akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <algorithm>

using namespace std;

#define rep(i,j) REP((i), 0, (j))
#define REP(i,j,k) for(int i=(j);(i)<(k);++i)
#define BW(a,x,b) ((a)<=(x)&&(x)<=(b))
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()

#define F first
#define S second
#define INF 1 << 30

typedef pair<int, int> pi;
typedef pair<int, pi> pii;
typedef vector<int> vi;
typedef queue<int> qi;
typedef long long ll;
typedef int Weight;
struct Edge{
  int src, dst;
  Weight weight;
  Edge(int src, int dst, Weight weight):
    src(src), dst(dst), weight(weight){}
};

bool operator<(const Edge &e, const Edge &f){
  return e.weight != f.weight ? e.weight > f.weight :
    e.src != f.src ? e.src > f.src : e.dst > f.dst;
}

typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

typedef vector<Weight> Array;
typedef vector<Array> Matrix;

bool visit(const Graph &g, int v, vector<int> &order, vector<int> &color){
  color[v] = 1;
  FOR(e, g[v]){
    if(color[e->dst] == 2) continue;
    if(color[e->dst] == 1) return false;
    if(!visit(g, e->dst, order, color)) return false;
  }
  order.push_back(v); color[v] = 2;
  return true;
}

bool topologicalSort(const Graph &g, vector<int> &order){
  int n = g.size();
  vector<int> color(n);
  rep(u, n) if(!color[u] && !visit(g, u, order, color))
    return false;
  reverse(ALL(order));
  return true;
}


int main(){
  int m, n, x, y;
  scanf("%d%d", &m, &n);
  Graph g(m);

  rep(i, n){
    scanf("%d%d", &x, &y); x--; y--;
    g[x].push_back(Edge(x, y, 1));
  }

  vector<int> res;
  if(topologicalSort(g, res)){
    rep(i, res.size())
      printf("%d\n", res[i]+1);
  }

  return 0;
}

Measured memory_bytes: 1216
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <deque>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <iomanip>
#include <bitset>
#include <set>
#include <map>
#include <stdio.h>
#include <numeric>
#include <cstring>

#define rep(i,n) for (int i = 0; i < (n); i++)
#define rep1(i,n) for (int i = 1; i < (n); i++)
#define FOR(i,a,b) for (int i=(a); i < (b); i++)
#define MOD 1000000007 //10^9+7
using namespace std;
using ll = long long;
using PII = pair<int, int>;
const int INF = numeric_limits<int>::max();

// 負の数にも対応した % 演算
long long mod(long long val, long long m) {
    long long res = val % m;
    if (res < 0) res += m;
    return res;
}

//greatest common divisor
long long gcd(ll a, ll b) 
{
    if (a % b == 0) {
        return b;
    } else {
        return gcd(b, a % b);
    }
}

//least common multiple
long long lcm(ll a, ll b)
{
    return a / gcd(a, b) * b ;
}

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


Measured memory_bytes: 3592
#include <algorithm>
#include <cassert>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <utility>
#include <vector>

using namespace std;
using ll = long long;

constexpr ll infl = 10000000000000007LL;
constexpr int inf = 1000000007;

int main() {
    string s;
    cin >> s;
    int x, y;
    cin >> x >> y;
    vector<int> dist[2];
    s += '.';
    dist[0].push_back(0);
    dist[1].push_back(0);
    int begin = 0;
    int dir = 0;
    char cur = s[0];
    for (int i = 1; i < s.size(); ++i) {
        if (s[i] != s[i - 1]) {
            int cnt = i - begin;
            if (cur == 'F') {
                if (begin > 0)
                    dist[dir].push_back(cnt);
                else
                    x -= cnt;
            } else if (cur == 'T' && cnt % 2 == 1) {
                dir ^= 1;
            }
            begin = i;
            cur = s[i];
        }
    }
    vector<vector<bool>> dp_x(dist[0].size(), vector<bool>(24001)), dp_y(dist[1].size(), vector<bool>(24001));

    if (16000 + dist[0][0] >= 0)
        dp_x[0][16000 + dist[0][0]] = true;
    if (16000 - dist[0][0] >= 0)
        dp_x[0][16000 - dist[0][0]] = true;

    for (int i = 1; i < dist[0].size(); ++i) {
        for (int j = 0; j <= 24000; ++j) {
            if (0 <= j - dist[0][i] && j - dist[0][i] <= 24000)
                dp_x[i][j] = dp_x[i][j] || dp_x[i - 1][j - dist[0][i]];
            if (0 <= j + dist[0][i] && j + dist[0][i] <= 24000)
                dp_x[i][j] = dp_x[i][j] || dp_x[i - 1][j + dist[0][i]];
        }
    }

    if (16000 + dist[1][0] >= 0)
        dp_y[0][16000 + dist[1][0]] = true;
    if (16000 - dist[1][0] >= 0)
        dp_y[0][16000 - dist[1][0]] = true;

    for (int i = 1; i < dist[1].size(); ++i) {
        for (int j = 0; j <= 24000; ++j) {
            if (0 <= j - dist[1][i] && j - dist[1][i] <= 24000)
                dp_y[i][j] = dp_y[i][j] || dp_y[i - 1][j - dist[1][i]];
            if (0 <= j + dist[1][i] && j + dist[1][i] <= 24000)
                dp_y[i][j] = dp_y[i][j] || dp_y[i - 1][j + dist[1][i]];
        }
    }

    cout << (dp_x.back()[x + 16000] && dp_y.back()[y + 16000] ? "Yes" : "No") << endl;
    return 0;
}

Measured memory_bytes: 12416
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>

using namespace std;
typedef long long ll;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define REP2(i,n,s) for(int i=(int)s;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin(),ie=(c).end();i!=ie;++i)
#define ALL(c) (c).begin(), (c).end()

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

    ll sum = 0;
    REP(i, pow(2,s.size()-1)) {
        string t = s;
        int cntadd = 0, cntloop = 0, i2 = i;
        while(i2 > 0) {
            if(i2%2 == 1) {
                t.insert(t.begin()+cntadd+cntloop+1, '+');
                cntadd++;
            }
            i2 /= 2;
            cntloop++;
        }
        ll tmp = 0;
        FOR(j, t) {
            if(*j != '+') tmp = tmp*10 + (*j - '0');
            else {
                sum += tmp;
                tmp = 0;
            }
        }
        sum += tmp;
    }

    cout << sum << "\n";
}


