akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
int main()
{

	int n,ans=0;;
	cin>>n;
	std::vector<int> v(n);
	for(auto &it:v)cin>>it;
	sort(v.begin(),v.end());
	for(int i=0;i<n-2;i++)
	{
		for(int j=i+1;j<n-1;j++)
		{
			for(int k=j+1;k<n;k++)
			{
				if((v[i]!=v[j] && v[j]!=v[k]) && (v[i]+v[j]>v[k]))ans++;
			}
		}
	}
	cout<<ans<<endl;
	ans=0;
}

Measured memory_bytes: 3588
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <cstdlib>
#include <cstdio>
#include <string>
#include <cstring>
#include <climits>
#include <map>
using namespace std;

static const long long INFTY = (1LL<<32);


int main() {
    string str;
    cin >> str;
    
    cout << "ABC" << str << endl;
}


Measured memory_bytes: 256
#include <stdio.h>

const char *t[] = {"black","blue","lime","aqua","red","fuchsia","yellow","white"};

int solve(int r, int g, int b){
    int min = 0; int mind = 200000;
    for(int i = 0; i < 8; i++){
        int r0 = ((i>>2)&1)*0xff, g0 = ((i>>1)&1)*0xff, b0 = ((i>>0)&1)*0xff;
        //pf("%d,%d,%d : %d,%d,%d\n", r,g,b,r0,g0,b0);
        int d = (r-r0)*(r-r0)+(g-g0)*(g-g0)+(b-b0)*(b-b0);
        if(mind > d){
            mind = d, min = i;
        }
    }
    if(min >= 8) throw;
    return min;
}

int main(){
    int n;
    char buf[16];
    while(fgets(buf,sizeof(buf),stdin)){
        if(buf[0] == '0') break;
        sscanf(buf+1,"%x",&n);
        int i = solve((n>>16)&0xff,(n>>8)&0xff,n&0xff);
        printf("%s\n", t[i]);
    }
    return 0;
}

Measured memory_bytes: 1028
#include<iostream>
#include<cmath>
#include<algorithm>
#include<vector>

double distance(int i, int j, int x[], int y[]){
    double dx = x[i] - x[j];
    double dy = y[i] - y[j];
    double temp = dx*dx + dy*dy;
    return std::pow(temp, 0.5);
}

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

    int x[n+1];
    int y[n+1];
    std::vector<int> v(n);

    for(int i = 1; i <= n; i++){
        std::cin >> x[i] >> y[i];
    }

    for(int i = 0; i < n; i++){
        v[i] = i+1;
    }

    double sum_of_distance = 0.0;

    do{ 
        for(int i = 0; i < n-1; i++) sum_of_distance += distance(v[i], v[i+1], x, y);
    } while(std::next_permutation(v.begin(), v.end()));

    double factorial = 1;
    for(int i = 2; i <= n; i++){
        factorial *= i;
    }

    double ans = sum_of_distance / factorial;

    printf("%.15lf", ans);
    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n)  for(long long i=0;i<(long long)(n);i++)
#define REP(i,k,n) for(long long i=k;i<(long long)(n);i++)
#define all(a) a.begin(),a.end()
#define eb emplace_back
#define pb push_back
#define lb(v,k) (lower_bound(all(v),k)-v.begin())
#define ub(v,k) (upper_bound(all(v),k)-v.begin())
typedef long long ll;
typedef pair<ll,ll> P;
#define se second
#define fi first
struct PP{ll fi;ll se;ll th;};
typedef multiset<ll> S;
typedef priority_queue<ll> PQ;
typedef priority_queue<P,vector<P>,greater<P>> SPQ;
using vi=vector<ll>;
using vvi=vector<vector<ll>>;
const ll inf=1001001001001001;
const int INF=1001001001;
const int mod=1000000007;
bool chmin(auto &a,auto b){if(a>b){a=b;return true;}return false;}
bool chmax(auto &a,auto b){if(a<b){a=b;return true;}return false;}
void outvi(vi v){rep(i,v.size()){if(i)cout<<' ';cout<<v[i];}cout<<endl;}
void outvvi(vvi v){rep(i,v.size()){rep(j,v[i].size()){if(j)cout<<' ';cout<<v[i][j];}cout<<endl;}}
int main(){
    ll n,a,m,b;cin>>n>>a>>m>>b;
    if(n+1==m)cout<<1<<endl;
    else cout<<0<<endl;
}

Measured memory_bytes: 256
def is_month(s):
    if 1 <= int(s) and int(s) <= 12:
        return 1
    else:
        return -1

s = list(input())

before = s[0] + s[1]

after = s[2] + s[3]

ret_b = is_month(before)
ret_a = is_month(after)

if ret_b == 1 and ret_a == 1:
    print("AMBIGUOUS")
elif ret_b == 1 and ret_a == -1:
    print("MMYY")
elif ret_b == -1 and ret_a == 1:
    print("YYMM")
else:
    print("NA")


Measured memory_bytes: 3064
/*
AuThOr GaRyMr
技巧:
1.区别对待大数据&小数据！
2.Dp难推时算贡献！
3.long long (尤其乘法)！
4.long long INF 要大
5.Dp on trees: 换根法，每次清空当前的节点和换到的子节点
6.long double | 输出浮点数
7.注意特判!(prince and princess)
8.是否可以记录两个值之间的关系 CSPday2 meal
9.括号-》数组or栈
10.是否可以先构造
11.网络流奇偶构图
*/
#include<bits/stdc++.h>
#define rb(a,b,c) for(int a=b;a<=c;++a)
#define rl(a,b,c) for(int a=b;a>=c;--a)
#define niv vector<int>
#define LL long long
#define IT iterator
#define PB push_back
#define II(a,b) make_pair(a,b)
#define FIR first
#define SEC second
#define FREO freopen("check.out","w",stdout)
#define rep(a,b) for(int a=0;a<b;++a)
#define KEEP while(1)
#define SRAND mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define random(a) rng()%a
#define ALL(a) a.begin(),a.end()
#define POB pop_back
using namespace std;
const int INF=0x3f3f3f3f;
typedef pair<int,int> mp;
typedef pair<mp,mp> superpair;
int main(){
	LL a,b;
	cin>>a>>b;
	cout<<a*b/__gcd(a,b);
	return 0;
}


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

void chmin(int64_t& a, int64_t b){
    a = min(a, b);
}

int N;
int64_t A[5000];
vector<int> edges[5000];

int64_t dp[5000][5000][2], sub[5000][2];
int sz[5000];

const int64_t INF = 1e18;

void dfs(int i, int p){
    for(int j=0; j<N; j++) for(int k=0; k<2; k++) dp[i][j][k] = sub[j][k] = INF;
    dp[i][0][(A[i] < 0)] = A[i];
    for(int j : edges[i]) if(j != p){
        dfs(j, i);
        for(int n1=0; n1<=sz[i]; n1++) for(int n2=0; n2<=sz[j]; n2++) for(int k1=0; k1<2; k1++) for(int k2=0; k2<2; k2++){
            int64_t v1 = dp[i][n1][k1], v2 = dp[j][n2][k2];
            if(max(v1, v2) == INF) continue;
            chmin(sub[n1+n2][k1|k2], v1+v2);
            if(k2 == 0 || v2 < 0) chmin(sub[n1+n2+1][k1], v1);
        }
        sz[i] += sz[j] + 1;
        for(int j=0; j<=sz[i]; j++) for(int k=0; k<2; k++){
            dp[i][j][k] = sub[j][k];
            sub[j][k] = INF;
        }
    }
}

