akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef pair<ll, ll> p_ll;

template<class T>
void debug(T itr1, T itr2) { auto now = itr1; while(now<itr2) { cout << *now << " "; now++; } cout << endl; }
#define repr(i,from,to) for (int i=(int)from; i<(int)to; i++)
#define all(vec) vec.begin(), vec.end()
#define rep(i,N) repr(i,0,N)
#define per(i,N) for (int i=(int)N-1; i>=0; i--)

const ll MOD = pow(10,9)+7;
const ll LLINF = pow(2,61)-1;
const int INF = pow(2,30)-1;

vector<ll> fac;
void c_fac(int x=pow(10,6)+10) { fac.resize(x,true); rep(i,x) fac[i] = i ? (fac[i-1]*i)%MOD : 1; }
ll inv(ll a, ll m=MOD) { ll b = m, x = 1, y = 0; while (b!=0) { int d = a/b; a -= b*d; swap(a,b); x -= y*d; swap(x,y); } return (x+m)%m; }
ll nck(ll n, ll k) { return fac[n]*inv(fac[k]*fac[n-k]%MOD)%MOD; }
ll gcd(ll a, ll b) { if (a<b) swap(a,b); return b==0 ? a : gcd(b, a%b); }
ll lcm(ll a, ll b) { return a/gcd(a,b)*b; }


int main() {
  int H, W, d; cin >> H >> W >> d;
  char color[H][W] = {};
  if (d%2==1) rep(i,H) rep(j,W) color[i][j] = (i+j)%2 ? 'R' : 'Y';
  else {
    rep(i,H) rep(j,W) {
      int nx = (i+j)%2==0 ? (i+j)/2 % d : (i+j+1)/2 % d;
      int ny = (i+j)%2==0 ? ((i-j)/2%d+d) % d : ((i-j-1)/2%d+d) % d;
      if (nx<d/2) color[i][j] = ny<d/2 ? 'R' : 'Y';
      else color[i][j] = ny<d/2 ? 'G' : 'B';
    }
  }
  rep(i,H) { rep(j,W) cout << color[i][j]; cout << endl; }
  return 0;
}

Measured memory_bytes: 768
#include <iostream>