Measured memory_bytes: 512
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)
	
	N := ScanText(scanner)
	fmt.Println("ABC" + string(N))
}

func ScanInt(scanner *bufio.Scanner) int {
	scanner.Scan()
	i, e := strconv.Atoi(scanner.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func ScanFloat64(scanner *bufio.Scanner) float64 {
	scanner.Scan()
	f, e := strconv.ParseFloat(scanner.Text(), 64)
	if e != nil {
		panic(e)
	}
	return f
}

func ScanText(scanner *bufio.Scanner) string {
	scanner.Scan()
	return scanner.Text()
}

func Max(a, b int) int {
	if a < b {
		return b
	}
	return a
}

func Min(a, b int) int {
	if a > b {
		return b
	}
	return a
}

func Abs(a int) int {
	if a < 0 {
		a *= -1
	}
	return a
}
 

Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#define rep(i, n) for(int i = 0; i < (n); ++i)
typedef long long ll;
using namespace std;

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

  string s;
  ll k;
  cin >> s >> k;

  char ans = '1';
  for(int i = 0; i < min(k, (ll)s.length()); ++i) {
    if(s[i]!='1') {
      ans = s[i];
      break;
    }
  }
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 256
from collections import Counter

N=int(input())
s=[input() for i in range(N)]
M=int(input())
t=[input() for i in range(M)]

wordlist=list(set(s+t))
cnt=0
ss=Counter(s)
tt=Counter(t)
for i in wordlist:
    buf=ss[i]-tt[i]
    if cnt<buf:
      cnt=buf
      
print(cnt)


Measured memory_bytes: 3316
def main():
    S = input()
    count = {}
    for s in S:
        if not s in count.keys():
            count[s] = 0
        count[s] += 1
    count_sorted = sorted(count.items(), key=lambda x:-x[1])
    if count_sorted[0][1] == 2 and count_sorted[1][1] == 2:
        print("Yes")
    else:
        print("No")
    return


if __name__ == "__main__":
    main()


Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <map>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <numeric>
#include <utility>

#define ALL_OF(x) (x).begin(), (x).end()
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; i++)
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; }

typedef long long ll;
using namespace std;

#define TRACEBACK_NULL 0
#define TRACEBACK_UP 1
#define TRACEBACK_LEFT 2
#define TRACEBACK_LEFTUP ((TRACEBACK_UP) | (TRACEBACK_LEFT))

int main() {
    
    string _s, _t;
    cin >> _s >> _t;

    bool exists_in_s[256] = {};
    bool exists_in_both[256] = {};
    for (char c : _s) exists_in_s[c] = true;
    for (char c : _t) exists_in_both[c] = exists_in_s[c];

    string s, t;
    for (char c : _s) if (exists_in_both[c]) s += c;
    for (char c : _t) if (exists_in_both[c]) t += c;

    int ls = s.size(), lt = t.size();
    vector<vector<int>> dp(ls + 1, vector<int>(lt + 1, 0));
    vector<vector<int>> tb(ls + 1, vector<int>(lt + 1, TRACEBACK_NULL));

    REP (i, ls+1) {
        REP (j, lt+1) {
            char cs = i < ls ? s[i] : '\0';
            char ct = j < lt ? t[j] : '\0';
            if (cs != '\0' && cs == ct) {
                int cand = dp[i][j] + 1;
                if (dp[i+1][j+1] < cand) {
                    dp[i+1][j+1] = cand;
                    tb[i+1][j+1] = TRACEBACK_LEFTUP;
                }
            } else {
                if (cs && dp[i+1][j] < dp[i][j]) {
                    dp[i+1][j] = dp[i][j];
                    tb[i+1][j] = TRACEBACK_UP;
                }
                if (ct && dp[i][j+1] < dp[i][j]) {
                    dp[i][j+1] = dp[i][j];
                    tb[i][j+1] = TRACEBACK_LEFT;
                }
            }
        }
    }

    string ans;
    for (int i = ls, j = lt; tb[i][j] != TRACEBACK_NULL; ) {
        int flag = tb[i][j];
        if (flag & TRACEBACK_LEFT) --j;
        if (flag & TRACEBACK_UP)   --i;
        if (flag == TRACEBACK_LEFTUP) {
            ans += s[i];
        }
    }

    reverse(ALL_OF(ans));
    cout << ans << endl;
    
}

Measured memory_bytes: 70912
#include <bits/stdc++.h>
#include <random>
#include <time.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rep1(i,n) for (int i = 1; i <= (n); ++i)

using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using ull= unsigned long long;
const ll K_MAX=1e5+5;
const ll Lmax=ll(1e18);
const int Nmax=2e5+1;
const int Nd=61;
const int INF=1e5;


int main(){
  string s,t;
  cin>>s>>t;
  cout<<t<<s;
}


Measured memory_bytes: 3624
import java.util.*;
import java.math.*;
public class Main{
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();
		int m=sc.nextInt();
		if(n==m){
			System.out.println("Yes");
		}else{
			System.out.println("No");
		}
	}
}


