akhauriyash/Code-Regression huggingface dataset:
from functools import reduce
import math
import collections

def main():
    # 文字列の2進数を数値にする
    # '101' → '5'
    # 文字列の頭に'0b'をつけてint()にわたす
    # binary = int('0b'+'101',0)

    # 2進数で立っているbitを数える
    # 101(0x5) → 2
    # cnt_bit = bin(5).count('1')
    
    # N! を求める
    # f = math.factorial(N)

    # N の逆元
    # N_inv = pow(N,MOD-2,MOD)

    # nCr
    # Nの階乗 * rの階乗の逆元 * n-rの階乗の逆元
    
    # 切り捨て
    # 4 // 3
    # 切り上げ
    #-(-4 // 3)
    
    # 初期値用:十分大きい数(100億)
    INF = float("inf")

    # 大きな素数
    MOD = 10**9+7
    
    # 1文字のみを読み込み
    # 入力:2
    # a = input().rstrip()
    # 変数:a='2'
    
    # スペース区切りで標準入力を配列として読み込み
    # 入力:2 4 5 7
    # a, b, c, d = (int(_) for _ in input().split())  
    # 変数:a=2 b=4 c=5 d =7
    
    # 1文字ずつ標準入力を配列として読み込み
    # 入力:2 4 5 7
    # a = list(int(_) for _ in input().split())
    # 変数:a = [2, 4, 5, 7]    

    # 1文字ずつ標準入力を配列として読み込み
    # 入力:2457
    # a = list(int(_) for _ in input())
    # 変数:a = [2, 4, 5, 7]
    N_max = 100005
    N, C = (int(_) for _ in input().split())
    s = []
    t = []
    c = []
    for i in range(N):
        s1, s2,s3 = (int(_) for _ in input().split())
        s.append(s1)
        t.append(s2)
        c.append(s3)
        
    d = [[0 for j in range(C)] for i in range(N_max)]
    for i in range(N):
        for j in range(s[i]-1,t[i]):
            d[j][c[i]-1] = 1
    ans = 0
    for i in range(N_max):
        ans = max(sum(d[i]),ans)
    print(ans)
    # for i in range(N):
    #     for d_i in range(len(d)):
    #         can_insert_channel = True
    #         for d_j in range(s[i],t[i]+1):
    #             if d_j == s[i]:
    #                 if d[d_i][d_j] == c[i] or d[d_i][d_j] == 0:
    #                     continue
    #                 else:
    #                     can_insert_channel = False
    #                     break
    #             if d[d_i][d_j] != 0:
    #                 can_insert_channel = False
    #                 break
                
    #         if can_insert_channel:
    #             for j in range(s[i],t[i]+1):
    #                 d[d_i][j] = c[i]
    #             break
    #         elif d_i == len(d)-1:
    #             d.append([0]*N_max)
    #             for j in range(s[i],t[i]+1):                    
    #                 d[d_i+1][j]= c[i]
    # for i in range(len(d)):
    #     print(list(d[i]))
    # print(len(d))
    
if __name__ == '__main__':
    main()


Measured memory_bytes: 47520
def main():
    n, m = map(int, input().split())
    if n > m:
        n, m = m, n

    if n == 1:
        if m == 1:
            print(1)
            return
        else:
            print(m - 2)
            return
    elif n == 2:
        print(0)
        return
    else:
        print((n - 2) * (m - 2))
        return


if __name__ == '__main__':
    main()


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

using namespace std;

#define REP(i, a, b) for (int i = (a), i##_end_ = (b); i < i##_end_; ++i)
#define debug(...) fprintf(stderr, __VA_ARGS__)
#define mp make_pair
#define x first
#define y second
#define pb push_back
#define SZ(x) (int((x).size()))
#define ALL(x) (x).begin(), (x).end()

#define ctz __builtin_ctz
#define bcnt __builtin_popcount

template<typename T> inline bool chkmin(T &a, const T &b) { return a > b ? a = b, 1 : 0; }
template<typename T> inline bool chkmax(T &a, const T &b) { return a < b ? a = b, 1 : 0; }

typedef long long LL;

const int oo = 0x3f3f3f3f;

const int Mod = 1e9 + 7;

const int maxn = 15;

int dp[(1 << maxn) + 5];

int n, m;
int adj[maxn + 5];

int main()
{
#ifdef matthew99
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	scanf("%d%d", &n, &m);
	REP(i, 0, m)
	{
		int u, v;
		scanf("%d%d", &u, &v), --u, --v;
		adj[u] |= 1 << v;
	}
	dp[0] = 1;
	REP(i, 0, 1 << n) if (dp[i])
	{
		int res = ((1 << n) - 1) ^ i;
		for (int j = res; j > 0; (--j) &= res)
		{
			if ((j & 3) == 3) continue;
			int val = dp[i];
			REP(k, 0, n) if (!(i >> k & 1))
			{
				if (j >> k & 1) val = ((LL)val << bcnt(adj[k] & ~(i | j))) % Mod;
				else val = (LL)val * ((1 << bcnt(adj[k] & j)) - 1) % Mod;
			}
			(dp[i | j] += val) %= Mod;
		}
	}
	int ans = dp[(1 << n) - 1];
	(ans += Mod) %= Mod;
	printf("%d\n", ans);
	return 0;
}


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

#define max(a,b) ((a)>(b)?(a):(b))
#define min(a,b) ((a)<(b)?(a):(b))
#define abs(a) max((a),-(a))
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define repe(i,n) rep(i,(n)+1)
#define per(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define pere(i,n) rep(i,(n)+1)
#define all(x) (x).begin(),(x).end()
#define SP <<" "<<
#define RET return 0
#define MOD 1000000007
#define INF 1000000000000000000

typedef long long LL;
typedef long double LD;

