akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll mod = 1e9+7;
#define rep(i,n) for(int i = 0; i < (n); ++i)

int main(){
    string s;
    cin >> s;
    int n = s.length();
    if ( n == 2 ) {
        cout << s[0] << endl;
        return 0;
    }
    rep(i, n/2) {
        s = s.substr(0, s.length()-2);
        if ( s.substr(0, s.length()/2) == s.substr(s.length()/2, s.length()/2) ) {
            cout << s.length() << endl;
            return 0;
        }
    }

    return 0;
}


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

#define endl "\n"
#define MOD 1000000007

#define forn(i, a, n) for (int i = a; i < n; i++)
#define forns(i, a, n, step) for (int i = a; i < n; i += step)
#define fornr(i, a, n) for (int i = n; i > a; --i)
#define fornrs(i, a, n, step) for (int i = n; i > a; i -= step)
#define forlimits(i, l, r) for (int i = l; i <= r; i++)

// Choose auto x when you want to work with copies.
#define foritc(i, v) for (auto i = v)
// Choose auto &x when you want to work with original items and may modify them.
#define foritm(i, v) for (auto &i = v)
// Choose auto const &x when you want to work with original items and will not modify them.
#define forit(i, v) for (auto const &i = v)

#define all(v) (v).begin(), (v).end()

#define fill(arr, n, k) \
    forn(i, 0, n) { arr[i] = k; }

#define print(arr, n)                        \
    forn(i, 0, n) { cout << arr[i] << " "; } \
    cout << endl;

#define sum_n(n) ((n) * (n + 1) / 2)
typedef long long ll;
void solve();

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    solve();
    // ll t;
    // cin >> t;
    // while (t--) {
    //     solve();
    // }
    // return 0;
}

void solve() {
    ll n, w;
    cin >> n >> w;
    ll weight[n];
    ll cost[n];
    ll dp[n + 1][w + 1] = {0};
    forn(i, 0, n) {
        cin >> weight[i] >> cost[i];
    }

    forn(i, 0, (n + 1)) {
        forn(j, 0, (w + 1)) {
            if (i == 0 || j == 0) {
                dp[i][j] = 0;
            } else if (weight[i - 1] <= j) {
                dp[i][j] = max(dp[i - 1][j], cost[i - 1] + dp[i - 1][j - weight[i - 1]]);
            } else {
                dp[i][j] = dp[i - 1][j];
            }
        }
    }
    cout << dp[n][w] << endl;
}

Measured memory_bytes: 82532
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
const double eps = 1e-10;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1ll<<50;
template<typename T>
void printv(const vector<T>& s) {
  for(int i=0;i<(int)(s.size());++i) {
    cout << s[i];
    if(i == (int)(s.size())-1) cout << endl;
    else cout << " ";
  }
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  while(1) {
    string s; cin >> s;
    if(s == "0") break;
    int n = (int)(s.size());
    vector<int> a(n);
    for(int i=0;i<n;++i) {
      a[i] = s[i] - '0';
    }
    vvi dp(n, vi(11, 0));
    dp[0][a[0]] = 1;
    for(int i=0;i<n-1;++i) {
      if(a[i+1] != 0) dp[i+1][a[i+1]] = 1;
      for(int j=0;j<11;++j) {
        dp[i+1][(j*10+a[i+1])%11] += dp[i][j];
      }
    }
    int ans = 0;
    for(int i=0;i<n;++i) {
      ans += dp[i][0];
    }
    cout << ans << endl;
  }
}



Measured memory_bytes: 10388
#!/usr/bin/env python3

def main():
    *N, = map(int, open(0).read().split())
    A = N[2:]
    K = N[0]
    N = N[1]

    S = []
    for i in range(0, N):
        if i == 0:
            S.append(A[0] + K - A[N - 1])
        else:
            S.append(A[i] - A[i - 1])
    print(sum(S) - max(S))

main()

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

using namespace std;

