akhauriyash/Code-Regression huggingface dataset:
/**
 *    Coded by : lucky_21
 *               --------Lokesh Singh
**/

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

#include<ext/pb_ds/tree_policy.hpp>
#include<ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
template<class T> using oset=tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;

#define     F           first
#define     S           second
#define     pb          push_back
#define     lb          lower_bound
#define     ub          upper_bound
#define     pii         pair<int,int>
#define     all(x)      x.begin(),x.end()
#define     fix         fixed<<setprecision(10)
#define     setbits(x)  __builtin_popcountll(x)
#define     rep(i,a,b)  for(int i=int(a);i<=int(b);i++)
#define     repb(i,b,a) for(int i=int(b);i>=int(a);i--)
#define     FastIO      ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)

typedef double db;
typedef long long ll;

const int N=2e5+5;
const int mod=1e9+7;

signed main(){
    FastIO;
    ll n,a,b;
    cin>>n>>a>>b;
    cout<<n/(a+b)*a+min(a,n%(a+b));
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll; //10^19 < 9223372036854775807
typedef unsigned long long ull; //10^20 < 18446744073709551615

#define REP(i,n) for(ll i=0;i<ll(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=ll(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=ll(b);i--)
#define FORA(i,I) for(const auto& i:I)
#define ALL(x) x.begin(),x.end() 
#define SIZE(x) ll(x.size()) 

#define MOD 1000000007

int main(void)
{
    int A,B,C,D;
    cin >> A >> B >> C >> D;

    while (1) {
        C -= B;
        if (C <= 0) {
            cout << "Yes" << endl;
            break;
        }

        A -= D;
        if (A <= 0) {
            cout << "No" << endl;
            break;
        }

    }

    return 0;
}


Measured memory_bytes: 3540
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip> 
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <bitset>

using namespace std;


#define PI 3.1415926535897

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

	vector<int> a(3);
	int ans;
	cin >> a[0] >> a[1] >> a[2];
	sort(a.rbegin(), a.rend());
	ans = a[0] * 10 + a[1] + a[2];
	cout << ans << "\n";

	return 0;
}


Measured memory_bytes: 384
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#define LL long long

