akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <limits>

static const int MAX_N   = 100;
static const int MAX_INT = std::numeric_limits<int>::max();
static const int UNKNOWN = 0;
static const int IN_MST  = 1;

int M[MAX_N][MAX_N];

// 任意の頂点uを起点としてMSTを構成する頂点集合Tを定義し、
// MSTに全ての頂点が含まれるまで、Tの周囲の辺のうち重みが
// 最小の辺を都度選択してTに加えていく。
int prim(int n) {
    int *costs   = new int[n];
    int *parents = new int[n];
    int *states  = new int[n];

    // 各変数を初期化する。
    for (int i = 0; i < n; i++) {
        costs[i]   = MAX_INT;
        parents[i] = -1;
        states[i]  = UNKNOWN;
    }

    costs[0] = 0;

    while (true) {
        int mincost = MAX_INT;
        int u = -1;

        // Tの周囲の辺のうち重みが最小の辺およびそれにつながる頂点を探す。
        for (int i = 0; i < n; i++) {
            if ( states[i] != IN_MST && costs[i] < mincost ) {
                u = i;
                mincost = costs[i];
            }
        }
        if ( u == -1 ) break;

        states[u] = IN_MST;
        for (int v = 0; v < n; v++) {
            if ( states[v] != IN_MST && M[u][v] < costs[v] ) {
                costs[v]   = M[u][v];
                parents[v] = u;
            }
        }
    }

    int total_cost = 0;
    for (int i = 0; i < n; i++) {
        if (parents[i] != -1)
            total_cost += M[i][ parents[i] ];
    }
    return total_cost;
}

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

    int cost;
    for (int u = 0; u < n; u++) {
        for (int v = 0; v < n; v++) {
            scanf("%d", &cost);
            M[u][v] = 0 <= cost ? cost : MAX_INT;
        }
    }

    printf("%d\n", prim(n));

    return 0;
}

Measured memory_bytes: 1064
#include<stdio.h>
#define MAX 100005
#define NIL -1

typedef struct{int p,l,r;}Node;

Node T[MAX];
int n,D[MAX];

void print(int u){
  int i,c;
  printf("node %d: ",u);
  printf("parent = %d,",T[u].p);
  printf(" depth = %d,",D[u]);
  if(T[u].p == NIL)printf(" root, ");
  else if(T[u].l == NIL)printf(" leaf, ");
  else printf(" internal node, ");
  printf("[");
  for(i=0,c = T[u].l ; c != NIL ;i++, c = T[c].r){
    if(i)printf(", ");
    printf("%d",c);
  }
  printf("]\n");
}

int rec(int u,int p){
  D[u] = p;
  if(T[u].r != NIL)rec(T[u].r, p);
  if(T[u].l != NIL)rec(T[u].l, p + 1);
}
int main(){
  int i,j,d,v,c,l,r;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    T[i].p = T[i].l = T[i].r = NIL;
  }
  for(i=0;i<n;i++){
    scanf(" %d %d",&v,&d);
    for(j=0;j<d;j++){
      scanf("%d",&c);
      if(j == 0)T[v].l = c;
      else T[l].r = c;
      l = c;
      T[c].p = v;
    }
  }
  for(i=0;i<n;i++){
    if(T[i].p == NIL){
      r = i;
    }
  }
  rec(r,0);
  for(i=0;i<n;i++)print(i);

  return 0;
}



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

using namespace std;

#define int long long
// #define double long double
#define FOR(i, a, b) for(ll i = (a); i < (b); ++i)
#define FORR(i, a, b) for(ll i = (a); i > (b); --i)
#define REP(i, n) for(ll i = 0; i < (n); ++i)
#define REPR(i, n) for(ll i = n; i >= 0; i--)
#define FOREACH(x, a) for(auto &(x) : (a))
#define VECCIN(x)                                                              \
    for(auto &youso_ : (x)) cin >> youso_
#define bitcnt __builtin_popcount
#define SZ(x) ((ll)(x).size())
#define fi first
#define se second
#define All(a) (a).begin(), (a).end()
#define rAll(a) (a).rbegin(), (a).rend()
template <typename T = long long> inline T IN() {
    T x;
    cin >> x;
    return (x);
}
inline void CIN() {}
template <class Head, class... Tail>
inline void CIN(Head &&head, Tail &&... tail) {
    cin >> head;
    CIN(move(tail)...);
}
#define CCIN(...)                                                              \
    char __VA_ARGS__;                                                          \
    CIN(__VA_ARGS__)
#define DCIN(...)                                                              \
    double __VA_ARGS__;                                                        \
    CIN(__VA_ARGS__)
#define LCIN(...)                                                              \
    ll __VA_ARGS__;                                                            \
    CIN(__VA_ARGS__)
#define SCIN(...)                                                              \
    string __VA_ARGS__;                                                        \
    CIN(__VA_ARGS__)
#define Printv(v)                                                              \
    {                                                                          \
        REP(x, v.size()) { cout << v[x] << (x == v.size() - 1 ? "\n" : " "); } \
    }
template <typename T = string> inline void eputs(T s) {
    cout << s << "\n";
    exit(0);
}
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
    std::fill((T *)array, (T *)(array + N), val);
}
template <typename T> using PQG = priority_queue<T, vector<T>, greater<T>>;
template <typename T> using PQ = priority_queue<T>;

typedef long long ll;
typedef pair<ll, ll> PL;
typedef vector<PL> VPL;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef vector<double> VD;

const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;
const ll dx[] = {1, 0, -1, 0};
const ll dy[] = {0, 1, 0, -1};
#define PI 3.141592653589793238

ll N, A, B;
VL h;

bool check(ll k) {
    ll cnt = 0;
    REP(i, N) {
        if(h[i] > 0) {
            cnt += max(0LL, (h[i] - B * k + (A - B - 1)) / (A - B));
        }
    }
    return cnt <= k;
}

signed main() {
    cin >> N >> A >> B;
    h.resize(N);
    ll lb = 0, ub = 1LL << 32;
    REP(i, N) cin >> h[i];
    while(ub - lb > 1) {
        ll mid = (ub + lb) / 2;
        if(check(mid))
            ub = mid;
        else
            lb = mid;
    }
    cout << ub << "\n";
}


Measured memory_bytes: 1024
#pragma gcc optimize("Ofast")
#include <bits/stdc++.h>

