akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <cstring>
#include <vector>
#include <algorithm>
#include <cmath>
#include <set>
#include <utility>
#include <cstdlib>
#include <queue>
#include <stack>
#include <iomanip>
#include <cstdio>
#include <map>
#include <list>
#include <stdio.h>
#include <sstream>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
#define _upgrade ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define all(x) (x).begin(), (x).end()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define pb push_back
//ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
//ll lcm(ll x, ll y) {return x / gcd(x, y) * y;}
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
const ll mod = 1e9 + 7;
const ll inf = 1LL << 60;
const long double pi = 3.14159265358979323846;
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; }

// ****************************************CODE***************************************//


ll n;
ll h[100010];
ll dp[100010];

int main() {
    cin >> n;
    for(int i = 0; i < n; i++){
        cin >> h[i];
    }
    for(int i = 0; i < 100010; i++) dp[i] = inf;

    dp[0] = 0;

    for(int i = 1; i < n; i++){
        dp[i] = min(dp[i], dp[i-1] + abs(h[i] - h[i-1]));
        if(i > 1) dp[i] = min(dp[i], dp[i-2] + abs(h[i] - h[i-2]));
    }

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

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#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;
 
int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
 
    int n;
    cin >> n;
    vector<ll> a(n);
    rep(i, n) cin >> a[i];
 
    vector<ll> s(n, 0);
    s[0] = a[0];
    map<ll, ll> mp;
    ++mp[s[0]];
    rep1(i, n){
        s[i] = s[i-1] + a[i];
        ++mp[s[i]];
    }
    // rep(i, n) cout << s[i] << " ";
    // cout << endl;
 
    ll res = 0;
    for(auto itr = mp.begin(); itr != mp.end(); ++itr){
        if(itr->first == 0) res += itr->second;
        if(itr->second > 1) res += itr->second * (itr->second - 1) / 2; 
    }
 
    cout << res << endl;
 
 
    return 0;
}

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

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

    return 0;
}

Measured memory_bytes: 256
#include <cctype>
#include <cfloat>
#include <climits>
#include <cmath>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <ios>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <forward_list>
#include <random>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <unordered_map>
#include <unordered_set>
#endif

#define F first
#define S second
#define MP make_pair
#define pb push_back
#define all(a) a.begin(), a.end()
#define lcm( a, b ) (a)/__gcd((a),(b))*(b)
#define endl '\n'

using namespace std;

typedef long long LL;
typedef pair< int, int > P;
typedef pair< LL, LL > LP;
typedef pair< int, P > iP;
typedef pair< P, P > PP;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1000000007;
static const int SIZE = 500005;

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

