akhauriyash/Code-Regression huggingface dataset:
import java.util.*;

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

        List<Integer> list = new ArrayList<>();

        for(int i=a; i<=b; i++){
            int x = i - a + 1;
            if(x <= k || (b-i+1) <= k){
                list.add(i);
            }
        }


        printListOneLine(list);
    }

    public static void printListOneLine(List list){
        for(int i=0; i<list.size(); i++){
            System.out.println(list.get(i));
        }
    }

    public static void printList(List list){
        for(int i=0; i<list.size(); i++){
            if(i == list.size()){
                System.out.println(list.get(i));
            } else {
                System.out.print(String.format("%d ", list.get(i)));
            }
        }
    }

    public static void printArray(int[] array){
        for(int i=0; i<array.length; i++){
            if(i == array.length){
                System.out.println(array[i]);
            } else {
                System.out.print(String.format("%d ", array[i]));
            }
        }
    }

    public static int gcd(int a, int b){
        if (b == 0) return a;
        return gcd(b, a % b);
    }

    public static int lcm(int a, int b){
        return a * b / gcd(a, b);
    }
}


Measured memory_bytes: 23636
#include<stdio.h>
int main()
{
	int a[33]={0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51};
	int k;
	scanf("%d",&k);
	printf("%d",a[k]);
	return 0;
} 

Measured memory_bytes: 128
#include <stdio.h>
#include <string.h>
#define REP(i, n) for(i = 0; i < n; ++i)
#define FOR(i, a, b) for(i = a; i < b; ++i)

unsigned int pow2(unsigned int k){
    if(k == 0){
        return 1;
    }else{
        return 2 * pow2(k - 1);
    }
}


unsigned long long calc(char S[11], unsigned int len, int op){
    int i;
    unsigned long long ret = 0;
    unsigned long long num = 0;

    REP(i, len){
        num *= 10;
        num += S[i] - '0';

        if(op & 1){
            ret += num;
            num = 0;
        }
        op /= 2;
    }
    //printf("ret:%llu\n", ret);
    return ret;
}

int main(){
    char S[11];
    int num = 1;
    int i;
    scanf("%s", S);
    unsigned int len = strlen(S);
    unsigned long long ANS = 0;

    if(len == 1){
        printf("%c\n", S[0]);
    }else{
        FOR(i, pow2(len - 1), pow2(len)){
            ANS += calc(S, len, i);
        }
        printf("%llu\n", ANS);
    }
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <cstring>
#include <math.h>
#include <bitset>
#include <queue>
#include <set>
#include <iomanip>
#include <math.h>
#include <assert.h>
// #include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr long long int INFLL = 1001001001001001LL;
constexpr long long int infll = 1001001001001001LL;
constexpr int INF = 1000000007;
constexpr int inf = 1000000007;
const int mod = 1000000007;

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

ll gcd(ll a, ll b)
{
    if (a % b == 0)
    {
        return (b);
    }
    else
    {
        return (gcd(b, a % b));
    }
}

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

inline double nCr(const int n, int r)
{
    if (n == 0)
    {
        return 0;
    }
    if (r == 0)
    {
        return 1;
    }
    if (r == 1)
    {
        return n;
    }
    if (n == r)
    {
        return 1;
    }

    if (r > n / 2)
    {
        r = n / 2;
    }

    double result = 1;
    for (double i = 1; i <= r; i++)
    {
        result *= (n - i + 1) / i;
    }

    return (result);
}

template <typename T>
T seinomi(T a)
{
    if (a > 0)
    {
        return a;
    }
    else
    {
        return 0;
    }
}

template <typename T>
map<T, T> soinsuubunkai(T n) //連想配列[素因数f.first][個数f.second]
{
    map<T, T> ret;
    for (T i = 2; i * i <= n; i++)
    {
        while (n % i == 0)
        {
            ret[i]++;
            n /= i;
        }
    }
    if (n != 1)
        ret[n] = 1;
    return ret;
}

template <typename T>
T ketasuu(T num)
{
    return std::to_string(num).length();
}

int kaizyou(int k)
{
    int sum = 1;
    for (int i = 1; i <= k; ++i)
    {
        sum *= i;
    }
    return sum;
}

template <class ForwardIt, class T>
void iota(ForwardIt first, ForwardIt last, T value)
{
    while (first != last)
    {
        *first++ = value;
        ++value;
    }
}

//nの階乗を計算
int factorial(int n)
{
    int answer = 1;
    while (n > 1)
    {
        answer *= n;
        n--;
    }
    return answer;
}
int comb(int n, int r)
{
    return factorial(n) / (factorial(r) * factorial(n - r));
}

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

//小数点以下10桁テンプレート（main関数内の最初に貼付け）
//std::cout << std::fixed << std::setprecision(10);

//----------------------------------------------------------------


int main(){
string s;
cin>>s;
string t;
cin>>t;
ll cnt=0;
for(int i=0;i<3;i++){
    if(s.at(i)==t.at(i)){
        cnt++;
    }
}
cout<<cnt<<endl;
}









Measured memory_bytes: 256
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

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

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

use std::collections::HashMap;

fn main() {
    input! {
        n: usize,
        b: [u32;n],
    }
    let mut m: HashMap<u32,u32> = HashMap::new();
    for i in b {
        *m.entry(i).or_insert(0) += 1;
    }
    let res: u32 = m.iter().filter(|&(k,v)| k != v)
        .map(|(k,v)| if v > k {v-k} else {*v}).sum();
    println!("{}", res);
}


Measured memory_bytes: 10492
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define vi vector<int>
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define pi 3.141592653589793238
#define rep(i,a,b) for (int i = a; i <= b; i++)
#define zip(i,a,b) for(int i=a;i<b;i++)
#define rzip(i,a,b) for(int i=a;i>=b;i--)
#define ll unsigned int
#define test int t;cin>>t; while(t--)
#define en '\n'
typedef pair<int, int>     pii;
typedef pair<char, int>    pci;
typedef pair<char, char>   pcc;
typedef vector<pii>       vii;
typedef long double ld;
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(),v.rend()
#define sz(x) (int)x.size()
#define INF (1e18+5)
#define inf (1e9+5)
#define mod 1000000007


void __print(int x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}
// You should only debug a pair of simple data types. For example,
// the debug won't work if one of pair's elements is collection type
// (std::vector, std::map, std::set...).
template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i : x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif


// bool check_prime(int n)  return whether a number is prime or not O(sqrt(N));
// int BE(int x,int n,int m)  return x^n%m; O(logN);
// void sieve()  from number 1-1000001 saare prime store kar lega  in bool is_prime[1000001] array
// vector<int> z_array(string s)  return vector which is Z-array of string s;
// vector<int> lps(string s)      return vector which is lps array of string s;
// int power(int x,int n) return x^n; O(logN);
// using_ordered_set (template for using ordered set , replace first 2 lines of this page with this code..);
const int gf = 1e6 + 9;
int dp[gf / 100];
int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(0);
#ifndef ONLINE_JUDGE
	if (fopen("input.txt", "r"))
	{
		freopen ("input.txt" , "r" , stdin);
		freopen ("output.txt" , "w" , stdout);
	}
#endif
	//_______________________________-code starts-_______________________________________________

	int s;
	cin >> s;
	dp[1] = 0;
	dp[2] = 0;
	dp[3] = 1;
	rep(i, 4, s)
	{
		// dp[i] numbers of seuqences having sm equals i...
		dp[i] = 1;
		rep(j, 3, i - 1)
		{
			dp[i] = (dp[i] + dp[i - j]) % mod;
		}
	}
	cout << dp[s] << en;



	return 0;
}