int main(){
    int n;
    cin>>n;
    vector<int> a(n);
    for(int i=0;i<n;i++){
      cin>>a[i];
    }
    int ans=0;
    while(true){
      for(int i=0;i<n;i++){
          if(a[i]%2!=0) goto FL;
          a[i]/=2;
      }
      ans++;
    }
    FL:
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
int main(){
  int N;
  cin >> N;
  int *a = new int[N];
  //int k = pow(10,9);
  //int check[k] = {};
  map<int, int> mp;
  for(int i=0; i<N; i++){
	cin >> a[i];
	mp[a[i]]++;
  }

  for(int i=0; i<N; i++){
	if(mp[a[i]] > 1){
	  cout << "NO" << endl;
	  return 0;
	}
  }

  cout << "YES" << endl;
  delete[] a;
  return 0;
}


Measured memory_bytes: 10368
#include<bits/stdc++.h>
const int inf=1145141919;
const int dd[]={0,-1,0,1,0};
using namespace std;
int p[114514],q[334][114514],r[334];
signed main(){
	int a,b;
	cin>>a>>b;
	a+=b;
	if(a>=24)
		a-=24;
	cout<<a<<endl;
}


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

int main(){
	int a,b,c,count=0;
	while(cin>>a>>b){
		count=0;
		 c=a+b;
		while(c!=0){
			c=c/10;
			count++;
		}
		cout<<count<<endl;
	}
	return 0;
}


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

int main() {
  int N;
  string str;
  cin >> N;
  cin >> str;
  if(N%2==1) {
    cout << "No" << endl;
  	return 0;
  }
  for(int i=0;i<N/2;i++){
    if(str.at(i)!=str.at(N/2+i)){
      cout << "No" << endl;
      return 0;
    }
    if(i==N/2-1)
      cout << "Yes" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
s=input()
a=s[0:(len(s)-1)//2]
n=len(a)
ans='Yes'
if a!=s[(len(s)-1)//2+1:]:
    ans='No'
for i in range(n):
    if a[i]!=a[n-i-1]:
        ans='No'

print(ans)

Measured memory_bytes: 3060
#include<stdio.h>

#define N 100

void MCM(void);

int n, p[N+1], m[N+1][N+1];

int main()
{
  int i;
  
  scanf("%d", &n);
  for(i=1;i<=n;i++)
    {
      scanf("%d%d", &p[i-1], &p[i]);
    }

  MCM();
  printf("%d\n", m[1][n]);
  
  return 0;
}

void MCM(void)
{
  int i=0, j=0, k=0, l=0, q;

  for(i=0;i<=n;i++)
    {
      m[i][i] = 0;
    }
  
  for(l=2;l<=n;l++)
    {
      for(i=1;i<=n-l+1;i++)
	{
	  int j = i + l - 1;
	  m[i][j] = 10000000;
	  for(k=i;k<j;k++)
	    {
	      q = m[i][k] + m[k+1][j] + p[i-1] * p[k] * p[j];
	      if(m[i][j] > q)m[i][j] = q;
	    }
	}
    }
}



Measured memory_bytes: 2104
"use strict";
const Main = (input) =>{
	let xs = input.trim().split(' ');
    let ans = 0;
    let A = parseInt(xs[0],10);
    let B = parseInt(xs[2],10);
    if(xs[1] == '-'){
    	ans = A - B;
    } else if(xs[1] == '+') {
    	ans = A + B;
    }
    console.log(ans);
}
Main(require('fs').readFileSync('/dev/stdin','utf8'));

Measured memory_bytes: 7372
#include<iostream>
#include<vector>
#include<sstream>
#include<algorithm>
#include<cstdlib>
using namespace std;

bool cmp(const string& a,const string b)
{
  if(a.size() != b.size())
    return a.size() < b.size();
  if(a != b)
    return (atoi)(a.c_str()) < (atoi)(b.c_str());
  return false;
}

int main()
{
  int n;
  vector<string> vec;
  cin >> n; 
  vec.resize(n);

  int men = 100000000;  
  int Size[6];
  for(int i=0;i<6;i++)
    Size[i] = 0;
  for(int i=0;i<n;i++)
    cin >> vec[i],Size[vec[i].size()]++,men = min(men,(int)vec[i].size());

  sort(vec.begin(),vec.end(),cmp);
    
  if(Size[men] >= 4)
      cout << vec[0] << vec[3] << endl;
  else if(Size[men] == 3)
    cout << vec[1] << vec[0] << endl;
  else if(Size[men] == 2)
    {
      string a,b;
      a = vec[0]+vec[2];
      b = vec[2]+vec[0];
      //cout << min((atoi)(b.c_str()),(atoi)(a.c_str())) << endl;
cout << a << endl;
    }
  else if(Size[men] == 1)
    {
      vector<string> ans;
      for(int i=0;i<4;i++)
	for(int j=0;j<4;j++)
	  if(i != j)
	    ans.push_back(vec[i]+vec[j]);
      sort(ans.begin(),ans.end(),cmp);
      cout << ans[2] << endl;
    }


  


  return 0;
}

Measured memory_bytes: 1656
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define LINF (ll)INF*INF
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,a,n) for(int i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

#define int ll //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef vector<pii> vp;

int gcd(int a, int b){
    if(b==0) return a;
    return gcd(b,a%b);
}
int lcm(int a, int b){
    return a/gcd(a,b)*b;
}

#define MAX 7*100*10+10

signed main(void) {
    int n;
    while(cin >> n, n){
        int dp[10][MAX] = {};
        dp[0][0] = 1;
        rep(i,n){
            int a,b;
            cin >> a >> b;
            rep(j,MAX)if(dp[i][j] > 0){
                rep(k,b+1){
                    dp[i+1][j+a*k] += dp[i][j];
                }
            }
        }

        int g;
        cin >> g;
        rep(i,g){
            int m;
            cin >> m;
            cout << dp[n][m] << endl;
        }
    }
}



Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=1e6;
const ll MOD=1e9+7;
ll n,m,inv[N],F[N],Finv[N];

void init(){
    inv[1] = 1;
    for(int i = 2; i < N; i ++){
        inv[i] = (MOD - MOD / i) * 1ll * inv[MOD % i] % MOD;
    }
    F[0] = Finv[0] = 1;
    for(int i = 1; i < N; i ++){
        F[i] = F[i-1] * 1ll * i % MOD;
        Finv[i] = Finv[i-1] * 1ll * inv[i] % MOD;
    }
}
ll comb(ll n, ll m){//comb(n, m)就是C(n, m)
    if(m < 0 || m > n) return 0;
    return F[n] * 1ll * Finv[n - m] % MOD * Finv[m] % MOD;
}

map<ll,ll>cnt;
//ll dp[100005][30][30];
//ll work(ll x){
//    if(x<=0&&(cnt[2]||cnt[3]))  return 0;
//    memset(dp,0,sizeof dp);
//    dp[0][0][0]=1;
//    for(int i=1;i<=x;i++){
//        for(int a=0;a<=cnt[2];a++){
//            for(int b=0;b<=cnt[3];b++){
//                for(int ua=0;ua<=a;ua++){
//                    for(int ub=0;ub<=b;ub++){
//                        dp[i][a][b]+=dp[i-1][a-ua][b-ub];
//                    }
//                }
//            }
//        }
//    }
////    cout << dp[1][1][1]<<endl;
//    return dp[x][cnt[2]][cnt[3]];
//}

int main(){
    cin >>n >> m;
    cnt.clear();
    for(int i=2;i<=m;i++){
        if(m%i==0)  while(m%i==0)   m/=i,cnt[i]++;
    }
    if(m>1) cnt[m]++;
    init();

    ll ans=1ll;
    for(auto t : cnt){
        ll v=t.second;
//        cout <<t.first<<" "<< v << endl;
        ans=ans*comb(n+v-1,n-1)%MOD;
    }
    cout << ans << endl;

    return 0;
}


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

int main(void) {
    int result = 0;
    string S;cin>>S;
    if (S[0] == '1') result++;
    if (S[1] == '1') result++;
    if (S[2] == '1') result++;
    cout << result << endl;
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <set>
using namespace std;
typedef long long LL;
const int MaxN = 1e5;
const int Inf = 1 << 30;

int main()
{
	int a,b;
	char s[5];
	while(~scanf("%d",&a)){
		scanf("%s",s);
		scanf("%d",&b);
		if(s[0] == '+') a += b;
		else a -= b;
		printf("%d\n",a);
	}
    return 0;
}

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

const int MAXN = 500001;

int w[MAXN];

int c0, c1;
bool dif;

vector <int> e[MAXN];

void dfs(int v, int d) {
    if (w[v]) {
        if (w[v] != d) {
            dif = true;
        }
        return;
    }

    if (d & 1) c1++;
    else c0++;

    w[v] = d;

    for (int u : e[v]) {
        dfs(u, d ^ 1);
    }
}

int main() {
#ifdef PAUNSVOKNO
    freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
#endif
    ios_base::sync_with_stdio(false); cout.setf(ios::fixed); cout.precision(20);
    int n, m;
    cin >> n >> m;
    ll ans = 0;

    for (int i = 0; i < m; i++) {
        int a, b;
        cin >> a >> b;
        e[a].push_back(b);
        e[b].push_back(a);
    }

    for (int i = 1; i <= n; i++) {
        if (!w[i]) {
            c0 = c1 = 0;
            dif = false;
            dfs(i, 2);
            if (dif) {
                ans += (ll(c0 + c1 - 1) * ll(c0 + c1)) / 2;
            } else {
                ans += ll(c0) * c1;
            }
        }
    }

    cout << ans - m << "\n";

    return 0;
}

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

int main(void){
    string S, T;
    int ans = 0;
    char s, t;

    cin >> S;
    cin >> T;

    for(int i = 0; i < S.length(); ++i){
        s = S[i];
        t = T[i];
        if(s != t) ++ans;
    }

    cout << ans << endl;
}

Measured memory_bytes: 3892
from collections import deque
from heapq import heapify,heappop,heappush,heappushpop
from copy import copy,deepcopy
from itertools import product,permutations,combinations,combinations_with_replacement
from collections import defaultdict,Counter
from bisect import bisect_left,bisect_right
from math import gcd,ceil,floor,factorial
# from fractions import gcd
from functools import reduce
from pprint import pprint
from statistics import mean,median,mode

INF = float("inf")

def mycol(data,col):
    return [ row[col] for row in data ]

def mysort(data,col,reverse_flag):
    data.sort(key=lambda x:x[col],reverse=reverse_flag)
    return data

def mymax(data):
    M = -1*float("inf")
    for i in range(len(data)):
        m = max(data[i])
        M = max(M,m)
    return M

def mymin(data):
    m = float("inf")
    for i in range(len(data)):
        M = min(data[i])
        m = min(m,M)
    return m

def mycount(ls,x):
    # lsはソート済みであること
    l = bisect_left(ls,x)
    r = bisect_right(ls,x)
    return (r-l)

def myoutput(ls,space=True):
    if space:
        if len(ls)==0:
            print(" ")
        elif type(ls[0])==str:
            print(" ".join(ls))
        elif type(ls[0])==int:
            print(" ".join(map(str,ls)))
        else:
            print("Output Error")
    else:
        if len(ls)==0:
            print("")
        elif type(ls[0])==str:
            print("".join(ls))
        elif type(ls[0])==int:
            print("".join(map(str,ls)))
        else:
            print("Output Error")

def I():
    return int(input())

def MI():
    return map(int,input().split())

def RI():
    return list(map(int,input().split()))

def CI(n):
    return [ int(input()) for _ in range(n) ]

def LI(n):
    return [ list(map(int,input().split())) for _ in range(n) ]

def S():
    return input()

def MS():
    return input().split()

def RS():
    return list(input())

def CS(n):
    return [ input() for _ in range(n) ]

def LS(n):
    return [ list(input()) for _ in range(n) ]

# ddict = defaultdict(lambda: 0)
# ddict = defaultdict(lambda: 1)
# ddict = defaultdict(lambda: int())
# ddict = defaultdict(lambda: list())
# ddict = defaultdict(lambda: float())

n,s = MI()
x = RI()

l = []
for i in range(n):
    l.append(abs(x[i]-s))

# def gcd3(*numbers):
#     return reduce(gcd, numbers)

def gcd3_list(numbers):
    return reduce(gcd, numbers)

ans = gcd3_list(l)
print(ans)

Measured memory_bytes: 95900
#include<iostream>
#include<vector>
#include<algorithm>
#include<math.h>
#include<queue>
#include<deque>
#include<map>
using namespace std;
typedef long long ll;

int main() {
    int n; cin >> n;
    map<int, int> s;
    auto prime_factorize = [&](int n) -> void {
        for (int i = 2; i*i <= n; i++) {
            if (n%i != 0) continue;
            int num = 0;
            while (n%i == 0) {
                num++;
                n /= i;
            }
            s[i] += num;
        }
        if (n != 1) s[n] += 1;
    };
    for (int i = 1; i <= n; i++)
    {
        prime_factorize(i);
    }

    auto rec = [&](auto &&rec, auto p, int m) -> int {
        if (p == s.end()) {
            if (m == 1) return 1;
            else return 0;
        }

        int res = 0;
        for (int i = 0; i <= p->second; i++)
        {
            if (m % (i+1) != 0) continue;
            res += rec(rec, ++p, m/(i+1));
            p--;
        }
        return res;
    };
    cout << rec(rec, s.begin(), 75) << endl;
    return 0;
}

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

map<int, int> mp;

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

  for (int i = 0; i < M; i++) {
    int b, c;
    cin >> b >> c;
    mp[-c] += b;
  }

  int ans = 0, cnt = 0;
  for (auto x : mp) {
    if (cnt + x.second <= N) {
      ans -= x.second * x.first;
      cnt += x.second;
    } else {
      int diff = N - cnt;
      ans -= diff * x.first;
      break;
    }
  }

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


Measured memory_bytes: 13568
list_input_str = input().split(' ')
n, m = map(int, list_input_str)


def p(_n, _r):
    # nPrをreturnする
    ret = 1
    for i in range(_r):
        ret = ret * (_n - i)
    return ret


def c(_n, _r):
    over = p(_n, _r)
    under = p(_r, _r)
    return over / under


print(int(c(n, 2) + c(m, 2)))


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

void solve(std::istream &in, std::ostream &out);

int main() {
#ifdef LOCAL
  freopen("../IO/d.in", "r", stdin);
//  freopen("../IO/d.out", "w", stdout);
#else
  std::ios_base::sync_with_stdio(false);
  std::cin.tie(nullptr);
  std::cout.tie(nullptr);
#endif
  solve(std::cin, std::cout);
  return 0;
}


void solve(std::istream &in, std::ostream &out) {
  int64_t sm = 0;
  int n;
  in >> n;
  vector<int> freq(n+1,0);
  vector<int> a(n);
  for (int &i : a){
    in>>i;
    sm += freq[i]++;
  }
  for (int i : a) {
    out << sm - freq[i] + 1 << '\n';
  }
}



Measured memory_bytes: 4224
#include <bits/stdc++.h>
const int INF=1e9;
const int MOD=1e9+7;
//const int MOD=998244353;
const long long LINF=1e18;
using namespace std;
#define int long long
//template
int s(int n){
  int res=0;
  while(n){
    res+=n%10;
    n/=10;
  }
  return res;
}
long double f(int n){
  return (long double)n/s(n);
}
//main
signed main(){
  int K;cin>>K;
  int now=0;int t=1;
  std::vector<int> ans;
  while(ans.size()<K){
    for(int i=1;i<=200;i++){
      if(f(now+i*t)>f(now+(i+1)*t))break;
      //cout<<now<<" "<<i<<" "<<t<<endl;
      if(ans.size()==0){ans.push_back(1);continue;}
      if(now+i*t>ans[ans.size()-1])ans.push_back(now+i*t);
    }
    //cout<<now<<endl;
    now*=10;now+=9;t*=10;
    //cout<<now<<endl;
  }
  for(int i=0;i<K;i++)cout<<ans[i]<<endl;
}


Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<set>
#include<map>
using namespace std;
#define rep(i,l,r) for(register int i=(l);i<=(r);++i)
#define repdo(i,l,r) for(register int i=(l);i>=(r);--i)
#define il inline
typedef double db;
typedef long long ll;

//---------------------------------------
const ll nmod=998244353,nsz=5e5+50;
int n,m;
//ll dp[2][nsz*2],cur=1;
ll fac[nsz*2],ifac[nsz*2],ninv[nsz*2];

ll qpow(ll a,ll b){
	ll res=1;
	while(b){
		if(b&1)res=res*a%nmod;
		b>>=1,a=a*a%nmod;
	}
	return res;
}
ll inv(ll a){return qpow(a,nmod-2);}
ll c(ll a,ll b){
	if(a<0||b<0||a<b)return 0;
	return fac[a]*ifac[b]%nmod*ifac[a-b]%nmod;
}

int main(){
	cin>>n>>m;
	if(n<m)swap(n,m);
	fac[0]=1;
	rep(i,1,n+m){
		fac[i]=fac[i-1]*i%nmod;
	}
	ifac[n+m]=inv(fac[n+m]);
	repdo(i,n+m-1,1){
		ifac[i]=ifac[i+1]*(i+1)%nmod;
		ninv[i]=fac[i-1]*ifac[i]%nmod;
	}
	ifac[0]=1;
	ll ans=0;	
	rep(i,1,m){
		ans=(ans+c(i*2,i)*c(n+m-i*2,n-i))%nmod;
	}
	ans=(ans*qpow(c(m+n,n)*2%nmod,nmod-2))%nmod;
	ans=(ans+n)%nmod;
	cout<<ans<<'\n';
    return 0;
}














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

using namespace std;

#define LL long long
#define DD double
#define Pb push_back
#define Bp pop_back
#define Pf push_front
#define Fp pop_front
#define Ub upper_bound
#define Lb lower_bound
#define In insert
#define All(x) x.begin(), x.end()
#define mem(a, b) memset(a, b, sizeof(a))
#define fast ios_base::sync_with_stdio(0);cin.tie(0)
#define X first
#define Y second
#define mx1 10
#define mx2 110
#define mx3 1010
#define mx4 10010
#define mx5 100010
#define mx6 1000010

typedef vector<LL> Vl;
typedef vector<DD> Vd;
typedef vector<bool> Vb;
typedef vector<Vl> VVl;
typedef pair<LL, LL> Pll;
typedef pair<DD, DD> Pdd;
typedef vector<Pll> Vpl;
typedef vector<Pdd> Vpd;
typedef queue<LL> Ql;
typedef stack<LL> Sl;
typedef deque<LL> Dl;

LL _set(LL N, LL pos) {return N = N | (1 << pos);}
LL _reset(LL N, LL pos) {return N = N & ~(1 << pos);}
bool _check(LL N, LL pos) {return (bool)(N & (1 << pos));}
bool _upper(char a) {return a >= 'A' && a <= 'Z';}
bool _lower(char a) {return a >= 'a' && a <= 'z';}
bool _digit(char a) {return a >= '0' && a <= '9';}

LL dx[] = {1, -1, 0, 0, -1, -1, 1, 1};
LL dy[] = {0, 0, 1, -1, -1, 1, -1, 1};

///**************************DONE****************************///

int main()
{
    int x[10];
    for(int i = 0; i < 5; i++){
        cin >> x[i];
        if(x[i] == 0)
            return cout << i + 1 << '\n', 0;
    }
    return 0;
}


Measured memory_bytes: 3564
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(long long i=0; i<(n); i++)
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }


int main(){
    ll n; cin >> n;
    vector<ll> x(n), y(n);
    rep(i, n){
        cin >> x[i];
        cin >> y[i];
    }
    if(n % 2 == 1) cout << "NA" << endl;
    else{
        double px = (x[0] + x[n / 2]) / 2.0, py = (y[0] + y[n / 2]) / 2.0;
        rep(i, n / 2) {
            double vx = (x[i] + x[i + n / 2]) / 2.0, vy = (y[i] + y[i + n / 2]) / 2.0;
            if(abs(px - vx) > 1e-10 || abs(py - vy) > 1e-10){
                cout << "NA" << endl;
                return 0;
            }
        }
        cout << fixed << setprecision(10) << px << ' ' << py << endl;
    }
    return 0;
}


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

using namespace std;

void solve(){
	int n;
	long long res=0;
	cin >> n;
	vector<int> height(n);
	for(int i=0;i<n;i++)
		cin >> height[i];
	for(int i=1;i<n;i++){
		if(height[i-1] > height[i]){
			res+=(height[i-1]-height[i]);
			height[i]=height[i-1];
		}
	}
	cout<<res<<"\n";	
}
int main(){
	ios::sync_with_stdio(false);
	solve();
	return 0;
}

Measured memory_bytes: 3984
#include "bits/stdc++.h"
using namespace std;
#define pb push_back
#define fi first
#define se second
#define FF first
#define SS second
#define mp make_pair
#define ll long long
#define pii pair<int,int>
#define sd(x) scanf("%d",&x)
#define slld(x) scanf("%lld",&x)
#define pd(x) printf("%d\n",x)
#define plld(x) printf("%lld\n",x)
#define endl '\n'
#define fr(i, a, b) for(int i = a; i <= b; i++)
#define sz(x) (int)x.size()
typedef long double f80;
#define all(x) x.begin(), x.end()

const int mod = 1e9 + 7;
vector<pii> v;
signed main()
{
    #ifdef LOCAL
        freopen("inp.txt", "r", stdin);
        freopen("out.txt", "w", stdout);
    #endif
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);
    int n, k;
    cin >> n >> k;
    if(k > ((n - 1) * (n - 2)) / 2)
        return cout << -1, 0;
    int val = ((n - 1) * (n - 2)) / 2;
    fr(i, 2, n) {
        v.pb({1, i});
    }
    fr(i, 2, n) {
        if(val != k)
        fr(j, i + 1, n) {
            if(val == k)
                break;
            val--;
            v.pb({i, j});
        }
    }
    cout << sz(v) << endl;
    for(pii x : v) {
        cout << x.fi << " " << x.se << endl;
    }
    return 0;
}

Measured memory_bytes: 384
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<map>
#include<queue>
#define inf1 1000000009
#define inf -1
using namespace std;
bool s[55556];
int s1[55556];int a;
void mm(){
    memset(s,true,sizeof(s));
    s[0]=s[1]=false;
 for(int i=2;i<=55555;i++)
 {
     if(s[i]){s1[a++]=i;}
    for(int j=2*i;j<=55555;j+=i)
    s[j]=false;
}}

int main(){
  mm();
  int t;
    cin>>t;
   for(int i=0;;i++){
    if(s1[i]%5==3) {t--;printf(t==0?"%d\n":"%d ",s1[i]);}
    if(t==0)break;

   }
}

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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N;
  cin >> N;
  int ans = 0;
  int tmp = 1;
  while(tmp * 2 <= N) {
    tmp *= 2;
  }
  cout << tmp << endl;

  return 0;
}

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

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 = 1LL << 60;

vector<ll> dp(100010, INF);

int main() {
    int n, m;
    cin >> n >> m;
    vector<int> c(m + 1);
    for (int i = 1; i <= m; i++) {
        scanf("%d", &c[i]);
    }
    dp[0] = 0;
    
    for (int i = 1; i <= m; i++) {
        for (int j = c[i]; j <= n; j++) {
            chmin(dp[j], dp[j - c[i]] + 1);
        }
    }

    cout << dp[n] << endl;

    return 0;
}


Measured memory_bytes: 3444
#include<bits/stdc++.h>
#include<chrono>
     
using namespace std;
using namespace std::chrono;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;
#define F first
#define S second
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define REP(i,a,b) for(i=a;i<=b;i++)
#define RAP(i,a,b) for(i=a;i>=b;i--)
ll mod=1000000007;

int main(){
    int n,i;
    cin>>n;
    string s;
    cin>>s;
    char ch[26];
    REP(i,0,25) ch[i]='A'+i;
    REP(i,0,s.size()-1)    s[i]=ch[(s[i]-'A'+n)%26];
    cout<<s<<"\n";
}	



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

#define int long long 
#define pb push_back
#define S second
#define F first
#define f(i,n) for(int i=0;i<n;i++)
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define vi vector<int>
#define pii pair<int,int>

const int N = 301;

double dp[N][N][N];

void solve()
{
  int n;
    cin >> n;
    
  int a[n];
   f(i,n) cin >> a[i];
    
 dp[0][0][0] = 0;
 
 for(int i=0;i<=n;i++)
     for(int j=0;j<=n;j++)
        for(int k=0;k<=n;k++)
 {
    if(i+j+k>n) continue;
    if(i==0 && j==0 && k==0) continue;
     
    dp[i][j][k] = n; 
     
    if(i>0) dp[i][j][k]+=(i*dp[i-1][j+1][k]); 
    if(j>0) dp[i][j][k]+=(j*dp[i][j-1][k+1]);
    if(k>0) dp[i][j][k]+=(k*dp[i][j][k-1]); 
    
    dp[i][j][k] /=(i+j+k); 
 }
 
 int p[4] = {0};
 
 f(i,n) p[a[i]]++;
    
 cout << fixed << setprecision(9) << dp[p[3]][p[2]][p[1]] << '\n';
    
}

signed main()
{
    fast;
    
    int t = 1;
    
//    cin >> t;
    
    while(t--)
        
    solve();
}

Measured memory_bytes: 213248
#include <iostream>
#include <vector>
#include <string>
#include <cstdlib>
#include<algorithm> 
#include <iomanip>

using namespace std;

int main(){
int h,w;
while(1){
cin>>h>>w;
if(h==0&&w==0)break;
for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
        cout<<"#";
    }
    cout<<endl;
}
cout<<endl;

}
}




Measured memory_bytes: 3092
function Main(input) {
  input = input.split(' ');
  var age = input[0];
  var few = input[1];
  if(age < 6){
   console.log(0);
  }else if (age > 12 ) {
   console.log(few);
  } else {
   console.log(few / 2);
  }
  
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 7372
import java.io.*;
import java.util.HashSet;
import java.util.StringTokenizer;

public class Main {

    public static void main(String[] args) throws IOException {
        init();
        int n = nextInt();
        HashSet<Integer> elements = new HashSet<>();
        for (int i = 0; i < n; i++) {
            elements.add(nextInt());
        }
        if (elements.size() == n) System.out.println("YES");
        else System.out.println("NO");
    }

    //Input Reader
    private static BufferedReader reader;
    private static StringTokenizer tokenizer;

    private static void init() {
        reader = new BufferedReader(new InputStreamReader(System.in));
        tokenizer = new StringTokenizer("");
    }

    private static String next() throws IOException {
        String read;
        while (!tokenizer.hasMoreTokens()) {
            read = reader.readLine();
            if (read == null || read.equals(""))
                return "-1";
            tokenizer = new StringTokenizer(read);
        }

        return tokenizer.nextToken();
    }

    private static int nextInt() throws IOException {
        return Integer.parseInt(next());
    }

    private static long nextLong() throws IOException {
        return Long.parseLong(next());
    }
}

Measured memory_bytes: 58432
#include <utility>
#include <vector>
#include <iostream>
#include <algorithm>
#include <set>
#define REP(i,n) for(int i=0;i<n;i++)
typedef unsigned long ul;
typedef unsigned long long ull;
typedef long long ll;
using namespace std;
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

int main() {
	cin.tie(0);
   	ios::sync_with_stdio(false);
    int N;
    vector<string> w;
    cin >> N;
    for (int i = 0; i < N; i++){
        string tmp;
        cin >> tmp;
        w.push_back(tmp);
    }
    
    string ans = "Yes";
    for(int i = 0; i < N; i++){
        for(int j = i+1; j < N; j++){
            if(w[i]==w[j]){
                ans = "No";
            }
        }
    }
    for(int i = 1; i < N; i++){
        if(w[i-1].at(w[i-1].length()-1)!=w[i].at(0)){
            ans = "No";
        }
    }
    cout <<ans <<endl;
    return 0;
}

Measured memory_bytes: 256
//B
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
	int x,y;
	cin >> x >> y;
	bool ok = 0;
	for(int i = 0;i <= x;i++){
		if(2*i + (x-i)*4 == y)ok = 1; 
	}
	if(ok)cout << "Yes";
	else cout << "No";
	return 0;
}


Measured memory_bytes: 3636
#include <iostream>

using namespace std;

int main()
{
	int n;
	cin>>n;
	int ans = 0;
	for(size_t i = 0; i<n; i++)
	{
		int a;
		cin>>a;
		if(a%2==0&&a%3!=0&&a%5!=0)
		{
			ans = 1;
		}
	}
	if(ans==0)
	{
		cout<<"APPROVED"<<endl;
	}
	else
	{
		cout<<"DENIED"<<endl;
	}
	return 0;
}

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

const int N = 1e5 + 10;
int col[N], n, v, u, w;
vector<pair<int, int> > g[N];

void dfs(int v, int p, long long h){
	col[v] = (h % 2);
	for (auto q : g[v])
		if(q.first != p)
			dfs(q.first, v, h + q.second);
}

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
	
	cin >> n;
	for (int i = 0; i + 1 < n; i++){
		cin >> v >> u >> w;
		v--;u--;
		
		g[v].push_back({u, w});
		g[u].push_back({v, w});
	}
	
	dfs(0, 0, 0);
	
	for (int i = 0; i < n; i++)
		cout << col[i] << '\n';
}

