akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<iomanip>
#include<map>
#include<unordered_map>
#include<set>
#include<unordered_set>
#include<vector>
#include<array>
#include<string>
#include<stack>
#include<queue>
#include<algorithm>
#include<cassert>
#include<functional>
#include<random>
#include<complex>
#include<bitset>
#include<chrono>
//#include<boost/multiprecision/cpp_int.hpp>
#define int int64_t
#define uint uint64_t
#define REP(i, a, b) for (int64_t i = (int64_t)(a); i < (int64_t)(b); i++)
#define rep(i, a) REP(i, 0, a)
#define SZ(X) ((int64_t)((X).size()))
#define ITR(x, a) for (auto x = a.begin(); x != a.end(); x++)
#define ALL(a) (a.begin()), (a.end())
#define HAS(a, x) (a.find(x) != a.end())
#define Min(x) *min_element(ALL(x))
#define Max(x) *max_element(ALL(x))
#define Unique(L) (L.erase(unique(ALL(L)), L.end()))
#define intmax (std::numeric_limits<int64_t>::max() / 4)
#define doublemax (std::numeric_limits<double>::max() / 4)
using namespace std;
//typedef boost::multiprecision::cpp_int bigint;
const double EPS = 1e-9;
const double PI = acos(-1.0);




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

	int N, M;
	cin >> N >> M;
	vector<array<int,3>>g;
	rep(i, M) {
		int a, b, c;
		cin >> a >> b >> c;
		a--; b--;
		g.push_back({ a,b,-c });
	}

	vector<int>d(N, intmax);
	d[0] = 0;
	rep(cnt,N+4000) {
		int p = d[N - 1];
		rep(i, g.size()) {
			if (d[g[i][0]] != intmax && d[g[i][1]] > d[g[i][0]] + g[i][2]) {
				d[g[i][1]] = d[g[i][0]] + g[i][2];
			}
		}
		if (N<cnt&&p != d[N - 1]) {
			cout << "inf" << endl;
			return 0;
		}
	}
	cout << -d[N - 1] << endl;




	return 0;
}

Measured memory_bytes: 384
import sys
 
stdin = sys.stdin
 
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline()
 
n = ni()
a = na()
f = [0]*8
sp = 0
for v in a:
    if v >= 3200:
        sp += 1
    else:
        f[v//400] = 1
        
if sum(f) > 0:
    print("{} {}".format(sum(f), sum(f)+sp))
else:
    print("{} {}".format(sum(f)+min(sp,1), sum(f)+sp))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, j, n) for (ll i = j; i < n; i++)
#define all(x) (x).begin(),(x).end()
#define INF (1000000000)
#define MOD (1000000007)
#define MAX (500000)
#define pii pair<int, int>

/////////////////////////////////////////////////////////

class XY{
public:
  ll x, y;
  XY() {x = y = 0;}
  XY(ll u, ll v) {x = u; y = v;}
};

class e{
public:
  ll a, b;
  e() {a = b = -1;}
  e(ll u, ll v) {a = u; b = v;}
};

template<typename T1, typename T2>
void chmin(T1 &a, T2 b) {if(a > b) a = b;}
template<typename T1, typename T2>
void chmax(T1 &a, T2 b) {if(a < b) a = b;}

template<typename T1, typename T2>
ll mypow(T1 a, T2 n){
  if(n == 0) return 1;
  if(n == 1) return a;
  if(n % 2) return a * mypow(a, n - 1);
  ll tmp = mypow(a, n / 2);
  return tmp * tmp;
}

template<typename T>
int BS(vector<T> &V, int left, int right, T key){
  int mid = (left + right) / 2;
  if(V[mid] <= key) left = mid;
  else right = mid;
  if(right - mid == 1) return left;
  else return BS(V, left, right, key);
}

ll comb(ll n, ll r){
	ll res = 1;
  rep(i, 0, r){
    res *= n - i;
    res /= i + 1;
  }
  return res;
}

template<typename T>
T euclid(T a, T b){
  if(b == 0) return a;
  else return euclid(b, a % b);
}

vector<ll> fact(MAX, 0), fact_inv(MAX, 0);

ll pow_mod(ll a, ll b){
	ll res = 1;
	while(b > 0){
		if(b & 1) res = res * a % MOD;
		a = a * a % MOD;
		b >>= 1;
	}
	return res;
}

void prepare_comb_mod(ll n){
	fact[0] = 1LL;
	for(ll i = 0; i < n; i++) fact[i+1] = fact[i] * (i + 1) % MOD;
	fact_inv[n] = pow_mod(fact[n], MOD - 2);
	for(ll i = n - 1; i >= 0; i--) fact_inv[i] = fact_inv[i + 1] * (i + 1) % MOD;
}

ll comb_mod(ll n, ll r){
	return (fact[n] * fact_inv[r]) % MOD * fact_inv[n - r] % MOD;
}

/////////////////////////////////////////////////////////

void Main() {
  ll N; cin >> N;
  string S1, S2; cin >> S1 >> S2;
  ll past = 0;
  ll res = 1;
  rep(i, 0, N){
    if(S1[i] == S2[i]){
      if(past == 0) res *= 3;
      else if(past == 1) res *= 2;
      else res *= 1;
      past = 1;
    }else{
      if(past == 0) res *= 6;
      else if(past == 1) res *= 2;
      else res *= 3;
      past = 2;
      i++;
    }
    res %= MOD;
  }
  cout << res << endl;
}

/////////////////////////////////////////////////////////

int main(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << std::fixed << std::setprecision(15);

  Main();
}


Measured memory_bytes: 8064
def main():
    N = int(input())
    x4 = 0
    x2 = 0
    for a in map(int, input().split()):
        if a % 4 == 0:
            x4 += 1
        elif a % 2 == 0:
            x2 += 1
    if x2 == 0 and x4*2 + 1 >= N:
        print("Yes")
    elif x4*2 + x2 >= N:
        print("Yes")
    else:
        print("No")


if __name__ == "__main__":
    main()


Measured memory_bytes: 62576
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define fi first
#define se second
using namespace std;
const int M=1e5+10;
typedef pair<int,int> P;
int n,m;
P a[M];
bool cmp(P x,P y){
    if(x.fi==y.fi) return x.se>y.se;
    return x.fi<y.fi;
}
int main()
{
    scanf("%d%d",&n,&m);
    for(int i=0;i<n;i++) scanf("%d%d",&a[i].fi,&a[i].se);
    sort(a,a+n,cmp);
    priority_queue<int> q;
    int now=0,ans=0;
    for(int i=1;i<=m;i++)
    {
        while(now<n && a[now].fi<=i) q.push(a[now].se),now++;
        if(!q.empty())
            ans+=q.top(),q.pop();
    }
    printf("%d\n",ans);
    return 0;
}



