akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i=0; i<(int)(n); i++)
#define FOR(i, r, n) for (int i=(int)(r); i<=(int)(n); i++)
#define all(v) v.begin(), v.end()
#define INF 2147483647
#define INF64 9223372036854775807
#define MOD 1000000007

int main(){

    int a,b,c,k;
    cin>>a>>b>>c>>k;
    int cnt=0;
    while(a>=b){
        cnt++;
        b*=2;
    }
    while(b>=c){
        cnt++;
        c*=2;
    }
    if(cnt<=k) cout <<"Yes"<<endl;
    else cout<<"No"<<endl;

}

Measured memory_bytes: 3600
#include <cstdio>
#define _USE_MATH_DEFINES
#include <cmath>
#define rad(r) (r * M_PI / 180)
int main() {
	int a, b, C;
	scanf("%d %d %d", &a, &b, &C);
	printf("%f\n", 0.5 * a * b * sin(rad(C)));
	printf("%f\n", a + b + sqrt(a*a + b*b - 2 * a*b*cos(rad(C))));
	printf("%f\n", b * sin(rad(C)));
}

Measured memory_bytes: 1112
#include <iostream>
#include <vector>
#include <string>
#include <math.h>
#include <set>
#include <map>
#include <unordered_map>
#include <algorithm>

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

using namespace std;

inline int max(int a, int b) {
	if (b > a) swap(a, b);
	return a;
}

inline int min(int a, int b) {
	if (a > b) swap(a, b);
	return a;
}




int main() {
	int n, q, j;
	cin >> n >> q;
	vector<tuple<int, int, int>> e;
	vector<int> d(q);
	set<int> s;

	rep(i, n) {
		int s, t, x;
		cin >> s >> t >> x;
		e.emplace_back(s-x, 1, x);
		e.emplace_back(t-x, -1, x);
	}

	sort(e.begin(), e.end());

	rep(i, q) {
		cin >> d[i];
	}

	j = 0;
	auto p = e.begin();
	while (j < q) {
		if (p != e.end()) {
			if (d[j] < get<0>(*p)) {
				if (s.size() != 0) {
					cout << *(s.begin()) << endl;
				}
				else {
					cout << -1 << endl;
				}
				j++;
			}
			else {
				if (get<1>(*p) == 1) {
					s.insert(get<2>(*p));
				}
				else {
					s.erase(get<2>(*p));
				}
				p++;
			}
		}
		else {
			if (s.size() != 0) {
				cout << *(s.begin()) << endl;
			}
			else {
				cout << -1 << endl;
			}
			j++;
		}
	}
	

	return 0;
}


Measured memory_bytes: 16108
N, Y = list(map(int, input().split()))
for i_yukichi in range(N + 1):
    for j_higuchi in range(N + 1 - i_yukichi):
        k_noguchi = N - i_yukichi - j_higuchi
        if 10000 * i_yukichi + 5000 * j_higuchi + 1000 * k_noguchi == Y:
            print(i_yukichi, j_higuchi, k_noguchi)
            exit()

print("-1 -1 -1")


Measured memory_bytes: 2940
#include<bits/stdc++.h>
#include<iomanip>
using namespace std;
typedef long long ll;
typedef long  l;
typedef pair<int,int> P;
#define rep(i,n) for(int i=0;i<n;i++)
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
const int INF=1000000001;
const double PI=3.141592653589;
const ll LMAX=1000000000000001;
ll gcd(ll a,ll b){if(a<b)swap(a,b);while((a%b)!=0){a=b;b=a%b;}return b;}
int dx[]={-1,0,1,0};
int dy[]={0,1,0,-1};