Measured memory_bytes: 8448
#define _GLIBCXX_DEBUG

#include <bits/stdc++.h>

#include <vector>
#include <cassert>
#include <algorithm>

using namespace std;

class Prim {
#define MAX_V 101

private:
  const int INF = 1e9 + 10;
  struct Edge {
    int to, cost;
    Edge(int to, int cost): to(to), cost(cost) { }
  };

  int V;
  vector<Edge> G[MAX_V];
  int mincost[MAX_V];
  bool used[MAX_V];

public:

  Prim(int V): V(V) { 
    if (V >= MAX_V) {
      assert(false);
    }
  }

  void AddEdge(int from, int to, int cost) {
    G[from].push_back(Edge(to, cost));
  }

  int Solve() {
    for (int i = 0; i < V; i++) {
      mincost[i] = INF;
      used[i]    = false;
    }

    mincost[0] = 0;
    int res = 0;

    while (true) {
      int v = -1;
      for (int u = 0; u < V; u++) {
        if (!used[u] && (v == -1 || mincost[u] < mincost[v])) {
          v = u;
        }
      }
      if (v == -1) {
        break;
      }
      used[v] = true;
      res += mincost[v];

      for (auto &e : G[v]) {
        mincost[e.to] = min(mincost[e.to], e.cost);
      }
    }

    return res;
  }
};

