akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
	    
	    
	    using namespace std;
	
	    #define ll long long
	    #define do double
	    #define ff first
	    #define ss second
	    #define FOR(a,n) for(i=0;i<n;i++){    cin>>a[i];}
	    #define pb push_back
	    #define mp make_pair
	    #define inf LONG_LONG_MAX
	    #define mod  1000000007
	    #define FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	
	    

	ll d,x,y;
	void extendedEuclid(ll A, ll B) 
	{
	    if(B == 0) {
	        d = A;
	        x = 1;
	        y = 0;
	    }
	    else {
	        extendedEuclid(B, A%B);
	        int temp = x;
	        x = y;
	        y = temp - (A/B)*y;
	    }
	}

	ll power(ll x,ll y, ll p) 
	{ 
	    ll res = 1; 
	    x = x % p;
	    while (y > 0) 
	    {  // If y is odd, multiply x with result 
	        if (y & 1) 
	            res = (res*x) % p;
	            
	        y = y>>1; 
	        x = (x*x) % p;   
	    } 
	    return res; 
	} 
	ll isPrime(ll n)
	        {
	            
	           if(n==0 || n==1)
	           return 0;
	            if (n%2 == 0) 
	                return 2;
	            
	            if(n%3==0)
	                return 3;
	         
	            for (ll i=5; i*i<=n; i=i+6)
	            {
	                if (n%i == 0)
	                   return i;
	                if (n%(i+2) == 0)
	                   return i+2;
	            }
	            
	            return n;
	        }



map<ll,ll> par,val;
void ini()
{
	for(ll i=0;i<500010;i++)
		{
			par[i]=i;
		}
}

ll root(ll x)
{
	while(par[x]!=x)
	{
		par[x]=par[par[x]];
		x=par[x];
	}
	return x;
}

void uni(ll x,ll y)
{
	x=root(x);
	y=root(y);
	if(val[x]<=val[y])
		par[y]=par[x];
	else
		par[x]=par[y];
	
}
vector<vector<pair<ll,ll> > > v(200010);
vector<ll> ans;
map<ll,ll> vis,dis;

ll bfs(ll n)
{
	vis[1]=1;
	dis[1]=0;
	ll f=0,i;
	queue<ll> q;
	q.push(1);
	ll ans=0;
	while(q.size()>0)
	{
		ll x=q.front();
		q.pop();
		for(i=0;i<v[x].size();i++)
		{
			if(!vis[v[x][i].ff])
			{
				dis[v[x][i].ff]=dis[x]+v[x][i].ss;
				ans=max(ans,dis[v[x][i].ff]);
				q.push(v[x][i].ff);
				vis[v[x][i].ff]=1;
			}
		}
	}
	return ans;
}
vector<ll> a(1000000);
vector<ll> spf(1000000);
void sieve()
{
	ll i,j;
	bool prime[1000000];
	memset(prime, true, sizeof(prime));
	prime[0]=prime[1]=false; 
	for(i=2;i*i<=1000000;i++)
	{
		if(prime[i]==true)
		{
			for(j=i*i;j<=100000;j+=i)
			{
				prime[j]=false;
				if(spf[j]==0)
					spf[j]=i;
			}
		}
	}
}

int gcdExtended(int a, int b, int *x, int *y) 
{ 

    if (a == 0) 
    { 
        *x = 0, *y = 1; 
        return b; 
    } 
    int x1, y1;
    int gcd = gcdExtended(b%a, a, &x1, &y1); 
    *x = y1 - (b/a) * x1; 
    *y = x1;
    return gcd; 
}  
int modInverse(int b, int m) 
{ 
    int x, y; 
    int g = gcdExtended(b, m, &x, &y); 
    if (g != 1) 
        return -1; 
    return (x%m + m) % m; 
} 

int main()
{
		FAST;
		ll n,m,k,i,j,h;
		ll t;
		ll a[3];
		for(i=0;i<3;i++)
			cin>>a[i];
		sort(a,a+3);
		cout<<a[0]+a[1];
		
}

Measured memory_bytes: 20608
import java.util.Scanner;

//Make Purse Light
public class Main {

	public static int minCoin;
	public static int[] coins;
	public static int[] used;
	public static int[] ans;

	public static int returnCoin(int x){
		int s = 0;
		s += x/500;
		x %= 500;
		s += x/100;
		x %= 100;
		s += x/50;
		x %= 50;
		s += x/10;
		return s;
	}

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		boolean first = true;
		while(true){
			int x = sc.nextInt();
			if(x==0)break;
			if(!first)System.out.println();
			first = false;
			minCoin = Integer.MAX_VALUE;
			coins = new int[4];
			int num = 0;
			for(int i=0;i<4;i++){
				coins[i] = sc.nextInt();
				num += coins[i];
			}
			used = new int[4];
			ans = new int[4];
			for(used[0]=0;used[0]<=coins[0];used[0]++){
				for(used[1]=0;used[1]<=coins[1];used[1]++){
					for(used[2]=0;used[2]<=coins[2];used[2]++){
						for(used[3]=0;used[3]<=coins[3];used[3]++){
							int sum = used[0]*10 + used[1]*50 + used[2]*100 + used[3]*500;
							if(sum >= x && num-(used[0]+used[1]+used[2]+used[3])+returnCoin(sum-x)<minCoin){
								minCoin = num-(used[0]+used[1]+used[2]+used[3])+returnCoin(sum-x);
								for(int i=0;i<4;i++)ans[i]=used[i];
							}
						}
					}
				}
			}
			for(int i=0;i<4;i++){
				if(ans[i]!=0){
					System.out.println((i==0?10:i==1?50:i==2?100:500) + " " + ans[i]);
				}
			}
		}
	}
}

