akhauriyash/Code-Regression huggingface dataset:
<?php

fscanf(STDIN,"%d %d",$a,$b);

$alice = [ 'alice' => $a ];
$bob = ['bob' => $b ];

if( $alice['alice'] === $bob['bob'] ){
    echo 'Draw';
}elseif ($bob['bob'] == 1) {
    echo 'Bob';
} elseif ($alice['alice'] == 1 ) {
    echo 'Alice';
}elseif ($alice['alice'] < $bob['bob']) {
    echo 'Bob';
}elseif ($alice['alice'] > $bob['bob']) {
    echo 'Alice';
}

Measured memory_bytes: 4604
#include <stdio.h>

int main(){
  int low, up, num;
  scanf("%d%d%d", &num, &low, &up);
  int i, dig, sum[num], ans=0;
  for (i = 1; i <= num; i++){
    sum[i] = 0; dig = i;
    while(dig){
      sum[i] += dig % 10;
      dig /= 10;
    }
    if(sum[i] >= low && sum[i] <= up) ans += i;
  }
  printf("%d",ans);
  return 0;
}

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

#define pb push_back
#define all(x) (x).begin(), (x).end()
#define for1(i, a, b) for (int i = (int)a; i < (int)(b); ++i)
#define rfor1(i, a, b) for (int i=(int)b-1;i>=(int)a;i--)
#define for2(i, a, b) for (int i = (int)a; i <= (int)(b); ++i)
#define for3(i, a, b) for (int i = (int)a; i < (int)(b); i=i+2)
#define for4(i, a, b) for (int i = (int)a; i <= (int)(b); i=i+2)
#define tc(t) int t; cin>>t; while(t--)
using namespace std;
typedef long long ll;
const int MOD = 1e9 + 7;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int a, b, c;
    cin >> a >> b >> c;
    if (a + b <= a + c && a + b <= b + c) {
        cout << a + b << "\n";
    } else if (a + b >= a + c && c + b >= a + c) {
        cout << a + c << "\n";
    } else {
        cout << b + c << "\n";
    }
}









Measured memory_bytes: 3640
#include <bits/stdc++.h>
 
using namespace std;
int main() {
    int N;
    cin >> N;
    int L[N];
    for(int i = 0; i < N; i++){
        cin >> L[i];
    }
    sort(L,L+N);
    int sum = 0;
    for(int i = 1; i < N - 1; i++){
        for(int j = 0; j<i; j++){
            for(int k = N-1; i< k; k--){
                int a = L[j];
                int b = L[i];
                int c = L[k];
                if(a < b + c && b < a + c && c < a + b){
                    sum ++;
                }
            }
        }
    }
    cout << sum << endl;
}

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

using ll = long long;

#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define pb push_back
#define mp make_pair
#define fill(x, y) memset(x, y, sizeof(x))
#define even(x) x % 2 == 0
#define odd(x) x % 2 != 0
#define all(x) x.begin(), x.end()
#define pcnt __builtin_popcount
#define buli(x) __builtin_popcountll(x)
#define F first
#define S second
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());

// these functions return the position of result of Binary Search.
#define LB(s, t, x) (int) (lower_bound(s, t, x) - s)
#define UB(s, t, x) (int) (upper_bound(s, t, x) - s)

ll qp(ll a, ll b, int mo) { ll ans = 1; do { if (b & 1) ans = 1ll * ans * a % mo; a = 1ll * a * a % mo; } while (b >>= 1); return ans; }
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
int dx8[] = { 1, -1, 0, 0, 1, 1, -1, -1 }, dy8[] = { 0, 0, -1, 1, -1, 1, -1, 1 };

template <typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }
template <typename T, typename... Ts>
auto make_v(size_t a, size_t b, Ts... ts) { return vector<decltype(make_v<T>(b, ts...))>(a, make_v<T>(b, 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); }
// auto dp = make_v<int>(4, h, w);
// fill_v(dp, 0);

const ll INF_LL = (1ll << 60);
const int INF_INT = (int)1e9;
const ll MOD_CONST = (ll)(1e9 + 7);

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

inline tuple<ll, ll> rotate45(tuple<ll, ll> point) { ll x = get<0>(point), y = get<1>(point); return tuple<ll, ll>(x + y, x - y); }
inline bool rangeCheck2D(int nx, int ny, int Width, int Height) { return nx >= 0 and nx < Width and ny >= 0 and ny < Height; }
void out_sequence(vector<ll> &out) { REP(i, (int)out.size()) { cout << out[i]; if (i == (int)out.size() - 1) cout << endl; else cout << " "; } }



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

    string A, B; cin >> A >> B;
	REP(i, A.size()) {
		string a = A.substr(i, A.size() - i);
		a += A.substr(0, i);
		if (B == a) {
			cout << "Yes" << endl;
			return 0;
		}	
	}
	
	
			cout << "No" << endl;

    
	return 0;
}



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

int main(){
	int a,b;
	cin>>a>>b;
	if(a>0)puts("Positive");
	else if(a<=0&&0<=b)puts("Zero");
	else if(b<0&&(b-a)%2==0)puts("Negative");
	else puts("Positive");
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second

const int mx=100010;
const ll mod=1e9+7;

int main(){
  int n,m; cin >> n >> m;
  priority_queue<int, vector<int>, greater<int>> a;
  rep(i,n){ int x; cin >> x; a.push(x);}
  
  vector<pair<int,int>> c;
  rep(i,m){
    int x,y; cin >> x >> y;
    c.emplace_back(y,x);
  }
  sort(c.rbegin(),c.rend());
  
  int cnt=0;
  while(a.top() < c[cnt].F && (int)c.size()>cnt){
    a.pop();
    a.push(c[cnt].F);
    c[cnt].S--;
    if(c[cnt].S==0){cnt++;}
  }
 
  ll ans=0;
  while(!a.empty()){ ans+=a.top(); a.pop();}
  cout << ans << endl;
  return 0;
}


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

using namespace std;
// ascending order
#define vsort(v) sort(v.begin(), v.end())
// descending order
#define vsort_r(v) sort(v.begin(), v.end(), greater<int>())
#define vunique(v) unique(v.begin(), v.end())
#define mp make_pair
#define ts(x) to_string(x)
#define rep(i, a, b) for(int i = (int)a; i < (int)b; i++)
#define repm(i, a, b) for(int i = (int)a; i > (int)b; i--)
#define bit(a) bitset<8>(a)
#define des_priority_queue priority_queue<int, vector<int>, greater<int> >
#define all(v) (v).begin(), (v).end()
typedef long long ll;
typedef pair<int, int> P;
const ll INF = 1e18;

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

	int N, H;
	cin >> N >> H;
	vector<int> a(N), b(N);
	rep(i, 0, N) cin >> a[i] >> b[i];

	vsort_r(a);
	vsort_r(b);

	int rsl = 0;
	rep(i, 0, N) {
		if(a[0] >= b[i]) break;
		if(H <= 0) break;
		H -= b[i];
		rsl++;
	}

	if(H > 0) {
		if(H % a[0] == 0) rsl += (H / a[0]);
		else rsl += (H / a[0] + 1);
	}

	cout << rsl << endl;

}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int n;
long long a[100005],minn=1000000001,ans;
bool zero,minu;

