akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<string>
#include<vector>
#include<math.h>
#include<algorithm>
#include<cstdio>
#include<stdio.h>
#include<stack>
#include<sstream>
#include<iomanip>
#include<map>
#include<unordered_map>
#include<list>
#include<numeric>
typedef long long ll;

#define pi 3.14159265358979323846
#define VI vector<int>
#define VLL vector<long long>
#define MAX max_element
#define MIN min_element
#define all(v) v.begin(), v.end()
const ll MOD = 1e9 + 7;
using namespace std;
template<typename T>
T gcd(T a, T b) {
	if (b == 0) return a;
	return gcd(b, a % b);
	//return b ? gcd(b, a % b) : a;
}
template<typename T>
T lcm(T a, T b) {
	ll g = gcd(a, b);
	return a / g * b; // Be careful not to overflow
	//return a * b / gcd(a, b);
}

template<typename T>
T binarysearch(vector<T> A, T key) {
	ll left = 0;ll right = 4;ll mid;
	while (left < right) {
		mid = (left + right) / 2;
		if (key == A[mid]) return 1;
		if (key > A[mid]) left = mid + 1;
		else if (key < A[mid]) right = mid;
	}
	return 0;
}

template<typename T>
T finder(vector<T> vec, T number) {
	auto itr = find(vec.begin(), vec.end(), number);
	size_t index = distance(vec.begin(), itr);
	if (index != vec.size()) { // 発見できたとき
		return 1;
	}
	else { // 発見できなかったとき
		return 0;
	}
}
ll frac(ll n)//階乗
{
	if (n == 0) {
		return 1;
	}
	return (n * frac(n - 1)) % MOD;
}

template<typename T>
T keta(T a) {
	ll kazu = 1;
	while (1) {
		if (a / 10 != 0) { a /= 10;kazu++; }
		else break;
	}
	return kazu;
}//桁数


template<typename T>
T nCr(ll n, T r) {
	ll ans = 1;
	for (int i = n; i > n - r; --i) {
		ans = ans * i;
	}
	for (int i = 1; i < r + 1; ++i) {
		ans = ans / i;
	}
	return ans;
}
/*char r[4];
int yaju[4];
char op[3];
int sum = 0;
scanf("%s", r);
for (int i = 0;i < 4;i++) {
	yaju[i] = r[i] - '0';
}
*/
//vector<vector<int>> data(3, vector<int>(4));

int main() {
	ll mod = 1e9 + 7;
	ll ans=0;
	ll A, B, C, K;cin >> A >> B >> C >> K;
	if (A >= K) cout << K << endl;
	else if ((A + B) >= K)cout << A << endl;
	else cout << A - (K - A - B) << endl;
}

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

using namespace std;

const int EuclideanAlgorithm(const int a, const int b)
{
    if (a < b)
    {
        return EuclideanAlgorithm(b, a);
    }
    if (b == 0)
    {
        return a;
    }
    return EuclideanAlgorithm(b, a % b);
}

const vector<int> ComputeLs(const vector<int> &As, const int N)
{
    vector<int> Ls{ 0 };
    for (int i = 1; i < N; ++i)
    {
        Ls.push_back(EuclideanAlgorithm(Ls[i - 1], As[i - 1]));
    }
    return Ls;
}

const vector<int> ComputeRs(const vector<int> &As, const int N)
{
    vector<int> reversedAs = As;
    reverse(reversedAs.begin(), reversedAs.end());
    auto Rs = ComputeLs(reversedAs, N);
    reverse(Rs.begin(), Rs.end());
    return Rs;
}

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

    vector<int> As(N);
    for (int i = 0; i < N; ++i)
    {
        cin >> As[i];
    }
    if (N == 2)
    {
        cout << max(As[0], As[1]);
        return 0;
    }

    const auto Ls = ComputeLs(As, N);
    const auto Rs = ComputeRs(As, N);

    vector<int> Ms;
    for (int i = 0; i < N; ++i)
    {
        Ms.push_back(EuclideanAlgorithm(Ls[i], Rs[i]));
    }
    cout << *max_element(Ms.begin(), Ms.end());

    return 0;
}

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

int main(void){

    int i, j, n, k, d, b, c;
    int a[100];

    scanf("%d %d", &n, &k);
    for (i=0; i<n; i++)
        a[i] = 0;

    for(j=0; j<k; j++){
        scanf("%d", &d);
        for(i=0; i<d; i++){
            scanf("%d", &b);
            a[b-1]=1;
        }
    }
    c=0;
    for (i=0; i<n; i++)
        if(a[i]==0)
            c++;
    printf("%d\n", c);

    return 0;
}


Measured memory_bytes: 1728
n,m = map(int,input().split())
mod = 10**9+7

if abs(n -m) > 1:
    print(0)
    
if  abs(n -m) == 0:
    n_ans = 1
    m_ans = 1
    for i in range(1,n+1):
        n_ans *= i
        n_ans %= mod
    for i in range(1,m+1):
        m_ans *= i
        m_ans %= mod
    print(2*n_ans*m_ans%mod)
    
if abs(n -m) == 1:
    n_ans = 1
    m_ans = 1
    for i in range(1,n+1):
        n_ans *= i
        n_ans %= mod
    for i in range(1,m+1):
        m_ans *= i
        m_ans %= mod
    print(n_ans*m_ans%mod)

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

#define INF 1.1e9
#define LINF 1.1e18
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define BIT(x,n) bitset<n>(x)
#define PI 3.14159265358979323846

typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll,P> PP;

//-----------------------------------------------------------------------------

int n,m;
ll a[270000];

int dfs(int depth,int idx) {
	if(depth==n) {
		return a[idx-m];
	}
	else {
		int x=dfs(depth+1,idx*2),y=dfs(depth+1,idx*2+1);
		if(x==y) return x;
		else return max(x,y)-min(x,y);
	}
}

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

	cin>>n;
	m=pow(2,n);
	REP(i,m) cin>>a[i];
	cout<<dfs(0,1)<<endl;


	return 0;
}


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

typedef long long ll;

int main(){
	static ll n;
	static ll a[200010];
	scanf("%lld",&n);
	for(int i = 0 ; i < n ; i ++){
		scanf("%lld",&a[i]);
	}
	
	ll sum = 0;
	for(int i = 0 ; i < n ; i ++){
		sum += a[i];
	}
	ll ret = sum;
	ll s = 0;
	for(int i = 0 ; i < n ; i ++){
		s += a[i];
		ret = min( ret , abs(sum-2*s) );
	}
	cout << ret << endl;
}
	

Measured memory_bytes: 1792
#include <iostream>

using namespace std;

