akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <clocale>
#include <cmath>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;

#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i, s, n) for(int i = (s), i##_len=(n); i < i##_len; ++i)
#define FORS(i, s, n) for(int i = (s), i##_len=(n); i <= i##_len; ++i)
#define VFOR(i, s, n) for(int i = (s); i < (n); ++i)
#define VFORS(i, s, n) for(int i = (s); i <= (n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define REPS(i, n) FORS(i, 0, n)
#define VREP(i, n) VFOR(i, 0, n)
#define VREPS(i, n) VFORS(i, 0, n)
#define RFOR(i, s, n) for(int i = (s), i##_len=(n); i >= i##_len; --i)
#define RFORS(i, s, n) for(int i = (s), i##_len=(n); i > i##_len; --i)
#define RREP(i, n) RFOR(i, n, 0)
#define RREPS(i, n) RFORS(i, n, 0)
#define ALL(v) (v).begin(), (v).end()
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v), greater<decltype(v[0])>())
#define SZ(x) ((int)(x).size())
#define PB push_back
#define MP make_pair
#define MT make_tuple
#define BIT(n) (1LL<<(n))
#define UNIQUE(v) v.erase(unique(ALL(v)), v.end())

using ll = long long;
using Pi_i = pair<int, int>;
using VI = vector<int>;
using VD = vector<double>;
using VLL = vector<ll>;
using VS = vector<string>;
using VC = vector<char>;
using VB = vector<bool>;

const int MOD = 1000000007;
const int INF = 1000000000;

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;
}



VI G;

void revprintVector(VI &a){
    int n = SZ(a);
    RREP(i, n-1){
         cout << a[i];
         if(i) cout << " ";
    }
    cout << "\n";
}

void printVector(VI &a){
    int n = SZ(a);
    REP(i, n){
        if(i) cout << " ";
        cout << a[i];
    }
    cout << "\n";
}

int insertionSort(VI &a, int g){
    int n = SZ(a), ret = 0;
    FOR(i, g, n){
        int instnum = a[i], j;
        for(j = i - g; j >= 0 && a[j] > instnum; j -= g){
            a[j+g] = a[j]; ++ret;
        }
        a[j+g] = instnum;
      //  printVector(a);
    }
    
    return ret;
}

ll shellSort(VI &a){
    ll cnt  = 0;
    int n = SZ(a);
    for(int h = 1;;){
        if(h > n) break;
        G.PB(h);
        h = 3*h + 1;
    }

    RREP(i, G.size() -1){
        cnt += insertionSort(a, G[i]);
    }
    return cnt;
}

int main(){
    int n; cin >> n;
    VI a(n);
    REP(i, n) cin >> a[i];
    ll cnt = shellSort(a);
    cout << G.size() << "\n";
    revprintVector(G);
    cout << cnt << "\n";
    REP(i, n) cout << a[i] << "\n";
    return 0;
}



Measured memory_bytes: 6732
s = int(input())
l = [s]
i = 0
def calc(n):
  if n % 2 == 0:
    return n // 2
  else:
    return 3 * n + 1
while True:
  l.append(calc(l[i]))
  if l.count(calc(l[i])) == 2:
    break
  i += 1
#print(l)
print(i+2)

Measured memory_bytes: 3060
import sys
R = lambda:map(int,raw_input().split())

s = raw_input()
l = len(s)
#print s, l
n = int(raw_input())
neko = 0
for i in xrange(n):
    ring = raw_input()
    #print ring
    rings = ring + ring
    #print rings
    for i in xrange(len(ring)):
        cc = []
        for j in xrange(l):
            cc.append(rings[i+j])
        zgok = "".join(cc)
        #print zgok
        if zgok == s:
            neko += 1
            break
print neko

Measured memory_bytes: 4236
#include <iostream>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <string>
#include <sstream>
#include <algorithm>
#include <random>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cmath>
#include <cassert>
#include <climits>
#include <bitset>
#include <functional>

#define FOR_LT(i, beg, end) for (int i = beg; i < end; i++)
#define FOR_LE(i, beg, end) for (int i = beg; i <= end; i++)
#define FOR_DW(i, beg, end) for (int i = beg; end <= i; i--)

using namespace std;

struct Edge {
	int n;
	int64_t p;
};

int64_t score[2501] = {};

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	int n, m, p; cin >> n >> m >> p;

	vector<vector<Edge>> edges(n + 1);
	FOR_LT(i, 0, m) {
		int a, b, c; cin >> a >> b >> c;
		edges[a].push_back({ b, c - p});
	}
	FOR_LE(i, 1, n) score[i] = INT64_MIN;
	score[1] = 0;

	FOR_LT(i, 0, n * 3) {
		FOR_LE(v, 1, n) {
			for (auto& edge : edges[v]) {
				if (score[v] == INT64_MIN) continue;

				int64_t np = score[v] + edge.p;
				if (np > score[edge.n]) {
					score[edge.n] = np;
					if (n <= i && edge.n == n) {
						cout << "-1" << endl;
						return 0;
					}
				}
			}
		}
	}

	if (score[n] < 0) cout << 0 << endl;
	else  cout << score[n] << endl;

	return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define pi acos(-1.0)

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

#define MOD 1000000007

