akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Linq.Expressions;
using System.Text;

class Procon {
    static void Main (string[] agrs) {
        int N = Int();
        int[] d = new int[N];
        for (int i = 0; i<N; i++) {
            d[i] = Int();
        }

        Array.Sort(d);

        int ans = 1;
        for (int i = 1; i<N; i++) {
            if (d[i] != d[i-1]) {
                ans ++;
            }
        }
        Console.WriteLine(ans);
    }

    static string String () => Scanner.nextString ();
    static int Int () => int.Parse (Scanner.nextString ());
    static long Long () => long.Parse (Scanner.nextString ());
    static double Double () => double.Parse (Scanner.nextString ());
    static char[] Chars () => String ().ToCharArray ();
    static string[] Strings () => Console.ReadLine ().Split (' ');
    static int[] Ints () => Strings ().Select (v => int.Parse (v)).ToArray ();
    static long[] Longs () => Strings ().Select (v => long.Parse (v)).ToArray ();
    static double[] Doubles () => Strings ().Select (v => double.Parse (v)).ToArray ();
    const int M = 1000000007;
    static void Dbg (object a) => Console.WriteLine (a);
    static void Dbg (params object[] a) => Console.WriteLine (string.Join (" ", a));
    static void Dbgs<T> (IEnumerable<T> a, string split = " ") => Console.WriteLine (string.Join (split, a));
    static T Max<T> (params T[] a) => a.Max ();
    static T Min<T> (params T[] a) => a.Min ();
}

class PriorityQueue<T> where T : IComparable<T> {
    public T[] heap;
    public int size;
    public int sign;
    public PriorityQueue (int N, bool descend = false) {
        heap = new T[N];
        if (descend) sign = -1;
    }
    public int Compare (T x, T y) {
        return x.CompareTo (y) * sign;
    }
    public void Push (T x) {
        int i = size++;
        while (i > 0) {
            int p = (i - 1) / 2;
            if (Compare (x, heap[p]) >= 0) {
                break;
            }
            heap[i] = heap[p];
            i = p;
        }
        heap[i] = x;
    }
    public T Pop () {
        T ret = heap[0];
        T x = heap[--size];
        int i = 0;
        while (i * 2 + 1 < size) {
            int a = i * 2 + 1;
            int b = i * 2 + 2;
            if (b < size && Compare (heap[a], heap[b]) > 0) {
                a = b;
            }
            if (Compare (heap[a], x) >= 0) {
                break;
            }
            heap[i] = heap[a];
            i = a;
        }
        heap[i] = x;
        return ret;
    }
    public int Count () {
        return size;
    }
}

class Scanner {
    static string[] s = new string[0];
    static int i = 0;
    static int max_i = 0;
    static public string nextString () {
        if (i >= s.Length) {
            s = Console.ReadLine ().Split (' ');
            max_i = s.Length;
            i = 0;
            if (max_i == 0) {
                return "";
            }
            return s[i++];
        }
        return s[i++];
    }
}

Measured memory_bytes: 11220
import java.util.*;

public class Main{
    static Scanner sc = new Scanner(System.in);
        