typedef unsigned long long ull;
ull mod = ull(1e9 + 7);

ull power(ull m, ull n)
{
	ull pow = 1;
	while (n != 0) {
		m %= mod;
		if (n % 2 == 1) {
			pow *= m;
			pow %= mod;
		}
		m *= m;
		n >>= 1;
	}
	return pow;
}

int main()
{
	ull m, n;
	cin >> m >> n;
	cout << power(m, n) << endl;
	return 0;
}

Measured memory_bytes: 1152
#include<bits/stdc++.h>
using namespace std;
const int N=1e5+10;
#define pb push_back
#define sz(a) int(a.size())

int gi() {
	int x=0,o=1;char ch=getchar();
	while(!isdigit(ch)&&ch!='-') ch=getchar();
	if(ch=='-') o=-1,ch=getchar();
	while(isdigit(ch)) x=x*10+ch-'0',ch=getchar();
	return x*o;
}

int n,A,lim,f[N],rt;
vector<int> E[N];
bool fl;

bool check2(vector<int> &v,int mid) {
	int l=0,r=sz(v)-1;
	while(l<r) {
		if(l==mid) { ++l;continue; }
		if(r==mid) { --r;continue; }
		if(v[l]+v[r]>lim) return 0;
		++l,--r;
	}
	return 1;
}

void dfs(int u,int fa) {
	vector<int> vec;
	for(auto v:E[u]) if(v^fa) dfs(v,u),vec.pb(f[v]);
	if(sz(vec)&1^1) vec.pb(0);
	sort(vec.begin(),vec.end());
	int l=0,r=sz(vec);
	while(l<r) {
		int mid=(l+r)>>1;
		if(check2(vec,mid)) r=mid;
		else l=mid+1;
	}
	if(l==sz(vec)) { fl=0;return; }
	f[u]=vec[l]+1;
}

bool check(int mid) {
	lim=mid;fl=1;dfs(rt,0);
	return fl&&f[rt]<=lim+1;
}

int main() {
	cin>>n;
	for(int i=1,u,v;i<n;i++) u=gi(),v=gi(),E[u].pb(v),E[v].pb(u);
	for(int i=1;i<=n;i++)
		if(sz(E[i])&1) ++A,rt=i;
	int l=0,r=n;
	while(l<r) {
		int mid=(l+r)>>1;
		if(check(mid)) r=mid;
		else l=mid+1;
	}
	cout<<A/2<<' '<<l;
	check(2);
	return 0;
}


Measured memory_bytes: 17024
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;

int main(){
    int n, k;
    cin >> n >> k;
    vector<int> move;
    ll ans[n];
    pair<int, int> l[k];
    ll sum[k];
    ll dis[k];
    ll now[k];
    for(int i = 0; i < k; i++){
        cin >> l[i].first >> l[i].second;
        sum[i] = 0;
        dis[i] = 0;
        now[i] = -1;
    }
    for(int i = 0; i < n; i++){
        ans[i] = 0;
    }
    ll mod = 998244353;
    sort(l, l + k);

    for(int i = 0; i < k; i++){
        dis[i] = l[i].second - l[i].first;
    }
    int size = move.size();
    ans[0] = 1;
    for(int i = 1; i < n; i++){
        for(int j = 0; j < k; j++){
            if(i - l[j].first < 0){
                break;
            }else{
                if(now[j] == dis[j]){
                    sum[j] -= ans[i - l[j].second - 1];
                    sum[j] += ans[i - l[j].first];
                    ans[i] += sum[j];
                    ans[i] %= mod;
                }else{
                    now[j]++;
                    sum[j] += ans[i - l[j].first];
                    ans[i] += sum[j];
                    ans[i] %= mod;
                }
            }
        }
    }

    cout << ans[n - 1] << endl;
}

Measured memory_bytes: 5196
#include <bits/stdc++.h>
using namespace std;
#define vec(type) vector<type>

int main() {
	int a, b;
	cin >> a >> b;

	if (a <= 0 && 0 <= b) cout << "Zero" << endl;
	else if (a > 0) cout << "Positive" << endl;
	else if (b < 0)
		if ((b-a)%2==1) cout << "Positive" << endl; 
		else cout << "Negative" << endl;
}

