akhauriyash/Code-Regression huggingface dataset:
/* vim:set foldmethod=marker: */
#include <bits/stdc++.h>
using namespace std;

//{{{
#define all(x) (x).begin(),(x).end()
#define REP(i,a,b) for(int i=(int)(a); i<(int)(b); i++)
#define RREP(i,a,b) for(int i=(int)(a); i>=b; i--)
#define rep(i,n) REP(i,0,n)
#define rrep(i,n) RREP(i,n,0)
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<pii> vp;

#define dump(x) (cerr << #x << "=" << x << endl)
template<class T> ostream& osContainer(ostream& os,T c) { os<<'[';for(decltype(c.begin()) it=c.begin();it!=c.end();it++)os<<*it<<',';os<<']';return os; }
template<class T> ostream& operator<<(ostream& os,const vector<T>& v) { return osContainer(os,v); }
template<class T> ostream& operator<<(ostream& os,const set<T>& s) { return osContainer(os,s); }
template<class T> ostream& operator<<(ostream& os,const multiset<T>& s) { return osContainer(os,s); }
template<class T,class S> ostream& operator<<(ostream& os,const map<T,S>& m) { return osContainer(os,m); }
template<class T,class S> ostream& operator<<(ostream& os,const multimap<T,S>& m) { return osContainer(os,m); }
template<class T1,class T2>
ostream& operator<<(ostream& os, const pair<T1,T2>& p){ os << '(' << p.first << ',' << p.second << ')'; return os; }

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

const int M = 1e6;
char isPrime[M+1];

void sieve()
{
    REP(i, 2, M) isPrime[i]=1;
    for(int i=2; i*i <= M; i++) {
        if (isPrime[i]) {
            for(int j=i+i; j<M+1; j+=i) {
                isPrime[j]=0;
            }
        }
    }
}

void solve()
{
    sieve();
    int a, d, n;

    while(cin>>a>>d>>n, a||d||n) {
        int idx=0;
        int acc=a;

        for(int acc=a; acc<=M; acc+=d){
            if (isPrime[acc] && ++idx == n) {
                cout << acc << endl;
                break;
            }
        }
    }
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(12);
    solve();
}

Measured memory_bytes: 4008
#include <stdio.h>
int main(void){
	int a,b,c;
	int kae;

	scanf("%d",&a);
	scanf("%d",&b);
	scanf("%d",&c);
	
	if(a>b){
		kae=a;
		a=b;
		b=kae;
	}
	
	if(b>c){
		kae=b;
		b=c;
		c=kae;
	}
	
	if(a>b){
		kae=a;
		a=b;
		b=kae;
	}
	
	printf("%d %d %d\n",a,b,c);
	
	return 0;
	
}

Measured memory_bytes: 596
N = int(input())
A = list(map(int,input().split()))
from collections import defaultdict
d = {}
for i,a in enumerate(A):
    if a not in d:
        d[a] = i
    else:
        l = d[a]
        r = i
        break
mod = 10**9+7
n = 100010
frac = [1]*(n+1)
finv = [1]*(n+1)
for i in range(n):
    frac[i+1] = (i+1)*frac[i]%mod
finv[-1] = pow(frac[-1],mod-2,mod)
for i in range(1,n+1):
    finv[n-i] = finv[n-i+1]*(n-i+1)%mod
def nCr(n,r):
    if n<0 or r<0 or n<r: return 0
    r = min(r,n-r)
    return frac[n]*finv[n-r]*finv[r]%mod
ans = 0
for i in range(1,N+2):
    ans = nCr(N+1,i)-nCr(N+l-r,i-1)
    ans %= mod
    print(ans)

Measured memory_bytes: 101540
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()


int main() {
  ll x;
  cin >> x;
  ll ans1, ans2;
  bool flag = 0;
  for (ll a = 0; a < 10000; a++) {
    for (ll b = -1000; b < a; b++) {
      ll A = pow(a, 5);
      ll B = pow(b, 5);
      if (A - B == x) {
        ans1 = a;
        ans2 = b;
        flag = true;
        break;
      }
    }
    if (flag) break;
  }
  printf("%ld %ld\n", ans1, ans2);
  return 0;
}

Measured memory_bytes: 4164
#include <bits/stdc++.h>
using namespace std;
int main() {
    int n;
    cin>>n;
    int arr[n];

    int i;
    for(i=0;i<n;i++) cin>>arr[i];

    int dp[n];
    memset(dp,10000,sizeof(dp));
    dp[0]=0;
    dp[1]=abs(arr[1]-arr[0]);
    for(i=2;i<n;i++)
    {
        int a=dp[i-1]+abs(arr[i]-arr[i-1]);
        int b=dp[i-2]+abs(arr[i]-arr[i-2]);

        dp[i]=min(a,b);


    }
    cout<<dp[n-1]<<endl;
}


Measured memory_bytes: 4296
#include <bits/stdc++.h>
#define int long long
#define lint long long
#define pii pair<int,int>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(c) (c).begin(),(c).end()
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define MINF(a) memset(a,0x3f,sizeof(a))
#define POW(n) (1LL<<(n))
#define IN(i,a,b) (a <= i && i <= b)
using namespace std;
template <typename T> inline bool CHMIN(T& a,T b) { if(a>b) { a=b; return 1; } return 0; }
template <typename T> inline bool CHMAX(T& a,T b) { if(a<b) { a=b; return 1; } return 0; }
template <typename T> inline void SORT(T& a) { sort(ALL(a)); }
template <typename T> inline void REV(T& a) { reverse(ALL(a)); }
template <typename T> inline void UNI(T& a) { sort(ALL(a)); a.erase(unique(ALL(a)),a.end()); }
template <typename T> inline T LB(vector<T>& v, T a) { return *lower_bound(ALL(v),a); }
template <typename T> inline int LBP(vector<T>& v, T a) { return lower_bound(ALL(v),a) - v.begin(); }
template <typename T> inline T UB(vector<T>& v, T a) { return *upper_bound(ALL(v),a); }
template <typename T> inline int UBP(vector<T>& v, T a) { return upper_bound(ALL(v),a) - v.begin(); }
template <typename T1, typename T2> ostream& operator<< (ostream& os, const pair<T1,T2>& p) { os << p.first << " " << p.second; return os; }
template <typename T1, typename T2> istream& operator>> (istream& is, pair<T1,T2>& p) { is >> p.first >> p.second; return is; }
template <typename T> ostream& operator<< (ostream& os, const vector<T>& v) { REP(i,v.size()) { if (i) os << " "; os << v[i]; } return os; }
template <typename T> istream& operator>> (istream& is, vector<T>& v) { for(T& in : v) is >> in; return is; }
template <typename T = int> vector<T> make_v(size_t a) { return vector<T>(a); }
template <typename T, typename... Ts> auto make_v(size_t a, Ts... ts) { return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...)); }
template <typename T, typename V> typename enable_if<is_class<T>::value == 0>::type fill_v(T &t, const V &v) { t = v; }
template <typename T, typename V> typename enable_if<is_class<T>::value != 0>::type fill_v(T &t, const V &v) { for(auto &e : t) fill_v(e,v); }
const lint MOD = 1000000007;
const lint INF = 0x3f3f3f3f3f3f3f3f;
const double EPS = 1e-10;