Measured memory_bytes: 23764
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    int n,k,i,j,x,y;
    cin>>n>>k;
    map<int,int>mp;
    for(i=1;i<=k;i++)
    {
        cin>>x;
        for(j=1;j<=x;j++)
        {
            cin>>y;
            mp[y]++;
        }
    }
    int ans=0;
    for(i=1;i<=n;i++)
    {
        if(mp[i]==0)
            ans++;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
using ll = long long;
const int INF = 2147483647;
// const ll INF = 1000000000000000000LL;
int main() {
	int n;
	cin >> n;
	vector<int> d(n);
	rep(i,n) cin >> d[i];
	int sum=0;
	rep(i,n){
		for(int j=i+1;j<n;j++){
			sum+=d[i]*d[j];
		}
	}
	cout << sum << endl;
	return 0;
}


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

int n,x[1000],y[1000],u[1000],v[1000];

int main(){
  cin >> n;
  for(int i=0;i<n;i++) cin >> x[i] >> y[i];

  // 目的地の座標和の偶奇が一致しているか確かめる
  bool ok = true;
  int p = abs(x[0] + y[0]) % 2;
  for(int i=1;i<n;i++){
    if( p != abs(x[i]+y[i]) % 2 ) ok = false;
  }

  if(ok){
    // 座標変換を行う
    for(int i=0;i<n;i++){
      v[i] = x[i] + y[i];
      u[i] = x[i] - y[i];
    }

    // 2進数 2^30,...4,2,1を用いて目的地の座標和を作成する
    // 腕の長さ(di)を用意 目的地の座標和が偶数->さらに1を足す
    vector<int> d;
    for(int i=30;i>=0;i--) d.push_back(1<<i);
    if( p == 0 ) d.push_back(1);
    cout << d.size() << endl;
    for(int i=0;i<d.size();i++){
      if(i) cout << " ";
      cout << d[i];
    }
    cout << endl;

    // 目的地ごとに大きい方の腕から方向を決める
    for(int i=0;i<n;i++){
      int vp = 0, up = 0;
      int x2 = 0, y2 = 0;
      for(int j=0;j<d.size();j++){
        if(vp <= v[i]){
          if(up <= u[i]){
            cout << "R";
            x2 += d[j];
            vp += d[j];
            up += d[j];
          }else{
            cout << "U";
            y2 += d[j];
            vp += d[j];
            up -= d[j];
          }
        }else{
          if(up <= u[i]){
            cout << "D";
            y2 -= d[j];
            vp -= d[j];
            up += d[j];
          }else{
            cout << "L";
            x2 -= d[j];
            vp -= d[j];
            up -= d[j];
          }
        }
      }
      cout << endl;
    }
  }
  else { cout << -1 << endl; return 0; }
  return 0;
}


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

using namespace std;

int n;
char a[1005];

void dfs(int pos,int maxn){
    if(pos>=n){
        for(int i=0;i<pos;i++){
            printf("%c",a[i]);
        }
        printf("\n");
        return ;
    }
    for(int i=0;i<=maxn+1;i++){
        a[pos]='a'+i;
        pos++;
        dfs(pos,max(maxn,i));
        pos--;
    }
}

int main(){
    scanf("%d",&n);
    a[0]='a';
    dfs(1,0);
    return 0;
}

Measured memory_bytes: 1536
N,W = map(int,input().split())
l = [list(map(int,input().split())) for i in range(N)]
w,v = [list(i) for i in zip(*l)]
INF = 10**9+7
dp = [[INF] * (100001) for i in range(N+1)]
dp[0][0] = 0
for i in range(1,N+1):
    for j in range(100001):
        if j-v[i-1] >= 0:
            dp[i][j] = min(dp[i-1][j],dp[i-1][j-v[i-1]]+w[i-1])
        else:
            dp[i][j] = dp[i-1][j]
ans = 100000
while dp[N][ans] > W:
    ans -= 1
print(ans)

Measured memory_bytes: 149200
import sys
from collections import deque
import numpy as np
import math
sys.setrecursionlimit(10**6)
def S(): return sys.stdin.readline().rstrip()
def SL(): return map(str,sys.stdin.readline().rstrip().split())
def I(): return int(sys.stdin.readline().rstrip())
def IL(): return map(int,sys.stdin.readline().rstrip().split())

ans = 0
def dfs(l,n,m,e):
    if len(l)==n:
        tmp = 0
        for aa,bb,cc,dd in zip(e[0],e[1],e[2],e[3]):
            if l[bb]-l[aa]==cc:
                tmp += dd
        global ans
        ans = max(ans,tmp)
        return
    x = l[-1] if len(l) else 0
    for i in range(x,m):
        dfs(l+[i],n,m,e)

def Main():
    n,m,q = IL()
    a,b,c,d = [0]*q,[0]*q,[0]*q,[0]*q
    for i in range(q):
        a[i],b[i],c[i],d[i] = IL()
        a[i] -= 1
        b[i] -= 1
    e = [a,b,c,d]
    dfs([],n,m,e)
    print(ans)
    return

if __name__=='__main__':
    Main()

Measured memory_bytes: 27148
import sys

n = int(input())
numbers = list(map(int, sys.stdin.readline().split()))

if 1 not in numbers:
    print(-1)
    sys.exit(0)

breaks = 0
current = 1
for i in range(n):
    if numbers[i] == current:
        current += 1
    else:
        breaks += 1
print(breaks)


Measured memory_bytes: 72140
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#define FOR(i,a,b) for (int i=(a),for_##i##_max=(b);i<=(for_##i##_max);++i)
#define RFOR(i,a,b) for (int i=(a),rfor_##i##_min=(b);i>=(rfor_##i##_min);--i)
#define REP(i,n) for (int i=0,rep_##i##_len=(n);i<(rep_##i##_len);++i)
#define RREP(i,n) for (int i=(n)-1;i>=0;--i)

namespace { // Basics

template<typename T>
void chmin(T &x, T y) {
  x = std::min(x, y);
}

template<typename T>
void chmax(T &x, T y) {
  x = std::max(x, y);
}

template<typename T>
__attribute__((unused))
const auto minimum = static_cast<T const &(*)(T const &, T const &)>(std::min);

template<typename T>
__attribute__((unused))
const auto maximum = static_cast<T const &(*)(T const &, T const &)>(std::max);

template<typename T>
int cmp3(T lhs, T rhs) { return (lhs == rhs) ? 0 : (lhs > rhs) ? 1 : -1; }

template<typename T>
__attribute__((unused))
T constexpr infty = std::numeric_limits<T>::max / 3;
template<>
__attribute__((unused))
auto constexpr infty<int> = 1'100'100'100;
template<>
__attribute__((unused))
auto constexpr infty<long long int> = 100'500'400'300'200'100LL;

using lli = long long int;
using ld = long double;

} // namespace

using namespace std;

int main() {
  // cout << fixed << setprecision(10);

  int N, M;
  cin >> N >> M;
  if (N % 2) {
    for (int i = 0, a = 1, b = N; i < M; ++i, ++a, --b) {
      printf("%d %d\n", a, b);
    }
  } else {
    int K = min(M, N/4);
    for (int i = 0, a = 1, b = K*2; i < K; ++i, ++a, --b) {
      printf("%d %d\n", a, b);
    }
    for (int i = K, a = 2*K+1, b = N-1; i < M; ++i, ++a, --b) {
      printf("%d %d\n", a, b);
    }
  }
  return 0;
}


Measured memory_bytes: 3764
import java.math.BigInteger;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.PriorityQueue;
import java.util.Queue;
import java.util.Scanner;
import java.util.Set;

public class Main {

	static Scanner sc = new Scanner(System.in);

	public static void main(String[] args){

		solve_abc159_c();
	}
  
  	public static void solve_abc159_c(){

		Scanner sc = new Scanner(System.in);

		double L = sc.nextDouble();
		
		double ans = L * L * L / 27.0000000000;
		
		System.out.println(String.format("%7f", ans));

		sc.close();

	}
}

Measured memory_bytes: 23252
// IOI 2021
 
#include <bits/stdc++.h>

using namespace std;

#define int ll
#define endl "\n"
#define ends ' '
#define die(x) return cout << x << endl, 0
#define all(v) v.begin(), v.end()
#define sz(x) (int)(x.size())
#define debug(x) cerr << #x << ": " << x << endl
#define debugP(p) cerr << #p << ": {" << p.first << ", " << p.second << '}' << endl
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const ll INF = 1e9;
const int MOD = 1e9 + 7;

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

const int N = 2e5 + 5;

int H[N];

int32_t main() {

	ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	
	int n, a, b, sum = 0; cin >> n >> a >> b;
	for (int i = 0; i < n; i++) cin >> H[i];
	int dw = 0, up = INF;
	while (up - dw > 1) {
		int md = dw + up >> 1;
		int cnt = 0;
		for (int i = 0; i < n; i++) cnt += ((H[i] - min(H[i], md * b)) + (a - b - 1)) / (a - b);
		if (cnt > md) dw = md;
		else up = md;
	}
	cout << up << endl;

	return 0;
}


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

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;

#define F first
#define S second
#define PB push_back
#define MP make_pair
#define what_is(x) cerr << #x << " is " << x << endl;
#define MT make_tuple
#define eb emplace_back
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))