Measured memory_bytes: 3528
#include <algorithm>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <vector>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define show(x) cout << #x << " = " << x << endl;
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
ll dist[51][51];
int a[50];
int b[50];
int main(){
    int n;
    cin >> n;
    rep(i,n){
        cin >> a[i];
    }
    rep(i,n){
        cin >> b[i];
    }
    rep(i,51)rep(j,51)dist[i][j] = 1LL<<60;
    rep(i,51)dist[i][i] = 0;
    for(int i = 1;i <= 50; i++){
        for(int j = 1; j <= 50; j++){
            dist[i][i%j] = min(dist[i][i%j],1LL<<j);
        }
    }
    ll ans = 0;
    for(;;){
        rep(k,51){
            rep(j,51){
                rep(i,51){
                    dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
                }
            }
        }
        ll temp = 0;
        rep(i,n){
            temp = max(temp,dist[a[i]][b[i]]);
        }
        if(temp==1LL<<60){
            cout << -1 << endl;
            return 0;
        }
        if(temp == 0)break;
        int k = (int)log2(temp);
        ans += 1LL<<k;
        rep(i,51){
            dist[i][i%k] = 0;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 888
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <numeric>
#include <queue>
#include <map> 
#include <set>
#include <string>
#include <functional>
#include <list>
#include <random>
#include <time.h>
#include <iomanip>
#include <assert.h>
#define int long long
#define double long double
#define oku7 1000000007
#define MAXN (int)1e+5 * 2+1
#define LL_MAX 9223372036854775807	//ない環境用
#define LL_HALFMAX 9223372036854775807 / 2	//ない環境用

using namespace std;
std::mt19937 mt((int)time(0));

int dx[4] = { 0, 1, 0, -1 }; // x軸方向への変位
int dy[4] = { 1, 0, -1, 0 }; // y軸方向への変位

int c[101], t[101];
signed main() {
	int N,T;
	cin >> N>>T;
	for (int i = 0; i < N; i++) {
		cin >> c[i] >> t[i];
	}
	int minc = 1145141919;
	int mint = 1145141919;
	for (int i = 0; i < N; i++) {
		if (t[i] <= T && minc > c[i]) { 
			minc = c[i]; 
			mint = t[i];
		}
	}

	if (mint > T) cout << "TLE\n";
	else cout << minc << "\n";

}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <utility>
#include <string>
#include <cmath>
#include <cstdlib>
#include <cstring>

using namespace std;

typedef uint64_t u64;
typedef int64_t s64;
typedef uint32_t u32;
typedef int32_t s32;
typedef vector<s32> vs32;
typedef vector<u32> vu32;
typedef vector<s64> vs64;
typedef vector<u64> vu64;

const double PI=3.14159265358979323846;

#define MAX(x, y) ((x) < (y) ? (y) : (x))
#define MIN(x, y) ((x) > (y) ? (y) : (x))

#define rep(i, N) for(int i = 0; i < N; ++i)

#define CEIL(x, y) (((x) + (y) - 1) / (y))
#define MOD 1000000007ULL

int c[10][10];
int d[10][10];

void bfs(int r)
{
    d[r][r] = 0;
    priority_queue< pair<int, int> > pq;

    pq.push(make_pair(0, r));
    while (!pq.empty())
    {
        pair<int, int> du = pq.top(); pq.pop();

        int u = du.second;
        int minv = -du.first;

        if (d[r][u] < -minv) continue;

        rep (i, 10)
        {
            if (i == u) continue;
            int w = c[u][i];
            if (d[r][i] > d[r][u] + w)
            {
                d[r][i]  = d[r][u] + w;
                pq.push(make_pair(-d[r][i], i));
            }
        }
    }
}

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

    int H, W;
    cin >> H >> W;
    rep (i, 10)
    {
        rep (j, 10)
        {
            cin >> c[i][j];
            d[i][j] = (int)1e9;
        }
    }

    rep (i, 10)
    {
        if (i == 1)
        {
            rep (j, 10)
            {
                d[i][j] = 0;
            }
            continue;
        }
        bfs(i);
    }

    int A;
    int ans = 0;
    rep (i, H)
    {
        rep (j, W)
        {
            cin >> A;
            if (A != -1)
            {
                ans += d[A][1];
            }
        }
    }

    cout << ans << "\n";

    return 0;
}



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

Long combinatorioEn2(Long n){
   if(n<2) return 0;
   else return n*(n-1)/2;
}

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

   Long n,m;
   cin >> n >> m;

   cout << combinatorioEn2(n) + combinatorioEn2(m);
   return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧  
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     
　　　　／　　　＼　 　  |　|     
　　　 /　　 /￣￣￣￣/　　|  
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿  
　 　　　＼/＿＿＿＿/　（u　⊃  
---------------------------------------------------------------------------------------------------*/






int S;
//---------------------------------------------------------------------------------------------------
void _main() {
    cin >> S;

    set<int> done;
    done.insert(S);
    int cur = S;

    rep(id, 2, 1010101) {
        int nxt;
        if (cur % 2 == 0) nxt = cur / 2;
        else nxt = 3 * cur + 1;

        if (done.count(nxt)) {
            printf("%d\n", id);
            return;
        }
        done.insert(nxt);
        cur = nxt;
    }
}

Measured memory_bytes: 256
def ii():return int(input())
def iim():return map(int,input().split())
def iil():return list(map(int,input().split()))
def ism():return map(str,input().split())
def isl():return list(map(str,input().split()))

a,b,c,d = iim()

if abs(a-c) <= d or (abs(a-b) <= d and abs(b-c) <= d):
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3064
a ,b ,c = gets.split.map(&:to_i)

if a > b
  temp = b
  b = a
  a = temp
end

if b > c
  temp = c
  c = b
  b = temp
end

if a > b
  temp = b
  b = a
  a = temp
end

puts "#{a}\s#{b}\s#{c}"

Measured memory_bytes: 8684
#include <bits/stdc++.h>
using namespace std;
using pib = pair<int, int>;

bool bitget(int a,int b){
    return a&(1<<b);
}

 
int main (){
    int N;
    cin >> N;
    vector<vector<pib>> A(N);
    for(int i=0;i<N;i++){
        int j;
        cin >> j;
        A[i]=vector<pib>(j);
        for(pib &i:A[i])cin >> i.first >> i.second;
    }
    
    int maxc=0;
    for(int i=0;i<1<<N;i++){
        int count0=0,cc=0;
        for(vector<pib> j:A){
            int count1=0;
            for(pib k:j){
                if(bitget(i,k.first-1)!=k.second)break;
                count1++;
            }
            
            if((count1==j.size())&&bitget(i, cc))count0++;
            else if(bitget(i, cc))goto skip;
            
            cc++;
        }
        
        maxc=max(maxc,count0);
        
    skip:;
        
    }
    
    cout << maxc << endl;
}


Measured memory_bytes: 3560
x,y,z=map(int, input().split())
if x<=y<=z:
  print(x,y,z)
elif x<=z<=y:
  print(x,z,y)
elif y<=z<=x:
  print(y,z,x)
elif y<=x<=z:
  print(y,x,z)
elif z<=x<=y:
  print(z,x,y)
else:
  print(z,y,x)


Measured memory_bytes: 5596
#include <bits/stdc++.h>
using namespace std;
int main(){
  cout << fixed << setprecision(20);
  int N,K;
  cin >> N >> K;
  vector<int> p(N);
  for (int i = 0; i < N; i++) cin >> p[i];
  vector<long long> T(N - K + 1,0);
  for (int i = 0; i < K; i++) T[0] += p[i];
  for (int i = 1; i < N - K + 1; i++){
    T[i] = T[i - 1] - p[i - 1] + p[i - 1 + K];
  }
  long long M = 0;
  for (int i = 0; i < N - K + 1; i++) M = max(M,T[i]);
  cout << (M + K) / 2.0;
}

Measured memory_bytes: 2560
#include "bits/stdc++.h"
// Begin Header {{{
#define all(x) (x).begin(), (x).end()
#define rep(i, s, n) for (i64 i = (s), i##_limit = (n); i < i##_limit; ++i)
#define repr(i, s, t) for (i64 i = (s), i##_limit = (t); i >= i##_limit; --i)
#define repc(i, s, t) for (i64 i = (s), i##_limit = (t); i <= i##_limit; ++i)
#define var(type, ...) \
    type __VA_ARGS__;  \
    read(__VA_ARGS__);
#ifndef DBG
#define dump(...)
#endif
using namespace std;
using i64 = int_fast64_t;
using pii = pair<i64, i64>;
template <class T, class U>
inline bool chmax(T &a, const U &b) {
    return b > a && (a = b, true);
}
template <class T, class U>
inline bool chmin(T &a, const U &b) {
    return b < a && (a = b, true);
}
constexpr int INF = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;

template <class T>
inline vector<T> makeV(const T &initValue, size_t sz) {
    return vector<T>(sz, initValue);
}

template <class T, class... Args>
inline auto makeV(const T &initValue, size_t sz, Args... args) {
    return vector<decltype(makeV<T>(initValue, args...))>(
        sz, makeV<T>(initValue, args...));
}

template <class T>
inline istream &operator>>(istream &is, vector<T> &vec) {
    for (auto &e : vec) is >> e;
    return is;
}

inline void read() {}

template <class Head, class... Tail>
inline void read(Head &head, Tail &... tail) {
    cin >> head;
    read(tail...);
}

inline void print() { cout << "\n"; }

template <class Head, class... Tail>
inline void print(Head &&head, Tail &&... tail) {
    cout << head;
    if (sizeof...(tail)) cout << ' ';
    print(forward<Tail>(tail)...);
}

template <class T>
inline ostream &operator<<(ostream &os, const vector<T> &vec) {
    static constexpr const char *delim[] = {" ", ""};
    for (const auto &e : vec) os << e << delim[&e == &vec.back()];
    return os;
}

template <class Container>
struct Rev {
    Container &x_;
    inline Rev(Container &x) : x_(x) {}
    inline auto begin() { return rbegin(x_); }
    inline auto end() { return rend(x_); }
};
// }}} End Header

enum class Hoge : int { xx };

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.setf(ios_base::fixed);
    cout.precision(12);

    var(i64, N, M, K);

    vector<i64> a(N), b(M);
    read(a);
    read(b);

    vector<i64> cumA{{0}}, cumB{{0}};
    partial_sum(all(a), back_inserter(cumA));
    partial_sum(all(b), back_inserter(cumB));

    dump(cumA);
    dump(cumB);

    int ans = 0;

    repc(n, 0, N) {
        const i64 rem = K - cumA[n];
        if (rem < 0) break;

        int ok = -1;
        int ng = M + 1;
        while (ng - ok > 1) {
            const int mid = (ok + ng) / 2;
            if (cumB[mid] <= rem) {
                ok = mid;
            } else {
                ng = mid;
            }
        }

        chmax(ans, n + ok);
    }

    print(ans);

    return 0;
}


Measured memory_bytes: 11076
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = ll(1e12);
const ll mod = ll(1e9+7);
const double pi = acos(-1);
#define rep0(i,n) for(ll (i) = 0; (i) < (n); ++(i))
#define rrep0(i,n) for(ll (i) = (n) - 1; (i) >= 0; --(i))
#define rep1(i,n) for(ll (i) = 1; (i) <= (n); ++(i))
#define rrep1(i,n) for(ll (i) = (n); (i) >= 1; --(i))
#define nfor(i,a,b) for(ll (i) = (a); (i) < (b); ++(i))
#define pf(x) cout << (x) << endl
#define all(x) (x).begin(),(x).end()
#define yes pf("Yes")
#define no pf("No")
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
int dx[8]={1,0,-1,0,1,1,-1,-1};
int dy[8]={0,1,0,-1,1,-1,1,-1};

ll gcd(ll a,ll b){
    if(a < b)swap(a, b);
    if(b == 0) return a;
    return gcd(b,a%b);
}

ll lcm(ll a,ll b){
    ll g = gcd(a,b);
    return a / g * b;
}

ll factorial(ll n){
    ll ans = 1;
    rep1(i, n){
        ans *= i;
        ans %= mod;
    }
    return ans;
}

ll power(ll a, ll b){
    ll ans = 1;
    a %= mod;
    while(b) {
        if(b & 1LL) ans = ans * a % mod;
        a = a * a % mod;
        b >>= 1;
    }
    return ans % mod;
}

//modの値の確認をすること
int main(){
    string s;
    cin >> s;
    ll k = 1,a = 0;
    vector<ll> c(2019,0);
    ++c[0];
    rrep0(i, s.size()){
        a += (s[i] - '0') * k % 2019;
        k *= 10;
        k %= 2019;
        a %= 2019;
        ++c[a];
    }
    ll ans = 0;
    rep0(i, c.size())ans += c[i] * (c[i] - 1) / 2;
    pf(ans);
    return 0;
}


Measured memory_bytes: 3676
#include <stdio.h>
int main(void){
    int n,l;
    scanf("%d%d",&n,&l);
    int a=l,b=l+n-1;
    if(b<=0) printf("%d",(b+a)*(b-a+1)/2-b);
    else if(a>=0) printf("%d",(b+a)*(b-a+1)/2-a);
    else printf("%d",(b+a)*(b-a+1)/2);
    return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
#define endl '\n'
#define PI 3.14159265358979323844
#define DECIMAL(n)  std::cout << std::fixed;std::cout << std::setprecision(n);
#define mp make_pair
#define pb push_back
#define int long long int 
#define forr(i,a,b) for (int i= a; i <b; ++i)
    using namespace std; 

    
    signed main(){
     int n;cin>>n;
     int k;cin>>k;
     int a[n+1];
     forr(i,0,n)cin>>a[i];
    int dp[n+1]{0};
    dp[1]=abs(a[1]-a[0]);
    
    forr(i,2,n){
        int ans=INT_MAX;
        forr(j,1,k+1){
            if(i>=j){ ans=min(ans, dp[i-j]  +abs(a[i-j]-a[i])  );}
        }dp[i]=ans;
    }cout<<dp[n-1];}
      
        
        
        
       

Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <array>
#include <queue>
#include <stack>
#include <set>
#include <list>
#include <utility>
using namespace std;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  long long int N, i; cin >> N >> i;
  cout << N-i+1 << endl;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		long D = sc.nextLong();
		int cnt = 0;
		for (int i = 0; i < N; i++) {
			long x = sc.nextLong();
			long y = sc.nextLong();
			if (D >= Math.sqrt(x * x + y * y)) {
				cnt++;
			}
		}
		System.out.println(cnt);
		sc.close();
	}
}