int N;
int a[510][510];

signed main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);

    cin >> N;
    for (int i = 1; i <= N; i++) {
        for (int j = i + 1; j <= N; j++) {
            int x = i ^ j;
            for (int k = 0; k < 10; k++) {
                if ((x >> k) & 1) {
                    a[i - 1][j - 1] = k + 1;
                    break;
                }
            }
        }
    }
    REP(i, N) FOR(j, i + 1, N) {
        cout << a[i][j] << " \n"[j+1==N];
    }

    return 0;
}

Measured memory_bytes: 2432
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String S = sc.next();
		int N = S.length();
		int[] mod_arr = new int[N];
		int[] mod_cnt = new int[2019];
		int radix = 1;
		for (int i=0;i<N;i++) {
			int tmp = ((int)S.charAt(N-1-i)-(int)'0')*radix%2019;
			if (i!=0) tmp = (tmp+mod_arr[i-1])%2019;
			mod_arr[i] = tmp;
			mod_cnt[tmp]++;
			radix = radix*10%2019;
		}

		long ans = 0L;
		mod_cnt[0]++;
		for (int i=0;i<2019;i++) {
			ans += mod_cnt[i]*(mod_cnt[i]-1)/2;
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 40960
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> ii;

bool isgreater(const ii& p1, const ii& p2){
    return (p2.first+p2.second)*100*p1.second > (p1.first+p1.second)*100*p2.second;
}

int main(){
    int a, b, c, d, e, f; cin >> a >> b >> c >> d >> e >> f;
    ii res = {1, 0};

    int tot = a*100, sug = 0;
    for(int i = 0; i <= 100; i++)
    for(int j = 0; j <= 100; j++)
    for(int k = 0; k <= 100; k++)
    for(int l = 0; l <= 100; l++){
        int water = i*100*a + j*100*b;
        int sugar = k*c + l*d;
        if(water+sugar <= f and 100*sugar <= e*water){
            if(sug*(water+sugar) <= sugar*tot){
                sug = sugar;
                tot = sugar+water;
                ii aux = {water,sugar};
                if(isgreater(aux,res))
                    res = aux;
            }
        }
    }
    cout << tot << " " << sug << endl;
	return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <string>
#include <cmath>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <list>
#include <iostream>
#include <sstream>
#include <climits>
#include <cfloat>
#include <complex>

using namespace std;

int main()
{
	int distance[][7] =
	{
		{ 0, 6, 13, 18, 23, 43, 58 },
		{ 0, 0, 7, 12, 17, 37, 52 },
		{ 0, 0, 0, 5, 10, 30, 45 },
		{ 0, 0, 0, 0, 5, 25, 40 },
		{ 0, 0, 0, 0, 0, 20, 35 },
		{ 0, 0, 0, 0, 0, 0, 15 }
	};
	int charge[][7] = 
	{
		{ 0, 300, 500, 600, 700, 1350, 1650 },
		{ 0, 0, 350, 450, 600, 1150, 1500 },
		{ 0, 0, 0, 250, 400, 1000, 1350, },
		{ 0, 0, 0, 0, 250, 850, 1300 },
		{ 0, 0, 0, 0, 0, 600, 1150 },
		{ 0, 0, 0, 0, 0, 0, 500 }
	};

	int n, m, s, e;
	while (scanf("%d", &n), n)
	{
		int a, b;
		scanf("%d %d", &a, &b);
		s = 60*a + b;
		scanf("%d %d %d", &m, &a, &b);
		e = 60*a + b;
		--n;
		--m;
		if (n > m)
			swap(n, m);

		int d = distance[n][m];
		int c = charge[n][m];
		const int S = 60*17 + 30;
		const int E = 60*19 + 30;
		if (d <= 40 && (S <= s && s <= E || S <= e && e <= E))
			c = (c+50)/100*50;
		printf("%d\n", c);
	}

	return 0;
}

Measured memory_bytes: 0
import itertools

n, k = map(int, input().split())
s = input()

before = s[0]
count = 1
lst = []
head = True if before == '1' else False
tail = True if s[-1] == '1' else False

for i in s[1:]:
    if i == before:
        count += 1
    else:
        lst.append(count)
        count = 1
        before = i
lst.append(count)

S = 0

lst1 = lst
if not head:
    S = sum(lst1[:2*k])
    lst1 = lst1[1:]
if not tail:
    S = max(S, sum(lst1[-2*k:]))
    lst1 = lst1[:-1]

lst1.insert(0,0)
accum_lst = list(itertools.accumulate(lst1))

#print('accum_lst :', accum_lst)
N = len(lst1)
if N <= 2*k + 1:
    S = max(S, accum_lst[-1])
else:
    K = 2*k+1
    for i in range(0, N-K, 2):
        S = max(S, accum_lst[i+K] - accum_lst[i])
        #print(S, accum_lst[i+K], accum_lst[i])

print(S)

Measured memory_bytes: 48948
#include <iostream>
#include <string>
#include <cstring>
#include <fstream>
#include <cmath>
#include <iomanip>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <map>
#include <deque>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <list>
#include <unordered_map>
#include <bitset>
#include <sstream>

typedef  long long ll;
#define mop 1000000007
using namespace std;



int main() {
    

    set <int> s;
    for (ll i=0;i<3;i++){
        int tmp;
        cin >> tmp;
        s.insert(tmp);
    }
    if(s.size() == 2){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }


}

Measured memory_bytes: 256
(n,m),*ab=$<.map{|s|s.split.map &:to_i}

par=[]
chi=[]

ab.map{|a,b|
  par[b]||=0
  par[b]+=1
  chi[a]||=[]
  chi[a]<<b
}

root=(1..n).find{|i|par[i]==nil}

res=[]
res[root]=0

que=[root]

until que.empty?
  nd=que.shift
  chi[nd]&&chi[nd].map{|ch|
    par[ch]-=1
    if par[ch]==0
      res[ch]=nd
      que.push(ch)
    end
  }
end

puts res[1,n]


Measured memory_bytes: 19860
#include<bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define pb push_back
#define powerof2 ()
#define mp make_pair
#define pi acos(-1)
using ll = long long;
const ll M = 1000000007;
const ll M1= 998244353;
using vl = vector<ll>;
using pll =  pair<ll,ll>;
ll power(ll x,ll y){
	if(y==0)
		return 1;
	ll res=power(x,y/2);
	res=(res*res);
	if(y&1)
		res=(res*x);
	return res;
}
 
ll powermod(ll x,ll y,ll mod){
	if(y==0)
		return 1;
	ll res=powermod(x,y/2,mod);
	res=(res*res)%mod;
	if(y&1)
		res=(res*x)%mod;
	return res;
}
/*ll binarysearch(ll va)
{
	ll n=1;
	ll l=va+1,u=n;
	ll st=num.order_of_key(va);
	while(l+1<u)
	{
		m=(l+u)/2;
		ll in=num.order_of_key(m);
		if(in-st==m-va)
		{
			l=m;
		}
		else
		{
            u=m;
		}
	}
	if(num1.find(l)==num1.end())
		return l;
	return u;
}*/
void solve(){
	map<string,string> m;
	m["Sunny"]="Cloudy";
	m["Cloudy"]="Rainy";
	m["Rainy"]="Sunny";
	string s;
	cin>>s;
	cout<<m[s]<<"\n";
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t=1;
    // cin>>t;
 
    for(int i=1;i<=t;i++)
    {//cout<<"Case #"<<i<<": ";
    solve();}
    return 0;
}

Measured memory_bytes: 3588
#include <bits/stdc++.h>
 
using namespace std;
typedef long long ll;
typedef vector<int> VI;
ll mm=1000000000;ll MM=mm+7;
#define rep(i, n) for(int i=0;i<n;i++)
#define PI 3.141592653589793

int main(){
   int n;
   string s;
   cin >> n >> s;
   int cnt=1;
   rep(i,n-1){
       if(s.at(i)!=s.at(i+1))cnt++;
   }
   cout << cnt << endl;
}

Measured memory_bytes: 512
n = int(input())
csf = [list(map(int,input().split())) for _ in range(n-1)]
ans = []
for i in range(n-1):
  time = csf[i][1]+csf[i][0]
  for j in range(i+1,n-1):
    if time < csf[j][1]:
      time = csf[j][1]
    elif (time-csf[j][1]) % csf[j][2] != 0:
      time = csf[j][1]+((time-csf[j][1])//csf[j][2]+1)*csf[j][2]
    time += csf[j][0]
  ans.append(time)
ans.append(0)
for k in range(n):
  print(ans[k])

Measured memory_bytes: 41200
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <limits>
#include <stack>
#include <queue>
#include <map> 
using namespace std;

#define LL long long

LL packCount(LL P, LL track_num, unsigned int w[], LL n) {
	LL total_w = 0; //最初の荷物でトラック増やすため
	LL track_count = 0;

	LL count = 0;
	while (true) {
		if (total_w + w[count] > P) {
			track_count++;

			if (track_count >= track_num) {
				break;
			}

			total_w = 0;
		}
		else {
			total_w += w[count];
			count++;

			if (count == n) {
				break;
			}
		}
	}

	return count;
}

int main() {
	LL n, k;
	static unsigned int w[100010];

	scanf("%lld %lld", &n, &k);
	for (int i = 0; i < n; i++) {
		scanf("%d", &w[i]);
	}

	LL P = 0;
	LL min = 1;
	LL max = 100000 * 10000;
	while (true) {
		P = (min + max) / 2;

		LL pack_count = packCount(P, k, w, n);

		if (pack_count >= n) {
			max = P;
		}
		else {
			min = P + 1;
		}

		if (min == max) {
			P = max;
			break;
		}
	}

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

	return 0;
}



Measured memory_bytes: 3564
// SeeAlso: https://atcoder.jp/contests/abc062/tasks/abc062_a

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

#define MAX 100000
#define NIL -1
#define MOD 1000000007

typedef int _loop_int;
#define REP(i,n) for(int i = 0; i < n; i++)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

// 最大公約数
inline constexpr ll gcd(ll a,ll b){if(!a||!b)return 0;while(b){ll c=b;b=a%b;a=c;}return a;}
// 最小公倍数
inline constexpr ll lcm(ll a,ll b){if(!a||!b)return 0;return a*b/gcd(a,b);}

#define print2D(h, w, arr) REP(i, h) { REP(j, w) cout << arr[i][j] << " "; cout << endl; }
template<class T> void print(const T& x){cout << setprecision(12) << x << endl;}
template<class T, class... A> void print(const T& first, const A&... rest) { cout << first << " "; print(rest...); }

int x, y;

int group(int num) {
    if (num==1||num==3||num==5||num==7||num==8||num==10||num==12) {
        return 0;
    } else if (num==4||num==6||num==9||num==11) {
        return 1;
    }else {
        return 2;
    }
}
int main() {
    cin >> x >> y;
    int x_g, y_g;
    x_g = group(x);
    y_g = group(y);
    print((x_g==y_g)?"Yes":"No");
    return 0;
}


Measured memory_bytes: 256
/*    ####################  */
/*   # I_LOVE_THUY_LINH #  */
/*  ####################  */
#include <bits/stdc++.h>
#define ll long long
#define db double
#define ld long double
#define ii pair<int,int>
#define pb push_back
#define vi vector<int>
#define vii vector<ii>
#define matrix vector<vector<ll>>
#define fir first
#define sec second
#define all(s) s.begin(),s.end()
#define rall(s) s.rbegin(),s.rend()
#define uni(a) (a).erase(unique(all(a)),(a).end())
#define sz(a) int((a).size())
#define ms(s,val) memset(s,val,sizeof(s))
#define bitcount(n) __builtin_popcountll((ll)n)
#define getbit(s,k) ((s >> k)&1)
#define turnbit(s,k) (s | (1<<k))
#define offbit(s,k) (s & ~(1<<k))
#define flipbit(s,k) (s ^ (1<<k))
#define prec(n) fixed<<setprecision(n)
#define sqr(x) (ll)(x)*(ll)(x)
#define lcm(a,b) ((ll)a/__gcd((ll)a,(ll)b)*(ll)(b))
#define gcd(a,b) __gcd(a,b)
using namespace std;
const int INF = int(1e9);
vector<vector<ii>> g;
vector<ll> wedge;

int n, m;

// Inclusion-Exclusion

bool dfs(int u,int to,int id,int par = -1){
    if (u == to) return true;

    for (auto ev: g[u]){
        if (ev.fir == par) continue;
        if (dfs(ev.fir,to,id,u)){
            wedge[id] |= (1LL << ev.sec);
            return true;
        }
    }

    return false;
}

int main(){
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    cin >> n;
    g.resize(n);
    for (int i = 0; i < n - 1; i++){
        int u, v;
        cin >> u >> v;
        u--, v--;
        g[u].pb({v,i});
        g[v].pb({u,i});
    }
    
    cin >> m;
    wedge.resize(m);
    for (int i = 0; i < m; i++){
        int u, v;
        cin >> u >> v;
        u--, v--;
        dfs(u,v,i);
    }

    ll ans = (1LL << (n - 1));
    for (int mask = 1; mask < (1 << m); mask++){
        ll edge = 0;
        for (int i = 0; i < m; i++)
            if (getbit(mask,i)) edge |= wedge[i];
        int flip = (bitcount((ll)mask) & 1);
        if (flip) ans -= (ll)(1LL << (n - 1 - bitcount((ll)edge)));
        else ans += (ll)(1LL << (n - 1 - bitcount((ll)edge)));
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 256
//Jai Bhole Ki
#include <bits/stdc++.h>
using namespace std;
#define fast int fvariable = []() { std::ios::sync_with_stdio(false); cin.tie(NULL); return 0; }();
#define ll long long
#define LL unsigned ll
#define pb push_back
#define pi pair<ll,ll>
#define debug(x) cout<<x<<"\n";
#define debug cout<<"debugged\n";
#define minval -2e9
#define maxval 2e9
long double PI =3.14159265358979323846;
 
const ll M=1e9+7;
const ll inf=1e18;
const ll ms=2e5+5;
fast;
ll ans;
ll n,m;
void solve()
{
    cin>>n>>m;
    set<ll>st;
    for(int i=0;i<m;i++)
    {
        ll val,a;
        cin>>val;
        while(val--)
            {cin>>a;st.insert(a);}
    }
    cout<<n-st.size()<<endl;
}
int main()
{
 // freopen("input.txt","r",stdin);
//  freopen("output.txt","w",stdout);
    //int t;cin>>t;while(t--)
    {
        solve();
    }
    return 0;
}

Measured memory_bytes: 3664
n, m = map(int, input().split())
store = [tuple(map(int, input().split())) for _ in range(n)]
store.sort()
count = 0
cost = 0
for a, b in store:
    if m - count > b:
        count += b
        cost += a*b
    else:
        cost += (m - count) * a
        print(cost)
        exit()

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

#define ll long long
#define vvi vector< vector<int> >
#define vi vector<int>
#define All(X) X.begin(),X.end()
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define pb push_back
#define pii pair<int,int>
#define mp make_pair
#define pi 3.14159265359
#define shosu(X) fixed << setprecision(X)
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;}
const int INF = 1e9;
int main(){
	int n,m;
	int data[100][100];
	REP(i,100) REP(j,100) data[i][j] = INF;	
	REP(i,100) data[i][i] = 0;
	cin >> n >> m;
	REP(i,m){
		int a,b,c,d;
		scanf("%d,%d,%d,%d",&a,&b,&c,&d);
		a--; b--;
		data[a][b] = c;
		data[b][a] = d;
	}
	REP(k,n){
		REP(i,n){
			REP(j,n){
				data[i][j] = min(data[i][j],data[i][k]+data[k][j]);
			}
		}
	}
	int s,g,v,p;
	scanf("%d,%d,%d,%d",&s,&g,&v,&p);
	s--;
	g--;
	cout << v-p-data[s][g]-data[g][s] << endl;
}

Measured memory_bytes: 1280
N, M = list(map(int, input().split()))
data = [list(map(int, input().split())) for _ in range(N)]

data.sort()

price = 0
for d in data:
    price += d[0] * min(M, d[1])
    M -= d[1]
    if M <= 0:
        break
print(price)

Measured memory_bytes: 27880
// Danielxlr
// https://atcoder.jp/contests/abc174/tasks/abc174_b
// math

#include <iostream>
using namespace std;

int main(){
    long long n, m, ans=0, x ,y;
    cin>>n>>m;
    for(int i=0; i<n; i++){
        cin>>x>>y;
        if(x*x+y*y<=m*m){
            ans++;
        }
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
#define int long long
#define pb push_back
#define l first
#define r second

using namespace std;

const int maxn = 2e5 + 1;

int p[maxn];

signed main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    int n; string s, t;
    cin >> n >> s >> t;
    int ps = s.size() + t.size();
    t += "#" + s;
    for (int i = 1; i < t.size(); i++) {
        p[i] = p[i - 1];
        while (p[i] && t[i] != t[p[i]])
            p[i] = p[p[i] - 1];
        if (t[i] == t[p[i]]) ++p[i];
    }
    cout << ps - p[t.size() - 1];
    return 0;
}


Measured memory_bytes: 892
#include<bits/stdc++.h>
using namespace std;
vector<int>v[100005];
int get_sg(int u,int pre){
    int ret=0;
    for(int i=0;i<v[u].size();i++){
        if(v[u][i]!=pre)
            ret^=(1+get_sg(v[u][i],u));
    }
    return ret;
}
int main(){
        int t,n;
        scanf("%d",&n);
        for(int i=1;i<=n;i++)
            v[i].clear();
        for(int i=1;i<n;i++){
            int x,y;
            scanf("%d%d",&x,&y);
            v[x].push_back(y);
            v[y].push_back(x);
        }
        if(get_sg(1,-1))
            puts("Alice");
        else
            puts("Bob");
    return 0;
}



Measured memory_bytes: 11904
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <stack> // s.top()
#include <bitset>
#include <queue> // s.front()
using namespace std;

typedef long long Int;
typedef pair<Int,Int> P;
#define print(x) cout<<(x)<<endl

#define INF10 10000000000
#define INF5 100000
#define EPS 1e-10
#define MOD 1000000007


bool is_kaibun(int num) {
	int tmp = num;
	int backward = 0;
	while (tmp > 0) {
		backward = 10 * backward + (tmp % 10);
		tmp /= 10;
	}
	if (backward == num)return true;
	else return false;


}

int main() {
	int A, B; cin >> A >> B;
	int score = 0;

	for (int i = A; i <= B; i++) {
		if (is_kaibun(i))score++;
	}
	print(score);






	



	return 0;
}

Measured memory_bytes: 256
base = list(map(str, range(1, 10)))
# print(base)
K = int(input())
count = 9
if K <= count:
    print(base[K-1])
else:
    while count < K:
        tmp = []
        for b in base:
            for i in range(max(0, int(b)%10-1), min(int(b)%10+2, 10)):
                tmp += [b + str(i)]
                count += 1
                if count == K:
                    break
            if count == K:
                break
        base = tmp
    print(tmp[-1])

Measured memory_bytes: 48348
#include<bits/stdc++.h>
#include<string>
#include<vector>
using namespace std;
typedef pair<int, int>P;
typedef long long ll;
#define rep(i,n)for(ll i=0;i<n;++i)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;
//max=({});
//条件式が真ならwhileの中身を回し続ける
//printf("%d\n", ans);

//pairの入力
//vector<pair<ll, ll>>work(n);
//rep(i, n) {
//	ll a, b;
//	cin >> a >> b;
//	work[i] = make_pair(a, b);
//for(auto p:mp)(mapの探索)
//printf("%.10f\n",なんちゃら)
//最大公約数
ll gcd(ll x, ll y) {
	return y ? gcd(y, x % y) : x;
}

ll lcm(ll x, ll y) {
	if (x == 0 || y == 0)return 0;
	return (x / gcd(x, y) * y);
}

//素因数分解
map<ll, ll>ins;
void facterize(ll n) {
	ll a = 2;
	while (n >= a * a) {
		if (n % a == 0) {
			ins[a]++;
			ins[a] = ins[a] % 1000000007;
			n /= a;
		}
		else {
			a++;
		}
	}
	ins[n]++;
}

int keta(int x) {
	int y = 0;
	while (x > 0) {
		y++;
		x /= 10;
	}
	return y;
}

ll dx[4] = { 0,0,-1,1 };
ll dy[4] = { -1,1,0,0 };
ll dp[1010][1010];
ll a[101][101];

//long longしか使わない
int main() {
	ll n, k;
	cin >> n >> k;
	vector<ll>a(n + 1);
	for (ll i = 1;i <= n;++i) {
		cin >> a[i];
	}
	vector<ll>flag(n + 1);
	ll target = a[1];
	vector<ll>comb;
	while (1) {
		k--;
		if (k == 0) {
			cout << target << endl;
			return 0;
		}
		flag[target]++;
		if (flag[target] == 2)comb.push_back(target);
		if (flag[target] == 3)break;
		target = a[target];
	}

	ll m = comb.size();
	ll ans = (k + 1) % m;
	if (ans == 0) {
		cout << comb[m - 1] << endl;
	}
	else {
		cout << comb[ans - 1]<< endl;
	}
	return 0;
}


Measured memory_bytes: 7280
#[allow(unused_imports)]
use std::cmp::{max, min, Ordering};
#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};
#[allow(unused_imports)]
use std::io::{stdin, stdout, BufWriter, Write};
#[allow(unused_imports)]
use std::iter::FromIterator;
mod util {
    use std::fmt::Debug;
    use std::io::{stdin, stdout, BufWriter, StdoutLock};
    use std::str::FromStr;
    #[allow(dead_code)]
    pub fn line() -> String {
        let mut line: String = String::new();
        stdin().read_line(&mut line).unwrap();
        line.trim().to_string()
    }
    #[allow(dead_code)]
    pub fn chars() -> Vec<char> {
        line().chars().collect()
    }
    #[allow(dead_code)]
    pub fn gets<T: FromStr>() -> Vec<T>
    where
        <T as FromStr>::Err: Debug,
    {
        let mut line: String = String::new();
        stdin().read_line(&mut line).unwrap();
        line.split_whitespace()
            .map(|t| t.parse().unwrap())
            .collect()
    }
    #[allow(dead_code)]
    pub fn with_bufwriter<F: FnOnce(BufWriter<StdoutLock>) -> ()>(f: F) {
        let out = stdout();
        let writer = BufWriter::new(out.lock());
        f(writer)
    }
}
#[allow(unused_macros)]
macro_rules ! get { ( [ $ t : ty ] ) => { { let mut line : String = String :: new ( ) ; stdin ( ) . read_line ( & mut line ) . unwrap ( ) ; line . split_whitespace ( ) . map ( | t | t . parse ::<$ t > ( ) . unwrap ( ) ) . collect ::< Vec < _ >> ( ) } } ; ( [ $ t : ty ] ; $ n : expr ) => { ( 0 ..$ n ) . map ( | _ | get ! ( [ $ t ] ) ) . collect ::< Vec < _ >> ( ) } ; ( $ t : ty ) => { { let mut line : String = String :: new ( ) ; stdin ( ) . read_line ( & mut line ) . unwrap ( ) ; line . trim ( ) . parse ::<$ t > ( ) . unwrap ( ) } } ; ( $ ( $ t : ty ) ,* ) => { { let mut line : String = String :: new ( ) ; stdin ( ) . read_line ( & mut line ) . unwrap ( ) ; let mut iter = line . split_whitespace ( ) ; ( $ ( iter . next ( ) . unwrap ( ) . parse ::<$ t > ( ) . unwrap ( ) , ) * ) } } ; ( $ t : ty ; $ n : expr ) => { ( 0 ..$ n ) . map ( | _ | get ! ( $ t ) ) . collect ::< Vec < _ >> ( ) } ; ( $ ( $ t : ty ) ,*; $ n : expr ) => { ( 0 ..$ n ) . map ( | _ | get ! ( $ ( $ t ) ,* ) ) . collect ::< Vec < _ >> ( ) } ; }
#[allow(unused_macros)]
macro_rules ! debug { ( $ ( $ a : expr ) ,* ) => { eprintln ! ( concat ! ( $ ( stringify ! ( $ a ) , " = {:?}, " ) ,* ) , $ ( $ a ) ,* ) ; } }
const BIG_STACK_SIZE: bool = true;
#[allow(dead_code)]
fn main() {
    use std::thread;
    if BIG_STACK_SIZE {
        thread::Builder::new()
            .stack_size(32 * 1024 * 1024)
            .name("solve".into())
            .spawn(solve)
            .unwrap()
            .join()
            .unwrap();
    } else {
        solve();
    }
}

fn solve() {
    let (x, y) = get!(usize, usize);
    println!("{}", x + y / 2);
}


Measured memory_bytes: 8572
#include <bits/stdc++.h>
 using namespace  std;
int main(){
  long long  n,k,sum=0;
  cin>>n>>k;
  long long  a[n];
  for (int i=0;i <n;i++){
    cin>>a[i];
  }
  sort(a,a+n);
  for (int i=0;i <k;i++){
    sum+=a[i];
    }
  cout<<sum;
  return 0;
}

Measured memory_bytes: 3612
import java.util.Scanner;

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

        String str = sc.next();
        String small;
        switch(str.charAt(index-1)){
            case 'A':
            small = "a";
            break;
            case 'B':
            small = "b";
            break;
            case 'C':
            small = "c";
            break;
            default:
            small = "error";

        }

        StringBuilder sb = new StringBuilder();
        sb.append(str.substring(0, index-1));
        sb.append(small);
        sb.append(str.substring(index));

        System.out.println(sb.toString());
    }
}

Measured memory_bytes: 21844
package main

import (
	"bufio"
	"container/heap"
	"fmt"
	"io"
	"os"
	"sort"
)

type contest struct {
	in  io.Reader
	out io.Writer
}

func (con *contest) Scan(a ...interface{}) (int, error) {
	return fmt.Fscan(con.in, a...)
}
func (con *contest) Scanln(a ...interface{}) (int, error) {
	return fmt.Fscanln(con.in, a...)
}
func (con *contest) Scanf(f string, a ...interface{}) (int, error) {
	return fmt.Fscanf(con.in, f, a...)
}
func (con *contest) Print(a ...interface{}) (int, error) {
	return fmt.Fprint(con.out, a...)
}
func (con *contest) Println(a ...interface{}) (int, error) {
	return fmt.Fprintln(con.out, a...)
}
func (con *contest) Printf(f string, a ...interface{}) (int, error) {
	return fmt.Fprintf(con.out, f, a...)
}
func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	con := &contest{in: in, out: out}
	con.main()
}

type PQLess []int

func (pq PQLess) Len() int { return len(pq) }

func (pq PQLess) Less(i, j int) bool {
	return pq[i] < pq[j]
}

func (pq PQLess) Swap(i, j int) {
	pq[i], pq[j] = pq[j], pq[i]
}

func (pq PQLess) Peek() interface{} {
	return pq[0]
}

func (pq *PQLess) Push(x interface{}) {
	item := x.(int)
	*pq = append(*pq, item)
}

func (pq *PQLess) Pop() interface{} {
	n := len(*pq)
	x := (*pq)[n-1]
	*pq = (*pq)[:n-1]
	return x
}

type item struct {
	v, i int
}

type byOrder []item

func (b byOrder) Len() int           { return len(b) }
func (b byOrder) Less(i, j int) bool { return b[i].v < b[j].v }
func (b byOrder) Swap(i, j int)      { b[i], b[j] = b[j], b[i] }

func (con *contest) main() error {
	var N int
	con.Scan(&N)

	p := make([]int, N)
	for i := 0; i < N; i++ {
		con.Scan(&p[i])
	}
	pPQ := (*PQLess)(&p)
	heap.Init(pPQ)

	q := make([]item, 2*N)
	r := make([]item, 2*N)
	for i := 0; i < 2*N; i++ {
		con.Scan(&r[i].v)
		r[i].i = i
	}
	sort.Sort(byOrder(r))
	for i := 0; i < 2*N; i++ {
		q[r[i].i].v = r[i].v
		q[r[i].i].i = i
	}

	pSum := 0
	qSum := 0
	for i := 0; i < N; i++ {
		pSum += p[i]
		qSum += r[i].v
	}

	s := N
	best := pSum - qSum
	for i := 0; i < N; i++ {
		if q[i].i < s {
			qSum -= q[i].v
			qSum += r[s].v
			r[s].v = 0
		}
		r[q[i].i].v = 0
		for s < len(r) && r[s].v == 0 {
			s++
		}
		if q[i].v > pPQ.Peek().(int) {
			pSum -= heap.Pop(pPQ).(int)
			pSum += q[i].v
			heap.Push(pPQ, q[i].v)
		}
		if pSum-qSum > best {
			best = pSum - qSum
		}
	}

	con.Println(best)

	return nil
}


Measured memory_bytes: 12288
import sys
N=int(input())
A=list(map(int,input().split()))
if 0 in A:
    print(0)
    sys.exit()

ans=A[0]
for i in range(N-1):
    if ans>10**18:
        print(-1)
        break
    else:
        ans*=A[i+1]
        if ans>10**18:
            print(-1)
            break

if ans<=10**18:
    print(ans)

Measured memory_bytes: 21568
#pragma GCC optimize("Ofast")   //Comment optimisations for interactive problems (use endl)
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")
#include<bits/stdc++.h>

using namespace std;

#define  fastio         ios:: sync_with_stdio(0);cin.tie(0);cout.tie(0);cout<<fixed;cout<<setprecision(10);
#define  randomINIT     mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
#define  foo(i,a,n)     for(ll i = (a); i <= n; i++)
#define  frr(i,a,n)     for(ll i = (a); i >= n; i--)
#define  fo(i,n)        for(ll i = 0; i < n; i++)
#define  all(x)         (x).begin(),(x).end()
#define  mset(x,val)    memset(x,val,sizeof(x))
#define  newl           cout<<"\n"
#define  pb             push_back
#define  mp             make_pair
#define  s              second
#define  f              first
#define  dline          cerr<<"///REACHED///\n";
#define  deb1(x)        cerr<<#x<<" = "<<x<<'\n';
#define  deb2(x,y)      cerr<<'['<<#x<<','<<#y<<"] = "<<'['<<x<<','<<y<<']'<<'\n';
#define  deb3(x,y,z)    cerr<<'['<<#x<<','<<#y<<','<<#z<<"] = "<<'['<<x<<','<<y<<','<<z<<']'<<'\n';

typedef  long long             ll;
typedef  long double           ld;
typedef  pair<ll,ll>           pll;
typedef  vector<ll>            vll;
typedef  vector<pll>           vpll;

const ll   MOD   =  1e+9+7;
const ll   INF   =  0x7f7f7f7f7f7f7f7f;
const int  INFi  =  0x7f7f7f7f;
const ll   MAXN  =  1e+5+7;

vll adj[MAXN];ll visit[MAXN]={};
int dx8[]={0,1,1,1,0,-1,-1,-1}, dy8[]={1,1,0,-1,-1,-1,0,1};
int dx4[]={0,1,0,-1}, dy4[]={1,0,-1,0};

//<<-----Declare Variable Here------->>//
int t=1;
ll n;
ll res[105];
map<ll,ll>map1;
//<<-----Implement Functions Here---->>//
void primfact(ll n)
{
	for(ll i=2;i<=n;i++)
	{	
		while(n%i==0){
			res[i]++;n/=i;
		}
	}
}
//<<-----Start of Main--------------->>//
void MAIN(){
		cin>>n;ll ans = 0;
		for(ll i=1;i<=n;i++)primfact(i);

		for(ll i=1;i<=n;i++)
		{
			if(res[i]>=2)map1[3]++;
			if(res[i]>=4)map1[5]++;
			if(res[i]>=14)map1[15]++;
			if(res[i]>=24)map1[25]++;
			if(res[i]>=74)map1[75]++;
		}
		ans += map1[75];
		ans += map1[25]*(map1[3]-1);
		ans += map1[15]*(map1[5]-1);
		ans += (map1[5]*(map1[5]-1))/2 * (map1[3]-2);
		cout<<ans<<endl;


}

int main(){
	fastio;randomINIT;

	//cin>>t;
	while(t--){
		MAIN();
	}

    #ifndef ONLINE_JUDGE
    cout<<"\nTime Elapsed: " << 1.0*clock() / CLOCKS_PER_SEC << " sec\n";
    #endif
}

Measured memory_bytes: 5924
#include <iostream>
#include <fstream>
#include <sstream>
#include <string>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <map>
#include <queue>
#include <ctime>
#include <cmath>

using namespace std;

#define forn(I,N) for (int I=0; I<N; I++)
#define fornd(I,N) for (int I=N-1; I>=0; I--)
#define forab(I,A,B) for (int I=A; I<=B; I++)
#define forabd(I,A,B) for (int I=B; I>=A; I--)
#define FOREACH(I,A) for (__typeof__(A)::iterator I=A.begin(); I<A.end(); I++)
#define pb push_back
#define mp make_pair

typedef long long int ll;

const ll mod = 1000000007;

int main() {
  int N, K;
  string S;

  cin >> N >> K;
  cin >> S;

  if (S[K - 1] >= 'A') {
    S[K - 1] -= 'A' - 'a';
  }

  cout << S << endl;

  return 0;
}


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

#define rep2(x,fr,to) for(int x=(fr);x<(to);x++)
#define rep(x,to) for(int x=0;x<(to);x++)
#define repr(x,fr,to) for(int x=(fr);x>=(to);x--)
#define all(c) c.begin(),c.end()
#define sz(v) (int)v.size()

using namespace std;
typedef long long ll; typedef vector<int> VI; typedef pair<int,int> pii;
typedef vector<ll> VL; const int MD = 1e9 + 7;
void dbg(){ cerr << "\n"; } template <typename T,typename ...T2> void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }


int main()
{
	cin.tie(0); ios_base::sync_with_stdio(false);
	int n;
	cin >>n;
	VI b(n+1), a(n);
	rep(i, n-1) cin >>b[i+1];
	b[0] = b[n]=1<<28;
	rep(i, n){
		a[i] = min(b[i], b[i+1]);
	}
	cout << accumulate(all(a), 0LL) <<"\n";
	return 0;
	
}


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

int main() {
  int n,minu;
  cin >>n;
  int w[n];
  int i=0,sum=0;
  while(cin >>w[i]){
    sum+=w[i];
    i++;
  }
  i=0;
  minu=sum;
  int sum2=0;
  while(i<n){
    sum2+=w[i];
    if(minu > abs(2*sum2-sum)){
      minu=abs(2*sum2-sum);
    }
    i++;
  }
  cout << minu <<endl;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void){

    int N,K,i;
    char S[10],ans[10],c[1];

    scanf("%d",&N);
    scanf("%s",S);
    scanf("%d",&K);

    for(i = 0;i < N;i++){
        if(S[i] != S[K - 1]){
            S[i] = '*';
        }else{
            continue;
        }
    }

    printf("%s",S);

    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define all(c) (c).begin(),(c).end()
#define pb push_back 
#define mp make_pair
typedef long long ll;



int main(){
	int n,m; cin>>n>>m;
	int cont=0;
	int s=0;
	int a[n];
	
	for(int i=0; i<n; i++){
		cin>>a[i];
		s+=a[i];
	}
	
	for(int i=0; i<n; i++){
		if(a[i]*4*m>=s) cont++;
	}
	
	if(cont>=m) cout<<"Yes";
	else cout<<"No";
	
	
				
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) REP(i, 0, n)
#define rrep(i, n) for (int i = (int)(n-1); i >= 0; i--)
#define sz(x) int(x.size())
#define bitsz(x) int(__builtin_popcount(x))
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define INF 2e9
#define LINF 1e18
#define mod 1000000007
template<class T> inline bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b) { if (a > b) { a = b; return 1; } return 0; }
typedef long long ll;
typedef pair<int, int> P;
int dx[4] = {1,0,-1,0};
int dy[4] = {0,1,0,-1};


int main() {
    int a,b,c; cin >> a >> b >> c;
    if (a==b && a!=c) cout << "Yes" << endl;
    else if (b==c && c!=a) cout << "Yes" << endl;
    else if (c==a && a!=b) cout << "Yes" << endl;
    else cout << "No" << endl;
}    

Measured memory_bytes: 3620
#include <iostream>
#include <set>
#define int long long
using namespace std;
set<int>s; int n, m, p;
signed main() {
	cin >> n; for (int i = 0; i < n; i++) { int p; cin >> p; s.insert(p); }
	cin >> m; for (int i = 0; i < m; i++) { int p; cin >> p; s.insert(p); }
	for (int i : s)cout << i << endl;
}


Measured memory_bytes: 21844
/**
 *    author:  otera    
**/
#include<iostream>
#include<string>
#include<cstdio>
#include<cstring>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<deque>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;

#define int long long
typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef long double ld;
const int inf=1e9+7;
const ll INF=1LL<<60 ;
const ll mod=1e9+7 ;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<int, int> P;
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
#define debug(x)  cerr << #x << " = " << (x) << endl;
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; }

