akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

int main() {
    int A, B, C, X; cin >> A >> B >> C >> X;
    int cnt = 0;
    for (int i = 0; i <= A; i++)
    {
        for (int j = 0; j <= B; j++)
        {
            for (int k = 0; k <= C; k++)
            {
                if(500*i+100*j+50*k==X) cnt++;
            }
        }
    }
    cout << cnt << endl;
}

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

char n[10][12]={
	"* = ****","* =* ***","* =** **","* =*** *","* =**** ",
	" *= ****"," *=* ***"," *=** **"," *=*** *"," *=**** "
};

int main(void){
	int i,j,set,x;
	char s[8];

	for(set=0;cin>>x;set++){
		if(set) cout<<endl;
		sprintf(s,"%05d",x);

		for(i=0;i<8;i++){
			for(j=0;j<5;j++){
				cout<<n[s[j]-'0'][i];
			}
			cout<<endl;
		}
	}

	return 0;
}

Measured memory_bytes: 0
s = input()

total = 0
tmp_current = 0
tmp_high = float('inf')
count_from_high = 1
flag_current = False # '<':True, '>':False
for c in s:
    if c == '<':
        if not flag_current:
            count_from_high = 0
        total += tmp_current+1
        tmp_current += 1
        flag_current = True
    else:
        if flag_current:
            tmp_high = tmp_current
            flag_current = False
        else:
            if tmp_high > count_from_high:
                total += count_from_high
            else:
                total += count_from_high + 1
        tmp_current = 0
        count_from_high += 1
print(total)

Measured memory_bytes: 4108
// Date: 2020-02-29

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

typedef long long LL;
typedef long double LD;
typedef vector<int> VI;
typedef pair<LL, LL> pll;
typedef pair<int, int> pii;
#define FIO ios::sync_with_stdio(false);cin.tie(0)
#define rep(i, a, b) for(int i = int(a); i <= int(b); ++i)
#define per(i, b, a) for(int i = int(b); i >= int(a); --i)
#define mem(x, y) memset(x, y, sizeof(x))
#define all(x) (x).begin(),(x).end()
#define mk make_pair
#define pb push_back
#define fi first
#define se second
const LL INF = 1e18;
const LL mod = 1e9 + 7;
const int inf = 0x3f3f3f3f;
const int N = 1e5 + 10;
template <typename T> void chkmax(T &x, T y) { x = max(x, y); }
template <typename T> void chkmin(T &x, T y) { x = min(x, y); }
LL qpow(LL x, LL y, LL MOD) {LL a=1; while(y){ if(y&1) a=a*x%MOD; x=x*x%MOD; y>>=1; } return a;}

int n, k, d[10], vis[10];

bool chk(int x) {
    if(x == 0) return vis[x];
    while(x) {
        if(vis[x % 10]) return true;
        x /= 10;
    }
    return false;
}

int main() {
    scanf("%d%d", &n, &k);
    rep(i, 1, k) scanf("%d", &d[i]), vis[d[i]] = 1;
    while(chk(n)) ++n;
    printf("%d\n", n);

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

#define MAX 100000
#define SENTINEL 2000000000

typedef struct {
  char suit;
  int value;
} Card;

void merge(Card *, int, int, int, int);
void mergesort(Card *, int, int, int);
int partition(Card *, int, int, int);
void quicksort(Card *, int, int, int);

Card Left[MAX/2+2];
Card Right[MAX/2+2];

int main()
{
  int n, i, v;
  Card a[MAX], b[MAX];
  char s[10];
  int stable = 1;

  scanf("%d", &n);
  for(i=0; i<n; i++) {
    scanf("%s %d", s, &v);
    a[i].suit = s[0];
    b[i].suit = s[0];
    a[i].value = v;
    b[i].value = v;
  }

  mergesort(a, n, 0, n);
  quicksort(b, n, 0, n-1);

  for(i=0; i<n; i++) {
    if(a[i].suit != b[i].suit)
      stable = 0;
  }
  if(stable == 1)
    printf("Stable\n");
  else
    printf("Not stable\n");
  for(i=0; i<n; i++) {
    printf("%c %d\n", b[i].suit, b[i].value);
  }

  return 0;
}

void merge(Card *A, int n, int left, int mid, int right)
{
  int i, j, k;
  int n1 = mid - left;
  int n2 = right - mid;

  for(i=0; i<n1; i++) {
    Left[i] = A[left+i];
  }
  for(i=0; i<n2; i++) {
    Right[i] = A[mid+i];
  }
  Left[n1].value = SENTINEL;
  Right[n2].value = SENTINEL;
  i = 0;
  j = 0;
  for(k=left; k<right; k++) {
    if(Left[i].value <= Right[j].value)
      A[k] = Left[i++];
    else
      A[k] = Right[j++];
  }
}

void mergesort(Card *a, int n, int left, int right)
{
  int mid;
  if(left+1 < right) {
    mid = (left+right)/2;
    mergesort(a, n, left, mid);
    mergesort(a, n, mid, right);
    merge(a, n, left, mid, right);
  }
}

int partition(Card *a, int n, int p, int r)
{
  int i, j;
  Card tmp, x;
  x = a[r];
  i = p-1;
  for(j=p; j<r; j++) {
    if(a[j].value <= x.value) {
      i++;
      tmp = a[i];
      a[i] = a[j];
      a[j] = tmp;
    }
  }
  tmp = a[i+1];
  a[i+1] = a[r];
  a[r] = tmp;
  return i+1;
}

void quicksort(Card *a, int n, int p, int r)
{
  int q;
  if(p <r) {
    q = partition(a, n, p, r);
    quicksort(a, n, p, q-1);
    quicksort(a, n, q+1, r);
  }
}

Measured memory_bytes: 2952
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(x) (x).begin(), (x).end()
using ll = long long;
using namespace std;
template <typename T>
using vec = std::vector<T>;

int main() {
    string S;
    cin >> S;
    if(S == "ABC"){
        cout << "ARC" << endl;
    } else{
        cout << "ABC" << endl;
    } 
    
}


Measured memory_bytes: 3628
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); ++i)
#define outl(x) cout<< (x) << '\n'
#define fi first
#define se second
using pii = pair<int,int>;
using ll = long long;