int main(){
    int n;
    cin >> n;
    VI t(n), a(n);
    REP(i,n) scanf("%d", &t[i]);
    REP(i,n) scanf("%d", &a[i]);

    VI h(n), f(n);
    int x = 0;
    REP(i,n){
        if (t[i] > x){
            h[i] = t[i];
            f[i] = 1;
            x = t[i];
        }else{
            h[i] = h[i-1];
        }
    }
    x = 0;
    FORR(i,n-1,0){
        if (f[i] == 1 && a[i] < h[i]){
            cout << 0 << endl;
            return 0;
        }
        if (a[i] > x){
            if (f[i] == 1 && a[i] != h[i]){
                cout << 0 << endl;
                return 0;
            }
            h[i] = a[i];
            f[i] = 1;
            x = a[i];
        }else{
            h[i] = min(h[i], h[i+1]);
        }
    }

    ll ans = 1;
    REP(i,n){
        if (!f[i])
            ans = (ans * h[i]) % MOD;
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define int long long
#define rng(i, l, r) for (size_t i = (l); i < (r); ++i)
#define rep(i, n) rng(i, 0, n)
#define gnr(i, l, r) for (size_t i = (r)-1; i >= (l); i--)
#define per(i, b) gnr(i, 0, b)
#define ALL(obj) (obj).begin(), (obj).end()    //1,2,3,...
#define rALL(obj) (obj).rbegin(), (obj).rend() //...,3,2,1

using namespace std;

const int INF = 1e18;

void solve()
{
    // remove the bottom 3 lines when you submit this code.
    std::ifstream in("./sample.txt");
    std::cin.rdbuf(in.rdbuf());

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

    int n, m;
    cin >> n >> m;

    int ans = 0;

    ans = ((n == 1) ? 1 : n - 2) * ((m == 1) ? 1 : m - 2);

    cout << ans << endl;
}

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


Measured memory_bytes: 3660
#include <stdio.h>

#define S_MAX 500000
#define inf 1000000000

int cnt = 0;

void merge(int *,int,int,int);
void mergeSort(int *,int,int);

int main(void){
  int n,i;
  int S[S_MAX];

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

  mergeSort(S,0,n);
  
  for(i = 0;i < n;i++){
    if(i == n - 1){
      printf("%d\n%d\n",S[i],cnt);
    }else{
    printf("%d ",S[i]);
    }
  }

  return 0;
}

void merge(int *S,int left,int mid,int right){
  int N1,N2,i,j,k;
  N1 = mid - left;
  N2 = right - mid;
  int L[N1],R[N2];

  for(i = 0;i < N1;i++){
    L[i] = S[left + i];
  }
  for(i = 0;i < N2;i++){
    R[i] = S[mid + i];
  }
  L[N1] = inf;
  R[N2] = inf;
  i = 0;
  j = 0;
  for(k = left;k < right;k++){
    if(L[i] <= R[j]){
      S[k] = L[i];
      i++;
      cnt++;
    }else{
      S[k] = R[j];
      j++;
      cnt++;
    }
  }
}

void mergeSort(int *S,int left,int right){
  int mid;
  if(left + 1 < right){
    mid = (left + right) / 2;
    mergeSort(S,left,mid);
    mergeSort(S,mid,right);
    merge(S,left,mid,right);
  }
}



Measured memory_bytes: 5612
#include <iostream>
#include <utility>
#include <map>
#include <vector>
#include <algorithm>
#include <queue>
#include <math.h>
#include <stack>
#include <set>
#include <deque>
#include <cmath>

using namespace std;
typedef long long ll;
ll mod = 1e9+7;
//ll mod = 998244353;
#define rep(i,n) for(int i = 0; i < (n); ++i)

int main() {
    ll n, a, b;
    cin >> n >> a >> b;
    if (!(abs(a-b)&1)) {
        cout << abs(a-b)/2 << endl;
    }
    else {
        ll d = min({a-1, b-1, n-a, n-b});
        cout << abs(a-b)/2 + 1 + d << endl;
    }
    return 0;
}


Measured memory_bytes: 3608
N = int(input())
A = sorted(list(map(int,input().split())))
B = (10**6+1)*[0]

for a in A:
  B[a]+=1
  if B[a]==1:
    for n in range(2*a,10**6+1,a):
      B[n]+=10

print(B.count(1))

Measured memory_bytes: 32408
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<string>
#include<vector>
#include<stack>
#include<bitset>
#include<cstdlib>
#include<cmath>
#include<set>
#include<list>
#include<deque>
#include<map>
#include<queue>
#define ll long long
using namespace std;
ll a[100009],k,j,i,n;
ll check(ll p)
{
    int i=0;
    for (j=0; j<k; j++)
    {
        ll s=0;
        while (s+a[i]<=p)
        {
            s+=a[i];
            i++;
            if (i==n)
            {
                return n;
            }
        }
    }
    return i;
}
int solve()
{
    ll left=0;
    ll right=1000000000;
    ll mid;
    while (left<right)
    {
        mid=(left+right)/2;
        if (check(mid)>=n)
        {
            right=mid;
        }
        else
        {
            left=mid+1;
        }
    }
    return right;
}
int main()
{
    cin>>n>>k;
    for (i=0; i<n; i++)
    {
        cin>>a[i];
    }
    ll ans=solve();
    cout<<ans<<endl;
}


Measured memory_bytes: 3876
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>

using namespace std;
#define MAXN 500000
#define INF 0x3f3f3f3f
#define pb push_back
#define lc(x) (x<<1)
#define rc(x) (x<<1|1)
#define mn(x) t[x]
#define mid (lef+rig>>1)
#define rint register int
#define gc() getchar()
inline int read(rint ans = 0, rint sgn = ' ', rint ch = gc())
{
	for(; ch < '0' || ch > '9'; sgn = ch, ch = gc());
	for(; ch >='0' && ch <='9';(ans*=10)+=ch-'0', ch = gc());
	return sgn-'-'?ans:-ans;
}
int N, K, O, P[MAXN+5], Q[MAXN+5], t[(MAXN<<2)+5], in[MAXN+5]; vector<int> e[MAXN+5]; priority_queue<int,vector<int>,less<int> > q;
#define Push(p) (mn(p) = min(mn(lc(p)),mn(rc(p))))
inline void Build(int p, int lef, int rig){lef-rig ? Build(lc(p),lef,mid), Build(rc(p),mid+1,rig), Push(p) : mn(p) = INF;}
inline void Edit(int p, int lef, int rig, int x, int v){lef-rig ? x <= mid ? Edit(lc(p),lef,mid,x,v) : Edit(rc(p),mid+1,rig,x,v), Push(p) : mn(p) = v;}
inline int Query(int p, int lef, int rig, int L, int R)
{
	if(L == lef && R == rig) return mn(p);
	if(R <= mid) return Query(lc(p),lef,mid,L,R);
	if(L >  mid) return Query(rc(p),mid+1,rig,L,R);
	return min(Query(lc(p),lef,mid,L,mid),Query(rc(p),mid+1,rig,mid+1,R));
}
int main()
{
	O = N = read(), K = read(); for(rint i = 1; i <= N; P[i] = read(), Q[P[i]] = i, i++); Build(1,1,N);
	for(rint i = N, p; i >= 1; Edit(1,1,N,Q[i],i), i--)
		p = Query(1,1,N,max(Q[i]-K+1,1),Q[i]), p <= N ? e[Q[p]].pb(Q[i]), ++in[Q[i]] : 0,
		p = Query(1,1,N,Q[i],min(Q[i]+K-1,N)), p <= N ? e[Q[p]].pb(Q[i]), ++in[Q[i]] : 0;
	for(rint i = 1; i <= N; !in[i] ? q.push(i),0 : 0, i++);
	for(rint p, i, _sz; !q.empty(); )
		for(p = q.top(), q.pop(), P[p] = O--, i = 0, _sz = (int)e[p].size(); i < _sz; i++)
			!--in[e[p][i]] ? q.push(e[p][i]),0 : 0;
	for(rint i = 1; i <= N; printf("%d\n",P[i]), i++); return 0;
}

Measured memory_bytes: 43008
#include <bits/stdc++.h>
#define ll long long
#define PB push_back
#define MP make_pair
#define F first
#define S second

#define REP(i, n) for(int i=0;i<(int)(n);++i)
#define FOR(i,l,h) for(int i=(int)(l);i<=(int)(h);++i)
#define FORD(i,h,l) for(int i=(int)(h);i>=(int)(l);--i)

#define max(a,b) a>b?a:b
#define min(a,b) a>b?b:a

ll gcd(ll a, ll b) { return !b ? a : gcd(b, a % b); }
ll lcm(ll a, ll b) { return (a / gcd(a, b)) * b; }

#define dump(x)  cerr << #x << " = " << (x) << endl
#define ALL(t) (t).begin(),(t).end()

using namespace std;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n,k;cin>>n>>k;
    if(n>=10){
        cout<<k<<"\n";
    }
    else{
        cout<<k+(100*(10-n))<<"\n";
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <numeric>
#include <queue>
#include <unordered_map>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <sstream>
#include <stack>
#include <map>
#include <set>

#define REP(i,a) for(int i = 0;i < (a);++i)
#define FOR(i,a,b) for(int i = (a);i < (b); ++i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SIZE(obj) (int)(obj).size()
#define MAX(list) std::max(list)
#define MIN(list) std::min(list)
#define YESNO(cond,yes,no){cout <<((cond)?(yes):(no))<<endl; }

template<typename T>
T round_up(const T& a, const T& b) {
    return (a + (b - 1)) / b;
}

using ll = long long;
using namespace std;
ll mod = 1'000'000'007;

const int INF = 1'050'000'000;

int main() {
    int A, B;
    string S;
    cin >> A >> B >> S;

    bool flag = true;
    REP(i, A + B + 1) {
        if (i == A) {
            if (S[i] != '-') {
                flag = false;
            }
        }
        else {
            if (!('0' <= S[i] && S[i] <= '9')) {
                flag = false;
            }
        }
    }

    YESNO(flag, "Yes", "No");
    return 0;

}

Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Linq;
using static MyIO;


public class A
{
    public static void Main()
    {
        int a = GetInt();
        int b = GetInt();
        int h= GetInt();

        int ans = (a*h) + ((b - a)*h)/2;
        Console.WriteLine(ans);
    }
}

public static class MyIO
{
    private static string[] args = null;
    private static int num = -1;
    private static int used = -1;

    private static string getArg()
    {
        if (used == num)
        {
            args = Console.ReadLine().Split(' ');
            num = args.Length;
            used = 0;
        }
        return args[used++];
    }

    public static int GetInt() { return int.Parse(getArg()); }
    public static long GetLong() { return long.Parse(getArg()); }
    public static double GetDouble() { return double.Parse(getArg()); }
    public static string GetString() { return getArg(); }
}


Measured memory_bytes: 13140
s = input()
if s[0] != 'A':
    print('WA')
    exit()
a = ord(s[1])
if not ord('a') <= a <= ord('z'):
    print('WA')
    exit()
a = ord(s[-1])
if not ord('a') <= a <= ord('z'):
    print('WA')
    exit()
c,d = 0,0
for i in s[2:]:
    if i == 'C':
        c += 1
    elif ord('a') <= ord(i) <= ord('z'):
        d += 1
    else:
        print('WA')
        exit()
if c != 1:
    print('WA')
    exit()
if c + d != len(s) - 2:
    print('WA')
    exit()
print('AC')

Measured memory_bytes: 3064
N = int(input())
A = [list(map(int, input().split())) for i in range(N)]
MOD = 10 ** 9 + 7
dp = [0] * (1<<N)
dp[0] = 1
for i in range(1, 1<<N):
    cnt = 0
    for j in range(N+1):cnt += (i>>j)&1
    for j in range(N):
        if (i>>j)&1 == 0: continue
        dp[i] += dp[i - (1<<j)] * A[cnt-1][j]
        dp[i] %= MOD
print(dp[-1])


Measured memory_bytes: 90220
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
#define repf(i,a,b) for (int i = (a); i < (b); i++)
#define repi(i,a,b) for (int i = (a); i <= (b); i++)
#define repr(i,a,b) for (int i = (a); i >= (b); i--)
#define all(x) (x).begin(),(x).end()
#define debug(x)  cout << #x << " = " << (x) << endl;
using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;
using vc = vector<char>;
using vvc = vector<vc>;
using vs = vector<string>;
using tiii = tuple<int, int, int>;

int main() {
  int N, X; cin >> N >> X;
  vi m(N); rep(i,N) cin >> m.at(i);
  
  int ans = N, W;
  W = accumulate(all(m),0);
  int mm = *min_element(all(m));
  while(W+mm<=X) {
    W += mm;
    ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
inline ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
inline ll lcm(ll a, ll b) { return a / gcd(a, b)*b; }
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T>& V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> >& Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T>& mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }
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,Ts... ts){return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));}
template<typename T,typename V> typename enable_if<is_class<T>::value==0>::type fill_v(T &t,const V &v){t=v;}
template<typename T,typename V> typename enable_if<is_class<T>::value!=0>::type fill_v(T &t,const V &v){for(auto &e:t) fill_v(e,v);}
/*
 <url:>
 問題文============================================================
 =================================================================
 解説=============================================================
 ================================================================
 */

// nの約数を列挙する
vector<ll> getdivisor(ll n){
    vector<ll> res;
    for(ll i = 1; i*i <= n;i++){
        if(n%i == 0) {
            res.push_back(i);
            if(n/i != i) res.push_back(n/i);
        }
    }
    sort(res.begin(),res.end());
    return res;
}

template<class Type>
Type solve(Type res = Type()){
    ll N; cin >> N;
    vector<ll> A(N);
    for(auto& in:A) cin >> in;
    
    
    {
        auto divisors = getdivisor(A[0]);
        for(auto divisor:divisors){
            ll cnt = 0;
            for(int i = 0; i < N;i++){
                if(A[i]%divisor==0) cnt++;
            }
            if(cnt >= N-1) res = max(res,divisor);
        }
    }
    {
        auto divisors = getdivisor(A[1]);
        for(auto divisor:divisors){
            ll cnt = 0;
            for(int i = 0; i < N;i++){
                if(A[i]%divisor==0) cnt++;
            }
            if(cnt >= N-1) res = max(res,divisor);
        }
    }
    
    return res;
}
int main(void) {
    cin.tie(0); ios_base::sync_with_stdio(false);
    // solve(0);
    cout << fixed << setprecision(15) << solve<ll>() << endl;
    return 0;
}


Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {
	
	public static void main(String[] args)
	{
		Scanner s=new Scanner(System.in);
		
		int n=s.nextInt();
		
		int rem=n%1000;
		
		int ans=1000-rem;
		
		if(ans==1000)
			ans=0;
		
		System.out.println(ans);
		
	}	
	
}

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

int main() {
  
  int N;
  cin >> N;
  
  int sum = 0;
  int M = N;
  
  while ( 0 < N ){
    sum += N % 10;
    N /= 10;
  }
  
  if ( M % sum == 0 ){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
   
}


Measured memory_bytes: 256
"""
O(1)解法
以下の3つから一番安いものを選ぶ
1. AピザとBピザをそれぞれ必要数買う場合
2. ABピザを必要数の多いピザ基準で買う場合 (2倍必要になることを忘れない)
3. ABピザを必要数の少ないピザ基準で買い、不足分のピザを買い足す場合
"""
A, B, C, X, Y = map(int, input().split())
# Aピザの必要数がBピザよりも多くなるように、必要数と値段を入れ替える
if X < Y:
    X, Y = Y, X
    A, B = B, A
p1 = A * X + B * Y  # 1
p2 = 2 * C * X  # 2
p3 = 2 * C * Y + (X - Y) * A  # 3
print(min(p1, p2, p3))


Measured memory_bytes: 3188
k=int(input())+1
tot=0

def gcd(a,b,c):#a<=b<=c
  t=a
  while a%t!=0 or b%t!=0 or c%t!=0:
    t-=1
    
  return t

for i in range(1,k):
  for j in range(i,k):
    for m in range(j,k):
      if i==j and i==m:
        tot+=gcd(i,j,m)
      elif i==j or j==m:
        tot+=3*gcd(i,j,m)
      else:
        tot+=6*gcd(i,j,m)
      
print(str(tot))

Measured memory_bytes: 68724
import heapq

def main():
    x, y, a, b, c = map(int, input().split())
    p = sorted(list(map(int, input().split())))
    p = [p[i] for i in range(-x, 0)]
    q = sorted(list(map(int, input().split())))
    q = [q[i] for i in range(-y, 0)]
    r = sorted(list(map(int, input().split())), reverse=True)
    for i in range(c):
        red = heapq.heappop(p)
        green = heapq.heappop(q)
        if r[i] <= red and r[i] <= green:
            heapq.heappush(p, red)
            heapq.heappush(q,green)
            break
        else:
            if r[i] - red >= r[i] - green:
                heapq.heappush(p, r[i])
                heapq.heappush(q,green)
            else:
                heapq.heappush(q, r[i])
                heapq.heappush(p, red)
    print(sum(p)+sum(q))

if __name__ == '__main__':
    main()

Measured memory_bytes: 109864
#include<bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
using namespace std;
bool ch(int x){
    string s;
    while(x){
        s+=x%10+'0';
        x/=10;
    }
    r(i,s.size()/2)if(s[i]!=s[s.size()-i-1])return 0;
    return 1;
}
int main(){
    int n,x=0,f=0;
    cin>>n;
    for(;;){
        if(ch(n-x))n-=x,f++;
        else if(ch(n+x))n+=x,f++;
        if(f)break;
        x++;
    }
    cout<<n<<endl;
}

Measured memory_bytes: 3204
// Created by sz
#include <bits/stdc++.h>
using namespace std;

const int maxn = 1e4+5;

int dp[maxn], s[10];

int digits[] = {1,2,3,4,5,6,7,8,9};
int num_sticks[] = {2,5,5,4,5,6,3,7,6};

int main(){
#ifdef LOCAL
    freopen("./input.txt", "r", stdin);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    
    int n,m;
    cin>>n>>m;
    vector<int> a(m, 0);
    
    set<int> len;
    
    for(int i = 0; i<m; i++){
        cin>>a[i];
        len.insert(num_sticks[a[i]-1]);
        s[num_sticks[a[i]-1]] = max(s[num_sticks[a[i]-1]], a[i]);
    }
    
    fill(dp, dp+n+1, -1);
    dp[0] = 0;
    for(int i = 1; i <= n; i++){
        for(auto j:len ){
            if(i>=j&&dp[i-j]!=-1)dp[i] = max(dp[i], dp[i-j]+1);
        }
    }

    int k = n;
    vector<char> ss;
    while(k){
        int somelen = *(len.begin());
        for(auto i: len){
            if(i!=somelen&&k-somelen>=0&&k-i>=0)
                if(dp[k-somelen]<dp[k - i]||(dp[k-somelen]==dp[k - i]&&s[somelen]<s[i]))
                somelen = i;
        }
        ss.push_back(s[somelen] + '0');
        k -= somelen;
    }
    
    for(auto i: ss)cout<<i;
    cout<<endl;
    return 0;
}



Measured memory_bytes: 384
#include <iostream>
#include <queue>
#include <string>
#include <algorithm>
using namespace std;

int main()
{
    int n, q, p_time, total_time, work_time;
    total_time = 0;
    string p_name;
    pair<string, int> process;
    cin >> n >> q;
    queue<pair<string, int>> p_queue;
    for (int i = 0; i < n; i++)
    {
        cin >> p_name >> p_time;
        p_queue.push(make_pair(p_name, p_time));
    }
    while (!p_queue.empty())
    {
        process = p_queue.front();
        p_queue.pop();
        work_time = min(process.second, q);
        process.second -= work_time;
        total_time += work_time;
        if (process.second > 0)
        {
            p_queue.push(process);
        }
        else
        {
            cout << process.first << " " << total_time << "\n";
        }
    }
    return 0;
}



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

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

#define mod 1e9+7;
#define inf 1e18+7;

typedef long long ll;

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


    if(n%500<=a){
        cout<<"Yes"<<endl;
        return 0;
    }
    cout<<"No"<<endl;
}


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

using namespace std;

int n;
long long f[maxn][3];
int x;
char s[maxn];

int main(){
	memset(f, -0x3f, sizeof(f));
	scanf("%d", &n);
	scanf("%d", &x);
	f[1][0] = x;
	for(int i = 2;i <= n;i++){
		scanf("%s%d", s, &x);
		if(s[0] == '-'){
			for(int j = 0;j < 3;j++) f[i][j] = max(f[i][j], f[i - 1][j] + x * (j & 1 ? 1 : -1));
			for(int j = 0;j < 2;j++) f[i][j + 1] = max(f[i][j + 1], f[i - 1][j] + x * (j & 1 ? 1 : -1));
		}else{
			for(int j = 0;j < 3;j++) f[i][j] = max(f[i][j], f[i - 1][j] + x * (j & 1 ? -1 : 1));
		}
		f[i][0] = max(f[i][0], f[i][1]);
		f[i][1] = max(f[i][1], f[i][2]);
	}
	printf("%lld", f[n][0]);
}

Measured memory_bytes: 6132
#include<stdio.h>
int main(void)
{
	int a[10000], b, c, d, e, f, g, i;
	for(i=0;i<5;i++){
	scanf("%d",&a[i]);
	}
	if(a[2]>a[4]){
		b=a[1];
	}
	if(a[2]<a[4]){
		b=a[1]+a[3]*(a[4]-a[2]);
	}
	if(a[0]*a[4]>b){
		printf("%d\n",b);
	}
	if(a[0]*a[4]<b){
		printf("%d\n",a[0]*a[4]);
	}
	return 0;
}

Measured memory_bytes: 2736
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG //これつけるとA[N]でもいいらしい
//for文のマクロ
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define mp(a,b) make_pair(a,b)
#define big 1000000007
#define all(a) sort((a).begin(),(a).end()) //ソートのマクロ
#define Re(a) reverse((a).begin(),(a).end())
#define YN(a) if(a){cout<<"Yes"<<endl;}else cout<<"No"<<endl;//条件によってYes、Noを出力する
const int MOD=1000000007;
const double pi = 3.141592653589793;
int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    char c;
    cin>>c;
    if(toupper(c)==c){
        cout<<"A"<<endl;
    }
    else{
        cout<<"a"<<endl;
    }
}

