akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <math.h>
#define _GLIBCXX_DEBUG
#define _LIBCPP_DEBUG 0

using namespace std;
#define ll long long
#define rep(i,n) for (int i = 0; i < n; i++)
#define rrep(i,n) for (int i = n-1; i >= 0; i--)
#define MOD (1000000007)
#define vi vector<int>
#define vl vector<ll>
#define vb vector<bool>
#define vvi vector<vi>
#define vvl vector<vl>
#define pii pair<int, int>
#define pli pair<ll, int>a
#define pb push_back

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

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

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

ll keta(ll n){
  string s = to_string(n);
  ll num = s.size();
  return num;
}

const ll INF = 1LL << 60;

const int dh[4] = {1,0,-1,0};
const int dw[4] = {0,1,0,-1};

struct Edge{
  int to;
  int weight;
  Edge(int t, int w) : to(t), weight(w){}
};
using Graph = vector<vector<Edge>>;
using P = pair<ll, int>;

class UnionFind{
  public:
  vi Parent;
  UnionFind(int n){
    Parent = vi(n,-1);
  }

  int root(int a){
    if(Parent[a] < 0) return a;
    else return Parent[a] = root(Parent[a]);
  }

  int size(int a){
    return -Parent[root(a)];
  }

  bool merge(int a, int b){
    a = root(a);
    b = root(b);
    if(a == b) return false;

    if(size(a) < size(b)) swap(a,b);
    Parent[a] += Parent[b];
    Parent[b] = a;

    return true;
  }
};

class Factrial{
  public:
  vl Fac;
  Factrial(int MAX){
    Fac = vl(MAX+1);
    rep(i,MAX) {
      if(i == 0) Fac[i+1] = 1;
      else Fac[i+1] = ((i+1)*Fac[i])%MOD;
    }
  }
};


int main(){
  ll n,m,v,p; cin >> n >> m >> v >> p;
  vl a(n); rep(i,n) cin >> a[i];

  sort(all(a));
  reverse(all(a));

  if(v <= p){
    ll num = a[p-1];
    rrep(i,n) {
      if(num - a[i] <= m){
        cout << i+1 << endl;
        return 0;
      }
    }
  }
  
  //rep(i,n) cout << a[i] << " ";
  //cout << endl;
  ll num = a[p-1];
  ll ans = p;
  v = v-p+1;
  //cout << "v:" << v << endl;
  vl b;
  for(int i = p-1; i < n; i++) {
    b.pb(a[i]);
  }
  ll N = b.size();
  //rep(i,N) cout << b[i] << " ";
  //cout << endl;
  vl s(N+1); rep(i,N) s[i+1] = s[i] + b[i];

  rrep(i,N) {
    if(b[0] - b[i] > m) continue;
    ll tmp = v - (N-i);
    if(tmp <= 0){
      if(num - b[i] <= m){
        while(i+1 < N && b[i] == b[i+1]) i++;
        cout << ans + i << endl;
        return 0;
      }
    }
    else{
      if(s[i]+m*tmp <= (b[i]+m)*i){
        while(i+1 < N && b[i] == b[i+1]) i++;
        cout << ans + i << endl;
        return 0;
      }
    }
  }

  cout << ans + 1 << endl;
  
}

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