Measured memory_bytes: 3564
#coding: utf-8
import math
import heapq
import bisect
import numpy as np
#from scipy.misc import comb

N,A,B,C = map(int, input().split())

L = []
for i in range(N):
    l = int(input())
    L.append(l)

ans = 10**9

for i in range(1<<(2*N)):
    a = b = c = 0
    tmp = 0
    for j in range(N):
        flg = 0
        if i&(1<<(2*j)):
            flg += 1
        if i&(1<<(2*j+1)):
            flg += 2

        if flg == 1:
            if a:
                tmp += 10
            a += L[j]
        elif flg == 2:
            if b:
                tmp += 10
            b += L[j]
        elif flg == 3:
            if c:
                tmp += 10
            c += L[j]

    if a*b*c==0:
        continue

    tmp += abs(A-a)+abs(B-b)+abs(C-c)
    ans = min(ans,tmp)

print(ans)


Measured memory_bytes: 12932
#include <iostream>
#include <cstdio>

using namespace std;

main(){
    int a[400000] = {0};

    for(int i = 3 ; i <= 300000 ; i+=2){
        if(a[i] == 0){
            for(int j = i+i ; j <= 400000 ; j+=i){
                a[j] = 1;
            }
        }
    }

    int n;

    while(cin >> n){
        if(n == 0) break;

        int ans = 0;
        for(int i = n+1 ; i <= 2*n ; i++){
            if(i == 2) ans++;
            else if(i % 2 == 1 && a[i] == 0) ans++;
        }

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

Measured memory_bytes: 2728
#include <bits/stdc++.h>
#define um unordered_map
#define us unordered_set
#define f first
#define s second
#define pb push_back
#define MOD 1000000007
#define eps 1e-9
#define INF 1000000002

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<int, pii> piii;
typedef pair<pii,pii> piiii;

const int N = 255;

    ll k;

ll solve(int n, string s) {
    if(n<=0)
        return 0;
    int diff = 0;
        bool changed[n] = {false};
    for(int i = 1;i<n;i++) {
        if(s[i] == s[i-1]) {
            if(!changed[i-1]) {
                diff++, changed[i] = true;
            }
        }
    }
    return diff * k;;
}

int main() {
    string s;
    cin>>s>>k;
    int n = s.length();
    if(n == 1)
        return cout<<(k>>1), 0;
    int cntStart = 0;
    int cntEnd = 0;
    int st = 0, en = n-1;
    for(int i =0;i<n;i++) {
        if(s[i] == s[0]) {
            cntStart++;
            st++;
        } else {
            break;
        }
    }
    for(int i =n-1;i>=0;i--) {
        if(s[i] == s[n-1]) {
            cntEnd++;
            en--;
        } else {
            break;
        }
    }
    if(st>en) {
        return cout<<n*k/2, 0;
    }
    if(s[0] == s.back())
        cout<<solve(n, s) + ( ((cntEnd%2) && (cntStart%2))?k-1:0);
    else
        cout<<solve(n, s);
    return 0;
}



Measured memory_bytes: 256
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;
import java.util.stream.Collectors;

public class Main {
  public static void main(String[] args) {
    Scanner scan = new Scanner(System.in);
    scan.nextLine();
    final int A = scan.nextInt();
    final int B = scan.nextInt();
    scan.nextLine();
    String[] splited = scan.nextLine().split(" ");
    List<Integer> list = Arrays.stream(splited).map(Integer::parseInt).collect(Collectors.toList());
    long list1 = list.stream().filter(l -> 1 <= l && l <= A).count();
    long list2 = list.stream().filter(l -> A < l && l <= B).count();
    long list3 = list.stream().filter(l -> B < l && l <= 20).count();

    long result = Math.min(Math.min(list1, list2), list3);
    System.out.println(result);
  }
}


Measured memory_bytes: 27092
using Atcoder;
using System;
using System.Collections.Generic;
using System.ComponentModel.Design;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var S = Console.ReadLine();
            var sCount = S.Length;
            var count = S.Where(x => x == 'o').Count();
            
            if ((15 - sCount + count) >= 8)
            {
                Console.WriteLine("YES");
            }
            else
            {
                Console.WriteLine("NO");
            }
        }

    }

    //var N = int.Parse(Console.ReadLine());
    //var S = Console.ReadLine();
    //var K = Console.ReadLine().Split(' ');
    //var N = int.Parse((K[0]));
    //var M = int.Parse((K[1]));
}

Measured memory_bytes: 11220
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    char s[100005];
    cin>>n;
    int co=0,cnt=0;
    for(int i=0;i<n;i++){
        cin>>s[i];
        if(s[i]=='x'){
            co++;
            if(co==2) break;
        }
        if(s[i]=='o'){
            co=0;
        }
        cnt++;
    }
    cout<<cnt<<endl;
    return 0;
}



