akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define ull unsigned long long
#define ll long long
#define F first
#define S second
#define pss pair<string,string>
#define pcc pair<char,char>
#define pll pair<ll,ll>
#define pii pair<int,int>
#define piii pair<int,pii>
#define vi vector<int>
#define vii vector<pii>
#define pb push_back
#define vs vector<string>
#define vl vector<ll>
#define vs vector<string>
#define vll vector<pll>
#define vss vector<pss>
#define vcc vector<pcc>
#define MP make_pair
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=n-1;i>=0;i--)
#define Very_fast std::ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
const int N = 2e5+5;
const int mod=1e9+7;
const int INF=0x3f3f3f3f;
inline ll gcd(ll a,ll b){if(b==0)return a;else return gcd(b,a%b);}
inline ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
inline ll lowbit(ll x){return (x&-x);}
inline ll kissme(ll x,ll y)
{
	ll res=1;
	if(x==0)return 1;
	if(x==1)return y;
	res=kissme(x/2,y);
	res=res*res%mod;
	if(x%2==1)res=res*y%mod;
	return res;
}
void read(int &x)
{
    int f=1;
    x=0;
    char s=getchar();
    while(s<'0'||s>'9')
    {
        if(s=='-')
            f=-1;
        s=getchar();
    }
    while(s>='0'&&s<='9')
    {
        x=x*10+s-'0';
        s=getchar();
    }
    x*=f;
}
void print(int x)
{
    if(x<0)putchar('-'),x=-x;
    if(x>9)print(x/10);
    putchar(x%10+'0');
}
int n,x[N]; 
ll ans;
signed main()
{
	Very_fast;
	cin>>n;
	for(int i=0;i<n;i++)cin>>x[i];
	sort(x,x+n);
	n--;int cnt=n-1;
	ans+=x[n];
	while(cnt>=2)
	{
		cnt-=2;
		n--;
		ans+=x[n]*2;
	}
	if(cnt)
	{
		ans+=x[n-1];
	}
	cout<<ans<<"\n";
	return 0;
}

Measured memory_bytes: 4396
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for(int i=0;i<(int)n;i++)
ll mod=1e9+7;
#define PI acos(-1)
struct edge{int from, to;};

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

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

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

using ll = long long;
using vll = vector<ll>;
using vvll = vector<vll>;
using P = pair<ll, ll>;

const ll INF = (1LL<<60);

int main(){

    ll n; cin >> n;
    vll a(n), b(n), c(n-1);
    rep(i, n) cin >> a[i];
    rep(i, n) cin >> b[i];
    rep(i, n-1) cin >> c[i];

    ll ans = b[0];
    rep2(i, 1, n){
        if(a[i]-a[i-1] == 1) ans += c[a[i-1]-1];
        ans += b[i];
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
N = gets.to_i
A = gets.split.map(&:to_i)
B = gets.split.map(&:to_i)

ret = 0
monsters = A[0]
N.times do |i|
  if monsters > B[i]
    monsters = A[i + 1]
    ret += B[i]
    next
  end
    
  power = B[i] - monsters
  ret += monsters
  if A[i + 1] <= power
    monsters = 0
    ret += A[i + 1]
  else
    monsters = A[i + 1] - power
    ret += power
  end
end
puts ret

Measured memory_bytes: 15380
#include <stdio.h>
int main(int argc, char const *argv[])
{
  int a;
  scanf("%d",&a);
  char b[a];
  scanf("%s",b);
  if(a%2!=0){
    printf("No");
    return (0);
  }
  for(int i=0;i<a/2;i++){
    if(b[i]!=b[i+a/2]){
      printf("No");
      return (0);
    }
  }
  printf("Yes");
  return (0);
}

Measured memory_bytes: 128
#input = raw_input

n, m = map(int, input().split(" "))

graph = {}
for node in range(1, n+1):
    graph[node] = []

for i in range(m):
    a, b = map(int, input().split(" "))
    graph[a].append(b)
    graph[b].append(a)

#print("graph", graph)

michi = [None] * (n+1)
uses = [False] * (n+1)

def set(x):
    return x

uses[1] = True

cur_node = 1
cur_nodes = {}
child_nodes = graph[cur_node]
for child_node in child_nodes:
    cur_nodes[child_node] = cur_node
depth = 1
while True:
    next_nodes = {}
    done = False
    for cur_node, pnode in cur_nodes.items():
        if not uses[cur_node]:
            michi[cur_node] = pnode
            uses[cur_node] = True
            for child_node in graph[cur_node]:
                if child_node == pnode or uses[child_node]:
                    continue
                next_nodes[child_node] = cur_node
            done = True

    if not done:
        break
    depth += 1
    cur_nodes = next_nodes
    #print("michi", michi[1:])

michi = michi[2:]
if None in michi:
    print("No")
else:
    print("Yes")
    for node in michi:
        print(node)

Measured memory_bytes: 48896
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
	string str;
	char ch='a',temp='a';
	cin>>str;
	sort(str.begin(),str.end());
	for(int i=0;ch<='z';)
	{
		if(str[i]==ch)
		{
			if(str[i+1]!=ch)
			ch++;
			i++;
		}
		else 
		{
			cout<<ch<<endl;
			return 0;
		}
	}
	cout<<"None\n";
}

Measured memory_bytes: 512
from collections import defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue,copy,time
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inp(): return int(input())
def inpl(): return list(map(int, input().split()))
def inpl_str(): return list(input().split())

mod = 2019
L,R = inpl()
Lm,Rm = L%mod, R%mod

if Lm < Rm and L//mod == R//mod:
    ans = INF
    for x in range(Lm,Rm+1):
        for y in range(x+1,Rm+1):
            ans = min(ans,x*y%mod)
    print(ans)
else:
    print(0)


Measured memory_bytes: 4456
#include <stdio.h>
#include <cmath>

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define FOR(i, n) for (int i = 0; i < int(n); i++)
#define FOR1(i, m, n) for (int i = int(m); i < int(n); i++)
#define MAX(a, b) ((a) >= (b) ? (a) : (b))
#define MIN(a, b) ((a) <= (b) ? (a) : (b))

int main(int argc, char *argv[argc])
{
  long double X, Y;

  scanf("%Lf%Lf", &X, &Y);

  int N = log2(Y / X) + 1;
  printf("%d\n", N);
  
  return 0;
}


Measured memory_bytes: 512
#include <vector>
#include <cstdio>
#include <cstring>
#include <cassert>
#include <iostream>
#include <algorithm>

using namespace std;

const int N = 50 + 5;
const int MOD = (int)1e9 + 7;

int n;
long long f[N][N + N];
long long binom[N][N];

void solve()
{

    binom[0][0] = 1;
    for (int i = 1; i < N; i++) {
        binom[i][0] = 1;
        for (int j = 1; j <= i; j++) {
            binom[i][j] = (binom[i - 1][j] + binom[i - 1][j - 1]) % MOD;
        }
    }
    f[1][0 + N] = 1;
    f[1][-1 + N] = 1;

    for (int i = 1; i < 50; i++) {
        for (int j = -i; j <= i; j++) {
            if (f[i][j + N] == 0) continue;
            for (int ni = 1; ni <= 50; ni++) {
                if (i + ni > 50) continue;
                if (ni < abs(j)) continue;
                if ((ni + j) % 2) continue;
                for (int pos = 0; pos <= ni; pos++) {
                    int neg = ni - pos;
                    assert((j + pos - neg) % 2 == 0);
                    int nj = (j + pos - neg) / 2;
                    if (nj < -50 || nj > 50) continue;
                    (f[i + ni][nj + N] += f[i][j + N] * binom[i + ni][ni] % MOD * binom[ni][pos] % MOD) %= MOD;
                }
            }
        }
    }

    cin >> n;
    cout << f[n][0 + N] << endl;
}

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



Measured memory_bytes: 256
// Drawing heavily from 2579705 by vjudge2
// http://judge.u-aizu.ac.jp/onlinejudge/review.jsp?rid=2579705#1
#include <algorithm>
#include <iostream>
#include <set>
#include <vector>
using namespace std;

#define NMAX 500010

int dim = 0, tree_idx = 1;

struct Point {
  int xy[2], id, left, right;
  bool operator<(const Point &other) const { return xy[dim] < other.xy[dim]; }
} P[NMAX], tree[NMAX];
istream &operator>>(istream &is, Point &p) { return is >> p.xy[0] >> p.xy[1]; }

int Build(int L, int R, int d) {
  int M = (L + R) / 2;
  dim = d;
  nth_element(P + L, P + M, P + R + 1); // now, P + M is the median of P+L...P+R
  int curr = ++tree_idx;
  tree[curr] = P[M]; // store values at internal nodes, too
  if (L < M)
    tree[curr].left = Build(L, M - 1, !d);
  if (R > M)
    tree[curr].right = Build(M + 1, R, !d);
  //  cout << "Built " << curr << " (" << tree[curr].xy[0] << ", "
  //       << tree[curr].xy[1] << ") " << tree[curr].left << " " <<
  //       tree[curr].right
  //       << endl;
  return curr;
}

void Find(int curr, int d, int x1, int x2, int y1, int y2, set<int> &res) {
  //  cout << "Find " << curr << " " << d << endl;
  if (curr == 0)
    return;
  if (tree[curr].xy[0] >= x1 and tree[curr].xy[0] <= x2 and
      tree[curr].xy[1] >= y1 and tree[curr].xy[1] <= y2) {
    //    cout << "Match at " << curr << endl;
    res.insert(tree[curr].id);
  }
  if (d == 0) {
    if (x1 <= tree[curr].xy[0]) {
      Find(tree[curr].left, !d, x1, x2, y1, y2, res);
    }
    if (x2 >= tree[curr].xy[0]) {
      Find(tree[curr].right, !d, x1, x2, y1, y2, res);
    }
  } else {
    if (y1 <= tree[curr].xy[1]) {
      Find(tree[curr].left, !d, x1, x2, y1, y2, res);
    }
    if (y2 >= tree[curr].xy[1]) {
      Find(tree[curr].right, !d, x1, x2, y1, y2, res);
    }
  }
}

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  int n, q, x1, x2, y1, y2;
  cin >> n;
  for (int i = 0; i < n; ++i) {
    P[i].id = i;
    cin >> P[i];
  }
  int root = Build(0, n - 1, 0);
  set<int> res;
  cin >> q;
  while (cin >> x1 >> x2 >> y1 >> y2) {
    res.clear();
    Find(root, 0, x1, x2, y1, y2, res);
    for (int x : res)
      cout << x << endl;
    cout << endl;
  }
}