int main(){
  int h,w; cin>>h>>w;
  ll ans=LMAX;
  ll S=(ll)h*(ll)w;
  for(int i=1;i<w;i++){
    ll s1=(ll)i*(ll)h;
    ll s2=(ll)(w-i)*(ll)(h/2);
    ll s3=S-s1-s2;
    ans=min(max({s1,s2,s3})-min({s1,s2,s3}),ans);
    s2=(ll)(w-i)/2*(ll)h;
    s3=S-s1-s2;
    ans=min(max({s1,s2,s3})-min({s1,s2,s3}),ans);
  }
  for(int i=1;i<h;i++){
    ll s1=(ll)i*(ll)w;
    ll s2=(ll)(h-i)*(ll)(w/2);
    ll s3=S-s1-s2;
    ans=min(max({s1,s2,s3})-min({s1,s2,s3}),ans);
    s2=(ll)(h-i)/2*(ll)w;
    s3=S-s1-s2;
    ans=min(max({s1,s2,s3})-min({s1,s2,s3}),ans);
  }
  cout<<ans<<endl;

  return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
#define ll long long
using namespace std;
const int N=4010,P=924844033;
inline int read(){
	int x=0,f=0,c=getchar();
	for(;c>'9'||c<'0';f=c=='-',c=getchar());
	for(;c>='0'&&c<='9';c=getchar())
	x=(x<<1)+(x<<3)+c-'0';return f?-x:x;
}
inline void write(ll x){
	if(x<0)putchar('-'),x=-x;
	if(x>9)write(x/10);putchar(x%10+'0');
}
ll a,b,c,ans;
int main(){
	a=read();b=read();c=read();
	ans=a*b;
	if(a&1)ans=min(ans,b*c);else ans=0;
	if(b&1)ans=min(ans,a*c);else ans=0;
	if(c&1)ans=min(ans,a*b);else ans=0;
	write(ans);puts("");
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <cstdint>
#include <cmath>
#include <string>
#include <vector>
#include <map>
#include <algorithm>

int main(void)
{
    int64_t N, D;
    std::cin >> N >> D;

    int64_t d = 1 + D*2;

    std::cout << std::ceil(N / static_cast<double>(d)) << std::endl;

    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];
    int tmp = 1;
    for (int i = 0; i < n; ++i) {
        if (A[i] == tmp) tmp++;
    }
    if (tmp == 1) cout << -1 << endl;
    else cout << n-tmp+1 << endl;
    return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<algorithm>
using namespace std;
int main() {
	long long n, k; cin >> n >> k;
	if (n == k) cout << "0" << endl;
	else if (n < k) cout << min(n, k - n) << endl;
	else cout << min(n % k, k - (n % k)) << endl;
}

Measured memory_bytes: 3644
N = int(input())
A = input()
B = input()
C = input()
cnt = 0
for i in range(N):
	if A[i] == B[i] == C[i]:
		pass
	elif A[i] != B[i] and B[i] != C[i] and C[i] != A[i]:
		cnt += 2
	else:
		cnt += 1
print(cnt)

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

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


int main()
{
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);

    int a, b, c;
    cin >> a >> b >> c;
    if (c - (a - b) >= 0) {
        cout << c - (a - b) << endl;
    }
    else { cout << "0" << endl; }

    return 0;
}


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


ll dp[100005][3];
ll happy[100005][3];
int main() {
    int N;
    cin >> N;
    ll dp[100005][3];
    ll happy[100005][3];

    for(int i = 1;i <= N;i++){
        cin >> happy[i][0] >> happy[i][1] >> happy[i][2];
    }
    for (int i = 1; i <= N; i++){
        for(int act = 0;act<3; act++){
            for (int prev = 0;prev<3;prev++){
                if (act == prev) continue;
                dp[i][act] = max(dp[i][act], dp[i-1][prev] + happy[i][act]);
                }
            }
        }
    ll ans = 0;
    rep(i,3) ans = max(ans,dp[N][i]);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4992
#include <iostream>
#include <algorithm>
#include <functional>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <string>

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

template<class T> inline bool chmin(T& a,T b) {if (a > b) {a = b; return true;} return false;}
template<class T> inline bool chmax(T& a,T b) {if (a < b) {a = b; return true;} return false;}

int main(){
  ll n; cin >> n;

  ll ans = 0;
  for (ll i = 1; i <= n; ++i){
    if (i % 3 == 0 || i % 5 == 0) continue;
    ans += i;
  }
  cout << ans << endl;
}


Measured memory_bytes: 3596
// AtCoder Regular Contest 061
// F - 3人でカードゲーム / Card Game for Three

#include <cstdio>
#include <cmath>
#define MAX_N (3 * 100000)
#define MAX_MK (3 * 100000)
#define MOD 1000000007
using namespace std;


typedef long long int ll;

int N;
int MK[2];
ll c0, c1, pow3;
ll ans;

int extgcd(int a, int b, int& x, int& y) {
  int d = a;
  if (b != 0) {
    d = extgcd(b, a % b, y, x);
    y -= (a / b) * x;
  } else {
    x = 1; y = 0;
  }
  return d;
}

int mod_inverse(int a, int m) {
  int x, y;
  extgcd(a, m, x, y);
  return (m + x) % m;
}

int main() {

  ll c1_edge[2];
  int inv3 = mod_inverse(3, MOD);

  scanf("%d%d%d", &N, &MK[0], &MK[1]);

  c0 = 1;
  c1 = 1;
  c1_edge[0] = 0;
  c1_edge[1] = 0;
  pow3 = 1;
  for (int i = 0; i < MK[0] + MK[1]; i++) {
    pow3 *= 3;
    pow3 %= MOD;
  }

  ans = 0;
  for (int p = N; p <= N + MK[0] + MK[1]; p++) {
    c1 = (c1 + 2 * MOD) % MOD;

    ans += ((c0 * c1) % MOD) * pow3;
    ans %= MOD;

    c0 = (c0 * ((p - 1) + 1) % MOD) * mod_inverse((p - 1) + 1 - (N - 1), MOD);
    c0 %= MOD;

    for (int i = 0; i <= 1; i++) {
      c1_edge[i] = (c1_edge[i] * (p - N)) % MOD * mod_inverse(p - N - MK[i], MOD);
      c1_edge[i] %= MOD;
      if (p - N == MK[i]) {
        c1_edge[i] = 1;
      }
    }
    c1 = c1 * 2 - c1_edge[0] - c1_edge[1] + 2 * MOD;
    c1 %= MOD;

    pow3 *= inv3;
    pow3 %= MOD;
  }

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

  return 0;

}




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

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define PB push_back
#define MP make_pair
typedef long long ll;
typedef double db;
typedef pair<int,int> pii;
const double PI=acos(-1.0);
const int INF=1e9;
const double EPS=1e-10;
const ll MOD=1e9+7;


int main(){
int a,b,coin;
cin>>a>>b;
if(a>b)coin=a*2-1;
else if(a<b)coin=b*2-1;
else if(a==b)coin=a*2;
cout<<coin<<endl;

return 0;
}

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

int main()
{
	int a, b;
	cin >> a >> b;
	if (b%a == 0)
		cout << a + b << endl;
	else
		cout << b - a << endl;
}

Measured memory_bytes: 256
import java.util.*;
import java.io.PrintWriter;

public class Main{
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();
		int k=sc.nextInt();
		long mod=1000000007;
		ArrayList<Integer> plus=new ArrayList<>();
		ArrayList<Integer> main=new ArrayList<>();
		int[] a=new int[n];
		int zero=0;
		long ans=1;
		for(int i=0; i<n; i++){
			a[i]=sc.nextInt();
			if(a[i]>0){
				plus.add(a[i]);
			}else if(a[i]<0){
				main.add(-a[i]);
			}else{
				zero++;
			}
		}
		if(n-k<zero){
			System.out.println(0);
			return;
		}else if(n==k){
			for(int i:a){
				if(i<0){
					i=-i;
				}
				ans=(ans*i)%mod;
			}
			if(main.size()%2==1){
				ans=(-ans+mod)%mod;
			}
			System.out.println(ans);
			return;
		}else if(n-k==zero){
			if(main.size()%2==1){
				System.out.println(0);
				return;
			}
			for(int i:plus){
				ans=(ans*i)%mod;
			}
			for(int i:main){
				ans=(ans*i)%mod;
			}
			System.out.println(ans);
			return;
		}
		Collections.sort(plus);
		Collections.sort(main);
		if(main.size()==(n-zero) && k%2==1){
			if(zero>0){
				System.out.println(0);
				return;
			}
			for(int i=0; i<k; i++){
				ans=(ans*main.get(i))%mod;
			}
			System.out.println((-ans+mod)%mod);
			return;
		}
		int maiind=main.size()-1;
		int pluind=plus.size()-1;
		long lastmai=1;
		long lastplu=1;
		for(int i=0; i<k; i++){
			if(maiind<0){
				ans=(ans*lastplu)%mod;
				lastplu=plus.get(pluind--);
			}else if(pluind<0){
				ans=(ans*lastmai)%mod;
				lastmai=main.get(maiind--);
				
			}else{
				if(main.get(maiind)>plus.get(pluind)){
					ans=(ans*lastmai)%mod;
					lastmai=main.get(maiind--);
				}else{
					ans=(ans*lastplu)%mod;
					lastplu=plus.get(pluind--);
				}
			}
		}
		
		if((main.size()-1-maiind)%2==1){
			long max=0;
			if(pluind>=0){
				max=Math.max(max,lastplu*plus.get(pluind));
			}
			if(pluind<(plus.size()-1) && maiind>=0){
				max=Math.max(max,lastmai*main.get(maiind));
			}
			max%=mod;
			ans=(ans*max)%mod;
		}else{
			ans=(ans*((lastmai*lastplu)%mod))%mod;
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 65536
import sys
def input(): return sys.stdin.readline().strip()


def main():
    N = int(input())
    ans = 0
    for i in range(1, N + 1):
        if i % 3 != 0 and i % 5 != 0:
            ans += i
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 67164
main(){
int n,m;
	for(;scanf("%d%d",&n,&m),n;){
		int t=1001,p,ans,c=0,i;
		for(i=0;i<n;i++){
			int a; scanf("%d",&a);

			int j;
			for(j=m;j%a;j--);

			if(j<t || (j==t && a<=p)){
				c=(j==t&&a==p?c+1:1);
				t=j;
				p=a;
				ans=i;
			}
		}

		printf("%d\n",c<2?ans+1:n);
	}
exit(0);
}

Measured memory_bytes: 0
import java.util.*;

class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    long a = Long.parseLong(sc.next());
    long b = Long.parseLong(sc.next());
    long c = Long.parseLong(sc.next());
    long d = Long.parseLong(sc.next());
	long ans;
    
    if (c > d) {
      long tmp = c;
      c = d;
      d = tmp;
    }
	long ndivc = b/c - a/c;
    if(a%c == 0) ndivc++;
    long ndivd = b/d - a/d;
    if(a%d == 0) ndivd++;
    long lcm = c * d / gcd(c, d);
    long ndivlcm = b/lcm - a/lcm;
    if(a%lcm == 0) ndivlcm++;
    
    ans = b - a + 1 - ndivc - ndivd + ndivlcm;
    
    System.out.println(ans);
    
  }
  
  public static long gcd(long a, long b) {
    if (b == 0) {
      return a;
    } else {
      return gcd(b,a%b);
    }
  }
}


Measured memory_bytes: 22996
import sys

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()

n = ni()
li = na()
ct = 0
s1 = 0
li2 = []
m = -1000000000000000000
for i in range(n):
    s1 += abs(li[i])
    li2.append(abs(li[i]))
    if li[i] < 0:
        ct += 1
if ct % 2 == 0:
    print(s1)
else:
    print(s1-2*min(li2))

Measured memory_bytes: 14412
#include <stdlib.h>
#include <cmath>
#include <cstdio>
#include <cstdint>
#include <string>
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
using namespace std;
using ll = long long;

#define MOD 1000000000+7

int main(){
  int N;
  cin >> N;
  vector<ll> A(N);
  vector<ll> sum(N);
  for(int i=0;i<N;++i){
    cin >> A.at(i);
    if(i!=0) sum.at(i)=sum.at(i-1)+A.at(i);
    else sum.at(i)=A.at(i);
    sum.at(i)%=1000000007;
  }

  ll ans=0;
  for(int i=0;i<N;++i){
    ll temp=sum.at(N-1)-sum.at(i);
    if(temp<0) temp=MOD+temp;
    ans=ans+temp*A.at(i)%1000000007;
    ans%=1000000007;
  }

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


Measured memory_bytes: 6428
n = gets.to_i
array_p = gets.split(" ").map!{|i | i.to_i}

swap = 0
flag = true

array_p.each_with_index do |num, index|
    unless num == (index + 1)
    swap = swap + 1

    if swap == 3
      flag = false
      break
    end
  end
end

flag ? result = "YES" : result = "NO"

puts result


Measured memory_bytes: 1788
#include <iostream>
int main (int argc, char* argv[])
{
    std::string s, t, u;
    int a, b;
    std::cin >> s >> t >> a >> b >> u;
    if (s == u) a--;
    else b--;
    std::cout << a << " " << b << std::endl;
    return 0;
}


Measured memory_bytes: 3636
r,g,y,n=map(int,input().split())
a=0
b=0
c=0
count=0


m=n
for i in range((n//r)+1):
    m=m-r*i
    for j in range((m//g)+1):
        c=m-j*g
        if c%y==0 and c>=0 :
            count+=1

    m=n

print(count)


Measured memory_bytes: 3060
import java.util.Scanner;

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

          int area=width*height;
          int s=2*(width+height);

          System.out.println(area+" "+s);
          

      }

}


Measured memory_bytes: 26100
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <cassert>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <algorithm>
#include <numeric>
#include <complex>
#include <stack>
#include <queue>
#include <list>
#include <set>
#include <map>
#include <bitset>
#include <functional>
#include <iterator>

using namespace std;

#define dump(n) cout<<"# "<<#n<<'='<<(n)<<endl
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define peri(i,a,b) for(int i=int(b);i-->int(a);)
#define rep(i,n) repi(i,0,n)
#define per(i,n) peri(i,0,n)
#define iter(c) __typeof__((c).begin())
#define foreach(i,c) for(iter(c) i=(c).begin();i!=(c).end();++i)
#define all(c) (c).begin(),(c).end()
#define mp make_pair

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<string> vs;
typedef pair<int,int> pii;

const int INFTY=1<<29;
const double EPS=1e-9;

template<typename T1,typename T2>
ostream& operator<<(ostream& os,const pair<T1,T2>& p){
	return os<<'('<<p.first<<','<<p.second<<')';
}
template<typename T>
ostream& operator<<(ostream& os,const vector<T>& a){
	os<<'[';
	rep(i,a.size()) os<<(i?" ":"")<<a[i];
	return os<<']';
}

struct Rect{
	int t,b,l,r;
	Rect(){}
	Rect(int t,int b,int l,int r):t(t),b(b),l(l),r(r){}
};

bool solve()
{
	int h,w; cin>>h>>w;
	vs grid(h);
	rep(i,h) cin>>grid[i];
	
	vi cs(26);
	vector<Rect> rs(26,Rect(h,0,w,0));
	rep(i,h) rep(j,w) if(grid[i][j]!='.'){
		int c=grid[i][j]-'A';
		cs[c]=1;
		rs[c].t=min(rs[c].t,i);
		rs[c].b=max(rs[c].b,i+1);
		rs[c].l=min(rs[c].l,j);
		rs[c].r=max(rs[c].r,j+1);
	}
	
	vvi dp(26,vi(26));
	rep(c,26)
		repi(i,rs[c].t,rs[c].b) repi(j,rs[c].l,rs[c].r){
			if(grid[i][j]=='.')
				return false;
			if(grid[i][j]!=c+'A')
				dp[c][grid[i][j]-'A']=1;
		}
	
	rep(k,26) rep(i,26) rep(j,26)
		dp[i][j]|=dp[i][k]&dp[k][j];
	
	rep(i,26) if(dp[i][i])
		return false;
	return true;
}

int main()
{
	int tc; cin>>tc;
	rep(i,tc)
		cout<<(solve()?"SAFE":"SUSPICIOUS")<<endl;;
	
	return 0;
}

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

using namespace std;

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

int main(){
  int n, k;
  cin >> n >> k;
  int b[k][2*k] = { };
  REP(i, n){
    int x, y;
    cin >> x >> y;
    x %= 2*k;
    y %= 2*k;
    char c;
    cin >> c;
    bool w = (c == 'W');
    if(x >= k){
      x -= k;
      w = !w;
    }
    if(w) y = (y+k)%(2*k);
    if(y < k){
      b[0][0]++;
      b[x][0]--;
      b[0][y]--;
      b[x][y] += 2;
      b[0][y+k]++;
      b[x][y+k] -= 2;
    }
    else{
      b[x][0]++;
      b[0][y-k]++;
      b[x][y-k] -= 2;
      b[0][y]--;
      b[x][y] += 2;
    }
  }
    REP(i, k-1){
      REP(j, 2*k) b[i+1][j] += b[i][j];
    }
    REP(i, 2*k-1){
      REP(j, k) b[j][i+1] += b[j][i];
    }
  int ans = 0;
  REP(i, k)REP(j, 2*k) ans = max(ans, b[i][j]);
  cout << ans << endl;
	return 0;
}


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

typedef long long ll;
typedef vector<int> vi;            typedef vector<vi> vii;
typedef vector<ll> vl;             typedef vector<vl> vll;
typedef pair<int,int> pi;          typedef pair<pi,int> pii;
typedef pair<ll,ll> pl;            typedef pair<pl,ll> pll;
typedef pair<int,bool> pib;        typedef pair<ll,bool> plb;

#define F first
#define S second
#define mp make_pair
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define in insert
#define er erase
//user-defined hash table for pairs --------------------------------------------------------------------------------------------------
struct hash_pair { 
    template <class T1, class T2> 
    size_t operator()(const pair<T1, T2>& p) const
    { 
        auto hash1 = hash<T1>{}(p.first); 
        auto hash2 = hash<T2>{}(p.second); 
        return hash1 ^ hash2; 
    } 
}; 

//returns (a^n mod p)---------------------------------------------------------------------------------------------------------------
ll power(ll a,ll n,ll p)
{
	if(n == 0)
	{
		return 1;
	}
	else if(n%2 == 0)
	{
		ll ans = power(a,n/2,p);
		return (ans*ans)%p;
	}
	else 
	{
		ll ans = power(a,n-1,p);
		return (ans*a)%p;
	}
}

//returns (a^-1 mod p)(if p is prime)----------------------------------------------------------------------------------------------
ll inverse(ll a,ll p)
{
   return power(a,p-2,p);
}
//----------------------------------------------------------------------------------------------------------------------------------


void solve()
{
   int n;
   cin>>n;
   int a[n];
   for(int i=0;i<n;i++)
   {
   	  cin>>a[i];
   }
   int ans = 0;
   for(int i=0;i<n;i++)
   {
   	  if(i%2 == 0 && a[i]%2 != 0)
   	  {
   	  	ans++;
   	  }
   }
   cout<<ans<<endl;
}


int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
#ifdef PAVANSAI006
    freopen("inp.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
    freopen("err.txt", "w", stderr);
#endif
    ll t = 1;
    //cin>>t;
    while(t--)
    {
    	solve();
    }
    
}

Measured memory_bytes: 3580
N = int(input())
A = list(map(int, input().split()))
ans = 0

def gcd(x, y):
  if x < y:
    x, y = y, x
  if y == 0:
    return x
  while y > 0:
    temp = x % y
    x = y
    y = temp
  return x

L = [0]
R = 0

for i in range(N-1):
  L.append(gcd(A[i], L[i]))
for i in range(N):
  temp = gcd(L[N-i-1], R)
  R = gcd(R, A[N-i-1])
  if ans < temp:
    ans = temp
    
print(ans)
  

Measured memory_bytes: 20888
#include<bits/stdc++.h>
#define lol(i,n) for(int i=0;i<n;i++)
#define fi first
#define sc second
typedef long long ll;

using namespace std;
#define N 200010
ll h,w,n;
pair<ll,ll> d[N];
int main(){
    cin>>h>>w>>n;
    lol(i,n)cin>>d[i].fi>>d[i].sc;
    sort(d,d+n);
    ll k=0;
    lol(i,n){
	ll x=d[i].fi,y=d[i].sc;
	if(y<x+k)return cout<<x-1<<endl,0;
	if(y==x+k)k--;
    }
    cout<<h<<endl;
    return 0;
}


Measured memory_bytes: 3328
#include <bits/stdc++.h>
#include <typeinfo>
#include <cxxabi.h>
#ifdef LOCAL
  #include "dbgtoki.hpp"
  #define DUMP(i) dump((string)TOSTRING(i), demangle(typeid(i).name()), __LINE__ , i) 
DbgTimer D_t;
  #define TSTART() D_t.start()
  #define TSTOP() D_t.stop()
#else
  #define DUMP(i) 
  #define TSTART()
  #define TSTOP()  
#endif
 
#define TOSTRING(x) #x
#define SZ(x) (int)(x).size()
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define ALL(s) (s).begin(), (s).end()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()) , v.end());
using namespace std;
typedef long long unsigned int llu;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;

const int EPS = 1e-9;



int main (){
  cin.tie(0);
  ios::sync_with_stdio(false);
  string a,b;
  while(cin >> a >> b ){
    TSTART();
    
    string ans;
    if(a == b)ans = "H";
    else ans = "D";
    
    cout << ans << endl;
    TSTOP();
  }
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)n; i++)
 
int main(){
  int n;
  cin >> n;
  int a[n];
  map<int, int> m;
  rep(i, n) {
    cin >> a[i];
    m[a[i]]++;
  }
  if(m.size() == 1){
    if(m[0]) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
  }
  if(n % 3){
     cout << "No" << endl;
     return 0;
  }
  if(m.size() == 2){
    int d[2];
    int i = 0;
    for(auto x : m){
      d[i] = x.first;
      i++;
    }
    if(d[0] == 0 && m[d[1]] == m[d[0]]*2) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
  }
  if(m.size() != 3){
    cout << "No" << endl;
    return 0;
  }
  int b[3];
  int i= 0;
  for(auto x : m){
    b[i] = x.first;
    i++;
  }
  if(!(m[b[0]] == m[b[1]] && m[b[0]] == m[b[2]])){
    cout << "No" << endl;
    return 0;
  }
  if((b[0] ^ b[1] ^ b[2]) == 0) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 4224
def isZero?(x,y)
  if x <= 0 && y <= 0 then
    return false
  end
  return true
end


x, y = gets.chomp.split.map(&:to_i)

while isZero?(x, y) do
  if y < x then
    puts "#{y} #{x}"
  else
    puts "#{x} #{y}"
  end

  x, y = gets.chomp.split.map(&:to_i)
end


Measured memory_bytes: 6860
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Main {
    public static void main(String args[]) {
        FastReader in = new FastReader();
        PrintWriter out = new PrintWriter(System.out);
        int n = in.nextInt();
        long[] arr = new long[3*n];
        for (int i=0; i<3*n; i++) {
            arr[i] = in.nextLong();
        }
        Arrays.sort(arr);
        long count = 0;
        int cn = 0;
        int i = (3 * n) - 2;
        while (cn < n) {
            cn++;
            count = count + arr[i];
            i = i - 2;
        }
        out.println(count);
        out.close();
    }

    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new
                    InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

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

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }
}


Measured memory_bytes: 57240
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int x = sc.nextInt();
    int y = sc.nextInt();
    String ans = "No";
    for(int i = 0; i <= x; i++) {
      int j = x - i;
      if((2 * i + 4 * j) == y) ans = "Yes";
    }
    System.out.println(ans);
  }
}

