akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <utility>
#include <algorithm>
#include <cstdio>
#include <iomanip>
#include <queue>
#include <deque>
#include <stack>
#include <fstream>
#include <cmath>
#include <random>
#include <complex>
#include <functional>
#include <bitset>
#include <sstream>
#include <cassert>
#include <time.h>

#define ll int64_t
#define Rep(i, n) for (ll i = 0; i < n; i++)
using namespace std;
typedef vector<ll> vec;
typedef vector<vec> mat;

const ll inf = 1LL << 60;

template<class T> inline void chmin(T& a, T b) {
    if (a > b) {
        a = b;
    }
}
template<class T> inline void chmax(T& a, T b) {
    if (a < b) {
        a = b;
    }
}
void printvec (vec &v) {
    Rep (i, (ll)v.size()) {
        cout << v[i] << " \n"[i+1 == (ll)v.size()];
    }
}

const ll OFFSET = 1e6;

ll encode (ll x, ll y) {
    return OFFSET * x + y;
}

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

    ll H, W, M;
    cin >> H >> W >> M;
    vec h(M), w(M), cnth(H), cntw(W);
    set<ll> targets;
    Rep (i, M) {
        cin >> h[i] >> w[i];
        h[i]--;
        w[i]--;
        cnth[h[i]]++;
        cntw[w[i]]++;
        targets.insert(encode(h[i], w[i]));
    }

    ll maxh = *max_element(cnth.begin(), cnth.end());
    ll maxw = *max_element(cntw.begin(), cntw.end());

    vec targeth, targetw;
    Rep (i, H) {
        if (cnth[i] == maxh) targeth.push_back(i);
    }

    Rep (i, W) {
        if (cntw[i] == maxw) targetw.push_back(i);
    }

    ll ans = maxh + maxw;

    for (ll y : targeth) {
        for (ll x : targetw) {
            if (targets.find(encode(y, x)) == targets.end()) {
                cout << ans << endl;
                exit(0);
            }
        }
    }

    cout << ans-1 << endl;

}

Measured memory_bytes: 34944
#include <bits/stdc++.h>
#include <stdlib.h>
#include <numeric>
using namespace std;
int main(){
  	int A, B, C;
    cin >> A >>B>>C;
	if(C-(A-B)>0){
    cout<<C-(A-B)<<endl;}else{
      cout<<0<<endl;}
  

 
 
}

Measured memory_bytes: 256
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;

import java.util.*;

public class Main {
    long MOD = (long) 1e9 + 7;

    InputStream in;
    OutputStream out;

    public Main() {
        this(System.in, System.out);
    }

    public Main(InputStream in, OutputStream out) {
        this.in = in;
        this.out = out;
    }

    void run() {
        Scanner sc = new Scanner(this.in);
        PrintWriter out = new PrintWriter(this.out);

        // write your code
        int x = sc.nextInt(), y = sc.nextInt();

        if ((x + y) % 3 != 0) {
            out.println(0);
            out.flush();
            return;
        }

        int n = (2 * y - x) / 3;
        int m = (2 * x - y) / 3;
        if (n < 0 || m < 0) {
            out.println(0);
            out.flush();
            return;
        }

        Combination comb = new Combination(n + m + 10, MOD);
        out.println(comb.nck(n + m, m));
        out.flush();
    }

    public class Combination {
        int n;
        long mod;
        long[] facts;

        public Combination(int n, long mod) {
            this.n = n;
            this.mod = mod;
            facts = new long[n];
            facts[0] = 1;
            for (int i = 1; i < n; i++) {
                facts[i] = facts[i - 1] * i % mod;
            }
        }

        long modpow(long a, long b) {
            if (b == 0) return 1;
            else if (b == 1) return a;

            long x = modpow(a, b / 2);
            return b % 2 == 0 ? x * x % mod : x * (x * a % mod) % mod;
        }

        long inv(long n) {
            return modpow(n, mod - 2);
        }

        public long nck(int n, int k) {
            return n < k ? 0 : facts[n] * (inv(facts[n - k]) * inv(facts[k]) % mod) % mod;
        }
    }


    void debug(Object... os) {
        System.err.println(Arrays.deepToString(os));
    }

    public static void main(String[] args) {
        new Main().run();
    }
}

Measured memory_bytes: 28116
H, W = [int(s) for s in input().split()]
S = []
for _ in range(H):
    S.append(input())


def num_bombs(h, w):
    if S[h][w] == '#':
        return '#'

    ps = [
        (w - 1, h + 1), (w, h + 1), (w + 1, h + 1),
        (w - 1, h), (w + 1, h),
        (w - 1, h - 1), (w, h - 1), (w + 1, h - 1)
    ]
    ps = [p for p in ps if p[0] in range(W) and p[1] in range(H)]
    return str([S[p[1]][p[0]] for p in ps].count('#'))

result = [[0] * W for _ in range(H)]
for w in range(W):
    for h in range(H):
        result[h][w] = num_bombs(h, w)

print('\n'.join([''.join(r) for r in result]))