int main(){
  int n;
  cin >> n;
  LL h,a,d,s;
  cin >> h >> a >> d >> s;
  vector<LL> eh(n),ea(n),ed(n),es(n);
  vector<pair<LD,LL>> ss(n,{0,-1});
  LL ans=0;
  for(int i=0;i<n;i++){
    cin >> eh[i] >> ea[i] >> ed[i] >> es[i];
    ea[i]=max(ea[i]-d,0);
    ed[i]=max(a-ed[i],0);
    if(es[i]>s) ans+=ea[i];
    if(ed[i]==0){
      if(ea[i]>0){
        cout << -1 << endl;
        return 0;
      }
    }else{
      if(ea[i]==0) ss[i]={INF,i};
      else ss[i]={((eh[i]+ed[i]-1)/ed[i])/(LD)ea[i],i};
    }
  }
  sort(all(ss));
  LL turn=0;
  int id;
  // cout << ans << endl;
  for(int i=0;i<n;i++){
    if(ss[i].second!=-1){
      id=ss[i].second;
      turn+=(eh[id]+ed[id]-1)/ed[id];
      ans+=(turn-1)*ea[id];
      // cout << id SP turn SP ans << endl;
      if(ans>=h){
        cout << -1 << endl;
        return 0;
      }
    }
  }
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 5476
//“ In order to be irreplaceable, one must always be different”
#include <bits/stdc++.h>
using namespace std;
# define ll long long
#define endl "\n"
# define pi 3.14159265359
# define str string
# define vll vector<ll>
# define vstr vector<str>
# define vchar vector<char>
# define pb push_back
# define popb pop_back
# define pf push_front
# define popf pop_front
# define sll set<ll>
# define schar set<char>
//find()
//erase(x) removes element x
//erase(position,position)
# define qll queue<ll>
# define qstr queue<str>
//front(),back()
# define stll stack<ll>
# define ststr stack<str>
//top()
# define dll deque<ll>
//at()
# define mll map<ll,ll>
#define mchar map<char, ll>
# define mstr map<str,ll>
# define mss map<str,str>
# define mci map<char,ll>
# define vp vector< pair<ll,ll> >
#define mp make_pair
#define ff first
#define ss second
#define pll pair<ll,ll>
# define f(x,y) for(int x=0;x<y;x++)
# define r(x,y) for(int x=y;x>=0;x--)
# define fr(x,y,z) for(int x=y;x<z;x++)
# define rr(x,y,z) for(int x=y;x>z;x--)
ll power(ll a , ll b){ll res=1;for(ll i=0; i<b; ++i){res*=a;}return res;}
ll logx(ll base, ll num){int cnt=0;while(num!=1){num/=base; ++cnt;}return cnt;}
ll gcd(ll a, ll b){
    if(b == 0)
        return a;
    return gcd(b, a % b);
}
ll lcm(ll a, ll b){
    return (a*b)/gcd(a, b);
}
void print(vll a){
    for(int i=0;i<a.size();i++){
        cout<<a[i]<<' ';
    }
    cout<<endl;
}
vll inp(int n){
    vll a;
    ll x;
    f(i,n){
        cin>>x;
        a.pb(x);
    }
    return a;
}
int main(){
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    ll x;
    cin>>x;
    ll k=x/500;
    ll m=x%500;
    ll k1=m/5;
    ll s=0;
    s+=k*1000;
    s+=k1*5;
    cout<<s;
}




Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef  long long  ll;
ll inf=1000000000000000000,mod=1000000007,BS,k;

int main(){
        ios_base::sync_with_stdio(false);
        cin.tie(NULL);
        #ifndef ONLINE_JUDGE
            freopen("input.txt","r",stdin);
            freopen("output.txt","w",stdout);
        #endif
        ll n,m,k;
        cin>>n>>m>>k;ll arr[n],barr[m];
        for(ll i=0;i<n;i++){
            cin>>arr[i];
            if(i)
            arr[i]+=arr[i-1];
        }
        for(ll i=0;i<m;i++){
            cin>>barr[i];
            if(i)
            barr[i]+=barr[i-1];
        }
        ll ma=0,idx;
        for(ll i=0;i<n;i++){
            if(arr[i]>k)break;
            idx=upper_bound(barr,barr+m,k-arr[i])-barr;
            ma=max(i+1+idx,ma);
        }
        for(ll i=0;i<m;i++){
            if(barr[i]>k)break;
            idx=upper_bound(arr,arr+n,k-barr[i])-arr;
            ma=max(i+1+idx,ma);
        }
        cout<<ma;
}


Measured memory_bytes: 6740
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <iostream>
#include <algorithm>
using namespace std;

#define fir first
#define sec second

typedef long long LL;
typedef pair<int, int> PP;

namespace INPUT {
	const int L = 1 << 15;
	char _buf[L], *S, *T, c;
	char _gc () {
		if (S == T) {
			T = (S = _buf) + fread(_buf, 1, L, stdin);
			if (S == T) return EOF;
		}
		return *S++;
	}
	void readi (int &X) {
		for (c = _gc (); c < '0' || c > '9'; c = _gc ()); X = c & 15;
		for (c = _gc (); c >= '0' && c <= '9'; X = X * 10 + (c & 15), c = _gc ());
	}
}
using INPUT :: readi;

const int Maxn = 2E5 + 5;

int N;
int a[Maxn];
bool b[Maxn];

bool Check (int X) {
	bool FLAG = true;
	for (int i = 1; i <= N; ++i)
		b[i] = (a[i] >= X);
	for (int i = 2; i <= N; ++i)
		FLAG &= (b[i] != b[i - 1]);
	if (FLAG) return b[N / 2 + 1] ^ ((N / 2) & 1);
	int l = 0, r = N + 1;
	for (int i = N / 2; i >= 1; --i)
		if (b[i] == b[i + 1]) {l = i; break ;}
	for (int i = N / 2 + 2; i <= N; ++i)
		if (b[i] == b[i - 1]) {r = i; break ;}
	if ((N / 2 + 1 - l) < (r - N / 2 - 1)) return b[l];
	return b[r];
}

int main () {
	readi (N), N = N * 2 - 1;
	for (int i = 1; i <= N; ++i) readi (a[i]);
	int lb = 0, rb = N + 1;
	while (lb + 1 < rb) {
		int mid = lb + rb >> 1;
		if (Check (mid)) lb = mid;
		else rb = mid;
	}
	printf ("%d", lb);
	return 0;
}


Measured memory_bytes: 1280
#include<bits/stdc++.h>
#define endl '\n'
#define eps 1e-6
#define oo 1e7+5

using namespace std;

typedef long long int ll;
typedef unsigned long long ull;
typedef vector<pair<int,pair<int,int>>> dirgraph;
typedef vector<vector<int>> graph;

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

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<string>
using namespace std;
int main()
{
  int n,k;
  cin>>n>>k;
  long int h[n];
  for(int i=0;i<n;i++) cin>>h[i];
  sort(h,h+n);

  long int det=10000000000;
  for(int i=0;i<=n-k;i++)
  {
    if(h[i+k-1]-h[i]<det) det=h[i+k-1]-h[i];
  }

  cout<<det<<endl;

}

Measured memory_bytes: 1024
#include<iostream>
using namespace std;
 
int  main()
{
  int n;
  cin>>n;
  
  int k=n%10;
  
  if(k==2 || k==4 || k==5 || k==7 || k==9)
    cout<<"hon"<<endl;
  else if(k==0 || k==1 ||k== 6 ||k== 8)
    cout<<"pon"<<endl;
  else
    cout<<"bon"<<endl;
  
  return 0;}

Measured memory_bytes: 3624
import java.util.*;
public class Main{
    
    public static void main(String[] args) throws InterruptedException{
        Scanner sc = new Scanner(System.in);
        
        int n_customer = sc.nextInt();
        
        long sold = sc.nextInt() -1;
        
        int i = 1;
        int price = 2;
        
        if(n_customer > 1){
            while(true){
                int money = sc.nextInt();
                if(money < price)
                    i++;
                else if(money == price){
                    price++;
                    i++;
                }else{
                    if(money % price == 0){
                        sold += money / price -1;
                    }else{
                        sold += money / price;
                    }
                    i++;
                }
                if(i == n_customer)
                    break;
            }
        }
        System.out.println(sold);
    }
}

Measured memory_bytes: 30840
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define len(x) (int)(x).size()
#define all(x) (x).begin() , (x).end()
#define rall(x) (x).rbegin() , (x).rend()
#define fast_io ios_base::sync_with_stdio(0) , cin.tie(0) , cout.tie(0)
typedef long long ll;
typedef long double ld;
using namespace std;
vector<ll>pos , neg;
ll check(ll x){
    int r = len(neg) - 1;
    ll ans = 0;
    for(int i = 0 ;i  < len(neg);++i){
        while(r > i && neg[i] * neg[r] >= x)--r;
        if(r == i)break;
        ans += r - i;
    }
    r = len(pos) - 1;
    for(int i = 0 ;i  < len(pos);++i){
        while(r > i && pos[i] * pos[r] >= x)--r;
        if(r == i)break;
        ans += r - i;
    }
    int l = 0;
    for(int i = len(neg)-1 ; i >=0;--i){
        while(l < len(pos) && -pos[l]*neg[i]>=x)++l;
        ans += len(pos) - l;
    }
    return ans;
}
signed main(){
    int n;cin >> n;
    ll k;cin >> k;
    vector < int > a(n);
    for(int i = 0 ; i < n; ++i){
        int x;cin >> x;
        a[i] = x;
        if(x >= 0)pos.pb(x);
        else neg.pb(-x);
    }
    sort(all(pos)) , sort(all(neg));
    ll l = -(ll)1e18 - (ll)100 , r = (ll)1e18 + (ll)100;
//    l = -(ll)1e18 , r = (ll)1e18;

    while(l != r){
        ll mid = (l + r) >> 1;
        ll f = check(mid);
        assert(f <= 1ll*n*(n-1)/2);
        if(f >= k){
            r = mid;
        }else{
            if(l + 1 == r) l = r;
            else l = mid;
        }
    }
//    cout << check(-11) << '\n';
    if(check(r + 1) >= k && check(r) <= k - 1)cout << r;
    else cout << r - 1;
    return 0;
}


Measured memory_bytes: 3316
#include<iostream>
#include<vector>
#include<set>
using namespace std;

int main(){
    long long N;
    cin >> N;
    long long ans=0;
    vector<long long> res;
    for(long long i=1;i*i<N;i++){
        if(N%i!=0) continue;
        res.push_back(i);
    }
    //cout << res.size() << endl;
    for(int i=0;i<res.size();i++){
        if(N/res[i]-1>res[i]){
            ans+=N/res[i]-1;
        }
    }
    cout << ans << endl;
}

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

using namespace std;

typedef long long ll;
const int MOD = 1000000007;

bool primefactor(int a){
    for(int i=2;i*i<=a;++i){
        if(a % i == 0) return false;
    }
    return true;
}

void makepf(vector<int>& pf, int n){
    for(int i=2;i<n+1;++i){
        if(primefactor(i)) pf.push_back(i);
    }
}

int countpf(vector<int>& pf, map<int, int>& S, int value){
    int a;
    for(auto v : pf){
        if(value < v) break;
        a = value;
        while(1){
            if(a % v == 0){
                ++S[v];
                a /= v;
            }
            else{
                break;
            }
        }
    }
}

int main()
{
    int N;
    ll ans = 1;
    cin >> N;
    vector<int> pf;
    map<int, int> S;
    makepf(pf, N);

    for(int i=2;i<N+1;++i){
        countpf(pf, S, i);
    }

    for(auto& p : S){
        ans = (ans * (p.second+1)) % MOD;
    }

    cout << ans << endl;
}


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

template <std::uint_fast64_t mod>
class ModInt {
    using u64 = std::uint_fast64_t;

   public:
    u64 x;
    ModInt(const int x = 0) : x(x < 0 ? (mod - (-x % mod)) % mod : x % mod) {}

    ModInt operator+(const ModInt r) { return ModInt(*this) += r; }
    ModInt operator*(const ModInt r) { return ModInt(*this) *= r; }
    ModInt operator-(const ModInt r) { return ModInt(*this) -= r; }
    ModInt operator/(const ModInt r) { return ModInt(*this) /= r; }
    ModInt operator-() { return ModInt(mod - x); }

    ModInt &operator+=(const ModInt r) {
        x += r.x;
        if (x >= mod) x -= mod;
        return *this;
    }
    ModInt &operator-=(const ModInt r) {
        if (x < r.x) x += mod;
        x -= r.x;
        return *this;
    }
    ModInt &operator*=(const ModInt r) {
        x *= r.x;
        if (x >= mod) x %= mod;
        return *this;
    }
    ModInt &operator/=(ModInt r) {
        if (!(x % r.x)) {
            x /= r.x;
            return *this;
        }
        u64 p = mod - 2;
        while (p > 0) {
            if (p & 1) *this *= r;
            r *= r;
            p >>= 1;
        }
        return *this;
    }
    ModInt &operator++(int) { return (*this) += 1; }
    ModInt &operator++() { return (*this) += 1; }
    ModInt &operator--(int) { return (*this) -= 1; }
    ModInt &operator--() { return (*this) -= 1; }

    bool operator<(const ModInt r) { return x < r.x; }
    bool operator>(const ModInt r) { return x > r.x; }
    bool operator<=(const ModInt r) { return x <= r.x; }
    bool operator>=(const ModInt r) { return x >= r.x; }
    bool operator==(const ModInt r) { return x == r.x; }
    bool operator!=(const ModInt r) { return x != r.x; }

    ModInt inv() { return (ModInt)1 / (*this); }
    int get_mod() { return mod; }

    friend std::istream &operator>>(std::istream &in, ModInt &m) {
        int a;
        in >> a;
        if (a < 0) a = mod - (-a % mod);
        if (a >= mod) a %= mod;
        m.x = a;
        return in;
    }
    friend std::ostream &operator<<(std::ostream &out, const ModInt &m) {
        out << m.x;
        return out;
    }
};
constexpr std::uint_fast64_t mod = 1e9 + 7;
using mint = ModInt<mod>;

template <typename T>
T fact(std::uint_fast32_t n) {
    static vector<T> factorial(1, 1);

    if (n < factorial.size())
        return factorial[n];
    else
        for (T i = factorial.size(); i <= n; i++) {
            factorial.push_back(factorial.back() * i);
        }
    return factorial[n];
}

int main() {
    int n;
    cin >> n;
    vector<mint> x(n + 1);
    vector<mint> si(n + 1);
    for (int i = 1; i <= n; i++) {
        cin >> x[i];
        si[i] = i > 1 ? si[i - 1] + mint(i).inv() : 1;
    }
    mint ans = 0;
    for (int i = 1; i <= n - 1; i++) {
        ans += (x[i + 1] - x[i]) * si[i];
    }
    ans *= fact<mint>(n - 1);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 2936
// 失敗するからこそ そこから立ち向かって行く強さがあってそんな強さが本当の強さだと私は思うから
// ぜったいあきらめない
#include<bits/stdc++.h>
using namespace std;

#if defined(DAIJOBU)
#include "/home/ichigo/debug.hpp"
#define deb(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define deb(x...)
#endif
#define FIO {ios::sync_with_stdio(0);cin.tie(nullptr);cout.tie(nullptr);}

const int mod = 1e9 + 7;

long long pow(long long a, long long b, long long mod){
	a %= mod;
	long long res = 1;
	while(b){
		if(b & 1){res *= a;res %= mod;}
		b >>= 1;
		a = a * a % mod;
	}
	return res % mod;
}

int main(){
	FIO
	
	int n;
	cin >> n;
	int a[n];
	for(int i = 0; i < n; i++)cin >> a[i];
	int lcm = a[0];
	for(int i = 1; i < n; i++){
		lcm = (a[i] * lcm) / __gcd(a[i], lcm);
	}
	cout << lcm << '\n';
	return 0;
}



Measured memory_bytes: 3204
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int mod=1e9+7,N=2e5+5;
int n,m,k;
ll f[N],invf[N];
vector<int>v;
ll qpow(ll a,ll n)
{
    ll ans=1;
    while(n)
    {
        if(n&1) ans=ans*a%mod;
        a=a*a%mod;
        n>>=1;
    }
    return ans;
}
void init()
{
    f[0]=invf[0]=1;
    for(int i=1;i<=200000;i++)
        f[i]=f[i-1]*i%mod,invf[i]=qpow(f[i],mod-2);
}
ll c(int n,int m)
{
    return f[n]*invf[n-m]%mod*invf[m]%mod;
}
ll solve(ll n,ll m,ll k)
{
    ll ans=0;
    for(int i=1;i<n;i++)
        ans=(ans+c(n*m-2,k-2)*(n-i)%mod*m%mod*m%mod*i%mod)%mod;
    return ans;
}
int main()
{
    init();
    scanf("%d%d%d",&n,&m,&k);
    printf("%lld\n",(solve(n,m,k)+solve(m,n,k))%mod);
}


Measured memory_bytes: 3328
N = int(input())
intervals = []
for _ in range(N):
  x, l = map(int, input().split())
  intervals.append((x-l,x+l))

intervals.sort(key=lambda ab: ab[1])
ans = 1
position = intervals[0][1]
for i in range(1,N):
  if position <= intervals[i][0]:
    ans += 1
    position = intervals[i][1]
print(ans)

Measured memory_bytes: 18260
#include <stdio.h>
#include <stdlib.h>

#define WHITE 0
#define GRAY 1
#define BLACK 2
#define MAX_N 100

int n,time,head,tail;
int *queue;
int *dist;
int *color;
int* matrix[MAX_N];

void enqueue(int);
int dequeue(void);
void bfs(void);

int main(){
  int i,j,u,k,v;

  scanf("%d",&n);

  int nn=n+1; 
  queue = malloc(n*n * sizeof(int));
  color = malloc(n * sizeof(int));
  dist = malloc(n * sizeof(int));

  for(i = 0 ; i < n ; i++){
    matrix[i] = malloc(n * sizeof(int));
  }
 for(i = 0 ; i < n ; i++){
   dist[i] = -1;
 }
 for(i = 0 ; i < n ; i++){
   for(j = 0 ; j < n ; j++){
     matrix[i][j] = 0;
   }
 }

 for(i = 0 ; i < n ; i++){
    scanf("%d",&u); u--;
    scanf("%d",&k);
    for(j = 0 ; j < k ; j++){
      scanf("%d",&v); v--;
      matrix[u][v] = 1;
    }
  }

  bfs();
  for(i = 0 ; i < n ; i++){
    printf("%d %d\n",i+1,dist[i]);
  }

  for(i = 0 ; i < n ; i++){
    free(matrix[i]);
  }
  free(queue);
  free(dist);
  free(color);
  return 0;
}

void bfs(){
  int u,i;

  head = tail = 0;
  color[0] = GRAY;
  dist[0] = 0;
  enqueue(0);

  while(head != tail){
    u = dequeue();
    for(i = 0 ; i < n ; i++){
      if(matrix[u][i] == 1 && color[i] == WHITE){
        color[i] = GRAY;
        dist[i] = dist[u] + 1;
        enqueue(i);
      }
    }
    color[u] = BLACK;
  }
}

void enqueue(int q){
  queue[tail] = q;
  if(++tail == n+1) tail = 0;
}

int dequeue(){
  int v = queue[head];
  if(++head == n+1) head = 0;
  return v;
}

Measured memory_bytes: 644
N = gets.to_i
march = [0,0,0,0,0]
N.times do
    s = gets.chomp
    march[0] += 1 if s[0] == "M"
    march[1] += 1 if s[0] == "A"
    march[2] += 1 if s[0] == "R"
    march[3] += 1 if s[0] == "C"
    march[4] += 1 if s[0] == "H"
end
ret = 0
march.combination(3) do |array|
    ret += array[0] * array[1] * array[2]
end
puts ret


Measured memory_bytes: 1788
#include <iostream>
using namespace std;
int main()
{
	string s;
	cin>>s;
	
	int len=s.size();
	string l,r;
	if(len%2==0)
	{
		l=s.substr(0,len/2);
		r=s.substr(len/2,len);
	}else
	{
		l=s.substr(0,(len-1)/2);
		r=s.substr((len-1)/2+1,len);
	}
	
	int nc=0;
	for(int i=0;i<l.size();i++)
	{
		if(l[i]!=r[r.size()-1-i])
			nc++;
	}
	cout<<nc<<endl;
 } 

Measured memory_bytes: 256
//shan61916
#include <bits/stdc++.h>
  using namespace std;
typedef   long long ll;
typedef   unsigned long long ull ;
typedef   double dll ;

#define   mp make_pair
#define   pb push_back
#define   ff first 
#define   ss second
#define   IOS ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define   endl "\n" 
#define   pll pair<ll, ll>
#define   all(x) x.begin(), x.end()
#define   vll vector<ll> 

const ll inf = (ll)(1e17 + 17);
const ll mod = (ll)(1e9 + 7);


int main(){
 IOS
#ifdef SHAN
    freopen("input.txt" , "r" , stdin);  
#endif
  ll a, b, k;
  cin >> a >> b >> k;
  ll tt = min(k, a);
  cout << a - tt << " ";
  ll rem = k - tt;
  cout << max(0LL, b - rem) ;
  return 0;
} //good night.

Measured memory_bytes: 256
package main

import (
	"fmt"
)

func COM(n, k int64) int64 {
	r := int64(1)
	for i := int64(0); i < k; i++ {
		r = ModMul(r, n-i)
		r = ModDiv(r, i+1)
	}

	return r
}

const (
	MOD = 1000000000 + 7
)

func ModAdd(a, b int64) int64 {
	return (a + b) % MOD
}

func ModMul(a, b int64) int64 {
	return a * b % MOD
}

func ModSub(a, b int64) int64 {
	r := (a%MOD - b%MOD) % MOD
	if r < 0 {
		r += MOD
	}
	return r
}

func ModDiv(a, b int64) int64 {
	return a % MOD * ModInv(b) % MOD
}

func ModPow(a, n int64) int64 {
	var r int64 = 1
	for n > 0 {
		if n&1 == 1 {
			r = r * a % MOD
		}
		a = a * a % MOD
		n >>= 1
	}
	return r
}

func ModInv(a int64) int64 {
	var b, u, v int64 = MOD, 1, 0
	for b > 0 {
		t := a / b
		a -= t * b
		a, b = b, a
		u -= t * v
		u, v = v, u
	}
	u %= MOD
	if u < 0 {
		u += MOD
	}
	return u
}

type Q struct {
	value int
	index int
	A, B  int
}

type QS []*Q

func (p QS) Len() int           { return len(p) }
func (p QS) Less(i, j int) bool { return p[i].value > p[j].value }
func (pq QS) Swap(i, j int) {
	pq[i], pq[j] = pq[j], pq[i]
	pq[i].index = i
	pq[j].index = j
}

func (pq *QS) Push(x interface{}) {
	n := len(*pq)
	item := x.(*Q)
	item.index = n
	*pq = append(*pq, item)
}

func (pq *QS) Pop() interface{} {
	old := *pq
	n := len(old)
	item := old[n-1]
	old[n-1] = nil  // avoid memory leak
	item.index = -1 // for safety
	*pq = old[0 : n-1]
	return item
}

func FactoredPrimeNumber(num int) map[int]int {
	m := map[int]int{}
	return factor(m, num, 2)
}

func factor(result map[int]int, num, pnum int) map[int]int {
	if pnum*pnum > num {
		if num != 1 {
			result[num] += 1
		}
		return result
	}

	if num%pnum == 0 {
		num /= pnum
		result[pnum]++
	} else {
		pnum++
	}
	return factor(result, num, pnum)
}

func GCD(a, b int64) int64 {
	if b == 0 {
		return a
	}
	return GCD(b, a%b)
}

func LCM(a, b int64) int64 {
	return a * b / GCD(a, b)
}

func main() {
	var N, M int64
	fmt.Scanf("%d %d\n", &N, &M)
	S := make([]int64, N)
	T := make([]int64, M)
	for i := int64(0); i < N; i++ {
		var v int64
		fmt.Scan(&v)
		S[i] = v
	}
	for i := int64(0); i < M; i++ {
		var v int64
		fmt.Scan(&v)
		T[i] = v
	}
	dp := [2100][2100]int64{}
	for i := int64(0); i <= N; i++ {
		dp[i][0] = 1
	}
	for j := int64(0); j <= M; j++ {
		dp[0][j] = 1
	}

	for i := int64(1); i <= N; i++ {
		for j := int64(1); j <= M; j++ {
			if S[i-1] == T[j-1] {
				dp[i][j] = ModAdd(dp[i][j], dp[i-1][j-1])
			}
			dp[i][j] = ModAdd(dp[i][j], dp[i-1][j])
			dp[i][j] = ModAdd(dp[i][j], dp[i][j-1])
			dp[i][j] = ModSub(dp[i][j], dp[i-1][j-1])
		}
	}
	fmt.Println(dp[N][M])
}

func Reverse(runes []rune) []rune {
	for i, j := 0, len(runes)-1; i < j; i, j = i+1, j-1 {
		runes[i], runes[j] = runes[j], runes[i]
	}
	return runes
}


Measured memory_bytes: 36352
input_data = input()
input_data_list = list(map(int, input_data.split()))
N = input_data_list[0]
A = input_data_list[1]
B = input_data_list[2]
total_sum_digits = 0

for num in range(1, N+1):
    digits_list = [int(digit) for digit in str(num)]
    sum_digits = sum(digits_list)
    if A <= sum_digits <= B:
        total_sum_digits += num

print(total_sum_digits)


Measured memory_bytes: 3060
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstring>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

const int MOD = 1e9 + 7;
const int iINF = 1000000000;
const long long int llINF = 1000000000000000000;

using namespace std;
using ll = long long int;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using vvvl = vector<vector<vector<ll>>>;
using edge = struct {
  int to;
  int cost;
};
#define REP(i, n) for (ll i = 0; i < (n); i++)
#define RREP(i, n) for (ll i = (n)-1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define AUTO(i, m) for (auto &i : m)
#define ALL(a) (a).begin(), (a).end()
#define MAX(vec) *std::max_element(vec.begin(), vec.end())
#define MIN(vec) *std::min_element(vec.begin(), vec.end())
#define ARGMAX(vec)                                                            \
  std::distance(vec.begin(), std::max_element(vec.begin(), vec.end()))
#define ARGMIN(vec)                                                            \
  std::distance(vec.begin(), std::min_element(vec.begin(), vec.end()))
#define BITS(n, num) std::bitset<(n)>((num)).to_string()
#define REV <T> greater<T>()
#define PQ(T) priority_queue<T, vector<T>, greater<T>>
#define VVL(a, b, c) vector<vector<ll>>(a, vector<ll>(b, c))
#define VVVL(a, b, c, d)                                                       \
  vector<vector<vector<ll>>>(a, vector<vector<ll>>(b, vector<ll>(c, d)))

typedef pair<ll, ll> pll;
bool paircomp(const pll &a, const pll &b) {
  if (a.first == b.first)
    return a.second < b.second;
  return a.first < b.first;
}

ll POW(ll n, ll m) {
  if (m == 0) {
    return 1;
  } else if (m % 2 == 0) {
    ll tmp = POW(n, m / 2);
    return (tmp * tmp);
  } else {
    return (n * POW(n, m - 1));
  }
}

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

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ll N;
  string S;
  cin >> S;
  ll ans = 0;
  REP(i, S.size()) {
    bool ok = true;
    ll score = 0;
    FOR(j, i, S.size()) {
      if (ok && (S[j] == 'A' || S[j] == 'T' || S[j] == 'C' || S[j] == 'G')) {
        score++;
      } else {
        ok = false;
      }
    }
    ans = max(score, ans);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define mod (int)(1e9+7)
#define inf (int)(3e18)
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define PP pair<P,P>
#define all(v) v.begin(),v.end()
#define mkp make_pair
#define mkt make_tuple
#define prique(T) priority_queue<T,vector<T>,greater<T>>
#define vecunique(vec) sort(vec.begin(), vec.end());decltype(vec)::iterator result = std::unique(vec.begin(), vec.end());vec.erase(result, vec.end())
using namespace std;
template<class T> inline void chmax(T& a, T b) { a = max(a, b); }
template<class T> inline void chmin(T& a, T b) { a = min(a, b); }

bool prime(int x) {
	for (int i = 2; i * i <= x; i++) {
		if (x % i == 0)return false;
	}
	return x > 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x / gcd(x, y) * y;
}
int kai(int x, int y) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= i; res %= mod;
	}
	return res;
}
int mod_pow(int x, int y, int m) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x, y) * mod_pow(kai(y, y), mod - 2, mod) % mod;
}
int get_rand(int MIN, int MAX) {
	random_device rnd;
	mt19937_64 mt64(rnd());
	uniform_int_distribution<int>engine(MIN, MAX);
	return engine(mt64);
}
/*--------Library Zone!--------*/

