akhauriyash/Code-Regression huggingface dataset:
s = input()
ans = 'Yes'
if ('N' in s):
  if not ('S' in s): ans = 'No'
if ('W' in s):
  if not ('E' in s): ans = 'No'
if ('S' in s):
  if not ('N' in s): ans = 'No'
if ('E' in s):
  if not ('W' in s): ans = 'No'
print(ans)

Measured memory_bytes: 3064
mod = 10**9+7

n,k = map(int, input().split())
a = [int(x) for x in input().split()]
a = sorted(a)

def inv(a,mod):
    r = [1,0,a]
    w = [0,1,mod]
    while w[2]!=1:
        q = r[2]//w[2]
        r_new = [r[0]-q*w[0],r[1]-q*w[1],r[2]-q*w[2]]
        r = w
        w = r_new
    x,y = w[0],w[1]    # a*x+y*mod = 1
    return (mod+x%mod)%mod

max_num = 2*10**5+1
fact = [0 for _ in range(max_num)]
ifact = [0 for _ in range(max_num)]

fact[0] = fact[1] = 1
ifact[0] = ifact[1] = 1

for i in range(2,max_num):
    fact[i] = fact[i-1] * i % mod
    ifact[i] = ifact[i-1] * inv(i,mod) % mod

def cmb(x,y):
    return fact[x] * ifact[y] * ifact[x-y] % mod

ans = 0

for i in range(k-1,n):
    ans += a[i]*cmb(i,k-1)
    ans %= mod

for i in range(n-k+1):
    ans -= a[i]*cmb(n-1-i,k-1)
    ans %= mod

print(ans)

Measured memory_bytes: 73896
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int a,b,Q;
    cin >> a >> b >> Q;
    vector<long long>s(a+2),t(b+2);
    s[0]=-(1e11);t[0]=-(1e11);
    s[a+1]=1e12;t[b+1]=1e12;
    for(int i=0;i<a;i++)cin >> s[i+1];
    for(int i=0;i<b;i++)cin >> t[i+1];

    for(int i=0;i<Q;i++){
        long long x;
        cin >> x;
        int l=-1;int r=a+2;
        while(r-l>1){
            int mid=(l+r)/2;
            if(s[mid]<x)l=mid;
            else r=mid;
        }
        int ll=-1;int rr=b+2;
        while(rr-ll>1){
            int mid=(ll+rr)/2;
            if(t[mid]<x)ll=mid;
            else rr=mid;
        }
        long long ans = (1e12);
        ans=min(ans,max(abs(x-s[l]),abs(x-t[ll])));
        ans=min(ans,max(abs(x-s[r]),abs(x-t[rr])));
        ans=min(ans,abs(s[r]-t[ll])+min(abs(x-s[r]),abs(x-t[ll])));
        ans=min(ans,abs(t[rr]-s[l])+min(abs(x-t[rr]),abs(x-s[l])));
        cout << ans << '\n';
    }

    return 0;
}


Measured memory_bytes: 2944
let n = Int(readLine()!)!
let a = readLine()!.split(separator: " ").map { Int($0)! }

var iDict = [Int: Int]()
var jDict = [Int: Int]()

a.enumerated().forEach { (i, v) in
  iDict[i+v] = iDict[i+v] ?? 0
  iDict[i+v]? += 1
  jDict[i-v] = jDict[i-v] ?? 0
  jDict[i-v]? += 1
}

var c = 0
iDict.forEach { (v, iIndicesNum) in
  if let jIndicesNum = jDict[v] {
    c += iIndicesNum * jIndicesNum
  }
}

print(c)


Measured memory_bytes: 26320
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef unsigned long long ULL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

int main() {
  int n, old;

  while(1) {
    cin >> n;
    if(!n) break;
    int a[7] = {0};
    REP(i, n) {
      cin >> old;
      if(0 <= old && old < 10) a[0]++;
      else if(10 <= old && old < 20) a[1]++;
      else if(20 <= old && old < 30) a[2]++;
      else if(30 <= old && old < 40) a[3]++;
      else if(40 <= old && old < 50) a[4]++;
      else if(50 <= old && old < 60) a[5]++;
      else a[6]++;
    }

    REP(i, 7) {
      cout << a[i] << endl;
    }
  }
}

Measured memory_bytes: 1160
import java.util.*;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		Checker c;
		String line;
		
		while(true){
			line = sc.nextLine();
			if(line.equals(".")){
				break;
			}else if(!line.isEmpty()){
				c = new Checker(line);
				if(c.scanLine()){
					System.out.println("yes");
				}else{
					System.out.println("no");
				}
			}
		}
		
	}
}

class Checker {
	String line;
	Stack<String> stack;
	
	public Checker(String line){
		this.line = line;
		stack = new Stack<String>();
	}
	
	public boolean scanLine(){
		if(!(line.charAt(line.length()-1) == '.')){
			return false;
		}
		
		for(int i=0; i<line.length(); i++){
			if(line.charAt(i) == '('){
				stack.push("(");
			}else if(line.charAt(i) == ')'){
				if(stack.size() == 0){
					return false;
				}else if(!stack.pop().equals("(")){
					return false;
				}
			}else if(line.charAt(i) == '['){
				stack.push("[");
			}else if(line.charAt(i) == ']'){
				if(stack.size() == 0){
					return false;
				}else if(!stack.pop().equals("[")){
					return false;
				}
			}
		}
		
		if(stack.size() != 0){
			return false;
		}
		
		return true;
	}
}

Measured memory_bytes: 32612
package main

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

func getScanner(fp *os.File) *bufio.Scanner {
	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 500001), 500000)
	return scanner
}

func getNextString(scanner *bufio.Scanner) string {
	scanner.Scan()
	return scanner.Text()
}

func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}

func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}

func getNextUint64(scanner *bufio.Scanner) uint64 {
	i, _ := strconv.ParseUint(getNextString(scanner), 10, 64)
	return i
}

func getNextFloat64(scanner *bufio.Scanner) float64 {
	i, _ := strconv.ParseFloat(getNextString(scanner), 64)
	return i
}