using namespace std;
using ll = long long;

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(V) (V).begin(),(V).end()
#define SORT(V) sort(ALL(V)) //小さい方からソート
#define REV(V) reverse(ALL(V)) //リバース
#define RSORT(V) SORT(V);REV(V) //大きい方からソート
#define NPN(V) next_permutation(ALL(V)) //順列
#define pb(n) push_back(n)
#define endl '\n'
#define Endl '\n'
#define DUMP(x)  cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define yes(n) cout << ((n) ? "yes" : "no"  ) << endl
#define Yay(n) cout << ((n) ? "Yay!": ":(") << endl
#define RAPID cin.tie(0);ios::sync_with_stdio(false)
#define VSUM(V) accumulate(ALL(V), 0)
#define MID(a,b,c) (a) < (b) && (b) < (c)
#define MIDe(a,b,c) (a) <= (b) && (b) <= (c)
#define IN(n) cin >> n
#define IN2(a,b) cin >> a >> b
#define IN3(a,b,c) cin >> a >> b >> c 
#define IN4(a,b,c,d) cin >> a >> b >> c >> d
#define VIN(V) for(int i = 0; i < (V).size(); i++) {cin >> (V).at(i);}
#define OUT(n) cout << n << endl
#define VOUT(V) REP(i, (V).size()) {cout << (V)[i] << endl;}
#define VOUT2(V) REP(i, (V).size()) {cout << (V)[i] << " ";} cout<<endl;

// 型マクロ定義
#define int long long
#define P pair<ll,ll>
#define Vi vector<ll>
#define Vd vector<double>
#define Vs vector<string>
#define Vc vector<char>
#define M map<ll,ll>
#define S set<ll>
#define PQ priority_queue<ll>
#define PQG priority_queue<ll,V,greater<ll>
//

const int MOD = 1000000007;
const int INF = 1061109567;
const double EPS = 1e-10;
const double PI  = acos(-1.0);

int gcd(int a,int b){return b != 0 ? gcd(b, a % b) : a;} //最大公約数
int lcm(int a, int b){return a * b / gcd(a, b);}
string toStrUp(string str){char diff = 'A'-'a';REP(i,str.size()) str[i] += diff;return str;}
string gCh(string str, int key){return str.substr(key,1);}

signed main() {
  RAPID;
  // デフォルト変数定義
  int n=0,m=0,a=0,b=0,d=0,x=0,y=0,z=0;
  double c = 0;
  string s="",t="";
  //

  // ここから
  IN(n);
  Vs SV(n);
  Vi TV(n);
  REP(i,n){
    IN2(SV[i],TV[i]);
  }
  IN(s);
  bool test = false;
  REP(i,n){
    
    if(test) z += TV[i];
    if(s==SV[i]) test=true;
  }
  OUT(z);
}


Measured memory_bytes: 256
//$g++ main.cpp - compile
//$./a.out - run
#include <iostream>
#include <string>
using namespace std;

int main(){
    int r, c, sum_row, max = 100;
    int data[max][max];
    int sum_column[max + 1];
    for(int i = 0; i < max; i++){
        sum_column[i] = 0;
    }
    cin >> r >> c;
    for(int i = 0; i < r; i++){
        for(int j = 0; j < c; j++){
            cin >> data[i][j];
        }
    }
    for(int i = 0; i < r; i++){
        sum_row = 0;
        for(int j = 0; j < c; j++){
            cout << data[i][j] << " ";
            sum_row += data[i][j];
            sum_column[j] += data[i][j];
        }
        cout << sum_row << endl;
        sum_column[c] += sum_row;
    }
    for(int i = 0; i < c + 1; i++){
        if(i != 0) cout << " ";
        cout << sum_column[i];
    }
    cout << endl;
}

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

int main(){
    vector<int> s(13);
    vector<int> h(13);
    vector<int> c(13);
    vector<int> d(13);

    int n;
    cin >> n;

    for (int i = 0; i < n; i++){
        string k;
        int m;
        cin >> k >> m;
        if (k == "S"){
            s[m-1] = 1;
        }
        if (k == "H"){
            h[m-1] = 1;
        }
        if (k == "C"){
            c[m-1] = 1;
        }
        if (k == "D"){
            d[m-1] = 1;
        }
    }
    for (int i = 0; i < 13; i++){
        if (s[i] == 0) cout << "S" << " " << i+1 << endl;
    }
    for (int i = 0; i < 13; i++){
        if (h[i] == 0) cout << "H" << " " << i+1 << endl;
    }
    for (int i = 0; i < 13; i++){
        if (c[i] == 0) cout << "C" << " " << i+1 << endl;
    }
    for (int i = 0; i < 13; i++){
        if (d[i] == 0) cout << "D" << " " << i+1 << endl;
    }
    return 0;
}


Measured memory_bytes: 3096
#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <climits>
#include <vector>
#include <numeric>
#include <complex>
#include <map>
#include <bitset>
#include <stack>
#include <queue>
#include <set>
using namespace std;

#define __int64 long long
#define long __int64
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
const int Vec = 4;
const int Vecy[Vec] = {0,-1,0,1};
const int Vecx[Vec] = {1,0,-1,0};
const int Modd = 1000000007;

int ball[50][2];
int to[50][50][2];
map<pair<int, int>, int> freq;
int main(){
    int n;
    cin >> n;
    rep(i,n){
        cin >> ball[i][0] >> ball[i][1];
    }

    for(int fromi=0; fromi<n; fromi++){
        for(int toi=0; toi<n; toi++){
            if(fromi == toi) continue;
            int x = ball[toi][0] - ball[fromi][0];
            int y = ball[toi][1] - ball[fromi][1];
            freq[make_pair(x,y)] ++;
        }
    }

    int maxCnt = 0;
    for(auto itr=freq.begin(); itr != freq.end(); ++itr){
        maxCnt = max(maxCnt, itr->second);
    }

    cout << n - maxCnt << endl;

    return 0;


}

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

struct Pass{
    int start,fin;
};

int inf=100;

int main(){
    string str[8];
    Pass line[8];
    int h,w;
    bool aflag=true;
    cin>>h>>w;
    for(int i=0; i<h; i++){
        bool sflag=false;
        bool fflag=false;
        cin>>str[i];
        for(int j=0; j<str[i].length(); j++){
            if(str[i][j]=='#'&&!sflag&&!fflag){
                line[i].start=j;
                sflag=true;
            }
            if((str[i][j+1]=='.'&&!fflag&&sflag)||(j==w-1&&!fflag&&sflag)){
                line[i].fin=j;
                fflag=true;
            }
            else if(fflag&&str[i][j]=='#')line[i].fin=inf;
        }
    }
    for(int i=0; i<h-1; i++){
        aflag*=(line[i].fin==line[i+1].start);
    }
    if(aflag)cout<<"Possible"<<endl;
    else cout<<"Impossible"<<endl;

    return 0;
}


