akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>
#include <bitset>
#include <iomanip>
#include <stack>
#include <list>
#include <map>
#include <unordered_map>
#include <chrono>
#include <numeric>
#include <set>
using namespace std;
using ll = long long;
const ll INF = (ll)1e18+1;
const ll DIV = 1000000007;
class UnionFind
{
private:
    vector<ll> data;
    vector<ll> tree_size;

public:
    UnionFind(ll n)
    {
        data = vector<ll>(n);
        tree_size = vector<ll>(n, 1);
        for (ll i = 0; i < n; ++i)
        {
            data[i] = i;
        }
    }

    ll root(ll a)
    {
        if (data[a] == a) return a;
        else return data[a] = root(data[a]);
    }

    void unite(ll a, ll b)
    {
        ll root_a = root(a);
        ll root_b = root(b);
        if (root_a == root_b)
            return;
        else
        {
            tree_size[root_b] += tree_size[root_a];
            tree_size[root_a] = 0;
            data[root_a] = root_b;
            return;
        }
        return;
    }
    ll get_tree_size(ll a)
    {
        return tree_size[root(a)];
    }
};

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
#ifdef TEST
    chrono::system_clock::time_point start, end;
    start = chrono::system_clock::now();
#endif
    long N, M;
    cin >> N >> M;
    vector<ll> A(M), B(M);
    //vector<set<ll>> friends(N);
    UnionFind uf = UnionFind(N);
    for(size_t i=0;i<M; i++)
    {
        cin >> A[i] >> B[i];
        uf.unite(A[i]-1, B[i]-1);
    }
    ll max_size=0;
    for(size_t i=0;i<N; i++)
    {
        max_size = max(max_size, ll(uf.get_tree_size(i)));
    }

    cout << max_size << endl;
#ifdef TEST
    end = chrono::system_clock::now();
    cerr << static_cast<double>(chrono::duration_cast<chrono::microseconds>(end - start).count() / 1000.0) << "[ms]" << endl;
#endif
    return 0;
}

Measured memory_bytes: 15228
//ヘッダー
#include<bits/stdc++.h>
using namespace std;


//定数
const int INF=1e+9;
const int MOD=1e+9+7;

//REPマクロ
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define REPD(i,n) for(int i=n-1;i>=0;i--)
#define REP2(i,a,b) for(int i=a;i<(int)(b);i++)
#define REPD2(i,a,b) for(int i=a;i>(int)(b);i--)

// 多次元 vector 生成
template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}
template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
  return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

//vectorの扱い
#define ALL(x) (x).begin(),(x).end() //sortなどの引数省略
#define SIZE(x) ((int)(x).size()) //size
#define MAX(x) *max_element(ALL(x)) //最大値
#define MIN(x) *min_element(ALL(x)) //最小値

bool L[5010][5010];
bool R[5010][5010];
int sumr[5010][5010];


int main(){
    int N,K;
    cin>>N>>K;
    vector<int> a(N);
    
    REP(i,N) cin>>a[i];
    sort(ALL(a));
    REP(i,5010){
        REP(j,5010){
            if(j==0){
                L[i][j]=true;
                R[i][j]=true;
            }else{
                L[i][j]=false;
                R[i][j]=false;
            }
        }
    }
    REP(i,N){
        REP(j,5010){
            if(a[i]>=K) continue;
            if(j-a[i]>=0){
                L[i+1][j]=L[i][j-a[i]]|L[i][j];
            }else{
                L[i+1][j]=L[i][j];
            }
        }
    }

    sort(ALL(a),greater<int>());
    REP(i,N){
        REP(j,5010){
            if(a[i]>=K) continue;
            if(j-a[i]>=0){
                R[N-1-i][j]=R[N-i][j-a[i]]|R[N-i][j];
            }else{
                R[N-1-i][j]=R[N-i][j];
            }
        }
    }


    sort(ALL(a));

    int ans=0;
    
    REP(i,5010){
        REP(j,5010){
            sumr[i][j]=0;
        }
    }

    REP(i,5010){
        REP(j,5009){
            sumr[i][j+1]=sumr[i][j]+R[i][j];
        }
    }

    REP(i,N){
        if(a[i]>=K) continue;
        bool flag=true;
        REP(j,K+1){
            if(!L[i][j]) continue;
            int l=max(K-a[i]-j,0);
            int r=K-j;
            if(sumr[i+1][r]-sumr[i+1][l]>0){
                flag=false;
                break;
            }
        }
        if(flag){
            ans++;
        }
    }
    cout<<ans<<endl;


}

Measured memory_bytes: 150708
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#define int long long

using namespace std;
typedef long long LL;
const int N=1000005;
const int MOD=1e9+7;

int n,m,k,ans,fac[N],inv[N],sum;

inline int fast_pow(int x,int y){
	int ret=1;
	for(;y;y>>=1){
		if(y&1) ret=1ll*ret*x%MOD;
		x=1ll*x*x%MOD;
	}
	return ret;
}

inline int C(int x,int y){
	return 1ll*fac[x]*inv[y]%MOD*inv[x-y]%MOD;	
}

signed main(){
	scanf("%lld%lld%lld",&n,&m,&k);
	fac[0]=inv[0]=1; sum=n+m+k;
	for(int i=1;i<=sum;i++) fac[i]=1ll*fac[i-1]*i%MOD;
	inv[sum]=fast_pow(fac[sum],MOD-2);
	for(int i=sum-1;i;i--) inv[i]=1ll*inv[i+1]*(i+1)%MOD;
//	for(int i=n;i<=sum;i++){
//		int now=0;
//		for(int j=max(i-n-m,1ll*0);j<=min(k,i-n);j++)
//			(now+=C(i-n,j))%=MOD;
//		ans+=now%MOD*C(i-1,n-1)%MOD*fast_pow(3,sum-i)%MOD;
//		ans%=MOD;
//	}
//	cout<<ans<<endl; ans=0;
	if(m<k) swap(m,k); int now=1;
	for(int i=n;i<=sum;i++){
		if(k+n>=i) {
			(ans+=1ll*C(i-1,n-1)*fast_pow(3,sum-i)%MOD*now%MOD)%=MOD;
			if(k+n!=i) now=now*2%MOD; 	
		}
		else if(n+m>=i) {
			now=now*2-C(i-n-1,k);
			now=(now%MOD+MOD)%MOD;
			(ans+=1ll*now*C(i-1,n-1)%MOD*fast_pow(3,sum-i)%MOD)%=MOD;
		}
		else {
			now=now*2-C(i-n-1,k); now=(now%MOD+MOD)%MOD;
			now=(now-C(i-n-1,i-n-m-1)+MOD)%MOD;
			(ans+=1ll*now*C(i-1,n-1)%MOD*fast_pow(3,sum-i)%MOD)%=MOD;
		}
	}
//	for(int i=n;i<=sum;i++) {
//		(ans+=1ll*C(i-1,n-1)*fast_pow(2,i-n)%MOD*fast_pow(3,sum-i)%MOD)%=MOD;
//		if(i==8) cout<<ans<<endl;
//		if(n+k+1<=i) 
//			(ans-=1ll*C(i-1,n-1)*C(i-n,k+1)%MOD*fast_pow(2,i-n-k-1)%MOD*fast_pow(3,sum-i)%MOD)%=MOD;
//		if(i==8) cout<<ans<<endl;
//		if(n+m+1<=i)
//			(ans-=1ll*C(i-1,n-1)*C(i-n,m+1)%MOD*fast_pow(2,i-n-m-1)%MOD*fast_pow(3,sum-i)%MOD)%=MOD;
//		cout<<ans<<endl;
//	}
//	for(int i=n+m;i<sum;i++){
//		(ans-=1ll*now*fast_pow(3,sum-n-m)%MOD)%=MOD;
//		now=1ll*now*i%MOD; now=(now+C(n+m,i-n-m+1))%MOD;	
//	}
//	now=1;
//	for(int i=n+k;i<sum;i++){
//		(ans-=1ll*now*fast_pow(3,sum-n-k)%MOD)%=MOD;
//		now=1ll*now*i%MOD; now=(now+C(n+k,i-n-k+1))%MOD;
//	}	
	printf("%lld\n",(ans+MOD)%MOD);
	return 0;
}	

