akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long
#define iiii tuple<int, int, int, int>
#define iii tuple<int, int, int>
#define ii pair<int, int>
#define dd pair<double, double>
#define fi first
#define vi vector<int>
#define vvi vector<vector<int>>
#define se second

using namespace std;
using namespace __gnu_pbds;

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

const int M = 1e3;
double e = 1e-8;

double f(vector<ii>& a, double x, double y) {
    double res = 0;
    for (auto& i : a)
        res = max(res, sqrt((i.fi - x) * (i.fi - x) + (i.se - y) * (i.se - y)));
    return res;
}

double dx(vector<ii>& a, double x, double y) {
    return (f(a, x + e, y) - f(a, x - e, y)) / e;
}

double dy(vector<ii>& a, double x, double y) {
    return (f(a, x, y + e) - f(a, x, y - e)) / e;
}

bool test(vector<ii>& a, double L, double x, double y) {
    return f(a, x, y) > f(a, x - dx(a, x, y) * L, y - dy(a, x, y) * L);
}

double cal_L(vector<ii>& a, double x, double y, double tdx, double tdy) {
    double lef = -M, rig = M;
    int cnt = 100;
    while (cnt--) {
        double l1 = (lef + lef + rig) / 3;
        double l2 = (lef + rig + rig) / 3;
        if (f(a, x - tdx * l1, y - tdy * l1) > f(a, x - tdx * l2, y - tdy *
        l2))
            lef = l1;
        else
            rig = l2;
    }
    return lef;
}

void solve() {
    int n;
    cin >> n;
    vector<ii> a(n);
    for (int i = 0; i < n; ++i) cin >> a[i].fi >> a[i].se;

    int cnt = 100;
    double L = 100, x = 0, y = 0;
    while (cnt--) {
        // int cnt_test = 100;
        // while (!test(a, L, x, y) && cnt_test--) L = L * 0.9;
        // L = L * 0.999;

        double tdx = dx(a, x, y), tdy = dy(a, x, y);
        L = cal_L(a, x, y, tdx, tdy);

        x -= tdx * L;
        y -= tdy * L;
    }
    cout << fixed << setprecision(15) << f(a, x, y) << '\n';
}

int main() {
    ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
    // freopen("in", "r", stdin);

    int t = 1;
    // cin >> t;
    while (t--) solve();

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

template<typename T> void chmin(T &a, T b) { if (a > b) a = b; }
template<typename T> void chmax(T &a, T b) { if (a < b) a = b; }

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }

int main() {
    int a, b;
    cin >> a >> b;
    int ans = 0, x = 1;
    while (x < b){
        x += a - 1;
        ans++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
  int N;
  cin>>N;
  int cards[N];
  int i;
  for(i=0;i<=N-1;i++){
  cin>>cards[i];
  }
  int Apoints=0;
  int Bpoints=0;
  int max=0;
  int turn=0;
  int maxnum=0;
  while(turn<N){
    turn++;
    max=0;
    maxnum=0;
    for(i=0;i<=N-1;i++){
      if(max<cards[i]){
        max=cards[i];
        maxnum=i;
      }
    }
    if(turn%2==1){
    Apoints+=max;
    }
    else if(turn%2==0){
    Bpoints+=max;
    }
    cards[maxnum]=0;
  }
  cout<<Apoints-Bpoints;
}

Measured memory_bytes: 3560
def gattai(s):
	g = ""
	for j in s:
		g += j
	return g

def judge(S, N):
	# 真ん中より左 list型なのでgattaiさせる
	S1 = gattai(S[:int(N / 2)])
	# 真ん中より右
	S2 = gattai(S[int(N / 2 + 1):])
	if S1 == S2:
		if S1 == S1:
			if S2 == S2:
				return "Yes"
	return "No"

S = list(input())
N = len(S)
print(judge(S, N))


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int X[1010];
int main()
{
  int N,K;
  cin>>N>>K;
  for(int i=0;i<N;i++)
  	cin>>X[i];
  sort(X,X+N);
  int Ans=0;
  for(int i=0;i<K;i++)
    Ans+=X[i];
  cout<<Ans<<endl;
  return 0;
}

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

class Main {

    public static void main(String[] args) {

	final Scanner stdin = new Scanner(System.in);

	while ( true ) {

	    final int n = stdin.nextInt();
	    if ( n == 0 ) {
		break;
	    }

	    int[][] map = new int[n][n];
	    int x = n / 2;
	    int y = n / 2 + 1;
	    for ( int i = 1; i <= n * n; i++ ) {
		map[y][x] = i;
		final int ny = ( y + 1 ) % n;
		final int nx = ( x + 1 ) % n;
		if ( map[ny][nx] > 0 ) {
		    y = ( y + 2 ) % n;
		} else {
		    y = ny;
		    x = nx;
		}
	    }
	    for ( int[] rows : map ) {
		for ( int row = 0; row < rows.length; row++ ) {
		    System.out.printf( "%4d", rows[row] );
		}
		System.out.println();
	    }
	}
	
    }
    
}

Measured memory_bytes: 18264
#include <algorithm>
#include <cstring>
#include <vector>
#include <iostream>
#include <complex>
#include <utility>
#include <queue>


using namespace std;
typedef long long LL;
typedef pair<LL, LL> PLL;
const int MAXN = 5000;

PLL dp[3000];
LL A[3000];
int main() {
  LL N, Z, W;
  scanf("%lld%lld%lld", &N, &Z, &W);
  for (size_t i = 0; i < N; ++i) scanf("%lld", A + i);
  reverse(A, A + N);
  A[N++] = W;
  A[N++] = Z;
  for (size_t i = 1; i < N; ++i) {
    dp[i] = {abs(A[0] - A[i]), abs(A[0] - A[i]) };
    for (size_t j = 1; j < i; ++j) {
      dp[i].first = max(dp[j].second, dp[i].first);
      dp[i].second = min(dp[j].first, dp[i].second);
    }
  }
  printf("%lld\n", dp[N - 2].first);
}


Measured memory_bytes: 256
D = int(input())
C = list(map(int, input().split()))
S = [list(map(int, input().split())) for i in range(D)]
A = [[0 for i in range(26)]]
B1 = []
B2 = []
AA = []
ans = 0
for i in range(D):
  K = []
  for k in range(26):
    c = 0
    for j in range(26):
      if j != k:
        c += C[j] * (i+1-A[-1][j])
    an = S[i][k]-c
    K.append([an, k+1])
  K.sort()
  a = K[-1][1]
  B = A[-1]
  B[a-1] = i+1
  A.append(B)
  ans += K[-1][0]
  AA.append(ans)
  B1.append(a)
  B2.append(K[-2][1])
c = 0
k = B2[-1] - 1
for j in range(26):
  if j != k:
    c += C[j] * (D-A[-1][j])
an = S[D-1][k]-c
if AA[-2] + an > AA[-1]:
  B1[-1] = k + 1
for i in range(D):
  print(B1[i])

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

int main()
{
    int a[6] = {0, 0, 0, 0, 0, 0};


    for (int i = 0; i < 3; i++) {
        for (int j = 0; j < 3; j++) {
            int c = 0;
            cin >> c;
            if ((i + j) % 3 == 0) {
                a[0] += c;
            }
            if ((i + j) % 3 == 1) {
                a[1] += c;
            }
            if ((i + j) % 3 == 2) {
                a[2] += c;
            }
            if ((j - i) % 3 == 0) {
                a[3] += c;
            }
            if ((j - i + 3) % 3 == 1) {
                a[4] += c;
            }
            if ((j - i + 3) % 3 == 2) {
                a[5] += c;
            }
        }
    }
    if (a[1] == a[0]
        && a[2] == a[0]
        && a[3] == a[0]
        && a[4] == a[0]
        && a[5] == a[0]) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <string>
#include <cmath>
#include <vector>
#include <queue>
#include <climits>
typedef long long ll;
using namespace std;

int main(void){
  const int mod=1e9+7;

  int n,i;
  ll ans=1;
  static int a;
  static int c[100000]={};
  c[0]=3;
  cin>>n;
  for(i=0;i<n;i++){
    cin>>a;
    ans*=(c[a]-c[a+1]);
    ans%=mod;
    c[a+1]++;
  }

  cout<<ans<<endl;

  return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;

const int INF = 1001001001;

int main() {
    int n;
    cin >> n;
    int p[n];
    for (int i = 0; i < n; i++) cin >> p[i];
    ll ans = INF;
    for (int i = 0; i <= p[0]; i++) {
        for (int j = 0; j <= p[n - 1]; j++) {
            int pt[n];
            for (int i = 0; i < n; i++) pt[i] = p[i];
            pt[0] -= min(pt[0], i); pt[n - 1] -= min(pt[n - 1], j);
            ll cnt = i + j;
            for (int k = 0; k < n; k++) {
                if (k == n - 1) {
                    cnt += max(0, pt[k]);
                    break;
                }
                cnt += max(0, pt[k] * 2);
                pt[k + 1] -= min(pt[k + 1], pt[k]);
                pt[k] = 0;
            }
            ans = min(ans, cnt);
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 3120
#include<bits/stdc++.h>
using namespace std;
int field[302][302],h,w,k,cnt=1;
char c;
int main(){
  cin>>h>>w>>k;
  for(int i=0;i<h+2;i++)for(int j=0;j<w+2;j++)field[i][j]=-1;
  for(int i=1;i<=h;i++){
    for(int j=1;j<=w;j++){
      cin>>c;
      if(c=='#'){
        field[i][j]=cnt;
        cnt++;
      }
      else field[i][j]=-1;
    }
  }
  for(int i=1;i<=h;i++){
    for(int j=1;j<=w;j++){
      if(field[i][j]==-1)field[i][j]=field[i-1][j];
    }
  }
  for(int i=h;i>=1;i--){
    for(int j=1;j<=w;j++){
      if(field[i][j]==-1)field[i][j]=field[i+1][j];
    }
  }
  for(int i=1;i<=h;i++){
    for(int j=1;j<=w;j++){
      if(field[i][j]==-1)field[i][j]=field[i][j-1];
    }
  }
  for(int i=1;i<=h;i++){
    for(int j=w;j>=1;j--){
      if(field[i][j]==-1)field[i][j]=field[i][j+1];
    }
  }
  for(int i=1;i<=h;i++){
    for(int j=1;j<=w;j++){
      cout<<field[i][j]<<" \n"[j==w];
    }
  }
}


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

const int MAX = 510000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

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

  int n, a, b;
  cin >> n >> a >> b;
  COMinit();

  long long ans = 1;
  int N = n;
  while(N > 0){
    if(N >= 10){
      ans *=1024;
      N -= 10;
    } else{
      ans *= 2;
      N -= 1;
    }
    ans %= 1000000007;
  }
  ans -= 1;
  long long sub = 1;
  for(int i = 0; i < b; i++){
    sub *= (n - i);
    sub %= 1000000007;
  }
  sub *= finv[b] % 1000000007;
  sub %= 1000000007;
  ans -= sub;
  if(ans < 0){
    ans += 1000000007;
  }
  sub = 1;
  for(int i = 0; i < a; i++){
    sub *= (n - i);
    sub %= 1000000007;
  }
  sub *= finv[a] % 1000000007;
  sub %= 1000000007;
  ans -= sub;
  if(ans < 0){
    ans += 1000000007;
  }
  cout << ans <<endl;
  return 0;
}



Measured memory_bytes: 12160
#include<iostream>
#include<vector>
#include<algorithm>
#include<iomanip>
using namespace std;
#define int long long
int gcd(int a, int b) {
	if (a > b)swap(a, b);
	while (a != 0) {
		b = b % a;
		swap(a, b);
	}
	return b;
}
signed main() {
	int H, W;
	cin >> H >> W;
	vector<string> A;
	A.resize(H + 1);
	for (int i = 0; i < H; i++) {

		cin >> A[i + 1];

		A[i + 1].push_back('.');
	}
	A[0] = string(W + 1, '.');
	reverse(A.begin(), A.end());
	int res = 0;
	for (int i = 1; i <= H; i++) {
		for (int j = 1; j <= W; j++) {
			if (gcd(i, j) == 1) {
				for (int l = 0; l < 2; l++) {
					int tmp = 0;
					if (A[0][0] == '#')tmp = 1;
					double d = ((double)i / j) + 1e-9 * (1 - 2 * l);
					for (int jj = 0; jj < W; jj++) {
						
						int ii = d * (jj + 1);
						/*if (i == 1 && j == 2) {
							cerr << ii << " yoko " << jj << endl;
						}*/
						if (ii >= H)break;
						if (A[ii][jj] != A[ii][jj + 1]) {
							tmp++;
						}
					}
					d = 1 / d;
					for (int ii = 0; ii < H; ii++) {
						int jj = d * (ii + 1);
						/*if (i == 1 && j == 2) {
							cerr << ii << " tate " << jj << endl;
						}*/
						if (jj >= W)break;
						if (A[ii + 1][jj] != A[ii][jj]) {
							tmp++;
						}
					}
					//cerr << i << " " << j << " " << l << " " << tmp << endl;
					res = max((tmp / 2) + 1, res);
				}
			}
		}
	}
	cout << res << endl;
}


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

/* Defines begin */
#define fastio ios_base::sync_with_stdio(false), cin.tie(NULL) , cout.tie(NULL);
#define w1 solve();
#define pb push_back
#define mp make_pair
#define double long double
#define fi first 
#define se second
#define all(a) (a).begin(),(a).end()
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define FOR2(I,A,B) for(ll I = (A); I < (B); ++I)
#define REP(I,N)   FOR(I,0,N)
#define random (rand()<<16|rand())
#define sqr(x) (x)*(x)
#define base complex<double>
#define LOCAL
#ifdef LOCAL
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
#else
#define trace(...) 42
#endif
/* Defines end */

/* Constants begin */
const long long int inf = 2e18 + 7;
const long long int mod = 1e9 + 7;
const double eps = 1e-7;
const double PI = 2*acos(0.0);
const double E = 2.71828;
/* Constants end */

/* Typedef begin */
typedef long long int ll;
typedef pair<ll,ll> pl;
typedef vector<ll> vl;
/* Typedef end */

template <typename Arg1>
void __f(const char* name, Arg1&& arg1)
{
	cerr << name << ": " << arg1 << endl;
}

template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args)
{
	const char* comma = strchr(names + 1, ',');
	cerr.write(names, comma - names) << ": " << arg1 << " |";
	__f(comma + 1, args...);
}



void solve()
{
    ll t;
    cin >> t;
    ll a, b;
    vl arr(t);
    FOR(i,0,t)
    {
        cin >> a >> b;
        if(a == b) arr[i] = 1;
        else 
            arr[i] = 0;


    }

    bool flag = false;
    FOR(i,0,t - 2)
    {
    if(arr[i] && arr[i + 1] && arr[i + 2]) 
        flag = true;
    }
    if(flag)
        cout << "Yes\n";
    else
        cout << "No\n";
}



 
 
auto main() -> int
{
	fastio
	w1
	return 0;
}


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

#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)-1; i >= 0; --i)
#define FORq(i, m, n) for(int i = (m); i <= (n); ++i)
#define FORqr(i, m, n) for(int i = (n); i >= (m); --i)
#define MP make_pair
#define SIN(x, S) (S.count(x) != 0)
#define M0(x) memset(x, 0, sizeof(x))
#define FILL(x, y) memset(x, y, sizeof(x))
#define MM(x) memset(x, -1, sizeof(x))
#define ALL(x) (x).begin(), (x).end()
#define DB(x) cerr << #x << " = " << x << endl
#define DB2(x, y)                                                              \
    cerr << "(" << #x << ", " << #y << ") = (" << x << ", " << y << ")\n";
#define DEBUG                                                                  \
    int x12345;                                                                \
    cin >> x12345;
typedef pair<int, int> PII;
typedef pair<long long, long long> PLL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<long long> VL;
typedef long long ll;
typedef long long integer;
///////////////////////////////////////////////
const long long MOD = 1e9 + 7;
template <class T> inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}

template <class T> inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

///////////////////////////////////////////////
/// 🍈( '-' 🍈 |AC|
int N;
vector<int> V(100001);
int ask(int n){
    n = n % N;
    if (V[n] > 0) return V[n];
    cout << n << endl;
    string s;
    cin >> s;
    if (s == "Vacant") return V[n] = -1;
    if (s == "Male") return V[n] = 1;
    else return V[n] = 2;
}
int main() {
    cin >> N;
    int pointl = 0;
    int pointr = N - 1;
    if (ask(0) == -1) return 0;

    while(true){
        //DB2(pointl,pointr);
        int mid = (pointr + pointl) / 2;
        if (ask(pointl) == -1) return 0;
        if (ask(pointr) == -1) return 0;
        if (ask(mid) == -1) return 0;
        int Choose = 2;
        if ((ask(pointl) == ask(mid)) and ((mid - pointl) % 2 == 1)) Choose = 1;
        if ((ask(pointl) != ask(mid)) and ((mid - pointl) % 2 == 0)) Choose = 1; // left
        if (Choose == 1){
            pointr = mid;
        }else{
            pointl = mid;
        }
    }
}

Measured memory_bytes: 1236
#include <bits/stdc++.h>
using namespace std;
template <typename T>
void WarshallFloyd(vector<vector<T>> &link) {
    int N = link.size();
    for (int k = 0; k < N; k++) {
        for (int i = 0; i < N; i++) {
            for (int j = 0; j < N; j++) {
                link[i][j] = min(link[i][j], link[i][k] + link[k][j]);
            }
        }
    }
}
const int64_t INF = 1e10;
int main() {
    #ifdef DEBUG
    std::ifstream in("/home/share/inputf.in");
    std::cin.rdbuf(in.rdbuf());
    #endif
    int N, M, R;
    cin >> N >> M >> R;
    vector<int> r(R), x(R);
    for(int i = 0; i < R; i++) {
        cin >> r[i];
        r[i]--;
        x[i] = i;
    }
    vector<vector<int64_t>> dist(N, vector<int64_t>(N, INF));
    for (int i = 0; i < N; i++) {
        for(int j = 0; j < N; j++) {
            dist[i][j] = i == j ? 0 : INF;
        }
    }
    for(int i = 0; i < M; i++) {
        int a, b, c;
        cin >> a >> b >> c;
        a--, b--;
        dist[a][b] = dist[b][a] = c;
    }
    WarshallFloyd(dist);
    int64_t ans = INF;
    do {
        int64_t sum = 0;
        for(int i = 0; i < R - 1; i++) {
            sum += dist[r[x[i]]][r[x[i+1]]];
        }
        ans = min(ans, sum);
    } while(next_permutation(x.begin(), x.end()));
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define all(x) x.begin(), x.end()
typedef vector <int> vi;
typedef pair<int,int> ii;
typedef long long ll;
typedef long double ld;
const int mod = 1e9 + 7;
const ll inf = 3e18 + 5;
int add(int a, int b) { return (a += b) < mod ? a : a - mod; }
int mul(int a, int b) { return 1LL * a * b % mod; }
int sub(int a, int b) { return (a -= b) < 0 ? a + mod : a; }

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

  ll a, b, c, d;
  cin >> a >> b >> c >> d;
  if((a <= 0 && b >= 0) || (c <= 0 && d >= 0)) {
    cout << max({0ll, a * c, b * d, a * d, b * c});
  } else {
    cout << max({a * c, b * d, a * d, b * c});
  } 
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define mod107 1000000007
#define rep(i, n) for (int i = 0; i < n; ++i)
using Graph = vector<vector<int>>;
#define grepq priority_queue<double, std::vector<double>, std::greater<double>>
#define all(v) v.begin(), v.end()
#define PI acos(-1)
const ll INF = 10010001010;
const int inf = 1000034000;
typedef vector<ll> vecl;
typedef vector<int> veci;
typedef tuple<string, int, int> TUP;

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

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    //cout << fixed << setprecision(15);
    ll X, K, D;
    cin >> X >> K >> D;
    if(X<0)X *= -1;
    if (X / D >= K)
    {
        cout << X - K * D << endl;
        return 0;
    }
    else{
        ll T = X / D;
        K -= T;
        X -= T * D;
        if (K % 2 == 0)
        {
            cout << X << endl;
        }
        else
        {
            cout << D - X << endl;
        }
    }
}


Measured memory_bytes: 3624
#include <iostream>
#include <string.h>

using namespace std;
bool card[11];

void solve()
{
	int c1, c2, c3;
	while(cin >> c1 >> c2 >> c3)
	{
		memset(card, 1, sizeof(card));
		card[c1] = false;
		card[c2] = false;
		card[c3] = false;
		int ok_count = 0;
		for(int i = 1; i < 11; ++i)
		{
			if(card[i] && (c1 + c2 + i < 21))
			{
				++ok_count;
			}
		}
		if(ok_count >= 4)
		{
			cout << "YES" << endl;
		}
		else
		{
			cout << "NO" << endl;
		}
	}
}

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

Measured memory_bytes: 0
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <cctype>
#define rep(i, m, n) for(int i = m;i < n;i++)
#define repr(i, n) for(int i = n;i >= 0;i--)
#define ll long long
#define ull unsigned long long
#define push(a) push_back(a)
#define pop(a) pop_back(a)
#define debug(x) cout<<#x<<": "<<x<<endl
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define INF 999999999
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

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

int main(){
  double A,B;
  cin >> A >> B;
  A /= 10e100;
  B /= 10e100;

  if(A==B){
    cout << "EQUAL" << endl;
  }else if(A>B){
    cout << "GREATER" << endl;
  }else if(A<B){
    cout << "LESS" << endl;
  }

}


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

int N, K;
int a[1005], used[1000005];
vector<int> S;

signed main(){
  
  cin>>N>>K;
  
  for(int i=0;i<N;i++) cin>>a[i];
  
  for(int i=0;i<N;i++){
    
    int sum = 0;
    
    for(int j=i;j<N;j++){
      sum += a[j];
      S.push_back( sum );
    }
    
  }
  
  int ans = 0;
  
  for(int i=50;i>=0;i--){
    
    int sum = 0;
    
    for(int j=0;j<(int)S.size();j++){
      
      if( used[j] == 1 ) continue;
      
      if( ( S[j] >> i ) & 1LL ) sum++;
      
    }
    
    if( sum >= K ){
      
      ans |= 1LL<<i;
      
      for(int j=0;j<(int)S.size();j++){
	
	if( ( ( S[j] >> i ) & 1LL ) == 0LL ) used[j] = 1;
	
      }
      
    }
    
  }

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


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

int main(){
	string s;
	cin>>s;
	bool playable = true;
	for(int i=0; s[i]; i++){
		if((i+1)%2 && s[i]=='L'){
			playable = false;
			break;
		}
		else if((i+1)%2==0 && s[i] == 'R'){
			playable = false;
			break;
		}
	}
	if(!playable) cout<<"No";
	else cout<<"Yes";
}


Measured memory_bytes: 3552
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) (v).begin(), (v).end()
#define coutd(n) cout << fixed << setprecision(n)
#define ll long long int
#define vl vector<ll>
#define vi vector<int>
const int INF = 2147483647;
const ll MOD = 1000000007;

using namespace std;

int main() {
  ll x, y;
  cin >> x >> y;
  if (abs(x - y) <= 1) {
    cout << "Brown" << endl;
  } else {
    cout << "Alice" << endl;
  }
  return 0;
}


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

int main() {
  int n;
  cin >> n;
  vector<int> p(n), q(n);
  rep(i, n) cin >> p[i];
  rep(i, n) cin >> q[i];
  int pv = 0, qv = 0;
  rep(i, n) {
    pv += p[i] * pow(10, n - 1 - i);
    qv += q[i] * pow(10, n - 1 - i);
  }
  vector<int> x(n, 0), y;
  int c = 0;
  for (int i = 0; i < n; i++) x[i] = i + 1;
  do {
    rep(i, n) {
      if (i == 0) {
        y.push_back(0);
        y[c] += x[i];
      } else {
        y[c] += x[i] * pow(10, i);
      }
    }
    c++;
  } while (next_permutation(x.begin(), x.end()));

  sort(y.begin(), y.end());
  int np, nq;

  auto itr1 = find(y.begin(), y.end(), pv);
  np = itr1 - y.begin();
  np++;
  auto itr2 = find(y.begin(), y.end(), qv);
  nq = itr2 - y.begin();
  nq++;

  cout << abs(np - nq) << endl;

  return 0;
}

Measured memory_bytes: 640
// This file is a "Hello, world!" in C++ language by GCC for wandbox.
#include <iostream>
#include <cstdlib>
#include <bits/stdc++.h>

using namespace std;
int main()
{
    int n;
    cin >> n;
    int k;
    cin >> k;
    int p[200010];
    for (int i=0;i<n;i++) {
        cin >> p[i];
    }
    double max = 0;
    double exp[200010];
    for(int i=0;i<n;i++) {
        exp[i] = (1+p[i])/2.0;
    }
    double cumsum[200010];
    cumsum[0]=0;
    for (int i=1;i<=n;i++){
        cumsum[i] = cumsum[i-1] + exp[i-1];
    }
    
    for (int i=0; i+k <= n; i++) {
        if (cumsum[i+k]-cumsum[i] > max) {
            max = cumsum[i+k]-cumsum[i];
        }
    }
    cout<<fixed<<setprecision(6);
    cout << max << "\n";
}

// GCC reference:
//   https://gcc.gnu.org/

// C++ language references:
//   https://cppreference.com/
//   https://isocpp.org/
//   http://www.open-std.org/jtc1/sc22/wg21/

// Boost libraries references:
//   https://www.boost.org/doc/


Measured memory_bytes: 4096
import java.io.BufferedReader;
import java.io.InputStreamReader;


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

    public void solve(String[] args) {
        MyScanner scanner = new MyScanner();

        // ビジネスロジックここから
        
        
        String s = scanner.next();
        
        int result = 0;
        
        for(int i = 0; i < 4; i ++) {
            if(s.charAt(i)=='+'){
            	result ++;
            }else{
            	result --;
            }
        }
        System.out.println(result);
        
        
        // ビジネスロジックここまで

    }

    private class MyScanner {
        String[] s;
        int i;
        BufferedReader br;
        String reg = " ";
        MyScanner () {
            s = new String[0];
            i = 0;
            br = new BufferedReader(new InputStreamReader(System.in));
        }
        public String next() {
            try {
                if (i < s.length) return s[i++];
                String line = br.readLine();
                while (line.equals("")) {line = br.readLine();}
                s = line.split(reg, 0);
                i = 0;return s[i++];
            } catch (Exception e) {e.printStackTrace();}
            return null;
        }
        public int nextInt() {
            try {return Integer.parseInt(next());} catch (Exception e) {e.printStackTrace();}
            return -1;
        }
        public double nextDouble() {
            try {return Double.parseDouble(next());} catch (Exception e) {e.printStackTrace();}
            return -1;
        }
        public long nextLong()  {
            try {return Long.parseLong(next());} catch (Exception e) {e.printStackTrace();}
            return -1;
        }
    }
}


Measured memory_bytes: 23124
import collections
 
n = int(input())
lens = list(map(int,input().split()))
lens = collections.Counter(lens)
lens = sorted(lens.items(), key=lambda x:x[0], reverse = True)
cnt = 0
for j in lens:
  if j[1] >= 4 and cnt == 0:
    print(j[0]**2)
    break
  elif j[1] >= 2 and cnt == 0:
    cnt = j[0]
  elif j[1] >= 2 and cnt != 0:
    print(cnt * j[0])
    break
else:
    print(0)

Measured memory_bytes: 72344
from collections import Counter

n = int(input())

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

A = Counter(a)

cnt = 0
for i in A.values():
    if i > 1:
        cnt += (i*(i-1)//2)
    

for i in a:
    ans = 0
    before = (A[i]*(A[i]-1))//2
    after = ((A[i]-1)*(A[i]-2))//2
    
    ans = cnt - before + after
    print(ans)

Measured memory_bytes: 33988
#include<bits/stdc++.h>
const int N=2e5+7;
int n,mx,a[N],t[533333][2];
int min(int a,int b){return a<b?a:b;}
struct itv{
	int l,r;
	int mv,mw;
	bool operator<(const itv&w)const{return mv>w.mv;}
	void init();
	void cal();
};
std::priority_queue<itv>q;
void cal(int l,int r){
	if(l>r)return;
	itv i=(itv){l,r};
	i.init();
	q.push(i);
}
void up(int&w,int l,int r){
	w=a[l]<a[r]?l:r;
}
void itv::init(){
	mw=0;
	for(int L=l+mx-1,R=r+mx+1,d=l&1;R-L>1;L>>=1,R>>=1){
		if(~L&1)up(mw,mw,t[L+1][d]);
		if(R&1)up(mw,mw,t[R-1][d]);
	}
	mv=a[mw];
}
void itv::cal(){
	int p=0;
	for(int L=mw+mx,R=r+mx+1,d=r&1;R-L>1;L>>=1,R>>=1){
		if(~L&1)up(p,p,t[L+1][d]);
		if(R&1)up(p,p,t[R-1][d]);
	}
	::cal(l,mw-1);
	::cal(mw+1,p-1);
	::cal(p+1,r);
	printf("%d %d ",mv,a[p]);
}
int main(){
	scanf("%d",&n);
	for(mx=1;mx<n+5;mx<<=1);
	a[0]=0x3f3f3f3f;
	for(int i=1;i<=n;++i){
		scanf("%d",a+i);
		t[mx+i][i&1]=i;
	}
	for(int i=mx-1;i;--i){
		up(t[i][0],t[i<<1][0],t[i<<1^1][0]);
		up(t[i][1],t[i<<1][1],t[i<<1^1][1]);
	}
	cal(1,n);
	while(q.size()){
		itv i=q.top();q.pop();
		i.cal();
	}
	return 0;
}

Measured memory_bytes: 7156
import java.util.*;
import java.io.*;
public class Main {

	public static void main(String[] args) throws Exception{
		long num = 1000000007;

		// TODO Auto-generated method stub
 		BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
 		PrintWriter out = new PrintWriter(System.out);
//	 		String input1 = bf.readLine().trim();
//	 		String input2 = bf.readLine().trim();
	 	int n = Integer.parseInt(bf.readLine());
	 	ArrayList<Integer> array = new ArrayList<Integer>();
	 	StringTokenizer st2 = new StringTokenizer(bf.readLine());
	 	for(int j=0;j<n;j++){
	 		array.add(Integer.parseInt(st2.nextToken()));
	 	}
	 	Collections.sort(array);
	 	long prod = power(2, 2*n-2, num);
	 	long sum = 0;
	 	for(int i = n-1;i>=0;i--){
	 		sum+=(long)((n+1-i))*(long)(array.get(i));
	 		sum%= num;
	 	}

 		
 		
 		out.println((sum*prod)%num);
	 		
 		out.close();
 		
 		
 		
 	}
	public static int power(long x, long y, long mod){
		long ans = 1;
		while(y>0){
			if (y%2==1)
				ans = (ans*x)%mod;
			x = (x*x)%mod;
			y/=2;
		}
		return (int)(ans);
	}
}
 	
 
//StringJoiner sj = new StringJoiner(" "); 
//sj.add(strings)
//sj.toString() gives string of those stuff w spaces or whatever that sequence is

 		
 		
 		
 		
	




Measured memory_bytes: 55076
#include <bits/stdc++.h>
using namespace std;
int main()
 {
int n;
cin>>n;
int a[n];
int b[n];
for(int i=0;i<n;i++)
   {
       cin>>a[i];
   }
   
   for(int i=1;i<=n;i++)
     {
         if(a[i-1]==i)
          b[i-1]=i;
          
          else
          b[a[i-1]-1]=i;
         
    }
    for(int i=0;i<n;i++)
      {
          cout<<b[i]<<" ";
      }
 }


Measured memory_bytes: 1536
import math

s = input()
a = [0] * len(s)
cnt = 0
# Rを見る
for i in range(len(s)):
    if s[i] == 'R':
        cnt += 1
    else:
        a[i] += math.floor(cnt / 2)
        a[i - 1] += math.ceil(cnt / 2)
        cnt = 0

# Lを見る(逆から)

cnt = 0
for i in range(len(s)-1, -1, -1):
    if s[i] == 'L':
        cnt += 1
    else:
        a[i] += math.floor(cnt / 2)
        a[i + 1] += math.ceil(cnt / 2)
        cnt = 0

for i in a:
    print(i, end=' ')


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

using namespace std;

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

#define FOR(i, n, m) for(ll (i)=(m);(i)<(n);++(i))
#define REP(i, n) FOR(i,n,0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll) 1e15;

ll S[10];
string T[4] = {"AC", "WA", "TLE", "RE"};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N;
    cin >> N;
    REP(i, N) {
        string s;
        cin >> s;
        REP(j, 4) {
            if (s == T[j]) {
                S[j]++;
                break;
            }
        }
    }

    REP(i, 4) {
        cout << T[i] << " x " << S[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 3648
import numpy as np

N,K = map(int,input().split())
R,S,P = map(int,input().split())
T = input()

def num(x):
    if x=="r":
        return 0
    if x=="s":
        return 1
    if x=="p":
        return 2

def miss_count(T):
    miss = [0,0,0]
    for k in range(K):
        l = 1
        for i in range(k+K,N,K):
            if T[i] == T[i-K]:
                l += 1
            else:
                miss[num(T[i-K])] += l//2
                l = 1
        if l!=1:
            miss[num(T[i-K])] += l//2
            l = 1
    return miss
        
miss = np.array(miss_count(T))

scores = np.array([P,R,S])
T_count = np.array([T.count("r"),T.count("s"),T.count("p")]) - miss
score = (scores*T_count).sum()

print(score)

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

int main(){
    int x, y, z, tmp;
    cin >> x >> y >> z;

    // swap A and B
    tmp = x;
    x = y;
    y = tmp;

    // swap A and C
    tmp = x;
    x = z;
    z = tmp;

    cout << x << " " << y << " " << z << endl;
}


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

void solve() 
{
    int n,k;cin>>n>>k;
    int ans=k;k--;
    REP(i,n-1)ans*=k;cout<<ans<<endl;
}

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, n) for (int i = 0; i < n; i++)
#define v(a, n) vector<int> a(n, 0)
#define s(a, n) vector<string> a(n, "")
#define lb(v, x) lower_bound(v.begin(), v.end(), x)
#define ub(v, x) upper_bound(v.begin(), v.end(), x)
#define ull unsigned long long
#define pb push_back
#define mp make_pair
#define ll long long
#define mod 1000000007
void dfs(vector<vector<int>> &d, vector<vector<int>> &g, int node, int p, vector<int> &vis);
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,m,s,k;
    cin>>n>>m>>s>>k;
    if( k > n + m)
    {
       cout<< n+n+m-k<<"\n";
    }
    else
      cout<<min(n,k)<<"\n";
}

Measured memory_bytes: 3648
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        n: usize,
        k: usize,
    };
    println!("{}", n % k);
}


Measured memory_bytes: 4352
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using System.Text.RegularExpressions;
using System.Diagnostics;
//var input = Console.ReadLine().Split().Select(int.Parse).ToArray();
namespace AtCoderSolve
{
    class Solve
    {
        const int mod = 1000000007;
        static void Main(string[] args)
        {

            //var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            //Console.SetOut(sw);

            //var p = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int N = int.Parse(Console.ReadLine());
            Console.WriteLine(N / 3);

            //Console.Out.Flush();

        }
    }



    public class Calculation
    {

    }

    public class Graph
    {

    }
}


Measured memory_bytes: 11092
#define DBG 0 //submit 0
#define ll long long
#if DBG
    #include <algorithm>
    #include <array>
    #include <ctime>
    #include <cstdlib>
    #include <string>
    #include <vector>
    #include <unordered_map>
    #include <iostream>
    #include <cmath>
    #include <queue>
    #include <numeric>
#else
    #include <bits/stdc++.h>
#endif
 
using namespace std;
 
 
int main(){
    int ans,n,x,m,mini=1001;
    
    cin >> n >> x;
    for(int i=0;i<n;i++){
        cin >> m;
        x-=m;
        if(m<mini){
            mini=m;
        }
    }
    
    ans = n+x/mini;
    //cout << (flag ? "Yes" : "No") << endl;
    cout << ans << endl;
}


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

using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
typedef vector<int> VI;
typedef long long ll;
typedef pair<int,int> PII;

const int N = 1e5 + 10;
int a[N];

int main() {
  #ifdef LOCAL
  freopen("in", "r", stdin);
  #endif
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n;
  cin >> n;
  rep(i, 0, n) cin >> a[i];
  int prev = n - 1, ans = 0;
  per(i, 0, n - 1) {
    if (a[i] < a[i + 1]) {
      ans = max(ans, prev - i);
      prev = i;
    }
  }
  ans = max(ans, prev + 1);
  cout << ans - 1;
  return 0;
}


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

#define ALL(a)  (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i, c) for (typeof((c).begin()) i = (c).begin(); i != (c).end(); i++)
#define EXIST(s, e) ((s).find(e) != (s).end())
#define SORT(c) sort((c).begin(), (c).end())

#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define REP(i,n) for(int i=0;i<(int)n;++i)

#define CLEAR(a) memset((a), 0, sizeof(a))

inline int toInt(string s) { int x; istringstream iss(s); iss >> x; return x; }
template<class T> inline string toString(T x) { ostringstream oss; oss <<x ; return oss.str(); }
template<class T> inline T sqr(T x) { return x * x; }

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;

const double EPS = 1e-10;
const double PI  = acos(-1.0);

int main(int argc, char *argv[]) {
  int n;
  scanf("%d", &n);

  int ans = 0;
  int b = 0, x = 1;
  scanf("%d", &b);
  REP(i, n - 1) {
    int a;
    scanf("%d", &a);
    if (b == a) x++;
    else {
      ans += x / 2;
      b = a; x = 1;
    }
  }
  ans += x / 2;
  printf("%d\n", ans);

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define ALL(A) A.begin(), A.end()

using namespace std;

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

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	
	string S; cin >> S;
	set<char> alpha; alpha.clear();
	rep (i, (int)S.length()){
		alpha.insert(S[i]);
	} // end rep

	int res = -1;
	rep (i, 26){
		char a = (char)('a' + i);
		if (!alpha.count(a)){
			res = i;
			break;
		} // end if
	} // end rep

	if (res == -1){
		cout << "None" << endl;
	}else{
		cout << (char)('a' + res) << endl;
	} // end if

	return 0;
}

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

int main() {
  int r, D, x; cin >> r >> D >> x;

  rep( i, 0, 10 ) {
    x = x * r - D;
    cout << x << endl;
  }
}


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

int main() {
    string w;
    cin >> w;
    int a[26] = {0};

    for (int i = 0; i < w.size(); i++) {
        a[w[i] - 'a']++; //'a'は1になる。a~zはそれぞれ1~26の数字に変換される。配列に出現回数を保存するために'a' == 1を引く。
    }

    for (int i = 0; i < 26; i++) {
        if (a[i] % 2 != 0) {
            cout << "No" << endl;
            return 0;
        }
    }

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream>
//#include <algorithm>
// #include <iomanip>
#define ll long long

using namespace std;

const int MOD = 1000000007;

int main() {
  ll n;
  scanf("%lld", &n);

  string s;
  cin >> s;

  string t;
  cin >> t;

  for (ll i = 0; i < n; i++) {
    cout << s[i];
    cout << t[i];
  }
}


Measured memory_bytes: 256
#include <stdio.h>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pdd pair<double,double>
#define FILL(a,x) memset(a,x,sizeof(a))
#define foreach( gg,ii ) for( typeof(gg.begin()) ii=gg.begin();ii!=gg.end();ii++)
#define mp make_pair
#define pb push_back
#define X first
#define Y second
#define sz(a) int((a).size())
#define N 1000010
#define MAX 30
#define mod 1000000007
#define REP(i,a) for(int i=0;i<a;++i)
#define REPP(i,a,b) for(int i=a;i<b;++i)
#define all(a) a.begin(),a.end()
const ll INF = 1e18+1;

ll a[N],b[N];

int main()
{
	ll n,x,ans=0,cost;
	scanf("%lld%lld",&n,&x);
	REP(i,n)
	{
		scanf("%lld",&a[i]);
		b[i]=a[i];
		ans+=a[i];
	}
	REP(i,n)
	{
		cost=i*x;
		REP(j,n)
		{
			cost+=b[j];
			b[j]=min(b[j],a[(j-i-1+n)%n]);
		}
		ans=min(cost,ans);
	}
	printf("%lld\n",ans);
return 0;
}


Measured memory_bytes: 256
import sys
import collections

input = sys.stdin.readline

def main():
    N = int(input())
    Slist = []
    for _ in range(N):
        Slist.append(str(input()[:-1]))
    SlistCounter = list(collections.Counter(Slist).items())
    SlistCounter.sort(key=lambda x: x[0])
    SlistCounter.sort(key=lambda x: x[1], reverse=True)
    maxcnt = SlistCounter[0][1]
    for s, cnt in SlistCounter:
        if cnt != maxcnt:
            break
        print(s)

if __name__ == "__main__":
    main()


Measured memory_bytes: 47860
#include<iostream>
#include<vector>
#include<algorithm>

int main(void){
    int n;
    std::cin >> n;

    std::vector<int> b(n-1);
    for(int i = 0; i < n-1; i++){
        std::cin >> b.at(i);
    }
    int ans = 0;

    ans += b.at(0);
    ans += b.at(n-2);

    for(int i = 0; i <= n-3; i++){
        ans += std::min(b.at(i), b.at(i+ 1));
    }
    std::cout << ans << std::endl;
    return 0;
}

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

public class Main {
    public static final long mod = (long)1e9+7;
    public static final long INF = Long.MAX_VALUE/4;
    public static final int inf = Integer.MAX_VALUE/4;

    static void solve(InputReader in, PrintWriter out){
        long n = in.ni(), k = in.ni();
        long ans = 0;
        for (long b = k+1; b <= n; b++) {
            ans += (n/b)*(b-k);
            if(n%b!=0){
                ans += Math.max(n%b-k+1,0);
                if(k==0) ans -= 1;
            }
        }
        out.println(ans);
    }

    public static void main(String[] args){
        InputReader in = new InputReader(System.in);
        PrintWriter out = new PrintWriter(System.out);
        solve(in, out);
        out.close();
    }
    public static class InputReader{
        private BufferedReader br;
        private StringTokenizer st;
        public InputReader(InputStream is){
            br = new BufferedReader(new InputStreamReader(is));
            st = null;
        }
        public String ns(){
            if(st == null || !st.hasMoreTokens()){
                try{
                    st = new StringTokenizer(br.readLine());
                }catch (Exception e){
                    throw new RuntimeException(e);
                }
            }
            return st.nextToken();
        }
        public int ni(){
            return Integer.parseInt(ns());
        }
        public long nl(){
            return Long.parseLong(ns());
        }
        public Double nd(){
            return Double.parseDouble(ns());
        }
        public int[] ni(int n){
            int[] a = new int[n];
            for (int i = 0; i < n; i++) {
                a[i] = ni();
            }
            return a;
        }
        public long[] nl(int n){
            long[] a = new long[n];
            for (int i = 0; i < n; i++) {
                a[i] = nl();
            }
            return a;
        }
        public double[] nd(int n){
            double[] a = new double[n];
            for (int i = 0; i < n; i++) {
                a[i] = nd();
            }
            return a;
        }
    }
}

Measured memory_bytes: 22740
#include<bits/stdc++.h>
using namespace std;
typedef int ll;
bool ispal(string str)
{
    for(register int i=0;i<str.length()/2;i++)
    {
        if(str[i]!=str[str.length()-1-i])
        {
            return false;
        }
    }
    return true;
}
string str;
int main()
{
    cin>>str;
    ispal(str)?cout<<"Yes\n":cout<<"No\n";
}

Measured memory_bytes: 256
tokens = gets.split

stack = []

until tokens.empty?
  token = tokens.shift

  case token
  when '+'
    a = stack.pop
    b = stack.pop
    stack.push(a + b)
  when '-'
    b = stack.pop
    a = stack.pop
    stack.push(a - b)
  when '*'
    a = stack.pop
    b = stack.pop
    stack.push(a * b)
  else
    stack.push(token.to_i)
  end
end

puts stack.pop

Measured memory_bytes: 8648
//#include <bits/stdc++.h>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <string>
#include <stdio.h>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <string.h>
#include <vector>
#define ME(x , y) memset(x , y , sizeof(x))
#define SF(n) scanf("%d" , &n)
#define rep(i , n) for(int i = 0 ; i < n ; i ++)
#define INF  0x3f3f3f3f
#define mod 1000000007
#define PI acos(-1)
using namespace std;
typedef long long ll ;

int vis[100009] , b[100009];
int main()
{
    int n , m ;
    scanf("%d%d" , &n , &m);
    int a = 0 , w = 0;
    for(int i = 0 ; i < m ; i++)
    {
        int x ;
        string s ;
        cin >> x >> s ;
        if(s == "WA" && !vis[x])
        {
            b[x]++;
        }
        else if(s == "AC" && !vis[x])
        {
            a++;
            vis[x] = 1;
        }
    }
    for(int i = 1 ; i <= n ; i++)
    {
        if(vis[i])
        {
            w += b[i];
        }
    }
    cout << a << " " << w << endl ;
    return 0 ;
}


Measured memory_bytes: 1024
# util functions

# debug
$debugFlag = ( ARGV[0] != nil )
p "==== DEBUG MODE ====" if $debugFlag

def pd(str)
  p str if $debugFlag
end

def printd(str)
  print str if $debugFlag
end

# input
inputs = []
lc = 0
nn = 0
while l = $stdin.gets do
  if lc == 0
    nn = l.chomp.to_i
  else
    inputs = l.chomp.split(" ").map(&:to_i)
  end
  lc += 1
end

# body
if $debugFlag
  p nn
  p inputs
end

inputs.sort!

neg_exists = (inputs[0] < 0)
pos_exists = (inputs[-1] > 0)

pd inputs

ans = 0
ansseq = []
if neg_exists
  if pos_exists
    inputs.reverse!
    ans = inputs[-1]
    for i in 0..inputs.length-2 do
      if inputs[i] >= 0
        if inputs[i+1] < 0
          ansseq << "#{inputs[i]} #{ans}"
          ans = inputs[i] - ans
        else
          ansseq << "#{ans} #{inputs[i]}"
          ans -= inputs[i]
        end
      else
        ansseq << "#{ans} #{inputs[i]}"
        ans -= inputs[i]
      end
    end
  else
    inputs.reverse!
    ans = inputs[0]
    for i in 1..inputs.length-1 do
      if i == inputs.length-1
        ansseq << "#{ans} #{inputs[i]}"        
        ans -= inputs[i]
      else
        ansseq << "#{ans} #{inputs[i]}"        
        ans -= inputs[i]
      end
    end
  end
else
  if pos_exists
    ans = inputs[0]
    for i in 1..inputs.length-1 do
      if i == inputs.length-1
        ansseq << "#{inputs[i]} #{ans}"        
        ans = inputs[i] - ans
      else
        ansseq << "#{ans} #{inputs[i]}"        
        ans -= inputs[i]
      end
    end
  else
    ans = inputs[0]
    for i in 1..inputs.length-1 do
      if i == inputs.length-1
        ansseq << "#{inputs[i]} #{ans}"        
        ans = inputs[i] - ans
      else
        ansseq << "#{ans} #{inputs[i]}"        
        ans -= inputs[i]
      end
    end
    ans = 0
  end
end
    
puts ans
ansseq.each do |a_i|
  puts a_i
end


Measured memory_bytes: 19720
H, W, K = map(int,input().split())

mod = 1000000007

fibonacci = [1,1,2,3,5,8,13,21] # W <= 8なのでこれだけでいい

Amida = [ [0] * W for h in range(H+1)]

for h in range(H+1):
	if W == 1:
		break
	for w in range(W):
		if h == 0:
			if w == 0:
				Amida[h][w] = 1
			else:
				break
		elif w == 0:
			Amida[h][w] = fibonacci[W-2] * Amida[h-1][w+1] + fibonacci[W-1] * Amida[h-1][w]
		elif w == W-1:
			Amida[h][w] = fibonacci[W-2] * Amida[h-1][w-1] + fibonacci[W-1] * Amida[h-1][w]
		else:
			Amida[h][w] += (fibonacci[w-1] * fibonacci[W-w-1] * Amida[h-1][w-1])
			Amida[h][w] += (fibonacci[w] * fibonacci[W-w-1] * Amida[h-1][w])
			Amida[h][w] += fibonacci[w] * fibonacci[W-w-2] * Amida[h-1][w+1]

		Amida[h][w] = Amida[h][w] % mod

if W == 1:
	if K == 1:
		print(1)
	else:
		print(0)
else:
	print(Amida[H][K-1])

Measured memory_bytes: 3064