akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
using namespace std;
int map[1010][1010];
int dp[1010][1010];
int main()
{
    while(1){
        int n;
        cin>>n;if(!n)return 0;
        for(int i=0;i<1010;++i){
            for(int j=0;j<1010;++j){
                map[i][j]=0;
                dp[i][j]=0;
            }
        }
        for(int i=0;i<n;++i){
            int h,r;
            cin>>h>>r;
            map[h+1][r+1]=1;
        }
        int m;
        cin>>m;
        for(int i=0;i<m;++i){
            int h,r;
            cin>>h>>r;
            map[h+1][r+1]=1;
        }
        for(int i=1;i<1002;++i){
            for(int j=1;j<1002;++j){
                dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
                if(map[i][j]){
                    dp[i][j]=max(dp[i][j],dp[i-1][j-1]+1);
                }
            }
        }
        cout<<dp[1001][1001]<<endl;
    }
}

Measured memory_bytes: 9128
import sys
sys.setrecursionlimit(10**8)
stdin = sys.stdin


def ni(): return int(ns())


def na(): return list(map(int, stdin.readline().split()))


def naa(N): return [na() for _ in range(N)]


def ns(): return stdin.readline().rstrip()  # ignore trailing spaces


N, K = na()
a_array = na()

mod = 10 ** 9 + 7

aa = []

for a in a_array:
    if a >= 0:
        aa.append([a, 1])
    else:
        aa.append([abs(a), 0])

aa = sorted(aa, key=lambda x: - (x[0]+0.1*x[1]))

minus_count = 0

last_plus = [0, 0]
last_minus = [0, 0]

for i in range(K):
    v, f = aa[i]
    if f == 0:
        minus_count += 1
        last_minus = [v, i]
    else:
        last_plus = [v, i]

ans = 1

if minus_count % 2 == 0:
    for i in range(K):
        ans = (ans * aa[i][0]) % mod
    print(ans)
    exit()
else:
    if aa[K-1][0] == 0:
        print(0)
        exit()
    plus_ok = 0
    minus_ok = 0
    change_plus = [-1, 0]
    change_minus = [0, 0]
    for i in range(K, N):
        v, f = aa[i]
        if plus_ok == 0 and minus_count != 0 and f == 1:
            plus_ok = 1
            change_plus = [v, i]
        elif minus_ok == 0 and minus_count != K and f == 0:
            minus_ok = 1
            change_minus = [v, i]
        if minus_ok == 1 and plus_ok == 1:
            break

    if minus_ok == 0 and plus_ok == 0:
        for i in range(N-1, N-K-1, -1):
            ans = (ans * aa[i][0]) % mod
        if ans == 0:
            print(0)
        else:
            print(mod - ans)
        exit()

    D = last_plus[0] * change_plus[0] - last_minus[0] * change_minus[0]

    # print(change_plus, change_minus, last_plus, last_minus)

    ans = 1

    if D >= 0:
        for i in range(K):
            if i != last_minus[1]:
                ans = (ans * aa[i][0]) % mod
        ans = ans * aa[change_plus[1]][0] % mod
        print(ans)
    else:
        for i in range(K):
            if i != last_plus[1]:
                ans = (ans * aa[i][0]) % mod
        ans = ans * aa[change_minus[1]][0] % mod
        print(ans)


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

using namespace std;

#define ll long long
#define ld long double
#define P pair<ll, ll>

#define FORm(i, m) for (auto i = m.begin(); i != m.end(); i++)

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

#define sortAl(v) sort(all(v))
#define sortAlr(v)          \
  sort(v.begin(), v.end()); \
  reverse(v.begin(), v.end())

#define cout(n) cout << fixed << setprecision(n)

#define rep(i, n) for (ll i = 0; i < n; i++)
#define REP(i, n) for (ll i = 1; i < n; 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 INF LLONG_MAX

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

  ll n;
  cin >> n;

  vector<ll> p(n);

  rep(i, n) {
    cin >> p[i];
  }

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

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <complex>
using namespace std;
long long  N=0;
long long  ans =0;
long long  i=0;
long long  j=0;
bool rule = true;


int main(){
  cin >> N;
  vector<string> W(N);
  for(i=0;i<N;i++){
    cin >> W.at(i);
  }
  
  for(i=1;i<N;i++){
    if(W.at(i-1).back() !=  W.at(i).at(0)){
      cout << "No" << endl;
      return 0;
    }
  }
  
  for(i=0;i<N-1;i++){
    for(j=i+1;j<N;j++){
      if(W.at(i) ==  W.at(j)){
        cout << "No" << endl;
        return 0;
      }
    }
  }
  cout << "Yes" << endl;
  return 0;
}



Measured memory_bytes: 256
// #define DEBUGGING
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define ALL(V) (V).begin(), (V).end()
#define ALLR(V) (V).rbegin(), (V).rend()

template <typename T> using V = vector<T>;
template <typename T> using VV = V<V<T>>;
using ll = int64_t;
using ull = uint64_t;
using PLL = pair<ll, ll>;

template <typename T> const T& var_min(const T &t) { return t; }
template <typename T> const T& var_max(const T &t) { return t; }
template <typename T, typename... Tail> const T& var_min(const T &t, const Tail&... tail) { return min(t, var_min(tail...)); }
template <typename T, typename... Tail> const T& var_max(const T &t, const Tail&... tail) { return max(t, var_max(tail...)); }
template <typename T, typename... Tail> void chmin(T &t, const Tail&... tail) { t = var_min(t, tail...); }
template <typename T, typename... Tail> void chmax(T &t, const Tail&... tail) { t = var_max(t, tail...); }
template <typename T> const T& clamp(const T &t, const T &low, const T &high) { return max(low, min(high, t)); }
template <typename T> void chclamp(T &t, const T &low, const T &high) { t = clamp(t, low, high); }

namespace init__ {

struct InitIO {
    InitIO() {
        cin.tie(nullptr);
        ios_base::sync_with_stdio(false);
        cout << fixed << setprecision(30);
    }
} init_io;

}

#ifdef DEBUGGING
// #include "../debug/debug.cpp"
#include "../../debug/debug.cpp"
#else
#define DEBUG(...) 0
#define DEBUG_SEPARATOR_LINE 0
#endif

template <typename T>
T make_v(T init) { return init; }

template <typename T, typename... Tail>
auto make_v(T init, size_t s, Tail... tail) {
#define rec make_v(init, tail...)
    return V<decltype(rec)>(s, rec);
#undef rec
}

pair<V<ll>, V<ll>> sum_ab(const string &S) {
    V<ll> sum_a(S.size() + 1);
    V<ll> sum_b(S.size() + 1);
    for(ll i = 0; i < S.size(); i++) {
        sum_a[i + 1] = sum_a[i] + (S[i] == 'A');
        sum_b[i + 1] = sum_b[i] + (S[i] == 'B');
    }
    return make_pair(move(sum_a), move(sum_b));
}