#define REP(i,a,b) for (int i = a; i <= b; i++)
#define FOR(i,n) for (int i=0;i < n ; i++)
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << endl;
	err(++it, args...);
}

int f(int a[],int n, int x){
	int sum=0;
	FOR(i,n)sum+=(a[i]-x)*(a[i]-x);
	return sum;
}

int main(){
	int n;
	cin >> n;
	int a[n];
	int sum=0;
	FOR(i,n){
		cin >> a[i];
		sum+=a[i];
	}
	int avg=sum/n;
	cout << min(f(a,n,avg),f(a,n,avg+1));
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <math.h>
#define fi first
#define se second
#define rep(i,n) for(ll i=0;i<(n);i++)
#define rrep(i,n) for(ll i = 1; i <= (n); ++i)
#define drep(i,n) for(ll i = (n)-1; i >= 0; --i)
#define all(v) v.begin(),v.end()
#define len(x) (ll)(x).length()
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define pb push_back
#define sz(x) (ll)(x).size()
#define v(T) vector<T>
#define vv(T) vector<vector<T>>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
ll gcd(ll a,ll b){if(a%b==0){return b;}else{return(gcd(b,a%b));}}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
const int INF=1e9;
const ll MX = 1e18;
const int MOD=INF+7;
const int di[] = {-1,0,1,0};
const int dj[] = {0,-1,0,1};
const double PI=acos(-1);
 
int main() {
  int n,m;
  cin>>n>>m;
  cout<<n*(n-1)/2+m*(m-1)/2<<endl;
}

Measured memory_bytes: 3620
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
#define mod ((int)1e9+7)
#define lim 1000000000000000007
#define lim1 18446744073709551615  //Unsigned
#define sq(a) ((a)*(a))
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define mms(v,i) memset(v,i,sizeof(v))
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define REP(i,a,b) for (int i = a; i <= b; i++)
#define REPN(i,a,b) for (int i = a; i >= b; i--)
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef pair<int,int> pi;
typedef pair<ll,ll> PL;
typedef pair<ll,int> PLI;
typedef pair<int,ll> PIL;
typedef pair<int,pair<int,int> > pii;
typedef pair<double,double> pdd;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;
ll power(ll a,ll b) {
   ll res=1;
   while(b){
      if(b%2==1) res=(res*a)%mod;
      a=(a*a)%mod;
      b>>=1;
   }
   return res;
}
ll gcdll(ll a,ll b) {
    if (b==0) return a;
    return gcdll(b,a%b);
}
int gcd(int a,int b) {
    if (b==0) return a;
    return gcd(b,a%b);
}

struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};

const int N = (int)2e5+5;
const int M = (int)3e3+5;
const int Q = 301;
const int logN = 19;

void solve() {
    string s;
    cin>>s;
    if(s.back()=='s') {
        s += 'e';
    }
    s += 's';
    cout<<s;
}
int main() {
    //freopen("output.txt","r",stdin);
    //freopen("output.txt","w",stdout);

    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    int T=1;
    //cin>>T;
    REP(TC,1,T) {
        //cout<<"Case #"<<TC<<": ";
        solve();
        cout<<"\n";
    }
}


Measured memory_bytes: 3676
#include<bits/stdc++.h>
#include <array>
using namespace std;
#define rep(i, n) for(int i = 0; i < (n); i++)
using ULL = unsigned long long;
using UL = unsigned;
using LL = long long;

void Solve(){
    UL ans = 0;
    UL a; cin >> a;
    if(65 <= a && a <= 90) ans = 1;
    if(97 <= a && a <= 122) ans = 2;
    cout << ans << endl;
}

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



