akhauriyash/Code-Regression huggingface dataset:
// Ho-kago Tea Time

#include <bits/stdc++.h>

using namespace std;

#define DEBUG(...) fprintf(stderr, __VA_ARGS__)
#define mp make_pair
#define fst first
#define snd second
#define SZ(u) ((int) (u).size())
#define ALL(u) (u).begin(), (u).end()

inline void proc_status()
{
	ifstream t("/proc/self/status");
	cerr << string(istreambuf_iterator<char>(t), istreambuf_iterator<char>()) << endl;
}

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; }
template<typename T> inline T read()
{
	register T sum(0), fg(1);
	register char ch(getchar());
	for(; !isdigit(ch); ch = getchar()) if(ch == '-') fg = -1;
	for(;  isdigit(ch); ch = getchar()) sum = sum * 10 - '0' + ch;
	return sum * fg;
}

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

const int INF = (int) 1e9;

const int MOD = (int) 1e9 + 7;

inline int fpm(int x, int y)
{
	int res = 1;
	for(; y; y >>= 1, x = (LL) x * x % MOD) if(y & 1) res = (LL) res * x % MOD;
	return res;
}

inline int inv(int x) { assert(x); return fpm(x, MOD - 2); }

const int MAXN = (int) 2e5;

namespace MATH
{
	const int n = MAXN;

	int fac[n + 5], ifac[n + 5];

	inline void init()
	{
		fac[0] = 1;
		for(int i = 1; i <= n; ++i) fac[i] = (LL) fac[i - 1] * i % MOD;
		ifac[n] = inv(fac[n]);
		for(int i = n - 1; i >= 0; --i) ifac[i] = (LL) ifac[i + 1] * (i + 1) % MOD;
	}
}
using MATH::fac;
using MATH::ifac;

int n, X, Y;

int c[MAXN + 5], w[MAXN + 5];

inline void input()
{
	n = read<int>(), X = read<int>(), Y = read<int>();
	for(int i = 1; i <= n; ++i) c[i] = read<int>(), w[i] = read<int>();
}

vector<int> adj[MAXN + 5];
int vis[MAXN + 5], cnt[MAXN + 5];

int bkt[MAXN + 5], cur;
vector<int> col;

inline void dfs(int u)
{
	vis[u] = 1;
	++cnt[c[u]];
	if(bkt[c[u]] != cur) bkt[c[u]] = cur, col.push_back(c[u]);

	for(auto v : adj[u]) if(!vis[v]) dfs(v);
}

inline void solve()
{
	static vector<int> id[MAXN + 5];
	static int mn[MAXN + 5], mn_id[MAXN + 5];

	for(int i = 1; i <= n; ++i) mn[i] = INF;
	for(int i = 1; i <= n; ++i)
	{
		id[c[i]].push_back(i);
		if(chkmin(mn[c[i]], w[i])) mn_id[c[i]] = i;
	}

	int p = 0, q = 0;
	mn[0] = INF;
	for(int i = 1; i <= n; ++i)
	{
		if(mn[i] < mn[p]) q = p, p = i;
		else if(mn[i] < mn[q]) q = i;
	}

	for(int k = 1; k <= n; ++k)
	{
		int r = mn_id[k], t = mn_id[p == k ? q : p];
		for(auto i : id[k])
		{
			if(r && w[i] + w[r] <= X)
			{
				adj[r].push_back(i);
				adj[i].push_back(r);
			}
			if(t && w[i] + w[t] <= Y)
			{
				adj[t].push_back(i);
				adj[i].push_back(t);
			}
		}
	}

	int ans = 1;
	for(int i = 1; i <= n; ++i) if(!vis[i])
	{
		++cur, col.clear(), dfs(i);

		int res = 1, sum = 0;
		for(auto j : col)
		{
			res = (LL) res * ifac[cnt[j]] % MOD;
			sum += cnt[j], cnt[j] = 0;
		}
		res = (LL) res * fac[sum] % MOD;

		ans = (LL) ans * res % MOD;
	}
	printf("%d\n", (ans + MOD) % MOD);
}

int main()
{
#ifdef K_ON // K-ON!
	freopen("D.in", "r", stdin);
	freopen("D.out", "w", stdout);
#endif

	MATH::init();
	input();
	solve();

	return 0;
}



Measured memory_bytes: 28020
#include <bits/stdc++.h>
using namespace std;
#define rep0(i, n) for (long long i = 0; i < (long long)(n); i++)
#define rep1(i,n) for(long long i=1;i<=(long long)(n);i++)
#define all(v) v.begin(),v.end()
#define Sort(v) sort(all(v))
#define Reverse(v) reverse(all(v))
#define Rsort(v) sort(all(v),greater)
#define pub(v) push_back(v)
#define pob(v) pop_back(v)
typedef long long ll;
typedef vector<ll> vel;
typedef vector<vector<ll>> vel2d;
typedef string str;
typedef pair<ll,ll> pal;
typedef vector<str> ves;
typedef vector<char> vech;