int main() {
    string S, T;
    cin >> S >> T;
    V<ll> sum_s_a, sum_s_b, sum_t_a, sum_t_b;
    tie(sum_s_a, sum_s_b) = sum_ab(S);
    tie(sum_t_a, sum_t_b) = sum_ab(T);
    ll Q;
    cin >> Q;
    while(Q--) {
        ll a, b, c, d;
        cin >> a >> b >> c >> d;
        a--; c--;
        ll s_a = sum_s_a[b] - sum_s_a[a];
        ll s_b = sum_s_b[b] - sum_s_b[a];
        ll t_a = sum_t_a[d] - sum_t_a[c];
        ll t_b = sum_t_b[d] - sum_t_b[c];
        DEBUG(make_tuple(s_a, s_b, t_a, t_b));
        ll rest_s = s_a + 2 * s_b;
        ll rest_t = t_a + 2 * t_b;
        ll diff = abs(rest_s - rest_t);
        cout << (diff % 3 == 0 ? "YES" : "NO") << endl;
    }
    return 0;
}


Measured memory_bytes: 4048
//
#include<bits/stdc++.h>
using namespace std;
int a,b;
int tt=1;
int main()
{
int r=0;
	cin>>a>>b;
	if(b<=1) {cout<<0<<endl;return 0;}
	while(1)
{	
	r++;
	tt+=a-1;
	if(tt>=b) break;
}
cout<<r<<endl;
} 

Measured memory_bytes: 256
#include<algorithm>
#include<iostream>
#include<cstdlib>
#include<cstring>
#include<cctype>
#include<cstdio>
#include<string>
#include<queue>
#include<stack>
#include<cmath>
#include<map>
#include<set>
using namespace std;
const int inf=0x7fffffff;
const double eps=1e-10;
const double pi=acos(-1.0);
//char buf[1<<15],*S=buf,*T=buf;
//char getch(){return S==T&&(T=(S=buf)+fread(buf,1,1<<15,stdin),S==T)?0:*S++;}
inline int read(){
	int x=0,f=1;char ch;ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-') f=0;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=(x<<1)+(x<<3)+(ch&15);ch=getchar();}
	if(f)return x;else return -x;
}
using namespace std;
const int N=300005;
int n,L,ans=1,cnt,ok;
int x[N],t[N];
bool l[N],r[N];
int main(){
	n=read();L=read()<<1;
	for(int i=1;i<=n;i++)x[i]=read()<<1;
	for(int i=1;i<=n;i++)t[i]=read();
	for(int i=1;i<=n;i++){
		int v=t[i]%L;//v：火车从商场 i出发后，到购物完成，与商场i的距离。 
		ans+=(1ll*t[i]+L-1)/L;//ans记录跑了其中多少个来回。 
		if(!v)continue;
		l[i]=(v<=x[i]);//右进是否左出 
		r[i]=(v<=L-x[i]);//左进是否右出 
//		cout<<l[i]<<" "<<r[i]<<endl;
	}
//	cout<<ans<<endl;
	for(int i=1;i<n;i++)
		if(cnt&&r[i]){if(l[i])++ok;--ans;--cnt;}
		else if(l[i]) ++cnt;
		else if(r[i]&&ok) --ok,++cnt;
	if(r[n])ans--;
//	cout<<ans<<endl;
	printf("%lld\n",1ll*ans*L);
	return 0;
}


Measured memory_bytes: 3200
N = int(input())
dct = {}
falseflag = 0
now = 0
for i in range(N):
  A,B = list(map(int, input().split()))
  if( B not in dct):
    dct[B] = [A]
  else:
    dct[B].append(A)
worklist = sorted(dct.items())
for i in range(len(worklist)):
  now += sum(worklist[i][1])
  if(now > worklist[i][0]):
    falseflag = 1
    break
if(falseflag==0):
  print("Yes")
else:
  print("No")

Measured memory_bytes: 61296
#include<bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pi;
 
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define rep(i,a,b) for (ll i=a; i<b; i++)
// #define endl "\n"
const int mod = 1000000007;
const ll INF = 1e18L + 5;

ll power(ll x, ll y) 
{ 
    ll res = 1;     // Initialize result 
   
    while (y > 0) 
    { 
        // If y is odd, multiply x with result 
        if (y & 1) 
            res = res*x; 
        res%=mod;
        // n must be even now 
        y = y>>1; // y = y/2 
        x = x*x;
        x%=mod;  // Change x to x^2 
    } 
    return res%mod; 
}