Measured memory_bytes: 22092
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cstring>
#include <math.h>
#include <numeric>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define drep(i,n) for (int i = n; i >= 0; --i)
#define all(x) (x).begin(),(x).end()
#define RALL(a) (a).rbegin(), (a).rend()
using namespace std;
typedef long long ll;

int gcd(int a, int b)
{
   if (a%b == 0) return(b);
   else          return(gcd(b, a%b));
}
int lcm(int a, int b)
{
   return a * b / gcd(a, b);
}
void printvv(vector<vector<auto>> vv, int n)
{
  cout << '[' << endl;
  rep(q, n)
  {
    cout << '[';
    rep(p, n)
    {
      cout << vv.at(q).at(p) << ',';
    }
    cout << ']' << endl;
  }
  cout << ']' << endl;
}


//------------------------------------------------------------
int main() {
  vector<vector<int>> vv(3, vector<int>(3)), nv(3, vector<int>(3, 0));
  rep(i, 3) rep(j, 3) cin >> vv.at(i).at(j);

  int flag=1;

  rep(i, *min_element(all(vv.at(0)))+1)
  {
    rep(j, 3) nv.at(0).at(j) = vv.at(0).at(j)-i;
    rep(j, *min_element(all(vv.at(1)))+1)
    {
      rep(k, 3) nv.at(1).at(k) = vv.at(1).at(k)-j;
      if (nv.at(0).at(0)==nv.at(1).at(0) && nv.at(0).at(1)==nv.at(1).at(1) && nv.at(0).at(2)==nv.at(1).at(2))
      {
        rep(k, *min_element(all(vv.at(2)))+1)
        {
          rep(l, 3) nv.at(2).at(l) = vv.at(2).at(l)-k;
          if (nv.at(1).at(0)==nv.at(2).at(0) && nv.at(1).at(1)==nv.at(2).at(1) && nv.at(1).at(2)==nv.at(2).at(2))
          {flag=0;}
        }
      }
    }
    if(flag==0) break;
  }

  if (flag==0) cout << "Yes" << endl;
  else cout << "No" << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <random>
#include <chrono>
#include <string>
#include <cstring>
#include <bitset>
#include <cassert>
#include <queue>
#include <deque>
#include <memory>

//#pragma comment(linker, "/STACK:16777216")
//#pragma GCC optimize("O3")
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC optimize("unswitch-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,sse4.1,sse4.2,abm,mmx,avx,avx2,popcnt,tune=native")

using namespace std;

mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());

#define ll long long
#define ull unsigned long long
//#define double long double
//#define int ll
//#define int ull
//#define int short
//#define int unsigned short
//#define int unsigned int
#define mp make_pair
#define F first
#define S second
#define pii pair<int, int>
#define hash hash228
const int SZ = 1e5 + 4;
const double EPS = 1e-3;
const int mod = 1e9 + 7;
const int hashpow = 2;
const int inf = 2e9;

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

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

int n, m;
vector<int> g[SZ];

inline void read() {
    cin >> n >> m;
    for (int i = 0; i < m; ++i) {
        int u, v;
        cin >> u >> v;
        --u, --v;
        g[u].push_back(v);
        g[v].push_back(u);
    }
}

