akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
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 main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	int ans = 1;
	while(ans*2 <= n) ans *= 2;
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3652
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        FastReader in = new FastReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        BEasyLinearProgramming solver = new BEasyLinearProgramming();
        solver.solve(1, in, out);
        out.close();
    }

    static class BEasyLinearProgramming {
        public void solve(int testNumber, FastReader s, PrintWriter out) {
            int a = s.nextInt();
            int b = s.nextInt();
            int c = s.nextInt();
            int k = s.nextInt();

            int ans = 0;
            ans += Math.min(a, k);

            k = Math.max(k - a, 0);
            k = Math.max(k - b, 0);

            ans -= Math.min(c, k);
            k = Math.max(k - c, 0);
            out.println(ans);
        }

    }

    static class FastReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private FastReader.SpaceCharFilter filter;

        public FastReader(InputStream stream) {
            this.stream = stream;
        }

        public int read() {
            if (numChars == -1) {
                throw new InputMismatchException();
            }
            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (numChars <= 0) {
                    return -1;
                }
            }
            return buf[curChar++];
        }

        public int nextInt() {
            int c = read();
            while (isSpaceChar(c)) {
                c = read();
            }
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            int res = 0;
            do {
                if (c < '0' || c > '9') {
                    throw new InputMismatchException();
                }
                res *= 10;
                res += c - '0';
                c = read();
            } while (!isSpaceChar(c));
            return res * sgn;
        }

        public boolean isSpaceChar(int c) {
            if (filter != null) {
                return filter.isSpaceChar(c);
            }
            return isWhitespace(c);
        }

        public static boolean isWhitespace(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public interface SpaceCharFilter {
            public boolean isSpaceChar(int ch);

        }

    }
}



Measured memory_bytes: 32384
/**
 *    author:  tourist
 *    created: 25.11.2017 12:52:51       
**/
#include <bits/stdc++.h>

using namespace std;

const int N = 2010;

int a[N][N];
vector<int> res[N];

int main() {
  int k = 38;
  int n = k * (k - 1) + 1;
  for (int x = 0; x < n; x++) {
    vector<int> cur;
    for (int i = 0; i < n; i++) {
      if ((int) cur.size() == k) {
        break;
      }
      if ((int) res[i].size() == k) {
        continue;
      }
      bool ok = true;
      for (int j : cur) {
        if (a[j][i]) {
          ok = false;
          break;
        }
      }
      if (ok) {
        if (x >= k && !cur.empty()) {
          int A = (x - 1) % (k - 1);
          if (A >= 0) {
            int B = (x - k) / (k - 1);
            int diff = ((i - 1) % (k - 1) - (i - 1) / (k - 1) * B + (k - 1) * (k - 1)) % (k - 1);
            if (diff != (A + B) % (k - 1)) {
              continue;
            }
          }
        }
        for (int j : cur) {
          a[j][i] = 1;
        }
        cur.push_back(i);
        res[i].push_back(x);
      }
    }
    if (!((int) cur.size() == k)) {
      puts("error");
      assert((int) cur.size() == k);
      break;
    }
  }
  printf("%d %d\n", n, k);
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < (int) res[i].size(); j++) {
      if (j > 0) {
        putchar(' ');
      }
      printf("%d", res[i][j] + 1);
    }
    printf("\n");
  }
  return 0;
}


Measured memory_bytes: 13184
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (register int i = a; i <= b; i++)
#define PAUSE system("pause");
#define FASTIO                    \
    ios_base::sync_with_stdio(0); \
    cin.tie(0);                   \
    cout.tie(0);
#define FILEIO                     \
    freopen("in.txt", "r", stdin); \
    freopen("out.txt", "w", stdout);
template <typename T>
void read(T &x)
{
    x = 0;
    int flag = 1;
    char c = getchar();
    while (c < '0' || c > '9')
    {
        if (c == '-')
            flag = -1;
        c = getchar();
    }
    while (c >= '0' && c <= '9')
    {
        x = x * 10 + c - '0';
        c = getchar();
    }
    x *= flag;
}
const int MOD = 1e9 + 7, INF = 0x3f3f3f3f;