    public static void main(String[] args) {
        int n;
        int ans = 0;
        n = Integer.parseInt(sc.next());
        for(int i = 1;i<n;i++){
            int temp = i;
            for(int j = 1;j<n;j++){
                temp = i * j;
                if(temp >= n) break;
                ans ++;
            }
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 36196
import java.io.*;
import java.util.*;

/**
 * @author masayamatu
 * 
 */
public class Main {
  
  public static void main(String[] args) throws IOException{
    FastScanner sc = new FastScanner();
    int n = sc.nextInt();
    int q = sc.nextInt();
    Graph[] graph = new Graph[n+1];
    for(int i = 0; i < n+1; i++) {
      graph[i] = new Graph();
    }
    for(int i = 1; i < n; i++) {
      int a = sc.nextInt(); int b = sc.nextInt();
      graph[a].child.add(graph[b]);
      graph[b].child.add(graph[a]);
    }
    for(int i = 0; i < q; i++) {
      int a = sc.nextInt(); int b = sc.nextInt();
      graph[a].value += b;
      } 
    dfs(graph[1] , null , 0);
    
    for(int i = 1; i < n+1; i++) {
      System.out.println(graph[i].value+ " ");
    }
  }
  
  public static class Graph{
      int  value=0;
      List<Graph> child = new ArrayList<Graph>();
  }
  public static void dfs(Graph graph,Graph parent,int value) {
        graph.value += value;
          for(Graph i:graph.child) {
            if(i != parent) {
              dfs(i,graph,graph.value); 
            }
          }           
      }      
}
class FastScanner {
  private final InputStream in = System.in;
  private final byte[] buffer = new byte[1024];
  private int ptr = 0;
  private int buflen = 0;
  private boolean hasNextByte() {
      if (ptr < buflen) {
          return true;
      }else{
          ptr = 0;
          try {
              buflen = in.read(buffer);
          } catch (IOException e) {
              e.printStackTrace();
          }
          if (buflen <= 0) {
              return false;
          }
      }
      return true;
  }
  private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
  private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
  public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
  public String next() {
      if (!hasNext()) throw new NoSuchElementException();
      StringBuilder sb = new StringBuilder();
      int b = readByte();
      while(isPrintableChar(b)) {
          sb.appendCodePoint(b);
          b = readByte();
      }
      return sb.toString();
  }
  public long nextLong() {
      if (!hasNext()) throw new NoSuchElementException();
      long n = 0;
      boolean minus = false;
      int b = readByte();
      if (b == '-') {
          minus = true;
          b = readByte();
      }
      if (b < '0' || '9' < b) {
          throw new NumberFormatException();
      }
      while(true){
          if ('0' <= b && b <= '9') {
              n *= 10;
              n += b - '0';
          }else if(b == -1 || !isPrintableChar(b)){
              return minus ? -n : n;
          }else{
              throw new NumberFormatException();
          }
          b = readByte();
      }
  }
  public int nextInt() {
      long nl = nextLong();
      if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
      return (int) nl;
  }
  public double nextDouble() { return Double.parseDouble(next());}
}


Measured memory_bytes: 108204
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, K, L = 1;
  cin >> N >> K;
  for (int i = 0; i > -1; i++) {
    if (N / K == 0) {break;}
    else {
      L++;
      N /= K;
    }
  }
  cout << L << endl;
}

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

#define ll long long
#define pb push_back
#define eb emplace_back
#define REP(i, n) for(int i=0;i<(n);++i)
#define caset int ___T; cin >> ___T; while(___T--)
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define fast_IO ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define endl "\n"

int main() {
	fast_IO;

	int n;
	cin >> n;

	string s;
	cin >> s;

	int cntR = 0, cntW = 0;
	REP(i, n) {
		if (s[i] == 'R') {
			cntR++;
		} else {
			cntW++;
		}
	}

	if (cntR == 0 || cntW == 0) {
		cout << 0 << endl;
		return 0;
	}

	ll int ans = 0;
	REP(i, cntR) {
		if (s[i] == 'W') {
			ans++;
		}
	}

	cout << ans << endl;

	cout << flush;
}


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

const int MOD = 1e9 + 7;
int dp[23][1003] , jc[1003] , inv[1003] , N , K , A[23];

int poww(long long a , int b){
	int times = 1;
	while(b){
		if(b & 1) times = times * a % MOD;
		a = a * a % MOD; b >>= 1;
	}
	return times;
}

int binom(int a , int b){return 1ll * jc[a] * inv[b] % MOD * inv[a - b] % MOD;}

int main(){
	cin >> N >> K; for(int i = 1 ; i <= K ; ++i) cin >> A[i];
	dp[0][0] = 1; jc[0] = 1;
	for(int i = 1 ; i <= N ; ++i) jc[i] = 1ll * jc[i - 1] * i % MOD;
	inv[N] = poww(jc[N] , MOD - 2);
	for(int i = N - 1 ; i >= 0 ; --i) inv[i] = inv[i + 1] * (i + 1ll) % MOD;
	for(int i = 1 ; i <= K ; ++i)
		for(int j = 0 ; j <= N ; ++j)
			if(dp[i - 1][j])
				for(int k = 0 ; k <= A[i] && k + j <= N ; ++k)
					dp[i][j + k] = (dp[i][j + k] + 1ll * dp[i - 1][j] * inv[k] % MOD * binom(N - k , A[i] - k)) % MOD;
	cout << 1ll * dp[K][N] * jc[N] % MOD;
	return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <vector>

const int MAXN = (int)2e5;

bool used[MAXN][2];

void solve(int len, int k, int c, const std::string& s) {
  for (int i = 0; i < len; ++i) used[i][0] = used[i][1] = false;
  
  int select_num = 0;
  int pre_pos = -c - 1;
  for (int i = 0; i < len; ++i) {
    if (s[i] == 'x' || i - pre_pos <= c) continue;
    used[i][0] = true;
    ++select_num;
    pre_pos = i;
    if (select_num == k) break;
  }
  int right = pre_pos;
  
  select_num = 0;
  pre_pos = len + c;
  for (int i = len - 1; i >= 0; --i) {
    if (s[i] == 'x' || pre_pos - i <= c) continue;
    used[i][1] = true;
    ++select_num;
    pre_pos = i;
    if (select_num == k) break;
  }
  int left = pre_pos;

  std::vector<int> ans;
  int x = 0, y = 0;
  for (int i = left; i <= right; ++i) {
    if (used[i][0]) ++x;
    if (used[i][1]) ++y;
    if (used[i][0] && used[i][1]) ans.emplace_back(i);
  }
  if (x + y > k) {
    for (const auto& v : ans)
      std::cout << v  + 1 << std::endl;
  }
}

int main() {
  int n, k, c;
  std::string s;
  std::cin >> n >> k >> c >> s;;
  solve(n, k, c, s);
  return 0;
}




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

int main() {
    ios::sync_with_stdio(0); cin.tie(0);
    int n;
    cin >> n;
    vector<int> h(n);
    int mx = 0;
    int ans = 0;
    for(int i = 0; i < n; ++i)
        cin >> h[i], ans += h[i] >= mx, mx = max(mx, h[i]);
    cout << ans << endl;
}

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

using namespace std;

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

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

const double PI=acos(-1);
const double EPS=1e-9; //うまくいかなかったらゆるめる

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

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


signed main(void) {
	string s,t;
    int n,a,b,c,d,e,x,y;
    cin >> n >> x >> a;
	int p = (n+x-1)/x;
	cout << p * a << endl;


}


Measured memory_bytes: 3164
/*01 02 03 12 13 23　と６回見ていくパターン 
for(int i=0;i<n-1;i++){
  for(int j=i+1;j<n;j++){
    }
  }
*///vector<vector<int>> data(3, vector<int>(4));//int型の2次元配列(3×4要素の)の宣言
//int64_t a;
//10のi乗pow(10, i);
/*string s; stringでの文字列を数字型に変える方法
  cin >> s;
  rep(i,s.size()-2) {
  int a= (s.at(i)-'0')*100 + (s.at(i+1)-'0')*10+ s.at(i+2) -'0';
    */
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main() {
  int n;
  cin >> n;
  vector<string>s(n);
  rep(i,n) cin >> s.at(i);
  sort(s.begin(), s.end());
  int count=0;
  for(int i=0; i<n-1;i++){
    if(s.at(i)!=s.at(i+1) )count++;
  }
  cout << count +1 <<endl;
  
}


Measured memory_bytes: 9584
#include <bits/stdc++.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, case_n = 1; scanf("%d ", &___T); while (___T-- > 0)
#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 a[SIZE];
int main(){
    LL s=0;
    DRI(n);
    REP(i,n){
        RI(a[i]);
        s+=a[i];
    }
    LL me=0;
    LL an=1e18;
    REP(i,n-1){
        me+=a[i];
        s-=a[i];
        an=min(an,abs(me-s));
    }
    cout<<an<<endl;
    return 0;
}


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


int main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    ll n,k,s;
    cin>>n>>k>>s;
    vector<ll> arr;
    
if(s==1)
{
	for(int i=0;i<k;i++)
	{
		arr.push_back(s);
	}
	while(arr.size()!=n)
	{
		arr.push_back(s+2);
	}
	
}     
    
else if(k!=n)
{
 if(s%2==0)
{
    for(int i=0;i<=k;i++)
    {
      arr.push_back(s/2);
	}

    while(arr.size()!=n)
	{
		arr.push_back(s/2+3);
	}
}
else 
{
	for(int i=0;i<=k;i++)
    {
    	if(i%2==0)
    	{
    	arr.push_back(s/2);
		}
		else 
		{
			arr.push_back(s/2+1);
		}
      
	}
	ll p=arr[arr.size()-1];
    while(arr.size()!=n)
	{
		arr.push_back(p);
	}
}
}
	
	
else
{
  for(int i=0;i<n;i++)
	arr.push_back(s);
}

for(int i=0;i<n;i++)
{
	cout<<arr[i]<<" ";
}
	return 0;
	
	
}

Measured memory_bytes: 2292
import java.util.*;

public class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int A = sc.nextInt();
        int B = sc.nextInt();
        int C = sc.nextInt();
        int l[] = new int[N];
        for(int i=0; i<N; i++) {
            l[i] = sc.nextInt();
        }
        int result = Integer.MAX_VALUE;
        int LIMIT = pow(4, N);
        for(int type=0; type<LIMIT; type++) {
            int bucket[] = new int[3];
            int b_count[] = new int[3];
            int tmp_masic = 0;
            for(int i=0; i<N; i++) {
                int m = (type / pow(4, i)) % 4;
                if(m==3) continue;
                bucket[m]+=l[i];
                b_count[m]++;
            }

            boolean ng = false;
            for(int k=0; k<3; k++) {
                if(b_count[k]<=0) {
                    ng=true;
                    break;
                }
            }
            if(ng) continue;

            for(int k=0; k<3; k++) {
                tmp_masic+=(b_count[k]-1)*10;
                int target=0;
                switch(k) {
                    case 0:
                        target=A;
                        break;
                    case 1:
                        target=B;
                        break;
                    case 2:
                        target=C;
                        break;
                }
                tmp_masic+=Math.abs(bucket[k]-target);
            }
            if(tmp_masic<result) {
                result = tmp_masic;
            }
        }
        System.out.println(result);
    }

