akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"

using namespace std;

using ll = long long;
using ld = long double;

const double PI = 3.1415926535897932384626433832795;
const ll MOD = 1000000007;

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

int gcd(int x, int y) { return y ? gcd(y, x % y) : x; }
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
int lcm(int x, int y) { return x / gcd(x, y) * y; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }

const ll INF = 1e10;

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

	ll n, m, l;
	cin >> n >> m >> l;

	vector<vector<ll>> g(n, vector<ll>(n, INF));
	for (int i = 0; i < n; i++) {
		g[i][i] = 0;
	}

	for (int i = 0; i < m; i++) {
		ll a, b, c;
		cin >> a >> b >> c;
		a--; b--;

		g[a][b] = g[b][a] = c;
	}

	for (int k = 0; k < n; k++) {
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < n; j++) {
				g[i][j] = min(g[i][j], g[i][k] + g[k][j]);
			}
		}
	}

	vector<vector<ll>> dp(n, vector<ll>(n, INF));
	for (int i = 0; i < n; i++) {
		dp[i][i] = 0;
	}
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			if (g[i][j] == INF || g[i][j] > l) {
				continue;
			}
			dp[i][j] = 1LL;
		}
	}

	for (int k = 0; k < n; k++) {
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < n; j++) {
				dp[i][j] = min(dp[i][j], dp[i][k] + dp[k][j]);
			}
		}
	}

	int q;
	cin >> q;
	for (int i = 0; i < q; i++) {
		int s, t;
		cin >> s >> t;
		s--; t--;

		if (dp[s][t] == INF) {
			cout << -1 << endl;
			continue;
		}

		cout << dp[s][t] - 1 << endl;
	}
	return 0;
}


Measured memory_bytes: 2048
#include <iostream>

using namespace std;

int main()
{
	int n, t, cnt;

	while (cin >> n)
	{
		cnt = 0;

		for (int i = 0; i < 10; i++)
		{
			for (int j = 0; j < 10; j++)
			{
				for (int k = 0; k < 10; k++)
				{
					t = n - (i + j + k);

					if (0 <= t && t < 10) { cnt++; }
				}
			}
		}

		cout << cnt << endl;
	}

	return 0;
}

Measured memory_bytes: 1156
#include <cstdio>
#include <cstring>
#include <cmath>
#include <vector>
#include <list>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <iostream>
#include <sstream>
using namespace std;

typedef long long int64;
const int inf = (int)1e9;

int main()
{
	while(true) {
		
		char str1[4096], str2[4096];
		
		if(scanf("%s", str1) == EOF)
			break;
		scanf("%s", str2);
		
		int len1 = strlen(str1), len2 = strlen(str2);
		int ans = 0;
		static int dp[2][4096] = {0};
		
		for(int i = 0; i <= len1; ++i)
			dp[0][i] = 0;
		
		int *cur = dp[0];
		int *next = dp[1];
	
		for(int i = 1; i <= len1; ++i) {
			
			
			cur[0] = 0;
			
			for(int j = 1; j <= len2; ++j) {
				if(str1[i - 1] == str2[j - 1]) {
					next[j] = cur[j - 1] + 1;
					ans = max(next[j], ans);
				} else {
					next[j] = 0;
				}
			}
			
			swap(cur, next);
		}
		
		printf("%d\n", ans);
	}
	
	return 0;
}

/* ハラスメントに負けず */
/* 0完太陽にも負けず */
/* はやく人権を獲得したい */
/* nullmineralが書きましたが */
/* 責任はまったくとりません */

Measured memory_bytes: 1176
using System;
using System.Linq;
using System.Diagnostics;
using System.Collections.Generic;
using static System.Math;

class P
{
    static void Main()
    {
        int max = int.MaxValue;
        //sum
        //A:0011
        //B:0101
        //  0110
        //XORは桁で完結
        //Sum->
        //A:0011
        //B:0101
        //  0110(1)
        //繰り上がりが起こらない存在
        //0がある場合はなんの変化もないので0があるところをマーク 無い限りは20で終わる
        int n = int.Parse(Console.ReadLine());
        long[] a = Console.ReadLine().Split().Select(long.Parse).ToArray();
        List<long> list = new List<long>();
        long zeroCount = 0;
        long res = 0;
        for (int i = 0; i < a.Length; i++)
        {
            if(a[i] != 0)
            {
                list.Add(-zeroCount);
                res += (zeroCount * (zeroCount + 1)) / 2;
                zeroCount = 0;
                list.Add(a[i]);
            }
            else
            {
                zeroCount++;
            }
        }
        list.Add(-zeroCount);
        res += (zeroCount * (zeroCount + 1)) / 2;
        zeroCount = 0;
        a = list.ToArray();

        n = (list.Count - 1) / 2;
        //0102030405060
        for (int i = 0; i < n; i++)
        {
            long sum = 0;
            long xor = 0;
            for (int j = i; j < n; j++)
            {
                sum += a[j * 2 + 1];
                xor ^= a[j * 2 + 1];
                if (sum == xor) res += ((-a[i * 2]) + 1) * ((-a[j * 2 + 2]) + 1);
                else break;
            }
        }
        Console.WriteLine(res);
    }
}

Measured memory_bytes: 42836
#include <stdio.h>

int abs(int a) {
  return a > 0 ? a : -a;
}

int main(void) {
  int i, n, ans = 1e9, ansn, now = 0;
  scanf("%d", &n);
  int a[n];
  for(i = 0; i < n; ++i) scanf("%d", &a[i]), now += a[i];
  for(i = 0; i < n; ++i) if(ans > abs(now - a[i] * n)) ans = abs(now - a[i] * n), ansn = i;
  printf("%d", ansn);
  return 0;
}

Measured memory_bytes: 128
N = int(input())
P = list(map(int, input().split()))

index_lst = [0] * N
for index, i in enumerate(P):
    index_lst[i - 1] = index

left_next_Index = list(range(-1, N - 1)) + [-1, -1]
right_next_Index = list(range(1, N + 1)) + [N, N]
# print (left_next_Index)
# print (right_next_Index)
ans = 0
for i in range(1, N):
    index = index_lst[i - 1]
    # print (i, index)
    l1 = left_next_Index[index]
    l2 = left_next_Index[l1]
    r1 = right_next_Index[index]
    r2 = right_next_Index[r1]
    # print ('l1 =', l1, ' l2 =', l2, ' r1 =', r1, ' r2 =', r2)
    ans += i * ((index - l1) * (r2 - r1) + (r1 - index) * (l1 -l2))

    left_next_Index[r1] = l1
    right_next_Index[l1] = r1