Measured memory_bytes: 15104
N = int(input())
P = list(map(int, input().split()))

A = [1 for i in range(N)]
B = [1 for i in range(N)]

for i in range(N):
    A[P[i] - 1] += i
    B[P[i] - 1] += i

for i in range(N - 1):
    A[i + 1] += A[i]
    B[N - i - 2] += B[N - i - 1]

print(*A)
print(*B)

Measured memory_bytes: 45956
package main

import (
	"fmt"
)

var table = make([][]int, 3)

func main() {
	for i := 0; i < 3; i++ {
		column := make([]int, 3)
		var a, b, c int
		fmt.Scan(&a, &b, &c)
		column[0], column[1], column[2] = a, b, c
		table[i] = column
	}
	// 縦, 横
	var a1, a2, a3, b1, b2, b3 int
	ans := false
	// 0<=as[0]<=100として調べる
	for ; a1 <= 100; a1++ {
		b1 = table[0][0] - a1
		b2 = table[0][1] - a1
		b3 = table[0][2] - a1
		a2 = table[1][0] - b1
		a3 = table[2][0] - b1
		if a2+b2 == table[1][1] && a2+b3 == table[1][2] && a3+b2 == table[2][1] && a3+b3 == table[2][2] {
			ans = true
			break
		}
	}
	if ans {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}

}


Measured memory_bytes: 512
K,N = map(int, input().split())
A = list(map(int, input().split()))
A.append(A[0]+K)
max_d = A[1] - A[0]
for i in range(N):
  d = A[i+1] - A[i]
  if max_d < d:
    max_d = d
print(K - max_d)

Measured memory_bytes: 26420
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
using namespace std;

int top{}, S[10000]{};

void push(int x) {
    S[++top] = x;
}

int pop() {
    return S[top--];
}

int main() {
    int a, b;
    char s[10000]{};
    
    while(scanf("%s", s) != EOF) {
        if(s[0] == '+') {
            a = pop();
            b = pop();
            push(a + b);
        } else if(s[0] == '-') {
            b = pop();
            a = pop();
            push(a - b);
        } else if(s[0] == '*') {
            a = pop();
            b = pop();
            push(a * b);
        } else {
            push(atoi(s));
        }
    }
    
    cout << pop() << endl;
    
    return 0;
}


Measured memory_bytes: 3176
#include<bits/stdc++.h>
#define f(i,n) for(int i=0;i<n;i++) 
#define fr(i,a,b) for(int i=a;i<b;i++) 
#define F first 
#define S second 
#define ll long long 
#define mp make_pair 
#define pb push_back 

using namespace std;

void test(){
	int a,b,c;
	cin>>a>>b>>c;
	swap(a,b);
	swap(a,c);
	cout<<a<<" "<<b<<" "<<c<<"\n";
}

