akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,a,b) for(ll i=ll(a);i<ll(b);i++)
#define irep(i,a,b) for(ll i=ll(a);i>=ll(b);i--)
#define pb push_back
#define mp make_pair
#define F .first
#define S .second 
using ll=long long;
using ld=long double;
using namespace std;
const ll mod=1e9+7;

int main(){
  ll k,s,x=0,ans=0;
  cin>>k>>s;
  rep(i,0,k+1){
    rep(j,0,k+1){
      if(s-i-j>=0&&s-i-j<=k)ans++;
    }
  }
  cout<<ans;
}




Measured memory_bytes: 256
from collections import Counter

N = int(input())
S = input()
cnt = Counter(S)

ans = cnt['R']*cnt['G']*cnt['B']
#まずansに要請１を満たす(i, j, k)の組の数を入れておき，ここから，要請２を満たさないものを除いていく。

for i in range(N-2):
    for j in range(i+1, N-1):
        k = j + (j - i)
        #kは　j - i = k - j を満たす。ただし，（i, j, k）が要請１を満たしているとは限らない。
        if k < N:
            if S[i] != S[j] and S[j] != S[k] and S[k] != S[i]:
                ans -= 1

print(ans)

Measured memory_bytes: 9360
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
typedef long long ll;
#define pb push_back
#define mii map <int, int>
#define mll map <ll, ll>
#define pii pair <int, int>
#define pll pair <ll, ll>
#define vi vector <int>
#define vd vector <double>
#define vll vector <ll>
#define fi first
#define se second
#define si set <int>
#define sll set <ll>
#define spii set <pii>
#define vs vector <string>
#define vpii vector <pair <int,int> >
#define vpll vector <pair <long long,long long> >
#define vvi vector <vector <int> >
#define vvpii vector <vector <pii > >
#define vvll vector <vll>
#define vsi vector <si>
#define forn(i, n) for (int i = 0; i < (n); i++)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define for1(i, n) for (int i = 1; i < (n); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(),(x).rend()


using namespace std;
const ll INFLL = 1e18;
const int MAXN = 1e6+100;
const ll INF = 1e9;
const ll mod1=1e9+7;
const ll mod2=2e9+11;
int ans[500][500];
int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
#ifdef LOCAL
    freopen("a.in","r",stdin);
#endif
    int H,W,w,h;
    cin>>H>>W>>h>>w;
    if (H%h==0&&W%w==0)
    {
        cout<<"No";
        return 0;
    }
    cout<<"Yes\n";
    for (int i=0;i<H;i++)
    {
        for (int j=0;j<W;j++)
            ans[i][j]=-1000;
    }
    for (int i = 0; i < H; i += h) {
        for (int j = 0; j < W; j += w)
            ans[i][j] = 1000*(h * w-1)-1;
    }
//    } else
//    {
//        for (int i = 0; i < W; i += w) {
//            for (int j = 0; j < H; j += h)
//                ans[j][i] = h * w - 2;
//        }
//    }
    rep(i,H) {
        rep(j, W) {
            cout << ans[i][j] << " ";
        }
        cout<<'\n';
    }
}


Measured memory_bytes: 2688
X = int(input())
def primes():
    """
    素数のジェネレータ
    """
    d = {}
    q = 2
    while True:
        if q not in d:
            yield q
            d[q * q] = [q]
        else:
            for p in d[q]:
                d.setdefault(p + q, []).append(p)
            del d[q]
        q += 1

for p in primes():
    if p >= X:
        print(p)
        break

Measured memory_bytes: 47596
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define VSORT(v) sort(v.begin(), v.end())
#define VRSORT(v) sort(v.rbegin(), v.rend())
#define ll long long
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;
typedef vector<unsigned int>vec;
typedef vector<vec> mat;
typedef vector<vector<int>> Graph;

const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const int INF = 1000000000;
const ll LINF = 1000000000000000000;//1e18
const ll  MOD = 1000000007;
const double PI = acos(-1.0);
const double EPS = 1e-10;

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; }
template<class T> inline void add(T &a, T b){a = ((a+b) % MOD + MOD) % MOD;};


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, D;
    cin >> N >> D;
    vector<vector<int>> X(N,vector<int>(D));
    REP(i,N) REP(j,D) cin >> X[i][j];
    int ans = 0;
    REP(i,N){
        for(int j=i+1;j<N;j++){
            int dist = 0;
            REP(k,D) dist += abs(X[i][k] - X[j][k]) * abs(X[i][k] - X[j][k]);
            if((int)sqrt(dist) == sqrt(dist)) ans++;
        }
    }
    cout << ans << endl;

}


Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#define INF (1<<21)
using namespace std;

int C[20], T[50001];
int n, m;

int getTheNumberOfCoin(){
	for (int j=0;j<=n;j++){
		T[j] = INF;
	}
	T[0] = 0;
	for(int i=0;i<=m+1;i++){
		for(int j=C[i];j<=n;j++){
			T[j] = min(T[j], T[j-C[i]] + 1);
		}
	}

	return T[n];
}