vector< LL > Div( LL n ) {
    vector< LL > ret;
    for( LL i = 1; i * i <= n; ++i ) {
        if( n % i == 0 ) {
            ret.pb( i );

            if( i * i != n ) ret.pb( n / i );
        }
    }
    sort( all( ret ) );
    return ret;
}

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

    LL a, b;
    cin >> a >> b;
    vector< LL > da = Div( a );
    vector< LL > db = Div( b );
    set< LL > st;
    vector< LL > to;
    for( int i = 0; i < da.size(); ++i ) {
        st.insert( da[i] );

    }

    for( int i = 0; i < db.size(); ++i ) {
        int size = st.size();
        st.insert( db[i] );
        if( size == st.size() ) {
            to.pb( db[i] );

        }
    }

    int cnt = 0;
    for( int i = 0; i < to.size(); ++i ) {
        bool flg = true;
        for( int j = 1; j < i; ++j ) {
            if( to[i] % to[j] == 0 ) {
                flg = false;
                break;

            }
        }
        if( flg ) ++cnt;

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



Measured memory_bytes: 768
#include<bits/stdc++.h>
#include<iomanip>
#include<numeric>

using namespace std;
using ll = long long;
using ull = unsigned long long;
constexpr int mo = 1e9+7;
constexpr int  mod = mo;
constexpr int inf = 1<<30;
constexpr ll infl = 1ll<<60;
int main(){
    int n;
    cin>>n;
    vector<int> A(n);
    for(auto &a : A) cin>>a;
    sort(A.begin(),A.end());
    vector<pair<ll,ll>> ans;
    if(A[n-1] < 0){
        for(int i=n-2;i>=0;i--){
            ans.emplace_back(A[n-1],A[i]);
            A[n-1] -= A[i];
        }
        cout << A[n-1] << endl;
        for(auto an : ans){
            cout << an.first << " " << an.second << endl;
        }
    }else if(A[0] >= 0){
        for(int i=1;i<n-1;++i){
            ans.emplace_back(A[0],A[i]);
            A[0] -= A[i];
        }
        ans.emplace_back(A[n-1],A[0]);
        cout << A[n-1] - A[0] << endl;
        for(auto an : ans){
            cout << an.first << " " << an.second << endl;
        }
     }else {
        int count = lower_bound(A.begin(),A.end(),0) - A.begin();
        for(int i=count+1;i<n;++i){
            ans.emplace_back(A[count-1],A[i]);
            A[count-1] -= A[i];
        }
        for(int i=0;i<count-1;++i){
            ans.emplace_back(A[count],A[i]);
            A[count] -= A[i];
        }
        ans.emplace_back(A[count],A[count-1]);
        cout << A[count] - A[count-1] << endl;
        for(auto a : ans){
            cout << a.first << " " << a.second << endl;
        }
    }
    return 0;
}



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

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

  vector<string> v(N);
  for (int i = 0; i < N; i++)
    cin >> v[i];
  
  sort(v.begin(), v.end());
  for (int i = 0; i < N; i++)
    cout << v[i];
  cout << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#define _USE_MATH_DEFINENS
#include <cmath>
using namespace std;

#define p(x) cout << x << endl;
#define el cout << endl;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

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

    int r, g, b;
    cin >> r >> g >> b;
    int ans = r * 100 + g * 10 + b;
    puts(ans % 4 == 0 ? "YES" : "NO");
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>
#include <iomanip>
#include <algorithm>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)

int main() {
	int a,b,c,ans=0,mx=0;
	cin>>a>>b>>c;
	cout<<(c/a)*b;
	return 0;
}


Measured memory_bytes: 256
// AOJ 1554: Friday the 13th
// 2019.2.22 bal4u
 
#include <stdio.h>
#include <stdlib.h>

#define MAGIC 6880  // 1000/1/1-4999/12/31
#define Magic 1719  // 1/1/1-999/12/31

int dayOfWeek(int year, int month, int day)
{
	if (month == 1 || month == 2) year--, month += 12;
	return (year + year / 4 - year / 100 + year / 400
		+ (13 * month + 8) / 5 + day) % 7;
}

long long dayFri13(long long year, int month, int day)
{
	int y, m;
	long long ans;

	year += 3000;
	ans = Magic + year / 4000 * MAGIC;
	year = 1000 + year % 4000;
	for (y = 1000; y < year; y++) {
		for (m = 1; m <= 12; m++)
			if (dayOfWeek(y, m, 13) == 5) ans++;
	}
	if (month > 1 || (month == 1 && day >= 13)) {
		if (day < 13) month--;
		for (m = 1; m <= month; m++)
			if (dayOfWeek(y, m, 13) == 5) ans++;
	}
	return ans;
}

int main()
{
	long long y1, y2; int m1, m2, d1, d2;

	scanf("%lld%d%d%lld%d%d", &y1, &m1, &d1, &y2, &m2, &d2);
	if (d1 == 13) d1--;
	printf("%lld\n", dayFri13(y2, m2, d2) - dayFri13(y1, m1, d1));
	return 0;
}


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

public class Main {
    public static void main(String[] args) {
        try(Scanner scanner = new Scanner(System.in)) {
            int N = scanner.nextInt();
            int count = 0;
            boolean flg = true;
            List<Integer> numList = new ArrayList<>();
            scanner.nextLine();
            for (int i = 0; i < N; i++) {
                int j = scanner.nextInt();
                if (j % 2 == 1) {
                    flg = false;
                    break;
                }
                numList.add(j);
            }
            while (flg) {
                List<Integer> nextNumList = new ArrayList<>();
                for (Integer i : numList) {
                    if (i % 2 == 1) {
                        flg = false;
                        break;
                    }
                    nextNumList.add(i / 2);
                }
                if (!flg) {
                    break;
                }
                numList = nextNumList;
                count++;
            }
            System.out.println(count);
        }
    }
}


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

int main(){
 long long  int n,m,a[200010],b[200010]={0};
  cin >> n >>m;
  
  for(int i=0;i<n;i++)
    cin >> a[i];
  
  for(int i=0;i<n;i++){
    b[a[i]]++;
  }
  
  sort(b,b+n,greater<int>());
  
  for(int i=0;i<m;i++){
    n -=b[i];
  }
  
  cout << n << endl;
}
    
  
  
  
    
 
 

Measured memory_bytes: 3328
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
#include<stdio.h>
#include <cstdint>
#include <stdlib.h> 
#include <time.h>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define drep(i,n,m) for(int i = n;i >= m;i--)
#define rrep(i,n) REP(i,1,n+1)
#define all(a) a.begin(), a.end()
#define fi first
#define se second
#define RNG(x, a, n) &((x)[a]), &((x)[n])
long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); }
long long lcm(long long a, long long b) { return a / gcd(a, b) * b; }
typedef long long ll;
typedef pair<ll, ll> Pll;
typedef pair<int, int> PII;
typedef vector<ll> Vl;
typedef vector<int> VI;
typedef tuple<int, int, int> TT;
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
#define all(v) v.begin(), v.end()
#define dmp(x,y) make_pair(x,y)
#define dmt(x, y, z) make_tuple(x, y, z)
#define pb(x) push_back(x)
#define pf(x) push_front(x)
const int MAX = 500000;
const int inf = 1000000007;
const ll mod = 1000000007;
const long double PI = (acos(-1));
const long double EPS = 0.0000000001;

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


int q;
int l, r;
int ruiseki[100010];

bool arr[100010];
void Eratosthenes() {
	rrep(i, 100005)arr[i] = true;
	for (int i = 2; i < 100005; i++) {
		if (arr[i]) {
			int cnt = i * 2;
			while (cnt < 100005) {
				arr[cnt] = false;
				cnt += i;
			}
		}
	}
	arr[1] = false;

}

int main() {

	cin >> q;

	Eratosthenes();

	REP(i, 3, 100005) {
		if (i % 2 == 1) {
			if (arr[i] && arr[(i + 1) / 2])ruiseki[i]++;
		}
		ruiseki[i] += ruiseki[i - 1];
	}

	rep(i, q) {
		cin >> l >> r;
		cout << ruiseki[r] - ruiseki[l - 1] << endl;
	}

	return 0;
}


Measured memory_bytes: 1152
from itertools import product
n,y = map(int,input().split())

bill_combination = '-1 -1 -1'
for bill10,bill5 in product(range(n+1),repeat=2):
    bill1 = n - (bill10 + bill5)
    if bill1 >= 0 and y == (bill10 * 10000 + bill5 * 5000 + bill1 * 1000):
        print(bill10,bill5,bill1)
        break
else:
    print(bill_combination)

