akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

#define fi first
#define se second
#define pb push_back
#define mod(n,k) ( ( ((n) % (k)) + (k) ) % (k))
#define forn(i,a,b) for(int i = a; i < b; i++)
#define forr(i,a,b) for(int i = a; i >= b; i--)
#define all(x) (x).begin(), (x).end()

typedef long long ll;
typedef long double ld;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;

int main(){
	ios_base::sync_with_stdio(0); cin.tie(0);
	ll N; cin >> N;
	string res = "";
	while(N){
		N--;
		ll c = N%ll(26);
		res += (char)(c+'a');
		N /= ll(26);
	}
	reverse(all(res));
	cout << res << '\n';
	return 0;
}
/*
__builtin_mul_overflow(x,y,&x)
-fsplit-stack
*/


Measured memory_bytes: 3632
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define INF (1<<30)
#define INFLL (1ll<<60)
typedef pair<int, int> P;
typedef pair<int, P> E;
#define MOD (1000000007ll)
#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	b += MOD;
	a += b;
	a %= MOD;
}

int main(void){
	ll a,b,c,ans=1ll;
	cin >> a >> b >> c;
	--c;
	ans += b;
	ans += min(a+b,c);
	cout << ans << endl;
	return 0;
}


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

#define REP(i, a, b) for(int i = (a); i <= (b); i++)
#define PER(i, a, b) for(int i = (a); i >= (b); i--)
#define rep(i, a, b) for(int i = (a); i < (b); i++)
#define debug(x) cerr << #x << " = " << x << endl;
#define SET(c, v) memset(c, v, sizeof c)
#define pi 3.14159265358979323846264338
#define all(S) (S).begin(), (S).end()
#define INF 0x3f3f3f3f
#define mod 1000000007
#define pf push_front
#define Pb push_back
#define mk make_pair
#define MAX 100000
#define S second
#define F first
typedef long long ll;
typedef long double lf;
typedef pair<int, int> ii;
typedef pair<int, ii> pii;
typedef unsigned long long int ull;
int a[MAX], b[MAX], c[MAX], pd[MAX][4], N;

int solve(int i, int op) {
	int &ans = pd[i][op];
	if(i == N) return 0;
	if(ans != -1) return ans;
	int pa = solve(i+1, 1) + a[i];
	int pb = solve(i+1, 2) + b[i];
	int pc = solve(i+1, 3) + c[i];
	if(op == 1) ans = max(pb, pc);
	else if(op == 2) ans = max(pa, pc);
	else if(op == 3) ans = max(pa, pb);
	else ans = max(pa, max(pb, pc));
	return ans;
}

int main(int argc, char** argv) {
	scanf("%d", &N);
	rep(i, 0, N) scanf("%d%d%d", &a[i], &b[i], &c[i]);
	memset(pd, -1, sizeof pd);
	printf("%d\n", solve(0, 0));
	return 0;
}


Measured memory_bytes: 9216
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <vector>
#include <string>
#include <sstream>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <functional>

using namespace std;

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

#define fst first
#define scd second
#define PB push_back
#define MP make_pair
#define rep(i,x) for(int i=0;i<(x);++i)
#define rep1(i,x) for(int i=1;i<=(x);++i)
#define rrep(i,x) for(int i=(x)-1;i>=0;--i)
#define rrep1(i,x) for(int i=(x);i>=1;--i)
#define FOR(i,a,x) for(int i=(a);i<(x);++i)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()

template<typename T>bool chmax(T&a,T b){if(a<b){a=b;return true;}return false;}
template<typename T>bool chmin(T&a,T b){if(a>b){a=b;return true;}return false;}
template<typename T>T get(){T a;cin>>a;return a;}
template<typename T>T rev(T a){reverse(all(a));return a;}
template<typename T>istream&operator>>(istream&is,vector<T>&vec){rep(i,vec.size())is>>vec[i];return is;}
template<typename T>vector<T>&sort(vector<T>&a){sort(all(a));return a;}

const int inf = 1e9;
const ll linf = 3e18;

struct edge {
    int to, cost;
    edge(int to, int cost = inf) : to(to), cost(cost) {}
};

int N, M, C;

int d[100000];
vector<edge> G[100000];
map<ll, vector<int> >  m;
bool found[100000];
map<int, bool> used[100000];

void dijkstra(int s)
{
    priority_queue<pii, vector<pii>, greater<pii> > q;
    fill(d, d + N, inf);
    d[s] = 0;
    q.push(pii(0, s));
    while (q.size()) {
        pii p = q.top(); q.pop();
        int v = p.scd;
        if (d[v] < p.fst) continue;
        rep(i, G[v].size()) {
            edge e = G[v][i];
            if (d[e.to] > d[v] + e.cost) {
                d[e.to] = d[v] + e.cost;
                m[d[e.to]].PB(e.to);
                q.push(pii(d[e.to], e.to));
            }
        }
    }
}

signed main()
{
    scanf("%d %d %d", &N, &M, &C);

    ll sum = 0;

    rep(i, M) {
        int A, B, D; scanf("%d %d %d", &A, &B, &D), A--, B--;
        G[A].PB(edge(B, D));
        G[B].PB(edge(A, D));
        sum += D;
    }

    dijkstra(0);
    found[0] = true;

    ll a = 0;

    ll mi = linf;

    m[0] = vector<int>();

    for (map<ll, vector<int> >::iterator itr = m.begin(); itr != m.end(); ++itr) {
        ll X = itr->fst;
        vector<int> vs = itr->scd;

        rep(i, vs.size()) {
            found[vs[i]] = true;
        }

        rep(i, vs.size()) {
            int v = vs[i];
            rep(j, G[v].size()) {
                edge e = G[v][j];
                if (!found[e.to]) continue;
                if (used[v][e.to]) continue;
                used[v][e.to] = used[e.to][v] = true;
                a += e.cost;
            }
        }

        chmin(mi, sum - a + C * X);
    }

    printf("%lld\n", mi);
}

Measured memory_bytes: 43176
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#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;
bool comp(int &a,int &b){
  return a>b;
}
int main()
{
  int _n;
  cin >> _n;
  int n = 1<<_n;
  vector<int> s(n);
  rep(i,n) cin >> s[i];
  sort(s.begin(), s.end(),comp);
  bool f = false;
  vector<int> a(1,s[0]);
  s[0] = -1;
  rep(i,_n){
    vector<int> p = a;
    sort(p.begin(), p.end(),comp);
    auto itr = p.begin();
    int j = 0;
    while(itr!=p.end()){
      if(j==n){
	f = true;
	break;
      }
      if(s[j]==-1){
	++j;
	continue;
      }
      if(*itr > s[j]){
	a.push_back(s[j]);
	s[j] = -1;
	++itr;
      }
      ++j;
    }
    if(f) break;
  }
  cout << (!f?"Yes":"No") << "\n";
  
  return 0;
}


