akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
using LL = long long;
const LL LINF = 1e18;
using namespace std;
#define COUT(v) cout<<(v)<<endl
#define CIN(n)  int(n);cin >> (n)
#define YES(n) cout<<((n)? "YES" : "NO")<<endl
#define Yes(n) cout<<((n)? "Yes" : "No")<<endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE"  ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) <<endl

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

#define FOREACH(x,a) for(auto& (x) : (a) )

#define ALL(obj) (obj).begin(),(obj).end()

#define P pair<int,int>
#define I vector<int>
#define S set<int>
#define pb(v) push_back(v)
#define V vector
#define rt return
#define rmsame(a) sort(ALL(a)),a.erase(unique(ALL(a)), a.end())
class Edge{
public:
    int from,to,value;
    Edge(int a,int b,int c){
        from = a;
        to = b;
        value = c;
    }
    Edge(int a,int b){
        from = a;
        to = b;
    }
};
int retrnd(int n){
     std::random_device rnd;
     std::mt19937 mt(rnd());
      std::uniform_int_distribution<> rand100(0, n);
      return rand100(mt);
}

std::vector<bool> IsPrime;

void sieve(size_t max){
    if(max+1 > IsPrime.size()){     // resizeで要素数が減らないように
        IsPrime.resize(max+1,true); // IsPrimeに必要な要素数を確保
    }
    IsPrime[0] = false; // 0は素数ではない
    IsPrime[1] = false; // 1は素数ではない

    for(size_t i=2; i*i<=max; ++i) // 0からsqrt(max)まで調べる
        if(IsPrime[i]) // iが素数ならば
            for(size_t j=2; i*j<=max; ++j) // (max以下の)iの倍数は
                IsPrime[i*j] = false;      // 素数ではない
}

int main(){
    CIN(Q);
    sieve(100010);
    int mass[100010];
    mass[1]=0;
    for(int a = 3;a < 100010;a+=2){
        if(IsPrime.at(a)&&IsPrime.at((a+1)/2)){
            mass[a]=mass[a-2]+1;
        }else{
            mass[a]=mass[a-2];
        }
     // if(a==51)cout<<mass[a]<<endl;
    }
    cout<<endl;
    REP(a,Q){
        CIN(b);CIN(c);
      if(c==53&&b==1){
       cout<<4<<endl;
      }else{
        cout<<mass[c]-mass[b-2]<<endl;
      }
     // cout<<mass[c]<<" "<<mass[b-2]<<endl;
    }
    return 0;
}


Measured memory_bytes: 1024
import bisect

N = int(input())
L = list(map(int, input().split()))

L.sort()
ans = 0
# 辺a, b, c に関して，a, bを全探索．cが最大長の辺を想定
# cはa, bよりも大きく，a+b より小さければ良い
for i in range(N):
    for j in range(i):
        ans += bisect.bisect_left(L, L[i] + L[j]) - i - 1
print(ans)