string s, t;
int sum1[114514], sum2[114514];
signed main() {
	cin >> s >> t;
	rep(i, s.size()) {
		if (s[i] == 'A')sum1[i]++;
		else sum1[i] += 2;
		sum1[i + 1] += sum1[i];
	}
	rep(i, t.size()) {
		if (t[i] == 'A')sum2[i]++;
		else sum2[i] += 2;
		sum2[i + 1] += sum2[i];
	}
	int n; cin >> n;
	while (n--) {
		int a, b, c, d; cin >> a >> b >> c >> d;
		a--; b--; c--; d--;
		int cnt1 = sum1[b] - (a ? sum1[a - 1] : 0);
		int cnt2 = sum2[d] - (c ? sum2[c - 1] : 0);
		if (cnt1 % 3 != cnt2 % 3)cout << "NO" << endl;
		else cout << "YES" << endl;
	}
}

Measured memory_bytes: 2432
S = input()
if (S.count(S[0]) == 4):
    print("No")
else:
    if (S == S[::-1]):
        print("Yes")
    else:
        if (S[0] == S[1] and S[2] == S[3]) or (S[0] == S[2] and S[1] == S[3]):
            print("Yes")
        else:
            print("No")

Measured memory_bytes: 3060
import qualified Data.ByteString.Char8 as BS
import Data.Maybe