int main(){
    cin >> N;
    for(int i=0; i<N; i++) cin >> A[i];
    for(int i=0; i<N-1; i++){
        int a, b;
        cin >> a >> b;
        edges[a-1].push_back(b-1);
        edges[b-1].push_back(a-1);
    }

    dfs(0, -1);
    for(int j=0; j<N; j++) if(dp[0][j][0] < INF || dp[0][j][1] < 0){
        cout << j << endl;
        return 0;
    }
    return 0;
}

Measured memory_bytes: 391936
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; ++i)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = int64_t;
using ld = long double;
using P = pair<int, int>;
using vs = vector<string>;
using vi = vector<int>;
using vvi = vector<vi>;
template<class T> using PQ = priority_queue<T>;
template<class T> using PQG = priority_queue<T, vector<T>, greater<T> >;
const int INF = 100010001;
const ll LINF = (ll)INF*INF*10;
template<typename T1, typename T2>
inline bool chmax(T1 &a, T2 b) {return a < b && (a = b, true);}
template<typename T1, typename T2>
inline bool chmin(T1 &a, T2 b) {return a > b && (a = b, true);}
template<typename T1, typename T2>
istream &operator>>(istream &is, pair<T1, T2> &p) { return is >> p.first >> p.second;}
template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p) { return os << p.first << ' ' << p.second;}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    string s;
    cin >> s;
    int n = s.size();
    int alp[26] = {};
    rep(i, n) {
        alp[s[i]-'a']++;
    }
    int oddcnt = 0;
    rep(i, 26) {
        oddcnt += (alp[i]&1);
    }
    if(oddcnt > 1) {
        cout << -1 << endl;
        return 0;
    }

    int alcnt[26] = {};
    string sg;
    char h;
    rep(i, n) {
        int num = s[i]-'a';
        alcnt[num]++;
        if(alcnt[num] <= (alp[num]+1)/2) {
            if(alp[num]&1 and alcnt[num] == (alp[num]+1)/2) {
                h = char(num+'a');
                continue;
            }
            sg += char(num + 'a');
        }
    }


    string rev = sg;
    if(n&1) rev += h;
    reverse(all(rev));
    int cnt = 0;
    vi bit(rev.size()+1);
    auto add = [&](int i, int x) {
        while(i <= rev.size()) {
            bit[i] += x;
            i += i&-i;
        }
    };
    auto sum = [&](int i) {
        int res = 0;
        while(i) {
            res += bit[i];
            i &= i-1;
        }
        return res;
    };


    queue<int> q[26];
    rep(i, rev.size()) {
        q[rev[i]-'a'].push(i+1);
    }


    ll ans = 0;
    rep(i, n) {
        if(cnt < sg.size() and s[i] == sg[cnt]) {
            cnt++;
        } else {
            int now = q[s[i]-'a'].front();
            q[s[i]-'a'].pop();
            ans += i-cnt-sum(now);
            add(now, 1);
            ans += sg.size() - cnt;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 4596
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const long long MOD = 1e9+7, MAX = 1e18, larg = 1e5, INF = -1e9;
long long A,B,C,D,E,F,G,H,I,J,K,L,N,M,O,P,Q,R,S,T,U,V,W,X,Y,Z;
long long max_value = INF, max_index = -1;
long long min_value = MAX, min_index = -1;
long long sum = 0;

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

int main() {
    cin >> N;
    cout << N*N;
}


Measured memory_bytes: 256
character(6) :: w(3)
character(6) :: in
integer :: ans
w(1) = 'Sunny'
w(2) = 'Cloudy'
w(3) = 'Rainy'

read*,in
if( trim(in)==trim(w(1)) ) ans = 2
if( trim(in)==trim(w(2)) ) ans = 3
if( trim(in)==trim(w(3)) ) ans = 1

print'(a)',trim( w(ans) )
end

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

void int_swap(int* a,int*b)
{
    int temp = *a;
    *a = *b;
    *b = temp;
}
void quicksort(int *a,int first,int last)
{
    int i=first,j=last,pivot=last;
    while(1){
        i--;
        do{i++;if(a[first]>a[i]) break;}while(i<j);
        if(i==j && !(a[first]>a[i])){
            pivot = i; 
            break;
        }
        j++;
        do{j--;if(a[first]<a[j]) break;}while(i<j);
        if(i==j){
            pivot = i-1;
            break;
        }
        int_swap(&a[i],&a[j]);
    }

    int_swap(&a[first],&a[pivot]);
    if(pivot>first) quicksort(a,first,pivot-1);
    if(pivot<last) quicksort(a,pivot+1,last);
}
int main(void)
{
    int a[3],i,j,k,n;

    cin >> a[0] >> a[1] >> a[2];
    quicksort(a,0,2);
    if(a[1]+a[2]>=10){
        cout << a[0]+1 << a[1]+a[2]-10;
    }
    else cout << a[0] << a[1]+a[2];

    return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n=sc.nextInt(),l=sc.nextInt();
    StringBuffer sb=new StringBuffer();
    String[] strs=new String[n];
    for(int i=0;i<n;i++){
      strs[i]=sc.next();
    }
    Arrays.sort(strs);
    for(int i=0;i<n;i++){
      sb.append(strs[i]);
    }
    System.out.println(sb);
  }
}

Measured memory_bytes: 21844
package main

import (
	"fmt"
	"sort"
)

func main() {
	var cnt int
	fmt.Scan(&cnt)
	nums := make([]int, cnt)

	for i := range nums {
		fmt.Scan(&nums[i])
	}
	sort.Ints(nums)
	sort.Sort(sort.Reverse(sort.IntSlice(nums)))

	var al int
	var bo int

	d := 0
	for i := range nums {
		if d%2 == 0 {
			al += nums[i]
		} else {
			bo += nums[i]
		}
		d = 1 - d
	}

	fmt.Print(al - bo)
}

Measured memory_bytes: 512
import java.util.*;
public class Main {
    public static void main(String[] args) {
    
    Scanner sc = new Scanner(System.in);

      //入力
      int m =sc.nextInt();//モンスターの数
      int waza =sc.nextInt();//必殺技回数
      
      //HPリストの空箱用意
      ArrayList<Long>hp=new ArrayList<>();
      
      //HPリスト作成
      for(int i=0; i<m; i++){
      		hp.add(sc.nextLong());
      }
      
      //HPリストの中を降順に
      Collections.sort(hp, Collections.reverseOrder());
      
      long kougeki =0;//攻撃のみの回数(初期値)
      
      //必殺技だけでモンスターを倒せるとき
      if(m<waza){
        	System.out.println(0);
        	return;
      }
      
      //必殺技を除いた攻撃回数を求める
      for(int i=waza; i<m; i++){
        	kougeki += hp.get(i);
      }
      
      System.out.println(kougeki);

    }
}

Measured memory_bytes: 66336
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,i,j,k,l;
    string s;
    int ac,wa,tle,re;
    cin>>n;
    ac=0;
    tle=0;
    re=0;
    wa=0;
    for(i=1;i<=n;i++)
    {
        cin>>s;
        if(s=="AC")ac++;
        if(s=="RE")re++;
        if(s=="TLE")tle++;
        if(s=="WA")wa++;

    }
    cout<<"AC x "<<ac<<endl;
    cout<<"WA x "<<wa<<endl;
    cout<<"TLE x "<<tle<<endl;
    cout<<"RE x "<<re<<endl;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
#include <math.h>
#define _GLIBCXX_DEBUG
#define _LIBCPP_DEBUG 0

using namespace std;
#define ll long long
#define rep(i,n) for (int i = 0; i < n; i++)
#define rrep(i,n) for (int i = n-1; i >= 0; i--)
#define MOD (1000000007)
#define vi vector<int>
#define vl vector<ll>
#define vb vector<bool>
#define vvi vector<vi>
#define vvl vector<vl>
#define pii pair<int, int>
#define pli pair<ll, int>a
#define pb push_back

#define mp make_pair
#define all(a) (a).begin(),(a).end()

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

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

ll keta(ll n){
  string s = to_string(n);
  ll num = s.size();
  return num;
}

const ll INF = 1LL << 60;

const int dh[4] = {1,0,-1,0};
const int dw[4] = {0,1,0,-1};

struct Edge{
  int to;
  int weight;
  Edge(int t, int w) : to(t), weight(w){}
};
using Graph = vector<vector<Edge>>;
using P = pair<ll, int>;


int main(){
  int H, W, D; cin >> H >> W >> D;
  vvi a(H,vi(W));
  vector<pii> C(H*W);
  rep(h,H) rep(w,W){
    cin >> a[h][w];
    a[h][w]--;
    C[a[h][w]] = mp(h,w);
  }



  vi s(H*W);
  for(int i = D; i < H*W; i++) {
    int dh = C[i].first - C[i-D].first;
    int dw = C[i].second - C[i-D].second;
    s[i] = s[i-D] + abs(dh) + abs(dw);
  }


  int q; cin >> q;
  while(q--){
    int l,r; cin >> l >> r;
    l--; r--;
    cout << s[r] - s[l] << endl;
  }
}

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

int main(){
  int K, S;
  cin >> K >> S;
  int count = 0;
  for(int i = 0; i <= K; i++){
    for(int j = 0; j <= K; j++){
      if(S - i - j >= 0 && S - i - j <= K) count++;
    }
  }
  cout << count << endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <queue>
#include <algorithm>
int N, p[200001], ref[200001], RMQ[2][18][200001], LOG[200001];
struct tok
{
	int l, r, x, y;
};
struct com
{
	inline bool operator () (const tok &x, const tok &y)
	{
		return p[x.x] > p[y.x];
	}
};
inline int choose(int x, int y)
{
	return p[x] < p[y] ? x : y;
}
inline int Query(int f, int l, int r)
{
	int Log = LOG[r - l + 1];
	return choose(RMQ[f][Log][l], RMQ[f][Log][r - (1 << Log) + 1]);
}
std::priority_queue < tok, std::vector < tok >, com > Q;
tok make(int l, int r)
{
	int x = Query(l & 1, l, r - 1), y = Query(r & 1, x + 1, r);
	return { l, r, x, y };
}
int main()
{
	scanf("%d", &N);
	p[0] = 1000000000;
	for (int i = 1; i <= N; i++)
	{
		scanf("%d", p + i);
		ref[p[i]] = i;
		RMQ[i & 1][0][i] = i;
	}
	for (int i = 2; i <= N; i++)
		LOG[i] = LOG[i >> 1] + 1;
	for (int i = 1, k = 1; k + k <= N; i++, k <<= 1)
		for (int j = 1; j <= N - k - k + 1; j++)
		{
			RMQ[0][i][j] = choose(RMQ[0][i - 1][j], RMQ[0][i - 1][j + k]);
			RMQ[1][i][j] = choose(RMQ[1][i - 1][j], RMQ[1][i - 1][j + k]);
		}
	Q.push(make(1, N));
	for (int T = N >> 1; T--; )
	{
		tok D = Q.top();
		Q.pop();
		printf("%d %d ", p[D.x], p[D.y]);
		if (D.l < D.x)
			Q.push(make(D.l, D.x - 1));
		if (D.x < D.y - 1)
			Q.push(make(D.x + 1, D.y - 1));
		if (D.y < D.r)
			Q.push(make(D.y + 1, D.r));
	}
	puts("");
	return 0;
}


Measured memory_bytes: 32500
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define all(x) (x).begin(),(x).end()
#define V vector
typedef V<int> vi;
typedef V<vi> vvi;
typedef long long ll;
typedef pair<ll, ll> P;
typedef tuple<int, int, int> T;
constexpr auto INF = INT_MAX >> 1;
constexpr auto LINF = 5000000000000000;
constexpr auto MOD = 1000000007;

int main() {

	int n, m;
	cin >> n >> m;
	string s;
	cin >> s;
	reverse(all(s));

	vi ans;
	int p = 0;
	while (true) {
		int k = min(p + m, n);
		while (p < k) {
			if (s[k] == '0') {
				ans.push_back(k - p);
				break;
			}
			k--;
		}
		if (p == k) {
			cout << -1 << endl;
			return 0;
		}
		p = k;
		if (p == n)break;
	}

	rep(i, ans.size()) {
		cout << ans[ans.size() - 1 - i];
		if (i < ans.size() - 1)cout << " ";
		else cout << endl;
	}
}

Measured memory_bytes: 1144
import java.io.*;
import java.util.*;
import java.util.function.*;

final class Solver {
	void solve(Supplier<String> sc) {
		int X = Integer.parseInt(sc.get());
		System.out.println(X >= 30 ? "Yes" : "No");
	}
}

class Main {
	public static void main(String... args) {
		System.setOut(new PrintStream(new BufferedOutputStream(System.out)));
		var reader = new BufferedReader(new InputStreamReader(System.in));
		new Solver().solve(new Supplier<>() {
			StringTokenizer line;

			public String get() {
				while (line == null || !line.hasMoreTokens()) try {
					line = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new UncheckedIOException(e);
				}
				return line.nextToken();
			}
		});
		System.out.flush();
	}
}

Measured memory_bytes: 32816
N, M = map(int, input().split())
A = list(map(int, input().split()))
ans = 0
pool = []
[pool.append((a, 1)) for a in A]
for _ in range(M):
  b, c = (map(int, input().split()))
  pool.append((c, b))
pool.sort(reverse=True, key=lambda x:x[0])

while N>0:
  for p in pool:
    if p[1] >= N:
      ans += p[0]*N
      N = 0
    if p[1] < N:
      ans += p[0]*p[1]
      N -= p[1]

print(ans)

Measured memory_bytes: 31944
#include <iostream>
#include <set>
#include <algorithm>
#include <vector>
#include <deque>
#include <stdint.h>
#include <utility>

using namespace std;

uint64_t calc(vector<int>& B)
{
  uint64_t ans = 0;
  for (int ii=0; ii<B.size()-1; ++ii) {
    ans += abs(B[ii+1]-B[ii]);
  }
  return ans;
}

void arrange_odd(deque<int>& A, vector<int>& B)
{
  int N = A.size();
  int idx_center = N/2;
  B[idx_center] = A.front();
  A.pop_front();
  int NN = (N-1)/2;

  for (auto b : B)
    cerr << b;
  cerr << endl;
  
  for (int n=0; n<2*(NN/2); ++n) {
    if (n%2==1)
      B[idx_center-2*(n/2)-2] = A.front();
    else
      B[idx_center+2*(n/2)+2] = A.front();
    A.pop_front();
  }

  for (int n=0; n<2*((NN+1)/2); ++n) {
    if (n%2==1)
      B[idx_center-2*(n/2)-1] = A.back();
    else
      B[idx_center+2*(n/2)+1] = A.back();
    A.pop_back();
  }

  for (auto b : B)
    cerr << b;
  cerr << endl;

}

void arrange_even(deque<int>& A, vector<int>& B)
{
  int N = A.size();
  int idx_center1 = N/2;
  int idx_center2 = N/2-1;
  B[idx_center1] = A.front();
  A.pop_front();
  B[idx_center2] = A.back();
  A.pop_back();
  int NN = (N-2)/2;

  for (auto b : B)
    cerr << b;
  cerr << endl;

  for (int n=0; n<NN; ++n) {
    cerr << n << endl;
    if (n%2==1)
      B[idx_center1+2*(n/2)+2] = A.front();
    else
      B[idx_center1-2*(n/2)-2] = A.front();
    A.pop_front();
  }

  for (auto b : B)
    cerr << b;
  cerr << endl;

  for (int n=0; n<NN; ++n) {
    if (n%2==1)
      B[idx_center2-2*(n/2)-2] = A.back();
    else
      B[idx_center2+2*(n/2)+2] = A.back();
    A.pop_back();
  }

  for (auto b : B)
    cerr << b;
  cerr << endl;
}

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

  multiset<int> ms;

  for (int n=0; n<N; ++n) {
    int a;
    cin >> a;
    ms.insert(a);
  }

  if (N%2==1) { // N is odd
    deque<int> A1(N), A2(N);
    copy(ms.begin(), ms.end(), A1.begin());
    copy(ms.rbegin(), ms.rend(), A2.begin());  
    vector<int> B1(N), B2(N);

    arrange_odd(A1,B1);
    arrange_odd(A2,B2);

    cerr << calc(B1) << endl;
    cerr << calc(B2) << endl;
    
    cout << max(calc(B1),calc(B2)) << endl;
    
  } else { // N is even
    deque<int> A1(N), A2(N);
    
    copy(ms.begin(), ms.end(), A1.begin());
    copy(ms.rbegin(), ms.rend(), A2.begin());

    for (auto a : A1)
      cerr << a;
    cerr << endl;
    
    vector<int> B1(N), B2(N);

    arrange_even(A1,B1);
    arrange_even(A2,B2);

    cerr << calc(B1) << endl;
    cerr << calc(B2) << endl;
    
    cout << max(calc(B1),calc(B2)) << endl;
  }

  
  return 0;
}

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

using ll = long long;
using Pi = pair<int, int>;
using Pl = pair<ll, ll>;
using vint = vector<int>;
using vvint = vector<vint>;
using vvvint = vector<vvint>;
using vdouble = vector<double>;
using vvdouble = vector<vdouble>;
using vvvdouble = vector<vvdouble>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using uint = unsigned int;
using ull = unsigned long long;

template<typename T> using uset = unordered_set<T>;
template<typename T1, typename T2> using umap = unordered_map<T1, T2>;

constexpr int INF = (1 << 30) - 1;
constexpr ll LLINF = 1LL << 60;
constexpr int dy[] = {1, 0, -1, 0, 1, -1, -1, 1};
constexpr int dx[] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr char el = '\n';
constexpr int mod = 1000000007;
constexpr int mod2 = 998244353;
template<typename T> T gcd(T a, T b) { return (b ? gcd(b, a % b) : a); }
template<typename T> T lcm(T a, T b) { return (a / gcd(a, b) * b); }
template<typename T1, typename T2>
inline bool chmin(T1 &a, T2 b) { return (a > b && (a = b, true)); }
template<typename T1, typename T2>
inline bool chmax(T1 &a, T2 b) { return (a < b && (a = b, true)); }

template<typename T>
vector<T> makeVector(size_t a, T b) { return (vector<T>(a, b)); }
template<typename... Ts>
auto makeVector(size_t a, Ts... ts) { 
	return (vector<decltype(makeVector(ts...))>(a, makeVector(ts...)));
}

template<typename T>
bool isin(T y, T x, T h, T w) { return (0 <= y && 0 <= x && y < h && x < w); }
template<typename T>
bool isin1(T y, T x, T h, T w) { return (0 < y && 0 < x && y <= h && x <= w); }

template<typename T>
ostream& operator <<(ostream &os, vector<T> &v) {
	if (v.size()) {
		os << v[0];
		for (int i = 1; i < v.size(); i++) os << " " << v[i];
	}
	return (os);
}

template<typename T>
istream& operator >>(istream &is, vector<T> &v) {
	for (auto &u : v) is >> u;
	return (is);
}

template<typename T1, typename T2>
istream& operator >>(istream &is, pair<T1, T2> &p) {
	return (is >> p.first >> p.second);
}


void Main() {
	int N; cin >> N;
	vector<string> S(N); cin >> S;

	ll cnt = 0;
	ll both = 0, lb = 0, ra = 0;
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < (int)S[i].size()-1; j++) {
			if (S[i][j] == 'A' && S[i][j+1] == 'B') cnt++;
		}
		if (S[i].front() == 'B' && S[i].back() == 'A') both++;
		else if (S[i].front() == 'B') lb++;
		else if (S[i].back()  == 'A') ra++;
	}	

	if (both > 0) {
		ll num = both-1;
		if (lb) {
			lb--, num++;
		}
		if (ra) {
			ra--, num++;
		}
		cnt += num;
	}
	
	cout << cnt + min(lb, ra) << endl;
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(0);
	cout << fixed << setprecision(20);
	Main();
	return (0);
}