int main() {
    ll N;
    cin>>N;
    vector<vel> S(N,vel(10));
    vector<vech> t(N,vech(10));
    rep0(i,N){
        rep0(j,10){
            cin>>t[i][j];
            S[i][j]=(ll)t[i][j];
          //cout<<S[i][j]<<endl;
        }
    }
    rep0(i,N){sort(all(S[i]));}
    map<vel,ll> data;
    rep0(i,N){
        data[S[i]]++;
    }
    //rep0(i,N){cout<<data[S[i]]<<endl;}
    ll ans=0;
    rep0(i,N){
        ll q=data[S[i]];
        ans+=q*(q-1)/2;
        data[S[i]]=0;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 34560
//INCLUDE
//------------------------------------------
#include <bits/stdc++.h>
//DEFINE
//------------------------------------------
#define ll long long
#define ld long double
#define ALLv(a)  (a).begin(),(a).end()
#define ALL(a,n)  (a),(a)+n
#define vi vector<long long>
#define vd vector<long double>
#define vs vector<string>
#define dcml(n) fixed<<setprecision(n)
//CONST
//------------------------------------------
const ll INF=1010000000000000017LL;
const ll MOD=1000000007LL;
const ld EPS=1e-12;
const ld PI=3.14159265358979323846;
//REPEAT
//------------------------------------------
#define   FOR(i,m,n) for(ll (i)=(m);   (i)<(n);  (i)++)
#define  FORS(i,m,n) for(ll (i)=(m);   (i)<=(n); (i)++)
#define  RFOR(i,m,n) for(ll (i)=(n)-1; (i)>=(n); (i)--)
#define RFORS(i,m,n) for(ll (i)=(n);   (i)>(n);  (i)--)
#define   REP(i,n)   for(ll (i)=0;     (i)<(n);  (i)++)
#define  REPS(i,x)   for(ll (i)=1;     (i)<=(x); (i)++)
#define  RREP(i,x)   for(ll (i)=(x)-1; (i)>=0;   (i)--)
#define RREPS(i,x)   for(ll (i)=(x);   (i)> 0;   (i)--)
#define  WREP(i,in,j,jn) REP(i,in)REP(j,jn)
#define WREPS(i,in,j,jn) REPS(i,in)REPS(j,jn)
//-----------------------------------------
//namespace
using namespace std;
//ライブラリはここに
//↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓

//-----------------------------------------
int main(void){
    ll N;cin>>N;
    vi v(N);REP(i,N)v[i]=i+1;
    vi P(N),Q(N);
    REP(i,N)cin>>P[i];
    REP(i,N)cin>>Q[i];
    ll cnt=0,cnt1=0,cnt2=0;
    do{
        if(v==P)cnt1=cnt;
        if(v==Q)cnt2=cnt;
        cnt++;
    }while(next_permutation(ALLv(v)));
    cout<<abs(cnt1-cnt2)<<"\n";
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string.h>
#include <math.h>
#include <map>
#include <iomanip>
#include <stdio.h>
#include <bitset>

typedef long long ll;

constexpr long long INFLL = 1e18;

using namespace std;

int main()
{
    int l, r, d;
    cin >> l >> r >> d;
    int ans = 0;

    for (int i = l; i <= r; i++)
    {
        if (i % d == 0)
        {
            ans++;
        }
    }

    cout << ans << endl;

    return 0;
}

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

int main() {
string S;
  cin>>S;
  if(S=="Sunny"){
    cout<<"Cloudy"<<endl;
  }
  else if(S=="Cloudy"){
    cout<<"Rainy"<<endl;
  }
  else{
    cout<<"Sunny"<<endl;
  }
}


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

int main(){
	int H, W; std::cin >> H >> W;
	std::vector<std::vector<char>> C(H, std::vector<char>(W));
	for (int i = 0; i < H; ++i)
		for (int j = 0; j < W; ++j)
			std::cin >> C[i][j];
	for (int i = 0; i < H; ++i) {
		for (int j = 0; j < W; ++j) {
			std::cout << C[i][j];
		}
		std::cout << std::endl;
		for (int j = 0; j < W; ++j) {
			std::cout << C[i][j];
		}
		std::cout << std::endl;
	}

	return 0;
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
#include <vector>
#include <numeric>
#define PI 3.14159265358979323846
#define MAXINF 1e18L
#define INF 1e9L
#define EPS 1e-9
#define REP(i, n) for(int i=0;i<int(n);++i)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define ALL(v) v.begin(),v.end()
#define FIND(v,x) (binary_search(ALL(v),(x)))
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v));reverse(ALL(v))
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define YES(n) cout<<((n)?"YES":"NO")<<endl
#define pb push_back
#define fi first
#define se second
using namespace std;
template<class A>void pr(A a){cout << (a) << endl;}
template<class A,class B>void pr(A a,B b){cout << a << " "  ;pr(b);}
template<class A,class B,class C>void pr(A a,B b,C c){cout << a << " " ;pr(b,c);}
template<class A,class B,class C,class D>void pr(A a,B b,C c,D d){cout << a << " " ;pr(b,c,d);}
typedef long long ll;
typedef pair<int, int> pii;

int main(void)
{
    int n;
    cin >> n;
    pr(180*(n-2));
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int Q;
int a,b,c,d;
int main() {
    cin >> Q;
    for(int i=0;i<Q;i++){
        scanf("%d%d%d%d",&a,&b,&c,&d);
        int ans = 0;
        for(int x=a;x<=c;x++){
            for(int y=b;y<=d;y++){
                if(!(x%2==1 && y%2==0)) ans++;
            }
        }
        cout << ans << endl;
    }
}


Measured memory_bytes: 3232
#include<stdio.h>
long long int as[1001][1001];
int main(void)
{
	long long int a,b,x[1001],s[1001],A=9223372036854775800,min=9223372036854775800,i,j;
	scanf("%lld %lld",&a,&b);
	for(i=1;i<=a;i++){
		scanf("%lld",&x[i]);
	}
	for(i=1;i<=b;i++){
		scanf("%lld",&s[i]);
	}
	for(i=0;i<=b;i++){
		for(j=0;j<=a;j++){
			as[i][j]=A;
		}
	}
	as[0][0]=0;
	for(i=0;i<b;i++){
		for(j=0;j<=a;j++){
			if(as[i][j]!=A){
				if(as[i+1][j]>as[i][j]){
					as[i+1][j]=as[i][j];
				}
                if(as[i+1][j+1]>as[i][j]+x[j+1]*s[i+1]){
					as[i+1][j+1]=as[i][j]+x[j+1]*s[i+1];
				}
			}
		}
	}
/*	for(i=0;i<=b;i++){
		for(j=0;j<=a;j++) printf("%d ",as[i][j]);
		printf("\n");
	}*/
	for(i=0;i<=b;i++){
		if(as[i][a]<min){
			min=as[i][a];
		}
	}
	printf("%lld\n",min);
	return 0;
}

Measured memory_bytes: 10520
x, y = map(int, input().split())

groups = [[1, 3, 5, 7, 8, 10, 12], [4, 6, 9, 11], [2]]
is_same_group = False
for group in groups:
    if x in group and y in group:
        is_same_group = True
        break

if is_same_group:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3316
#pragma GCC optimize ("-O3")
    #include <bits/stdc++.h>  
     
    using namespace std;
     
    typedef long long ll;
    typedef long double ld;
    typedef pair<int,int> p32;
    typedef pair<ll,ll> p64;
    typedef pair<double,double> pdd;
    typedef vector<ll> v64;
    typedef vector<int> v32;
    typedef vector<vector<int> > vv32;
    typedef vector<vector<ll> > vv64;
    typedef vector<vector<p64> > vvp64;
    typedef vector<p64> vp64;
    typedef vector<p32> vp32;
    ll MOD = 998244353;
    #define forn(i,e) for(ll i = 0; i < e; i++)
    #define forsn(i,s,e) for(int i = s; i < e; i++)
    #define rforn(i,s) for(ll i = s; i >= 0; i--)
    #define rforsn(i,s,e) for(ll i = s; i >= e; i--)
    #define ln "\n"
    #define dbg(x) cout<<#x<<" = "<<x<<ln
    #define mp make_pair
    #define pb push_back
    #define fi first
    #define se second
    #define INF 1e18
    #define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
    #define all(x) (x).begin(), (x).end()
    #define sz(x) ((ll)(x).size())
     
    ll mpow(ll a, ll b){
        if(b >= (MOD-1)) b %= (MOD-1);
        if(b==0) return 1;
        ll t1 = mpow(a,b/2);
        t1 *= t1;
        t1 %= MOD;
        if(b%2) t1 *= a;
        t1 %= MOD;
        return t1;
    }
     
    ll mpow(ll a, ll b, ll p){
        if(b==0) return 1;
        ll t1 = mpow(a,b/2,p);   t1 *= t1;
        t1 %= p;
        if(b%2) t1 *= a;
        t1 %= p;
        return t1;
    }
    ll modinverse(ll a, ll m){
        ll m0 = m; 
        ll y = 0, x = 1; 
        if (m == 1) return 0; 
        while (a > 1){
            ll q = a / m; 
            ll t = m; 
            m = a % m, a = t; 
            t = y; 
            y = x - q * y; 
            x = t; 
        }
        if (x < 0) x += m0; 
        return x; 
    }
    ll range(ll l, ll r){
        return l + rand()%(r-l+1);
    }
    
    int main()
    {
        ll t=1;
        //cin>>t;
        while(t--)
        {
            ll x,k,d;
            cin>>x>>k>>d;

            if( abs(x)/d > k)
            {
                cout<<abs(x) - k*d <<endl;
            }
            else
            {
                k =  k - abs(x)/d;

                if(k%2==0)cout<<abs(x)%d<<endl;
                else cout<< d - (abs(x)%d) <<endl;
            }
        }
    }

Measured memory_bytes: 3628
q, h, s, d = map(int, input().split())
n = int(input())
q1 = q * 4
h1 = h * 2
ans = 0
if n >= 2:
    buy = min([q1 * 2, h1 * 2, s * 2, d]) * (n // 2)
    n -= n // 2 * 2
    ans += buy
if n > 0:
    ans += min([q1, h1, s])
print(ans)

Measured memory_bytes: 3064
a,b,c=map(int,input().split())
k=int(input())
s=0
for i in range(10):
    if b*(2**i)>a:
        s=i
        break
b*=2**s
t=0
for i in range(10):
    if c*(2**i)>b:
        t=i
        break
if s+t>k:
    print("No")
else:
    print("Yes")


Measured memory_bytes: 61876
class PriorityQueue
    def initialize(arr)
        @size = arr.size
        @array = arr
        @array.unshift(nil)
        h = (@size / 2) | 0
        h.downto(1) do |i|
            maxHeapify(i)
        end
    end
    def getArray
        return @array[1..@size]
    end
    def maxHeapify(i)
        left = 2 * i
        right = 2 * i + 1
        largest = 0
        if left <= @size && @array[left] > @array[i]
            largest = left
        else
            largest = i
        end
        if right <= @size && @array[right] > @array[largest]
            largest = right
        end
        if largest != i
            @array[i], @array[largest] = @array[largest], @array[i]
            maxHeapify(largest)
        end
    end
    def pop
        return -(1<<29) if @size < 1
        maxv = @array[1]
        @array[1] = @array[@size]
        @size -= 1
        maxHeapify(1)
        maxv
    end
    def push(e)
        @size += 1
        i = @size
        @array[i] = -(1<<29)
        return if e < @array[i]
        @array[i] = e
        while i > 1 && @array[i/2] < @array[i]
            @array[i], @array[i/2] = @array[i/2], @array[i]
            i = i / 2
        end
    end
end

n = gets.chomp.to_i
ans = n
a = gets.chomp.split.map(&:to_i)
h = Hash.new(0)
a.each do |i|
    h[i] += 1
end

if h.size == 1 then
    puts 1
    exit
end

arr = []
h.each do |key, val|
    arr << val
end
pq = PriorityQueue.new(arr)

loop do
    large_1 = pq.pop
    break if large_1 == 1
    large_2 = pq.pop
    ans -= 2
    pq.push(large_1-1) if large_1 != 0
    pq.push(large_2-1) if large_2 != 0
end

puts ans

Measured memory_bytes: 25816
import math
import fractions
import bisect
import collections
import itertools
import heapq
import string
import sys
import copy
from collections import deque
sys.setrecursionlimit(10**7)
MOD = 10**9+7
def gcd(a,b):return fractions.gcd(a,b) #最大公約数
def lcm(a,b):return (a*b) // fractions.gcd(a,b) #最小公倍数
def iin(): return int(input()) #整数読み込み
def ifn(): return float(input()) #浮動小数点読み込み
def isn(): return input().split() #文字列読み込み
def imn(): return map(int, input().split()) #整数map取得
def fmn(): return map(float, input().split()) #浮動小数点map取得
def iln(): return list(map(int, input().split())) #整数リスト取得
def iln_s(): return sorted(iln()) # 昇順の整数リスト取得
def iln_r(): return sorted(iln(), reverse=True) # 降順の整数リスト取得
def fln(): return list(map(float, input().split())) # 浮動小数点リスト取得
def join(l, s=''): return s.join(l) #リストを文字列に変換
def perm(l, n): return itertools.permutations(l, n) # 順列取得
def perm_count(n, r): return math.factorial(n) // math.factorial(n-r) # 順列の総数
def comb(l, n): return itertools.combinations(l, n) # 組み合わせ取得
def comb_count(n, r): return math.factorial(n) // (math.factorial(n-r) * math.factorial(r)) #組み合わせの総数
def two_distance(a, b, c, d): return ((c-a)**2 + (d-b)**2)**.5 # 2点間の距離
def m_add(a,b): return (a+b) % MOD

N,K = imn()
h = iln()

dp = [10**10 for _ in range(N)]

dp[0] = 0

for i in range(N):
    for k in range(1,K+1):
        if i+k < N: dp[i+k] = min(dp[i+k], dp[i]+abs(h[i+k]-h[i]))
print(dp[N-1])

Measured memory_bytes: 82012
#include <bits/stdc++.h>
#define st first
#define nd second
#define mp make_pair
#define pb push_back
#define mod 1000000007
#define N 1000005
using namespace std;
typedef long long ll;
ll n, dp[2][N];
vector < ll > g[N];

ll f(ll node, ll par, ll d){
	ll &crp = dp[d][node];
	if(crp != -1)
		return crp;
	crp = 1;
	for(ll i = 0; i < g[node].size(); i++)
		if(g[node][i] != par){
			if(d)
				crp = crp*f(g[node][i], node, 0)%mod;
			else
				crp = crp*( (f(g[node][i], node, 0) + f(g[node][i], node, 1))%mod )%mod;
		}
	return crp;
}

int main() {
	// freopen("in.txt", "r", stdin);
	// freopen("out.txt", "w", stdout);
	memset(dp, -1, sizeof dp);
	scanf("%lld",&n);
	for(ll i = 1; i < n; i++){
		ll u, v;
		scanf("%lld %lld",&u ,&v);
		g[u].pb(v);
		g[v].pb(u);
	}
	printf("%lld\n",(f(1, 0, 1) + f(1, 0, 0))%mod );
	return 0;
}

Measured memory_bytes: 52224
#include <iostream>
#include <iomanip>
#include<vector>
#include <algorithm>
#include <queue>
#include<string>
#include <map>
#include <cmath>
#include <deque>
#include <list>
#include <stack>
#include <queue>
#include <utility>
#include <set>
#include <bitset>
typedef long long ll;
typedef long double ld;

#define REP(i,s,n)for(ll i=s;i<(n);++i)
#define rep(i,n) REP(i,0,n)
using namespace std;

int main() {
    string S;
    int K;
    cin >> K >> S;
    if (S.length()<=K) {
        cout << S << endl;
    }
    else {
        rep(i,K) {
            cout << S[i];
        }
        cout << "..." << endl;
    }
    return 0;
}

Measured memory_bytes: 3636
// AGC011A.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//
#include <iostream>
using namespace std;
#include <vector>
#include <algorithm>

int main()
{
	int N, C, K;
	cin >> N >> C >> K;
	vector<int>T(N);
	for (int i = 0; i < N; i++)cin >> T[i];
	sort(T.begin(), T.end());
	int num = 0;
	for (int i = 0; i < N;) {
		num++;
		int start = i;
		while ((i < N) && (T[i] <= T[start] + K) && (i-start < C)) i++;		
		}
	cout << num << endl;
	return 0;
}

// プログラムの実行: Ctrl + F5 または [デバッグ] > [デバッグなしで開始] メニュー
// プログラムのデバッグ: F5 または [デバッグ] > [デバッグの開始] メニュー

// 作業を開始するためのヒント: 
//    1. ソリューション エクスプローラー ウィンドウを使用してファイルを追加/管理します 
//   2. チーム エクスプローラー ウィンドウを使用してソース管理に接続します
//   3. 出力ウィンドウを使用して、ビルド出力とその他のメッセージを表示します
//   4. エラー一覧ウィンドウを使用してエラーを表示します
//   5. [プロジェクト] > [新しい項目の追加] と移動して新しいコード ファイルを作成するか、[プロジェクト] > [既存の項目の追加] と移動して既存のコード ファイルをプロジェクトに追加します
//   6. 後ほどこのプロジェクトを再び開く場合、[ファイル] > [開く] > [プロジェクト] と移動して .sln ファイルを選択します


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

int main(){
    long long int n, w;
    cin >> n >> w;
    vector<long long int> v[4];
    long long int w1, v1;
    cin >> w1 >> v1;
    v[0].push_back(v1);
    for(int i=1;i<n;++i){
        long long int wi, vi;
        cin >> wi >> vi;
        v[wi-w1].push_back(vi);
    }
    for(int i=0;i<4;++i){
        sort(v[i].rbegin(), v[i].rend());
    }

    long long int ans = 0;
    for(long long int i=0;i<=v[0].size();++i){
        for(long long int j=0;j<=v[1].size();++j){
            for(long long int k=0;k<=v[2].size();++k){
                if(i+j+k > n || w1*i+(w1+1)*j+(w1+2)*k > w)continue;
                long long int l = min((long long int)v[3].size(),(w - (w1*i+(w1+1)*j+(w1+2)*k)) / (w1+3));
                long long int sum = 0;
                for(int m=0;m<i;++m)sum += v[0][m];
                for(int m=0;m<j;++m)sum += v[1][m];
                for(int m=0;m<k;++m)sum += v[2][m];
                for(int m=0;m<l;++m)sum += v[3][m];
                ans = max(ans, sum);
            }
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 1LL << 60;
ll MOD = 1000000000 + 7;

int main() {
    ll n, x, m;
    cin >> n >> x >> m;
    ll x1 = x;
    ll sum = x;
    vector<ll> a(m);
    ll l = 0, r = 0;
    a[0] = x;
    bool roop = false;
    for (ll i = 1; i < n; i++) {
        ll tmp = (x * x) % m;
        x = tmp;
        for (int j = 0; j < i; j++) {
            if (a[j] == tmp) {
                l = j;
                r = i - 1;
                roop = true;
                break;
            }
        }
        if (roop) break;
        a[i] = tmp;
        sum += tmp;
    }
    if (r) {
        ll fsum = 0;
        for (int i = 0; i < l; i++) {
            fsum += a[i];
        }
        ll lsum = 0;
        for (int i = 0; i < ((n - l) % (r - l + 1)); i++) {
            lsum += a[l + i];
        }
        sum += (sum - fsum) * ((n - l + 1) / (r - l + 1) - 1) + lsum;
    }

    if (x1 == ((x1 * x1) % m)) {
        sum = x1 * n;
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 4028
#include<stdio.h>

int main(){
    int i,fibo0,fibo1,fibo2,num,sum;
    scanf("%d",&num);
    i=0;
    fibo0=0;
    fibo1=1;
    while(i<num){
        //printf("%d回目 :",i+1);
        fibo2=fibo1+fibo0;
        //printf("sum = %d\n",fibo2);
        fibo0=fibo1;
        fibo1=fibo2;
        ++i;
  }
  //printf("Finally sum %d or %d or %d\n",fibo0,fibo1,fibo2);
  printf("%d\n",fibo2);
  return 0;
}


Measured memory_bytes: 2104
#include<bits/stdc++.h>
using namespace std;
//dp[l][r]->(x-y)in the range l to r both inclusive
 
int main()
{
  int n;
  cin>>n;
  vector<long long> v(n);
  for(long long &x:v)
  cin>>x;
  vector<vector<long long>> dp(n,vector<long long>(n,INT_MIN));
  for(int d=0;d<=n-1;d++)
  {
      for(int l=0;l<n-d;l++)
      {
          int r=l+d;
          if(l==r)
          dp[l][r]=v[l];
          else
          dp[l][r]=max(v[l]-dp[l+1][r],v[r]-dp[l][r-1]);
      }
  }
  cout<<dp[0][n-1]<<endl;
  return 0;
}

Measured memory_bytes: 73724
def dist(p,q):
	return float((p*p + q*q))

line = input()
line = line.split()
n=int(line[0])
d=float(line[1])
d=d*d

cnt = 0
for i in range(n):
	line = input()
	line = line.split()
	x=float(line[0])
	y=float(line[1])
	if(dist(x,y)<=d):
		cnt+=1

print(cnt)

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

int main(){
  int n;
  cin >> n;
  vector<vector<ll>> dp(n,vector<ll>(4));
  dp[0][0]=8;
  dp[0][1]=1;
  dp[0][2]=1;
  dp[0][3]=0;
  
  for(int i=1;i<n;i++){
    dp[i][0]=dp[i-1][0]*8;
    dp[i][1]=dp[i-1][0]+dp[i-1][1]*9;
    dp[i][2]=dp[i-1][0]+dp[i-1][2]*9;
    dp[i][3]=dp[i-1][1]+dp[i-1][2]+dp[i-1][3]*10;
    for(int j=0;j<4;j++){
      dp[i][j]%=1000000007;
    }
  }
  
  cout << dp[n-1][3] << endl;
}

Measured memory_bytes: 73404
#include <iostream>
#include <cstdlib>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <ctime>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <string>

using namespace std;

int main()
{
	int n,a,b;
	cin>>n>>a>>b;
	cout<<min(a,b)<<' '<<max(a+b-n,0);
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
static const int N = 1000;

int lcs(string X, string Y) {
  int c[N + 1][N + 1];
  int m = X.size();
  int n = Y.size();
  int maxl = 0;
  X = " "+ X;
  Y = " "+ Y;
  for ( int i = 0; i <= m; i++ ) c[i][0] = 0;
  for ( int j = 1; j <= n; j++ ) c[0][j] = 0;

  for ( int i = 1; i <= m; i++ )
    for ( int j = 1; j <= n; j++ ) {
      if ( X[i] == Y[j] )
        c[i][j] = c[i - 1][j - 1] + 1;
      else
        c[i][j] = max(c[i - 1][j], c[i][j - 1]);
      maxl = max(maxl, c[i][j]);
    }

  return maxl;
}

int main() {
  string s1, s2;
  int n; cin >> n;
  for ( int i = 0; i < n; i++ ) {
    cin >> s1 >> s2;
    cout << lcs(s1, s2) << endl;
  }
  return 0;
}


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

int main(){
  int n;cin>>n;
  map<string,int> mp;
  string before,after;
  cin>>before;
  mp[before]++;
  
  REP(i,n-1){
    cin>>after;
    if(((before.at(before.size()-1)) == after.at(0))&&mp[after]==0){
      mp[after]++;
      before=after;
    }else{
      cout<<"No";
      return 0;
    }
  }
  cout<<"Yes";
}

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

using namespace std;

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

    vector<int> alph(26);
    for(int i=0;i<w.size();i++){
        int  tmp = w[i] - 'a';
        alph[tmp]++;
    }
    sort(alph.begin(),alph.end(),greater<int>());

    for(int i=0;i<26;i++){
        if(alph[i]%2!=0){
            cout<<"No"<<endl;
            return 0;
        }
    }
    cout<<"Yes"<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int a[111111];
int main(){
	int n,x;
	for(scanf("%d",&n); n--;){
		scanf("%d",&x);
		a[x+1] ++;
	}
	int res  = 0;
	for(int i=1; i<=100000; i++){
		int now = a[i-1] + a[i] + a[i+1];
		if(now > res)res = now;
	}
	printf("%d\n",res);
	return 0;
}


Measured memory_bytes: 640
using System;
using System.Collections.Generic;
using System.Linq;


namespace AtCoder
{
    partial class Program
    {
        static void Main(string[] args)
        {
			//↓

            var n = int.Parse(Console.ReadLine());
            var aas = Console.ReadLine().Split(' ').Select(decimal.Parse).ToArray();

            var r = 1 / aas.Select(a => 1 / a).Sum();
            Console.WriteLine(r);


			//↑
        }
	}
}

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

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define ft first
#define sd second
#define fr(i,n) for(int i=0;i<(n);++i)
#define Fr(i,n) for(int i=1;i<=(n);++i)
#define ifr(i,n) for(int i=(n)-1;i>=0;--i)
#define iFr(i,n) for(int i=(n);i>0;--i)

class B0Or1Swap {
public:
    void solve(istream& in, ostream& out) {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        int n;
        in>>n;
        vector<int> p(n);
        for(auto& i:p) in>>i;
        int tmp=0;
        fr(i,n) tmp+=(p[i]!=i+1);
        out<<(tmp<3?"YES":"NO")<<endl;
    }
};

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


Measured memory_bytes: 256
a={chr(i) for i in range(97,123)}
s=input()
n=len(s)
if n<26:
  print(s+sorted(a-set(s))[0])
else:
  for i in range(2,27):
    if s[-i]<s[-i+1]:
      break
    if i==26:
      print(-1)
      exit()
  for j in sorted(s[-i+1:]):
    if j>s[-i]:break
  print(s[:-i]+j)

Measured memory_bytes: 3064
#pragma GCC optimize("Ofast") 
#include<bits/stdc++.h>
#define l(i,a,b) for(auto i=a;i<b;i++)
#define lr(i,a,b) for(auto i=a;i>=b;i--)
#define ll long long
#define lli long long int
#define ld long double
#define vec vector<int>
#define mii map<ll,ll>
#define vl vector<long long>
#define se set <long long int>
#define pi pair<long long,long long>
#define pb push_back
#define mp make_pair
#define ft first
#define sd second
#define all(v) v.begin(), v.end()
#define in(x) cin>>x
#define o(x) cout<<x
#define SYNC ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define PI 3.14159265359
using namespace std;

ll count(ll k)
{
    ll p=0;
    while(k)
    {
        p+= (k/5);
        k/=5;
    }
    return p;
}


int main()
{
    SYNC
   // clock_t tStart = clock();
   // freopen("input.txt","r",stdin);
   // freopen("output.txt","w",stdout);
    ll a,b,c,d; in(a)>>b>>c>>d;
   // o(a)<<endl;
    ll ans = a*c;
    ans= max(ans, a*d);
    ans= max(ans, b*c);
    ans= max(ans, b*d);
    o(ans)<<endl;
    









    //printf("Time taken: %.2fs\n", (double)(clock() - tStart)/CLOCKS_PER_SEC);   
}


Measured memory_bytes: 3648
#pragma GCC target ("avx2")
#pragma GCC optimize ("unroll-loops")
#pragma GCC optimize ("O3")
#include "bits/stdc++.h"
#include <unordered_set>
#include <unordered_map>
#include <random>
using namespace std;
typedef long long ll;
const ll MOD = 1'000'000'007LL; /*998'244'353LL;*/
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int (i)=0; (i)<(n); (i)++)
const int dx[4]={ 1,0,-1,0 };
const int dy[4]={ 0,1,0,-1 };

int N;
ll A[200000];

signed main(){
    cin >> N;
    rep(i, N) cin >> A[i];
    sort(A, A+N);
    reverse(A, A+N);

    ll ans = A[0];
    int k = 2;
    for(int i=1; i<N; i++){
        for(int j=0; j<2 && k<N; j++,k++){
            ans += A[i];
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 5008
#include<bits/stdc++.h>
#define int long long
using namespace std;
const int INF = 1e9;
const int ZERO = 0;
const int MOD = 1000000007;
const double PI = 3.1415926535897;
typedef pair<int,int> P;

signed main() {
    int M1,D1;
    cin >> M1 >> D1;
    int M2,D2;
    cin >> M2 >> D2;
    if(D2 == 1) {
        cout << 1 << endl;
    }
    else {
        cout << 0 << endl;
    }
}

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

int a()
{
    int a, b, c;
    std::cin >> a >> b >> c;
    
    std::cout << c << " " <<  a << " " << b;
    
    return 0;
}

int main(int argc, const char * argv[])
{
    a();
    return 0;
}


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


int main(){
	char str[1001];
	while(1){
	scanf("%s",str);
	if(str[0]=='0') break;
	int sum=0;
	for(int i=0;i<strlen(str);i++){
	sum+=(str[i]-'0');
	}
	printf("%d\n",sum);
	}
  return 0;
}


Measured memory_bytes: 2760
#include <bits/stdc++.h>
using namespace std;
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;
}

#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define all(x) (x).begin(), (x).end() //sortなどの引数を省略したい
#define F first
#define S second

typedef long long ll;
const ll MOD = 1e9 + 7;
const int inf = 1000000;
const int minf = -1000000;
const ll lnf = 1e12;
const ll mlnf = -1e12;
const double e = 1e-10;

using Graph = vector<vector<int>>;

// global variery
int N;
int d[110];
int f[110];
int ans;

void solve();
void dfs(const Graph& G, int v);

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

void solve()
{
    cin >> N;
    Graph G(N);
    rep(i, N)
    {
        int hoge;
        cin >> hoge;
        int k;
        cin >> k;
        rep(j, k)
        {
            int tmp;
            cin >> tmp;
            tmp--;
            G[i].push_back(tmp);
        }
    }
    rep(i, N) d[i] = -1;
    rep(i, N) f[i] = -1;
    ans = 0;

    rep(i, N)
    {
        if (d[i] != -1)
            continue;
        ans++;
        dfs(G, i);
    }
    rep(i, N)
    {
        cout << i + 1 << " " << d[i] << " " << f[i] << endl;
    }
    return;
}

void dfs(const Graph& G, int v)
{
    d[v] = ans;
    for (auto nv : G[v]) {
        if (d[nv] != -1)
            continue;
        ans++;
        dfs(G, nv);
    }
    ans++;
    f[v] = ans;
}



Measured memory_bytes: 3208
#include <iostream>

int main() {
  using namespace std;

  int x, n;
  cin >> x >> n;

  bool flag[102] = { };
  int p;
  for (int i = 0; i < n; i++) {

    cin >> p;
    flag[p] = true;
  }

  int ans = 0;
  for (int i = 0; i < 102; i++) {
    if (flag[i]) {
      continue;
    } else if (abs(x - ans) > abs(x - i)) {
      ans = i;
    }
  }

  cout << ans;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
const int MAXN=10010;
int h,n,a,b,dp[MAXN];
int main () {
	scanf("%d%d",&h,&n);
	memset(dp,0x3f,sizeof(dp));
	dp[0]=0;
	for (int i=1;i<=n;i++) {
		scanf("%d%d",&a,&b);
		for (int i=a;i<=h;i++) {dp[i]=min(dp[i],dp[i-a]+b);}
		for (int i=max(h-a,0);i<=h;i++) {dp[h]=min(dp[h],dp[i]+b);}
	}
	printf("%d\n",dp[h]);
	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  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  INF 1LL << 60
typedef long long int LL;
typedef long long int ll;
#define pll pair<ll, ll>
#define F first
#define S second
const int MOD = 1000000007;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return true; } return false; }
//sort(all(x))とするとソートできるよ
// 10^x は pow(10,(x)) 
// 任意のlogは　対数の底の変換を使う    log(N) / log(任意の底)

typedef struct edge{
    int v;              // エッジの　終点　だと思われる
    LL w;               // エッジの　重み　だと思われる
    edge() {}                                              // 構造体のコンストラクタ 
    edge(int v, LL w) : v(v), w(w) {};                     // これはv,wを同時にpush_back(emplace_back)するために必要
} Edge;

vector<LL> dijkstra(int n, vector<vector<Edge> >& G, int s) {   // N , G , start (ノードは0-index)
    vector<LL> d(n, LLONG_MAX/10); d[s] = 0;                    // LLONG_MAX はlong　long　の最大値を呼び出す 
    priority_queue<pair<LL, int> > que;                         // p_queue の作成　s　はやっぱりstart地点の番号
    que.push(make_pair(0LL, s));                                // queue に　（0、辺の始点）をpushしてる。                 
    while (!que.empty()) {                                      // queue が空っぽになるまでループ
        auto p = que.top(); que.pop();                          // queue から一個もってくる
        int u = p.second;                                       // もってきたpairから　二番目の情報、つまり対象となるノード番号を獲得
        LL  dist = -p.first;                                    // dist は最短距離の一時変数で、 -p.first と負の数にしているのは、p_queue の greater を省略するため。逆順ソートしたいから。
        if (dist > d[u]) continue;                              // dはそのノードまでの最短距離を表現していると考えられる。
        for (Edge e : G[u]) {                                   // 作ったグラフの　u番目　のもつpairを呼び出してる
            if (d[e.v] > d[u]+e.w) {                            // d[e.v]はEdgeの接続先のこれまでの最短距離。　右辺は接続元までの距離＋辺の重み
                d[e.v] = d[u] + e.w;                            // 最短距離の更新 
                que.push(make_pair(-d[e.v], e.v));              // 更新したノードの（最短距離と番号）をpush
            }                                                   // つまり、拡張for文でpushされた要素たちは、最短距離を更新できなくなると廃棄されて行ってemptyになるということ。
        }
    }
    return d;                                                   // 各ノードまでのstart地点からの最短距離が出る。
}

int main(){
    int N,M;cin >> N >> M;
    vector<vector<Edge>> G(N);
    rep(i,M){
        int a,b;
        cin >> a >> b;
        a--,b--;
        G[a].emplace_back(b,1);
        G[b].emplace_back(b,1);
    }
    vector<LL> d(N,-1);
    d = dijkstra(N,G,0);
    if(d[N-1] <= 2 && d[N-1] != -1)cout << "POSSIBLE" << endl;
    else cout << "IMPOSSIBLE" << endl;
}




Measured memory_bytes: 20448
/* ex4_1
   offNaria */
#include <stdio.h>

int main(void){
  int number, range;
  scanf("%d %d", &number, &range); //監視員は2*range+1本の木を監視できる
  if(number % (2 * range + 1) == 0){
    printf("%d\n", number / (2 * range + 1)); //あまりなく監視できるなら必要人数を返す
  }else{
    printf("%d\n", number / (2 * range + 1) + 1); //そうでなければ(整数部分)+1を返す
  }
  return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
#define LL long long
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPA(i,n) for(int i=1;i<(n);++i)
#define PII pair<int,int>
#define PLI pair<long long, int>
#define PLL pair<long long, long long>
#define MOD ((int)1e9 + 7)
#define INF ((int)1e9)
#define INFLL ((LL)1e18)
#define ALL(x) (x).begin(),(x).end()
#define ctoi(x) (x - 'a') 
#define CTOI(x) (x - 'A')
#define BIT(x) (1 << (x))
#define int LL
using namespace std;

LL modinv(LL a){
    LL b = MOD, u = 1, v = 0;
    while(b){
        LL t = a / b;
        a -= t * b;swap(a, b);
        u -= t * v;swap(u, v);
    }
    u%=MOD;
    if(u < 0) u += MOD;
    return u;

}

LL exp(LL a, LL b){
    LL res = 1;
    LL sum = a;
    while(b){
        if(b&1)res = (res * sum);
        sum = (sum * sum);
        b>>=1;
    }
    return res;
}

LL lcd(LL a, LL b){
    LL c = a;
    LL d = b;
    while(d){
        c%=d;
        swap(c, d);
    }
    return a * b / c;
}

PII operator+(const PII &a, const PII &b){
    return PII(a.first + b.first, a.second + b.second);
}

PII operator-(const PII &a, const PII &b){
    return PII(a.first - b.first, a.second - b.second);
}
bool operator==(const PII &a, const PII &b){
    return (a.first == b.first) && (a.second == b.second);
}

signed main(){
    int N;
    cin >> N;
    vector<int> a(3), b(3);
    vector<PII> A, B;
    REP(i, 3)cin>>a[i];
    REP(i, 3)cin>>b[i];
    REP(i, 3){
        if(a[i] < b[i]){
            A.push_back({a[i], b[i]-a[i]});
        }else if(a[i] > b[i]){
            B.push_back({b[i], a[i]-b[i]});
        }
    }
    if(!A.empty()){
        vector<int> dp(N+1, 0);
        REP(i, A.size()){
            REP(j, N+1-A[i].first){
                dp[j+A[i].first] = max(dp[j+A[i].first], dp[j]+A[i].second);
            }
        }
        N += dp.back();
    }
    if(!B.empty()){
        vector<int> dp(N+1, 0);
        REP(i, B.size()){
            REP(j, N+1-B[i].first){
                dp[j+B[i].first] = max(dp[j+B[i].first], dp[j]+B[i].second);
            }
        }
        N += dp.back();    
    }
    cout << N << endl;
    return 0;
}


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

int main() {
long double a,b,c,d;
long double ans;
cin >> a >> b >> c >> d;
long double x=a-c;
long double y=b-d;
ans=sqrtl(x*x+y*y);
cout << fixed << setprecision(15) << ans <<endl;
}



Measured memory_bytes: 3288
class Card

	include Comparable
	attr_accessor :suit, :number

	def initialize(suit, number)
		@suit, @number = suit, number
	end

	def <=>(other)
		self.number - other.number
	end

	def to_s
		"#{@suit} #{@number}"
	end

	def eql?(other)
		self.suit == other.suit && self.number == other.number
	end

	def self.create_sentinel
		Card.new("Z", Float::INFINITY)
	end

end

def partition(array, from, to)
	separator = array[to]
	i = from - 1
	(from...to).each do |j|
		if array[j] <= separator
			i = i + 1
			array[i], array[j] = array[j], array[i]
		end
	end
	array[i + 1], array[to] = array[to], array[i + 1]
	i + 1
end

def quick_sort(array, from, to)
	return unless from < to
	pivot = partition(array, from, to)
	quick_sort(array, from, pivot - 1)
	quick_sort(array, pivot + 1, to)
end

def merge_sort(array, left, right)
	return 0 unless left + 1 < right
	mid = (left + right) / 2
	compared_count  = merge_sort(array, left, mid)
	compared_count += merge_sort(array, mid, right)
	compared_count += merge(array, left, mid, right)
	compared_count
end

def merge(array, left, mid, right)
	left_array_size  = mid - left
	right_array_size = right - mid

	left_array  = []
	left_array_size.times { |i| left_array << array[left + i] }

	right_array = []
	right_array_size.times { |i| right_array << array[mid + i] }

	left_array  << Card.create_sentinel
	right_array << Card.create_sentinel

	compared_count = 0
	i = j = 0
	(left...right).each do |k|
		if left_array[i] <= right_array[j]
			array[k] = left_array[i]
			i += 1
		else
			array[k] = right_array[j]
			j += 1
		end
		compared_count += 1
	end
	compared_count
end

cards = []
array_size = STDIN.gets.to_i
array_size.times do
	suit, number = STDIN.gets.split[0..1]
	cards << Card.new(suit, number.to_i)
end

original_cards = cards.dup
quick_sort(cards, 0, array_size - 1)
merge_sort(original_cards, 0, array_size)
puts cards.eql?(original_cards) ? "Stable" : "Not stable"
cards.each do |c|
	puts c
end

Measured memory_bytes: 92512
from collections import defaultdict
from collections import deque
from string import ascii_uppercase
import sys, bisect, math, heapq

stdin = sys.stdin
read_int = lambda : list(map(int,stdin.readline().split()))
read_str = lambda : stdin.readline().rstrip()

N = read_int()[0]

def solve():
    return rec(N)

def rec(n):
    if n == 1:
        return 1
    return 2 * rec(n // 2) + 1

if __name__ == "__main__":
    print(solve())

Measured memory_bytes: 3760
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.HashSet;
import java.util.Arrays;
import java.util.Scanner;
import java.util.Set;

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

    static class A {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int a = in.nextInt();
            int b = in.nextInt();
            int c = in.nextInt();
            Set<Integer> set = new HashSet<>(Arrays.asList(a, b, c));
            out.println(set.size());
        }

    }
}



Measured memory_bytes: 25172
#include <iostream>

using namespace std;

long long a[10001];

int main(){
    a[1] = 2;
    for(int i = 2; i <= 10000; i++){
        a[i] = a[i-1] + i;
    }
    int n;
    while(cin >> n){
        cout << a[n] << endl;
    }
}

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

using namespace std;

int main()
{
  int L, A, B, C, D;
  cin >> L >> A >> B >> C >> D;
  cout << L - max((A + (A%C != 0)*(C - A%C)) / C, (B + (B%D != 0)*(D - B%D)) / D) << endl;
  return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
#define int long long
#define mod (int)(1e9+7)
#define inf (int)(3e18+7)
#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 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;

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) {
	if (x == 0)return 1;
	return kai(x - 1) * x % mod;
}
int mod_pow(int x, int y, int mod_) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % mod_;
		}
		x = x * x % mod_;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x)* mod_pow(kai(x - y), mod - 2, mod) % mod * mod_pow(kai(y), mod - 2, mod) % mod;
}
/*--------Library Zone!--------*/

int ka[214514];
int comb_(int x, int y) {
	if (y > x)return 0;
	return ka[x] * mod_pow(ka[x - y], mod - 2, mod) % mod * mod_pow(ka[y], mod - 2, mod) % mod;
}
void init() {
	ka[0] = 1;
	REP(i, 214514)ka[i] = ka[i - 1] * i % mod;
}
int n, m, k;
signed main() {
	cin >> n >> m >> k;
	init();
	int ans = 0;
	//X座標
	REP(i, n) {
		ans += i * (n - i) * m % mod * m % mod * comb_(n * m - 2, k - 2) % mod;
		ans %= mod;
	}
	REP(i, m) {
		ans += i * (m - i) * n % mod * n % mod * comb_(n * m - 2, k - 2) % mod;
		ans %= mod;
	}
	cout << ans << endl;
}


Measured memory_bytes: 1920
#include <iostream>
#include <stdio.h>
#include <set>
#include<bits/stdc++.h>
#include <stack>
#include <queue>
#include <map>
#include <cmath>
#include <iomanip>
#include <vector>
#include <algorithm>
using namespace std;
long long int dp[402 ][402];
long long int sum[402];
int main(){
    int n;
    cin>>n;
    vector <long long int > v;v.push_back(0);
    for(int i = 0;i<n;i++){
        long long int z;
        cin>>z;
        v.push_back(z);
    }
    for(int i = 1;i<=n;i++){
        sum[i] = sum[i-1]+ v[i];
    }
    /// sum i- j = sum[j] - sum[i-1]
    for(int l = 2 ; l<=n;l++){
        for(int i = l;i<=n;i++){
            for(int j = i - l+1;j<=i;j++){
                if(dp[i-l+1][i]==0 ){
                    dp[i-l+1][i] = dp[i-l+1][j]+dp[j+1][i]+ sum[i ] - sum[i-l ];
                }
                else{
                    dp[i-l+1][i] = min(dp[i-l+1][j]+dp[j+1][i]+ sum[i ] - sum[i-l ],dp[i-l+1][i] );
                }
            }
        }
    }
    cout<<dp[1][n];
}


Measured memory_bytes: 1536
#include <iostream>
#include <vector>
using namespace std;
 
int main(void)
{
  int n;
  int cnt = 0;
  vector<int> v;
  cin >> n;
  
  int buf;
  for(int i = 0;i < n;i++)
  {
    cin >> buf;
  	v.push_back(buf);
    
  }
  
  for(int i = 0;i < n;i++)
  {
  	if(v[i] != i + 1)
      cnt ++;
    if (cnt >= 3)
    {
      cout << "NO";
      break;
    }
  }
  
  if(cnt < 3)
    cout << "YES";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
int main() {
  int N;
  cin >> N;
  vector<int> vec(N);
  rep(i, N) {
    cin >> vec.at(i);
  }
  sort(vec.begin(), vec.end());
  int c = 1;
  rep(i, N - 1) {
    if(vec.at(i) < vec.at(i + 1)) {
      c++;
    }
  }
  cout << c << endl;
}



Measured memory_bytes: 3636
n = int(input())
ab = [list(map(int,input().split())) for _ in range(n-1)]
c = list(map(int,input().split()))

c.sort(reverse = True)
edges = [[] for _ in range(n)]
ans = [-1]*n
ans[0] = c[0]
count = 1

for a,b in ab:
    edges[a-1].append(b-1)
    edges[b-1].append(a-1)

q = [0]

while q:
    l = q.pop(-1)
    for l1 in edges[l]:
        if ans[l1] == -1:
            q.append(l1)
            ans[l1] = c[count]
            count += 1

print(sum(c[1:]))
for i in ans:
    print(i, end = ' ')


Measured memory_bytes: 52568
/*
    Washief Hossain Mugdho
    17 September 2020
    Educational DP Frog1
*/

#ifndef DEBUG
#pragma GCC optimize("O3")
#endif

#include <bits/stdc++.h>
#define ull unsigned long long
#define ll long long
#define pb push_back
#define mp make_pair
#define fr first
#define sc second
#define fastio ios_base::sync_with_stdio(0)
#define untie cin.tie(0)
#define ms(a, b) memset(a, b, sizeof a)
using namespace std;

int main()
{
#ifdef LOCAL_OUTPUT
    freopen(LOCAL_OUTPUT, "w", stdout);
#endif
#ifdef LOCAL_INPUT
    freopen(LOCAL_INPUT, "r", stdin);
#endif

    int n;
    cin >> n;
    int a[n];
    vector<int> dp(n, INT32_MAX);
    dp[0] = 0;
    for (int i = 0; i < n; i++)
        cin >> a[i];
    for (int i = 0; i < n - 1; i++)
    {
        dp[i + 1] = min(dp[i + 1], dp[i] + abs(a[i + 1] - a[i]));
        if (i + 2 < n)
            dp[i + 2] = min(dp[i + 2], dp[i] + abs(a[i + 2] - a[i]));
    }
    cout << dp[n - 1] << endl;
}


Measured memory_bytes: 3984
h=int(input())
w=int(input())
n=int(input())
c1=0
c2=0
t=0
while t<n:
  if h-c2<=w-c1:
    t+=w-c1
    c2+=1
  else:
    t+=h-c2
    c1+=1
print(c1+c2)

Measured memory_bytes: 3060
#include <iostream>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <algorithm>
#include <climits>

using namespace std;

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

    int res = 0;

    int cur_max = INT_MIN;
    while (n--) {
        int k; cin >> k;
        if (k >= cur_max) res++;
        cur_max = max(cur_max, k);
    }

    cout << res << endl;

    return 0;
}

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

int a[200100];

signed main(){
    int n, k;
    cin >> n >> k;
    for(int i = 1; i <= n; i++){
        cin >> a[i];
    }
    int arr = 1, curr = 1;
    if(k <= n){
        while(k){
            arr = a[arr];
            k--;
        }
        cout << arr;
        return 0;
    }
    else{
        vector<int> v, cnt(n + 5, 0);
        cnt[1] = 1;
        arr = a[1];
        k--;
        while(k > 0){
            if(cnt[arr]){
                break;
            }
            cnt[arr] = 1;
            arr = a[arr];

            k--;
        }
        int ver = arr;
        v.pb(ver);
        arr = a[ver];
        v.pb(arr);
        while(k > 0){
            if(a[arr] == ver){
                break;
            }
            arr = a[arr];
            v.pb(arr);
        }
        k %= v.size();
        cout << v[k];
    }
}


Measured memory_bytes: 7364
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii =  pair<int, int>;
using pll =  pair<long long, long long>;
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
constexpr long long INF = 1000000009LL;
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define fo(i,j,n) for (int i=(j); i < (n); i++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }


int main() {    
    double a, b, h, m; cin >> a >> b >> h >> m;
    
    double sh = h * (360.0 / 12.0) + m * (1 / 2.0);
    double lo = m * (360.0/ 60.0);

    double ang = abs(lo - sh);
    ang = min(ang, (360 - ang));
    ang = ang * M_PI / 180.0;

    double res;
    cout << fixed << setprecision(15); 
    res = b * b + a * a - cos(ang) * 2 * b * a;
    cout << sqrt(res) << ln;
}

Measured memory_bytes: 4052
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int A,B,K,i;
  cin>>K>>A>>B;
  i=A;
  while(i<=B){if(i%K==0)return cout<<"OK"<<endl,0;i++;}
  return cout<<"NG"<<endl,0;
}

Measured memory_bytes: 3636