akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>

#define long long long
using namespace std;

const int N = 1e5 + 5;
int n, W;
long w[105], val[105], dp[105][N];

int main(){
    scanf("%d%d", &n, &W);
    for(int i = 1; i <= n; i++){
        scanf("%lld%lld", &w[i], &val[i]);
    }
    for(int i = 0; i <= n; i++){
        for(int j = 0; j <= W; j++){
            if(i == 0 || j == 0) dp[i][j] = 0;
            else if(j >= w[i]) dp[i][j] = max(dp[i-1][j], dp[i-1][j-w[i]] + val[i]);
            else dp[i][j] = dp[i-1][j];
        }
    }
    printf("%lld\n", dp[n][W]);


    return 0;
}


Measured memory_bytes: 80128
from itertools import combinations
from bisect import bisect_right

def main():
    N, *L = map(int, open(0).read().split())

    L.sort()

    print(sum(bisect_right(L, L[i] + L[j] - 1, lo=j + 1) - (j + 1) for i, j in combinations(range(N), 2)))

if __name__ == '__main__':
    main()


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

using namespace std;

int main(){
    string S, T;
    cin >> S >> T;
    int ans = 0;
    for(int i=0; i<3; i++){
        if(S[i] == T[i]){
            ans++;
        }
    }
    cout << ans << endl;
}

        

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

using namespace std;

void Main() {
    int N;
    cin >> N;
    map<int, int> A;
    for (int i = 0; i < N; ++i) {
        int a;
        cin >> a;
        if (A.count(a) == 0) {
            A.insert(make_pair(a, 0));
        }
        A[a] += 1;
    }
    int ans = 0;
    for (int x = 0; x <= 100000; ++x) {
        int mid = A.count(x) == 0 ? 0 : A[x];
        int p = A.count(x + 1) == 0 ? 0 : A[x + 1];
        int m = A.count(x - 1) == 0 ? 0 : A[x - 1];
        ans = max(ans, mid + p + m);
    }
    cout << ans << endl;
}

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


Measured memory_bytes: 6420
#include <stdio.h>  /*入出力*/
#include <stdlib.h> /*標準ライブラリ*/
#include <string.h> /*文字列*/
#include <math.h>   /*計算*/
#include <assert.h> /*確認*/
#include <ctype.h>  /*文字操作*/
#include <stdbool.h>/*bool型*/
#include <limits.h>/*限界*/
//---------------------------------------------------
#define rep(i, n) for(int  i = 0; i < (n); i++)
#define ABS(a) (((a)>(0))?a:-(a))
#define LL long long
#define MOD 1000000007//10^9+7(素数)
//---------------------------------------------------
LL max(LL a, LL b)
{
  if (a<b) {
    a = b;
  }
  return a;
}

void swap(int *a, int *b)
{
  int temp;
  temp = *a;*a = *b;*b = temp;
}
//-------------------------------------------------------
int main(void)
{
  int n;
  int u;
  scanf("%d %d", &n, &u);
  if (n > u) {
    printf("safe\n");
  }else{
    printf("unsafe\n" );
  }
  return 0;
}


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

int black[2002][2002];
int Cumulative_sum[4002][4002]; //累積和
int k;

//累積和を二倍に取ることにより、二つの四角形で探索できるようになっている。
//ans = のところは、実質kの範囲の四角形二つに入っているBの数となっている。
//i=j=0の時にはget(i,j)でk～2k四角形、get(i+k,j+k)で0～k(2k～3k)の四角形を探索している。

int get(int x , int y){
    return Cumulative_sum[x+k-1][y+k-1] + Cumulative_sum[x-1][y-1] - Cumulative_sum[x-1][y+k-1] - Cumulative_sum[x+k-1][y-1];
}