Measured memory_bytes: 60744
#include "bits/stdc++.h"

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
constexpr double EPS = 1e-12;
constexpr int INF = numeric_limits<int>::max()/2;
constexpr int MOD = 1e9+7;

vector<ll> dp(111111,INF);

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

    dp[0]=0;
    ll n;cin>>n;
    vector<ll> v;
    ll p=1;
    while(p<=n){
        v.push_back(p);
        p *= 6;
    }
    p=9;
    while(p<=n){
        v.push_back(p);
        p *= 9;
    }
    sort(v.begin(),v.end());
    for(int i=0;i<(int)v.size();i++){
        for(int j=v[i];j<=n;j++){
            dp[j]=min(dp[j],dp[j-v[i]]+1);
        }
    }
    cout<<dp[n]<<endl;
}


Measured memory_bytes: 1152
#include <iostream>
#include <math.h>

int is_prime(int n) {
	if (n <= 1) {
		return 0;
	}

	if (n == 2 || n == 3) {
		return 1;
	}

	if (0 == n % 2) {
		return 0;
	}

	int range = (int)sqrt(n);
	for (int i = 3; i <= range; i += 2) {
		if (0 == n % i) {
			return 0;
		}
	}

	return 1;
}

int solve_prime(int num) {
	int i;

	std::cout << num << ":";

	if (is_prime(num) == 1) {
		std::cout << " " << num;
	}
	else {
		while (num % 2 == 0) {
			std::cout << " 2";
			num /= 2;
		}
		for (i = 3; i <= num; i++) {
			while (num % i == 0) {
				std::cout << " " << i;
				num /= i;
			}
		}
	}
	std::cout << std::endl;
	return 0;
}