long long m(long long x,long long y){
	return x<y?x:y;
}

int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;++i){
		scanf("%lld",&a[i]);
		if(a[i]==0)
			zero=true;
		if(a[i]<0){
			minu=!minu;
			a[i]=-a[i];
		}
		minn=m(minn,a[i]);
		ans+=a[i];
	}
//	cout<<zero<<' '<<minu<<' '<<ans<<' '<<minn<<endl;
	if(!zero && minu)
		ans-=2*minn;
	printf("%lld\n",ans);
}

Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <bitset>
#include <map>
#include <tuple>
#include <unordered_map>
#include <list>
#include <numeric>
#include <utility>
#include <iterator>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <ctime>
#include <cassert>

#define INF 1000000000
#define LINF 9000000000000000000
#define mod 1000000007

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<long long>vll;
typedef pair<int,int> pi;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
int ddx[8]={-1,-1,0,1,1,1,0,-1};
int ddy[8]={0,1,1,1,0,-1,-1,-1};
bool debug=false;

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

int main(){
  int N, T, A;
  cin >> N >> T >> A;
  double H;

  int idx = 1;
  double mini = 10000000;
  rep(i, N){
    cin >> H;
    // cout << i << " " << abs(T - H * 0.006) << endl;
    double tmp = abs(A - (T - H * 0.006));
    if(tmp < mini){
      mini = tmp, idx = i + 1;
    }
  }
  cout << idx << endl;
  return 0;
}


Measured memory_bytes: 256
import sys
import numpy as np
import random
from decimal import Decimal
import itertools
import re
import bisect
from collections import deque, Counter
from functools import lru_cache

sys.setrecursionlimit(10**9)
INF = 10**13
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def I(): return int(sys.stdin.buffer.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
def SERIES(n): return np.fromstring(sys.stdin.buffer.read(), dtype=np.int32, sep=' ')
def GRID(h,w): return np.fromstring(sys.stdin.buffer.read(), dtype=np.int32, sep=' ').reshape(h,-1)[:,:w]
def GRIDfromString(h,w): return np.frombuffer(sys.stdin.buffer.read(), 'S1').reshape(h,-1)[:,:w]
MOD = 1000000007

def main():
	s_list = LS()
	print('A{}C'.format(s_list[1][0]))




if __name__ == '__main__':
    main()

Measured memory_bytes: 27168
import java.util.Scanner;

class Main{
        public static void main(String args[]){
                Scanner scan = new Scanner(System.in);
                int val1=scan.nextInt();
                int val2=scan.nextInt();
                int val3=scan.nextInt();
                int count=0;
                for(int i=val1;i<=val2;i++){
                        if(val3%i==0){
                                count++;
                        }
                }
                System.out.println(count);
        }
}

Measured memory_bytes: 26292
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

//#define int long long
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
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; }

using Weight = int;
using Flow = int;
struct Edge {
	int s, d; Weight w; Flow c;
	Edge() {};
	Edge(int s, int d, Weight w = 1) : s(s), d(d), w(w), c(w) {};
	bool operator<(const Edge &e)const { return w < e.w; }
};
using Edges = vector<Edge>;
using Graph = vector<Edges>;
using Array = vector<Weight>;
using Matrix = vector<Array>;

inline ostream &operator<<(ostream &os, const Edge &e) { return (os << '(' << e.s << ", " << e.d << ", " << e.w << ')'); }

void add_edge(Graph &g, int a, int b, Weight w = 1) {
	g[a].emplace_back(a, b, w);
	g[b].emplace_back(b, a, w);
}
void add_arc(Graph &g, int s, int d, Weight w = 1) { g[s].emplace_back(s, d, w); }

//??¨?????±???
//?????????: ???????????????????????????????????§?????¨????????°
vector<int> depth(const Graph &g, int root) {
	vector<int> ret(g.size(), INF);
	using State = tuple<int, int, int>;
	stack<State> st; st.emplace(root, -1, 0);
	while (st.size()) {
		int s, p, d; tie(s, p, d) = st.top(); st.pop();
		ret[s] = d;
		for (auto &e : g[s]) {
			if (e.d == p)continue;
			st.emplace(e.d, s, d + 1);
		}
	}
	return ret;
}

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(10);
	double p; cin >> p;
	int N; cin >> N;
	Graph g(N);
	rep(i, 0, N - 1) {
		int x, y, c; cin >> x >> y >> c;
		x--, y--;
		add_edge(g, x, y, c);
	}
	vector<int> d = depth(g, 0);
	double a = 0;
	auto dfs = [&](const Graph &g, int root) {
		int n = g.size();
		vector<bool> f(n);
		stack<int> st; st.emplace(root);
		while (st.size()) {
			int u = st.top(); st.pop();
			f[u] = true;
			for (auto &e : g[u]) {
				if (f[e.d])continue;
				a += e.w * pow(p, d[e.d]);
				st.emplace(e.d);
			}
		}
	};
	dfs(g, 0);
	dump(a);
	double ans = a;
	auto dfs2 = [&](const Graph &g, int root) {
		int n = g.size();
		vector<bool> f(n);
		stack<int> st; st.emplace(root);
		while (st.size()) {
			int u = st.top(); st.pop();
			f[u] = true;
			ans += a * pow(p, d[u]);
			for (auto &e : g[u]) {
				if (f[e.d])continue;
				st.emplace(e.d);
			}
		}
	};
	dfs2(g, 0);
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 10812
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
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> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
REP(i,v.size()){if(i)os<<endl;os<<v[i];}return os;}
 