Measured memory_bytes: 3188
// g++ -std=c++11 a.cpp
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<unordered_map>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<random>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(long long i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define FOR(i,a) for(auto i:a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define show1d(v) {rep(_,v.size())cout<<" "<<v[_];cout<<endl;}
#define show2d(v) {rep(__,v.size())show1d(v[__]);}
using namespace std;
//kaewasuretyuui
typedef long long ll;
#define int ll
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
#define mt make_tuple
typedef tuple<int,int,int> tp;
typedef vector<tp> vt;
typedef vector<vt>vvt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
const double PI=acos(-1);
const double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
int dx[]={-1,0,1,0};
int dy[]={0,1,0,-1};
#define yes cout<<"Yes\n"
#define no cout<<"No\n"


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

	int a,b;
	cin>>a>>b;
	cout<<a*b<<endl;


}


Measured memory_bytes: 3644
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define rrep(i,n) for(int i=(n)-1; i>=0; i--)
#define FOR(i,a,b) for(int i=(a); i<(b); i++)
#define RFOR(i,a,b) for(int i=(b-1); i>=(a); i--)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define pb push_back
using ll = long long;
using D = double;
using LD = long double;
using P = pair<int, int>;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

template<int mod> struct Fp {
    long long val;
    constexpr Fp(long long v = 0) noexcept : val(v % mod) {
        if (val < 0) val += mod;
    }
    constexpr int getmod() { return mod; }
    constexpr Fp operator - () const noexcept {
        return val ? mod - val : 0;
    }
    constexpr Fp operator + (const Fp& r) const noexcept { return Fp(*this) += r; }
    constexpr Fp operator - (const Fp& r) const noexcept { return Fp(*this) -= r; }
    constexpr Fp operator * (const Fp& r) const noexcept { return Fp(*this) *= r; }
    constexpr Fp operator / (const Fp& r) const noexcept { return Fp(*this) /= r; }
    constexpr Fp& operator += (const Fp& r) noexcept {
        val += r.val;
        if (val >= mod) val -= mod;
        return *this;
    }
    constexpr Fp& operator -= (const Fp& r) noexcept {
        val -= r.val;
        if (val < 0) val += mod;
        return *this;
    }
    constexpr Fp& operator *= (const Fp& r) noexcept {
        val = val * r.val % mod;
        return *this;
    }
    constexpr Fp& operator /= (const Fp& r) noexcept {
        long long a = r.val, b = mod, u = 1, v = 0;
        while (b) {
            long long t = a / b;
            a -= t * b; swap(a, b);
            u -= t * v; swap(u, v);
        }
        val = val * u % mod;
        if (val < 0) val += mod;
        return *this;
    }
    constexpr bool operator == (const Fp& r) const noexcept {
        return this->val == r.val;
    }
    constexpr bool operator != (const Fp& r) const noexcept {
        return this->val != r.val;
    }
    friend constexpr istream& operator >> (istream &is, const Fp<mod>& x) noexcept {
        int val; is >> val;
        x = Fp<mod>(val);
        return is;
    }
    friend constexpr ostream& operator << (ostream &os, const Fp<mod>& x) noexcept {
        return os << x.val;
    }
    friend constexpr Fp<mod> modpow(const Fp<mod> &a, long long n) noexcept {
        if (n == 0) return 1;
        auto t = modpow(a, n / 2);
        t = t * t;
        if (n & 1) t = t * a;
        return t;
    }
};

const int mod = 1e9+7;
using mint = Fp<mod>;

int main(){
    int n,k; cin >> n >> k;
    vector<mint> f(k+1);
    vector<mint> g(k+1);
    FOR(i,1,k+1) g[i] = modpow((mint)(k/i), n);
    RFOR(i,1,k+1){
        f[i] = g[i];
        int now = 2;
        while(now*i <= k){
            f[i] -= f[now*i];
            now++;
        }
    }
    mint ans = 0;
    FOR(i,1,k+1) ans += (mint)i*f[i];
    cout << ans << endl;
}


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

#define rep(i, n) for (int i = 0; i < n; ++i)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((int)(x).size())
using ll = long long;
using P = pair<int, int>;
using llP = pair<ll, ll>;
using DoP = pair<double, double>;
const int di[] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dj[] = {1, 0, -1, 0, 1, -1, 1, -1};
const int INF = 1 << 29;
const ll INF64 = 1ll << 45;
const int mod = 1000000007;
//const int mod = 998244353;

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

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

  // for prime mod
  mint inv() const
  {
    return pow(mod - 2);
  }
  mint &operator/=(const mint a)
  {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const
  {
    mint res(*this);
    return res /= a;
  }
};

bool check(vector<P> s) {
  int h = 0;
  for(auto p : s) {
    int b = h+p.first;
    if(b < 0) return false;
    h += p.second;
  }
  return true;
}
int main()
{
  int n;
  cin >> n;
  vector<P> ls, rs;
  int total = 0;
  rep(i, n) {
    string s;
    cin >> s;
    int h = 0, b = 0;
    for(auto c : s) {
      if(c == '(') ++h; else --h;
      chmin(b, h);
    }
    if(h > 0) ls.emplace_back(b, h);
    else rs.emplace_back(b-h, -h);
    total += h;
  }
  sort(ls.rbegin(), ls.rend());
  sort(rs.rbegin(), rs.rend());
  if(check(ls) && check(rs) && total == 0) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 18912
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<functional>
#include<math.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define pf(n) printf("%lld\n",n)
typedef long long ll;
typedef pair<ll, ll> p;
const int INF = 1001001001;
const double PI = acos(-1);

ll yaku(ll a) {
	ll cnt = 0;
	//if (a % 2 != 0) return 0;

	while (a % 2 == 0 ) {
		cnt++;
		a /= 2;
	}
	return cnt;
}


int main() {
	ll n;
	cin >> n;
	vector<ll> a(n);
	rep(i, n) cin >> a[i];
	//pf(yaku(n));

	ll y = 0;
	rep(i, n) {
		y += yaku(a[i]);
		//pf(yaku(a[i]));
	}

	cout << y << endl;


	return 0;
}

Measured memory_bytes: 3644
#include <iostream>
#include <string>
#include <stdio.h>
#include <stdlib.h>


int main() {

    int N, K, tmp1, i=0, ans = 0;

    std::cin >> N >> K ;

    if(K == 1)ans = 0;
    else{
        ans = N - K;
    }

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

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using lint=int64_t;
using namespace std;

int main()
{
	char c;
	cin >> c;

	if(c=='A')cout << "T";
	if(c=='T')cout << "A";
	if(c=='G')cout << "C";
	if(c=='C')cout << "G";
	cout << endl;
	
	return 0;
}



Measured memory_bytes: 768
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <time.h>

int max(int a, int b){
    if(a > b){
        return a;
    }else{
        return b;
    }
}



int main(){
    int X;
    scanf("%d", &X);
    int i, j;
    int kazu = 0;
    int ans = 1;
    for(i=2;i<(sqrt(X));i++){
        kazu = i;
        while(kazu<=X && kazu*i<=X){
            kazu *= i;

            // printf("%d\n", kazu);
        }
        ans = max(ans, kazu);
    }

    printf("%d", ans);
   
    return 0;
}

Measured memory_bytes: 128
using System;
using System.Linq;

namespace DPL_1_F
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] s = Console.ReadLine().Split();
            int n = int.Parse(s[0]); int limit = int.Parse(s[1]);
            int[] v = new int[n]; int[] w = new int[n];
            for (int i = 0; i < n; i++)
            {
                int[] x = Console.ReadLine().Split().Select(int.Parse).ToArray();
                v[i] = x[0]; w[i] = x[1];
            }
            long[,] dp = new long[n + 1,n * v.Max() + 1];
            for (int i = 1; i < n * v.Max() + 1; i++) dp[0,i] = 10000000000000;
            for (int i = 0; i < n; i++)
            {
                for (int j = 0; j <= n * v.Max(); j++)
                {
                    if (j < v[i]) dp[i + 1,j] = dp[i,j];
                    else dp[i + 1,j] = Math.Min(dp[i,j],dp[i,j - v[i]] + w[i]);
                }
            }
            long ret = 0;
            for (int i = 0; i < n * v.Max() + 1; i++) if (dp[n,i] <= limit) ret = i;
            Console.WriteLine(ret);
        }
    }
}


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

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

