akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; ++i)
#define FOR(i, a, b) for (int i = a; i < b; ++i)
using namespace std;
using ll = long long;

int main() {
    int N;
    cin >> N;
    int ans = 0;
    rep(i, N) {
        int a;
        cin >> a;
        while (a % 2 == 0) {
            a /= 2;
            ans += 1;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef vector<int> VI;

template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()


int main() {
    int n;
    cin >> n;
    vector<int> x(n), y(n), h(n);
    int base;
    rep (i, n) {
        cin >> x[i] >> y[i] >> h[i];
        if (h[i] != 0) {
            base = i;
        }
    }
    rep (cx, 101) {
        rep (cy, 101) {
            int H = abs(cx - x[base]) + abs(cy - y[base]) + h[base];
            rep (i, n) {
                if (max(H - abs(cx - x[i]) - abs(cy - y[i]), 0) != h[i]) {
                    break;
                } else if (i == n - 1) {
                    printf("%d %d %d\n", cx, cy, H);
                    exit(0);
                }
            }
        }
    }
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int,input().split()))

waru = 7 + 1000000000

asum = 0

for i in a:
  asum += i
  
mod = 0
asum -= a[0]
for i in range(len(a)-1):

  mo = (a[i] * (asum)) % waru
  mod += mo

  asum -= a[i+1]
  
print(mod % waru)

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

using namespace std;
using ll = long long;

#pragma region Macros
#define FOR(i, m, n) for (ll i = (ll)(m); i < (ll)(n); i++)
#define rep(i, n) FOR(i, 0, n)

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

template <class T> string join(const T &v, const string delim = ",")
{
    if (v.empty())
        return "";

    ostringstream res;
    res << v[0];
    for (int i = 1; i < v.size(); i++)
    {
        res << delim << v[i];
    }
    return res.str();
}

#ifdef LOCAL
#define dbg(x) cerr << __LINE__ << ":" << #x << " = " << (x) << endl;
#else
#define dbg
#endif

#pragma endregion Macros

int main()
{
    ll A,B,C;
    cin >> A >> B >> C;

    string ans = "NO";
    for (int n = 1; n < 1100100; n++) {
        if((n*A)%B == C) {
            ans = "YES";
            break;
        }
    }

    cout << ans << endl;
}


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

int main() {
    int n, k;
    cin >> n >> k;
    vector<int> fruit(n,0);
    for (int i = 0; i < n; i++) {
        cin >> fruit.at(i);
    }
    sort(fruit.begin(), fruit.end());
    long long sum = 0;
    for (int i = 0; i < k; i++) {
        sum += fruit.at(i);
    }
    cout << sum << endl;
}

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

int main() {
  ll a, b, x;
  cin >> a >> b >> x;
  if (a%x)
    cout << b/x - a/x << endl;
  else
    cout << b/x - a/x + 1 << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstdlib>
#include <vector>
#include <array>
#include <map>
#include <algorithm>
#include <queue>
#include <stack>
#include <cmath>
#include <climits>

using namespace std;
typedef long long int ll;


int main(int argc, char const *argv[])
{
	ll n;
	cin >> n;
	vector<double> a(n);
	for (ll i = 0; i < n; i++)
	{
		cin >> a[i];
	}

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

	double sum = a[0];

	for (ll i = 1; i < n; i++)
	{
		sum += a[i];
		sum /= 2;
	}

	cout << sum << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main
{
  public static void main(String[]args)
  {
    Scanner input=new Scanner(System.in);
    int a=input.nextInt(),b=input.nextInt(),c=input.nextInt();
    int count=a,lim=b,divc=0;
    while(count<=lim)
    {
      if(c%count==0)
      {
        divc++;
        count++;
      }
      else
        count++;}
    System.out.println(divc);
  }
}


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

signed main() {
	int n;
	string s;
	cin >> n >> s;
	int ans = 0;
	rep(i, n-2){
		if(s[i] == 'A' && s[i+1] == 'B' && s[i+2] == 'C') ans++;
	}
	cout << ans << endl;
}


Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#include <map>
#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 INF 2e9
#define ALL(v) v.begin(), v.end()
typedef long long ll;



int main(){
    ll h,n;
    cin >> h >> n;
    vector<ll> a(n);
    REP(i,n){
        cin >> a[i];
    }
    ll max = accumulate(a.begin(),a.end(),0);
    if(max >= h){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
}


Measured memory_bytes: 1024
"""
あ
あ
あ
あ
あ
あ
あ
あ
あ
あ
あ
あ
あ
あ
あ
あ
あ
あ
あ
あ
あ
あ
あ
あ
あ
あ
あ
あ
あ
あ
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
みたな？































"""
import sys
input = sys.stdin.readline
N, K  = map(int, input().split())
e = [[] for _ in range(N + 1)]
mod = 10 ** 9 + 7
for _ in range(N - 1):
  u, v = map(int, input().split())
  e[u].append(v)
  e[v].append(u)

class Factorial:
  def __init__(self, n, mod):
    self.mod = mod
    self.f = [1]
    for i in range(1, n + 1):
      self.f.append(self.f[-1] * i % mod)
    self.i = [pow(self.f[-1], mod - 2, mod)]
    for i in range(1, n + 1)[: : -1]:
      self.i.append(self.i[-1] * i % mod)
    self.i.reverse()
  def factorial(self, i):
    return self.f[i]
  def ifactorial(self, i):
    return self.i[i]
  def combi(self, n, k):
    return self.f[n] * self.i[n - k] % self.mod * self.i[k] % self.mod
  def permi(self, n, k):
    return self.f[n] * self.i[n - k] % self.mod

f = Factorial(N + K, mod)
s = [1]
vis = [0] * (N + 1)
res = f.permi(K, len(e[1]) + 1)
if K < len(e[1]) + 1: res = 0
while len(s):
  x = s.pop()
  vis[x] = 1
  for y in e[x]:
    if vis[y]: continue
    s.append(y)
    if K - 2 < 0 or (K - 2 < len(e[y]) - 1): res = 0
    res *= f.permi(K - 2, len(e[y]) - 1)
    res %= mod
print(res)

Measured memory_bytes: 124800
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main(){
    input!{
        n: usize,
        l: [i32; n],
    }
    
    let max = l.iter().fold(0,|x, y| if x > *y { x} else{ *y });
    let sum : i32 = l.into_iter().sum();
    println!("{}", if 2*max < sum { "Yes"} else {"No"});
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i < (n); i++)
using namespace std;
using ll = long long;
int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i,n) cin >> a[i];
  double total=0;
  rep(i,n){
    total += a[i];
  }
  int p;
  p = round(total/n);
  int sum=0;
  rep(i,n) sum += pow(a[i]-p,2);
  cout << sum << endl;
}

Measured memory_bytes: 256
#pragma warning(disable:4996)
#include <bits/stdc++.h>

using namespace std;

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

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

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

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

TPL<TNM V, TNM H> void resize(vector<V>& v, const H h) { v.resize(h); }
TPL<TNM V, TNM H, TNM ... T> void resize(vector<V>& v, const H& h, const T ... t) { v.resize(h); for (auto& _v : v) resize(_v, t ...); }
TPL<TNM V, TNM T> void fill(V& x, const T& val) { x = val; }
TPL<TNM V, TNM T> void fill(vector<V>& vec, const T& val) { for (auto& v : vec) fill(v, val); }

bool f() {
	int A, B;
	cin >> A >> B;
	if (A > 8 || B > 8)return false;
	else return true;
}

int main(void) {
	bOUT(f(), "Yay!", ":(" );
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#define REP(i,n) for (int i=0;i<(n);i++)
#define FOR(i,a,b) for (int i=(a);i<(b);i++)

using namespace std;

int main()
{
    int a[4], b[4];
    while (cin >> a[0] >> a[1] >> a[2] >> a[3]) {
        int hit = 0, blow = 0;
        cin >> b[0] >> b[1] >> b[2] >> b[3];
        REP(i, 4) {
            REP(j, 4) {
                if (a[i] == b[j]) {
                    if (i == j) {
                        hit++;
                    } else {
                        blow++;
                    }
                }
            }
        }
        cout << hit << " " << blow << endl;
    }
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
#define pb push_back
#define fs first
#define sc second
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x).size()
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<double> vd;
typedef pair<int, int> pii;
typedef vector<pii> vpii;

int main() {
	int i, n, s=0, t;
	scanf("%d", &n);
	for(i=0; i<n; i++) {
		scanf("%d", &t);
		s^=t;
	}
	printf(s&1? "NO\n":"YES\n");
   	return 0;
}

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

using namespace std;
using ll = long long;

ll hoge(string s, ll a, ll b) {
  ll cnt = 0;
  ll c = 1;
  for (ll i = b - 1; a <= i; --i) {
    if (s[i] != 'A')
      continue;
    cnt += b - i - c;
    ++c;
  }
  return cnt;
}

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

  ll pos = s.find("BC");
  while (pos != static_cast<ll>(string::npos)) {
    s.replace(pos, 2, "D ");
    pos = s.find("BC", pos + 2);
  }

  string s2;
  for (auto &v : s)
    if (v != ' ')
      s2 += v;
  s = s2;

  ll cnt = 0;
  ll n = static_cast<ll>(s.size());
  ll a = 0;
  for (ll i = a + 1; i < n; ++i) {
    if (s[i] != 'B' and s[i] != 'C')
      continue;
    cnt += hoge(s, a, i);
    a = i + 1;
  }
  cnt += hoge(s, a, n);
  cout << cnt << endl;
}

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

using namespace std;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define itn int

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


int main()
{
  string s;
  cin >> s;
  string akiba = "KIHBR";

  int now = 0;
  for (int i = 0; i < int(s.size()); i++)
  {
    if(s[i] != akiba[now] && s[i] != 'A')
    {
      cout << "NO" << endl;
      return 0;
    }
    if(s[i] == akiba[now]) now++;
  }

  now = 0;
  akiba = "AKIHABARA";
  int count = 0;
  for (int i = 0; i < int(s.size()); i++)
  {
    if(s[i] != akiba[now])
    {
      if(akiba[now] == 'A'){
        i--;
        now++;
        count++;
        continue;
      }
      else{
        cout << "NO" << endl;
        return 0;
      }
    }
    now++;
  }
  if(s[s.size()-1] == 'R') count++;

  if(count + int(s.size()) != 9) cout << "NO" << endl;
  else cout << "YES" << endl;

}

Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	int n,m,x[1001],w,cnt[1001],max,s,i,j;
	scanf("%d%d",&n,&m);
	for(i=0;i<n;i++){
		scanf("%d",&x[i]);
		cnt[i]=0;
	}
	for(i=0;i<m;i++){
		scanf("%d",&w);
		for(j=0;j<n;j++){
			if(x[j]<=w){
				cnt[j]++;
				break;
			}
		}
	}
	max=-1;
	for(i=0;i<n;i++){
		if(max<cnt[i]){
			max=cnt[i]; s=i+1;
		}
	}
//	for(i=0;i<n;i++) printf("%d\n",cnt[i]);
	printf("%d\n",s);
	return 0;
}

Measured memory_bytes: 1860
import java.util.Scanner;

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

		int sum;
		int score[] = new int[3];

		score[0] = sc.nextInt();
		score[1] = sc.nextInt();
		score[2] = sc.nextInt();

		while(score[0] != -1 || score[1] != -1 || score[2] != -1){
			sum = score[0] + score[1];

			if(score[0] == -1 || score[1] == -1){
				System.out.println("F");
			}else if(sum >= 80){
				System.out.println("A");
			}else if(sum >= 65){
				System.out.println("B");
			}else if(sum >= 50){
				System.out.println("C");
			}else if(sum >= 30){
				if(score[2] >= 50) System.out.println("C");
				else System.out.println("D");
			}else{
				System.out.println("F");
			}

			score[0] = sc.nextInt();
			score[1] = sc.nextInt();
			score[2] = sc.nextInt();
		}
	}
}


