akhauriyash/Code-Regression huggingface dataset:
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.NoSuchElementException;

public class Main {
	
	public static void main(String[] args) {
		FastScanner sc = new FastScanner();
		PrintWriter out = new PrintWriter(System.out);
		
		String s = sc.next();
		int c = s.indexOf('C');
		int f = s.lastIndexOf('F');
		if (c >= 0 && f >= 0 && c < f) {
			out.println("Yes");
		} else {
			out.println("No");
		}
		
		out.flush();
	}
	
}

class FastScanner {
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;
	
	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		} else {
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen <= 0) {
				return false;
			}
		}
		return true;
	}
	
	private byte readByte() {
		if (hasNextByte()) {
			return buffer[ptr++];
		} else {
			return -1;
		}
	}
	
	private boolean isPrintableChar(int c) {
		return '!' <= c && c <= '~';
	}
	
	private void skipUnprintable() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr])) {
			ptr++;
		}
	}
	
	public boolean hasNext() {
		skipUnprintable();
		return hasNextByte();
	}
	
	public String next() {
		if (!hasNext()) {
			throw new NoSuchElementException();
		}
		StringBuilder sb = new StringBuilder();
		byte b = readByte();
		while (isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}
}


Measured memory_bytes: 8148
#include <bits/stdc++.h>
using namespace std;
int main() {
	while (true) {
		int m, f, r;
		cin >> m >> f >> r;
		if (m == -1 && f == -1 && r == -1) break;
		else if (m == -1 || f == -1) cout << "F" << endl;
		else if (m + f >= 80) cout << "A" << endl;
		else if (m + f >= 65)cout << "B" << endl;
		else if (m + f >= 50)cout << "C" << endl;
		else if (m + f >= 30 && r >= 50)cout << "C" << endl;
		else if (m + f >= 30)cout << "D" << endl;
		else cout << "F" << endl;
	}
}


Measured memory_bytes: 3068
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
 long long minim(long long a, long long b) { return a < b ? a : b; }
int main(void){
    long long a,b,n,i,ans=0;
    scanf("%lld %lld %lld",&n,&a,&b);
    ans=(n/(a+b))*a+minim(a,n%(a+b));
    printf("%lld",ans);
    return 0;
}

Measured memory_bytes: 128
n,m = map(int,input().split())
g = [[] for i in range(n)]
ab = []
for k in range(m):
  i,j = map(int,input().split())
  i,j = i-1,j-1
  g[i].append(j)
  g[j].append(i)
  ab.append((i,j))
c = 0
for i in range(m):
  visited = [1]+[0]*(n-1)
  stack = [0]
  while stack:
    cur = stack.pop()
    for j in g[cur]:
      if ab[i] in [(cur,j),(j,cur)]:
        continue
      if visited[j] == 0:
        visited[j] = 1
        stack.append(j)
  if 0 in visited:
    c += 1
print(c)

Measured memory_bytes: 9176
def gcd(x,y):
    if x > y:
        a = y
        b = x % y
    elif x < y:
        a = x
        b = y % x
    else:
        return x

    for i in range(b//2 + 1, 0, -1):
        if a % i == 0 and b % i == 0:
            return i

x,y = (int(i) for i in input().split())

print (gcd(x,y))


Measured memory_bytes: 5604
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define pie 3.141592653589793238462643383279
#define mod 1000000007
#define INF LLONG_MAX/5
#define all(v) v.begin(),v.end()
#define P pair<int,int>
#define S second
#define F first
#define f(i,n) for(int i=0;i<n;i++)
int mypow(int a,int b,int c){
	if(b==0)return 1;
	if(b%2)return mypow(a,b-1,c)*a%c;
	int z=mypow(a,b/2,c);
	return z*z%c;
}
int gcd(int a,int b){
	if(b==0)return a;
	return gcd(b,a%b);
}
int lcm(int a,int b){
	return a/gcd(a,b)*b;
}
int x[1000000];
signed main(){
	int a,b,ans=0;
	cin>>a>>b;
	f(i,a){
		cin>>x[i];
	}
	sort(x,x+a);
	f(i,a-b){
		ans+=x[i];
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
int main(){
    int N, K, Q;
    cin >> N >> K >> Q;
    vector<int> pt(N, K - Q);
    for(int i = 0; i < Q; i++){
        int A;
        cin >> A;
        A--;
        pt[A]++;
    }
    for(int i = 0; i < N; i++){
        if(pt[i] > 0){
            cout << "Yes" << endl;
        } else {
            cout << "No" << endl;
        }
        
    }
}

Measured memory_bytes: 1024
# -*- coding: utf-8 -*-
N, X = map(int, input().split())

p = [0 for _ in range(N+1)]
b = [0 for _ in range(N+1)]
t = [0 for _ in range(N+1)]
p[0] = 1
t[0] = 1
idx = 0
for i in range(1,N+1):
    p[i] = p[i-1]*2 + 1
    b[i] = b[i-1]*2 + 2
    t[i] = p[i]+b[i]
    if X == t[i]:
        print(p[i])
        exit()
    if t[i-1] < X < t[i]:
        idx = i

if X <= N:
    print(0)
    exit()

start = X
ans = 0
for i in reversed(range(1,N+1)):
    if t[i] - i <= start <= t[i]:
        ans += p[i]
        print(ans)
        exit()

    if t[i]//2 == start:
        ans += p[i-1]
        print(ans)
        exit()

    if t[i]//2 + 1 == start:
        ans += p[i-1] + 1
        print(ans)
        exit()

    if t[i]//2 + 1 < start < t[i] - i:
        ans += p[i-1] + 1
        start = start - t[i-1] - 2
    else:
        start = start - 1

print(ans)



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

int li[5];

int main(){
	for(int i=0;i<3;i++) cin >> li[i];
	sort(li,li+3);
	if(li[0]+li[1] == li[2]) cout << "Yes\n";
	else cout << "No\n";
	return 0;
}


Measured memory_bytes: 256
INT = lambda: int(input())
INTM = lambda: map(int,input().split())
STRM = lambda: map(str,input().split())
STR = lambda: str(input())
LIST = lambda: list(map(int,input().split()))
LISTS = lambda: list(map(str,input().split()))
def do():
    n=INT()
    ct=1
    mod=10**9+7
    for i in range(1,n+1):
        ct=ct*i
        ct=ct%mod
    print(ct)
if __name__ == '__main__':
    do()

Measured memory_bytes: 3064
def main():
    from collections import defaultdict, deque
    import sys
    mod = 10**9+7
    N, K = map(int, input().split())
    dic= defaultdict(list)

    for i in range(N-1):
        a, b =  map(int, input().split())
        dic[a].append(b)
        dic[b].append(a)

    seen = [-1]*N
    seen[0]=0
    ans = K
    
    for i in range(len(dic[1])):
        if K-i-1<=0:
            print(0)
            sys.exit()
        ans *= K-i-1
        ans %= mod

    queue = deque(dic[1])
    for  p in dic[1]:
        seen[p-1]=0

    while queue:
        bla= queue.popleft()
        for j in range(len(dic[bla])-1):
            if K-j-2<=0:
                print(0)
                sys.exit()
            ans *= K-j-2
            ans %= mod

        for i in dic[bla]:
            if len(dic[i])==1:
                continue
            if seen[i-1]==-1:
                queue.append(i)
                seen[i-1]=0
    print(ans)
main()

Measured memory_bytes: 103420
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <cassert>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
typedef vector<int> VI;
typedef long long ll;
typedef pair<int,int> PII;
const ll mod=1000000007;
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
// head

ll n,s,b;
int main() {
	scanf("%lld%lld",&n,&s);
	for (b=2;b<=400000;b++) {
		ll x=n,c=0;
		while (x) c+=x%b,x/=b;
		if (c==s) {
			printf("%lld\n",b);
			return 0;
		}
	}
	for (b=400000;b>=1;b--) {
		ll rm=s-b;
		if (rm>=0&&n>rm&&(n-rm)%b==0) {
			ll x=(n-rm)/b;
			if (x>rm) {
				printf("%lld\n",x);
				return 0;
			}
		}
	}
	if (n==s) {
		printf("%lld\n",n+1);
		return 0;
	}
	puts("-1");
}


Measured memory_bytes: 128
#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 rALL(a) (a).rbegin(), (a).rend()
#define SZ(x) ((int)(x).size())
using ll = long long;
using ull = unsigned 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 << 28;
const ll INF64 = 1ll << 55;
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;
}
template <class T>inline void line_out(const vector<T> vec) {
  int n = SZ(vec);
  rep(i, n) {
    cout << vec[i];
    if(i < n-1) cout << " ";
  }
  cout << endl;
  return;
}

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

// h(n, r) = c(n+r-1, r)
struct combination
{
  vector<mint> fact, ifact;
  combination(int n) : fact(n + 1), ifact(n + 1)
  {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i)
    fact[i] = fact[i - 1] * i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i)
    ifact[i - 1] = ifact[i] * i;
  }
  mint operator()(int n, int k)
  {
    if (k < 0 || k > n)
    return 0;
    return fact[n] * ifact[k] * ifact[n - k];
  }
};