Measured memory_bytes: 3756
#include <iostream>
#include <algorithm>
#include <complex>
#include <vector>
#include <cmath>
using namespace std;
typedef complex<double> P;

const double PI = acos(-1);
const double EPS = 1e-9;
bool hit(P p,double a,double b,double r){
	if( abs(p) > r + EPS ) return false;
	double deg = atan2(p.imag(),p.real());
	if( a <= deg && deg <= b ) return true;
	if( a <= deg+2*PI && deg+2*PI <= b ) return true;
	if( a <= deg-2*PI && deg-2*PI <= b ) return true;
	return false;
}
int main(){
	int H,R;
	while(cin >> H >> R && H){
		P home[100];
		for(int i = 0 ; i < H ; i++) cin >> home[i].real() >> home[i].imag();
		int U,M,S;
		double du,dm,ds;
		cin >> U >> M >> S >> du >> dm >> ds;
		du = du / 180.*PI;
		dm = dm / 180.*PI;
		ds = ds / 180.*PI;
		du /= 2;
		dm /= 2;
		ds /= 2;
		vector< pair<P,double> > flower;
		for(int i = 0 ; i < U+M+S ; i++){	
			P p; cin >> p.real() >> p.imag();
			flower.push_back(make_pair(p,(i<U?du:i<U+M?dm:ds)));
		}
		int answer[110] = {};
		for(int i = 0 ; i < R ; i++){
			double w,r;
			cin >> w >> r;
			w = w / 180. * PI;
			for(int j = 0 ; j < H ; j++){
				int ok = hit(home[j],w-du,w+du,r);
				//cout << w-du << " " << w+du << endl;
				for(int k = 0 ; k < U+M+S ; k++){
					ok &= !hit(home[j]-flower[k].first,w-flower[k].second,w+flower[k].second,r);
				}
				answer[j] += ok;
			}
		}
		int maximum = *max_element(answer,answer+H);
		int fst = 1;
		if( maximum == 0 ){ cout << "NA" << endl; goto exit; }

		for(int i = 0 ; i < H ; i++)
			if( maximum == answer[i] ){
				if( fst == 0 ) cout << " ";
				cout << i+1;
				fst = 0;
			}
		cout << endl;
		exit:;
	}
	
	
	
	
}

