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

#define Fast           ios_base::sync_with_stdio(0);cin.tie(0),cout.tie(0)
#define FO             freopen("in.txt", "r", stdin)
#define FC             freopen("out.txt", "w", stdout)
#define aise           cout<<"aise"<<endl
#define pb             push_back
#define pf             push_front
#define ppb            pop_back
#define ppf            pop_front
#define mp             make_pair
#define ll             long long
#define all(x)         x.begin(), x.end()
#define mset(v, a)     memset(v, a, sizeof(v))
#define pll            pair< ll, ll >
#define pd             pair< double, double >
#define ff             first
#define ss             second
#define pi             acos(-1.0)
#define mxN            2010
#define inf            1e14
#define mod            1000000007
#define tc             ll tc;scanf("%lld",&tc);while(tc--)

//NCR iterative
/*voidcomb_table(intN)
{
    for(inti=0; i<=N; ++i)
    {
        for(intj=0; j<=i; ++j)
        {
            if(j==0or j==i)
            {
                C[i][j]=1LL;
            }
            else
            {
                C[i][j]=(C[i-1][j-1]+C[i-1][j]);
            }
        }
    }
}*/


//NCR recursive
/*ll dp[55][55];

ll NCR(ll n,ll r)
{

    if(n==r)
        return dp[n][r]=1;
    if(r==0)
        return dp[n][r]= 1;
    if(r==1)
        return dp[n][r]=n ;
    if(dp[n][r] != -1)
        return dp[n][r];
    return dp[n][r] = NCR(n-1,r)+NCR(n-1,r-1);
}*/

//Sieve:
/*bool Flag[1000010];
vector<ll> Prime;

void sieve()
{

    ll val=sqrt(1000010);
    for(ll i=4;i<=1000005; i+=2) Flag[i]=1;
    for(ll i=3;i <= val;i+=2)
    {

        if(Flag[i]==0)
        {

            for(ll j=i*i;j<=1000005;j+=i) Flag[j]=1;
        }
    }
    Flag[1]=1;
    for(ll i=1;i<=1000000;i++)
        if(Flag[i]==0) Prime.pb(i);
}*/


//Conversion
/*string bin(ll x)
{

    string ret;
    while(x)
    {

        ll t=x%2;
        char c;
        if(t==1)
            c='1';
        else
            c='0';
        ret.pb(c);
        x/=2;
    }
    reverse(all(ret));
    return ret;
}*/

/*ll lcm(ll x, ll y)
{

    ll ret=__gcd(x,y);
    return (x*y)/ret;
}*/

/*ll dx[]= {0,0,1,-1};
ll dy[]= {1,-1,0,0};*/

int main()
{
    ll n;
    cin >> n;
    vector< ll > v(n+2, 0), v1(n+2, 0), v2(n+2, 0);
    for(ll i = 1; i <= n; i++)
        cin >> v[i];
    for(ll i = 1; i <= n; i++)
    {

        v1[i] = __gcd(v1[i-1], v[i]);
    }
    for(ll i = n; i >= 1; i--)
    {

        v2[i] = __gcd(v2[i+1], v[i]);
    }
    ll ans = 0;
    for(ll i = 1; i<= n; i++)
    {

        ll x = v1[i-1], y = v2[i+1];
        ll z = __gcd(x, y);
        ans = max(ans, z);
    }
    cout << ans;
}


Measured memory_bytes: 5644
N = int(input())
S1 = input()
S2 = input()
mod = 10 ** 9 + 7

X = []
i = 0
while i < N:
    if i + 1 < N and S1[i] == S1[i + 1]:
        X.append("Y")
        i += 2
    else:
        X.append("T")
        i += 1


if X[0] == "Y":
    ans = 6
    before = "Y"
elif X[0] == "T":
    ans = 3
    before = "T"

for x in X[1:]:
    if before == "Y" and x == "Y":
        ans = ans * 3 % mod
        before = "Y"

    elif before == "Y" and x == "T":
        ans = ans * 1 % mod
        before = "T"

    elif before == "T" and x == "Y":
        ans = ans * 2 % mod
        before = "Y"

    elif before == "T" and x == "T":
        ans = ans * 2 % mod
        before = "T"

print(ans % mod)


Measured memory_bytes: 3064
#include <functional>
#include <algorithm>
#include <stdexcept>
#include <iostream>
#include <sstream>
#include <fstream>
#include <numeric>
#include <iomanip>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <cctype>
#include <vector>
#include <string>
#include <bitset>
#include <cmath>
#include <queue>
#include <stdio.h>
#include <stack>
#include <ctime>
#include <list>
#include <map>
#include <set>
#include <assert.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define TR(i,x) for(__typeof(x.begin()) i=x.begin();i!=x.end();i++)
#define ALL(x) x.begin(),x.end()
#define SORT(x) sort(ALL(x))
#define CLEAR(x) memset(x,0,sizeof(x))
#define FILL(x,c) memset(x,c,sizeof(x))

using namespace std;

#define PB push_back
#define MP make_pair

typedef map<int,int> MII;
typedef map<string,int> MSI;
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<long double> VD;
typedef pair<int,int> PII;
typedef long long int64;
typedef long long LL;
typedef unsigned int UI;
typedef long double LD;
typedef unsigned long long ULL;

const int MOD = 1000000007;

const int N = 4444;

int dp[N][N][2];

void solve(int caseId) {
  int n, m, k;
  cin >> n >> m >> k;

  int level = (n + m - 1) / (k - 1);

  int answer = 0;
  CLEAR(dp);
  dp[0][m][0] = 1;
  for (int l = 0; l < level; ++l) {
    for (int rest = 0; rest <= m; ++rest) {
      for (int empty = 0; empty < 2; ++empty) {
        for (int delta = 0; delta <= k && delta <= rest; ++delta) {
          if (delta == rest) {
            bool realEmpty = empty || n == 0 || (delta < k);
            if (realEmpty) {
              answer = (answer + dp[l][rest][empty]) % MOD;
            }
            continue;
          }
          if (delta < k) {
            if (delta < k - 1) {
              dp[l + 1][rest - delta][1] = (dp[l + 1][rest - delta][1] + dp[l][rest][empty]) % MOD;
            } else {
              dp[l + 1][rest - delta][empty] = (dp[l + 1][rest - delta][empty] + dp[l][rest][empty]) % MOD;
            }
          }
        }
      }
    }
  }

  cout << answer << endl;
}

int main() {
    int cases = 1;
    for (int caseNumber = 1; caseNumber <= cases; ++caseNumber) {
        solve(caseNumber);
    }
    return 0;
}