func main() {
	fp := os.Stdin
	wfp := os.Stdout

	if os.Getenv("MASPY") == "ますピ" {
		fp, _ = os.Open(os.Getenv("BEET_THE_HARMONY_OF_PERFECT"))
	}
	if os.Getenv("MASPYPY") == "ますピッピ" {
		wfp, _ = os.Create(os.Getenv("NGTKANA_IS_GENIUS10"))
	}

	scanner := getScanner(fp)
	writer := bufio.NewWriter(wfp)

	n := getNextInt(scanner)
	s := getNextString(scanner)

	for i := 0; i < 2; i++ {
		for j := 0; j < 2; j++ {
			ok, ans := solve(i, j, n, s)
			if ok {
				fmt.Println(ans)
				return
			}
		}
	}

	fmt.Fprintln(writer, -1)
	writer.Flush()
}

func solve(an0, an1, n int, s string) (bool, string) {
	ans := make([]int, n)
	ans[0] = an0
	ans[1] = an1
	for i := 0; i < n-2; i++ {
		if ans[(i+1)%n] == 0 {
			if s[i+1] == 'o' {
				ans[(i+2)%n] = ans[i]
			} else {
				ans[(i+2)%n] = 1 - ans[i]
			}
			continue
		}
		if s[i+1] == 'o' {
			ans[(i+2)%n] = 1 - ans[i]
		} else {
			ans[(i+2)%n] = ans[i]
		}
	}

	ss := make([]string, n)
	animal := map[int]string{
		0: "S",
		1: "W",
	}
	for i := 0; i < n; i++ {
		ss[i] = animal[ans[i]]
	}

	animals := strings.Join(ss, "")
	for i := 0; i < n; i++ {
		if ans[i] == 0 {
			if s[i] == 'o' && ans[(i-1+n)%n] != ans[(i+1+n)%n] {
				return false, animals
			}
			if s[i] != 'o' && ans[(i-1+n)%n] == ans[(i+1+n)%n] {
				return false, animals
			}
			continue
		}
		if s[i] == 'o' && ans[(i-1+n)%n] == ans[(i+1+n)%n] {
			return false, animals
		}
		if s[i] != 'o' && ans[(i-1+n)%n] != ans[(i+1+n)%n] {
			return false, animals
		}
	}

	return true, animals
}


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

int main(){
  long long int N;
  cin >> N;
  int seikai = -1;
  long long int A[N];
  long long int B[N];
  for(int i=0; i<N ;++i){
    if(i==0) {
      A[i] = 7%N;
      B[i] = 7%N;
    }
    else {
      A[i] = (A[i-1]*10)%N;
      B[i] = A[i] + B[i-1];
    }
    if(B[i]%N==0) {
      seikai = i+1;
      break;
    }  
  }
  cout << seikai <<endl;
}

Measured memory_bytes: 19184
N, K = map(int, input().split())
MOD = 10**9+7

mx = [0]*(K+1)
ans = 0

for i in range(K, 0, -1):
    mx[i] = pow(K//i, N, MOD)
    for j in range(2*i, K+1, i):
        mx[i] -= mx[j]
    ans += i*mx[i]

print(ans%MOD)


Measured memory_bytes: 11152
#include <iostream>
#include <stack>
#include <algorithm>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <functional>
#include <string>
#include <cstdlib>
#include <numeric>
#include <cstdbool>
#include <cstring>
#include <map> 
#include<set>
#include<queue>
#include <iomanip>

typedef long long ll;

#define rep(i,n) for(ll i=0;i<n;i++)
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; }

const long long INF = 1000000000000000;
const ll inf = -1e18;
typedef pair<ll, ll> P;
ll ma = 1000000000 + 7;
ll mx = 1000003;
ll h,n, w,m; string s;
int dx[4] = { 1, 0, -1, 0 };
int dy[4] = { 0, 1, 0, -1 };
ll gcd(ll x, ll y) {
	if (x % y == 0) return y;
	return gcd(y, x % y);
}
ll lcm(ll a,ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}
void comb(vector<vector <ll> >& v) {
	for (ll i = 0; i < v.size(); i++) {
		v[i][0] = 1;
		v[i][i] = 1;
	}
	for (ll k = 1; k < v.size(); k++) {
		for (int j = 1; j < k; j++) {
			v[k][j] = (v[k - 1][j - 1] + v[k - 1][j])%ma;
		}
	}
}

ll GetDigit(ll num) {
	return log10(num) + 1;
}
ll Combination(int n, int r)
{
	if (n - r < r) r = n - r;
	if (r == 0) return 1;
	if (r == 1) return n;

	vector<ll> numerator(r);
	vector<ll> denominator(r);

	for (int k = 0; k < r; k++)
	{
		numerator[k] = n - r + k + 1;
		denominator[k] = k + 1;
	}

	for (int p = 2; p <= r; p++)
	{
		int pivot = denominator[p - 1];
		if (pivot > 1)
		{
			int offset = (n - r) % p;
			for (int k = p - 1; k < r; k += p)
			{
				numerator[k - offset] /= pivot;
				denominator[k] /= pivot;
			}
		}
	}

	ll result = 1;
	for (int k = 0; k < r; k++)
	{
		if (numerator[k] > 1) result *= numerator[k];
		result %= ma;
	}

	return result;
}
int main() {
	cin >> n;
	cin >> s;
	if (n % 2 == 0) {
		rep(i, n / 2) {
			if (s[i] != s[i + (n / 2)]) {
				cout << "No" << endl;
				return 0;
			}
		}
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
		return 0;
	}
}


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

using namespace std;

int main(void)
{
	string s[3];
	int diff='a'-'A';
	for(int i=1;i<=3;i++)
	{
		cin >> s[i-1];
		printf("%c",s[i-1][0]-diff);
	}
	cout << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<=b;++i)