Measured memory_bytes: 40812
def solve(N, TAs):
    T, A = 1, 1
    for t, a in TAs:
        m = (t * A) % a
        y = max(0, (T * a - t * A) // t)
        while True:
            if (m + (y * t)) % a == 0:
                break
            y += 1
        x = (t * A + t * y) // a - T
 
        T += x
        A += y
    return T + A
  
if __name__ == "__main__":
    N = int(input())
    TAs = [(tuple)(map(int, input().split(" "))) for l in range(N)]
    print(solve(N, TAs))

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <random>

using namespace std;


int main()
{
	int N,X;

	cin >> N >> X;	


	int ans = 0;
	long long sum = 0;;

	int n;
	int ni;
	for(ni = 0; ni < N; ni++){
		cin >> n;
		sum += n;
		if (sum > X){
			break;
		}
	}

	ans = ni + 1;
	printf("%d",ans);

	return 0;
}



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

int main() {
	ios::sync_with_stdio(0);cin.tie(0);
	multiset<double> st;
	int n;
	cin >> n;
	for(int i=0; i<n; i++) {
		double t;
		cin >> t;
		st.insert(t);
	}
	for(int i=0; i<n-1; i++) {
		double a = *st.begin();
		st.erase(st.begin());
		double b = *st.begin();
		st.erase(st.begin());
		st.insert((a+b)/2);
	}
	cout << fixed << setprecision(10) << *st.begin();
}

Measured memory_bytes: 256
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <climits>
#include <numeric>
#include <cmath>
#include <queue>
#include <sstream>
#include <string.h>
#include <bitset>

using namespace std;
typedef long long ll;

int main() {
  int n, k;
  cin >> n >> k;
  
  vector<int> x(n), y(n);
  vector<int> xary(n), yary(n);
  
  for (int i = 0; i < n; i++) {
    cin >> x[i] >> y[i];
    xary[i] = x[i];
    yary[i] = y[i];
  }
  
  sort(xary.begin(), xary.end());
  sort(yary.begin(), yary.end());
  ll ans = 1LL * (xary[n - 1] - xary[0]) * (yary[n - 1] - yary[0]);

  for (int xi = 0; xi < n; xi++) {
    for (int xj = xi + 1; xj < n; xj++) {
      for (int yi = 0; yi < n; yi++) {
        for (int yj = yi + 1; yj < n; yj++) {
          ll lx = xary[xi], rx = xary[xj];
          ll by = yary[yi], ty = yary[yj];
          
          int num = 0;
          for (int i = 0; i < n; i++) {
            if (lx <= x[i] && x[i] <= rx && by <= y[i] && y[i] <= ty) {
              num++;
            }
          }
          if (num >= k) {
            ans = min(ans, 1LL * (rx - lx) * (ty - by));
          }
        }
      }
    }
  }
  cout << ans << endl;
  return 0;
}


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

int main()
{
	 
	 
	  
	  
	int ans;  
	for(int i=1;i<=5;i++)
	{
		int x;
		cin>>x;
		if(x==0) ans=i;
	}
	cout<<ans<<endl;
 
	return 0;
}

Measured memory_bytes: 3564
#include<bits/stdc++.h>
using namespace std;
#include <numeric> 
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);
#define endl "\n"
#define int long long int
#define mod 1000000007


int32_t main()
{
	int n;
	cin>>n;
	int flag=0;
	while(n>0)
	{
		int x=n%10;
		if(x==7)
			flag=1;
		n/=10;
	}
	if(flag==1)
		cout<<"Yes"<<endl;
	else
		cout<<"No"<<endl;
	return 0;
  }

Measured memory_bytes: 3576
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
const long long LINF = 1e18;
#define dump(x)  cout << 'x' << ' = ' << (x) << ` `;
#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) )
typedef long long ll;
using namespace std;
typedef pair<int, int> P;

int main(int argc, char const *argv[]) {
    int n;
    cin >> n;
    vector<ll> place(n+1);
    REP(i,n) {
        int a;
        cin >> a;
        place[a] = i;
    }
    ll ans = 0;

    set<ll> used;
    used.insert(-1), used.insert(n);

    for (int i = 1; i <= n; ++i) {
        ll ind = place[i];
        auto ritr = used.lower_bound(ind);
        ll r = *ritr-ind;
        auto litr = used.lower_bound(ind);
        --litr;
        ll l = ind-*litr;
        ans += l*r*i;
        used.insert(ind);
    }

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

Measured memory_bytes: 11136
import java.util.Scanner;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int x = sc.nextInt();
        double area = (1.0 * x) / (1.0 * a);
        sc.close();
        if (a * b / 2 >= area) {
            // 三角形
            double len = 2 * area / b;
            double tan = b / len;
            double ans = Math.atan(tan);
            double answer = ans / Math.PI * 180;
            System.out.println(answer);
        } else {
            double len = (area * 2 / a) - b;
            double tan = (b - len) / a;
            double ans = Math.atan(tan);
            double answer = ans / Math.PI * 180;
            System.out.println(answer);
        }
    }
}


Measured memory_bytes: 22732
S = list(input())
cumu=[0]
cnt = 0
for i in S:
    if(i=='B'):
        cumu.append(cumu[-1]+1)
    else:
        cumu.append(cumu[-1])

for ind,i in enumerate(cumu[1:]):
    if(S[ind]=='W'):
        cnt+=i

print(cnt)


Measured memory_bytes: 14140
import itertools
import math
import string
import collections
from collections import Counter
from collections import deque
import sys
sys.setrecursionlimit(2*10**5)
INF = 2**60


def readints():
    return list(map(int, input().split()))


def nCr(n, r):
    return math.factorial(n)//(math.factorial(n-r)*math.factorial(r))


def has_duplicates2(seq):
    seen = []
    for item in seq:
        if not(item in seen):
            seen.append(item)
    return len(seq) != len(seen)


def divisor(n):
    divisor = []
    for i in range(1, n+1):
        if n % i == 0:
            divisor.append(i)
    return divisor


# coordinates
dx = [-1, -1, -1, 0, 0, 1, 1, 1]
dy = [-1, 0, 1, -1, 1, -1, 0, 1]
n, k, q = map(int, input().split())
a = []
for _ in range(q):
    a.append(int(input()))
point = [k-q]*(n+1)
for i in range(q):
    point[a[i]] += 1
for i in range(1, n+1):
    if point[i] > 0:
        print('Yes')
    else:
        print('No')


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

using namespace std;
 
#define DEBUG(x) cout<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cout<<#v<<":";for(int i=0;i<v.size();i++) cout<<" "<<v[i]; cout<<endl
 
typedef long long ll;
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define in(x, a, b) a <= x && x < b
const int inf = 1000000001;
const ll INF = 2e18;
const ll MOD = 1000000007;
//const ll mod = 1000000009;
const double pi = 3.14159265358979323846;
#define Sp(p) cout<<setprecision(15)<< fixed<<p <<endl;
int dx[4] = { 1,0, -1,0 }, dy[4] = { 0,1,0,-1 };
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };

const int N = 100010;
vii G2(N);
vii G(N);
vi weight(N);
string s;