    static int pow(int base, int p) {
        if(p==0) return 1;
        return base * pow(base, p-1);
    }
}

Measured memory_bytes: 27988
#include <stdio.h>


int main()
{
	int n;
	int *number;
	int i;

	scanf("%d", &n);

	number = (int *)malloc(sizeof(int) * (n + 1));

	number[0] = 1;
	number[1] = 1;	

	for(i = 2; i <= n; i++)
		number[i] = number[i - 1] + number[i - 2];

	printf("%d\n", number[n]);

	return 0;
}


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

using namespace std;
using ll = long long;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    int k = 1;
    while (2 * k <= n) {
        k *= 2;
    }
    cout << k << '\n';
    return 0;
}




Measured memory_bytes: 3216
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define pii pair<int,int>
#define sorted(a_1) sort(a_1.begin(),a_1.end())
#define rsorted(a_1) sort(a_1.rbegin(),a_1.rend())
#define t1(a_1) cout<<a_1<<endl;
#define t2(a_1) for(auto it_test : a_1) cout<<it_test<<" ";
#define MOD 1000000007

long double dp[3001][3001];
long double probability(vector<double>&arr, int index, int tail){
	if(index<0 || tail<0){ return 1.0;}
	if(dp[tail][index]>0.0) return dp[tail][index];
	if(tail==0){
		dp[tail][index]=arr[index]*probability(arr,index-1,tail);
		return dp[tail][index];
	}
	else{
		dp[tail][index]=(1-arr[index])*probability(arr,index-1,tail-1)+arr[index]*probability(arr,index-1,tail);
		return dp[tail][index];
	}
}
void solve(){
    int n;
    cin>>n;
    vector<double>arr(n);
    for(int i=0;i<n;i++){
    	cin>>arr[i];
    }
    memset(dp,0,sizeof(dp));
  	long double ans = probability(arr,n-1,(n%2==0)?n/2-1:n/2);
  	cout<<fixed<<setprecision(10)<<ans;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t=1;
    while(t--){
        solve();
    }

return 0;
}

Measured memory_bytes: 144836
#pragma region Macros
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i, n) for(int i=(n); i>=0; --i)
#define FOR(i, n, m) for(int i=(m), i##_len=(n); i<i##_len; ++i)
#define EACH(i, v) for(const auto& i : v)
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<class Value>using vec = vector< Value >;
using ll = long long;
using P = pair< long long, long long >;
#define fi first
#define se second
#define el endl
#pragma endregion

void Main();

int main(){
    std::cin.tie(nullptr);
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}


void Main(){
    int A1, A2, A3;
    cin >> A1 >> A2 >> A3;
    cout << (A1+A2+A3<=21?"win":"bust") << el;
}



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

int main() {
    int x;
    cin>>x;
    rep(i,1000)rep(j,1000){
        if(pow(i,5)-pow(j,5)==x){
            cout << i<<" "<<j <<endl;
            return 0;
        }
        if(pow(i,5)+pow(j,5)==x){
            cout << i<<" "<<-j <<endl;
            return 0;
        }
    }
}

Measured memory_bytes: 4096
//bcw0x1bd2 {{{
#include<bits/stdc++.h>
#include<unistd.h>
using namespace std;
#define F first
#define S second
#define MP make_pair
#define PB push_back
#define IOS ios_base::sync_with_stdio(0); cin.tie(0);
#define SZ(x) ((int)((x).size()))
#define ALL(x) begin(x),end(x)
#define REP(i,x) for (int i=0; i<(x); i++)
#define REP1(i,a,b) for (int i=(a); i<=(b); i++)

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef long double ld;

#ifdef DARKHH
#define FILEIO(name)
#else
#define FILEIO(name) \
  freopen(name".in", "r", stdin); \
  freopen(name".out", "w", stdout);
#endif

#ifdef DARKHH
template<typename T>
void _dump( const char* s, T&& head ) { cerr<<s<<"="<<head<<endl; }

template<typename T, typename... Args>
void _dump( const char* s, T&& head, Args&&... tail ) {
  int c=0;
  while ( *s!=',' || c!=0 ) {
    if ( *s=='(' || *s=='[' || *s=='{' ) c++;
    if ( *s==')' || *s==']' || *s=='}' ) c--;
    cerr<<*s++;
  }
  cerr<<"="<<head<<", ";
  _dump(s+1,tail...);
}

#define dump(...) do { \
  fprintf(stderr, "%s:%d - ", __PRETTY_FUNCTION__, __LINE__); \
  _dump(#__VA_ARGS__, __VA_ARGS__); \
} while (0)

