akhauriyash/Code-Regression huggingface dataset:
/*
	atcoder ARC094
	F Normalization
*/
#include <bits/stdc++.h>
typedef long long ll;
const ll P = 998244353;
const int N = 2e5 + 5;
inline void up(int &x, int y) { x < y ? x = y : 0; }
inline void down(int &x, int y) { x > y ? x = y : 0; }
inline int max(const int x, const int y) { return x > y ? x : y; }
inline int min(const int x, const int y) { return x < y ? x : y; }

inline void mod(ll &x) { x >= P ? x -= P : x; }

std::string str;
std::set < std::string > s;
int n;
ll dp[N][3][3][2];
inline bool all_equal(std::string str) {
	for (int i = 0; i < n; ++i)
		if (str[i] != str[0]) return false;
	return true;
}
inline void bfs(std::string str) {
	if (s.count(str)) return;
	s.insert(str);
	for (int i = 0; i < n - 1; ++i) 
		if (str[i] != str[i + 1]) {
		std::string t = str;
		if (str[i] != 'a' && str[i + 1] != 'a') t[i] = t[i + 1] = 'a';
		if (str[i] != 'b' && str[i + 1] != 'b') t[i] = t[i + 1] = 'b';
		if (str[i] != 'c' && str[i + 1] != 'c') t[i] = t[i + 1] = 'c';
		bfs(t);
	}
} 

inline ll dp_solve() {
	int s1 = 0;
	for (int i = 0; i < n; ++i) s1 += str[i] - 'a';
	s1 %= 3;
	for (int i = 0; i < 3; ++i) dp[0][i][i][0] = 1;
	for (int i = 0; i < n - 1; ++i)
		for (int s0 = 0; s0 < 3; ++s0)
			for (int now = 0; now < 3; ++now)
				for (int type = 0; type <= 1; ++type)
					for (int nxt = 0; nxt < 3; ++nxt) 
						mod(dp[i + 1][(s0 + nxt) % 3][nxt][type | (now == nxt)] += dp[i][s0][now][type]);
	ll ans = 0;
	for (int i = 0; i < 3; ++i) mod(ans += dp[n - 1][s1][i][1]);
	int ok = 0;
	for (int i = 1; i < n; ++i)
		if (str[i] == str[i - 1]) ok = 1;
	if (! ok) mod(ans += 1);
	return ans; 
}
int main() {
    std::ios::sync_with_stdio(false), std::cin.tie(0);
    std::cin >> str;
    n = str.size();
    if (all_equal(str)) return std::cout << 1 << '\n', 0;
    if (n < 4) bfs(str), std::cout << s.size() << '\n';
    else std::cout << dp_solve() << '\n';
	return 0;
}


Measured memory_bytes: 31876
#coding:utf-8
import sys,os
from collections import defaultdict, deque
from fractions import gcd
from math import ceil, floor
sys.setrecursionlimit(10**6)
write = sys.stdout.write
dbg = (lambda *something: print(*something)) if 'TERM_PROGRAM' in os.environ else lambda *x: 0
def main(given=sys.stdin.readline):
    input = lambda: given().rstrip()
    LMIIS = lambda: list(map(int,input().split()))
    II = lambda: int(input())
    XLMIIS = lambda x: [LMIIS() for _ in range(x)]
    YN = lambda c : print('Yes') if c else print('No')
    MOD = 10**9+7
    N = II()
    A = LMIIS()
    print('YES' if len(A) == len(set(A)) else 'NO')

    

if __name__ == '__main__':
    main()