int dfs1(int now, int parent) {
  int res;
  if (s[now] == 'W') {
    res = 1;
  }
  else {
    res = 0;
  }
  rep (i, G2[now].size()) {
    if (G2[now][i] == parent) {
      continue;
    }
    res += dfs1(G2[now][i], now);
  }
  if (res && parent != -1) {
    G[now].push_back(parent);
    G[parent].push_back(now);
  }
  return res;
}

int dfs2(int now, int parent) {
  int res = 1;
  if ((s[now] == 'W') xor ((int)G[now].size()%2)) {
    weight[now] = 1;
  }
  rep (i, G[now].size()) {
    if (G[now][i] == parent) {
      continue;
    }
    res += dfs2(G[now][i], now);
  }
  return res;
}

pii dfs3(int now, int parent, int cnt = 0, pii res = pii(0, 0)) {
  cnt += weight[now];
  res = max(res, pii(cnt, now));
  rep (i, G[now].size()) {
    if (G[now][i] == parent) {
      continue;
    }
    res = max(res, dfs3(G[now][i], now, cnt, res));
  }
  return res;
}

int main() {
  int n;
  cin >> n;
  rep (i, n - 1) {
    int x, y;
    cin >> x >> y;
    x--; y--;
    G2[x].push_back(y); G2[y].push_back(x);
  }
  cin >> s;
  int cnt = 0, root = -1;
  rep (i, n) {
    if (s[i] == 'W') {
      cnt++;
      root = i;
    }
  }
  if (cnt <= 1) {
    cout << cnt << endl;
    return 0;
  }

  dfs1(root, -1);
  n = dfs2(root, -1);
  int sum = accumulate(all(weight), 0);
  int ans = 2 * (n - 1) + sum;

  pii res = dfs3(root, -1);
  int u = res.second;
  res = dfs3(u, -1);
  int v = res.second;
  int d = res.first;
  ans -= 2*d;
  cout << ans << endl;
}


Measured memory_bytes: 19584
#include<iostream>
#include<string>
 
using namespace std;
 
int main()
{
  int a, b;
  string op;
   
  while(1)
    {
      cin >> a >> op >> b;
       
      if (op == "+")
        cout << a + b << endl;
      else if (op == "-")
        cout << a - b << endl;
      else if (op == "*")
        cout << a * b << endl;
      else if (op == "/")
        cout << a / b << endl;
      else if (op == "?")
        break;
    }
  return 0;
}

Measured memory_bytes: 1204
mod = 2019
l,r = map(int,input().split())

cnt = 0
tank = []
for i in range(l,r+1):
    tank.append(i%mod)
    cnt += 1
    if cnt >= 2020:
        break

res = 2019

n = len(tank)
for i in range(n):
    for j in range(i+1,n):
        res = min(res,tank[i]*tank[j]%mod)
print(res)

Measured memory_bytes: 41836
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <iostream>
typedef long long int ll;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;

int dp[50][3001];

void func(int N,int M,int S,int limit){

	for(int i = 0; i <= 49; i++){
		for(int k = 0; k <= 3000; k++)dp[i][k] = 0;
	}

	dp[0][0] = 1;

	for(int number = 1; number <= M; number++){
		for(int loc = limit; loc >= 1; loc--){
			for(int sum = number; sum <= S; sum++){
				dp[loc][sum] = (dp[loc][sum] + dp[loc-1][sum-number])%100000;
			}
		}
	}

	printf("%d\n",dp[limit][S]);

}

int main(){

	int N,M,S,limit;

	while(true){
		scanf("%d %d %d",&N,&M,&S);
		if(N == 0 && M == 0 && S == 0)break;

		limit = N*N;

		func(N,M,S,limit);
	}

	return 0;
}

Measured memory_bytes: 3744
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string S,T;
  // 変数aで入力を受け取る
  cin >> S >>T;
  int ans = 0;
for(int i = 0;i<3;i++){
  if (S.at(i) == T.at(i)){
      ans++;
  }
}
  cout << ans << endl;
}

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

int main() {
    long long x;
    cin >> x;

    long long count = 0;
    long long sihon = 100;

    for(long long i=0; ; i++){
    
        sihon = (sihon*1.01)/1;
        count ++;

        if(sihon>=x) break;
    }
  cout << count << endl;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n;
  long long int k;
  cin >> n >> k;
  vector<long long int> num(100001,0);
  for(int i = 0;i < n;i++){
    int a,b;
    cin >> a >> b;
    num[a] += b;
  }
  long int count = 0;
  for(int i = 1;i <= 100000;i++){
    count += num[i];
    if(count >= k){
      cout << i << endl;
      break;
    }
  }
}
  


Measured memory_bytes: 1024
import static java.util.Arrays.deepToString;

import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		new Main().run();
	}
	Scanner sc = new Scanner(System.in);
	public void run() {
		for (;sc.hasNext();) {
			int t = sc.nextInt();
			if (t == 0) break;
			int q = sc.nextInt();
			for (int i = 0; i < q; i++) {
				int start = sc.nextInt();
				int end = sc.nextInt();
				t -= end - start;
			}
			if (t <= 0) System.out.println("OK");
			else System.out.println(t);
		}
	}
}

Measured memory_bytes: 23588
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#ifdef ENABLE_DEBUG
#define dump(a) cerr<<#a<<"="<<a<<endl
#define dumparr(a,n) cerr<<#a<<"["<<n<<"]="<<a[n]<<endl
#else
#define dump(a) 
#define dumparr(a,n) 
#endif
#define FOR(i, a, b) for(ll i = a;i < b;i++)
#define For(i, a) FOR(i, 0, a)
#define REV(i, a, b) for(ll i = b-1;i >= a;i--)
#define Rev(i, a) REV(i, 0, a)
#define REP(a) For(i, a)

typedef long long int ll;
typedef unsigned long long ull;
typedef unsigned int uint;
typedef pair<ll, ll> pll;
typedef pair<ll,pll> ppll;
typedef vector<ll> vll;

const ll INF=(1LL<<50);
#if __cplusplus>=201700L
ll gcd(ll a, ll b) {
  if(a < b) return gcd(b, a);
  ll r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}
#endif

template<class S,class T>
std::ostream& operator<<(std::ostream& os,pair<S,T> a){
  os << "(" << a.first << "," << a.second << ")";
  return os;
}
template<class T>
std::ostream& operator<<(std::ostream& os,vector<T> a){
  os << "[ ";
  REP(a.size()){
    os<< a[i] << " ";
  }
  os<< " ]";
  return os;
}