pair<vector<int>, vector<int>> bfs(int u) {
    vector<int> d(n, inf);
    vector<int> p(n, -1);
    d[u] = 0;
    vector<char> used(n, false);
    used[u] = true;
    queue<int> q;
    q.push(u);
    while (!q.empty()) {
        u = q.front();
        q.pop();
        for (int v : g[u]) {
            if (!used[v]) {
                d[v] = d[u] + 1;
                p[v] = u;
                used[v] = true;
                q.push(v);
            }
        }
    }
    return mp(d, p);
}

inline void solve() {
    auto [d, p] = bfs(0);
    cout << "Yes\n";
    for (int i = 1; i < n; ++i) {
        cout << p[i] + 1 << "\n";
    }
}

signed main() {

#ifdef __LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#else
    ios_base::sync_with_stdio(0);
    cin.tie(0);
#endif

//    int t;
//    cin >> t;
//    for (int i = 0; i < t; ++i) {
        read();
        solve();
//    }

    return 0;
}

Measured memory_bytes: 11416
#include<iostream>
using namespace std;
int main() {
    int N,L,t;
    cin >> N >> L;
    int a=0,top=0,last=0,zero=0;
    for (int i=1; i<=N; i++) {
        t = L+i-1;
        if (i == 1) top = t;
        else if (i == N) last = t;
        else if (t == 0) zero = 1;
        a += t;
    }
    if (zero == 0 && a > 0) a -= top;
    else if (zero == 0 && a < 0) a -= last;
    cout << a << endl;
    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
int main()
{
	int d;scanf("%d",&d);
	if(d==22) printf("Christmas Eve Eve Eve");
	else if(d==23) printf("Christmas Eve Eve");
	else if(d==24) printf("Christmas Eve");
	else if(d==25) printf("Christmas");
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n);i++)
#define sz(x) int(x.size())
typedef long long ll;
typedef pair<int,int> P;

int main(){
  int N;
  cin >> N;
  int cnt = 0;
  for (int i = 1; i <= N; i++) {
    if(i & 1) cnt++;
  }
  double res = (double)cnt/N;
  printf("%.12f\n",res);
  return 0;
}

Measured memory_bytes: 256
n = int(input())
L = list(map(int,input().split()))
mod = 10**9+7
from fractions import gcd
import functools
def lcm(x,y):
    return (x * y) // gcd(x, y)
def lcmL(L):
    return functools.reduce(lcm,L)
a = lcmL(L)

sum1 = 0
for i in range(n):
    sum1+=a//L[i]
print(sum1%mod)

Measured memory_bytes: 5576
#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

char* add(const char* a, const char* b)
{
    int sizeA, sizeB, sizeX;
    int A, B, C;
    char* x;
    char* t;
    int la, lb, lx;
    C = 0;
    sizeA = strlen(a);
    sizeB = strlen(b);
    sizeX = (sizeA > sizeB ? sizeA : sizeB)+1;
    x = (char*)calloc(sizeX, 1);
    la = sizeA - 1;
    lb = sizeB - 1;
    lx = sizeX - 1;
    
    while(lx >= 0){
        A = la >= 0 ? a[la] - '0' : 0;
        B = lb >= 0 ? b[lb] - '0' : 0;
        x[lx] = '0' + (A + B + C) % 10;
        C = (A + B + C) / 10;
        la--;
        lb--;
        lx--;
    }
    if (*x == '0'){
        t = (char*)calloc(sizeX - 1, 1);
        strcpy(t, x + 1);
        free(x);
        return t;
    }
    return x;
}
int main()
{
    int i;
    int N;
    char first[101];
    char second[101];
    char* result;
    scanf("%d", &N);
    for(i = 0; i < N; ++i){
        scanf("%s", first);
        scanf("%s", second);
        if(strlen(first) > 80
        || strlen(second) > 80){
            printf("overflow\n");
            continue;
        }
        result = add(first, second);
        if(strlen(result) <= 80){
            printf("%s\n", result);
        }else{
            printf("overflow\n");
        }
        free(result);
    }
    return 0;
}

Measured memory_bytes: 1608
#include <bits/stdc++.h> 
using namespace std;
//関数
const long INF=1000000000000000;
const long MOD=1000000007;
bool check=false;