int main() {
    // Write Your Code Below
    ll a, b, c;
    double sum, s;
    string ans;
    cin >> a >> b >> c;
    sum = a+b+c;
    s = sum/2;
    if(s==a || s==b || s==c){
        ans = "Yes";
    }else{
        ans = "No";
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>
#include <iostream>
#include <vector>
#include <assert.h>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <stdlib.h>
#include <math.h>
#include <string>
#include <time.h>
#include <string.h>
#include <queue>
#include <complex>
#include <iomanip>
#include <stack>
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
ll mod=1e9+7;
double eps=1e-7;
ll exp(ll x,ll y){if(y<0) return 0; ll ret=1;for(;y;y>>=1,x=(x*x)%mod){if(y&1)ret=(ret*x)%mod;}return ret;}
ull pexp(ull x,ull y){if(y<0) return 0; ull ret=1; for(;y;y>>=1,x=(x*x)){if(y&1)ret=(ret*x);}return ret;}
ll gcd(ll x,ll y){if(!x||!y) return x+y; return x%y==0?y:gcd(y,x%y);}
ll lcm(ll x,ll y){return x*(y/gcd(x,y));}
ll bsum(ll u,ll b){ll ret=0;if(u<b)return u;while(u){ret+=u%b;u/=b;}return ret;}
ll prival(ll u,ll p){ll cn=0;while(u%p==0){cn++;u=u/p;}return cn;}
ll minv(ll a,ll b){return 1<a?b-minv(b%a,a)*b/a:1;}
ll extm(ll a,ll b){ll ret=0;while(a!=0){if(a%2==1){ret+=b;ret%=mod;}a>>=1;b=(2*b)%mod;}return ret;}   
ll eaphi(ll x){ll t=x,ret=x,i;for(i=2;i*i<=x;i++){if(t%i==0){ret-=ret/i;while(t%i==0) t/=i;}}if(t!=1) ret-=ret/t;return ret;}
ll eadivc(ll x){ll ret=0;ll i;for(i=1;i*i<=x;i++){if(x%i==0 && i*i!=x) ret+=2;if(x%i==0 && i*i==x) ret+=1;}return ret;}
ll eadivs(ll x){ll ret=0;ll i;for(i=1;i*i<=x;i++){if(x%i==0 && i*i!=x) ret+=i+x/i;if(x%i==0 && i*i==x) ret+=i;}return ret;}
ll ndig(ll x, ll b){ll ret=0;while(x){x/=b; ret++;}return ret;}
ll rev(ll n, ll b){ll ret=0;while(n){ret=b*ret+n%b; n/=b;}return ret;}
ll sq(ll x){ll t=(ll)sqrt(x); for(ll i=t-2 ; i<=t+2 ; i++) if(i*i==x) return abs(i); return -1;}
ll extexp(ll x,ll y){if(y<0) return 0; ll ret=1;for(;y;y>>=1,x=extm(x,x)){if(y&1)ret=extm(ret,x);}return ret;}
bool isprime(ll x){if(x<=1) return false; for(ll i=2;i*i<=x;i++){if(x%i==0){return false;}}return true;}
ll n, ans;
ll vv[111111];
map<ll, int> TT;
map<ll, int>::iterator it;
vector<ll> pos;

int main(void)
{
	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	cin>>n; int i;
	for(i=1 ; i<=n ; i++) cin>>vv[i];
	for(i=1 ; i<=n ; i++) TT[vv[i]]++;
	for(it=TT.begin() ; it!=TT.end() ; it++)
	{
		if((it->second)>=2) pos.push_back((it->first));
		if((it->second)>=4) pos.push_back((it->first));
	}
	if(pos.size()<2) cout<<0;
	if(pos.size()<2) return 0;
	sort(pos.begin(),pos.end());
	cout<<pos[pos.size()-1]*pos[pos.size()-2]; 
	return 0;
}

Measured memory_bytes: 7296
#include <iostream>
#include <vector>
#include <cmath>
using ll = long long;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, s, n) for(int i = s; i < n; i++)
using namespace std;

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

int main(){
  ll a, b;
  cin >> a >> b;
  ll n = gcd(a, b);
  ll x = n;
  ll ans = 1;
  rep2(i, 2, sqrt(n)+2){
    if (x % i == 0) ans++;
    while(x % i == 0){
      x /= i;
    }
  }
  if (x != 1) ans++;
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 3648
#include <iostream>
#include <vector>
#include <string>
#define rep(i,n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
int main(){
    int n;
    ll cnt[5] = {};
    cin >> n;
    string t = "MARCH";
    rep(i,n){
        string s;
        cin >> s;
        rep(j,t.size()){
            if(t[j] == s[0]){
                cnt[j]++;
                break;
            }
        }
    }
    ll ans = 0;
    rep(i,5)rep(j,i)rep(k,j)ans += cnt[i]*cnt[j]*cnt[k];
    cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.*;
 
public class Main {
  public static void main (String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    long[][] x = new long[N][2];
    long a = 0;
    long b = 0;
    long c = 0;

    boolean hantei = true;

    for (int i = 0; i < N ; i++) {
      x[i][0] = sc.nextInt();
      x[i][1] = sc.nextInt();

      a = 0;
      b = 0;
      c = 0;

        if( i > 0 && (x[i][0] < x[i - 1][0] || x[i][1] < x[i - 1][1])){
          a = (x[i-1][0] % x[i][0] != 0) ? (x[i-1][0] / x[i][0]) + 1:(x[i-1][0] / x[i][0]);
          b = (x[i-1][1] % x[i][1] != 0) ? (x[i-1][1] / x[i][1]) + 1:(x[i-1][1] / x[i][1]);
          c = Math.max(a,b);


          x[i][0] = c * x[i][0];
          x[i][1] = c * x[i][1];

        }
    }
    System.out.println(x[N-1][0] + x[N-1][1]);
  }
}


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

int main() {
  int N, u, v;
  cin >> N >> u >> v;
  --u; --v;

  vector<vector<int>> G(N);
  for(auto i=1; i<N; ++i) {
    int A, B;
    cin >> A >> B;
    --A; --B;
    G[A].emplace_back(B);
    G[B].emplace_back(A);
  }

  vector<int> path;
  function<bool(int,int)> dfs = [&](auto cur, auto pre) {
    if(cur == v) return true;
    for(auto nex: G[cur]) if(nex != pre) if(dfs(nex, cur)) {
      path.emplace_back(nex);
      return true;
    }
    return false;
  };
  dfs(u, -1);
  path.emplace_back(u);
  reverse(begin(path), end(path));

  auto ans = path.size() / 2 - 1;
  u = path[ans];
  unordered_set<int> NG;
  for(auto i=ans+1; i<path.size(); ++i) NG.emplace(path[i]);

  function<int(int,int)> height = [&](auto cur, auto pre) {
    auto res = 0;
    for(auto nex: G[cur]) if(nex != pre) if(!NG.count(nex)) res = max(res, 1 + height(nex, cur));
    return res;
  };

  ans += height(u, -1);
  if(path.size() & 1) ++ans;
  cout << ans << endl;
}


Measured memory_bytes: 12788
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
int main() {
 ll a; double b;
    cin>>a>>b;
    ll k=b*100+0.5;
  //cout<<k<<endl;
    ll m=(a*k)/100;
    cout<<m<<endl;
 return 0;
}

Measured memory_bytes: 3708
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = (int)(a); i <= (int)(n); ++i)
#define rrep(i, a, n) for (int i = (int)(a); i >= (int)(n); --i)
#define debug(x) cerr << #x << " = " << x << "\n"
#define debugv(x) \
  rep(f, 0, (x.size() - 1)) cerr << x[f] << (f == (x.size() - 1) ? "\n" : " ")
#define all(x) x.begin(), x.end()
#define int long long
using namespace std;
typedef pair<int, int> pii;
typedef vector<int> vi;
const int MX = 1e5 + 5, INF = 5 << 28, MOD = 1e9 + 7;

int A, B, C, D;
void input() { cin >> A >> B >> C >> D; }
void solve() {
  cout << max(A * B, C * D) << endl;
  ;
  ;
}
signed main() {
  input();
  solve();
  return 0;
}

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

S = []
D = {'ab': 0, 'a': 0, 'b': 0}

res = 0
for _ in range(N):
    s = input()
    res += s.count('AB')
    if s[0] == 'B' and s[-1] == 'A':
        D['ab'] += 1
    elif s[0] == 'B':
        D['b'] += 1
    elif s[-1] == 'A':
        D['a'] += 1

if D['ab'] > 0:
    res += D['ab'] - 1
    res += int(D['a'] > 0) + int(D['b'] > 0)
    res += max(0, min(D['a'] - 1, D['b'] - 1))
else:
    res += min(D['a'], D['b'])

print(res)


Measured memory_bytes: 9160
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String word = sc.next();
        List<String> list = new ArrayList<>();
        while (true) {
            String s = sc.next();
            if (s.equals("END_OF_TEXT")) {
                break;
            }
            list.add(s.toLowerCase());
        }
        long sum = 0;
        for (String s : list) {
            if (s.equals(word)) {
                sum++;
            }
        }
        System.out.println(sum);
    }
}