Measured memory_bytes: 126876
#include <bits/stdc++.h>
using namespace std;
#define GET_MACRO(_1, _2, _3, NAME, ...) NAME
#define _repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define _rep(i,n) _repl(i,0,n)
#define rep(...) GET_MACRO(__VA_ARGS__, _repl, _rep)(__VA_ARGS__)
#define mp(a,b) make_pair((a),(b))
#define pb(a) push_back((a))
#define all(x) (x).begin(),(x).end()
#define uniq(x) sort(all(x)),(x).erase(unique(all(x)),end(x))
#define fi first
#define se second
#define dbg(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
void _dbg(string){cout<<endl;}
template<class H,class... T> void _dbg(string s,H h,T... t){int l=s.find(',');cout<<s.substr(0,l)<<" = "<<h<<", ";_dbg(s.substr(l+1),t...);}
template<class T,class U> ostream& operator<<(ostream &o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream &o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

#define INF 1120000000

int solve(){
  string s;
  cin>>s;
  int n = s.size();

  int mask = 0;
  map<int,int> dp;
  dp[0] = 0;
  rep(p,n){
    mask = mask ^ (1<<(s[p]-'a'));
    if(dp.count(mask)==0) dp[mask] = INF;
    rep(i,26){
      int nm = mask^(1<<i);
      if(dp.count(nm)==0) continue;
      dp[mask] = min(dp[nm]+1, dp[mask]);
    }
  }
  return max(dp[mask], 1);
}

int main(){
  cout << solve() << endl;

  return 0;
}


Measured memory_bytes: 9860
using System;
using System.Collections.Generic;
using System.Linq;

namespace AtcoderCS
{
    class Program
    {
        static void Main(string[] args)
        {
            long N = long.Parse(Console.ReadLine());
            string s = Console.ReadLine();

            var A = s.Split().Select(a => long.Parse(a)).ToArray();

            Dictionary<long, long> participants = new Dictionary<long, long>();

            long size = A.Length;
            long total = 0;

            for(long i = 0; i < size; i++)
            {
                long key = (i + 1) - A[i];

                if (participants.ContainsKey(key))
                {
                    total += participants[key];
                }

                long key2 = (i + 1) + A[i];

                if (participants.ContainsKey(key2))
                {
                    participants[(i + 1) + A[i]]++;
                }
                else
                {
                    participants.Add(key2, 1);
                }
            }

            Console.WriteLine(total);
        }
    }
}


Measured memory_bytes: 57236
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
ll a[200005], n, ma[200005], sum=0;
int main() {
   cin >> n;
   for (int i=0; i<n; i++) cin >> a[i];
   ma[0]=a[0];
   for (int i=1; i<n; i++) {
       ma[i]=max(ma[i-1], a[i]);
       sum+=ma[i]-a[i];
   }
   
   cout << sum;
}

Measured memory_bytes: 6760
/*
	0160:Delivery Fee
*/

#include	<iostream>

using namespace std;

int main(void) {
	int dataset;
	while(1) {
		int x, y, h, l, w, m = 0;
		
		cin >> dataset;
		if(dataset == 0) { break; }
		for(int i = 0; i < dataset; i++) {
			cin >> x >> y >> h >> w;
			l = x + y + h;
			if(     l <=  60 && w <=  2) { m +=  600; }
			else if(l <=  80 && w <=  5) { m +=  800; }
			else if(l <= 100 && w <= 10) { m += 1000; }
			else if(l <= 120 && w <= 15) { m += 1200; }
			else if(l <= 140 && w <= 20) { m += 1400; }
			else if(l <= 160 && w <= 25) { m += 1600; }
		}
		cout << m << endl;
	}
	return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <map>
#include <list>
#include <stack>
#include <algorithm>
#include <math.h>

using namespace std;

#define dump(x) cout << (x) << endl;
typedef long long Int;

Int mod = 1e9+7;
Int MOD = 998244353;

int main() {
    Int N, W;
    cin >> N >> W;
    vector<Int> a[4];
    Int w, v;
    cin >> w >> v;
    a[0].push_back(v);
    for (Int i = 0; i < N-1; i++) {
        Int x, y;
        cin >> x >> y;
        a[x-w].push_back(y);
    }
    for (Int i = 0; i < 4; i++) {
        sort(a[i].begin(), a[i].end(), greater<Int>());
        for (Int j = 0; j < (Int)a[i].size()-1; j++) {
            a[i][j+1] += a[i][j];
        }
    }
    Int res = 0;
    for (Int i = 0; i <= a[0].size(); i++) {
        if (i*w > W) continue;
        for (Int j = 0; j <= a[1].size(); j++) {
            if (i*w + j*w > W) continue;
            for (Int k = 0; k <= a[2].size(); k++) {
                if (i*w + j*(w+1) + k*(w+2) > W) continue;                
                for (Int l = 0; l <= a[3].size(); l++) {
                   if (i*w + j*(w+1) + k*(w+2) + l*(w+3)> W) continue;
                    Int x = 0;
                    if (i > 0) x += a[0][i-1];
                    if (j > 0) x += a[1][j-1];
                    if (k > 0) x += a[2][k-1];
                    if (l > 0) x += a[3][l-1];
                    res = max(res, x);
                }
            }
        }
    }
    dump(res);
    return 0;
}  

Measured memory_bytes: 256
n, m = [int(x) for x in input().split()]
a = set(int(input()) for _ in range(m))

mod = 10 ** 9 + 7

dp = [0] * (n + 1)
dp[0] = 1
for i in range(1, n + 1):
    if i in a:
        continue
    if i >= 2:
        dp[i] = (dp[i - 1] + dp[i - 2]) % mod
    else:
        dp[i] = dp[i - 1]
print(dp[-1])


Measured memory_bytes: 11884
import itertools as ite
import math
import random

INF = 10 ** 18
MOD = 10 ** 9 + 7

N = input()
A = map(int, raw_input().split())
B = map(int, raw_input().split())
C = map(int, raw_input().split())
ls = []
for num in A:
    ls += [(num, 2)]
for num in B:
    ls += [(num, 1)]
for num in C:
    ls += [(num, 0)]
ls.sort()

sumA = sumB = 0
ans = 0
for num, tp in ls:
    if tp == 0:
        ans += sumB
    elif tp == 1:
        sumB += sumA
    else:
        sumA += 1
print ans


Measured memory_bytes: 39992
/*
  ->->->->->-> Vora Mahammadasim <-<-<-<-<-<-
*/
#include<bits/stdc++.h>
#include<stdio.h>
#define int long long
#define pb emplace_back
#define Mod 1000000007
#define all(a) a.begin(),a.end()
using namespace std;
signed main(){

    ios::sync_with_stdio(false);
    cin.tie(0);
    int n,k;
    cin>>n>>k;
    map<int,int>m;
    for(int i=0;i<k;i++){
        int s;
        cin>>s;
        for(int j=0;j<s;j++){
            int x;
            cin>>x;
            m[x] = true;
        }
    }
    cout<<n-m.size();
}


Measured memory_bytes: 3656
#include<bits/stdc++.h>
using namespace std; 
#define mod 1000000007
#define INF 0x3f3f3f3f
#define all(x) (x).begin(),(x).end()
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define endl "\n" 
#define pb push_back
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define mp make_pair
#define print(v); for(auto x:v) cout<<x<<" "; cout<<endl;
typedef long long int ll;
int main()
{
    fast;
    long double a, b;
    cin >> a >> b;
    for(long double i = 1; i <= 10000000; i++){
        if(floor(i * 0.08) == a && floor(i * 0.1) == b){
            cout << i << endl;
            return 0;
        }
    }
    cout << -1 << endl;


    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>

using namespace std;

uint64_t gcd(uint64_t a, uint64_t b)
{

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

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

    uint64_t T[100] = {0};
    for (int i=0; i < N; i++) {
        cin >> T[i];
    }

    uint64_t c = T[0];
    for (int i=1; i < N; i++) {
        c = c * (T[i] / gcd(T[i], c));
    }

    cout << c << endl;
    return 0;
}


Measured memory_bytes: 764
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
#include <cstdlib>
#include <cmath>

typedef long long ll;

using namespace std;

int main() {
    int a, b, ans = 0;
	cin >> a >> b; 

	if (a <= 0 || a >= 10 || b <= 0 || b >= 10 ) {
		cout << -1 << endl;
	} else {
		ans = a * b;
		cout << ans << endl;
	}
}

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

using namespace std;

int main() {
  int H, W, N;
  cin >> H >> W >> N;
  vector<int> a(N), ans(H * W);
  for (int i = 0; i < N; ++i) cin >> a[i];
  int pt = 0;
  for (int i = 0; i < H; ++i) {
    for (int j2 = 0; j2 < W; ++j2) {
      int j = (i % 2 == 0 ? j2 : W - 1 - j2);
      if (a[pt] == 0) pt++;
      ans[i * W + j] = pt + 1;
      a[pt]--;
    }
    for (int j = 0; j < W; ++j) cout << ans[i * W + j] << " ";
    cout << endl;
  }
  return 0;
}

Measured memory_bytes: 384
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<unordered_map>
#include<queue>
#include<cmath>
#include<string>
typedef long long ll;


using namespace std;

vector<string> permute(int N){
    if(N==1){return vector<string>{"1"};}
    auto bef = permute(N-1);
    vector<string> res;
    for(auto s:bef){
        for(int i=0;i<N;i++){
            string ne=s;
            ne.insert(ne.begin()+i, '0'+N);
            res.push_back(ne);
        }
    }
    return res;
}
int pow10(int n){
    if(n == 0){return 1;}
    return pow10(n-1)*10;
}

int main(){
    int N;
    cin >> N;
    vector<string> per=permute(N);
    vector<int> pi(per.size(),0);
    for(int k=0;k<per.size();k++){
        pi[k]=stoi(per[k]);
    }
    sort(pi.begin(),pi.end());
    unordered_map<int, int> num;
    for(int i=0;i<pi.size();i++){
        num[pi[i]] = i;
    }

    int P=0, Q=0;
    for(int i=0;i<N;i++){
        int p;
        cin >> p;
        P += pow10(N-i-1)*p;
    }
    for(int i=0;i<N;i++){
        int q;
        cin >> q;
        Q += pow10(N-i-1)*q;
    }
    cout << abs(num[P] - num[Q]);


    return 0;
}


Measured memory_bytes: 4344
#include<cstdio>
#include<algorithm>
using namespace std;
const int maxn = 1e5 + 7;
int a[maxn];
int main(){
    int n, k;
    scanf("%d%d", &n, &k);
    int cnt = -1;
    for(int i = 0; i < n; ++i){
        scanf("%d", &a[i]);
        if(a[i] >= 0 && cnt == -1){
            cnt = i;
        }
    }
    //a[cnt] >= 0
    if(cnt == -1){
        printf("%d\n", -a[n - k]);
        return 0;
    }
    else if(cnt == 0){
        printf("%d\n", a[k - 1]);
        return 0;
    }

    int ans = 2e9;
    if(cnt - k >= 0){
        ans = min(ans, -a[cnt - k]);
    }
    if(cnt + k - 1 < n){
        ans = min(ans, a[cnt + k - 1]);
    }
    for(int i = 1; i < k; ++i){
        if(cnt - i < 0 || cnt + k - i - 1 >= n)
            continue;
            ans = min(ans, -2*a[cnt - i] + a[cnt + k - i - 1]);
    }
    for(int i = 1; i < k; ++i){
        if(cnt + i - 1 >= n || cnt - k + i < 0)
            continue;
        ans = min(ans, 2*a[cnt + i - 1] - a[cnt - k + i]);
    }
    printf("%d\n", ans);
}


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

// c++11
#include <array>
#include <tuple>
#include <unordered_map>
#include <unordered_set>

#define mp make_pair
#define mt make_tuple
#define rep(i, n) for (int i = 0; i < (n); i++)

using namespace std;

using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;

const int INF = 1 << 29;
const double EPS = 1e-9;
const ll MOD = 1000000007;

const int dx[] = {1, 0, -1, 0}, dy[] = {0, -1, 0, 1};
vector<ll> cookies;
ll sum_cookie;
set<pair<ll, ll>> memo;
int main() {
  cookies.resize(3);
  for (auto &val : cookies){
    cin >> val;
    sum_cookie += val;
  }
  sort(cookies.begin(), cookies.end());
  int result = 0;
  while (true){
    bool is_over = false;
    for (auto &val : cookies){
      if (val % 2 != 0){
        is_over = true;
        break;
      }
    }
    if (is_over){
      break;
    }
    if (memo.count(mp(cookies[0], cookies[1]))){
      result = -1;
      break;
    }
    memo.emplace(mp(cookies[0], cookies[1]));
    result++;
    vector<ll> next;
    next.push_back(cookies[1] / 2 + cookies[2] / 2);
    next.push_back(cookies[0] / 2 + cookies[2] / 2);
    next.push_back(cookies[0] / 2 + cookies[1] / 2);
    sort(next.begin(), next.end());
    cookies = move(next);
  }
  cout << result << endl;
  return 0;
}


Measured memory_bytes: 256
a,b,c,x,y=map(int,input().split())

if a+b <= c*2:
    print(a*x +b*y)
else:
    if x>y:
        i=a
    elif x<y:
        i=b
    else:
        i=0
    
    p=min(x,y)*c*2 + abs(x-y)*i
    q=max(x,y)*c*2
    
    if p >= q:
        print(q)
    else:
        print(p)

Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <functional>
#include <bitset>
#include <cassert>
#include <random>
using namespace std;
using ll = long long;


int main() {
	int a, b; cin >> a >> b;
	for (int i = 1; i <= 100000; i++) {
		int ia = 8 * i / 100;
		int ib = 10 * i / 100;
		if (ia == a && ib == b) {
			cout << i << endl;
			return 0;
		}
	}
	cout << -1 << endl;
	return 0;
}


Measured memory_bytes: 256
n = int(input())
A = [0]*n
B = [0]*n
for i in range(n):
    a,b = map(int, input().split())
    A[i] = a
    B[i] = b
A.sort()
B.sort(reverse=True)
if n%2 == 1:
    ans = B[(n+1)//2-1]-A[(n+1)//2-1]+1
    print(ans)
else:
    y = A[n//2-1] + A[n//2]
    x = B[n//2-1] + B[n//2]
    ans = x-y+1
    print(ans)

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

ll a[100005];
const ll MOD=1000000007;

int main(){
    ll n; cin >> n;
    for(ll i=0;i<n;i++){
        cin >> a[i];
    }
    ll pos[3]={0,0,0};
    ll ans=1;
    for(ll i=0;i<n;i++){
        ll cnum=0;
        ll cpos=-1;
        for(ll j=0;j<3;j++){
            if(a[i]==pos[j]){cnum++;cpos=j;}
        }
        ans*=cnum;
        ans%=MOD;
        pos[cpos]++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 3e3 + 5;
int dp[MAXN][MAXN];
int par[MAXN][MAXN];
string s, t;
int lcs(int i, int j){
    if(i < 0 || j < 0) return 0;
    if(dp[i][j] != -1) return dp[i][j];
    int k = lcs(i, j - 1);
    int p = lcs(i - 1, j);
    int res = max(k, p);
    par[i][j] = 1;
    if(k > p) par[i][j] = 0;
    if(s[i] == t[j]){int tmp = res; res = max(res, lcs(i - 1, j - 1) + 1); if(tmp < res) par[i][j] = 2;}
    dp[i][j] = res;
    return res;
}
int main(){
    cin >> s >> t;
    memset(dp, -1, sizeof(dp));
    int n = s.size();
    int m = t.size();
    lcs(n - 1, m - 1);
    string ans = "";
    int i = n - 1, j = m - 1;
    while(i >= 0 && j >= 0){
        if(par[i][j] == 2){ ans += s[i]; i--, j--;}
        else{
            if(par[i][j] == 1) i--;
            else j--;
        }
    }
    reverse(ans.begin(), ans.end());
    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 71296
N = int(input())
A = list(map(int, input().split()))
if abs(max(A)) >= abs(min(A)):
    max_idx = A.index(max(A))
    print(2 * N - 1)
    for i in range(N):
        print(max_idx + 1, i + 1)
    for i in range(N - 1):
        print(i + 1, i + 2)
else:
    min_idx = A.index(min(A))
    print(2 * N - 1)
    for i in range(N):
        print(min_idx + 1, i + 1)
    for i in range(N, 1, -1):
        print(i, i - 1)


Measured memory_bytes: 9080
n=int(input())
al=list(map(int,input().split()))

from collections import Counter
myc=Counter(al)
val=list(myc.values())
key=list(myc.keys())
val2=list(map(lambda x:x-1,val))

nc2=[0]*n
nc22=[0]*n

for i in range(len(key)):
    p=val[i]
    q=val2[i]
    if q>=2:
        nc2[key[i]-1]=p*(p-1)//2
        nc22[key[i]-1]=q*(q-1)//2
    elif q==1:
        nc2[key[i]-1]=1
        nc22[key[i]-1]=0
    else:
        pass

sum1=sum(nc2)

for i in range(n):
    j=al[i]-1
    print(sum1-nc2[j]+nc22[j])

Measured memory_bytes: 95820
from collections import deque
from heapq import heapify,heappop,heappush,heappushpop
from copy import copy,deepcopy
from itertools import product,permutations,combinations,combinations_with_replacement
from collections import defaultdict,Counter
from bisect import bisect_left,bisect_right
from math import gcd,ceil,floor,factorial
# from fractions import gcd
from functools import reduce
from pprint import pprint
from statistics import mean,median,mode

INF = float("inf")

def mycol(data,col):
    return [ row[col] for row in data ]

def mysort(data,col,reverse_flag):
    data.sort(key=lambda x:x[col],reverse=reverse_flag)
    return data

def mymax(data):
    M = -1*float("inf")
    for i in range(len(data)):
        m = max(data[i])
        M = max(M,m)
    return M

def mymin(data):
    m = float("inf")
    for i in range(len(data)):
        M = min(data[i])
        m = min(m,M)
    return m

def mycount(ls,x):
    # lsはソート済みであること
    l = bisect_left(ls,x)
    r = bisect_right(ls,x)
    return (r-l)

def myoutput(ls,space=True):
    if space:
        if len(ls)==0:
            print(" ")
        elif type(ls[0])==str:
            print(" ".join(ls))
        elif type(ls[0])==int:
            print(" ".join(map(str,ls)))
        else:
            print("Output Error")
    else:
        if len(ls)==0:
            print("")
        elif type(ls[0])==str:
            print("".join(ls))
        elif type(ls[0])==int:
            print("".join(map(str,ls)))
        else:
            print("Output Error")

def I():
    return int(input())

def MI():
    return map(int,input().split())

def RI():
    return list(map(int,input().split()))

def CI(n):
    return [ int(input()) for _ in range(n) ]

def LI(n):
    return [ list(map(int,input().split())) for _ in range(n) ]

def S():
    return input()

def MS():
    return input().split()

def RS():
    return list(input())

def CS(n):
    return [ input() for _ in range(n) ]

def LS(n):
    return [ list(input()) for _ in range(n) ]

ddict = defaultdict(lambda: 0)
# ddict = defaultdict(lambda: 1)
# ddict = defaultdict(lambda: int())
# ddict = defaultdict(lambda: list())
# ddict = defaultdict(lambda: float())

n = I()
a = CI(n)

for i in range(n):
    ddict[a[i]] += 1
# print(ddict.items())
    
ans = 0
for t in ddict.items():
    m = t[0]
    c = t[1]
    if c%2==0:
        pass
    else:
        ans += 1
print(ans)

Measured memory_bytes: 98828
#include<iostream>
#include<vector>
#include<set>
#include<bitset>
using namespace std;

vector<set<int>> lose;
bitset<5000> visited;
vector<int> order;
int size;

void dfs(const int i) {
    if(visited[i]) return;
    visited.set(i);
    for(const auto j: lose[i]) dfs(j);
    order[size++] = i;
}

bool unique(const int depth) {
    if(depth == 0) return true;
    if(lose[order[depth]].count(order[depth - 1])) return unique(depth - 1);
    return false;
}

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

    lose.resize(n);
    order.resize(n);

    while(m-- > 0) {
        int w, l;
        cin >> w >> l;
        --w; --l;
        lose[l].insert(w);
    }

    for(int t = 0; t < n; ++t) dfs(t);
    for(const auto i: order) cout << i + 1 << endl;
    cout << (unique(n - 1) ? 0 : 1) << endl;
}

Measured memory_bytes: 6016
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")

def main():
    input()
    aa=list(map(int,input().split()))
    print(min(aa),max(aa),sum(aa))

main()



Measured memory_bytes: 6568
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int n,m,ans,a[3002],b[3002],s[3002][3002];
inline int read()
{
    int sum=0,x=1;
    char ch=getchar();
    while (!isdigit(ch))
	{
        if (ch=='-')
		  x=-1;
        ch=getchar();
    }
    while (isdigit(ch))
	{
        sum=(sum<<1)+(sum<<3)+(ch^'0');
        ch=getchar();
    }
    return sum*x;
}
inline void write(int x)
{
    if (x<0)
	{
        putchar('-');
        x=-x;
    }  
    if (x>9)
      write(x/10);
    putchar(x%10+'0');
}
inline int sr(int x,int y)
{
	return (ll)a[x]*b[y]%m*b[x-y]%m;
}
inline int power(int x,int y,int z)
{
    int ss=1;
    while (y)
    {
        if (y%2==1)
		  ss=(ll)ss*x%z;
        x=(ll)x*x%z;
		y>>=1;
    }
    return ss;
}
int main()
{
    n=read();m=read();
    a[0]=a[1]=b[0]=b[1]=1;
    for (register int i=2;i<=n;++i)
	{
		a[i]=(ll)a[i-1]*i%m;
	    b[i]=(ll)(m-m/i)*b[m%i]%m;
	}
    for (register int i=2;i<=n;++i)
	  b[i]=(ll)b[i-1]*b[i]%m;
    s[0][0]=1;
    for (register int i=1;i<=n+1;++i)
      for (register int j=1;j<=i;++j)
        (s[i][j]=s[i-1][j-1]+(ll)s[i-1][j]*j%m)%=m;
    int ans=0;
    for (register int i=0;i<=n;++i)
    {
        int ss=0;
        for (register int j=0;j<=i;++j)
          (ss+=(ll)power(power(2,n-i,m),j,m)*s[i+1][j+1]%m)%=m;
        ss=(ll)ss*power(2,power(2,n-i,m-1),m)%m*sr(n,i)%m;
        if (i%2==1)
		  (ans-=ss)%=m;else
		  (ans+=ss)%=m;
    }
    write((ans+m)%m);
    return 0;
}

Measured memory_bytes: 31132
#include<bits/stdc++.h>
using namespace std;
int main() {
    int x,n;
    cin>>x>>n;

    vector<int>v(n);
    map<int,int> m ;

    for(int i=0; i<n; ++i) {
        cin>>v[i];
        m[v[i]]++;
    }
    int z = 0;
    if(n==0) {
        cout<<x;
        return 0;
    }
    while(1) {
        if(m[x-z] == 0) {
            cout<<x-z;
            break;
        }
        if(m[x+z] == 0) {
            cout<<x+z;
            break;
        }

        z++;
    }
}



Measured memory_bytes: 3644
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <unordered_map>
using namespace std;

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

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...));
}
template<class T, class V>
typename enable_if<is_class<T>::value == 0>::type fill(T &t, const V &v) {
    t = v;
}
template<class T, class V>
typename enable_if<is_class<T>::value != 0>::type fill(T &t, const V &v){
    for (auto &e : t) fill(e, v);
}

#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }

#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
template<class T> ostream& operator << (ostream &s, set<T> P)
{ EACH(it, P) { s << "<" << *it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }




int N;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    while (cin >> N) {
        vector<long long> d(N);
        for (int i = 0; i < N; ++i) cin >> d[i];

        sort(d.begin(), d.end());
        long long left = d[N/2-1];
        long long right = d[N/2];
        cout << right - left << endl;
    }
}


















Measured memory_bytes: 1024
from itertools import permutations


def warshallfloyd(N, DIST):  # ワーシャルフロイド法:全頂点対最短経路 O(n**3)
    # DIST:隣接行列
    for k in range(N):
        for i in range(N):
            for j in range(N):
                DIST[i][j] = min(DIST[i][j], DIST[i][k] + DIST[k][j])
    return DIST


h, w = map(int, input().split())
c = [list(map(int, input().split())) for _ in range(10)]
a = [list(map(int, input().split())) for _ in range(h)]

ans, dist = 0, warshallfloyd(10, c)
for ai in a:
    for aij in ai:
        if aij != -1:
            ans += dist[aij][1]
print(ans)


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

using namespace std;

using card = pair<int, char>;

auto bubble_sort(const vector<card> &a) {
	auto sorted = a;

	int n = sorted.size();
	for (int i = 0; i < n; ++i) {
		for (int j = n-1; j >= i+1; --j) {
			if (sorted[j].first < sorted[j-1].first) {
				swap(sorted[j], sorted[j-1]);
			}
		}
	}

	return sorted;
}

auto select_sort(const vector<card> &a) {
	auto sorted = a;

	int n = sorted.size();
	for (int i = 0; i < n; ++i) {
		int minj = i;
		for (int j = i; j < n; ++j) {
			if (sorted[j].first < sorted[minj].first) {
				minj = j;
			}
		}
		swap(sorted[i], sorted[minj]);
	}

	return sorted;
}

ostream &operator<<(ostream &out, const card &c) {
	out << c.second << c.first;
	return out;
}

vector<vector<char>> create_bucket(const vector<card> &a) {
	vector<vector<char>> bucket(9);
	for (auto e: a) {
		bucket[e.first-1].push_back(e.second);
	}
	return bucket;
}

void stability_check(const vector<card> &a, const vector<card> &b) {
	int n = a.size();
	cout << b[0];
	for (int i = 1; i < n; ++i) {
		cout << ' ' << b[i];
	}
	cout << '\n';

	auto c = create_bucket(a);
	auto d = create_bucket(b);
	if (c == d) {
		cout << "Stable";
	} else {
		cout << "Not stable";
	}
	cout << '\n';
}

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

	vector<card> cards(N);
	for (int i = 0; i < N; ++i) {
		cin >> cards[i].second >> cards[i].first;
	}

	stability_check(cards, bubble_sort(cards));
	stability_check(cards, select_sort(cards));
}


Measured memory_bytes: 3112
H,W,A,B = map(int,input().split())
MOD = 10**9 + 7
FAC = [1]
INV = [1]
for i in range(1,H+W+1):
  FAC.append((FAC[i-1]*i) % MOD)
  INV.append(pow(FAC[-1],MOD-2,MOD))
#print(FAC)
#print(INV)

def nCr(n,r):
  return FAC[n]*INV[n-r]*INV[r]

ans = 0
for i in range(H-A):
  ans += nCr(i+B-1,min(i,B-1)) * nCr(H-i-1+W-B-1,min(H-i-1,W-B-1))
  ans %= MOD
print(ans)


Measured memory_bytes: 66544
def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a % b)


def solve(n, a):
    l = [0] * n
    r = [0] * (n + 1)

    for i in range(1, n):
        l[i] = gcd(l[i - 1], a[i - 1])
    for i in range(n - 1, 0, -1):
        r[i] = gcd(r[i + 1], a[i])

    m = 0
    for i in range(n):
        m = max(m, gcd(l[i], r[i + 1]))
    return m


def input_from_console():
    n = int(input())
    a = list(map(int, input().split()))
    return n, a


def main():
    n, a_list = input_from_console()
    print(solve(n, a_list))


if __name__ == "__main__":
    main()


Measured memory_bytes: 14384
#include<bits/stdc++.h>
using namespace std;
int main()
{
	long long n,w,j;
	cin>>n>>w;
	long long A[n][2];
	for(int i=0;i<n;i++)
	{
		cin>>A[i][0]>>A[i][1];
	}
	long long dp[w+5]={0};
	for(long long i=0;i<n;i++)
	{
		for( j=w-A[i][0];j>=0;j--)
		{
			
			dp[j+A[i][0]]=max(dp[j]+A[i][1],dp[j+A[i][0]]);
		}
	}
	cout<<dp[w];
	// for(int j=W-w;j>=0;--j) dp[j+w]=max(v+dp[j],dp[j+w]);
	
	
	return 0;
}

Measured memory_bytes: 1024
/*
Miles Morales : When will I know I'm ready?
Peter B. Parker : You won't. It's a leap of faith. That's all it is, Miles. A leap of faith.
*/
//KEEP IT SIMPLE STUPID

#include <bits/stdc++.h>

// #pragma GCC optimize("O3")
// #pragma GCC target("avx")
// #pragma GCC optimize("Ofast")
// #pragma GCC optimize("unroll-loops")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#define ll long long
#define MP make_pair
#define ERR cout << "================================================\n"
#define fi first
#define se second
#define PB push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define for1(i, n) for (ll i = 1; i <= (ll)(n); ++i)
#define ford(i, n) for (ll i = (ll)(n)-1; i >= 0; --i)
#define fore(i, a, b) for (ll i = (ll)(a); i <= (ll)(b); ++i)
#define print(v)          \
	for (auto x : v)      \
	{                     \
		cout << x << " "; \
	}
#define MAX(v) *max_element(all(v))
#define MIN(v) *min_element(all(v))
#define SP << " " <<
#define W(t)  \
	ll t;     \
	cin >> t; \
	while (t--)
#define FIO                           \
	freopen("input.txt", "r", stdin); \
	freopen("output.txt", "w", stdout);
#define FAST                 \
	ios::sync_with_stdio(0); \
	cin.tie(0);              \
	cout.tie(0);

using namespace std;

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<vll> vvll;

const ll INF = 1e18;
const ll NEG_INF = -1 * (1e18);
using namespace std;

void usaco(string prob)
{
	freopen((prob + ".in").c_str(), "r", stdin);
	freopen((prob + ".out").c_str(), "w", stdout);
}

/* Function to check primality in O(sqrt(n)) */
bool prime(int n)
{
	if (n < 2)
		return false;
	for (int x = 2; x * x <= n; x++)
	{
		if (n % x == 0)
			return false;
	}
	return true;
}

/* Function to get prime factorization of n */
vector<int> getFactors(int n)
{
	vector<int> f;
	for (int x = 2; x * x <= n; x++)
	{
		while (n % x == 0)
		{
			f.push_back(x);
			n /= x;
		}
	}
	if (n > 1)
		f.push_back(n);
	return f;
}

void solve()
{
	/* Write Solution Here */
	string n;
	cin >> n;
	ll k = 0;
	forn(i, n.length())
	{
		k += (n[i] - '0');
	}

	if (k % 9)
	{
		cout << "No\n";
	}
	else
	{
		cout << "Yes\n";
	}
}

int main()
{
	//FIO
	//FAST

	//usaco("cowlands");

	ll TC = 1;
	/*
	Uncomment when multiple test cases
	*/

	// cin>>TC;
	for1(tt, TC)
	{
		solve();
	}
	return 0;
}

/* stuff you should look for
	* int overflow, array bounds
	* special cases (n=1?)
	* do smth instead of nothing and stay organized
	* WRITE STUFF DOWN
*/


Measured memory_bytes: 3768
Imports System.Collections
Imports System.Collections.Generic
Imports System.Linq
Imports System.xml
Imports System.xml.Linq

Module Module1
	public sub main()

		dim NM as string() = Console.ReadLine().split(" ")
		dim A as string() = Console.ReadLine().split(" ")

		dim day as Integer = convert.toint32(NM(0))
		dim homeworks as Integer = convert.toint32(NM(1))
		dim sumHomework as Integer = 0
		for each stra as string in A
			sumHomework += convert.toint32(stra)
		next
		
		select case true
			case sumHomework > day
				console.writeLine("-1")
			case else
				console.writeLine((day - sumHomework).tostring)
		end select
		
	  
	end sub 
End Module

Measured memory_bytes: 28732
#include<iostream>
using namespace std;
 
int main(){
	long long a = 0;
	long long n[5];
 
	for(int i = 0; i < 5; i++){
		long long b;
		cin >> b;
		n[i] = b;
	}

	for(long long j = 0; j < 5; j++){
		if(n[j] == 0){
			a = j+1;
			break;
		}
	}
 
	cout << a << endl;
}

Measured memory_bytes: 3524
#include<stdio.h>
#include<algorithm>
#include<vector>
using namespace std;

int a,b;
vector<int> vec;
int main(){
    scanf("%d %d", &a,&b);
    vec={a+b,a-b,a*b};
    sort(vec.begin(),vec.end());
    printf("%d",vec[2]);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std; 
#define int int64_t
#define itn int
#define fi first
#define se second 
signed main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int x,r=8;
  cin>>x;
  for(int i=0;i<8;i++){
    if(600+200*i<=x) r--;
  }
  cout<<r<<"\n";
}


Measured memory_bytes: 3528
import sys,queue,copy,math
sys.setrecursionlimit(10**8)
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())
INF = float('inf')
N = int(input())
S = list(input())
x = ""
ans =list()
for x in S:
    if ord(x)+N > ord('Z'):
        ans.append(ord('A') + (ord(x) + N - (ord('Z')))-1)
    else:
        ans.append(ord(x) + N)

ANS = list()
for i in range(len(S)):
    ANS.append(chr(ans[i]))

print("".join(ANS))



Measured memory_bytes: 4336
#include<bits/stdc++.h>
#define debug(x) cout<<#x<<"::"<<x<<endl;
using namespace std;
typedef long long ll;

void solve()
{
	ll n;
	cin>>n;
	vector<ll>freq(200001);
	vector<ll>v(n);
	for(ll i=0;i<n;i++)
	{
		cin>>v[i];
		freq[v[i]]++;
	}
	ll total=0;
	for(ll i=1;i<=200000;i++)
	{
		if(freq[i]>=2)
		{
			total+=freq[i]*(freq[i]-1)/2;
		}
	}
	for(ll i=0;i<n;i++)
	{
		ll x=freq[v[i]];
		if(x>2)
		{
			ll sub=x*(x-1)/2;
			x--;
			ll add=x*(x-1)/2;
			cout<<total-sub+add;
		}
		else if(x==2)
		{
			ll sub=x*(x-1)/2;
			cout<<total-sub;
		}
		else
			cout<<total;
		cout<<'\n';
	}

}

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

Measured memory_bytes: 5760
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
//template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
 
/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
*/

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

int main(){
    int N; cin >> N;
    vector<ll> a(N+1);
    vector<ll> accum(N+1), accum2(N+1);
    for(int i=1; i<=N; i++) cin >> a[i];

    accum[1] = a[1];
    accum2[N] = a[N];

    for(int i=2; i<=N; i++) accum[i] = gcd(a[i], accum[i-1]);
    for(int i=N-1; i>=1; i--) accum2[i] = gcd(a[i], accum2[i+1]);

    ll ans = 0;

    for(int i=1; i<=N; i++){
        if(i == 1) ans = max(ans, accum2[2]);
        else if(i == N) ans = max(ans, accum[N-1]);
        else ans = max(ans, gcd(accum[i-1], accum2[i+1]));
    }

    cout << ans << endl;
}

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

int main() {
	int H, W;

	while (1) {
		cin >> H >> W;

		if (!H && !W)
			break;

		for (int r = 1; r <= H; r++)
		{
			for (int c = 1; c <= W; c++)
			{
				cout << "#";
			}
			cout << endl;
		}
		cout << endl;
			
	}

	return 0;
}

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
int main()
{/// Standing in The hall of Fame
    ios_base::sync_with_stdio(false) , cin.tie(NULL) , cout.tie(NULL);
    int n , h[100005] , x = 0 , mx = 0;
    cin >> n;
    for(int i = 0 ; i < n; i++)
        cin >> h[i];
    for(int i = n-1; i > 0 ; i--){
        if(h[i] <= h[i-1])x++;
        else              x=0;
        mx = max(mx , x);
    }
    cout << mx << "\n";
    return 0;
}

Measured memory_bytes: 640
function main(input) {
    const inputArray: string[] = input.split('\n');
    const n: number = Number(inputArray.shift());
    const [a,b,c] = inputArray.map(v => v.split(' ').map(Number));
    let r = a.reduce((acc, current) => acc + b[current - 1] ,0);
    r += a.reduce((acc, current, index, array) => {
        return current +1 === array[index+1] ? acc += c[current -1] : acc;
    },0);
    console.log(r);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));


Measured memory_bytes: 7372
function rollA(arr){
var a=arr.slice();
var memo7=a[7];
var memo8=a[8];
var memo9=a[9];
var memo10=a[10];
var memo13=a[13];
a[7]=a[22];
a[8]=a[23];
a[9]=a[24];
a[10]=a[12];
a[13]=a[18];
a[22]=memo7;
a[23]=memo8;
a[24]=memo9;
a[12]= memo10;
a[18]=memo13;
a=a.join(" ");
return a;
}
function rollB(arr){
var a=arr.slice();
var memo1=a[1];
var memo2=a[2];
var memo3=a[3];
var memo19=a[19];
var memo15=a[15];
a[1]=a[28];
a[2]=a[29];
a[3]=a[30];
a[19]=a[21];
a[15]=a[16];
a[28]=memo1;
a[29]=memo2;
a[30]=memo3;
a[21]=memo19;
a[16]=memo15;
a=a.join(" ");
return a;
}
function rollC(arr){
var a=arr.slice();
var memo1=a[1];
var memo4=a[4];
var memo7=a[7];
var memo18=a[18];
var memo10=a[10];
a[1]=a[24];
a[4]=a[27];
a[7]=a[30];
a[18]=a[16];
a[10]=a[21];
a[24]=memo1;
a[27]=memo4;
a[30]=memo7;
a[16]=memo18;
a[21]=memo10;
a=a.join(" ");
return a;
}
function rollD(arr){
var a=arr.slice();
var memo3=a[3];
var memo6=a[6];
var memo9=a[9];
var memo13=a[13];
var memo12=a[12];
a[3]=a[22]
a[6]=a[25]
a[9]=a[28]
a[13]=a[15]
a[12]=a[19]
a[22]=memo3;
a[25]=memo6;
a[28]=memo9;
a[15]=memo13;
a[19]=memo12;
a=a.join(" ");
return a;
}
function BFS(str){
   var obj={};
   var bfs=[[str,0]];
   obj[str]=true;
   while(true){
      if(bfs.length==0)break;
      var leaf=bfs.shift();
      var s=leaf[0];
      var cnt=leaf[1];
      if(s=="0 1 1 1 1 1 1 1 1 1 2 2 2 4 4 4 6 6 6 5 5 5 3 3 3 3 3 3 3 3 3")break;
      var sArr=s.split(" ").map(Number);
      var sA=rollA(sArr);
      if(obj.hasOwnProperty(sA)==false){bfs.push([sA,cnt+1]);obj[sA]=true;}
      var sB=rollB(sArr);
      if(obj.hasOwnProperty(sB)==false){bfs.push([sB,cnt+1]);obj[sB]=true;}
      var sC=rollC(sArr);
      if(obj.hasOwnProperty(sC)==false){bfs.push([sC,cnt+1]);obj[sC]=true;}
      var sD=rollD(sArr);
      if(obj.hasOwnProperty(sD)==false){bfs.push([sD,cnt+1]);obj[sD]=true;}
   }
   return cnt;
}
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var Arr=(input.trim()).split("\n");
var n=Arr.shift()-0;
for(var i=0;i<n;i++){
   var v=Arr.shift();
   console.log(BFS("0 "+v));
}

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

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

using namespace std;

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

  int slen = s.length() - 1;
  int ans =  0;
  int odd = (slen & 1) ? 1 : 0;
  for(int i = 0; i < slen / 2 + odd; ++i)
  {
    if(s[i] != s[slen - i]) ++ans;
  }
  cout << ans << endl;
  return 0;
}


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

