akhauriyash/Code-Regression huggingface dataset:
#pragma warning(disable:4996)
#include <bits/stdc++.h>

using namespace std;

#define FOR(i, a, b) for (ll i = (ll)(a); i<(ll)(b); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) begin(a), end(a)
#define TPL template
#define TNM typename

using ll = long long;
using ull = unsigned long long;
TPL<TNM T> using vec = vector<T>;
TPL<TNM T> using vec2 = vec<vec<T>>;
TPL<TNM T> using vec3 = vec<vec2<T>>;
TPL<TNM T> using vec4 = vec<vec3<T>>;
TPL<TNM T> using vec5 = vec<vec4<T>>;

TPL<TNM K, TNM V> using umap = unordered_map<K, V>;
TPL<TNM K, TNM V> using uset = unordered_set<K, V>;

TPL <class T = ll> inline T IN() { T x; cin >> x; return x; }
TPL<class T> inline void OUT(const T &x) { cout << x << "\n"; }
void YESNO(bool c) { OUT(c ? "YES" : "NO"); };
void YesNo(bool c) { OUT(c ? "Yes" : "No"); };
void bOUT(bool c, string s, string t) { OUT(c ? s : t); }
struct pre_ { pre_() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(6); } } pre__;

TPL<TNM V, TNM H> void resize(vector<V>& v, const H h) { v.resize(h); }
TPL<TNM V, TNM H, TNM ... T> void resize(vector<V>& v, const H& h, const T ... t) { v.resize(h); for (auto& _v : v) resize(_v, t ...); }
TPL<TNM V, TNM T> void fill(V& x, const T& val) { x = val; }
TPL<TNM V, TNM T> void fill(vector<V>& vec, const T& val) { for (auto& v : vec) fill(v, val); }
TPL<TNM T> vector<T> make_v(size_t a) { return vector<T>(a); }
TPL<TNM T, TNM... Ts> auto make_v(size_t a, size_t b, Ts... ts) { return vector<decltype(make_v<T>(b, ts...))>(a, make_v<T>(b, ts...)); }

int main(void) {
	int A, B, C, D;
	cin >> A >> B >> C >> D;
	int d1 = abs(A - B);
	int d2 = abs(C - B);
	int d3 = abs(A - C);
	if (d3 <= D) {
		cout << "Yes" << endl;
		return 0;
	}
	if (d1 <= D && d2 <= D) {
		cout << "Yes" << endl;
		return 0;
	}
	cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){

int a, b, c, x, d, e, f, g, h = 0;
scanf("%d", &a);//500
scanf("%d", &b);//100
scanf("%d", &c);//50
scanf("%d", &x);

for(d = 0; d < a+1; d++){
  for(e = 0; e < b+1; e++){
    for(f = 0; f < c+1; f++){
      g = 500*d + 100*e + 50*f;
      if(g == x){
        h = h +1;
      }
    }
  }
}

printf("%d", h);

return 0;
}

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

int main() {
    int A, B;
    cin >> A >> B;
    if (A > 12) {
        cout << B << endl;
    }
    else if (A > 5) {
        cout << B / 2 << endl;
    }
    else {
        cout << 0 << endl;
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rrep(i,n) rrepi(i,n,0)
#define rrepi(i,a,b) for(int i=int(a);i>int(b);--i)
#define all(x) (x).begin(),(x).end()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define show(v) rep(i,v.size()){cout<<v[i]<<" ";}cout<<endl;
#define MOD 1000000007
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define SZ(x) ((int)(x).size())
#define sum(v,i) accumulate(all(v),i)
//#define int long long
using ll = long long;
int dx[4] = { 1,0,-1,0 };
int dy[4] = { 0,1,0,-1 };
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; }
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }//最大公約数
int lcm(int a, int b) { return a * b / gcd(a, b); }	//最小公倍数
#define deg_to_rad(deg) (((deg)/360)*2*PI);
#define rad_to_deg(rad) (((rad)/2/PI)*360);
//template <typename... Args>void IN(Args& ... args) {cin >>args;IN(args...);return;} //まとめて入力　IN(a,b,c,d...)

void Main(){
	int a, b;
	cin >> a >> b;
	cout << 6 - a - b;
}

signed main() {
	Main();

	return 0;
}


Measured memory_bytes: 256
package main
import . "fmt"
func main() {
  var a,b,k int
  Scan(&a,&b,&k)
  if a+k-1 >= b-k+1 {
    for i:=a;i<b+1;i++ { Println(i) }
  } else {
    for i:=0;i<k;i++ { Println(a+i) }
    for i:=k-1;i>=0;i-- { Println(b-i) }
  }
}

Measured memory_bytes: 512
N = int(input())

point = []
for i in range(N):
    x,l = map(int,input().split())
    point.append([x,l])

point.sort()

dp = []
dp.append([1,point[0][1]+point[0][0]])
for i in range(1,N):
    x = point[i][0]
    l = point[i][1]
    n = dp[i-1][0]
    if dp[i-1][1]<=x-l:
        dp.append([n+1, x+l])
    else:
        dp.append([n,min(dp[i-1][1],x+l)])

ans = dp[-1][0]
print(ans)

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

using namespace std;

/*  テンプレここから */
typedef long long ll;

#define rep(i, n) for(int i = 0; i < n; i++)
#define repi(i, start, end) for(int i = start; i < end; i++)
#define all(x) (x).begin(), (x).end()
#define INF (1e9)
#define add_mod(a, b, x) ( (ll)(a) + (ll)(b) ) % (ll)(x)
#define mul_mod(a, b, x) ( ((ll)(a) % (ll)(x)) * ((ll)(b) % (ll)(x)) ) % (ll)(x)
#define out(x) cout << (x) << endl;
#define outyes(bool_val) cout << (bool_val ? "yes" : "no") << endl;
#define outYes(bool_val) cout << (bool_val ? "Yes" : "No") << endl;
#define outYES(bool_val) cout << (bool_val ? "YES" : "NO") << endl;
#define outPossible(bool_val) cout << (bool_val ? "Possible" : "Impossible") << endl;
#define outPOSSIBLE(bool_val) cout << (bool_val ? "POSSIBLE" : "IMPOSSIBLE") << endl;

ll sub_mod(ll a, ll b, ll x){
    ll tmp = (a - b) % x;
    if(tmp < 0) tmp += x;
    return tmp;
}
ll gcd(ll a, ll b){
    if(b == 0) return a;
    else return gcd(b, a % b);
}

int dx[] = {0, 1, 0, -1};
int dy[] = {-1, 0, 1, 0};
/*  テンプレここまで */


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

    bool success = true;

    success = s[0] == 'A' && success;
    if(success && count(all(s), 'C') == 1){
        s[0] = 'a';
        rep(i, s.size()) if(s[i] == 'C' && 2 <= i && i < s.size() - 1) s[i] = 'c';
    }else{
        success = false;
    }

    rep(i, s.size()){
        success = (int)(s[i]) > 90 && success;
    }

    if(success) cout << "AC" << endl;
    else cout << "WA" << endl;
}