Measured memory_bytes: 26168
#include <bits/stdc++.h>
#define REP(i,  n) for (int i  =  0; i < (int)(n); ++i)
#define REPR(i,  n) for (int i  =  n - 1; i >= 0; --i)
using namespace std;

int main() {
  int a; cin >> a;
  for (int i = 0; i <= 10000; i += 1000) {
    if (i >= a && i - a < 1000) {
      cout << i - a  << endl;
      return 0;
    }
  }
}


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

memo = [[0]*10 for _ in range(10)]

for i in range(1,N+1):
  s = str(i)
  memo[int(s[0])][int(s[-1])] += 1
  
rlt = 0
for i in range(1,10):
  for j in range(1,10):
    rlt += memo[i][j]*memo[j][i]
    
print(rlt)

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

using namespace std;

int main()
{
    string s;
    cin >> s;
    int n = atoi(s.c_str());
    int res = 0;
    for(char c : s)
    {
        res += (c-'0');
    }
    if(n % res == 0)
    {
        cout << "Yes" << endl;
    } else
    {
        cout << "No" << endl;
    }

    return 0;
}

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

using ll = long long;
using K = long double;

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define SIZE(a) ((int)(a).size())

const int N = 2005;

int a[N][N];

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

	int n, k;
	cin >> n >> k;
	REP(i, n) {
		int x, y;
		char c;
		cin >> x >> y >> c;
		c = c == 'B';
		int now = y/k;
		int rem = y%k;
		for (int j = 0; j < 2*k; ++j) {
			int col = (x + j)/k;
			int tr = (col % 2 == now % 2) ^ c;
			if (tr) {
				++a[j][0];
				--a[j][k-rem];
			} else {
				++a[j][k-rem];
				--a[j][k];
			}
		}
	}

	int best = 0;
	for (int j = 0; j < 2*k; ++j) {
		int now = 0;
		REP(i, k) {
			now += a[j][i];
			best = max(best, now);
		}
	}

	cout << best << endl;

	return 0;
}