print (ans)

Measured memory_bytes: 19576
#include <bits/stdc++.h>
#define rb(x) ((x)&(-(x)))
#define upmin(a,b) (a)=min((a),(b))
#define upmax(a,b) (a)=max((a),(b))
#define INF (0x3f3f3f3f)
#define INFLL (0x3f3f3f3f3f3f3f3fll)
using namespace std;
typedef long long ll;

const int MAXN = 100005;
const int MX = 131072;

struct SEG {
	SEG() { init(); }
	ll d[MX*2];
	void init() { fill(d, d+MX*2, INFLL); }
	void upd(int x, ll r) {
		x += MX; d[x] = r;
		for(x /= 2; x; x /= 2)
			d[x] = min(d[x*2], d[x*2+1]);
	}
	ll get(int s, int e) {
		ll r = INFLL; for(s += MX, e += MX; s <= e; s /= 2, e /= 2) {
			if(s&1) upmin(r, d[s++]); if(~e&1) upmin(r, d[e--]);
		} return r;
	}
} seg1, seg2;

ll dp[MAXN];

int A[MAXN];

int N, T, E;

int main() {
	scanf("%d%d%d", &N, &E, &T);
	for(int i = 1; i <= N; i++) scanf("%d", &A[i]);

	seg1.upd(0, 0);
	seg2.upd(0, -2 * ll(A[1]));

	for(int i = 1; i <= N; i++) {
		ll &ret = dp[i];
		ret = INFLL;

		int li = max(0, (int)(lower_bound(A, A+i, A[i] - T/2) - A) - 1);
		if(li < i)
			upmin(ret, seg1.get(li, i-1) + A[i] + T);
		if(0 < li)
			upmin(ret, seg2.get(0, li-1) + ll(A[i])*3);

		seg1.upd(i, ret - A[i]);
		seg2.upd(i, ret - A[i] - ll(A[i+1])*2);
	}

	printf("%lld\n", dp[N] + E - A[N]);
	return 0;

}

Measured memory_bytes: 5504
//Deep Godhani
//DAIICT

#include<bits/stdc++.h>
using namespace std;

#define N 100000000000
#define PI acos(-1)
#define INF LONG_LONG_MAX
#define NINF LONG_LONG_MIN
#define ll long long int
#define ld long double
#define precision(x,d) cout << fixed << setprecision(d) << x
#define FAST ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);srand(time(NULL))

#include <bits/stdc++.h>
using namespace std;

const ll M = 1e9+7;

void solve()
{
  ld a,b,ans;
  cin >> a >> b;
  a = a*b;
  ld temp = modf(a,&ans);
  cout << (ll)ans << endl;
}

int main()
{
    FAST;

    ll t=1;
    //cin >> t;
    while(t--)
    {
      solve();
    }
    return 0;
}


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