int main(){
//	std::ios::sync_with_stdio(false);
//	cin.tie(0);
//	cout.tie(0);
	int t=1;
//	cin>>t;
	while(t--){
		test();
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <stdio.h>
#include <algorithm>
 
using namespace std;
#define rep(i,a,b) for (ll i = a; i < b; i++)
#define rrep(i,a,b) for (ll i = a; i >= b; i--)
#include <bits/stdc++.h>
#include <stdio.h>
#include <algorithm>
 
using namespace std;
#define rep(i,a,b) for (ll i = a; i < b; i++)
#define rrep(i,a,b) for (ll i = a; i >= b; i--)
#define l(s) s.length()
#define sort(v) sort(v.begin(), v.end());
#define scan(v,n) rep(i,0,n) {ll k; cin >> k; v.pb(k);}
#define print(v,n) {rep(i,0,n) cout << v[i] << " "; cout << endl;}
#define printstr(s,n) {rep(i,0,n) cout << s[i]; cout << endl;}
#define rev(a) reverse(a.begin(), a.end());
#define pb push_back
typedef long long ll;
typedef long double lld;
typedef vector<pair<ll,ll>> vpi;
typedef vector<ll> vi;
 
const ll mxN=2e5;
const ll N=1e9+7;
 
ll dp[mxN]; 
 
  int main() {
      int T=1;// cin >> T;
      while(T--){
          ll n,k; cin >> n >> k; vi v; scan(v,n);
          //dp[1]=abs(v[1]-v[0]);
          rep(i,1,n) dp[i]=N;
          rep(i,0,n) {
             for(ll j=i+1; j<n&&j<i+k+1 ;++j) {
                 if(dp[j]>dp[i]+abs(v[j]-v[i])) dp[j]=dp[i]+abs(v[j]-v[i]);
             }
          }
          cout << dp[n-1];
      } 
      
	 return 0;
}


Measured memory_bytes: 4840
#include <bits/stdc++.h>
#include <atcoder/all>
#include <iostream>
using namespace std;
using namespace atcoder;
using pint = pair<int, int>;
using ll = long long;
using ull = unsigned long long;
using vll = vector<long long>;
using pll = pair<ll, ll>;
#define FOR(i, begin, end) \
    for (int i = (begin), i##_end_ = (end); i < i##_end_; i++)
#define IFOR(i, begin, end) \
    for (int i = (end)-1, i##_begin_ = (begin); i >= i##_begin_; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#define VREP(s, ite) for (auto ite = s.begin(); ite != s.end(); ++ite)
#define FI first
#define SE second
#define ALL(v) v.begin(), v.end()
#define endl "\n"
#define ciosup  \
    cin.tie(0); \
    ios::sync_with_stdio(false);
#define eb emplace_back
#define vint vector<int>
constexpr ll INF = 1e15 + 7LL;
constexpr ll MOD = 998244353;
template <typename T>
istream &operator>>(istream &is, vector<T> &v) {
    for (int i = 0; i < v.size(); ++i) {
        is >> v[i];
    }
    return is;
}
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v) {
    if (v.size() == 0) return os;
    for (int i = 0; i < v.size() - 1; ++i) {
        os << v[i] << " ";
    }
    os << v[v.size() - 1];
    return os;
}

using mint = modint998244353;

struct S {
    mint a;
    mint b;
};

struct F {
    mint a;
};

S op(S l, S r) {
    return {l.a + r.a, l.b + r.b};
}

S e() { return S{0, 0}; }

S mapping(F l, S r) {
    if (l.a == 0) return r;
    return S{l.a*r.b, r.b}; 
}

F composition(F l, F r) {
    if (l.a == 0) return r;
    if (r.a == 0) return l;
    return F {l.a};
}

F id() { return F{0}; }

void solve() {
    ll n,q;
    cin >> n >> q;
    vector<S> a(n);
    mint now = 1;
    REP(i,n) {
        S nowS {now, now};
        a[n - 1 - i] = nowS;
        now *= 10;
    }
    lazy_segtree<S, op, e, F, mapping, composition, id> seg(a);
    REP(i,q) {
        int l,r;
        int d;
        cin >> l >> r >> d;
        --l;--r;
        seg.apply(l, r+1, F {d});
        S ans = seg.all_prod();
        cout << (ans.a).val() << endl;
    }
}


int main() {
    solve();
    char tmp;
    while (cin >> tmp) {
        cin.putback(tmp);
        solve();
    }
}



Measured memory_bytes: 9872
def main(n, m, a_b):
    road = [list() for n in range(n)]

    for a, b in a_b:
        road[a - 1].append(b)
        road[b - 1].append(a)

    for l in road:
        print(len(l))


if __name__ == "__main__":
    n, m = map(int, input().split(" "))
    a_b = [list(map(int, input().split())) for _ in range(m)]

    main(n, m, a_b)


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

using ll = long long;
#define MIN(a, b) (((a) < (b)) ? (a) : (b))
#define MAX(a, b) (((a) < (b)) ? (b) : (a))

int main() {
  int a, b;
  std::cin >> a >> b;
  if(a <= 0 && 0 <= b)
    std::cout << "Zero";
  else if(0 < a)
    std::cout << "Positive";
  else if(b < 0) {
    int sum = a + b;
    if(sum % 2 == 0)
      std::cout << "Negative";
    else
      std::cout << "Positive";
  }
  return 0;
}


Measured memory_bytes: 3608
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<algorithm>
#include<cmath>
#include<climits>
#include<string>
#include<set>
#include<numeric>
#include<map>
#include<iostream>
using namespace std;
#define rep(i,n) for(int i = 0;i<((int)(n));i++)
#define reg(i,a,b) for(int i = ((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i = ((int)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(int i = ((int)(b));i>=((int)(a));i--)
typedef long long ll;
typedef pair<ll, ll> mp;

ll A,B,C;

int main(void){
	cin>>A>>B>>C;
	if(A==B){
		printf("%lld",C);
	}else{
		if(A==C){
			printf("%lld",B);
		}else{
			printf("%lld",A);
		}
	}
	return 0;
}

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

const ll mod=1000000007;

int main() {
  ll k,a,b;
  cin >> k >> a >> b;
  if(a%k==0)cout<<"OK"<<endl;
  else if(b/k>=a/k+1)cout<<"OK"<<endl;
  else cout<<"NG"<<endl;
}


Measured memory_bytes: 3612
main :: IO ()
main = do
  [x, y] <- map read . words <$> getLine
  let group = [1, 3, 1, 2, 1, 2, 1, 1, 2, 1, 2, 1]
  putStrLn $ if group !! (x - 1) == group !! (y - 1) then "Yes" else "No"

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

int main() {
  int X, A, B;
  scanf("%d%d%d", &X, &A, &B);
  if (B <= A) {
    printf("delicious");
  } else if (B <= (A + X)) {
    printf("safe");
  } else {
    printf("dangerous");
  }
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <queue>

using namespace std;

const int nmax = 1e9 + 7;
typedef long long ll;

int GCD(int a, int b){
  int M = max(a, b), m = min(a, b);
  if (m == 0){
    return M;
  }else{
    while (M % m != 0){
      int res = M % m;
      M = m; m = res;
    }
    return m;
  }
}

int main(){

  int N; cin >> N;
  vector <int> A(N);
  for (int i = 0; i < N; i++){
    cin >> A[i];
  }
  sort(A.begin(), A.end());

  vector <int> L(N), R(N);
  L[0] = 0; L[1] = A[0];
  for (int i = 2; i < N; i++){
    L[i] = GCD(A[i - 1], L[i - 1]);
  }
  
  R[N - 1] = 0; R[N - 2] = A[N - 1];
  for (int i = N - 3; i >= 0; i--){
    R[i] = GCD(R[i + 1], A[i + 1]);
  }
  
  int ans = 0;
  for (int i = 0; i < N; i++){
    if (ans < GCD(L[i], R[i])){
      ans = GCD(L[i], R[i]);
    }
  }
  cout << ans << endl;
  
  return 0;
}


Measured memory_bytes: 1408
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>


int main(){
  int n,m;
  char s;
    
  
  scanf("%d",&n);

  printf("%d\n",(int)(n+n*n+n*n*n));
  
  return 0;
}


Measured memory_bytes: 1736
#include <iostream>
#include <utility>
#include <map>
#include <vector>
#include <algorithm>
#include <queue>
#include <math.h>
#include <stack>
#include <set>
#include <deque>
#include <cmath>

using namespace std;
typedef long long ll;
ll mod = 1e9+7;
//ll mod = 998244353;
#define rep(i,n) for(int i = 0; i < (n); ++i)

int main() {
    ll x;
    cin >> x;
    ll idx = 1;
    ll sum = 0;
    while(1) {
        if (sum >= x) {
            cout << idx - 1 << endl;
            return 0;
        }
        sum += idx;
        ++idx;
    }
    return 0;
}


Measured memory_bytes: 3584
#設定
import sys
input = sys.stdin.buffer.readline

#ライブラリインポート
from collections import defaultdict

#入力受け取り
def getlist():
	return list(map(int, input().split()))

#処理内容
def main():
	T1, T2 = getlist()
	A1, A2 = getlist()
	B1, B2 = getlist()
	if A1 * T1 + A2 * T2 == B1 * T1 + B2 * T2:
		print("infinity")
		return

	if A1 - B1 > 0 and A1 * T1 + A2 * T2 > B1 * T1 + B2 * T2:
		print(0)
		return

	if B1 - A1 > 0 and A1 * T1 + A2 * T2 < B1 * T1 + B2 * T2:
		print(0)
		return

	x = A1 - B1
	y = A2 - B2
	if x > 0:
		ans = 0
		dif = -y * T2 - x * T1
		if (x * T1) % dif == 0:
			ans += 2 * int((x * T1) // dif)
		else:
			ans += 2 * int((x * T1) // dif) + 1
		print(ans)
		return

	if x < 0:
		ans = 0
		dif = y * T2 + x * T1
		if (-x * T1) % dif == 0:
			ans += 2 * int((-x * T1) // dif)
		else:
			ans += 2 * int((-x * T1) // dif) + 1
		print(ans)
		return


if __name__ == '__main__':
	main()

Measured memory_bytes: 38480
def insertionSort(A, N):
    for i in range(1, N):
        print (*A)
        v = A[i]
        j = i - 1
        while j>= 0 and A[j] > v:
            A[j+1] = A[j]
            j -= 1
        A[j+1] = v
    return A


if __name__ == "__main__":
    N = int(input())
    A = [int(i) for i in input().split()]

    print (*insertionSort(A, N))

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

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

    //good luck kittu!
    int n, m, p; cin>>n>>m;
    string s;
    set<int> correct, wrong;
    map<int, int> attempts;
    int penalty = 0;
    while(m--){
        cin>>p>>s;
        if(s=="WA" && correct.count(p)==0){
            wrong.insert(p);
            attempts[p]++;
        }
        else if(s=="AC" && wrong.count(p)==0) correct.insert(p);
        else if(s=="AC" && wrong.count(p)!=0){
            correct.insert(p);
            wrong.erase(p);
            penalty += attempts[p];
            attempts[p] = 0;
        }
    }

    cout<<correct.size()<<" "<<penalty<<"\n";
    return 0;
}

Measured memory_bytes: 6144
#include<iostream>
#include<bits/stdc++.h>
#define LL long long int
using namespace std;
int main()
{
		LL n;
		cin>>n;
		LL a[n];
		map<LL,LL>m;
		LL sum=0;
		LL x=0;
		for(LL i=0; i<n; i++)
		{
			cin>>a[i];
			x=x^a[i];
		}
		for(LL i=0; i<n; i++)
		{
			cout<<(LL)(x^a[i])<<" ";
		}
		cout<<"\n";
		
}


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

typedef long long LL;
typedef long double LD;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;
typedef pair<LD, LD> PDD;

#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x).size()
#define dbl(k, x) fixed << setprecision(k) << (x)

template <typename _T>
inline void _DBG(const char *s, _T x) {
  cerr << s << " = " << x << "\n";
}
template <typename _T, typename... args>
void _DBG(const char *s, _T x, args... a) {
  while (*s != ',') cerr << *s++;
  cerr << " = " << x << ',';
  _DBG(s + 1, a...);
}

#define _upgrade                \
  ios_base::sync_with_stdio(0); \
  cin.tie(0);                   \
  cout.tie(0);
#define DBG(...) _DBG(#__VA_ARGS__, __VA_ARGS__)

// ********************** CODE ********************** //

int main() {
  _upgrade;
  int a, b, h, m;
  cin >> a >> b >> h >> m;
  LD ang_h = (LD)(60 * h + m) / (LD)(60 * 12) * 2 * M_PI;
  LD ang_m = (LD)m / (LD)60 * 2 * M_PI;
  LD ang = abs(ang_h - ang_m);

  LD res = sqrt(a * a + b * b - 2 * a * b * cos(ang));

  cout << dbl(12, res) << "\n";
  return 0;
}

Measured memory_bytes: 4200
#include <stdio.h>

typedef struct { char suit, value; } Card;

void bubble(Card A[], int N) {
  int i,j;
  Card t;
  for(i = 0; i<N; i++) {
    for(j = N-1; j >= i; j--) {
      if(A[j].value < A[j-1].value) {
        t = A[j]; A[j] = A[j-1]; A[j-1] = t;
      }
    }
  }
}

void selection(Card A[], int N) {
  int i,j,minj;
  Card t;
  for(i=0;i<N;i++) {
    minj = i;
    for(j=i; j<N; j++) {
      if(A[j].value < A[minj].value) minj = j;
    }
    t = A[i]; A[i] = A[minj]; A[minj] = t;
  }
}

void print(Card A[], int N) {
  int i;
  for(i=0; i<N; i++) {
    if(i>0) printf(" ");
      printf("%c%d",A[i].suit,A[i].value);
  }
  printf("\n");
}

int isStable(Card C1[], Card C2[], int N) {
  int i;
  for(i=0; i<N; i++) {
    if(C1[i].suit != C2[i].suit) return 0;
  }
  return 1;
}

void str2Card(Card *t,char str[]) {
    t->suit  = str[0];
    t->value = str[1] - '0';
}

int main(void) {
  Card C1[100], C2[100];
  int N,i;
  char str[3];

  scanf("%d",&N);
  for(i=0;i<N; i++) {
    scanf("%s",str);
    str2Card(&C1[i],str);
  }

  for(i=0; i<N; i++) C2[i] = C1[i];

  bubble(C1,N);
  selection(C2,N);

  print(C1,N);
  printf("Stable\n");
  print(C2,N);
  if(isStable(C1,C2,N)) {
    printf("Stable\n");
  } else {
    printf("Not stable\n");
  }

  return 0;
}


Measured memory_bytes: 2116
#include<stdio.h>
#include<stdlib.h>
#include<limits.h>

int Chain(int);
int min(int, int, int);

int sec[101];
int m[101][101];

main(){
  int n, i;

  int min;

  scanf("%d", &n);
  
  for(i = 1; i <= n; i++){
    
    scanf("%d %d", &m[i][0], &m[i][1]);
    
  }
  
  for(i = 0; i < n; i++){

    sec[i] = m[i+1][0];
 
  }
  sec[n] = m[n][1];
  i = Chain(n);
  printf("%d\n",m[1][i]);
 
 return 0;

}

int Chain(int n){
  
  int i, l, j, k, q;
  
  for(i = 1; i <= n; i++){
    
    m[i][i] = 0;
  
  }
 
  for(j = 2; j <= n; j++){
    for(i = 1; i <= n - j + 1; i++){
      
      l = i + j - 1;
      
      m[i][l] = INT_MAX;
      
      for(k = i; k <= l-1; k++){
	
	q = m[i][k] + m[k+1][l] + sec[i-1]*sec[k]*sec[l];
	 
	m[i][l] = min(i, l, q);

      }
    }
  }
  return l;
}

int min(int i, int j, int min){

  if(m[i][j] > min)
    return min;

  return m[i][j];
}

Measured memory_bytes: 636
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<algorithm>
#include<queue>
#include<vector>
#include<set>
#include<set>
#include<map>
#include<ctime>
#include<iostream>
using namespace std;
typedef long long LL;
int vis[4];
int main()
{
	int A,B,C;
	while( ~scanf(" %d %d %d",&A,&B,&C) ){
		for( int i = 1 ; i <= 3 ; i++ )	vis[i] = 0;
		int max_t = max(A,B);
		max_t = max(max_t,C);
		int flag = 0;
		if( A == max_t ){
			vis[1] = 1;
			flag += 1;
		}
		if( B == max_t ){
			vis[2] = 1;
			flag += 1;
		}
		if( C == max_t ){
			vis[3] = 1;
			flag += 1;
		}
		if( flag == 1 ){
			int d1,d2;
			if( vis[1] == 1 ){
				d1 = max(A - B,A - C);
				d2 = min(A - B,A - C);
				if( d1 == d2 ){
					printf("%d\n",d1);
				}
				else{
					if( (d1 - d2) % 2 == 0 ){
						printf("%d\n",(d1-d2)/2+d2);
					}
					else
						printf("%d\n",(d1-d2)/2+1+d2+1);
				}
			}
			if( vis[2] == 1 ){
				d1 = max(B - A,B - C);
				d2 = min(B - A,B - C);
				if( d1 == d2 ){
					printf("%d\n",d1);
				}
				else{
					if( (d1 - d2) % 2 == 0 ){
						printf("%d\n",(d1-d2)/2+d2);
					}
					else
						printf("%d\n",(d1-d2)/2+1+d2+1);
				}
			}
			if( vis[3] == 1 ){
				d1 = max(C - A,C - B);
				d2 = max(C - A,C - B);
				if( d1 == d2 ){
					printf("%d\n",d1);
				}
				else{
					if( (d1 - d2) % 2 == 0 ){
						printf("%d\n",(d1-d2)/2+d2);
					}
					else
						printf("%d\n",(d1-d2)/2+1+d2+1);
				}
			}
		}
		else if( flag == 2 ){
			int d1,d2;
			if( vis[1] == 1 )	d1 = A;
			else if( vis[2] == 1 )	d1 = B;
			if( vis[1] == 0 )	d2 = A;
			else if( vis[2] == 0 )	d2 == B;
			else	d2 = C;
			int sum = 0;
			if( (d1 - d2) % 2 == 1 )
				sum = (d1-d2)/2+2;
			else
				sum = (d1-d2)/2;
			printf("%d\n",sum);
		}
		else if( flag == 3 )
			printf("0\n");
	}
}

Measured memory_bytes: 256
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ll long long
#define rep(i,n) for(ll i=0;i<(n);i++)
#define pll pair<ll,ll>
#define pq priority_queue
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define lb(c,x) distance(c.begin(),lower_bound(all(c),x))
#define ub(c,x) distance(c.begin(),upper_bound(all(c),x))

using namespace std;

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;}

const ll INF=1e9+7;

int main(){
    ll n;
    cin >> n ;
    vector<string> a(3);
    rep(i,3){
        cin >> a[i];
    }
    ll ans=0;
    rep(i,n){
        set<char> s;
        rep(j,3){
            s.insert(a[j][i]);
        }
        ans+=s.size()-1;
    }
    cout << ans << endl;
}

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

const int MOD = 1000000007;

int main(void){
  int N, M;
  cin >> N >> M;
  vector<int> vec(N, 0);
  for(int i = 0; i < M; i++){
    int temp;
    cin >> temp;
    vec[temp] = 1;
  }
  
  vector<int> dp(N + 1, 0);
  dp[0] = 1;
  if(vec[1] == 0) dp[1] = 1;
  for(int n = 2; n <= N; ++n){
   if(vec[n - 1] == 0) dp[n] += dp[n - 1];
    if(vec[n - 2] == 0) dp[n] += dp[n - 2];
    dp[n] %= MOD;
    
  }
  cout << dp[N] << endl;
  return 0;
}

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

int main()
{
  int N;

  cin >> N;

  vector<int> W(N);
  for (int i = 0; i < N; i++)
  {
    cin >> W.at(i);
  }

  int sum_R = std::accumulate(W.begin(), W.end(), 0), sum_L = 0;
  for (int s : W)
  {
    sum_L += s;
    sum_R -= s;
    if (sum_L > sum_R)
    {
      int result = (sum_L > (sum_R + s)) ? (sum_R + 2 * s - sum_L) : (sum_L - sum_R);
      cout << result << endl;
      break;
    }
  }

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<functional>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<tuple>
#include<stack>
#include<queue>
#include<deque>
#include<sstream>
#include<stdio.h>
#include<math.h>
#include<stdlib.h>
#include<bitset>
#include<time.h>
#include<cstdlib>
#include<cassert>
#define ll long long
#define fi first
#define se second
using namespace std;

int n;
                   
int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.precision(10);
  cout<<fixed;
#ifdef LOCAL_DEFINE
    freopen("in", "r", stdin); 
    freopen("out","w",stdout);
#endif
  cin>>n;
  int maxi=0;
  for(int i=0;i<=n;i++){
    if(i*(i+1)>=2*n){
      maxi=i;
      break;
    }
  }
  for(int i=maxi;i>0;i--){
    if(n==0)break;
    if(n>=i){
      cout<<i<<"\n";
      n-=i;
    }
  }
#ifdef LOCAL_DEFINE
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
  return 0;
}

Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let r : i32 = read();
    println!("{}", if r < 1200 {
        "ABC"
    } else if r < 2800{
        "ARC"
    } else {
        "AGC"
    });
}


Measured memory_bytes: 4352
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>

using namespace std;

int main(){
    int S;

    cin >> S;

    int h = S/3600;
    int m = (S%3600)/60;
    int s = S%3600 - m*60;

    printf("%d:%d:%d\n",h,m,s);
    return 0;
}


Measured memory_bytes: 3184
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#pragma GCC optimize("Ofast")
//*********************************************DO IT NOW****************************************************************
#include<bits/stdc++.h> 
#include<random>
#define int long long   
#define pp pair<int,int> 
#define ss second 
#define ff first 
#define pb push_back
#define mod 1000000007
#define pi 3.14159265359
#define mk(arr,n,type)  type *arr=new type[n];
#define sl s1.length();
#define yes cout<< "YES"<<endl
#define no  cout<< "NO"<<endl
#define all(v) (v).begin(),(v).end()
#define s(v)   sort(v,v+n)
#define  mt mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define read(a,n) for(int i=0;i<n;i++)cin>>a[i]
#define print(a,n) for(int i=0;i<n;i++)cout<<a[i]<<" "
using namespace std;
//**********************************************DO IT NOW***************************************************************
void fastio()
{  
  #ifndef ONLINE_JUDGE
  freopen("INPUT.txt","r",stdin);
  freopen("OUTPUT.txt","w",stdout); 
  #endif
  ios_base :: sync_with_stdio(false); 
  cin.tie(NULL) ; 
  cout.tie(NULL);
}
int dp[101][1001],ans1=1e9,dp1[1000001];
int num[10];
int a[1000000];
int prime(int n)
{
 for(int i=2;i*i<=n;i++)
      {
          if(n%i==0)
          return 0;
      }
      return 1;
}
int gcd(int a, int b){ 
    if (a == 0) 
        return b;  
    return gcd(b % a, a);  
 } 
int lcm(int a, int b)  
  {  
     return (a*b)/gcd(a, b);  
  } 
signed main()
{   
    fastio();
    int t=1;
   // cin>>t;
    while(t--)
    {  
       int n;
       cin>>n;
       int a[n];
       read(a,n);
       int c=1;
       int ans=0;
       for(int i=0;i<n;i++)
       {
           if(a[i]==c)
           c++;
           else
           ans++;
       }
       if(c==1)
       cout<<"-1";
       else
       cout<<ans;
        
        
    }
    
}
// 🍪 🍪 🍪


Measured memory_bytes: 5216
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#define rep(i,n) for (int i = 0; i < n; ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
  int X;
  cin >> X;
  vector<int> A(100020);
  A[0] = 1;
  A[1] = 1;
  for (int i = 2; i <= 100010; ++i) {
    if (A[i] > 0) continue;
    else {
      for (int j = 2 * i; j <= 100010; j += i) {
        A[j] += 1;
      }
    }
  }
  for (int i = X; i <= 100010; ++i) {
    if (A[i] == 0) {
      cout << i << endl;
      return 0;
    }
  }
  return 1;
}

Measured memory_bytes: 3168
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define ff first
#define ss second
#define pii pair <int,int>
#define pll pair <ll,ll>
#define testcase() int t; cin>>t; while(t--)
#define forn(i,n) for(int i=0;i<n;i++)
#define forn1(i,n) for(int i=1;i<=n;i++)
#define vll vector <ll>
#define vi vector <int>
#define all(v) v.begin(),v.end()

ll M = 1e9 + 7;
double pi = acos(-1.0);
ll powerm(ll x,ll y){ ll res=1; while(y){ if(y&1) res=(res*x)%M; y=y>>1; x=(x*x)%M;} return res%M; }
ll power(ll x,ll y){ ll res=1; while(y){ if(y&1) res=(res*x); y=y>>1; x=(x*x);} return res; }
ll gcd(ll a,ll b){if(b>a)return gcd(b,a); if(b==0)return a; return gcd(b,a%b);}

int main() {
	
	//ifstream cin("input.txt");
	//ofstream cout("output.txt");
	ios_base::sync_with_stdio(false); 
    cin.tie(NULL); 
	
	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;
	return 0;
}


Measured memory_bytes: 3632
#include<iostream>
using namespace std;
int main()
{
  int a,b;
  cin>>a;
  cin>>b;
  if(a>b)
  {
    for(int i=0;i<a;i++)
      cout<<b;
  }
  else
  {
    for(int i=0;i<b;i++)
      cout<<a;
  }
  return 0;
}

Measured memory_bytes: 256
from statistics import mean, median,variance,stdev
import sys

x = input()
a = []
for i in range(len(x)):
    a.append(int(x[i]))
min = abs(a[0]*100+a[1]*10+a[2]-753)
for i in range(len(x)-2):
    if abs(a[i]*100+a[i+1]*10+a[i+2]-753) < min:
        min = abs(a[i]*100+a[i+1]*10+a[i+2]-753)
print(min)


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

// 型定義
typedef long long ll;
typedef pair<ll, ll> P;

// forループ
#define REP(i,n) for(ll i=0; i<(ll)(n); ++i)

// 定数宣言
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

// グラフ表現
using Graph = vector<vector<int>>;

// グラフの辺表現
using Edge = map<pair<int,int>,int>;

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

// 最大公約数
ll gcd(ll a,ll b){
   if (a%b == 0) return(b);
   else return(gcd(b, a%b));
}

// 最小公倍数
ll lcm(ll a, ll b){
    return a/gcd(a, b) * b;
}

int main()
{
    cout << fixed << setprecision(15);
    ll N, M;
    cin >> N >> M;

    if(N > (M/2)){
        cout << (M/2) << endl;
    }
    else{
        cout << N + (M-N*2)/4 << endl;
    }
    return 0;
}

Measured memory_bytes: 3636
#include <iostream>
#include <cctype>
#include <string>
#include <cassert>

using namespace std;

string S;
size_t cur;
int x;

char readchar(){
	assert(cur < S.size());
	return S[cur++];
}

char peek(){
	assert(cur < S.size());
	return S[cur];
}

int digit(){
	assert(isdigit(peek()));
	int n = readchar() - '0';
	return n;
}

int number(){
	int n = digit();
	while (cur < S.size() && isdigit(peek())){
		n = n*10 + digit();
	}
	return n;
}

int expression();
int factor(){
	if (peek() != '(') return number();
	cur += 1;
	int n = expression();
	assert(peek()==')');
	cur+=1;
	return n;
}

int term(){
	int a = factor();
	while(cur < S.size() && (peek()=='*' || peek()=='/')){
		char op = readchar();
		int b = factor();
		if (op=='*'){
			a = a*b;
		}else{
			a = a/b;
		}
	}
	return a;
}

int expression(){
	int a = term();
	while(cur < S.size() && (peek()=='+' || peek()=='-')){
		char op = readchar();
		int b = term();
		if (op == '+'){
			a = a+b;
		}else{
			a = a-b;
		}
	}
	return a;
}

int main() {
	cin >> x;
	for (int i=1; i<=x; i++){
		cin >> S;
		cur = 0;
		S.resize(S.size()-1);
		cout << expression() << endl;
	}
}

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

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

    int n,k; cin>>n>>k; vector<Int> a(n,0),b(n-k+1,0);
    for (int i = 0; i < n; i++)cin>>a[i];
    for (int i = 0; i < n-k+1; i++){
        b[i]=a[i+k-1]-a[i]+min(abs(a[i+k-1]),abs(a[i]));
    }
    cout<<*min_element(b.begin(), b.end())<<'\n';
}

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

using namespace std;
typedef unsigned long long ull;
typedef vector<ull> vec;

void Gsort(vec* a){
	sort(a->begin(), a->end(), greater<>());
}

int MaxID(ull a1, ull a2, ull a3){
	if(a1 >= a2){
		if(a1 > a3){
			return 1;
		} else {
			return 3;
		}
	} else{
		if(a2 >= a3){
			return 2;
		} else {
			return 3;
		}
	}
}

ull Pacman(ull x, ull y, vec red, vec green, vec trans){
	Gsort(&red);
	Gsort(&green);
	Gsort(&trans);

	ull r = 0, g = 0, t = 0, ret = 0, have_r = 0, have_g = 0, cur_r, cur_g, cur_t, maxid;

	for(int i = 0; i < x + y; ++i){
		cur_r = have_r < x ? red[r] : 0;
		cur_g = have_g < y ? green[g] : 0;
		cur_t = trans[t];
		maxid = MaxID(cur_r, cur_g, cur_t);
		switch (maxid){
		case 1:
			ret += cur_r;
			++have_r;
			++r;
			break;
		case 2:
			ret += cur_g;
			++have_g;
			++g;
			break;
		case 3:
			ret += cur_t;
			++t;
		}
	}

	return ret;
}

int main(void){
	ull x, y, a, b, c;
	vec p, q, r;

	cin >> x >> y >> a >> b >> c;
	for(int i = 0; i < a; ++i){
		ull a_cur;
		cin >> a_cur;
		p.push_back(a_cur);
	}
	for(int i = 0; i < b; ++i){
		ull a_cur;
		cin >> a_cur;
		q.push_back(a_cur);
	}
	for(int i = 0; i < c; ++i){
		ull a_cur;
		cin >> a_cur;
		r.push_back(a_cur);
	}
	
	cout << Pacman(x, y, p, q, r) << endl;

	return 0;
}


Measured memory_bytes: 5108
#include <iostream>
using namespace std;
int main(void){
   int N=0;
   int d[100];
   int ans=0;
   std::cin >> N;
   for(int i=0;i<N;i++){
       cin>>d[i];
   }
   
   for(int i=0;i<N-1;i++){
       for(int j=i+1;j<N;j++){
           ans = ans + d[i]*d[j];
       }
   }
   std::cout << ans << std::endl;
}


Measured memory_bytes: 256
s = gets.chomp.split("").map(&:to_i)
ans1 = [0]
ans2 = []
s.length.times do |i|
    if i % 2 == 0
        ans1 << 1
        ans2 << 1
    else
        ans1 << 0
        ans2 << 0
    end
end
asn1 = ans1.pop
sa1 = 0
sa2 = 0
s.each_with_index do |x, i|
    sa1 += (x - ans1[i]).abs
    sa2 += (x - ans2[i]).abs
end
puts [sa1, sa2].min


Measured memory_bytes: 9452
#include <iostream>

using namespace std;

int main(){
  int A;
  int B;
  cin >> A >> B;
  int out = 0;
  int mouse = 1;
  if(mouse >= B){
    cout << out << endl;
    return 0;;
  }
  for(;;){
    mouse += (A-1);
    out++;
    if(mouse >= B){
      break;
    }
  }
  cout << out << endl;
  return 0;
}

Measured memory_bytes: 256
n = int(input())
A = list(map(int, input().split()))
B = [0] + list(map(int, input().split()))
C = [0] + list(map(int, input().split()))

total = 0
pre_dish = -1
for i in range(n):
  dish = A[i]
  total += B[dish]
  if dish - pre_dish == 1:
    total += C[dish-1]
  pre_dish = dish
print(total)

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

int main() {
  string S;
  cin >> S;
  int res = 100000;
  for (int i = 0; i + 2 < S.size(); ++i) {
    int val = (S[i]-'0')*100 + (S[i+1]-'0')*10 + (S[i+2]-'0');
    res = min(res, abs(val - 753));
  }
  cout << res << endl;
}

Measured memory_bytes: 3472
use std::io::*;
use std::str::FromStr;
use std::collections::BTreeMap;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char) 
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let n: usize = read();
    let k: usize = read();
    let mut v: Vec<bool> = (0..n).map(|_| false).collect();

    for _ in 0..k {
        let d: usize = read();

        for _ in 0..d {
            let a: usize = read::<usize>() - 1;

            v[a] = true;
        }
    }

    println!("{}", (&v).into_iter().fold(0, |a, &b| if b { a } else { a + 1}));

}


Measured memory_bytes: 2124
import math
X = int(input())

# lists = []
# for i in range(2, 100001):
#     count = 0
#     for j in range(2, i+1):
#         if i % j == 0:
#             count += 1
#     if count == 1:
#         lists.append(i)
# print(lists)
#
# max_lists = []
# for i in lists:
#     if i >= X:
#         max_lists.append(i)
#
# print(max_lists)
# print(min(max_lists))


# ----エラトステネスの篩--------

def get_prime_number(number):
    prime_list = []

    search_list = list(range(2, number + 1))

    while True:
        if search_list[0] > math.sqrt(number):
            prime_list.extend(search_list)
            break

        else:
            head_num = search_list[0]
            prime_list.append(head_num)

            search_list.pop(0)
            search_list = [num for num in search_list if num % head_num != 0]

    return prime_list


lists = get_prime_number(110000)
max_list = []
for i in lists:
    if i >= X:
        max_list.append(i)

print(min(max_list))

Measured memory_bytes: 9460
//Compete against Yourself.
#include <bits/stdc++.h>
#define _ ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define int long long
#define sz(i) (int)(i.size())
#define F first
#define S second
#define L long double
#define P pair<int, int>
const int inf = 0x3f3f3f3f3f3f3f3LL;
const int mod = (int)1e9 + 7;
using namespace std;
#if LOCAL
#include "../../tr.h"
#else
#define tr(...)
#define endl '\n'
#endif
template<class T> void smin(T& a, T val) {if (a > val) a = val;}template<class T> void smax(T& a, T val) {if (a < val) a = val;}
const int N = 5*(int)1e5 + 10;

int n, a[N], m;

int32_t main(){_
   
   cin>>n>>m;

   int lcm = 1;
   for (int i = 0; i < n; ++i)
   {
      cin>>a[i];
      lcm = (a[i]/2 * lcm) / __gcd(a[i]/2, lcm);
   }

   int X = lcm;
   
   tr(lcm);
   for (int i = 0; i < n; ++i)
   {
      if(((2 * X) / a[i]) % 2 == 0){
         cout<<0;
         exit(0);
      }
   }
   
   int terms = m / lcm;
   terms = (terms + 1) / 2;
   cout<<terms;

   return 0;
}

Measured memory_bytes: 1024
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func configure(scanner *bufio.Scanner) {
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 1000005), 1000005)
}
func getNextString(scanner *bufio.Scanner) string {
	scanned := scanner.Scan()
	if !scanned {
		panic("scan failed")
	}
	return scanner.Text()
}
func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}
func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}
func getNextFloat64(scanner *bufio.Scanner) float64 {
	i, _ := strconv.ParseFloat(getNextString(scanner), 64)
	return i
}
func main() {
	fp := os.Stdin
	wfp := os.Stdout
	extra := 0
	if os.Getenv("I") == "IronMan" {
		fp, _ = os.Open(os.Getenv("END_GAME"))
		extra = 100
	}
	scanner := bufio.NewScanner(fp)
	configure(scanner)
	writer := bufio.NewWriter(wfp)
	defer func() {
		r := recover()
		if r != nil {
			fmt.Fprintln(writer, r)
		}
		writer.Flush()
	}()
	solve(scanner, writer)
	for i := 0; i < extra; i++ {
		fmt.Fprintln(writer, "-----------------------------------")
		solve(scanner, writer)
	}
}
func solve(scanner *bufio.Scanner, writer *bufio.Writer) {
	n := getNextInt(scanner)
	k := getNextInt(scanner)
	dp := makeGrid(n+5, k+5)
	dp[0][0] = 1
	for i := 0; i < n; i++ {
		for j := 0; j < k+1; j++ {
			dp[i+1][j+1].addAs(dp[i][j])
			dp[i+1][j].addAs(dp[i][j].mul(mint(j)))
		}
	}
	fmt.Fprintln(writer, dp[n][k])
}
func makeGrid(h, w int) [][]mint {
	index := make([][]mint, h, h)
	data := make([]mint, h*w, h*w)
	for i := 0; i < h; i++ {
		index[i] = data[i*w : (i+1)*w]
	}
	return index
}