Measured memory_bytes: 154496
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <iostream>
using namespace std;
int main(){
  char O[51],E[51];
  scanf("%s",O);
  scanf("%s",E);
  int l=min(strlen(O),strlen(E));
  for(int i=0;i<l;i++){
    printf("%c%c",O[i],E[i]);
  }
  if(strlen(O)>strlen(E)) printf("%c",O[strlen(O)-1]);
  printf("\n");
  return 0;
}


Measured memory_bytes: 256
import Control.Applicative

data Dice = Dice { diceTop    :: String
                 , diceFront  :: String
                 , diceRight  :: String
                 , diceLeft   :: String
                 , diceBack   :: String
                 , diceBottom :: String
                 } deriving (Show, Eq)

makeDice :: [String] -> Dice
makeDice (t:f:r:l:b:bo:[]) = Dice t f r l b bo

diceToN :: Dice -> Dice
diceToN dice = dice { diceTop    = diceFront dice
                    , diceFront  = diceBottom dice
                    , diceBottom = diceBack dice
                    , diceBack   = diceTop dice
                    }

diceToS :: Dice -> Dice
diceToS dice = dice { diceTop    = diceBack dice
                    , diceFront  = diceTop dice
                    , diceBottom = diceFront dice
                    , diceBack   = diceBottom dice
                    }

diceToE :: Dice -> Dice
diceToE dice = dice { diceTop    = diceLeft dice
                    , diceLeft   = diceBottom dice
                    , diceBottom = diceRight dice
                    , diceRight  = diceTop dice
                    }

diceToW :: Dice -> Dice
diceToW dice = dice { diceTop    = diceRight dice
                    , diceLeft   = diceTop dice
                    , diceBottom = diceLeft dice
                    , diceRight  = diceBottom dice
                    }

diceMoveTo :: Char -> Dice -> Dice
diceMoveTo 'N' = diceToN
diceMoveTo 'S' = diceToS
diceMoveTo 'E' = diceToE
diceMoveTo 'W' = diceToW

diceMoves :: String -> Dice -> Dice
diceMoves []     dice = dice
diceMoves (s:ss) dice = diceMoves ss $ diceMoveTo s dice

diceMoveToTopFront :: String -> String -> Dice -> Dice
diceMoveToTopFront top front = moveToTop top . moveToFront front
  where
      moveToTop top dice
        | top == diceTop dice    = dice
        | top == diceBottom dice = diceMoves "EE" dice
        | top == diceLeft dice   = diceMoves "E"  dice
        | top == diceRight dice  = diceMoves "W"  dice
      moveToFront front dice
        | front == diceTop dice    = diceMoves "S"  dice
        | front == diceBottom dice = diceMoves "N"  dice
        | front == diceFront dice  = dice
        | front == diceBack dice   = diceMoves "NN" dice
        | front == diceLeft dice   = diceMoves "ES" dice
        | front == diceRight dice  = diceMoves "WS" dice

main :: IO ()
main = do
    dice1 <- makeDice.words <$> getLine
    dice2 <- makeDice.words <$> getLine

    if dice1 == diceMoveToTopFront (diceTop dice1) (diceFront dice1) dice2
       then putStrLn "Yes"
       else putStrLn "No"



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

const int MAX_N = (int)(1e5 + 5);

using ll = long long int;

int n;
ll a[MAX_N];

int over2;
int just1;
int just0;

int main(void){
  // Here your code !
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) {
    scanf("%lld\n", &(a[i]));
  }

  for (int i = 0; i < n; ++i) {
    int cnt = 0;
    while (true) {
      if (a[i] % 2 == 0) {
        a[i] /= 2;
        cnt += 1;
      }
      else {
        if (cnt >= 2) {
          over2 += 1;
        }
        else if (cnt == 1) {
          just1 += 1;
        }
        else {
          just0 += 1;
        }

        break;
      }
    }
  }

  int threshold = (n % 2 == 0) ? n / 2 : (n - 1) / 2;

  if ((just1 > 0 && (just1 + over2 + over2) >= n) || over2 >= threshold) {
    // cout << over2 << "_" << threshold << "_" << over1 << endl;
    printf("Yes\n");
  }
  else printf("No\n");

  return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>
#include <vector>
#include <cstring>
#include <bitset>
#include <cmath>
#include <iomanip>
#include <stack>
#include <set>
#include <queue>
#include <algorithm>
#include <deque>
#include <map>
#include <cmath>
#include <iomanip>
using namespace std;

#define INF 1e18
#define int long long

static const int  MOD = 1000000007;

void printMap(map<int, int> &mp) {
    for(auto i = mp.begin(); i != mp.end(); i++) {
        cout << i -> first << " ";
    }
    cout << endl;
    for(auto i = mp.begin(); i != mp.end(); i++) {
        cout << i -> second << " ";
    }
    cout << endl;
}