int main(int argc, const char * argv[]) {
    // insert code here...
    string a;
    cin >> a ;
    if(a[2]==a[3] and a[4]==a[5]){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key

typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<int> vi;
typedef long double ld;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;

vector<ll> arr[4];

int main(){
    ios_base::sync_with_stdio(0); cin.tie(0);
    int n;
    ll w;
    cin>>n>>w;
    ll w1;
    cin>>w1;
    ll v;
    cin>>v;
    arr[0].pb(v);
    for(ll i=1;i<n;i++){
        ll c;
        cin>>c>>v;
        arr[c-w1].pb(v);
    }
    sort(arr[0].rbegin(),arr[0].rend());
    sort(arr[1].rbegin(),arr[1].rend());
    sort(arr[2].rbegin(),arr[2].rend());
    sort(arr[3].rbegin(),arr[3].rend());

    ll A=arr[0].size(),B=arr[1].size(),C=arr[2].size(),D=arr[3].size();
    vector<ll> sua(A+1,0);
    vector<ll> sub(B+1,0);
    vector<ll> suc(C+1,0);
    vector<ll> sud(D+1,0);
    for(ll i=1;i<=A;++i)sua[i]=sua[i-1]+arr[0][i-1];
    for(ll i=1;i<=B;++i)sub[i]=sub[i-1]+arr[1][i-1];
    for(ll i=1;i<=C;++i)suc[i]=suc[i-1]+arr[2][i-1];
    for(ll i=1;i<=D;++i)sud[i]=sud[i-1]+arr[3][i-1];

    ll ans=0;
    for(ll i=0;i<=A && i<=n;i++){
        for(ll j=0;j<=B && j<=n-i;j++){
            for(ll k=0;k<=C && k<=n-i-j;k++){
                for(ll l=0;l<=D && l<=n-i-j-k;l++){
                    if(w1*i+(w1+1)*j+(w1+2)*k+(w1+3)*l>w){
                        continue;
                    }
                    ans=max(ans,sua[i]+sub[j]+suc[k]+sud[l]);
                }
            }
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
K = int(input())

def Lunlun(K):
  if K<=9:
    return K
  q = [i for i in range(1,10)]
  now_index = 0
  while len(q)<K:
    now_number = q[now_index]
    now_1 = now_number%10
    if now_1==0:
      q.append(now_number*10)
      q.append(now_number*10+1)
    elif now_1==9:
      q.append(now_number*10+8)
      q.append(now_number*10+9)
    else:
      q.append(now_number*10+now_1-1)
      q.append(now_number*10+now_1)
      q.append(now_number*10+now_1+1)
    now_index += 1
  return q[K-1]

print(Lunlun(K))

Measured memory_bytes: 7172
def main():
    S = input()
    if S[0] == S[1] == S[2] == S[3]:
        ans = "No"
    elif S[0] == S[1] and S[2] == S[3]:
        ans = "Yes"
    elif S[0] == S[2] and S[1] == S[3]:
        ans = "Yes"
    elif S[0] == S[3] and S[1] == S[2]:
        ans = "Yes"
    else:
        ans = "No"
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
#include "bits/stdc++.h"
using namespace std;
///////////////////////////////////////////
const long long int INF = 1LL<<60;
const long long int Mod = 1000000007;
using ll = long long int; using ci = const int;
using vi = vector<int>;  using Vi = vector<long long int>;
using P = pair<int, int>;  using PLL = pair<ll, ll>;
using matrix = vector<vector<ll>>;
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define rep(i,N) for(ll i = 0; i < (ll)N; i++)
#define repi(i,a,b) for(ll i = ll(a); i < ll(b); ++i)
template<class T>bool chmax(T &former, const T &b) { if (former<b) { former=b; return true; } return false; }
template<class T>bool chmin(T &former, const T &b) { if (b<former) { former=b; return true; } return false; }
template<class T>T sqar(T x){ return x*x; }//sqrt(x)は平方根;
#define Sort(v) std::sort(v.begin(), v.end(), std::greater<decltype(v[0])>()) //降順でVをソート
#define p_queue(v) priority_queue<v, vector<v>, greater<v> >
template<class T> inline void princ(T x){cout<<x<<" ";}; 
template<class T> inline void print(T x){cout<<x<<"\n";};
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
///////////////////////////////////////////////////////////////////////////////////

ll n,k;
Vi a;
Vi pl,mi,ze;

bool ck(ll num){//num以下の数はいくつあるか.
	bool ans;
	ll tmp = 0;
	if(num>0){
		rep(i,pl.size()){
			ll now = num/pl[i];
			ll id = upper_bound(all(pl),now) - pl.begin();
			if(id>i)id--;
			tmp += id;
		}
		rep(i,mi.size()){
			ll now = num/abs(mi[i]);
			ll id = lower_bound(all(mi),-now) - mi.begin();
			if(id<=i)id++;
			tmp += (mi.size()-id);
		}
		tmp /= 2;
	}
	if(num>=0){
		tmp += ze.size()*(n-ze.size());
		tmp += ze.size()*(ze.size()-1)/2;
	}
	
		rep(i,mi.size()){
			ll now = num/mi[i];
			if(num%mi[i]!=0)now += 1;
			ll id = lower_bound(all(pl),now) - pl.begin();
			tmp += pl.size()-id;
		}
	
	if(tmp>=k)return true;
	else return false;
}


int main(){
	cin.tie(0);ios::sync_with_stdio(false);
	std::cout<<std::fixed<<std::setprecision(30);
	cin>>n>>k;
	a.resize(n);
	rep(i,n){
		cin>>a[i];
	}
	sort(all(a));
	rep(i,n){
		if(a[i]<0){
			mi.pb(a[i]);
		}else if(a[i]==0){
			ze.pb(a[i]);
		}else{
			pl.pb(a[i]);
		}
	}
	ck(6);
	ll mid, ok = INF, ng = -INF;
	while(abs(ok-ng)>1){
		mid = (ok+ng)/2;
		if(ck(mid))ok = mid;
		else ng = mid;
	}//midではなくokを使わないとバグる!
	print(ok);
	return 0;
}

Measured memory_bytes: 4468
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <string>

using namespace std;

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

  int y = 700;
  for (auto c : s) {
    if (c == 'o')
      y += 100;
  }
  cout << y << endl;
  return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"

using namespace std;

using u8 = uint8_t;
using u16 = uint16_t;
using u32 = uint32_t;
using u64 = uint64_t;
using i8 = int8_t;
using i16 = int16_t;
using i32 = int32_t;
using i64 = int64_t;

constexpr char newl = '\n';
constexpr double eps = 1e-10;

#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define F0R(i,b) FOR(i,0,b)
#define RFO(i,a,b) for (int i = ((b)-1); i >=(a); i--)
#define RF0(i,b) RFO(i,0,b)
//#define fi first
//#define se second
#define debug(x) cout << #x << ": " << x << '\n';
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()

template<typename T1, typename T2> inline void chmin(T1& a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1& a, T2 b) { if (a < b) a = b; }
template<class T> void Print(vector<T> v) {
  F0R(i, v.size()) {
    cout << v[i] << ' ';
  }
  cout << newl;
}

#if 1


// INSERT ABOVE HERE
signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);

  int K, X;
  cin >> K >> X;

  cout << (500 * K >= X ? "Yes" : "No");
}
#endif


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

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n, m;
	cin>>n>>m;
	for(int i=m/n; i>=1; --i){
		if(m%i==0){
			cout<<i<<'\n';
			return 0;
		}
	}
	return 0;
}


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

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
	string s;
	cin >> s;
	if (s == "SUN") cout << "7" << "\n";
	if (s == "MON") cout << "6" << "\n";
	if (s == "TUE") cout << "5" << "\n";
	if (s == "WED") cout << "4" << "\n";
	if (s == "THU") cout << "3" << "\n";
	if (s == "FRI") cout << "2" << "\n";
	if (s == "SAT") cout << "1" << "\n";
	return 0;
}


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

typedef long long ll;
typedef pair<int, int> ii;

const int maxv = 1e6 + 1;
const int N = 2e5 + 5;
int n;
int a[N];
bool ok[maxv];
unordered_map<int, int> ma;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> n;
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
  }
  sort(a, a + n);
  for (int i = 0; i < n; ++i) {
    int v = a[i];
    ma[v]++;
    if (ma[v] > 1) {
      ok[v] = true;
      continue;
    } else {
      for (int j = v + v; j < maxv; j += v) {
        ok[j] = true;
      }
    }
  }
  int cnt = 0;
  for (int i = 0; i < n; ++i) {
    int v = a[i];
    if (!ok[v])
      cnt++;
  }
  cout << cnt << endl;

  return 0;
}


Measured memory_bytes: 12996
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define inf (int)(1e18)

signed main(){
	int N, A[5], i, minA = inf;
	scanf("%lld", &N);
	for(i = 0; i < 5; i++){
		scanf("%lld", &A[i]);
		minA = min(minA, A[i]);
	}
	printf("%lld\n", (N + minA - 1) / minA + 4);
	return 0;
}

Measured memory_bytes: 256
from collections import deque

k = int(input())
q = deque()
for i in range(1, 10):
    q.append(i)
for _ in range(k):
    p = q.popleft()
    r = p % 10
    if r != 0:
        q.append(10 * p + r - 1)
    q.append(10 * p + r)
    if r != 9:
        q.append(10 * p + r + 1)
print(p)

Measured memory_bytes: 11968
// This amazing code is by Eric Sunli Chen.
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <utility>
#include <vector>
using namespace std;
template<typename T> void get_int(T &x)
{
	char t=getchar();
	bool neg=false;
	x=0;
	for(; (t>'9'||t<'0')&&t!='-'; t=getchar());
	if(t=='-')neg=true,t=getchar();
	for(; t<='9'&&t>='0'; t=getchar())x=x*10+t-'0';
	if(neg)x=-x;
}
template<typename T> void print_int(T x)
{
	if(x<0)putchar('-'),x=-x;
	short a[20]= {},sz=0;
	while(x>0)a[sz++]=x%10,x/=10;
	if(sz==0)putchar('0');
	for(int i=sz-1; i>=0; i--)putchar('0'+a[i]);
}
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define get1(a) get_int(a)
#define get2(a,b) get1(a),get1(b)
#define get3(a,b,c) get1(a),get2(b,c)
#define printendl(a) print_int(a),puts("")
typedef long long LL;
typedef unsigned long long uLL;
typedef pair<LL,LL> pii;
const int inf=0x3f3f3f3f;
const LL Linf=1ll<<61;
const double pi=acos(-1.0);

LL x,r[100111],a[100111],t[100111];

int id[100111],q,k,f[100111],sz;
int gf(int x){return x==f[x]?x:f[x]=gf(f[x]);}
LL pos[100111],ans[100111];
bool cmp(int x,int y){return t[x]<t[y];}
vector<int> v;
set<pii> st;

