akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <list>
#include <vector>
#include <complex>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <bitset>
#include <ctime>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cassert>
#include <cstddef>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <sstream>
#include <fstream>
#include <functional>

using namespace std;
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define FOR(i, a, b) for (int (i) = (a); (i) < (b); (i)++)
#define RREP(i, a) for(int (i) = (a) - 1; (i) >= 0; (i)--)
#define FORR(i, a, b) for(int (i) = (a) - 1; (i) >= (b); (i)--)
#define DEBUG(C) cerr << #C << " = " << C << endl;
using LL = long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<LL>;
using VVL = vector<VL>;
using VD = vector<double>;
using VVD = vector<VD>;
using PII = pair<int, int>;
using PDD = pair<double, double>;
using PLL = pair<LL, LL>;
using VPII = vector<PII>;
template<typename T> using VT = vector<T>;
#define ALL(a) begin((a)), end((a))
#define RALL(a) rbegin((a)), rend((a))
#define SORT(a) sort(ALL((a)))
#define RSORT(a) sort(RALL((a)))
#define REVERSE(a) reverse(ALL((a)))
#define MP make_pair
#define FORE(a, b) for (auto &&a : (b))
#define EB emplace_back
#define GREATER(T) T, VT<T> greater<T>
template<typename T> inline bool chmax(T &a, T b){if (a < b){a = b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if (a > b){a = b;return true;}return false;}

const int INF = 1e9;
const int MOD = INF + 7;
const LL LLINF = 1e18;

int N;
int K;
LL V[55];

int calc(int l, int r) {
    priority_queue<int, VI, greater<int>> pq;
    int cnt = 0;
    REP(i, l) {
        pq.emplace(V[i]);
        cnt++;
    }
    FORR(i, N, r) {
        pq.emplace(V[i]);
        cnt++;
    }

    if (cnt > K) {
        return -1;
    }

    while (cnt < K && !pq.empty() && pq.top() < 0) {
        pq.pop();
        cnt++;
    }

    int ret = 0;
    while (!pq.empty()) {
        ret += pq.top();
        pq.pop();
    }
    return ret;
}

int main(void) {
    cin >> N >> K;
    REP(i, N) {
        cin >> V[i];
    }

    int ans = 0;
    REP(l, N + 1) {
        REP(r, N + 1) {
            if (l > r) {
                continue;
            }

            chmax(ans, calc(l, r));

        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
N,M = list(map(int, input().split()))
H = list(map(int, input().split()))
E = [[] for _ in range(N)]

for i in range(M):
  a,b = list(map(int, input().split()))
  a,b = a-1, b-1
  E[a].append(b)
  E[b].append(a)
  
ans = 0

for i in range(N):
  flg = True
  for p in E[i]:
    if H[i] > H[p]:
      continue
    else:
      flg = False
      break
  if flg:
    ans += 1
    
print(ans)

Measured memory_bytes: 29556
#include <stdio.h>

char n[51][51], m[51][51];
int N, M;

int serch(int x, int y);

int main(void)
{
  int i, j;

  scanf("%d %d", &N, &M);

    for(i = 0; i <  N; i++)
    scanf("%s", n[i]);
  

    for(i = 0; i < M; i++)
    scanf("%s", m[i]);

  for(i = 0; i < N; i++){
    for(j = 0; j < N; j++){
      if(m[0][0] == n[i][j]){
      int se = serch(i, j);
      if(se){
	printf("Yes\n");
	return 0;
      }
      }
    }
  }
  printf("No\n");
  return 0;
}

  int serch(int x, int y){
    int i, j;
      for(i = 0; i <  M; i++){
	for(j = 0; j <  M; j++){
	  if(x+i < N && y+j < N){
	  if(n[x+i][y+j] != m[i][j])
	    return 0;
	     }else{
	      return 0;
	    }
	}
      }
      return 1;
  }


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

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

int main(){
    int x,n;
    cin>>x>>n;
    vector<int>v;
    for(int i=0;i<n;i++){
        int p;
        cin>>p;
        v.push_back(p);
    }
    sort(v.begin(),v.end());
    
    int dif=0;
    while(1){
        if(!binary_search(v.begin(),v.end(),x-dif)){
            cout<<x-dif<<endl;
            return 0;
        }
        if(!binary_search(v.begin(),v.end(),x+dif)){
            cout<<x+dif<<endl;
            return 0;
        }
        dif++;
    }


    return 0;
}

Measured memory_bytes: 3592
#include <iostream>
#include <stdlib.h>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;
int main(int argc,char** argv){
  int x[3];
  cin >> x[0] >> x[1] >> x[2];
  sort(x,x+3);
  int ret = x[2] * 10 + x[1] + x[0];
  cout << ret << endl;
  return 0;
}



Measured memory_bytes: 256
import sys

def main():
    X = int(input())

    num = [-1, 1]
    for i in range(501):
        for j in range(501):
            for k in num:
                for l in num:
                    if((k*i)**5-(j*l)**5 == X):
                        print(i*k, j*l)
                        sys.exit()
main()

Measured memory_bytes: 9180
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
#include<string>
#include<iostream>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include<bitset>
#include<vector>
#include<limits.h>
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define RI(X) scanf("%d", &(X))
#define RII(X, Y) scanf("%d%d", &(X), &(Y))
#define RIII(X, Y, Z) scanf("%d%d%d", &(X), &(Y), &(Z))
#define DRI(X) int (X); scanf("%d", &X)
#define DRII(X, Y) int X, Y; scanf("%d%d", &X, &Y)
#define DRIII(X, Y, Z) int X, Y, Z; scanf("%d%d%d", &X, &Y, &Z)
#define RS(X) scanf("%s", (X))
#define CASET int ___T; scanf("%d", &___T); for(int cs=1;cs<=___T;cs++)
#define MP make_pair
#define PB push_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define PII pair<int,int>
#define VI vector<int>
#define VL vector<long long>
#define VPII vector<pair<int,int>>
#define PLL pair<long long,long long>
#define VPLL vector<pair<long long,long long>>
#define F first
#define S second
typedef long long LL;
using namespace std;
const int MOD = 1e9+7;
const int SIZE = 1e6+10;
int t[SIZE],v[SIZE],a[SIZE],m;
template <class T>
void maa(T& x,T y){
    if(x<y)x=y;
}
template <class T>
void mii(T& x,T y){
    if(x>y)x=y;
}
int main(){
    DRI(N);
    REP(i,N){
        RI(t[i]);
        t[i]*=2;
    }
    REP(i,N){
        RI(v[i]);
        v[i]*=2;
    }
    REP(i,SIZE)a[i]=MOD;
    int it=0;
    a[0]=0;
    REP(i,N){
        mii(a[it],v[i]);
        REP(j,t[i]){
            it++;
            mii(a[it],v[i]);
        }
    }
    mii(a[it],0);
    REPP(i,1,it+1)mii(a[i],a[i-1]+1);
    for(int i=it-1;i>=0;i--)mii(a[i],a[i+1]+1);
    LL an=0;
    REP(i,it){
        an+=(a[i]+a[i+1]);
    }
    printf("%.12f\n",an*0.125);
    return 0;
}


Measured memory_bytes: 6400
#include<iostream>
#include<string>
#include<vector>
#include<cstdio>
#include<map>
using namespace std;

vector<char>a, b, c;
char s = 0;
void saiki(char d) {
	char e = 0;
	switch (d) {
	case 'a':
		if (a.size() == 0) {
			s = 'a';
			return;
		}
		e = a[a.size() - 1];
		a.pop_back();
		saiki(e);
		break;
	case 'b':
		if (b.size() == 0) {
			s = 'b';
			return;
		}
		e = b[b.size() - 1];
		b.pop_back();
		saiki(e);
		break;
	case 'c':
		if (c.size() == 0) {
			s = 'c';
			return;
		}
		e= c[c.size() - 1];
		c.pop_back();
		saiki(e);
		break;
	}
}
int main() {
	string d;
	cin >> d;
	for (int l = d.length() - 1; l != -1; l--) {
		a.push_back(d[l]);
	}
	cin >> d;
	for (int l = d.length() - 1; l != -1; l--) {
		b.push_back(d[l]);
	}
	cin >> d;
	for (int l = d.length() - 1; l != -1; l--) {
		c.push_back(d[l]);
	}
	saiki('a');
	cout << char(s-32) << endl;
}

Measured memory_bytes: 256
from itertools import permutations

def distance(a, b):
    return ((a[0]-b[0])**2 + (a[1]-b[1])**2)**0.5

n = int(input())
xy = [list(map(int, input().split())) for _ in range(n)]

d = 0
cnt = 0
for per in permutations(list(range(n)), n):
    cnt += 1
    for i in range(n-1):
        a = xy[per[i]]
        b = xy[per[i+1]]
        d += distance(a, b)

print(d/cnt)

Measured memory_bytes: 9408
#include <iostream>
#include <numeric>
#include <math.h>
#include <algorithm>
#include <float.h>
#include <limits>
#include <vector> 
#include <string.h>
#include <iomanip>

#define rep(i,a,n) for(ll int (i) = (a);(i) < (n);(i)++)
#define urep(i,a,n) for(ll int (i) = (a);(i) > (n);(i)--)
#define MOD 1000000007
#define ll long long
#define asort(a) sort(a.begin(),a.end());

using namespace::std;

int jo(ll int jxo, ll int jyo){//累乗
	ll int jhogeo = 1;
	rep(jinto,0,jyo) jhogeo=jhogeo*jxo;
	return jhogeo;
}
char tobig(char toxbig){//char大文字化
  return (toxbig-0x20);
}
char tolow(char toxlow){//char小文字化
  return (toxlow+0x20);
}
int ctoi(char cctoi){//char->int
  if('0' <= cctoi && cctoi <= '9') return (cctoi-'0');
  return -1;
}
int gcd(int gcad, int gcbd) {//最大公約数
  if(gcad < gcbd) return gcd(gcbd, gcad);
  int gcrd;
  while ((gcrd=gcad%gcbd)) {
    gcad = gcbd;
    gcbd = gcrd;
  }
  return gcbd;
}
int lcm(int lcam, int lcbm){//最小公倍数
 return (lcam*lcbm)/gcd(lcam,lcbm);
}


int main(){
  int N;
  cin>>N;
  int kai=1;
  double sum=0;
  vector<double> x(N);
  vector<double> y(N);
  rep(i,0,N) cin>>x[i]>>y[i];
  rep(i,0,N){
    rep(j,i,N){
      sum+=sqrt((x[i]-x[j])*(x[i]-x[j])+(y[i]-y[j])*(y[i]-y[j]));
    }
  }
  rep(i,1,N+1) kai=kai*double(i);
  cout<<fixed<<setprecision(10); 
  cout<<(sum*(kai*(N-1)/(N*(N-1)/2)))/kai;
      
      
      
}
// int *p = new int[N];

//  vector<int> 変数名(要素数);
//  sort(変数名.begin(),変数名.end());//昇順ソート

// vector<vector<int>> 変数名(左の個数, vector<int>(右の個数));

//cout<<fixed<<setprecision(n);  //小数点n桁まで表示


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

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

int main() {
    int n, l;
    cin >> n >> l;
    vector<string> s(n);
    rep(i, n) cin >> s[i];
    sort(s.begin(), s.end());
    rep(i, n) {
        cout << s[i];
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 3576
#include <iostream>
#include <string>
#include <cmath>
#include <fstream>
#include <chrono>
#include <iomanip>
#include <vector>
#include <utility>
#include <time.h>
#include <set>
#include <unordered_set>
#include <list>
#include <iterator>
#include <time.h>
#include <chrono>
#include <deque>
#include <cstdio>
#include <sstream>
#include <algorithm>
#include <stack>
#include <queue>
#include <climits>
using namespace std;

#define ll long long
#define ldb long double

ll mod(ll a, ll b)
{
	return (b + (a % b)) % b;
}

ll subMod(ll a, ll b, ll M)
{
	return mod((mod(a, M) - mod(b, M)), M);
}

void solve()
{
	string s, t;
	ll a, b;
	string u;

	cin >> s >> t;
	cin >> a >> b;
	cin >> u;

	if (u == s)
	{
		a--;
	}
	else if (u == t)
	{
		b--;
	}

	cout << a << " " << b;
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	solve();

	return 0;
}

Measured memory_bytes: 256
def main():

    N = int(input())
    S = input()
    suffix_w = [0]
    for i in range(N-1, -1, -1):
        if S[i] == ".":
            suffix_w.append(suffix_w[-1] + 1)
        else:
            suffix_w.append(suffix_w[-1])
        # print(suffix_w, S[i])
    suffix_w = suffix_w[::-1]
    # print(suffix_w)


    min_c = float('inf')
    countb = 0
    countw = 0
    for i in range(N):
        if S[i] == "#":
            c = suffix_w[i+1] + countb
            min_c = min(min_c, c)
            countb += 1
        else:
            countw += 1
    min_c = min(min_c, countb, countw)
    return min_c

if __name__ == '__main__':
    print(main())

Measured memory_bytes: 12800
# -*- coding: utf-8 -*-

import sys
import os
import math

for s in sys.stdin:
    n = int(s)

    if n == 0:
        break

    A = []
    for i in range(n):
        A.append(int(input()))

    A.sort()

    ans = 0
    for i, a in enumerate(A):
        ans += a * (n - i - 1)

    print(ans)

Measured memory_bytes: 7872
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

const int N = 1e5 + 5, inf = 1e9;
#define pb push_back
#define mp make_pair
#define ll long long
#define ff first
#define ss second
#define all(a) a.begin(),a.end()
#define sz(x) (int)x.size()
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<ii> vii;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const double pi = acos(-1.0);
int main(){
	ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
	int r;
	cin >> r;
	cout << pi * 2 * r << '\n';	
	return 0;
}



Measured memory_bytes: 3804
import java.util.*;

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

    if (a < b) {
      System.out.println("a < b");
    } else if(a > b) {
      System.out.println("a > b");
    } else {
      System.out.println("a == b");
    }
    sc.close();
  }
}


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

int main() {
  int h, w, i;
  cin >> h >> w;
  string s;
  vector<string> ans(2 * h);
  for (i = 0; i < h; ++i) {
    cin >> s;
    ans[2 * i] = s;
    ans[2 * i + 1] = s;
  }
  for (i = 0; i < 2 * h; ++i) {
    cout << ans[i] << "\n";
  }
  return 0;
}

Measured memory_bytes: 256
from scipy.sparse.csgraph import floyd_warshall

#input
h, w = list(map(int, input().split()))

c = [0 for i in range(10)]
for i in range(10):
    c[i] = list(map(int, input().split()))

wall = []

for i in range(h):
    wall.append(list(map(int, input().split())))

#solve
#1へのコスト
costone = [(10**3) + 1 for i in range(11)]
#-1, 1はコストがかからないため０で初期化
costone[1] = 0
#-1の処理
costone[10] = 0
#ワーシャルフロイド法を使う
#iは出発、jは経由,
c = floyd_warshall(c)
##for i in range(10):
##    for j in range(10):
##        for k in range(10):
##            c[i][k] = min(c[i][k], c[i][j] + c[j][k])
#costoneを更新
for i in range(10):
    costone[i] = min(costone[i], c[i][1])
sum = 0


for i in range(h):
    for j in range(w):
        sum += costone[wall[i][j]]
print(int(sum))


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

int main() {
int a,b,c,d;
  cin >> a >> b >> c >>d;
  
  bool ans=true;
  rep(i,100) {
    c-=b;
    if(c<=0) {
      break;
    }
    a-=d;
    if(a<=0) {
      ans=false;
      break;
    }
  }
  if(ans==false) cout << "No" << endl;
  else cout << "Yes" << endl;
}

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

using namespace std;

int main() {
    string s;
    cin >> s;
    vector<char> v;
    for (char c : s) {
        switch (c) {
            case '0':
                v.push_back('0');
                break;
            case '1':
                v.push_back('1');
                break;
            case 'B':
                if (v.size() != 0) v.pop_back();
                break;
        }
    }

    string ans;
    for (char c : v) ans += c;
    cout << ans;
}


Measured memory_bytes: 3600
n = int(input())
cards = list(map(int,input().split()))
cards.sort(reverse=True)
Alice = 0
Bob = 0
for i in range(0, n, 2):
  Alice += cards[i]
for j in range(1, n, 2):
  Bob += cards[j]
z = Alice - Bob
print(z)

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

int main() {
    int n; cin >> n;
    vector<int> h(n);
    rep(i, n) cin >> h.at(i);

    int before = h.at(0)-1;
    for (int i = 1; i < n; i++) {
        if (h.at(i) == before) {
            before = h.at(i);
        }
        else if (before > h.at(i)) {
            cout << "No" << endl;
            return 0;
        }
        else {
            before = h.at(i)-1;
        }
    }

    cout << "Yes" << endl;
    return 0;
}

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

using namespace std;
using ll = long long;

#define rep(i, n) for (int i = 0; i < (int)(n); ++i)

vector<int> to[200005];
vector<int> ans;

void dfs(int u, int p = -1) {
  for (auto v : to[u]) {
    if (v == p) continue;
    ans[v] += ans[u];
    dfs(v, u);
  }
}

int main() {
  int n, q;
  cin >> n >> q;
  rep(i, n - 1) {
    int a, b;
    cin >> a >> b;
    --a, --b;
    to[a].push_back(b);
    to[b].push_back(a);
  }

  ans.resize(n);

  rep(i, q) {
    int p, x;
    cin >> p >> x;
    --p;
    ans[p] += x;
  }

  dfs(0);
  rep(i, n) cout << ans[i] << endl;
  return 0;
}


Measured memory_bytes: 23424
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(ll i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(ll i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(ll i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((ll)(x).size())
#define len(x) ((ll)(x).length())

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    // ifstream in("input.txt");
    // cin.rdbuf(in.rdbuf());
    ll n, m;
    cin >> n >> m;
    vector<vector<ll>> a(n, vector<ll>(m));
    rep(i, n) rep(ii, m) cin >> a[i][ii];
    ll ans = LONG_LONG_MAX;
    rep(i, m) {
        map<ll, ll> cnt;
        rep(ii, n) cnt[a[ii][0]]++;
        ll mv = -1, mi = -1;
        for(auto x : cnt) {
            if (mv < x.second) {
                mv = x.second;
                mi = x.first;
            }
        }
        ans = min(ans, mv);
        rep(ii, n) {
            for(auto it = a[ii].begin(); it != a[ii].end(); it++) {
                if (*it == mi) {
                    a[ii].erase(it++);
                    break;
                }
            }
        }
    }
    cout << ans << endl;
    return 0;
}


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

int main() {
    int N, M, Q;
    cin >> N >> M >> Q;
    using T = tuple<int, int, int, int>;
    vector<T> q(Q);
    for(int i = 0; i < Q; ++i) {
        int a, b, c, d;
        cin >> a >> b >> c >> d;
        a--, b--;
        q[i] = make_tuple(a, b, c, d);
    }
    int cnt = 0;
    auto score = [&](const vector<int> &A) -> int {
        int res = 0;
        for(auto &[a,b,c,d] : q) {
            if(A[b] - A[a] == c) res += d;
        }
        return res;
    };
    auto f = [&](auto &&f, vector<int> &A, int last) -> int {
        if(A.size() == N) {
            return score(A);
        }
        int res = 0;
        for(int i = last; i <= M; ++i) {
            A.push_back(i);
            res = max(res, f(f, A, i));
            A.pop_back();
        }
        return res;
    };
    vector<int> A;
    cout << f(f, A, 1) << '\n';
    return 0;
}


Measured memory_bytes: 3636
while True:
    n, x = map(int, input().split())
    if n == 0 and x == 0:
        break
    ans = 0
    for i in range(1, n+1):
        for j in range(i+1, n+1):
            for k in range(j+1, n+1):
                if i + j + k == x:
                    #print(i, j, k)
                    ans += 1
    print(ans)



Measured memory_bytes: 5592
/****************************************************************
# @Author:      iLovePKU_zbtxdy
# @DateTime:    2020-02-07 11:14:19
# @Description: Think twice. Code once. 
# @More: Once lots of AC, try Brute-force,dynamic programming
****************************************************************/
#include<bits/stdc++.h>
using namespace std;
#define close std::ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define eps 1e-8
typedef long long ll;
const int maxn = 1e6+10;
const int INF = 0x3f3f3f3f;
const ll linf = 0x3f3f3f3f3f3f3f3f;
const double PI = acos(-1.0);
ll mod = 1e9+7;
int main()
{
    string s;
    cin >> s;
    int len = s.size();
    if(s[len-1] == s[0]){
        len -= 1;
    }else {
        len -= 2;
    }
    puts(len&1==1?"First":"Second");
    system("pause");
}
/***************************************************************************
*stuff you should look for
*int overflow, array bounds
*special cases (n=1?), set tle
*do smth instead of nothing and stay organized
***************************************************************************/

Measured memory_bytes: 760
import java.util.Scanner;
import java.util.stream.IntStream;

public class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int n = scanner.nextInt();
		int x = scanner.nextInt();
		
		print(x, n);
	}
	
	public static void print(int x,int n){
		int max =  n * 2 - 1;
		if (x == 1 || x == max) {
			System.out.println("No");
			return;
		}
		System.out.println("Yes");
		String sep = System.lineSeparator();
		String ans = IntStream.range(x + n - 1, x + n + max -1)
				.mapToObj(e -> (e % max + 1) + sep)
				.collect(StringBuilder::new, StringBuilder::append, StringBuilder::append).toString();
		System.out.println(ans);
	}
}


Measured memory_bytes: 37364
d=int(input())
c=list(map(int,input().split()))
s=[list(map(int,input().split())) for i in range(d)]
for i in range(d):
    cand=0
    for j in range(26):
        if s[i][cand]<s[i][j]:
            cand=j
    print(1)

Measured memory_bytes: 68624
#include<bits/stdc++.h>
#define ull unsigned long long
#define ll long long
#define pb push_back
#define endl '\n'
#define line cout<<"----------------------"<<endl
#define mp make_pair
#define mod 1000000007
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL)
#define filein freopen("input.txt","r",stdin)
#define fileout freopen("output.txt","w",stdout)
using namespace std;
const ll  mx=2000009;
ll ara[22][22];
ll  n;
ll  dp[1LL<<22];
ll  call(ll  mask)
{
    if(mask==(1LL<<n)-1) return 1;
    ll  &ans=dp[mask];
    if(ans!=-1) return ans;
    ans=0;
    int ind=__builtin_popcount(mask);
    for(ll  i=0;i<n;i++)
    {
        if(mask&(1<<i) or ara[ind][i]==false) continue;
        ans+=call(mask|(1LL<<i));
        ans%=mod;
    }
    return ans;
}
int  main()
{
    memset(dp,-1,sizeof dp);
    cin>>n;
    for(ll  i=0;i<n;i++)
    {
        for(ll  j=0;j<n;j++) cin>>ara[i][j];
    }
    cout<<call(0)<<endl;
}


Measured memory_bytes: 33024
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
using namespace std;

const int MAX = 1000001;

class Node
{
public:
	char c;
	int num;
	int total;
	vector<Node> child;
	Node(int num0, char c0){
		num = num0;
		c = c0;
		total = 0;
	}
};

void solve(string s, int a)
{
	Node root(1, '(');
	Node* pNode = &root;
	stack<Node*> stkNode;
	istringstream iss(s);

	for(;;){
		int tmp;
		if(!(iss >> tmp)){
			if(iss.eof())
				break;
			tmp = 1;
			iss.clear();
		}
		char c;
		iss >> c;
		if(c == ')'){
			pNode = stkNode.top();
			stkNode.pop();
			pNode->total += pNode->child.rbegin()->total * pNode->child.rbegin()->num;
			if(pNode->total > MAX)
				pNode->total = MAX;
		}else{
			pNode->child.push_back(Node(tmp, c));
			if(c == '('){
				stkNode.push(pNode);
				pNode = &(*pNode->child.rbegin());
			}else{
				pNode->child.rbegin()->total = 1;
				pNode->total += tmp;
				if(pNode->total > MAX)
					pNode->total = MAX;
			}
		}
	}

	if(pNode->total <= a){
		cout << 0 << endl;
		return;
	}

	for(;;){
		a %= pNode->total;
		for(int i=0; ; ++i){
			if(a < pNode->child[i].total * pNode->child[i].num){
				pNode = &(pNode->child[i]);
				break;
			}
			a -= pNode->child[i].total * pNode->child[i].num;
		}
		if(pNode->c != '('){
			cout << pNode->c << endl;
			return;
		}
	}
}

int main()
{
	for(;;){
		string s;
		int a;
		cin >> s >> a;
		if(s == "0" && a == 0)
			break;

		solve(s, a);
	}

	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <random>
#include <chrono>
#include <atcoder/all>
 
using namespace std;
using namespace __gnu_pbds;
using namespace atcoder;
 
#define endl '\n'
 
typedef long long ll;
typedef pair<int, int> pii;
typedef tree<int, null_type,less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
template<typename T>
static T randint(T lo, T hi){
	return uniform_int_distribution<T>(lo, hi)(rng);
}


int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
 
	// freopen("capastaty_input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);

	int n, q;
	cin >> n >> q;

	fenwick_tree<ll> fw(n);

	for(int i = 0; i < n; i++){
		ll x;
		cin >> x;
		fw.add(i, x);
	}

	for(int i = 0, t; i < q; i++){
		cin >> t;
		if(t == 0){
			int p;
			ll x;
			cin >> p >> x;
			fw.add(p, x);
		}
		else{
			int l, r;
			cin >> l >> r;
			cout << fw.sum(l, r) << endl;
		}
	}

	return 0;
}


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

int gcd(int c, int d)
{
	int i, gcd, c_max;
	gcd = 0;
	for (i = 1; i < sqrt((double)c); i++) {
		if (c % i == 0) {
			c_max = c / i;

			if (d % c_max == 0) {
				gcd = c_max;
				break;
			}

			if (d % i == 0) {
				gcd = i > gcd ? i : gcd;
			}
		}
	}
	return gcd;
}

int main(int argc, char** argv)
{
	int a, b, result;

	scanf("%d %d", &a, &b);

	if (a > b) {
		result = gcd(a % b, b);
	}
	else if (a == b) {
		result = a;
	}
	else {
		result = gcd(b % a, a);
	}

	printf("%d\n", result);
	return 0;
}

Measured memory_bytes: 592
n,m=map(int,input().split())
mod=10**9+7
dp=[0]*(n+7)
dp[0]=1
a=[int(input())for _ in range(m)]
a=set(a)
for i in range(n+1):
  if i+2 not in a:
    dp[i+2]+=dp[i]
  if i+1 not in a:
    dp[i+1]+=dp[i]
  dp[i+2]%=mod
  dp[i+1]%=mod
print(dp[n]%mod)

Measured memory_bytes: 13968
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef long double ld;
#define size(a) int((a).size())
#define present(c, x) (c.find(x) != c.end()) 
#define printVerdict(verdict) cout << (verdict ? "yes": "no") << '\n'
#define printDecimal(d) printf("%.9f\n", d)
#define inrange(val, start, end) (val >= start && val <= end)
 
const int mod = 1e9 + 7; 
 
template <class T1, class T2, class T3> 
void printTuple(tuple<T1, T2, T3> t) { cout << get<0>(t) << " " << get<1>(t) << " " << get<2>(t) << '\n'; }
template <class T1, class T2>
void printPair(pair<T1, T2> p) { cout << p.first << " " << p.second  << '\n'; }
template <class T>
void printArray(vector<T> arr) { for (int i = 0; i<size(arr); i++) {cout << arr[i] << " ";} cout << '\n'; } 

vector<int> sieve(int maxVal) {
	vector<int> ret;
	vector<bool> is_prime(maxVal + 1, true);
	for (int i = 2; i<=maxVal; i++) {
		if (is_prime[i]) {
			ret.push_back(i);
			if (ll(i) * i <= maxVal) {
				for (int j = i*i; j <= maxVal; j += i) is_prime[j] = false;
			}
		}
	}
	return ret;
}

int main() {
	std::ios_base::sync_with_stdio(false);
	cin.tie(0);
	int n, maxVal = 0; cin >> n;
	int a[n];
	int count_even = 0, count_odd = 0;
	for (int i = 0; i<n; i++) {
		cin >> a[i];
		maxVal = max(maxVal, a[i]);
		if (a[i] & 1) count_odd++;
		else count_even++;
	}
	int curr_gcd = a[0];
	for (int i = 1; i<n; i++) curr_gcd = __gcd(curr_gcd, a[i]);
	if (curr_gcd != 1) cout << "not coprime" << '\n';
	else {
		vector<int> primes = sieve(maxVal);
		bool pairwise = true;
		set<int> seen;
		for (int i = 0; i<n && pairwise; i++) {
			int temp = a[i];
			for (int p : primes) {
				if (p * p  > temp) break;
				if (temp%p==0) {
					if (present(seen, p)) {
						pairwise = false; 
						break;
					}
					else {
						seen.insert(p);
						while (temp % p == 0) temp /= p;
					}
				}
			}
			if (pairwise && temp > 1) {
				if (present(seen, temp)) pairwise = false;
				else seen.insert(temp);
			}
		}
		cout << (pairwise ? "pairwise coprime" : "setwise coprime") << '\n';
	}
}


Measured memory_bytes: 7800
#include<bits/stdc++.h>
#define Rint register int
#define MP make_pair
#define fi first
#define se second
#define PB push_back
using namespace std;
typedef long long LL;
typedef pair<int, int> pii;
const int N = 4003, mod = 998244353;
template<typename T>
void read(T &x){
	int ch = getchar(); x = 0; bool f = false;
	for(;ch < '0' || ch > '9';ch = getchar()) f |= ch == '-';
	for(;ch >= '0' && ch <= '9';ch = getchar()) x = x * 10 + ch - '0';
	if(f) x = -x;
}
void qmo(int &x){x += (x >> 31) & mod;}
int ksm(int a, int b){
	int res = 1;
	for(;b;b >>= 1, a = (LL) a * a % mod) if(b & 1) res = (LL) res * a % mod;
	return res;
}
template<typename T>
inline bool chmax(T &a, const T &b){if(a < b) return a = b, 1; return 0;}
template<typename T>
inline bool chmin(T &a, const T &b){if(a > b) return a = b, 1; return 0;}
char s[10];
bool query(int x, int y){printf("? %d %d\n", x, y); fflush(stdout); scanf("%s", s); return s[0] == 'Y';}
int a, b, stk[N], top; bool ans[N];
int main(){
	read(a); read(b);
	if(a <= b){puts("Impossible"); return 0;}
	for(Rint i = 0;i < a + b;++ i){
		if(!top || query(stk[top], i)) stk[++ top] = i;
		else -- top;
	}
	for(Rint i = 0;i < a + b;++ i) ans[i] = query(stk[top], i);
	printf("! "); for(Rint i = 0;i < a + b;++ i) printf("%d", ans[i]); putchar('\n');
} // ntfmefx

Measured memory_bytes: 3844
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define all(a) a.begin(), a.end()
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<ll,int> pli;
typedef pair<int,int> pii;
typedef long double ld;
#define rep(i,a,b) for(ll i=a ; i<b ; i++)
#define qrep(que, ite) for(auto ite=begin(que) ; ite!=end(que) ; ite++)
const int max_n = 1e5;
const ll mod = 1e9+7;
const ll INF = 1LL<<60;
const int inf = 1e5;
//typedef long double ld;
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; }
int dx[4] = {0,0,1,-1};
int dy[4] = {1,-1,0,0};
struct UnionFind {
    vector<int> par;

    UnionFind(int n) : par(n, -1) { }
    void init(int n) { par.assign(n, -1); }

    int root(int x) {
        if (par[x] < 0) return x;
        else return par[x] = root(par[x]);
    }

    bool issame(int x, int y) {
        return root(x) == root(y);
    }

    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (par[x] > par[y]) swap(x, y); // merge technique
        par[x] += par[y];
        par[y] = x;
        return true;
    }

    int size(int x) {
        return -par[root(x)];
    }
};
ll gcd(ll a, ll b) { return a ? gcd(b%a, a) : b; }
int main(){
  int H,W;  cin>>H>>W;
  string s[H];
  rep(i,0,H){
    cin >> s[i];
  }
  map<int,int> ma;
  rep(i,0,H){
    bool ok=true;
    rep(j,0,W){
      if(s[i][j]!='.') ok=false;
    }
    if(ok){
      ma[i]++;
    }
  }
  rep(j,0,W){
    bool ok=true;
    rep(i,0,H){
      if(s[i][j]!='.') ok=false;
    }
    if(ok){
      rep(i,0,H){
        s[i][j] = 'o';
      }
    }
  }
  rep(i,0,H){
    if(ma[i]) continue;
    rep(j,0,W){
      if(s[i][j]!='o') cout<<s[i][j];
    }
    cout << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
#define rep(i,a,b) for(int (i)=a;(i)<(int)(b);(i)++)
    
int main(){
    int N;
    cin >> N;
    vector<int> A(N,0);
    rep(i,0,N) cin >> A[i];
    set<int> st;
    rep(i,0,N) st.insert(A[i]);

    if(A.size() == st.size()) cout << "YES" << endl;        
    else if(A.size() != st.size()) cout << "NO" << endl;        

}

Measured memory_bytes: 10368
import heapq
N,M = map(int,input().split())
LRC = [tuple(map(int,input().split())) for i in range(M)]

es = [[] for i in range(N)]
for l,r,c in LRC:
    l,r = l-1,r-1
    es[l].append((r,c))
for i in range(N-1):
    es[i+1].append((i,0))

INF = 10 ** 18
dist = [INF]*N
dist[0] = 0
hq = [(0,0)]
heapq.heapify(hq)

while(hq):
    d,v = heapq.heappop(hq)
    if v==N-1:
        print(d)
        exit()
    for to,c in es[v]:
        if d+c >= dist[to]: continue
        dist[to] = d+c
        heapq.heappush(hq, (d+c, to))
print(-1)


Measured memory_bytes: 57480
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int dx[4] = {0,0,1,-1};
const int dy[4] = {1,-1,0,0};

int main()
{
    int h,w;
    cin >> h >> w;
    vector< string > field;
    for( int i = 0; i < h; ++i )
    {
        string s;
        cin >> s;
        field.push_back(s);
    }
    int count = 0;
    for( int i = 0; i < h; ++i )
    {
        for( int j = 0; j < w; ++j )
        {
            if( field[i][j] == '.' )
            {
                count++;
            }
        }
    }
    vector< vector<int> > dist(h,vector<int>(w,-1));
    dist[0][0] = 1;
    queue< pair<int,int> > q;
    q.push(make_pair(0,0));
    bool flag = false;
    while(!q.empty())
    {
        int x = q.front().first;
        int y = q.front().second;
        q.pop();
        if( x == h-1 && y == w - 1 )
        {
            flag = true;
            break;
        }
        for( int i = 0; i < 4; ++i )
        {
            int nx = x + dx[i];
            int ny = y + dy[i];
            if( nx < 0 || ny < 0 || nx >= h || ny >= w )
            {
                continue;
            }
            else if( field[nx][ny] == '#' || dist[nx][ny] != -1 )
            {
                continue;
            }
            q.push(make_pair(nx,ny));
            dist[nx][ny] = dist[x][y] + 1;
         }
    }
    
    if( flag == true )
    {
        cout << count - dist[h-1][w-1] << endl;
    }
    else{
        cout << -1 << endl;
    }
    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<char> vchar;
typedef vector<int> vint;
typedef vector<long long> vll;
typedef vector<vector<long long>> vvll;
typedef vector<vector<int>> vvint;
typedef vector<vector<char>> vvchar;
typedef priority_queue<long long> prque;
#define ain(i,n,a) for(long long i=0;i<(long long)(n);i++){cin>>a[i];}
#define aout(i,n,a) for(long long i=0;i<(long long)(n);i++){cout<<a[i]<<endl;}
#define rep(i, n) for(long long i = 0; i < (long long)(n); i++)
#define vsort(v) sort((v).begin(), (v).end())
#define vrsort(v) sort((v).rbegin(), (v).rend())
#define vreverse(v) reverse((v).begin(), (v).end())
#define pb(a) push_back(a)
#define INF 2000000009
#define MOD 1000000007
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  //input
  ll i,j,x,y,z,k;cin>>x>>y>>z>>k;vll a(x),b(y),c(z);
  ain(i,x,a);ain(i,y,b);ain(i,z,c);
  //caricurate
  vrsort(a);vrsort(b);vrsort(c);vll ab,ans;
  rep(i,min(k,x)){
    rep(j,min(k,y)){
     ab.pb(a[i]+b[j]);
    }
  }
  vrsort(ab);ll absz=ab.size();
  rep(i,min(k,absz)){
    rep(j,min(k,z)){
     ans.pb(ab[i]+c[j]);
    }
  }
  vrsort(ans);
  //output
  aout(i,k,ans);
}

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

using namespace std;

#define MAX 100000
#define INF (1LL<<55)
typedef long long ll;
typedef pair<ll, ll> pll;

int main()
{
    ll N, M, K, S, P, Q;
    cin >> N >> M >> K >> S >> P >> Q;
    
    vector<ll> z(N, INF);
    queue<int> q;
    for (int i = 0; i < K; i++) {
        ll c;
        cin >> c; c--;
        z[c] = 0;
        q.push(c);
    }
    
    vector<int> G[MAX];
    for (int i = 0; i < M; i++) {
        ll a, b;
        cin >> a >> b; a--; b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }

    
    while (!q.empty()) {
        int v = q.front(); q.pop();
        if (z[v] == S) continue;

        for (int i = 0; i < (int)G[v].size(); i++) {
            int to = G[v][i];
            if (z[v] + 1 < z[to]) {
                z[to] = z[v] + 1;
                q.push(to);
            }
        }
    }

    vector<ll> dist(N, INF);
    dist[0] = 0;
    
    priority_queue<pll, vector<pll>, greater<pll>> pq;
    pq.push(pll(0, 0));

    while (!pq.empty()) {
        pll p = pq.top(); pq.pop();
        ll c = p.first, v = p.second;

        if (v == N-1) {
            cout << c << endl;
            break;
        }
        
        for (int i = 0; i < (int)G[v].size(); i++) {
            int to = G[v][i];
            if (z[to] == 0) continue;
            
            ll ncost = c;
            if (to != N-1) ncost += (z[to] == INF ? P : Q);
            if (ncost < dist[to]) {
                dist[to] = ncost;
                pq.push(pll(dist[to], to));
            }
        }
    }    
    return 0;
}

Measured memory_bytes: 11004
#include "bits/stdc++.h"

using namespace std;

int main() {
    int D, N;
    cin >> N >> D;
    vector<vector<int>> dot(N, vector<int>(D));
    for(int i = 0; i < N; i++){
        for(int j = 0; j < D; j++) cin >> dot.at(i).at(j);
    }

    int count = 0;
    for(int i = 0; i < N; i++){
        for(int j = i + 1; j < N; j++){
            int length = 0;
            for(int k = 0; k < D; k++){
                length += (dot.at(i).at(k) - dot.at(j).at(k)) * (dot.at(i).at(k) - dot.at(j).at(k));
            }

            bool flag = false;
            for(int k = 0; k <= length; k++){
                if(k * k == length){
                    count++;
                    break;
                }
            }
        }
    }
    cout << count << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define f1(a,b,c) for(int c=a;c<=b;c++)
#define f2(a,b,c) for(int c=a;c>=b;c--)
#define f3(a,b,c) for(int c=a;c;c=b)
#define so1(a,n) sort(a+1,a+n+1,mycmp);
#define so2(a,n) sort(a+1,a+n+1);
#define ll long long
#define itn int
#define ubt int 
const int twx=1e5+100;
const int inf=0x3f3f3f3f;
const int MOD=1e9+7;
ll read()
{
    ll sum=0;
    ll flag=1;
    char c=getchar();
    while(c<'0'||c>'9')
    {
        if(c=='-')
        {
            flag=-1;
        }
        c=getchar();
    }
    while(c>='0'&&c<='9')
    {
        sum=((sum*10)+c-'0');
        c=getchar();
    }
    return sum*flag;
}
int n,m;
ll asd[twx+5];
ll inv[twx+5];
int lim;
ll ans=1;
ll mul(ll a,ll b,ll asd)
{
	return a*b%asd;
}
ll POW(ll a,ll b)
{
    ll res=1;
    for(;b;b>>=1)
    {
        if(b&1)
        {
            res=mul(res,a,MOD);
        }
		a=mul(a,a,MOD);
    }
    return res;
}
void pre()
{
    asd[0]=1;
    f1(1,twx,i)
    {
        asd[i]=asd[i-1]*i%MOD;
    }
    inv[0]=1;
    inv[twx]=POW(asd[twx],MOD-2);
    f2(twx-1,0,i)
    {
        inv[i]=inv[i+1]*(i+1)%MOD;
    }
}
ll c(ll a,ll b)
{
    return asd[a+b-1]*inv[a-1]%MOD*inv[b]%MOD;
}
void init()
{
    n=read();
    m=read();
}
void work()
{
	lim=sqrt(m);
    f1(2,lim,i)
    {
        if(m%i==0)
        {
            int cnt=0;
            while(m%i==0)
            {
                m/=i;
                cnt++;
            }
            ans=ans*c(n,cnt)%MOD;
        }
    }
}
void print()
{
	if(m!=1)
    {
        ans=ans*n%MOD;
    }
    printf("%lld",ans);
}
int main()
{
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
    init();
    pre();
    work();
    print();
	return 0;
}

Measured memory_bytes: 1792
import sys
sys.setrecursionlimit(4100000)

import math

import logging

logging.basicConfig(level=logging.DEBUG)

logger = logging.getLogger(__name__)


def resolve():
    # S = [x for x in sys.stdin.readline().split()][0]  # 文字列 一つ
    # N = [int(x) for x in sys.stdin.readline().split()][0]  # int 一つ
    A, B = [int(x) for x in sys.stdin.readline().split()]  # 複数int
    # h_list = [int(x) for x in sys.stdin.readline().split()]  # 複数int

    # grid = [list(sys.stdin.readline().split()[0]) for _ in range(N)]  # 文字列grid
    # v_list = [int(sys.stdin.readline().split()[0]) for _ in range(N)]
    # grid = [[int(x) for x in sys.stdin.readline().split()]
    #         for _ in range(N)]  # int grid

    logger.debug('{}'.format([]))

    for i in range(0, 1001):
        if int(i * 0.08) == A and int(i * 0.1) == B:
            print(i)
            return

    print(-1)


if __name__ == "__main__":
    resolve()

# AtCoder Unit Test で自動生成できる, 最後のunittest.main は消す
# python -m unittest template/template.py で実行できる
# pypy3 -m unittest template/template.py で実行できる

import sys
from io import StringIO
import unittest


class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)

    def test_入力例_1(self):
        input = """2 2"""
        output = """25"""
        self.assertIO(input, output)

    def test_入力例_2(self):
        input = """8 10"""
        output = """100"""
        self.assertIO(input, output)

    def test_入力例_3(self):
        input = """19 99"""
        output = """-1"""
        self.assertIO(input, output)


Measured memory_bytes: 6368
#include <bits/stdc++.h>
#define fo(a,b,c) for (a=b; a<=c; a++)
#define fd(a,b,c) for (a=b; a>=c; a--)
#define min(a,b) (a<b?a:b)
#define ll long long
//#define file
using namespace std;

int n,i,j,k,l;
ll a[19];

ll dg(int l,int r,ll x,ll y)
{
	ll s,ans=9223372036854775807ll;
	int i;
	
	if (l>r) return 0;
	
	fo(i,l,r)
	{
		s=dg(l,i-1,x,x+y)+dg(i+1,r,x+y,y)+a[i]*(x+y);
		ans=min(ans,s);
	}
	return ans;
}

int main()
{
	#ifdef file
	freopen("agc035d.in","r",stdin);
	#endif
	
	scanf("%d",&n);
	fo(i,1,n) scanf("%lld",&a[i]);
	
	printf("%lld\n",dg(2,n-1,1,1)+a[1]+a[n]);
	
	fclose(stdin);
	fclose(stdout);
	return 0;
}

Measured memory_bytes: 256
a = gets.chomp.to_s
cnt = 0
flg = 0
res = 0
a.each_char do |s|
  case s
  when 'A','C','G','T'
    flg = 1
    cnt += 1
    if res <= cnt
      res = cnt
    end
  else
    if flg == 1
      if res <= cnt
        res = cnt
      end
      flg = 0
    end
    cnt = 0
  end
end
puts res

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

int main(){
  ll N;
  cin >> N;
  vector<ll> L(N,0);
  for(ll i=0;i<N;i++){
    cin >> L.at(i);
  }
  sort(L.begin(),L.end());
  ll count=0;
  for(ll i=0;i<N;i++){
    for(ll j=i+1;j<N;j++){
      for(ll k=j+1;k<N;k++){
        if(L.at(i)==L.at(j) || L.at(j)==L.at(k)){
          continue;
        }
        else if(L.at(k)<L.at(i)+L.at(j) && L.at(i)>L.at(k)-L.at(j) && L.at(j)>L.at(k)-L.at(i)){
          count++;
        }
      }
    }
  }
  cout << count << endl;
}


Measured memory_bytes: 3624
#include<stdio.h>
#include<string.h>
int main(void){
    int A,B,C,D,E,x,y,cou=0,v[3];
    char S[3],s[3],X,Y;
    scanf("%d %d %d",&A,&B,&C);
    if(A>B){
        D=A-B;
    }else{
        D=B-A;
    }
    if(A>C){
        E=A-C;
    }else{
        E=C-A;
    }
    if(D>E){
        printf("B");
    }else{
        printf("A");
    }
    return 0;
}

Measured memory_bytes: 128
#include <algorithm>
#include <cassert>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <vector>
#define repeat(i, n) for (int i = 0; (i) < (n); ++(i))
#define repeat_from(i, m, n) for (int i = (m); (i) < (n); ++(i))
using namespace std;
template <class T>
void setmax(T &a, T const &b) {
    if (a < b) a = b;
}

template <class T>
void setmin(T &a, T const &b) {
    if (a > b) a = b;
}

template <typename T, typename X>
auto vectors(T a, X x) { return vector<T>(x, a); }

template <typename T, typename X, typename Y, typename... Zs>
auto vectors(T a, X x, Y y, Zs... zs) {
    auto cont = vectors(a, y, zs...);
    return vector<decltype(cont)>(x, cont);
}

int main() {
    long long a, b, c, d;
    cin >> a >> b >> c >> d;
    long long res = -1000000000000000010LL;
    repeat(x_rev, 2) {
        repeat(y_rev, 2) {
            long long tmp = 0;
            if (x_rev)
                tmp = a;
            else
                tmp = b;
            if (y_rev)
                tmp *= c;
            else
                tmp *= d;
            setmax(res, tmp);
        }
    }
    cout << res << endl;
    return 0;
}

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

using namespace std;
using ll = long long;

#define REP(i, n) for (ll i = 0; i < n; i++)
#define INF 9223372036854775807
#define all(x) (x).begin(), (x).end()

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

  string n, m;

  cin >> n;

  m = n;

  reverse(all(n));

  cout << (n == m ? "Yes" : "No");
}

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

int main(){
  char c;
  cin >> c;
  if(c=='a'||c=='i'||c=='u'||c=='e'||c=='o'){
    cout << "vowel" << endl;
  }else{
    cout << "consonant" << endl;
  }
  return 0;
}

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

#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define ll long long int
#define ull unsigned long long int
#define ld long double

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	
	#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	#endif

	int k;
	cin >> k;
	for(int i = 1; i <= k; i++) {
		cout << "ACL";
	}
	return 0;
}

Measured memory_bytes: 3596
#include<stdio.h>
int main(void){
  int xf,yb,ylim,yov,water,X,Y;
  scanf("%d %d %d %d %d",&xf,&yb,&ylim,&yov,&water);
  /*
  scanf("%d",&xf);
  scanf("%d",&yb);
  scanf("%d",&ylim);
  scanf("%d",&yov);
  scanf("%d",&water);
  */
  X=xf*water;
  if(water>ylim){
    Y=yb+(yov*(water-ylim));
  }
  else{
    Y=yb;
  }
  if(X>Y){
    printf("%d\n",Y);
  }
  else{
    printf("%d\n",X);
  }
  return 0;
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
#define rep(i,n) for (ll i = 0; i < n; ++i)
#define ALL(c) (c).begin(), (c).end()
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v, x) (std::find(v.begin(), v.end(), x) != v.end())
#define FORV(i, v) for (auto i = v.begin(); i != v.end(); i++)
using namespace std;

typedef long long ll;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
const ll INF = 1e9;
const long long INFL = 1LL<<60;

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

int main() {
  int n, m;
  cin >> n >> m;
  vector<ll> a(n);
  rep(i, n) {
    cin >> a[i];
  }
  sort(ALL(a));

  vector<pair<int, ll>> b; b.reserve(m);
  rep(i, m) {
    int bb;
    ll c;
    cin >> bb >> c;
    b.emplace_back(bb, c);
  }
  sort(ALL(b), secdesc);

  int pos = 0;
  rep(i, m) {
    auto p = b[i];
    if (a[pos] > p.second) break;
    rep(j, p.first) {
      if (a[pos] < p.second) {
        a[pos] = p.second;
        pos++;
      } else {
        break;
      }
    }
  }
  cout << SUM(a) << endl;
  return 0;
}


Measured memory_bytes: 2560
#include<iostream>
#include<string>
#include<vector>
#include<cstdio>
#include<sstream>
#include<algorithm>
#include<cmath>
#include<map>
#include<functional>
#include<queue>
#include<stack>
#include<set>
using namespace std;
 char ta[100][100];
 
 string dp[100][100];
 bool ok(char n){
 	for(int i=0;i<10;i++)if(i+'0'==n)return 1;
 	return 0;
 }
 string maa(string a,string b){
 	while(a[0]=='0')a.erase(a.begin());
 	while(b[0]=='0')b.erase(b.begin());
 	if(a.size()>b.size())return a;
 	if(a.size()<b.size())return b;
 	for(int i=0;i<a.size();i++){
 		if(a[i]-'0'>b[i]-'0')return a;
 		else if(a[i]-'0'<b[i]-'0')return b;
 	}
 	return a;
 }
 
int main(){
	int h,w;
	string a,b;
	//cin>>a>>b;cout<<maa(a,b);
	while(cin>>w>>h,w+h){
	for(int i=0;i<h;i++)cin>>ta[i];
	for(int i=0;i<h;i++)for(int j=0;j<w;j++)if(ok(ta[i][j]))dp[i][j]=ta[i][j]; 
	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			if(! ok(ta[i][j]))continue;
			string tmpa="",tmpb="";
			if(i>=1)tmpa=dp[i-1][j];
			if(j>=1)tmpb=dp[i][j-1];
			dp[i][j]=maa(tmpa,tmpb);
			//if(dp[i][j]=="0")dp[i][j]="";
			dp[i][j].push_back(ta[i][j]);
			//if(i&&j)cout<<i<<" "<<j<<" "<<dp[i-1][j]<<" "<<dp[i][j-1]<<" "<<min(dp[i-1][j],dp[i][j-1])<<endl;
		}
	}
	string ans;
	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
		//(dp[i][j].empty())? cout<<"N " : cout<<dp[i][j]<<" " ;
		ans=maa(ans,dp[i][j]);
		}
	}
	cout<<ans<<endl;
	for(int i=0;i<100;i++)for(int j=0;j<100;j++)dp[i][j]="",ta[i][j]=' ';
	}
	return 0;
}

Measured memory_bytes: 1480