Measured memory_bytes: 35780
package main

import (
	"fmt"
	"math"
	"strconv"
)

func max(x, y int) int {
	if x > y {
		return x
	}
	return y
}

func min(x, y int) int {
	if x < y {
		return x
	}
	return y
}

func main() {
	var n int
	fmt.Scan(&n)

	ans := math.MaxInt64
	for i := 1; i*i <= n; i++ {
		if n%i != 0 {
			continue
		}
		f := max(len(strconv.Itoa(i)), len(strconv.Itoa(n/i)))
		ans = min(ans, f)
	}
	fmt.Println(ans)
}


Measured memory_bytes: 512
#include <iostream>
#include <stdio.h>
#include <string>
#include <vector>
#include <algorithm>
#include <limits.h>
using namespace std;

int main(int argc,char const* argv[])
{
  string s;
  cin >> s;
  int ans=0;
  for(int i=0;i<s.size();i++)
    {
      if(s[i]=='1') ans++;
    }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
import sys

input = sys.stdin.readline


def main():
    N = int(input())
    p = []
    q = []
    for _ in range(N):
        x, y = map(int, input().split())
        p.append(x + y)
        q.append(x - y)
    ans = 0
    p_min = min(p)
    q_min = min(q)
    for i in range(N):
        ans = max(abs(p[i] - p_min), abs(q[i] - q_min), ans)
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 87620
#include<stdio.h>
int main(){
  int N,i,v,j,A[1000],k,h;
  scanf("%d",&N);
  for(i=0;i<N;i++)
    {
      scanf("%d",&A[i]);
    }
  for(h=0;h<N;h++){
    printf("%d",A[h]);
	if(h>=0 && h<N-1)
	  printf(" ");
  }
  printf("\n");

  for(i=1;i<N;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;k++){
      printf("%d",A[k]);
	if(k>=0 && k<N-1)
	  printf(" ");
    }
    printf("\n");

  }
  //  printf("%d",A[i]);
  return 0;
}

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