#define all(x)        (x).begin(),(x).end()
#define mp            make_pair
#define pb            push_back
#define fi            first
#define se            second
#define sz(x)         ((int)(x).size())
#define rep(x,y,z)    for(int x=y;x<z;x++)
#define per(x,z,y)    for(int x=z-1;x>=y;x--)
#define trav(y,x)     for(auto& y:x)
#define pii           pair<int,int>
#define vi            vector<int>

int dbg = 0;
#define cri           if(0)
#define shame         cri cerr<<(++dbg)<<"\n\n";

// aaaaaaaaaaaaaaaa
const int N = 2e5 + 1;
const int lg = 20;
const ll mod = 0xfffff;


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

int main() {
  // freopen("input.in", "r", stdin);
  // freopen("input.out", "w", stdout);
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	// cout<<setprecision(15);
	// int t; cin>>t; while(t--)
	solve();
	return 0;
}

Measured memory_bytes: 256
S = input()
n = len(S) - 1
ans = 0
for i in range(2**n):
    bits = [(i>>j)&1 for j in range(n)]
    bits.append("")
    expr = ""
    for s, b in zip(S, bits):
        expr += s
        if b == 1:
            expr += "+"
    ans += sum([int(s) for s in expr.split("+")])
print(ans)

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

int main(){
    long long n;
    cin >> n;
    long long a[n];
    vector<long long> b(100001,0);
    vector<long long> c(100001,0);
    for(long long i=0;i<n;i++){
        cin >> a[i];
        if(i%2==0) b[a[i]]++;
        else c[a[i]]++;
    }
    long long d1=0,d2=0,e1=0,e2=0;
    for(long long i=0;i<100001;i++){
        if(b[i]>=b[d1]){
            d2=d1;
            d1=i;
        }
        if(b[i]<b[d1]&&b[i]>b[d2]) d2=i;
        if(c[i]>=c[e1]){
            e2=e1;
            e1=i;
        }
        if(c[i]<c[e1]&&c[i]>c[e2]) e2=i;
    }
    long long res;
    if(d1!=e1) res=n-b[d1]-c[e1];
    else res=min(n-b[d2]-c[e1],n-b[d1]-c[e2]);
    cout << res << endl;
}


Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
int main(){
	long long N,resu,ol;
	cin>>N;
	if(N<2){
		resu=0;
	} else{
		if(N%2 !=0){
			resu=0;
		}else {
			resu=N/10;
			ol=resu;
			while(ol != 0){
			resu= resu+ol/5;
			ol= ol/5;	
			}
			
		}
	} 	
	cout<<resu;
	return 0;
}

