akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
using namespace std;

int main()
{
	int n;
	cin >> n;
	int a[n];
	int snd, fst;
	snd = fst = 0;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		if (a[i] >= fst){
			snd = fst;
			fst = a[i];
		} else if (a[i] >= snd){
			snd = a[i];
		}
	}

	for (int i = 0; i < n; i++){
		if (a[i] == fst) cout << snd << endl;
		else cout << fst << endl;
	}
}


Measured memory_bytes: 2432
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end())
#define VRSORT(v) sort(v.rbegin(), v.rend())//vectorの降順ソート
#define ll long long
#define pb(a) push_back(a)
#define INF 1000000000
#define MOD 1000000007
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

typedef vector<unsigned int>vec;
typedef vector<vec> mat;
//typedef tuple<ll, ll, ll> T;

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


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

const int MAX = 510000;
long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void comb_init() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long comb(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

//繰り返し二乗法 O(logN)
ll mod_pow(ll x, ll n, ll mod){
    ll res = 1;
    while(n > 0){
        if(n & 1) res = res * x % mod;//最下位ビットが立っているときにx^(2^i)をかける
        x = x * x % mod; //xを順次二乗していく
        n >>= 1;
    }
    return res;
}

//逆元を求める(フェルマーの小定理)X^(p-1)≡1 <=> X^(-1) ≡ X^(p-2) p:素数
ll mod_inv(ll x) {
    return mod_pow(x,MOD-2,MOD);
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int H,W,A,B;
    cin>>H>>W>>A>>B;
    comb_init();
    ll N=H+W;
    
    ll ans = 0;
    REP(i,H-A){
        ans += (comb(B-1+i,B-1)*comb(W-1-B+H-1-i,W-1-B));
        ans %= MOD;
    }
    cout<<ans<<endl;

}

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

struct UnionFind
{
    vector<int> par, rank, sz;
    UnionFind(int N) : par(N), rank(N), sz(N)
    {
        REP(i, N)
        {
            par[i] = i;  //the parent of the node
            rank[i] = 0; //the rank of the tree
            sz[i] = 1;
        }
    }
    int find(int x)
    { //Find the root of x
        if (par[x] == x)
        {
            return x;
        }
        else
        {
            return par[x] = find(par[x]);
        }
    }
    int size(int x)
    {
        return sz[find(x)];
    }
    void unite(int x, int y)
    { //Unite (the set of x) and (the set of y)
        x = find(x), y = find(y);
        if (x == y)
            return;
        if (rank[x] < rank[y])
        { //larger rank is above
            sz[y] += sz[x];
            par[x] = y;
        }
        else
        {
            sz[x] += sz[y];
            par[y] = x;
            if (rank[x] == rank[y])
                rank[x]++;
        }
    }
    bool same(int x, int y)
    {
        return find(x) == find(y);
    }
};


void solve() {
    ll n,m;
    cin >> n >> m;
    UnionFind uf(n);
    REP(i,m) {
        int a,b;
        cin >> a >> b;
        --a;--b;
        uf.unite(a,b);
    }
    set<int> se;
    REP(i,n) {
        se.insert(uf.find(i));
    }
    cout << (ll)se.size() - 1 << endl;
}


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



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

int main(){
  
  int H, W;
  cin >> H >> W;
  vector<string> maze(H);
  for(int i = 0; i < H; i++) {
    cin >> maze[i];
  }
  
  vector<int> dx = {1, -1, 0, 0};
  vector<int> dy = {0, 0, 1, -1};
  
  int ans = 0;
  
  for (int sx = 0; sx < H; sx++) {
    for (int sy = 0; sy < W; sy++) {
      
      if (maze[sx][sy] == '#') continue;
      else {
        
        vector<vector<int>> d(H, vector<int>(W, -1));
        d[sx][sy] = 0;
        
        queue<pair<int, int>> q;
        q.push({sx, sy});
        
        while (!q.empty()) {
          
          pair<int, int> p;
          p = q.front();
          q.pop();
          
          int x = p.first;
          int y = p.second;
          
          for (int i = 0; i < 4; i++) {
            
            int nx = x + dx[i];
            int ny = y + dy[i];
            
            if (nx < 0 || nx >= H || ny < 0 || ny >= W) continue;
            if (maze[nx][ny] == '#') continue;
            if (d[nx][ny] >= 0) continue;
            
            d[nx][ny] = d[x][y] + 1;
            q.push({nx, ny});
            
            if (d[nx][ny] > ans) ans = d[nx][ny];
            
          }
          
        }
      }
      
    }
  }
  
  cout << ans << endl;
  
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)

typedef long long ll;

int main(void) {
  int x;
  while(~scanf("%d", &x)) {
    ll c = 0;
    for(int i = 1; ; ++i) {
      c += i;
      if(x <= c) {
        printf("%d\n", i);
        break;
      }
    }
  }
  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<T> vt;

const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};
mint dp[1001][1001] = {0};
char g[1001][1001];

int main() {
  int h, w;
  cin >> h >> w;
  vector<string> g(h+1);

  rep(ih,h){
    cin >> g[ih];
  }
  dp[0][0] = 1;
  rep(ih,h)rep(jw,w){
    if(g[ih][jw+1] == '.')
    dp[ih][jw+1] += dp[ih][jw];

    if(g[ih+1][jw] == '.') 
    dp[ih+1][jw] += dp[ih][jw];

  }
  cout<<dp[h-1][w-1].x<<endl;
  return 0;
}

Measured memory_bytes: 9088
#include <bits/stdc++.h>
using namespace std;
#define watch(x) cout << (#x) << " is " << (x) << '\n'
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> pi;
typedef pair<ll, ll> pll;
typedef double db;
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a; }
//head