struct UnionFind
{
    int uni[100010];
    UnionFind() { memset(uni, -1, sizeof(uni)); }
    int root(int x) { return uni[x] < 0 ? x : uni[x] = root(uni[x]); }
    bool same(int x, int y) { return (root(x) == root(y)); }
    bool unite(int x, int y) {
        if ((x=root(x)) == (y=root(y)))
            return true;
        if (uni[y] < uni[x])
            swap(x, y);

        uni[x] += uni[y];
        uni[y] = x;
        return (false);
    }
};

UnionFind uf;

int main()
{
   cin.tie(0), ios::sync_with_stdio(false);
   int N, Q, m;

   cin >> N >> m;

   while (m--) {
       int x, y;
       cin >> x >> y;
       uf.unite(x, y);
   }

   cin >> Q;
   while (Q--) {
       int x, y;
       cin >> x >> y;
       outl(uf.same(x,y) ? "yes" : "no");
   }

}




Measured memory_bytes: 3588
#include <iostream>
#include <math.h>
#include <vector>
#include <stack>
#include <cstdio>
#include <string>
#include <bitset>
#include <list>
#include <set>
#include <algorithm>
#include <numeric>
#include <unordered_map>
#include <functional>
#include <queue>
#include <regex>
// #include "bits/stdc++.h"

using namespace std;
//debug

#define rep(i, N) for (ll i = 0; i < N; i++)
#define rep2(i, N, M) for (ll i = N; i < M; i++)
#define pb push_back



typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<string> vs;
typedef priority_queue<pll, vector<pll>, greater<pll>> greater_pq;


#define all(a)  (a).begin(),(a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define vec(a) vector<a>

#define MAX_NUM 2<<20



int main() {
	int N;
	cin >> N ;
	auto flg = false;
	rep(i, 100) {
		rep(j, 100) {
			flg = flg || (N == i * 4 + j * 7);
		}
	}

	cout << (flg ? "Yes" : "No");
	return 0;
}



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

#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)

constexpr int Nmax = 102;
int N;
int va[Nmax], vi[Nmax], ti[Nmax];

inline int dist(int &va, int &vi, int &vb, int &t) // 本来の4倍を出力
{
    int vmax_2 = va + vb + t; // 本来の2倍
    if (vmax_2 > vi * 2) return vi * t * 4 - 2 * (vi - va) * (vi - va) - 2 * (vi - vb) * (vi - vb); // 本来の4倍
    int t__2 = vmax_2 - va * 2; // 本来の2倍
    return ((va * 2 + vmax_2) * t__2 + (vb * 2 + vmax_2) * (t * 2 - t__2)) / 2; // 本来の4倍
}

int main()
{
    scanf("%d", &N);
    va[0] = va[N + 1] = vi[0] = vi[N + 1] = ti[0] = ti[N + 1] = 0;
    REP(i, N) scanf("%d", &ti[i + 1]);
    REP(i, N) scanf("%d", &vi[i + 1]);

    FOR(i, 1, N + 1) va[i] = min(min(vi[i], vi[i - 1]), va[i - 1] + ti[i - 1]);
    IFOR(i, 1, N + 1) va[i] = min(va[i], va[i + 1] + ti[i]);
    int ans = 0;
    FOR(i, 1, N + 1) ans += dist(va[i], vi[i], va[i + 1], ti[i]);
    printf("%.02lf\n", ans / 4.0);
}


Measured memory_bytes: 256
using System;
 
public class Program
{ 
	public static void Main()
	{
		int N, i;
		N = int.Parse(Console.ReadLine());
		string[] strA = Console.ReadLine().Split(' ');
		int[] intA = new int[N];
		for( i = 0; i < N; i++) {
			intA[i] = int.Parse(strA[i]);
		}

		trace(intA, N);
		insertionzSort(intA, N);
	}

	public static void trace(int[] A, int N)
	{
		int i;
		for(i = 0; i < N; i++) {
			if(i > 0) Console.Write(" ");
			Console.Write("{0}", A[i]);
		}
		Console.Write("\n");
	}

	public static void insertionzSort(int[] A, int N)
	{
		int j, i, v;
		for ( i = 1; i < N; i++) {
			v = A[i];
			j = i - 1;
			while ( j >= 0 && A[j] > v) {
				A[j + 1] = A[j];
				j--;
			}
			A[j + 1] = v;
			trace(A, N);
		}
	}
}

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

using ll = long long;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define ddrep(i, n) for (int i = n; i > 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)
#define ssrep(i, s, t) for (int i = s; i <= t; ++i)

#define rng(a) a.begin(), a.end()
#define rrng(a) a.rbegin(), a.rend()
#define pb push_back
#define eb emplace_back
#define fi first
#define se second

#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))

using pi = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using ld = long double;

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
    os << "(" << p.first << "," << p.second << ")";
    return os;
}

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
    os << "{";
    rep(i, (int)v.size()) {
        if (i)
            os << ",";
        os << v[i];
    }
    os << "}";
    return os;
}

template <typename T, size_t S> void printArray(const T (&array)[S]) {
    for (auto val : array)
        std::cout << val << ", ";
    std::cout << "\n";
}

const int mod = 1e9 + 7;
const int inf = 1e9 + 5;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << std::setprecision(10);

    int a, b, c; std::cin >> a >> b >> c;
    std::cout << a * b / 2 << "\n";
}


Measured memory_bytes: 256
# pragma GCC optimize("O3")
# include <bits/stdc++.h>
std::pair<int,int> DR[] = {{-1,0},{0,1},{1,0},{0,-1},{-1,1},{-1,-1},{1,1},{1,-1}};
# define maxn 100005
# define ll long long
# define clock (clock() * 1000.0 / CLOCKS_PER_SEC)
# define rc(s) return cout << s,0
# define _ ios_base::sync_with_stdio(false);cin.tie(0);cerr.tie(0);cout.tie(0);
# define db(x) cerr << #x << " = " << x << '\n'
# define pb push_back
# define mp make_pair
# define sz(x) (int)((x).size())
//# define int ll
using namespace std;

int n,M,a[1 << 17],sum[1 << 17];
map<int,int>m[1 << 17];
int ans;

int32_t main(){_
    //freopen("input","r",stdin);
	cin >> n >> M;
	for(int i = 1;i <= n;i++)
	{
		cin >> a[i];
		m[a[i] % M][a[i]]++;
		sum[a[i] % M]++;
	}	
	for(int i = 0;i <= M / 2;i++)
	{
		if((i == 0) || ((M % 2 == 0) && (i == M / 2))) ans += sum[i] / 2;
		else
		{
			int j = i;
			if(sum[i] < sum[M - i]) j = M - i;
			ans += sum[M - j];
			for(auto it : m[j])
			{
				if((it.second & 1) && sum[M - j])
					sum[M - j]--;
				ans += it.second / 2;
			}
			ans -= ((sum[M - j] + 1) / 2);
		}
	}
	rc(ans);
}