int main(){
	scanf("%d %d", &n, &m);
	for(int i=0;i<m;i++){
		scanf("%d", &C[i]);
	}

	int ans = getTheNumberOfCoin();

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

Measured memory_bytes: 2900
#include <bits/stdc++.h>
#define all(v) (v).begin(), (v).end()
typedef long long int lint;
using namespace std;

//ただの辺
struct edge {
    using lint = long long int;
    int to;
    lint cost;
    //引数一つの時は距離1
    edge(int t, lint c = 1) : to(t), cost(c) {
    }
};

int main() {
    int n;
    cin >> n;
    vector<vector<edge>> g(n);
    for (int i = 0; i < n - 1; i++) {
        int a, b;
        cin >> a >> b;
        a--, b--;
        g[a].push_back(edge(b));
        g[b].push_back(edge(a));
    }
    lint ans = 0;
    vector<int> c(n);
    for (int i = 0; i < n; i++) {
        cin >> c[i];
        ans += c[i];
    }
    sort(all(c));
    ans -= c[n - 1];
    queue<int> q;
    vector<int> deg(n);
    for (int i = 0; i < n; i++) {
        deg[i] = g[i].size();
        if (deg[i] == 1) {
            q.push(i);
        }
    }
    vector<int> w(n);
    auto itr = c.begin();
    while (!q.empty()) {
        int now = q.front();
        q.pop();
        w[now] = (*itr);
        itr++;
        for (int i = 0; i < g[now].size(); i++) {
            int next = g[now][i].to;
            deg[next]--;
            if (deg[next] == 1) {
                q.push(next);
            }
        }
    }
    cout << ans << endl;
    for (int i = 0; i < n; i++) {
        cout << w[i] << " ";
    }
    cout << endl;
}

Measured memory_bytes: 1152
# -*- coding: utf-8 -*-
# 整数の入力
#a = int(input())
# スペース区切りの整数の入力
#b, c = map(int, input().split())
# 文字列の入力
#s = input()
# 出力
#print("{} {}".format(a+b+c, s))

import math

N = int(input())
for i in range(0, N):
    t, a = map(int, input().split())
    if i == 0:
        tt = t
        aa = a
        ratio = 1
    else:
        if tt % t == 0:
            rt = tt // t
        else:
            rt = tt // t + 1
        if aa % a == 0:
            ra = aa // a
        else:
            ra = aa // a + 1

        ratio = max(rt, ra)

        tt = t * ratio
        aa = a * ratio
    # print("{} {} {} {} {}".format(t, a, tt, aa, ratio))

print("{}".format(tt + aa))


Measured memory_bytes: 3060
import java.util.*

//package atcoder// TODO: ←消す

fun main(args: Array<String>) = ABC161D2.main()

object ABC161D2 {
    fun log(message: Any?) {
        println(message)// TODO: ←消す
    }

    fun main() {
        val K = readInt()

        val seq = generateSequence { LunSequence.next() }
        val ans = seq.drop(K - 1).first()
        println(ans)
    }

    object LunSequence {
        private val queue: Queue<Long> = ArrayDeque()

        init {
            queue.addAll(listOf(1, 2, 3, 4, 5, 6, 7, 8, 9))
        }

        fun next(): Long {
            val next = queue.poll()!!
            val bottom = next % 10

            val second = next * 10 + bottom
            val first = if (bottom != 0L) second - 1 else null
            val third = if (bottom != 9L) second + 1 else null

            val validNums = listOf(first, second, third)
                .filterNotNull()
            queue.addAll(validNums)

            return next
        }
    }
    /*####################################################################################*/

    fun readInt() = readLine()!!.toInt()
}

Measured memory_bytes: 52532
import numpy as np
n = input()
MAX_NUM = 55555
is_prime = [True] * MAX_NUM
is_prime[0] = False
is_prime[1] = False
primes = []
for num in range(MAX_NUM):
    if is_prime[num]:
        primes.append(num)
        for j in range(2*num, MAX_NUM, num):
            is_prime[j] = False
seq = filter(lambda x: x % 10 == 1, primes)
print " ".join(map(str, seq[:n]))

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

using ll=long long;
#define int ll

#define FOR(i,a,b) for(int i=int(a);i<int(b);i++)
#define REP(i,b) FOR(i,0,b)
#define MP make_pair
#define PB push_back
#define ALL(x) x.begin(),x.end()
#define REACH cerr<<"reached line "<<__LINE__<<endl
#define DMP(x) cerr<<"line "<<__LINE__<<" "<<#x<<":"<<x<<endl
#define ZERO(x) memset(x,0,sizeof(x))

using pi=pair<int,int>;
using vi=vector<int>;
using ld=long double;

template<class T,class U>
ostream& operator<<(ostream& os,const pair<T,U>& p){
	os<<"("<<p.first<<","<<p.second<<")";
	return os;
}

template<class T>
ostream& operator <<(ostream& os,const vector<T>& v){
	os<<"[";
	REP(i,(int)v.size()){
		if(i)os<<",";
		os<<v[i];
	}
	os<<"]";
	return os;
}

int read(){
	int i;
	scanf("%lld",&i);
	return i;
}

void printSpace(){
	printf(" ");
}

void printEoln(){
	printf("\n");
}

void print(int x,int suc=1){
	printf("%lld",x);
	if(suc==1)
		printEoln();
	if(suc==2)
		printSpace();
}

string readString(){
	static char buf[3341919];
	scanf("%s",buf);
	return string(buf);
}

char* readCharArray(){
	static char buf[3341919];
	static int bufUsed=0;
	char* ret=buf+bufUsed;
	scanf("%s",ret);
	bufUsed+=strlen(ret)+1;
	return ret;
}

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

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

template<class T>
T Sq(const T& t){
	return t*t;
}

const int inf=LLONG_MAX/3;

void Yes(){
	cout<<"Yes"<<endl;
	exit(0);	
}

void No(){
	cout<<"No"<<endl;
	exit(0);	
}

signed main(){
	int n=read();
	vi a(n);REP(i,n)a[i]=read();
	if(a==vi(n,n-1))
		Yes();
	int k=*max_element(ALL(a));
	int solo=0,comp=0;
	for(auto x:a)
		if(x==k-1)solo++;
		else if(x==k)comp++;
		else No();
	if(solo>=k)No();
	if((k-solo)*2<=comp)Yes();
	else No();
}

Measured memory_bytes: 1792
#include<iostream>

using namespace std;

int main() {
  int a,b;
  cin >> a >> b;
  if( a < b ){
    cout << "a" << " < " << "b" << endl;
  } else if ( a > b ){
    cout << "a" << " > " << "b" << endl;
  } else { 
    cout << "a" << " == " << "b" << endl;
  }

    return 0;
}



Measured memory_bytes: 3084
#include <bits/stdc++.h>
using namespace std;
#define all(a)a.begin(),a.end()
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
const int mod= int(1e9)+7;
//const int mod=998244353;
using P = pair<int,int>;
using Pll = pair<ll,ll>;
using ld=long double;
using V=vector<int>;
using Vl=vector<ll>;
using VV=vector<vector<int>>;
using VVl=vector<vector<ll>>;

int main(){
    int n;cin >>n;
    V cnt(n,0);
    for (int i = 0; i < n-1; ++i) {
        int a;cin>>a;
        a--;
        cnt[a]++;
    }
    for (int i = 0; i < n; ++i) {
        cout <<cnt[i]<<endl;
    }
}



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

int main(){
    int A,B,M,min_a=1e7,min_b=1e7;
    cin >>A>>B>>M;
    int a[A],b[B],c[M],x[M],y[M],ans=1e7,tem=0;
    rep(i,A){
        cin >>a[i];
        if(min_a>a[i])min_a=a[i];}
    rep(i,B){
        cin >>b[i];
        if(min_b>b[i])min_b=b[i];}
    rep(i,M){
        cin >>x[i]>>y[i]>>c[i];}
    rep(i,M){
        tem=a[x[i]-1]+b[y[i]-1]-c[i];
        if(tem<ans)ans=tem;
    }
    cout << min(ans,min_a+min_b)<<endl;
    return 0;
}

Measured memory_bytes: 2176
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef map<int,int> mii;
typedef map<ll,ll> mll;
typedef vector<pii> vii;
typedef vector<pll> vll;
#define fi first
#define se second
#define pi 3.141592653589793
#define mod 998244353
#define pb push_back
#define all(v) v.begin(),v.end()
#define tc int t;cin>>t;while(t--)
#define pqmax priority_queue<int>
#define pqmin priority_queue<int,vi,greater<int>>
#define fast_io ios_base::sync_with_stdio(0), cin.tie(NULL)
#define tc_g int tt;cin>>tt;for(int ti=1;ti<=tt;ti++)
#define case_g "Case #"<<ti<<": "
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
typedef tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_multiset;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
typedef tree<int, int, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_map;
using namespace std;
int main() {
    ll a, b, c, k;
    cin >> a >> b >> c >> k;
    if(k <= a)
        cout << k << endl;
    else if (k > a && k <= (b + a)){
        cout << a << endl;
    }
    else if(k > (a + b)){
        cout << (a - (k - (a + b))) << endl;
    }
}


Measured memory_bytes: 3624
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<iostream>
#include<queue>
#include<vector>
#include<bitset>
#include<math.h>
#include <string.h>
using namespace std;
#define INF 11000
#define MOD 1000000007
typedef long long ll;
typedef pair<int,int> P;

ll dp[110][10],mul[10][2],s[10];

int main(){
    mul[1][0]=1; mul[1][1]=1; s[1]=2; s[0]=1;
    for(int i=2;i<=8;i++){
        mul[i][0]=s[i-1];
        mul[i][1]=mul[i-1][0];
        s[i]=mul[i][0]+mul[i][1];
    }
    int H,W,K;
    cin>>H>>W>>K;
    K--;
    dp[0][0]=1;
    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            if(dp[i][j]==0) continue;
            if(j==0){
                dp[i+1][j]+=dp[i][j]*s[max(0,W-2)];
                dp[i+1][j+1]+=dp[i][j]*s[max(W-3,0)];

            }else if(j==W-1){
                dp[i+1][j]+=dp[i][j]*s[max(0,W-2)];
                dp[i+1][j-1]+=dp[i][j]*s[max(W-3,0)];
            }else{
                dp[i+1][j]+=dp[i][j]*s[max(0,j-1)]*s[max(0,W-j-2)];
                dp[i+1][j+1]+=dp[i][j]*s[max(0,j-1)]*s[max(0,W-j-3)];
                dp[i+1][j-1]+=dp[i][j]*s[max(0,j-2)]*s[max(0,W-j-2)];
            }
            dp[i+1][j]%=MOD;
            dp[i+1][max(j-1,0)]%=MOD;
            dp[i+1][max(W-1,j+1)]%=MOD;
        }
    }
    cout<<dp[H][K]<<endl;
}



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