void solve(){
    int w, h, n;
    cin >> w >> h >> n;
    vector<vector<int>> seq(n);
    int d, b, c;
    for (int i = 0; i < n; i++){
        cin >> d >> b >> c;
        seq[i].push_back(d);
        seq[i].push_back(b);
        seq[i].push_back(c);
    }

    int lx = 0, rx = w;
    int ly = 0, ry = h;

    int x, y, a;
    for (int i = 0; i < n; i++){
        x = seq[i][0];
        y = seq[i][1];
        a = seq[i][2];
        if (a == 1){
            lx = max(lx, x);
        }
        else if (a == 2){
            rx = min(rx, x);
        }
        else if (a == 3){
            ly = max(ly, y);
        }
        else if (a == 4){
            ry = min(ry, y);
        }
    }
    int s1 = (rx-lx);
    int s2 = (ry-ly);
    int ans = s1*s2;
    if (s1 <= 0 || s2 <= 0) ans = 0;
    cout << ans << '\n';
}

int main(void){ 
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);

    //int t; cin >> t; while (t--)
        solve();
}


Measured memory_bytes: 3604
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ

		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();
		int[] V = new int[N];
		int[] C = new int[N];
		int[] d = new int[N];
		int sum = 0;

		for(int i=0; i<N ; i++) {
			V[i] = sc.nextInt();
		}

		//System.out.println(N);
		//System.out.println(V[0]+" "+V[N-1]);

		for(int i=0; i<N ; i++) {
			C[i] = sc.nextInt();
		}

		//System.out.println(sum);
		//System.out.println(C[0]+" "+C[N-1]);

		for(int i=0; i<N ; i++) {
			int di = V[i] - C[i];
			if(di > 0) {
				d[i] = di;
			}else {
				d[i] = 0;
			}
		}

		for(int i=0; i<N; i++) {
			sum += d[i];
		}

		System.out.println(sum);


	}

}


Measured memory_bytes: 20948
IDENTIFICATION DIVISION.
       PROGRAM-ID. test1.
       ENVIRONMENT DIVISION.
       DATA DIVISION.
       WORKING-STORAGE SECTION.
       01 A PIC 99.
       01 B PIC 99.
       01 C PIC 99.
       01 X PIC 99999.
       01 RE PIC 99999.
       01 REN PIC ZZZZ9.
       01 temp1 PIC 99999.
       01 S PIC 99.
       01 T PIC 99.
       01 U PIC 99.
       PROCEDURE DIVISION.
       MAIN.
      	ACCEPT A.
      	ACCEPT B.
      	ACCEPT C.
      	ACCEPT X.
      	ADD 1 TO A.
      	ADD 1 TO B.
     	ADD 1 TO C.
      	MOVE 0 TO RE.
      	PERFORM VARYING S FROM 0 BY 1 UNTIL S = A
      		PERFORM VARYING T FROM 0 BY 1 UNTIL T = B
      			PERFORM VARYING U FROM 0 BY 1 UNTIL U = C
      				COMPUTE temp1 = S * 500
      				COMPUTE temp1 = temp1 + T * 100
      				COMPUTE temp1 = temp1 + U * 50
      				IF temp1 = X THEN
      					ADD 1 TO RE
      				END-IF
      			END-PERFORM
      		END-PERFORM
      	END-PERFORM.
      	MOVE RE TO REN.
      	DISPLAY REN.
        STOP RUN.





Measured memory_bytes: 384
package main

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

func main() {
	var n int
	fmt.Scan(&n)

	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	x := make([]int, n)
	for i := range x {
		sc.Scan()
		x[i], _ = strconv.Atoi(sc.Text())
	}

	sx := make([]int, len(x))
	copy(sx, x)
	sort.Ints(sx)

	lm, rm := sx[len(sx)/2-1], sx[len(sx)/2]
	wr := bufio.NewWriter(os.Stdout)
	for _, v := range x {
		if v <= lm {
			wr.WriteString(strconv.Itoa(rm) + "\n")
		} else {
			wr.WriteString(strconv.Itoa(lm) + "\n")
		}
	}
	wr.Flush()
}


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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N;
string S;
void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N>>S;
	if(N%2==0) {
		if(S.substr(0,N/2)==S.substr(N/2)) {
			return _P("Yes\n");
		}
	}
	return _P("No\n");
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#ifdef BUG
    #include "debug.hpp"
#else
    #define DEBUG(var)
#endif

using namespace std;
template< class T1, class T2 > inline istream &
operator>>( istream & fin, pair< T1, T2 > & pr )
{ fin >> pr.first >> pr.second; return fin; }
template< class T0, class T1, class T2 > inline istream &
operator>>( istream & fin, tuple< T0, T1, T2 > & t )
{ fin >> get<0>(t) >> get<1>(t) >> get<2>(t); return fin; }
template< class T > inline istream &
operator>>( istream & fin, vector< T > & a ) {
for(auto & u: a) fin >> u; return fin; }
template<class T, size_t n> inline istream &
operator>>( istream & fin, array<T, n> & a ) {
for(auto & u: a) fin >> u; return fin; }
template<class FwdIter> inline auto
dump(FwdIter first, FwdIter last, const char * dlm = " ") -> void {
typedef typename iterator_traits<FwdIter>::value_type value_type;
copy(first, last, ostream_iterator<value_type>(cout, dlm)); }
template<typename T> vector<T> & operator--(vector<T> & a)
{ for(auto & i: a) --i; return a; }
/* @@@ ----------------------------------- */


int main(const int argc, char * argv [])
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

    string str;
    cin >> str;
    const auto size = str.size();
    size_t i;

    for(i = 0 ; i < size ; ++i)
        if(str[i] == 'C') break;

    size_t j;
    for(j = i + 1; j < size; ++ j)
        if(str[j] == 'F') break;


    cout << (i < size && j < size ? "Yes" : "No") << '\n';

    return EXIT_SUCCESS;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <cstdlib>