int main() {

    int n;

    cin >> n >> k;

    int x,y;
    char c;

    for(int i=0; i<n; i++){
        cin >> x >> y >> c;
        if(c == 'W'){
            y += k;
        }
        black[x%(2*k)+1][y%(2*k)+1]++;
    }

    //累積和計算中
    for(int i=1; i<4*k+1; i++){
        for(int j=1; j<4*k+1; j++){
            Cumulative_sum[i][j] = Cumulative_sum[i][j-1] + black[(i-1)%(2*k)+1][(j-1)%(2*k)+1];
        }

    }

    //累積和計算中その2
    for(int j=1; j<4*k+1; j++){
        for(int i=1; i<4*k+1; i++){
            Cumulative_sum[i][j] += Cumulative_sum[i-1][j];
        }
    }

    int ans = 0;

    for(int i=1; i<2*k+1; i++){
        for(int j=1; j<2*k+1; j++){
            ans = max(ans, get(i,j) + get(i+k,j+k));
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 78464
// abc043_c
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <type_traits>
#include <typeindex>
#include <unordered_map>
#include <unordered_set>
#endif

template <typename A, typename B> bool cmin(A &a, const B &b) {
  return a > b ? (a = b, true) : false;
}
template <typename A, typename B> bool cmax(A &a, const B &b) {
  return a < b ? (a = b, true) : false;
}
const double PI = acos(-1);
const double EPS = 1e-9;
int inf = sizeof(int) == sizeof(long long) ? 2e18 : 1e9 + 10;
int dx[] = {0, 1, 0, -1};
int dy[] = {1, 0, -1, 0};
#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> A(N);
  rep(i, N) cin >> A[i];
  ll cost = inf;

  for (int i = -101; i <= 101; ++i) {
    ll now = 0;
    for (int j = 0; j < N; ++j) {
      now += (i - A[j]) * (i - A[j]);
    }
    cost = min(now, cost);
  }
  cout << cost << endl;
  return 0;
}


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

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;
#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 pb(a) push_back(a)
#define mp make_pair
#define dump(x)  cout << #x << " = " << (x) << "\n";
#define COUT(x) cout<<(x)<<"\n"

int main()
{
	int n = 0;
	cin >> n;

	vector<int> d(n);
	REP(i, n)
	{
		cin >> d[i];
	}
	sort(d.begin(), d.end());

	int index = 0;
	int k = d[d.size() - 1];
	int ans = 0;
	REP(i, k + 1)
	{
		auto Iter = lower_bound(d.begin(), d.end(), i);
		int ch = Iter - d.begin();
		if ((n / 2) == Iter - d.begin())
		{
			ans++;
		}
	}

	COUT(ans);

	return 0;
}

Measured memory_bytes: 640
n = int(input())
a = map(int, input().split())
b = list(map(int, input().split()))
c = list(map(int, input().split()))

sum = 0

prev = -1

for i in a:
    sum += b[i-1]
    if prev and prev == i-1:
        sum += c[prev-1]
    prev = i

print(sum)


Measured memory_bytes: 3060
#ifdef __APPLE__
#include <iostream>
#include <vector>
#include <utility>
#include <stack>
#include <queue>
#include <set>
#include <algorithm>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <iomanip>
#include <cmath>
#include <ctgmath>
#include <math.h>
#else
#include <bits/stdc++.h>
#endif

using namespace std;
#define io ios_base::sync_with_stdio(false), cin.tie(NULL)
#define GFOR(i,a,n) for (i=a;i<n;i++)
#define FOR(i,a,n) for (int i=a;i<n;i++)
#define RFOR(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())
#define tc(t) for (int tc=1; tc<=t; tc++)
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<long long int> vll;
typedef vector<pair<int, int> > vpi;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
mt19937 mrand(random_device{}()); 
const ll mod=1000000007;
int rnd(int x) { return mrand() % x;}
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
ll modInverse (ll a) {ll p = mod - 2; return powmod(a, p);}
// head

void solve() {
    char a;
    cin >> a;
    if (a >= 'a' and a <= 'z') {
        cout << 'a' << "\n";
    } else {
        cout << "A" << "\n"; 
    }
}

int main() {
    io;
    int t = 1;
    tc(t) {
        solve();
    }
}
//check for edge cases in limits
//printing double may print 1.223232e9 like values, beware of that


Measured memory_bytes: 3668
n = int(input())
for i in range(n):
    t, x, y = map(int, input().split())
    if x + y > t or (x + y + t) % 2 != 0: # (xi,yi)という値は様々な値を動きますが
                                          # xi+yi は毎秒ごとに必ず偶奇が入れ替わることがわかります
        print("No")
        exit()
print("Yes")


Measured memory_bytes: 3060
#include<stdio.h>



int main()
{
	int h ,r ;
	scanf( "%d %d" ,&h ,&r ) ;


	if( h > -1 || r + h > 0 )
	{
		puts( "1" ) ;
	}

	else if( r + h == 0 )
	{
		puts( "0" ) ;
	}

	else
	{
		puts( "-1" ) ;
	}



	return 0 ;
}

Measured memory_bytes: 580
import java.util.Scanner;

public class Main {

	/**
	 * @param args
	 */
	Scanner sc = new Scanner(System.in);

	void run() {
		int sum = 0;
		for (int i = 0; i < 10; i++) {
			sum += sc.nextInt();
		}
		System.out.println(sum);

	}

	public static void main(String[] args) {

		new Main().run();
	}

}

Measured memory_bytes: 17184
#include <bits/stdc++.h>
using namespace std;
int main() {
  int a, b, c;
  cin >> a >> b >> c;
  for (int t = 0; t < 32; ++t) {
    if ((a & 1) || (b & 1) || (c & 1)) {
      cout << t << "\n";
      return 0;
    }
    int A = a / 2, B = b / 2, C = c / 2;
    a = B + C, b = A + C, c = A + B;
  }
  cout << -1 << "\n";
  return 0;
  return 0;
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int r,g,b;
	int k;
	cin>>r>>g>>b>>k;
	while(g<=r){
		k--;
		g*=2;
	}
	while(b<=g){
		k--;
		b*=2;
	}
	if(k>=0)
	 cout<<"Yes";
	else
	 cout<<"No";
	return 0;
}

Measured memory_bytes: 3584
N, K = map(int, input().split())
A = list(map(int, input().split()))

location = 1
k = 0
visit = {1:0}

while k < K:
    k += 1
    location = A[location - 1]
    #print(k, location)
    if location in visit:
        #print(k - visit[location])
        k += ((K - k) // (k - visit[location])) * (k - visit[location])
        #print(k)
    else:
        visit[location] = k

print(location)


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

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        PrintWriter out = new PrintWriter(System.out);

        String S1 = sc.next();
        String S2 = sc.next();
        String S3 = sc.next();
        sc.close();

        out.printf("%c%c%c\n", S1.charAt(0), S2.charAt(1), S3.charAt(2));
        out.flush();
    }
}


Measured memory_bytes: 23252
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <numeric>
#include <utility>
#include <string>
#include <cmath>

using namespace std;

int main() {
	int x;
	cin >> x;

	int ans = 1;
	for (int i = 2; i < x; i++) {
		for (int j = 2; j < 10; j++) {
			int a = pow(i, j);
			if (a > x) {
				break;
			}
			ans = max(ans, a);
		}
	}

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


Measured memory_bytes: 256
using System;

public class Hello
{
    public static void Main()
    {
        var n = int.Parse(Console.ReadLine().Trim());
        string[] line = Console.ReadLine().Trim().Split(' ');
        var a = Array.ConvertAll(line, int.Parse);
        Array.Sort(a);
        Array.Reverse(a);
        var ret = 0L;
        for (int i = 0; i < n; i++)
            ret += a[2 * i + 1];
        Console.WriteLine(ret);
    }
}

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

int main(void)
{
  string list;
  int idx = 1;
  getline(cin, list);
  for (int i = 0; i < (int)list.size(); i++) {
    if(list[i] == ' ') continue;
    if(list[i] == '0') break;
    idx++;
  }
  cout << idx;
}

Measured memory_bytes: 3572
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(int i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

int main() {
  ll n;
  string s, t;
  cin >> n >> s >> t;
  rep(i, n) {
    string s2 = s.substr(i, n - i);
    string t2 = t.substr(0, n - i);
    if(s2 != t2) continue;
    cout << n + i << endl;
    return 0;
  }
  cout << n * 2 << endl;
}

Measured memory_bytes: 3592
#include "stdio.h"

int N, L, min, res;

int main(void){
  scanf("%d %d", &N, &L);
  if(L <= 0 && L + N - 1 >= 0){
    min = 0;
  }else if(L > 0){
    min = L;
  }else{
    min = L + N - 1;
  }
  res = N * (N + 1) / 2 + N * (L - 1) - min;
  printf("%d", res);
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 99999999999999999
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


int N;
int POW[9];
double table[9];

double calc(vector<double> G){

	double need_sum = 2*M_PI;
	double table[G.size()],base;

	double left = 0,right = M_PI,mid = (left+right)/2;
	double tmp_value,tmp_sum;

	for(int loop = 0; loop < 50; loop++){

		base = G[0]*G[1]*cos(mid);
		table[0] = mid;
		tmp_sum = mid;

		for(int i = 1; i < G.size(); i++){
			tmp_value = base/(G[i]*G[(i+1)%G.size()]);
			table[i] = acos(tmp_value);
			tmp_sum += table[i];
		}

		if(fabs(tmp_sum-need_sum) < EPS){
			double ret = 0;
			for(int i = 0; i < G.size(); i++){
				ret += G[i]*G[(i+1)%G.size()]*sin(table[i]);
			}
			ret /= 2;

			return ret;

			break;
		}

		if(tmp_sum > need_sum){
			right = mid-EPS;
		}else{
			left = mid+EPS;
		}
		mid = (left+right)/2;
	}

	return -1;
}

int main(){

	POW[0] = 1;

	for(int i = 1; i < 9; i++){
		POW[i] = POW[i-1]*2;
	}

	scanf("%d",&N);

	for(int i = 0; i < N; i++){
		scanf("%lf",&table[i]);
	}

	vector<double> TMP;
	double ans = 0;
	int count;

	for(int state = 1; state < POW[N];state++){

		count = 0;
		TMP.clear();

		for(int loop = 0; loop < N; loop++){
			if(state&(1 << loop)){
				count++;
				TMP.push_back(table[loop]);
			}
		}
		if(count < 2)continue;

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

		do{
			ans = max(ans,calc(TMP));

		}while(next_permutation(TMP.begin(),TMP.end()));
	}

	printf("%.10lf\n",ans);

	return 0;
}



Measured memory_bytes: 3728
#include <bits/stdc++.h>
using namespace std;
int main(void){
  int K,N;
  cin>>K>>N;
  vector<int> A(N);
  for(int i=0;i<N;i++){
    cin>>A.at(i);
  }
  sort(A.begin(),A.end());
  reverse(A.begin(),A.end());
  int distance=K-A.at(0)+A.at(N-1);
  for(int i=0;i<N-1;i++){
    if(distance<A.at(i)-A.at(i+1)){
      distance=A.at(i)-A.at(i+1);
    }
  }
  int ans=K-distance;
  
  printf("%d",ans);
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define ll long long
#define PB push_back
#define MP make_pair

#define REP(i, n) for(int i=0;i<(int)(n);++i)
#define FOR(i,l,h) for(int i=(int)(l);i<=(int)(h);++i)
#define FORD(i,h,l) for(int i=(int)(h);i>=(int)(l);--i)

#define max(a,b) a>b?a:b
#define min(a,b) a>b?b:a

ll gcd(ll a, ll b) { return !b ? a : gcd(b, a % b); }
ll lcm(ll a, ll b) { return (a / gcd(a, b)) * b; }

#define dump(x)  cerr << #x << " = " << (x) << endl
#define ALL(t) (t).begin(),(t).end()

using namespace std;
/*
const ll int nax = 1e18;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int a,k;
    for (int i = 0; i < 5; ++i)
    {
        cin>>a;
        if(a==0)k = i+1;
    }
    cout<<k;
    return 0;
}
*/
/*
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int x,y;
    cin>>x>>y;
    if((2*x) < y && y < (4*x)){
        y = y - (2*x);
        if(y % 2 == 0){
            cout<<"Yes\n";
        }
        else{
            cout<<"No\n";
        }
    }
    else if(y == (2*x)){
        cout<<"Yes\n";
    }
    else if(y == (4*x)){
        cout<<"Yes\n";
    }
    else{
        cout<<"No\n";
    }
    return 0;
}
*/

/*
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int x,n;
    cin>>x>>n;
    std::map<int, int> mp;
    int a;
    for (int i = 0; i < n; ++i)
    {
        cin>>a;
        mp[a]++;

    }
    int r = x , l = x;
    while (true)
    {
        if(mp[l] != 1){
            cout<<l;
            return 0;
        }
        else{
            l--;
        }
        if(mp[r] != 1){
            cout<<r;
            return 0;
        }
        else{
            r++;
        }
    }
    return 0;
}
*/


int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;cin>>n;
    std::vector<int> v(n);
    std::map<int, int> ump;
    int mx = 0;
    //sort(v.begin(),v.end());

    for (int i = 0; i < n; ++i)
    {
        std::cin >> v[i];
        ump[v[i]]++;
        mx = max(mx , v[i]);
    }
    set<int>ms;
    for (int i = 0; i < n; ++i)
    {
        for (int j = (2*v[i]); j <= mx; j += v[i])
        {
            if(ump[j] >= 1){
                ms.insert(j);
            }
        }
    }
    int cnt = 0;
    for(auto it : ump)
    {
        int a = it.first;
        if(ump[a] >= 2){
            if(ms.count(a) == 0){
                cnt += ump[a];
            }
        }
        if(ms.count(a) != 0){
            cnt += ump[a];
        }
    }
    cout<<n - cnt;
    return 0;
}


Measured memory_bytes: 57724
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int a,b,c,d,e;
  cin>>a>>b>>c>>d>>e;
  if(a==0)cout<<1;
  else if(b==0)cout<<2;
  else if(c==0)cout<<3;
  else if(d==0)cout<<4;
  else cout<<5;
return 0;}

  

Measured memory_bytes: 3628
#include <iostream>
#include <bits/stdc++.h>
#include <iomanip>
#include <cmath>
using namespace std;

const double PI = 3.14159265358979323846;

int main() {
    double a, b, x;
    cin >> a >> b >> x;
    double theta;
    if (x >= a * a * b / 2) {
        theta = atan(2 * (a * a * b - x) / (a * a * a));
    } else {
        theta = atan(a * b * b / (2 * x));
    }
    cout << std::setprecision(15) << theta * (180 / M_PI) << endl;
}

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

using namespace std;

typedef long long ll;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<vi> vvi;
#define INF 1000000000
#define pb push_back
#define sz(a) int((a).size())
#define all(c) c.begin(), c.end()
#define tr(c, i) for (typeof(c).begin() i = c.begin(); i != c.end(); i++)
#define present(c, x) (c.find(x) != c.end())
#define cpresent(c, x) (find(all(c), x) != c.end())

ll bigmod(ll a, ll b, ll m)
{

    if (b == 0)
        return 1;
    ll x = bigmod(a, b / 2, m);
    x = (x * x) % m;

    if (b % 2)
        x = (x * a) % m;
    return x;
}

ll bigsum(ll a, ll b, ll m)
{
    ll s;
    if (b == 0)
        return b;
    if (b == 1)
        return a + 1;
    if (b % 2)
    {
        b = b / 2;
        s = bigsum(a, b, m) % m;
        s = (s * bigmod(a, b + 1, m)) % m;
        return s;
    }
    else
    {
        s = bigsum(a, b - 1, m) % m;
        s = (a * s + 1) % m;
        return s;
    }
}


int main()
{
    int a,b,c,i,j,m;
    char s[100005],t[100005];
    cin>>s;
    cin>>t;

    a = strlen(s);
    b = strlen(t);
    m = 0;
    for(i=0;i<=a-b;i++){
        c=0;
        for(j=0;j<b;j++){
            if(s[i+j]==t[j]){
                c++;
            }
        }
        m = max(m,c);
    }

     cout<<b-m<<endl;
    return 0;
}

Measured memory_bytes: 3664
#include <stdio.h>

int main(void) {
	// your code goes here
	char w[1000];
	scanf("%s",w);
	int cnt,i,j,flag=0;
	for(i=0;w[i]!='\0';i++){
		cnt=0;
		for(j=0;w[j]!='\0';j++){
			//if(i==j)continue;
			if(w[i]==w[j])cnt++;
		}
		//printf("%d\n",cnt);
		if(cnt%2==1){
			flag=1;
			break;
		}
	}
	if(flag==0) printf("Yes\n");
	else printf("No\n");
	return 0;
}


Measured memory_bytes: 128
#include <stdio.h>
#include <string.h>

int main(void){
	int l[10],v1,v2,i,sum;
	double h;
	while(scanf("%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d",&l[0],&l[1],&l[2],&l[3],&l[4],&l[5],&l[6],&l[7],&l[8],&l[9],&v1,&v2)!=EOF){
		sum=0;
		for(i=0;i<10;i++){sum+=l[i];l[i]=sum;}
		h=(double)sum/(v1+v2)*v1;
		for(i=0;i<10;i++){
			if(h<=l[i]){printf("%d\n",i+1);break;}
		}
	}

	return 0;
}

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

int main()
{
    ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int n,x,g=0,br1,br2,broj;
    cin >> x >> n;
    vector<int> v(n);
    for (int i=0;i<n;i++)
        cin >> v[i];
    sort(v.begin(),v.end());
    broj=x;
    while(true)
    {
        br1=x-g;
        br2=x+g;
        if(!binary_search(v.begin(),v.end(),br1))
        {broj=br1;break;}
        else if(!binary_search(v.begin(),v.end(),br2))
        {broj=br2;break;}
        g++;
    }
    cout << broj;
}


Measured memory_bytes: 3620
import java.util.*;
public class Main{
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();
		int k=sc.nextInt();
		int q=sc.nextInt();
		int[] a=new int[n];
		for(int i=0; i<n; i++){
			a[i]=sc.nextInt();
		}
		long ans=1000000000;
		PriorityQueue<Integer> small = new PriorityQueue<>(), big = new PriorityQueue<>();
		for(int i=0; i<n; i++){
			int left=0;
			big.clear();
			while(left<n){
				while(left<n && a[left]<a[i]){
					left++;
				}
				small.clear();
				while(left<n && a[left]>=a[i]){
					small.add(a[left++]);
				}
				while(small.size()>=k){
					big.add(small.poll());
				}
			}
			if(big.size()<q){
				continue;
			}
			for(int j=1; j<q; j++){
				big.poll();
			}
			ans=Math.min(ans,big.peek()-a[i]);
		}
		System.out.println(ans);
	}
}


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

int main(void){
	int walk, rotation;
	double x = 0, y = 0, angle = 90;	// 初期位置(x,y) 向いている方向angle(90=北)
	
	while(scanf("%d,%d", &walk, &rotation) != EOF){
		if(walk == 0 && rotation == 0) break;
		y += sin(angle * (M_PI / 180)) * walk;
		x += cos(angle * (M_PI / 180)) * walk;
		angle -= rotation;
	}
	
	printf("%d\n%d\n", (int)x, (int)y);
	return 0;
}

Measured memory_bytes: 600
N = int(input())
color = list(input().split())

# 1つの袋があり、ひなあられが N個 入っています。
# 桃色を P、白色を W、緑色を G、黄色を Y と表したとき、袋からひなあられを1粒ずつ取り出していったところ、i番目に取り出したひなあられの色は Si でした。
# この袋に 3種類 のひなあられが入っていた場合は Three、4種類 のひなあられが入っていた場合は Four と出力してください。

if "Y" in color:
    print("Four")
else:
    print("Three")

Measured memory_bytes: 9068
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep2(i,n) for(int i=1;i<=(n);i++)
#define rep3(i,i0,n) for(int i=i0;i<(n);i++)
#define pb push_back
#define mod 1000000007
const ll INF = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
ll gcd(ll a, ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) {return a/gcd(a,b)*b;}
#define all(x) x.begin(), x.end()
#define mp make_pair
bool compare(pair<int, int> a, pair<int, int> b) {
    if(a.first != b.first){
        return a.first < b.first;
        
    }else{
        return a.second < b.second;
    }
}


bool In_map(ll y,ll x,ll h,ll w){
    if(y<0 || x<0 || y>=h || x>=w){
        return 0;
    }else{
        return 1;
    }
}
const vector<ll> dx{1,0,-1,0};
const vector<ll> dy{0,1,0,-1};

int main() {
    ll N;
    cin >> N;

    vector<ll> dp(N+1,INF);
    vector<ll> A(N);
    rep(i,N){
        cin >> A[i];
    }

    rep(i,N){
        ll inx;
        inx = lower_bound(all(dp),A[i]) -dp.begin();
        dp[inx] = A[i];
    }
    ll ans;
    rep(i,N+1){
        if(dp[i] == INF){
            ans = i;
            break;
        }
    }

    cout << ans << endl;
    return 0;
    

}



Measured memory_bytes: 4456
#include<iostream>
#include<vector>

using namespace std;
//class
class DisjointSet{ //クラスの宣言
public: //公開部分
  vector<int>rank,p; //メンバ変数の宣言

  //DisjointSet(); //コンストラクタ
  DisjointSet(int size){ 
    rank.resize(size,0); //resize→要素数を変更
    p.resize(size,0);
    //上二行:メンバ変数のrank,pの要素を調整
    for(int i=0;i<size;++i) makeSet(i);
  }

  void makeSet(int x){ //メンバ関数"makeSet"の宣言
    p[x]=x;
    rank[x]=0;
  }

  bool same(int x,int y){ //メンバ関数"same"の宣言
    return findSet(x)==findSet(y);
  }

  void unite(int x,int y){ //メンバ関数"unite"の宣言
    link(findSet(x),findSet(y));
  }

  void link(int x,int y){ //メンバ関数"link"の宣言
    if( rank[x]>rank[y]){
      p[y]=x;
    }else{
      p[x]=y;
      if(rank[x]==rank[y]) rank[y]++;
    }
  }
  
  int findSet(int x){ //メンバ関数"findSet"の宣言
    if(x!=p[x]) p[x]=findSet(p[x]);
    return p[x];
  }
};

//main関数
int main(){
  int n,a,b,q;
  int t;
  
  cin>>n>>q;
  DisjointSet ds=DisjointSet(n); //class-DisjointSetでdsを宣言
  
  for(int i=0;i<q;++i){
    cin>>t>>a>>b;
    if(t==0) ds.unite(a,b);
    else if(t==1){
      if(ds.same(a,b)) cout<<1<<endl;
      else cout<<0<<endl;
    }
  }
  return 0;
}



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

using namespace std;

int N, root[2], ap[100009], parity[2][100009], t[2][100009];
vector < int > h[100009], v[2][100009];

void addEdge (int x, int y)
{
    h[x].push_back (y);
    h[y].push_back (x);
}

int dfs (int lin, int nod)
{
    int curr = 0;
    for (auto it : v[lin][nod])
    {
        int curr2 = dfs (lin, it);
        if (curr != 0) addEdge (curr, curr2), curr = 0;
        else curr = curr2;
    }
    if (v[lin][nod].size () & 1)
    {
        parity[lin][nod] = 0;
        return curr;
    }
    parity[lin][nod] = 1;
    return nod;
}

void paint (int nod, int c)
{
    if (ap[nod])
    {
        assert (ap[nod] == c);
        return ;
    }
    ap[nod] = c;
    for (auto it : h[nod])
        paint (it, 3 - c);
}

int main ()
{
//freopen ("input", "r", stdin);
//freopen ("output", "w", stdout);

scanf ("%d", &N);
for (int i=0; i<2; i++)
    for (int j=1; j<=N; j++)
    {
        scanf ("%d", &t[i][j]);
        if (t[i][j] == -1) root[i] = j;
        else v[i][t[i][j]].push_back (j);
    }
dfs (0, root[0]);
dfs (1, root[1]);
for (int i=1; i<=N; i++)
    if (parity[0][i] != parity[1][i])
    {
        printf ("IMPOSSIBLE\n");
        return 0;
    }
printf ("POSSIBLE\n");
for (int i=1; i<=N; i++)
    if (ap[i] == 0 && parity[0][i])
        paint (i, 1);
for (int i=1; i<=N; i++)
    if (parity[0][i] == 0) printf ("0 ");
    else
    if (ap[i] == 1) printf ("1 ");
    else printf ("-1 ");
printf ("\n");
return 0;
}


Measured memory_bytes: 23168
package main

import (
	"fmt"
)

func main() {
	var w, h, x, y, r int
	fmt.Scan(&w, &h, &x, &y, &r)

	if x < 0 || y < 0 {
		fmt.Println("No")
		return
	}

	if w < x+r || h < y+r {
		fmt.Println("No")
		return
	}
	fmt.Println("Yes")
}



Measured memory_bytes: 1160
#include<bits/stdc++.h>
typedef  long long  ll;
using namespace std;
int main(){
	ll n,a,b,diff;
	cin>>n;
	assert(n>=2 && n<=pow(10,18));
	cin>>a;
	cin>>b;
	assert(b>=1 && b<=n);
	assert(a>=1 && a<b);
	
	diff=abs(a-b);
	if(diff%2==0)
		cout<<(diff/2)<<endl;

	else{
		diff=min((a-1),(n-b))+1+(abs(b-a)/2);
		cout<<diff<<endl;
	}
	
	return 0;
}

Measured memory_bytes: 256
//have fun
#include <bits/stdc++.h>
using namespace std;
#define mod 		1000000007
#define ll 		long long
#define mp 		make_pair
#define pb 		push_back
#define forn(i,n) 	for(int i=0;i<n;i++)
#define for1(i,n) 	for(int i=1;i<n;i++)
#define ford(i,n) 	for(int i=n-1;i>=0;i--)
#define vi 		vector<int>
#define vl 		vector<ll>
#define pii 		pair<int,int>
#define pll 		pair<ll,ll>
#define vpi 		vector<pair<int,int> >
#define vpl		vector<pair<ll,ll> >
#define vvi 		vector<vector<int> >
#define vvl 		vector<vector<ll> >
#define ull 		unsigned long long
#define IOS 		ios_base::sync_with_stdio(false);
#define PI 		3.1415926535897932384626
#define ff 		first
#define ss 		second
#define char2Int(c) 	(c-'0')
#define FOREACH(i,t) 	for (auto i=t.begin(); i!=t.end(); i++)
#define clr(a,x) 	memset(a,x,sizeof(a)) //set elements of array to some value
#define all(x)		(x).begin(),(x).end()//cout<<"Case #"<<zzz<<": ";
int main()
{
    IOS;cin.tie(NULL);
    int zz=1;
    for(int zzz=1;zzz<=zz;zzz++)
    {
        string s,t;cin>>s>>t;
        vector<string> dp(s.size(),"");
        forn(i,t.size())
        {
            ford(j,s.size())
            {
                if(s[j]==t[i])
                {
                    if(j==0)
                    {
                        dp[j]="";dp[j].pb(s[j]);
                    }
                    else
                    {
                        if((int)dp[j].size()<=(int)dp[j-1].size())
                        {
                            dp[j]=dp[j-1];dp[j].pb(s[j]);
                        }
                    }
                }
            }
            for1(j,s.size())
            {
               if((int)dp[j].size()<(int)dp[j-1].size())dp[j]=dp[j-1];
            }
        }
        cout<<dp[(int)s.size()-1]<<endl;
    }
    return 0;
}


Measured memory_bytes: 14464
import java.util.*;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int ans = 0;
        int[] a = new int[n];
        for (int i=0;i<n;i++)a[i]=sc.nextInt();
        for (int i=1;i<=n;i++)if (i%2==1&&a[i-1]%2==1)ans++;
        System.out.println(ans);
    }
}


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

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

