akhauriyash/Code-Regression huggingface dataset:
#pragma region header
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
#define rev(i, n) for(int i = (int)(n - 1); i >= 0; i--)
#define rev1(i, n) for(int i = (int)(n); i > 0; i--)
#define pb push_back
#define all(v) (v).begin(), (v).end()
#define resort(v) sort((v).rbegin(), (v).rend())
#define vi vector<int>
#define vvi vector<vector<int>>
#define vc vector<char>
#define vvc vector<vector<char>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
using ll = long long;
using P = pair<int, int>;
/* ----------------よく使う数字や配列----------------- */
int dx[] = {1,0,-1,0};
int dy[] = {0,1,0,-1};
constexpr ll mod = 1e9+7;
constexpr ll inf = INT32_MAX/2;
constexpr ll INF = LLONG_MAX/2;
constexpr long double eps = DBL_EPSILON;
constexpr long double pi = 3.141592653589793238462643383279;
/* ----------------------end----------------------- */

/* --------------------テンプレート------------------ */
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a <= b) {
        a = b;
        return true;
    }
    return false;
}
/* ----------------------end----------------------- */

/* --------------------ライブラリ-------------------- */
ll fact(int i) {       //階乗
    if (i == 0) return 1;
    return (fact(i - 1)) * i % mod;
}
ll gcd(ll a, ll b) {        //最大公約数
    if(b == 0) return a;
    return gcd(b, a % b); 
}
ll lcm(ll a, ll b) {      //最小公倍数
    return a * b / gcd(a, b);
}
int keta(ll n) {        //桁数を求める
    if(n == 0) return 1;
    int count = 0;
    while(n != 0) {
        n /= 10;
        count++;
    }
    return count;
}
ll ketasum(ll n) {    //各桁の和
    ll sum = 0;
    while(n != 0) {
        sum += n % 10;
        n /= 10;
    }
    return sum;
}
/* ----------------------end----------------------- */
#pragma endregion
signed main() {
    int n,m;cin >> n >> m;
    vvi a(m,vi(4));
    // vvi ans = a;
    rep(i, m) {
        cin >> a[i][0] >> a[i][1];
        a[i][3] = i;
    }
    map<int,int> mp;
    sort(all(a));
    rep(i, m) {
        mp[a[i][0]]++;
        // rep(j, 6-keta(a[i][0])) cout << 0;
        // cout << a[i][0];
        // rep(j, 6-keta(mp[a[i][0]])) cout << 0;
        // cout << mp[a[i][0]];
        // cout << endl;
        a[i][2]=mp[a[i][0]];
        swap(a[i][0],a[i][3]);
    }
    sort(all(a));
    // rep(i, m) cout << a[i][0] << endl;
    // for(auto p:a)cout << p[0] << ' ' << p[1] << ' ' << p[2] << ' ' << p[3] << endl;
    rep(i, m) {
        rep(j, 6-keta(a[i][3])) cout << 0;
        cout << a[i][3];
        rep(j, 6-keta(a[i][2])) cout << 0;
        cout << a[i][2];
        cout << endl;
    }
    return 0;
}

Measured memory_bytes: 16236
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;

#define ll long long
#define ld long double
typedef vector <ll> vi;                 // Vector of long long
typedef vector <vi> vvi;                // Vector of vi
typedef vector <pair<ll,ll>> ii;        // Vector of pairs
#define ff first                        // For pairs
#define ss second                       // For pairs
#define sz(a) int((a).size())           // Function to determine size of any container
#define pb push_back                    // Pushback to vector
#define mp make_pair                    // Makes pairs to be stored as pair
#define all(c) (c).begin(), (c).end()   // Mainly used by me in sorting
// ordered_set adds two new functions to set - (set).find_by_order([kth element based on zero indexing]) and order_of_key()
// order_of_key returns number of elements less that parameter. If element exists, that order is its index
#define ordered_set tree < ll ,  null_type ,  less<ll> ,  rb_tree_tag ,  tree_order_statistics_node_update >
#define MAXV (ll)(1e5 + 5)
#define INF (ll)(1e12)

int main(void)
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    ll n, w;
    cin >> n >> w;

    ll mg[n], val[n];
    for (int i = 0; i < n; i++)
        cin >> mg[i] >> val[i];

    ll dp[n + 1][MAXV];

    for (int i = 1; i < MAXV; i++)
        dp[0][i] = INF;
    dp[0][0] = 0;

    for (int i = 1; i <= n; i++)
    {
        for (int j = 0; j < MAXV; j++)
        {
            ll ans = INF;
            if (j - val[i - 1] >= 0)
                ans = dp[i - 1][j - val[i - 1]] + mg[i - 1];
            ans = min(ans, dp[i - 1][j]);

            dp[i][j] = ans;
        }
    }

    /* for (int i = 0; i <= n; i++)
        for (int j = 0; j < MAX; j++)
            cout << dp[i][j] << " \n"[j == MAX - 1]; */

    for (int i = MAXV-1; i >= 0; i--)
    {
        if (dp[n][i] <= w)
        {
            cout << i << "\n";
            break;
        }
    }
}


Measured memory_bytes: 79232
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const long long maxn=100050;
vector< pair<ll,ll> > v[maxn];
int col[maxn];
void dfs(ll now,ll p){
	for (int i=0;i<v[now].size();i++){
		ll nxt=v[now][i].first;
		ll w=v[now][i].second;
		if (nxt!=p){
			col[nxt]=col[now]^w;
			dfs(nxt,now);
		}
	}
}
int main()
{
	ll n;
	cin >> n;
	for (int i=1;i<=n-1;i++){
		int x, y, z;
		cin >> x >> y >> z;
		z%=2; 
		v[x].push_back(make_pair(y,z));
		v[y].push_back(make_pair(x,z));
	}	
	dfs (1,-1);
	for (int i=1;i<=n;i++)
		cout << col[i] << endl;
	return 0;
} 
/*
5
2 5 2
2 3 10
1 3 8
3 4 2
*/

Measured memory_bytes: 9856
#include <bits/stdc++.h>
using namespace std;
 
int main()
{
    string s1,s2;
    cin>>s1>>s2;
    s1=(s1+s2);
    int k,x;
    k=stoi(s1);
    x=sqrt(k);
    if(x*x==k)
        cout<<"Yes";
    else
        cout<<"No";
    return 0;
}
 

