akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define ll long long int
using namespace std;

int main(void) {
  int h,w;
  cin >> h >> w;

  char a[1024][1024];
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      cin >> a[i][j];
    }
  }

  vector<int> ii,jj;
  for (int i = 0; i < h; i++) {
    bool c = true;
    for (int j = 0; j < w; j++) {
      if(a[i][j]=='#'){
	c=false;
	break;
      }
    }
    if(c){
      ii.push_back(i);
    }
  }

  for (int j = 0; j < w; j++) {
    bool c = true;
    for (int i = 0; i < h; i++) {
      if(a[i][j]=='#'){
	c=false;
	break;
      }
    }
    if(c){
      jj.push_back(j);
    }
  }

  for (int i = 0; i < h; i++) {
    if(find(ii.begin(), ii.end(), i) != ii.end()){
      continue;
    }
    for (int j = 0; j < w; j++) {
      if(find(jj.begin(), jj.end(), j) == jj.end()){
	cout << a[i][j];
      }
    }
    cout << endl;
  }

  return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;
const int INF=99999999;

int main(){
  int n;
  cin>>n;
  string s;
  cin>>s;
  vector<int> vW(n+1,0),vE(n+1,0);
  for(int i=0;i<n;i++){
    vW[i+1]+=vW[i];
    if(s[i]=='W') vW[i+1]++;
    vE[i+1]+=vE[i];
    if(s[i]=='E') vE[i+1]++;
  }
  int ans=INF;
  for(int i=0;i<n;i++){
    int now=vW[i]+(vE[n]-vE[i+1]);
    if(ans>now)ans=now;
  }
  cout <<ans<<endl;
}


Measured memory_bytes: 3076
#include<iostream>
#include<vector>
#include<algorithm>
#include<cctype>
#include<utility>
#include<string>

#define REP(n) for(int i = 0;i < n;i++)
#define LLREP(n) for(long long int  i = 0;i < n;i++)
typedef long long int ll;
using namespace std;
#define MAX_A 100000