#define per(i,a,b) for(int i=a;i>=b;--i)
#define repd(i,a,b) for(int i=a;i>=b;--i)
#define rvc(i,S) for(int i=0;i<(int)S.size();++i)
#define fore(i,x) for(int i = head[x] ; i ; i = e[i].next)
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define ll long long
#define PII pair<int,int>
#define debug(...) fprintf(stderr, __VA_ARGS__)
#define int ll
using namespace std;
int ans=0;
int n;
signed main()
{cin>>n;
 int j;
 for(int i=1;i<=n;i=j+1)
   { j=n/(n/i);
     int tmp=n/i;
	 if((n-tmp)%tmp==0)
	 { int m=(n-tmp)/tmp;
	   if(m>=i&&m<=j) ans+=m;
	 }
   }
  cout<<ans;	
	
	
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include<cmath>
#define N 100005
#define A 1000005
#define MOD 998244353 //1000000007 // //100000000
#define INF 1000000000000000000
#define ll long long
//#define M_PI 3.141592653589793238463

using namespace std;

#define pii pair<ll, ll>
#define piii pair<ll, pii>
#define ft first
#define sd second
#define pb push_back
#define rep(i, n) for(ll i = 0; i < n; i++)
#define repr(i, n) for(ll i = n-1; i >= 0; i--)
#define itr(it, x) for(auto it = x.begin(); it != x.end(); it++)
#define mem(a, b) memset(a, (ll)b, sizeof(a))
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()
#define edge(v, x, y) v[x].pb(y); v[y].pb(x);
#define popcount __builtin_popcount
#define ANS(s) {cout << s << "\n"; return;}

//~~~~~~fancy print~~~~~~~//
#define printpii(a) cout << a.ft << " " << a.sd << endl;
#define printpiii(a) cout << a.ft << " " << a.sd.ft << " " << a.sd.sd << endl;
#define print(a, n) rep(i, n) cout << a[i] << " "; cout << endl;
#define printv(v) for(auto x: v)cout << x << " "; cout << endl;
#define printm(a, n, m) rep(i, n) { rep(j, m) cout << a[i][j] << "\t"; cout << endl;}

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

void fast(){ios_base::sync_with_stdio(false);cin.tie(0);cout << setprecision(12) << fixed;}


void solve(){
    ll a, b, c, k;
    cin >> a >> b >> c >> k;
    cout << (k%2 == 1? b-a: a-b);
}
main(){
    /*#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif*/
    fast();
    ll t = 1; //cin >> t;
    while(t--){
        solve();
    }
}


Measured memory_bytes: 256
string = input()
lengch = len(string)
halfLengch = lengch // 2
startString = list(string[:halfLengch])
endString = list(string[:halfLengch - 1:-1])
countHug = 0
 
for i,j in zip(startString, endString) :
    if i != j :
      countHug += 1
 
print(countHug)

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

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

using namespace std;

typedef long long ll;

// const int INF = 1 << 30;
// const ll INF = 1LL << 60;
// const int MOD = 1000000007;

int main() {
  int n, k;
  cin >> n >> k;

  double ans = 0;

  REP (i, 1, n + 1) {
    int c = i;
    double tmp = 1.0 / n;
    while (c < k) {
      c *= 2;
      tmp /= 2;
    }
    ans += tmp;
  }

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


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

typedef long long ll;
const ll INF = 1010000000000000017LL;
const ll MOD = 1000000007LL;

#define REP(i, n) for(ll i = 0 ; i < n; i++)

//#define DEBUG(fmt, ...)
#define DEBUG(fmt, ...) fprintf(stderr, fmt "\n", ##__VA_ARGS__)

int main(){
    std::cout<<std::fixed<<std::setprecision(10);

    ll N, K;

    cin >> N >> K;
    vector<ll> array(N+1, 0);

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

    unordered_map<ll, ll> visited; // i, dist
    unordered_map<ll, ll> steps; // dist, i
    ll dist = 0;
    ll last = 0;
    ll next = 1;
    ll circle;
    while(true){
        last = next;
        visited.insert(make_pair(next, dist));
        steps.insert(make_pair(dist,next));
        next = array[next];
        dist++;
        if(visited.find(next) != visited.end()){
            // found circle
            circle = next;
            break;
        }
    }

    ll step_to_circle = visited.find(circle)->second;
    ll step_1_round = visited.find(last)->second - step_to_circle + 1;

    // DEBUG("s1=%lld, s2 = %lld", step_to_circle, step_1_round);

    if( K <= step_to_circle ){
        cout << steps.find(K)->second << endl;
    }else{
        K -= step_to_circle;
        K %= step_1_round;
        K += step_to_circle;
        cout << steps.find(K)->second << endl;
    }

}


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

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = (n) - 1; i >= 0; i--)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (a); i > (b); i--)
#define ALL(a) (a).begin(), (a).end()