void solve(long long N, long long K, std::vector<long long> A, std::vector<long long> F){
  sort(A.begin(),A.end(),less<ll>());
  sort(F.begin(),F.end(),greater<ll>());
  ll l=-1,r=1000000000009LL;
  while(l+1<r){
    ll mid=(l+r)/2;
    ll k=0;
    REP(N){
      if(mid==0){
        k+=A[i];
      }
      else if(A[i]*F[i]>mid){
        k+=A[i]-(mid/F[i]);
      }
    }
    if(K<k){
      l=mid;
    }else{
      r=mid;
    }
  }
  cout<<r<<endl;
}

int main(){
    long long N;
    scanf("%lld",&N);
    long long K;
    scanf("%lld",&K);
    std::vector<long long> A(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&A[i]);
    }
    std::vector<long long> F(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&F[i]);
    }
    solve(N, K, std::move(A), std::move(F));
    return 0;
}


Measured memory_bytes: 3328
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
#define all(a) a.begin(), a.end()
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; }
using namespace std;
typedef long long ll;

// AtCoder Beginner Contest 141
int main(){

    int N, M;
    cin >> N >> M;

    vector<int> a(N);
    priority_queue<pair<int, int>> que;
    rep(i, N){
        cin >> a[i];
        que.push(make_pair(a[i], i));
    }

    rep(i, M){
        pair<int, int> p = que.top();
        que.pop();
        a[p.second] /= 2;
        que.push(make_pair(a[p.second], p.second));
    }

    ll ans = 0;
    rep(i, N)ans += a[i];
    cout << ans << endl;

}

Measured memory_bytes: 1784
#include<stdio.h>
int main(void)
{
	int x=0,y=0,i,j;
	char s[4];
	scanf("%s", s);
	for(i=1; i<4; i++)
	{
		if(s[0]==s[i])
		x++;
		else
		{
			for(j=i+1; j<4; j++)
			{
				if(s[i]==s[j])
				y++;
			}
		}
	}
	if(x==1&&y==1)
	printf("Yes\n");
	else
	printf("No\n");
	
	return 0;
}

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

pt, px, py = [0, 0, 0]
ans = 'Yes'
for t, x, y in XY:
    lim = t - pt
    need = abs(x-px) + abs(y-py)
    if lim < need or (lim-need)%2==1:
        ans = 'No'
        break
    pt, px, py = t, x, y

print(ans)

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

int main()
{
	stack<int> x;
	int n;
	while(cin>>n){
		if(n==0){
			cout<<x.top()<<endl;
			x.pop();
		}else{
			x.push(n);
		}
	}
    return 0;
}

Measured memory_bytes: 1204
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
const int maxn=1010;
typedef long long LL;
struct Node
{
    LL x,y,z;
} a[maxn];
int n,m,i,j,k;

bool _cmp(const Node &n1,const Node &n2)
{
    return n1.x*i+n1.y*j+n1.z*k>n2.x*i+n2.y*j+n2.z*k;
}

int main()
{
    //freopen("1.txt","r",stdin);
    while (scanf("%d%d",&n,&m)!=EOF)
    {
        for (int q=0;q<n;q++) scanf("%lld%lld%lld",&a[q].x,&a[q].y,&a[q].z);
        LL ans=0;
        for (i=-1;i<=1;i+=2)
            for (j=-1;j<=1;j+=2)
                for (k=-1;k<=1;k+=2)
                {
                    sort(a,a+n,_cmp);
                    LL t[4]={0};
                    for (int q=0;q<m;q++)
                    {
                        t[1]+=a[q].x;
                        t[2]+=a[q].y;
                        t[3]+=a[q].z;
                    }
                    ans=max(ans,t[1]*i+t[2]*j+t[3]*k);
                }
        printf("%lld\n",ans);
    }
    return 0;
}


Measured memory_bytes: 888
import sys
input = lambda: sys.stdin.readline().rstrip()
input_nums = lambda: list(map(int, input().split()))

def main():
    A, B = input_nums()
    if A == B:
        ans = 0
    else:
        if (A+B)%2 == 0:
            ans = (A+B)//2
        else:
            ans = 'impossible'.upper()
    print(ans)

if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
package main

import (
	"bufio"
	"os"
	"strconv"
	"fmt"
)

func main() {
	sc.Split(bufio.ScanWords)
	a, b := nextInt(), nextInt()
	if a%2 == 0 || b%2 == 0 {
		fmt.Println("Even")
	} else {
		fmt.Println("Odd")
	}
}

// -------- Library --------
var sc = bufio.NewScanner(os.Stdin)

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	v, err := strconv.Atoi(next())
	if err != nil {
		fmt.Println("Failed to read int", err)
		os.Exit(1)
	}
	return v
}

func nextIntArray(size int) []int {
	res := make([]int, size)
	for i := 0; i < size; i++ {
		res[i] = nextInt()
	}
	return res
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
#define int long long
using namespace std;
int read( ){
	int x=0,y=1;char ch=' ';
	for(;(ch!='-' && (ch>'9' || ch<'0'));ch=getchar( ));
	if(ch=='-')y=-1,ch=getchar( );
	for(;ch>='0' && ch<='9';ch=getchar( ))x=x*10+ch-48;
	return x*y;
}
const int N=1e5+10;
int n,m;
char s[N<<1],g[N<<1];
int f[N<<1][27];
signed main( ){
	int x,y,z,k,ans=0;
	scanf("%s",s);
	scanf("%s",g);
	n=strlen(s);m=strlen(g);
	for(register int i=n;i<n*2;++i)s[i]=s[i-n];
	for(register int i=2*n-2;i>=0;--i){
		for(register int j=0;j<26;++j){
			if(s[i+1]==j+'a')f[i][j]=i+1;
			else f[i][j]=f[i+1][j];
		}
	}
	k=0;

	//for(register int i=0;i<n*2-1;++i)
	//	printf("%lld ",f[i][2]);
	for(register int i=0;i<m;++i){
		int x=g[i]-'a';
		
		if(i==0 && g[0]==s[0]){
			ans=k=0;continue;
		}
		if(f[k][x]==0){
			printf("-1\n");return 0;
		}
		ans+=f[k][x]-k;
		k=f[k][x]%n;
	}
	printf("%lld\n",ans+1);
	return 0;
}

Measured memory_bytes: 42752
import java.io.File;
import java.io.FileInputStream;
import java.util.NoSuchElementException;
import java.util.Scanner;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.Deque;
import java.util.HashMap;
import java.util.List;
import java.util.Map.Entry;

public class Main {
	
	public static void main(String[] args) throws IOException {
		Scanner sc = new Scanner(System.in);
		
		String s = sc.next();
		System.out.println(1 + s.lastIndexOf('Z') - s.indexOf('A'));
	}
}

Measured memory_bytes: 26064
#include<cstdio>
#include<algorithm>
using namespace std;
int main(void)
{
	int n,d[51],i,j,sum;
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d",&d[i]);
	}
	sum=0;
	for(i=0;i<n-1;i++){
		for(j=i+1;j<n;j++){
			sum+=d[i]*d[j];
		}
	}
	printf("%d\n",sum);
	return 0;
}

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