Measured memory_bytes: 12000
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(ll i = 0; i < (n); ++i)
#define repA(i, a, n) for(int  i = a; i <= (n); ++i)
#define all(x) x.begin(), x.end()
#define sz(x) (int) (x).size()
#define fill(a) memset(a, 0, sizeof(a))
#define fst first
#define snd second
#define mp make_pair
#define pb push_back
#define endl '\n'
#define init(n) int n;cin>>n;int a[n];rep(i,n)cin>>a[i];
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<long long int> vll;
typedef vector<pii> vii;
const ll INF=1e18 + 5;
ll p=1000000007;
const int N = 2*(1e5)+5;
ll fac[N];
ll invr[N];
ll power(ll x,ll y){
    ll res=1;

    while(y>0){
        if(y&1){
            res=res*x;res%=p;
        }
        y=y/2;x=x*x;x%=p;

    }

    return res;
}
ll invrse(ll r){
    return power(r,p-2);
}
ll binomial(ll n,ll r){
    if(n<0||r<0||n<r)return 0;
    return ((fac[n]*invr[r])%p*invr[n-r])%p;
}
int main() {
    // #ifndef ONLINE_JUDGE
    // freopen("input.txt", "r", stdin);   
    // freopen("output.txt", "w", stdout);
    // #endif
    cin.sync_with_stdio(0); cin.tie(0);
    cin.exceptions(cin.failbit);
    ll h,w,n;cin>>h>>w>>n;
    vector<pair<int,int> > ob(n+1);
    rep(i,n)cin>>ob[i].fst>>ob[i].snd;
    ob[n]=mp(h,w);
    sort(ob.begin(),ob.end());
    fac[0]=1;
    memset(invr,-1,sizeof(invr));
    invr[0]=1;
    repA(i,1,N){
        fac[i]=(fac[i-1]*i)%p;
        invr[i]=invrse(fac[i])%p;
    }
    ll dp[n+1];
    for(int i=0;i<=n;i++){
        // cout<<ob[i].fst<<endl;
        dp[i]=binomial(ob[i].fst+ob[i].snd-2,ob[i].snd-1);
        dp[i]%=p;
        for(int j=0;j<i;j++){
            ll l=ob[i].fst-ob[j].fst;
            ll r=ob[i].snd-ob[j].snd;
            dp[i]-=(dp[j]*binomial(l+r,l))%p;
            dp[i]=(dp[i]+p)%p;
        }
    }
    cout<<dp[n];
    return 0;
}

Measured memory_bytes: 3456
/**
 *    author:  otera    
**/
#include<iostream>
#include<string> 
#include<cstdio>
#include<cstring>
#include<vector>
#include<cmath>
#include<algorithm> 
#include<functional>
#include<iomanip>
#include<queue>
#include<deque>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;

#define int long long
typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef long double ld;
const int inf=1e9+7;
const ll INF=1LL<<60 ;
const ll mod=1e9+7 ;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<int, int> P;
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
#define debug(x)  cerr << #x << " = " << (x) << endl;
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; }

int n;
vector<int> a;

void solve() {
	cin >> n;
    a.resize(n);
    rep(i, n) {
        cin >> a[i];
    }
    map<int, int> mp;
    int ans = 0;
    rep(i, n) {
        ans += mp[a[i] - i];
        mp[-a[i] - i] ++;
    }
    cout << ans << endl;
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(10);
	//int t; cin >> t; rep(i, t)solve();
	solve();
    return 0;
}

Measured memory_bytes: 27332
#!usr/bin/env python3

import sys


def string_to_list_spliter():
    n = sys.stdin.readline()
    lst = [int(i) for i in sys.stdin.readline().split()]
    return lst


def main():
    lst = string_to_list_spliter()
    print(min(lst), max(lst), sum(lst))


if __name__ == '__main__':
    main()

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

typedef long long ll;
constexpr ll MOD = 1000000007;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ALL(a) begin(a),end(a)
#define COUNTOF(a) (sizeof(a)/sizeof(a[0]))
#define SP << " " <<
#define FMT(a) #a<<":"<<a 
#define FMT2(a,b) #a<<":"<<a<<", "<<#b<<":"<<b 
#define FMT3(a,b,c) #a<<":"<<a<<", "<<#b<<":"<<b<<", "<<#c<<":"<<c 
#define FMT4(a,b,c,d) #a<<":"<<a<<", "<<#b<<":"<<b<<", "<<#c<<":"<<c<<", "<<#d<<":"<<d 
template<class T> istream& operator >> (istream& s, vector<T>& v) {
  for (T& x: v) s >> x;
  return s;
}
void yes(bool f){cout<<(f?"yes":"no")<<endl;}
void Yes(bool f){cout<<(f?"Yes":"No")<<endl;}
void YES(bool f){cout<<(f?"YES":"NO")<<endl;}
#define ANS(a) cout<<a<<endl


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

    int N,M; cin >>N>>M;
    vector<int> a(N),b(N),c(M),d(M);
    rep(i,N) { cin>>a[i]>>b[i]; }    
    rep(i,M) { cin>>c[i]>>d[i]; }    

    rep(i,N) {
        int min_dist = INT_MAX;
        int cp;
        rep(j,M) {
            int dist = abs(a[i] - c[j]) + abs(b[i] - d[j]);
            if (dist < min_dist) {
                min_dist = dist;
                cp = j + 1;
            }
        }
        cout << cp << endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, a, n) for (long long i = (a); i < (long long)(n); ++i)
#define REPC(i, a, n) for (long long i = (a); i <= (long long)(n); ++i)
#define ALL(t) t.begin(), t.end()
#define RALL(t) t.rbegin(), t.rend()
#define MATINIT(type, row, col, init)                                          \
  vector<vector<type>>(row, vector<type>(col, init));
#define Yes(cond) cout << (cond ? "Yes" : "No") << endl;
#define YES(cond) cout << (cond ? "YES" : "NO") << endl;
using namespace std;
using LL = long long;
using ULL = unsigned long long;
template <class T> using VEC = std::vector<T>;
template <class T> using MAT = std::vector<std::vector<T>>;
void DUMP() { cerr << endl; }
template <class Head, class... Tail> void DUMP(Head &&head, Tail &&... tail) {
  cerr << head << ", ";
  DUMP(std::move(tail)...);
}
template <typename T> ostream &operator<<(ostream &os, vector<T> &vec) {
  os << "{";
  for (auto v : vec)
    os << v << ",";
  os << "}";
  return os;
}
template <typename T> ostream &operator<<(ostream &os, set<T> &s) {
  os << "{";
  for (auto p : s)
    os << p << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, map<T1, T2> &m) {
  os << "{";
  for (auto p : m)
    os << p << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, pair<T1, T2> p) {
  os << "[" << p.first << " " << p.second << "]";
  return os;
}