void solve() {
	int h, w; cin >> h >> w;
    if(h == 1) {
        cout << 1 << endl;
        return;
    }
    if(w == 1) {
        cout << 1 << endl;
        return;
    }
    if(h % 2 == 0) {
        cout << w * (h / 2) << endl;
    } else {
        cout << w * (h / 2) + (w % 2 == 0 ? w / 2 : (w + 1) / 2) << endl;
    }
}

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

Measured memory_bytes: 256
// vim: foldmethod=marker
#include <iostream> // cout, endl, cin{{{
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;
typedef long long ll;/*}}}*/

int main(int argc, char *argv[])
{
  ll n;
  cin >> n;
  long P[n + 1];
  long ans = n;

  for (long i = 1; i <= n; ++i) {
    cin >> P[i];
  }

  long m = n;
  for (int i = 1; i <= n; ++i) {
    long pi = P[i];
    m = min(m, pi);

    if (pi > m) {
      ans--;
    }
  }




  cout << ans << endl;
}


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

void swap(int &a, int &b) {
	a = a ^ b;
	b = a ^ b;
	a = a ^ b;
}

int main() {
	int W, N;
	cin >> W >> N;
	int start[W];
	for (int w = 0; w != W; ++w) {
		start[w] = w+1;
	}

	int a, b, throwaway;

	for (int n = 0; n != N; ++n) {
		cin >> a;
		cin.get();
		cin >> b;
		swap(start[a-1], start[b-1]);
	}

	for (int w = 0; w != W; ++w) {
		cout << start[w] << endl;
	}
	return 0;
}