using namespace std;
const int MAXN=101;
int n,m;
int a[MAXN];
int main()
{
	scanf("%d",&n);
	scanf("%d",&m);
	
	for(int i=1;i<=n;i++)scanf("%d",a+i);
	
	sort(a+1,a+n+1);
	
	int ans=0;
	
	for(int i=1;i<=n;i++)
	{
		if(m>=a[i])
		{
			ans++;
			m-=a[i];
		}
		if(m==0)
		{
			break;
		}
	}
	if(ans == n && m != 0) ans--;
	if(ans<0)ans=0;
	printf("%d\n",ans);
	
	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define ALL(x) (x).begin(),(x).end() 
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define INF 1000000000
using namespace std;
typedef long long ll;
ll mod = 1e+9 + 7;

int main(){
    int H, W, K;
    bool flag = true;
    cin >> H >> W >> K;

    vector<vector<char>> c(H, vector<char>(W));
    REP(i, H){
        REP(j, W){
            cin >> c[i][j];
        }
    }

    int ans = 0, res = 0;
    for (int bith = 0; bith < (1 << H); ++bith) {
        for (int bitw = 0; bitw < (1 << W); ++bitw) {
            res = 0;
            REP(i, H) {
                REP(j, W){
                    if (bith & (1<<i) and bitw & (1<<j)) {
                        if(c[i][j] == '#')res++;
                    }
                }
            }

            if(res == K) ans++;
        }
    }
    cout << ans << endl;

    return 0;
}


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

#define SZ(a) int((a).size())
#define _REP(_1,_2,_3,_4,name,...) name
#define _REP4(i,b,e,s) for(decltype(e) _b=(b),_e=(e),i=_b+(0<(s)?0:(s));(0<(s)?i<_e:_e<=i);i+=(s))
#define _REP3(i,b,e) for(decltype(e) _b=(b),_e=(e),i=(_b<_e?_b:_b-1);(_b<_e?i<_e:_e<=i);(_b<_e?i++:i--))
#define _REP2(i,n) for(decltype(n) i=0,_n=(n);i<_n;i++)
#define _REP1(n) for(decltype(n) _i=0,_n=(n);_i<_n;_i++)
#define REP(...) _REP(__VA_ARGS__,_REP4,_REP3,_REP2,_REP1)(__VA_ARGS__)
#define INT(n) int n;assert(0<scanf("%d",&n))
#define VI(v,n) vector<int> v(n);REP(i,n){assert(0<scanf("%d",&v[i]));}

int main(){
  int ans = 0;
  INT(n); VI(as, n);
  map<int, int> mp;
  for(int a: as){mp[a] += 1;}
  if (mp[1] == 1){ans++;}
  for(int a: as){
    if (0 < mp[1]){continue;}
    if (1 < mp[a]){continue;}
    bool ok = true;
    REP(i, 2, a){
      if (a < i*i){break;}
      if (a % i == 0 && 0 < mp[i]){ok = false; break;}
      if (a % i == 0 && 0 < mp[a / i]){ok = false; break;}
    }
    if (ok){ans++;}
  }
  printf("%d\n", ans);
  return 0;
}

Measured memory_bytes: 32932
#include <iostream>
#include <limits.h>
using namespace std;

int main() {
	unsigned long long n, k;
	cin >> n >> k;
    if (k % 2 != 0) cout << (n / k)*(n / k)*(n / k);
    else cout << (n / k)*(n / k)*(n / k)+(n / (k/2) - n / k)*(n / (k/2) - n / k)*(n / (k/2) - n / k) ;
	return 0;
}


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

int main(){
  int n;
  int A, B, C;
  int t[102];

  while(cin >> n >> A >> B >> C){
    for(int i = 0; i < n; i++){
      cin >> t[i];
    }
    sort(t, t + n, greater<int>());

    int maxCal = C / A;
    int sumCal = C;

    for(int i = 0; i < n; i++){
      sumCal += t[i];
      maxCal = max(maxCal, sumCal / (A + (i + 1) * B));
    }

    cout << maxCal << endl;
  }
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const ll MOD = 1e9+7;
ll dp[1010][1010];
int main(){
  ll n,k;
  cin>>n>>k;
  if(n<k){
	cout<<0<<endl;
	return 0;
  }
  dp[0][0]=1;
  for(int i=1;i<=n;i++){
	for(int j=1;j<=k;j++){            
	  dp[i][j]+=dp[i-1][j-1];
	  if(i>=j)dp[i][j]+=dp[i-j][j];       
	  dp[i][j]%=MOD; 
	}
  }
  cout<<dp[n][k]<<endl;
  return 0;
}



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

int main(int argc, char *argv[]) { ios::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);


  ld a,b;cin>>a>>b;
  ll ans=floor(a*b);
  cout<<ans<<endl;
  
  return 0;
}


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

int main() {
  int H, W;
  cin >> H >> W;
  vector<string> A(H);
  for (int i = 0; i < H; i++) {
		cin >> A.at(i);
  }

	vector<vector<string>> result(H, vector<string>(W));

	// 行
  for (int i = 0; i < H; i++) {
		int cnt = 0;
	  for (int j = 0; j < W; j++) {
		  result.at(i).at(j) = A.at(i).at(j);
			if(A.at(i).at(j) == '.') cnt++;
  	}
		if(cnt == W){
			for (int j = 0; j < W; j++) {
		  	result.at(i).at(j) = "-";
			}
		}
  }

	// 列
	for (int j = 0; j < W; j++) {
		int cnt = 0;
	  for (int i = 0; i < H; i++){
			if(A.at(i).at(j) == '.') cnt++;
		}
		if(cnt == H){
			for (int i = 0; i < H; i++){
		  	result.at(i).at(j) = "-";
			}
		}
	}

	// 出力
  for (int i = 0; i < H; i++) {
		int cnt = 0;
	  for (int j = 0; j < W; j++) {
			if(result.at(i).at(j) != "-"){
				cout << result.at(i).at(j);
			} else {
				cnt++;
			}
  	}
		if(cnt != W) cout << endl;
  }
}


Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, pii> pip;
const ll INF = 1e9+100;
const ll MOD = 1e9;
const double EPS = 1e-10;
const bool debug = 0;
//------------------------------//

int main() {
	string s;
	cin >> s;
	cout << s.substr(0, s.size() - 8) << endl;
	return 0;
}


Measured memory_bytes: 764
#include<iostream>
#include<vector>

using namespace std;
int main(){
    int n,k;
    cin >> n >> k;
    vector<int> A(n);
    for(int i=0; i<n; i++){
        cin >> A[i];
    }
    //a/b切り上げ： (a + (b - 1)) / b
    cout << 1+((n-k)+((k-1)-1))/(k-1) << endl;
    return 0;
}

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

int b=-2;

int dfs(int n)
{
	int t=n%b;
	n=n/b;
	if(t<0) 
	{
		t-=b;
		n++;
	}
	if(n!=0) 
	{
		dfs(n);
	}
	putchar(t>9?t+55:t+48);
}

int main()
{
	int n;
	cin>>n;
	dfs(n);
}


Measured memory_bytes: 256
import java.util.*;

@SuppressWarnings("unchecked")
public class Main {
	public static class Pair implements Comparable<Pair> {
		public final long first;
		public final long second;
	
		public Pair(long first, long second) {
			this.first = first;
			this.second = second;
		}
	
		@Override
		public int compareTo(Pair o) {
			int ord = Long.compare(this.first, o.first);
			if (ord != 0) return ord;
			ord = Long.compare(this.second, o.second);
			return ord;
		}
	}

	// public static void printArray(int[] a) {
	// 	for (int i = 0; i < a.length; i++) {
	// 		System.out.print(a[i] + ", ");
	// 	}
	// 	System.out.println();
	// }

	// public static<T> void printArrayT(T[] a) {
	// 	for (int i = 0; i < a.length; i++) {
	// 		System.out.print(a[i] + ", ");
	// 	}
	// 	System.out.println();
	// }

	public static String joinInt(int[] a, String separator) {
		StringBuilder sb = new StringBuilder();
		for (int i = 0; i < a.length; i++) {
			if (i > 0) {
				sb.append(separator);
			}
			sb.append(a[i]);
		}
		return sb.toString();		
	}

	static int[] nextIntArray(Scanner sc, int N) {
		int[] arr = new int[N];
		for (int i = 0; i < N; i++) {
			arr[i] = sc.nextInt();
		}
		return arr;
	}

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		ArrayList<Pair>[] edge = new ArrayList[N];
		for (int i = 0; i < N - 1; i++) {
			int a = sc.nextInt() - 1;
			int b = sc.nextInt() - 1;
			long c = sc.nextLong();
			add(edge, a, b, c);
			add(edge, b, a, c);
		}
		int Q = sc.nextInt();
		int K = sc.nextInt() - 1;
		int[] X = new int[Q];
		int[] Y = new int[Q];
		for (int i = 0; i < Q; i++) {
			X[i] = sc.nextInt() - 1;
			Y[i] = sc.nextInt() - 1;
		}
		long[] table = new long[N];
		Arrays.fill(table, Integer.MAX_VALUE);
		PriorityQueue<Pair> q = new PriorityQueue<>();
		q.add(new Pair(0, K));
		while (q.size() > 0) {
			Pair p = q.poll();
			long cost = p.first;
			int pos = (int)p.second;
			if (table[pos] != Integer.MAX_VALUE) continue;

			table[pos] = cost;
			if (edge[pos] != null) {
				for (Pair next : edge[pos]) {
					int nextPos = (int)next.first;
					long nextCost = next.second;
					if (table[nextPos] == Integer.MAX_VALUE) {
						q.add(new Pair(cost + nextCost, nextPos));
					}
				}
			}
		}
		for (int i = 0; i < Q; i++) {
			System.out.println(table[X[i]] + table[Y[i]]);
		}
	}

	static void add(ArrayList<Pair>[] edge, int a, int b, long c) {
		if (edge[a] == null) {
			edge[a] = new ArrayList<>();
		}
		edge[a].add(new Pair(b, c));
	}
}


Measured memory_bytes: 183212
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws IOException {

		// input
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		char[][] f = new char[n][10];
		int[][] p = new int[n][11];
		for (int i = 0; i < n; i++) {
			StringBuffer sb = new StringBuffer();
			for (int j = 0; j < 10; j++) {
				sb.append(in.next());
			}
			f[i] = sb.toString().toCharArray();
		}
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < 11; j++) {
				p[i][j] = in.nextInt();
			}
		}

		// solve
		int pow = 10;
		int num_to = (int) Math.pow(2, pow) - 1;
		List<String> bitList = new ArrayList<>();
		for (int i = num_to; i >= 1; i--) {
			String bin = String
					.format("%" + pow + "s", Integer.toBinaryString(i)).replace(
							' ', '0');
			bitList.add(bin);
		}

		int sum = 0;
		int ans = Integer.MIN_VALUE;
		for (String bits : bitList) {
			char[] bit = bits.toCharArray();
			sum = 0;
			for (int i = 0; i < n; i++) {
				int count = 0;
				for (int j = 0; j < 10; j++) {
					if (f[i][j] == '1' && bit[j] == f[i][j]) {
						count++;
					}
				}
				sum += p[i][count];
			}
			ans = Math.max(ans, sum);
		}
		System.out.println(ans);

	}

}


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