Measured memory_bytes: 3648
#include<stdio.h>
#include<string.h>
int main(){
  int i,j;
  int m[6][7],n[7][6],x=1+1,y=0+1,xs=1,ys=0;
  char s[6];
  memset(m,0,sizeof(m));
  memset(n,0,sizeof(n));
  for(i=0+1;i<4+1;i++){
    scanf("%s",s);
    for(j=0+1;j<4+1;j++)
      m[j][i]=s[j-1]-'0';
    scanf("%s",s);
    for(j=0+1;j<5+1;j++)
      n[j][i]=s[j-1]-'0';
  }
  scanf("%s",s);
  for(j=0+1;j<4+1;j++)
    m[j][i]=s[j-1]-'0';
  printf("R");
  for(i=0;x!=1||y!=1;i++){
    if(i==100)
      break;
    if(xs==1){
      if(n[x][y-1]){
	xs=0;
	ys=-1;
      }else if(m[x][y]){
      }else if(n[x][y]){
	xs=0;
	ys=1;
      }else
	xs=-1;
    }else if(xs==-1){
      if(n[x][y]){
	xs=0;
	ys=1;
      }else if(m[x-1][y]){
      }else if(n[x][y-1]){
	xs=0;
	ys=-1;
      }else
	xs=1;
    }else if(ys==1){
      if(m[x][y]){
	xs=1;
	ys=0;
      }else if(n[x][y]){
      }else if(m[x-1][y]){
	xs=-1;
	ys=0;
      }else
	ys=-1;
    }else if(ys==-1){
      if(m[x-1][y]){
	xs=-1;
	ys=0;
      }else if(n[x][y-1]){
      }else if(m[x][y]){
	xs=1;
	ys=0;
      }else
	ys=1;
    }
    x+=xs;
    y+=ys;
    if(xs==1)
      printf("R");
    if(xs==-1)
      printf("L");
    if(ys==1)
      printf("D");
    if(ys==-1)
      printf("U");
  }
  puts("");
  return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#define int long long
#define rep(i, n) for(i = 0; i < (n); i++)
using namespace std;

int mod = 1000000007;
int h, w, k;
int dp[101][8];

//番号x -> x+1の間に線を引くとき、その高さの線の引き方が何通りあるか？（0-indexed）
int count1(int x) {
	int i, j;
	int cnt = 0;
	
	rep(i, 1 << (w - 1)) {
		if ((i >> x) % 2 == 0) continue;
		rep(j, w - 2) {
			if ((i >> j) % 2 == 1 && (i >> (j + 1)) % 2 == 1) break;
		}
		if (w >= 3 && j < w - 2) continue;
		cnt++;
	}
	return cnt;
}

//番号x(>=0)の縦棒と隣接する場所に線を引かないとき、その高さの線の引き方が何通りあるか？
int count2(int x) {
	int i, j;
	int cnt = 0;
	
	rep(i, 1 << (w - 1)) {
		if ((i >> x) % 2 == 1) continue;
		if (x > 0 && (i >> (x - 1)) % 2 == 1) continue;
		rep(j, w - 2) {
			if ((i >> j) % 2 == 1 && (i >> (j + 1)) % 2 == 1) break;
		}
		if (w >= 3 && j < w - 2) continue;
		cnt++;
	}
	return cnt;
}

signed main() {
	int i, j;
	
	cin >> h >> w >> k;
	if (w == 1) { cout << 1 << endl; return 0; }
	k--;
	
	dp[0][0] = 1;
	rep(i, h) {
		rep(j, w) {
			//左にいく
			if (j > 0) {
				dp[i + 1][j - 1] += dp[i][j] * count1(j - 1);
				dp[i + 1][j - 1] %= mod;
			}
			//右に行く
			if (j + 1 < w) {
				dp[i + 1][j + 1] += dp[i][j] * count1(j);
				dp[i + 1][j + 1] %= mod;
			}
			//直進する
			dp[i + 1][j] += dp[i][j] * count2(j);
			dp[i + 1][j] %= mod;
		}
	}
	
	cout << dp[h][k] << endl;
	return 0;
}

Measured memory_bytes: 256
import sys
import  math
import fractions
from collections import defaultdict
import copy
stdin = sys.stdin
     
ns = lambda: stdin.readline().rstrip()
ni = lambda: int(stdin.readline().rstrip())
nm = lambda: map(int, stdin.readline().split())
nl = lambda: list(map(int, stdin.readline().split()))

X,K,D=nm()
X=abs(X)
if(K*D<=X):
    print(X-K*D)
    sys.exit(0)
else:
    tmp=X%D
    tmp2=K-(X//D)
    if(tmp2%2==0):
        print(tmp)
        sys.exit(0)
    else:
        print(D-tmp)
        sys.exit(0)

Measured memory_bytes: 10536
/*
    Washief Hossain Mugdho
    17 September 2020
    Educational DP Knapsack2
*/

#ifndef DEBUG
#pragma GCC optimize("O3")
#endif

#include <bits/stdc++.h>
#define ull unsigned long long
#define ll long long
#define pb push_back
#define mp make_pair
#define fr first
#define sc second
#define fastio ios_base::sync_with_stdio(0)
#define untie cin.tie(0)
#define ms(a, b) memset(a, b, sizeof a)
using namespace std;
int N, W, w[105], v[105];

int main()
{
#ifdef LOCAL_OUTPUT
    freopen(LOCAL_OUTPUT, "w", stdout);
#endif
#ifdef LOCAL_INPUT
    freopen(LOCAL_INPUT, "r", stdin);
#endif
    int N, W;
    cin >> N >> W;
    int w[N], v[N];
    for (int i = 0; i < N; i++)
        cin >> w[i] >> v[i];
    int res = 0;
    int high = 1000 * N + 4;
    vector<vector<int>> memo(high, vector<int>(N + 1, INT32_MAX));

    for (int i = 0; i <= N; i++)
        memo[0][i] = 0;

    for (int i = 0; i < high; i++)
        for (int j = 1; j <= N; j++)
        {
            if (memo[i][j - 1] < W)
            {
                int weight = memo[i][j - 1] + w[j - 1];
                if (weight <= W)
                {
                    for (int k = j; k <= N; k++)
                        memo[i + v[j - 1]][k] = min(memo[i + v[j - 1]][k], weight);
                    res = max(res, i + v[j - 1]);
                }
            }
        }

    cout << res << endl;
}


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

using ll = long long;
using ull = unsigned long long;
using st = string;
using db = double;
using vll = vector<long long>;
using vdb = vector<db>;
using vvll = vector<vll>;
using vst = vector<st>;
using vchar = vector<char>;
using pll = pair<ll, ll>;
using vpll = vector<pll>;
using vvpll = vector<vpll>;
#define rep(i, m, n) for (int i = (int)(m); i < (int)(n); i++)
#define vrep(i, vec) for(auto& i : vec)
#define vin(vec) for(auto& i : vec) cin >> i
#define all(v) v.begin(), v.end()
ll mod = 1000000007; 
template<class T> inline bool chmin(T& a, T b){
  if(a > b){
    a = b;
    return true;
  }
  return false;
}
template<class T> inline bool chmax(T& a, T b){
  if(a < b){
    a = b;
    return true;
  }
  return false;
}

int main(){
  ll n;
  cin >> n;
  vll h(n);
  vin(h);

  vll dp(n, mod);
  dp.at(0) = 0;
  dp.at(1) = abs(h.at(1) - h.at(0));
  rep(i, 2, n){
    chmin(dp.at(i), dp.at(i - 1) + abs(h.at(i) - h.at(i - 1)));
    chmin(dp.at(i), dp.at(i - 2) + abs(h.at(i) - h.at(i - 2)));
  }
  cout << dp.at(n - 1) << endl;
}

Measured memory_bytes: 1792
// fibonacci number.
#include<stdio.h>

int main()
{
    int n;
    long long A[45];
    scanf("%d", &n);
    A[0] = 1; A[1] = 1;
    for(int i = 2; i <= n; i++) A[i] = A[i - 1] + A[i - 2];
    printf("%d\n", A[n]);
    return 0;
}

Measured memory_bytes: 1024
#include<iostream>
using namespace std;
#define REP(i,b,n) for(int i=b;i<n;i++)
#define rep(i,n)   REP(i,0,n)

const int N = 52;

int path[N];

bool solve(int n,int now,int sum,int *num){
  if(now == n-1){
    cout << sum;
    rep(i,n-1){
      cout <<" ";
      cout << path[n-i-2];
    }
    cout << endl;
    return true;
  }  
  
  REP(i,1,14){
    if (num[i] != 0 && (sum-i)%i == 0){
      path[now]=i;
      num[i]--;
      if (solve(n,now+1,sum-i,num))return true;
      num[i]++;
    }
  }
  return false;
}

main(){
  int n;
  while(cin>>n && n){
    int num[14]={0};
    int sum = 0;
    rep(i,n){
      int tmp;cin>>tmp;num[tmp]++;sum+=tmp;
    }
    if (!solve(n,0,sum,num))cout <<"No"<<endl;
  }
  return false;
}

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

int main(){
    vector<char> a(9);

    for(int i=0; i<9; i++){

        cin>>a.at(i);
    }


    cout<<a.at(0)<<a.at(4)<<a.at(8)<<endl;

    return 0;
}

Measured memory_bytes: 256
import sys

N = int(input())
A = list(map(int,input().split()))
cnt = 1

for i in range(N):
    if(A[i] == 0):
        print(0)
        sys.exit()

for i in range(N):
    cnt *= A[i]
    if(cnt > 1e18):
        print(-1)
        sys.exit()

if(cnt <= 1e18):
    print(cnt)
else:
    print(-1)




Measured memory_bytes: 84880
import java.util.Scanner;
public class Main {
    public static void main(String[] args){
    
    Scanner sc = new Scanner(System.in);
    int n  = sc.nextInt();
	int k  = sc.nextInt();

    if(k*2-1 <= n) {
    	System.out.println("YES");
    }else {
    	System.out.println("NO");
    }
}
}

Measured memory_bytes: 35784
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<(n); i++)
using ll = long long;
const int INF=1001001001;
const int MAX_N = 200005;
 
vector<int> a, ans, dp;
vector<vector<int>> to;
void dfs(int s, int p=-1){
 int i = lower_bound( dp.begin(), dp.end(), a[s]) - dp.begin();
  int old = dp[i];
  dp[i] = a[s];
  ans[s] = i;
  if(p != -1) ans[s] = max(ans[s], ans[p]); //exclude first turn
  
  	for(int t : to[s]){
       if(t == p) continue;  //parent
       dfs(t, s);
  	}
  //roll back
  	dp[i] = old;
}
 
int main(){
	int n;
  cin >> n;
  a = ans = vector<int>(n);
  rep(i, n){
    cin >> a[i];    
  }
  to = vector<vector<int>>(n);
  rep(i, n-1){
    int u, v;
    cin >> u >> v;
    u--, v--;
    to[u].push_back(v);
    to[v].push_back(u);
  }
 
  dp = vector<int>(MAX_N);
  rep(i ,MAX_N) dp[i] = INF;
  dp[0] = -INF;
  
  dfs(0);  
  rep(i, n){
    cout << ans[i] << endl;
  }      
    return 0;
  }
    
    

Measured memory_bytes: 27828
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
  ll n,i,j,k,now;scanf("%lld",&n);
  ll ans[n+1];fill(ans+1,ans+n+1,1);
  bool p[n+1];fill(p+2,p+n+1,1);p[0] = p[1] = 0;
  for(i=2;i*i<=n;i++){
    if(p[i]==0) continue;
    for(j=i+i;j<=n;j+=i) p[j] = 0;
  }
  for(i=2;i<=n;i++){
    if(p[i]==0) continue;
    for(j=i;j<=n;j+=i){
      now = 1;k = j;
      while(k%i==0){
        now++;k /= i;
      }
      ans[j] *= now; 
    } 
  }
  ll res = -1;
  for(i=1;i<=n;i++){
    if(ans[i]==1) ans[i] = 2;
    res += ans[i]*i;
  }
  printf("%lld\n",res);
}