readInt = fromIntegral . fst . fromJust . BS.readInteger

getInt = readInt <$> BS.getLine

createDivision :: Int -> [Int]
createDivision n = 2 : filter (\ x -> x `mod` 2 /= 0) [2 .. divMax]
  where
    divMax = n `div` 2

isPrime :: Int -> [Int] -> Bool
isPrime x [] = True
isPrime x (n : ns)
  | x `mod` n == 0 = False
  | otherwise = isPrime x ns

leastPrime :: Int -> Int
leastPrime x
  | isPrime x (createDivision x) = x
  | otherwise = leastPrime (x + 1)

main = do
  x <- getInt
  if x == 2 then
    print x
  else do
    print $ leastPrime x

Measured memory_bytes: 892
def main():
    N = int(input())
    A, B = [], []
    for _ in range(N):
        a, b = (int(_) for _ in input().split())
        A.append(a)
        B.append(b)
    A = A[::-1]
    B = B[::-1]
    output = 0
    for a, b in zip(A, B):
        if (a+output)%b != 0:
            output += b - (a + output)%b
    print(output)
    return

if __name__ == '__main__':
    main()
    

Measured memory_bytes: 11780
#include<iostream>
#include<cctype>
#include<cstdio>
#include<string>
using namespace std;

string shuffle(string s, int h){
    string t = s.substr(0, h);
    string a = s.substr(h, s.size() - h);
    return a + t;
}