int main() {
  while (true) {
    int n, m;
    cin >> n;
    if (n == 0) {
      break;
    }
    cin >> m;
    Prim prim(n);
    for (int i = 0; i < m; i++) {
      int a, b, d;
      char s;
      cin >> a >> s >> b >> s >> d;
      prim.AddEdge(a, b, d);
      prim.AddEdge(b, a, d);
    }
    cout << prim.Solve() / 100 - (n - 1) << endl;
  }

  return 0;
}

Measured memory_bytes: 3156
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line;
		line = br.readLine();
		
		while(true){
			Map<String, Integer> itemMap = new HashMap<>();
			Map<String, List<String>> recipeMap = new HashMap<>();

			int n = Integer.valueOf(line);

			for(int i = 0; i < n; i++){
				line = br.readLine();
				String[] nums = line.split(" ");
				String s = nums[0];
				int p = Integer.valueOf(nums[1]);
				itemMap.put(s, p);
			}

			line = br.readLine();
			int m = Integer.valueOf(line);
			
			for(int i = 0; i < m; i++){
				line = br.readLine();
				String[] nums = line.split(" ");
				String o = nums[0];
				
				List<String> list = new ArrayList<>();
				
				int k = Integer.valueOf(nums[1]);
				for(int j = 2; j < k + 2; j++){
					String p = nums[j];
					list.add(p);
				}
				recipeMap.put(o, list);
			}

			line = br.readLine();
			String t = line;
			System.out.println(getCost(itemMap, recipeMap, t));
			

			line = br.readLine();
			if(line.equals("0")){
				break;
			}
			
		}
		
	}
	
	private static int getCost(Map<String, Integer> itemMap, Map<String, List<String>> recipeMap, String t){
		int min = itemMap.get(t);
		int cost = 0;
		
		List<String> itemList = recipeMap.get(t);
		if(itemList == null){
			return min;
		}
		
		for(String item : itemList){
			cost += getCost(itemMap, recipeMap, item);
		}
		
		if(min > cost){
			return cost;
		}else{
			return min;
		}
	}
}