signed main() {
    int n; cin >> n;
    map<int, int> mp1, mp2;
    for(int i = 1; i <= n; i++) {
        int dif = abs((n - i) - (i - 1));
        mp1[dif]++;
    }
    for(int i = 0; i < n; i++) {
        int a; cin >> a;
        mp2[a]++;
    }

    if(mp1 != mp2) {
        cout << 0 << endl;
        return 0;
    }

    int ans = 1;
    for(auto i = mp1.begin(); i != mp1.end(); i++) {
        ans *= i -> second;
        ans %= MOD;
    }
    ans %= MOD;

    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 7296
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

int main(){
	int n,a,b;
	cin>>n>>a>>b;
	cout<<(n-a+1)*(n-b+1)<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
	int K, N;

	cin >> K >> N;

	int a = 0, b = 0,first = 0;
	int max = 0;
	cin >> a;
	first = a;
	for (int i = 1; i < N; i++)
	{
		b = a;
		cin >> a;
		if (a - b > max) max = a - b;
	}
	if (K - a + first > max) max = K - a + first;

	int ans = K - max;

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
w, h, n = map(int, raw_input().split())
x = [1 for i in range(w)]
y = [1 for i in range(h)]
for i in range(n):
    x1, y1, a = map(int, raw_input().split())
    if a == 1:
        for t in range(x1):
            x[t] = 0
    if a == 2:
        for t in range(x1, w):
            x[t] = 0
    if a == 3:
        for t in range(y1):
            y[t] = 0
    if a == 4:
        for t in range(y1, h):
            y[t] = 0
print sum(x)*sum(y)


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

const int INF = 1e9;
int N, M;
int opPos[10];
int depth[10];
int num[10];
string s;
set<int> ans;
int c;

bool isOperator(char c) {
	return c == '+' || c == '-' || c == '*' || c == '/';
}

void dfs(int d) {
	while(c < N && s[c] != ')') {
		if(s[c] == '(') {
			c++;
			dfs(d + 1);
			assert(s[c] == ')');
		}
		if(isOperator(s[c])) {
			for(int i = 0; i < M; i++) {
				if(opPos[i] == c) depth[i] = d;
			}
		}
		c++;
	}
}

int findMinPos(int l, int r) {
	int minId = -1;
	for(int i = 0; i < M; i++) {
		if(l <= opPos[i] && opPos[i] <= r) {
			if(minId == -1 || num[minId] > num[i]) minId = i;
		}
	}
	if(minId == -1) return -1;
	return opPos[minId];
}

int R(double n) {
	if(n > 0) return (int)floor(n);
	return (int)ceil(n);
	double an = abs(n);
	int ret = round(an - 1e-9);
	if(n < 0) ret *= -1;
	return ret;
}

int f(int l, int r) {
	int minPos = findMinPos(l, r);
	if(minPos == -1) {
		int ret = 0;
		while(s[l] == '(') l++;
		while(s[r] == ')') r--;
		for(int i = l; i <= r; i++) {
			assert(isdigit(s[i]));
			ret = ret * 10 + s[i] - '0';
		}
		return ret;
	}

	int vl = f(l, minPos - 1), vr = f(minPos + 1, r);
	if(vl == INF || vr == INF) return INF;
	char op = s[minPos];
	if(op == '+') return vl + vr;
	if(op == '-') return vl - vr;
	if(op == '*') return vl * vr;
	if(vr == 0) return INF;
	int ret = R((double)vl / vr);
	return ret;
}


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

	while(cin >> s, s != "#") {
		N = s.size();
		M = 0;
		for(int i = 0; i < N; i++) {
			if(isOperator(s[i])) {
				opPos[M] = i;
				depth[M] = 0;
				M++;
			}
		}
		c = 0;
		dfs(0);

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

		ans.clear();
		do {
			for(int i = 0; i < M; i++) {
				num[i] = p[i] + depth[i] * 100;
			}
			int res = f(0, N - 1);
			if(res != INF) ans.insert(res);
		} while(next_permutation(p.begin(), p.end()));

		cout << ans.size() << endl;
		/*for(auto a : ans) {
			cout << a << " ";
		}
		cout << endl;*/
	}
}

Measured memory_bytes: 3256
#include <stdio.h>

void reverse(int array[], int n){
	int temp;
	int i = 0;
	int j= n-1;
	while (i < j){
		temp = array[i];
		array[i] = array[j];
		array[j] = temp;
		i++;
		j--;
	}
}

int main(void){
	int n ;
	char buf[128];
	fgets(buf,128,stdin);
	sscanf(buf,"%d",&n);
	int array[n];
	for ( int i = 0; i < n ; i++){
		scanf("%d",&array[i]);
	}
	int j = 0;
	int arrayS[n];
	int i = n-1;
	if (n % 2 == 0){
		while (i > 0){
			arrayS[j] = array[i];
			i = i - 2;
			j++;
		}
		i = 0;
		while (i < n-1){
			arrayS[j] = array[i];
			i = i +2;
			j++;
		}
	}
	else if (n % 2 != 0){
		while (i >= 0){
			arrayS[j] = array[i];
			i = i - 2;
			j++;
		}
		i = 1;
		while (i < n){
			arrayS[j] = array[i];
			i = i +2;
			j++;
		}
	}
	/*
	int arrayS[n];
	for (int i = 0; i < n;i++){
		arrayS[j]= array[i];
		reverse(array,j);
		j++;
	}
	reverse(array,n);
	*/
	for (int i=0 ; i < n; i++){
		printf("%d ",arrayS[i]);
	}
	
	return (0);

}

Measured memory_bytes: 3712
let solve = Array.fold_left (fun ((c, c'), n) d ->
  (c', c), n + if c = d then 1 else 0)

let () =
  let s = read_line () in
  let s = Array.init (String.length s) (String.get s) in
  Printf.printf "%d\n" @@ min
    (snd @@ solve (('0', '1'), 0) s)
    (snd @@ solve (('1', '0'), 0) s)

Measured memory_bytes: 5504
#include <iostream>
#include <map>
#include <queue>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
#include <functional>
using namespace std;
#pragma warning (disable: 4996)

int N, H, A[1 << 18], B[1 << 18];
int dp[1 << 18];

int main() {
	cin >> H >> N;
	for (int i = 1; i <= N; i++) cin >> A[i] >> B[i];
	for (int i = 0; i <= H; i++) dp[i] = (1 << 30);

	dp[0] = 0;
	for (int i = 1; i <= N; i++) {
		for (int j = 0; j <= H; j++) dp[min(j + A[i], H)] = min(dp[min(j + A[i], H)], dp[j] + B[i]);
	}
	cout << dp[H] << endl;
	return 0;
}

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

using namespace std;

typedef long long ll;

const ll mod=1000000007;

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

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

 ll n;
  cin >> n;
  vector<long> t(n),a(n);
  ll res=1;
  rep(i,0,n) cin >>t[i];
  rep(i,0,n) cin >>a[i];
  
  if(t[n-2]<t[n-1]&&t[n-1]>a[n-1]) res*=0;
  if(a[0]>a[1]&&a[0]>t[0]) res*=0;
  
  
  
  rep(i,1,n-1){
    if(res==0) break;
   if(t[i-1]<t[i]) {
     if(t[i]>a[i]) res*=0; 
   }
     else if(a[i]>a[i+1]) {
       if(a[i]>t[i]) res*=0;
     }
   else {
     res*=min(t[i],a[i]);
   }
     res%=mod;
  }
  
 cout << res << endl;
  
}

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

const ll mod = 1e9 + 7;
int n;
vector<int> a;

int main()
{
    cin.tie(0);
    ios_base::sync_with_stdio(0);
    char c;
    cin >> c;
    if (c >= 'A' && c <= 'Z') {
        c = 'A';
    } else {
        c = 'a';
    }
    cout << c;
    return 0;
}

Measured memory_bytes: 3500
use std::fmt;
use std::io::stdin;
use std::io::BufRead;
use std::str;
use std::str::FromStr;

fn main() {
    let stdin = stdin();
	let mut scan = InputScanner::new(stdin.lock(),256);

	let mut answer = Vec::new();

	loop {
		let w:usize = scan.next();
		let h:usize = scan.next();

		if w == 0 && h == 0 {
			break;
		}

		let c: Vec<Vec<u32>> = (0..h).map(|_| (0..w)
			.map(|_| scan.next::<u32>())
			.collect::<Vec<u32>>()).collect::<Vec<Vec<u32>>>();

		let mut m: Vec<Vec<bool>> = (0..h).map(|_| (0..w)
			.map(|_| false)
			.collect::<Vec<bool>>()).collect::<Vec<Vec<bool>>>();

		let mut count = 0;

		for y in 0..h {
			for x in 0..w {
				if search(&c, x, y, w, h, &mut m) {
					count += 1;
				}
			}
		}

		answer.push(count);
	}

	for answer in answer {
		println!("{}", answer);
	}
}
fn search(c:&Vec<Vec<u32>>,x:usize,y:usize,w:usize,h:usize,m:&mut Vec<Vec<bool>>) -> bool {
    if m[y][x] || c[y][x] == 0 {
        false
    } else {
		m[y][x] = true;

        let x = x as i64;
        let y = y as i64;
		let w = w as i64;
		let h = h as i64;

        for &(dx,dy) in &[(-1,-1),(0,-1),(1,-1),(-1,0),(1,0),(-1,1),(0,1),(1,1)] {
            if dx + x >= 0 && dx + x < w && dy + y >= 0 && dy + y < h {
                search(c,(x+dx) as usize, (y+dy) as usize,w as usize,h as usize,m);
            }
        }
        true
    }
}
struct InputScanner<R: BufRead> {
	reader: R,
	buf: Vec<u8>, // Should never be empty
	pos: usize,   // Should never be out of bounds as long as the input ends with '\n'
}
impl<R: BufRead> InputScanner<R> {
	fn new(reader: R, capacity: usize) -> Self {
		InputScanner {
			reader: reader,
			buf: Vec::with_capacity(capacity),
			pos: 0,
		}
	}

	#[inline]
	fn next<T: FromStr>(&mut self) -> T
	where
		T::Err: fmt::Debug,
	{
		if self.buf.is_empty() {
			self._read_next_line();
		}
		let mut start = None;
		loop {
			match (self.buf[self.pos], start.is_some()) {
				(b' ', true) | (b'\n', true) | (b'\r', true) => break,
				(_, true) | (b' ', false) => self.pos += 1,
				(b'\n', false) | (b'\r', false) => self._read_next_line(),
				(_, false) => start = Some(self.pos),
			}
		}
		let target = &self.buf[start.unwrap()..self.pos];
		unsafe { str::from_utf8_unchecked(target) }.parse().unwrap()
	}

	#[inline]
	fn _read_next_line(&mut self) {
		self.pos = 0;
		self.buf.clear();
		if self.reader.read_until(b'\n', &mut self.buf).unwrap() == 0 {
			panic!("Reached EOF");
		}
	}
}




Measured memory_bytes: 5204
#include <cstdio>
#include <algorithm>
using namespace std;


int main() {
  
  int n, k, ans = 1;
  scanf("%d %d", &n, &k);
  if (n == 1)
    printf("%d\n", k);
  else {
    ans *= k;
    for (int i = 2; i <= n; i++)
      ans *= (k-1);
    
    printf("%d\n", ans);
  }
  
  
  
  return 0;
  
}



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

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

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

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

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

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

fn main() {
    input!{
        n: f64,
        k: f64,
    };
    let mut ret = 0.0_f64;
    for i in 1..(n+1.0).round() as i64 {
        if i >= k as i64 {
            ret += 1.0_f64/n;
        } else {
            let ps = k / i as f64;
            let sholder = ps.log2().ceil() as i64;
            ret += 1.0_f64 / (sholder as f64).exp2()/n;
            // println!("{}: {} {}, {}", i, ps, sholder, ret);
        }
    }

    println!("{}", ret);

}



Measured memory_bytes: 4352
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
#define pb push_back
#define srt(a) sort(a.begin(),a.end())
#define rsrt(a) sort(a.rbegin(),a.rend())
#define lb(a,b) lower_bound(a.begin(),a.end(),b)
#define ub(a,b) upper_bound(a.begin(),a.end(),b)
#define MOD ((int)(1e9+7  ))
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long
#define float long double
#define sqrt sqrtl
#define cbrt cbrtl
#define endl '\n'
typedef vector<int> vi;
typedef vector<float> vf;
typedef pair<float,int> fi;
typedef pair<int,int> ii;
typedef vector<ii> vii;
typedef vector<fi> vfi;
typedef vector<vi> vvi;
typedef vector<vf> vvf;
typedef vector<vii> vvii;
typedef vector<bool> vb;
typedef vector<string> vs;
typedef priority_queue<int> pqi;
typedef priority_queue<ii> pqii;
typedef priority_queue<fi> pqfi;
typedef priority_queue <int, vector<int>, greater<int> > rpqi; 
typedef priority_queue <ii, vector<ii>, greater<ii> > rpqii; 
typedef priority_queue <fi, vector<fi>, greater<fi> > rpqfi;




	
int32_t main()
{
	IOS
	int n,k;cin>>n>>k;
	vector<int>v(n+1),f1(n+1),f2(n+1);
	for(int i=1;i<=n;i++)
	cin>>v[i];
	
	for(int i=1;i<=n;i++)
	{
		for(int j=i;j<=n;j++)
		{
			if(v[j] < v[i])f1[i]++;
		}
		for(int j=1;j<=n;j++)
		{
			if(v[j] < v[i])f2[i]++;
		}
	}
	
	int ans=0;
	for(int i=1;i<=n;i++)
	{
		ans +=  (k * f1[i])%MOD + (f2[i] *( ( k * ( k-1 ) /2 ) %MOD ))%MOD;
		ans%=MOD;
	}
	cout<<ans<<endl;
	
				
		
		
		
}




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


vector<int> v,v2;
    int a,b,c,d,e=0;
    cin>>a;
    c=a;
    while(a--)
    {
        cin>>b;
        v.push_back(b);
    }
    for(int i=0;i<c-2;i++)
    {
        if((v[i]>v[i+1] && v[i+1]>v[i+2]) ||(v[i]<v[i+1] && v[i+1]<v[i+2]))
        {
            e++;
        }
    }
    cout<<e<<endl;


return 0;


}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define fi first
#define se second
double power(double x, ll y)  
{  
    double res = 100;  
    while (y > 0)  
    {  
        if (y & 1)  
            res = ceil(res*x);  
        y = y>>1; 
        x = (x*x);  
    }  
    return res;  
}  
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    ll x;
    cin>>x;
    ll ans=100,u=0;
    while(1){
        ll cu=ans/100;
        ll mxa=1e18;
        
        //ans+=cu;
        u++;
        if(mxa-ans<cu) break;
        ans+=cu;
        if(ans>=x) break;
    }
    //cout<<x<<" ";
    //cout<<ans-x<<" ";
    //if(ans>=x) cout<<"ues";
    cout<<u;
    return 0;
}

Measured memory_bytes: 3652
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast,no-stack-protector")
#include<bits/stdc++.h>
using namespace std;
#define INF 0x3f3f3f3f
#define LL long long int
#define vi vector<int>
#define vl vector<LL>
#define pb push_back
#define all(V) V.begin(),V.end()
#define sci(x) scanf("%d",&x)
#define scl(x) scanf("%I64d",&x)
#define pii pair<int,int>
#define cmax(a,b) ((a) = (a) > (b) ? (a) : (b))
#define cmin(a,b) ((a) = (a) < (b) ? (a) : (b))
#define debug(x)  cerr << #x << " = " << x << endl
function<void(void)> ____ = [](){ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);};

void solve(){
    vi A(3);
    for(int &x : A) sci(x);
    sort(all(A));
    if(A[0]!=5 or A[1]!=5 or A[2]!=7) cout << "NO" << endl;
    else cout << "YES" << endl;
}
int main(){
    #ifndef ONLINE_JUDGE
    freopen("Local.in","r",stdin);
    freopen("ans.out","w",stdout);
    #endif
    solve();
    return 0;
}

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

int main() {
  int N;
  cin >> N;
  int number = 100;

  for(int i=0;i<N;i++){
    int A;
    cin >> A;
    int Anumber =0;
    while(A%2==0){
      Anumber++;
      A=A/2;
    }
    if(Anumber<=number){
      number = Anumber;
    }      
  }
  cout << number << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long LL;
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define RI(X) scanf("%d", &(X))
#define RII(X, Y) scanf("%d%d", &(X), &(Y))
#define RIII(X, Y, Z) scanf("%d%d%d", &(X), &(Y), &(Z))
#define DRI(X) int (X); scanf("%d", &X)
#define DRII(X, Y) int X, Y; scanf("%d%d", &X, &Y)
#define DRIII(X, Y, Z) int X, Y, Z; scanf("%d%d%d", &X, &Y, &Z)
#define RS(X) scanf("%s", (X))
#define CASET int ___T, case_n = 1; scanf("%d ", &___T); while (___T-- > 0)
#define MP make_pair
#define PB push_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define PII pair<int,int>
#define VI vector<int>
#define VL vector<long long>
#define VPII vector<pair<int,int> >
#define PLL pair<long long,long long>
#define VPLL vector<pair<long long,long long> >
#define F first
#define S second

using namespace std;

VI difs(0);
VI same(0);

VI gendiff(int n){
	if (n==1) {VI v(2,0); v[1]=1<<difs[0]; return v;}
	VI base=gendiff(n-2);
	int sb=base.size();
	int st=0;
	VI res(0);
	int j=0;
	int nn=1<<difs[n-1];
	int nn2=1<<difs[n-2];
	REP(i,sb){res.PB(base[i]);}
	REP(i,sb){res.PB(base[sb-1-i]+nn);}
	VI t={nn+nn2,nn2};
	int last=0;
	while (j<sb){
		res.PB(base[j]+t[st]);
		if ((st+1)%2==last){j++;last=st;}
		else {st++; st%=2; }
	}
	return res;
}

VI gensame(int n){
	if (n==0) {VI v(1,0);  return v;}
	if (n==1) {VI v(2,0); v[1]=(1<<same[0]); return v;}
	VI base=gensame(n-1);
	int sb=base.size();
	int st=0;
	VI res(0);
	int j=0;
	int nn=1<<same[n-1];
	REP(i,sb){res.PB(base[i]);}
	REP(i,sb){res.PB(base[sb-1-i]+nn);}
	return res;
}


int main(){
	DRIII(n,a,b);
	int na=a;
	int nb=b;
	int kk=0;
	while (kk<n){
	    if (na%2!=nb%2) {difs.PB(kk);}
	    else {same.PB(kk);}
	    na>>=1;
	    nb>>=1;
	    kk++;
	}
	/*
	for (auto i:difs) {cout<<i<<" ";} cout<<endl;
	for (auto i:same) {cout<<i<<" ";} cout<<endl;
	for (auto i:gensame(same.size())) {cout<<i<<" ";} cout<<endl;
	for (auto i:gendiff(difs.size())) {cout<<i<<" ";} cout<<endl;*/
	if (difs.size()%2){
		printf("YES\n");
    	VI ss=gensame(same.size());
    	VI sd=gendiff(difs.size());
    	VI res;
    	REP(i,sd.size()){
    	    if (i%2) {
				for (int j=ss.size()-1;j>=0;j--){
					res.PB((ss[j]+sd[i])^a);
				}
			}
			else{
				REP(j,ss.size()){
					res.PB((ss[j]+sd[i])^a);
				}
			}
    	}
		REP(i,res.size()){
			printf("%d%c",res[i],i==res.size()-1?'\n':' ');
		}
    }
    else { printf("NO\n");}
	
}


Measured memory_bytes: 1692
a,b,c,d=map(int,input().split())
#最大公約数
def gcd(x,y):
  r=x%y
  return gcd(y,r) if r else y
#最小公倍数
def lcm(x, y):
    return (x * y) // gcd(x, y)

lcmnum = lcm(c,d)
cs=0
ds=0
cds=0

acs = a // c
ads = a // d
acds =  a // lcmnum
aa = a-(acs+ads-acds)

bcs = b // c

bds = b // d
bcds =  b // lcmnum
bb = b-(bcs+bds-bcds)
uo = 1

if a % c==0 or a % d ==0:
	uo-=1

print(bb-aa+uo)




Measured memory_bytes: 3064
package main

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

const (
	initialBufSize = 100000
	maxBufSize     = 1000000
)

var sc *bufio.Scanner

func initScanner(r io.Reader) *bufio.Scanner {
	buf := make([]byte, initialBufSize)

	sc := bufio.NewScanner(r)
	sc.Buffer(buf, maxBufSize)
	sc.Split(bufio.ScanWords) // bufio.ScanLines
	return sc
}

func main() {
	sc = initScanner(os.Stdin)
	fmt.Println(resolve(parseProblem()))
}

func parseProblem() (int, []int) {
	n := scanInt(sc)
	as := nextIntSlice(sc, n)
	return n, as
}

func nextInt(sc *bufio.Scanner) int {
	sc.Scan()
	a, _ := strconv.Atoi(sc.Text())
	return int(a)
}

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

func nextIntSlice(sc *bufio.Scanner, n int) (a []int) {

	a = make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = nextInt(sc)
	}
	return a
}

const (
	increasing = 0 + iota
	decreasing
)

func resolve(n int, as []int) int {
	budget := 1000
	stocks := 0
	as = append(as, 0) // make it easy
	for i := 0; i+1 < len(as); i++ {
		if as[i] <= as[i+1] {
			stocks += budget / as[i]
			budget = budget % as[i]
		} else {
			budget += stocks * as[i]
			stocks = 0
		}
	}
	return budget
}

// snip-scan-funcs
func scanInt(sc *bufio.Scanner) int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return int(i)
}
func scanString(sc *bufio.Scanner) string {
	sc.Scan()
	return sc.Text()
}