Measured memory_bytes: 256
x1,y1,x2,y2 = list(map(int,input().split()))

x3 = x2 - (y2-y1)
y3 = y2 - (x1-x2)
x4 = x1 - (y2-y1)
y4 = y1 - (x1-x2)

print(x3,y3,x4,y4)

Measured memory_bytes: 2940
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func next() int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return i

}

var (
	edges   [][]int
	visited []int
)

func main() {
	sc.Split(bufio.ScanWords)

	var V, E int
	fmt.Scanf("%d %d %d", &V, &E)

	edges = make([][]int, V)
	visited = make([]int, V)

	for i := 0; i < E; i++ {
		s, e := next(), next()
		edges[s] = append(edges[s], e)
	}

	for i := 0; i < V; i++ {
		if DFS(i) {
			fmt.Println("1")
			return
		}
	}

	fmt.Println("0")
}

func DFS(v int) bool {
	var ret bool
	visited[v] = 1
	for _, e := range edges[v] {
		if visited[e] == 1 {
			ret = true
		}
		if visited[e] == 0 {
			ret = ret || DFS(e)
		}

	}
	visited[v] = 2
	return ret
}



Measured memory_bytes: 1188
#include <stdio.h>
#include <stdlib.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define max(a, b) ((a) > (b) ? (a) : (b))
#define min(a, b) ((a) < (b) ? (a) : (b))
typedef long long ll;

int main(void)
{
    int ans = 0;
    int num;

    char s[5];
    scanf("%s", s);

    num = atoi(s);

    if (1 <= num % 100 && num % 100 <= 12)
        ans = 1;
    if (1 <= num / 100 && num / 100 <= 12 && ans == 0)
        puts("MMYY");
    else if (1 <= num / 100 && num / 100 <= 12 && ans == 1)
        puts("AMBIGUOUS");
    else if (ans == 0)
        puts("NA");
    else
        puts("YYMM");

    return 0;
}

Measured memory_bytes: 128
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <map>
#include <set>

#define MIN_INT -2147483648
#define MAX_INT 2147483647
#define MIN_LONG -9223372036854775808L
#define MAX_LONG 9223372036854775807L
#define PI 3.141592653589793238462643383279502884L

#define long long long int

using std::vector;
using std::map;
using std::set;
using std::string;
using std::pair;
using std::cin;
using std::cout;
using std::cerr;

// @author: pashka

int main() {
    std::ios::sync_with_stdio(false);

    int n, m, a, b;
    cin >> n >> m >> a >> b;

    vector<vector<char>> res(n, vector<char>(m, '.'));
    if (n % 2 == 1) {
        int i = 0;
        while (a > 0 && i + 1 < m) {
            res[n - 1][i++] = '<';
            res[n - 1][i++] = '>';
            a--;
        }
    }
    if (m % 2 == 1) {
        int i = 0;
        while (b > 0 && i + 1 < n) {
            res[i++][m - 1] = '^';
            res[i++][m - 1] = 'v';
            b--;
        }
    }
    for (int i = 0; i < n / 2; i++) {
        for (int j = 0; j < m / 2; j++) {
            if (n % 2 == 1 && m % 2 == 1 && i == n / 2 - 1 && j == m / 2 - 1 && a > 0 && b > 0) {
                res[2 * i][2 * j + 1] = '<';
                res[2 * i][2 * j + 2] = '>';
                res[2 * i][2 * j] = '^';
                res[2 * i + 1][2 * j] = 'v';
                res[2 * i + 1][2 * j + 2] = '^';
                res[2 * i + 2][2 * j + 2] = 'v';
                a--;
                b--;
            } else if (a > b && a > 0) {
                res[2 * i][2 * j] = '<';
                res[2 * i][2 * j + 1] = '>';
                a--;
                if (a > 0) {
                    res[2 * i + 1][2 * j] = '<';
                    res[2 * i + 1][2 * j + 1] = '>';
                    a--;
                }
            } else if (b > 0) {
                res[2 * i][2 * j] = '^';
                res[2 * i + 1][2 * j] = 'v';
                b--;
                if (b > 0) {
                    res[2 * i][2 * j + 1] = '^';
                    res[2 * i + 1][2 * j + 1] = 'v';
                    b--;
                }
            }
        }
    }
    if (a > 0 || b > 0) {
        cout << "NO\n";
    } else {
        cout << "YES\n";
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < m; j++) {
                cout << res[i][j];
            }
            cout << "\n";
        }
    }


    return 0;
}

Measured memory_bytes: 2304
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<int, int> pii;
int a[100005];
LL ans[100005];
pii p[100005];
int main(){
    int n;
    scanf("%d", &n);
    for(int i=1;i<=n;i++){
        scanf("%d", &a[i]);
        p[i] = pii(a[i], -i);
    }
    p[n+1] = pii(0, 0);
    sort(p+1, p+1+n);
    reverse(p+1, p+1+n);

    int mn = 1e9;
    for(int i=1;i<=n;i++){
        mn = min(mn, -p[i].second);
        if(a[-p[i].second] != a[-p[i+1].second]){
            int d = a[-p[i].second]-a[-p[i+1].second];
            ans[mn] += d*1ll*i;
        }
    }
    for(int i=1;i<=n;i++) printf("%lld\n", ans[i]);
}

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

using namespace std;

//typedef
//------------------------------------------
template<class T> using V = vector<T>;
using VI = V<int>;
using VVI = V<VI>;
using VS = V<string>;
using LL = long long;
using ULL = unsigned long long;
using VLL = V<LL>;
using VVLL = V<VLL>;
template<class T, class U> using P = pair<T, U>;
using PII = P<int, int>;
using PLL = P<LL, LL>;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define MT make_tuple
#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 FILL(a, x) memset(a, x, sizeof(a))

//repetition
//------------------------------------------
#define FOR(i,s,n) for(int i=s;i<(int)n;++i)
#define REP(i,n) FOR(i,0,n)

template<class T> inline T updmax(T &a, T b){return a = max(a,b);}
template<class T> inline T updmin(T &a, T b){return a = min(a,b);}

const int MOD = 1000000007;

int p[25];
int t[3];

int main(){
    int n;
    scanf("%d", &n);
    REP(i,n)scanf("%d", &p[i]);
    int ret = 0;
    REP(i, n-2){
        int tmp = 0;
        if(p[i+1] > p[i])tmp++;
        if(p[i+1] > p[i+2])tmp++;
        if(tmp == 1)ret++;
    }
    cout << ret << endl;
    return 0;
}