public class Main {
    public static final Scanner in = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
    public static final PrintStream out = System.out;
    public static final PrintStream err = System.err;

    public static void main(String[] args) {
        int N = in.nextInt();
        int[] P = new int[N];
        for (int i = 0; i < N; i++) {
            P[i] = in.nextInt();
        }
        
        int err = 0;
        for (int i = 0; i < N; i++) {
            if (P[i] != i + 1) {
                err++;
            }
        }

        out.println(err == 0 || err == 2 ? "YES" : "NO");
    }
}


Measured memory_bytes: 21844
import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
from itertools import product
def main():
    h, w, k = map(int, input().split())
    gg = []
    for _ in range(h):
        row = [1 if c == '#' else 0 for c in list(input())]
        gg.extend(row)
    row_pro = tuple(product((0, 1), repeat=h))
    col_pro = tuple(product((0, 1), repeat=w))
    pat = tuple(product(row_pro, col_pro))
    r = 0
    for pate in pat:
        t0 = 0
        for i0, p0 in enumerate(pate[0]):
            for i1, p1 in enumerate(pate[1]):
                if p0 and p1:
                    t0 += gg[i0*w + i1]
        r += t0 == k
    print(r)

if __name__ == '__main__':
    main()


Measured memory_bytes: 9168
#include <bits/stdc++.h>
#define rep(i,k,n) for(int i=k;i<n;++i)
#define repe(i,k,n) for(int i=k;i<=n;++i)

using namespace std;
int a[5][5];
int mark[5][5];

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

    repe(i,1,3){
        repe(j,1,3){
            cin >> a[i][j];
        }
    }
    int n;
    cin >> n;
    int b;
    for (int x=0;x<n;++x){
        cin >> b;



        for (int x=1;x<=3;++x){
            for (int y=1;y<=3;++y){
                if (a[x][y] == b){
                    mark[x][y] =1;
                }

            }
        }
    }
    int ok =false;
    repe(x,1,3)
    {
        if (mark[x][3] and mark[x][1] and mark[x][2]){
            ok = true;
        }
    }
    repe(y,1,3)
    {
        if (mark[1][y] and mark [2][y] and mark[3][y]){
            ok = true;
        }
    }
    if (mark[1][1] and mark [2][2] and mark[3][3]) ok =true;
    if (mark[1][3] and mark [2][2] and mark[3][1]) ok =true;
    if (ok) cout << "Yes";
    else cout << "No";

    return 0;
}