typedef long long ll;

using namespace std;

struct UF {
  int groups;
  vector<int> parent;
  UF(int n):parent(n,-1),groups(n){}
  int root(int x){return parent[x]<0?x:parent[x]=root(parent[x]);}
  bool merge(int x,int y){
    x=root(x);y=root(y);
    if(x==y)return false;
    if(parent[y]<parent[x])swap(x,y);
    if(parent[x]==parent[y])--parent[x];
    parent[y]=x;
    --groups;
    return true;
  }
};

int main(){
  int W, H;
  cin>>W>>H;

  vector<int> cx(W),cy(H);
  rep(i,W)cin>>cx[i];
  rep(i,H)cin>>cy[i];

  vector<pair<ll,pair<int,int>>> cc;
  rep(i,W)cc.push_back({cx[i],{0,i}});
  rep(i,H)cc.push_back({cy[i],{1,i}});

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

  ll gx = W + 1;
  ll gy = H + 1;
  ll cost=0;

  UF ux(W+1),uy(H+1);

  rep(i,cc.size()){
    if(cc[i].second.first == 0){
      --gx;
      cost += gy * cc[i].first;
    }else{
      --gy;
      cost += gx * cc[i].first;
    }
  }

  cout << cost << endl;

  return 0;
}


Measured memory_bytes: 5232
#include<map>
#include<cmath>
#include<queue>
#include<cstdio>
#include<string>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;