type mint int64

func (mt mint) mod() mint {
	m := mint(1e9 + 7)
	mt %= m
	if mt < 0 {
		return mt + m
	}
	return mt
}
func (mt mint) inv() mint {
	return mt.pow(mint(0).sub(2))
}
func (mt mint) pow(n mint) mint {
	p := mint(1)
	for n > 0 {
		if n%2 == 1 {
			p.mulAs(mt)
		}
		mt.mulAs(mt)
		n >>= 1
	}
	return p
}
func (mt mint) add(x mint) mint {
	return (mt + x).mod()
}
func (mt mint) sub(x mint) mint {
	return (mt - x).mod()
}
func (mt mint) mul(x mint) mint {
	return (mt * x).mod()
}
func (mt mint) div(x mint) mint {
	return mt.mul(x.inv())
}
func (mt *mint) addAs(x mint) *mint {
	*mt = mt.add(x)
	return mt
}
func (mt *mint) subAs(x mint) *mint {
	*mt = mt.sub(x)
	return mt
}
func (mt *mint) mulAs(x mint) *mint {
	*mt = mt.mul(x)
	return mt
}
func (mt *mint) divAs(x mint) *mint {
	*mt = mt.div(x)
	return mt
}



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

#ifdef LOCAL
#include "../lib/dump.hpp"
#else
#define dump(...)
#define dumpv(...)
#endif