#include <cmath>
#include <algorithm>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using Graph= vector<vector<ll>>;
struct edge{ll to ; ll cost ;} ;
using graph =vector<vector<edge>> ;
#define rep(i,n) for (ll i=0; i < (n); ++i)
#define rep2(i,n,m) for(ll i=n;i<=m;i++)
#define rep3(i,n,m) for(ll i=n;i>=m;i--)
#define pb push_back
#define eb emplace_back
#define ppb pop_back
#define mpa make_pair
#define fi first
#define se second 
#define set20 cout<<fixed<<setprecision(20) ;
const ll INF=1e18 ;
inline void chmax(ll& a,ll b){a=max(a,b);}
inline void chmin(ll& a,ll b){a=min(a,b);}
double pi=acos(-1) ;
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}
 

 int main(){
  ll n ; cin>>n ;
  vector<ll> A(n) ;
  rep(i,n) cin>>A[i] ;
  vector<ll> B(n),C(n) ;
  rep(i,n){
    if(i==0){
      B[i]=A[i] ;
      C[i]=A[n-1-i] ;
    }
    else{
      B[i]=gcd(B[i-1],A[i]) ;
      C[i]=gcd(C[i-1],A[n-1-i]) ;
    }
  }
  ll ans=0 ;
  rep(i,n){
    ll now=0 ;
    if(i==0) now=C[n-2] ;
    else if(i==n-1) now= B[n-2] ;
    else now= gcd(B[i-1],C[n-2-i]) ;
    chmax(ans,now) ;
  }
  cout<<ans<<endl ;
   return 0 ;
}



Measured memory_bytes: 5540
#include <bits/stdc++.h>
 
using namespace std;
typedef long long ll;
typedef vector<int> VI;
ll mm=1000000000;ll MM=mm+7;
#define rep(i, n) for(int i=0;i<n;i++)
#define PI 3.141592653589793

int main(){
 int n;
 cin >> n;
 VI a(n);
 rep(i,n)cin >> a.at(i);
 int ans=__gcd(a.at(0),a.at(1));
 for(int i=2;i<n;i++){
   ans=__gcd(ans,a.at(i));
 }
 cout << ans << endl;
}


Measured memory_bytes: 3748
#include<cstdio>
#include<queue>
#include<utility>
#include<cstring>
#include<stack>
#include<algorithm>
#include<cmath>
#include<iostream>
#include<map>
#define MAX_N 100001
#define INF_INT 2147483647
#define INF_LL 9223372036854775807
#define REP(i,n) for(int i=0;i<(int)(n);i++)
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> P;
void init(int n);
int find(int n);
void unite(int x,int y);
bool same(int x, int y);
ll bpow(ll,ll,ll);
typedef vector<int> vec;
typedef vector<vec> mat;
mat mul(mat &A,mat &B);
mat pow(mat A,ll n);
int dx[4] = {1,0,0,-1};
int dy[4] = {0,1,-1,0};


bool cmp_P(const P &a,const P &b){
  return a.second < b.second;
}
int main()
{
  int x1,x2,y1,y2,S,vx,vy,tmp;
  cin >> x1 >> y1 >> x2 >> y2;
  vx = x2-x1;
  vy = y2-y1;
  tmp = vx;
  vx = -vy;
  vy = tmp;
  printf("%d %d %d %d\n",x2+vx,y2+vy,x1+vx,y1+vy);
  return 0;
}

int par[MAX_N];
int ranks[MAX_N];

//n要素で初期化
void init(int n){
  REP(i,n){
    par[i] = i;
    ranks[i] = 0;
  }

}

//木の根を求める
int find(int x){
  if(par[x] == x){
    return x;
  }else{
    return par[x] = find(par[x]);
  }
}

void unite(int x,int y){
  x = find(x);
  y = find(y);
  if(x == y) return ;
  if(ranks[x] < ranks[y]){
    par[x] = y;
  }else{
    par[y] = x;
    if(ranks[x] == ranks[y]) ranks[x]++;
  }
}

bool same(int x, int y){
  return find(x) == find(y);
}

ll bpow(ll a, ll n,ll mod){
  int i = 0;
  ll res=1;
  while(n){
    if(n & 1)
      res = (res*a) % mod;
    a = (a*a) % mod;
    n >>= 1;
  }
  return res;
}
const int MOD = 1000000007;
mat mul(mat &A, mat &B){
  mat C(A.size(),vec(B[0].size()));
    REP(i,A.size())REP(k,B.size())REP(j,B[0].size()){
    C[i][j] = (C[i][j] + A[i][k] * B[k][j]) % MOD;
  }
  return C;
}