int main(){

    string s;
    string w;
    cin >> s;
    //cout << "w" << endl;

    REP(s.length()){
        //cout << "g" << endl;
        if(s[i] == '0'){
            w.push_back(s[i]);
        }
        if(s[i] == '1'){
            w.push_back(s[i]);
        }
        if(s[i] == 'B'){
            if(!w.empty()){
                //cout << "e" << endl;
                //cout << w << endl;
                w.pop_back();
                //cout << w << endl;
            }else{

            }
        }

    }
    cout << w << endl;

    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
 
#define NIL -1
#define MAX 500001
 
typedef struct{
  int right;
  int left;
  int key;
  int parent;
} Node;
 
void Insert(Node*,int,int);
void PreOrder(Node*,int);
void InOrder(Node*,int);
void Find(Node*,int, int);
void Delete(Node*,int);
int Successor(Node*, int);
 
int main(void){
  int i, n, k, f, del, count=0;
  char state[8];
  Node T[MAX];
 
  scanf("%d", &n);
  for(i = 0; i < n; i++){
    scanf("%s", state);
 
    if(state[0] == 'i'){
 
      scanf("%d",&k);
      Insert(T, count, k);
      count++;
 
    } else if(state[0] == 'p'){
 
      if(count > 0){
        InOrder(T, 0);
        printf("\n");
        PreOrder(T, 0);
        printf("\n");
      }
 
    } else if(state[0] == 'f'){
 
      scanf("%d", &f);
      Find(T, f, 0);
 
    } else if(state[0] == 'd'){
 
      scanf("%d", &del);
      Delete(T, del);
 
    }
  }
  return 0;
}
 
void Insert(Node *T,int count, int k){
  int x, y;
 
  T[count].key = k;
  T[count].left = NIL;
  T[count].right = NIL;
  //T[count].parent = NIL;
 
  if(count == 0) return;
 
  x = 0;
  while(x!=NIL){
    y = x;
 
    if(k < T[x].key) x = T[x].left;
    else x = T[x].right;
 
  }
 
  T[count].parent = y;
 
  if(k < T[y].key) T[y].left = count;
  else T[y].right = count;
 
  return;
}
 
void PreOrder(Node *T, int u){
 
  if(u == NIL) return;
 
  printf(" %d", T[u].key);
  PreOrder(T, T[u].left);
  PreOrder(T, T[u].right);
 
  return;
}
 
void InOrder(Node *T, int u){
 
  if(u == NIL) return;
 
  InOrder(T, T[u].left);
  printf(" %d", T[u].key);
  InOrder(T, T[u].right);
 
  return;
}
 
void Find(Node *T, int f, int u){
 
  if(u == NIL) printf("no\n");
  else if(T[u].key == f) printf("yes\n");
  else if(T[u].key > f && T[u].left != NIL) Find(T, f, T[u].left);
  else Find(T, f, T[u].right);
 
  return;
}
 
void Delete(Node *T, int k){
  int x, y, z = 0;
 
  while(1){
    if(T[z].key == k) break;
    else if(k < T[z].key) z = T[z].left;
    else z = T[z].right;
 
  }
 
  if(T[z].left == NIL || T[z].right == NIL) y = z;
  else y = Successor(T, z);
 
  if(T[y].left != NIL) x = T[y].left;
  else x = T[y].right;
 
  if(x != -1) T[x].parent = T[y].parent;
 
  if(T[y].parent != NIL){
    if(y == T[T[y].parent].left) T[T[y].parent].left = x;
    else T[T[y].parent].right = x;
  }
 
  if(y != z) T[z].key = T[y].key;
 
  return;
 
}
 
int Successor(Node *T,int x){
  int y;
 
  if(T[x].right != NIL){
    x = T[x].right;
    while(T[x].left != NIL) x = T[x].left;
    return x;
  } else {
    y = T[x].parent;
    while(y != NIL && x == T[y].right){
      x = y;
      y = T[y].parent;
    }
    return y;
  }
 
}

Measured memory_bytes: 7932
def maybe_prime(d,s,n):
    for a in (2,3,5,7):
        p = False
        x = pow(a,d,n)
        if x==1 or x==n-1:
            continue
        for i in range(1,s):
            x = x*x%n
            if x==1: return False
            elif x == n-1:
                p = True
                break
        if not p: return False
    return True

def is_prime(n):
    if n in (2,3,5,7): return True
    elif 0 in (n%2,n%3,n%5,n%7): return False
    else:
        d,s = n-1, 0
        while not d%2:
            d,s = d>>1,s+1
        return maybe_prime(d,s,n)
cnt = 0
n = int(input())
for i in range(n):
  n = int(input())
  if is_prime(n): cnt+=1

print(cnt)

Measured memory_bytes: 7716
#include<bits/stdc++.h>
#include<cmath>
#define pb push_back
#define ld long double
#define mp make_pair
#define vl vector<ll> 
#define vd vector<double>
#define vld vector<long double>
#define ll long long int
#define pl pair<ll, ll>
#define all(a) a.begin(), a.end()
#define forr(i, n) for(ll i=0; i<n; i++) 
#define forr1(i, n) for(ll i=1; i<=n; i++)
using namespace std;
const ld PI =3.1415926535897923846;
const ll MOD = 1e9+7;
const ll N=998244353;
void solve()
{
    string s, t;
    cin>>s>>t;
    ll count=0;
    forr(i, s.length())
    {
        if(s[i]!=t[i])
        count++;
    }
    cout<<count;
}
int main()
{
    ll test=1;
    //cin>>test;
    while(test--)
        solve();
}

Measured memory_bytes: 3916
#include <iostream>

using namespace std;

int n, k, x, a[10];

bool f(int n) {
	while (n > 0) {
		if (a[n % 10]) return true;
		n /= 10;
	}
	return false;
}

int main() {
	cin >> n >> k;
	while (k--) {
		cin >> x;
		a[x] = true;
	}
	while (f(n)) n++;
	cout << n << endl;
}


Measured memory_bytes: 256
N, A, B = map(int, input().split())
def _sum(n):
    ans = 0
    while n>0:
        ans += n%10
        n /= 10
        n = int(n)
    return ans
total = 0
for i in range(N+1):
    judge = _sum(i)
    if A <= judge <= B:
        total += i
print(total)


Measured memory_bytes: 2940
//#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define int long long
#define x first
#define y second
#define inf 1000000000000000000
#define N 1000000007
#define speed ios_base::sync_with_stdio(0);cin.tie(0);
using namespace std;
template<class L,class R> ostream& operator<<(ostream& cout,pair<L, R> P)
{return cout<<'('<<P.x<<','<< P.y<<')';}
template<class T> ostream& operator<<(ostream& cout,vector<T> V)
{cout<<"[ ";for(auto v:V)cout<<v<<' ';return cout<<']';}

struct node{
    char ch;
    vector<node*> next;
    vector<int> sub;
    node(char ch){
        this->ch=ch;
        next.resize(26,NULL);
        sub.resize(26,0);
    }
};
node* head;
void dfs(string &tmp, int s, int e, node* head, unordered_set<int>& indices){
    if(s>e){return ;}
    if(head->next[tmp[s]-'a']==NULL){
        head->next[tmp[s]-'a']=new node(tmp[s]);
    }
    if(indices.find(s)!=indices.end()){
        ++head->sub[tmp[s]-'a'];
    }
    for(int i=0;i<26;++i){
        head->sub[i]-=head->next[tmp[s]-'a']->sub[i];
    }
    dfs(tmp,s+1,e,head->next[tmp[s]-'a'],indices);
    for(int i=0;i<26;++i){
        head->sub[i]+=head->next[tmp[s]-'a']->sub[i];
    }
}

//edge cases when n=1,m=1.wrong variable in loop.if<->while;merge resize;LLONG_MAX
signed main()
{
    //#ifndef ONLINE_JUDGE
    //freopen("input.txt","r",stdin);
    //#endif
    speed
    //global var
    int n;cin>>n;
    vector<string> inp;
    head = new node('a');
    for(int _=0;_<n;++_){
        string tmp;cin>>tmp;
        reverse(tmp.begin(),tmp.end());
        inp.push_back(tmp);
        int len=tmp.size();
        unordered_set<char> taken;
        unordered_set<int> indices;
        for(int i=len-1;i>=0;--i){
            if(taken.find(tmp[i])==taken.end()){
                indices.insert(i);
                taken.insert(tmp[i]);
            }
        }
        dfs(tmp,0,tmp.size()-1,head,indices);
    }
    int ans=0;
    for(auto it:inp){
        
        auto pres=head;
        int len=it.size();
        for(int i=0;i<len-1;++i){
            pres=pres->next[it[i]-'a'];
        }
        ans+=pres->sub[it.back()-'a']-1;
    }
    cout<<ans<<"\n";
    
}
//try thinking from a different angle after spending some time


Measured memory_bytes: 590320
if __name__ == '__main__':
    K, S = map(int, input().split())
    
    ans = 0
    
    for x in range(K+1):
        for y in range(K+1):
            z = S - x - y
            if x <= y <= z <= K:
                ans += [None, 1, 3, 6][len( set( [x,y,z]))]
   
    print(ans)

Measured memory_bytes: 3064
n = input()
line1 = input()
line2 = input()
line3 = input()
a_list = line1.split(" ")
a_list = [int(a) for a in a_list]
b_list = line2.split(" ")
b_list = [int(b) for b in b_list]
c_list = line3.split(" ")
c_list = [int(c) for c in c_list]

manzoku = 0

for i in range(int(n)):
    if i == 0:
        manzoku = manzoku + b_list[a_list[i]-1]
    else:
        manzoku = manzoku + b_list[a_list[i]-1]
        if a_list[i]-1 == a_list[i-1]:
            manzoku = manzoku + c_list[a_list[i-1]-1]
print(manzoku)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  string A, B;
  int taro = 0, hanako = 0;
  for (size_t i = 0; i < n; i++) {
    cin >> A >> B;
    if (A>B){
      taro += 3;
    }else if (A < B){
      hanako += 3;
    }else{
      taro += 1;
      hanako += 1;
    }
  }
  cout << taro << ' ' << hanako << endl;
}



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

int n;
map <int, int> a;
int ans;