int main()
{
	get2(x,k);for(int i=1;i<=k;i++)get1(r[i]);r[++k]=inf;
	get1(q);for(int i=1;i<=q;i++){get2(t[i],a[i]);v.pb(a[i]);id[i]=i;}
	sort(id+1,id+q+1,cmp);
	v.pb(-1);sort(v.begin(),v.end());v.erase(unique(v.begin(),v.end()),v.end());sz=(int)v.size();
	
	for(int i=1;i<=sz;i++){f[i]=i;pos[i]=v[i];st.insert(mp(v[i],i));}
	bool neg=1;
	int cur=1;
	LL add=0;
	set<pii>::iterator it,it2;
	for(int i=1;i<=k;i++)
	{
		while(cur<=q&&t[id[cur]]<=r[i])
		{
			LL now=lower_bound(v.begin(),v.end(),a[id[cur]])-v.begin();
			now=pos[gf(now)]+add;
			if(neg)
			{
				now-=t[id[cur]]-r[i-1];
				now=max(now,0ll);
			}
			else
			{
				now+=t[id[cur]]-r[i-1];
				now=min(now,x);
			}
			ans[id[cur]]=now;
			cur++;
		}
		LL lb,ub;
		if(neg)
		{
			lb=-add;ub=r[i]-r[i-1]-add;
//			printf("lb= %lld ub= %lld\n",lb,ub);
			it=st.lower_bound(mp(lb,0));
			int u=0,v;
			for(;it!=st.end()&&it->ff<=ub;)
			{
				if(!u)
				{
					u=it->ss;
					pos[u]=ub;
				}
				else
				{
					v=it->ss;
					f[gf(v)]=gf(u);
				}
				it2=it;it++;st.erase(it2);
			}
			if(u)st.insert(mp(pos[u],u));
			add-=r[i]-r[i-1];
			neg=0;
		}
		else
		{
			ub=x-add;lb=x-add-r[i]+r[i-1];
//			printf("lb= %lld ub= %lld\n",lb,ub);
			it=st.lower_bound(mp(lb,0));
			int u=0,v;
			for(;it!=st.end()&&it->ff<=ub;)
			{
				if(!u)
				{
					u=it->ss;
					pos[u]=lb;
				}
				else
				{
					v=it->ss;
					f[gf(v)]=gf(u);
				}
				it2=it;it++;st.erase(it2);
			}
			if(u)st.insert(mp(pos[u],u));
			add+=r[i]-r[i-1];
			neg=1;
		}
//		for(int j=1;j<=sz;j++)printf("v= %lld now= %lld\n",v[j],pos[gf(j)]+add);
//		puts("");
	}
	for(int i=1;i<=q;i++)printendl(ans[i]);
	return 0;
}

Measured memory_bytes: 12792
#include <iostream>
#include <cstdio>
#include <sstream>

#include <string>
#include <vector>
#include <map>
#include <set>
#include <list>
#include <deque>
#include <queue>
#include <stack>

#include <algorithm>
#include <utility>
#include <numeric>
#include <functional>

#include <chrono>
#include <random>

using namespace std;
using i64 = int_fast64_t;
using ui64 = uint_fast64_t;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<i64>;
using vvl = vector<vl>;
using vd = vector<double>;
using vvd = vector<vd>;
using vb = vector<bool>;
using vvb = vector<vb>;
using pii = pair<int, int>;
using pll = pair<i64, i64>;

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