mat pow(mat A,ll n)
{
  mat B(A.size(),vec(A.size()));
  REP(i,A.size()){
    B[i][i] = 1;
  }
  while(n > 0){
    if ( n & 1) B = mul(B,A);
    A = mul(A,A);
    n >>= 1;
  }
  return B;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define MOD 1000000007

int main(){
  int a,b,c,d,e,f;
  cin>>a>>b>>c>>d>>e>>f;
  a*=100;
  b*=100;
  bool dp1[3001]={},dp2[3001]={};
  dp1[0]=1, dp2[0]=1;
  for(int i=0;i<=3000;i++){
    if(i>=a){
      if(dp1[i-a]) dp1[i]=1;
      if(i>=b){
        if(dp1[i-b]) dp1[i]=1;
      }
    }
    if(i>=c){
      if(dp2[i-c]){
        dp2[i]=1;
      }
      if(i>=d){
        if(dp2[i-d]){
          dp2[i]=1;
        } 
      }
    }
  }
  int X=0, Y=a;
  for(int i=0;i<=f;i++){
    if(!dp1[i]) continue;
    for(int j=0;j<=f;j++){
      if(!dp2[j]) continue;
      if(i+j>f) break;
      if(100*j<=e*i){
        if(j*Y>X*(i+j)){
          X=j;
          Y=i+j;
          //cout<<Y<<" "<<X<<endl;
        }
      }
    }
  }
  cout<<Y<<" "<<X<<endl;
  return 0;
}

Measured memory_bytes: 256
class BipartiteGraph(object):
    
    def __init__(self, num_nodes):
        self.graph = [[] for _ in range(num_nodes)] # ??°???????????£??\???????????¨???
        self.match = [None] * num_nodes # ??????????????°????????¢

    def add_edge(self, u, v):
        self.graph[u].append(v)
        self.graph[v].append(u)

    def has_increasing_path(self, v, used):
        used[v] = True
        for i, u in enumerate(self.graph[v]):
            w = self.match[u]
            if w is None or (not used[w] and self.has_increasing_path(w, used)):
                self.match[v] = u
                self.match[u] = v
                return True
        return False

    def __str__(self):
        ret = ["graph bipartite_graph {"]
        for v, g in enumerate(self.graph):
            for u in g:
                ret.append("    {} -- {};".format(v, u))
        # ret.append("    rank = source; {};"
        ret.append("}")
        return "\n".join(ret)
        

    def solve(self):
        ret = 0
        for v in range(len(self.graph)):
            if self.match[v] is not None:
                continue
            if self.has_increasing_path(v, [False]*len(self.graph)):
                ret += 1
        return ret

if __name__ == "__main__":
    X, Y, E = list(map(int, input().split()))
    bg = BipartiteGraph(X+Y)
    for _ in range(E):
        x, y = list(map(int, input().split()))
        y += X
        bg.add_edge(x, y)
    print(bg.solve())

Measured memory_bytes: 8016
#include<bits/stdc++.h>
using namespace std;
#define IL inline
#define rep(i,j,k) for(int i=j;i<=k;++i)
#define repd(i,j,k) for(int i=j;i>=k;--i)
#define pb push_back
#define db double
#define mp make_pair
#define mp3(a,b,c) mp(mp(a,b),c)
#define pii pair<int,int>
#define piii pair<pii,int>
#define fr first
#define se second
#define ll long long
#define ull unsigned long long
#define pbc(x) __builtin_popcount(x)
#define clr(x) memset(x,0,sizeof x)
#define SIZE(x) (int)(x.size())
const int mod=1e9+7;
IL int pls(int x,int y){x+=y;return x>=mod?x-mod:x;}
IL int dec(int x,int y){x-=y;return x<0?x+mod:x;}
IL int mul(int x,int y){return 1ll*x*y%mod;}
IL int mul(int x,int y,int z){return mul(mul(x,y),z);}
IL int mul(int x,int y,int z,int p){return mul(mul(x,y),mul(z,p));}
IL void add(int &x,int y){x+=y;x=(x>=mod)?x-mod:x;}
IL int fpw(int x,int y,int r=1){for(;y;y>>=1,x=mul(x,x))if(y&1)r=mul(r,x);return r;}
IL int inv(int x){return fpw(x,mod-2);}
IL int gi(){int x;int _w=scanf("%d",&x);return x;}
IL void gi(int &x){int _w=scanf("%d",&x);}
IL void write(int x){printf("%d\n",x);}
void chkmax(int &x,int y){x=(x>y)?x:y;}
void chkmin(int &x,int y){x=(x<y)?x:y;}
const int INF=0x3f3f3f3f;
template<typename T>IL void debug(T x){cerr<<x;return;}
/* --------------------------------------------------------------------------------------------------------- */
const int maxn=2005;
int n,k;
vector<int>e[maxn];
namespace sub1{
	int dep[maxn];
	IL bool check(){
		return (!(k&1));
	}
	void dfs(int x,int fa){
		for(int v:e[x])if(v!=fa)dep[v]=dep[x]+1,dfs(v,x);
	}
	IL void work(){
		int ans=n;
		rep(i,1,n){
			rep(j,1,n)dep[j]=0;
			dfs(i,0);
			int del=0;
			rep(j,1,n){
				if(dep[j]>k/2)del++;
			}
			ans=min(ans,del);
		}
		printf("%d\n",ans);
	}
}
namespace sub2{
	pii edge[maxn];
	int dep[maxn];
	IL bool check(){
		return k&1;
	}
	void dfs(int x,int fa){
		for(int v:e[x])if(v!=fa)dep[v]=dep[x]+1,dfs(v,x);
	}
	IL void work(){
		int ans=n;
		rep(i,1,n-1){
			int del=0;
			rep(j,1,n)dep[j]=0;
			dfs(edge[i].fr,edge[i].se);
			dfs(edge[i].se,edge[i].fr);
			rep(j,1,n)if(dep[j]>k/2)del++;
			ans=min(ans,del);
		}
		printf("%d\n",ans);
	}
}
int main(){
#ifdef LOCAL
	freopen("/home/noilinux/Desktop/input.txt","r",stdin);
#endif
	n=gi(),k=gi();
	rep(i,1,n-1){
		int x=gi(),y=gi();
		e[x].pb(y);e[y].pb(x);
		sub2::edge[i]={x,y};
	}
	if(sub1::check())sub1::work();else sub2::work();
	return 0;
}

Measured memory_bytes: 512
from collections import defaultdict
      
class Combinatorics:
    def __init__(self, N, mod):
        '''
        Preprocess for calculating binomial coefficients nCr (0 <= r <= n, 0 <= n <= N)
        over the finite field Z/(mod)Z.
        Input:
            N (int): maximum n
            mod (int): a prime number. The order of the field Z/(mod)Z over which nCr is calculated.
        '''
        self.mod = mod
        self.fact = {i: None for i in range(N+1)}         # n!
        self.inverse = {i: None for i in range(1, N+1)}   # inverse of n in the field Z/(MOD)Z
        self.fact_inverse = {i: None for i in range(N+1)} # inverse of n! in the field Z/(MOD)Z
         
        # preprocess
        self.fact[0] = self.fact[1] = 1
        self.fact_inverse[0] = self.fact_inverse[1] = 1
        self.inverse[1] = 1
        for i in range(2, N+1):
            self.fact[i] = i * self.fact[i-1] % self.mod
            q, r = divmod(self.mod, i)
            self.inverse[i] = (- (q % self.mod) * self.inverse[r]) % self.mod
            self.fact_inverse[i] = self.inverse[i] * self.fact_inverse[i-1] % self.mod
             
    def perm(self, n, r):
        '''
        Calculate nPr = n! / (n-r)! % mod
        '''
        if n < r or n < 0 or r < 0:
            return 0
        else:
            return (self.fact[n] * self.fact_inverse[n-r]) % self.mod
        
    def binom(self, n, r):
        '''
        Calculate nCr = n! /(r! (n-r)!) % mod
        '''
        if n < r or n < 0 or r < 0:
            return 0
        else:
            return self.fact[n] * (self.fact_inverse[r] * self.fact_inverse[n-r] % self.mod) % self.mod
    
    def hom(self, n, r):
        '''
        Calculate nHr = {n+r-1}Cr % mod.
        Assign r objects to one of n classes.
        Arrangement of r circles and n-1 partitions:
            o o o | o o | | | o | | | o o | | o
        '''
        if n == 0 and r > 0:
            return 0
        if n >= 0 and r == 0:
            return 1
        return self.binom(n + r - 1, r)

def Bell_num(n, k, mod):
    com = Combinatorics(k, mod)
    temp = [1]
    for i in range(1, k+1):
        temp.append((temp[-1] + ((-1)**i * com.fact_inverse[i]) % mod) % mod)
    ans = 0
    for i in range(k+1):
        ans = (ans + (((pow(i, n, mod) * com.fact_inverse[i]) % mod)* temp[k-i]) % mod) % mod
    return ans
    
N, K = map(int, input().split())
MOD = 10**9 + 7
ans = Bell_num(N, K, MOD)
print(ans)


Measured memory_bytes: 6296
import bisect
 
n = int(input())
a = [int(input()) for _ in range(n)]
# それぞれの色の最大値を入れる筒のリスト
t = [a[-1]]
 
for i in reversed(a[:-1]):
    # それぞれの色のどの値よりも小さかったとき
    idx = bisect.bisect_left(t, i+1)
    # print(i, idx)
    if idx == len(t):
        t.append(i)
    # 効率的な色の探索
    else:
        t[idx] = i
    # print(t)
 
print(len(t))

Measured memory_bytes: 8604
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define watch(x) cout <<(#x)<<" is "<<(x)<<endl
#define debug cout <<"hi"<<endl
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
const int MOD=1e9+7;
const int INF32=1<<30;
const ll INF64=1LL<<60;

int main(){
  int n; cin >>n;
  vector<int>p(n); int cnt=0;
  for(int i=0; i<n; i++) cin >>p[i];
  for(int i=0; i<n; i++) if(p[i]-i-1) cnt++;
  if(cnt<=2) cout <<"YES";
  else cout <<"NO";
return 0;}

Measured memory_bytes: 3596
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<vector>
#include<set>
#include<map>
#include<stdlib.h>

using namespace std;

#define x first
#define y second
#define NMAX 100005

int n, v[NMAX], boss, ord[NMAX];
long long amount, answer[NMAX], people;

inline int cmp(const int& a, const int& b){
    if(v[a] == v[b])
        return a < b;
    return v[a] > v[b];
}

int main (){

    scanf("%d",&n);
    for(int i = 1; i <= n; i++){
        scanf("%d",&v[i]);
        ord[i] = i;
    }
    sort(ord + 1, ord + n + 1, cmp);
    boss = ord[1];
    amount = v[boss];
    people = 1;
    for(int i = 2; i <= n; i++){
        answer[boss] += (amount - v[ord[i]]) * people;
        if(ord[i] < boss){
            boss = ord[i];
        }
        amount = v[ord[i]];
        people++;
    }
    answer[boss] += amount * people;
    for(int i = 1; i <= n; i++)
        printf("%lld\n", answer[i]);
    
    return 0;
}



Measured memory_bytes: 2560
#include <stdio.h>

int main(void)
{
	int x1,x2,a;
	scanf("%d",&x1);
	scanf("%d",&x2);
	if(x2>x1){
		a=x2-x1;
	}else{
		a=x1-x2;
	}
	printf("%d\n",a);
	return 0;
}


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

int T[17][17];//????????????,?£????
int DP[1<<16];//??????

int main(){
    int N;
    while(cin>>N,N){
        for(int i=0;i<N;i++){
            for(int j=0;j<=N;j++){
                cin>>T[i][j];
            }
        }
        fill(DP,DP+(1<<N),10000000);
        DP[0]=0;
        for(int b=0;b<(1<<N);b++){
            int t[16];
            for(int i=0;i<N;i++) t[i]=T[i][0];
            for(int i=0;i<N;i++){
                if(b&(1<<i))
                for(int s=0;s<N;s++) t[s]=min(t[s],T[s][i+1]);
            }
            for(int i=0;i<N;i++){
                if(b&(1<<i)) continue;
                DP[b^(1<<i)]=min(DP[b^(1<<i)],DP[b]+t[i]);
            }
        }
        cout<<DP[(1<<N)-1]<<endl;
    }

    return 0;
}

Measured memory_bytes: 3344
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)
 
# 遅延評価で加えてあげるだけ
 
N,Q = map(int,input().split())
ab = [[int(x) for x in input().split()] for _ in range(N-1)]
px = [[int(x) for x in input().split()] for _ in range(Q)]

graph = [[] for _ in range(N+1)]
for a,b in ab:
    graph[a].append(b)
    graph[b].append(a)
 
value = [0] * (N+1)
for p,x in px:
    value[p] += x
    
q = [(1,0)]
while q:
    x,parent = q.pop()
    value[x] += value[parent]
    for y in graph[x]:
        if y == parent:
            continue
        q.append((y,x))
 
answer = ' '.join(map(str,value[1:]))
print(answer)

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

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

    if(S == "Sunny") {
        cout << "Cloudy" << endl;
    } else if(S == "Cloudy") {
        cout << "Rainy" << endl;
    } else if(S == "Rainy") {
        cout << "Sunny" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
// #define int long long
#define ff first
#define ss second
#define endl "\n"
#define all(x) (x).begin(), (x).end()
#define PI 3.1415926535897932384626433832795
int MOD=1e9+7;
int powmod(int a,int l, int md){int res=1;while(l){if(l&1)res=res*a%md;l/=2;a=a*a%md;}return res;}
typedef long long ll; typedef vector<ll> vi; typedef pair<ll, ll> ii; typedef vector<ii> vii;
#define pb push_back
int __set(int b, int i) {return b|(1<<i);} //set ith bit
int __unset(int b, int i) {return b&!(1<<i);}
int __check(int b, int i) {return b&(1<<i);} //returns 0 if ith bit is 0
int mul(int a, int b) {return ((a%MOD)*(b%MOD))%MOD;}
int add(int a, int b) {return (a+b)%MOD;}
int sub(int a, int b) {return (((a-b)%MOD)+MOD)%MOD;}
int __div(int a, int b) {return mul(a, powmod(b, MOD-2, MOD));} //if MOD is prime;
const ll inf = 0xFFFFFFFFFFFFFFFL; //very large number
priority_queue<int, vector<int>, greater<int> > pq; //for min priority_queue
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
clock_t time_p=clock();
void time()
{
    time_p=clock()-time_p;
    cerr<<"Time Taken : "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";
}

int main(void)
{
	IOS;
	int m, d;
	cin>>m>>d;
	int st=22;
	if(d < 22) {
		cout<<0<<endl;
		return 0;
	}
	int ct=0;
	for(int i = 22; i <= d; i++) {
		int d1=i%10, d2 = ((i%100)-(i%10))/10;
		if(d1*d2 <= m && d1>=2 && d2>=2) ct++;
	}
	cout<<ct<<endl;
 	time();
	return 0;
}

Measured memory_bytes: 256
//  Created by conan1024hao in 2019.
//  Copyright © 2019 conan1024hao. All rights reserved.
//  専用ライブラリです、自由にコピーして構いません。
//  感谢看我的代码！Wechat:conan1024hao QQ:810396815
#pragma GCC optimize ("O3")
#include <iostream>
#include <iomanip>
#include <istream>
#include <ostream>
#include <sstream>
#include <iterator>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <utility>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <ctime>
#include <cctype>
#include <cstdlib>
#define INF 10e16
#define MOD 1000000007
#define rep(i, a, n) for (ll i = a; i < (ll)(n); i++)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define mmax(x,y)(x>y?x:y)
#define mmin(x,y)(x<y?x:y)
#define chmax(x,y) x=mmax(x,y)
#define chmin(x,y) x=mmin(x,y)
#define all(x) (x).begin(),(x).end()
#define siz(x) (ll)(x).size()
#define PI acos(-1.0)
using namespace std;
using Int=int_fast64_t;
typedef long long int ll;
typedef pair<ll,ll>Pll;
typedef pair<int,int>Pin;
long long GCD(long long a, long long b) { return b ? GCD(b, a%b) : a; }
long long LCM(long long a, long long b)  {return a/GCD(a,b)*b;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
ll cmp(pair<ll,string>a,pair<ll,string> b){
        if(a.fi!=b.fi)
        return a.fi<b.fi;
        else
        return a.se<b.se;
}

//---------------------------------------------------------------------------

//---------------------------------------------------------------------------
int main(){//問題をちゃんと見ろ!!!!!!!!!!!!!!!!!      llか??????????
    cin.tie(0);
    ios::sync_with_stdio(false);
    //-------------------------------
    int n,k;cin>>n>>k;
    vector<int>a(n);
    for(int i=0;i<n;i++)cin>>a[i];
    map<int,int>m;
    for(int i=0;i<n;i++)m[a[i]]++;
    vector<int>o;
    for(int i=1;i<=n;i++){
        if(m[i])
            o.pb(m[i]);
    }
    sort(all(o));
    int ans=0;
    int nm=o.size();
    int i=0;
    while(nm>k){
        ans+=o[i];
        i++;
        nm--;
    }
    cout<<ans<<endl;
    //-------------------------------
    return 0;
}
//---------------------------------------------------------------------------


Measured memory_bytes: 11640
import collections as col
from functools import reduce
from operator import add
n = int(input())

v = list(map(int, input().split()))

if len(set(v)) == 1:
    print(int(n / 2))
    exit()

odd = v[1::2]
even = v[0::2]

co = col.Counter(odd).most_common()
ce = col.Counter(even).most_common()

if co[0][0] != ce[0][0]:
    print(n - co[0][1] - ce[0][1])
else:
    # a1 = reduce(add, coli[1:], 0)
    # b1 = reduce(add, celi[2:], 0)
    # b1 = celi[0] + b1

    # a2 = reduce(add, coli[2:], 0)
    # b2 = reduce(add, celi[1:], 0)
    # a2 = a2 + coli[0]
    if len(co) <= 1:
        co.append((0, 0))
    if len(ce) <= 1:
        ce.append((0, 0))

    ans1 = n - co[1][1] - ce[0][1]
    ans2 = n - co[0][1] - ce[1][1]

    print(min(ans1, ans2))

Measured memory_bytes: 21204
// Author -> Preeyadarshee Dev
//
// train hard win easy :D
// nik is love
// nik is motivation
//
// do modulo operations very carefully
// try to avoid binary search, use linear search preferrably to make calculations easier
// always make your custom binary search and watch out for overflows
// read the problems carefully
// never rely on floating point calculation
#include <bits/stdc++.h>
#define mp                    make_pair
#define pb                    push_back
#define ll                   long long
#define ss                       second
#define ff                        first
#define fr(i,a,b)   for(ll i=a;i<b;i++)
#define f(i,n)                fr(i,0,n)
#define rf(i,b,a) for(ll i=b-1;i>=a;i--)
#define r(i,n)                rf(i,n,0)
#define inf                  1000000007
#define eps                  0.000000000000001
#define endl                       '\n'
#define sz(a)                int((a).size())
#define all(c)               (c).begin(),(c).end()
#define tr(c,i)              for(typeof(c).begin() i = (c).begin(); i != (c).end(); i++)
#define present(c,x)         ((c).find(x) != (c).end())
#define cpresent(c,x)        (find(all(c),x) != (c).end())
#define pi                   pair<int,int>
#define pll                  pair < ll , ll >
#define PI                   3.141592653589793238462643383279502884197169399375105820974944592307816406286
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
typedef vector< int > vi;
typedef vector< vi > vvi;
int dx[8]={-2,-2,1,-1,-1,-1,1,1};
int dy[8]={1,-1,-2,-2,-1,1,-1,1};

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    //ifstream fin;
    //ofstream fout;
    //fin.open("input.txt");
    //fout.open("output.txt");
    int n;
    cin>>n;
    vector<int> v(n+1,0);
    int cnt=0;
    for(int i=1;i<=n;i++)
    {
        cin>>v[i];
        if(v[i]!=i)
        {
            cnt++;
        }
    }
    if(cnt<=2)
    {
        cout<<"YES"<<endl;
    }
    else
    {
        cout<<"NO"<<endl;
    }
}


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


int main(int argc, char *argv[]) {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout << setprecision(20);

  int N; cin >> N;
  vector<int> a(N), b(N), rev(N);
  for (int i = 0; i < N; i++) {
    int p; cin >> p; p--;
    rev.at(p) = i;
  }
  a.at(0) = 1;
  b.at(0) = rev.at(0) - a.at(0);
  for (int i = 1; i < N; i++) {
    int diff = rev.at(i) - rev.at(i-1);
    if (diff > 0) {
      a.at(i) = a.at(i-1) + diff + 1;
      b.at(i) = b.at(i-1) - 1;
    }else {
      a.at(i) = a.at(i-1) + 1;
      b.at(i) = b.at(i-1) + diff - 1;
    }
  }
  int shift = 1 - b.at(N-1);
  for (int i = 0; i < N; i++) b.at(i) += shift;
  
  for (int i = 0; i < N; i++) {
    if (i > 0) cout << " ";
    cout << a.at(i);
  }
  cout << endl;
  for (int i = 0; i < N; i++) {
    if (i > 0) cout << " ";
    cout << b.at(i);
  }
  cout << endl;

  return 0;
}



Measured memory_bytes: 896
#include <iostream> 
#include<stdio.h>
using namespace std; 
  
 
int maxSum(int arr[], int n, int k) 
{ 
    if (n < k) 
    { 
       cout << "Invalid"; 
       return -1; 
    } 
  
    
    int res = 0; 
    for (int i=0; i<k; i++) 
       res += arr[i]; 
  
     
    int curr_sum = res; 
    for (int i=k; i<n; i++) 
    { 
       curr_sum += arr[i] - arr[i-k]; 
       res = max(res, curr_sum); 
    } 
  
    return res; 
} 
  
int main() 
{ 
    int n,s,i,k;
    cin>>n>>k;
    int a[n];
    for(i=0;i<n;i++)
    {
    cin>>a[i];	
	}
     s=maxSum(a, n, k); 
    float b;
	b=(s+k)/2.00000;
	printf("%.12f",b);  
    return 0; 
} 


Measured memory_bytes: 1024
#include <algorithm>
#include <atcoder/all>
#include <iostream>
#include <set>
#include <tuple>
#include <vector>

using ll = long long;
#define rep(i, j, n) for (int i = j; i < (n); ++i)
using namespace std;
using namespace atcoder;

int main() {
  int n;
  cin >> n;
  vector<tuple<int, int, int>> xy, yx;

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

    int x, y;
    cin >> x >> y;
    xy.emplace_back(x - 1, y - 1, i);
    yx.emplace_back(y - 1, x - 1, i);
  }
  sort(xy.begin(), xy.end());
  sort(yx.begin(), yx.end());
  dsu uf(n);
  set<int> st;
  rep(i, 0, n) st.insert(i); // まだ使ってないyの値

  int x1, y1, v1, x2, y2, v2;
  for (int i = 0; i < n; ++i) {
    tie(x1, y1, v1) = xy[i];
    if (y1 < *st.rbegin()) {
      int j = i + 1;
      while (j < n) {
        tie(x2, y2, v2) = xy[j];
        uf.merge(v1, v2);
        if (y1 < y2) { break; }
        st.erase(st.find(y2));
        ++j;
      }
      st.erase(st.find(y1));
      i = j - 1;
    } else
      st.erase(st.find(y1));
  }

  st.clear();
  rep(i, 0, n) st.insert(i);

  for (int i = 0; i < n; ++i) {
    tie(x1, y1, v1) = yx[i];
    if (y1 < *st.rbegin()) {
      int j = i + 1;
      while (j < n) {
        tie(x2, y2, v2) = yx[j];
        uf.merge(v1, v2);
        if (y1 < y2) { break; }
        st.erase(st.find(y2));
        ++j;
      }
      st.erase(st.find(y1));
      i = j - 1;
    } else
      st.erase(st.find(y1));
  }

  reverse(xy.begin(), xy.end());
  reverse(yx.begin(), yx.end());

  st.clear();
  rep(i, 0, n) st.insert(i);

  for (int i = 0; i < n; ++i) {
    tie(x1, y1, v1) = xy[i];
    if (y1 > *st.begin()) {
      int j = i + 1;
      while (j < n) {
        tie(x2, y2, v2) = xy[j];
        uf.merge(v1, v2);
        if (y1 > y2) { break; }
        st.erase(st.find(y2));
        ++j;
      }
      st.erase(st.find(y1));
      i = j - 1;
    } else
      st.erase(st.find(y1));
  }

  st.clear();
  rep(i, 0, n) st.insert(i);

  for (int i = 0; i < n; ++i) {
    tie(x1, y1, v1) = yx[i];
    if (y1 > *st.begin()) {
      int j = i + 1;
      while (j < n) {
        tie(x2, y2, v2) = yx[j];
        uf.merge(v1, v2);
        if (y1 > y2) { break; }
        st.erase(st.find(y2));
        ++j;
      }
      st.erase(st.find(y1));
      i = j - 1;
    } else
      st.erase(st.find(y1));
  }

  for (int i = 0; i < n; ++i) cout << uf.size(i) << '\n';

  return 0;
}


Measured memory_bytes: 18268
#define _USE_MATH_DEFINES
#include<iostream>
#include<cmath>
#include<algorithm>
#include<vector>
#include<string>
#include<cctype>
#include<iomanip>
#include<cassert>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)

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

    int x, y;
    int big, small;
    int temporary;

    cin >> x >> y;

    big = max(x, y);
    small = min(x, y);

    while(small != 0){
        temporary = big;
        big = small;
        small = temporary % small;
    }

    cout << big << '\n';

    return 0;
}