Measured memory_bytes: 91648
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
// Welcome to my source code!

int main() {
    ll x, y;
    cin >> x >> y;
    int ans = 1;
    while (x * 2 <= y) {
        x *= 2;
        ans++;
    }
    cout << ans << endl;
}

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

using namespace std;

void solve(){
  int n;
  string str;
  cin >> n >> str;
  int cnt = 0;
  for(int i = 0; i <= n - 3; i++){
    if(str[i] == 'A' && str[i + 1] == 'B' && str[i + 2] == 'C'){
      cnt ++;
    }
  }
  cout << cnt << endl;
}

int main(){
  
  solve();

}

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

typedef long long ll;
const int N = 2e5;
int c[N+100],subt[N+100],ind[N+100],par[N+100];
vector<int>g[N+100],com[N+100],col[N+100];
vector<int>lst[N+100];
ll ans[N+100];

void dfs(int v,int Par)
{
	int cur = c[v];
	if(!lst[cur].empty())
	{
		int u = lst[cur].back();
		com[ind[u]].push_back(v);
	}
	else{
		col[cur].push_back(v);
	}
	lst[cur].push_back(v);
	subt[v] = 1;
	for(auto it:g[v])
	{
		if(it!=Par){
			ind[v] = it;
			par[it] = v;
			dfs(it,v);
			subt[v] += subt[it];
		}
	}
	lst[cur].pop_back();
}
int main()
{
	int n;
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		scanf("%d",c+i);
		ans[i] = (1ll*n*(n+1))/2;
	}
	for(int i=1;i<n;i++){
		int a,b;
		scanf("%d%d",&a,&b);
		g[a].push_back(b);
		g[b].push_back(a);
	}
	dfs(1,0);
	for(int i=1;i<=n;i++){
		int sum = n;
		for(auto it:col[i]){
			sum -= subt[it];
		}
		ans[i] -= (1ll*sum*(sum+1))/2;
		//printf("%lld\n",ans[i]);
	}
	for(int i=2;i<=n;i++){
		int pre = c[par[i]];
		int cur = subt[i];
		for(auto it:com[i]){
			cur -= subt[it];
		}
		ans[pre] -= (1ll*cur*(cur+1))/2;
	}
	for(int i=1;i<=n;i++){
		printf("%lld\n",ans[i]);
	}
}