int main() {
    ios_base::sync_with_stdio(false);    //Fast I/O
    cin.tie(NULL);
 
    // freopen("input.txt", "r", stdin);    // Read and write from a file
    // freopen("output.txt", "w", stdout);
    
    int n;
    cin >> n;
    vector<double> arr(n,0);
    vector<double> dp(n+1, 0);

    for(int i=0; i<n; i++){
        cin >> arr[i];
    }
    // dp[i] = Probability of having exactly i heads. 
    dp[0] = 1-arr[0];
    dp[1] = arr[0];
    for(int i=1; i<n; i++){
        int j=i+1;
        dp[j] = dp[j-1]*arr[i];
        j--;
        for(; j>0; j--){
            dp[j] = dp[j]*(1-arr[i]) + dp[j-1]*arr[i];
        }
        dp[0] = dp[0]*(1-arr[i]);
    }

    double ans=0;
    int i = n;
    while(1){
        if(i > (n-i))
            ans += dp[i];
        else
            break;
        i--;
    }

    cout.precision(9);
    cout << ans << endl;


    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const double PI  = acos(-1.0);

#define print(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl; 
int main()
{
    double x;
    cin >> x;
    cout << 2 * PI * x;
    return 0;
}



Measured memory_bytes: 3764
open Scanf
open Printf

let flip f x y = f y x

let rec range a b = if a >= b then [] else a :: range (a+1) b

let read_int () = scanf " %d" (fun x -> x)
let rec read_ints n = if n = 0 then [] else let i = read_int () in i :: read_ints (n-1)

let rec for_iter a b f = if a >= b then [] else let x = f a in x :: for_iter (a+1) b f
let rec for_iter_ a b f = if a >= b then () else (f a; for_iter_ (a+1) b f)

let () =
  let n = read_int () in let k = read_int () in
  read_ints n
  |> List.map (fun x -> 2 * min x (k-x))
  |> List.fold_left (+) 0
  |> printf "%d\n"


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define LL_MAX LLONG_MAX
#define ULL_MAX ULLONG_MAX
#define ull unsigned long long
#define IOS ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define pb(x) push_back(x)
#define eb(x) emplace_back(x)
#define forn(i, n) for (int i = 0; i < int(n); ++i)
#define fore(i, l, r) for (int i = int(l); i < int(r); ++i)
#define mk make_pair
#define endl '\n'

int main()
{
    IOS;
    ll n,k;
    cin>>n>>k;
    vector<int> a(n+1,0);
    for (int i = 1; i < n+1; i++)
    {
        cin>>a[i];
        /* code */
    }
    map<int,int> mp;

    int count=0;
    int s=1;
    int diff=0;
    while(k)
    {
        k--;
        count++;
        s=a[s];
        if(mp[s]!=0)
        {
            diff=count-mp[s];
            break;
        }
        else
        {
            mp[s]=count;
        }
    }
    if(k!=0)
        k=k%diff;
    while(k--)
    {
        s=a[s];
    }
    cout<<s;
}

Measured memory_bytes: 11468
n, l = map(int, input().split())

d = [l + i for i in range(n)]
pre_d = sum(d)
mi = 100 * 200
for i in d:
    if i == 0:
        ans = pre_d
        break
    else:
        dif = abs(pre_d - (pre_d - i))
        if dif < mi:
            mi = dif
            ans = pre_d - i

print(ans)


Measured memory_bytes: 3060
n = int(input())
a = list(map(int, input().split()))
q = int(input())
dic = [0 for _ in range(10 ** 5 + 1)]
count = 0
for i in a:
    dic[i] += 1
    count += i

for i in range(q):
    b, c = map(int,input().split())
    count -= b * dic[b]
    dic[c] += dic[b]
    count += c * dic[b]
    dic[b] = 0
    print(count)

Measured memory_bytes: 21000
//
//AtCoder Beginner Contest 107
//B
//

#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <ctime>
#include <queue>
#include <map>
#include <set>
#include <tuple>
#include <functional>
#include <cassert>
#include <bitset>
#include <numeric>

using namespace std;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define SIZE(x) (int)(x).size()
#define SIZEL(x) (ll)(x).size()
#define MSG(a) cout << #a << " " << a << endl;

using ll = long long;
using ld = long double;
using Graph = vector<vector<int>>;

const double PI = 3.14159265358979323846;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

ll gcd(ll x, ll y) { return (x % y)? gcd(y, x % y): y; }    //最大公約数
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }            //最小公倍数

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

    vector<string> a;
    REP(h, H) {
        string tmp;
        cin >> tmp;
        if (count(tmp.begin(), tmp.end(), '#') > 0){
            a.push_back(tmp);
        }
    }
    vector<int> wSkip(W,1);
    REP(w, W){
        REP(h, a.size()){
            if (a[h][w]=='#') wSkip[w]=0;
        }
    }

    REP(h, a.size()){
        REP(w, W){
            if (wSkip[w]==1) continue; 
            cout << a[h][w];
        }
        cout << endl;
    }
    return 0;
}


Measured memory_bytes: 3624
#include <iostream>
#include <vector>
#include <algorithm>

int main(){
   int N, K;
   std::string S;
   std::cin >> N >> K >> S;

   std::vector<int> serial;
   std::string state;
   int count = 0;
   for(int i=0; i<N-1; ++i){
      ++count;
      if(S[i]!=S[i+1]){
	 serial.push_back(count);
	 state.push_back(S[i]);
	 count = 0;
      }
   }
   serial.push_back(++count);
   state.push_back(S[N-1]);

   int m = serial.size();
   int n = 0;
   int ans = 0;
   for(int i=0; i<m; ++i){
      if(state[i]=='0'){
	 if(i==0){
	    for(int j=0; j<K; ++j){
	       if(i+j*2<m) n += serial[i+j*2];
	       if(i+j*2+1<m) n += serial[i+j*2+1];
	    }
	 }
      }else{
	 if(i==0){
	    n += serial[i];
	    for(int j=0; j<K; ++j){
	       if(i+j*2+1<m) n += serial[i+j*2+1];
	       if(i+j*2+2<m) n += serial[i+j*2+2];
	    }
	 }else{
	    if(i-1>=0) n -= serial[i-1];
	    if(i-2>=0) n -= serial[i-2];
	    if(i+(K-1)*2+1<m)  n += serial[i+(K-1)*2+1];
	    if(i+(K-1)*2+2<m)  n += serial[i+(K-1)*2+2];
	 }
      }
      if(ans<n) ans = n;
   }
   std::cout << ans << std::endl;
   return 0;
}


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

int main()
{
  string r, a;
  while (cin >> r >> a) {
    if (r == "0" && a == "0")
      break;

    int hit = 0;
    for (int i = 0; i < 4; ++i) {
      if (r[i] == a[i])
	++hit;
    }

    int blow = 0;
    for (int i = 0; i < 4; ++i) {
      for (int j = 0; j < 4; ++j) {
	if (i == j)
	  continue;
	if (r[i] == a[j])
	  ++blow;
      }
    }

    cout << hit << " " << blow << endl;
  }
  return 0;
}

Measured memory_bytes: 916
#include<iostream>
#include<algorithm>
using namespace std;
int n, v[3][100005], st, dr, mid;
long long sol = 0, s;
int main(){
    cin >> n;
    for( int k = 0; k <= 2; k++ )
        for( int i = 1; i <= n; i++ )
            cin >> v[k][i];
    sort( v[0] + 1, v[0] + n + 1 );
    sort( v[2] + 1, v[2] + n + 1 );
    for( int i = 1; i <= n; i++ ){
        st = 1;
        dr = n;
        while( st <= dr ){
            mid = ( st + dr ) >> 1;
            if( v[0][mid] < v[1][i] )
                st = mid + 1;
            else
                dr = mid - 1;
        }
        s = dr;
        st = 1;
        dr = n;
        while( st <= dr ){
            mid = ( st + dr ) >> 1;
            if( v[1][i] < v[2][mid] )
                dr = mid - 1;
            else
                st = mid + 1;
        }
        s *= (n - dr);
        sol += s;
    }
    cout << sol << "\n";
    return 0;
}


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

#define dump(x) cout << (x) << '\n'
#define Int int64_t
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
 
Int INF = 1e18;
int inf = 1e9;
Int mod = 1e9+7;

int main() {
    Int n, l;
    cin >> n >> l;
    vector<Int> a(n);
    for (Int i = 0; i < n; i++) {
        cin >> a[i];
    }
    Int index = -1;
    bool check = false;
    for (Int i = 0; i < n - 1; i++) {
        if (a[i] + a[i + 1] >= l) {
            check = true;
            index = i;
        }
    }
    if (check) {
        dump("Possible");
        for (Int i = 0; i < index; i++) {
            dump(i + 1);
        }
        for (Int i = n - 2; i > index; i--) {
            dump(i + 1);
        }
        dump(index + 1);
    } else {
        dump("Impossible");
    }
    return 0;
}