using namespace std;

vector<vector<int>> adj;
vector<int> dp;

int dfs(int v){
	if(dp[v]!=-1)
		return dp[v];
	dp[v]=1;
	for(auto c: adj[v]){
		dp[v]=max(dp[v],1+dfs(c));
	}
	return dp[v];
}
int main(){
	int n,m,res=0;
	cin >> n >> m;
	adj=vector<vector<int>>(n+1);
	dp=vector<int>(n+1,-1);
	for(int i=0;i<m;i++){
		int s,d;
		cin >> s >> d;
		adj[s].push_back(d);
	}
	for(int i=1;i<=n;i++){
		if(dp[i]==-1){
			res=max(res,dfs(i));
		}
	}
	if(res > 0)
		res-=1;
	cout<<res<<"\n";
}

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

int waru(int A){
    int s=0;
    while(A %2 == 0){
        A /= 2;
        s ++;
    }
    return s;

}
 
int main () {
    int N;
    cin >> N;

    int A, ans=40;
    rep(i,N){
        cin >> A;
        ans = min(ans,waru(A));
    }

    cout << ans << endl;

}


Measured memory_bytes: 256
n = int(input())
S = []
result = 0
A_count = 0
B_count = 0
BA_count = 0

for i in range(n):
    Si = str(input())
    S.append(Si)