int main(){
    int m, h;
    string card;
    while(1){
        cin >> card;
        if(card == "-")break;

        cin >> m;
        for(int i = 0; i < m; i++){
            cin >> h;
            card = shuffle(card, h);
        }
        cout << card << endl;;
    }
    return 0;
}


Measured memory_bytes: 3172
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b;
    bool c=0;
    cin>>a>>b;
    if(a*b==15)
    {
        cout<<"*";
        c=1;
    }
    if(a+b==15)
    {
        cout<<"+";
        c=1;
    }
    if(c==0)
      cout<<"x";
    return 0;
}

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

int main()
{
  int n, pm, pe, pj;
  while (cin >> n, n){
    for (int i = 0; i < n; i++){
      cin >> pm >> pe >> pj;
      double sum = pm + pe + pj;
      if ((max(pm, max(pe, pj)) == 100) || (pm + pe) / 2 >= 90 || (sum / 3) >= 80){
        cout << 'A';
      }
      else if (sum / 3 >= 70 || (sum / 3 >= 50 && max(pm, pe) >= 80)){
        cout << 'B';
      } 
      else {
        cout << 'C';
      }
      cout << endl;
    }
  }
  return (0);
}

Measured memory_bytes: 1152
#include<iostream>
#include<cstdio>
#include<algorithm>
#define ll long long
#define N 1000010
using namespace std;
int n,m,cnt,ans,mo=1e9+7;
int fac[N],ine[N],f[N];
void add(int &a,int b){a+=b;if(a>=mo)a-=mo;}
int cc(int a,int b)
{
	if(a<0 || b<0 || a<b)return 0;
	return (ll)fac[a]*ine[b]%mo*ine[a-b]%mo;
}
int pw(int i,int k)
{
	int a=1;
	while(k)
	{
		if(k&1)a=(ll)a*i%mo;
		i=(ll)i*i%mo;k>>=1;
	}
	return a;
} 
int main()
{
	int i,s,a,b,j,k;
	scanf("%d",&n);
	for(i=1,fac[0]=ine[0]=1;i<=n;i++)fac[i]=(ll)fac[i-1]*i%mo;
	ine[n]=pw(fac[n],mo-2);
	for(i=n-1;i;i--)ine[i]=(ll)ine[i+1]*(i+1)%mo;
	for(i=1;i<n;i++)f[i]=(ll)cc(i-1,n-i-1)*fac[i]%mo*fac[n-1-i]%mo,add(ans,(ll)(f[i]-f[i-1]+mo)*i%mo);
	printf("%d",ans);
	return 0;
}

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