Measured memory_bytes: 256
/*------------------------------------
........Bismillahir Rahmanir Rahim....
..........created by Abdul Aziz.......
------------------------------------*/
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <cstring>
#include <unordered_map>
#include <queue>
#define   mod  998244353
#define   int  long long 
#define   ld   long double
#define   pb   push_back
#define   vi  vector<int> 
#define   dbg(x)  cerr << #x << " = " << x << '\n'
#define   sz(x)  (int)x.size()
#define   all(a) (a.begin(),a.end())
#define   ff   first
#define   ss   second
#define   pii  pair<int,int> 
#define   lcm(a,b) (a*b)/__gcd(a,b) 
using namespace std;

inline void solve(){
    int n,ans=0; cin>>n; 
    int t[n];
    for (int &i: t) cin>>i;
    sort(t,t+n);
    for (int i=0;i<n;i++){ 
        for (int j=i+1;j<n;j++){ 
            for (int k=j+1;k<n;k++){
                if (t[k]>=t[i]+t[j]) break;
                ans++;
            }
        }
    } 
    cout << ans << endl;
}

signed main()
{
    int n=1; // cin>>n;
    while (n--) solve();
    return 0;
}


Measured memory_bytes: 3668
#include <cstdio>
#include <algorithm>
#define repi(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)
#define all(a) (a).begin(), (a).end()

int A, B, C, K;

int main()
{
  scanf( "%d%d%d%d", &A, &B, &C, &K );

  int arr[3] = { A, B, C };

  int p = std::max_element( arr, arr+3 )-arr;

  rep( i, K )
    arr[p] <<= 1;

  printf( "%d\n", arr[0]+arr[1]+arr[2] );
  
  return 0;
}

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

int main()
{
  long long int r, d, x;
  cin >> r >> d >> x;

  long long int dummy = x;
  for(int i = 0; i < 10; i++){
    dummy = r * dummy - d;
    cout << dummy << endl;
  }

  return 0;

}


Measured memory_bytes: 256
fun main(args: Array<String>) {
    val (N, H) = readLine()!!.split(" ").map { it.toInt() }
    val ab = mutableListOf<Pair<Int, Int>>()
    (1..N).forEach {
        val (a, b) = readLine()!!.split(" ").map { it.toInt() }
        ab.add(Pair(a, b))
    }

    // 後ろから考えるのはありやな
    // Basically, we should use the best brade.
    // O(N)
    val maxA = ab.maxBy { it.first }!!.first
    // If there is a goog brade which can hit damage bigger than maxA by throging, we should also use it
    // O(N)
    val bradesShouldBeThrown = ab.map { it.second }.filter { it > maxA }.sortedDescending()
    // We can consider throwing first actually even if one of them is same as maxA, because the order can be changed later.
    // O(N)
    var totalDamege = 0L
    var attackCount = 0
    bradesShouldBeThrown.forEach {
        totalDamege += it
        attackCount++
        if (totalDamege >= H) {
            println(attackCount)
            return
        }
    }

    val remainders = H - totalDamege
    attackCount += Math.ceil(remainders.toDouble() / maxA.toDouble()).toInt()

    println(attackCount)
}


Measured memory_bytes: 66640
/**
 *    Coded by : lucky_21
 *               --------Lokesh Singh
**/

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

#include<ext/pb_ds/tree_policy.hpp>
#include<ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
template<class T> using oset=tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;

#define     F           first
#define     S           second
#define     pb          push_back
#define     lb          lower_bound
#define     ub          upper_bound
#define     pii         pair<int,int>
#define     all(x)      x.begin(),x.end()
#define     fix         fixed<<setprecision(10)
#define     rep(i,a,b)  for(int i=int(a);i<=int(b);i++)
#define     repb(i,b,a) for(int i=int(b);i>=int(a);i--)
#define     FastIO      ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)

typedef double db;
typedef long long ll;

const int N=5e5+5;
const int mod=1e9+7;

int ans[N];
vector<vector<int>>v;
int n,q,sz,a[N],f[N],m[N];
bool comp(vector<int>a,vector<int>b){
    if(a[0]/sz!=b[0]/sz) return a[0]<b[0];
    return (a[0]/sz%2?a[1]>b[1]:a[1]<b[1]);
}
signed main(){
    FastIO;
    cin>>n>>q;
    sz=sqrt(n);
    rep(i,1,n) cin>>a[i];
    rep(i,1,q){
        int l,r;
        cin>>l>>r;
        v.pb({l,r,i});
    }
    sort(all(v),comp);
    int l=v[0][0],r=l-1,tans=0;
    rep(i,0,q-1){
        while(l<v[i][0]){
            if(m[a[l]]==1) tans--;
            m[a[l]]--;
            l++;
        }
        while(l>v[i][0]){
            l--;
            if(m[a[l]]==0) tans++;
            m[a[l]]++;
        }
        while(r<v[i][1]){
            r++;
            if(m[a[r]]==0) tans++;
            m[a[r]]++;
        }
        while(r>v[i][1]){
            if(m[a[r]]==1) tans--;
            m[a[r]]--;
            r--;
        }
        ans[v[i][2]]=tans;
    }
    rep(i,1,q) cout<<ans[i]<<'\n';
    return 0;
}


Measured memory_bytes: 37056
#include <stdio.h>
 
int main(void){
    int N,count=0,p[55];
    scanf("%d",&N);
    for(int i=1;i<=50;i++){
        scanf("%d",&p[i]);
    }
    for(int i=1;i<=N;i++){
        if(p[i]==i){
            count++;
        }
    }
    if(count == N-2 || count == N ){
        printf("YES");
    }else{
        printf("NO");
    }
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n; i++)
#define PI 3.14159265359
#define INF 1000100100
#define all(x) (x).begin(),(x).end()
#define P pair<int,int>
typedef long long ll;
using namespace std;

int main(){
    string s; cin >> s;
    bool a,b; a=b=false;
    if(s[0]=='0' && s[1]!='0') a=true;
    else if(s[0]=='1' && (s[1]=='0' || s[1]=='1' || s[1]=='2')) a=true;
    if(s[2]=='0' && s[3]!='0') b=true;
    else if(s[2]=='1' && (s[3]=='0' || s[3]=='1' || s[3]=='2')) b=true;
    if(a==true && b==true) cout << "AMBIGUOUS" << endl;
    else if(a==true) cout << "MMYY" << endl;
    else if(b==true) cout << "YYMM" << endl;
    else cout << "NA" << endl;

return 0;
}


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

int main() {
  int n,r;
  cin >> n >> r;
  if(n>=10)cout<<r<<endl;
  else cout<<r+100*(10-n)<<endl;
}


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

int main (void){
    double r;
    cin >> r;

    double pi = acos(-1);
    cout << fixed << setprecision(6);
    double area = r * r * pi;
    double cir = (r+r) * pi;
    cout << area << ' ' << cir << endl;
}
//ITP_5_B*


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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair < int, int > pii;