template<typename Iter>
ostream& _out( ostream &s, Iter b, Iter e ) {
  s<<"[";
  for ( auto it=b; it!=e; it++ ) s<<(it==b?"":" ")<<*it;
  s<<"]";
  return s;
}

template<typename A, typename B>
ostream& operator <<( ostream &s, const pair<A,B> &p ) { return s<<"("<<p.first<<","<<p.second<<")"; }
template<typename T>
ostream& operator <<( ostream &s, const vector<T> &c ) { return _out(s,ALL(c)); }
template<typename T, size_t N>
ostream& operator <<( ostream &s, const array<T,N> &c ) { return _out(s,ALL(c)); }
template<typename T>
ostream& operator <<( ostream &s, const set<T> &c ) { return _out(s,ALL(c)); }
template<typename A, typename B>
ostream& operator <<( ostream &s, const map<A,B> &c ) { return _out(s,ALL(c)); }
#else
#define dump(...)
#endif
// }}}
// Let's Fight! ~OAO~~

ll N,X,ip[2005],ip2[2005];

int main() {
  IOS;
  cin >> N >> X;
  ll ans = 0;
  REP(i,N) {
    cin >> ip[i];
    ans += ip[i];
  }
  
  REP(i,N) {
    ll c = 0;
    REP(j,N) {
      int k = j - 1;
      if (k < 0) k = N-1;
      ip2[j] = min(ip[j], ip[k]);
      c += ip2[j];
    }
    REP(j,N) ip[j] = ip2[j];
    ans = min(ans, c+X*(i+1));
  }
  cout << ans << endl;

  return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define maxn 500010
#define fo(i,a,b) for(register int (i)=(a);(i)<=(b);++(i))
#define rd read()
int a[maxn];
int read() 
{
	int x=0,f=1;
	char c=getchar();
	while(c<'0'||c>'9') {
		if(c=='-')f=-1;
		c=getchar();
	}
	while(c>='0'&&c<='9') {
		x=(x<<1)+(x<<3)+(c^48);
		c=getchar();
	}
	return x*f;
}
int main() 
{   
    fo(i,1,3)
    {
      a[i]=rd;
	}
	int k=rd;
	sort(a+1,a+4);
	while(k!=0)
	{
		a[3]*=2;k--;
	}
    printf("%d",a[1]+a[2]+a[3]);
	return 0;
}

Measured memory_bytes: 256
from bisect import bisect_left

def binsearch(l, r, fn):
    while r - l > 1:
        m = (l + r) // 2
        if fn(m):
            l = m
        else:
            r = m
    return l


def main():
    N, K = list(map(int, input().split()))
    A = sorted(list(map(int, input().split())))
    p = bisect_left(A, 0)
    An = A[:p]
    Ap = A[p:]

    if K <= p * (N - p):
        def helper(x):
            t = 0
            r = 0
            for p in Ap:
                while t < len(An) and An[t] * p <= x:
                    t += 1
                r += t
            return r < K
        l = binsearch(Ap[-1] * An[0] - 1, 1, helper)
    else:
        K -= p * (N - p)
        An.reverse()
        def helper(x):
            r = 0
            for a in [Ap, An]:
                t = len(a) - 1
                for i, p in enumerate(a):
                    if t <= i:
                        break
                    while t > i and a[t] * p > x:
                        t -= 1
                    r += t - i
            return r < K 
        m = Ap[-1]
        if An:
            m = max(m, -An[-1])
        l = binsearch(-1, m * m, helper)
    print(l + 1)


main()


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

#define ll long long
#define fornum(A,B,C) for(A=B;A<C;A++)
#define mp make_pair
#define pii pair<int,int>
#define pll pair<ll,ll>

using namespace std;

/////////////////////////////////////////////////////
ll N,A,B,C,D;
char S[202020];
ll i, j, k;
int main(){
    scanf("%lld%lld%lld%lld%lld%s", &N,&A,&B,&C,&D,S);
    if(D<C){
        fornum(i,B-1,D){
            if(S[i-1]=='.'&&S[i]=='.'&&S[i+1]=='.'){
                break;
            }
        }
        if(i==D){
            printf("No");
            return 0;
        }
    }
    fornum(i,B-1,D-1){
        if(S[i+1]=='#'){
            if(S[i+2]=='#'){
                printf("No");
                return 0;
            }
            i++;
        }
    }
    fornum(i,A-1,C-1){
        if(S[i+1]=='#'){
            if(S[i+2]=='#'){
                printf("No");
                return 0;
            }
            i++;
        }
        
    }
    printf("Yes");

    return 0;
}

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

using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
typedef long long ll;
using Graph = vector<vector<int>>;
typedef long long ll;
typedef pair<int, int> P;

const int MOD = 1000000007;
const int INF_32 = 1LL << 30;
const int64_t INF_64 = 1LL << 60;

int n;
void output(string s, int now, int c)
{
    if (now == n) {
        cout << s << endl;
        return;
    }

    // 新しいのを使わないやつ
    for (int i = 0; i < c; i++) {
        string t = s + char('a' + i);
        output(t, now + 1, c);
    }

    // 新しいのを使うやつ
    string t = s + char('a' + c);
    output(t, now + 1, c + 1);
}
int main()
{
    cin >> n;
    output("", 0, 0);
}

Measured memory_bytes: 1536
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;

typedef pair<ll, ll> P;
class BF{
    public:
    ll N;
    ll INF;
    vector<vector<P> >path;
    vector<vector<ll> >rev;
    vector<ll>dist;
    vector<ll>flg;
    BF(ll n, ll inf){
        N = n + 1;
        INF = inf;
        path = vector<vector<P> >(N);
        rev = vector<vector<ll> >(N);
        dist = vector<ll>(N, INF);
        flg = vector<ll>(N, 1);
    }
    void add(ll a, ll b, ll c){
        path[a].push_back(P(b, c));
        rev[b].push_back(a);
    }
    // loopがあったらtrue(目標ノードに到達できないところでloopする可能性あり)
    // 無関係なノードはadjust()で消しておくと良い
    bool make(ll s){
        dist[s] = 0;
        for(ll i = 0; i < N; i++){
            for(ll v = 0; v < N; v++){
                if(dist[v] == INF)continue;
                for(ll k = 0; k < path[v].size(); k++){
                    ll to = path[v][k].first;
                    ll w = path[v][k].second;
                    if(dist[to] > dist[v] + w){
                        dist[to] = dist[v] + w;
                        if(i == N - 1 && flg[to])return true;
                    }
                }
            }
        }
        return false;
    }
    // 目標ノードに到達できないノードのフラグを0にする
    void adjust(ll t){
        flg = vector<ll>(N, 0);
        queue<ll>Q;
        flg[t] = 1;
        Q.push(t);
        while(!Q.empty()){
            ll q = Q.front();
            Q.pop();
            for(ll i = 0; i < rev[q].size(); i++){
                ll j = rev[q][i];
                if(flg[j])continue;
                flg[j] = 1;
                Q.push(j);
            }
        }
    }
    ll get(ll t){
        return dist[t];
    }
};

int main(){

    ll N, M, X;
    cin >> N >> M >> X;
    BF bf(N, 10000000000LL);
    for(ll i = 0; i < M; i++){
        ll a, b, c;
        cin >> a >> b >> c;
        bf.add(a, b, X - c);
    }
    bf.adjust(N);
    if(bf.make(1)){
        cout << -1 << endl;
        return 0;
    }
    cout << max(-bf.dist[N], 0LL) << endl;

    return 0;
}

Measured memory_bytes: 768
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <string>

using namespace std;

int main()
{
	int n, m;
	vector<int> a;
	int dp[100010] = { 0 };
	bool isDanger[100010] = { false };

	cin >> n >> m;

	a.resize(m);
	for(int i = 0; i < m; ++i)
	{
		cin >> a[i];
		isDanger[a[i]] = true;
	}

	dp[0] = 1;
	dp[1] = isDanger[1] ? 0 : 1;
	for(int i = 2; i <= n; ++i)
	{
		if(!isDanger[i])
		{
			dp[i] = (dp[i - 1] + dp[i - 2]) % 1000000007;
		}
	}

	cout << dp[n] << endl;
}

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

#define whole(f, x, ...)                                 \
  ([&](decltype((x)) whole) {                            \
    return (f)(begin(whole), end(whole), ##__VA_ARGS__); \
  })(x)

using namespace std;
using ll = long long;

#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>
namespace mp = boost::multiprecision;
using Bint = mp::cpp_int;
using Real = mp::number<mp::cpp_dec_float<1024>>;

void solve() {
  Real a;
  Real b;
  cin >> a >> b;

  // ll c = (a * b) / 1;

  cout << (Bint)mp::floor(a * b) << endl;
}

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);

  solve();
  return 0;
}