Measured memory_bytes: 384
/* Simplicity and Goodness */

#include <bits/stdc++.h>
using namespace std;
#define scn(n) scanf("%d", &n)
#define lscn(n) scanf("%lld", &n)
#define pri(n) printf("%d ", (int)(n))
#define prin(n) printf("%d\n", (int)(n))
#define lpri(n) printf("%lld ", n)
#define lprin(n) printf("%lld\n", n)
#define deb(x) cout << #x << " = " << x << ' ';
#define rep(i, a, b) for(int i=(int)(a); i<(int)(b); i++)
#define tc int tt; scn(tt); while(tt --)
#define pb push_back
#define mp make_pair
#define F first
#define S second
using ll = long long;
const int inf = INT_MAX;
const int ninf = INT_MIN;
const int mod = 998244353;
const int N = 2e5+2;


int main()
{
    ll n;
    lscn(n);

    ll cnt = 0;

    for(ll i=2; i*i<=n; i++) {
        if(n % i == 0) {
            ll here = 0;

            while(n % i == 0) {
                n /= i; here ++;
            }

            ll st = 1, here_2 = 0;

            while(here - st >= 0) {
                here -= st;
                here_2 ++;
                st ++;
            }

            cnt += here_2;
        }
    }

    if(n > 1)
        cnt ++;

    lprin(cnt);
    return 0;
}

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