for i in range(n):
    Si = S[i]
    result += Si.count("AB")
    if Si[0] == "B" and Si[-1] != "A":
        B_count += 1
    if Si[0] != "B" and Si[-1] == "A":
        A_count += 1
    if Si[0] == "B" and Si[-1] == "A":
        BA_count += 1 

if BA_count >= 2:
    result += (BA_count - 1)

if BA_count >= 1:
    if B_count >= 1:
        result += 1
        B_count -= 1
    if A_count >= 1:
        result += 1
        A_count -= 1

if B_count >= 1 and A_count >= 1:
    result += min(B_count, A_count)

print(result)  

Measured memory_bytes: 3700
import java.io.*;
import java.util.Arrays;
import java.util.stream.IntStream;

public class Main {
  public static void main(String[] args) {
    new Main().run();
  }

  private void run() {
    try(BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter out = new PrintWriter(System.out)) {

      final int MAX = 100000;
      int n = Integer.parseInt(in.readLine());

      int[] table = new int[MAX+1];
      in.lines()
        .limit(n)
        .map(s -> s.split(" "))
        .map(a -> Arrays.stream(a).mapToInt(Integer::parseInt).toArray())
        .forEach(a -> IntStream.rangeClosed(a[0],a[1])
          .forEach(i -> table[i] = 1)
        );

      final int ans = Arrays.stream(table).sum();
      System.out.println(ans);
    }
    catch(IOException e) {
      System.err.println(e);
    }
  }
}