Measured memory_bytes: 15872
parseInt(x::String) = parse(Int, x)
parseInt(x::SubString{String}) = parse(Int, x)
parseInt(x::Char) = parse(Int, x)
parseInt(x::Float64) = trunc(Int, x)
parseFloat(x::String) = parse(Float64, x)
parseFloat(x::Int) = trunc(Float64, x)
parseFloat(x::SubString{String}) = parse(Float64, x)
parseFloat(x::Char) = parse(Float64, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

function main()
    a,b,c,d=parseMap(split(readline()))
    println(max(a*b,c*d))
end
main()

Measured memory_bytes: 168232
#define _GLIBCXX_DEBUG
#include "bits/stdc++.h"

using namespace std;

//------------------------------- Libraries --------------------------------//

//------------------------------- Type Names -------------------------------//

using i64 = int_fast64_t;

using seika = string;
//akari : 1D, yukari : 2D, maki : 3D vector
template <class kizuna>
using akari = vector<kizuna>;
template <class yuzuki>
using yukari = akari<akari<yuzuki>>;
template <class tsurumaki>
using maki = akari<yukari<tsurumaki>>;
//akane : ascending order, aoi : decending order
template <class kotonoha>
using akane = priority_queue<kotonoha, akari<kotonoha>, greater<kotonoha>>;
template <class kotonoha>
using aoi = priority_queue<kotonoha>;

//------------------------------- Dubug Functions ---------------------------//
inline void print()
{
    cout << endl;
}
template <typename First, typename... Rest>
void print(const First &first, const Rest &... rest)
{
    cout << first << ' ';
    print(rest...);
}
//------------------------------- Solver ------------------------------------//

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

int main()
{
    solve();
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
 
 
using namespace std;
int main()
{
 
  int a,b,c;
    cin >> a >> b >> c;
    if(a-b < c)
        cout << c-(a-b) << endl;
    else{
        cout << 0 << endl;
    }
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long int
#define MOD 1000000007
#define INF 1e18
#define PI 3.14159265358979

using namespace std;

int main(void){
  int n, k;
  cin >> n >> k;

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

  // 右からi個，左からj個取り出す
  ll m = -INF;
  for (int i = 0; i <= k; i++){
    for (int j = 0; j <= k; j++){
      if (i + j > k)
        break;
      if (i + j > n)
        break;

      vector<ll> a(0);
      for (int l = 0; l < i; l++){
        a.push_back(v[l]);
      }
      for (int l = 0; l < j; l++){
        a.push_back(v[n - l - 1]);
      }
      sort(a.begin(), a.end());
      int id = 0;
      while(id < i + j
          && a[id] < 0 
          && i + j + id < k){
        id++;
      }

      ll ret = 0;
      for (int l = id; l < i + j; l++){
        ret += a[l];
      }


      m = max(ret, m);
    }
  }


  cout << m << endl;

  return 0;
}


Measured memory_bytes: 256
//InTheNameOfGod
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define rep(i,j,k) for(int i=j;i<k;++i)
#define rrep(i,j,k) for(int i=j;i>=k;i--)
#define pb push_back
#define lb(i) i&(-i);
template<typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
const int maxn =1e9;
int n,re;
int sum(int a)
{
    int o=0;
    while(a)
    {
        o+=a%10;
        a/=10;
    }
    return o;
}
int main()
{
    ios_base::sync_with_stdio(false);cin.tie(0);
    cin>>n;
    re=maxn;
    rep(i,1,n)
    {
        int j=n-i;
        re=min(re,sum(i)+sum(j));
    }
    cout<<re;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#pragma warning(disable:4996)
#ifdef _MSC_VER
#  define __builtin_popcount __builtin_popcountll
#  define __builtin_popcountll __popcnt
#endif
//#define int long long
using namespace std;
using ll = long long;
using ld = long double;
const long double PI = acos(-1.0);
const int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
const int MAX_V = 500;

inline void my_io() {
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	std::cout << fixed << setprecision(10);
}
const int INF = 1e8;
struct edge {
	int from, to;long double  cost;
};
vector<double> dijkstra(int s, vector<vector<edge>>&graph,vector<int>&prev_) {//頂点sからほかのすべての頂点の最短距離を入れたvectorを返す
														 //以下pair<int,int>はfirstは最短距離 secondは頂点番号
	int n = graph.size();
	priority_queue < pair<int, int>, vector<pair<int, int>>, greater<pair<int, int>>>que;
	vector<double>d(n, INF);//頂点sからの最短距離
	d[s] = 0;//スタート地点からスタート地点の距離はゼロ
	que.push(pair<int, int>(0, s));
	while (!que.empty()) {
		pair<int, int>p = que.top();
		que.pop();
		int v = p.second;
		for (int i = 0; i < graph[v].size(); i++) {
			edge const &e = graph[v][i];
			if (d[e.to] > d[v] + e.cost) {
				d[e.to] = d[v] + e.cost;
				que.push(pair<int, int>(d[e.to], e.to));
				prev_[e.to] = v;
			}
		}
	}
	return d;
}
vector<int> get_path(int t,vector<int>&prev_) {
	vector<int>path;
	for (; t !=-1; t = prev_[t]) {
		path.push_back(t);
	}
	reverse(path.begin(), path.end());
	return path;
}
ld distance(ld x0, ld y0, ld x1, ld y1) {
	return sqrt((x0 - x1)*(x0 - x1) + (y0 - y1)*(y0 - y1));
}
signed main(){
	int n;
	while (cin >> n, n) {
		
		vector<tuple<int, int, int>>vs(n);
		map<int, int>mp;
		map<int, int>mp1;
		for (int i = 0; i < n; i++) {
			int p;
			
			cin >> p >> get<1>(vs[i]) >> get<2>(vs[i]);
			mp[i] = p;  
			mp1[p] = i;
			
		}

		vector < vector<edge>>graph(n);
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < n; j++) {
				if (i != j) {
					ld d = distance(get<1>(vs[i]), get<2>(vs[i]), get<1>(vs[j]), get<2>(vs[j]));
					if (50 >= d) {
						graph[i].push_back({ i,j,d });
						graph[j].push_back({ j,i,d });

					}
				}
			}
		}
		int m;
		cin >> m;
		for (int i = 0; i < m; i++) {
			int s, g;
			cin >> s >> g;
			vector<int>prev_(n, -1);
			vector<double>distes = dijkstra(mp1[s], graph,prev_);
			if (distes[mp1[g]] == INF) {
				cout << "NA" << endl;

			}
			else {
				assert(prev_[mp1[s]] == -1);
				auto ans = get_path(mp1[g],prev_);
				for (int i = 0; i < ans.size(); i++) {
					ans[i] = mp[ans[i]];
				}
				for (int i = 0; i < ans.size(); i++) {
					int integer = ans[i] ;
					cout << integer;
					if (i != ans.size() - 1) {
						cout << " ";
					}
					else {
						cout << endl;
					}

				}
			}
		}
	}
	return 0;

}	






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

int main(){
    int H,W;
    while(1){
    cin >> H >> W ;
    if(H==0&&W==0) break;
    for (int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            if(i==0||i==H-1||j==0||j==W-1){
            cout << "#";
        }else{
            cout << ".";
         }
        }
        cout << "\n" ;
    }
    cout << endl;
    }
    return 0;
}


Measured memory_bytes: 2976
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = (int)(a); i <= (int)(n); ++i)
using namespace std;
const int nmax = 1003;
int N;
deque<int> D[nmax];
void input() {
  int x;
  cin >> N;
  rep(i, 0, N - 1) {
    rep(j, 0, N - 2) {
      cin >> x;
      D[i].push_back(--x);
    }
  }
}
int ans;
void solve() {
  int M = N * (N - 1) / 2;
  bool update;
  set<int> available;
  rep(i, 0, N - 1) available.insert(i);  // 前日に戦っていない人
  set<int> av;
  for (int xxx = 1;; ++xxx) {
    av.clear();
    update = false;
    for (auto i : available) {
      bool exsist_i = D[i].size() && av.find(i) == av.end();
      int rival = D[i].front();
      bool exsist_rival = D[rival].size() && av.find(rival) == av.end();
      if (exsist_i && exsist_rival && D[rival].front() == i)

      {
        --M;
        update = true;
        D[i].pop_front();
        D[rival].pop_front();
        av.insert(i);
        av.insert(rival);
      }
    }
    available = av;
    if (M == 0) {
      ans = xxx;
      break;
    }
    if (!update) {
      ans = -1;
      break;
    }
  }
  cout << ans << endl;
}
signed main() {
  input();
  solve();
  return 0;
}