Measured memory_bytes: 256
//by Himanshu Shukla
#pragma GCC optimize("O2")
#include <bits/stdc++.h>
using namespace std;
#define FASTIO ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define ll long long
#define v32 vector<int>
#define v64 vector<ll>
#define s32 set<int>
#define s64 set<ll>
#define graph vector<s32>
#define p32 pair<int,int>
#define p64 pair<ll,ll>
#define fi first
#define se second
#define ln '\n'
#define debug(x) cout << (#x) << ": " << (x) << ln
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
inline ll add(ll a, ll b, ll m) { return (((a % m + b % m) % m + m) % m); }
inline ll mul(ll a, ll b, ll m) { return (((a % m * b % m) % m + m) % m); }
const double EPS = 1e-6;
const ll MOD = 1e9 + 7;
template <typename T, typename U>
ostream& operator<<(ostream& out, const pair<T,U>& p){
	out << '[' << p.fi << ", " << p.se << ']';
	return out;
}
template <template <typename, typename...> class ContainerType, typename ValueType, typename ...Args>
void print_container(const ContainerType<ValueType, Args...>& c){
	cout << "{ ";
	for(const auto& v : c)
		cout << v << ' ';
	cout << '}' << ln;
}

int main()
{
	FASTIO;
	int n;
	cin >> n;
	vector<double> arr(n,0);
	double prod = 1;
	for(int i = 0;i < n;i++) cin >> arr[i],prod = prod * arr[i];
	double temp = 0;
	for(int i = 0;i < n;i++)
		temp += (prod / arr[i]);
	cout << fixed << setprecision(6) << (prod / temp) << ln;
	return 0;
}


Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using System.Text;

class Program
{
    static void Main(string[] args)
    {
        // 入力
        int n = int.Parse(Console.ReadLine());
        int[] x = Console.ReadLine().Split().Select(int.Parse).ToArray();


        // 中央値の選択は二つ
        // 配列のコピー
        int[] tmp = x.Skip(0).Take(n+1).ToArray();
        Array.Sort(tmp);
        var ans1 = tmp[n / 2];
        var ans2 = tmp[(n / 2) - 1];


        // ans1未満ならans1
        // ans1以上ならans2
        for (int i = 0; i < n; i++)
        {
            if (x[i] < ans1)
            {
                Console.WriteLine(ans1);
            }
            else
            {
                Console.WriteLine(ans2);
            }
        }
    }
}


Measured memory_bytes: 36928
#include <algorithm>
#include <cassert>
#include <cstring>
#include <iostream>
#include <vector>

#define TRACE(x) std::cout << #x << " = " << x << "\n"
#define _ << " _ " <<

using namespace std;

const int MAX = 5050;

int f[MAX][MAX][2];
int nf[MAX][MAX][2];

int main() {
  std::ios_base::sync_with_stdio(false);

  int N, M;
  cin >> N >> M;

  auto upd = [&](int& x, int v) {
    x += v;
    if (x >= M) x -= M;
  };

  for (int a0 = 1; a0 <= N; ++a0) {
    upd(f[N - a0][a0][1], 1);
  }

  int ret = 0;
  for (int i = 0; i * 2 < N; ++i) {
    for (int d = i == 0 ? N : N / i; d >= 0; --d) {
      for (int g = 0; g <= N; ++g) {
        // A[i]
        if (f[d][g][0] > 0) {
          // a) ++A[i]
          if (d > 0) {
            upd(f[d - 1][g + 1][0], f[d][g][0]);
          }
          // b) move to A[N-i-1]
          upd(f[d][g][1], f[d][g][0]);

          if (N % 2 == 1 && i == N / 2) {
            upd(ret, f[d][g][0]);
          }
        }

        // A[N-i-1]
        if (f[d][g][1] > 0) {
          // a) --A[N-i-1]
          if (d > 0) {
            upd(f[d - 1][g][1], f[d][g][1]);
          }
          // b) i++
          int ng = g - d;
          int nd = d;
          if (ng <= 0) {
            nd -= -ng + 1;
            ng = 1;
          }
          if (nd >= 0) {
            upd(nf[nd][ng][0], f[d][g][1]);
          }

          if (N % 2 == 0 && i == N / 2 - 1) {
            upd(ret, f[d][g][1]);
          }
        }
      }
    }

    for (int d = i == 0 ? N : N / i; d >= 0; --d) {
      for (int g = 0; g <= N; ++g) {
        for (int c = 0; c < 2; ++c) {
          f[d][g][c] = nf[d][g][c];
          nf[d][g][c] = 0;
        }
      }
    }
  }

  cout << ret << "\n";
  return 0;
}


Measured memory_bytes: 397568
#include<iostream>
#include<queue>
#include<string>
#include<stack>
#include<cstdio>
#include<algorithm>

using namespace std;

int main(void)
{
  int w=0;
  int n=0;
  int v[50]={};
  int i=0;
  int a=0;
  int b=0;

  for(i=0;i<50;i++)
    v[i]=i+1;

  cin>>w>>n;

  for(i=0;i<n;i++)
    {
      scanf("%d,%d", &a, &b);
      swap(v[a-1],v[b-1]);
    }

  for(i=0;i<w;i++)
    {
      cout<<v[i]<<endl;
    }

}

Measured memory_bytes: 1240
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

void push(int);
int pop();

int top,s[1000];