Measured memory_bytes: 27732
#include<iostream>
using namespace std;
int main(){
	int a,b;
	char c;
	while(cin>>a>>c>>b){
		if(c=='?')	break;
		if(c=='+'){
			cout<<a+b<<endl;
			continue;
		}
		else if(c=='-'){
			cout<<a-b<<endl;
			continue;
		}
		else if(c=='*'){
			cout<<a*b<<endl;
			continue;
		}
		else if(c=='/'){
			cout<<a/b<<endl;
			continue;
		}
	}
	return 0;
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
using namespace std;
int main(){
	double a,b;
	int f1=0;
	cin>>a>>b;
	int i=0;
	for(;i<5000;i++){
		int t1=i*0.08,t2=i*0.1;
		if(t1==a&&t2==b){
			f1=1;
			break;
		}
	}
	if(f1)cout<<i;
	else cout<<-1;
	return 0;
}

Measured memory_bytes: 256
n, m = input().split()
a = list(map(int, input().split()))
b = []
s = 0

for i in a:
    s += i

for i in a:
    if float(i) >= float(int(s)/(4*int(m))):
        b.append(i)
        if len(b) == int(m):
            break

if len(b) == int(m):
    print("Yes")
else:
    print("No")

Measured memory_bytes: 9196
#include<iostream>
#include<vector>
#define rep(i, start, end) for (int i = (int)start; i < (int)end; ++i)
#define rrep(i, start, end) for (int i = (int)start - 1; i >= end; --i)
#define arep(i, c) for (auto i = (c).begin(); i != (c).end(); ++i)
#define all(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;

vector<ll> get_divisor(ll x) {
    vector<ll> res;
    for (ll i = 1; i * i <= x; ++i) {
        if (x % i) continue;
        res.push_back(i);
        if (i * i != x) res.push_back(x / i);
    }
    return res;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll A, B;
    cin >> A >> B;
    vector<ll> div_a = get_divisor(A);
    vector<ll> divs;
    rep(i, 0, div_a.size()) {
        if (B % div_a[i]) continue;
        divs.push_back(div_a[i]);
    }
    vector<bool> is_prime(divs.size(), true);
    rep(i, 0, divs.size()) {
        bool is_ok = true;
        for (ll j = 2; j * j <= divs[i]; ++j) {
            if (divs[i] % j == 0) {
                is_ok = false;
                break;
            }
        }
        is_prime[i] = is_ok;
    }
    int ans = 0;
    rep(i, 0, is_prime.size()) {
        if (is_prime[i]) ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 384
#include<iostream>
using namespace std;
#define MAX 500000
#define NIL 2000000000
int L[MAX/2+2],R[MAX/2+2];
int cnt;
void Merge(int A[],int n,int left,int mid,int right){
  int n1=mid-left;
  int n2=right-mid;
  for(int i=0;i<n1;i++)L[i]=A[left+i];
  for(int i=0;i<n2;i++)R[i]=A[mid+i];
  L[n1]=R[n2]=NIL;
  int i=0,j=0;
  for(int k=left;k<right;k++){
    cnt++;
    if(L[i]<=R[j])
      A[k]=L[i++];
    else
      A[k]=R[j++];
  }
}

void Sort(int A[],int n,int left,int right){
  if(left+1<right){
    int mid =(left+right)/2;
    Sort(A,n,left,mid);
    Sort(A,n,mid,right);
    Merge(A,n,left,mid,right);
  }
}
int main(){
  int A[MAX],n,i;
  cnt=0;
  cin >> n;
  for(i=0;i<n;i++)cin >> A[i];
  Sort(A,n,0,n);
  for(i=0;i<n;i++){
    if(i)cout<<" ";
    cout << A[i];
  }
  cout << endl; cout <<cnt << endl;
  return 0;
}

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

#define rep(i,x,y) for(ll i=(x);i<(y);i++)
#define rrep(i,x,y) for(ll i=(ll)(y)-1;i>=(x);i--)
#define all(x) (x).begin(),(x).end()
#ifdef LOCAL
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl
#define itrdebug(x) cerr << #x << " "; for (auto & el : (x)) {cerr << (el) << " ";} cerr << endl
#define dassert(...) assert(__VA_ARGS__)
#else
#define debug(x)
#define itrdebug(x)
#define dassert(...)
#endif
//#define int long long

typedef long long ll;
const ll MOD = 1e9 + 7;
const long double EPS = 1e-8;

void solve(long long N, std::vector<long long> A){
    sort(all(A), greater<>());
    priority_queue<pair<int, int>> que;
    ll answer = 0;
    answer += A[0];
    que.push({A[1], A[0]});
    que.push({A[1], A[0]});
    rep(i,2,N) {
        auto p = que.top();
        que.pop();
        answer += p.first;
        que.push({A[i], p.first});
        que.push({A[i], p.second});
    }
    cout << answer << endl;
}

signed main(){
    // ios_base::sync_with_stdio(false);
    // cin.tie(NULL);
    long long N;
    scanf("%lld",&N);
    std::vector<long long> A(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&A[i]);
    }
    solve(N, std::move(A));
    return 0;
}


Measured memory_bytes: 6864
def main():
    from collections import Counter as ct
    n = int(input())
    a = list(map(int, input().split()))
    c = ct(a)
    min_a = min(a)
    max_a = max(a)
    if min_a == 1:
        if c[min_a] == 1:
            pass
        elif a == [1, 1]:
            print("Possible")
            return 0
        else:
            print("Impossible")
            return 0
    if c[min_a] == 1 and (max_a+1)//2 > min_a:
        print("Impossible")
        return 0
    if c[min_a] == 2 and (max_a+2)//2 > min_a:
        print("Impossible")
        return 0
    if c[min_a] > 2:
        print("Impossible")
        return 0
    for i in range(min_a+1, max_a+1):
        if c[i] < 2:
            print("Impossible")
            return 0
    print("Possible")
main()

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

int main(void)
{
	long long int power = 1;
	int i,j;
	int n;
	cin >> n;
	long long int ru = 1;

	for (j = 0; j < 9; j++) {
		ru = ru * 10;

	}


	for (i = 0; i < n; i++) {
		power = power *(i + 1);

		power = power % (ru + 7);



	}


	cout << power << endl;


	return (0);


}

Measured memory_bytes: 256
#include <cstdio>
#include <queue>
#include <cstring>

using namespace std;

struct state {
  int x, y;
  int cost;
  bool operator>(const state& e) const {
    return cost > e.cost;
  }
};

int w, h;
char a[555][555];

int cost[555][555];
int prevx[555][555], prevy[555][555];
int done[555][555];

const int MAX_N = 555*555;
struct uni {
  int p[MAX_N];
  uni(){init();}
  void init(){ memset(p,-1,sizeof(p)); }
  int root(int a) {
    return p[a]<0?a:(p[a]=root(p[a]));
  }
  bool find(int a,int b){ return root(a) == root(b); }
  bool merge(int a,int b) {
    a = root(a);
    b = root(b);
    if( a == b ) return false;
    p[a] += p[b];
    p[b] = a;
    return true;
  }
  int size(int a){ return -p[root(a)]; }
};

uni u;
int ans1[555][555];
int ans2[555][555];

int main(void) {
  scanf("%d%d", &h, &w);
  int sx, sy;
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      scanf(" %c", a[i]+j);
      if (a[i][j] == '#') {
        sx = j;
        sy = i;
      }
    }
  }

  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      printf("%c", i == 0 || a[i][j] == '#' || (i!=h-1&&j%2 == 0) ? '#' : '.');
    }
    puts("");
  }

  puts("");
  
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      printf("%c", i == h-1 || a[i][j] == '#' || (i!=0&&j%2 == 1) ? '#' : '.');
    }
    puts("");
  }
  
  return 0;
}