int main(void){
    string s;
    cin>>s;
    
    for(int i=0;i<s.size();i++){
        cout<<"x";
    }
    cout<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const long long N = 2e5+5 , M = 998244353, OO = 0x3f3f3f3f;
typedef long long ll;
#define FIO ios_base::sync_with_stdio(0);cin.tie(0);
const double Pii = 3.14159265359;
ll n;
ll a[N], b[N];

int main()
{
    FIO
    cin >> n;
    for(int i=0; i<n; ++i) cin >> a[i] >> b[i];
    sort(a, a+n);
    sort(b, b+n);
    if(n%2 == 1) cout << b[n/2]-a[n/2]+1 << endl;
    else cout << b[n/2-1]+b[n/2]-a[n/2-1]-a[n/2]+1 << endl;
    return 0;
}


Measured memory_bytes: 6780
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <string>
#include <vector>

using namespace std;

typedef long long ll;

int main() {
	ios::sync_with_stdio(0);
	ll ans = 1;
	ll x, y;
	cin >> x >> y;
	ll tmp = x;
	while (x * 2 <= y) {
		x *= 2;
		ans++;
	}
	cout << ans;
	//system("pause");
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define SORT(a) sort(a.begin(), a.end())
#define REVERSE(a) reverse(a.begin(), a.end())
#define int long long
#define INF 1000000000000000
using namespace std;

typedef vector<int> vec;
typedef vector<vec> mat;
typedef pair<int, int> Pii;

template<typename T>
void readvec(vector<T> &a);
void readindex(vector<int> &a);



signed main(){

    int N, M; cin >> N >> M;
    vector<bool> from1(N, false), toN(N, false);
    int a, b;
    REP(i, M){
        cin >> a >> b;
        if(a == 1) from1[b] = true;
        if(b == N) toN[a] = true;
    }
    string ans = "IMPOSSIBLE";
    FOR(i, 2, N){
        if(from1[i] && toN[i]) ans = "POSSIBLE";
    }

    cout << ans;
    
    return 0;
}


template<typename T>
void readvec(vector<T> &a){
    REP(i, a.size()){
        cin >> a[i];
    }
}
void readindex(vector<int> &a){
    REP(i, a.size()){
        cin >> a[i];
        a[i]--;
    }
}

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

int main() {
  int n, result = 0;
  cin >> n;
  while (n--) {
    int x;
    scanf("%d", &x);
    if (x & 1) {
      result = 1;
    }
  }
  puts(result ? "first" : "second");

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
using namespace std;
int main()
{
	int n;
	double m[10];
	char coin[10][5];
	cin >> n;
	for (int i = 1; i <= n; i++)
		cin >> m[i] >> coin[i];
	double sum = 0;
	for (int i = 1; i <= n; i++)
	{
		if (strcmp(coin[i], "JPY") == 0)
			sum = sum + m[i];
		else sum = sum + m[i] * 380000;
	}
	
	cout << sum;
}

Measured memory_bytes: 256
//written by NewbieChd
#include <cstdio>
#include <cctype>
#include <algorithm>
using namespace std;

const int BUF = 1000000;
char buf[BUF], *p1, *p2;
inline char getChar() { return p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, BUF, stdin), p1 == p2) ? EOF : *p1++; }
inline int read() {
    register int f = 0;
    register char c;
    while (!isdigit(c = getChar())) {}
    do
        f = f * 10 + (c ^ 48);
    while (isdigit(c = getChar()));
    return f;
}

const int N = 100003;
inline int gcd(int x, int y) { return y ? gcd(y, x % y) : x; }

struct Segtree {
    int f[N << 2];
    #define lSon (k << 1)
    #define rSon (k << 1 | 1)
    #define mid ((l + r) >> 1)
    inline void pushup(int k) { f[k] = gcd(f[lSon], f[rSon]); }
    void build(int k, int l, int r) {
        if (l == r) {
            f[k] = read();
            return ;
        }
        build(lSon, l, mid), build(rSon, mid + 1, r), pushup(k);
    }
    int query(int k, int l, int r, int x, int y) {
        if (x <= l && r <= y)
            return f[k];
        register int o = 0;
        if (x <= mid)
            o = gcd(query(lSon, l, mid, x, y), o);
        if (mid < y)
            o = gcd(query(rSon, mid + 1, r, x, y), o);
        return o;
    }
}tree;
int main() {
    register int n = read(), i, ans;
    tree.build(1, 1, n), ans = max(tree.query(1, 1, n, 2, n), tree.query(1, 1, n, 1, n - 1));
    for (i = 2; i < n; ++i)
        ans = max(ans, gcd(tree.query(1, 1, n, 1, i - 1), tree.query(1, 1, n, i + 1, n)));
    printf("%d", ans);
    return 0;
}


Measured memory_bytes: 2176
#include <iostream>

using namespace std;

int h, w;
char c[55][55];
int sx, sy, gx, gy, sdir;
int dx[] = {1, 0, -1, 0}, dy[] = {0, -1, 0, 1};
bool used[55][55];

int main(void)
{
  cin >> h >> w;
  for(int y = 1; y <= h; y++){
    for(int x = 1; x <= w; x++){
      cin >> c[x][y];
      if(c[x][y] == 'G'){
        gx = x, gy = y;
        c[x][y] = '.';
      }
      if(c[x][y] != '.' && c[x][y] != '#'){
        sx = x, sy = y;
        if(c[x][y] == '>') sdir = 0;
        if(c[x][y] == '^') sdir = 1;
        if(c[x][y] == '<') sdir = 2;
        if(c[x][y] == 'v') sdir = 3;
        c[x][y] = '.';
      }
    }
  }

  int x = sx, y = sy, dir = sdir;
  for(int i = 0; i < 100000; i++){
    used[x][y] = true;
    if(x == gx && y == gy) break;
    dir = (dir+3)%4;
    int ndir = -1;
    for(int i = 0; i < 4; i++){
      int nx = x + dx[(dir+i)%4], ny = y + dy[(dir+i)%4];
      if(nx <= 0 || nx > w || ny <= 0 || ny > h) continue;
      if(c[nx][ny] == '#') continue;
      ndir = (dir+i)%4;
      break;
    }
    if(ndir == -1) break;
    x = x + dx[ndir], y = y + dy[ndir], dir = ndir;
  }

  if(!used[gx][gy]) cout << -1 << endl;
  else{
    int ans = 0;
    for(int x = 1; x <= w; x++){
      for(int y = 1; y <= h; y++){
        if(used[x][y]) ans++;
      }
    }
    cout << ans << endl;
  }
  return 0;
}



Measured memory_bytes: 3104
# coding: utf-8
# Your code here!

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

# print(N)

def hantei(N):
    if not 1 in N:
        return False
    if not 9 in N:
        return False
    if not 7 in N:
        return False
    if not 4 in N:
        return False
        
    return True
    
if hantei(N):
    print('YES')
else:
    print('NO')

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int i,j,k,x,y,ans,curr,temp;
    int n,m;
    scanf("%d %d",&n,&m);
    double jwb;
    jwb = n / (float) m;
    printf("%.12f\n",jwb);
    return 0;
}


Measured memory_bytes: 256
#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream> 
#include <random>
#include<map>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include<fstream>
#include <unordered_map>  
using namespace std;
#define Ma_PI 3.141592653589793
#define eps 0.00000000000000000000000001
#define LONG_INF 10000000000000000
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007
#define REP(i,n) for(long long i = 0;i < n;++i)
int gogo[7370000];
int main() {
	while (true) {
		int m,n;
		cin >> m >> n;
		if (m == 0) return 0;
		for (int i = 0; i < 7370000; ++i) {
			gogo[i] = 0;
		}
		int i = m;
		for (; n != -1; ++i) {
			if (gogo[i] == 0) {
				n--;
				for (int j = 1; i * j < 7370000; ++j) {
					gogo[i * j] = 1;
				}
			}
		}
		cout << i - 1 << endl;
	}
}



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

int main(){
  int R,C,K;
  cin>>R>>C>>K;
  vector<vector<int64_t>> p(R,vector<int64_t>(C));
  for(int i=0;i<K;i++){
    int a,b;
    int64_t c;
    cin>>a>>b>>c;
    a--,b--;
    p[a][b]=c;
  }
  vector<vector<vector<int64_t>>> dp(R,vector<vector<int64_t>>(C,vector<int64_t>(4)));
  dp[0][0][1]=p[0][0];
  for(int a=0;a<R+C-2;a++){
    for(int b=0;b<C;b++){
      int i=a-b,j=b;
      if(i<0||R<=i){
        continue;
      }
      for(int k=0;k<4;k++){
        if(j+1<C){
          dp[i][j+1][k]=max(dp[i][j+1][k],dp[i][j][k]);
          if(k<3){
            dp[i][j+1][k+1]=max(dp[i][j+1][k+1],dp[i][j][k]+p[i][j+1]);
          }
        }
        if(i+1<R){
          dp[i+1][j][1]=max(dp[i+1][j][1],dp[i][j][k]+p[i+1][j]);
          dp[i+1][j][0]=max(dp[i+1][j][0],dp[i][j][k]);
        }
      }
    }
  }
  int64_t Z=0;
  for(int k=0;k<4;k++){
    Z=max(Z,dp[R-1][C-1][k]);
  }
  cout<<Z<<endl;
}