const int N = int(2e5) + 5;
const int inf = (int)1e9 + 7;

int n;
int a[N];
int cnt[N];

int main(){
  scanf("%d", &n);
  for(int i = 1; i <= n; ++i){
    scanf("%d", a + i);
  }
  for(int i = 1; i <= n; ++i){
    cnt[a[i]]++;
    cnt[a[i] - 1]++;
    cnt[a[i] + 1]++;
  }
  int ans = 0;
  for(int i = 1; i <= (int)1e5 + 5; ++i){
    ans = max(ans, cnt[i]);
  }
  printf("%d", ans);
  return 0;
}


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

int main(){
  string S;
  cin>>S;
  int memo[26]={};
  string AL="abcdefghijklmnopqrstuvwxyz";
  for(int i=0;i<26;i++){
    for(int j=0;j<S.size();j++){
      if(AL[i]==S[j]){
        memo[i]=1;
      }
    }
    if(memo[i] ==0){
      cout<<AL[i]<<endl;
      return 0;
    }
  }
  cout<<"None"<<endl;
  return 0;
}


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

int V[51];
int C[51];
int A[51];

int main() {
	int N;
  	cin >> N;
	for ( int i = 0; i < N; i++ ) cin >> V[i];
    for ( int i = 0; i < N; i++ ) cin >> C[i];
  	
  	int ans = 0;
  	for ( int i = 0; i < N; i++ )
    {
      A[i] = V[i] - C[i];
      if ( A[i] > 0 ) ans += A[i];
    }
  	cout << ans;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <math.h>
#include <deque>
using ll = long long;
using namespace std;


int main(){
    ll n, ans = 1;
    cin >> n;
    for (ll i = 1; i <= n; i++) {
        ans = ans * i % 1000000007;
    }
    cout << ans << endl;
    return 0;
}


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

using namespace std;

typedef long long int lli;

const int N = 100000;

lli n, x, d = 0;
vector<lli> b(N), l(N), u(N), full(N), fullsum(N+1, 0);
vector<int> ord(N, 0), nrank(N, 0);

bool isWon(lli k) {
    lli q = k/x, r = k - q*x;

    for (int i=0; i<n; i++) {
        lli d_ = d;

        d_ += min(b[i], r)*l[i] + max(0LL, r-b[i])*u[i];
        d_ += fullsum[q];
        if (q < n && nrank[i] < q) {
            d_ += -full[i] + full[ord[q]];
        }

        if (d_ >= 0) return true;
    }

    return false;
}

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

    cin >> n >> x;

    for (int i=0; i<n; i++) {
        cin >> b[i] >> l[i] >> u[i];
        full[i] = b[i]*l[i] + (x-b[i])*u[i];
        d += -l[i]*b[i];
    }

    iota(ord.begin(), ord.end(), 0);
    sort(ord.begin(), ord.begin()+n, [&](int x, int y) {
        return full[x] > full[y];
    });

    for (int i=0; i<n; i++) {
        nrank[ord[i]] = i;
        fullsum[i+1] = fullsum[i] + full[ord[i]];
    }

    // binary search
    lli ng = -1, ok = n * x;
    while (abs(ok-ng) > 1) {
        lli mid = (ok+ng)/2;

        // cout << mid << " " << ok << " " << ng << endl;

        if (isWon(mid)) ok = mid;
        else ng = mid;
    }

    cout << ok << endl;

    return 0;
}


Measured memory_bytes: 4992
#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// #include <ext/pb_ds/detail/standard_policies.hpp>
// using namespace __gnu_pbds;
using namespace std;
// template <typename T>
// using ordered_set = tree<T, null_type, less<T>, rb_tree_tag,
//     tree_order_statistics_node_update>;
 
// #pragma GCC optimize("Ofast")
// #pragma GCC target("avx,avx2,fma")
// #pragma GCC optimization ("unroll-loops")
typedef long long int ll;
const ll N = 1e6;
// const ll m = 1e9 + 7;
// const ll inf= 1e14;
const ll mod =998244353;
const ll INF = 1e14;
#define x first
#define y second
#define pb push_back
#define mp make_pair
#define pld pair<ld,ld>
#define pii pair<ll, ll>
#define ld long double
ll powm(ll a, ll b) { a = a%mod;ll res = 1; while (b) { if (b & 1) res = (res * a) % mod; a = (a * a) % mod; b >>= 1; } return res; }



int main() {   
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    freopen("error.txt","w",stderr);
    #endif
    ll t = 1;
    // cin>>t; 
    while(t--){
        ll a,b,h,m;cin>>a>>b>>h>>m;
        ld H = h + (ld)m/60;
        ld theta = ((ld)H/12*360) - ((ld)m/60*360);

        // cout<<theta<<'\n';
        ld pi = acos(-1); 
        ld ans= (ld)a*a + (ld)b*b - 2*a*b*cos(theta/180*pi);
        ans=sqrt(ans);
        cout<<fixed<<setprecision(10)<<ans<<'\n';
    }
}              

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

