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

#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
// #define MOD 998244353 
#define MEM_SIZE 100010
#define DEBUG_OUT true
#define ALL(x) (x).begin(), (x).end()

template<typename T> void DEBUG(T e){if(DEBUG_OUT == false)return; std::cout << e <<" ";}
template<typename T> void DEBUG(const std::vector<T>& v){if(DEBUG_OUT == false)return;for(const auto& e : v){std::cout<< e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){if(DEBUG_OUT == false)return;for(const auto& v : vv){ DEBUG(v); } }
template<class T,class... Ts> void DEBUG(T d, Ts... e){if(DEBUG_OUT == false)return;DEBUG(d);DEBUG(e...);}
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; abort();}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

 

//SOLVE
void solve(void)
{
  int N;cin>>N;
  vector<map<int,int> > mp (2);
  for (int i = 0; i < N; i++)
  {
    int X;cin>>X;
    mp[i%2][X]++;
  }
  vector<vector<pair<int,int > > > mp2(2);
  for (auto &&i : mp[0])
  {
    mp2[0].push_back(make_pair(i.second,i.first));
  }
  for (auto &&i : mp[1])
  {
    mp2[1].push_back(make_pair(i.second,i.first));
  }
  sort(ALL(mp2[0]));
  reverse(ALL(mp2[0]));

  sort(ALL(mp2[1]));
  reverse(ALL(mp2[1]));
  if(mp2[0].begin()->second != mp2[1].begin()->second)
  {
    cout<<N - mp2[0].begin()->first - mp2[1].begin()->first;
  }
  else
  {
    int E1 = mp2[0].begin()->first ;
    int E2;
    int O1 =  mp2[1].begin()->first;
    int O2;
    // DEBUG(E1,O1);
    if(mp2[0].size() == 1)
    {
      E2 = 0;
    }
    else
    {
      auto itr = mp2[0].begin();
      itr++;
      E2  = itr->first;
    }

    if(mp2[1].size() == 1)
    {
      O2 = 0;
    }
    else
    {
      auto itr = mp2[1].begin();
      itr++;
      O2  = itr->first;
    }
      
     cout<<N - max(O1 +E2 ,O2 +E1)<<endl;
  
  }

  
  

  return;
}

int32_t main(int32_t argc, const char *argv[])
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  std::cout << std::fixed;
  std::cout << std::setprecision(11);
  solve();

  return 0;
}


Measured memory_bytes: 11748
#include <bits/stdc++.h>
const int maxn = 1e5 + 10;
using namespace std;
int a[maxn];
int b[maxn];
int main()
{
    int n;
    cin >> n;
    for (int i = 1; i <= n; i++) {
        cin >> b[i];
        if (b[i] == i)
            a[i] = 1;
        else
            a[i] = 0;
    }
    int sum = 0;
    for (int i = 1; i <= n; i++) {
        if (i == n) {
            if (a[i] == 1)
                sum++;
        }
        else {
            if (a[i] == 1 && a[i + 1] == 0) {
                sum++;
                swap(b[i], b[i+1]);
                if (b[i+1] == i+1)
                    a[i+1] = 1;
                else
                    a[i+1] = 0;
                a[i] = 0;
                    
            }
            else if (a[i] == 1 && a[i+1] == 1) {
                sum++;
                swap(b[i], b[i+1]);
                a[i] = 0;
                a[i+1] = 0;
            }
        }

    }
    cout << sum << endl;
    return 0;
}


Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int m = sc.nextInt();
		int f = sc.nextInt();
		int r = sc.nextInt();

		while(!(m==-1&&f==-1&&r==-1)) {
			int mf = m+f;
			if(m==-1||f==-1||mf<30) {
				System.out.println("F");
			}else if(mf >= 80) {
				System.out.println("A");
			}else if(mf >= 65) {
				System.out.println("B");
			}else if(mf >= 50) {
				System.out.println("C");
			}else if(mf >= 30 && r>=50) {
				System.out.println("C");
			}else if(mf >= 30) {
				System.out.println("D");
			}
			else {
				System.out.println("F");
			}

			m = sc.nextInt();
			f = sc.nextInt();
			r = sc.nextInt();

		}




	}
}


Measured memory_bytes: 26208
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi=vector<int>;
using vvi=vector<vi>;
using pii=pair<int,int>;
const ll LINF=0x1fffffffffffffff;
const int INF=0x3fffffff;
const int MOD=1000000007;
#define VAR(type,...) type __VA_ARGS__;in(__VA_ARGS__)
#define VEC(type,name,size) vector<type> name(size);in(name)
#define rep(i,a,b) for(int i=(a);i<(b);++i)
#define rrep(i,a,b) for(int i=(a-1);i>=(b);--i)
#define each(x,v) for(auto &x:(v))
#define all(x) (x).begin(),(x).end()
#define print(x) cout<<(x)<< endl
void in(){} template<class T,class... U> void in(T &t,U &...u){cin>>t;in(u...);}
void solve();
int main(){cin.tie(0);ios::sync_with_stdio(0);solve();}

void solve() {
  VAR(string, S);
  int ans = 0;
  rep(i, 0, (int)S.length() - 1) {
    if (S[i] == S[i + 1]) {
      S[i + 1] = 49 - (S[i] % 2);
      ans++;
    }
  }

  print(ans);
}


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

int main() {
	std::string s;
	int n;
	std::cin >> s;
	n = s.size();
	int k = 0;
	for (int i = 0; i < (n - 1) / 2; i++) {
		if (s[i] != s[n - 1 - i]) {
			std::cout << "No" << std::endl;
			return 0;
		}
	}
	for (int i = 0; i<(n-1)/2-1-i / 2; i++) {
		if (s[i] != s[(n - 1) / 2 - 1-i]) {
			std::cout << "No" << std::endl;
			return 0;
		}
	}
	for (int i = (n + 1) / 2; (n+1)/2+i<n-1-i; i++) {
		if (s[(n + 1) / 2+i] != s[n - 1-i]) {
			std::cout << "No" << std::endl;
			return 0;
		}
	}
	std::cout << "Yes" << std::endl;
	return 0;
}

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

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

	string ret;
	if(A+B >= 10)
		ret = "error";
	else
		ret = to_string(A+B);

	cout << ret << endl;

	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner scan = new Scanner(System.in);
		int a = scan.nextInt();
		int b = scan.nextInt();
		int h = scan.nextInt();
		int area = (a + b) * h / 2;
		
		System.out.println(area);

	}

}