int main()
{
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	string s;
	cin >> s;
	int length = s.size();
	int ans = 0;
	for (int i = 0, j = length - 1; i < length / 2; ++i, j--)
	{
		if (s[i] != s[j])
		{
			ans++;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3616
#include <iostream>
#include <algorithm>
using namespace std;
int main(){
int n;
cin >>n;
int b;
long long int c[21][n-1];
cin >>b;
int d;
d=0;
while(d<21){
if(d==b){c[d][0]=1;}
else{c[d][0]=0;}
d=d+1;}
int e;
e=1;
while(e<n-1){
d=0;
cin >>b;
while(d<21){
c[d][e]=0;
if(d>=b){c[d][e]=c[d][e]+c[d-b][e-1];}
if(d+b<=20){c[d][e]=c[d][e]+c[d+b][e-1];}
d=d+1;}
e=e+1;}
cin >>b;
cout <<c[b][n-2]<<endl;}

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

//?????¢??¢?´¢
int search(int A[], int n, int key) {
    int i = 0;
    A[n] = key;
    while (A[i] != key) {
        i++;
    }
    return i != n;
}

int main() {
    int i, n, A[10000+1], q, key, sum = 0;

    scanf("%d", &n);
    for(i = 0; i < n; i++) {
        scanf("%d", &A[i]);
    }

    scanf("%d", &q);
    for(i = 0; i < q; i++) {
        scanf("%d", &key);
        if (search(A, n, key)) {
            sum++;
        }
    }
    printf("%d\n", sum);
    return 0;
}

Measured memory_bytes: 3216
#include <algorithm>
#include <bitset>
#include <cassert>
#include <chrono>
#include <climits>
#include <cmath>
#include <complex>
#include <cstring>
#include <deque>
#include <functional>
#include <iostream>
#include <iomanip>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <cstdint>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
#define MP make_pair
#define PB push_back
#define inf 1000000007
#define rep(i,n) for(int i = 0; i < (int)(n); ++i)
#define all(x) (x).begin(),(x).end()

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}
 
template<class T> inline bool chmax(T &a, T b){
    if(a<b){
        a = b;
        return true;
    }
    return false;
}

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



int main(){
    int n,m;
    cin >> n >> m;
    vector<int> h(n);
    rep(i,n)cin >> h[i];
    vector<bool> p(n,1);
    rep(i,m){
        int a,b;
        cin >> a >> b;
        a--; b--;
        if(h[a]>h[b]){
            p[b] = 0;
        }else if(h[b]>h[a]){
            p[a] = 0;
        }else{
            p[a] = p[b] = 0;
        }
    }
    int sm = 0;
    rep(i,n){
        if(p[i]){
            sm++;
        }
    }
    cout << sm << endl;
    return 0;
}

Measured memory_bytes: 3420
n = int(input())
c = sorted(list(map(int, input().split())),reverse=True)
mod = 10**9 + 7
ans = 0
two = [1]
for i in range(n*2):
  two += [(two[i]*2) % mod]

for i in range(n):
  ans += (i+2) * c[i]
  ans %= mod
ans *= two[2*n - 2]
print(ans%mod)

Measured memory_bytes: 29420
#include <cstdio>

#include <atcoder/dsu>

int main() {
  int n, q;
  scanf("%d %d", &n, &q);

  atcoder::dsu dsu(n);
  for (int i = 0; i < q; ++i) {
    int t, u, v;
    scanf("%d %d %d", &t, &u, &v);

    if (t == 0) {
      dsu.merge(u, v);
    } else if (t == 1) {
      printf("%d\n", dsu.same(u, v)? 1: 0);
    }
  }
}


Measured memory_bytes: 3428
def check(arr, x, y):
    d = ((0, -1), (0, 1), (1, -1), (1, 0), (1, 1), (-1, -1), (-1, 0), (-1, 1))

    if arr[x][y] == '#':
        return -1
    else:
        cnt = 0
        for dx, dy in d:
            try:
                if (x+dx) >=0 and (y+dy) >= 0:
                    if arr[x + dx][y + dy] == '#':
                        cnt += 1
            except:
                pass
    return cnt    

h, w = map(int, input().split())
s = []
for _ in range(h):
    s.append(input())
ans = []
for x in range(h):
    for y in range(w):
        val = check(s, x, y)
        if val == -1:
            ans.append('#')
        else:
            ans.append(val)

for i in range(h*w):
    print(ans[i], end="")
    if (i+1)%w == 0:
        print()

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

using namespace std;

int n,d=0; string a,b,c;

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin >> n;
    cin >> a >> b >> c;
    for (int i=0;i < n;i++)
    {
        if(a[i]==b[i]&& b[i]==c[i])
        {
            d+=0;
        }
        else
        {
            if(a[i]==b[i] || a[i]==c[i] || c[i]== b[i])
            {
                d+=1;
            }
            else d+=2;
        }
    }
    cout << d;
    return 0;
}

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

#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 pair<int, int> pii;
typedef vector<int> vi;

int main() {
  cin.sync_with_stdio(0); cin.tie(0);
  cin.exceptions(cin.failbit);
  string s;
  cin >> s;
  int n = sz(s)+1;
  vi l(n,0), r(n,0);
  rep(i,0,n-1)
    l[i+1] = s[i] == '<' ? l[i]+1 : 0;
  for(int i = n-1; i >= 1; --i)
    r[i-1] = s[i-1] == '>' ? r[i]+1 : 0;

  ll sm = 0;
  rep(i,0,n) sm += max(l[i], r[i]);
  cout << sm << endl;
}


Measured memory_bytes: 4764
use strict;
use warnings;

my $next_sunday = {
    'SUN' => 7,
    'MON' => 6,
    'TUE' => 5,
    'WED' => 4,
    'THU' => 3,
    'FRI' => 2,
    'SAT' => 1,
};

my $day = <STDIN>;
chomp($day);

print $next_sunday->{$day};

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

using namespace std;

int main(){

	int N,K;

	cin >> N>> K;

	vector<int> A(N,0);

	for(int i=0;i<N;i++){
		cin >> A[i];
	}

	vector<int> DP(K+1,0);

	for(int k=1;k<=K;k++){

		int s = 1;
		for(int j=0;j<N;j++){

			if(k>=A[j]){
				s = (s)&&(DP[k-A[j]]);
			}
		}

		DP[k] = (!s);
		
	}
	

	string ans = (DP[K]==1)?"First":"Second";
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 3788
n=int(input())
s=input()

E = [0 for i in range(n)]
W = [0 for i in range(n)]

for i in range(n):
    if s[i] == "E":
        E[i] = 1
    else:
        W[i] = 1
for i in range(n-1):
    W[i+1] += W[i]
    E[-i-2] += E[-i-1]

ans = float("inf")
for i in range(n):
    if i == 0:
        ans = min(ans, E[i+1])
    elif i == n-1:
        ans = min(ans, W[i-1])
    else:
        ans = min(ans, E[i+1]+W[i-1])

print(ans)
#print(E)
#print(W)

Measured memory_bytes: 65252
#include "vector"
#include "iostream"
#include "algorithm"

using namespace std;

int main()
{
	int x, y;
	cin >> x >> y;
	vector<int> a = { 1, 3, 5, 7, 8, 10, 12 };
	vector<int> b = {4, 6, 9, 11};
	vector<int> c = {2};
	auto rax = find(a.begin(), a.end(), x);
	auto ray = find(a.begin(), a.end(), y);
	auto rbx = find(b.begin(), b.end(), x);
	auto rby = find(b.begin(), b.end(), y);
	auto rcx = find(c.begin(), c.end(), x);
	auto rcy = find(c.begin(), c.end(), y);
	if (rax != a.end() && ray != a.end())
	{
		cout << "Yes" << endl;
		return 0;
	}
	else if(rbx != b.end() && rby != b.end())
	{
		cout << "Yes" << endl;
		return 0;
	}
	else if (rcx != c.end() && rcy != c.end())
	{
		cout << "Yes" << endl;
		return 0;
	}
	cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

using pi = pair<int,int>;
const int INF = 19191919;

int dist(pi p, pi q){
    return abs(p.fi-q.fi) + abs(p.se-q.se);
}

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

    map<pi,int> ct;
    rep(i,n-1){
        int a = s[i]-'0', b = s[i+1]-'0';
        ++ct[{a,b}];
    }

    int ans = INF;
    vector<int> v(9);

    vector<int> p(9);
    rep(i,9) p[i] = i+1;
    do{
        vector<pi> pos(10);
        rep(i,9) pos[p[i]] = {i/3,i%3};

        int t = 0;
        for(const auto &pp:ct){
            int num = pp.se;
            int a = pp.fi.fi, b = pp.fi.se;
            t += num * dist(pos[a],pos[b]);
        }

        if(t < ans){
            ans = t;
            v = p;
        }
    }while(next_permutation(all(p)));

    rep(i,3){
        rep(j,3) cout << v[3*i+j];
        cout << "\n";
    }
    return 0;
}



Measured memory_bytes: 3316
s = gets.to_i
a = Array.new
ans = 0
i = 0
def f (hoge)
    return hoge.odd? ? (3 * hoge + 1) : hoge / 2
end
loop do 
   if i == 0 then
    a[i] = s
   elsif i >= 1 then
    a[i] = f(a[i - 1])
   end
   if a.uniq! != nil then
    ans = i + 1
    break
   end
   i += 1
end
puts ans

Measured memory_bytes: 2300
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define dbg(...) do{cerr<<__LINE__<<": ";dbgprint(#__VA_ARGS__, __VA_ARGS__);}while(0);

using namespace std;

namespace std{template<class S,class T>struct hash<pair<S,T>>{size_t operator()(const pair<S,T>&p)const{return ((size_t)1e9+7)*hash<S>()(p.first)+hash<T>()(p.second);}};template<class T>struct hash<vector<T>>{size_t operator()(const vector<T> &v)const{size_t h=0;for(auto i : v)h=h*((size_t)1e9+7)+hash<T>()(i)+1;return h;}};}
template<class T>ostream& operator<<(ostream &os, const vector<T> &v){os<<"[ ";rep(i,v.size())os<<v[i]<<(i==v.size()-1?" ]":", ");return os;}template<class T>ostream& operator<<(ostream &os,const set<T> &v){os<<"{ "; for(const auto &i:v)os<<i<<", ";return os<<"}";}
template<class T,class U>ostream& operator<<(ostream &os,const map<T,U> &v){os<<"{";for(const auto &i:v)os<<" "<<i.first<<": "<<i.second<<",";return os<<"}";}template<class T,class U>ostream& operator<<(ostream &os,const pair<T,U> &p){return os<<"("<<p.first<<", "<<p.second<<")";}
void dbgprint(const string &fmt){cerr<<endl;}template<class H,class... T>void dbgprint(const string &fmt,const H &h,const T&... r){cerr<<fmt.substr(0,fmt.find(","))<<"= "<<h<<" ";dbgprint(fmt.substr(fmt.find(",")+1),r...);}
typedef long long ll;typedef vector<int> vi;typedef pair<int,int> pi;const int inf = (int)1e9;const double INF = 1e12, EPS = 1e-9;

int main(){
	cin.tie(0); cin.sync_with_stdio(0);
	
	int n; cin >> n;
	vector<vi> a(n, vi(n));
	rep(i, n) rep(j, n) if(i != j) cin >> a[i][j];
	
	vector<vector<ll>> dp(n, vector<ll>(n, 1e18));
	vector<vector<ll>> ls(n + 1, vector<ll>(n));
	vector<vector<ll>> rs(n + 1, vector<ll>(n));
	
	rep(i, n) rep(j, n) rs[j + 1][i] = rs[j][i] + a[i][j];
	rep(i, n) rep(j, n) ls[j + 1][i] = ls[j][i] + a[j][i];
	
	vector<ll> sum(n + 1), lsd(n);
	rep(i, n) lsd[i] = ls[i][i];
	
	ll ans = 1e18;
	dp[0][0] = 0;
	rep(j, n) rep(i, j + 1){
		for(int k = n - 1; k > j; k--) sum[k] = sum[k + 1] + rs[j][k] - rs[i][k];
		ll tmp = 0;
		for(int k = j + 1; k < n; k++){
			dp[j][k] = min(dp[j][k], dp[i][j] + tmp + sum[k]);
			tmp += lsd[k] - ls[j][k];
		}		
		ans = min(ans, dp[i][j] + tmp);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 7168
#include <iostream>

using namespace std;
using ll = long long;

int main() {
  ll N, K;
  cin >> N >> K;

  ll a = N / K;
  ll b = (N + K / 2) / K;

  cout << (K % 2 == 0 ? a * a * a + b * b * b : a * a * a) << endl;

  return 0;
}


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

using namespace std;

int main(void) {
	long long N, K;
	cin >> N >> K;
	long long result = 0;
	if(K == 0) {
		cout << N * N << '\n';
		return 0;
	}
	for(long long b = K + 1; b <= N; ++b) {
		long long n = N / b * b;
		long long ng = K * (n / b);
		ng += min((N + 1) - n, K);
		result += (N + 1) - ng;
	}
	cout << result << '\n';
	return 0;
}



Measured memory_bytes: 256
n,q=map(int,input().split())
x= n-2
y= n-2
dx={}
dy={}

for _ in range(q):
    a,b=map(int,input().split())
    b-=1
    if a==1:
        if y< b:
            dy[b]=0;continue
        # y= b-1
        for i in range(b+1,y+1):
            dy[i] = x
        y=b-1

    if a==2:
        if x < b:
            dx[b]=0;continue
        # x=b-1
        for i in range(b+1,x+1):
            dx[i] =y
        x=b-1
print(x*y + sum(dx.values()) + sum(dy.values()) )


Measured memory_bytes: 131072
#include <bits/stdc++.h>
#include <math.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rrep(i, n) for(int i = 0; i <= (n); i++)
using namespace std;
typedef long long ll;
 
const ll INF = 1LL<<62;
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; }
// 多次元 vector 生成
template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}
template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
  return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

const int MOD = 1000000007;

int main(){
    int N; cin >> N;
    vector<vector<int>> F(N, vector<int>(10));
    rep(i,N){
        rep(j,10){
            cin >> F[i][j];
        }
    }
    vector<vector<int>> P(N, vector<int>(11));
    rep(i,N){
        rep(j,11){
            cin >> P[i][j];
        }
    }

    ll ans = -INF;
    for (int i = 1; i < (1<<10); i++){
        ll benefit = 0;
        vector<int> isOpen(10, 0);
        rep(j,10){
            isOpen[j] = (i >> j) & 1;
        }

        rep(j,N){
            int count = 0;
            rep(k,10){
                if (F[j][k] == 1 && isOpen[k] == 1){
                    count++;
                }
            }
            benefit += P[j][count];
        }
        ans = max(ans, benefit);

    }

    cout << ans << endl;
}

Measured memory_bytes: 3564
# include <iostream>


using namespace std;


int main () {
    int n, l; cin >> n >> l;
    int apple_pie = 0;
    int min_diff = 1001001001;

    for (int i=1; i<=n; ++i) apple_pie += l+i-1;

    int ans, tmp_apple_pie;
    for (int i=1; i<=n; ++i) {
        tmp_apple_pie = apple_pie - (l+i-1);
        if (abs(apple_pie - tmp_apple_pie) < min_diff) {
            min_diff = abs(apple_pie - tmp_apple_pie);
            ans = tmp_apple_pie;
        }
    }

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


Measured memory_bytes: 256
#include<iostream>
#include<map>
#include<cmath>

using namespace std;
using pii = pair<int,int>;

constexpr int H_MAX = 300, W_MAX = 300;

pii pos[H_MAX*W_MAX + 3] = {};
int cost[H_MAX*W_MAX + 3] = {};

int main(){
    int h, w, d;

    cin >> h >> w >> d;

    int a;
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            cin >> a;
            pos[a] = pii(i,j);
        }
    }

    for(int i=1;i<=d;i++)
        cost[i] = 0;
    for(int i=d+1;i<=h*w;i++){
        cost[i] = cost[i-d] + abs(pos[i].first-pos[i-d].first) + abs(pos[i].second-pos[i-d].second);
    }

    int q, l, r;
    cin >> q;

    for(int k=0;k<q;k++){
        cin >> l >> r;
        cout << cost[r] - cost[l] << endl;
    }

    return 0;
}

Measured memory_bytes: 2176
S = list(input())
T = list(input())
key = T[0]
flag = False
k = 0

for i in range(len(S)):
	if S[i] == key:
		k = i
		flag = True
		break

if not flag:
	print("No")
	exit()

for i in range(len(S)):
	if not T[i] == S[(k + i) % len(S)]:
		flag = False
		break

if flag:
	print("Yes")
else:
	print("No")


Measured memory_bytes: 3064
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7
 
N, M = MAP()
ks = [LIST() for _ in range(M)]
p = LIST()
 
ans = 0
for x in product([0, 1], repeat=N):
	#print(x)
	for i in range(M):
		cnt = 0
		for j in range(ks[i][0]):
			#print(i, ks[i][j+1])
			if x[ks[i][j+1]-1] == 1:
				cnt += 1
		if cnt%2 != p[i]:
			break
	else:
		ans += 1

print(ans)

Measured memory_bytes: 5204
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n,m,x;
    cin>>n>>m>>x;
    vector<int> c(n);
    vector<vector<int>> A(12,vector<int>(12));
    for(int i=0;i<n;i++){
        cin>>c[i];
        for(int j=0;j<m;j++){
            cin>>A[i][j];
        }
    }
    vector<int> sum(m,0);
    for(int i=0;i<m;i++){
        for(int j=0;j<n;j++){
            sum[i]+=A[j][i];
        }
    }
    bool ans1=true;
    for(int i=0;i<m;i++){
        if(sum[i]<x) ans1=false;
    }

    if(!ans1) cout<<-1<<endl;
    else{
        int minv=(1<<30);
        for(int i=0;i<(1<<12);i++){
            bitset<12> t(i);
            vector<int> sum1(m,0);
            int price=0;
            for(int j=0;j<m;j++){
                for(int k=0;k<n;k++){
                    if(t.test(k)){
                        sum1[j]+=A[k][j];
                        if(j==0){
                            price+=c[k];
                        }
                    }
                }
            }
            bool ans2=true;
            for(int j=0;j<m;j++){
                if(sum1[j]<x) ans2=false;
            }
            if(ans2){
                minv=min(minv,price);
            }
        }
        cout<<minv<<endl;
    }


}

Measured memory_bytes: 3624
s = list(input())
k = int(input())

def count_replace(l):
    ret = 0
    cnt = 1
    for i in range(len(l)-1):
        if l[i] == l[i+1]: #
            cnt += 1
        elif l[i] != l[i+1]:
            ret += cnt//2
            cnt = 1
    ret += cnt // 2 # 最後尾（ループが尽きた）のための処理. 末尾が連続していた場合には連続分が追加、それ以外は0が追加
    return ret

if len(set(s)) == 1: # すべての文字が同じとき
    ans = (len(s) * k) // 2
elif s[0] != s[-1]: #先頭末尾が一致しないとき
    ans = count_replace(s)
    ans = k * ans
else: # 先頭末尾が一致
    # 先頭の連続する文字数
    cnt_pre = 1
    for i in range(len(s)-1):
        if s[i] == s[i+1]:
            cnt_pre += 1
        else:
            break
    # 末尾の連続する文字数
    cnt_pos = 1
    for i in reversed(range(len(s))):
        if s[i] == s[i-1]:
            cnt_pos += 1
        else:
            break
    # 先頭の連続数//2+末尾の連続数//2＋(k-1)*（先頭+末尾）の連続数//2
    ans = cnt_pre//2 + cnt_pos//2 + (k-1) * ((cnt_pos+cnt_pre)//2)
    # 先頭、末尾以外の部分のカウント
    ret = count_replace(s[cnt_pre:-cnt_pos])
    ans += k * ret

print(ans)

Measured memory_bytes: 38512
#include "bits/stdc++.h"
using namespace std;

int main() {
	int N, F[100][10], P[100][11], ans = -1000000000, c, cc;
	cin >> N;
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < 10; j++) {
			cin >> F[i][j];
		}
	}
	for (int i = 0; i < N; i++) {
		for (int j = 0; j <= 10; j++) {
			cin >> P[i][j];
		}
	}
	for (int i = 1; i < 1024; i++) {
		cc = 0;
		for (int j = 0; j < N; j++) {
			int X = i;
			c = 0;
			for (int k = 0; k < 10; k++) {
				if (X % 2 == 1 && F[j][k] == 1) {
					c++;
				}
				X /= 2;
			}
			cc += P[j][c];
		}
		ans = max(ans, cc);
	}
	cout << ans;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<utility>
#include<algorithm> // sort
#include<map> // pair
#include<cmath>
#include<cstring>
#include<set>
using namespace std;
using ll = long long;
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; }
#define rep(i, n) REP(i, 0, n)
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
#define all(x) (x).begin(),(x).end()
const ll mod = 1e9+7;
const int INF = 1e9;
const ll INFLONG = 1e18;
// vector<vector<ll>> vec(100000,vector<ll>(3,0));
int main(){
  ll n;
  ll tmp,tmp1,tmp2;
  cin >> n;
  ll ans=-1;
  vector<ll> num1(1e5+1,0);
  vector<ll> num2(1e5+1,0);
  if(n == 2){
    cin >> tmp1 >> tmp2;
    if(tmp1 == tmp2){
      ans = 1;
    }else{
      ans = 0;
    }
    cout << ans;
    return 0;
  }
  rep(i,n){
    cin >> tmp;
    if(i % 2 == 0){
      num1[tmp]++;
    }else{
      num2[tmp]++;
    }
  }
  // for(auto itr:num1){
  //   cout << itr << " ";
  // }
  //cout << endl;
  auto itr1 = max_element(all(num1));
  size_t maxindex1 = distance(num1.begin(),itr1);
  auto itr2 = max_element(all(num2));
  size_t maxindex2 = distance(num2.begin(),itr2);
  sort(all(num1));
  sort(all(num2));
  //cout << maxindex1 <<" " <<  maxindex2;
  if(maxindex1 != maxindex2){
    ans = num1[num1.size()-1] + num2[num2.size()-1];
  }else{
    ans = max(num1[num1.size()-2]+num2[num2.size()-1],num2[num2.size()-2]+num1[num1.size()-1]);
  }
  ans = n - ans;
  cout << ans;
}