Measured memory_bytes: 1536
#include<bits/stdc++.h>
#define reg register
using namespace std;
inline int  read() {
    reg int s = 0, t = 0; reg char ch = getchar();
    while(ch > '9' || ch < '0') t |= ch == '-', ch = getchar();
    while(ch >= '0' && ch <= '9') s = (s << 1) + (s << 3) + (ch ^ 48), ch = getchar();
    return t ? -s : s;
}
int n, m, a[301][301], d[301], pos[301], sum[301], minn = 190090, ans;
int main()
{
    n = read(); m =  read();
    for(int i = 1; i <= n; i++)
    {
        for(int j = 1; j <= m; j++) a[i][j] = read();
        sum[a[i][1]]++;
    }
    for(int i = m; i >= 1; i--){
        ans = 0;
        for(int j = 1; j <= m; j++) ans = max(ans, sum[j]);
        minn = min(minn, ans);
        for(int j = 1; j <= m; j++) {
            if(sum[j] == ans){   pos[j] = 1; break;}
        }
        for(int j = 1; j <= m; j++) sum[j] = 0;
        for(int j = 1; j <= n; j++) 
            for(int k = 1; k <= m; k++){
                if(!pos[a[j][k]]) {sum[a[j][k]]++; break;} 
            }
    }
    cout << minn;
}

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

using namespace std;
 
typedef long long int ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<bool> vb;
typedef vector <string> vs;
typedef vector<vector<int>> vvi;
typedef pair<int,int> pi;

#define int ll
#define forl(i,a,b) for (int i = a; i < b; i++)
#define rfor(i,b,a) for (int i = b; i >= a; i--)
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define srt(x) sort(x.begin(), x.end())
#define sumup(x) accumulate(x.begin(), x.end(), 0)
#define PI 3.141592653589793238
#define MOD 1000000007
#define loop(n) for(int i = 0; i < n; i++)
#define rloop(n) for(int i = n-1; i >= 0; i--)

void io() {
    #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);
}

int32_t main() {
    io();
    int t=1;
    //cin>>t;
    while(t--) {
        int n, d;
        cin>>n>>d;
        vl x(n);
        vl y(n);
        int c=0;
        loop(n) {
          cin>>x[i]>>y[i];
          if((x[i]*x[i] + y[i]*y[i])<= d*d) c++;
        }
        cout<<c<<"\n";
    }
    return 0;
}

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

using ll = int64_t;
#define int ll

#define FOR(i, a, b) for (int i = int(a); i < int(b); i++)
#define REP(i, b) FOR(i, 0, b)
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define ALL(x) x.begin(), x.end()
auto &errStream = cerr;
#ifdef LOCAL
#define cerr (cerr << "-- line " << __LINE__ << " -- ")
#else
class CerrDummy {
} cerrDummy;
template <class T> CerrDummy &operator<<(CerrDummy &cd, const T &) {
  return cd;
}
using charTDummy = char;
using traitsDummy = char_traits<charTDummy>;
CerrDummy &operator<<(CerrDummy &cd,
                      basic_ostream<charTDummy, traitsDummy> &(
                          basic_ostream<charTDummy, traitsDummy> &)) {
  return cd;
}
#define cerr cerrDummy
#endif
#define REACH cerr << "reached" << endl
#define DMP(x) cerr << #x << ":" << x << endl
#define ZERO(x) memset(x, 0, sizeof(x))
#define ONE(x) memset(x, -1, sizeof(x))

using pi = pair<int, int>;
using vi = vector<int>;
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;
}

ll read() {
  ll i;
  scanf("%" SCNd64, &i);
  return i;
}

void printSpace() { printf(" "); }

void printEoln() { printf("\n"); }

void print(ll x, int suc = 1) {
  printf("%" PRId64, x);
  if (suc == 1)
    printEoln();
  if (suc == 2)
    printSpace();
}

string readString() {
  static char buf[3341000];
  scanf("%s", buf);
  return string(buf);
}

char *readCharArray() {
  static char buf[3341000];
  static int bufUsed = 0;
  char *ret = buf + bufUsed;
  scanf("%s", ret);
  bufUsed += strlen(ret) + 1;
  return ret;
}

template <class T, class U> void chmax(T &a, U b) {
  if (a < b)
    a = b;
}

template <class T, class U> void chmin(T &a, U b) {
  if (b < a)
    a = b;
}

template <class T> T Sq(const T &t) { return t * t; }

#define CAPITAL
void Yes(bool ex = true) {
#ifdef CAPITAL
  cout << "YES" << endl;
#else
  cout << "Yes" << endl;
#endif
  if (ex)
    exit(0);
}
void No(bool ex = true) {
#ifdef CAPITAL
  cout << "NO" << endl;
#else
  cout << "No" << endl;
#endif
  if (ex)
    exit(0);
}

const ll infLL = LLONG_MAX / 3;

#ifdef int
const int inf = infLL;
#else
const int inf = INT_MAX / 2 - 100;
#endif

signed main() {
  int x = read();

  if (x <= 6) {
    print(1);
  } else if (x == 7) {
    print(2);
  } else {
    int ans, remain;
    ans = (x / 11) * 2;
    remain = x % 11;
    if (remain >= 1 && remain <= 6)
      ans += 1;
    else if (remain >= 1 && remain <= 10)
      ans += 2;
    print(ans);
  }

  return 0;
}


Measured memory_bytes: 256
fun main(args: Array<String>) {
  val n = readLine()!!.toInt()
  val s = readLine()!!

  var ans = 0L
  val dp = IntArray3D(n + 1, n + 1, n + 1)
  for (pattern in 0 until (1 shl n)) {
    val word = CharArray(n)
    var redCount = 0
    var blueCount = 0
    for (i in 0 until n) {
      if (pattern and (1 shl i) > 0) {
        // Blue
        word[n - 1 - blueCount] = s[i]
        blueCount++
      } else {
        // Red
        word[redCount] = s[i]
        redCount++
      }
    }
    // println(word)

    // DP Part
    for (i in 0..n) {
      for (r in 0..(n - redCount)) {
        for (b in 0..(n - blueCount)) {
          dp[i, r, b] = 0
        }
      }
    }
    dp[0, 0, 0] = 1
    for (i in 0 until n) {
      for (r in 0..(n - redCount)) {
        for (b in (0..(n - blueCount))) {
          if (redCount + r < n && s[n + i] == word[redCount + r]) {
            dp[i + 1, r + 1, b] += dp[i, r, b]
          }
          if (blueCount + b < n && s[n + i] == word[n - 1 - blueCount - b]) {
            dp[i + 1, r, b + 1] += dp[i, r, b]
          }
        }
      }
    }
    val count = dp[n, n - redCount, n - blueCount]
    ans += count.toLong()
  }
  println(ans)
}