Measured memory_bytes: 4736
from collections import Counter,defaultdict
import sys,bisect,math,itertools,string,queue
mod = 10**9+7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())

n = inp()
a = inpl()
m_cnt = 0
for i in range(n):
    if a[i] < 0:
        m_cnt += 1
        a[i] = abs(a[i])
a.sort()
if m_cnt%2:
    print(sum(a) - a[0]*2)
else:
    print(sum(a))

Measured memory_bytes: 16060
import sys
input = sys.stdin.readline
ri = lambda: int(input())
#rl = lambda: [int(x) if x.isdecimal() else x for x in input().split()]
#rl = lambda: list(input().split()))
rl = lambda: map(int,input().split())
rr = lambda N: [list(l) for l in zip(*[rl() for _ in range(N)])]
YN = lambda b: print('YES') if b else print('NO')
yn = lambda b: print('Yes') if b else print('No')
OE = lambda x: print('Odd') if x%2 else print('Even')
INF = 10**18
MOD = 10**9+7

n=ri()
p=list(rl())
ans = 0
for i in range(1,n-1):
    p1,p2,p3 = p[i-1],p[i],p[i+1]
    p123 = [p1,p2,p3]
    if p2 != max(p123) and p2 != min(p123):
        ans += 1

print(ans)

Measured memory_bytes: 3064
import java.io.*;

class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		StringBuilder sb=new StringBuilder();
		int i=1;
		while(true){
        	String x=br.readLine();
        	if(x.equals("0")) break;
        	sb.append("Case "+i+": "+x+"\n");
    		i++;
        }
		System.out.print(sb);
	}
}

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

using namespace std;

#define ALL(g) (g).begin(),(g).end()
#define REP(i, x, n) for(int i = (int) x; i < (int)n; i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i, x, n) for(int i = (int) n; i > (int)x; i--)
#define rrep(i,n) RREP(i,0,n)
#define F(i,j,k) fill(i[0],i[0]+j*j,k)
#define P(p) cout<<(p)<<endl;
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define INF 1<<25
#define pb push_back
#define SZ(x) ((int)(x).size())

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

int main (){
  int x;
  int a,i;
  cin >> x;
  for(i=0;a<x;i++)
    a+=i;
  P(i-1);
  return 0;
}


Measured memory_bytes: 256
#include <iostream>

typedef long long int ll;

ll a, b, x;

ll qry(ll on)
{
	if(on==-1)
		return 0;
	return on/x+1;
}

int main()
{
	std::cin >> a >> b >> x;
	std::cout << qry(b)-qry(a-1) << '\n';
}

Measured memory_bytes: 256
n=int(input())
s=input()
t=input()
if n==1 and s!=t:
  print(2)
  exit()
if n==1 and s==t:
  print(1)
  exit()
ans=2*n
for i in range(n):
  if s[i:n]==t[0:n-i]:
    ans-=n-i
    break
print(ans)

Measured memory_bytes: 9056
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define REP(i,a,b) for (int i = a; i < (b); ++i)
#define all(x) (x).begin(),(x).end()
const int INF = 1000000007;
typedef long long ll;
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll a, ll b) { return (a * b) / gcd(a,b); }
ll fac(ll a) { return a > 1 ? fac(a - 1) * a : 1; }
bool echeck(ll a) { return a % 2 == 0 ? 1 : 0; }
ll comb(ll n, ll m){
  ll tmp = 1;
  for(int i = n; i >= n - m + 1; i--){
    tmp *= i;
  }
  ll temp = 1;
  for(int i = 1; i <= m; i++){
    temp *= i;
  }
  return tmp / temp;
}
int main(){
  // ios::sync_with_stdio(false);cin.tie(nullptr);
  vector<string>v(3);
  rep(i,3)cin >> v[i];
  int now = 0;
  vector<int>si(3);
  while(1){
    if(v[now].size() <= si[now])break;
    if(v[now][si[now]] == 'a'){
      si[now]++;
      now = 0;
    }
    else if(v[now][si[now]] == 'b'){
      si[now]++;
      now = 1;
    }
    else{
      si[now]++;
      now = 2;
    }
  }
  if(now == 0)cout << "A" << endl;
  else if(now == 1)cout << "B" << endl;
  else cout << "C" << endl;
  return 0;
} 

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

#define times(n, i) uptil(0, n, i)
#define upto(f, t, i) for(auto _##i = (t), i = decltype(_##i)(f) poi  i <= _##i poi  i++)
#define uptil(f, t, i) for(auto _##i = (t), i = decltype(_##i)(f) poi  i < _##i poi  i++)
#define downto(f, t, i) for(auto i = (f), _##i = decltype(i)(t) poi  i >= _##i poi  i--)
#define downtil(f, t, i) for(auto i = (f), _##i = decltype(i)(t) poi  i > _##i poi  i--)

#define unless(c) if(!(c))
#define until(c) while(!(c))
#define loop while(true)

#define poi ;
#define poipoi << "\n"

#define fuwafuwa(n, c) dokidoki((n) + (c) - 1, c)
#define dokidoki(n, c) ((n) / (c) * (c))

template<class T> bool read(T& t){
    return cin >> t poi
}
template<class T, class...U> bool read(T& t, U&... u){
    unless(cin >> t) return false poi
    return read(u...) poi
}

const int PYON = 80 poi