Measured memory_bytes: 1920
# import numpy as np
import sys, math, heapq
from itertools import permutations, combinations
from collections import defaultdict, Counter, deque
from math import factorial, gcd
from bisect import bisect_left, bisect_right

sys.setrecursionlimit(10 ** 7)
MOD = 10 ** 9 + 7
input = lambda: sys.stdin.readline()[:-1]
pl = lambda x: print(*x, sep="\n")

N = int(input())
S = input()

cnt = 0
for num in range(1000):
    snum = str(num).zfill(3)
    # print("snum", snum)
    ind = 0
    chkind = 0
    # while ind < len(S):
    for s in S:
        if chkind >= 3:
            break
        if s == snum[chkind]:
            chkind += 1
    if chkind == 3:
        cnt += 1
print(cnt)

Measured memory_bytes: 68668
#include<bits/stdc++.h>
using namespace std;
#define endl "\n"
#define mod 1000000007
//#define int long long int
unordered_map<string, bool>mp;
string factorial(long long n)
{
	if (n > 1000) {
		cout << " Integer Overflow"
		     << endl;
		return "";
	}

	long long counter;
	long double sum = 0;

	// Base case
	if (n == 0)
		return "1";

	// Calculate the sum of
	// logarithmic values

	for (counter = 1; counter <= n;
	        counter++) {
		sum = sum + log(counter);
	}
	cout << sum << endl;

	// Number becomes too big to hold in
	// unsigned long integers.
	// Hence converted to string
	// Answer is sometimes under
	// estimated due to floating point
	// operations so round() is used
	string result
	    = to_string(round(exp(sum)));

	return result;
}
bool solve(string a, string b)
{
	if (a.compare(b) == 0)
		return true;

	if (a.length() <= 1)  //if a ki length is 1 it means a!=b(becz we checked for equality above so it returns false
		return false;

	string key = a;
	key.push_back(' ');
	key.append(b);
	if (mp.find(key) != mp.end())
		return mp[key];

	int n = a.length();
	bool flag = false;

	for (int i = 1; i < n; i++)
	{
		bool cond_1 = false, cond_2 = false;
		if ((solve(a.substr(0, i), b.substr(n - i, i)) == true) && (solve(a.substr(i, n - i), b.substr(0, n - i)) == true))
			cond_1 = true;

		if ((solve(a.substr(0, i), b.substr(0, i)) == true) && (solve(a.substr(i, n - i), b.substr(i, n - i)) == true))
			cond_2 = true;

		if (cond_1 || cond_2)
		{
			flag = true;
			break;
		}
	}
	return mp[key] = flag;
}
int result(int n, unordered_map<int, int>&m)
{
	if (n <= 2)
		return 1;
	if (m.find(n) != m.end())
		return m[n];

	int ans = result(n - 1, m) + result(n - 2, m);
	return m[n] = ans;

}
int32_t main()
{
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int t, a = 0;
	string s = "No";
	cin >> t;
	while (t--)
	{
		int x, y;
		cin >> x >> y;
		if (x == y)
			a++;
		else
			a = 0;
		if (a >= 3)
			s = "Yes";
	}
	cout << s;
	return 0;
}

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