Measured memory_bytes: 1792
from itertools import *
n,*s=open(0).read().split()
u=[[min(accumulate(t,lambda a,b: a+(1 if b=="(" else -1),initial=0)),2*t.count("(")-len(t)] for t in s]
m=0
for c,d in chain(sorted([x for x in u if x[1]>=0])[::-1],sorted([x for x in u if x[1]<0],key=lambda z:z[0]-z[1])):
    if m+c<0:print("No");break
    m+=d
else:
    print("No" if m else "Yes")

Measured memory_bytes: 119608
str = [input() for i in range(2)]
nums = list(map(int, str[1].split()))
maxCount = 0
index = -1
count = 0

for i in range(len(nums)-1):
    if nums[i] >= nums[i+1]:
        count = count + 1
        if count >= maxCount:
            maxCount = count
    else:
        count = 0
        
print(maxCount)

Measured memory_bytes: 15192
#include <bits/stdc++.h>
#define ll long long

using namespace std;

int n, k;
vector<int> v;
int dp[100005];


void solve()
{
	for (int i = 1; i <= k; ++i)
	{
		if(dp[i] >= 0)
			continue;

		int res;
		for (int j = 0; j < n; ++j)
		{
			int tam = (i - v[j]);
			if(tam < 0)
				continue;
			res = dp[tam];
			if(res == 1)
			{
				dp[i] = 2;
			}
			else if(res == 2)
			{
				dp[i] = 1;
				break;
			}
		}

	}

}