int main()
{
	cin >> n;
	while (n--){
		int x;
		cin >> x;
		a[x]++;
	}
	
	while (!a.empty()){
		map <int, int> :: iterator it=a.end();
		it--;
		int x=it->first;
		
		if (!a[x])  throw;
			
		a[x]--;
		if (!a[x])  a.erase (x);
		
		int z=1;
		while (z <= x)
			z <<= 1;
			
		if (a.count (z-x) > 0){
			a[z-x]--;
			if (!a[z-x])
				a.erase (z-x);
				
			ans++;
		}
	}
	
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 9600
import java.util.*;

public class Main {

  public static void main (String[] args) {

    Scanner sc = new Scanner(System.in);

    int A = sc.nextInt();
    int B = sc.nextInt();
    int C = sc.nextInt();
    int D = sc.nextInt();

    sc.close();

    int[] time = new int[102];

    time[A+1]++;
    time[B+1]--;
    time[C+1]++;
    time[D+1]--;

    for (int i = 2; i < 101; i++) {
      time[i] += time[i-1]; 
    }

    int count = 0;

    for (int i = 1; i < 101; i++) {
      if (time[i] == 2) {
        count++;
      } 
    }

    System.out.println(count);

  }

}

Measured memory_bytes: 23636
#include<bits/stdc++.h>
#include<unordered_map>
#include<string>
#include<math.h>
#define ll long long
using namespace std;
const ll INF = 1LL << 60;
const int inf = 1 << 30;
const ll N= 1e10;
inline void fastio()
{ 
     ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
}
ll a[200005], b[200005];
int main()
{
    ll n, m, k;
    int ans = 0;
    cin >> n >> m >> k;
    for (ll i = 0; i < n; i++)
    {
        cin >> a[i+1];
        a[i + 1] += a[i];
    }
    for (ll i = 0; i < m;i++)
    {
        cin >> b[i + 1];
        b[i + 1] += b[i];
    }

    for (int i = 0,j = m; i <= n;i++)
    {
        if(a[i]>k)
            break;
        while(a[i]+b[j]>k)
            j--;
        ans = max(ans, i + j);
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 6700
def main():
    import sys
    input = sys.stdin.buffer.readline
    N = int(input())
    from itertools import accumulate
    S = [i for i in accumulate(range(1, min(N+1, 44725)))]

    def is_ok(mid):
        if N <= S[mid]:
            return True
        else:
            return False

    def binary_search_meguru():
        left = -1
        right = len(S)
        while right - left > 1:
            mid = left + ((right - left) // 2)
            if is_ok(mid):
                right = mid
            else:
                left = mid
        return right

    ans = binary_search_meguru() + 1
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 40560
package main
 
import(
  "fmt"
)
 
func main() {
  var a, b int
  fmt.Scan(&a,&b)
  if a >= 10 {
    fmt.Print("-1")
  } else if b >= 10 {
    fmt.Print("-1")
  } else {
    fmt.Printf("%d", a*b)
  }
}

Measured memory_bytes: 512
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<bitset>
#include<cstdio>
#include<cmath>
#include<map>
#include<numeric>
#include<set>
#include<sstream>
#include<string>
#include<utility>
#include<vector>

#define rep(i, a, n)  for(int i=a; i<n; i++)
#define per(i, a, n)  for(int i=n-1; i>=a; i--)
#define fill0(n)  setfill('0') << right << setw(n)
#define all(x)  (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define INF 1000000007
using namespace std;
typedef long long ll;

int main(){
  int n;  cin >> n;
  string s; cin >> s;
  map<char, int> mp;
  for(char c:s){
    mp[c]++;
  }
  if(mp['R'] > mp['B']){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
use std::cmp;
use std::collections::{BTreeSet, VecDeque};

const INF: usize = 1000000;
fn main() {
    let s = std::io::stdin();
    let mut sc = Scanner { stdin: s.lock() };
    let n: usize = sc.read();
    let edge: Vec<Vec<bool>> = (0..n)
        .map(|_| sc.chars().into_iter().map(|c| c == '1').collect())
        .collect();

    let mut ans: Option<usize> = None;
    for start in 0..n {
        if let Some(t) = bfs(start, &edge) {
            match ans {
                Some(cur) => ans = Some(cmp::max(cur, t)),
                None => ans = Some(t),
            }
        }
    }

    match ans {
        Some(ans) => println!("{}", ans),
        None => println!("-1"),
    }
}

fn bfs(start: usize, edge: &Vec<Vec<bool>>) -> Option<usize> {
    let n = edge.len();
    let mut distances = vec![vec![]; n];
    distances[start].push(0);
    let mut dist = vec![INF; n];
    dist[start] = 0;
    let mut q = VecDeque::new();
    q.push_back(start);
    while let Some(v) = q.pop_front() {
        for next in 0..n {
            if !edge[v][next] {
                continue;
            }
            let next_dist = dist[v] + 1;
            if dist[next] > next_dist {
                dist[next] = next_dist;
                distances[next].push(next_dist);
                q.push_back(next);
            } else if dist[next] < next_dist {
                distances[next].push(next_dist);
            }
        }
    }

    let mut set = BTreeSet::new();
    for i in 0..n {
        let min = distances[i][0];
        if distances[i].iter().any(|&x| (x - min) % 2 != 0) {
            return None;
        }
        set.insert(min);
    }
    Some(set.len())
}

pub struct Scanner<R> {
    stdin: R,
}

impl<R: std::io::Read> Scanner<R> {
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .stdin
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n')
            .take_while(|&b| b != b' ' && b != b'\n')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}


Measured memory_bytes: 4352
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Atc_0031
{
    class Program
    {
        static void Main(string[] args)
        {
            var str = Console.ReadLine();

            int A = int.Parse(str.Split(' ')[0]);

            int B = int.Parse(str.Split(' ')[1]);

            int result = 0;

            if (B % A == 0)
            {
                result = A + B;
            }
            else
            {
                result = B - A;
            }

            Console.WriteLine(result);

        }
    }
}


Measured memory_bytes: 27428
#include<iostream>
using namespace std;
int main() {
    int a, b;
    string op;
    while (1) {
        cin >> a >> op >> b;
        if (op == "?") break;
        if (op == "+") {
            cout << a+b << endl;
        } else if (op == "-") {
            cout << a-b << endl;
        } else if (op == "*") {
            cout << a*b << endl;
        } else if (op == "/") {
            cout << a/b << endl;
        }
    }
    return 0;
}


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

int main() {
  while(1){
    int h,m,s;
    cin >> h >> m >>s;
    if(h==-1 && m==-1 && s==-1) break;
    int rec = 120*60-(60*60*h+m*60+s);
    h = rec/(60*60), rec%=60*60;
    m = rec/(60), rec%=60;
    s = rec;
    printf("%02d:%02d:%02d\n",h,m,s);
    rec = 3*(60*60*h+m*60+s);
    h = rec/(60*60), rec%=60*60;
    m = rec/(60), rec%=60;
    s = rec;
    printf("%02d:%02d:%02d\n",h,m,s);
  }
  return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
using namespace std;

long long cnt;
int l;
int A[1000000];
int n;
vector<int> G;

//間隔gを指定した挿入ソート
void insertionSort(int A[], int n, int g) {
	for (int i = g; i < n; i++) {
		int v = A[i];
		int j = i - g;
		while (j >= 0 && A[j] > v) {
			A[j + g] = A[j];
			j -= g;
			cnt++;
		}
		A[j + g] = v;
	}
}

void shellSort(int A[], int n) {
	//数列を作成
	for (int h = 1;;) {
		if (h > n) break;
		G.push_back(h);
		h = 3 * h + 1;
	}

	for (int i = G.size() - 1; i >= 0; i--) {
		//逆順にG[i] = gを指定
		insertionSort(A, n, G[i]);
	}
}

int main() {
	cin >> n;
	for (int i = 0; i < n; i++) scanf("%d", &A[i]);
	cnt = 0;

	shellSort(A, n);
	cout << G.size() << endl;
	for (int i = G.size() - 1; i >= 0; i--) {
		printf("%d", G[i]);
		if (i) printf(" ");

	}
	printf("\n");
	printf("%d\n", cnt);
	for (int i = 0; i < n; i++) printf("%d\n", A[i]);
}


Measured memory_bytes: 7196
def coins(n,prob):
    dp = [[0]*(n+1) for _ in range(n+1)]
    dp[0][0] = 1
    for i in range(1,n+1):
        for j in range(i+1):

            if j == 0:
                dp[i][j] = dp[i-1][j]*(1-prob[i-1])
            else:
                dp[i][j] = dp[i-1][j]*(1-prob[i-1])+dp[i-1][j-1]*prob[i-1]
    total = 0
    for i in range(n,n//2,-1):
        total+= dp[n][i]
    return total

n = int(input())
prob = list(map(float,input().split()))
print(coins(n,prob))

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

using namespace std;

int main()
{
    int N, M, sum=0;
    cin >> N >> M;

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

    for(int i = 0; i < M; i++) {
        sum += a[i];
    }

    if(N - sum >= 0) {
        cout << N-sum << endl;
    }else{
        cout << -1 << endl;
    }

    return 0;
}

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

const int MAX_N = 100000 + 10;
int X[MAX_N], n, m;
struct node{int d, id; } pre[MAX_N];
int maxx = 0xcfcfcfcf, minn = 0x3f3f3f3f, ans;

bool cmp(node x, node y) {return x.d > y.d; }

int main() {
	scanf("%d%d", &n, &m);
	for (int i = 1; i <= m; i++) {
		scanf("%d", &X[i]);
		maxx = max(maxx, X[i]);
		minn = min(minn, X[i]);
	}
	if (n >= m) {
		puts("0");
		return 0;
	}
	ans = maxx - minn;
	sort(X + 1, X + m + 1);
	for (int i = 1; i < m; i++) {
		pre[i].d = X[i + 1] - X[i];
		pre[i].id = i;
	}
	sort(pre + 1, pre + m, cmp);
	for (int i = 1; i < n; i++) {
		ans -= X[pre[i].id + 1] - X[pre[i].id];
	}
	printf("%d\n", ans);
	return 0;
}

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

int main() {
    int a, b, c;
    cin >> a >> b >> c;
    int Max = a;
    if (b > Max) Max = b;
    if (c > Max) Max = c;

    cout << a + b + c - Max << endl;

    return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
"""ABC142.ipynb

Automatically generated by Colaboratory.

Original file is located at
    https://colab.research.google.com/drive/1a5aajQRjVtRR5jXaooVlLtRM2WBIS2cv
"""

N=int(input())

def EO(x):
  if x % 2 == 0:
    return "Even"
  return "Odd"

if EO(N)=="Even":
  prob=0.5
else:
  prob=(int(N/2)+1)/N
print(prob)



Measured memory_bytes: 2940
#include<bits/stdc++.h>
#define endl '\n';
#define rep(i,n) for(int i=0; i<(n); i++)
using namespace std;
using ll = long long;
using P = pair<int,int>;
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("Ofast")
constexpr ll INF = 1e18;
constexpr int inf = 1e9;
constexpr double INFD = 1e100;
constexpr ll mod = 1000000007;
constexpr ll mod2 = 998244353;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
// ios::sync_with_stdio(false);
// cin.tie(nullptr);
// ---------------------------------------------------------------------------


int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int N;
    cin >> N;
    while(N != 0){
        vector<int> num(N);
        for(int i=0; i<N; i++){
            string S;
            cin >> S;
            num[i] = S.size();
        }
        vector<int> pos = {5,7,5,7,7};
        for(int i=0; i<N; i++){
            int now = 0;
            int sum = 0;
            bool did = false;
            for(int j=i; j<N; j++){
                if(sum+num[j] == pos[now]){
                    now++;
                    if(now == 5){
                        cout << i+1 << endl;
                        did = true;
                        break;
                    }
                    sum = 0;
                }else if(sum+num[j] < pos[now]){
                    sum += num[j];
                }else{
                    break;
                }
            }
            if(did) break;
        }
        cin >> N;
    }
    return 0;
}


Measured memory_bytes: 3180
using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;

public class SumOfFourInteger
{
	public static void Main(string[] args)
	{
		BindingList<int> outputList = new BindingList<int>();
		do
		{
			string input = Console.ReadLine();
			if (string.IsNullOrEmpty(input))
			{
				break;
			}
			int outputCount = 0;
			for (int a = 0; a <= 9; a++)
			{
				for (int b = 0; b <= 9; b++)
				{
					for (int c = 0; c <= 9; c++)
					{
						for (int d = 0; d <= 9; d++)
						{
							if (a + b + c + d == int.Parse(input))
							{
								outputCount++;
							}
						}
					}
				}
			}
			outputList.Add(outputCount);
		} while(true);
		foreach (int output in outputList)
		{
			Console.WriteLine(output);
		}
	}
}

Measured memory_bytes: 6176
#include<iostream>
#include<algorithm>
#include<cmath>
using namespace std;
long long a[6];
int main()
{
	long long n;
	cin >> n;
	long long ans=1e16;;
	for(int i=1;i<=5;i++)
	{
	cin >> a[i];
	ans=min(ans,a[i]);
	}
	cout << (n-1)/ans +5 << endl;
	return 0;
 } 



Measured memory_bytes: 256
import numpy as np

def check(A):
    for i in range(3):
        if A[i,0] == 0 and A[i,1] == 0 and A[i,2] == 0:
            return True
        if A[0,i] == 0 and A[1,i] == 0 and A[2,i] == 0:
            return True
    if A[0,0] == 0 and A[1,1] == 0 and A[2,2] == 0:
        return True
    if A[0,2] == 0 and A[1,1] == 0 and A[2,0] == 0:
        return True

    return False



a = list(map(int, input().split()))
A = a
a = list(map(int, input().split()))
A = np.vstack((A, a))
a = list(map(int, input().split()))
A = np.vstack((A, a))
N = int(input())
b = []
for i in range(N):
    b.append(int(input()))

for i in range(N):
    for m in range(3):
        for n in range(3):
            if b[i] == A[m,n]:
                A[m,n] = 0

if check(A):
    print("Yes")
else:
    print("No")


Measured memory_bytes: 21284
package main

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

var sc *bufio.Scanner = func() *bufio.Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	return sc
}()

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

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

type inputString []rune

func (a inputString) Len() int           { return len(a) }
func (a inputString) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }
func (a inputString) Less(i, j int) bool { return a[i] < a[j] }

func countPair(input []string) (count int) {
	m := make(map[string]int, len(input))
	for _, v := range input {
		is := inputString(v)
		sort.Sort(is)
		m[string(is)]++
	}
	for _, v := range m {
		if v == 0 {
			continue
		}
		count += v * (v - 1) / 2
	}
	return
}

func main() {
	n := nextInt()
	ss := make([]string, n)
	for i := 0; i < n; i++ {
		ss[i] = nextString()
	}
	pair := countPair(ss)
	fmt.Println(pair)
}


Measured memory_bytes: 13568
#include <stdio.h>

int main()
{
    
    int H=0,W=0;
    int i=0,j=0;
    
    for (; ; )
    {
        scanf("%d %d",&H,&W);
        
    if (H==0&&W==0)
    {
        break;
    }
      for (i=0; i<H; i++)
      {
          for (j=0; j<W; j++)
          {
              printf("#");
          }
          printf("\n");
      }printf("\n");
    }
    return 0;
}

Measured memory_bytes: 572
#include<stdio.h>
#include<iostream>
#include<string>
using namespace std;
int main(){

int n;
cin>>n;
for(int iii=0;iii<n;iii++){
string st1,st2;
int n1[83]={},n2[83]={};
cin>>st1>>st2;

int r=st1.size();
int N[83]={};int y=0;
if(r<st2.size())r=st2.size();
if(st1.size()>80||st2.size()>80)r=81;
else{
for(int i=0;i<st1.size();i++)
n1[i]=st1[st1.size()-i-1]-'0';
for(int i=0;i<st2.size();i++)
n2[i]=st2[st2.size()-i-1]-'0';



for(int i=0;i<r;i++){
N[i]=(n1[i]+n2[i]+y)%10;
y=(n1[i]+n2[i]+y)/10;
if(i==r-1&&y>0)r++;
}}
if(r>80)cout<<"overflow"<<endl;
else{
for(int i=0;i<r;i++)
cout<<N[r-i-1];
cout<<endl;
}}
return 0;
}

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

typedef long long ll;

using namespace std;

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

template<class T>
using vt = vector<T>;
template<class T>
using vvt = vector<vector<T>>;

int main(){
    int N,T,ans=0;
    cin >> N >> T;
    vt<int> sentou(N);
    cin >> sentou[0];
    reps(i,1,N){
        cin >> sentou[i];
        sentou[i] += sentou[0];
    }
    rep(i,N-1){
        if(sentou[i]+T > sentou[i+1]){
            ans += sentou[i+1]-sentou[i];
        }
        else {
            ans += T;
        }
    }
    cout << ans+T << endl;
    return 0;  
}



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

int main(){
  int N;
  cin>>N;
  int Hi[N];
  bool I[N-1];
  int move=0,ans=0;
  for(int i=0;i<N;i++){
    cin>>Hi[i];
  }
  for(int i=0;i<N-1;i++){
    if(Hi[i]>=Hi[i+1] && N>=i+1){
      I[i]=true;
    } else {
      I[i]=false;
    }
  }
  for(int i=0;i<N-1;i++){
    if(I[i]){
      move++;
      ans=max(move,ans);
      continue;
    }
    move=0;
  }
  cout<<ans<<endl;
}


      

Measured memory_bytes: 768
#include<bits/stdc++.h>
#include<map>
#include<iostream>

using namespace std;

int main(){
    int A,B,C,D;
    cin >> A >> B >> C >> D;
    bool flag = true;
    while(1){
        if(C <= 0){
            flag = true;
            break;
        }
        else if(A <= 0){
            flag = false;
            break;
        }
        else{
            C = C - B;
            A = A - D;
        }

    }
    cout << (flag ? "Yes" : "No" ) << endl;
}

Measured memory_bytes: 3544
#include <bits/stdc++.h>
using namespace std;
int main(){
    string S;
    cin>>S;
    int l,r;
    int N=S.size();
    for(int i=0;i<N;i++){
        if(S[i]=='A'){l=i;break;}
    }
    for(int i=N-1;0<=i;i--){
        if(S[i]=='Z'){r=i;break;}
    }
    cout<<r-l+1<<endl;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    ll n,i,j,k,l,m,a,b,c;
    cin>>n;
    map<ll,ll>mp;
    for(i=0;i<n;i++)
    {
        cin>>k;
        mp[k]++;
    }
    map<ll,ll>::iterator it;
    c=0;
    for(it=mp.begin();it!=mp.end();it++)
    {
        k=it->first;
        l=it->second;
        if(k!=l)
        {
            if(k>l)
            {
                c+=abs(l-0);
            }
            else if(k<l)
            {
                c+=abs(k-l);
            }
        }
    }
    cout<<c<<endl;
    return 0;

}


Measured memory_bytes: 6272
#define _USE_MATH_DEFINES


#include <iostream>
#include <vector>
#include <stdio.h>
#include <algorithm>
#include <numeric>
#include <array>
#include <set>
#include <sstream>
#include <cmath>

using namespace std;

vector<string> split(const string& s, char delim) {
	vector<string> elems;
	stringstream ss(s);
	string item;

	while (getline(ss, item, delim)) {
		if (!item.empty()) {
			elems.push_back(item);
		}
	}

	return elems;
}


vector<double> str_vec2dbl_vec(vector<string> str_vec) {

	vector<double> dbl_vec;
	for (auto&& s : str_vec) {
		dbl_vec.emplace_back(stod(s));
	}
	return dbl_vec;
}


double calc_Manhattan_distance(vector<double> x, vector<double> y) {
	double dist = 0.0;
	for (int i = 0; i < x.size(); ++i) {
		dist += abs(x[i] - y[i]);
	}
	return dist;
}

double calc_Euclidean_distance(vector<double> x, vector<double> y) {
	double dist = 0.0;
	for (int i = 0; i < x.size(); ++i) {
		dist += pow(abs(x[i] - y[i]), 2.0);
	}
	dist = sqrt(dist);
	return dist;
}

double calc_p3_distance(vector<double> x, vector<double> y) {
	double dist = 0.0;
	for (int i = 0; i < x.size(); ++i) {
		dist += pow(abs(x[i] - y[i]), 3.0);
	}
	dist = pow(dist, 1.0/3.0);
	return dist;
}

double calc_Chebyshev_distance(vector<double> x, vector<double> y) {
	double dist;
	vector<double> dists;
	for (int i = 0; i < x.size(); ++i) {
		dists.emplace_back(abs(x[i] - y[i]));
	}
	dist = *max_element(dists.begin(), dists.end());
	return dist;
}

int main() {

	int n;
	double dbl;
	cin >> n;
	vector<double> x, y, dists;
	for (int i = 0; i < n; ++i) {
		cin >> dbl;
		x.emplace_back(dbl);
	}
	for (int i = 0; i < n; ++i) {
		cin >> dbl;
		y.emplace_back(dbl);
	}

	dists.emplace_back(calc_Manhattan_distance(x, y));
	dists.emplace_back(calc_Euclidean_distance(x, y));
	dists.emplace_back(calc_p3_distance(x, y));
	dists.emplace_back(calc_Chebyshev_distance(x, y));

	for (auto&& d : dists) {
		printf("%lf\n", d);
	}

	return 0;
}



Measured memory_bytes: 3420
#include <cstdio>
#include <cstring>
#include <cmath>
#include <utility>
#include <iostream>
#include <functional>
#include <bitset>
#include <algorithm>
#include <vector>
#include <forward_list>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <tuple>
#include <numeric>
#define rep(i, s, g) for ((i) = (s); (i) < (g); ++(i))
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const ll MOD = 1e9 + 7;
const ll INF = (1ll << 60);

int main(void)
{
    string s, t;
    cin >> s >> t;

    ll ans = INF;

    for (int i = 0; i <= s.size() - t.size(); i++)
    {
        ll tmp = 0;

        for (int j = 0; j < t.size(); j++)
        {
            if (t[j] != s[i + j])
            {
                tmp++;
            }
        }

        ans = min(ans, tmp);
    }

    cout << ans << endl;
}


Measured memory_bytes: 3628
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using static System.Math;
using System.Text;
using System.Threading;
using System.Globalization;
using System.Runtime.CompilerServices;
using Library;

namespace Program
{
    public static class ABC042B
    {
        static public int numberOfRandomCases = 0;
        static public void MakeTestCase(List<string> _input, List<string> _output, ref Func<string[], bool> _outputChecker)
        {
        }
        static public void Solve()
        {
            var N = NN;
            var L = NN;
            var SList = NSList(N);
            var sb = new StringBuilder();
            foreach (var item in SList.OrderByRand().OrderBy(e => e))
            {
                sb.Append(item);
            }
            Console.WriteLine(sb.ToString());
        }
        static class Console_
        {
            static Queue<string> param = new Queue<string>();
            public static string NextString() { if (param.Count == 0) foreach (var item in Console.ReadLine().Split(' ')) param.Enqueue(item); return param.Dequeue(); }
        }
        class Printer : StreamWriter
        {
            public override IFormatProvider FormatProvider { get { return CultureInfo.InvariantCulture; } }
            public Printer(Stream stream) : base(stream, new UTF8Encoding(false, true)) { base.AutoFlush = false; }
            public Printer(Stream stream, Encoding encoding) : base(stream, encoding) { base.AutoFlush = false; }
        }
        static public void Main(string[] args) { if (args.Length == 0) { Console.SetOut(new Printer(Console.OpenStandardOutput())); } var t = new Thread(Solve, 134217728); t.Start(); t.Join(); Console.Out.Flush(); }
        static long NN => long.Parse(Console_.NextString());
        static double ND => double.Parse(Console_.NextString());
        static string NS => Console_.NextString();
        static long[] NNList(long N) => Repeat(0, N).Select(_ => NN).ToArray();
        static double[] NDList(long N) => Repeat(0, N).Select(_ => ND).ToArray();
        static string[] NSList(long N) => Repeat(0, N).Select(_ => NS).ToArray();
        static IEnumerable<T> OrderByRand<T>(this IEnumerable<T> x) => x.OrderBy(_ => xorshift);
        static long Count<T>(this IEnumerable<T> x, Func<T, bool> pred) => Enumerable.Count(x, pred);
        static IEnumerable<T> Repeat<T>(T v, long n) => Enumerable.Repeat<T>(v, (int)n);
        static IEnumerable<int> Range(long s, long c) => Enumerable.Range((int)s, (int)c);
        static uint xorshift { get { _xsi.MoveNext(); return _xsi.Current; } }
        static IEnumerator<uint> _xsi = _xsc();
        static IEnumerator<uint> _xsc() { uint x = 123456789, y = 362436069, z = 521288629, w = (uint)(DateTime.Now.Ticks & 0xffffffff); while (true) { var t = x ^ (x << 11); x = y; y = z; z = w; w = (w ^ (w >> 19)) ^ (t ^ (t >> 8)); yield return w; } }
    }
}
namespace Library {
}


Measured memory_bytes: 15712
require 'pp'
$DEBUG ? define_method(:dpp){|e|pp e} : define_method(:dpp){|e|}

# 空白区切の入力値を数値の配列で返却する
def gets_i_list()
  gets.chomp.split(" ").map(&:to_i)
end
N, A, B = gets_i_list

count = N / (A + B)
mod = N % (A + B)

puts count * A + [mod, A].min


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

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

    while (true) {
        c -= b;
        if (c <= 0) {
            cout << "Yes" << endl;
            break;
        }

        a -= d;
        if (a <= 0) {
            cout << "No" << endl;
            break;
        }
    }

    return 0;
}

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

using namespace std;

#ifndef aa
#define trace(...)
#define endl '\n'
#endif
#define pb push_back
#define ub upper_bound
#define lb lower_bound
#define fi first
#define se second
#define int long long
typedef long long ll;
typedef long double ld;
#define double long double
#define pii pair<int,int>
#define pdd pair<double,double>
#define pll pair<ll,ll>
#define sz(x) ((long long)x.size())
#define fr(a,b,c) for(int a=b; a<=c; a++)
#define frev(a,b,c) for(int a=c; a>=b; a--)
#define rep(a,b,c) for(int a=b; a<c; a++)
#define trav(a,x) for(auto &a:x)
#define all(con) con.begin(),con.end()
#define deb(x) cout << x << endl
#define done(x) {cout << x << endl;return;}
const ll infl = 0x3f3f3f3f3f3f3f3fLL;
const int infi = 0x3f3f3f3f;
mt19937_64 mt(chrono::steady_clock::now().time_since_epoch().count());
//const int mod = 998244353;
const int mod = 1e9 + 7;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<pair<int, int>> vpii;
typedef map<int, int> mii;
typedef set<int> si;
typedef set<pair<int,int>> spii;
typedef queue<int> qi;


const int N = 2e5 + 5;
    
  
void solve() {

   int x,k,d,ans;
   cin>>x>>k>>d;
   if(x<0)
     x=-x;
   if(k>x/d){
      k-=x/d;
      x-=x/d*d;
      ans=(k&1?d-x:x);
   }else{
     ans=x-k*d;
   }
   cout<<ans;
}


signed main() {
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    //srand(chrono::high_resolution_clock::now().time_since_epoch().count());
    cout << fixed << setprecision(15);
    int t = 1;
    //cin >> t;

    while (t--)
        solve();
#ifdef aa
    cout << endl << endl << endl << endl << "Time elapsed: " << (double)(clock() - clk) / CLOCKS_PER_SEC << endl;
#endif
    return 0;
}




int powm(int a, int b) {
    int res = 1;
    while (b) {
        if (b & 1)
            res = (res*a) % mod;
        a = (a * a) % mod;
        b >>= 1;
    }
    return res;
}


int divide(int a, int b) {
    return (a % mod) * powm(b, mod - 2) % mod;
}

int norm(int a) {
    while (a >= mod) a -= mod;
    while (a < 0) a += mod;
    return a;
}


int gcd(int a, int b) {
    return b ? gcd(b, a % b) : a;
}


Measured memory_bytes: 3604
N,D = gets.split.map(&:to_i)
X_arr =  N.times.map{gets.split.map(&:to_i)}

ans = 0
X_arr.combination(2) do |x1, x2|
  sum = 0
  D.times do |i|
    sum += (x1[i] - x2[i])**2
  end

  sq = Math.sqrt(sum)
  ans += 1 if sq % 1 == 0
end

puts ans


Measured memory_bytes: 1788
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int a ,b,c;
    cin >> a >> b>> c;
    
    if(a==b){
        cout<<c<<endl;
    }else if(b==c){
        cout << a << endl;
    }else if(c == a){
        cout << b << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <unordered_set>
using namespace std;
#define ll long long
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repeat(i,s,n) for(int (i)=s; (i)<(n); (i)++)
#define revrep(i,n) for(int (i)=(n)-1;i>=0; i--)

bool check(vector<ll>& a, int lb, int ub) {
  int n=a.size();
  auto can = vector<vector<bool>>(n+1,vector<bool>(ub));
  can[0][0]=true;
  rep(i,n) {
    rep(k,ub) {
      can[i+1][k]=can[i][k];
      if(k-a[i]>=0) {
        can[i+1][k]=can[i][k-a[i]];
      }
    }
  }
  repeat(s,max(0,lb),ub) {
    if(can[n][s])
      return true;
  }
  return false;
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<setprecision(std::numeric_limits<float>::max_digits10);
  int n,k;
  cin>>n>>k;
  vector<ll> a(n);
  rep(i,n)cin>>a[i];
  sort(a.begin(),a.end());
  int need=0;
  // check max
  vector<ll> b;
  rep(i,n-1) {
    b.push_back(a[i]);
  }
  if(!check(b,k-a[n-1],k)) {
    cout << n << endl;
    return 0;
  }
  int ok=n-1;
  int ng=-1;
  while(ok-ng>1) {
    int m=(ok+ng)/2;
    vector<ll> b;
    rep(j,n) {
      if(j!=m)
        b.push_back(a[j]);
    }
    if(check(b,k-a[m],k)) {
      ok=m;
    } else {
      ng=m;
    }
  }
  cout << ok << endl;
  return 0;
}


Measured memory_bytes: 3792
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while (true) {
			int m = sc.nextInt();
			int f = sc.nextInt();
			int r = sc.nextInt();
			if (m == -1 && f == -1 && r == -1) {
				break;
			}

			if (m == -1 || f == -1) {
				System.out.printf("F");
			} else if (m + f >= 80) {
				System.out.printf("A");
			} else if (m + f >= 65) {
				System.out.printf("B");
			} else if (m + f >= 50) {
				System.out.printf("C");
			} else if (m + f >= 30) {
				if (r >= 50) {
					System.out.printf("C");
				} else {
					System.out.printf("D");
				}
			} else {
				System.out.printf("F");
			}
			System.out.printf("\n");

		}
	}
}


Measured memory_bytes: 26656
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
using namespace std;
int main(){
    string s;
    cin >> s;
    int len;
    len = s.length();
    string temp;
    int num;
    int tempnum;
    int ans = 1000000;
    for(int i=0;i<len-2;i++){
        temp = s.substr(i,3);
        num = stoi(temp);
        tempnum = abs(num-753);
        if(tempnum < ans){
            ans = tempnum;
        }
    }
    cout  << ans << endl;
}

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


int main() {
  int a,b,c;
  cin >> a >> b >> c;
  if( (a==5 && b==5 && c== 7) || (a==5 && b==7 && c== 5) || (a==7 && b==5 && c== 5)){
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
	int n;
	while(cin>>n,n){
		int ans=0;
		for(int i=n/2+1;i>1;i--)for(int j=i-1,now=i+j;j>0&&now<=n;j--,now+=j)if(now==n)ans++;
		cout<<ans<<endl;
	}
}

Measured memory_bytes: 1156
#include "bits/stdc++.h"
using namespace std;
#define FOR(i,j,k) for(int (i)=(j);(i)<(int)(k);++(i))
#define rep(i,j) FOR(i,0,j)
#define each(x,y) for(auto &(x):(y))
#define mp make_pair
#define mt make_tuple
#define all(x) (x).begin(),(x).end()
#define debug(x) cout<<#x<<": "<<(x)<<endl
#define smax(x,y) (x)=max((x),(y))
#define smin(x,y) (x)=min((x),(y))
#define MEM(x,y) memset((x),(y),sizeof (x))
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;

class UnionFind{
    int cnt;
    vector<int> par, rank, size;
public:
    UnionFind(){}
    UnionFind(int _n):cnt(_n), par(_n), rank(_n), size(_n, 1){
        for(int i=0;i<_n;++i) par[i]=i;
    }
    int find(int k){
        return (k==par[k])?k:(par[k]=find(par[k]));
    }
    int operator[](int k){
        return find(k);
    }
    int getSize(int k){
        return size[find(k)];
    }
    void unite(int x, int y){
        x = find(x); y = find(y);
        if(x==y) return;
        --cnt;
        if(rank[x] < rank[y]){
            par[x] = y;
            size[y] += size[x];
        }else{
            par[y] = x;
            size[x] += size[y];
            if(rank[y] == rank[x]) ++rank[x];
        }
    }
    int count(){
        return cnt;
    }
};

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N, K, L;
    while(cin >> N >> K >> L) {
        UnionFind kuf(N), luf(N);
        rep(i, K) {
            int u, v;
            cin >> u >> v;
            --u; --v;
            kuf.unite(u, v);
        }
        rep(i, L) {
            int u, v;
            cin >> u >> v;
            --u; --v;
            luf.unite(u, v);
        }

        map<int, vi> km, lm;
        rep(i, N)km[kuf[i]].push_back(i);

        vi ans(N);
        each(p, km) {
            lm.clear();
            each(v, p.second) {
                lm[luf[v]].push_back(v);
            }
            each(q, lm) {
                each(v, q.second) {
                    ans[v] = sz(q.second);
                }
            }
        }
        rep(i, N)cout << ans[i] << (i != N - 1 ? ' ' : '\n');
    }
}

Measured memory_bytes: 25948
import heapq

S = []

heapq.heapify(S)

while True:
  l = input().split()
  if len(l) == 2:
    heapq.heappush(S, (-1)*int(l[1]))
  elif l[0] == "extract":
    print(heapq.heappop(S)*(-1))
  else:
    break


Measured memory_bytes: 45304
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N,num=0;
  bool flag = true;
  cin>>N;
  int a[200];
  while(1){
  	for(int i=0;i<N;i++){
      if(flag) cin>>a[i];
      if(a[i]%2){
      cout<<num<<endl;
      return 0;
      }else{
        a[i]/=2;
      }
  	}
    if(flag) flag=false;
    num++;
  }
}

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

int main()
{
	long long H, W;
	cin >> H >> W;

	long long ans = H * W / 2;
	if( H * W % 2 ) ans++;
	if( H == 1 || W == 1 ) ans = 1;

	cout << ans << endl;
}


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


vector<int> solve(int L, const vector<int> & As){
    vector<int> ans;
    deque<pair<int, int>> stack;
    for (int i = 0; i < As.size(); ++i){
        if ((not stack.empty()) and stack.front().first + L <= i) stack.pop_front();
        int a = As[i];
        while ((not stack.empty()) and stack.back().second >= a) stack.pop_back();
        stack.push_back({i, a});
        if (i >= L - 1) ans.push_back(stack.front().second);
    }
    return ans;
}


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, L;
    cin >> N >> L;
    vector<int> As(N);
    for (auto & a : As) cin >> a;
    auto ans = solve(L, As);
    cout << ans[0];
    for (int i = 1; i < ans.size(); ++i) cout << ' ' << ans[i];
    cout << endl;
    return 0;
}

Measured memory_bytes: 10988
fun main(args: Array<String>) {
    val giftNums = Integer.parseInt(readLine())

    var giftsPrice = 0.0
    for(i in 1..giftNums) {
        val inputs = readLine()?.split(" ")!!
        var priceNum = inputs[0].toDouble()
        val type = inputs[1]
        if (type == "BTC") {
            priceNum *= 380000.0
        }
        giftsPrice+=priceNum
    }
    System.out.println(giftsPrice)
}


Measured memory_bytes: 35968
t = gets.to_i

s, level, arr = 0, 0, [0]
while s <= t
    s += (3 ** level) + (3 ** (level + 1))
    level += 1
    arr[-1] += 1
    arr << 1
end
level -= 1
s -= (3 ** level) + (3 ** (level + 1))
arr.pop
arr[-1] -= 1

while t > s
    level -= 1 while (t - s) < (3 ** level)
    s += (3 ** level)
    arr[level] += 1
end
puts arr.inject(:+)



Measured memory_bytes: 6876
#include <iostream>
#include <cstdio>
#include <cmath>
#include <string>
using namespace std;
#define ll long long int
#define abs(n) ((n>0)?(n):((n)*(-1)))

int main(int argc, const char * argv[]) {
	string s;
	cin >> s;
	int len = s.length();
	int ret = 10000;
	for (int i = 0; i < len-2; ++i) {
		int X = (s[i]-'0')*100
				+(s[i+1]-'0')*10
				+(s[i+2]-'0');
		cerr << X << endl;
		int diff = abs(X-753);
		if(diff < ret) ret = diff;
	}
	cout << ret << endl;
}


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

using namespace std;

typedef long long ll;

#define MAX 1024
#define INF LLONG_MAX/4

ll N, W, memo[MAX];
vector<ll> a;

ll solve(int n)
{
    if (n == N) return 0;
    ll &res = memo[n], sum = 0;
    if (res != INF) return res;
    for (int i = n; i < N; i++) {
        sum += a[i];
        res = min(res, solve(i+1) + abs(sum - W));
    }
    res = min(res, solve(N) + max(0LL, sum - W));
    return res;
}

int main()
{
    int T = 1;
    while (cin >> N >> W, N) {
        a.resize(N);
        for (int i = 0; i < N; i++) {
            cin >> a[i];
        }
        fill(memo, memo + MAX, INF);
        cout << "Case " << T++ << ": " << solve(0) << endl;
    }    
    return 0;
}

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

typedef long long ll;

int main(void)
{
    int n, m;
    cin >> n >> m;
    vector<pair<int, int> > AB(n);
    rep(i, n)
    {
        cin >> AB[i].first >> AB[i].second;
    }
    sort(AB.begin(), AB.end());
    ll ans  = 0;
    int cnt = m;
    rep(i, n)
    {
        ans += (ll)(AB[i].first)*(ll)(min(cnt, AB[i].second));
        cnt -= min(cnt, AB[i].second);
        if(cnt == 0) break;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
import java.util.Scanner;

class Main{
  public static void main(String[] args){
    Scanner scan=new Scanner(System.in);
    long a=scan.nextLong();
    long b=scan.nextLong();
    long num=scan.nextLong();
    long Ansa=0, Ansb=0;
    if(num<a){
      Ansa=a-num;
      Ansb=b;
    }else if(num<a+b){
      Ansa=0;
      Ansb=b-(num-a);
    }else{
      Ansa=0;
      Ansb=0;
    }
    System.out.println(Ansa+" "+Ansb);
  }
}

Measured memory_bytes: 21844