class IntArray3D(val size1: Int, val size2: Int, val size3: Int) {
  private val innerArray = IntArray(size1 * size2 * size3)

  operator fun get(i1: Int, i2: Int, i3: Int): Int = innerArray[i3 + size3 * (i2 + size2 * i1)]

  operator fun set(i1: Int, i2: Int, i3: Int, v: Int) {
    innerArray[i3 + size3 * (i2 + size2 * i1)] = v
  }
}


Measured memory_bytes: 41200
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=300010;
int n,x,y;
string s;
int main()
{
	cin>>s;
	if(s.size()>=6&&s[2]==s[3]&&s[4]==s[5]) cout<<"Yes";
	else cout<<"No";
	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;
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
using namespace std;
const int RANDOM1 = chrono::high_resolution_clock::now().time_since_epoch().count();
struct chash {
    int operator()(int x) const { return hash<int>{}(x ^ RANDOM1); }
};
#define ll long long
#define mod 1000000007
#define pb push_back
#define mp make_pair
#define deb(x) cout<<#x<<" : "<<x<<"\n";
#define debug(x,y) cout<<#x<<" : "<<x<<"\t"<<#y<<" : "<<y<<"\n";
#define ff first
#define ss second
#define ub upper_bound
#define lb lower_bound
#define all(a) (a).begin(),(a).end()
#define bs binary_search
#define sz size()
#define vi vector<int>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define ld long double
#define clr fflush(stdout);
//#define clr cout.flush();
#define N 100001
#define fpr(i,a,b) for(int i=a;i<b;i++)
#define fdr(i,a,b) for(int i=a;i>b;i--)
#define repp(i,a,b,d) for(int i=a;i<b;i+=d)
#define repd(i,a,b,d) for(int i=a;i>b;i-=d)
#define LLMIN LLONG_MIN
#define LLMAX LLONG_MAX
#define AKASH_PATEL ios_base::sync_with_stdio(false);
#define SVNIT_SURAT cin.tie(NULL);cout.tie(NULL);
#define mset(x,a) memset(x,a,sizeof(x));
#define nl cout<<'\n';
#define print(c) cout<<c<<'\n';
#define setp(n) cout << fixed << setprecision(n)
#define take_arr(a,n) fpr(i,0,n) cin>>a[i];
#define print_arr(a,n) for(int i=0;i<n;i++) {cout<<a[i]<<" ";} cout<<'\n';
#define take_mat(mat,n,m) fpr(i,0,n) fpr(j,0,m) cin>>mat[i][j];
#define set_mat(mat,n,m,k) fpr(i,0,n) fpr(j,0,m) mat[i][j]=k;
#define print_mat(dist,n,m) for(int i=0;i<n;i++){for(int j=0;j<m;j++){cout<<dist[i][j]<<" ";}cout<<'\n';}
template< class T > bool inside(T a, T b, T c) { return a<=b && b<=c; }
int main()
{
    AKASH_PATEL;
    SVNIT_SURAT;
    ll k,n;
    cin>>k>>n;
    ll a[n];
    take_arr(a,n)
    ll p[n];
    ll ans=LLMAX;
    ll dif=a[0]+k-a[n-1];
    fpr(i,0,n)
    {
        ll l=i,r=(n-1+i)%n;
        //debug(l,r)
        if(l<r)
        {
            ans=min(a[r]-a[l],ans);
        }
        else
        {
//            deb(a[n-1]-a[l]+a[r]-a[0]+dif)
            ans=min(ans,a[n-1]-a[l]+a[r]-a[0]+dif);
        }
    }
    print(ans)
    return 0;
}





Measured memory_bytes: 1792
n=int(input())
count=0
for i in range(0,n):
    x=int(input())
    if(x==2 or x==3):
        count+=1
    elif(x%2!=0):
        d=3
        while(1):
            if(x%d!=0):
                d+=2
            else:
                break
            if(x < d*d):
                count+=1
                break
print(count)


Measured memory_bytes: 5604
#include <bits/stdc++.h>
#include<ctime>
using ll = long long;
using namespace std;
#define rep(i,n) for(int i=0, i##_len=(int)(n); i<i##_len; i++)
#define reps(i,n) for(int i=1 , i##_len=(int)(n);i<=i##_len;i++)
#define rrep(i,n) for(int i=((int)(n)-1);i>=0;i--)
#define rreps(i,n) for(int i=((int)(n));i>0;i--)
#define repi(i,x) for(auto i=(x).begin(),i##_fin=(x).end();i!=i##_fin;i++)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define solve(a) ((a)?"Yes":"No")
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef pair<int , int> Pi;
typedef vector<Pi> VPi;
typedef vector<long long> V;
typedef vector<V> VV;
typedef pair<long long , long long> P;
typedef vector<P> VP;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1;} return 0;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1;} return 0;}
const long long INFLL = 1LL<<60;
const int INF = 1<<30;
const double PI=acos(-1);
int main(){
	srand((unsigned int)time(NULL));
	int d;
	cin >>d;
	Vi ans(d,0);
	Vi res(d,0);
	Vi c(26,0);
	ll sum=0LL;
	rep(i,26){
		cin>>c[i];
		sum+=c[i];
	}
	VVi s(d,Vi(26,0));
	rep(i,d){
		rep(j,26){
			cin>>s[i][j];
		}
	}
	int up=1;
	ll val=-INFLL;
	ll now=0LL;
	ll pen=0LL;
	ll cnt=0;
	ll upr=-INFLL;
	Vi last(26,0);
	int J;
	ll RES = 0LL;
	rep(_, 1000)
	{
		srand((unsigned int)time(NULL));
		cnt = 0LL;
		RES = 0LL;
		rep(i, 26)
		{
			last[i] = 0;
		}

		rep(i, d)
		{
			ans[i] = rand() % 26;
			RES += s[i][ans[i]];
			last[ans[i]] = i + 1;
			rep(j, 26)
			{
				RES -= c[j] * (i + 1 - last[j]);
			}
			//  cout<<res<<endl;
		}

		if (chmax(upr, RES))
		{
			res = ans;
		}
	}

	rep(i, d)
	{
		cout << res[i] + 1 << endl;
	}
}

Measured memory_bytes: 3676
#include <iostream>