Measured memory_bytes: 2932
# For taking integer inputs.
import math
from decimal import Decimal
from itertools import permutations


def inp():
    return(int(input()))


# For taking List inputs.
def inlist():
    return(list(map(int, input().split())))


# For taking string inputs. Actually it returns a List of Characters, instead of a string, which is easier to use in Python, because in Python, Strings are Immutable.
def instr():
    s = input()
    return(list(s[:len(s)]))


# For taking space seperated integer variable inputs.
def invr():
    return(map(int, input().split()))


def fact(n):
    if n == 0:
        return 1
    return fact(n-1) * n


N = inp()
points = []
p = []
for i in range(N):
    p.append(i)
    points.append(inlist())
D = [[0 for i in range(N)] for j in range(100)]
c = 0
for i in range(N-1):
    for j in range(i+1, N):
        x1, y1 = points[i]
        x2, y2 = points[j]
        #print("p ", points[i], points[j])
        d = math.sqrt((x1 - x2)**2 + (y1 - y2)**2)
        D[i][j] = d
        D[j][i] = d
# print(D)
permut = list(permutations(p))

res = 0
for pt in permut:
    for i in range(N-1):
        res += D[pt[i]][pt[i+1]]
print(res / fact(N))


Measured memory_bytes: 10064
#define _CRT_SECURE_NO_WARNINGS
#define REL

#pragma GCC optimize("Ofast")

#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <deque>
#include <queue>
#include <iomanip>
#include <cstdio>
#include <unordered_map>
#include <unordered_set>
#include <map>
#include <string>
#include <set>
#include <bitset>
#include <cstdint>
#include <cstring>
#include <cassert>
#include <complex>
#include <stack> 

using namespace std;

typedef int64_t i64;
typedef long long LL;
typedef long long ll;
typedef long double LD;
typedef complex <LD> cld;
typedef unsigned int uint;
typedef complex <double> cd;
typedef unsigned long long ULL;

#define endl "\n"
#define dendl "\n\n"
#define mp make_pair
#define mt make_tuple
#define size(v) (int)v.size()
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()

/////////////////////////////////////////////////////////////////////

template <typename T>
T sqr(T a) {
	return a * a;
}

template <typename T>
int sign(T a) {
	if (a == 0)
		return 0;
	return (a > 0 ? 1 : -1);
}

template <typename T1, typename T2>
T2 sum_mod(T1 x, T2 MOD) {
	if (x < 0)
		x += MOD;
	if (x >= MOD)
		x -= MOD;
	return x;
}

template <typename T1, typename T2>
T2 mul_mod(T1 x, T2 MOD) {
	if (x < 0)
		return (abs(x) % MOD == 0 ? 0 : MOD - abs(x) % MOD);
	return x % MOD;
}

template <typename T>
bool uax(T& a, const T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}

template <typename T>
bool uin(T& a, const T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}

template <typename T1, typename T2>
istream& operator >> (istream& in, pair<T1, T2>& p) {
	in >> p.first >> p.second;
	return in;
}

template <typename T1, typename T2>
ostream& operator << (ostream& out, pair<T1, T2>& p) {
	out << p.first << ' ' << p.second;
	return out;
}

const int LOG = 18;
const int N = (int)1e5 + 7;
const int MAXN = (int)2e3 + 7;
const int MOD = (int)998244353;
const int INF = (int)1e9 + 7;
const int CONST = 300;
const LL LINF = (i64)2e15;
const LD PI = 3.1415926535897932384626433832795;
const LD EPS = 1;

/////////////////////////////////////////////////////////////////////

int main() {
	double start = clock();
#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	cout << fixed << setprecision(20);
	cerr << fixed << setprecision(20);
#else
	cout << fixed << setprecision(20);
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
#endif

	int a[3];
	cin >> a[0] >> a[1] >> a[2];
	swap(a[0], a[1]);
	swap(a[0], a[2]);
	cout << a[0] << ' ' << a[1] << ' ' << a[2];

#ifdef _DEBUG
	cout << endl << "Time is " << (clock() - start) / 1000.0;
#endif
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <string.h>
#include <math.h>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <algorithm>
#include <utility>
#include <deque>
#include <queue>
#include <functional>

#define rep(i, n) for(int i = 0; i < n; ++i)
#define REP(i, m, n) for(int i = m; i < n; ++i)
#define rrep(i,n) for(int i = n; i >= 0; --i)
#define RREP(i, m, n) for(int i = n; i >= m; --i)
#define llrep(i, n) for(ll i = 0; i < n; ++i)
#define llREP(i, m, n) for(ll i = m; i < n; ++i)
#define llrrep(i,n) for(ll i = n; i >= 0; --i)
#define llRREP(i, m, n) for(ll i = n; i >= m; --i)

using ll = long long;
using ull = unsigned long long;
using pii = std::pair<int, int>;
using pll = std::pair<long long, long long>;
using plpii = std::pair<long long, std::pair<int, int>>;

using namespace std;

const long long _MOD = 1000000007;
const long long MOD = 998244353;

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

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

	if (n & 1) {
		rep(i, m) {
			cout << i + 1 << " " << n - i << "\n";
		}
	}
	else {
		rep(i, m) {
			if (i < n / 4) {
				cout << i + 1 << " " << n - i << "\n";
			}
			else {
				cout << i + 2 << " " << n - i << "\n";
			}
		}
	}

	return 0;
}



Measured memory_bytes: 3656
// --------------
// Tejas Pandey  |
// 21 - 06 - 19  |
// Atcoder #131  |    |
// --------------

#include <bits/stdc++.h>
using namespace std;

#define mod 1000000007
typedef long long int ll;

int main (void)
{
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	string s;
	cin >> s;
	for(int i = 1; i < s.size();i++)
		if(s[i] == s[i-1])
		{
			cout << "Bad";
			return 0;
		}
	cout << "Good";
	return 0;
}

Measured memory_bytes: 256
import math,itertools,fractions,heapq,collections,bisect,sys,queue,copy

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
# def LF(): return [float(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()

def main():
  h,w,k=LI()
  field=[S() for _ in range(h)]

  ans=0
  for i in range(1<<(h+w)):
    hh=[False]*h
    ww=[False]*w
    for j in range(h+w):
      if i&(1<<j):
        if j<h:
          hh[j]=True
        else:
          ww[j-h]=True

    cnt=0
    for j in range(h):
      if hh[j]:
        continue
      for _k in range(w):
        if ww[_k]:
          continue

        if field[j][_k]=='#':
          cnt+=1

    if cnt==k:
      ans+=1

  return ans