int main() {
    int N, M, a, b, road[50] = {};
    cin >> N >> M;
    REP(i, M) {
        cin >> a >> b;
        road[a - 1]++;
        road[b - 1]++;
    }
    REP(i, N) cout << road[i] << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <algorithm>
#include <vector>
#include <iterator>
#include <cmath>
#include <map>
using namespace std;

void func149c() {
  int x;
  cin >> x;
  for (int i = 2; i < x; i++) {
    if (x%i == 0) {
      //xが割り切れちゃったら次の数字へ
      //iもリセット
      x++;
      i = 1;
    }
  }
  cout << x;
}



int main() {
  func149c();
  return 0;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(100000000)


def main():
    n, m , q = map(int, input().split())

    all_qlist = []
    for i in range(q):
        _qlist = list(map(int, input().split()))
        all_qlist.append(_qlist)
    max = sum([x[3] for x in all_qlist])

    all_list = []
    # for i in range(n):
    _list = []
    for i in range(1, m+1):
        tmp_list = []
        all_list.append(tmp_list)
        tmp_list.append(i)

    for _ in range(n-1):
        tmp_all_list = []
        for _list_sub in all_list:
            x = _list_sub[-1]
            for i in range(x, m+1):
                tmp_list = _list_sub.copy()
                tmp_all_list.append(tmp_list)
                tmp_list.append(i)
        all_list = tmp_all_list

    total_max = 0
    for _list in all_list:
        total = 0
        for _qlist in all_qlist:
            if _list[_qlist[1]-1] - _list[_qlist[0]-1] == _qlist[2]:
                total += _qlist[3]
        if total > total_max:
            total_max = total
        if total_max == max:
            break

    print(total_max)


main()


Measured memory_bytes: 38656
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h>
#include <iomanip>
using namespace std;
#define int long long

int sosu(int x){
    if(x < 2) return 0;
    if(x == 2) return 1;
    if(x % 2 == 0) return 0;
    for(int i = 3;i * i <= x;i += 2) if(x % i == 0) return 0;
    return 1;
}

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

    long double n; cin >> n;
    vector<long double> a(n);
    for(int i = 0;i < n;i ++) cin >> a.at(i);
 
    long double ans = 1;
 
    for(long double i = 0;i < n;i ++){
        if(a.at(i) == 0){
            cout << 0 << endl;
            return 0;
        }
    }
 
    for(long double i = 0;i < n;i ++){
        ans *= a.at(i);
        if(ans > 1000000000000000000){
            cout << -1 << endl;
            return 0;
        }
    }
    cout << (int)ans << endl;

}

Measured memory_bytes: 4888
<?php
    // データ読み込み部
    fscanf(STDIN, "%d", $N);
    $A = explode(" ", trim(fgets(STDIN)));

    // 石の数の総計
    $total = array_sum($A);
    // 1回の操作で取り出す石の数
    $one = (1 + $N) * $N / 2;
    // 取り出す回数を算出
    $round = $total / $one;
    // 取り出す回数計算用
    $round_x = $round;
    // 取り出す回数が整数でない場合はNOを出力して終了
    if (floor($round) != $round) {
        echo "NO\n";
        exit;
    }

    // 配列の最後に1番目の箱をつける
    $A[] = $A[0];
    for ($i = 0; $i < $N; $i++) {
        // 「右の箱の石の数」引く「左の箱の石の数」引く「取り出す回数」
        $diff = $A[$i+1] - $A[$i] - $round;
        if ($diff < 0) {
            // ここがマイナスになる場合には切れ目なので切れ目の回数を計算
            $kaisuu = floor($diff / $N);
            $round_x += $kaisuu;
        }
    }

    // 「切れ目の数」と「取り出す回数」が同じならYES
    if ($round_x == 0) {
        echo "YES\n";
    } else {
        echo "NO\n";
    }


Measured memory_bytes: 10868
n = int(input())
ans = 0
flg = False
for _ in range(n):
    a, b = map(int, input().split())
    if a == b:
        ans += 1
        if ans >= 3:
            flg = True
    else:
        ans = 0
if flg:
    print('Yes')
else:
    print('No')

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

int main(){
    int flag=0;
    int n;
    cin >>n;
    int x[n],sorted[n];
    int small,big;
    int ans=0;

    for (int i = 0; i < n; i++){
        cin >> x[i];
        sorted[i] = x[i];
    }
    sort(sorted,sorted+n);
    
    small=sorted[(n-1)/2];
    big = sorted[((n-1)/2)+1];

    for (int i = 0; i < n; i++){
        
        if(x[i] <= small)cout << big << '\n';
        else if(x[i] >= big)cout << small << '\n';
    }

    //cout <<fixed<<setprecision(16)<< << endl;

    //if(flag==1)cout << "Yes" <<endl;
    //else cout << "No" <<endl;
    
    return 0;
}


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


int main() {
    int N;
    cin >> N;
    vector<int> v(N*3);
    for (int i = 0; i < N * 3; ++i) {
        cin >> v.at(i);
    }
    sort(v.begin(), v.end());
    reverse(v.begin(), v.end());
    int64_t sum = 0;
    for (int i =1; i < N + N; i+=2) {
        sum += v.at(i);
    }
    cout << sum << endl;
}

Measured memory_bytes: 1408
import java.util.*; 
public class Main{
    static public void main(String[] args){
        Scanner sc=new Scanner(System.in);
       String str=sc.next();
       String str2=sc.next();
       int num=0;
       for(int i=0;i<str.length();i++){
           if(str.charAt(i)==str2.charAt(i)){
               continue;
           }
           else{
               num++;
           }
       }
       System.out.print(num);
        sc.close();
    }
}

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

int main(){
    int n;
    char c;
    double w,h;
    while(cin >> n >> c >> w >> c >> h){
    	if(w / h / h >= 25){
    		cout << n << endl;
    	}
    }
    return 0;
}


Measured memory_bytes: 3068
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
 
#define num_max(p,q)((p)>(q)?(p):(q))
#define num_min(p,q)((p)<(q)?(p):(q))
int cmp(const void *a, const void *b)
{
	return *(int*)a - *(int*)b;//昇順
	 //降順ならreturn *(int*)b - *(int*)a;
}
int main()
{
	int n;
	char s[110];
	
	scanf("%d", &n);
	for (int i = 0;i <= n;i++)scanf("%c", &s[i]);
	if (n % 2 != 0) {
		printf("No\n");return 0;
	}
	int m = n / 2;
	for (int i = 1;i <= m;i++)
	{
		if (s[i] != s[i + m])
		{
			printf("No\n");
			return 0;
		}
	}
	printf("Yes\n");
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define _LIBCPP_DEBUG 0

using namespace std;
#define ll long long
#define rep(i,n) for (int i = 0; i < n; i++)
#define MOD (1000000007)
#define vi vector<int>
#define vvi vector<vi>
#define all(a)  (a).begin(),(a).end()

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

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

const ll INF = 1LL << 60;

int main() {
  int N, M;
  cin >> N >> M;
  vi P(M), Y(M);
  vector<vector<int>> ans(N);
  rep(i,M){
    cin >> P[i] >> Y[i];
    P[i]--;
    ans[P[i]].push_back(Y[i]);
  }

  rep(i,N){
  	sort(all(ans[i]));
  }

  rep(i,M){
    cout<< setfill('0') << setw(6) << P[i]+1;
    //"lower_bound(all(配列), key) - 配列.begin()" でkeyの先頭からの距離（0-index）
    //"lower_bound(all(配列), key)" はkey以上の要素の値（型はイテレータ）を返す
    int num = lower_bound(all(ans[P[i]]),Y[i])-ans[P[i]].begin();
    cout<< setfill('0') << setw(6) << num+1 <<endl;
  }
}


Measured memory_bytes: 7808
//#pragma comment(linker, "/stack:200000000") //  (UNCOMMENT WHEN HAVING LOTS OF RECURSIONS)
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC optimize("unroll-loops")  // $ (UNCOMMENT WHEN TRYING TO BRUTEFORCE WITH A LOT OF LOOPS)\

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

#define endl "\n"
#define int long long
#define ll long long
#define pb push_back
#define all(c) (c).begin(), (c).end()
#define fi first
#define se second
#define vi vector<int>
#define vii vector< vector<int> >
#define vpi vector< pair<int,int> >
#define pair <int, int> pii

typedef tree< int, null_type, less<int>, rb_tree_tag,tree_order_statistics_node_update>
    ordered_set;
// order_of_key (val): returns the no. of values less than val
// find_by_order (k): returns the iterator to kth largest element.(0-based)

#define TRACE
#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	cerr << name << " : " << arg1 << endl;}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<"  ";__f(comma+1, args...);}
#else
#define trace(...)
#endif

template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){
	o<<"{";
	for(const T& v:vc) o<<v<<",";
	o<<"}";
	return o;
}

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

const long long inf = 2e18 ;
const int mod = 1e9+7 ;
// const int mod = 998244353 ;
const int N = 1e5 + 10 ;

typedef long double ld;

int lcm(int a,int  b) {
	return ( (a*b)/(__gcd(a,b)) );
}

int f(int n, int m) {
	ld ans=0;
	ans=1.0*n;
	ans=ans/m;
	int qw = n/m;
	if(ans-(ld)qw <0.5000) {
		return qw;
	}
	else{ 
		return (qw+1);
	}
}

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

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

	int a[n];
	bool ok=true;
	int x=1;
	int o=0;
	for(int i=0;i<n;i++) {
		cin>>a[i]; 
		if(i==0){
			int ss=a[0];
			while(ss%2==0) {
				ss/=2;
				o++;
			}
		}
		int temp=0;
		int zz=a[i];
		while(zz%2==0) {
			zz/=2;
			temp++;
		}
		if(temp!=o) {
			ok=false;
		}
		x=lcm(a[i],x);
	}

	int ans=f(m,x);
	if(!ok)ans=0;
	cout<<ans<<endl;

return 0 ;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int main(){
  long long a,b,c,d,ans=0;
  cin >> a >> b >> c >> d;
  ans+=b/c-(a-1)/c;
  ans+=b/d-(a-1)/d;
  long long lcm=c*d/__gcd(c,d);
  ans-=b/lcm-(a-1)/lcm;
  cout << b-a+1-ans << endl;
  return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_DEPRECATE
#define _USE_MATH_DEFINES
#include <iostream>
#include <cmath>
#include <string>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <memory.h>
#include <set>
#include <ctime>
#include <map>
#include <cstring>
#include <iterator>
#include <queue>
#include <assert.h>
#include <bitset>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <functional>

//#pragma comment(linker, "/STACK:512000000")

using namespace std;

#define pb emplace_back
#define mp make_pair
#define all(a) (a).begin(), (a).end()
#define forn(i, n) for (int i = 0; i < (n); ++i)
#define forab(i, a, b) for (int i = (a); i < (b); ++i)

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int infi = 1e9 + 7;
const ll infl = (ll)1e18 + (ll)7;

int dsu[100500];
ll sum[100500];
ll ar[100500];
vector<pair<ll, pii> > edges;
int find(int v) {
    if (v == dsu[v])
        return v;
    return dsu[v] = find(dsu[v]);
}
void merge(int a, int b) {
    a = find(a), b = find(b);
    if (a == b)
        return;
    dsu[b] = a;
    sum[a] += sum[b];
}
vector<vector<pii> > g;
int used[100500];
int dfs(int v, int w) {
    if (used[v])
        return 0;
    used[v] = 1;
    int ans = 0;
    for (auto e : g[v]) {
        if (e.second > w)
            continue;
        ans += dfs(e.first, w) + 1;
    }
    return ans;
}

int32_t main() {
    cin.sync_with_stdio(false);
    cin.tie(0);
    //srand(time(NULL));
   // freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
    //freopen("customs.in", "r", stdin); freopen("customs.out", "w", stdout);
    int n, m;
    cin >> n >> m;
    g.resize(n);
    forn(i, n)
        cin >> ar[i];
    forn(i, m) {
        int u, v;
        ll w;
        cin >> u >> v >> w;
        --u, --v;
        edges.push_back({ w, { u, v } });
        g[u].pb(v, w);
        g[v].pb(u, w);
    }
    sort(all(edges));
    forn(i, n)
        dsu[i] = i, sum[i] = ar[i];
    vector<pair<ll, pii> > good;
    for (auto e : edges) {
        int u = e.second.first, v = e.second.second;
        u = find(u), v = find(v);
        if (u == v) {
            if (sum[u] >= e.first)
                good.pb(e);
        } else {
            if (sum[u] + sum[v] >= e.first)
                good.pb(e);
            merge(u, v);
        }
    }
    reverse(all(good));
    int ans = m * 2;
    for (auto e : good) {
   //     cout << e.second.first + 1 << ' ' << e.second.second + 1<< '\n';
        ans -= dfs(e.second.first, e.first);
    }
    cout << ans  / 2<< '\n';

    return 0;
}

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

int main(){
    string s;
    cin >> s;
    int n = s.length();
    rep(i,n){
        if((i+1) %2 == 0 && s[i] == 'R'){
            puts("No");
            return 0;
        }
        if((i+1) %2 == 1 && s[i] == 'L'){
            puts("No");
            return 0;
        }
    }
    puts("Yes");
    return 0;
}


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

int main()
{
	int n;
	while(cin >> n && n)
	{
		int ans = 0;
		while((n/5) != 0)
		{
			n /= 5;
			ans += n;
		}

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

Measured memory_bytes: 1160
// while( !(succeed == try()) );

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

// Alpha // Alpha // Alpha // Alpha // Alpha // Alpha // Alpha // Alpha // Alpha // Alpha


#define int long long int
#define loop(i,s,e) for(int i=s; i<e; i++)
#define endl '\n'
#define vii vector<int>
#define pii pair<int, int>
#define ff first
#define ss second
#define N 100001
#define pb push_back
#define INF LLONG_MAX
#define inf INT_MAX

void INP();

#define bug(...)        __f (#__VA_ARGS__, __VA_ARGS__)
#define rtn                                       if(0)return;
template <typename Arg1>
void __f (const char* name, Arg1&& arg1) { rtn cout << name << " : " << arg1 << endl; }
template <typename Arg1, typename... Args>
void __f (const char* names, Arg1&& arg1, Args&&... args)
{     rtn 
     const char* comma = strchr (names + 1, ',');
     cout.write (names, comma - names) << " : " << arg1 << " | "; __f (comma + 1, args...);
}

// Alpha // Alpha // Alpha // Alpha // Alpha // Alpha // Alpha // Alpha // Alpha // Alpha


void alpha()
{	
	int n, m;
	cin>>n>>m;

	int arr[n];
	int total = 0;
	loop(i,0,n) {
		cin>>arr[i];
		total += arr[i];
	}

	sort(arr, arr+n, greater<int>());

	loop(i,0,n){
		if(i<m and arr[i] < (1.0*total)/(4*m)){
			cout<<"No"<<endl;
			return;
		}
		if(i>=m-1){
			cout<<"Yes"<<endl;
			return;
		}
	}
}

int32_t main(){

	ios_base:: sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	//INP();
    int t=1;
	//cin>>t;

  	while(t--) alpha();

	return 0;

}






















inline void INP()
{
      #ifndef ONLINE_JUDGE
          freopen("input.txt",  "r",  stdin);
          freopen("output.txt", "w", stdout);
      #endif
}
 
 

Measured memory_bytes: 256
n = int(input())
if n <= 9:
  print(n)
else:
  if n <= 99:
    print(9)
  else:
    if n <= 999:
      print(n - 90)
    else:
      if n <= 9999:
        print(909)
      else:
        if n <= 99999:
          print(n - 9090)
        else:
          print(90909)

Measured memory_bytes: 3060
#include<stdio.h>
#define N 10000

int main(void){
  int i,num,j;
  int n,s[N];

  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&s[i]);
  }
  for(i=0;i<n;i++){
    printf("Case %d:\n",i+1);
    for(j=0;j<10;j++){
      s[i]*=s[i];
      s[i]%=1000000;
      s[i]/=100;
      printf("%d\n",s[i]);
    }
  }
  return 0;
}

Measured memory_bytes: 0
import scala.util.control.Breaks

object Main extends App {
  val n = scala.io.StdIn.readInt()
  val a = scala.io.StdIn.readLine()
  val aArray = a.split(" ").map(_.toLong).toVector
  val sum = aArray.sum
  val sumCenter = aArray.sum / 2L

  var index = 0L
  var lowerSum = 0L
  var result = 0L

  val b = new Breaks
  b.breakable {
    (0 to n - 1).foreach { i =>
      val tempSum = lowerSum + aArray(i)
      if (tempSum > sumCenter) {
        val lower = (sum - lowerSum) - lowerSum
        val upper = tempSum - (sum - tempSum)
        if (lower < upper) {
          result = lower
        } else {
          result = upper
        }
        b.break()
      } else {
        lowerSum = tempSum
      }
    }
  }
  println(result)

}

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

using namespace std;

typedef long long LL;

const int NN = 205;

LL c[NN][NN];

void init(){
	c[0][0] = 1;
	for(int i = 1; i<NN; i++){
		c[i][0] = c[i][i] = 1;
	}
	for(int i = 2; i < NN; i++){
		for(int j = 1 ; j<i; j++){
			c[i][j] = c[i - 1][j] + c[i - 1][j - 1];
		}
	}
}

int main(){
	init();
	int n, k;
	scanf("%d%d",&n,&k);
	LL ans = (n + 1) / 2;
	for(int i = 1; (i * k + (i - 1)) <= n; i++ ){
		LL t = (n - (i * k + (i - 1))) / 2;
		LL tt = 1;
		for(int j = 1; j<=t; j++){
			tt += c[j + i + 1 - 1][j];
		}
		ans += tt;
	}
	printf("%lld\n", ans);
	return 0;
}



Measured memory_bytes: 3548
#include<iostream>
using namespace std;
int main(){
    int N, K;
    string S;
    int count_one, count_zero;
    int num, before_num, nums_i;
    int before, new_before,max;
    int nums[100000];
    cin >> N >> K;
    count_one =0;
    count_zero = 0;
    nums_i =0;
    cin >> S;
    for(int i=0; i<N; i++){
        num = S[i]-'0';
        if(i == 0){
            if(num == 0){
                before_num =0;
                count_zero++;
                nums[0]=0;
                nums_i++ ;
            }
            if(num == 1){
                before_num =1;
                count_one++;
            }
        }
        else if(num ==0 && before_num == 0){
            count_zero++;
            before_num = num;
        }
        else if(num ==1 && before_num == 1){
            count_one++;
            before_num = num;
        }
        else if(num ==1 && before_num == 0){
            nums[nums_i]=count_zero;
            nums_i++;
            count_zero =0;
            count_one =1;
            before_num = 1;
        }
        else if(num ==0 && before_num == 1){
            nums[nums_i]=count_one;
            nums_i++;
            count_one =0;
            count_zero =1;
            before_num = 0;
        }
        if(i == N-1 && num == 0){
            nums[nums_i] = count_zero;
            nums_i++;
            nums[nums_i]=0;
            nums_i++;
        }
        else if(i == N-1 && num==1){
            nums[nums_i] = count_one;
            nums_i++;
        }
        
    }
    
    if((nums_i-1)/2 <=K){
        cout << N << endl;
        return 0;
    }
    before = 0;
    for(int i=0; i<K+K+1; i++){
        before += nums[i];
    }
    max = before;
    for(int i=0; i<nums_i-(K+K+1+1); i+=2){
       new_before = before - nums[i]- nums[i+1] + nums[i+K+K+1] + nums[i+1+K+K+1];
       if(max < new_before){
           max = new_before;
       }
       before = new_before;
    }
    cout << max << endl;
    return 0;
}

Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
int main(void) {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  
  int n;
  cin >> n;
  
  int vec[200002];
  int mm[200002]{};
  multiset<int> map;
  
  int max = -1;
  for (int i = 0; i < n; ++i) {
    int a;
    cin >> a;
    vec[i] = a;
    map.insert(a);
    if (a > max) max = a;
    
    mm[a]++;
  }
  
  int pm;
  if (n == 1) pm = max;
  else pm = *(++map.rbegin());
  
  for (int i = 0; i < n; ++i) {
    int key = vec[i];
    if (key < max) {
      cout << max << endl;
    }
    else if (mm[key] > 1) {
      cout << key << endl;
    }
    else {
      cout << pm << endl;
    }
  }
  
  return 0;
}

Measured memory_bytes: 12544
#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e6;
typedef long long LL;
char s[maxn];
char tmp[maxn];
void solve()
{
    //ios::sync_with_stdio(false);
   LL N,A,B;
   cin >> N >> A >> B;
   if(A==0&&B==0)
   {
       printf("0\n");
       return ;
   }
   LL d = N/(A+B);
   N%=(A+B);
   N = min(A,N);
 // N = max(N,(LL)0);
   cout << d*A+N << "\n";
}
int main()
{
    solve();
    return 0;
}


Measured memory_bytes: 256
<?php

$args = [];
while(true){
	$input = explode(' ', trim(fgets(STDIN)));
	foreach ($input as $value) {
		if (!empty($value)) {
			$args[] = $value;
		}
		if (count($args) >= 3) {
			break;
		}
	}
	if (count($args) >= 3) {
		break;
	}
}


sort($args);
$check = [5,5,7];
for ($i=0; $i < 3; $i++) { 
	if ($args[$i] == $check[$i]) {
		continue;
	}else{
		echo 'NO';
		exit(0);
	}
}
echo 'YES';

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

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

using std::cin;
using std::cout;
using std::endl;
using std::string;
using std::vector;

int main() {
  int n, m;
  cin >> n >> m;

  cout << (n - 1) * (m - 1) << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define pii pair<int,int>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(c) (c).begin(),(c).end()
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define MINF(a) memset(a,0x3f,sizeof(a))
#define POW(n) (1LL<<(n))
#define IN(i,a,b) (a <= i && i <= b)
using namespace std;
template <typename T> inline bool CHMIN(T& a,T b) { if(a>b) { a=b; return 1; } return 0; }
template <typename T> inline bool CHMAX(T& a,T b) { if(a<b) { a=b; return 1; } return 0; }
template <typename T> inline void SORT(T& a) { sort(ALL(a)); }
template <typename T> inline void REV(T& a) { reverse(ALL(a)); }
template <typename T> inline void UNI(T& a) { sort(ALL(a)); a.erase(unique(ALL(a)),a.end()); }
const int MOD = 1000000007;
const int INF = 0x3f3f3f3f3f3f3f3f;
const double EPS = 1e-10;
/* ---------------------------------------------------------------------------------------------------- */

int N,M;
int x[100010];
int dp[100010];

signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);

  cin >> N >> M;
  REP(i,M) {
    int a;
    cin >> a;
    x[a] = 1;
  }
  dp[0] = 1;
  FOR(i,1,N+1) {
    if (x[i] == 1) continue;
    (dp[i] += (dp[i-1] + dp[i-2]) % MOD) %= MOD;
  }
  cout << dp[N] << endl;

  return 0;
}

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

int solve(){
    int n, w;
    cin >> n >> w;
    if(n == 0) return 1;
    vector<int> v(n), h;
    for(int i=0;i<n;i++){
        cin >> v[i];
    }
    sort(v.begin(), v.end());
    int maxi = 0, sum = 0;
    for(int i=0,j=1;i<n;j++){
        int cnt = 0;
        while(i<n && v[i]<w*j){
            cnt++;
            i++;
        }
        maxi = max(maxi, cnt);
        h.push_back(cnt);
    }
    double ans = 0.0;
    int m = h.size();
    for(int i=0;i<m-1;i++){
        ans += double(h[i])/maxi*(m-i-1)/(m-1);
    }
    ans += 0.01;
    printf("%.8lf\n",ans);
    return 0;
}

int main(){
    while(solve()==0);
    return 0;
}


Measured memory_bytes: 3096
#include<iostream>
using namespace std;
#include<cmath>
#define int long long int
int32_t main()
{
    int h,w;
    cin>>h>>w;
    if(h==1||w==1)
         cout<<1<<endl;
    else
    {
		int answer=h*w;
		answer=ceil((double)(answer)/2.0);
		cout<<answer<<endl;
	}
}


Measured memory_bytes: 256
#include <stdio.h>
int main()
{
  int N, A[100], i, j, v, con=0, k;
  
  scanf("%d", &N);
  for(i = 0; i < N; i++)
    scanf("%d", &A[i]);

  for(i = 0; i < N-1; i++)
    printf("%d ", A[i]);
  printf("%d\n", A[N-1]);
  
  for(i = 1; i <= N-1; i++){
    v = A[i];
    j = i-1;

    while(j >= 0 && A[j] > v){
	A[j+1] = A[j];
	j--;
      }
    A[j+1] = v;

    for(k = 0; k < N-1; k++)
      printf("%d ", A[k]);
    printf("%d\n", A[N-1]);
  }
  return 0;
}

Measured memory_bytes: 600
import scala.io.Source.stdin

object Main {
  val r = Array(2,3,5,7)

  def twoPow(d:Int,s:Int):(Int,Int) = {
    if(d%2 == 1) (d,s)
    else twoPow(d>>1,s+1)
  }

  def maybePrime(i:Int,d:Int,s:Int, n:Int):Boolean = {
    if(i>3) true
    else {
      val a = r(i)
      val x = BigInt(a).modPow(d,n).toLong

      if(x==1 || x==n-1) maybePrime(i+1,d,s,n)
      else repeat(s-1,BigInt(x).modPow(2,n).toLong, i, d, s, n)
    }
  }

  def repeat(j:Int, x:Long, i:Int, d:Int, s:Int, n:Int):Boolean = {
    if(j==0) false
    else if(x==1) false
    else if(x==n-1) maybePrime(i+1,d,s,n)
    else repeat(j-1,BigInt(x).modPow(2,n).toLong,i,d,s,n)
  }

  def isPrime(n:Int):Boolean = {
    if(n==2 || n==3 || n==5 || n==7) true
    else if(n%2==0) false
    else {
      val (d,s) = twoPow(n-1,0)
      maybePrime(0,d,s,n)
    }
  }

  def main(args:Array[String]) = {
    println(stdin.getLines.count{ x => isPrime(x.toInt) })
  }
}

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

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n;
  cin >> n;
  map<int, int> cnt;
  long long res = 0;
  for (int i = 1; i <= n; i++) {
    int foo;
    cin >> foo;
    res += cnt [ -foo + i ];
    cnt[ foo + i ]++;
  }
  cout << res << '\n';
  return 0;
}


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