int main()
{
    int n;
    int count = 0;
    std::vector<int> p;
    std::cin>>n;
    p.resize(n);
    for(int i=0;i<n;i++)std::cin>>p[i];

    //昇順になっていない部分を検出
    for(int i=1;i<=n-1;i++){
        if(p[i-1]!=i)count++;
    }
    std::cout<<(count<=2?"YES":"NO")<<std::endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <list>
#include <vector>
#include <complex>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <bitset>
#include <ctime>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cassert>
#include <cstddef>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <sstream>
#include <fstream>

using namespace std;
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define FOR(i, a, b) for (int (i) = (a); (i) < (b); (i)++)
#define RREP(i, a) for(int (i) = (a) - 1; (i) >= 0; (i)--)
#define FORR(i, a, b) for(int (i) = (a) - 1; (i) >= (b); (i)--)
#define DEBUG(C) cerr << #C << " = " << C << endl;
using LL = long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<LL>;
using VVL = vector<VL>;
using VD = vector<double>;
using VVD = vector<VD>;
using PII = pair<int, int>;
using PDD = pair<double, double>;
using PLL = pair<LL, LL>;
using VPII = vector<PII>;
template<typename T> using VT = vector<T>;
#define ALL(a) begin((a)), end((a))
#define RALL(a) rbegin((a)), rend((a))
#define SORT(a) sort(ALL((a)))
#define RSORT(a) sort(RALL((a)))
#define REVERSE(a) reverse(ALL((a)))
#define MP make_pair
#define FORE(a, b) for (auto &&a : (b))
#define FIND(s, e) ((s).find(e) != (s).end())
#define EB emplace_back
template<typename T> inline bool chmax(T &a, T b){if (a < b){a = b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if (a > b){a = b;return true;}return false;}

const int INF = 1e9;
const int MOD = INF + 7;
const LL LLINF = 1e18;

int main(void) {
    LL n, m;
    cin >> n >> m;
    cout << (1900 * m + (n - m) * 100) * (int)pow(2, m) << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	int max;
	int min;
	int i,n = 0;
	long long int sum = 0;
	int A[10000];
	scanf("%d",&n);
	for(i=0;i<n;i++) scanf("%d",&A[i]);
	max = A[0];
	min = A[0];
	for(i=0;i<n;i++){
		if(A[i]>max) max=A[i];
		if(A[i]<min) min=A[i];
		sum = sum + A[i];
		}		
	printf("%d %d %lld\n",min,max,sum);

	return 0;
}


Measured memory_bytes: 2144
/* ex7_3
   moka223711 */

#include <stdio.h>
#include <stdlib.h>

int main(void){
    // row_black, col_black は黒('#')が少なくとも1マス入っている行や列を保存しておくための配列
    int row, col, i, j, *row_black, *col_black;
    char **ptr; // 入力の行列を読み込むための文字型の二次元配列
    scanf("%d %d", &row, &col);
    
    if((ptr = (char**)calloc(row, sizeof(char*))) == NULL) // 文字型の二次元配列の動的確保
        exit(1);
    for(i = 0; i < row; i++)
        if((ptr[i] = (char*)calloc(col, sizeof(char))) == NULL)
            exit(1);
    if((row_black = (int*)calloc(row, sizeof(int))) == NULL) // 整数型の配列の動的確保
        exit(1);
    if((col_black = (int*)calloc(col, sizeof(int))) == NULL) // 整数型の配列の動的確保
        exit(1);
    
    // 二次元配列ptr[][]で入力を受け取り、黒('#')があった行と列をrow_blackとcol_blackに保存する。
    for(i = 0; i < row; i++){
        for(j = 0; j < col; j++){
            scanf(" %c", &ptr[i][j]);
            if(ptr[i][j] == '#'){
                // callocによってrow_blackとcol_blackは0で初期化されている。
                row_black[i] = 1; // 黒のある行を1に変える
                col_black[j] = 1; // 黒のある列を1に変える
            }
        }
    }
    
    // row_blackとcol_blackがともに1の行と列のptr[][]要素を出力していく。
    for(i = 0; i < row; i++){
        if(row_black[i] == 1){
            for(j = 0; j < col; j++){
                if(col_black[j] == 1){
                    putchar(ptr[i][j]);
                }
            }
            putchar('\n'); // 1行出力したら改行を出力する。
        }
    }
    
    // 使い終わった配列を解放する。
    free(row_black);
    free(col_black);
    for(i = 0; i < row; i++)
        free(ptr[i]);
    free(ptr);
    return 0;
}

Measured memory_bytes: 1676
n = int(input())
#n, k = map(int,input().split())
#plst = [int(i) for i in input().split()]
lst = [int(input()) for _ in range(n)]

def a(p, q):
    if p % q == 0:
        return q
    else:
        return a(q, p % q)

f = lst[0]
for i in range(1, n):
    f = f * (lst[i] // a(f, lst[i]))

print(f)

Measured memory_bytes: 2940
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>

int main() {
    using namespace std;
    char a[300000],b[300000];
    long long s=0,o;
    cin>>a>>b;
    o=strlen(a);
    for (long long i = 0; i < o ; ++i) {
        if (a[i]!=b[i])
            s++;
    }
    cout<<s;

    return 0;
}

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


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#define lli long long int
#define uli unsigned long long int
#define inf 999999999999999999
#define rep(i,n,m) for(lli i=(lli)(n);i<(lli)(m);++i)
#define reep(i,n,m) for(int i=(int)(n);i<=(int)(m);++i)
#define per(i,m,n) for(lli i=(int)(m)-1;i>=(int)(n);--i)
#define st(n) sort(n.begin(), n.end())
#define rev(n) reverse(n.begin(),n.end())
#define ou(S) cout << S << endl
using namespace std;
int main(){
  int k;
  cin>>k;
  if(k%2==1){
    ou((k/2)*(k/2+1));
  }
  else ou(pow(k/2,2));
}

Measured memory_bytes: 256
#include <cstdio>
typedef long long ll;
int main() {
  ll n, ans = 0LL, t = 10;
  scanf("%lld", &n);
  if (n % 2) {
    printf("0\n");
  } else {
    while (n >= t) {
      ans += n / t;
      t *= 5;
    }
    printf("%lld\n", ans);
  }
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main(){
	ll n,k,m;
	cin>>n>>m>>k;
	ll a[n],b[m];
	for(int i=0;i<n;i++)cin>>a[i];
	for(int i=0;i<m;i++)cin>>b[i];
	for(int i=1;i<n;i++)a[i]+=a[i-1];
	for(int i=1;i<m;i++)b[i]+=b[i-1];
	ll ans=0;
	auto l=lower_bound(a,a+n,k);
	ans=max(ans,(a[l-a]==k)?((ll)(l-a)+1):(ll)(l-a));
	for(int i=0;i<m;i++){
		ll z=k-b[i];
		if(z>=0){
			auto u=lower_bound(a,a+n,z);
			ans=max(ans,((a[u-a]==z)?((ll)(u-a)+1):(ll)(u-a))+i+1);
		}
	}
	cout<<ans<<endl;
}


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

int main() {
  string s,t;
  cin>>s>>t;
  vector<char> vs(s.size()),vt(t.size());
  for(int i=0;i<s.size();i++)vs.at(i)=s.at(i);
  for(int i=0;i<t.size();i++)vt.at(i)=t.at(i);
  
  sort(vs.begin(),vs.end());
  
  sort(vt.begin(),vt.end());
  reverse(vt.begin(),vt.end());
  
  if(vs>=vt)cout<<"No"<<endl;
  else cout<<"Yes"<<endl;
}

Measured memory_bytes: 3648
o = list(input())
e = list(input())

oe = list()

while len(o) > 0 or len(e) > 0:
    if len(o) > len(e):
        oe.append(o.pop())
    else:
        oe.append(e.pop())

oe.reverse()
print(''.join(oe))

Measured memory_bytes: 3060
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<string>
using namespace std;

typedef long long ll;
const int INF = 1e+9;

int main() {
	ll l, r, ans = INF;
	cin >> l >> r;
	if (r - l >= 2019) ans = 0;
	else {
		for (ll i = l; i < r; ++i) {
			for (ll j = 1; i + j <= r; ++j) {
				ans = min(ans, (i % 2019) * ((i + j) % 2019) % 2019);
			}
		}
	}
		cout << ans << endl;
	return 0;
}

Measured memory_bytes: 384
def main():
    from itertools import accumulate

    MOD = 10 ** 9 + 7
    n = int(input())
    *x, = map(int, input().split())
    y = [b - a for b, a in zip(x[1:], x)]

    csum_invs = [0] + list(accumulate([pow(i, MOD - 2, MOD) for i in range(1, n + 1)]))
    # csum_invs = [0]
    # t = 0
    # for i in range(1, n + 1):
    #     t += pow(i, MOD - 2, MOD)
    #     t %= MOD
    #     csum_invs.append(t)

    fact = [0]
    t = 1
    for i in range(1, n + 1):
        t *= i
        t %= MOD
        fact.append(t)

    ret = 0
    for j, y_ in enumerate(y, 1):
        ret = (ret + csum_invs[j] * y_) % MOD
    print((ret * fact[n - 1]) % MOD)


if __name__ == '__main__':
    main()


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

namespace Atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = ReadLineIntSpilit();
            var a = "";
            var b = "";

            for (int i = 0; i < n[1]; i++) a += n[0];
            for (int i = 0; i < n[0]; i++) b += n[1];

            if(n[0] == n[1]) {
                Console.WriteLine(a);
                return;
            }

            Console.WriteLine((n[0] < n[1]) ? a : b);
            ReadLine();
        }

        //メモ

        //降順
        //var sort = array.OrderBy(x => -x).ToArray();

        //最大公約数
        static int gcd(int a, int b)
        {
            if (a > b) {
                return gcd(b, a);
            }

            while (b != 0) {
                var remainder = a % b;
                a = b;
                b = remainder;
            }

            return a;
        }

        //最小公倍数
        static int lcm(int a, int b) => a * b / gcd(a, b);

        /// <summary>
        /// コンビネーション
        /// </summary>
        static int nCm(int n, int m)
        {
            if (m == 0) return 1;
            if (n == 0) return 0;
            return n * nCm(n - 1, m - 1) / m;
        }

        public static string ReadLine() => Console.ReadLine();
        public static int ReadLineInt() => int.Parse(Console.ReadLine());
        public static long ReadLineLongInt() => long.Parse(Console.ReadLine());
        public static string[] ReadLineStringSplit(char a = ' ') => ReadLine().Split(a).ToArray();
        public static int[] ReadLineIntSpilit(char a = ' ') => ReadLine().Split(a).Select(x => int.Parse(x)).ToArray();
        public static long[] ReadLineLongSpilit(char a = ' ') => ReadLine().Split(a).Select(x => long.Parse(x)).ToArray();
        static string[] GetAplhaLowerArray() => new string[] { "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z" };
        static string[] GetAplhaUpperArray() => new string[] { "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z" };
    }
}


Measured memory_bytes: 13268
#include<bits/stdc++.h>
using namespace std;
 
#define rep(i, a, n) for(int i=a; i<n; i++)
#define ll long long
#define all(x) begin(x), end(x)
#define toInt(x) (x - '0')
#define pll pair<ll, ll>
#define MAXN 200 + 5
const long long INF = 1LL << 60;
const int inf = 1 << 30;

void printVec(std::vector<int> &vec) {
  std::cout << "";
  for (auto it = vec.begin(); it != vec.end(); ++it) {
    std::cout << *it << " ";
  }
  std::cout << std::endl;
}
 
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; }

