akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<math.h>
#include<string.h>
int main()
{
  int N,a=0,b=0,c=0,d=0,i;
  char in[4];
  scanf("%d",&N);
  for(i=0;i<N;i++){
    scanf("%s",in);
    if(strcmp(in,"AC")==0){
      a++;
    }else if(strcmp(in,"WA")==0){
      b++;
    }else if(strcmp(in,"TLE")==0){
      c++;
    }else if(strcmp(in,"RE")==0){
      d++;
    }
  }
  printf("AC x %d\nWA x %d\nTLE x %d\nRE x %d",a,b,c,d);
    return 0;
}


Measured memory_bytes: 1732
#include <cstdio>

int main()
{	
	unsigned long int a, b,c,d, n,x=0;
	scanf("%lu %lu %lu", &n, &a, &b);
	c = a + b;
	d = n % c;
	if (a == 0)printf("0");
	else if (b == 0)printf("%lu", n);
	else if (n == c) printf("%lu", a);
	else if (d == 0)printf("%lu", a * n / c);
	else {
		x = (n - d) / c;
		if (d>=a)printf("%lu", a * x+a);
		else if(d<a) printf("%lu", a * x+d);
	}
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <cmath>
#include <cstdio>
#include <vector>

using namespace std;

int comp(int *a,int *b){
    int buffer;
    if(*a > *b){
        buffer = *b;
        *b = *a;
        *a = buffer;
        return 1;
    }
    else{
        return 0;
    }
}

int main(){
    int a,b,c,d,e;
    int i = 1;
    cin >> a >> b >> c >> d >> e;
    while(i){
        i = 0;
        i += comp(&a,&b);
        i += comp(&b,&c);
        i += comp(&c,&d);
        i += comp(&d,&e);
    }
    cout << e << " " << d << " " << c << " " << b << " " << a << endl;
    return 0;
}

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

int main() {
	int N, count=0;
	cin >> N;
	vector<int> d(N);
	for (int i = 0; i < N; i++)cin >> d[i];
	sort(d.begin(), d.end());

	int memo = 0;
	for (int i = N-1; i >= 0; i--) {

		if (i == N-1 || d[i] < memo) {
			count++;
			memo = d[i];
		}
	}
	cout << count << endl;
}

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

using namespace std;

#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)((x).size()))

typedef pair<int, int> PII;
typedef vector<int> VI;
typedef long long int64;
typedef unsigned int uint;
typedef unsigned long long uint64;

#define gi(x) ((x) = F())
#define gii(x, y) (gi(x), gi(y))
#define giii(x, y, z) (gii(x, y), gi(z))

int F()
{
	char ch;
	int x, a;
	while (ch = getchar(), (ch < '0' || ch > '9') && ch != '-');
	if (ch == '-') ch = getchar(), a = -1;
	else a = 1;
	x = ch - '0';
	while (ch = getchar(), ch >= '0' && ch <= '9')
		x = (x << 1) + (x << 3) + ch - '0';
	return a * x;
}

int n, A, B, C, D;

int main()
{
	giii(n, A, B);
	gii(C, D);
	--n;
	for (int i = 0; i <= n; ++i)
	{
		int64 x = 1LL * (n - i) * D - 1LL * i * C;
		int64 y = 1LL * (n - i) * C - 1LL * i * D;
		if (B - A <= x && B - A >= y)
		{
			//cerr << i << " : " << x << ", " << y << endl;
			puts("YES");
			return 0;
		}
	}
	puts("NO");
	return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;

public class Main {

    public static void main(String[] args) {

        InputStreamReader isr = new InputStreamReader(System.in);
        BufferedReader br = new BufferedReader(isr);

        String str1 = null;
        String strDat = null;


        PrintWriter out = new PrintWriter(System.out);
        try {
            str1 = br.readLine();
            strDat = br.readLine();

            String str2[] = strDat.split(" ", 0);

            int intCnt = Integer.parseInt(str1);

            int intHigh[] = new int [intCnt+1];
            for (int i=0 ; i<intCnt ; i++) {
            	intHigh[i] = Integer.parseInt(str2[i]);
            }


            int intSee=0;

            int intNowHigh=0;
            for (int i=0 ; i<intCnt; i++) {
            	if (intNowHigh <= intHigh[i]) {
            		intNowHigh = intHigh[i];
            		intSee ++;
            	}
            }


            System.out.println(intSee);


        } catch (IOException e) {

        }


    }
}

Measured memory_bytes: 21460
#include<cstdio>
#define int long long
int n,a[100001];
signed main()
{
	scanf("%lld",&n);
	for(int i=1;i<=n;i++)scanf("%lld",a+i);
	int l=2,r=2;
	for(int i=n;i;i--)
	{
		l=(l/a[i]+bool(l%a[i]))*a[i];
		r=(r/a[i]+1)*a[i]-1;
		if(l>r||r<1){puts("-1");return 0;}
		//printf("%lld %lld\n",l,r);
	}
	printf("%lld %lld\n",l,r);
	return 0;
}


Measured memory_bytes: 896
#include<bits/stdc++.h>
#define ll long long

using namespace std;
const int MAXN = 100005;

vector<pair<int,int>> g[MAXN];
int ans[MAXN] , arr[MAXN] , tree[3*MAXN],lazy[3*MAXN];

void propagate(int c,int a,int b){
	int cc = c << 1;
	tree[c] += lazy[c];
	if(a != b) lazy[cc] += lazy[c] , lazy[cc+1] += lazy[c];
	lazy[c] = 0;
}

void update(int c,int a,int b,int x,int y){
	propagate(c,a,b);
	if(a > y || b < x) return ;
	if(a >= x && b <= y){
		lazy[c] += 1;
		propagate(c,a,b);
		return ;
	}
	int cc = c << 1 , m = (a + b) >> 1;
	update(cc,a,m,x,y); update(cc+1,m+1,b,x,y);
	tree[c] = tree[cc] + tree[cc+1];
}

int query(int c,int a,int b,int x){
	propagate(c,a,b);
	int cc = c << 1 , m = (a + b) >> 1;
	if(a == b) return tree[c];
	if(x <= m) return query(cc,a,m,x);
	return query(cc+1,m+1,b,x);
}

int main(){
	ios_base::sync_with_stdio(false); cin.tie(0);
	int n,m; cin >> n >> m;
	for(int i=0;i<n;i++){
		int a,b; cin >> a >> b;
		int dif = b -a;
		g[dif].push_back({a,b});
	}
	for(int i=0;i<m;i++){
		int k = g[i].size();
		arr[1] += k; arr[i+2] -= k;
		for(int j=i+1;j<=m;j+=i+1) ans[i+1] += query(1,0,m,j);
		for(auto j:g[i]) update(1,0,m,j.first,j.second);
	}
	for(int i=1;i<=m;i++) arr[i] += arr[i-1];
	for(int i=1;i<=m;i++) cout << ans[i] + arr[i] << '\n';
	return 0;
}


Measured memory_bytes: 10496
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define int long long int
#define M 1000000007
#define pb push_back
#define pf push_front
#define ulli unsigned long long int
#define what_is(x) cerr << #x << " is " << x << endl;
#define pi 2*acos(0.0)
#define F  first
#define S  second
#define endl '\n'
using namespace std;
using namespace __gnu_pbds;
const int INF = 1e18L+5;
const int LG = 20;
const int N = 1e5+9;
typedef tree<int,null_type,less_equal<int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
int power(int x,int y){int res=1;while(y>0){if(y%2==1)res=(res*x)%M;x=(x*x)%M;y=y/2;}return res;}
bool isvowel(char c){if(c=='a' || c=='e' || c=='i' || c=='o' || c=='u' || c=='A' || c=='E' || c=='I' || c=='O' || c=='U')return true;return false;}
int32_t main()
{
	//cout.precision(15);
	//cout.setf(ios::fixed,ios::floatfield);
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	int T=1;
	//cin>>T;
	while(T--)
	{
		int i=0,a,b,n,x;
		cin>>a>>b>>n;
		x=b-1;
		if(x!=0)
		i=n/(x*b);
		x=max(x,i*x);
		x=min(x,n);
		cout<<(a*(x)/b-a*((x)/b))<<endl;
	}
}


Measured memory_bytes: 3640
import bisect

S = input()
rl = [] # lのidx
pre = '_'
for i, s in enumerate(S):
    if pre == 'R' and s == 'L':
        rl.append(i)
    pre = s


ans = [0]*len(S)
for i, s in enumerate(S):
    if s == 'L':
        j = rl[bisect.bisect(rl, i)-1]
    if s == 'R':
        j = rl[bisect.bisect(rl, i)]
    if (i - j) % 2 == 0:
        ans[j] += 1
    else:
        ans[j-1] += 1
print(' '.join(map(str, ans)))


Measured memory_bytes: 83848
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define vl vector<ll>

int main() {

    int N;
    string s;
    set<string> S;
    cin >> N;

    for (int i = 0; i < N; i++) {
        cin >> s;
        S.insert(s);
    }

    cout << S.size() << endl;

    return 0;
}


Measured memory_bytes: 19124
using System;

class C
{
	static void Main()
	{
		var k = int.Parse(Console.ReadLine());

		var r = 0;
		for (int a = 1; a <= k; a++)
			for (int b = 1; b <= k; b++)
				for (int c = 1; c <= k; c++)
					r += Gcd(Gcd(a, b), c);
		Console.WriteLine(r);
	}

	static int Gcd(int a, int b) { for (int r; (r = a % b) > 0; a = b, b = r) ; return b; }
}


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

typedef long long int ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pair<int, int> > vii;
#define rrep(i, m, n) for(int (i)=(m); (i)<(n);  (i)++)
#define erep(i, m, n) for(int (i)=(m); (i)<=(n); (i)++)
#define  rep(i, n)    for(int (i)=0; (i)<(n);  (i)++)
#define rrev(i, m, n) for(int (i)=(n)-1; (i)>=(m); (i)--)
#define erev(i, m, n) for(int (i)=(n); (i)>=(m); (i)--)
#define  rev(i, n)    for(int (i)=(n)-1; (i)>=0; (i)--)
#define vrep(i, c)    for(__typeof((c).begin())i=(c).begin(); i!=(c).end(); i++)
#define  ALL(v)       (v).begin(), (v).end()
#define mp            make_pair
#define pb            push_back
template<class T, class S> inline bool minup(T& m, S x){ return m>(T)x ? (m=(T)x, true) : false; }
template<class T, class S> inline bool maxup(T& m, S x){ return m<(T)x ? (m=(T)x, true) : false; }

const int    INF = 1000000000;
const ll     MOD = 1000000007LL;
const double EPS = 1E-12;

struct Point : public complex<double>
{
public:
  Point() { this->real(0);  this->imag(0); }
  Point(const double& x, const double& y) { this->real(x);  this->imag(y); }
  Point(const complex<double> w)  { this->real(w.real());  this->imag(w.imag()); }
  inline double dot(Point p){ return (conj(*this) * p).real(); }  // ??????
  inline double det(Point p){ return (conj(*this) * p).imag(); }  // ??????
};

namespace std
{
  inline bool operator < (const Point& a, const Point& b)
  {
    return real(a) != real(b) ? real(a) < real(b) : imag(a) < imag(b);
  }
}
typedef vector<Point> Polygon;
inline Point currPoint(vector<Point> P, int i){ return P[i]; }
inline Point nextPoint(vector<Point> P, int i){ return P[(i+1)%P.size()]; }
inline Point diffPoint(vector<Point> P, int i){ return nextPoint(P, i) - currPoint(P, i); }


struct Line : public vector<Point>
{
public:
  Line(const Point P, const Point Q){ this->pb(P);  this->pb(Q); }
};

template<typename T> T add(T x, T y){ if(abs(x+y) < EPS*(abs(x)+abs(y))) return 0; return x + y; }
template<typename T> inline bool semieq(T x, T y){ return abs(x - y) < EPS; }
template<typename T> inline bool semige(T x, T y){ return y - x < -EPS; }
template<typename T> inline bool semile(T x, T y){ return x - y < -EPS; }


double x[2], y[2];
int q;

int main()
{
  cin >> q;

  while(q--){
    cin >> x[0] >> y[0] >> x[1] >> y[1];  Point AB = Point(x[1], y[1]) - Point(x[0], y[0]);
    cin >> x[0] >> y[0] >> x[1] >> y[1];  Point CD = Point(x[1], y[1]) - Point(x[0], y[0]);

    if(semieq(AB.det(CD), 0.0)){ cout << 2 << endl;  continue; }
    if(semieq(AB.dot(CD), 0.0)){ cout << 1 << endl;  continue; }
    cout << 0 << endl;
  }

  return 0;
}

Measured memory_bytes: 1236
//
// Created by 13783 on 2020/3/28.
//
#include<iostream>
using namespace std;
int x;
int a,b,c,d;
long long ans1,ans2;
int main(){
    cin>>x;
    a=x/500;
    b=x-a*500;
    ans1=a*1000;
    c=b/5;
    ans2=c*5;
    cout<<ans1+ans2;
    return 0;
}


Measured memory_bytes: 384
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <string>
#include <algorithm>
#include <utility>
#include <vector>
#include <list>
#include <deque>
#include <stack>
#include <queue>
#include <map>
#include <set>
#define INF (1000000000)
#define MOD (1000000007)
using namespace std;

typedef vector<int> VI;
typedef vector<int>::iterator VII;
typedef vector<double> VD;
typedef vector<double>::iterator VDI;
typedef pair<int, int> PII;


int b[100];

int main()
{
	int n, q;
	while (scanf("%d %d", &n, &q), n + q){
		memset(b, 0, sizeof(b));
		
		for (int i = 0; i < n; i++){
			int m;
			scanf("%d", &m);
			for (int j = 0; j < m; j++){
				int d;
				scanf("%d", &d);
				b[d]++;
			}
		}
		
		int ma = 0;
		for (int i = 1; i < 100; i++){
			if (b[i] > b[ma] && b[i] >= q){
				ma = i;
			}
		}
		
		printf("%d\n", ma);
	}
	
	return 0;
}

Measured memory_bytes: 1188
#include<iostream>
#include<functional>
#include<utility>
#include<cmath>
#include<iomanip>
#include<algorithm>
#include<string>
#include<vector>

using namespace std;
const auto MOD = 1000000007;
const int INF = 1e9;
const long long LINF = 1e18;
#define rep(i,n) for(int i = 0; i < (n);i++)
typedef pair<int, int> PII;
typedef pair<long, long> PLL;
typedef vector<int> VI;
typedef vector<long long> VLL;


long long n, m,a,b;
string s;

int main() {
	cin >> n;
	VLL a(n);
	long long cnt = 0;
	for (int i = 0; i < n; i++)
	{
		cin >> a[i];
		cnt += a[i];
	}
	long long temp = 0;
	for (int i = 1; i <n; i+=2)
	{
		temp += a[i];
	}
	VLL ans(n);
	ans[0] = cnt/2 - temp;
	long long now=ans[0];
	for (int i = 0; i < n-1; i++)
	{
		ans[i + 1] = a[i] - now;
		now = ans[i + 1];
	}
	for (int i = 0; i < n; i++)
	{
		cout << ans[i]*2 << endl;
	}
}

Measured memory_bytes: 2944
import sys
input = sys.stdin.readline
def print_ans(n,pr):
    """Test Case
    >>> print_ans(5, [1, 3, 5, 4, 2])
    2
    >>> print_ans(9, [9, 6, 3, 2, 5, 8, 7, 4, 1])
    5
    """
    ans = 0
    for i in range(1, n-1):
        tmp_arr = sorted([pr[i-1],pr[i],pr[i+1]])
        if  tmp_arr[1] == pr[i]:
            ans +=1
    print(ans)

if __name__ == '__main__':
    n = int(input().rstrip())
    pr = list(map(int, input().rstrip().split()))
    print_ans(n,pr)




Measured memory_bytes: 3060
fun main(args: Array<String>) {

    val (n,k) = readLine()!!.split(" ").map { it.toInt() }
    val v = readLine()!!.split(" ").map { it.toInt() }
    val f = listOf(0)+v.summed()
    val b = listOf(0)+v.reversed().summed()
    
    var ans = 0
    for(takeL in 0..Math.min(n,k)){
        for(takeR in 0..Math.min(n-takeL,k-takeL)) {
            var remove = k-takeL-takeR
            if(remove<0) remove = 0
            if(remove>takeL+takeR) remove = takeL+takeR
            val vv = v.take(takeL)+v.takeLast(takeR)
            val vvv = vv.sorted().take(remove).filter { it<0 }
            val tmp0 = f[takeL] + b[takeR]
            val tmp1 =  vvv.sum()
            ans = Math.max(ans, tmp0-tmp1)
        }
    }
    println(ans)
}

inline fun List<Int>.summed(): List<Int> {
    var sum = 0
    return this.map { sum += it; sum }
}


Measured memory_bytes: 40820
#include <cstdio>
    #include <iostream>
    using namespace std;
     
    int main(){
      	int x;
      	cin >> x;
      
      	if(x == 22){
        	cout << "Christmas Eve Eve Eve" << endl;
        }else if(x == 23){
              	cout << "Christmas Eve Eve" << endl;
        }else if(x == 24){
         	    	cout << "Christmas Eve" << endl; 
        }else{
             	cout << "Christmas" << endl; 
        }
      
     	return 0; 
    }


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		var sc = new Scanner(System.in);
		var l = sc.nextInt();
		var r = sc.nextInt();
		var d = sc.nextInt();
		sc.close();

		var count = 0;
		for (var i = l; i <= r; i++) {
			if (i % d == 0) {
				count++;
			}
		}
		System.out.println(count);
	}
}


