akhauriyash/Code-Regression huggingface dataset:
import java.util.*;
import java.io.*;
import static java.util.Arrays.*;
import static java.util.Collections.*;
import static java.lang.Math.*;

public class Main {

	int INF = 1 << 28;
	//long INF = 1L << 62;
	double EPS = 1e-10;

	void run() {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int MAX = 10;
		ArrayList<Integer> l = new ArrayList<Integer>();
		for(int i=0;i<n;i++) {
			int b = sc.nextInt();
			if(l.size() < MAX || l.get(MAX-1) >= b )
				l.add(b);
			sort(l);
			if(l.size()==MAX) l.remove(MAX-1);
		}
		Integer[] a = l.toArray(new Integer[]{});
		ArrayList<Long> ans = new ArrayList<Long>();

		for(int i=0;i<a.length;i++) for(int j=0;j<a.length;j++) if(i!=j) {
			ans.add(Long.parseLong(String.valueOf(a[i]) + String.valueOf(a[j])));
		}
		sort(ans);
		System.out.println(ans.get(2));
	}

	void debug(Object... os) {
		System.err.println(Arrays.deepToString(os));
	}

	public static void main(String[] args) {
		new Main().run();
	}
}

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

using namespace std;

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

    vector<long long> w(N+1), v(N+1);
    for (int i = 1; i <= N; i++) {
        cin >> w[i] >> v[i];
    }

    // 1からiまでの品物の中で価値の和がj以上の品物の重さの総和の最小値dp[i][j]
    vector<vector<long long>> dp(N+1, vector<long long>(100001, 2000000000));

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

    // dp開始
    for (int i = 1; i <= N; i++) {
        for (int j = 0; j <= 100001; j++) {
            // 品物が入る場合、入れる場合と入れない場合を比べて重さが小さい方を取る
            if (j - v[i] >= 0) {
                dp[i][j] = min(dp[i-1][j], dp[i-1][j - v[i]] + w[i]);
            // 品物が入らない場合
            } else {
                dp[i][j] = dp[i-1][j];
            }
        }
    }

    long long answer = 0;

    for (int j = 100000; j >= 1; j--) {
        if (dp[N][j] <= W) {
            answer = j;
            break;
        }
    }

    cout << answer << endl;
	return 0;
}

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

int a;
int b;
int c;
set<int> considered;

int main() {
  scanf("%d%d%d", &a, &b, &c);
  
  int k = 0;
  int ans = 0;
  while (1) {
    if (considered.count(k)) {
      puts("-1");
      return 0;
    }

    if ((k <= c && c <= k+a) || (k <= c+60 && c+60 <= k+a)) {
      printf("%d\n", ans*60 + c);
      return 0;
    }

    considered.insert(k);
    k = k+a+b;
    if (k >= 60) {
      k %= 60;
      ans++;
    }
  }
}

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

int main() {
  int a;
  cin>>a;
  vector<int> A(a);
  for(int i=0;i<a;i++)
    cin>>A[i];
  int b=A[0],c=1;
  for(int i=0;i<a;i++){
    if(b==2){
      cout<<c<<endl;
      break;
      }
    else if(i==a-1){
      cout<<"-"<<1<<endl;
      break;
      }
    c++;
    b=A[b-1];
    }
  }

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

//FILE *fin = freopen("b.in", "r", stdin);

/* --------------------------------------------- */
int n, m, a[maxN][maxN];
/* --------------------------------------------- */
int sel[maxN], frq[maxN];
/* --------------------------------------------- */
int ans;