int main(void){
    string s;
    cin >> s;
    int N = stoi(s);
    int X = 0;
    for(int i = 0; i < s.length(); i++)
        X += (s[i]- '0');

    if(N % X == 0)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;

    return 0;
}

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

#pragma region
using namespace std;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define rep(i,n) FOR(i,0LL,n)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define rrep(i,n) RFOR(i,0LL,n)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define COUNT(a,y,x) upper_bound(all(a), y) - lower_bound(all(a), x)
#define UNIQUE(a) sort(all(a)); a.erase(unique(all(a)), a.end())
#define pb push_back
typedef long long int ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef vector<string> vs;
typedef map<ll, ll> MAP;
const ll inf = 2222222222222222222LL;
//const ll mod = 1000000007LL;
const ll mod = 998244353LL;

ll n = 0, m = 0, ans = 0, tmp = 0, ma = -inf, mi = inf;
string s;
bool ok;
ll dx[9] = { 0,1,0,-1,0,1,1,-1,-1 }, dy[9] = { 0,0,1,0,-1,1,-1,1,-1 };
#define endl '\n'
#pragma endregion
#define MAX 222222


ll a[MAX];
bool dp[MAX];




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


  cin >> n >> m;
  rep(i, n) cin >> a[i];
  rep(i, m + 1) {
    rep(j, n) {
      if (i - a[j] < 0) continue;
      if (!dp[i - a[j]]) dp[i] = true;
    }
  }

  if (dp[m]) cout << "First" << endl;
  else cout << "Second" << endl;

  return 0;
}

Measured memory_bytes: 384
//It’s never too late to become what you might have been....
 #include <iostream>
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define inf 1000000000000
#define mod 1000000007
#define pb push_back
#define mp make_pair
#define all(v) v.begin(),v.end()
#define S second
#define F first
#define boost1 ios::sync_with_stdio(false);
#define boost2 cin.tie(0);
#define mem(a,val) memset(a,val,sizeof a)
#define endl "\n"
#define maxn 100001

ll a[1000];
int main()
{
	boost1;boost2;	
	ll i,j,n,ans=inf,sum;
	cin>>n;
	for(i=1;i<=n;i++)
	cin>>a[i];
	for(i=-1000;i<=1000;i++)
	{
		sum=0;
		for(j=1;j<=n;j++)
		sum+=(a[j]-i)*(a[j]-i);
		ans=min(ans,sum);
	}
	cout<<ans;
	return 0;
}


Measured memory_bytes: 256
n,k=map(int,input().split())
r,s,p=map(int,input().split())
t=input()

score= {"r": p,"s": r,"p": s}
ans=0
for i in range(k):
    tt = t[i:n:k]    
    old="x"
    c=1
    for ttt in tt:
        if ttt!=old:
            ans+=score[ttt]
            c=1
        else:
            if c==1:
                c=-1
            else:
                c=1
                ans+=score[ttt]
        old = ttt
print(ans)
            

Measured memory_bytes: 41324
import java.util.*;

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

      int n = Integer.parseInt(sc.next());

      String s = sc.next();
      int lng = s.length();
      char[] c = new char[lng];
      c[0] = s.charAt(0);
      int cnt = 1;
      for(int i=1;i<lng;i++){
        c[i] = s.charAt(i);
        if(c[i-1]!=c[i]){
          cnt++;
        }
      }

      System.out.println(cnt);

    }
}


Measured memory_bytes: 25812
#include <stdio.h>

int main(void)
{
	int N, i;
	int a, b, c;
	scanf("%d\n", &N);
	for(i=0; i<N; i++) {
		scanf("%d %d %d", &a, &b, &c);
		a*=a; b*=b; c*=c;
		if(a+b==c || b+c==a || c+a==b) printf("YES\n");
		else printf("NO\n");
	}
	return 0;
}


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

using namespace std;

#define SZ(v) ((int)(v).size())
#define ALL(v) (v).begin(),(v).end()
#define one first
#define two second
using ll = long long;
using pi = pair<int, int>;
const int INF = 0x3f3f3f3f;
const ll LINF = 1ll * INF * INF;

const int MAX_N = 55;

int N, A;
ll Dy[MAX_N][MAX_N][MAX_N * MAX_N];
int main() {
	cin >> N >> A;
	Dy[0][0][0] = 1;
	for(int i=1; i<=N; i++) {
		int x; scanf("%d", &x);
		for(int j=0; j<i; j++) for(int k=0; k<=MAX_N*j; k++) {
			Dy[i][j][k] += Dy[i-1][j][k];
			Dy[i][j+1][k+x] += Dy[i-1][j][k];
		}
	}
	ll ans = 0;
	for(int i=1; i<=N; i++) ans += Dy[N][i][A*i];
	cout << ans << endl;
	return 0;
}


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

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