int main()
{
	int n;
	cin >> n;
	int *a = new int[n];
	int sum = 0;
	for (int i = 0; i < n; ++i)
		cin >> a[i];
	for (int i = 1; i < n-1; ++i)
	{
		if (a[i] > a[i - 1] && a[i] < a[i + 1] || a[i] < a[i - 1] && a[i] > a[i + 1])
			sum++;
	}
	cout << sum;
	return 0;
}

Measured memory_bytes: 256
n,m=[int(i) for i in input().split()]
py=[[int(i) for i in input().split()]+[_,""] for _ in range(m)]
kazu=[0]*(n+1)
py.sort(key=lambda x:x[1])
for i in range(m):
    kazu[py[i][0]]+=1
    py[i][3]+=str(kazu[py[i][0]])
py.sort(key=lambda x:x[2])
for i in range(m):
    print(str(py[i][0]).zfill(6)+py[i][3].zfill(6))

Measured memory_bytes: 85720
#include <iostream>
#include <string.h>
#include <vector>
#include <algorithm>
#include <cmath>
#include <map>
#include <functional>
#include <cassert>
#include <utility>
#include <stack>
#include <queue>
using namespace std;
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,n1,n2) for(int i=n1;i<n2;i++)
typedef long long ll;
typedef pair<int,int> Pii;
const int INF=(1<<30)-1;
const ll INFl=9223372036854775807;
const int MAX=310;
const int MOD=1000000007;
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a/gcd(a, b)*b;}