Measured memory_bytes: 3112
package main

import (
	"fmt"
)

func main() {
	var s string
	var t string
	var count int

	fmt.Scanf("%s", &s)
	fmt.Scanf("%s", &t)

	for i := 0; i < len(s); i++ {
		if s[i] != t[i] {
			count++
		}
	}

	fmt.Printf("%d\n", count)
}

Measured memory_bytes: 4592
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iterator>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <stack>
#include <set>
#include <string>
#include <unordered_map>
#include <vector>
 
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define all(obj) (obj).begin(), (obj).end()
#define bit(n) (1LL << (n))
 
typedef long long ll;

using namespace std;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
 
  int n, m;
  cin>>n>>m;
  
  vector<int> vs;
  vector<char> vc;
  
  string res = string(n, '0');
  
  if(n!=1) {
    res[0]='1';
  }
  
  rep(i,m) {
    int s;
    cin>>s;
    vs.push_back(s);
    
    char c;
    cin>>c;
    vc.push_back(c);
    
    res[s-1]=c;
  }

  rep(i,m) {
    int s=vs[i];
    char c=vc[i];
    if(res[s-1]!=c) {
      cout<<-1;
      return 0;
    }
  }
  
  if(res.length()>1 and res[0]=='0') {
    cout<<-1;
  } else {
    cout<<res;
  }
  
  return 0;
}

Measured memory_bytes: 256
#include <cstdio>

const int MAXN = 1000;

const char s3[3][3] = {
{'a', 'a', 'b'},
{'c', '.', 'b'},
{'c', 'd', 'd'}
};

const char s5[5][5] = {
{'a', 'b', 'b', 'c', 'c'},
{'a', 'z', 'z', '.', 'd'},
{'e', '.', '.', 'y', 'd'},
{'e', '.', '.', 'y', 'f'},
{'g', 'g', 'h', 'h', 'f'}
};

const char s6[6][6] = {
{'a', 'a', '.', 'b', 'b', 'c'},
{'d', '.', 'e', 'e', '.', 'c'},
{'d', 'f', '.', '.', 'g', '.'},
{'.', 'f', '.', '.', 'g', 'l'},
{'h', '.', 'i', 'i', '.', 'l'},
{'h', 'j', 'j', '.', 'k', 'k'}
};

int n; char s[MAXN + 5][MAXN + 5];
void get1(int x1, int y1, int x2, int y2, int n) {
	if( n == 0 ) return ;
	if( n == 6 ) {
		for(int i=0;i<6;i++)
			for(int j=0;j<6;j++)
				s[x1+i][y1+j] = s6[i][j];
	}
	else {
		s[x1][y1] = s[x1+1][y1] = 'a';
		s[x1][y2] = s[x1][y2-1] = 'b';
		s[x2][y1] = s[x2][y1+1] = 'c';
		s[x2][y2] = s[x2-1][y2] = 'd';
		s[x1][y1+1] = s[x1+1][y1+1] = 'e';
		s[x1+1][y2] = s[x1+1][y2-1] = 'f';
		s[x2-1][y1] = s[x2-1][y1+1] = 'g';
		s[x2][y2-1] = s[x2-1][y2-1] = 'h';
		get1(x1 + 2, y1 + 2, x2 - 2, y2 - 2, n - 4);
	}
}


void get2(int x1, int y1, int x2, int y2, int n, int t) {
	if( n == 3 ) {
		s[x1][y1] = s[x1][y1+1] = 'z';
		s[x1+1][y2] = s[x2][y2] = 'y';
		return ;
	}
	else {
		s[x1][y1] = s[x1+1][y1] = ('a' + t);
		s[x2][y1] = s[x2][y1+1] = ('a' + t);
		s[x2][y2] = s[x2-1][y2] = ('a' + t);
		s[x1][y2] = s[x1][y2-1] = ('a' + t);
		get2(x1 + 1, y1 + 1, x2 - 1, y2 - 1, n - 2, t ^ 1);
	}
}

int main() {
	scanf("%d", &n);
	for(int i=0;i<n;i++)
		for(int j=0;j<n;j++)
			s[i][j] = '.';
	if( n == 2 ) puts("-1");
	else if( n == 3 ) {
		for(int i=0;i<3;i++) {
			for(int j=0;j<3;j++)
				printf("%c", s3[i][j]);
			puts("");
		}
	}
	else if( n == 5 ) {
		for(int i=0;i<5;i++) {
			for(int j=0;j<5;j++)
				printf("%c", s5[i][j]);
			puts("");
		}
	}
	else if( n % 2 == 0 ) {
		get1(0, 0, n-1, n-1, n);
		for(int i=0;i<n;i++) {
			for(int j=0;j<n;j++)
				printf("%c", s[i][j]);
			puts("");
		}
	}
	else {
		int p = (n - 1) / 2;
		s[0][0] = s[1][0] = s[p][0] = s[p+1][0] = 'a';
		s[n-1][0] = s[n-1][1] = s[n-1][p] = s[n-1][p+1] = 'a';
		s[n-1][n-1] = s[n-2][n-1] = s[p][n-1] = s[p-1][n-1] = 'a';
		s[0][n-1] = s[0][n-2] = s[0][p] = s[0][p-1] = 'a';
		get2(1, 1, n-2, n-2, n-2, 1);
		for(int i=0;i<n;i++) {
			for(int j=0;j<n;j++)
				printf("%c", s[i][j]);
			puts("");
		}
	}
}

Measured memory_bytes: 2176
#include <bits/stdc++.h> 
#include <chrono>
using namespace std;
 
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
 
 
//typedef
//------------------------------------------
typedef pair<int, int> PII;
typedef long long LL;
typedef pair<LL, LL> PLL;
 
//container util
//------------------------------------------
#define PB emplace_back
#define MP make_pair 
#define SZ(a) int((a).size())
//repetition
//------------------------------------------
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SORT(c) sort((c).begin(),(c).end())
#define ALL(a)  (a).begin(),(a).end()
//constant
//--------------------------------------------
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