int main()
{

	cin >> n >> k;


 	memset(dp, -1, sizeof(dp));
 
 	int num1, menor = 1000002;
 	for (int i = 0; i < n; ++i)
 	{
 		cin >> num1;
 		v.push_back(num1);
 		dp[num1] = 1;
 		menor = min(menor, num1);
 	}

 	for (int i = 0; i < menor; ++i)
 	{
 		dp[i] = 2;
 	}

 	solve();

 	if(dp[k] == 1 || dp[k] == 3)
 		cout << "First\n";
 	else
 		cout << "Second\n";


 






















    return 0;
}

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

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

    int n,m;
    cin >> n >> m;

    if (m&1) cout << "No";
    else {
        if (m > n*4 || m < n*2) cout << "No";
        else cout << "Yes";
    }
}

Measured memory_bytes: 3628
import sys
from itertools import accumulate
mod = pow(10, 9) + 7
N, = [int(i) for i in input().split(' ')]
As = [int(i) for i in input().split(' ')]
sys.setrecursionlimit(pow(10, 8))

def mul(a, b):
    return ((a % mod) * (b % mod)) % mod

def power(x, y):
    if   y == 0     : return 1
    elif y == 1     : return x % mod
    elif y % 2 == 0 : return power(x, y//2)**2 % mod
    else            : return power(x, (y-1)//2)**2 * x % mod

NNN = 10**5
g1 = [1, 1]
g2 = [1, 1]
inverse = [0, 1]

for i in range( 2, NNN + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )

def fractional(N):
    if N == 0:
        return 1
    else:
        return mul(N, fractional(N-1))

T = g1[N]
fracs = list(accumulate([0] + [mul(T, inverse[(i+1)]) for i in range(N)]))


result = 0
for i in range(N):
    i = i+1
    x = mul(As[i-1], fracs[N-i+1] + (fracs[i] - fracs[1]))
    result = (result + x) % mod 
print(result)


Measured memory_bytes: 76244
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<queue>
#include<string>
#include<cstring>
#include<algorithm>
#include<set>
#include<map>
#include<iomanip>

#define REP(i,n) for(int i=0;i<(n);i++)
#define EPS (1e-7)
#define INF (2e9)
// cout << setprecision(10)

using namespace std;
typedef long long int ll;

int N, M;
int H[100000];
int A, B;
int R[100000];
int main(void){
    cin >> N >> M;
    REP(i,N) R[i] = 1;
    REP(i,N) cin >> H[i];
    REP(i,M){
        cin >> A >> B;
        A--;
        B--;
        if(H[A] == H[B]){
            R[A] = 0;
            R[B] = 0;
        }
        else if(H[A] > H[B]){
            R[B] = 0;
        }else R[A] = 0;
    }

    int ans = 0;
    REP(i,N) {
        if(R[i] == 1)ans++;
    }
    cout << ans << endl;

    return 0;
}



Measured memory_bytes: 4412
#include<bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
#define ll long long
#define int long long
int n;
int w;
int dp[200][200000];
vector<int> v[200];
int f(int x,int y)
{
	if(x==n)
		return 0;
	if(dp[x][y]!=-1)
		return dp[x][y];
	else
	{
		if(y-v[x][0]<0)
			{
				return dp[x][y]=f(x+1,y);

			}
		return dp[x][y]=max(v[x][1]+f(x+1,y-v[x][0]),f(x+1,y));
	}
}
int32_t  main()
{
	memset(dp,-1,sizeof(dp));
	cin>>n>>w;
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<2;j++)
		{
			int x;
			cin>>x;
			v[i].push_back(x);
		}
	}
	cout<<f(0,w)<<endl;
	return 0;
}