int n;
char a[110];
char b[220];
int l=0,r=0;
int cnt1=0,cnt2=0;

int main()
{
    scanf("%d\n%s",&n,a);
    for(int i=0;i<n;i++)
    {
        if(r==0)b[r++]=a[i];
        else if(b[r-1]=='('&&a[i]==')') r--;
        else b[r++]=a[i];
    }
    for(int i=0;i<r;i++)
    {
        if(b[i]=='(')cnt2++;
        else cnt1++;
    }
    for(int i=0;i<cnt1;i++)printf("(");
    printf("%s",a);
    for(int i=0;i<cnt2;i++)printf(")");
    return 0;
}


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

using namespace std;

#define int long long
#define MOD 1000000007

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i < (n); i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)
#define all(i) (i).begin(), (i).end()
#define rall(i) (i).begin(), (i).end(), greater<int>()

#define elif else if
#define eb emplace_back
#define pb push_back
#define mp make_pair
#define fst first
#define sec second
template <typename T>
void print(T x)
{
    std::cout << x << '\n';
}

//typedef long long ll;
#define TENNINE 1000000005
#define TENFIVE 100005
//#define int long long

int n;
string s;

signed main()
{
    cin>>n>>s;
    int x=s.size();

    vector<int> a(x);
    rep(i,x){
        a[i]=s[i]-'0';
    }

    set<tuple<int,int,int>> index;    

    set<int> p;
    set<pair<int,int>> q;

    for(int i=0;i<x-2;i++){
        if(p.find(a[i])!=p.end()){
            continue;
        }else{
            p.insert(a[i]);
        }
        
        for(int j=i+1;j<x-1;j++){
             if(q.find(mp(a[i],a[j]))!=q.end()){
            continue;
        }else{
            q.insert(mp(a[i],a[j]));
        }


            for(int t=j+1;t<x;t++){



                index.insert(make_tuple(a[i],a[j],a[t]));

            }
        }

    }
    cout<<index.size()<<endl;



    return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <cstdio>
#include <vector>
#define _USE_MATH_DEFINES
#include <math.h>
#include <cstring>
#include <numeric>
#include <algorithm>
#include <stdlib.h>
#include <functional>
#include <string>
#include <array>
#include <map>
#include <queue>
#include <limits.h>
#include <set>
#include <stack>
#include <random>
#include <complex>
#include <unordered_map>
#include <nmmintrin.h>
#include <chrono>
const double EPS = 1e-8;
#define Scan(a) int a;scanf("%d", &a);
#define ScanS(a) char a[500];scanf("%s", a);
#define rep(i,s,n) for(int i = (s); (n) > i; i++)
#define REP(i,n) rep(i,0,n)
#define RANGE(x,a,b) ((a) <= (x) && (x) <= (b))
#define DUPLE(a,b,c,d) (RANGE(a,c,d) || RANGE(b,c,d) || RANGE(c,a,b) || RANGE(d,a,b))
#define INCLU(a,b,c,d) (RANGE(a,c,d) && (b,c,d))
#define PW(x) ((x)*(x))
#define ALL(x) (x).begin(), (x).end()
#define MODU 1000000007
#define bitcheck(a,b)   ((a >> b) & 1)
#define bitset(a,b)      ( a |= (1 << b))
#define bitunset(a,b)    (a &= ~(1 << b))
#define MP(a,b) make_pair((a),(b))
#define Manh(a,b) (abs((a).first-(b).first) + abs((a).second - ((b).second))
#define pritnf printf
#define scnaf scanf
#define itn int
#ifdef _MSC_VER
#define __builtin_popcount _mm_popcnt_u32
#define __builtin_popcountll _mm_popcnt_u64
#endif
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a%b);
}
template<typename A, size_t N, typename T>
void Fill(A(&array)[N], const T &val) {
	std::fill((T*)array, (T*)(array + N), val);
}
class Graph {
public:
	int vn;
	int sumcost = 0;
	vector<vector<pii>> g;