int main() {
  int N;
  cin>>N;
  cout<<N*N*N<<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 MOD 1000000007
#define el endl
#define INF 1e7
#define LINF 1e15
typedef long long ll;
typedef long double ld;
// 'a' = 97 'z' = 122 => 'a' = 0 'z' = 25


int main() {
    string s;
    int q;
    cin >> s >> q;
    bool rev = false;
    rep(i, q){
        int t; cin >> t;
        if(t == 1){
            if(rev){
                rev = false;
            }else{
                rev = true;
            }
        }else{
            int f; cin >> f;
            string c; cin >> c;
            if(f == 1){
                if(rev){
                    s += c;
                }else{
                    s.insert(0, c);
                }
            }else{
                if(rev){
                    s.insert(0, c);
                }else{
                    s += c;
                }
            }
        }
    }
    if(rev){
        reverse(s.begin(), s.end());
    }
    cout << s << endl;
}




Measured memory_bytes: 900
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;

/*
 <url:https://cf17-final-open.contest.atcoder.jp/tasks/cf17_final_c>
 問題文============================================================
 XXXX年のCODE FESTIVALには、世界中から高橋君を含めて N+1 人の参加者が集まりました。
 
 高橋君の都市と他の N 人の都市の時刻の差を調べてみたところ、i 番目の人の都市との時刻の差は Di 時間でした。
 ただし 2 つの都市について、片方の都市で 0 時の瞬間にもう一方の都市で d 時であるようなとき、
 これらの都市の時刻の差は min(d,24−d) であるものとします。
 ここで、時刻の表記には 24 時間表記を用いるものとします。
 つまり、例えば高橋君の都市で 0 時の瞬間には i 番目の人の都市は Di 時または 24−Di 時のいずれかとなります。
 
 高橋君は次に、N+1 人のうちの全ての 2 人組についてその人の都市どうしの時刻の差を書き出し、
 それらの時刻の差のうちの最小値を s としました。
 
 s として考えられる最大値を求めて下さい。
 =================================================================
 
 解説=============================================================
 
 高橋君を 0時とすることを最初に確定しておく。
 時差をソートしておき、順番に時間を見て行った時、
 おく時の選択は D[i] or 24 - D[i] となる
 
 ここで、その二つの選択に関して、それまでに確定した時間との差の最小値をそれぞれ見て行き、
 差が大きい選択をその都市の時間とすれば良い
 （ソートされているので時間は必ず　0 -> 12 or 24 -> 12 で埋まって行く）
 
 
 解説を確認したところ
 この選択方法は
     D[i] と 24-D[i] を交互に選択した場合と同義になる。（確かにそれは、そう）
 
 ================================================================
 */
ll solve(){
    ll ret = INF;
    ll N; cin >> N;
    vector<ll> D(N);
    for(auto& in:D) cin >> in;
    sort(D.begin(),D.end());
    vector<ll> t; t.push_back(0);
    for(int i = 0; i < N;i++){
        ret = min(ret,D[i]);
        
        ll t1 = D[i],t2 = 24 - D[i];
        ll dif1 = INF, dif2 = INF;
        for(auto T:t){
            dif1 = min(dif1,min(abs(t1-T),abs(24+t1-T)));
            dif2 = min(dif2,min(abs(t2-T),abs(24+t2-T)));
        }
        ret = min(ret,max(dif1,dif2));
        if(dif1 > dif2){
            t.push_back(t1);
        }else{
            t.push_back(t2);
        }
    }
    return ret;
}

ll solve_2(){
    ll ret = INF;
    ll N; cin >> N;
    vector<ll> D(N);
    for(auto& in:D) cin >> in;
    sort(D.begin(),D.end());
    vector<ll> t; t.push_back(0);
    for(int i = 0; i < N;i++){
        if(i%2 == 0){
            t.push_back(D[i]);
        }else{
            t.push_back(24-D[i]);
        }
    }
    for(int i = 0; i <= N;i++){
        for(int j = i+1; j <= N;j++){
            ret = min(ret,abs(t[i]-t[j]));
        }
    }
    return ret;
}

int main(void) {
    cin.tie(0); ios::sync_with_stdio(false);
    cout << solve() << endl;
    return 0;
}


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

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

    ll ans = 1e18;
    for (int n = 1; n < N - 2; n++) {
        int pq = lower_bound(A.begin(), A.end(), (A[n] + 1) / 2) - A.begin();
        ll P = A[pq];
        ll Q = A[n] - A[pq];
        if (pq > 0 && abs(P - Q) > abs(A[pq - 1] - A[n] + A[pq - 1])) {
            P = A[pq - 1];
            Q = A[n] - A[pq - 1];
        }

        ll d = A[N - 1] - A[n];
        int rs = lower_bound(A.begin(), A.end(), A[n] + (d + 1) / 2) - A.begin();
        ll R = A[rs] - A[n];
        ll S = A[N - 1] - A[rs];
        if (rs > n + 1 && abs(R - S) > abs(A[rs - 1] - A[n] - A[N - 1] + A[rs - 1])) {
            R = A[rs - 1] - A[n];
            S = A[N - 1] - A[rs - 1];
        }

        ans = min(max({P, Q, R, S}) - min({P, Q, R, S}), ans);
    }
    cout << ans << endl;
}


Measured memory_bytes: 1792
s = int(input())
soFar = [s]
i = 1
while True:
    i += 1
    if s % 2 == 0:
        s = s / 2
    else:
        s = 3 * s + 1
    if s in soFar:
        print(i)
        break
    soFar.append(s)


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
#define REP(i,x,n) for(int i=x;i<(int)n;i++)
#define rep(i,n) REP(i,0,n)
#define sp(p) cout<<setprecision(16)<<fixed<<p<<endl;
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define SORT(a) sort(all(a))
#define RSORT(a) sort(rall(a))
#define UNIQ(a) unique(all(a))
#define UNIQNUM(a) UNIQ(a)-a.begin()
#define UNIQIT(a) a.erase(UNIQ(a), a.end());
#define VOUT(v,i) cout<<#v<<": ";for(int i=0;i<(int)v.size();i++){cout<<v[i]<<" ";}cout<<"\n";
#define vout(v) VOUT(v,z);
#define vmin(v) *min_element(all(v))
#define vmax(v) *max_element(all(v))
#define vsum(v) accumulate(all(v), 0LL);
#define MOUT(m,r,c) rep(i,r){rep(j,c){cout<<m[i][j]<<" ";}cout<<endl;}
#define mout(m) MOUT(m,m.size(),m[0].size())
#define debg(a) cout<<#a<<": "<<a<<endl;
#define show(a) for(cont &y:a){for(cont &x:y){cout<<x<<" ";}cout<<endl;}
#define digit(a) to_string(a).length();
template<class T>inline int out(const T &t){ print(t); putchar('\n'); return 0; }
template<class T>inline T gcd(T a,T b){if(b==0)return a; return(gcd(b,a%b));}
template<class T>inline T lcm(T a,T b){return a/gcd(a,b)*b;}
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef vector<ll> V;
// const long long MOD=1000000007;
const long long INF = 1e18;
#define EPS (1e-7)
#define PI (acos(-1))
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) { a = b; return true; }
    return false;
}
template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) { a = b; return true; }
    return false;
}


void solve(long long H){
    ll ex=floor(log2(H))+1;
    ll ret=pow(2,ex)-1;
    cout << ret << "\n";
}

