akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#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 <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <climits>

#define rep(i, m, n) for(int i=int(m);i<int(n);i++)
#define EACH(i, c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s, e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

//#define LOCAL 0
//#ifdef LOCAL
//#define DEBUG(s) cout << (s) << endl
//#define dump(x)  cerr << #x << " = " << (x) << endl
//#define BR cout << endl;
//#else
//#define DEBUG(s) do{}while(0)
//#define dump(x) do{}while(0)
//#define BR
//#endif


//改造
typedef long long int ll;
using namespace std;
#define INF (1 << 30) - 1
#define INFl (ll)5e15
#define DEBUG 0 //デバッグする時1にしてね
#define dump(x)  cerr << #x << " = " << (x) << endl
#define MOD 1000000007
//ここから編集する


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

    int H, W, D;
    cin >> H >> W >> D;
//    vector<vector<int> A(H,vector<int>(W));
    vector<pair<int, int> > mat(H * W + 1);
    rep(i, 0, H) {
        rep(j, 0, W) {
            int A;
            cin >> A;
            mat[A] = pair<int, int>(i, j);
        }
    }
    vector<vector<ll> > rui(D, vector<ll>(H * W / D + 1));
    rep(i, 1, H * W + 1) {

        if (i - D >= 0) {
            ll x = abs(mat[i].first - mat[i - D].first);
            ll y = abs(mat[i].second - mat[i - D].second);
            rui[i % D][i / D] = x + y;
        }
    }
    rep(i, 0, D) {
        rep(j, 1, rui[i].size()) {
            rui[i][j] += rui[i][j - 1];
        }
    }


    int Q;
    cin >> Q;
    rep(i, 0, Q) {
        int L, R;
        cin >> L >> R;
//        int ans = 0;
//        for (int j = L; j < R; j += D) {
//            int x = abs(mat[j + D].first - mat[j].first);
//            int y = abs(mat[j + D].second - mat[j].second);
//            ans += (x + y);
//        }
//        cout << ans << endl;
        int k = L % D;
        if (L / D == 0) {
            cout << rui[k][(R - k) / D] << endl;
        } else {
            cout << rui[k][(R - k) / D] - rui[k][(L - k) / D] << endl;
        }
    }


    return 0;
}


Measured memory_bytes: 6016
K,A,B = map(int,input().split())

if B-A < 3:
    print(K+1)
else:
    if A > K-1:
        print(K+1)
    else:
        count = K-A+1
        shou = count//2
        if count%2 == 1:
            print(A+(B-A)*shou+1)
        else:
            print(A+(B-A)*shou)

Measured memory_bytes: 61920
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n) FOR(i,0,n)
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define PB push_back
typedef vector<ll> vi;
typedef vector<vector<ll>> vvi;
typedef pair<ll,ll> pii;
typedef vector<pii> vpii;
typedef pii point;
using namespace std;

int main(){
  ll N; cin>>N;
  vi t(N),x(N),y(N);
  REP(i,N) cin>>t[i]>>x[i]>>y[i];
  ll a=0,b=0,c=0;
  REP(i,N){
    ll dist=abs(x[i]-a)+abs(y[i]-b);
    if(dist>t[i]-c||(t[i]-c)%2!=dist%2){
      cout<<"No"<<endl;
      return 0;
    }
  }
  cout<<"Yes"<<endl;
}


Measured memory_bytes: 2560
from bisect import bisect_left

MOD = 10 ** 9 + 7

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

A.sort()

n = bisect_left(A, 0) #負の数の個数
p = N - bisect_left(A, 0.5)
z = N - n - p

if K == 1: #一つだけ選ぶ-->最大の値を選べば良い
    print (A[-1] % MOD)
    exit()

if n + p < K: #正の数と負の数だけでは足りない-->必ず0になる　(0　を選ばざる得ない)
    print (0)
    exit()

i = 0 #負の数をどこから取るか
j = N - 1 #正の数をどこから取るか

if p >= 1: #正の数が一つ以上ある-->掛けた数を正に調整することができる
    if K % 2 == 0: #2つずつセット
        ans = 1
    else:
        ans = A[-1]
        j -= 1
        K -= 1
    
    k = K // 2
    for _ in range(k):
        if A[i] * A[i + 1] < A[j - 1] * A[j]:
            ans = (((ans * A[j - 1]) % MOD) * A[j]) % MOD
            j -= 2
        else:
            ans = (((ans * A[i]) % MOD) * A[i + 1]) % MOD
            i += 2
else:
    if K % 2 == 0: #正にすることができる -->最終的にプラスになるなら絶対値が大きいやつから使うべき
        ans = 1
        for i in range(K):
            ans = (ans * A[i]) % MOD
    else: #正にすることができない -->最終的にマイナスになるなら絶対値が小さいやつから使うべき
        ans = 1
        for i in range(K):
            ans = (ans * (A[N - 1 - i])) % MOD

print (ans % MOD)

Measured memory_bytes: 31736
/*
AuThOr GaRyMr
*/
#include<bits/stdc++.h>
#define rb(a,b,c) for(int a=b;a<=c;++a)
#define rl(a,b,c) for(int a=b;a>=c;--a)
#define LL long long
#define IT iterator
#define PB push_back
#define II(a,b) make_pair(a,b)
#define FIR first
#define SEC second
#define FREO freopen("check.out","w",stdout)
#define rep(a,b) for(int a=0;a<b;++a)
#define KEEP while(1)
#define SRAND mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define random(a) rng()%a
#define ALL(a) a.begin(),a.end()
#define POB pop_back
#define ff fflush(stdout)
#define fastio ios::sync_with_stdio(false)
using namespace std;
const int INF=0x3f3f3f3f;
typedef pair<int,int> mp;
typedef pair<mp,mp> superpair;
map<LL,int> M;
int main(){
	fastio;
	LL n,m;
	cin>>n>>m;
	string s,t;
	cin>>s>>t;
	swap(s,t);
	LL res=n*m/__gcd(n,m);
	LL now=1;
	rb(i,1,m){
		
//		cout<<now<<endl;
		M[now]=(int)(s[i-1]-'a'+1);now+=res/m;
	}
	now=1;
	rb(i,1,n){
		
		if(M[now]){
//			cout<<now<<endl;
			if(M[now]!=(int)(t[i-1]-'a'+1)){
				cout<<-1<<endl;
				return 0;
			}
		}now+=res/n;
	}
	cout<<res<<endl;
	return 0;
}


Measured memory_bytes: 10880
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