Measured memory_bytes: 3972
public
class Main
{
  private static
  final int ColorNum = 6;

  public static
  void main (
    String args[ ]
    )
  {
    java.util.Scanner scanner
      = new java.util.Scanner ( System.in );

    while ( true )
    {
      int[ ][ ] panel;
      int       h, w, c;

      h = scanner.nextInt ( );
      w = scanner.nextInt ( );
      c = scanner.nextInt ( );
      if ( h == 0 && w == 0 && c == 0 ) break;

      panel = new int[ h ][ w ];
      for ( int j = 0; j < h; ++j )
      for ( int i = 0; i < w; ++i )
      {
        panel[ j ][ i ] = scanner.nextInt ( );
      }

      System.out.format ( "%d\n", solve ( panel, c ) );
    }

    return ;
  }

  public static
  int solve (
    int[ ][ ]   panel,
    int         c
    )
  {
    int[ ]  p = new int[ 5 ];
    int     res = 0;

    p[ 4 ] = c;
    for ( p[ 0 ] = 1; p[ 0 ] <= ColorNum; ++p[ 0 ] )
    for ( p[ 1 ] = 1; p[ 1 ] <= ColorNum; ++p[ 1 ] )
    for ( p[ 2 ] = 1; p[ 2 ] <= ColorNum; ++p[ 2 ] )
    for ( p[ 3 ] = 1; p[ 3 ] <= ColorNum; ++p[ 3 ] )
    {
      int[ ][ ] clone
        = new int[ panel.length ][ ];

      /* Copies panel to clone by deep copy */
      for ( int i = 0; i < panel.length; ++i )
      {
        clone[ i ] = panel[ i ].clone ( );
      }

      res = Math.max ( res, test ( clone, p ) );
    }

    return ( res );
  }

  private static
  int test (
    int[ ][ ]   panel,
    int[ ]      param
    )
  {
    for ( int c : param )
    {
      simulate ( panel, 0, 0, panel[ 0 ][ 0 ], c );
    }

    return
      count ( panel, 0, 0, panel[ 0 ][ 0 ] );
  }

  private static
  void simulate (
    int[ ][ ]   panel,
    int         x,
    int         y,
    int         pc,
    int         nc
    )
  {
    if ( nc == pc )               return ;
    if ( x < 0 || y < 0
      || y >= panel.length
      || x >= panel[ y ].length ) return ;
    if ( panel[ y ][ x ] != pc )  return ;

    panel[ y ][ x ] = nc;

    simulate ( panel, x - 1 , y     , pc, nc );
    simulate ( panel, x     , y - 1 , pc, nc );
    simulate ( panel, x + 1 , y     , pc, nc );
    simulate ( panel, x     , y + 1 , pc, nc );

    return ;
  }

  private static
  int count (
    int[ ][ ]   panel,
    int         x,
    int         y,
    int         c
    )
  {
    int res;

    if ( x < 0 || y < 0
      || y >= panel.length
      || x >= panel[ y ].length ) return ( 0 );
    if ( panel[ y ][ x ] != c )   return ( 0 );

    /* Flags not to recount this point */
    panel[ y ][ x ] = -1;

    res  = 1;
    res += count ( panel, x - 1 , y     , c );
    res += count ( panel, x     , y - 1 , c );
    res += count ( panel, x + 1 , y     , c );
    res += count ( panel, x     , y + 1 , c );

    return ( res );
  }
}

Measured memory_bytes: 13000
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define rep(i,m,n) for(int i=m;i<n;i++)
ll mod=1e9+7;

int main(){
  int n,k;
  cin>>n>>k;
  ll ans=0;
  rep(i,k+1,n+1){
    ans+=(n+1)/i*(i-k)+max(0,(n+1)%i-k);
  }
  if(k==0) ans-=n;
  cout<<ans<<endl;
}