Measured memory_bytes: 312704
#include <stdio.h>
int main () {
  int k,a,b;
  scanf("%d%d%d",&k,&a,&b);
  for(int i=k;i<=b;i+=k) {
      if (i>=a && i<=b) {
          printf("OK");
          return 0;
      }
  }
  printf("NG");
}


Measured memory_bytes: 1728
#include <bits/stdc++.h>
template<class T> inline bool chmin(T&a, T b){if(a > b){a = b; return true;}else{return false;}}
template<class T> inline bool chmax(T&a, T b){if(a < b){a = b; return true;}else{return false;}}
#define ll long long
#define double long double
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define mod (ll)(1e9+7)
#define inf (ll)(3e18+7)
#define pi (double) acos(-1.0)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
using namespace std;

int main() {
    int n;
    cin >> n;
    vector<int> a(n), pos(n), ans(n);
    rep(i, n){
        cin >> a[i];
        a[i]--;
        pos[a[i]] = i;
    }
    rep(i, n){
        if(a[i] == 0)ans[0] = 1;
        else{
            if(pos[a[i]-1] < i)ans[a[i]] = ans[a[i]-1]+1;
            else ans[a[i]] = 1;
        }
    }
    cout << n - *max_element(all(ans)) << endl;
}


Measured memory_bytes: 2560
#include<iostream>