	Graph(int n) {
		vn = n;
		g.resize(n);
	}
	virtual void con(int a, int b, int w) = 0;
	int getWeight(int f, int t) {
		auto itr = lower_bound(ALL(g[f]), make_pair(t, INT_MIN));
		if (itr != g[f].end())
			return itr->second;
		return INT_MIN;
	}
	int Costsum() {
		return sumcost;
	}
	void scan(int edcount, bool oindexed, bool w) {
		REP(i, edcount) {
			int a, b, c = 1;
			scanf("%d %d", &a, &b);
			if (w)scanf("%d", &c);
			con(a - oindexed, b - oindexed, c);
		}
	}
};
class BiDGraph : public Graph {//無向
public:
	BiDGraph(int n) : Graph(n) {}

	void con(int a, int b, int w = 1) {
		g[a].push_back({ b,w });
		g[b].push_back({ a, w });
		sumcost++;
	}
};
signed main() {

	int n;
	cin >> n;
	if (n % 10 == 9)
		printf("Yes");
	else if (n / 10 == 9)
		printf("Yes");

	else
		printf("No");
	return 0;
}

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

#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF 1e9
typedef long long ll;


int main() {
    string S; cin >> S;
    FOR(i,1,S.size()/2){
        int N = (S.size()-2*i)/2;

        bool ok = true;
        REP(j,N){
            if(S[j] != S[N+j]) ok = false;
        }
        if(ok){
            cout << N*2 << endl;
            return 0;
        }
    }
    return 0;
}

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