#define FOR(i, n, m) for (ll(i) = (m); (i) < (n); ++(i))
#define REP(i, n) FOR(i, n, 0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll)1e15;

bool L[200005];

int main()
{
    ll N;
    cin >> N;
    string S;
    cin >> S;
    memset(L, 0, sizeof(L));
    ll s = 0;
    bool e = true;
    REP(i, 2 * N)
    {
        if (S[i] == 'B')
        {
            if (s % 2 == 0)
            {
                L[i] = true;
                s++;
            }
            else
            {
                s--;
            }
        }
        else
        {
            if (s % 2 == 0)
            {
                s--;
            }
            else
            {
                L[i] = true;
                s++;
            }
        }
        if (s < 0)
            e = false;
    }

    ll ans = 1;
    s = 0;
    for (int i = 2 * N - 1; i >= 0; --i)
    {
        if (L[i])
        {
            ans *= s;
            s--;
        }
        else
            s++;
        ans %= MOD;
    }

    REP(i, N)
    {
        ans *= (i + 1);
        ans %= MOD;
    }
    if (!e)
        cout << 0 << endl;
    else
        cout << ans << endl;
    return 0;
}

Measured memory_bytes: 772
n = gets.chomp.to_i
h = gets.chomp.split().map(&:to_i)

ans = 0
current = 0
(n-1).times do |i|
  if h[i] >= h[i+1]
    current += 1
  else
    current = 0
  end

  ans = [ans, current].max
end

puts ans

Measured memory_bytes: 12292
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<queue>

using namespace std;

inline int read()
{
  int x=0,f=1;char ch=getchar();
  while (!isdigit(ch)) {if (ch=='-') f=-1;ch=getchar();}
  while (isdigit(ch)) {x=(x<<1)+(x<<3)+ch-'0';ch=getchar();}
  return x*f;
}

const int maxn = 3e5+1e2;

int f[maxn];
int a[maxn];
int n;