int main(){
	int n,k;
	cin>>n>>k;
	ll x[n],y[n];
	for(int i=0;i<n;i++)
		cin>>x[i]>>y[i];
	ll ans=INFl;
	for(int i=0;i<n-1;i++){
		
		for(int j=i+1;j<n;j++){
			for(int q=0;q<n-1;q++){
				for(int r=0;r<n;r++){
					int count=0;
					ll x1=x[i],x2=x[j];
					ll y1=y[q],y2=y[r];
					if(x1>x2) swap(x1,x2);
					if(y1>y2) swap(y1,y2);
					for(int l=0;l<n;l++){
						if(x1<=x[l]&&x[l]<=x2)
							if(y1<=y[l]&&y[l]<=y2)
								count++;
					}
				if(count>=k)ans=min(ans,(x2-x1)*(y2-y1));
				}
			}
		}
	}
	cout<<ans<<endl;
}

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

int main() {
  int s,s1,s2,s3;
  cin >> s;
  s3 = s%2;
  s2 = (s-s3)%20/10;
  s1 = (s-s3-s2*10)/100;
  cout << s1+s2+s3 << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <array>
using namespace std;
typedef long long ll;

int N, M;
const ll mod = 1000000007;

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

    cin >> N >> M;

    if(N > M){
        swap(N, M);
    }
    if(N == M - 1){
        ll ans = 1;
        for(int i = N; i >= 1; --i){
            ans *= i;
            ans %= mod;
        }
        for(int i = M; i >= 1; --i){
            ans *= i;
            ans %= mod;
        }
        cout << ans << endl;
    }
    else if(N == M){
        ll ans = 1;
        for(int i = N; i >= 1; --i){
            ans *= i;
            ans %= mod;
        }
        for(int i = N; i >= 1; --i){
            ans *= i;
            ans %= mod;
        }
        ans *= 2;
        ans %= mod;
        cout << ans << endl;
    }
    else {
        cout << 0 << endl;
    }

    return 0;
}

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