#ifdef LOCAL
#define debug(_) cerr << #_ << ": " << (_) << '\n'
#define _GLIBCXX_DEBUG
#else
#define debug(_) (void(0))
#endif  // LOCAL

const long long MOD = 1000000007;

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

    long long eq = 2, less = 1;

    for (int i = 1; i < L.size(); i++) {
        debug(eq), debug(less);
        if (L[i] == '1') {
            less *= 3;
            less += eq;
            less %= MOD;
            eq *= 2;
            eq %= MOD;
        } else {
            less *= 3;
            less %= MOD;
        }
    }
    debug(eq), debug(less);

    cout << ((eq + less) % MOD) << endl;

    return 0;
}

Measured memory_bytes: 3692
#include <bits/stdc++.h>
using namespace std;
int main(void){
  int L,N;
  cin>>N>>L;
  string s[N];
  for(int i=0;i<N;i++){
    cin>>s[i];
  }
  sort(s,s+N);
  string ans;
  for(int i=0;i<N;i++){
    ans+=s[i];
  }
  cout<<ans<<endl;

}


Measured memory_bytes: 256
<?php
$data = trim(fgets(STDIN));
$checkList = array( "A"=>true,"T"=>true, "C"=>true,"G"=>true );

$max = 0;
$dataList = str_split($data);
$count = count( $dataList );
for( $i=0; $i<$count; $i++ )
{
  $tmp = 0;
  for( $j=$i; $j<$count; $j++ )
  {
    if( isset($checkList[$dataList[$j]]) )
    { $tmp++; }
    else
    {
      $max = max( $max, $tmp );
      $tmp = 0;
    }    
  }

  $max = max( $max, $tmp );
}