int main(){


    int n, m, k, i, t;

    int ans = 0;


    cin >> n >> m;


    vector<int> a(m + 1);


    for( i = 1 ; i <= n ; i = i + 1 ){

         cin >> k;

         while( 0 < k ){

                cin >> t;

                a.at(t) += 1;

                k -= 1;

                }

         }

    
    for( i = 1 ; i <= m ; i = i + 1 ){

         if( a.at(i) == n ) ans += 1;

         }
 

    cout << ans << endl;

    return 0;

    }


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

#define _p(...) (void)printf(__VA_ARGS__)
#define forr(x,arr) for(auto&& x:arr)
#define _overload3(_1,_2,_3,name,...) name
#define _rep2(i,n) _rep3(i,0,n)
#define _rep3(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,_rep3,_rep2,)(__VA_ARGS__)
#define _rrep2(i,n) _rrep3(i,0,n)
#define _rrep3(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define rrep(...) _overload3(__VA_ARGS__,_rrep3,_rrep2,)(__VA_ARGS__)
#define ALL(x) (x).begin(), (x).end()
#define BIT(n) (1LL<<(n))
#define SZ(x) ((int)(x).size())
#define fst first
#define snd second
typedef vector<int> vi;typedef vector<vi> vvi;typedef pair<int,int> pii;typedef vector<pii> vpii;
typedef long long ll;

void Main() {
  int N;
  scanf("%d", &N);
  vi A(N * 2);
  rep(i, N * 2) scanf("%d", &A[i]);

  sort(ALL(A), greater<int>());

  int ans = 0;
  for (int i = 0; i < SZ(A); i+=2) {
    ans += min(A[i], A[i+1]);
  }
  _p("%d\n", ans);
}
int main() { cin.tie(0); ios::sync_with_stdio(false); Main(); return 0; }


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;
  vector<int> a(n);
  for(int i=0;i<n;i++){
    cin>>a[i];
  }
  sort(a.begin(),a.end());
  cout<<a[n/2]-a[n/2-1]<<endl;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define N 110
using namespace std;
template <typename T> void read(T &x){
	x=0;char ch=getchar();int fh=1;
	while (ch<'0'||ch>'9'){if (ch=='-')fh=-1;ch=getchar();}
	while (ch>='0'&&ch<='9')x=x*10+ch-'0',ch=getchar();
	x*=fh;
}
int n,x,y,ma,nm,an[N];
ll ans=1,no;
vector<int> h[N],ppx,a[N];
void jb(int x,int y){a[x].pb(y);}
void get(int x,int fa,int di,vector<int> s){
	s.pb(x);h[x]=s;
	if (di>ma) {ma=di;nm=x;}
	for (auto y:a[x])if (y!=fa)get(y,x,di+1,s);
	s.pop_back();
}
void dfs(int x,int fa,int di){
	an[di]=max(an[di],(int)a[x].size()-(fa!=0));
	for (auto y:a[x])if (y!=fa)dfs(y,x,di+1);
}
int main(){
	read(n);
	for (int i=1;i<n;i++){read(x);read(y);jb(x,y);jb(y,x);}
	no=1,ma=0,nm=0;get(no,0,0,ppx);
	no=nm;ma=0;nm=0;get(no,0,0,ppx);
	cout<<ma/2+1<<' ';
	if (ma%2==0){
		dfs(h[nm][ma/2],0,0);
		ans=1;
		for (int i=0;i<ma/2;i++)ans*=an[i];
		for(auto x:a[h[nm][ma/2]]){
			no=2;memset(an,0,sizeof(an));
			dfs(h[nm][ma/2],x,0);
			dfs(x,h[nm][ma/2],0);
			for (int i=0;i<ma/2;i++)no*=an[i];
			ans=min(ans,no);
		}
	}else{
		dfs(h[nm][ma/2],h[nm][ma/2+1],0);
		dfs(h[nm][ma/2+1],h[nm][ma/2],0);
		ans=2;
		for (int i=0;i<ma/2;i++)ans*=an[i];
	}
	cout<<ans<<endl;
	return 0;
}

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

  int main() {
    int n, k, x, y;
    
    cin >> n >> k >> x >> y;
    
    if ( n > k)
    	cout << x * k + (n-k) * y << endl; 
    else
      	cout << x * n << endl; 
    
    return 0;
  }

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

n = int(input())
a = list(map(int, input().split()))
memo = [[0, 0] for i in range(n)]
for i, j in enumerate(a):
    memo[i][0] = j
    memo[i][1] = i + 1
memo.sort()
for i in range(n):
    print(memo[i][1], end=' ')
print()


Measured memory_bytes: 21452
#include<math.h>
#include<limits.h>
#include<iostream>
#include<string>
#include<vector>
#include<stdio.h>
#include<sstream>
#include<list>
#include<queue>
#include<algorithm>
#include<functional>
#include<map>
#include<set>
#include<utility>
#include<initializer_list>
#include<tuple>
#include<regex>
using namespace std;
#define ull unsigned long long
#define ll long long
#define rep(i, n) for(int i=0;i<(int)(n);i++)
#define all(t) t.begin(), t.end()


int main() {
	ll n, k;
	cin >> n >> k;
	vector<ll> a(n);
	rep(i, n)cin >> a[i];
	vector<ll> buc(n+1, 0);
	rep(i, n) buc[a[i]]++;
	int nonzero = 0;
	sort(all(buc));
	rep(i, n) {
		if (buc[i] != 0) {
			nonzero = i; break;
		}
	}
	vector<ll> buc2(buc.begin() + nonzero, buc.end());
	int cnt = 0;
	if (buc2.size() > k) {
		int deleting = buc2.size() - k;
		rep(i, deleting) {
			cnt += buc2[i];
		}
	}
	cout << cnt << endl;



	return 0;
}





Measured memory_bytes: 4992
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
const int INF = 1001001001;
const int MOD = 1000000007;
typedef long long ll;

template<typename T> void print(const T & v);