int main(){
  int n;
  cin >> n;
  ll a[n];
  rep(i,n) cin >> a[i];
  ll ans = 0;
  ll res = 0;
  int r = 0;
  rep(l,n) {
    while(r < n && (a[r] & res) == 0) {
      res ^= a[r++];
    }
    ans += r-l;
    if(r == l) r++;
    else res ^= a[l];
  }
  cout << ans << endl;
  return 0;
}

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

int main(){
  int N;cin>>N;
  bool ok=true;
  int num=0;
  for(int i=0;i<N;++i){
    string st;cin>>st;
    if(st=="A")num++;
    else num--;
    if(num<0)ok=false;
  }
  if(num!=0)ok=false;
  if(ok){
    cout<<"YES"<<endl;
  }else{
    cout<<"NO"<<endl;
  }
}

Measured memory_bytes: 3144
#include <iostream>
#include <map>
#include <vector>
#include <queue>
#include <functional>
#include <algorithm>
#include <cmath>
#include <string>
#define mp make_pair
#define pb push_back

using namespace std;

int board[100][100];
int dx[4] = {-1,0,1,0};
int dy[4] = {0,-1,0,1};

void clear() {
	for (int i = 0; i<100; ++i) {
		for (int j = 0; j<100; ++j) {
			board[i][j] = (j%2 != 0);
		}
	}
}

vector<int> check() {
	vector<int> res;
	res.pb(0);
	res.pb(0);
	bool used[100][100];
	for (int i = 0; i<100; ++i) {
		for (int j = 0; j<100; ++j) {
			used[i][j] = 0;
		}
	}
	for (int i = 0; i<100; ++i) {
		for (int j = 0; j<100; ++j) {
			int type = board[i][j];
			if (!used[i][j]) {
				res[type]++;
				used[i][j] = 1;
				queue<pair<int, int>> q;
				q.push(mp(i,j));
				while (!q.empty()) {
					pair<int, int> cur = q.front();
					q.pop();
					for (int i = 0; i<4; ++i) {
						int nx = cur.first + dx[i];
						int ny = cur.second + dy[i];
						if (nx >= 0 && nx < 100 && ny >= 0 && ny < 100 && !used[nx][ny] && board[nx][ny] == type) {
							used[nx][ny] = 1;
							q.push(mp(nx,ny));
						}
					}
				}
			}
		}
	}
	return res;
}

