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

#define IOS cin.tie(0);ios_base::sync_with_stdio(false)

#define ll      long long
#define Fi      first
#define Se      second
#define Pb      push_back
#define vi      vector<int>
#define vs      vector<string>
#define vp      vector<pair<int,int>>
#define vvi     vector<vector<int>>
#define vvp     vector<vector<pair<int,int>>>
using Graph  =  vector<vector<int>>; //Caution!! Segmentation Fault!! Don't forget to add +1!

#define sz(x) (int)x.size()
#define all(v) v.begin(),v.end()
#define output_s(s) printf("%s\n",(s).c_str())

#define rep(i,n)        for(int i=0;i<(int)(n);i++)
#define Rep(i,n,m)      for(int i=(int)(n);i<(int)(m);i++)
#define RepS(i,n,m)     for(int i=(int)(n);i<=(int)(m);i++)
#define RRepS(i,n,m)    for(int i=(int)(n);i>=(int)(m);i--)
#define SRepS(i,n,m)     for(int i=(int)(n);i*i<=(int)(m);i++)
#define RepA(x)         for(auto &item:(x))

void CINT(){} //@shibh308's template
template<class Head,class... Tail> void CINT(Head&& head,Tail&&... tail){cin>>head; CINT(move(tail)...);}    
#define CIN(...) int __VA_ARGS__;CINT(__VA_ARGS__)
#define LCIN(...) ll __VA_ARGS__;CINT(__VA_ARGS__)
#define SCIN(...) string __VA_ARGS__;CINT(__VA_ARGS__)
#define VCIN(x) for(auto &item:x) cin>>item

void OUT(){}
template<class Head,class...Tail> void OUT(Head&& head,Tail&&...tail){cout<<head<<(sizeof...(tail)?" ":"\n"); OUT(move(tail)...);}
#define COUT(...) OUT(__VA_ARGS__)

template<typename TypeInt>TypeInt GCD(TypeInt a,TypeInt b){return a%b==0?b:GCD(b,a%b);} //最大公約数
template<typename TypeInt>TypeInt LCM(TypeInt a,TypeInt b){return a*b/GCD(a,b);} //最小公倍数
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return true;}return false;}
template<class T>bool comp(T a,T b){return abs(a)<abs(b);} //比較関数

void YES(bool f){printf(f?"YES\n":"NO\n");}
void Yes(bool f){printf(f?"Yes\n":"No\n");}
void Possible(bool f){printf(f?"Possible\n":"Impossible\n");}
void POSSIBLE(bool f){printf(f?"POSSIBLE\n":"IMPOSSIBLE\n");}

//----------------------library------------------------//

//const int dx[4]={1,0,-1,0};
//const int dy[4]={0,1,0,-1};
const int dx[8]={1,0,-1,0,1,-1,-1,1};
const int dy[8]={0,1,0,-1,1,1,-1,-1};
const int NMAX = 200;
const int INF = 1e9;
const int MOD = 1e9+7;
bool flag;

//----------------------Global-------------------------//

signed main(){
    CIN(N);
    map<int,int> mp;
    RepS(i,1,N)mp[i]=0;
    rep(i,N-1){
        int a;cin>>a;
        mp[a]++;
    }
    RepA(mp){
        printf("%d\n",item.second);
    }
    

    return 0;
}


Measured memory_bytes: 13068
#include <bits/stdc++.h>
using namespace std;
void Main();

using i8  = int8_t;   /* -128 ~ 127 */
using u8  = uint8_t;  /* 0 ~ 255 */
using i16 = int16_t;  /* -32,768 ~ 32,767 */
using u16 = uint16_t; /* 0 ~ 65,535 */
using i32 = int32_t;  /* -2,147,483,648 ~ 2,147,483,647 */
using u32 = uint32_t; /* 0 ~ 4,294,967,295 */
using i64 = int64_t;  /* -9,223,372,036,854,775,808 ~ 9,223,372,036,854,775,807 */
using u64 = uint64_t; /* 0 ~ 18,446,744,073,709,551,615 */
using f32 = float;    /* (-3.4 * 10^38) ~ (3.4 * 10^38) */
using f64 = double;   /* (-1.7 * 10^308) ~ (1.7 * 10^308) */
using f80 = __float80;
template <class T> using Vec = vector<T>;
constexpr i64 INF = 1010000000000000017;
constexpr i64 MOD = 1e9 + 7;
constexpr f64 EPS = 1e-12;
constexpr f64 PI = 3.14159265358979323846;
#define ALL(v) v.begin(), v.end()
#define GCD(a, b) __gcd(a, b) /* 最大公約数 */
#define LCM(a, b) a / __gcd(a, b) * b /* 最小公倍数 */

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}

void Main() {
    u32 N, R;
    cin >> N >> R;
    if (N > 10) {
        cout << R << endl;
    } else {
        cout << R + 100 * (10 - N) << endl;
    }
}


Measured memory_bytes: 384
e1,e2,e3,e4 = map(int,input().split())

if e1==e2 and e3==e4:
    print("yes")
elif e1==e3 and e2==e4:
    print("yes")
elif e1==e4 and e2==e3:
    print("yes")
else:
    print("no")


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

int main(){
	int n, i;
	cin >> n;
	int b[n], f[n], r[n], v[n], h1[30], h2[30], h3[30], h4[30];
	for(i = 0; i <= 29; i++){
		h1[i] = 0;
		h2[i] = 0;
		h3[i] = 0;
		h4[i] = 0;
	}
	
	for(i = 0; i <= n-1; i++){
		cin >> b[i] >> f[i] >> r[i] >> v[i];
	}
	
	for(i = 0; i <= n-1; i++){
		switch(b[i]){
			case 1:
				h1[(f[i]-1)*10+r[i]-1] += v[i];
				break;
			case 2:
				h2[(f[i]-1)*10+r[i]-1] += v[i];
				break;
			case 3:
				h3[(f[i]-1)*10+r[i]-1] += v[i];
				break;
			case 4:
				h4[(f[i]-1)*10+r[i]-1] += v[i];
				break;
		}
	}
	
	for(i = 0; i <= 29; i++){
		cout << ' ' << h1[i];
		if(i%10 == 9){
			cout << endl;
		}
	}
	cout << "####################" << endl;
	for(i = 0; i <= 29; i++){
		cout << ' ' << h2[i];
		if(i%10 == 9){
			cout << endl;
		}
	}
	cout << "####################" << endl;
	for(i = 0; i <= 29; i++){
		cout << ' ' << h3[i];
		if(i%10 == 9){
			cout << endl;
		}
	}
	cout << "####################" << endl;
	for(i = 0; i <= 29; i++){
		cout << ' ' << h4[i];
		if(i%10 == 9){
			cout << endl;
		}
	}
	
	return 0;
}
	