Measured memory_bytes: 3220
import sys
import numpy as np
import numba
from numba import njit, b1, i4, i8, f8

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

@njit((i8[:], ), cache=True)
def suffix_array(S):
    """ sa by doubling. O(N log^2N)"""
    N = len(S)
    SA = np.arange(N, dtype=np.int64)
    rnk = S
    tmp = np.empty(N, np.int64)
    k = 1
    while True:
        comp_key = np.empty(N, np.int64)
        for i in range(N):
            if i + k < N:
                comp_key[i] = rnk[i] << 32 | (1 + rnk[i + k])
            else:
                comp_key[i] = rnk[i] << 32
        SA = comp_key.argsort()
        rnk = np.empty(N, np.int64)
        rnk[SA[0]] = 0
        for i in range(1, N):
            rnk[SA[i]] = rnk[SA[i -
                                1]] + (comp_key[SA[i - 1]] < comp_key[SA[i]])
        k *= 2
        if k >= N:
            break
    return SA


@njit((i8[:], i8[:]), cache=True)
def lcp_array(S, SA):
    N = len(S)
    rnk = np.empty(N, np.int64)
    for i in range(N):
        rnk[SA[i]] = i
    LCP = np.empty(N - 1, np.int64)
    h = 0
    for i in range(N):
        if h:
            h -= 1
        if not rnk[i]:
            continue
        j = SA[rnk[i] - 1]
        while True:
            if S[j + h] != S[i + h]:
                break
            h += 1
            if i + h >= N or j + h >= N:
                break
        LCP[rnk[i] - 1] = h
    return LCP