ll modpow(ll a, ll n) {
  ll res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}

int main()
{
  int k;
  string s;
  cin >> k >> s;
  combination C(2000010);
  auto H = [&](int n, int r) {
    return C(n+r-1, r);
  };

  mint ans = 0;
  for(int i = 0; i <= k; ++i) {
    mint add = H(SZ(s), i);
    add *= modpow(25, i);
    add *= modpow(26, k-i);
    ans += add;
  }
  cout << ans.x << endl;
}

Measured memory_bytes: 35660
import bisect
from math import factorial
def comb_cnt(n, r):
    return factorial(n) // (factorial(n - r) * factorial(r))

n, a, b = list(map(int, input().split()))
vs = list(map(int, input().split()))
vs.sort()

maxsum = sum(vs[-a:])
val = vs[-a]
l, r = bisect.bisect_left(vs, val), bisect.bisect_right(vs, val)
nmin, nmax = r - (n - a), r - max(l, n - b)
if r != n:
    ans = comb_cnt(r - l, nmin)
else:
    ans = 0
    for i in range(nmin, nmax + 1):
        ans += comb_cnt(r - l, i)

print(maxsum / a)
print(ans)


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

const int N = 1e5+5;
int n;
long long a[N];
long long ans;

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

    cin >> n;
    for(int i=1;i<=n;i++)cin >> a[i];
    long long mini = 1e18;
    int cnt = 0;
    for(int i=1;i<=n;i++){
        if(a[i] < 0){cnt++;a[i]=-a[i];}
        ans += a[i];
        mini = min(mini,a[i]);
    }
    cout << (cnt&1 ? ans - 2 * mini : ans) << "\n";


    return 0;
}


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

int main()
{
    int a, b;
    cin >> a >> b;
    cout<<max(a-2*b,0)<<endl;
    return 0;
}

Measured memory_bytes: 3632
while True:
    a, op, b = input().split()
    if op == "?":
        break

    if op == "+":
        print(int(a)+int(b))
    elif op == "-":
        print(int(a)-int(b))
    elif op == "*":
        print(int(a)*int(b))
    else:
        print(int(int(a)/int(b)))


Measured memory_bytes: 5596
fun main(args: Array<String>) {
    while(true)
    {
        val list = readLine()!!.split(" ").map(String::toInt)
        for ( i in 3..list[0])
        {
            if ((i%3 ==0) or (i.toString().contains('3')))
                    {
                        print(" %d".format(i))
                    }
        }
        println()
        return
    }
}


Measured memory_bytes: 39932
#include<bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
#define bye return 0
#define Yes cout << "Yes" << "\n"
#define No  cout << "No" << "\n"
#define YES cout << "YES" << "\n"
#define NO cout << "NO" << "\n"
//#define endl cout << "\n"
typedef long long ll;
int main(){
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    int k;
    string s;
    cin >> k; 
    cin >> s;
    int l = s.size();
    if(l<=k) cout << s << endl;
    else{
    	for(int i=0; i<k; ++i) cout << s[i];
    		cout << "..." << endl;
    }
    bye;
}