Measured memory_bytes: 35732
n = int(input())
in_val = input().split()
in_cos = input().split()

lis_val = [int(s) for s in in_val]
lis_cos = [int(s) for s in in_cos]

sum_vc = 0
for i in range(n):
    if lis_val[i] > lis_cos[i]:
        sum_vc += lis_val[i] - lis_cos[i]
    else:
        continue

print(sum_vc)


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,k) for(int i=j;i<k;i++)
#define M 1046527
#define L 14
char H[M][L];
int getchar (char ch){
    if(ch=='A')return 1;
    else if(ch=='C')return 2;
    else if(ch=='G')return 3;
    else if(ch=='T')return 4;
    else return 0;
}
long long getkey(char str[]){
    long long sum=0,p=1,i;
    for(i=0;i<strlen(str);i++){
        sum+=p*(getchar(str[i]));
        p*=5;
    }
    return sum;
}
int h1(int key){return key%M;}
int h2(int key){return 1+(key%(M-1));}
int find(char str[]){
    long long key,i,h;
    key=getkey(str);
    for(i=0;;i++){
        h=(h1(key)+i*h2(key))%M;
        if(strcmp(H[h],str)==0)return 1;
        else if(strlen(H[h])==0)return 0;
    }
    return 0;
}
int insert(char str[]){
    long long key,i,h;
    key=getkey(str);
    for(i=0;;i++){
        h=(h1(key)+i*h2(key))%M;
        if(strcmp(H[h],str)==0)return 1;
        else if(strlen(H[h])==0){
        strcpy(H[h],str);
        return 0;
        }
    }
    return 0;
}
int main(){
    int n,i,h;cin>>n;
    char str[L],com[9];
    rep(i,0,M)H[i][0]=0;
    rep(i,0,n){
        cin>>com>>str;
        if(com[0]=='i')insert(str);
        else{
            if(find(str))cout<<"yes"<<endl;
            else cout<<"no"<<endl;
        }
    }
    return 0;
}