int main()
{
  cin>>n;
  for (int i=1;i<=n;i++) a[i]=read();
  int ans=0;
  for (int i=1;i<=n;i++) f[a[i]]=f[a[i]-1]+1,ans=max(ans,f[a[i]]);
  cout<<n-ans;
  return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <string.h>
#include <math.h>
#include <algorithm>
using namespace std;
typedef long long ll;

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

int main() {
  int n, m, x, zz;
  cin >> n >> m >> x;
  int a[100] = {0};
  for (int i= 0; i< m; i++){
    cin >> zz;
    a[zz] = 1;
  }
  int l = 0, r = 0;
  for(int i=0; i < x; i++){l += a[i];}
  for(int i=x+1; i<n; i++){r += a[i];}
  if(l < r) cout << l;
  else cout << r;
}

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

long long n;

int solve() {
  scanf("%lld", &n);
  vector<pair<long long, int>> pe;
  for (long long p = 2; p*p <= n; ++p) {
    if (n % p != 0) continue;
    int e = 0;
    do {
      n /= p;
      ++e;
    } while (n % p == 0);

    pe.emplace_back(p, e);
  }
  if (n > 1) pe.emplace_back(n, 1);

  int ans = 0;
  for (pair<long long, int> f: pe) {
    int e = f.second;

    int k = 1;
    while (e >= k) {
      ++ans;
      e -= k;
      ++k;
    } 
  }

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

int main() {
  int t = 1;
  // scanf("%d", &t);
  for (int tc = 0; tc < t; ++tc) {
    // printf("Case #%d: ", tc+1);
    solve();
  }
  return 0;
}


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

#define rep(i,n) for(i = 0;i < n;++i)
#define all(v) v.begin(), v.end()
using ll = long long;

int main()
{
    ll i,j;
    ll n;
    cin >> n;
    vector<ll> a(n);
    for(i = 0;i < n;++i){
        cin >> a.at(i);
    }
    sort(all(a));
    vector<pair<ll,ll>> aa;
    ll tmp = a.front();
    ll num = 1;
    for(i = 1;i < n;++i){
        if(a.at(i) == tmp) ++ num;
        else{
            aa.emplace_back(tmp, num);
            tmp = a.at(i);
            num = 1;
        }
    }
    aa.emplace_back(tmp, num);
    n = aa.size();
    i = n-1;
    ll ans = 0;
    while(i >= 0){
        if(aa.at(i).second == 0){
            --i;
            continue;
        }
        ll now = aa.at(i).first;
        --aa.at(i).second;
        tmp = now;
        num = 0;
        while(tmp != 1){
            tmp >>= 1;
            ++num;
        }
        rep(j,num+1) tmp <<= 1;
        ll obj = tmp-now;
        ll ind = lower_bound(all(aa), make_pair(obj,0ll)) - aa.begin();
        if(aa.at(ind).first != obj){
            --i;
            continue;
        }else{
            if(aa.at(ind).second == 0){
                --i;
                continue;
            }else{
                --aa.at(ind).second;
                ++ans;
            }
        }
        if(aa.at(i).second == 0) --i;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 7664
#include <bits/stdc++.h>
#include <algorithm>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<(n);++i)
#define all(x) (x).begin(), (x).end()
#define PB(x) push_back(x)
#define MP(x,y) make_pair(x,y)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;


int main() {
    
    int x,y,z;
    cin >> x >> y >> z;

    cout<<z<<' '<<x<<' '<<y<<endl;


 return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int h,m;
int cal(int h,int m){
    return h*60+m;
}
int main(){
    int ans=0;
    scanf("%d%d",&h,&m);
    ans-=cal(h,m);
    scanf("%d%d",&h,&m);
    ans+=cal(h,m);
    int k;scanf("%d",&k);
    ans=ans-k;
    printf("%d\n",max(ans,0));
    return 0;
}

Measured memory_bytes: 3804
#include<bits/stdc++.h>
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
 
 
int main() {
	string s;
	cin>>s;
	if(s=="ABC")
	{
		cout<<"ARC"<<endl;
	}
	else
	{
		cout<<"ABC"<<endl;
	}
}

Measured memory_bytes: 3624
using System;
using System.Collections.Generic;
using System.Linq;

class Class1
{
    static void Main(string[] args)
    {
        int N = int.Parse(Console.ReadLine());
        List<int> inputs = Console.ReadLine().Split(' ').Select(_ => int.Parse(_)).ToList();


        int result = 0;
        for (int i = 0; i < N; i++)
        {
            if (i % 2 != 0)
            {
                // 奇数の番号
                continue;
            }

            if (inputs[i] % 2 != 0)
            {
                result++;
            }
        }

        Console.WriteLine(result);
    }
}

Measured memory_bytes: 28312
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;

namespace AtCoder_Beginner_Contest_131
{
    class Program
    {
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }
        public struct Works
        {
            public long A;
            public long B;
            public Works(long a, long b) { A = a; B = b; }
        }
        static void Main(string[] args)
        {
            var works = new List<Works>();
            var N = Sarray()[0];
            for (var i = 0; i < N; ++i) 
            {
                var ab = Sarray();
                works.Add(new Works(ab[0], ab[1]));
            }
            works.Sort((l, r) => (int)(l.B - r.B));
            var sum = 0L;
            foreach(var w in works)
            {
                sum+=w.A;
                if(w.B<sum)
                {
                    WriteLine("No");
                    return;
                }
            }
            WriteLine("Yes");
        }
    }
}

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

int imos[111111];
int main(){
    int n;
    while(cin >> n){
        //memset(imos,0,sizeof(imos));
        for(int i=0;i<n;i++){
            int a,b;
            cin>>a>>b;
            imos[a-1]++;
            imos[b]--;
        }
        for(int i=1;i<111111;i++){
            imos[i]+=imos[i-1];
        }
        int ans=0;
        for(int i=0;i<111111;i++){
            if(imos[i]>=i)ans=max(ans,i);
        }
        cout << ans << endl;
    }
}

Measured memory_bytes: 1592
from itertools import permutations


def check(queen):
    for r1, c1 in queen:
        if not all((r1 == r2 and c1 == c2) or (r1 + c1 != r2 + c2 and r1 - c1 != r2 - c2) for r2, c2 in queen):
            return False
    return True


N = int(input())
row, col = list(range(8)), list(range(8))
queen = []
for _ in range(N):
    r, c = map(int, input().split())
    queen.append((r, c))
    row.remove(r)
    col.remove(c)
for l in permutations(col):
    queen_tmp = queen[:]
    for r, c in zip(row, l):
        queen_tmp.append((r, c))
    if check(queen_tmp):
        board = [''.join('Q' if (r, c) in queen_tmp else '.' for c in range(8)) for r in range(8)]
        print(*board, sep='\n')
        break

Measured memory_bytes: 7816
#include <iostream>
using namespace std;
int main(void){
  int h1,h2,k1,k2,a,b,c,d,x,y;
  cin>>h1>>h2>>k1>>k2>>a>>b>>c>>d;
  x=h1*a+h2*b+h1/10*c+h2/20*d;
  y=k1*a+k2*b+k1/10*c+k2/20*d;
  if(x<y){
      cout<<"kenjiro"<<endl;
  }
  else if(x>y){
      cout<<"hiroshi"<<endl;
  }
  else{
      cout<<"even"<<endl;
  }
  }


Measured memory_bytes: 3100
#include<bits/stdc++.h>
typedef long long ll;
const ll mod=1e9+7;
const ll inf=0x3f3f3f3f;
const int N=3e5+5;
using namespace std;
int a[N];
int hang[N],lie[N];
int x[N],y[N];
int main()
{
    ios::sync_with_stdio(false);
    ll h,w,m;
    cin>>h>>w>>m;
    int mxh=0,mxl=0;
    for(int i=0;i<m;i++)
    {
        cin>>x[i]>>y[i];
        hang[x[i]]++;lie[y[i]]++;
        mxh=max(mxh,hang[x[i]]);
        mxl=max(mxl,lie[y[i]]);
    }
    ll lx=0,ly=0;
    for(int i=0;i<=N;i++)
        {
            if(mxh==hang[i]) lx++;
            if(mxl==lie[i]) ly++;
        }
    ll sum=1ll*lx*ly;
    for(int i=0;i<m;i++)
    {
        if(hang[x[i]]==mxh&&lie[y[i]]==mxl) sum--;
    }
    if(sum==0) cout<<mxh+mxl-1<<endl;
    else cout<<mxh+mxl<<endl;

}


Measured memory_bytes: 8284
# B
N = int(input())
a_list = list(map(int, input().split()))
b_list = list(map(int, input().split()))

cnt_plus_a_2 = 0
cnt_plus_a_1 = 0
cnt_plus_b = 0

for i in range(N):
    if a_list[i] < b_list[i]:
        cnt_plus_a_2 += (b_list[i] - a_list[i]) // 2
        cnt_plus_a_1 += (b_list[i] - a_list[i]) % 2
    elif a_list[i] > b_list[i]:
        cnt_plus_b += -(b_list[i] - a_list[i])
        
if cnt_plus_a_2 >= cnt_plus_b:
    print("Yes")
else:
    print("No")

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

const int N = 100005;
int n, M, a[2 * N];

int main() {
	scanf("%d%d", &n, &M);
	for (int i = 1; i <= 2 * n; ++i)
		scanf("%d", a + i);
	sort(a + 1, a + 1 + 2 * n);
	int b = 0;
	for (int i = 2 * n, j = 0; i; --i) {
		while (j < i && a[i] + a[j] < M) ++j;
		b = max(b, j + !(i - j & 1) - (2 * n - i));
	}
	int ans = 0;
	for (int i = b; i < 2 * n + b - i; ++i)
		ans = max(ans, a[i] + a[2 * n + b - i] - M);
	for (int i = 1; i < b - i; ++i)
		ans = max(ans, a[i] + a[b - i]);
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define fo(i,w,n) for(int i=(int) w;i<(int) n;i++)
#define qi queue<int>
#define vi vector<int>
#define ll long long
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define pii pair<int,int>
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define fi first
#define se second
#define prq priority_queue
#define foreach(it,c) for(__typeof((c).begin()) it=c.begin();it!=c.end();it++)
using namespace std;
inline ll read(){
	ll x=0;
	int f=1;
	char c=getchar();
	for(;!isdigit(c);c=getchar()) if(c=='-')f=-f;
	for(;isdigit(c);c=getchar())x=x*10+(c-'0');
	return x*f;
}
int main(){
	//freopen("a.in","r",stdin);
	//freopen("a.out","w",stdout);
	int a,b;
	cin>>a>>b;
	if((a+b)%2){
		cout<<"IMPOSSIBLE\n";
		return 0;
	}
	cout<<(a+b)/2<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int N = 4002;
int dp[N][N],cost[N][N],n,rem[2] = {1,1};
pair<int,int>a[2][N];
char c;
int main(){
	//freopen("readin.txt","r",stdin);
	scanf("%d",&n);
	for(int i = 1;i <= 2*n;i++){
		scanf(" %c",&c);
		scanf("%d",&a[c == 'B'][rem[c == 'B']].first);
		a[c == 'B'][rem[c == 'B']++].second = i;
	}
	sort(a[0] + 1,a[0] + n + 1);
	sort(a[1] + 1,a[1] + n + 1);
	for(int k = 0;k < 2;k++)
		for(int i = 1;i <= n;i++){
			for(int j = 1;j < i;j++)if(a[k][i].second < a[k][j].second)cost[i + k*n][0]++;
			for(int j = 1;j <= n;j++)cost[i + k*n][j] = cost[i + k*n][j - 1] + (a[!k][j].second > a[k][i].second);
		}
	for(int i = 0;i <= n;i++)
		for(int j = 0;j <= n;j++)
			dp[i][j] = 1e9 + 7;
	dp[0][0] = 0;
	for(int i = 0;i <= n;i++)
		for(int j = 0;j <= n;j++)
			dp[i + 1][j] = min(dp[i + 1][j],dp[i][j] + cost[i + 1][j]),
			dp[i][j + 1] = min(dp[i][j + 1],dp[i][j] + cost[j + 1 + n][i]);
	printf("%d\n",dp[n][n]);
}

Measured memory_bytes: 94080
#include <bits/stdc++.h>
using namespace std::literals::string_literals;
using i64 = std::int_fast64_t;
using std::cout;
using std::cerr;
using std::endl;
using std::cin;

template<typename T>
std::vector<T> make_v(size_t a){return std::vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return std::vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

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

	std::vector<std::string> latte = {"SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"};
	for(int i = 0; i < latte.size(); i++) {
		if(latte[i] != s) continue;

		printf("%d\n", 7 - i);
		break;
	}
	return 0;
}


Measured memory_bytes: 256
MAX = 10**9
N = int(input())
A = list(map(int,input().split()))

cnt = 0
a_abs_min = MAX
s = 0
for a in A:
    s += abs(a)
    if a < 0:
        cnt += 1
    if abs(a_abs_min) > abs(a):
        a_abs_min = a

if cnt%2 == 1:
    s -= abs(a_abs_min)*2

print(s)

Measured memory_bytes: 14212
#include<bits/stdc++.h>
using namespace std;
typedef long long int lli;
#define forn(i,n) for(int i=0;i<(int) n;i++)
#define Forn(i,n) for(int i=1;i<=(int) n;i++)
#define M 100005

int main()
{
  int n,t,ans;
  cin>>n;
  t=n+1000-1;
  t/=1000;
  ans=(t*1000)-n;
  cout<<ans;


}






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

int cnt;

void merge(int A[], int left, int mid, int right)
{
	int n1 = mid - left;
	int n2 = right - mid;

	int L[500000];
	int R[500000];
	const int INFTY = 2000000000;
	for (int i = 0; i < n1; ++i)
		L[i] = A[left + i];

	for (int i = 0; i < n2; ++i)
		R[i] = A[mid + i];

	L[n1] = INFTY;
	R[n2] = INFTY;

	int i = 0;
	int j = 0;
	for (int k = left; k < right; ++k) {
		++cnt;
		if (L[i] < R[j]) {
			A[k] = L[i];
			++i;
		} else {
			A[k] = R[j];
			++j;
		}
	}
}

void mergeSort(int A[], int left, int right)
{
	if (left + 1 < right) {
		int mid = (left + right) / 2;
		mergeSort(A, left, mid);
		mergeSort(A, mid, right);
		merge(A, left, mid, right);
	}
}

int main()
{
	int n;
	scanf("%d", &n);
	int A[500000];
	for (int i = 0; i < n; ++i) {
		scanf("%d", &A[i]);
	}
	cnt = 0;
	mergeSort(A, 0, n);
	for (int i = 0; i < n; ++i) {
		if (i > 0) cout << " ";
		cout << A[i];
	}
	cout << endl;
	cout << cnt << endl;
}

Measured memory_bytes: 6188
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long int n,W;
    cin>>n>>W;
    long long int val[n+1];
    long long int wt[n+1];
    
    /* Space O(n*2)
    for(long long int i=0;i<n;i++)
    {
        cin>>wt[i]>>val[i];
    }
	long long int i, w; 
	long long int dp[n + 1][W + 1]; 

	for (i = 0; i <= n; i++) { 
		for (w = 0; w <= W; w++) { 
			if (i == 0 || w == 0) 
				dp[i][w] = 0; 
			else if (wt[i - 1] <= w) 
				dp[i][w] = max( 
					val[i - 1] + dp[i - 1][w - wt[i - 1]], 
					dp[i - 1][w]); 
			else
				dp[i][w] = dp[i - 1][w]; 
		} 
	} 

	cout<<dp[n][W]<<endl;
    */

   /* Space O(n)*/
    long long int dp[W+1]={0};
    long long int ans = INT_MIN;
    for(long long int i=0;i<n;i++)
    {
        cin>>wt[i]>>val[i];
    }

    for(long long int i=0;i<n;i++)
        for(int j=W; j>=wt[i]; j--)
        {
            dp[j] = max(dp[j],val[i]+dp[j-wt[i]]);
        }
    
    for(long long int i=0;i<=W;i++)
        ans = max(ans,dp[i]);
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 1024
# ABC-145-D
X, Y = map(int, input().split())
ans = 0
mod = 10**9 + 7

# 組み合わせを出す関数
# https://qiita.com/derodero24/items/91b6468e66923a87f39f
def cmb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result

if (X + Y) % 3 != 0: 
    ans = 0
else:
    #(+1,+2)を行う回数nを求める。
    n = (2*Y - X)//3
    #(+2,+1)を行う回数mを求める。    
    m = Y - 2*n
    # 例えば、X=18, Y=6のときはnがマイナスになってしまう。
    if n < 0 or m < 0:
        ans = 0
    else:
        ans = cmb(n+m, n)
    
print(ans%mod)

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


int main() {
  int n , m ;
  cin >> n >> m ;
  
  int c = 0 ;
  int a = 1 ;
  while(a<m){
    a=a+(n-1);
    c++;
  }
  
  cout << c << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static final int MOD = 1000000007;

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        long[] a = new long[n];
        long sum = 0;
        for (int i = 0; i < n; i++) {
            long temp = Long.parseLong(sc.next());
            a[i] = temp;
            sum += temp;
            sum %= MOD;
        }
        long[] b = new long[n];
        for (int i = 0; i < n; i++) {
            sum = (sum - a[i] + MOD) % MOD;
            b[i] = sum;
        }
        long ans = 0;
        for (int i = 0; i < n; i++) {
            ans += a[i] * b[i] % MOD;
            ans %= MOD;
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 61120
import math,itertools,fractions,heapq,collections,bisect,sys,queue,copy

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()

def main():
  a,b,c=LI()
  print(c,a,b)

main()
# print(main())


Measured memory_bytes: 5700
#include <bits/stdc++.h>
#define REP(i,n)   for(int i=0;i<(n);++i)
#define ALL(v)     (v).begin(),(v).end()
#define debug(x)   cerr<<#x<<": "<<(x)<<endl
using namespace std;
using llong = long long;
using vi    = vector<int>;
using vvi   = vector<vi >;
using vvvi  = vector<vvi >;
using pii   = pair<int,int>;
constexpr int    INF=1e9;
constexpr double EPS=1e-9;
constexpr int    MOD=1e9+7;
template<class Type>
void line(const Type &a){int cnt=0;for(const auto &elem:a){cerr<<(cnt++?' ':'>');cerr<<elem;}cerr<<endl;}

template<typename Type>
struct Dinic{
	struct Edge{//Edge:=(辺の情報を表す構造体).
		int to;		//to:=(行先). 
		Type cap;	//cap:=(容量).
		int rev;	//rev:=(逆辺).
	};
	
	vector<vector<Edge> > g;//g:=(グラフの隣接リスト表現).
	vi level;				//level[i]:=(sからiまでの距離).
	vi iter;				//iter[i]:=(ノードiの)
	Type inf;
	
	Dinic(int vn):g(vn),level(vn),iter(vn){//constructor.
		if(typeid(Type)==typeid(int)) inf=1e9;
		else if(typeid(Type)==typeid(long long)) inf=1e18;
	};
	
	void add_egde(int from,int to,Type cap){//fromからtoへ向かう容量capの辺をグラフに追加する.
		g[from].push_back((Edge){to,cap,(int)g[to].size()});
		g[to].push_back((Edge){from,0,(int)g[from].size()-1});
	}
	void bfs(int s){//sからの最短距離を計算する.
		fill(ALL(level),-1);
		level[s]=0;
		queue<int> que;
		que.push(s);
		while(!que.empty()){
			int v=que.front();
			que.pop();
			REP(i,g[v].size()){
				Edge &e=g[v][i];
				if(e.cap>0 and level[e.to]<0){
					level[e.to]=level[v]+1;
					que.push(e.to);
				}
			}
		}	
	}
	Type dfs(int v,int t,Type f){//増加パスを探す.
		if(v==t) return f;
		for(int &i=iter[v];i<g[v].size();++i){
			Edge &e=g[v][i];
			if(e.cap>0 and level[v]<level[e.to]){
				Type d=dfs(e.to,t,min(f,e.cap));
				if(d>0){
					e.cap-=d;
					g[e.to][e.rev].cap+=d;
					return d;
				}
			}
		}
		return 0;
	}
	Type max_flow(int s,int t){//sからtへの最大流を調べる. O(en*(vn)^2).
		Type flow=0;
		while(1){
			bfs(s);
			if(level[t]<0) return flow;
			fill(ALL(iter),0);
			Type f;
			while((f=dfs(s,t,inf))>0) flow+=f;
		}
	}
	
};

int main(){//Refering other editorials.
	int n;
	cin>>n;
	
	vector<pii > red(n),bule(n);
	REP(i,n){
		int a,b;
		cin>>a>>b;
		a--, b--;
		red[i]=pii(a,b);
	}
	REP(i,n){
		int c,d;
		cin>>c>>d;
		c--, d--;
		bule[i]=pii(c,d);
	}
	sort(ALL(red));
	sort(ALL(bule));
	
	Dinic<int> ob(2*n+2);
	REP(i,n) ob.add_egde(2*n,i,1);
	REP(i,n) ob.add_egde(i+n,2*n+1,1);
	REP(i,n){
		int c,d;
		tie(c,d)=bule[i];
		REP(j,n){
			int a,b;
			tie(a,b)=red[j];
			if(a>=c) break;
			if(b<d) ob.add_egde(j,i+n,1);
		}
	}
	
	int ans=ob.max_flow(2*n,2*n+1);
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3688
#include <bits/stdc++.h>
typedef long long ll;
typedef unsigned long long ull;
#define reps(i,s,n) for(int (i)=(s);(i)<(n);++(i))
#define rep(i,n) reps(i,0,n)
#define reptr(i,n) for(int (i)=(n);(i)>=0;--(i))
#define All(x) (x).begin(),(x).end()
#define mp make_pair
#define pb push_back
const ll MOD=1e9+7;
using namespace std;

//Mの公約数を配列に格納
//Mにおける任意の公約数をsと置くと, M%s==0,N<=M/sを満たす、最大のsの値がanser

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

  ll mKey = 1;
  for(ll i=2;i*i<=M;i++){
    if(M%i==0){
      //ルートM以下で最大の割り切れる数
      mKey = i;
      break;
    }
  }

  if(N==1){
    cout << M << endl;
    return 0;
  }else{
    //Mが素数のとき
    if(mKey == 1){
      cout << 1 << endl;
      return 0;
    }
  }

  //この状態で必ずMは割り切れるよな?
  ll max = 1;
  ll sMax = M/mKey;
  for(ll s=2;s<=sMax && s*N<=M;s++){
    if(M%s==0){
      max = s;
    }
  }
  cout << max << endl;
}

Measured memory_bytes: 380
/** Which of the favors of your Lord will you deny ? **/

#include<bits/stdc++.h>
using namespace std;

#define LL long long
#define PII pair<int,int>
#define PLL pair<LL,LL>
#define MP make_pair
#define F first
#define S second

#define ALL(x) (x).begin(), (x).end()
#define DBG(x) cerr << __LINE__ << " says: " << #x << " = " << (x) << endl
#define READ        freopen("alu.txt", "r", stdin)
#define WRITE       freopen("vorta.txt", "w", stdout)

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

template<class TIn>using indexed_set = tree<TIn, null_type, less<TIn>,rb_tree_tag, tree_order_statistics_node_update>;

/**

PBDS
-------------------------------------------------
1) insert(value)
2) erase(value)
3) order_of_key(value) // 0 based indexing
4) *find_by_order(position) // 0 based indexing

**/

template<class T1, class T2>
ostream &operator <<(ostream &os, pair<T1,T2>&p);
template <class T>
ostream &operator <<(ostream &os, vector<T>&v);
template <class T>
ostream &operator <<(ostream &os, set<T>&v);

inline void optimizeIO()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
}

const int nmax = 3e3+7;
const LL LINF = 1e17;

template <class T>
string to_str(T x)
{
    stringstream ss;
    ss<<x;
    return ss.str();
}

//bool cmp(const PII &A,const PII &B)
//{
//
//}

double p[nmax];
double dp[nmax][nmax];

//double solve(int h,int tot) /** probability of getting 'h' heads in first 'tot' coins **/
//{
//    if(h==0 && tot==0) return 1.0;
//    if(h==0 || tot==0) return 0.0;
//
//    double &ret = dp[]
//
//
//
//}

int main()
{
    optimizeIO();

    int n;
    cin>>n;

    for(int i=1;i<=n;i++)
        cin>>p[i];

    dp[0][0] = 1;

    for(int h=0;h<=n;h++)
    {
        for(int c=1;c<=n;c++)
        {
            double p1 = 0 , p2 = 0;

            if(h>0) p1 = dp[h-1][c-1] * p[c];
            p2 = dp[h][c-1] * (1-p[c]);

            dp[h][c] = p1 + p2;
        }
    }

    double ans = 0;

    for(int h=0;h<=n;h++)
    {
        int t = n-h;

        if(h>t)
            ans += dp[h][n];
    }

    cout << setprecision(9) << ans<<endl;;

    return 0;
}

/**

**/

template<class T1, class T2>
ostream &operator <<(ostream &os, pair<T1,T2>&p)
{
    os<<"{"<<p.first<<", "<<p.second<<"} ";
    return os;
}
template <class T>
ostream &operator <<(ostream &os, vector<T>&v)
{
    os<<"[ ";
    for(int i=0; i<v.size(); i++)
    {
        os<<v[i]<<" " ;
    }
    os<<" ]";
    return os;
}

template <class T>
ostream &operator <<(ostream &os, set<T>&v)
{
    os<<"[ ";
    for(T i:v)
    {
        os<<i<<" ";
    }
    os<<" ]";
    return os;
}




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

#define ll long long int 

int main(){

	ios_base::sync_with_stdio(false);
	int N ;
	cin >> N ;
	vector<ll> profits(N) ;
	for(int i = 0 ; i < N ; i++) 
		cin >> profits[i] ;
	
	vector<ll> suffix(N) , prefix(N) ;
	
	// prefix calculation
	for(int i = 0 ; i < N ; i++){
		if(i){
			prefix[i] = __gcd(prefix[i-1],profits[i]) ;
		}
		else{
			prefix[i] = profits[i] ;
		}
	}
	//suffix calculation
	for(int i = N-1 ; i >= 0 ; i--){
		if(i < N-1){
			suffix[i] = __gcd(suffix[i+1],profits[i]) ;
		}
		else{
			suffix[i] = profits[i] ;
		}
	}
	
	ll mx_gcd = -1 , ind = - 1;
	
	for(int i = 0 ; i < N; i++){
		ll a = 0 , b = 0 ;
		if(i-1 >= 0) a = prefix[i-1];
		if(i+1 < N ) b = suffix[i+1] ;
		ll cal = __gcd(a,b) ;
		if(cal > mx_gcd){
			mx_gcd = cal ;
			ind = i + 1;
		}
	}
	cout << mx_gcd << endl ;
	return 0 ;
}


Measured memory_bytes: 2560
#include <iostream>
using namespace std;
int main()
{
	char s[4];
	cin >> s;
	//cout << s[0] << "," << s[1] << "," << s[2];

	int a = 0, b = 0, c = 0;
	for (int n = 0; n <= 2; n++)
	{
		//cout << n << endl;
		switch (s[n])
		{
		case 'a':
			a++;
			break;
		case 'b':
			b++;
			break;
		case 'c':
			c++;
			break;
		}
		//cout << a << b << c << endl;
	}
		if ((a == 1) && (b == 1) && (c == 1))
		{
			cout << "Yes" << endl;
		}
		else {
			cout << "No" << endl;
		}

		return 0;
	}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ld double
#define ll long long
#define pb emplace_back
#define mk make_pair
#define mod 1000000007
#define ff first
#define ss second
#define sz(x) (int)x.size()
#define FIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define all(x) x.begin(),x.end()
ll power(ll a, ll b) {ll res = 1; a = a % mod; while (b) {if (b & 1)res = (res * a) % mod; a = (a * a) % mod; b /= 2;} return res;}
ll invmod(ll a) {return power(a, mod - 2);}
int main(void)
{
	FIO
	int t = 1;
	// cin>>t;
	while (t--)
	{
		int n;
		cin >> n;
		vector<ll> mn(n), mx(n);
		for (int i = 0; i < n; i++) {
			cin >> mn[i] >> mx[i];
		}
		auto h = [](int n, vector<ll> arr)-> ll {
			sort(all(arr));
			if (n & 1) return arr[n / 2];
			return arr[n / 2] + arr[n / 2 - 1];
		};
		ll mnn = h(n, mn);
		ll mxn = h(n, mx);
		cout << mxn - mnn + 1 << '\n';
	}
	return 0;
}

Measured memory_bytes: 7908
#include <stdio.h>

int main()
{
    int n = 1;
    int x;
    do
    {
        scanf("%d", &x);
        if (x != 0)
        {
            printf("Case %d: %d\n", n, x);
            n++;
        }
    } while (x != 0);
    return 0;
}


Measured memory_bytes: 2048
#include<iostream>
#include<math.h>
#include<string>
#include<vector>
#include<algorithm>
#include<sstream>

using namespace std;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int t;
  cin >> t;
  int n[t], d[t], ans[t];
  for(int i = 0; i < t; i++){
    cin >> n[i] >> d[i];
    if(n[i]%2 == 1){
      ans[i] = 127*(n[i]-1) + d[i];
    }
    else{
      ans[i] = 127*(n[i]-1) + (127-d[i]);
    }
  }
  
  for(int i = 0; i < t; i++){
    cout << ans[i] << endl;
  }

}


Measured memory_bytes: 256
def GCM(p, q):
  if p < q:
    t = p
    p = q
    q = t
  if p % q == 0:
    return q
  else:
    return GCM(q, p%q)
A, B, K = map(int, raw_input().split())
G = GCM(A, B)
i = 1
CM = []
while i*i <= G:
  if G % i == 0:
    CM.append(i)
    CM.append(G/i)
  i += 1
print sorted(list(set(CM)))[-K]



Measured memory_bytes: 2692
#[derive(Copy, Clone, Eq, PartialEq)]
struct State {
    v: usize,
    d: usize,
}

use std::cmp::Ordering;
impl Ord for State {
    fn cmp(&self, other: &State) -> Ordering {
        other.d.cmp(&self.d)
    }
}

impl PartialOrd for State {
    fn partial_cmp(&self, other: &State) -> Option<Ordering> {
        Some(self.cmp(other))
    }
}

fn run() {
    let n: usize = {
        let mut s = String::new();
        std::io::stdin().read_line(&mut s).unwrap();
        s.trim().parse().unwrap()
    };
    let mut g = vec![vec![]; n + 1];
    for i in 0..n {
        for d in 0..10 {
            let k = (10 * i + d) % n;
            g[i].push((k, d));
        }
    }
    for d in 1..10 {
        let k = d % n;
        g[n].push((k, d));
    }
    let mut dp = vec![9 * (n + 1); n + 1];
    dp[n] = 0;
    let mut h = std::collections::BinaryHeap::new();
    h.push(State{v: n, d: 0});
    while let Some(State{v, d}) = h.pop() {
        if d > dp[v] {
            continue;
        }
        for &(u, c) in g[v].iter() {
            let d = d + c;
            if d < dp[u] {
                dp[u] = d;
                h.push(State{v: u, d: d});
            }
        }
    }
    println!("{}", dp[0]);
}

fn main() {
    run();
}


Measured memory_bytes: 43260
#include <iostream>
#include <fstream>
#include <typeinfo>
#include <vector>
#include <stack>
#include <cmath>
#include <set>
#include <map>
#include <string>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <iomanip>
#include <cctype>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<52;
const double pi=acos(-1);
const double eps=1e-8;
const ll mod=1e9+7;
const vi emp;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,-0};
const int DX[8]={-1,-1,-1,0,0,1,1,1},DY[8]={1,0,-1,1,-1,1,0,-1};

int n;

map<int,int> m;

int main(){
	cin>>n;
	for(int i=0;i<n;i++){
		int A;
		cin>>A;
		m[A]++;
	}
	int sum=0;
	for(auto i=m.begin();i!=m.end();i++) sum+=(i->second)-1;
	cout<<n-(sum+1)/2*2<<endl;
}

Measured memory_bytes: 4864
n = (int)(input())
a=list(map(int, input().split(" ")))
count=0
for i in range(n - 1):
  if a[i] > a[i + 1]:
    count += a[i] - a[i+1]
    a[i+1] += a[i] - a[i+1]
print(count)

Measured memory_bytes: 96704
#include <iostream>
#include <iomanip>
#include <vector>
using namespace std;

typedef vector<double> vd;

int N;
vd P;
vector<vd> dp;

void input_init(void) {
	cin >> N;
	P.resize(N);
	for (int i = 0; i < N; ++i)
		cin >> P[i];
	dp.resize(N + 1, vd(N + 1));
	dp[0][0] = 1.0;
}

void solve(void) {
	for (int i = 0; i < N; ++i) {
		for (int j = 0; j <= i; ++j) {
			dp[i + 1][j + 1] += dp[i][j] * P[i];
			dp[i + 1][j] += dp[i][j] * (1.0 - P[i]);
		}
	}
}

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

	input_init();
	solve();

	double ans = 0.0;
	for (int j = (N + 1) / 2; j <= N; ++j)
		ans += dp[N][j];
	cout << fixed << setprecision(10) << ans << '\n';
	return 0;
}


Measured memory_bytes: 70784
#include<bits/stdc++.h>
using namespace std;
int main(){
  long long int n;
  cin>>n;
  long long int h[100000];
  for(long long int i=0;i<n;i++)
    cin>>h[i];
  vector<long long int> dp(n);
  dp[0]=0;
  for(long long int i=1;i<n;i++){
    if(i-2<0){
    	dp[i]=abs(h[i]-h[i-1])+dp[i-1];
    }
    else dp[i]=min(abs(h[i]-h[i-1])+dp[i-1],abs(h[i]-h[i-2])+dp[i-2]);
  }
  cout<<dp[n-1];
}
 

Measured memory_bytes: 1792
# -*- coding: utf-8 -*-
N = int(input())
A = [int(i) for i in input().split()]
B = [int(i) for i in input().split()]
C = [int(i) for i in input().split()]

X = 0
for i in range(0,N):
    X += B[i]

for i in range(0,N - 1):
    if A[i] + 1 == A[i + 1]:
        X += C[(A[i] - 1)]

print(X)


Measured memory_bytes: 3064
local s=io.read()
local n=#s
local sable={s:byte(1,n)}

local min=100
for alphabyte=97,122 do
    local before=0
    local counter=0
    for i=1,n do
        if sable[i]==alphabyte then
            counter=math.max(counter,i-before-1)
            before=i
        end
    end
    counter=math.max(counter,n-before)
    min=math.min(min,counter)
end
print(min)

Measured memory_bytes: 256