using namespace std;

int main(){
	int n;
	cin>>n;
	int a[n+1], i, count=0, tmp;
	for(i=1;i<=n;i++){
		cin>>a[i];
		if(a[i]==i) a[i]=0;
	}
	for(i=1;i<=n;i++){
		if(a[i]!=0) {
			tmp=a[i];
			if(a[tmp]==i) {
				count++;
				a[tmp]=0;	
			}
		}
	}
	cout<<count<<endl;
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
const int N = 100010;
int a[N];
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0), cout.tie(0);
	int n, K;
	cin >> n >> K;
	for(int i = 1; i <= n; i++) cin >> a[i];
	if(K == 2){
		cout << n - 1 << "\n";
	}
	else{
		if(n % (K - 1) <= 1)
			cout << n / (K - 1) << "\n";
		else
			cout << n / (K - 1) + 1 << "\n";
	}
}

Measured memory_bytes: 640
#pragma GCC optimize("O2")
#include <bits/stdc++.h>
using namespace std;
#define FASTIO ios_base::sync_with_stdio(false), cin.tie(0)
//#define MULTI_TEST
//#define GOOGLE
#ifdef LOCAL
#include "debugger.h"
#else
#define db(...)
#endif
#define ll long long
#define v32 vector<int>
#define v64 vector<ll>
#define s32 set<int>
#define s64 set<ll>
#define p32 pair<int, int>
#define p64 pair<ll, ll>
#define sz(v) (ll)(v).size()
#define fi first
#define se second
#define ln '\n'
const ll MOD = 1e9 + 7;
inline ll add(ll a, ll b, ll m) { return (((a % m + b % m) % m + m) % m); }
inline ll mul(ll a, ll b, ll m) { return (((a % m * b % m) % m + m) % m); }

vector<int> pf;
void sieve(int n)
{
	pf.assign(n + 1, 0);
	iota(pf.begin(), pf.end(), 0);
	for (int i = 2; i * i <= n; i++)
	{
		if (pf[i] == i)
		{
			for (int j = 2 * i; j <= n; j += i)
				if (pf[j] == j)
					pf[j] = i;
		}
	}
	return;
}

void solve(int tc)
{

	int n;
	cin >> n;
	sieve(n);
	ll ans = 0;
	for (int i = 1; i <= n; i++)
	{
		int tmp = i;
		int cnt = 1;
		while (tmp > 1)
		{
			int p = pf[tmp];
			int ctr = 0;
			while (tmp % p == 0)
			{
				tmp /= p;
				ctr++;
			}
			cnt *= (ctr + 1);
		}
		db(i, cnt);
		ans += (1ll * i * cnt);
	}
	cout << ans << ln;
	return;
}

int main()
{
#ifndef LOCAL
	FASTIO;
#endif
	int t = 1;
#ifdef LOCAL
	clock_t start, stop;
	start = clock();
#endif
#ifdef MULTI_TEST
	cin >> t;
#endif
	for (int tc = 1; tc < t + 1; tc++)
	{
#ifdef GOOGLE
		cout << "Case #" << tc << ": ";
#endif
		solve(tc);
	}
#ifdef LOCAL
	stop = clock();
	cerr << "Time :" << fixed << setprecision(5) << double(stop - start) / double(CLOCKS_PER_SEC) << "s" << ln;
#endif
	return 0;
}


Measured memory_bytes: 42272
//
//  atcoder.cpp
//
//
///
#include <bits/stdc++.h>
#include <boost/optional.hpp>
#include <boost/range/irange.hpp>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/bimap/bimap.hpp>
#include <boost/bimap/multiset_of.hpp>
#include <boost/multi_array.hpp>
#include <boost/math/common_factor.hpp>
#include <boost/algorithm/string.hpp>

#define REP(i, N) for(int i=0; i<(N); i++)
#define REC(f, ...) (void)0; const auto f = [&](const auto f, __VA_ARGS__)
using namespace std;
using namespace boost::math;

using ll = long long;
namespace bst = boost;
template<typename T> class in {
    T value;
public:
    in() { cin >> value; }
    operator const T&() const { return value; }
    operator T&() { return value; }
    in& operator=(T source) { value = source; return *this; }
};
template<> class in<string> : public string {
public:
    in() { cin >> *this; }
};
template<class T> class inseq : public T {
public:
    template<typename... Arg> inseq(Arg... arg) : T(forward<Arg>(arg)...) { for (auto&& i : *this) cin >> i; }
};
template<class T> using invec = inseq<vector<T>>;

auto solve() {
  in<string> N;
  ll dp0 = N[0] - '0', dp1 = 11 - dp0;
  
  for (auto i : bst::irange(1, (int)N.length())) {
    ll new0 = min(dp0, dp1) + N[i] - '0',
       new1 = min(dp0 + 11 - (N[i] - '0'), dp1 + 9 - (N[i] - '0'));
    tie(dp0, dp1) = make_tuple(new0, new1);
  }

  return min(dp0, dp1);
}

template<typename T> void plot(const T& func) { cout << func() << endl; }
template<> void plot<void()>(void(&func)()) { func(); }
template<> void plot<double()>(double(&func)()) { cout << setprecision(9) << func() << endl; }

int main() {
  plot(solve);

  return 0;
}



Measured memory_bytes: 1412
s=str(input())
S=[]
S_unique=[]
for i in range(len(s)):
    S.append(s[i])
    if(s[i] not in S_unique):
        S_unique.append(s[i])
num_A=0
num_B=0
if(len(S_unique)!=2):
    print("No")
else:
    for i in range(len(S)):
        if(S[i]==S_unique[0]):
            num_A+=1
        else:
            num_B+=1
    if(num_A==num_B):
        print("Yes")
    else:
        print("No")