Measured memory_bytes: 1660
W,H,N=map(int,input().split())
xM=W
xm=0
yM=H
ym=0
for i in range(N):
    a=list(map(int,input().split()))
    if a[2]==1:
        if a[0]>xm:
            xm=a[0]
        else:
            continue
    elif a[2]==2:
        if a[0]<xM:
            xM=a[0]
        else:
            continue
    elif a[2]==3:
        if a[1]>ym:
            ym=a[1]
        else:
            continue
    else:
        if a[1]<yM:
            yM=a[1]
        else: 
            continue
xl=xM-xm
yl=yM-ym
print(max(0,xl)*max(0,yl))

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
typedef complex<double> P;

struct S{
  P p,q;
  S(P p,P q): p(p),q(q) {}
};

P calc(P a,P b,P c,P d){
  a-=d;b-=d;c-=d;
  return d+a+(b-a)*imag(a/c)/imag(a/c-b/c);
}

P calc( S a, S b){
  return calc( a.p , a.q , b.p , b.q );
}

double cross(P a,P b){
  return imag( b * conj(a) );
}

double calcArea(P a,P b,P c,P d){
  b-=a;c-=a;d-=a;
  double res=0;
  res+= abs( cross(b,c) )*0.5;
  res+= abs( cross(c,d) )*0.5;
  return res;
}

int main(){
  int n;
  while(1){
    cin>>n;
    if(n==0)break;
    vector< P > top,right,left,bottom;
    for(int i=0;i<n;i++){
      double k;
      cin>>k;
      bottom.push_back( P(k,0) );
    }
    for(int i=0;i<n;i++){
      double k;
      cin>>k;
      top.push_back( P(k,1) );
    }
    for(int i=0;i<n;i++){
      double k;
      cin>>k;
      left.push_back( P(0,k) );
    }
    for(int i=0;i<n;i++){
      double k;
      cin>>k;
      right.push_back( P(1,k) );
    }
    
    vector< S > sh,sw;
    sh.push_back( S( P(0,0) , P(0,1) ) );
    for(int i=0;i<n;i++){
      sh.push_back( S( bottom[i],top[i] ) );
    }
    sh.push_back( S( P(1,0) , P(1,1) ) );
    
    sw.push_back( S( P(0,0) , P(1,0) ) );
    for(int i=0;i<n;i++){
      sw.push_back( S( left[i],right[i] ) );
    }
    sw.push_back( S( P(0,1) , P(1,1) ) );

    double ans=-1;
    for(int i=0;i<=n;i++){
      for(int j=0;j<=n;j++){
	P ld = calc( sh[i], sw[j] );
	P lu = calc( sh[i+1], sw[j] );
	P rd = calc( sh[i], sw[j+1] );
	P ru = calc( sh[i+1], sw[j+1] );
	ans=max(ans, calcArea(ld,rd,ru,lu) );
      }
    }

    printf("%.6f\n",ans);
  }
  return 0;
}

Measured memory_bytes: 3192
#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#include "debug.h"
#else
#define dump(...)
#endif
#define endl "\n"
#define ll long long
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define REP(i, x) for (int i = 0; i < (int)(x); i++)
#define REPS(i, x) for (int i = 1; i <= (int)(x); i++)
#define RREP(i, x) for (int i = ((int)(x)-1); i >= 0; i--)
#define RREPS(i, x) for (int i = ((int)(x)); i > 0; i--)
#define INF (1 << 30)
#define LLINF (1LL << 60)
#define vi vector<int>
#define vvi vector<vector<int>>
#define pi pair<int, int>
#define ALL(a) (a).begin(), (a).end()
#define BIT(n) (1LL << (n))
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end()) //sortしてからつかうこと
constexpr ll MOD = 1e9 + 7;
int dx[8] = {1, 0, -1, 0, 1, 1, -1, -1};
int dy[8] = {0, 1, 0, -1, 1, -1, 1, -1};
ll A, B, C, D, E, F, G, H, N, M, L, K, P, Q, R, W, X, Y, Z;
string S, T;
ll ans = 0;

template <typename T>
istream &operator>>(istream &is, vector<T> &vec) {
    for (T &x : vec)
        is >> x;
    return is;
}

signed main() {
    cin >> N;
    vi a(N), p(N), q(N);
    cin >> p >> q;
    for (int i = 0; i < N; i++) {
        a[i] = i + 1;
    }
    int cnt = 0;
    do {
        cnt++;
        bool pf = 1, qf = 1;
        for (int i = 0; i < N; i++) {
            if (a[i] != p[i]) {
                pf = 0;
            }
            if (a[i] != q[i]) {
                qf = 0;
            }
        }
        if (pf) {
            A = cnt;
        }
        if (qf) {
            B = cnt;
        }
    } while (std::next_permutation(a.begin(), a.end()));
    cout << abs(A - B) << endl;
}

Measured memory_bytes: 256
H,W,K=map(int,input().split())
c=[input() for _ in range(H)]
ans=0
for row in range(1<<H):
  for col in range(1<<W):
    count=0
    for i in range(H):
      for j in range(W):
        if row&(1<<i)==0 and col&(1<<j)==0 and c[i][j]=="#":
          count+=1
    if count==K:
      ans+=1
print(ans)




Measured memory_bytes: 9196
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
#define ll long long

int main(){
  int Q,H,S,D;
  cin >> Q >> H >> S >> D;
  H = min(Q*2, H);
  S = min(H*2, S);
  D = min(S*2, D);
  ll N;
  cin >> N;
  if(N%2 == 0){
    cout << (N/2)*D << endl;
  }else{
    cout << (N/2)*D + S << endl;
  }
  return 0;
}


Measured memory_bytes: 256
import java.util.*;

class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int A = sc.nextInt();
        int B = sc.nextInt();
        int C = sc.nextInt();
        if(A==B) System.out.println(C);
        else{
            if(A==C) System.out.println(B);
            else System.out.println(A);
        }
    }
}

Measured memory_bytes: 23636
#include <iostream>

using namespace std;