int main(){
  int x,y;
  char a[100];
  top=0;

  while(scanf("%s",a)!=EOF){
    if(a[0]=='+'){
      x=pop();
      y=pop();
      push(x+y);
    }
    else if(a[0]=='-'){
      y=pop();
      x=pop();
      push(x-y);
    }
    else if(a[0]=='*'){
      x=pop();
      y=pop();
      push(x*y);
    }
    else{
      push(atoi(a));
    }

  }

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

void push(int a){
  s[++top]=a;
}


int pop(){
  top--;
  return s[top+1];
}



Measured memory_bytes: 2104
#include<bits/stdc++.h>
#include <unistd.h>
using namespace std;
#define nl cout<<"\n"
#define pb push_back
#define se second
#define fi first
#define int long long 
#define pi pair<int,int>
#define vpi vector<pi>
#define vvpi vector<vpi>
#define fio ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL)
#define For(i,n) for(int i=0;i<n;i++)
#define Forn(i,a,n) for(int i=a;i<n;i++)
#define pie =3.14159265358979323846264338327950;
const int mod= 1e9+7;


void solve(){
	fio;
	int n,k;
	cin>>n>>k;
	int ar[n];
	For(i,n) cin>>ar[i];
	vector<int> dp(k+1);
	dp[0]=1;
	for(int i=0;i<n;i++){
		vector<int> temp(k+1);
		for(int j=k;j>=0;j--){
			int l=j+1;
			int r= j+min(ar[i],k-j);
			if(l<=r){
				temp[l]+=dp[j];
				temp[l]%=mod;
				if(r+1<=k){
					temp[r+1]-=dp[j];
					if(temp[r+1]<0){
						temp[r+1]+=mod;
					}
				}
			}
		}
		for(int i=1;i<k+1;i++){
			temp[i]+=temp[i-1];
			temp[i]%=mod;
		}
		for(int i=0;i<k+1;i++){
			dp[i]+=temp[i];
			dp[i]%=mod;
		}
	}
	cout<<dp[k]%mod<<endl;
}

int32_t main(){
	fio;
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	int t=1;
	//cin>>t;
	for(int i=1;i<=t;i++){ 
		//cout<<"Case #"<<i<<":\n";
		solve();
	}
	return 0;
}


Measured memory_bytes: 4784
#include <cstdio>
#include <iostream>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
#define maxlen 64
using namespace std;
typedef long long ll;

template <typename T> void read(T &t)
{
	t=0;int f=0;char c=getchar();
	while(!isdigit(c)){f|=c=='-';c=getchar();}
	while(isdigit(c)){t=t*10+c-'0';c=getchar();}
	if(f)t=-t;
}

ll a,b;
ll xsa,xsb;

ll Calc(ll x)
{
	ll re=0;
	for(ll y=x-x%4;y<=x;re^=y,++y);
	return re;
}

int main()
{
	scanf("%lld%lld",&a,&b);
	printf("%lld",Calc(b)^Calc(a-1));
	return 0;
}


Measured memory_bytes: 256
//author:luckYrat(twitter:@luckYrat_)
//#include <bits/stdc++.h>

//def
#include <iostream>

#include <cmath>
#include <algorithm>
#include <iomanip>

//array
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <utility>
#include <climits>



using namespace std;

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

#define anyfill(n,s) setw(n) << setfill(s)
#define loop(s) for(int i = 0; s > i; i++)
#define rep(i,q) for(int i = 0; (q) > i; i++)
#define repp(i,n,q) for(int i = n; (q) > i; i++)
#define dep(i,q) for(int i = (q); 0 < i; i--)


#define MAX 1000000000
const int mod = 1000000007;
#define EPS (1e-10)

#define pb push_back
#define fir first
#define scn second
#define ednl endl

#define YesNo(a) (a?"Yes":"No")
#define YESNO(a) (a?"YES":"NO")
#define yesno(a) (a?"yes":"no")



/*
確認ポイント
cout << fixed << setprecision(n) << 小数計算//n桁の小数表記になる
vector.unique()は隣接した同じ要素を削除するので先にソートをする

計算量は変わらないが楽できるシリーズ
C++11以降でmin({a,b,c...})で複数個のmic,maxを処理できる
min(max)_element(iter,iter)で一番小さい(大きい)値のポインタが帰ってくる
count(iter,iter,int)でintがiterからiterの間にいくつあったかを取得できる

*/
__attribute__((constructor))
void initial() {
 cin.tie(0);
 ios::sync_with_stdio(false);
}
int main() { 
  int a,b;cin>>a>>b;
  for(int i = 0; max(a,b) > i; i++){
    cout << min(a,b);
  }
  cout << endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
const int maxn = 1024;
int main(){
	int n, k;
	cin >> n;
	vector<long long> a(n);
	long long s = 0;
	for(auto & v : a) cin >> v, s += v;
	long long diff = 1ll<<60;
	for(auto & v : a) diff = min(diff, abs(v * n - s));
	for(int e = 0; e < n; e++){
		if(diff == abs(a[e] * n - s)){
			cout << e  << endl;
			return 0;
		}
	}
	return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bits/stdc++.h>
#include <cstdint>
#include <iostream>
#include <iterator>
#include <vector>

// lib/util.hpp
#ifndef UTIL_HPP
#define UTIL_HPP


using i64 = ::std::int_fast64_t;
using u64 = ::std::uint_fast64_t;
using i32 = ::std::int_fast32_t;
using u32 = ::std::uint_fast32_t;

namespace tools {
  template <typename T>
  void read(::std::istream& is, ::std::vector<T>& vector, const typename ::std::vector<T>::size_type size) {
    vector.reserve(size);
    ::std::copy_n(::std::istream_iterator<T>(is), size, ::std::back_inserter(vector));
  }
  template <typename T>
  void read(::std::vector<T>& vector, const typename ::std::vector<T>::size_type size) {
    ::tools::read(::std::cin, vector, size);
  }

  template <typename T, ::std::size_t N>
  void read(::std::istream& is, ::std::array<T, N>& array) {
    ::std::copy_n(std::istream_iterator<T>(is), N, array.begin());
  }
  template <typename T, ::std::size_t N>
  void read(::std::array<T, N>& array) {
    ::tools::read(::std::cin, array);
  }
}

#endif

// main.cpp

int main() {
  i64 N;
  std::cin >> N;

  std::unordered_map<std::string, i64> tally = {{"AC", 0}, {"WA", 0}, {"TLE", 0}, {"RE", 0}};
  for (i64 i = 0; i < N; ++i) {
    std::string S_i;
    std::cin >> S_i;
    ++tally[S_i];
  }

  std::cout << "AC x " << tally["AC"] << std::endl;
  std::cout << "WA x " << tally["WA"] << std::endl;
  std::cout << "TLE x " << tally["TLE"] << std::endl;
  std::cout << "RE x " << tally["RE"] << std::endl;
  return 0;
}

Measured memory_bytes: 3624
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <iomanip>
#include <map>
#include <set>
#include <tuple>
#include <unordered_map>
#include <iterator>
#include <string>

using namespace std;

using i64 = int64_t;
using P = pair<i64, i64>;
i64 mod = 1000000007;
int int_max = 2147483647;
int max_n = 1e5;
using mat2d_t = std::vector<std::vector<int64_t>>;

int main(int argc, char **argv) {
    std::string s;
    cin >> s;

    std::vector<std::vector<int64_t>> table(s.size(), std::vector<int64_t>(2, 0));

    int64_t ans{0};
    bool carry{false};
#if 0
    for (size_t p=0; p<s.size(); ++p) {
        int c = s[p] - '0';
        if (c > 5) {
            if (!carry) ++ans;
            if (p != s.size()-1) {
                int next = s[p+1]-'0';
                if (next > 5) {
                    ans += (9-c);
                } else {
                    ans += (10-c);
                }
            } else if(c == 5) {
                bool flag{false};
                for (size_t p2 = p; p2 < s.size(); ++p) {
                    int c2 = s[p2] - '0';
                    if (p2 > 5) {
                        flag = true;
                        break;
                    } else if (p2 == 5) {
                        continue;
                    } else {
                        flag = false;
                        break;
                    }
                }
                if (flag)
            } else {
                ans += (10-c);
            }
            carry = true;
        } else {
            ans += c;
            carry = false;
        }
        cout << "  " << ans << endl;
    }

    for (int64_t p=s.size()-1; p >= 0; --p) {
        int c = s[p] - '0';
        if (c >= 5) {
            if (carry) {
                ans += (9-c);
            } else {
                ans += (10-c);
            }
            carry = true;
        } else if (c==4) {
            if (carry) {
                ans += (9-c);
            } else {
                ans += c;
            }
        } else {
            ans += c;
            if (carry) ++ans;
            carry = false;
        }
        if (p == 0 && carry) ++ans;
                cout << c <<"  " << ans << " " << carry << endl;
    }
#endif


    table[s.size()-1][0] = (s[s.size()-1] - '0');
    table[s.size()-1][1] = 10-(s[s.size()-1]-'0');
    //cout << table[s.size()-1][0] << "  " << table[s.size()-1][1] << " " << endl;
    for (int64_t p=s.size()-2; p >= 0; --p) {
        int c = s[p] - '0';

        table[p][0] = min(table[p+1][0] + c, table[p+1][1] + c + 1);
        table[p][1] = min(table[p+1][0] + (10-c), table[p+1][1] + (9-c));

        //cout << table[p][0] << "  " << table[p][1] << " " << endl;
    }

    ans = min(table[0][0], table[0][1] + 1);

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 55940
#include <iostream>
#include <string>
#include <vector>
#include <stdio.h>
#include <algorithm>
#define _USE_MATH_DEFINES
#include <cmath>
#include <numeric>
#include <iomanip>
#include <deque>
#include <tuple>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <sstream>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>

#define rep(i, x) for (int i = 0; i < (int)(x); i++)
#define FOR(i, a, done) for (int i = (a); i < (done); ++i)
#define all(a) (a).begin(), (a).end()
#define F first
#define S second
#define x first
#define y second
#define pb push_back
#define pf push_front

namespace mp = boost::multiprecision;
using cpp_int = mp::cpp_int;
using ll = long long;
using namespace std;

ll M = 1000000007;

int main()
{
    ll n, a, b;
    cin >> n >> a >> b;
    ll ans = 0;
    if ((b - a) % 2 == 0)
    {
        ans = (b-a)/2;
    }
    else
    {
        ans=(b-a)/2;
        ll mine=min(a,n-b+1);
        ans+=mine;

    }
    cout << ans << endl;
}


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

using namespace std;

#define rep(i,a,b) for(int i = a; i<int(b);++i)
#define all(v) v.begin(),v.end()
#define sz(v) v.size()
#define trav(a,c) for(auto a: c)

typedef long long ll;
typedef vector<ll> vi;
typedef pair<ll,ll> pii;

ll n;

int main(){
	cin.sync_with_stdio(false);
    cin>>n;
    vi a(n);
    rep(i,0,n)cin>>a[i];
    sort(all(a));
    if(a[0]+1<a[n-1]) {
        cout<<"No"<<endl;
        return 0;
    }
    if(a[0]==a[n-1]){
        if((a[0]<=n/2)||a[0]==n-1) cout<<"Yes"<<endl;
        else cout<<"No"<<endl;
    } else {
        ll numSame,numUnique;
        rep(i,0,n-1){
            if(a[i]!=a[i+1]){
                numSame = n-(i+1);
                numUnique = i+1;
            }
        }
        a[n-1]-=numUnique;
        if(a[n-1]>0&&a[n-1]<=numSame/2) cout<<"Yes"<<endl;
        else cout<<"No"<<endl;
    }
}


Measured memory_bytes: 1024
#include<iomanip>
#include<limits>
#include<thread>
#include<utility>
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#include<cmath>
#include<numeric>
#include<cassert>
#include<random>
#include<chrono>
#include<unordered_set>
#include<unordered_map>
#include<fstream>
#include<list>
#include<functional>
#include<bitset>
#include<complex>
#include<tuple>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pi;
typedef pair<double,double> pd;
typedef pair<double,ll> pdl;
#define F first
#define S second
const ll E=1e18+7;
const ll MOD=1000000007;


int main(){
    char c;
    cin>>c;
    if(c=='A'){cout<<'T'<<endl;}
    if(c=='T'){cout<<'A'<<endl;}
    if(c=='C'){cout<<'G'<<endl;}
    if(c=='G'){cout<<'C'<<endl;}
    
    
    return 0;
}


Measured memory_bytes: 256
N = int(input())
Xmi, Xma, Ymi, Yma, DYmi, DYma, UYmi, UYma, RXmi, RXma, LXmi, LXma = [(10**10), -(10**10)] * 6
for _ in range(N):
    x, y, d = input().split()
    x, y = int(x), int(y)
    
    if d == "R":
        RXmi = min(RXmi, x)
        RXma = max(RXma, x)
    elif d == "L":
        LXmi = min(LXmi, x)
        LXma = max(LXma, x)
    else:
        Xmi = min(Xmi, x)
        Xma = max(Xma, x)
        
    if d == "U":
        UYmi = min(UYmi, y)
        UYma = max(UYma, y)
    elif d == "D":
        DYmi = min(DYmi, y)
        DYma = max(DYma, y)
    else:
        Ymi = min(Ymi, y)
        Yma = max(Yma, y)

def calc(t):
    xmi = min(RXmi+t, LXmi-t, Xmi)
    xma = max(RXma+t, LXma-t, Xma)
    ymi = min(UYmi+t, DYmi-t, Ymi)
    yma = max(UYma+t, DYma-t, Yma)
    return max(yma-ymi, 0)*max(xma-xmi, 0)

mi = 10**20
import random
import time
sTime = time.time()
while time.time()-sTime < 4.5:
    l = 0
    r = 10**(random.randrange(10000)/1000)
    for _ in range(100):
        m1 = (l*2+r)/3
        m2 = (l+r*2)/3
        if calc(m1) > calc(m2):
            l = m1
        else:
            r = m2
    mi = min(mi, calc(m1))


print(mi)

Measured memory_bytes: 3572
#include<stdio.h>
void swap(int *,int*);
void bable(int *,int );
int main() {
	int a[10000], b[10000],an,bn,key = -1,cnt=0,i,j;
	scanf("%d", &an);
	for ( i = 0; i <an; i++)
	{
		scanf("%d", &a[i]);
	}
	scanf("%d", &bn);
	for (i = 0; i < bn; i++)
	{
		scanf("%d", &b[i]);
	}
	bable(a, an);
	bable(b, bn);
	for ( i = 0; i < bn; i++)
	{
		for (j = 0; j < an; j++)
		{
			if (a[j] != key) {
				if (b[i] == a[j])
				{
					cnt++;
					key = b[i];
				}
			}
		}
	}
	printf("%d", cnt);
	printf("\n");
	return 0;
}
void swap(int *a, int *b) {
	int temp;
	temp = *a;
	*a = *b;
	*b = temp;
}
void bable(int *x, int y) {
	int i,j;
	for ( i = 0; i < y-1 ; i++)
	{
		for ( j = y-1; j > i; j--)
		{
			if (x[j -1] > x[j] )
			{
				swap(&x[j - 1], &x[j]);
			}
		}
	}

}


Measured memory_bytes: 2104
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int n, a[100000], b[100000], c[100000], dp[100000][4];
int f(int i, int p)
{
    if( i == n )
        return 0;
    if( dp[i][p] != -1 )
        return dp[i][p];
    int mx = -1;
    if( p != 0 )
    {
        mx = max(mx , f(i+1, 0)+a[i]);
    }
    if( p != 1 )
    {
        mx = max(mx , f(i+1, 1)+b[i]);
    }
    if( p != 2 )
    {
        mx = max(mx , f(i+1, 2)+c[i]);
    }
    return dp[i][p] = mx;

}
int main()
{
    scanf("%d", &n);
    for(int i=0; i<n; ++i)
        scanf("%d%d%d", a+i, b+i, c+i);
    memset(dp, -1, sizeof dp);
    cout << f(0, 3);
    return 0;
}

Measured memory_bytes: 7808
import std.stdio;
import std.range;
import std.string;
import std.algorithm;
import std.conv;

void main() {
    ulong x = readln.chomp.to!ulong;
    (x/11*2 + (x%11 <= 6 ? 1 : 2) + (x%11 == 0 ? -1 : 0)).writeln;
}

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

int main(){
    int N, M;
    cin >> N >> M;
    long long int A[N], B[M], C[M];
    priority_queue<pair<int, int>> que;
    for(int i = 0; i < N; i++){
        cin >> A[i];
        que.push(make_pair(A[i], 1));
    }

    for(int i = 0; i < M; i++){
        cin >> B[i] >> C[i];
        que.push(make_pair(C[i], B[i]));
    }
    long long int sum = 0;
    for(int i = 0; i < N; i++){
        auto p = que.top();
        que.pop();
        sum += p.first;
        if(p.second > 1){
            p.second--;
            que.push(p);
        }
    }
    cout << sum << endl;
    return 0;
}

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

int main() {
  int n; cin>>n;
  vector<bool> c(4);
  rep(i, n) {
    char a; cin>>a;
    if (a=='P') c[0]=true;
    if (a=='W') c[1]=true;
    if (a=='G') c[2]=true;
    if (a=='Y') c[3]=true;
  }
  int tmp = 0;
  rep(i, 4) if (c[i]) tmp++;
  if (tmp==3) cout<<"Three"<<endl;
  else cout<<"Four"<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <string.h>
#include <math.h>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <algorithm>
#include <utility>
#include <deque>
#include <queue>
#include <functional>
//#include <boost/multiprecision/cpp_int.hpp>

#define rep(i, n) for(int i = 0; i < n; ++i)
#define REP(i, m, n) for(int i = m; i < n; ++i)
#define rrep(i,n) for(int i = n; i >= 0; --i)
#define RREP(i, m, n) for(int i = n; i >= m; --i)
#define llrep(i, n) for(ll i = 0; i < n; ++i)
#define llREP(i, m, n) for(ll i = m; i < n; ++i)
#define llrrep(i,n) for(ll i = n; i >= 0; --i)
#define llRREP(i, m, n) for(ll i = n; i >= m; --i)

using ll = long long;
using ull = unsigned long long;
using pii = std::pair<int, int>;
using pll = std::pair<long long, long long>;
using pil = std::pair<int, long long>;
using pli = std::pair<long long, int>;
using plpii = std::pair<long long, std::pair<int, int>>;
using pdd = std::pair<double, double>;

const long long INF = 1000000000000000001;
const long long _MOD = 1000000007;
const long long MOD = 998244353;
const int ALPHABET = 27;
const double pi = 3.14159265358979;

using namespace std;
//namespace mp = boost::multiprecision;

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

	int n;
	ll k;
	cin >> n >> k;
	int* p = new int[n];
	rep(i, n) cin >> p[i];
	ll* c = new ll[n];
	rep(i, n) cin >> c[i];

	ll ans = INF * (-1);
	ll sum;
	ll* sum_max = new ll[n + 1];
	rep(i, n) {
		sum = 0;
		sum_max[0] = 0;
		
		ll counter = 0;
		int j = i;

		do {
			++counter;

			j = p[j] - 1;
			sum += c[j];
			sum_max[counter] = max(sum, sum_max[counter - 1]);
		} while (i != j);

		if (k <= counter || sum < 0) {
			if (sum_max[min(k, counter)] == 0) {
				sum = 0;
				sum_max[0] = c[p[i] - 1];
				counter = 0;
				j = i;

				do {
					++counter;
					j = p[j] - 1;
					sum += c[j];
					sum_max[counter] = max(sum, sum_max[counter - 1]);
				} while (i != j);
			}
			ans = max(ans, sum_max[min(k, counter)]);
		}
		else {
			if (sum + sum_max[k%counter] >= sum_max[counter]) {
				ans = max(ans, sum*(k / counter) + sum_max[k%counter]);
			}
			else { 
				ans = max(ans, sum*max((ll)0, k / counter - 1) + sum_max[counter]);
			}
		}
	}

	cout << ans << "\n";

	return 0;
}


Measured memory_bytes: 3748
#include <iostream>
#include <string>

int main() {
    std::string S;
    std::cin >> S;

    if(S == "SUN"){
        std::cout << 7 << std::endl;
    }
    else if(S == "MON"){
        std::cout << 6 << std::endl;
    }
    else if(S == "TUE"){
        std::cout << 5 << std::endl;
    }
    else if(S == "WED"){
        std::cout << 4 << std::endl;
    }
    else if(S == "THU"){
        std::cout << 3 << std::endl;
    }
    else if(S == "FRI"){
        std::cout << 2 << std::endl;
    }
    else if(S == "SAT"){
        std::cout << 1 << std::endl;
    }
    else{

    }

    return 0;
}

Measured memory_bytes: 256
read = lambda:list(map(int, input().split()))
n = int(input())
l = read()
l.sort()
ans = 0
for i in range(n - 2):
    for j in range(i + 1, n - 1):
        if l[i] == l[j]:
            continue
        for k in range(j + 1, n):
            if l[j] == l[k]:
                continue
            if l[i] + l[j] > l[k]:
                ans += 1
print(ans)

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

using namespace std;

long long gcd(long long x, long long y) {
  if (y == 0) { return x;}
  return gcd(y, x % y);
}

int main() {
  int n; cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }

  vector<int> left(n+1, 0);
  for (int i = 0; i < n; i++) {
    left[i+1] = gcd(left[i], a[i]);
  }
  vector<int> right(n+1, 0);
  for (int i = n-1; i > 0; i--) {
    right[i] = gcd(right[i+1], a[i]);
  }
  int ans = 0;
  for (int i = 0; i < n; i++) {
    int t = gcd(left[i], right[i+1]);
    ans = max(ans, t);
  }
  cout << ans << endl;
  return 0;
}

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

int main(){

int n;
int a,b,c;

scanf("%d",&n);

if(n == 2){
scanf("%d%d",&a,&b);
if(a > b)swap(a,b);
for(int i = 1;i <= a;i++){
if(a % i == 0 && b % i == 0)printf("%d\n",i);
}
}else{
scanf("%d%d%d",&a,&b,&c);

if(a > b)swap(a,b);
if(a > c)swap(a,c);

for(int i = 1;i <= a;i++){
if(a % i == 0 && b % i == 0 && c % i == 0)printf("%d\n",i);
}
}
return 0;
}


Measured memory_bytes: 1188
A['   '];B,X,Y;W,J,I;main(M){scanf("%d%d",&I,&M);for(;~scanf("%d%d",&X,&Y);){for(B=Y+1,J=1;J*J<=M;J++)I=(X+J-1)/J,W=Y/J+1,A[I]++,A[W<B?W:B]--,B=I;for(I=1;I<B;I++)(X-1)/I<Y/I?A[I]++,A[I+1]--:0;}for(I=1;I<=M;I++)A[I]+=A[I-1],printf("%d\n",A[I]);}

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

#define F first 
#define S second

using namespace std;

typedef long long LL;
typedef pair<int, int> PII;

const int N = 100010, M = 4 * N, INF = 0x3f3f3f3f;

int n, m;
int h[N], e[M], w[M], ne[M], idx;
int dist[N], q[N];
bool st[N];

bool bfs(int u)
{
	int hh = 0, tt = -1;
	q[ ++ tt] = u;
	st[u] = true;
	
	while (hh <= tt)
	{
		int t = q[hh ++ ];
		// st[t] = true;
		
		for (int i = h[t]; ~i; i = ne[i])
		{
			int j = e[i];
			if (!st[j])
			{
				q[ ++ tt] = j;
				st[j] = true;
				dist[j] = dist[t] + w[i];
			}
			else if (dist[j] != dist[t] + w[i]) return false;
		}
	}
	return true;
}

void add(int a, int b, int c)
{
	e[idx] = b, w[idx] = c, ne[idx] = h[a], h[a] = idx ++ ;
}

int main()
{
	memset(h, -1, sizeof h);
	scanf("%d%d", &n, &m);
	while (m -- )
	{
		int a, b, c;
		scanf("%d%d%d", &a, &b, &c);
		add(a, b, c), add(b, a, -c);
	}
	
	for (int i = 1; i <= n; i ++ )
		if (!st[i] && !bfs(i))
		{
			puts("No");
			return 0;
		}
	puts("Yes");
    return 0;
}

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

int main()
{
    int n;
    cin >> n;
    vector<int> t(n), x(n), y(n);
    rep(i, 0, n) cin >> t[i] >> x[i] >> y[i];
    rep(i, 0, n){
        if(t[i]%2 == (x[i] + y[i])%2) continue;
        cout << "No" << endl;
        return 0;
    }
    if(t[0] < x[0] + y[0]){
        cout << "No" << endl;
        return 0;
    }
    rep(i, 1, n){
        if(abs(x[i-1] - x[i]) + abs(y[i-1] - y[i]) > t[i] - t[i-1]){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}


Measured memory_bytes: 4248
#include<bits/stdc++.h>
using namespace std;
int main(){
 int n;
 char ch;
 while(1){
 int max=0,idx=0,idx2=26,f=0,a[27]={};
 cin>>n;
 if(n==0)break;
 for(int i=0;i<n;i++){
  cin>>ch; 
  if(f!=1){
   a[(int)ch-65]++;
   for(int j=0;j<26;j++)if(a[j]>max){max=a[j];idx=j;}
   max=0;
   for(int j=0;j<26;j++)if(a[j]>max && j!=idx){max=a[j];idx2=j;} 
   if(a[idx]>a[idx2]+(n-(i+1))){idx2=idx;idx=i;f=1;}
  }
 }
 if(f==1)cout<<(char)(idx2+65)<<' '<<idx+1<<endl;
 else cout<<"TIE"<<endl;
 }
 return 0;
}

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

public class Main{
	public static void main(String args[]){
		try{
			new Main();
		}catch(IOException err){
			err.printStackTrace();
		}
	}

	public Main() throws IOException{
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		String line;

		while((line = in.readLine()) != null){
			String[] dst = line.split(" ");
			List<Integer> sort = new ArrayList<Integer>();
			List<Integer> que = new ArrayList<Integer>();
			double box = Double.parseDouble(dst[0]);

			int size = dst.length-1;
			int[] rad = new int[size];
			for(int i=0; i<size; i++){
				rad[i] = Integer.parseInt(dst[i+1]);
			}

			double width = 0.0;
			if(size>1){
				Arrays.sort(rad);
				for(int i=0; i<size-1; i++){
					que.add(rad[i]);
				}

				int flag = -1;
				sort.add(rad[size-1]);
				while(que.size() > 1){
					if(flag == 1){
						flag = -1;
						int num = que.size()-1;
						int r = que.get(num);
						que.remove(num);
						double wr = 2.0 * Math.sqrt(r * sort.get(0));
						double wl = 2.0 * Math.sqrt(r * sort.get(sort.size()-1));
						if(wr < wl){
							sort.add(0, r);
							width += wr;
						}else{
							sort.add(r);
							width += wl;
						}
					}
					else if(flag == -1){
						flag = 1;
						int num = 0;
						int r = que.get(num);
						que.remove(num);
						double wr = 2.0 * Math.sqrt(r * sort.get(0));
						double wl = 2.0 * Math.sqrt(r * sort.get(sort.size()-1));
						if(wr < wl){
							sort.add(r);
							width += wl;
						}else{
							sort.add(0, r);
							width += wr;
						}
					}
				}

				int r = que.get(0);
				double wr = r + 2.0 * Math.sqrt(r * sort.get(0)) + sort.get(sort.size()-1);
				double wl = sort.get(0) + 2.0 * Math.sqrt(sort.get(sort.size()-1) * r) + r;
				width += Math.min(wr, wl);
			}
			else{
				width = 2.0 * rad[0];
			}
			if(width <= box){
				System.out.println("OK");
			}else{
				System.out.println("NA");
			}
		}
	}
}

Measured memory_bytes: 9740
#include<bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<(int)N;i++)
int main()
{
  int T,F,Q,count=0;
  string S;
  char C;
  deque<char> d;
  cin>>S>>Q;
  for(auto str:S)d.push_back(str);
  rep(i,Q)
  {
    cin>>T;
    if(T==2)
    {
      cin>>F>>C;
      if(count%2==0&&F==1)d.push_front(C);
      if(count%2==0&&F==2)d.push_back(C);
      if(count%2==1&&F==1)d.push_back(C);
      if(count%2==1&&F==2)d.push_front(C);
    }else{count++;}
  }
  if(count%2==1)reverse(d.begin(),d.end());
  for(auto x:d)cout<<x;
}

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

int main() {
	int h;
	cin >> h;
	int w;
	cin >> w;
	vector<string> a(h);
	for (int i = 0; i < h; i++) {
		cin >> a[i];
	}

	vector<bool> row(h, false);
	vector<bool> col(w, false);
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			if (a[i][j] == '#') {
				row[i] = true;
				col[j] = true;
			}
		}
	}

	for (int i = 0; i < h; i++) {
		if (row[i]) {
			for (int j = 0; j < w; j++) {
				if (col[j]) {
					cout << a[i][j];
				}
			}
			cout << endl;
		}
	}
}


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

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

using namespace std;

int main(){
	int l,r; cin>>l>>r;

	if(r-l>=2019) cout<<0<<endl;
	else{
		int ans=2019;
		for(int i=l;i<=r;i++) for(int j=i+1;j<=r;j++) ans=min(ans,(int)((long long)i*j%2019));
		cout<<ans<<endl;
	}

	return 0;
}


Measured memory_bytes: 256
import java.io.*;
import java.util.*;
import java.lang.Math.*;
public class Main{
    public static void main(String[] args)throws IOException{
	InputStreamReader isr = new InputStreamReader(System.in);
	BufferedReader br = new BufferedReader(isr);
	String line = br.readLine();
	int n = Integer.parseInt(line);
	while(n!=0){
	    int answer = -2000000;
	    int sum = 0;
	    for(int i =0;i<n;i++){
		int a = Integer.parseInt(br.readLine());
		sum=Math.max(a,sum+a);
		answer=Math.max(answer,sum);
	    }
	    System.out.println(answer);
	    n=Integer.parseInt(br.readLine());
	}
    }
}
		

Measured memory_bytes: 21448
#define REP(i, t, n)  for (int i = t; i < n; i++)
#define ALL(n)        (n).begin(),(n).end()
#include <limits.h>
#include <stdio.h>
#include <cmath>
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <map>
#include <queue>
#include <deque>
#include <functional>
#include <algorithm>
#include <cstring>
#include <unordered_map>
#include <numeric>

using namespace std;

typedef bool               BOOL;
typedef short              WORD;
typedef unsigned short     U_WORD;
typedef long               DWORD;
typedef unsigned long      U_DWORD;
typedef long long          QWORD;
typedef unsigned long long U_QWORD;

#define MAX_POINT (100000)
vector<DWORD> vdwLevel;
DWORD N;

void solve_main()
{
	DWORD dwAns = 0;
	cin >> N;

	REP(i, 0, N) {
		DWORD tmp;
		cin >> tmp;
		vdwLevel.push_back(tmp);
	}

	sort(ALL(vdwLevel));

	REP(i, 1, MAX_POINT + 1) {
		auto iter = lower_bound(ALL(vdwLevel), i);

		if (iter == vdwLevel.end()) {
			break;
		}
		if ((N / 2) == distance(vdwLevel.begin(), iter)) {
			dwAns++;
		}
	}

	cout << dwAns;
}

int main()
{
#ifdef FOR_IDE
	ifstream in("input.txt");
	cin.rdbuf(in.rdbuf());
#endif

	solve_main();
	return 0;
}


Measured memory_bytes: 1400
#include <stdio.h>
int main(void)
{
	int A, B, C;
	int flag=0;

	scanf("%d %d %d", &A, &B, &C);

	for(int i=1; i<2*2*2*2*2*2*2*2*2; i++){
		if((A*i)%B==C)
			flag=1;
	}

	if(flag)
		printf("YES\n");
	else
		printf("NO\n");

	return 0;
}

Measured memory_bytes: 128
# coding: utf-8
# Your code here!
"""
Binary indexed tree
0-indexed, 関数は閉区間
0からの区間加算、1点更新
"""
class BIT: #0-indexed
    def __init__(self, n):
        self.tree = [0]*(n+1)
        self.tree[0] = None
#        self.element = [0]*(n+1)
    def sum(self, i): #a_0 + ... + a_{i} #閉区間
        s = 0; i += 1
        while i > 0:
            s += self.tree[i]
            i -= i & -i
        return s
    def range(self,l,r): #a_l + ... + a_r 閉区間
        return sum(r) - sum(l-1) 
    def add(self, i, x):
        i += 1
        while i <= n:
            self.tree[i] += x
            i += i & -i
        # self.element[i] += x
    #def get(self,i): return element[i]        
    
###########################################

import sys
sys.setrecursionlimit(10**6)
readline = sys.stdin.readline #文字列入力のときは注意

n = int(input())
xyi = [[int(i) for i in readline().split()]+[j] for j in range(n)]
#xyi = []
#for i in range(n):
#    a = [int(i) for i in readline().split()]
#    xyi.append(a+[i])

#dame_x = [0]*n
#dame_y = [0]*n
#dame_xy = [0]*n

ABi = [0]*n
CDi = [0]*n

MOD = 998244353

sxyi = sorted(xyi, key = lambda x: x[1])
zaatu = [0]*n
for j in range(n): zaatu[sxyi[j][2]] = j
for j, (x,y,i) in enumerate(sxyi):
    ABi[i] = n-j-1
    CDi[i] = j

pow2 = [1]*(n+1)
for i in range(n):
    pow2[i+1] = pow2[i]*2%MOD


xyi.sort()
#print(pow2)

bit = BIT(n)

ans = n*(pow2[n]-1)%MOD
for j, (x,y,i) in enumerate(xyi):
    AB = ABi[i]
    CD = CDi[i]
    BC = j
    AD = n-j-1
    c = bit.sum(zaatu[i])
    C = c
    B = j-c
#    print(AB-B,B,C,CD-C)
    ans -= pow2[AB]-1 + pow2[CD]-1 
    ans -= pow2[BC]-1 + pow2[AD]-1
    ans += pow2[C]-1 + pow2[CD-C]-1 + pow2[B]-1 + pow2[AB-B]-1

    bit.add(zaatu[i],1)
        

        


print(ans%MOD)    








Measured memory_bytes: 111452
MAX = 300000001

N, K = map(int, input().split())
xn = [int(i) for i in input().split()]


def main():
    if 0 <= xn[0]:
        print(xn[K - 1])
        return

    if xn[N - 1] < 0:
        print(abs(xn[N - K]))
        return

    ans = MAX

    for i in range(N):
        if N - 1 < i + K - 1:
            break

        if xn[i] < 0:
            if xn[i + K - 1] < 0 and i + K <= N - 1 and 0 < xn[i + K]:
                ans = min(ans, abs(xn[i]))

            elif 0 <= xn[i + K - 1]:
                ans = min(ans,
                          2 * abs(xn[i]) + abs(xn[i + K - 1]),
                          abs(xn[i]) + 2 * abs(xn[i + K - 1]))

        elif 0 == xn[i]:
            ans = min(ans, xn[i + K - 1])

    print(ans)
    return


main()


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

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

using namespace std;

int main(){
  map<int, int>m;
  int maxn=0;
  rep(i,3)rep(i,2){
    int t;cin>>t;
    m[t]++;
    maxn=max(maxn, m[t]);
  }

  if(m.size()==4 && maxn==2) cout<<"YES";
  else cout<<"NO";

  return 0;
}

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

using namespace std;
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)

int main () {
    long long q, h, s, d;
    long long n;
    cin >> q >> h >> s >> d;
    cin >> n;

    long long res = 0;

    long long p[4];
    long long curVol = 2;
    p[0] = 8LL * q;
    p[1] = 4LL * h;
    p[2] = 2LL * s;
    p[3] = 1LL * d;
    res += 1LL * min(p[0], min(p[1], min(p[2], p[3]))) * (n / 2);

    if(n & 1) {
        p[0] /= 2LL;
        p[1] /= 2LL;
        p[2] /= 2LL;
        res += 1LL * min(p[0], min(p[1], p[2]));
    }

    cout << res;
}


Measured memory_bytes: 256