# main()
print(main())


Measured memory_bytes: 10720
n, y = map(int, (input().split()))
 
for i in range(n+1):
  for j in range(n+1-i):
    k = n - i - j
    if 10000*i + 5000*j + 1000*k == y:
      print(i, j, k)
      break
  else:
    continue
  break
else:
  print(-1, -1, -1)

Measured memory_bytes: 40684
//============================================================================
// Name        : Hello5.cpp
// Author      :
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
#include <vector>
#include <bits/stdc++.h>
#include <numeric>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using p = pair<int,int>;//<key,value>


int main() {
int n,k;
cin>>n>>k;
vector<int> h(n);
rep(i,n) cin>>h[i];
int ans=0;
rep(i,n)
if(h[i]>=k)
	ans++;
cout<<ans<<endl;
return 0;
}




Measured memory_bytes: 640
M,D = map(int, input().split())
count = 0

for month in range(4, M+1):
    if len(str(D)) == 2:
        for day in range(22,D+1):
            if int(str(day)[0]) >= 2 and int(str(day)[1]) >= 2:
                if int(str(day)[0]) * int(str(day)[1]) == month:
                    count += 1

print(count)

Measured memory_bytes: 39408
//37
#include<iostream>
#include<string>
#include<algorithm>
#include<cctype>

using namespace std;

int main(){
  int n;
  cin>>n;
  while(n--){
    string r,m;
    cin>>r>>m;
    for(int i=r.size()-1;i>=0;i--){
      switch(r[i]){
      case 'J':
	if(m.size()>1){
	  rotate(m.begin(),m.end()-1,m.end());
	}
	break;
      case 'C':
	if(m.size()>1){
	  rotate(m.begin(),m.begin()+1,m.end());
	}
	break;
      case 'E':
	{
	  string n;
	  n=m.substr((m.size()+1)/2);
	  if(m.size()%2){
	    n+=m[m.size()/2];
	  }
	  n+=m.substr(0,m.size()/2);
	  m=n;
	}
	break;
      case 'A':
	reverse(m.begin(),m.end());
	break;
      case 'P':
      case 'M':
	for(int j=0;j<m.size();j++){
	  if(isdigit(m[j])){
	    m[j]=(m[j]-'0'+(r[i]=='M')-(r[i]=='P')+10)%10+'0';
	  }
	}
	break;
      }
    }
    cout<<m<<endl;
  }
  return 0;
}
      

Measured memory_bytes: 1224
#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
int n,i,x,k,nr;
int main()
{
    cin>>n>>k;
    for(i=1;i<=n;i++)
    {
        cin>>x;
        if(x>=k)
            nr++;
    }
    cout<<nr;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define pi acos(-1)
#define IOS ios_base::sync_with_stdio(0); cin.tie(); cout.tie();
#define ff first
#define ss second
#define pb push_back
#define debug(val) cerr << "The value of " << #val << " is = " << val << '\n';
typedef long long ll;
typedef unsigned long long ull;
const ll mod = 1e9 + 7;
const ll inf = 0x3f3f3f3f;
const ll mininf = -922337203685477;
const ll nax = 1e5+5;
int n, m, maks=-1;
priority_queue<int>arr;
long long ans=0;

int main(){
	IOS
	cin >> n >> m;
	for(int i=0;i<n;i++){
		int x;
		cin >> x;
		arr.push(x);	
	}
	while(m--){
		int gede=arr.top();
		arr.pop();
		arr.push(gede/2);
	}
	for(int i=0;i<n;i++){
		ans+=arr.top();
		arr.pop();
	}
	cout << ans << '\n';
}


Measured memory_bytes: 3844
package main

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

func main() {
	r := bufio.NewReader(os.Stdin)
	var a, b int
	fmt.Fscan(r, &a)
	fmt.Fscan(r, &b)

	// gcdの素因数 + 1
	pf := primeFactor(gcd(a, b))
	fmt.Println(len(pf) + 1)
}

// Utility

func primeFactor(x int) map[int]int {
	res := make(map[int]int)
	for i := 2; i*i <= x; i++ {
		for x%i == 0 {
			res[i]++
			x = x / i
		}
	}
	if x != 1 {
		res[x] = 1
	}
	return res
}

func divisor(x int) []int {
	res := make([]int, 0)
	for i := 1; i*i <= x; i++ {
		if x%i == 0 {
			res = append(res, i)
			if i != x/i {
				res = append(res, x/i)
			}
		}
	}
	return res
}

func gcd(x, y int) int {
	if y == 0 {
		return x
	}
	return gcd(y, x%y)
}

func min(x, y int) int {
	if x < y {
		return x
	}
	return y
}

func max(x, y int) int {
	if x > y {
		return x
	}
	return y
}

func abs(x int) int {
	if x < 0 {
		return -x
	}
	return x
}


Measured memory_bytes: 640
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#include<bits/stdc++.h>
#define speedX ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
using namespace std;
#define ONLINE_JUDGE
#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	cout<< name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
int begtime = clock();
#define end_time() cout << "\n\nTime of execution: " << (clock() - begtime)*1000/CLOCKS_PER_SEC << " ms\n\n";
#else
#define trace(...)
#define end_time()
#endif


#define int long long 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<pii, int> piii;
typedef vector<int> vi;
typedef vector<pii> vii;

#define pb push_back
#define mp make_pair
#define mt make_tuple
#define ff first
#define ss second
#define uset unordered_set
#define umap unordered_map
#define all(x) x.begin(), x.end()
#define mod 1000000007

void solve(){
	int a,b;
	cin>>a>>b;
	cout<<max(max(a+b,a-b),a*b)<<"\n";
	return;
}
signed main(){
	speedX;
	#ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
	int t=1;
	//cin>>t;
	while(t--){
		solve();
	}
	end_time();
	return 0;
}

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

using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

#define TASKNAME main

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

	//freopen(TASKNAME".inp", "r", stdin);
	//freopen(TASKNAME".out", "w", stdout);

	ll n;
	cin >> n;
	ll ct = 0;
	for(ll i = 1; i <= n; i++) {
		ll x; cin >> x;
		if(x ^ i) ++ct;
	}

	if(ct && ct ^ 2) cout << "NO";
	else cout << "YES";
	

	cerr << "\nTime elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
}