const int MAX_N=2e5+3;


const unsigned long long B=1e12+7;


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

    return 0;
}

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

int main(){

  int W,H,x,y,r;
  cin >> W >> H >> x >> y >> r;
  
  if((x+r)<=W)
    if(0<=(x-r))
      if(y+r<=H)
	if((y-r)>=0)
	  cout << "Yes" << endl;
	else
	  cout << "No" << endl;
      else
	cout << "No" << endl;
    else
      cout << "No" << endl;
  else
    cout << "No" << endl;
}

Measured memory_bytes: 1156
#include<stdio.h>
#include<math.h>

int main(){
	double x1=0,x2=0,y1=0,y2=0;
	double tmp1=0,tmp2=0;

	scanf("%lf",&x1);
	scanf("%lf",&y1);
	scanf("%lf",&x2);
	scanf("%lf",&y2);

	if(x2>x1){
		tmp1=x2-x1;
	}else{
		tmp1=x1-x2;
	}
	if(y2>y1){
		tmp2=y2-y1;
	}else{
		tmp2=y1-y2;
	}

	printf("%.8f\n",sqrt(tmp1*tmp1+tmp2*tmp2));
	return 0;
}



Measured memory_bytes: 2736
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization("unroll-loops")
#include <bits/stdc++.h>
using namespace std;
 
//krishrawat
 
 
//----------------------------MACROS-------------------------------------------------
#define pb insert//                                                                 |
#define eb emplace_back//                                                           |
#define ff first//                                                                  |
#define ss second//                                                                 |
typedef long long int ll;//                                                         |
typedef long double ld;//                                                           |
#define all(a) a.begin(), a.end()//                                                 |
#define show(x) cerr << #x << " is " << x << "\n"//                                 |
#define show2(x, y) cerr << #x << " " << #y << " " << x << " " << y << "\n"//       |
typedef vector<ll> vl;//                                                            |
typedef vector<vl> vvl;//                                                           |
typedef pair<ll, ll> pp;//                                                          |
typedef vector<pp> vp;//                                                            |
typedef map<pp, ll> ipi;//                                                          |
typedef map<pp, char> ipc;//                                                        |
typedef map<ll, ll> ii;//                                                           |
typedef set<ll> sl;//                                                               |
typedef multiset<ll> msl;//                                                         |
typedef map<char, ll> ci;//                                                         |
typedef set<pair<ll, ll>> sp;//                                                     |
const ll mod = 1e9 + 7;//                                                           |
const ll N = 2e5 + 1;//                                                             |
//----------------------------------------------------------------------------------

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


//solution
void solve()
{   
    ll n;cin>>n;
    vl v(n);
    for(auto &i:v) cin>>i;
    vl pref(n);
    ll sums=0;
    for(int i=n-1;i>=0;i--){
        sums+=v[i];
        sums%=mod;
        pref[i]=sums;
    }
    ll ans=0;
    for(int i=0;i<n-1;i++){
        ans+=(v[i]*pref[i+1])%mod;
        ans%=mod;
    }
    cout<<ans<<"\n";
}
 
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
    
    ll t; t=1;
    //cin>>t;
    while(t--) solve(); return 0;
}


Measured memory_bytes: 6360
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <queue>
#include <vector>
#include <map>
#include <set>

using namespace std;

typedef pair<int , int> P2;
typedef pair<pair<int , int> , int> P3;
typedef pair<pair<int , int> , pair<int , int> > P4;
#define Fst first
#define Snd second
#define PB(a) push_back(a)
#define MP(a , b) make_pair((a) , (b))
#define M3P(a , b , c) make_pair(make_pair((a) , (b)) , (c))
#define M4P(a , b , c , d) make_pair(make_pair((a) , (b)) , make_pair((c) , (d)))
#define repp(i,a,b) for(int i = (int)(a) ; i < (int)(b) ; ++i)
#define repm(i,a,b) for(int i = (int)(a) ; i > (int)(b) ; --i)
#define repv(t,it,v) for(vector<t>::iterator it = v.begin() ; it != v.end() ; ++it)

int a , b;

int main(){
	scanf("%d%d" , &a , &b);
	printf("%.9f\n" , 1.0 / (1.0 / a + 1.0 / b));
	return 0;
}


Measured memory_bytes: 128
from sys import stdin
def main():
    #入力
    readline=stdin.readline
    n=int(readline())
    s=readline().strip()

    left_left=0
    need_left=0
    for i in range(n):
        if s[i]=="(":
            left_left+=1
        else:
            if left_left>0:
                left_left-=1
            else:
                need_left+=1

    print("("*need_left+s+")"*left_left)

if __name__=="__main__":
    main()

Measured memory_bytes: 3060
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        long N = sc.nextLong();
        long M = sc.nextLong();

        System.out.println(solve(N, M));

        sc.close();
    }

    static long solve(long N, long M) {
        return Math.min(N, M / 2) + (M - Math.min(N, M / 2) * 2) / 4;
    }
}

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