Measured memory_bytes: 17400
#include <bits/stdc++.h>
 
using namespace std;
 
//const int MOD=1e9+7;
 
const int MOD=998244353;

long long modpow(long long x, long long n, long long m) {
    if (n == 0) return 1%m;
    long long u = modpow(x,n/2,m);
    u = (u*u)%m;
    if (n%2 == 1) u = (u*x)%m;
    return u;
}

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    
    int n;
    cin>>n;
    
    vector<int> v(n);
    for(int &i:v)cin>>i;
    
    if(v[0]){
        cout<<0;
        return 0;
    }
    vector<int> ct(n);
    for(int i:v) ct[i]++;
    if(ct[0]>1){
        cout<<0;
        return 0;
    }
    
    int m=*max_element(v.begin(),v.end());
    long long ans=1;
    for(int i=2; i<=m; i++){
        if(ct[i]){
            ans*=modpow(ct[i-1],ct[i],MOD);
            ans%=MOD;
        }
        else{
            cout<<0;
            return 0;
        }
    }
    cout<<ans;
    
    
    
    
    
    
    return 0;
}

Measured memory_bytes: 1024
import sys
sys.setrecursionlimit(10 ** 5 + 10)


def input(): return sys.stdin.readline().strip()


def resolve():
    MOD = 10**9+7
    N = int(input())
    I, J, K, L = N, 4, 4, 4
    # dpテーブル dp[i][j][k][l]:=i文字目までで末尾3桁が'ijk'のものの個数であるとき作れる，長さiの文字列の個数
    dp = [[[[0]*(L+1) for _ in range(K+1)] for _ in range(J+1)]
          for _ in range(I+1)]
    # 初期条件
    dp[0][0][0][0] = 1
    # ループ
    for i in range(1, I+1):
        for j in range(J+1):
            for k in range(K+1):
                for l in range(L+1):
                    for a in range(1, 5):

                        if [k, l, a] == [1, 3, 2]:
                            continue
                        if [k, l, a] == [1, 2, 3]:
                            continue
                        if [k, l, a] == [2, 1, 3]:
                            continue
                        if [j, l, a] == [1, 2, 3]:
                            continue
                        if [j, k, a] == [1, 2, 3]:
                            continue

                        dp[i][k][l][a] += dp[i-1][j][k][l]

    ans = 0
    for j in range(1, 5):
        for k in range(1, 5):
            for l in range(1, 5):
                ans += dp[I][j][k][l]

    print(ans % MOD)