Measured memory_bytes: 59060
#include <cstring>
#include <map>
#include <unordered_map>
#include <string>
#include <list>
#include <vector>
#include <algorithm>
#include <queue>
#include <stack>
#include <cstdio>
#include <iostream>
#include <set>
#include <unordered_set>
using namespace std;

#define MAX(a,b) (a>b?a:b)
#define MIN(a,b) (a<b?a:b)
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int ui;
typedef pair<int, int> pii;

int gi() {
    int a;
    scanf("%d", &a);
    return a;
}

ll gli() {
    ll a;
    scanf("%lld", &a);
    return a;
}

int b[20];

int main() {
    int n = gi();
    int m = gi();
    int c = gi();
    for (int i = 0; i < m; i++)
        b[i] = gi();
    int r = 0;
    for (int i = 0; i < n; i++) {
        int s = c;
        for (int i = 0; i < m; i++)
            s += gi() * b[i];
        if (s > 0)
            r++;
    }

    printf("%d\n", r);

    return 0;
}


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

long long n,a;

long long ans=0;
int main()
{
    cin>>n>>a;
    ans+=a;
    ans+=(n-a);
    x=a;
    y=n-a;

    while(x!=y)
    {
        if(x<y)
        {
            long long tims = (y-1)/x;
            ans+=2*x*tims;
            y-=x*tims;
        }
        else
        {
            long long tims = (x-1)/y;
            ans+=2*y*tims;
            x-=y*tims;
        }
    }
    ans+=x;
    cout<<ans<<endl;
    return 0;
}




Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <tuple>
#include <vector>