Measured memory_bytes: 3588
t = []
temp = 0
while True:
        d,w,h = [int(s) for s in input().split(' ')]
        if d < w:
            temp = d
        else:
            temp = w
        if d == 0 and w == 0 and h == 0:
            break
        else:
            n = int(input())
            for i in range(n):
                t.append(i)
                t[i] = int(input())
                if (temp/2) ** 2 + (h/2) ** 2 < t[i] ** 2:
                    print("OK")
                else:
                    print("NA")



Measured memory_bytes: 5604
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 1e5 + 5, mod = 1e9 + 7;

int n, a, b, c, d;
bool exist = true;
string s;

bool jumpb();
bool jumpa()
{
    if (s[a + 1] == '.' && a + 1 != b) ++a;
    else if (s[a + 2] == '.' && a + 2 != b) ++a, ++a;
    else{
        if (s[b + 1] == '.') ++b;
        else if (s[b + 2] == '.') ++b, ++b;
        else return false;
    }
    return true;
}
bool jumpb()
{
    if (s[b + 1] == '.' && b + 1 != a) ++b;
    else if (s[b + 2] == '.' && b + 2 != a) ++b, ++b;
    else{
        if (s[a + 1] == '.') ++a;
        else if (s[a + 2] == '.') ++a, ++a;
        else return false;
    }
    return true;
}
void walka()
{
    while (a < c){
        if (!jumpa()){
            exist = 0;
            break;
        }
    }
}
void walkb()
{
    while (b < d){
        if (!jumpb()){
            exist = 0;
            break;
        }
    }
}
int main()
{
    //ios::sync_with_stdio(0); cin.tie(0);

    cin >> n >> a >> b >> c >> d >> s;
    --a, --b, --c, --d;

    if (c < b){
        walka();
        walkb();
    }else if (c < d){
        walkb();
        walka();
    }else{
        walka();
        walkb();
    }
    if (a > c || b > d) exist = 0;
    if (exist) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}


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

typedef long long ll;
#define mod 1000000007

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif

void solve(){
    ll n;
    cin>>n;
    vector<ll> a(n);
    for(auto& e:a){
        cin>>e;
    }
    ll ans = 0;
    ll mx = a[0];
    for(int i = 1; i < n; i++){
        ans += max(mx - a[i], 0LL);
        mx = max(a[i], mx);
    }
    cout<<ans<<"\n";
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int t = 1;
    // cin >> t;
    // pre();
    while (t--)
        solve();

    return 0;
}

Measured memory_bytes: 4760
object Main extends App {
  import scala.io.StdIn._
  val g = Array.tabulate(201){_ ⇒ Array.tabulate(101){_ ⇒ -1}}
  g(0)(0) = 0
  for (w ← 0 until 100; b ← 0 until 100) grundy(w, b)
  val state = Array.tabulate(readInt){_ ⇒
    val Array(white, black) = readLine.trim.split(' ').map(_.toInt)
    grundy(white, black)
  }
  println(
    if (state.foldLeft(0){(a, b) ⇒ a ^ b} != 0) 0 else 1
  )
  def grundy(white: Int, black: Int): Int = {//先手必勝ならtrue
    if (g(white)(black) != -1) g(white)(black)
    else if (black == 0) white % 2
    else {
      var all = (1 to math.min(white, black)).reverse.map(remove ⇒ grundy(white, black - remove)).distinct.toList
      if (white > 0) all ::= grundy(white - 1, black)
      if (black > 0) all ::= grundy(white + 1, black - 1)
      val set = all.toSet
      g(white)(black) = (0 until 1000).find(!set.contains(_)).get
      g(white)(black)
    }
  }
}


Measured memory_bytes: 226768
S=[]
for i in range(10):
    n=int(input())
    S.append(n)
    i+=1
    
T=[]
for j in range(10):
    m=int(input())
    T.append(m)
    j+=1
    
A=[]
for k in range(3):
    a=max(S)
    S.remove(a)
    A.append(a)
    
B=[]
for l in range(3):
    b=max(T)
    T.remove(b)
    B.append(b)
    
P=sum(A)
Q=sum(B)

print(P,Q)



Measured memory_bytes: 5592
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <limits.h>
#include <queue>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
#define REP(i, n) for(int i=0; i<n; i++)
#define TLIM 2*110100

bool hist[40][TLIM];
int main(){
    int N, C;
    cin >> N >> C;
    int s,t,c;
    REP(i,N){
        cin >> s >> t >> c;
        s = s*2 - 1;
        t *= 2;
        for(;s < t; s++)
            hist[c][s] = true;
    }

    int ans = 0;
    REP(t,2*TLIM){
        int num = 0;
        REP(ch, C+1){
            if(hist[ch][t]) num++;
        }
        ans = max(ans, num);
    }
    cout << ans << endl;
    return 0;
}


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