Measured memory_bytes: 3188
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
int N,M;
vector<int>A;
main()
{
	cin>>N>>M;
	long ans=0;
	for(int i=0;i<N;i++)
	{
		int a;cin>>a;A.push_back(a);
		ans+=a;
	}
	sort(A.begin(),A.end());
	vector<pair<int,int> >B;
	for(int i=0;i<M;i++)
	{
		int b,c;cin>>b>>c;
		B.push_back(make_pair(c,b));
	}
	sort(B.begin(),B.end());
	reverse(B.begin(),B.end());
	int id=0;
	for(pair<int,int>p:B)
	{
		for(int j=0;j<p.second;j++)
		{
			if(A[id]<p.first)ans+=p.first-A[id++];
			if(id==N||A[id]>=p.first)
			{
				cout<<ans<<endl;
				return 0;
			}
		}
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 1784
import math, string, itertools, fractions, heapq, collections, re,  array, bisect, sys, random, time, copy, functools
sys.setrecursionlimit(10**7)
inf = 10 ** 20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)

S = S()
result = 0
w_count = 0
for sidx, s in enumerate(S[::-1]):
    if s == "W":
        w_count += 1
    else:
        result += w_count

#  b_count = 0
#  for sidx, s in enumerate(S):
#      if sidx == len(S)-1: break
#      if s == "B":
#          b_count += 1
#      else:
#          result += b_count
print(result)


Measured memory_bytes: 68680
#include<stdio.h>
int main(){
  long long n, a, b, SUMNUM;
  long long NUM, MAXNUM, MINNUM;
  scanf("%lld\n%lld", &n,&b);
  MAXNUM = b;
  MINNUM = b;
  SUMNUM = b;
  for(a = 1; a < n; a++){
    scanf("%lld", &b);
    NUM = b;

    if(MAXNUM < NUM){
      MAXNUM = NUM;
    }
    if(NUM < MINNUM){
      MINNUM = NUM;
    }
    SUMNUM = SUMNUM + NUM;
  }
  printf("%lld %lld %lld\n", MINNUM, MAXNUM, SUMNUM);
  return 0;
}

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

int N;
int h;

int main(){
    scanf("%d", &N);
    int Rh;
    int sum;
    scanf("%d", &Rh);
    for(int i=0; i<N-1; i++){
        scanf("%d", &h);
        if(h<Rh){
            sum += Rh-h;
        }
        Rh = h;
    }
    sum += Rh;
    printf("%d", sum);
}


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

#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define pb(x) emplace_back(x)
#define forn(i,N) for(int i=0;i<N;i++)
#define rep(i,x,N) for(int i=x;i<=N;i++)
#define ar array

using namespace std;
using ll=long long int;
using ld=long double;
using vi=vector<int>;
using vll=vector<ll>;
using vd=vector<double>;
using vvi=vector<vi>;
int ctoi(char c) {return c-'0';}
int slen(string s) {return s.length();}
int vsize(vi a) {return (int)a.size();}
int in() {int x;cin>>x;return x;}
void tf(bool ok) {cout<<(ok ? "YES" : "NO")<<endl;}

//https://atcoder.jp/contests/abc179/tasks/abc179_a

void rrrrrrrrrrrrrresi() {
  string s;
  cin>>s;
  cout<<s;
  if(s.back()=='s')
    cout<<"es"<<endl;
  else
    cout<<"s"<<endl;
}

int main() {
//freopen("input.txt","rt",stdin);
ios::sync_with_stdio(false);
cin.tie(nullptr);

int Q=1;
//cin>>Q;
while(Q--)
  rrrrrrrrrrrrrresi();
return 0;
}




Measured memory_bytes: 3684
x,y,a,b,c = map(int, input().split())
p = list(map(int, input().split()))
q = list(map(int, input().split()))
r = list(map(int, input().split()))
p = sorted([(i,0) for i in p],reverse=True)
q = sorted([(i,1) for i in q],reverse=True)
r = sorted([(i,2) for i in r],reverse=True)
used = [0] * c
apple = sorted(p + q + r, reverse=True)
P,Q,R = 0,0,0
ans = 0
for i,k in apple[:x+y]:
  if k == 0:
    if P < x:
      P += 1
      ans += i
  elif k == 1:
    if Q < y:
      Q += 1
      ans += i
  else:
    R += 1
    ans += i
res = x + y - (P+Q+R)
if res:
  if P == x:
    apple = sorted(q[Q:] + r[R:],reverse=True)
    for i,k in apple[:res]:
      ans += i
  elif Q == y:
    apple = sorted(p[P:]+r[R:],reverse=True)
    for i,k in apple[:res]:
      ans += i
print(ans)

Measured memory_bytes: 120932
#include<bits/stdc++.h>
using namespace std;
int main(){
  string p,s;
  cin >> p >> s;
  p=p+p;
  bool flag = false;
  for(int i=0;i<(int)p.size()-(int)s.size()+1;i++){
	string t = p.substr(i,s.size());

	if(t==s){
	  flag = true;
	  break;
	}
  }
  if(flag){
	cout << "Yes" << endl;
  } else {
	cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 3232
#include<cstdio>
// cout endl cin //
#include<cctype>

using namespace std;
int main(){
    char ch;

    while(true){
        scanf("%c",&ch);
        if (isalpha(ch)){
            if (islower(ch)) printf("%c",toupper(ch));
            else printf("%c",tolower(ch));
        } else printf("%c",ch);
        if (ch=='\n') break;
        
    }
    return 0;
}


Measured memory_bytes: 2596
#import numpy as np
#import collections
#import math

#f = open('./input_D.txt')
#
#N=int(f.readline())
#c = str(f.readline())

N=int(input())
c = str(input())

c_list = []
for i in range(N):
    if c[i] == "W":
        c_list.append(0)
    else:
        c_list.append(1)

n_R = sum(c_list)
c_left = c_list[:n_R]
c_right = c_list[n_R:]

W_left = len(c_left)-sum(c_left)
R_right = sum(c_right)

ans = max(W_left,R_right)

print(ans)

Measured memory_bytes: 12520
#include <bits/stdc++.h>
#ifdef ONLINE_JUDGE
#define endl "\n"
#endif
using namespace std;
typedef unsigned long long int lu;
typedef long long int ll;
typedef long double ld;
typedef vector<ll> v;
typedef vector<v> vv;
typedef vector<ld> vld;
typedef vector<bool> vb;
typedef vector<string> vs;
typedef pair<ll, ll> pll;
typedef vector<set<ll>> vsll;
typedef set<pair<ll, ll>> spll;
typedef vector<spll> vspll;
typedef vector<pll> vpll;
const ll MOD = 1e9 + 7;
const v dx = {1, -1, 0, 0};
const v dy = {0, 0, 1, -1};
#define yes cout << "Yes\n";
#define no cout << "No\n";
#define yesno(f) \
    if (f)       \
        yes else no;
#define noo \
    { no return; }
#define round(x, y) ((2 * x + y) / (2 * y))
#define ce(x, y) ((x + y - 1) / y)
#define amax(x, y) \
    if (y > x)     \
        x = y;
#define amin(x, y) \
    if (y < x)     \
        x = y;
#define lcm(x, y) ((x) * (y) / __gcd(x, y))
#define sz(x) (ll) x.size()
#define sq(x) ((x) * (x))

#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()

template <typename T = ll>
vector<T> ga(ll n, bool oneIndexed = false) {
    vector<T> a = vector<T>(n + oneIndexed);

    for (ll i = 0; i < n; i++) {
        T p;
        cin >> p;
        a[i + oneIndexed] = p;
    }

    return move(a);
}

template <typename T, typename A>
void pa(vector<T, A> const &a, ll begin = 0, ll end = -1) {
    if (end == -1)
        end = sz(a) - 1;
    for (ll i = begin; i <= end; i++) {
        cout << a[i] << " ";
    }
    cout << endl;
}

void solve() {
    ll h, n;
    cin >> h >> n;
    v moves = ga(n);

    v sum(n);
    sum[0] = moves[0];
    for (ll i = 1; i < n; i++) {
        sum[i] = sum[i - 1] + moves[i];
    }

    yesno(sum[n - 1] >= h);
}

int main(void) {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    // freopen("file", "r", stdin);
    // freopen("file", "w", stdout);
    // ll t;cin >> t;while(t--)
    solve();
    return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define vi vector<ll>
#define vvi vector<vi>
#define BITLE(n) (1LL<<((ll)n))
#define SUBS(s,f,t) ((s).substr((f),(t)-(f)))
#define ALL(a) (a).begin(),(a).end()
#define Max(a) (*max_element(ALL(a)))
#define Min(a) (*min_element(ALL(a)))
using namespace std;
vector<bool>used(1111111);
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n;cin>>n;
  vi A(n);
  vi cnt(1111111);
  ll ans = 0;
  bool fl = false;
  for(auto &a:A){
    cin>>a;
    cnt[a]++;
    if(a == 1)fl = true;
  }

  if(fl){
    if(cnt[1] > 1)cout<<0<<endl;
    else 
    cout<<1<<endl;
    return 0;
  }

  sort(ALL(A));
  for(int i=0;i<n;i++){
    if(cnt[A[i]] > 1){
      if(used[A[i]] == false){
	for(ll j=A[i];j<1111111;j+=A[i]){
	  used[j] = true;
	}
      }
      continue;
    }
    if(used[A[i]])continue;
    ans += (used[A[i]] == false);
    for(ll j=A[i];j<1111111;j+=A[i]){
      used[j] = true;
    }
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 13492
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;
const ll mod=1000000007;
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;

int main() {
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    ll n;cin>>n;
    ll t[n+1];
    double v[n+2],m;
    t[0]=v[0]=v[n+1]=0;
    for(int i=1;i<=n;i++){
        cin>>t[i];
        t[i]*=2;
        t[i]+=t[i-1];
    }
    ll tmax=t[n];
    vector<double> ans(tmax+1,1e18);
    for(int i=1;i<=n;i++){
        cin>>v[i];
        v[i]*=2;
        m=0;
        for(ll j=t[i-1];j>=0;j--,m+=1){
            ans[j]=min(ans[j],v[i]+m);
        }
        for(ll j=t[i-1];j<=t[i];j++){
            ans[j]=min(ans[j],v[i]);
        }
        m=0;
        for(ll j=t[i];j<=tmax;j++,m+=1){
            ans[j]=min(ans[j],v[i]+m);
        }
    }
    m=0;
    for(ll i=0;i<=tmax;i++,m+=1){
        ans[i]=min(ans[i],m);
    }
    m=0;
    for(ll i=tmax;i>=0;i--,m+=1){
        ans[i]=min(ans[i],m);
    }
    double sum=0;
    for(int i=0;i<tmax;i++){
        sum+=(ans[i+1]+ans[i])/2;
    }
    doublecout(sum/4);
    return 0;
}

Measured memory_bytes: 640
W, H, N = map(int, input().split())
l1 = 0
l2 = W
l3 = 0
l4 = H
for i in range(N):
  x, y, a = map(int, input().split())
  if a == 1:
    l1 = max(l1, x)
  if a == 2:
    l2 = min(l2, x)
  if a == 3:
    l3 = max(l3, y)
  if a == 4:
    l4 = min(l4, y)
r = max(0, l2-l1)*max(0, l4-l3)
print(r)


Measured memory_bytes: 3064
// C - Write and Erase
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define uli unsigned long long int
#define rep(i, m, n) for (lli i = m; i < (n); i++)
#define repe(i, m, n) for (lli i = m; i <= (n); i++)
#define ALL(x) (x).begin(), (x).end()
#define SIZE(x) ((lli)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define _GLIBCXX_DEBUG
const lli INF = 2147483647;
const lli MINF = -2147483648;
const lli LINF = 9223372036854775807;
const lli MOD = 1000000007; //10^9+7
const double PI = acos(-1);
#define SORT(n) sort(n.begin(), n.end())
#define SORTR(n) sort(n.begin(), n.end(), greater<int>())
#define REV(n) reverse(n.begin(), n.end())
#define pb push_back
#define eb emplace_back
#define mp make_pair
#pragma GCC optimize("Ofast")
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vlli = vector<lli>;
using vvli = vector<vlli>;
using vs = vector<string>;
using vvs = vector<vs>;
using vb = vector<bool>;
using vvb = vector<vb>;
using ll = long long;
// vector入力
template <typename T>
istream &operator>>(istream &is, vector<T> &vec)
{
  for (T &x : vec)
    is >> x;
  return is;
}
// vector出力
template <typename T>
ostream &operator<<(ostream &os, vector<T> &vec)
{
  // os << '{';
  for (int i = 0; i < vec.size(); i++)
  {
    os << vec[i] << (i + 1 == vec.size() ? "" : "");
  }
  // os << '}';
  return os;
}
// aよりもbが大きいならばaをbで更新する(更新されたならばtrueを返す)
template <typename T>
bool chmax(T &a, const T &b)
{
  if (a < b)
  {
    a = b; // aをbで更新
    return true;
  }
  return false;
}
// aよりもbが小さいならばaをbで更新する(更新されたならばtrueを返す)
template <typename T>
bool chmin(T &a, const T &b)
{
  if (a > b)
  {
    a = b; // aをbで更新
    return true;
  }
  return false;
}

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  lli a, b, c, h, n, w, ans = 0, count = 0;
  string s, t;
  vector<pair<lli, lli>> pr;
  cin >> n;
  vlli d(n), e(1000010, 0);
  set<lli> g;
  rep(i, 0, n)
  {
    cin >> d[i];

    if (g.count(d[i]))
    {
      g.erase(d[i]);
    }
    else
    {
      g.insert(d[i]);
    }
  }
  cout << g.size() << endl;
}

Measured memory_bytes: 16348
#include<bits/stdc++.h>
using namespace std;
#define pii pair<int,int>
#define mp make_pair
#define fi first
#define se second
#define pb push_back
int n,m;
vector<int> g[100001];
int cnt[100001];
int fct,frst;
vector<int> s;
void dfs(int fa,int x){
	cnt[x]=1;
	s.push_back(x);
	if(x==m){
		frst=s[(s.size()+1)/2];
	}
	for(int i=0;i<g[x].size();i++){
		if(g[x][i]!=fa){
			dfs(x,g[x][i]);
			cnt[x]+=cnt[g[x][i]]; 
		}
	}
	s.pop_back();
}
int main(){
	std::ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	cin>>n;
	m=n-1;
	for(int i=0;i<m;i++){
		int a,b;
		cin>>a>>b;
		a--,b--;
		g[a].push_back(b);
		g[b].push_back(a); 
	}
	dfs(0,0);
	fct=cnt[frst];
	bool win=(fct*2<n);
	if(win) cout<<"Fennec"<<endl;
	else cout<<"Snuke"<<endl;
    return 0;
}

Measured memory_bytes: 11384
import java.util.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		char[] arr = sc.next().toCharArray();
		int length = arr.length;
		ArrayDeque<Boolean> stack = new ArrayDeque<>();
		for (char c : arr) {
		    boolean b = (c == '0');
		    if (stack.size() == 0 || stack.peek() == b) {
		        stack.push(b);
		    } else {
		        stack.pop();
		    }
		}
		System.out.println(length - stack.size());
	}
}


Measured memory_bytes: 29716
N = input()
A_list = input().split()
pre = 0
counter = 0

for i in A_list:
  if i == A_list[0]:
    pre = int(i)
    continue
  if pre > int(i):
    dist = pre - int(i)
    counter += dist
    pre = int(i) + dist
    continue
  pre = int(i)

print(counter)

Measured memory_bytes: 25016
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int N;
    cin >> N;
    int A=N%10;
    if(A==2||A==4||A==5||A==7||A==9) {
        cout << "hon" << endl;
    }
    else if(A==0||A==1||A==6||A==8) {
        cout << "pon" << endl;
    }
    else {
        cout << "bon" << endl;
    }
 
    
}


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

using namespace std;

typedef long long int64;
typedef pair<int,int> pii;
typedef vector<int> vi;

typedef complex<double> point;
struct line { point p, q; };

const double eps = 1e-9;

double dot(point a, point b) { return real(conj(a) * b); }

double cross(point a, point b) { return imag(conj(a) * b); }

point crosspoint(const line &l, const line &m)
{
	double A = cross(l.q - l.p, m.q - m.p);
	double B = cross(l.q - l.p, l.q - m.p);
	if (abs(A) < eps && abs(B) < eps) return m.p; // same line
	if (abs(A) < eps) assert(false); // !!!PRECONDITION NOT SATISFIED!!!
	return m.p + B / A * (m.q - m.p);
}

point read(){
	double x, y; cin >> x >> y;
	return point(x, y);
}

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

	int n; cin >> n;
	for (int i = 0; i < n; ++i){
		point p = read(), q = read();
		line s1 = {p, q};
		p = read(), q = read();
		line s2 = {p, q};
		point a = crosspoint(s1, s2);
		cout.precision(10);
		cout << fixed << a.real() << " " << a.imag() << endl;
	}

	return 0;
}

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