def main(S):
    N = len(S)
    SA = suffix_array(S)
    LCP = lcp_array(S, SA)
    return N * (N + 1) // 2 - LCP.sum()

S = np.array(list(read().rstrip()), np.int64)

print(main(S))

Measured memory_bytes: 126084
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define PI 3.141592653589793
#define rep(i, n) for (int i = 0; i < (n); i++)
#define REP(i, a, n) for (int i = a; i < (n); i++)
#define rrep(i, n, k) for (int i = (n); i >= (k); i--);
#define all(x) (x).begin(), (x).end()
#define vi vector<int>
template<class T> istream &operator>>(istream&is,vector<T>&v){for(auto &elemnt:v)is>>elemnt;return is;}
template<class T,class U> istream &operator>>(istream&is,pair<T,U>&p){is>>p.first>>p.second;return is;}
template<class T>vector<T> make_vector(size_t a){return vector<T>(a);}
template<class T, class... Ts>auto make_vector(size_t a, Ts... ts){return vector<decltype(make_vector<T>(ts...))>(a, make_vector<T>(ts...));}
const int MOD = 1e9 + 7;
const int INF = 9e18;

signed main() {
    int N, M;
    cin >> N >> M;
    vector<vector<int>> language(M + 1);
    vector<vector<int>> people(N + 1);
    for (int i = 1; i <= N; i++) {
        int K;
        cin >> K;
        for (int j = 0; j < K; j++) {
            int L;
            cin >> L;
            language[L].push_back(i);
            people[i].push_back(L);
        }
    }
    vector<bool> check(N + 1, false);
    vector<bool> langCheck(M + 1, false);
    check[1] = true;
    stack<int> next;
    next.push(1);
    while (!next.empty()) {
        int now = next.top();
        next.pop();
        for (auto temp : people[now]) {
            if (!langCheck[temp]) {
                for (auto i : language[temp]) {
                    if(!check[i]) next.push(i);
                    check[i] = true;
                }
                langCheck[temp] = true;
            }
        }
    }
    bool ans = true;
    for (int i = 1; i <= N; i++) if(!check[i]) ans = false;
    cout << (ans ? "YES" : "NO") << endl;

}