Measured memory_bytes: 21588
import sys
#input = sys.stdin.readline
sys.setrecursionlimit(10**7)
S = input()

S = S + 'g'
memo = [0]*len(S)
last = 's'
cnt_r = 0
cnt_l = 0
res = 0
for s in S:
    if last == 's':
        if s == '<':
            cnt_l = 1
        else:
            cnt_r = 1
    elif last == '<':
        if s == '<':
            cnt_l += 1
        elif s == '>':
            cnt_r = 1
        else:
            res += cnt_l * (cnt_l + 1) // 2
    else:
        if s == '<':
            maxv = max(cnt_l, cnt_r)
            minv = min(cnt_l, cnt_r)
            res += maxv * (maxv+1) // 2
            if minv != 0:
                res += (minv-1) * minv // 2
            cnt_l = 1
            cnt_r = 0
        elif s == '>':
            cnt_r += 1
        else:
            maxv = max(cnt_l, cnt_r)
            minv = min(cnt_l, cnt_r)
            res += maxv * (maxv+1) // 2
            if minv != 0:
                res += (minv-1) * minv // 2


    last = s


print(res)


Measured memory_bytes: 7708
from sys import stdin

def main():
	N = int(stdin.readline().strip())
	i,card = 0,[-1 for x in range(N)]
	while i < N:
		x = int(stdin.readline().strip())
		card[i] = x
		i+=1
	i,ans = 0,0
	while i < N:
		if card[i]%2==0:
			ans+= card[i]//2
			card[i] = 0
		else:
			ans+=(card[i]-1)//2
			card[i] = 1
			if i+1 < N and card[i+1] >=1:
				ans+=1
				card[i],card[i+1] = 0, card[i+1]-1
		i+=1
	print(ans)
main()

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