int main(){
    int N poi
    cin >> N poi
    times(N, i){
        string A, B poi
        cin >> A >> B poi
        if(A.size() > PYON || B.size() > PYON){
            cout << "overflow" poipoi poi continue poi
        }else if(A == "0" && B == "0"){
            cout << "0" poipoi poi continue poi
        }
        vector<int> a(PYON, 0), b(PYON, 0) poi
        upto(1, A.size(), i) a[PYON - i] = A[A.size() - i] - '0' poi
        upto(1, B.size(), i) b[PYON - i] = B[B.size() - i] - '0' poi
        int pyon = 0 poi
        vector<int> sum(PYON) poi
        downto(PYON - 1, 0, i){
            sum[i] = a[i] + b[i] + pyon poi
            pyon = sum[i] / 10 poi
            sum[i] %= 10 poi
        }
        if(pyon) cout << "overflow" poi
        else times(PYON, i) if((pyon = pyon || sum[i])) cout << sum[i] poi
        cout poipoi poi
    }
    return 0 poi
}

Measured memory_bytes: 1212
//#pragma GCC optimize("trapv")
#include <iostream>
#include <vector>
#include <tuple>
#include <deque>
#include <set>
#include <map>
#include <cmath>
#include <string>
#include <cassert>
#include <iomanip>
#include <algorithm>
#include <unordered_map>
#include <functional>
#define int long long
#define all(x) (x).begin(), (x).end()
#define allr(x) (x).rbegin(), (x).rend()

using namespace std;

const int MOD = 1e9 + 7;
const int INF = 1e9 + 10;

void fast()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
}

signed main()
{
	fast();
	int n;
	cin >> n;
	vector <int> a(n);
	int sum = 0;
	for (long long & e : a)
	{
		cin >> e;
		sum += e;
	}
	int ans = 0;
	for (int i = 0; i < n; ++i)
	{
		sum -= a[i];
		ans = (ans + (((sum % MOD) * a[i]) % MOD)) % MOD;
	}
	cout << ans << '\n';
	return 0;
}

Measured memory_bytes: 4764
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<deque>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#include<string>
#define rep(i,n,m) for(int i=(n);i<(int)(m);i++)
#define reps(i,n,m) for(int i=(n);i<=(int)(m);i++)
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair
#define fs first
#define sc second
#define lb lower_bound
#define ub upper_bound
#define LB(a,x) lb(all(a), x) - a.begin()
#define UB(a,x) ub(all(a), x) - a.begin()
#define printfdouble(x) printf("%.12f\n",(x))
#define chartoint(c) (int)((c) - '0')
#define chartoll(c) (long long)((c) - '0')
#define MOD 1000000007
#define itn int
#define enld endl
#define ednl endl
#define icn cin
#define stirng string
using namespace std;
typedef long long ll;
const double pi = 3.141592653589793;
using Graph = vector<vector<int>>;
template<class T> bool chmax(T &a, const T &b){if(a<b){a=b; return 1;} return 0;}
template<class T> bool chmin(T &a, const T &b){if(b<a){a=b; return 1;} return 0;}
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}