Measured memory_bytes: 26468
A,B,C=map(int,input().split())#どれか１つでも偶数ならばans=0
l=[A,B,C]
for i in range(3):
    if l[i]%2==0:
        print(0)
        exit()
#以下すべて奇数の場合）
x=(A//2 +1)*B*C-(A//2)*B*C
y=A*(B//2 +1)*C-A*(B//2)*C
z=A*B*(C//2 +1)-A*B*(C//2)
print(min(x,y,z))

Measured memory_bytes: 3064
/*---------------Go Code GO---------------*/

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

#define     PI              acos(-1.0)
#define     O_O             ios_base::sync_with_stdio(false); cin.tie(NULL)
#define     precision(a)    fixed<<setprecision(a)
#define     endl            '\n'
#define     Flush           cout<<flush
#define     LLMX            0x3fffffffffffffff
#define     PW2(a)          (long long)1<<a

long long ar[500005];

int main()
{
    long long i,j,k,l,m,n,o,p,q,r,tst,ans=0;
    cin>>ar[0]>>ar[1]>>ar[2];
    bool pos=false;
    for(i=0; i<10; i++)
    {
        next_permutation(ar, ar+3);
        if(ar[0]==ar[1]&&ar[0]!=ar[2])
        {
            pos=true;
            break;
        }

    }
    if(pos)
    {
        cout<<"Yes"<<endl;
    }
    else
        cout<<"No\n";

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
template<class S, class T> inline S min_L(S a,T b){
  return a<=b?a:b;
}
inline void rd(int &x){
  int k, m=0;
  x=0;
  for(;;){
    k = getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
inline void wt_L(char a){
  putchar_unlocked(a);
}
inline void wt_L(int x){
  char f[10];
  int m=0, s=0;
  if(x<0){
    m=1;
    x=-x;
  }
  while(x){
    f[s++]=x%10;
    x/=10;
  }
  if(!s){
    f[s++]=0;
  }
  if(m){
    putchar_unlocked('-');
  }
  while(s--){
    putchar_unlocked(f[s]+'0');
  }
}
int N;
int A[200];
int cnt[200];
int main(){
  int i, res;
  rd(N);
  {
    int Lj4PdHRW;
    for(Lj4PdHRW=0;Lj4PdHRW<N;Lj4PdHRW++){
      rd(A[Lj4PdHRW]);
    }
  }
  for(i=0;i<N;i++){
    while(A[i]%2==0){
      A[i] /= 2;
      cnt[i]++;
    }
  }
  {
    int KL2GvlyY, Q5VJL1cS;
    if(N==0){
      Q5VJL1cS = 0;
    }
    else{
      Q5VJL1cS = cnt[0];
      for(KL2GvlyY=1;KL2GvlyY<N;KL2GvlyY++){
        Q5VJL1cS = min_L(Q5VJL1cS, cnt[KL2GvlyY]);
      }
    }
    res =Q5VJL1cS;
  }
  wt_L(res);
  wt_L('\n');
  return 0;
}
// cLay varsion 20190721-1

// --- original code ---
// int N, A[200], cnt[200];
// {
//   int i, res;
//   rd(N, A(N));
// 
//   rep(i,N) while(A[i]%2==0) A[i] /= 2, cnt[i]++;
// 
//   res = min(cnt(N));
//   wt(res);
// }


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

using namespace std;

int main()
{
//    ifstream cin("input.txt");
    char s[3];
    cin>>s;
    if (strcmp(s,"RRR")==0) cout<<3;
    else if (strcmp(s,"RRS")==0) cout<<2;
    else if (strcmp(s,"RSR")==0) cout<<1;
    else if (strcmp(s,"RSS")==0) cout<<1;
    else if (strcmp(s,"SRR")==0) cout<<2;
    else if (strcmp(s,"SRS")==0) cout<<1;
    else if (strcmp(s,"SSR")==0) cout<<1;
    else cout<<0;
}


Measured memory_bytes: 3636
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <cassert>
#include <cfloat>
#include <complex>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

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

#define MOD 1000000007

int main() {
  ll N;

  cin >> N;

  vector<double> lst(N + 1);
  vector<vector<double> > dp(N + 1, vector<double>(N + 1, 0.0));

  for (int i = 1; i <= N; i++) {
    cin >> lst[i];
  }

  dp[0][0] = 1.0;
  for (int i = 1; i <= N; i++) {
    for (int j = 0; j <= i; j++) {
      dp[i][j] = lst[i] * dp[i - 1][j - 1] + (1 - lst[i]) * dp[i - 1][j];
    }
  }

  double ans = 0;
  for (int i = N / 2 + 1; i <= N; i++) {
    ans += dp[N][i];
  }

  printf("%.011f\n", ans);

  return 0;
}


Measured memory_bytes: 70656
#include <iostream>
#include <algorithm>
#include <stdlib.h>
#include <string>
#include <queue>
using namespace std;
int main(){
int n,ans,r,l;
string s,t;
while(cin>>n && n>0){
ans=0;
r=0;
l=0;
for(int i=0;i<n/2;i++){
cin>>s>>t;
if((s=="lu"&&t=="ru")||(t=="lu"&& s=="ru")||(s=="ld"&&t=="rd")||(s=="rd"&&t=="ld")) ans++;


}
if(n%2==1) cin>>s;

cout<<ans<<endl;

}



return 0;
}

Measured memory_bytes: 1208
import math

def partition(A, p, r):
    x = A[r].num
    i = p
    for j in range(p, r):
        if x >= A[j].num:
            A[j], A[i] = A[i], A[j]
            i += 1
    A[i], A[r] = A[r], A[i]
    return i
    
def quickSort(A, p, r):
    if p < r:
        q = partition(A, p, r)
        quickSort(A, p, q-1)
        quickSort(A, q+1, r)


def merge(A, left, mid, right):
    L, R = [], []
    for a in A[left:mid]:
        L.append(a)
    for a in A[mid:right]:
        R.append(a)
    L.append(Card("dummy 0"))
    R.append(Card("dummy 0"))
    L[-1].num = math.inf
    R[-1].num = math.inf
    i, j = 0, 0
    for k in range(left, right):
        if L[i].num <= R[j].num:
            A[k] = L[i]
            i += 1
        else:
            A[k] = R[j]
            j += 1

def mergeSort(A, left, right):
    if right - left > 1:
        mid = (right + left) // 2
        mergeSort(A, left, mid)
        mergeSort(A, mid, right)
        merge(A, left, mid, right)

class Card(str):
    def __init__(self, input_card):
        super().__init__
        self.num = int(input_card.split(" ")[-1])

N = int(input().rstrip())
A = []
for _ in range(N):
    A.append(Card(input().rstrip()))

A_2 = A.copy()

quickSort(A, 0, len(A)-1)
mergeSort(A_2, 0, len(A))

stable = True
for a_1, a_2 in zip(A, A_2):
    if a_1 != a_2:
        stable = False
        break
print("Stable" if stable else "Not stable")
for a in A:
    print(a)


Measured memory_bytes: 35676
#include <stdio.h>

int main(){
    int yen;
    scanf("%d", &yen);
    int flag = 0;
    int c=1000;
    
    if (yen <= c){
        printf("%d\n", c-yen);
    }
    else{
        while (flag == 0){
            c+=1000;
            if (yen<=c){
                printf("%d\n", c-yen);
                break;
            }
        }
    }
    
    return 0;
}


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

const long mod = 1e9+7;

long power(long a,long b)
{
  return b ? power(a * a % mod, b / 2) * (b % 2 ? a : 1) % mod : 1;
}

long comb(long a, long b)
{
  long res = 1;
  for (long i = a; i > a - b; i--)
  {
    res = res * i % mod;
  }
  for (long i = 1; i <= b; i++)
  {
    res = (res * power(i, mod - 2)) % mod;
  }
  return res;
}

int main()
{
  long N, A, B;
  cin >> N >> A >> B;
  long ans = power(2, N);
  ans--;
  ans -= comb(N, A);
  ans -= comb(N, B);
  while (ans < 0) ans += mod;
  cout << ans << "\n";
}


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

int gcd(int a, int b) {
	if(a == 0 || b == 0)
      return max(a, b);
  	return gcd(b%a, a);
}

int lcm(int a, int b) {
	return (1ll*a*b)/gcd(a, b);
}

int main() {
  int x;
  cin >> x;
  int l = lcm(x, 360);
  cout << l/x << "\n";
  return 0;
}

Measured memory_bytes: 3668
def main():
    A, V = list(map(int, input().split()))
    B, W = list(map(int, input().split()))
    T = int(input())

    if A == B:
        return True
    if A < B:
        return A + V * T >= B + W * T
    else:
        return A - V * T <= B - W * T

print('YES' if main() else 'NO')


Measured memory_bytes: 9176
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int N = 2e5 + 10;
#define fi first
#define se second
#define pb push_back
char a[14][1111];
int h,w,k,inf=1e9;
int s[15][1111];
int main() {
  ios::sync_with_stdio(false);
  cin>>h>>w>>k;
  for(int i=1;i<=h;i++){
    cin>>a[i]+1;
    for(int j=1;j<=w;j++){
      s[i][j]=s[i-1][j]+s[i][j-1]-s[i-1][j-1];
      if(a[i][j]=='1'){
        s[i][j]++;
      }
    }
  }
  auto get=[&](int x,int y,int a,int b){
    return s[a][b]-s[a][y-1]-s[x-1][b]+s[x-1][y-1];
  };
  int ans=inf;
  for(int i=0;i<1<<h-1;i++){
    vector<pair<int,pair<int,int> >>v;int pre=1;
    for(int j=0;j<h-1;j++){
      if(1<<j&i){
        v.pb(make_pair(pre,make_pair(j+1,0)));
        pre=j+2;
      }
    }
    v.pb(make_pair(pre,make_pair(h,0)));
    int ok=1;int tmp=__builtin_popcount(i);
    for(int j=1;j<=w && ok;j++){
      for(auto K:v){
        if(get(K.fi,j,K.se.fi,j)>k){
          ok=0;
          break;
        }
      }
      int nw=0;
      for(auto &K:v){
        if(K.se.se+get(K.fi,j,K.se.fi,j)>k){
          nw=1;
          tmp++;
          break;

        }
        K.se.se+=get(K.fi,j,K.se.fi,j);
      }
      if(nw){
        for(auto &K:v){
          K.se.se=get(K.fi,j,K.se.fi,j);
        }
      }
    }
    if(!ok)
      continue;
    ans=min(ans,tmp);
  }
  cout<<ans<<'\n';
  return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define REP(i,n) for(ll i = 0; i < (ll)n; i++)
#define FOR(i,a,b) for (ll i=(a);i<(ll)b; i++)
#define ALL(obj) (obj).begin(),(obj).end()
#define INF 1000000000
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;
typedef pair<ll,ll> p;
const int MOD = 1000000007;

// vector<p> cut(M);
// cut[i].second
// cut[i].first;
// REP(i,M){
//     int a,b;cin>>a>>b;
//     cut[i] = make_pair(b,a);//last first の順番
// }
// for(int i=0; i<N;i++){
// }
// sort(cut.begin(),cut.end()); //sort
// char '' str ""
int main(void)
{
    str o,e; cin>>o>>e;

    int size = o.size() + e.size();

    for(int i=0; i<size;i++){
      if(i%2==0 && (i/2) < o.size()) cout<<o[i/2];
      if(i%2==1 && (i/2) < e.size()) cout<<e[i/2];
    }

    cout<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int x, y;
  cin >> x >> y;
  if(x == 2){
    if(y == 2) cout << "Yes" << endl;
    else cout << "No" << endl;
  }
  else if(x == 4 || x == 6 || x == 9 || x == 11){
    if(y == 4 || y == 6 || y == 9 || y == 11) cout << "Yes" << endl;
    else cout << "No" << endl;
  }
  else{
    if(y == 1 || y == 3 || y == 5 || y == 7 || y == 8 || y == 10 || y == 12)
      cout << "Yes" << endl;
    else cout << "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repe(i, n) for (int i = 0; i <= (n); ++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
typedef long long ll;
const int INF = 1e9;
const ll mod = 1000000007;
int gcd(int a,int b){return b?gcd(b,a%b):a;}

int main() {
  int a,b;
  cin >> a >> b;
  if (a+b >= 24) {
    cout << a+b-24 << "\n";
  } else {
    cout << a+b << "\n";
  }
}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int i,j,w,k, a[3],x,y;
    scanf("%d%d%d",&a[0],&a[1],&a[2]);
    j=a[0];
    k=a[0];
    int as,sa;
  for(int i=0;i<3;i++)
  {
      if(j>a[i])
      {
          j=a[i];
          sa=i;
      }
      if(k<a[i])
      {
          k=a[i];
          as=i;
      }
  }
    for(i=0;i<3;i++)
    {
        if(i!=as && i!=sa)
        {
            w=a[i];
        }
    }
    x=w-j+k-w;
      printf("%d\n",x);


    return 0;
}


Measured memory_bytes: 128
s =list(input())
y =int(s[0])*1000+int(s[1])*100+int(s[2])*10+int(s[3])
m = int(s[5])*10+int(s[6])
if y < 2019:
    print('Heisei')
elif y > 2019:
    print('TBD')
else:
    if m <= 4:
        print('Heisei')
    elif m > 4:
        print('TBD')

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

int main(){
  int k,n;
  cin >> k >> n;
  vector<int> v(n);
  for(int i=0;i<n;i++){
    cin >> v[i];
  }
  v.push_back(v[0]+k);
  int l=0;
  for(int i=0;i<n;i++){
    l=max(l,v[i+1]-v[i]);
  }
  cout << k-l << endl;
}


Measured memory_bytes: 1920
from math import *
n = int(input())
s = input()
r = 0
b = 0
g = 0
ans = 0
for i in range(n):
	rf = s[:i].count('R')
	rb = s[i:].count('R')
	bf = s[:i].count('B')
	bb = s[i:].count('B')
	gf = s[:i].count('G')
	gb = s[i:].count('G')
	if(s[i] == 'R'):
		ans += bf*gb + bb*gf
		for j in range(i+1):
			if i+j >= n:
				break
			if(s[i-j] == 'B' and s[i+j] == 'G') or (s[i-j] == 'G' and s[i+j] == 'B'):
				ans -= 1
	elif(s[i] == 'B'):
		ans += rf*gb + rb*gf
		for j in range(i+1):
			if i+j >= n:
				break
			if(s[i-j] == 'R' and s[i+j] == 'G') or (s[i-j] == 'G' and s[i+j] == 'R'):
				ans -= 1
	else:
		ans += rf*bb + rb*bf
		for j in range(i+1):
			if i+j >= n:
				break
			if(s[i-j] == 'R' and s[i+j] == 'B') or (s[i-j] == 'B' and s[i+j] == 'R'):
				ans -= 1
print(ans)


Measured memory_bytes: 69080
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int K = sc.nextInt();
    String S = sc.next();
     if( S.length() <= K ){
      System.out.println(S); 
     }
     else{
      System.out.println( S.substring(0,K) + "..." ); 
     }
    }
}

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

using namespace std;

#define int long long

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

const int IINF =  0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3fLL;
const int INF = sizeof(int) == sizeof(long long) ? LINF : IINF;
const ll MOD = 1e9+7;

#define for_(i,a,b) for(int i = (a);i < (b);i++)
#define rfor_(i,a,b) for(int i = (b)-1;i >= (a);i--)

#define rep(i,n) for_(i,0,n)
#define rrep(i,n) rfor_(i,0,n)

#define pb push_back
//#define eb emplace_back
#define mp make_pair
#define ft first
#define sd second

#define all(a) (a).begin(), (a).end()
#define sz(a) (int)(a).size()
#define rev(a) reverse(all(a))

#define endl '\n'

const int limit = 100007;

int A, B, C, D, E, F;

bool c[32];
int s[32];
int m, n=1;

signed main(){
  cin.tie(0);
  cout.tie(0);
  ios_base::sync_with_stdio(false);
  
  cin>>A>>B>>C>>D>>E>>F;
  
  rep(i, 31) {
    if(100*A*i>F)break;
    rep(j, 31) {
      if(100*(A*i+B*j)>F)break;
      c[A*i+B*j] = true;
    }
  }
  
  rep(i, 31) {
    if(!c[i])continue;
    rep(j, 100) {
      if(C*j>i*E || 100*i+C*j>F)break;
      rep(k, 100) {
        if(C*j+D*k>i*E || 100*i+(C*j+D*k)>F)break;
        s[i] = max(s[i], C*j+D*k);
      }
    }
  }
  
  for_(i, 1, 31) {
    if(!c[i])continue;
    if(m*i<s[i]*n) {
      m = s[i];
      n = i;
    }
  }
  if(n==1)n=A;
  
  cout<<(n*100+m)<<' '<<m<<endl;
  
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;				//ArrayListの使い方
import java.util.ArrayList;

class Main{
	public static void main(String[] args){
		ArrayList<Integer> array = new ArrayList<Integer>();
		Scanner scan = new Scanner(System.in);
		
		int x = scan.nextInt();
		while(x != 0){
			array.add(x);
			x = scan.nextInt();
		}

		int size = array.size();
		for(int i = 0; i < size; i++){
		    System.out.println("Case " + (i+1) + ": " + array.get(i));
		}
	}
}


Measured memory_bytes: 44420
#include<stdio.h>
#define M 10000000
char p[M]={1,1};
int main(){
  int i,j,n;
  for(i=2;i*i<M;i++){
    for(j=i*i;j<M;j+=i)p[j]=1;
  }
  while(scanf("%d",&n),n){
    for(;p[n]+p[n-2]+p[n-6]+p[n-8];n--);
    printf("%d\n",n);
  }
  return 0;
}
 

Measured memory_bytes: 10364
import java.util.*;
import java.math.*;
import java.lang.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int n = sc.nextInt();
		String a = sc.next();
		String b = sc.next();
		String c = sc.next();

		int count = 0;
		for (int i = 0; i < n; i++) {
			char aChar = a.charAt(i);
			char bChar = b.charAt(i);
			char cChar = c.charAt(i);
			// System.out.println(count);

			if (aChar == bChar && bChar == cChar) {
				continue;
			}
			if (aChar != bChar && bChar != cChar && cChar != aChar) {
				count += 2;
				continue;
			}
			count++;

		}
		System.out.println(count);
	}
}

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

#define fr(i,n) _back
#define pb	push_back
#define eb	emplace_back
#define mk	make_pair
#define fi	first
#define se	second
#define endl	'\n'

typedef long long ll;
typedef pair<int,int> ii;
typedef vector<ii> vii;
const int INF = 0x3f3f3f3f;
const double PI = acos(-1.0);

const int T = 1e6 + 3;
const int N = 2;
int v[T];
string s;
ll dp[T][N];

ll solve(int at, bool carry) {
    if(at == s.size()) return carry;
    if(~dp[at][carry]) return dp[at][carry];
    ll x = v[at]+carry;
    ll y = (10-x);
    dp[at][carry] = 1e18;
    if(x < 10) dp[at][carry] = min(dp[at][carry],solve(at+1,0)+x);
    return dp[at][carry] = min(dp[at][carry], solve(at+1,1)+y);
}

int main() {
    ios_base::sync_with_stdio(false);
    memset(dp,-1,sizeof dp);
    cin >> s;
    reverse(s.begin(),s.end());
    for(int i = 0; i < s.size(); i++) v[i] = (s[i]-'0');
    cout << solve(0,0) << endl;
    return 0;
}



Measured memory_bytes: 83356
/**akshaykumar99**/
 
#include<bits/stdc++.h>
using namespace std;
 
#define f(i,x,n) for(i=x;i<n;i++)
#define pu push_back           
#define pp pop_back
#define mp(a,b) make_pair(a,b)
#define F first
#define S second
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define IOS() ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
 
const long long MOD=1e9+7 ;
const long long INF=INT_MAX;
const long long LINF=LLONG_MAX;
const long long N=2e5+1;
 
typedef long long ll;
typedef long double ld;
typedef vector<ll> ivc;
typedef pair<ll,ll> ipr;
 
int main()
{
    IOS();
   
    int n,m,i;
    cin>>n;
    f(i,1,10)
    {
        if(n%i==0 && n/i<=9 && n/i!=0)
        {
            cout<<"Yes";
            return 0;
        }
    }
    cout<<"No";

    return 0;
}

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

const int N = 18, INF = 1005;

int n, a[N][2], dp[1 << N][N];

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> a[i][1];
    }
    for (int i = 0; i < n; i++) {
        cin >> a[i][0];
    }
    for (int msk = 0; msk < (1 << n); msk++) {
        for (int i = 0; i < n; i++) {
            dp[msk][i] = INF;
        }
    }
    for (int msk = 1; msk < (1 << n); msk++) {
        int les = 0, cnt = __builtin_popcount(msk);
        for (int i = 0; i < n; i++) {
            if (msk >> i & 1) {
                if (cnt == 1) {
                    dp[msk][i] = 0;
                }
                dp[msk][i] += les;
                int cur = a[i][(cnt ^ i) & 1];
                for (int j = 0; j < n; j++) {
                    if (!(msk >> j & 1) && a[j][(cnt ^ j ^ 1) & 1] >= cur) {
                        dp[msk ^ (1 << j)][j] = min(dp[msk ^ (1 << j)][j], dp[msk][i]);
                    }
                }
            } else {
                les++;
            }
        }
    }
    int mi = *min_element(dp[(1 << n) - 1], dp[(1 << n) - 1] + n);
    cout << (mi >= INF ? -1 : mi);
}


Measured memory_bytes: 18816
#include <bits/stdc++.h>
using namespace std;
template <typename T> void read(T &x){
	x = 0; int f = 1; char ch = getchar();
	while (!isdigit(ch)) {if (ch == '-') f = -1; ch = getchar();}
	while (isdigit(ch)) {x = x * 10 + ch - '0'; ch = getchar();}
	x *= f;
}
inline void write(int x){if (x > 9) write(x/10); putchar(x%10+'0'); }
const int N = 2000050,P = 1e9 + 7;
int r1,r2,c1,c2;
int fac[N],nfac[N],inv[N];
inline int C(int n,int m){
	return 1ll * fac[n] * nfac[m] % P * nfac[n-m] % P; 
}
inline int calc(int N,int m){
	int ret = 0;
	for (int n = 1; n <= N; ++n){
		ret += C(n+m+1,n+1); ret %= P;
	}
	return ret;
}
int main(){
	int i;
	read(r1),read(c1),read(r2),read(c2);
	for (fac[0] = fac[1] = nfac[0] = nfac[1] = inv[0] = inv[1] = 1,i = 2; i <= 2000040; ++i){
		fac[i] = 1ll*fac[i-1]*i%P;
		inv[i] = 1ll*(P-P/i)*inv[P%i]%P;
		nfac[i] = 1ll*nfac[i-1]*inv[i]%P;
	}
	int ans = calc(r2,c2) - calc(r1-1,c2) - calc(r2,c1-1) + calc(r1-1,c1-1);
	ans %= P; ans += P; ans %= P;
	cout<<ans<<endl; 
    return 0;
}

Measured memory_bytes: 23680
package main

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

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func getString() string {
	sc.Scan()
	return sc.Text()
}

// min, max, asub, absなど基本関数
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func asub(a, b int) int {
	if a > b {
		return a - b
	}
	return b - a
}

func abs(a int) int {
	if a >= 0 {
		return a
	}
	return -a
}

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

	A, B, C, D := getInt(), getInt(), getInt(), getInt()

	for {
		C -= B
		if C <= 0 {
			out("Yes")
			return
		}
		A -= D
		if A <= 0 {
			out("No")
			return
		}
	}
}


Measured memory_bytes: 1756
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Numerics;
public class MainClass
{
	public const long Giri = 1000000007;
	public const long DpInf = 99999999999999;
	
	public static void Main(string[] args)
	{
		var s = Console.ReadLine();
		
		var al = new int[28];
		for(int i = 0; i < s.Length; i++)
		{
			al[(int)(s[i]-'a')]++;
		}
		
		foreach(var k in al)
		{
			if(k%2!=0)
			{
				Console.WriteLine("No");
				return;
			}
		}
		Console.WriteLine("Yes");
	}
	
	
	static long GCD(long a, long b)
	{
		var v = new[] { a, b };
		while (v[1] != 0) { v = new[] { v[1], v[0] % v[1] }; }
		return v[0];
	}
	public static string[] Input() { return Console.ReadLine().Split(); }
}

public static class Smarter
{
	public static int ToInt(this string str) { return int.Parse(str); }
	public static long ToLong(this string str) { return long.Parse(str); }
	public static int[] ToInt(this string[] str, int offset = 0)
	{
		var r = new int[str.Length];
		for(int i = 0; i < str.Length; i++) r[i] = str[i].ToInt() + offset;
		return r;
	}
}

Measured memory_bytes: 25868
#include <iostream>
#include <math.h>
using namespace std;

long long n, ans = 0;
long long dest[200002], orig[200002], subs[200002];

int main() {
    cin>>n;
    dest[0] = 0;
    for(int i = 1; i <= n; i++)
        cin>>dest[i];
    dest[n+1] = 0;
    for(int i = 1; i <= n + 1; i++)
        orig[i] = abs(dest[i] - dest [i-1]);
    for(int i = 2; i <= n+1; i++)
        subs[i] = abs(dest[i] - dest[i-2]);
    for(int i = 1; i <= n + 1; i++)
        ans += orig[i];
    ans = ans - orig[1] - orig[2] + subs[2];
    cout<<ans<<endl;
    for(int i = 2; i <= n; i++) {
        ans = ans - orig[i+1] + orig[i-1] + subs[i+1] - subs[i];
        cout<<ans<<endl;
    }
}

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

#define N (int)2e5 + 1
bool isPrime[N];

void sieve(int n) {
  isPrime[0] = isPrime[1] = false;
  for (int i = 2; i <= n; i++) isPrime[i] = true;
  for (int i = 2; i * i <= n; i++)
    if (isPrime[i])
      for (int j = 2 * i; j <= n; j += i)
        isPrime[j] = false;
}

int main() {
  int X;
  cin >> X;
  sieve(N - 1);
  while (!isPrime[X]) X++;
  cout << X;
  return 0;
}

Measured memory_bytes: 384
/*
　　　  ∧＿∧　やあ
　　 （´・ω・｀)　　　　　/　　　　　ようこそ、バーボンハウスへ。
　　 ／∇y:::::＼　　　 [￣]　　　　　このテキーラはサービスだから、まず飲んで落ち着いて欲しい。
　　 |:⊃:|:::::|　　　|──|
￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣|　うん、「また」なんだ。済まない。
￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣|￣　  仏の顔もって言うしね、謝って許してもらおうとも思っていない。
￣￣￣￣￣￣￣￣￣￣￣￣￣￣／|
　　　　∇　∇　∇　∇　　　／.／|　　　でも、この提出を見たとき、君は、きっと言葉では言い表せない
　　　　┴　┴　┴　┴　／ ／　  |　　　「ときめき」みたいなものを感じてくれたと思う。
￣￣￣￣￣￣￣￣￣￣|／　　  |　　　殺伐としたコンテストの中で、そういう気持ちを忘れないで欲しい
￣￣￣￣￣￣￣￣￣￣　　　　 |　　　そう思って、この提出を投げたんだ。
　　　(⊆⊇)　(⊆⊇)　(⊆⊇)　　|
　    ||　　 ||　　||　　|　　　 じゃあ、判定を聞こうか。
　　.／|＼　／|＼ ／|＼
*/

#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <array>
#include <bitset>
#include <climits>
#include <cmath>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;
#define fst first
#define snd second
#define ALL(obj) (obj).begin(),(obj).end()
#define debug(x) cerr << #x << " -> " << x << " (line:" << __LINE__ << ")" << '\n';
#define debugpair(x, y) cerr << "(" << #x << ", " << #y << ") -> (" << x << ", " << y << ") (line:" << __LINE__ << ")" << '\n';
typedef long long lint;
typedef priority_queue<int> p_que;
typedef priority_queue<int, vector<int>, greater<int>()> p_que_rev;
const int INF = INT_MAX;
const lint LINF = LLONG_MAX;
const int MOD = 1000000000 + 7;
const double EPS = 1e-9;
const double PI = acos(-1);
const int di[]{0, -1, 0, 1, -1, -1, 1, 1};
const int dj[]{1, 0, -1, 0, 1, -1, -1, 1};

double solve(int n, vector<double> &p){
    double dp[n+1][n+1];
    double ret = 0.0;
    for (int i=0; i<=n; ++i){
        for (int j=0; j<=n; ++j){
            if(i == 0 && j == 0){
                dp[i][j] = 1.0;
            }
            else {
                dp[i][j] = 0.0;
            }
        }
    }
    for (int i=1; i<=n; ++i){
        for (int j=0; j<=n; ++j){
            if(i < j){
                dp[i][j] = 0.0;
            }
            else if(j == 0){
                dp[i][0] = (1 - p[i-1]) * dp[i-1][0];
            }
            else {
                dp[i][j] = p[i-1] * dp[i-1][j-1] + (1.0 - p[i-1]) * dp[i-1][j];
            }
        }
    }
    for (int j = (n + 1) / 2; j <= n; ++j){
        ret += dp[n][j];
    }
    return ret;
}

int main()
{
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<double> p(n);
    for (int i=0; i<n; ++i){
        cin >> p[i];
    }
    double answer = solve(n, p);
    printf("%.15f\n", answer);
    return 0;
}

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

struct Problem {

    ULL V[50][3000];

    void Solve() {
        UL N, M, S; cin >> N >> M >> S;
        vector<vector<pair<UL, pair<UL, UL>>>> E(N);
        rep(i, M) {
            UL u, v, a, b; cin >> u >> v >> a >> b;
            u--; v--;
            E[u].push_back({ v, {a,b} });
            E[v].push_back({ u, {a,b} });
        }
        vector<pair<UL, UL>> C(N);
        rep(i, N) {
            UL c, d; cin >> c >> d;
            C[i] = { c, d };
        }
        rep(i, N) rep(j, 3000) V[i][j] = -1;
        using Node = pair<ULL, pair<UL, UL>>;
        priority_queue<Node, vector<Node>, greater<Node>> G;
        G.push({ 0, {0, min(S, 2999u)} });

        ULL ans[50]; rep(i, N) ans[i] = -1;

        while (G.size()) {
            ULL d = G.top().first;
            UL p = G.top().second.first;
            UL s = G.top().second.second; G.pop();
            if (V[p][s] != -1) continue;
            V[p][s] = d;
            if (ans[p] == -1) ans[p] = d;
            G.push({ d + C[p].second, {p, min(s + C[p].first, 2999u)} });
            for (auto& e : E[p]) {
                if (e.second.first > s) continue;
                G.push({ d + e.second.second, {e.first, s - e.second.first} });
            }
        }

        for (UL i = 1; i < N; i++) cout << ans[i] << endl;
    }
};
int main() {
    unique_ptr<Problem> p(new Problem());
    //cout << fixed << setprecision(10);
    p->Solve();
    return 0;
}


Measured memory_bytes: 12840
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin>>N;
  vector<vector<int>> data(10,vector<int>(10,0));
  for(int i=1;i<=N;i++){
    vector<int> tmp;
    int n=i;
    while(n!=0){
      tmp.push_back(n%10);
      n=n/10;
    }
    data[tmp.back()][tmp[0]]++;
  }
  long long ans=0;
  for(int i=0;i<=9;i++){
    for(int j=0;j<=9;j++){
      ans+=data[i][j]*data[j][i];
    }
  }
  cout<<ans<<endl;
}

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

//素因数分解
vector<pair<ll,int>> factorize(ll n){
    vector<pair<ll,int>>res;
    for(ll i=2;i*i<=n;i++){
        if(n%i)continue;
        res.emplace_back(i,0);
        while (n%i == 0)
        {
        n /= i;
        res.back().second++;
        }
        
    }
    if(n != 1) res.emplace_back(n,1);
    return res;
}

void trace(int A[],int N){
    REP(i,N){
        if(i>0)printf(" ");
        printf("%d",A[i]);
    }
    printf("\n");
}


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

Measured memory_bytes: 256
N = int(input())
T,A = map(int,input().split())
res = 0
diff = 10000
Hlist = input().split()
Hlist = [int(i) for i in Hlist]
for i in range(N):
    H = Hlist[i]
    average = T - H * 0.006
    a = abs(A-average)
    if diff >= a:
        res = i
    diff = min(diff,a)
print(res+1)

Measured memory_bytes: 3064
#include<stdio.h>
                                                                                                                                                                                              
int main(void){
    int a,b,c;
    scanf("%d%d%d",&a,&b,&c);

    if(a<=c && c<=b){
            printf("Yes");
    }       
    else{
            printf("No");
    }
    return (0);
}


Measured memory_bytes: 128
import sys,os,re
from collections import Counter,deque
from operator import itemgetter
from itertools import accumulate
sys.setrecursionlimit(10**6)

a=[[[0 for i in range(10)]for j in range(3)]for k in range(4)]
n=int(input())
for i in range(n):
    b,f,r,v=map(int,input().split())
    a[b-1][f-1][r-1]+=v

for i in range(4):
    for j in range(3):
        print(" ",end='')
        print(*a[i][j])
    if i!=3:
        print("#"*20)


Measured memory_bytes: 6516
// AtCoder.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//

// AtCoder.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//


#define _USE_MATH_DEFINES
#include<math.h>

//#include<cmath>

#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<array>
#include<map>
#include<iomanip>
#include<assert.h>
#include<bitset>
#include<stack>
#include<memory>



//#include "Ants.h"
using namespace std;
typedef long long ll;
#define rad_to_deg(rad) (((rad)/2/M_PI)*360)
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define rep(i,n) for(int i=0;i<n;i++)
#define show(s) cout<<s<<endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define LINF (1000000000000000000ll)
//typedef pair < int, int> P;
ll gcd(ll a, ll b) {//最大公約数を求める///最大公倍数a*b/gcd(a,b)
	if (b == 0) return a;
	return gcd(b, a % b);
}
ll lcd(ll a, ll b) {//最小公倍数を求める　b=0のときaを返す
	if (b == 0) return a;
	return (a / gcd(a, b)) * b;
}
vector<int> divnum(ll num) {
	int dig;
	vector<int>p;
	while (num) {
		dig = num % 10;
		p.push_back(dig);
		num /= 10;
	}
	return p;
}
int digiter(ll num) {
	int dig;
	vector<int>p;
	while (num) {
		dig = num % 10;
		p.push_back(dig);
		num /= 10;
	}
	return p.size();
}
vector<int> convertstring(string s) {
	vector<int> d;
	ll n = s.size();
	rep(i, n) {
		d.push_back(s[i] - '0');
	}
	return d;
}
map< int64_t, int > prime_factor(int64_t n) {
	map< int64_t, int > ret;
	for (int64_t i = 2; i * i <= n; i++) {
		while (n % i == 0) {
			ret[i]++;
			n /= i;
		}
	}
	if (n != 1) ret[n] = 1;
	return ret;
}
vector<ll> divisor(ll n) {
	vector<ll>res;
	for (ll i = 1; i * i <= n; i++) {
		if (n % i != 0)continue;
		res.push_back(i);
		if (i * i != n)res.push_back(n / i);
	}
	return res;
}

int N;
int main()
{
	cin >> N;
	vector<int> d = divnum(N);
	for (int x : d) {
		if (x == 7) {
			cout << "Yes" << endl;
			return 0;
		}
	}
	cout << "No" << endl;
	
	
}




Measured memory_bytes: 3636
#include <iostream>
#include <vector>
#include <cmath>

using namespace std;

int main(void)
{
	int N, D;
	int result;
	double after;
	int count = 0;

	cin >> N >> D;

	vector<vector<int>> X(N, vector<int>(D));

	for (int i = 0; i < N; i++)
	{
		for (int j = 0; j < D; j++)
		{
			cin >> X[i][j];
		}
	}

	for (int k = 1; k < N; k++)
	{
		for (int i = 0; i < N - k; i++)
		{
			result = 0;
			after = 0.0;
			for (int j = 0; j < D; j++)
			{
				result += abs(X[i + k][j] - X[i][j]) * abs(X[i + k][j] - X[i][j]);
			}

			after = sqrt((double)result);

			if (after / floor(after) == 1)
				count++;
		}
	}

	cout << count << endl;

	return 0;
}

Measured memory_bytes: 256
import java.util.*;
 
public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int number = sc.nextInt();
    Integer[] num = new Integer[number];
   	for (int i=0; i<number; i++) {
         num[i] = sc.nextInt();
     }
     Arrays.sort(num, Comparator.reverseOrder());
    
    int Alice = 0;
    int Bob   = 0;
    for (int i=0; i<number; i+=2) {
        Alice += num[i];
    }
    for (int i=1; i<number; i+=2) {
        Bob += num[i];
    }
    System.out.println(Alice - Bob);
  }
}

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

