akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
// debug
#define d(x) cerr << #x ":" << x << endl;
#define dd(x, y) cerr << "(" #x "," #y "):(" << x << "," << y << ")" << endl;
#define ddd(x, y, z) cerr << "(" #x "," #y "," #z "):(" << x << "," << y << "," << z << ")" << endl;
#define dump(v) cerr<<#v":[ ";for (auto macro_vi:v){cerr<<macro_vi<< " ";}cerr<<"]"<<endl;
#define ddump(v) cerr<<#v":"<<endl;for(auto macro_row:v) {cerr<<"["; for (auto macro__vi:macro_row){cerr<<macro__vi<< " ";}cerr<<"]"<<endl;}
#define damp(m) for(auto macro_pair:m){cerr<< macro_pair.first<<":"<<macro_pair.second<<endl;}
#define dpair(p) cerr << #p":"<<"(" << p.first << "," << p.second << ")" << endl;
// iterate
#define rep(i, n) for (int i = (int)(0); i < (int)(n); i++)
#define all(v) v.begin(), v.end()
// etc
#define chmin(mi, val) mi = min(mi, val);
#define chmax(ma, val) ma = max(ma, val);
using ll = long long;

using namespace std;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    string s;
    cin >> s; 

    int cnt=1;
    int tt = 0;
    char prev = s[0];

    for(int i=0;i<n; i++){
        dd(i,tt)
        if(s[i]==prev){
            tt++;
            prev = s[i];
            continue;
        }
        else{
            cnt++;
            d(s[i])
            tt=0;
            prev = s[i];
            continue;
        }
    }

    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main(){
  	ll N;
  	cin>>N;
  	vector<ll> v(N);
  	unordered_map<ll,ll> mp;
  	ll sum=0;
  	for(ll i=0;i<N;i++){
  		cin>>v[i];
  		sum+=v[i];
  		mp[v[i]]++;
  	}
   ll Q,B,C;
   cin>>Q;
   while(Q--){
   	cin>>B>>C;
   	ll t=mp[B];
   	mp.erase(B);
   	if(mp.find(C)!=mp.end())
   	    mp[C]+=t;
   	else
   	mp[C]=t;
   	sum=sum+(C-B)*t;
   	cout<<sum<<"\n";
   }
}

Measured memory_bytes: 7284
import sys


class Point(object):
    def __init__(self, x, y):
        self.x = x
        self.y = y

    def __eq__(self, other):
        return self.x == other.x and self.y == other.y


def can_move(start, end, time):

    d_x = end.x - start.x
    d_y = end.y - start.y
    if abs(d_x) + abs(d_y) > time:
        return False
    elif abs(d_x) + abs(d_y) == time:
        return True
    else:
        if (abs(d_x) + abs(d_y) - time) % 2 == 0:
            return True
        else:
            return False


if __name__ == "__main__":
    N = int(input())
    prev_point = Point(0, 0)
    prev_time = 0
    for _ in range(N):
        t, x, y = [int(x) for x in input().split(" ")]
        if not can_move(prev_point, Point(x, y), t - prev_time):
            print("No")
            sys.exit(0)
        else:
            prev_time = t
            prev_point = Point(x, y)
    print("Yes")


Measured memory_bytes: 3064
#include <iostream>
#include<string>
#include<time.h>
#include<math.h>
#include<stdlib.h>
#include<map>
using namespace std;


int main() {
	int N, M, ans;
	cin >> N >> M;
	if (N == 1 && M == 1) {
		cout << 0 << endl;
	}
	else if (N == 1 && M != 1) {
		ans = M * (M - 1) / 2;
		cout << ans << endl;
	}
	else if (N != 1 && M == 1) {
		ans = N * (N - 1) / 2;
		cout << ans << endl;
	}
	else {
		ans = (M * (M - 1) / 2)+(N * (N - 1) / 2);
		cout << ans << endl;
	}

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
        using namespace std;
        #define int long long
const int MAX = 1000001;
const int MOD = 1000000007;
   
        signed main() {
          string s;
          cin>>s;
          int ans=0;
          for(int i=0;i<s.size();i++)if(s[i]=='2')ans++;
          cout<<ans;
           return 0;

        }

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <deque>
#include <queue>
#include <array>
#include <set>
#include <map>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cstdint>
#include <cassert>
#include <random>

using namespace std;
using i64 = int64_t;
using i32 = int32_t;
template<class T, class U> void init_n(vector<T>& v, size_t n, U x) 
{ v = vector<T>(n, x); }
template<class T> void init_n(vector<T>& v, size_t n) { init_n(v, n, T()); }
template<class T> void read_n(vector<T>& v, size_t n, size_t o = 0) 
{ v = vector<T>(n+o); for (size_t i=o; i<n+o; ++i) cin >> v[i]; }
template<class T> void read_n(T a[], size_t n, size_t o = 0)
{ for (size_t i=o; i<n+o; ++i) cin >> a[i]; }
template<class T> T iabs(const T& x) { return max(x, -x); }
// #define abs gabs

const i64 mod = 1e9 + 7;
i64 ipow(i64 a, i64 b) {
    i64 x = a, y = 1;
    for (; b > 0; b >>= 1) {
        if (b & 1) (y *= x) %= mod;
        (x *= x) %= mod;
    }
    return y;
}
i64 inv(i64 x) {
    return ipow(x, mod - 2);
}
i64 fact(i64 x) {
    static vector<i64> f;
    if (x >= i64(f.size())) {
        i64 i = f.size();
        f.resize(x + 1);
        for (; i <= x; ++i) {
            f[i] = i == 0 ? 1 : i * f[i - 1] % mod;
        }
    }
    return f[x];
}
i64 perm(i64 n, i64 k) {
    return k <= n ? fact(n) * inv(fact(n - k)) % mod : 0;
}
i64 conb(i64 n, i64 k) {
    return perm(n, k) * inv(fact(k)) % mod;
}

int main() {
    i64 n, k;
    cin >> n >> k;
    vector<i64> a(n);
    for (int i = 0; i < n; ++i) cin >> a[i];
    sort(begin(a), end(a));
 
    i64 y[2] = {};
    for (int j = 0; j < 2; ++j) {
        for (int i = n - 1; i >= k - 1; --i) {
            i64 x = conb(i, k - 1) % mod * (a[i] + mod) % mod;
            (y[j] += x) %= mod;
        }
        reverse(begin(a), end(a));
    }
 
    cout << (y[0] - y[1] + mod) % mod << endl;
    return 0;
}

Measured memory_bytes: 2424
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

    public static void main(String[] args) throws IOException {
        BufferedReader bufferedReader = new BufferedReader(
                new InputStreamReader(System.in));
        int intInputWeek = Integer.parseInt(bufferedReader.readLine());

        // 借金計算
        double totalDebt = calcDebt(100000, intInputWeek);
        System.out.println((int) totalDebt);
    }

    /**
     * 借金計算メソッド（週利0.05%）
     * @param debt 現在の借金
     * @param week 現在の残り週
     * @return 借金額
     */
    private static double calcDebt(double debt, int week) {
        if (week == 0) {
            return debt;
        }
        debt *= 1.05;

        // 1000円未満は切り上げる
        double debtPlus = debt / 1000 - (int) (debt / 1000);
        if (debtPlus > 0)
            debt = debt + 1000 - debtPlus * 1000;

        return calcDebt(debt, --week);
    }

}