Measured memory_bytes: 1312
#include <stdio.h>

int main(){
	int A, B, C, D;

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

	while(1){
		C = C - B;
		if(C<=0){
			printf("Yes");
			break;
		}

		A = A - D;
		if(A<=0){
			printf("No");
			break;
		}
	}

	return 0;
}


Measured memory_bytes: 1724
#include <iostream>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <string>
#include <sstream>
#include <algorithm>
#include <random>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cmath>
#include <cassert>
#include <climits>
#include <bitset>
#include <functional>
#include <iomanip>

#define FOR_LT(i, beg, end) for (int i = beg; i < end; i++)
#define FOR_LE(i, beg, end) for (int i = beg; i <= end; i++)
#define FOR_DW(i, beg, end) for (int i = beg; end <= i; i--)

using namespace std;

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout << fixed << setprecision(20);

	bool ok[4] = { false };
	FOR_LT(i, 0, 2) {
		int a; cin >> a;
		ok[a] = true;
	}

	FOR_LE(i, 1, 3) {
		if (!ok[i]) {
			cout << i << endl;
			break;
		}
	}

	return 0;
}

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

using namespace std;
using namespace __gnu_pbds;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key

typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<int> vi;
typedef long double ld;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;

const long long mod = 1000000007;

int main(){
    ios_base::sync_with_stdio(0); cin.tie(0);
    string s;
    cin>>s;
    int n=s.length();
    if((n&1)==0){
        s=s.substr(0,n-2);
        n=n-2;
    }
    else{
        s=s.substr(0,n-1);
        n-=1;
    }
    int ans=0;
    string a,b;
    while(ans==0){
        a=s.substr(0,n/2);
        b=s.substr(n/2,n/2);
        if(a==b)
            ans=1;
        else{
            n-=2;
        }
    }
    cout<<n<<endl;
    return 0;
}


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

