akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
#define rep(i, n) for(int (i)=0;(i)<(n);(i)++)
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
bool custom1 (pair<int, int> a, pair<int, int> b) {
  return (a.first < b.first);
}
bool custom2(pair<int, int> a, pair<int, int> b) {
  return (a.second < b.second);
}

const int MAX = 200005;
const long long MOD = 1000000007;
const long long MODMOD = 998244353;
const double PI = acos(-1);

long long fac[MAX], finv[MAX], inv[MAX];

void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

long long gcd(long long a, long long b) {
  if(a % b == 0) return b;
  else return gcd(b, a % b);
}
int main() {
  int a, b, m;
  cin >> a >> b >> m;
  vector<int> aa(a);
  vector<int> bb(b);
  rep(i, a) cin >> aa[i];
  rep(i, b) cin >> bb[i];
  int ans = INT_MAX;
  rep(i, m) {
    int x, y, c;
    cin >> x >> y >> c;
    x--;y--;
    chmin(ans, aa[x] + bb[y] - c);
  }
  chmin(ans, *min_element(aa.begin(), aa.end())+*min_element(bb.begin(), bb.end()));
  cout << ans << endl;
}


Measured memory_bytes: 1024
import math
from collections import defaultdict

N = int(input())

d = defaultdict(int)

def division(n,d):
    flag = True
    tmp = n // 2 + 1
    for num in range(2, tmp):
        while n % num == 0:
            flag = False
            n //= num
            d[num] += 1

    if flag:
        d[n] += 1

    return

for n in range(2,N+1):
    division(n,d)

ans = 1
for i in d.values():
    ans *= (i+1)

print(ans%(10**9+7))



Measured memory_bytes: 3316
#include<iostream>
#include<vector>
#include<string>
#include<array>
#include<cmath>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<numeric>
#include<iomanip>
#include<utility>
using namespace std;
#define INF 1000000005

bool isprime(int num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false; // 偶数はあらかじめ除く

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            // 素数ではない
            return false;
        }
    }

    // 素数である
    return true;
}



int main()
{
int  q;
std::cin >> q;
int a[100001];
std::vector<pair<int , int>> p;
a[0] = 0;
for(int i = 1; i < 100001; i++){
    a[i] = a[i - 1] + (isprime(i) && isprime((i + 1)/2));
}
for(int i = 0; i < q; i++){
    int l,r;
    std::cin >> l >> r;
    pair<int,int> temp = make_pair(l,r);
    p.push_back(temp);
}

for(int i = 0; i < q; i++){
    int l = p[i].first;
    int r = p[i].second;
    int sum = a[r] - a[l - 1];
    std::cout << sum << std::endl;
}


return 0;
}

Measured memory_bytes: 1908
import logging

logging.basicConfig(level=logging.INFO, format="%(message)s")
#logging.disable(logging.CRITICAL)