int main() {
  long long n, x;
  cin >> n >> x;
  long long ans = 0;
  if (2 * x == n) {
    ans = 3 * x;
  } else {
    ans = n;
    long long d = x;
    long long l = n - x;
    while (true) {
      long long cnt = l / d;
      ans += cnt * 2 * d;
      if (l % d == 0) {
        ans -= d;
        break;
      }
      l = l % d;
      swap(l, d);
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> pll;
const ll mod=1e9+7;
//const ll mod=998244353;
const ll inf=1LL<<61;

int main() {
  ll n,k;
  cin >> n >> k;
  k=min(k,50LL);
  vec a(n);
  for(ll i=0;i<n;i++) {
    cin >> a[i];
  }
  priority_queue<ll,vec,greater<ll>> f,t;
  ll tmp=0;
  while(k--) {
    tmp=0;
    for(ll i=0;i<n;i++) {
      f.push(i-a[i]);
      t.push(i+a[i]);
    }
    for(ll i=0;i<n;i++) {
      while(f.size()&&f.top()<=i) {
        tmp++;
        f.pop();
      }
      a[i]=tmp;
      while(t.size()&&t.top()<=i) {
        tmp--;
        t.pop();
      }
    }
    while(t.size()) t.pop();
  }
  for(ll i=0;i<n;i++) {
    if(i) cout << " ";
    cout << a[i];
  }
  cout << endl;
}

Measured memory_bytes: 8096
#include <stdio.h>

int main(void) {
  int r, c, i, j;
  int sum=0;
  scanf("%d %d", &r, &c);
  int a[r+1][c+1];
  for(i=0;i<r+1;i++){
    for(j=0;j<c+1;j++){
      a[i][j]=0;
    }
  }
  for(i=0;i<r;i++){
    for(j=0;j<c;j++){
      scanf("%d", &a[i][j]);
      a[i][c]+=a[i][j];
      a[r][j]+=a[i][j];
      sum+=a[i][j];
    }
  }
  a[r][c]=sum;
  for(i=0;i<r+1;i++){
    for(j=0;j<c;j++){
      printf("%d ", a[i][j]);
    }
    printf("%d\n", a[i][c]);
  }
  return 0;
}



Measured memory_bytes: 1980
#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = a; i < b; i++)
#define Rep(i, a, b) for(int i = a; i <= b; i++)
#define _GLIBCXX_DEBUG
#define Vl vector<ll>
#define Vs vector<string>
#define ll long long
#define ALL(v) (v).begin(),(v).end()
using namespace std;

int gcd(int a, int b)
{
   if (a%b == 0)
   {
       return(b);
   }
   else
   {
       return(gcd(b, a%b));
   }
}

void solve(){
    int k; cin >> k;
    int M = -1;
    ll ans = 0;
    Rep(i, 1, k){
        Rep(j, 1, k){
            Rep(l, 1, k){
                int a = gcd(i, j);
                ans += gcd(a, l);
            }
        }
    }
    cout << ans << endl;
}

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

Measured memory_bytes: 3636
#include<cstdio>
#include<algorithm>
using namespace std;
int n,a[2001],sum=0;

inline void init() {
	scanf("%d",&n);
	n*=2;
	for (int i=1;i<=n;i++) scanf("%d",&a[i]);
	sort(a+1,a+n+1);
}

inline void work() {
	for (int i=1;i<=n;i++) 
		if (i%2==1) 
			sum+=a[i]; 
}

int main() {
	init();
	work();
	printf("%d\n",sum);
	return 0;
}

Measured memory_bytes: 504
#include<stdio.h>
#include<math.h>
int gcd(int a,int b){
	if(a%b){
      return gcd(b,a%b);
    }else{
      return b;
    }
}
int main(){
	int n,x,i,ans;
	int c[100000];
	scanf("%d %d",&n,&x);
	for(i=0;i<n;i++){
		scanf("%d",&c[i]);
		c[i]=abs(x-c[i]);
	}
	if(n==1){
      printf("%d",c[0]);
    }
	else{
		ans=gcd(c[0],c[1]);
		for(i=2;i<n;i++){
			ans=gcd(ans,c[i]);
		}
		printf("%d",ans);
	}
	return 0;
}

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

int main(void){
    long long n, ans=0;
    cin >> n;
    for(long long i=1;i<n;++i){
        if((n-i)/i<i+1){
            break;
        }
        if((n-i)%i==0) ans += (n-i)/i;
    }
    cout << ans << endl;
}

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

using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))

int dx4[4] = {1,0,-1,0}, dy4[4] = {0,1,0,-1};

int main(){
    string s;
    cin>>s;
    int n = s.size();
    vector<int> dp(n+10);
    int cnt = 0;
    for (int i = 0; i < n; i++)
    {
        if(i==0)
        {
            dp[0]=1;
        }
        else
        {
            if(s[i]!=s[i-1] || cnt>0)
            {
                dp[i]=dp[i-1]+1;
                if(cnt>0) cnt--;
            }
            else
            {
                dp[i]=dp[i-1];
                cnt=2;
            }
        }
    }
    cout<<dp[n-1]<<endl;
    
    return 0;
}

Measured memory_bytes: 1412
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n)  for(long long i=0;i<(long long)(n);i++)
#define REP(i,k,n) for(long long i=k;i<(long long)(n);i++)
#define all(a) a.begin(),a.end()
#define pb push_back
#define eb emplace_back
#define lb(v,k) (lower_bound(all(v),k)-v.begin())
#define ub(v,k) (upper_bound(all(v),k)-v.begin())
#define fi first
#define se second
#define pi M_PI
typedef long long ll;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> PP;
typedef multiset<ll> S;
typedef priority_queue<ll> PQ;
typedef priority_queue<P,vector<P>,greater<P>> SPQ;
using vi=vector<ll>;
using vvi=vector<vi>;
using vvvi=vector<vvi>;
const ll inf=1001001001001001;
const int INF=1001001001;
const int 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> void out(T a){cout<<a<<'\n';}
template<class T> void outp(T a){cout<<'('<<a.fi<<','<<a.se<<')'<<'\n';}
template<class T> void outvp(T v){rep(i,v.size())outp(v[i]);}
template<class T> void outv(T v){rep(i,v.size()){if(i)cout<<' ';cout<<v[i];}cout<<'\n';}
template<class T> void outvv(T v){rep(i,v.size()){rep(j,v[i].size()){if(j)cout<<' ';cout<<v[i][j];}cout<<'\n';}}
ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
ll modpow(ll a,ll b){a%=mod;if(b==0)return 1;if(b&1)return a*modpow(a,b-1)%mod;ll k=modpow(a,b/2);return k*k%mod;}
int main(){
    string s,t;cin>>s>>t;
    ll a,b;cin>>a>>b;
    string k;cin>>k;
    if(k==s)a--;
    else b--;
    cout<<a<<' '<<b<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cmath>
using namespace std;
int main(){
	int n,sum;
	double wq;
    cin>>n;
    for(int i=n;i>=1;i--){
    	wq=sqrt(i);
        if(int(sqrt(i))==wq){
            cout<<i<<endl;
            return 0;
        }
	}
}

Measured memory_bytes: 256
fn main() {
    let mut buf = String::new();
    std::io::stdin().read_line(&mut buf).unwrap();
    let r: i64 = buf.trim().parse().ok().unwrap();
    if r < 1200 {
        println!("ABC");
    } else if r < 2800 {
        println!("ARC");
    } else {
        println!("AGC");
    }
}


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

#define ll              long long int
#define ull             unsigned long long int
#define pii             pair < int, int>
#define pll             pair < ll, ll>
#define sc              scanf
#define scin(x)         sc("%d",&(x))
#define scln(x)         sc("%lld",&(x))
#define pf              printf
#define ms(a,b)         memset(a,b,sizeof(a))
#define pb(a)           push_back(a)
#define mp              make_pair
#define db              double
#define EPS             10E-10
#define ff              first
#define ss              second
#define sqr(x)          (x)*(x)
#define vi              vector< int >
#define vl              vector< ll >
#define vii             vector<vector< int > >
#define vll             vector<vector< ll > >
#define DBG             pf("HI\n")
#define MOD             1000000007
#define CIN             ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define RUN_CASE(t,T)   for(__typeof(t) t=1;t<=T;t++)
#define CASE(t)         printf("Case %d: ",t)
#define CASEL(t)        printf("Case %d:\n",t)
#define intlimit        2147483648
#define longlimit       9223372036854775808
#define infinity        (1<<28)
#define gcd(a, b)       __gcd(a,b)
#define lcm(a, b)       ((a)*(b)/gcd(a,b))
#define mx              123456789

using namespace std;

///--------------Graph Moves--------------------------------------
///const int fx[] = {+1,-1,+0,+0};
///const int fy[] = {+0,+0,+1,-1};
///const int fx[] = {+0,+0,+1,-1,-1,+1,-1,+1}; ///King's move
///const int fy[] = {-1,+1,+0,+0,+1,+1,-1,-1}; ///king's Move
///const int fx[] = {-2,-2,-1,-1,+1,+1,+2,+2}; ///knight's move
///const int fx[] = {-1,+1,-2,+2,-2,+2,-1,+1}; ///knight's move
///---------------------------------------------------------------


int main()
{
    int n,s1,s2,ans;
    scin(n);
    scin(s1);
    scin(s2);
    scin(ans);
    if(n+s1==s2+ans)
        pf("Balanced\n");
    else if(n+s1<s2+ans)
        pf("Right\n");
    else
        pf("Left\n");
    return 0;
}


Measured memory_bytes: 256
n, k = map(int,input().split())

# m,nに対してm^(-1) mod n を求める
def reciprocal(m, n):
# p < q ならpをqで割った余りを求める
    if (m > n):
        m = m % n
    a0 = n
    a1 = m
    x0 = 1
    x1 = 0
    y0 = 0
    y1 = 1
    while (a1 != 0):
        q = a0 // a1
        r = a0 % a1
        x2 = x0 - q * x1
        y2 = y0 - q * y1
        a0 = a1
        a1 = r
        x0 = x1
        x1 = x2
        y0 = y1
        y1 = y2
    if (a0 !=1):
        print("法除算に失敗しました")
    while (y0 < 0):
      y0 += n
    return(y0)

# 各iに対して、(k-1)!/{(k-i)!(i-1)!} * (n-k+1)!/{(n-k-i+1)!i!}を計算する
# 以前のiの答えをansに格納しておく
# i = 1の時は(n-k+1)となる
ans = (n-k+1) % (10**9+7)
# i * j mod (10**9+7)を計算する関数を作る
def modMulti(i,j):
  return(i*j % (10**9+7))
# i / j mod (10**9+7)を計算する関数を作る
# i< j なら(10**9+7 + i) / jとする必要がある
def modDiv(i,j):
  if i % j == 0:
    # ここを(i/j % (10**9+7))とすると何故かバグる
    return(i//j % (10**9+7))
  else:
    return(i * reciprocal(j, (10**9+7)) % (10**9+7))
print(ans)
if k > 1:
  for i in range(2, k+1):
    ans = modDiv(modMulti(modMulti(ans,k-i+1), n-k-i+2), modMulti(i-1,i))
    print(ans)

Measured memory_bytes: 3444
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a)  (a).begin(),(a).end()
#define pb emplace_back
#define INF (1e9+1)
//#define INF (1LL<<59)

//0-index ?????????????????°?????????(????????´??°or?????? , ????°????or?????§???or???) verified AOJ DSL_2,DSL_3
template<class T>
class segtree{
private:
    vector<T> dat;
    int _size;  //the number of leaves
    T _init;
    
public:
    segtree(int __size=0 , T init=numeric_limits<T>::max() ):_size(__size) , _init(init){
        if(__size==0)return ;
        int x=1;
        while(x<_size)x*=2;
        _size = x;
        dat.resize(_size*2);
    }
    
    void update(int m,T x){
        int i = m+_size;
        dat[i] = x;     //initialize
        for(; i!=1; i/=2){
            dat[i/2] = min(dat[i],dat[i^1]);    //minimum
        }
    }
    
    // call find(s,t)
    T find(int s,int t,int num=1,int l=0,int r=-1){
        if(r==-1)r=_size; //I couldn't "int b=_size".
        if(r<=s||t<=l)return _init;
        if(s<=l&&r<=t)return dat[num];
        return min( find(s,t,num*2,l,(l+r)/2) , find(s,t,num*2+1,(l+r)/2,r) );    //minimum
    }
    int size(){return _size;}
};

int main(){
    int n,q;
    cin>>n>>q;
    segtree<int> st(n);
    rep(i,n)st.update((int)i,(1LL<<31)-1);
    rep(i,q){
        int type;
        cin>>type;
        
        if(type==0){
            int j,x;
            cin>>j>>x;
            st.update(j,x);
        }else{
            int s,t;
            cin>>s>>t;
            cout<<st.find(s,t+1)<<endl;
        }
    }
}

Measured memory_bytes: 3796
#include <cstdio>
#include <functional>
#include <algorithm>

using namespace std;

int main(void)
{
  int i;
  int heights[10];

  for (i = 0; i < 10; i++) {
    scanf("%d", &heights[i]);
  }

  sort(heights, heights + 10, greater<int>());

  for (i = 0; i < 3; i++) {
    printf("%d\n", heights[i]);
  }

  return 0;
}

Measured memory_bytes: 1048
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <math.h>
#include <cmath>
#include <limits.h>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <functional>
using namespace std;

int main() {
    
    int N;
    cin >> N;
    
    vector<long long> A, B, C;
    
    for ( int i = 0; i < N; i++ ) {
        long long a;
        cin >> a;
        A.push_back(a);
    }
    
    for ( int i = 0; i < N; i++ ) {
         if ( i%2 != N%2 ) {             
             C.push_back( A[i] );
         }
         else {
             B.push_back(A[i]);
         }
    }
    
   reverse( C.begin(), C.end() );
    
    for ( auto& a : C ) {
        cout << a << " ";
    }    
    for ( auto& a : B ) {
        cout << a << " ";
    }
    
    cout << endl;
    
    return 0;
}

Measured memory_bytes: 6640
// Problem : C - Sum of product of pairs
// Contest : AtCoder - AtCoder Beginner Contest 177
// URL : https://atcoder.jp/contests/abc177/tasks/abc177_c
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

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

//Macros

#define ll long long
#define db long double
#define pb push_back
#define eb emplace_back
#define pii pair<int,int>
#define vi vector<int>
#define vii vector<pii>
#define mi map<int,int>
#define mii map<pii,int>
#define fi first
#define se second
#define all(a) (a).begin(),(a).end()
#define sz(x) (int)x.size()
#define mod 1000000007
#define EPS 1e-9
#define io ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define inf 1e10
#define PI acos(-1.0)
#define int long long
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
#define N 100005

//Solution

void solve(){
    int n;
    cin>>n;
    vi a(n);
    for(int &x : a) cin>>x;
    int sum = a[n-1];
    int ans = 0;
    for(int i=n-2;~i;i--){
        ans += (sum*a[i])%mod;
        ans %= mod;
        sum += a[i];
        sum %= mod;
    }
    cout<<ans;
}

signed main(){
    io;
    //freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
    int tests;
    //cin>>tests;
    tests = 1;
    for(int test=1;test<=tests;test++){
        //cout<<"Case #"<<test<<": ";
        solve();
    }
    return 0;
}

Measured memory_bytes: 4776
array = gets.chomp.split("").map(&:to_i)

case 7
when array[0] + array[1] + array[2] + array[3]
  print "#{array[0]}+#{array[1]}+#{array[2]}+#{array[3]}=7"
when array[0] + array[1] + array[2] - array[3]
  print "#{array[0]}+#{array[1]}+#{array[2]}-#{array[3]}=7"
when array[0] + array[1] - array[2] + array[3]
  print "#{array[0]}+#{array[1]}-#{array[2]}+#{array[3]}=7"
when array[0] - array[1] + array[2] + array[3]
  print "#{array[0]}-#{array[1]}+#{array[2]}+#{array[3]}=7"
when array[0] + array[1] - array[2] - array[3]
  print "#{array[0]}+#{array[1]}-#{array[2]}-#{array[3]}=7"
when array[0] - array[1] + array[2] - array[3]
  print "#{array[0]}-#{array[1]}+#{array[2]}-#{array[3]}=7"
when array[0] - array[1] - array[2] + array[3]
  print "#{array[0]}-#{array[1]}-#{array[2]}+#{array[3]}=7"
when array[0] - array[1] - array[2] - array[3]
  print "#{array[0]}-#{array[1]}-#{array[2]}-#{array[3]}=7"
end


Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
using pii=pair<int,int>;
using ll=long long;
using pll=pair<ll,ll>;

#define fi first
#define se second
#define pb push_back
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define MOD 1000000007

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

bool hoge (pii a, pii b) {
	if(a.se > b.se) return true;
	else return false;
}
int main() {
	int N,M;
	cin >> N >> M;
	map<ll,ll> mp;
	rep(i,N) {
		ll at;
		cin >> at;
		mp[at]++;
	}
	vector<pii> b(M);
	ll bt,ct;
	rep(i,M) {
		cin >> bt >> ct;
		mp[ct] += bt;
	}
	ll ans = 0;
	int count = 0;
	auto itr = mp.end();
	while(count < N) {
		itr--;
		if(itr->second != 0) {
			//cout << itr->first << " " << itr->second << endl;
			ans += itr->first * min(itr->second, (ll)(N - count));
			count += min(itr->second, (ll)(N - count));
		}
	}
	cout << ans << endl;

/*
	rep(i,M) {
		if(b[i].fi <= a.top()) continue;
		int count = 0;
		while(a.top()< b[i].fi && count < b[i].se) {
			a.pop();
			a.push(b[i].fi);
			count++;
		}
	}
	ll ans = 0;
	rep(i,N) {
		ans += a.top();
		a.pop();
	}
	cout << ans << endl;
*/
  return 0;
}


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

int mygcd(int x,int y){
    if(x <= y){
        if(x == 0)
            return y;
        else
            return mygcd(y%x,x);      
    }else{
        if(y == 0)
            return x;
        else
        {
            return mygcd(y,x%y);
        }
        
    }
}

int main(){
    string S;
    cin >> S;
    int n=0,s=0,w=0,e=0,ns=0,we=0;

    for(int i = 0;i < S.size();i++){
        if(S.at(i) == 'N')
            n++;
        else if(S.at(i) == 'S')
            s++;
        else if(S.at(i) == 'W')
            w++;
        else
            e++;
    }
    if(mygcd(n,s) == 0)
        ns = 1;
    else
        ns = n * s /mygcd(n,s);
    if(mygcd(w,e) == 0 )
        we = 1;
    else
        we = w * e /mygcd(w,e);

    if(ns > 0 && we > 0)
        cout << "Yes" << endl;
    else 
        cout << "No" << endl;




}

Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
int main(){
  string s;
  int max=0,size;
  cin >> s;
  for(int i=0;i<s.size();i++){
    size=0;
    for(int j=i;j<s.size();j++){
      if(s[j]=='A'||s[j]=='C'||s[j]=='G'||s[j]=='T'){
        size++;
      }else{
        break;
      }
    }
    max = (max>size)? max:size;
  }
  cout<< max << endl;
}


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

#define MOD 1000000007

long long fac[1000001],finv[1000001],inv[1000001];

void COMinit(){
	fac[0]=fac[1]=1;
	finv[0]=finv[1]=1;
	inv[1]=1;
	for(int i=2;i<1000001;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 COM(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;
}
 
long long MODpow(long long a,int b){
	if(b==0)return 1;
	if(b%2==0){
		long long t=MODpow(a,b/2);
		return (t*t)%MOD;
	}
	return (a*MODpow(a,b-1))%MOD;
}

int main(){
	COMinit();
	int N;
	cin >> N;
	vector<long long> x(N);
	for(auto &i:x)cin >> i;
	
	long long ans=0;
	
	vector<long long> a(N-1);
	a[0]=fac[N-1];
	for(int i=1;i<N-1;i++)a[i]=(a[0]*inv[i+1])%MOD;
	//for(int i=1;i<N-1;i++)a[i]=(a[i]+a[i-1])%MOD;
	
	for(int i=0;i<N-1;i++){
		//long long diff=x[i+1]-x[i];
		long long diff=x[N-1]-x[i];
		ans+=diff*a[i];
		ans%=MOD;
	}
	//for(auto i:a)cout << i << endl;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 25216
#include<bits/stdc++.h>
#define pii pair<int, int>
#define F first
#define S second
#define pb push_back
using namespace std;
const int H=11, W=1e3+3, INF=1e9;
int h, w, k, mat[H][W], ans = INF, cnt[H], tmpcnt[H];
char c;
int solve(int mask)
{
    int vcuts = 0;
    int prev=1;
    int sections = __builtin_popcount(mask);
    sections+=1;
    for(int i = 0; i < sections; i++)
    {
        cnt[i]=0;
    }
    for(int i = 1; i <= w; i++)
    {
        for(int j = 0; j < sections; j++)
        {
            tmpcnt[j]=0;
        }
        int sec=0;
        for(int j = 1; j <= h; j++)
        {
            if(j!=1 && (mask & (1<<(j-2))))
            {
                sec++;
            }
            tmpcnt[sec] += mat[j][i];
        }
        for(int j = 0; j < sections; j++)
        {
            //cout << i << " " << j << " - " << tmpcnt[j] << endl;
            if(cnt[j] + tmpcnt[j] > k)
            {
                if(prev==i) return INF;
                vcuts+=1;
                for(int jj = 0; jj < sections; jj++)
                {
                    cnt[jj]=0;
                }
                prev=i;
                i--;
                break;
            }
            cnt[j]+=tmpcnt[j];
        }
    }
    return vcuts;
}
signed main()
{
    cin >> h >> w >> k;
    for(int i = 1; i <= h; i++)
    {
        for(int j = 1; j <= w; j++)
        {
            cin >> c;
            mat[i][j] = c - '0';
        }
    }
    for(int i = 0; i < 1<<(h-1); i++)
    {
        int ret = solve(i);
       // cout << i << " --- " << ret << endl;
        ans = min(ans, ret + __builtin_popcount(i));
    }
    //cout << solve(0) << endl;
    cout << ans;
}

Measured memory_bytes: 256
#include <algorithm>
#include <chrono>
#include <iostream>
#include <vector>

using namespace std;
using namespace std::chrono;

int main() {
  auto start = high_resolution_clock::now();

  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);

  long long n;
  cin >> n;
  size_t ans = to_string(n).length();
  for (long long i = 1; i * i <= n; ++i) {
    if (n % i != 0)
      continue;
    ans = min(ans, max(to_string(i).length(), to_string(n / i).length()));
  }

  cout << ans << endl;

  cerr << "Total execution time : " << duration_cast<milliseconds>(high_resolution_clock::now() - start).count() << " ms" << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  FOR(i,0,n)
#define req(i,n) for(int i = 1;i <=n;i++)
#define pai 3.14159265358979323846
const int INF = 1001001001;
typedef long long ll;
int A[3][3], N;
bool punched[3][3];
bool ok[3][3];
using Graph = vector<vector<int>>;
vector<vector<int>> field;
vector<bool> seen;

const int MOD = 1000000007;
typedef pair<int,int> P;

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

}

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

//素数判定
bool is_prime(long long N) {
    if (N == 1) return false;
    for (long long i = 2; i * i <= N; ++i) {
        if (N % i == 0) return false;
    }
    return true;
}



  








      

 
int main(){
  int n,a,b,c,d; cin >> n >> a >> b >> c >> d;
  a--,b--,c--,d--;
  string s; cin >> s;
  int maxcd=max(c,d);
  bool empflag=false,sflag=true;
  if(c<d) empflag=true;
  for(int i=a;i<=maxcd;++i){
    if(i==n-1) break;
    if(b<=i && i<=d){
      if(s[i-1]=='.' && s[i]=='.' && s[i+1]=='.') empflag=true;
    }
    if(s[i]=='#' && s[i+1]=='#') sflag=false;
  }
  if(empflag && sflag) cout << "Yes";
  else cout << "No";
  cout << endl;
  
  return 0;
}

Measured memory_bytes: 3720
import java.util.*;
public class Main {
	static Scanner sc = new Scanner(System.in);
	static int n, m;
	static int[][] data;
	public static void main(String[] args) {
		while(read()){
			solve();
		}

	}
	static boolean read(){
		n = sc.nextInt(); m = sc.nextInt();
		if(n == 0 && m == 0)return false;
		data = new int[n][m];
		for(int i = 0; i < n; i++){
			for(int j = 0; j < m; j++){
				data[i][j] = sc.nextInt();
				//System.out.print(data[i][j]);
			}
			//System.out.println();
		}
		return true;
	}
	static void solve(){
		int []res = new int[m];
		for(int i = 0; i < n; i++){
			for(int j = 0; j < m; j++){
				if(data[i][j] == 1) res[j]++;
			}
		}
		/*for(int i = 0; i < res.length; i++)
			System.out.print("res[" + i + "] = " + res[i] + " ");
		System.out.println();
*/
		int max = 0;
		int index = 0;
		for(int i = 0; i < m; i++){
			for(int j = 0; j < m; j++){
				if(res[j] > max){
					max = res[j];
					index = j;
				}
			}
			if(i != m-1){
				System.out.print(index+1 + " ");
				res[index] = 0;
				max = 0;
				index = 0;
			}else{
				System.out.println(index+1);
			}
		}
		//System.out.println();
	}
}

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

int main()
{
ll n, m;
cin >> n >> m;
vector<vector<ll>> g(n);
rep(i, m)
{
  ll a, b;
  cin >> a >> b;
  g[a - 1].push_back(b - 1);
  g[b - 1].push_back(a - 1); 
}
vector<bool> see(n);
vector<ll> d(n,0);

queue<ll> q;
see[0]=1;
d[0]=0;
q.push(0);
while(!q.empty()){
  auto p=q.front();
  q.pop();
  for(auto r:g[p]){
    if(see[r]!=0)continue;
    see[r]=1;
    d[r]=p;
    q.push(r);
  }
}
cout << "Yes" << endl;
rep(i,n-1)cout << d[i+1]+1 << endl;

return 0;
}

Measured memory_bytes: 12880
import java.util.*;

public class Main{
	public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int c[][]=new int[3][3];
        for(int i=0;i<3;i++){
            for(int j=0;j<3;j++){
                c[i][j]=sc.nextInt();
            }
        }
        int a1,a2,a3,b1,b2,b3;
        boolean fans=false;
        for(int i=0;i<=100;i++){
            boolean ans=true;
            a1=i;
            b1=c[0][0]-i;
            b2=c[1][0]-a1;
            b3=c[2][0]-a1;
            a2=c[0][1]-b1;
            a3=c[0][2]-b1;
            if(a1<0 ||b1<0||a2<0||a3<0||b2<0||b3<0) ans=false;
            if(b2+a2!=c[1][1]) ans=false;
            if(b2+a3!=c[1][2]) ans=false;
            if(b3+a2!=c[2][1]) ans=false;
            if(b3+a3!=c[2][2]) ans=false;
            if(ans) fans=true;
        }
        if(fans)System.out.println("Yes");
        else System.out.println("No");

    }
}


Measured memory_bytes: 23764
#include <bits/stdc++.h>
    #include <math.h>
 
    using namespace std;
    typedef long long ll;
    typedef unsigned long long ull;
    # define M_PI  3.14159265358979323846
 
 
    const int M=1e9+7;
    long long mod(long long x){
        return ((x%M + M)%M);
    }
    long long add(long long a, long long b){
        return mod(mod(a)+mod(b));
    }
    long long mul(long long a, long long b){
        return mod(mod(a)*mod(b));
    }
    long long minu(long long a, long long b){
        return mod(mod(a)-mod(b));
    }
    ll modPow(ll a, ll b){
        if(b==0)
            return 1LL;
        if(b==1)
            return a%M;
        ll res=1;
        while(b){
            if(b%2==1)
                res=mul(res,a);
            a=mul(a,a);
            b=b/2;
        }
        return res;
    }
    
    vector<int>dirX={-1,0,1};
    vector<int>dirY={-1,0,1};


    void solve(){
        ll n;
        cin>>n;
        if(n==1){
            cout<<0;
            return;
        }
        if(n==2){
            cout<<2;
            return;
        }
        ll ans=minu(add(modPow(10LL,n),modPow(8LL,n)),mul(2LL,modPow(9LL,n)));
        cout<<ans;
    }
    int main(){
        ios::sync_with_stdio(0);
        cin.tie(0);
        cout.tie(0);
        cout<<fixed;
        cout<<setprecision(10);
//        freopen("timber_input.txt", "r", stdin);
//        freopen("timber_output.txt", "w", stdout);
        int t=1;
        // cin>>t;
        for(int i=1;i<=t;i++){
        //    cout<<"Case #"<<i<<": ";
            solve();
        }
        return 0;
    }

Measured memory_bytes: 3636
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		try (Scanner sc = new Scanner(System.in);) {
			int n = sc.nextInt();

			int[] a = new int[n];
			int xor = 0;

			for (int i = 0; i < n; i++) {
				int value = sc.nextInt();
				a[i] = value;
				xor ^= value;
			}

			for (int i = 0; i < n; i++) {
				int value = a[i] ^= xor;
				System.out.print(value + " ");
			}

		} catch (Exception e) {
			e.printStackTrace();
		}

	}
}