int main()
{
    int n,k,x,y;
    cin >> n >> k >> x >> y;
    int total=0;
    if(k >= n){
        total = x * n;
    }
    else {
        total = (x * k) + (y * (n-k));
    }
    
    cout << total << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cmath>
#include <algorithm>
#define rep(i, n)   for(int i = 0; i < (n); i++)
using namespace std;

int main(){
    string s;	cin >> s;
    //solve
    bool alphabet[27] = {false};    //true:使用済み
    rep(i, s.size()){
	alphabet[s[i] - 'a'] = true;
    }
    rep(i, 27){
	if(i <= 25){
	    if(!alphabet[i]){
		cout << (char)('a' + i)<< endl;
		return 0;
	    }
	}else{
	    cout << "None" << endl;
	}
    }
    return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
 
int main(){
    int r;
    cin>>r;
    if(r<1200){
        cout<<"ABC"<<endl;
    }
    else if(r<2800){
        cout<<"ARC"<<endl;
    }
    else{
        cout<<"AGC"<<endl;
    }
}

Measured memory_bytes: 256
program example
	implicit none

	integer :: H,A,i=0
    
    read(*,*)H,A
    
    do 
    
    	if (H-A>0) then
        	H=H-A
            i=i+1
        else
        	i=i+1
        	exit
        end if
    end do
    
    write(*,*) i

end program example

Measured memory_bytes: 384
N = int(input())
X = list(map(int, input().split()))
X_min = min(X)
X_max = max(X)
S = []
for base_point in range(X_min, X_max+1):
    sum_X = 0
    for X_i in X:
        sum_X += (X_i-base_point)**2
    S.append(sum_X)
print(min(S))


Measured memory_bytes: 3060
#include<iostream>
#include<sstream>
#include<cstdio>
#include<fstream>
#include<vector>
#include<list>
#include<stack>
#include<queue>
#include<deque>
#include<map>
#include<set>
#include<algorithm>
#include<string>
#include<cmath>
#include<cstdlib>
using namespace std;

int size(int n){
	int ret = 0;
	while(n>0){
		++ret;
		n/=10;
	}
	return ret;
}

int main(){
	int i,j;
	while(scanf("%d %d",&i,&j)==2){
		printf("%d\n",size(i+j));
	}
	return 0;
}

Measured memory_bytes: 1188
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define pii pair<int, int>
#define pll pair<ll, ll>
#define str string
#define fi first
#define se second
#define pb push_back
#define SET(a, b) memset(a, b, sizeof(a))
#define eps 1e-6
#define pi atan(1) * 4
#define mod 1000000007
#define inf 1000000000
#define llinf 1000000000000000000
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define FORD(i, a, b) for (int i = (a); i >= (b); i--)
#define FORl(i, a, b) for (ll i = (a); i <= (b); i++)
#define FORDl(i, a, b) for (ll i = (a); i >= (b); i--)
using namespace std;
pii num[55];
map<pii, int> freq;
int main () {
  int n;
  scanf("%d", &n);
  FOR(i, 1, n) {
    scanf("%d %d", &num[i].fi, &num[i].se);
  }
  int mx = 0;
  FOR(i, 1, n) {
    FOR(j, 1, n) {
      if (i == j) continue;
      int dx = num[j].fi - num[i].fi;
      int dy = num[j].se - num[i].se;
      mx = max(mx, ++freq[{dx, dy}]);
    }
  }
  printf("%d\n", n - mx);
  return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define itn int
#define rep(i,x,y) for(int i=x;i<y;i++)
#define range(a) a.begin(),a.end()
#define print(A) rep(i,0,A.size()){cout<<(i ? " ":"")<<A[i];}cout<<endl;
const int mod=1e9+7;
int main(){
	int N,D;cin>>N>>D;
	int X[N][D];
	int res=0;
    rep(i,0,N){
        rep(j,0,D){
            cin>>X[i][j];
        }
    }
	rep(i,0,N){
		rep(j,0,i){
			int sum=0;
			rep(k,0,D){
				sum+=(X[i][k]-X[j][k])*(X[i][k]-X[j][k]);
			}int a=(int)sqrt(sum);
            if(sum==a*a) res++;
            //cout<<sum<<endl;
		}
	}cout<<res<<endl;
}

Measured memory_bytes: 256
#include<stdio.h>
void swap(int *a , int *b) {
	int tmp;
	tmp = *a;
	*a = *b;
	*b = tmp;
}
int main () {
	int a , b;
	while(1) {
		scanf("%d %d" , &a , &b);
		if (a == 0 && b == 0) break;
		if (b < a) swap(&a , &b);
		printf("%d %d\n" , a , b);
	}
	return 0;
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 1e5 + 5;
ll fact[N], inv_fact[N];
const ll mod = 1e9 + 7;
ll mul(ll a, ll b) {
    return (a * b) % mod;
}
ll fp(ll base, ll pw) {
    if (pw == 1) return base;
    if (base == 0) return 0;
    if (pw == 0) return 1;
    ll x = fp(base, pw / 2);
    x = mul(x, x);
    if (pw & 1) x = mul(x, base);
    return x;
}
void build() {
    fact[0] = inv_fact[0] = 1;
    for (int i = 1; i < N; i++) {
        fact[i] = mul(i, fact[i - 1]);
        inv_fact[i] = fp(fact[i], mod - 2);
    }
}
ll ncr(ll n, ll r) {
    if (r > n) return 0;
    ll A = fact[n];
    ll B = mul(inv_fact[r], inv_fact[n - r]);
    return mul(A, B);
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    build();
    int n, k;
    cin >> n >> k;
    for (int i = 1; i <= k; i++) cout << mul(ncr(n - k + 1, i), ncr(k - 1, i - 1)) << '\n';
    return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <string>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int mod = 1000000007;

int main() {
    ios::sync_with_stdio(false);
    int n, a[100005] = {}, b[100005] = {}, x, c = 0, d = 0, e = 0, f = 0;
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> x;
        if (i % 2) a[x]++;
        else b[x]++;
    }
    for (int i = 1; i <= 100000; i++) {
        if (a[i] > a[c]) d = c, c = i;
        else if (a[i] > a[d]) d = i;
        if (b[i] > b[e]) f = e, e = i;
        else if (b[i] > b[f]) f = i;
    }
    if (c != e) cout << n - a[c] - b[e];
    else cout << n - a[c] - b[e] + min(a[c] - a[d], b[e] - b[f]);
}


Measured memory_bytes: 1024
#include<cstdio>
#include<cstring>
using namespace std;

char s[11];

int main()
{
	scanf("%s",&s[1]); int len=strlen(s+1);
	bool flag=false;
	for (int i=1; i<len; ++i)
		if (s[i]=='A'&&s[i+1]=='C') {flag=1;break;}
	if (flag) printf("Yes"); else printf("No");
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define rep(i, n) for(int i=0; i<(int)(n); ++i)
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0), cout.tie(0);
  string s;
  cin >> s;
  cout << s.substr(0, 3) << endl;
}

Measured memory_bytes: 3564
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <map>
#include <cstring>
using namespace std;
#define MAXH 101
#define MAXW 101
#define INF 1000
#define MAXN 100001

int N, M;

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

int gcd(int a, int b, int c){
    return gcd(gcd(a, b), c);
}


int main(){
    cin >> N;
    long long sum = 0;
    for(int i = 1;i <= N;i++){
        for(int j = 1;j <= N;j++){
            for(int k = 1;k <= N;k++){
                sum += gcd(i, j, k);
            }
        }
    }

    printf("%lld\n", sum);
    
    return 0;
}


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

long long int solve(int *a,int *b,int n,int w){
	long long int dp[n+1][w+1];
	for(int i=0;i<=w;i++)
		dp[0][i]=0;
	for(int i=0;i<=n;i++)
		dp[i][0]=0;
		
	for(int i=1;i<=n;i++){
		for(int j=0;j<=w;j++){
			if(b[i-1]>j)
				dp[i][j]=dp[i-1][j];
			else
				dp[i][j]=max(dp[i-1][j],dp[i-1][j-b[i-1]]+a[i-1]);
		}
	}
	
/*	for(int i=0;i<=n;i++){
		for(int j=0;j<=w;j++){
			cout<<dp[i][j]<<" ";
		}cout<<endl;
	}
*/	
	return dp[n][w];
}

int main() {
	// your code goes here
	int n,w;
	cin>>n>>w;
	int a[n],b[n];
	for(int i=0;i<n;i++){
		cin>>b[i]>>a[i];
	}
	
	long long int aa=solve(a,b,n,w);
	cout<<aa<<endl;
	return 0;
}

Measured memory_bytes: 79104
#+swank(declaim (optimize (speed 0) (debug 3) (safety 3)))
#-swank(declaim (optimize (speed 3) (debug 0) (safety 0)))

(defmacro ret (bindings body)
  `(labels ((rec ,(mapcar #'car bindings) ,@body))
     (rec ,@ (mapcar #'cadr bindings))))

(defun char-or (str i default)
  (cond ((minusp i) default)
        (t (char str i))))

(defun x=y? (i str)
  (eq (char-or str i nil) (char-or str (1- i) nil)))

(defun xy=zw? (i str)
  (and 
   (eq (char-or str i nil) (char-or str (- i 2) nil))
   (eq (char-or str (1- i) nil) (char-or str (- i 3) nil))))

(defun solve (str)
  (labels ((rec (i ny nyz nz nzw)
             (cond ((>= i (length str)) (max ny nyz))
                   (t (rec (1+ i)
                           (cond ((x=y? i str) (1+ nyz))
                                 (t (1+ (max ny nyz))))
                           (cond ((xy=zw? i str) (1+ nz))
                                 (t (1+ (max nz nzw))))
                           ny
                           nyz)))))
    (rec 1 1 -1000000000 0 0)))

(format t "~a~%" (solve (read-line)))


Measured memory_bytes: 17636
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<algorithm>
#include<cmath>
#include<queue>
#include<vector>
#include<stack>
using namespace std;

#define REP(i,n) for(int i=0;(i)<(n);(i)++)
#define ll long long

int main() {
	ll N, M;
	cin >> N >> M;
	
	ll ans;

	if (2 * N <= M) {
		ans = N + (M - 2 * N) / 4;
	}
	else {
		ans = M / 2;
	}

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

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

int main() {
  int N, Q;
  string S;

  cin >> N >> Q >> S;

  vector<int> l(Q), r(Q);
  for (int i = 0; i < Q; i++) cin >> l[i] >> r[i];

  vector<int> sum(N + 1, 0);

  for (int i = 1; i < N; i++) {
    if (S[i - 1] == 'A' && S[i] == 'C') sum[i + 1] = sum[i] + 1;
    else sum[i + 1] = sum[i];
  }

  for (int i = 0; i < Q; i++) {
    int ans = sum[r[i]] - sum[l[i]];
    cout << ans << endl;
  }
}



Measured memory_bytes: 2176
def lower_elements(A, b):
    lower_bound = -1
    upper_bound = len(A)
    while upper_bound - lower_bound > 1:  # ア
        middle = (lower_bound + upper_bound) // 2
        if A[middle] < b:  # イ
            lower_bound = middle
        else:
            upper_bound = middle
    return lower_bound + 1  # ウ upper_boundでも可


def upper_elements(C, b):
    lower_bound = -1
    upper_bound = len(C)
    while upper_bound - lower_bound > 1:  # ア
        middle = (lower_bound + upper_bound) // 2
        if C[middle] <= b:
            lower_bound = middle
        else:
            upper_bound = middle
    return len(C) - upper_bound


def answer(N: int, A: list, B: list, C: list):
    assert N == len(A) == len(B) == len(C)
    A.sort()
    B.sort()
    C.sort()
    count = 0
    for b in B:
        count += lower_elements(A, b) * upper_elements(C, b)
    return count


def snuke_festival():
    N = int(input())
    A = list(map(int, input().split()))
    B = list(map(int, input().split()))
    C = list(map(int, input().split()))
    print(answer(N, A, B, C))


if __name__ == '__main__':
  snuke_festival()

Measured memory_bytes: 24052
n=int(input())
bn=list(map(int,input().split()[:n-1]))
an=[0]*n
for i in range(n-1):
    if i==0:
        an[0]=bn[0]
        an[1]=bn[0]
    else:
        if an[i] >= bn[i]:
            an[i]=bn[i]
        an[i+1]=bn[i]

print(sum(an))

Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
#include <utility>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <math.h>
#include <string.h>
#include <iomanip>
#include <numeric>
#include <cstdlib>
#include <cstdint>
#include <cmath>
#include <functional>
#include <limits>
#include <cassert>
#include <bitset>
 
using namespace std;
 
/* template */
 
using ll = long long;
 
void debug_out() { std::cout << std::endl; }
 
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cout << H << " ";
  debug_out(T...);
}
 
#ifdef LOCAL
#define debug(...) cout << "debug: "; debug_out(__VA_ARGS__)
#else
#define debug(...) 
#endif
 
#define rep(i, a, n) for (int i = (int)(a); i < (int)(n); i++)
#define rrep(i, a, n) for (int i = ((int)(n-1)); i >= (int)(a); i--)
#define Rep(i, a, n) for (long long i = (long long)(a); i< (long long)(n); i++)
#define RRep(i, a, n) for (long long i = ((long long)(n-1ll)); i>=(long long)(a); i--)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
 
template <typename T>
std::ostream& operator<<(std::ostream& os, std::vector<T> vec) {
  for (std::size_t i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
  return os;
}
 
struct Edge{
    int to;
    ll weight;
    Edge(int t, ll w) : to(t), weight(w){ }
};
 
struct edge{
    int from;
    int to;
    ll weight;
    edge(int f,int t,ll w) : from(f), to(t), weight(w){ }
};
 
 
using Graph = vector<vector<Edge>>;
using graph = vector<vector<int>>;
using edges = vector<edge>;
 
template <class T>
inline bool chmin(T &a, T b){
    if (a > b){
        a = b;
        return true;
    }
    return false;
}
 
template <class T>
inline bool chmax(T &a, T b){
    if (a < b){
        a = b;
        return true;
    }
    return false;
}
 
template <class T>
T lcm(T a, T b){
    return (a*b)/gcd(a,b);
}
 
ll ctoi(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 0;
	}
}
 
constexpr ll LNF = 1LL<<50;
 
constexpr int INF = 1e9+7;
 
const long double PI=3.14159265358979323846;
 
 
vector<int> dx = {1,0,-1,1,-1,0};
vector<int> dy = {1,1,1,0,0,-1};
 
/* template */

ll Pow(ll x, ll n){
    ll res = 1;
    while(n>0){
        if(n&1) res = res *x;
        x = x*x;
        n>>=1;
    }
    return res;
}

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    ll n,k; cin >> n >> k;
    ll x = 0ll;
    vector<ll> a(n),b(n);
    rep(i,0,n){
        cin >> a[i] >> b[i];
        if((k|a[i])==k){
            x += b[i];
        }
    }
    ll q = 0;
    rrep(i,0,31){
        if(k & (1ll<<i)){
            ll r = q + Pow(2ll,i) -1ll;
            ll z = 0ll;
            rep(j,0,n){
                if((r|a[j])==r){
                    z += b[j];
                }
            }
            chmax(x,z);
        }
        else{
            continue;
        }
        q += Pow(2ll,i);
    }
    cout << x << endl;
}

Measured memory_bytes: 4788
#include <bits/stdc++.h>
 
using namespace std;
 
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  string s;
  cin >> s;
  string dup = s;
  reverse(dup.begin(), dup.end());
  cout << (dup == s ? "Yes" : "No") << '\n';
  return 0;
}

Measured memory_bytes: 256
import math

a, b, h, m = map(int,input().split())
s_a = m * 6.0;
s_b = (h * 360 / 12.0) + (m * 30 /60.0);
s_c = abs(s_a - s_b);
s_c = min(s_c,360-s_c)
ans =  a*a + b*b - 2*a*b*math.cos(s_c * math.pi /180.0);
print(math.sqrt(ans))


Measured memory_bytes: 9488
#include "math.h"
#include <iostream>
#include <fstream>
#include <algorithm>
#include <string>
#include <map>
#include <vector>
#include <functional>
#include <numeric>
#include <cmath>
using namespace std;

int main()
{
	int n;
	cin >> n;
	long long ans = 0;
	for (int i = 0; i < n; i++)
	{
		//vertices
		ans += 1LL*(i+1)*(n - i);
	}
	for (int i = 0; i < n-1; i++)
	{
		int u, v;
		cin >> u >> v;
		//edges
		if (u<=v)
		{
			ans -= 1LL*(u) * (n - v+1);
		}
		else {
			ans -= 1LL*(v) * (n - u+1);
		}
	}
	cout << ans;
	return 0;
}


Measured memory_bytes: 3636
module Main where

import Control.Applicative
import Text.Printf
import Numeric

main :: IO ()
main = loop

loop :: IO ()
loop = do
   { _ <- getLine
   ; xs <- getInts
   ; let mx = maximum xs
   ; let mn = minimum xs
   ; let sm = sum xs
   ; putInts [mn, mx, sm] 
   }

--

getInts :: IO [Int]
getInts = map read . words <$>getLine

putInts :: [Int] -> IO ()
putInts = putStrLn . unwords . map show

getDoubles :: IO [Double]
getDoubles = map read . words <$>getLine


putDoubles :: [Double] -> IO ()
putDoubles = putStrLn . unwords . map showDouble

showDouble :: Double -> String
showDouble x = showFFloat Nothing x ""

readInt :: String -> Int 
readInt = read 

getStrings :: IO [String]
getStrings = words <$> getLine



Measured memory_bytes: 11484
#include <bits/stdc++.h>
using namespace std;
#define INCANT cin.tie(0), cout.tie(0), ios::sync_with_stdio(false), cout << fixed << setprecision(20);
#define int long long
#define gcd __gcd
#define all(x) (x).begin(), (x).end()
template<class T>
bool chmax(T& a, T b){return (a = max(a, b)) == b;}
template<class T>
bool chmin(T& a, T b){return (a = min(a, b)) == b;}
#define _overload(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(...) _overload(__VA_ARGS__, repi, _rep)(__VA_ARGS__)
#define _rev(i, n) revi(i, n, 0)
#define revi(i, a, b) for(int i = (int)(a - 1); i >= (int)(b); i--)
#define rev(...) _overload(__VA_ARGS__, revi, _rev)(__VA_ARGS__)
#define each(i, n) for(auto&& i: n)
const int INF = 1e18, MOD = 1e9 + 7;
signed main() {
    INCANT;
    int sx, sy, gx, gy, x, y;
    cin>>sx>>sy>>gx>>gy;
    x = sx, y = sy;
    if(sx < gx){
        while(x < gx){
            x++;
            cout<<'R';
        }
    }else{
        while(x > gx){
            x--;
            cout<<'L';
        }
    }

    if(sy < gy){
        while(y < gy){
            y++;
            cout<<'U';
        }
    }else{
        while(y > gy){
            y--;
            cout<<'D';
        }
    }
 
    if(sx < gx){
        while(x > sx){
            x--;
            cout<<'L';
        }
    }else{
        while(x < sx){
            x++;
            cout<<'R';
        }
    }

    if(sy < gy){
        while(y > sy){
            y--;
            cout<<'D';
        }
    }else{
        while(y < sy){
            y++;
            cout<<'U';
        }
    }
 
    if(sy < gy){
        y--;
        cout<<'D';
    }else{
        y++;
        cout<<'U';
    }
    if(sx < gx){
        while(x <= gx){
            x++;
            cout<<'R';
        }
    }else{
        while(x >= gx){
            x--;
            cout<<'L';
        }
    }
    if(sy < gy){
        while(y < gy){
            y++;
            cout<<'U';
        }
    }else{
        while(y > gy){
            y--;
            cout<<'D';
        }
    }
 
    if(sx < gx){
        x--;
        cout<<'L';
    }else{
        x++;
        cout<<'R';
    }
    if(sy < gy){
        y++;
        cout<<'U';
    }else{
        y--;
        cout<<'D';
    }
    if(sx < gx){
        while(x >= sx){
            x--;
            cout<<'L';
        }
    }else{
        while(x <= sx) {
            x++;
            cout<<'R';
        }
    }
 
    if(sy < gy){
        while(y > sy){
            y--;
            cout<<'D';
        }
    }else{
        while(y < sy){
            y++;
            cout<<'U';
        }
    }
    if(sx < gx){
        x++;
        cout<<'R';
    }else{
        x--;
        cout<<'L';
    }
}


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

#if DEBUG && !ONLINE_JUDGE
  #include "header.h"
#else
  #define debug(args...)
#endif

typedef vector<int> vi;
typedef pair<int,int> ii;
typedef long long lli;
typedef long double ld;

#define pb push_back
#define all(x) x.begin(),x.end()
#define SZ(x) (int)(x).size()
#define fi first
#define se second
#define lb lower_bound
#define ub upper_bound
#define rep(i,a,b) for(auto i=(a);i<b;i++)

#define INF (int)1e9
#define EPS 1e-9
#define MOD 1000000007
void preprocess(void) {
  return;
}

vector<vi> adj;
vector<lli> c, a;
int ff = 0;
void dfs(int v, int par = -1) {
  for(auto x: adj[v]) {
    if(x != par) dfs(x, v);
  }
  long long sum = 0;
  int flag = 0;
  for(auto x: adj[v]) {
    if(x != par) {
      sum += c[x];
      flag = 1;
    }
  }
  if(!flag) {
    c[v] = a[v];
  }
  else {
    c[v] = 2*a[v] - sum;
    if(c[v]<0) ff = 1;
    if(par == -1 && c[v] != 0) ff = 1;
  }
}

void dfs1(int v, int par = -1) {
  for(auto x: adj[v]) {
    if(x != par) {
      dfs1(x, v);
    }
  }
  if(SZ(adj[v]) == 1) return;
  long long s = 0;
  long long m = 0;
  for(auto x: adj[v]) {
    if(x!=par) {
      s += c[x];
      m = max(m, c[x]);
    }
  }
  if(SZ(adj[v]) != 1) {
    s += c[v];
    m = max(m, c[v]);
  }
  if(SZ(adj[v]) != 1 && (2*m>s || s%2 == 1)) {
    ff = 1;
  }
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.precision(20);
  preprocess();
  int n; cin>>n;
  adj.resize(n+1, vi(0));
  c.resize(n+1, 0);
  a.resize(n+1);
  rep(i,1,n+1) cin>>a[i];
  rep(i,0,n-1) {
    int x, y; cin>>x>>y;
    adj[x].pb(y);
    adj[y].pb(x);
  }
  int root = -1;
  if(n == 2) {
    if(a[1] != a[2]) cout<<"NO"<<endl;
    else cout<<"YES"<<endl;
    return 0;
  }
  rep(i,1,n+1) if(SZ(adj[i])!=1) root = i;
  debug(root);
  assert(root!=-1);
  dfs(root, -1);
  debug(c);
  if(ff) {
    cout<<"NO"<<endl;
    return 0;
  }
  dfs1(root, -1);
  if(ff) cout<<"NO"<<endl;
  else cout<<"YES"<<endl;
}



Measured memory_bytes: 14464
#include<bits/stdc++.h>
using namespace std;
int main(void)
{
	int n;
	string word[101];
	bool flg=false;
	int i,j;
	
	cin>>n;
	for(i=0;i<n;i++)	cin>>word[i];
	
	for(i=0;i<n-1;i++){
		for(j=i+1;j<n;j++){
			if(word[i]==word[j]){
				flg=true;
			}
		}
	}
	
	for(i=0;i<n-1;i++){
		if(word[i].back()!=word[i+1].front()){
			flg=true;
		}
	}
		
	
	
	
	cout<<((flg)?"No":"Yes")<<endl;
	return 0;
}
		
		
	

Measured memory_bytes: 256
// MYCOP

#include <bits/stdc++.h>

#if SEREZHKA
	#define filename "file"
#else
	#define filename ""
#endif // SEREZHKA

#define forn(i, n) for (llong i = 0ll; i < (llong) n; ++i)
#define fornn(i, l, r) for (llong i = (llong) l; i < (llong) r; ++i)
#define here(str) fprintf(stderr, "here: %s\n", #str)
#define size(x) ((int) (x.size()))

using namespace std;

const int MAX_MEM = (int) 1e8;
int mpos = 0;
char mem[MAX_MEM];

inline void * operator new (size_t n) { char *res = mem + mpos; mpos += n; return (void *) res; }
inline void operator delete (void *) { }

struct __io_dev
{
	__io_dev(const bool& __fastio = false)
	{
		if (__fastio) ios_base::sync_with_stdio(false), cin.tie(nullptr);
		srand(time(nullptr));

		if (!string(filename).empty())
			freopen(filename ".in", "r", stdin), freopen(filename ".out", "w", stdout);
	}

	~__io_dev() { fprintf(stderr, "%.6f ms\n", 1e3 * clock() / CLOCKS_PER_SEC); }
}
__io(false);

typedef long long llong;
const llong inf = (llong) 1e+9 + 7ll;
const llong linf = (llong) 1e+18 + 7ll;
const long double eps = (long double) 1e-9;
const long double pi = acosl((long double) -1.0);
const int alph = 26;
const int maxs = 512l;

static char buff[(int) 2e6 + 17];
llong __p[3] = {29ll, 31ll, 33ll};
llong __mod[3] = {inf, inf + 2ll, 14881337ll};

const int maxn = (int) 3e5 + 17;

int n, ans = 0;
string s;
int b[maxn];

int main()
{
	scanf("%s", buff);
	s = buff;
	n = size(s);
	ans = -count(s.begin(), s.end(), 'p');
	int g = 0;

	forn (i, n)
	{
		b[i] = i == 0 ? 0 : b[i - 1];
		if (s[i] == 'g' && b[i] + 1 <= i - b[i]) ++b[i], ++ans;
		if (s[i] == 'p' && b[i] + 1 <= i - b[i]) ++b[i], ++ans;
	}

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

	return 0;
}


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

//template
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(a);i>(b);i--)
#define ALL(v) (v).begin(),(v).end()
typedef long long int ll;
const int inf = 0x3fffffff; const ll INF = 0x1fffffffffffffff; const double eps=1e-12;
void tostr(ll x,string& res){while(x)res+=('0'+(x%10)),x/=10; reverse(ALL(res)); return;}
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; }
//end

constexpr int N=8000,M=4000;
string s,t,r;
bool st[16020]={},sr[16020]={},tr[16020]={};
bool check(char c,char d){return (c=='?'||d=='?'||c==d);}

int main(){
   cin>>s>>t>>r;
   int a=s.size(),b=t.size(),c=r.size();
   rep(i,0,a)rep(j,0,b)if(!check(s[i],t[j]))st[i-j+N]=1;
   rep(i,0,a)rep(j,0,c)if(!check(s[i],r[j]))sr[i-j+N]=1;
   rep(i,0,b)rep(j,0,c)if(!check(t[i],r[j]))tr[i-j+N]=1;
   int res=3*N;
   rep(i,-M,M+1)rep(j,-M,M+1)if(!st[i+N]&&!sr[j+N]&&!tr[j-i+N]){
      int lb=min({0,i,j}),rb=max({a,b+i,c+j});
      chmin(res,rb-lb);
   } printf("%d\n",res);
   return 0;
}

Measured memory_bytes: 256
from sys import setrecursionlimit
setrecursionlimit(10 ** 5 + 10)

N, M, *XY = map(int, open(0).read().split())

E = [[] for _ in range(N + 1)]
for x, y in zip(*[iter(XY)] * 2):
    E[x].append(y)

memo = {}
def dp(p):
    if p in memo:
        return memo[p]

    memo[p] = max((1 + dp(c) for c in E[p]), default=0)
    return memo[p]

print(max(dp(p) for p in range(1, N + 1)))

Measured memory_bytes: 126648
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a,b;
	cin>>a>>b;
	float x,y;
	int res;
	x=((float)a+(float)b)/2;
	//cout<<x<<"\n";
	res=(a+b)/2;
	y=x-res;
	if(y>=0.5)
		res++;
	cout<<res<<"\n";
}

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

signed main()
{   
    string s; cin>>s;
    int N=s.size();
    for(int i=0;i<N-1;i++){
        if(s[i]==s[i+1]){
            cout<<"Bad"<<endl;
            return 0;
        }
    }
    cout<<"Good"<<endl;
    return 0;
}


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

using namespace std;

int main() {

    int n,k;
    cin >> n >> k;

    double ans = 0;
    for (int i = 1; i <= n; ++i) {
        long long cur = i;
        int cnt = 0;
        while(cur < k) cnt++, cur += cur;
        double m = 1;
        while(cnt--) m *= 0.5;
        ans += (m * (1. / n));
    }

    printf("%.10lf\n", ans);
    return 0;
}


Measured memory_bytes: 256
#!usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from itertools import permutations
import sys
import math
import bisect
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

def solve():
    n,m,v,p = LI()
    a = LI()
    a.sort()
    l = -1
    r = n-1
    while r-l > 1:
        i = (l+r) >> 1
        ai = a[i]
        aim = ai+m
        ri = bisect.bisect_right(a,aim)
        if n-ri >= p:
            l = i
            continue
        cnt = 0
        for j in range(n-p+1):
            if i == j:
                continue
            cnt += min(m,max(0,aim-a[j]))
        if cnt >= m*(v-p):
            r = i
        else:
            l = i
    print(n-r)
    return

#Solve
if __name__ == "__main__":
    solve()


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

int pattern_cnt = 0;
int a, b, c, x;

void func(bool choiced_a, bool choiced_b, bool choiced_c, int now_x)
{
	if (!choiced_a)
	{
		for (int i = 0; i <= a; i++)
		{
			func(true, choiced_b, choiced_c, now_x + 500 * i);
		}
	}
	else if (!choiced_b)
	{
		for (int i = 0; i <= b; i++)
		{
			func(choiced_a, true, choiced_c, now_x + 100 * i);
		}
	}
	else if (!choiced_c)
	{
		for (int i = 0; i <= c; i++)
		{
			func(choiced_a, choiced_b, true, now_x + 50 * i);
		}
	}
	else
	{
		if (now_x == x) pattern_cnt++;

		return;
	}
}

int main()
{

	cin >> a >> b >> c >> x;

	func(false, false, false, 0);

	cout << pattern_cnt << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {

  int N,T;

  cin >> N >> T ;

  vector<int> t(N);

  for(int i=0;i<N;i++) cin >> t.at(i);

  int64_t ans=0;

  for(int i=1;i<N;i++) ans+=min(T,t.at(i)-t.at(i-1));//一人対策のためにあえてiの条件とtの()内部の条件を特異的に設定している。
  //i=1からはじめることで、要素が一つしかないときはスルーされる

  ans+=T;//最後に出続けるお湯
  
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 1024
import java.util.*;
public class Main {
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
int a;
a= sc.nextInt();
int b;
b= sc.nextInt();
if (a < b)
System.out.println("a < b");
else if(a > b)
System.out.println("a > b");
else
System.out.println("a == b");
}
}

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

int gcd(int a,int b){
	if(a<b)swap(a,b);
	if(b==0)return a;
	return gcd(a%b,b);
}
int main(void){
	int N,ans=0,temp;
	cin >> N;
	int A[N];
	for(int i=0;i<N;i++)cin >>A[i];
	int leftgcd[N];//左からi番目までのgcd
	int rightgcd[N];//右からi番目までのgcd
	leftgcd[0]=A[0];
	rightgcd[0]=A[N-1];
	for(int i=1;i<N;i++){
		leftgcd[i] = gcd(leftgcd[i-1],A[i]);
	}
	for(int i=1;i<N;i++){
		rightgcd[i] = gcd(rightgcd[i-1],A[(N-1)-i]);
	}
	//あとは地点iから左のgcdと右のgcdのgcdを求める
	for(int i=0;i<=N-1;i++){
		if(i==0){
			temp = rightgcd[N-1-1];
		}else if(i==(N-1)){
			temp = leftgcd[N-2];
		}else{
			temp= gcd(leftgcd[i-1],rightgcd[N-2-i]);
		}
		if(temp>ans)ans=temp;
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 1408
#include <limits>
#include <iostream>

using namespace std;

int x, y, s;
int tax(int rate, int price_without_tax);

//前の税率での税抜価格の組み合わせ
//後の税率での値段を出す関数

/**
 * @fn
 * 税込み価格を出す関数
 * @param rate
 * @param price_without_tax
 */
int tax(int rate, int price_without_tax)
{
    int price = 0;
    price = price_without_tax * (100 + rate) / 100;
    return price;
}

int main()
{
    while (cin >> x >> y >> s)
    {
        int maximum = 0;

        for (int i = 1; i < s; ++i)
        {
            for (int j = i; j < s; ++j)
            {
                //最大で O(S^2) = 1000^2 ∵ 0 < S < 1000;
                if (tax(x, i) + tax(x, j) == s)
                {
                    maximum = max(maximum, tax(y, i) + tax(y, j));
                }
            }
        }
        if (maximum > 0)
        {
            cout << maximum << endl;
        }
    }
}


Measured memory_bytes: 3096
#include<iostream>
using namespace std;
int main(){
	int n,x=0,i,k=0;
	string s;
	cin >> n >> s;
	for(i=0;i<s.size();i++){
		if(s[i]=='I')
			x++;
		else
			x--;
		if(x>k)
			k=x;
	}
	cout << k << endl;
	return 0;
}

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

int main(){
	int N, t[100100], x[100100], y[100100];
	cin >> N;
	t[0] = x[0] = y[0] = 0;
	for(int i=1; i<=N; i++){
		cin >> t[i] >> x[i] >> y[i];
	}

	bool can = true;
	int dt, dx, dy, dd;
	for(int i=0; i<N; i++){
		dt = t[i+1] - t[i];
		dx = abs(x[i+1] - x[i]);
		dy = abs(y[i+1] - y[i]);

		dd = dx + dy;
		if(dt < dd || (dt % 2 != dd % 2)){
			can = false;
			break;
		}
	}

	if(can) cout << "Yes" << endl;
	else cout << "No" << endl;

	return 0;
}
			


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

int main(){
	int i,j,k,n,m,l,f,x,y,z; string s;
	cin >> s;
	n = s.size();
	cout << s[0] << n-2 << s[n-1] << endl;
}

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

using namespace std;

#define sqr(x) ((x) * (x))
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()

typedef long long ll;

const int MOD = 1000000007;
const int INF = 1000000007;
const ll INFLL = 1000000000000000007LL;

void solve() {
  int N, K;
  cin >> N >> K;
  int ans = 0;
  while (N > 0) {
    N /= K;
    ans++;
  }
  cout << ans << endl;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  // cout << fixed << setprecision(12);

  solve();

  return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
using ll     = long long;
using pii    = pair<int, int>;
using pll    = pair<ll, ll>;
using vi     = vector<int>;
using vl     = vector<ll>;
using vvi    = vector<vi>;
using vvl    = vector<vl>;
const ll INF = 1LL << 60;
const ll MOD = 1000000007;
template <class T>
bool chmax(T &a, const T &b) {
    return (a < b) ? (a = b, 1) : 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    return (b < a) ? (a = b, 1) : 0;
}
template <class C>
void print(const C &c, std::ostream &os = std::cout) {
    std::copy(std::begin(c), std::end(c), std::ostream_iterator<typename C::value_type>(os, " "));
    os << std::endl;
}

int main() {
    int n;
    cin >> n;
    vi a(n);
    vvi xs(n), ys(n);
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
        for (int j = 0; j < a[i]; ++j) {
            int x, y;
            cin >> x >> y;
            x--;
            xs[i].push_back(x);
            ys[i].push_back(y);
        }
    }
    int ret = 0;
    for (int i = 0; i < (1 << n); ++i) {
        vi tr(n, -1);
        bool ok = true;
        for (int j = 0; j < n; ++j) {
            if ((1 << j) & i) {
                if (tr[j] == -1)
                    tr[j] = 1;
                else if (tr[j] == 0)
                    ok = false;
                for (int k = 0; k < a[j]; ++k) {
                    if (tr[xs[j][k]] == -1)
                        tr[xs[j][k]] = ys[j][k];
                    else {
                        if (tr[xs[j][k]] != ys[j][k])
                            ok = false;
                    }
                }
            } else {
                if (tr[j] == -1)
                    tr[j] = 0;
                else if (tr[j] == 1)
                    ok = false;
            }
        }
        if (ok) {
            chmax(ret, __builtin_popcount(i));
        }
    }
    cout << ret << "\n";
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define INF 1e9;
using namespace std;
using ll = long long;
int N;
int x[10], y[10];
double dist(int i, int j) {
    double X = x[i] - x[j];
    double Y = y[i] - y[j];
    return pow(X * X + Y * Y , 0.5);
}
void solve() {
    cin >> N;
    for(int i = 1; i <= N; i++){
        cin >> x[i] >> y[i];
    }
    double ans = 0.0;
    for(int i = 1; i <= N; i++){
        for(int j = i + 1; j <= N; j++){
            ans += dist(i, j) * 2 / N;
        }
    }
    cout << fixed << setprecision(10) << ans << endl;
    return;
}
int main() {
    solve();
    return 0;
}


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

#define mod 1000000007
#define sp ' '
#define intmax 2147483647
#define llmax 9223372036854775807
#define nyan "(=^･ω･^=)"
#define mkp make_pair
#define lP pair<ll, ll>
#define iP pair<int,int>
using namespace std;
typedef long long ll;


string s;
int N, Q, l, r, t[100000];

int main() {
	cin >> N >> Q >> s;
	for (int i = 0; i < N - 1; ++i) {
		if (s[i] == 'A'&&s[i + 1] == 'C') {
			++t[i];
		}
	}
	for (int i = 1; i < N; ++i) {
		t[i] += t[i - 1];
	}
	for (int i = 0; i < Q; ++i) {
		cin >> l >> r;
		--l;
		--r;
		int res;
		if (l == 0) {
			res = t[r];
		}
		else {
			res = t[r] - t[l - 1];
		}
		if (r!=N-1&&s[r] == 'A'&&s[r + 1] == 'C') {
			--res;
		}
		cout << res << endl;
	}
	return 0;
}

Measured memory_bytes: 1408
#include <algorithm>
#include <iostream>
#include <stack>
#include <queue>
#include <cmath>
#include <string>
#include <iterator>
#include <map>
#include <set>
#include <iomanip>
#include <vector>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using Graph = vector<vector<int>>;
int dx[] = {0, 1, 0, -1};
int dy[] = {1, 0, -1, 0};
#define INF 100000000000
#define MAX 200001
#define MOD 1000000007  

int dfs(int s, Graph &G){
    vector<int> ans;
    for(auto v:G[s]){
        int n = dfs(v, G);
        ans.push_back(n + 1);
    }
    sort(ans.begin(), ans.end());
    int ANS = 0;
    if(ans.size() != 0){
        ANS = ans[0];
        for(int i = 1; i < ans.size(); i++){
            if(ANS >= ans[i]) ANS++;
            else
             ANS = ans[i];
        }
    }
    return ANS;
}

int main(){
    int N;
    cin >> N;
    vector<vector<int>> G(N);
    for(int i = 0; i < N - 1; i++){
        int a;
        cin >> a;
        a--;
        G[a].push_back(i + 1);
    }
    int ans = dfs(0, G);
    cout << ans << endl;
}


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

ll gcd(ll x, ll y) { return y ? gcd(y,x%y) : x;}

vector<pair<ll,int>> factorize(ll n) {
  vector<pair<ll,int>> res;
  for (ll i = 2; i*i <= n; ++i) {
    if (n%i) continue;
    res.emplace_back(i,0);
    while (n%i == 0) {
      n /= i;
      res.back().second++;
    }
  }
  if (n != 1) res.emplace_back(n,1);
  return res;
}
ll max(ll a, ll b){ if(a >= b) return a;else if(a < b) return b; }
ll min(ll a, ll b){ if(a <= b) return a;else if(a > b) return b; }

int main() {
	string s;
	cin >> s;
	ll k;
	cin >> k;
	ll range_max = min(100, k);
	int ans_index = 0;
	for(int i = 0; i < min(s.size(), range_max); i++){
		if(s[i] != '1')	{
			ans_index = i;
			break;	
		}
	}
	cout << s[ans_index] << endl;
}


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

using namespace std;

#define rep(i, a, b) for (int i = (a); i < (b); ++i)
#define sz(s) (int)s.size()

int main() {
    int x;
    cin >> x;
    cout << (x < 1200 ? "ABC" : "ARC");
}

Measured memory_bytes: 256