const ll infll = (1LL << 62) - 1;
const int inf = (1 << 30) - 1;


int main() {
  int h,w;
  cin >> h >> w;
  vector<string> a(h);
  rep(i,h) cin >> a[i];
  queue<P> q;
  int ans=0,mx=0;
  rep(i,h) rep(j,w) {
    if(a[i][j]=='#') continue;
    vector<vector<int>> dist(h,vector<int> (w,inf));
    dist[i][j]=0;
    q.push(P(i,j));
    auto update= [&](int x, int y, int z) {
      if (x<0 || y<0 || x>=h || y>=w) return;
      if(a[x][y]=='#') return;
      if(dist[x][y]!=inf) return;
      dist[x][y]=z;
      mx=max(mx,z);
      q.push(P(x,y));
    };
    
    while(!q.empty()) {
      P b=q.front(); q.pop();
      int x=b.first;
      int y=b.second;
      update(x+1,y,dist[x][y]+1);
      update(x-1,y,dist[x][y]+1);
      update(x,y+1,dist[x][y]+1);
      update(x,y-1,dist[x][y]+1);
      
    }
    ans=max(ans,mx);
   
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <stdlib.h>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <math.h>
#include <string>
#include <map>
#include <cstdlib>
using namespace std;

typedef long long ll;
typedef pair<int,int> P;

int main()
{
    int n;
    cin >> n;
    vector<int> v(n), v1(100004), v2(100004);
    fill(v1.begin(), v1.end(), 0);
    fill(v2.begin(), v2.end(), 0);
    for(int i=0; i<n/2; i++){
        int tmp1,tmp2;
        cin >> tmp1 >> tmp2;
        v[i*2]=tmp1;
        v[i*2+1]=tmp2;
        v1[tmp1]++;
        v2[tmp2]++;
    }
    
    int cnt1=0, cnt2=0, M1=0, M2=0;
    for(int i=1; i<=100000; i++){
        if(cnt1<v1[i]){
            M1=i;
            cnt1=v1[i];
        }
        if(cnt2<v2[i]){
            M2=i;
            cnt2=v2[i];
        }
    }
    ll ans_;
    sort(v1.begin(), v1.end(), greater<int>());
    sort(v2.begin(), v2.end(), greater<int>());
    if(M1==M2){
        ans_=max(v1[0]+v2[1], v1[1]+v2[0]);
    }else{
        ans_=v1[0]+v2[0];
    }

    cout << n-ans_ << endl;

    return 0;
}


Measured memory_bytes: 1536
/*
　　　　　　 ＿＿
　　　　　／＞　　 フ
　　　　　| 　_　 _ l
　 　　　／` ミ＿xノ    見ちゃだめ！
　　 　 /　　　 　 |　
　　　 /　 ヽ　　 ﾉ　　
　 　 │　　|　|　|　　
　／￣|　　 |　|　|
　| (￣ヽ＿_ヽ_)__)
　＼二つ
*/

#include <bits/stdc++.h>
using namespace std;
#define SORT(a) sort((a).begin(), (a).end())
#define RSORT(a) reverse((a).begin(), (a).end())
#define rep(i, n) for (int i = 0; i < n; i++)
typedef long long ll;
const long long INF = 1LL << 60;

int main() {
  int n;
  cin >> n;
  vector<ll> a(n);
  rep(i, n) cin >> a[i];
  ll k = INF;
  int neg = 0;
  rep(i, n) {
    k = min(k, abs(a[i]));
    if (a[i] < 0) neg++;
  }
  ll total = 0;
  rep(i, n) total += max(a[i], -a[i]);
  if (neg % 2 == 0)
    cout << total << endl;
  else
    cout << total - 2 * k << endl;
}

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

using namespace std;

const int MX = 200000;

void no() {
	printf("%s\n", "No");
	exit(0);
}

char s[MX + 1];

int main() {
	int n, a, b, c, d;
	ignore = scanf("%d %d %d %d %d %s", &n, &a, &b, &c, &d, s);
	a--;
	b--;
	c--;
	d--;
	
	for (int i = 0; i + 1 < n; i++)
		if (s[i] == '#' && s[i + 1] == '#') {
			if (a < i && i < c) no();
			if (b < i && i < d) no();
		}
	
	if (c > d) {
		bool ok = false;
		for (int i = b; i <= d; i++)
			if (s[i - 1] == '.' && s[i] == '.' && s[i + 1] == '.')
				ok = true;
		
		if (ok == false) no();
	}
	
	printf("%s\n", "Yes");
	
	return 0;
}


Measured memory_bytes: 384