akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
#include <cstring>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define CLR(mat) memset(mat, 0, sizeof(mat))
typedef long long ll;
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll N; cin >> N;
  ll sum = 0;
  ll A[N], sa[N];
  FOR(i,0,N) {
    cin >> A[i];
    sum += A[i];
  }
  if(sum % (N * (N + 1) / 2) != 0) {
    cout << "NO" << endl;
    return 0;
  }
  ll x = sum / (N * (N + 1) / 2);
  FOR(i,0,N) {
    sa[i] = A[(i + 1) % N] - A[i];
  }
  ll ksum = 0;
  FOR(i,0,N) {
    if((x - sa[i]) % N != 0 || (x - sa[i]) < 0) {
      cout << "NO" << endl;
      return 0;
    }
    ksum += (x - sa[i]) / N;
  }
  if(x == ksum) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
  return 0;
}

Measured memory_bytes: 1792
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower

using namespace std;
int judge(vector<int> vec,int A){
    int sum=0,ret=0;
    double Pop;
    for(int i=0;i<vec.size();i++){
        sum+=vec.at(i);
    }
    Pop=(double)sum/A;
    for(int i=0;i<vec.size();i++){
        if(vec.at(i)>=Pop)ret++;
    }
    return ret;
}
int main(){
    int N,M,sum=0,ans;
    cin>>N>>M;
    vector<int> p(N);
    for(int i=0;i<N;i++){
        cin>>p.at(i);
    }
    ans=judge(p,4*M);
    if(ans>=M){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
  int n;
  scanf("%d", &n);
  int trump[4][13];
  for(int i = 0; i < 4; i++){
    for(int j = 0; j < 13; j++){
      trump[i][j] = 0;
    }
  }
  for(int i = 0; i < n; i++){
    char pic;
    int num;
    scanf("%*c%c %d", &pic, &num);
    if(pic == 'S') trump[0][num - 1] = 1;
    else if(pic == 'H') trump[1][num - 1] = 1;
    else if(pic == 'C') trump[2][num - 1] = 1;
    else trump[3][num - 1] = 1;
  }
  for(int i = 0; i < 4; i++){
    for(int j = 0; j < 13; j++){
      if(trump[i][j] == 0){
        if(i == 0) printf("S ");
        else if(i == 1) printf("H ");
        else if(i == 2) printf("C ");
        else printf("D ");
        printf("%d\n", j + 1);
      }
    }
  }
}



Measured memory_bytes: 2728
N = int(input())
for h in range(1,3501):
    for n in range(1,3501):
        t1 = 4 * h * n
        t2 = N * (h+n)
        if t1 != t2:
            temp = (N*h*n) / (t1-t2)
            if temp.is_integer():
                if temp > 0:
                    print(h,n,int(temp))
                    break
    else:
        continue
    break

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


int main()
{


	double a, b, x1, y1, x2, y2;
	cin >> a >> b;

	x1 = a/0.08;
	y1 = b/0.1;
	x2 = (a+1.0)/0.08;
	y2 = (b+1.0)/0.1;

	int minm = min(x1, y1);
	int maxm = max(x2, y2);

	for(int i=minm; i<maxm; i++)
	{
		if( floor(i*0.08) == a && floor(i*0.1) == b)
		{
			cout << i << "\n";
			return 0;
		}
	}

	cout << "-1\n";
	return 0;
}


Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
namespace AtCoder
{
    class Program
    {
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }

        //static long Mod = (long)1e9 + 7;
        static List<long>[] tree;
        static long[] query;
        static bool[] cmp;
        static void Main(string[] args)
        {
            //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
            var N = Sarray()[0];
            var ai = Sarray();
            var ball = new long[N + 1];
            for (var i = N; 1 <= i; --i)
            {
                var pre = 0L;
                for (var p = N / i; 1 < p; --p)
                    pre += ball[p * i];
                if (pre % 2 == ai[i - 1])
                    ball[i] = 0;
                else
                    ball[i] = 1;
            }
            WriteLine(ball.Count(b => b != 0));
            for (var i = 1; i <= N; ++i)
            {
                if (0 != ball[i])
                    Write($"{i} ");
            }
            //Out.Flush();
        }
    }
}


Measured memory_bytes: 32604
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--) 
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
#define downque(que) priority_queue<ll> que;
#define upque(que) priority_queue<ll, vector<int>, greater<int>> que;
typedef long long ll;
typedef vector<vector<int>> Matrix;
const int MOD = 1e9 + 7;
const int MAX = 1e7;
const int INF = numeric_limits<int>::max();

int main(){
int  n,m,res=0; cin>>n>>m; 


cout<<(n*(n-1))/2+(m*(m-1))/2<<endl;

}

Measured memory_bytes: 256
n,m,k=map(int,input().split())
mod=998244353

def prepare(m, mod=10 ** 9 + 7):
	fac = [1] * (m + 1)
	inv = [1] * (m + 1)
	for i in range(1, m + 1):
		fac[i] = fac[i - 1] * i % mod
	inv[-1] = pow(fac[-1], mod - 2, mod)
	for i in range(m - 1, -1, -1):
		inv[i] = inv[i + 1] * (i + 1) % mod
	return fac, inv

fac, inv = prepare(n,mod)

def cmb(n, r):
	assert n >= r >= 0
	return fac[n] * inv[n - r] * inv[r] % mod

subt=0
for x in range(k+1,n):
	subt+=cmb(n-1,x)*m%mod*pow(m-1,n-x-1,mod)%mod
	subt%=mod
print((pow(m,n,mod)+mod-subt)%mod)