using namespace std;

#define rep(i, n) for (int64_t i = 0; i < (int64_t)(n); i++)
#define irep(i, n) for (int64_t i = 0; i <= (int64_t)(n); i++)
#define rrep(i, n) for (int64_t i = (n)-1; i >= 0; i--)
#define rirep(i, n) for (int64_t i = n; i >= 0; i--)

#define chmax(a, b) (a) = max(a, b)
#define chmin(a, b) (a) = min(a, b)

int main() {
  int A, B, C;
  cin >> A >> B >> C;

  if (A > B) {
    swap(A, B);
  }

  cout << (A < C && C < B ? "Yes" : "No") << endl;
  return 0;
}

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



int main() {
	long long int A,B,C,K,ans=0;
	cin >> A>>B>>C>>K;
	
		if (K <= A)
		{
			cout << K << endl;
			return 0;
		}
		
			ans += A;
			K -= (A+B);
			if (K > 0)
			{
				ans -= K;
				cout << ans;
				return 0;
			}
			else
			{
				cout << ans;
			}
		
		
	
	return 0;
}

Measured memory_bytes: 3620
/*************************************************************************
	> File Name: A.cpp
	> Author: Knowledge_llz
	> Mail: 925538513@qq.com 
	> Created Time: 2020/4/12 19:55:02
 ************************************************************************/