Measured memory_bytes: 256
//package AtCoderDp;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
    public static void main(String[] args)throws IOException {
        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
        int n=Integer.parseInt(br.readLine());
        int h[]=new int[n+1];
        StringTokenizer st=new StringTokenizer(br.readLine());
        long dp[]=new long[n+1];
        for(int i=1;i<=n;i++){
            h[i]=Integer.parseInt(st.nextToken());
        }
        dp[n-1]=Math.abs(h[n]-h[n-1]);
        for(int i=n-2;i>=1;i--){
            dp[i]=Long.MAX_VALUE;
            for(int j=i+1;j<=i+2;j++){
                dp[i]=Math.min(dp[i],dp[j]+Math.abs(h[j]-h[i]));
            }
        }
        System.out.println(dp[1]);
    }
}


Measured memory_bytes: 42596
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <utility>
#include <cmath>
#include <climits>

#define ll long long int
#define pb push_back
#define mk make_pair
#define pq priority_queue

using namespace std;
typedef pair<int, int> P;
typedef pair<ll, int> Pl;
typedef pair<ll, ll> Pll;
const int inf = 1e9;
const ll linf = 1LL << 50;
const double EPS = 1e-10;

int main(int argc, char const* argv[])
{
  ll a, b;
  cin >> a >> b;
  if(a > 0)cout << "Positive" << endl;
  else if(a == 0)cout << "Zero" << endl;
  else{
    if(b >= 0)cout << "Zero" << endl;
    else{
      if((b - a) % 2 == 0)cout << "Negative" << endl;
      else cout << "Positive" << endl;
    }
  }
	return 0;
}


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

#define int long long
#define ull unsigned long long
#define ld long double
#define rep(a) rep1(i,a)
#define rep1(i,a) rep2(i,0,a)
#define rep2(i,b,a) for(int i=(b); i<((int)(a)); i++)
#define rep3(i,b,a) for(int i=(b); i>=((int)(a)); i--)
#define all(a) a.begin(),a.end()
#define pii pair<int,int>
#define pb push_back
#define mp make_pair
//#define inf 2000000000
#define inf 8000000000000000000
#define eps 1e-9
#define sz(a) ((int)a.size())
#define pow2(x) (1ll<<(x))
#define ceiling(a,b) (((a)+(b)-1)/(b))
#define print0(a) cout << (a) << ' '
#define print1(a) cout << (a) << '\n'
#define print2(a,b) cout << (a) << ' ',print1(b)
#define print3(a,b,c) cout << (a) << ' ',print2(b,c)
#define print4(a,b,c,d) cout << (a) << ' ',print3(b,c,d)
#define ykh mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#ifdef i_am_noob
#define debug(a) print2(#a,a)
#else
#define debug(a)
#endif
#define ordered_set tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>

using namespace std;
using namespace __gnu_pbds;

const int Mod=1000000007,Mod2=998244353;
const int MOD=Mod;

inline int add(int a, int b){return (a+b>=MOD?a+b-MOD:a+b);}
inline int sub(int a, int b){return (a+MOD-b>=MOD?a-b:a+MOD-b);}
int Pow(int a, int b){
	if(!b) return 1;
	int tmp=Pow(a*a%MOD,b>>1);
	return (b&1?tmp*a%MOD:tmp);
}
inline int inverse(int n){return Pow(n,MOD-2);}

const int maxn=200005;
//i_am_noob
int n;

signed main(){
    ios_base::sync_with_stdio(0),cin.tie(0);
    cin >> n;
    print1(n%1000?1000-n%1000:0);
    return 0;
}


Measured memory_bytes: 3548
#include <bits/stdc++.h>
#define REP(i, n) for (long i = 0; i < n; ++i)
#define FOR(i, b, n) for (long i = b; i < n; ++i)

using namespace std;
using ll = long long;
using P = pair<long, long>;

void solve(long N, vector<long> A, vector<long> B) {
  // the best strategy is to eat max(Ai + Bi)

  // create Ai + Bi list
  vector<P> ryouri(N);
  REP(i, N)
    ryouri[i] = P(A[i] + B[i], i);

  // sort the list
  sort(ryouri.rbegin(), ryouri.rend());

  // simulate
  ll taka(0), aoki(0);
  REP(i, N)
    if (i % 2)
      aoki += B[ryouri[i].second];
    else
      taka += A[ryouri[i].second];

  // get the answer
  cout << taka - aoki << endl;
}

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

  long N;
  cin >> N;
  vector<long> A(N);
  vector<long> B(N);
  REP(i, N)
    cin >> A[i] >> B[i];

  solve(N, move(A), move(B));

  return 0;
}


Measured memory_bytes: 6348
#include <stdio.h>
#include <iostream>
#include <cmath>

using namespace std;

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

    if(
        (s[2]==s[3])
        &&
        (s[4]==s[5])
    ) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    

    return 0;
}

Measured memory_bytes: 256
n = gets.chomp.to_i
a = gets.chomp.split(" ").map(&:to_i)
cnt = 0
while true
  0.upto(n-1) do |i|
    if a[i]%2 == 0
      a[i] /= 2
    else
      puts cnt
      exit
    end
  end
  cnt += 1
end
puts cnt

Measured memory_bytes: 3836
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <vector>
using namespace std;

const int mod = 1000000007;

inline int mul(int a, int b) {
    return (1LL * a * b) % mod;
}

int main() {
    int N;
    cin >> N;
    vector<int>a(N);
    for (int i = 0; i < N; ++i) {
        scanf("%d", &a[i]);
    }
    sort(a.begin(), a.end());


    int next_coor = 1;
    int res = 1;
    int num_elements = 0;
    int departed = 0;
    for (int i = 0, j; i < N; i = j) {
        // Find the interval.
        for (j = i+1; j < N; ++j) {
           if (a[j] != next_coor + j-i) {
               break;
           }
        }
    
        for (int k = 0; k < (j - i)/2; ++k) {
            num_elements += 2;
            res = mul(res, num_elements - departed);
            ++departed;
        }
        num_elements += (j - i) % 2;

        int candidate = next_coor + j - i + 1;
        if ((j - i) % 2 == 0) {
            --candidate;
        }
        next_coor = candidate;
    }
    while (departed < num_elements) {
        res = mul(res, num_elements - departed);
        ++departed;
    }
    cout << res << endl;

    return 0;
}