void test(vector<int> &a, int k){
	bool dp[k+1];
	memset(dp, 0, sizeof(dp));
	int n = a.size();
	for(int j = 1; j <= k; j++){
		for(int i = 0; i < a.size(); i++){
			if(j >= a[i]){
				dp[j] = dp[j] || !dp[j-a[i]];
			}
		}
	}
	if(dp[k]) cout << "First" << endl;
	else cout << "Second" << endl;
	return;
}
 
int main(){ //no changes here
	int n, k;
	cin >> n >> k;
	vector<int> a(n);
	for(int i =0 ; i < n; i++){
		cin >> a[i];
	}
	test(a, k);
	return 0;
}

Measured memory_bytes: 3728
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  
  int A,B;
  cin >> A >> B;
  
  B*=2;
  
  if(B>=A){
    
    cout << '0' << endl;
  }
  
  else{
    
    cout << A-B << endl;
    
    
  }
}

Measured memory_bytes: 256
def is_prime(n):
    if n == 1:
        return False
    for i in range(2,int(n**0.5)+1):
        if n % i == 0:
            return False
    return True

x = int(input())

if (x == 2):
  print(x)
else:
  while((is_prime(x)!=True)):
    x += 1
  print(x)
  

Measured memory_bytes: 3064
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<list>
#include<set>
#include<string>
using namespace std;
int gcd(int a, int b) {
	int c = a % b;
	while (c != 0) {
		a = b;
		b = c;
		c = a % b;
	}
	return b;
}
struct UnionFind {
	vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

	UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
		for (int i = 0; i < N; i++) par[i] = i;
	}

	int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
		if (par[x] == x) return x;
		return par[x] = root(par[x]);
	}

	void unite(int x, int y) { // xとyの木を併合
		int rx = root(x); //xの根をrx
		int ry = root(y); //yの根をry
		if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
		par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
	}

	bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
		int rx = root(x);
		int ry = root(y);
		return rx == ry;
	}
};
typedef long long ll;

ll M = 1000000007;

vector<ll> fac(300001); //n!(mod M)
vector<ll> ifac(300001); //k!^{M-2} (mod M)

ll mpow(ll x, ll n) {
	ll ans = 1;
	while (n != 0) {
		if (n & 1) ans = ans * x % M;
		x = x * x % M;
		n = n >> 1;
	}
	return ans;
}
ll comb(ll a, ll b) {
	if (a == 0 && b == 0)return 1;
	if (a < b || a < 0)return 0;
	ll tmp = ifac[a - b] * ifac[b] % M;
	return tmp * fac[a] % M;
}
// mod. m での a の逆元 a^{-1} を計算する
long long modinv(long long a) {
	long long b = M, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= M;
	if (u < 0) u += M;
	return u;
}
vector<vector<ll>> mul(vector<vector<ll>> a, vector<vector<ll>> b, int n) {
	int i, j, k, t;
	vector<vector<ll>> c(n);
	for (i = 0; i < n; i++) {
		for (j = 0; j < n; j++) {
			t = 0;
			for (k = 0; k < n; k++)
				t = (t + a[i][k] * b[k][j] % M) % M;
			c[i].push_back(t);
		}
	}
	return c;
}

template< typename Monoid >
struct SegmentTree {

	int sz;
	vector< Monoid > seg;

	const Monoid M1;

	SegmentTree(int n, const Monoid &M1) : M1(M1) {
		sz = 1;
		while (sz < n) sz <<= 1;
		seg.assign(2 * sz, M1);
	}

	void set(int k, const Monoid &x) {
		seg[k + sz] = x;
	}

	void build() {
		for (int k = sz - 1; k > 0; k--) {
			seg[k] = f(seg[2 * k + 0], seg[2 * k + 1]);
		}
	}

	void update(int k, const Monoid &x) {
		k += sz;
		seg[k] = x;
		while (k >>= 1) {
			seg[k] = f(seg[2 * k + 0], seg[2 * k + 1]);
		}
	}