Measured memory_bytes: 3196
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;} return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;} return 0;}
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(vec) vec.begin(),vec.end()
typedef long long ll;
typedef pair<ll,ll> l_l;
typedef pair<int,int> i_i;
const ll MOD=1e9+7;
const int INF=1<<30;

int main(){
  int a,b;
  cin >> a >> b;
  if(a<=b){
    string s;
    rep(i,b){
      s+=to_string(a);
    }
    cout << s << endl;
  }
  else{
    string t;
    rep(i,a){
      t+=to_string(b);
    }
    cout << t << endl;
  }
  
}

Measured memory_bytes: 256
n, q, s, t = map(int, input().split())
a_lst = [int(input()) for _ in range(n + 1)]
diff = [a_lst[i + 1] - a_lst[i] for i in range(n)]
temp = sum([-d * s if d > 0 else -d * t for d in diff])
def score(d):
  if d > 0:
    return -s * d
  else:
    return -t * d
for _ in range(q):
  l, r, x = map(int, input().split())
  a = diff[l - 1]
  diff[l - 1] += x
  temp += score(diff[l - 1]) - score(a)
  if r < n:
    b = diff[r]
    diff[r] -= x
    temp += score(diff[r]) - score(b)
  print(temp)


Measured memory_bytes: 29428
#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <complex>
#include <tuple>

#define FAST ios_base::sync_with_stdio(false); cin.tie(0)
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define repri(i, a, b) for(int i=int(a); i>=int(b); i--)
#define reps(i,n) for(int i=1;i<=int(n);++i)
#define repr(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define reprs(i,x) for(int i=((int)(x));i>0;i--)
#define iceil(x,y) (x+y-1)/y
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define all(x) (x).begin(),(x).end()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )
#define LF "\n"

template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
typedef pair<int, PII> PP;
typedef vector<int> VI;
typedef vector<ll> VL;

string s;

void Main() {
	cin >> s;
	string ans = {};
	rep(i,s.size()) {
		if (s[i] == '0') ans+='0';
		if (s[i] == '1') ans+='1';
		if (s[i] == 'B') {
			if (ans.size() != 0) ans.pop_back();
		}
	}

	cout << ans << LF;

	return;
}