int main(){
    long long H;
    scanf("%lld",&H);
    solve(H);
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long ll;
ll dp[11][111][1111];
ll solve(int m,int k,int s){
  if(!m) return s?0:1;
  if(s < k) return 0;
  if(k > 100) return 0;
  if(dp[m][k][s] >= 0) return dp[m][k][s];
  ll ret = solve(m,k+1,s);
  if(m && s >= k) ret += solve(m-1,k+1,s-k);
  return dp[m][k][s] = ret;
}
int main(void){
  memset(dp,-1,sizeof(dp));
  int n,s;
  while(cin >> n >> s && n){
    cout << solve(n,0,s) << endl;
  }
}

Measured memory_bytes: 11764
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
int n,k,r,s,p;

int main(){
    
    string t;
    cin >> n >> k >> r >> s >> p; //r:'r' s:'s' p:'p'
    cin >> t;
    vector<string> x(k,"");
    for(int i=0;i<n;i++){
        x[i%k] += t[i];
    }
    int ans = 0;

    for(int i=0;i<x.size();i++){
        if(x[i].size() == 0) continue;
        if(x[i][0] == 'r'){
            ans += p;
        }else if(x[i][0] == 's'){
            ans += r;
        }else{
            ans += s;
        }
        bool last = true;
        for(int j = 1;j<x[i].size();j++){
            if(x[i][j] == x[i][j-1] && last == true) {last = false; continue;}
            if(x[i][j] == 'r'){
                ans += p;
                last = true;
            }else if(x[i][j] == 's'){
                ans += r;
                last = true;
            }else{
                ans += s;
                last = true;
            }
        }        
    }
    cout << ans << endl;
}

Measured memory_bytes: 5120
#include<bits/stdc++.h>
using namespace std;
#define ll long long                                    // long long省略
#define pb push_back                                    // push_back省略
#define mp make_pair                                    // make_pair省略
#define fi first                                        // first省略
#define se second                                       // second省略
#define itn int                                         // int誤字保険
#define count cout                                      // cout誤字保険
#define vecotr vector                                   // vector誤字保険
#define ednl endl                                       // endl誤字保険
#define opt() cin.tie(0); ios::sync_with_stdio(false)   // 入出力速度改善

#define rep(i,l,r) for(ll i=(l);i<(r);i++)               // 範囲[l, r)で刻み1のfor文(順方向)
#define repp(i,l,r,k) for(ll i=(l);i<(r);i+=(k))         // 範囲[l, r)で刻みkのfor文(順方向)
#define rrep(i,l,r) for(ll i=(r-1);i>=(l);i--)           // 範囲[l, r)で刻み1のfor文(逆方向)
#define rrepp(i,l,r,k) for(ll i=(r-1);i>=(l);i-=(k))     // 範囲[l, r)で刻みkのfor文(逆方向)
#define all(x) (x).begin(), (x).end()                   // vectorのポインタ位置指定用
#define max(p,q)((p)>(q)?(p):(q))                       // max拡張
#define min(p,q)((p)<(q)?(p):(q))                       // min拡張
#define bit(n,m)(((n)>>(m))&1)                          // 変数nのm番目のbitを取り出す

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int dy[]={0, 1, 0, -1};                                 // 4方向近傍
int dx[]={1, 0, -1, 0};                                 // 4方向近傍

int main(){
    ll n;cin>>n;
    cout << (n/100 == n%10 ? "Yes" : "No") << ednl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <vector>

int main() {
  std::vector<std::vector<int>> c(3, std::vector<int>(3));
  auto d = c;
  for (int i = 0; i < 3; ++i)
    for (int j = 0; j < 3; ++j) {
      scanf("%d", &c[i][j]);
      d[j][i] = c[i][j];
    }

  for (int i = 0; i < 3; ++i) {
    for (int j: std::vector<int>{1, 2, 0}) {
      c[i][j] -= c[i][0];
      d[i][j] -= d[i][0];
    }
  }

  bool valid = true;
  {
    if (c[0] != c[1] || c[0] != c[2]) valid = false;
    if (d[0] != d[1] || d[0] != d[2]) valid = false;
  }
  puts(valid? "Yes":"No");
}

Measured memory_bytes: 504
#include<iostream>
#include<cmath>
#include<iomanip>

int main(){
    int i,n;
    double D_1,D_2,D_3,D_inf;
    D_1=0;
    D_2=0;
    D_3=0;
    D_inf=0;
    std::cin>>n;
    double x[100],y[100],abs[100];

    //データをそれぞれ読み込む
    for(i=0;i<n;i++){
        std::cin>>x[i];
    }
    for(i=0;i<n;i++){
        std::cin>>y[i];
        abs[i]=std::abs(x[i]-y[i]);
    }

    for(i=0;i<n;i++){
        D_1+=abs[i];
        D_2+=pow(abs[i],2);
        D_3+=pow(abs[i],3);
        if(abs[i]>D_inf){
            D_inf=abs[i];
        }
    }

    D_2=sqrt(D_2);
    D_3=cbrt(D_3);

    std::cout<<std::fixed;
    std::cout<<std::setprecision(5)<<D_1<<std::endl;
    std::cout<<std::setprecision(5)<<D_2<<std::endl;
    std::cout<<std::setprecision(5)<<D_3<<std::endl;
    std::cout<<std::setprecision(5)<<D_inf<<std::endl;
 
    return 0;
}



Measured memory_bytes: 3488
#include <iostream>
#include <string>
#include <cstdint>
#include <algorithm>
#include <cmath>
#include <vector>
#include <unordered_map>


int main()
{
	int val[] = { 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51 };
	int index;
	std::cin >> index;

	std::cout << val[index - 1] << std::endl;
	
	return 0;
}

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

using namespace std;

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

    if (n == 1)
    {
        cout <<  "1";
    } else if (n % 2 == 0) {
        cout << "0.5";
    } else {
        cout << (float)((n/2) + 1)/n;
    }
}


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

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

    for(int i=0; i<H; i++){
        if(i == 0){
            for(int j=0; j<W+2; j++){
                cout << '#';
            }
            cout << endl;
        }
        
        cin >> a;
        cout << '#' << a << '#' << endl;
        
        if(i == H-1){
            for(int j=0; j<W+2; j++){
                cout << '#';
            }
            cout << endl;
        }
    }
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for(int i = 0; (i) < (n); (i)++)
#define FOR(i, m, n) for(int i = (m); (i) < (n); (i)++)
#define All(v) (v).begin(), (v).end()
#define MP make_pair
#define pb push_back
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1 << 30;
const ll LINF = 1LL << 61;
const int MOD = 1e9 + 7;

//素因数分解
map<int64_t, ll> prime_factor(int64_t n) {
    map<int64_t, ll> ret;
    for(int64_t i = 2; i * i <= n; i++) {
        while(n % i == 0) {
            ret[i]++;
            n /= i;
        }
    }
    if(n != 1)
        ret[n] = 1;
    return ret;
}

int main() {
    int N;
    cin >> N;
    map<int64_t, ll> factors;
    for(int i = 1; i <= N; i++) {
        auto f = prime_factor(i);
        for(pair<int64_t, ll> p : f) {
            factors[p.first] += p.second;
        }
    }

    ll res = 1LL;
    for(pair<int64_t, ll> p : factors) {
        res = (res * (p.second + 1LL)) % MOD;
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
using namespace std;

int main(){
    char s[101];
    char p[101];
    int c,d,i,t;
    scanf("%s",s);
    scanf("%s",p);
    if(s[0] == '0'||p[0] == '0'||s[0] == '-'||p[0] == '-')
    	return 0;
    c = strlen(s);
    d = strlen(p);
    if(c > d)
    	printf("GREATER\n");
    else if(c < d)
        printf("LESS\n");
    else if(c == d)
{
				for(i = 0;i < c;i++){
                    if(s[i] != p[i])
                    	break;
                    if(s[i] == p[i])
                    	continue;
				}
				if(s[i] > p[i])
				    printf("GREATER\n");
				else if(s[i] < p[i])
                    printf("LESS\n");
                else
                	printf("EQUAL\n");
			}
     return 0;
}


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

using namespace std;
typedef long long int ll;

#define PI (acos(-1))
#define REP(i,n) for(int (i)=0;(i)<(n);(i)++)

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define dumparr(x) cerr << #x ; for(auto elem: x){cerr << " " << elem;} cerr << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))

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

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

#include <iostream>
#include <fstream>

#include <iostream>
#include <fstream>

#include <string>
#include <vector>
#include <math.h>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <bitset>
using namespace std;
using ll = long long;
//constexpr ll INF = 1010000000000000017LL;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define all(v) v.begin(), v.end()

ll GCD(ll a, ll b) {
    if(b==0) return a;
    else return GCD(b, a%b);
}

ll LCM(ll a, ll b) {
    return a/GCD(a,b)*b;
}

class BMultiplication2 {
public:
	void solve(std::istream& in, std::ostream& out) {
	        ll mx = 1e18;
            ll n;
            in>>n;
            ll res=1;
            vector<ll> v(n);
            rep(i,n) in>>v[i];
            sort(all(v));
            rep(i,n){
                ll tmp = v[i];
                if(tmp==0){
                    out<<0<<endl;
                    return;
                }
                if(mx/res<tmp || res*tmp >mx){
                    out<<-1<<endl;
                    return;
                }
                res*=tmp;
            }
            out<<res<<endl;

	}
};


int main() {
	BMultiplication2 solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


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

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)

#define ALL(x) (x).begin(),(x).end() 
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))

#define INF 1000000000000000 
#define MOD 10000007 
#define MAXR 100000 

#define PB push_back 
#define VL vector<ll>


#define PQ priority_queue<VL,vector<VL>,greater<VL>>

#define MAXS ll(2999)

vector<VL> dijkstra(ll f,ll n,ll s,vector<vector<VL>>& edge){

    s=min(s,MAXS);

    vector<VL> confirm(n,VL(MAXS+1,false));

    vector<VL> mincost(n,VL(MAXS+1,INF));mincost[f][s]=0;

    PQ mincand;mincand.push({mincost[f][s],f,s});


    while(!mincand.empty()){

        VL next=mincand.top();mincand.pop();

        if(confirm[next[1]][next[2]]) continue;

        confirm[next[1]][next[2]]=true;

        vector<VL>& v=edge[next[1]];ll l=SIZE(v);
        REP(i,l){

            ll nextS=min(next[2]+v[i][1],MAXS);

            if(nextS<0) continue;

            if(mincost[v[i][0]][nextS]<=next[0]+v[i][2]) continue;
 
            mincost[v[i][0]][nextS]=next[0]+v[i][2];
            mincand.push({mincost[v[i][0]][nextS],v[i][0],nextS});
        }
    }
    return mincost;
}

signed main(){
    ll n,m,s;cin >> n >> m >> s;

    vector<vector<VL>> edge(n);
    REP(i,m){
        ll u,v,a,b;cin >> u >> v >> a >> b;
        edge[u-1].PB({v-1,-a,b});
        edge[v-1].PB({u-1,-a,b});
    }
    REP(i,n){
        ll c,d;cin >> c >> d;
        edge[i].PB({i,c,d});
    }

    vector<VL> mincost=dijkstra(0,n,s,edge);

    FOR(i,1,n-1) cout << MIN(mincost[i]) << endl;
}

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

#define int long long

using namespace std;

 main () {
 	int q, h, s, d, n;
 	cin >> q >> h >> s >> d >> n;
    h = min (h, q * 2);
    s = min (s, h * 2);
    d = min (d, s * 2);
    if (n & 1) cout << n / 2 * d + s;
    else cout << n / 2 * d;
    return 0;           		
}

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

#define rep(i,n) for(long long i=0; i<(long long)(n);i++)
#define rep2(i,s,n) for(long long i=(s); i<(long long)(n);i++)

#define mod 1e9+7;
#define inf 1e18+7;

typedef long long ll;

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

    rep(i,s.size()){
        cout<<char('A'+((s[i]-'A')+n)%26);
    }
    cout<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <unordered_map>
using namespace std;
using lint = long long;
const lint mod = 1000000007;
const lint INF = 1145141919810;
signed main(){
    int n,a,b;
    cin>>n>>a>>b;
    cout<<min(n*a,b)<<endl;
}

Measured memory_bytes: 256
#ABC175-D
"""
1周未満で終わる時の最大値をまずもとめる
(i)k<一周なら
最大値を出力して終了
(ii)sum(lst) <= 0
1周以上する価値はないので、最大値を出力して終了
(iii)sum(lst) > 0
N%kの端数だけ愚直にもう一度最大値を求めて出力
"""
import sys
readline = sys.stdin.buffer.readline
def even(n): return 1 if n%2==0 else 0

n,k = map(int,readline().split())
p = list(map(int,readline().split()))
c = list(map(int,readline().split()))
p = [i-1 for i in p]

ans = -10**18

for i in range(n):
    lst1 = [c[i]]
    idx = p[i]
    while idx != i:
        lst1.append(c[idx])
        idx = p[idx]
    sm = sum(lst1)
    acc = 0
    for i in range(min(len(lst1),k+2)):
        acc += lst1[i]
        a = acc
        if sm > 0:
            a += sm*((k-(i+1))//len(lst1))
        ans = max(a,ans)
print(ans)


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

#define EPS (1e-10)
#define equals(a,b) (fabs((a)-(b))<EPS)

class Point{
    public:
    double x,y;
    Point(double x=0,double y=0):x(x),y(y){}
    Point operator+(const Point &p){
        return Point(x+p.x,y+p.y);
    }
    Point operator-(const Point &p){
        return Point(x-p.x,y-p.y);
    }
    Point operator*(const double &a){
        return Point(a*x,a*y);
    }
    Point operator/(const double &a){
        return Point(x/a,y/a);
    }
    double abs(){
        return sqrt(norm());
    }
    double norm(){
        return x*x+y*y;
    }
    bool operator<(const Point &p){
        return x!=p.x?x<p.x:y<p.y;
    }
    bool operator==(const Point &p){
        return fabs(x-p.x)<EPS&&fabs(y-p.y)<EPS;
    }
};
typedef Point Vector;
struct Segment{
    Point p1,p2;
};

double dot(Vector a,Vector b){
    return a.x*b.x+a.y*b.y;
}

double cross(Vector a,Vector b){
    return a.x*b.y-a.y*b.x;
}

bool isOrthogonal(Segment s1,Segment s2){
    return equals(dot(s1.p2-s1.p1,s2.p2-s2.p1),0.0);
}

bool isParallel(Segment s1,Segment s2){
    return equals(cross(s1.p2-s1.p1,s2.p2-s2.p1),0.0);
}


int main(){
    int q;
    cin>>q;
    Segment s1,s2;
    for(int i=0;i<q;i++){
        int a,b,c,d,e,f,g,h;
        cin>>a>>b>>c>>d>>e>>f>>g>>h;
        s1.p1.x=a;
        s1.p1.y=b;
        s1.p2.x=c;
        s1.p2.y=d;
        s2.p1.x=e;
        s2.p1.y=f;
        s2.p2.x=g;
        s2.p2.y=h;
        if(isParallel(s1,s2)) cout<<2<<endl;
        else if(isOrthogonal(s1,s2)) cout<<1<<endl;
        else cout<<0<<endl;
    }
}


Measured memory_bytes: 3092
#include <bits/stdc++.h>
#define ALL(a)  (a).begin(),(a).end()
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<long long, long long> Pll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<long long> vll;
typedef vector<vector<long long>> vvll;
template <typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template <typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
const int INT_INF = 1LL << 30;

int main(){
  ll N;
  cin >> N;
  map<ll, ll> s;
  vll X(0);
  for(int i = 0; i < N; i++){
    ll A;
    cin >> A;
    if(!s.count(A)){
      s[A] = (ll)X.size();
      X.push_back(1);
    }
    else X.at(s.at(A))++;
  }
  int counter = 0;
  for(int i = 0; i < X.size(); i++){
    if(X.at(i) % 2 == 1) counter++;
  }
  cout << counter << endl;
}

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

int gcd(int, int);

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

    cout << gcd(a, b) << endl;

    return 0;
}

int gcd(int x, int y) {
    if (x % y == 0) {
        return y;
    } else {
        return gcd(y, x % y);
    }
}


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

int n, lt, rt, md;
char c[100005];
string re;
int main() {
	cin >> n;
	cout << "0\n";
	fflush(stdout);
	cin >> re;
	c[0] = c[n] = re[0];
	rt = n;
	while(1) {
		md = lt+rt >> 1;
		cout << md << '\n';
		fflush(stdout);
		cin >> re;
		c[md] = re[0];
		if(c[md]=='V') return 0;
		else if((md-lt&1) ^ c[md]==c[lt]) lt = md;
		else rt = md;
	}
	return 0;
}

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

int main() {
  ll n, m;
  cin >> n >> m;

  for (int i = 0; i < m; i++) {
    int a = i + 1, b = n - i;
    if (n % 2 == 0) {
      if (b - a <= n / 2) b--;
    }
    cout << a << ' ' << b << endl;
  }
}


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

int main()
{
	int n,flag=0;
    long long k=1;
    cin>>n;
	long long a[n];
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
    }
    sort(a,a+n);
    for(int i=0;i<n;i++)
    {
        if(a[i] && k>1000000000000000000/a[i])
        {
            cout<<-1<<endl;
            return 0;
        }
        k*=a[i];
    }
    cout<<k;
}