struct edge {
  int u, v, w;
};

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

  int l = 0;
  while((1<<(l+1)) <= L) l++;
  if(L == 1) {
    printf("2 1\n1 2 0\n");
    return 0;
  }

  int N = l+1;
  vector<edge> edges;
  for(int i = 1; i <= l; i++) {
    edges.push_back(edge{i,i+1,0});
    edges.push_back(edge{i,i+1,(1<<(l-i))});
  }

  int k = L - (1<<l);
  int w = (1<<l);
  for(int i = 20; i >= 0; i--) {
    if((k>>i) & 1) {
      edges.push_back(edge{1,N-i,w});
      w += 1<<i;
    }
  }

  printf("%d %d\n", N, edges.size());
  for(auto e: edges) {
    printf("%d %d %d\n", e.u, e.v, e.w);
  }

  return 0;
}


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

int n ;

char s[100010] ;

int main(){
	#define NAME "arc013"
	//freopen( NAME".inp" , "r" , stdin ) ; freopen( NAME".out" , "w" , stdout ) ;

	scanf("%s", s + 1) ;

	n = strlen(s + 1) ;

	for (int i = 1; i < n; ++ i){
		if(s[i] != s[n - i]) return printf("-1"), 0 ;
	}

	if(s[1] == '0' || s[n] == '1') return printf("-1"), 0 ;

	int root = 1;

	for (int i = 2; i < n; ++ i){
		if(s[i] == '0') continue ;
		for (int j = root; j < i; ++ j) printf("%d %d\n", j, i) ;
		root = i ;
	}

	for (int i = root; i < n; ++ i) printf("%d %d", i, n) ;

	return 0 ;
}

Measured memory_bytes: 1536