Measured memory_bytes: 640
import java.lang.Math;
import java.util.Scanner;

class Main {
    public static void main(String[] args) {
        Scanner sn = new Scanner(System.in);
        int S = sn.nextInt();
        int h = (int) Math.floor(S / 3600);
        int m = (int) Math.floor(S % 3600 / 60);
        int s = (int) Math.floor(S % 60);
        System.out.println(String.format("%d:%d:%d", h, m, s));
    }
}

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

int main(){

  int n;
  cin >> n;
  vector<int> V;
  V.push_back(1);

  for(int i = 6; i < 100001; i*=6){
    V.push_back(i);
  }
  for(int i = 9; i < 100001; i*=9){
    V.push_back(i);
  }
  sort(V.begin(),V.end());
  //for(int i = 0; i < V.size(); i++) cout << V[i] << " ";

  vector<int> dp(n+1);
  for(int i = 1; i < dp.size(); i++) dp[i] = 1e8;

  for(int i = 1; i <= n; i++){
    for(int j = 0; j < V.size(); j++){
      if(i >= V[j])
        dp[i] = min(dp[i],dp[i - V[j]]+1);
    }
    //cout << dp[i] << " ";
  }
  
  cout << dp[n] << endl;

	return 0 ;
}


Measured memory_bytes: 640
#include <iostream>
#include <iomanip>
#include <fstream>
#include <stdio.h>
#include <math.h>
#include <time.h>
#include <string>
#include <tuple>
#include <vector>
#include <map>
#include <unordered_map>
#include <list>
#include <set>
#include <stack>
#include <queue>
#include <cstdlib>
#include <algorithm>
#include <random>
#include <cassert>
using namespace std;
#define LL long long
#define MP(a, b) make_pair(a, b)
#define POWER9 1000000000
#define MOD POWER9+7
#define PI 3.14159265359

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << setprecision(9);

	int H,W,h,w;
	cin >> H >> W >> h >> w;
	cout << H*W - h*W - w*H + w*h << endl;

	return 0;
}

/*

int main(){
cin.tie(0);
ios::sync_with_stdio(false);
cout << setprecision(9);



return 0;
}
*/

Measured memory_bytes: 256
#include <stdio.h>

int main(){
  int A, B, C, X, Y, i, j, ans;
  scanf("%d %d %d %d %d", &A, &B, &C, &X, &Y);
  if(A+B<2*C){
    if(X<Y){
      ans = A*X + B*X;
      if(B < 2*C) ans += B*(Y-X);
      else ans += 2*C*(Y-X);
    } else {
      ans = A*Y + B*Y;
      if(A < 2*C) ans += A*(X-Y);
      else ans += 2*C*(X-Y);
    }
  } else {
    if(X<Y){
      ans = 2*C*X;
      if(B < 2*C) ans += B*(Y-X);
      else ans += 2*C*(Y-X);
    } else {
      ans = 2*C*Y;
      if(A < 2*C) ans += A*(X-Y);
      else ans += 2*C*(X-Y);
    }
  }
  printf("%d\n", ans);
  return 0;
}

Measured memory_bytes: 128
# -*- coding: utf-8 -*-
N, K = map(int, input().split(" "))
S = input()
d = {"A": "a", "B": "b", "C": "c"}
r = ""
for i, s in enumerate(S):
    if i == K-1:
        r += d[s]
    else:
        r += s
print(r)

Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
#define finish(x){cout << x << endl; exit(0);}
#define ll long long

const int N = 100001;

int n;
vector <int> a, v[N];

ll dfs(int node, int pnode){
    ll s = 0;
    ll mx = 0;
    for(auto &i : v[node]){
        if(i == pnode) continue;
        ll cur = dfs(i, node);
        s += cur;
        mx = max(mx, cur);
    }
    if(v[node].size() == 1) return a[node];
    ll x = 2 * a[node] - s;
    ll y = s - a[node];
    if(x < max(0LL, 2 * mx - s) || y < 0) finish("NO");
    if(pnode == -1 && x) finish("NO");
    return x;
}
int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cin >> n;
    a.resize(n);
    for(auto &i : a) cin >> i;
    for(int i = 0 ; i < n - 1 ; i++){
        int x, y;
        cin >> x >> y;
        x--; y--;
        v[x].push_back(y);
        v[y].push_back(x);
    }
    if(n == 2){
        if(a[0] == a[1]) cout << "YES" << endl;
        else cout << "NO" << endl;
        return 0;
    }
    int root = 0;
    for(int i = 0 ; i < n ; i++){
        if(v[i].size() != 1) root = i;
    }
    dfs(root, -1);
    cout << "YES" << endl;
}


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

#define pb push_back
#define F first
#define S second
#define y1 dasdasfasfas
#define x1 wqdadfasfasfas
#define All(c) c.begin(), c.end()
#define SZ(A) (int((A).size()))
#define umap unordered_map
#define __ fflush(stdout)
#define FILENAME ""

typedef long long ll;
typedef long double ld;    

using namespace std;

void FREOPEN() {
	#ifdef LOCAL
		freopen(".in", "r", stdin);
		freopen("1.out", "w", stdout);
	#else
		//freopen(FILENAME".in", "r", stdin);
		//freopen(FILENAME".out", "w", stdout);
	#endif
}

inline double Time() {return (clock() * 1.0) / CLOCKS_PER_SEC; }             

const int N = 20, inf = 2e9;

const ll MOD = 1e9 + 7ll, INF = 1e18;

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

ll a[N][N], dp[(1 << N)], sum[(1 << N)];

string bit(int x) {
	string ret = "";
	for (int i = 0; i < 16; i++) {
		if (x & (1 << i)) ret += '1';
		else ret += '0';
	}
	return ret;
}

int main() {
	FREOPEN();
	int n;
	scanf("%d ", &n);
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			scanf("%lld", &a[i][j]);
		}
	}
	for (int mask = 0; mask < (1 << n); mask++) {
		for (int i = 0; i < n; i++) {
			for (int j = i + 1; j < n; j++) {
				if (mask & (1 << i)) {
					if (mask & (1 << j)) {
						sum[mask] += a[i][j];
					}
				}
			}
		}
	}
	for (int mask = 0; mask < (1 << n); mask++) {
		int revmask = 0;
		for (int i = 0; i < n; i++) {
			if ((mask & (1 << i)) == 0) revmask |= (1 << i);
		}
		for (int add = revmask; ; add = ((add - 1) & revmask)) {
			dp[(mask | add)] = max(dp[(mask | add)], dp[mask] + sum[add]);
			if (add == 0) break;
		}	
	}
	printf("%lld", dp[(1 << n) - 1]);
	return 0;
}