Measured memory_bytes: 706612
#include<iostream>
#include<cstring>
#include<cstdio>
#define MN 200000
using namespace std;
inline int read()
{
    int x=0,f=1;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9')x=x*10+ch-'0',ch=getchar();
    return x*f;
}
int n,V,x[MN+5],s,nxt[20][MN+5],res[MN+5],f[1<<18];
inline void R(int&x,int y){y>x?x=y:0;}
void Solve(int l,int r)
{
    memset(f,200,sizeof(f));f[0]=l==1?r+1:1;
    for(int i=0;i<1<<s;++i)
        for(int j=1;j<=s;++j) if(!(i&(1<<j-1)))
            R(f[i|(1<<j-1)],nxt[j][f[i]]==l?r+1:nxt[j][f[i]]);
    if(f[(1<<s)-1]>n) for(int i=l;i<=r;++i) res[i]=1;
}
int main()
{
    n=read();V=read();
    for(int i=1;i<=n;++i) x[i]=read();
    for(int t=V;;t>>=1,++s)
    {
        nxt[s][n]=nxt[s][n+1]=n+1;
        for(int i=n-1;i;--i) nxt[s][i]=x[i+1]-x[i]>t?i+1:nxt[s][i+1];
        if(!t) break;
    }
    int tot=0;
    for(int i=1;i<=n;i=nxt[0][i],++tot);
    if(tot<=s+1) for(int b=1;b<=n;b=nxt[0][b],++tot) Solve(b,nxt[0][b]-1);
    for(int i=1;i<=n;++i) puts(res[i]?"Possible":"Impossible");
    return 0;
}


Measured memory_bytes: 19072
use std::io::stdin;
fn get_string() -> String {
    let mut s = String::new();
    stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

macro_rules! input {
    ($single:ty) => ( get_string().parse::<$single>().unwrap() );
    ($plural:ty,) => ({
        let line = get_string();
        line.split_whitespace().map(|v| v.parse::<$plural>().unwrap()).collect::<Vec<$plural>>()
    });
    ($($plural:ty),+) => ({
        let line = get_string();
        let mut iter = line.split_whitespace();
        ($(iter.next().unwrap().parse::<$plural>().unwrap()),+)
    });
    ($single:ty; $times:expr) => ( (0..$times).map(|_| input!($single)).collect::<Vec<$single>>() );
    ($($plural:ty),+; $times:expr) => ( (0..$times).map(|_| input!($($plural),+)).collect::<Vec<($($plural),+)>>() );
}

#[allow(dead_code)]
fn get_value<T: std::str::FromStr>() -> T {
    get_string().parse().ok().unwrap()
}
#[allow(dead_code)]
fn get_values_for<T: std::str::FromStr>(times: u64) -> Vec<T> {
    (0..times).map(|_| get_value()).collect()
}
#[allow(dead_code)]
fn get_vector<T: std::str::FromStr>() -> Vec<T> {
    get_string()
        .split_whitespace()
        .map(|v| v.parse().ok().unwrap())
        .collect()
}
#[allow(dead_code)]
fn get_vectors_for<T: std::str::FromStr>(times: u64) -> Vec<Vec<T>> {
    (0..times).map(|_| get_vector()).collect()
}

fn main() {
    let n = input!(u32);
    let a = input!(i64,);

    let mut a_sum: Vec<_> = a
        .iter()
        .enumerate()
        .map(|v| *v.1 - (v.0 + 1) as i64)
        .collect();
    a_sum.sort();
    let a_mid = a_sum[(n / 2) as usize];
    let ans: i64 = a_sum.iter().map(|v| (v - a_mid).abs()).sum();
    println!("{}", ans);
}


Measured memory_bytes: 8444
module Main where

import Control.Applicative
import Numeric
import Data.Char
import Data.List
import Data.Ord

main :: IO ()
main = do
  { l1 <- getLine
  ; l2 <- getLine
  ;let l1' = l1 ++ l1
  ;if isInfixOf l2 l1' then putStrLn "Yes" else putStrLn "No"
  }

--
getIntegers :: IO[Integer]
getIntegers = map read. words <$> getLine

getInts :: IO [Int]
getInts = map read . words <$> getLine

putInts :: [Int] -> IO()
putInts = putStrLn . unwords . map show

getDoubles :: IO [Double]
getDoubles = map read . words  <$> getLine

putDoubles :: [Double] -> IO()
putDoubles = putStrLn . unwords . map showDouble

showDouble :: Double -> String
showDouble d = showFFloat Nothing d ""



Measured memory_bytes: 3756
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i, s, n) for (int i = (s); i < (n); ++i)
#define rrep(i, n, g) for (int i = (n)-1; i >= (g); --i)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define len(x) (int)(x).size()
#define dup(x, y) (((x) + (y)-1) / (y))
#define pb push_back
#define Field(T) vector<vector<T>>
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
  int a, b;
  cin >> a >> b;
  cout << (a + b + 1) / 2 << endl;
}

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

int n;
int w[1055], s[1055];
int v[1055];

long long dp[20055];

int main() {
	cin >> n;
	
	for (int i = 0; i < n; i++) {
		cin >> w[i] >> s[i] >> v[i];
	}
	
	vector<int> vs(n);
	
	for (int i = 0; i < n; i++) {
		vs[i] = i;
	}
	
	// sum(w[1..i - 1]) <= s[i]
	
	sort(vs.begin(), vs.end(), [&] (int v, int u) {
		return s[v] - w[u] < s[u] - w[v];
	});
	
	for (int i = 0; i < n; i++) {
		int u = vs[i];
		
		for (int j = s[u]; j >= 0; j--) {
			dp[j + w[u]] = max(dp[j + w[u]], dp[j] + v[u]);
		}
	}
	
	cout << *max_element(dp, dp + (int)2e4 + 1);
}


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

int main() {
  string s;

  cin >> s;

  vector<long> a((int)s.size() + 1), b((int)s.size() + 1);

  int cnt = 0;
  if (s[0] == '<') {
    a[0] = cnt;
    cnt++;
  }

  for (int i = 0; i < (int)s.size(); i++) {
    if (s[i] == '<') {
      a[i + 1] = cnt;
      cnt++;
    } else {
      cnt = 1;
    }
  }

  cnt = 0;
  if (s[(int)s.size() - 1] == '>') {
    b[s.size()] = cnt;
    cnt++;
  }

  for (int i = s.size() - 1; i >= 0; i--) {
    if (s[i] == '>') {
      b[i] = cnt;
      cnt++;
    } else {
      cnt = 1;
    }
  }

  long ans = 0;

  for (int i = 0; i < (int)s.size() + 1; i++) {
    ans += max(a[i], b[i]);
  }

  cout << ans;

  return 0;
}

Measured memory_bytes: 8708
import java.util.Scanner;

public class Main {

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

	void solve() {
		Scanner sc = new Scanner(System.in);
		int H = Integer.parseInt(sc.next());
		int W = Integer.parseInt(sc.next());
		int h = Integer.parseInt(sc.next());
		int w = Integer.parseInt(sc.next());
		sc.close();
		long hw = (H-h)*(W-w);

		System.out.println(hw);
	}

}