int main()
{
    ll N;
    cin >> N;
    vector<vector<ll> > cor(N,vector<ll>(2));

    for(ll i=0;i<N;i++){
        cin >> cor.at(i).at(0) >> cor.at(i).at(1);
    }

    //経路が何通りあるのか
    ll tot=1;
    for(ll i=1;i<=N;i++){
        tot*=i;
    }
    ll tot_step=tot*2/N;

    double sum=0.;
    for(ll i=0;i<N-1;i++){
        for(ll j=i+1;j<N;j++){
            sum +=
            sqrt(
                (cor.at(i).at(0)-cor.at(j).at(0))*(cor.at(i).at(0)-cor.at(j).at(0))+
                (cor.at(i).at(1)-cor.at(j).at(1))*(cor.at(i).at(1)-cor.at(j).at(1))
                );
        }
    }

    cout << setprecision(15) << sum*(double)tot_step/(double)tot <<endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<cstdlib>
#include<string>
#include<cstring>
#include<algorithm>
#include<vector>
#include<map>
#include<iomanip>

using namespace std;

typedef long long ll;

typedef std::pair<int, int> ipair;
bool lessPair(const ipair& l, const ipair& r){return l.second < r.second;}
bool morePair(const ipair& l, const ipair& r){return l.second > r.second;}

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

const ll MOD = 1e9 + 7;
// const long long INF = 1LL<<60;
void add(long long &a, long long b) { a += b; if (a >= MOD) a -= MOD; }
void sub(long long &a, long long b) { a -= b; if (a < 0) a += MOD; }
void mul(long long &a, long long b) { a *= b; a %= MOD; }
ll llmin(ll a, ll b) { if (a < b) return a; else return b; }
ll llmax(ll a, ll b) { if (a < b) return b; else return a; }
ll llabs(ll a) { if (a >= 0) return a; else return - a; }
ll llmodpow(ll a, ll n) {
   if (n == 0) return 1;
   ll tmp = llmodpow(a, n / 2);
   mul(tmp, tmp);
   if (n & 1) mul(tmp, a);
   return tmp;
}

int main() {
   string S;
   cin >> S;
   ll N = S.size();
   map<char, int> log;
   for (int i = 0; i < N; i++) {
      log[S[i]]++;
   }
   ll ans = N * (N - 1) / 2;
   for (auto it = log.begin(); it != log.end(); it++) {
      ll n = it->second;
      ans -= n * (n - 1) / 2;
   }
   cout << ans + 1 << endl;
   return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define PI 3.14159265358979323
#define ll long long int
#define vi vector <int>
#define vl vector <ll>
#define all(v) (v).begin(),(v).end()
#define pb push_back
#define watch(x) cout << (#x) << " is " << (x) << "\n"
#define MOD 1000000007
ll power(ll a, ll b) { //a^b
	ll res = 1;
	while (b > 0) {
		if (b & 1) {res = (res * a); b--;}
		a = (a * a);
		b >>= 1;
	}
	return res;
}
ll n;
ll gcd(ll a, ll b) {return (b == 0) ? a : gcd(b, a % b);}


int main() {
	ll n;
	cin>>n;
	double p[n];
	for(ll i=0;i<n;i++)
		cin>>p[i];
	
	double dp[n+1][n+1];
	for(ll i=0;i<=n;i++)
		for(ll j=0;j<=n;j++)
			dp[i][j]=0;
	dp[0][0]=1;
	for(ll i=1;i<=n;i++){
		for(ll j=0;j<=i;j++){
			if(j==0)
				dp[i][j]=(1-p[i-1])*(dp[i-1][j]);
			else
				dp[i][j]=p[i-1]*dp[i-1][j-1]+(1-p[i-1])*dp[i-1][j];
		}
	}
	double sum=0;
	for(ll i=n/2+1;i<=n;i++)
		sum+=dp[n][i];
	printf("%0.10lf\n",sum);
}

Measured memory_bytes: 74016
N = int(input())
def make_divisors(n):
    divisors = []
    for i in range(1,int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n//i:
                divisors.append(n//i)

    return divisors
ans = 0
for i in range(N):
    if (i+1)%2==1:
        d = make_divisors(i+1)
        if len(d) == 8:
            ans += 1
print(ans)

Measured memory_bytes: 3060
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
 
int main(void){
	int N;
	int A,B;
	int i;
	int cond, count;

	int list[1000];
 
 	scanf("%d", &N);

 	for(i=0; i < N; i++){
 		scanf("%d", &list[i]);
 	}

 	cond = list[0];
 	count = 1;
	for(i=1; i < N; i++){
		if(cond <= list[i]){
			count++;
			cond = list[i];
		}
	}

	printf("%d\n", count);
 
	return 0;
}

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

int main() {
  int K;
  string s ;
cin >> K ;
  cin >> s;
  
  int c=0;
  int d=0;
  
  for (int i =0 ; i<K;i++){
    
   
    if (s[i] == 'I'){
      d += 1;
    }
    else if (s[i] == 'D'){
      d -= 1;
    }
    
    c =max(d,c);
  }
  cout << c <<endl;
    
}

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

using namespace std ;

const int MAX = 1e6 + 10 ;

int arr[MAX] , Plus[MAX] , Minus[MAX] ;
int n ;

bool cmp(int &i,int &j){
	if(Minus[i]==0&&Minus[j]==0){
		return Plus[i]>Plus[j];
	}
	else if(Minus[i]==0||Minus[j]==0){
		return Minus[i]<Minus[j];
	}
	else{
		if(Plus[i]-Minus[i]>0&&Plus[j]-Minus[j]>0){
			return Minus[i]<Minus[j];
		}
		else if(Plus[i]-Minus[i]>0||Plus[j]-Minus[j]>0){
			return Plus[i]-Minus[i]>Plus[j]-Minus[j];
		}
		else{
			if(Plus[i]>0&&Plus[j]>0){
				return Plus[i]-Minus[i]>Plus[j]-Minus[j];
			}
			else if(Plus[i]>0||Plus[j]>0){
				return Plus[i]>Plus[j];
			}
			else{
				Minus[i]<Minus[j];
			}
		}
	}
}
int main(){
	ios_base::sync_with_stdio(0) ;
	cin.tie(0);
	cin>>n;
	string s;
	vector<int> perm;
	for(int i=0;i<n;i++){
		cin>>s;
		int cnt=0;
		for(auto &c:s){
			if(c=='('){
				cnt++;
			}
			else{
				if(cnt==0){
					Minus[i]++;
				}
				cnt--;
				cnt=max(cnt,0);
			}
		}
		Plus[i]=cnt;
		perm.push_back(i);
	}
	sort(perm.begin(),perm.end(),cmp) ;
	int cnt=0;
	for(auto &i:perm){
		cnt-=Minus[i];
		if(cnt<0){
			cout<<"No"<<endl;
			return 0;
		}
		cnt+=Plus[i];
	}
	if(cnt==0){
		cout<<"Yes"<<endl;
		return 0;
	}
	else{
		cout<<"No"<<endl;
		return 0;
	}
	return 0 ;
}


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

const int MAXN = 105;
const int MAXW = 10e5+5;

int n, w, v[MAXN], b[MAXN];
long long dp[MAXN][MAXW];

int main() {
    ios::sync_with_stdio(false); cin.tie(0);
    cin >> n >> w;
    for (int i = 0; i < n; i++) cin >> b[i] >> v[i];
    for (int i = 0; i <= n; i++) {
        for (int j = 0; j <= w; j++) {
            if (i == 0 || j == 0) dp[i][j] = 0;
            else if (b[i-1] <= j) dp[i][j] = max(dp[i-1][j], v[i-1]+dp[i-1][j-b[i-1]]);
            else dp[i][j] = dp[i-1][j];
        }
    }
    cout << dp[n][w] << "\n";
    return 0;
}


Measured memory_bytes: 82892
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <string>
#include <cstdio>
#include <cstdlib>
#include <cmath>

using namespace std;

int main()
{
  long long int N;
  long long int A, B;
  cin >> N;

  if(N <= 7) {cout << 1 << endl; return 0;}

  A = -1; B = -1;
  for(int i = 7; i < (int)sqrt(N)+1; i += 2) {
    if(N % i == 0) {A = i; B = N / i;}
  }

  string a, b;
  if(A != -1) {
    a = to_string(A); b = to_string(B);
  } else {
    a = to_string(N); b = to_string(B);
  }
  cout << max(a.size(), b.size()) << endl;
  
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
long long n, W, wt[100], val[100], dp[100000];
int main(){
    cin.sync_with_stdio(0); cin.tie(0);
    cin >> n >> W;
    for (int i = 0; i < n; i++){
        cin >> wt[i] >> val[i];
    }
    for (int i = 0; i < n; i++){
        for (int j = W; j >= wt[i]; j--){
            dp[j] = max(dp[j], dp[j - wt[i]] + val[i]);
        }
    }
    cout << dp[W];
    return 0;
}

Measured memory_bytes: 1024
import java.io.*;

class Main{
    public static void main(String[] args) throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        
        String str = br.readLine();
        String strArr[] = str.split(" ");
        
        int w, h, x, y, r;
        
        w = Integer.parseInt(strArr[0]);
        h = Integer.parseInt(strArr[1]);
        x = Integer.parseInt(strArr[2]);
        y = Integer.parseInt(strArr[3]);
        r = Integer.parseInt(strArr[4]);
        
        if(x+r<=w && x-r>=0 && y+r<=h && y-r>=0){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }
    }
}

Measured memory_bytes: 24432
#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 pb emplace_back
typedef long long ll;
typedef pair<int,int> pint;

int n;
ll a[200001],cnt[200002][2];
int main(){
    cin>>n;
    rep(i,n){
        cin>>a[i];
        if(i-a[i]>=0) ++cnt[i-a[i]][0];
        if(i+a[i]<n) ++cnt[i+a[i]][1];
    }
    ll ans=0;
    rep(i,n) ans+=cnt[i][0]*cnt[i][1];
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 8348
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define REP(i,n) FOR(i,0,n)
#define FOR(i,a,b) for(int i=(a),i##Len_=(b);i<i##Len_;i++)
#define RFOR(i,a,b) for(int i=(a),i##End_=(b);i>=i##End_;i--)
template <class T> void chmax(T& a, const T& b) { if (b > a) a = b; }
const char* LF = "\n";
namespace{struct _{_(){
    cin.tie(0);
    ios::sync_with_stdio(false);
}}a;}

ll gcd(ll a, ll b)
{
	if (a < b) std::swap(a, b);
    if (b == 0) return a;
	while (ll c = a % b)
	{
		a = b;
		b = c;
	}
	return b;
}

signed main() {
    ll N;
    cin >> N;
    vector<ll> A(N);
    REP(i, N) { cin >> A[i]; }
    vector<ll> L(N+1, 0), R(N+1, 0);
    FOR(i, 1, N+1) L[i] = gcd(A[i-1], L[i-1]);
    RFOR(i, N-1, 0) R[i] = gcd(A[i], R[i+1]);

    ll ans = 0;
    REP(i, N) {
        chmax(ans, gcd(L[i], R[i+1]));
    }

    cout << ans << LF;

    return 0;
}


Measured memory_bytes: 2560
N = map( int , raw_input().split() )
 
if N[0] < N[1] < N[2] or N[0] == N[1] == N[2] or N[0] < N[1] == N[2] or N[0] == N[1] < N[2]:
  print "%d %d %d" %(N[0],N[1],N[2])
elif N[0] < N[2] < N[1]:
  print "%d %d %d" %(N[0],N[1],N[2])
elif N[1] < N[0] < N[2]:
  print "%d %d %d" %(N[1],N[0],N[2])
elif N[1] < N[2] < N[0] or N[1] < N[2] == N[0] or N[1] == N[2] < N[0]: 
  print "%d %d %d" %(N[1],N[2],N[0])
elif N[2] < N[0] < N[1] or N[2] < N[0] == N[1] or N[2] == N[0] < N[1]:
  print "%d %d %d" %(N[2],N[0],N[1])
elif N[2] < N[1] < N[0]:
  print "%d %d %d" %(N[2],N[1],N[0])

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

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

	int five = 0;
	int seven = 0;

	if (A == 5)
		five += 1;
	if (A == 7)
		seven += 1;
	if (B == 5)
		five += 1;
	if (B == 7)
		seven += 1;
	if (C == 5)
		five += 1;
	if (C == 7)
		seven += 1;

	if (five == 2 && seven == 1)
		cout << "YES" << endl;
	else
		cout << "NO" << endl;

}

Measured memory_bytes: 256
($n,$k)=glob<>;$k--;@X=glob<>;$m=1e20;
for(0..$n-$k-1){
    $c=(abs($X[$_])<abs($X[$_+$k]))?abs($X[$_]):abs($X[$_+$k]);
    $c+=abs($X[$_]-$X[$_+$k]);
    $m=($m<$c)?$m:$c;
}
print$m

Measured memory_bytes: 26880
import math
a,b,h,m = map(int,input().split())
n = 6 * m
t = 30 * h + 0.5 * m
d = abs(n - t)
if d > 360 - d:
    d = 360 -d
cc = a * a + b * b - 2 * a * b * (math.cos(math.radians(d)))
print(math.sqrt(cc))

Measured memory_bytes: 9508
#include <iostream>

using namespace std;

int min(int a, int b, int c)
{
    int m(a);
    
    if(b < m)
        m = b;
    if(c < m)
        m = c;
    
    return m;
}

int gcd(int a, int b, int c)
{
    int m = min(a, b, c);
    
    for(int i = m; i > 0; --i)
    {
        if((a % i == 0) and (b % i == 0) and (c % i == 0))
            return i;
    }
    
    return 1;
}

int main(int argc, char* argv[])
{
    int K(0);
    cin >> K;
    
    long result(0);
    
    for(int i(1); i <= K; ++i)
    {
        for(int j(1); j <= K; ++j)
        {
            for(int k(1); k <= K; ++k)
            {
                //cout << "gcd(" << i << ", " << j << ", " << k << ") =  " << gcd(i, j, k) << endl;
                result += gcd(i, j, k);
            }
        }
    }
    
    cout << result << endl;
    
    return 0;
}


Measured memory_bytes: 3228
#include<iostream>
#include<string>
using namespace std;
int main(){
  int n;
  char c[10][5];
  c[1][0] = '.';c[1][1] = ',';c[1][2] = '!';c[1][3] = '?';c[1][4] = ' ';
  c[2][0] = 'a';c[2][1] = 'b';c[2][2] = 'c';
  c[3][0] = 'd';c[3][1] = 'e';c[3][2] = 'f';
  c[4][0] = 'g';c[4][1] = 'h';c[4][2] = 'i';
  c[5][0] = 'j';c[5][1] = 'k';c[5][2] = 'l';
  c[6][0] = 'm';c[6][1] = 'n';c[6][2] = 'o';
  c[7][0] = 'p';c[7][1] = 'q';c[7][2] = 'r';c[7][3] = 's';
  c[8][0] = 't';c[8][1] = 'u';c[8][2] = 'v';
  c[9][0] = 'w';c[9][1] = 'x';c[9][2] = 'y';c[9][3] = 'z';
  cin >>n;
  while(n--){
    string s;
    cin >>s;
    for(int i=0,a=0,b=0; i<s.size(); i++){
      if(s[i] == '0' && a == 0) continue;
      else if(s[i] == '0' && a!=0){
	if(a == 1) b%=5;
	else if(a == 7 || a == 9) b%=4;
	else b%=3;
	cout <<c[a][b];
	a = 0;
	b = 0;
      }
      else if(s[i] != '0' && a == 0) a = s[i]-'0';
      else if(s[i] != '0' && a!=0) b++;
    }
    cout <<endl;
  }
  return 0;
}

Measured memory_bytes: 1204
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << x << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
typedef pair<int,int> P;
int p[800],d[800],deg[800];
vector<P> G[800];
int dfs(int v,int pp){
	int ret=0;
	for(P p:G[v]){
		int u=p.fs;
		if(u!=pp&&deg[u]>1) chmax(ret,dfs(u,v)+p.sc);
	}
	return ret;
}
int main(){
	while(true){
		int N;
		cin>>N;
		if(N==0) break;
		int s=0;
		rep(i,N) deg[i]=0,G[i].clear();
		rep(i,N-1) cin>>p[i];
		rep(i,N-1) cin>>d[i];
		rep(i,N-1){
			s+=d[i];
			p[i]--;
			G[i+1].pb(P(p[i],d[i]));
			G[p[i]].pb(P(i+1,d[i]));
			deg[i+1]++,deg[p[i]]++;
		}
		int s2=0;
		rep(i,N){
			if(deg[i]==1) continue;
			for(P p:G[i]) if(deg[p.fs]>1) s2+=p.sc;
		}
		int ans=0;
		rep(i,N) if(deg[i]>1) chmax(ans,dfs(i,-1));
		cout<<s+s2-ans<<endl;
	}
}

Measured memory_bytes: 1356
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#include <limits>
#include <sstream>
#include <fstream>
#include <climits>
#include <map>
#include <numeric>
#include <functional>
#include <utility>

using namespace std;

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

int main(void) {
  int h, w, a, b;
  cin >> h >> w >> a >> b;
  rep(y, h) {
    rep(x, w) {
      if (x < a && y < b || x >= a && y >= b) cout << 0;
      else cout << 1;
    }
    cout << endl;
  }
  return 0;
}


Measured memory_bytes: 1280
import sys

n = int(input())
# a = map(int, sys.stdin.read().split("\n"))
a = [int(input()) for i in range(n)]

d = dict()
for a_i in a:
	if a_i not in d:
		d[a_i] = 0
	d[a_i] = (d[a_i]+1) % 2

print(sum(d.values()))

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

namespace ABC149A
{
    class Program
    {
        static void Main(string[] args)
        {
            var word = Console.ReadLine().Split();
            string s = word[0];
            string d = word[1];
            Console.WriteLine(d + s);
            Console.ReadKey();
        }
    }
}


Measured memory_bytes: 11092
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;

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



		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();

		int k = sc.nextInt();

		ArrayList<Integer> list = new ArrayList<Integer>();
		for(int i =0;i<n;i++) {
			list.add(sc.nextInt());
		}
		Collections.sort(list);
		
		for(int i =0;i<Math.min(k, n);i++) {
			list.remove(list.size()-1);
		}
		long sum =0;
		for(int i=0;i<n-k;i++) {
			sum+=list.get(i);
		}
		System.out.println(sum);
	}

}
/*
class City{
	int order;
	int prefecture;
	int year;
	int number;
	City(int order,int prefecture, int year){
		this.order = order;
		this.prefecture = prefecture;
		this.year = year;
	}
}
*/


Measured memory_bytes: 78912
import java.util.Arrays;
import java.util.Scanner;
 
public class Main {
	public static void main (String[] args) {
      Scanner in = new Scanner(System.in);
      int N = in.nextInt();
      int[][] a = new int[N][3];
      for (int i = 0; i < N; i++) {
        a[i][0] = in.nextInt();
        a[i][1] = in.nextInt();
        a[i][2] = in.nextInt();
      }
      int[][] dp = new int[N][3];
      dp[0][0] = a[0][0];
      dp[0][1] = a[0][1];
      dp[0][2] = a[0][2];
      for(int i = 1; i< N ;i++){
        dp[i][0] = Math.max(dp[i-1][1] + a[i][0], dp[i-1][2] + a[i][0]);
        dp[i][1] = Math.max(dp[i-1][0] + a[i][1], dp[i-1][2] + a[i][1]);
        dp[i][2] = Math.max(dp[i-1][1] + a[i][2], dp[i-1][0] + a[i][2]);
      }
      System.out.println(Math.max(dp[N-1][0], Math.max(dp[N-1][1], dp[N-1][2])));
	}
}


Measured memory_bytes: 99060
# -*- coding: utf-8 -*-
import sys
import math
import os
import itertools
import string
import heapq
import _collections
from collections import Counter
from collections import defaultdict
from functools import lru_cache
import bisect
import re
import queue
from decimal import *


class Scanner():
    @staticmethod
    def int():
        return int(sys.stdin.readline().rstrip())

    @staticmethod
    def string():
        return sys.stdin.readline().rstrip()

    @staticmethod
    def map_int():
        return [int(x) for x in Scanner.string().split()]

    @staticmethod
    def string_list(n):
        return [input() for i in range(n)]

    @staticmethod
    def int_list_list(n):
        return [Scanner.map_int() for i in range(n)]

    @staticmethod
    def int_cols_list(n):
        return [int(input()) for i in range(n)]


class Math():
    @staticmethod
    def gcd(a, b):
        if b == 0:
            return a
        return Math.gcd(b, a % b)

    @staticmethod
    def lcm(a, b):
        return (a * b) // Math.gcd(a, b)

    @staticmethod
    def divisor(n):
        res = []
        i = 1
        for i in range(1, int(n ** 0.5) + 1):
            if n % i == 0:
                res.append(i)
                if i != n // i:
                    res.append(n // i)
        return res

    @staticmethod
    def round_up(a, b):
        return -(-a // b)

    @staticmethod
    def is_prime(n):
        if n < 2:
            return False
        if n == 2:
            return True
        if n % 2 == 0:
            return False
        d = int(n ** 0.5) + 1
        for i in range(3, d + 1, 2):
            if n % i == 0:
                return False
        return True


def pop_count(x):
    x = x - ((x >> 1) & 0x5555555555555555)
    x = (x & 0x3333333333333333) + ((x >> 2) & 0x3333333333333333)
    x = (x + (x >> 4)) & 0x0f0f0f0f0f0f0f0f
    x = x + (x >> 8)
    x = x + (x >> 16)
    x = x + (x >> 32)
    return x & 0x0000007f


MOD = int(1e09) + 7
INF = int(1e15)


def solve():
    N = Scanner.int()
    A = Scanner.map_int()
    B = [0] * N
    for i in reversed(range(N)):
        j = 1
        p = 0
        while True:
            n = j * (i + 1) - 1
            if n >= N:
                break
            p += B[n]
            j += 1
        if A[i] != p % 2:
            B[i] += 1
    ans = sum([b > 0 for b in B])
    print(ans)
    if ans > 0:
        for i, b in enumerate(B):
            if b == 1:
                print(i + 1, end=' ')
        print('')


def main():
    # sys.stdin = open("sample.txt")
    solve()


if __name__ == "__main__":
    main()


Measured memory_bytes: 94436
#include <bits/stdc++.h>
using namespace std;
#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 all(x) (x).begin(), (x).end()
#define sz(x) int(x.size())
#define get_unique(x) x.erase(unique(all(x)), x.end());
#define fout cout << fixed << setprecision(20)
typedef long long ll;
typedef complex<double> Complex;
const int INF = 1e9;
const ll MOD = 1e9 + 7;
const ll LINF = 1e18;
template <class T>
bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

int main() {
    ll n;
    cin >> n;
    vector<ll> v;
    for (ll d = 1; d * d <= n; d++) {
        if (n % d == 0) {
            v.push_back(d);
            if (d * d != n) v.push_back(n / d);
        }
    }

    vector<ll> w;
    ll p = n - 1;
    for (ll d = 2; d * d <= n; d++) {
        if (p % d > 0) continue;
        ll cnt = 0;
        while (p % d == 0) {
            p /= d;
            cnt++;
        }
        w.push_back(cnt);
    }
    if (p != 1) w.push_back(1);

    ll ans = 1;
    for (ll x : w) {
        ans *= x + 1;
    }
    for (ll k : v) {
        if (k == 1) continue;
        ll m = n;
        while (m % k == 0) {
            m /= k;
        }
        if (m % k == 1) ans++;
    }

    cout << ans - 1 << endl;
}


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

int main(){
    int n;
    cin >> n;
    vector<ll>a(n);
    rep(i,n) cin >>a[i];
    sort(a.begin(),a.end());
    cout << a[n-1]-a[0] << endl;
    return 0;
}


Measured memory_bytes: 256
import java.io.IOException;
import java.util.Scanner;

public class Main {

	static int mod = (int)Math.pow(10, 9)+7;

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

		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		long ans = 1;
		for (long i = 1; i <= n; i++) {
			ans = (ans*i)%mod;
		}
		System.out.println(ans);

	}

}


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

int main() {
    int a, b; cin >> a >> b;
    int cnt = 0;
    for (int x = a; x <= b; x++) {
        cnt += x / 10000 == x % 10 && x / 1000 % 10 == x / 10 % 10;
    }
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
        #include <chrono>
      
        using namespace std;
        using namespace std::chrono; 
     
        typedef long long int ll;
     
        #define MOD (ll)(1e9+7)
        #define endl "\n"
        #define pb push_back
        #define TEST_CASES  ll t;cin>>t;while(t--)
        #define forn(i,a,n) for (int i = a; i < n; ++i)
        #define f first
        #define s second
        #define all(x) x.begin(), x.end()


        
        ll powD(ll x,ll y){
          ll res = 1;
          while(y > 0){
            if(y & 1)
              res = (res*x);
            x = (x*x);
            y = y>>1;
          }
          return res;
        }
        int main()
        {
          ios_base::sync_with_stdio(false);
          cin.tie(NULL);
          ll n;
          cin>>n;
          ll mult = 26;
          string s = "";
          while(n > 0){
            n--;
            ll r = (n)%26;
            s += 'a' + r;
            n /= 26;
          }
          reverse(all(s));
          cout<<s<<endl;

        }

        
      


Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
#define rep1(i,N) for(int i=1;i<int(N);++i)
#define all(a) (a).begin(),(a).end()

#define print(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<_<<", "; cerr<<"]"<<endl; }
#define printpair(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<"{"<<_.first<<","<<_.second<<"}"<<", "; cerr<<"]"<<endl; }
#define dump(x) cerr<<#x<<": "<<x<<endl;

#define bit(k) (1LL<<(k))

typedef long long ll;

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

const int INF = (ll)1e9;
const ll INFLL = (ll)1e18;
const ll MOD = (ll)1e9+7;
const double PI = acos(-1.0);

const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

/*------------------------------------/
for library*/

/*------------------------------------*/

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);

    int N;
    cin>>N;
    cout<<(N+2-1)/2<<endl;
}

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

using namespace std;

#define ll long long
const int N = 2e6; 

int n,a[N],maxi,ans;

int main(){
	scanf("%d",&n);
	for(int i = 1; i <= n; i++){
		cin >> a[i];
		if(a[i] > ans){
			ans = a[i];
			maxi = i;
		} 
	}
	for(int i = 1; i <= n; i++){
		if(maxi == i){
			int tot = 0;
			for(int j = 1; j <= n; j++){
				if(j == i) continue;
				if(tot < a[j]) tot = a[j];	
			}
			cout << tot << endl;
		}
		else cout << ans << endl;
	}
} 

Measured memory_bytes: 2432
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
#include <ext/pb_ds/detail/standard_policies.hpp>

using namespace std;
using namespace __gnu_pbds;

typedef tree<int, null_type, less<int>, rb_tree_tag,
		tree_order_statistics_node_update> ordered_set;

#define el				'\n'
#define sz(v)			((int)((v).size()))
#define all(v)          ((v).begin()),((v).end())
#define clr(v, d)		memset(v, d, sizeof(v))

double const EPS = 1e-8, PI = acos(-1);
const int N = 1e5 + 9, M = 100 + 9, OO = (int) 1e6 + 1;
const long long MOD = 998244353;

typedef long long ll;

void OUTPUT() {
	cout << fixed << setprecision(12);
	ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
}

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

int main() {
	//INPUT();
	OUTPUT();
	int n, k;
	cin >> n >> k;
	vector<int> a(n);
	for (int i = 0; i < n; ++i) {
		cin >> a[i];
	}
	vector<bool> dp(k + 1);
	for (int stones = 0; stones <= k; ++stones) {
		for (int x : a) {
			if (stones >= x && !dp[stones - x]) {
				dp[stones] = 1;
			}
		}
	}
	cout << (dp[k] ? "First" : "Second");

	return 0;

}


Measured memory_bytes: 256
fun main(args: Array<String>) {
    val N = nextInt()
    val A = listOfLong()
    val X = LongArray(N)
    X[0] = A.reduceIndexed { n, acc, v -> if (n % 2 == 0) acc + v else acc - v }
    for (n in 0 until N - 1) X[n + 1] = 2 * A[n] - X[n]
    println(X.joinToString(separator = " "))
}
fun next() = readLine()!!
fun nextInt() = Integer.parseInt(next())
fun listOfString() = next().split(" ")
fun listOfLong(delta: Long = 0) = listOfString().map { it.toLong() + delta }

Measured memory_bytes: 59728
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <cctype>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <functional>

using namespace std;
using ll = long long int;
#define rep(i,n) for(int i = 0; i < n; i++)
#define FOR(i, a, b)  for(int i = (a); i < (b) ; i++)
#define pb push_back
#define SORT(v,n) sort(v, v+n)
#define ALL(x) (x).begin(),(x).end()
#define debug(x) cerr << #x << ": " << x << '\n'
#define elif else if
#define itn ll
#define int ll
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
///                →,↑,←,↓,↗,↖,↙,↘
int dx[8] = { 1, 0, -1, 0, 1, -1, -1, 1 };
int dy[8] = { 0, 1, 0, -1, 1, 1, -1, -1 };


signed main() {
	ios::sync_with_stdio(false);
	int i, n,k;
	string s;
	cin >> n >> s >> k;
	rep(i, n) {
		if (s[i] != s[k - 1])
			s[i] = '*';
	}
	cout << s << endl;
	return 0;
}

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

const int MaxN = 100005;

int n, m;
int du[MaxN], f[MaxN];

vector <int> son[MaxN];
queue <int> Q;

int main() {
	scanf("%d%d", &n, &m);
	for (int i = 1; i <= m; ++ i) {
		int x, y;
		scanf("%d%d", &x, &y);
		++ du[x]; son[y].push_back(x);
	}
	for (int i = 1; i <= n; ++ i)
		if (!du[i]) Q.push(i);
	while (!Q.empty()) {
		int u = Q.front(); Q.pop();
		for (auto v : son[u]) {
			f[v] = max(f[v], f[u] + 1);
			-- du[v];
			if (!du[v]) Q.push(v);
		}
	}
	int Ans = 0;
	for (int i = 1; i <= n; ++ i)
		Ans = max(Ans, f[i]);
	printf("%d\n", Ans);
	return 0;
}


Measured memory_bytes: 6528
#include<iostream>
#include<string.h>
#define ll long long int
#define f(i,a,b) for(ll i=a;i<b;i++)
#define fr(i,x,n) for(ll i=x;i>=n;i--)
#define mod 1e9+7
using namespace std;





int main()
{
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	string s;
	cin>>s;
	if(s=="ABC")
	cout<<"ARC\n";
	else
	cout<<"ABC\n";
	return 0;
}

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

int main(){
  int n;
  cin >>n;
  vector<char> a(n);
  rep(i,n) cin >>a[i];
  bool four = false;
  rep(i,n){
    if(a[i] == 'Y') {
      four = true;
      break;
    }
  }
  if(four) cout << "Four" << endl;
  else cout << "Three" << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; --i)
#define whole(x) (x).begin(),(x).end()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
using P = pair<int, int>;
#define debug(var) cerr << "[" << #var << "] " << var << endl
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
const ll mod = 1000000007;
const int dx[] = {-1,0,1,0};
const int dy[] = {0,-1,0,1};


int main(){
    int n;
    cin >> n;
    vector<int> d(n);
    rep(i, n) cin >> d[i];
    sort(whole(d));
    UNIQUE(d);
    int ans = d.size();
    
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3576
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
#include<complex>
#include<numeric>
using namespace std;

//#define int long long
typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = mod * mod;
typedef pair<int, int>P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
#define all(v) (v).begin(),(v).end()
typedef pair<ll, ll> LP;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-12;
const ld pi = acos(-1.0);
//typedef vector<vector<ll>> mat;
typedef vector<int> vec;

ll mod_pow(ll a, ll n, ll m) {
	ll res = 1;
	while (n) {
		if (n & 1)res = res * a%m;
		a = a * a%m; n >>= 1;
	}
	return res;
}

struct modint {
	ll n;
	modint() :n(0) { ; }
	modint(ll m) :n(m) {
		if (n >= mod)n %= mod;
		else if (n < 0)n = (n%mod + mod) % mod;
	}
	operator int() { return n; }
};
bool operator==(modint a, modint b) { return a.n == b.n; }
modint operator+=(modint &a, modint b) { a.n += b.n; if (a.n >= mod)a.n -= mod; return a; }
modint operator-=(modint &a, modint b) { a.n -= b.n; if (a.n < 0)a.n += mod; return a; }
modint operator*=(modint &a, modint b) { a.n = ((ll)a.n*b.n) % mod; return a; }
modint operator+(modint a, modint b) { return a += b; }
modint operator-(modint a, modint b) { return a -= b; }
modint operator*(modint a, modint b) { return a *= b; }
modint operator^(modint a, int n) {
	if (n == 0)return modint(1);
	modint res = (a*a) ^ (n / 2);
	if (n % 2)res = res * a;
	return res;
}

ll inv(ll a, ll p) {
	return (a == 1 ? 1 : (1 - p * inv(p%a, a)) / a + p);
}
modint operator/(modint a, modint b) { return a * modint(inv(b, mod)); }

const int max_n = 1 << 18;
modint fact[max_n], factinv[max_n];
void init_f() {
	fact[0] = modint(1);
	for (int i = 0; i < max_n - 1; i++) {
		fact[i + 1] = fact[i] * modint(i + 1);
	}
	factinv[max_n - 1] = modint(1) / fact[max_n - 1];
	for (int i = max_n - 2; i >= 0; i--) {
		factinv[i] = factinv[i + 1] * modint(i + 1);
	}
}
modint comb(int a, int b) {
	if (a < 0 || b < 0 || a < b)return 0;
	return fact[a] * factinv[b] * factinv[a - b];
}
using mP = pair<modint, modint>;

void solve() {
	ll h, w; cin >> h >> w;
	if (h == 1 || w == 1) {
		cout << 1 << endl; return;
	}
	ll ans = h * w;
	ans = (ans + 1) / 2;
	cout << ans << endl;
}


signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(7);
	//init_f();
	//init();
	//int t; cin >> t; rep(i, t)solve();
	solve();
	stop
		return 0;
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
#include <string.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, m, n) for(int i = m; i < n; i++) 
typedef long long int ll;
int main(){
    int N;
    cin>>N;
    vector<string>S(N);
    map<string,int>a;
    rep(i,N){
        cin>>S.at(i);
        if(a[S.at(i)]){
            a.at(S.at(i))++;
        }else{
            a[S.at(i)]=1;
        }
    }
    int max=0;
    rep(i,N){
        if(a.at(S.at(i))>max){
            max=a.at(S.at(i));
        }
    }
    set<string>b;
    vector<string>c;
    int count=0;
    rep(i,N){
        if(b.count(S.at(i))){
            continue;
        }
        if(max==a.at(S.at(i))){
            c.push_back(S.at(i));
            count++;
            b.insert(S.at(i));
        }
    }
    sort(c.begin(),c.end());
    rep(i,count){
        cout<<c.at(i)<<endl;
    }

    return 0;
}

Measured memory_bytes: 37744
#include<iostream>

using namespace std;

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

    bool travel = true;
    int t2=0, x2=0,y2=0;
    for (int i = 0; i < N;i++){
        int t1, x1, y1;
        cin >> t1 >> x1 >> y1;
        int t = t1 - t2;
        int d = abs(x2 - x1) + abs(y2 - y1);
        if(t<d||t%2!=d%2){
            travel = false;
        }
        t2 = t1;
        x2 = x1;
        y2 = y1;
    }
    if(travel)
        cout << "Yes";
    else
        cout << "No";
}

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

const int MOD = 1e9 + 7;



pair<LL, LL> intersect(pair<LL, LL> A, pair<LL, LL> B) {
  if (A.first > B.first) swap(A, B);
  return {B.first, min(A.second, B.second)};
}




int main() {
  ios_base::sync_with_stdio(false); cin.tie(0);
  int N, M;
  cin >> N >> M;
  pair<LL, LL> ans = {1, N + 1};
  for (int i = 0; i < M; ++i) {
    int L, R;
    cin >> L >> R;
    ans = intersect(ans, {L, R + 1});
  }
  cout << max(0ll, ans.second - ans.first) << '\n';
}


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

int main() {

  double W,H,x,y;
  cin >> W >> H >> x >> y;

  int can = 0;

  if(W / 2 == x && H / 2 == y) can = 1;

  printf("%.6lf %d", (H * W) / 2,can);
}


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

int main() {
    int N;
    cin >> N;
    N %= 10;
    string ans;
    if (N==2 or N==4 or N==5 or N==7 or N==9) {
        ans = "hon";
    }
    else if (N==0 or N==1 or N==6 or N==8) {
        ans = "pon";
    }
    else {
        ans = "bon";
    }
    cout << ans << endl;
}

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

using namespace std;
// template for creating 2d vector
template<typename T>
vector<vector<T>> make_2d_vector(size_t rows, size_t cols, T init)
{ return vector< vector<T> >(rows, vector<T>(cols, init)); }



#define debug(x) cout << #x << "==" << x << endl;

const int inf = 100000000;

typedef long long ll;

int main() {
  ios::sync_with_stdio(false);

  int N, W;
  cin >> N >> W;

  vector<int> v(N), w(N);
  for(int i = 0; i < N; i++) { cin >> v[i] >> w[i]; }

  // dp[i][j] := i???????????§?????????????????£??????j????¶?????????????????????????????????§
  auto dp = make_2d_vector(N+1, W+1, 0);

  for(int i = 0; i <= N; i++ ) {
    for(int j = 0; j <= W; j++) {

      if( i == 0 || j == 0 ) { dp[i][j] = 0; }

      else {
        if( w[i-1] <= j ) {
          dp[i][j] = max(dp[i-1][j-w[i-1]] + v[i-1], dp[i-1][j]);
        } else {
          dp[i][j] = dp[i-1][j];
        }
      }

    }
  }

  cout << dp[N][W] << "\n";

  return 0;
}

Measured memory_bytes: 6752
N = gets.to_i

data = []
N.times do
  data << gets.split.map(&:to_i)
end
positive_h_data = data.select do |d|
  d[2] > 0
end
zero_h_data = data.select do |d|
  d[2] == 0
end

found = false
0.upto(100) do |x|
  0.upto(100) do |y|
    h = []
    positive_h_data.each do |d|
      h << (d[0] - x).abs + (d[1] - y).abs + d[2]
    end
    if h.uniq.size == 1
      found = true
      zero_h_data.each do |d|
        if h.first > (d[0] - x).abs + (d[1] - y).abs
          found = false
          break
        end
      end
    end
    if found
      puts "#{x} #{y} #{h.first}"
    end

    break if found
  end

  break if found
end

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

using namespace std;

int main(){
	string str;
	cin>>str;
	bool flag=false;
	for(int i=0; i<str.length(); i++){
		if(str[i]=='C'){
			flag=true;
		}
		if(flag && str[i]=='F'){
			cout<<"Yes"<<endl;
			return 0;
		}
	}
	cout<<"No"<<endl;

	return 0;
}


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


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

int main()
{
	while(true){
		int a, b;
		cin>>a>>b;
		
		if(cin.eof())
			break;
			
		int g=gcd(a,b);
		cout<<g<<' '<<a/g*b<<endl;
	}
	return 0;
}

Measured memory_bytes: 3016
import java.util.Scanner;

public class Main {
	public static void main(String[]args){
		//????????£?????????????????????
		Scanner sc = new Scanner(System.in);
		//??\???????????????
		int X = sc.nextInt();
		//X???3???
		int XX = X * X * X;
		//??¨???
		System.out.println(XX);
	}
}

Measured memory_bytes: 26088
//#include <tourist>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> p;
const int INF = 1e9;
const ll LINF = ll(1e18) + 1;
const int MOD = 1000000007;
const int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0};
const int Dx[8] = {0, 1, 1, 1, 0, -1, -1, -1}, Dy[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
#define rep(i, n) for (int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()
#define debug(v)          \
    cout << #v << ":";    \
    for (auto x : v)      \
    {                     \
        cout << x << ' '; \
    }                     \
    cout << endl;
template <class T>
bool chmax(T &a, const T &b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b)
{
    if (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}
//cout<<fixed<<setprecision(15);有効数字15桁
//-std=c++14
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
ll n, m,k;
vector<vector<ll>> v;
void write_r(){
    ll sum=0;
    rep(i,n){
        sum+=v[i].size();
    }
    cout<<sum<<"\n";
    rep(i,n){
        rep(j,v[i].size()){
            cout<<i+1<<" "<<v[i][j]+1<<"\n";
        }
    }
}
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n>>k;
    ll now=(n-2)*(n-1)/2;
    if((n-2)*(n-1)/2<k)return cout<<-1<<"\n",0;
    v.resize(n);
    for(int i=1;i<n;i++){
        v[0].push_back(i);
    }
    for(int i=1;i<n;i++){
        for(int j=i+1;j<n;j++){
            if(now==k){
                write_r();
                return 0;
            }
            now--;
            v[i].push_back(j);
        }
    }
    write_r();
}


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

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF = (1<<30) - 1;
const ll LINF = (1LL<<60) - 1;

int main(){
    int a, b;
    cin >> a >> b;
    cout << max(0, a - 2 * b) << endl;
}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
#define de(x) cout << #x << "=" << x << ", "
#define dd cout << '\n';
#define XinAi ios::sync_with_stdio(0), cin.tie(0);
#define F first
#define S second
#define int long long
using namespace std;
typedef pair<int,int> pii;

int a[1000000];

signed main()
{
    int n;
    int res = 0;
    cin >> n;
    for (int i=0; i<n; i++) cin >> a[i];
    for (int i=1; i<n; i++)
    {
        if (a[i] < a[i-1])
        {
            res += a[i-1] - a[i];
            a[i] = a[i-1];
        }
    }
    cout << res << '\n';
}

Measured memory_bytes: 5152