int main() {
    int H, W;
    cin >> H >> W;
    map<char, int> mp;
    rep(i, H){
        rep(j, W){
            char ipt;
            cin >> ipt;
            mp[ipt]++;
        }
    }
    vector<int> numbers;
    for(auto m: mp){
        numbers.push_back(m.second);
    }
    sort(numbers.begin(), numbers.end());
    reverse(numbers.begin(), numbers.end());
    int four = (H / 2) * (W / 2);
    int two = (H % 2) * (W / 2) + (W % 2) * (H / 2);
    int one = (H % 2) * (W % 2);
    int four_mk = 0, two_mk = 0, one_mk = 0;
    for(int i = 0; i < numbers.size(); i++){
        four_mk += numbers[i] / 4;
        numbers[i] %= 4;
        two_mk += numbers[i] / 2;
        numbers[i] %= 2;
        one_mk += numbers[i];
    }

    if(four_mk < four){
        cout << "No" << endl;
        return 0;
    }
    two_mk += (four_mk - four) * 2;
    if(two_mk < two){
        cout << "No" << endl;
        return 0;
    }
    one_mk += (two_mk - two) * 2;
    if(one_mk < one){
        cout << "No" << endl;
        return 0;
    }
    cout << "Yes" << endl;
    return 0;
}






// Use For Debug
template <typename T>
void print(T const & v){
    for(int i = 0; i < v.size(); i++){
        if(i) cout << " ";
        cout << v[i];
    }
    cout << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>

int main(void)
{
	for (;;) {
		int n;
		scanf("%d", &n);
		if (n == 0) {
			break;
		}
		double s[n], a, t, m;
		a = 0.0;
		t = 0.0;
		for (int i = 0; i < n; i++) {
			scanf("%lf", &s[i]);
			t += s[i];
		}
		m = t / (double)n;
		for (int i = 0; i < n; i++) {
			a += pow(s[i] - m, 2.0);
		}
		a = sqrt(a / (double)n);
		printf("%.8lf\n", a);
	}
	return 0;
}



Measured memory_bytes: 2044
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  // Failed to predict input format
  int a[3];
  cin >> a[0] >> a[1] >> a[2];
  sort(a, a + 3);
  cout << a[0] * a[1] / 2 << endl;
  cerr << "Hello" << endl;
  return 0;
}

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

int main(void) {
  int N;
  cin >> N;
  vector<pair<int,int>> X;
  for (int i = 0; i < N; i++) {
    int x;
    cin >> x;
    X.emplace_back(x, i);
  }
  sort(X.begin(), X.end());
  vector<int> rank(N);
  for (int i = 0; i < N; i++) {
    pair<int,int> p = X[i];
    rank[p.second] = i;
  }

  int l = X[N / 2 - 1].first;
  int r = X[N / 2].first;
  cerr << l << " " << r << endl;
  for (int i = 0; i < N; i++) {
    if (rank[i] < N / 2) cout << r << endl;
    else cout << l << endl;
  }


  return 0;
}

Measured memory_bytes: 4592
X,Y,i;
x[12],y[12];
q[9999],t,h,p,ok,c;
char *d="22210/.../01";
main(n)
{
  for(;scanf("%d%d",&X,&Y),X;puts(ok?"OK":"NA")){
    for(ok=t=h=i=!scanf("%d",&n);i++<n;)scanf("%d%d",x+i,y+i);
    for(p=q[t++]=X*10+Y;t!=h&!ok;p=q[h++]){
      c=p/100;
      if(!c||abs(x[c]-p/10%10)<2&abs(y[c]-p%10)<2){
        ok=c++==n;
        for(i=0;i<12;X>=0&X<10&Y>=0&Y<10?q[t++]=c*100+X*10+Y:0)
            X=p/10%10+d[i]-48,Y=p%10+d[11-i++]-48;
      }
    }
  }
}

Measured memory_bytes: 0
#include <stdio.h>

int main(void) {
	char S[114514];
	int a = 0, b = 0;
	int i;
	if (scanf("%114153s", S) != 1) return 1;
	for (i = 0; S[i] != '\0'; i++) {
		if (i % 2 == 0) {
			if (S[i] == '0') a++;
			if (S[i] == '1') b++;
		} else {
			if (S[i] == '1') a++;
			if (S[i] == '0') b++;
		}
	}
	printf("%d\n", a <= b ? a : b);
	return 0;
}


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

using namespace std;

const int MOD = 1000000007;

int main(){
    const int maxSize = 200001;
	vector<long long> inv(maxSize);
	vector<long long> fact(maxSize);
	vector<long long> factInv(maxSize);
	for(int i=0;i<2;i++) inv[i] = fact[i] = factInv[i] = 1;
	for(int i=2;i<maxSize;i++){
		inv[i] = inv[MOD % i] * (MOD - MOD / i) % MOD;
		fact[i] = fact[i-1] * i % MOD;
		factInv[i] = factInv[i-1] * inv[i] % MOD;
	}
    int N, X, Y;
    while(cin >> N >> X >> Y){
        vector<vector<int>> w(N);
        int low1 = MOD, low2 = MOD, lowIdx = -1;
        for(int i=0;i<N;i++){
            int a, b; cin >> a >> b;
            w[a-1].push_back(b);
            if(b < low1){
                low2 = low1; low1 = b; lowIdx = a-1;
            } else if(b < low2){
                low2 = b;
            }
        }
        long long res = 1;
        int cnt = 0;
        for(int i=0;i<N;i++){
            if(w[i].empty()) continue;
            int m = *min_element(w[i].begin(), w[i].end());
            int lowest = (i == lowIdx ? low2 : low1);
            if(lowest + m > Y) continue;
            int l = count_if(w[i].begin(), w[i].end(), [&](int t){ return m+t <= X || lowest+t <= Y; });
            res = (res * factInv[l]) % MOD;
            cnt += l;
        }
        res = (res * fact[cnt]) % MOD;
        cout << res << endl;
    }
}

Measured memory_bytes: 13952
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const double EPS=1e-6;
const double PI=acos(-1.0);
int ABS(int a){return max(a,-a);}
long long ABS(long long a){return max(a,-a);}
char in[100000];
int main(){
	int a;scanf("%d",&a);printf("ABC%d\n",a);
}

Measured memory_bytes: 128
N, K = map(int, input().split())
A = [int(i) for i in input().split()]
mod = 10**9 + 7

list_size = 10**5 + 1
 
f_list = [1] * list_size
f_r_list = [1] * list_size
 
for i in range(list_size-1):
	f_list[i+1] = (f_list[i] * (i+1)) % mod
 
f_r_list[-1] = pow(f_list[-1], mod - 2, mod)
 
for i in range(list_size-2, -1, -1):
	f_r_list[i] = (f_r_list[i+1] * (i+1)) % mod
 
def comb(n, r, mod):
	if n < r or r < 0:
		return 0
	elif n == 0 or r == 0 or n == r:
		return 1
	else:
		return (f_list[n] * f_r_list[n-r] * f_r_list[r]) % mod

A.sort()
ans = 0
for i, a in enumerate(A, start=1):
    if i <= N-K+1:
        ans -= (a * comb(N-i, K-1, mod))%mod
ans %= mod

A.sort(reverse=True)

for i, a in enumerate(A, start=1):
    if i <= N-K+1:
        ans += (a * comb(N-i, K-1, mod))%mod