Measured memory_bytes: 11904
#include<stdio.h>
int main(void){
  int i;
  int left,light,mid;
  int c=0;
  int N1,N2;
  int A[100000];
  int B[50000];

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

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

  for(i=0;i<N2;i++){
    left=0;
    light=N1;
    while(left<light){
      mid=(left+light)/2;
      if(A[mid]<B[i])left=mid+1;
      else if(A[mid]>B[i])light=mid;
      else {
	c++;
	break;
      }
    }
  }
  printf("%d\n",c);
  return 0;
}

Measured memory_bytes: 912
#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <vector>
#include <climits>
#include <cstring>
#include <cmath>
#include <cassert>

#include <queue>
#include <map>
#include <set>

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int MN = 1e5 + 5, MOD = 1e9 + 7;

int N, dp[MN][3];

int main() {
    ios_base::sync_with_stdio(0), cin.tie(0);
    cin >> N >> dp[1][0] >> dp[1][1] >> dp[1][2];
    for (int i = 2, a, b, c; i <= N; i++) {
        cin >> a >> b >> c;
        dp[i][0] = a + max(dp[i - 1][1], dp[i - 1][2]);
        dp[i][1] = b + max(dp[i - 1][0], dp[i - 1][2]);
        dp[i][2] = c + max(dp[i - 1][0], dp[i - 1][1]);
    }
    cout << max(dp[N][0], max(dp[N][1], dp[N][2])) << '\n';
    return 0;
}


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

string s;
int sum = 0, n, point = 0;
int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    cin >> s; n = s.length();
    for(int i = 0; i < n; i++) {
        if(s[i] == 'g') {
            if(sum > 0) point++, sum--;
            else sum++;
        }
        else {
            if(sum > 0) sum--;
            else point--, sum++;
        }
    }
    cout << point;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a) for(int i = 0; i < (a); i++)
#define ALL(a) (a).begin(),(a).end()
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const long long LINF = 1e18;
const long long MOD = 1e9 + 7;

signed main(){
    int n;
    cin >> n;
    ll ans = 0;
    int v;
    REP(i,n){
        cin >> v;
        ans += v;
        ans -= i + 1;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3100
#include <cstdio>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <iterator>
#define loop(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define debug(x)  cout << #x << " = " << (x) << endl;

using namespace std;
using LL = long long;
using ULL = unsigned long long;

int main() {
    int n; cin >> n;
    if (n / 100 == n % 10) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}


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

using namespace std;

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

const int N = 2e5 + 5;
int n, k;
int a[N];

int main() {
	scanf("%d %d", &n, &k);
	for (int i = 1; i <= n; i++) scanf("%d", a + i);
	int s = 1, e = 1e9, ans;
	while (s <= e) {
		int mid = s + e >> 1;
		auto check = [&](int minlen) {
			int cut = 0;
			for (int i = 1; i <= n; i++) {
				if (a[i] <= minlen) continue;
				cut += a[i] / minlen;
			}
			return cut <= k;
		};
		if (check(mid)) {
			ans = mid;
			e = mid - 1;
		}
		else {
			s = mid + 1;
		}
	}

	return !printf("%d\n", ans);
}

Measured memory_bytes: 4496
#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 ll long long int
#define ld long double
#define ordered_set tree < ll ,  null_type ,  less<ll> ,  rb_tree_tag ,  tree_order_statistics_node_update >
//added two more functions to set
//(1)*(set.find_by_order(k))[kth element in the sorted set] 
//(2)set.order_of_key(k)[count of elements strictly less than k]

typedef vector< int > vi;
typedef vector<long long> lvi;
typedef vector< vector<int> > vvi;
typedef vector< vector<long long> > lvvi;
typedef pair< int,int > ii;
typedef pair< long long,long long > lii;
typedef vector<pair<int,int>> vii;
typedef vector<pair<long long,long long>> lvii;
typedef vector<vector<pair<int,int>>> vvii;
typedef vector<vector<pair<long long,long long>>> lvvii;
typedef vector<bool> vb;

// #ifdef ONLINE_JUDGE 
// #define endl '\n'
// #endif
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define tr(c,i) for(auto i = (c).begin(); i != (c).end(); i++)//remember i is an iterator
#define tc(t) int (t); cin>>(t);while((t)--)
#define ff first
#define ss second
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " is " << a << endl;
	err(++it, args...);
}

//-----------------------------------------------------------------------------------------------------------------------------------------------------------------
const long long mod = 1e9 + 7;
//-----------------------------------------------------------------------------------------------------------------------------------------------------------------

long long mos() { return 0LL; }
template<typename T, typename... Args>
T mos(T a, Args... args) { return ((a + mos(args...))%mod + mod)%mod; }

long long mop() { return 1LL; }
template<typename T, typename... Args>
T mop(T a, Args... args) { return (a*mop(args...))%mod; }
//-----------------------------------------------------------------------------------------------------------------------------------------------------------------



signed main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);	
	string s;
	cin>>s;
	ll k=0;
	ll n=s.length();
	for (int i = 0; i < n; ++i)
	{
		k+=(s[i]-'0');
	}
	if(k%9==0) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return 0;
}	


// WA
// 1. overflow
// 2. re-initialize global variables for every test case.
// 3. edge cases like n=1

// Run time error
// 1. division by zero.
// 2. array bounds.

// TLE
// 1. uncomment that #define endl '\n' lines