using namespace std;
long long dp[100010][3] = {},a[100010],b[100010],c[100010],ans = 0;
int main(){
	int i,n;
	cin >> n;
	for(i=1;i<=n;i++){
		cin >> a[i] >> b[i] >> c[i];
	}
	for(i=1;i<=n;i++){
		dp[i][0] = max(dp[i-1][1],dp[i-1][2]) + a[i];
		dp[i][1] = max(dp[i-1][2],dp[i-1][0]) + b[i];
		dp[i][2] = max(dp[i-1][0],dp[i-1][1]) + c[i];
	}
	for(i=0;i<3;i++){
		ans = max(ans,dp[n][i]);
	}
	cout << ans << endl;
}

Measured memory_bytes: 4992
#include <iostream>

using namespace std;

int main()
{
    string s, t;
    cin >> s >> t;

    string result;
    bool exists = false;
    for (int i = 0; i < s.size() - t.size() + 1; i++)
    {
        string tmp("");
        bool valid = true;
        for (int j = 0; j < s.size(); j++)
        {
            if (j >= i && j < i + t.size())
            {
                if (s[j] != '?' && s[j] != t[j - i])
                {
                    valid = false;
                }
                tmp.push_back(t[j - i]);
            }
            else if (s[j] == '?')
            {
                tmp.push_back('a');
            }
            else
            {
                tmp.push_back(s[j]);
            }
        }
        if (valid)
        {
            exists = true;
            result = tmp;
        }
    }
    cout << (exists ? result : "UNRESTORABLE") << endl;
}

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

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    
    int n;
    cin >> n;
    n %= 10;
    switch(n){
    case 2:
    case 4:
    case 5:
    case 7:
    case 9:
        cout << "hon" << endl;
        break;
    case 0:
    case 1:
    case 6:
    case 8:
        cout << "pon" << endl;
        break;
    default:
        cout << "bon" << endl;
    }
    
    return 0;
}

Measured memory_bytes: 3652
import math
from collections import deque
from collections import defaultdict
import itertools as it

#自作関数群
def readInt():
  return int(input())
def readInts():
  return list(map(int, input().split()))
def readChar():
  return input()
def readChars():
  return input().split()