typedef long long ll;

bool check(string s){
  bool b3 = false, b5 = false, b7 = false;
  for(int i = 0; i < s.size(); i++){
    if(s[i] == '3') b3 = true;
    if(s[i] == '5') b5 = true;
    if(s[i] == '7') b7 = true;
    
    if(b3 && b5 && b7){
      break;
    }
  }
  return b3 && b5 && b7;
}

ll N;
ll num = 0;
void dfs(string s){
  ll x = stoll(s);
  if(x <= N && check(s)){
    num++;
    dfs(s+'3');
    dfs(s+'5');
    dfs(s+'7');
  } else if(x <= N){
    dfs(s+'3');
    dfs(s+'5');
    dfs(s+'7');
  }
}

int main(){
  cin >> N;
  dfs("3");
  dfs("5");
  dfs("7");
  cout << num << endl;
  
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int a[5][110],dp[5][110];
int main()
{
    int n;cin>>n;
    for(int i=1;i<=2;i++)
        for(int j=1;j<=n;j++)
            cin>>a[i][j];
    dp[1][1]=a[1][1];
    for(int i=1;i<=2;i++)
    {
        for(int j=1;j<=n;j++)
        {
            dp[i][j]=max(dp[i][j-1],dp[i-1][j])+a[i][j];
        }
    }
    cout<<dp[2][n]<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <cmath>
#define rep(i,cc,n) for(int i=cc;i<=n;++i)
#define drep(i,cc,n) for(int i=cc;i>=n;--i)
typedef long long ll;
using namespace std;
int main(){
    int n;
    cin>>n;
    int cnt = 0;
    rep(i,1,n) if(i%2!=0) cnt++;
    double ans = (double)cnt / (double)n;
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#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;

#define sint int32_t
#define int long long int
#define all(v) v.begin() , v.end()
#define pb push_back
#define pii pair<int,int>
#define F first
#define S second
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;



int32_t main()
{   fastio;

    int n;
    cin>>n;
    int sum=0;
    int arr[n];

    for(int i=0; i<n; i++)
        cin>>arr[i];

    for(int i=0; i<n-1; i++) {
        for(int j=i+1; j<n; j++)
            sum += arr[i]*arr[j];
    }
    cout<<sum<<endl;

}


Measured memory_bytes: 3580
#include <bits/stdc++.h>
#define ll long long
#define double long double
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define mod (ll)(1e9+7)
#define inf (ll)(3e18+7)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define all(x) x.begin(),x.end()
using namespace std;

int main() {
  int n, a, b;
  cin >> n >> a >> b;
  cout << min(b, a*n);
}

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

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

using i64 = int_fast64_t;
using u64 = uint_fast64_t;
using f64 = double;
using p64 = pair<i64, i64>;

constexpr i64 INF = INT_FAST64_MAX / 2;

i64 n;
vector<vector<vector<f64>>> dp;

f64 dfs(i64 i, i64 j, i64 k) {
    if (i < 0 || j < 0 || k < 0) return 0;
    if (i == 0 && j == 0 && k == 0) return 0;
    if (dp[i][j][k] >= 0) return dp[i][j][k];

    f64 res = (f64) n;
    res += (f64) i * dfs(i - 1, j , k);
    res += (f64) j * dfs(i + 1, j - 1, k);
    res += (f64) k * dfs(i, j + 1, k - 1);
    res /= (f64) (i + j + k);
    return dp[i][j][k] = res;
}

void solve() {
    cin >> n;

    i64 cnt1 = 0, cnt2 = 0, cnt3 = 0;
    for (i64 i = 0; i < n; i++) {
        i64 a;
        cin >> a;
        (a == 1 ? cnt1 : a == 2 ? cnt2 : cnt3)++;
    }

    dp.resize(n + 1, vector<vector<f64>>(n + 1, vector<f64>(n + 1, -1)));
    cout << dfs(cnt1, cnt2, cnt3) << endl;
}

int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
}


Measured memory_bytes: 219936
#include<cstdio>
#define R register
#include<algorithm>
using namespace std;
int a[203020];long long sum[203020];
int main()
{
	int n,l=1;long long ans=0;
	scanf("%d",&n);
	for (R int i=1;i<=n;++i) scanf("%d",&a[i]);
	for (R int i=1;i<=n;++i) sum[i]=sum[i-1]+a[i];sum[0]=0x7f7f7f7f;
	sort(sum+1,sum+1+n);
	for (R int i=2;i<=n;++i)
		if (sum[i]!=sum[i-1])
		{
			ans+=1ll*(i-l)*(i-l-1)/2;
			l=i;
		}
	ans+=1ll*(n+1-l)*(n-l)/2;
	for (R int i=1;i<=n;++i) if (!sum[i]) ++ans;
//	for (R int i=1;i<=n;++i) printf("%d ",sum[i]);
	printf("%lld",ans);
	return 0;
}

Measured memory_bytes: 2560
#include<stdio.h>
#include<stdlib.h>
#define LEN 7

struct node{
  int key;
  struct node *parent, *left, *right;
};

typedef struct node node;
typedef struct node * nodepointer;

void insert(int);
void inorder(nodepointer);
void preorder(nodepointer);

nodepointer root;

int main(){
  int n, k;
  int i;
  char com[LEN];

  scanf("%d", &n);
  for(i=0;i<n;i++){
    scanf(" %s", com);
    if(com[0] == 'i'){
      scanf("%d", &k);
      insert(k);
    }
    else{
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }
  }

  return 0;
}

void insert(int k){
  nodepointer x, y, z; //zが新しく挿入するノード

  z = (nodepointer)malloc(sizeof(node));
  //zの設定　zは葉だからleft,rightはnullでok
  z -> key = k;
  z -> left = NULL;
  z -> right = NULL;

  x = root; //たどる際のスタートは根
  y = NULL; //yはxの親
  //xがnullになるまでたどる。このときyはxの直前のノード、つまりxの親であり葉ノードである。
  while(x != NULL){
    y = x;
    if(z -> key < x -> key) x = x -> left;
    else x = x -> right;
  }
  z -> parent = y;

  //rootがnullのときwhile回らずにyはnullのまま
  //つまり、木が空っぽのときyはnull
  if(y == NULL) root = z;
  else if(z -> key < y -> key) y -> left = z;
  else y -> right = z;
}

void inorder(nodepointer n){
  if(n == NULL) return;
  inorder(n -> left);
  printf(" %d", n -> key);
  inorder(n -> right);
}

void preorder(nodepointer n){
  if(n == NULL) return;
  printf(" %d", n -> key);
  preorder(n -> left);
  preorder(n -> right);
}



Measured memory_bytes: 25224
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
const long long LINF = 1e18;
#define dump(x)  cout << 'x' << ' = ' << (x) << ` `;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOREACH(x,a) for(auto& (x) : (a) )
typedef long long ll;
using namespace std;
typedef pair<ll, ll> P;

template<typename T>
void print(const vector<T> &x) {
    int n = x.size();
    rep(i,n) {
        cout << x[i];
        if (i!=n-1) cout<<" ";
        else cout << endl;
    }
}

template<typename T>
void print(const vector<vector<T>> &x) {
    int n = x.size();
    rep(i,n) {
        rep(j,x[i].size()) {
            cout << x[i][j] << " ";
        }
        cout << endl;
    }
}

template<typename T>
void print(const vector<T> &x, int n) {
    rep(i,n) {
        cout << x[i];
        if (i!=n-1) cout<<" ";
        else cout << endl;
    }
}

template<typename T>
void print(const vector<vector<T>> &x, int n, int m) {
    rep(i,n) {
        rep(j,m) {
            cout << x[i][j] << " ";
        }
        cout << endl;
    }
}

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; }

void input_init() {
    cin.tie(0); ios::sync_with_stdio(false);
}

int main(int argc, char const *argv[]) {
    string s; cin>>s;
    if (s=="ABC") cout << "ARC" << '\n';
    else cout << "ABC" << '\n';
    return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
#define rep(i, m, n) for (int i = m; i < n; ++i)
#define rem(i, m, n) for (int i = m; i >= n; --i)
typedef long long ll;
#define mod 1000000007
template<class T>bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }

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


Measured memory_bytes: 256
n = int(input())
ans = 0

def dfs(x:int): #準753数をDFSで列挙
    global ans
    if x > n:
        return
    if judge(x):
        ans += 1
    for i in "357":
        dfs(int(str(x) + i))

def judge(x): #753数かを判定する
    if set(str(x)) == {"3", "5", "7"}:
        return True
    else:
        return False

dfs(0)
print(ans)

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

#define ll long long 
#define pi  pair<int,int>
#define ti  tuple<int,int,int>
#define mt  make_tuple
#define mk  make_pair
#define vi  vector<int>
#define vll vector<ll>
#define fastInOut ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pr(a) for(auto x:a) cout<<x<<" ";
#define prmap(m) for(auto x:m) cout<<x.first<<" "<<x.second<<"\n";
int n,k,m;
int main() {
    fastInOut
    cin>>n>>m;
    string s;
    ll r=0;
    ll a=0;
    int A[n+1]={0};
    int B[n+1]={0};
    for(int i=0;i<m;i++){
         cin>>k>>s;
         if(A[k]!=1){
           if(s=="AC"){
              A[k]=1;
              a++;
              r+=B[k];
           }
           else {
              B[k]++;
           }
        }
    }
    cout<<a<<" " <<r;
  return 0;
}

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

using namespace std;

#define INF 1000007
#define MOD 1000000007
#define int long long int
#define maxn 100
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define rep(i, n) FOR(i, 0, n)

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

int lcm(int a, int b) { return a / gcd(a, b) * b; }

int mpow(int N, int P, int M)  //繰り返し自乗法
{
    if (P == 0)
        return 1;
    if (P % 2 == 0) {
        int t = mpow(N, P / 2, M);
        return t * t % M;
    }
    return N * mpow(N, P - 1, M) % M;
}

int counter(int x) {           //bit計算
    if (x == 0) return 0;
    return counter(x >> 1) + (x & 1);
}

vector<bool> prime(maxn + 1, true); //素数テーブル
void prime_table(void) {
    prime[0] = false;
    prime[1] = false;
    for (int i = 2; i * i <= maxn; i++) {
        if (!prime[i]) {
            continue;
        }
        for (int j = i + i; j <= maxn; j += j + i) {
            prime[j] = false;
        }
    }
}

bool IsPrime(int num) {   //素数判定
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false;

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2) {
        if (num % i == 0) {
            return false;
        }
    }

    return true;
}