Measured memory_bytes: 25452
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Runtime.Remoting;
using System.Runtime.Remoting.Contexts;
using System.Text;
using System.Threading;
using System.Xml.Schema;

namespace Contest
{
    class Scanner
    {
        private string[] line = new string[0];
        private int index = 0;

        public string Next()
        {
            if (line.Length <= index)
            {
                line = Console.ReadLine().Split(' ');
                index = 0;
            }

            var res = line[index];
            index++;
            return res;
        }

        public int NextInt()
        {
            return int.Parse(Next());
        }

        public long NextLong()
        {
            return long.Parse(Next());
        }

        public ulong NextUlong()
        {
            return ulong.Parse(Next());
        }

        public string[] Array()
        {
            line = Console.ReadLine().Split(' ');
            index = line.Length;
            return line;
        }

        public int[] IntArray()
        {
            var array = Array();
            var result = new int[array.Length];
            for (int i = 0; i < array.Length; i++)
            {
                result[i] = int.Parse(array[i]);
            }

            return result;
        }

        public long[] LongArray()
        {
            var array = Array();
            var result = new long[array.Length];
            for (int i = 0; i < array.Length; i++)
            {
                result[i] = long.Parse(array[i]);
            }

            return result;
        }
    }

    class Program
    {
        private string D;
        private void Scan()
        {
            var sc = new Scanner();
            D = sc.Next();
        }