// g++ main.cpp -o main.exe -std=c++11 -DEVAL -pipe -O2 -s -static -Wall -Wshadow
/* stuff you should look for
	* array bounds
	* special cases (n=1?), set tle
	* do sth instead of nothing and stay organized
	* check for variables with close names
*/

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main () {
  int N, M;
  cin >> N >> M;
  vector<vector<char>> main(N, vector<char> (N)), sub(M, vector<char> (M));
  for(int i = 0; i < N; i++) {
    for (int j = 0; j < N; j++) {
      cin >> main.at(i).at(j);
    }
  }
  for(int i = 0; i < M; i++) {
    for (int j = 0; j < M; j++) {
      cin >> sub.at(i).at(j);
    }
  }
  int count, flag = 0;
  for(int i = 0; i < N - M + 1; i++) {
    for (int j = 0; j < N - M + 1; j++) {
      count = 0;
      for (int k = 0; k < M; k++) {
        for (int l = 0; l < M; l++) {
          if(main.at(i + k).at(j + l) == sub.at(k).at(l)) count++;
        }
      }
      if(count == M * M) flag = 1;
    }
    if (flag == 1) break;
  }
  if(flag == 1)cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <limits>
#include <queue>
#include <string>

using namespace std;

#define int long long

struct Edge {
	int to;
	int cost;
	int rev;
	Edge(int to, int cost, int rev) :to(to), cost(cost), rev(rev){}
	Edge(int to, int cost) :to(to), cost(cost), rev(-1){}
	Edge(int to) :to(to), cost(1), rev(-1){}
	Edge(){}
};

int DinicDFS(const vector<int>& level,vector<vector<Edge>> &Gf, int node, int t, int flow = std::numeric_limits<int>::max()) {
	int res = 0;
	if (node == t) {
		return flow;
	}
	for (auto &e : Gf[node]) if(level[node] + 1 == level[e.to]){
		int f = DinicDFS(level, Gf, e.to, t, min(e.cost, flow));
		e.cost -= f;
		Gf[e.to][e.rev].cost += f;
		flow -= f;
		res += f;
		if (flow == 0) return res;
	}
	return res;
}

int Dinic(const vector<vector<Edge> > &G, const int s, const int t) {
	int res = 0;
	vector<vector<Edge> > Gf(G.size());
	// construct Gf
	for (int i = 0; i < G.size(); ++i) {
		for (auto &e : G[i]) {
			int from = i;
			int to = e.to;
			int cost = e.cost;
			Gf[from].emplace_back(to, cost, Gf[to].size());
			Gf[to].emplace_back(from, 0, Gf[from].size()-1);
		}
	}

	while (1) {
		// BFS(leveling)
		vector<int> level(G.size(), -1);
		queue<int> que;
		vector<vector<Edge*> > Gl;

		que.push(s);
		level[s] = 0;
		while (!que.empty()) {
			int from = que.front(); que.pop();
			for (auto &e : Gf[from]) {
				if (level[e.to] == -1 and e.cost > 0) {
					level[e.to] = level[from] + 1;
					que.push(e.to);
				}
			}
		}

		if(level[t] == -1) return res;
		res += DinicDFS(level, Gf, s, t);
	}
	return 0;
}

signed main(void) {
	int N; cin >> N;
	vector<pair<int, int> > ab;
	vector<pair<int, int> > cd;
	
	vector<vector<Edge>> G(N * 2 + 2); // cost, to
	for (int i = 0; i < N; ++i) {
		int a, b; cin >> a >> b;
		ab.emplace_back(a, b);
	}
	for (int i = 0; i < N; ++i) {
		int c, d; cin >> c >> d;
		for (int j = 0; j < ab.size(); ++j) {
			if (ab[j].first < c && ab[j].second < d) {
				G[j].emplace_back(i+N, 1);
			}
		}
	}

	for (int i = 0; i < N; ++i) {
		G[2 * N].emplace_back(i);
		G[i + N].emplace_back(2*N+1);
	}

	cout << Dinic(G, 2 * N, 2 * N + 1) << endl;
}


Measured memory_bytes: 552
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

ll ans[1000000];
int main() {
    ll h,w,d;
    cin>>h>>w>>d;

    ll a[1000][1000];
    pair<ll,ll> sqr[1000000];
    for(ll i=0;i<h;i++){
        for(ll j=0;j<w;j++){
            cin>>a[i][j];
            sqr[a[i][j]]=make_pair(i,j);
        }
    }
    ll q;
    cin>>q;
    for(ll i=d+1;i<h*w+1;i++){
        ans[i]=ans[i-d]+abs(sqr[i].first-sqr[i-d].first)+abs(sqr[i].second-sqr[i-d].second);
    }
    for(ll i=0;i<q;i++){
        ll l,r;
        cin>>l>>r;
        cout<<ans[r]-ans[l]<<endl;
    }
    return 0;
}


Measured memory_bytes: 23168
#include<bits/stdc++.h>
using namespace std;
using ll = long long;

int digit[10];
int unite(int a, int b) {
    int i;
    for(i = 0; a > 0 || b > 0; ++i) {
        if(b > 0) {
            digit[i] = b%10;
            b /= 10;
        } else {
            digit[i] = a%10;
            a /= 10;
        }
    }
    int res = 0;
    while(i > 0) {
        res *= 10;
        res += digit[i-1];
        --i;
    }
    return res;
}

int main()
{
    int a, b;
    cin >> a >> b;
    int c = unite(a, b);
    /*
    for(int i = 0; i < 320; ++i) {
        if(i*i == c) { cout << "Yes" << endl; return 0; }
    }
    */
    int mn = 0, mx = 320;
    while(true) {
        if(mx - mn <= 1) {
            if(mx*mx == c) { cout << "Yes" << endl; return 0;}
            else break;
        }
        int md = (mx + mn)/2;
        if(md*md < c) {
            mn = md;
        } else if(md*md > c) {
            mx = md;
        } else {
            cout << "Yes" << endl; return 0;
        }
        //cout << "mn: " << mn << " mx: " << mx << endl;
    }
    //cout << "mn: " << mn << endl;
    cout << "No" << endl;
    return 0;
}

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

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

    string S;
    for(int i=0; i<N; i++) cin >> S[i];

    bool jdg = true;
    int i = 0;

    while(i<N && jdg){
        // 黄色のひなあられの場合
        if(S[i] == 'Y'){
            cout << "Four" << endl;
            jdg = false;
            break;
        }
        // 黄色のひなあられでない場合
        else i++;
    }
    if(jdg) cout << "Three" << endl;
}

Measured memory_bytes: 256
n,k = map(int,input().split())

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

tmp = sum(p[:k])
res = tmp
start = 0
end = k-1
for i in range(n-k):
  tmp -= p[i]
  tmp += p[k+i]
  if res < tmp:
    res = tmp
    start = i+1
    end = k+i