Measured memory_bytes: 24020
xy = [list(map(int, input().split())) for i in range(3)]
result = sum(map(sum, xy))
if result % 3 != 0:
    print("No")
    exit()
if result != (xy[0][0]+xy[1][1]+xy[2][2]) * 3:
    print("No")
    exit()
if result != (xy[0][2]+xy[1][1]+xy[2][0]) * 3:
    print("No")
    exit()
else:
    print("Yes")

Measured memory_bytes: 9120
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		//		new Main().solveA();
		//		new Main().solveB();
		new Main().solveC();
		// new Main().solveD();
	}

	private void solveA() {
		Scanner scanner = null;
		int numA = 0;
		int numB = 0;

		try {
			scanner = new Scanner(System.in);
			numA = scanner.nextInt();
			numB = scanner.nextInt();

			int res = numA - 1;
			res += numB >= numA ? 1 : 0;

			System.out.println(res);

		} finally {
			if (scanner != null) {
				scanner.close();
			}
		}
	}

	private void solveB() {
		Scanner scanner = null;
		int[] wk = new int[3];
		int numK = 0;

		try {
			scanner = new Scanner(System.in);
			wk[0] = scanner.nextInt();
			wk[1] = scanner.nextInt();
			wk[2] = scanner.nextInt();
			numK = scanner.nextInt();

			Arrays.sort(wk);

			int res = wk[wk.length - 1];
			for (int i = 0; i < numK; i++) {
				res *= 2;
			}
			wk[wk.length - 1] = res;
			res = 0;
			for (int i = 0; i < 3; i++) {
				res += wk[i];
			}

			System.out.println(res);

		} finally {
			if (scanner != null) {
				scanner.close();
			}
		}
	}

	private boolean hasNeighbor(char[][] wk, int i, int j, int maxH, int muxW) {
		int cnt = 0;

		if (i > 0 && wk[i - 1][j] == '#') {
			cnt++;
		}
		if (j < muxW - 1 && wk[i][j + 1] == '#') {
			cnt++;
		}
		if (i < maxH - 1 && wk[i + 1][j] == '#') {
			cnt++;
		}
		if (j > 0 && wk[i][j - 1] == '#') {
			cnt++;
		}

		return cnt > 0;
	}

	private void solveC() {
		Scanner scanner = null;
		int numH = 0;
		int numW = 0;

		try {
			scanner = new Scanner(System.in);
			numH = scanner.nextInt();
			numW = scanner.nextInt();
			char[][] wk = new char[numH][numW];

			for (int i = 0; i < numH; i++) {
				wk[i] = scanner.next().toCharArray();
			}

			boolean isRepaint = true;
			outside: for (int i = 0; i < numH; i++) {
				for (int j = 0; j < numW; j++) {
					if (wk[i][j] == '#') {
						isRepaint = hasNeighbor(wk, i, j, numH, numW);
						if (!isRepaint) {
							break outside;
						}
					}
				}
			}

			System.out.println(isRepaint ? "Yes" : "No");

		} finally {
			if (scanner != null) {
				scanner.close();
			}
		}
	}

	private void solveD() {
		Scanner scanner = null;
		int numN = 0;
		int numK = 0;
		int numS = 0;

		try {
			scanner = new Scanner(System.in);
			numN = scanner.nextInt();

			System.out.println("");

		} finally {
			if (scanner != null) {
				scanner.close();
			}
		}
	}
}

Measured memory_bytes: 23764
#include <bits/stdc++.h>
using namespace std;
long dp[100001][2];
vector<int> tree[100001];
void solve(int n, int p) {
    if(dp[n][0] > -1) return;
    if(tree[n].size() == 1 && tree[n][0] == p) {
        dp[n][0] = dp[n][1] = 1;
        return;
    }
    long r = 1, b = 1;
    for(auto i : tree[n]) {
        if(i == p) continue;
        solve(i, n);
        b = (b * dp[i][1]) % 1000000007;
        r = (r * (dp[i][0] + dp[i][1])) % 1000000007;
    }
    dp[n][0] = b;
    dp[n][1] = r;
    return;
}
int main() {
    int n, i, x, y;
    cin >> n;
    for(i = 1; i <= n; ++i) dp[i][0] = dp[i][1] = -1; 
    for(i = 1; i < n; ++i) {
        cin >> x >> y;
        tree[x].push_back(y);
        tree[y].push_back(x);
    }
    solve(1, 0);
    cout << (dp[1][0] + dp[1][1]) % 1000000007;
    return 0;
}

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