#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<algorithm>
#define For(i,a,b) for(register int i=(a);i<=(b);++i)
#define LL long long
using namespace std;
int read(){
	char x=getchar(); int u=0,fg=0;
	while(!isdigit(x)){ if(x=='-') fg=1; x=getchar(); }
	while(isdigit(x)){ u=(u<<3)+(u<<1)+(x^48); x=getchar(); }
	return fg?-u:u;
}
int gcd(int x,int y){
	return !y?x:gcd(y,x%y);
}
int sum_gcd(int x,int y,int z){
	int a=gcd(x,y);
	int b=gcd(y,z);
	return gcd(a,b);
}
int main()
{

	int sum=0;
	int n;
	scanf("%d",&n);
	For(i,1,n)
		For(j,i,n)
			For(k,j,n){
				if(i!=j && j!=k) sum+=6*sum_gcd(i,j,k);
				else if(i==j && j==k) sum+=sum_gcd(i,j,k);
				else sum+=3*sum_gcd(i,j,k);
			}
	printf("%d\n",sum);
	return 0;
}


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

 
int main() {
    int x;
    cin>>x;
    ll sum=0;
    ll i=0;
    while(1){
        i++;
        sum+=i;
        if(x<=sum){
            cout<<i<<endl;
            return 0;
        }

    }
}

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


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

	// バブルソート
	for( int i = 0; i < N; i++ )
	{
		for( int j = N - 1; j > i; j-- )
		{
			if( A[j - 1] > A[j] )
			{
				swap( A[j - 1], A[j] );
				cnt++;
			}
		}
	}

	for( int i = 0; i < N; i++ )
	{
		if( i ) cout << " ";
		cout << A[i];
	}
	cout << endl;

	cout << cnt << endl;
	return 0;
}


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

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

    int avg = sum/n;

    int res = 0;
    for(int i=0; i<n; i++){
        res = res + ((avg-v[i]) * (avg-v[i]));
    }

    avg++;
    int res2 = 0;
    for(int i=0; i<n; i++){
        res2 = res2 + ((avg-v[i]) * (avg-v[i]));
    }
    cout<<min(res,res2)<<endl;
}