def factorization(n):
  res = []
  if n%2==0:
    res.append(2)
  for i in range(3,math.floor(n//2)+1,2):
    if n%i==0:
      c = 0
      for j in res:
        if i%j==0:
          c=1
      if c==0:
        res.append(i)
  if len(res)==0:
    res = [n]
  return res
def fact2(n):
  p = factorization(n)
  res = []
  for i in p:
    c=0
    z=n
    while 1:
      if z%i==0:
        c+=1
        z/=i
      else:
        break
    res.append([i,c])
  return res
def fact(n):#階乗
  ans = 1
  m=n
  for _i in range(n-1):
    ans*=m
    m-=1
  return ans
def comb(n,r):#コンビネーション
  if n<r:
    return 0
  l = min(r,n-r)
  m=n
  u=1
  for _i in range(l):
    u*=m
    m-=1
  return u//fact(l)
def combmod(n,r,mod):
  return (fact(n)/fact(n-r)*pow(fact(r),mod-2,mod))%mod
def printQueue(q):
  r=copyQueue(q)
  ans=[0]*r.qsize()
  for i in range(r.qsize()-1,-1,-1):
    ans[i] = r.get()
  print(ans)
class UnionFind():
  def __init__(self, n):
    self.n = n
    self.parents = [-1]*n

  def find(self, x): # root
    if self.parents[x]<0:
      return x
    else:
      self.parents[x] = self.find(self.parents[x])
      return self.parents[x]

  def union(self,x,y):
    x = self.find(x)
    y = self.find(y)

    if x==y:
      return

    if self.parents[x]>self.parents[y]:
      x,y = y,x

    self.parents[x]+=self.parents[y]
    self.parents[y]=x

  def size(self,x):
    return -1*self.parents[self.find(x)]

  def same(self,x,y):
    return self.find(x)==self.find(y)

  def members(self,x): # much time
    root = self.find(x)
    return [i for i in range(self.n) if self.find(i)==root]

  def roots(self):
    return [i for i,x in enumerate(self.parents) if x<0]

  def group_count(self):
    return len(self.roots())

  def all_group_members(self):
    return {r: self.members(r) for r in self.roots()} # 1~n
def bitArr(n):#ビット全探索
  x = 1
  zero = "0"*n
  ans = []
  ans.append([0]*n)
  for i in range(2**n-1):
    ans.append(list(map(lambda x:int(x),list((zero+bin(x)[2:])[-1*n:]))))
    x+=1
  return ans;
def arrsSum(a1,a2):
  for i in range(len(a1)):
    a1[i]+=a2[i]
  return a1
def maxValue(a,b,v):
  v2 = v
  for i in range(v2,-1,-1):
    for j in range(v2//a+1): #j:aの個数
      k = i-a*j
      if k%b==0:
        return i
  return -1
def copyQueue(q):
  nq = queue.Queue()
  n = q.qsize()
  for i in range(n):
    x = q.get()
    q.put(x)
    nq.put(x)
  return nq
def get_sieve_of_eratosthenes(n):
  data = [2]
  #data = [0,0,0]
  for i in range(3,n+1,2):
    data.append(i)
    data.append(0)
  for i in range(len(data)):
    interval = data[i]
    if interval!=0:
      for j in range(i+interval,n-1,interval):
        data[j] = 0
  ans = [x for x in data if x!=0]
  #ans = data[:]
  return ans


a,b = readInts()

#print(a+b)
print(a*b)

Measured memory_bytes: 9524
#include <iostream>
#include <string>
#include <vector>
#include <numeric>
#include <queue>
#include <unordered_map>
#include <algorithm>
#include <cmath>

using ll = long long;

int main() {
    int N, T, A;
    std::cin >> N >> T >> A;
    std::vector<int> H(N);
    for (int i = 0; i < N; i++) {
        std::cin >> H[i];
    }

    int index = 0;
    double min = std::abs((double)T - H[0] * 0.006 - A);
    for (int i = 1; i < N; i++) {
        double h = std::abs((double)T - H[i] * 0.006 - A);
        if (h < min) {
            min = h;
            index = i;
        }
    }
    index++;
    std::cout << index << std::endl;
    return 0;
}


Measured memory_bytes: 256
# https://atcoder.jp/contests/abc155/tasks/abc155_b

N = int(input())
A = list(map(int,input().split()))

def main(A):
    for a in A:
        if a%2 ==1:
            continue
        if (a%3 != 0) and (a%5 != 0):
            return "DENIED"
    return "APPROVED"

if __name__ == "__main__":
    print(main(A))

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

using namespace std;

int a[100000];

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

  int ret=0;
  sort(a,a+N);
  for(int i=0;i<N;)
  {
    int now=a[i];
    int sum=0;
    for(;i<N;i++)
    {
      if(now==a[i])sum++;
      else break;
    }
    if(sum>=now)ret+=sum-now;
    else ret+=sum;
    cerr<< ":"<< now<< " "<< sum<< " "<< ret<< endl;
  }
  cout<< ret<< endl;

  return 0;
}


Measured memory_bytes: 640
import java.util.Scanner;

public class Main {
	public static void main(String args[]){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();

		int[][][] bfr =	new int[4][3][10]; //初期値は0?

		for(int z = 0; z < n; z++) {  //n回繰り返す
			int b = sc.nextInt();
			int f = sc.nextInt();
			int r = sc.nextInt();
			int v = sc.nextInt();
			bfr[b-1][f-1][r-1] += v;    //b棟f階r番目の部屋にv人の入出
			}

		for(int k = 0; k < 4; k++) {
			for(int i = 0; i < 3; i++) {
				for(int j = 0; j < 10; j++) {
					System.out.print(" " + bfr[k][i][j]);     //代入した数値を出力
				}
			System.out.println();
			}
			if(k < 3)
			System.out.println("####################");
		}
		sc.close();
	}
}



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

int main() {
	int n, x, m[100],sum=0,min=1000,ans;
	cin >> n >> x;
	for (int i = 0; i < n; i++) {
		cin >> m[i];
	}
	for (int i = 0; i < n; i++) {
		sum = sum + m[i];
		if (min > m[i]) {
			min = m[i];
		}
	}
	x = x - sum;
	ans = n + x / min;
	cout << ans << endl;
}

Measured memory_bytes: 256
### main

loop do
  n = gets.strip.to_i
  break if n == 0

  n2 = 2 * n

  cards = n2.times.map{1}
  c0 = []

  n.times do
    c = gets.strip.to_i - 1
    c0 << c
    cards[c] = 0
  end

  c0.sort!
  c1 = (0...n2).select{|c| cards[c] == 1}

  nxt = 0

  while ! c0.empty? && ! c1.empty?
    ## turn 0
    while nxt < n2 && cards[nxt] != 0
      nxt += 1
    end

    if nxt < n2
      cards[nxt] = -1
      c0.delete nxt
      nxt += 1
    else
      nxt = 0
    end

    break if c0.empty?

    ## turn 1
    while nxt < n2 && cards[nxt] != 1
      nxt += 1
    end

    if nxt < n2
      cards[nxt] = -1
      c1.delete nxt
      nxt += 1
    else
      nxt = 0
    end

    break if c1.empty?
  end

  puts c1.length
  puts c0.length
end

Measured memory_bytes: 6128
n,k = map(int,input().split())
r,s,p = map(int,input().split())
t = input()

t1 = t.replace("r","P")
t2 = t1.replace("s","R")
t3 = t2.replace("p","S")

# print(t3)
T = list(t3)
# print(T)
minus = 0
ls = ["R","S","P"]
for i in range(k,n):
    if i < n-k:
        tmp = T[i]
        before = T[i-k]
        after = T[i+k]
        if tmp == before:
            ls.remove(tmp)
            if tmp == after:
                T[i] = ls[0]
            else:
                ls.remove(after)
                T[i] = ls[0] 
                ls.append(after)
            ls.append(tmp)
            if T[i] == "R":
                minus += r
            elif T[i] == "S":
                minus += s
            elif T[i] == "P":
                minus += p
        else:
            pass
    elif i >= n-k:
        tmp = T[i]
        before = T[i-k]
        # after = T[i+k]
        if tmp == before:
            ls.remove(tmp)
            T[i] = ls[0]
            ls.append(tmp)
            if T[i] == "R":
                minus += r
            elif T[i] == "S":
                minus += s
            elif T[i] == "P":
                minus += p
        else:
            pass

# print(T)
p1 = r * T.count("R")
# print(p1)
p2 = s * T.count("S")
# print(p2)
p3 = p * T.count("P")
# print(p3)
# print(minus)

print(p1+p2+p3-minus)

Measured memory_bytes: 4340
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)

using namespace std;
using ll = long long;

int main()
{
    int N,X,T;
    cin >> N >> X >> T;

    int a = N/X;
    if ((N - X*a) > 0)
        a++;
    
    cout << a*T << endl;
    return 0;
}


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

using namespace std;

int main()
{
	string S;
	cin >> S;
	int start0, start1;
	start0 = start1 = 0;
	char current = '0';
	for (int i = 0; (size_t) i < S.size(); i++) {
		if (S[i] != current) {
			start0++;
		}
		if (current == '0') {
			current = '1';
		} else {
			current = '0';
		}
	}

	current = '1';
	for (int i = 0; (size_t) i < S.size(); i++) {
		if (S[i] != current) {
			start1++;
		}
		if (current == '0') {
			current = '1';
		} else {
			current = '0';
		}
	}

	cout << min(start0, start1) << endl;
	return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define l long
#define pb push_back

ll gcd(ll p,ll q )
{
    if(q>p) return gcd(q,p);
    if(q==0) return p;
    return gcd(q,p%q);
}

int main() {
	// your code goes here
	ios_base::sync_with_stdio(false); 
    cin.tie(NULL); 
	ll a,b,c,d;
	cin>>a>>b>>c>>d;
	ll t1=b/c - a/c;
	if(a%c==0) t1++;
	t1+=( b/d - a/d );
	if(a%d==0) t1++;
	ll t=(c*d)/gcd(c,d);
	ll t2=( b/t - a/t );
	if(a%t==0) t2++;
	ll sum=t1-t2;
	//cout<<t1<<":"<<t2;
	cout<<b-a+1-sum;
	return 0;
}


Measured memory_bytes: 256
s = input()
s1 = int(s[:2])
s2 = int(s[2:])
m = range(1,13)
if s1 in m and s2 in m:
    print('AMBIGUOUS')
elif s1 in m:
    print('MMYY')
elif s2 in m:
    print('YYMM')
else:
    print('NA')

Measured memory_bytes: 38384
#include<iostream>
#include<cmath>
#include<bits/stdc++.h>
#include<string.h>
using namespace std;
typedef long long int ll;
const ll maxn=1e6+8;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string s,t,p;
    cin>>s>>t;
    p=s;
    p="";
    ll ls=s.length();
    ll lt=t.length();
    ll i,j,m=0;
    for(i=0;i<=ls-lt;i++)
    {
        ll c=0;
        for(j=0;j<lt;j++)
        {
            p=p+s[i+j];
            if(s[i+j]==t[j])
                c++;
        }
        if(c>m)
            m=c;
        p="";
    }
    cout<<lt-m<<"\n";
    cerr<<"\nTime elapsed:"<< 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
    return 0;
}


Measured memory_bytes: 3720
#include <algorithm>
#include <iostream>
#include <utility>
#include <vector>

using namespace std;
using price_t = unsigned long long;

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

    vector<std::pair<price_t, int>> priceAmounts;

    for (int i = 0; i < N; ++i)
    {
        price_t a;
        int b;
        cin >> a;
        cin >> b;
        priceAmounts.emplace_back(a, b);
    }

    std::sort(priceAmounts.begin(), priceAmounts.end(), [](auto &left, auto &right) {
        return left.first < right.first;
    });


    price_t spent = 0;

    for (const auto priceAmount : priceAmounts)
    {
        if (M > priceAmount.second) {
            spent += priceAmount.second * priceAmount.first;
            M -= priceAmount.second;
        } else {
            spent += M * priceAmount.first;
            break;
        }
    }

    cout << spent;
    return 0;
}