Measured memory_bytes: 24712
#include<bits/stdc++.h>
#define FIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define PI 3.141592653589793238462643383279502884L
#define make_unique(vec) vec.resize(distance(vec.begin(),unique(vec.begin(),vec.end())))
#define Sort(vec) sort(vec.begin(),vec.end())
#define RSort(vec) sort(vec.rbegin(),vec.rend())
#define endl "\n"
#define tr1(i) cout<<i<<endl;
#define tr2(i,j) cout<<i<<" "<<j<<endl;
#define tr3(i,j,k) cout<<i<<" "<<j<<" "<<k<<endl;
#define vvi vector<vector<int> > 
#define vvl vector<vector<ll> >
#define all(st) st.begin(),st.end()
#define vpl vector<pair<ll,ll> >
#define vpi vector<pair<int,int> >
#define pi pair<int,int>
#define pl pair<ll,ll>
#define al vector<list<int> >
#define vs vector<string>
#define vi vector<int>
#define vb vector<bool>
#define vl vector<ll>
#define vc vector<char>
#define rep(i,l,r) for(int i=l;i<r;i++)
#define repit(st) for(auto it=st.begin();it!=st.end();it++)
#define ull unsigned long long int
#define eb emplace_back
#define pb push_back
#define ll long long int
#define minf -(1e18)
#define inf 1e18
#define f first
#define se second
#define mod 1000000007
using namespace std;
ll mi(ll n,ll m){ll pw=n%m;ll ex=m-2;ll ans=1;while(ex){if(ex&1) ans = ans*pw%m;pw = pw*pw%m;ex>>=1;}return ans%mod;}
ll pw(ll a,ll n){ll pw=a%mod;ll ex=n;ll ans=1;while(ex){if(ex&1) ans = ans*pw%mod;pw = pw*pw%mod;ex>>=1;}return ans%mod;}
template<typename T>istream &operator>>(istream &is, vector<T> &v) { for (T &t : v) is >> t; return is; }
template<typename T>ostream &operator<<(ostream &os, const vector<T> &v) { for (const T &t : v) {os << t <<" ";} os << '\n'; return os; }
void show(ll x){cout<<x<<" ";}
ll gcd(ll a,ll b){return b==0?a:gcd(b,a%b);}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
ll max(ll a,ll b){return a>b?a:b;}
ll min(ll a,ll b){return a<b?a:b;}
ll Abs(ll x){return x>0?x:(-x);}
ll Ceil(ll a,ll b){return a/b+(a%b!=0);}
#define bs binary_search
#define lb lower_bound
#define mkp make_pair
//#define d double
void solve(){
	int x,y;
	cin>>x>>y;
	const int mxm=2e6+1;
	vl fac(mxm,1);
	for(ll i=2;i<mxm;i++) fac[i]=fac[i-1]*i%mod,fac[i]%=mod;;
	if((2*x-y>=0) && (2*x-y)%3==0 && (2*y-x>=0) && (2*y-x)%3==0){
		ll a=(2*x-y)/3;
		ll b=(2*y-x)/3;
		ll ans=(fac[a+b]*mi(fac[a],mod)%mod)*mi(fac[b],mod)%mod;
		ans%=mod;
		cout<<ans;
	}
	else cout<<"0";
 
 
 
 
 
}
int32_t main(){
FIO;
int t=1;
//cin>>t;
while(t--){
	solve();
}
}

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

using namespace std;
using ll = long long;


int n, m;
int A[1000000];

void solve()
{
    int sum =0;
    for(int i = 0; i < m; i++){
        sum += A[i];
    }
    if(sum <= n) cout << n - sum << endl;
    else puts("-1");
}

int main()
{
    cin >> n >> m;
    for(int i = 0; i < m; i++) cin >> A[i];
    solve();
    

    return EXIT_SUCCESS;
}

Measured memory_bytes: 3636
// Sheep and Wolves.cpp : This file contains the 'main' function. Program execution begins and ends there.
//

#include <iostream>
using namespace std;
int main()
{
    int sheep; int wolves; 
    cin >> sheep >> wolves; 
    if (sheep <= wolves)

    {
        cout << "unsafe";
    }

    else
    {
        cout << "safe";
    }

}

// Run program: Ctrl + F5 or Debug > Start Without Debugging menu
// Debug program: F5 or Debug > Start Debugging menu

// Tips for Getting Started: 
//   1. Use the Solution Explorer window to add/manage files
//   2. Use the Team Explorer window to connect to source control
//   3. Use the Output window to see build output and other messages
//   4. Use the Error List window to view errors
//   5. Go to Project > Add New Item to create new code files, or Project > Add Existing Item to add existing code files to the project
//   6. In the future, to open this project again, go to File > Open > Project and select the .sln file


Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,(n)-1,0)
#define all(v) v.begin(), v.end()
#define endk '\n'
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;
const ld eps = 1e-10;
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b){if(a>b) a=b;}
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b){if(a<b) a=b;}

ll gcd(ll x, ll y) {
  if(x > y)
    return gcd(y, x);
  else if(x == 0)
    return y;
  else
    return gcd(y % x, x);
}
ll lcm(ll x, ll y) {
  ll g = gcd(x, y);
  return g * (x / g) * (y / g);
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int x; cin >> x;
  cout << lcm(x, 360)/x << endk;
  return 0;
}


Measured memory_bytes: 3660
from functools import reduce


def product(a, b):
    return a*b % (10**9+7)


N = int(input())
S = input()
count = 0
alpha = [1] * 26
left = 0
for s in S:
    #print(ord(s) - ord("a"), s)
    alpha[ord(s) - ord("a")] += 1
ans = reduce(product, alpha)
print(ans - 1)


"""
for i in range(len(S)):
    if alpha[ord(S[i]) - ord("a")] == -1:
        alpha[ord(S[i]) - ord("a")] == i
        continue
    else:
        count += sum_(i-left)
        count %= 10**9+7
        # 書き換える
        left = alpha[ord(S[i]) - ord("a")] + 1
        alpha[ord(S[i]) - ord("a")] = i
count += sum_((N - 1)-left)
count %= 10**9+7
print(count)
"""


Measured memory_bytes: 3940
s = input()[::-1]
#sは文字列 逆向きにしている
sum_of_digits = 0
 
cnts = [0] * 2019
 
cnts[0] = 1
 
d = 1
 
for c in s:
    sum_of_digits += int(c) * d
    sum_of_digits %= 2019
    d *= 10         #dを１０倍
    d %= 2019       #dを2019で割る（2019は10と素なので意味はないかも）
    cnts[sum_of_digits] += 1
    #cntは2019個ある　modの値が同じごとに個数を計算して足したもの
 
ans = 0
    
for cnt in cnts:
    ans += cnt * (cnt - 1) // 2  
                    #cnt conbination 2
                    #mod ごとに m(m − 1)/2
        
#(i, j)が条件をみたすのはTi−1 == Tj (mod2019)のとき
#Ti−1 - Tj == 0 (mod2019) と等価 Ti−1 == Tj (mod2019)
 
print(ans)