typedef long long ll;
typedef pair<int, int> P;
const int MOD = 1e9 + 7;
const int INF = 1001001001;
const ll LINF = 1001002003004005006ll;

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  // freopen("temp.1", "r", stdin);

  int N;
  cin >> N;
  map<string, int> mp;
  vector<string> w(N);
  for (int i = 0; i < N; i++) {
    cin >> w[i];
    mp[w[i]]++;
  }
  for (int i = 1; i < N; i++) {
    if (w[i - 1][w[i - 1].size() - 1] != w[i][0]) {
      cout << "No" << endl;
      return 0;
    }
  }
  for (auto& a : mp) {
    if (a.second > 1) {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
  return 0;
}

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

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

  if ((a!=b&&a==c&&b!=c)||(a!=b&&a!=c&&b==c)||(a==b&&a!=c&&b!=c)) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}


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

int main() {
  int a, b, c, d, e ,k;
  cin >> a >> b >> c >> d >> e >> k;
  
  int distance;
  bool flag = true;
  
  if (abs(e - a) > k) {
    flag = false;
    if (abs(e - b) > k) {
      flag = false;
      if (abs(e - c) > k) {
        flag = false;
        if (abs(e - d) > k) {
          flag - false;
        }
      }
    }
  }
  if (abs(d - a) > k) {
    flag = false;
    if (abs(d - b) > k) {
      flag =false;
      if (abs(d - c) > k) {
        flag = false;
      }
    }
  }
  if (c - a > k) {
    flag = false;
    if (c - b > k) {
      flag = false;
    }
  }
  if (b - a > k) {
    flag = false;
  }
  
  if (flag) {
    cout << "Yay!" << endl;
  } else {
    cout << ":(" << endl;
  }
  
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N,M;
  cin>>N>>M;
  vector<vector<int>> G(N,vector<int>());
  for(int i=0;i<M;i++){
    int a,b;
    cin>>a>>b;
    a--;
    b--;
    G.at(a).push_back(b);
    G.at(b).push_back(a);
  }
  
  queue<int> seen;
  int dist[N];
  bool judge[N];
  for(int i=0;i<N;i++){
    dist[i]=0;
    judge[i]=false;
  }
  
  judge[0]=true;
  seen.push(0);
  int ct=0;
  
  while(!(seen.empty()||ct==N)){
    int S=seen.front();
    for(int i=0;i<G.at(S).size();i++){
      int nv=G.at(S).at(i);
      if(judge[nv]){
        continue;
      }
      dist[nv]=S;
      seen.push(nv);
      judge[nv]=true;
    }
    seen.pop();
    ct++;
  }
  cout<<"Yes"<<endl;
  for(int i=1;i<N;i++){
    cout<<dist[i]+1<<endl;
  }
}