Measured memory_bytes: 3636
#include <iostream>
#include <algorithm>
using namespace std;
int main(){
    int A;
    int B;
    int C;
    cin >> A >> B >> C;
    if((A + B == 10 || B + C == 10 || C + A == 10) && (A + B == 12 || B + C == 12 || C + A == 12) && A + B + C == 17){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long int ll;
#define pb push_back
typedef pair<ll,ll> pp;

ll mod = 1e9+7;
ll INF = 1e15;

ll powm(ll a , ll b , ll mod)
{
  ll res = 1;
  while(b)
  {
    if(b & 1)
    res = (res *a)%mod;
    a = (a*a)%mod;
    b>>1;
  }
  return res;
}
ll gcd(ll a , ll b);
ll power(ll x , ll y , ll m);

ll modInverse(ll a , ll m)
{
  ll g = gcd(a,m);
  if(g != 1)
  return 1;
  else
  return power(a,m-2,m);

}

ll power(ll x , ll y , ll m)
{
  if(y == 0)
  return 1;
  ll p = power(x , y/2 , m)%m;
  p = (p*p)%m;

  return (y%2 == 0) ? p : (x *p) % m;
}

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





void solve()
{
  ll n,m;
  cin>>n>>m;
  ll h[n+1];
  for(ll i = 1;i<=n;i++)
  cin>>h[i];

  vector<ll>v[n+1];

  for(ll i = 0,a,b;i<m;i++)
  {
    cin>>a>>b;
    v[a].pb(h[b]);
    v[b].pb(h[a]);

  }
  // cout<<"hey\n";

  for(ll i = 1;i<=n;i++)
  {
    sort(v[i].begin(),v[i].end());
    reverse(v[i].begin(),v[i].end());
  }
  ll ans = 0;
  // cout<<"noe\n";

  for(ll i = 1;i<=n;i++)
  {
    if(v[i].size() == 0)
    ans++;
    else
    {if(h[i] > v[i][0])
    ans++;}
  }
  cout<<ans<<"\n";


}



int main()
{
  int tc;
  // cin>>tc;
  tc = 1;
  while(tc--)
  {
    solve();
  }
}


Measured memory_bytes: 10256
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
 
const double pi = acos(-1.0);
 
int main(){
    ll xs, ys, xg, yg;
    cin >> xs >> ys >> xg >> yg;
    if (xs > xg){
        swap(xs, xg);
        swap(ys, yg);
    }
    int n;
    cin >> n;
    vector<PL> p;
    REP(_,n){
        ll i, j;
        scanf("%lld %lld", &i, &j);
        if (i < xs || i > xg) continue;
        if ((j - ys) * (j - yg) > 0) continue;
        p.push_back(PL(i, j));
    }
 
    sort(ALL(p));
 
    if (yg < ys){
        REP(i,p.size()) p[i].second *= -1;
    }
 
    double ans = 100.0 * (xg - xs + abs(yg - ys));
    n = p.size();
 
    if (xs == xg || ys == yg){
        if (p.size() > 0) ans += 10.0*pi - 20.0;
    }else{
        VL dp(n+1,1e18);
        REP(i,n){
            *lower_bound(ALL(dp), p[i].second) = p[i].second;
        }
        ll d = lower_bound(ALL(dp), 1e18) - dp.begin();
        ans -= (20.0 - 5.0*pi) * d;
        if (d == min(xg - xs, abs(yg - ys)) + 1){
            ans += 20.0 - 5.0*pi + 10.0*pi - 20.0;
        }
    }
    printf("%.15f\n", ans);
    return 0;
}

Measured memory_bytes: 6256
import std.stdio;
import std.string;
import std.format;
import std.conv;
import std.typecons;
import std.algorithm;
import std.functional;
import std.bigint;
import std.numeric;
import std.array;
import std.math;
import std.range;
import std.container;
import std.concurrency;
import std.traits;
import std.uni;
import std.regex;
import core.bitop : popcnt;
alias Generator = std.concurrency.Generator;

enum long INF = long.max/5;

void main() {
  string s = readln.chomp;
  writeln(s[2]==s[3] && s[4]==s[5] ? "Yes" : "No");
}

// ----------------------------------------------


void times(alias fun)(long n) {
  // n.iota.each!(i => fun());
  foreach(i; 0..n) fun();
}
auto rep(alias fun, T = typeof(fun()))(long n) {
  // return n.iota.map!(i => fun()).array;
  T[] res = new T[n];
  foreach(ref e; res) e = fun();
  return res;
}

T ceil(T)(T x, T y) if (isIntegral!T || is(T == BigInt)) {
  // `(x+y-1)/y` will only work for positive numbers ...
  T t = x / y;
  if (y > 0 && t * y < x) t++;
  if (y < 0 && t * y > x) t++;
  return t;
}

T floor(T)(T x, T y) if (isIntegral!T || is(T == BigInt)) {
  T t = x / y;
  if (y > 0 && t * y > x) t--;
  if (y < 0 && t * y < x) t--;
  return t;
}

ref T ch(alias fun, T, S...)(ref T lhs, S rhs) {
  return lhs = fun(lhs, rhs);
}
unittest {
  long x = 1000;
  x.ch!min(2000);
  assert(x == 1000);
  x.ch!min(3, 2, 1);
  assert(x == 1);
  x.ch!max(100).ch!min(1000); // clamp
  assert(x == 100);
  x.ch!max(0).ch!min(10); // clamp
  assert(x == 10);
}

mixin template Constructor() {
  import std.traits : FieldNameTuple;
  this(Args...)(Args args) {
    // static foreach(i, v; args) {
    foreach(i, v; args) {
      mixin("this." ~ FieldNameTuple!(typeof(this))[i]) = v;
    }
  }
}

void scanln(Args...)(auto ref Args args) {
  enum sep = " ";
  enum n = Args.length;
  enum fmt = n.rep!(()=>"%s").join(sep);

  string line = readln.chomp;
  static if (__VERSION__ >= 2074) {
    line.formattedRead!fmt(args);
  } else {
    enum argsTemp = n.iota.map!(
      i => "&args[%d]".format(i)
    ).join(", ");
    mixin(
      "line.formattedRead(fmt, " ~ argsTemp ~ ");"
    );
  }
}

// fold was added in D 2.071.0
static if (__VERSION__ < 2071) {
  template fold(fun...) if (fun.length >= 1) {
    auto fold(R, S...)(R r, S seed) {
      static if (S.length < 2) {
        return reduce!fun(seed, r);
      } else {
        return reduce!fun(tuple(seed), r);
      }
    }
  }
}

// popcnt with ulongs was added in D 2.071.0
static if (__VERSION__ < 2071) {
  ulong popcnt(ulong x) {
    x = (x & 0x5555555555555555L) + (x>> 1 & 0x5555555555555555L);
    x = (x & 0x3333333333333333L) + (x>> 2 & 0x3333333333333333L);
    x = (x & 0x0f0f0f0f0f0f0f0fL) + (x>> 4 & 0x0f0f0f0f0f0f0f0fL);
    x = (x & 0x00ff00ff00ff00ffL) + (x>> 8 & 0x00ff00ff00ff00ffL);
    x = (x & 0x0000ffff0000ffffL) + (x>>16 & 0x0000ffff0000ffffL);
    x = (x & 0x00000000ffffffffL) + (x>>32 & 0x00000000ffffffffL);
    return x;
  }
}


Measured memory_bytes: 256
#include <map>
#include <set>
#include <vector>
#include <algorithm>
#include <iostream>
#include <bitset>
#include <cassert>
#include <queue>
#include <random>
#include <stack>
#include <iomanip>

using namespace std;

typedef unsigned int uint;
typedef long long llong;
typedef unsigned long long ullong;
typedef long double ldouble;

typedef vector<llong> vecllong;
typedef vector<vecllong> vvecllong;

const llong MOD = 1e9 + 7;
const llong INF = 1e17;

#define FOR(i, n) for (llong i = 0; i < n; i++)
#define FORS(i, a, b) for (llong i = a; i < b; i++)
#define FORR(i, n) for (llong i = n; i > 0; i++)

int main(void) {
    llong N;
    cin >> N;

    vecllong A(N);

    llong maxA = 1;
    llong maxIndex = 0;
    FOR(i, N) {
        cin >> A[i];
        if (maxA < A[i]) {
            maxA = A[i];
            maxIndex = i;
        }
    }

    A.erase(A.begin() + maxIndex);

    long double middle = maxA / 2.0;
    llong middleA = A[0];

    FOR(i, N - 1) {
        if (abs(middle - A[i]) < abs(middle - middleA)) {
            middleA = A[i];
        }
    }

    cout << maxA << " " << middleA << endl;

    return 0;
}

Measured memory_bytes: 1024
val primes1 = intArrayOf(2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,101,103,107,109,113,127,131,137,139,149,151,157,163,167,173,179,181,191,193,197,199,211,223,227,229,233,239,241,251,257,263,269,271,277,281,283,293,307,311,313)
fun main(args: Array<String>) {
    val s = readLine()!!
    val (n, m) = s.split(" ").map(String::toInt)
    val divider = 1000000000L + 7L


    val primes = primes1

    fun factorial_product(n: Int, m: Int): Long {
        val counts = IntArray(primes.size, { 0 })
        val restPrimes: MutableList<Int> = mutableListOf()

        val min = Math.min(n, m)
        val max = Math.max(n, m)

        for (i in 1..min) {
            var dividend = i
            for (index in 0 until primes.size) {
                while (dividend % primes[index] == 0) {
                    dividend /= primes[index]
                    counts[index] += 2
                }
            }
            restPrimes.add(dividend)
            restPrimes.add(dividend)
        }
        for (i in min + 1 .. max) {
            var dividend = i
            for (index in 0 until primes.size) {
                while (dividend % primes[index] == 0) {
                    dividend /= primes[index]
                    counts[index] += 1
                }
            }
        }

        var result: Long = 1L

        for (index in 0 until primes.size) {
            repeat(counts[index]) { result = result * primes[index] % divider}
        }
        for (prime in restPrimes) {
            result = result * prime % divider
        }

        return result
    }

    val result = when {
        n == m -> factorial_product(n, n) * 2L % divider
        n + 1 == m || m + 1 == n -> factorial_product(n, m)
        else -> 0L
    }

    println(result)
}


Measured memory_bytes: 40728
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> l_l;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef pair<l_l,ll> lll;
const ll dx[4]={1,-1,0,0};
const ll dy[4]={0,0,1,-1};
#define pb push_back
#define sz(x) (int)(x).size()
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
const int INF=1001001000;
const int mINF=-1001001000;
const ll LINF=1010010010010010000;
template<class T> inline bool chmin(T& a, T b) {
if (a > b) {
a = b;
return true;
}
return false;
}
template<class T> inline bool chmax(T& a, T b) {
if (a < b) {
a = b;
return true;
}
return false;
}
//グリッド：（典型）dp,dfs,bfs,最短経路,その他
ld dp[310][310][310];
ll sa,sb,sc;
ll n;
ld rec(ll a,ll b,ll c){
    if(dp[a][b][c]>=0)return dp[a][b][c];
    if(a==0&&b==0&&c==0) return 0.0;
    ld res=0.0;
    if(a!=0)res+=a*rec(a-1,b,c);
    if(b!=0)res+=b*rec(a+1,b-1,c);
    if(c!=0)res+=c*rec(a,b+1,c-1);
    res+=n;
    res*=1.0/(a+b+c);
    return dp[a][b][c]=res;
}
int main(){
    cin>>n;
    vl a(n);
    rep(i,n)cin>>a[i];
    memset(dp,-1,sizeof(dp));
    sa=0,sb=0,sc=0;
    rep(i,n){
        if(a[i]==1)sa++;
        else if(a[i]==2)sb++;
        else sc++;
    }
    ld ans=rec(sa,sb,sc);
    cout<<fixed<<setprecision(10)<<ans<<endl;
    return 0;
}

Measured memory_bytes: 469336
k=lambda s,t:max(s)<min(t)or max(t)<min(s)
import sys
for x in sys.stdin:
 a,b,c,d,e,f,g,h=map(float,x.split())
 print(['YES','NO'][k((a,c),(e,g))or k((b,d),(f,h))])


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


int main(){
  string x, y;
  cin >> x >> y;

  sort(x.begin(), x.end());
  sort(y.begin(), y.end());
  reverse(y.begin(), y.end());

  if(x < y){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}

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

int main(){
    string n;
    cin >> n;
    int ans=0;
    for(int i=0;i<n.length();i++){
        if(n[i]=='2') ans++;
    }
    
    cout << ans << endl;
    
    return 0;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
 
int main() {

    int uMax, vMax, k;
    cin >> uMax >> vMax >> k;
    vector<vector<bool>> isWhiteChoco(uMax);
    for (int i = 0; i < uMax; i++) {
        string s;
        cin >> s;
        isWhiteChoco[i] = vector<bool>(vMax);
        for (int j = 0; j < vMax; j++) isWhiteChoco[i][j] = (s[j] == '1');
    }

    ll minOperation = LLONG_MAX;
    // hが少ないので、ここの割り方について総当たりで見る。
    for (int bit = 0; bit < (1 << (uMax - 1)); bit++) {
        // i行目が、第何グループになるか。
        vector<int> group(uMax);
        int cnt = 0; //最終的に、bitに何個1が立ってるかもカウントしてくれる。
        for (int i = 0; i < uMax; i++) {
            group[i] = cnt;
            if (bit & (1 << i)) cnt++;
        }
        vector<int> whiteCounter(cnt, 0);
        int cutCount = cnt; //すでに、横方向への切断回数を入れておく。
        vector<vector<int>> groupWhiteNum(cnt + 1);
        for (int g = 0; g < cnt + 1; g++) {
            groupWhiteNum[g] = vector<int>(vMax, 0);
        }
        for (int j = 0; j < vMax; j++) {
            for (int i = 0; i < uMax; i++) if (isWhiteChoco[i][j]) groupWhiteNum[group[i]][j]++;
        }

        bool isOver = false; //この横切断では、kをオーバーする列がある場合を調べる。
        for (int g = 0; g < cnt + 1; g++) {
            for (int j = 0; j < vMax; j++) {
                if (groupWhiteNum[g][j] > k) {
                    isOver = true;
                    break;
                }
            }
            if (isOver) break;
        }
        if (isOver) continue;

        ll cnt2 = (ll)cnt;
        vector<int> counter(cnt + 1, 0);
        for (int v = 0; v < vMax; v++) {
            // v列目をcounterに足していく。その中でオーバーしたら、初期化とcnt++をする。
            bool over = false;
            for (int g = 0; g < cnt + 1; g++) {
                counter[g] += groupWhiteNum[g][v];
                if (counter[g] > k) {
                    over = true;
                    break;
                }
            }
            if (over) {
                for (int g = 0; g < cnt + 1; g++) {
                    counter[g] = groupWhiteNum[g][v]; //初期化
                }
                cnt2++;
            }
        }
        minOperation = std::min(minOperation, cnt2);
    }

    cout << minOperation << endl;

    return 0;

}


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

int main() {
    int N;
    cin >> N;
    vector<vector<int> > data(2, vector<int>(N));
    
    for (int i=0; i<2; i++) {
        for (int j=0; j<N; j++) {
            cin >> data.at(i).at(j);
        }
    }
    int ans = 0;
    for (int k=0; k<N; k++) {
        int sum = 0;
        for (int j = 0; j <= k; j++) {
            sum += data.at(0).at(j);
        }
        for (int l = k; l < N; l++) {
            sum += data.at(1).at(l);
        }
        ans = max(sum, ans);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define MAX 1e5 + 9

void counting_sort(int a[], int b[], int k, int n);

int main(){
    int n;
    cin >> n;
    int a[n];
    int b[n];
    rep(i, n) cin >> a[i], b[i] = 0;
    counting_sort(a, b, MAX, n);
    rep(i, n) {
        if (i == n -1)
            cout << b[i + 1] << endl;
        else
            cout << b[i + 1] << ' ';
    }
}

void counting_sort(int a[], int b[], int k, int n){
    int c[k];
    rep(i, k) c[i] = 0;
    rep(i, n) c[a[i]]++;
    for (int i = 1; i < k; i++) c[i] += c[i - 1];
    for (int i = n - 1; i >= 0; i--) {
        b[c[a[i]]] = a[i];
        c[a[i]]--;
    }
}


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

int main()
{
    ll N;
    cin >> N;
    ll ns = sqrt(N) + 1;
    ll j = 0;
    int ans = 1e9;
    for (ll i = 1; i < ns; i++)
    {
        if (N % i == 0)
        {
            j = N / i;
            int cnt = 1;
            while (j >= 10)
            {
                j /= 10;
                cnt++;
            }
            ans = min(ans, cnt);
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3644
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n,x,sum=0,ma=0;
  scanf("%d",&n);
  for(int i=1;i<=n;i++)
  {
      scanf("%d",&x);
      if(ma<x)ma=x;
      sum+=x;
  }
  if(sum-2*ma>0)printf("Yes");
  else
    printf("No");
    return 0;
}


Measured memory_bytes: 256
n=int(input())
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

l=factorization(n)

ans=0
now=n
if n==1:
  print(0)
else:
  for i,e in l:
    for j in range(1,e+1):
      if now%(i**j)==0:
        now=now//(i**j)
        ans+=1
  print(ans)

Measured memory_bytes: 9400
def calc(arr, i, j)
  holi = [-1,0,1]
  vert = [-1,0,1]
  sum = 0
  holi.each{|h|
    vert.each{|v|
      if i+h >= 0 && j+v >= 0 && i+h < H
        sum +=1 if arr[i+h][j+v] == "#"
      end
    }
  }
  sum.to_s
end


H, W = gets.split.map(&:to_i)
arr = []
H.times{arr <<  gets[0..(W-1)] }
H.times{|i|
  W.times{ |j|
    arr[i][j] = calc(arr, i, j) if arr[i][j] == '.'
  }
}
puts arr



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

count = 0
flag = False
while True:
    for x in range(N):
        if A[x] % 2 == 0:
            A[x] = A[x]/2            
        else:
            flag = True
    if flag:
        break
    count += 1
print(count)

Measured memory_bytes: 3060
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector> 
#include <cstring>
#include <queue>
#include <ctime>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,int> pli;
const int INF = 10e8;
const int maxM = 1000010;
//const int maxN = 100010;
const int maxN = 110;

int x,y,z;
int a[4];
int main()
{
	for(int i=1;i<=3;i++)
	{
		scanf("%d",&a[i]);
	}
	sort(a+1,a+4);
	int ans = 0;
	for(int i=1;i<3;i++)
	{
		ans += abs(a[i+1] - a[i]);
	}
	printf("%d\n",ans);
	return 0;
}

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

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

int main(int argc, char *argv[])
{
    int i, N, t = 0, n = 0;
    long long list[100000] = {0LL}, l;
    scanf("%d", &N);
    for ( i = 0; i < N; i++ ){
        scanf("%lld", &list[i]);
    }
    qsort(list, N, sizeof(long long), cmp);

    l = list[0];
    n = 1;
    for ( i = 1; i < N; i++ ){
        if ( l == list[i] ){
            n++;
        } else {
            if ( n%2 == 1 ){
                t++;
            }
            l = list[i];
            n = 1;
        }
    }
    if ( n%2 == 1 ){
        t++;
    }

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

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


Measured memory_bytes: 1788
#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
#define ALL(a) a.begin(), a.end()
#define fi first
#define se second
#define mp make_pair
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,K,Q,A,B,L,R;
string S, T;
const ll MOD = (1e+9) + 7;
const ll INF = 1LL << 60;
typedef pair<ll,ll> P;

int main() {
    cin>>N;
    ll ans = INF;
    reps(i,1,min(N,20000000LL)){
        if(N%i == 0) {
            ans = min(ans, i + (N/i) - 2);
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <vector>
#define EPS (1e-10)
#define equals(a,b) (fabs(a)-fabs(b)<EPS)


using namespace std;

class Point{
public:
    double x,y;

    Point(double x=0,double y=0):x(x),y(y){}

    Point operator + (Point p) { return Point(x+p.x,y+p.y); }///这里注意，没有$
    Point operator - (Point p) { return Point(x-p.x,y-p.y); }
    Point operator * (double a) { return Point(x*a,y*a); }
    Point operator / (double a) { return Point(x/a,y/a); }

    double abs() { return sqrt(norm()); }
    double norm() { return x*x+y*y; }

    bool operator < (const Point &p) const {
        return x!=p.x?x<p.x:y<p.y;
    }

    bool operator == (const Point &p) const {
        return fabs(x-p.x)<EPS && fabs(y-p.y)<EPS;
    }
};

typedef Point Vector;
///Program 16.3 表示线段的结构体
struct Segment{
    Point p1,p2;
};

///Program 16.4 表示直线的结构体
typedef Segment Line;

///内积
double dot(Vector a,Vector b){
    return a.x*b.x+a.y*b.y;
}
///外积
double cross(Vector a,Vector b){
    return a.x*b.y-a.y*b.x;
}

Point project(Segment s,Point p){
    Vector base=s.p2-s.p1;
    double r=dot((p-s.p1),base)/base.norm();
    return s.p1 + base*r;
}
int main(){
    Point p1,p2;
    Segment s;
    scanf("%lf%lf%lf%lf",&s.p1.x,&s.p1.y,&s.p2.x,&s.p2.y);
    int q;
    scanf("%d",&q);
    for(int i=0;i<q;i++){
        Point tmp;
        scanf("%lf%lf",&tmp.x,&tmp.y);
        Point ans=project(s,tmp);
        printf("%.10f %.10f\n",ans.x,ans.y);
    }
    return 0;
}



Measured memory_bytes: 3244
#include <bits/stdc++.h>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <vector>
#include <string>
using namespace std;
typedef double  dbl;
typedef long long int lld;
#define PI 3.14159265358979323
#define foi(i,n) for(i = 0; i < n; i+=1)
#define fod(i,n) for(i=n-1; i >=0; i-=1)
#define MAX std::numeric_limits<lld>::max()
#define MIN std::numeric_limits<lld>::min()
#define FastIO  ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
int main ()
{
      FastIO
      lld a, b;
      cin >> a;
      cin >> b;
      cout << 6-(a+b);
      return 0;
}

Measured memory_bytes: 256
suit = ["S", "H", "C", "D"]
fig = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]
trump = []
for j in range(4):
    for k in range(13):
        trump.append(suit[j]+" "+str(fig[k]))

taro = []        
n = int(input())
for i in range(n):
    taro.append(input())

for m in range(52):
    if trump[m] not in taro:
        print(trump[m])


Measured memory_bytes: 5604
#include <bits/stdc++.h>
//#include <vector>
using namespace std;
 
 
int main(){
    int64_t n,ans=0;
    cin>>n;
    
    vector<int64_t> d(n);
    for(int i=0;i<n;i++)cin>>d.at(i);
    
    for(int i=0;i<n-1;i++){
        for(int j=i+1;j<n;j++){
            ans+=d.at(i)*d.at(j);
        }
    }
    
    cout<<ans<<endl;
    
   
    
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <complex>

using namespace std;

//typedef
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long ll;

#define omajinai ios::sync_with_stdio(false);cin.tie(0)

//container util
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define UNIQUE(a)  (a).erase(unique((a).begin(),(a).end()),(a).end())
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(auto i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RFOR(i,b,a) for(int i=(b)-1;i>=(a);--i)
#define RREP(i,n) RFOR(i,n,0)

//debug
#define dump(x)  cerr << "[L " << __LINE__ << "] " << #x << " = " << (x) << "\n";


const int INF = 1e9;
typedef pair<int , int> P;

int n;
vector<P> odd, even;

struct SEG{
	int na,m;
	P d[280000];
	SEG(int _n):m(_n){
		na=1;
		while(na<_n)na*=2;
		REP(i, 2*na -1)d[i]=MP(-INF, 0);
	}
	void update(int a, P v){
		a+=na-1;
		d[a]=v;
		while(a>0){
			a=(a-1)/2;
			d[a] = max(d[a*2+1], d[a*2+2]);
		}
	}
	P query(int a, int b){
		return _query(a, b, 0, 0, na);
	}
	P _query(int a, int b, int k, int l, int r){
		if(r <= a || b <= l) return MP(-INF, 0);
		if(a<=l && r <= b) return d[k];
		else{
			P vl = _query(a,b,k*2+1, l, (l+r)/2);
			P vr = _query(a,b,k*2+2, (l+r)/2,r);
			return max(vl, vr);
		}
	}
};

typedef pair<P, P> R;

int ans[200000];///,ddd[100000];
int main() {
	omajinai;
	cin >> n;
	SEG odd(n/2), even(n/2);
	REP(i,n/2){
		int a,b;
		cin >> a >> b;
		odd.update(i, MP(-a, i*2));
		even.update(i, MP(-b, i*2 + 1));
	}
	priority_queue<R> rs;
	rs.push(MP(odd.query(0,n/2), MP(0, n)));
	int j=0;
	REP(i, n/2){
		R pr = rs.top();rs.pop();
		//dump(rs.size());
		P p = pr.first, r = pr.second;
		if(r.first%2){ // even
			P emin = p;
			P omin = odd.query((emin.second+2)/2, (r.second + 2)/2);
			ans[j++]=-emin.first;ans[j++]=-omin.first;
			if(r.first - emin.second < 0)rs.push(MP(even.query(r.first / 2, emin.second/2), MP(r.first, emin.second)));
			if(emin.second+1 - omin.second < 0)rs.push(MP(odd.query((emin.second+2)/2, omin.second/2), MP(emin.second+1, omin.second)));
			if(omin.second+1 - r.second < 0)rs.push(MP(even.query(omin.second/2, r.second/2), MP(omin.second+1, r.second)));
		}else{ // odd
			P omin = p;
			P emin = even.query(omin.second/2, r.second/2);
			ans[j++]=-omin.first;ans[j++]=-emin.first;
			if(r.first - omin.second < 0)rs.push(MP(odd.query(r.first / 2, omin.second/2), MP(r.first, omin.second)));
			if(omin.second+1 - emin.second < 0)rs.push(MP(even.query(omin.second/2, emin.second/2), MP(omin.second+1, emin.second)));
			if(emin.second+1 - r.second < 0)rs.push(MP(odd.query((emin.second+2)/2, r.second/2), MP(emin.second+1, r.second)));
		}
	}
	REP(i, n){
		cout << ans[i];
		if(i!=n-1)cout << " ";
	}
	cout << endl;
}


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

int main() {
	string s;
  	string YES = "Yes";
    string NO = "No";
    int ans = 0;
  
    cin >> s;
    
  for(int i = 0; i < 3;i++){
    if(s[i] == s[i+1]){
      ans++;
    }
    else{
      ans = 0;
    }
    if(ans == 2) break;
  }
  
  if(ans==2){
    cout << YES << endl;
  }
  else{
    cout << NO << endl;
  }
  
}

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

int main() {
    int a, b;
    cin >> a >> b;

    int sum = 0;
    for(int i=1; i<=b-a; i++){
        sum += i;
    }

    cout << sum - b << endl;
}

Measured memory_bytes: 764
import Control.Applicative
import Control.Monad
import Data.Char
import Data.List

main :: IO ()
main = do
  ls <- lines <$> getContents
  forM_ ls $ \l -> putStrLn $ head $ filter (\s -> "the" `isInfixOf` s || "this" `isInfixOf` s || "that" `isInfixOf` s) $ map (shift l) [1..26]

shift :: String -> Int -> String
shift s n = map (\ch -> if isAlpha ch then chr ((ord ch-ord 'a'+n)`mod`26+ord 'a') else ch) s

Measured memory_bytes: 3916
import sys

def solve():
    readline = sys.stdin.buffer.readline
    mod = 10 ** 9 + 7
    n = int(readline())
    a = list(map(int, readline().split()))
    ls = [0] * 60
    t = 0
    for i in range(60):
        for v in a:
            ls[i] += (v >> i) & 1
        t += pow(2, i, mod) * (n - ls[i]) * ls[i]
        t %= mod
    print(t)


if __name__ == '__main__':
    solve()


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

using namespace std;
using ll = long long;
using P = pair<int, int>;

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

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

int main() {
  string s;
  cin >> s;
  string s1 = s.substr(0, (s.length() - 1) / 2);
  string s2 = s.substr((s.length() + 3) / 2 - 1);

  if (s1 == s2)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;

  return 0;
}

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

int q;
string X,Y;
int L[1001][1001];

int max(int i,int j) {return i > j ? i : j;}

int getL(int i,int j) {
	if(L[i][j] != -1) return L[i][j];

	int res;

	if(i == 0 || j == 0) res = 0;
	else if(X[i - 1] == Y[j - 1]) res = 1 + getL(i - 1,j - 1);
	else res = max(getL(i,j - 1),getL(i - 1,j));

	L[i][j] = res;
	return res;
}

int main() {

	cin >> q;
	for(int i = 0;i < q;i++) {
		cin >> X >> Y;
		for(int j = 0;j <= X.size();j++) {
			for(int k = 0;k <= Y.size();k++) L[j][k] = -1;
		}
		cout << getL(X.size(),Y.size()) << endl;
	}
}

Measured memory_bytes: 5268
using System;
public class Hello{
    public static void Main(){
       var s = Console.ReadLine();
       var k = long.Parse(Console.ReadLine());
       for(var i = 0;i < k;i++){
           if(s[i] != '1'){
               Console.WriteLine(s[i]);
               return;
           }
       }
       Console.WriteLine('1');
    }
}


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


const int MAXN = 100005;

int main()
{
    int n;
    cin >> n;
    int odd = 0, two = 0, four = 0;
    for (int i = 0; i < n; i++)
    {
        int a; cin >> a;
        if (a % 2)
            odd++;
        else if (a % 4)
            two++;
        else
            four++;
    }

    if (odd <= four || (odd == four + 1 && odd + four == n))
    {
        cout << "Yes";
    }
    else cout << "No";

}


Measured memory_bytes: 256
//***Little by little one travels far***
 
#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 ll long long
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i,n) for(i=0;i<n;i++)
#define forn(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define for1(i, n) for (ll i = 1; i <= (ll)(n); ++i)
#define ford(i, n) for (ll i = (ll)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (ll i = (ll)(a); i <= (ll)(b); ++i)
#define fora(it,x) for(auto it:x)
#define PI 3.14159265
#define sync ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define endl "\n"
 
typedef pair<ll, ll> pii;
typedef vector<ll> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef long double ld;
 
template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }

int main()
{
    double w,h,x,y,c=0;
    cin>>w>>h>>x>>y;

    printf("%0.9f ",((double)h*(double)w)/2.0);

    double p=w/2.0,q=h/2.0;

    if((x==p)&&(y==q)) cout<<"1";
    else cout<<"0";
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		
		while(in.hasNextInt()==true){
		int n = in.nextInt();
		int m = in.nextInt();
		int keta = (int)Math.log10(n+m) + 1;
		System.out.println(keta);
		}
				
		

	}

}

Measured memory_bytes: 12000
#include <iostream>
#include <vector>
#include <string>

using namespace std;

const int MOD = 998244353;

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

  int ans = 0;
  for (int i=0;i<n;++i) {
    if (v[i] > c[i])
      ans += (v[i] - c[i]);
  }  
  
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
<?php
//error_reporting(0);
//$A = explode(" ",trim(fgets(STDIN)));
//list($A,$B) = explode(" ",trim(fgets(STDIN)));
$N=trim(fgets(STDIN));
for($i=0;$i<$N;$i++) {
  $d[]=trim(fgets(STDIN));
}
asort($d);
$r = array_unique($d);
printf("%d\n",count($r));


Measured memory_bytes: 3828