int solve(int x, int y) {
	int w = 50, b = 50;
	int lx = 3, ly = 0, rx = 3, ry = 99;
	int ld = 1, rd = 98;
	while (w < x || b < y) {
		if (w < x) {
			board[lx][ly] = 1;
			lx += 2;
			w++;
			if (lx == 5 && ly != 0) {
				b--;
			}
			if (lx == 99) {
				lx = 3;
				ly += 2;
			}
		}
		if (b < y) {
			board[rx][ry] = 0;
			rx += 2;
			b++;
			if (rx == 5 && ry != 99) {
				w--;
			}
			if (rx == 99) {
				rx = 3;
				ry -= 2;
			}
		}
	}
	while (w > x || b > y) {
		if (w > x) {
			board[0][ld] = 0;
			w--;
			ld += 2;
		}
		if (b > y) {
			board[99][rd] = 1;
			b--;
			rd -= 2;
		}
	}
}

int main() 
{
	int x, y;
	scanf("%d%d", &x, &y);
	// for (int k = 1; k<=500; ++k) {
	// 	for (int l = 1; l<=500; ++l) {
	// 		clear();
	// 		solve(k,l);
	// 		x = k, y = l;
	// 		vector<int> res = check();
	// 		if (res[0] != x || res[1] != y) {
	// 			printf("WA\nOutput:%d %d\nAnswer:%d %d\n", res[0], res[1], x, y);
	// 			return 0;
	// 		}
	// 		else {
	// 			printf("OK\n");
	// 		}
	// 	}
	// }
	clear();
	solve(x, y);
	vector<int> v = check();
	//printf("%d %d\n", v[0], v[1]);
	printf("100 100\n");
	for (int i = 0; i<100; ++i) {
		for (int j = 0; j<100; ++j) {
	 		if (board[i][j])
	 			printf("#");
	 		else 
	 			printf(".");
	 	}
	 	printf("\n");
	}
	return 0;
}

Measured memory_bytes: 256
def cSort(hoge, k):
    sorted_list = [0] * (len(hoge)-1)
    sorted_list.insert(0, None)
    count_list = [0] * (k+1)
    for i in range(1, len(hoge)):
        count_list[hoge[i]] += 1
    
    for i in range(1, len(count_list)):
        count_list[i] = count_list[i] + count_list[i-1]
    
    for j in range(1, len(hoge))[::-1]:
        sorted_list[count_list[hoge[j]]] = hoge[j]
        count_list[hoge[j]] -= 1
    
    sorted_list.remove(None)
    return sorted_list
    
if __name__ == '__main__':
    _ = input()
    hoge = [int(x) for x in input().split()]
    max_num = max(hoge)
    hoge.insert(0, None)
    print (' '.join([str(x) for x in cSort(hoge, max_num)]))


Measured memory_bytes: 248064
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <functional>
#include <utility>
#include <tuple>
#include <cctype>
#include <bitset>
#include <complex>
#include <cmath>
#include <array>
using namespace std;
#define INF 0x3f3f3f3f
#define INFLL 0x3f3f3f3f3f3f3f3fLL
#define MOD 1000000007
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pint;
typedef pair<ll,ll> pll;
typedef tuple<int,int,int> tint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
int dx[8]={0,0,-1,1,1,1,-1,-1};
int dy[8]={-1,1,0,0,1,-1,1,-1};
const int SIZE=1050;
//ここまでテンプレ
int main(){
	int N;
	cin>>N;
	vll L,R;
	for(int i=0;i<N;i++){
		ll l,r;
		cin>>l>>r;
		L.pb(l);
		R.pb(r);
	}
	ll Loff=0LL,Roff=0LL;
	priority_queue<ll> LQ;
	priority_queue<ll,vector<ll>,greater<ll>> RQ;
	LQ.push(L[0]+Loff);
	RQ.push(L[0]+Roff);
	//傾きがゼロのところのy座標
	ll bot=0LL;
	for(int i=1;i<N;i++){
		//机の幅
		ll NW=R[i]-L[i],RW=R[i-1]-L[i-1];
		//LQに入ってる全部の要素に、前の机の幅を引く
		Loff+=NW;
		//RQに入ってる全部の要素に、今の机の幅を足す
		Roff-=RW;
		//左側の点と右側の点
		ll L0=LQ.top()-Loff,R0=RQ.top()-Roff;
		//現在の机の左端がL0,R0の間にあるとき
		if(L0<=L[i] && L[i]<=R0){
			//botはそのまま
			//LQ,RQに入れる
			LQ.push(L[i]+Loff);
			RQ.push(L[i]+Roff);
		}
		//L0より左にあるとき
		else if(L[i]<L0){
			//botを増やす
			bot+=L0-L[i];
			//LQの一番前のやつをRQに入れる
			RQ.push(L0+Roff);
			//LQからpopする
			LQ.pop();
			//LQに二つ入れる
			LQ.push(L[i]+Loff);
			LQ.push(L[i]+Loff);
		}
		//R0より右にあるとき
		else{
			//botを増やす
			bot+=L[i]-R0;
			//RQの一番前のやつをLQに入れる
			LQ.push(R0+Loff);
			//RQからpopする
			RQ.pop();
			//RQに二つ入れる
			RQ.push(L[i]+Roff);
			RQ.push(L[i]+Roff);
		}
	}
	cout<<bot<<endl;
	return 0;
}

Measured memory_bytes: 4844
import math
N = int(input())

if math.floor(math.floor(N/1.08) * 1.08) == N:
    print(math.floor(N/1.08))
    exit()
if math.floor((math.floor(N/1.08)+1) * 1.08) == N:
    print(math.floor(N/1.08)+1)
    exit()
print(":(")

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

int main(void){
    int n;
    int ans = 0;
    std::cin >> n;
    int cur;
    std::vector<int> h(n);
    for(int i = 0; i < n; i++){
        std::cin >> h[i];
    }
    int tmp_cnt = 0;
    for(int i = 1; i < n; i++){
        if(h[i] <= h[i-1]){
            tmp_cnt++;
        }else{
            tmp_cnt = 0;
        }
        ans = std::max(ans, tmp_cnt);
    }
    std::cout << ans << std::endl;
    return 0;
}

Measured memory_bytes: 3712
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;
const ll inf = numeric_limits<ll>::max()/3;
const ll mod = 998244353;

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


Measured memory_bytes: 256
#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++)
typedef long long ll;

int main() {
  int x, a;
  cin >> x >> a;
  if (x < a) {
    cout << 0;
  } else {
    cout << 10;
  }
  cout << endl;
}


Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<cstring>

using namespace std;

int a, b, c, d,sum = 0;
int vis[1000] = {};
int main()
{
	scanf("%d%d%d%d", &a, &b, &c, &d);
	if(a < b) vis[1] = a;
	else vis[1] = b;
	if(c < d) vis[2] = c;
	else vis[2] = d;
	sum = vis[1] + vis[2];
	printf("%d\n",sum);
	return 0;
}