Measured memory_bytes: 3608
#include <bits/stdc++.h>
#define f(i,j,k) for(int i=j;i<k;i++)
using namespace std;
int main(){
    long long x;
    cin>>x;
    vector<long long> a(x+1,0);
    a[1]=1;
    for(long long i=2;i*i<=x;i++){
        long long v=i*i;
        while(v<=x){
            a[v]=1;
            v*=i;
        }
    }
    for(int i=x;i>=1;i--){
        if(a[i]==1){
            cout<<i<<endl;
            return 0;
        }
    }
}


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

int main(void) {
    int n, k;
    cin >> n >> k;
    vector< int > p(n);
    for (int i = 0; i < n; i++) {
        cin >> p[i];
    }
    sort(p.begin(), p.end());
    int sum = 0;
    for (int i = 0; i < k; i++) {
        sum += p[i];
    }
    cout << sum << endl;
    return 0;
}

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

using namespace std;

typedef long long ll;

const int mod = 1e9+7;

int main(){
	std::ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    int s[n+1];
    memset(s,0,sizeof(s));
    for(int i=2;i<=n;i++){
    	if(i%2!=0) continue;
    	for(int j=i;j<=n;j*=2){
    		s[j]++;
		}
	}
	s[1] = 1;
	int ans = 0,t = 0;
	for(int i=n;i>=1;i--){
//		cout << "s[" << i << "] = " << s[i] << "\n";
		if(t<s[i]){
			ans = i;
			t = s[i];
		}
	}
	cout << ans << "\n";

	return 0;
} 


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

int main(){
  int H,N;
  cin >> H >> N;
  
  vector<int> A(N);
  for(int i=0;i<N;i++){
    cin >> A[i];
  }
  
  int sum=0;
  
  for(int i=0;i<N;i++){
    sum=sum+A[i];
  }
  
  if(sum>=H){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}
  


Measured memory_bytes: 640
#include <iostream>
#include <vector>

using namespace std;

int main() {
    int h,w;
    cin >> h >> w;
    vector<string> s(h);
    for (int i=0; i<h; i++) cin >> s[i];

    const vector<int> dx = {-1, 0, 1,-1, 1,-1, 0, 1};
    const vector<int> dy = { 1, 1, 1, 0, 0,-1,-1,-1};

    vector<string> ans(h, string(w,'#'));
    for (int i=0; i<h; i++) {
        for (int j=0; j<w; j++) {
            if (s[i][j] == '#') continue;

            int cnt = 0;
            for (int k=0; k<8; k++) {
                int y = i + dy[k];
                int x = j + dx[k];
                if (y < 0 || h <= y) continue;
                if (x < 0 || w <= x) continue;
                if (s[y][x] == '#') cnt++;
            }
            ans[i][j] = char('0' + cnt);
        }
    }

    for (const auto& a : ans) {
        cout << a << endl;
    }
}

Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)

	var res []byte
	for n > 0 {
		n -= 1
		rem := n % 26
		n /= 26
		res = append(res, byte(rem)+'a')
	}

	Reverse(res)
	fmt.Println(string(res))
}

func Reverse(s []byte) {
	for i, j := 0, len(s)-1; i < j; i, j = i+1, j-1 {
		s[i], s[j] = s[j], s[i]
	}
}


Measured memory_bytes: 1768
#include <set>
#include <map>
#include <list>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <cstring>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#define ft first
#define sc second
#define lb lower_bound
#define ub upper_bound
#define pb(t) push_back(t)
#define pt(num) cout << num << "\n"
#define chmax(a, b) (a<b ? a=b : 0)
#define chmin(a, b) (a>b ? a=b : 0)
#define max(a, b) ((a)>(b) ? (a):(b))
#define min(a, b) ((a)<(b) ? (a):(b))
#define moC(a, s, b) (a)=((a)s(b)+MOD)%MOD
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef map<ll, ll> Map;
static const ll INF=1e18;
static const ll MAX=1e5+7;
static const ll MOD=1e9+7;





int main(void) {
    ll N, M;
    cin >> N >> M;
    P p[MAX];
    ll i;
    
    for(i=0; i<N; i++) {
        cin >> p[i].ft >> p[i].sc;
    }
    sort(p, p+N);
    
    ll ans=0;
    ll cnt=0;
    for(i=0; i<N; i++) {
        
        if(cnt+p[i].sc>=M) {
            ans+=p[i].ft*(M-cnt);
            pt(ans);
            return 0;
        }
        
        ans+=p[i].ft*p[i].sc;
        cnt+=p[i].sc;
        
    }
    
    
    
}





Measured memory_bytes: 1792
def isprime(n):
  if n == 2:
    return True
  if n % 2 == 0:
    return False
  
  m = int(n ** 0.5) + 1
  for p in range(3, m, 2):
      if n % p == 0:
        return False
  return True

x = int(input())

while isprime(x) == False:
    x += 1
  
print(x)

Measured memory_bytes: 9228
#!/usr/bin/env python3
import sys


def solve(r: int):
    print(r**2)
    return


# Generated by 1.1.5 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    r = int(next(tokens))  # type: int
    solve(r)

if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
bin_str = str(input())  # 入力されたビット列そのまま文字列
bitdigits = len(bin_str)  # 桁数

cntzero = bin_str.count("0")
cntone = bin_str.count("1")

if cntzero < cntone:
    print(cntzero * 2)
else:
    print(cntone * 2)

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

typedef long long ll;

ll a, b, n;

int main()
{
  cin >> n >> a >> b;
  if (a == b) cout << "1" << endl;
  else if (n == 1 || a > b) cout << "0" << endl;
  else cout << (b - a) * (n - 2) + 1;
  return 0;
}


Measured memory_bytes: 256
// #define _GLIBCXX_DEBUG // for STL debug (optional)
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
#include <unordered_map>
using namespace std;

#define debug(...) fprintf(stderr, __VA_ARGS__)
#define int long long int
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
typedef pair<int, int> pii;
typedef long long ll;
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const ll INF = 1001001001001001LL;
const ll MOD = 1000000007LL;

// 約数全列挙
vector<ll> OutDivisor(ll n) {
    vector<ll> ret;
    for(ll i=1; i*i<=n; i++) {
        if(n % i == 0) {
            ret.push_back(i);
            if(i*i!=n) ret.push_back(n / i);
        }
    }
    return ret;
}