Measured memory_bytes: 9716
#include<iostream>
#include<algorithm>
#include<climits>
#include<vector>
#include<utility>
#include<cmath>
#include<string>
#include<cstring>
#include<map>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define prin(arg) std::cout<<arg<<"\n"
#define prin2(arg1,arg2) std::cout<<arg1<<" "<<arg2<<"\n"
#define fill(arg,n) memset(arg,n,sizeof(arg))
using std::cin;
typedef long long ll;
typedef std::pair<int,int> pi;
typedef std::vector<int> vi;
const int INF=1e+9;
const ll INFLL=1e+17;
int a,b,c;
void solve(){
  if(b-a==c-b) prin("YES");
  else prin("NO");
}
int main(){
  cin>>a>>b>>c;
  solve();
  return 0;
}


Measured memory_bytes: 256
package main

import (
	"fmt"
	"strconv"
)

func main() {
	var a, b string
	fmt.Scan(&a, &b)
	num, _ := strconv.Atoi(a + b)

	for i := 1; i <= num; i++ {
		if i*i == num {
			fmt.Println("Yes")
			return
		}
	}
	fmt.Println("No")
}


Measured memory_bytes: 512
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

c=array(3)
3.times do|i|
    c[i]=get_i
end
flag=true
-100.upto(100) do|a|
  b=[c[0][0]-a,c[0][1]-a,c[0][2]-a]
  flag=true
  1.upto(2) do|i|
      unless c[i][0]-b[0]==c[i][1]-b[1] and c[i][1]-b[1]==c[i][2]-b[2]
        flag=false 
      end
  end