Measured memory_bytes: 3732
// C - Go Home
// https://atcoder.jp/contests/abc056/tasks/arc070_a
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define uli unsigned long long int
#define rep(i, m, n) for (lli i = m; i < (n); i++)
#define repe(i, m, n) for (lli i = m; i <= (n); i++)
#define ALL(x) (x).begin(), (x).end()
#define SIZE(x) ((lli)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define _GLIBCXX_DEBUG
const lli INF = 2147483647;
const lli MINF = -2147483648;
const lli LINF = 9223372036854775807;
const lli MOD = 1000000007; //10^9+7
const double PI = acos(-1);
#define SORT(n) sort(n.begin(), n.end())
#define SORTR(n) sort(n.begin(), n.end(), greater<int>())
#define REV(n) reverse(n.begin(), n.end())
#define pb push_back
#define eb emplace_back
#define mp make_pair
#pragma GCC optimize("Ofast")
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vlli = vector<lli>;
using vvli = vector<vlli>;
using vs = vector<string>;
using vvs = vector<vs>;
using vb = vector<bool>;
using vvb = vector<vb>;
using ll = long long;
// vector入力
template <typename T>
istream &operator>>(istream &is, vector<T> &vec)
{
  for (T &x : vec)
    is >> x;
  return is;
}
// vector出力
template <typename T>
ostream &operator<<(ostream &os, vector<T> &vec)
{
  // os << '{';
  for (int i = 0; i < vec.size(); i++)
  {
    os << vec[i] << (i + 1 == vec.size() ? "" : "");
  }
  // os << '}';
  return os;
}
// aよりもbが大きいならばaをbで更新する(更新されたならばtrueを返す)
template <typename T>
bool chmax(T &a, const T &b)
{
  if (a < b)
  {
    a = b; // aをbで更新
    return true;
  }
  return false;
}
// aよりもbが小さいならばaをbで更新する(更新されたならばtrueを返す)
template <typename T>
bool chmin(T &a, const T &b)
{
  if (a > b)
  {
    a = b; // aをbで更新
    return true;
  }
  return false;
}

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  lli a = 0, b, c, h, n, w, ans = 0, count = 1;
  string s, t;
  vector<pair<string, pair<lli, lli>>> pr;
  cin >> n;
  vlli d;
  while (ans < MOD)
  {
    ans += count;
    d.pb(ans);
    count++;
  }
  rep(i, 0, d.size())
  {
    if (n <= d[i])
    {
      a = i + 1;
      break;
    }
  }
  cout << a << endl;
}

Measured memory_bytes: 3884
#include <bits/stdc++.h>
using namespace std;
int main()
{
    string s, p;
    cin >> s >> p;
    bool ok = false;
    s += s;
    // cout << s << " " << p << '\n';
    for (int i = 0; i < s.size(); i++)
    {
        int j = 0;
        while (1)
        {
            // cout << i + j << " " << j << '\n';
            if(s[i + j] != p[j])
                break;
            if(p[j + 1] == '\0') {
                ok = true;
                // cout << (j + 1 == p.size()) << '\n';
                // cout  << "ok" << i << " " << j << '\n';
                break;
            }
            if(p.size() == j - 1)
                break;
            j++;
        }
        
    }
    if(ok)
        cout << "Yes" << '\n';
    else
        cout << "No" << '\n';
  
    return 0;
}


Measured memory_bytes: 3216
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

struct robodata {
	int x;
	int d;
	long long tori;
	int parent;
	vector<int> children;
};


const long long C = 998244353;


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

	vector<robodata> data(n);
	int* index_top = new int[n];
	int index_max = -1;

	for (int i = 0; i < n; ++i) {
		int x;
		int d;
		cin >> x >> d;
		data[i] = robodata{ x, d, -1, -1 };
		index_top[i] = -1;
	}

	std::sort(data.begin(), data.end(), [&](const robodata& a, const robodata& b) { return a.x < b.x; });


	for (int i = 0; i < n; ++i) {
		if (data[i].parent == -1) {
			
			index_max++;
			index_top[index_max] = i;
			
			vector<int> node_stack;
			int max_index = i + 1;

			node_stack.push_back(i);

			while (!node_stack.empty()) {
				int k = node_stack.back();

				int max_range = data[k].x + data[k].d;
				bool none_child = true;

				for (int j = max_index; j < n && data[j].x < max_range; ++j) {
					if (data[j].parent == -1) {

						data[k].children.push_back(j);
						data[j].parent = k;
						node_stack.push_back(j);
						none_child = false;
						max_index = j;
						break;
					}
				}

				if (none_child) {
					node_stack.pop_back();
				}
			}
		}
	}

	unsigned long long ret = 1;

	for (int i = data.size() - 1; i >= 0; --i) {
		if (data[i].children.empty()) {
			data[i].tori = 2;
		}
		else {
			long long x = 1;
			for (int j : data[i].children) {
				x *= data[j].tori;
				x %= C;
			}
			data[i].tori = x + 1;
		}
	}

	for (int i = 0; i <= index_max; ++i) {
		ret *= data[index_top[i]].tori;
		ret %= C;
	}


	cout << ret << endl;

	delete[] index_top;

	return 0;
}


Measured memory_bytes: 17396
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <climits>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++ )
#define repf(i,m,n) for(int (i)=m;(i)<n;(i)++)
#define all(v) (v).begin(), (v).end()
#define ll long long


int main(){
    int n,k;
    int ans=0;
    cin>>n>>k;
    vector <ll>v(300000);

    repf(i,1,n+1){
        v[i%k]++;
    }
    if(k%2==0){
        cout<<v[0]*v[0]*v[0]+v[k/2]*v[k/2]*v[k/2]<<endl;
    }else cout<<v[0]*v[0]*v[0]<<endl;
    return 0;

}


Measured memory_bytes: 2560
import numpy as np

H, W = map(int,input().split())
S = [list(str(input())) for _ in range(H)]
S = np.array(S)
S = (S == '.') * 1

R = np.zeros((H, W), dtype=int)
L = np.zeros((H, W), dtype=int)
U = np.zeros((H, W), dtype=int)
D = np.zeros((H, W), dtype=int)

for i in range(W):
    if i == 0:
        L[:, 0] = S[:, 0]
        R[:, W - 1] = S[:, W - 1]
    else:
        L[:, i] = L[:, i - 1] * S[:, i] + S[:, i]
        R[:, W - i - 1] = R[:, W - i] * S[:, W - i - 1] + S[:, W - i - 1]
for i in range(H):
    if i == 0:
        U[i] = S[i]
        D[H - 1] = S[H - 1]
    else:
        U[i] = U[i - 1] * S[i] + S[i]
        D[H - i - 1] = D[H - i] * S[H - i - 1] + S[H - i - 1]

print(np.max(R + L + U + D) - 3)

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