ans %= mod
print(ans)


Measured memory_bytes: 21080
package main

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

var scanner = bufio.NewScanner(os.Stdin)

func init() {
	scanner.Split(bufio.ScanWords)
}

func ScanInt() int {
	scanner.Scan()
	t := scanner.Text()
	n, _ := strconv.Atoi(t)
	return n
}

func main() {
	n := ScanInt()
	k := ScanInt()
	hs := make([]int, n)
	for i := 0; i < n; i++ {
		hs[i] = ScanInt()
	}
	sort.Ints(hs)

	min := math.MaxInt32
	for i := 0; i <= n-k; i++ {
		if v := hs[i+k-1] - hs[i]; v < min {
			min = v
		}
	}
	fmt.Println(min)
}


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

int main() {
  int n; cin>>n;
  vector<ll> v(n);
  ll sum= 0;
  rep(i,n){cin>>v[i]; sum+=v[i];}
  ll s= v[0],ans=abs(sum-2*v[0]);
  for(int i=1; i<n-1; i++){
    s+=v[i];
    ans=min(abs(sum-s*2),ans);
  }
  cout<<ans;
}

Measured memory_bytes: 4824
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <math.h>
#include <string>
#include <numeric>
#define ll long long
#define rep(i,n) for(ll i=0;i<n;++i)
#define rep1(i,n) for(ll i=1;i<n;++i)
#define mrep(i,n) for(ll i=n;i>=0;--i)
#define all(a) (a).begin(),(a).end()
#define vl vector<ll>
#define vvl vector<vector<ll> >
#define vb vector<bool>
#define vvb vector<vector<bool> >
#define pl pair<ll,ll>
#define inf 1001001001001000
#define mod 1000000007
#define pi 3.1415926535
using namespace std;

int main(void){
    string s;
    cin>>s;
    if(s[2]==s[3] && s[4]==s[5]){
        cout<<"Yes"<<endl;
    }
    else cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void){
	int a, b[100], c, i;
	scanf("%d", &a);
	for(i=0;i<a;i++){
		scanf("%d", &c);
		b[i] = c;
	}
	for(i=a-1;i>0;i--){
		printf("%d ", b[i]);
	}
	printf("%d\n", b[0]);
	return 0;
}

Measured memory_bytes: 596
a, b, c = map(int, input().split())

ans = 0
while a%2 == 0 and b%2 == 0 and c%2 == 0:
    if a == b == c:
        ans = -1
        break

    a, b, c = int(b/2)+int(c/2), int(a/2)+int(c/2), int(a/2)+int(b/2)
    ans += 1

print(ans)


Measured memory_bytes: 3060
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import java.util.Queue;
import java.util.Scanner;
 

//result = Math.pow(num1, num3)
//StringBuffer str = new StringBuffer(hoge1);
//String hoge2 = str.reverse().toString();
//map.containsKey(A)

//Map<String, Integer> map = new HashMap<String, Integer>(n);
/*for ( キーのデータ型 key : マップの名前.keySet() ) {
	データのデータ型 data = マップの名前.get( key );
	
	// keyやdataを使った処理;
}*/
//int i = Integer.parseInt(s);
//Queue<String> qq=new ArrayDeque<>(); //add,poll,peek
//Deque<String> qq=new ArrayDeque<>();//push,pop,peek
//ArrayList<String> cc = new ArrayList<>(n);
//Collections.sort(list);
//Array.sort(list);
//Arrays.asList(c).contains("a")
//list.set(1,"walk");
public class Main {
	static int a1[]= {0,-1,0,1};
	static int b1[]= {-1,0,1,0};
	private static Scanner sc = new Scanner(System.in);
	static void p(String ans) {System.out.println(ans);};
	static void p(int ans) {System.out.println(ans);};
	static void p(long ans) {System.out.println(ans);};
	static void p(double ans) {System.out.println(ans);};
	static int K;
	public static void main(String[] args) {
		String H=sc.next();
		String W=sc.next();
		
		int N=Integer.parseInt(H+W);
		boolean a=false;
		for(int i=1;Math.pow(i, 2)<=N;i++) {
			if(Math.pow(i, 2)==N) {
				a=true;
			}
		}
		if(a) {
			p("Yes");
		}else {
			p("No");
		}
		//p((double)H*W/2);
		
	}
}


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

using namespace std;

constexpr int MAXN = 1e5 + 5, MOD = 1e9 + 7;

int main() {
    std::ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
    long long a, b, c, d;
    cin >> a >> b >> c >> d;
    cout << max(a * c, max(b * d, max(b * c, a * d)));
    return 0;
}

Measured memory_bytes: 3644
N=int(input())
S=input()