signed main() {
    int N, M, V, P;
    vector<int> A;
    cin >> N >> M >> V >> P;
    rep(i, N) {
        int a;
        cin >> a;
        A.push_back(a);
    }
    sort(A.begin(), A.end(), greater<int>());
    int l = P, r = N;
    while (l < r) {
        int mid = (l + r) / 2;
        int all = P * M + (N - mid - 1) * M;
        bool check = true;
        for (int i = P - 1; i < mid; i++) {
            if (A[mid] + M - A[i] < 0) {
                check = false;
            }
            all += max(A[mid] + M - A[i], 0LL);
        }
        if (all >= M * V && check) {
            l = mid + 1;
        } else {
            r = mid;
        }
    }
    cout << l << endl;
}


Measured memory_bytes: 1400
#include"bits/stdc++.h"
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
const long long mod =998244353;
const long long inf = 1ll << 61;
typedef pair<char, int> P;
struct edge { int to; int to2; int cost; };
int a[100006];
int imos[200006];
signed main() {
	int n, m; cin >> n >> m;
	rep(i, n)cin >> a[i];
	rep(i, n - 1) {
		if (a[i] > a[i + 1]) {
			a[i + 1] += m;
		}
			imos[a[i] + 1]--;
			imos[a[i + 1]] += a[i + 1] - a[i];
			imos[a[i + 1] + 1] -= a[i + 1] - a[i] - 1;
			if (a[i + 1] > m)a[i + 1] -= m;
	}
	rep(i, 2*m)imos[i + 1] += imos[i];
	rep(i, 2*m)imos[i + 1] += imos[i];
	rep(i, m)imos[i] += imos[m + i];
	int sum = 0;
	rep(i, n - 1) {
		sum += (a[i + 1] - a[i] + m) % m;
	}
	rep(i, m)imos[i] += sum;
	int mn = inf;
	rep(i, m) {
		if (mn > imos[i]) {
			mn = imos[i];
		}
	}
	cout << mn << endl;
}