Measured memory_bytes: 9260
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define sqr(x) ((x)*(x))
#define mp make_pair
#define uint unsigned
inline char gc(){
    static char buf[100000],*p1=buf,*p2=buf;
    return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
}
#define gc getchar
inline int read(){
	int x = 0; char ch = gc(); bool positive = 1;
	for (; !isdigit(ch); ch = gc())	if (ch == '-')	positive = 0;
	for (; isdigit(ch); ch = gc())	x = x * 10 + ch - '0';
	return positive ? x : -x;
}
inline void write(int a){
    if(a>=10)write(a/10);
    putchar('0'+a%10);
}
inline void writeln(int a){
    if(a<0){
    	a=-a; putchar('-');
	}
	write(a); puts("");
}
int main(){
	int q=read();
	while(q--){
		int a=read(),b=read();
		if(a>b)swap(a,b);
		ll pro=(ll)a*b-1;
		int l=0,r=b-1;
		while(l<r){
			int mid=(l+r)>>1; mid++;
			//cout<<(long double)pro/mid-(long double)pro/(mid+1)<<endl;
			if(pro<(ll)mid*(mid+1))r=mid-1; else l=mid;
		}
		writeln(a-1+l+max((ll)0,pro/(l+1)-a));
	}
}
/*
8
1 4
10 5
3 3
4 11
8 9
22 40
8 36
314159265 358979323
pro*(mid+1)-pro*mid<mid*(mid+1)
1
1 4
*/

Measured memory_bytes: 256
#include<stdio.h>

int main(void){
  unsigned long long int N,K;
  unsigned long long int x;
  
  scanf("%lld %lld",&N,&K);
  
  N = N % K;
  x = K - N;
  
  if(x<N){
    N = x;
  }
  
  printf("%lld",N);
  return 0;
}

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


const int N = 3005;



string s, t, ans;
int n, m, dp[N][N], p[N][N];

void rec(int n, int m){
    if(p[n][m] == 3){
        rec(n - 1, m - 1);
        cout << s[n];
    }
    else if(p[n][m] == 1){
        rec(n - 1, m);
    }
    else if(p[n][m] == 2){
        rec(n, m - 1);
    }
    else{
        return;
    }
}

int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    cin >> s >> t;
    n = (int)s.size();
    m = (int)t.size();
    s = '#' + s;
    t = '#' + t;
    for(int i = 1; i <= n; i++){
        for(int j = 1; j <= m; j++){
            if(s[i] == t[j]){
                dp[i][j] = dp[i - 1][j - 1] + 1;
                p[i][j] = 3;
            }
            else{
                if(dp[i - 1][j] > dp[i][j - 1]){
                    dp[i][j] = dp[i - 1][j];
                    p[i][j] = 1;
                }
                else{
                    dp[i][j] = dp[i][j - 1];
                    p[i][j] = 2;
                }
            }
        }
    }
    rec(n, m);
}


Measured memory_bytes: 70912
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
from bisect import bisect_left, bisect
from heapq import heappush, heappop

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N, A = MAP()

x = LIST()

sum_x = sum(x)
dp = [[0]*(sum_x+1) for _ in range(N+1)]
dp[0][0] = 1
for i in range(N):
	for j in range(N-1, -1, -1):
		for k in range(sum_x+1):
			if k-x[i] >= 0 and dp[j][k-x[i]]:
				dp[j+1][k] += dp[j][k-x[i]]

ans = 0
for i in range(1, N+1):
	if A*i <= sum_x:
		# print("{}こで総和が{}になる通り:{}".format(i, A*i, dp[i][A*i]))
		ans += dp[i][A*i]
print(ans)