char s[100010] = {'\0'};
int main()
{
    int ans1 = 0, ans2 = 0;
    cin >> s;
    int i;
    for (i = 0; s[i] != '\0'; i++)
    {
        if (s[i] - '0' == i %2)
            ans1++;
        else
            ans2++;
    }
    cout << min(min(min(ans1, ans2), i - ans1), i - ans2);
    return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <math.h>
#include <tuple>

#include <set>
#include <unordered_map>
#include <stack>
#include <map>

using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define all(x) (x).begin(),(x).end()
using ll = long long;
template<class T>bool chmaxj(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; }
void YesNo(bool y) { cout << (y ? "Yes" : "No") << endl; } //true==yes


#define INF 21474836

//////////////////////////////////////////////////////////////

int main() {

	int N, K;
	cin >> N >> K;
	
	long long ans = 0;

	long long max = 0;
	long long min = 0;

	rep(i, K) {
		max += N - i;
		min += i;
	}
	ans += max - min + 1;
	ans = ans % 1000000007;

	for (int k = K+1; k <= N+1; k++) 
	{
		max += N - (k - 1);
		min += k - 1;
		ans += max - min + 1;
		ans = ans % 1000000007;
	}

	cout << ans << endl;

}


Measured memory_bytes: 3196
//ΔARC 095C
#include<iostream>
#include<cstdio>
#include<fstream>
#include<algorithm>
#include<vector>
#include<map>
#include<set>
#include<queue>
#include<cmath>
#include<cstring>
#include<cstdlib>
using namespace std;
typedef long long LL;
typedef double DB;
const int N = 15;
int n,m,p[N];
char a[N][N];
string l[N],r[N];
int main()
{
	srand(19260817);
	int i,j,x,f,o=30000;
	cin>>n>>m;
	for(i=1;i<=n;i=i+1)
		scanf("%s",a[i]+1);
	while(o--){
		for(j=1;j<=m;j=j+1)
			l[j]="",r[j]="";
		for(i=1;i<=n;i=i+1)
			p[i]=i;
		random_shuffle(p+1,p+n+1);
		for(i=1;i<=n;i=i+1){
			x=p[i];
			for(j=1;j<=m;j=j+1)
				l[j]=l[j]+a[x][j],r[j]=a[x][j]+r[j];
		}
		for(j=1;j<=m;j=j+1)
			p[j]=0;
		f=m&1;
		for(j=1;j<=m;j=j+1){
			if(p[j])
				continue;
			p[j]=1;
			x=1;
			while(p[x]||x<=m&&l[j]!=r[x]){
				x++;
			}
			if(x<=m)
				p[x]=1;
			else{
				if(l[j]==r[j]&&f)
					f--;
				else
					break;
			}
		}
		if(j>m){
			cout<<"YES";
			return 0;
		}
	}
	cout<<"NO";
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstring>
#include<algorithm>
using namespace std;
int x[30][2];
int y[30];
int h, w, sum;
int s[20], t[20];

int hantei() {
	sum = 0;
	memset(x, 0, sizeof(x));
	memset(y, 0, sizeof(y));
	for (int i = 0; i < h; i++) {
		x[s[i]][0]++;
	}
	for (int i = 0; i < w; i++) {
		x[t[i]][1]++;
	}
	for (int i = 0; i < 30; i++) {
		y[i] = max(x[i][0], x[i][1]);
		sum += y[i] * i;
	}
	return sum;
}

int main() {
	while (true) {
		cin >> h >> w;
		if (h == 0 && w == 0) { break; }
		for (int i = 0; i < h; i++) {
			cin >> s[i];
		}
		for (int i = 0; i < w; i++) {
			cin >> t[i];
		}
		cout << hantei() << endl;
	}
}

Measured memory_bytes: 1156
import sys


def rollDice(dice, direction):
    buf = [x for x in dice]
    if direction == "S":
        buf[0] = dice[4]
        buf[1] = dice[0]
        buf[4] = dice[5]
        buf[5] = dice[1]
    elif direction == "E":
        buf[0] = dice[3]
        buf[2] = dice[0]
        buf[3] = dice[5]
        buf[5] = dice[2]
    elif direction == "W":
        buf[0] = dice[2]
        buf[2] = dice[5]
        buf[3] = dice[0]
        buf[5] = dice[3]
    elif direction == "N":
        buf[0] = dice[1]
        buf[1] = dice[5]
        buf[4] = dice[0]
        buf[5] = dice[4]

    for i in range(6):
        dice[i] = buf[i]


def rollDiceSide(dice):
    buf = [x for x in dice]
    buf[1] = dice[2]
    buf[2] = dice[4]
    buf[3] = dice[1]
    buf[4] = dice[3]

    for i in range(6):
        dice[i] = buf[i]


def isSameRollSide(d1, d2):
    if d1 == d2:
        return True
    rollDiceSide(d2)
    return False


def isSameRoll(d1, d2):
    if d1 == d2:
        return True
    rollDice(d2, "S")
    for _ in range(4):
        if isSameRollSide(d1, d2):
            return True
    return False


def isSameDice(d1, d2):
    for _ in range(4):
        for _ in range(4):
            if isSameRoll(d1, d2):
                return True
        rollDice(d2, "W")
    return False


n = int(input())
dice = [list(map(int, input().split())) for i in range(n)]
ans = [False for x in range(n)]
for i in range(n):
    for j in range(n):
        if i == j:
            continue
        if isSameDice(dice[i], dice[j]):
            ans[i] = True
            break
if True in ans:
    print("No")
else:
    print("Yes")



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

int N;
vector<int> A;


int dp[10100];

int solve(){
	vector<int> ansv;
	long long ans=0;

	sort(A.begin(),A.end());

	int small = 0;
	int large = N-1;

	ans += A[N-1]-A[0];
	for(int i=0; i<N/2-1; i++){
		ans += abs( A[large] - A[small+1] );
		ans += abs( A[small] - A[large-1] );		
		small++; large--;
	}

	if(N%2==1) ans+=max(abs(A[N/2]-A[N/2+1]), abs(A[N/2]-A[N/2-1]));

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


int main(){
	cin >> N;
	A.resize(N);
	for(int i=0;i<N;i++){
		cin >> A[i];
	}

	solve();
	return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using  namespace  std;
using ll=long long;
int main(){
  vector<int> a(3);
  for(int i=0;i<3;i++)cin>>a.at(i);
  sort(a.begin(),a.end());
  if(a.at(2)==a.at(0)+a.at(1))cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main() {
  int x;
  cin>>x;
  if(400<=x&&x<=599) cout<<8<<endl;
  else if(600<=x&&x<=799) cout<<7<<endl;
  else if(800<=x&&x<=999) cout<<6<<endl;
  else if(1000<=x&&x<=1199) cout<<5<<endl;
  else if(1200<=x&&x<=1399) cout<<4<<endl;
  else if(1400<=x&&x<=1599) cout<<3<<endl;
  else if(1600<=x&&x<=1799) cout<<2<<endl;
  else if(1800<=x&&x<=1999) cout<<1<<endl;
}

Measured memory_bytes: 3628
#include<stdio.h>
int fun(int a,int b);
int main(void)
{
	int a,b,c;
	int flag=0;
	scanf("%d%d%d",&a,&b,&c);
	int d=fun(a,b);
	for(int i=a;i<=d;i+=a)
	{
		if(i%b==c)
		{
			flag=1;
			break;
		}
	}
	if(flag) printf("YES\n");
	else printf("NO\n");
	return 0;
}
int fun(int a,int b)
{
	int q=a;
	while(q%b!=0)
	{
		q+=a;
	}
	return q;
}

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

int main(){

  ll a,b,c,k;
  cin >> a >> b >> c >> k;
  ll cnt = 0;

  for (ll i = 0; i < k; i++) {

    if (a > i) {
      cnt++;
    } else if (a+b > i) {

    } else {
      cnt--;
    }

  }
  cout << cnt << endl;








}


Measured memory_bytes: 3624
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <stack>
#include <deque>
#include <cmath>
#include <map>
using ll = long long;
using namespace std;

int main() {
  string s;
  cin >> s;
  int l = s.length();
  string ans = s[0] + to_string(l-2) + s[l-1];
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> P;
map <int,int> mp;
vector<int> V;
#define INF (1<<29) //53687091
#define INFLL (1ll<<58)
#define EPS (1e-10)
static const int MAX=10;
static const int MOD=1e9+7;
static const int NMAX=40;
static const int MMAX=0;
int dx[4]={0,1,0,-1},dy[4]={-1,0,1,0};
const int tx[8] = { -1,0,1,-1,1,-1,0,1 }, ty[8] = { -1,-1,-1,0,0,1,1,1 };
int a[NMAX],b[NMAX],c[NMAX],N,Ma,Mb;

int dp[NMAX+1][NMAX*MAX+1][NMAX*MAX+1]; //i-1までの組み合わせで、ca g cb gのときの最小コスト
void solve(){
    for(int i=0;i<=N;i++){
        for(int ca=0;ca<=NMAX*MAX;ca++){
            for(int cb=0;cb<=NMAX*MAX;cb++) dp[i][ca][cb]=INF;
        }
    }
    dp[0][0][0]=0;
    for(int i=0;i<N;i++){
        for(int ca=0;ca<=NMAX*MAX;ca++){
            for(int cb=0;cb<=NMAX*MAX;cb++){
                if(dp[i][ca][cb]==INF) continue;//ca,cbの組み合わせがまだない
                //この前のca,cbループで記録されたものと比較
                dp[i+1][ca][cb]  = min(dp[i+1][ca][cb],dp[i][ca][cb]); //iを加えない
                dp[i+1][ca+a[i]][cb+b[i]] = min(dp[i+1][ca+a[i]][cb+b[i]],dp[i ][ca][cb]+c[i]);//iを加える
             }
        }
    }
    int ans = INF;
    for(int ca = 1;ca<=NMAX*MAX;ca++){
        for(int cb = 1;cb<=NMAX*MAX;cb++){
            if(ca*Mb==cb*Ma) ans=min(ans,dp[N][ca][cb]); //ca:cb=Ma:Mbとなるすべての組み合わせを確かめる
        }
    }
    if(ans == INF) ans = -1;
    cout<<ans<<"\n";
    
}

int main(){
    cin.tie(0);  ios::sync_with_stdio(false);
    cin >> N>> Ma >> Mb;
    for(int i=0;i<N;i++) cin >> a[i] >> b[i] >> c[i];

    solve();
    
    return 0;
}


Measured memory_bytes: 25984
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {
    Scanner scanInt = new Scanner(System.in);
    int[] nums = new int[2];
    int gcd;
    nums[0] = scanInt.nextInt();
    nums[1] = scanInt.nextInt();
    gcd = gcd(nums[0], nums[1]);
    System.out.println(gcd);
  }

  public static int gcd(int num_1, int num_2){
    if (num_1 % num_2 != 0){
      return gcd(num_2, num_1 % num_2);
    }else{
      return num_2;
    }
  }


}




Measured memory_bytes: 26216
#include<iostream>

using namespace std;

int main(){

   char n[5];

   cin >> n;

   if(n[0] == n[1] && n[1] == n[2] && n[2] ==n[3]){
      cout << "Yes" << endl;
   }else if(n[0] == n[1] && n[1] == n[2]){
      cout << "Yes" << endl;
   }else if(n[1] == n[2] && n[2] == n[3]){
      cout << "Yes" << endl;
   }else{
      cout << "No" << endl;
   }

   return 0;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
//#define ll long long
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 (a>b) { a=b; return 1; } return 0; }
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
#define all(x) (x).begin(),(x).end()
ll tmp1,tmp2,tmp3;
const ll mod = 1000000007;
const int INF = 1e9;
const ll INFLONG = 1e18;
void swap(ll *x,ll *y){
  ll tmp;
  tmp = *x;
  *x = *y;
  *y = tmp;
}

ll maxi = 6400;
ll ans[80][80][6400];
int main(){
  ll h,w;
  cin >> h >> w;
  vector<vector<ll>> a(80,vector<ll>(80)),b(80,vector<ll>(80)),c(80,vector<ll>(80));

  //vector<vector<vector<ll>>> ans(h,vector<vector<ll>>(w,vector<ll>(maxi,0)));
  memset(ans,0,sizeof(ans));
//  rep(i,h){
//    rep(j,w){
//      rep(k,maxi){
//        ans[i][j][k] = 0;
//      }
//    }
//  }
  rep(i,h){
    rep(j,w){
      cin >> a[i][j];
    }
  }
  rep(i,h){
    rep(j,w){
      cin >> b[i][j];
    }
  }
  rep(i,h){
    rep(j,w){
      c[i][j] = abs(a[i][j] - b[i][j]);
    }
  }
  ans[0][0][c[0][0]] = 1;
  for(ll i = 0;i < h;i++){
    for(ll j = 0;j < w;j++){
      rep(k,maxi){
        if(ans[i][j][k]){
          if(i != h-1){
            tmp1 = k + c[i+1][j];
            if(tmp1 < 6400){
              ans[i+1][j][tmp1] = 1;
            }
            tmp2 = abs(k - c[i+1][j]);
            if(tmp2 < 6400){
              ans[i+1][j][tmp2] = 1;
            }
          }

          if(j != w-1){
            tmp1 = k + c[i][j+1];
            if(tmp1 < 6400){
              ans[i][j+1][tmp1] = 1;
            }
            tmp2 = abs(k - c[i][j+1]);
            if(tmp2 < 6400){
              ans[i][j+1][tmp2] = 1;
            }
          }
        }
      }
    }
  }
  ll mini = INFLONG;
  rep(i,maxi){
    if(ans[h-1][w-1][i]){
      mini = i;
      break;
    }
  }
  cout << mini << endl;
}


Measured memory_bytes: 320512
/*
*                                 Name : chaitanya
*
*                         Institute : ANITS,Visakhapatnam
*   "Don't regret anything you do, because in the end it makes you who you are."
*
*/
#include<cstdio>
#include<iostream>
#include<sstream>
#include<fstream>
#include<iomanip>
#include<algorithm>
#include<cmath>
#include<complex>
#include<cstring>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#include<numeric>
#include<limits>
#include<climits>
#include<cfloat>
#include<functional>
#include<iterator>
#include <random>
#include<sstream>
#include <assert.h>
#define infy  1000000000
#define all(x) begin(x),end(x)
#define ll long long int
#define ff first
#define ss second
#define pb push_back
const ll m = 1000000007;
using namespace std;

int main()
{
    
    string s;
    cin >> s;
    if ( s[s.size()-1] == 's')
        cout << s << "es";
    else
        cout << s << "s";
    return 0;
}

Measured memory_bytes: 3628
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String a = sc.nextLine();
		String b = sc.nextLine();
		String c = b.substring(0, b.length() - 1);
				
		if(c.contains(a) && b.length() > a.length())
			System.out.println("Yes");
		else
			System.out.println("No");
	}
}


Measured memory_bytes: 35812
#include<bits/stdc++.h>
#define ll long long
#define rep(i,a,n) for(int i=a;i<=n;i++)
#define per(i,n,a) for(int i=n;i>=a;i--)
#define endl '\n'
#define mem(a,b) memset(a,b,sizeof(a))
#define IO ios::sync_with_stdio(false);cin.tie(0);
using namespace std;
const int INF=0x3f3f3f3f;
const ll inf=0x3f3f3f3f3f3f3f3f;
const int mod=1e9+7;
const int maxn=1e5+5;
int h[maxn];
int tot,head[maxn];
struct E{
	int to,next;
}edge[maxn<<1];
void add(int u,int v){
	edge[tot].to=v;
	edge[tot].next=head[u];
	head[u]=tot++;
}
int main(){
	int n,m;cin>>n>>m;mem(head,-1);
	for(int i=1;i<=n;i++) cin>>h[i];
	for(int i=1;i<=m;i++){
		int u,v;cin>>u>>v;
		add(u,v);add(v,u);
	}
	int ans=0;
	for(int u=1;u<=n;u++){
		int flag=0;
		for(int i=head[u];i!=-1;i=edge[i].next){
			int v=edge[i].to;
			if(h[v]>=h[u]){
				flag=1;break;
			}
		}
		if(!flag) ++ans;
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 5960
#include <bits/stdc++.h>
#define DEBUG if(0)
#define lli long long int
#define ldouble long double
using namespace std;

int digits(lli n, int k)
{
  int d = n == 0;
  while (n)
  {
    d ++;
    n /= k;
  }
  return d;
}

int main()
{
  lli n; int k;
  while (scanf("%lld %d", &n, &k) != EOF)
  {
    printf("%d\n", digits(n, k));
  }
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cstdio>
#include <queue>
#include <algorithm>
#include <functional>
#include <string>
#include <queue>
#include <cmath>
#include <iomanip>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <numeric>
#define ll long long
#define fr(i,k,N) for(decltype(N+k) i=k; i<N;i++)
#define rep(i,N) for(decltype(N) i=0; i<N;i++)
#define ALL(v) v.begin(),v.end()
using namespace std;
template <class X> void pr(X test){cout<<test<<endl;}
template <class X> void prr(X test){for(auto it:test){cout<<it<<endl;}}
template <class X> void prrr(X test){int f=0;for(auto it:test){cout<<(f++!=0?" ":"")<<it;}cout<<endl;}
template<typename X>
istream&operator>>(istream&i,vector<X>&v){for(X&x:v)i>>x;return i;}

class UF { // union find from https://github.com/kartikkukreja/blog-codes (MIT)
    // [usage]
    // auto uf = new UF(n);
    // uf->merge(l, r); // 0 <= l, r <= n-1
    // ...
public:
    int *id; // inner id
    int cnt; // number of all vartices
    int *sz; // sz[i] means size of i's set
    UF(int N)   {
        cnt = N;
        id = new int[N];
        sz = new int[N];
        for(int i=0; i<N; i++) {
            id[i] = i;
            sz[i] = 1;
        }
    }
    ~UF() {
        delete [] id;
        delete [] sz;
    }
    int find(int p) {
        int root = p;
        while (root != id[root]) root = id[root];
        while (p != root) {
            int newp = id[p];
            id[p] = root;
            p = newp;
        }
        return root;
    }
    void merge(int x, int y) {
        int i = find(x);
        int j = find(y);
        if (i == j) return;
        
        if (sz[i] < sz[j]) {
            id[i] = j;
            sz[j] += sz[i];
        } else {
            id[j] = i;
            sz[i] += sz[j];
        }
        cnt--;
    }
    bool connected(int x, int y) {
        return find(x) == find(y);
    }
    int count() {
        return cnt;
    }
};

// return 約数unordered_set 1 <= x <= n
auto divv = [](auto n) {
  unordered_set<decltype(n)> v;
  for(decltype(n) i = 1; i*i <= n; i++) {
    if(n%i == 0) {
      v.insert(i);
      if(i*i != n) v.insert(n/i);
    }
  }
  return v;
};

// check prime (and n>=2) or not
auto isPrime = [](auto n){
  if(n <= 1) return false;
  for(decltype(n) i = 2; i <= sqrt(n); ++i) {
      if(n % i == 0) {
          return false;
      }
  }
  return true;
};



int main() {
    ll n;
    cin>>n;
    if(n>=2000){
        pr(1);
    }else{
        fr(i,1,20){
            ll a = i*100;
            ll b = i*105;
            if( a<=n && n<=b){
                pr(1);
                return 0;
            }
        }
        pr(0);
    }
}


Measured memory_bytes: 256
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val k = sc.nextLong()
    val a = sc.nextLong()
    val b = sc.nextLong()
    if (a + 2 > b || a - 1 > k) {
        println(1 + k)
        return
    }
    val rem = k - (a - 1)
    println(a + rem / 2 * (b - a) + rem % 2)
}

Measured memory_bytes: 31520
import java.util.*;

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

        for(int i = a;i <= b;i++){
            if(i-a < k || b-i < k)
                System.out.println(i);
        }
        
    }
}

Measured memory_bytes: 23636
#include<stdio.h>
int nxt[20][200005];
int a[200005];
int last[20];
int main()
{
    int n;
    scanf("%d",&n);
    int i,j,k; 
    for(j=0;j<20;j++)
    for(i=1;i<=n+1;i++)
    nxt[j][i] = n+1;
    for(i=1; i<=n; i++)
    {
        scanf("%d",&a[i]);
        for(j=0; j<20; j++)
        {
            if(a[i] & (1<<j))
            {
                for(k=last[j];k<i;k++)
                nxt[j][k] = i;
                last[j] = i;
            }
        }
    }
    long long ans = 0;
    for(i=1; i<=n; i++)
    {
        // starting from i consider next position of each bit and minimum of them 
        int pos = n+1;
        for(j=0; j<20; j++)
        {
            if(a[i] & (1<<j)){
        if(nxt[j][i] < pos)pos = nxt[j][i];
            }
            else {
                k = nxt[j][i];
                if(nxt[j][k] < pos)pos = nxt[j][k];
            }
            }
        
        
        ans += pos - i;
       // printf("from %d to %d\n",i,pos);
    }
    printf("%lld\n",ans);
    return 0;
}

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

#define ll long long
#define int long long
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define pii pair<int, int>
#define vi vector<int>
#define pqb priority_queue<int>
#define pqs priority_queue<int, vi, greater<int>>
#define setbits(x) __builtin_popcountll(x)
#define zrobits(x) __builtin_ctzll(x)
#define mod 1000000007
#define inf (int)(1e18)
#define ps(x, y) fixed << setprecision(y) << x
#define w(x)  \
    int x;    \
    cin >> x; \
    while (x--)
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define all(p) p.begin(), p.end()
#define ub(a, b) upper_bound(all(a), b)
#define lb(a, b) lower_bound(all(a), b)
#define PI 3.14159265
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

void run()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
}
void solution()
{
}
int32_t main()
{
    run();
    int n;
    cin >> n;
    int sum = 0;
    vector<int> a(n);
    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
    }
    sort(all(a));
    int x = n - 1;
    for (int i = n - 1; x > 0; i--)
    {
        if (i == n - 1 or x == 1)
        {
            sum += a[i];
            x--;
        }
        else
        {
            sum += (a[i] * 2);
            x -= 2;
        }
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 4736
#include <bits/stdc++.h>
using namespace std;
#define ll long long
 
const int mod = 1e9 + 7;
 
ll int power(int x, int y) {
    ll int res = 1;
    for(int i = 1; i <= y; i++) {
        res = (res * x) % mod;
    }
    return res;
}
 
int main() {
    int n;
    cin >> n;
    ll int s = (power(10, n) - 2 * power(9, n) + power(8, n)) % mod; 
    cout << (s + mod) % mod;
}

Measured memory_bytes: 3624
N = gets.to_i

#max = 57
max = 100
a = []
(1..max).each{ |x|
  (1..max).each{ |y|
    (1..max).each{ |z|
      n = x**2 + y**2 + z**2 + x*y + y*z + z*x
      a.push n
    }
  }
}

a2 = a.group_by{|n| n}
(1..N).each{ |n|
  puts a2.fetch(n, []).size
}


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

#define pb push_back
#define eb emplace_back
#define mk make_pair
#define fi first
#define se second
#define mset(a, b) memset(a, b, sizeof(a))
#define DBG(x) cout << "[" << #x << "]: " << x << endl
using ll = long long;
using pii = pair<int, int>;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

template<class Ty> Ty randint(Ty a, Ty b) { return uniform_int_distribution<Ty>(a, b)(rng); }
template<class num> inline void rd(num& x) {
	char c; while(isspace(c = getchar()));
	bool neg = false;
	if(!isdigit(c)) neg = (c == '-'), x = 0;
	else x = c - '0';
	while(isdigit(c = getchar())) x = (x << 3) + (x << 1) + c - '0';
	x = neg ? -x : x; }
template <class... Args> inline void rd(Args&... args) { (rd(args), ...); }
template <class... Args> inline void rf(Args&... args) { (cin >> ... >> args); }
template <class... Args> inline void pr(Args&&... args) { (cout << ... << args); }

const int MAXN = 2e5 + 5, INF = 0x3f3f3f3f;

int main() {
	ll a, b; rd(a, b);
	printf("%lld\n", a * b);
}

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

#define rep(i,n) for(int i=0; i<(n); ++i)
#define rrep(i,n) for(int i=1; i<=(n); ++i)
#define drep(i,n) for(int i=(n)-1; i>=0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define foreach(it, v) for(typeof(v.begin()) it=v.begin(); it!=v.end(); ++it)
#define pb push_back
#define sz(x) (int)(x).size()
#define fi first
#define se second
#define v(T) vector<T>

typedef unsigned int uint;
typedef long long int ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef vector<pii> vpii;
typedef set<int> si;
template<typename T>string join(const v(T)&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(sz(v))o<<join(v);return o;}

//MOD//
const ll MOD = 998244353;
struct big;
big ex(big a, ll tms);
typedef struct big{
  ll val;
  big():val(0){}
  big(ll val):val((val%MOD+MOD)%MOD){}
  big& operator += (const big& obj){ (val+=obj.val)%=MOD; return *this;}
  big& operator -= (const big& obj){ (val+=MOD-obj.val)%=MOD; return *this;}
  big& operator *= (const big& obj){ (val*=obj.val)%=MOD; return *this;}
  big& operator /= (const big& obj){ (val*=ex(obj,MOD-2).val)%=MOD; return *this;}
  big operator + (const big& obj)const{ return big(*this) += obj;}
  big operator - (const big& obj)const{ return big(*this) -= obj;}
  big operator * (const big& obj)const{ return big(*this) *= obj;}
  big operator / (const big& obj)const{ return big(*this) /= obj;}
  bool operator < (const big& obj)const{ return val < obj.val;}
  bool operator == (const big& obj)const{ return val == obj.val;}
} big;
istream& operator >> (istream& i, big& obj){ i>>obj.val; return i;}
ostream& operator << (ostream& o, const big& obj){ o<<obj.val; return o;}
big ex(big obj, ll tms){
  if(!tms) return 1;
  big ret = ex(obj, tms/2);
  ret *= ret;
  return (tms&1) ? ret*obj : ret;
}
//MOD//

template <class F, class T>
void convert(const F &f, T &t){
  stringstream ss;
  ss << f;
  ss >> t;
}

int N;
string S;

int cd(char c) {
  switch(c){
    case 'R':
    return 0;
    case 'G':
    return 1;
    case 'B':
    return 2;
  }
  return -1;
}

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

  cin >> N >> S;

  int s[3] = {0, 0, 0};
  big ans = big(1);

  for (char c : S) {
    int d = cd(c);
    s[d]++;
    int nz = 0;
    rep(j,3) if (s[j]) nz++;
    if (nz==3) {
      int mi = INT_MAX;
      rep(j,3) if (j!=d) mi = min(mi, s[j]);
      ans *= mi;
      rep(j,3) s[j]--;
      N--;
    } else if (nz==2) {
      int ma = 0;
      rep(j,3) if (j!=d) ma = max(ma, s[j]);
      if (ma>=s[d]) ans *= (ma+1-s[d]);
      else ans *= (N+1-s[d]);
    } else if (nz==1) {
      ans *= (N+1-s[d]);
    }
  }

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


Measured memory_bytes: 720
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main(){
  int n,m;
  cin >> n >> m;
  priority_queue<int, vector<int>, less<int>> Q3;
  rep(i,n){
    int a;
    cin >> a;
    Q3.push(a);
  }
  rep(i,m){
    int u=Q3.top();
    Q3.pop();
    Q3.push(u/2);
  }
  int64_t ans=0;
  rep(i,n){
    ans+=Q3.top();
    Q3.pop();
  }
  cout << ans << endl;
}  


Measured memory_bytes: 892
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <set>
#include <stack>
#include<algorithm>
#include<sstream>
#include<iomanip>
#include<deque>


using namespace std;

typedef long long ll;

const ll MOD_CONST = 1000000007;
const ll BIG_NUM = 1000000000000000000;
typedef pair<int, int> pii;


int main() {
	int k;
	cin >> k;
	
	vector<vector<pii>> g(k);
	for (int i = 1; i < k;i++) {
		g[i].emplace_back(make_pair((i + 1) % k,1));
		g[i].emplace_back(make_pair((i * 10) % k,0));
	}

	vector<int> d(k,10*k);
	vector<int> isChecked(k);
	d[1] = 0;
	deque<int> deq;
	deq.push_front(1);
	while (!deq.empty()) {
		int v = deq.front();
		deq.pop_front();
		if (v == 0) {
			break;
		}
		if (!isChecked[v]) {

			for (int i = 0; i < g[v].size();i++) {

				if (g[v][i].second == 0) {
					d[g[v][i].first] = min(d[v], d[g[v][i].first]);
					deq.push_front(g[v][i].first);

				}
				else {
					d[g[v][i].first] = min(d[v]+1, d[g[v][i].first]);
					deq.push_back(g[v][i].first);
				}

			}

			isChecked[v] = true;
		}

	}
	cout << d[0] + 1 << endl;
}


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

int N;
vector<int> L;

int main() {
  scanf("%d", &N);
  L = vector<int>(N);
  for (int n = 0; n < N; ++n) scanf("%d", &L[n]);
  
  sort(L.begin(), L.end());
  int sum = 0;
  for (int n = 0; n < N-1; ++n) sum += L[n];

  if (sum > L[N-1]) printf("Yes\n");
  else printf("No\n");
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int k;
    long long ans;
    cin>>k;
    
    queue<long long> lun;
    for(int i=1; i<=9; i++){
        lun.push(i);
    }
    
    for(int i=0; i<k-1; i++){
        ans=lun.front();
        if(ans%10!=0){
            lun.push(10*ans+(ans%10)-1);
        }
        lun.push(10*ans+(ans%10));
        if(ans%10!=9){
            lun.push(10*ans+(ans%10)+1);
        }
        lun.pop();
    }
    
    cout<<lun.front()<<endl;
    return 0;
}

Measured memory_bytes: 5160
import sys
import math
from collections import defaultdict

sys.setrecursionlimit(10**7)
def input():
    return sys.stdin.readline()[:-1]

mod = 10**9 + 7

def I(): return int(input())
def II(): return map(int, input().split())
def III(): return list(map(int, input().split()))
def Line(N,num):
    if N<=0:
        return [[] for _ in range(num)]
    elif num==1:
        return [I() for _ in range(N)]
    else:
        read_all = [tuple(II()) for _ in range(N)]
        return map(list, zip(*read_all))

#################

# FFT
# use python3
# a = np.array([a1,a2,a3]), b= np.array([b1,b2,b3])
# c = np.array([a1b1,a1b2+a2b1,a1a3+a2b2+a3b1,a2b3+a3b2,a3b3])
import numpy as np
def FFT(a,b):
    bit = (len(a)+len(b)).bit_length()+1
    L = 2**bit
    fa,fb = np.fft.rfft(a,L), np.fft.rfft(b,L)
    c = np.rint(np.fft.irfft(fa*fb,L)).astype(np.int64)
    return c[:len(a)+len(b)-1]

N,M = II()
A = III()

h = [0]*(max(A))
for a in A:
    h[a-1] += 1

conv = np.append([0,0],FFT(h,h))
ans = 0
count = 0

for k in range(2,2*max(A)+1)[::-1]:
    if conv[k]:
        num = min(M-count,conv[k])
        count += num
        ans += k*num
    if count==M:
        break

print(ans)

Measured memory_bytes: 55528
x = list(map(lambda x:int(x), input().split()))
X = x[0]
N = x[1]
p = []
if N != 0:
  p = list(map(lambda x:int(x), input().split()))

near = [False]*102

#print(near)
#print(near[200])

for i in p:
  near[i] = True
  
for i in range(0,100):
  if not near[X-i]:
    print(X-i)
    break
  elif not near[X+i]:
    print(X+i)
    break
  

Measured memory_bytes: 9204
// When you are hungry for something and you're determined and you're focused 
// and you're committed to something it's hard to surrender, isn't it?

#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(), (x).end()
#define endl "\n"
#define ll long long 
#define int ll
#define mod 1000000007
#define mod1 1000000006
#define modi 998244353
#define setbit(x) __builtin_popcount(x)
#define ff first
#define ss second
#define pb push_back
vector<ll> vi[300005];
int color[100005];
ll pa[500005];
ll si[500005];
#define pb push_back
bool visi[1000005]={false};
bool is[100005];
ll fac[10000001];
ll prime[400005];
ll bit[100005];
const long double eps = 1.0e-14;      // allowable error
#define fio ios_base::sync_with_stdio(false); cin.tie(NULL);
 
 
void fact(){
    fac[0]=1;
    for(int i=1;i<=10000000;i++){
        fac[i]=(fac[i-1]*i)%mod;
    }
    return ;
}
void sieve(){
    prime[0]=0;
    prime[1]=0;
    for(int i=2;i<400005;i++){
        prime[i]=1;
    }
    for(int i=2;i*i<400005;i++){
        if(prime[i]==1){
            for(int j=i*i;j<400005;j+=i){
                prime[j]=0;
            }
        }
    }
    
}
 
ll power(ll n , ll p ){
    if(p==0)
        return 1;
    
    ll res = power((n*n)%mod,p/2);
    if(p%2==1)
        res = (n*res)%mod;
    
    return res;
}
 
 
void upd(ll i,ll val,ll n) {
    for(;i<=n;i+=i&(-i))
        bit[i]+=val;
}
 
ll qry(ll i) {
    ll sum=0;
    for(;i>0;i-=i&(-i))
        sum+=bit[i];
    return sum;
}
 
 
ll fin(ll u) {
    if(pa[u]==u)
        return u;
    return fin(pa[u]);
}
 
void uni(ll u,ll v) {
    ll p1=fin(u);
    ll p2=fin(v);
    if(p1==p2)
        return;
    if(si[p1]<si[p2])
        swap(p1,p2);
    si[p1]+=si[p2];
    pa[p2]=p1;
    return;
}
 
int32_t main() {
    fio
    
    int a,b;
    cin >> a >> b;
    
    int x = 100*a;
    x/=8;
    int y = 10*b;
   // cout << x << " " << y << endl;
    
    for(int i=min(x,y)-10;i<=max(x,y)+10;i++) {
        int p = (i*8)/100;
        int q = (i)/10;
        
        if(p==a and q==b) {
            cout << i << endl;
            return 0;
        }
    }
    cout << -1 << endl;
    

	return 0;
    
}


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

int main() {
    int S;
    cin >> S;
    int h = S / 3600;
    int m = (S - h * 3600) / 60;
    int s = S % 60;
    cout << h << ":" << m << ":" << s << endl;
}


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


int main()
{
  int a, b;
  cin >> a >> b;
  if (abs(a - b) % 2 == 0)
    cout << (a + b) / 2 << endl;
  else
    cout << "IMPOSSIBLE\n";
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>    
#include<cmath>
#include<map>
#include<vector>
#include<math.h>
#include<stdio.h>
#include<stack>
#include<queue>
#include<tuple>
#include<cassert>
#include<set>
#define int long long
#define mod(int)(1000000007)
using namespace std;
char maze[2134][2134];
int d[1234][1234], dx[4] = { 1, 0, -1, 0 }, dy[4] = { 0, 1, 0, -1 };
signed main() {
	int n, m, sx = 1, sy = 1, sum = 0; char a;
	cin >> n >> m; int gx = n, gy = m, ans = 0; 
	const int INF = 1000000000; typedef pair<int, int>P;
	for (int h = 1; h <= n; h++) {
		for (int i = 1; i <= m; i++) {
			cin >> a; maze[h][i] = a;
			if (a == '#') { sum++; }
		}
	}
	queue<P> que;
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= m; j++) {
			d[i][j] = INF;
		}
	}
	que.push(P(sx, sy));
	d[sx][sy] = 0;
	while (que.size()) {
		P p = que.front(); que.pop();
		if (p.first == gx && p.second == gy) {
			break;
		}
		for (int i = 0; i < 4; i++) {
			int nx = p.first + dx[i], ny = p.second + dy[i];
			if (0 < nx && nx <= n && 0 < ny && ny <= m && maze[nx][ny] != '#' && d[nx][ny] == INF) {
				que.push(P(nx, ny));
				d[nx][ny] = d[p.first][p.second] + 1;
			}
		}
	}
	if (d[gx][gy] == 1000000000) {
		cout << -1 << endl;
	}
	else {
		cout << n * m - sum - 1 - d[gx][gy] << endl;
	}
}

Measured memory_bytes: 2560
#include<bits/stdc++.h>
#define ll long long
#define pii pair<ll ,int>
using namespace std;
const int inf = 0x3f3f3f3f;
const int maxn = 1e5+5;
const ll mod=998244353;
int a,b,c,d,e;
int main(){
    ios::sync_with_stdio(false);
    cin>>a>>b>>c>>d>>e;
    cout<<60*c+d-a*60-b-e<<'\n';
    return 0;
}


Measured memory_bytes: 3652
#include<cstdio>
#include<vector>
#include<string>
using namespace std;

const int maxn = 30;

struct Node
{
	int parent;
	int left;
	int right;
	Node() {}
};

Node Tree[maxn];

void init(int n) {
	for (int i = 0; i < n; i ++) {
		Tree[i].parent = -1;
	}
}

void build(int n) {
	for (int i = 0; i < n; i ++) {
		int id, left, right;
		scanf("%d%d%d", &id, &left, &right);
		Tree[id].left = left;
		Tree[id].right = right;
		Tree[left].parent = id;
		Tree[right].parent = id;
	}
}


void pre_order(int now) {
	if (now == -1) return;
	printf(" %d", now);
	pre_order(Tree[now].left);
	pre_order(Tree[now].right);
}

void in_order(int now) {
	if (now == -1) return;
	in_order(Tree[now].left);
	printf(" %d", now);
	in_order(Tree[now].right);
}

void post_order(int now) {
	if (now == -1) return;
	post_order(Tree[now].left);
	post_order(Tree[now].right);
	printf(" %d", now);
}

int main()
{
	int n;
	while (~scanf("%d", &n)) {
		init(n);
		build(n);
		int root;
		for (int i = 0; i < n; i ++) {
			if (Tree[i].parent == -1)
				root = i;
		}
		puts("Preorder");
		pre_order(root);
		puts("");
		puts("Inorder");
		in_order(root);
		puts("");
		puts("Postorder");
		post_order(root);
		puts("");
	}
	return 0;
}


Measured memory_bytes: 2684
#ABC177 B
s = str(input())
t = str(input())
ls = len(s)
lt = len(t)
ans = lt
for i in range(ls - lt + 1):
  count = 0
  tmp_str = s[i:i+lt]
  #print(tmp_str)
  for j in range(lt):
    #print(tmp_str[j])
    #print(t[j])
    if tmp_str[j] != t[j] :
      count += 1
  #print(count)
  if count <= ans:
    ans = count
print(ans)

Measured memory_bytes: 9064
readlines.each do |l|
  n = l.to_i
  break if n==-1
  r = 1.0
  rad = 0.0
  (n-1).times do
    s = Math.sqrt(r**2 + 1)
    rad += Math.acos(r/s)
    r = s
  end
  puts [r*Math.cos(rad), r*Math.sin(rad)]
end

Measured memory_bytes: 6208
// g++ macro.cpp -std=c++14
#include <bits/stdc++.h>
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;
using namespace std;

#define dump(x)  cout << #x << " = " << (x) << endl;
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE"  ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) << endl

#define SANKOU(n,a,b) cout << ((n) ? (#a) : (#b) ) << endl

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)

#define FOREACH(x,a) for(auto& (x) : (a) )

#define WFA(d,v) REP(k,v)REP(i,v)REP(j,v)d[i][j]=min(d[i][j],d[i][k]+d[k][j])

#define SCOUT(x) cout<<(x)<<" "
#define ENDL cout<<endl

#define VECCIN(x) for(auto&youso_: (x) )cin>>youso_
#define VECIN2(x,y) REP(i,x.size())cin>>x[i]>>y[i]
#define VECCOUT(x) for(auto&youso_: (x) )cout<<youso_<<" ";cout<<endl

#define ALL(obj) (obj).begin(),(obj).end()

#define EXIST(n,x) (find(ALL(n),x)!=n.end())
#define UNIQUE(obj) sort(ALL( obj )); obj.erase(unique(ALL(obj)),obj.end())
#define COUT(x) cout<<(x)<<endl
void CINT(){}
template <class Head,class... Tail>
void CINT(Head&& head,Tail&&... tail){
    cin>>head;
    CINT(move(tail)...);
}
#define CIN(...) int __VA_ARGS__;CINT(__VA_ARGS__)
#define SCIN(...) string __VA_ARGS__;CINT(__VA_ARGS__)

//#include <boost/multiprecision/cpp_int.hpp>
//using namespace boost::multiprecision; // cpp_int

#define P pair<int,int>
#define V vector<ll>
#define M map<int,int>
#define S set<int>
#define L list<int>

#define pb(a) push_back(a)
#define mp make_pair


int main(){
  ll n,x;cin>>n>>x;
  vector<ll> a(n);
  VECCIN(a);
  vector<V> vec(n,V(n));
  vec[0]=a;
  FOR(i,1,n)
    REP(j,n)//vec[i][j]:i回まで魔法が使える
      vec[i][j]=min(vec[i-1][j],vec[i-1][(j-1+n)%n]);

  /*
  REP(i,n){
    REP(j,n){
      SCOUT(vec[i][j]);
    }
    cout<<" sum : "<<accumulate(ALL(vec[i]),0LL)+i*x;
    ENDL;
  }
  */

  ll ans=LINF;
  REP(bound,n) //魔法の使用回数上限
    ans = min(ans,accumulate(ALL(vec[bound]),0LL)+bound*x);
  COUT(ans);

  return 0;
}



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

int main(){
    double r;
    cin >> r;
    double S = 3.141592653589 * r * r;
    double L = 3.141592653589 * 2 * r;
    printf("%f %f\n", S, L);
}


Measured memory_bytes: 3212
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>
#include <bitset>
#include <iomanip>
#include <stack>
#include <list>
#include <map>
#include <unordered_map>
#include <chrono>
#include <numeric>
using namespace std;
using ll = long long;
const ll INF = (ll)1e18+1;
const ll DIV = 1000000007;
//#define TEST
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
#ifdef TEST
    chrono::system_clock::time_point start, end;
    start = chrono::system_clock::now();
#endif
    ll N;
    cin >> N;
    vector<ll> v(N);
    for(size_t i=0;i<N; i++)
    {
        cin >> v[i];
    }
    sort(v.begin(), v.end());
    double value = v[0];
    for(size_t i=1;i<N; i++)
    {
        value = 1.0 * (value + v[i])/ 2.0;
    }
    cout << fixed << setprecision(10) << value << endl;
#ifdef TEST
    end = chrono::system_clock::now();
    cerr << static_cast<double>(chrono::duration_cast<chrono::microseconds>(end - start).count() / 1000.0) << "[ms]" << endl;
#endif
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
//#include <ext/rope>

#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx")

#define endl "\n"
#define fi first
#define se second
#define pb push_back
#define last(s) (s)[int((s).size())-1]
#define prelast(s) (s)[int((s).size())-2]
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define elif else if
#define left asdasd
#define next zaza

#define cclear cout<<flush;
#define x0 kerker
#define time chas
#define y0 lolik
#define kchay ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define files freopen("a.in", "r", stdin);freopen("a.out", "w", stdout);
#define ref svyazi
#define int long long
#define ii pair<int, int>
#define ld long double
#define list spisok


using namespace std;
//using namespace __gnu_cxx;
string s;
main(){
    kchay;
    cin >> s;
    cout<<s[0]<<s.size()-2<<s[s.size()-1];
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,x) for(int i=0;i<x;i++)
#define put(ans)    cout << ans << endl;
#define reverse(s) reverse(s.begin(),s.end())


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

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

int main(){
    map<char,int> dir;
    dir['N'];
    dir['W'];
    dir['S'];
    dir['E'];

    string s;   cin >> s;

    rep(i,s.length()){
        dir[s[i]]++;
    }

    bool x(false),y(false);
    if(dir['W']==dir['E'])
        x = true;
    if(dir['W']>=1&&dir['E']>=1){
        x = true;
    }

    if(dir['S']==dir['N']){
        y = true;
    }
    if(dir['S']>=1&&dir['N']>=1){
        y = true;
    }

    if(x&&y){
        puts("Yes");
    }else{
        puts("No");
    }

    return 0;
}

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

int main() {
    int h,w;
    cin>>h>>w;
    char a[h][w];
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++)cin>>a[i][j];
    }
    char ans[h+2][w+2];
    for(int i=0;i<h+2;i++){
        for(int j=0;j<w+2;j++){
            if(i==0 || i==h+1 || j==0 || j==w+1)ans[i][j]='#';
            else ans[i][j]=a[i-1][j-1];
        }
    }
    for(int i=0;i<h+2;i++){
        for(int j=0;j<w+2;j++)cout<<ans[i][j];
        cout<<endl;
    }
	return 0;
}

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