public class Main {
	public static void main(String[] args) throws IOException {
		Scanner sc = new Scanner(System.in);
		String s = sc.nextLine();
		int ans = 0;
		for(int i = 0; i<s.length(); i++) {
			if(s.charAt(i) == '-') ans--;
			else 
				ans++; 
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 21844
/* include c++ libraries */
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <unordered_map>
#include <map>
#include <queue>
#include <set>

/* include c-lang libraries */
#include <climits>
#include <cmath>

/* include my libraries */
//#include <show_vec.hh>

using namespace std;

#define DEBUG if(false)

using ll = long long;
#define LINE printf("LINE : %d\n", __LINE__);
#define loop(i, n) for(i = 0; i < n; i++)
template<class T> using vec = vector<T>;

const int MOD = 1000000007;

int main(){
  int X, N;
  cin >> X >> N;
  if(N == 0){
    cout << X << endl;
    return 0;
  }
  vec<int> p(N);;
  for(int i = 0; i < N; i++){
    cin >> p[i];
  }
  sort(p.begin(), p.end());

  int distance = 0;
  auto itr = find(p.begin(), p.end(), X + distance);

  while(true){
    int s = X - distance;
    itr = find(p.begin(), p.end(), s);
    if(itr == p.end()){
      cout << s << endl;
      break;
    }

    s = X + distance;
    itr = find(p.begin(), p.end(), s);
    if(itr == p.end()){
      cout << s << endl;
      break;
    }
    distance++;
  }
  return 0;
}


Measured memory_bytes: 3632
h={};("0%b"%gets[/\d+$/]).scan(/./){h[eval"0b#$`0#{$&<?1?$':?1*$'.size}"]=0};$<.map{|s|a,b=s.split.map &:to_i;h.map{|k,_|a|k>k||h[k]+=b}};p h.values.max

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

char s[100001];
int N;
const long long mod = 1000000000 + 7;
int count[128];

int main() {
    std::cin >> N >> s;
    for (int i = 0; i < N; i++)
        count[s[i]]++;
    long long tmp = 1;
    for (int c = 'a'; c <= 'z'; c++)
        tmp = tmp * (count[c]+1) % mod;
    std::cout << tmp-1 << std::endl;
    return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
#include <climits>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
using namespace std;

int main() {
    long long x, y;
    cin >> x >> y;
    if(x == 1 && y == 1) {
        cout << 1;
    } else if (x == 1 || y == 1) cout << max(x,y) - 2;
    else {
        cout << (x-2) * (y-2) ;
    }
    cout << endl;


    return 0;
}



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

// boost
#include <boost/multiprecision/cpp_int.hpp>
using boost::multiprecision::cpp_int;

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

using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vs = vector<string>;
using vld = vector<ld>;
using vvld = vector<vld>;

typedef pair<ll, ll> P;

#define bit(n) (1LL << (n))

//#define int long long

#define all(v) v.begin(), v.end()

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

#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define FORm(i, m) for (auto i = m.begin(); i != m.end(); i++)

template <class T>
inline void chmax(T& a, T b) {
  a = std::max(a, b);
}
template <class T>
inline void chmin(T& a, T b) {
  a = std::min(a, b);
}

#define mod (ll)(1e9 + 7)
// #define mod (998244353ll)

const long long INF = 1LL << 60;

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(20);

  ll x;
  cin >> x;
  cout << 1 - x << endl;

  return 0;
}


Measured memory_bytes: 3652
n,m=map(int,input().split())
x=[2,5,5,4,5,6,3,7,6]#各数に使うマッチ棒の本数
a=[]#使う数字でけ格納するリスト
for i in map(int,input().split()):
    a.append([i,x[i-1]])#以上、入力
a.sort(reverse=True)
#ソート：なるべく大きい数字を先に使う：更新減る
#(OK)print(a)使える数字だけ
dp=[0]*(n+1)
#dp[i]：ちょうどi本使った時に表せる最大の数
#ループの順番が、いまひとつ、腑に落ちない
for i in range(m):#外側ループが使用できる数
    for j in range(n+1):#マッチ棒は0からnまで使える
        if j==0 or dp[j]!=0:
        #(NG)if dp[j]!=0: 「jの範囲を1始め」でもNG
            if j+a[i][1]<=n:#マッチ棒が使用範囲内なら
                dp[j+a[i][1]]=max(dp[j+a[i][1]],dp[j]*10+a[i][0])
#この更新はDP典型。右１項が左と同じ。右は両項とも、前から使っているj本に
#新しく使うi番目を使った　本数での数を表している。
print(dp[n])

Measured memory_bytes: 16492
#include <iostream>
using namespace std;
int main(){
  int r,c;
  int a[1000][1000]={0};
  cin >> r >> c;

  for(int i = 0;i < r;i++){
    for(int j = 0; j < c;j++){
      cin >> a[i][j];
      a[r][j] += a[i][j];
      a[i][c] += a[i][j];
    }   
    a[r][c] += a[i][c];
  }

  for(int i= 0; i <= r;i++){
    for(int j = 0;j <= c;j++){
      cout << a[i][j];
      if(j != c){ 
        cout << " ";
      }   
    }   
    cout << endl;
  }
}

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

using namespace std;

template <typename T> void max_self(T& a, T b) {
    a = max(a, b);
}

bool first_row_or_column(pair<int,int> p) {
    return p.first == 0 || p.second == 0;
}

const int INF = 1e9 + 5;

signed main() {
    string a, b;
    cin >> a >> b;
    vector<vector<pair<int, pair<int, int> > > > dp(a.length() + 1,
        vector<pair<int, pair<int, int> > > (b.length() + 1, {-INF,{0, 0}}));
    dp[0][0] = {0, {0,0}};
    // dp[i][j] - the max total length so far
    for (int i = 0; i < (int) a.length(); i++) {
        for (int j = 0; j < (int) b.length(); j++) {
            if (a[i] == b[j]) {
                max_self(dp[i + 1][j + 1], make_pair(dp[i][j].first + 1, make_pair(i, j)));
            }
            max_self(dp[i + 1][j], make_pair(dp[i][j].first, make_pair(i, j)));
            max_self(dp[i][j + 1], make_pair(dp[i][j].first, make_pair(i, j)));
        }
    }
    pair<int, pair<int, int> > ans = {0, {0, 0}};
    for (int i = 0; i <= (int) a.length(); i++) {
        for (int j = 0; j <= (int) b.length(); j++) {
            max_self(ans, make_pair(dp[i][j].first, make_pair(i, j)));
        }
    }
    string s;
    pair<int, int> cur = ans.second;
    while (!first_row_or_column(cur)) {
        int i = cur.first;
        int j = cur.second;
        pair<int, int> previous = dp[i][j].second; 
        if (previous == make_pair(i - 1, j - 1)) {
            assert(a[i - 1] == b[j - 1]);
            s += a[i - 1];
        }
        cur = previous;
    }
    reverse(s.begin(), s.end());
    cout << s << endl;
    return false;
}

Measured memory_bytes: 105984
# https://qiita.com/_-_-_-_-_/items/34f933adc7be875e61d0
# abcde	s=input()	s='abcde'
# abcde	s=list(input())	s=['a', 'b', 'c', 'd', 'e']
# 5(1つだけ)	a=int(input())	a=5
# 1 2	| x,y = s_inpl()   |	x=1,y=2
# 1 2 3 4 5 ... n 　	li = input().split()	li=['1','2','3',...,'n']
# 1 2 3 4 5 ... n 　	li = inpl()	li=[1,2,3,4,5,...,n]
# FFFTFTTFF 　	li = input().split('T')	li=['FFF', 'F', '', 'FF']

# INPUT
# 3
# hoge
# foo
# bar
# ANSWER
# n=int(input())
# string_list=[input() for i in range(n)]

import math
import copy
from collections import defaultdict
from collections import Counter
from collections import deque
# 直積 A={a, b, c}, B={d, e}:のとき，A×B={(a,d),(a,e),(b,d),(b,e),(c,d),(c,e)}: product(A, B)
from itertools import product
# 階乗 P!: permutations(seq), 順列 {}_len(seq) P_n: permutations(seq, n)
from itertools import permutations
# 組み合わせ {}_len(seq) C_n: combinations(seq, n)
from itertools import combinations
from bisect import bisect_left, bisect_right
# import numpy as np

def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W

# 四方向: 右, 下, 左, 上
dy = [0, -1, 0, 1]
dx = [1, 0, -1, 0]

def i_inpl(): return int(input())
def s_inpl(): return map(int,input().split())
def l_inpl(): return list(map(int, input().split()))
INF = float("inf")

############

N, K = s_inpl()

ans = 0
for i in range(1, N+1):
    r = math.ceil(math.log2(K/i))
    if r<0:
        r = 0
    ans += (1/N) * ((0.5)**r)

print(ans)

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

string a,b;
long int dp[3002][3002];
long int c,d;

long int lcs(long int m,long int n){

	if(m<0 || n<0)	return 0;
	if(dp[m][n] !=-1)	return dp[m][n];
	
	if(a[m]==b[n]){
		return dp[m][n] = 1+ lcs(m-1,n-1);
	}
	else{
		return dp[m][n] = max(lcs(m,n-1),lcs(m-1,n));
	}
	
}

void print(){
	long int i=c-1 ,j=d-1;
	string p = "";
	while(i>0 && j>0){
		if(a[i]==b[j]){
			p = a[i] + p;
			i--;
			j--;
		}
		else if(dp[i-1][j]>dp[i][j-1]){
			i--;
		}
		else{
			j--;
		}
	}
	if(i==0 && j>0){
		for(int k=j;k>=0;k--)
			if(b[k]==a[0]){
				p = b[k]+p;
				break;
			}
	}
	if(j==0 && i>0){
		for(int k=i;k>=0;k--)
			if(a[k]==b[0]){
				p = a[k]+p;
				break;
			}
	}
	if(i==0 && j==0){
		if(a[0]==b[0])
			p = a[0] + p;
	}
	cout<<p<<endl;
}

int main(){

	cin>>a>>b;
	long int m = a.length();
 	c = a.length();
	long int n = b.length();
	d = b.length();
	for(long int i=0;i<3002;i++)
		for(long int j=0;j<3002;j++)
			dp[i][j] = -1;
	long int u = lcs(m-1,n-1);
	print();
	return 0;
}

Measured memory_bytes: 70912
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<math.h>
using namespace std;
int main()
{
    //while(1)
    //{
        int a[5];
        for(int i=0; i<3; i++)
            scanf("%d",&a[i]);
        sort(a,a+3);
        int sum=0;
        sum=a[2]-a[1];
        a[0]+=sum;
        if((a[2]-a[0])%2==0)
        {
            sum+=(a[2]-a[0])/2;
        }
        else
        {
            sum+=(a[2]-a[0])/2+2;
        }
        printf("%d\n",sum);
    //}
    return 0;
}


Measured memory_bytes: 128
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
using Library;
using static Library.Input;

namespace AtCoderTemplate
{
    class ProgramE
    {
        static void Main()
        {
            var line = Line;
            int k = NextInt, n = line.Length;
            var dp = new long[n + 1, k + 2, 2];
            dp[0, 0, 0] = 1;

            for (int i = 0; i < n; i++)
            {
                for (int j = 0; j <= k; j++)
                {
                    if (line[i] == '0')
                    {
                        dp[i + 1, j, 0] += dp[i, j, 0];
                    }
                    else
                    {
                        dp[i + 1, j + 1, 0] += dp[i, j, 0];
                        dp[i + 1, j + 1, 1] += dp[i, j, 0] * (line[i] - '1');
                        dp[i + 1, j, 1] += dp[i, j, 0];
                    }
                    
                    dp[i + 1, j + 1, 1] += dp[i, j, 1] * 9;
                    dp[i + 1, j, 1] += dp[i, j, 1];
                }
            }

            System.Console.WriteLine(dp[n, k, 0] + dp[n, k, 1]);
        }
    }
}

namespace Library
{
    class Input
    {
        static IEnumerator<string> enumerator = new string[] { }.AsEnumerable().GetEnumerator();

        public static string Line => Console.ReadLine();

        public static string[] StrArr => Line.Split(' ');

        public static int NextInt => int.Parse(NextWord());

        public static long NextLong => long.Parse(NextWord());

        public static List<int> IntList => StrArr.Select(int.Parse).ToList();

        public static List<long> LongList => StrArr.Select(long.Parse).ToList();

        public static IEnumerable<long[]> TakeLine(int N)
        {
            return Enumerable.Repeat(0, N).Select(_ => Console.ReadLine().Split(' ').Select(long.Parse).ToArray());
        }

        public static string NextWord()
        {
            while (!enumerator.MoveNext())
            {
                enumerator = StrArr.AsEnumerable().GetEnumerator();
            }
            return enumerator.Current;
        }
    }
}


Measured memory_bytes: 13268
#include<stdio.h>
#include<time.h>
int power(int x,int p){//x^pを返す ただしp=0のとき0を返す
    if(p==0) return 0;
    int i,ans=1;
    for(i=0;i<p;i++){
        ans*=x;
    }
    return ans;
}

int func(int n,int d[]){
    int i,j,k;//for文
    int seq,ans;
    int flag[10000];//0は存在しない、１は存在するを表す
    for(i=0;i<10000;i++) flag[i]=0;
    for(i=0;i<n;i++){//iは桁数−１
        for(j=0;j<n-i;j++){//jはindex
            seq=0;
            for(k=j;k<i+j+1;k++){
                seq=seq*10+d[k];
            }
            flag[seq]=1;
        }
        for(j=power(10,i);j<power(10,i+1);j++){
            if(flag[j]==0) return j;
        }
    }
    return -1;
}

int main(void){
    clock_t c1,c2; c1 = clock();
    int n;//数列の大きさ
    scanf("%d",&n);
    int d[n];//数列
    int i,x;
    for(i=0;i<n;i++){
        scanf("%d",&x);
        d[i]=x;
    }
    printf("%d\n",func(n,d));
    //c2 = clock(); printf("time = %f[s]\n", (double)(c2-c1)/CLOCKS_PER_SEC);
    return 0;
}



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

int main() {
  int n,x,t;
  cin >> n >> x >> t;
  int ans = n/x;
  if(n%x != 0) ans++;
  cout << ans*t << endl;
}

Measured memory_bytes: 3584
'use strict'
const main = (input: string) => {
    const std: string = input.trim();
    const [a, b, c] = std.split(' ').map(Number);
    const r = c - (a - b);
    if (r <= 0) {
        console.log(0);
        return;
    }
    console.log(r);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));  


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

int main(){
        while(true){
                int n,k;
                cin>>n>>k;

                if(n==0 && k==0){
                        break;
                }

                int a[n],sum=0;
                for(int i=0;i<n;i++){
                        cin>>a[i];
                }
                for(int i=0;i<k;i++){
                        sum+=a[i];
                }

                int ans=sum;
                for(int i=0;i<n-k;i++){
                        sum+=a[i+k]-a[i];
                        ans=max(ans,sum);
                }

                cout<<ans<<endl;
        }

        return 0;
}

Measured memory_bytes: 1552
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cctype>
#include <cmath>

using namespace std;

typedef long long    ll;
typedef long double  ld;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pld;

template <typename T> bool chmax(T &a, T& b) {if (a < b) {a = b; return true;} return false;}
template <typename T> bool chmin(T &a, T& b) {if (a > b) {a = b; return true;} return false;}
#define rep(i, n)      for (int i = 0; i < (int)(n); ++i)
#define rep3(i, m, n)  for (int i = (m); i < (int)(n); ++i)
#define rrep(i, n)     for (int i = (int)(n)-1; i >= 0; --i)
#define rrep3(i, m, n) for (int i = (int)(n)-1; i >= (m); --i)
#define all(x) x.begin(), x.end()
#define rall(x) x.end(), x.begin()
#define mset(x, val) memset(x,(val),sizeof(x))
#define cons(a, b) make_pair((a), (b))
#define car first
#define cdr second

#define endl '\n'
#define INF  0x7f7f7f7f7f7f7f7f
#define INFi 0x7f7f7f7f
const string YES = "YES";
const string NO = "NO";

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

bool solve(string r, string g, string b) {
  ll x = stoi(r+g+b);
  return x%4 == 0; 
}

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

  string r, g, b;
  cin >> r >> g >> b;

  auto ans = solve(r, g, b);
  cout << (ans ? YES : NO) << endl;

  return 0;
}


Measured memory_bytes: 3012
#include <cstdlib>
#include <iostream>
#include <queue>

using namespace std;

bool LinearSearch(int tgt,int array[],int length){
    int i = 0;
    array[length] = tgt;
    while(tgt != array[i]){
        i++;
    }

    if(i == length){
        return false;
    }

    return true;
}

int main(){
   int n;
   int s[10000];
   int q;
   int t[500];
   int count = 0;

   cin >> n;

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

   cin >> q;

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

   //探索
   for(int i=0; i<q; i++){
       if(LinearSearch(t[i],s,n)){
           count++;
       }
   }

   cout << count << endl;

    return 0;
}



Measured memory_bytes: 3100
from scipy.sparse.csgraph import shortest_path, floyd_warshall, dijkstra, bellman_ford, johnson, minimum_spanning_tree
from scipy.sparse import csr_matrix, coo_matrix, lil_matrix
import numpy as np
from functools import reduce

from collections import deque, Counter, defaultdict
from itertools import product, permutations,combinations
from operator import itemgetter
from heapq import heappop, heappush
from bisect import bisect_left, bisect_right, bisect
from fractions import gcd
from math import ceil,floor, sqrt, cos, sin, pi, factorial
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10**8)
INF = float('inf')
MOD = 10**9+7