def onaji(s):
    while True:
        if len(S)%2==1:
            return 'No'
        for i in range(len(S)//2):
            if S[i]!=S[i+(len(S)//2)]:
                return 'No'
            else:
                continue
        return 'Yes'
        
print(onaji(S))

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n; //nは要素数
  int i;
  int count = 0;
  cin >> n;
  
  int p[n];
  for(i=0;i<n;i++){
    cin >> p[i];
  }
  while(true){
    int flag = 0;
    for(i=0;i<n;i++){
      if( p[i] % 2 == 1 ){
        flag = 1;
      }
      p[i] /= 2;
    }
    if(flag == 1){
      break;
    }
    count++;
  }
  cout << count << endl;
}

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

typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> pll;
typedef vector<bool> vb;
const ll oo = 0x3f3f3f3f3f3f3f3f;
const double eps = 1e-9;
#define sz(c) ll((c).size())
#define all(c) begin(c), end(c)
#define FOR(i,a,b) for (ll i = (a); i < (b); i++)
#define FORD(i,a,b) for (ll i = (b)-1; i >= (a); i--)
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define xx first
#define yy second
#define TR(X) ({ if(1) cerr << "TR: " << (#X) << " = " << (X) << endl; })

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	ll n;
	cin >> n;

	ll k = 0;
	FOR(i,0,n) {
		ll x; cin >> x;
		if (x == k+1) k++;
	}
	
	if (k == 0) cout << -1 << endl;
	else cout << n-k << endl;

}



Measured memory_bytes: 384
import sys
sys.setrecursionlimit(500*500)
N = int(input())
edges = [list(map(int,input().split())) for _ in range(N-1)]
A = [[] for _ in range(N+1)]
 
for edge in edges:
  A[edge[0]].append([edge[1],edge[2]])
  A[edge[1]].append([edge[0],edge[2]])
  
depth = [-1] * (N+1)
depth[1] = 0
 
def dfs(A,s):
  for v in A[s]:
    if depth[v[0]] == -1:
      depth[v[0]] = depth[s] + v[1]
      dfs(A,v[0])    
dfs(A,1)
for d in depth[1:]:
  if d % 2 == 0:
    print(0)
  else:
    print(1)

Measured memory_bytes: 163416
#include <cmath>
#include <vector>
#include <iostream>

class Position {
  private:
    const int x_;
    const int y_;

  public:
    Position(int x, int y)
      : x_ { x }, y_ { y }
    {}

    int dx(const Position & other) const {
      return abs(x_ - other.x());
    }

    int dy(const Position & other) const {
      return abs(y_ - other.y());
    }

    int x() const { return x_; }

    int y() const { return y_; }
};

class LocationInfo {
  private:
    const int t_;
    const Position p_;

  public:
    LocationInfo(int t, const Position & p)
      : t_ { t }, p_ { p }
    {}

    bool canTravelTo(const LocationInfo & other) const {
      const auto remainingTime = remainingTimeAfterTraveledTo(other);
      return (0 <= remainingTime) && (remainingTime % 2 == 0);
    }

    int t() const { return t_; }

    Position p() const { return p_; }

  private:
    int remainingTimeAfterTraveledTo(const LocationInfo & other) const {
      const auto dt { other.t() -t_ };
      const auto dx { p_.dx(other.p()) };
      const auto dy { p_.dy(other.p()) };

      return dt - (dx + dy); 
    }
};

bool canTravelAllPosition(int from, int to, const std::vector<LocationInfo> & locationInfos) {
  if(to == locationInfos.size()) {
    return true;
  }

  if(locationInfos[from].canTravelTo(locationInfos[to])) {
    return canTravelAllPosition(from + 1, to + 1, locationInfos);
  }

  return false;
}

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

  std::vector<LocationInfo> locationInfos = {
    LocationInfo { 0, Position { 0, 0 } }
  };
  for(int i = 0; i < n; ++i) {
    int t, x, y;
    std::cin >> t >> x >> y;
    locationInfos.push_back(LocationInfo { t, Position { x, y} });
  }

  if(canTravelAllPosition(0, 1, locationInfos)) {
    std::cout << "Yes";
  } else {
    std::cout << "No";
  }

  std::cout << std::endl;

  return 0;
}

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

#define fr(i,n) _back
#define pb	push_back
#define eb	emplace_back
#define mk	make_pair
#define fi	first
#define se	second
#define endl	'\n'

typedef long long ll;
typedef pair<int,int> ii;
typedef vector<ii> vii;
const int INF = 0x3f3f3f3f;
const double PI = acos(-1.0);
const int T = 12;
const int N = 51;
int v[T];
int a[N], b[N], c[N], d[N];
int n,m,q;

int calc() {
    int ans = 0;
    for(int i = 0; i < q; i++)
        if(v[b[i]] - v[a[i]] == c[i]) ans += d[i];
    return ans;
}

int solve(int casa, int last) {
    if(casa > n) return calc();
    int ans = 0;
    for(int i = last; i <= m; i++) {
        v[casa] = i;
        ans = max(ans, solve(casa+1,i));
    }
    return ans;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin >> n >> m >> q;
    for(int i = 0; i < q; i++)
        cin >> a[i] >> b[i] >> c[i] >> d[i];
    cout << solve(1,1) << endl;
    return 0;
}



Measured memory_bytes: 3652
import java.util.Scanner;



public class Main {

	public static void main(String[] args) {



		Solve s= new Solve();
		s.solve();

	}
}


class Solve{
	 Scanner sc = new Scanner(System.in) ;

	 void solve() {
		 int P=sc.nextInt();
		 int Q=sc.nextInt();
		 int R= sc.nextInt();
		 
		 int res=P+Q;
		 if(res>Q+R) {
			 res=Q+R;
		 }
		 if(res>P+R) {
			 res=P+R;
		 }
		 System.out.println(res);




	 }



	 }

Measured memory_bytes: 24276
import math
import itertools
import statistics
#import collections
n = int(input())
a = list(map(int, input().split()))
#a.sort()

#rate = [400, 800, 1200, 1600, 2000, 24000, 2800, 3200]
count = [0]*9
for i in range(n):
    if a[i] < 400:
        count[0] += 1
    elif a[i] < 800:
        count[1] += 1
    elif a[i] < 1200:
        count[2] += 1
    elif a[i] < 1600:
        count[3] += 1
    elif a[i] < 2000:
        count[4] += 1
    elif a[i] < 2400:
        count[5] += 1
    elif a[i] < 2800:
        count[6] +=1
    elif a[i] < 3200:
        count[7] +=1
    else:
        count[8] += 1


ans = 0
for i in range(0, 8):
    if count[i] > 0:
        ans += 1


ans_max = ans+count[8]

"""
if ans+count[8] <= 8:
    ans_max = ans+count[8]
else:
    ans_max = 8
"""
   
if ans==0:
    ans = 1

print(str(ans)+" "+str(ans_max))

        


Measured memory_bytes: 5148
import java.util.*;

public class Main {
    public static void main(String[] args) {

        solve_148_A();
      
        return;
    }

    private static void solve_148_A() {
        Scanner sc = new Scanner(System.in);
        int A = sc.nextInt();
        int B = sc.nextInt();
        int C;

        C = (6 - A - B);

        System.out.println(C);
    }
}

Measured memory_bytes: 21332
#include<stdio.h>

const int INF = 1000000;

int min(int a, int b){
  return a > b ? b : a;
}

int main(){
  int N, Ma, Mb;
  scanf("%d %d %d", &N, &Ma, &Mb);
  
  int a[N];
  int b[N];
  int c[N];
  for(int i = 0; i < N; i++) scanf("%d %d %d", &a[i], &b[i], &c[i]);
  
  int dp[N + 1][401][401];
  for(int i = 0; i <= N; i++){
    for(int ma = 0; ma <= 400; ma++){
      for(int mb = 0; mb <= 400; mb++){
        dp[i][ma][mb] = INF;
      }
    }
  }
  dp[0][0][0] = 0;
  
  for(int i = 0; i < N; i++){
    for(int ma = 0; ma <= 400; ma++){
      for(int mb = 0; mb <= 400; mb++){
        dp[i + 1][ma][mb] = min(dp[i][ma][mb], dp[i + 1][ma][mb]);
        if(ma + a[i] <= 400 && mb + b[i] <= 400){
          dp[i + 1][ma + a[i]][mb + b[i]] = min(dp[i][ma][mb] + c[i], dp[i][ma + a[i]][mb + b[i]]);
        }
      }
    }
  }
  
  int cost = INF;
  for(int ma = 1; ma <= 400; ma++){
    for(int mb = 1; mb <= 400; mb++){
      if(ma * Mb == mb * Ma) cost = min(dp[N][ma][mb], cost);
    }
  }
  
  if(cost < INF) printf("%d\n", cost);
  else puts("-1");
  
  return 0;
}