        public void Solve()
        {
            Scan();
            if (D == "25")
            {
                Console.WriteLine("Christmas");
            }
            else if (D == "24")
            {
                Console.WriteLine("Christmas Eve");
            }
            else if (D == "23")
            {
                Console.WriteLine("Christmas Eve Eve");
            }
            else if (D == "22")
            {
                Console.WriteLine("Christmas Eve Eve Eve");
            }
        }

        static void Main() => new Program().Solve();
    }


}

Measured memory_bytes: 11092
#include <cstdio>
#include <cstring>
#include <vector>
#include <queue>
#include <string>
#include <algorithm>
#include <iostream>
#include <string>
#include <map>
#include <set>
#include <functional>
#include <iostream>
#define MOD 1000000007LL
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

struct edge{
	int f,t;
	int c,d;
	double cost;
	edge(){}
	bool operator<(const edge &e)const{
		return cost<e.cost;
	}
};

int n,m;
edge e[100001];
int par[10001],rank[10001];

int find(int x){
	if(par[x]==x){
		return x;
	}else{
		return par[x]=find(par[x]);
	}
}

void unite(int x,int y){
	x=find(x);
	y=find(y);
	if(x==y)return;
	if(rank[x]<rank[y]){
		par[x]=y;
	}else{
		par[y]=x;
		if(rank[x]==rank[y])rank[x]++;
	}
}