using namespace std;
int main(){
	int i,j,a[5],sum = 0,mx = 0;
	for(i=0;i<5;i++) cin >> a[i];
	for(i=0;i<5;i++){
		for(j=0;j<200;j+=10){
			if(j>=a[i]){
				sum += j; mx = max(mx,j - a[i]);
				break;
			}
		}
	}
	cout << sum - mx << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <numeric>
#include <iomanip>
#include <map>
#include <set>
#include <deque>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repk(i, k, n) for (int i = k; i < n; i++)
#define all(vec) vec.begin(), vec.end()
#define ll long long
#define debug(x) cout << "debug: " << x << endl
#define MOD 1e9 + 7
#define INF 1e9

template <class T>
inline bool chmin(T &a, T b){if(a > b){a = b; return true;}return false;}
template <class T>
inline bool chmax(T &a, T b){if(a < b){a = b; return true;}return false;}

int main(){
    int n; cin >> n;
    vector<int> h(n); rep(i, n) cin >> h[i];
    vector<int> dp_table(n, INF);
    dp_table[0] = 0;
    rep(i,n){
        chmin(dp_table[i], abs(h[i] - h[i - 1]) + dp_table[i - 1]);
        if (i > 1) {
            chmin(dp_table[i], abs(h[i] - h[i - 2]) + dp_table[i - 2]);
        }
    }
    cout << dp_table[n - 1] << endl;
}

Measured memory_bytes: 1024
#include <algorithm>
#include <iostream>
#include <queue>
#include <string>
#include <utility>
#include <vector>

using namespace std;

int ans, x[10];
int n, m, q, a[50], b[50], c[50], d[50];

void dfs(int y, int z) {
  if (y == n) {
    int cnt = 0;
    for (int i = 0; i < q; i++) {
      if (x[b[i] - 1] - x[a[i] - 1] == c[i]) {
        cnt += d[i];
      }
    }
    ans = max(ans, cnt);
    return;
  }
  for (int i = z; i <= m; i++) {
    x[y] = i;
    dfs(y + 1, i);
  }
}

int main() {
  cin >> n >> m >> q;
  for (int i = 0; i < q; i++) {
    cin >> a[i] >> b[i] >> c[i] >> d[i];
  }
  dfs(0, 1);
  cout << ans << endl;
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std ;
#define int                 long long
#define ull                 unsigned long long int
#define ld                  long double
#define vi                  vector<int>
#define vii                 vector<pair<int,int>>
#define vvi                 vector<vector<int>>
#define pii                 pair<int,int>
#define prec(x)             fixed<<setprecision(15)<<x
#define all(x)              x.begin(),x.end()
#define rall(x)             x.rbegin(),x.rend()
#define rev(x)              reverse(x.begin(),x.end())
#define mset(a,b)           memset(a,b,sizeof(a))
#define mcpy(a,b)           memcpy(a,b,sizeof(a))
#define fo0(i,n)            for(int i=0,i##end=n;i<i##end;i++)
#define fo1(i,n)            for(int i=1,i##end=n;i<=i##end;i++)
#define fo(i,a,b)           for(int i=a,i##end=b;i<=i##end;i++)
#define foe(i,x)            for(__typeof((x).end())i=(x).begin();i!=(x).end();++i)
#define fre(i,x)            for(__typeof((x).rend())i=(x).rbegin();i!=(x).rend();++i)
#define mk(arr,n,type)      type *arr=new type[n];
#define dbg(x) cerr << #x << " is " << x << endl;
#define FAST_IO ios_base::sync_with_stdio(false); cin.tie(0);cout.tie(0)
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
int gcd(int a, int b) { return b ? gcd(b, a%b) : a; }
clock_t beg = clock();
const int inf=1e18;const int mod=1e9+7;const int N=2e5+9;
const double pi = 3.1415926535897932384626433;
void FILE_IO(){
#ifndef ONLINE_JUDGE
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#endif
}

void JH(){
    int d=0,e=0,f=0,g=0,p=0,w=0,flag=0,ans=0,res=0,cnt=0,sum=0;double f1=0.0,f2=0.0,f3=0.0;
    int n;cin>>n;
    int a[n];
    map<int,int> m;
    fo0(i,n){
        cin>>a[i];
        sum+=a[i];
        m[a[i]]++;
    }
    res=sum;
    int q;cin>>q;
    while(q--){
        int c,d;cin>>c>>d;

        int p=m[c];
        m.erase(c);
        res-=p*c;

        if(m.count(d)){
            m[d]+=p;
        }
        else{
            m[d]=p;
        }
        res+=p*d;

        cout<<res<<endl;

    }
}

int32_t main()
{
    FILE_IO();FAST_IO;int t=1;
    // cin>>t;
    while(t--){JH();}cerr<<(double)(clock()-beg)/1000<<"s ";
}

Measured memory_bytes: 8476
#include<iostream>
#include<string>
#include<stdio.h>
#include<cctype>
#include<algorithm>
#include<climits>
#include<cmath>
#include<map>
#include<vector>
#define INF INT_MAX
using namespace std;

int N,M;
int A,B,C,D;
int sum, ans;
string S;

int main() {
	cin >> A >> B >> C >> D;

	while (1) {
		C -= B;
		if (C <= 0) {
			cout << "Yes" << endl;
			return 0;
		}
		A -= D;
		if (A <= 0) {
			cout << "No" << endl;
			return 0;
		}
	}


	return 0;
}

Measured memory_bytes: 3636
#pragma GCC optimize(2)
#include <bits/stdc++.h>
using namespace std;
using PII = pair<int,int>;
#define IOS cin.tie(nullptr); cout.tie(nullptr); ios_base::sync_with_stdio(false);

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

int main()
{
    IOS
    int n, mn, ans = 0;
    cin >> n;
    mn = n + 5;
    for(int i = 0, x; i < n; ++i)
    {
        cin >> x;
        if(x < mn)
        {
            ++ans;
            mn = x;
        }
    }
    cout << ans << '\n';
}

Measured memory_bytes: 256
//Relive your past life.
//Face your demons.
//The past is never dead,it is not even past.
//The memories are not only the key to the past but...also to the future.
//coded in Rusty Lake
#include<cmath>
#include<math.h>
#include<ctype.h>
#include<algorithm>
#include<bitset>
#include<cassert>
#include<cctype>
#include<cerrno>
#include<cfloat>
#include<ciso646>
#include<climits>
#include<clocale>
#include<complex>
#include<csetjmp>
#include<csignal>
#include<cstdarg>
#include<cstddef>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<cwchar>
#include<cwctype>
#include<deque>
#include<exception>
#include<fstream>
#include<functional>
#include<iomanip>
#include<ios>
#include<iosfwd>
#include<iostream>
#include<istream>
#include<iterator>
#include<limits>
#include<list>
#include<locale>
#include<map>
#include<memory>
#include<new>
#include<numeric>
#include<ostream>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<stdexcept>
#include<streambuf>
#include<string>
#include<typeinfo>
#include<utility>
#include<valarray>
#include<vector>
#include<string.h>
#include<stdlib.h>
#include<stdio.h>
#define ll   long long
#define pb   push_back
#define mp   make_pair
#define orz  1000000007
#define fi   first
#define se   second
using namespace std;
int n,q,nxt[200005],f[200005];
priority_queue<pair<int,pair<int,int> > > p;
int get(int x){return x==f[x]?x:f[x]=get(f[x]);}
int main(){
    scanf("%d%d",&n,&q);
    for(int i=0;i<n;++i)f[i]=i,nxt[i]=(i+1)%n;
    for(int i=1;i<=q;++i){
        int a,b,c;
        scanf("%d%d%d",&a,&b,&c);
        p.push(mp(-c,mp(a,b)));
        p.push(mp(-c-1,mp(b,nxt[a])));
    }
    int ok=n-1;
    ll ans=0;
    while(ok){
        int c=p.top().fi,a=p.top().se.fi,b=p.top().se.se;
        p.pop();
        if(get(a)==get(b)) continue;
        --ok;
        ans+=-1ll*c;
        f[f[a]]=f[b];
        p.push(mp(c-2,mp(nxt[a],nxt[b])));
    }
    printf("%lld\n",ans);
//	system("pause");
	return 0;
}


Measured memory_bytes: 9968
#include<bits/stdc++.h>
using ll=long long;
using namespace std;
#define rep(i, n) for(ll i=0; i<n; i++)
#define Rep(i, j, n) for(ll i=j; i<n; i++)
#define all(vec) vec.begin(), vec.end()
template<class T> inline bool chmin(T& a, T b) {if(a > b) {a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) {if(a < b) {a = b; return true;} return false;}
ll MM = 1000000000; ll mod = MM + 7; ll MMM=9223372036854775807;//2^63 -1
ll GCD(ll x, ll y){ if(y == 0) return x; else return GCD(y, x % y);}
ll LCM(ll x, ll y){ return x / GCD(x, y) * y;}
int dh[4] = {-1, 0, 0, 1};
int dw[4] = {0, -1, 1, 0}; 
using P = pair<int, int>;
const double pi = acos(-1.0);

using Graph = vector<vector<ll>>;

int main(){
  ll a,b,c,d;
  cin>>a>>b>>c>>d;
  ll ans;
  ans=a*c;
  ans=max(ans,a*d);
  ans=max(ans,b*c);
  ans=max(ans,b*d);

  cout<<ans<<endl;
    
  return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define MV 200001
#define LMV 21
#define ff first
#define ss second
#define pb push_back
#define eb emplace_back
#define emp emplace
#define mp make_pair
#define ins insert
#define sz size
#define whoami(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); whi(_it, args); }

void whi(istream_iterator<string> it) { cerr<<"\n"; }

template<typename T, typename... Args>
void whi(istream_iterator<string> it, T a, Args... args) { cerr<<*it<<" "<<a<<" "; whi(++it, args...); }

void FLASH() {ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);}
void SETF() {cout.ios_base::setf(ios_base::fixed); cerr.ios_base::setf(ios_base::fixed);}
void UNSETF() {cout.ios_base::unsetf(ios_base::fixed); cerr.ios_base::unsetf(ios_base::fixed);}

typedef long long ll;
typedef long double ld;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
typedef pair<PII, int> PPII;
typedef pair<PLL, ll> PPLL;
typedef map<int, int> MII;

const int MOD = 1000000007;
const ll INF = 4e18;

template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template <typename T>
using ordered_multiset = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;

struct h_llint {
  static uint64_t splitmix64(uint64_t x) {    // http://xorshift.di.unimi.it/splitmix64.c
    x += 0x9e3779b97f4a7c15;
    x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
    x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
    return x ^ (x >> 31);
  }
  size_t operator()(uint64_t x) const {
    static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
    return splitmix64(x + FIXED_RANDOM);
  }
};

struct h_pair{
  size_t operator()(const PLL&x)const{
    return hash<ll>()(((ll)x.ff)^(((ll)x.ss)<<32));
  }
};

typedef map<ll, ll> MLL;
typedef map<PII, int> MPII;
typedef map<PLL, ll> MPLL;
typedef set<int> SI;
typedef set<ll> SL;
//ordered_set = order_of_key(.)
//ordered_set = find_by_order(.)
typedef ordered_set<int> OSI;
typedef ordered_set<ll> OSL;
typedef ordered_multiset<int> MOSI;
typedef ordered_multiset<ll> MOSL;
typedef unordered_map<ll, int, h_llint> UMLI;
typedef unordered_map<ll, ll, h_llint> UMLL;
typedef unordered_map<PLL, int, h_pair> UMPI;
typedef unordered_map<PLL, ll, h_pair> UMPL;

int ar[MV];
ll arr[MV];

void solve(int T)
{
	int x;
	cin>>x;
	int lc = 360/__gcd(360, x);
	cout<<lc<<"\n";
	return;	
}

int main(void)
{
	FLASH();
	//freopen("cowjog.in", "r", stdin);
	//freopen("cowjog.out", "w", stdout);
	int T;
	T = 1;

#ifndef ONLINE_JUDGE
	time_t time_t1, time_t2;
	time_t1 = clock();
#endif

	//cin>>T;
	while(T--)
	solve(T);

#ifndef ONLINE_JUDGE
	time_t2 = clock();
	SETF();
	cerr<<"Time taken: "<<setprecision(7)<<(time_t2 - time_t1)/(double)CLOCKS_PER_SEC<<"\n";
	UNSETF();
#endif

	return 0;
}

Measured memory_bytes: 3636
from collections import deque
n,m = map(int, input().split())
G = [[] for _ in range(n)]
for i in range(m):
    a,b = map(lambda z:int(z)-1,input().split())
    G[a].append(b)
    G[b].append(a)

queue = deque()
pre = [-1 for _ in range(n)]
dist = [10**10 for _ in range(n)]

dist[0] = 0
queue.append(0)
while queue:
    now = queue.popleft()
    for to in G[now]:
        if dist[to] > dist[now] + 1:
            dist[to] = dist[now] + 1
            pre[to] = now
            queue.append(to)

print("Yes")
for i in range(1,n):
    print(pre[i]+1)

Measured memory_bytes: 107832
#include<bits/stdc++.h>
#define int long long
using namespace std;
int n,m,a[10009],tot,ans;
signed main(){
	cin>>n>>m;
	for(int i=1;i<=n;i++) cin>>a[i],tot+=a[i];
	for(int i=1;i<=n;i++) if(a[i]*(4*m)>=tot) ans++;
	if(ans>=m) cout<<"Yes";
	else cout<<"No";
	return 0;
}


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

const string YES = "Yes";
const string NO = "No";

void solve(long long N){
  long long acc = 0;
  long long tmpN = N;

  while(tmpN > 0) {
    acc += tmpN%10;
    tmpN /= 10;
  }

  cout << ((N % acc == 0) ? YES : NO) << endl;
}

// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
  scanf("%lld",&N);
    solve(N);
    return 0;
}


Measured memory_bytes: 3576
while true
    t, d, l = gets.chomp.split.map(&:to_i)
    break if [t, d, l] == [0, 0, 0]
    arr = []
    t.times{arr << gets.to_i}
    countdown, sum = 0, 0
    arr[0...-1].each{|x|
        countdown = (x >= l) ? d : countdown - 1
        sum += 1 if countdown > 0
    }
    puts sum
end



Measured memory_bytes: 17436
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
int n, a, b, c, L[8], min = std::pow(10, 7), mp;
std::vector<int> v;

void calc(std::vector<int>v){
    int mpa = 0, mpb = 0, mpc = 0, cnta = 0, cntb = 0, cntc = 0, mpp = 0;
    for(int i = 0;i < n;i++){
        if(v[i] == 0) {
            mpa += L[i];
            cnta++;
        }
        else if(v[i] == 1) {
            mpb += L[i];
            cntb++;
        }
        else if(v[i] == 2) {
            mpc += L[i];
            cntc++;
        }
    }
    mpp += abs(mpa - a);
    mpp += abs(mpb - b);
    mpp += abs(mpc - c);
    if(cnta == 0){
        cnta++;
    }
    if(cntb == 0){
        cntb++;
    }
    if(cntc == 0){
        cntc++;
    }
    mp = (cnta - 1) * 10 + (cntb - 1) * 10 + (cntc - 1) * 10 + mpp;
    if (min > mp && mpc != 0 && mpb != 0 && mpa != 0){
        min = mp;
    }
}

void fds(int depth, std::vector<int>v)
{
    if(depth == n){
        calc(v);

        return ;
    }

    for(int i = 0;i < 4;i++){
        v.push_back(i);
        fds(depth + 1, v);
        v.pop_back();
    }
}


int main()
{
    
    std::cin >> n >> a >> b >> c;
    for(int i = 0;i < n;i++){
        std::cin >> L[i];
    }
    
    fds(0, v);
    
    std::cout << min;

    return 0;

}



Measured memory_bytes: 256
#include <stdio.h>
#define N 100

int main(){

  int n,A[N],i,j,k,l,count=0,temp;

  int minj;
  
  scanf("%d",&n);

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

      for(l=j;l<=n-1;l++){
	if(A[l]<A[minj]){

	  minj=l;

      }

      }
      if(j != minj){
      temp=A[j];
	A[j]=A[minj];
	A[minj]=temp;
	count++;
      }
  }

  for(k=0;k<n;k++){
    if(k)printf(" ");
    printf("%d",A[k]);
    
  }

  printf("\n");

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

  return 0;
}



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

/* 大文字を小文字に変換 */
char tolower(char c) {return (c + 0x20);}
/* 小文字を大文字に変換 */
char toupr(char c) {return (c - 0x20);}

// if('A'<=s[i] && s[i]<='Z') s[i] += 'a'-'A';

/*
string s = "abcdefg"
s.substr(4) "efg"
s.substr(0,3) "abc"
s.substr(2,4) "cdef"

// イテレータ要素のインデックス
distance(A.begin(), itr);
*/

const int MAX_N = 200005;
const int INF = 1001001001;

vector<int> a, ans;
vector<int> to[MAX_N];   // 隣接リストとして使用する変数
int dp[MAX_N];  // LIS(最長増加部分列)を求める際のDP（動的計画法）で使用する多次元配列

void dfs(int v, int p=-1){
    int i = lower_bound(dp, dp+MAX_N, a[v]) - dp;    // スタート位置のインデックスを求める
    int old = dp[i];
    dp[i] = a[v];
    ans[v] = i;
    if(p != -1) ans[v] = max(ans[v], ans[p]);
    for(int u: to[v]){
        if(u == p) continue;
        dfs(u, v);
    }
    dp[i] = old;
}

int main()
{
    int n; cin >> n;
    a = ans = vector<int>(n);
    rep(i,n) cin >> a[i];
    // 隣接リストに各辺の情報を格納していく
    rep(i,n-1){ // 辺の数はn-1
        int u, v; cin >> u >> v;
        u--; v--;   // インデックスの番号と整合性をとるためにデクリメントする
        to[v].push_back(u);
        to[u].push_back(v);
    }
    rep(i,MAX_N) dp[i] = INF;   // 初期化
    dp[0] = -INF;
    dfs(0);
    rep(i,n) cout << ans[i] << endl;
    return 0;
}

Measured memory_bytes: 30896
def get_i() #空白区切の入力を数値(整数)の配列で返す
  return gets.chomp.split(" ").map(&:to_i)
end
def get_f() #空白区切の入力を数値(実数)の配列で返す
  return gets.chomp.split(" ").map(&:to_f)
end
def get() #空白区切の入力を文字列の配列で返す
  return gets.chomp.split(" ")
end
def get_nsp() #入力されたものを一文字ずつに区切った文字列の配列で返す
  return gets.chomp.split("")
end
def yn_judge(bool,y="Yes",n="No") #boolに真偽を投げることで、trueならy、falseならnの値を出力する
  return bool ? y : n 
end
def array(size1,init=nil,size2=1) #size2に二次元配列時の最初の要素数、size1に次の配列の大きさ、initに初期値を投げることでその配列を返す
  if size2==1
    return Array.new(size1){init}
  else
    return Array.new(size2){Array.new(size1){init}}
  end
end

n,k=get_i
n=n%k
ans=n
loop do
  n=(n-k).abs
  if ans>n
      ans=n
  else
      break
  end  
end
puts ans

Measured memory_bytes: 1788
fn main() {
	let mut s = String::new();
	use std::io::Read;
	std::io::stdin().read_to_string(&mut s).unwrap();
	let mut s = s.split_whitespace();
	let n: usize = s.next().unwrap().parse().unwrap();
	let mut d: Vec<i32> = s.map(|d| d.parse().unwrap()).collect();
	d.sort();
	let ans = d[n / 2] - d[n / 2 - 1];
	println!("{}", ans);
}


Measured memory_bytes: 6396
import Control.Monad                                                                                                       
import Data.Array                                                                                                          
                                                                                                                           
main :: IO ()                                                                                                              
main = do                                                                                                                  
  n <- read <$> getLine                                                                                                    
  as <- listArray (0,n-1) <$>  replicateM n (read <$> getLine)                                                             
                                                                                                                           
  print $ f n as 0 1                                                                                                       
                                                                                                                           
f :: Int -> Array Int Int -> Int -> Int -> Int                                                                             
f n xs m i                                                                                                                 
  | i == 2 = m                                                                                                             
  | n == m = -1                                                                                                            
  | otherwise = f n xs (m+1) (xs!(i-1)) 

Measured memory_bytes: 40316
#include<iostream>
#include<vector>
#include<algorithm>
#include<string.h>
#include<complex>
using namespace std;
typedef long long int llint;
int main(){
	int a, b, c, d, e;
	cin >> a;
	if (a < 1000){
		cout << "ABC" << endl;
	}
	else{
		cout << "ABD" << endl;
	}
	return 0;
}

Measured memory_bytes: 384
#include"bits/stdc++.h"
using namespace std;
int main(void){
  int n,a;
  bool ok=true;
  cin>>n;
  for(int i=0;i<n;++i){
    cin>>a;
    if(a%2==0){
      if(a%5==0||a%3==0){}
      else{
        ok=false;
      }
    }
  }
  if(ok){
    cout<<"APPROVED";
  }
  else{
    cout<<"DENIED";
  }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int a,b,c,d;
int main()
{
cin>>a>>b>>c>>d;
while(1)
{
	c=c-b;
	if(c<=0)
	{
		cout<<"Yes";
		return 0;
		
	}
	a=a-d;
	if(a<=0)
	{
		cout<<"No";
		return 0;
	}
	
}
return 0;

}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
#define inf 1000000007
#define mod 1000000007
//#pragma GCC optimize(2)
//#define int long long
using namespace std;
template <typename T> void read(T &x){
	x=0;char ch=getchar();int fh=1;
	while (ch<'0'||ch>'9'){if (ch=='-')fh=-1;ch=getchar();}
	while (ch>='0'&&ch<='9')x=x*10+ch-'0',ch=getchar();
	x*=fh;
}
template <typename T> void write(T x) {
	if (x<0) x=-x,putchar('-');
	if (x>9) write(x/10);
	putchar(x%10+'0');
}
template <typename T> void writeln(T x) {
	write(x);
	puts("");
}
signed main()
{
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int k;
	cin>>k;
	queue<string> q;
	string t;
	for(char i='1';i<='9';i++)
		q.push(t+i);
	int cnt=0;
	while(!q.empty())
	{
		string s=q.front();
		q.pop();
		if(++cnt==k)
		{
			cout<<s<<endl;
			return 0;
		}
		char c=s[s.size()-1];
		if(c=='0')
		{
			q.push(s+'0');
			q.push(s+'1');
		}
		else if(c=='9')
		{
			q.push(s+'8');
			q.push(s+'9');
		}
		else
		{
			q.push(s+(char)(c-1));
			q.push(s+c);
			q.push(s+(char)(c+1));
		}
	}
	return 0;
}


Measured memory_bytes: 13824
using System;
using System.Collections.Generic;
using System.Linq;
using BitArray = System.Collections.BitArray;
using BigInteger = System.Numerics.BigInteger;

namespace AtCoderProject
{
    public class Program
    {
        public object Calc()
        {
            N = consoleReader.Int;
            var sushiCount = new int[3];
            foreach (var a in consoleReader.Split.Int)
            {
                ++sushiCount[a - 1];
            }
            dp = new double[sushiCount[0] + sushiCount[1] + sushiCount[2] + 1, sushiCount[1] + sushiCount[2] + 1, sushiCount[2] + 1];

            return Calc(sushiCount[0], sushiCount[1], sushiCount[2]);
        }

        double Calc(int i, int j, int k)
        {
            if (i == 0 && j == 0 && k == 0) return 0;
            else if (dp[i, j, k] > 0) return dp[i, j, k];
            double res = 0;
            if (i > 0)
            {
                res += Calc(i - 1, j, k) * i;
            }
            if (j > 0)
            {
                res += Calc(i + 1, j - 1, k) * j;
            }
            if (k > 0)
            {
                res += Calc(i, j + 1, k - 1) * k;
            }
            res += N;
            res /= (i + j + k);

            return dp[i, j, k] = res;
        }

        int N;
        double[,,] dp;

        #region いつもの
        private readonly ConsoleReader consoleReader;
        public Program(ConsoleReader consoleReader) { this.consoleReader = consoleReader; }
        static void Main() => Console.WriteLine(new Program(new ConsoleReader()).Calc()); static string AllLines<T>(IEnumerable<T> source) => string.Join("\n", source);
        #endregion
    }

#pragma warning disable
    public class ConsoleReader { public class SplitLine { string[] splited; public SplitLine(string line) { splited = line.Split(); } public string[] String => splited.ToArray(); public int[] Int => splited.Select(int.Parse).ToArray(); public long[] Long => splited.Select(long.Parse).ToArray(); public ulong[] ULong => splited.Select(ulong.Parse).ToArray(); public double[] Double => splited.Select(double.Parse).ToArray(); } public class RepeatLine { ConsoleReader reader; int num; public RepeatLine(ConsoleReader reader, int num) { this.reader = reader; this.num = num; } public IEnumerable<string> String { get { for (int i = 0; i < num; i++) yield return reader.String; } } public IEnumerable<int> Int { get { for (int i = 0; i < num; i++) yield return reader.Int; } } public IEnumerable<long> Long { get { for (int i = 0; i < num; i++) yield return reader.Long; } } public IEnumerable<string[]> Split { get { for (int i = 0; i < num; i++) yield return reader.Split.String; } } public IEnumerable<int[]> SplitInt { get { for (int i = 0; i < num; i++) yield return reader.Split.Int; } } } public virtual string String => Console.ReadLine(); public int Int => int.Parse(String); public long Long => long.Parse(String); public ulong ULong => ulong.Parse(String); public double Double => double.Parse(String); public SplitLine Split => new SplitLine(String); public RepeatLine Repeat(int count) => new RepeatLine(this, count); }
}

Measured memory_bytes: 224096
from functools import reduce
from operator import add

n = int(input())
lst = list(map(int, input().split()))

m = 0 #-の個数
z = 0 #0の個数

for i in range(n):
  if lst[i] == 0:
    z += 1
  if lst[i] < 0:
    m += 1

ans = 0
l = list(map(abs, lst))
if m%2 == 1 and z == 0:
  ans = reduce(add,l) - 2 * min(l)
else:
  ans = reduce(add,l)
print(ans)

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

#define FOR(i, s, e)   for(int i = (s); i < (e); i++)
#define FOR64(i, s, e) for(ll  i = (s); i < (e); i++)
#define ALL(x)         (x).begin(), (x).end()
#define SORT(b, e)     sort((b), (e))
#define REV(b, e)      reverse((b), (e))
#define VSORT(v)       sort((v).begin(), (v).end())
#define VREV(v)        reverse((v).begin(), (v).end())
#define pb(a)          push_back(a)
#define INF            999999999

typedef long long ll;

#define W 0
#define B 1

int main()
{
	int h, w;
	cin >> h >> w;

	vector<int> a(h * w);

	vector<int> sum_horz(h, 0);

	int k = 0;
	FOR(j, 0, h){
		FOR(i, 0, w){
			char c;
			cin >> c;
			a[k] = (c == '.') ? W : B;
			sum_horz[j] += a[k];
			k++;
		}
	}

	vector<int> sum_vert(w, 0);

	FOR(i, 0, w){
		FOR(j, 0, h){
			sum_vert[i] += a[j * w + i];
		}
	}

	FOR(j, 0, h){
		if(sum_horz[j] == 0)
			continue;

		FOR(i, 0, w){
			if(sum_vert[i] == 0)
				continue;

			cout << ((a[j * w + i] == W) ? '.' : '#');
		}

		cout << endl;
	}

	return 0;
}



Measured memory_bytes: 256
#include<stdio.h>

int A[1000000], n;

int binarySearch(int key) {
  int left = 0;
  int right = n;
  int mid;
  while ( left < right ) {
    mid = (left + right) / 2;
    if ( key == A[mid] ) return 1;
    if ( key > A[mid] ) left = mid + 1;
    else if ( key < A[mid] ) right = mid;
  }
  return 0;
}

int main() {
  int i, q, k, sum = 0;

  scanf("%d", &n);
  for ( i = 0; i < n; i++ )
    scanf("%d", &A[i]);

  scanf("%d", &q);
  for ( i = 0; i < q; i++ ) {
    scanf("%d", &k);
    if ( binarySearch( k ) ) sum++;
  }
  printf("%d\n", sum);

  return 0;
}


Measured memory_bytes: 2964
#include <stdio.h>

int main(void)
{
	int a, b;
	scanf("%d", &a);
	scanf("%d", &b);

	if(a>b){
		printf("a > b\n");
	}else if(a<b){
		printf("a < b\n");
	}else{
		printf("a == b\n");
	}
}

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

int main() {
  int h, a;
  cin >> h >> a;
  if (h%a==0) {
    cout << h/a << endl;
  } else {
  	cout << (h/a) + 1 << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include<vector>
#include <algorithm>
#include <queue>
#include<string>
#include <map>
#include <cmath>
#define rep(i,n) for(int i=0;i<(n);++i)
using namespace std;
typedef long long ll;
typedef long double ld;

int main() {
	int N;
	cin >> N;
	vector<int>A(N);
	priority_queue<int>P;
	rep(i, N) {
		cin >> A[i];
		P.push(A[i]);
	}
	for (int i = 0; i < N ;++i) {
		if (P.top()!=A[i]) {
			cout << P.top()<<endl;
		}
		else {
			P.pop();
			cout << P.top()<<endl;
			P.push(A[i]);
		}
	}

	return 0;
}

Measured memory_bytes: 3316
#include <bits/stdc++.h>
 
using namespace std;
 
#define MD 1000000007
typedef long long int ll;


int main(){
    string s;
    cin>>s;
    int w;
    cin>>w;
    int cnt=s.size(),i=0;
    
    while(i<cnt){
        cout<<s[i];
        i+=w;
    }
    cout<<endl;
    return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <stack> // s.top()
#include <bitset>
#include <queue> // s.front()
using namespace std;

typedef long long ll;
#define print(x) cout<<(x)<<endl


#define INF10 10000000000
#define INF5 100000
#define EPS 1e-10
#define MOD 1000000007



int main() {
	ll N; cin >> N;
	vector<ll> D;
	for (ll i = 0; i < N; i++) {
		ll ipt; cin >> ipt;
		D.push_back(ipt);
	}
	ll M; cin >> M;
	vector<ll> T;
	for (ll i = 0; i < M; i++) {
		ll ipt; cin >> ipt;
		T.push_back(ipt);
	}
	sort(D.begin(), D.end()); sort(T.begin(), T.end());
	for (ll i = 0; i < M; i++) {
		while (D.size()>0){
			if(D.back() > T.back()) D.pop_back();
			else break;
		}
		if (D.size() == 0 || D.back() < T.back()) {
			print("NO");
			return 0;
		}
		D.pop_back();
		T.pop_back();
	}
	print("YES");




	



	return 0;
}

Measured memory_bytes: 4848
#include <bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
typedef long long ll;
typedef long double ld;
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define mod 1000000007
#define inf 1000000000000000000
#define bpc(x) __builtin_popcountll(x)
#define autoit(x,it) for(auto it = x.begin(); it != x.end(); it++)
#define rep(n) for(ll i = 0; i < n; i++)
#define repi(i,n) for(ll i = 0; i < n; i++)

#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 

#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 

using namespace std;

int main()
{
  FAST/**/
   
   ll n,d;
   cin>>n>>d;
   
   ll ans = 0;
   rep(n)
   {
       ll x,y;
       cin>>x>>y;
       
       ll dis = (x*x) + (y*y) - d*d;
       if(dis<=0)
            ans++;
   }
   cout<<ans;
   
   
   return 0;        
}  
  
          
   

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

using namespace std;

#define rep(i, n) for (int i = 0; i < (n); ++i)

const char sp = ' ';
const char cmm = ',';
const int MOD = 1000000007;

using ll = long long;

ll mod(ll a, ll b){return (a%b+b)%b;}
ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b){return a*b/gcd(a,b);}
void Yes(){cout << "Yes" << endl;}
void No(){cout << "No" << endl;}
void Judge(bool b){b?Yes():No();}
void YES(){cout << "YES" << endl;}
void NO(){cout << "NO" << endl;}
void JUDGE(bool b){b?YES():NO();}
ll powMod(ll b, ll e, ll m){ll r=1;while(e>0){if(e&1)r=(r%m)*(b%m)%m;b=(b%m)*(b%m)%m;e>>=1;}return r;}
double distance(ll x1, ll y1, ll x2, ll y2){return sqrt((x1-x2)*(x1-x2) + (y1-y2)*(y1-y2));}

template<typename T>
void ppp(T n){cout << n << endl;}

ll fac[200001];
ll invfac[200001];

ll comb(ll a, ll b){
    if(a == 0 and b == 0) return 1;
    if(a < b or a < 0) return 0;
    ll tmp = invfac[a-b]*invfac[b]%MOD;
    return tmp * fac[a] % MOD;
}

int main(){

    cin.tie(0);
    ios::sync_with_stdio(false);

    int h, w, a, b;
    cin >> h >> w >> a >> b;

    fac[0] = invfac[0] = 1;
    for(ll i = 1; i <= 200000; ++i){
        fac[i] = fac[i-1]*i % MOD;
        invfac[i] = invfac[i-1] * powMod(i, MOD-2, MOD) % MOD;
    }

    ll upside[w-b];
    ll downside[w-b];
    for(int i = 0; i < w-b; ++i){
        upside[i] = comb(h-a-1+b+i, b+i);
        downside[i] = comb(w+a-b-2-i, w-b-1-i);
    }


    ll ans = 0LL;
    for(int i = 0; i < w-b; ++i){
        ans += upside[i] * downside[i] % MOD;
        ans %= MOD;
    }

    ppp(ans);

    return 0;
}


Measured memory_bytes: 4864
#include <iostream>
#include <string>

using namespace std;

int main(){    
    int N;
    string S;

    cin >> N;
    cin >> S;

    if(S.size()%2 == 1){
        cout << "No" << endl;
    }else{
        string s1 = S.substr(0, S.size()/2);  
        string s2 = S.substr(S.size()/2, S.size()/2);  
        if(s1 == s2){
            cout << "Yes" << endl;
        }else{
            cout << "No" << endl;
        }
    }

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cmath>
#include<vector>
#include<queue>
#include<map>
#include<algorithm>
#include<set>
#include<complex>
#include<string>
#include<cstring>
using namespace std;
#define rep2(x,from,to) for(long long x=(from);(x)<(to);(x)++)
#define rep(x,to) rep2(x,0,to)
#define INF 100000000
#define debug(x) cout<<#x<<": "<<x<<endl

#define all(x) x.begin(),x.end()
typedef pair<long long,long long> P;
typedef pair<long long,P> PP;
long long n,a,b;
int main()
{
	cin>>n>>a>>b;
	if(n==1)
	{
		if(a==b)cout<<1<<endl;
		else cout<<0<<endl;
	}
	if(n==2)
	{
		if(a>b)cout<<0<<endl;
		if(a<=b)cout<<1<<endl;
	}
	if(n>2)
	{
		if(a>b)cout<<0<<endl;
		if(a==b)cout<<1<<endl;
		if(a<b)
		{
			cout<<b*(n-1)+a-b-a*(n-1)+1<<endl;
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = s; i < (int)(n); i++)
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

using namespace std;
using ll = long long;
using pii = pair<int, int>;

//const ll INF = 1e18L + 5;
//const int INF = 1e9 + 5;
//const double pi = 3.14159265358979323846;

void	solve()
{
	int n, a, b;
	cin >> n >> a >> b;

	cout << min(n * a, b) << endl;
}

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

	solve();
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <utility>
#include <functional>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_map>
#include <iomanip>
#include <numeric>
#include <complex>

using namespace std;
using ll = long long;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
const int INF = (1<<30);
const ll INFL = (1LL<<62);
const ll MOD = 1000000007;
template<class T> bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template<class T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
template<class T> ll mod_pow(ll a, ll n, T mod) { mod=(ll)mod; ll res=1, p=a%mod; while(n){ if(n&1) res=res*p%mod; p=p*p%mod; n>>=1; } return res; }

struct ModCombination {
  ModCombination(unsigned int n) : n(n), F(n + 1, 1), I(n + 1, 1) {
    for (unsigned int i = 1; i <= n; ++i) F[i] = 1ll * i * F[i - 1] % MOD;
    for (int64_t i = MOD - 2, j = F[n]; i; i >>= 1) {
      if (i & 1) I[n] = I[n] * j % MOD;
      j = j * j % MOD;
    }
    for (int i = n - 1; i; --i) I[i] = I[i + 1] * (i + 1ll) % MOD;
  }

  unsigned int n;
  vector<int> F, I;

  int operator()(int p, int k) {
    if (k < 0 || k > p) return 0;
    return 1ll * F[p] * I[k] % MOD * I[p - k] % MOD;
  }
};


int main() {
    int H, W, A, B;
    cin >> H >> W >> A >> B;
    ModCombination mC(H+W);
    int ans = 0;
    for(int i=B+1; i<=W; i++){
        ans += ((int64_t)mC(H-A+i-2, i-1) * mC(W-i+A-1, A-1)) % MOD;
        ans %= MOD;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1920
#include <bits/stdc++.h>
#define PI 3.1415926535897
using namespace std;
typedef long long ll;
const int INF = 1000000000;
const ll LINF = 1000000000000000000; //1e18
const double EPS = 1e-10;            //

int main(void)
{
    int r, g, b;
    cin >> r >> g >> b;

    if ((g * 10 + b) % 4 == 0)
    {
        cout << "YES" << endl;
    }
    else
    {
        cout << "NO" << endl;
    }
    return (0);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int mat[4005][4005];
int sum[4005][4005];
int n,k;
int query(int a, int b) 
{
	return sum[a+k][b+k] - sum[a][b+k] - sum[a+k][b] + sum[a][b];
}
int main()
{
	scanf("%d %d",&n,&k);
	int contw = 0;
	for(int i = 0 ; i < n ; i++)
	{
		int add = 1;
		int x,y;
		char c;
		scanf("%d %d %c",&x,&y,&c);
		if(c == 'W')
		{
			contw++;
			add = -1;
		}
		x %= 2 * k;
		y %= 2 * k;
		y++;
		x++;
		mat[x][y] += add;
		mat[x + 2 * k][y] += add;
		mat[x][y + 2 * k] += add;
		mat[x + 2 * k][y + 2 * k] += add;
	}
	for(int i = 1 ; i <= 4 * k ; i++)
	{
		for(int j = 1 ; j <= 4*k; j++)
		{
			sum[i][j] = mat[i][j] + sum[i-1][j] + sum[i][j-1]  - sum[i-1][j-1]; 
		}
	}
	int ans = 0;
	for(int i = 1 ; i <= 2 * k ; i++)
	{
		for(int j = 1 ; j <= 2 * k; j++)
		{
			ans = max(ans,contw + query(i,j) + query(i+k,j+k));//counting blacks 
		}
	}

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

	return 0;
}


Measured memory_bytes: 125440
#include <stdio.h>
#include <string.h>
#include <algorithm>
#define rep(i,st,ed) for (int i=st;i<=ed;++i)
#define lowbit(x) (x&-x)

typedef long long LL;
const int MOD=1e9+7;
const int N=18;

LL f[1<<N],g[N][1<<N],bin[155];

int read() {
	int x=0,v=1; char ch=getchar();
	for (;ch<'0'||ch>'9';v=(ch=='-')?(-1):(v),ch=getchar());
	for (;ch<='9'&&ch>='0';x=x*10+ch-'0',ch=getchar());
	return x*v;
}

int main(void) {
	bin[0]=1; rep(i,1,125) bin[i]=bin[i-1]*2LL%MOD;
	int n=read(),m=read();
	rep(i,1,m) {
		int x=read()-1,y=read()-1;
		++g[x][1<<y];
	}
	rep(i,0,n-1) {
		for (int j=1;j<(1<<n);++j) {
			g[i][j]=g[i][j-lowbit(j)]+g[i][lowbit(j)];
		}
	}
	for (int S=1;S<(1<<n);++S) {
		if ((S&1)!=((S>>1)&1)) continue;
		f[S]=1;
		for (int a=S,b,w;a;a=(a-1)&S) {
			if ((a&1)!=((a>>1)&1)) continue;
			b=S-a; w=f[b];
			rep(i,0,n-1) {
				if ((b>>i)&1) w=(bin[g[i][a]]-1)*w%MOD;
				if ((a>>i)&1) w=bin[g[i][b]]*w%MOD;
			}
			f[S]=(f[S]+w)%MOD;
		}
	}
	LL ans=(bin[m]+MOD-f[(1<<n)-1])%MOD;
	printf("%lld\n", ans);
	return 0;
}

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

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<ll> vl;
typedef vector<char> vc;
typedef vector<string> vs;
const ll mod = 1e9+7;
const ll inf = 1e17;
const int INF = 1e9;
const double PI = acos(-1);
#define fo(i, a, b) for(int i = a; i < b; i++)
#define re(i, n) fo(i, 0, n)
#define pb push_back
#define mp make_pair
#define all(s) s.begin(), s.end()
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { ll g = gcd(a, b); return a / g * b; }
int main()
{
  ll a;
  cin >> a;
  int x, y;
  scanf("%d.%d", &x, &y);

  cout << a * (x * 100 + y) / 100 << endl;

  return 0;
}


Measured memory_bytes: 3720
# D - Friends

from collections import Counter

n, m = map(int, input().split())
adj = [[] for a in range(n + 1)]
for i in range(m):
    a, b = map(int, input().split())
    adj[a].append(b)
    adj[b].append(a)

# 答は最大連結成分の要素数

cc = [None for a in range(n + 1)] # 各頂点の連結成分

ccid = 0
for u in range(1, n + 1):
    if cc[u] != None:
        continue
    ccid += 1
    queue = [u]
    while len(queue) > 0:
        a = queue.pop()
        if cc[a] == None:
            cc[a] = ccid
            queue.extend(adj[a])

counter = Counter(cc)
print(max(counter.values()))


Measured memory_bytes: 46632
import fractions
a, b, c, d = list(map(int, input().split()))
ans = []
for n in [a - 1, b]:
    mc = n // c
    md = n // d
    cd = c * d // fractions.gcd(c, d)
    mcd = n // cd
    ans.append(n - mc - md + mcd)
print(int(ans[1] - ans[0]))

Measured memory_bytes: 5048
#include <bits/stdc++.h> 
#define FOR(i,a,b) for(int i=(a);i<=(b);++i) 
#define RFOR(i,a,b) for(int i=(a);i>=(b);--i) 
#define REP(i,n) for(int i=0;i<(n);++i)
#define RREP(i,n) for(int i=(n);i>0;--i)
#define CI cin>> 
#define CO cout<<
#define EN <<endl 
#define all(x) (x).begin(),(x).end() 
#define asn ans
using namespace std;
template <typename T> istream& operator >> (istream& is, vector<T>& vec) { for (T& x : vec) is >> x; 	return is; }
using ll = long long;

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

	if (a > b)CO a - 1 EN;
	else CO a EN;

	return 0;
}

Measured memory_bytes: 256
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int d = sc.nextInt() - 1;
        int x = sc.nextInt();
        int ans = n;
        for(int i = 0;i < n;i++){
            int day = sc.nextInt();
            ans += d / day;
        }
        System.out.println(ans + x);
    }
}

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

const int MOD = 1000000007;

//long long
using ll = long long;

//出力系
#define print(x) cout << x << endl
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
 
// begin() end()
#define all(x) (x).begin(),(x).end()

//for
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)

//最大公約数 
unsigned gcd(unsigned a, unsigned b) {
  if(a < b) return gcd(b, a);
  unsigned r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}

  
int main() {

int N;
cin >> N;
if(N == 1) {
    print(1);
    return 0;
}
long long ans;
ll l1 = 2, l2 = 1;
for(int i = 2; i <= N; i++){ 
     ans = l1 + l2;
     l1 = l2;
     l2 = ans;     
}
print(ans);
}

Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<algorithm>
#include<map>
using namespace std;
char ch[510000];
int n,A[510000],len,f[510000][3],B[510000];
int solve(int l,int r){
	len=1; A[1]=0; if (l>r) return 0;
	for (int i=l;i<=r;i++)
		if (ch[i]=='1') A[len]++;
		else {
			len++; A[len]=0;
		}
	for (int i=0;i<=len;i++)
		f[i][0]=f[i][1]=f[i][2]=1e9;
	//cout<<"fa "<<l<<" "<<r<<endl;
	//for (int i=0;i<=len;i++) cout<<A[i]<<" "; cout<<endl;
	f[0][0]=0;
	//f[i][1] remain one to right
	//f[i][2] get one from right
	//f[i][0] nothing
	for (int i=1;i<=len;i++){
		f[i][1]=min(f[i-1][1]+1,f[i-1][0]+A[i]-1);
		if (A[i]>1) f[i][1]=min(f[i][1],f[i-1][2]+A[i]-2);
		f[i][0]=min(f[i-1][1]+1,f[i-1][0]+A[i]);
		f[i][0]=min(f[i][0],f[i-1][2]+A[i]-1);
		f[i][2]=min(f[i-1][1]+2,f[i-1][0]+1);
		f[i][2]=min(f[i][2],f[i-1][2]+1);
		//cout<<f[i][0]<<" "<<f[i][1]<<" "<<f[i][2]<<endl;
	}
	int tot=0;
	for (int i=1;i<=len;i++) tot+=A[i];
	return tot-f[len][0];
}
int main(){
	scanf("%d",&n);
	scanf("%s",ch+1);
	int pre=1; ch[0]='0'; ch[n+1]='0'; ch[n+2]='0'; int ans=0;
	for (int i=1;i<=n+2;i++)
		if (ch[i]=='0'&&ch[i-1]=='0') ans+=solve(pre,i-2),pre=i+1;
	cout<<ans<<endl; return 0;
}

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

#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

int dp[3030][3030];
string s,t;
int n,m;

int main(){
    ios::sync_with_stdio(0);
    cin >> s >> t;n = s.size(),m = t.size();
    for(int i = n-1;i>=0;i--)
        for(int j = m-1;j>=0;j--)
            dp[i][j] = max({(s[i] == t[j]?dp[i+1][j+1]+1:(int)-1e9),dp[i+1][j],dp[i][j+1]});
    int i=0,j=0;
    while(i<n&&j<m){
        if(s[i] == t[j] && dp[i][j] == dp[i+1][j+1]+1){
            cout << s[i];
            i++,j++;
        }
        else{
            if(dp[i][j] == dp[i+1][j])
                i++;
            else
                j++;
        }
    }
    return 0;
}


Measured memory_bytes: 35840
#include<bits/stdc++.h>
#define pb push_back
#define gc getchar 
using namespace std;
const int N=105;
typedef long long ll;
typedef double db;

int n,u[N*N],v[N*N],cnt;

char cp;
template<class T>inline void rd(T &x)
{
	cp=gc();x=0;int f=0;
	for(;!isdigit(cp);cp=gc()) if(cp=='-') f=1;
	for(;isdigit(cp);cp=gc()) x=x*10+(cp^48);
	if(f) x=-x;
}

int main(){
	int i,j,k,x,y,lim;
    rd(n);lim=(n&1)?n:(n+1);
	for(i=1;i<=n;++i)
	 for(j=i+1;j<=n;++j) if((i+j)^lim)
	  {u[++cnt]=i;v[cnt]=j;}
    printf("%d\n",cnt);
    for(i=1;i<=cnt;++i)
     printf("%d %d\n",u[i],v[i]);
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#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() {
    string s;
    cin >> s;

    if (s.at(0)!='A') {
        cout << "WA" << endl;
        return 0;
    }

    string sbuff=s.substr(2, s.size()-3);
    int pos;
    if (sbuff.find("C")==string::npos) {
        cout << "WA" << endl;
        return 0;
    } else {
        pos=s.find("C");
    }

    for (int i=1; i<(int)s.size(); ++i) {
        if (i==pos) continue;
        if (isupper(s.at(i))) {
            cout << "WA" << endl;
            return 0;
        }
    }

    cout << "AC" << endl;
    return 0;
}

Measured memory_bytes: 3612
import sys
from collections import deque

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

N, *A = map(int, read().split())

A.sort(reverse=True)

deq = deque([A[0]])
ans = 0
for x in A[1:]:
    ans += deq.popleft()
    deq.append(x)
    deq.append(x)

print(ans)

Measured memory_bytes: 29440
/**********************************************************/
/**            Bismillahir-rahmanir-rahim                **/
/**  In the name of Allah, the Beneficent, the Merciful. **/
/**********************************************************/
/**@author: Sayed Sohan*/
/**status : */
/**url: */
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp> // Common file
//#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
using namespace std;
typedef long long  ll;
typedef unsigned long long ull;
#define FOR(i,x,n) for(ll i=(x);i<(n);i++)
#define IFOR(i,n,x) for(ll i=(n-1);i>=(x);i--)
#define REP(i,n) for(ll i=0;i<n;i++)
#define IREP(i,n) for(ll i = n-1;i>=0;i--)
#define cas(c,x)  cout<<"Case "<<c++<<": "<<x<<NL;
#define clr(arr,value) memset(arr,value,sizeof(arr))
#define MOD 1000000007
#define PI acos(-1.0)
#define rtod 180/PI
#define DIF if(0)
#define PB push_back
#define MP make_pair
#define SP " "
#define NL "\n"
#define DE cout<<"HERE"<<endl;
#define F first
#define S second
#define INF 1e18
#define Pause system("pause")
#define __FAST_IO ios_base::sync_with_stdio(0);
#define clr2V(x,sz) for(int iii=0;iii<=sz;iii++) x[iii].clear();
#define NUM1(x) __builtin_popcount(x)
#define MAX 100010/** can increase another 0 */

//** your code goes from here



int main()
{
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    __FAST_IO;
    ll i,j,k,arr[MAX],l,m,n,x,y,coun,sum,ans,T,check;
    vector<ll> v;
    string s;
	
   cin>>n>>m;
  if(n==m) cout<<"Yes"<<NL;
  else cout<<"No"<<NL;



    return 0;
}


Measured memory_bytes: 256