using ll = long long;

constexpr ll inf = 1e18;

int main() {
    int A, B, C, X, Y;
    cin >> A >> B >> C >> X >> Y;
    ll ans = inf;
    for(int c = 0; c <= 2 * max(X, Y); c += 2) {
        int restx = max(0, X - c / 2);
        int resty = max(0, Y - c / 2);
        ans = min(ans, (ll)C * c + restx * A + resty * B);
    }
    cout << ans << endl;
}


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

#define int long long

#define pb push_back
#define fi first
#define se second
#define rep(i,s,n) for(int i = s;i<n;i++)
#define repe(i,s,n) for(int i = s;i<=n;i++)
#define rrep(i,s,n) for(int i = (n)-1;i>=(s);i--)
#define all(v) (v).begin(),(v).end()
#define chmin(a,b) a=min((a),(b))
#define chmax(a,b) a=max((a),(b))
#define low(a,b) lower_bound(all(a),(b))
#define upp(a,b) upper_bound(all(a),(b))
#define fill(i,n) memset(i,n,sizeof(i))
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0)
typedef long long ll;
typedef pair<int,int>pint;
typedef vector<int>vint;
typedef vector<vint> vvint;
typedef vector<pint>vpint;
typedef pair<pint,int> P1;
typedef pair<int,pint> P2;
typedef pair<pint,pint> PP;
static const ll maxLL = (ll)1 << 62;
const ll MOD=1000000007;
const ll INF=1e18;

int N,K,M,A,B,C;
string s,t;
int a[100010],b[100010],c[100010];

signed main() {
    IOS();
    cin>>N;
    rep(i,0,N)cin>>a[i];
    sort(a,a+N);
    a[N-1]/=2;
    int ans=0;
    rep(i,0,N)ans+=a[i];
    cout<<ans<<endl;
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    




















































    return 0;
}

Measured memory_bytes: 256