Measured memory_bytes: 4424
#include<stdio.h>
#define N 100
#define W 0
#define G 1
#define B 2

int n, m[N][N];
int c[N], d[N], f[N], tt;

void dfs_visit(int u) {
	int v;
	c[u] = G;
	d[u] = ++tt;
	for (v = 0; v < n; v++) {
		if (m[u][v] == 0) {
			continue;
		}
		if (c[v] == W) {
			dfs_visit(v);
		}
	}
	c[u] = B;
	f[u] = ++tt;
}

void dfs() {
	int u;
	for(u = 0; u < n; u++) {
		c[u] = W;
	}
	tt = 0;
	for (u = 0; u < n; u++) {
		if (c[u] == W) {
			dfs_visit(u);
		}
	}

	for (u = 0; u < n; u++) {
		printf("%d %d %d\n", u + 1, d[u], f[u]);

	}
}

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

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


Measured memory_bytes: 2108
N = int(input())
a = []
for i in range(N):
    a.append(int(input()))
    
ans = set()
i = 0
count = 0
while True:
    if a[i] == 2:
        print(count+1)
        exit()
    elif a[i]-1 not in ans:
        ans.add(a[i]-1)
        count += 1
        i = a[i] - 1
    else:
        print(-1)
        exit()

Measured memory_bytes: 16008
import java.util.Arrays;
import java.util.Scanner;