int main(){
    int n;
    cin >> n;
    vi a(n);
    for(auto&& x:a)cin >> x;
    a.push_back(0);
    for(int i=0;i<n;i++){
      a[i+1] += a[i];
    }
    int res = 100000007;
    for(int i=0;i<n;i++){
      res = min(res, abs(a[i] - (a[n] - a[i])));
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 256
// Linear Search

#include<stdio.h>

int search(int a[],int n,int key){
    int i,ans=0;
    for(i=0;i<n;i++){
        if(a[i]==key){
            ans=1;
        }
    }
    return ans;
}

int main(void){
    int n,q,S[10000],i,key,sum=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",&key);
        if(search(S,n,key)){
            sum++;
        }
    }
    printf("%d\n",sum);
    return 0;
}



Measured memory_bytes: 2104
#include<stdio.h>

int main() {
  int h[3] = {-1, -1, -1},t,s;
  for(int i=0; i<10; ++i) {
    scanf("%d", &t);
    for(int j=0; j<3; ++j) {
      if(h[j] < t) {
	s = h[j];
	h[j] = t;
	t = s;
      }
    }
  }

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

Measured memory_bytes: 0
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
int INF = 1e9;
int MOD = 1e9+7;
ll dp[200020];
ll cnt[26];
main(){
    string S;
    cin >> S;
    dp[0] = 1;
    cnt[S[0]-'a']++;
    for(int i = 1;i < S.length();i++){
        cnt[S[i]-'a']++;
        ll dif = accumulate(cnt,cnt+26,0) - cnt[S[i]-'a'];
        dp[i] = dp[i-1] + dif;
    }
//    for(int i = 0;i < S.length();i++)cout << dp[i] << " ";
    cout << dp[S.length()-1] << endl;
}

Measured memory_bytes: 2180
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define all(v) v.begin(), v.end()
using in = int64_t;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const double PI=3.14159265358979323846;
const int64_t waru = 1000000007;
const in INF=1<<30;
#define vec2(a,y,x) vector<vector<int>> a(y,vector<int>(x))
#define vec1(a,n) vector<in> a(n);rep(i,n)cin>>a[i]

int main(){
 int d,g;
  cin>>d>>g;
  g /=100;
  vector<int> p(d),c(d);
  rep(i,d) cin>>p[i]>>c[i];
  int max_point=0;
  int cnt=0;
  int total_point=0;
  int ans =1000000;
  
for (int tmp = 0; tmp < (1 << d); tmp++) {
  bitset<10> s(tmp);
  max_point=0;cnt=0;total_point=0;
 rep(i,d){
   if(s.test(i)){
      cnt +=p[i];
     total_point += p[i]*(i+1);
     total_point += c[i]/100;
   }
   else{
      max_point =max(i+1,max_point);
   }
   
 }//rep
  if(total_point>=g){ans =min(ans,cnt);continue;}
  if(max_point*p[max_point-1]+total_point<=g) continue;
   
  int x=g-total_point;
  if(x%max_point==0) cnt += x/max_point;
  else cnt += x/max_point+1;
  ans =min(ans,cnt);
  
}//bit
cout<<ans;
}


Measured memory_bytes: 256
R,G,B,N = map(int,input().split())
count = 0
for r in range(3001):
    if N-r*R<0:
        break
    for g in range(3001):
        if N-(r*R+g*G)>=0 and (N-(r*R+g*G))%B==0:
            count += 1
print(count)

Measured memory_bytes: 41068
import java.util.*;

public class Main {
	int A, B;
	int Q;
	long[] s, t, x;
	long[] results;

	void calc() {
		results = new long[Q];
		for (int i = 0; i < Q; ++i) {
			results[i] = calcEachResult(x[i]);
		}
	}

	void show() {
		for (int i = 0; i < Q; ++i) {
			System.out.println(results[i]);
		}
	}

	Main() {
		Scanner in = new Scanner(System.in);
		A = in.nextInt();
		B = in.nextInt();
		Q = in.nextInt();
		s = new long[A + 2];
		t = new long[B + 2];
		x = new long[Q];
		s[0] = -1000000000001L;
		for (int i = 0; i < A; ++i) {
			s[i + 1] = in.nextLong();
		}
		s[A + 1] = 1000000000001L;
		t[0] = -1000000000001L;
		for (int i = 0; i < B; ++i) {
			t[i + 1] = in.nextLong();
		}
		t[B + 1] = 1000000000001L;

		for (int i = 0; i < Q; ++i) {
			x[i] = in.nextLong();
		}
		in.close();
	}

	long calcEachResult(long targetVal) {
		int lsIndex = binSearch(s, targetVal, 0, A + 1);
		int ltIndex = binSearch(t, targetVal, 0, B + 1);
		long ls = s[lsIndex];
		long lt = t[ltIndex];
		long rs = s[lsIndex + 1];
		long rt = t[ltIndex + 1];
		long result = Long.MAX_VALUE;
		result = Math.min(result, Math.max(rs, rt) - targetVal);
		result = Math.min(result, targetVal - Math.min(ls, lt));
		result = Math.min(result, targetVal - ls + rt - ls);
		result = Math.min(result, targetVal - lt + rs - lt);
		result = Math.min(result, rs - targetVal + rs - lt);
		result = Math.min(result, rt - targetVal + rt - ls);
		return result;
	}

	int binSearch(long[] vals, long targetVal, int minIndex, int maxIndex) {
		if (minIndex + 1 == maxIndex) {
			if (targetVal > vals[maxIndex]) {
				return maxIndex;
			} else {
				return minIndex;
			}
		}
		int medIndex = minIndex + Math.floorDiv(maxIndex - minIndex, 2);
		if (targetVal > vals[medIndex]) {
			return binSearch(vals, targetVal, medIndex, maxIndex);
		} else {
			return binSearch(vals, targetVal, minIndex, medIndex);
		}
	}

	public static void main(String[] args) {
		Main ins = new Main();
		ins.calc();
		ins.show();
	}
}

Measured memory_bytes: 98740
#include <iostream>
#include <cmath>
#define max(X, Y) ((X) > (Y) ? (X) : (Y))
#define min(X, Y) ((X) < (Y) ? (X) : (Y))
#define abs(X) ((X) < 0 ? -1 * (X) : (X))

using namespace std;

typedef long long ll;

int main()
{
    ll n;
    ll t, a;
    ll ans = 0;
    ll i;
    ll h;
    ll m = 1ll << 60ll;

    cin >> n;
    cin >> t >> a;

    a = a * 1000;
    t = t * 1000;
    
    for (i = 1; i <= n; i++) {
        cin >> h;

        ll tmp = t - h * 6;

        if (abs(a - tmp) < m) {
            m = abs(a - tmp);
            ans = i;
        }
        
    }

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define MOD 1000000007LL
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int n;
int x[200005],y[200005],u[200005];
vector<int> vec[2][2][600005];
vector<int> vec2[4][600005];
string s="RLUD";
int B=200000;

int main(void){
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		char c;
		scanf(" %d %d %c",&x[i],&y[i],&c);
		for(int j=0;j<4;j++){
			if(c==s[j]){
				u[i]=j;
			}
		}
		if(u[i]==0){
			vec[0][0][B+x[i]+y[i]].push_back(x[i]);
			vec[0][1][B+x[i]-y[i]].push_back(x[i]);
			vec2[0][y[i]].push_back(x[i]);
		}
		if(u[i]==1){
			vec[1][0][B+x[i]-y[i]].push_back(x[i]);
			vec[1][1][B+x[i]+y[i]].push_back(x[i]);
		}
		if(u[i]==2){
			vec2[1][x[i]].push_back(y[i]);
		}
	}
	for(int i=0;i<2;i++){
		for(int j=0;j<2;j++){
			for(int k=0;k<=600000;k++){
				sort(vec[i][j][k].begin(),vec[i][j][k].end());
				sort(vec2[i][k].begin(),vec2[i][k].end());
			}
		}
	}
	int ans=1<<25;
	for(int i=0;i<n;i++){
		if(u[i]==1){
			if(vec2[0][y[i]].size()==0)continue;
			int pos=lower_bound(vec2[0][y[i]].begin(),vec2[0][y[i]].end(),x[i])-vec2[0][y[i]].begin();
			if(pos>0){
				pos--;
				ans=min(ans,abs(x[i]-vec2[0][y[i]][pos])*5);
			}
		}
		if(u[i]==2){
			int pos=lower_bound(vec[0][0][B+x[i]+y[i]].begin(),vec[0][0][B+x[i]+y[i]].end(),x[i])-vec[0][0][B+x[i]+y[i]].begin();
			if(pos>0){
				pos--;
				ans=min(ans,abs(x[i]-vec[0][0][B+x[i]+y[i]][pos])*10);
			}

			pos=lower_bound(vec[1][0][B+x[i]-y[i]].begin(),vec[1][0][B+x[i]-y[i]].end(),x[i])-vec[1][0][B+x[i]-y[i]].begin();
			if(pos<vec[1][0][B+x[i]-y[i]].size()){
				ans=min(ans,abs(x[i]-vec[1][0][B+x[i]-y[i]][pos])*10);
			}
		}
		if(u[i]==3){
			int pos=lower_bound(vec2[1][x[i]].begin(),vec2[1][x[i]].end(),y[i])-vec2[1][x[i]].begin();
			if(pos>0){
				pos--;
				ans=min(ans,abs(y[i]-vec2[1][x[i]][pos])*5);
			}

			pos=lower_bound(vec[0][1][B+x[i]-y[i]].begin(),vec[0][1][B+x[i]-y[i]].end(),x[i])-vec[0][1][B+x[i]-y[i]].begin();
			if(pos>0){
				pos--;
				ans=min(ans,abs(x[i]-vec[0][1][B+x[i]-y[i]][pos])*10);
			}

			pos=lower_bound(vec[1][1][B+x[i]+y[i]].begin(),vec[1][1][B+x[i]+y[i]].end(),x[i])-vec[1][1][B+x[i]+y[i]].begin();
			if(pos<vec[1][1][B+x[i]+y[i]].size()){
				ans=min(ans,abs(x[i]-vec[1][1][B+x[i]+y[i]][pos])*10);
			}
		}
		//printf("%d\n",ans);
	}
	
	if(ans==(1<<25)){
		printf("SAFE\n");
	}else{
		printf("%d\n",ans);
	}
	return 0;
}


Measured memory_bytes: 130804
//============================================================================
// Name        : AOL.cpp
// Author      : Akari Fujii
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
#include <cctype>
#include <algorithm>
using namespace std;
typedef long long ll;


int main() {
	int a,b,c,d;

	cin>>a;
	cin>>b;
	cin>>c;
	cin>>d;




	cout<<(a+b+c+d)/60<<endl;
	cout<<(a+b+c+d)%60<<endl;
	return 0;
}

Measured memory_bytes: 3100
//#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<long long> vll;
typedef vector<bool> vb;
#define pb push_back
#define fi first
#define se second
#define in insert
#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 mod = 1e9 + 7;
void solve(){
    int n;
    cin >> n;
    ll ans = 0;
    for (int i = 1; i <= n; ++i) {
        if (i % 3 != 0 && i % 5 != 0) ans += i;
    }
    cout << ans;
}
int main(){
    speed;
    int t = 1;
    //cin >> t;
    for (int i = 1; i <= t; ++i) {
        solve();
    }
}

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

int main(){
    int n;
    ll ans = 0;
    cin >> n;
    vector<int> a(n+1);
    vector<int> b(n);
    rep(i,n+1) cin >> b[i];
    rep(i,n) cin >> a[i];
    rep(i,n){
        ans += min(a[i],b[i]);
        a[i] -= min(a[i],b[i]);
        ans += min(a[i],b[i+1]);
        b[i+1] -= min(a[i],b[i+1]);
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 1024
#include <cstdio>
#include <iostream>
#include <string>
#include <sstream>
#include <stack>
#include <algorithm>
#include <cmath>
#include <queue>
#include <map>
#include <set>
#include <cstdlib>
#include <bitset>
#include <tuple>
#include <assert.h>
#include <deque>
#include <bitset>
#include <iomanip>
#include <limits>
#include <chrono>
#include <random>
#include <array>
#include <unordered_map>
#include <functional>
#include <complex>
#include <numeric>
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

constexpr long long MAX = 5100000;
constexpr long long INF = 1LL << 60;
constexpr int inf = 1 << 28;
//constexpr long long mod = 1000000007LL;
//constexpr long long mod = 998244353LL;

using namespace std;
typedef unsigned long long ull;
typedef long long ll;

double dist(double a, double b) {
	return (b - a) * (b - a);
}
int main()
{
	/*
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	*/
	int kkt = 1;
	while (kkt--) {
		ll N, M; scanf("%lld %lld", &N, &M);
		vector<ll> perm(N);
		for (int i = 0; i < M; i++) perm[i] = 1;
		vector<double> L(N), a(N), b(N);
		for (int i = 0; i < N; i++) {
			scanf("%lf %lf %lf", &L[i], &a[i], &b[i]);
		}
		double res = 0.0;
		sort(perm.begin(), perm.end());
		do {
			vector<ll> idx;
			for (int i = 0; i < N; i++) {
				if (perm[i]) {
					idx.push_back(i);
				}
			}
			double tmp = 0;
			for (int i = 0; i < idx.size(); i++) {
				for (int j = i + 1; j < idx.size(); j++) {
					tmp += dist(L[idx[i]], L[idx[j]]) + dist(a[idx[i]], a[idx[j]]) + dist(b[idx[i]], b[idx[j]]);
				}
			}
			chmax(res, tmp);
			
		} while (next_permutation(perm.begin(), perm.end()));
		printf("%.12f\n", res);
	}

	return 0;
}


Measured memory_bytes: 3304
#include <bits/stdc++.h>
 
using namespace std;
 
#define ll long long
#define ull unsigned long long
 
int main() {
    ios::sync_with_stdio(0); cin.tie(0);
 
    double n;
    cin >> n;
    n /= 3;
    cout << fixed << setprecision(10) << n * n * n << '\n';
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <iterator>
#include <cmath>
#include <set>
#include <deque> 
#include <string>


using namespace std;

int n;
int d1, d2;
int sameCount;


int main()
{
	sameCount = 0;
	bool isAccepted = false;
	
	scanf("%d", &n);
	for (int i = 0 ; i < n ; i++) {
		scanf("%d%d", &d1, &d2);
		
		if (d1 == d2) {
			sameCount++;
			if (sameCount >= 3)
				isAccepted = true;
		} else {
			sameCount = 0;
		}
	}
	if (isAccepted) {
		printf("Yes\n");
	} else {
		printf("No\n");
	}
	
	return 0;
}




Measured memory_bytes: 1660
// Template
#include <bits/stdc++.h>
#define rep_override(x, y, z, name, ...) name
#define rep2(i, n) for (int i = 0; i < (int)(n); ++i)
#define rep3(i, l, r) for (int i = (int)(l); i < (int)(r); ++i)
#define rep(...) rep_override(__VA_ARGS__, rep3, rep2)(__VA_ARGS__)
#define per(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
constexpr int inf = 1001001001;
constexpr ll INF = 3003003003003003003LL;
template <typename T> inline bool chmin(T &x, const T &y) {if (x > y) {x = y; return 1;} return 0;}
template <typename T> inline bool chmax(T &x, const T &y) {if (x < y) {x = y; return 1;} return 0;}
struct IOSET {IOSET() {cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(10);}} ioset;

template <typename T>
class Dinic {
    T INF_;
    struct Edge {int to, rev; T cap;};
    vector<vector<Edge>> G;
    vector<int> dist, iter;
    bool bfs(int s, int t) {
        dist.assign(G.size(), -1);
        queue<int> q;
        dist[s] = 0;
        q.push(s);
        while (!q.empty()) {
            int v = q.front();
            q.pop();
            for (Edge &e : G[v]) {
                if (dist[e.to] != -1 || e.cap == 0) continue;
                dist[e.to] = dist[v] + 1;
                q.push(e.to);
            }
        }
        return dist[t] != -1;
    }
    T dfs(int now, int t, T min_cap) {
        if (now == t) return min_cap;
        for (int &i = iter[now]; i < G[now].size(); ++i) {
            Edge &e = G[now][i];
            if (e.cap == 0 || dist[e.to] != dist[now] + 1) continue;
            T d = dfs(e.to, t, min(min_cap, e.cap));
            if (d > 0) {
                e.cap -= d;
                G[e.to][e.rev].cap += d;
                return d;
            }
        }
        return 0;
    }
public:
    Dinic(int V) : G(V), INF_(numeric_limits<T>::max()) {}
    void AddEdge(int from, int to, T cap) {
        G[from].push_back(Edge{to, (int)G[to].size(), cap});
        G[to].push_back(Edge{from, (int)G[from].size() - 1, 0});
    }
    T MaxFlow(int s, int t) {
        T ans = 0;
        while (bfs(s, t)) {
            iter.assign(G.size(), 0);
            T f = 0;
            while ((f = dfs(s, t, INF_)) > 0) ans += f;
        }
        return ans;
    }
};

// Main
int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    
    Dinic<ll> G(n + 2);
    ll ans = 0;
    rep(i, n) {
        int x = max(a[i], 0);
        G.AddEdge(0, i + 1, x - a[i]);
        G.AddEdge(i + 1, n + 1, x);
        ans += x;
    }
    rep(i, 1, n + 1) for (int j = 2 * i; j <= n; j += i) G.AddEdge(i, j, INF);
    ans -= G.MaxFlow(0, n + 1);
    cout << ans << "\n";
    return 0;
}


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


int main() {
    int N, M;
    cin >> N >> M;
    if (N == M) cout << "Yes" << endl;
    else cout << "No" << endl;
}


Measured memory_bytes: 256
n = int(input())
s = [input() for i in range(n)]
m = int(input())
t = [input() for i in range(m)]

s.sort()
word = ""
max = 0
for i in range(n):
  if s[i] == word:
    continue
    
  word = s[i]
  points = s.count(word) - t.count(word)
  if points > max:
    max = points

print(max)

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

int main(){
  int N,M,C;
  int sub,solve=0;
  cin >> N >> M >> C;
  int A[N][M]={},B[M]={};
  for(int i=0;i<M;i++) cin >> B[i];
  for(int i=0;i<N;i++) {
    for(int j=0;j<M;j++) cin >> A[i][j];
  }

  for(int i=0;i<N;i++) {
    sub=0;
    for(int j=0;j<M;j++) sub+=A[i][j]*B[j];
    if(sub+C>0) solve++;
  }
  cout << solve << endl;
}


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

struct UnionFind{
    vector<int> r;
    UnionFind(int n){
        r=vector<int>(n,-1);
    }
    
    //根を求める
    int root(int x){
        if(r[x]<0) return x;
        return r[x]=root(r[x]);
    }
    
    //aとbを結合
    void unite(int a,int b){
        a=root(a);
        b=root(b);
        if(a==b) return;
        if(r[a]>r[b]) swap(a,b);
        r[a]+=r[b];
        r[b]=a;
        return;
    }
    
    //サイズを求める
    int size(int a){
        return -r[root(a)];
    }
};

int main(){
    int n,m;
    cin>>n>>m;
    UnionFind uf(n+1);
    rep(i,m){
        int a,b;
        cin>>a>>b;
        a--;b--;
        uf.unite(a,b);
    }
    int ans=0;
    rep(i,n) ans=max(ans,uf.size(i));
    cout<<ans;
}

Measured memory_bytes: 4060
#include<bits/stdc++.h>
#define pb push_back
using namespace std;
const int N=1e5+10;
int n,m,x,y,r[N],d[N],ans=0;
queue<int> q;
vector<int> g[N];
int main()
{
	cin>>n>>m;
	for(int i=0;i<m;i++)
	{
		cin>>x>>y;
		x--; y--;
		g[x].pb(y);
		r[y]++;
	}
	memset(d,-1,sizeof(d));
	for(int i=0;i<n;i++)
	 if(r[i]==0) q.push(i);
	while(!q.empty())
	{
		int a=q.front();
		q.pop();
		ans=max(ans,d[a]);
		for(int i=0;i<g[a].size();i++)
		{	
			d[g[a][i]]=max(d[g[a][i]],d[a]+1);
			r[g[a][i]]--;
			if(r[g[a][i]]==0) q.push(g[a][i]);
		}
	}
	cout<<ans+1<<endl;
	return 0;
}

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

#define ll long long

#define rep(i, a, b) for (int i = a; i < b; i++)
#define For(i, a, b) for (int i = a; i <= b; i++)

using namespace std;

const int mod = 1000000000 + 7;
const int MAXN = 100000;

ll n, ans;
pair<ll, ll> det[MAXN];
char t[10];

bool cmp(pair<ll, ll> a, pair<ll, ll> b) {
    return a.first == b.first ? a.second < b.second : a.first < b.first;
}

bool equals(pair<ll, ll> a, pair<ll, ll> b) {
    return a.first == b.first && a.second == b.second;
}

int main() {
    scanf("%lld", &n);
    rep(i, 0, n) {
        scanf("%s", t);
        rep(j, 0, 10) t[j] - 'a' >= 15 ? det[i].first += (ll) pow(11, (t[j] - 'a' - 15)) : det[i].second += (ll) pow(11,
                                                                                                                     (t[j] -
                                                                                                                      'a'));
    }
    sort(det, det + n, cmp);
    det[n] = {-1, -1};
    ll x = 1;
    For(i, 0, n) {
//        printf("%lld %lld\n", det[i].first, det[i].second);
        if (equals(det[i], det[i + 1])) {
//            printf("%lld", &det[i] - cur);
            x++;
        } else ans += x * (x - 1) / 2, x = 1;
    }
    printf("%lld", ans);
}

Measured memory_bytes: 1792
#include<stdio.h>

int main(){
  int l,r,d,i,count=0;
  scanf("%d %d %d",&l,&r,&d);

  for(i=l;i<=r;i++){
    if(i%d==0){
      count++;
    }
  }

  printf("%d\n",count);
  return 0;
}

Measured memory_bytes: 2148
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
ll gcd(ll a, ll b) {
  if (b==0) return a;
  return gcd(b, a%b);
}
int main() {
  ll a, b;
  cin >> a >> b;
  cout << a*b/gcd(a, b) << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define l_ength size
const int inf = (1<<30);
const int mod = 1000000007;
using ll = long long;
using namespace std;

int main(){
	ll n; cin >> n;
	vector<ll> a(n);
	for( auto &k : a ) cin >> k;
	vector<ll> gs(n+1);
	fill_n( gs.begin(), n+1, 0 );
	for( auto k : a ) ++gs[k];
	ll ans = 0;
	for( auto k : gs ){
		ans += max(0ll, k*(k-1)/2);
	}
	for( auto k : a ){
		if( gs[k] >= 2 ) cout << ans - (gs[k]-1) << endl;
		else cout << ans << endl;
	}
}

Measured memory_bytes: 5760
#include <bits/stdc++.h>
#include <string>
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <bitset>
typedef long long ll;
using namespace std;

const int MAX = 510000;
const int MOD = 1000000007;
const int MAX_N = 200000;

int ctoi(const char c){
  switch(c){
    case '0': return 0;
    case '1': return 1;
    case '2': return 2;
    case '3': return 3;
    case '4': return 4;
    case '5': return 5;
    case '6': return 6;
    case '7': return 7;
    case '8': return 8;
    case '9': return 9;
    default : return -1;
  }
}

int main(int argc, const char * argv[]) {
    ll N,M; cin>> N>>M;
    vector<ll> H(N);
    
    set<ll> connect[N];
    
    for(ll i=0;i<N;i++){
        cin >> H[i];
    }
    
    for(ll i=0;i<M;i++){
        ll temp_A,temp_B; cin >> temp_A >> temp_B ;
        temp_A--; temp_B--;
        connect[temp_A].insert(temp_B);
        connect[temp_B].insert(temp_A);
    }
    
    ll cnt=0;
    for(ll i=0;i<N;i++){
        ll max_itr = 0;
        for(ll itr : connect[i]){
            max_itr = max(max_itr, H[itr]);
        }
        if(max_itr < H[i]){
            cnt++;
        }
    }
    
    cout << cnt << endl;
    
    return 0;
}


Measured memory_bytes: 17980
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const ll MOD=(ll)1e9+7;
//const ll MOD=(ll)998244353;
const ll INF=(ll)1e18+10;
const double PI = 2.0*acos(0);
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 (a>b) { a=b; return 1; } return 0; }
int dy[]={-1,1,0,0};
int dx[]={0,0,-1,1};

void solve(int ca){
    int N,M; cin>>N>>M;
    vector<int> cnt(N,0);
    for (int i = 0; i < M; ++i) {
        int a,b;
        cin>>a>>b;
        --a; --b;
        cnt[a]++; cnt[b]++;
    }

    for(auto i:cnt){
        if(i%2==1){
            cout<<"NO"<<endl;
            return;
        }
    }
    cout<<"YES"<<endl;

}

//#define MULTI
int main() {
#ifdef MULTI
    int N; cin>>N;
    for (int i = 0; i < N; ++i) {
        solve(i+1);
    }
#else
    solve(0);
#endif
    return 0;
}


Measured memory_bytes: 640
n = int(input())
xy = [[],[],[],[]]
s = {'L':0,'R':1,'U':2,'D':3}
for i in range(n):
  x,y,d = input().split()
  xy[s[d]] += [[int(x),int(y)]]
q = -10**9
p = [[q,q,q] for i in range(4)]
ss = [[0,2,1,1],[1,1,2,0]]
pm = [1,-1,1,-1]
for i in range(4):
  if xy[i]:
    for j in range(4):
      ps = ss[j//2][i]
      z = max(xy[i],key=lambda z:z[j//2]*pm[j])
      p[j][ps] = max(p[j][ps],z[j//2]*pm[j])
t = {0}
for i in range(4):
  z = [u*pm[i] for u in p[i]]
  t = t | {z[1]-z[2],z[0]-z[1],(z[0]-z[2])/2}
def dis(u,v):
  return max(p[0+v][0]-u,p[0+v][1],p[0+v][2]+u)-min(-p[1+v][0]-u,-p[1+v][1],-p[1+v][2]+u)
print(min([dis(u,0)*dis(u,2) for u in t if u<=2*10**8 and u>=0]))

Measured memory_bytes: 58456
n = int(input())
al = list(map(int, input().split()))

def gcd(a,b):
    while b>0:
        a,b = b,a%b
    return a


accl = [0]*(n+1)
accr = [0]*(n+1)

accl[0] = al[0]
for i in range(n):
    accl[i+1] = gcd(accl[i],al[i])

accr[n] = al[n-1]
for i in range(n,0,-1):
    accr[i-1] = gcd(accr[i],al[i-1])

res = 0
for i in range(n):
    if i==0:
        res = max(res, accr[1])
    elif i==n-1:
        res = max(res, accl[n-1])
    else:
        res = max(res, gcd(accl[i], accr[i+1]))
print(res)

Measured memory_bytes: 20540
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
//const int mod=1e9+7;
                     // I'm in Love with Experience. 
void solve()
{
    int N;cin>>N;
    int a=0,t=0,w=0,r=0;
    while(N--)
    {
        string str;cin>>str;
        if(str=="AC")a++;
        else if(str=="TLE")t++;
        else if(str=="WA")w++;
        else r++;
    }
    cout<<"AC x "<<a<<'\n';
    cout<<"WA x "<<w<<'\n';
    cout<<"TLE x "<<t<<'\n';
    
    cout<<"RE x "<<r<<'\n';
}
int main(void)
{
    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);solve();
    //int T;cin>>T;while(T--){solve();}exit(0);
}/*Solved By:- Ritik Agarwal*/

Measured memory_bytes: 3584
#include <bits/stdc++.h>
using namespace std;
#define ri register int
typedef long long ll;
namespace io {
	const int SIZE = (1 << 21) + 1;
	char ibuf[SIZE], *iS, *iT, obuf[SIZE], *oS = obuf, *oT = oS + SIZE - 1, c, qu[55]; int f, qr;
	// getchar
	#define gc() (iS == iT ? (iT = (iS = ibuf) + fread (ibuf, 1, SIZE, stdin), (iS == iT ? EOF : *iS ++)) : *iS ++)
	// print the remaining part
	inline void flush () {
		fwrite (obuf, 1, oS - obuf, stdout);
		oS = obuf;
	}
	// putchar
	inline void putc (char x) {
		*oS ++ = x;
		if (oS == oT) flush ();
	}
	// input a signed integer
	template <class I>
	inline void gi (I &x) {
		for (f = 1, c = gc(); c < '0' || c > '9'; c = gc()) if (c == '-') f = -1;
		for (x = 0; c <= '9' && c >= '0'; c = gc()) x = (x << 1) + (x << 3) + (c & 15); x *= f;
	}
	// input a letter
	template <class I>
	inline void get (I &x) {
		for (c = gc(); c < 'A' || c > 'Z'; c = gc()) ;
		x = c;
	}
	// input a string
	inline void read (char *s){
		for(c = gc(); c < 'A' || c > 'Z'; c = gc()) ;
		for(; c >= 'A' && c <= 'Z'; c = gc()) *++s = c;
		*++s = '\0';
	}
	// print a signed integer
	template <class I>
	inline void print (I x) {
		if (!x) putc ('0'); if (x < 0) putc ('-'), x = -x;
		while (x) qu[++ qr] = x % 10 + '0',  x /= 10;
		while (qr) putc (qu[qr --]);
	}
	//no need to call flush at the end manually!
	struct Flusher_ {~Flusher_(){flush();}}io_flusher_;
}
using io :: gi;
using io :: get;
using io :: read;
using io :: putc;
using io :: print;
const int N=2e5+5,mod=1e9+7,inv2=mod+1>>1;
int n,a[N],c[N],pre[N],pos[N],inv[N],t[N];
inline void add(int &x,ri y){
	x=(x+=y)>=mod?x-mod:x;
}
inline int _sub(ri x,ri y){
	return (x-=y)<0?x+mod:x;
}
struct node{
	int v[N];
	inline void upd(ri i,ri x){
		for(;i<=n;i+=i&-i)
			add(v[i],x);
	}
	inline int query(ri i){
		ri s=0;
		for(;i;i-=i&-i) add(s,v[i]);
		return s;
	}
	inline int modify(ri l,ri r){
		return l<=r?_sub(query(r),query(l-1)):0;
	}
	inline void clear(){
		for(ri i=1;i<=n;++i) v[i]=0;
	}
}bit,cnt;
inline int fpow(ri a,ri b){
	ri ans=1;
	for(;b;b>>=1,a=(ll)a*a%mod)
		if(b&1)
			ans=(ll)ans*a%mod;
	return ans;
}
int main(){
	ri i,p,S,ans;
	gi(n);
	for(i=1;i<=n;++i) gi(a[i]),++c[a[i]];
	for(i=n;i;--i) c[i]+=c[i+1];
	S=1;
	for(i=1;i<=n;++i){
		if(c[i]<=n-i) return puts("0"),0;
		c[i]-=n-i;
		S=(ll)S*c[i]%mod;
		pre[i]=pre[i-1]+(c[i]==1);
	}
	p=1;
	for(i=1;i<=n;++i){
		for(;p+1<=n&&pre[p+1]==pre[i];++p);
		pos[i]=p;
	}
	inv[1]=1;
	for(i=2;i<=n;++i) inv[i]=(ll)(mod-mod/i)*inv[mod%i]%mod;
	t[0]=1;
	for(i=1;i<=n;++i) t[i]=c[i]>1?(ll)t[i-1]*(c[i]-1)%mod*inv[c[i]]%mod:t[i-1];
//	for(i=1;i<=n;++i) printf("%d ",t[i]); puts("");
//	for(i=1;i<=n;++i) printf("%d ",pos[i]); puts("");
	ans=0;
	for(i=n;i;--i)
		ans=(ans+(ll)bit.modify(a[i],pos[a[i]])*fpow(t[a[i]],mod-2)%mod*S%mod*inv2)%mod,
		bit.upd(a[i],t[a[i]]);
//	printf("ans = %d\n",ans);
	bit.clear();
	for(i=1;i<=n;++i)
		ans=(ans-(ll)bit.modify(a[i]+1,pos[a[i]])*fpow(t[a[i]],mod-2)%mod*S%mod*inv2)%mod,
		ans=(ans+(ll)cnt.modify(a[i]+1,n)*S)%mod,
		bit.upd(a[i],t[a[i]]),
		cnt.upd(a[i],1);
	ans=ans<0?ans+mod:ans;
//	puts("bingo");
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 10496
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
int main(void)
{
	char a[201],b[201],c;
	int i,j,h,n,len,x;
	while(1)	{
		scanf("%s",a);
		len=strlen(a);
		if(a[0]=='-')	break;
		scanf("%d",&n);
		for(i=0;i<n;i++)	{
			scanf("%d",&h);
			x=len-h;
			for(j=0;j<h;j++)	{
				b[x]=a[j];
				x++;
			}
			x=0;
			for(j=h;j<len;j++)	{
				b[x]=a[j];
				x++;
			}
			for(j=0;j<len;j++)	{
				a[j]=b[j];
			}
		}
		printf("%s\n",a);
	}
	return 0;
}


Measured memory_bytes: 1012
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

class Program
{
    static void Main(string[] args)
    {
        string s = Console.ReadLine();
        if (s.Equals("AAA") || s.Equals("BBB")) Console.WriteLine("No");
        else Console.WriteLine("Yes");

        
        

    }

  




}





Measured memory_bytes: 11092
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cassert>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <map>
#include <set>
#include <cassert>
#include <string.h>
#include <iomanip>

using namespace std;

int main()
{
	string S, T;
	cin >> S >> T;
	int A, B;
	cin >> A >> B;
	string U;
	cin >> U;
	
	if (S == U) A = A - 1;
	else if (T == U){
		B = B -1;
	}
	cout << A <<" " <<B <<endl;
	
	
	
	
	
	
	
	
	return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,i,r=-1;
    string s;
    map<string,int>m;
    cin>>n;
    for(i=0; i<n; i++)
    {
        cin>>s;
        m[s]++;
    }
    for(auto & it:m)
        r=max(r,it.second);
    for(auto & it: m)
    {
        if(it.second==r)
            cout<<it.first<<endl;
    }
}


Measured memory_bytes: 19264
#include<bits/stdc++.h>
#define LL long long
#define REP(i,n) for(int i=0;i<(n);++i)
#define PER(i,n) for(int i=n-1;i>=0;--i)
#define REPA(i,n) for(int i=1;i<(n);++i)
#define foreach(i, n) for(auto &i:(n))
#define PII pair<int,int>
#define PLI pair<long long, int>
#define PLL pair<long long, long long>
#define MOD ((LL)1e9+7) 
#define INF ((int)1e9+7)
#define INFLL ((LL)1e18)
#define ALL(x) (x).begin(),(x).end()
#define BIT(x) (1LL << (x))
using namespace std;

LL modpow(LL x, LL b){
	LL res = 1;
	while(b){
		if(b&1)res = res * x % MOD;
		x = x * x % MOD;
		b>>=1;
	}
	return res;
}

LL modinv(LL x){
	return modpow(x, MOD-2);
}

int main(){
	int N;
	cin >> N;
	vector<vector<int>> pos(N, vector<int>(3));
	foreach(i, pos){
		foreach(j, i)cin>>j;
	}
	REP(i, 101){
		REP(j, 101){
			int h;
			foreach(k, pos){
				if(k[2]==0)continue;
				h = abs(i - k[0]) + abs(j - k[1]) + k[2];
				break;
			}
			bool flag = true;
			foreach(k, pos){
				if(k[2]==0){
					if(abs(i-k[0])+abs(j-k[1]) < h){
						flag=false;
						break;
					}
				}else if(h != abs(k[0] - i) + abs(k[1] - j) + k[2]){
					flag=false;
					break;
				}
			}
			if(flag){
				cout << i << " " << j << " " << h << endl;
				return 0;
			}
		}
	}	
	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 RFOR(i,b,a) for (int i = (b)-1; i >= (a); --i)
#define ITER(it,a) for (__typeof(a.begin()) it = a.begin(); it != a.end(); it++)
#define FILL(a,value) memset(a, value, sizeof(a))

#define SZ(a) (int)a.size()
#define ALL(a) a.begin(), a.end()
#define PB push_back
#define MP make_pair

typedef long long LL;
typedef vector<int> VI;
typedef pair<int, int> PII;

const double PI = acos(-1.0);
const int INF = 1000 * 1000 * 1000 + 7;
const LL LINF = 1LL * INF * INF;

const int MAX = 100100;

vector<PII> g[MAX];
int C[MAX];
pair<int,PII> Q[MAX];

int us[MAX];

int ID = 1;

int done = 0;
int n;

PII q[MAX];
int qt,qh;
void paint(int v,int d,int c)
{
	if(done== n)return;
	ID++;
	qt=qh=0;
	q[qt++]=(MP(v,d));
	us[v]=ID;
	if(C[v] == 0)C[v] = c,++done;
	while(qh!=qt)
	{
		int v = q[qh].first;
		int d = q[qh].second;
//		cerr<<v<<" "<<d<<" "<<c<<" "<<C[v]<<endl;
		++qh;
		if(d==0)continue;

		FOR(i,0,SZ(g[v]))
		{
			int to = g[v][i].first;
			int ds = g[v][i].second;
			if(ds>=d)continue;
			if(us[to]==ID)continue;
			g[v][i].second = d;
			if(C[to]==0)
			{
				C[to]=c;
				++done;
				if(done == n)return;
			}
			us[to]=ID;
			if(d==1)continue;

			q[qt++]=(MP(to,d-1));
		}
	}
}
int main()
{
	//freopen("in.txt", "r", stdin);
	//ios::sync_with_stdio(false); cin.tie(0);

	int m;

	scanf("%d%d",&n,&m);

	FOR(i,0,m)
	{
		int a,b;
		scanf("%d%d",&a,&b);
		--a;--b;
		g[a].PB(MP(b,0));
		g[b].PB(MP(a,0));
	}

	int q;
	scanf("%d",&q);
	FOR(i,0,q)
	{
		scanf("%d%d%d",&Q[i].first,&Q[i].second.first,&Q[i].second.second);
		--Q[i].first;
	}

	RFOR(i,q,0)
	{
		paint(Q[i].first,Q[i].second.first,Q[i].second.second);
	}

	FOR(i,0,n)
	{
		printf("%d\n",C[i]);
	}
}


Measured memory_bytes: 9588
#include <iostream>
#include <algorithm>
using namespace std;
int main(){
	int a = 1 , b = 1;
	while (a != 0 || b != 0){
		cin >> a >> b;
		if (a != 0 || b != 0){
			if (a > b)
				swap(a, b);
			cout << a << " " << b << endl;
		}
	}
	return 0;
}


Measured memory_bytes: 3076
N = int(input())
A = list(map(int,input().split()))

MAXN = N+1
p = 10**9+7
f = [1]
for i in range(MAXN):
    f.append(f[-1] * (i+1) % p)
def nCr(n, r, mod=p):
    return f[n] * pow(f[r], mod-2, mod) * pow(f[n-r], mod-2, mod) % mod

MA = max(A)
out = [MA,0]
MA2 = MA//2
mincand = 10**9
for i in range(N):
    if mincand>abs(A[i]-MA2) and A[i]!=MA:
        mincand = abs(A[i]-MA2)
        out[1] = A[i]
print(*out)

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

int main() {
  int N, M;
  cin >> N >> M;
  vector<int> H(N), C(N, 1);
  for (int i=0; i<N; i++) {
    cin >> H[i];
  }
  
  int a,b;
  for (int i=0; i<M; i++) {
    cin >> a >> b;
    a--;
    b--;
    if (H[a]>H[b]) {
      C[b]=0;
    }
    else if (H[a]==H[b]) {
      C[b]=0;
      C[a]=0;
    }
    else {
      C[a]=0;
    }
  }
  
  int S=0;
  for (int i=0; i<N; i++) {
    S+=C[i];
  }
  cout << S << endl;
}

Measured memory_bytes: 4060