def main():
  n = input()
  k = int(input())
  l = len(n)
  for i in range(min(k,l)):
    if n[i] == '1':
      ans = '1'
    else:
      ans = n[i]
      break
  print(ans)
  
  
  
if __name__ == '__main__':
  main()

Measured memory_bytes: 14560
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<vector>
#include<set>
#include<cmath>
#include<cstdlib>
#include<iostream>
#include<map>

#define Rep(i,x,y) for (int i=x,_Lim=y;i<=_Lim;i++)
#define Dep(i,x,y) for (int i=x,_Lim=y;i>=_Lim;i--)

#define mk(a,b) make_pair(a,b)

using namespace std;

typedef long long ll;
typedef pair<int,int> PII;

int Stv[1<<8];

inline int read(){
	int f=1,res=0,ch=getchar();
	while (ch<'0' || ch>'9'){
		if (ch=='-') f=-1;ch=getchar();
	}
	while (ch>='0' && ch<='9') res=res*10+ch-48,ch=getchar();
	return f*res;
}

int n,m;
int main(){
	n=read(),m=read();
	if (m==0){
		cout<<1ll*n*n<<endl;return 0;
	}
	ll Ans=0;
	Rep(i,m+1,n){
		int kes=n/i;
		Ans+=1ll*(i-m)*kes;
		Ans+=max(n%i-m+1,0);
	}
	cout<<Ans<<endl;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func getString() string {
	sc.Scan()
	return sc.Text()
}

// min, max, asub, absなど基本関数
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func asub(a, b int) int {
	if a > b {
		return a - b
	}
	return b - a
}

func abs(a int) int {
	if a >= 0 {
		return a
	}
	return -a
}

func lowerBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] >= x
	})
	return idx
}

func upperBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] > x
	})
	return idx
}

func div(a, b, x int) int {
	ret := 0

	for i := a; i <= b; i++ {
		if i%x == 0 {
			ret++
		}
	}
	return ret
}

func main() {
	sc.Split(bufio.ScanWords)

	a, b, x := getInt(), getInt(), getInt()

	n := b/x - a/x
	if a%x == 0 {
		n++
	}

	out(n)
}


Measured memory_bytes: 640
N,K=map(int,input().split())
A=list(map(int,input().split()))
mod=pow(10,9)+7
answer=0
for n in range(N-1):
    number=A[n]
    for n_ in range(n,N-1):
        if A[n_+1]<number:
            answer+=1
sort_A=sorted(A,reverse=True)
answer2=0
for n in range(N-1):
    number=sort_A[n]
    for n_ in range(n,N-1):
        if sort_A[n_+1]<number:
            answer2+=1
print((answer*K+answer2*(K-1)*K//2)%mod)


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

int main()
{
    int a,b;

    cin>>a>>b;
    vector<int>v(a);

    for(int i=0;i<a;i++)
        cin>>v[i];

    int d=0,res=1;
    for(int i=0;i<a;i++)
    {
        int temp=d+v[i];
        d=temp;
        if(temp<=b) res++;
    }

    cout<<res<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void){

  int a;
  int b;
  int sum;
  
  char buf1[30];
  fgets(buf1, 30, stdin);
  sscanf(buf1, "%d %d", &a, &b);
  
  sum = a + b;
  
  if(sum < 10) {
   printf("%d", sum);
   }else{
   printf("error");
   }
   return 0;
}

Measured memory_bytes: 128
#include<stdio.h>

main(){
  int a, b, i, res, cnt = 0, lp;

  while(1){
    lp = scanf("%d %d", &a, &b);
    if(lp == EOF) break;

    for(i = 10 ; ; i *= 10){
      cnt++;
      res = (a + b) / i;

      if(res == 0) break;
    }

    printf("%d\n", cnt);
    cnt = 0;
  }
  return 0;
}

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

int main(){

    char s[10];
    scanf("%s",s);
    if(s[0] == 'Y' && s[1] == 'A' && s[2] == 'K' && s[3] == 'I'){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
from sys import stdin
def main():
    #入力
    readline=stdin.readline
    n=int(readline())
    a=list(map(int,readline().split()))

    cnt_2=0
    cnt_4=0
    for i in range(n):
        if a[i]%4==0:
            cnt_4+=1
        elif a[i]%2==0:
            cnt_2+=1
    
    m=min(n,n-cnt_2+1)
    if cnt_4>=m//2:
        print("Yes")
    else:
        print("No")

if __name__=="__main__":
    main()

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

int main(void) {
  int n, k, c = 0;

  if(scanf("%d %d", &n, &k) == 1);

  for(int i = 1; i <= n; i++) {
    if(i % 2 != 0) {
      c++;
    }
  }

  if(c >= k) {
    printf("YES");
  } else {
    printf("NO");
  }

  return 0;
}


Measured memory_bytes: 128
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")

#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <sstream>
#include <set>
#include <map>
#include <vector>
#include <list>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <string>
#include <queue>
#include <bitset>		//UWAGA - w czasie kompilacji musi byc znany rozmiar wektora - nie mozna go zmienic
#include <cassert>
#include <iomanip>		//do setprecision
#include <ctime>
#include <complex>
#include <chrono>
#include<unordered_map>
using namespace std;

#define FOR(i,b,e) for(int i=(b);i<(e);++i)
#define FORQ(i,b,e) for(int i=(b);i<=(e);++i)
#define FORD(i,b,e) for(int i=(b)-1;i>=(e);--i)
#define REP(x, n) for(int x = 0; x < (n); ++x)
#define ALL(u) (u).begin(),(u).end()

#define ST first
#define ND second
#define PB push_back
#define MP make_pair
#define LL long long
#define ULL unsigned LL
#define LD long double

typedef pair<int, int> PII;

struct custom_hash {
	static uint64_t splitmix64(uint64_t x) {
		// http://xorshift.di.unimi.it/splitmix64.c
		x += 0x9e3779b97f4a7c15;
		x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
		x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
		return x ^ (x >> 31);
	}

	size_t operator()(uint64_t x) const {
		static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
		return splitmix64(x + FIXED_RANDOM);
	}
};

unordered_map<long long, int, custom_hash> safe_map;

const double pi = 3.141592653589793238462643383279502884197169399375105820974944592307816406286208998628034825342;

const int MR = 5e5 + 10;

char s[MR];

int pref[MR], suf[MR];

int main()
{
	scanf("%s", s);
	int n = strlen(s);

	FORQ(i, 1, n)
		if (s[i - 1] == '<')
			pref[i] = pref[i - 1] + 1;
	FORD(i, n, 0)
		if (s[i] == '>')
			suf[i] = suf[i + 1] + 1;

	LL s = 0;
	FORQ(i, 0, n)
		s += max(pref[i], suf[i]);
	printf("%lld\n", s);

	return 0;
}

// FOR GNU C++ use the following pattern:
// Uncomment the code below and change your main into main2
// It does not build in MS C++
// But it does increase the stack size from 256 MB on CF and uses GNU C++

//#include <Processthreadsapi.h>
//#include <iostream>
//#include <Synchapi.h>
//#include <windows.h>
//#include <process.h>
//
//DWORD WINAPI MyThreadFunction(LPVOID lpParam) {
//    main2(nullptr);
//    return 0;
//}
//int main() {
//    auto h = CreateThread(nullptr, 1024 << 20, MyThreadFunction, nullptr, STACK_SIZE_PARAM_IS_A_RESERVATION, nullptr);
//    WaitForSingleObject(h, INFINITE);
//}

Measured memory_bytes: 4608
#include <iostream>
#include <queue>

using namespace std;
priority_queue<int, vector<int>, greater<int>> que;

int P,Q,R;
int main(){
  cin >> P >> Q >> R;
  que.push(P);
  que.push(Q);
  que.push(R);
  int ans = 0;
  ans = ans + que.top();
  que.pop();
  ans = ans + que.top();
  que.pop();

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


Measured memory_bytes: 256