Measured memory_bytes: 16864
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <map>
using namespace std;
typedef long long ll;
ll n, m, a, b, ans;
map<ll, ll> mp;

int main()
{
	cin >> n >> m;
	for (ll i = 0; i < n; i++)
	{
		cin >> a >> b;
		mp[a] += b;
	}
	for (auto itr = mp.begin(); itr != mp.end(); ++itr)
	{
		if (m >= itr->second)
		{
			ans += itr->first * itr->second;
			m -= itr->second;
		}
		else
		{
			ans += itr->first * m;
			m = 0;
		}
	}
	cout << ans << endl;
	int www;
	cin >> www;
}

Measured memory_bytes: 6528
#include <iostream>
#include <iomanip>
#include <cmath>
#include <vector>
#include <queue>
#include <limits>
#include <algorithm>
#include <string>
#include <set>
#include <map>
using namespace std;

int main()
{
	int32_t A, B;
	cin >> A >> B;

	int32_t _min = min(A, B);
	int32_t _max = max(A, B);

	for (int32_t K = _min + 1; K < _max; K++) {
		if (abs(A - K) == abs(B - K)) {
			cout << K << endl;
			return 0;
		}
	}
	cout << "IMPOSSIBLE" << endl;

	return 0;
}


Measured memory_bytes: 256
# ロボットのXY座標
_robotXY = []

def RobotMove(dir, amt, stPoint):
    global _robotXY

    isXMove = True

    orgX, orgY = _robotXY
    if dir == "N":
        isXMove = False
        _robotXY[1] += amt
    elif dir == "E":
        _robotXY[0] += amt
    elif dir == "S":
        isXMove = False
        _robotXY[1] -= amt
    elif dir == "W":
        _robotXY[0] -= amt

    # X軸移動
    if isXMove:
        startX = min(orgX, _robotXY[0])
        endX = max(orgX, _robotXY[0])
        for i in range(startX, endX + 1):
            if [i, _robotXY[1]] in stPoint:
                stPoint.remove([i, _robotXY[1]])
    
    # Y軸移動
    else:
        startY = min(orgY, _robotXY[1])
        endY = max(orgY, _robotXY[1])
        for i in range(startY, endY + 1):
            if [_robotXY[0], i] in stPoint:
                stPoint.remove([_robotXY[0], i])



while True:
    _robotXY = [10, 10]

    n = int(input())
    if n == 0:
        break

    # 不思議な宝石の落ちている座標
    stPoint = [list(map(int, input().split())) for _ in range(n)]

    m = int(input())
    for _ in range(m):
        # ロボットを移動・チェック
        dir, amt = input().split()
        RobotMove(dir, int(amt), stPoint)

    if stPoint:
        print("No")
    else:
        print("Yes")


Measured memory_bytes: 5624
import sys
readline = sys.stdin.readline

N = int(readline())

def dfs(num):
    if int(num) > N:
        return 0
    if all(num.count(n) > 0 for n in '753'):
        res = 1
    else:
        res = 0
    for n in '753':
        res += dfs(num + n)
        
    return res


def main():
    print(dfs('0'))