Measured memory_bytes: 1160
def nCr(n, r):
    return (fact(n) / (fact(r)* fact(n - r)))

def fact(n):
    res = 1
    if n == 0:
        res == 1
    elif n == 1:
        res == 1
    else:
        for i in range(2, n + 1):
            res = res * i

    return res

inList = list(map(int, input().split()))
N = inList[0]
M = inList[1]
a = nCr(N, 2)
b = nCr(M, 2)
if N == M == 1:
    print(0)
else:
    print(int(a+b))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
int main(){
  int cnt=0;
  string s,t="",u="",alph="abcdefghijklmnopqrstuvwxyz",alphh="zyxwvutsrqponmlkjihgfedcba";
  cin >> s;
  if(s==alph){
    cout << "abcdefghijklmnopqrstuvwxz" << endl;
    return 0;
  }
  if(s.size()==26&&s==alphh){
    cout << -1 << endl;
    return 0;
  }else if(s.size()==26&&s!=alphh){
    for(int i=s.size()-1;i>=0;i--){
      if(s[i]!=alph[i]){
        cnt++;      
      }
      if(cnt==2){
        for(int j=s.size()-1;j>=0;j--){
          string ss=s.substr(j,s.size()-j);
          sort(ss.begin(),ss.end());
          for(int k=0;k<ss.size();k++){
            if(ss[k]>s[j-1]){
              cout << s.substr(0,j-1) << ss[k] << endl;
              return 0;
            }
          }
        }
      }
    }
  }
  t+=s;
  sort(s.begin(),s.end());
  for(int i=0;i<alph.size();i++){
    if(s[i]!=alph[i]){
      cout << t << alph[i] << endl;
      return 0;
    }
  }
}


Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Scanner;
import java.util.function.IntToDoubleFunction;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int[] nums = getIntArray(sc);
		for (int i = 0; i < nums.length; i++) {
			if (nums[i] != i + 1) {
				System.out.println(i + 1);
			}
		}
	}

	/**
	 * *汎用メソッド<br>
	 * 入力した配列に対する順列を取得
	 *
	 * @param numArray
	 * @return
	 */
	private static List<Integer[]> getPermutation(int[] numArray) {
		List<Integer[]> permutation = new ArrayList<>();
		Integer[] ans = new Integer[numArray.length];
		boolean[] used = new boolean[numArray.length];

		return buildPermutaion(permutation, numArray, ans, used, 0);
	}

	/**
	 * *汎用メソッド(内部)<br>
	 * 入力した配列に対する順列を作成
	 *
	 * @param list
	 * @param numArray
	 * @param ans
	 * @param used
	 * @param depth
	 * @return
	 */
	private static List<Integer[]> buildPermutaion(List<Integer[]> list, int[] numArray, Integer[] ans, boolean[] used,
			int depth) {

		// 全部使い切った時=>できた順列を返す
		if (depth == numArray.length) {
			list.add(ans.clone());
			return list;
		}
		// 使い切っていない場合

		for (int i = 0; i < numArray.length; i++) {
			if (used[i]) {
				continue;
			}
			ans[depth] = numArray[i];
			used[i] = true;
			list = buildPermutaion(list, numArray, ans, used, depth + 1);

			used[i] = false;
		}

		return list;
	}

	/**
	 * *汎用メソッド <br>
	 * スキャナーからの入力値をlongで返却
	 *
	 * @return
	 */
	public static long getLong(Scanner sc) {

		return Long.parseLong(sc.next());
	}

	/**
	 * *汎用メソッド <br>
	 * スキャナーからの入力値をintで返却
	 *
	 * @return
	 */
	public static int getInt(Scanner sc) {

		return Integer.parseInt(sc.next());
	}

	/**
	 * *汎用メソッド <br>
	 * スキャナーからの入力値をStringで返却
	 *
	 * @return
	 */
	public static String getString(Scanner sc) {

		return sc.next();
	}

	/**
	 * *汎用メソッド <br>
	 * スキャナーからの入力値をint配列で返却
	 *
	 * @return
	 */
	public static int[] getIntArray(Scanner sc) {
		String line = "";
		// 直前にnext()を実行していると改行コードだけ取ってしまうのでその対策
		while (line.equals("")) {
			line = sc.nextLine();
		}

		String[] strArray = line.split(" ");
		int[] intArray = new int[strArray.length];
		for (int i = 0; i < strArray.length; i++) {
			intArray[i] = Integer.parseInt(strArray[i]);
		}
		return intArray;
	}

}