//INSERT ABOVE HERE
signed main(){
  Int n,l;
  cin>>n>>l;
  vector<Int> ps(n),ds(n);
  for(Int i=0;i<n;i++) cin>>ps[i]>>ds[i];
  {
    using P = pair<Int, Int>;
    vector<P> vp;
    for(Int i=0;i<n;i++) vp.emplace_back(ps[i],ds[i]);
    sort(vp.begin(),vp.end());
    for(Int i=0;i<n;i++) tie(ps[i],ds[i])=vp[i];
  }

  // dp[i] : [0, i)
  vector<Int> dp(n+1,0);
  for(Int i=0;i<n;i++){
    Int dif=(i+1)-ps[i];
    Int cst=dif*(ds[i]==0?-1:1);
    dp[i+1]=dp[i]+cst;
  }

  // pd[i] : [i, n)
  vector<Int> pd(n+1,0);
  for(Int i=n-1;i>=0;i--){
    Int dif=(l-n)+(i+1)-ps[i];
    Int cst=dif*(ds[i]==0?-1:1);
    pd[i]=pd[i+1]+cst;
  }

  Int ans=0;
  for(Int i=0;i<=n;i++) chmax(ans,dp[i]+pd[i]);
  cout<<ans<<endl;
  return 0;
}



Measured memory_bytes: 6420
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <cmath>
#include <iomanip>
#include <bitset>
#include <string>
#include <stdlib.h>
using namespace std;
//cout <<  << endl;
typedef long long int ll;
typedef long double ld;

//境界値に注意！！！