int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    int N; cin >> N;
    pair<int,int> red[105];
    pair<int,int> blue[105];
    rep(i,0,N){
        int a,b; cin >> a >> b;
        red[i] = {a,b};
    }
    rep(i,0,N){
        int c,d; cin >> c >> d;
        blue[i] = {c,d};
    }
    sort(red,red+N);
    sort(blue,blue+N);
    int ptr = 0;
    int ans = 0;
    bool used[105];
    Fill(used,false);
    rep(i,0,N){
        int cnt = -1;
        int maxy = -1;
        rep(j,0,N){
            if(blue[i].first > red[j].first && blue[i].second > red[j].second && used[j] == false){
                if(maxy < red[j].second){
                    maxy = red[j].second;
                    cnt = j;
                }
            }
        }
        if(cnt != -1){
            used[cnt] = true;
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3660
def main():
    import sys
    readline = sys.stdin.readline

    n = int(readline())
    *p, = (float(pi) for pi in readline().rstrip().split())

    dp = [[0] * (n + 1) for _ in range(n + 1)]
    dp[0][0] = 1
    # dp[投げた枚数][表の枚数] = 確率

    for i, pi in enumerate(p, 1):
        for j in range(i + 1):
            dp[i][j] += dp[i - 1][j] * (1 - pi) + dp[i - 1][j - 1] * pi

    ret = sum(dp[n][j] for j in reversed(range(n + 1)) if j * 2 > n)
    print(ret)


if __name__ == '__main__':
    main()


Measured memory_bytes: 275080
#include <iostream>

using namespace std;

int main()
{
	int N, M, C;
	cin >> N >> M >> C;

	int B[20];
	for (int j = 0; j < M; ++j)
		cin >> B[j];

	int count = 0;
	for (int i = 0; i < N; ++i)
	{
		int feature = C;
		for (int j = 0; j < M; ++j)
		{
			int A;
			cin >> A;
			feature += A * B[j];
		}
		if (feature > 0)
			++count;
	}

	cout << count << endl;
	return 0;
}


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

int main(){
    
    // 1. 入力情報.
    int a, b, c;
    scanf("%d %d %d", &a, &b, &c);
    
    // 2. 各ペンキの色の個数をカウント.
    set<int> s;
    s.insert(a);
    s.insert(b);
    s.insert(c);
    
    // 3. 出力.
    printf("%d\n", s.size());
    return 0;
    
}

Measured memory_bytes: 3736
#include <iostream> // cout, endl, cin
#include <cmath> //sqrt pow
#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> // dequef
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower

#define rep(i,n) for(int i = 0; i < n; i++)
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int, int>
#define all(a) (a).begin(), (a).end()
#define mod 1000000007
using ll = long long;
using namespace std;
int main(){
  int n;
  cin >> n;
  cout << n * 800 - n / 15 * 200 << endl;
}

Measured memory_bytes: 3580
#include<bits/stdc++.h>
using namespace std ;
int main () {
  
  string s , t ;
  cin >> s >> t ;
  vector<int> a[26] ;
  for(int i=0 ; i < s.length() ;i++)
    a[s[i]-'a'].push_back(i) ;
  long long cnt =0 ;
  int  ptr = -1;
  bool flag = true ;
        
  for(int i = 0 ; i < t.length() ;i++){
    int c = t[i]-'a';
    if(a[c].size() == 0) {
      flag= false ;
      break ;
    }
    vector<int> :: iterator it = upper_bound(a[c].begin(),a[c].end(),ptr) ;
    if(it == a[c].end()) {
      ptr = -1 ;
      cnt++ ;
      ptr = *upper_bound(a[c].begin(),a[c].end(),ptr);
    }
    else 
      ptr = *it ;
  }
  if(flag == true)
  cout<<(long long)(cnt*s.length())+ptr + 1<<endl;
  else cout<<-1<<endl;
      
  return 0 ;
  
}

Measured memory_bytes: 1216
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
using namespace std;
const int mod = 1000000007;
#define ll long long

int main()
{
	int N, s[110];
	cin >> N;
	int ans = 0;
	for (int i = 0; i < N; i++) {
		cin >> s[i];
		ans += s[i];
	}
	sort(s, s + N);
	if (ans % 10 == 0) {
		for (int i = 0; i < N; i++) {
			if ((ans - s[i]) % 10 != 0) {
				cout << ans - s[i] << endl;
				return 0;
			}
		}
		cout << 0 << endl;
		return 0;
	}
	else cout << ans << endl;
}


Measured memory_bytes: 256
n = int(input())
a = [int(i) for i in input().split(" ")]
c = 0
z = False
for i in range(0, n):
    if a[i] == 0:
        z = True
    elif a[i] < 0:
        c += 1

if z or c % 2 == 0:
    print(sum([abs(i) for i in a]))
else:
    ab = [abs(i) for i in a]
    print(sum(ab) - 2 * min(ab))

Measured memory_bytes: 14412
#include <bits/stdc++.h>
#define mod 1000000007
#define mod998 998244353
#define sp ' '
#define intmax 2147483647
#define llmax 9223372036854775807
#define mkp make_pair
typedef long long ll;
using namespace std;


ll Pow10[11];
char c;

int main() {
	Pow10[0] = 1;
	for (int i = 1; i < 11; ++i) {
		Pow10[i] = Pow10[i - 1] * 10;
	}
	for (int i = 1; i < 10; ++i) {
		cout << '?' << sp << Pow10[i] << endl;
		cin >> c;
		if (c == 'N') {
			ll l = Pow10[i - 1];
			ll r = Pow10[i] - 1;
			while (l + 1 != r) {
				cout << '?' << sp << (l + r) / 2 << 0 << endl;
				cin >> c;
				if (c == 'Y') {
					r = (l + r) / 2;
				}
				else {
					l = (l + r) / 2;
				}
			}
			cout << '!' << sp << r << endl;
			return 0;
		}
	}
	for (int i = 1; i < 11; ++i) {
		cout << '?' << sp << Pow10[i] - 1 << endl;
		cin >> c;
		if (c == 'Y') {
			cout << '!' << sp << Pow10[i - 1] << endl;
			return 0;
		}
	}
}

Measured memory_bytes: 596
N, X = map(int, input().split())
S = list(map(int, input().split()))
MOD = 10 ** 9 + 7
dp = [[0] * (X + 1) for i in range(N + 1)]
for i in range(X + 1):
    dp[0][i] = i

S = sorted(S)
for i in range(N):
    for j in range(X + 1):
        dp[i + 1][j] += dp[i][j % S[i]] + dp[i][j] * i
        dp[i + 1][j] %= MOD

print(dp[N][X])


Measured memory_bytes: 192136
#include <cmath>
#include <iostream>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <bitset>
#include <algorithm>
#include <utility>
#include <iomanip>

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

using namespace std;

typedef pair<int, int> P;

const int INF = 1e15;
const int MOD = 1e9+7;

int levenshtein(string s, string t){
    int lenS = s.length();
    int lenT = t.length();
    vector<vector<int>> dp(lenS+1, vector<int>(lenT+1));
    rep(i, lenS+1){
        dp[i][0] = i;
    }
    rep(i, lenT+1){
        dp[0][i] = i;
    }

    rep(i, lenS){
        rep(j, lenT){
            dp[i+1][j+1] = min(dp[i+1][j]+1, dp[i][j+1]+1);
            int c = s[i] == t[j] ? 0 : 1;
            dp[i+1][j+1] = min(dp[i+1][j+1], dp[i][j] + c);
        }
    }

    return dp[lenS][lenT];
}

signed main(){
    string s1, s2;
    cin >> s1 >> s2;

    cout << levenshtein(s1, s2) << endl;

    return 0;
}



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

using namespace std;
 
int main(void){
  // Num input
  int N, M;
  cin >> N >> M;
  // number vecter input
  vector<int> vec(N);
  for(int i = 0;i < N;i++){
  	cin >> vec.at(i);
  }
  // sort
  sort(vec.begin(),vec.end(),greater<int>());
  
  // sum number vector
  int total = 0;
  for(int i = 0; i < vec.size();i++){
    total += vec[i];
  }
  
  // check Yes or No
  int total_per;
  if (total % (4 * M) == 0){
  	total_per = total / (4 * M);
  }else{
  	total_per = total / (4 * M) + 1;
  }
  for(int i = 0;i < M;i++){
    if(vec[i] < total_per){
      cout << "No" << endl;
      return 0;
    }
  }
  
  cout << "Yes" << endl;
  
  return 0;
}

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

using namespace std;
typedef long long ll;
#define FOR(i,n) for(int i=0; i<int(n); i++)
#define FOR1(i,m,n) for(int i=int(m); i<int(n); i++)

const int MAXN=1e5;
const int MAXX=1e9;
const int MOD = 1e9+7;
int n, m;
ll sumx, sumy;

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

    ll x, prevx;
    cin >> x;
    FOR1(i,1,n) {
        prevx = x;
        cin >> x;
        sumx += (x-prevx) * i * (n-i);
        sumx %= MOD;
    }

    ll y, prevy;
    cin >> y;
    FOR1(i,1,m) {
        prevy = y;
        cin >> y;
        sumy += (y-prevy) * i * (m-i);
        sumy %= MOD;
    }

    cout << (sumx * sumy) % MOD << endl;
        
    return 0;
}


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

int main() {
	int A, B;
	cin >> A >> B;
	if(A>=13){
		cout << B <<endl;
	}
	else if(A<=5) {
		cout << 0 << endl;
	}
	else{
		cout << B/2 <<endl;
	}
}

Measured memory_bytes: 256