echo $max;
?>

Measured memory_bytes: 4604
/*  
    ┬┴┬┴┤(･_├┬┴┬┴ hiding from those WAs
*/

#include <bits/stdc++.h>
using namespace std;

template<typename T>
struct SegmentTree{
    int n;
    vector <T> node, lazy;
    SegmentTree (int n=0): n(n), node(4*n+5, -2111111111), lazy(4*n+5, -2111111111) {}
    
    void pushLazy(int l, int r, int id){
        node[id] = max(node[id], lazy[id]);             
        if (l != r)
            lazy[2*id] = max(lazy[2*id], lazy[id]),
            lazy[2*id+1] = max(lazy[2*id+1], lazy[id]);
        lazy[id] = -2111111111;
    }
    
    void update(int u, int v, T val, int l=0, int r=0, int id = 1){
    	if (!l)	l = 1, r = n;
        pushLazy(l, r, id);
        if (r < u || v < l)     return;
        if (u <= l && r <= v)   { lazy[id] = max(lazy[id], val); pushLazy(l, r, id); return; }
        update(u, v, val, l, (l+r)/2, 2*id);
        update(u, v, val, (l+r)/2+1, r, 2*id + 1);
        node[id] = max(node[2*id], node[2*id+1]);
    }
    T get(int u, int v, int l=0, int r=0, int id = 1){
    	if (u > v)	return -2111111111;
    	if (!l)	l = 1, r = n;
        pushLazy(l, r, id);
        if (r < u || v < l)     return -2111111111;
        if (u <= l && r <= v)   return node[id];
        return max(get(u, v, l, (l+r)/2, 2*id), get(u, v, (l+r)/2+1, r, 2*id + 1));
    }
};

int n;
pair<int,int> robot[200005];
const int mod = (int) 998244353;
int f[200005];
SegmentTree<int> best;

void ngk(){
	cin >> n;
	for(int i=1;i<=n;i++)
		cin >> robot[i].first >> robot[i].second;
	
	best = SegmentTree<int>(n);
	sort(robot+1, robot+n+1);
	f[n+1] = 1;
	
	for(int i=n;i>=1;i--){
		int pos = lower_bound(robot+i+1, robot+n+1, pair<int,int>(robot[i].first + robot[i].second, -1)) - robot - 1;
		int z = max(robot[i].first + robot[i].second - 1, best.get(i+1, pos));
		int where = lower_bound(robot+i+1, robot+n+1, pair<int,int>(z+1, -1)) - robot;
		f[i] = (f[i+1] + f[where]) % mod;

		best.update(i, i, z);
	}
	
	cout << f[1];
}

int main(int argc, char *argv[]){
    iostream::sync_with_stdio(0);
    int test = 1;
    while(test--){
        ngk();
    }
    return 0;
}

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

using namespace std;

using int64 = long long;

template<class T> inline bool UpdateMin(T& a, T b) {
  if (a > b) { a = b; return 1; } return 0;
}
template<class T> inline bool UpdateMax(T& a, T b) {
  if (a < b) { a = b; return 1; } return 0;
}

template <typename T>
class SegmentTree {
 private:
  function<T(T, T)> merge_fn;
  T empty_value;
  vector<T> nodes;
  int num_nodes;

  // Returns the fold of overwrap between [node_l, node_r) and [l, r).
  // nodes[node_index] needs to correspond to [node_l, node_r).
  T GetRangeInternal(int node_index, int node_l, int node_r, int l, int r) {
    if (node_r <= l || r <= node_l) return empty_value;
    if (l <= node_l && node_r <= r) return nodes[node_index];
    int node_m = (node_l + node_r) / 2;
    return merge_fn(
        GetRangeInternal(2 * node_index, node_l, node_m, l, r),
        GetRangeInternal(2 * node_index + 1, node_m, node_r, l, r));
  }

 public:
  // Arguments:
  // in_merge: The function to merge two values. It should be a monoid.
  // in_empty_value: The identity of the monoid.
  // xs: The initial values.
  SegmentTree(
      function<T(T, T)> merge_fn, T empty_value, const vector<T>& xs) :
          merge_fn(merge_fn), empty_value(empty_value) {
    int n = xs.size();
    num_nodes = 1;
    while (num_nodes < n) num_nodes *= 2;
    num_nodes *= 2;
    nodes = vector<T>(num_nodes, empty_value);
    for (int i = 0; i < xs.size(); ++i) {
      nodes[num_nodes / 2 + i] = xs[i];
    }
    for (int i = num_nodes / 2 - 1; i >= 1; i--) {
      nodes[i] = merge_fn(nodes[2 * i], nodes[2 * i + 1]);
    }
  }

  // Updates the i-th element to x.
  void Update(int i, T x) {
    nodes[num_nodes / 2 + i] = x;
    for (int cur = (num_nodes / 2 + i) / 2; cur > 0; cur /= 2) {
      nodes[cur] = merge_fn(nodes[2 * cur], nodes[2 * cur + 1]);
    }
  }

  // Returns the value of the range [l, r) merged by merge_fn.
  T GetRange(int l, int r) {
    return GetRangeInternal(1, 0, num_nodes / 2, l, r);
  }

  T Get(int i) {
    return nodes[num_nodes / 2 + i];
  }
};

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

  int n;
  int64 t;
  cin >> n >> t;
  vector<int64> xs(n);
  for (int i = 0; i < n; i++) {
    cin >> xs[i];
  }

  auto min_fn = [](int64 x, int64 y) { return min(x, y); };
  SegmentTree<int64> tree(min_fn, INT64_MAX, xs);

  int64 ans = INT64_MAX;
  for (int k = 0; k < n; k++) {
    vector<int64> ys = xs;
    for (int i = 0; i < n; i++) {
      int r_inclusive = i;
      int l = i - k;
      if (l >= 0) {
        ys[i] = tree.GetRange(l, r_inclusive + 1);
      }
      if (l < 0) {
        ys[i] = min(
            tree.GetRange(0, r_inclusive + 1),
            tree.GetRange(l + n, n));
      }
    }
    int64 cost = t * k;
    for (int64 y : ys) cost += y;
    UpdateMin(ans, cost);
  }

  cout << ans << endl;
}

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