Measured memory_bytes: 256
(unless (member :child-sbcl *features*)
  (quit
   :unix-status
   (process-exit-code
    (run-program *runtime-pathname*
                 `("--control-stack-size" "128MB"
                   "--noinform" "--disable-ldb" "--lose-on-corruption" "--end-runtime-options"
                   "--eval" "(push :child-sbcl *features*)"
                   "--script" ,(namestring *load-pathname*))
                 :output t :error t :input t))))
 
(defvar *n* (read))
(defvar *in* (make-array (list *n* 3) :initial-element nil))
 
(dotimes (i *n*)
  (dotimes (j 3)
    (setf (aref *in* i j) (read))
    ))
 
;dp[i][j]→i日目に行動jを行うときの最大幸福度
(defvar *dp* (make-array (list *n* 3) :initial-element -1))
 
(defun ans (i j)
  (cond
    ((< i 0) 0)
    ((<= 0 (aref *dp* i j)) (aref *dp* i j))
    (t (setf (aref *dp* i j) (max
                              (if (equal j 0) 0 (+ (ans (1- i) 0) (aref *in* i j)))
                              (if (equal j 1) 0 (+ (ans (1- i) 1) (aref *in* i j)))
                              (if (equal j 2) 0 (+ (ans (1- i) 2) (aref *in* i j)))
                              )))
    ))
  
(print (max (ans (1- *n*) 0) (ans (1- *n*) 1) (ans (1- *n*) 2)))

Measured memory_bytes: 70648
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr int Inf = 1000000000;
constexpr ll INF= 1e18;
constexpr ll MOD = 1000000007;
const double PI = 3.1415926535897;
typedef pair<ll,int> P;

int main() {
    int N,M,Q;
    cin >> N >> M >> Q;
    vector<vector<int>> vec(N + 1,vector<int>(N + 1));
    for(int i = 0;i < M;i++) {
        int A,B;
        cin >> A >> B;
        vec.at(A).at(B)++;
    }
    for(int i = 0;i < N;i++) {
        for(int j = 0;j < N;j++) {
            vec.at(i + 1).at(j + 1) = vec.at(i).at(j + 1) + vec.at(i + 1).at(j) - vec.at(i).at(j) + vec.at(i + 1).at(j + 1);
        }
    }
    for(int i = 0;i < Q;i++) {
        int A,B;
        cin >> A >> B;
        cout << vec.at(B).at(B) - vec.at(A - 1).at(B) - vec.at(B).at(A - 1) + vec.at(A - 1).at(A - 1) << endl;
    }
}

Measured memory_bytes: 1920
#include<stdio.h>  
    main(){  
      int d,b,e=0;  
      int c,a,n;  
      scanf("%d",&d);  
      for(b=0;b<d;b++){  
        scanf("%d %d %d",&c,&a,&n);  
        while(1){  
          if((c>=1&&a>=1)&&n>=1){  
          e=e+1;  
          c=c-1;  
          a=a-1;  
          n=n-1;  
          }  
          else if(c>=2&&a>=1){  
        e=e+1;  
        c=c-2;  
        a=a-1;  
          }  
          else if(c>=3){  
        e=e+1;  
        c=c-3;  
          }  
          else{  
        break;  
          }  
        }  
        printf("%d\n",e);  
        e=0;  
      }  
      return 0;  
    }  

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

public class Main {

	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int a=sc.nextInt();
		int b=sc.nextInt();
		int c=sc.nextInt();
		int k=sc.nextInt();
		if(k<=a)
			System.out.println(k);
		else if(k>a&&k<=a+b)
			System.out.println(a);
		else
			System.out.println(a-(k-a-b));
	}

	static class Pair {
		int x;
		int y;

		public Pair(int x, int y) {
			this.x = x;
			this.y = y;
		}

	}

	static class Scanner {
		StringTokenizer st;
		BufferedReader br;

		public Scanner(InputStream s) {
			br = new BufferedReader(new InputStreamReader(s));
		}

		public Scanner(String file) throws FileNotFoundException {
			br = new BufferedReader(new FileReader(file));
		}

		public String next() throws IOException {
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}

		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}

		public long nextLong() throws IOException {
			return Long.parseLong(next());
		}

		public String nextLine() throws IOException {
			return br.readLine();
		}

		public double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}

		public boolean ready() throws IOException {
			return br.ready();
		}

	}
}


Measured memory_bytes: 32864
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(n) for (ll i = 0; i < n; ++i)
#define rep2(i, n) for (ll i = 0; i < n; ++i)
#define rep3(i, a, b) for (ll i = a; i < b; ++i)
#define rep4(i, a, b, c) for (ll i = a; i < b; i += c)
#define erep(n) for (ll i = 0; i <= n; ++i)
#define erep2(i, n) for (ll i = 0; i <= n; ++i)
#define erep3(i, a, b) for (ll i = a; i <= b; ++i)
#define erep4(i, a, b, c) for (ll i = a; i <= b; i += c)
#define rrep(i, a, b) for (ll i = a; i > b; --i)
#define rrep2(i, a, b, c) for (ll i = a; i > b; i -= c)
#define errep(i, a, b) for (ll i = a; i >= b; --i)
#define errep2(i, a, b, c) for (ll i = a; i >= b; i -= c)
#define print(a) cout << a << endl;
#define printVec(v) printf("{"); for (const auto& i : v) { std::cout << i << ", "; } printf("}\n");
#define cin(x) cin >> x;
const ll MOD = 1000000007;
const double PI = 3.14159265358979323846264338327950;
inline int newline() { putchar('\n'); return 0; }

int main() {
    rep2(i, 5) {
        ll temp;
        cin(temp);
        if (temp == 0) {
            print(i + 1);
            return 0;
        }
    }
    return 0;
}

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

      int a,b,c,i,j,d,e,f,g,h,k,l,m,n,o,p,q,r,s,t=0,u=0,v1=0,w=0,x=0,y=0,z=0,z1=0;
      vector<int> v;
      cin>>a>>b>>c;
      cin>>d>>e>>f;
      cin>>g>>h>>i;
      cin>>j;
      while(j--){
        cin>>k;
        v.push_back(k);
      }
      for(m=0;m<v.size();m++){
         if(v[m]==a || v[m]==b || v[m]==c)
            t++;
        if(v[m]==d || v[m]==e || v[m]==f)
            u++;
        if(v[m]==g || v[m]==h || v[m]==i)
            v1++;
        if(v[m]==a || v[m]==d || v[m]==g)
            w++;
        if(v[m]==b || v[m]==e || v[m]==h)
            x++;
        if(v[m]==c || v[m]==f || v[m]==i)
            y++;
        if(v[m]==a || v[m]==e || v[m]==i)
            z++;
        if(v[m]==c || v[m]==e || v[m]==g)
            z1++;

      }
      if(t>=3 || u>=3 ||v1>=3 ||w>=3 ||x>=3 ||y>=3 ||z>=3 ||z1>=3)
      cout<<"Yes"<<endl;
      else cout<<"No"<<endl;
      v.clear();


    return 0;
}


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

int main() {
    int n;
    cin >> n;
    int num[n];
    for (int i=0; i < n; i++) {
        cin >> num[i];
    }
    for (int i=n-1; i > 0; i--){
        cout << num[i] << " ";
    }
    cout << num[0] << endl;
    return 0;
}


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

int main() {
    int x, y;
    cin >> x >> y;
    //グループごとに番号を振っている
    int a[13] = {0, 1, 3, 1, 2, 1, 2, 1, 1, 2, 1, 2, 1};

    if (a[x] == a[y]) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 256