Measured memory_bytes: 3064
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;

public class Main {

	public static void main(String[] args) {

		FastScanner sc = new FastScanner();
		double W = sc.nextInt();
		double H = sc.nextInt();
		double x = sc.nextInt();
		double y = sc.nextInt();

		System.out.print(W * H / 2 + " ");

		if (x == W / 2 && y == H / 2)
			System.out.print(1);
		else
			System.out.print(0);

	}
}

class FastScanner {
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;

	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		} else {
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen <= 0) {
				return false;
			}
		}
		return true;
	}

	private int readByte() {
		if (hasNextByte())
			return buffer[ptr++];
		else
			return -1;
	}

	private static boolean isPrintableChar(int c) {
		return 33 <= c && c <= 126;
	}

	public boolean hasNext() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr]))
			ptr++;
		return hasNextByte();
	}

	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = readByte();
		while (isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	public long nextLong() {
		if (!hasNext())
			throw new NoSuchElementException();
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}

	public int nextInt() {
		long nl = nextLong();
		if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
			throw new NumberFormatException();
		return (int) nl;
	}

	public double nextDouble() {
		return Double.parseDouble(next());
	}
}


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

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine(int.Parse(Console.ReadLine())<1200?"ABC":"ARC");
        }
    }
}


Measured memory_bytes: 11092
#include <bits/stdc++.h>
#define ll long long
#define dbg(x) cout<<#x<<"="<<x
#define nl cout<<"\n"
#define frn(i,n) for(int i = 0;i < n;i++)
#define fr(i,a,b) for(int i = a;i < b;i++)
#define pb push_back
#define trav(x,c) for(auto &x:c)
using namespace std;

int toint(string s) {
  int ans = 0;
  for(char x: s) ans = ans*10 + (x - '0');
  return ans;
}

int sum(int x) {
  int s = 0;
  while(x) {
    s += x%10;
    x /= 10;
  }
  return s;
} 

int main() {
  string s;
  cin>>s;
  int ans = 0;
  for(int i = 0,j = s.size()-1;i < j;i++,j--) {
    ans += s[i]!=s[j];
  }
  cout<<ans;
}

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

int main() {
  int K, X, a, b;
  cin >> K >> X;
  a = X - K + 1;
  b = X + K - 1;
  for (int i = a; i <= b; i++) {
    cout << i << " ";
  }
  cout << endl;
}

Measured memory_bytes: 256
firstLine = input()

# 文字列の長さ
N = int(firstLine.split()[0])
# 置き換えインデックス
K = int(firstLine.split()[1]) - 1

# 置き換え文字列
S = list(input())

if S[K] == 'A' or S[K] == 'B' or S[K] == 'C':
    S[K] = S[K].lower()
else:
    S[K] = S[K].upper()

print(''.join(S))

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

struct Data {
    Data() {
        key = -1;
        str = "";
    }

    Data(std::string str) : str(str) {
        key = 0;
        int offset = 1;
        for (auto && c : str) {
            if (c == 'A') {
                key += offset * 1;
            } else if (c == 'C') {
                key += offset * 2;
            } else if (c == 'G') {
                key += offset * 3;
            } else if (c == 'T') {
                key += offset * 4;
            }
            offset *= 5;
        }
    }
    
    int key;
    std::string str;
};

class Dictionary {
  public:
    Dictionary() {
        datas = std::vector<Data>(1000000, Data());
    }
    
    void insert(std::string str) {
        Data data(str);
        int pos = hash(data, 0);
        datas[pos] = data;
    }

    void search(std::string str) {
        Data data(str);
        int pos = hash(data, 0);
        if (datas[pos].str == data.str) {
            std::cout << "yes" << std::endl;
        } else {
            std::cout << "no" << std::endl;
        }
    }

    int hash(const Data &data, const int n_collision) {
        int pos = (data.key % N + n_collision * (N - 1)) % N;
        if (datas[pos].str == data.str || datas[pos].str == "") {
            return pos;
        }
        return hash(data, n_collision + 1);
    }

  private:
    const int N = 1000000;
    std::vector<Data> datas;
};

int main() {
    int n;
    std::cin >> n;

    std::string command, str;
    Dictionary dict = Dictionary();
    for (int i = 0; i < n; i++) {
        std::cin >> command >> str;
        if (command == "insert") {
            dict.insert(str);
        } else if (command == "find") {
            dict.search(str);
        }
    }
}



Measured memory_bytes: 34736
use List::Util qw(max min sum);
 
my ($n) = split(/\s+/, <>);
chomp(my @a = <STDIN>);
 
my $index=0;
my $max = $a[0];
for (0..$n-1) {
    if ($max<$a[$_]) {
	$max=$a[$_]; $index=$_;
    }
}
splice @a, $index, 1;
 
for (0..$n-1) {
    if ($_ == $index) {
	print max(@a), "\n";
    } else {
	print $max, "\n";
    }
}

Measured memory_bytes: 45824
import java.math.*

fun main(args: Array<String>) {
    val (n, m, x) = readInputLine().split(" ").map { it.toInt() }
    
    var backward = 0
    var forward = 0
    
    val inputs = readInputLine().split(" ").map { it.toInt() }
    
    for (i in 0 until m) {
        if (inputs[i] < x) {
            backward++
        } else {
            forward++
        }
    }
    
    println(Math.min(forward, backward))
}
 
fun readInputLine(): String {
    return readLine()!!
}

Measured memory_bytes: 37608
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <functional>
using namespace std;

typedef long long ll;

int cnt[100005];
bool used[100005];

int main() {
	int q; cin >> q;
	set <int> primes;
	for (int i = 2; i < 100005; ++i) {
		if (used[i]) continue;
		primes.insert(i);
		int w = i;
		while (w < 100005) {
			used[w] = true;
			w += i;
		}
	}
	for (int i = 2; i < 100005; ++i) {
		cnt[i] = cnt[i - 1] + ((i % 2 == 1 && primes.count(i) == 1 && primes.count((i + 1)/2) == 1) ? 1 : 0);
	}
	for (int i = 0; i < q; ++i) {
		int l, r; cin >> l >> r;
		cout << cnt[r] - cnt[l - 1] << endl;
	}
	return 0;
}

Measured memory_bytes: 1536
if __name__ == '__main__':
    tokens = map(int, input().split(' '))
    five = 0
    seven = 0
    for t in tokens:
        if t == 5:
            five += 1
        if t == 7:
            seven += 1

    print("YES" if (five == 2) and (seven == 1) else "NO")

Measured memory_bytes: 3060