int main()
{
    int N, K;
    string S;
    cin >> N >> K >> S;
    rep(i, N){
        if(i == K - 1){
            cout << (char)(S[i] + 0x20);
        }else{
            cout << S[i];
        }
    }
    cout << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define DEBUG if(0)
#define lli long long int
#define ldouble long double
using namespace std;

const int maxN = 2e5; int n; lli k;
lli a[maxN];

bool can(lli x)
{
  lli cuts = 0;
  for (int i = 0; i < n; i++)
    if (a[i] > x)
      cuts += a[i] / x;
  return cuts <= k;
}

int main()
{
  while (scanf("%d %lld", &n, &k) != EOF)
  {
    for (int i = 0; i < n; i++)
      scanf("%lld", &a[i]);

    lli lo = 1, hi = 1e9;
    while (lo < hi)
    {
      lli mid = (lo + hi) >> 1;
      if (can(mid)) hi = mid;
      else lo = mid + 1;
    }
    printf("%lld\n", lo);
  }
  return 0;
}

Measured memory_bytes: 5272
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;

internal class Program {
    static void Main() => CustomMain();

    static void Solve() {
        var c = ReadString().ToCharArray();

        WriteAnswer(c.Count(x => x == '1'));
    }


    static void CustomMain() {
#if DEBUG
        // ファイルからテストケースを読み込む
        ChangeStdIn();
        // 時間計測
        var stopwatch = new Stopwatch();
        stopwatch.Start();
#endif
        // 出力高速化
        var streamWriter = new StreamWriter(Console.OpenStandardOutput()) {AutoFlush = false};
        Console.SetOut(streamWriter);
        // 回答
        Solve();
#if DEBUG
        stopwatch.Stop();
        Console.WriteLine(stopwatch.Elapsed);
#endif
        Console.Out.Flush();
    }

    static string ReadString() => Console.ReadLine().Trim();
    static int ReadInt() => int.Parse(ReadString());
    static long ReadLong() => long.Parse(ReadString());
    static float ReadFloat() => float.Parse(ReadString());
    static double ReadDouble => double.Parse(ReadString());

    static string[] ReadStringArray() => ReadString().Split(' ');
    static int[] ReadIntArray() => Array.ConvertAll(ReadString().Split(' '), int.Parse);
    static long[] ReadLongArray() => Array.ConvertAll(ReadString().Split(' '), long.Parse);
    static float[] ReadFloatArray() => Array.ConvertAll(ReadString().Split(' '), float.Parse);
    static double[] ReadDoubleArray() => Array.ConvertAll(ReadString().Split(' '), double.Parse);

    static T TypeConversion<T>(string s) {
        if (typeof(T) == typeof(int)) {
            return (T) Convert.ChangeType(int.Parse(s), typeof(T));
        } else if (typeof(T) == typeof(long)) {
            return (T) Convert.ChangeType(long.Parse(s), typeof(T));
        } else if (typeof(T) == typeof(double)) {
            return (T) Convert.ChangeType(double.Parse(s), typeof(T));
        } else {
            return (T) Convert.ChangeType(s, typeof(T));
        }
    }

    static void ReadMulti<T, U>(out T a, out U b) {
        var str = ReadStringArray();
        a = TypeConversion<T>(str[0]);
        b = TypeConversion<U>(str[1]);
    }

    static void ReadMulti<T, U, V>(out T a, out U b, out V c) {
        var str = ReadStringArray();
        a = TypeConversion<T>(str[0]);
        b = TypeConversion<U>(str[1]);
        c = TypeConversion<V>(str[2]);
    }

    static void WriteAnswer(object ans) => Console.WriteLine(ans);

    static bool IsOdd(long num) {
        return (num & 1) == 1;
    }

    static bool IsEven(long num) {
        return (num & 1) == 0;
    }

    static long GCD(long a, long b) {
        return b != 0 ? GCD(b, a % b) : a;
    }

    static long RoundUp(long a, long b) {
        return (a + b - 1) / b;
    }


    static void ChangeStdIn() {
        var path = "./../../TestCase.txt";
        var exStdIn = new System.IO.StreamReader(path);
        Console.SetIn(exStdIn);
    }
}

Measured memory_bytes: 13268
#include<iostream>
#include <fstream>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>

unsigned gcd(unsigned a, unsigned b) {
  if(a < b) return gcd(b, a);
  unsigned r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}

#define LOCAL  1
#define UPLOAD 2

using namespace std;

int main()
{
#if ENVIRONMENT == LOCAL
    std::ifstream in("input.txt");
    std::cin.rdbuf(in.rdbuf());
#endif

    int A, B;
    cin >> A >> B;

    int res1 = A+B;
    int res2 = A-B;
    int res3 = A*B;

    cout << max(max(res1, res2), res3) << endl;

    return 0;
}

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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define ALL(a)     (a).begin(),(a).end()
#define MOD 1000000007

typedef long long int ll;

const ll INF=(ll)1e19;
//const int INF=(1<<30);


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

  vector<int> x(N);
  vector<int> y(N);

  REP(i,N){
    int t;
    cin >> t;
    x[i] = y[i] = t;;
  }
  sort(ALL(y));

  REP(i,N){
    cout << (x[i]<=y[N/2-1] ? y[N/2] : y[N/2-1]) << endl;

  }



}



Measured memory_bytes: 3712
#!/usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
import sys, random, itertools, math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float, input().split()))
def LI_(): return list(map(lambda x: int(x)-1, input().split()))
def II(): return int(input())
def IF(): return float(input())
def S(): return input().rstrip()
def LS(): return S().split()
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = 1e10

#solve
def solve():
    n, m = LI()
    a = LI()
    suma = sum(a)
    m4 = suma / 4 / m
    ans = 0
    for i in a:
        if i >= m4:
            ans += 1
    print("Yes" if ans >= m else "No")
    return


#main
if __name__ == '__main__':
    solve()


Measured memory_bytes: 39024
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int lim = 1e5+7;
vector<int> adj[lim];
vector<int> dp(lim,0);

int dfs(int v){
    if(dp[v]) return dp[v];
    dp[v]=1;
    for(int u:adj[v]){
        if(dp[v]<dfs(u)+1){
            dp[v]=dp[u]+1;
        }
    }
    return dp[v];
}

int main(){
    int n,m;
    cin>>n>>m;
    while(m--){
        int x,y;
        cin>>x>>y;
        adj[x].push_back(y);
    }
    int ans = 0;
    for(int i=1;i<=n;i++){
        int path_len = dfs(i);
        if(ans<path_len){
            ans=path_len;
        }
    }
    cout<<ans-1;
    return 0;
}