public class Main {
	static void doit(){
		Scanner scan = new Scanner(System.in);
		Player player[]=new Player[24];
		Player[] f_player=new Player[8];
		Player[] memo=new Player[6];
		for(int i=0;i<24;i++){
			player[i]=new Player(scan.nextInt(),scan.nextDouble());
		}
		//System.out.println(Arrays.toString(player));
		Arrays.sort(player,0,8);
		//System.out.println(Arrays.toString(player));
		Arrays.sort(player,8,16);
		//System.out.println(Arrays.toString(player));
		Arrays.sort(player,16,24);
		//System.out.println(Arrays.toString(player));
		int k=0;
		for(int i=0;i<=16;i+=8){
			f_player[k]=player[i];
			f_player[k+1]=player[i+1];
			k+=2;
		}
		int cnt=0;
		for(int i=2;i<=18;i+=8){
			memo[cnt]=player[i];
			memo[cnt+1]=player[i+1];
			cnt+=2;
		}
		Arrays.sort(memo);
		f_player[6]=memo[0];
		f_player[7]=memo[1];
		//System.out.println(Arrays.toString(memo));
		for(int i=0;i<f_player.length;i++){
			System.out.printf("%d %s\n", f_player[i].num,f_player[i].time);
		}
	}
	public static void main(String[] args) {
		new Main().doit();
	}

}
class Player implements Comparable<Player>{
	int num;
	Double time;
	public Player(int num,Double time){
		this.num=num;
		this.time=time;
	}
	@Override
	public String toString(){
		return num+" "+time;
	}
	@Override
	public int compareTo(Player p){
		return time.compareTo(p.time);
	}	
}