Measured memory_bytes: 1168
from itertools import product, combinations

n, *abc = list(map(int, input().split()))
ll = [int(input()) for _ in range(n)]

# 合成してから短縮/延長すればよい
# 合成方法を全探索する

ans = float("inf")
for n_use in range(3, n+1) : # 何本使うか
    for l_use in combinations(ll, n_use) : # どの竹を使うか
        for dist in product(*[range(3) for _ in range(n_use)]) : #竹をどう合成するか
            if len(set(dist)) != 3 :
                continue

            labc = [0, 0, 0]
            for i, l in zip(dist, l_use) :
                labc[i] += l
    
            diff = [abs(labc[i]-abc[i]) for i in range(3)]
            ans = min(ans, 10*(n_use-3)+sum(diff))

print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define full(a) a.begin(),a.end()
#define rfull(a) a.rbegin(),a.rend()

using namespace std;
const double pi=acos(-1.0);
const double pii=2*pi;
const double eps=1e-6;
const long long MOD=1e9+7;

void solve(){
    char a;
    cin>>a;
    if(a>='A' && a<='Z'){
        cout<<"A\n";
    }
    else
    {
        cout<<"a\n";
    }
    
}

int main(){
    std::ios::sync_with_stdio(false);
    std::cin.tie(NULL);
    std::cout.tie(NULL);

    int t=1;
    // cin >> t;
    while(t--){
        solve();
    }
    return 0;
}

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

using namespace std;

const long long INF = 1LL<<60;

int N, M; // input
vector<vector<int> > G; //graph

// メモ化再帰
int dp[100100];

int rec( int v ){
    if(dp[v] != -1) return dp[v]; // if it's updated, use the value

    int res = 0;
    for(auto nv : G[v]){
        res = max(res, rec(nv) + 1);
    }

    return dp[v] = res; // memo and return
}

int main(){
    cin >> N >> M;
    G.assign(N, vector<int>());

    for(int i=0; i<M; ++i){
        int x, y;
        cin >> x >> y;
        --x, --y;
        G[x].push_back(y);
    }

    //init(not visted)
    for(int v=0; v<N; ++v) dp[v] = -1;

    //memosaiki
    int res = 0;
    for(int v=0; v<N; ++v){
        res = max(res, rec(v));
    }

    cout << res << endl;
}


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

int main() {
  ll k;
  cin >> k;
  queue<ll> q;
  for (ll i = 1; i <= 9; ++i) {
    q.push(i);
  }
  ll ans = 0;
  for (ll i = 0; i < k; ++i) {
    ans = q.front(); q.pop();
    ll t = ans % 10;
    for(ll i = -1; i < 2; ++i) {
      if(t + i == -1 || t + i == 10) continue;
      q.push(ans * 10 + t + i);
    }
  }
  cout << ans << endl;
}

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

#define ll     long long
#define fr     first
#define sec    second
#define rep(i,n)  for(i=0;i<n;i++)
#define vi     vector <int>
#define vc     vector <char>
#define vl     vector <ll>
#define vb     vector <bool>
#define pb     push_back
#define M      1000000007
#define ios    ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define open   freopen("input.txt","r",stdin);
#define close  freopen("output.txt","w",stdout);
#define M_PI   3.14159265358979323846
#define pp     pair<int,int>
#define nn 100003

int main()
{
    ios;
    ll a;
    cin>>a;
    ll ans = a+a*a+a*a*a;
    cout<<ans;
    return 0;
}


Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define int ll
signed main(){
    string s; cin >> s;
    map<int,int>mp;
    for(auto c : s) mp[c]++;
    int ans = 0;
    for(auto i : mp){
        for(auto j : mp){
            if(i.first == j.first)continue;
            ans += i.second * j.second;
        }
    }
    ans /= 2;
    cout <<ans  + 1  << endl;
}


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

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

    if(D==0){
        if(N==100){
            cout<<101<<endl;
            return 0;
        }
        cout<<N<<endl;
    }
    if(D==1){
        if(N==100){
            cout<<10100<<endl;
            return 0;
        }
        cout<<N*100<<endl;
    }
    if(D==2){
        if(N==100){
            cout<<1010000<<endl;
            return 0;
        }
        cout<<N*10000<<endl;
    }
}

Measured memory_bytes: 256
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>

using namespace std;

inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v;}
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str();}

typedef vector<int> vi;
typedef vector<vi>  vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;

#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EACH(t,i,c) for(t::iretator i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

const double EPS = 1e-10;
const double PI = acos(-1.0);

int main() {
	int N, T, E;
	cin >> N >> T >> E;

	int temp;
	
	REP(i, N) {
		cin >> temp;

		for(int j = T-E; j <= T+E; j++) {
			if(j%temp == 0) {
				cout << i+1 << endl;
				return 0;
			}
		}
	}

	cout << "-1" << endl;
	return 0;
}

Measured memory_bytes: 1164
n=int(input())
P=[list(map(int,input().split())) for i in range(n)]
dist=0
for i in range(n-1):
    for j in range(i+1,n):
        dist+=((P[i][0]-P[j][0])**2+(P[i][1]-P[j][1])**2)**0.5
print(2*dist/n)


Measured memory_bytes: 9216
#include<bits/stdc++.h>
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3f
#define MOD 1000000007
#define EPS (1e-10)
#define rep(i,n)for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
typedef pair<int, int>P;

ll dp[1001][1001];
ll fact[1001];
ll ppow(ll a, ll b) {
	ll res = 1;
	while (b) {
		if (b & 1)res = (res*a) % MOD;
		a = (a*a) % MOD;
		b >>= 1;
	}
	return res;
}
ll comb(ll a, ll b) {
	return (((fact[a] * ppow(fact[a - b], MOD - 2))%MOD)*ppow(fact[b], MOD - 2))%MOD;
}
int main() {
	fact[0] = 1;
	int n, a, b, c, d; scanf("%d%d%d%d%d", &n, &a, &b, &c, &d);
	for (int i = 1; i <= n; i++)fact[i] = (fact[i - 1] * i) % MOD;
	rep(i, n)dp[i][0] = 1;
	for (int i = a - 1; i < b; i++) {
		for (int j = 0; j <= n; j++) {
			if (j)(dp[i + 1][j] += dp[i][j]) %= MOD;
			if (j - c*(i + 1) < 0)continue;
			ll y = 1, t = n - j;
			rep(p, c - 1) {
				(y *= comb(t + i + 1, t)) %= MOD;
				t += i + 1;
			}
			for (int k = c; j - k*(i + 1) >= 0 && k <= d; k++) {
				(y *= comb(t + i + 1, t)) %= MOD;
				ll o = y;
				(o *= ppow(fact[k], MOD - 2)) %= MOD;
				(dp[i + 1][j] += ((dp[i][j - k*(i + 1)] * o) % MOD)) %= MOD;
				t += i + 1;
			}
		}
	}
	cout << dp[b][n] << endl;
}