long long dp[52][2600];
int main() {
    int n, a;
    cin >> n >> a;
    dp[0][0] = 1;
    for (int i = 0; i < n; ++i) {
        int x;
        cin >> x;
        for (int j = i; j >= 0; --j) {
            for (int k = 2550; k >= x; --k) {
                dp[j + 1][k] += dp[j][k - x];
            }
        }
    }
    long long ans = 0;
    for (int i = 1; i <= n; ++i) {
        ans += dp[i][i * a];
    }
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 1280
#include<bits/stdc++.h>
using namespace std;
#define LL long long
#define P pair<int,int>
const LL inf = 0x3f3f3f3f;
const LL mod = 1e9+7;
const LL N = 4e3+10;
template <typename tp> inline void read(tp &x)
{
	x=0;char c=getchar();int f=0;
	for(;c>'9'||c<'0';f|=(c=='-'),c=getchar());
	for(;c<='9'&&c>='0';x=(x<<3)+(x<<1)+c-'0',c=getchar());
	if(f) x=-x;
}
LL n,a[200010],b[200010],ans;
LL fac[N*2],fav[N*2],inv[N*2];
void init()
{
	fac[0]=fav[0]=1;
	inv[1] = fac[1] = fav[1] = 1;
	for (int i = 2; i < N * 2; ++i) 
	{
		inv[i] = -mod / i * inv[mod % i] % mod + mod;
		fac[i] = fac[i - 1] * i % mod;
		fav[i] = fav[i - 1] * inv[i] % mod;
	}
}
inline LL C(int x, int y) 
{
	if (x < 0 || x < y) return 0;
	return fac[x] * fav[y] % mod * fav[x - y] % mod;
}
LL cost[N][N];
signed main()
{
	read(n);init();
	for(int i=1;i<=n;i++) read(a[i]),read(b[i]);
	for(int i=1;i<=n;i++) cost[-a[i]+2001][-b[i]+2001]++;
	for(int i=1;i<=4001;i++)
		for(int j=1;j<=4001;j++)
			(cost[i][j]+=(cost[i-1][j]+cost[i][j-1]))%=mod;
	//cout<<ans<<endl;
	for(int i=1;i<=n;i++) 
		ans=(ans+cost[a[i]+2001][b[i]+2001])%mod;
	//cout<<ans<<endl;
	for(int i=1;i<=n;i++)
		ans=(ans-C(a[i]*2+b[i]*2,a[i]*2)+mod)%mod;
	printf("%lld\n",(ans*(mod+1)/2%mod+mod)%mod);
	return 0;
}

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

int main() {
    map <string,int> memo;
    int N;
    cin >> N;
    for (int i = 0; i < N; i++){
    string s;
    cin >> s;
    memo[s] += 1;
  }
int ans=0;

  for(auto p:memo){
      auto v = p.second;
      if(v>1)v=1;
      ans +=v;
  }

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

Measured memory_bytes: 19244
#include<bits/stdc++.h>
using namespace std;
#define FasterIO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)

typedef unsigned long long ull;
typedef long long ll;
typedef double db;

#define mem(a,x) memset(a,x,sizeof(a))
#define pb push_back
#define ff first
#define ss second
#define mk make_pair
#define pi pair<int,int>
#define vi vector<int>
#define pL pair<ll,ll>
#define vL vector<ll>
#define vp vector<pi>
#define vpL vector<pL>

const int MX=2000000;
const ll mod=998244353;
const int LG=26;



int main()
{
    FasterIO;

    ll x, d, k;

    cin>>x>>k>>d;

    x=abs(x);

    ll m=x/d;

    if(m>=k)
    {
        cout<<(x-k*d)<<endl;
    }
    else
    {
        ll d1=x-(m*d);
        ll d2=abs(x-(m*d)-d);

        if((k-m)%2==0) cout<<d1<<endl;
        else           cout<<d2<<endl;
    }

    return 0;
}


Measured memory_bytes: 3652
function Main(input){
	input=input.split(" ");
  const a = parseInt(input[0], 10);
  const b = parseInt(input[1], 10);
 
  let s = a * b;
  let l = 2 * (a + b);

  console.log(s +' '+ l);

}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 15120
#include <bits/stdc++.h>
 
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef pair<ll, ll> pii;
 
#define REP(a,b,c) for(ll (a)=(b);(a)<(c);(a)++)
#define PER(a,b,c) for(ll (a)=(b);(a)>=(c);(a)--)
 
void ii(ll &x){ cin >> x; }
void is(string &x){ cin >> x; }
void oi(ll x){ cout << x << " "; }
void os(string x){ cout << x; }
void oie(ll x){ cout << x << endl; }
void ose(string x){ cout << x << endl; }
void oe(){ cout << endl; }

ll INF = 1e9+7;

int main(){
    ll N;
    string S;
    ll Q;
    ii(N); is(S); ii(Q);
    vector<set<ll>> loc(26);
    REP(i,0,N){
        ll c=S[i]-'a';
        loc[c].insert(i+1);
    }
    REP(i,0,Q){
        ll q;
        ii(q);
        if(q==1){
            ll l; string r;
            ii(l); is(r);
            ll o=S[l-1]-'a';
            ll n=r[0]-'a';
            loc[o].erase(l);
            loc[n].insert(l);
            S[l-1]=r[0];
        }else{
            ll l; ll r;
            ii(l); ii(r);
            ll ans = 0;
            REP(i,0,26){
                auto c=loc[i].lower_bound(l);
                if(c!=loc[i].end() && *c <= r){
                    ans++;
                }
            }
            oie(ans);
        }
    }

    return 0;
}

Measured memory_bytes: 24196
#include<stdio.h>
int main(void){
    int n,a,b,c,i;
    long d=0;
    b=-1000000;
    c=1000000;
    scanf("%d",&n);
    for(a=0;a<n;a++){
        scanf("%d",&i);
        if(b<i){
            b=i;
        }
        if(c>i){
            c=i;
        }
        d+=i;
    }
    printf("%d %d %ld\n",c,b,d);
             
return 0;
 
}

Measured memory_bytes: 600
n, k = map(int, input().split())
V = list(map(int, input().split()))
ans = 0
for pull in range(k + 1):
    for back in range(k):
        if pull + back != k:
            continue
        for l in range(pull+1):
            r = pull - l
            if r > 0:
                hand = V[:l] + V[-r:]
            else:
                hand = V[:l]
            if pull >= n:
                hand = V
            hand = sorted(hand, reverse=True)
            for _ in range(back):
                if len(hand) == 0:
                    break
                if hand[-1] < 0:
                    hand.pop()
                else:
                    break
            ans = max(ans, sum(hand))
print(ans)

Measured memory_bytes: 3188
#include <iostream>
#include <string>
#include <cstring>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <queue>
#include <stack>
#include <iomanip>
#include <fstream>
#include <unordered_set>

using namespace std;

#define REP(i, n) for(ll i = 0;i < n;i++)
#define REPR(i, n) for(ll i = n;i >= 0;i--)
#define FOR(i, m, n) for(ll i = m;i < n;i++)
#define FORR(i, m, n) for(ll i = m;i >= n;i--)
#define REPO(i, n) for(ll i = 1;i <= n;i++)
#define ll long long
#define INF (ll)1ll << 60
#define MINF (-1 * INF)
#define ALL(n) n.begin(),n.end()
#define MOD 1000000007
#define P pair<ll, ll>

//セグ木
ll dat[27][1210000], sz;

void init(ll n) {
	sz = 1;
	while (sz < n)sz *= 2;
}

void update(ll z, ll k, ll a) { //場所(0-indexed), 値
	k += sz - 1;
	dat[z][k] = a;
	while (k > 0) {
		k = (k - 1) / 2;
		dat[z][k] = dat[z][k * 2 + 1] + dat[z][k * 2 + 2]; //更新
	}
}

ll query(ll z, ll a, ll b, ll k, ll l, ll r) { //[a, b) 呼ぶとき (a, b, 0, 0, sz)
	if (r <= a or b <= l)return 0;
	if (a <= l and r <= b)return dat[z][k];
	ll v1 = query(z, a, b, k * 2 + 1, l, (l + r) / 2);
	ll v2 = query(z, a, b, k * 2 + 2, (l + r) / 2, r);
	return v1 + v2; //戻り値
}
string s;
int main() {
	ll n, q;
	cin >> n;
	cin >> s;
	init(500010);
	REP(i, n) update((ll)s[i] - 'a', i, 1);
	cin >> q;
	REP(qi, q) {
		ll t;
		cin >> t;	
		if (t == 1) {
			ll a;	
			char c;
			cin >> a >> c;
			a--;
			update((ll)s[a] - 'a', a, 0);
			update((ll)c - 'a', a, 1);
			s[a] = c;
			//cout << s << endl;
		}
		else if(t == 2) {
			ll a, b;
			cin >> a >> b;
			a--;
			ll ans = 0;
			REP(i, 26) if (query(i, a, b, 0, 0, sz) > 0) ans++;
			cout << ans << endl;
		}
	}
}



Measured memory_bytes: 246660
use std::str::FromStr;
use std::fmt::Debug;
use std::cmp;
use std::collections::HashSet;
#[allow(dead_code)]
fn read_as_vec<T>() -> Vec<T>
where T: FromStr, <T as FromStr>::Err : Debug{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().split_whitespace().map(|c| T::from_str(c).unwrap()).collect()

}

#[allow(dead_code)]
fn read_as_string() -> String{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

fn main(){
    let n = read_as_vec::<usize>()[0];
    let a = read_as_vec::<i64>();

    let mut b: Vec<(i64, usize)> = vec![(0, 0);a.len()];
    for i in 0..b.len(){
        b[i] = (a[i] + i as i64, i);
    }
    b.sort();

    let mut c: Vec<(i64, usize)> = vec![(0, 0);a.len()];
    for i in 0..c.len(){
        c[i] = (i as i64 - a[i], i);
    }
    c.sort();

    let mut ans: usize = 0;
    let mut bi: usize = 0;
    let mut ci: usize = 0;


    while bi < n{
        let mut boff: usize = 0;
        //store which number is counted
        //let mut hash = HashSet::new();
        while bi + boff < n && b[bi].0 == b[bi+boff].0{
            //hash.insert(b[bi+boff].1);
            boff += 1;
        }

        //skip
        while ci < n && b[bi].0 > c[ci].0{
            ci += 1;
        }

        while ci < n && b[bi].0 == c[ci].0{
            //if c[ci+coff].1 > b[bi+boff].1 && hash.get(&c[ci+coff].1).is_none(){
            //if c[ci].1 > b[bi+boff].1{
                ans += boff;
            //}
            ci += 1;
        }
        bi += boff;
    }

    println!("{}", ans);
}


Measured memory_bytes: 11464
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
#include<algorithm>//next_permutation
#define rep(i,n) for (int i = 0;i < (n);i++)
#define all(v) v.begin(),v.end()
#define dec(n) cout << fixed << setprecision(n);
#define large "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
#define small "abcdefghijklmnopqrstuvwxyz"
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using vl = vector<ll>;
using vvl = vector<vl>;

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

ll mod(ll a){
  return (a % 1000000007);
}

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

ll nCr(ll n,ll r){
  if(r == 1) return n;
  else if(r == 0) return 1;
  else return nCr(n-1,r-1)*n/r;
}

int main(){
  ll x,y; cin >> x >> y;
  
  if(2*x <= y and y <= 4*x and y % 2 == 0) cout << "Yes" << endl;
  else cout << "No"  << endl;
  
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n; cin >> n;
	vector<int> a(n), ops;
	for(int & v : a) cin >> v;
	auto sorted = [&](){
		for(int k = 0; k < n; k++){
			int i;
			for(i = 0; i < n - 1; i++) if(a[(i + k) % n] > a[(i + 1 + k) % n]) break;
			if(i == n - 1) return k;
		}
		return -1;
	};
	auto op = [&](int k){
		ops.push_back(k);
		for(int i = k; i < n; i++)
			swap(a[i], a[i - k]);
	};
	for(int i = 0; i < n && sorted() == -1; i++){
		for(int j = 0; j < n - 1; j++){
			op(1);
			if(a[0] < a[n - 1]) op(n - 1);
		}
		op(1);
	}
	while(sorted() != 0) op(1);
	cout << ops.size() << '\n';
	for(int v : ops) cout << v << '\n';
	return 0;
}


Measured memory_bytes: 760
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
typedef pair<ll,ll> P;
#define fi first
#define se second
set<string> c;
map<ll,ll> mp;
const ll inf=100000000000000000;
const ll mod=1000000007;
const ll mod2=998244353;
ll gcd(ll a,ll b) {return b ? gcd(b,a%b):a;}
ll lcm(ll c,ll d){return c/gcd(c,d)*d;}

int main(){
int n;
cin>>n;
vector<bool> color(9,false);
int colorful=0;
for(int i=0;i<n;i++){
    int a;
    cin>>a;
    color[a/400]=true;
    if(a/400>=8)colorful++;
}
int ans=0;
for(int i=0;i<8;i++)if(color[i])ans++;
cout<<max(ans,1)<<" "<<ans+colorful<<endl;
}

Measured memory_bytes: 256
import java.util.*;
import java.math.*;
public class Main {
     public static String mul(String v1, String v2, int scale) {
        if (scale < 0) {
            throw new IllegalArgumentException(
                    "The scale must be a positive integer or zero");
        }
        BigDecimal b1 = new BigDecimal(v1);
        BigDecimal b2 = new BigDecimal(v2);
        return b1.multiply(b2).setScale(scale, BigDecimal.ROUND_DOWN).toString();
    }
    public static void main(String[] args)
    {
       Scanner input =new Scanner(System.in);
String str1=input.next();
        String str2=input.next();//会从控制5261台读入一4102个字符串，1653以空格版为标志权
        Main c=new Main();
        System.out.println(c.mul(str1,str2,0));

    }
}

Measured memory_bytes: 35960
il = input().split()
N = int(il[0])
K = int(il[1])
T = N
# 整数NをK進数に変換し、その桁数を出力する

result = ""

i = 0
k = 0
while (T != 0):
    result = str(T%K)+result
    T = T//K

print (len(result))


Measured memory_bytes: 2940
import os
import sys

import numpy as np


def solve(inp):
    d = inp[0]
    ccc = inp[1:27]
    sss = np.zeros((d, 26), dtype=np.int64)
    for r in range(d):
        sss[r] = inp[27 + r * 26:27 + (r + 1) * 26]
    ttt = inp[27 + d * 26:] - 1
    last = np.full(26, -1, dtype=np.int64)
    sat = 0
    buf = np.zeros(d, dtype=np.int64)
    for i in range(d):
        t = ttt[i]
        sat += sss[i][t]
        for j in range(26):
            if j == t:
                continue
            sat -= ccc[j] * (i - last[j])
        last[t] = i
        buf[i] = sat
    return buf


if sys.argv[-1] == 'ONLINE_JUDGE':
    from numba.pycc import CC

    cc = CC('my_module')
    cc.export('solve', '(i8[:],)')(solve)
    cc.compile()
    exit()

if os.name == 'posix':
    # noinspection PyUnresolvedReferences
    from my_module import solve
else:
    from numba import njit

    solve = njit('(i8[:],)', cache=True)(solve)

inp = np.fromstring(sys.stdin.read(), dtype=np.int64, sep=' ')
ans = solve(inp)
print('\n'.join(map(str, ans)))


Measured memory_bytes: 27548
#include <cstdio>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <iterator>
#define loop(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define debug(x)  cout << #x << " = " << (x) << endl;

using namespace std;
using LL = long long;
using ULL = unsigned long long;

int main() {
    int n; cin >> n;
    vector<int> p(n);
    rep(i, n) cin >> p[i], --p[i];

    int cnt = 0;
    rep(i, n) {
        if (p[i] == i) {
            if (p[i] == n - 1) swap(p[i - 1], p[i]);
            else swap(p[i], p[i + 1]);

            ++cnt;
        }
    }
    cout << cnt << endl;
}


Measured memory_bytes: 888