int main()
{

    ll a,b,x,res=0;
    cin >> a >> b >> x;

    if(a%x==0)
        res =(b/x) - (a/x) +1;
    else
        res = (b/x) - (a/x);
              cout << res << endl;
    return 0;
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
#define MOD 1000000007
#define PI (6.28318530718/2.0)
#define ft first
#define sec second
#define ll long long
#define pb push_back
using namespace std;
ll n,dp[2001];
int main()
{
	cin >> n;
	dp[0]=dp[3]=1;
	for(int i=4; i<=n; i++)
	{
		for(int j=3; j<=i; j++) dp[i]=(dp[i]+dp[i-j])%MOD;
	}
	cout << dp[n];
}

Measured memory_bytes: 3636
#include<stdio.h>

int A[1000000], n;

int binarySearch(int key) {
	int left = 0;
	int right = n;
	int mid;
	while(left < right) {
		mid = (left + right) / 2;
		if(A[mid] == key) return 1;
		if(key < A[mid]) right = mid;
		else if(key > A[mid]) left = mid+1; 
	}
	return 0;	
}

int main() {
	int i, q, key, sum = 0;
	
	scanf("%d", &n);
    for(int i = 0; i < n; i++) { 
        scanf("%d", &A[i]);
    }
    
    scanf("%d", &q);
    for(int i = 0; i < q; i++) {
	    scanf("%d", &key);
		if( binarySearch(key)) sum++; 
	}
	printf("%d\n", sum);
	
	return 0;    
}

Measured memory_bytes: 2948
A,B,C,D = map(int,input().split())

def euc(a,b):
    x = a*b
    if(a<b):
        t = b
        b = a
        a = t
    
    r = a%b
    while(r!=0):
        a = b
        b = r
        r = a%b
    
    return int(x/b)

w = euc(C,D)
    
nc = B//C-(A-1)//C
nd = B//D-(A-1)//D
ncd = B//w-(A-1)//w

nb = B - B//C - B//D + B//w
na = (A-1) - (A-1)//C - (A-1)//D + (A-1)//w

n = nc + nd - ncd

print(nb - na)

Measured memory_bytes: 3064
import java.util.*;
public class Main{
	public static void main(String[] args){
    	Scanner sc=new Scanner(System.in);
     	int[] x=new int[4];
      	for(int i=0;i<2;i++){
        	int m=sc.nextInt();
          		x[m]++;
        }
      	for(int i=1;i<=3;i++){
        	if(x[i]==0){
            	System.out.print(i);
              	break;
            }
        }
    }
}

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

#define ll long long int
#define vi vector<int> 
ll prime(int i){

    int j=2;
    for(j=2;j<sqrt(i);j++){
        if(i%j==0)return 0;
        
    }
return 1;    
}




int main() {
  string a;
  cin >> a;
  int n=a.length();
  int i=0,j=n-1,cnt=0;
  for(;i<=j;i++,j--){
      if(a[i]==a[j])
        continue;
      else cnt++;
  }
    cout << cnt;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <math.h>
#include <numeric>
#include <set>
#include <unordered_set>
#include <queue>
#include <boost/math/constants/constants.hpp>
#include <boost/math/common_factor_rt.hpp>

using namespace std;
#define ll long long
#define rep(i, n) for(int i = 0;i < n;i++)
#define FOR(i, n, m) for(int i=n; i<m; ++i)

int main(){
  ll N;
  cin >> N;
  ll A[110];
  
  rep(i, N-1) cin >> A[i];
  
  ll sum = A[0]+A[N-2];
  
  rep(i,N-2){
    sum += min(A[i],A[i+1]);
  }

  cout << sum << endl;
}

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


def solve(N: int, K: int, x: "List[int]"):
    from bisect import bisect
    if 0 in x:
        x.remove(0)
        K -= 1
    if K == 0:
        return 0
    ans = float('inf')
    for l, r in zip(x, x[K-1:]):
        ans = min(ans, abs(r)+r-l)
        ans = min(ans, abs(l)+r-l)
    return ans

# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    x = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    print(solve(N, K, x))

def test():
    import doctest
    doctest.testmod()

if __name__ == '__main__':
    #test()
    main()


Measured memory_bytes: 15524
/*C - Build Stairs*/
#include <bits/stdc++.h>

using namespace std;

int main(){

	int tam;
	int num;
	cin >> tam;
	bool can = true;

	vector <int> arr;

	for (int i = 0; i < tam; ++i){
		
		cin >> num;
		
		if(i != 0){
			if(arr.back() != num){
				arr.push_back(num);
			}
		}
		else{
			arr.push_back(num);
		}

	}

	for (int i = 0; i < arr.size() - 1; ++i)
	{
		if(arr[i] > arr[i+1]){
			arr[i]--;
			if(arr[i] - arr[i+1] > 1){
				can = false;
				break;
			}
		}
	}
 
	for (int i = 0; i < arr.size() - 1; ++i)
	{
		if(arr[i] > arr[i+1]){
			can = false;
			break;
			
		}
	}

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


	return 0;
}

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

YES = "Yes"  # type: str
NO = "No"  # type: str


def solve(N: str):
    s = 0
    for c in N:
        s += int(c)
    print(YES if s % 9 == 0 else NO)
    return


# Generated by 1.1.7.1 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()
    N = next(tokens)  # type: str
    solve(N)

if __name__ == '__main__':
    main()


Measured memory_bytes: 68144
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ll long long
#define rep(i,n) for(ll i=0;i<(n);i++)
#define pll pair<ll,ll>
#define pii pair<int,int>
#define pq priority_queue
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define endl '\n'
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define lb(c,x) distance(c.begin(),lower_bound(all(c),x))
#define ub(c,x) distance(c.begin(),upper_bound(all(c),x))

using namespace std;


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

const ll INF=1e9+7;

int main(){
    ll n;
    cin >> n;
    vector<ll> a(n);
    ll cnt=0;
    rep(i,n){
        cin >> a[i];
        if(a[i]%2==1) cnt++;
    }
    if(cnt%2==0) cout << "YES" << endl;
    else cout << "NO" << endl;
    return 0;
}

Measured memory_bytes: 4024
#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
/* #include <regex> */

using namespace std;

/* g++ -g -fsanitize=address -lasan -std=c++11 -Dfoo_ */

/* freopen("input.txt", "rt", stdin); */
/* freopen("output.txt", "wt", stdout); */

#define ALL(c)          (c).begin(), (c).end()
#define ALLR(c)         (c).rbegin(), (c).rend()
#define FOR(i,a,b)      for (int i=(a); i < (b); ++i)
#define FORR(i,a,b)     for (int i=(a); i > (b); --i)
#define FOR_ALL(i,c)    for (__typeof((c).begin()) i=(c).begin();   \
                             i != (c).end(); ++i)
#define FOR_ALLR(i,c)   for (__typeof((c).rbegin()) i=(c).rbegin(); \
                             i != (c).rend(); ++i)
#define SZ(array)       (sizeof(array)/sizeof(array[0]))
#define lc(x)           (x<<1)     /* 2*x */
#define rc(x)           (x<<1 | 1) /* 2*x+1 */
#define lowbit(x)       (x & (-x)) /* 0b10100 -> 0b100 */