Measured memory_bytes: 2816
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pi;
#define debug(x) cerr << #x << ": " << x << endl;
#define debug2(x, y) debug(x) debug(y);
#define repn(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(i, a) for(int i = 0; i < (int)(a); i++)
#define all(v) v.begin(), v.end() 
#define mp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define sq(x) ((x) * (x))

template<class T> T gcd(T a, T b){ return ((b == 0) ? a : gcd(b, a % b)); }

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	//freopen("input.in", "r", stdin);
	//freopen("output.out", "w", stdout);
	int d, n;
	cin >> d >> n;
	if(!d){
		if(n != 100) cout << n << endl;
		else cout << 101 << endl;
	}
	else if(d == 1){
		if(n != 100) cout << 100 * n << endl;
		else cout << 100 * 101 << endl;
	}
	else{
		if(n != 100) cout << 10000 * n << endl;
		else cout << 10000 * 101 << endl;
	}
	return 0;
}
/*
Things to look out for:
	- Integer overflows
	- Array bounds
	- Special cases
Be careful!
*/


Measured memory_bytes: 256
#include "bits/stdc++.h"
#define FI first.first
#define SE first.second
#define TH second
#define fi first
#define se second
#define th second

using namespace std;

template<typename T>
string to_string(const vector<T>& vc, int w) {
	if(vc.empty()) return "";
	if(w + 1 == vc.size()) return to_string(vc[w]);
	return to_string(vc[w]) + "," + to_string(vc, w + 1);
}

template<typename T>
string to_string(const vector<T>& vc) {
	return "{" + to_string(vc, 0) + "}";
}

void debug_out() { cerr << endl; }
 
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
 
#ifdef DEBUG
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

class DebugStream {}LOG;
template <typename T>DebugStream &operator<<(DebugStream &s, const T&) { return s; }
#ifdef DEBUG
#define LOG clog
#endif

typedef long long ll;
typedef pair<ll, ll> ii;
typedef long double ld;
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());

const int maxN = 1e5 + 9, maxV = 1e6 + 9, MOD = 1e9 + 7, SQ = 335, lg = 20, bs = 29;

ll mulm(ll a, ll b) {
	ll ret = 0;
	while(b) {
		if(b & 1) ret = min(ll(1e18) + 1, ret + a);
		a = min(ll(1e18) + 1, a * 2);
		b >>= 1;
	}
	return ret;
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	#ifdef DEBUG
	freopen("input.txt", "r", stdin);
	#endif

	int n;
	cin >> n;
	ll mul = 1;
	for(int i = 0; i < n; i++) {
		ll inp;
		cin >> inp;
		mul = mulm(mul, inp);
	}
	if(mul == ll(1e18) + 1) mul = -1;
	cout << mul << '\n';
}



Measured memory_bytes: 3664
#include <bits/stdc++.h>
#define N 1000000007
using namespace std;
 
long long n;
vector<int> edge[100005];
bool ch[100005] = {0};
long long dp[100005][2] = {0};
 
long long solve(int x);
 
int main() {
  cin >> n;
  for(int i = 0; i < n - 1; ++i) {
    int x, y;
    cin >> x >> y;
    --x;
    --y;
    edge[x].push_back(y);
    edge[y].push_back(x);
  }
  cout << solve(0) << endl;
  return 0;
}
 
long long solve(int x) {
  ch[x] = 1;
  long long b = 1, w = 1;
  for(int i = 0; i < edge[x].size(); ++i) {
    if(!ch[edge[x][i]]) solve(edge[x][i]);
    if(dp[edge[x][i]][0] == 0) continue;
    b *= dp[edge[x][i]][1];
    b %= N;
    w *= (dp[edge[x][i]][0] + dp[edge[x][i]][1]) % N;
    w %= N;
  }
  dp[x][0] = b;
  dp[x][1] = w;
  return (dp[0][0] + dp[0][1]) % N;
}

Measured memory_bytes: 14336
from collections import deque,defaultdict,Counter
from itertools import accumulate
import bisect
from heapq import heappop,heappush
from fractions import gcd
from copy import deepcopy
import math
Mod = 1000000007



def main(): #startline-------------------------------------------
    S = input()
    N = len(S)
    p = [0,0,0,1]
    for i in range(N):
        if S[i] == "A":
            p[0] += p[3]
            p[0] %= Mod
        elif S[i] == "B":
            p[1] += p[0]
            p[1] %= Mod
        elif S[i] == "C":
            p[2] += p[1]
            p[2] %= Mod
        elif S[i] == "?":
            p[2] = p[2]*3 + p[1]
            p[1] = p[1]*3 + p[0]
            p[0] = p[0]*3 + p[3]
            p[3] *= 3
            for l in range(4):
                p[l] %= Mod

    print(p[2])
if __name__ == "__main__":
    main() #endline===============================================




def sieve_of_eratosthenes(n):
    if not isinstance(n,int):
        raise TypeError("n is not int")
    if n<2:
        raise ValueError("n < 2 is not effective")
    prime = [1]*(n+1)
    for i in range(2,int(math.sqrt(n))):
        if prime[i] == 1:
            for j in range(2*i,n):
                if j%i == 0:
                    prime[j] = 0
    res = []
    for i in range(2,n):
        if prime[i] == 1:
            res.append(i)
    return res

class UnionFind:
    def __init__(self,n):
        self.parent = [i for i in range(n+1)]
        self.rank = [0 for i in range(n+1)]
    
    def findroot(self,x):
        if x == self.parent[x]:
            return x
        else:
            y = self.parent[x]
            y = self.findroot(self.parent[x])
            return y
    
    def union(self,x,y):
        px = self.findroot(x)
        py = self.findroot(y)
        if px < py:
            self.parent[py] = px
        else:
            self.parent[px] = py

    def same_group_or_no(self,x,y):
        return self.findroot(x) == self.findroot(y)

Measured memory_bytes: 5808