Measured memory_bytes: 2560
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
#include <utility>
#include <climits>
#include <bitset>
#include <math.h>

using namespace std;
#define li long long int
#define FOR(i, a, b) for (int i = a ; i < b ; ++i)
#define REP(i, n) for (int i = 0 ; i < n ; ++i)

li gcd(li a,li b) {
    return a % b == 0 ? b : gcd(b, a % b);
}

int main(void) {
    li N, K;
    cin >> N >> K;

    li h[N];
    FOR(i, 0, N) {
        cin >> h[i];
    }

    sort(h, h + N);

    li min = 1 << 30;
    FOR(i, 0, N - K + 1) {
        li diff = h[K + i - 1] - h[i];
        if (diff < min) {
            min = diff;
        }
    }
    cout << min;
    return 0;
}

Measured memory_bytes: 1024
#include<stdio.h>
int main(){
  int N;
  scanf("%d",&N);
    int a=N%10;
    if((a==2)||(a==4)||(a==5)||(a==7)||(a==9))
    {
      printf("hon");
    }
    else if((a==0)||(a==1)||(a==6)||(a==8))
    {
      printf("pon");
    }
  	else
  	{
    	printf("bon");
  	}
}

  

Measured memory_bytes: 1732
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <cstdio>
#include <string.h>
#define rep(i,n) for (int i = 0; i < (int)n; i++)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<pi, pi> pp;
typedef pair<ll, ll> pl;
double PI = 3.1415926535897932;
const double EPS = 1e-9;
const ll MOD = 1000000007;
const int inf = 1 << 30;
const ll linf = 1LL << 60;