int main() {
	int num;
	std::cin >> num;

	solve_prime(num);

	return 0;
}


Measured memory_bytes: 3112
import java.util.*;
class Main{
	
    public static void main(String args[]){
    	Scanner sc=new Scanner(System.in);
    	int a=sc.nextInt();
    	int b=sc.nextInt();
    	int c=sc.nextInt();
    	int d=sc.nextInt();
    	System.out.println(a+b>c+d?"Left":a+b==c+d?"Balanced":"Right");
    }
}

Measured memory_bytes: 23636
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, A;

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

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

int main() {
  int A, B;
  cin >> A >> B;
  
  int ans = 0;
  for (int i = 0; i < 2; i++) {
    if (A > B) {
      ans += A;
      A--;
    } else {
      ans += B;
      B--;
    }
  }
  cout << ans << endl;
  return 0;
}

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

int main(void) {
  int i, ans;
  char s[100010];
  scanf("%s", s);
  ans = strlen(s);
  for(i = 0; i < strlen(s) - 1; ++i) if(s[i] != s[i + 1]) {
    int t = i + 1 > strlen(s) - i - 1 ? i + 1 : strlen(s) - i - 1;
    ans = ans < t ? ans : t;
  }
  printf("%d", ans);
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<math.h>
using namespace std;
int prime(int n)
{
	int i;
	double t;
	if (n % 2 != 0 || n == 2)
	{
		if (n == 2)
			return 1;
		else
		{
			t = sqrt(n); 
			for (i = 3; i <= t; i += 2)
				if (n%i == 0)
					break;
			if (i > t)
				return 1;
			else
				return 0;
		}
	}
	else
	{
		return 0;
	}
}
int main()
{
	int n;
	cin >> n;
	int a, count = 0;
	for (int i = 0; i < n; i++)
	{
		cin >> a;
		if (prime(a) == 1)
		{
			count++;
		}
	}
	cout << count << endl;
	return 0;
}


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

using namespace std;

char sd[10010];
int nxt[10010],now[26],st[26];
int main()
{
	scanf("%s",sd+1);
	for(int i=1;i<=strlen(sd+1);i++)
	{
		if(now[sd[i]-'a']==0) st[sd[i]-'a']=i,now[sd[i]-'a']=i;
		else nxt[now[sd[i]-'a']]=i,now[sd[i]-'a']=i;
	}
//	for(int i=1;i<=strlen(sd+1);i++) printf("%d ",nxt[i]); printf("\n");
//	for(int i=0;i<26;i++) printf("%d ",st[i]); printf("\n");
	int Ans=10000;
	for(int i=0;i<26;i++)
	{
		int ret=st[i]-1,nw=st[i];
		if(st[i]==0) continue;
		while(1)
		{
			//cout << nw << endl;
			if(nxt[nw]==0)
			{
				ret=max(ret,(int)strlen(sd+1)-nw);
				break;
			}
			ret=max(ret,nxt[nw]-nw-1);
			nw=nxt[nw];
		}
		Ans=min(Ans,ret);
	}
	cout << Ans << endl;
	return 0; 
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<set>
#include<map>
#include<algorithm>
#include<cmath>
#include<queue>
#include<map>
using namespace std;
 
typedef long long ll;
 
 
int main(){
	int n;
	cin >> n;
	vector<int> data(n);
	ll sums[1001];
	for(int i=0;i<1001;++i) sums[i] = 0;
	
	for(int i=0;i<n;++i){
		cin >> data[i];
		sums[data[i]]++;
	}
	for(int i=1;i<1001;++i){
		sums[i] += sums[i-1];
	}
	
	
	
	ll res = 0;
	for(int i=0;i<n;++i){
		for(int j=i+1;j<n;++j){
			int index = min(data[i]+data[j]-1,1000);
//			int tmp = sums[index];
			int index2 = max(0,data[i]-data[j]);
			int index3 = max(0,-data[i]+data[j]);
			int ind = max(index2,index3);
//			cout <<data[i]<<" " <<data[j] << " " << ind << " " << index <<endl;
			
//			cout << sums[index]<< " " << (n- sums[ind]) << " "<<n << " " <<sums[ind]<<endl;
//			cout <<"--" <<  ind << " " << index <<endl;
//			cout << (n- sums[ind]) << " " << sums[index] <<endl;
			//int tmp = min(sums[index],(n- sums[ind]));
			int tmp = n - (n- sums[index] + n- (n- sums[ind]));
//			cout << tmp <<endl;
//			if(sums[index] - (n- sums[ind]) >= 0){
				res += tmp;
				if(ind < data[i] &&data[i] <=  index+1) res--;
				if(ind < data[j] &&data[j] <=  index+1) res--;
//			}
//			cout<< "_res " << res <<endl;
		}
	}
/*	
	for(int i=0;i<10;++i){
		cout << sums[i] <<" ";
	}cout <<endl;
*/	
	cout << res/3 <<endl;
	return 0;
}



Measured memory_bytes: 256
#include<iostream>

int a[20],n,res;

int main(){

    std::cin>>n;

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

    for(int i=1;i<n-1;i++){
        if((a[i-1]<a[i]&&a[i]<a[i+1])||a[i-1]>a[i]&&a[i]>a[i+1])
        res++;
    }

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

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



int main() {
    int n, m;
    cin >> n >> m;
    
    priority_queue<int,vector<int>,greater<int>> pq;
    rep(i,n) {
        int a;
        cin >> a;
        pq.push(a);
    }
    
    vector<P> cb(m);
    rep(i,m) cin >> cb[i].second >> cb[i].first;
    
    sort(cb.rbegin(),cb.rend());
    
    rep(i,m) {
        while(pq.top() < cb[i].first && cb[i].second > 0) {
            pq.pop();
            pq.push(cb[i].first);
            cb[i].second--;
        }
    }
    
    ll ans = 0;
    rep(i,n) {
        ans += pq.top();
        pq.pop();
    }
    
    cout << ans << endl;
    
    
    return 0;
}


Measured memory_bytes: 4584
#include<stdio.h>
int main(void){
  int k,dif,n=0,l=0,ans=0;
  char s[2001],p[1001];
  for(k=1;k<=2000;k++) s[k]='0'; //??????????????????0??§?????????
  for(k=1;k<=1000;k++) p[k]='0'; //p???????????£?????????????????????????????????????????????
  for(k=1;k<=1000;k++){
    scanf("%c",&s[k]);
    s[k+1000]=s[k];
    if(s[k]=='\n') break;
    n++; //s[k]??????n???????????????????´????????????¨??????????????????
  }
  for(k=1;k<=n+1;k++){
    scanf("%c",&p[k]);
    if(p[k]=='\n') break;
    l++;
  }
  for(k=1;k<=n;k++){
    if(p[1]==s[k]){
      for(dif=0;dif<=l-1;dif++){
        if(p[1+dif]==s[k+dif]){
          ans = 1;
        }else{
          ans = 0;
          break;
        }
      }
      if(ans == 1) break;// Yes?????????
      for(dif=0;dif<=n-k;dif++){
        if(p[1+dif]==s[k+dif]){
          ans = 2; //?¬¬?????????????????¢
        }else{
          ans = 0;
          break;
        }
      }
      if(ans == 2){
        for(dif=0;dif<=l-n+k-2;dif++){
          if(p[n-k+2+dif]==s[1001+dif]){
            ans = 1;
          }else{
            ans = 0;
            break;
          }
        }
      }
      if(ans == 1) break;
    }
  }
  if(ans == 1) printf("Yes\n");
  else printf("No\n");
  return 0;
}

Measured memory_bytes: 524
#include"bits/stdc++.h"

using namespace std; 

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef vector<PII> VPII;
typedef long long LL;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef pair<LL, LL> PLL;
typedef vector<PLL> VPLL;
typedef priority_queue<LL> PQ_DESC;
typedef priority_queue<LL, VL, greater<LL>> PQ_ASC;
typedef priority_queue<PII> PQ_DESC_PII;
typedef priority_queue<PII, vector<PII>, greater<PII>> PQ_ASC_PII;
typedef priority_queue<VL> PQ_DESC_VL;
typedef priority_queue<VL, vector<VL>, greater<VL>> PQ_ASC_VL;
typedef priority_queue<PLL> PQ_DESC_PLL;
typedef priority_queue<PLL, vector<PLL>, greater<PLL>> PQ_ASC_PLL;

#define ALL(c) (c).begin(),(c).end()
#define PB push_back
#define MP make_pair
#define SORT_ASC(c) sort(ALL(c))
//#define SORT_DESC(c) sort(ALL(c), greater<typeof(*((c).begin()))>())
#define SORT_DESC(c) sort((c).rbegin(),(c).rend())
#define REV(c) reverse((c).begin(), (c).end())
#define SIZE(a) int((a).size())

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ROF(i,a,b) for(int i=(b-1);i>=(a);--i)
#define REP(i,n) FOR(i,0,n)
#define PER(i,n) ROF(i,0,n)

const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int LARGE_INT = 1e9+100;
const int INF = 2e9+100;
const LL INF_LL = (LL)INF*(LL)INF;
const int MOD = 1e9+7;

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

LL modpow(LL a, LL n) {
    LL res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % MOD;
        a = a * a % MOD;
        n >>= 1;
    }
    return res;
}

void Main()
{
    LL d,n;cin>>d>>n;
    if(n==100){
        n++;
    }
    cout<<n*(LL)(pow(100,d))<<endl;
    
	return;
}

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

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

int main()
{

  ios::sync_with_stdio(0);
  cin.tie(0);
  int n,x,t;
  cin>>n>>x>>t;
  if(n%x==0){n=n/x;}
  else{n=n/x+1;}
  cout<<n*t;

  return 0;
}

Measured memory_bytes: 3636
/*input
3 3
2 1 3
2 1 3
2 1 3
*/

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

int n, m, a[N][N];
int mn[N], cnt[N];
bool del[N];
int solve() {
	int ans = n;
	for (int rmv = 1; rmv <= m; rmv++) {
		memset(mn, 0, sizeof(mn));
		memset(cnt, 0, sizeof(cnt));
		for (int i = 1; i <= n; i++) {
			for (int j = 1; j <= m; j++) 
				if (!del[j] && (!mn[i] || a[i][j] < a[i][mn[i]])) mn[i] = j;
			cnt[mn[i]]++;
		}
		int mx = max_element(cnt + 1, cnt + m + 1) - cnt;
		del[mx] = true;
		ans = min(ans, cnt[mx]);
	}
	return ans;
}
int main() {
	scanf("%d %d", &n, &m);
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= m; j++) {
			int x; scanf("%d", &x);
			a[i][x] = j;
		}
	}
	printf("%d\n", solve());
}