	Monoid query(int a, int b) {
		Monoid L = M1, R = M1;
		for (a += sz, b += sz; a < b; a >>= 1, b >>= 1) {
			if (a & 1) L = f(L, seg[a++]);
			if (b & 1) R = f(seg[--b], R);
		}
		return f(L, R);
	}

	Monoid value(const int &k) const {
		return seg[k + sz];
	}

	Monoid f(Monoid a, Monoid b) {
		return a + b;
	}
};

int main() {
	int n;
	cin >> n;
	cout << n * 800 - 200 * (n / 15) << endl;
}

Measured memory_bytes: 4992
process.stdin.resume();
process.stdin.setEncoding('utf8');
// Here your code !
process.stdin.on('data', function(chunk){
    var lines = chunk.toString().split("\n");
    var num = lines[0];
    var str = lines[1];

    var num_1 = 0;
    var num_2 = 0;

    for(var i= 0; i<str.length; i++){
        if(str[i] === "("){
            num_1 += 1;
        }else{
            num_1 -= 1;
        }

        if(num_1<0){
            num_1 ++; num_2 ++;

        }
    }
    
        var ary_1 = new Array(num_1); //対がない(の数
        var ary_2 = new Array(num_2); //対がない)の数
        //console.log(ary_1);
        //console.log(ary_2);
        
        ary_1.fill(")");
        ary_2.fill("(");

//対になっていない括弧を補足。前に"("、後に")"を付け足す
        var ansAry = ary_2.concat(str);
        //console.log(ansAry);
        ansAry = ansAry.concat(ary_1);
        //console.log(ansAry);

//配列を文字列に変換
        var ans = ansAry.join("");
        console.log(ans);
});


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

int main()
{
    int n;
    cin>>n;
    string s;
    set<string>st;
    for(int i=1;i<=n;i++)
    {
        cin>>s;
        st.insert(s);
    }
    cout<<st.size()<<endl;
}


Measured memory_bytes: 19116
#include<bits/stdc++.h>
using namespace std;
#define INF 100000000000
long long int dp[100005],arr[100005],n;
long long int solve(long long int idx)
{
	if(idx>n)
		return INF;
	if(idx==n)
		return 0;
	if(dp[idx]!=-1)
		return dp[idx];
	long long int i,j,k,ans=INF;
	for(i=idx+1;i<=(idx+2);i++)
    {
     j=abs(arr[i]-arr[idx]);
     //printf("%lld %lld\n",idx,j);
     k=solve(i);
     ans=min(ans,(j+k));
    }
    dp[idx]=ans;
    return dp[idx]; 
}
int main()
{
   long long int i,j,k,ans=0;
   scanf("%lld",&n);
   for(i=1;i<=n;i++)
   	dp[i]=-1;
   for(i=1;i<=n;i++)
   	scanf("%lld",&arr[i]);
   ans=solve(1);
   /*for(i=1;i<=n;i++)
   	printf("%lld ",dp[i]);
   printf("\n");*/
   printf("%lld\n",ans);
}

Measured memory_bytes: 6528
#include <iostream>
using namespace std;
typedef long long ll;

int main() {
  int n; cin >> n; ll a[n], sm=0, sm2=0, an=1e18;
  for(int i=0; i<n; i++) {cin >> a[i]; sm += a[i];}
  for(int i=0; i<n-1; i++) {
    sm2 += a[i];
    an = min(an, abs(sm-sm2*2));
  }
  cout << an << endl;
}

Measured memory_bytes: 1792
#include<iostream>

using namespace std;

template <class T> bool update_min(T &a, const T &b) { a = min(a, b); return 0;}

int main(){
  int a=0, b=0, c=0;
  update_min(a, b);
  cin >> a >> b >> c;
  if(a > b)swap(a, b);
  if(a<= c && c <= b){
    cout << "Yes" <<endl;
  }
  else cout << "No"<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(){
	
	int a=0,b=0,c=0,d=0,e=0,k=0,tes=0;

	scanf("%d\n%d\n%d\n%d\n%d\n%d",&a,&b,&c,&d,&e,&k);

	if(b - a > k){
		tes = 1;
	}
	if(c - a > k){
		tes = 1;
	}
	if(d - a > k){
		tes = 1;
	}
	if(e - a > k){
		tes = 1;
	}
	if(c - b > k){
		tes = 1;
	}
	if(d - b > k){
		tes = 1;
	}
	if(e - b > k){
		tes = 1;
	}
	if(d - c > k){
		tes = 1;
	}
	if(e - c > k){
		tes = 1;
	}
	if(e - d > k){
		tes = 1;
	}

	if(tes == 0){
		printf("Yay!\n");
	}else{
		printf(":(\n");
	}
	

	return 0; 
}

Measured memory_bytes: 128
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner reader = new Scanner(System.in);
		int A = reader.nextInt();
		int B = reader.nextInt();
		int gap = B - A;
		int ans = -A;
		for (int i = 1; i < gap; i++) {
			ans += i;
		}

		System.out.print(ans);
		reader.close();
	}
}


Measured memory_bytes: 21844
from __future__ import division
import sys
if sys.version_info[0]>=3: raw_input=input

X=4
Y=2
i=0
m={}
prev={}
v=[]
for i in range(X*Y): v.append(str(i))
m[''.join(v)]=[0,0]
prev[''.join(v)]=[''.join(v),None]
q=[v]
while len(q)>0:
	v=q.pop(0)
	coor=m[''.join(v)][0]
	x=coor%X
	y=coor//X
	depth=m[''.join(v)][1]
	nextstr=''.join(v)
	if 0<x:
		v[coor],v[coor-1]=v[coor-1],v[coor]
		if ''.join(v) not in m:
			m[''.join(v)]=[coor-1,depth+1]
			q.append(v[:])
			prev[''.join(v)]=[nextstr,'R']
		v[coor],v[coor-1]=v[coor-1],v[coor]
	if x<X-1:
		v[coor],v[coor+1]=v[coor+1],v[coor]
		if ''.join(v) not in m:
			m[''.join(v)]=[coor+1,depth+1]
			q.append(v[:])
			prev[''.join(v)]=[nextstr,'L']
		v[coor],v[coor+1]=v[coor+1],v[coor]
	if 0<y:
		v[coor],v[coor-X]=v[coor-X],v[coor]
		if ''.join(v) not in m:
			m[''.join(v)]=[coor-X,depth+1]
			q.append(v[:])
			prev[''.join(v)]=[nextstr,'D']
		v[coor],v[coor-X]=v[coor-X],v[coor]
	if y<Y-1:
		v[coor],v[coor+X]=v[coor+X],v[coor]
		if ''.join(v) not in m:
			m[''.join(v)]=[coor+X,depth+1]
			q.append(v[:])
			prev[''.join(v)]=[nextstr,'U']
		v[coor],v[coor+X]=v[coor+X],v[coor]

try:
	while True:
		v=raw_input().split()
		print(m[''.join(v)][1])
except EOFError:
	pass

Measured memory_bytes: 12568
// AOJ 1301: Malfatti Circles
// 2018.1.26 bal4u@uu

#include <stdio.h>
#include <math.h>

#define ABS(a)  ((a)>=0?(a):-(a))

double ra, rb, rc;