resolve()

Measured memory_bytes: 50288
import java.util.*;

public class Main {
  public static void main(String[] args) {
	  Scanner sc = new Scanner(System.in);
	  int A = Integer.parseInt(sc.next());
	  int B = Integer.parseInt(sc.next());
	  
	  if(B == 1) {
		  System.out.println(0);
	  }
	  else {
		  int count = 1;
		  int temp = A;
		  while(temp < B) {
			  temp += A - 1;
			  count++;
		  }
		  System.out.println(count);
	  }
	  sc.close();
	  
  }
}


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

int main() {
  int a,b,c;
  cin >>a>>b;
  if(b==100){c=a*1000+100;}
  else if(b<10){c=a*10+b;}
  else {c=a*100+b;}
  int x=0;
  for(int i=0;i<333;i++){
    x++;
    if(c==i*i){
      cout<<"Yes"<<endl;
      break;
    }
  }
    if(x==333){cout <<"No"<<endl;}
   
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(i64 (i) = (s);(i) < (e);(i)++)
#define all(x) x.begin(),x.end()
#define let auto const

template<typename... Types>
struct dynarr: std::vector<Types...> {
  using std::vector<Types...>::vector;
  using size_type = typename std::vector<Types...>::size_type;
  auto&& operator[](size_type i) { return this->at(i); }
  auto&& operator[](size_type i) const { return this->at(i); }
};

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

int main() {
  i64 a, b;
  cin >> a >> b;
  i64 g = gcd(a, b);
  i64 ans = 1;
  for(i64 i = 2;i * i <= g;i++) {
    if(g % i == 0) {
      ans++;
      while(g % i == 0) {
        g /= i;
      }
    }
  }
  if(g != 1) { ans++; }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 1LL << 60;

int main() {
    int n;
    cin >> n;
    vector<string> s(n);
    map<string, int> tbl;
    int cnt_max = 0;
    for (int i = 0; i < n; i++) {
        cin >> s[i];
        if (tbl.count(s[i])) {
            tbl[s[i]]++;
            cnt_max = max(cnt_max, tbl[s[i]]);
        } else {
            tbl[s[i]] = 1;
            cnt_max = max(cnt_max, 1);
        }
    }
    vector<string> ans(0);
    for (auto p : tbl) {
        if (p.second == cnt_max) {
            cout << p.first << endl;
        }
    }
    return 0;
}

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

int main(){
  vector<vector<int>> a(3, vector<int>(3));
  for(int i=0; i<3; i++){
    for(int j=0; j<3; j++){
      cin >> a[i][j];
    }
  }
  int n;
  set<int> mem;
  cin >> n;
  for (int k=0; k<n; k++){
    int b;
    cin >> b;
    mem.insert(b);
  }

  bool ans = false;
  for(int i=0; i<3; i++){
    if (mem.count(a[i][0]) && mem.count(a[i][1]) && mem.count(a[i][2])) ans = true;
  }
  for(int i=0; i<3; i++){
    if (mem.count(a[0][i]) && mem.count(a[1][i]) && mem.count(a[2][i])) ans = true;
  }
  if (mem.count(a[0][0]) && mem.count(a[1][1]) && mem.count(a[2][2])) ans = true;
  if (mem.count(a[0][2]) && mem.count(a[1][1]) && mem.count(a[2][0])) ans = true;
  if (ans){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
N = int(input())

l = []
sum_b = 0
for _ in range(N):
    a, b = map(int, input().split())
    l.append(a+b)
    sum_b += b

l = sorted(l, reverse=True)
sum_l = sum(l[0::2])
ans = sum_l - sum_b
print(ans)


Measured memory_bytes: 8284
#include <bits/stdc++.h>
using namespace std;
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL);


typedef long long ll;
typedef long int li;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
typedef vector<ll> vll;
typedef long double ld;

#define mp make_pair
#define f first
#define s second

#define pu push
#define pb push_back

#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
#define print(x) cout<<x<<endl;
#define printarray(a, start, end) for(int i=start; i<=end; i++) cout<<a[i]<<" "; cout<<endl;


ll n, k;
ll ar[105];
ll val[1000000];

int main()
{
	fastio;
	cin>>n>>k;
	rep(i,n) cin>>ar[i];

	rep(i, k) rep(j, n) if(val[i]==0) val[i+ ar[j]] = 1;
	// print(val[k]);
	if(val[k]) {print("First");}
	else print("Second");
	return 0;
}


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

n = int(input())
G = [[] for _ in range(n)]
for _ in range(n-1):
    a,b,c = map(int,input().split())
    a -= 1
    b -= 1
    G[a].append((b,c))
    G[b].append((a,c))
q,k = map(int,input().split())
k -= 1

dist = [-1]*n
dist[k] = 0
def dfs(now):
    for nxt,d in G[now]:
        if dist[nxt] != -1: continue
        dist[nxt] = dist[now] + d
        dfs(nxt)
dfs(k)

ans = [0]*q
for i in range(q):
    x,y = map(int,input().split())
    x -= 1
    y -= 1
    ans[i] = dist[x]+dist[y]

for i in range(q): print(ans[i])

Measured memory_bytes: 132660
import bisect
import cmath
import heapq
import itertools
import math
import operator
import os
import re
import string
import sys
from collections import Counter, deque, defaultdict
from copy import deepcopy
from decimal import Decimal
from fractions import gcd
from functools import lru_cache, reduce
from operator import itemgetter, mul, add, xor

import numpy as np

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(10 ** 9)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7
# MOD = 998244353


c = sys.stdin.buffer.readline().decode().rstrip()
a =     chr(ord(c) + 1)
print(a)


Measured memory_bytes: 23460
#include <iostream>

using namespace std;

int main()
{
    int n; cin >> n;
    int cnt = 0;

    for (int i = 0; i < n; i++) {
        int a; cin >> a;
        if (a % 2 != 0) cnt++;
    }
    if (cnt % 2 == 0) cout << "YES" << endl;
    else              cout << "NO" << endl;
    
    return 0;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

typedef pair<int, int> ii;
typedef pair<ll, ll> pll;

int main( int argc, char *argv[] ) {
	int n;
	string s;
	cin >> n >> s;

	for ( auto l : s ) {
		l += n;
		if ( l > 'Z' )
			l -= 26;
		cout << l;
	}
	cout << "\n";

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define REP(i,n) for (int i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define MOD 1000000007
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
const int INFTY =2147483647;
int main(){
    ll n,m,a,b,ans=0;
    bool C[100005];
    ll H[100005];
    vi K[100005];
    cin>>n>>m;
    REP(i,n) C[i]=true;
    REP(i,n) cin>>H[i];
    REP(i,m){
        cin>>a>>b;
        if(H[a-1]==H[b-1]) C[a-1]=C[b-1]=false;
        else if(H[a-1]>H[b-1]) C[b-1]=false;
        else C[a-1]=false;
    }
    REP(i,n) if(C[i]==true){
        ans++;
    } 
    cout<<ans<<endl;
}

Measured memory_bytes: 6844
#include<stdio.h>
int main(){
    int n,l;
    scanf("%d%d",&n,&l);
    int a[n+1];
    for(int i=1;i<=n;i++)
        a[i]=l+i-1;
    if(a[1]<=0&&a[n]>0){
        int sum=0;
        for(int i=1;i<=n;i++)
            if(a[i]!=0)
                sum+=a[i];
        printf("%d\n",sum);
        return 0;
    }
    else if(a[1]>0){
        int sum=0;
        for(int i=2;i<=n;i++)
            sum+=a[i];
        printf("%d\n",sum);
        return 0;
    }
    int sum=0;
    for(int i=1;i<n;i++)
        sum+=a[i];
    printf("%d\n",sum);
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
const double eps=1e-9;
typedef vector<int> vi;
typedef long long ll;
string a,b;
int main(void)
{
    while(cin >> a >> b && a!="0") {
        int hit=0,blow=0;
        set<int> st;
        for (int i = 0; i < 4; i++) {
            st.insert(int(a[i]-'0'));
        }
        for(int i=0;i<4;i++)
        {
            if(a[i]==b[i])
            {
                hit++;
                continue;
            }
            else
            {
                auto it=st.find(int(b[i]-'0'));
                if(it!=st.end()) blow++;
            }
        }
        cout << hit << ' ' << blow << endl;
    }

  return 0;
}



Measured memory_bytes: 3144
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};
using pii = pair<int, int>;
int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  ll sum = 0;
  vector<int> memo(9999999);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    memo[a[i]]++;
    sum += (ll)a[i];
  }
  int q;
  cin >> q;
  for (int i = 0; i < q; i++) {
    int b, c;
    cin >> b >> c;
    sum += (ll)memo[b] * (ll)(c - b);
    int temp = memo[b];
    memo[b] = 0;
    memo[c] += temp;
    cout << sum << endl;
  }
}

Measured memory_bytes: 42852
#!python3

def resolve():
    N, K = map(int, input().rstrip().split())
    R, S, P = map(int, input().rstrip().split())
    T = list(input().rstrip())

    score = {"r":  P, "s": R, "p": S}

    s = 0
    for i in range(K):
        s += score[T[i]]

    for i in range(K, N):
        if T[i-K] == T[i]:
            T[i] = ""
            continue
        s += score[T[i]]

    print(s)

if __name__ == "__main__":
    resolve()


Measured memory_bytes: 4084
#include <bits/stdc++.h>
using namespace std;
const int M = 2019;

int main()
{
    int l, r;
    cin >> l >> r;
    for (int i = l; i <= r; ++i)
    {
        if (i % M == 0)
        {
            cout << 0 << endl;
            return 0;
        }
    }
    int ans = M;
    for (int i = l; i <= r; ++i)
    {
        for (int j = i + 1; j <= r; ++j)
        {
            ans = min(ans, ((i % M) * (j % M)) % M);
        }
    }
    cout << ans << endl;
    return 0;
}


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

using namespace std;

int main() {
    int a,b,c;
    cin >> a >> b >> c;
    int m = max(a,b), n = min(a,b);
    int q = m%n;
    while (q){
        m = n;
        n = q;
        q = m%n;
    }
    if (c%n == 0){
        cout << "YES" << endl;
        return 0;
    }
    cout << "NO" << endl;
}

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

using namespace std;

const int N = 1e5 + 100;

int n, m, x, y;
int vis[N], a[N];

int main() {
	cin >> n >> m; vis[1] = 1;
	for(int i = 1;i <= n; ++i) a[i] = 1;
	for(int i = 1;i <= m; ++i) {
		cin >> x >> y;
		if(vis[x] == 1) vis[y] = 1;
		a[x]--; a[y]++;
		if(!a[x]) vis[x] = 0;
	}
	int ans = 0;
	for(int i = 1;i <= n; ++i)
		if(vis[i] && a[i])
			ans++;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 4328
#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <set>
#include <cstring>
#include <cmath>


#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, k, n) for (int i = (int)(k); i < (int)(n); i++)
#define rrep(i, n) for (int i = (int)(n)-1; i >= 0; i--)
#define rREP(i, k, n) for (int i = (int)(n)-1; i >= k; i--)

#define debug(x) cerr<<#x<<": "<<x<<endl;

#define fi first
#define se second

#define vi vector<int>
#define pb push_back
#define mp make_pair

#define pcnt __builtin_popcount

typedef long long ll;
const ll inf = 900900900100100100;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
const int MID=255;
using namespace std;

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    int n,m;
    while(cin >> n >> m,n){
        vector<int> c(m);
        rep(i,m) cin >> c[i];
        vector<int> x(n);
        rep(i,n) cin >> x[i];
        vector<vector<ll> > dp(20100,vector<ll> (MID*3,inf));
        dp[0][128+MID] = 0;
        rep(i,n){
            REP(j,0,MID+1){
                rep(k,m){
                    int nj;
                    if(j+c[k]>255) nj=255;
                    else if(j+c[k]<0) nj=0;
                    else nj = j+c[k];
                    dp[i+1][nj+MID]=min<ll>(dp[i+1][nj+MID],dp[i][j+MID]+(nj-x[i])*(nj-x[i]));
                }
            }
        }
        ll ans = inf;
        REP(i,-MID,MID+1) ans = min<ll>(dp[n][i+MID],ans);
        cout << ans << endl;
    }

    return 0;
}



Measured memory_bytes: 123784
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
const int maxn = 2e5 + 20;
ll a[maxn] , s[maxn];
int main()
{
	int n;
	cin >> n;
	for(int i = 0; i < n; i++)
	{
		cin >> a[i];
		s[i] = s[i - 1] + a[i];
	}
	ll res = 1e18;
	for(int i = 0; i < n - 1; i++)
		res = min(res , abs(s[n - 1] - 2 * s[i]));
	cout << res << endl;
}


Measured memory_bytes: 3328
// Copyright 2020 yaito3014
#include <bits/stdc++.h>

int main() {
  using namespace std;
  cin.tie(nullptr); ios::sync_with_stdio(false);
  int N, K;
  cin >> N >> K;
  vector<int> snukes(N, 0);
  for (int i = 0; i < K; ++i) {
    int d;
    cin >> d;
    for (int j = 0; j < d; ++j) {
      int A;
      cin >> A, --A;
      ++snukes[A];
    }
  }
  cout << count(cbegin(snukes), cend(snukes), 0) << endl;
}


Measured memory_bytes: 3624
/*
[agc026] B - rng_10s
*/

#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;

ll gcd(ll a, ll b) {
    while (b > 0) {
        swap(b, a %= b);
    }
    return a;
}

ll solve(ll a, ll b, ll c, ll d) {
    if (a < b) {
        return false;
    }
    if (d < b) {
        return false;
    }
    if (c >= b) {
        return true;
    }
    ll g = gcd(b, d);
    return (b - g + (a % g) <= c);
}

int main() {
    int T;
    cin >> T;
    for (int i = 0; i < T; i++) {
        ll a, b, c, d;
        cin >> a >> b >> c >> d;
        cout << (solve(a, b, c, d) ? "Yes" : "No") << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include<iostream>



using namespace std;



int main() {



	int W, H, x, y, r;

	cin >> W >> H >> x >> y >> r;

	if ((x-r) >= 0 && (x+r) <= W && (y-r) >= 0 && (y+r) <= H){

		cout << "Yes" << endl;

	} else {

		cout << "No" << endl;

	}

	return 0;

}


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

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

  vector<pair<int, int>> p(n);
  for (int i = 0; i < n; i++) {
    int x, y;
    cin >> x >> y;

    p[i] = make_pair(x, y);
  }

  vector<int> v(n);
  for (int i = 0; i < n; i++) {
    v[i] = i;
  }

  double ans = 0;
  do {
    double d = 0;
    for (int i = 0; i < n - 1; i++) {
      d += sqrt(pow(p[v[i]].first - p[v[i + 1]].first, 2) +
                pow(p[v[i]].second - p[v[i + 1]].second, 2));
    }

    ans += d;
  } while (next_permutation(v.begin(), v.end()));

  int x = 1;
  for (int i = 1; i <= n; i++) {
    x *= i;
  }

  ans /= x;
  cout << fixed << setprecision(10) << ans << endl;

  return 0;
}

Measured memory_bytes: 256
def resolve():
    n=int(input())
    a=[0]*(60000)
    nn=int(n**0.5)
    for x in range(1,nn):
        for y in range(1, nn):
            for z in range(1, nn):
                a[x**2+y**2+z**2+x*y+y*z+z*x]+=1
    for i in range(n):
        print(a[i+1])
resolve()

Measured memory_bytes: 69300
#include <bits/stdc++.h>
const int N = 1e5 + 54;
int n, a[N], dp[N];
int main() {
	scanf("%d", &n);
	for (int i = 1; i <= n; ++i) scanf("%d", &a[i]);
	dp[1] = 0, dp[2] = abs(a[2] - a[1]);
	for (int i = 3; i <= n; ++i) dp[i] = std::min(dp[i - 2] + abs(a[i] - a[i - 2]), dp[i - 1] + abs(a[i] - a[i - 1]));
	printf("%d\n", dp[n]); 
}


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

#define int long long
#define pii pair<int,int> 

int N,M;
pii a[100010];

main()
{
	ios::sync_with_stdio(false);
	
	cin>>N>>M;
	for(int i=1;i<=N;i++)
	{
		cin>>a[i].first>>a[i].second;
	}
	sort(a+1,a+1+N);
	
	int cnt=0,res=0;
	for(int i=1;i<=N;i++)
	{
		if(cnt+a[i].second<=M)
		{
			res+=a[i].first*a[i].second;
			cnt+=a[i].second;
		}
		else
		{
			res+=a[i].first*(M-cnt);
			break;
		}
	}
	cout<<res;
	return 0;
}


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

using namespace std;

int main() {
	int a, b;
	cin >> a >> b;
	a += b;
	if (a < 10)cout << a << endl;
	else cout << "error" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int ans = 0;
  int x = 0;
  string S, T;
  cin >> S >> T;
    char a = S.at(x);
    char b = T.at(x);
for(int i = 0;i < S.size();i++){
    if(S.at(x) != T.at(x)){
    ans++;
    }
  x++;
}
  cout << ans << endl;
}

Measured memory_bytes: 3832
//#pragma comment(linker,"/STACK:36777216")
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,fma,tune=native")
#include <bits/stdc++.h>
using namespace std;
#define itoc(c) (char)((int)'0' + c)
#define ctoi(c) (int)(c - '0')
#define all(x) (x).begin(), (x).end()
#define ff first
#define ss second
#define emb emplace_back
#define pb push_back

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;

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

int main() {
  ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
  int K, X; cin>>K>>X;
  if (500*K>=X) cout<<"Yes";
  else cout<<"No";
  return 0;
}

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

int main(){
  string b;
  cin >> b;
  
  if (b == "A")
    cout << "T" << endl;
  else if (b == "C")
    cout << "G" << endl;
  else if (b == "G")
    cout << "C" << endl;
  else
    cout << "A" << endl;
}

Measured memory_bytes: 3516
#ライブラリインポート
from collections import defaultdict

#入力受け取り
def getlist():
	return list(map(int, input().split()))

#処理内容
def main():
	N = int(input())
	A = []
	for i in range(N):
		a = int(input())
		A.append(a)

	if A[0] != 0:
		print(-1)
	else:
		judge = "Yes"
		ans = 0
		for i in range(N - 1):
			if A[-1 - i] == A[-2 - i] + 1:
				ans += 1
			elif A[-1 - i] <= A[-2 - i]:
				if A[-1 - i] <= N - 1 - i:
					ans += A[-1 - i]
				else:
					judge = "No"
					break
			else:
				judge = "No"
				break
		if judge == "No":
			print(-1)
		else:
			print(ans)

if __name__ == '__main__':
	main()

Measured memory_bytes: 11396
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
// const bool debug=true;
const bool debug=false;
#define DEBUG if(debug==true)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll MOD = 1000000007;

int main(void) {
    int n,ma,mb;
    cin>>n>>ma>>mb;
    int a[n],b[n],c[n];
    const int lim = 1000000;
    vector<vector<vector<int> > > dp(41,vector<vector<int> >(401, vector<int>(401,lim)));
    rep(i,41)dp[i][0][0]=0;
    rep(i,n)cin>>a[i]>>b[i]>>c[i];
    for(int i=1;i<=n;i++){
        rep(j,401){
            rep(k,401){
                dp[i][j][k]=dp[i-1][j][k];
            }
        }
        for(int j=0;j+a[i-1]<=400;j++){
            for(int k=0;k+b[i-1]<=400;k++){
                dp[i][j+a[i-1]][k+b[i-1]]=min(dp[i][j+a[i-1]][k+b[i-1]],dp[i-1][j][k]+c[i-1]);
            }
        }
    }
    int res=lim;
    for(int i=1;ma*i<=400&&mb*i<=400;i++){
        res=min(res,dp[n][ma*i][mb*i]);
    }

    cout << (res==lim ? -1 : res) << endl;
    return 0;
}


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

using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;

#define fi first
#define se second

const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll MOD3 = 1812447359;
const ll INF = 1ll << 62;
const double PI = 2 * asin(1);

void yes() {printf("yes\n");}
void no() {printf("no\n");}
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

int N;
ll A[int(1e5+5)], sum;

int main(){
  cin >> N;
  for (int i = 0; i < N; i++) cin >> A[i];

  ll cnt1 = 0, cnt2 = 0;
  for (int i = 0; i < N; i++){
    sum += A[i];
    if (i % 2 == 0){
      if (sum > 0) continue;
      cnt1 += abs(sum) + 1; sum = 1;
    }else{
      if (sum < 0) continue;
      cnt1 += abs(sum) + 1; sum = -1;
    }
  }

  sum = 0;
  for (int i = 0; i < N; i++){
    sum += A[i];
    if (i % 2 == 0){
      if (sum < 0) continue;
      cnt2 += abs(sum) + 1; sum = -1;
    }else{
      if (sum > 0) continue;
      cnt2 += abs(sum) + 1; sum = 1;
    }
  }

  cout << min(cnt1, cnt2) << endl;

  return 0;
}


Measured memory_bytes: 4456
#include<iostream>
#include<algorithm>
#include<cmath>
#include<string>

using namespace std;

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

int main(){
    long int h, w;
    cin >> h >> w;
    if((h * w) % 2 == 0 && h != 1 && w != 1){
        cout << (h * w) / 2 << endl;
    }else if((h * w) % 2 == 1 && h != 1 && w != 1){
        cout << (h * w) / 2 + 1 << endl;
    }else{
        cout << 1 << endl;
    }
}

Measured memory_bytes: 256
a,b,c,k = map(int, raw_input().split(' '))
def f(a,b,c,k):
	elems = [(a,1), (b,0), (c,-1)]
	i = 0
	res = 0
	while(k and i <len(elems)):
		res += min(k, elems[i][0]) * elems[i][1] 
		k-= min(k, elems[i][0])
		i+=1
	return res

print f(a,b,c,k)

Measured memory_bytes: 64176
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int gcd(int a, int b) {
  if (a % b == 0) {
    return b;
  }
  return gcd(b, a % b);
}
int main(void) {
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  vector<int> front_gcd(n), back_gcd(n);
  front_gcd[0] = a[0];
  back_gcd[n - 1] = a[n - 1];
  for (int i = 1; i < n; i++) {
    front_gcd[i] = gcd(front_gcd[i - 1], a[i]);
    back_gcd[n - i - 1] = gcd(back_gcd[n - i], a[n - i - 1]);
  }
  int ans = max(front_gcd[n - 2], back_gcd[1]);
  for (int i = 1; i < n - 1; i++) {
    ans = max(ans, gcd(front_gcd[i - 1], back_gcd[i + 1]));
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 4564
#include<iostream>
#include<vector>
using namespace std;
const long long inf=(long long)(1e18);
int main()
{
    long long n,i,j,k;
    cin>>n;
    long long x,y;
    long long *arr=new long long[n+1];
    long long *pre=new long long[n+1];
    pre[0]=0l;
    for(i=1;i<=n;i++)    cin>>arr[i],pre[i]=pre[i-1]+arr[i];
    vector<long long>tmp(n+1);
    vector<vector<long long> >dp(n+1,tmp);
    for(i=0;i<=n;i++) dp[i][i]=0;
    for(i=n-1;i>0;i--)
    {
        for(j=i+1;j<=n;j++)
        {
            dp[i][j]=inf;
            for(k=i;k<j;k++)
                dp[i][j]=min(dp[i][j],dp[i][k]+dp[k+1][j]+pre[j]-pre[i-1]);
        }
    }
    cout<<dp[1][n];
}


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

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vint;
typedef vector<double> vd;
typedef vector<ll> vll;
typedef vector<string> vstr;
typedef vector<vector<int>> vvint;
typedef vector<pair<int, int>> vpii;
typedef vector<pair<ll, ll>> vpll;
typedef priority_queue<int, vector<int>, greater<int>> spqint; //小さい順に取り出し
typedef priority_queue<ll, vector<ll>, greater<ll>> spqll;     //小さい順に取り出し
typedef priority_queue<int, vector<int>, less<int>> bpqint;    //大きい順に取り出し
typedef priority_queue<ll, vector<ll>, less<ll>> bpqll;        //大きい順に取り出し

#define REP(i, n) for (ll i = 0; i < (ll)(n); i++)
#define FOR(i, a, b) for (ll i = (ll)a; i < (ll)b; i++)
#define IREP(i, v) for (auto i = (v).begin(); i != (v).end(); i++)
#define FI first
#define SE second
#define MP make_pair
#define MT make_tuple
#define PB push_back
#define PF push_front
#define TS to_string
#define BS binary_search
#define LB lower_bound
#define UB upper_bound
#define NP next_permutation
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) (ll) x.size()
#define SP(x) setprecision((ll)x)


int INF = 1e9;
int NIL = -1;
ll MOD = 1000000007;
ll LINF = 1e18;
double EPS = 1e-9;
double PI = M_PI;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
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; }     //最小公倍数

void yes(){ cout << "Yes" << endl;}
void no(){ cout << "No" << endl;}
//-----------------------------------------

//-----------------------------------------
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    std::chrono::system_clock::time_point start,end;
    start = std::chrono::system_clock::now();

    ll n, k ;
    cin >> n >> k ;
    vll ans(n) ;
    REP(i,n){
        cin >> ans[i] ;
    }
    bool f = true ;
    while(f){
        vll zero(n,0) ; 
        if(k<=0){
            break ;
        }
        REP(i,n){
            if(ans[i]!=n){
                break ;
            }
            if(i==n-1){
                f = false ;
            }
        }
        REP(i,n){
            zero[max((ll)0,i-ans[i])]++ ;
            if(i+ans[i]+1<=n-1){
                zero[i+ans[i]+1]-- ;
            }
        }
        REP(i,n-1){
            zero[i+1] += zero[i] ;
        }
        ans = zero ;
        k-- ;
    }
    REP(i,n){
        cout << ans[i] <<" " ;
    }
    cout << endl;





    end = std::chrono::system_clock::now();
    auto elapsed = std::chrono::duration_cast< std::chrono::milliseconds >(end - start).count();
    //std::cout << elapsed <<"ms"<< std::endl;

    

    return 0;
}



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

#define watch(x) cerr << (#x) << ": " << (x) << endl
#define int long long

const int mod = 1000000007;

int solve(string s) {
    int n = s.length();

    vector<vector<int>> dp(n+1, vector<int>(2, 0));
    dp[0][0] = 1;

    for(int i = 0; i < n; ++i) {
        if(s[i] == '1') {
            dp[i+1][0] = dp[i][0]*2;
            dp[i+1][1] = dp[i][0] + dp[i][1]*3;
        } else {
            dp[i+1][0] = dp[i][0];
            dp[i+1][1] = dp[i][1]*3;
        }
        dp[i+1][0] %= mod;
        dp[i+1][1] %= mod;
    }

    return (dp[n][0] + dp[n][1])%mod;
}

int32_t main() {

    string l; cin >> l;
    
    int ans = solve(l);

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


Measured memory_bytes: 5888
#include <stdio.h>
#include <string.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>
#include <limits.h>
#include <math.h>
int acs(const void *a, const void *b){return *(int*)a - *(int*)b;} /* 1,2,3,4.. */
int des(const void *a, const void *b){return *(int*)b - *(int*)a;} /* 8,7,6,5.. */
int cmp_char(const void *a, const void *b)
{ return *(char*)a - *(char*)b;} /* a,b,c,d.. */
int cmp_str(const void *a, const void *b)
{ return strcmp(*(const char **)a, *(const char **)b);} /* aaa,aab.. */
#define min(a,b) (a < b ? a: b)
#define max(a,b) (a > b ? a: b)
#define rep(i, n) for (int i = 0; i < n; i++)

int main(void) {
  char s[101];

  scanf("%s", s);

  bool judge = true;
  rep(i, strlen(s)) {
    if (i % 2 == 0) {
      if (s[i] != 'R' && s[i] != 'U' && s[i] != 'D') {
        judge = false;
        break;
      }
    } else {
      if (s[i] != 'L' && s[i] != 'U' && s[i] != 'D') {
        judge = false;
        break;
      }
    }
  }
  printf(judge ? "Yes\n" : "No\n");
  return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <type_traits>

using namespace std;

int main(int argc, const char * argv[]) {
    int n;
    cin >> n;
    string s;
    vector<int> W(n+1,0);
    vector<int> E(n+1,0);
    vector<int> WR(n+1,0);
    vector<int> ER(n+1,0);
    cin >> s;
    int Es = 0;
    for(int i = 0; i < n; i++){
        if(s[i] == 'W'){
            W[i+1] = W[i] + 1;
            E[i+1] = E[i];
        }
        else if(s[i] == 'E'){
            E[i+1] = E[i] + 1;
            W[i+1] = W[i];
            Es++;
        }
    }
    int ans = 99999999;
    for(int i = 0; i < n; i++){
        ans = min(ans, W[i] + Es - E[i+1]);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 5508
#include <bits/stdc++.h>
#include <unordered_map>
#include <unordered_set>
using namespace std;
#define endl "\n"
#define ll long long
#define sz(s) (int)(s.size())
#define INF 0x3f3f3f3f3f3f3f3fLL
#define all(v) v.begin(),v.end()
#define watch(x) cout<<(#x)<<" = "<<x<<endl
const int dr[] { -1, -1, 0, 1, 1, 1, 0, -1 };
const int dc[] { 0, 1, 1, 1, 0, -1, -1, -1 };
#if __cplusplus >= 201402L
template<typename T>
vector<T> create(size_t n) {
	return vector<T>(n);
}
template<typename T, typename ... Args>
auto create(size_t n, Args ... args) {
	return vector<decltype(create<T>(args...))>(n, create<T>(args...));
}
#endif
void run() {
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
#ifdef EZZAT
	freopen("input.in", "r", stdin);
	//freopen("output.out", "w", stdout);
#else
#endif
}

int main() {
	run();
	int n;
	cin >> n;
	vector<vector<int>> adj(n + 1);
	for (int i = 1; i < n; i++) {
		int u, v;
		cin >> u >> v;
		adj[u].push_back(v);
		adj[v].push_back(u);
	}
	ll sum = 0;
	for (int i = 1; i <= n; i++) {
		sum += (n - i + 1);
		for (int j : adj[i])
			if (j > i)
				sum -= (n - j + 1);
	}
	ll ans = sum;
	for (int i = 1; i < n; i++) {
		sum -= (n - i + 1);
		for (int j : adj[i])
			if (j > i)
				sum += (n - j + 1);
		ans += sum;
	}
	cout << ans << endl;
}


Measured memory_bytes: 15024