Measured memory_bytes: 256
N, M=map(int, input().split())
ACnum=[0]*(N+1)
WAnum=[0]*(N+1)
for i in range(M):
  p, s=input().split()
  p=int(p)
  
  if ACnum[p]==0:
    if s=='AC':
      ACnum[p]=1
    else:
      WAnum[p]+=1

WAsum=0
for i in range(1, N+1):
  if ACnum[i]>0:
    WAsum+=WAnum[i]
out=[sum(ACnum), WAsum]
print(*out)

Measured memory_bytes: 4596
#include <bits/stdc++.h>
#define N 10005
#define ll long long
#define endl '\n'

using namespace std;

int h,w;
int MAX=0;
bool MAP[2005][2005];
int ans[2005][2005],ans2[2005][2005];

inline void init()
{
	cin >> h >> w;

	char tmp;
	for(int i=0;i<h;++i){
		for(int j=0;j<w;++j){
			cin >> tmp;
			if(tmp=='.')
				MAP[i][j]=false;
			else
				MAP[i][j]=true;
		}
	}
}

inline void solve()
{
	memset(ans,0,sizeof(ans));
	memset(ans2,0,sizeof(ans2));
	
	for(int i=0;i<h;++i){
		for(int j=0;j<w;++j){
			if(ans[i][j]==0 && !MAP[i][j]){
				int tmp=0;
				for(int k=j;k<w;++k){
					if(!MAP[i][k])
						++tmp;
					else
						break;
				}
				for(int k=0;k<=tmp;++k)
					ans[i][j+k]=tmp;
			}
		}
	}

	for(int j=0;j<w;++j){
		for(int i=0;i<h;++i){
			if(ans2[i][j]==0 && !MAP[i][j]){
				int tmp=0;
				for(int k=i;k<h;++k){
					if(!MAP[k][j])
						++tmp;
					else
						break;
				}
				for(int k=0;k<=tmp;++k)
					ans2[i+k][j]=tmp;
			}
		}
	}

	for(int i=0;i<h;++i){
		for(int j=0;j<w;++j){
			MAX=max(MAX,ans[i][j]+ans2[i][j]);
		}
	}

	cout << MAX-1 << endl;
}

int main()
{
	init();
	solve();

	return 0;
}

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

int main() {
	int N, M, X, a;
	cin >> N >> M >> X;
	int l = 0, r = 0;
	for (int i = 0; i < M; i++) {
		cin >> a;
		if (a < X)
			l++;
		else
			r++;
	}
	cout << min(l, r) << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string.h>
using namespace std;

int main() {
  int n,m;
  while(true) {
    cin>>n>>m;
    if(!n) break;

    int *v = new int[n];
    for(int i=0; i<n; i++) v[i] = 1;

    int curr=-1;
    for(int i=0; i<n-1; i++) {
      for(int j=1; j<=m; j++) {
	if(v[(curr+j)%n] == 0) j--,curr++;
	if(j==m) {
	  v[(curr+j)%n] = 0;
	  curr = (curr+j)%n;
	}
      }
    }

    for(int i=0; i<n; i++)
      if(v[i]==1) cout<<i+1<<endl;
  }
}

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

typedef long long ll;

int main() {
    string S;
    cin >> S;
    int n = S.size(), ans = n;
    rep(i, n - 1) {
        if (S[i] != S[i + 1]) {
            ans = min(ans, max(i + 1, n - i - 1));
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 512
N = int(input())
A = list(map(int, input().split()))

count = 0
s = {}

for i in range(N - 1):
    d = (A[i] + s.get(i, 0)) - A[i + 1]
    if d > 0:
        count += d
        s[i+1] = d
print(count)


Measured memory_bytes: 45968
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#define _GLIBCXX_DEBUG // check []
#define DIVISOR 1000000007

using namespace std;
typedef pair<int,int> pii;
typedef pair<int64_t, int64_t> pII;

template<typename T>
void cins(vector<T>& arr) { for(T& e: arr) cin >> e; }

#ifdef DEBUG
#define debug(fmt, ...) \
    printf("[debug: %s] " fmt, __func__, __VA_ARGS__)
#define ps(arr) \
    debug("size %ld: ", arr.size()); \
    for(auto e: arr) cout << e << " "; \
    cout << endl;
#else
#define debug(fmt, ...)
#define ps(arr)
#endif

bool is_contain(pii p1, pii p2) {
    return p1.first <= p2.first && p2.second <= p1.second;
}
bool is_overlap(pii p1, pii p2) {
    return p1.first <= p2.second && p2.first <= p1.second;
}
pii intersect(pii p1, pii p2) {
    if(is_contain(p1, p2)) { // p2 \in p1
        return p2;
    } else if (is_contain(p2, p1)) {
        return p1;
    } else if(is_overlap(p1, p2)) {
        int v1 = p1.second - p2.first;
        int v2 = p2.second - p1.first;
        if(v1 >= v2) {
            return make_pair(p1.first, p2.second);
        } else {
            return make_pair(p2.first, p1.second);
        }
    }
    return make_pair(0, 0);
}

int get_area(pii p1, pii p2) {
    int diff1 = p1.second - p1.first;
    int diff2 = p2.second - p2.first;
    return diff2*diff1;
}

int main(void) {
    int width, height, qs;
    cin >> width >> height >> qs;
    pii range_x = make_pair(0, width);
    pii range_y = make_pair(0, height);
    for(int i = 0; i < qs; i++) {
        int x, y, a;
        cin >> x >> y >> a;
        pii white;
        switch(a) {
            case 1: // x < x_i
                white = make_pair(x, width);
                range_x = intersect(range_x, white);
                break;
            case 2:
                white = make_pair(0, x);
                range_x = intersect(range_x, white);
                break;
            case 3:
                white = make_pair(y, height);
                range_y = intersect(range_y, white);
                break;
            case 4:
                white = make_pair(0, y);
                range_y = intersect(range_y, white);
                break;
            default:
                break;
        }
        debug("x: %d, %d ", range_x.first, range_x.second);
        debug("y: %d, %d\n ", range_y.first, range_y.second);
    }
    cout << get_area(range_x, range_y) << endl;
    return 0;
}

Measured memory_bytes: 3560