Measured memory_bytes: 8064
#include<bits/stdc++.h>
using namespace std;
#define loop(i,x,z) for (int i=x;i<z;i++)
using ll = long long;
#define pb push_back
#define fi first
#define se second
#define all(x) x.begin(), x.end()
typedef pair<int, int> pii;
const ll M = 1000000007;
typedef int item;
int main()
{
	ll a,b,c,d;
	cin>>a>>b>>c>>d;
	cout<<max(a*c,max(a*d,max(b*c,b*d)));
}

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

int main() {
  string S;
  cin >> S;
  int count = 0;
  for (int i = 0; i < S.size(); i++) {
    if (S[i] == 'o') {
      count++;
    }
  }
  int price = 700 + 100 * count;
  cout << price << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int int64_t
#define MAX 105
int w[MAX],v[MAX],dp[100005];
int knapsack(int n,int x)
{
	for(int i=0;i<=n;i++)
	for(int j=x;j>=0;j--)
	{
		if(i==0||j==0)
		dp[j]=0;
		else if(j>=w[i])
		{
			if(dp[j]<dp[j-w[i]]+v[i])
			dp[j]=dp[j-w[i]]+v[i];
		}
	}
	return dp[x];
}
signed main()
{
	int n,x,i;
	cin>>n>>x;
	for(i=1;i<=n;i++)
	{
		cin>>w[i]>>v[i];
	}
	cout<<knapsack(n,x)<<"\n";
}

Measured memory_bytes: 4316
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
const ll INF=1LL<<60;
const double EPS = 1e-10;
const ll mod=1000000007;
//const ll mod=998244353;

int main(void){
    string s;
    cin>>s;
    int ans=0;
    for(int i=0;i<6;i++){
        if(s[i]=='1') ans++;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3652
#include <cstdio>
#include <cmath>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <algorithm>
#include <iomanip>

#ifdef _DEBUG
#define DMP(x) cerr << #x << ": " << x << "\n"
#else
#define DMP(x) ((void)0)
#endif

const int MOD = 1000000007, INF = 1111111111; 
using namespace std;
using lint = long long;

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	int N;
	cin >> N;

	cout << "AB" << char('C' + N / 1000)<< "\n";
	//cout << "AB" << char('C' + N / 1000) << setw(3) << setfill('0') << N % 1000 + N / 1000 << "\n";

	return 0;
}

Measured memory_bytes: 256
main(){
 long int k,i,n;
  scanf("%ld",&n);
  long long int a[n],b[n],l=0,s=0,m=1000000000+7;
  for(i=0;i<n;i++){scanf("%lld",&a[i]);l=(l+a[i])%m;b[i]=l;}
 for(k=0;k<n;k++){s+=a[k]*(b[n-1]-b[k]+m);s=s%m;}
  printf("%lld",s);
}


Measured memory_bytes: 4840
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>   
#include<limits.h>
#include<float.h>
#include<list>
#include <array>
#include <complex>
#include<stdio.h>
#include<string.h>

using namespace std;
#define int  long long
 
#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807int
#define I64_MAX2 1223372036854775807int
#define INF I64_MAX2
#define MOD 1000000007
#define MEM_SIZE 10000
#define DEBUG_OUT true
#define ALL(x) (x).begin(),(x).end()
// int DP[MEM_SIZE][MEM_SIZE] = {0};
// int GMEM[MEM_SIZE][MEM_SIZE] = {0};
template<typename T> void DEBUG(T e){if(DEBUG_OUT == false)return;std::cout << e << std::endl;}
template<typename T> void DEBUG(const std::vector<T>& v){if(DEBUG_OUT == false)return;for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){if(DEBUG_OUT == false)return;for(const auto& v : vv){ DEBUG(v); } }
template<class T,class X> void DEBUG(X d, T e){if(DEBUG_OUT == false)return;std::cout <<d<<" ";DEBUG(e);};
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }


//FUNCTION  
 
//solve

void solve(void)
{
  int N, K;
  cin >> N >> K;
  int X = N / K;
  int ANS = pow(X, 3);
  if (K%2 == 0)
  {

    X = N / K;
    if(N%K >= K/2)
    {
      X++;
    }

    ANS += pow(X,3);
  }
  cout << ANS;

  return;
}

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

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

  return 0;
}


Measured memory_bytes: 384
#include <float.h>
#include <inttypes.h>
#include <limits.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <unistd.h>
#include <math.h>
#ifdef __cplusplus
#include <bits/stdc++.h>
#endif

int comp(const void *a, const void *b){return (*(int*)a>*(int*)b)-(*(int*)a<*(int*)b);}
int compr(const void *a, const void *b){return (*(int*)a<*(int*)b)-(*(int*)a>*(int*)b);}

#define putchar(c) putc_unlocked((c), stdout);
uint32_t nextpint(void){ char c=getc_unlocked(stdin); while(c<'0'||'9'<c) c=getc_unlocked(stdin); uint32_t x=0; while('0'<=c && c<='9'){ x=x*10+c-'0'; c=getc_unlocked(stdin); } return x; }
uint64_t nextplong(void){ char c=getc_unlocked(stdin); while(c<'0'||'9'<c) c=getc_unlocked(stdin); uint64_t x=0; while('0'<=c && c<='9'){ x=x*10+c-'0'; c=getc_unlocked(stdin); } return x; }
uint32_t nextstr(char *s){ char c=getc_unlocked(stdin); while(c==' '||c=='\n') c=getc_unlocked(stdin); uint32_t len=0; while(c!=' '&&c!='\n'){ *s++=c; len++; c=getc_unlocked(stdin); } *s='\0'; return len; }
uint32_t nextstrln(char *s){ char c=getc_unlocked(stdin); while(c==' '||c=='\n') c=getc_unlocked(stdin); uint32_t len=0; while(c!='\n'){ *s++=c; len++; c=getc_unlocked(stdin); } *s='\0'; return len; }