int main (){

   int x;
   cin >> x;

   for(long long int i = -150; i<= 150; i++){
       for (long long int j = -150; j<= 150; j++){
           if(i*i*i*i*i - j*j*j*j*j == x){
               cout << i << " " << j << endl;
               return 0;
           } 
       }
   }
    
}


Measured memory_bytes: 3596
#include<bits/stdc++.h>
using namespace std;
const int inf=1005,mo=1000000007;
bool b[inf][inf];
int n,m,a[inf][inf];
char tmp;
int main(){
	cin>>n>>m;
	for(int i=1;i<=n;i++){
		for(int j=1;j<=m;j++){
			cin>>tmp;
			if(tmp=='#') b[i][j]=1;
		}
	}
	a[0][1]=1;
	for(int i=1;i<=n;i++){
		for(int j=1;j<=m;j++){
			if(b[i][j]) continue;
			a[i][j]=(a[i][j-1]+a[i-1][j])%mo;
		}
	}
	cout<<a[n][m]<<endl;
	return 0;
}


Measured memory_bytes: 5120
h, w = gets.split.map(&:to_i)
a = h.times.map{ gets.split("") }

hei, wid = [], []

a.each_with_index{ |x, y| wid.push(y) if x.count(".") == w }

w.times do |i|
    hoge = 1
    a.each{ |j| hoge = 0 if j[i] == "#" }
    hei.push(i) if hoge == 1