end
puts yn_judge(flag)

Measured memory_bytes: 1788
#include <iostream>
#include <math.h>
#include <string>
#include <string.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <stdlib.h>
#include <deque>  
#include <iomanip>

using namespace std;

int main(){
    int A,B,C,D;
    cin>>A>>B>>C>>D;
    cout<<max(A*B,C*D)<<endl;
    return 0;
}

Measured memory_bytes: 768
//#include<bits/stdc++.h>
#include<iostream>
#include<cmath>
#include<cstdio>
#include<vector>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<utility>
#include<algorithm>
#include<cstring>
#include<sstream>
#include <iomanip>

using namespace std;

typedef long long ll ;
typedef double db;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector< pair<int,int> > vii;
const double pi = 2*acos(0) ;

#define pf		  	printf
#define sf			  scanf
#define pb(a)         push_back(a)
#define mp			make_pair
#define fr			 first
#define sc			 second
#define for0(i,n)        for(int i=0;i<n;i++)
#define for1(i,n)        for(int i=1;i<=n;i++)
#define forab(i,a,b)       for(int i=a;i<=b;i++)
#define lcm(a, b)     ((a)*((b)/gcd(a,b)))
#define sq(a)		   (a)*(a)
#define nw				"\n"
#define abs(x)		fabs(x)
#define pcase(z,x)    cout<<"Case "<<z<<": "<<x<<"\n"

int main()
{
	int n,r;
	cin>>n;
	r = n%10;
	if(r==0 || r==1 || r==6 || r==8) cout<<"pon\n";
	else if(r==3) cout<<"bon\n�";
	else cout<<"hon\n";
	return 0;
}

Measured memory_bytes: 3596