akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define int long long
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e18;
const double EPS = 1e-7;

signed main(){
    double W, H, x, y;
    cin >> W >> H >> x >> y;
    double ans = W * H * 0.5;
    printf("%.10lf ", ans);
    if(fabs(W * 0.5 - x) < EPS && fabs(H * 0.5 - y) < EPS) cout << 1 << endl;
    else cout << 0 << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int  n,a,cntm,cntp,cnts;
int main ()
{
   cin>>a>>n;

if (n==a)
    cout<<"Draw";

else if(a==1)
cout<<"Alice";
else if (n==1)
cout<<"Bob";
else if(a>n)
cout<<"Alice";
else if(n>a)
cout<<"Bob";




    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
    #include <set>
    #define REP(i, n) for(int i = 0;i < n;i++)
    #define REPR(i, n) for(int i = n;i >= 0;i--)
    #define FOR(i, m, n) for(int i = m;i < n;i++)
    #define FORR(i, m, n) for(int i = m;i >= n;i--)
    #define SORT(v, n) sort(v, v+n);
    #define VSORT(v) sort(v.begin(), v.end());
    //
    #define llong long long
    #define pb(a) push_back(a)

    #define INF 100000000
    #define MOD 1000000007

    #define writeln(n) cout<<n<<endl

    using namespace std;
    typedef pair<int, int> P;
    typedef pair<llong, llong> LP;
    typedef pair<int, P> PP;
    typedef pair<llong, LP> LPP;
    //vector<tuple<long long, long long, long long>>vec;

    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;
    }

    llong pownew(llong m, llong n) {
        if (n == 0) { return 1; }
        if (n % 2 == 0) { return pow(m*m, n/2); }
        return pow(m, n-1) * m;
    }

    bool isprime(int p) {
        if (p == 1) return false;
        for (int i = 2; i < p; i++) {
            if (p%i == 0) return false;
        }
        return true;
    }

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

    const int inf=100000000;

    long long modpow(long long a, long long n, long long mod) //a^n
    {
        long long res = 1;
        while (n > 0) {
            if (n & 1) res = res * a % mod;
            a = a * a % mod;
            n >>= 1;
        }
        return res;
    }

    int gcd(int a, int b) {
        return b != 0 ? gcd(b, a % b) : a;
    }
    //setprecision(10);

    typedef long long ll;

    ll merge_cnt(vector<int> &a) {
        int n = a.size();
        if (n <= 1) { return 0; }

        ll cnt = 0;
        vector<int> b(a.begin(), a.begin()+n/2);
        vector<int> c(a.begin()+n/2, a.end());

        cnt += merge_cnt(b);
        cnt += merge_cnt(c);

        int ai = 0, bi = 0, ci = 0;
        // merge の処理
        while (ai < n) {
            if ( bi < b.size() && (ci == c.size() || b[bi] <= c[ci]) ) {
                a[ai++] = b[bi++];
            } else {
                cnt += n / 2 - bi;
                a[ai++] = c[ci++];
            }
        }
        return cnt;
    }


    int main() {
        ios::sync_with_stdio(false);
        cin.tie(0);
        int n; cin>>n;
        vector<int> a(n,0);
        vector<int> b(n,0);
        vector<int> c(n-1,0);
        REP(i,n) cin>>a[i];
        REP(i,n) cin>>b[i];
        REP(i,n-1) cin>>c[i];
        int ans=0;

        REP(i,n-1)
        {
         ans+=b[a[i]-1];
         if(a[i+1]==a[i]+1) ans+=c[a[i]-1];
        }
        ans+=b[a[n-1]-1];
        cout<<ans<<endl;

        return  0;
    }


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

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

typedef long long ll;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
//定数
#define INF 1000000000 //10^9:極めて大きい値,∞
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素

int main(){
    int N;
    cin>>N;
    vector<int> A(N);
    rep(i,N) cin>>A[i];
    sort(A.rbegin(),A.rend());
    ll ans=A[0];
    for(int i=2;i<N;i++){
        ans+=A[i/2];
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 4032
#400
N = int(input())
A = list(map(int,input().split()))
L = [0]*N
S = 0
for i in range(N):
    L[A[i]-1] =  L[A[i]-1] + 1

for i in range(N):
    if L[i] != 0:
        S += (L[i] * (L[i]-1)) // 2

for i in range(N):
    n = A[i]
    S2 = S
    S2 = S2 - ((L[A[i]-1] * (L[A[i]-1]-1)) // 2)
    if L[A[i]-1] - 1 > 0:
        S2 += (((L[A[i]-1]-1) * (L[A[i]-1]-2)) // 2)
    print(S2)

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

const int N=1e6+20;
typedef long long ll;
int n,k;
int h[N];
int dp[N];
int solve(int i){
    if(i==n-1){
        return 0;
    }
    if(i>=n)return 1e9;
    if(dp[i]!=-1)return dp[i];
    int ch1;
    int mn=INT_MAX;
    for(int j=1;j<=k;j++){

        ch1=abs(h[i]-h[i+j])+solve(i+j);
        mn=min(ch1,mn);
    }
    return dp[i]=mn;
}
int main()
{
    cin>>n>>k;
    for(int i=0;i<n;i++)cin>>h[i];
    memset(dp,-1,sizeof dp);
    cout<<solve(0);

}


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

const int MAX = 1100000;
vector<int> cnt; // cnt[n] := how many times n! can be divided by 2
void pre() {
    cnt.assign(MAX, 0);
    for (int i = 1; i <= MAX; i++) {
        int n = i;
        int count = 0;
        while(n % 2 == 0) {
            count ++;
            n /= 2;
        }
        cnt[i] = cnt[i-1] + count;
    }
} 

int main(){ 
    pre();
    int N; cin >> N;
    vector<int> x(N);
    bool one = false;
    for (int i = 0; i < N; i++) {
        char a; cin >> a;
        x[i] = (a-'0')-1;
        if (x[i] == 1) one = true;
    }
    //x[0] is a vector conprised of only 0, 1, or 2.
    //until i = N, x[i] is conprised of only 0, 1, 2.
    // 偶奇判定
    int res = 0;
    for (int i = 0; i < N; i++) {
        int mod_comb = cnt[N-1] - cnt[N-1-i] - cnt[i];
        if (mod_comb > 0) continue;
        res += x[i];
    }

    if (res % 2 == 1) {
        cout << 1 << endl;
    }
    else {
        if (one) cout << 0 << endl;
        else {
            for (int i = 0; i < N; i++) {
                x[i] /= 2; 
            }
            res = 0;
            for (int i = 0; i < N; i++) {
                int mod_comb = cnt[N-1] - cnt[N-1-i] - cnt[i];
                if (mod_comb > 0) continue;
                res += x[i];
            }
            if (res % 2 == 1) cout << 2 << endl;
            else cout << 0 << endl;
        }
    }
}

Measured memory_bytes: 8448
#include <bits/stdc++.h>
using namespace std;
#define ll int64_t
#define ALL(a)  (a) c;.begin(),(a).end()
 
const ll mod = 1000000007;
const ll LINF = 1e13;
const ll LLINF = 1e18;
const ll ALPHABET = 26;
 
template <class T>
void Swap(T& r, T& l) {
  T tmp = r;
  r = l;
  l = tmp;
}
 
template<typename T>
istream& operator >> (istream& is, vector<T>& vec) {
  for (T& x : vec) is >> x; //for(int i=0; i<vec.size(); i++) is >> x[i]; とかでもいい
  return is;
}


int main(){
  ll a,b,c;
  cin >> a >> b >>c;
  
  bool ans = false;

  if (a==b & a!=c)ans = true;
  if (a==c & a!=b)ans = true;
  if (c==b & a!=c)ans = true;


  cout << ((ans==true)?"Yes":"No");

}


Measured memory_bytes: 256
import java.util.Scanner;

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


Measured memory_bytes: 23764
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define fi first
#define se second
#define mp make_pair
#define itrfor(itr,A) for(auto itr = A.begin(); itr !=A.end();itr++)
template <class T> using reversed_priority_queue = priority_queue<T, vector<T>, greater<T> >;
typedef long long llong;
char moji[26]={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
char moji2[26]={'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
char moji3[10]={'0','1','2','3','4','5','6','7','8','9'};
#define Sort(a) sort(a.begin(),a.end());
#define Reverse(a) reverse(a.begin(),a.end());
#define print(a) cout << a << endl;
#define MOD llong(1e9+7)
#define MAX int(2 * 1e5 +5)
#define debug(x)  cout << #x << " = " << (x) << endl;
#define pi acos(-1.0)
#define int llong
#define INF llong(1e18 + 3)
template<class T> bool chmax(T &a,  T b) {if(a<b){a=b; return 1;} return 0;}
template<class T> bool chmin(T &a,  T b) {if(a>b){a=b; return 1;} return 0;}
bool Add(int &a,int b){a = (a + b) % MOD;}
void myprint(int* A,int A_num){
   REP(i,A_num) cout << A[i] << " ";
   cout << endl;
}


struct edge{
    int to, tru;
};

signed main(){
    int n;
    cin >> n;
    vector<edge> E[n];
    REP(i,n){
        int a;
        cin >> a;
        REP(j,a){
            int x,y;
            cin >> x >> y;
            x --;
            E[i].push_back( edge{x,y});
        }
    }
    int bit = 1 << n;
    int ans = 0;
    REP(joutai, bit){
        bool flag = true;
        int tmp = 0;
        REP(i,n){
            if( (joutai &  (1 <<i) ) ){
                tmp ++;
                itrfor(itr,E[i]){
                    int huga = ( joutai & (1 << itr->to ));
                    if(  huga != 0 and itr->tru == 0 ){
                        flag = false;
                        break;
                    }
                    if( huga == 0 and itr->tru == 1){
                        flag = false;
                        break;
                    }
                }
            }
            if(flag == false) break;
        }
        if(flag){
            chmax(ans,tmp);
        } 
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void){
    
    int n;
    int a;
    int x=0,y=0,z=0;
    scanf("%d",&n);
    for(;~scanf("%d",&a);){
        if(a%4==0){
            z++;
        }else if(a%2==0){
            y++;
            }else{
            z--;
        }
    }
    puts((y&&z+1||!y&&z>=-1)?"Yes":"No");
}

Measured memory_bytes: 1632
N = int(input())
C = {0:0,1:0,2:0}
cnt = 0
for _ in range(N):
    s = input().strip()
    if s[0]=="B" and s[-1]!="A":
        C[0] += 1
    elif s[0]!="B" and s[-1]=="A":
        C[1] += 1
    elif s[0]=="B" and s[-1]=="A":
        C[2] += 1
    for i in range(len(s)-1):
        if s[i:i+2]=="AB":
            cnt += 1
if C[2]>0:
    cnt += C[2]-1
    if C[0]>0:
        cnt += 1
        C[0] -= 1
    if C[1]>0:
        cnt += 1
        C[1] -= 1
cnt += min(C[0],C[1])
print(cnt)


Measured memory_bytes: 3064
#include <stdio.h>
#include <iostream>

using namespace std;

char s[1000][1111];

char w[2][10];

char q[3] = {'J','O','I'};

int k[1000][1000];

bool itti(int y,int x)
{
	for(int i = 0; i < 2; i++)
	{
		for(int ii = 0; ii < 2; ii++)
		{
			if(s[y + i][x + ii] != w[i][ii])
			{
				return false;
			}
		}
	}
	return true;
}

int main()
{
	int m,n;
	scanf("%d%d",&m,&n);
	for(int i = 0; i < m; i++)
	{
		scanf("%s",s[i]);
	}
	for(int i = 0; i < 2; i++)
	{
		scanf("%s",w[i]);
	}
	for(int i = 0; i < m; i++)
	{
		for(int ii = 0; ii < n; ii++)
		{
			k[i][ii] = 0;
		}
	}
	int all = 0;
	for(int i = 0; i < m - 1; i++)
	{
		for(int ii = 0; ii < n - 1; ii++)
		{
			if(itti(i,ii))
			{
				k[i][ii]++;
				k[i + 1][ii]++;
				k[i][ii + 1]++;
				k[i + 1][ii + 1]++;
				all++;
			}
		}
	}
	int maxw = all;
	for(int i = 0; i < m; i++)
	{
		for(int ii = 0; ii < n; ii++)
		{
			char moto = s[i][ii];
			for(int j = 0; j < 3; j++)
			{
				s[i][ii] = q[j];
				int now = all - k[i][ii];
				if(i != 0)
				{
					if(ii != 0)
					{
						if(itti(i - 1,ii - 1))
						{
							now++;
						}
					}
					if(ii != n - 1)
					{
						if(itti(i - 1,ii))
						{
							now++;
						}
					}
				}
				if(i != m - 1)
				{
					if(ii != 0)
					{
						if(itti(i,ii - 1))
						{
							now++;
						}
					}
					if(ii != n - 1)
					{
						if(itti(i,ii))
						{
							now++;
						}
					}
				}
				maxw = max(maxw,now);
			}
			s[i][ii] = moto;
		}
	}
	printf("%d\n",maxw);
	return 0;
}

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

int main() {
  string s;
  cin >> s;
  if(s[0]!=s[1]&&s[1]!=s[2]&&s[2]!=s[0]) {
  cout << "Yes" << endl;
  }
  else cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 256
var input=require("fs").readFileSync("/dev/stdin","utf8");
var str;
var i,x,y;

input=input.split("\n");

for(i=0;i<3000;i++){
    str=input[i].split(" ");
    x=parseInt(str[0]);
    y=parseInt(str[1]);
    if(x==0 && y==0){
        break;
    }
    else if(x>y){
       console.log("%d %d",y,x);
    }
    else{
       console.log("%d %d",x,y);
    }
}


Measured memory_bytes: 19108
N = int(input())
S = input()
white = [0] * (N + 1)
black = [0] * (N + 1)
bound = [-1]
for i, s in enumerate(S):
    if s == '.':
        white[i + 1] = 1
    else:
        black[i + 1] = 1
    white[i + 1] += white[i]
    black[i + 1] += black[i]
    if i < N - 1 and S[i] == '#' and S[i + 1] == '.':
        bound.append(i)
bound.append(N)

ans = N
for i, j in zip(bound, bound[1:]):
    ans = min(ans, black[i + 1] + white[-1] - white[j])
print(ans)


Measured memory_bytes: 24120
#pragma gcc optimize("Ofast")
#include <bits/stdc++.h>

using namespace std;
using ll = long long;

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(V) (V).begin(),(V).end()
#define pb(n) push_back(n)
#define endl '\n'
#define Endl '\n'
#define DUMP(x)  cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define Yay(n) cout << ((n) ? "Yay!": ":(") << endl
#define RAPID cin.tie(0);ios::sync_with_stdio(false)
#define VSUM(V) accumulate(ALL(V), 0)
#define MID(a,b,c) (a) < (b) && (b) < (c)
#define MIDe(a,b,c) (a) <= (b) && (b) <= (c)
#define IN(n) cin >> n
#define IN2(a,b) cin >> a >> b
#define IN3(a,b,c) cin >> a >> b >> c 
#define IN4(a,b,c,d) cin >> a >> b >> c >> d
#define VIN(V) for(int i = 0; i < (V).size(); i++) {cin >> (V).at(i);}
#define OUT(n) cout << n << endl
#define VOUT(V) REP(i, (V).size()) {cout << (V)[i] << endl;}
#define VOUT2(V) REP(i, (V).size()) {cout << (V)[i] << " ";} cout<<endl;

// 型マクロ定義
#define int long long
#define P pair<ll,ll>
#define Vi vector<ll>
#define Vd vector<double>
#define Vs vector<string>
#define Vc vector<char>
#define M map<ll,ll>
#define S set<ll>
#define PQ priority_queue<ll>
#define PQG priority_queue<ll,V,greater<ll>
//

const int MOD = 1000000007;
const int INF = 1061109567;
const double EPS = 1e-10;
const double PI  = acos(-1.0);

int gcd(int a,int b){return b != 0 ? gcd(b, a % b) : a;} //最大公約数
int lcm(int a, int b){return a * b / gcd(a, b);}
string toStrUp(string str){char diff = 'A'-'a';REP(i,str.size()) str[i] += diff;return str;}
string gCh(string str, int key){return str.substr(key,1);}

signed main() {
  RAPID;
  int n=0,m=0,a=0,b=0,c=0,d=0,x=0,y=0,z=0;
  string s="",t="";
  //

  IN2(n,a);
  z = 1;
  REP(i,n){
    if(z*2 < z+a) z *= 2;
    else z += a;
  }
  OUT(z);
}


Measured memory_bytes: 256
import java.math.BigDecimal;
import java.util.Scanner;

import static java.math.BigDecimal.ROUND_HALF_UP;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        long a = scanner.nextLong();
        long b = scanner.nextLong();
        long c = scanner.nextLong();


        BigDecimal as = BigDecimal.valueOf(a);
        BigDecimal bs = BigDecimal.valueOf(b);
        BigDecimal cs = BigDecimal.valueOf(c);

        if ((sqrt(as).add(sqrt(bs))).compareTo(sqrt(cs)) == -1) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }

    }

    public static BigDecimal sqrt(BigDecimal A) {
        final int SCALE = 1000;
        BigDecimal x0 = new BigDecimal("0");
        BigDecimal x1 = new BigDecimal(Math.sqrt(A.doubleValue()));
        while (!x0.equals(x1)) {
            x0 = x1;
            x1 = A.divide(x0, SCALE, ROUND_HALF_UP);
            x1 = x1.add(x0);
            x1 = x1.divide(BigDecimal.valueOf(2), SCALE, ROUND_HALF_UP);

        }
        return x1;
    }
}

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

int main(void){
    int n, k;
    cin >> n >> k;

    double ans = 0;

    for(int i = 1; i <= n; i++){
        double p = 1;
        int score  = i;
        while(score < k){
            p *= 0.5;
            score *= 2;
        }
        ans += p / n;
    }
    printf("%.12f", ans);
    return 0;
}

Measured memory_bytes: 256
n,m = map(int,input().split())
d={j:0 for j in range(1,n+1)}
for i in range(m):
    a,b = map(int,input().split())
    d[a] = d[a]+1
    d[b] = d[b]+1
for k in range(1,n+1):
    print(d[k])
    

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

#define pb(n) push_back(n)
#define fi first
#define se second
#define all(r) begin(r),end(r)
#define vmax(ary) *max_element(all(ary))
#define vmin(ary) *min_element(all(ary))
#define debug(x) cout<<#x<<": "<<x<<endl
#define fcout(n) cout<<fixed<<setprecision((n))
#define scout(n) cout<<setw(n)
#define vary(type,name,size,init) vector< type> name(size,init)
#define vvl(v,w,h,init) vector<vector<ll>> v(w,vector<ll>(h,init))
#define mp(a,b) make_pair(a,b)

#define rep(i,n) for(int i = 0; i < (int)(n);++i)
#define REP(i,a,b) for(int i = (a);i < (int)(b);++i)
#define repi(it,array) for(auto it = array.begin(),end = array.end(); it != end;++it)
#define repa(n,array) for(auto &n :(array))

using ll = long long;
using pii = pair<int,int> ;
using pll = pair<ll,ll> ;

template<typename T>
void O(T t){
  cout << t << endl;
}

const ll mod = 1e9+7;
constexpr ll inf = ((1<<30)-1)*2+1 ;
constexpr double PI = acos(-1.0) ;
double eps = 1e-10 ;
const int dy[] = {-1,0,1,0,1,-1,1,-1};
const int dx[] = {0,-1,0,1,1,-1,-1,1};

struct Edge{
  int to;
  long long cost;
};

vector<Edge> g[100001];
int prenum[100001],parent[100001],lowest[100001],visited[100001],cnt = 1,child[100001];

void Articulation_Points(int k,int p){
  visited[k] = true;
  prenum[k] = cnt;
  lowest[k] = cnt;
  ++cnt;
  for (auto&& n : g[k]) {
    if(!visited[n.to]){
      parent[n.to] = k;
      Articulation_Points(n.to,k);
      child[k]++;
      lowest[k] = min(lowest[k],lowest[n.to]);
    }
    else if(n.to != p){
      lowest[k] = min(lowest[k],prenum[n.to]);
    }
  }
}


int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n ,a,b,e;
  cin >> n >> e;
  rep(i,e){
    cin >> a >> b;
    g[a].push_back({b,0LL});
    g[b].push_back({a,0LL});
  }
  Articulation_Points(0,-1);
  set<int> art;
  set<pair<int,int>> ans;
  int np = 0;
  for (int i = 1; i < n; i++) {
    int p = parent[i];
    if(p == 0){
      ++np;
    }
    else{
      if(prenum[p] <= lowest[i]){
        art.insert(p);
      }
    }
  }
  if(np > 1) art.insert(0);
  rep(i,n){
    if(g[i].size() == 1)
      art.insert(i);
  }
  REP(i,1,n){
    int p = parent[i];
    if(prenum[i] <= lowest[i]){
      if(i < p){
        ans.insert({i,p});
      }
      else
        ans.insert({p,i});
    }
  }
  for (auto&& k : ans) {
    std::cout << k.fi << ' ' << k.se << std::endl;
  }
  return 0;
}

Measured memory_bytes: 8408
#[allow(unused_imports)]
use proconio::{
    fastout, input,
    marker::{Bytes, Chars, Isize1, Usize1},
};

fn main() {
    input! {
        n:usize,
        c:Chars,
    }
    let r = c.iter().filter(|x| **x == 'R').count();
    let w = n - r;
    let ans = std::cmp::min(r, w);
    let mut p1 = 0;
    let mut p2 = n - 1;
    let mut buf = 0;
    if n == 2 {
        if c[0] == 'W' && c[1] == 'R' {
            println!("1");
        } else {
            println!("0");
        }
        return;
    }
    while p1 < p2 {
        while p1 < p2 && c[p1] == 'R' {
            p1 += 1;
        }
        while p1 < p2 && c[p2] == 'W' {
            p2 -= 1;
        }
        if p1 < p2 {
            buf += 1;
            p1 += 1;
            p2 -= 1;
        }
    }
    println!("{}", std::cmp::min(ans, buf));
}


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

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

		int[] freq = new int[26];
		boolean flag = true;
		for(int i=0; i<s.length(); i++){
			if(freq[s.charAt(i)-97] == 0){
				freq[s.charAt(i)-97]++;
			}else{
				flag= false;
				break;
			}
		}

		if(!flag){
			System.out.println("no");
			return;
		}
		System.out.println("yes");
	}
}

Measured memory_bytes: 21844
N, M, C = gets.split(" ").map(&:to_i)
b_array = gets.split(" ").map(&:to_i)
counter = 0

N.times do
  a_array = gets.split(" ").map(&:to_i)
  total = 0
  
  a_array.each_with_index do |a, i|
    total += a * b_array[i]
  end
  
  total += C
  counter += 1 if total > 0
end

puts counter

Measured memory_bytes: 3836
import sys
from collections import deque

n = int( sys.stdin.readline( ) )
que = deque( )
lines = sys.stdin.readlines()
for line in lines:
	op = line.rstrip().split( " " )
	if "insert" == op[0]:
		que.appendleft( op[1] )
	elif "delete" == op[0]:
		if op[1] in que:
			que.remove( op[1] )
	elif "deleteFirst" == op[0] :
		que.popleft( )
	elif "deleteLast" == op[0]:
		que.pop( )


print( " ".join( que ) )

Measured memory_bytes: 348028
#include<bits/stdc++.h>
#define MIN -1000000
using namespace std;
typedef long long ll;
int main(void)
{
  ll L,R;
  cin >> L >> R;
  if(R-L>=2019LL)
  {
    cout << 0 << endl;
    return 0;
  }
  else if(L%2019LL==0 || R%2019LL==0)
  {
    cout << 0 << endl;
    return 0;
  }
  ll ans=100000000;
  for(ll i=L;i<=R;i++)
  {
    for(ll j=i+1LL;j<=R;j++)
    {
      ans=min(ans,((i%2019)*(j%2019LL))%2019LL);
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
//
//  main.c
//  q_03_02
//
//  Created by k19104kk on 2020/08/29.
//  Copyright © 2020 AIT. All rights reserved.
//

#include <stdio.h>

int main(int argc, const char * argv[]) {
    long long n;
    scanf("%lld", &n);
    
    long long ai[n], as[n];
    
    for (int i=0; i<n; i++) {
        scanf("%lld", &ai[i]);
        
        if (i==0) {
            as[i] = ai[i];
        } else {
            as[i] = as[i-1]+ai[i];
        }
    }
    
    long long result = 0;
    
    long long waru = 1000000007;
    
    for (int i=0; i<n-1; i++) {
        result += (ai[i]%waru) * ((as[n-1]-as[i])%waru);
        result %= waru;
    }
    
    printf("%lld\n", result);
    return 0;
}


Measured memory_bytes: 4812
n,k = map(int,input().split())
p = list(map(int,input().split()))

st = 0
max_p = sum(p[0:k])
sum_p = max_p
for i in range(0,n-k):
    sum_p -= p[i]
    sum_p += p[i+k]
    if max_p < sum_p:
        st = i+1
        max_p = sum_p

ex = 0
for j in range(st,st+k):
    ex += (p[j]+1)/2

print(ex)

Measured memory_bytes: 25060
#include <iostream>
#include <vector>
#include <unordered_set>
#include <algorithm>
#include <cmath>

using namespace std;

template <int base>
int digit_sum(int n)
{
	int sum = 0;
	while (n > 0) {
		sum += n % base;
		n /= base;
	}
	return sum;
}

using ivec = vector<int>;

ivec read_int_args()
{
	int N;
	cin >> N;
	ivec v(N);
	for (auto& e : v) {
		cin >> e;
	}
	return v;
}

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

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

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


int main()
{
	int N, K;
	cin >> N >> K;
	int cnt = 0;
	for (int i = 0; i < N; i++) {
		int h;
		cin >> h;
		if (h >= K)
			cnt++;
	}
	cout << cnt << endl;

	return 0;
}


Measured memory_bytes: 888
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<vector>
#include<tuple>
#include<map>
#include<queue>
#include<stack>
#include<deque>
#include<bitset>
#include<math.h>
using namespace std;
int main(){
    int n;
    cin >> n;
    vector<string> s;
    for(int i=0;i<n;i++){
        string ns;
        cin >> ns;
        s.push_back(ns);
    }

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

    // for(int i=0;i<n;i++) cout << s.at(i) << endl;

    int counter=1;
    for(int i=1;i<n;i++){
        if(s.at(i-1)!=s.at(i)) counter++;
    }

    cout << counter << endl;
}

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

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)n; ++i)
#define REP(i, a, b) for (int i = (int)a; i < (int)b; ++i)
#define each(i,c) for(__typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define all(v) v.begin(), v.end()
#define mset(a, n) memset(a, n, sizeof(a))

typedef long long ll;

const int INF = 1000000000;
const int MOD = 1000000007;

int main () {
    int N; cin >> N;
    vector<ll> march(5, 0);
    rep(i, N) {
        string S; cin >> S;
        if (S[0] == 'M') march[0]++;
        else if (S[0] == 'A') march[1]++;
        else if (S[0] == 'R') march[2]++;
        else if (S[0] == 'C') march[3]++;
        else if (S[0] == 'H') march[4]++;
    }

    ll ans = 0;
    rep(i, 3) REP(j, i+1, 4) REP(k, j+1, 5) {
        ans += march[i] * march[j] * march[k];
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
pub struct Scanner<R> {
    reader: R,
}

impl<R> Scanner<R> {
    pub fn new(reader: R) -> Scanner<R> {
        Scanner { reader }
    }
}

fn is_whitespace(b: u8) -> bool {
    b == b' ' || b == b'\n' || b == b'\r' || b == b'\t'
}

impl<R: std::io::Read> Scanner<R> {
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        let buf = std::io::Read::bytes(self.reader.by_ref())
            .map(|b| b.expect("Read failed"))
            .skip_while(|&b| is_whitespace(b))
            .take_while(|&b| !is_whitespace(b))
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error")
    }

    pub fn read_vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }

    pub fn read_chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}

fn main() {
    let stdin = std::io::stdin();
    let mut sc = Scanner::new(stdin.lock());
    loop {
        let m: usize = sc.read();
        let n_min: usize = sc.read();
        let n_max: usize = sc.read();
        if m == 0 {
            break;
        }
        let p: Vec<usize> = sc.read_vec(m);
        let mut ans = n_max;
        for n in (n_min..n_max).rev() {
            let diff = p[n - 1] - p[n];
            if diff > p[ans - 1] - p[ans] {
                ans = n;
            }
        }
        println!("{}", ans);
    }
}



Measured memory_bytes: 5044
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define whole(x) (x).begin(),(x).end()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
using ll = long long;
using P = pair<int, int>;
const int mod = 1000000007;


int main(){
    double a, b, x;
    cin >> a >> b >> x;
    x /= a;
    
    double ans;
    if (x<(0.5*a*b)) {
        double v = 2.0*x/b;
        ans = atan(b/v)*180.0/M_PI;
    }
    else {
        double v = 2.0*(a*b-x)/a;
        ans = atan(v/a)*180.0/M_PI;
    }
    
    printf("%.10f", ans);
    return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <cctype>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <utility>
#include <string>
#include <functional>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iomanip>
#include <bitset>
#define pb push_back
#define mp make_pair
#define YES cout<<"YES"<<endl
#define Yes cout<<"Yes"<<endl
#define NO cout<<"NO"<<endl
#define No cout<<"No"<<endl
#define INF (1<<30)
#define LLINF (1<<60)
#define MOD 1000000007
#define rep(i, n) for(int i=0;i<n;i++)
using ll = long long;
using namespace std;

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

    int n, a, b;
    cin >> n;
    if (n == 1)cout << "Hello World" << endl;
    else {
        cin >> a >> b;
        cout << a + b << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main()
{
	int A1, A2, A3;
	scanf("%d %d %d", &A1, &A2, &A3);
	if (A1+A2+A3>=22){
		printf("bust\n");
	}
	else if (A1+A2+A3<=22){
		printf("win\n");
		}
	return 0;
}

Measured memory_bytes: 2044
/* In the name of God */

#include<bits/stdc++.h>

using namespace std;
//#define int long long
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define F first
#define S second
#define IOS() ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define Dec cout<<fixed<< setprecision
#define endl "\n"
#define nlp printf("\n")
#define nl cout << "\n"
#define MP(make_pair)
#define SZ(x) (int) x.size()
#define tc() int t; cin >> t ; while (t--)
#define debug(x) cerr << "### " << #x << " is : " << x << " ###" << endl
#define clr(a) memset(a , 0 , sizeof a)
#define endl "\n"
#define bit(i , x) ((x >> i) & 1)
#define all(v) v.begin() , v.end()
typedef long long ll;
typedef pair<int,int> pii;
typedef long double ld;
typedef vector<int> VI ;
typedef vector<pii> VPI;

inline void smax(int &x , int y) { x = max(x , y) ; }
inline void smin(int &x , int y) { x = min(x , y) ; }
inline int in(){int32_t x ; scanf ("%d" , &x) ; return x ; }
inline ll lin(){ll x ; scanf ("%I64d" , &x) ; return x ; }
inline void out(int x){printf("%d " , x) ; }
inline void lout(ll x){printf("%I64d " , x) ; }

const int MOD = 1e9 + 7 ;
const ld EPS = 1e-9 ;
const int INF = 1e9 + 10 ;
const ll LINF = 1e18 ;
const int N = 1e3 + 10 ;
const int maxn = 1e4 + 10 ;
const int MAXN = 1e5 + 10 ;
const int MN = 1e6 + 10 ;
inline int powmod(int x , int y){ ll res = 1 , a = x ; while(y){if(y&1) res = (res*a)%MOD ;  a = (a*a)%MOD ; y >>= 1 ;} return res ; }

int n , m , cnt[MAXN] , par[MAXN] , dis[MAXN] ;
VI e[MAXN] ;

void dfs(int v , int p = -1){
	par[v] = p ;
	cnt[v] = 1 ;
	if(p != -1)
		dis[v] = dis[p] + 1 ;
	for(auto u : e[v]){
		if(u == p)
			continue ;
		dfs(u , v) ;
		cnt[v] += cnt[u] ;
	}
}


int32_t main (){
	IOS() ;
	cin >> n ; m = n-1 ;
	while(m--){
		int u , v ; cin >>u >> v ;
		e[u].pb(v) ;
		e[v].pb(u) ;
	}
	dfs(1) ;
	dis[n]-- ;
	dis[n]/= 2 ;
	int x = n ;
	while(dis[n]--){
		x = par[x] ;
	}
	if(cnt[x] >= n - cnt[x])
		cout << "Snuke" ;
	else
		cout << "Fennec" ;
}


Measured memory_bytes: 13184
n,a,b = gets.split.map(&:to_i)

if (a-b).even?
  p [[a,b].max - 1, n - [a,b].min - 1, (a-b).abs/2].min
else
  a,b = b,a if a > b
  x = a + ((b-a) - 1)/2

  k = n-b+1 
  y = k + (n-(a+k))/2
  p [x,y].min
end

Measured memory_bytes: 3836
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
 
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
 
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

n = input()
K = INT()
L = len(n)

# dp[L][k][2]

# k = 0 nと一致
# k = 1 nより小さい
dp = [[[0] * 2 for i in range(4)] for j in range(L+1)]
dp[0][0][0] = 1
for i in range(L):
    for j in range(4):
        for k in range(2):
            nd = int(n[i])
                
            for d in range(10):
                ni = i + 1
                nj = j
                nk = k

                if d != 0:
                    nj += 1
                # 設定してるKよりもnjが大きいならありえない
                if nj > K:
                    continue
                # 今までみたところ一致してたら
                if k == 0:
                    # 見てる数ndよりもdが大きかったら，
                    # それより大きい数字はない
                    if d > nd:
                        continue
                    # 次も同じなら一致してる
                    if d == nd:
                        nk = 0
                    # 違うなら一致してない
                    if d < nd:
                        nk = 1
                # print(ni, nj, nk)
                dp[ni][nj][nk] += dp[i][j][k]

ans = dp[L][K][0] + dp[L][K][1]
print(ans)
            
            


Measured memory_bytes: 5204
while True:
    a,b,c = input().split()
    if b=='?':
        break
    elif b =='+':
        d = int(a) + int(c)
    elif b=='-':
        d = int(a) - int(c)
    elif b=='*':
        d = int(a)*int(c)
    else :
        d = int(a)/int(c)
    print(int(d))

Measured memory_bytes: 7556
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
#include<vector>
#include<functional>
#include<iomanip>
using namespace std;

int main()
{
	string s;
	cin >> s;
	cout << s[0] << s.size() - 2 << s[s.size() - 1] << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void)
{
  int a,b,c,i,atai;
  atai=0;
  scanf("%d %d %d",&a,&b,&c);
  for(i=a;i<=b;i++){
    if((c%i)==0){
      atai+=1;
    }
  }
  printf("%d\n",atai);
  return 0;
}

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

const int INF = 1000000000;

int main(){
	while(true){
		int n, m;
		cin >> n >> m;

		if(n==0 && m==0)
			break;

		int C[100][100];
		int T[100][100];
		for(int i=0; i<m; i++){
			for(int j=0; j<m; j++){
				if(i==j){
					C[i][j] = T[i][j] = 0;
				}
				else{
					C[i][j] = T[i][j] = INF;
				}
			}
		}

		for(int i=0; i<n; i++){
			int a, b, c, t;
			cin >> a >> b >> c >> t;

			C[a-1][b-1] = C[b-1][a-1] = c;
			T[a-1][b-1] = T[b-1][a-1] = t;
		}

    int cd[m][m];
    int td[m][m];

    for(int i=0; i<m; i++){
      for(int j=0; j<m; j++){
        cd[i][j] = C[i][j];
      }
    }
    for(int i=0; i<m; i++){
      for(int j=0; j<m; j++){
        td[i][j] = T[i][j];
      }
    }

    for(int h=0; h<m; h++){
      for(int i=0; i<m; i++){
        for(int j=0; j<m; j++){
          if(cd[i][j] > cd[i][h]+cd[h][j]){
            cd[i][j] = cd[i][h]+cd[h][j];
          }
        }
      }
    }

    for(int h=0; h<m; h++){
      for(int i=0; i<m; i++){
        for(int j=0; j<m; j++){
          if(td[i][j] > td[i][h]+td[h][j]){
            td[i][j] = td[i][h]+td[h][j];
          }
        }
      }
    }

    int k;
    cin >> k;

    while(k>0){
      int p,q,r;
      cin >> p >> q >> r;

      if(r==0){
        cout << cd[p-1][q-1] << '\n';
      }else if(r==1){
        cout << td[p-1][q-1] << '\n';
      }

      k--;
    }

	}

	return 0;
}



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

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    long long x;
    cin>>x;
    if(x>=30)
    {
        cout<<"Yes"<<endl;
    }
    else{
        cout<<"No"<<endl;
    }
}


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

#ifdef LOCAL
#define debug(var) cerr << (#var) << " = " << (var) << endl;
#else
#define debug(var)
#endif

void init() {
  ios_base::sync_with_stdio(0);
  cin.tie(0); cout.tie(0);
}

const int N = 1e5+23;

long long a[N];

void solve() {
  int n; scanf("%d", &n);
  for (int i = 1; i <= n; ++i) {
    scanf("%lld", a+i);
    if (i%2) {
      a[i] += a[i-1];
    } else {
      a[i] = a[i-1] - a[i];
    }
  }
  for (int i = 1; i <= n; ++i) {
    if (i%2) {
      printf("%lld ", a[n]-2*a[i-1]);
    } else {
      printf("%lld ", 2*a[i-1]-a[n]);
    }
  }
}

int main() {
  init();
  int t = 1; //scanf("%d", &t);
  while (t--) {
    solve();
  }
  return 0;
}


Measured memory_bytes: 2176
import itertools 
N=int(input())
L=list(map(int,input().split()))
result=[]
for pair in itertools.combinations(L, 3):
	result.append(list(pair))
count=0
for i in range(len(result)):
	result[i].sort()
	if result[i][0]!=result[i][1] and result[i][0]!=result[i][2] and result[i][1]!=result[i][2] and (result[i][0]+result[i][1])>result[i][2]:
		count+=1
print(count)

Measured memory_bytes: 25496
#include <iostream>
#include <algorithm>
using namespace std;
int main() {
    int n;
    cin >> n;
    long t = 0, m = -1;
    for (int i = 0; i < n; i++) {
        long a;
        cin >> a;
        if (a < m) {
            t += m - a;
        } else {
            m = a;
        }
    }
    cout << t << endl;
}


Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int lim = 2e5+5;
pair<int,int> jobs[lim];

bool comp(const pair<int,int>& a,const pair<int,int>& b) {
	return a.second<b.second;
}

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

    int n;
    cin>>n;
    for(int i=0;i<n;i++)
    	cin>>jobs[i].first>>jobs[i].second;
	sort(jobs,jobs+n,comp);

	int l = 0;
	for(int i=0;i<n;i++) {
		if(l+jobs[i].first>jobs[i].second) {
			cout<<"No";
			return 0;
		}
		l += jobs[i].first;
	}

	cout<<"Yes";
	return 0;
}

Measured memory_bytes: 1920
#include<iostream>
#include<algorithm>
#include<vector>
#include<complex>
#define X first
#define Y second
#define F 1145141919
using namespace std;

vector<pair<int,int> > v[160];
int dp[80][160][12],n,m,k;

int Jump(int a,int b,int c,int d){
	if(v[a][b].X==-1||v[c][d].X==-1)return 0;
	int ret=abs(v[a][b].X-v[c][d].X);
	ret*=v[a][b].Y+v[c][d].Y;
	return ret;
}

int main(){
	pair<int,int> p;
	p.X=-1,p.Y=-1;
	v[0].push_back(p);
	while(cin>>n>>m&&n){
	for(int i=1;i<=n;i++){
		cin>>k;v[i].clear();
		while(k--){
			cin>>p.X>>p.Y;
			v[i].push_back(p);
		}
	}
	v[n+1].clear();p.X=-1,p.Y=-1;v[n+1].push_back(p);

	for(int i=0;i<80;i++)for(int j=0;j<160;j++)for(int k=0;k<12;k++)dp[i][j][k]=F;

	for(int i=0;i<=m;i++)dp[i][0][0]=0;

	for(int i=0;i<=m;i++){
		for(int f=0;f<=n;f++){
			for(int g=0;g<v[f].size();g++){
				for(int k=0;k<v[f+1].size();k++){
					dp[i][f+1][k]=min(dp[i][f+1][k],dp[i][f][g]+Jump(f,g,f+1,k));
				}
				if(f!=n&&i!=m){for(int k=0;k<v[f+2].size();k++){
					dp[i+1][f+2][k]=min(dp[i+1][f+2][k],dp[i][f][g]+Jump(f,g,f+2,k));
				}}
			}
		}
	}

	int ans=F;
	for(int i=0;i<=m;i++){
		ans=min(ans,dp[i][n+1][0]);
	}
	cout<<ans<<endl;
	}
	return 0;
}

Measured memory_bytes: 3708
#include <bits/stdc++.h>
#define pb  push_back
#define pob pop_back
#define int long long
#define N 100001
using namespace std;


vector<int>v[N];
queue<int>q;
int visit[N];
int a,b,n,ans,k;
int dp[N];


void dfs(int u,int p){
	visit[u]=1;
	for(int i=0;i<v[u].size();i++){
		if(visit[v[u][i]]==0 && v[u][i]!=p){
			visit[u]=1;
			dfs(v[u][i],u);
		}
	}
	q.push(u);
}

int32_t main(){
	//freopen("all.in","r",stdin);
	//freopen("all.out","w",stdout);
	scanf("%lld %lld",&k,&n);
	for(int i=0;i<n;i++){
		scanf("%lld %lld",&a,&b);
		v[a].pb(b);
	}
	for (int i = 1; i <= k; ++i){
		if(visit[i]==0)
			dfs(i,i);
	}
	while(!q.empty()){
		k=q.front();
		//printf("%lld\n",k );
		for(int i=0;i<v[k].size();i++){
			dp[k]=max(dp[k],dp[v[k][i]]+1);
		}
		ans=max(ans,dp[k]);
		q.pop();
	}
	printf("%lld",ans);
	return 0;
}

Measured memory_bytes: 10112
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <algorithm>
#include <climits>
#include <cstring>
#include <cmath>
#include <stack>
#include <iomanip>
#include <tuple>
#include <functional>
#include <cfloat>
#include <map>
#include <set>
#include <array>
#include <stdio.h>
#include <string.h>
using ll = long long;
using ull = unsigned long long;
using namespace std;
//LLONG_MAX = 90^18
#define int long long
#define CONTAINS(v,n) (find((v).begin(), (v).end(), (n)) != (v).end())
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
#define ARY_SORT(a, size) sort((a), (a)+(size))
#define REMOVE(v,a) (v.erase(remove((v).begin(), (v).end(), (a)), (v).end()))
#define REVERSE(v) (reverse((v).begin(), (v).end()))
#define ARY_REVERSE(v,a) (reverse((v), (v)+(a)))
#define LOWER_BOUND(v,a) (lower_bound((v).begin(), (v).end(), (a)))
#define UPPER_BOUND(v,a) (upper_bound((v).begin(), (v).end(), (a)))
#define REP(i, n) for (int (i)=0; (i) < (n); (i)++)
#define CONTAINS_MAP(m, a) (m).find((a)) != m.end()
void YesNo(bool b) { cout << (b ? "Yes" : "No"); }
void Yes() { cout << "Yes"; }
void No() { cout << "No"; }
//max_element

int N;
int A[200010];
int B[200010];
vector<int> sort_A;
vector<int> sort_B;


signed main()
{
	cin >> N;
	REP(i, N)
	{
		cin >> A[i] >> B[i];

		sort_A.push_back(A[i]);
		sort_B.push_back(B[i]);
	}

	SORT(sort_A);
	SORT(sort_B);

	if (N % 2 == 0)
	{
		int a1 = sort_A[N / 2 - 1];
		int b1 = sort_B[N / 2 - 1];
		int a2 = sort_A[N / 2];
		int b2 = sort_B[N / 2];

		int a = (a2 + a1);
		int b = (b2 + b1);

		cout << (b - a) + 1 << endl;
	}
	else
	{
		int a = sort_A[N / 2];
		int b = sort_B[N / 2];
		cout << (b - a) + 1 << endl;
	}
}




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

using namespace std;

int main(){
	long long r, d, x;
	scanf("%lld%lld%lld", &r, &d, &x);
	
	for(int i = 1; i <= 10; i ++){
		x = x*r-d;
		printf("%lld\n", x);
	}
	
	return 0;
}


Measured memory_bytes: 256
from math import ceil 
N = int(input())
votes = [1,1]
rate = 1
for i in range(N):
    t,a = map(int,input().split())
    rate = max((votes[0] - 1) // t, (votes[1] - 1) // a) + 1
    # if t * rate >= votes[0] and a * rate >= votes[1]:
    votes = [t * rate, a * rate]

print(sum(votes))

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,k;
    scanf("%d%d",&n,&k);
    if(k<= (1<<n)-1&&!(n==k&&k==1))
    {
        int pos=0;
        if(k==0)
        {
            for(int i=1; i<=1<<(n+1); i++)
            {
                printf("%d ",(i-1)/2);
            }
        }
        else
        {
            for(int i=1; i<=1<<(n+1); i++)
            {
                if(i==1<<(n+1)||i==1<<n)
                {
                    printf("%d ",k);
                }
                else
                {

                    printf("%d ",pos);
                    if(i<(1<<n)-1) pos++;
                    else if(i==(1<<n)-1) continue;
                    else pos--;
                    if(pos==k)
                    {
                        if(i<(1<<n)-1) pos++;
                        else if(i==(1<<n)-1) continue;
                        else pos--;
                    }
                }

            }
        }
    }
    else
    {
        printf("-1");
    }
}


Measured memory_bytes: 1792
#include <stdio.h>
#include <stdlib.h>
#define N 2000000
int n;
void Counting_Sort(int *A, int *B, int k){
  int i, j, C[10001];
  for(i = 0; i <= k; i++) C[i] = 0;
  for(j = 0; j < n; j++) C[A[j]]++;
  for(i = 0; i <= k; i++) C[i+1] = C[i] + C[i+1];
  for(j = n-1; j >= 0; j--){
    B[C[A[j]]-1] = A[j];
    C[A[j]]--;
  } 
}
int main(){
  int i, A[N], *B;
  scanf("%d",&n);
  for(i = 0; i < n; i++) scanf("%d",&A[i]);
  B = malloc(sizeof(int)*n);
  Counting_Sort(A, B, 10000);
  for(i = 0; i < n; i++){
    if(i > 0) printf(" ");
    printf("%d",B[i]);
  }
  printf("\n");
  free(B);
  return 0;
}

Measured memory_bytes: 16124
def xgcd(a, b):
    x0, y0, x1, y1 = 1, 0, 0, 1
    while b != 0:
        q, a, b = a // b, b, a % b
        x0, x1 = x1, x0 - q * x1
        y0, y1 = y1, y0 - q * y1
    return a


import random
def is_prime(q, k=50):
    q = abs(q)
    if q == 2:
        return True
    if q < 2 or q % 2 == 0:
        return False

    d = (q - 1) >> 1
    while d & 1 == 0:
        d >>= 1
    for i in range(k):
        a = random.randint(1, q - 1)
        t = d
        y = pow(a, t, q)
        while t != q - 1 and y != 1 and y != q - 1:
            y = pow(y, 2, q)
            t <<= 1
        if y != q - 1 and t & 1 == 0:
            return False
    return True

def prime_num(target):
    ra = 2
    prime = 0
    while target>1:
        if target%ra == 0:
            prime += 1
            while target%ra==0:
                target = target//ra
            if is_prime(target):
                prime += 1
                break
        if ra == 2:
            ra += 1
        else:
            ra += 2
    return prime   
        
a, b = map(int, input().split())
gcd = xgcd(a, b)
if gcd == 1:
    print(1)
elif is_prime(gcd):
    print(2)
else:
    ans = prime_num(gcd)    
    print(ans+1)

Measured memory_bytes: 3824
//#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>

using namespace std;


void solve() {
    int N; cin >> N;
    vector<int> A(N);
    for (int i = 0; i < N; i++) cin >> A[i];

    map<int, long long> mp;

    for (int i = 0; i < N; i++) mp[i+1] = 0;
    for (int i = 0; i < N; i++) mp[A[i]]++;

    long long cnt = 0;
    for (int i = 1; i <= N; i++) {
        if (mp[i] != 0 && mp[i] != 1) cnt += mp[i] * (mp[i]-1) / 2;
    }

    for (int i = 0; i < N; i++) {
        long long ans = cnt;
        if (mp[A[i]] == 1) cout << ans << endl;
        else {
            ans = ans - mp[A[i]] * (mp[A[i]]-1) / 2 + (mp[A[i]]-1) * (mp[A[i]]-2) / 2;
            cout << ans << endl;
        }
    }
}


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

Measured memory_bytes: 15872
def main():
    from collections import Counter as ct
    n = int(input())
    s = list(map(int, input().split()))
    a = ct(s)
    a2 = sorted([i for i, j in a.items() if j == 1])
    a3 = sorted([i for i, j in a.items() if j > 1])
    s = set(s)

    ans = 0
    for i in a3:
        if i in s:
            k = i
            while k <= 10**6:
                if k in s:
                    s.remove(k)
                k += i
    for i in a2:
        if i in s:
            ans += 1
            k = i
            while k <= 10**6:
                if k in s:
                    s.remove(k)
                k += i
    print(ans)


main()


Measured memory_bytes: 48164
#include <bits/stdc++.h>
#define l_ength size
using ll = long long;
const int mod = 1000000007;
const int inf = (1<<30);
const ll infll = (1ll<<60);
using namespace std;

int sz;
vector<bitset<26>> st(10000010);

void init( int n ){
	sz = 1;
	while( sz < n ) sz = 2*sz;
}

void update( int k, int a ){
	k += sz-1;
	st[k] &= 0;
	st[k] |= (1<<a);
	while( k ){
		k = (k-1)/2;
		st[k] = st[2*k+1] | st[2*k+2];
	}
}

bitset<26> query( int a, int b, int k = 0, int l = 0, int r = sz ){
	if( b <= l || r <= a ){
		bitset<26> temp;
		return temp;
	} else if( a <= l && r <= b) {
		return st[k];
	} else {
		bitset<26> temp = query( a, b, 2*k+1, l, (l+r)/2 ) bitor query( a, b, 2*k+2, (l+r)/2, r );
		return temp;
	}
}

int main(){
	int n; cin >> n;
	init(n+3);
	string s; cin >> s;
	for( int i = 0; i < n; ++i ) update( i, (int)(s[i]-'a') );
	int q; cin >> q;
	while( q-- ){
		int t; cin >> t;
		if( t == 1 ){
			int i; char c; cin >> i >> c;
			update( i-1, c-'a' );
		} else {
			int l, r; cin >> l >> r;
			--l; --r;
			cout << query(l, r+1).count() << endl;
		}
	}
}

Measured memory_bytes: 79108
-- for safety(?)
floorThird :: Integral a => a -> a
floorThird n
        | n' == n = third
        | n' < n = if (third+1)^3 <= n
                            then third+1
                            else third
        | n' > n = third-1
        where third = floor $ (fromIntegral n)**(1/3)
              n' = third^3

solve :: Int -> Int
solve z = z^3 - maximum (cands z)

cands :: Int -> [Int]
cands z = [x3+y^3 | x3 <- map (^3) [1..z-1], let y = floorThird (z^3-x3)]

main = getContents >>=
        mapM_ (print . solve) . takeWhile (/= 0) . map read . lines

Measured memory_bytes: 5680
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,sum=0;
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=n;j++)
		for(int z=1;z<=n;z++)
		sum++; 
	}
	cout<<sum;
	return 0;
}

Measured memory_bytes: 256