end

h.times do |i|
    w.times{ |j| print a[i][j] if !hei.include?(j) && !wid.include?(i) }
    puts "\n" if !wid.include?(i)
end

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

int main() {
  
  int t,A,B;
  cin >> t >> A >> B;
  
  int prA = t * A, prB = B;
  
  if (prA >= prB) {
    cout << prB << endl;
  }
  
  else cout << prA << endl;
  
} 

Measured memory_bytes: 3600
#include <stdio.h>
#include <string>
#include <iostream>
#include <map>
#include <algorithm>
using namespace std;

int main() {
    string s1, s2, s3;
    cin >> s1 >> s2 >> s3;
    cout << (char)toupper(s1[0]);
    cout << (char)toupper(s2[0]);
    cout << (char)toupper(s3[0]);
    cout << endl;
 
    return 0;
}

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

using namespace std;

#define REP(i,m) for(int i=0; i<m; i++)
#define FOR(i,n,m) for(int i=n; i<m; i++)
#define INF 1000000007
#define INFL (1LL << 60)
#define MOD 998244353
#define ALL(v) v.begin(),v.end()
#define pb push_back
#define ll long long int
#define P pair<ll, ll>

int main(){
	while(true){
		int x;
		cin >> x;
		if(x==0) break;
		x = 1000-x;
		int ans = 0;
		ans += x/500;
		x %= 500;
		ans += x/100;
		x %= 100;
		ans += x/50;
		x %= 50;
		ans += x/10;
		x %= 10;
		ans += x/5;
		x %= 5;
		ans += x;
		cout << ans << endl;
	}
	return 0;
} 


Measured memory_bytes: 3056
//https://atcoder.jp/contests/agc011/tasks/agc011_b
#include <bits/stdc++.h>
using namespace std;
using ll=int64_t;
#define FOR(i,a,b) for(int64_t i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
int main() {
    ll N;cin>>N;
    vector<ll> an(N);
    for(auto&& a:an){
        cin>>a;
    }
    sort(an.begin(), an.end());
    //sortして累積和
    ll sum=0;
    vector<ll> sumtbl(N);
    REP(i,N){
        sum+=an[i];
        sumtbl.at(i)=sum;
    }
    //後ろから
    ll ans=1; //終端はok
    for(ll i=N-2; i>=0; --i){
        if (sumtbl[i]*2>=an[i+1]){
			++ans;
		} else {
            break;
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 1792
n, k = map(int, input().split())
ret = 0.0
p = 1.0
r = n + 1
while True:
    num = r - min(r, k)
    ret += num * p
    r   -= num
    if k == 1:
        break
    k = (k + 1) // 2
    p = p * 0.5
print(ret / n)


Measured memory_bytes: 3060