Measured memory_bytes: 2176
import sys
n = int(input())

if n == 1:
    print(0)
    sys.exit()

def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

factor_list = factorization(n)
# print(factor_list)


target_list = []
for i in factor_list:
    num = i[0]
    for j in range(i[1]):
        target_list.append(num ** (j+1))

target_list.sort()

if len(target_list) == 1:
    print(1)
    sys.exit()
current_n = n 
cnt = 0
for i in target_list:
    if  current_n % i == 0:
        current_n = current_n / i
        cnt = cnt + 1
print(cnt)

Measured memory_bytes: 9524
// AOJ 0368: Flag
// 2017.11.14 bal4u@uu

#include <stdio.h>
#include <string.h>

char m[23][23];

int main()
{
	int w, h, c, r;
	char buf[5];

	scanf("%d%d%s", &w, &h, buf);
	c = *buf;
	memset(m, '.', sizeof(m));
	memset(m[  0], '-', w);
	memset(m[h-1], '-', w);
	for (r = 0; r < h; r++) m[r][0] = m[r][w-1] = '|';
	m[0][0] = m[h-1][0] = m[0][w-1] = m[h-1][w-1] = '+';
	m[h/2][w/2] = c;
	for (r = 0; r < h; r++) m[r][w] = 0, puts(m[r]);
	return 0;
}

Measured memory_bytes: 1796
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;

ll l[100];

ll luca(int n){
    if(l[n] != 0) return l[n];
    l[n] = luca(n-1) + luca(n-2);
    return l[n];
}

int main(int argc, char* argv[]){
    int n;
    cin >> n;
    l[0] = 2;
    l[1] = 1;
    rep(i, 2, 100){
        luca(n);
    }

    cout << l[n] << endl;
}


Measured memory_bytes: 256
// Problem : B - Bishop
// Contest : AtCoder - Panasonic Programming Contest 2020
// URL : https://atcoder.jp/contests/panasonic2020/tasks/panasonic2020_b
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

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

//Macros

#define ll long long
#define db long double
#define pb push_back
#define eb emplace_back
#define pii pair<int,int>
#define vi vector<int>
#define vii vector<pii>
#define mi map<int,int>
#define mii map<pii,int>
#define fi first
#define se second
#define all(a) (a).begin(),(a).end()
#define sz(x) (int)x.size()
#define mod 1000000007
#define EPS 1e-9
#define io ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define inf 1e10
#define PI acos(-1.0)
#define int long long
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
#define N 100005

//Solution

void solve(){
    int n,m;
    cin>>n>>m;
    if(min(n,m) == 1){
        cout<<1<<endl;
        return;
    }
    int x = n*m;
    if(x % 2) x = (x+1)/2;
    else x /= 2;
    cout<<x<<endl;
}

signed main(){
    io;
    //freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
    int tests;
    //cin>>tests;
    tests = 1;
    while(tests--){
        solve();
    }
    return 0;
}

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

int N, X;
int L[1000];