Measured memory_bytes: 640
num = int(input())
for i in range(1, num + 1):
    if i % 3 == 0:
        print(f' {i}', end='')
        continue
    x = i
    while True:
        if x % 10 == 3:
            print(f' {i}', end='')
            break
        x = int(x / 10)
        if x < 1:
            break
print()


Measured memory_bytes: 5880
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#define rep(i,l,r)for(int i=(l);i<(r);i++)

int c(const void*s,const void*t){return strcmp(s,t);}
char s[1010][40];
char t[40];
int f[1010];

int ans[1010],cnt;
int main(){
	int n,len;
	scanf("%d%d",&n,&len);
	rep(i,0,n)scanf(" %s",s[i]);
	qsort(s,n,40,c);
	
	rep(i,0,n)if(!f[i]){
		rep(j,0,len)t[j]=s[i][len-1-j];
		rep(j,i+1,n)if(!f[j]&&!strcmp(t,s[j])){
			ans[cnt++]=i;
			f[i]=f[j]=1;
			break;
		}
	}
	int flag=0;
	rep(i,0,n)if(!f[i]){
		rep(j,0,len)t[j]=s[i][len-1-j];
		if(!strcmp(s[i],t)){
			ans[cnt++]=i;
			flag=1;
			break;
		}
	}
	
	rep(i,0,cnt)printf("%s",s[ans[i]]);
	for(int i=cnt-1-flag;i>=0;i--)rep(j,0,len)putchar(s[ans[i]][len-1-j]);
	puts("");
}