Measured memory_bytes: 10376
/* 
 * Project: AtCoder Beginners Contest 151 A - Next Alphabet
 * Author: toms74209200 <https://github.com/toms74209200>
 *
 * Created on 2020/07/11
 * Copyright (c) 2020 toms74209200
 * 
 * This software is released under the MIT License.
 * http://opensource.org/licenses/mit-license.php
 */
#include <cstdio>
using namespace std;

char c;

void solve() {

    char next = c + 1;

    printf("%c\n", next);

}

int main() {

    scanf("%c", &c);

    solve();

}

Measured memory_bytes: 3184
#include<stdio.h>
int main(void){
    int n,i,count,x;
    scanf("%d",&n);
    int a[n];
    count=0;
    for(i=1;i<=n;i++){
        x=i;
        if(i%3==0 || i%10==3 || x/10==3 || x/100==3 || x/1000==3){
            a[count]=i;
            count++;
        }
        else if(i>1000){
            while(x>1000){
                x-=1000;
            }
            if(x/100==3){
                a[count]=i;
                count++;
            }
            else{
                while(x>100){
                x-=100;
                }
                if(x/10==3){
                    a[count]=i;
                    count++;
                }
                else if(x%10==3){
                    a[count]=i;
                    count++;
                }
            }
        }
        else if(i>100){
            while(x>100){
                x-=100;
            }
            if(x/10==3){
                a[count]=i;
                count++;
            }
            else if(x%10==3){
                a[count]=i;
                count++;
            }
        }
    }
    for(int j=0;j<count;j++){
        printf(" %d",a[j]);
    }
    printf("\n");
    return 0;
}