long long  mod = 1e9 + 7;

int main(){
  ll x, y, a, b, c;
  cin >> x >> y >> a >> b >> c;
  vector<ll> p(a), q(b), r(c);
  vector<ll> pr;
  rep(i, 0, a){
    cin >> p[i];
  }
  sort(all(p), greater<ll>());
  rep(i, 0, b){
    cin >> q[i];
  }
  sort(all(q), greater<ll>());
  rep(i, 0, c){
    cin >> r[i];
    pr.push_back(r[i]);
  }
  rep(i, 0, x){
    pr.push_back(p[i]);
  }
  rep(i, 0, y){
    pr.push_back(q[i]);
  }
  sort(all(pr), greater<ll>());
  ll ans = 0;
  rep(i, 0, x + y){
    ans += pr[i];
  }
  cout << ans << endl;
}
     


Measured memory_bytes: 7792
#include <iostream>

int main(){
   int X, Y;
   std::cin >> X >> Y;

   if(Y%2==1) std::cout << "No" << std::endl;
   else{
      int b = Y/2 - X;
      if(b<0 || b>X) std::cout << "No" << std::endl;
      else std::cout << "Yes" << std::endl;
   }
   return 0;
}


Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define mp make_pair
#define pb push_back
#define F first
#define S second
#define mod 1000000007
#define dbg(n) cout<<#n<<' '<<n<<endl;
#define dbg_v(v) cout<<#v<<":";for(int i=0;i<(int)v.size();i++) cout<<" "<<v[i]; cout<<endl;
int power(ll x,ll y){ll res = 1;while(y>0){if(y&1)res = (res*x)%mod;y=y>>1;x=(x*x)%mod;}return res;}
int main(){ 
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int l,r,d;
	cin>>l>>r>>d;
	int ct=0;
	for(int i=l;i<=r;i++)
		if(i%d==0)ct++;
	cout<<ct<<endl;
}



Measured memory_bytes: 3564
#include<iostream>
#include<iomanip>
#include<vector>
typedef unsigned long long ull;
typedef signed long long sll;
using namespace std;

#define INF 0x7FFFFFFFFFFFFFFF
#define BIG_PRIME 1000000007