Measured memory_bytes: 28276
#include<bits/stdc++.h>
using namespace std;
typedef  long long ll;
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;}
//自作関数
template<class T> ll llpow(T x,T n){ll ans=1;while(n--){ans*=x;}return ans;}

#define rep(i,n) for(ll i=0;i<(ll)n;i++)
#define rep2(i, begin_i, end_i) for (ll i = (ll)begin_i; i < (ll)end_i; i++)

long long INF = 1LL<<60;
int n,m;
int main(){
    cin>>n>>m;
    ll div=1e9+7;
    vector<bool> skip(n+10,false);
    vector<ll> way(n+10);
    rep(i,m){
        int temp;
        cin>>temp;
        skip.at(temp)=true;
    }
    way.at(0)=1;
    for(int i=1;i<=n;i++){
        if(skip.at(i))continue;
        if(!(skip.at(i-1)))way.at(i)+=way.at(i-1);
        if(((i-2)>=0)&&(!(skip.at(i-2))))way.at(i)+=way.at(i-2);
        way.at(i)%=div;
    }
    cout<<way.at(n)<<endl;
    return 0;
}




Measured memory_bytes: 1024
#include <iostream>
#include <stdio.h>

using namespace std;

int main() {
  int A, B, K;
  cin >> A >> B >> K;
  for (int i = A; i <= min(B, A + K - 1); ++i) {
    printf("%d\n", i);
  }
  for (int i = max(A + K, max(A, B - K + 1)); i <= B; ++i) {
    printf("%d\n", i);
  }
}