Measured memory_bytes: 8192
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> v;
typedef pair<int,int>p;
typedef set<int>s;
#define ll long long
#define fr(i,a,b) for(int i=a;i<b;i++)
#define fre(i,a,b) for(int i=a;i<=b;i++)
#define FOR(i,a,b) for(int i=a;i>b;--i)
#define FORE(i,a,b) for(int i=a;i>=b;--i)
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define bg begin()
#define en end()
/*note

*/
int main()
{   int x,n,ans1,ans2,dif1,dif2,i,y,j;
    cin>>x>>n;
    if(n==0){cout<<x<<endl; return 0;}
    int ar[2000]={0};
    for(int i=0;i<n;i++){
        cin>>y;ar[y]=1;
    }
    i=x;
    j=x;
    while(1){

        if(ar[i]==0){dif1=abs(x-i); ans1=i; break;}
        --i;
    }
    while(1){
        if(ar[j]==0){dif2=abs(x-j);ans2=j; break;}
        ++j;
    }
    if(dif1==dif2)cout<<min(ans1,ans2)<<endl;
    else if(dif1<dif2)cout<<ans1<<endl;
    else cout<<ans2<<endl;








}



Measured memory_bytes: 3624
#include<stdio.h>
int main(){
    int n, d;
    scanf("%d%d",&n,&d);
    if(n % (2 * d + 1) == 0)
        printf("%d\n",n / (2 * d + 1));
    else
        printf("%d\n",n / (2 * d + 1) + 1);
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define endl "\n"
#define se second
#define ls( s) (s&(-s))
#define ll long long
const int N = 3000300;
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
const int mod =    1e9+7;

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

int n;
cin>>n;
string s;
cin>>s;
if((n%2))
{
	cout<<"No";
	return 0;
}
string ss =s.substr(0,n/2);
string sss=s.substr(n/2,n/2);
if(ss==sss)
cout<<"Yes";
else
cout<<"No";

}

Measured memory_bytes: 256
a , b , c , x , y = map(int , input().split())
if a / 2 + b / 2 >= c:
  ans = min(x , y) * 2 * c 
  if x > y:
    ans += (x - y) * a
  elif x < y:
    ans += (y - x) * b
else:
  ans = a * x + b * y
print(ans if c * max(x , y) * 2 > ans else  c * max(x , y) * 2)

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

int main() {

  int a,b;
  cin>>a>>b;


  if((a>=1&&a<=9)&&(b>=1&&b<=9))
    cout<<a*b<<endl;
  else
    cout<<-1<<endl;
  
  return 0;
}


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

#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define fastt ios_base::sync_with_stdio(false); cin.tie(NULL)

typedef long long ll;
typedef pair<ll,ll> pii;

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

int main(){
   fastt;

   int n,w;
   cin>>n>>w;

   int weight[n+1];
   int val[n+1];
   ll value[100001];

   memset(weight,0,sizeof(weight));
   memset(val,0,sizeof(val));
   memset(value,0,sizeof(value));

   for(int i=1;i<=n;i++){
      cin>>weight[i]>>val[i];
   }

   for(ll i=1;i<=n;i++){
      for(ll j=100000;j>=val[i];j--){
          if(value[j-val[i]]==0&&(j-val[i])!=0)
            continue;
          if(value[j-val[i]]+weight[i]>w)
            continue;
          if(value[j]==0)
            value[j]=value[j-val[i]]+weight[i];
          else
            value[j]=min(value[j],value[j-val[i]]+weight[i]);
      }
   }

   int ans;

   for(int i=0;i<=100000;i++)
      if(value[i]!=0)
        ans=i;

   cout<<ans<<endl;

   return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define MAX 100005
#define INF (1e9+1)

int n,W;
int dp[MAX];

int main(){
  fill(dp,dp+MAX,-INF);
  dp[0]=0;
  
  cin>>n>>W;
  for(int i=0;i<n;i++){
    int v,w,m;
    cin>>v>>w>>m;

    for(int k=0;k<=30;k++){
      int key=(1<<k);
      if( key <= m ){
        m-=key;
        int nv=key*v;
        int nw=key*w;
        for(int j=W;j>=nw;j--){
          dp[j]=max(dp[j],dp[j-nw]+nv);
        }
      }else{
        key=m;
        int nv=key*v;
        int nw=key*w;
        for(int j=W;j>=nw;j--){
          dp[j]=max(dp[j],dp[j-nw]+nv);
        }
        break;
      }

    }
    
  }
  int ans=0;
  for(int i=0;i<=W;i++)
    ans=max(ans,dp[i]);
  cout<<ans<<endl;
  return 0;
}

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

h=list(map(int,input().split()))

#初期化
dp=[float('inf') for i in range(N)]
dp[0]=0

#DP
for i in range(N-1):
  if dp[i+1] > dp[i]+abs(h[i+1]-h[i]):
    dp[i+1]=dp[i]+abs(h[i+1]-h[i])
  if i!= N-2:
    if dp[i+2] > dp[i]+abs(h[i+2]-h[i]):
      dp[i+2]=dp[i]+abs(h[i+2]-h[i])
      
print(dp[N-1])

Measured memory_bytes: 88728
a, b = gets.split.map(&:to_i)

c = b-a
for i in 1..1000 do
  j = i+1
    if j*(j+1)/2 - i*(i+1)/2 == c && i*(i+1)/2 > a && j*(j+1)/2 > b then
      puts i*(i+1)/2 - a
    end

end


Measured memory_bytes: 1788
#include<iostream>
using namespace std;
int main()
{
    int n, count = 0, i, j, x;
    cin >> n;
    int arr[n];
    for(i=0; i<n; i++)
    {
        cin >> arr[i];
    }
    for(i=0; i<n; i++)
    {
        for(j=n-1; j>i; j--)
        {
            if(arr[i] > arr[j])
            {
                x = arr[i];
                arr[i] = arr[j];
                arr[j] = x;
                count++;
            }
        }
    }
    if(count <= 1)
        cout << "YES" << endl;
    else
        cout << "NO" << endl;
}


Measured memory_bytes: 256