Measured memory_bytes: 25856
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef pair<int,int> P;
 
const int INF = 1e9;
const int mod = 1e9+7;
const double EPS = 1e-10;
const double PI = acos(-1.0);

int main()
{
    int h,w;
    cin >> h >> w;
    char a[h][w];
    for(int i = 0; i < h; i++) for(int j = 0; j < w; j++) cin >> a[i][j];
    int row[h] = {},col[w] = {};
    for(int i = 0; i < h; i++){
        int cnt = 0;
        for(int j = 0; j < w; j++){
            if(a[i][j] == '.') cnt++;
        }
        if(cnt == w) row[i] = 1;
    }
    for(int i = 0; i < w; i++){
        int cnt = 0;
        for(int j = 0; j < h; j++){
            if(a[j][i] == '.') cnt++;
        }
        if(cnt == h) col[i] = 1;
    }
    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            if(!row[i] && !col[j]) cout << a[i][j];
        }
        if(!row[i])cout << endl;
    }
    return 0;
}

Measured memory_bytes: 256
s=input()[::-1]+'0'
n=len(s)
ans=0
flg=False
for i in range(n):
    a=int(s[i])
    if flg:
        a+=1
    if a==5:
        if int(s[i+1])>=5:
            ans+=5
            flg=True
        else:
            ans+=5
            flg=False
    elif a>5:
        ans+=10-a
        flg=True
    else:
        ans+=a
        flg=False
if flg:
    ans+=1
print(ans)

Measured memory_bytes: 5492
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstring>
#include <iomanip>
#include <cassert>

using namespace std;
typedef long long ll;

int main()
{
   int N;
   cin >> N;
   vector<pair<int, int>> V(N);
   for (int i = 0; i < N; i++)
   {
      cin >> V[i].first >> V[i].second;
   }
   vector<pair<int, int>> add(N);
   vector<pair<int, int>> sub(N);
   for (int i = 0; i < N; i++)
   {
      add[i].first = V[i].first + V[i].second;
      add[i].second = i;
      sub[i].first = V[i].second - V[i].first;
      sub[i].second = i;
   }
   sort(add.begin(), add.end());
   sort(sub.begin(), sub.end());
   pair<int, int> v1 = V[add[0].second];
   pair<int, int> v2 = V[add[N - 1].second];
   pair<int, int> v3 = V[sub[0].second];
   pair<int, int> v4 = V[sub[N - 1].second];
   cout << max(abs(v1.first - v2.first) + abs(v1.second - v2.second), abs(v3.first - v4.first) + abs(v3.second - v4.second)) << endl;

   return 0;
}


Measured memory_bytes: 8000
// include
// ------------------------------------------------
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <math.h>

using namespace std;

// func
// ------------------------------------------------
int CalcSumOfDigit(int n);      // 各桁の和を計算する。
long long getDigit(long long n);      // 数字の桁数を取得する。
string upper(string str);       // 英字を大文字に変換する。
string lower(string str);       // 英字を小文字に変換する。

// define
// ------------------------------------------------
#define all(a)        (a).begin(),(a).end()
#define rall(a)       (a).rbegin(),(a).rend()
#define sz(a)         int((a).size())
#define rep(i,n)      for(int(i)=0;(i)<(n);(i)++)
#define repe(i,n)     for(int(i)=0;(i)<=(n);(i)++)
#define vsort(v)      sort((v).begin(),(v).end())
#define rvsort(v)     sort(rall((v)))
#define vi            vector<int>
#define GCD(a,b)      __gcd((a),(b))
#define LCM(a,b)      ((a)/GCD((a),(b))*(b))
#define kiriage(a,b)  ((a)+(b)-1)/(b)

const int INF = 1e9;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> vll;

// code
// ------------------------------------------------
int main()
{

  ll h,w;
  cin >> h >>w;

  ull ans = (h * w + 2 - 1) / 2;

  if(h==1||w==1)
  {
    ans = 1;
  }

  cout << ans << endl;
  return 0;
}
// funcの実体
// ------------------------------------------------
ll getDigit(ll n)
{
  int i = 1;
  while(1)
  {
    n = n / 10;
    if(n == 0)
      break;
    i++;
  }
  return i;
}
ll CalcSumOfDigit(ll n)
{
  ll s = 0;
  while(n)
  {
    s += n % 10;
    n = n / 10;
  }
  return s;
}

string upper(string str)
{
  for(auto itr = str.begin();itr != str.end() ; itr++)
  {
    if(97 <= *itr && *itr <= 122)
    {
      *itr = *itr - 32;
    }
  }
  return str;
}

string lower(string str)
{
  for(auto itr = str.begin();itr != str.end() ; itr++)
  {
    if(65 <= *itr && *itr <= 90)
    {
      *itr = *itr + 32;
    }
  }
  return str;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;



/*
  acc1[i]  i日より前にacc1[i].n日働き、最後に働いたのはacc1[i].l日である
  acc2[i]  i日より後にacc2[i].n日働き、i以降で最初に働いたのはacc1[i].l日である
*/

struct accdata{
	int n;
	int l;
};

int main(){
	ll n, k, c;
	string s;
	
	cin >> n >> k >> c;
	cin >> s;
	
	vector<accdata> acc1(n);
	vector<accdata> acc2(n);
	ll cc = c+1;
	
	
	int worked = 0;
	int last_worked = -cc;
	acc1[0] = { worked, last_worked };
	for ( int i = 0; i < n-1; i++ ){
		if ( s[i] == 'o' && last_worked+cc <= i ){
			worked++;
			last_worked = i;
		}
		acc1[i+1].n = worked;
		acc1[i+1].l = last_worked;
	}
	
	
	worked = 0;
	last_worked = n-1+cc;
	acc2[n-1] = { worked, last_worked };
	for ( int i = n-1; i >= 1; i-- ){
		if ( s[i] == 'o' && last_worked-cc >= i ){
			worked++;
			last_worked = i;
		}
		acc2[i-1].n = worked;
		acc2[i-1].l = last_worked;
	}
	
	
	for ( int i = 0; i < n; i++ ){
		//cout << i << "/" << s[i] << " : " << acc1[i].n << " " << acc1[i].l << " " << acc2[i].n << " " << acc2[i].l << "    " 
		//  << (acc1[i].n+acc2[i].n) << " " << (acc2[i].l-acc1[i].l) << endl;
		if ( acc1[i].n+acc2[i].n < k )
			cout << i+1 << endl;
	}
	
	return 0;
}




Measured memory_bytes: 6748
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;

ll v[10] = {0, 2, 5, 5, 4, 5, 6, 3, 7, 6};
 
int main() {
    ll n, m;
    cin >> n >> m;
    
    vl a(m);
    rep(i, m) {
        cin >> a[i];
    } 
    sort(rall(a));

    vl dp(n+1000, -INF);  // dp[i] : i本のマッチ棒で作れる桁数の最大値
    dp[0] = 0;
    rep(i, n) {
        rep(j, m) {
            chmax(dp[i + v[a[j]]], dp[i] + 1);
        }
    }

    ll now = n;  // 残りマッチ棒の本数
    while(now != 0) {
        rep(i, m) {
            if(now >= v[a[i]] && dp[now] == dp[now - v[a[i]]] + 1) {
                cout << a[i];
                now -= v[a[i]];
                break;
            }
        }
    }

    cout << endl;
    re0;
}

Measured memory_bytes: 384
s=input()
t=input()
len_s=len(s)
len_t=len(t)
cnt=0
ans=len_s
for i in range(len_s-len_t+1):
  cnt=0
  for j in range(len_t):
    if s[j+i]!=t[j]:
      cnt+=1
  ans=min(ans,cnt)
print(ans)

Measured memory_bytes: 67524
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(vec) (vec).begin(),(vec).end()
#define int long long
#define f first
#define s second

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


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

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

    int u = s.size();
    int counter = 0;

    for (int i = 0; i < u; i++) {
        if (s.at(i) != t.at(i)) {
            counter++;
        }
    }

    cout << counter << endl;
}


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