def main():
    N, D = map(int, input().split())
    logging.info("Hello!")

    print(-1 * ((-1 * N) // (D * 2 + 1)))
    
    
if __name__ == "__main__":
    main()


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

int main(){
    ll n;
    cin >> n;
    ll a[n];
    for(ll i=0;i<n;i++) cin >> a[i];
    if(n==2){
        cout << abs(a[1]-a[0]) << endl;
        return 0;
    }
    ll dp[n];
    dp[0]=0;
    dp[1]=abs(a[1]-a[0]);
    for(ll i=2;i<n;i++){
        dp[i]=min(dp[i-1]+abs(a[i]-a[i-1]),dp[i-2]+abs(a[i]-a[i-2]));
    }
    cout << dp[n-1] << endl;
    return 0;
}


Measured memory_bytes: 5064
#include <stdio.h>
#include <math.h>
int main()
{
    int h, w, n, i;
    scanf("%d %d %d", &h, &w, &n);
    for(i = 1; i <= n; i++)
    {
        if(h*i >= n || w*i >= n)
        {
            printf("%d\n", i);
            break;
        }
    }
    return 0;
}


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

// マクロ
// forループ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=(a);i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=(a);i>=(ll)(b);i--)
// xにはvectorなどのコンテナ
#define ALL(x) (x)begin(),(x).end()
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
// 出力
#define PRINT(x) cout<<(x)<<endl
#define PRINTA(x,n) REP(i,n)PRINT(x[i])
// 定数
#define INF 1000000000000 // 10^12
#define MOD 1000000007 // 10^9+7
// 略記
#define PB push_back
#define MP make_pair

const int MAX_N = 100000, MAX_Q = 50000;

int n, S[MAX_N], q, T[MAX_Q];

int main() {
    cin >> n;
    REP(i, n) cin >> S[i];
    cin >> q;
    REP(i, q) cin >> T[i];

    sort(S, S + n);
    int C = 0;

    REP(i, q) {
        if (lower_bound(S, S + n, T[i] + 1) - lower_bound(S, S + n, T[i])) C++;
    }
    PRINT(C);
    return 0;
}


Measured memory_bytes: 3740
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#include <sstream>
#include <iomanip>
#define rep(i,n) for(int i = 0; i < n; i++)
#define rep1(i,n) for(int i = 1; i <= n; i++)
#define co(x) cout << x <<endl
#define cs(x) cout << x <<" "
typedef long long ll;

using namespace std;

int main()
{
	int W, a, b;
	cin >> W >> a >> b;
	if (a + W < b)co(b - (a + W));
	else if (b + W < a)co(a - (b + W));
	else co(0);
	return 0;
}


Measured memory_bytes: 256
import           Control.Monad

main :: IO ()
main = do
    n  <- fmap read getLine :: IO Int
    vs <- replicateM n $ fmap words getLine :: IO [[String]]
    print $ solve vs

solve :: [[String]] -> Double
solve vs = sum $ map exchange vs

exchange :: [String] -> Double
exchange (x : u : _) =
    let y = read x :: Double in if u == "JPY" then y else y * 380000
exchange _ = 0


Measured memory_bytes: 636
use petgraph::unionfind::UnionFind;
use petgraph::{algo::dijkstra, Graph};
use proconio::input;
use std::collections::HashMap;

fn main() {
    input! {
        h: usize,
        w: usize,
        ch: usize,
        cw: usize,
        dh: usize,
        dw: usize,
        s: [String; h],
    }
    let s: Vec<Vec<_>> = s.iter().map(|row| row.chars().collect()).collect();
    let mut uf = UnionFind::new(h * w);
    let flatten = |hi, wi| hi * w + wi;
    for (i, row) in s.iter().enumerate() {
        for (j, &square) in row.iter().enumerate() {
            if square == '#' {
                continue;
            }
            if j > 0 && s[i][j - 1] == '.' {
                uf.union(flatten(i, j), flatten(i, j - 1)); // left
            }
            if i > 0 && s[i - 1][j] == '.' {
                uf.union(flatten(i, j), flatten(i - 1, j)); // up
            }
            if j < w - 1 && s[i][j + 1] == '.' {
                uf.union(flatten(i, j), flatten(i, j + 1)); // right
            }
            if i < h - 1 && s[i + 1][j] == '.' {
                uf.union(flatten(i, j), flatten(i + 1, j)); // down
            }
        }
    }
    let mut g = Graph::<_, _, _>::new_undirected();
    let mut map = HashMap::new();
    for (i, row) in s.iter().enumerate() {
        for (j, &square) in row.iter().enumerate() {
            if square == '#' {
                continue;
            }
            for k in 0..5 {
                for l in 0..5 {
                    if i + k < 2
                        || j + l < 2
                        || i + k >= h + 2
                        || j + l >= w + 2
                        || s[i + k - 2][j + l - 2] == '#'
                    {
                        continue;
                    }
                    let &mut current = map
                        .entry(uf.find(flatten(i, j)))
                        .or_insert_with(|| g.add_node(0));
                    let &mut jump = map
                        .entry(uf.find(flatten(i + k - 2, j + l - 2)))
                        .or_insert_with(|| g.add_node(0));
                    if s[i + k - 2][j + l - 2] == '.'
                        && uf.find(flatten(i, j)) != uf.find(flatten(i + k - 2, j + l - 2))
                        && g.find_edge(current, jump) == None
                    {
                        g.add_edge(current, jump, 1);
                    }
                }
            }
        }
    }
    let &mut from = map
        .entry(uf.find(flatten(ch - 1, cw - 1)))
        .or_insert_with(|| g.add_node(0));
    let &mut to = map
        .entry(uf.find(flatten(dh - 1, dw - 1)))
        .or_insert_with(|| g.add_node(0));
    if let Some(d) = dijkstra(&g, from, Some(to), |e| *e.weight()).get(&to) {
        println!("{}", d);
    } else {
        println!("-1");
    }
}


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


int main() {
  int A, B, M, ans;
  long int dmin, amin, bmin;
  cin >> A >> B >> M;
  vector<int> a(A), b(B), x(M), y(M), c(M);
  
  for(int i = 0;i < A;i++){
    cin >> a.at(i);
  }
  for(int i = 0;i < B;i++){
    cin >> b.at(i);
  }
  for(int i = 0;i < M;i++){
    cin >> x.at(i);
    cin >> y.at(i);
    cin >> c.at(i);
  }

  ///////////////////////////
  dmin = 9999999999999;
  for(int i = 0;i < M;i++){
    if(a.at(x.at(i) - 1) + b.at(y.at(i) - 1) - c.at(i) < dmin){
      dmin = a.at(x.at(i) - 1) + b.at(y.at(i) - 1) - c.at(i);
    }
  }
  
  amin = 99999999999999999;
  for(int i = 0;i < A;i++){
    if(a.at(i) < amin){
      amin = a.at(i);
    }
  }
  
  bmin = 99999999999999999;
  for(int i = 0;i < B;i++){
    if(b.at(i) < bmin){
      bmin = b.at(i);
    }
  }
  
  ans = amin + bmin;
  if(ans > dmin){
    ans = dmin;
  }
  
  cout << ans << endl;
 
}

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

using namespace std;

template<class T>
ostream& operator<<(ostream& os, const vector<T> &vec){
    os << "[";
    for(int i=0;i<vec.size();i++){
        os << (i==0?"":" ") << vec[i];
    }
    os <<  "]";
    return os;
}


long long saiki(int now, vector<bool> plus, string &s){
    int m = plus.size();
    if(now == m){
        long long sumx = 0;
        long long t = s[0]-'0';
        for(int i=0;i<m;i++){
            if(plus[i]){
                sumx += t;
                t = s[i+1]-'0';
            }
            else{
                t = t * 10 + s[i+1]-'0';
            }
        }
        sumx += t;
        return sumx;
    }

    long long ans = 0;
    plus[now] = true;
    ans += saiki(now+1, plus, s);
    plus[now] = false;
    ans += saiki(now+1, plus, s);

    return ans;
}
int main(){
    string s;
    cin >> s;
    int n = s.size();
    vector<bool> plus(n-1);
    cout << saiki(0, plus, s) << endl;
    return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.math.BigDecimal;
import java.math.MathContext;
import java.util.StringTokenizer;

public class Main {

	static long expo(long base, long exp) {
		long t = 1L;
		while (exp > 0) {
			if (exp % 2 != 0)
				t = (t * base);

			base = (base * base);
			exp /= 2;
		}
		return t;
	}

	static int calcAngle(int h, int m) {

		int hour_angle = (int) (0.5 * (h * 60 + m));
		int minute_angle = (int) (6 * m);

		int angle = Math.abs(hour_angle - minute_angle);

		angle = Math.min(360 - angle, angle);

		return angle;
	}

	public static void main(String args[]) throws Exception {
		MyScanner sc = new MyScanner();
		int a = sc.nextInt();
		int b = sc.nextInt();
		int h = sc.nextInt();
		int m = sc.nextInt();
		double ans = 0.0;
		double pi = 3.14159265358979323846264338327950;
		//int angle = calcAngle(h, m);
		
		double rad = pi * 2 * ((double)h / 12.0 + ((double)m / 60.0) / 12.0 - (double)m / 60.0);
		
		
		ans = (double)((long)(a * a) + (long)(b * b)) - (double)((2.0 * a * b) * Math.cos(rad));
		/*BigDecimal br = new BigDecimal(Double.toString(ans));
		br = br.sqrt(new MathContext(20));*/
		System.out.println(Math.sqrt(ans));
	}

	public static class MyScanner {
		BufferedReader br;
		StringTokenizer st;

		public MyScanner() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		String next() {
			while (st == null || !st.hasMoreElements()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
			return st.nextToken();
		}

		int nextInt() {
			return Integer.parseInt(next());
		}

		long nextLong() {
			return Long.parseLong(next());
		}

		double nextDouble() {
			return Double.parseDouble(next());
		}

		String nextLine() {
			String str = "";
			try {
				str = br.readLine();
			} catch (IOException e) {
				e.printStackTrace();
			}
			return str;
		}
	}
}

Measured memory_bytes: 33252
#include "bits/stdc++.h"
using namespace std;
string S;
bool ok(string t)
{
	for(int i=0;i<t.size();i++)
	{
		if(t[i]!='A'&&t[i]!='C'&&t[i]!='G'&&t[i]!='T')
		{
			return false;
		}
	}
	return true;
}
int main()
{
	cin>>S;
	int ans=0;
	for(int len=0;len<=S.size();len++)
	{
		for(int i=0;i<=S.size()-len;i++)
		{
			string t=S.substr(i,len); 
			if(ok(t))
			{
				ans=max(ans,len);
			}
		}
	}
	cout<<ans<<endl;
	return 0;
}
/*
ACGTAGCTAAAACCCGTAGTC
Output:21

POPPOPOPOPOHHHHHQQQWQ
Output:0
*/


Measured memory_bytes: 256
import math
n,k = map(int,input().split())
a = list(map(int,input().split()))

i_1 = a.index(1)

ans = 9999999999

left = len(a[:i_1])
right = len(a[i_1:])

for i in range(k):
    x = left  - i
    y = right - (k-i)
    
    if x < 0 or y < 0:
        continue
    
    count = 1 + math.ceil(x/(k - 1)) + math.ceil(y/(k - 1))
    ans = min(ans,count)

print(ans)

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


int main() {
    int n;
    cin >> n;
    int count = 0;
    for (int i = 1; i <= n; i++) {
        int num;
        cin >> num;
        if (i != num) count++;
    }

    if (count == 0 || count == 2) cout << "YES" << endl;
    else cout << "NO" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = ll(1e12);
const ll mod = ll(1e9) + 1;
#define rep0(i,n) for(ll (i) = 0; (i) < (n); ++(i))
#define rrep0(i,n) for(ll (i) = (n) - 1; (i) >= 0; --(i))
#define rep1(i,n) for(ll (i) = 1; (i) <= (n); ++(i))
#define rrep1(i,n) for(ll (i) = (n); (i) >= 1; --(i))
#define nfor(i,a,b) for(ll (i) = (a); (i) < (b); ++(i))
#define pf(x) cout << (x) << endl
#define all(x) (x).begin(),(x).end()

ll gcd(ll a,ll b){
    if(a < b)swap(a, b);
    if(b == 0) return a;
    return gcd(b,a%b);
}

ll lcm(ll a,ll b){
    ll g = gcd(a,b);
    return a / g * b;
}

ll factorial(ll n){
    ll t = 1;
    rep1(i, n){
        t *= i;
        t %= mod;
    }
    return t;
}

ll power(ll a, ll b){
    a %= mod;
    if(b == 0){
        return 1;
    }
    ll ans = power(a, b / 2);
    ans = ans * ans % mod;
    if(b % 2 == 1){
        ans = ans * a % mod;
    }
    return ans;
}

ll combination(ll a, ll b){
    if((a == b) || (b == 0)){
        return 1;
    }
    if(a < b) return 0;
    ll ans = 1;
    for(ll i = 0; i < b; i++) {
        ans *= (a - i);
        ans %= mod;
        ans *= power(i + 1, mod - 2);
        ans %= mod;
    }
    return ans;
}

int main(){
    ll n;
    cin >> n;
    vector<ll> a(n + 1,0),ans(n + 1,0);
    rep1(i, n)cin >> a[i];
    rrep1(i, n){
        ll cnt = 0;
        for (ll j = i; j <= n; j += i)cnt += ans[j];
        if(cnt % 2 != a[i])++ans[i];
    }
    ll cnt = 0;
    rep0(i, n + 1)if(ans[i])++cnt;
    pf(cnt);
    rep1(i, n)if(ans[i])cout << i << " ";
    return 0;
}


Measured memory_bytes: 3968
k = int(input())
n = 500
if k <= n:
  print(k)
  l = list(range(1,k+1)) + list(range(1,k+1)) 
  for i in range(k):
    a = [str(x) for x in l[i:i+k]]  
    print(" ".join(a))
else:
  print(n)
  for i in range(n):
    a = [ str(1+(i+j)%n+n*(i%2 == 0 and 1+(i+j)%n+n <= k)) for j in range(n)]
    print(" ".join(a))

Measured memory_bytes: 3956
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cstring>
#include <queue>
#include <vector>
#include <functional>
#include <map>
#include <set>
#include <cmath>
#include <string>
#define SIZE 200005
#define INF 1000000005LL

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

int n;
int K;

int main()
{
	scanf("%d %d",&n,&K);
	int a;
	for(int i=0;i<n;i++){
		scanf("%d",&a);
	}
	if((n-1)%(K-1)==0)printf("%d\n",(n-1)/(K-1));
	else printf("%d\n",(n-1)/(K-1) +1);
	return 0;
}


Measured memory_bytes: 128
//Author : Vipul Sharma

// LIBRARIES
#include <bits/stdc++.h>

// MACROS
#define rep(i, a, b) for (i = a; i < b; i++)
#define itrep(at) for (auto it = at.begin(); it != at.end(); it++)
#define ll long long int
#define ld long double
#define pb push_back
#define w(t) while (t--)
#define booster                       \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);
#define mod 1000000007
#define endl "\n"
#define deb1(x) cout << #x << " : " << x << endl;
#define deb2(x, y) cout << #x << " : " << x << "\t" << #y << " : " << y << endl;
#define deb3(x, y, z) cout << #x << " : " << x << "\t" << #y << " : " << y << "\t" << #z << " : " << z << endl;
#define deb4(x, y, z, w) cout << #x << " : " << x << "\t" << #y << " : " << y << "\t" << #z << " : " << z << "\t" << #w << " : " << w << endl;
#define deb5(a, b, c, d, e) cout << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << endl;
#define deb6(a, b, c, d, e, f) cout << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << " | " << #f << ": " << f << endl;

using namespace std;
long long cost = 1e18;
// FUNCTIONS
ll power(ll a, ll n)
{
    ll res = 1;
    while (n)
    {
        if (n & 1)
        {
            res *= a;
            n--;
        }
        else
        {
            a *= a;
            n >>= 1;
        }
    }
    return res;
}

struct cmp
{

    bool operator()(const pair<int, int> &a, const pair<int, int> &b)
    {
        int l1 = a.second - a.first + 1;
        int l2 = b.second - b.first + 1;
        if (l1 == l2)
            return a.first < b.first;
        return l1 > l2;
    }
};

//MAIN
int main()
{
    booster;
    ll k;
    cin>>k;
    string s;
    cin>>s;
    ll l=s.length();
    if(l<=k) cout<<s<<endl;
    else
    {
    	string res=s.substr(0,k);
    	res+="...";
    	cout<<res<<endl;
	}
    
    return 0;
}

Measured memory_bytes: 3652
#include<iostream>
#include<string>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<tuple>
#include<vector>
#include<map>
#include<numeric>
#include<limits>
#include<type_traits>
using namespace std;

int main(void){
  //入力
  long long int N;
  vector<long long int > a;
  vector<bool > b;
  cin >> N;
  for(int i = 0; i < N; i++){
    long long int temp;
    cin >> temp;
    a.push_back(temp);
    b.push_back(false);
  }

  //大きい方からgreedyに考えていく．
  //大きい方から埋めていって，埋められなくなったらbreak;
  for(int i = N - 1; i >= 0; i--){
    long long int sum = 0;
    // 数値がN/2より大きい場合:1,0をそのまま反映
    if(i > N / 2){
      if(a[i] == 1){
        b[i] = true;
      }
      else{
        b[i] = false;
      }
    }
    //そうでない場合: 割った数まで掛け算して調べて足していく．
    else{
      for(int j = 1; j <= N / (i + 1); j++){
        if(j*(i+1) <= N){
          if(b[j*(i+1) - 1]){
            sum++;
          }
        }
      }
      //あまりが一緒の時 0
      if(sum%2 == a[i]){
        b[i] = false;
      }
      //あまりが違う時 1
      else{
        b[i] = true;
      }
    }
  }
  long long int count = 0;
  for(int i = 0; i < N; i++){
    if(b[i]){
      count++;
    }
  }
  cout << count << endl;
  for(int i = 0; i < N; i++){
    if(b[i]){
      cout << i + 1 << " ";
    }
  }
  return 0;
}


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

typedef long long ll;
ll const mod = 1e9+7;

#define p_ary(ary,a,b,i) do { cout << "["; for (int (i) = (a);(i) < (b);++(i)) cout << ary[(i)] << ((b)-1 == (i) ? "" : ", "); cout << "]\n"; } while(0)
#define p_map(map,it) do {cout << "{";for (auto (it) = map.begin();;++(it)) {if ((it) == map.end()) {cout << "}\n";break;}else cout << "" << (it)->first << "=>" << (it)->second << ", ";}}while(0)

int rec(int s,int i,int n,vector<int>& dp,vector<vector<int>>& a) {
    if (dp[s] > -1) return dp[s];
    dp[s] = 0;
    for (int j = 0;j < n;++j) if (((s>>j)&1) && a[i][j]) {
        dp[s] += rec(s^(1<<j),i-1,n,dp,a);
        dp[s] %= mod;
    }
    return dp[s];
}

int main() {
    int n;
    cin >> n;
    vector<int> dp(1<<n,-1);
    vector<vector<int>> a(n,vector<int>(n));
    for (int i = 0;i < n;++i) for (int j = 0;j < n;++j) cin >> a[i][j];
    dp[0] = 1;
    cout << rec((1<<n)-1,n-1,n,dp,a) << endl;
    return 0;
}

Measured memory_bytes: 8448
use std::io;

fn main() {
	let mut buf = String::new();
	io::stdin().read_line(&mut buf).expect("");
	let s = buf.trim().chars().collect::<Vec<char>>();
	let t = format!("{}{}{}", s[0], s.len() - 2, s[s.len() - 1]);
	println!("{}", t);
}

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

int main () {
  int N , D ;
  cin >> N >> D ;
  int ans ;
  cin >> ans ;
  
  for(int i = 0 ; i < N ; i++ ) {
    int a ;
    cin >> a ;
    ans += ( D - 1 ) / a + 1 ;
  }
  
  cout << ans << endl ;
  
}

Measured memory_bytes: 256
import sys
import numpy as np
def proc(C, L, R, Order, N, Q):
    pl = pr = 0
    ans = 0
    A = np.zeros(N+1, dtype=np.int32)
    Ans = np.zeros(Q, dtype=np.int32)
    for idx_LR in Order:
        l = L[idx_LR]
        r = R[idx_LR]
        while pr < r:
            pr += 1
            c = C[pr]
            if A[c] == 0:
                ans += 1
            A[c] += 1
        while pl > l:
            pl -= 1
            c = C[pl]
            if A[c] == 0:
                ans += 1
            A[c] += 1
        while pr > r:
            c = C[pr]
            A[c] -= 1
            if A[c] == 0:
                ans -= 1
            pr -= 1
        while pl < l:
            c = C[pl]
            A[c] -= 1
            if A[c] == 0:
                ans -= 1
            pl += 1
        Ans[idx_LR] = ans
    return Ans

if sys.argv[-1] == 'ONLINE_JUDGE':
    import numba
    from numba.pycc import CC
    cc = CC('my_module')
    def cc_export(f, signature):
        cc.export(f.__name__, signature)(f)
        return numba.njit(f)
    build = cc_export(proc, "i4[:](i4[:],u4[:],u4[:],i8[:],i4,i4)")
    cc.compile()

from my_module import proc
def main():
    input = sys.stdin.buffer.readline
    N, Q = map(int, input().split())
    C = np.empty(N+1, dtype=np.int32)
    C[0] = 0
    C[1:] = np.array(input().split(), dtype=np.int32)
    LR = np.array(sys.stdin.buffer.read().split(), dtype=np.uint32)
    L = LR[::2]
    R = LR[1::2]
    
    n = 1 << N.bit_length()
    X = L.copy()
    Y = R.copy()
    s = n >> 1
    B = np.zeros(Q, dtype=np.int64)
    while s > 0:
        rx = X & s > 0
        ry = Y & s > 0
        B += s * s * (3*rx ^ ry)
        Idx2 = ~ry
        Idx1 = rx & Idx2
        X[Idx1] = n-1 - X[Idx1]
        Y[Idx1] = n-1 - Y[Idx1]
        X[Idx2], Y[Idx2] = Y[Idx2], X[Idx2]
        s >>= 1
    
    Order = np.argsort(B)
    Ans = proc(C, L, R, Order, N, Q)
    print("\n".join(map(str, Ans.tolist())))

main()


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

int main() {
    int N; cin >> N;
    double sum = 0;
    for(int i = 0; i < N; i++) {
        double money; cin >> money;
        string unit; cin >> unit;

        if(unit == "JPY") {
            sum += double(1.0) * money;
        } else {
            sum += double(380000.0) * money;
        }
    }

    cout << sum << endl;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Practice
{
    class Program
    {
        private static int ReadAndParseInt()
        {
            return int.Parse(Console.ReadLine());
        }
        private static int[] ReadAndParseIntArr()
        {
            return Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
        }
        private static long ReadAndParseLong()
        {
            return long.Parse(Console.ReadLine());
        }
        private static long[] ReadAndParseLongArr()
        {
            return Array.ConvertAll(Console.ReadLine().Split(' '), long.Parse);
        }
        static void Main(string[] args)
        {
            //SolveA(args);
            SolveB(args);
            //SolveC(args);
            //SolveD(args);


        }

        static void SolveB(string[] args)
        {
            int n = ReadAndParseInt();
            string s = Console.ReadLine();
            int max = 0;
            for(int cutidx = 1; cutidx < s.Length - 1; ++cutidx)
            {
                string x = s.Substring(0, cutidx);
                string y = s.Substring(cutidx, s.Length - cutidx );
                int bitX = 0;
                int bitY = 0;
                CalcHashSet(ref bitX, x);
                CalcHashSet(ref bitY, y);
                // どちらにも含まれてる文字を検索
                int bit = bitX & bitY;
                int sum = 0;
                for(int i=0;i<32;++i)
                {
                    if( (bit & (1 << i)) != 0)
                    {
                        sum++;
                    }
                }
                max = Math.Max(sum, max);
            }
            Console.WriteLine(max);
        }
        static void CalcHashSet(ref int bit, string s)
        {
            for(int i=0;i<s.Length;++i)
            {
                bit |= 1 << (int)(s[i]);
            }
        }
    }
}


Measured memory_bytes: 11092
a, b = map(int,input().split())
c, d = map(int,input().split())
e, f = map(int,input().split())
lst = []
lst.extend([a, b, c, d, e, f])
lst.sort()
count = 0
for i in range(1, 5, 1):
    if lst[i - 1] == lst[i] and lst[i] != lst[i + 1]:
        count += 1
if count == 2:
    print("YES")
else:
    print("NO")


Measured memory_bytes: 3064
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <vector>

using namespace std;

const double EPS = 1e-8;

int dcmp(double d) {
    if (fabs(d) < EPS) {
        return 0;
    }
    else {
        return d < 0? -1 : 1;
    }
}

struct Vector {
    double x, y;
    Vector(double x = 0, double y = 0): x(x), y(y){
    }
    
    bool operator<(const Vector& other) const {
        return dcmp(x - other.x) < 0 || (dcmp(x - other.x) == 0 && dcmp(y - other.y) < 0);
    }
};

typedef Vector Point;

double dot(const Vector& a, const Vector& b) {
    return a.x * b.x + a.y * b.y;
}

double cross(const Vector& a, const Vector& b) {
    return a.x * b.y - a.y * b.x; 
}

Vector operator+(const Vector& a, const Vector& b) {
    return Vector(a.x + b.x, a.y + b.y);
}

Vector operator-(const Vector& a, const Vector& b) {
    return Vector(a.x - b.x, a.y - b.y);
}

Vector operator*(const Vector& a, const double& p) {
    return Vector(a.x * p, a.y * p);
}

double angle(const Vector& a) {
    return atan2(a.y, a.x);
}

double length(const Vector& a) {
    return sqrt(dot(a, a));
}

struct Circle {
    Point c;
    double r;
    Circle(double x = 0, double y = 0,  double r = 0): c(Point(x, y)), r(r){}
    
    Point point(double rad) const {
        return Point(c.x + r * cos(rad), c.y + r * sin(rad));
    }
};


vector<Point> tagent(const Circle& c, const Point& p) {
    Vector v = p - c.c;
    double rad = angle(v);
    double x = acos(c.r / length(v));
    
    Point p1 = c.point(rad + x);
    Point p2 = c.point(rad - x);
    
    vector<Point> results{p1, p2};
    
    sort(results.begin(), results.end());
    
    return results;
}

int main() {
    double px, py;
    double x, y, r;
    cin >> px >> py >> x >> y >> r;
    
    Circle c(x, y, r);
    Point p(px, py);
    
    vector<Point> ans = tagent(c, p);
    cout << fixed << setprecision(8);
    
    cout << ans[0].x << "  " << ans[0].y << endl;
    
    cout << ans[1].x << "  " << ans[1].y << endl;
    
    return 0;
    
}

Measured memory_bytes: 3728
//自称高知能系Vtuberの高井茅乃です。
//Twitter: https://twitter.com/takaichino
//YouTube: https://www.youtube.com/channel/UCTOxnI3eOI_o1HRgzq-LEZw

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

#define INF 1999999999
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define MODA 1000000007 

int main() {
    int ans = 0;
    int tmp;
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    if(abs(a-c)<=d)cout << "Yes" << endl;
    else if (abs(a-b)<=d&& abs(b-c)<=d)cout << "Yes" << endl;
    else cout << "No" << endl;
    
}

Measured memory_bytes: 256
#include <iostream>
#include <utility>
#include <map>
#include <vector>
#include <algorithm>
#include <queue>
#include <math.h>
#include <stack>
#include <set>
#include <deque>
#include <cmath>

using namespace std;
typedef long long ll;
ll mod = 1e9+7;
//ll mod = 998244353;
#define rep(i,n) for(int i = 0; i < (n); ++i)

int main() {
    ll x;
    cin >> x;
    ll ans = x / 500 * 1000;
    x %= 500;
    ans += x / 5 * 5;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3604
#include<stdio.h>
#include<string.h>
  
#define N 20000
  
typedef struct Data{
  int area,pos;
} Data;
  
Data t[N];
int u[N]; 
int n,i;
char str[N];
int T,U;
int ans,A;
Data B,X;
  
void D_push(Data );
Data D_pop();
void push(int);
int pop();
void init();
Data makeData(int,int);
  
 int main(){
     init();
    
  scanf("%s",str);
    
  n = strlen(str);
    
  for(i = 0;i < n;i++){    
    if(str[i] == '/'){
      if(U == 0)continue;
      A = pop();
      X = makeData(i-A,A);
      ans = ans + i - A;
      while(T > 0){
    B = D_pop();
    if(B.pos < A){
      D_push(B);
      break;
    }
    X.area = X.area + B.area;
    if(B.pos < X.pos)X.pos = B.pos;
      }
      D_push(X);
    }else if(str[i] == '\\'){
      push(i);
    }
      
  }
    
  printf("%d\n%d", ans, T);
  for(i = 0;i < T;i++){
    printf(" %d",t[i].area);
  }
  printf("\n");
  return 0;
}
  
void D_push(Data data){
  t[T++]=data;
}
  
Data D_pop(){
  return t[--T];
}
void push(int x){
  u[U++]=x;
}
  
int pop(){
  return u[--U];
}
 
void init(){
    
  ans=0;
  T=0;
  U=0;
    
}
  
Data makeData(int x,int y){
    
  Data res;
    
  res.area=x;
  res.pos=y;
    
  return res;
} 



Measured memory_bytes: 2096
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = a; i < n; i++)
#define repr(i, a, n) for (int i = n - 1; i >= a; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }

int is_ng(map<char, int> mp, string s, string t) {
  for (auto u : mp) {
    if (u.second < 2)
      continue;
    unordered_set<char> se;
    rep(i, 0, s.size()) {
      if (s[i] == u.first)
        se.insert(t[i]);
    }
    if (se.size() > 1)
      return true;
  }
  return false;
}

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

  string s, t;
  cin >> s >> t;
  int n = s.size();

  map<char, int> up, lo;

  rep(i, 0, n) {
    up[s[i]]++;
    lo[t[i]]++;
  }

  if (is_ng(up, s, t) || is_ng(lo, t, s))
    cout << "No" << endl;
  else
    cout << "Yes" << endl;
}


Measured memory_bytes: 1556
#include <bits/stdc++.h>
using namespace std;
const int N = 10004;

char a[20];

int ans;
int xa, bx, ba;

int main()
{
    int m;
    cin >> m;
    while (m--)
    {
        cin >> a;
        int n = strlen(a);
        for (int i = 0; i < n - 1; ++i)
        {
            if (a[i] == 'A' && a[i + 1] == 'B')
                ++ans;
        }
        if (a[0] == 'B' && a[n - 1] == 'A')
            ++ba;
        else if (a[0] == 'B')
            ++bx;
        else if (a[n - 1] == 'A')
            ++xa;
    }
    if (ba)
        ans += (ba - 1);
    if (xa && ba)
    {
        ++ans;
        --xa;
    }
    if (ba && bx)
    {
        ++ans;
        --bx;
    }
    ans += min(xa, bx);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.math.BigInteger;
import java.util.Arrays;
import java.util.LinkedList;
import java.util.Scanner;
import java.util.StringTokenizer;

public class Main {
	
	public static class SegTree{
		int size;
		int[] index;
		int[] data;
		
		public SegTree(int n){
			int n_ = 1;
			while(n_ < n){
				n_ *= 2; 
			}
			
			this.size = n_;
			
			
			index = new int[this.size * 2 - 1];
			for(int i = 0; i < index.length; i++){
				index[i] = Math.max(0, i - this.size + 1);
			}
			
			data = new int[this.size * 2 - 1];
			for(int i = 0; i < data.length; i++){
				data[i] = 0;
			}
		}
		
		public void comp(int t, int k1, int k2){
			data[t] = Math.max(data[k1], data[k2]);
			if(data[k1] >= data[k2]){
				index[t] = index[k1];
			}else if(data[k1] < data[k2]){
				index[t] = index[k2];
			}
		}
		
		public void update(int x, int a_diff){
			final int t = x + size - 1;
			
			//System.out.println(data.length + " " + x + " " + t);
			data[t] += a_diff;
			
			int k = t;
			while(k != 0){
				k = (k - 1) / 2;
				comp(k, k*2 + 1, k*2 + 2);
			}
		}
		
		public int get_top_index(){
			return index[0];
		}
		
		public int get_top_data(){
			return data[0];
		}
	}
	
	public static void main(String[] args) throws IOException {
		Scanner sc = new Scanner(System.in);
		
		final int N = sc.nextInt();
		final int R = sc.nextInt();
		final int L = sc.nextInt();
		
		SegTree seg = new SegTree(N);
		SegTree time = new SegTree(N);
		
		int prev_time = 0;
		for(int i = 0; i < R; i++){
			final int d = sc.nextInt() - 1;
			final int t = sc.nextInt();
			final int x = sc.nextInt();
			
			time.update(seg.get_top_index(), t - prev_time);
			prev_time = t;
			//System.out.println((time.get_top_index() + 1) + " " + time.get_top_data());
			
			seg.update(d, x);
			//System.out.println((seg.get_top_index() + 1) + " " + seg.get_top_data());
		}
		
		time.update(seg.get_top_index(), L - prev_time);
		
		System.out.println(time.get_top_index() + 1);
	}
	
public static class Scanner {
		
		private BufferedReader br;
		private StringTokenizer tok;
		
		public Scanner(InputStream is) throws IOException{
			br = new BufferedReader(new InputStreamReader(is));
			getLine();
		}
		
		private void getLine() throws IOException{
			while(tok == null || !tok.hasMoreTokens()){
				tok = new StringTokenizer(br.readLine());
			}
		}
		
		private boolean hasNext(){
			return tok.hasMoreTokens();
		}
		
		public int nextInt() throws IOException{
			if(hasNext()){
				return Integer.parseInt(tok.nextToken());
			}else{
				getLine();
				return Integer.parseInt(tok.nextToken());
			}
		}
		
		public long nextLong() throws IOException{
			if(hasNext()){
				return Long.parseLong(tok.nextToken());
			}else{
				getLine();
				return Long.parseLong(tok.nextToken());
			}
		}
		
		public double nextDouble() throws IOException{
			if(hasNext()){
				return Double.parseDouble(tok.nextToken());
			}else{
				getLine();
				return Double.parseDouble(tok.nextToken());
			}
		}
	}

}

Measured memory_bytes: 97312
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const int MAX_N = 2005;
int ans[MAX_N];

int main()
{
	int N,X,Y;
	cin >> N >> X >> Y;
	for (int i = 1; i <= N; ++i)
	{
		for (int j = i+1; j <= N; ++j)
		{
			int dist = min(j-i,abs(i-X)+abs(j-Y)+1);
			ans[dist]++;
		}
	}
	for (int i = 1; i <= N-1; ++i)
	{
		cout << ans[i] << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <numeric>
#include <vector>
#include <cassert>
#include <string>
#include <memory.h>
#include <queue>
#include <cstdio>
#include <cstdlib>
#include <set>
#include <map>
#include <cctype>
#include <iomanip>
#include <sstream>
#include <cctype>
#include <fstream>
#include <cmath>
using namespace std;

#define REP2(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define REP(i, n) REP2(i, 0, n)
#define ALL(c) (c).begin(), (c).end()
#define ITER(c) __typeof((c).begin())
#define PB(e) push_back(e)
#define FOREACH(i, c) for(ITER(c) i = (c).begin(); i != (c).end(); ++i)
#define MP(a, b) make_pair(a, b)
#define PARITY(n) ((n) & 1)

typedef long long ll;
typedef pair<ll, ll> P;
const int INF = 1000 * 1000 * 1000 + 7;
const double EPS = 1e-10;

int ndays(int y, int m){
  if(y % 3 == 0) return 20;
  else return m % 2 ? 20 : 19;
}

int main(){
  int n;
  int y, m, d;
  cin >> n;
  while(n--){
    cin >> y >> m >> d;

    int days = 0;
    while(y != 1000){
      days++;
      d++;
      if(d == ndays(y, m) + 1){
        d = 1;
        m++;
        if(m == 11){
          m = 1;
          y++;
        }
      }
    }
    cout << days << endl;
  }
  return 0;
}

Measured memory_bytes: 1160
#include<iostream>
using namespace std;
int n;
const int sz=1e5;
int a[sz+10];
signed main()
{
    cin>>n;
    for(int i=0;i<n;i++)
    {
        int b;
        cin>>b;
        a[b-1]=i+1;
    }
    for(int i=0;i<n;i++)cout<<a[i]<<endl;
    return 0;
}

Measured memory_bytes: 1152
import numpy as np
import itertools
N, D = map(int, input().split())
A = [np.array(input().split(), dtype=np.int64) for _ in range(N)]

count = 0
for y, z in itertools.combinations(A, 2):
  d = np.sqrt(((y-z)**2).sum())
  if d == int(d):
    count += 1
print(count)    
  

Measured memory_bytes: 12480
#include <stdio.h>

int main(void){
	char c[4][3];
	int i;
	for(i=0;i<3;i++){
		scanf("%s",&c[i]);
	}
	printf("%c",c[0][0]);
	printf("%c",c[1][1]);
	printf("%c",c[2][2]);
	
	
	return 0;
}

Measured memory_bytes: 128
N = int(input())
S = [input() for i in range(N)]

from collections import defaultdict
dd = defaultdict(int)

max_n = 0

for i in range(N):
    dd[S[i]]+=1
    max_n = max(max_n,dd[S[i]])

ans = []
for key in dd:
    if dd[key]==max_n:
        ans.append(key)

ans.sort()
for a in ans:
    print(a)

Measured memory_bytes: 101128
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

int main() {
    ios_base::sync_with_stdio(false);

    string s;
    cin >> s;

    int answer = 0;

    int count = 0;
    for (int i = 0; i < (int) s.size(); ++i) {
        if (s[i] == 'g') {
            if (count > 0) {
                --count;
                ++answer;
            } else {
                ++count;
            }
        } else {
            if (count > 0) {
                --count;
            } else {
                ++count;
                --answer;
            }
        }
    }

    cout << answer << endl;

    return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <algorithm>
#include <math.h>
#include <queue>
using namespace std;
int main(){
  int H,W;
  cin>>H>>W;
  string s[400];
  for(int i=0;i<H;i++) cin>>s[i];
  queue<pair<int,int>> que;
  int search[400][400];
  int dx[4]={0,-1,0,1};
  int dy[4]={1,0,-1,0};
  long long answer=0;
  for(int i=0;i<H;i++) for(int j=0;j<W;j++) search[i][j]=0;
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      if(search[i][j]==0){
        que.push(make_pair(i,j));
        long long white=0;
        long long black=0;
        search[i][j]++;
        while(!que.empty()){
          int x=que.front().second;
          int y=que.front().first;
          que.pop();
          if(s[y][x]=='.') white++;
          else black++;
          for(int k=0;k<4;k++){
            if(x+dx[k]>=0&&x+dx[k]<W&&y+dy[k]>=0&&y+dy[k]<H){
              if(s[y+dy[k]][x+dx[k]]!=s[y][x]&&search[y+dy[k]][x+dx[k]]==0){
                que.push(make_pair(y+dy[k],x+dx[k]));
                search[y+dy[k]][x+dx[k]]++;
              }
            }
          }//for k
        }//while
        answer+=white*black;
      }
    }
  }
  cout<<answer<<endl;
  
  return 0;
}

Measured memory_bytes: 4084
#include <iostream>
#include <fstream>
using namespace std;
const int nmax=5025;
int dp[2][nmax][nmax];
int a[nmax],l[nmax],r[nmax];
int n,i,j,k,ind,n1,n2,ans;
bool check()
{
    ind=1;
    for(j=n1;j>=1;j--)
    {
        while(ind<=n2&&l[j]+r[ind]<k) ind++;
        ind--;
        if(l[j]+r[ind]>=k-a[i])
            return 0;
    }
    return 1;
}
int main()
{
    //freopen("data.in","r",stdin);
    cin>>n>>k;
    dp[0][0][0]=1;
    for(i=1;i<=n;i++)
    {
        cin>>a[i];
        for(j=0;j<=k;j++)
            dp[0][i][j]=dp[0][i-1][j];
        for(j=k-a[i];j>=0;j--)
            dp[0][i][j+a[i]]|=dp[0][i][j];
    }
    dp[1][n+1][0]=1;
    for(i=n;i>=1;i--)
    {
        for(j=0;j<=k;j++)
            dp[1][i][j]=dp[1][i+1][j];
        for(j=k-a[i];j>=0;j--)
            dp[1][i][j+a[i]]|=dp[1][i][j];
    }
    for(i=1;i<=n;i++)
    {
        n1=n2=0;
        for(j=0;j<k;j++)
            if(dp[0][i-1][j])
               l[++n1]=j;
        for(j=0;j<k;j++)
            if(dp[1][i+1][j])
               r[++n2]=j;
        if(check()) ++ans;
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 197120
#include <stdio.h>
#include <algorithm>
#include <set>
using namespace std;

int main()
{
    int n;
    set<int> st;
    scanf("%d",&n);
    while(n--) {
        int d; scanf("%d",&d);
        if(st.find(d) != st.end()) st.erase(d);
        else st.insert(d);
    }
    printf("%d",st.size());
    return 0;
}


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

using namespace std;

int main()
{
    int n;
    cin >> n;
    vector<int> a(n + 1), pre(n + 1), suf(n + 2);
    for (int i = 1; i <= n; i++) {
        cin >> a[i];
    }
    for (int i = 1; i <= n; i++) {
        pre[i] = __gcd(a[i], pre[i - 1]);
    }
    suf[n] = 0;
    for (int i = n; i >= 0; i--) {
        suf[i] = __gcd(suf[i + 1], a[i]);
    }
    int ans = 1;
    for (int i = 1; i <= n; i++) {
        ans = max(ans, __gcd(pre[i - 1], suf[i + 1]));
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
int n;

int main(){
	cin>>n;
	int i;
	while(n!=0){
		if(n%10==7){
			cout<<"Yes";
			return 0;
		}
		n/=10;
	}
	cout<<"No";
	
	
	return 0;
}


Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
char s[11];
long long a[5];
int main()
{
    int n;
    scanf("%d",&n);
    memset(a,0,sizeof(a));
    for(int i=0;i<n;i++)
    {
        scanf("%s",s);
        if(s[0]=='M')
            a[0]++;
        else if(s[0]=='A')
            a[1]++;
        else if(s[0]=='R')
            a[2]++;
        else if(s[0]=='C')
            a[3]++;
        else if(s[0]=='H')
            a[4]++;
    }
    sort(a,a+5);
    int t=upper_bound(a,a+5,0)-a;
    long long ans=0;
    if(t>=3)
        printf("0\n");
    else if(t==2)
    {
        ans=a[2]*a[3]*a[4];
        printf("%lld\n",ans);
    }
    else if(t==1)
    {
        ans+= a[1]*a[2]*a[3]+a[1]*a[2]*a[4]+a[2]*a[3]*a[4]+a[1]*a[3]*a[4];
        printf("%lld\n",ans);
    }
    else if(t==0)
    {
        ans+=a[0]*a[1]*a[2]+a[0]*a[1]*a[3]+a[0]*a[1]*a[4];
        ans+=a[1]*a[2]*a[3]+a[1]*a[2]*a[4]+a[2]*a[3]*a[4];
        ans+=a[0]*a[3]*a[4]+a[0]*a[2]*a[3]+a[0]*a[2]*a[4]+a[1]*a[3]*a[4];
        printf("%lld\n",ans);
    }
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>


int sub(int x){
  if((x>=1)&&(x<=12)){
    return 1;
  }else if(x==0){
    return 2;
  }else{
    return 3;
  }
}

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

  int A,B;
  A=(S[0]-'0')*10+(S[1]-'0');
  B=(S[2]-'0')*10+(S[3]-'0');

  if((sub(A)==1)&&(sub(B)==1)){
    printf("AMBIGUOUS\n");
  }else if(sub(A)==1){
    printf("MMYY\n");
  }else if(sub(B)==1){
    printf("YYMM\n");
  }else{
    printf("NA\n");
  }
  return 0;
}


Measured memory_bytes: 128
import java.util.Scanner;

public class Main {

  private static int n, input_num, min, max;
  private static long sum;

  public static void main(String[] args) {
    Scanner stdIn = new Scanner(System.in);
    n = stdIn.nextInt();
    input_num = stdIn.nextInt();
    max = input_num;
    min = input_num;
    sum = input_num;
    for (int i = 1;i < n; i++) {
      input_num = stdIn.nextInt();
      if(max < input_num) {
        max = input_num;
      }
      if(min > input_num) {
        min = input_num;
      }
      sum += input_num;
    }

    System.out.println(min + " " + max + " " + sum);

  }
}

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

long N, A, B;
vector<long> H;

bool f(long n) {
  vector<long> V = H;
  for (auto &v : V) v -= B * n;
  long cnt = 0;
  long d = A - B;
  for (auto v : V) if (v > 0) cnt += (v + d - 1) / d;
  if (cnt > n) return false;
  else return true;
}


int main() {
  cin >> N >> A >> B;
  H.resize(N);
  for (long i = 0; i < N; i++) cin >> H.at(i);
  long ng = -1, ok = 1e9+1;
    while (ok - ng > 1) {
      long mid = (ok + ng) / 2;
      (f(mid)) ? ok = mid : ng = mid;
    }
  cout << ok << "\n";
}

Measured memory_bytes: 4752
#include <algorithm>
#include <array>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <limits>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>

using namespace std;

int main() {
  int n;
  cin >> n;

  deque<int> prices(n);
  for (int i = 0; i < n; i++) {
    cin >> prices[i];
  }

  long long money = 1000;
  long long stock = 0;
  long long min, max;
  min = max = prices[0];
  for (int i = 0; i < n - 1; i++) {
    if (prices[i] < min) {
      min = prices[i];
    } else if (prices[i] > max) {
      max = prices[i];
    }

    // 次下がるので、ここまでの最安値で買えるだけ買い、最高値で売れるだけ売る
    if (prices[i] > prices[i + 1]) {
      long long buy_num = money / min;

      // 購入
      money -= buy_num * min;
      stock += buy_num;

      // 売却
      money += stock * max;
      stock = 0;

      // min,maxをリセット
      min = max = prices[i + 1];
    }
  }

  /* 最後の購入、売却 */
  if (prices[n - 1] < min) {
    min = prices[n - 1];
  } else if (prices[n - 1] > max) {
    max = prices[n - 1];
  }

  long long buy_num = money / min;

  // 購入
  money -= buy_num * min;
  stock += buy_num;

  // 売却
  money += stock * max;
  stock = 0;

  cout << money << endl;

  return 0;
}


Measured memory_bytes: 3128
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; ++i)
#define rrep(i, n) for(int i = n-1; i >= 0; --i)
#define fi first
#define se second
using namespace std;
using lint = long long;
using uint = unsigned int;
using ulint = unsigned long long;
using ldouble = long double;
using pii = pair<int, int>;
using pli = pair<lint, lint>;
using pdd = pair<double, double>;
using pld = pair<ldouble, ldouble>;
using v1i = vector<int>;
using v1li = vector<lint>;
using v2i = vector<vector<int>>;
using v2li = vector<vector<lint>>;
using v3i = vector<vector<vector<int>>>;
using v3li = vector<vector<vector<lint>>>;
using v1b = vector<bool>;
using v2b = vector<vector<bool>>;
using v3b = vector<vector<vector<bool>>>;
using v1c = vector<char>;
using v2c = vector<vector<char>>;
using v3c = vector<vector<vector<char>>>;
constexpr lint mod1 = 1e9+7;
constexpr lint mod2 = 998244353;

int main() {
  lint s = 0, n, a, b;
  cin >> n;
  a = n / 500;
  n -= a * 500;
  s += a * 1000;
  b = n / 5;
  s += b * 5;
  cout << s << endl;
  return 0;
}

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

int main(void) {
	int a, b;
	cin >> a >> b;
	if (a == b) {
		cout << "a == b" << endl;
	}
	else if (a > b) {
		cout << "a > b" << endl;
	}
	else {
		cout << "a < b" << endl;
	}
	return 0;
}


Measured memory_bytes: 3056