akhauriyash/Code-Regression huggingface dataset:
#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;
#define ll long long
#define pp pair<ll,ll>
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin() , (x).end()
#define rep(i,a,b) for( ll i = a ; i < b ; i+=1 )
#define sz(v) (ll)(v.size())
#define hell (ll)1000000007
#define slld(x) scanf("%lld",&x)
typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> oset;
#define ld long double
ll t = 1, tt;
const ll N = 1000005;
inline ll add(ll x,ll y,ll mod){x+=y;return x%mod;}
inline ll mult(ll x,ll y,ll mod){ return (x*y)%mod;}
void solve(){
	ll n, ans=0, k;
	cin>>n>>k;
	vector<char> v(n+4);
	rep(i,1,n+1)
		cin>>v[i];
	if(k==2 || k==5){
		for(ll i=n;i>=1;i--)
			if((v[i]-'0')%k==0)ans+=i;
		cout<<ans;
	}
	else{
		map<ll,ll> mapa;
		mapa[0]++;
		vector<ll> dp(n+5,0);
		ll factor=1;
		for(ll i=n;i>=1;i--){
			dp[i]=add(dp[i+1],mult(factor,(v[i]-'0'),k),k);
			ans+=mapa[dp[i]];
			mapa[dp[i]]++;
			factor=mult(factor,10,k);
		}
		cout<<ans;
	}
}
signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
	//cin>>t;
	tt=t;
    while(t--){
        solve();
        if(t!=0)cout<<"\n";
    }
    return 0;
}


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

int main(){
  int n;
  cin >> n;
  bool flag=false;
  
  rep(i,26){
    rep(j,15){
      if(4*i+7*j==n) flag=true;
    }
  }
  
  if(flag) cout << "Yes" << endl;
  else cout << "No" << endl;
  
  return 0;
}


Measured memory_bytes: 256
N, X = map(int, input().split())
l = list(map(int, input().split()))

l.insert(0, X)
diff_list = [0] * (int(len(l)/2) + 1)

ans = abs(l[0] - l[1])
ix = 2

#a,bの最大公約数
def gcd(a,b):
    if b == 0:
        return a
    else:
        return gcd(b,a%b)

for i in l[1:len(l)-1]:
    tmp = abs(i - l[ix])
    ans = gcd(ans, tmp)
    ix += 1
print(ans)



Measured memory_bytes: 14228
n,k = map(int,input().split())

a = list(map(int,input().split()))

s = sum(a)

dlist = []
for p in range(1,int(s**(1/2))+1):
    if s % p == 0:
        dlist.append(p)
        dlist.append(int(s/p))

anslist = []

for d in dlist:
    r = [a[_] % d for _ in range(n)]
    r.sort()

    w = [r[0]]#累積和
    for i in range(1,n):
        w.append(w[-1]+r[i])
    
    can = "no"
    for j in range(0,n):
        if max(w[j],d*(n-j-1)-w[n-1]+w[j])<=k:
            can = "yes"
            break
    if can == "yes":
        anslist.append(d)

print(max(anslist))


Measured memory_bytes: 3192
#include<stdio.h>
#include<string.h>

int main(){
  int n,i;
  float money,total=0;
  char type[4];

  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%f %s",&money,type);
    if(strcmp(type,"BTC")==0) money*=380000.0;
  total+=money;
  }
    printf("%f\n",total);
    return 0;
  }

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

int main() {
	ios_base::sync_with_stdio(false);
	int n,mx=-400;
	cin>>n;
	
	int a[n+5];
	for(int i=0;i<n;i++){
		cin>>a[i];
		mx = max(mx, a[i]);
	}
	
	int ans = INT_MAX;
	for(int i=-100;i<=100;i++){
		int x=0;
		for(int j=0;j<n;j++){
			x += (i - a[j])*(i - a[j]);
		}
		ans = min(ans, x);
	}
	
	cout<<ans<<endl;
	
	return 0;
}

Measured memory_bytes: 256
class Main
{
    public static void main(String[] a)
    {
    	for (int i = 1; i <= 9; i++) {
    		for (int j = 1; j <= 9; j++) {
    			System.out.println(i + "x" + j + "=" + i * j);    			
    		}
    		
    	}
    }
}

Measured memory_bytes: 24272
#include <bits/stdc++.h>
using namespace std;
const int maxn=1e5+5;
char s[maxn];
int  is[maxn];
bool solve(int x, int y, int len)
{
      int i;
      is[0]=x;
      is[1]=y;
      for(i=2; i<=len+1; i++){
            if(is[i-1]){
                if(s[i-1]=='o')
                    is[i]=is[i-2];
                else
                    is[i]=!is[i-2];
            }
            else{  //前面的人说了假话
                if(s[i-1]=='o')
                    is[i]=!is[i-2];
                else
                    is[i]=is[i-2];
            }
      }
      /* for(i=0; i<len+2; i++)
       {
          printf(is[i]?"S":"W");
       }
       printf("\n");
       */
      if(is[len]== is[0] && is[len+1]==is[1]){
            for(i=0; i<len; i++){
                printf(is[i]?"S":"W");
            }
            printf("\n");
            return 1;
      }
      return 0;
}

int main()
{
   int n;
   scanf("%d", &n);
   int i;
   scanf("%s", s);
   int len=strlen(s);
   s[len]=s[0];
   s[len+1]=s[1];
   s[len+2]='\0';
   int j;
   for(i=0; i<2; i++)
   {
     for(j=0; j<2; j++)
     {
    if(solve(i, j, len))return 0;
     }
   }
   printf("-1\n");
}


Measured memory_bytes: 768
from functools import lru_cache
import sys
sys.setrecursionlimit(10 ** 7)

N = int(input())
MOD = 10**9 + 7

def isOk(T):
    for i in range(4):
        t = list(T)
        if i >= 1:
            t[i - 1], t[i] = t[i], t[i - 1]
        if 'AGC' in ''.join(t):
            return False
    return True

@lru_cache(maxsize=None)
def search(n, prev):
    if n == 0:
        return 1

    ret = 0
    for s in ['A', 'G', 'C', 'T']:
        t = (prev + s)[1:]
        if isOk(t):
            ret += search(n - 1, t)
            ret %= MOD

    return ret

print(search(N, 'ZZZZ'))

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

#define F first
#define S second
const long long mod = 1000000007;

int N, A[100], X, K;