bool same(int x,int y){
	return find(x)==find(y);
}

bool C(double x){
	for(int i=0;i<m;i++){
		e[i].cost=(double)e[i].c*x-e[i].d;
	}
	sort(e,e+m);
	double res=0.0;
	for(int i=0;i<n;i++){
		par[i]=i;
		rank[i]=0;
	}
	for(int i=0;i<m;i++){
		if(!same(e[i].f,e[i].t)){
			unite(e[i].f,e[i].t);
		}else res+=e[i].cost;
	}
	return res>=0.0;
}

int main(void){
	scanf("%d%d",&n,&m);
	for(int i=0;i<m;i++){
		scanf("%d%d%d%d",&e[i].f,&e[i].t,&e[i].c,&e[i].d);
	}
	double l=0.0,r=1000000.0;
	for(int i=0;i<100;i++){
		double mid=(l+r)/2;
		if(C(mid))r=mid;
		else l=mid;
	}
	printf("%.9f\n",r);
	return 0;
}

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

#define pb push_back
#define ss second
#define ff first
#define N 1000006
#define inf 1000000009
#define ll long long
#define mid(a,b) (a+b)/2
#define pii pair<int,int>

using namespace std;

const int mod = 1e9+7;
int a[N],lc[N],x,cnt,n;
ll ans,jog,l;
bool b[N];
vector <int> v;

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

int main()
{
	scanf("%d",&n);
	for(int i = 1;i <= n;i++){
		scanf("%d",&a[i]);
		x = a[i];
		for(int j = 2;j * j <= x;j++){
			cnt = 0;
			while(x % j == 0){
				cnt++;
				x /= j;
			}
			lc[j] = max(lc[j],cnt);
		}
		if(x > 1 and lc[x] == 0) lc[x] = 1;
	}
	l = 1;
	for(int i = 2;i <= 1e6;i++)
		if(lc[i]) l = (l * pw(i,lc[i])) % mod;
	for(int i = 1;i <= n;i++){
		ans = (ans + (l * pw(a[i],mod - 2)) % mod) % mod;
	}
	printf("%lld",ans);
}

Measured memory_bytes: 5376
#include<cstdio>
#include<cstdlib>
#include<algorithm>

using namespace std;

int n;
int a[100000];

int main() {
    scanf("%d", &n);
    for(int i = 0; i < n; ++i) {
        scanf("%d", a+i);
    }
    sort(a, a+n);
    printf("%d ", a[n-1]);
    int t = 0;
    int diff = abs(a[n-1]-a[0]*2);
    for(int i = 1; i < n; ++i) {
        int diff2 = abs(a[n-1]-a[i]*2);
        if(diff > diff2) {
            diff = diff2;
            t = i;
        }
    }
    printf("%d\n", a[t]);
    return 0;
}


Measured memory_bytes: 512
// Aaradhya Beri
#pragma GCC optimze("Ofast")
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define pb push_back
#define fi first
#define se second
typedef long long ll;
typedef long double f80;
#define double long double
#define pii pair<int,int>
#define pll pair<ll,ll>
#define sz(x) ((long long)x.size())
#define fr(a,b,c) for(int a=b; a<=c; a++)
#define rep(a,b,c) for(int a=b; a<c; a++)
#define trav(a,x) for(auto &a:x)
#define all(con) con.begin(),con.end()
#define w(x) int x; cin>>x; while(x--)
const ll infl=0x3f3f3f3f3f3f3f3fLL;
const int infi=0x3f3f3f3f;
//const int mod=998244353;
const int mod=1000000007;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<bool> vb;

int powm(int a, int b) {
    int res=1;
    while(b) {
        if(b&1)
            res=(res*a)%mod;
        a=(a*a)%mod;
        b>>=1;
    }
    return res;
}
 

signed main() {
    ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
    cout<<fixed<<setprecision(8);
    int a,b;
    cin>>a>>b;
    cout<<(a*b)<<endl;
    return 0;
}

Measured memory_bytes: 3596
#include <iostream>
#include <unordered_map>
#include <vector>

inline long long gcd(long long a, long long b)
{
    if (!a) {
        return b;
    }
    if (!b) {
        return a;
    }
    return gcd(b, a % b);
}