Measured memory_bytes: 3220
#include<bits/stdc++.h>
#define N 300005
using namespace std;
int val[N];
int n,m;
void solve(int l,int r){
	if(l==0) {
		val[1]++,val[r+1]--;
		return;
	}//(]
	for(int i=1,ne,lastl=1e9;i<=r;i=ne+1){
		if(i<=l) ne=min(l/(l/i),r/(r/i));
		else ne=r;
		if(l/i<lastl){
			val[l/i+1]++,val[min(lastl,r/i)+1]--;
			lastl=l/i;
		}
	}
}
int main(){
	scanf("%d%d",&n,&m);
	for(int i=1,l,r;i<=n;i++){
		scanf("%d%d",&l,&r);
		solve(l-1,r);
	}
	for(int i=1;i<=m;i++) printf("%d\n",val[i]+=val[i-1]);
	return 0;
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define int ll
#define all(x) x.begin(), x.end()
#define x first
#define y second
#define mp make_pair
#define mt make_tuple

bool check(int x) {
	int s = round(sqrt(x));
	return x == s * s;
}

const int N = 1100;
int n;
int d;
vector<int> v[N];


signed main() {
#ifdef LC
	assert(freopen("input.txt", "r", stdin));
#endif
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	int l;
	int r;
	cin >> l >> r;
	if (r - l > 2020) {
		cout << "0\n";
		return 0;
	}
	int ans = 2020;
	for (int i = l; i <= r; ++i) {
		for (int j = i + 1; j <= r; ++j) {
			ans = min(ans, i * j % 2019);
		}
	}
	cout << ans << "\n";
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const ll mod = 1e9 + 7;

int main(){
	int N; cin >> N;
	vector<P> c[N];
	for(int i=0; i<N; i++){
		int a; cin >> a;
		for(int j=0; j<a; j++){
			int x, y; cin >> x >> y;
			x--;
			c[i].push_back(P(x, y));
		}
	}
	int ans = 0;
	for(int bit=0; bit<(1<<N); bit++){
		int cnt = 0, f = 1;
		int peo[N];
		for(int i=0; i<N; i++){
			if(bit & (1<<i)){
				peo[i] = 1;
				cnt++;
			}else{
				peo[i] = 0;
			}
		}
		for(int i=0; i<N; i++){
			if(bit & (1<<i)){
				for(int j=0; j<c[i].size(); j++){
					if(peo[c[i][j].first] != c[i][j].second){
						f = 0;
					}
				}
			}
		}
		if(f){
			if(ans < cnt) ans = cnt;
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
//Volume0-0088
import java.util.HashMap;
import java.util.Scanner;

public class Main {

	//declare
	private static HashMap<Character,String> CtoS = new HashMap<Character,String>();
	private static HashMap<String,Character> StoC = new HashMap<String,Character>();

	public static void main(String[] args) {

		int    padding;
		char[] ch;
		String s;

		//initialize
		initMap();

        //input
        Scanner sc = new Scanner(System.in);
        while(sc.hasNext()){
        	ch = sc.nextLine().toCharArray();

        	//calculate
        	s = "";
        	for(int i=0;i<ch.length;i++){
        		s += CtoS.get(ch[i]);
        	}
        	padding = 5 - s.length() % 5;
        	if(padding < 5){
        		while(padding-- > 0){
        			s += "0";
        		}
        	}

        	//output
        	for(int i=0;i<s.length();i+=5){
        		System.out.print(StoC.get(s.substring(i, i+5)));
        	}
        	System.out.println();
        }
	}

	private static void initMap(){

		//initialize CtoS.
		CtoS.put(' ', "101");
		CtoS.put('\'',"000000");
		CtoS.put(',', "000011");
		CtoS.put('-', "10010001");
		CtoS.put('.', "010001");
		CtoS.put('?', "000001");
		CtoS.put('A', "100101");
		CtoS.put('B', "10011010");
		CtoS.put('C', "0101");
		CtoS.put('D', "0001");
		CtoS.put('E', "110");
		CtoS.put('F', "01001");
		CtoS.put('G', "10011011");
		CtoS.put('H', "010000");
		CtoS.put('I', "0111");
		CtoS.put('J', "10011000");
		CtoS.put('K', "0110");
		CtoS.put('L', "00100");
		CtoS.put('M', "10011001");
		CtoS.put('N', "10011110");
		CtoS.put('O', "00101");
		CtoS.put('P', "111");
		CtoS.put('Q', "10011111");
		CtoS.put('R', "1000");
		CtoS.put('S', "00110");
		CtoS.put('T', "00111");
		CtoS.put('U', "10011100");
		CtoS.put('V', "10011101");
		CtoS.put('W', "000010");
		CtoS.put('X', "10010010");
		CtoS.put('Y', "10010011");
		CtoS.put('Z', "10010000");

		//initialize StoC.
		StoC.put("00000",'A');
		StoC.put("00001",'B');
		StoC.put("00010",'C');
		StoC.put("00011",'D');
		StoC.put("00100",'E');
		StoC.put("00101",'F');
		StoC.put("00110",'G');
		StoC.put("00111",'H');
		StoC.put("01000",'I');
		StoC.put("01001",'J');
		StoC.put("01010",'K');
		StoC.put("01011",'L');
		StoC.put("01100",'M');
		StoC.put("01101",'N');
		StoC.put("01110",'O');
		StoC.put("01111",'P');
		StoC.put("10000",'Q');
		StoC.put("10001",'R');
		StoC.put("10010",'S');
		StoC.put("10011",'T');
		StoC.put("10100",'U');
		StoC.put("10101",'V');
		StoC.put("10110",'W');
		StoC.put("10111",'X');
		StoC.put("11000",'Y');
		StoC.put("11001",'Z');
		StoC.put("11010",' ');
		StoC.put("11011",'.');
		StoC.put("11100",',');
		StoC.put("11101",'-');
		StoC.put("11110",'\'');
		StoC.put("11111",'?');
	}
}

Measured memory_bytes: 43016
#include <stdio.h>

int main(){
  
  int i,j,n,min,minj,total=0,A[100][100],flag[100],t[100];

  scanf("%d",&n);
  
  
  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      scanf("%d",&A[i][j]);
    }
  }
  for(i=0;i<n;i++){
    flag[i]=0;
    t[i]=2000;
  }
  t[0]=0; 

  for(i=0;i<n-1;i++){
    min=2000;
    for(j=0;j<n;j++){
      if(t[j]<min&&flag[j]==0){
	min=t[j];
	minj=j;
      }
    }
    flag[minj]=1;
  
    for(j=0;j<n;j++){
      if(A[minj][j]!=-1&&A[minj][j]<t[j]&&flag[j]==0){
	t[j]=A[minj][j];
      }
    }
  }
  
  for(i=0;i<n;i++){
    total+=t[i];
  }
  printf("%d\n",total);
  return 0;
}

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

using namespace std;

#define LL long long
#define DD double
#define Pb push_back
#define Bp pop_back
#define Pf push_front
#define Fp pop_front
#define Ub upper_bound
#define Lb lower_bound
#define In insert
#define All(x) x.begin(), x.end()
#define mem(a, b) memset(a, b, sizeof(a))
#define fast ios_base::sync_with_stdio(0);cin.tie(0)
#define X first
#define Y second
#define mx1 10
#define mx2 110
#define mx3 1010
#define mx4 10010
#define mx5 100010
#define mx6 1000010

typedef vector<LL> Vl;
typedef vector<DD> Vd;
typedef vector<bool> Vb;
typedef vector<Vl> VVl;
typedef pair<LL, LL> Pll;
typedef pair<DD, DD> Pdd;
typedef vector<Pll> Vpl;
typedef vector<Pdd> Vpd;
typedef queue<LL> Ql;
typedef stack<LL> Sl;
typedef deque<LL> Dl;

LL _set(LL N, LL pos) {return N = N | (1 << pos);}
LL _reset(LL N, LL pos) {return N = N & ~(1 << pos);}
bool _check(LL N, LL pos) {return (bool)(N & (1 << pos));}
bool _upper(char a) {return a >= 'A' && a <= 'Z';}
bool _lower(char a) {return a >= 'a' && a <= 'z';}
bool _digit(char a) {return a >= '0' && a <= '9';}

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

///**************************DONE****************************///

int main()
{
    int n, a, s = 0;
    cin >> n;

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

    cout << s - n << '\n';
    return 0;
}


Measured memory_bytes: 3624
n, m = gets.chomp.split(" ").map(&:to_i)
arr = []

n.times do |i|
  arr.push(gets.chomp.split(" ").map(&:to_i))
end
arr.sort_by!{|a, _| a}

total = 0
arr.each do |a, b|
  count = [b, m].min
  total += count * a
  m -= count
  break if m <= 0
end

puts total


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

int main(){
  int n, sum;
  int s[1000];
  double m, stv;
  
  while (1){
  	sum = 0;
  	stv = 0;
  	cin >> n;
  	if ( n == 0 ) break;
  	
    for ( int i = 0; i < n; i++ ){
  	  cin >> s[i];
  	  sum += s[i];
    }
    m = sum / double(n);
  
    for ( int i = 0; i < n; i++ ){
  	  stv += pow(s[i]-m, 2);
    }
    printf("%lf\n", sqrt(stv/n));
  }
  
  return 0;
}


Measured memory_bytes: 3204
#include <bits/stdc++.h>
using namespace std;
int main() {
    int x, y;
    cin >> x >> y;
    auto f = [](int n) {
        return n == 3 ? 100000 : n == 2 ? 200000 : n == 1 ? 300000 : 0;
    };
    auto ans = f(x) + f(y);
    if (x == 1 && y == 1) ans += 400000;
    cout << ans << endl;
}


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

using namespace std;

int main() {
  string s, t;
  cin >> s >> t;
  if (s.size() +1 == t.size() && equal(begin(s), end(s), begin(t))) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 3620
X, N = map(int, input().split(" "))

if N > 0:
  p = list(map(int, input().split(" ")))
else:
  p = []

go = True
absolute = 1
plus = True

if X not in p:
  print(X)
else:
  while go:
    if plus:
      target = X - absolute
      if target not in p:
        print(target)
        go = False
      plus = False
    else:
      target = X + absolute
      if target not in p:
        print(target)
        go = False
      absolute += 1
      plus = True

Measured memory_bytes: 61916
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Atcoder01_12 {
    class Program {
        static void Main(string[] args) {
            char C = char.Parse(Console.ReadLine());
            int c = (int)C + 1;
            


            Console.WriteLine((char)c);
        }
    }
}


Measured memory_bytes: 11092
N = int(input())
S = input()

num_type_max = 0

for i in range(1, N-1):
    s1 = set(S[:i])
    s2 = set(S[i:])

    num_type = 0
    for s in s1:
        if s in s2:
            num_type += 1
    if num_type > num_type_max:
        num_type_max = num_type

print(num_type_max)


Measured memory_bytes: 2940