int main() {
    //freopen("input.in","r",stdin);
    cin >> N;
    int maxi = 1, mini = 1;
    for(int i = 1;i <= N;i++) {
        cin >> A[i];
        if(A[i] > A[maxi]) maxi  = i;
        if(A[i] < A[mini]) mini  = i;
    }

    vector<pair<int, int> > ans;
    if(A[maxi] >= 0 and A[mini] < 0) {        
        if(A[maxi]+A[mini] >= 0) {
            for(int i = 1;i <= N;i++) {
                ans.push_back({maxi, i});
            }
        } else {
            for(int i = 1;i <= N;i++) {
                ans.push_back({mini, i});
            }
        }
    }

    maxi = mini = 1;
    for(auto t : ans) {
        A[t.S] += A[t.F];
    }
    for(int i = 1;i <= N;i++) {     
        if(A[i] > A[maxi]) maxi  = i;
        if(A[i] < A[mini]) mini  = i;
    }

    if(A[maxi] >= 0 and A[mini] >= 0) {        
        for(int i = 2;i <= N;i++) {
            ans.push_back({i-1, i});
        }        
    } else {
        for(int i = N-1;i >= 1;i--) {
            ans.push_back({i+1, i});
        }        
    }

    cout << ans.size() << endl;
    for(auto t : ans) {
        cout << t.F << " " << t.S << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;

int n, m, x, y, u[200105];
vector<int> g[200105];
queue<pii> q;

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

    cin >> n >> m;
    while (m--) {
        cin >> x >> y;
        g[x].push_back(y);
        g[y].push_back(x);
    }
    q.push(make_pair(1, 0));
    while (q.size()) {
        int curv = q.front().first;
        int curd = q.front().second;
        q.pop();
        if (u[curv] || curd > 2) continue;
        u[curv] = curd + 1;
        for (int to : g[curv])
            q.push(make_pair(to, curd + 1));
    }
    puts(u[n] ? "POSSIBLE" : "IMPOSSIBLE");

    return 0;
}


Measured memory_bytes: 14192
#include<bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define rrep(i,n) for(int i=1,i##_len=(n); i<=i##_len; ++i)
#define drep(i,n) for(int i=(n)-1; i>=0; --i)
#define srep(i,s,t) for(int i=(s);i<(t);++i)
#define rng(obj) (obj).begin(), (obj).end()
#define maxs(x,y) (x=max((x),(y)))
#define mins(x,y) (x=min((x),(y)))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x=max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T>>
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) vector<vector<T>>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using uint = unsigned int;
using P = pair<int,int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vp = vector<P>;
template <class T> inline istream& operator>>(istream&i,v(T)&v)
{ rep(j,sz(v))i>>v[j];return i;}
template <class T> string join(const v(T)&v)
{ stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template <class T> inline ostream& operator<<(ostream&o,const v(T)&v)
{ if(sz(v))o<<join(v); return o;}
template <class T1,class T2> inline istream& operator>>(istream&i ,pair<T1,T2>&v)
{ return i>>v.fi>>v.se;}
template <class T1,class T2> inline ostream& operator<<(ostream&o ,pair<T1,T2>&v)
{ return o<<v.fi<<","<<v.se;}
template <class T> inline ll suma(const v(T)& a) 
{ ll res(0); for(auto&& x:a) res += x; return res;}
const int INF = 1001001001;
const ll LINF = 1001002003004005006ll;
const double eps = 1e-10;
#define dame {puts("-1"); return 0;}
#define yn {puts("YES");}else{puts("NO");}
const int MX = 200005;
#define fileio ifstream fio; if(argc>=2){fio.open(argv[1]); std::cin.rdbuf(fio.rdbuf());}
#define fastio ios_base::sync_with_stdio(false);
//----------------------------------------------------------------
void Main(){
  int n;
  cin>>n;
  ll p,q;
  cin>>p>>q;
  rep(i,n-1){
    ll a,b;
    cin>>a>>b;
    ll ap  = a*dup(p,a);
    ll apb = ap/a*b;
    ll bq  = b*dup(q,b);
    ll bqa = bq/b*a;
    ll la = (apb>=q? apb-q + ap-p:LINF);
    ll lb = (bqa>=p? bqa-p + bq-q:LINF);
    if( la < lb ){p = ap ;q = apb;}
    else         {p = bqa;q = bq; }
  }
  cout<<p+q<<endl;
} int main(int argc,char* argv[]){ 
    fastio; fileio; Main();}

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

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    string s;
    cin>>s;
    ll mi=2019;
    int n=s.length();
    ll ans=0;
    vector<ll> dp(2019);
    for(int i=0;i<n;i++)
    {
        vector<ll> td(2019);
        int num=s[i]-'0';
        td[num]=1;
        for(int j=0;j<2019;j++)
        {
            if(dp[j]>0){
                ll rem=((10*j)%mi+num)%mi;
                if(rem==0) ans+=dp[j];
                td[rem]+=dp[j];
            }
        }
        for(int j=0;j<2019;j++) dp[j]=td[j];
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 3732
def gcd(*nums)
	return nums.inject do |a, b|
		a, b = b, a % b until b.zero?
		a
	end
end

def lcm(*nums)
	return nums.inject {|a, b| a * b / gcd(a, b)}
end

$<.each_line do |line|
	a, b = line.split.map(&:to_i)
	puts "#{gcd(a, b)} #{lcm(a, b)}"
end

Measured memory_bytes: 6096
#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
using ll = long long;

int main() {
    int N, M;
    cin >> N >> M;
    vector<int>A(N);
    vector<pair<int,int>>BC(M);
    for (int i = 0; i < N; ++i) {
        cin >> A[i];
    }
    for (int i = 0; i < M; ++i) {
        int bb, cc;
        cin >> bb >> cc;
        BC[i] = make_pair(cc,bb);
    }
    sort(A.begin(), A.end());
    sort(BC.begin(), BC.end(), greater<pair<int,int>>());
    int x = 0;
    for (int i = 0; i < M; ++i) {
        for (int j = 0; j < BC[i].second; ++j) {
            if(A[x] < BC[i].first){
                A[x] = BC[i].first;
                x++;
                if(x >= N) break;
            }else{
                break;
            }
        }
        if(x >= N) break;
    }

    ll ans = 0;
    for (int i = 0; i < N; ++i) {
        ans += A[i];
    }
    cout << ans;
    return 0;
}

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

int h, w;
char b[200][200];
int pri[200][200];
int sol[200][200];
queue<int> que;
int dh[4] = {0,1,0,-1};
int dw[4] = {1,0,-1,0};

int main(){
    cin >> h >> w;
    rep(i,h) rep(j,w) cin >> b[i][j];
    rep(i,h) rep(j,w){
        pri[i][j] = INF;
        sol[i][j] = INF;
    }
    rep(i,h) rep(j,w){
        if(b[i][j] == '$'){
            que.push(i*200+j);
            sol[i][j] = 0;
        }
    }
    while(!que.empty()){
        int q = que.front();
        que.pop();
        int hh = q/200, ww = q%200;
        rep(i,4){
            int y = q/200+dh[i], x = q%200+dw[i];
            if(0>y||y>=h||0>x||x>=w) continue;
            if(sol[y][x] <= sol[hh][ww]+1) continue;
            if(b[y][x] == '#') continue;
            sol[y][x] = sol[hh][ww]+1;
            que.push(y*200+x);
        }
    }
    rep(i,h) rep(j,w){
        if(b[i][j] == '@'){
            que.push(i*200+j);
            pri[i][j] = 0;
        }
    }
    while(!que.empty()){
        int q = que.front();
        que.pop();
        int hh = q/200, ww = q%200;
        rep(i,4){
            int y = hh+dh[i], x = ww+dw[i];
            if(0>y||y>=h||0>x||x>=w) continue;
            if(pri[y][x] <= pri[hh][ww]+1) continue;
            if(sol[y][x] <= pri[hh][ww]+1) continue;
            if(b[y][x] == '#') continue;
            pri[y][x] = pri[hh][ww]+1;
            que.push(y*200+x);
        }
    }
    rep(i,h) rep(j,w){
        if(b[i][j] == '%'){
            if(pri[i][j] != INF){
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    cout << "No" << endl;
}

Measured memory_bytes: 3588
#define rep(i,a,b) for (int i = (a); i < (b); i++)
#define _USE_MATH_DEFINES
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <functional>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include <math.h>
#include <complex>
#include <cassert>
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> p;
typedef complex<double> com;
const int mod = 1e9 + 7;
const int MOD = 998244353;
const ll INF = 1e18;


int main() {
	int n; cin >> n;
	vector<int> c(n), s(n), f(n);
	rep(i, 0, n-1) cin >> c[i] >> s[i] >> f[i];
	rep(i, 0, n) {
		int ans = 0;
		rep(j, i, n - 1) {
			if (ans < s[j]) ans = s[j];
			else if (ans % f[j] == 0);
			else ans+= (f[j] - ans % f[j]);
			ans += c[j];
		}
		cout << ans << endl;
	}
	return 0;
}

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

int main(){
  int N;
  cin >> N;
  int ans = 1;
  int check = 0;
  for(int i = 0; i <= N; i++){
    int count = 0;
    int j = i;
    while(j % 2 == 0 && j > 1){
      count++;
      j = j / 2;
    }
	if(check < count){
      ans = i;
      check = count;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cstdlib>
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; }

const long long INF = 1LL << 60;

// 入力
int N, K;
long long h[100010];

// DP テーブル
long long dp[100010];

int main() {
    cin >> N >> K;
    for (int i = 0; i < N; ++i) cin >> h[i];

    // 初期化 (最小化問題なので INF に初期化)
    for (int i = 0; i < 100010; ++i) dp[i] = INF;

    // 初期条件
    dp[0] = 0;

    // ループ
    for (int i = 1; i < N; ++i) {
        for(int j = 0; j < min(K, i); j++){
            chmin(dp[i], dp[i - 1 - j] + abs(h[i] - h[i - 1 - j]));
        }
    }

    // 答え
    cout << dp[N-1] << endl;
    return 0;
}

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

using namespace std;

#define x first
#define y second
#define mp make_pair
#define pb push_back
#define sqr(a) ((a) * (a))
#define sz(a) int(a.size())
#define all(a) a.begin(), a.end()
#define forn(i, n) for(int i = 0; i < int(n); i++) 
#define fore(i, l, r) for(int i = int(l); i < int(r); i++)

typedef long long li;
typedef long double ld;
typedef pair<int, int> pt;

template <class A, class B> ostream& operator << (ostream& out, const pair<A, B> &a) {
	return out << "(" << a.x << ", " << a.y << ")";
}

template <class A> ostream& operator << (ostream& out, const vector<A> &v) {
	out << "[";
	forn(i, sz(v)) {
		if(i) out << ", ";
		out << v[i];
	}
	return out << "]";
}

mt19937 rnd(time(NULL));

const int INF = int(1e9);
const li INF64 = li(9e18);
const int MOD = int(1e9) + 7;
const ld EPS = 1e-9;
const ld PI = acos(-1.0);

li n;
int a[3], b;

bool read () {
	if (scanf("%lld%d%d%d%d", &n, &a[0], &a[1], &a[2], &b) != 5)
		return false;
	return true;
}

int nums[] = {2, 3, 5};

void solve() {	
	map<li, li> d;
	d[n] = 0;
	set<pair<li, li>> q;
	q.insert(mp(d[n], n));
	while (!q.empty()){
		li x = q.begin()->y;
		q.erase(q.begin());
		if (x == 0){
			printf("%lld\n", d[x]);
			return;
		}
		forn(i, 3){
			li nx = x / nums[i];
			li c = d[x] + b * (x % nums[i]) + a[i];
			if (!d.count(nx) || d[nx] > c){
				auto it = q.find(mp(d[nx], nx));
				if (it != q.end())
					q.erase(it);
				d[nx] = c;
				q.insert(mp(d[nx], nx));
			}
		}
		forn(i, 3){
			li nx = x / nums[i] + 1;
			li c = d[x] + b * (nums[i] - x % nums[i]) + a[i];
			if (!d.count(nx) || d[nx] > c){
				auto it = q.find(mp(d[nx], nx));
				if (it != q.end())
					q.erase(it);
				d[nx] = c;
				q.insert(mp(d[nx], nx));
			}
		}
		if (x < INF64 / b){
			li nx = 0;
			li c = d[x] + x * b;
			if (!d.count(nx) || d[nx] > c){
				auto it = q.find(mp(d[nx], nx));
				if (it != q.end())
					q.erase(it);
				d[nx] = c;
				q.insert(mp(d[nx], nx));
			}
		}
	}
}

int main() {
#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);
	
	int tt = clock();
#endif
	
	cerr.precision(15);
	cout.precision(15);
	cerr << fixed;
	cout << fixed;

	int tc;
	scanf("%d", &tc);
	while (tc--){
		read();
		solve();
		
#ifdef _DEBUG
	cerr << "TIME = " << clock() - tt << endl;
	tt = clock();
#endif

	}
}

Measured memory_bytes: 4888
using System;
using System.Linq;
using System.Collections.Generic;
public class Hello
{

    public static void Main()
    {
        int N = int.Parse(Console.ReadLine());
        string[] s = Console.ReadLine().Split(' ');
        int[] num = Array.ConvertAll<string, int>(s, delegate (string value) { return int.Parse(value); });
        Array.Sort(num);

        Console.WriteLine(num[N-1] - num[0]);

    }
}

Measured memory_bytes: 11220
L=[int(input()) for _ in range(5)]
sum=0
modL=[(L[i]-1)%10 for i in range(5)]
last = modL.index(min(modL))
for i in range(5):
    if L[i]%10==0:
        sum += L[i]
    else:
        sum += (int(L[i]//10)+1)*10
if L[last]%10!=0:
    sum -= 10 - L[last]%10
print(sum)

Measured memory_bytes: 3064
#include <iostream>
#include <fstream>
#include <sstream>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>

#include <vector>
#include <cstring>
#include <queue>
#include <map>
#include <set>

#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>

using namespace std;

typedef vector<int> vi; 
typedef vector<vi> vvi;
typedef vector<string> vs;
#define sz(a) int((a).size()) 
#define pb push_back 
#define all(c) (c).begin(),(c).end() 
#define rep(i, n) for(int i = 0; i < n; ++i) 
#define foreach(it, c) for(__typeof((c).begin()) it = (c).begin(); it != (c).end(); ++it) 

#define TRACE(x...) x
#define watch(x) TRACE(cout << #x" = " << x << endl)
#define watcharr(i, x) TRACE(cout << #x" = "); rep(i, sz(x)) cout << x[i] << " "; cout << endl

int main() {
	
	ifstream infile("input.in");
	if(infile.good()) cin.rdbuf(infile.rdbuf());
	
	long long X;
    cin >> X;

    long long n = 100, c = 0;
    while(n < X) {
        n *= 1.01;
        c++;
    }

    cout << c << endl;
	
	if(infile.good()) infile.close();
	return 0;
	
}



Measured memory_bytes: 3640
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

#define mod 10e9+7
#define ll long long int

long long int xor(long long int x, long long int y){
    long long int x2len = floor(log2(x)) + 1;
    long long int y2len = floor(log2(y)) + 1;
    long long int len;
    if(x2len > y2len) len = x2len;
    else len = y2len;
    long long int z = 0;
    for(int i = 0;i < len;i++){
        z += pow(2, i) * ((x%(long long int)pow(2,i+1) >= pow(2, i))!=(y%(long long int)pow(2,i+1) >= pow(2, i)));
    }
    return z;
}

int main(void){
    int a, b, c;
    scanf("%d %d %d", &a, &b, &c);
    if(a < c || b < c)printf("%d\n", a*b/2);
    else if(b < a || c < a)printf("%d\n", b*c/2);
    else printf("%d\n", c*a/2);
    return 0;
}

Measured memory_bytes: 128
#include<iostream>
using namespace std;
#include<cstdio>
typedef long long LL;
LL a[1000];
int main()
{
	int n;
	LL sum=0;
	while(cin>>n)
	{
		sum=0;
		for (int i=1;i<=n;i++)
		{
			cin>>a[i];
			sum+=a[i];
		}
		if (sum%n==0)
		{
			LL p=sum/n;
			LL ans=0;
			for (int i=1;i<=n;i++)
			{
				ans+=(a[i]-p)*(a[i]-p);
			}
			cout<<ans<<endl;
		}
		else
		{
			LL p1=sum/n,p2=sum/n+1;
			LL ans,ans1=0,ans2=0;
			for (int i=1;i<=n;i++)
			{
				ans1+=(a[i]-p1)*(a[i]-p1);
				ans2+=(a[i]-p2)*(a[i]-p2);
			}
			if (ans1<ans2) ans=ans1;
			else
			ans=ans2;
			cout<<ans<<endl;
		}
	}
	return 0;
}

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

#define ms(s, n) memset(s, n, sizeof(s))
#define f(i, a, b) for (int i = (a); i <=(b); i++)
#define FORd(i, a, b) for (int i = (a) - 1; i >= (b); i--)
#define FORall(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
#define sz(a) int((a).size())
#define present(t, x) (t.find(x) != t.end())
#define all(a) (a).begin(), (a).end()
#define uni(a) (a).erase(unique(all(a)), (a).end())
#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second
#define prec(n) fixed<<setprecision(n)
#define bit(n, i) (((n) >> (i)) & 1)
#define bitcount(n) __builtin_popcountll(n)
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pi;
typedef vector<ll> vi;
typedef vector<pi> vii;
const int MOD = (int) 1e9 + 7;
const int MOD2 = MOD + 2; //1007681537;
const int INF = (int) 1e9;
const ll LINF = (ll) 1e18;
const ld PI = acos((ld) - 1);
const ld EPS = 1e-9;
inline ll gcd(ll a, ll b) {ll r; while (b) {r = a % b; a = b; b = r;} return a;}
inline ll lcm(ll a, ll b) {return a / gcd(a, b) * b;}
inline ll fpow(ll n, ll k, int p = MOD) {ll r = 1; for (; k; k >>= 1) {if (k & 1) r = r * n % p; n = n * n % p;} return r;}
template<class T> inline int chkmin(T& a, const T& val) {return val < a ? a = val, 1 : 0;}
template<class T> inline int chkmax(T& a, const T& val) {return a < val ? a = val, 1 : 0;}
inline ll isqrt(ll k) {ll r = sqrt(k) + 1; while (r * r > k) r--; return r;}
inline ll icbrt(ll k) {ll r = cbrt(k) + 1; while (r * r * r > k) r--; return r;}
inline void addmod(int& a, int val, int p = MOD) {if ((a = (a + val)) >= p) a -= p;}
inline void submod(int& a, int val, int p = MOD) {if ((a = (a - val)) < 0) a += p;}
inline int mult(int a, int b, int p = MOD) {return (ll) a * b % p;}
inline int inv(int a, int p = MOD) {return fpow(a, p - 2, p);}
inline int sign(ld x) {return x < -EPS ? -1 : x > +EPS;}
inline int sign(ld x, ld y) {return sign(x - y);}
int modulo(int a, int b) { return (a % b + b) % b; }
#define db(x) cerr << #x << " = " << (x) << " ";
#define endln cerr << "\n";

int main()
{
	IOS;
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	string s;
	cin >> s;
	ll sum = 0;
	for (auto x : s) {
		sum += x - '0';
	}
	cout << (sum % 9 ? "No\n" : "Yes\n");
	// read the stuff at the bottom
	return 0;
}
/* stuff you should look for
	* int overflow, array bounds
	* special cases (n=1?)
	* do smth instead of nothing and stay organized
	* WRITE STUFF DOWN
	* use int when constraints limits are tight
	* Time taken : global variable < pass by refernce < pass by value
	* It takes significant amt. of time in pass by value
*/





























Measured memory_bytes: 3780
import itertools
N, K = map(int, input().split())
S = input()
flg = int(S[0])
gr = itertools.groupby(S)
ans, tmp = 0, 0
check_0, check_1 = [], []
for key, group in gr:
    target = len(list(group))
    tmp += target
    if key == '1':
        check_1.append(target)
    else:
        check_0.append(target)
    if key == '0':
        if len(check_0) > K:
                tmp -= check_0[len(check_0)-(K+1)]
        if len(check_1) > K:
                tmp -= check_1[len(check_1)-(K+1)]
    ans = max(ans,tmp)
print(ans)

Measured memory_bytes: 4168
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define rrep(i,n) for(int i=1;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define dunk(a) cout << (a) << endl
using namespace std;
typedef long long ll;
const int inf = 1001001001;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	vector<int> a(3);
	rep(i, 3) cin >> a[i];
	if (a[0] == a[1] && a[1] != a[2]) puts("Yes");
	else if (a[1] == a[2] && a[1] != a[0]) puts("Yes");
	else if (a[0] == a[2] && a[0] != a[1]) puts("Yes");
	else puts("No");
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		int c = sc.nextInt();
		int[] b = new int[m];
		for(int i = 0; i < m; i++){
			int bi = sc.nextInt();
			b[i] = bi;
		}
		int cnt = 0;
		for(int i = 0; i < n; i++){
			int sum = 0;
			for(int j = 0; j < m; j++){
				int a = sc.nextInt();
				sum += (a*b[j]);
			}
			if(sum + c > 0){
				cnt++;
			}
		}
		System.out.println(cnt);
	}
}

Measured memory_bytes: 23892
#include <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(int)(a); (i)<(int)(b); ++(i))
#define rFor(i, a, b) for(int (i)=(int)(a)-1; (i)>=(int)(b); --(i))
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
#define fi first
#define se second
#define double long double
using namespace std;
typedef long long lint;
typedef unsigned long long ulint;
typedef pair<int, int> pii;
typedef pair<lint, lint> pll;
template<class T> bool chmax(T &a, const T &b){if(a<b){a=b; return true;} return false;}
template<class T> bool chmin(T &a, const T &b){if(a>b){a=b; return true;} return false;}
template<class T> T div_floor(T a, T b){
    if(b < 0) a *= -1, b *= -1;
    return a>=0 ? a/b : (a+1)/b-1;
}
template<class T> T div_ceil(T a, T b){
    if(b < 0) a *= -1, b *= -1;
    return a>0 ? (a-1)/b+1 : a/b;
}

constexpr lint mod = 1e9+7;
constexpr lint INF = mod * mod;
constexpr int MAX = 200010;

int main(){
    lint n;
    scanf("%lld", &n);
    printf("%lld\n", n*(n-1)/2);
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include<algorithm>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<iostream>
#include<vector>
#include<queue>
#include<deque>
#include<stack>
#include<set>
#include<map>
#include<string>
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define rep2(i,s,n) for(int i=s;i< (int)n; i++)
#define ll long long 
#define all(v) v.begin(),v.end()
using namespace std;
int main(){
  ll a;cin >>a;
  double long b; cin >>b;
  double long s=a*b;
  ll ans  = (ll)s;
  cout <<ans<<endl;
}

Measured memory_bytes: 3724
package main

import "fmt"

func main() {
	var a, b, x int
	fmt.Scan(&a, &b, &x)
	fmt.Println(between(a, b, x))
}

func between(a, b, x int) int {
	if a <= 0 {
		return b/x + 1
	}
	return b/x - (a-1)/x
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long
#define ld long double
 
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
 
template <typename T> using oset = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
 
string to_string(char c) {
	return string(1, c);
}
string to_string(bool b) {
	return b ? "true" : "false";
}
string to_string(const char* s) {
	return string(s);
}
string to_string(string s) {
	return s;
}
string to_string(vector<bool> v) {
	string res;
	for(int i = 0; i < (int) v.size(); i++)
		res += char('0' + v[i]);
	return res;
}
 
template<size_t S> string to_string(bitset<S> b) {
	string res;
	for(int i = 0; i < S; i++)
		res += char('0' + b[i]);
	return res;
}

template<class T> string to_string(T v) {
    bool f = 1;
    string res;
    for(auto& x : v) {
		if(!f)
			res += ' ';
		f = 0;
		res += to_string(x);
	}
    return res;
}
 
void DBG() {
	cerr << "]" << endl;
}

template<class H, class... T> void DBG(H h, T... t) {
	cerr << to_string(h);
	if(sizeof...(t))
		cerr << ", ";
	DBG(t...);
}

#ifdef _DEBUG
#define dbg(...) cerr << "LINE(" << __LINE__ << ") -> [" << #__VA_ARGS__ << "]: [", DBG(__VA_ARGS__)
#else
#define dbg(...) 0
#endif

const int d4i[4] = {-1, 0, 1, 0}, d4j[4] = {0, 1, 0, -1};
const int d8i[8] = {-1, -1, 0, 1, 1, 1, 0, -1}, d8j[8] = {0, 1, 1, 1, 0, -1, -1, -1};

void solve() {
	int n;
	cin >> n;
	vector<int> a(n);
	bool b1 = 0;
	for(auto& it: a) cin >> it;
	vector<int> vis(1e6+1);
	for(int i = 0; i < n && !b1; i++){
		for(int j = 1; j <= sqrt(a[i]); j++){
			vis[0] = vis[1] = 0;
			if(a[i] % j == 0){
				if(vis[j] || vis[a[i] / j]){
					b1 = 1;
					break;
				}
				else {
					vis[j] = vis[a[i] / j] = 1;
				}
			}
		}
	}
	int gcd = a[0];
	if(b1){
		for(int i = 1; i < n; i++){
			gcd = __gcd(gcd, a[i]);
			if(gcd == 1) break;
		}
	}
	if(!b1) cout << "pairwise coprime\n";
	else if(gcd == 1) cout << "setwise coprime\n";
	else cout << "not coprime\n";
}	
 
int main() {
	
	ios::sync_with_stdio(0);
	cin.tie(0);
 	
	int t = 1;
	//cin >> t;
	for(int i = 1; i <= t; i++) {
		//cout << "Case #" << i << ": ";
		solve();
	}
}

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

// region template
#define rep(i, a, b) for (int i = (a); i < (b); ++i)
#define trav(a, x) for (auto &a : x)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;

ll gcd(ll a, ll b) { return __gcd(a, b); }

ll euclid(ll a, ll b, ll &x, ll &y) {
    if (b) { ll d = euclid(b, a % b, y, x);
        return y -= a/b * x, d; }
    return x = 1, y = 0, a;
}

typedef unsigned long long ull;
typedef long double ld;
ull mod_mul(ull a, ull b, ull M) {
    ll ret = a * b - M * ull(ld(a) * ld(b) / ld(M));
    return ret + M * (ret < 0) - M * (ret >= (ll)M);
}
ull mod_pow(ull b, ull e, ull mod) {
    ull ans = 1;
    for (; e; b = mod_mul(b, b, mod), e /= 2)
        if (e & 1) ans = mod_mul(ans, b, mod);
    return ans;
}

const ll mod = 1000000007;
struct Mod {
    ll x;
    Mod(ll xx) : x(xx) {}
    Mod operator+(Mod b) { return Mod((x + b.x) % mod); }
    Mod operator-(Mod b) { return Mod((x - b.x) % mod); }
    Mod operator*(Mod b) { return Mod((x * b.x) % mod); }
    Mod operator/(Mod b) { return *this * invert(b); }
    Mod invert(Mod a) {
        ll x, y, g = euclid(a.x, mod, x, y);
        assert(g == 1); return Mod((x + mod) % mod);
    }
    Mod operator^(ll e) {
        if (!e) return Mod(1);
        Mod r = *this ^ (e / 2); r = r * r;
        return e & 1 ? *this * r : r;
    }
};
// endregion

int main() {
    cin.sync_with_stdio(0); cin.tie(0); cin.exceptions(cin.failbit);

    int a, b;
    cin >> a >> b;
    if ((a + 1) / 2 >= b) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }
}

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

const int table[] = {-1, 6000, 4000, 3000, 2000};

int main()
{
	for (int i = 0; i < 4; i++){
		int t, n;
		scanf("%d %d", &t, &n);
		printf("%d\n", table[t] * n);
	}
}

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

typedef long long int lli;
typedef unsigned long long int ulli;
typedef pair<int,int> pii;

#define ones(x) __builtin_popcount(x)
#define onesl(x) __builtin_popcountl(x)
#define onesll(x) __builtin_popcountll(x)

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#define scn(n) scanf("%d",&n)
#define scnll(n) scanf("%lld",&n)
#define scn2(n,m) scanf("%d%d",&n,&m)
#define scn3(n,m,w) scanf("%d%d%d",&n,&m,&w)
#define scn2ll(n,m) scanf("%lld%lld",&n,&m)
#define atoz(v) v.begin(),v.end()
#define ratoz(v) v.rbegin(),v.rend()
#define Fill(a,v) memset(a,v,sizeof(a))
#define sz(v) v.size()
#define fi first
#define se second
#define inf 1e9
#define pi acos(-1.0)
#define sqr(x) x*x
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define ten(n) (int)1e##n
#define tenll(n) (lli)1e##n
#define mod 1000000007
#define FastIO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

int Set(int N,int pos)
{
    return N=N | (1<<pos);
}
int reset(int N,int pos)
{
    return N = N & ~(1<<pos);
}
bool check(int N,int pos)
{
    return (bool)(N & (1<<pos));
}

///priority_queue< int, vector< int >, greater< int > > minHeap;

void mor(){cout<<"NO"; exit(0);}

bool dp[2][2003][2002];

int ans = 0;
int n, val[2003];


int main()
{
    ///freopen("output.txt","w",stdout);
    ///freopen("input.txt","r",stdin);

    ///FastIO;

    int a,b;
    scn3(n,a,b);

    for(int i=1; i<=n; i++){
        scn(val[i]);
    }


    ans = abs(val[n]-b);
    if(n>1)ans = max(ans , abs(val[n]-val[n-1]));
cout<<ans;
    return 0;
    ///return main();
}

///sin and cos expect input in radians not degrees. so use , sin(degrees * pi / 180)


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

int ans = INT_MAX;
string org;
bool mark[26];
bool valid(string s, int k) {
	assert(!s.empty());
	bool ret = true;
	for(char c: s) ret &= (c-'a') == k;
	return ret;
}
int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin >> org;
	for(char c: org) mark[c-'a'] = true;
	for(int k = 0; k < 26; k++) if(mark[k]) {
		string s = org;
		int res = 0;
		while(!valid(s, k)) {
			++res;
			for(int i = 0; i < s.length()-1; i++) {
				if(s[i+1]-'a' == k) s[i] = s[i+1];
			}
			s.pop_back();
		}
		ans = min(res, ans);
	}
	cout << ans;
}

Measured memory_bytes: 256
#include <algorithm>
#include <climits>
#include <cmath>
#include <iostream>

using namespace std;

const int NMAX = 1e5 + 11;

int  n, k, h[NMAX], mem[NMAX];
bool vis[NMAX];

inline int dh(int i, int j) { return (int)abs(h[i] - h[j]); }

int dp(int i)
{
    int &ans = mem[i];

    if (i == n - 1)
        return 0;
    if (vis[i])
        return ans;

    vis[i] = true;
    ans    = INT_MAX;
    for (int j = i + 1; j <= i + k; ++j)
        if (j < n)
            ans = min(ans, dp(j) + dh(i, j));

    return ans;
}

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

    cout << dp(0) << endl;
    return 0;
}


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

#define int long long
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define all(v) (v).begin(),(v).end()
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

struct node{
    int val,sum;
    node *to[10];

    node(){
        val=sum=0;
        rep(i,10)to[i]=NULL;
    }
};

int A,B,P;

void insert(node *t,string &s,int i,int v){
    if(i==s.size()){
        t->val=v;
        t->sum=(t->sum+v)%P;
        return;
    }

    int c=s[i]-'0';
    if(t->to[c]==NULL){
        t->to[c]=new node();
    }
    t->sum=(t->sum-t->to[c]->sum+P)%P;
    insert(t->to[c],s,i+1,v);
    t->sum=(t->sum+t->to[c]->sum)%P;
}

int query(node *t,string &s,int i){
    int ret=0;
    int c=s[i]-'0';
    for(int j=0;j<c;j++)if(t->to[j]!=NULL)ret=(ret+t->to[j]->sum)%P;
    ret=(ret+t->val)%P;
    if(t->to[c]!=NULL)ret=(ret+query(t->to[c],s,i+1))%P;
    return ret;
}

void del(node *t){
    rep(i,10)if(t->to[i]!=NULL)del(t->to[i]);
    delete t;
}

signed main(){
    while(cin>>A>>B>>P,A||B||P){
        int ans=0;
        node *root=new node();
        for(int i=A;i<=B;i++){
            stringstream ss;
            ss<<i;
            string s=ss.str();
            int tmp=(query(root,s,0)+1)%P;
            ans=(ans+tmp)%P;
            insert(root,s,0,tmp);
        }
        cout<<ans<<endl;

        del(root);
    }
    return 0;
}

Measured memory_bytes: 13364
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <functional>
#include <cmath>
using namespace std;

bool isPrime[100001];
vector<int> prime;
vector<pair<int, pair<int, int> > > v;

void makePrime() {
  int lim = 100000/2+1;
  fill(isPrime, isPrime+lim, true);
  isPrime[0] = isPrime[1] = false;
  for(int i = 2; i < lim; ++i) {
    if(isPrime[i]) {
      prime.push_back(i);
      for(int j = i*2; j < lim; j += i) isPrime[j] = false;
    }
  }
}

void make2() {
  for(int i = 0; i < prime.size(); ++i) {
    for(int j = i; j < prime.size() && prime[i]*prime[j] < 100000; ++j) {
      v.push_back(make_pair(prime[i]*prime[j], make_pair(prime[i], prime[j])));
    }
  }
  sort(v.begin(), v.end());
}

int main() {
  makePrime();
  make2();
  int m, a, b;
  while((cin >> m >> a >> b) && (m || a || b)) {
    /*vector<pair<int, pair<int, int> > >::iterator it =
      upper_bound(v.begin(), v.end(), make_pair(m, make_pair(0, 0)));*/
    for(int i = v.size()-1; i >= 0; --i) {
      if(v[i].first > m) continue;
      int p = v[i].second.first;
      int q = v[i].second.second;
      if(a*q <= b*p && b*p <= b*q) {
	cout << p << " " << q << endl;
	break;
      }
    }
  }
}

Measured memory_bytes: 2108
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll n,a,b,ans=1;
map<ll,ll> mp;
int main(void){
    cin>>n>>a;
    b=a;
    for(ll i=2;i*i<=b;i++){
        if(a==1)break;
        while(a%i==0){
            a/=i;
            mp[i]++;
        }
    }
    mp[a]++;
    for(auto x:mp){
        if(x.second>=n){
            for(int i=0;i<(x.second/n);i++)ans*=x.first;
        }
    }
    cout<<ans<<endl;
}


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

string s;
long long k;
set<string> skup;

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

    cin>>s;
    cin>>k;
    long long n=s.size();
    for(long long q=1;q<=k;q++)
    {
        long long j=0;
        string boban="";
        if(j+q-1>=n)
            break;
        else
        {
            for(int i=0;i<q;i++)
                boban+=s[i];
        }
        skup.insert(boban);

        for(j=1;j+q-1<n;j++)
        {
            boban.erase(0,1);
            boban+=s[j+q-1];
            skup.insert(boban);
        }
    }
    long long br=0;
    for(auto u: skup)
    {
        br++;
        if(br==k)
        {
            cout<<u<<endl;
            break;
        }
    }

    return 0;
}


Measured memory_bytes: 4804
N = int(input())
cnt = 0
BX = 0
BA = 0
XA = 0
for _ in range(N):
    S = input()
    for i in range(1, len(S)):
        if S[i - 1] == 'A' and S[i] == 'B':
            cnt += 1
    if S[0] == 'B' and S[-1] == 'A':
        BA += 1
    elif S[0] == 'B':
        BX += 1
    elif S[-1] == 'A':
        XA += 1

if BA > 0:
    cnt += BA - 1
    if BX > 0:
        cnt += 1
        BX -= 1
    if XA > 0:
        cnt += 1
        XA -= 1
cnt += min(XA, BX)
print(cnt)

Measured memory_bytes: 50152
#include<bits/stdc++.h>
#define SORT(v) sort(v.rbegin() , v.rend())
#define si(n) scanf( "%d" , &n)
#define sii(n , m) scanf( "%d %d" , &n , &m)
#define sl(n) scanf( "%lld" , &n)
#define sll(n , m) scanf( "%lld %lld" , &n, &m)
#define ss(cad) scanf( "%s" , cad)
#define sz(x) (int)x.size()
#define PB push_back
#define fst first
#define scn second
#define DBG(x) cerr << #x << " = " << (x) << endl
#define M 1000000007
#define N_MAX 1000010
#define EPS 1e-9

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<bool> vb;
typedef vector<ll> vll;
typedef pair<int,int> pi;
typedef pair<ll,ll> pll;
typedef vector<pi> vp;

int cb[1000100];
void criba(){
	for(int i = 2; i*i <= 1000000; i++){
		if(cb[i])
			continue;
		for(int j = i*i; j <= 1000000; j+=i)
			if(cb[j] == 0)
				cb[j] = i;
	}
}

int vec[1001000];
bool frec[1001000];

int main(){
	criba();
	int n;
	si(n);
	int gcd = 0;
	for(int i = 0; i < n; i++){
		si(vec[i]);
		if(gcd == 0)
			gcd = vec[i];
		else
			gcd = __gcd(gcd, vec[i]);
	}
	bool sw = 1;
	for(int i = n-1; i >= 0; i--){
		int tmp = vec[i];
		while(cb[tmp] != 0){
			int f = cb[tmp];
			//cout << 
			//frec[f] = 1;
			while(tmp%f == 0){
				tmp /= f;
			}
			if(frec[f] == 0)
				frec[f] = 1;
			else
				sw = 0;
		}

		if(tmp != 1){
			//cout << tmp << endl;
			if(frec[tmp] == 0)
				frec[tmp] = 1;
			else
				sw = 0;
		}

		if(sw == 0)
			break;
	}
	if(sw)
		printf("pairwise coprime\n");
	else if(gcd == 1)
		printf("setwise coprime\n");
	else
		printf("not coprime\n");
	
    return 0;
}

Measured memory_bytes: 11444
N,K=map(int, input().split())
A=list(map(int, input().split()))
ball={}
result=0
for i in range(N):
  if A[i] in ball.keys():
    ball[A[i]]+=1
  else:
    ball[A[i]]=1
sorted_ball = sorted(list(ball.values()))
if len(sorted_ball) > K:
  for i in range(len(sorted_ball)-K):
    result+=sorted_ball[i]
print(result)

Measured memory_bytes: 33152
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<deque>
using namespace std;
#define ll long long
const int mod = 1000000007;
const ll INF = 1000000000000000000;


int main()
{
	int N, K;
	cin >> N >> K;
	ll zero = 0, half = 0;
	for (int i = 1; i <= N; i++) {
		if (i % K == 0) zero++;
		if (i % K == K / 2) half++;
	}
	if (K % 2 == 0) cout << zero * zero * zero + half * half * half << endl;
	else cout << zero * zero * zero << endl;
}


Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,m,k,i,j;
    cin>>n>>m>>k;
    bool flag=false;
    if(k==0)flag=true;
    for(i=0;i<=n;i++)
	  for(j=0;j<=m;j++){
    	  if(m*i+n*j-2*i*j==k)flag=true;
	  }
	if(flag)cout<<"Yes";else cout<<"No";
}

Measured memory_bytes: 256
N = int(input())
SP = []
a = 1
for i in range(N):
    SP.append(input().split())
    SP[i][1] = int(SP[i][1])
for i in SP:
    i.append(a)
    a += 1
SP.sort(reverse=True)
SP.sort(key=lambda x: x[0])
for i in range(N):
    print(SP[i][2])

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

class triangle{
    vector<int> data;
    
public:
    triangle() { data.reserve(3); }
    void set(int *a);
    char* isright();
    void clearset() {data.clear();}
};

void triangle::set(int *a)
{
    data.push_back(a[0]);
    data.push_back(a[1]);
    data.push_back(a[2]);

    sort(data.begin(), data.end());
}

char* triangle::isright()
{
    if(data[0] * data[0] + data[1] * data[1] == data[2] * data[2])
        return "YES";
    return "NO";
}

int main()
{
    triangle tri;
    int loop, buff[3];
    cin >> loop;
    for(int c =0; c< loop; c++)
    {
        cin >> buff[0] >> buff[1] >> buff[2];
        tri.set(buff);
        cout << tri.isright() << endl;
        tri.clearset();
    }

    return 0;
}

Measured memory_bytes: 1208
#include <cstdio>
#define M 1000000007
using namespace std;
int f[11111];
int main(){
    int n; scanf("%d",&n);
    f[0]=1;
    for (int i=3;i<=n;i++){
        for (int j=3;j<=i;j++)
            (f[i]+=f[i-j])%=M;
    }
    printf("%d\n",f[n]);
    return 0;
}


Measured memory_bytes: 3192
#include <bits/stdc++.h>
using namespace std;
#define f first
#define s second
#define pb push_back
typedef long long int ll;
const int N=2e5+5;
int k,n,a[N],ans,mx;
int mn(int x) {
    int op1=0,op2=0;
    for(int i=x+1;i<n;i++)
        op1+=(a[i]-a[i-1]);
    if(x) op1+=(k-a[n-1]);
    for(int i=0;i<x;i++){
        if(i)
            op1+=(a[i]-a[i-1]);
        else
            op1+=a[i];
    }
    for(int i=x-1;i>=0;i--){
        op2+=(a[i+1]-a[i]);
    }
    if(x!=n-1) op2+=(k-a[n-1]);
    for(int i=n-2;i>x;i--)
        op2+=(a[i+1]-a[i]);
    return min(op1,op2);
}
int main(){
    cin.tie(NULL);
    cout.tie(NULL);
    ios_base::sync_with_stdio(false);
    cin>>k>>n;
    for(int i=0;i<n;i++)
        cin>>a[i];
    sort(a,a+n);
    for(int i=1;i<n;i++){
        ans+=(a[i]-a[i-1]);
        mx=max(a[i]-a[i-1],mx);
    }
    ans-=mx;
    ans+=min(mx,a[0]+k-a[n-1]);
    cout<<ans<<'\n';
    return 0;
}


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

int main()
{
    int n;
    cin >> n;
    int ans = (1 << 30);
    for (int i = 1; i < n; i++)
    {
        int a = i, b = n - a, sum = 0;
        while (a)
        {
            sum += a % 10;
            a /= 10;
        }
        while (b)
        {
            sum += b % 10;
            b /= 10;
        }
        ans = min(ans, sum);
    }
    cout << ans << endl;
    return 0;
}

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

//マクロ
#define REP(i,n) for(int i=0; i<(int)(n); ++i)
#define REPS(i,n) for(int i=1; i<=(int)(n); ++i)
#define RREP(i,n) for(int i=(int)(n)-1; i>=0; --i)
#define RREPS(i,n) for(int i=(int)(n); i>0; --i)
#define FOR(i,s,e) for(int i=(int)(s); i<(int)(e); ++i)
#define RFOR(i,s,e) for(int i=(int)(e)-1; i>=(int)(s); --i)

#define All(a) (a).begin(),(a).end()

//定数
#define INF 1e9
#define MOD (int)(1e9+7)

typedef long long ll;
typedef unsigned long long ull;
using namespace std;

//とりあえず書いておく変数
int dx[4] = { 1,0,-1,0 };
int dy[4] = { 0,1,0,-1 };

//今回の変数

//使用する関数
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;
}


int main()
{
	int n;
	int a[21], b[21], c[21];

	cin >> n;
	REPS(i, n) {
		cin >> a[i];
	}
	REPS(i, n) {
		cin >> b[i];
	}
	REPS(i, n) {
		cin >> c[i];
	}

	int score = 0;
	int pre = -100;
	REPS(i, n) {
		score += b[a[i]];
		if (pre == a[i] - 1)score += c[a[i]-1];
		pre = a[i];
	}
	cout << score << endl;
}

Measured memory_bytes: 256
//NOMURA プログラミングコンテストB
#include <bits/stdc++.h>
using namespace std;
int main() {
    string t;
    cin >> t;

    int n = t.size();
    for (int i = 0; i < n; i++) {
        if (t[i] == '?') {
            t[i] = 'D';
        }
    }

    cout << t << endl;
    return 0;
}

Measured memory_bytes: 3728
#include <stdio.h>

int main(void)
{
	int n;
	float h;
	int i, j;
	int r[6] = {-1, -1, -1, -1, -1, -1};
	
	scanf("%d", &n);
	
	for (i = 0; i < n; i++) {
		scanf("%f", &h);
		
		if (h < 165.0) {
			r[0]++;
		}
		else if (h < 170.0) {
			r[1]++;
		}
		else if (h < 175.0) {
			r[2]++;
		}
		else if (h < 180.0) {
			r[3]++;
		}
		else if (h < 185.0) {
			r[4]++;
		}
		else {
			r[5]++;
		}
	}
	
	for (j = 1; j <= 6; j++) {
		printf("%d:", j);
		for (i = 0; i <= r[j - 1]; i++) {
			printf("*");
		}
		printf("\n");
	}
	
	return (0);
}

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

using namespace std;
using llong = long long;
using ldbl = long double;
using lpair = pair<llong, llong>;

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

constexpr llong mod = 1e9+7;
constexpr llong inf = mod * mod;

int main() {
  llong N;
  vector<llong> A;
  array<int, 1000001> cnt = {};
  
  cin >> N;
  A.resize(N);
  for (auto &in: A) {
    cin >> in;
    cnt[in]++;
  }

  llong ans = 0;
  for (auto a: A) {
    bool ok = true;
    if (cnt[a] > 1 || (a != 1 && cnt[1] > 0)) {
      continue;
    }
    for (llong i = 2; i * i <= a; i++) {
      if (a % i == 0) {
        ok &= cnt[i] == 0 && cnt[a/i] == 0;
      }
    }
    ans += ok;
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 8748