int main()
{
  ull i,j,N,K;
  cin >> N >> K;
  vector<int> a(N);
  for(i=0;i<N;++i)
  {
    cin >> a[i];
  }
  vector<int> dp(K+1,0);

  for(i=1;i<=K;++i)
  {
    for(j=0;j<N;++j)
    {
      if(i<a[j])break;
      if(dp[i-a[j]]==0)
      {
        dp[i]=1;
        break;
      }
    }
  }
  if(dp[K])
  {
    cout << "First";
  }
  else
  {
    cout << "Second";
  }
  return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
typedef long long ll;
typedef pair<ll, ll> P;
int main()
{
    ll n;
    ll k;
    cin >> n >> k;
    vector<ll> a(n), b(n), c(n);
    vector<P> ans(n);
    rep(i, n)
    {
        c[i] = 2 * n + k + i;
        a[i] = k + i;
        b[i] = n + k + i;
    }
    reverse(b.begin(), b.end());
    int mx = n/2;
    for(int i = 0;i<mx-i && mx-i<n;i++){
        swap(a[i],a[mx-i]);
    }
    for(int i = 0;mx+1+i<n-1-i;i++){
        swap(a[i+mx+1],a[n-1-i]);
    }
    rep(i,n){
        ans[i] = P(a[i]+b[i],a[i]);
    }
    sort(ans.begin(), ans.end());
    if (2 * k > n + 1)
    {
        cout << "-1" << endl;
        return 0;
    }
    rep(i, n)
    {
        cout << ans[i].second << ' ' << ans[i].first - ans[i].second << ' ' << c[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 6144
#include<iostream>
#include<algorithm>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
using namespace std;

int main(){
	int n,m,c;
	cin>>n>>m>>c;
	int l[c];
	rep(i,c)cin>>l[i];
	long long sum=0;
	pair<int,int> ball[n];
	rep(i,n)cin>>ball[i].second>>ball[i].first;
	sort(ball,ball+n);
	int cnt = 0;
	for(int i=n-1;i>=0;i--){
		if(l[ball[i].second-1]>0){
			sum+=ball[i].first;
			l[ball[i].second-1]--;
			cnt++;
		}
		if(cnt == m) break;
	}
	cout<<sum<<endl;
	return 0;
}


Measured memory_bytes: 4200
#include<stdio.h>
#define min(a, b) ((a) > (b) ? (b) : (a))
#define ll long long

int d, g, arr[99]={}, flg[99]={}, c[11], p[11], ans = 1001001001; 

void nya(int n){
    if(n == d){
        int sum = 0, score = 0;
        for(int i=0; i<d; i++){
            if((arr[i]+1)*100*p[arr[i]] <= g - score){
                score += (arr[i]+1)*100*p[arr[i]] + c[arr[i]];
                sum += p[arr[i]];
            }else {
                int tmp = (g-score + (arr[i]+1)*100 - 1) / ((arr[i]+1)*100);
                sum += tmp;
                score += tmp * (arr[i]+1) * 100;
            }
            if(score >= g){
                ans = min(ans, sum);
                break;
            }
        }
        return;
    }
    for(int i=0; i<d; i++){
        if(!flg[i]){
            flg[i] = 1;
            arr[n] = i;
            nya(n + 1);
            flg[i] = 0;
        }
    }
    return;
}

int main(){
    scanf("%d%d", &d, &g);
    for(int i=0; i<d; i++){
        scanf("%d%d", &p[i], &c[i]);
    }
    nya(0);
    printf("%d\n", ans);
    return 0;
}

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

int main()
{
  int N, X;
  cin >> N >> X;
  int D = 0;
  int count = 1;

  for(int i = 0; i < N; i++) {
    int L;
    cin >> L;
    if(D + L <= X) {
      D += L;
      count++;
    } else 
      break;
  }
  cout << count << endl;
  return 0; 
}

Measured memory_bytes: 256
import sys
input=sys.stdin.readline
N = int(input())
a = list(map(int,input().split()))
c = 1
n = 0
for i in range(N):
    if a[i] == c:
        c += 1
    else:
        n += 1
if c == 1:
    print(-1)
else:
    print(n)

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

int main() {
  int a, b, c, d;
  scanf("%d %d %d %d", &a, &b, &c, &d);
  int n1= c/b + 1;
  if(c%b==0) n1--;
  int n2= a/d + 1;
  if(a%d==0) n2--;
  
  if(n2>=n1) printf("Yes");
  else printf("No");
  return 0;

}


Measured memory_bytes: 1736
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define lvector vector<ll>
#define cvector vector<char>
#define svector vector<string>
#define lque queue<ll>
#define lpque priority_queue<ll>
#define dlpque priority_queue<ll,lvector,greater<ll>>
#define P pair<ll,ll>
#define ALL(a) a.begin(),a.end()
#define RALL(a) a.rbegin(),a.rend()
#define rep(i,n) for(ll i=0; i<n; ++i)
#define print(a) cout << (a) << endl

class UnionFind
{
public:
    ll n;
    lvector uf;
    UnionFind(ll N);
    //~UnionFind();
    ll find(ll x);
    ll size(ll x) {return -(*this).uf[(*this).find(x)];}
    void unite(ll x, ll y);
};

UnionFind::UnionFind(ll N)
{
  (*this).n=N;
  rep(i,n) (*this).uf.emplace_back(-1);
}

ll UnionFind::find(ll x)
{
  if((*this).uf[x]<0) return x;
  (*this).uf[x]=(*this).find((*this).uf[x]);
  return (*this).uf[x];
}

void UnionFind::unite(ll x, ll y)
{
  x=(*this).find(x);
  y=(*this).find(y);
  if(x==y) return;
  if((*this).size(x)>(*this).size(y)) swap(x,y);
  (*this).uf[y]+=(*this).uf[x];
  (*this).uf[x]=y;
  (*this).n-=1;
  return;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n,m,a,b;cin>>n>>m;
  UnionFind un(n);
  rep(i,m) {
    cin>>a>>b;a--,b--;
    un.unite(a,b);
  }
  ll msize=0;
  rep(i,n) {
    ll tmp=un.size(i);
    msize=max(tmp,msize);
  }
  print(msize);
  return 0;
}

Measured memory_bytes: 5328
package main
 
import (
  "fmt"
  "math")
func main(){
var a,b,c,d int
  fmt.Scanf("%d %d %d %d",&a,&b,&c,&d)
  
  if math.Abs(float64(b-a))<=float64(d) && math.Abs(float64(c-b))<=float64(d) {
  fmt.Println("Yes")
  } else if math.Abs(float64(c-a))<=float64(d){
    fmt.Println("Yes")
  } else {
    fmt.Println("No")
  }
                }

Measured memory_bytes: 512
#include <iostream>
#include <cmath>
#include <cstdio>
#include <cassert>
#define REP(i,s,n) for(int i=s;i<n;++i)
#define rep(i,n) REP(i,0,n)
using namespace std;
double ans,ko,hen,san,theta;
int n,k;
int main() {
  cin >> n >> k;
  ko = M_PI/(double)n - sin(2*M_PI/(double)n)/2;
  hen = sqrt(2-2*cos(2*M_PI/(double)n));
  theta = M_PI*((double)n-2)*((double)k-1)/((double)n)/((double)n-2);
  san = hen/2*tan(theta)*hen/2;
  ans = M_PI - ko*n - san*n;
  //cout << ko << ',' << hen << ',' << theta << ',' << san;                                                                                                                        
  //cout << ans << endl;                                                                                                                                                           
  printf("%.9f\n",ans);
  return 0;
}

Measured memory_bytes: 1232
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define pb push_back
#define f(i,x,n) for(int i=x;i<n;i++)
#define all(c) c.begin(),c.end()
#define int ll
using ll = long long;
using pii = pair<int,int>;
const int MOD = 1e9+7, N = 1e5 + 10; 

int32_t main(){
   ios::sync_with_stdio(false);
   cin.tie(NULL);
   int n,m;
   cin >> n >> m;
   cout << n*(n-1)/2+m*(m-1)/2 << '\n';
   return 0;
} 

Measured memory_bytes: 256
import std.stdio, std.string, std.conv;
import std.range, std.algorithm, std.array, std.typecons, std.container;
import std.math, std.numeric, core.bitop;

enum inf3 = 1_001_001_001;
enum inf6 = 1_001_001_001_001_001_001L;
enum mod = 1_000_000_007L;




void main() {
    int a, b, c;
    scan(a, b, c);
    int ans = max(0, c - (a - b));
    writeln(ans);
}


















int[][] readGraph(int n, int m, bool isUndirected = true, bool is1indexed = true) {
    auto adj = new int[][](n, 0);

    foreach (i; 0 .. m) {
        int u, v;
        scan(u, v);
        if (is1indexed) {
            u--, v--;
        }
        adj[u] ~= v;
        if (isUndirected) {
            adj[v] ~= u;
        }
    }

    return adj;
}

alias Edge = Tuple!(int, "to", int, "cost");

Edge[][] readWeightedGraph(int n, int m, bool isUndirected = true, bool is1indexed = true) {
    auto adj = new Edge[][](n, 0);

    foreach (i; 0 .. m) {
        int u, v, c;
        scan(u, v, c);
        if (is1indexed) {
            u--, v--;
        }
        adj[u] ~= Edge(v, c);
        if (isUndirected) {
            adj[v] ~= Edge(u, c);
        }
    }

    return adj;
}

void yes(bool b) {
    writeln(b ? "Yes" : "No");
}

void YES(bool b) {
    writeln(b ? "YES" : "NO");
}

T[] readArr(T)() {
    return readln.split.to!(T[]);
}

T[] readArrByLines(T)(int n) {
    return iota(n).map!(i => readln.chomp.to!T).array;
}

void scan(T...)(ref T args) {
    import std.stdio : readln;
    import std.algorithm : splitter;
    import std.conv : to;
    import std.range.primitives;

    auto line = readln().splitter();
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}

void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}

bool chmin(T, U...)(ref T x, U args) {
    bool isChanged;

    foreach (arg; args) {
        if (x > arg) {
            x = arg;
            isChanged = true;
        }
    }

    return isChanged;
}

bool chmax(T, U...)(ref T x, U args) {
    bool isChanged;

    foreach (arg; args) {
        if (x < arg) {
            x = arg;
            isChanged = true;
        }
    }

    return isChanged;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <map>
#include <vector>
#include <deque>
#include <list>
#include <stack>
#include <queue>
#include <algorithm>
#include <iostream>
#include <iterator>
#include <memory>

using namespace std;

#if 1
#define PRINT(x) { cout << #x << ": " << (x) << endl; }
#define PRINT_CONTAINER(x)  { cout << #x << ": ";                       \
        for (size_t ix = 0; ix < (x).size(); ++ix) cout << (x)[ix] << ", "; \
        cout << endl; }
#else
#define PRINT(x)
#define PRINT_CONTAINER(x)
#endif

static const int N_MAX = 100000;
int n;
int m;
vector<pair<int, int>> graph[N_MAX];
int x[N_MAX];
int visited[N_MAX];

bool traverse(int i)
{
    if (visited[i]) return true;
    queue<int> q;
    visited[i] = 1;
    x[i] = 0;
    q.push(i);
    while (!q.empty())
    {
        int v = q.back();
        q.pop();
        for (const auto& e : graph[v])
        {
            if (!visited[e.first])
            {
                x[e.first] = x[v] + e.second;
                visited[e.first] = 1;
                q.push(e.first);
            }
        }
    }
    return true;
}

void dfs(int i)
{
    visited[i] = 1;
    for (const auto& e : graph[i])
    {
        if (!visited[e.first])
        {
            x[e.first] = x[i] + e.second;
            dfs(e.first);
        }
    }
}

int main(int argc, char *argv[])
{
    scanf("%d %d", &n, &m);
    for (int i = 0; i < m; ++i)
    {
        int l, r, d;
        scanf("%d %d %d", &l, &r, &d);
        l--;
        r--;
        graph[l].push_back({r, d});
        graph[r].push_back({l, -d});
    }
    for (int i = 0; i < n; i++)
    {
        x[i] = 0;
        visited[i] = 0;
    }
    for (int i = 0; i < n; i++)
    {
        if (!visited[i])
            dfs(i);
    }
    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < graph[i].size(); ++j)
        {
            if (x[graph[i][j].first] - x[i]  != graph[i][j].second)
            {
                puts("No");
                return 0;
            }
        }
    }
    puts("Yes");
}


Measured memory_bytes: 11392
import sys
readline = sys.stdin.readline

def main():

	#s = tuple(input())
	s = input()
	length = len(s)

	dp = [[0]*13 for _ in range(length)]
	MOD = 10**9+7
	if s[-1] == '?':
		for i in range(10):
			dp[0][i] = 1
	else:
		dp[0][int(s[-1])] = 1

	num = 1
	for i in range(1,length):
		num = (10*num) % 13
		if s[-i-1] != '?':
			num2 = num * int(s[-i-1]) % MOD
			for j in range(13):
				dp[i][(num2+j)%13] = dp[i-1][j] % MOD
		else:
			for j in range(10):
				for k in range(13):
					dp[i][(num*j+k)%13] += dp[i-1][k] % MOD

	print(dp[-1][5] % MOD)

if __name__ == '__main__':
	main()


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

//#define int long long
typedef long long ll;
const int INF = 2e9;
//const ll INF = 9e18;


signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int D;
    cin >> D;
    vector<int> c(26);
    for (int i=0;i<26;i++) cin >> c[i];
    vector<vector<int>> s(D,vector<int>(26));
    for (int i=0;i<D;i++){
        for (int j=0;j<26;j++){
            cin >> s[i][j];
        }
    }
    vector<int> t(D);
    //初期t[i]の決定
    for (int i=0;i<D;i++) {
        t[i] = i % 26;
    }

    ll oldsum = -INF;
    for (int m=0;m<100000;m++){
        //ここでt[i]を更新していく
        int dd = rand()%D;
        int qq;
        int mn = INF;
        for (int i=0;i<26;i++){
            if (mn>c[i]){
                mn = c[i];
                qq = i;
            }
        }
        int oldval = t[dd];
        t[dd] = qq;
        //=======================
        ll sum = 0;
        vector<int> last(26);
        for (ll i=0;i<D;i++){
            sum += s[i][t[i]];
            last[t[i]] = i+1;
            for (int j=0;j<26;j++){
                sum -= c[j]*(i+1-last[j]);
            }
        }
        if (sum > oldsum) {
            oldsum = sum;
        } else {
            t[dd] = oldval;
        }
    }
    for (int i=0;i<D;i++){
        cout << t[i]+1 << "\n";
    }
}

Measured memory_bytes: 3712