Measured memory_bytes: 61288
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i, s, n) for (int i = (s); i < (n); ++i)
#define rrep(i, n, g) for (int i = (n)-1; i >= (g); --i)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define len(x) (int)(x).size()
#define dup(x, y) (((x) + (y)-1) / (y))
#define pb push_back
#define Field(T) vector<vector<T>>
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  if (a * b > c * d)
    cout << a * b << endl;
  else
    cout << c * d << endl;
}

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

#define For(i, j, k) for(int i = j; i <= k; i++)
#define Forr(i, j, k) for(int i = j; i >= k; i--)
#define Set(i, v) memset(i, v, szieof i)

using namespace std;

const int N = 1e5 + 10;

char S[N];
int A[N], n;

bool check(int k){
	For(i, n - k + 2, n) if(A[i] && i <= k) return false;
	return true;
}

int main(){

	scanf("%s", S + 1);
	n = strlen(S + 1);
	S[0] = '0';
	For(i, 1, n) A[i] = (S[i] - '0') ^ (S[i - 1] - '0');

	int L = 1, R = n;
	while(L < R){
		int mid = (L + R + 1) >> 1;
		if(check(mid)) L = mid;
		else R = mid - 1;
	}
	printf("%d\n", L);

	return 0;
}

Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
const int N=210000;
#define ll long long
#define PA pair<int,int>
int n,cnt;
int a[N],b[N],vis[N],neg[N<<1];
vector<int>v1,v2;
ll ans;
PA c[N<<1];
int main()
{
	//freopen("tt.in","r",stdin);
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%d%d",&a[i],&b[i]);
		v1.push_back(min(a[i],b[i]));
		v2.push_back(max(a[i],b[i]));
		c[++cnt]=PA(a[i],i);
		c[++cnt]=PA(b[i],i);
	}
	sort(v1.begin(),v1.end());
	sort(v2.begin(),v2.end());
	ans=(ll)(v1[n-1]-v1[0])*(v2[n-1]-v2[0]);

	sort(c+1,c+1+cnt);
	for(int i=1,t;i<=cnt;i++)
	{
		if(!vis[t=c[i].second])vis[t]=i;
		else neg[i]=vis[t],neg[vis[t]]=i;
	}
	for(int i=1,r=0,num=0,t;i<=cnt;i++)
	{
		while(num!=n&&r<cnt)
		{
			r++;t=c[r].second;
			if(neg[r]<i||neg[r]>r)
				num++;
		}
		if(num==n)
			ans=min(ans,(ll)(c[cnt].first-c[1].first)*(c[r].first-c[i].first));
		if(neg[i]<i||neg[i]>r)
			num--;
	}
	printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 9324
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) FOR(i,0,n)
#define repr(i,n) for(int i=(n)-1;0<=i;--i)
#define each(e,v) for(auto&& e:(v))
#define all(v) begin(v),end(v)
#define DUMP(x) cerr<<#x<<": "<<(x)<<endl
#define DEBUG(x) cerr<<#x<<": "<<(x)<<" (L"<<__LINE__<<")"<<endl
using namespace std;
using vint = vector<int>;
using vdouble = vector<double>;
using vstring = vector<string>;
using ll = long long;
template <class T> void chmin(T& a, const T& b) { a = min(a, b); }
template <class T> void chmax(T& a, const T& b) { a = max(a, b); }