Measured memory_bytes: 2148
#include<iostream>
#include<vector>
#include <algorithm>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
int main() {
    ll n, m;
    double sum = 0;
    cin >> n >> m;
    ll a[n];
    rep(i, n) cin >> a[i];
    rep(i, n) sum += a[i];
    sort(a, a + n);
    double border = sum / (4 * m);
    if (a[n - m] < border) {
        cout << "No" << endl;
    } else {
        cout << "Yes" << endl;
    }
}


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




int main(){
  int N,T,A;
  cin >> N;
  cin >> T >> A;
  vector<int> H(N);
  for(int i=0;i<N;i++){
    cin >> H.at(i) ;
  }

  for(int i=0;i<N;i++){
    H.at(i) = abs(A-(T-H.at(i)*0.006))*1000;
  }

  vector<int>::iterator minIt = min_element(H.begin(),H.end());
  size_t minIndex = distance(H.begin(),minIt);

  cout << minIndex+1 << endl;
  

}

Measured memory_bytes: 256
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
using namespace std;
using LL = long long;
constexpr long long MOD = 1000000000 + 7;
constexpr long long INF = 1000000000;
const double PI = acos(-1);

int main() {
	double t1, t2;
	while (cin >> t1 >> t2) {
		int a1, a2;
		if (t1 < 35.5)a1 = 1;
		else if (t1 < 37.5)a1 = 2;
		else if (t1 < 40.0)a1 = 3;
		else if (t1 < 43.0)a1 = 4;
		else if (t1 < 50.0)a1 = 5;
		else if (t1 < 55.0)a1 = 6;
		else if (t1 < 70.0)a1 = 7;
		else a1 = 8;

		if (t2 < 71)a2 = 1;
		else if (t2 < 77)a2 = 2;
		else if (t2 < 83)a2 = 3;
		else if (t2 < 89)a2 = 4;
		else if (t2 < 105)a2 = 5;
		else if (t2 < 116)a2 = 6;
		else if (t2 < 148)a2 = 7;
		else a2 = 8;
		string ans[9] = { " ","AAA","AA","A","B","C","D","E","NA" };
		cout << ans[max(a1, a2)] << endl;
	}
}

Measured memory_bytes: 3180
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxx = 2e5 + 7;
const int Inf = 1 << 30;
const ll INF = 1ll << 30;
int a, b, c;

int main() {
	scanf("%d %d %d", &a, &b, &c);
	bool flg = 0;
	if(a == b && a != c) flg = 1;
	else if(a == c && a != b) flg = 1;
	else if(b == c && b != a) flg = 1;
	if(flg) puts("Yes");
	else puts("No");
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<cstdlib>
#include<algorithm>
#include<vector>
#include<map>
#include<cmath>
#include<string>

#define rep(i,p) for(int i=1;i<=p;i++)
#define ll long long

using namespace std;

int main(){

	char A;
	cin >> A;
	string B;
	B[0] = A+1;
	cout << (B[0]);










	return 0;

}



Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<stdlib.h>
#include<iomanip>
#include<string>
#include<math.h>

#define MOD 1000000007

using namespace std;
 
int main(){
    int n,m;
    int sum;
    cin>>n>>m;
    sum=1900*m+(n-m)*100;
    cout<<sum*pow(2,m)<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
  int y1, m1, d1, y2, m2, d2, ans;
  scanf("%d%d%d%d%d%d", &y1, &m1, &d1, &y2, &m2, &d2);
  if(y1 > y2) {
    int t;
    t = y1, y1 = y2, y2 = t;
    t = m1, m1 = m2, m2 = t;
    t = d1, d1 = d2, d2 = t;
  }
  if(y1 != y2) {
    ans = y2 - y1;
    if(m1 < m2) printf("%d\n", ans + 1);
    else if(m1 > m2) printf("%d\n", ans);
    else {
     if(d1 < d2) printf("%d\n", ans + 1);
     else printf("%d\n", ans);
    }
  } else {
    if(m1 == m2 && d1 == d2) printf("0\n");
    else printf("1\n");
  }
  return 0;
}


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

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	vector<long long> ans;
	long long x = 0;
	do {
		++ x;
		int a[15], c = 0;
		long long t = x, f = 0;
		while(t) {
			a[c ++] = t % 10;
			f += t % 10;
			t /= 10;
		}
		for(int i = 0; i <= c; ++ i) {
			long long v = 0, sv = 0;
			for(int j = c - 1; j >= 0; -- j) {
				if(j < i) v = v * 10 + 9, sv += 9;
				else v = v * 10 + a[j], sv += a[j];
			}
			if(x * sv > f * v) {
				x = v; f = sv;
			}
		}
		ans.push_back(x);
	} while(x < (long long)1e15 - 1);
	int k; cin >> k;
	for(int i = 0; i < k; ++ i) cout << ans[i] << "\n";
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <stdint.h>
#include <vector>
#include <string>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <string>
#include <math.h>
#include <time.h>
#include <algorithm>
#include <deque>

using namespace::std;

int ri()
{
	int x;
	scanf("%d", &x);

	return x;
}

int64_t ri64()
{
	int64_t x;
	scanf("%lld", &x);

	return x;
}

void wi(int x)
{
	printf("%d\n", x);
}

void wvi(vector<int> &v)
{
	for (int i = 0; i < v.size(); i++)
		printf("%d ", v[i]);
	printf("\n");
}

void dbg(string &str, int x)
{
	cout << str << ": ";
	wi(x);
}

void dbg(string &str, vector<int> &x)
{
	cout << str << ": ";
	wvi(x);
}

int main()
{
        long double pi = 4.0 * atanl(1.0);
        
        long double R;
        cin >> R;

        long double ans = 2.0 * pi * R;
        printf("%.2f\n", (double) ans);

	return 0;
}


Measured memory_bytes: 3776
fun main(args: Array<String>) {
    val s = readLine()!!
    val t = readLine()!!

    val flag = (0 until s.length).map{i ->
        s.substring((s.length-1-i)..(s.length-1)) + s.substring(0..s.length-2-i)
    }.any{it == t}

    println(if (flag) "Yes" else "No")
}

Measured memory_bytes: 33720
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include <string.h>
#include <limits.h>
#include <math.h>
#include <time.h>
#include <queue>
#include <stdarg.h>
#include <map>
#include <vector>
#include <algorithm>
#include <stack>
#include <iostream>
#include <numeric>
#include <set>

#define ll long long

using namespace std;

ll 
gcd(ll a, ll b) {
  if (b < a)
    return gcd(b, a);

  if (a == 0)
    return b;

  return gcd(b % a, a);
}

void
solve() {
  ll a, b;
  cin>>a>>b;

  cout<<a*b/gcd(a, b)<<endl;
}

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

  int t = 1;
  //cin>>t;

  while (t > 0) {
    t--;
    solve();
  }

  return 0;
}



