akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
// #include <boost/multiprecision/cpp_int.hpp>
// using i128 = boost::multiprecision::int128_t;
#define _GLIBCXX_DEBUG
using namespace std;
using ll = long long;
using ld = long double;
using V = vector<int>;
using Vll = vector<ll>;
using Vld = vector<ld>;
using Vbo = vector<bool>;
using VV = vector<V>;
using VVll = vector<Vll>;
using VVld = vector<Vld>;
using VVbo = vector<Vbo>;
using VVV = vector<VV>;
using VVVll = vector<VVll>;
using P = pair<int, int>;
using Pll = pair<ll, ll>;
using Pld = pair<ld, ld>;
#define rep2(i, m, n) for(int i=int(m); i<int(n); ++i)
#define drep2(i, m, n) for(int i=int(m)-1; i>=int(n); --i)
#define rep(i, n) rep2(i, 0, n)
#define drep(i, n) drep2(i, n, 0)
#define all(a) a.begin(), a.end()
struct fast_ios { fast_ios(){ cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
template<typename T> inline int sz(T &x) { return x.size(); }
template<typename T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
template<typename T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
template<typename T1, typename T2> istream &operator>>(istream &is, pair<T1, T2> &p) { is >> p.first >> p.second; return is; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
template<typename T> istream &operator>>(istream &is, vector<T> &v) { for (auto &e : v) is >> e; return is; }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &v) { for (auto &e : v) os << e << " "; return os; }
template<typename T> inline int count_between(vector<T> &a, T l, T r) { return lower_bound(all(a), r) - lower_bound(all(a), l); } // [l, r)
inline int fLog2(const int x) { return 31-__builtin_clz(x); } // floor(log2(x))
inline int fLog2(const ll x) { return 63-__builtin_clzll(x); }
inline int cLog2(const int x) { return (x == 1) ? 0 : 32-__builtin_clz(x-1); } // ceil(log2(x))
inline int cLog2(const ll x) { return (x == 1) ? 0 : 64-__builtin_clzll(x-1); }
inline int popcount(const int x) { return __builtin_popcount(x); }
inline int popcount(const ll x) { return __builtin_popcountll(x); }
const int INF  = 1<<30;
const ll INFll = 1ll<<62;
const ld EPS   = 1e-10;
const ld PI    = acos(-1.0);
const int MOD  = int(1e9)+7;
// const int MOD  = 998244353;


int main() {
  ll n; cin >> n;

  ll ans = 0;
  ans += n;
  ans += n*n;
  ans += n*n*n;
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 3592
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<set>
#include<map>
#include<queue>
#define REP(i,a) for (int i = 0;i < (a);++i)
#define FOR(i,a,b) for (int i = (a);i < (b); ++i)
#define FORR(i,a,b) for (int i = (a);i >= (b); --i)
#define ALL(obj) (obj).begin,(obj).end()
#define SORT(list) sort(ALL((list)));
#define MOD 1000000007
using namespace std;
using ll = long long;
int main(){
    int n,m;
    cin >> n >> m;
    ll a[n],b[n];
    REP(i,n)cin >> a[i] >> b[i];
    ll c[m],d[m];
    REP(i,m)cin >> c[i] >> d[i];
    int cp[n];
    REP(i,n){
        ll min = 1000000000;
        REP(j,m){
            ll dist = abs(a[i]-c[j])+abs(b[i]-d[j]);
            if(min > dist){
                min = dist;
                cp[i] = j+1;
            }
        }
    }
    REP(i,n){
        cout << cp[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 256
l = map(int, raw_input().split())

if l[0] + l[1] > 2 * l[2]:
	if l[3] < l[4]:
		if (l[4] - l[3]) * l[1] < (l[4] - l[3]) * 2 * l[2]:
			print l[3] * 2 * l[2] + (l[4] - l[3]) * l[1]
		else:
			print l[4] * 2 * l[2]
	else:
		if (l[3] - l[4]) * l[0] < (l[3] - l[4]) * 2 * l[2]:
			print l[4] * 2 * l[2] + (l[3] - l[4])  * l[0]
		else:
			print l[3] * 2 * l[2]
else:
	print l[3] * l[0] + l[4] * l[1]


Measured memory_bytes: 2692
#include <stdio.h>
int main(){
	int a,b;
	scanf("%d %d", &a, &b);
	if(a!=1 && b!=1){
		printf("%d", 1);
	} else if(a!=2 && b!=2){
		printf("%d", 2);
	} else {
		printf("%d", 3);
	}
	return 0;
}

Measured memory_bytes: 3196
#include <bits/stdc++.h>
#define sz(v)   ((int)(v).size())
#define  all(v)    ((v).begin()),((v).end())
#define  allr(v)    ((v).rbegin()),((v).rend())
#define   pb         push_back
#define   mp         make_pair
#define  clr(v,val)      memset(v,val,sizeof(v))
#define    lcm(a,b)                ((a*b)/(__gcd(a,b)))
typedef  long long     ll ;
typedef  unsigned long long     ull ;
const double eps= (1e-9);
using namespace std;
int getBit(ll num, int idx) {return ((num >> idx) & 1ll) == 1;}
ll setBit1(ll num, ll idx) {return num | (1ll<<idx);}
ll setBit0(ll num, int idx) {return num & ~(1ll<<idx);}
ll flipBit(ll num, int idx) {return num ^ (1ll<<idx);}
int dcmp(long double a,long double b){   return fabsl(a-b)<=eps ? 0: (a>b)? 1:-1  ;}
void GO(){ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);}
const int N=500000+5,mod=1e9+7;
ll F[N],Iv_f[N];
ll power(ll b,ll p){

   if(p==0) return 1;
   if(p%2==0){
     return power((b%mod)*(b%mod)%mod,p/2);
   }
   else{
    return b%mod*power((b%mod)*(b%mod)%mod,p/2)%mod;
   }
}
ll P(ll n,ll r){
  if(n<r){
   // cout<<n<<" "<<r<<endl;
    return 0;
  }
  return F[n]*Iv_f[n-r]%mod;
}
ll C(ll n,ll r){
   if(n<r){
  //  cout<<n<<" "<<r<<endl;
    return 0;
   }
  return F[n]*Iv_f[n-r]%mod*Iv_f[r]%mod;
}
int main(){
    GO();
    int n,m;
    cin>>n>>m;
    F[0]=1;
    int lim=max(n,m);
    for(int i=1;i<=lim;i++){
        F[i]=(F[i-1]*i)%mod;
    }

    Iv_f[lim]=power(F[lim],mod-2);
    for(int i=lim-1;i>=0;i--){
        Iv_f[i]=(Iv_f[i+1]*(i+1))%mod;
    }


    //ll tot= cnt*cnt%mod;
    ll res= P(m,n)*P(m,n)%mod;
   // cout<<tot<<" "<<res<<endl;
    ll ans=0;
    for(int i=1;i<=n;i++){
        if(i%2!=0)
        ans+=P(m,i)*P(m-i,n-i)%mod*P(m-i,n-i)%mod*C(n,i)%mod;
        else
        ans-=P(m,i)*P(m-i,n-i)%mod*P(m-i,n-i)%mod*C(n,i)%mod;
    //    cout<<ans<<endl;
        ans+=mod;
        ans%=mod;
    }
   // cout<<ans<<endl;
    cout<<((res-ans)%mod+mod)%mod<<"\n";




}

























































































































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

#define ll long long
#define fornum(A,B,C) for(A=B;A<C;++A)
#define pii pair<int,int>
#define pll pair<ll,ll>

using namespace std;

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

ll D;
ll Dd;
ll Ddgt[50];
ll dp[50][10][10];
ll i, j, k,ans;

ll calc(ll ii,ll ba,ll bb,const ll& d){
    ll &dpa = dp[ii][ba][bb];
    if(dpa)
        return dpa - 1;
    dpa = 1;

    if(ii>=d/2){
        if(d%2==0){
            if(ba==bb){
                ++dpa;
            }
        }else{
            if(Ddgt[ii]==9&&ba==1&&bb==1)
                dpa += 10;
            if(Ddgt[ii]==0&&ba==0&&bb==0)
                dpa += 10;
        }
        return dpa - 1;
    }
    
    ll i = 0,ai,bi;
    fornum(i,(ii==0),10){
        fornum(ai,0,2){
            fornum(bi,0,2){
                ll ja = -10 * ba + i + Ddgt[d - 1 - ii] + ai;
                ll jb = 10 * bi + i - Ddgt[ii] - bb;
                if(ja<0||jb<0)
                    continue;
                if(ja==jb&&0<=ja&&jb<=9){
                    dpa += calc(ii + 1, ai, bi, d);
                }
            }
        }
    }
    return dpa - 1;
}
int main(){
    scanf("%lld", &D);

    j = 1;
    while(j<=D){
        Ddgt[Dd++] = D / j % 10;
        j *= 10;
    }
    fornum(i,Dd,Dd*2+1){
        fornum(j,0,30){
            dp[j][0][0] = dp[j][0][1] = dp[j][1][0] = dp[j][1][1] = 0;
        }
        ans += calc(0, 0, 0, i);
    }
    printf("%lld\n", ans);
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define int long long
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e18;

struct UF{
    vector<int> par, sz, cnt;
    UF(){}
    UF(int n):par(n), sz(n, 1), cnt(n, 0){
        iota(par.begin(), par.end(), 0);
    }
    int find(int x){
        if(x == par[x]) return x;
        return par[x] = find(par[x]);
    }
    void unite(int x, int y){
        x = find(x); y = find(y);
        cnt[x]++;
        if(x == y) return;
        if(sz[x] < sz[y]) swap(x, y);
        sz[x] += sz[y];
        cnt[x] += cnt[y];
        par[y] = x;
    }
    bool same(int x, int y){
        return find(x) == find(y);
    }
};

signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<int> y(n), x(n);
    rep(i, 0, n){
        cin >> y[i] >> x[i];
        y[i]--; x[i]--;
    }
    UF uf(200000);
    rep(i, 0, n){
        uf.unite(y[i], 100000 + x[i]);
    }
    int ans = 0;
    int cntx[200000] = {};
    int cnty[200000] = {};
    rep(i, 0, 100000){
        cnty[uf.find(i)]++;
    }
    rep(i, 100000, 200000){
        cntx[uf.find(i)]++;
    }
    rep(i, 0, 200000){
        if(cntx[i]){
            ans += cntx[i] * cnty[i] - uf.cnt[i];
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 9728
#include<bits/stdc++.h>
typedef long long int LL;
typedef long double dd; 
#define endl "\n"
int dx[4]={1,-1,0,0};
int dy[4]={0,0,-1,1};
LL dp[2000001];
LL mod=1e9+7;
using namespace std;
bool isPrime(LL n) {
  LL j; 
  for( j=2;j<=sqrt(n);j++){
    if(n%j==0){
      break;  
    } 
  }
  if(j>sqrt(n)){
    return 1; 
  }
  else{
    return 0; }
}
void solve(LL k){
LL n; 
cin>>n; 
LL a[n];
for(LL i=0;i<n;i++){
  cin>>a[i];
}
LL c=0;
for(LL i=1;i<n;i++){
  if(a[i]<a[i-1]){
    c+=(a[i-1]-a[i]);
    a[i]+=a[i-1]-a[i]; 
   // cout<<c<<endl; 
  }
}
cout<<c<<endl; 
 }
int main(){
  ios_base::sync_with_stdio(false);
    cin.tie(NULL);
 LL t=1;
//cin>>t;
 LL k=1;
while(k<=t){
   solve(k);
  k++;
  }
   return 0;
   }

Measured memory_bytes: 5228
n,m = map(int,input().split())
if(n%2 == 1):
    for i in range(m):
        print(i+1,n-1-i)
else:
    for i in range(m//2):
        print(i+1,n//2-1-i)
    for i in range((m+1)//2):
        print(n//2+1+i,n-i)

Measured memory_bytes: 9300
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define zero_pad(num) setfill('0') << std::right << setw(num)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;

int main() {
    int n;
    cin >> n;
    cout << 800 * n - (n / 15) * 200 << endl;
    
}

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

using namespace std;

#define INF ((1<<30)-1)  //int32_t
#define MOD 1000000007
#define MOD2 

#define all(a)  (a).begin(),(a).end()

#define mkp make_pair
#define pb push_back

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

int main(){

    bool flag=true;

    ll ans=0,sum=0;
    
    int n,k;
    cin >>n>>k;

    for (int i = 0; i < n; i++){
        int a;
        cin >>a;
        if(a >= k)++ans;
    }
    
    

    //cout <<fixed<<setprecision(16)<< << endl;
    cout << ans << endl;

    //if(flag)cout << "Yes" <<endl;
    //else cout << "No" <<endl;
    
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int i,j,k,l,m,n,o,p,q,r,s,t,u,v=9;
char c;
char a[200005];
int main()
{
	scanf("%s",a+1);
	for(i=1;a[i];i++)
	{
		s+=(a[i]-'0');
		if(s>=9)
			s%=9;
	}
	if(s==0)
		cout<<"Yes";
	else
		cout<<"No";
		return 0;
}

Measured memory_bytes: 3840
#coding:utf-8

def main():
    N = int(input())
    L = map(int, input().split())

    Llist = list(L)
    Llist.sort(reverse=True)
    numlist = []
#   print(Llist)

    for i in range(1,N):
        numlist.append(Llist[i])

    if Llist[0] < sum(numlist):
        print('Yes')
    else:
        print('No')

if __name__ == "__main__":
    main()

Measured memory_bytes: 3064
from operator import mul
from functools import reduce

def cmb(n,r):
    r = min(n-r,r)
    if r == 0: return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1,r + 1))
    return over // under


s= int(input())
box_max =s//3
ans =0
if box_max ==0:
  print(ans)
else:
  for i in range(1, box_max +1):
     ball_and_bar =(s-3*i)+i-1
     bar =i-1
     ans += cmb(ball_and_bar, bar)%(10**9 +7)
  print(ans%(10**9 + 7))

Measured memory_bytes: 9616
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
using namespace std;
int main(){
    string s;cin>>s;
    for(int i=1;i<s.size()-1;i++){
        if(s[i]==s[i-1]&&s[i]==s[i+1]){
            cout<<"Yes"<<endl;
            return 0;
        }
    }
    cout<<"No"<<endl;
}

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

int main(){
    int n;
    cin >> n;

    vector<int> a(n);
    vector<int> count(pow(10, 5));
    auto max_itr = count.begin();
    int max = 0;
    for (auto i = 0; i < n; i++) {
        cin >> a[i];
        count[a[i]]++;
        if(max < a[i]) {
            max = a[i];
            max_itr = next(count.begin(), a[i]);
        }
    }

    if(n == 1) {
        cout << 1 << endl;
        return 0;
    }
    if(distance(count.begin(), max_itr) <= 1){
        cout << accumulate(count.begin(), next(max_itr, 1), 0) << endl;
        return 0;
    }

    int tmp, ans = 0;
    for (auto itr = next(count.begin(), 1); itr < max_itr; itr++) {
        tmp = accumulate(prev(itr, 1), next(itr, 2), 0);
        if(tmp > ans) ans = tmp;
    }

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

Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>
#include <cmath>
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define per(i,a,b) for(int i=a;i>=b;i--)
using namespace std;
const int N=2e5+5;
struct edge{
	int v,Next;
}e[2][N<<2];
int head[2][N],cnt[2],n,dep[2][N],f[N][30],tot[2],rt[2],ans;
void addedge(int u,int v,int col){
	e[col][++cnt[col]].v=v;
	e[col][cnt[col]].Next=head[col][u];
	head[col][u]=cnt[col];
}
void dfs(int p,int fa,int type){
	if(type) rep(i,1,20) f[p][i]=f[f[p][i-1]][i-1];
	for(int ne=head[type][p];ne;ne=e[type][ne].Next){
		if(e[type][ne].v==fa) continue;
		if(type) f[e[type][ne].v][0]=p;
		dep[type][e[type][ne].v]=dep[type][p]+1;
		dfs(e[type][ne].v,p,type);
	}
}
int LCA(int u,int v){
	if(dep[1][u]<dep[1][v]) swap(u,v);
	per(i,20,0) if(dep[1][f[u][i]]>=dep[1][v]) u=f[u][i];
	if(u==v) return u;
	per(i,20,0) if(f[u][i]!=f[v][i]) u=f[u][i],v=f[v][i];
	return f[u][0]; 
}
void solve(int p,int fa){
	if(dep[0][p]>=dep[1][p]) return ;
	if(ans==-1) return ;
	ans=max(ans,(dep[1][p]-1)*2);
	for(int ne=head[0][p];ne;ne=e[0][ne].Next){
		if(e[0][ne].v==fa) continue;
		if(dep[1][p]+dep[1][e[0][ne].v]-2*dep[1][LCA(p,e[0][ne].v)]>2) return (void)(ans=-1);
		solve(e[0][ne].v,p);
	}
}
int main(){
	scanf("%d%d%d",&n,&rt[0],&rt[1]);
	dep[0][rt[0]]=1,dep[1][rt[1]]=1;
	rep(i,2,n){
		int u,v;
		scanf("%d%d",&u,&v);
		addedge(u,v,0);addedge(v,u,0);
	}
	rep(i,2,n){
		int u,v;
		scanf("%d%d",&u,&v);
		addedge(u,v,1);addedge(v,u,1);
	}
	dfs(rt[0],0,0);dfs(rt[1],0,1);
	ans=0; solve(rt[0],0);
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 49152
n=int(input())
a=[list(map(int,input().split())) for _ in range(n)]
x=y=t=0
ans='Yes'
for i in range(n):
  c=a[i]
  xy=c[1]+c[2]-(x+y)
  if xy>c[0]-t:
    ans='No'
    break
  else:
    if xy%2!=(c[0]-t)%2:
      ans='No'
      break
    elif abs(c[1]-x)+abs(c[2]-y)>c[0]-t:
      ans='No'
      break
  x=c[1]
  y=c[2]
  t=c[0]
print(ans)

Measured memory_bytes: 27276
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
using namespace std;
using Graph = vector<vector<int>>;
typedef pair<int,int> P;
typedef long long ll;
const int mod= 1e+9+7;

int main(){
  string s; cin>>s;
  ll K; cin>>K;
  if(s.size()==1){
    cout<<K/2<<endl;
    return 0;
  }
  vector<ll>a(110);
  char c;
  ll cnt;
  ll j=0;
  rep(i,s.size()){
    c=s[i];
    cnt=1;
    while(s[i+1]==c){
      cnt++;
      i++;
      if(i>=s.size()-1)break;
    }
    if(cnt>=2){
      a[j]=cnt;
      j++;
    }
  }
  ll sum=0;
  rep(i,j){
    sum+=a[i]/2;
}

ll b,d;
if(s[0]!=s[s.size()-1]){
  cout<<sum*K<<endl;
}
else{
  c=s[0];
    cnt=1;
    ll i=0;
    while(s[i+1]==c){
      cnt++;
      i++;
      if(i==s.size()-1)break;
    }
   b=cnt;

   i=s.size()-1;
    cnt=1;
    while(s[i-1]==c){
      cnt++;
      i--;
      if(i==0)break;
    }
   d=cnt;
   if(b+d>=s.size())cout<<(s.size()*K)/2<<endl;
   else cout<<sum*K-(K-1)*((b/2)+(d/2)-((b+d)/2))<<endl;
}

}



Measured memory_bytes: 256
#include <bits/stdc++.h>  // clang-format off
using Int = long long;
#define REP_(i, a_, b_, a, b, ...) for (Int i = (a), lim##i = (b); i < lim##i; i++)
#define REP(i, ...) REP_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
struct SetupIO { SetupIO() { std::cin.tie(nullptr), std::ios::sync_with_stdio(false), std::cout << std::fixed << std::setprecision(13); } } setup_io;
#ifndef _MY_DEBUG
#define dump(...)
#endif  // clang-format on

/**
 *    author:  knshnb
 *    created: Sun Apr 12 21:00:01 JST 2020
 **/

template <class T, class S> T make_vec(S x) { return x; }
template <class T, class... Ts> auto make_vec(size_t n, Ts... ts) {
    return std::vector<decltype(make_vec<T>(ts...))>(n, make_vec<T>(ts...));
}

signed main() {
    Int n;
    std::cin >> n;
    std::vector<Int> a(n);
    REP(i, n) std::cin >> a[i];
    if (n % 2 == 0) {
        auto dp = make_vec<Int>(n + 1, 2, 0);
        REP(i, n) {
            dp[i + 1][0] = dp[i][0] + (i % 2 ? 0 : a[i]);
            dp[i + 1][1] = std::max(dp[i][0], dp[i][1] + (i % 2 ? a[i] : 0));
        }
        std::cout << std::max(dp[n][0], dp[n][1]) << std::endl;
        return 0;
    }
    auto dp = make_vec<Int>(n + 1, 3, 0);
    REP(i, n) {
        dp[i + 1][0] = dp[i][0] + (i % 2 ? 0 : a[i]);
        dp[i + 1][1] = std::max(dp[i][0], dp[i][1] + (i % 2 ? a[i] : 0));
        dp[i + 1][2] = std::max({dp[i][1], dp[i][2] + (i % 2 || i == 0 ? 0 : a[i])});
    }
    std::cout << std::max({dp[n - 2][0], dp[n][1], dp[n][2]}) << std::endl;
}


Measured memory_bytes: 15872
import sys

# import math
import heapq

# input = sys.stdin.readline
from collections import deque


def main():
    N = int(input())
    X=[]
    Y =[]
    for i in range(N):
        x,y = map(int,input().split())
        X.append(x)
        Y.append(y)
    ans =0

    for i in range(N):
        for j in range(N):
            if i==j:
                continue
            ans += ((X[i]-X[j])**2 + (Y[i]-Y[j])**2 )**0.5

    print(ans/N)




if __name__ == "__main__":
    main()


Measured memory_bytes: 65484
#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 repr(i, a, b) for(int i = a; i >= b; i--)
#define _GLIBCXX_DEBUG
#define Vl vector<ll>
#define Vs vector<string>
#define Vp vector<pair<ll, ll>>
#define ld long double
using ll = long long;
#define ALL(v) (v).begin(),(v).end()
#define endl "\n"
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define co(x) cout << x << endl
#define coel cout << endl
#define pb push_back
#define sz(v) ((ll)(v).size())
using namespace std;  
const double pi = acos(-1.0);
const ll MOD = 1e9 + 7;
const ll INF = 1LL << 60;
// const ll INF = 1LL << 30;
#define pp pair<ll, pair<ll, ll>> 
#define fi first
#define se second

void print(Vl vec){
    rep(i, 0, sz(vec)){
        if(i) cout << " ";
        cout << vec[i];
    }
    coel;
}

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

int main() {
    ll n; cin >> n;
    Vl a(n);
    rep(i, 0, n) cin >> a[i];
    ll ans = 0;
    rep(i, 0, n) ans ^= a[i];
    rep(i, 0, n){
        ll rec = ans ^ a[i];
        if(i) cout << " ";
        cout << rec;
    }
    coel;

    return 0;
}


Measured memory_bytes: 4836
#include <bits/stdc++.h>
using namespace std;
#define int long long 
const int N = 1e5 + 5, INF = 0x3f3f3f3f;
inline int read() {
	int x = 0, f = 0; char ch = 0;
	while (!isdigit(ch)) f |= ch == '-', ch = getchar();
	while (isdigit(ch)) x = (x << 3) + (x << 1) + (ch ^ 48), ch = getchar();
	return f ? -x : x;
}
int a[N], b[N], c[N];
signed main() {
	int A = read(), B = read(), m = read();
	int mina = INF, minb = INF;
	//cout << INF << endl;
	for (int i = 1; i <= A; i++) a[i] = read(), mina = min(mina, a[i]);
	for (int i = 1; i <= B; i++) b[i] = read(), minb = min(minb, b[i]);
	int ans = mina + minb;
	while (m--) {
		int x = read(), y = read(), c = read();
		ans = min(ans, a[x] + b[y] - c);
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 1792
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		char c[] = s.toCharArray();
      int n = 700;
for(int i=0;i<=2;i++){
if(c[i]=='o'){
n=n+100;
}
}
      
System.out.println(n);
	}}


Measured memory_bytes: 23892
#!/usr/bin/env python3

MOD = 10 ** 9 + 7

def main():
    n, k = map(int, input().split())
    adj = [[] for i in range(n)]
    for i in range(n - 1):
        a, b = map(int, input().split())
        a -= 1
        b -= 1
        adj[a].append(b)
        adj[b].append(a)
    res = k
    stack = [0]
    visited = [False for i in range(n)]
    while stack:
        i = stack.pop()
        visited[i] = True
        children = [x for x in adj[i] if not visited[x]]
        res *= perm((k - 1 if i == 0 else k - 2), len(children))
        res %= MOD
        for c in children:
            stack.append(c)
    print(res)

def perm(t, s):
    if s > t:
        return 0
    res = 1
    for i in range(s):
        res *= t
        res %= MOD
        t -= 1
    return res

if __name__ == "__main__":
    main()


Measured memory_bytes: 24432
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
typedef long long LL;
int main(){
        LL N;
        cin>>N;
        REP(i,N){
            vector<int>v;
            int a,b,c;
            cin>>a>>b>>c;
            v.push_back(a);
            v.push_back(b);
            v.push_back(c);
            sort(v.begin(),v.end());
            if(v[0]*v[0]+v[1]*v[1]==v[2]*v[2]){
               cout<<"YES"<<endl;
            }else{
               cout<<"NO"<<endl;
            }
        }
	return(0);
}

Measured memory_bytes: 3136
// #include "pch.h"
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <bitset>
#include <climits>
#include <string>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>
#include <ctime>
#include <cassert>
#include <fstream>
#include <stack>
#include <random>

typedef long long ll;
typedef std::pair<int, int> Pii;
typedef std::pair<long long, long long> Pll;
typedef std::pair<double, double> Pdd;

#define rip(i, n, s) for (int i = (s);i < (int)( n ); i++)
#define all(a) a.begin(), a.end()
#define MM << " " <<

template<typename T>
using MaxHeap = std::priority_queue<T>;
template<typename T>
using MinHeap = std::priority_queue<T, std::vector<T>, std::greater<T>>;

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

template<typename T>
void vdeb(std::vector<T> &da) {
    for (int i = 0;i < da.size();i++) {
        if (i == da.size() - 1) std::cout << da[i];
        else std::cout << da[i] << ' ';
    }
    std::cout << '\n';
}
template<typename T>
void vdeb(std::vector<std::vector<T>> &da) {
    for (int i = 0;i < da.size();i++) {
        std::cout << i << ' ';
        vdeb(da[i]);
    }
    std::cout << '\n';
}

using namespace std;

int main() {
    int n; cin >> n;
    vector<ll> da(n);
    rip(i,n,0) cin >> da[i];
    int q; cin >> q;
    vector<ll> ans(q);
    ll su = 0;
    map<ll, int> mp;
    rip(i,n,0) {
        su += da[i];
        if(mp.count(da[i])) mp[da[i]]++;
        else mp[da[i]] = 1;
    }
    rip(i,q,0) {
        ll b, c; cin >> b >> c;
        if(mp.count(b)) {
            su += mp[b] * (c-b);
            if(mp.count(c)) {
                mp[c] += mp[b];
            }
            else {
                mp[c] = mp[b];
            }
            mp.erase(b);
        }
        ans[i] = su;
    }
    rip(i,q,0) printf("%lld\n", ans[i]);
}

Measured memory_bytes: 8728
#include <bits/stdc++.h>
#define Int int64_t

using namespace std;

int main() {
	int N, Q;
	string s;
	cin >> N >> s >> Q;
	vector<int> K(Q);
	for (int i = 0; i < Q; ++i) { cin >> K[i]; }

	s = "#" + s;
	vector<Int> cntD(N + 1, 0);
	vector<Int> cntM(N + 1, 0);
	for (int i = 1; i <= N; ++i) {
		if (s[i] == 'D') { ++cntD[i]; }
		if (s[i] == 'M') { ++cntM[i]; }
		cntD[i] += cntD[i - 1];
		cntM[i] += cntM[i - 1];
	}

	auto DMC = [&](int k) -> Int {
		int l = 0, r = 1;
		Int ret = 0, sum = 0;
		while (l < r && r <= N) {
			while (r <= N && s[r] != 'C') {
				if (s[r] == 'M') { sum += cntD[r]; }
				++r;
			}
			while (r - l - 1 >= k && l <= N) {
				++l;
				if (s[l] == 'M') { sum -= cntD[l]; }
			}
			if (r > N || l > N) { break; }
			ret += sum - cntD[l] * (cntM[r] - cntM[l]);
			++r;
		}
		return ret;
	};

	for (int k : K) { cout << DMC(k) << endl; }

	return 0;
}


Measured memory_bytes: 20068
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <map>

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

vector<ll> fac(200010);
vector<ll> ifac(200010);

ll mpow(ll x,ll n){
    ll ret = 1;
    while(n != 0){
        if(n&1) ret = ret*x % mod;
        x = x * x % mod;
        n = n >> 1;
    }
    return ret;
}

ll comb(ll a, ll b){
    if(a == 0 && b == 0)return 1;
    if(a < b || a < 0) return 0;
    ll tmp = ifac[a-b] * ifac[b] % mod;
    return tmp * fac[a] % mod;
}

int main(){
    ll n,k;
    cin >> n >> k;
    ll ans = 0;

    fac[0] = 1;
    ifac[0] = 1;
    for(ll i = 0; i < 200008; i++){
        fac[i+1] = fac[i] * (i+1) % mod;
        ifac[i+1] = ifac[i]*mpow(i+1,mod-2) % mod;
    }
    
    for(ll i = 0; i < min(n,k+1); i++){
        ll tmp = (comb(n,i) * comb(n-1,n-i-1)) % mod;
        ans = (ans + tmp) % mod;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 6292
import sys
x,y = list(input().split())
judge = 0
x = x.translate(str.maketrans({"3":"1","5":"1","7":"1","8":"1","6":"4","9":"4"}))
y = y.translate(str.maketrans({"3":"1","5":"1","7":"1","8":"1","6":"4","9":"4"}))
x = x.replace("10", "1").replace("12", "1").replace("11","4")
y = y.replace("10", "1").replace("12", "1").replace("11","4")

print("Yes" if x == y else "No")



Measured memory_bytes: 3064
n = int(input())
frame_list = list(map(int,input().split()))
frame_mean = sum(frame_list)/len(frame_list)
outcome = 200
count = 0

for i in range(n):
    if abs(frame_mean - frame_list[i]) < outcome:
        outcome = abs(frame_mean - frame_list[i])
        count = i

print(count)


Measured memory_bytes: 3060
def solve():
    V, E = map(int, input().split())
    edges = [[] for _ in [0]*V]
    for _ in [0]*E:
        s, t, d = map(int, input().split())
        edges[s].append((t, d))

    result = float("inf")
    beam_width = 70
    for i in range(V):
        q = [(0, i, {i})]
        for j in range(V-1):
            _q = []
            append = _q.append
            for cost, v, visited in q[:beam_width+1]:
                for dest, d_cost in edges[v]:
                    if dest not in visited:
                        append((cost+d_cost, dest, visited | {dest}))
            q = sorted(_q)
        for cost, v, visited in q[:beam_width+1]:
            for dest, d_cost in edges[v]:
                if dest == i:
                    if result > cost + d_cost:
                        result = cost + d_cost
                        break

    print(result if result < float("inf") else -1)


if __name__ == "__main__":
    solve()

Measured memory_bytes: 8704
#include <bits/stdc++.h>
using namespace std;
int time(vector<int> data){
    int time = 0;
    for (int i = 0; i < 5; i++){
        while(!(time % 10 == 0)){
            time ++;
        }
        time += data.at(i);
    }
    return time;
}
int main(){
    vector<int> data(5);
    vector<int> tempdata(5);
    vector<int> timer(120);
    vector<int> next(5);
    for (int i = 0; i < 5; i++){
        cin >> data.at(i);
        tempdata.at(i) = data.at(i);
        next.at(i) = i;
    }
    int i=0;
    do {
        for (int j = 0; j < 5; j++){
            data.at(j) = tempdata.at(next.at(j));
        }
        timer.at(i) = time(data);
        i++;
    } while (next_permutation(next.begin(), next.end()));
    sort(timer.begin(), timer.end());
    cout << timer.at(0) << endl;
}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i < (int)(n); i++)
typedef long long ll;

int main() {
    int a,b,c; cin >> a >> b >> c;
    bool ans = false;
    rep1(i,b+1){
        int A = a*i;
        if(A % b == c) ans = true;
       
    }
    if(ans) cout << "YES" << endl;
    else cout << "NO" << endl;
} 

Measured memory_bytes: 256
using System;
using System.Diagnostics;
using System.IO;
using System.Text;
using System.Linq;
using System.Collections.Generic;

class Program
{
    static void Main(string[] args) {
#if DEBUG
        MyDebugger.Test(process, "../TextFile1.txt");
        //MyDebugger.Test(process, "../TextFile2.txt");
        //MyDebugger.MakeTestCase("../TextFile2.txt");
#else
        object ret = process(new StreamReader(Console.OpenStandardInput()));
        Console.WriteLine(ret);
#endif
    }

    static void WriteLine(object obj) {
#if DEBUG
        Debug.WriteLine(obj.ToString());
#else
        Console.WriteLine(obj.ToString());
#endif
    }

    static object process(TextReader input) {
        var n = int.Parse(input.ReadLine());
        var aa = ToIntArray(input.ReadLine(), n);

        
        while (true) {
            var min = GetMin(aa);
            var c = 0;
            for(int i=0; i<n; i++) {
                if(i != min && aa[i] > 0) {
                    aa[i] %= aa[min];
                    c++;
                }
            }
            if (c == 0) return aa[min];
        }
    }

    static int GetMin(int[] aa) {
        var min = int.MaxValue;
        var ii = -1;

        for (int i=0; i<aa.Length; i++) {
            if (aa[i] != 0 && aa[i] < min) {
                min = aa[i];
                ii = i;
            }
        }
        return ii;
    }

    static int[] ToIntArray(string strs, int n) {
        var ret = new int[n];
        var spl =strs.Split(' ');
        for (int i = 0; i < n; i++)
            ret[i] = int.Parse(spl[i]);
        return ret;
    }
}

Measured memory_bytes: 18528
import java.util.*;
import java.lang.*;
import java.io.*;

class Main
{
	public static void main (String[] args) throws java.lang.Exception
	{
		String nl = System.getProperty("line.separator");
		StringBuilder p = new StringBuilder(500);
		Scanner r = new Scanner(System.in);
		int h, w, i, j;
		while ((h = r.nextInt()) + (w = r.nextInt()) > 0) {
			for (i = h; i > 0; --i) {
				for (j = w; j > 0; --j) {
					if ((i == h)||(j == w)||(j == 1)||(i == 1)) {
						p.append('#');
					} else {
						p.append('.');
					}
				}
				p.append(nl);
			}
			p.append(nl);
		}
		System.out.print(p);
	}
}

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

int main() {
	int n, r, p, c, i, ans;
	
	while (cin >> n  && cin >> r) {
		int Deck[51];

		if (n == 0 && r == 0) {
			break;
		}

		for (i = 0; i < n; i++) {
			Deck[i] = n-i;
		}

		for (i = 0; i < r; i++) {
			cin >> p; cin >> c;

			rotate(Deck, Deck + p - 1, Deck + p + c - 1);
		}

		cout << Deck[0] << endl;
	}
}

Measured memory_bytes: 1188
import static java.util.function.Function.*;
import static java.util.stream.Collectors.*;

import java.util.*;

public class Main {
    public void main(Scanner sc) {
        int n = sc.nextInt();
        int a = sc.nextInt();
        int b = sc.nextInt();
        Long v[] = new Long[n];
        for (int i = 0; i < n; i++) {
            v[i] = sc.nextLong();
        }

        Arrays.sort(v, (o1, o2) -> Long.compare(o2, o1));
        Long sum[] = new Long[n];
        sum[0] = v[0];
        for (int i = 1; i < n; i++) {
            sum[i] = sum[i - 1] + v[i];
        }
        Map<Long, Long> map = Arrays.stream(v).collect(groupingBy(identity(), counting()));

        long max = 0;
        long select = 1;
        long cnt = 0;
        for (int i = a; i <= b; i++) {
            if (max * i <= sum[i - 1] * select) {
                if (max * i == sum[i - 1] * select) {
                    cnt += calc(i, v, map);
                } else {
                    cnt = calc(i, v, map);
                }
                max = sum[i - 1];
                select = i;
            }
        }

        System.out.println(String.format("%f", (max * 1.0 / select)));
        System.out.println(cnt);
    }

    private long calc(int cnt, Long v[], Map<Long, Long> map) {
        long nowv = v[cnt - 1];
        long all = map.get(nowv);
        long now = 0;
        while ((now + cnt) < v.length && v[(int) (now + cnt)] == nowv) {
            now++;
        }

        if (all / 2 < now) {
            now = all - now;
        }

        long ans = 1;
        for (long i = 0; i < now; i++) {
            ans *= (all - i);
            ans /= (i + 1);
        }

        return ans;
    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        new Main().main(sc);
        sc.close();
    }
}


Measured memory_bytes: 29396
N = int(input())
if N < 105:
	print(0)
else:
	if N < 135:
		print(1)
	else:
		if N < 165:
			print(2)
		else:
			if N < 189:
				print(3)
			else:
				if N < 195:
					print(4)
				else:
					print(5)

Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
// #include <ext/pb_ds/assoc_container.hpp> 
// #include <ext/pb_ds/tree_policy.hpp> 
// using namespace __gnu_pbds;   
#define ll long long
#define ull unsigned long long
// #define ordered_set tree<pair<ll, ll>, null_type, less<pair<ll, ll>>, rb_tree_tag, tree_order_statistics_node_update> 
ll mod=1e9+7;
#define PI 3.1415926535897932385
#define inf 9e18
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
string char_to_str(char c){string tem(1,c);return tem;}
typedef pair<long long, long long> ii;
#define S second
#define F first
ll max(ll a,ll b){if(a>b){return a;}return b;}
ll min(ll a,ll b){if(a<b){return a;}return b;}
#define MAXN 200005
// Comment this out for interactice problem
// #define endl '\n'
// string to integer stoi() Remember: it takes string not character
// string to long long stoll()
// string.substr(position,length);
// integer to string to_string();
 
// To compile--> g++ -std=c++0x -o output one.cpp
// To run--> ./output

int main()
{ 
    fastio;
    // freopen("input.txt","r",stdin);
    // freopen("output.txt","w",stdout);

    string s;
    cin>>s;
    ll max1=0;
    ll curr=0;
    for (int i = 0; i < s.length(); ++i)
    {
        if(s[i]=='R'){
            curr++;
        }
        else{
            max1=max(max1, curr);
            curr=0;
        }
    }
    max1=max(max1, curr);
    cout<<max1;

    return 0;
}

Measured memory_bytes: 3632
// Bismillaahirrahmaanirrahiim
/* Author	: Jehian Norman Saviero (@Reiva5) */
#include <bits/stdc++.h>

/* MACROS SAMPAH */
#define jehian using
#define mau namespace
#define libur std
#define cepet {ios_base::sync_with_stdio(0);cin.tie(0);}

jehian mau libur;
/* MACROS FOR TYPE */
typedef long l;
typedef long double ld;
typedef long long ll;
typedef unsigned long ul;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<l> vl;
typedef vector<ll> vll;
typedef pair<int, int> pi;
typedef pair<l,l> pl;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pld;

/* MACROS FOR PRINT */
#define nl printf("\n");
#define sp printf(" ");

/* MACROS FOR FUNCTION AND METHOD */
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define mp make_pair
#define eb emplace_back
#define RESET(x) memset((x), 0, sizeof(x))
#define SET(x,y) for(int _je = sizeof(x)/sizeof(x[0]); _je--;) x[_je] = y

/* MACROS FOR ATTRIBUTE */
#define fi first
#define se second

/* MACROS FOR SCAN */
#define scc(x) scanf("%c", &x)
#define scd(x) scanf("%Lf", &x)
#define scf(x) scanf("%f", &x)
#define sci(x) scanf("%d", &x)
#define scl(x) scanf("%ld", &x)
#define scll(x) scanf("%lld", &x)
#define scld(x) scanf("%Lf", &x)
#define scui(x) sci(x)
#define scul(x) scl(x)
#define scull(x) scll(x)
#define special pair<ll,pll>

string A, B;
vector<string> solution;
bool same(string x, string y){
	for (ll i = 0; i < x.size(); ++i){
		if (x[i] != y[i] && x[i] != '?'){
			return false;
		}
	}
	return true;
}

string tmp;
int main(){
	cin >> A >> B;
	for (ll i = 0; i <= (ll) A.size() - (ll) B.size(); ++i){
		if (same(A.substr(i,B.size()),B)){
			tmp = A;
			for (ll j = 0; j < A.size(); ++j){
				if (tmp[j] == '?'){
					tmp[j] = 'a';
				}
			}
			for (ll j = 0; j < B.size(); ++j){
				tmp[i+j] = B[j];
			
			}
			solution.pb(tmp);
		}
	}
	if (solution.size()){
		sort(solution.begin(),solution.end());
		cout << solution[0] << endl;
	} else {
		cout << "UNRESTORABLE" << endl;
	}
	return 0;
}

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

int main(int argc, char *argv[])
{
    int A, B;
    std::cin >> A >> B;

    int add = A + B;
    int sub = A - B;
    int mul = A * B;

    int ans = 0;

    if (add < sub) {
        ans = sub;
        if (sub < mul) {
            ans = mul;
        }
    } else {
        ans = add;
        if (add < mul) {
            ans = mul;
        }
    }

    std::cout << ans << std::endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
vector<int> e[100010];
int cnti,cntb,cntr;
int vis[100010];

bool dfs(int x,int c){
	vis[x]=c;
	bool res = true;
	for(int it:e[x])
		if(vis[it]){
			if(vis[x]+vis[it]!=3)
				res=false;
		}
		else
			res&=dfs(it,3-c);
	return res;
}

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n,m;
	cin>>n>>m;
	for(int i=1,u,v;i<=m;i++)
		cin>>u>>v,e[u].emplace_back(v),e[v].emplace_back(u);
	for(int i=1;i<=n;i++)
		if(!vis[i]){
			if(e[i].size()==0)
				cnti++;
			else if(dfs(i,1))
				cntb++;
			else
				cntr++;
		}
	long long int ans = 0;
	ans = 1LL*cnti*cnti+2LL*cnti*(n-cnti)+2LL*cntb*cntb+2LL*cntb*cntr+1LL*cntr*cntr;
	cout<<ans<<endl;
}


Measured memory_bytes: 10880
#include <iostream>
#include <algorithm>
#include <cmath>
#include <map>
#include <vector>
#include <queue>
#include <functional>
#include <string>
#include <stack>
#include <set>
#include <sstream>
#include <iomanip>
#include <limits>
#include <cstring>

using namespace std;
using ll = long long;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<string, string> sP;
typedef pair<ll, pair<ll, ll>> PP;

const ll mod = 1e4;
const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll INF = 1 << 30;
const ll INF2 = 9e18;
const double INF3 = 9e14;
const int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
const int tx[8] = { -1,0,1,-1,1,-1,0,1 }, ty[8] = { -1,-1,-1,0,0,1,1,1 };
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define pb push_back
#define eb emplace_back
#define fr first
#define sc second



int main() {
	ll n, a[200010], rui[200010] = { 0 }, ans = INF2;
	cin >> n;
	for (int i = 0;i < n;i++) {
		cin >> a[i];
		rui[i + 1] = rui[i] + a[i];
	}
	for (int i = 2;i <= n - 1;i++) {
		int l = 1, r = i - 1, mid;
		while (r - l > 1) {
			mid = (r + l) / 2;
			if (rui[i] - rui[mid] < rui[mid])r = mid;
			else l = mid;
		}
		int p = l, q = r;
		l = i + 1, r = n;
		while (r - l > 1) {
			mid = (r + l) / 2;
			if (rui[n] - rui[mid] < rui[mid] - rui[i])r = mid;
			else l = mid;
		}
		int ppp = l, qqq = r;
		ll P = rui[q], Q = rui[i] - rui[q], R = rui[qqq] - rui[i], S = rui[n] - rui[qqq], pp = rui[p], qq = rui[i] - rui[p], rr = rui[ppp] - rui[i], ss = rui[n] - rui[ppp];
		ans = min(ans, max({ P,Q,R,S }) - min({ P,Q,R,S}));
		ans = min(ans, max({ pp,qq,R,S }) - min({ pp,qq,R,S }));
		ans = min(ans, max({ P,Q,rr,ss }) - min({ P,Q,rr,ss }));
		ans = min(ans, max({ pp,qq,rr,ss }) - min({ pp,qq,rr,ss }));
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3328
#include <iostream>
#include <vector>
using namespace std;
int main(void){
    int n;
    cin >> n;
    vector<int> p(n, 0), pos(n, 0);
    for(int i=0;i<n;i++) cin >> p[i];
    for(int i=0;i<n;i++) pos[--p[i]] = i;
    
    int ans = 1, str = 1;
    for(int i=1;i<n;i++){
        if(pos[i-1] <= pos[i]) str++;
        else str = 1;
        if(ans < str) ans = str;
    }
    cout << n-ans << endl;
}


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

int main(){
  string S;
  cin >> S;
  
  string before="ATGC";
  string after="TACG";
  map<char, char> m;
  
  for (int i=0;i<before.size();i++){
    m[before[i]] = after[i];
  }
  
  char ans=m[S[0]];//変換
  
  cout << ans << endl;
}
//直大さんの別解その2
    


Measured memory_bytes: 256
#include <stdio.h>

int binarysearch(int key,int S[],int n){
  int i,left=0,right=n,mid;
  while(left < right){
    mid = (left + right) / 2;
    if(S[mid] == key)
      return 1;
    else if(key < S[mid])
      right = mid;
    else left = mid + 1;
  }
  return 0;
}

int main(){
  int i,n,S[1000000],q,T[50000],ans=0;

  scanf("%d",&n);

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

  for(i=0;i<q;i++){
    scanf("%d",&T[i]);
  }
  
  for(i=0;i<q;i++){
    if(binarysearch(T[i],S,n) == 1)
      ans++;
  }
  printf("%d\n",ans);
  return 0;
}



Measured memory_bytes: 2388
n = gets.split.map(&:to_i)
a = []
b = []
n[0].times do
	a << gets.chomp!.split('').map(&:to_s)
end

n[1].times do
	b << gets.chomp!.split('').map(&:to_s)
end

ans = false
(n[0] - n[1] + 1).times do |i|
	(n[0] - n[1] + 1).times do |l|
		dt = true
		n[1].times do |j|
			n[1].times do |k|
				if	b[j][k] != a[j + i][k + l]
					dt = false
				end
			end
		end
		if dt
			ans = true
			break
		end
	end
	if ans
		break 
	end
end

if ans 
	puts "Yes"
else
	puts "No"
end

Measured memory_bytes: 1916
package main

import (
	"fmt"
	"math"
)

func main() {
	var a, b, x int
	fmt.Scanf("%d %d %d", &a, &b, &x)

	if x*2 <= a*a*b {
		fmt.Println(math.Atan(float64(b*b*a)/float64(x)/2) * 180.0 / math.Pi)
	} else {
		fmt.Println(math.Atan(float64(2*(a*a*b-x))/float64(a*a*a)) * 180 / math.Pi)
	}
}


Measured memory_bytes: 1840
def dec26(X, n):
    if (int(X/n)):
        return dec26(int(X/n)-1, n)+chr(X % n + 97)
    return chr(X % n + 97)


def main():
    n = int(input())
    x2 = dec26(n-1, 26)
    print(x2)


main()


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

int n, vis[101010];
vector<pair<int, int> > v;
long long mx, my, Ans;

int main(void) {
  scanf("%d", &n);
  for(int i = 1, x, y; i <= n; i++) {
    scanf("%d%d", &x, &y);
    mx += x;
    my += y;
    v.push_back({x, i});
    v.push_back({y, i});
  }
  
  sort(v.begin(), v.end());
  bool flg = 0;
  for(int i = 0; i < n; i++) {
    Ans += v[i].first;
    if(vis[v[i].second]) flg = 1;
    else vis[v[i].second] = 1;
  }
  if(!flg) {
    if(v[n].second == v[n - 1].second) 
      Ans = min(Ans - v[n - 1].first + v[n + 1].first,
		Ans - v[n - 2].first + v[n].first);
    else Ans = Ans - v[n - 1].first + v[n].first;
  }
  cout << min(Ans, min(mx, my)) << endl;
  return 0;
}


Measured memory_bytes: 2420
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
int main()
{
    char str1[100],str2[100],str3[100];
    cin>>str1;
    cin>>str2;
    int ln1,ln2,i,k=0;
    ln1=strlen(str1);
    ln2=strlen(str2);
    sort(str1,str1+ln1);
    sort(str2,str2+ln2);
    for(i=ln2-1;i>=0;i--){
        str3[k]=str2[i];
        k++;
    }
    str3[k]='\0';
    //cout<<str1<<" "<<str3<<endl;
    if(strcmp(str1,str3)<0){
        cout<<"Yes"<<endl;
    }
    else{
        cout<<"No"<<endl;
    }
    return 0;

}


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

int main()
{
  long long int a,b,c,d;
  cin>>a>>b>>c>>d;
  long long int ans1=a*d;
  long long int ans2=a*c;
  long long int ans3=b*c;
  long long int ans4=b*d;
  cout<<max(ans1,max(ans2,max(ans3,ans4)))<<endl;
}

Measured memory_bytes: 3156
#include<stdio.h>
int main()
{
    int A,B,C,D,x,y,z;
    scanf("%d %d %d %d",&A,&B,&C,&D);

    x=A*B;
    y=C*D;
    z=x;
    if(x>y)
        printf("%d\n",x);
    else if(x<y)
        printf("%d\n",y);
    else
        printf("%d\n",z);
    return 0;

}


Measured memory_bytes: 128
def gcd(x, y):
    while (y):
        x, y = y, x % y
    return x

k = int(input())
sm = 0
for i in range(1,k+1):
    for j in range(1,k+1):
        for w in range(1,k+1):
            sm += gcd(gcd(i,j),w)
print(sm)

Measured memory_bytes: 73884
#include<bits/stdc++.h>
#define LL long long
#define P 1000000007
#define M 1000005
using namespace std;  
LL A,B,C,D,E;
LL gcd(LL n,LL m){
	return m?gcd(m,n%m):n;
}
LL solve(LL n){
	if(n==0)return 0;
	return n/C+n/D-n/E; 
}

int main(){ 
	cin>>A>>B>>C>>D;
	E=C/gcd(C,D)*D;
	//cout<<E<<endl;
	cout<<(B-A+1)-(solve(B)-solve(A-1))<<endl;
		
	return 0;
}

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


int main(void){
    int N, D;
    cin >> N >> D;
    vector<vector<int>> vec(N, vector<int>(D));
    
    for (int i = 0; i < N; i++) {
        
        for (int j = 0; j < D; j++) {
            cin >> vec[i][j];
            
        }
    }
    
    
    double distance;
    int dis2;
    int count = 0;
    for (int i = 0; i < N - 1; i++) {
        for (int j = i + 1; j < N; j++) {
            distance = 0;
            for (int z = 0; z < D; z++) {
                distance += pow(vec[i][z] - vec[j][z], 2);
            }
            
            distance = pow(distance, 0.5);
            
            dis2 = distance;
            
            if (distance == dis2) {
                count++;
            }
        }
    }
    cout << count << endl;
    
    return 0;
}

Measured memory_bytes: 256
N, M, P = map(int, input().split())
edge = []

for i in range(M):
    A, B, C = map(int, input().split())
    edge.append((A, B, P-C))

inf = float('inf')
cost = [inf] * (N+1)
cost[1] = 0
for i in range(N-1):
    for e in edge:
        a, b, c = e
        if cost[a] + c < cost[b]:
            cost[b] = cost[a] + c

for e in edge:
    a, b, c = e
    if cost[a] + c < cost[b]:
        cost[b] = -inf
            
for i in range(N-1):
    for e in edge:
        a, b, c = e
        if cost[a] + c < cost[b]:
            cost[b] = -inf
        if cost[b] == -inf and b == N:
            print(-1)
            exit()
                        

print(max(-cost[N], 0))



        


Measured memory_bytes: 50412
N,M,X = map(int, input().split())
li = list(map(int, input().split()))
a = 0
nu = 0
for i in range(1,X):
    if i == li[nu]:
        a += 1
        nu += 1
    if nu == len(li):
        break
b = len(li) - a
if a > b:
    print(b)
else:
    print(a)

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

namespace AtCoder_ABC089_A
{
    class Program
    {
        static void Main(string[] args)
        {
            int day = int.Parse(Console.ReadLine());

            int count = 25 - day;

            string str = "Christmas";

            for (int i = 0; i < count; ++i)
            {
                str += " Eve";
            }

            Console.WriteLine(str);
        }
    }
}


Measured memory_bytes: 11092
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <set>
using namespace std;
using Data = pair<long long, vector<int> >;

int main() {
  int M, D; cin >> M >> D;
  int res = 0;
  for(int m = 1; m <= M; m++){
    for(int d = 1; d <= D; d++){
      if(d%10 > 1 && d/10>1 && (d%10)*(d/10) == m) res++;
    }
  }
  cout << res << endl;
}


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

using namespace std;

typedef long long ll;

const ll MOD = (ll) 1e9 + 7;

int main() {
    int n;
    string s;
    cin >> n >> s;

    map<int, ll> mp;
    for (int i = 0; i < n; ++i) {
        ++mp[s[i] - 'a'];
    }

    ll ans = 1;
    for (auto i : mp) {
        if (i.second == 1) (ans *= 2) %= MOD;
        else (ans *= (i.second + 1)) %= MOD;
    }

    cout << ans - 1 << endl;
}

Measured memory_bytes: 512