int main() {
    int n; cin >> n;
    vint a(n);
    rep(i, n) cin >> a[i];
    sort(all(a));

    int longest = 1, l = 0, r = 0;
    while(l < n) {
        if(2 < a[r] - a[l]) l++;
        else r++;
        if(r < l) r = l;
        chmax(longest, r - l);
        if(n <= r) break;
    }
    cout << longest << endl;
    return 0;
}


Measured memory_bytes: 640
#include<iostream>
#include<algorithm>
using namespace std;
static const int MAX = 200000;

int main(){
  int R[MAX],n;
  
  cin >> n;
  for (int i = 0; i < n; i++) cin >> R[i];

  int maxv = -2000000000;
  int minv = R[0];
  
  for ( int i = 1; i < n; i++ ){
    maxv = max(maxv,R[i] - minv);
    minv = min(minv,R[i]);
  }
  
  cout << maxv << endl;
  
  return 0;
}


Measured memory_bytes: 3912
#include <bits/stdc++.h>
#define fio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
using namespace std;
typedef pair <int, int> pi;
int A[800][800], B[400][400];
int main() {fio; // remove during scanf
	int N;
	cin >> N;
	vector <pi> pos[26];
	for(int i = 0; i < N; i++) {
		string s;
		cin >> s;
		for(int j = 0; j < N; j++) {
			A[i][j] = s[j] - 'a';

			pos[A[i][j]].push_back({i, j});
		}
	}
	for(int i = 0; i < 2 * N; i++) {
		for(int j = 0; j < 2 * N; j++) {
			A[i][j] = A[i % N][j % N];
			// cerr << A[i][j];
		}
		// cerr << endl;
	}
	vector <pi> toDo;
	for(int i = 0; i < 26; i++) {
		toDo.push_back({pos[i].size(), i});
	}
	sort(toDo.begin(), toDo.end());
	vector <int> prc;
	for(auto u : toDo) {
		if(u.first == 0) {
			continue;
		}
		prc.push_back(u.second);
	}
	prc.pop_back();
	reverse(prc.begin(), prc.end());
	int ans = 0;
	map <int, int> yo;
	// for(int a = 0; a < N; a++) {
		for(int del = 0; del < N; del++) {
			bool ok = 1;
			for(int i = 0; i < prc.size(); i++) {
				int u = prc[i];
				for(auto c : pos[u]) {
					if(A[c.first][c.second] != A[(c.second + del) % N][(c.first - del + N) % N]) {
						ok = 0;
						break;
					}
				}
				if(ok == 0) {
					break;
				}
			}
			yo[del] = ok;
			yo[del + N] = ok;

			// ans += ok;
		}
	// }
	for(int a = 0; a < N; a++) {
		for(int b = 0; b < N; b++) {
			ans += yo[a + b];
		}
	}


	cout << ans << endl;
	cerr << "Time : " << (double)clock() / (double)CLOCKS_PER_SEC << "s\n";
    return 0;
}