//#define getchar_unlocked()  getchar()
int in()
{
	int n = 0;
	int c = getchar_unlocked();
	if (c == '-') {
		c = getchar_unlocked();
		do n = (n<<3)+(n<<1) + (c & 0xf), c = getchar_unlocked();
		while (c >= '0');
		return -n;
	}
	do n = (n<<3)+(n<<1) + (c & 0xf), c = getchar_unlocked();
	while (c >= '0');
	return n;
}

double cross(int xa, int ya, int xb, int yb){ return xa*yb - ya*xb; }

void malfattiCircle(int xa, int ya, int xb, int yb, int xc, int yc)
{
	int i;
	double a, b, c, x, y, z, r;
	double lo, hi, t1, t2, t3;

	a = hypot(xb-xc, yb-yc), b = hypot(xa-xc, ya-yc), c = hypot(xa-xb, ya-yb);
	r = ABS(cross(xb-xa, yb-ya, xc-xa, yc-ya))/(a+b+c);
    x = (-a+b+c)/(2*r), y = (a-b+c)/(2*r), z = (a+b-c)/(2*r);
	lo = 0, hi = r;
	for (i = 0; i < 100; i++) {
		ra = (lo + hi) / 2;
		t1 = y*y, t2 = x*y*ra - c*y - 2*ra, t3 = (c-x*ra)*(c-x*ra);
		rb = (-t2 - sqrt(t2*t2 - t1*t3))/t1;
		t1 = z*z, t2 = x*z*ra - b*z - 2*ra, t3 = (b-x*ra)*(b-x*ra);
		rc = (-t2 - sqrt(t2*t2 - t1*t3))/t1;
		if (2*sqrt(rb*rc) + y*rb + z*rc > a) lo = ra; else hi = ra;
	}
}
 
int main()
{
	int x1, y1, x2, y2, x3, y3;
	
	while (1) {
		x1 = in(), y1 = in(), x2 = in(), y2 = in(), x3 = in(), y3 = in();
		if (!(x1|y1|x2|y2|x3|y3)) break;
		malfattiCircle(x1, y1, x2, y2, x3, y3);
		printf("%.6lf %.6lf %.6lf\n", ra, rb, rc);
	}
	return 0;
}


Measured memory_bytes: 2024
//(UNCOMMENT WHEN SUBMITTING)
//#pragma GCC optimize("O3")

//(UNCOMMENT WHEN HAVING LOTS OF RECURSIONS)
// #pragma comment(linker, "/stack:200000000")
//(UNCOMMENT WHEN NEEDED)
// #pragma GCC optimize("Ofast,unroll-loops,no-stack-protector,fast-math")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#include <bits/stdc++.h>

// clang-format off
#define range(i) for (int _ = 0; _ < i; _++)
#define vprnt(v) for (auto vi : v) cout << vi << " "; cout << endl;
#define fastio() ios::sync_with_stdio(false); cin.tie(0)
#define ll long long
#define all(x) (x).begin(), (x).end()
using namespace ::std;
int nxt() {int x;cin >> x;return x;}
ll nxtll() {ll x;cin >> x;return x;}
// clang-format on

int main() {
    fastio();
    int X = nxt();

    cout << (X >= 30 ? "Yes" : "No") << endl;

    return 0;
}


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

int main() {
	int w, h, sx, sy;
	while (cin >> w >> h , w != 0 || h != 0) {
		vector<string> field = vector<string>(h);

		for (int i = 0; i < h; i++) {
			cin >> field[i];
		}
		for (int i = 0; i < h; i++) {
			for (int j = 0; j < w; j++) {
				if (field[i][j] == '@') {
					sx = j;
					sy = i;
				}
			}
		}

		int ans = 0;
		auto visited = vector<vector<bool>>(h, vector<bool>(w, false));
		queue<int> q = queue<int>();
		q.push(sy * 100 + sx);
		while (!q.empty()) {
			int x = q.front() % 100, y = q.front() / 100;
			q.pop();
			if (visited[y][x]) continue;
			ans++;
			visited[y][x] = true;
			int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};
			for (int i = 0; i < 4; i++) {
				int nx = x + dx[i], ny = y + dy[i];
				if (nx < 0 || w <= nx || ny < 0 || h <= ny) continue;
				if (field[ny][nx] == '.' && !visited[ny][nx])
					q.push(ny * 100 + nx);
			}
		}

		cout << ans << endl;
	}
}

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

#define FAST_INP  ios_base::sync_with_stdio(false);cin.tie(NULL)


int main()  
{ 
    FAST_INP;
    int a,b,c,k;
    cin >> a >> b >> c >> k;
    int ok=0;
    while(k--){
    	// c > b > a
    	if(b<=a) b*=2;
    	else if(c<=b) c*=2;
	}
	if(b>a&&c>b) cout << "Yes\n";
	else cout <<"No\n";
    return 0;
} 

Measured memory_bytes: 3632
def shortest_path_faster_algorithm(E, start):
    # ベルマンフォードの更新があるところだけ更新する感じのやつ
    # O(VE) だが実用上高速
    # E は隣接リスト
    # 検証: http://judge.u-aizu.ac.jp/onlinejudge/review.jsp?rid=4005805#1
    from collections import deque
    inf = float("inf")  # 10**18 は良くない
    N = len(E)
    q = deque([start])  # スタックにするとコーナーケースがあるっぽい
    distance = [inf] * N;  distance[start] = 0
    in_q = [0] * N;        in_q[start] = True
    times = [0] * N;       times[start] = 1
    while q:
        v = q.popleft()
        in_q[v] = False
        dist_v = distance[v]
        for u, cost in E[v]:
            new_dist_u = dist_v + cost
            if distance[u] > new_dist_u:
                times[u] += 1
                if times[u] >= N:  # 負閉路検出
                    print("NEGATIVE CYCLE"); exit()
                    distance[u] = -inf
                else:
                    distance[u] = new_dist_u
                if not in_q[u]:
                    in_q[u] = True
                    q.append(u)
    return distance

import sys
def main():
    N, M, r = map(int, sys.stdin.readline().split())
    E = [[] for _ in range(N)]
    for s, t, d in zip(*[iter(map(int, sys.stdin.read().split()))]*3):
        E[s].append((t, d))
    distance = shortest_path_faster_algorithm(E, r)
    for d in distance:
        if d == float("inf"):
            print("INF")
        else:
            print(d)

main()



Measured memory_bytes: 6560
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import sys

def dot_z(v1,v2):
  if v1[0]*v2[1]-v1[1]*v2[0] > 0:
    return 1
  else:
    return -1

def diff_p(p1,p2):
  return [ p2[0]-p1[0], p2[1]-p1[1] ]

for s in sys.stdin:
  d = map(float , s.split() )
  a = [d[0],d[1]]
  b = [d[2],d[3]]
  c = [d[4],d[5]]
  p = [d[6],d[7]]
  e1 = dot_z(diff_p(a,b),diff_p(b,p))
  e2 = dot_z(diff_p(b,c),diff_p(c,p))
  e3 = dot_z(diff_p(c,a),diff_p(a,p))
  if abs(e1+e2+e3) == 3 :
    print "YES"
  else:
    print "NO"

  