inline int read()
{
	int ret=0; char c=getchar();
	while(c<48||c>57)c=getchar();
	while(c>=48 && c<=57)ret=ret*10+c-48,c=getchar();
	return ret;
}
int n,a[100097],d[100099],t,l,r,ss,m;
int main()
{
	n=read();
	for(int i=1;i<=n;++i)a[i]=read();
	
	d[t=1]=a[1];
	for(int i=2;i<=n;++i){
		if(a[i]<=d[t]){
			d[++t]=a[i];
			continue;
		}
		/*
		if(a[i] > d[1]){
			d[1]=a[i];
			continue;
		} */ //lower  //upper //set
		l=1; r=t;
		while(l<=r){
			m=l+r>>1;
			if(d[m]<a[i])ss=m,r=m-1;
			else l=m+1;
		}
		d[ss]=a[i];
	}
	
	cout<<t;
	 
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define SZ(x) ((int)(x).size())
#define debug(x) cerr << #x << ": " << x << '\n'
#define INF 999999999
typedef long long int Int;
typedef pair<int,int> P;
using ll = long long;
using VI = vector<int>;
using Edge = pair<int,int>;
using Graph = vector<vector<Edge>>;
int N;
Graph G;
vector<int> res;

void dfs(int v,int p,int c){
  res[v] = c;
  for(auto e:G[v]){
    if(e.first==p) continue;
    if(e.second&1) dfs(e.first,v,1-c);
    else dfs(e.first,v,c);
  }
}

int main(){
  cin >> N;
  G.assign(N,vector<Edge>());
  for(int i=0;i<N-1;i++){
    int u,v,w;cin >> u >> v >> w;
    --u,--v;
    G[u].push_back(Edge(v,w));
    G[v].push_back(Edge(u,w));
  }
  res.assign(N,0);
  dfs(0,-1,0);
  for(auto &v:res) cout << v << endl;
}

Measured memory_bytes: 8960
#include <bits/stdc++.h>
#include<string.h>
using namespace std;
#define FAST ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define endl "\n"
#define Max(x,y,z) max(x,max(y,z))
#define Min(x,y,z) min(x,min(y,z))
#define fr(i,s,e) for(i=s;i<e;i++)
#define rf(i,s,e) for(i=s-1;i>=e;i--)
#define pb push_back
#define eb emblace_back
#define mp make_pair
#define ff first
#define ss second
//#define int   long long
#define ll   long long
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
#define vl vector<long long>
#define inf (1LL<<61)
#define vi vector<int>
#define vii vector< vector<int> >
#define vll vector< vector<long long> >
#define vpi vector< pair<int,int> >
#define vpl vector< pair<ll,ll> >
#define viii vector< vector<vector<int> > >
typedef pair<pair<int, int>,int> P;
#define cd complex<double>
#define PI 4*atan(1)
#define mod %1000000007
#define pi 3.14159265358979323846//20 decimals
#define ld long double

ll a[101];
ll n, k;
ll dp[100005];
ll o[100005];

void pro(ll c)
{
//	cout << "Hi" << c << endl;
	ll i;
	fr(i,0,n)
	{
		if(c >= a[i])
		{
			if((o[c-a[i]]))
				dp[c] = !dp[c-a[i]];
			else
			{
				pro(c-a[i]);
				dp[c] = !dp[c-a[i]];
			}
			if(dp[c])
				break;
		}
		else
			break;
	}
	o[c] = 1;
//	trace2(c, dp[c]);
}

int main()
{
	FAST;
	ll i, j;
	cin >> n >> k;
	fr(i,0,n)
		cin >> a[i];
//	cout << "Hi" << endl;
	pro(k);
	if(dp[k])
		cout << "First";
	else
		cout << "Second";
}


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

int main(){
	int n;
	cin >> n;
	vector<int> p(n);
	rep(i,n) cin >> p[i];
	int cnt=0;
	rep(i,n){
		if(p[i]==i+1){
			cnt++;
			i++;
		}
	}
	cout << cnt << endl;
	return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <limits>
#include <cassert>
#include <map>
#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define REPI(i,a,b) for(ll (i)=(a);(i)<(b);(i)++)
#define INF numeric_limits<double>::infinity()
#define ll long long
constexpr ll MOD = 1e9 + 7;
ll gcd(ll a, ll b) {return b % a ? gcd(b % a, a) : a;}
ll lcm(ll a, ll b) {return a / gcd(a, b) * b;}
using namespace std;
using P = pair<ll, ll>;
using VI = vector<ll>;

int main() {
    int n, a, b;
    cin >> n >> a >> b;
    if ((a - b) % 2) {
        cout << "Borys" << endl;
    } else {
        cout << "Alice" << endl;
    }
}


Measured memory_bytes: 256
import java.util.Scanner;
class Main{
    int a,b,c;
    public void solve(){
        Scanner sc = new Scanner(System.in);
        a = sc.nextInt();
        b = sc.nextInt();
        c = sc.nextInt();
        if (a < b){
            if (b < c){
                System.out.println("Yes");
            }else{
                System.out.println("No");
            }
        }else{
                System.out.println("No");
        }
    }
    public static void main(String[] args){
        new Main().solve();     
    }
 
}

Measured memory_bytes: 17156