typedef long long       LL;
typedef map<int,int>    MII;
typedef pair<int,int>   PII;
typedef set<int>        SI;
typedef vector<bool>    VB;
typedef vector<double>  VD;
typedef vector<int>     VI;
typedef vector<string>  VS;

/* check if a key is in container C */
template <class C>
inline bool in_(const typename C::key_type& k, const C& A)
{ return A.find(k) != A.end(); }
inline bool in_(const string& s, const string& S)
{ return S.find(s) != string::npos; }

int gcd(const int a, const int b)
{ return b==0 ? a : gcd(b,a%b); }

int main()
{
#ifdef foo_
    freopen("foo", "rt", stdin);
#endif
    ios::sync_with_stdio(false);
    int n;
    while (cin >> n) {
        VI A(n);
        FOR(i,0,n) 
            cin >> A[i];
        VI G[2]; G[0] = G[1] = VI(n);
        G[0][0] = A[0]; G[1][n-1] = A[n-1];
        FOR(i,1,n)
            G[0][i] = gcd(G[0][i-1],A[i]);
        FORR(i,n-2,-1)
            G[1][i] = gcd(G[1][i+1],A[i]);
        int ans = 1;
        FOR(i,1,n-1)
            ans = max(ans, gcd(G[0][i-1],G[1][i+1]));
        if (n > 1)
            ans = max(ans, max(G[0][n-2],G[1][1]));
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 1536
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        #[allow(unused_mut)]
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        a: usize,
        b: usize,
        c: usize,
    }
    let ans = if a == b && b != c {
        "Yes"
    } else if b == c && b != a {
        "Yes"
    } else if c == a && c != b {
        "Yes"
    } else {
        "No"
    };
    println!("{}", ans);
}


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

using namespace std;

#define long long long
#define INF ((long) 2e18)
#define MOD ((long) (1e9 + 7))
#define umap unordered_map

void build(auto &divs, auto &f, long mult)
{
    if (f.empty()) {
        divs.push_back(mult);
        return;
    }
    auto p = *f.begin();
    long k = p.first;
    long count = p.second + 1;
    long pot = 1;
    auto g = f;
    g.erase(k);
    while (count--) {
        build(divs, g, mult * pot);
        pot *= k;
    }
}

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

    long t = 1;
    //cin >> t;

    while (t--) {
        long n;
        cin >> n;

        if (n == 2) {
            puts("1");
            return 0;
        }
        vector<bool> crive(2000100);
        vector<long> primes = {2};
        crive[2] = true;
        for (long k = 3; k < 2e6; k += 2) {
            if (not crive[k]) {
                for (long l = k; l < 2e6; l += k) {
                    crive[l] = true;
                }
                primes.push_back(k);
            }
        }
        umap<long, long> d, f;
        long x = n;
        long y = n-1;
        long ans = 0;
        x = n;
        for (auto &p : primes) {
            if (p > n) break;
            while (x % p == 0) {
                x /= p;
                f[p]++;
            }
            if (x == 1) break;
        }
        if (x > 1) {
            f[x]++;
        }
        vector<long> divs;
        build(divs, f, 1);
        for (auto &div : divs) {
            long x = n;
            if (div == 1) continue;
            while (x % div == 0) x /= div;
            if (x % div == 1) ans++;
        }
        for (auto &p : primes) {
            if (p > n) break;
            while (y % p == 0) {
                y /= p;
                d[p]++;
            }
            if (y == 1) break;
        }
        if (y > 1) {
            d[y]++;
        }
        long mult = 1;
        for (auto &p : d) {
            mult *= (p.second + 1);
        }
        ans += mult - 1;
        printf("%lld\n", ans);
    }
}


Measured memory_bytes: 5564
n = int(input())
x = str(input())


def power(a, n, mod):
    bi=str(format(n,"b")) #2進数
    res=1
    for i in range(len(bi)):
        res=(res*res) %mod
        if bi[i]=="1":
            res=(res*a) %mod
    return res

p = x.count('1')

if p == 0:
    ans = [1]*n
    for i in range(n):
        print(ans[i])
    exit()

if p == 1:
    if x[-1] != '1':
        ans = [1]*n
        for i in range(n):
            if x[i] == '1':
                ans[i] = 0
        ans[-1] = 2
    else:
        ans = [2]*n
        ans[-1] = 0
    for i in range(n):
        print(ans[i])
    exit()

x = list(x)
x.reverse()
temp1 = 0
for i in range(len(x)):
    temp1 += int(x[i])*power(2, i, p+1)
temp1 %= (p+1)

temp2 = 0
for i in range(len(x)):
    temp2 += int(x[i])*power(2, i, p-1)
temp2 %= (p-1)

ans = [0]*n

for i in range(n):
    if x[n-1-i] == '1':
        temp = temp2-power(2, n-1-i, p-1)
        c = p-1
    else:
        temp = temp1+power(2, n-1-i, p+1)
        c = p+1
    temp %= c
    #print(i, temp, c)
    cnt = 1
    while temp != 0:
        x_ = format(temp, 'b')
        c = x_.count('1')
        x_ = list(x_)
        x_.reverse()
        temp = 0
        for j in range(len(x_)):
            temp += int(x_[j])*power(2, j, c)
        temp %= c
        cnt += 1
    #print(i, cnt)
    ans[i] = cnt

for i in range(n):
    print(ans[i])


Measured memory_bytes: 88484
import heapq as hq

N,K=map(int,input().split())
V=list(map(int,input().split()))

ans=0
for i in range(1,min(N,K)+1): #取り出す個数
    for j in range(i+1):
        A=[]
        hq.heapify(A) #左から取り出す個数
        for k in range(j):
            hq.heappush(A,V[k])
        for k in range(i-j):
            hq.heappush(A,V[N-k-1])
        p=min(i,K-i) #しまえる個数
        while p>0:
            if A[0]<0:
                hq.heappop(A)
                p-=1
            else:
                break
        ans=max(sum(A),ans)
print(ans)

Measured memory_bytes: 3188