Measured memory_bytes: 256
N=gets.to_i
a=gets.split.map(&:to_i)
dp=[]
dp[0]=0
dp[1]=(a[0]-a[1]).abs
for i in 2..N-1
    b=dp[i-2]+(a[i-2]-a[i]).abs
    c=dp[i-1]+(a[i-1]-a[i]).abs
    dp[i]=b > c ? c : b
end
puts dp[N-1]

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

using namespace std;

int32_t main() {
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	
	int n, m;
	cin >> n >> m;
	cout << (n * (n - 1) / 2) + (m * (m - 1) / 2);

	return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
int main()
{
  int n,k;
  scanf("%d%d", &n,&k);
  
  vector<int> s(n);
  for(int &it : s)scanf("%d",&it);
  bool res[k+1];
  memset(res,0,k+1);
  for(int i = 0; i <= k; i++)
  {
    for(int j : s)
    {
      if(i >= j && !res[i-j])
        res[i] = true;
    }
  }
  
  res[k]?puts("First"):puts("Second");
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
// #define int long long

#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(),(x).end()

#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define REPS(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREPS(i,x) for(int i=((int)(x));i>0;i--)

typedef pair<int, int> pint;

#define mp make_pair
#define mt make_tuple
#define pb push_back
#define pf push_front

#define MOD (1000 * 1000 * 1000 + 7)

signed main() {
    int N;
    cin >> N;

    int ans = 0;

    REPS(i, 9) {
        REPS(j, 9) {
            if (i * j == N) ans = 1;
        }
    }

    cout << ((ans == 1) ? "Yes" : "No") << endl;

    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<cstdlib>
#include<cstring>
using namespace std;
inline int read()
{
	int x=0,f=1;char ch=getchar();
	while(ch<'0' || ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0' && ch<='9')x=x*10+ch-'0',ch=getchar();
	return x*f;
}
int stack[20];
inline void write(int x)
{
	if(x<0){putchar('-');x=-x;}
	if(!x){putchar('0');return;}
	int top=0;
	while(x)stack[++top]=x%10,x/=10;
	while(top)putchar(stack[top--]+'0');
}
inline void pr1(int x){write(x),putchar(' ');}
inline void pr2(int x){write(x),puts("");}
int cnt[2010];
int main()
{
    //freopen("a.in","r",stdin);
    //freopen("a.out","w",stdout);
    int n=read(),x=read(),y=read();
    for(int i=1;i<n;i++)
    {
    	for(int j=i+1;j<=n;j++)
    	{
    		if(j<=x || i>=y)cnt[j-i]++;
    		else
    		{
    			if(i>=x && j<=y)cnt[min(j-i,y-x+1-(j-i))]++;
    			else
    			{
    				if(i<=x && j>=y)cnt[x-i+j-y+1]++;
    				else if(i<x)cnt[x-i+min(j-x,y-x+1-(j-x))]++;
    				else cnt[j-y+min(y-i,y-x+1-(y-i))]++;
    			}
    		}
    	}
    }
    for(int i=1;i<n;i++)pr2(cnt[i]);
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n; cin>>n;
  vector<int> v(n); for(int i=0;i<n;i++) cin>>v[i];
  sort(v. begin(),v.end());
  double a=v[0];
  for(int i=1;i<n;i++) a=(a+v[i])/2;
  printf("%.6lf",a);
}

Measured memory_bytes: 3760
#include<bits/stdc++.h>
using namespace std;
#define fraction() cout.unsetf(ios::floatfield); cout.precision(10); cout.setf(ios::fixed,ios::floatfield);
#define file() freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define faster() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const long long int infLL = 9000000000000000000;
#define mem(a,b) memset(a, b, sizeof(a) )
#define all(a) (a).begin(),(a).end()
#define mx_int_prime 999999937
const int inf = 2000000000;
const double PI = acos(-1);
const double eps = 1e-9;
typedef long double ld;
#define MOD 1000000007
typedef long long ll;
const int mx=2e5+125;
ll pr[mx],ar[mx],br[mx];
#define PB push_back
#define endl '\n'
#define S second
#define F first
int main()
{
    faster();
    int a,b,c;
    cin>>a>>b>>c;
    cout<<b*a*0.5<<endl;

    return 0;
}



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

#define rng(i, a, b) for (int i = int(a); i < int(b); i++)
#define rep(i, b) rng(i, 0, b)
#define gnr(i, a, b) for (int i = int(b) - 1; i >= int(a); i--)
#define per(i, b) gnr(i, 0, b)

using namespace std;

using ll = long long;
using P = pair<int, int>;

int main() {
  int n;
  cin >> n;
  ll res = 0;
  for (int a = 1; a < n; a++) {
    res += (n % a == 0) ? (n / a - 1) : (n / a);
  }
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
ll GetDigit(ll num){ return log10(num)+1; } //numの桁数を求める

int main()
{
    int k,x;
    cin >> k >> x;
    for (int i = x-k+1; i <= x+k-1; i++)
    {
        cout << i << " ";
    }
    cout << endl;
    
    return 0;
}

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

int main(){
  int n;
  ll k;
  cin >> n >> k;
  ll a[n];
  rep(i,n)cin >> a[i];
  ll ans = 0;
  for(int i=39;i>=0;i--){
    int n0 = 0;
    int n1 = 0;
    rep(j,n){
      if(a[j]>>i&1LL)n1++;
      else n0++;
    }
    if(n1<n0&&1LL<<i<=k){
      ans += n0*(1LL<<i);
      k -= 1LL<<i;
    }else{
      ans += n1*(1LL<<i);
    }
    //cout << n1 << " " << n0 << endl;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define fi first
#define se second
#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 srep(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 maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define eb emplace_back
#define all(c) begin(c),end(c)
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<T> vt;
//最大公約数
ll gcd(ll x, ll y) {
  return y ? gcd(y, x % y) : x;
}
//最小公倍数
ll lcm(ll x, ll y) {
  return x/gcd(x, y)*y;
}
//素因数分解
vector<pair<ll,int>> factorize(ll n) {
  vector<pair<ll,int>> res;
  for (ll i = 2; i*i <= n; ++i) {
    if (n%i) continue;
    res.emplace_back(i,0);
    while (n%i == 0) {
      n /= i;
      res.back().second++;
    }
  }
  if (n != 1) res.emplace_back(n,1);
  return res;
}
 
 
 ll mod=998244353;
 
int main() {
  int n;
  cin>>n;


  rep(i,n+1){
    int pay=1000*i;
    if(pay>=n){
      cout<<pay-n;
      break;
    }
  }



}



Measured memory_bytes: 3628