if __name__ == '__main__':
    main()

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
lint minf = -1e18;
signed main() {
  int n;
  cin >> n;
  vector<vector<int>> f(n, vector<int>(10, 0));
  vector<vector<int>> p(n, vector<int>(11, 0));
  for (int i = 0; i < n; i++)
    for (int j = 0; j < 10; j++) cin >> f[i][j];
  for (int i = 0; i < n; i++)
    for (int j = 0; j <= 10; j++) cin >> p[i][j];

  lint ans = minf;
  for (int bit = 1; bit < 1 << 10; bit++) {
    lint sm = 0ll;
    for (int i = 0; i < n; i++) {
      int cn = 0;
      for (int j = 0; j < 10; j++) {
        if (bit >> j & 1) cn += f[i][j];
      }
      sm += p[i][cn];
    }
    ans = max(ans, sm);
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
import math
n,m=map(int,input().split())
b=0
c={}
for a in input().split():
  b+=int(a)
  c[b%m]=c.get(b%m,0)+1
print(sum(map(lambda x:math.factorial(x)//(math.factorial(x-2)*math.factorial(2))if x>1else 0,c.values()))+c.get(0,0))

Measured memory_bytes: 62704
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long
#define vvi vector<vector<int>>
#define vec vector
#define pq priority_queue
#define all(v) (v).begin(), (v).end()
#define uniqueV(x) sort(x.begin(), x.end()); x.erase(unique(x.begin(), x.end()), x.end());
#define rep(i, n) for (int (i) = (0); (i) < (n); ++(i))
#define repp(i, m, n) for (int (i) = (m); (i) < (n); ++(i))
#define debug(x) cerr << #x << ": " << x << endl;
#define debug2(x, y) cerr<<"("<<#x<<", "<<#y<<") = "<<"("<<x<<", "<<y<<")"<<endl;
#define debug3(x, y, z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = "<<"("<<x<<", "<<y<<", "<<z<<")"<<endl;
#define debugB(x, y) cerr<<#x<<": "<<bitset<y>(x) << endl;
#define line() cerr << "---------------" << endl;
 
const int dx[] = {1, -1, 0, 0};
const int dy[] = {0, 0, -1, 1};
const double PI = 3.14159265358979323846;
 
template<typename T>
void printA(vector<T> &printArray, char between = ' ') {
   int paSize = printArray.size();
   for (int i = 0; i < paSize; i++) { cerr << printArray[i] << between;}
   if (between != '\n') {cerr << endl;}
}
 
// ------------------------------------------------------------------------------------------
 
struct edge { int to, cost; };
struct P { 
   int dist, number; 
   bool operator<(const P &p) const {
      return dist < p.dist;
   }
   bool operator>(const P &p) const {
      return dist > p.dist;
   }
};
 
const int INF = 1e8;
int n;
vec<vec<edge>> G;
int d[111];

void printDist() {
   rep (i, n) { printf("%d %d\n", i, d[i]); }
}
 
void dijkstra(int s) {
   fill(d, d + n, INF);
   d[s] = 0;
   priority_queue<P, vec<P>, greater<P>> Q;
   Q.push({0, s});

   while (Q.size()) {
      P p = Q.top(); Q.pop();
      int v = p.number;
      if (d[v] < p.dist) continue;
      for (int i = 0; i < G[v].size(); i++) {
         edge e = G[v][i];
         if (d[e.to] > d[v] + e.cost) {
            d[e.to] = d[v] + e.cost;
            Q.push({d[e.to], e.to});
         }
      }
   }
}
 
int main() {
   // 入力
   cin >> n;
   G = vec<vec<edge>>(n);
   rep (i, n) {
      int u, k;
      cin >> u >> k;
      rep (j, k) {
         int v, c;
         cin >> v >> c;
         G[u].push_back({v, c});
      }
   }
 
   // ダイクストラ法
   dijkstra(0);
 
   // 出力
   printDist();
 
   return 0;
}


Measured memory_bytes: 3288
n = int(input())
p = [list(map(int,input().split())) for _ in range(n)]

a = []
b = []

for i in range(n):
  a.append(p[i][0] - p[i][1])
  b.append(p[i][0] + p[i][1])
  
ans = max(max(a)-min(a),max(b)-min(b))
print(ans)

Measured memory_bytes: 61428
//#include <bits/stdc++.h>
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <stdio.h>
#include <queue>
#include <deque>
#include <set>
#include <stack>
#include <time.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;

#define fi first
#define se second

const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll MOD3 = 1812447359;
const ll INF = 1ll << 62;
const double PI = 2 * asin(1);

void yes() {printf("yes\n");}
void no() {printf("no\n");}
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

int main(){
  int X, Y;
  while (cin >> X >> Y){
    if (X == 0 && Y == 0) return 0;
    if (X > Y) swap(X, Y);
    printf("%d %d\n", X, Y);
  }

  return 0;
}



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

using namespace std;
const long long MOD = 1e18;

vector<pair<long long, long long>> factorize(long long n) {
    vector<pair<long long, long long>> a;

    for (long long i = 2; i * i <= n; i++) {
        if (n % i == 0) {
            int cnt = 0;
            while (n % i == 0) {
                n /= i;
                cnt++;
            }
            a.push_back(make_pair(i, cnt));
        }
    }
    if (n > 1) a.push_back(make_pair(n, 1));
    return a;

}

int main() {
    int x, n;
    cin >> x >> n;
    if (n == 0) {
        cout << x;
        return 0;
    }

    set<int> s;
    for (int i = 0; i < n; i++) {
        int x;
        cin >> x;
        s.insert(x);
    }
    vector<int> missing;
    for (int i = 0; i <= 101; i++) {
        if (s.count(i)) continue;
        missing.push_back(i);
    }

    int ans = missing[0];
    for (int i = 1; i < (int)missing.size(); i++) {
        if (abs(missing[i] - x) < abs(ans - x)) {
            ans = missing[i];
        }
    }
    cout << ans;

    return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define pb push_back
#define MOD 1000000007

typedef long long ll;

std::vector<int> G[100001];
ll memo[100001][2];

ll dfs_visit(int s, int p, bool col)
{
	if(memo[s][col] != -1)
	return memo[s][col];
	ll ans = 1;
	for(auto u : G[s])
	{
		if(u != p)
		{
			if(!col)
			ans = ((ans%MOD) * (((dfs_visit(u, s, col)%MOD) + (dfs_visit(u, s, col ^ 1)%MOD))%MOD))%MOD;
			else ans = ((ans%MOD) * (dfs_visit(u, s, col ^ 1)%MOD))%MOD;	
		}
	}
	memo[s][col] = ans;
	return ans;	
}

int main(void)
{
	std::ios_base::sync_with_stdio(false);
	std::cin.tie(NULL);
	std::cout.tie(NULL);
	memset(memo, -1, sizeof(memo));
	int n;
	std::cin>>n;
	for(int i=0;i<n-1;i++)
	{
		int s,d;
		std::cin>>s>>d;
		G[s].pb(d);
		G[d].pb(s);
	}
	ll ans = ((dfs_visit(1, -1, 0)%MOD) + (dfs_visit(1, -1, 1)%MOD))%MOD;
	std::cout<<ans<<"\n";
	return 0;
}

Measured memory_bytes: 17024
#ifdef LOCAL111
#else
	#define NDEBUG
#endif
#include <bits/stdc++.h>
const int INF = 1e9;
using namespace std;
template<typename T, typename U> ostream& operator<< (ostream& os, const pair<T,U>& p) { cout << '(' << p.first << ' ' << p.second << ')'; return os; }

#define endl '\n'
#define ALL(a)  (a).begin(),(a).end()
#define SZ(a) int((a).size())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define RBP(i,a) for(auto& i : a)
#ifdef LOCAL111
	#define DEBUG(x) cout<<#x<<": "<<(x)<<endl
	template<typename T> void dpite(T a, T b){ for(T ite = a; ite != b; ite++) cout << (ite == a ? "" : " ") << *ite; cout << endl;}
#else
	#define DEBUG(x) true
	template<typename T> void dpite(T a, T b){ return; }
#endif
#define F first
#define S second
#define SNP string::npos
#define WRC(hoge) cout << "Case #" << (hoge)+1 << ": "
#define rangej(a,b,c) ((a) <= (c) and (c) < (b))
#define rrangej(b,c) rangej(0,b,c)
template<typename T> void pite(T a, T b){ for(T ite = a; ite != b; ite++) cout << (ite == a ? "" : " ") << *ite; cout << endl;}
template<typename T> bool chmax(T& a, T b){if(a < b){a = b; return true;} return false;}
template<typename T> bool chmin(T& a, T b){if(a > b){a = b; return true;} return false;}

typedef long long int LL;
typedef unsigned long long ULL;
typedef pair<int,int> P;
typedef pair<LL,LL> LP;

void ios_init(){
	//cout.setf(ios::fixed);
	//cout.precision(12);
#ifdef LOCAL111
	return;
#endif
	ios::sync_with_stdio(false); cin.tie(0);	
}

int main()
{
	ios_init();
	string ss = "CODEFESTIVAL2016";
	string s;
	cin >> s;
	int ans = 0;
	REP(i,16){
		if(s[i] != ss[i]) ans++;
	}
	cout << ans << endl;
	return 0;
}


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

int main() {
  int n,k,ans=0;
  cin >> n >> k;
  vector<ll> v(n),v2(n+1,0);
  r(i,n)cin >> v[i];
  r(i,n)v2[i+1]=v2[i]+v[i];
  r(i,n-k+1){
    if(ans<v2[i+k]-v2[i])ans=v2[i+k]-v2[i];
  }
  ans+=k;
  double ans2=ans;
  ans2/=2;
  printf("%.8lf\n",ans2);
}

Measured memory_bytes: 3328
N,M  =map(int,input().split())

if N==1 and M==1: print(1);exit()
if N==1 and M==2: print(0);exit()
if N==2 and M==1: print(0);exit()
if N==1: print(M-2);exit()
if M==1:print(N-2);exit()
if N==2 or M==2:print(0);exit()
else: print((N-2)*(M-2))

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

#define rep(i, n) for(long long i=0;i<(long long)(n);i++)
#define rep2(i, s, n) for(long long i=(s);i<(long long)(n);i++)
#define repi(i, n) for(int i=0;i<(int)(n);i++)
#define rep2i(i, s, n) for(int i=(s);i<(int)(n);i++)
#define all(v) v.begin(), v.end()

#define deg2rad(deg) (((deg)/360)*2*M_PI)
#define rad2deg(rad) (((rad)/2/M_PI)*360)

using ll = long long;
using ld = long double;
using vll = vector<ll>;
using vvll = vector<vll>;
using P = pair<ll, ll>;
using vi = vector<int>;
using vvi = vector<vi>;

const ll INF = (1LL<<60);
const int INFi = (1<<29);

/*素数判定*/
bool is_prime(ll n){
    if(n==1) return false;
    for(ll i=2;i*i<=n;i++){
        if(n%i==0) return false;
    }
    return true;
}

/*約数列挙*/
vll enum_divisors(ll n){
    vll l;
    for(ll i=1;i*i<=n;i++){
        if(n%i==0){
            l.push_back(i);
            if(n/i != i) l.push_back(n/i);
        }
    }
   sort(all(l));
   return l;
}

/*素因数分解*/
vector<P> prime_factorize(ll n){
    vector<P> l;
    for(ll i=2;i*i<=n;i++){
        if(n%i!=0) continue;
        ll e = 0;
        while(n%i==0){
            e++;
            n /= i;
        }
        l.push_back({i, e});
    }
    if(n!=1) l.push_back({n, 1});
    return l;
}

/*最小公倍数*/
ll lcm(ll a, ll b){
    return a*b/__gcd(a,b);
}

/*最大公約数*/
ll gcd(ll a, ll b){
    return __gcd(a,b);
}

/*組み合わせ(Combination)*/
const ll CMAX = 1010000;
const ll CMOD = 1e9+7;
ll fac[CMAX], finv[CMAX], inv[CMAX];
// テーブルを作る前処理
void combinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (ll i = 2; i < CMAX; i++) {
		fac[i] = fac[i - 1] * i % CMOD;
		inv[i] = CMOD - inv[CMOD%i] * (CMOD / i) % CMOD;
		finv[i] = finv[i - 1] * inv[i] % CMOD;
	}
}
// 二項係数計算
ll comb(ll n, ll k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % CMOD) % CMOD;
}


int main(){

    ll n, k; cin >> n >> k;
    vll a(n);
    rep(i, n) cin >> a[i];

    rep2(i, k, n){
        if(a[i]<=a[i-k]){
            cout << "No" << endl;
        }
        else{
            cout << "Yes" << endl;
        }
    }


    return 0;
}

Measured memory_bytes: 4840
import java.util.Scanner;

public class Main {
	Scanner sc = new Scanner(System.in);

	void run() {
		int N = sc.nextInt();
		int Q = sc.nextInt();
		String ans = "kogakubu10gokan";
		for (int i = 0; i < N; i++) {
			int year = sc.nextInt();
			String name = sc.next();
			if (Q >= year) {
				ans = name;
			}
		}
		System.out.println(ans);
	}

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

Measured memory_bytes: 18232
n, m = map(int, input().split())
ans = [1] + [1]*n

if n == 1:
  print(1)
  exit()

for i in range(m):
    ans[int(input())] = 0
for i in range(n-2, -1, -1):
    if ans[i]==0:
        continue
    ans[i] = (ans[i+1]+ans[i+2])%(10**9 + 7)

print(ans[0])

Measured memory_bytes: 12500
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<int(n);++i)
#define all(a) a.begin(),a.end()
#define lb(s,x) lower_bound(all(s),x)-s.begin()

int main(void){
    int n;
    cin>>n;
    vector<int> a(n),b(n);
    rep(i,n)cin>>a[i];
    rep(i,n)cin>>b[i];

    int res = 0;
    rep(k,29){
        vector<int> bk(n);
        rep(i,n){
            bk[i] = b[i] % (1<<(k+1));
        }
        sort(all(bk));
        int bit = 0;
        rep(i,n){
            int pos[4];
            rep(m,4){
                pos[m] = lb(bk, ((m+1)<<k) - (a[i] % (1<<(k+1))));
            }
            bit ^= (pos[3]-pos[2]+pos[1]-pos[0])%2;
        }
        res |= bit<<k;
    }
    cout<<res<<endl;
    return 0;
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
 
#define rep for(int i = 0;i<n;i++)
const int MOD = 1000000007;
 
int main(){
    int n;cin >> n;
    int h[n][3]; rep{
        for(int j = 0;j<3;j++){
            cin >> h[i][j];
        }
    }
    int dp[n][3] = {};
    for(int i = 0;i<3;i++){
        dp[0][i] = h[0][i];
    }
    for(int i = 1;i<n;i++){
        dp[i][0] = max(dp[i-1][1], dp[i-1][2]) + h[i][0];
        dp[i][1] = max(dp[i-1][0], dp[i-1][2]) + h[i][1];
        dp[i][2] = max(dp[i-1][1], dp[i-1][0]) + h[i][2];
    }
    cout << max(dp[n-1][0], max(dp[n-1][1],dp[n-1][2])) << endl;
}

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

public static class Program {
    static int N;
    static long[]table;
    public static void Main() {
        int n=int.Parse(Console.ReadLine());
        int[]h=Console.ReadLine().Split().Select(int.Parse).ToArray();
        for(int i=0;i<n;i++)h[i]--;
        long[]a=Console.ReadLine().Split().Select(long.Parse).ToArray();

        N=1;
        while(N<n)N*=2;
        table=new long[2*N];
        for(int i=0;i<n;i++){
            Update(h[i],a[i]+Query(0,h[i]));
        }
        Console.WriteLine(table[1]);
    }
    public static void Update(int i, long x){
        i+=N;
        table[i]=x;
        for(i/=2;1<=i;i/=2){
            table[i]=Math.Max(table[2*i],table[2*i+1]);
        }
    }
    public static long Query(int l, int r){
        l+=N; r+=N;
        long ans=0;
        for(;l<r;l/=2,r/=2){
            if(l%2==1)ans=Math.Max(ans,table[l++]);
            if(r%2==1)ans=Math.Max(ans,table[--r]);
        }
        return ans;
    }
}


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

using namespace std;
typedef long long ll;
typedef pair<int,int> P;

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

    ll N; cin >> N;

    ll A[200005];
    ll sum = 0;
    for (int i = 0;i < N;i++){
        cin >> A[i];
        sum += A[i];
    }

    ll ans = sum;
    ll tmp = 0;
    for (int i = 0;i < N;i++){
        tmp += A[i];
        ans = min(ans,abs(sum-tmp-tmp));
    }

    cout << ans << endl;

    return 0;

}

Measured memory_bytes: 1792
#include <iostream>

using namespace std;
int v[100009];
int main()
{
    int n,i,p=0;
    cin>>n;
    v[n+1]=1;
    for(i=1;i<=n;i++)
    {
        cin>>v[i];
        v[i]=v[i]-i;
    }
    for(i=1;i<=n;i++)
    {
        if((v[i]==0)&&(v[i+1]==0))
        {
            p++;
            v[i+1]=1;
        }
        else if(v[i]==0)
            p++;
    }
    cout<<p;
    return 0;
}

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

int main(){
  int N; cin >> N;
  vector<int> a(N);
  rep(i, N) cin >> a[i];
  
  int count = 0;
  int i = 0;
  while(count <= N){
    count++;
    i = a[i] - 1;
    if(i == 1){
      cout << count << endl;
      return 0;
    }
  }
  cout << -1 << endl;
}


Measured memory_bytes: 640
#include<stdio.h>
int serch(int,int,int[]);

int main(){
  int S[100000];
  int t;
  int i,key,n,q,sum=0;

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

  scanf("%d",&q);
  for(i=0;i<q;i++){
    scanf("%d",&t);
    if(serch(n,t,S)==1){
      sum++;
    }
  }
  printf("%d\n",sum);
  return 0;
}

int serch(int n,int key,int S[]){
  int left=0,mid,right=n;

   while(left<right){
     mid=(left+right)/2;

     if(key==S[mid]){
       return 1;
     }
     if(key>S[mid]){
       left=mid+1;
     }
     else if(key<S[mid]){
        right=mid;
       }
   }
     return 0;
}

  



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

#define ll long long
#define mx 100005

int n,m,ii,k;
int ar[mx];
char ch[mx];

int main()
{
    ll a,b,c,d;
    cin>>a>>b>>c>>d;
    ll re=-1e18;
    re=max(re,b*d);
    re=max(re,b*c);
    re=max(re,a*d);
    re=max(re,a*c);
    cout<<re<<endl;

    return 0;
}


Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
int A[10010],B[10010];
int main()
{
	int N;
	cin>>N;
	for(int i=0;i<N;i++)
		cin>>A[i];
	for(int i=0;i<N;i++)
		cin>>B[i];
	long long Asum=0,Bsum=0,Csum=0;
	for(int i=0;i<N;i++)
	{
		Asum+=A[i];
		Bsum+=B[i];
		Csum+=max(0,(B[i]-A[i]+1)/2);
	}
	Bsum-=Asum;
	if(Bsum<0)
		puts("No");
	else if(Bsum==0)
	{
		bool ok=true;
		for(int i=0;i<N;i++)
			if(A[i]!=B[i])
				ok=false;
		if(ok)
			puts("Yes");
		else	puts("No");
	}
	else
	{
		if(Csum>Bsum)
			puts("No");
		else	puts("Yes");
	}
	return 0;
}


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

int main(){
	int a, b, c, k;
	scanf("%d %d %d %d", &a, &b, &c, &k);
	if(a<b) std::swap(a, b);
	if(b<c) std::swap(b, c);
	if(a<b) std::swap(a, b);

	while(k--) a *= 2;
	printf("%d\n", a+b+c);
	return 0;
}



Measured memory_bytes: 3728
from collections import defaultdict

def main():
    N, M = map(int, input().split())
    g = defaultdict(set)

    for _ in range(M):
        a, b = map(int, input().split())
        a -= 1
        b -= 1 
        g[a].add(b)
        g[b].add(a)

    def dfs(u, visited: set):
        stack = [u]
        visited.add(u)
        while stack:
            u = stack.pop()
            for v in g[u]:
                if v not in visited:
                    stack.append(v)
                    visited.add(v)

    count = dict()       
    for u in range(N):
        if u in count:
            continue
        visited = set()
        dfs(u, visited)
        # print(visited)
        count[u] = len(visited)
        for v in visited:
            count[v] = len(visited)

    print(max(count.values()))


if __name__ == '__main__':
    import sys
    sys.setrecursionlimit(10000)
    main()

Measured memory_bytes: 111312
// https://atcoder.jp/contests/abc106/tasks/abc106_b
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i, n) FOR(i, 0, n)
#define REPR(i, n) for (int_fast32_t i = n - 1; i >= 0; i--)
#define FOR(i, s, n) for (int_fast32_t i = (s), i##_len = (n); i < i##_len; ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()
#define DIV(a, b) ((a - 1) / b + 1)

vector<int> a = {105, 135, 165, 189, 195};

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N;
    cin >> N;
    auto it = lower_bound(ALL(a), N + 1);
    cout << distance(a.begin(), it) << endl;
    return 0;
}


Measured memory_bytes: 3568
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define int long long int
#define mod 1000000007
#define string_mod 2549536629329_base_255
#define pb push_back
#define F first
#define S second
#define endl "\n"
#define all(v) v.begin(), v.end()
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
int power(int x, unsigned int y, int p)
{
    int res = 1;
    x = x % p;
    while (y > 0)
    {
        if (y & 1)
            res = (res * x) % p;
        y = y >> 1;
        x = (x * x) % p;
    }
    return res % p;
}
int mp[1000001];
void solve()
{
    int n;
    cin >> n;
    int a[n];

    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
        mp[a[i]]++;
    }
    int ans = 0;
    for (int i = 0; i < n; i++)
    {
        int f = a[i], g = 0;
        for (int j = 1; j * j <= f; j++)
        {
            if (f % j == 0)
            {
                if (j == f && mp[j] > 1)
                    g = 1;
                if (j != f&&mp[j])
                {
                    g = 1;
                }
            }
            if (f % j == 0)
            {
                if (f / j == f && mp[f / j] > 1)
                    g = 1;
                if (f / j != f&&mp[f/j])
                {
                    g = 1;
                }
            }
        }
        
        if (!g)
            ans++;
    }
    cout << ans << endl;
}
int32_t main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int tc;
    tc = 1;
    //cin >> tc;
    while (tc--)
    {
        solve();
    }

    return 0;
}

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