Measured memory_bytes: 3200
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef string str;
#define rep(i, n) for(int i=0; i<n; ++i)
#define REP(i, n) for(int i=1; i<=n; ++i)
#define all(obj) (obj).begin(), (obj).end()
using P = pair<int, int>;
const int inf = 1e9;
const ll INF = 1e18;
const ll MOD = 1e9+7;
const ll MAX = 1e9+7;

int main(){
    int n, d; cin >> n >> d;
    int x, y;
    int ans = 0;
    rep(i, n){
        cin >> x >> y;
        if((double)sqrt(pow(x, 2) + pow(y, 2)) <= (double)d){
            ans += 1;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3684
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<bool> vb;
typedef vector<string> vs;
typedef vector<ll> vl;
typedef vector<vector<int, int> > vvi;
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define in insert
#define FOR(i,a,b) for (int i = a; i < b; i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const int INF = 1e9 + 5;
int main(){
    int x;
    cin >> x;
    if(x<1200) cout << "ABC";
    else cout << "ARC";
}

Measured memory_bytes: 256
N = int(input())
best_rank = 1000000000
best_score = 0
worst_rank = 0
worst_score = 0
for i in range(N):
    a, b = list(map(int, input().split()))
    if a < best_rank:
        best_rank, best_score = a, b
    if a > worst_rank:
        worst_rank, worst_score = a, b

print(worst_score+worst_rank)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define FIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define PI 3.141592653589793238462643383279502884L
#define make_unique(vec) vec.resize(distance(vec.begin(),unique(vec.begin(),vec.end())))
#define Sort(vec) sort(vec.begin(),vec.end())
#define RSort(vec) sort(vec.rbegin(),vec.rend())
#define endl "\n"
#define tr1(i) cout<<i<<endl;
#define tr2(i,j) cout<<i<<" "<<j<<endl;
#define tr3(i,j,k) cout<<i<<" "<<j<<" "<<k<<endl;
#define vvi vector<vector<int> > 
#define vvl vector<vector<ll> >
#define all(st) st.begin(),st.end()
#define vpl vector<pair<ll,ll> >
#define vpi vector<pair<int,int> >
#define pi pair<int,int>
#define pl pair<ll,ll>
#define al vector<list<int> >
#define vs vector<string>
#define vi vector<int>
#define vb vector<bool>
#define vl vector<ll>
#define vc vector<char>
#define rep(i,l,r) for(int i=l;i<r;i++)
#define repit(st) for(auto it=st.begin();it!=st.end();it++)
#define ull unsigned long long int
#define eb emplace_back
#define pb push_back
#define ll long long int
#define minf -(1e18)
#define inf 1e18
#define f first
#define se second
#define mod 1000000007
#define mx 500001
using namespace std;
ll mi(ll n,ll m){ll pw=n%m;ll ex=m-2;ll ans=1;while(ex){if(ex&1) ans = ans*pw%m;pw = pw*pw%m;ex>>=1;}return ans%mod;}
ll pw(ll a,ll n){ll pw=a%mod;ll ex=n;ll ans=1;while(ex){if(ex&1) ans = ans*pw%mod;pw = pw*pw%mod;ex>>=1;}return ans%mod;}
template<typename T>istream &operator>>(istream &is, vector<T> &v) { for (T &t : v) is >> t; return is; }
template<typename T>ostream &operator<<(ostream &os, const vector<T> &v) { for (const T &t : v) {os << t <<" ";} os << '\n'; return os; }
void show(ll x){cout<<x<<" ";}
ll gcd(ll a,ll b){return b==0?a:gcd(b,a%b);}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
ll max(ll a,ll b){return a>b?a:b;}
ll min(ll a,ll b){return a<b?a:b;}
ll Abs(ll x){return x>0?x:(-x);}
ll Ceil(ll a,ll b){return a/b+(a%b!=0);}
#define bs binary_search
#define lb lower_bound
#define mkp make_pair
//#define d double
void solve(){
	int n;
	cin>>n;
	vvi adj(n);vi deg(n);
	vpi ok;
	for(int i=0;i<n-1;i++){
		int x,y;
		cin>>x>>y;
		x--;y--;
		if(x>y) swap(x,y);
		ok.pb(mkp(x,y));
		adj[x].pb(y);
		adj[y].pb(x);
		deg[x]++;
		deg[y]++;
	}
	int ans=0;
	int ver;
	for(int i=0;i<n;++i){
		if(deg[i]>ans){
			ans=deg[i];
			ver=i;
		}
	}
	vi col(n);
	vb vis(n);
	map<pi,int> mp;
	col[ver]=-1;
	queue<int> q;
	q.push(ver);
	vis[ver]=true;
	while(!q.empty()){
		int x=q.front();
		q.pop();
		int c=1;
		for(int nbs:adj[x]){
			if(!vis[nbs]){
				if(c==col[x]) c++;
				col[nbs]=c;
				if(x<nbs) mp[mkp(x,nbs)]=col[nbs];
				else mp[mkp(nbs,x)]=col[nbs];
				q.push(nbs);
				vis[nbs]=true;
				c++;
			}
		}
	}
	cout<<ans<<endl;
	for(auto it:ok){
		cout<<mp[it]<<endl;
	}
		
	
	
	
	
	
}
int32_t main(){
FIO;
int t=1;
//cin>>t;
while(t--){
	solve();
}
}

Measured memory_bytes: 13944