ans = 0
for i in range(start,end+1):
  if p[i] % 2 == 0:
    ans += ((p[i]+1) * (p[i] // 2)) / p[i]
  else:
    ans += (1 + p[i]//2 + (p[i]+1) * (p[i] // 2)) / p[i]
print(ans)


Measured memory_bytes: 25604
import sys

def main():
    line = sys.stdin.readline().rstrip('\n').split()
    if ((line[0]==line[1] and line[0]!=line[2]) or (line[1]==line[2] and line[0]!=line[2]) or
        (line[0]==line[2] and line[1]!=line[2])):
        print('Yes')
    else:
        print('No')

main()


Measured memory_bytes: 2940
#include <iostream>
#include <cctype>
#include <cstdlib>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#define rep(i, n) for(int i = 0; i < n; ++i)
using namespace std;

int comp(const void* a, const void* b){
	return *(int*)a - *(int*)b;
}

int main() {
	int a[3], ans = 0;
	rep(i, 3) cin >> a[i];
	qsort(a, 3, sizeof(int), comp);
	rep(i, 2) ans += a[i+1] - a[i];
	cout << ans << endl;
}

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

int main(){
    string tmp[4];
    tmp[0]="dream";
    tmp[1]="dreamer";
    tmp[2]="erase";
    tmp[3]="eraser";
    string str;
    cin>>str;
    bool flag=true;
    int i=str.size()-1;
    while(i>=0){
        bool tm=false;
        if(i-6>=0){
            if(str.substr(i-6,7)==tmp[1]){
                tm=true;
                i-=7;
            }
        }
        if(!tm){
            if(i-5>=0){
                if(str.substr(i-5,6)==tmp[3]){
                    tm=true;
                    i-=6;
                }
            }
        }
        if(!tm){
            if(i-4>=0){
                if(str.substr(i-4,5)==tmp[0]||str.substr(i-4,5)==tmp[2]){
                    tm=true;
                    i-=5;
                }
            }
        }
        if(!tm){
            flag=false;
            break;
        }
    }
    if(flag){
        cout<<"YES"<<endl;
    }else{
        cout<<"NO"<<endl;
    }
    return 0;
}


Measured memory_bytes: 512
import math

#use math.degrees() or math.radians()

a,b,x = map(int, input().split())


theta = 0

if x <= a**2*b/2: # little water
    #print("check")
    theta = math.atan(a*b*b/(2*x))
    #print(math.degrees(theta))
    #print(theta)
else:
    #print("check2")
    theta = math.atan((2*a**2*b-2*x)/a**3)
    #print(math.degrees(theta))

print(180 * theta / math.pi)


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

int main(){
    int n;
    string s,t;
    cin>>n>>s>>t;
    ll ans=1;
    bool prev=false;
    for(int i=0;i<n;i++){
        if(i!=n-1&&s[i]==s[i+1]){
            if(prev)ans=(ans*3)%MOD;
            else ans=(ans*2)%MOD;
            if(i==0)ans=6;
            prev=1;
            i++;
        }
        else{
            if(!prev)ans=(ans*2)%MOD;
            if(i==0)ans=3;
            prev=0;
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

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 loop = N / (A + B);
		long amari = N % (A + B);
		long blue;
		if (amari <= A){
			blue = amari;
		} else {
			blue = A;
		}
		
		System.out.println(loop * A + blue);
	}
}

Measured memory_bytes: 23764
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
int main(){
    int n,k; cin >> n >> k;
    vector<int> H;
    for(int i = 0; i < n; i++){
        int h;cin >> h;
        H.push_back(h);
    }
    sort(H.begin(), H.end());
    vector<int> d;
    int m;
    int ans = 1e9;
    for(int i = 0; i < n - k + 1; i++){
        m = H[i + k - 1] - H[i];
        ans = min(m, ans);
    }
    cout << ans << endl;
    // O(n*nlogn)
}

Measured memory_bytes: 1020
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int A, B;
    cin >> A >> B;
    int cnt = 1;
    int ans = 0;
    while(true) {
        if (cnt >= B) {
            cout << ans << endl;
            return 0;
        }
        cnt += A - 1;
        ans++;
    }

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;

int N, A, B, C, D;

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  cin >> N >> A >> B >> C >> D;
  int yes = 0;
  for (int i = 0; i < N; i++) {
    ll tmp = B - A - (ll)(N - 1 - 2 * i) * C;
    if (tmp > 0) {
      if (abs(tmp) <= (ll)(D - C) * (N - 1 - i)) yes = 1;
    } else if (tmp < 0) {
      if (abs(tmp) <= (ll)(D - C) * i) yes = 1;
    } else {
      yes = 1;
    }
  }  
  cout << (yes ? "YES" : "NO") << endl;

  return 0;
}

Measured memory_bytes: 256
import collections
import functools

class memoized(object):
    def __init__(self, func):
       self.func = func
       self.cache = {}

    def __call__(self, *args):
       if not isinstance(args, collections.Hashable):
          return self.func(*args)

       if args in self.cache:
          return self.cache[args]

       else:
          value = self.func(*args)
          self.cache[args] = value
          return value

    def __repr__(self):
       return self.func.__doc__

    def __get__(self, obj, objtype):
       return functools.partial(self.__call__, obj)

def knapsack(items, maxweight):
    @memoized
    def bestvalue(i, j):
        if i == 0: return 0
        value, weight = items[i - 1]
        if weight > j:
            return bestvalue(i - 1, j)
        else:
            return max(bestvalue(i - 1, j),
                       bestvalue(i - 1, j - weight) + value)

    j = maxweight
    result = []
    for i in xrange(len(items), 0, -1):
        if bestvalue(i, j) != bestvalue(i - 1, j):
            result.append(items[i - 1])
            j -= items[i - 1][1]
    result.reverse()
    return bestvalue(len(items), maxweight), result

def input_str(row):
    res = []
    for _ in range(row):
        res.append(raw_input().split())
    return res

N, W = [int(i) for i in raw_input().split()]
wvlist = input_str(N)
items = [(int(v), int(w)) for w, v in wvlist]
print knapsack(items, W)[0]


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

INF = 998244353

LR = []
for i in range(K):
    LR.append(list(map(int, input().split())))

dp = [0] * N
dp[0] = 1
a_sum = [0] * N
a_sum[0] = 1
for i in range(1, N):
    for lr in LR:
        if i - lr[0] >= 0:
            if i - lr[1]-1 >= 0:
                # print(i, lr, dp[i], i-lr[0], i-lr[1]-1, a_sum[i-lr[0]], a_sum[i-lr[1]-1])
                dp[i] = dp[i] + a_sum[i-lr[0]] - a_sum[i-lr[1]-1]
            else:
                dp[i] = dp[i] + a_sum[i-lr[0]]
    dp[i] %= INF
    a_sum[i] = a_sum[i-1] + dp[i]
    a_sum[i] %= INF
    # print(i, dp, a_sum)
print(dp[-1])


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

using namespace std;

typedef long long ll;
//#define int long long
#define F first
#define S second
#define pii pair<int,int>
#define mpr make_pair

const int maxn = 1e7+10;
const int mod = 998244353;
const ll inf = 1e9+10;

int n;

int pw(int a, int b)
{
    if(b == 0) return 1;
    int x = pw(a,b/2); x = (x * 1ll * x) % mod;
    if(b & 1) x = (x * 1ll * a) % mod;
    return x;
}

int fac[maxn], repo[maxn];
int C(int n, int k)
{
    return (fac[n] * 1ll * ((repo[k] * 1ll * repo[n-k]) % mod)) % mod;
}

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

    cin>> n;
    fac[0] = repo[0] = 1;
    for(int i = 1; i <= n; i++)
        fac[i] = (fac[i-1] * 1ll * i) % mod;
    repo[n] = pw(fac[n], mod-2);
    for(int i = n-1; i >= 1; i--)
        repo[i] = (repo[i+1] * 1ll * (i+1)) % mod;

    int ans = pw(3,n);
    int power = 1;
    for(int k = 0; k <= n/2-1; k++)
    {
        (ans -= (2ll * ((C(n,k) * 1ll * power) % mod)) % mod) %= mod;
        (power *= 2) %= mod;
    }
    cout<< (ans + mod) % mod;
}




Measured memory_bytes: 81648
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <sstream>
#include <set>
#include <map>
#include <vector>
#include <list>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <string>
#include <stack>
#include <queue>
#include <bitset>     //UWAGA - w czasie kompilacji musi byc znany rozmiar wektora - nie mozna go zmienic
#include <cassert>
#include <iomanip>        //do setprecision
#include <ctime>
#include <complex>
using namespace std;

#define FOR(i,b,e) for(int i=(b);i<(e);++i)
#define FORQ(i,b,e) for(int i=(b);i<=(e);++i)
#define FORD(i,b,e) for(int i=(b)-1;i>=(e);--i)
#define REP(x, n) for(int x = 0; x < (n); ++x)

#define ST first
#define ND second
#define PB push_back
#define PF push_front
#define MP make_pair
#define LL long long
#define ULL unsigned LL
#define LD long double
#define pii pair<int,int>
#define pll pair<LL,LL>
#define vi vector<int>
#define vl vector<LL>
#define vii vector<vi>
#define vll vector<vl>

const double pi = 3.14159265358979323846264;
const int mod=1000000007;

int dist(int x,int xx,int y,int yy){
    return (x-xx)*(x-xx)+(y-yy)*(y-yy);
}

LD calcCircleOf2Point(int x1, int y1, int x2, int y2, int x3, int y3, LD& cx, LD& cy, LD& r)
{
	LD 	ox, oy, a, b, c, d ;
	LD 	r1, r2, r3 ;
	int		stat ;
    LD u=1.;

	a = x2 - x1 ;
	b = y2 - y1 ;
	c = x3 - x1 ;
	d = y3 - y1 ;

	stat = 0 ;

	if  ((x2 - x1 && y3 - y1) || (y2 - y1 && x3 - x1)) {
        if(a*d-b*c==0)return 0;
		ox = x1 + (d * (a * a + b * b) - b * (c * c + d * d))*u / (a * d - b * c) / 2 ;
		if  (y2 - y1) {
			oy = (a * (x1 + x2 - ox - ox) + b * (y1 + y2))*u / b / 2 ;
		} else {
			oy = (c * (x1 + x3 - ox - ox) + d * (y1 + y3))*u / d / 2 ;
		}
		r1   = sqrt((ox - x1) * (ox - x1)*u + (oy - y1) * (oy - y1)) ;
		r2   = sqrt((ox - x2) * (ox - x2)*u + (oy - y2) * (oy - y2)) ;
		r3   = sqrt((ox - x3) * (ox - x3)*u + (oy - y3) * (oy - y3)) ;
		cx = ox ;
		cy = oy ;
		r  = (r1 + r2 + r3)*u / 3 ;
		stat = 1 ;
	}

	return stat ;
}

int main(){
	int n;
    cin>>n;
    vi x(n);
    vi y(n);
    FOR(i,0,n){
        cin>>x[i]>>y[i];
        x[i]*=2;
        y[i]*=2;
    }
    LD ans=1000000.;
    const LD unit=1.;
    FOR(i,0,n){
        FOR(j,i+1,n){
            int xx=(x[i]+x[j])/2;
            int yy=(y[i]+y[j])/2;
            int f=1;
            int dd=dist(x[i],xx,y[i],yy);
            FOR(k,0,n){
                int dd2=dist(x[k],xx,y[k],yy);
                if(dd<dd2)f=0;
            }
            if(f)ans=min(ans,sqrt(dd*unit));
        }
    }
    if(n>=3)FOR(i,0,n){
        FOR(j,i+1,n){
            FOR(k,j+1,n){
            LD cx=0,cy=0,r=0;
            int f=calcCircleOf2Point(x[i],y[i],x[j],y[j],x[k],y[k],cx,cy,r);
            FOR(kk,0,n){
                LD rr=(x[kk]-cx)*(x[kk]-cx)+(y[kk]-cy)*(y[kk]-cy);
                if(r<sqrt(rr)-0.0000000001)f=0;
            }
            if(f){
                ans=min(ans,r);
                }
            }
            
        }
    }
    

    cout << setprecision(18)<<ans/2<<endl;

}


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

int main(){
  int N,K,l[50];
  cin>>N>>K;
  for (int i(0);i<N;i++) cin>>l[i];
  sort(l,l+N,greater<int>());
  int sum(0);
  for (int i(0);i<K;i++) cerr << l[i]<< " ";
  for (int i(0);i<K;i++) sum+=l[i];
  cout << sum << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int flag=1,e[12],x[111]={0};
  for(int i=0;i<12;i++){
    cin>>e[i];
    x[e[i]]++;
  }
  for(int i=1;i<=100;i++){
    int ret=0;
    if(x[i]==0) ret++;
    if(x[i]==4) ret++;
    if(x[i]==8) ret++;
    if(x[i]==12) ret++;
    if(ret==0){
      flag=0;
      break;
    }
  }
  if(flag==0) cout<<"no"<<endl;
  else cout<<"yes"<<endl;
  return(0);
}



Measured memory_bytes: 3136
#include<iostream>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int main(){
    string c;
    getline(cin,c);
    printf("%c%d%c\n",c[0],c.length()-2,c[c.length()-1]);
    return 0;
}

Measured memory_bytes: 256
// Copyright (C) 2017 Sayutin Dmitry.
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License as
// published by the Free Software Foundation; version 3

// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.

// You should have received a copy of the GNU General Public License
// along with this program; If not, see <http://www.gnu.org/licenses/>.

#include <iostream>
#include <vector>
#include <stdint.h>
#include <algorithm>
#include <set>
#include <map>
#include <array>
#include <queue>
#include <stack>
#include <functional>
#include <utility>
#include <string>
#include <assert.h>
#include <iterator>
#include <cstdint>
#include <cinttypes>
#include <string.h>
#include <random>
#include <numeric>
#include <tuple>


using std::cin;
using std::cout;
using std::cerr;

using std::vector;
using std::map;
using std::array;
using std::set;
using std::string;

using std::pair;
using std::make_pair;

using std::min;
using std::abs;
using std::max;

using std::unique;
using std::sort;
using std::generate;
using std::reverse;
using std::min_element;
using std::max_element;

#ifdef LOCAL
#define LASSERT(X) assert(X)
#else
#define LASSERT(X) {}
#endif

template <typename T>
T input() {
    T res;
    cin >> res;
    LASSERT(cin);
    return res;
}

template <typename IT>
void input_seq(IT b, IT e) {
    std::generate(b, e, input<typename std::remove_reference<decltype(*b)>::type>);
}

#define SZ(vec)         int((vec).size())
#define ALL(data)       data.begin(),data.end()
#define RALL(data)      data.rbegin(),data.rend()
#define TYPEMAX(type)   std::numeric_limits<type>::max()
#define TYPEMIN(type)   std::numeric_limits<type>::min()

#define pb push_back
#define eb emplace_back


int main() {
    std::iostream::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    
    // code here.
    int n = input<int>();
    int m = input<int>();

    int cnt[3] = {0, 0, 0};
    for (int i = 0; 2 * i <= n - 1; ++i)
        for (int j = 0; 2 * j <= m - 1; ++j)
            cnt[2 - (2 * i == n - 1) - (2 * j == m - 1)] += 1;

    vector<int> letcnt(26);
    for (int i = 0; i != n; ++i)
        for (int j = 0; j != m; ++j) {
            char ch;
            cin >> ch;
            letcnt[ch - 'a'] += 1;
        }

    assert(cnt[0] <= 1);
    
    int num_odd = 0;
    for (int i = 0; i != 26; ++i)
        num_odd += (letcnt[i] % 2 == 1);

    if (num_odd != cnt[0]) {
        cout << "No\n";
        return 0;
    }

    for (int i = 0; i != 26; ++i)
        letcnt[i] -= letcnt[i] % 2;

    for (int i = 0; i != 26; ++i) {
        while (letcnt[i] >= 4 and cnt[2] != 0) {
            letcnt[i] -= 4;
            cnt[2] -= 1;
        }

        while (letcnt[i] >= 2) {
            letcnt[i] -= 2;
            cnt[1] -= 1;
        }
    }

    if (cnt[1] == 0)
        cout << "Yes\n";
    else
        cout << "No\n";
    
    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define all(vec) vec.begin(), vec.end()
#define tmax(x,y,z) max((x),max((y),(z)))
#define tmin(x,y,z) min((x),min((y),(z)))
typedef long long ll; ll MM = 1000000000;ll mod = MM + 7; ll MMM=9223372036854775807;//2^63 -1
ll GCD(ll x, ll y) {if (y == 0) return x;else return GCD(y, x % y);}
ll LCM(ll x, ll y) { return x / GCD(x, y) * y;}
//cout << fixed << setprecision(10);
ll fac(ll x){if(x==0) return 1;  return x*fac(x-1);}

int main(){
    ll a,b; cin>>a>>b;
    cout<<max(max(a+b,a-b),a*b)<<endl;
}

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

using ll = long long;
using vll = vector<ll>;
using pl4 = pair<ll,ll>;
using str = string;
using vpl4 = vector<pair<ll,ll>>;

#define sz size()
#define be begin()
#define en end()
#define fi first
#define se second
#define pb push_back
#define mp make_pair

#define llin(x) ll (x);cin >>(x);
#define stin(x) str (x);cin >>(x);
#define FOR(i,a,b) for(ll i = a ; i <= b ; i++)
#define rFOR(i,b,a) for(ll i = a; i >= b ; i--)
#define SORT(x) sort(x.be, x.en)
#define rSORT(x) sort(x.rbegin(), x.rend())
#define say(x) cout<<(x);
#define sal(x) cout<<(x)<<endl;
#define yn(a) cout <<((a)?"yes":"no")<<endl;
#define Yn(a) cout <<((a)?"Yes":"No")<<endl;
#define YN(a) cout <<((a)?"YES":"NO")<<endl;
#define Imp(a) cout <<((a)?"Possible":"Impossible")<<endl;
#define IMP(a) cout <<((a)?"POSSIBLE":"IMPOSSIBLE")<<endl;

signed main(){
    llin(h);
    llin(w);
    vector<str> s(h);
    vector<vector<ll>> v(h,vll (w,0));
    ll k=1;
    FOR(i,0,h-1){
        cin >>s[i];
    }
    FOR(i,0,h-1){
        FOR(j,0,w-1){
            if(s[i][j]=='#'){
                v[i][j]=k;
                k++;
            }
        }
    }
    ll g=1;
    vll t={(-1),1,0,0};
    while(g==1){
        g=0;
    FOR(i,0,h-1){
        FOR(j,0,w-1){
            if(v[i][j]>0){
                FOR(l,0,3){
                    if(i+t[l]>=0&&i+t[l]<h&&j+t[3-l]>=0&&j+t[3-l]<w&&v[i+t[l]][j+t[(3-l)]]<=0){
                        if(v[i][j]+v[i+t[l]][j+t[(3-l)]]>0){
                            v[i+t[l]][j+t[(3-l)]]=(-v[i][j]);
                            g=1;
                        }else if(v[i][j]+v[i+t[l]][j+t[(3-l)]]<0){
                            v[i][j]=(-v[i+t[l]][j+t[(3-l)]]);
                            g=1;
                        }
                    }
                }
            }
        }
    }
    }
    vll p(k,0);
    vll q(k,0);
    FOR(i,0,h-1){
        FOR(j,0,w-1){
            if(v[i][j]>0){
                p[v[i][j]]++;
            }
            if(v[i][j]<0){
                q[(-v[i][j])]++;
            }
        }
    }
    ll x=0;
    FOR(i,1,k-1){
        x+=p[i]*q[i];
    }
    sal(x);
}


Measured memory_bytes: 3712
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,tune=native")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>

using namespace std;

#define forn(i, s, f) for (int i = s; i < f; i++)
#define ll long long
#define ull unsigned long long
#define ld long double
#define pii pair <int, int>
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x).size()

int main() {
    ios_base::sync_with_stdio(0), cin.tie(0);
    int n, m;
    cin >> n >> m;
    vector <vector <char>> a(n + 2, vector <char> (m + 2, '#'));
    vector <vector <int>> b(n + 1), c(m + 1);
    forn (i, 1, n + 1) {
        forn (j, 1, m + 1) {
            cin >> a[i][j];
            if (a[i][j] == '.')
                continue;
            b[i].pb(j), c[j].pb(i);
        }
    }
    forn (i, 1, n + 1) {
        b[i].pb(0), b[i].pb(m + 1);
        sort(all(b[i]));
    }
    forn (i, 1, m + 1) {
        c[i].pb(0), c[i].pb(n + 1);
        sort(all(c[i]));
    }
    int ans = 0;
    forn (i, 1, n + 1) {
        forn (j, 1, m + 1) {
            if (a[i][j] == '#')
                continue;
            int t1 = *upper_bound(all(b[i]), j) - j;
            int t2 = j - *(--lower_bound(all(b[i]), j));
            int t3 = *upper_bound(all(c[j]), i) - i;
            int t4 = i - *(--lower_bound(all(c[j]), i));
            //cout << i << " " << j << ":  " << t1 << " " << t2 << " " << t3 << " " << t4 << "\n";
            ans = max(ans, t1 + t2 + t3 + t4 - 3);
        }
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 38400
#include <iostream>
#include <algorithm>
#include <vector>
#include <sstream>
using namespace std;

string table[10001];

string itos(int n){
	stringstream ss;
	ss << n;
	return ss.str();
}

int main(){
	for(int i = 1 ; i <= 10000 ; i++){
		if(i%15==0){
			table[i] = "FizzBuzz";
		}else if(i%3==0){
			table[i] = "Fizz";
		}else if(i%5==0){
			table[i] = "Buzz";
		}else{
			table[i] = itos(i);
		}
	}
	int n,m;
	while(cin >> n >> m && n){
		vector<int> v(n);
		for(int i = 0 ; i < n ; i++) v[i] = i;
		int x = 0;
		for(int z = 1 ; z <= m ; z++){
			string s; cin >> s;
			if(v.size()==1) continue;
			if(s != table[z]){
				v.erase(remove(v.begin(),v.end(),v[x]),v.end());
			}else{
				x++;
			}
			x %= v.size();
		}
		for(int i = 0 ; i < v.size() ; i++)
			cout << v[i]+1 << (v.size()-1==i?"\n":" ");
	}
}

Measured memory_bytes: 0
#include<iostream>
#include<queue>
using namespace std;
int h,w;
char s[66][33];
int d[2][66][33];
main()
{
	while(cin>>w>>h,w)
	{
		for(int i=0;i<h;i++)for(int j=0;j<w;j++)
		{
			cin>>s[i][j];
			d[0][i][j]=d[1][i][j]=1e9;
		}
		priority_queue<pair<pair<int,int>,pair<int,int> > >P;
		for(int i=0;i<w;i++)if(s[h-1][i]=='S')
		{
			for(int j=0;j<2;j++)
			{
				P.push({{0,j},{h-1,i}});
				d[j][h-1][i]=0;
			}
		}
		while(!P.empty())
		{
			int c,r,x,y;
			c=-P.top().first.first;
			r=P.top().first.second;
			x=P.top().second.first;
			y=P.top().second.second;
			P.pop();
			if(d[r][x][y]<c)continue;
			if(r)
			{
				for(int tx=x-2;tx<=x+2;tx++)
				{
					for(int ty=y-3;ty<y;ty++)
					{
						if(abs(tx-x)+abs(ty-y)>3)continue;
						if(tx<0||ty<0||tx>=h||ty>=w||s[tx][ty]=='X')continue;
						int cost=c+(s[tx][ty]>'A'?0:s[tx][ty]-'0');
						if(d[!r][tx][ty]>cost)
						{
							d[!r][tx][ty]=cost;
							P.push({{-cost,!r},{tx,ty}});
						}
					}
				}
			}
			else
			{
				for(int tx=x-2;tx<=x+2;tx++)
				{
					for(int ty=y+1;ty<=y+3;ty++)
					{
						if(abs(tx-x)+abs(ty-y)>3)continue;
						if(tx<0||ty<0||tx>=h||ty>=w||s[tx][ty]=='X')continue;
						int cost=c+(s[tx][ty]>'A'?0:s[tx][ty]-'0');
						if(d[!r][tx][ty]>cost)
						{
							d[!r][tx][ty]=cost;
							P.push({{-cost,!r},{tx,ty}});
						}
					}
				}
			}
		}
		int ans=1e9;
		for(int i=0;i<w;i++)if(s[0][i]=='T')ans=min(ans,min(d[0][0][i],d[1][0][i]));
		cout<<(ans<1e9?ans:-1)<<endl;
	}
}



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

print(0, flush=True)
begin = input()

l, r = 0, N
while abs(r - l) > 1:
    mid = (l+r) // 2
    print(mid, flush=True)
    sol = input()
    if sol == "Vacant":
        l = mid
        break
    elif mid % 2 == 0:
        if sol != begin:
            r = mid
        else:
            l = mid
    else:
        if sol != begin:
            l = mid
        else:
            r = mid

print(l)


Measured memory_bytes: 74752
N,M = map(int,input().split())
S = [list(map(int,input().split())) for _ in range(M)]
P = list(map(int,input().split()))
ans = 0
for i in range(2**N):
  count = 0
  on_or_off = [0]*M
  for j in range(N):
    if (i>>j)&1:
      for k in range(M):
        if j+1 in S[k][1:]:
          on_or_off[k] += 1
  for l in range(M):
    if on_or_off[l]%2 == P[l]:
      count += 1
  if count == M:
    ans += 1
print(ans)

Measured memory_bytes: 73072
from itertools import accumulate

S = int(input())
mod = 10**9 + 7
if S == 1 or S == 2:
    print(0)
    exit()
dp = [0] * (S + 1)
dp[0] = 1
ans = 0
for i in range(S):
    cum = list(accumulate(dp))
    for j in range(S, 2, -1):
        dp[j] = cum[j-3] % mod
    dp[0] = dp[1] = dp[2] = 0
    ans = (ans + dp[S]) % mod
print(ans)

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

using namespace std;

const int maxn=1e6+5;

typedef long long ll;

const ll mod=1e9+7;

ll a[maxn];

int num[maxn];

ll qPow(ll a,ll b){
	ll ans=1;
	while(b){
		if(b&1) ans=(ans*a)%mod;
		a=(a*a)%mod;
		b>>=1;
	}
	return ans;
}

int main(){
	int n,m;
	scanf("%d%d",&n,&m);
	printf("%d",(n-1)/m+1);
	return 0;
} 

Measured memory_bytes: 256