int main() {
    ll n,ans=0;
    cin >> n;
    for (ll i=0;i<n;++i){
        ll a,b;
        cin >> a >> b;
        ans+=b-a+1;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#define popcount __builtin_popcount
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const ll MOD=998244353;
ll powmod(ll a, ll k){
    ll ap=a, ans=1;
    while(k){
        if(k&1){
            ans*=ap;
            ans%=MOD;
        }
        ap=ap*ap;
        ap%=MOD;
        k>>=1;
    }
    return ans;
}
ll inv(ll a){
	return powmod(a, MOD-2);
}
ll f[5000001], invf[5000001];
void fac(int n){
    f[0]=1;
    for(ll i=1; i<=n; i++) f[i]=f[i-1]*i%MOD;
    invf[n]=inv(f[n]);
    for(ll i=n-1; i>=0; i--) invf[i]=invf[i+1]*(i+1)%MOD;
}
ll comb(int x, int y){
    if(!(0<=y && y<=x)) return 0;
    return f[x]*invf[y]%MOD*invf[x-y]%MOD;
}
int main()
{
    int n, m; cin>>n>>m;
    fac(3*m+n);
    ll ans=0;
    for(int i=0; i<=m; i++){
        if((m-i)%2!=0) continue;
        int l=(3*m-i)/2;
        (ans+=comb(n, i)*comb(l+n-1, n-1))%=MOD;
        (ans+=MOD-i*comb(n, i)%MOD*comb(l-m+n-1, n-1)%MOD)%=MOD;
        (ans+=MOD-(n-i)*comb(n, i)%MOD*comb(l-m-1+n-1, n-1)%MOD)%=MOD;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 41216
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#define int long long
using namespace std;
int n, m, a[345678], a1[345678], b[345678], c, d;
signed main() {
	cin >> n;
	for (int i = 1; i <= n; i++)cin >> a[i];
	sort(a + 1, a + n + 1);
	for (int i = 1; i <= n; i++)a1[i] = a1[i - 1] + a[i];
	cin >> m;
	for (int i = 0; i < m; i++)cin >> b[i];
	for (int i = 0; i < m; i++) {
		cin >> c;
		if (a[n] <= b[i])d = a1[n];
		else if (b[i] < a[1])d = 0;
		else {
			int e = 1, f = n;
			while (f - e > 1) {
				int mid = (f + e) / 2;
				if (b[i] < a[mid])f = mid;
				else e = mid;
			}
			d = a1[e];
		}
		cout << (c <= d ? "Yes\n" : "No\n");
	}
}


Measured memory_bytes: 9784
#include "bits/stdc++.h"
using namespace std;
typedef long long LL;
typedef pair<int, int> P;
typedef pair<int, P> E;
const LL MOD = 1000000007LL;
int X[100000];
int main() {
	int N;
	cin >> N;
	LL A, B;
	cin >> A >> B;
	for (int i = 0; i < N; i++) cin >> X[i];
	LL sum = 0;
	for (int i = 0; i + 1 < N; i++) {
		sum += min((X[i + 1] - X[i])*A, B);
	}
	cout << sum << endl;
}

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

int main(){
    int A, B, C, D, E;
    cin >> A; cin >> B; cin >> C; cin >> D; cin >> E;
    int pre_temp = A;
    int sum_time = 0;
    if (A <= -1){
        sum_time += -(pre_temp)*C;
        pre_temp = 0;
    }
    if (pre_temp == 0){
        sum_time += D;
    }

    cout << sum_time + (B - pre_temp)*E << endl;
}


Measured memory_bytes: 3100
"""
    Template written to be used by Python Programmers.
    Use at your own risk!!!!
    Owned by enraged(rating - 5 star at CodeChef and Specialist at Codeforces).
"""
import sys
from functools import lru_cache, cmp_to_key
from heapq import merge, heapify, heappop, heappush, nlargest, nsmallest, _heapify_max, _heapreplace_max
from math import ceil, floor, gcd, fabs, factorial, fmod, sqrt, inf, log
from collections import defaultdict as dd, deque, Counter as c
from itertools import combinations as comb, permutations as perm
from bisect import bisect_left as bl, bisect_right as br, bisect
from fractions import Fraction
# sys.setrecursionlimit(2*pow(10, 6))
# sys.stdin = open("input.txt", "r")
# sys.stdout = open("output.txt", "w")
mod = pow(10, 9) + 7
mod2 = 998244353
def data(): return sys.stdin.readline().strip()
def out(var): sys.stdout.write(str(var))
def outln(var): sys.stdout.write(str(var)+"\n")
def l(): return list(sp())
def sl(): return list(ssp())
def sp(): return map(int, data().split())
def ssp(): return map(str, data().split())
def l1d(n, val=0): return [val for i in range(n)]
def l2d(n, m, val=0): return [l1d(n, val) for j in range(m)]


s, w = sp()
if s > w:
    outln("safe")
    exit()
outln("unsafe")


Measured memory_bytes: 72820
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
const int mod=1e9+7;

int h,w;
char math[1010][1010];
vector<pair<int,int>> black;
bool flag = true;


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

//BFS
int bfs(vector<vector<int>> depth){
    queue<pair<int,int>> que;
    int ans = 0;

    for(int i = 0; i < black.size(); i++){
        que.push(black[i]);
    }
 
    while(!que.empty()){
        pair<int,int> nw = que.front(); que.pop();
        for(int i = 0; i < 4; i++){
            if(0 <= nw.first+dy[i] && nw.first+dy[i] < h && 0 <= nw.second+dx[i] && nw.second+dx[i] < w){
                pair<int,int> nxt = make_pair(nw.first+dy[i],nw.second+dx[i]);
                if((depth[nxt.first][nxt.second] > depth[nw.first][nw.second]+1 || depth[nxt.first][nxt.second] == 0) && math[nxt.first][nxt.second] != '#'){
                    que.push(nxt);
                    depth[nxt.first][nxt.second] = depth[nw.first][nw.second]+1;
                    ans = max(ans,depth[nxt.first][nxt.second]);
                }
            }
        }
    }
    return ans;
}


int main(){
    cin >> h >> w;
    int cnt = 0;
    int ans = 0;
    vector<vector<int>> depth(h);

    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            cin >> math[i][j];
            if(math[i][j] == '#') black.push_back(make_pair(i,j));
            depth[i].push_back(0);
        }
    }

    cout << bfs(depth) << endl;
}

Measured memory_bytes: 25264
#include <iostream>
#include <algorithm>

using namespace std;

#define MAX_N 50

// 入力
int N, A, B;
long long v[MAX_N];

long long C[51][51];

void comb_table(int N) {
    for (int i = 0; i <= N; ++i) {
        for (int j = 0; j <= i; ++j) {
            if (j == 0 || j == i) {
                C[i][j] = 1LL;
            } else {
                C[i][j] = (C[i - 1][j - 1] + C[i - 1][j]);
            }
        }
    }
}

int main(void) {
    cin >> N >> A >> B;
    for (int i = 0; i < N; ++i) {
        cin >> v[i];
    }

    comb_table(N);
    sort(v, v + N);
    reverse(v, v + N);

    long double max_average = 0.0;
    for (int i = 0; i < A; ++i) {
        max_average += v[i];
    }
    max_average /= A;

    int a_th_val_num = 0, a_th_val_pos = 0;
    for (int i = 0; i < N; ++i) {
        if (v[i] == v[A - 1]) {
            a_th_val_num++;
            if (i < A) {
                a_th_val_pos++;
            }
        }
    }

    long long cnt = 0LL;
    if (a_th_val_pos == A) {
        for (a_th_val_pos = A; a_th_val_pos <= B; ++a_th_val_pos) {
            cnt += C[a_th_val_num][a_th_val_pos];
        }
    } else {
        cnt += C[a_th_val_num][a_th_val_pos];
    }

    cout.precision(20);
    cout << fixed << max_average << endl;
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 256
/***********************
*  Author: xuziyuan    * 
***********************/

#include <bits/stdc++.h>

#define rt0 return 0
#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
#define replet(c) for(char c='a';c<='z';c++) 
#define LL long long
#define pii pair <int,int>
#define pb push_back
#define fi first
#define se second
#define mpr make_pair
#define sqr(a) ((a)*(a))

using namespace std;

const LL MOD=1e9+7;

double n,m,x,y;

int main()
{
	cin>>n>>m>>x>>y;
	cout<<n*m/2<<' '<<(x*2==n&&y*2==m ? 1:0)<<endl;
	rt0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#pragma warning(disable: 4244) // 最悪をします
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <numeric>
#include <queue>
#include <stack>
#include <map> 
#include <set>
#include <string>
#include <functional>
#include <list>
#include <random>
#include <time.h>
#include <iomanip>
#include <assert.h>
#include <numeric>
#include <sstream>
#define BIT(nr) (1UL << (nr))
#define int long long
//#define ll long long
#define double long double
#define mod 1000000007
#define MAXN (int)1e+5 * 2+1
#define LL_MAX 9223372036854775807	//ない環境用
#define LL_HALFMAX 9223372036854775807 / 2	//ない環境用
#define MIN -(9223372036854775807 / 2)
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
#define REPS(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREPS(i,x) for(int i=((int)(x));i>0;i--)
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define mp make_pair
template<typename T1, typename T2> inline void chmin(T1 & a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1& a, T2 b) { if (a < b) a = b; }


using namespace std;

//デバッグ用カッコの有無
#ifdef DEBUG
template <class T>ostream &operator<<(ostream &o, const vector<T>&v)
{
	o << "{"; for (int i = 0; i<(int)v.size(); i++)o << (i>0 ? ", " : "") << v[i]; o << "}"; return o;
}
#endif // DEBUG

template <class T>ostream &operator<<(ostream &o, const vector<T>&v)
{
	for (int i = 0; i<(int)v.size(); i++)o << (i>0 ? " " : "") << v[i]; return o;
}

int dx[4] = { 0, 1, 0, -1 }; // x軸方向への変位
int dy[4] = { 1, 0, -1, 0 }; // y軸方向への変位

int dxp[4] = { 0, 1 }; // x軸方向への変位(正のみ)
int dyp[4] = { 1, 0 }; // y軸方向への変位(負のみ)

using Weight = int;
using Flow = int;
struct Edge {
	int src, dst;

	// libalgo のものに追加、メンバを追加するだけなので互換性は崩さないはず、逆辺のG[e.dstの]インデックスを保持
	int rev;
	Weight weight;
	Flow cap;
	Edge() : src(0), dst(0), weight(0) {}
	Edge(int s, int d, Weight w) : src(s), dst(d), weight(w) {}
};
using Edges = std::vector<Edge>;
using Graph = std::vector<Edges>;
using Array = std::vector<Weight>;
using Matrix = std::vector<Array>;

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

void solve() {

}

int dp[110][10010];

signed main() {
	int N, W;
	cin >> N >> W;
	vector<int> v(N + 1, 0), w(N + 1, 0);

	REPS(i, N) {
		cin >> v[i] >> w[i];
	}

	rep(i, 110) rep(j, 1010) {
		dp[i][j] = -LL_HALFMAX;
	}

	dp[0][0] = 0;

	REPS(i, N) {
		rep(j, W + 1) {
			if (j - w[i] >= 0) {
				chmax(dp[i][j], dp[i - 1][j - w[i]] + v[i]);
			}
			chmax(dp[i][j], dp[i - 1][j]);
		}
	}

	int ans = 0;
	rep(j, W + 1) {
		chmax(ans, dp[N][j]);
	}

	cout << ans << "\n";

}



Measured memory_bytes: 10960
N = int(input())
s = input()

T = ['' for _ in range(N+1)]
for T[0],T[1] in [['S','S'],['S','W'],['W','S'],['W','W']]:
  for i in range(2,N+1):
    if (T[i-1] == 'S' and s[i-1] == 'o') or (T[i-1] == 'W' and s[i-1] == 'x'):
      T[i] = T[i-2]
    else:
      if T[i-2] == 'S':
        T[i] = 'W'
      else:
        T[i] = 'S'
  #print(T)
  if (T[0] == T[N]) and ((T[0] == 'S' and s[0] == 'o' and T[1] == T[N-1]) or (T[0] == 'S' and s[0] == 'x' and T[1] != T[N-1]) or (T[0] == 'W' and s[0] == 'o' and T[1] != T[N-1]) or (T[0] == 'W' and s[0] == 'x' and T[1] == T[N-1])):
    print(''.join(T[:N]))
    exit()
print(-1)

Measured memory_bytes: 45296
num = input()

for pattern in range(8):
    base = int(num[0])
    formula = num[0]
    for bit in range(3):
        if (pattern >> bit) & 1:
            base += int(num[bit+1])
            formula = formula + '+' + num[bit+1]
        else:
            base -= int(num[bit+1])
            formula = formula + '-' + num[bit+1]

    if base == 7:
        print(formula + '=7')
        exit()



Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("O3")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

//  const int MOD = 1e9 + 7;

//unsigned seed1= chrono::system_clock::now().time_since_epoch().count();
//mt19937 rng (seed1);


int main(){
  ios::sync_with_stdio(0);
  cin.tie(0);
 
  string s;
  cin >> s;
  if( s ==  "SUN"){
    cout << 7 << endl;
  } else if( s == "MON"){
    cout << 6 << endl;
  } else if( s == "TUE"){
    cout << 5 << endl;
  } else if( s == "WED"){
    cout << 4 << endl;
  } else if( s == "THU"){
    cout << 3 << endl;
  }else if( s == "FRI"){
    cout << 2 << endl;
  }else if( s == "SAT"){
    cout << 1 << endl;
  }
      
  return 0;
}

Measured memory_bytes: 256
from collections import deque

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

A.sort(reverse=True)
X=deque([A[0]])

K=0
for b in A[1:]:
    a=X.popleft()
    K+=a
    X.append(b)
    X.append(b)

print(K)


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

a=[int(x) for x in input().split()]

a.sort()

c=b=0

for i in range(n-1):
  if(a[-i-1]==a[-i-2]):
    a[-i-2]=0
    if b==0:
      b=a[-i-1]
    else:
      c=a[-i-1]
      break
      
print(b*c)

Measured memory_bytes: 14252
#include<bits/stdc++.h>
using namespace std;
int n,now,ans;
char c;
int main()
{
    cin>>n;
    for(int s=0;s<n;s++)
    {
        cin>>c;
        if(c=='I')now++;
        else now--;
        ans=max(ans,now);
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define F first
#define S second
using namespace std;
using ll = long long;
typedef pair<int, int> P;
ll Mod = 1000000007;
int main() {
  int N; ll M;
  cin >> N >> M;
  ll A[N];
  ll R[N+1];
  for (int i = 0; i < N; i++) {
    cin >> A[i];
  }
  sort(A,A+N);
  R[N] = 0;
  R[N-1] = A[N-1];
  for (int i = N-2; i >= 0; i--) {
    R[i] = R[i+1] + A[i];
  }
  int left = 0;
  int right = 220000;
  ll leftres = 0;
  ll rightres = 0;
  ll leftcnt = 0;
  ll rightcnt = 0;
  while (right - left > 1) {
    int mid = (left + right) / 2;
    ll cnt = 0;
    ll res = 0;
    for (int i = 0; i < N; i++) {
      ll s = (A+N) - lower_bound(A,A+N,mid-A[i]);
      cnt += s;
      res += R[N-s];
      res += A[i] * s;
    }
    if (cnt >= M) {
      left = mid;
      leftres = res;
      leftcnt = cnt;
    } else {
      right = mid;
      rightres = res;
      rightcnt = cnt;
    }
  }
  ll ans = rightres + (left * (M - rightcnt));
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 5152
#include<iostream>
using namespace std;
static const int MAX = 100;
static const int INFTY = (1 << 21);
static const int WHITE = 0;
static const int GRAY = 1;
static const int BLACK = 2;

int n, M[MAX][MAX];

int prim() {
    int u, minv;
    int d[MAX], p[MAX], color[MAX];

    for (int i = 0; i < n; i++) {
        d[i] = INFTY;
        p[i] = -1;
        color[i] = WHITE;
    }

    d[0] = 0;

    while (1) {
        minv = INFTY;
        u = -1;
        for (int i = 0; i < n; i++) {
            if (minv > d[i] && color[i] != BLACK) {
                u = i;
                minv = d[i];
            }
        }
        if (u == -1) break;
        color[u] = BLACK;
        for (int v = 0; v < n; v++) {
            if (color[v] != BLACK && M[u][v] != INFTY) {
                if (d[v] > M[u][v]) {
                    d[v] = M[u][v];
                    p[v] = u;
                    color[v] = GRAY;
                }
            }
        }
    }
    int sum = 0;
    for (int i = 0; i < n; i++) {
        if (p[i] != -1) sum += M[i][p[i]];
    }

    return sum;
}

int main() {
    cin >> n;

    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            int e; cin >> e;
            M[i][j] = (e == -1) ? INFTY : e;
        }
    }

    cout << prim() << endl;

    return 0;
}


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

int main() {
    string c1,c2;
    cin >> c1 >> c2;

    rep(i,3)
        if(c1.at(i) != c2.at(2-i)) {
            cout << "NO" << endl;
            return 0;
        }
    
    cout << "YES" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

//INSERT ABOVE HERE

signed main(){
  Int X[3][3]={};
  cin>>X[0][0]>>X[0][1]>>X[1][1];
  X[2][0]=X[0][0]+X[0][1]-X[1][1];
  X[1][2]=X[0][0]+X[2][0]-X[1][1];
  X[0][2]=X[0][0]+X[1][1]-X[1][2];

  Int sum=X[0][0]+X[0][1]+X[0][2];
  X[1][0]=sum-X[0][0]-X[2][0];
  X[2][1]=sum-X[0][1]-X[1][1];
  X[2][2]=sum-X[0][2]-X[1][2];

  for(Int i=0;i<3;i++){
    for(Int j=0;j<3;j++){
      if(j) cout<<" ";
      cout<<X[i][j];
    }
    cout<<endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <utility>
#include <queue>
#include <set>
#include <map>

using namespace std;
typedef  long long ll;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
#define  MP make_pair
#define  PB push_back
#define inf  1000000007
#define rep(i,n) for(int i=0;i<(int)(n);++i)

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}


int main(){
    int n,k;
    cin >> n >> k;
    vector<vector<int> > v(n);
    vector<pair<int,int> > g;
    for(int i=0;i<n-1;i++){
        int a,b;
        cin >> a >> b;
        a--;
        b--;
        v[a].push_back(b);
        v[b].push_back(a);
        g.push_back(MP(a,b));
    }
    if(k%2==0){
        int mx = 0;
        for(int i=0;i<n;i++){
            vector<bool> flag(n);
            flag[i] = 1;
            queue<pair<int,int> > q;
            q.push(MP(i,0));
            int tmp=1;
            while(!q.empty()){
                auto x = q.front();
                q.pop();
                if(x.second==(k/2))break;
                for(int i=0;i<v[x.first].size();i++){
                    if(!flag[v[x.first][i]]){
                        flag[v[x.first][i]] = 1;
                        q.push(MP(v[x.first][i],x.second+1));
                        tmp++;
                    }
                }
            }
            mx = max(mx,tmp);
        }
        cout << n-mx << endl;
    }else{
        int mx = 0;
        for(int i=0;i<n-1;i++){
            vector<bool> flag(n);
            flag[g[i].first] = 1;
            flag[g[i].second] = 1;
            queue<pair<int,int> > q;
            q.push(MP(g[i].first,0));
            q.push(MP(g[i].second,0));
            int tmp=2;
            while(!q.empty()){
                auto x = q.front();
                q.pop();
                if(x.second==(k/2))break;
                for(int i=0;i<v[x.first].size();i++){
                    if(!flag[v[x.first][i]]){
                        flag[v[x.first][i]] = 1;
                        q.push(MP(v[x.first][i],x.second+1));
                        tmp++;
                    }
                }
            }
            mx = max(mx,tmp);
        }
        cout << n-mx << endl;
    }

    return 0;
}

Measured memory_bytes: 384
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <map>
#include <unordered_map>
#include <queue>
#include <deque>
#include <string>
#include <stack>
#include <vector>
#include <set>
#include <tuple>
#include <utility>
#include <functional>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
const int INF = 1000000000;
const long long INFL = 2e18;
const int MOD = 1000000007;
int main(){
	string s;
	cin >> s;

	if(s[s.size()-1] != 's')cout << s + 's' << endl;
	else cout << s + "es" << endl;
}


Measured memory_bytes: 3632
void main() {
	auto R = readAs!real;
	writeln(2*R*PI);
}

// ===================================

import std.stdio;
import std.string;
import std.functional;
import std.algorithm;
import std.range;
import std.traits;
import std.math;
import std.container;
import std.bigint;
import std.numeric;
import std.conv;
import std.typecons;
import std.uni;
import std.ascii;
import std.bitmanip;
import core.bitop;

T readAs(T)() if (isBasicType!T) {
	return readln.chomp.to!T;
}
T readAs(T)() if (isArray!T) {
	return readln.split.to!T;
}

T[][] readMatrix(T)(uint height, uint width) if (!isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		res[i] = readAs!(T[]);
	}
	return res;
}

T[][] readMatrix(T)(uint height, uint width) if (isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		auto s = rs;
		foreach(j; 0..width) res[i][j] = s[j].to!T;
	}
	return res;
}

int ri() {
	return readAs!int;
}

double rd() {
	return readAs!double;
}

string rs() {
	return readln.chomp;
}

Measured memory_bytes: 2996
#include<algorithm>
#include<iostream>
#include<string>

int N;
std::string S;

int main()
{
	std::cin >> S;
	N = S.size();

	int ans = 0;
	int i = 0;
	while( i < N )
	{
		int cntJ = 0, cntO = 0, cntI = 0;
		for( ; S[i+cntJ] == 'J'; ++cntJ );
		i += cntJ;
		for( ; S[i+cntO] == 'O'; ++cntO );
		i += cntO;
		for( ; S[i+cntI] == 'I'; ++cntI );
		i += cntI;

		if( cntJ >= cntO && cntO <= cntI )
			ans = std::max( ans, cntO );
	}

	std::cout << ans << std::endl;

	return 0;
}

Measured memory_bytes: 2052
#include <bits/stdc++.h>
using namespace std;
#define int long long

const int MOD = 1e9+7;

signed main() {
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    int N;
    cin >> N;
    vector<int> A(N);
    for (int i = 0; i < N; i++) {
        cin >> A[i];
    }
    // それぞれと別のやつとのXORのやつを取って, / 2すればいい.
    // bitごとに計算できる
    // 0 ^ 0 = 0, 1 ^ 1 = 0, 1 ^ 0 = 1
    // よって　(各ビットの0の数*1の数 + 1の数*0の数) / 2

    int res = 0;
    for (int bit = 0; bit < 60; bit++) {
        int one = 0;
        for (int i = 0; i < N; i++) {
            one += (A[i] >> bit) & 1;
        }
        int tmp = one * (N - one) % MOD;
        (tmp *= (1LL << bit) % MOD) %= MOD;
        res += tmp;
        res %= MOD;
    }
    cout << res % MOD << endl;
    return 0;
}

Measured memory_bytes: 2560
import java.util.*;

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

        int n = sc.nextInt();
        int k = sc.nextInt();
        int[] a = new int[n+1];
        for (int i=0; i < n; i++) a[i] = sc.nextInt();
        a[n] = k;

        Arrays.sort(a);

        int left = 0;
        int right = n;
        while (true) {
            int i = (left+right)/2;
            boolean[][] dp = new boolean[n+1][k+1];
            dp[0][0] = true;

            for (int j = 0; j < n; j++) {
                for (int l = 0; l <= k; l++) {
                    if (dp[j][l]) {
                        dp[j+1][l] = true;
                        if (i != j && l+a[j] <= k) {
                            dp[j+1][l+a[j]] = true;
                        }
                    }
                }
            }

            boolean f = false;
            for (int j = Math.max(k-a[i], 0); j < k; j++) {
                if (dp[n][j]) f = true;
            }

            if (right == left + 1) {
                if (f) System.out.println(i);
                else System.out.println(i+1);
                break;
            }

            if (f) right = i;
            else left = i;
        }
    }
}

Measured memory_bytes: 216328
use proconio::input;

fn main() {
    input!(n: usize, k: u64, a: [u64; n]);
    let mut l = 0;
    let mut r = 1_000_000_000;
    while 1 < r - l {
        let c = (l + r) / 2;
        if a.iter().map(|&x| (x - 1) / c).sum::<u64>() <= k {
            r = c;
        } else {
            l = c;
        }
    }
    println!("{}", r);
}


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

using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;


#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))

int dx4[4] = {1,0,-1,0}, dy4[4] = {0,1,0,-1};


int main()
{
    int l,r,d;
    cin>>l>>r>>d;
    cout<<r/d-(l-1)/d<<endl;
    
    return 0;
}

Measured memory_bytes: 3592
#import heapq
from collections import deque

n = int(input())
s = [0] * n

for i in range(n):
    s[i] = int(input())

# a = list(map(lambda x: int(x) * (-1), input().split()))
'''
heapq.heapify(s)  # 優先度付きキューに。自動で最小値順に並ぶ。
while (sum(s) % 10 == 0):
    try:
        heapq.heappop(s)
    except IndexError:
        s = [0]
        break
'''
s = sorted(s)

if (sum(s) % 10 != 0):
    tar = sum(s)
else:
    for i, val in enumerate(s):
        tar = sum(s) - val
        if (tar % 10 != 0):
            break
        else:
            for j in range(i):
                tar -= s[j]
                if (tar % 10 != 0):
                    break

# ---------------
print(tar)


Measured memory_bytes: 3316
#include<bits/stdc++.h>
using namespace std;
//define
#define str string
#define rep(x,y) for(int i=x;i<y;i++)
#define REP(x,y) for(int j=x;j<y;j++)
#define all(x) x.begin(),x.end()
#define elif else if
//vectordefine
#define vint vector<int>
#define vc vector<char>
#define vtr vector<string>
#define pb(n) push_back(n)
//queuedefine
#define qint queue<int>
#define qc queue<char>
#define qstr queue<str>
//mapdefine
#define mint map<int>
#define mc map<char>
//pairdefine
#define pint pair<int,int>
#define pis pair<int,str>
#define pic pair<int,char>
#define pci pair<char,int>
#define mod 100000007
//main
signed main(){
  int N,M,O,P,count=0,count2=mod,count3=0,stack=0;
  str S,T;
  double l,s;
  cin>>N;
  vint p(N);
  rep(0,N){
    cin>>p[i];
  }
  rep(1,N-1){
    if(p[i]<p[i+1]&&p[i-1]<p[i])count+=1;
    elif(p[i]>p[i+1]&&p[i-1]>p[i])count+=1;
  }
  cout<<count<<endl;
}


Measured memory_bytes: 256
n, d = map(int, input().split())
x = []
cnt = 0
sum = 0
for _ in range(n):
    tmp = list(map(int, input().split()))
    x.append(tmp)

for i in range(n):
    for j in range(i + 1, n):
        sum = 0
        for k in range(d):
            sum += (x[i][k] - x[j][k]) ** 2
        distance = sum ** 0.5
        if distance.is_integer():
            cnt += 1

print(cnt)


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

minc = 100000000
for ct in CT:
    if ct[1] > T: continue
    newc = ct[0]
    if newc < minc: minc = newc

if minc == 100000000: print('TLE')
else: print(minc)

Measured memory_bytes: 3060
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <map>
#include <string>
using namespace std;
map<string, int> str;

char s[3][3];

int main() {
	scanf("%s %s %s", s[0], s[1], s[2]);
	printf("%c%c%c\n", s[0][0], s[1][1], s[2][2]);
	return 0;
}

Measured memory_bytes: 256
if (!String.prototype.padStart) {
    String.prototype.padStart = function padStart(targetLength,padString) {
        targetLength = targetLength>>0; //truncate if number or convert non-number to 0;
        padString = String((typeof padString !== 'undefined' ? padString : ' '));
        if (this.length > targetLength) {
            return String(this);
        }
        else {
            targetLength = targetLength-this.length;
            if (targetLength > padString.length) {
                padString += padString.repeat(targetLength/padString.length); //append to original to ensure we are longer than needed
            }
            return padString.slice(0,targetLength) + String(this);
        }
    };
}


function Main(input) {
  const data = input.split("\n")
  const a = data.shift().split(" ")
  const N = a[0]
    const M = a[1]
  const pref = []
  data.forEach( (d, i) => {
    if (d.length === 0) { return; }
    const x = d.split(" ")
      const I = x[0]
      const Y = x[1]
    var P = pref[I]
    if (P === undefined) {
      pref[I] = [[i,Y]]
    } else {
      P.push([i,Y])
    }
  })
  const r = [];

  pref.forEach( (p,pi) => {
    if (!Array.isArray(p)) { return;}
    p.sort( (a, b) => {
      const a1 = parseInt(a[1]), b1 = parseInt(b[1])
      return a1 > b1 ? 1 : a1 === b1 ? 0 : -1
    })
    p.forEach( (m, mi) => {
      r[m[0]] = ("" + pi).padStart(6, "0") + ("" + (mi + 1)).padStart(6, "0")
    })
  });

  console.log(r.join("\n"))


}

Main(require("fs").readFileSync("/dev/stdin", "utf8")); 

Measured memory_bytes: 86708
n = int(input())
h = list(map(int, input().split()))

dp = [0] * (n+1)
dp[2] = abs(h[1] - h[0])
for i in range(3, n+1):
    dp[i] = min(dp[i-1] + abs(h[i-1] - h[i-2]), dp[i-2] + abs(h[i-1] - h[i-3]))
print(dp[n])

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

int main() {
  int N, L;
  cin >> N >> L;
  int S=(N-1)*N/2+N*L;
  int m;
  if (L>0) {
    m=L;
  }
  else if (L<=0 && N+L-1>=0) {
    m=0;
  }
  else {
    m=N+L-1;
  }
  cout << S-m << endl;
}


Measured memory_bytes: 3640
#include <stdio.h>

int main(void)
{
  while(1)
    {
  int H,W;
  int flg=0;

  scanf("%d %d",&H,&W);

  if(H==0 && W==0)
    {
      break;
    }

  for(int y=0;y<H;y++)
    {
      for(int x=0;x<W;x++)
	{
	  if((x+flg)%2==0)
	    {
	      printf("#");
	    }
	  else
	    {
	      printf(".");
	    }

	  if(x==W-1)
	    {
	      printf("\n");

	      if(flg==0)
		{
		  flg=1;
		}
	      else
		{
		  flg=0;
		}
	    }
	}
    }
  printf("\n");
    }
  
  return 0;
}

Measured memory_bytes: 1000
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
using namespace std;
const int MOD = 1000000007;
const ll INF = 1LL << 60;
int main()
{
   cin.tie(0);
   ios::sync_with_stdio(false);
   int n;
   cin >> n;
   int count = 0;
   for (int i = 1; i <= n; i++)
   {
      for (int j = 1; j <= n; j++)
      {
         for (int k = 1; k <= n; k++)
         {
            int s = __gcd(j, k);
            int num = __gcd(i, s);

            count += num;
         }
      }
   }
   cout << count << endl;
}

Measured memory_bytes: 3652
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc=new Scanner(System.in);
    long N =sc.nextLong(); 
    long A =sc.nextLong();
    long B =sc.nextLong();
    long m =N/(A+B);
    long n=N%(A+B);
    if(n<A){System.out.println(m*A+n);}
    else{System.out.println((m+1)*A);}
  }
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
//#include <chrono>
//#pragma GCC optimize("Ofast")
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
#define ALL(a) a.begin(), a.end()
#define fi first
#define se second
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,Q,K,A,B;
string S;
typedef pair<ll, ll> P;
const ll INF = (1LL<<60);

/*
void dfs1(int n, mat &G, vec &level){
    int k(0);
    stack<int> sta;
    rep(i, n) {
        if(level[i] != -1) continue;
        level[i] = -2;
        sta.push(i);
        while (!sta.empty()) {
            int v = sta.top(); sta.pop();
            if (v < 0) {
                level[- v - 1] = k++;
            } else {
                sta.push(- v - 1);
                for (int to : G[v]) {
                    if (level[to] == -1) {
                        level[to] = -2;
                        sta.push(to);
                    }
                }
            }
        }
    }
}
 */

void dfs1(int v, int &k, mat &G, vec &level){
    level[v] = -2;
    for(int to : G[v]){
        if(level[to] == -1) dfs1(to, k, G, level);
    }
    level[v] = k++;
}

void dfs2(int n, mat &G, vector<bool> &used, vec &ord, mat &res){
    stack<int> sta;
    Rrep(i, n){
        int s = ord[i];
        if(!used[s]){
            used[s] = true;
            vec temp(0);
            sta.push(s);
            while(!sta.empty()){
                int v = sta.top(); sta.pop();
                used[v] = true;
                temp.push_back(v);
                for(int to : G[v]) {
                    if(!used[to]) {
                        used[to] = true;
                        sta.push(to);
                    }
                }
            }
            res.push_back(temp);
        }
    }
}
/*
void dfs2(int v, mat &G, vector<bool> &used, vec &res){
    used[v] = true;
    res.push_back(v);
    for(int to : G[v]) if(!used[to]) dfs2(to, G, used, res);
}
 */

void scc(mat &G, mat &res){
    int n = G.size();
    mat G_rev(n, vec(0));
    rep(u, n) rep(v, (int)G[u].size()) G_rev[G[u][v]].push_back(u);
    vec level(n, -1), ord(n);
    vector<bool> used(n, false);
    //dfs1(n, G, level);
    int k(0);
    rep(i, n) if(level[i] == -1) dfs1(i, k, G, level);
    rep(i, n) ord[level[i]] = i;
    dfs2(n, G_rev, used, ord, res);
    /*
    Rrep(i, n) {
        if(!used[ord[i]]) {
            vec temp(0);
            dfs2(ord[i], G_rev, used, temp);
            res.push_back(temp);
        }
    }
     */
}

int main() {
    cin>>N>>M;
    mat G(N, vec(0));
    rep(i,M){
        int a, b;
        scanf("%d%d", &a, &b);
        G[a].push_back(b);
    }
    mat scc_list(0);
    scc(G, scc_list);
    printf("%d\n", (int)scc_list.size());
    for(vec v : scc_list){
        int n = v.size();
        printf("%d ", n);
        rep(i, n) printf("%lld%c", v[i], " \n"[i == n - 1]);
    }
}


Measured memory_bytes: 83176
#include <bits/stdc++.h>
using namespace std;
#ifdef _IS_LOCAL //
#define dout cout
#define debug() if (true)
#define dvout(v) vout(v)
#else
#define dout   \
	if (false) \
	cout
#define debug() if (false)
#define dvout if(false) cout
#endif //
#define next asdnext
#define prev asdprev
#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define vrep(i, v) for (auto &i : v)
#define all(x) (x).begin(), (x).end()
#define vout(v)           \
	for (auto &i : v)     \
	{                     \
		cout << i << " "; \
	}                     \
	cout << "\n"; //配列出力
#define vin(v)        \
	for (auto &i : v) \
		cin >> i; //配列入力
#define vecin(v,n)	\
	vec(v,n);		\
	vin(v);
#define vec(v, n) vector<int> v(n, 0);
#define mod (int)(1e9+7)
typedef long long ll;
typedef unsigned long long ull;
void Main()
{
	int A, B;
	cin>>A>>B;
	int ans = max(A-B, A+B);
	ans = max(ans, A*B);

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

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define perl(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define pb push_back
#define ins insert
#define pqueue(x) priority_queue<x,vector<x>,greater<x>>
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
#define vtpl(x,y,z) vector<tuple<x,y,z>>
#define rev(x) reverse(x);
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
using vpl=vector<pl>;
using vvpl=vector<vpl>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[8]={1,0,-1,0,1,1,-1,-1};
const ll dx[8]={0,-1,0,1,1,-1,1,-1};
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

int main(){
    ll h,w;cin >> h >>w;
    vector<string> g(h);
    rep(i,h)cin >> g[i];
    pl p={0,0};
    pl goal={h-1,w-1};
    g[0][0]='.';
    while(p!=goal){
        if(p.fi!=h-1){
            if(g[p.fi+1][p.se]=='#'){
                g[p.fi+1][p.se]='.';
                p.fi++;
                continue;
            }   
        }
        if(p.se!=w-1){
            if(g[p.fi][p.se+1]=='#'){
                g[p.fi][p.se+1]='.';
                p.se++;
                continue;
            }   
        }
        cout << "Impossible" <<endl;
        return 0;
    }
    bool check=true;
    /*rep(i,h){
        rep(j,w){
            cout << g[i][j];
        }
        cout << endl;
    }*/
    rep(i,h){
        rep(j,w)if(g[i][j]=='#')check=false;
    }
    if(check)cout << "Possible" <<endl;
    else cout << "Impossible" <<endl;
}

Measured memory_bytes: 3620
#include<bits/stdc++.h>
#include<cctype>
using namespace std;
#define rep(i,n) for (int i=0;i<(n);i++)
#define all(v) (v).begin(),(v).end()
typedef long long int ll;
#define pi 3.1415926535897932384
#define E9 1000000000
#define eps 1e-4
#define pii pair<int,int>

int main(){
  int a, b; cin >> a >> b;
  cout << a*b << endl;





  // cout << fixed << setprecision(6);
  return 0;
}


Measured memory_bytes: 3592
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

int main()
{
    int n, a, b, c, d, cdmax;
    cin >> n >> a >> b >> c >> d;
    a--;
    b--;
    c--;
    d--;
    cdmax = max(c, d);

    bool s[n];
    char inp;
    int ren = 0;
    int renn = 0;
    bool ok = false;
    if (c < d)
    {
        ok = true;
    }

    for (int i = 0; i < n; i++)
    {
        cin >> inp;
        if (inp == '.')
        {
            s[i] = true;
            renn = 0;
            ren++;
            if (ren == 3)
            {
                if (b < i && i <= d + 1)
                {
                    ok = true;
                }
                ren = 2;
            }
        }
        else
        {
            s[i] = false;
            ren = 0;
            renn++;
            if (renn == 2)
            {
                if (a < i && i < cdmax)
                {
                    cout << "No" << endl;
                    return 0;
                }
            }
        }
    }
    if (ok == true)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
    return 0;
}

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

int mat[100003] , minn = INT_MAX;

int solve(int arr[] , int pos ,int k){
	
	if(pos==0){
		return 0;
	}
	else{
	if(mat[pos]!=-1){
		return mat[pos];
	}	
	for(int r = 1; r<=k ;r++){
		
		int returnValue ;
		if(pos-r>=0){
			 returnValue = solve(arr , pos-r , k) + abs(arr[pos] - arr[pos-r]);	
		}

		if( returnValue < minn ){
			minn = returnValue;
		}
	}
	mat[pos] = minn;
	minn = INT_MAX;
	return mat[pos];
	}
}

int main()
{


memset( mat , -1 ,  sizeof(mat) );
int n ,k;
cin>>n>>k;

int arr[n] , i;

for(i=0;i<n;i++){
	cin>>arr[i];
}
int size = sizeof(arr)/sizeof(int); 

cout<<solve(arr , size-1 , k );

   return 0;
}


Measured memory_bytes: 12096
#include <stdio.h>

typedef long long ll;

ll dp[110][100010];

ll max(ll x, ll y)
{
	return x > y ? x : y;
}

int main()
{
	int n, w, weight[100], value[100];

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

	for (int i = 0; i < n; i++)//品物の数
	{
		for (int j = 0; j <= w; j++)//重さ
		{
			if (j >= weight[i])
			{
				dp[i + 1][j] = max(dp[i][j], dp[i][j - weight[i]] + value[i]);
			}
			dp[i + 1][j] = max(dp[i + 1][j], dp[i][j]);
		}
	}
	printf("%lld\n", dp[n][w]);
	return 0;
}

Measured memory_bytes: 79864
#include <stdio.h>

int main()
{
	int i, N, K, A[100001];
	scanf("%d %d", &N, &K);
	for (i = 1; i <= N; i++) scanf("%d", &(A[i]));
	printf("%d\n", (N - 2) / (K - 1) + 1);
	fflush(stdout);
	return 0;
}

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

using namespace std;

int main(){
	//freopen("C:\Users\changzheng\Desktop\in.txt","r",stdin);
	//freopen("C:\Users\changzheng\Desktop\out.txt","w",stdout);
	int n;
	cin>>n;
	string s;
	int AC=0,WA=0,TLE=0,RE=0;
	for(int i=1;i<=n;i++){
		cin>>s;
		if(s=="AC")AC++;
		if(s=="WA")WA++;
		if(s=="TLE")TLE++;
		if(s=="RE")RE++;
	}
	cout<<"AC x "<<AC<<'\n';
	cout<<"WA x "<<WA<<'\n';
	cout<<"TLE x "<<TLE<<'\n';
	cout<<"RE x "<<RE<<'\n';
	//fclose(stdin);
	//fclose(stdout);
	return 0;
}

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

#define si(x) scanf("%d",&x)

using namespace std;
const int MAXN = 301;
const int MOD = 1e9+7;
int dp[MAXN][MAXN][MAXN];
int n,q;
vector<pair<int,int> > endd[MAXN];

int solve(int r,int g,int b, int ind){
    int indd = max(max(r,g),b);
    if(endd[indd].size()!=0){
        for(int i=0;i<endd[indd].size();i++){
            int startt = endd[indd][i].first;
            int cnt = (r>=startt) + (g>=startt) + (b>=startt);
            if(cnt != endd[indd][i].second)return 0;
        }
    }
    if(ind == n+1){
        //cout << r << " " << g << " " << b << "\n";
        return 1;
    }
    if(dp[r][g][b]!=-1)return dp[r][g][b];

    dp[r][g][b] = ((solve(ind,g,b,ind+1) + solve(r,ind,b,ind+1))%MOD + solve(r,g,ind,ind+1))%MOD;
    return dp[r][g][b];
}

int main()
{
    si(n);si(q);
    memset(dp,-1,sizeof(dp));
    for(int i=0;i<q;i++){
        int l,r,c;
        si(l);si(r);si(c);
        endd[r].push_back({l,c});
    }
    cout << solve(0,0,0,1);
    return 0;
}


Measured memory_bytes: 106752
#include <bits/stdc++.h>
using namespace std;
#define   nl   <<'\n'
#define   ll   long long
#define   pb   push_back
#define   eb   emplace_back
#define   tc   int t; cin>>t; while(t--)
#define   fio  ios_base::sync_with_stdio(0); cin.tie(0)

int main()
{
    int x;
    cin>>x;
    cout<<!x;
}   

Measured memory_bytes: 3460