Measured memory_bytes: 4264
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <bitset>
#include <cmath>
#include <string>
#define FI first
#define SE second
#define VE vector<int>
#define PB push_back
#define PA pair<int,int>
#define MA make_pair
#define LL long long
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ROF(i,a,b) for(int i=b-1;i>=a;i--)
#define YES(i) cout<<(i?"YES":"NO")<<endl
#define Yes(i) cout<<(i?"Yes":"No")<<endl
using namespace std;
//
const int INF=1e9+7;
//
int GCD(int A,int B){
  if(B==0){
    return A;
  }else{
    return GCD(B,A%B);
  }
}
int main(){
  int X,Y;
  cin>>X>>Y;
  cout<<GCD(X,Y)<<endl;
  return 0;
} 


Measured memory_bytes: 3080
#include <stdio.h>

int main(void)          
{
	int W, H, x, y, r;
	scanf("%d%d%d%d%d", &W, &H, &x, &y, &r);
	if (x - r<0 || x + r>W || y - r<0 || y + r>H) 
	{
		printf("No\n");
	}
	else 
	{
		printf("Yes\n");
	}
	return 0;
}

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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

void Main() {
    ll N, K; cin >> N >> K;
    map<ll, ll> x;
    rep(i, N){
        ll a, b;
        cin >> a >> b;
        if (x.find(a) != x.end()){
            x[a] += b;
        } else {
            x[a] = b;
        }
    }
    for (auto y: x){
        if (K <= y.second){
            cout << y.first << endl;
            break;
        } else {
            K -= y.second;
        }
    }
}

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


Measured memory_bytes: 4224
n = int(input())
s1 = input()
s2 = input()
mod = 1000000007
dp = [0]*n
dp[0] = 3 if s1[0] == s2[0] else 6
for i in range(1,n):
    if s1[i] == s1[i-1]: dp[i] = dp[i-1]
    elif s1[i-1] == s2[i-1]: dp[i] = dp[i-1]*2%mod
    elif s1[i] == s2[i]: dp[i] = dp[i-1]
    else: dp[i] = dp[i-1]*3%mod
print(dp[n-1])

Measured memory_bytes: 3188
#include<stdio.h>
int main()
{
  int a,b=1,c;
  while( 1 ){
    scanf( "%d%d\n",&a,&b );
    if( a==0 && b==0 ){break;}
    else if(a>b)printf( "%d %d\n",b,a );
    else printf( "%d %d\n",a,b );
    
  }
  return 0;
}


Measured memory_bytes: 2032
N = int(input())
pri_cnt = {}
n = N
i = 2

while i ** 2 <= N:
  while n % i == 0:
    if i not in pri_cnt:
      pri_cnt[i] = 1
    else:
      pri_cnt[i] += 1
    n = n / i
  if (i == 2):
    i += 1
  else:
    i += 2

if n > 1:
  pri_cnt[int(n)] = 1

ans = 0
for pri, cnt in pri_cnt.items():
  count = 1
  remain = cnt
  while remain >= count:
    ans += 1
    remain -= count
    count += 1
print(ans)

Measured memory_bytes: 9176
using System;

class MyClass
{
    public static void Main(string[] args)
    {
        string str = "";
        string str0;
        while ((str0 = Console.ReadLine()) != null)
        {
            str += str0;
        }
        str = str.ToLower();
        string abc = "abcdefghijklmnopqrstuvwxyz";
        for (int i = 0; i < 26; i++)
        {
            Console.WriteLine(abc[i] + " : " + (str.Length - str.Replace(abc[i].ToString(), "").Length));
        }
    }
}


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

int main() {
  long long X,ans=0;
  cin >> X;
  
  while(X >= 500){
    X -= 500;
    ans += 1000;
  }
  while(X >= 5){
    X -= 5;
    ans += 5;
  }
  
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>

static int cmp(const void *a, const void *b);

int main(int argc, char *argv[])
{
	int i, N, list[100], n = 0;
	scanf("%d", &N);
	for ( i = 0; i < N; i++ ){
		scanf("%d", &list[i]);
		n += list[i];
	}
	qsort(list, N, sizeof(int), cmp);
	if ( n % 10 ){
		printf("%d\n", n);
		return 0;
	}
	for ( i = 0; i < N; i++ ){
		if ( (n-list[i]) % 10 ){
			printf("%d\n", n-list[i]);
			return 0;
		}
	}
	printf("0\n");
	return 0;
}

static int cmp(const void *a, const void *b)
{
	return *((int *)a) - *((int *)b);
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
 
#define si(x) scanf("%d",&x)
#define sf(x) scanf("%lf",&x)
#define sl(x) scanf("%lld",&x)
#define pr(x) printf("%d\n",x)
#define prll(x) printf("%lld\n",x)
 
#define ll long long int
#define ull unsigned long long int
#define F first
#define S second
 
#define rep(i,x,y) for(int i=x;i<y;i++)
#define ii pair<int,int> 
#define pll pair<ll,ll> 
#define vi vector<int> 
#define vvi vector< vi > 
#define vl vector<long long int>
#define vvl vector< vl >
#define vii vector< ii >
#define vvii vector< vii >
#define priority_queue pq;
#define sz(a) ll((a).size()) 
#define pb push_back 
#define mp make_pair
 
#define ROUNDOFFINT(d) d = (int)((double)d + 0.5)
#define SET(a,b) memset(a,b,sizeof(a))
#define all(c) (c).begin(),(c).end() 
#define tr(i,c) 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())
#define ison(x,i) (((x) >> (i)) & 1)	//checks if ith bit is on
#define set0(x,i) (x & ~(1 << i))		//set ith bit in x to be zero
#define clr(a) memset(a,0,sizeof(a))
 
#define MOD 1000000007
#define INF 4000000000000000000
#define MAX 100000+5
using namespace std;



int main()
{
	int c5=0,c7=0,p;
	rep(i,0,3)
	{
		si(p);
		if(p==5)
			c5++;
		else if(p==7)
			c7++;
	}
	if(c5==2 && c7==1)
		printf("YES");
	else
		printf("NO");
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long int 
#define ld double
#define mp make_pair
#define pb push_back
#define mod 1000000007
#define ff first
#define ss second
#define pll pair <ll,ll>
#define nl "\n"
 
int main()
{
	ios_base::sync_with_stdio(false);
	ll n,x,t;
	cin>>n>>x>>t;
	ll ans = (n/x)*t;
	if(n%x)
		ans += t;
	cout<<ans<<nl;
	return 0;
}

Measured memory_bytes: 3600
import sys
input=sys.stdin.readline


def solve():
    S, T = input(), input()
    q = int(input())

    ls, lt = len(S), len(T)
    acs, act = [0]*(ls+1), [0]*(lt+1)

    for i in range(1, ls+1):
        acs[i] = acs[i-1] + (S[i-1]=="A")
    for i in range(1, lt+1):
        act[i] = act[i-1] + (T[i-1]=="A")

    for _ in range(q):
        a, b, c, d = map(int, input().split())
        print("YES" if (acs[b]-acs[a-1]+b-a+1)%3==(act[d]-act[c-1]+d-c+1)%3 else "NO")


if __name__ == "__main__":
    solve()


Measured memory_bytes: 12028