Measured memory_bytes: 35656
using System;
using System.Linq;
using System.Collections.Generic;
using System.Text.RegularExpressions;
using System.Collections;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var ir = new Resolver(new ConsoleReader());
            Console.WriteLine(ir.Resolve());
        }
    }

    public class Resolver
    {
        IInputReader InputReader { get; }
        public List<string> Messages { get; set; } = new List<string>();

        float[] input;

        public void ParseLines()
        {
            input = InputReader.ReadLine().Split(' ').Select(x => float.Parse(x)).ToArray();
        }

        public string Resolve()
        {

            return (input[0] / input[1]).ToString();
        }


        public Resolver(IInputReader inputReader)
        {
            InputReader = inputReader;
            ParseLines();
        }

    }

    public interface IInputReader
    {
        string ReadLine();
    }

    class ConsoleReader : IInputReader
    {
        string IInputReader.ReadLine()
        {
            return Console.ReadLine();
        }
    }
}

Measured memory_bytes: 13396
i = gets.to_i
ary = gets.split.map(&:to_i)
count = 0
sum = 0
(i-1).times do |n|
  if ary[n]>= ary[n+1]
    count +=1
  else
    count =0
  end
  if sum<count
    sum =count
  end
end
puts sum


Measured memory_bytes: 8580