int main(){
	FAST;
	std::cout << std::fixed << std::setprecision(15);
	Main();
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define OO 1e9
using namespace std;
ll ways[3001];
ll ways2[3001][3001];
ll fact[3001];
ll inv[3001];

ll mem[10000001][2];
int n, m;
ll pow1(ll n, ll p, ll MOD){
    if(MOD != m && MOD != m-1)assert(0);
    if(n == 2 && p < 10000001 && mem[p][MOD == m ? 1 : 0] != -1)
        return mem[p][MOD == m ? 1 : 0];
    ll cur, res;
    cur = n;
    res = 1;
    ll z = p;
    while(p){
        if(p & 1){
            res *= cur;
            res %= MOD;
        }

        p /= 2;
        cur *= cur;
        cur %= MOD;
    }
    if(n == 2 && z < 10000001)
        mem[z][MOD == m ? 1 : 0] = res;
    return res;
}
ll C(int n, int k){
    return fact[n] * inv[k] % m * inv[n-k] % m;
}
//int p1[3001];
//int p2[3001];
int main(){
//    freopen("in.txt", "r", stdin);
//    freopen("out.txt", "w", stdout);
    cin >> n >> m;
    for(int i = 0;i <= n;i++){
        ways2[i][0] = 1;
    }
    memset(mem, -1, sizeof(mem));

    for(int i = 1;i <= n;i++){
        for(int j = 1;j <= i;j++){
            ways2[i][j] = ((j+1) * ways2[i-1][j] % m + ways2[i-1][j-1]) % m;
            ways2[i][j] %= m;
        }
    }


    for(int i = 0;i <= n;i++)
        for(int j = 0;j <= i;j++)
            (ways[i] += ways2[i][j] * pow1(2, (n-i) * j, m) % m * pow1(2, pow1(2, n-i, m-1), m) % m) %= m;
    fact[0] = inv[0] = 1;
    for(int i = 1;i < 3001;i++)
        fact[i] = fact[i-1] * i % m, inv[i] = pow1(fact[i], m - 2, m);

    ll res = 0;
    for(int i = 0;i <= n;i++){
        res += ((i&1) ? -1 : 1) * C(n, i) * ways[i] % m;
        res %= m;
    }
    if(res < 0)res += m;
    cout << res;
    return 0;
}



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

#define sz(x) int(x.size())
#define pii pair<int, int>
#define All(x) (x).begin(), (x).end()
#define mp make_pair
#define Task "abc"

typedef long long ll;
const int maxn = 2e5 + 10;
const ll mod = 1e9 + 7;

int main(){
  ios_base::sync_with_stdio(0); cin.tie(NULL);
//  freopen(Task".inp", "r", stdin); freopen(Task".out", "w", stdout);
  string s, t; cin >> s >> t;
  t.erase(sz(t) - 1, 1);
  if (t == s) return cout << "Yes", 0;
  cout << "No";
return 0;
}




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

#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
using namespace std;

int main()
{
    ll n;
    string abc;
    cin >> n >> abc;
    int ans = 0;
    rep(i, n-2) {
        if (abc.substr(i,3) == "ABC") ++ans;
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
    public static void main(String[] args){
    
    Scanner sc = new Scanner(System.in);
    int h = sc.nextInt();
    int w = sc.nextInt();
    String[]S = new String[h];
     
    for(int i=0; i<h; i++){
         S[i] = sc.next();
}

   for(int i=0; i<h; i++){
	   System.out.println(S[i]);
	   System.out.println(S[i]);
    }
}
}
 

Measured memory_bytes: 37596
N = STDIN.gets.chomp.to_i
P = STDIN.gets.split(' ').map{|s| s.to_i}

ans = 0
min = []
N.times do |i|
  if i == 0
    min[i] = P[0]
  else
    min[i] = [min[i-1], P[i]].min
  end

  if P[i] <= min[i]
    ans += 1
  end
end

puts ans



Measured memory_bytes: 20868
#include<iostream>

using namespace std;

int main()
{
  int a,b,c,d,e,f;
  cin>>a>>b>>c>>d>>e;
  if(a<=0) cout << (-1)*a*c+d+b*e << endl;
  else cout << (b-a)*e << endl;
  return 0;
}


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

N, M = map(int, input().split())
X = list(map(int, input().split()))
Y = list(map(int, input().split()))
mod = 10**9+7

A = 0
for i in range(N-1):
    A += (X[i+1] - X[i])*((i+1)*(N-1-i)) % mod
    A %= mod

B = 0
for j in range(M-1):
    B += (Y[j+1]-Y[j])*((j+1)*(M-1-j)) % mod
    B %= mod

print(A*B%mod)

Measured memory_bytes: 19308
/*
Owner: dxxrk
Problem: Wanna go back home
Date: 21/11/2019
*/
#include <bits/stdc++.h>

using namespace std;

const int N = 2e5 + 3;
const int M = 1e6 + 7;
const long long MOD = 1e9 + 7;
const long long INF = 1e18 + 9;
const int SM = 1e3 + 8;
const int logN = 20, BL = 400;
const double EPS = 3e-16;

int main(){
//	freopen("ex.in", "r", stdin);
//	freopen("ex.out", "w", stdout);
	ios_base::sync_with_stdio(false);
	cin.tie(0), cout.tie(0);
	string s; cin >> s;
	
	map<char, bool> m;
	for(int i = 0; i < int(s.size()); i++){
		m[s[i]] = true;
	}
	
	if(m['S'] == m['N'] && m['W'] == m['E']){
		cout << "Yes";
	}
	else {
		cout << "No";
	}
	return 0;
}


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

int n;

int main(){
  cin >> n;
  int m = 1e9, res = 0;
  rep(i, n){
    int p; cin >> p;
    if(p <= m){
      m = p;
      res++;
    }
  }
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 256
fun main(args: Array<String>) {
    val (n,k) = readLine()!!.split(" ").map(String::toInt)
    val s = readLine()!!.toCharArray()
    var cnt = 0
    for (i in 1 until n) {
        if (s[i] != s[i-1]) {
            cnt += 1
        }
    }
    if (2*k >= cnt) {
        println(n-1)
    } else {
        println(n-1-cnt+2*k)
    }
}

Measured memory_bytes: 41512
import java.util.Scanner;

class Main{





	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);			//文字の入力
		int N =sc.nextInt();
		int W = sc.nextInt();
		int[] w = new int[N+1];
		long[] v = new long[N+1];
		for(int  i = 1;i <= N;i++){
			w[i] = sc.nextInt();
			v[i] = sc.nextInt();
		}
		long[][] dp = new long[N+1][W+1];		//dp[i][j] i番目までで重さjの時の価値の最大値

		for(int i = 1;i <= N;i++){
			dp[i][w[i]] =(long)Math.max(dp[i-1][w[i]], v[i]);
			for(int j = 0;j <= W;j++){
				if(dp[i-1][j] > 0){
					if(j +w[i] <= W){
						dp[i][j+w[i]] =(long)Math.max(dp[i][j+w[i]], dp[i-1][j] + v[i]);
						dp[i][j] =(long)Math.max(dp[i][j], dp[i-1][j]) ;

					}else{
						dp[i][j] =(long)Math.max(dp[i][j], dp[i-1][j]) ;
					}
					
				}else{
					dp[i][j] =(long)Math.max(dp[i][j], dp[i-1][j]) ;
				}
					//	System.out.println("i "+i +" j "+ j+" "+dp[i][j]);
			}
		}
		long max = 0;
		for(int i = 0;i <= W;i++){
			max =(long)Math.max(max, dp[N][i]);
		}
		System.out.println(max);



	}
}







class Pair implements Comparable{
	int from;		//p
	int end;		//y
	int num;
	int bango;
	@Override
	public int compareTo(Object other) {
		Pair otherpair = (Pair)other;

		return end - otherpair.end;
	}
}



Measured memory_bytes: 127440
#include <iostream>
#include <cstring>
#include <cstdio>
#include <algorithm>

using namespace std;

const int maxn=1e5+10;
int N,T;

int A[maxn];
int main(){
    scanf("%d%d",&N,&T);
    for(int i=0;i<N;i++){
        scanf("%d",A+i);
    }
    int last_num=A[0];
    int cnt=0;
    int max_differ=-1;
    for(int i=1;i<N;i++){
        if(last_num<A[i]){
            if(max_differ<A[i]-last_num){
                max_differ=A[i]-last_num;
                cnt=1;
            }
            else if(max_differ==A[i]-last_num){
                cnt++;
            }
        }
        else
            last_num=A[i];
    }
    int ex_ans=T>>1;
    int ans;
    if(ex_ans==1){
        ans=1;
    }
    else {
        ans=cnt;
    }
    printf("%d\n",ans);
    // getchar();
    // getchar();
    return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define f(i, n) for(ll i=0;i<n;i++)
#define r(i, n) for(ll i=n-1;i>=0;i--)
#define forr(i, x, y) for(ll i=x;i<y;i++)
ll fastPower(ll n){
    ll res=1;
    ll a=2;
    while(n){
        if(n&1)
        res=(res*a)%1000000007;
        a=(a*a)%1000000007;
        n>>=1;

    }
    return res%1000000007;
}

int main()
{
    ll n; cin>>n;
    ll arr[64]={0};
    ll given[n]; 
    f(i,n) cin>>given[i];
    f(i,64){
        f(j,n){
            if(given[j]&1)
            arr[i]++;
            if(given[j]>0)
            given[j]>>=1;
        }
    }
    ll ans=0;
    f(i,64){
        ans+=(((n-arr[i])*arr[i])%1000000007)*fastPower(i);
        ans=ans%1000000007;

    }
    cout<<ans%1000000007<<endl;

}

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

int main(){
    int N,M;cin>>N>>M;
    vector<ll> price(N);
    for(int i=0;i<N;i++)cin>>price.at(i);
    sort(price.begin(),price.end());
    ll p;
    while(M){
        int i;
        p=price.at(N-1)/2;
        for(i=N-1;i>=0;i--){
            if(price.at(i)>=p){
                price.at(i)/=2;
                M--;
                if(M==0)break;
            }
            else break;
        }
        sort(price.begin(),price.end());
        if(price.at(N-1)==0)break;
    }
    ll ans=0;
    for(int i=0;i<N;i++)ans+=price.at(i);
    cout<<ans<<endl;


    return 0;
}

Measured memory_bytes: 1024
#include <iostream>

using namespace std;

int main()
{
    int A,B,X;
    cin>>A>>B>>X;
    if(A==X){
        cout<<"YES"<<endl;
    }
    else if((A>X) ||(X>(A+B))){
        cout<<"NO"<<endl;
    }
else{
    cout<<"YES"<<endl;
}
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
//template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
*/

int main(){
    string s; cin >> s;
    for(int i=0; i<3; i++){
        if(s[i] == '9') cout << 1;
        else cout << 9;
    }
    cout << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
 
using namespace std;
 
int main()
{
  int A, B ,C;
  cin >> A >> B >> C;
  
  if (A == B && B != C) {
  	cout << "Yes\n";
  }
  else if (B == C && C != A) {
  	cout << "Yes\n";  
  }
  else if (C == A && A != B) {
  	cout << "Yes\n";  
  }
  else {
    cout << "No\n";
  }
}

Measured memory_bytes: 3576
package main

import "fmt"

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

func main() {
	var a, b, c int
	fmt.Scan(&a, &b, &c)
	maxn, minn := max(a, max(b, c)), min(a, min(b, c))
	fmt.Println(minn, (a+b+c)-(maxn+minn), maxn)
}



Measured memory_bytes: 1120
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxx = 1e5 + 7;
const int Inf = 1 << 30;
const ll INF = 1ll << 60;
char s[125];

int main() {
	scanf("%s", s + 1);
	int l = strlen(s + 1);
	for(int i = 1; i <= l; i++) printf("x");
	printf("\n");
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define watch(x) cout<<"->"<<#x<<" : "<<x<<endl;
#define min3(a,b,c) min(a,min(b,c))
#define max3(a,b,c) max(a,max(b,c)) 
#define all(v) (v).begin(),(v).end()
typedef long long ll;
typedef unsigned long long llu;
const double PI = 2*acos(0.0);

signed main()
{
	//freopen("","r",stdin);
	//freopen("","w",stdout);
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int n,a,b;
	cin>>n>>a>>b;
	bool turn = 0;
	bool win;
	while(true)
	{
		if(!turn)
		{
			if(a+1==b)
			{
				win = 1;
				break;
			}
			else ++a;
		}
		else
		{
			if(b-1==a)
			{
				win = 0;
				break;
			}
			else --b;
		}
		turn = !turn;
	}	
	if(win)cout<<"Borys"<<endl;
	else
		cout<<"Alice"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#define N 100005
using namespace std;

int n, mx, a, c[N];
int main()
{
	int i;
	cin >> n;
	for (i = 0; i < n; i++) {
		scanf("%d", &a);
		c[a]++;
		mx = max(mx, a);
	}
	if (c[mx] + c[mx - 1] < n) {cout << "No"; return 0;}
	if (c[mx] == n) {
		if (mx == n - 1 || mx <= n / 2) cout << "Yes";
		else cout << "No";
	} else {
		if (c[mx - 1] + 1 <= mx && mx <= c[mx - 1] + c[mx] / 2) cout << "Yes";
		else cout << "No";
	}
    return 0;
}

Measured memory_bytes: 640
s  =input()
S = []
for c in s:
  S.append(c)
t = input()
T = []
for c in t:
  T.append(c)

S.sort()
s= ''.join(S)
T.sort(reverse=True)
t= ''.join(T)

print('Yes' if s<t else 'No')




Measured memory_bytes: 38256
//#define __USE_MINGW_ANSI_STDIO 0
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef pair<int, int> PII;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define MP make_pair
#define PB push_back
#define MOD 1000000007
#define INF (1LL<<30)
#define LLINF (1LL<<60)
#define PI 3.14159265359
#define EPS 1e-12
//#define int ll

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

	bool flag = true;
	int cnt = 0;
	for(int i=0; i<s.size(); i+=2) {
		while(cnt < t.size() && t[cnt] != s[i]) cnt++;
		if(cnt == t.size()) {flag = false; break;}
		cnt++;
		//cout << i << " " << cnt << endl;
	}
	if(flag) {cout << "Yes" << endl; return 0;}

	flag = true;
	cnt = 0;
	for(int i=1; i<s.size(); i+=2) {
		while(cnt < t.size() && t[cnt] != s[i]) cnt++;
		if(cnt == t.size()) {flag = false; break;}
		cnt++;
	}
	if(flag) {cout << "Yes" << endl; return 0;}
	cout << "No" << endl;

	return 0;
}

Measured memory_bytes: 3228
n, m = gets.split(" ").map(&:to_i)

a = Array.new()
b = Array.new()

n.times {
  a.push(gets.split.map(&:to_i))
}

m.times {
  b.push(gets.to_i)
}

for i in 0..n-1
  p = 0
  for j in 0..m-1
    p += a[i][j] * b[j]
  end
  puts p
end

Measured memory_bytes: 8836
#include <bits/stdc++.h>
#define rep(i, n) for (rint i = 1; i <= (n); i ++)
#define re0(i, n) for (rint i = 0; i < (int) n; i ++)
#define travel(i, u) for (rint i = head[u]; i; i = e[i].nxt)
#define rint int
using namespace std;
     
typedef long long lo;
     
template<typename tp> inline void read(tp &x) {
	x = 0; char c = getchar(); int f = 0;
	for (; c < '0' || c > '9'; f |= c == '-', c = getchar());
	for (; c >= '0' && c <= '9'; x = (x << 3) + (x << 1) + c - '0', c = getchar());
	if (f) x = -x;
}
namespace {
    const int mo = 998244353;
    inline int add(int x, int y) { x += y; return x >= mo ? x - mo : x; }
    inline int sub(int x, int y) { x -= y; return x < 0 ? x + mo : x; }
    inline int mul(int x, int y) { return (lo) x * y % mo; }
    inline int power(int a, int k = mo - 2) {
		int ans = 1;
		for (; k; k >>= 1, a = mul(a, a))
			if (k & 1) ans = mul(ans, a);
		return ans;
    }
	inline void U(int &x, int y) { x = add(x, y); } 
}
const int N = (1 << 18) + 3;
int n, m, p[N], sum, r[N];

inline void FWT(int *p, int f) {
	int n = ::m;
	for (int l = 2; l <= n; l <<= 1)
		for (int *a = p, m = l >> 1; a != p + n; a += l)
			for (int k = 0; k < m; k++) {
				int x = a[k], y = a[k + m];
				a[k] = add(x, y); a[k + m] = sub(x, y);
			}
	if (f == -1) {
		int mult = power((mo + 1) / 2, ::n);
		for (int i = 0; i < n; i++)
			p[i] = mul(p[i], mult);
	}
}

int main(void) {
	read(n); m = 1 << n;
	for (int i = 0; i < m; i++) {
		read(p[i]); sum += p[i];
	}
	sum = power(sum);
	for (int i = 0; i < m; i++) {
		p[i] = mul(p[i], sum);
		r[i] = mo - 1;
	}
	r[0] = m - 1;
	p[0] = sub(p[0], 1);
	// for (int i = 0; i < m; i++) {
	// 	cout << p[i] << " \n"[i + 1 == m];
	// }
	// for (int i = 0; i < m; i++) {
	// 	cout << r[i] << " \n"[i + 1 == m];
	// }
	FWT(r, 1); FWT(p, 1);
	for (int i = 0; i < m; i++) 
		r[i] = mul(r[i], power(p[i]));
	FWT(r, -1);
	for (int i = 0; i < m; i++) {
		cout << sub(r[i], r[0]) << "\n";
	}
}


Measured memory_bytes: 4864
N = int(input())
H = list(map(int,input().split()))
judge = 1 #可

for i in range(N):
  if(i != 0):
   dif = H[i]-H[i-1]
   if(dif == -1): 
     H[i] = H[i-1]      
   elif(dif < -1):
     judge = 0 #不可
  
if(judge == 1): print('Yes')
else: print('No')

Measured memory_bytes: 15020
#include"bits/stdc++.h"
using namespace std;
int ce(int a,int b){ if(a%b==0) return a/b; return a/b+1; }
int main()
{
  ios_base::sync_with_stdio(false); cin.tie(0); 
  int n,d; cin>>n>>d; cout<<ce(n,2*d+1)<<"\n";  
  return 0;
}

Measured memory_bytes: 3596
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
const int maxn = 20000;
int n,m;
int op[20][20];
int judge[200];
int states[200];
int ans;
void dfs(int now){
    if(now == n + 1){
        for(int i = 1;i <= m;i++){
            int Sum = 0;
            for(int j = 1;j <= op[i][0];j++){
                Sum += states[op[i][j]];
            }
            int x = Sum % 2;
            if(x != judge[i]) return;
        }
        ans ++;
        return;
    }
    states[now] = 0;
    dfs(now+1);
    states[now] = 1;
    dfs(now+1);
}

int main()
{
    cin >> n >> m;
    for(int i = 1;i <= m;i++){
        cin >> op[i][0];
        for(int j = 1;j <= op[i][0];j++){
            cin >> op[i][j];
        }
    }
    for(int i = 1;i  <= m;i++){
        cin >> judge[i];
    }
    dfs(1);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include"stdio.h"

int main(void) {
	// Your code here!
	int ans = 1,x;
	int a[4];
	int b[4] = { 1,4,7,9 };
	int c[4];
	for (int i = 0; i<4; i++) {
		scanf("%d", &a[i]);
	}
	for (int i = 0; i<4; i++) {
		for (int j = i+1; j<4; j++) {
			if (a[i] > a[j]) {
				x = a[i];
				a[i] = a[j];
				a[j] = x;
			}
		}

	}
	for (int i = 0; i < 4; i++) {
		if (a[i]!=b[i])ans = 0;
	}
	if (ans == 1)printf("YES\n");
	else printf("NO\n");

}


Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <math.h>
#include <string>
#include <numeric>


using std::cout;
using std::cin;
using namespace std;
typedef long long ll;
typedef unsigned long long ull;


ll gcd(ll a, ll b) {
    while (b != 0) {
        auto tmp = a;
        a = b;
        b = tmp % a;
    }
    return a;
}



void oneCase () {
    string line;
    cin >> line;
    int pos = 0;
    int n = line.size();
    int cnt = 0;
    while (pos < n - pos - 1) {
        if (line[pos] != line[n - pos - 1]) {
            ++cnt;
        }
        ++pos;
    }
    cout << cnt << "\n";
}




int main() {
    int k = 1;
//    cin >> k;
    for (int i = 0; i < k; ++i) {
        oneCase();
    }

    return 0;
}

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

vector<int> v[1000];
string str[1000];
int n;

void dfs(int a, int d){
	rep(i,d) printf(".");
	cout << str[a] << endl;
	rep(i,v[a].size()){
		dfs(v[a][i],d+1);
	}
}

int main(){
	cin >> n;
	rep(i,n){
		int k;
		cin >> k;
		k--;
		if(k >= 0) v[k].push_back(i);
		cin >> str[i];
	}
	dfs(0,0);
}

Measured memory_bytes: 1424
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define debug(x) cerr << "[(" << __LINE__ << ") " << #x << "]: " << (x) << endl;

int dfs(vector<vector<int>>& g, vector<int>& dp, int cur) {
    if (dp[cur] != -1) return dp[cur]+1;
    for (int e : g[cur]) {
        dp[cur] = max(dp[cur], dfs(g, dp, e));
    }
    return dp[cur]+1;
}

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

    int n, m;
    cin >> n >> m;
    vector<int> dp(n+1, -1);
    vector<vector<int>> g(n+1);
    for (int i=0; i<m; i++) {
        int x, y;
        cin >> x >> y;
        g[y].push_back(x);
    }

    int ans = 0;
    for (int i=1; i<n+1; i++)
        if (dp[i] == -1)
            ans = max(ans, dfs(g, dp, i));
    cout << ans << "\n";
}


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

int main()
{
    int h, w;
    cin >> h >> w;
    vector<vector<char>> x(h, vector<char>(w));
    vector<vector<char>> y(h, vector<char>(w));
    vector<vector<char>> z(h, vector<char>(w));
    for (int i = 0; i < h; i++)
    {
        for (int j = 0; j < w; j++)
        {
            cin >> x.at(i).at(j);
        }
    }
    int count=0;

    //縦を圧縮
    int iii = 0;
    for (int i = 0; i < h; i++)
    {
        count = 0;
        for (int j = 0; j < w; j++)
        {
            if (x.at(i).at(j) == '.')
            {
                count++;
            }
        }
        if (count != w)
        {
            for (int j = 0; j < w; j++)
            {
                y.at(iii).at(j) = x.at(i).at(j);
            }
            iii++;
        }
     // cout<<count<<endl;
      count=0;
    }

    //横を圧縮
    int jjj = 0;
    for (int j = 0; j < w; j++)
    {
        count = 0;
        for (int i = 0; i < iii; i++)
        {
            if (y.at(i).at(j) == '.')
            {
                count++;
            }
        }
        if (count != iii)
        {
            for (int i = 0; i < iii; i++)
            {
                z.at(i).at(jjj) = y.at(i).at(j);
            }
            jjj++;
        }
    //  cout<<count<<endl;
      count=0;
    }

    for (int i = 0; i < iii; i++)
    {
        for (int j = 0; j < jjj; j++)
        {
            cout << z.at(i).at(j);
        }
        cout<<endl;
    }
 // cout<<iii<<jjj<<endl;

}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <iterator>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <string>
#include <cmath>
using namespace std;
#define MOD 1000000007
#define INF 1<<30
#define LINF (ll)1<<62
#define MAX 510000
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(ll i=(a); i<(b); i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll, ll> P;
typedef vector<pair<ll, ll>> vpl;

ll power(ll x, ll m){
    if(m == 0) return 1;
    if(m == 1) return x;
    if(m % 2 == 0){
        return power(x*x,m/2);
    }else{
        return power(x*x,m/2)*x;
    }
}

int main(){
    ll d,n; cin >> d >> n;
    ll p = power(100,d);
    if(n!=100) cout << n*p << endl;
    else cout << (n+1)*p << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
string YESNO(int Z){
    if (Z == 0) return "No";
    else if (Z == 1) return "Yes";
}
int main(){
    vector<int> vec(3);
    cin >> vec.at(0) >> vec.at(1) >> vec.at(2);
    int maxx = *max_element(vec.begin(),vec.end());
    if ((vec.at(0) + vec.at(1) + vec.at(2)) - maxx == maxx) cout << YESNO(1) << endl;
    else cout << YESNO(0) << endl;
}

Measured memory_bytes: 256
//Abhinav ---IIIT_A
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define ld long double
#define pb push_back
#define ff first
#define ss second
#define f(i,x,n) for(int i=x;i<(int)n;++i)
#define vpii vector<pair<int,int>> 
#define vi vector<int>
#define vpii vector<pair<int,int>> 
#define mpii map<pair<int,int>,int>
#define mpivpii map<int,vector<pair<int,int>>> 
#define pii pair<int,int> 
#define all(x) x.begin(),x.end()
#define sz(x) x.size()
#define mpi map<int,int>
#define vvi vector<vector<int>>
#define vvvi vector<vvi>

ld pie=3.141592653589793238462643383279;
int mod=1e9+7;

struct point{
  ld x,y;
};

vvi mat_mul(vvi mat1,vvi mat2){
  vvi ret;
  f(i,0,2){
    vi xx;
    f(j,0,2){
      int r=0;
      f(k,0,2) r=(r+(mat1[i][k]*mat2[k][j])%mod)%mod;
      xx.pb(r%mod);
    }
    ret.pb(xx);
  }
  return ret;
}

vvi mat_exp(vvi mat,int p){
  vvi iden={{1,0},{0,1}};
  while(p!=0){
    if(p&1) iden=mat_mul(iden,mat);
    p/=2; 
    mat=mat_mul(mat,mat);
  }
  return iden;
}


int myexp(int p){
  p++;
  int r=1;
  int val=2;
  while(p!=0){
    if(p&1){
      r*=val;
    }
    val*=val;
    p/=2;
  }
  r-=2;
  return r;
}


int fact[2000005];
int infact[2000005];
 
int inv(int a){
  int y=mod-2;
  int r=1;
  while(y!=0){
    if(y&1){
      r*=a; r%=mod;
    }
    y/=2; a*=a; a%=mod;
  }
  return r;
}
 
int po(int a,int y){
  int r=1;
  while(y!=0){
    if(y&1){
      r*=a; r%=mod;
    }
    y/=2; a*=a; a%=mod;
  }
  return r; 
}
 
void facto(){
  fact[0]=1;
  f(i,1,2000005) {fact[i]=i*fact[i-1]; fact[i]%=mod;}
  f(i,0,2000005) infact[i]=inv(fact[i]); 
}
 
int nck (int n,int k){
  if(k<0 || k>n) return 0;
  int ret=fact[n]; ret*=infact[k]; ret%=mod;
  ret*=infact[n-k]; ret%=mod;
  return ret;
}
  
void mymul(int arr[],int num){
  int carry=0;
  f(i,0,100){
    arr[i]=arr[i]*num+carry;
    carry=arr[i]/10;
    arr[i]%=10;
  }
}

map<int,int> mp;

int myfun(int val){
  auto it = mp.lower_bound(val);
  if(it==mp.begin()) return 0;
  --it; 
  return it->second;
}

void myerase(int val,int key){
 
}

int32_t main(){ 
  ios_base::sync_with_stdio(false);   
  cin.tie(NULL);
  #ifndef ONLINE_JUDGE
  freopen("input.txt","r",stdin);
  freopen("output.txt","w",stdout);
  #endif
  int n; cin>>n;
  map<int,int> mp;
  f(i,0,n){
    int x; cin>>x;
    ++mp[x];
  }
  int del=0;
  for(auto it : mp){
    if(it.ss >= it.ff) del+=it.ss-it.ff;
    else del+=it.ss; 
  }
  cout<<del;
  return 0; 
}
// check for overflows dummy !!!

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

int main(){
  int n;
  cin >> n;
  int a[n];
  for(int i=0; i<n; i++){
    cin >> a[i];
  }
  double sum = 0;
  for(int i=0; i<n; i++){
    sum += (double)1/a[i];
  }
  printf("%.16f\n", double(1/sum));
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstring>

template <class T>
inline void read(T &x) {
    x = 0;
    int f = 0;
    char ch = getchar();
    while (!isdigit(ch))    { f |= ch == '-'; ch = getchar(); }
    while (isdigit(ch))     { x = (x << 1) + (x << 3) + (ch ^ 48); ch = getchar(); }
    x = f ? -x : x;
    return;
}

int a[10];

int main() {
    read(a[1]), read(a[2]), read(a[3]);
    std::sort(a + 1, a + 4);
    puts(a[1] == a[2] && a[1] == 5 && a[3] == 7 ? "YES" : "NO");
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<ctime>

using namespace std;
using ll = long long;

// vector<int> contribution(int n){
//   vector<int> a(n+1, 0);
//   a[0] = 1;
//   for(int i = 1; i <= n/2; i++){
//     a[i] = a[i-1] * (n+1 - i) / i % 2;
//   }
//   for(int i = 0; i <= n/2; i++){
//     a[n-i] = a[i];
//   }
//   // for(int i = 0; i < n+1; i++) cout << a[i] << ' ';
//   // cout << endl;
//   return a;
// }

vector<int> contribution(int n){
  vector<int> a(n, 0);
  for(int i = 0; i < n; i++){
    if(((n-1) | i) == n-1){
      a[i] = 1;
    }
  }
  return a;
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int ti = clock();
  // start-----------------------------------------------
  int n; cin >> n;
  string s; cin >> s;
  vector<int> c = contribution(n);
  vector<int> a(n);
  bool f = 0;
  bool ans = 0;
  for(int i = 0; i < n; i++){
    a[i] = s[i]-'1';
    if(a[i] == 1) f = true;
  }
  if(f){
    for(int i = 0; i < n; i++){
      if(a[i]%2 && c[i]) ans = !ans;
    }
    if(ans) cout << 1 << endl;
    else cout << 0 << endl;
  }
  else{
    for(int i = 0; i < n; i++){
      if(a[i] && c[i]) ans = !ans;
    }
    if(ans) cout << 2 << endl;
    else cout << 0 << endl;
  }

  // end-----------------------------------------------
  // cerr << 1.0 * (clock() - ti) / CLOCKS_PER_SEC << endl;
}


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

int main() {

	int a,b,c,K,max1,max2;
	cin>>a>>b>>c>>K;

  max1=max(a,b); //error
  max1=max(max1,c); max2=max1; 
  for(int i=0;i<K;i++){
    max1 *= 2;}//cout<<max1<<endl;
  if(max2==a){cout<<b+c+max1<<endl;}
  else if(max2==b){cout<<a+c+max1<<endl;}
  else{cout<<a+b+max1<<endl;}
 
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define MP make_pair
#define PB push_back
#define int long long
#define st first
#define nd second
#define rd third
#define FOR(i, a, b) for(int i =(a); i <=(b); ++i)
#define RE(i, n) FOR(i, 1, n)
#define FORD(i, a, b) for(int i = (a); i >= (b); --i)
#define REP(i, n) for(int i = 0;i <(n); ++i)
#define VAR(v, i) __typeof(i) v=(i)
#define FORE(i, c) for(VAR(i, (c).begin()); i != (c).end(); ++i)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
using namespace std;
template<typename TH> void _dbg(const char* sdbg, TH h) { cerr<<sdbg<<"="<<h<<"\n"; }
template<typename TH, typename... TA> void _dbg(const char* sdbg, TH h, TA... t) {
  while(*sdbg != ',')cerr<<*sdbg++; cerr<<"="<<h<<","; _dbg(sdbg+1, t...);
}
#ifdef LOCAL
#define debug(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#define debugv(x) {{cerr <<#x <<" = "; FORE(itt, (x)) cerr <<*itt <<", "; cerr <<"\n"; }}
#else
#define debug(...) (__VA_ARGS__)
#define debugv(x)
#define cerr if(0)cout
#endif
#define next ____next
#define prev ____prev
#define left ____left
#define hash ____hash
typedef long long ll;
typedef long double LD;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VLL;
typedef vector<pair<int, int> > VPII;
typedef vector<pair<ll, ll> > VPLL;

template<class C> void mini(C&a4, C b4){a4=min(a4, b4); }
template<class C> void maxi(C&a4, C b4){a4=max(a4, b4); }
template<class T1, class T2>
ostream& operator<< (ostream &out, pair<T1, T2> pair) { return out << "(" << pair.first << ", " << pair.second << ")";}
template<class A, class B, class C> struct Triple { A first; B second; C third;
  bool operator<(const Triple& t) const { if (st != t.st) return st < t.st; if (nd != t.nd) return nd < t.nd; return rd < t.rd; } };
template<class T> void ResizeVec(T&, vector<int>) {}
template<class T> void ResizeVec(vector<T>& vec, vector<int> sz) {
  vec.resize(sz[0]); sz.erase(sz.begin()); if (sz.empty()) { return; }
  for (T& v : vec) { ResizeVec(v, sz); }
}
typedef Triple<int, int, int> TIII;
template<class A, class B, class C>
ostream& operator<< (ostream &out, Triple<A, B, C> t) { return out << "(" << t.st << ", " << t.nd << ", " << t.rd << ")"; }
template<class T> ostream& operator<<(ostream& out, vector<T> vec) { out<<"("; for (auto& v: vec) out<<v<<", "; return out<<")"; }

    
int32_t main() {

  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(10);
  cerr << fixed << setprecision(10);
  cin.tie(0);
  //double beg_clock = 1.0 * clock() / CLOCKS_PER_SEC;
  
  int q, h, s, d;
  cin>>q>>h>>s>>d;
  mini(h, 2 * q);
  mini(s, 2 * h);
  mini(d, 2 * s);
  int n;
  cin>>n;
  cout<<n / 2 * d + (n % 2) * s<<endl;
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  return 0;
}


Measured memory_bytes: 256