int n;
int b[100];
int dp[2][100];

int main() {
    cin >> n;
    rep(i,n-1) cin >> b[i];
    int ans = b[0] + b[n-2];
    for (int i = 0; i < n-2; i++) {
        ans += min(b[i], b[i+1]);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#ABC087 B
A=int(input())
B=int(input())
C=int(input())
X=int(input())

#初期値
able_number=0

for a in range(A+1):
  for b in range(B+1):
    for c in range(C+1):
      if X==500*a+100*b+50*c:
        able_number+=1
print(able_number)        

Measured memory_bytes: 3064
"use strict";
    
const main = arg => {
    arg = arg.trim().split("\n");
    const A = parseInt(arg[0].split(" ")[0]);
    const B = parseInt(arg[0].split(" ")[1]);
    
    console.log(A - (B * 2) < 0 ? 0 : A - (B * 2) );
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 21064
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N,L;
  cin>>N>>L;
  vector<string>data(110);
  for(int i=0;i<N;i++){
  cin>>data.at(i);
  }
  sort(data.begin(),data.end());
  for(int i=0;i<data.size();i++){
  cout<<data.at(i);
  }
} //CE原因最後の｝忘れ　

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

typedef vector<int> veci;
typedef pair<int,int> pii;
typedef vector<pii> vecii;
typedef long long ll;
typedef pair<ll,ll> pll;
typedef vector<ll> vecl;
typedef vector<pll> vecll;
#define EPS (1e-9)
#define MOD (1e9+7)
#define fi first
#define se second

int main()
{
    ios::sync_with_stdio(false);
#ifdef LOCAL_TEST    
    int tcs;
    cin >> tcs;
    while (tcs-->0)
#endif        
{
    ll k;
    cin >> k;

    ll div = k / 50;
    ll rem = k % 50;

    vecl num(50,div+49);
    for (int i=0; i<rem; ++i) {
        num[i] += 51;
        for (int j=0; j<50; ++j)
            num[j]--;
    }

    cout << 50 << endl;
    for (auto e:num)
        cout << e << " ";
    cout << endl;
}}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<cmath>
#include<algorithm>
#include <numeric>
#include<map>
#include<unordered_map>
#include <queue>
 
using namespace std;
using ll=long long;
#define rep(i,n)  for(ll i=0;i<n;++i)
#define all_map(itr,mp) for(auto itr=mp.begin();itr!=mp.end();itr++)
#define ALL(a) (a).begin(),(a).end()
 
int main(){
    ll  n, x;
    cin >> n >> x;
    vector<ll> a(n);
    rep(i, n)cin >> a[i];
    sort(ALL(a));
    ll ans = 0;
    rep(i, n){
        if(x<a[i])break;
        ans++;
        x -= a[i];
    }
    if(x > 0 && ans == n)ans--;
    cout << ans << endl;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**6)

def main():
	n,x=map(int,input().split())
	ans = 0
	for i in range(n, -1, -1):
		if x == 0:
			break
		m = 4*(2**i)-3
		if x == m:
			ans += 2**(i+1) - 1
			break
		if x >= (m+1)/2:
			ans += 2**(i)
			x -= int((m+1)/2)
		else:
			x -= 1
	print(ans)
	return
main()

Measured memory_bytes: 3060