#define rep(i,n) for(int i=0; i<(n); i++)
#define rrep(i,n) for(int i=(n)-1; i>=0; i--)
#define all(X) (X).begin(),(X).end()

using namespace std;
typedef long long int ll;
typedef pair<int,int> pii;

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

template<class A, size_t N, class T> void Fill(A (&a)[N], const T &v){ fill( (T*)a, (T*)(a+N), v ); }

const int INF = 0x3fffffff;


int main(){
	int N, ans=0;
	int a[100005];
	set<int> b[100005];

	cin >> N;
	rep(i,N){
		cin >> a[i];
		a[i]--;
		b[ a[i] ].insert(i);
		if( b[i].count( a[i] ) ) ans++;
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 9984
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<long long> vll;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef pair<int, int> pii;
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define vv(type, c, m, n, i) vector<vector<type>> c(m, vector<type>(n, i))
#define mat(type, c, m, n) vector<vector<type>> c(m, vector<type>(n));for(auto& r:c)for(auto& i:r)cin>>i;
#define rep(i,a,n) for(int i=(a), i##_len=(n); i<i##_len; ++i)
#define rrep(i,a,n) for(int i=(a), i##_len=(n); i>i##_len; --i)
#define each(x,y) for(auto &(x):(y))
#define var(type, ...)type __VA_ARGS__;Scan(__VA_ARGS__);
template<typename T> void Scan(T& t) { cin >> t; }
template<typename First, typename...Rest>void Scan(First& first, Rest&...rest) { cin >> first; Scan(rest...); }
#define vec(type, c, n) vector<type> c(n);for(auto& i:c) cin>>i;
#define len(x) ((int)(x).size())
#define mp make_pair
#define eb emplace_back
#define em emplace
#define pb pop_back
#define fi first
#define se second
#define get(a, i) get<i>(a)
#define bit_count __builtin_popcount
#define mt make_tuple
inline string zero(int a,string s,char c='0'){return string(a-len(s),c)+s;}
inline string zero(int a,int t,char c='0'){return zero(a, to_string(t), c);}
inline string zero(int a,ll t,char c='0'){return zero(a, to_string(t), c);}
#define mini min_element
#define maxi max_element
#define sum accumulate
#define chmax(a,b) if(a<b)a=b
#define chmin(a,b) if(a>b)a=b
template <class T> inline void print(T t){cout << t << '\n';}
template <class H, class... T> inline void print(H h, T... t){cout << h << " ";print(t...);}
ll solve() {
	var(ll, n, m);
	ll ans = 1;
	for (ll i = 1; i * i <= m; ++i) {
		if (m % i)
			continue;
		if (i * n <= m)
			chmax(ans, i);
		if ((m / i) * n <= m)
			chmax(ans, m / i);
	}
	return ans;
}
int main() {
	print(solve());
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cmath>

int main()
{
    int n, k;
    std::cin >> n >> k;
    int answer = k;
    for(int i = 2; i <= n; i++){
        answer = answer * (k-1);
    }
    std::cout << answer << std::endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <vector>
#include <queue>
#include <algorithm>

using namespace std;

//typedef pair<int,int> P;

int main(){
	char s[101];
	scanf("%s",s);

	printf("%c",s[0]);
	printf("%d",strlen(s)-2);
	printf("%c",s[strlen(s)-1]);
	printf("\n");

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define ALL(obj)   (obj).begin(),(obj).end()

#define debug(var)  do{std::cout << __LINE__ << "> " << #var << ": ";view(var);}while(0)
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }

using namespace std;
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;

void Main() {
	int N; cin >> N;
	int res = 0;
	for (int i = 1; i <= N; i += 2) {
		int cnt = 0;
		FOR (j, 1, i + 1) {
			if (i % j == 0) ++cnt;
		}
		if (cnt == 8) ++res;
	}
	cout << res << endl;
}

int main() {
    cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<iostream>
#include<string>
#include<stack>
#include<queue>
#include<vector>
#include<map>
#include<set>
#include<algorithm>
#include<numeric>

#define all(c) c.begin(), c.end()
#define rall(c) c.rbegin(), c.rend()
#define pb(x) push_back(x)
#define eb(x,y) emplace_back(x,y)
#define MOD 1000000007
#define MAX 1000000001
#define INF 1410065408
#define EPS 1e-12
#define DEBUG 0
#define ll long long
#define Pll pair<ll, ll>
#define Pii pair<int, int>
#define rep(n) for(int i=0;i<n;i++)
#define repp(j, n) for(int j=0;j<n;j++)
#define reppp(i, m, n) for(ll i=m;i<=n;i++)
 
using namespace std;
struct edge{int from, to; ll cost;};

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

    ll N;
    cin >> N;
    vector< tuple<double, ll, ll, ll> > ans;
    reppp(h, 1, 3500){
        reppp(n, 1, 3500){
            // okは大きいか正しい, ngは小さすぎ
            ll ok = 3500, ng = 0, w;
            while(ng < ok){
                if((ng + ok)/2 == w) break;
                w = (ng+ok) / 2;
                double diff =  (double)((h*n+n*w+w*h) * N)/(4*h*n*w) - 1.0;
                if(abs(diff) <= EPS){
                    //printf("%lld %lld %lld\n", h, n, w);
                    ans.pb(make_tuple(diff, h, n, w));
                    break;
                }
                if(diff < 0.0){
                    ok = w;
                }else{
                    ng = w+1;
                }
            }
        }
    }
    sort(all(ans));
    printf("%lld %lld %lld\n", get<1>(ans[0]), get<2>(ans[0]), get<3>(ans[0]));
}


Measured memory_bytes: 384
#pragma region macro
#include <bits/stdc++.h>
using i64 = int_fast64_t;
#define repeat(i, a, b) for(int i = (a); (i) < (b); ++(i))
#define rep(i, n) repeat(i, 0, n)

namespace std {
template <typename A, typename B>
string to_string(pair<A, B> p);

string to_string(const string &s) {
    return '"' + s + '"';
}

string to_string(const char *s) {
    return to_string((string)s);
}

string to_string(bool b) {
    return (b ? "true" : "false");
}

string to_string(vector<bool> v) {
    bool first = true;
    string res = "{";
    for(int i = 0; i < static_cast<int>(v.size()); i++) {
        if(!first) {
            res += ", ";
        }
        first = false;
        res += to_string(v[i]);
    }
    res += "}";
    return res;
}

template <size_t N>
string to_string(bitset<N> v) {
    string res = "";
    for(size_t i = 0; i < N; i++) {
        res += static_cast<char>('0' + v[i]);
    }
    return res;
}

template <typename A>
string to_string(A v) {
    bool first = true;
    string res = "{";
    for(const auto &x : v) {
        if(!first) {
            res += ", ";
        }
        first = false;
        res += to_string(x);
    }
    res += "}";
    return res;
}

template <typename A, typename B>
string to_string(pair<A, B> p) {
    return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
};  // namespace std
#pragma endregion

void solve() {
    int A, B, M;
    std::cin >> A >> B >> M;
    std::vector<int> a(A), b(B);
    rep(i, A) std::cin >> a[i];
    rep(i, B) std::cin >> b[i];
    std::vector<std::vector<int>> x(M, std::vector<int>(3));
    rep(i, M) {
        std::cin >> x[i][0] >> x[i][1] >> x[i][2];
        x[i][0]--;
        x[i][1]--;
    }
    std::vector<i64> v;
    rep(i, M) {
        v.emplace_back(a[x[i][0]] + b[x[i][1]] - x[i][2]);
    }
    std::sort(a.begin(), a.end());
    std::sort(b.begin(), b.end());
    v.emplace_back(a[0] + b[0]);
    std::sort(v.begin(), v.end());
    std::cout << v[0] << std::endl;
}

int main() {
    // std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    solve();
    return 0;
}

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

int main() {
    int n,m,k;
    cin >> n >> m >> k;

    int ai = -1;
    long time = 0;
    int nummax = 0;

    vector<int> a(n);
    vector<int> b(m);

    bool flg = true;
    for(int i=0; i<n; i++){
        cin >> a[i];
        if(time + a[i] <= k && flg){
            time += a[i];
            nummax++;
            ai = i;
        }else{
            flg = false;
        }
    }

    int tmp = nummax;
    for(int i=0; i<m; i++){
        cin >> b[i];
        while(time + b[i] > k && ai >= 0){
            time -= a[ai];
            ai--;
            tmp--;
        }
        if(time + b[i] <= k){
            time += b[i];
            tmp++;
        }else{
            break;
        }
        nummax = max(nummax,tmp);
    }
    cout << nummax << endl;
}

Measured memory_bytes: 4828
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <math.h>
#include <algorithm>
#include <string>
#include <string.h>
#include <vector>
#include <functional>
#include <queue>
#include <unordered_set>
#include <climits>

using namespace std;
typedef long long ll;

bool IsMore(ll A[],ll S[], ll N, ll M, int K, ll& sum){
	ll count = 0;
	sum = 0;
	for(int i = 0; i < N; i++){
		int left = A[i];
		int min = 0;
		int max = N;
		int mid;
		while(max - min > 0){
			mid = (max+min)/2;
			if(mid == N){
				min = N;
				continue;
			}
			if(left + A[mid] >= K){
				max = mid;
			}
			else{
				min = mid + 1;
			}
		}
		
		count += N - min;
		sum += A[i] * (N-min) + (min < N ? S[min] : 0);
	}
	sum -= (count-M)*K;
	
	return count >= M;
}

int main()
{
	ll N, M;
	ll A[100000];
	cin >> N >> M;
	for(int i = 0; i < N; i++){
		cin >> A[i];
	}
	sort(A, A+N);
	
	ll S[100000];
	S[N-1] = A[N-1];
	for(int i = N-1; i > 0; i--){
		S[i-1] = S[i] + A[i-1];
	}
	
	int min = 0;
	int max = 200000;
	int mid;
	ll sum;
	// 幸福度がX以上になるような組み合わせがM以上あるような最大のXを二分探索
	while(max - min > 0){
		mid = (max+min+1)/2;
		if(IsMore(A, S, N, M, mid, sum)){
			min = mid;
		}else{
			max = mid - 1;
		}
	}
	
	IsMore(A, S, N, M, max, sum);
	
	cout << sum << endl;
	
	return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <map>
#include <vector>
#include <algorithm>
#include <iostream>
#include <string>
#include <map>
#include <vector>
#include <algorithm>
using namespace std;
#define ll long long
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    vector<ll> a;
    vector<ll> r;
    vector<ll> l;
    ll input, ans;
    cin >> n;
    rep(i, n){
        cin >> input;
        a.push_back(input);
    }
    int j;
    rep(i, n + 1){
        if (i == 0){
            l.push_back(0);
            continue;
        }
        l.push_back(__gcd(l[i - 1], a[i - 1]));
    }
    rep(i, n + 1){
        j = n - i;
        if (i == 0){
            r.push_back(0);
            continue;
        }
        r.push_back(__gcd(r[i - 1], a[j]));
    }
    reverse(r.begin(), r.end());
    /*
    for (auto i = l.begin(); i != l.end(); ++i)
        std::cout << *i << ' ';
    cout << "" << endl;
    for (auto i = r.begin(); i != r.end(); ++i)
        std::cout << *i << ' ';
    cout << "" << endl;
    */
    ans = 0;
    rep(i, n){
        ans = max(ans, __gcd(l[i], r[i + 1]));
    }
    cout << ans << endl;  



    return 0;
}



Measured memory_bytes: 3316
#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 r,g,b;
  cin >> r >> g >> b;
  if ((100*r+10*g+b)% 4 == 0) cout << "YES" << endl;
  else cout << "NO" << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>

using namespace std;

int main() {
    int n;
    string s;
    cin >> s;   n = s.length();
    int ans = 0;
    for (int i = 0; i < n; i++) {
        if (i % 2 == 0 && s[i] == 'p')
            ans--;
        else if (i % 2 && s[i] == 'g')
            ans++;
    }

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

Measured memory_bytes: 3740
#include <iostream>
#include <algorithm>
#include <iomanip>
using namespace std;
using ll = long long;
#define pi 3.1415926
 
 
int main()
{
    ll n;
    cin >> n;
    ll s = 0;
    for(int i = 1; i <= n; i++){
        if(i%3 != 0 && i%5 != 0)
            s = s + i;
        
    }
    cout << s;


}


Measured memory_bytes: 3576
#include<cstdio>
#include<algorithm>
using namespace std;
const int N=880;
int i,j,k,n,m,K,x,y,ans;
int c[N][N];
int bx[4]={1,-1,0,0};
int by[4]={0,0,1,-1};
int dx[N*N],dy[N*N];
char s[N][N];
int main() {
	scanf("%d%d%d",&n,&m,&K);
	for (i=1;i<=n;i++) {
		scanf("%s",s[i]+1);
		for (j=1;j<=m;j++) if (s[i][j]=='S') x=i,y=j;
	}
	i=0;j=1;
	dx[1]=x;dy[1]=y;
	c[x][y]=1;
	while (i<j) {
		i++;
		int dis=c[dx[i]][dy[i]];
		if (dis==K+1) break;
		for (k=0;k<4;k++) {
			int xx=dx[i]+bx[k];
			int yy=dy[i]+by[k];
			if (1<=xx && xx<=n && 1<=yy && yy<=m && !c[xx][yy] && s[xx][yy]!='#') {
				c[xx][yy]=dis+1;
				j++;
				dx[j]=xx;
				dy[j]=yy;
			}
		}
	}
	ans=n*m;
	for (i=1;i<=n;i++)
		for (j=1;j<=m;j++) if (c[i][j]) {
			int t1=min(i-1,n-i);
			int t2=min(j-1,m-j);
			ans=min(ans,(min(t1,t2)+K-1)/K);
		}
	printf("%d\n",ans+1);
}

Measured memory_bytes: 9600
from collections import Counter

N = int(input())
a = [int(i) for i in input().split()]

k, v = list(Counter(a).keys()), list(Counter(a).values())
if len(k) == 3 and k[0] ^ k[1] == k[2] and v[0] == v[1] == v[2] :
    print('Yes')
elif len(k) == 2 and ((k[0] == 0 and v[0] * 2 == v[1]) or (k[1] == 0 and v[1] * 2 == v[0])) :
    print('Yes')
elif len(k) == 1 and k[0] == 0 :
    print('Yes')
else :
    print('No')

Measured memory_bytes: 61248
#include <bits/stdc++.h>
typedef long long int ll;
#define pb push_back
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define MOD 1000000007
#define INF 93193111451418101
using namespace std;

int main() {
  long double n, a, b, c, d;
  cin >> n >> a >> b >> c >> d;
  n -= 1;
  b -= a;
  REP(i, n) {
    long double axis = (double)i * (c + d) / 2.0;
    b < axis ? b = 2 * axis - b : b;
  }
  n -= 1;
  cout << ((n + 1) * c <= b && b <= (n + 1) * d ? "YES" : "NO") << endl;
}


Measured memory_bytes: 256
N = int(input())
a = [int(i) for i in input().split()]

color = []
color2 = []

def rate(a):
    if a < 400:
        if 1 not in color:
            color.append(1)
    elif 400<= a and a<800:
        if 2 not in color:
            color.append(2)
    elif 800<=a and a<1200:
        if 3 not in color:
            color.append(3)
    elif 1200<=a and a<1600:
        if 4 not in color:
            color.append(4)
    elif 1600<=a and a<2000:
        if 5 not in color:
            color.append(5)
    elif 2000 <=a and a<2400:
        if 6 not in color:
            color.append(6)
    elif 2400 <=a and a<2800:
        if 7 not in color:
            color.append(7)
    elif 2800<=a and a<3200:
        if 8 not in color:
            color.append(8)
    elif a>= 3200:
        color2.append(a)

for i in range(N):
    rate(a[i])

max = len(color) + len(color2)

if len(color) == 0:
    print(1,max)
else:
    print(len(color),max)

Measured memory_bytes: 9104
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<algorithm>
#include<cmath>
#include<climits>
#include<string>
#include<set>
#include<map>
#include<iostream>
using namespace std;
#define rep(i,n) for(int i=0;i<((int)(n));i++)
#define reg(i,a,b) for(int i=((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i=((int)(n))-1;i>=0;i--)
#define ireg(i,a,b) for(int i=((int)(b));i>=((int)(a));i--)
typedef long long int lli;
#define fir first
#define sec second
#define IINF INT_MAX
#define LINF LLONG_MAX
#define eprintf(...) fprintf(stderr,__VA_ARGS__)
#define pque(type) priority_queue<type,vector<type>,greater<type> >
#define memst(a,b) memset(a,b,sizeof(a))
#define iter(v,ite) for(auto ite=(v).begin();ite!=(v).end();ite++)
#define mimunum(v,x) distance((v).begin(),lower_bound((v).begin(),(v).end(),x))


typedef pair<lli,int> mp;

int w,h;

mp dat[200005];

int main(void){
	int wn=0,hn=0;
	scanf("%d%d",&w,&h);
	
	pque(mp) que;
	rep(x,w){
		lli a;
		scanf("%lld",&a);
		dat[x] = mp(a,0);
	}
	rep(x,h){
		lli a;
		scanf("%lld",&a);
		dat[x+w] = mp(a,1);
	}
	sort(dat,dat+w+h);
	
	lli s=0;
	//lli bn=((lli)(w+1))*(h+1)-1;
	int x=w+h;
	rep(i,x){
		mp pa=dat[i];
		lli c=pa.fir;
		int t=pa.sec;
		//printf("%lld %d\n",c,t);
		if(t==0){
			w--;
			s += c * (h+1);
		}
		else{
			h--;
			s += c*(w+1);
		}
	}
	
	printf("%lld\n",s);
	
	return 0;
}






Measured memory_bytes: 3328
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
#include <vector>
#include <set>
#include <cstdlib>
#include <deque>

using namespace std;
const long long P = 1000000007;

int main() {
  string s;
  cin >> s;
  int flag = 0;
  if(s[5] == '1') {
    flag = 1;
  }
  if(s[6] != '4' && s[6] != '3' && s[6] != '2' && s[6] != '1') {
    flag = 1;
  }
  if(flag == 1) { 
    cout << "TBD" << endl;
  }else {
    cout << "Heisei" << endl;
  }
  return 0;
}


Measured memory_bytes: 384
def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getList():
    return list(map(int, input().split()))
def getArray(intn):
    return [int(input()) for i in range(intn)]
def input():
    return sys.stdin.readline().rstrip()

from collections import defaultdict, deque, Counter
from sys import exit
import heapq
import math
import fractions
import copy
from itertools import permutations
from operator import mul
from functools import reduce
from bisect import bisect_left, bisect_right

import sys
sys.setrecursionlimit(1000000000)
mod = 10 ** 9 + 7

N = getN()
A = [0] + getList() + [0]

# dp[i + 1] i番目まで抜かさずに行った時の距離の合計
dp = [0]
sta = A[0]
for i in range(1, N + 2):
    dist = abs(A[i] - sta)
    dp.append(dp[-1] + dist)
    sta = A[i]
for i in range(N):
    opt1 = dp[i]
    opt2 = abs(A[i + 2] - A[i])
    opt3 = dp[-1] - dp[i + 2]
    print(opt1 + opt2 + opt3)



Measured memory_bytes: 84584