Measured memory_bytes: 2100
n,m = map(int,input().split())
a = [int(c) for c in input().split()]
from heapq import *
from math import *
a = [-i for i in a]
heapify(a)
while m > 0:
	heappush(a,-((-heappop(a))//2))
	m -=1
print(-sum(a))


Measured memory_bytes: 14252
#include<iostream>
#include<stdio.h>
#include<string.h>
#include<queue>
using namespace std;
int main(){
char s[20];
int a;
priority_queue<int>que;
while(1){
scanf("%s\n",s);
if(strcmp(s,"end")==0){
break;
}
else if(strcmp(s,"insert")==0){
scanf("%d\n",&a);
que.push(a);
}
else{
cout << que.top() << endl;
que.pop();
}
}
return 0;
}


Measured memory_bytes: 6972
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<map>
#include<set>
#include<queue>
#include<bitset>
#include<math.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define N (1000000000+7)
#define INF (ll)1e16
typedef long long ll;


int main(void){
    int n;
    cin>>n;
    vector<int>a(n);
    for(int i=0;i<n;i++)cin>>a[i];
    int ans=0;
    int i=0;
    for(;i<n;){
        int num=0;
        int j=i;
        while(true){
            if(i==n-1){
                num=i-j;
                ans=max(ans,num);
                i++;
                break;
            }
            if(a[i]>=a[i+1])i++;
            else{
                num=i-j;
                ans=max(ans,num);
                i++;
                break;
            }
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 640
#include <stdio.h>
long long f(long long b,long long x){
	return x<b?x:f(b,x/b)+x%b;
}
long long g(){
	long long n,s,b=2,r=-1,z;
	scanf("%lld%lld",&n,&s);
	if(n<s)return -1;
	if(n==s)return n+1;
	for(;b*b<=n;b++)if(f(b,n)==s)return b;
	for(b=1;b*b<=n&&b<=s;b++){
		if((n-s)%b==0&&f(z=(n-s)/b+1,n)==s)r=z;
		if(!~r&&s==1)r=n;
	}
	return r;
}
int main(){printf("%lld\n",g());}

Measured memory_bytes: 128