Measured memory_bytes: 6216
$N=<>;/ /,push@{$`},$' for<>;map$q[$_]+=$q[$i]/@$i,@{$i=$_}for++$q[1]..$N;while(--$N){$s=$~=0;$s+=$_,$~=$_>$~?$_:$~for@e[@$N];$e[$N]=1+$s/@$N;$a<($t=$q[$N]*=$#$N&&($s-$~)/$#$N-$s/@$N)or$a=$t}print"@e"+$a

Measured memory_bytes: 42368
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include <iostream>
#include <fstream>

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

typedef long long ll;
#define tr(container, it) \
        for (auto it = container.begin(); it != container.end(); it++)
#define scontains(c, x) ((c).find(x) != (c).end())   //O(log n)
#define contains(c, x) (find((c).begin(),(c).end(),x) != (c).end()) //O(n)
#define pll pair<ll,ll>
#define pii pair<int,int>
#define mll map<ll,ll>
#define intv(x, a, b)((x)>=a && (x)<=b)
#define  rep(i, _begin, _end) for (__typeof(_end) end = _end, begin = _begin,  i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define  _for(i, end) for (__typeof(end) i = 0, _len = (end); i < (_len); i += 1)
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define F first
#define S second
#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
#define next asdnext
#define prev asdprev
#define what_is(x) cerr << #x << " is " << x << endl;
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
#define mod(x, m) ((((x) % (m)) + (m)) % (m))
#define bit(n) (1LL<<(n))
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define readint ({int t;cin >> t;t;})
const double PI = 2 * acos(.0);
const int INF = 0x3f3f3f3f;
const ll LLINF = 1000000000000000005LL;;
const ll MOD = (ll) (1e9) + 7;
void _mod(ll &x){x = mod(x, MOD);}
//const ll MOD = (ll) 998244353 ;
const double EPS = 1e-10;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
    std::fill((T *) array, (T *) (array + N), val);
}


//#define int ll
ll L, R;
class CRemainderMinimization2019 {
public:

void solve(std::istream& cin, std::ostream& cout) {
    cin >> L >> R;
    if(L/2019 != R/2019)cout << 0 << endl;
    else {
        ll mi = 2022;
        rep(i,L,R)rep(j,i+1,R+1)mi = min(mi, i*j%2019);
        cout <<mi << endl;
    }
}


};


#undef int
int main() {
	CRemainderMinimization2019 solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	in.tie(0); ios::sync_with_stdio(0); out<<fixed<<setprecision(20);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace AtCorder
{
    public static class Program
    {
        static public void Main(string[] args)
        {
            //int cnt = int.Parse(Console.ReadLine());
            double[] input=  Console.ReadLine().Split(' ').Select(double.Parse).ToArray();
            double A = 0;
            double B = 0;
            for (int N = 1;N <= 10000; N++)
            {
                A = Math.Truncate(N * 0.08);
                B = Math.Truncate(N * 0.1);
                if (input[0] == A && input[1] == B)
                {
                    Console.WriteLine(N.ToString());
                    return;
                }
            }
            Console.WriteLine("-1");
                        
        }
    }
}




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

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

int main(){
    ll a,b;
    cin >> a >> b;
    cout << a * b / gcd(a, b) << endl;
    return 0;
}

Measured memory_bytes: 256
<?php
$n = (int)trim(fgets(STDIN));

$max = (int)ceil(sqrt($n));
$min = $n-1;

for ($i=1; $i <= $max; $i++) { 
	if ($n % $i === 0) {
		$min = min($min, ($i-1) + (int)($n / $i) - 1);
	}
}
echo $min;

Measured memory_bytes: 4856
#include <iostream>
#include <algorithm>
#include <math.h>
#include <string>
#include <cstdio>
#include <vector>
#include <set>
#include <cassert>
#include <cstdlib>
#include <complex>
#include <cctype>
#include <cmath>
#include <ctime>
#include <deque>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <sstream>
#include <functional>
//#include <windows.h>  //Should be deleted when using AtCoder&POJ
using namespace std;
/**==Info==
*Program:B
*Problem:Two Switches
*Date:2017-8-11
*Algorithm:AtCoder
*Stats:Unknown*/
int main(){
	int a,b,c,d,cnt=0;
	cin>>a>>b>>c>>d;
	for(int i=0;i<=100;i++){
		if(i>=a && i<=b && i>=c && i<=d){
			cnt++;
		}
	}
	cout<<max(cnt-1,0);
	return 0;
}


Measured memory_bytes: 256
<?php
while (!feof(STDIN)) {
  $stdin = trim(fgets(STDIN));
  $values  = explode(',', $stdin);
  if (count($values) != 3) {
  } else {
    list($no, $weight, $height) = $values;
    $bmi = $weight / pow($height, 2);
    if ($bmi >= 25) {
      echo $no . "\n";
    }
  }
}

Measured memory_bytes: 15256
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

inline void solve() {
	string a, b;
	cin >> a >> b;
	b.pop_back();
	if (a == b)
		cout << "Yes";
	else
		cout << "No";
}

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
#if defined(_DEBUG)
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	int q = 1;
	//cin >> q;
	for (; q > 0; q--) {
		solve();
		cout << '\n';
	}
}

Measured memory_bytes: 3656
#include <bits/stdc++.h>
#define ll long long
using namespace std;
ll n,d,a;
struct st{ ll x,h; }arr[200002];
ll bmb[200002],now=0;
ll e, ans=0;
int main(){
	ios_base::sync_with_stdio(0); cin.tie(0);
	cin>>n>>d>>a;
	for(ll i=1;i<=n;i++) cin>>arr[i].x>>arr[i].h;
	sort(arr+1,arr+n+1,[&](st aa, st bb){
		if(aa.x==bb.x) return aa.h<bb.h;
		return aa.x<bb.x;
	}); e=1;
	for(ll i=1;i<=n;i++){
		now+=bmb[i];
		while(e<n && arr[e+1].x<=arr[i].x+2*d) e++;
		if(arr[i].h>0){
			ll imsi=(max(arr[i].h-now*a,(ll)0)+a-1)/a;
			now+=imsi; bmb[e+1]+=-imsi;
			ans+=imsi;
		}
	}
	cout<<ans;
}

Measured memory_bytes: 4992
n = int(input())
Inlist = []

for i in range(n):
    val = list(input().split())
    Inlist.append(val)
    
CKlist = []
for mark in ['S', 'H', 'C', 'D']:
    for num in range(1, 14):
        num = str(num)
        CKlist.append(list((mark, num)))
        
reslist = [res for res in CKlist if res not in Inlist ]
for p in reslist:
    print('{} {}'.format(p[0], p[1]))


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

int main(){
	int n;
	std::vector<int> aList;
	std::vector<int> ansList;

	std::cin>>n;
	aList.resize(n);

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

	for(int i=0; i<n; i++){
		int max=0;

		for(int j=0; j<aList.size(); j++)
			if(j+1 == aList[j] && aList[j]> max)
				max= aList[j];

		if(max==0){
			std::cout<<-1<<std::endl;
			return 0;
		}

		ansList.push_back(max);
		aList.erase(aList.begin()+ max - 1);
	}

	for(int i=n-1; i>=0; i--)
		std::cout<<ansList[i]<<std::endl;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll  long long
#define fio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define mod 1000000007
int main(){
	string s;
	cin>>s;
	int x=s.length();
	if(s[x-1]=='2' || s[x-1]=='4' || s[x-1]=='5' || s[x-1]=='7' || s[x-1]=='9'){
		cout<<"hon";
	}
	else if(s[x-1]=='0' || s[x-1]=='1' || s[x-1]=='6' || s[x-1]=='8'  ){
        cout<<"pon";
	}
	else{
		cout<<"bon";
	}
	
}

Measured memory_bytes: 3624
from collections import deque


def topological(N, LIST):  # トポロジカルソート:DAGに適用可
    incnt = [0] * N
    CHILD = [set() for _ in range(N)]
    for a, b in LIST:
        CHILD[a].add(b)
        incnt[b] += 1

    TPLGSORT = []
    que = deque([i for i, num in enumerate(incnt) if num == 0])
    while len(que) > 0:
        q = que.popleft()
        for i in CHILD[q]:
            incnt[i] -= 1
            if incnt[i] == 0:
                que.append(i)
        TPLGSORT.append(q)
    return TPLGSORT


n, m = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(m)]

tplg = topological(n, ab)
print(*tplg, sep='\n')



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

using ll = long long;

int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  for (int i{}; i < N; ++i)
    cin >> A[i];
  vector<ll> S(N + 1);
  S[0] = 0;
  for (int i{}; i < N; ++i)
    S[i + 1] = S[i] + A[i];

  map<ll, ll> sum;
  for (int i{}; i <= N; ++i) {
    ++sum[S[i]];
  }

  ll ans{};
  for (auto p : sum) {
    if (p.second <= 1) continue;
    ans += p.second * (p.second - 1) / 2;
  }

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


Measured memory_bytes: 15104
n,k=map(int,input().split())
sunuke=[0]*n
for i in range(k):
 d=int(input())
 a=list(map(int,input().split()))
 
 for j in range(d):
  sunuke[a[j]-1]+=1
  
ninnzuu=0

for i in range(n):
 if sunuke[i]==0:
  ninnzuu+=1
print(ninnzuu)

Measured memory_bytes: 9184
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
#define FOR(i,n,j) for(int i=(j);i<(n);++i)
#define rrep(i,n) for(int i=(n);i>=0;--i)
#define ssort(n) sort((n).begin(),(n).end())
using ll=long long;
using ld=long double;
typedef pair<int,int> P;
#define Yes cout << "Yes" << endl
#define No cout << "No" << endl
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl
#define INF 10101010

class Calc_Mod{//calculate mod
    public:
        unsigned int mod=1000000007;
        ll plus_mod(ll a,ll b){
            return (a+b)%mod;
        }
        ll minus_mod(ll a,ll b){
            return (a-b)%mod;
        }
        ll multi_mod(ll a,ll b){
            return a*b%mod;
        }
        ll LSM(ll a,int b){//a^b%mod
            queue<int> q;
            while(b>=1){
                q.push(b%2);
                b/=2;
            }
            ll ans=1;
            while(!q.empty()){
                if(q.front()==1){
                    ans=multi_mod(ans,a);
                }
                a=multi_mod(a,a);
                q.pop();
            }
            return ans;
        }
        ll div_mod(ll a,ll b){// a/b
            return multi_mod(a,LSM(b,mod-2));
        }
        ll combi(ll a,ll b){//aCb
            ll ans=1;
            ll kaijo=1;
            rep(i,b){
                ans=multi_mod(ans,a-i);
                kaijo=multi_mod(kaijo,b-i);
            }
            ans=div_mod(ans,kaijo);
            return ans;
        }
        ll kaijo(ll a){
            ll kaijo=1;
            rep(i,a){
                kaijo=multi_mod(kaijo,a-i);
            }
            return kaijo;
        }
};

int main()
{
    int n,m;
    cin >> n >> m;
    Calc_Mod mod;
    ll ans;
    ll comb;
    if(abs(n-m)<=1){
        if(abs(n-m)==1){
            ans=mod.multi_mod(mod.kaijo(n),mod.kaijo(m));
        }else{
            ans=mod.multi_mod(mod.kaijo(n),mod.kaijo(m));
            ans=mod.multi_mod(ans,2);
        }
    }else{
        ans=0;
    }

    cout << ans << endl;
    
}

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

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

    int N,L; cin >> N >> L;
    string a[N];
    for(int i=0;i<N;i++){
        cin >> a[i];
    }
    sort(a,a+N);
    for(int i=0;i<N;i++){
        cout << a[i];
    }


    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void){
    int a;
    int b;
    scanf("%d",&a);
    scanf("%d",&b);
    if(a<b){
        printf("a < b\n");
    }else if(a>b){
        printf("a > b\n");
    }else{
        printf("a == b\n");
    }
    
    return 0;
}


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

using namespace std;

#define int long long
#define ALL(x) (x).begin(),(x).end()
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))

typedef pair<int,int> PI;
typedef pair<int,pair<int,int>> PII;
static const int INF=1010000000000000017LL;
static const double eps=1e-12;
static const double pi=3.14159265358979323846;
static const int dx[4]={1,-1,0,0};
static const int dy[4]={0,0,1,-1};
static const int ddx[8]={1,-1,0,0,1,1,-1,-1};
static const int ddy[8]={0,0,1,-1,1,-1,1,-1};

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

struct  edge{
    int to,cost;
    edge(int to,int cost):to(to),cost(cost){}
};


int N;
vector<edge> T[100005];
int color[100005];
bool visited[100005];


void dfs(int n){
    for(auto u:T[n]){
        if(visited[u.to])continue;
        if(u.cost%2!=0)color[u.to]=!color[n];
        else color[u.to]=color[n];
        visited[u.to]=true;
        dfs(u.to);
    }
}


signed main(){
    cin>>N;
    for(int i=0;i<N-1;++i){
        int u,v,w;
        cin>>u>>v>>w;
        u--,v--;
        T[u].push_back(edge(v,w));
        T[v].push_back(edge(u,w));
    }
    color[0]=0;
    visited[0]=true;
    dfs(0);
    for(int i=0;i<N;++i)cout<<color[i]<<endl;
}

Measured memory_bytes: 13232
#include <bits/stdc++.h>
using namespace std;
using ll =long long;
#define all(v) v.begin(),v.end()
 
int main() {
  string S;
  cin>>S;
  if(S[2]==S[3]&&S[4]==S[5]) {
cout<<"Yes"<<endl;
  }
  else {
    cout<<"No"<<endl;
  }
}

Measured memory_bytes: 3624
#include <cstdlib>
#include <iostream>
#include <string>
#include <time.h>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <sstream>
#include <iomanip>
using namespace std;

#define huge 1000000007

int main(void) {

	long int C = 0, A=0, B = 0,D=0;
	cin >> A >> B >> C >> D;
	
	if(A+B>C+D)
	cout << "Left" << endl;
	else if (A + B<C + D)
		cout << "Right" << endl;
	else
		cout << "Balanced" << endl;

	
	return 0;


}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
#define X first
#define Y second
#define mod 1e9+7
#define pb push_back
#define mp make_pair
#define abs(x) ((x)>0?(x):(-(x)))
#define F(n) Fi(i,n)
#define Fi(i,n) Fl(i,0,n)
#define Fl(i,l,n) for(int i=l;i<n;i++)
#define memres(a) memset(a,0,sizeof(a))
int gcd(int a,int b){if(b==0)return a;return gcd(b,a%b);}

int main(){
	ios_base::sync_with_stdio(0);cin.tie(0);
	string a,b;
	cin>>b>>a;
	cout<<a+b<<endl;
return 0;
}


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

using namespace std;

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

  const int sz=s.size();

  int ans=0;

  for(int i=1;i<sz;++i){
	if(s[i]==s[i-1]){
	  ans++;
	  if(s[i]=='0')s[i]='1';
	  else s[i]='0';
	}
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 512
import java.util.*;

public class Main{

    public static void main(String args[]){

        Scanner scan = new Scanner(System.in);
        Long k = scan.nextLong();
        Long x = scan.nextLong();

        if(500 * k >= x)
            System.out.println("Yes");
        else
            System.out.println("No");
    }
}


Measured memory_bytes: 22868
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string s;
  cin >> s;
  
  if (s == "Sunny"){
    cout << "Cloudy" << endl;
  }
  else if (s == "Cloudy"){
    cout << "Rainy" << endl;
  }
  else if (s == "Rainy"){
    cout << "Sunny" << endl;
  }
}

Measured memory_bytes: 256
/*Lucky_Glass*/
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;

const int N=3e5,MOD=1e9+7;
const int tra[8][2]={{6,1},{3,2},{2,2},{4,1},{3,3},{6,1},{7,5},{6,6}};

inline int Add(const int a,const int b){return a+b>=MOD? a+b-MOD:a+b;}

int n;
int f[N+3][8];
char str[N+6];
int main(){
    scanf("%s",str);
    n=strlen(str);
    f[0][0]=1;
    for(int i=0;i<n;i++){
        if(str[i]=='0' || str[i]=='?')
            for(int j=0;j<8;j++)
                f[i+1][tra[j][0]]=Add(f[i][j],f[i+1][tra[j][0]]);
        if(str[i]=='1' || str[i]=='?')
            for(int j=0;j<8;j++){
                // printf("%d -> %d\n",j,tra[j][1]);
                f[i+1][tra[j][1]]=Add(f[i][j],f[i+1][tra[j][1]]);
            }
        // for(int j=0;j<8;j++) printf("%d ",f[i][j]);
        // printf("\n");
    }
    printf("%d\n",Add(f[n][1],f[n][2]));
    return 0;
}


Measured memory_bytes: 9984
#include<iostream>
#include<map>
#include<vector>
#include<queue>
using namespace std;
#define P pair<int,int>
#define mk make_pair
int dx[]={1,1,1,0,0,-1,-1,-1};
int dy[]={1,0,-1,1,-1,1,0,-1};
int ddx[]={-2,-2,-2,-2,-2,-1,-1,0,0,1,1,2,2,2,2,2};
int ddy[]={-2,-1,0,1,2,-2,2,-2,2,-2,2,-2,-1,0,1,2};
int c[4];
int main(){
    map<P,int>s;
    vector<P>v1,v2;
    int n,w,h;
    cin>>w>>h>>n;
    for(int i=0;i<n;i++){
        int x,y;
        cin>>x>>y;
        if(x==0||y==h-1)v1.push_back(mk(x,y));
        if(y==0||x==w-1)v2.push_back(mk(x,y));
        s[mk(x,y)]=0;
    }
    if(s.find(mk(w-1,h-2))!=s.end())c[3]=1;
    if(s.find(mk(w-2,h-1))!=s.end())c[2]=1;
    if(s.find(mk(0,1))!=s.end())c[1]=1;
    if(s.find(mk(1,0))!=s.end())c[0]=1;
    if((c[0]&&c[1])||(c[2]&&c[3]))goto L0;
    for(vector<P>::iterator it=v1.begin();it!=v1.end();it++){
        int x=(*it).first,y=(*it).second;
        if(s[mk(x,y)]==0){
            queue<P>q;
            q.push(mk(x,y));
	    if(y==0||x==w-1)goto L0;
            s[mk(x,y)]=1;
            while(!q.empty()){
                P po=q.front();q.pop();
                int xx=po.first,yy=po.second;
                for(int i=0;i<8;i++){
                    int px=xx+dx[i],py=yy+dy[i];
                    if(s.find(mk(px,py))!=s.end())if(s[mk(px,py)]==0){
                        if(py==0||px==w-1)goto L0;
                        s[mk(px,py)]=1;
                        q.push(mk(px,py));
                    }
                }
            }
        }
    }
    for(vector<P>::iterator it=v2.begin();it!=v2.end();it++){
        int x=(*it).first,y=(*it).second;
        if(s[mk(x,y)]==0){
            queue<P>q;
            q.push(mk(x,y));
	    if(x==0||y==h-1)goto L0;
            s[mk(x,y)]=2;
            while(!q.empty()){
                P po=q.front();q.pop();
                int xx=po.first,yy=po.second;
                for(int i=0;i<16;i++){
                    int px=xx+ddx[i],py=yy+ddy[i];
                    if(s.find(mk(px,py))!=s.end()){
                        if(s[mk(px,py)]==1)goto L1;
                    }
                }
                for(int i=0;i<8;i++){
                    int px=xx+dx[i],py=yy+dy[i];
                    if(s.find(mk(px,py))!=s.end())if(s[mk(px,py)]==0){
                        if(px==0||py==h-1)goto L0;
                        s[mk(px,py)]=2;
                        q.push(mk(px,py));
                    }
                }
            }
        }
    }
    for(int i=0;i<4;i++)if(c[i])goto L1;
    for(int i=0;i<w;i++)
      for(int j=0;j<8;j++){
	int x=i+dx[j],y=dy[j];
	if(s.find(mk(x,y))!=s.end())
	  if(s[mk(x,y)]==1)goto L1;
	  }
 for(int i=0;i<h;i++)
      for(int j=0;j<8;j++){
	int x=w-1+dx[j],y=i+dy[j];
	if(s.find(mk(x,y))!=s.end())
	  if(s[mk(x,y)]==1)goto L1;
	  }
 for(int i=0;i<w;i++)
      for(int j=0;j<8;j++){
	int x=i+dx[j],y=h-1+dy[j];
	if(s.find(mk(x,y))!=s.end())
	  if(s[mk(x,y)]==2)goto L1;
	  }
 for(int i=0;i<h;i++)
      for(int j=0;j<8;j++){
	int x=0+dx[j],y=i+dy[j];
	if(s.find(mk(x,y))!=s.end())
	  if(s[mk(x,y)]==2)goto L1;
	  }
    goto L2;
    if(0)L0:cout<<0<<endl;
    if(0)L1:cout<<1<<endl;
    if(0)L2:cout<<2<<endl;
}

Measured memory_bytes: 9372
#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, m;
    cin >> n >> m;
    priority_queue<int> que;
    rep(i, n){
        int a;
        cin >> a;
        que.push(a);
    }
    rep(i, m){
        int a = que.top();
        que.pop();
        que.push(a / 2);
    }
    ll ans = 0;
    while(!que.empty()){
        int b = que.top();
        ans += b;
        que.pop();
    }
    cout << ans << endl;
}

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

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(),v.end()
#define bitcount(s) __builtin_popcount(s)
#define _GLIBCXX_DEBUG

using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using vd = vector<double>;
using vvi = vector<vi>;
using vvll = vector<vll>;
using vvd = vector<vd>;
using vvvi = vector<vvi>;
using vvvll = vector<vvll>;
using vvvd = vector<vvd>;

const double pi=3.141592653589793;
const ll MOD=1e9+7;

int main() {
    int n;
    cin>>n;
    int a[n+1][n+1];
    rep(i,n){
        rep(j,n){
            cin>>a[i+1][j+1];
            //cout<<a[i+1][j+1]<<endl;
        }
    }
    //cout<<1<<endl;
    int num1=int(1<<n);
    //cout<<num1<<endl;
    //cout<<2<<endl;
    int dp[n+1][num1];
    //cout<<num1<<endl;
    memset(dp,0,sizeof(dp));
    dp[0][0]=1;
    for (int i=1;i<n+1;i++){
        for (int j=0;j<(1<<n);j++){
            bitset<21> s(j);
            if (bitcount(j)!=i){
                continue;
            }
            else{
                for (int k=0;k<n;k++){
                    if (s.test(k)){
                        if (a[i][k+1]){
                            int num=(1<<k);
                            dp[i][j]+=dp[i-1][j-num];
                            dp[i][j]%=MOD;
                        }
                    }
                }
            }
        }
    }
    //cout<<num1<<endl;
    cout<<dp[n][num1-1]<<endl;

    return 0;
}

Measured memory_bytes: 180480
function Main(input){
	var temp = input.trim().split("\n");
  	var K = parseInt(temp[0].split(" ")[0],10);
  	var N = parseInt(temp[0].split(" ")[1],10);
  	var A = temp[1].split(" ").map(x => x*1);
  	var maxd = 0;
  	var d = [];
    for(var i = 0 ;i<N;i++){
      	if(i+1 == N){
          	maxd = Math.max(maxd,((K-A[i]) + A[0]));
        }else{
          	maxd = Math.max(maxd,A[i+1] - A[i]);
        }
    }
 	console.log(K-maxd)
}
Main(require("fs").readFileSync("/dev/stdin","utf8"));

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

int main(){
  int N; cin >> N;
  vector<int> cnt(1e5+2, 0);
  for(int i = 0; i < N; i++){
    int a; cin >> a;
    if(a) cnt[a-1]++;
    cnt[a]++;
    cnt[a+1]++;
  }
  int ans = 0;
  for(auto e:cnt){
    ans = max(ans, e);
  }
  cout << ans;
}

Measured memory_bytes: 640
n,m = map(int, input().split())

a = [0]*(n+1)
for i in range(m):
    a[int(input())] = -1

dp = [0]*(n+1)

for i in range(n+1):
    if a[i] == -1:
        dp[i] = 0
    else:
        if i > 1:
            dp[i] = dp[i-1] + dp[i-2]
        else:
            dp[i] = 1
print(dp[-1] % 1000000007)

Measured memory_bytes: 460788
#include<bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
#define int long long
using namespace std;
int n,N,a[1000001],b[1000001],t;
main(){
    cin>>N;
    r(i,N){
        cin>>t;
        a[t]+=t;
    }
    r(i,1000000)a[i+1]+=a[i];
    cin>>n;
    r(i,n)cin>>b[i];
    r(i,n){
        cin>>t;
        if(a[b[i]]>=t)cout<<"Yes"<<endl;
        else cout<<"No"<<endl;
    }
}

Measured memory_bytes: 13224
N, M = map(int, input().split())
a = []
b = []
for i in range(N):
    a.append(input())
c = 0
ans = "No"
for i in range(M):
    b.append(input())
for i in range(N-M+1):
    for j in range(N-M+1):
        for k in range(M):
            if a[i+k][j:j+M] == b[k]:
                c += 1
        if c == M:
            ans = "Yes"
            break
        c = 0
print(ans)

Measured memory_bytes: 3064
// #Sazaの1日1AC
#include<bits/stdc++.h>
using namespace std;
const long long mod=1000000007;
const long long INF=9e15;
const double PI=3.14159265358979323846;

//マクロ
//型エイリアス
using ll = long long;
using P=pair<long long,long long>;
using vl=vector<long long>;
using vvl=vector<vector<long long>>;
using vP=vector<pair<long long, long long>>;
//ショートカット
#define rep(i,n) for(long long i = 0; i < n; i++)
#define rep2(i,k,n) for(long long i = k; i < n; i++) //半開区間
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(),v.rend()
#define pb push_back
#define mkp make_pair
//入力
#define vin(v,N) for(long long id=0;id<N;id++) cin>>v.at(id)
#define lin(n) long long n;cin>>n
#define chin(x) char x;cin>>x;
#define sin(s) string s;cin>>s;
#define vlin(v,N) vector<long long>v(N);for(long long i=0;i<N;i++)cin>>v.at(i)

#define max(a,b) max((ll)a,(ll)b)
#define min(a,b) min((ll)a,(ll)b)

//関数
//最大公約数
long long gcd(long long m, long long n){
  long long a=max(m,n);
  long long b=min(m,n);
  long long r=a%b;
  while(r!=0){
    a=b; b=r; r=a%b;
  }
  return b;
}
// 最小公倍数
long long lcd(long long m, long long n){
  return m*n/gcd(m,n);
}
//xのn乗
long long power(long long x, long long N){
  long long ret=1;
  for(long long i=0;i<N;i++)   
    ret*=x;
  return ret;
}
//繰り返し二乗法
long long repeat_squaring(long long x, long long n){
  if(n==0) return 1;
  else if(n%2==0){
    long long t=repeat_squaring(x,n/2);
    return t*t%mod;
  }
  else
    return x*repeat_squaring(x,n-1);
}
//素因数分解(mapで返す)
map<long long,long long> factor(long long p){
  ll p1=p;
  map<long long,long long>ret;
  for(long long i=2;i*i<=p1;i++){
     while(p%i==0){
      ret[i]++;
      p/=i;
    }
  }
  if(p!=1)
  ret[p]++;
  return ret;
}
//素数判定
bool is_prime(long long N){
  for(long long i=2;i*i<=N;i++){
    if(N%i==0)
      return false;
  }
  return true;
}
//最大値更新
void chmax(long long &a,long long b){
  a=max(a,b);
}
//最小値更新
void chmin(long long &a,long long b){
  a=min(a,b);
}

//構造体

/////////////////⊂('ω'⊂ )))Σ≡GO!/////////////////

double f(double x){
  return 4*x*(1-x);
}

//メイン関数
int main(){
  //doubleの桁数
  cout<<fixed<<setprecision(10);
  
  lin(N);lin(K);
  vlin(a, N);
  ll sup = 11 * floor(log2(N));

  if(K > sup) {
    rep(i, N){
      cout << N << " ";
    }
    cout << endl;
  }
  else{
    rep(i, K){
      vl b(N);
      rep(i, N){
        ll x = a[i];
        b[max(0, i - x)]++;
        if(i + x + 1 < N) b[i + x + 1]--;
      }
      rep(i, N-1){
        b[i+1] += b[i];
      }
      a = b;
    }

    rep(i, N){
      cout << a[i] <<" ";
    }
    cout << endl; 
  }
}

Measured memory_bytes: 6536
#include<bits/stdc++.h>
#define inf 1<<29
#define linf 1e18
#define eps (1e-8)
#define mod 1000000007
#define pi M_PI
#define f first
#define s second
#define mp make_pair
#define pb push_back
#define all(a) (a).begin(),(a).end()
#define pd(a) printf("%.10f\n",(double)(a))
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(a)-1;(b)<=i;i--)
#define equals(a,b) (fabs((a)-(b))<eps)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<double,int> pdi;
typedef vector<int> vi;
typedef vector<pii> vpi;
const int dx[8]={1,0,-1,0,1,1,-1,-1};
const int dy[8]={0,1,0,-1,1,-1,1,-1};

string s,t;
string ans;
ll bef;
bool a[10]={};

void dfs(int index){
  if(index==s.length()){
    ll tmp1=atoll(t.c_str());
    ll tmp2=atoll(ans.c_str());
    ll dif1=min(abs(bef-tmp1),(ll)pow(10,s.length())-abs(bef-tmp1)); 
    ll dif2=min(abs(bef-tmp2),(ll)pow(10,s.length())-abs(bef-tmp2));
    if(dif2!=dif1 ? dif2<dif1 : tmp1<tmp2)ans=t;
  }
  else {
    FOR(i,0,10){
      if(!a[i]){
        a[i]=true;
        t[index]=i+'0';
        dfs(index+1);
        a[i]=false;
      }
    }
  }
}

int main()
{
  cin>>s;

  t=s;
  bef=atoll(s.c_str());
  if(t[0]<'5')t[0]+=5;
  else t[0]-=5;
  a[t[0]-'0']=true;

  dfs(1);

  cout<<ans<<endl;

  return 0;
}

Measured memory_bytes: 3340
n=int(input())
f=lambda x:sorted([tuple(map(int,input().split())) for _ in range(n)],key=lambda k:k[x])
qr,qb=f(1)[::-1],f(0)
a=0
for c,d in qb:
  for i in range(n-a):
    if c>qr[i][0] and d>qr[i][1]: qr.pop(i); a+=1; break
print(a)

Measured memory_bytes: 3060
#include <iostream>
#include <map>
#include <set>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <fstream>
#include <bitset>
#include <queue>
#include <stack>
#include <deque>
#include <complex>
#include <iomanip>
#include <stdio.h>
#include <string.h>
#include <random>
#include <functional>
using namespace std;
#define all(x) (x).begin(), (x).end()

const int N = 500000;
const long long MOD = 1e9 + 7;

int n, m;
vector<string> s;
long long ans = 0;

void R()
{
    vector<string> f(m, string(n, ' '));
    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < m; j++)
        {
            f[m - 1 - j][i] = s[i][j];
        }
    }
    swap(n, m);
    s = f;
    return;
}

void F()
{
    vector<vector<int> > summ(n, vector<int>(m));
    function<int(int, int)>G = [&](int i, int j)
    {
        if (j < 0 || j + i < 0 || i >= n) return 0;
        if (i < 0)
        {
            j -= -i;
            i += -i;
        }
        return summ[i][j];
    };
    function<int(int, int)>M = [&](int i, int j)
    {
        if (i < 0 || j < 0 || i >= n || j >= m) return 0;
        return (int)(s[i][j] == '#');
    };
    for (int si = 0; si < n + m - 1; si++)
    {
        for (int i = si; i >= 0; i--)
        {
            int j = si - i;
            if (0 <= i && i < n && 0 <= j && j < m)
            {
                summ[i][j] = G(i + 1, j - 1) + M(i, j);
            }
        }
    }
    for (int s = 0; s < n + m - 1; s++)
    {
        for (int i1 = 0; i1 <= s; i1++)
        {
            for (int i2 = 0; i2 <= s; i2++)
            {
                int j1 = s - i1, j2 = s - i2;
                if (j1 < j2 && 0 <= j1 && j1 < m && 0 <= j2 && j2 < m && M(i1, j1) && M(i2, j2))
                {
                    int k = j2 - j1;
                    int i3 = i2, j3 = j1 - k;
                    int i4 = i2 - k, j4 = j1;
                    i3++, j3--;
                    ans += G(i4, j4) - G(i3, j3);
                }
            }
        }
    }
    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < m; j++)
        {
            for (int k = 1; k <= 300; k++)
            {
                if (M(i + k, j) && M(i, j + k) && M(i - k, j)) ans--;
            }
        }
    }
}

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cin >> n >> m;
    s.resize(n);
    for (int i = 0; i < n; i++)
    {
        cin >> s[i];
    }
    F();
    R();
    F();
    R();
    F();
    R();
    F();
    cout << ans;
}


Measured memory_bytes: 788
#include<iostream>
#include<math.h>
#include<iomanip>

using namespace std;


class Hoge{
		
		public:
		int k,n,p[1000];
		double danswer;
		const double PI=3.14159265358979323846;
		string s0,s1;		
		//Hoge(int k,int n ,int p);
		Hoge(int,int,int p[1000]);		
		void angle();
		void sort0();
		void printp();
		void takesum();		
};

//Hoge::Hoge(int k0,int n0,int p0){k=k0;n=n0;p[]=p0;}
Hoge::Hoge(int k0,int n0,int p0[]){k=k0;n=n0;}



void Hoge::angle(){
		
			//cout<<"k="<<k<<endl;
			//cout<<p[323]<<endl;
			
for(int i=0;i<n;i++){
			//cout<<i;
			cin>>p[i];
			}	
			//cout<<endl;
			
		}

void Hoge::sort0(){
			int icheck=1;
			while(icheck==1){
			icheck=0;
			for(int i=0;i<n-1;i++){
			
			if(p[i]>p[i+1]){
					
					int itemp=p[i];
					p[i]=p[i+1];
					p[i+1]=itemp;
					icheck=1;
					}		
			
						}
			}
			//cout<<icheck<<endl;
			}
void Hoge::printp(){

			

for(int i=0;i<n;i++){
			cout<<"p["<<i<<"]="<<p[i]<<endl;
			
			}

		
		}

void Hoge::takesum(){

			int isum=0;
			for(int i=0;i<k;i++){
						isum+=p[i];
						}
			cout<<isum<<endl;

			}

int main(){
		int k,n;
		int p[1000];		
		cin>>n>>k;
		p[323]=323;
		Hoge hoge(k,n,p);
		
		//Hoge hoge(k,n,p);
		hoge.angle();
		//hoge.printp();	
		hoge.sort0();
		//hoge.printp();	
		hoge.takesum();
		}

Measured memory_bytes: 3556
import std;

void main() {
    int a, b; scan(a, b);
    writeln(a * b);
}

void scan(T...)(ref T a) {
    string[] ss = readln.split;
    foreach (i, t; T) a[i] = ss[i].to!t;
}
T read(T=string)() { return readln.chomp.to!T; }
T[] reads(T)() { return readln.split.to!(T[]); }
alias readints = reads!int;


Measured memory_bytes: 3664
#include <bits/stdc++.h>
#define MAX (ll)(1e5 + 7)
#define INF (ll)(4e18)
#define MOD (ll)(998244353)

using namespace std;
using ll = long long;
using cd = complex<double>;

int main ()  {
	ll x;
	long double y;
	cin >> x >> y;		
	cout << (ll)(x * y) << "\n";
}


Measured memory_bytes: 3720
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const ll INF = 100000000;
#define rep1(i, n) for (ll i=0; i<(n); i++) 
#define rep2(i, k, n) for (ll i=k; i<(n); i++)
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; }

ll a, b, c, d;

ll solve(ll x){
    ll cnt = lcm(c, d);
    ll ans = x/cnt * (cnt - cnt/c - cnt/d + 1);
    x %= cnt;
    ans += x - x/c - x/d;
    return ans;
}


int main() {
    cin >> a >> b >> c >> d;
    cout << solve(b) - solve(a-1) << endl;
}

Measured memory_bytes: 3684