void printint(int x){ if(x<0){x=-x; putc_unlocked('-', stdout);}else if(x==0){putc_unlocked('0', stdout);} int d=0; char s[10]; while(x){ s[d]='0'+x%10; x/=10; d++; } for (int i=d-1; i>=0; i--) putc_unlocked(s[i], stdout); putc_unlocked('\n', stdout); }
void printlong(long x){ if(x<0){x=-x; putc_unlocked('-', stdout);}else if(x==0){putc_unlocked('0', stdout);} int d=0; char s[20]; while(x){ s[d]='0'+x%10; x/=10; d++; } for (int i=d-1; i>=0; i--) putc_unlocked(s[i], stdout); }

inline int max2(const int a, const int b){return a>b?a:b;}
inline int min2(const int a, const int b){return a>b?b:a;}
inline int dif2(const int a, const int b){return a>b?a-b:b-a;}
inline int abs2(const int a){return a>=0?a:-a;}

char s[200001];
int l[200001];
int r[200001];
int main(void){
	int n=nextpint();
	int k=nextpint();
	int c=nextpint();
	nextstr(s);
	int h=0, hp=-1;
	for(int i=0; i<n; i++){
		if(s[i]=='o'){
			if(i>hp){
				h++;
				l[h]=i;
				hp=i+c;
			}
		}
	}
	h=0, hp=n;
	for(int i=n-1; i>=0; i--){
		if(s[i]=='o'){
			if(i<hp){
				h++;
				r[h]=i;
				hp=i-c;
			}
		}
	}
	for(int i=max2(1,k-h+1); i<=min2(h,k); i++){
		if(l[i]==r[k-i+1]){
			printint(l[i]+1);
		}
	}
}