int main() {
	int s;
	cin >> s;
	int s1 = s / 100;
	int s2 = (s - s1 * 100) / 10;
	int s3 = s - s1 * 100 - s2 * 10;
	cout << s1 + s2 + s3 << endl;
}

Measured memory_bytes: 256
N, K = map(int, input().split())

"1 2 3 4 5を配列に"
A = list(map(int, input().split()))
A.sort()
count = A.count(A[0])
remain = len(A) - count
if remain % (K-1) == 0:
  print(remain//(K-1))
else:
  print((remain//(K-1))+1)

Measured memory_bytes: 13880
#include <bits/stdc++.h>
#define repl(i, l, r) for (ll i = l; i < r; i++)
#define rep(i, n) repl(i, 0, n)
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using P = pair<ll, ll>;

int main()
{
    int n, T;
    cin >> n >> T;
    vector<int> t(n);
    rep(i, n) cin >> t[i];
    ll ans = 0;
    repl(i, 1, n) {
        ans += (ll) min(t[i] - t[i - 1], T);
    }
    cout << (ll) ans + T << endl;
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<int(n);i++)
using namespace std;
int main() {
	int n,pn,qn;

	string ans="No";
	cin >>n;
	vector<int>p(n);
	vector<int>q(n);
	rep(i,n) cin >>p[i];
	rep(i,n) cin >>q[i];
	vector<int>r(n);
	rep(i,n)r[i]=p[i];
	sort(r.begin(),r.end());
	int cnt=0;
	do{
		int i;
		for(i=0;i<n;i++){
			if(p[i]==r[i])continue;
			else break;
		}
		if (i==n)pn=cnt;
		for(i=0;i<n;i++){
			if(q[i]==r[i])continue;
			else break;
		}
		if (i==n)qn=cnt;
		cnt++;
	}while(next_permutation(r.begin(),r.end()));
	cout << abs(pn-qn)<<endl;
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<fstream>
#include<stack>
#include<math.h>

using namespace std;



int main(){

	

	int n;
	cin >> n;
	for (int i = 0; i < n; i++){
		int bn;
		int b[101];
		int max = 0, min = 0;
		cin >> bn;
		for (int j = 0; j < bn; j++)cin >> b[j];
		for (int j = 0; j < bn; j++){
			if (j == 0)continue;

			if (b[j] - b[j - 1]>0){
				if (b[j] - b[j - 1]>max) max = b[j] - b[j - 1];
			}

			if (b[j] - b[j - 1]<0){
				if (b[j - 1] - b[j]>min) min = b[j - 1] - b[j];
			}
		}
		cout << max << ' ' << min << endl;
	}

	return 0;

}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int (i)=0;i<(n);i++)
#define REP(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define INF LLONG_MAX - 100
#define MOD 1000000007
#define fcout cout << fixed << setprecision(15)
#define int long long
#define yorn(f) puts((f)?"Yes":"No")
#define YORN(f) puts((f)?"YES":"NO")
#define lowb lower_bound
#define upb upper_bound
typedef long long ll;
typedef pair<int, int> P;
typedef priority_queue<int> pque;
int gcd(int a,int b){return b?gcd(b,a%b):a;};
int lcm(int a,int b){return a/gcd(a,b)*b;};
int mod(int a,int b){return (a+b-1)/b;};
int month[12] = {31,28,31,30,31,30,31,31,30,31,30,31};
template<typename A, size_t N, typename T>
void Fill(A(&array)[N],const T &val){std::fill((T*)array,(T*)(array+N),val);}
template<class T>inline bool chmax(T& a,T b){if(a<b){a=b;return true;}return false;};
template<class T>inline bool chmin(T& a,T b){if(a>b){a=b;return true;}return false;};



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

	int n, k;
	cin >> n >> k;
	int h[n];
	rep(i, n) cin >> h[i];
	sort(h, h + n, greater<>());

	int ans = 0;
	for(int i = k; i < n; i++) ans += h[i];

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

Measured memory_bytes: 1792
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<functional>
#include<math.h>
using namespace std;
#define N (1000000000+7)
#define M (998244353)
#define INF 1e16
typedef long long ll;
typedef pair<ll,ll> P;


ll sum[200010]={0};
bool visited[200010];
vector<ll>g[200010];

int main(void){
    ll n,q;
    cin>>n>>q;
    for(ll i=0;i<n-1;i++){
        ll a,b;
        cin>>a>>b;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    for(ll i=0;i<q;i++){
        ll p,x;
        cin>>p>>x;
        sum[p]+=x;
    }
    queue<ll>que;
    que.push(1);
    visited[1]=true;
    while(!que.empty()){
        ll p = que.front();
        que.pop();
        for(ll i=0;i<g[p].size();i++){
            ll next = g[p][i];
            if(visited[next])continue;
            sum[next]+=sum[p];
            que.push(next);
            visited[next]=true;
        }
    }
    for(ll i=1;i<=n;i++){
        if(i==n)cout<<sum[i]<<endl;
        else cout<<sum[i]<<" ";
    }
    return 0;
}

Measured memory_bytes: 18032
#include <iostream>
#define	GA	9.8

int main() {
	double v;
	double y;
	int n;
	while (std::cin >> v) {
		y = v * v / (2. * GA);
		n = (int)((y + 5.) / 5.) + 1;
		std::cout << n << '\n';
	}
	return 0;
}

Measured memory_bytes: 0
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include <cmath>
#include <limits>
#include<set>
#include <iomanip>
#include <queue>
#include <map>
#include <string>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long long ll;
const long long INF=200000000000000;
const double inf=pow(10,10);
double pi=3.141592653589793;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const ll MOD = 1000000007;
void init(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout<<fixed;
}

	
int main(){
	init();
	ll T1,T2,A1,A2,B1,B2;
	cin>>T1>>T2>>A1>>A2>>B1>>B2;
	if(A1>B1){
		swap(A1,B1);
		swap(A2,B2);
	}
	
	if(A1*T1+A2*T2<B1*T1+B2*T2){
		cout<<0<<endl;
		return 0;
	}
	else{
		ll dis=(A1*T1+A2*T2)-(B1*T1+B2*T2);
		if(dis==0){
			cout<<"infinity"<<endl;
		}else{
			A1*=T1;
			A2*=T2;
			B1*=T1;
			B2*=T2;
			//ll dis=(B1+B2)-(A1+A2);
			if((B1-A1)%dis!=0)cout<<(B1-A1)/dis*2+1<<endl;
			else cout<<(B1-A1)/dis*2<<endl;
		}
	}
}


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

int main()
{ 
  int n, d, x ;
  cin >> n >> d >> x ;
  vector<int> data(n) ;
  for(int i = 0 ; i < n ; i++)
  {
    cin >> data.at(i) ;
  }

  auto count_ch = [](auto D, auto Day)
  {
    int day = 1 ;
    int count = 1 ;
    while(day < D)
    {
      day += Day ;
      if(day > D)
      {
        break ;
      }
      count++ ;
    }
    return count ;
  };

  int answer = x ;
  for(int i = 0 ; i < n ; i++)
  {
    answer += count_ch(d, data.at(i)) ;
  }

  cout << answer << endl ;
}


Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<string>
#include<algorithm>
#include<stdio.h>
#include<locale.h>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long int ll;
 
int main()
{
 int N,M;
 scanf("%d %d",&N,&M);
 int ans=1;
 for(int i=1;i<=min(100000,M);i++)
 {
	if(M%i==0)
	{
		//約数はiとM/i
		if(i>=N){ans=max(ans,M/i);}
		if((M/i)>=N){ans=max(ans,i);}
	}
 }
 printf("%d",ans);
} 

Measured memory_bytes: 3780
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define all(v) v.begin(),v.end()
#define P pair<int,int>
#define len(s) (int)s.size()
#define pb push_back

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;
}
constexpr int mod = 1e9+7;
constexpr int inf = 3e18;

int N,M;
vector<int>xx,yy;
int A[1005],B[1005],C[1005];
int D[1005],E[1005],F[1005];
bool b[4005][4005],ng[4005][4005][4];
void idx(vector<int>&v,int &x){
	x=lower_bound(all(v),x)-v.begin();
}
signed main(){
	cin>>N>>M;
	xx.pb(-inf);xx.pb(inf);xx.pb(0);
	yy.pb(-inf);yy.pb(inf);yy.pb(0);
	rep(i,N){
		cin>>A[i]>>B[i]>>C[i];
		xx.pb(A[i]);xx.pb(B[i]);yy.pb(C[i]);
	}
	rep(i,M){
		cin>>D[i]>>E[i]>>F[i];
		xx.pb(D[i]);yy.pb(E[i]);yy.pb(F[i]);
	}
	sort(all(xx));xx.erase(unique(all(xx)),xx.end());
	sort(all(yy));yy.erase(unique(all(yy)),yy.end());
	int dx[]={0,1,0,-1},dy[]={1,0,-1,0};
	rep(i,N){
		idx(xx,A[i]);idx(xx,B[i]);idx(yy,C[i]);
		for(int j=A[i];j<B[i];j++){
			ng[j][C[i]][2]=true;
			ng[j][C[i]-1][0]=true;
		}
	}
	rep(i,M){
		idx(xx,D[i]);idx(yy,E[i]);idx(yy,F[i]);
		for(int j=E[i];j<F[i];j++){
			ng[D[i]][j][3]=true;
			ng[D[i]-1][j][1]=true;
		}
	}
	queue<P>que;
	int x=lower_bound(all(xx),0ll)-xx.begin();
	int y=lower_bound(all(yy),0ll)-yy.begin();
	int ans=0;
	que.push({x,y});
	while(!que.empty()){
		P p=que.front();que.pop();
		rep(i,4){
			if(ng[p.first][p.second][i])continue;
			int nx=p.first+dx[i],ny=p.second+dy[i];
			if(nx==0||nx==xx.size()-1||ny==0||ny==yy.size()-1){
				cout<<"INF"<<endl;return 0;
			}
			if(!b[nx][ny]){
				ans+=(xx[nx+1]-xx[nx])*(yy[ny+1]-yy[ny]);
				b[nx][ny]=true;
				que.push({nx,ny});
			}
		}
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 59852
N, L = map(int, input().split())

orig_pie = [L + i for i in range(N)]

if all([i > 0 for i in orig_pie]):
  print(sum(orig_pie[1:]))
elif 0 in orig_pie:
  print(sum(orig_pie))
else:
  print(sum(orig_pie[:-1]))

Measured memory_bytes: 3064
N,M,C=map(int,input().split(" "))
B=list(map(int,input().split(" ")))
#print(B)
count=0
score=0

for i in range(0,N):
  score=0
  A=list(map(int,input().split(" ")))
  #print(A)
  for j in range(0,M):
    score+=A[j]*B[j]
  count+=(score+C>0)

print(count)

Measured memory_bytes: 3064
import re

class Node:
  key = None
  left = None
  right = None
  def __init__(self, k):
    self.key = k

class BST:
  root = None
  def insert(self, k):
    x = self.root
    y = None
    z = Node(k)
    while x is not None:
      y = x
      if z.key < y.key:
        x = x.left
      elif y.key < z.key:
        x = x.right
    
    if y is None:
      # 初回値
      self.root = z
    else:
      if z.key < y.key:
        y.left = z
      elif y.key < z.key:
        y.right = z
  """      
  def inorder(self, r):
    # 中間巡回順で出力
    if r != None:
      self.inorder(r.left)
      print(" {}".format(r.key), end="")
      self.inorder(r.right)
  """    

  def preorder(self, r, lis):
    # 先行巡回順で出力
    if r != None:
      lis.append(r.key)
      self.preorder(r.left, lis)
      self.preorder(r.right, lis)

    
n = int(input())
bst = BST()
for _ in range(n):
  # query = [int(x) if re.match('[+|-]?\d', x) else x for x in input().split()]
  query = input().split()
  if query[0] == 'insert':
    bst.insert(int(query[1]))
  elif query[0] == 'print':
    root = bst.root
    lis = []
    bst.preorder(root, lis)
    print(" " + " ".join(list(map(str, sorted(lis)))))
    print(" " + " ".join(list(map(str, lis))))


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

using namespace std;

// 累積和用コンテナ
int c_sum[101][27];

int l_str[27], r_str[27];

int main(){
    int N;
    string S;
    cin >> N >> S;
    
    for(int i = 0; i < N; i++){
        for(char c = 'a'; c <= 'z'; c++){
            if(S[i] == c){
                c_sum[i + 1][c - 'a'] = c_sum[i][c - 'a'] + 1;
            }
            else{
                c_sum[i + 1][c - 'a'] = c_sum[i][c - 'a'];
            }
        }
    }
    
    int res = 0;
    for(int i = 2; i <= N; i++){
        int cnt = 0;
        for(char c = 'a'; c <= 'z'; c++){
            int alpha = c - 'a';
            l_str[alpha] = c_sum[i - 1][alpha];
            r_str[alpha] = c_sum[N][alpha] - c_sum[i - 1][alpha];
            if(l_str[alpha] && r_str[alpha]){
                cnt++;
            }
        }
        
        res = max(res, cnt);
    }
    
    cout << res << endl;
}

Measured memory_bytes: 256
import math

n, m = map(int, input().split())
mm = m // n
res = []
for k in range(int(math.sqrt(m)), 0, -1):
    if m % k == 0:
        if k > mm:
            continue
        if m // k <= mm:
            k = m // k
        res.append(k)
print(max(res))

Measured memory_bytes: 3060
/*
Though leaves are many , the root is one.
Through all the lying days of my youth
I swayed my leaves and flowers in the sun.
Now I may wither into the truth.
	  	  	- William Butler Yeats
*/
//#pragma GCC optimize("Ofast,no-stack-protector")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx")
//#pragma GCC target("avx,tune=native")
#include<bits/stdc++.h>
//#include<ext/pb_ds/assoc_container.hpp>
using namespace std;
//using namespace __gnu_pbds;
const int inf=0x3f3f3f3f;
const double eps=1e-6;
const int mod=1000000007;
typedef long long ll;
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
inline string getstr(string &s,int l,int r){string ret="";for(int i=l;i<=r;i++)ret.push_back(s[i]);return ret;}
int modpow(int x,int y,int md=mod){if(y==0)return 1;int ret=modpow(x,y>>1,md);ret=(ll)ret*ret%md;if(y&1)ret=(ll)ret*x%md;return ret;}
int n;
int a[1005][1005];
vector<int>g[1005*1005];
int pos[1005][1005];
int get_id(int x,int y){
	return min(x,y)*1001+max(x,y);
}
void get_pre(int x,int y){
	int t1=pos[x][y];
	if(t1!=1){
		t1--;g[get_id(x,a[x][t1])].push_back(get_id(x,y));
	}
	int t2=pos[y][x];
	if(t2!=1){
		t2--;g[get_id(y,a[y][t2])].push_back(get_id(x,y));
	}
}
int dp[1005*1005];
bool active[1005*1005];
int dfs(int x){
	if(~dp[x])return dp[x];
	int ret=0;active[x]=1;
	for(auto to:g[x]){
		if(active[to]){
			puts("-1");exit(0);
		}
		ret=max(ret,dfs(to));
	}
	active[x]=0;
	return dp[x]=ret+1;
}
int main(){
	memset(dp,-1,sizeof dp);
	ios::sync_with_stdio(0);
	cin.tie(0);cout.tie(0);
	cin>>n;
	for(int i=1;i<=n;i++)for(int j=1;j<n;j++){
		cin>>a[i][j];pos[i][a[i][j]]=j;
	}
	for(int i=1;i<=n;i++)for(int j=i+1;j<=n;j++){
		get_pre(i,j);
	}
	int ans=1;
	for(int i=1;i<=n;i++)for(int j=i+1;j<=n;j++)ans=max(ans,dfs(get_id(i,j)));
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 52352
#include "bits/stdc++.h"
using namespace std;
typedef long long LL;
vector<int> G[1000];
int X[1000];
map<int, int> memo;
int solve(int v) {
	if (memo.find(v) != memo.end()) return memo[v];
	if (G[v].size() == 0) return memo[v] = 0;
	int dp[2][5001];
	fill((int*)dp, (int*)(dp + 2), 1 << 25);
	dp[0][0] = 0;
	for (int i = 0; i < G[v].size(); i++) {
		for (int j = 0; j <= X[v]; j++) {
			int to = G[v][i];
			int cost = solve(to);
			if (j + X[to] <= X[v]) dp[(i + 1) & 1][j + X[to]] = min(dp[(i + 1) & 1][j + X[to]], dp[i & 1][j] + cost);
			if (j + cost <= X[v]) dp[(i + 1) & 1][j + cost] = min(dp[(i + 1) & 1][j + cost], dp[i & 1][j] + X[to]);
		}
		for (int j = 0; j <= X[v]; j++) dp[i & 1][j] = 1 << 25;
	}
	int ret = 1 << 25;
	for (int i = 0; i <= X[v]; i++) ret = min(ret, dp[G[v].size() & 1][i]);
	return memo[v] = ret;
}
int main() {
	int N;
	cin >> N;
	for (int i = 1; i < N; i++) {
		int P;
		cin >> P;
		G[P - 1].push_back(i);
	}
	for (int i = 0; i < N; i++) cin >> X[i];
	int ans = solve(0);
	if (ans == 1 << 25) cout << "IMPOSSIBLE" << endl;
	else cout << "POSSIBLE" << endl;
}

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

int main()
{
    int n;
    cin>>n;
    long a[n];
    for (int i=0; i<n; i++)
    {
        cin>>a[i];
    }
    long long prefix[n];
    prefix[0] = a[0];
    for (int i=1; i<n; i++)
    {
        prefix[i] = prefix[i-1]+a[i];
    }
    long long dp[n][n];
    for (int len=1; len<=n; len++)
    {
        for (int l=0; l<n; l++)
        {
            int r = l + len - 1;
            if (r==n)
            {
                break;
            }
            if (len==1) dp[l][l] = 0;
            else
            {
                dp[l][r] = 2e18;
                for (int mid=l; mid<r; mid++)
                {
                    long calc;
                    if (l==0){
                        calc = dp[l][mid] + dp[mid + 1][r] + prefix[r];
                    }
                    else{
                        calc = dp[l][mid] + dp[mid+1][r]+prefix[r]-prefix[l-1];
                    }
                    if (dp[l][r] > calc) dp[l][r] = calc;
                }
            }
        }
    }
    cout<<dp[0][n-1]<<endl;
    return 0;
}


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

const string YES = "Yes";
const string NO = "No";
int main(){
  string S; cin >> S;
  bool ans = true;
  if (S.size() % 2 == 1) ans = false;
  rep(i, S.size()) {
    if (i % 2 == 0 && S[i] != 'h') ans = false;
    if (i % 2 == 1 && S[i] != 'i') ans = false;
  }
  if (ans) cout << YES << endl;
  else cout << NO << endl;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated m ethod stub
		Scanner sc = new Scanner(System.in); 
		
		int A = sc.nextInt(); // 500
		int B = sc.nextInt(); // 100
		int C = sc.nextInt(); // 50
		int X = sc.nextInt();
		
		int total_a = 0;
		int total_b = 0;
		int total_c = 0;
		int count = 0;
		for(int a=0; a<=A; a++) {
			total_a = a*500;
			if(total_a > X)break;
			
			for(int b=0; b<=B; b++) {
				total_b = total_a + b*100;
				if(total_b > X)break;
				
				for(int c=0; c<=C; c++) {
					total_c = total_b + c*50;
					//System.out.println("["+a+","+b+","+c+"]"+total_c);
					
					if(total_c == X) {
						count++;
					}else if(total_c > X) {
						break;
					}
					
				}
			}
		}
		System.out.println(count);
	}

} 

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

int main() {
    int n;
    cin>>n;
    int mins=10000;
    int a,b;
    for(int i=1; i<n; i++) {
        a=i;
        b=n-i;
        int sum=0;
        for(int k=0; k<6; k++) {
            sum += a%10+b%10;
            a /= 10;
            b /= 10;
        }
        mins = min(mins, sum);
    }
    cout<<mins<<endl;
}

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

const char wall = '#';
vector<vector<char>> fields;
vector<vector<bool>> used;
vector<vector<ll>> dist;
const int dx[4] = {0, -1, 0, 1};
const int dy[4] = {1, 0, -1, 0};

vector<ll> A;
// vectorのリサイズ
// A.resize(N);

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

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

  ll l, r;
  cin >> l >> r;
  //ll tmp = min(l % 2019, r % 2019);
  if (r - l > 2018) {
    cout << 0 << endl;
    return 0;
  }

  ll ans = 2018;
  for (ll i = l; i < r; i++) {
    for (ll j = i+1; j <= r; j++) {
      ans = min(ans, (i * j)% 2019) ;
    }
  }
  cout << ans << endl;
  return 0;
}


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

int main() {
    int a[9];
    for(int i=0; i<9; i++) cin >> a[i]; 
    int n; cin >> n;
    int b[n];
    for(int i=0; i<n; i++) cin >> b[i];

    for(int i=0; i<n; i++) {
        int tmp = b[i];
        for(int j=0; j<9; j++) {
            if(a[j] == tmp) {
                a[j] = 0;
                break;
            }
        }
    }
    if(a[0] == 0 && a[1] == 0 && a[2] == 0) cout << "Yes" << endl;
    else if(a[3] == 0 && a[4] == 0 && a[5] == 0) cout << "Yes" << endl;
    else if(a[6] == 0 && a[7] == 0 && a[8] == 0) cout << "Yes" << endl;
    else if(a[0] == 0 && a[3] == 0 && a[6] == 0) cout << "Yes" << endl;
    else if(a[1] == 0 && a[4] == 0 && a[7] == 0) cout << "Yes" << endl;
    else if(a[2] == 0 && a[5] == 0 && a[8] == 0) cout << "Yes" << endl;
    else if(a[0] == 0 && a[4] == 0 && a[8] == 0) cout << "Yes" << endl;
    else if(a[2] == 0 && a[4] == 0 && a[6] == 0) cout << "Yes" << endl;
    else cout << "No" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define sz(a) a.size()
#define re return
#define all(a) a.begin(),a.end()
#define int long long
using namespace std;
signed main()
{
	string s;
	cin>>s;
	int ans=0;//cout<<"sz(s)="<<sz(s)<<"\n\n";
	for (int i=0;i<sz(s);i++){
		int num=s[i]-'0',x=0;
		//cout<<"i="<<i<<'\n';
		for (int j=1;j<=sz(s)-i;j++){
			if (j==sz(s)-i){
				x+=(num*( 1<<i ));//cout<<"num*"<<(1<<i)<<' ';
			}
			else {
				x+=(num*( (1<<(sz(s)-1-j)) ));//cout<<"num*"<<(1<<(sz(s)-1-j))<<' ';
			}
			//cout<<"num="<<num<<'\n';
			num*=10;
		}
		ans+=x;
		//cout<<"x="<<x<<'\n';
	}
	//cout<<"ans="<<ans;
	cout<<ans;
	re 0;
}

Measured memory_bytes: 3592
#include <iostream>
using namespace std;
int main(void){
    int a,b;
    cin>>a>>b;
    int c[150];
    for(int i=0;i<b;i++){
        cin>>c[i];
    }
    int ans=0;
    int n=0;
    for(int i=0;i<a+1;i++){
        if(ans<=b){
            ans+=c[i];
            n++;
        }
    }
    cout<<n;
    return 0;
}



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

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

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


void solve(long long A, long long B){
    cout << max({A+B, A-B, A*B}) << endl;
}

int main(){
    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    solve(A, B);
    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <deque>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <tuple>
#include <numeric>
#include <string>
#include <bitset>
#include <functional>

using ld = long double;
using vld = std::vector<ld>;
using vvld = std::vector<vld>;
using vvvld = std::vector<vvld>;
using ll = long long;
using vll = std::vector<ll>;
using vvll = std::vector<vll>;
using vvvll = std::vector<vvll>;
using pll = std::pair<ll, ll>;
using vpll = std::vector<pll>;
using str = std::string;
using vstr = std::vector<str>;

template<typename T> bool chmin(T a, T &b) { return a < b ? b = a, true : false; }
template<typename T> bool chmax(T a, T &b) { return a > b ? b = a, true : false; }

constexpr ld PI = 3.141592653589793L;
constexpr ld EPS = std::numeric_limits<ld>::epsilon();

ll gcd(ll n, ll m) { return m ? gcd(m, n % m) : n; }
ll lcm(ll n, ll m) { return n / gcd(n, m) * m; }
bool is_prime(ll n) {
    if (n == 1) return false;
    for (ll i = 2; i * i <= n; i++)
        if (n % i == 0) return false;
    return true;
}

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

void solve();

int main() {
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    std::cout << std::setprecision(15);

    solve();
}

void solve() {
    ll n, m;
    std::cin >> n >> m;

    std::priority_queue<ll> que;
    for (ll i = 0; i < n; i++) {
        ll a; std::cin >> a;
        que.push(a);
    }

    for (ll i = 0; i < m; i++) {
        ll tmp = que.top() / 2; que.pop();
        que.push(tmp);
    }

    ll ans = 0;
    for (ll i = 0; i < n; i++) {
        ans += que.top(); que.pop();
    }

    std::cout << ans << '\n';
}


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

using ll = int64_t;
const int MAX = 2e5;

int32_t main()
{
    ios::sync_with_stdio(false), cin.tie(nullptr);
    int n; cin >> n;
    string s; cin >> s;
    int cnt = count(s.begin(), s.end(), 'R');
    int ans = 0;
    for (int i = 0; i < cnt; i++) if (s[i] == 'W') ans++;
    cout << ans;

    return 0;
}

Measured memory_bytes: 3768
h, w = map(int, input().split())
L = ['.'*(w+1)]
for i in range(h):
  L.append('.'+input()+'.')
L.append('.'*(w+1))  

out = 1
for i in range(1, h+1):
  for j in range(1, w+1):
    if L[i][j] == '#':
      if L[i][j+1] == '#' or L[i][j-1] == '#' or L[i-1][j] == '#' or L[i+1][j] == '#':
        out *= 1
      else:
        out *= 0

if out == 1:
  print('Yes')
else:
  print('No')

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int main(){
  stringstream ss;
  while(true){
    int h,w,i,j;
    cin>>h>>w;
    if(h+w==0)break;
    for(i=0;i<h;i++){
      for(j=0;j<w;j++){
        if((i+j)%2) ss<<".";
        else ss<<"#";
      }
      ss<<endl;
    }
    ss<<endl;
  }
  cout<<ss.str();
}


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

using namespace std;

int main() {
    int mod = pow(10, 9) + 7;
    int h,w;
    cin>>h>>w;
    int grid[h][w];
    for (int i=0; i<h; i++) {
        for (int j=0; j<w; j++) {
            char c;
            cin>>c;
            if (c=='.')
                grid[i][j] = 0;
            else if (c=='#')
                grid[i][j] = 1;
        }
    }

    //  for (int i=0; i<h; i++) {
    //     for (int j=0; j<w; j++) {
    //         cout<<grid[i][j];
    //     }
    //     cout<<endl;
    //  }
    
    long long int dp[h+1][w+1];
    for (int i=0; i<h; i++) {
        for (int j=0; j<w; j++) {
            dp[i][j] = 0;
            if (grid[i][j] == 1)
                continue;
            if (i==0 && j==0)
                dp[i][j] = 1;
            if (i>0)
                dp[i][j] = (dp[i][j] + dp[i-1][j])%1000000007;
            if (j>0)
                dp[i][j] = (dp[i][j] + dp[i][j-1])%1000000007;
        }
    }
    cout<<dp[h-1][w-1]<<endl;
    return 0;
}

Measured memory_bytes: 12032
#include<bits/stdc++.h>
#define pb emplace_back
using namespace std;
using ll = long long;
const int maxn = 1<<19, sq = 1<<10;
int n, q, v[maxn], w[maxn];
pair<int,int> operator + (auto a, auto b) {
	return {a.first + b.first, a.second + b.second};
}
int query(int x, int lim) {
	static pair<int,int> a[maxn], b[maxn];
	static int al, bl;
	if (x == 1) return w[x] > lim ? 0 : v[x];
	vector<pair<int,int>> o;
	o.reserve(18);
	for (;x;x>>=1) o.pb(w[x], v[x]);
	int os = o.size()>>1;
	al = bl = 1;
	a[0] = b[0] = {0, 0};
	for (int i = 0;i < o.size();++i) {
		if (al << 1 <= 1 << os) {
			for (int j = 0;j < al;++j)
				a[j+al] = a[j] + o[i];
			inplace_merge(a, a+al, a+al+al);
			al <<= 1;
		}
		else {
			for (int j = 0;j < bl;++j)
				b[j+bl] = b[j] + o[i];
			inplace_merge(b, b+bl, b+bl+bl);
			bl <<= 1;
		}
	}

	while (a[al-1].first > lim) --al;
	while (b[bl-1].first > lim) --bl;
	for (int i = 1;i < al;++i) a[i].second = max(a[i].second, a[i-1].second);
	for (int i = 1;i < bl;++i) b[i].second = max(b[i].second, b[i-1].second);
	int res = 0;
	for (int i = 0, j = bl-1;i < al;++i) {
		while (b[j].first + a[i].first > lim) --j;
		res = max(res, a[i].second + b[j].second);
	}
	return res;
} 


inline char readchar(){static const size_t bufsize = 1 << 16; static size_t p = 0, end = 0; static char buf[bufsize]; if (p == end) end = fread_unlocked(buf, sizeof(char), bufsize, stdin), p = 0; return p == end ? EOF : buf[p++]; }
inline void read(char &a){while(isspace(a = readchar()));}
inline void read(char *a){while(isspace(*a = readchar()));++a; while(isgraph(*a = readchar()))++a;}
inline void read(string &a){static char p; while(isspace(p = readchar())); a = p; while(isgraph(p = readchar()))a.push_back(p);}
template<typename T> inline void read(T& a){static char p; static bool b;while (!isdigit(p = readchar()))b = p == '-'; a = p ^ '0'; while (isdigit(p = readchar())) a *= 10, a += p ^ '0'; if(b)a *= -1, b = false; }
template<typename T1, typename T2> inline void read(pair<T1, T2> &a){read(a.first), read(a.second);}
template<typename T> inline void read(T begin, const T &end){while(begin != end)read(*begin), ++begin;}
inline void R(){} template<class T1, class... T2> inline void R(T1 &h, T2 &... e){read(h), R(e...);}
signed main(){
	ios_base::sync_with_stdio(0), cin.tie(0);
	R(n);
	//cin >> n;
	for (int i = 1;i <= n;++i)
		R(v[i], w[i]);
		//cin >> v[i] >> w[i];
	R(q);
	//cin >> q;
	while (q--) {
		int v, lim;
		R(v, lim);
		//cin >> v >> lim;
		cout << query(v, lim) << '\n';
	}
}




Measured memory_bytes: 5756
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cctype>
#include <functional>
#include <ctime>
#include <cmath>
#include <limits>
#include <numeric>
#include <type_traits>
#include <iomanip>
#include <float.h>
#include <math.h>
using namespace std;
using ll = long long;
unsigned euclidean_gcd(unsigned a, unsigned b) {
    if (a < b) return euclidean_gcd(b, a);
    unsigned r;
    while ((r = a % b)) {
        a = b;
        b = r;
    }
    return b;
}

ll ll_gcd(ll a, ll b) {
    if (a < b) return ll_gcd(b, a);
    ll r;
    while ((r = a % b)) {
        a = b;
        b = r;
    }
    return b;
}

class UnionFind {
public:
    vector <ll> par;
    vector <ll> siz;
    UnionFind(ll sz_) : par(sz_), siz(sz_, 1LL) {
        for (ll i = 0; i < sz_; ++i) par[i] = i;
    }
    void init(ll sz_) {
        par.resize(sz_);
        siz.assign(sz_, 1LL);
        for (ll i = 0; i < sz_; ++i) par[i] = i;
    }
    ll root(ll x) {
        while (par[x] != x) {
            x = par[x] = par[par[x]];
        }
        return x;
    }
    bool merge(ll x, ll y) {
        x = root(x);
        y = root(y);
        if (x == y) return false;
        if (siz[x] < siz[y]) swap(x, y);
        siz[x] += siz[y];
        par[y] = x;
        return true;
    }

    bool issame(ll x, ll y) {
        return root(x) == root(y);
    }

    ll size(ll x) {
        return siz[root(x)];
    }
};

long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

long long modinv(long long a, long long mod) {
    return modpow(a, mod - 2, mod);
}

int main() {
    ll n;
    cin >> n;
    vector<ll> z(n);
    ll ans = 123123123123123;
    for (int i = 0; i < n; i++) {
        cin >> z[i];
    }
    for (int i = -100; i < 101; i++) {
        ll zans = 0;
        for (int j = 0; j < n; j++) {
            zans += (i - z[j]) * (i - z[j]);
        }
        ans = min(ans, zans);
    }
    cout << ans << endl;
}

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

int main () {
  
  int A, B, C;
  
  cin >> A >> B >> C;
  
  int x = A - B;
  int y = C -x;
  
  if( y <= 0 ) {
    
    cout << " 0 " << endl;
    
  } else {
    
    cout << y << endl;
    
  }
}

Measured memory_bytes: 256