Measured memory_bytes: 2420
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author silviase
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        CMaximumVolume solver = new CMaximumVolume();
        solver.solve(1, in, out);
        out.close();
    }

    static class CMaximumVolume {
        public void solve(int testNumber, Scanner in, PrintWriter out) {

            double l = Math.pow(in.nextInt(), 3);
            out.println(l / 27);

        }

    }
}



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

int findSumOfDigits(int);

int findSumOfDigits(int n) {
	int sum = 0;
	while (n > 0) { 
		sum += n % 10;
		n /= 10;
	}
	return sum;
}

int main() {
	int N;
	cin >> N ;
	int sum = findSumOfDigits(N); 

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

	}
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int N,K,a,ans[123456],arr[123456];
    cin>>N;
    for(int i=1; i<=N; i++)
    {
        cin>>arr[i];
        int c=arr[i];
        ans[c]=i;
    }
    for(int i=1; i<=N; i++)
    {
        cout<<ans[i]<<" ";
    }
}


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

void solve(){
  int a, b, c, d; cin >> a >> b >> c >> d;
  string ans;
  if(abs(a - c) <= d) ans = "Yes";
  else if(abs(a - b) <= d && abs(b - c) <= d) ans = "Yes";
  else ans = "No";
  cout << ans << endl;
  return;
}
int main(){
  solve();
  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <cmath>
#include <cstring>
#include <map>
#include <queue>
#include <string>
#include <set>
#include <random>
#define pb push_back
#define mod 1000000007
#define all(x) x.begin(),x.end()
#define inf (int)(1e9)
using namespace std;
typedef long long int ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<string,int> psi;

vector<pii> aka,ao;
bool use[111];
int main(void){
  int n;
  cin>>n;
  int a,b,c,d;
  for(int i=0;i<n;i++){
    cin>>a>>b;
    aka.pb(pii(a,b));
  }
  for(int i=0;i<n;i++){
    cin>>c>>d;
    ao.pb(pii(c,d));
  }
  sort(ao.begin(),ao.end());
  for(int i=0;i<n;i++){
   // printf(":%d %d\n",ao[i].first,ao[i].second);
  }
  int res=0;
  for(int i=0;i<n;i++){
    a=ao[i].first;
    b=ao[i].second;
    bool f=false;
    int t=-1;
    for(int j=0;j<n;j++){
      if(use[j]) continue;
      if(aka[j].first<a && aka[j].second<b){
	if(!f){
	  c=aka[j].first;
	  d=aka[j].second;
	  f=true;
	  t=j;
	}
	else{
	  if(d<aka[j].second){
	    t=j;
	    c=aka[j].first;
	    d=aka[j].second;
	  }
	}
      }
    }
    if(f){
      res++;
      use[t]=true;
    }
  }
  cout<<res<<endl;
  return 0;
}


Measured memory_bytes: 256
/* https://atcoder.jp/contests/abc088/tasks/abc088_c */

#include <iostream>
#include <vector>

std::vector<std::vector<int>> c(3, std::vector<int>(3));

int main(int argc, char *argv[])
{
  // Input
  for (int i = 0; i < 3; ++i) {
    for (int j = 0; j < 3; ++j) {
      std::cin >> c.at(i).at(j);
    }
  }

  // Output
  std::vector<int> a(3, 0);
  std::vector<int> b(3, 0);

  b.at(0) = c.at(0).at(0) - a.at(0);
  b.at(1) = c.at(0).at(1) - a.at(0);
  b.at(2) = c.at(0).at(2) - a.at(0);

  a.at(1) = c.at(1).at(1) - b.at(1);
  a.at(2) = c.at(2).at(2) - b.at(2);

  for (int i = 0; i < 3; ++i) {
    for (int j = 0; j < 3; ++j) {
      if (c.at(i).at(j) != a.at(i)+b.at(j)) {
        std::cout << "No" << std::endl;
        return 0;
      }
    }
  }

  std::cout << "Yes" << std::endl;

  return 0;
}


Measured memory_bytes: 764
#include<iostream>
using namespace std;
int main(){
  int a,b,sum=0,c;
  cin>>a>>b;
  for(int i=0;i<b;i++){
    cin>>c;
    sum+=c;
  }
  if(a<=sum)
    cout<<"Yes"<<endl;
  else
    cout<<"No"<<endl;
}

Measured memory_bytes: 256
n, m = list(map(int, input().split()))
a = set(list(int(input()) for _ in range(m)))
mod = 1000000007

memo = [0]*(n+1)
memo[0] = 1


for i in range(1, n+1):
    memo[i] = memo[i-1] + memo[i-2]
    if i in a:
        memo[i] = 0

print(memo[-1]%mod)


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

using namespace std;

#define PI          3.1415926535897932384626433832795l

#define pb push_back
#define mp make_pair
#define lb lower_bound // First element which is not less than val
#define ub upper_bound // First element greater than val
#define f first
#define s second

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vd = vector<double>;
using vs = vector<string>;
using vpii = vector<pair<int,int>>;
using vpll = vector<pair<ll,ll>>;

using pii = pair<int,int>;
using pll = pair<ll,ll>;

#define endl '\n'
#define re return

#define repz(i, a) for (ll i = 0; i < (a); i++)

#define vecin(n,v) for(ll i = 0; i < n; i++) cin>>v[i];
#define llin(a) ll a; cin>>a;
#define llin2(a,b) ll a,b; cin >>a>>b;
#define llin3(a,b,c) ll a,b,c; cin>>a>>b>>c;
#define full(v) v.begin(),v.end()

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

void solve()
{
  map<string,int> m;
  int q;
  cin >> q;
  while(q--)
  {
    string s;
    cin >> s;
    m[s]++;
  }

  cout << "AC x " << m["AC"] << endl;  
  cout << "WA x " << m["WA"] << endl;  
  cout << "TLE x " << m["TLE"] << endl;  
  cout << "RE x " << m["RE"] << endl;  

}

int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ll t = 1;
  //cin >> t;
  while (t--)
  {
      solve();
  }
}



Measured memory_bytes: 3576