int main() {
    cin >> N >> X;
    rep(i, N) {
        cin >> L[i];
    }

    int sum = 0;
    int ans = 1;
    rep(i, N) {
        sum += L[i];
        // printf("i: %d sum: %d\n", i, sum);

        if (sum > X) {
            break;
        }

        ans++;
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize("O3")
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,n) for(int i=1;i<=n;i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define EPS (1e-9)
#define INF (1e17)
#define PI (acos(-1))
//const double PI = acos(-1);
//const double EPS = 1e-15;
//long long INF=(long long)1E17;
#define i_7 (long long)(1e9+7)
//#define i_7 998'244'353
long mod(long a){
    long long c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
long long po(long a, long b){
    if(b==0){
        return 1;
    }
    
    long long z = po(a,b/2);
    z = mod(z*z);
    if(b%2!=0){
        z = mod(a*z);
    }
    return z;
}
 
bool prime_(int n){
  if(n==1){
    return false;
  }else if(n==2){
    return true;
  }else{
    for(int i=2;i<=std::sqrt(n);i++){
      if(n%i==0){
        return false;
      }
    }
    return true;
  }
}
 
long long gcd_(long long a, long long b){
  if(a<b){
    std::swap(a,b);
  }
  if(a%b==0){
    return b;
  }else{
    return gcd_(b,a%b);
  }
}
 
long long lcm_(long long x, long long y){
  return (x/gcd_(x,y))*y;
}
 
//using namespace std;
//using namespace boost::multiprecision;
//using namespace __gnu_pbds;
 
int main(){
  using namespace std;
  string s;
  cin>>s;
  if(s[2] == s[3] && s[4] == s[5]){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
  return 0;
}


Measured memory_bytes: 256
n,a,b=map(int,input().split())
ab=a+b
S=input()
allp=0
forp=0
for s in S:
  if s=='a':
    if allp<ab:
      allp+=1
      print('Yes')
    else:
      print('No')
  elif s=='b':
    if allp<ab and forp<b:
      allp+=1
      forp+=1
      print('Yes')
    else:
      print('No')
  else:
    print('No')

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

int main(){
    int n;
    cin >> n;
    int ans = 100000000;
    int a[n];
    int min = 100000;
    int max = -100000;
    for(int i=0;i<n;i++){
        cin >> a[i];
        if(min > a[i]){
            min = a[i];
        }
        if(max < a[i]){
            max = a[i];
        }
    }
    for(int j=min;j <= max;j++){
        int tmp = 0;
        for(int i=0;i<n;i++){
            tmp += (a[i]-j)*(a[i]-j);
        }
        if(ans > tmp) {
            ans = tmp;
        }
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;

char s[1010];
bool ok[128];

int main()
{
    #ifdef waltz
        freopen("input.txt","r",stdin);
    #endif
    scanf("%s",s);
    int n=strlen(s);
    for (int i=0;i<n;i++) ok[s[i]]=1;
    if ((ok['E']&&!ok['W'])||(ok['W']&&!ok['E'])||(ok['N']&&!ok['S'])||(ok['S']&&!ok['N'])) puts("No"); else puts("Yes");
    return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n,count=0;
  string s,t;
  cin>>n>>s>>t;
  for(int i=1; i<=n; i++){
    if(s.substr(n-i,n)==t.substr(0,i)){
      count=i;
    }
  }
  cout<<n*2-count<<'\n';

  return 0;
}



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

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repc(i, n) for (int i = 0; i <= int(n); i++)
#define rrepc(i, n) for (int i = int(n); i >= 0; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define repic(i, a, b) for (int i = int(a); i <= int(b); i++)
#define each(x, y) for (auto &x : y)
#define all(a) (a).begin(), (a).end()
#define bit(b) (1ll << (b))
#define uniq(v) (v).erase(unique(all(v)), (v).end())

using namespace std;

using i32 = int;
using i64 = long long;
using f80 = long double;
using vi32 = vector<i32>;
using vi64 = vector<i64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

inline void yes() { cout << "Yes" << '\n'; exit(0); }
inline void no() { cout << "No" << '\n'; exit(0); }
inline i64 gcd(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); if (a % b == 0) return b; return gcd(b, a % b); }
inline i64 lcm(i64 a, i64 b) { return a / gcd(a, b) * b; }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }
template <typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template <typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template <typename T> inline void amax(T &x, T y) { if (x < y) x = y; }
template <typename T> inline void amin(T &x, T y) { if (x > y) x = y; }
template <typename T> inline T power(T x, i64 n, T e = 1) { T r = e; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template <typename T> istream& operator>>(istream &is, vector<T> &v) { each(x, v) is >> x; return is; }
template <typename T> ostream& operator<<(ostream &os, vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }
template <typename T, typename S> istream& operator>>(istream &is, pair<T, S> &p) { is >> p.first >> p.second; return is; }
template <typename T, typename S> ostream& operator<<(ostream &os, pair<T, S> &p) { cout << p.first << ' ' << p.second; return os; }

void solve() {
  int N, Z, W; cin >> N >> Z >> W;
  vi64 a(N); cin >> a;
  
  vi64 dp0(N, -1e9), dp1(N, 1e9);
  rrep(i, N) {
    i64 Y = (i ? a[i - 1] : W);
    amax(dp0[i], abs(Y - a[N - 1]));
    repi(j, i + 1, N) amax(dp0[i], dp1[j]);

    i64 X = (i ? a[i - 1] : Z);
    amin(dp1[i], abs(X - a[N - 1]));
    repi(j, i + 1, N) amin(dp1[i], dp0[j]);
  }
  cout << dp0[0] << '\n';
}


Measured memory_bytes: 256
#include <iostream>
#include <stack>
using namespace std;
static const int N = 100;
static const int WHITE = 0;
static const int GRAY = 1;
static const int BLACK = 2;

int n, time1=0, M[N][N], color[N];
int nt[N], begin[N], end[N];

int next(int r)
{
	int i;
	for(i=nt[r]; i<n; i++)
	{
		nt[r]=i+1;
		if(M[r][i]==0)
			continue;
		if(color[i]==WHITE)
			return i;
	}
	return -1;
	
}

void dfs_visit(int r)
{
	int i, j;
	stack<int> S;
	S.push(r);
	color[r]=GRAY;
	begin[r]=++time1;
	
	while(!S.empty())
	{
		int u=S.top();
		int v=next(u);
		if(v!=-1)
		{
			begin[v]=++time1;
			color[v]=GRAY;
			S.push(v);
		}
		else
		{
			S.pop();
			color[u]=BLACK;
			end[u]=++time1;
		}

	}
}

void dfs()
{
	int i, j;
	for(i=0; i<n; i++)
	{
		color[i]=WHITE;
		nt[i]=0;
	}

	for(i=0; i<n; i++)
	{
		if(color[i]==WHITE)
		{
			dfs_visit(i);
		}
	}
	for(i=0; i<n; i++)
	{
		cout<<i+1<<" "<<begin[i]<<" "<<end[i]<<endl;
	}
}

int main()
{
	int i, j;
	int u, v, k;
	cin>>n;
	for(i=0; i<n; i++)
	{		
		for(j=0; j<n; j++)
		{
			M[i][j]=0;
		}
	}
	
	for(i=0; i<n; i++)
	{
		cin>>v>>k;
		v--;
		for(j=0; j<k; j++)
		{
			cin>>u;
			u--;
			M[v][u]=1;
		}
	}

	dfs();
	return 0;
}


Measured memory_bytes: 3128
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
        @SuppressWarnings("resource")
		Scanner sc = new Scanner(System.in);
        // 複数行の読み込み
        int a = Integer.parseInt(sc.next());
        int b = Integer.parseInt(sc.next());
        
        if ((a * b) % 2 == 0) {
        	System.out.println("Even");
        } else {
        	System.out.println("Odd");
        }
    }
}

Measured memory_bytes: 21844