int main()
{
    int n;
    std::cin >> n;
    std::vector<int> a(n);
    for (int i = 0; i < n; i++) {
        std::cin >> a[i];
    }

    long long l[n + 1] = { 0 }, r[n + 1] = { 0 };

    for (int i = 1; i <= n; i++) {
        l[i] = gcd(l[i - 1], a[i - 1]);
    }

    for (int i = n - 1; i >= 0; i--) {
        r[i] = gcd(r[i + 1], a[i]);
    }

    long long ans = 0;
    for (int i = 0; i < n; i++) {
        ans = std::max(ans, gcd(l[i], r[i + 1]));
    }

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


Measured memory_bytes: 2176
#include <stdio.h>

int main(void){
  
  int s[4],s2[4],i,sum=0,sum2=0;
  
  scanf("%d %d %d %d",&s[0],&s[1],&s[2],&s[3]);
  scanf("%d %d %d %d",&s2[0],&s2[1],&s2[2],&s2[3]);
  
  for(i=0;i<4;i++){
    sum += s[i];
    sum2 += s2[i];
  }
  
  if(sum>sum2) printf("%d\n",sum);
  else printf("%d\n",sum2);
  
  return 0;
}

Measured memory_bytes: 592
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <time.h>
#include <assert.h>
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <fstream>
#include <stack>
#include <queue>
#include <map>
#include <set>

using namespace std;

typedef long long ll;

const int MAXN = 100005;

int x,y,z;

ll ans,tot,sum;
ll v1[MAXN];
ll v2[MAXN];

pair<int,int> v[MAXN];
priority_queue<int> Q;

bool cmp(const pair<int,int> &a,const pair<int,int> &b)
{
	return a.first - a.second < b.first - b.second;
}

int main()
{
	scanf("%d%d%d",&x,&y,&z);
	for (int c,i = 1;i <= x + y + z;i++)
	{
		scanf("%d%d%d",&v[i].first,&v[i].second,&c);
		tot += c;
		v[i].first -= c;
		v[i].second -= c;
	}
	sort(v + 1,v + x + y + z + 1,cmp);
	for (int i = 1;i <= y;i++)
	{
		sum += v[i].second;
		Q.push(-v[i].second);
	}
	v1[y] = sum;
	for (int i = y + 1;i <= x + y + z;i++)
	{
		sum += v[i].second;
		Q.push(-v[i].second);
		sum += Q.top();
		Q.pop();
		v1[i] = sum;
	}
	sum = 0;
	while (!Q.empty())
		Q.pop();
	for (int i = x + y + z;i >= y + z + 1;i--)
	{
		sum += v[i].first;
		Q.push(-v[i].first);
	}
	v2[y + z + 1] = sum;
	for (int i = y + z;i >= 1;i--)
	{
		sum += v[i].first;
		Q.push(-v[i].first);
		sum += Q.top();
		Q.pop();
		v2[i] = sum;
	}
	ans = -1e18;
	for (int i = y;i <= y + z;i++)
		ans = max(ans,v1[i] + v2[i + 1]);
	printf("%lld\n",ans + tot);
	return 0;
}

Measured memory_bytes: 2560
#include <iostream>
#include <queue>
#include <algorithm>
#include <utility>
#include <cmath>
#include <map>

using namespace std;

int main(void) {
    int h,w,d,a[300][300],l,r,cs[300*300+1];
    map<int,pair<int,int>> v;
    cin >> h >> w >> d;
    for(int i = 0;i < h;i++) {
        for(int j =0;j < w;j++) {
            cin >> a[i][j];
            v.insert(make_pair(a[i][j],make_pair(i,j)));
        }
    }
    for(int i = 1;i <= h*w-d;i++) {
        auto itr0 = v.find(i);
        auto itr1 = v.find(i+d);
        pair<int,int> vv[2] = {itr0->second,itr1->second};
        cs[i+d] = cs[i] + abs(vv[0].first - vv[1].first) + abs(vv[0].second - vv[1].second);
    }
    int q;
    cin >>q;
    for(int i = 0;i < q;i++) {
        cin >> l >> r;
        cout << cs[r] - cs[l] << endl;
    }
    return 0;
}

Measured memory_bytes: 7424
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<vector>
#include<string.h>
#include<math.h>
#include<map>
#include<iomanip>

#define MOD 1e9+7;
#define INF 1e17+9;
#define PI acos(-1);

using namespace std;

int main(){
	int n;
	cin >> n;
	vector<long long> h(n),s(n-1,0);
	if(n==1){
		cout << "Yes" << endl;
		return 0;
	}
	for(int i=0;i<n;i++){
		cin >> h[i];
	}
	for(int i=1;i<n;i++){
		s[i-1]=h[i]-h[i-1];
	}
	int cnt=0;
	for(int i=0;i<s.size();i++){
		if(s[i]<=-2){
			cout << "No" << endl;
			return 0;
		}
		if(s[i]==-1)cnt++;
		if(cnt>=2){
			cout << "No" << endl;
			return 0;
		}
		if(s[i]>=1)cnt=0;			
	}
	cout << "Yes" << endl;
	return 0;
}


Measured memory_bytes: 1792
def f(n)
    if n % 2 == 0 then 
        return n/2
    else 
        return 3*n+1
    end
end

a = []
a[0] = 0
a[1] = gets.chomp!.to_i
i = 1
while 1 do
    #puts f(a[i])
    i+=1
    a << f( a [i-1] )
    if a.count( a [i] ) == 2 then
        puts a.length-1
        break
    end
end

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

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

#define rep(i, n) for (int i = 0; i < n; i++)
#define rep_op(i, a, n) for (int i = a; i < n; i++)
#define rep_d(j, n) for (int j = n; j >= 0; j--)
#define rep_d_op(j, n, a) for (int j = n; j >= a; j--)

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 int MOD = 1000000007;

const vector<int> dx = {1, 0};
const vector<int> dy = {0, 1};
const ll INF = 1LL << 60;

// int min = *max_element(vec.begin(), vec.end());
// int max = *max_element(vec.begin(), vec.end());
// int sum = accumulate(a.begin(), a.end(), 0);

int GCD(int a, int b) { return b ? GCD(b, a % b) : a; }

bool is_prime(int x)
{
    if (x <= 1)
    {
        return false;
    }
    for (int i = 2; i * i <= x; i++)
    {
        if (x % i == 0)
        {
            return false;
        }
    }
    return true;
}

int main()
{
    ll h;
    cin >> h;
    ll ans = 1;
    while (h > 0)
    {
        h = h / 2;
        ans *= 2;
    }
    cout << ans - 1 << endl;
}


Measured memory_bytes: 256