void init()
{
    for (int i = 1; i <= m; ++ i)
        sel[i] = 1;
    ans = n;
}
void solve(int M)
{
    int sol = 0, favSp = 0;
    memset(frq, 0, sizeof(frq));
    for (int i = 1; i <= n; ++ i)
    {
        int j = 1;
        while (j <= m && !sel[a[i][j]])
            ++ j;
        ++ frq[a[i][j]];
    }
    for (int i = 1; i <= m; ++ i)
        if (sel[i] && sol < frq[i])
        {
            sol = frq[i];
            favSp = i;
        }
    sel[favSp] = 0;
    ans = min(ans, sol);
    if (M > 1)
        solve(M - 1);
}
int main()
{
    scanf("%d %d", &n, &m);
    for (int i = 1; i <= n; ++ i)
        for (int j = 1; j <= m; ++ j)
            scanf("%d", &a[i][j]);
    init();
    solve(m);
    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include<string>

int main() {
	int x, y;
	while (std::cin >> x >> y, x || y) {
		if (x > y) {
			std::cout << y << " " << x << std::endl;
		}
		else {
			std::cout << x << " " << y << std::endl;
		}
	}
	return 0;
}


Measured memory_bytes: 3004
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor
from functools import reduce



INF = float('inf')
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return sys.stdin.readline().strip()
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 1000000007


n, m = LI()
graph = [[INF] * n for _ in range(n)]
for i in range(n):
    graph[i][i] = 0


for a, b, c in LIR(m):
    graph[a - 1][b - 1] = c
    graph[b - 1][a - 1] = c


dist = [[graph[i][j] for j in range(n)] for i in range(n)]




for i in range(n):
    for j in range(n):
        for k in range(n):
            dist[j][k]=min(dist[j][i]+dist[i][k], dist[j][k])



cnt = 0
for i in range(n):
    for j in range(i, n):
        if graph[i][j] != INF and graph[i][j] > dist[i][j]:
            cnt += 1


print(cnt)

Measured memory_bytes: 48112
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#define dlog(str) cout << "====" << str << endl;
#else
#define dlog(str)
#endif
#define INF 999999999
#define MOD 1000000007
#define REP(i, n) for(int i = 0, i##_l = (n); i < i##_l; i++)
#define FOR(i, s, e) for(int i = s, i##_l = (e); i < i##_l; i++)
#define LLI long long int
#define _min(a,b) ((a<b)?a:b)
#define _max(a,b) ((a<b)?b:a)
#define chmax(a, b) a = _max(a, b)
#define chmin(a, b) a = _min(a, b)
#define bit(a, shift) ((a>>shift)&1))
#define pm(a) ((a)?1:-1)
#define SORT(v) sort(v.begin(),v.end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
// int 2.14E±9    lli 9.2E±18    double 1.7E±380


int main()
{
	cout << fixed << setprecision(10);
	int n, m;
	cin >> n >> m;
	int sum = 0;
	REP(i, m)
	{
		int a;
		cin >> a;
		sum += a;
	}
	if (n < sum)
	{
		cout << -1;
	}
	else
	{
		cout << n - sum;
	}
	return 0;
}

Measured memory_bytes: 3596
from collections import Counter


def find(x):
    if par[x] < 0:
        return x
    else:
        par[x] = find(par[x])
        return par[x]


def unite(x, y):
    x = find(x)
    y = find(y)

    if x == y:
        return False
    else:

        if par[x] > par[y]:
            x, y = y, x
        par[x] += par[y]
        par[y] = x
        return True


def size(x):
    return -par[find(x)]


N, M = map(int, input().split())
par = [-1]*N

for i in range(M):
    a, b = map(int, input().split())
    unite(a - 1, b - 1)

count = 0
for i in par:
    count += i < 0

print(count-1)


Measured memory_bytes: 11108
#include<iostream>

using namespace std;

int main()
{
    int x,y,r,w,h;

    cin >> w >> h >> x >> y >> r;

    if(r<=x&&x<=w-r)
    {
        if(r<=y&&y<=h-r)
            {
                cout << "Yes"<<endl;
            }
        else
        {
            cout << "No" << endl;
            return 0;
        }
        
    }
    else 
    {
        cout <<"No" <<endl;
        return 0;
    }
}


Measured memory_bytes: 3100
from collections import deque

n = int(input())
p = list(map(int, input().split()))
q = list(map(int, input().split()))
a, b, x = 0, 0, 1
c = deque()
d = deque()
for i in range(n):
    c.append(i + 1)
    d.append(i + 1)
    x *= i + 1
for i in range(n):
    for j in range(n - i):
        if p[i] == c[j]:
            a += j * x / (n - i)
            c.remove(p[i])
            break
    for j in range(n - i):
        if q[i] == d[j]:
            b += j * x / (n - i)
            d.remove(q[i])
            break
    x /= n - i

print(abs(int(a - b)))

Measured memory_bytes: 3444
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>
#include<complex>

using namespace std;

#define ll long long
#define ld long double
#define EPS 1e-9
#define INF 1e9
#define LINF (ll)INF*INF
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,a,n) for(int i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

#define int ll //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef pair<pii,int> ppi;
typedef pair<int,pii> pip;
typedef vector<pii> vp;
typedef vector<vi> vvi;

int gcd(int a, int b){if(b==0) return a;return gcd(b,a%b);}
int lcm(int a, int b){return a/gcd(a,b)*b;}


signed main(void) {
    int n;
    cin >> n;
    string s;
    cin >> s;
    rep(i,s.size()){
        int t = s[i]-'A';
        t += n;
        t %= 26;
        cout << char('A'+t);
    }
    cout << endl;

}


Measured memory_bytes: 888
import sys
import itertools
sys.setrecursionlimit(1000000000)
from heapq import heapify,heappop,heappush,heappushpop

import collections

s = input()
cnt = 0
for i in range(len(s)):
    if s[i] == "o":
        cnt+=1
if cnt == 0:
    print(700)
else:
    print(700+ 100*cnt)

Measured memory_bytes: 3316
#include <cstdio>

using namespace std;

int main(void)
{
    int r;
    scanf("%d", &r);

    if (r < 1200) {
        puts("ABC");
    }
    else if (r < 2800) {
        puts("ARC");
    }
    else
        puts("AGC");
    
    return 0;
}

Measured memory_bytes: 888
x=int(input())
i=1
s=set([])
while(i<int(x**0.5)):
    i+=1
    mkr=0
    for j in s:
        if i%j==0:
            mkr=1
            break
    if mkr==0:
        s|={i}
i=x-1
while(1):
    i+=1
    mkr=0
    for j in s:
        if i%j==0:
            mkr=1
            break
    if mkr==0:
        print(i)
        break

Measured memory_bytes: 3064
#pragma warning(disable:4996)

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <float.h>

#pragma region 定義
#define i_cin(X) scanf("%d", &X)
#define i_cin2(X,Y) scanf("%d %d",&X,&Y)
#define i_cin4(X,Y,Z,W) scanf("%d %d %d %d",&X,&Y,&Z,&W)
#define i_cin3(X,Y,Z) scanf("%d %d %d",&X,&Y,&Z)
#define l_cin(X) scanf("%ld",&X)
#define f_cin(X) scanf("%f",&X)
#define l_cin2(X,Y) scanf("%ld %ld",&X,&Y)
#define s_cin(X) scanf("%s",&X)

#define  i_cout(X) printf("%d\n",X)
#define  f_cout(X) printf("%g\n",X)
#define  i_cout2(X,Y) printf("%d %d\n",X,Y)
#define  l_cout(X) printf("%ld\n",X)
#define  s_cout(X) printf("%s\n",X)
#define  ll_cout(X) printf("%lld\n",X)

typedef long long  ll;
#define rept(x, s, n) for (int x = s; x < n; x++)

#define S_RTN(S)  s_cout(S);return 0


#define _itoa(A,N) sprintf(A, "%d", N);

int i_cins(int n, int* A);
int l_cins2(int n, long* A, long* B);
int s_dsort(const void* a, const void* b);
int s_asort(const void* a, const void* b);

int  _gcd(int a, int b);
int  _swp(int* a, int* b);
int _cknum(char* a, int n);


int s_asorts(const void* a, const void* b);

//昇順
int s_asorts(const void* a, const void* b) {
	return(strcmp((char*)a, (char*)b));
}
int s_dsort(const void* a, const void* b) {
	return(*(int*)b - *(int*)a);
}
int s_asort(const void* a, const void* b) {
	return(*(int*)a - *(int*)b);
}
int l_cins2(int n, long* a, long* b) {
	int i;
	rept(i, 0, n) {
		l_cin2(*(a + i), *(b + i));
	}
	return 0;
}
int i_cins(int n, int* a) {
	int i;
	for (i = 0; i < n; i++) {
		i_cin(*(a + i));
	}

	return 0;
}
int _gcd(int a, int b) {
	int r, tmp;
	if (a < b) { tmp = a; a = b; b = tmp; }
	r = a % b;
	while (r) {
		if (!r) break;
		a = b; b = r;
		r = a % b;
	}
	return(b);
}

long _max(long a, long b) {
	return a > b ? a : b;
}
long _min(long a, long b) {
	return a < b ? a : b;
}
int _swp(int* a, int* b)
{
	int tmp;
	tmp = *b; *b = *a; *a = tmp;
	return 0;
}

int _cknum(char* a, int n) {
	int i;
	char t = '0';

	for (i = 0; i < n; i++) {
		if (a[i] < '0' || a[i]>'9') return 1;
	}
	return 0;
}

#pragma endregion

int main(void) {
	int n,i=0,cnt=0;
	int d[101];

	i_cin(n);
	i_cins(n, d);

	qsort(d, n, sizeof(int), s_asort);
	while (i < n) {
		i++;
		if (d[i] != d[i - 1]) cnt++;
	}
	i_cout(cnt);
	return 0;
}


#define  c_coin(b,c) (b >= c)?1:0;

int b_coin(int a, int B,int c);

int b_coin(int x, int B,int C) {
	int j,b,tmp,cnt=0;

	b = _min(x*2, B);
	if (!b) return 1;

	for (j = 0; j < b; j++) {
		tmp = x - 2 * j;
		if (!tmp) { cnt++; continue; }
		cnt += (tmp <= C && C) ? 1 : 0;
	}
	return cnt;
}
//
//int main(void) {
//
//	int A, B, C, X;
//	int a, i = 0, tmp, cnt = 0;
//
//	i_cin4(A, B, C, X);
//	X /= 50;
//	//a = _min(X / 500, A);
//	//if (!a) { i_cout(b_coin(a,B,C)); return 0; }
//
////	for (i = 1; i < a; i++) {
////		tmpA = X - 500 * i;
////		if (!tmpA) { cnt++; continue; }
//	tmp = X - 100 * i;
//	cnt += b_coin(tmp, B, C);
////	}
//
//	i_cout(cnt);
//	return 0;
//}
//




Measured memory_bytes: 128
'''
例
6 5
4 7 10 6 5

１．X = 6 との差を求める
(X-P_iの配列を作る)
2 -1 -4 0 1

2. X-P_iの配列に0, ±1, ±2, ... が含まれていないか調べる


3. 数列Pに含まれていない数で
6との差が-2になる8
'''

import numpy as np

def pm_list(i):
    if(i%2 == 0):
        return i//2
    else:
        return -i//2

X, N = list(map(int, input().split()))
P = list(map(int, input().split()))

def_list = np.array(P) - X

i = 0
while True:
    iter_num = pm_list(i) 
    if not (iter_num in def_list):
        print(X + iter_num)
        break
    i += 1


Measured memory_bytes: 27308
#include <iostream>
//#include <iomanip>
//#include <algorithm>
//#include <numeric>
//#include <queue>
//#include <stack>
//#include <math.h>
//#include <vector>
//#include <string>
typedef long long LL;
using namespace std;

int main(){
    LL n;
    LL k;
    LL tmp;
    LL ans;
    cin >> n >> k;
    tmp=n/k;
    ans = tmp*tmp*tmp;
    if(k%2==0){
        tmp=n/(k/2)-n/k;
        ans+=tmp*tmp*tmp;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static int MOD = 1000000007;

    public static void main(String[] args){
        Scanner s = new Scanner(System.in);
        String str = s.next();
        System.out.println(new Main().ABC(str.toCharArray()));
        s.close();
    }

    private long ABC(char[] str){
        long c = 0, bc = 0, abc = 0, count = 1;

        for(int i = str.length-1; i >= 0; --i){
            char ch = str[i];
            if(ch == 'A')
                abc += bc;
            else if(ch == 'B')
                bc += c;
            else if(ch == 'C')
                c += count;
            else {
                abc = abc * 3 + bc;
                bc = bc * 3 + c;
                c = c * 3 + count;
                count *= 3;
            }
            abc %= MOD;
            bc %= MOD;
            c %= MOD;
            count %= MOD;
        }
        return (int) (abc % MOD);
    }
}

Measured memory_bytes: 26960
#pragma GCC optimize("O3")
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("unroll-loops")

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

using namespace std;
using namespace __gnu_pbds; 

#define int long long
#define pb push_back
#define pf push_front
#define eb emplace_back
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define f first
#define s second
#define sz(x) (int)x.size()
#define endl "\n"
#define forn(i,n) for(int i=0;i<n;++i)
#define fore(i,l,r) for(int i=int(l);i<=int(r);++i)
#define rep(i,begin,end) for(__typeof(end) i=(begin);i!=(end);i++)
#define fill(a,value) memset(a,value,sizeof(a));
#define gcd(a,b) __gcd((a),(b))
#define watch1(x) cout<<(x)<<endl
#define watch2(x,y) cout<<(x)<<" "<<(y)<<endl
#define watch3(x,y,z) cout<<(x)<<" "<<(y)<<" "<<(z)<<endl
#define fastio ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);

typedef long long ll;
typedef long double ld; 
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> oset;

const int INF = 9e18;
const int mod = 1e9 + 7;
const int N = 2e5 + 5;

int i,n,a[N];

void solve()
{
    cin>>n;
    bool ok=1;
    for(i=1;i<=n;++i)
    {
        cin>>a[i];
        if(a[1])
            ok=0;
        if(a[i]>a[i-1] && a[i]!=a[i-1]+1)
            ok=0;
    }
    if(!ok)
    {
        cout<<-1;
        return;
    }
    int ans=0;
    for(i=2;i<=n;++i)
    {
        if(a[i]==a[i-1]+1)
        {
            ans++;
        }
        else
        {
            ans+=a[i];
        }
    }
    cout<<ans;
}

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

Measured memory_bytes: 1792
#include <stdio.h>
#include <string.h>
#include <vector>
#include <queue>
#include <stack>
#include <math.h>
#include <algorithm>
#include <map>
#include <set>
#define ll long long
using namespace std;
int a[100010];
int cnt[100010];
int main() {
	int n, k, q;
	scanf("%d %d %d", &n, &k, &q);
	for (int i = 0; i < q; i++) {
		scanf("%d", a + i);
		cnt[a[i]]++;
	}
	for (int i = 1; i <= n; i++) {
		if (q - cnt[i] >= k)
			printf("No\n");
		else
			printf("Yes\n");
	}
}

Measured memory_bytes: 1280
#[allow(unused_imports)]
use itertools::Itertools;
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::*;

fn main() {
    input! {
        n: usize,
        a: [i64; n],
    }

    let mut res = 0;
    let mut mx = 0;
    for a in a {
        if mx > a {
            res += mx - a;
        } else {
            mx = a;
        }
    }
    println!("{}", res);
}


Measured memory_bytes: 5572
#include "bits/stdc++.h"
using namespace std;
#define MOD 1000000007
#define Nmax 200010
#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define RFOR(i,a,b) for(long long i = (b-1);i>=a;i--)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define RITR(itr,mp) for(auto itr = (mp).rbegin(); itr != (mp).rend(); ++itr)
#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<P> Graph;

int main() {
	int W,a,b;
	cin >> W >> a >> b;
	int ans;
	if(a+W<b)ans=b-(a+W);
	else if(a>b+W)ans=a-(b+W);
	else ans=0;
	cout << ans << endl;
	
	
	return 0;
}

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

int main(){
    int N, H[100000];
    cin >> N;
    for(int i=0; i<N; i++) cin >> H[i];
    int len = 0, ans = 0;
    for(int i=1; i<N; i++){
        if(H[i-1] >= H[i]){
            len++;
            ans = max(len, ans);
        }else{
            len = 0;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 640
from heapq import heappop,heappush

input=open(0).readline
n,k=map(int,input().split())
res={}
for i in range(n):
    a,b=map(int,input().split())
    res[a]=res.get(a,0)+b

que=[]
for key,val in res.items():
    heappush(que,(key,val))

while k:
    key,val=heappop(que)
    if val>=k:
        print(key)
        exit()
    k-=val


Measured memory_bytes: 14692
struct Scanner {
	handle: std::io::Stdin,
	buffer: std::collections::VecDeque<String>
}

impl Scanner {
	fn new() -> Scanner {
		Scanner {
			handle: std::io::stdin(),
			buffer: std::collections::VecDeque::new()
		}
	}
	fn next<T: std::str::FromStr>(&mut self) -> Result<T, T::Err> {
		if self.buffer.len() == 0 {
			loop {
				let mut available = String::new();
				self.handle.read_line(&mut available).unwrap();
				self.buffer = available.split_whitespace().map(String::from).collect();
				if self.buffer.len() > 0 {
					break;
				}
			}
		}
		T::from_str(&self.buffer.pop_front().unwrap())
	}
}

fn main() {
	let mut scanner = Scanner::new();
	let mut n: i64 = scanner.next().unwrap();
	let mut total: i64 = 0;
	for p in 2i64.. {
		#[cfg(debug_assertions)] dbg!(n, p);
		if p * p > n {
			break;
		}
		if n % p != 0 {
			continue;
		}
		let mut e = 0;
		while n % p == 0 {
			n /= p;
			e += 1;
		}
		for i in 1.. {
			e -= i;
			if e < 0 {
				break;
			}
			total += 1;
		}
	}
	if n > 1 {
		total += 1;
	}
	println!("{}", total);
}


Measured memory_bytes: 2120
#include <bits/stdc++.h> 
#define rep(i,n) for(long long i = 0; i < (long long)(n); i++)
#define per(i,n) for(long long i = (long long)(n-1);i >= 0;--i)
#define REP(i,s,t) for(long long i=s;i<t;i++)
#define PER(i,s,t) for(long long i=s;i>t;--i)
#define all(x) x.begin(),x.end()
#define sp(n) setprecision(n)
typedef long long ll;
using namespace std;
int main(){
  string s;
  int n;
  cin>>n>>s;
  int m=0;
  rep(i,n-2){if(s[i]=='A'&&s[i+1]=='B'&&s[i+2]=='C'){m++;}}
  cout<<m<<endl;
}

Measured memory_bytes: 256
// https://atcoder.jp/contests/abc059/tasks/abc059_a
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
#define REP(i, n) FOR(i, 0, n)
#define FOR(i, s, n) for (int i = (s), i##_len = (n); i < i##_len; ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    string a, b, c;
    cin >> a >> b >> c;
    cout << (char)toupper(a[0]) << (char)toupper(b[0]) << (char)toupper(c[0])
         << endl;

    return 0;
}


Measured memory_bytes: 256
char s[1000001];c[1000001];
main(n,m,i,r){for(;scanf("%d",&n),n;printf("%d\n",r)){
	for(memset(c,0,sizeof(c)),scanf("%d%s",&m,s),i=2;i<m;i++)if(s[i-2]=='I'&&s[i-1]=='O'&&s[i]=='I')c[i]=c[i-2]+1;
	for(i=r=0;i<m;i++)if(c[i]>=n)r++;
}}

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

void solve() {
    int N;
    cin >> N;
    vector<int> L(N);
    for (int i = 0; i < N; ++i) {
        cin >> L[i];
    }
    sort(L.begin(), L.end());
    int ans = 0;
    for (int i = N - 1; i >= 2; --i) {
        int b = L[i];
        for (int j = i-1; j >= 1; --j) {
            int c = L[j];
            int t = b - c;
            int l = 0;
            int r = j - 1;
            bool ok = false;
            while(l <= r) {
                int mid = (l + r) / 2;
                if (t < L[mid]) {
                    ok = true;
                    r = mid -1;
                }
                else l = mid+1;
            }
            if (ok) {
                ans += j - 1 - r;
            }
        }
    }
    cout << ans << endl;
}

int main() {
    solve();
    return 0;
}


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

using namespace std;
const double EPS = 1e-8;
const double INF = 1e12;
typedef complex<double> P;

namespace std {
  bool operator < (const P& a, const P& b) {
    return real(a) != real(b) ? real(a) < real(b) : imag(a) < imag(b);
  }
}

double cross(const P& a, const P& b) {
  return imag(conj(a)*b);
}
double dot(const P& a, const P& b) {
  return real(conj(a)*b);
}

struct L : public vector<P> {
  L(const P &a, const P &b) {
    push_back(a); push_back(b);
  }
};

typedef vector<P> G;

struct C {
  P p; double r;
  C(const P &p, double r) : p(p), r(r) { }
};

int ccw(P a, P b, P c) {
  b -= a; c -= a;
  if (cross(b, c) > 0)   return +1;       // counter clockwise
  if (cross(b, c) < 0)   return -1;       // clockwise
  if (dot(b, c) < 0)     return +2;       // c--a--b on line
  if (norm(b) < norm(c)) return -2;       // a--b--c on line
  return 0;
}


//直線と直線の交差
bool intersectLL(const L &l, const L &m) {
  return abs(cross(l[1]-l[0], m[1]-m[0])) > EPS || // non-parallel
    abs(cross(l[1]-l[0], m[0]-l[0])) < EPS;   // same line
}
bool intersectLS(const L &l, const L &s) {
  return cross(l[1]-l[0], s[0]-l[0])*       // s[0] is left of l
    cross(l[1]-l[0], s[1]-l[0]) < EPS; // s[1] is right of l
}
bool intersectLP(const L &l, const P &p) {
  return abs(cross(l[1]-p, l[0]-p)) < EPS;
}

//線分と線分の交差
bool intersectSS(const L &s, const L &t) {
  return ccw(s[0],s[1],t[0])*ccw(s[0],s[1],t[1]) <= 0 &&
         ccw(t[0],t[1],s[0])*ccw(t[0],t[1],s[1]) <= 0;
}


bool intersectSP(const L &s, const P &p) {
  return abs(s[0]-p)+abs(s[1]-p)-abs(s[1]-s[0]) < EPS; // triangle inequality
}



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

  int x1,y1,x2,y2,x3,y3,x4,y4;
  for(int i=0;i<n;i++){
    cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3 >> x4 >> y4;
    
    P p1(x1,y1);
    P p2(x2,y2);
    L l1(p1,p2);

    P p3(x3,y3);
    P p4(x4,y4);

    L l2(p3,p4);

    cout << intersectSS(l1,l2) << endl;
  }
}

Measured memory_bytes: 1216
#include<bits/stdc++.h>
using namespace std;
/*#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
*/typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll,ll> pl;
typedef pair<int,int> pii;

#define int ll
#define LOCAL 0
#define dbg(x) cout << #x << " is " << x << "\n"
#define gll(x) scanf("%d",&x)
#define gll2(x,y) scanf("%d%d",&x,&y)
#define gll3(x,y,z) scanf("%d%d%d",&x,&y,&z)
#define gllarr(arr,n) f(i,n) gll(arr[i]);
#define sz(x) ((int)x.size())
#define s(x) sort(x.begin(),x.end())
#define all(v) v.begin(),v.end()
#define rs(v) { s(v) ; r(v) ; }
#define r(v) {reverse(all(v));}
#define pb push_back
#define f(i,n) for(int i=0;i<n;i++)
#define fr(i,n) for(int i=n-1;i>=0;i--)
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define repr(i,a,b) for(int i=a;i>=b;i--)

const ll mod = (ll)1e9 + 7;
const ll inf = (ll)1e16;
const ld eps = 1e-12;
const ll N = (int)2e5 + 5;
const ll LOGN = 19;
const ld PI = 3.14159265358979323846;
inline ll mul(ll a, ll b, ll m = mod) { return (ll)(a * b) % m;}
inline ll add(ll a, ll b, ll m = mod) { a += b; if(a >= m) a -= m; if(a < 0) a += m; return a;}
inline ll power(ll a, ll b, ll m = mod) { if(b == 0) return 1; if(b == 1) return (a % m); ll x = power(a, b / 2, m); x = mul(x, x, m); if(b % 2) x = mul(x, a, m); return x;}

const int MAX_FACT = (int)2e5 + 50;
ll fact[MAX_FACT];
ll inv[MAX_FACT];

/* Calculates factorial and inverse factorial MODULO mod upto MAX_FACT */
void init()
{
    inv[0] = fact[0] = 1 % mod;
    rep(i, 1, MAX_FACT - 1) {
        fact[i] = mul(fact[i - 1], i);
        inv[i] = power(fact[i], mod - 2);
    }
}

ll C(int n, int r){
    /* nCr */
    if(n < r || r < 0) return 0ll;
    return mul(mul(fact[n], inv[r]), inv[n - r]);
}

ll P(int n, int r){
    /* nPr */ 
    if(n < r || r < 0) return 0ll;
    return mul(fact[n], inv[n - r]);
}

ll H(int n, int m){
    /* Solution of equation x1 + x2 + .. + xn = m */
    return C(n + m - 1, m);
}


int sum(int k) {
    int to = (k * (k + 1)) / 2;
    to %= mod;
    return to;
}

int sum(int L, int R) {
    if(L == 0) return sum(R);
    return add(sum(R), -sum(L));
}

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    if (LOCAL) {
        freopen("C:\\Users\\Dishant\\Desktop\\Collection-DEV c++\\input.txt", "r", stdin);
        freopen("C:\\Users\\Dishant\\Desktop\\Collection-DEV c++\\output.txt", "w", stdout);
    }
    init();
    int n, k;
    cin>>n>>k;
    int ans = 0;
    for(int i = k; i <= n + 1; i++) {
        int ff = sum(i - 1);
        int ss = sum(n - i, n);
        ans = add(ans, add(ss, -ff));
        ans = add(ans, 1);
    }
    cout<<ans;
    return 0;
}

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

class Main {

    // Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
    public static void main(String[] args) throws Exception {
        final Scanner sc = new Scanner(System.in);
        long N;
        N = sc.nextLong();
        long K;
        K = sc.nextLong();
        long[] h = new long[(int)(N)];
        for(int i = 0 ; i < N ; i++){
                h[i] = sc.nextLong();
        }
        solve(N, K, h);
    }

    static void solve(long N, long K, long[] h){
        long[] dp = new long[(int)(N+1)];
        
        for (int i = 2; i <= N; i++){
            long tmp = Integer.MAX_VALUE;
            for (int j = 1; j <= K; j++){
                if (i - j - 1 >= 0){
                    tmp = Math.min(tmp, dp[i-j] + Math.abs(h[i-1] -h[i-j-1]));
                }
            }
            dp[i] = tmp;
        }
        System.out.print(dp[(int)(N)]);

    }
}


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

using namespace std;
const long mod = 1000000007;
typedef long long lint;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(N) for(int i = 0; i < (int)(N); i++)
#define all(x) (x).begin(),(x).end()
#define length(x) ((int)(x).size())
#define prln(s) cout<<s<<endl;

#define str(s) string s;cin>>s;
#define int1(x) int x;cin>>x;
#define int2(x,y) int x,y;cin>>x>>y;

int main() {
  int1(n);
  int2(a,b);
  prln(min(n*a,b));
  
}


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

#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)
#define rrep(i, n) RFOR(i, n, 0)
#define dump(x)  cout << #x << " = " << (x) << endl;

typedef long long ll;
typedef pair<int, int> ii;
const ll INF = 1e18;
const int inf = 1e8;


void solve()
{
  ll a;
  scanf("%lld",&a);
  ll b;
  scanf("%lld",&b);
  if (a<=b) cout << a << endl;
  else cout << max(1LL,a-1) << endl;
}

int main()
{
  solve();
  return 0;
}


Measured memory_bytes: 256
<?php
// $n = (int)trim(fgets(STDIN));
$input = explode(' ', trim(fgets(STDIN)));

$n = (int)$input[0];
$m = (int)$input[1];

$gates = [];
for ($i=0; $i < $m; $i++) { 
	$input = explode(' ', trim(fgets(STDIN)));
	$gates[] = [
		(int)$input[0],
		(int)$input[1]
	];
}
usort($gates, function($a, $b){
	return $a[0] - $b[0];
});

$prev = $gates[0];
$cur_l = $prev[0];
$cur_r = $prev[1];
for ($i=1; $i < $m; $i++) { 
	$g = $gates[$i];
	$cur_l = $g[0];
	$cur_r = min($cur_r, $g[1]);
	$prev = $g;
}

echo max(0, $cur_r - $cur_l + 1);

Measured memory_bytes: 50036
#include <iostream>
#include <algorithm>
#include <bitset>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <cstring>
#include <utility>
#include <vector>
#include <complex>
#include <valarray>
#include <fstream>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <numeric>

#define rep(X,Y) for (int (X) = 0;(X) < (Y);++(X))
#define rrep(X,Y) for (int (X) = Y-1;(X) >= 0;--(X))
#define repa(X,A,Y) for (int (X) = A;(X) <= (Y);++(X))
#define all(X) (X).begin(),(X).end()
#define mod(n, m) (((n)%(m)+(m))%m)
#define fi first
#define sc second
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
const int INFINT = 1 << 30;                          // 1.07x10^ 9
const ll INFLL = 1LL << 60;                          // 1.15x10^18
const double EPS = 1e-10;
const int MOD = 1000000007;

ll N, M;
string S, T;
ll cm, cd;

//gcd(a, b)を求める。
ll gcd(ll a, ll b) {
  if (b == 0) return a;
  return gcd(b, a%b);
}


//整数a,bに対し、ax + by = gcd(a,b) を満たす整数x,y,gcd(a,b) を計算する
int extgcd(int a, int b, int& x, int& y) {
  int d = a;
  if (b != 0) {
    d = extgcd(b, a%b, y, x);
    y -= (a/b) * x;
  } else {
    x = 1; y = 0;
  }
  return d;
}

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

  cin >> N >> M;
  cin >> S >> T;

  cd = gcd(N, M);
  cm = N*M/cd;
  ll K = cm/N, L = cm/M;

  ll ans = cm;
  for (int i = 0; i*L < N || i*K < M; ++i) {
    if (S[i*L] != T[i*K]) {
      ans = -1; break;
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
int main() {
  int a,b;
  cin >> a >> b;
  if(b%2 == 1){
    cout << "No" << endl;
  }
  else if(b > 4*a||b< 2*a){
    cout << "No" << endl;
  }
  else{
    cout << "Yes" << endl;
  }
}


Measured memory_bytes: 3580
import java.util.*;

public class Main
{
    public static void main(String[] args)
    {
        //long start = System.currentTimeMillis();
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int x = sc.nextInt();
        int t = sc.nextInt();
        sc.close();
        int tmp = n/x;
        if (n%x != 0) ++tmp;
        System.out.println(tmp*t);
//        long end = System.currentTimeMillis();
//        System.err.println((end-start)+"ms");
    }
}

Measured memory_bytes: 35728
import sys

input = sys.stdin.readline


def main():
    N = int(input())

    ans = float("inf")
    for A in range(1, N):
        B = N - A
        total = sum(int(s) for s in str(A)) + sum(int(s) for s in str(B))
        if total < ans:
            ans = total

    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 3060
#include<iostream>
#include<string.h>
#define loop(i,a,b) for(int i=a;i<b;++i)
#define rep(i,b) loop(i,0,b)
using namespace std;
    int m[7]={};
    int m2[7]={};
class DICE{
public :
void set_DISE(int(x[7])){
    rep(i,6){
        cin>>x[i];
    }
}
void Rotate(char(dir)){
    if (dir=='N'){
        m[6]=m[0];
        m[0]=m[1];
        m[1]=m[5];
        m[5]=m[4];
        m[4]=m[6];
    }
    else if(char(dir)=='E'){
        m[6]=m[0];
        m[0]=m[3];
        m[3]=m[5];
        m[5]=m[2];
        m[2]=m[6];
    }
    else if(char(dir)=='W'){
        m[6]=m[0];
        m[0]=m[2];
        m[2]=m[5];
        m[5]=m[3];
        m[3]=m[6];
    }    
    else{
        m[6]=m[0];
        m[0]=m[4];
        m[4]=m[5];
        m[5]=m[1];
        m[1]=m[6];
    }
}
};
int main(){
    DICE d;
    d.set_DISE(m);
    d.set_DISE(m2);
        rep(i1,4){
            d.Rotate('E');
            if(m[0]==m2[0]&&m[1]==m2[1]&&m[2]==m2[2]&&m[3]==m2[3]&&m[4]==m2[4]&&m[5]==m2[5]) goto QUT;
            rep(i2,4){
                d.Rotate('N');
                if(m[0]==m2[0]&&m[1]==m2[1]&&m[2]==m2[2]&&m[3]==m2[3]&&m[4]==m2[4]&&m[5]==m2[5]) goto QUT;
                rep(i3,4){
                    d.Rotate('W');
                   if(m[0]==m2[0]&&m[1]==m2[1]&&m[2]==m2[2]&&m[3]==m2[3]&&m[4]==m2[4]&&m[5]==m2[5]) goto QUT;
                    rep(i4,4){
                        d.Rotate('S');   
                       if(m[0]==m2[0]&&m[1]==m2[1]&&m[2]==m2[2]&&m[3]==m2[3]&&m[4]==m2[4]&&m[5]==m2[5]) goto QUT;
                    }
                }
            }
        }
        cout<<"No"<<endl;
        goto END;
        QUT:
        cout<<"Yes"<<endl;
        END: ;
}


Measured memory_bytes: 3108
using System;
    using System.Linq;
    using System.Collections.Generic;
    using System.IO;
    using System.Text;
    using System.Text.RegularExpressions;

    class Program
    {
        static void Main()
        {
            var input = System.Console.ReadLine().Split(' ').Select((x) => long.Parse(x)).ToArray();
            var n = input[0];
            var d = input[1];
            double distance = 0;
            double distance2 = Math.Pow(d, 2);
            var cnt = 0;
            for (int i = 0; i < n; i++)
            {
                var input2 = System.Console.ReadLine().Split(' ').Select((x) => double.Parse(x)).ToArray();
                var a = input2[0];
                var b = input2[1];
                distance = Math.Pow(a, 2) + Math.Pow(b, 2);
                if (distance <= distance2)
                {
                    cnt++;
                }
            }
            
            Output(cnt.ToString());
        }
        private static void Output(string str)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);

            Console.WriteLine(str);

            Console.Out.Flush();
        }

    }

Measured memory_bytes: 41428
X, N = map(int, input().split())
if N:
    p = list(map(int, input().split()))
    for i in range(N // 2 + 3):
        if X - i not in p:
            print(X - i)
            break
        if X + i not in p:
            print(X + i)
            break
else:
    print(X)


Measured memory_bytes: 9048
#include<stdio.h>

int main(){
int a,b,c,max,maxv;
scanf("%d %d %d",&a,&b,&c);
max = a;
maxv= 1;

if(max < b){
max = b;
maxv = 2;
}

if(max < c){
max = c;
maxv= 3;
}

if(maxv==1)printf("%d",b+c);
if(maxv==2)printf("%d",a+c);
if(maxv==3)printf("%d",a+b);
return 0;
}

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

int main(){
  int N;
  cin >> N;
  
  vector<int> A(N);
  int max_A = 0;
  for ( int i = 0 ; i < N ; i++ ){
    cin >> A.at(i);
  }
  vector<int> A2 = A;
  int second_max_A;
  sort( A2.begin(),A2.end(),greater<int>() );
  bool judge = true;
  if ( A2.at(0) == A2.at(1) ){
  	max_A = A2.at(0);
  }
  else{
    max_A = A2.at(0);
  	second_max_A = A2.at(1);
    judge = false;
  }
    
  for ( int i = 0 ; i < N ; i++ ){
  	if (judge)
      cout << max_A << endl;
    else{
      if ( A.at(i) == max_A )
        cout << second_max_A << endl;
      else
        cout << max_A << endl;
    }  
  }
}

Measured memory_bytes: 3200
#define _GIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
int main(){
  int K;
  cin>>K;
  string S;
  cin>>S;
  if(S.size()>K){
    int t;
    t=S.size();
    for(int i=0;i<t-K;i++)
      S.pop_back();
    S+="...";
  }
  cout<<S<<endl;
}
  

Measured memory_bytes: 3536
#include <iostream>
#include <vector>
#include <math.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;



ll calcSum(string _l){
  // cout << "_l = " << _l << endl;
  ll sum = 0;
  if(_l.length() == 1){
    sum = stoll(_l);
  } else {
    for (int i = 1; i < _l.length(); i++){
        string rest = _l.substr(i);
      sum += stoll(_l.substr(0,i)) * pow(2, rest.length()-1) + calcSum(rest);
    }
    sum += stoll(_l);
  }
  return sum;
}

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


  ll answer;
  answer = calcSum(S);

  cout << answer << endl;


  return 0;
}


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

#define int long long

const int INF = 1e15;

int dp[55555];
int c[22];

int n, m;

int rec(int money) {
  if (money == 0) {
    return dp[money] = 0;
  }

  if (dp[money] != INF) {
    return dp[money];
  }

  int ans = INF;
  for (int i = 0; i < m; i++) {
    if (money - c[i] < 0) continue;
    ans = min(ans, rec(money - c[i]) + 1);
  }

  return dp[money] = ans;
}

signed main() {
  cin >> n >> m;
  fill(dp, dp + n + 10, INF);
  for (int i = 0; i < m; i++) {
    cin >> c[i];
  }

  cout << rec(n) << endl;

  return 0;
}


Measured memory_bytes: 5004
#include <stdio.h>

int main() {
    int a, b, sum, digit;
    while ( scanf("%d %d", &a, &b) != EOF ) {
        sum = a + b;
        digit = 0;
        while (sum!=0) {
            sum = sum / 10;
            ++digit;
        }
        printf("%d\n", digit);
    }
    return 0;
}


Measured memory_bytes: 2112
n,i,j,k;
long sum[444],dp[444][444];
main(a)
{
	scanf("%d",&n);
	for(;~scanf("%d",&a);i++)sum[i+1]=sum[i]+a;
	for(;j++<n;)
	{
		for(i=j-1;i--;)
		{
			dp[i][j]=9e18;
			for(k=i;++k<j;)
			{
				dp[i][j]=fmin(dp[i][j],dp[i][k]+dp[k][j]+sum[j]-sum[i]);
			}
		}
	}
	printf("%ld",dp[0][n]);
}

Measured memory_bytes: 1536
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const int INF = 1e9;

string S;

bool dfs(int i, int g) {
    if(i == g)
        return true;
    if(S[i] == '#')
        return false;
    return dfs(i + 1, g) || dfs(i + 2, g);
}

int main() {
    int N, A, B, C, D;
    cin >> N >> A >> B >> C >> D;
    A--, B--, C--, D--;
    cin >> S;

    bool flag = false;
    if(C > D)
        flag = true;

    if(flag) {
        for(int i = B; i <= D; ++i) {
            if(S[i - 1] == '.' && S[i] == '.' && S[i + 1] == '.')
                flag = false;
        }
    }

    if(!flag && dfs(A,C) && dfs(B,D))
        cout << "Yes" << endl;
    else
        cout << "No" << endl;

    return 0;
}


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

int main() {
    int n;
    cin >> n;
    vector<ll> a(n);
    rep(i, n) cin >> a[i];
    sort(a.rbegin(), a.rend());

    ll ans = a[0];
    ll sa = 0;
    for (int i = 1; i < (n + 1) / 2; ++i) {
        ans += a[i] * 2;
        if (i == (n + 1) / 2 - 1)
            sa = a[i];
    }

    if (n % 2 == 1)
        ans -= sa;

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 4840
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0,i##_len=(n);i<i##_len;++i)
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
#define All(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
class SOSU{
 private:
    vector<int> Prime_Number;
    vector<bool> isp;
 public:
    SOSU(int N){
        isp.resize(N+1,true);
        isp[0]=isp[1]=false;
        rep(i,2,N+1) if(isp[i]){
            Prime_Number.push_back(i);
            for(int j=2*i;j<=N;j+=i) isp[j]=false;
        }
    }
    int operator[](int i){return Prime_Number[i];}
    int size(){return Prime_Number.size();}
    int back(){return Prime_Number.back();}
    bool isPrime(int q){return isp[q];}
};
class Divisor{//素因数分解をしてから約数列挙、分解結果はＰ(底,指数)でpfacにまとめている
  private:
    vector<ll> F;
    vector<P> pfactorize;
  public:
    Divisor(ll N){
        for(ll i = 1; i * i <= N; i++) {
            if(N % i == 0) {
                F.push_back(i);
                if(i * i != N) F.push_back(N / i);
            }
        }
        sort(begin(F), end(F));
		SOSU p(sqrt(N)+1);
    	REP(i,p.size()){
    		pfactorize.push_back(P(p[i],0));
    		while(N%p[i]==0){
    			N/=p[i];
    			pfactorize.back().second++;
    		}
            if(pfactorize.back().second==0) pfactorize.pop_back();
    	}
    	if(N>1) pfactorize.push_back(P(N,1));
    }
    int size(){return F.size();}
    vector<P> pfac(){return pfactorize;}
    ll operator[](int k){return F[k];}
};
int main(){
    ll N;cin>>N;
    Divisor d(N);
    ll ans=LLONG_MAX;
    REP(i,d.size()){
        ans=min(ans,N/d[i]+d[i]-2);
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 1020
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <functional>
#include <bitset>
#include <numeric>
#include <complex>
#include <cassert>
#include <random>


int main() {
    int n; std::cin >> n;
    std::string s; std::cin >> s;
    int cnt = 0;
    for (int i = 0; i < n - 2; i++) {
        cnt += s[i] == 'A' && s[i + 1] == 'B' && s[i + 2] == 'C';
    }
    std::cout << cnt << std::endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<cstddef>
#include<queue>
#include<math.h>
#include<iomanip>
using namespace std;

int main()
{
    long long inx, k, d, ans = 0;
    cin >> inx >> k >> d;
    long long x = abs(inx);
    long long move = x / d;
    long long rest = x % d;
    if(move >= k) ans = x - d * k;
    else if(move < k){
        if((k - move) % 2 == 0) ans = min(rest, 2 * d - rest); 
        else if((k - move) % 2 == 1) ans = d - rest;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3620
a=gets.chomp.to_i
ary=[]
a.times do 
  c=gets.chomp
  ary.push(c)
end

ary=ary.each_with_object(Hash.new(0)){|v,o| o[v]+=1}
u=ary.max{|x,y| x[1]<=>y[1]}
h=u[1]
k=[]
ary.each do |x,y|
  if y==h
    k.push(x)
  end
end
k=k.sort
puts k

Measured memory_bytes: 46312
import math
# 入力
a, b, C = (int(i) for i in input().split())

# Cのラジアン表記、Cradの計算
Crad = C * math.pi / 180

# Sの計算と出力（sinを使った面積計算公式）
S = 0.5 * a * b * math.sin(Crad)
print(S)

# 対辺cの計算（余弦定理）
c = math.sqrt(a**2 + b**2 - 2*a*b*math.cos(Crad))

# lの計算と出力
l = a + b + c
print(l)

# hの計算と出力（面積計算公式）
h = 2 * S / a
print(h)


Measured memory_bytes: 5728
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <vector>
#define rep(i,n) for(int i=0;i<n;i++)
#define ll long long int
#define ii pair<int,int>
#define MAX 1000000007
using namespace std;

int main(void){
	string s;
	cin>>s;
	int num=0;
	ll ans=0;
	rep(i,s.length()){
		if(s[i]=='A')num++;
		if(s[i]=='B' && s[i+1]=='C'){
			ans+=num;
			i++;
		}
		else if(s[i]=='B' || s[i]=='C')num=0;
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#ifdef ENABLE_DEBUG
#define dump(a) cerr<<#a<<"="<<a<<endl
#define dumparr(a,n) cerr<<#a<<"["<<n<<"]="<<a[n]<<endl
#else
#define dump(a) 
#define dumparr(a,n) 
#endif
#define FOR(i, a, b) for(ll i = a;i < b;i++)
#define For(i, a) FOR(i, 0, a)
#define REV(i, a, b) for(ll i = b-1;i >= a;i--)
#define Rev(i, a) REV(i, 0, a)
#define REP(a) For(i, a)
#define SIGN(a) (a==0?0:(a>0?1:-1))

typedef long long int ll;
typedef unsigned long long ull;
typedef unsigned int uint;
typedef pair<ll, ll> pll;
typedef pair<ll,pll> ppll;
typedef vector<ll> vll;
typedef long double ld;
typedef pair<ld,ld> pdd;

const ll INF=(1LL<<50);
#if __cplusplus<201700L
ll gcd(ll a, ll b) {
  if(a < b) return gcd(b, a);
  ll r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}
#endif

template<class S,class T>
std::ostream& operator<<(std::ostream& os,pair<S,T> a){
  os << "(" << a.first << "," << a.second << ")";
  return os;
}
template<class T>
std::ostream& operator<<(std::ostream& os,vector<T> a){
  os << "[ ";
  REP(a.size()){
    os<< a[i] << " ";
  }
  os<< " ]";
  return os;
}

ll comb(ll a,ll b){
  b=min(b,a-b);
  if(b<0||b>a){
    return 0;
  }
  ll ret=1;
  REP(b){
    ret*=(a-i);
  }
  REP(b){
    ret/=(i+1);
  }
  return ret;
}
void solve(string N, long long K){
  if(N.size()<K){
    cout<<0<<endl;
    return;
  }
  ll ans=0;
  ll tmp1=1;
  REP(K){
    tmp1*=9;
  }
  REP(N.size()-K){
    ans+=tmp1*comb(i+K-1,i);
  }
  dump(N.size());
  ll cur=0,i=0;
  while(cur<K&&i<N.size()){
    if(N[i]!='0'){
      ++cur;
      tmp1/=9;
      ans+=(N[i]-'1')*tmp1*comb(N.size()-cur,N.size()-K);
      if(i!=0){
        ans+=tmp1*9*comb(N.size()-i-1,N.size()-K-(i+1-cur+1));
      }
    }else{
    }
    ++i;
    dump(i);
    dump(ans);
  }
  dump(cur);
  if(cur==K){
    ++ans;
  }
  cout<<ans<<endl;
}

int main(){
  cout<<setprecision(1000);
  cin.tie(0);
  ios::sync_with_stdio(false);
    string N;
    cin>>N;
    long long K;
    cin>>K;
    solve(N, K);
    return 0;
}


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

ll a,b,c,n,m;
ll ans=100000000000;
string s;

int main() {
	cin.tie(0);
  ios::sync_with_stdio(false);
  cin>>a;
  long sum=0;
  for(int i=0; i<=a; i++){
    if(i%3 !=0 && i%5 !=0)sum+=i;
  }
  cout<<sum;

  return 0;
}



Measured memory_bytes: 3656