Measured memory_bytes: 3200
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <utility>
#include <iomanip>
using namespace std;
typedef long long ll;
typedef pair<ll,int> P;
const ll MOD = 1e9+7;
P pq[200001];
int main()
{
	int w,h;
	ll ans=0;
	cin>>w>>h;
	for(int i=0;i<w+h;i++)
	{
		ll tmp;
		cin>>tmp;
		if(i>=w)
			pq[i]=P(tmp,1);
		else
			pq[i]=P(tmp,0);
	}
	sort(pq,pq+w+h);
	ll tate=h+1;
	ll yoko=w+1;
	for(int i=0;i<w+h;i++)
	{
		if(pq[i].second)
		{
			ans+=yoko*pq[i].first;
			tate--;
		}else{
			ans+=tate*pq[i].first;
			yoko--;
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3328
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long ll;
typedef pair<int,int> P;
int main(){
    ll n;
    cin>>n;
    if(n%2) cout<<0;
    else{
        ll ans=0;
        for(int i=0;i<=log2(n/10)/log2(5);i++) ans+=n/(10*ll(pow(5,i)));
        cout<<ans;
    }
}

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

#define int long long
const double PI = 3.14159265358979323846;
typedef vector<int> vint;
typedef pair<int, int> pint;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

int N;
string W[110000];
signed main() {
    int A,B;
    cin >> A>>B;
    if(A%2==1&&B%2==1)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}


Measured memory_bytes: 1152
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#include <cstdio>

using namespace std;

int main(){

  int N, K;
  cin >> N >> K;

  int a[100001];
  int auau, iter;
  for (int i = 0; i < N; i++){
    auau = scanf("%d",&a[i]);
    if (a[i] == 1) iter = i;
  }

  int num;

  // if (iter < K || ((N - iter) < K)) {
  //   num = int(ceil(double(N - 1) / double(K - 1)));
  // }else{
  //   num = int(ceil(double(iter) / double(K - 1)) + ceil(double(N - iter - 1) / double(K - 1)));
  // }

  num = min(int(ceil(double(N - 1) / double(K - 1))), int(ceil(double(iter) / double(K - 1)) + ceil(double(N - iter - 1) / double(K - 1))));


  cout << num << endl;



  return 0;

}


Measured memory_bytes: 640
#include <iostream>
#include <atcoder/math>

using namespace std;

int main(){
    int T; cin >> T;
    for(int i=0;i<T;i++){
        int n, m, a, b; cin >> n >> m >> a >> b;
        cout << atcoder::floor_sum(n, m, a, b) << endl;
    }
}

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

const int N = 1e5 + 5;

vector<pair<int, int>> adj[N];
int n, m;
int dist[N];
bool vis[N];

bool dfs(int now) {
    vis[now] = true;

    bool ok = true;
    for(pair<int, int> nxt : adj[now]) {
        if(vis[nxt.first]) {
            if(dist[now] + nxt.second != dist[nxt.first]) {
                return false;
            }
        } else {
            dist[nxt.first] = dist[now] + nxt.second;
            ok &= dfs(nxt.first);
        }
    }

    return ok;
}

void read() {
    scanf("%d %d", &n, &m);
    for(int i = 0 ; i < m ; i++) {
        int l, r, d;
        scanf("%d %d %d", &l, &r, &d);

        adj[l].push_back({r, d});
        adj[r].push_back({l, -d});
    }
}

bool work() {
    for(int i = 1 ; i <= n ; i++) {
        if(!vis[i]) {
            if(!dfs(i)) {
                return false;
            }
        }
    }
    return true;
}

int main() {
    read();
    printf("%s\n", work() ? "Yes" : "No");
    return 0;
}

Measured memory_bytes: 12032
#include <bits/stdc++.h>
using namespace std;
#define ll long long 
#define endl "\n"
#define pb push_back
#define f(i,n) for(i=0;i<n;i++)
#define F(i,a,b) for(i=a;a<=b;i++)
#define arr(a,n) for( i=0;i<n;i++)cin>>a[i];
#define fi first
#define se second
#define mp make_pair
#define mod 1000000007
#define YES cout<<"YES"<<endl;
#define Yes cout<<"Yes"<<endl;
#define NO cout<<"NO"<<endl;
#define No cout<<"No"<<endl;
#define yes cout<<"yes"<<endl;
#define no cout<<"no"<<endl;
#define vi vector<ll>
#define ed end()
#define bg begin()
#define sz size()
#define ln length()
#define s() sort(a,a+n);
#define sr() sort(a,a+n,greater<ll>());
#define v()  sort(v.begin(),v.end());
#define vr() sort(v.begin(),v.end(),greater<ll>());
#define mod 1000000007
#define fast() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
ll gcd(ll a, ll b){if(!b)return a;return gcd(b, a % b);}
ll power(ll x,ll y,ll p){ll res=1;x%=p;while(y>0){if(y&1)res=(res*x)%p;y=y>>1;x=(x*x)%p;}return res;}
int main() {
    /*#ifndef ONLINE_JUDGE
        // for getting input from input.txt
        freopen("input.txt", "r", stdin);
        // for writing output to output.txt
        freopen("output.txt", "w", stdout);
    #endif*/
        

fast();
//ll t;cin>>t;while(t--)
{
    ll n,s=0,k;
    cin>>n>>k;
    ll a[n];
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
    }
    sort(a,a+n);
    for(int i=0;i<k;i++)
    {
        s+=a[i];
    }
cout<<s<<endl;
}
return 0;
}

Measured memory_bytes: 3648
#include<bits/stdc++.h>
using ll  = long long;
#define int ll
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define erep(e,v) for(auto && e :v)
#define all(in) in.begin(), in.end()
#define MP make_pair
#define INF (sizeof(int) == 4 ? (int)1e9:(int)1e18)
#define EPS 0.0000000001
using namespace std;
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
template<typename Head, typename Value> auto vectors(const Head &head, const Value &v) { return vector<Value>(head, v); }
template<typename Head, typename... Tail> auto vectors(Head x, Tail... tail) { auto inner = vectors(tail...); return vector<decltype(inner)>(x, inner); }
template<class T> void join(T a){for(auto itr :a){if(itr != *a.begin())cout << " "; cout << itr;} }
using ld  = long double;
using pii = pair<int,int>;
using piii = pair<int,pii>;
int W,H;
int dx[]={0,0,1,-1}, dy[]={1,-1,0,0};
bool valid(int x,int y){return (0<=x&&x<W)&&(0<=y&&y<H);}
signed main(){
    int a,b,c; cin >> a >> b >> c;
    cout << a + b + c << endl;
}





Measured memory_bytes: 3064
s = input()

c1, c2 = False, False

if s[0] == 'A':
    c1 = True

if s[2:-1].count('C') == 1:
    c2 = True

s_lower = s[1:].replace('C', 'c')
c3 = s_lower.islower()

if c1 and c2 and c3:
    print('AC')
else:
    print('WA')

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define pb push_back
#define all(con) (con).begin(),(con).end()
#define zoro ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
const int N=1e5+5;
const int mod=1e9+7;
void solve();
signed main(){
    zoro;
    int tests=1;
    // cin>>tests;
    while(tests--){
        solve();
    }
return 0;
}
void solve(){
    int n;
    cin>>n;
    int ans=0;
    for(int i=1;i<=n;i++){
        if( i%3==0 || i%5==0 ){
            // ans+=i;
        }
        else{
            ans+=i;
        }
    }
    cout<<ans<<endl;
}



Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace std;
long long int mod=1000000007;
int main()
{
	#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	#endif
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	long long int k;
	cin>>k;
	if(k%2==0)
	{
		cout<<"-1"<<endl;
		return 0;
	}
	unordered_map<int,int> a;
	long long int p=7%k;
	int ans=1;
	a[p]=1;
	while(p)
	{
		ans++;
		p=(10*p+7)%k;
		if(a[p]==1)
			break;
		a[p]=1;
	}
	if(p==0)
		cout<<ans<<endl;
	else
		cout<<"-1"<<endl;
	return 0;
}

Measured memory_bytes: 42540
#include <iostream>
#include <algorithm>
using namespace std;
 
int main() {
  int n, m;
   
  cin >> n >> m;
  int A[1000], B[1000];
  for(int i=0; i<n; i++) {
    cin >> A[i];
  }
   
  int cnt[1000]={};
   
  for(int i=0; i<m; i++) {
    cin >> B[i];
  }
   
  for(int j=0; j<m; j++) {
      for(int i=0; i<n; i++) {
    if(B[j] >= A[i]) {
      cnt[i] ++;
      break;
    }
      }
  }
 
   
   
  int mx = 0, num = 0;
  for(int i=0; i<n; i++) {
    if(mx < cnt[i]) {
      num = i;
      mx = cnt[i];
    }
  }
   
  cout << num + 1 << endl;
   
  return 0;
}

Measured memory_bytes: 1172
from fractions import gcd
n,m=map(int,input().split())
s=input()
t=input()
g=gcd(n,m)
a=n//g
b=m//g
for i in range(g):
  if s[a*i]!=t[b*i]:
    print(-1)
    break
else:
  print(n*m//g)

Measured memory_bytes: 65260
#include <stdio.h>
#define M 100
int main()
{
    int N, d[M], i, j, sum = 0;
    scanf("%d", &N);
    for (i = 0; i < N; i++)
    {
        scanf("%d", &d[i]);
    }
    for (i = 0; i < N-1; i++)
    {
        for (j = i+1; j < N; j++)
        {
            sum += d[i] * d[j];
        }
    }
    printf("%d", sum);
    return 0;
}


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

int main() {
  int n;cin>>n;
  string t="MARCH";
  vector<int> vec(5);
  rep(i,n){
    string s;cin>>s;
    rep(j,5){
      if(s[0]==t[j])vec[j]++;
    }
  }
  ll ans=0;
  rep(i,3)for(int j=i+1;j<4;j++)for(int k=j+1;k<5;k++){
    ans+=(ll)vec[i]*vec[j]*vec[k];
  }
  cout<<ans<<endl;
}

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

#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)

template<class T> bool umin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool umax(T &a, T b) { return a < b ? (a = b, true) : false; }

using namespace std;

int main(int argc, char** argv) 
{
#ifdef HOME
	if(IsDebuggerPresent())
	{
		freopen("../in.txt", "rb", stdin);
		freopen("../out.txt", "wb", stdout);
	}
#endif
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.precision(10);
	cout << fixed;
	int H, W, K;
	cin >> H >> W >> K;
	vector<vector<bool>> w(H, vector<bool>(W));
	forn(h, H)
	{
		string s;
		cin >> s;
		forn(x, W)
		{
			if (s[x] == '#')
				w[h][x] = true;
		}
	}
	uint32_t res = 0;
	forn(i, 1 << H)
	{
		forn(j, 1 << W)
		{
			int ctr = 0;
			forn(ii, H)
			{
				forn(jj, W)
				{
					if (w[ii][jj] && ((1 << ii) & i) == 0 && ((1 << jj) &j) == 0)
					{
						++ctr;
					}
				}
			}

			if (ctr == K)
				++res;
		}
	}
	cout << res << endl;
	return 0;
}


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

using namespace std;

int main ()
{

  int a;
  int b;
  int pro;

  cin >> a;
  cin >> b;

  pro = a*b;

  if( pro%2 == 1 )
  {
    cout << "Odd" << endl;
  }
  else
  {
    cout << "Even" << endl;
  }


  return 0;

}








Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define space putchar(' ')
#define enter putchar('\n')
#define eps 1e-10
#define MAXN 1005
//#define ivorysi
using namespace std;
typedef long long int64;
typedef unsigned int u32;
typedef double db;
template<class T>
void read(T &res) {
    res = 0;T f = 1;char c = getchar();
    while(c < '0' || c > '9') {
    	if(c == '-') f = -1;
    	c = getchar();
    }
    while(c >= '0' && c <= '9') {
    	res = res * 10 +c - '0';
    	c = getchar();
    }
    res *= f;
}
template<class T>
void out(T x) {
    if(x < 0) {x = -x;putchar('-');}
    if(x >= 10) {
	out(x / 10);
    }
    putchar('0' + x % 10);
}
int R,G,B,N;
void Solve() {
    read(R);read(G);read(B);read(N);
    int cnt = 0;
    for(int i = 0 ; i <= N / R ; ++i) {
        int t = N - i * R;
        for(int j = 0 ; j <= t / G ; ++j) {
            int h = N - i * R - j * G;
            if(h % B == 0) ++cnt;
        }
    }
    out(cnt);enter;
}
int main() {
#ifdef ivorysi
    freopen("f1.in","r",stdin);
#endif
    Solve();
    return 0;
}


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

#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < n; i++)
typedef long long ll;

int main() {
   int n; cin >> n;
   vector<vector<int> > a(n + 1);
   for(int i = 1; i < n; i++){
       int t; cin >> t;
       a[t].push_back(i);
   }
   for(int i = 1; i <= n; i++){
       cout << a[i].size() << endl;
   }
}


Measured memory_bytes: 13996
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
using namespace std;
int main(){
  int n;
  while(cin >> n &&n){
	vector<vector<int> > field(n,vector<int>(n));
	for(int i = 0;i < n;i++){
	  for(int j = 0;j < n;j++){
		cin >> field[i][j];
	  }
	}
	
	vector<int> min_row(n,1<<28);
	vector<int> max_col(n,0);
	for(int i = 0;i < n;i++){
	  for(int j = 0;j < n;j++){
		min_row[i] = min(min_row[i],field[i][j]);
		max_col[j] = max(max_col[j],field[i][j]);
	  }
	}
	
	int ans = 0;
	for(int i = 0;i < n;i++){
	  for(int j =0;j < n;j++){
		if(min_row[i] == max_col[j])ans = min_row[i];
	  }
	}
	cout << ans << endl;	
  }
  return 0;
}

Measured memory_bytes: 1216
#include <iostream>
#include <algorithm>
#include <utility>
using namespace std;
typedef long long ll;
ll A[100005];
pair<ll,int> B[100005];
int main() {
  ios::sync_with_stdio(false);
  int N, M;
  cin >> N >> M;
  for (int i=0; i<N; i++) {
    cin >> A[i];
  }
  for (int i=0; i<M; i++) {
    cin >> B[i].second >> B[i].first;
  }
  sort(A, A+N, greater<ll>());
  sort(B, B+M, greater<pair<ll,int>>());
  int a = 0;
  int b = 0;
  ll ret = 0;
  int num = 0;
  for (int i=0; i<N; i++) {
    if (b == M || A[a] >= B[b].first) {
      ret += A[a++];
    } else {
      ret += B[b].first;
      B[b].second--;
      if (B[b].second == 0) b++;
    }
  }
  cout << ret << endl;
}

Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
int main()
{

string s,ss;
int a,b,i,j,l;
vector<string>v;
cin>>a>>b;
for(i=1;i<=a;i++)
{
cin>>s;v.push_back(s);
}
for(i=0;i<=b+1;i++)cout<<"#";
cout<<endl;
for(i=0;i<a;i++)cout<<"#"<<v[i]<<"#\n";
for(i=0;i<=b+1;i++)cout<<"#";
cout<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>

#define REP(i,n) for(int i=0;i<n;i++)
#define llong long long

using namespace std;

int main(){

  int n;
  vector<int> a;

  REP(i,3){
    cin>>n;
    a.push_back(n);
  }

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

  cout<<a[0]+a[1]<<endl;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;  
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
#define ll long long int 
#define fi first
#define se second
#define pb push_back
#define pob pop_back
#define mp make_pair
#define pll pair<ll,ll>
#define vll vector<ll>
#define mll map<ll,ll>
#define mod 1000000007
#define IOS std::ios::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL);
#define endl "\n"
#define pqmin priority_queue<ll,vector<ll>,greater<ll>>
#define pqmax priority_queue<ll>
using namespace std;
ll power(ll a,ll n){
	if(n==0)
	  return 1;
	if((n%2)==0)
	  return (power((a*a),n/2));
	else
	  return (a*(power((a*a),n/2)));    
}
int main()
 {
     IOS;
     ll n;
     cin>>n;
     for(int i=0;i<n;i++)
     {
     	cout<<"ACL";
	 }
	return 0;
}




Measured memory_bytes: 3540
N, C = gets.strip.split(/ /).collect{|n| n.to_i}

xv_list = []
N.times{
	xv_list << gets.strip.split(/ /).collect{|n| n.to_i}
}

max = 0

cw_cals = []
sum = 0
pos = 0
cw_max = 0
xv_list.each{|x, v|
	cal = sum + v - (x - pos)
	if cal > cw_max
		cw_max = cal
	end
	cw_cals << [cal, cw_max]
	sum = cal
	pos = x
	if max < cal
		max = cal
	end
}

acw_cals = []
sum = 0
pos = C
acw_max = 0
xv_list.reverse.each{|x, v|
	cal = sum + v - (pos - x)
	if cal > acw_max
		acw_max = cal
	end
	acw_cals << [cal, acw_max]
	sum = cal
	pos = x
	if max < cal
		max = cal
	end
}
acw_cals.reverse!

(N - 1).times{|i|
	cw_cal = cw_cals[i][0]
	x, v = xv_list[i]
	cal = cw_cal - x + acw_cals[i + 1][1]
	if max < cal
		max = cal
	end
	
	j = N - i - 1
	acw_cal = acw_cals[j][0]
	x, v = xv_list[j]
	cal = acw_cal - (C - x) + cw_cals[j - 1][1]
	if max < cal
		max = cal
	end
}

#p cw_cals
#p acw_cals
p max




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

int main() {
  int H, W;
  int count;
  cin >> H >> W;
  vector<vector<char>> vec_in (H, vector<char>(W));//入力配列
  vector<vector<char>> vec_su (H+2, vector<char>(W+2,'.')); //一回り大きい配列．
  vector<vector<char>> vec_an (H, vector<char>(W,'#')); //出力配列

  //入力値．OK
  for (int i=0; i<H; i++) {
    for (int j=0; j<W; j++) {
      cin >> vec_in.at(i).at(j);
    }
  }

  //入力値をH+2, W+2の配列に埋め込み．OK
  for (int i=0; i<H; i++) {
    for (int j=0; j<W; j++) {
      vec_su.at(i+1).at(j+1)=vec_in.at(i).at(j);
    }
  }

  // 判定開始：原因
  for (int i=1; i<H+1; i++) {
    for (int j=1; j<W+1; j++){
      if (vec_su.at(i).at(j)=='#') {
        continue;
      }
      else if (vec_su.at(i).at(j)=='.') {
        count=0;
        for (int m=0; m<3; m++) {
          for (int n=0; n<3; n++) {
            if (m==1 && n==1) {
              continue;
            }
            else {
              if (vec_su.at(i+m-1).at(j+n-1)=='.') {
                continue;
              }
              else if (vec_su.at(i+m-1).at(j+n-1)=='#') {
                count++;
              }
            }
          }
        }
        vec_an.at(i-1).at(j-1)=char (count+'0');
      }
    }
  }


  //出力
  for (int i=0; i<H; i++) {
    for (int j=0; j<W; j++) {
      cout << vec_an.at(i).at(j);
    }
    cout << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <utility>
#include <stack>
#include <vector>
#include <queue>
#include <algorithm>
#include <map>
#include <climits>
#include <set>
#include <numeric>
#include <iomanip>
#include <cmath>
#include <cstring>
using namespace std;
long long x[50];
long long y[50];
int main(){
  int N;
  cin >> N;

  for(int i = 0; i < N; i++){
    cin >> x[i] >> y[i];
  }

  set <pair<long long, long long> > diffs;
  for(int i = 0; i < N; i++){
    for(int j = 0; j < N; j++){
      if(i != j){
        diffs.insert(make_pair(x[i] - x[j], y[i] - y[j]));
      }
    }
  }

  int ans = N;
  for(auto it = diffs.begin(); it != diffs.end(); it++){
    int edge_no = 0;
    for(int i = 0; i < N; i++){
      for(int j = 0; j < N; j++){
        if(i != j){
          if(make_pair(x[i] - x[j], y[i] - y[j]) == *it){
            edge_no ++;
          }
        }
      }
    }
    ans = min(ans, N - edge_no);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 384
import qualified Data.ByteString.Char8 as B
import Control.Monad
import Data.Maybe

main = do
    n <- read <$> getLine :: IO Int
    plans <- replicateM n $ do
        [t, x, y] <- map (fst . fromJust . B.readInt) . B.words <$> B.getLine
        return (t, x, y)
    putStrLn $ if plan (0,0,0) plans then "Yes" else "No"

plan (curT, curX, curY) [] = True
plan (curT, curX, curY) ((t,x,y):plans) = 
    let a = abs (t-curT)
        b = abs (x-curX) + abs (y-curY)
    in if a >= b && ((a - b) `mod` 2) == 0
        then plan (t,x,y) plans
        else False
    

Measured memory_bytes: 39932
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<cmath>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<numeric>
#include<functional>
#include<algorithm>
#include<bitset>
#include<tuple>
#include<unordered_set>
#include<unordered_map>
#include<random>
#include<array>
#include<cassert>
using namespace std;
#define INF (1<<29)
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define uniq(v) v.erase(unique(all(v)),v.end())





int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);

	long long h, w;
	cin >> h >> w;

	if (h == 1 || w == 1)cout << 1 << endl;
	else cout << (h * w + 1) / 2 << endl;

	return 0;
}

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

struct Edge { int to; ll cost; };
vector<Edge> G[2510];
ll INF = 1e18;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);

  int V, E; cin >> V >> E;
  ll P; cin >> P;
  vector<ll> d(V, INF);

  for (int i = 0; i < E; i++) {
    int a, b; cin >> a >> b; a--; b--;
    ll c; cin >> c;
    G[a].emplace_back(Edge({b, -(c - P)}));
  }

  d[0] = 0;
  for (int t = 0; t < V * 2; t++) {
    for (int i = 0; i < V; i++) {
      if (d[i] == INF) continue;
      if (t >= V && d[i] > -INF / 2) continue;
      for (auto e: G[i]) {
        if (d[e.to] > d[i] + e.cost) {
          d[e.to] = d[i] + e.cost;
          if (t == V - 1) {
            d[e.to] = -INF;
          }
        }
      }
    }
  }

  if (d[V - 1] < -INF / 2) cout << "-1\n";
  else cout << max(-d[V - 1], 0ll) << '\n';

  return 0;
}

Measured memory_bytes: 512
#include<stdio.h>
#define MAX 100000
#define SENTINEL 2000000000

struct Card {
    char suit;
    int value;
};

struct Card L[MAX / 2 + 2], R[MAX / 2 + 2];

void merge(struct Card A[], int n, int left, int mid, int right) {
    int i, j, k;
    int n1 = mid -left;
    int n2 = right - mid;
    for (i = 0; i < n1; i++) L[i] = A[left + i];
    for (i = 0; i < n2; i++) R[i] = A[mid + i];
    L[n1].value = R[n2].value = SENTINEL;
    i = j = 0;
    for ( k = left; k < right; k++) {
        if (L[i].value <= R[j].value) {
            A[k] = L[i++];
        } else {
            A[k] = R[j++];
        }
    }
}

void mergeSort(struct Card A[], int n, int left, int right) {
    int mid;
    if (left + 1 < right) {
        mid = (left + right) / 2;
        mergeSort(A, n, left, mid);
        mergeSort(A, n, mid, right);
        merge(A, n, left, mid, right);
    }
}

int partition(struct Card A[], int n, int p, int r) {
    int i, j;
    struct Card t, x;
    x = A[r];
    i = p- 1;
    for (j = p; j < r; j++) {
        if (A[j].value <= x.value) {
            i++;
            t = A[i]; A[i] = A[j]; A[j] = t;
        }
    }
    t = A[i + 1]; A[i + 1] = A[r]; A[r] = t;
    return i + 1;
}

void quickSort(struct Card A[], int n, int p, int r) {
    int q;
    if ( p < r) {
        q = partition(A, n, p, r);
        quickSort(A, n, p, q -1);
        quickSort(A, n, q + 1, r);
    }
}

int main() {
    int n, i, v;
    struct Card A[MAX], B[MAX];
    char S[10];
    int stable = 1;
    
    scanf("%d", &n);
    
    for (i = 0; i < n; i++) {
        scanf("%s %d", S, &v);
        A[i].suit = B[i].suit = S[0];
        A[i].value = B[i].value = v;
    }
    
    mergeSort(A, n, 0, n);
    quickSort(B, n, 0, n-1);

    for (i = 0; i < n; i++) {
        if (A[i].suit != B[i].suit ) stable = 0;
    }
    
    if (stable == 1) printf("Stable\n");
    else printf("Not stable\n");
    for (i = 0; i < n; i++) {
        printf("%c %d\n", B[i].suit, B[i].value);
    }
    
    return 0;
}


Measured memory_bytes: 4044
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	Scanner sc = new Scanner(System.in);
	
	public static void main(String[] args) {
		Main m = new Main();
		m.run();
	}
	
	void run() {
		int n = sc.nextInt();
		String[] s = new String[n];
		
		for(int i =0 ;i < n ;i ++) {
			s[i] = sc.next() +"_"+ (1100-sc.nextInt())+"_"+(i+1);
		}
		
		Arrays.sort(s);
		
		for(int i =0;i < n ; i++) {
			String[] e = s[i].split("_");
			System.out.println(e[2]);
		}
		
		
	}
}


Measured memory_bytes: 23764
use std::io::*;
use std::cmp;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {

    let n: usize = read();
    let mut vec: Vec<i32> = Vec::with_capacity(n);

    for _i in 0..n {
        vec.push(read())
    }

    let mut ans: i32 = 0;

    for i in 0..n {
        for j in i..n {
            ans = cmp::max(ans, (vec[i] - vec[j]).abs());
        }
    }
    println!("{}", ans);
}



Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using p = pair<int, int>;
#define INF 1000000000
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repX(i, n ,x) for (int i = x; i < (int)(n); i++)
#define repBack(i, n) for (int i = n; i > 0; i--)

int main() {
    int N;
    cin >> N;
    vector<int> d(N);
    rep(i,N)cin >> d[i];
    int sum = 0;
    rep(i,N){
        repX(j,N,i+1){
            sum += d[i] * d[j];
        }
    }
    cout << sum << endl;

    return 0;
}

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

int main() {
  double N;cin>>N;
  vector<double> data(N);
  rep(i,N) cin>>data[i];
  double sum =0;
  rep(i,N) sum+=1.0/data[i];
  cout << fixed << setprecision(6);
  cout << 1.0/sum << endl;
}

Measured memory_bytes: 256
def total_pairs(N):
    hashmap = {}
    answer = 0
    for current in range(1, N+1):
        s = str(current)
        first, second = s[0], s[-1]
        total = first+second
        if not hashmap.get(total):
            hashmap[total] = 1
        else:
            c = hashmap[total]
            hashmap[total] = c + 1
            
    #print(hashmap)
    for k, v in hashmap.items():
        #print(k, v)
        f_s, s_s = k[0], k[1]
        if f_s == s_s:
            answer += v*v 
        else:
            temp = s_s+f_s
            if hashmap.get(temp):
                value = hashmap[temp]
                answer +=(v*value)
        #print("--->", answer)
    return answer

N = int(input())
print(total_pairs(N))

Measured memory_bytes: 3064
using System;
using System.Linq;

public class Program
{
    static void Main()
    {
        long x = long.Parse(Console.ReadLine());
        long m = 100;
        long count = 0;
        while (m < x)
        {
            m += (long)(m * 0.01);
            count++;
        }
        Console.WriteLine(count);
    }
}

Measured memory_bytes: 27480
import java.util.Scanner;


public class Main {


//	final int MOD = 1000000007;

//	public static int min = 3000000;

	public static void main(String[] args) {

		int ans = 0;
		Scanner sc = new Scanner(System.in);
		boolean f = false;

//		long k = sc.nextLong();
//		int n = sc.nextInt();

		String string = sc.next();
		String[] s = string.split("");

		//-------------------------------------------------------------------------------------

		for(int i =0; i < 3; i++) {
			System.out.print(s[i]);
		}
		System.out.println();
		//-------------------------------------------------------------------------------------

//		if(f) {
//			System.out.println("Yes");
//		} else {
//			System.out.println("No");
//		}

//		System.out.println(ans);

		sc.close();
	}



}

Measured memory_bytes: 35744
H, W = map(int, input().split())
S = [input() for _ in range(H)]


def bfs():
    q = [(0, 0, 1)]
    m = [[0 for _ in range(W)] for _ in range(H)]
    while len(q) > 0:
        x, y, c = q.pop(0)
        for xx, yy in [(x + 1, y), (x, y + 1), (x - 1, y), (x, y - 1)]:
            if (H, W) == (yy + 1, xx + 1):
                return c + 1
            if 0 <= yy < H and 0 <= xx < W and S[yy][xx] == '.' and \
                    m[yy][xx] == 0:
                q.append((xx, yy, c + 1))
                m[yy][xx] = 1
    return -1


def main():
    dc = 0
    for i in range(H):
        dc += S[i].count('.')
    c = bfs()
    if c == -1:
        print(-1)
    else:
        print(dc - c)


main()


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 10;
typedef long long ll;
ll a[maxn];
int n;
ll solve(int flag)
{
	ll delta = 0, ans = 0;
	for(int i = 1; i <= n; ++i)
	{
		if(flag * (a[i] + delta) <= 0)
		{
			if(flag > 0)
			{
				ans += 1 - a[i] - delta;
				delta = 1 - a[i];
			}
			else
			{
				ans += a[i] + delta + 1;
				delta = -a[i] - 1;
			}
		}
		flag *= -1;
	}
	return ans;
}
int main()
{
	scanf("%d", &n);
	for(int i = 1; i <= n; ++i) 
	{
		scanf("%lld", &a[i]);
		a[i] += a[i - 1];
	}
	cout << min(solve(1), solve(-1)) << endl;
	return 0;
}
	

Measured memory_bytes: 4436
n = int(input())

def trans(t): 
    alph = 'abcdefghijklmnopqrstuvwxyz'
    return alph[t]

ans = ''
i=n
while i > 0:
    s = (i-1) % 26
    i = (i-1) //26
    ans = trans(s) + ans

print(ans)

Measured memory_bytes: 9176