akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <iostream>
#include <string>
using namespace std;

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

int main() {
  int N;
  cin >> N;
  int A[N];
  rep(i, N) { cin >> A[i]; }
  bool ans = true;
  rep(i, N) {
    if (A[i] % 2 == 0)
      if (A[i] % 3 != 0)
        if (A[i] % 5 != 0) ans = false;
  }
  if (ans == true)
    cout << "APPROVED" << endl;
  else
    cout << "DENIED" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int x, y, flag;

int main() {
    int n,id=1,cnt,tmp,max=0;
    cin >> n;
    for(int i=0;i<=n;i++){
        cnt = 0;
        tmp = i;
        while(tmp%2==0&&tmp>0){
            cnt++;
            tmp/=2;
        }
        if(cnt>max){
            max = cnt;
            id = i;
        }
    }
    cout << id << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define uli unsigned long long int
#define INF 999999999999999999
#define rep(i,m,n) for(lli i = m;i < n;i++)
#define rrep(i,m,n) for(lli i=m-1;i>=n;i--)
#define pb(n) push_back(n)
#define UE(N) N.erase(unique(N.begin(),N.end()),N.end());
#define Sort(n) sort(n.begin(), n.end())
#define Rev(n) reverse(n.begin(),n.end())
#define Out(S) cout << S << endl
#define NeOut(S) cout << S
#define HpOut(S) cout << setprecision(30) << S << endl
#define Vec(K,L,N,S) vector<L> K(N,S)
#define DV(K,L,N,M,S) vector<vector<L>> K(N,vector<L>(M,S))
#define TV(K,L,N,M,R,S) vector<vector<vector<L>>> K(N,vector<vector<L>>(M,vector<L>(R,S)))
#define pint pair<lli,lli>
#define paf(L,R) pair<L,R>
#define mod 1000000007
#define MAX 5100000
#define ALL(a)  a.begin(),a.end()
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
int main(){
  lli A,B,C,D,E,F,N,M,K,L,R,X,Y,Z,H,W,sum=0,num=0,flag=0;string S,T;
  cin >> N >> S;
  X=0;
  rep(i,0,N)if(S[i]=='(')sum++;else if(sum) sum--;else X++;
  rep(i,0,X)S='('+S;
  rep(i,0,sum)S+=')';
  Out(S);
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
//#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define all(v) v.begin(),v.end()
#define P pair<int,int>
#define len(s) (int)s.size()
#define pb push_back

template<class T> inline bool chmin(T &a, T b){
	if(a>b){a=b;return true;}
	return false;
}
template<class T> inline bool chmax(T &a, T b){
	if(a<b){a=b;return true;}
	return false;
}
constexpr int mod = 998244353;
//constexpr int inf = 3e18;

int N;
int f(int A,int B){
	if(A<B)return 0;
  	int res=A/B;
	if(A%B==0)return res;
	int AA=A-res;
	return f(AA-1,B);
}
signed main(){
	cin.tie(0);ios::sync_with_stdio(false);
	cin>>N;
	int grundy=0;
	rep(i,N){
		int A,B;cin>>A>>B;
		grundy^=f(A,B);
	}
	if(grundy==0)cout<<"Aoki"<<endl;
	else cout<<"Takahashi"<<endl;
}


Measured memory_bytes: 3608
#include<iostream>
using namespace std;
int main()
{
   	char a[3],b[3];
   	for(int i=0;i<3;i++)
   		cin>>a[i];
   	for(int i=0;i<3;i++)
   		cin>>b[i];
   	int sum=0;
	for(int i=0;i<3;i++)
   		if(a[i]==b[i])
   			sum++;
   	cout<<sum;
         return 0;
} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define _GLIBCXX_DEBUG
#define all(a) a.begin(), a.end()
#define pb push_back
#define mp make_pair
#define INF (1 << 31) - 1

int main() {
  long double A;
  long double B;
  cin >> A >> B;
  cout << fixed << setprecision(0);
  ll C = (ll)A*B;
  
	  cout << C << endl;
}

Measured memory_bytes: 3712
#include "bits/stdc++.h"
using namespace std;

int dp[3000][3000];
// dp[x][y] = s wali string mein x index par hain, t wali string mein y index par... max length


// 0 -> (i-1,j) , 1 -> (i,j-1) , 2 -> pick and goto (i-1,j-1)

int main(){
	string s,t;
	cin>>s>>t;
	
	int n = s.size(), m = t.size();
	
	dp[0][0] = 0;
	int choice[3000][3000];
	if(s[0] == t[0]){
		dp[0][0] = 1;
		choice[0][0] = 2;
	}
	
	for(int i = 0 ; i < n; i++){
		for(int  j = 0 ; j < m ; j++){
			// not picking current character
			if(i > 0){
				dp[i][j] = dp[i-1][j];
				choice[i][j] = 0;
			}
			if(j > 0){
				if(dp[i][j-1] > dp[i][j]){
					dp[i][j] = dp[i][j-1];
					choice[i][j] = 1;
				}
			}
			// pick current character
			if(s[i] == t[j]){
				int ans = 1;
				if(i>0 && j>0){
					ans = 1 + dp[i-1][j-1];
				}
				if(ans > dp[i][j]){
					dp[i][j] = ans;
					choice[i][j] = 2;
				}
			}
		}
	}
	
	int i = n-1, j = m-1;
	
	string subsequence;
	
	while(i >= 0 && j >= 0){
		if(choice[i][j] == 0){
			i--;
		}
		else if(choice[i][j] == 1){
			j--;
		}
		else{
			subsequence.push_back(s[i]); // or t[j]
			i--;
			j--;
		}
	}
	
	reverse(subsequence.begin(), subsequence.end());
	cout<<subsequence;
	
}


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

#define REP(i, x, n) for (int i = x; i < (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x.size())
#define popcount(x) __builtin_popcount(x)
#define popcountll(x) __builtin_popcountll(x)
#define uniq(x) x.erase(unique(x.begin(), x.end()), x.end())
#define F first
#define S second
#define mp make_pair
#define eb emplace_back
#define pii pair<int, int>
#define pll pair<ll, ll>

using namespace std;

typedef long long ll;

/* --- INFの値が適切か確認する --- */
// const int INF = 1 << 30;
// const ll INF = 1LL << 60;
// const int MOD = 1000000007;

int main() {
  ll N, K;
  cin >> N >> K;
  vector<ll> A(N), B(N);
  rep(i, N) cin >> A[i] >> B[i];

  ll ans = 0;
  rep(i, N) if ((K | A[i]) == K) ans += B[i];

  for (int i = 30; i >= 0; i--) {
    if (K & (1 << i)) {
      ll sum = 0;
      int k = K ^ (1 << i);
      rep(j, i) k |= (1 << j);
      rep(j, N) if ((k | A[j]) == k) sum += B[j];
      ans = max(ans, sum);
    }
  }

  cout << ans << endl;
}


Measured memory_bytes: 1920
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
x = 0
for i in range(n):
    x += b[i]
for i in range(n - 1):
    if a[i] + 1 == a[i + 1]:
        x += c[int(a[i] - 1)]
print(int(x))

Measured memory_bytes: 9196
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from sys import stdin
N = int(stdin.readline().rstrip())
A = [int(i) for i in stdin.readline().rstrip().split()]
A_i = sorted([a - (i + 1) for i, a in enumerate(A)])

if N % 2 != 0:
    idx_of_median = int(N // 2)  # 奇数時のインデックス [0, 1, 2, 3, 4] -> 5//2 = 2
    print(sum([abs(a - A_i[idx_of_median])for a in A_i]))
else:
    idx_of_median = int(N / 2) # 奇数時のインデックス [0, 1, 2, 3, 4, 5] -> 6/2 = 3 or 6/2 - 1 = 2
    print(sum([abs(a - A_i[idx_of_median]) for a in A_i]))


Measured memory_bytes: 27844
n, k = map(int, input().split())
vs = list(map(int, input().split()))

from collections import deque
from heapq import heappush, heappop

res = 0

for i in range(0, min(k, n) + 1):
    for j in range(i + 1):
        a = j
        b = i - j

        hq = []
        dq = deque(vs)

        for _ in range(a):
            heappush(hq, dq.popleft())
        for _ in range(b):
            heappush(hq, dq.pop())

        c = k - a - b
        for _ in range(c):
            if len(hq) == 0:
                break
            v = heappop(hq)
            if v > 0:
                heappush(hq, v)
                break

        res = max(res, sum(hq))

print(res)

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

typedef long long LL;

const int N=100000,INF=(1<<30)-1;

int n,m,cm,a[N+9],b[N+9],c[N+9];
struct side{
  int y,next;
}e[N*2+9];
int lin[N+9],cs;

void Ins(int x,int y){e[++cs].y=y;e[cs].next=lin[x];lin[x]=cs;}
void Ins2(int x,int y){Ins(x,y);Ins(y,x);}

int deg[N+9][2];

void into(){
  scanf("%d%d",&n,&m);cm=m;
  for (int i=1;i<=m;++i){
	scanf("%d%d%d",&a[i],&b[i],&c[i]);
	Ins2(a[i],b[i]);
	cm-=a[i]==b[i];
	++deg[a[i]][0];++deg[b[i]][1];
  }
}

int vis[N+9],d[N+9],cd;

void Dfs_d(int k){
  vis[d[++cd]=k]=1;
  for (int i=lin[k];i;i=e[i].next)
	if (!vis[e[i].y]) Dfs_d(e[i].y);
}

int id[N+9],opt[N+9];
int cnt;

void Get_opt(){
  for (int i=1;i<=n;++i){
	if (vis[i]) continue;
	cd=0;
	Dfs_d(i);
	int now=cd>1;
	for (int j=1;j<=cd;++j)
	  if (deg[d[j]][0]^1||deg[d[j]][1]^1) now=2;
	if (now==1) ++cnt;
	for (int j=1;j<=cd;++j) id[d[j]]=now;
  }
  for (int i=1;i<=m;++i)
	switch (id[a[i]]){
	  case 0:opt[i]=0;c[i]-=2;break;
	  case 1:opt[i]=1;c[i]-=1;break;
	  case 2:opt[i]=2+(a[i]!=b[i]);c[i]-=1;break;
	}
}

vector<int>w[3];

int Get_ans(int x,int y){
  int res=INF,sum=x;
  for (int vs=w[0].size(),i=0;i<vs;++i) sum+=w[0][i];
  if (sum>=cnt) return cm+y+cnt;
  sum=cnt-sum;
  int now1=0,now2=0;
  for (int vs=w[2].size(),i=0;i<vs;++i)
	if ((now2+=w[2][i])>=sum) res=min(res,cm+cnt+y+(i+1<<1));
  for (int vs=w[1].size(),p1=0,p2=w[2].size()?w[2].size()-1:-1;p1<vs;++p1){
	now1+=w[1][p1];
	for (;p2>=0&&now1+now2-w[2][p2]>=sum;now2-=w[2][p2],--p2);
	if (now1+now2>=sum) res=min(res,cm+cnt+y+p1+1+(p2+1<<1));
  }
  return res;
}

int ans;

void Get_ans(){
  ans=INF;
  if (!cnt) {ans=cm;return;}
  for (int i=1;i<=m;++i)
	if (c[i]>0&&opt[i]>=2) w[opt[i]==2].push_back(c[i]);
  sort(w[0].begin(),w[0].end(),greater<int>());
  sort(w[1].begin(),w[1].end(),greater<int>());
  ans=min(ans,Get_ans(0,0));
  if (!w[0].size()&&!w[1].size()) return;
  int t=w[0].empty(),x=w[t][0];
  w[t].erase(w[t].begin());
  for (int i=1;i<=m;++i)
	if (c[i]>0&&opt[i]<=1) w[opt[i]?0:2].push_back(c[i]);
  sort(w[0].begin(),w[0].end(),greater<int>());
  sort(w[1].begin(),w[1].end(),greater<int>());
  sort(w[2].begin(),w[2].end(),greater<int>());
  //for (auto x:w[0]) printf("%d\n",x);
  //for (auto x:w[1]) printf("%d\n",x);
  //for (auto x:w[2]) printf("%d\n",x);
  ans=min(ans,Get_ans(x,t));
}

void work(){
  Get_opt();
  Get_ans();
}

void outo(){
  printf("%d\n",ans==INF?-1:ans);
}

int main(){
  into();
  work();
  outo();
  return 0;
}

Measured memory_bytes: 9692
a = input()
b = input()
c = input()
La = len(a)
Lb = len(b)
Lc = len(c)

def func(a, b):
    ret = set()
    for i in range(-len(b)+1, len(a)):
        ok = True
        for j in range(max(0, i), min(len(a), len(b)+i)):
            if a[j] != '?' and b[j-i] != '?' and a[j] != b[j-i]:
                ok = False
                break
        if ok:
            ret.add(i)
    return ret

L1 = func(a, b)
L2 = func(a, c)
L3 = func(b, c)
L1.add(-Lb)
L1.add(La)
L2.add(-Lc)
L2.add(La)
L3.add(-Lc)
L3.add(Lb)
ans = 10000
for i in L1:
    for j in L2:
        if j - i in L3 or j - i <= -Lc or j - i >= Lb:
            lo = min(0, i, j)
            hi = max(len(a), i+len(b), j+len(c))
            ans = min(ans, hi-lo)
    for k in L3:
        j = i + k
        if j >= La or j <= -Lc:
            lo = min(0, i, j)
            hi = max(len(a), i+len(b), j+len(c))
            ans = min(ans, hi-lo)
for j in L2:
    for k in L3:
        i = j - k
        if i >= La or i <= -Lb:
            lo = min(0, i, j)
            hi = max(len(a), i+len(b), j+len(c))
            ans = min(ans, hi-lo)
    
print(ans)

Measured memory_bytes: 59612
main :: IO ()
main = interact $ eachLineWithoutEnd solve

eachLineWithoutEnd :: (String -> String) -> (String -> String)
eachLineWithoutEnd f = unlines . map f . init . lines

solve :: String -> String
solve s = show $ count m n
  where
    [m,n] = map read $ words s

count :: Int -> Int -> Int
count m n = length $ takeWhile (<=n) $ dropWhile (<m) hamming

hamming :: [Int]
hamming = 1 : merge fives (merge threes twos)
  where
    fives  = map (*5) hamming
    threes = map (*3) hamming
    twos   = map (*2) hamming

merge :: Ord a => [a] -> [a] -> [a]
merge xs [] = xs
merge [] ys = ys
merge a@(x:xs) b@(y:ys)
  | x < y     = x : merge xs b
  | x > y     = y : merge a ys
  | otherwise = x : merge xs ys



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

int main(){
	int N, A, B;
	cin >> N >> A >> B;
	int tot = 0;
	rep(i,N+1){
		int tmp = 0;
		int k = i;
		rep(j,5){
			tmp += k%10;
			k /= 10;
		}
		if (A<=tmp && tmp<=B) tot += i;
	}
	cout << tot << endl;
	return 0;
}


Measured memory_bytes: 3556
#include <bits/stdc++.h>
#include <cstdlib>  //abs()で絶対値を取得する（整数）
#include <cmath>    //abs()かfabs()で絶対値を取得する（少数）
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
int main(){
    int n, r;
    cin >> n >> r;
    if (n >= 10){
        cout << r << endl;
    }else{
        int ans = 100 * (10 - n) + r;
        cout << ans << endl;
    }
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef pair<int, int> P;
typedef long long ll;
int main()
{
    ll d,n;
    cin >> d >> n;
    ll res = 1;
    if(n==100){
        n++;
    }
    for(int i = 0;i<d;i++){
        res*=100;
    }
    cout << res*n << endl;
}

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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define MOD 1000000007

typedef long long int ll;

const ll INF=(ll)1e18;

int main(){
  int N;
  cin >> N;
  vector<ll> a(N);
  REP(i,N){
    cin >> a[i];
  }

  ll ans=0;

  REP(i,61){
    ll cnt0=0;    
    ll cnt1=0;
    REP(i,N){
      if(a[i]&1==1){
        cnt1++;
      }else{
        cnt0++;
      }
    }
    REP(i,N){
      a[i] = a[i] >> 1;
    }

    ll tmp=1;
    tmp = tmp << i;
    tmp %= MOD; 
    ans += ((( tmp * cnt0 ) % MOD) * cnt1) % MOD;
    ans %= MOD;
  }
  cout << ans << endl;

}



Measured memory_bytes: 2560
use std::str::FromStr;
use std::collections::HashSet;

fn get_one<T : FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    return s.trim().parse().ok().unwrap();
}

fn get_vec<T : FromStr>() -> Vec<T> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    return s.trim().split_whitespace().map(|e| e.parse().ok().unwrap()).collect();
}

fn main() {
    let nk : Vec<i32> = get_vec();
    let n : i32 = nk[0];
    let d : Vec<i32> = get_vec();
    let set : HashSet<i32> = d.into_iter().collect();

    let mut ans = n;
    loop {
        let mut solved = true;
        let mut cur = ans;
        while cur > 0 {
            if set.contains(&(cur % 10)) {
                solved = false;
                break;
            }
            cur = cur / 10;
        }
        if solved {
            break;
        }
        ans += 1;
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
import sys
s = input()
n = len(s)
def check(string):
    flag = 1
    l = len(string)
    for i in range(l):
        if string[i] != string[-i-1]:
            flag = 0
            break
    return flag

if check(s):
    if check(s[:(n-1)//2]):
        if check(s[-1+(n+3)//2:]):
            print('Yes')
            sys.exit()
print('No')

Measured memory_bytes: 3060
s = gets.strip.split('')
t = gets.strip.split('')

hs = {}
s.each { |c| hs[c] = hs[c].nil? ? 1 : hs[c] + 1 }

ht = {}
t.each { |c| ht[c] = ht[c].nil? ? 1 : ht[c] + 1 }

puts hs.values.sort == ht.values.sort ? 'Yes' : 'No'


Measured memory_bytes: 22780
object Main {
  def main(args: Array[String]): Unit = {
    solve
  }

  def solve(): Unit = {
    val sc = new java.util.Scanner(System.in)
    val n = sc.nextInt
    val k = sc.nextLong
    val q = sc.nextInt
    val wincounts = new Array[Int](n)
    for (i <- 0 until q) {
      val win = sc.nextInt - 1
      wincounts(win) += 1
    }

    val pw = new java.io.PrintWriter(System.out)
    for (i <- 0 until n) {
      pw.println(if (k - q + wincounts(i) > 0) "Yes" else "No")
    }
    pw.flush()
  }
}


Measured memory_bytes: 51964
#include <iostream>
#include <vector>
#include <map>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main()
{
    int n;
    cin >> n;
    string s;
    cin >> s;
    int ans = 1;
    rep(i, n-1){
        if(s[i] != s[i+1]){
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 512
#include<iostream>
#include<vector>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
int main() {
    ll n, k;
    cin >> n >> k;
    if (n < k) {
        cout << min(n, k - n) << endl;
    } else if (n == k) {
        cout << 0 << endl;
    } else {
        ll l = n / k;
        cout << min(n - (l * k), ((l + 1) * k - n)) << endl;
    }
}


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

def main():
  n, m = map(int, input().split())
  arg = [int(i) for i in input().split()]
  for i in arg:
    n -= i
    if n < 0:
      return -1
    
  return n
  
if __name__ == '__main__':
  print(main())

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

int main() {
	// your code goes here
	int i,k=0;
	string s;
	cin>>s;
	for(i=0;i<4;i++)
	{
	    if(s[i]=='+')
	    k++;
	    else
	    k--;
	}
	cout<<k<<endl;
}


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

using namespace std;

int main()
{
    #ifdef LOCAL_EXEC
    #else
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    #endif // LOCAL_EXEC
    long long int n,i,j,k,x=0,y=0,sum=0,h,w,m;
    map<long long int,long long int>rt,ct;
    cin>>h>>w>>m;
    map<pair<long long int,long long int>,long long int>mt;
    for(i=1;i<=m;i++){
        cin>>x>>y;
        rt[x]+=1;
        ct[y]+=1;
        mt[{x,y}]=1;
    }
    map<long long int,long long int>::iterator it;
    x=0;
    y=0;
    vector<long long int>r,c;
    for(it=rt.begin();it!=rt.end();it++){
        x=max(x,it->second);
    }
    for(it=ct.begin();it!=ct.end();it++){
        y=max(y,it->second);
    }
    for(it=rt.begin();it!=rt.end();it++){
        if(it->second==x)
            r.push_back(it->first);
    }
    for(it=ct.begin();it!=ct.end();it++){
        if(it->second==y)
            c.push_back(it->first);
    }
    sum=x+y;
    for(i=0;i<r.size();i++){
        for(j=0;j<c.size();j++){
            if(mt[{r[i],c[j]}]==0)
                break;
        }
        if(j<c.size())
            break;
    }
    if(i<r.size())
        cout<<x+y;
    else
        cout<<x+y-1;
    return 0;
}


Measured memory_bytes: 67832
N = int(input())
def primes(n):
    is_prime = [True] * (n + 1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5) + 1):
        if not is_prime[i]:
            continue
        for j in range(i * 2, n + 1, i):
            is_prime[j] = False
    return [i for i in range(n + 1) if is_prime[i]]
    
primes = primes(55555)
primes2 = [i for i in primes if i%5 == 1]
print(*primes2[:N])

Measured memory_bytes: 3572
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<cmath>
using namespace std;
#define REP(i, limit) for(int i=0; i< limit; ++i)
#define FOR(i, j, limit) for(int i=j; i< limit; ++i)
#define DUMP(a) REP(d,a.size()){cout<<a[d];if(d!=a.size()-1)cout<<" ";else cout<<endl;}
#define ECHO(x) cout<<x<<endl;
#define MEMSET(a, n, x) REP(i, n) a[i]=x;
#define ARRIN(a, n) REP(i, n) cin>>a[i];
#define LL long long
int INF = 2147483647;
LL LINF = 9223372036854775807;
LL MOD = 1000000007;
typedef pair<int, int>P;
typedef pair<LL, LL>PL;
typedef vector<int> vi;
typedef vector<LL> vl;


int main(){
  int n;
  string s;
  cin>>s;
  n=s.size();

  int l=0, r=n-1, ans=0;
  while(r-l>0){
    //cout<<s[l]<<s[r]<<endl;
    if(s[l]==s[r]) ++l, --r;
    else if(s[l]=='x') ++l, ++ans;
    else if(s[r]=='x') --r, ++ans;
    else {
      cout<<-1<<endl;
      return 0;
    }
  }
  cout<<ans<<endl;
  return 0;

  return 0;
}


Measured memory_bytes: 512
A = int(input())
B = int(input())
C = int(input())
X = int(input())

count = 0

for i in range(A + 1):
  temp = X - i*500
  if temp ==0:
    count = count + 1
    continue
  elif temp > 0:
    
    for j in range(B + 1):
      tempB = temp -j *100
      if temp == 0:
        count = count +1
        continue
      elif temp>0:
        
        for h in range(C + 1):
          tempC = tempB -h * 50
          if tempC == 0:
            count = count + 1
            continue
          else:
            continue
      else:
        continue
  else:
    continue
    
print(count)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
int main(){
	string s1, s2;
	cin >> s1;
	int ans = 0;
	while(cin >> s2){
		if(s2=="END_OF_TEXT")
			break;
		for(int i=0; i<s2.size(); i++)
			if(s2[i]>='A' && s2[i]<='Z')
				s2[i] += 'a'-'A';
		if(s1==s2)
			ans ++;
	}
	cout << ans << endl;
	return 0;
}


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

int main() {
	int n;
	cin >> n;
	
	for (int i = 0; 7 * i <= n; i++) {
		if ((n - 7 * i) % 4 == 0) {
			cout << "Yes" << endl;
			return 0;
		}
	}
	cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
def gcd(x,y):
    if x<y:
        x,y=y,x
    if y==0:
        return x
    else:
        return gcd(y,x%y)

T=int(input())
for _ in range(T):
    A,B,C,D=map(int,input().split())
    if D<B:
        print("No")
        continue
    if A<B:
        print("No")
        continue
    if C>=B:
        print("Yes")
        continue
    a=A%B
    d=D%B
    g=gcd(d,B)
    k=(C-a)//g
    if a+(k+1)*g>=B:
        print("Yes")
    else:
        print("No")

Measured memory_bytes: 41840
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
typedef long long ll;
const long long INF = 1LL << 60;
typedef pair<int, int> P;
int main()
{
    string s;
    cin >> s;

    int g = 0, p = 0, w = 0, l = 0;
    rep(i, s.size()) {
        if (p + 1 <= g) {
            if (s[i] == 'g') {
                w++;
            }
            p++;
        }
        else {
            if (s[i] == 'p') {
                l++;
            }
            g++;
        }
    }

    cout << w - l << endl;
    return 0;
}

Measured memory_bytes: 512
# -*- coding: utf-8 -*-

import sys
from collections import Counter

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

N=INT()
AB=[(INT(), 'pc') for i in range(N)]+[(INT(), 'plug') for i in range(N)]
AB.sort()

C=Counter()
ans=1
for i in range(N*2):
    a,_type=AB[i]
    if C['pc']==C['plug']:
        C[_type]+=1
    elif C['pc']>C['plug']:
        if _type=='pc':
            C['pc']+=1
        else:
            ans=(ans*C['pc'])%MOD
            C['pc']-=1
    elif C['pc']<C['plug']:
        if _type=='plug':
            C['plug']+=1
        else:
            ans=(ans*C['plug'])%MOD
            C['plug']-=1
print(ans)


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

int main()
{
  int64_t N, K, ans = 0;
  cin >> N >> K;
  vector<int64_t> A(N), B(N);
  for (int i = 0; i < N; i++)
  {
    cin >> A.at(i) >> B.at(i);
  }
  for (int i = 0; i < N; i++)
  {
    bool ok = true;
    for (int j = 0; j <= 30; j++)
    {
      if (!(K & (1 << j)) && A.at(i) & (1 << j))
      {
        ok = false;
        break;
      }
    }
    if (ok)
    {
      ans += B.at(i);
    }
  }
  for (int i = 30; i >= 0; i--)
  {
    int64_t k = K;
    if (!(k & (1 << i)))
      continue;
    k &= ~(1 << i);
    for (int j = i - 1; j >= 0; j--)
    {
      k |= (1 << j);
    }
    int64_t tmp = 0;
    for (int l = 0; l < N; l++)
    {
      bool ok = true;
      for (int m = 0; m <= 30; m++)
      {
        if (!(k & (1 << m)) && A.at(l) & (1 << m))
        {
          ok = false;
          break;
        }
      }
      if (ok)
      {
        tmp += B.at(l);
      }
    }
    ans = max(ans, tmp);
  }
  cout << ans << endl;
}


Measured memory_bytes: 4832
#include <cstdio>
using namespace std;
int a,b;
int main(){
    scanf("%d%d",&a,&b);
    if(a>0)puts("Positive");               //情况1
    else if(b>=0)puts("Zero");             //情况2
    else if((a&1)^(b&1))puts("Positive");  //情况3
    else puts("Negative");
    return 0;
}

Measured memory_bytes: 128
#include <cmath>
#include <cstdio>
#include <algorithm>

#define MAX_N 300
const double PI=acos(-1.0);

struct Point{
    double x,y;
    Point(){
        x=y=0;
    }
    bool operator<(const Point& p)const{
        return this->x < p.x;
    }
};

struct comp{
    bool operator()(const Point &P1, const Point &P2){
        return P1.x < P2.x;
    }
    bool operator()(const Point &P, double d){
        return P.x < d;
    }
    bool operator()(double d, const Point &P){
        return d < P.x;
    }
};

Point points[MAX_N];
int N;

double distance(Point *a, Point *b){
    return std::sqrt(pow(a->x-b->x,2)+pow(a->y-b->y,2));
}

double distance2(Point *a, Point *b){
    return pow(a->x-b->x,2)+pow(a->y-b->y,2);
}

int solve(){
    Point C, *P1, *P2, *P3;
    int max=1;
    for(int i=0;i<N;i++){
        P1=&points[i];
        Point *LB,*UB;
        LB=std::lower_bound(points,points+N,P1->x-2.0001,comp());
        UB=std::upper_bound(points,points+N,P1->x+2.0001,comp());
        for(int j=(LB-points);j<(UB-points);j++){
            if(i==j) continue;
            P2=&points[j];
            if(distance(P1,P2)>2.0) continue;

            double alpha,beta;
            alpha=acos(distance(P1,P2)/2.0);
            if((P2->x-P1->x)>=0){
                if((P2->y - P1->y)>=0){
                    beta=atan((P2->y - P1->y) / (P2->x - P1->x));
                }else{
                    beta=atan((P2->y - P1->y) / (P2->x - P1->x))+2.0*PI;
                }
            }else{
                beta=atan((P2->y - P1->y) / (P2->x - P1->x))+PI;
            }
            C.x=P1->x+cos(alpha+beta);
            C.y=P1->y+sin(alpha+beta);

            int enclosed=0;
            Point *lb,*ub;
            lb=std::lower_bound(points,points+N,C.x-1.0001,comp());
            ub=std::upper_bound(points,points+N,C.x+1.0001,comp());
            for(int k=(lb-points);k<(ub-points);k++){
                if(k==i||k==j){
                    enclosed++;
                    continue;
                }
                P3=&points[k];
                if(distance2(P3,&C)<1.0) enclosed++;
            }
            if(enclosed>max) max=enclosed;
            if(max==N) return max;
        }
    }
    return max;
}

int main(void){
    while(scanf("%d",&N), N){
        for(int i=0;i<N;i++){
            scanf("%lf %lf", &points[i].x, &points[i].y);
        }
        std::sort(points,points+N);
        printf("%d\n",solve());
    }
    return 0;
}

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

int main() {
  int N, M;
  cin >> N >> M;
   
  vector<int> vec(M*2);
  
  for (int i = 0; i < M*2; i++) {
    cin >> vec.at(i);
  }
  
  
  for (int j = 0; j < N; j++) {
    int count = 0;
    for (int k = 0; k < M*2; k++) {
      if (vec.at(k) == j+1) {
        count++;
      }
    }
    cout << count << endl;
  }
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#define swap(type ,a ,b) {type t; t=a; a=b; b=t;}
#define forN(i,n) for(i=0;i<n;i++)
#define forR(i,s,n) for(i=s;i<n;i++)
#define ll long long
#define pb(t,d,n) {t p;int i;forN(i,n){cin>>p;d.push_back(p);}}

using namespace std;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int,int> pii;

typedef vector<pair<int,int>> vpii;

int main(){
    string s;
    int i,n,res,tmp;
    cin >> s;
    res = 0;
    n = s.length();
    forN(i,n){
        if((int)s[i]-48 != (tmp = i%2)){
            res++;
            (int)s[i] +1 - tmp *2;
        }
    }
    cout << min(res, n-res) << endl;
}

Measured memory_bytes: 512
#include <algorithm>
#include <cmath>
#include <complex>
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <locale>
#include <map>
#include <numeric>
#include <queue>
#include <string>
#include <vector>

const long long int INF = 1e9;
typedef long long int ll;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define Rep(i, n) for(int i = 1; i <= (int)(n); i++)
#define llrep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define llRep(i, n) for(ll i = 1; i <= (ll)(n); i++)

using namespace std;

struct Point{
	int x,y;
};

bool vector_finder(std::vector<int> vec, int number) {
    auto itr = std::find(vec.begin(), vec.end(), number);
    size_t index = std::distance( vec.begin(), itr );
  if (index != vec.size()) { // 発見できたとき
    return true;
    }
  else { // 発見できなかったとき
    return false;
    }
}

ll factorial(ll N){
    ll ans = 1;
    llRep(i,N){
        ans *= i;
    }
    return ans;
}

ll extended_factorial(ll N){
    ll ans = 1;
    llRep(i,N){
        ans *= i;
        ans %= (ll)(1e9+7);
    }
    return ans;
}

vector<ll> Eratosthenes(ll N){
    bool arr[N+1];
    //initialization
    arr[0] = false;
    arr[1] = false;
	for(ll i = 2; i < N+1; i++){
		arr[i] = true;
	}
    //eratosthenes
	for(ll i = 2; i <= sqrt(N); i++){
		if(arr[i]){
			for(ll j = 0; i * (j + 2) <= N; j++){
				arr[i *(j + 2)] = false;//not prime number
			}
		}
	}
    vector<ll> prime;
    llRep(i,N){
        if (arr[i]==true){
            prime.push_back(i);
        }
    }
    return prime;
}

char alphabet[] = {
    'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'
};

// 二分探索
// llrep(i,N){
//     b = B[i];
//     auto cntA = lower_bound(A.begin(), A.end(), b);//イテレータなのでそのままllに変換とかはできない
//     auto cntC = upper_bound(C.begin(), C.end(), b);
//     ll cntA_ll = distance(A.begin(), cntA);
//     ll cntC_ll = C.size() - distance(C.begin(), cntC);
//     cnt += (cntA_ll * cntC_ll);
// }


int main(){
    string S;
    cin >> S;
    int y = stoi(S.substr(0,4));
    int m = stoi(S.substr(5,2));
    int d = stoi(S.substr(8,2));
    int date = y * 1e4 + m * 1e2 + d;
    if (date <= 20190430) cout << "Heisei" << endl;
    else cout << "TBD" << endl;

    return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;

namespace ITP1_3_C
{
	class Program
	{
		static void Main(string[] args)
		{
			List<Tuple<int, int>> ts = new List<Tuple<int, int>>();

			for(int i = 1; i <= 3000; i++) {
				string[] vs = Console.ReadLine().Split(' ');
				int x = int.Parse(vs[0]);
				int y = int.Parse(vs[1]);

				if(x == 0 && y == 0) {
					break;
				}

				ts.Add(Tuple.Create(x, y));
			}

			foreach(Tuple<int, int> t in ts) {
				if(t.Item1 < t.Item2) {
					Console.WriteLine($"{t.Item1} {t.Item2}");
				}
				else {
					Console.WriteLine($"{t.Item2} {t.Item1}");
				}
			}
		}
	}
}



Measured memory_bytes: 13936
#include<stdio.h>

int N,M,R,ans=100000000;
int r[8];
int dist[200][200];
int visit[8];

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

void dfs(int c,int v,int dis){
	if(c==R)ans=min(ans,dis);
	for(int i=0;i<R;i++){
		if(visit[i]==0){
			visit[i]=1;
			dfs(c+1,i,dis+dist[r[v]][r[i]]);
			visit[i]=0;
		}
	}
}

int main(){
	scanf("%d%d%d",&N,&M,&R);
	
	for(int i=0;i<R;i++){
		scanf("%d",&r[i]);
		r[i]--;
	}
	
	for(int i=0;i<N;i++){
		for(int j=0;j<N;j++){
			if(i==j)dist[i][j]=0;
			else dist[i][j]=100000000;
		}
	}
	
	for(int i=0;i<M;i++){
		int A,B,C;
		scanf("%d%d%d",&A,&B,&C);
		A--;
		B--;
		dist[A][B]=dist[B][A]=C;
	}
	
	for(int k=0;k<N;k++)
		for(int i=0;i<N;i++)
			for(int j=0;j<N;j++)
				dist[i][j]=min(dist[i][j],dist[i][k]+dist[j][k]);
	
	for(int i=0;i<R;i++)dfs(0,i,0);
	
	printf("%d\n",ans);
	return 0;
}

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

int main(int argc, char const *argv[])
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    ll N;
    string S;

    cin >> N >> S;

    if (N&1) {
        cout << "No";
        return 0;
    }

    bool correct = true;
    for (int i = 0; i < N/2; i++) {
        if (S[i] != S[i + N/2]) {
            correct = false;
            break;
        }
    }

    if (correct) cout << "Yes";
    else cout << "No";
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define maxn 100
#define maxw 100001
int main()
{
    long long n,w;
    cin>>n>>w;
    long long dp[maxn][maxw], weight[maxn], val[maxn];
    for(long long i = 0; i < n; i++) cin>>weight[i]>>val[i];
    for(long long i = 0; i <= w; i++) dp[0][i] = 0;
    dp[0][w - weight[0]] = val[0];
    for(long long i = 1; i < n; i++)
    {
        for(long long j = 0; j <= w; j++)
        {
            if(j + weight[i] > w) dp[i][j] = dp[i-1][j];
            else dp[i][j] = max(val[i] + dp[i-1][j+weight[i]], dp[i-1][j]);
        }
    }
    long long max = 0;
    for(long long i = 0; i <= w; i++)
    {
        if(dp[n-1][i] > max) max = dp[n-1][i];
    }
    cout<<max;
    return 0;
}

Measured memory_bytes: 81752
#include <bits/stdc++.h>
#define REP(i,n) for(int (i)=0;(i)<(n);(i)++)
using namespace std;
typedef long long ll;
const ll mod = 1e9+7;
#define all(x) (x).begin(),(x).end()

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

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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    std::cout<<std::fixed<<std::setprecision(10);
    int N;
    cin >> N;
    vector<int> X(N),Y(N);
    REP(i,N){
        cin >> X[i];
        cin >> Y[i];
    }
    double sum;
    for(int i = 0;i<N;i++){
        for(int l = i+1;l<N;l++){
            sum += sqrt((X[i]-X[l])*(X[i]-X[l]) + (Y[i]-Y[l])*(Y[i]-Y[l]));
        }
    }
    double answer = 2*sum/N;
    cout <<answer<< "\n";
}

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

int main(){
    int N;
    cin >> N;
    vector<int> arr_d(N, 0);
    for(int i = 0; i < N; i++) cin >> arr_d[i];

    // 昇順にソート
    sort(arr_d.begin(), arr_d.end());

    // 問題数をABCとARCで同じにする
    int num_q = N / 2;

    // arr_d[num_q-1]より大きくarr_d[num_q]以下の整数の数 = K
    int K = arr_d[num_q] - arr_d[num_q-1];

    cout << K << endl;

    return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
typedef     long long    ll;
typedef     vector<int> vi;
typedef     vector<long long> vl;
typedef     pair<int, int>pi;
typedef     pair<long long, long long>pl;
#define F   first
#define S   second
#define pb  push_back
#define     all(x)      x.begin() , x.end()
#define mp  make_pair
#define       FOR(i,a,b) for(i=a;i<=b;i++)
#define     mem(a)      memset(a , 0 ,sizeof a)
#define     memn(a)     memset(a , -1 ,sizeof a)
int a[5];
int main()
{
  int t=1;
  //cin>>t;
  while(t--)
  {
    int a1,b;
       cin>>a1>>b;
       a[a1]=1;a[b]=1;
       for(int i=1;i<=3;i++)
       {
        if(a[i]==0)  
        {
          cout<<i<<endl;
        }
    }
  }
 
  return 0;
}

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

#define SAFE_DELETE( x ) { if ( x ){ delete x; x = NULL; } }

struct tCell{
	tCell() : side1( 0 ), side2( 0 ), diagonal( 0 ), prev( NULL ), next( NULL ){}
	int side1, side2, diagonal;
	tCell *prev, *next;
};

class MyArray{
public:
	MyArray() : mSize( 0 ), head( NULL ), tail( NULL ){
		head = new tCell;
		tail = new tCell;
		head->next = tail;
		tail->prev = head;
	}
	~MyArray(){
		for ( int i = mSize; i > 0; --i ){
			tCell* cell = tail->prev;
			cell->prev->next = cell->next;
			cell->next->prev = cell->prev;
			SAFE_DELETE( cell );
		}
		SAFE_DELETE( tail );
		SAFE_DELETE( head );
	}

	void pushBack( int a, int b, int c ){
		++mSize;
		tCell* cell = new tCell;
		cell->side1 = a;
		cell->side2 = b;
		cell->diagonal = c;
		cell->prev = tail->prev;
		cell->next = tail;
		cell->prev->next = cell;
		cell->next->prev = cell;
	}
	int size(){ return mSize; }

	tCell operator[]( int d ){
		tCell* cell = head->next;
		if ( d >= mSize ){ cell = NULL; return *cell; }
		for ( int i = 0; i < d; ++i ){
			cell = cell->next;
		}
		return *cell;
	}

private:
	int mSize;
	tCell *head, *tail;
};

int main(){
	char c;
	int side1, side2, diagonal;
	MyArray ma;

	while ( cin >> side1 >> c >> side2 >> c >> diagonal ){
		ma.pushBack( side1, side2, diagonal );
	}

	side1 = side2 = 0;

	for ( int i = 0; i < ma.size(); ++i ){
		if ( ma[ i ].side1 == ma[ i ].side2 ){
			++side2;
		}else{
			double oblique = sqrt( pow( static_cast< double >( ma[ i ].side1 ), 2.0 )
								 + pow( static_cast< double >( ma[ i ].side2 ), 2.0 ) );
			if ( static_cast< double >( ma[ i ].diagonal ) == oblique ){
				++side1;
			}
		}
	}

	cout << side1 << endl << side2 << endl;

	return 0;
}

Measured memory_bytes: 0
use proconio::input;

#[allow(unused_variables)]
fn main() {
    input! {
      s: String,
    };

    if s.contains("RRR") {
        println!("3");
    } else if s.contains("RR") {
        println!("2");
    } else if s.contains("R") {
        println!("1");
    } else {
        println!("0");
    }
}


Measured memory_bytes: 2128
#include<stdio.h>
#include<math.h>
int main(void){
  double x1,y1,x2,y2,xq,yq,n,m,x,y;
  while(scanf("%lf,%lf,%lf,%lf,%lf,%lf",&x1,&y1,&x2,&y2,&xq,&yq) != EOF){
    if(x1 == x2){
      printf("%f %f\n",xq+(x1-xq)*2,yq);
      continue;
    }
    if(y1 == y2){
      printf("%f %f\n",xq,yq+(y1-yq)*2);
      continue;
    }
    m = (y2-y1)/(x2-x1);
    n = ((-y2+y1)*x1) / (x2-x1)+y1;
    y = (2*m*xq+2*n+(m*m-1)*yq)/(m*m+1);
    x = ( (1-m*m) * xq + 2*m*yq - 2*m*n)/(m*m+1);
    printf("%f %f\n",x,y);
  }
  return 0;
}

Measured memory_bytes: 0
/* بِسْمِ اللَّهِ الرَّحْمَٰنِ الرَّحِيمِ */
//codeforces
#include <bits/stdc++.h>
//#pragma GCC target ("avx2")
//#pragma GCC optimization ("O3")
//#pragma GCC optimization ("unroll-loops")
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define FASTIO ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define mp make_pair
#define pb push_back
#define sz(v) ((int)v.size())
#define all(v) v.begin(), v.end()
void parseArray(ll* A,ll n){ for ( ll K = 0; K < n; K++){ cin >> A[K]; } }
ll modInverse(ll a, ll b){ return 1<a ? b - modInverse(b%a, a)*b/a : 1; }
ll gcd(ll a, ll b){ return b?gcd(b, a % b):a; }
ll lcm(ll a, ll b){ return (a*b)/gcd(a, b); }
ld dist(ld x, ld y, ld a, ld b){ return sqrt((x-a)*(x-a) + (y-b)*(y-b)); }
void debug(ll* a, ll n) { for ( ll k = 0; k < n; k++ ){ cerr << a[k] << " ";} cout << "\n"; }
#define PI 3.14159265358979323846
#define FF first
#define SS second

int main(){
	FASTIO;
	ll n, d; cin >> n >> d; d = d * d;
	ll ans = 0;
	for ( int k = 0; k < n; k++ ){
		ll x, y; cin >> x >> y;
		if (x * x + y * y <= d)
			ans++;
	}
	cout << ans << endl;
	return 0;
}

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

#define pb push_back
#define pob pop_back
#define mp make_pair
#define f first
#define s second

typedef long long ll;
const ll Inf = 1e18;
const ll mod = 1e9 + 7;

void solve(){
	ll w,h,x,y;
	cin>>w>>h>>x>>y;
	double ans = (double)(w*h)*0.5;
	cout<<fixed<<showpoint;
	cout<<setprecision(6);
	cout<<ans<<" ";
	if(w == 2*x && h == 2*y) cout<<1<<"\n";
	else cout<<0<<"\n";
}

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


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

int main() {
  int N;
  cin >> N;
  vector<int64_t> height(N);
  for (int i=0; i<N; i++) {
    cin >> height[i];
  }
  
  vector<int> times(N);
  int rank = 0;
  for (int i=N; i>0; i--) {
    if (i == N) {
      times[i-1] = 0;
    }
    else if (height[i-1] >= height[i]) {
      rank++;
      times[i-1] = rank;
    }
    else if (height[i-1] < height[i]) {
      rank = 0;
      times[i-1] =rank;
    }
  }
  
  sort(times.begin(), times.end());
  
  cout << times[N-1] << endl;
}

Measured memory_bytes: 1408
def args():
    return int(input())


def F(a, b):
    return len(str(b)) if len(str(a)) < len(str(b)) else len(str(a))


def solve(N):
    import math

    res = len(str(N))
    for a in range(1, int(math.ceil(math.sqrt(N))) + 1):
        if N % a == 0:
            b = N // a
            res = min(res, F(a, b))

    return res


if __name__ == '__main__':
    n = args()
    ans = solve(n)
    print(ans)


Measured memory_bytes: 39024
import Control.Monad
import Control.Applicative
import Data.Functor
import Data.Function
import Data.Monoid
import Data.Maybe
import Data.List
import Data.Foldable (foldMap)
import Data.List.Split
import Data.Char
import Data.Ratio
import Data.Ord
import Data.Tuple
import Data.Array.IO
import Data.IORef
import Control.Monad.ST
import Data.STRef
 
readInt = read :: String -> Int
readDouble = read :: String -> Double
getInt = readLn :: IO Int
getInts = map readInt . words <$> getLine
sjoin :: (Show a) => [a] -> String
sjoin = unwords . map show
cond :: a -> a -> Bool -> a
cond t f c = if c then t else f
applyBin :: (b -> c -> d) -> (a -> b) -> (a -> c) -> a -> d
applyBin op f g x = op (f x) $ g x
applyUni :: (a -> b -> c) -> (a -> b) -> a -> c
applyUni op f x = op x $ f x
applyTuple :: (a -> b, a -> c) -> a -> (b, c)
applyTuple (f,g) a = (f a, g a)
-- end of templete

dec [] = []
dec ('@':n:c:s) = replicate (digitToInt n) c ++ dec s
dec (c:s) = (c:dec s)

main = map dec . lines <$> getContents >>= mapM_ putStrLn

Measured memory_bytes: 3452
#pragma region include
#include "bits/stdc++.h"
#define ALL(obj) (obj).begin(),(obj).end()
#define RALL(obj) (obj).rbegin(),(obj).rend()
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define REPR(i, n) for(int i = (int)(n); i >= 0; i--)
#define FOR(i,n,m) for(int i = (int)(n); i < int(m); i++)
#define MOD (int)(1e9+7)
#define INF (int)(1e9)
#define LLINF (int)(4e18)
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
void input() {}
template<typename... R> void input(int& f, R&... r) { scanf("%d", &f); input(r...); }
template<typename... R> void input(double& f, R&... r) { scanf("%lf", &f); input(r...); }
template<typename... R> void input(ll& f, R&... r) { scanf("%lld", &f); input(r...); }
template<typename... R> void input(char& f, R&... r) { scanf("%c", &f); input(r...); }
template<typename T, typename... R> void input(vector<T>& f, R&... r) { REP(i, f.size())input(f[i]); input(r...); }
#pragma endregion

int main() {
    ll X, Y; input(X,Y);
    if (X % Y != 0) cout << X * (Y + 1) << endl;
    else cout << -1 << endl;
    getchar(); getchar();
}

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

using namespace std;
// using Graph = vector<vector<ll>>;

typedef long long ll;
typedef pair<ll, ll> pll;
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int(i) = 0; (i) < (n); (i)++)

const ll MOD = 1000000007;
const ll INF = 1e18; //1*10^18
const double PI = 3.14159265;

int ctoi(char c)
{
  if (c >= '0' && c <= '9')
  {
    return c - '0';
  }
  return 0;
}

ll gcd(ll x, ll y) { return (x % y) ? gcd(y, x % y) : y; }
//最大公約数
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }
//最小公倍数

ll powll(ll a, ll n)
{ //O(log n)
  ll res = 1;
  while (n > 0)
  {
    if (n & 1) //(n & 1)=(n % 2 !=0)
    {
      res = res * a;
    }
    a = a * a;
    n >>= 1; //(n & 1)=(n % 2 !=0)
  }
  return res;
}

ll modpow(ll a, ll n, ll mod) //O(log n)
{
  ll res = 1;
  while (n > 0)
  {
    if (n & 1) //(n & 1)=(n % 2 !=0)
    {
      res = res * a % mod;
    }
    a = a * a % mod;
    n >>= 1; //(n>>=1)=(n/2)
  }
  return res;
}

int ReturnDigit(ll num)
{
  string number = to_string(num);
  return number.length();
}

const ll MAX = 1e4;
long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit()
{
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for (int i = 2; i < MAX; i++)
  {
    fac[i] = fac[i - 1] * i % MOD;
    inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
    finv[i] = finv[i - 1] * inv[i] % MOD;
  }
}

// 二項係数計算
long long COM(int n, int k)
{
  if (n < k)
    return 0;
  if (n < 0 || k < 0)
    return 0;
  return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

struct UnionFind
{
  vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

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

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

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

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

int main()
{
  // srand((unsigned int)time(NULL));//--> rand()
  ll i, j, k, l, ans = 0;
  ll n, m, a;
  cin >> n >> m;
  for (i = 0; i < m; i++)
  {
    cin >> a;
    ans += a;
  }

  cout << max(n - ans, -1ll) << endl;
}


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

using namespace std ;
typedef long long ll ;
ll q , h , s , d  , n , ans ;
int main()
{
    scanf("%lld %lld %lld %lld" , &q , &h , &s , &d) ;
    scanf("%lld" , &n) ;
    ll mn = 1e18 ;

    if( 4ll*q <= mn ) mn = 4ll*q ;
    if( 2ll*h <= mn ) mn = 2ll*h ;
    if( s <= mn ) mn = s ;
    if( d <= mn*2ll ) mn = d ;

    if( mn == d ){
        ans+=(n/2ll)*d ;
        n%=2 ;
        if( n )
        ans+=min( s , min(4ll*q,2ll*h) ) ;
    }
    else
        ans = mn*n ;

    printf("%lld\n" , ans) ;



    return 0 ;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdlib>
#include <string>
#include <cstring>
#include <cmath>
#include <climits>
#include <ctime>
#define endl '\n'
#define ll long long
#define mod 1000000007
#define NCONS 1000000000
//#define NCONS 100001
//#define NCONS 1001
//#define NCONS 101
#define MCONS 2001
#define LIMIT 1000000000
#define TRUE 1
#define FALSE 0
#define toRadian(degree) ((degree) * (M_PI / 180.))
#define toDegree(radian) ((radian) * (180. / M_PI))
using namespace std;

int ret;

int watering(int N, vector<int> &h, int& mini)
{
    int watering = 0;
    
    int start = 0;
    while(h[start] == 0) start += 1;
    int ende = start;
    
    while(ende + 1 < N && h[ende + 1] != 0) ende += 1;
    
    for(int i = start; i <= ende; i++)
        mini = min(mini, h[i]);
    
    for(int i = start; i <= ende; i++)
    {
        watering += mini;
        h[i] -= mini;
    }
    
    
    return watering;
}

int main(void)
{
    cin.tie(NULL); ios_base::sync_with_stdio(false);
    int N; cin >> N; vector<int> h(N, 0); for(int i = 0; i < N; i++) cin >> h[i];
    int total = 0;
    for(int i = 0; i < N; i++) total += h[i];
    if(total == 0) { cout << 0; return 0; }
    
    int cur = 0;
    while(cur < total)
    {
        int mini = INT_MAX;
        auto temp = watering(N, h, mini);
        cur += temp;
        ret += mini;
    }
    
    
    
    cout << ret << endl;
    return 0;
}


Measured memory_bytes: 256