int main() {
	int n;
	string s;
	cin >> n >> s;
	int ans = 0;
	rep(i, n) {
		set<char> a;
		rep(j, i) {
			a.insert(s[j]);
		}
		set<char> b;
		for(int j = i; j < n; j++) {
			b.insert(s[j]);
		}
		int now = 0;
		for(char c: a) {
			if(b.count(c)) now++;
		}
		ans = max(ans, now);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	string s;
	cin>>s;
	int ans1=0,ans2=0;
	for(int i=0;i<s.size();i++)
	{
		if(i%2==0&&s[i]!='0')
			ans1++;
		if(i%2==1&&s[i]!='1')
			ans1++;
		if(i%2==0&&s[i]!='1')
			ans2++;
		if(i%2==1&&s[i]!='0')
			ans2++;
	}
	cout<<min(ans1,ans2)<<endl;
	return 0;
}


Measured memory_bytes: 512
// practice with Dukkha
#include <algorithm>
#include <iostream>

using namespace std;

const int N = 200000;
const long long INF = 1000000000000000001LL;

int pp[N], qq[N];

long long count2(int *xx, int n, int *yy, int m, long long a) {
	long long cnt = 0;
	for (int i = 0, j = m - 1; i < n; i++) {
		long long z = a / xx[i];
		while (j >= 0 && yy[j] > z)
			j--;
		cnt += j + 1;
	}
	return cnt;
}

long long count1(int *xx, int n, long long a) {
	long long cnt = 0;
	for (int i = 0, j = n - 1; i < j; i++) {
		long long z = a / xx[i];
		while (i < j && xx[j] > z)
			j--;
		cnt += j - i;
	}
	return cnt;
}

int main() {
	int n; cin >> n;
	long long k; cin >> k;
	int np = 0, nq = 0, no = 0;
	for (int i = 0; i < n; i++) {
		int a; cin >> a;
		if (a > 0)
			pp[np++] = a;
		else if (a < 0)
			qq[nq++] = -a;
		else
			no++;
	}
	sort(pp, pp + np);
	sort(qq, qq + nq);
	long long mq = (long long) np * nq;
	long long mo = (long long) no * (no - 1) / 2 + (long long) no * (np + nq);
	if (mq < k && k <= mq + mo) {
		cout << "0\n";
		return 0;
	}
	bool positive;
	if (k <= mq) {
		positive = false;
		k = mq + 1 - k;
	} else {
		positive = true;
		k -= mq + mo;
	}
	long long lower = 0, upper = INF;
	while (upper - lower > 1) {
		long long a = (lower + upper) / 2;
		long long cnt = positive ? count1(pp, np, a) + count1(qq, nq, a) : count2(pp, np, qq, nq, a);
		if (cnt >= k)
			upper = a;
		else
			lower = a;
	}
	cout << (positive ? upper : -upper) << '\n';
	return 0;
}


Measured memory_bytes: 4332
#include <iostream>

using namespace std;
 
int main()
{
	while(1==1){
        int H,W;
    cin >> H >> W;
    if(H==0 && W==0) break;
    for(int j=0;j<H;j++){
        
     for(int i=0;i<W;i++){
        cout << "#";
    }
    cout << endl;
    }
        cout << endl;
    }
}

Measured memory_bytes: 1152
n = int(input())
chars = "Xabcdefghijklmnopqrstuvwxyz"
n_rem = n
ans = ""
 
while True:
  x = n_rem % 26
  if x == 0:
      x = 26
  ans += chars[x]
  n_rem -= x
  if n_rem == 0:
    break
  n_rem //= 26
  
print(ans[::-1])

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

using namespace std;

#ifdef DEBUG_MODE
	#define DBG(n) n;
#else
	#define DBG(n) ;
#endif
#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define rep(i,s,g) for(ll (i) = (s);(i) < (g);++i)
#define rrep(i,s,g) for(ll (i) = (s);i >= (g);--(i))
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {for(int W = 0;W < (n);W++)cerr << v[W] << ' ';cerr << endl << endl;}
#define SHOW2d(v,i,j) {for(int aaa = 0;aaa < i;aaa++){for(int bbb = 0;bbb < j;bbb++)cerr << v[aaa][bbb] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define MOD 1000000007


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

string a,b;
int placeA,placeB;

void dfs(){
	DBG(cout << "START DFS " << placeA << ' ' << placeB << endl;);
	cout << '(';
	int num = 0;
	int tmp;
	if(a[placeA+1] == '(' && b[placeB+1] == '('){
		DBG(cout << "HIDARI DFS" << endl;);
		placeA++;
		placeB++;
		dfs();
	}
	else{
		tmp = 0;
		do{
			if(a[placeA] == '(')tmp++;
			if(a[placeA] == ')')tmp--;
			placeA++;
		}while(tmp != 0);
		tmp = 0;
		do{
			if(b[placeB] == '(')tmp++;
			if(b[placeB] == ')')tmp--;
			placeB++;
		}while(tmp != 0);
	}
	while(!isdigit(a[placeA]))placeA++;
	while(!isdigit(b[placeB]))placeB++;
	cout << ")[";
	tmp = 0;

	while(isdigit(a[placeA])){
		tmp *= 10;
		tmp += a[placeA] - '0';
		placeA++;
	}
	num += tmp;
	DBG(cout << "A is " << tmp << endl;);
	tmp = 0;
	while(isdigit(b[placeB])){
		tmp *= 10;
		tmp += b[placeB] - '0';
		placeB++;
	}
	num += tmp;
	DBG(cout << "B is " << tmp << endl;);
	DBG(cout << "num is ";)cout << num <<  "](";
	placeA++;
	placeB++;
	
	if(a[placeA+1] == '(' && b[placeB+1] == '('){
		DBG(cout << "MIGI DFS" << endl;);
		placeA++;
		placeB++;
		dfs();
	}
	else{
		tmp = 0;
		do{
			if(a[placeA] == '(')tmp++;
			if(a[placeA] == ')')tmp--;
			placeA++;
		}while(tmp != 0);
		tmp = 0;
		do{
			if(b[placeB] == '(')tmp++;
			if(b[placeB] == ')')tmp--;
			placeB++;
		}while(tmp != 0);
	}
	DBG(cout << "END DFS " << a[placeA] << ' ' << b[placeB] << endl;);
	cout << ")";
}

int main()
{
	cin >> a >> b;
	dfs();
	cout << endl;
	return 0;
}


Measured memory_bytes: 3212
def dist(x1, y1, x2, y2):
    return ((x1 - x2) ** 2 + (y1 - y2) ** 2) ** 0.5

N = int(input())
x, y = [0] * N, [0] * N
for i in range(N):
    x[i], y[i] = map(int, input().split())
ans = 0

for i in range(N - 1):
    for j in range(i + 1, N):
        ans += dist(x[i], y[i], x[j], y[j])

ans = ans * 2 / N

print(ans)


Measured memory_bytes: 3188