map<int, int> mp;
signed main() {
    int N; cin >> N;
    vector<int> A(N);
    for(int i=0; i<N; i++) {
        cin >> A[i];
    }

    set<int> cand;
    for(int i=0; i<min(N, 2LL); i++) {
        auto vec = OutDivisor(A[i]);
        for(auto e : vec) cand.insert(e);
    }

    for(int i=0; i<N; i++) {
        for(auto e : cand) {
            if(A[i] % e == 0) mp[e]++;
        }
    }

    int ans = 0;
    for(auto e : mp) {
        if(e.second >= N-1) chmax(ans, e.first);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define int long long
int32_t main()
{
   int x,n,p,q;
   cin>>x>>n;
   int a[n];
   map<int,int>m;
   for(int i=0;i<n;++i)
   {
      cin>>a[i];
      m[a[i]]=1;
   }
   for(int i=x;i>=0;--i)
   {
      if(m[i]!=1)
      {
         p=i;break;
      }
   }
   for(int i=x;i<x+100;++i)
   {
      if(m[i]!=1)
      {
         q=i; break;
      }
   }
   if(abs(p-x)<=abs(q-x))
   cout<<p;
   else
   {
      cout<<q;
   }
   
   
}

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

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<=(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define Eunique(v) v.erase(unique(all(v)),v.end())
#define Eback(s) s.erase(s.end()-1,s.end())
#define rev(v) reverse(all(v))
#define minvec(v) *min_element(all(v))
#define maxvec(v) *max_element(all(v))
#define sumvec(v) accumulate(all(v),0)
#define mapmax(v) v.rbegin()->first
#define mapmin(v) v.begin()->first
#define pb push_back
#define pf push_front
#define mod 1000000007
#define m_p make_pair
#define DOUBLE fixed << setprecision(15)
#define OK puts("OK")
#define OK1 puts("OK1")
#define OK2 puts("OK2")
#define SIZE(s) (int)s.size()
#define INF ((1LL<<62)-(1LL<<31))
#define zero(x,n) setw(x) << setfill('0') << n

typedef long long ll;

typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<double> vd;
typedef vector<char> vc;
typedef vector<string> vs;

typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
typedef vector<pair<int,int>> vpii;
typedef vector<pair<ll,ll>> vpll;

const double pi = acos(-1.0);

template<class A, class B>
ostream& operator<<(ostream& ost, const pair<A, B>&p) {
	ost << "{" << p.first << ", " << p.second << "} ";
	return ost;
}

template<class T>
ostream& operator<<(ostream& ost, const vector<T>&v) {
	ost << "{";
	for (int i = 0; i<(int)v.size(); i++) {
		if (i)ost << " ";
		ost << v[i];
	}
	ost << "} \n";
	return ost;
}

template<class A, class B>
ostream& operator<<(ostream& ost, const map<A, B>&v) {
	ost << "{";
	for (auto p:v) {
		ost << "{" << p.first << ", " << p.second << "} ";
	}
	ost << "} ";
	return ost;
}

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

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

ll gcd(ll x, ll y) {return __gcd(x,y);}
ll lcm(ll x, ll y) {return x/__gcd(x,y)*y;}

int main()
{
	ll n,m,ans=0;
	cin >> n >> m;
	if(n*2<=m){
		ans+=n;
		m-=n*2;
		cout << ans+m/4 << endl;
	}
	else cout << m/2 << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <unordered_map>
#include <math.h>
#include <algorithm>
#include <deque>
#include <queue>
#include <climits>
using namespace std;
#define rep(i,l,r) for(int i=l;i<r;i++)
#define repb(i,r,l) for(int i=r;i>l;i--)
#define ll long long
#define ull unsigned long long
#define ve vector
#define umap unordered_map
#define iter iterator

string ar[50];
void solve() {
    int n;cin>>n;
    for(int i=0;i<n;i++) cin>>ar[i];
    int mp[50][26] = {0};
    char ch;
    for(int i=0;i<n;i++) {
        for(int j=0;j<ar[i].size();j++) {
            mp[i][ar[i][j] - 'a']++;
        }
    }
    string s;
    for(int i=0;i<26;i++) {
        int m = 50;
        for(int j=0;j<n;j++) {
            m = min(mp[j][i], m);
        }
        cout<<endl;
        for(int j=0;j<m;j++) {
            s += (char)(i+'a');
        }
    }
    cout<<s<<endl;
}

int main() {
    solve();
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void){
    // Your code here!
    char s[4],t[4];
    int cnt=0;
    scanf("%s%s",s,t);
    for(int i=0;i<3;i++){
        if(s[i]==t[i])cnt++;
    }
    printf("%d\n",cnt);
    return 0;
}

Measured memory_bytes: 128
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String str = sc.next();
		int n = 0;

		for(int i = 0;i < 3; i++) {
			if(str.charAt(i) == '1') {
				n += 1;
			}else {
				n += 0;
			}
		}
		System.out.println(n);

	}

}


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

#define mp make_pair
typedef long long ll;
typedef pair<int,int>pii;
typedef pair<ll,ll>pll;
const ll mod = 1e9+7;
const int N = 1e5;
ll npr1[N+100],npr2[N+100];
vector<int>graph[N+100];
int deg[N+100];
void dfs(int u,int p)
{
	for(auto it:graph[u])
	{
		if(it!=p){
			deg[u]++;
			dfs(it,u);
		}
	}
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n,k;
	cin >> n >> k;
	for(int i=1;i<n;i++){
		int u,v;
		cin >> u >> v;
		graph[u].push_back(v);
		graph[v].push_back(u);
	}
	dfs(1,-1);
	npr1[0] = 1,npr2[0] = 1;
	for(int i=1;i<=k;i++){
		npr1[i] = (npr1[i-1]*(k-i+1))%mod;
	}
	for(int i=1;i<=k-2;i++){
		npr2[i] = (npr2[i-1]*(k-2-i+1))%mod;
	}
	deg[1]++;
	ll ans = npr1[deg[1]];
	for(int i=2;i<=n;i++){
		ans = (ans*npr2[deg[i]])%mod;
	}
	cout << ans << "\n";
}


Measured memory_bytes: 11008
n = int(input())
a = []
for _ in range(n):
    a.append(int(input()))

desc = sorted(list(set(a)), reverse=True)
max = desc[0]
large_2 = desc[1] if len(desc) > 1 else 0

if a.count(max) == 1:
    for val in a:
        if val == max:
            print(large_2)
        else:
            print(max)
else:
    for _ in range(n):
        print(max)


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

int main() {
  int n;
  cin >> n;
  
  vector<int> a(n);
  for (int i=0;i<n;i++) {
    cin >> a.at(i);
  }
  
  int k = 0, ret = -1;
  for (int i=0;i<n;i++) {
    if (a.at(k) == 2) { 
      ret = i+1;
      break; }
    if (a.at(k) == k+1) { 
      ret = -1;
      break; }
    k = a.at(k) -1;
  }
  cout << ret << endl;

}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<pair<int,int>> vpii;

#define F first
#define S second
#define PU push
#define PUF push_front
#define PUB push_back
#define PO pop
#define POF pop_front
#define POB pop_back

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

void solve(int test_case) {
	ll n,k;
	cin>>n>>k;
	ll ans = k;
	ans*=pow(k-1,n-1);
	cout<<ans;
}

int main() {
	
	////// FILE BASED IO////
	//freopen("in", "r", stdin);
	//freopen("out", "w", stdout);
	///////////////
	
	ios::sync_with_stdio(0);
	cin.tie(0);
	int t=1;
	//cin>>t;
	REP(i,1,t) {
		solve(i);
	}
}	


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

typedef long long ll;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define each(itr,c) for(__typeof(c.begin()) itr=c.begin(); itr!=c.end(); ++itr)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second

typedef vector<int> vi;
typedef vector<vi> Mat;

Mat mul(const Mat &a, const Mat &b, int mod)
{
    int n=a.size();
    Mat c(n,vi(n,0));
    rep(i,n)rep(j,n)rep(k,n) (c[i][j]+=a[i][k]*b[k][j])%=mod;
    return c;
}

Mat make(int n, int A, int B, int C)
{
    Mat r(n,vi(n,0));
    if(n==1) r[0][0]=B;
    else
    {
        r[0][0]=B;
        r[0][1]=C;
        r[n-1][n-2]=A;
        r[n-1][n-1]=B;
        for(int i=1; i<n-1; ++i)
        {
            r[i][i-1]=A;
            r[i][i]=B;
            r[i][i+1]=C;
        }
    }
    return r;
}

int main()
{
    int n,m,a,b,c,t;
    while(cin>>n>>m>>a>>b>>c>>t,n)
    {
        vector<int> s(n);
        rep(i,n) cin >>s[i];

        Mat P[31];
        P[0]=make(n,a,b,c);
        for(int i=1; i<31; ++i) P[i]=mul(P[i-1],P[i-1],m);

        Mat A(n,vi(n,0));
        rep(i,n) A[i][i]=1;
        for(int i=30; i>=0; --i)
        {
            if(t>=(1<<i))
            {
                A=mul(A,P[i],m);
                t-=(1<<i);
            }
        }

        rep(i,n)
        {
            int ans=0;
            rep(j,n) (ans+=A[i][j]*s[j])%=m;
            if(i) printf(" ");
            printf("%d", ans);
        }
        printf("\n");
    }
    return 0;
}

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

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef tuple<int,int,int> tpl;

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RFOR(i,a,b) for(int i=(a)-1;i>=(b);--i)
#define RREP(i,n) RFOR(i,n,0)

const double EPS = 1e-9;
const double PI  = acos(-1.0);
const int INT_INF = 2147483647;
const long long LL_INF = 1LL<<60;
const long long MOD = 1000000007;

#define CLR(a) memset((a), 0 ,sizeof(a))

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

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

int main(void){
    int N; cin >> N;
    VI x(N), y(N), h(N);
    REP(i,N) cin >> x[i] >> y[i] >> h[i];
    int t;
    REP(i,N){
        if(h[i] > 0){
            t = i;
            break;
        }
    }

    FOR(cx,0,101)FOR(cy,0,101){
        int H = h[t] + abs(x[t]-cx) + abs(y[t]-cy);
        bool flag = true;
        REP(i,N){
            if(h[i] != max(H - abs(x[i]-cx) - abs(y[i]-cy), 0)){
                flag = false;
                break;
            }
        }
        if(flag){
            cout << cx << " " << cy << " " << H << endl;
            return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll =long long;
#define all(v) v.begin(),v.end()
 
int main() {
  ll a,b;
  cin>>a>>b;
  if(a<=b) {
cout<<a<<endl;
  }
  else {
cout<<a-1<<endl;
  }
}

Measured memory_bytes: 3580
//JSD
#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<cmath>
#define ll long long 
#define Mod 1000000007
using namespace std;
map<ll,ll> m;
ll modular_exponentiation(ll a,ll b){	
	if(b==0){
		return 1;
	}
	if(b==1){
		return a%Mod;
	}
	ll x=modular_exponentiation(a,b/2);
	x=(x*x)%Mod;	
	if(b%2==1){
		x=(x*a)%Mod;
	}
	return x;
}
ll modular_divison(ll a,ll b){
    return (modular_exponentiation(b,Mod-2)*a)%Mod;	
}
bool isPrime(ll n){
	if(n<=1) return 0;
	if(n==2 or n==3 ) return 1;
	if(n%2==0 or n%3==0) return 0;
	for(ll i=5;i*i<=n;i+=6){
		if(n%i==0 or n%(i+2)==0)
			return 0;
	}
	return 1;
}
struct primeFactorInfo{
	map<ll,ll> M;
	set<ll> S;
};
primeFactorInfo pfs(ll n){
	primeFactorInfo p;
	for(ll i=2;i<=sqrt(n);i++){				
		if(n%i==0){
			p.S.insert(i);			
			while(((n%i)==0)){							
				p.M[i]++;
				n/=i;			
			}
		}		
	}
	if(n>1){
		p.M[n]++;
		p.S.insert(n);
	}	
	return p;
}
void sieve(ll n,vector<ll>& v){
	bool isComposite[n+1]={0};
	isComposite[0]=isComposite[1]=1;	
	for(ll i=2;i*i<=n;i++){
		if(!isComposite[i]){
			v.push_back(i);
			for(int j=2;j*i<=n;j++){
				isComposite[i*j]=1;
			}
		}		
	}
}
primeFactorInfo pfsUsingFeededSieve(ll n,vector<ll> &v){
	primeFactorInfo p;		
	for(auto i: v){				
		if(n%i==0){
			p.S.insert(i);			
			while(((n%i)==0)){							
				p.M[i]++;
				n/=i;			
			}
		}		
	}
	if(n>1){
		p.M[n]++;
		p.S.insert(n);
	}	
	return p;
}
int main(){	
	ll n;
	cin>>n;
	ll a[n];
	vector<ll> v;
	sieve(1000002,v);
	for(ll i=0;i<n;i++)	{
		cin>>a[i];	
		primeFactorInfo p=pfsUsingFeededSieve(a[i],v);
		for(auto x: p.M){
			m[x.first]=max(m[x.first],x.second);
		}
	}	
	ll lcm=1,ans=0;
	for(auto x: m)	{
		for(int j=0;j<x.second;j++){
			lcm=((lcm*x.first)%Mod);
		}
	}
	for(ll i=0;i<n;i++){
		ans=(ans+(modular_divison(lcm,a[i])))%Mod;
	}
	cout<<ans<<"\n";
	return 0;
}

Measured memory_bytes: 1920
n = int(input())
prime = [2]
for i in range(3, 101):
  for j in range(2, i + 1):
    if (i % j) == 0:
      break
  if i == j:
    prime.append(i)
pflag = True
for k in prime:
  if k >= 10:
    if (n % k == 0):
      pflag = False
for l in range(50, 101, 10):
  if (n % l) == 0:
    pflag = False
if n > 81:
  pflag = False
if(pflag):
  print('Yes')
else:
  print('No')

Measured memory_bytes: 3064
#include <stdio.h>
int main()
{
	unsigned long long a,b,x;
	scanf("%llu %llu %llu", &a, &b, &x);
	unsigned long long nCnt = 0;

	if (x == 0)
	{
		printf("0");
		return 0;
	}

	unsigned long long nBigJ = b / x;
	unsigned long long nSmlJ = a / x;
	unsigned long long nSmlA = a % x;

	nCnt = nBigJ - nSmlJ;
	if (0 == nSmlA)
		nCnt++;
	printf("%llu", nCnt);
	return 0;
}

Measured memory_bytes: 128
#include <stdio.h>
#include <string.h>
//#include <stdlib.h>
#define N 100005

typedef struct pp{
char name[100];
int t;
} P;

P Q[N];
int head,tail,n;

void enqueue(P x){
  Q[tail] = x;
  tail = (tail + 1) % N;
}

P dequeue(){
  P x = Q[head];
  head = (head +1) % N;
  return x;
}

int min(int a,int b){
  return a < b ? a : b;
}

int main(){

  int elaps = 0,c;
  int i,q;
  P u;

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

  for(i=1; i<=n; i++){
    scanf("%s %d",Q[i].name,&Q[i].t);
  }

   /*i=0;
  while(count!=n){
    if(t[i]<=q){
      total += t[i];
      t[i] = t[i]-t[i];
    }
    else {
      total += q;
      t[i] = t[i]-q;

        ntmp=name[i];
        ttmp=t[i];
        j=0;
        while(t[j+1]!='\0'){
          t[j]=t[j+1];
          name[j]=name[j+1];
          j++;
        }
        name[j]=ntmp;
        t[j]=ttmp;
    }

    if(t[i]==0){
      printf("%s %d\n",name,total);
      count++;
    }

    i++;

  }
  */

  head = 1;
  tail = n+1;

  while(head != tail){
    u=dequeue();
    c = min(q,u.t);
    u.t -= c;
    elaps += c;
    if(u.t > 0) enqueue(u);
    else {
      printf("%s %d\n",u.name,elaps);
    }
  }

  return 0;
  }



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

using namespace std;
const int MAXN=610; 
long long int A[MAXN],N,K;
long long int sol[MAXN][MAXN];
long long int dp(int start, int end){
	if(start==end)
		sol[start][end]=0;	
	if(sol[start][end]!=-1)
		return sol[start][end];
	sol[start][end]=LONG_MAX;
	for(int i=start;i<end;i++)
		sol[start][end]=min(sol[start][end],dp(start,i)+dp(i+1,end));
	for(int i=start;i<=end;i++)
		sol[start][end]+=A[i];
	return sol[start][end];
}
int main(){
	cin>>N;
	for(int i=0;i<N;i++)
		cin>>A[i];
	for(int i=0;i<N;i++)
		for(int j=0;j<N;j++)
			sol[i][j]=-1;
	cout<<dp(0,N-1);
}

Measured memory_bytes: 2176
#include <iostream>
#include <vector>
#include <map>
using namespace std;

const int divisor = 1000000007;

int main(){
	//vector<int> ansvec;

	// 100000!までの数をdivisorで割った余りを格納しておく
	long long* factmodary = new long long[100001];
	long long fact = 1;
	for (int i = 1; i <= 100000; i++){
		fact *= i;
		fact %= divisor;
		factmodary[i] = fact;
	}

	int* word = new int[100000] {0};

	for (;;){
		int N, R;
		cin >> N;
		if (N == 0) break;
		cin >> R;
		
		//まず0番目の単語を入れておく
		for (int i = 0; i < N; i++) word[i] = i + 1;

		for (int i = 0; i < R; i++){
			int s, t;
			cin >> s >> t;
			/* swap */
			int tmp = word[s - 1]; word[s - 1] = word[t - 1]; word[t - 1] = tmp;
		}

		//word[i]をkey, word[i]より小さい数がそれ以前にいくつ使われていたかをvalueとして格納するmap
		map<int, int> bubblehist;
		bubblehist[word[0]] = 0;

		long long ans = factmodary[N-1] * (word[0] - 1);

		for (int i = 1; i < N; i++){
			int facttime = word[i] - 1;
			int bubblenum;
			map<int, int>::iterator it = bubblehist.lower_bound(word[i]);

			if (it != bubblehist.end()){
				bubblenum = it->second;
				it--;
			}
			else {
				it--;
				bubblenum = it->second + 1;
			}
			pair<int, int> p;
			p.first = word[i];
			p.second = bubblenum;
			map<int, int>::iterator it2 = bubblehist.insert(it, p);
			//word[i]より大きい数はすべてvalueが1増える
			for (++it2; it2 != bubblehist.end(); it2++) (it2->second)++;

			facttime -= bubblenum;
			ans += factmodary[N - (i + 1)] * facttime;
			ans %= divisor;
		}
		cout << (int)ans << endl;
		//ansvec.push_back((int)ans);
	}

	//for (vector<int>::iterator it = ansvec.begin(); it != ansvec.end(); it++) cout << *it << "\n";

	delete[] word;
	delete[] factmodary;
	return 0;
}

Measured memory_bytes: 6816
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 1e16;
const ll mod = 1000000007;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

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;
}
int ctoi(char c) {
  if (c >= '0' && c <= '9') {
    return c - '0';
  }
  return 0;
}
ll factorial(ll n) {
  if (n == 1) {
    return 1;
  }
  ll ans = factorial(n-1);
  return ans*n;
}
ll gcd(ll a, ll b) {
  if (b == 0) return a;
  return gcd(b, a%b);
}
ll lcm(ll a, ll b) {
  return (a/gcd(a, b))*b;
}
bool is_prime(ll n) {
  for (ll i = 2; i*i <= n; i++) {
    if (n%i == 0) return false;
  }
  return n != 1;
}
ll mod_pow(ll x, ll n, ll mod) {
  if (n == 0) return 1;
  ll res = mod_pow(x*x%mod, n/2, mod);
  if (n & 1) res = res * x % mod;
  return res;
}

int main() {
  string s;
  cin >> s;
  rep(i, s.size()) {
    if (i%2 == 0) cout << s.at(i);
  }
  cout << endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
using P = pair<int,int>;
const int MOD=1000000007;

int main() {
  int n, k;
  cin >> n >> k;
  int ans=0;
  rep(i,n) {
    int h;
    cin >> h;
    if(h>=k) ans++;
  }

  cout << ans << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){
  int a,b,c,n,ans=0;
  scanf("%d",&n);
  a=n/100;
  b=n%100/10;
  c=n%10;
  switch(a){
    case 1:a=9;
      break;
    case 9:a=1;
      break;
  }
  switch(b){
    case 1:b=9;
      break;
    case 9:b=1;
      break;
  }
  switch(c){
    case 1:c=9;
      break;
    case 9:c=1;
      break;
  }
  ans=a*100+b*10+c;
  printf("%d\n",ans);
  return 0;
}


Measured memory_bytes: 128
parseInt(x) = parse(Int, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

function main()
	n,t = readline() |> split |> parseMap
	a = readline() |> split |> parseMap
	ma = a[1]
	d = Dict{Int,Int}()
	for i in 2:n
		if a[i]>ma
			if haskey(d,a[i]-ma)
				d[a[i]-ma]+=1
			else
				d[a[i]-ma] = 1
			end
		else
			ma = a[i]
		end
	end
	z = 0
	zk = 0
	for k in keys(d)
		if k>z
			z = k
			zk = d[k]
		end
	end
	println(zk)
end

main()

Measured memory_bytes: 174512
#include<bits/stdc++.h>
using namespace std;
typedef  long long  int ll;
int main()
{ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    ll n;
    cin>>n;
    ll z1=0,z2=0;
    ll a[n+1],b[n+1];
    priority_queue <ll> l2;
    priority_queue <ll, vector<ll>, greater<ll> > l1;
    vector<ll> v;
    for(ll i=0;i<n*3;i++)
    {ll x;
    cin>>x;
    
        if(i<n)
        {
            l1.push(x);
            z1+=x;
        }
        if(i>=2*n)
        {
            l2.push(x);
            z2+=x;
        }
        v.push_back(x);
    }
    a[0]=z1;
    b[n]=z2;
    for(ll i=n;i<2*n;i++ )
    {
        if(v[i]>l1.top())
        {  z1-=l1.top();
            z1+=v[i];
          
            l1.pop();
            l1.push(v[i]);
            
            
            
        }
        a[i-n+1]=z1;
        
    }
    for(ll i=(2*n)-1,j=n-1;i>=n;i--,j--)
    {
    if(v[i]<l2.top())
    { z2-=l2.top();
        z2+=v[i];
       
          l2.pop();
            l2.push(v[i]);
        
    }
    b[j]=z2;
        
    }
    ll ans=-1e15;
    for(ll i=0;i<=n;i++)
    {ans=max(ans,a[i]-b[i]);
        
    }
    cout<<ans;
    
    
}


Measured memory_bytes: 8424
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author cksharma
 */

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

class CGrandGarden {
public:
    void solve(istream& cin, ostream& cout) {
        ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
        cout.setf(ios::fixed); cout.precision(20);
        int n; cin >> n;
        vector<int> arr(n);
        for (int& a : arr) cin >> a;

        int ans = 0;
        list<vector<int>> V; V.push_back(arr);
        while (V.size() > 0) {
            const vector<int>& v = V.front();
            int min = *min_element(v.begin(), v.end());
            vector<int> temp;
            for (int j = 0; j < v.size(); ++j) {
                if(v[j] != min) {
                    temp.push_back(v[j] - min);
                } else if(temp.size() > 0) {
                    V.push_back(temp);
                    temp.clear();
                }
            }
            if (temp.size() > 0) V.push_back(temp);
            ans += min;
            V.pop_front();
        }
        cout << ans << endl;
    }
};


int main() {
    CGrandGarden solver;
    std::istream& in(std::cin);
    std::ostream& out(std::cout);
    solver.solve(in, out);
    return 0;
}


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

long long int inf=1e9+7;

int main(){
	int n,m,R;
	cin>>n>>m>>R;
	vector<int> r(R);
	for(int i=0;i<R;i++)cin>>r[i];
	vector<vector<int> > g(n+1,vector<int>(n+1,inf));
	for(int i=0;i<m;i++){
		int a,b,c;
		cin>>a>>b>>c;
		a;
		b;
		g[a][b]=c;
		g[b][a]=c;
	}
	for(int i=0;i<n+1;i++)g[i][i]=0;
	
	for(int k=1;k<n+1;k++){
		for(int i=1;i<n+1;i++){
			for(int j=1;j<n+1;j++){
				g[i][j]=min(g[i][j],g[i][k]+g[k][j]);
			}
		}
	}
	
	int ans=1e9;
	int tmp;
	
	sort(r.begin(),r.end(),greater<int>());
	
	do{
		tmp=0;
		for(int i=0;i<r.size()-1;i++){
			tmp+=g[r[i]][r[i+1]];
		}
		ans=min(ans,tmp);
	}while(prev_permutation(r.begin(),r.end()));
	
	cout<<ans<<endl;
}

Measured memory_bytes: 384
using System;
using System.Collections.Generic;
using System.Text;
using System.Numerics;
using System.IO;


namespace SolutionCS
{
    class Program
    {
        struct MOVE
        {
            public MOVE(int fW,int fH,int tW,int tH)
            {
                fromW = fW;
                fromH = fH;
                toW = tW;
                toH = tH;
            }

            public int fromW;
            public int fromH;
            public int toW;
            public int toH;
        }



        static void Main(string[] args)
        {
            string[] s = Console.ReadLine().Split(' ');
            int H = int.Parse(s[0]);
            int W = int.Parse(s[1]);

            int[,] v = new int[W, H];

            for (int i = 0; i < H; i++)
            {
                s = Console.ReadLine().Split(' ');

                for (int j = 0; j < W; j++)
                {
                    v[j, i] = int.Parse(s[j]);
                }
            }

            List<MOVE> lm = new List<MOVE>();
            for (int h = 0; h < H; h++)
            {
                for (int w = 0; w < W - 1; w++)
                {
                    if(0 != v[w,h] % 2)
                    {
                        lm.Add(new MOVE(w + 1, h + 1, w + 2, h + 1));
                        v[w + 1, h]++;
                    }
                }
            }

            for(int h = 0; h < H - 1; h++)
            {
                if (0 != v[W - 1, h] % 2)
                {
                    lm.Add(new MOVE(W, h + 1, W, h + 2));
                    v[W - 1, h + 1]++;
                }
            }

            Console.WriteLine(lm.Count);

            foreach(MOVE m in lm)
            {
                Console.WriteLine("{0} {1} {2} {3}", m.fromH, m.fromW, m.toH, m.toW);
            }
        }
    }
}




Measured memory_bytes: 23976
#include <bits/stdc++.h>
#define SORT(a) sort(a.begin(), a.end())
#define RSORT(a) sort(a.rbegin(), a.rend())
#define REP(i, n) for (long long i = 0; i < n; i++)
#define RREP(i, n) for (long long i = n - 1; 0 <= i; i--)
#define FOR(i, start, end) for (long long i = start; i < end; i++)
#define RFOR(i, start, end) for (long long i = start - 1; 0 <= i; i--)
#define ALL(a) a.begin(), a.end()
#define MOD(a) a %= 1'000'000'007
using ll = long long;
using namespace std;
const int INF32       = 1'050'000'000;
const long long INF64 = 4'000'000'000'000'000'000;
const int MOD7        = 1'000'000'007;
const int MOD9        = 1'000'000'009;
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;
}
void print() { std::cout << '\n'; }
template <class H, class... T> void print(H &&head, T &&... args) {
    std::cout << head;
    sizeof...(args) == 0 ? std::cout << "" : std::cout << ' ';
    print(std::forward<T>(args)...);
}
template <class T> void print(std::vector<T> &v) {
    for (int i = 0; i < v.size(); i++) {
        std::cout << v[i];
        i == v.size() - 1 ? std::cout << '\n' : std::cout << ' ';
    }
}
template <class T> void print(std::vector<std::vector<T>> &v) {
    for (int i = 0; i < v.size(); i++) {
        for (int j = 0; j < v[i].size(); j++) {
            std::cout << v[i][j];
            j == v[i].size() - 1 ? std::cout << '\n' : std::cout << ' ';
        }
    }
}

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

    ll a, b;
    cin >> a >> b;
    auto posi = []() {
        print("Positive");
        exit(0);
    };
    auto nega = []() {
        print("Negative");
        exit(0);
    };
    auto zero = []() {
        print("Zero");
        exit(0);
    };
    if (0 < a && 0 < b) {
        posi();
    }
    if (a <= 0 && 0 <= b) {
        zero();
    }
    if (a < 0 && b < 0) {
        if (abs(b - a + 1) % 2 == 0) {
            posi();
        } else {
            nega();
        }
    }

    return 0;
}

Measured memory_bytes: 256
// #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define REP(i, n) for (int i = 0; i < n; ++i)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x) cout << #x << ' ' << '=' << ' ' << (x) << endl;
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
typedef long long ll;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> T;
typedef vector<ll> vec;
typedef vector<P> pvec;
typedef vector<vector<ll>> vvec;
typedef vector<vector<P>> pvvec;
typedef priority_queue<ll> PQI;
typedef priority_queue<P> PQP;
typedef priority_queue<ll,vector<ll>,greater<ll>> PQIG;
typedef priority_queue<P,vector<P>,greater<P>> PQPG;
const vector<int> dx = {0, -1, 0, 1, 1, 1, -1, -1};
const vector<int> dy = {1, 0, -1, 0, 1, -1, 1, -1};
const int MOD = (1000000007);
// const int MOD = (998244353);
// const int INF = (1 << 30);
const int INF = (1LL << 60);
const double EPS = (1 >> 30);
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return 1;} return 0;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return 1;} return 0;}
template< typename T1, typename T2 > istream &operator>>(istream &is, pair< T1, T2 > &p) { is >> p.first >> p.second; return is; }
template< typename T > istream &operator>>(istream &is, vector< T > &v) { for(T &in : v) is >> in; return is; }



signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(15);
    //---------------------------------------------
    
    string s;
    cin>>s;
    int ng=0;
    int n=s.size();
    rep(i,s.size()){
        if(s.substr(i,2)=="hi"){

        }
        else{
            ng++;
        }
        i++;
    }
    if(ng==0&&n%2==0){
        cout<<"Yes"<<endl;
    }
    else{
        cout<<"No"<<endl;
    }
    
}

Measured memory_bytes: 256