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

typedef long long lint;
typedef long double louble;

template<typename T1,typename T2> inline T1 max(T1 a,T2 b){return a<b?b:a;}
template<typename T1,typename T2> inline T1 min(T1 a,T2 b){return a<b?a:b;}

namespace ae86
{
	const int bufl = 1<<15;
	
	char buf[bufl],*s=buf,*t=buf;
	
	inline int fetch()
	{
		if(s==t){t=(s=buf)+fread(buf,1,bufl,stdin);if(s==t)return EOF;}
		return *s++;
	}
	
	inline int ty()
	{
		int a=0,b=1,c=fetch();
		while(!isdigit(c))b^=c=='-',c=fetch();
		while(isdigit(c))a=a*10+c-48,c=fetch();
		return b?a:-a;
	}
}
using ae86::ty;

const int _ = 100007;

struct cxk
{
	int v,x;
	cxk(int _v=0,int _x=0){v=_v,x=_x;}
	inline friend int operator < (cxk a,cxk b){return a.v<b.v;}
}q[_];

int n;

int main()
{
	n=ty();
	for(int i=1;i<=n;i++)q[i]=cxk(ty(),i);
	sort(q+1,q+n+1);
	int ans=0;
	for(int i=1;i<=n;i++)ans+=(q[i].x-i)&1;
	printf("%d\n",ans/2);

	return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
#include<math.h>
using namespace std;
typedef long long ll;
#define ds(q) scanf("%lld",&q)
pair<ll,ll>ans[100005];
ll gcd(ll a,ll b)
{
    return b==0?a:gcd(b,a%b);
}
ll solve(ll x)
{
    ll c=0;
    for(ll i=2;i<=sqrt(x);i++)
    {
        if(x%i==0)
            c++;
        while(x%i==0)
        {
            x/=i;
        }
    }
    if(x!=1)
        c++;

    return c;
}
int main()
{
    ll a,b;
    ds(a);
    ds(b);
    ll x=gcd(a,b);
    printf("%lld",solve(x)+1);
    return 0;
}


Measured memory_bytes: 256
from collections import deque

n, u, v = map(int, input().split())
tree = [[] for _ in range(n)]
for i in range(n-1):
  a, b = map(int, input().split())
  tree[a-1].append(b-1)
  tree[b-1].append(a-1)

not_yet = deque([u-1])
already = [False]*n
already[u-1] = True
dist = [0]*n

while not_yet:
  key = not_yet.popleft()
  for value in tree[key]:
    if already[value]:
      continue
    dist[value] = dist[key] + 1
    already[value] = True
    not_yet.append(value)
  
not_yet = deque([v-1])
already = [False]*n
already[v-1] = True
dist2 = [0]*n

while not_yet:
  key = not_yet.popleft()
  for value in tree[key]:
    if already[value]:
      continue
    dist2[value] = dist2[key] + 1
    already[value] = True
    not_yet.append(value)

judge = dist[v-1]
ans = 0
for i in range(n):
  if dist[i]+dist2[i] > judge:
    if dist[i] >= dist2[i]:
      continue
    sub = dist2[i]-1
  else:
    sub = judge-1
  if sub > ans:
    ans = sub
print(ans)

Measured memory_bytes: 30156
#include <iostream>
#include <algorithm>
using namespace std;
#define MAX 110
#define MAX_E 1010
#define INF 10000000


int e[MAX][MAX];
int d[MAX][MAX];
int n;

void warshall_floyd() {
  for (int k = 0; k < n; k++) {
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < n; j++) {
        if (d[i][j] > d[i][k] + d[k][j]) {
          d[i][j] = d[i][k] + d[k][j];
        }
      }
    }
  }
}

bool contains(int i, int j) {
  for (int s = 0; s < n; s++) {
    if (s == j) continue;
    if (d[s][i] + e[i][j] == d[s][j]) return true;
  }
  return false;
}

int main() {
  for (int i = 0; i < MAX; i++) {
    for (int j = 0; j < MAX; j++) {
      if (i == j) d[i][j] = 0;
      else d[i][j] = INF;
    }
  }
  int m;
  cin >> n >> m;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      if (i == j) e[i][j] = 0;
      else e[i][j] = INF;
    }
  }
  for (int i = 0; i < m; i++) {
    int a, b, c;
    cin >> a >> b >> c;
    e[a - 1][b - 1] = c;
    e[b - 1][a - 1] = c;
    d[a - 1][b - 1] = c;
    d[b - 1][a - 1] = c;
  }
  warshall_floyd();
  int ans = 0;
  for (int i = 0; i < n; i++) {
    for (int j = i; j < n; j++) {
      if (e[i][j] != INF && e[i][j] > d[i][j]) ans++;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 384
#include <iostream>


int main() 
{
    size_t value;
    std::cin >> value;
    size_t happy_500 = value / 500 * 1000;
    size_t happy_5 = (value % 500) / 5 * 5;
    std::cout << happy_500 + happy_5 << std::endl;
}


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

#define int long long
#define ll long long
#define pb push_back

main(){
    int n, x, y;
    cin >> n >> x >> y;
    vector<vector<int>> g(n);
    vector<int> ans(n);
    for(int i = 0; i < n - 1; i++){
        g[i].pb(i + 1);
        g[i + 1].pb(i);
    }
    g[x - 1].pb(y - 1);
    g[y - 1].pb(x - 1);
    for(int i = 0; i < n; i++){
        queue <int> ty;
        ty.push(i);
        vector<int> h(n);
        for(int j = 0; j < n; j++) h[j] = 100000000;
        h[i] = 0;
        while (ty.empty() == 0){
            int r = ty.front();
            ty.pop();
            for(int j = 0; j < g[r].size(); j++){
                if (h[g[r][j]] == 100000000){
                    h[g[r][j]] = h[r] + 1;
                    ans[h[r]]++;
                    ty.push(g[r][j]);
                }
            }
        }
    }
    for(int i = 0; i < n - 1; i++){
        cout << ans[i] / 2 << '\n';
    }
}


Measured memory_bytes: 384
def insertionSort(a, n)
  puts a.join(' ')
  for i in 1..(n-1) do
    v = a[i]
    j = i - 1
    while j >= 0 && a[j] > v do
      a[j+1] = a[j]
      j -= 1
      a[j+1] = v
    end
    puts a.join(' ')
  end
end

n = gets.to_i
a = gets.split(" ").map(&:to_i)
insertionSort(a, n)



Measured memory_bytes: 6888
//#include "bits/stdc++.h"

#define _USE_MATH_DEFINES
#include<cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iterator>
#include<iomanip>

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

//typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<int, double> pid;
typedef pair<double, int> pdi;
typedef pair<double, double> pdd;
typedef vector< vector<int> > mat;

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

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;

int N, K;
int A[200010];

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

	cin >> N >> K;
	rep(i, 0, N)
	{
		cin >> A[i];
		A[i]--;
	}

	rep(i, 1, N)
	{
		A[i] += A[i - 1];
	}

	map<int, int> vmap;
	int ans = 0;
	rep(i, 0, N)
	{
		A[i] %= K;
		if (i - K >= 0)vmap[A[i - K]]--;
		if (i < K - 1 && A[i] == 0)ans++;
		if (vmap.find(A[i]) != vmap.end())ans += vmap[A[i]];
		vmap[A[i]]++;
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 14336
const main = input => input.split('\n').slice(1).filter(x => x).map(line => line.split('')).map((vs, i, matrix) => vs.map((v, j) => v === '#' ? '#' : [i - 1, i, i + 1].filter(x => matrix[x]).map(x => [j - 1, j, j + 1].map(y => matrix[x][y] === '#' ? 1 : 0).reduce((a, b) => a + b)).reduce((a, b) => a + b)).join('')).join('\n');

console.log(main(require('fs').readFileSync('/dev/stdin', 'utf8')));


Measured memory_bytes: 10484
import java.util.*;
import java.io.*;

public class Main {
    public static void main(String[] args){
        Main main = new Main();
        main.solve();
    }
    void solve(){
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] a = new int[N];
        for(int i=0;i<N;i++) a[i]=sc.nextInt();
        int nextValue = 1, ans = 0;
        for(int i=0;i<N;i++){
            if(a[i]==nextValue){
                nextValue += 1;
                ans += 1;
            }
        }
        if(ans==0) ans = -1;
        else ans = N-ans;
        System.out.println(ans);
    }
}


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


int main(){
  	string a,b,c;
  	cin >> a >> b;
  	c = a+b;
  	int n = stoi(c);
  
  	rep(i,0,100100){
      	if(i*i == n){
          	cout << "Yes" << endl;
          	return 0;
        }
    }
  	
  	cout << "No" << endl;
  	
 	return 0; 
}


Measured memory_bytes: 256
#include <iostream>
#include <set>
#include <vector>
#include <string>
#include <algorithm>
#include <iterator>
#include <map>
#include <utility>
#include <list>
#include <climits>
#include <bitset>
#include <numeric>

using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)
#define repi(i, n) for(auto i = (n).begin(); i != (n).end(); i++)
#define in_arr(type, a, n) copy_n(istream_iterator<type>(cin), n, (a).begin());
#define ll long long int

int main(){
    int n, W;
    cin >> n >> W;
    vector<int> v(n), w(n);
    vector< vector<int> > dp(n + 1);
    repi(i, dp){
        *i = vector<int>(W + 1, 0);
    }
    rep(i, n){
        cin >> v[i] >> w[i];
    }
    rep(i, n){
        rep(j, W){
            dp[i + 1][j + 1] = dp[i][j + 1];
            if(j + 1 - w[i] >= 0){
                dp[i + 1][j + 1] = max(dp[i + 1][j + 1], dp[i][j + 1 - w[i]] + v[i]);
            }
        }
    }
    cout << dp[n][W] << endl;
    return 0;
}



Measured memory_bytes: 6792
#include <iostream>
#include <string>

using namespace std;

int const NMAX = 1e5;
int v[1 + NMAX];

int main() {

  int n, pos = 1, p, ans = 1;
  string GUIDO;
  cin >> n >> p;
  for(int i = max(p - n + 1, -1000000);i <= min(p + n - 1, 1000000);i++){
    cout << i << ' ';
  }
  return 0;
}


Measured memory_bytes: 3624
#include<bits/stdc++.h>
#define ll long long 
#define vl vector
#define pb push_back
#define ff first
#define ss second
using namespace std;

int main()
{
    ll n,m,i,a,b;
    char c;
    cin>>c;
    if('a'<=c && c<='z') cout<<"a";
    else cout<<"A";
    
}

Measured memory_bytes: 3628
#include <cstdio>
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <stack>
#include <functional>
#include <set>
#include <map>
#include <deque>
#define WMAX 10000
#define HMAX 10000

//コメントアウトするとdebug()を実行しない
#define DEBUG

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

typedef pair<int ,int > P;
typedef long long ll;

int A,B,C,N,W,H,ans,dp[HMAX][WMAX];
string S[3];
static const int dx[8] = {0,1,1,1,0,-1,-1,-1},
					dy[8] = {1,1,0,-1,-1,-1,0,1};

void solve(){

}

void debug(){

}

void answer(){
	for (int i = 0; i < 3; ++i)
	{
		char c;
		c = toupper(S[i][0]);
		cout << c;
	}
	cout << "\n";
}

int main(){
	for (int i = 0; i < 3; ++i)
	{
		cin >> S[i];
	}
	solve();
	#ifdef DEBUG
	debug();
	#endif
	answer();

	return 0;
}

Measured memory_bytes: 256
<?php
  	$input = trim(fgets(STDIN));
	$array = explode(" ",$input);
	$a = ($array[1]) - ($array[0]) + 1;
	$b = ($array[1]) + ($array[0]) - 1;
	for($i = $a; $i <= $b; $i++){
	    if($i != $b){
            echo   $i.' ';   	        
	    }else{
            echo $b;
	    }
	}  
?>

Measured memory_bytes: 3828
package main

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

var sc = bufio.NewScanner(os.Stdin)

func nextInt() int {
	var i int
	if sc.Scan() {
		if num, err := strconv.Atoi(sc.Text()); err == nil {
			i = num
		}
	}
	return i
}

func main() {
	sc.Split(bufio.ScanWords)
	n := nextInt()
	var sum int
	for i := 1; i <= n && i <= int(math.Pow(10, 6)); i++ {
		if i%3 != 0 && i%5 != 0 {
			sum += i
		}
	}
	fmt.Println(sum)
}


Measured memory_bytes: 1772
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <queue>
#define llint long long
#define inf 1e18

using namespace std;
typedef pair<llint, llint> P;

struct edge{
	llint to, cap, rev;
	edge(llint a, llint b, llint c){
		to = a, cap = b, rev = c;
	}
};

llint m, n;
llint b[505], r[505];

vector<edge> G[1005];
llint S, T;
llint level[1005], iter[1005];

void bfs(llint s)
{
	for(int i = 1; i <= T; i++) level[i] = inf;
	level[s] = 0;
	
	queue<int> Q;
	Q.push(s);
	while(Q.size()){
		int v = Q.front();
		Q.pop();
		for(int i = 0; i < G[v].size(); i++){
			int u = G[v][i].to;
			if(G[v][i].cap <= 0 || level[u] < inf) continue;
			level[u] = level[v] + 1;
			Q.push(u);
		}
	}
}

llint dfs(int v, llint f)
{
	if(v == T) return f;
	
	llint ret;
	for(llint &i = iter[v]; i < G[v].size(); i++){
		if(level[v] >= level[G[v][i].to] || G[v][i].cap <= 0) continue;
		ret = dfs(G[v][i].to, min(f, G[v][i].cap));
		if(ret > 0){
			G[v][i].cap -= ret;
			G[G[v][i].to][G[v][i].rev].cap += ret;
			return ret;
		}
	}
	return 0;
}

void add_edge(int s, int t, llint cap)
{
	G[s].push_back(edge(t, cap, G[t].size()));
	G[t].push_back(edge(s, 0, G[s].size()-1));
}

llint gcd(llint a, llint b)
{
	if(b == 0) return a;
	return gcd(b, a%b);
}

int main(void)
{
	while(1){
		cin >> m >> n;
		if(n == 0 || m == 0) break;
		
		for(int i = 1; i <= m; i++) cin >> b[i];
		for(int i = 1; i <= n; i++) cin >> r[i];
		
		S = n+m+1, T = n+m+2;
		for(int i = 1; i <= T; i++) G[i].clear();
		for(int i = 1; i <= m; i++){
			for(int j = 1; j <= n; j++){
				if(gcd(b[i], r[j]) > 1) add_edge(i, m+j, 1);
			}
		}
		for(int i = 1; i <= m; i++) add_edge(S, i, 1);
		for(int i = 1; i <= n; i++) add_edge(m+i, T, 1);
		
		llint ans = 0, flow;
		while(1){
			bfs(S);
			if(level[T] >= inf) break;
			for(int i = 1; i <= T; i++) iter[i] = 0;
			while(1){
				flow = dfs(S, inf);
				if(flow <= 0) break;
				ans += flow;
			}
		}
		cout << ans << endl;
	}
	return 0;
}


Measured memory_bytes: 15768
n, w = map(int, input().split())
arr = [list(map(int, input().split())) for _ in range(n)]

# 最大化問題なので0で初期化
dp = [[0] * (w + 1) for _ in range(n + 1)]

# 品物iを選ばない場合で更新してから、選べる場合は再更新
for i in range(1, n + 1):
    for j in range(w + 1):
        dp[i][j] = dp[i - 1][j]
        if j - arr[i - 1][0] >= 0:
            dp[i][j] = max(dp[i][j], dp[i - 1][j - arr[i - 1][0]] + arr[i - 1][1])

print(dp[n][w])

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

using namespace std;

struct Manachan
{
  vector< int > radius;

  void build(const string &s)
  {
    radius.resize(s.size());

    int i = 0, j = 0;
    while(i < s.size()) {
      while(i - j >= 0 && i + j < s.size() && s[i - j] == s[i + j]) {
        ++j;
      }
      radius[i] = j;
      int k = 1;
      while(i - k >= 0 && i + k < s.size() && k + radius[i - k] < j) {
        radius[i + k] = radius[i - k];
        ++k;
      }
      i += k;
      j -= k;
    }
  }

  int operator[](const int k) const
  {
    return (radius[k]);
  }

  size_t size()
  {
    return (radius.size());
  }
};

const int _base = 1e9 + 7;

struct RollingHash
{
  vector< unsigned long long > hashed, power;

  RollingHash(const string &s)
  {
    int sz = s.size();
    hashed.assign(sz + 1, 0);
    power.assign(sz + 1, 0);

    power[0] = 1;
    for(int i = 0; i < sz; i++) {
      power[i + 1] = power[i] * _base;
    }
    for(int i = 0; i < sz; i++) {
      hashed[i + 1] = (hashed[i] + s[i]) * _base;
    }
  }

  unsigned long long get(int l, int r) // [l, r)
  {
    return ((hashed[r] - hashed[l] * power[r - l]));
  }
};

int main()
{
  string S, T;
  cin >> S >> T;

  string A[2];
  A[0] += S[0], A[1] += T[0];
  for(int i = 1; i < S.size(); i++) A[0] += "$", A[0] += S[i];
  for(int i = 1; i < T.size(); i++) A[1] += "$", A[1] += T[i];

  Manachan latte[2];
  latte[0].build(A[0]), latte[1].build(A[1]);

  priority_queue< tuple< int, int, int > > que;
  map< unsigned long long, int > sz[2];
  RollingHash hash[2] = {RollingHash(A[0]), RollingHash(A[1])};

  auto gethash = [&](int idx, int center, int length)
  {
    return (hash[idx].get(center - length + 1, center + length));
  };

  for(int z = 0; z < 2; z++) {
    for(int i = 0; i < latte[z].size(); i++) {
      if(sz[z][gethash(z, i, latte[z][i])]++ == 0) {
        que.emplace(latte[z][i], i, z);
      }
    }
  }

  long long ret = 0;

  while(!que.empty()) {
    int length, center, idx;
    tie(length, center, idx) = que.top();
    que.pop();

    auto hash1 = gethash(idx, center, length);

    if(A[idx][center - length + 1] != '$' && idx == 0) {
      ret += 1LL * sz[0][hash1] * sz[1][hash1];
    }

    if(length > 1) {
      auto hash2 = gethash(idx, center, length - 1);
      if(!sz[idx].count(hash2)) que.emplace(length - 1, center, idx);
      sz[idx][hash2] += sz[idx][hash1];
    }
  }

  cout << ret << endl;
}

Measured memory_bytes: 23936
// Date: 2020-04-17

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

typedef long long LL;
typedef long double LD;
typedef vector<int> VI;
typedef pair<LL, LL> pll;
typedef pair<int, int> pii;
#define IO freopen("in.txt", "r", stdin);freopen("out.txt", "w", stdout)
#define FIO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define rep(i, a, b) for(int i = int(a); i <= int(b); ++i)
#define per(i, b, a) for(int i = int(b); i >= int(a); --i)
#define D(x) cout << #x << " = " << x << endl;
#define mem(x, y) memset(x, y, sizeof(x))
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)x.size())
#define mk make_pair
#define pb push_back
#define fi first
#define se second
const LL INF = 1e18;
const LL mod = 1e9 + 7;
const int inf = 0x3f3f3f3f;
const int N = 2e5 + 10;
template <typename T> void chkmax(T &x, T y) { x = max(x, y); }
template <typename T> void chkmin(T &x, T y) { x = min(x, y); }
LL qpow(LL x, LL y, LL MOD) {LL a=1; while(y){ if(y&1) a=a*x%MOD; x=x*x%MOD; y>>=1; } return a;}

int a[N], n;
int main() {
    FIO;
    cin >> n;
    n *= 2;
    rep(i, 1, n) cin >> a[i];
    sort(a+1, a+1+n);
    int ans = 0;
    for(int i = 1; i <= n; i += 2) ans += a[i];
    cout << ans;

    return 0;
}

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

int main()
{
    long long a, b, c, d, N;
    cin >> a >> b >> c >> d >> N;

    N *= 4;

    if(2*a < b) b = 2*a;
    if(2*b < c) c = 2*b;
    if(2*c < d) d = 2*c;

    long long res = 0;
    res += (N/8)*d;
    N %= 8;
    res += (N/4)*c;
    N %= 4;
    res += (N/2)*b;
    N %= 2;
    res += (N)*a;

    cout << res << '\n';
    return 0;
}

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

using namespace std;
int main(){
	int n,x,i,a[1000],ans = 0,k = -1;
	cin >> n >> x;
	for(i=0;i<n;i++){
		cin >> a[i];
	}
	sort(a,a+n);
	for(i=0;i<n;i++){
		if(a[i]<=x){
			x -= a[i];
			ans++;
			k = i;
		}
	}
	if(k==n-1 && x>0){
		ans--;
	}
	cout << ans << endl;
}

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

int dp[4000][4000];
int b[4000];
int sum[4000];

int main(){
	int n,m;cin>>n>>m;
	string s;cin>>s;
	vector<P>v;
	rep(i,m){
		int l,r;scanf("%d%d",&l,&r);l--;r--;
		if(v.empty())v.push_back(P(l,r));
		else if(v.back().first==l)v.back().second=max(v.back().second,r);
		else if(v.back().second<r)v.push_back(P(l,r));
	}
	for(auto p:v)b[p.first]=p.second;
	for(int i=1;i<n;i++)b[i]=max({i,b[i],b[i-1]});
	int cnt=0;
	rep(i,n){
		if(s[i]=='1')cnt++;
		sum[i]=cnt;
	}
	dp[0][cnt]=1;
	rep(i,n)rep(j,cnt+1){
		if(dp[i][j]==0)continue;
		int a=j-(sum[n-1]-sum[b[i]]);
		if(a)(dp[i+1][j-1]+=dp[i][j])%=MOD;
		if(b[i]-i+1-a)(dp[i+1][j]+=dp[i][j])%=MOD;
	}
	cout<<dp[n][0]<<endl;
  
    return 0;
}

Measured memory_bytes: 45952
while True:
    Name, Type = input().split()
    
    if Type=='X':
        break
    
    if '_' in Name:
        
        Name_ = Name
        _n_ = [0]
        i = 0
        while True:
            Namelist_ = list(Name_)
            n_ = Name_.find('_')
            if n_==-1:
                break
            _n_.append(n_+_n_[i])
            i += 1
            del(Namelist_[0:n_+1])
            Name_ = ''.join(Namelist_)
        
        Name = ''.join(Name.split('_'))
        Namelist = list(Name)
        for i in range(len(_n_)):
            o = str(Namelist[_n_[i]])
            O = o.upper()
            Namelist.pop(_n_[i])
            Namelist.insert(_n_[i],O)
        Name = ''.join(Namelist)
        
    if Type=='U':
        NameLIST = list(Name)
        o = str(NameLIST[0])
        O = o.upper()
        NameLIST.pop(0)
        NameLIST.insert(0,O)
        NAME = ''.join(NameLIST)
    
    if Type=='L':
        NameLIST = list(Name)
        O = str(NameLIST[0])
        o = O.lower()
        NameLIST.pop(0)
        NameLIST.insert(0,o)
        NAME = ''.join(NameLIST)
    
    if Type=='D':
        NameLIST = list(Name)
        _T_ = []
        t = 0
        for i in range(len(NameLIST)):
            T = str(NameLIST[i])
            if T.isupper()==False:
                pass
            if T.isupper()==True:
                if i==0:
                    pass
                if i>0:
                    _T_.append(i+t)
                    t += 1
                Tt = T.lower()
                NameLIST.pop(i)
                NameLIST.insert(i,Tt)
        for i in range(len(_T_)):
            NameLIST.insert(_T_[i],'_')
        NAME = ''.join(NameLIST)
        
    
    print(NAME)


Measured memory_bytes: 5572
from collections import Counter

n = int(input())
a = list(map(int, input().split()))


xc = Counter()
yc = Counter()
for i, v in enumerate(a):
    xc[i + v] += 1
    yc[i - v] += 1
ans = 0
for v in xc:
    ans += xc[v] * yc[v]
print(ans)


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

using namespace std;
typedef long long ll;

#define REP(i, n) for (ll i = 0; i < (n); i++)
#define REPR(i, n) for (ll i = (n); i >= 0; i--)
#define FOR(i, m, n) for (ll i = (m); i < (n); i++)
#define FORR(i, m, n) for (ll i = (m); i >= (n); i--)
#define INF 1e9
#define pb push_back
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((ll)(x).size())
#define SORT(x) sort((x).begin(), (x).end())
#define dump(x) cerr << #x << " = " << (x) << endl
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" \
                      << " " << __FILE__ << endl

int main(int argc, char const *argv[])
{
    string s;
    cin >> s;
    ll res = 0;
    REP(i, 3)
    {
        if (s[i] == '1')
            res++;
    }
    cout << res << endl;
    return 0;
}


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

using ll = long long int;
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()

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


bool my_cp(pair<int, int> a, pair<int, int> b){
  return (double)b.first / (double)(b.second+1) < (double)a.first / (double)(a.second+1);
}

ll cnt_rep = 0;
ll powmod(ll N, ll P, ll M){
  cnt_rep++;
  if(P == 0) return 1;
  if(P%2 == 0){
    ll t = powmod(N, P/2, M);
    return t*t % M;
  }
  return (N * powmod(N, P-1, M)) % M;
}

int N;

void dfs(string s, char m, int N){

  if(s.length() == N){
    cout << s << endl;
  }else{
    for(char c = 'a'; c <= m; c++){
      dfs(s + c, ((c == m)? (m + 1) : m), N);
    }
  }
}





// substr(start, len)

int main(){

  // P2
  cin >> N;
  ll sum = 0;

  rep(i, 1, N+1){
    if(i % 3 != 0 && i % 5 != 0){
      sum += i;
    }
  }

  cout << sum << endl;



  // cout << setprecision(8) << ans << endl;  // For double
// CHECK if it's possible to overflow!!
}

Measured memory_bytes: 3620
MOD = 998244353


def main():
    N = int(input())
    D = list(map(int, input().split()))
    M = max(D)
    cnt = [0] * (M+1)
    for x in D:
        cnt[x] += 1
    if D[0] != 0 or cnt[0] != 1:
        print(0)
        return
    for x in range(1, M+1):
        if cnt[x] == 0:
            print(0)
            return
    ans = 1
    for i in range(1, M):
        ans = (ans * pow(cnt[i], cnt[i+1], MOD)) % MOD
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 54324
def print_sum():
	d = int(raw_input())
	if d == 0: return False
	n, m = int(raw_input()), int(raw_input())
	S = [int(raw_input()) for _ in range(n-1)]
	K = sorted([int(raw_input()) for _ in range(m)], reverse=True)
	S = sorted(S) + [d]
	S_k = [[] for _ in range(len(S))]
	for i, s in enumerate(S):
		for j in range(len(K)-1, -1, -1):
			if K[j] <= s:
				S_k[i].append(K.pop())
			else:
				break
	sum = 0
	S = [0] + S
	for i, sk in enumerate(S_k):
		for k in sk:
			sum += min(k-S[i], S[i+1]-k)
	print sum
	return True

while print_sum():
	pass

Measured memory_bytes: 21032
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
const int INF = 1000000004;
int main () {
  int N, K;
  cin >> N >> K;
  vector<int>hei(N);
  for (int i = 0; i < N; i ++) {
    cin >> hei[i];
  }
  sort(hei.begin(), hei.end());
  int ans = INF;
  for (int i = 0; i < N - K + 1; i ++) {
    int jun = hei[i + K - 1] - hei[i];
    //cout << jun << ' ';
    if (ans > jun) ans = jun;
  }
  //cout << endl;
  cout << ans << endl;
}



Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
int n,m,k[101],p1,p[101],ans;
vector<int> arr[101];
int main() {
    cin>>n>>m;
    for (int i=0; i<m; i++) {
        cin>>k[i];
        for (int j=0; j<k[i]; j++) {cin>>p1; arr[i].push_back(p1-1);}
    }
    for (int i=0; i<m; i++) cin>>p[i];
    for (int i=0; i<(1<<n); i++) {
        int imp=0;
        for (int j=0; j<m; j++) {
            int on=p[j];
            for (int l=0; l<k[j]; l++) {
                if (i&(1<<arr[j][l])) on++;
            }
            if ((on%2)==1) {imp=1; break;}
        }
        if (!imp) ans++;
    }
    cout<<ans<<'\n';
}

Measured memory_bytes: 3652
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <map>
#include <algorithm>
#include <functional>

using namespace std;
using pii = pair<int,int>;

int main() {
    int N;
    cin >> N;
    map<int, int> m[2];
    for (int i = 0; i < N; i++) {
	int x;
	cin >> x;
	m[i % 2][x]++;
    }

    vector<pii> A[2];
    for (int i = 0; i < 2; i++) {
	for (auto &x: m[i]) {
	    A[i].push_back({x.second, x.first});
	}
	A[i].push_back({0, 0});
    }

    for (int i = 0; i < 2; i++) {
	sort(begin(A[i]), end(A[i]), greater<pii>());
    }
    
    int ans = N;
    for (int i = 0; i < 2; i++) {
	for (int j = 0; j < 2; j++) {
	    if (A[0][i].second != A[1][j].second) {
		ans = min(ans, N - A[0][i].first - A[1][j].first);
	    }
	    
	}
    }

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


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

using namespace std;
int dx[4] = {0, 1, 0, -1};
int dy[4] = {1, 0, -1, 0};
bool visited[410][410];
vector<string> s;
int h, w;

bool inside(int a, int b){
    if(a < 0 || a >= h) return false;
    if(b < 0 || b >= w) return false;
    return true;
}

pair<long long, long long> dfs(int a, int b){
    if(visited[a][b]) return make_pair(0, 0);
    visited[a][b] = true;
    long long c1 = 0, c2 = 0;
    if(s[a][b] == '.') c1++;
    else c2++;
    for(int i = 0; i < 4; i++){
        int to_a = a + dy[i], to_b = b + dx[i];
        if(!inside(to_a, to_b)) continue;
        if(s[to_a][to_b] == s[a][b]) continue;
        auto x = dfs(to_a, to_b);
        c1 += x.first;
        c2 += x.second;
    }
    return make_pair(c1, c2);
}

int main(){
    long long ans = 0;
    cin >> h >> w;
    s = vector<string>(h);
    for(int i = 0; i < h; i++){
        cin >> s[i];
    }
    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            if(s[i][j] != '#') continue;
            auto x = dfs(i, j);
            ans += x.first * x.second;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 20608
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <limits>
#include <string>

#define rep(i, n) for (int i = 0; i < (n); i++)
#define repr(i, n) for (int i = (n); i > 0; i--)
#define rep1(i, n) for (int i = 1; i <= (n); i++)
#define all(x) (x).begin(), (x).end()
using namespace std;
using lint = long long;
using P = pair<int, int>;
using V = vector<int>;
constexpr int MOD = 1e9 + 7;

int A, B, C, F, H, I, J, K, L, M, N, S, T, U, W;
// lint A, B, F, H, I, J, K, L, M, N, S, T, U, W;
// string A, B;
int ans = 0;
// string ans;
vector<vector<P>> t;

bool check(int i) {
	rep (j, N) {
		if (i & (1 << j)) {
			for(auto c : t[j]) {
				if (i & (1 << c.first)) {
					if (c.second == 0) {
						return false;
					}
				} else {
					if (c.second == 1) {
						return false;
					}
				}
			}
		}
	}
	return true;
}

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

	cin >> N;
	t.resize(N);
	rep(i, N) {
		cin >> A;
		rep(j, A) {
			cin >> F >> S;
			F--;
			t[i].push_back(make_pair(F, S));
		}
	}

	rep(i, pow(2, N)) {
		if (check(i)) {
			ans = max(ans, __builtin_popcount(i));
		}
	}

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

Measured memory_bytes: 384
N = int(input())
X = list(input())
r = N % 2
F = 0
i = 0


if N % 2 != 0:
  print('No')
  F = 1
  
else:
  while i <= int(N/2-1):
    if X[i] == X[int(i+N/2)]:
      i+=1
      
    else:
      print('No')
      F = 1
      break
      
if F != 1:
  print('Yes')
  

Measured memory_bytes: 3060
Public Class Program
  Shared Sub Main()
    Dim s As String = Console.ReadLine()
    Dim l As Long = s.Length()
    Dim b(0 To l - 1) As Boolean
    Dim dp(0 To l - 1) As Long
    For i As Long = 0 To l - 1
      b(i) = (s(i + If(s(i) = "L", -1, 1)) = s(i))
      dp(i) = 1
    Next
    For i As Long = 0 To l - 1
      If s(i) = "R" AndAlso b(i) Then
        dp(i + 2) += dp(i)
        dp(i) = 0
      End If
    Next
    For i As Long = l - 1 To 0 Step -1
      If s(i) = "L" AndAlso b(i) Then
        dp(i - 2) += dp(i)
        dp(i) = 0
      End If
    Next
    Console.WriteLine(String.Join(Of Long)(" ", dp))
  End Sub
End Class

Measured memory_bytes: 24920
#include <bits/stdc++.h>
#include <numeric>
typedef long long ll;
#define rep(i,a,b) for(int i=a;i<b;++i)
#define rrep(i,a,b) for(int i=a;i>=b;--i)
using namespace std;

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

    ll N, M;
    cin >> N >> M;

    ll res = 0;
    ll used = min(N, M/2);
    res += used;
    N -= used,
    M -= used*2;

    if (M >= 4) res += M/4;

    cout << res << "\n";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define ld long double
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
using P=pair<long long,long long>;
#define rep(i,n) for(long long i=0; i<(long long)n; i++)
#define req(i,n) for(long long i=n-1; i>=0; i--)
#define range(i,a,b) for(long long i=a; i<b; i++)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((long long)(x).size())
#define COUT(x) cout << x << endl
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define onBoard(y,x) (y>=0 && y<h && x>=0 && x<w)
#define pri_que priority_queue
#define vint vector<int>
#define vvint vector<vector<int>>
#define vi vector<int>
#define vvi vector<vector<int>>
#define vs vector<string>
#define vvc vector<vector<char>>
#define vc vector<char>
#define vp vector<pair<int,int>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define show(x) cout<<#x<<"="<<x<<endl;
#define SUM(x) accumulate(x.begin(),x.end(),0)
#define MAX(x) *max_element(x.begin(),x.end())
#define MIN(x) *min_element(x.begin(),x.end())
#define couty cout<<"Yes"<<endl
#define coutn cout<<"No"<<endl
#define coutY cout<<"YES"<<endl
#define coutN cout<<"NO"<<endl
#define yn(x) cout<<(x?"Yes":"No")<<endl
#define YN(x) cout<<(x?"YES":"NO")<<endl
long long gcd(long long a,long long b){return b?gcd(b,a%b):a;}
long long lcm(long long a, long long b){return a/gcd(a,b)*b;}
const long long dx[8]={1,0,-1,0,1,-1,-1,1};
const long long dy[8]={0,1,0,-1,1,1,-1,-1};
const long long INF = 1e15;
const long long MOD = 1e9+7;

signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(15);

    string s; cin >> s;
    yn(s[0]=='9' || s[1]=='9');
}

Measured memory_bytes: 3612
use Math::BigInt;

($a, $b, $c, $d) = split(/ /, <>);
$a = Math::BigInt->new($a);
$b = Math::BigInt->new($b);
$c = Math::BigInt->new($c);
$d = Math::BigInt->new($d);

$a--;
$lcm = Math::BigInt::blcm($c, $d);

print $b - $a - 
	  (
	  (int($b / $c) - int($a / $c))
	+ (int($b / $d) - int($a / $d))
	- (int($b / $lcm) - int($a / $lcm))
	  ) . "\n";


Measured memory_bytes: 4480
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <stack>
#include <queue>
#define llong long long
#define INF (__INT32_MAX__ / 2)

using namespace std;
typedef pair<int, int> ipair;
llong modulo(llong left, llong right) { return (left % right + right) % right; }

string S;
int res[100000];
int main(int argc, char **argv) {
    cin >> S;


    list<int> top, bottom;
    top.push_back(-1);
    for(int i = 0; i < S.size() - 1; ++i) {
        if(S[i] == 'R' && S[i + 1] == 'L')
            bottom.push_back(i);
        if(S[i] == 'L' && S[i + 1] == 'R')
            top.push_back(i);
    }
    top.push_back(S.size() - 1);


    while(!top.empty() && !bottom.empty()) {
        int start = top.front();  top.pop_front();
        int mid = bottom.front();   bottom.pop_front();
        int end = top.front();

        res[mid + 1] += (mid - start) / 2;
        res[mid] += (mid - start) - (mid - start) / 2;

        res[mid] += (end - mid) / 2;
        res[mid + 1] += (end - mid) - (end - mid) / 2;
    }

    for(int i = 0; i < S.size(); ++i) {
        if(i != 0)
            cout << " ";
        cout << res[i];
    }
    cout << endl;

}

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

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n, ma = -1;
	cin >> n;
	vector<vector<int>> v(2, vector<int>(n));
	for (int i = 0; i < 2; i++) {
		for (int j = 0; j < n; j++) {
			cin >> v.at(i).at(j);
		}
	}
	int cnt1 = n, cnt2 = n - 1;
	int sum = 0;
	for (int a = 0; a < n; a++) {
		sum = 0;
		for (int i = 0; i < cnt1; i++) {
			sum += v.at(0).at(i);
		}
		for (int i = cnt2; i < n; i++) {
			sum += v.at(1).at(i);
		}
		ma = max(sum, ma);
		cnt1--;
		cnt2--;
	}
	cout << ma << endl;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
	int n,t1=0,t2=0,t3=0;
	cin >> n;
 	while (n--)
	{
		int t;
		cin >> t;

		if (t % 4 == 0)t1++;
		else if (t % 2 == 0)t2++;
		else t3++;
	}
	if (t2 > 0 && t3<= t1)
		printf("Yes\n");
	else if (t2 == 0 && t3 <= t1 + 1)
		printf("Yes\n");
	else
		printf("No\n");
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, k, n) for (int i = k; i < (int)(n); i++)
#define repd(i, n) for (int i = n-1; i >= 0; i--)
#define rrepd(i, k, n) for (int i = n-1; i >= (int)(k); i--)
#define all(x) (x).begin(),(x).end()
#define chmax(x,y) x=max(x,y)
#define chmin(x,y) x=min(x,y)
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素
#define PB push_back //挿入
#define MP make_pair //pairのコンストラクタ
//V,Pは大文字i,l,bは小文字
using ll = long long;
using Vi = vector<int>;
using VVi = vector<Vi>;
using Vl = vector<ll>;
using VVl = vector<Vl>;
using Vb = vector<bool>;
using VVb = vector<Vb>;
using P = pair<int,int>;
using Pll = pair<ll, ll>;
const ll mod = 1000000007;
const ll inf = 1000000000000;//10の12乗

int main() {
  ll n,m;
  cin >> n >> m;
  ll mi=1,mx=n;
  rep(i,n){
    ll x,y;
    cin >> x >> y;
    chmax(mi,x);chmin(mx,y);
  }
  ll ans=max((ll)0,mx-mi+1);
  cout << ans << endl;
}


Measured memory_bytes: 3588
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>
#include <stack>


using namespace std;
using ll = long long;
using ull = unsigned long long;

const ll INF = 1e16;
const ll MOD = 1e9 + 7;

#define REP(i, n) for(ll i = 0; i < n; i++)





int main() {
    string s;
    cin >> s;
    
    ll n = s.size();
    if(s[0] == '0' || s[n - 1] == '1'){
        cout << -1 << endl;
        return 0;
    }
    REP(i, n - 1){
        if(s[i] != s[n - i - 2]){
            cout << -1 << endl;
            return 0;
        }
    }
    
    vector<pair<ll, ll>> ans;
    ll v = 1;
    for(ll i = 1; i < n; i++){
        if(s[i] == '1'){
            for(; v <= i; v++){
                ans.push_back({v, i + 1});
            }
        }
    }
    ans.push_back({n - 1, n});
    REP(i, ans.size()){
        cout << ans[i].first << ' ' << ans[i].second << endl;
    }
}


Measured memory_bytes: 3312
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def SI(): return sys.stdin.readline()[:-1]

def main():
    cnt=[0]*5
    for _ in range(3):
        a,b=MI()
        cnt[a]+=1
        cnt[b]+=1
    for c in cnt:
        if c>2:
            print("NO")
            exit()
    print("YES")

main()

Measured memory_bytes: 9132
import java.util.Scanner

fun main(args: Array<String>){
    val sc = Scanner(System.`in`)
    val N = sc.nextInt()
    val D = sc.nextInt()
    var counter = 0
    var nowcovered = 0
    while(nowcovered < N){
        nowcovered += 2 * D + 1
        counter++
    }
    println(counter)
}

Measured memory_bytes: 31520
N,K = map(int, input().split())
l_prev = 0
r_prev = 0
ans = 0
mod = 10**9+7
for i in range(N+1):
    l_prev += i
    r_prev += (N-i)
    # print(i,l_prev,r_prev)
    if i+1 >= K:
        ans += r_prev-l_prev+1
        ans %= mod

print(ans%mod)

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

long long nextnum(long long n1, long long n2){
    return n1 + n2;
}

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

    vector<long long> nums(N+1);
  	nums[0]=2;
  	nums[1]=1;
  	//cout <<0 <<" "<< nums[0] << endl;

	//cout << nums[0] << " " << nums[1] << endl;
    int cnt = 1;
    while(1){
        //cout <<cnt <<" "<< nums[cnt] << endl;
      	if (cnt == N) {
          //cout <<N <<" "<< nums[cnt] << endl;
          cout <<nums[cnt] << endl;
          break;
        }
      	cnt++;
        long long ln = nextnum(nums[cnt-1], nums[cnt-2]);
        nums[cnt] = ln;
      	//cout << ln << endl;
     	

      	
    }

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main()
{
  int x,y,r,z;

  scanf("%d%d",&x,&y);

  if(x<y)
    {
      z=x;
      x=y;
      y=z;
    }
  while(y>0)
    {
      r = x % y;
      x = y;
      y = r;
    }

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

  return 0;
}

Measured memory_bytes: 592
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
#include<bitset>
#include<vector>
#include<deque>
#include<queue>
#include<map>
#include<set>
#include<stack>
#include<cmath>
#include<iomanip>
#include <functional>
using namespace std;
typedef long long ll;
const int mod = 1000000007;
const int INF = 1 << 30;
const double EPS = 1e-10;
//cout << fixed << std::setprecision(9)
//memset(a, 0, sizeof(a));
//--------------------------

string s;
int a, b, c, d, x;

int main()
{
	cin >> a >> b;

	cout << max(a + b, max(a - b, a * b)) << endl;

	return 0;
}


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

int main() {
  int N;
  cin >> N;
  
  int A;
  if (N % 2 == 1) {
    A = N / 2 + 1;
  } else {
    A = N / 2;
  }
  cout << A << endl;
}


Measured memory_bytes: 256
N=int(input())
b=[int(i) for i in input().split()]
a=[]

noanswer=0
while len(b)>0:
  for i in range(len(b)-1,-1,-1):
    if b[i]==i+1:
      a.append(b.pop(i))
      break
    if i==0:
      noanswer=1
  if noanswer==1:
    print(-1)
    break

if noanswer==0:
  for i in range(len(a)-1,-1,-1):
    print(a[i])

Measured memory_bytes: 3064
from itertools import accumulate

N, M = map(int, input().split())
acc = [0] * N
for _ in range(M):
    a, b = map(int, input().split())
    if a > b:
        a, b = b, a
    acc[a - 1] += 1
    acc[b - 1] -= 1
acc = list(accumulate(acc))
print("NO") if any(a % 2 for a in acc) else print("YES")


Measured memory_bytes: 13644
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<cstdio>
#include<sstream>
#include<iomanip>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef pair<int,pii> pip;
typedef vector<pip>vip;
const double PI=acos(-1);
const double EPS=1e-8;
const int inf=1e8;
typedef int SegT;
const int defvalue=0;
int main(){
	int n;
	cin>>n;
	ll a,b;
	cin>>a>>b;
	rep(i,n-1){
		ll s,t;
		cin>>s>>t;
		if(a<=s&&b<=t){
			a=s;b=t;
		}else if((double)a/s<(double)b/t){
			ll q=(b-1)/t+1;
			a=s*q;b=t*q;
		}else{
			ll q=(a-1)/s+1;
			a=s*q;b=t*q;
		}
	}
	cout<<a+b<<endl;
}
//3 10
//5 7 -> 10 14
//2 3 -> 8 12







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

int main( void ) {
   // ios::sync_with_stdio( false );
    int n, k;
    cin >> n >> k;
    double ans = 0;
    for( int i = 1; i <= n; ++i ) {
        if( i < k ) {
            int sum = i, cnt = 0;
            double a = 1.0 / double( n );
            for( int j = sum; j < k; j *= 2 ) ++cnt;
            double b = pow( 0.5, cnt );
            ans += a * b;
        }
        else ans += 1.0 / double( n );
    }
    printf("%.12lf\n", ans );
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>  
#include <algorithm>  
#include <assert.h>
#include <bitset>
#include <cmath>  
#include <complex>  
#include <deque>  
#include <functional>  
#include <iostream>  
#include <limits.h>  
#include <map>  
#include <math.h>  
#include <queue>  
#include <set>  
#include <stdlib.h>  
#include <string.h>  
#include <string>  
#include <time.h>  
#include <unordered_map>  
#include <unordered_set>  
#include <vector>  
#define ll long long
#define rep2(i,a,b) for(ll i=a;i<=b;++i)
#define rep(i,n) for(int i=0;i<n;i++)
#define rep3(i,a,b) for(int i=a;i>=b;i--)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define tii tuple<int,int,int>
#define pq priority_queue<int>
#define pqg priority_queue<int,vector<int>,greater<int>>
#define pb push_back
#define edge(v,a,b) v[a].pb(b);v[b].pb(a);
#define MAX_V 400010
#define vec vector<int>
#define vecll vector<ll>
#define vecpii vector<pii>
#define endl "\n"
#define ALL(c) (c).begin(),(c).end()
using namespace std;
int in() {int x;scanf("%d",&x);return x;}
ll lin() {ll x;scanf("%lld",&x);return x;}
template<typename A, size_t NNN, typename T>
void Fill(A (&array)[NNN], const T &val){
    fill( (T*)array, (T*)(array+NNN), val );
}
#define INF 1e9+7
#define LLINF 1e18+7
ll MOD=1e9+7;
#define N 610000
ll n,m,k;
ll mem[N];
int a[N];
int main(){
    n=in();
    k=in();
    rep(i,n){
        a[i]=in();
    }
    fill(mem,mem+n,INF);
    mem[0]=0;
    rep(i,n){
        rep2(j,1,k){
            mem[i+j]=min(mem[i+j],mem[i]+abs(a[i+j]-a[i]));
        }
    }
    cout<<mem[n-1];
    return 0;
}

Measured memory_bytes: 2688
#include <bits/stdc++.h>
using namespace std;
int main(void){
    string S;cin>>S;
    vector<int> cnt(2, 0);
    for (int i=0;i<S.size();i++){
        cnt[S[i] - '0']++;
    }
    int ans = min(cnt[0], cnt[1]) * 2;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 512
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<stdint.h>
#include<tgmath.h>
#include<stdbool.h>
#include<sys/queue.h>
#include<time.h>
#define ll long long
#define min(a, b) ((a) > (b) ? (b) : (a))
#define max(a, b) ((a) > (b) ? (a) : (b))

const ll mod = 1000000007;
ll modpow(ll x, ll y, ll m){
    if(y == 0ll)return 1ll;
    ll res = 1ll, tmp = x;
    while(y){
        if(y&1) res = res * tmp % m;
        tmp = tmp * tmp % m;
        y >>= 1;
    }
    return res;
}
ll pom(ll x, ll y){
    return modpow(x, y, mod);
}

ll n, a, b[99] = {}, ans = 0;

main(){
	scanf("%lld", &n);
	for(int i=0; i<n; i++){
		scanf("%lld", &a);
		for(int j=0; j<=60; j++){
			b[j] += (a>>j) & 1;
		}
	}
	for(int i=0; i<60; i++){
		ans += pom(2, i) * b[i] % mod * (n - b[i]) % mod;
		ans %= mod;
	}
	printf("%lld\n", ans);
	return 0;
}

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

int main(){
   int A,B,C,D;
   cin>>A>>B>>C>>D;
   if(abs(C-A)<=D)cout <<"Yes";
   else if(abs(B-A)<=D&&abs(C-B)<=D) cout <<"Yes";
   else cout <<"No";
 }



Measured memory_bytes: 256
#include<bits/stdc++.h>
#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define ull unsigned long long
#define vi vector<ll>
#define vvi vector<vi>
#define DBG_N(hoge) cerr<<" "<<(hoge)<<endl;
#define DBG cerr<<"!"<<endl;
#define BITLE(n) (1LL<<((ll)n))
#define BITCNT(n) (__builtin_popcountll(n))
#define SUBS(s,f,t) ((s).substr((f)-1,(t)-(f)+1))
#define ALL(a) (a).begin(),(a).end()
using namespace std;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n;cin>>n;
  string s;cin>>s;
  ll q;cin>>q;
  ll d = 0,m = 0,dm = 0;
  while(q--){
    ll k;cin>>k;
    ll ans = 0;
    d = 0;m = 0;dm = 0;
    for(int i=0;i<n;i++){
      if(i >= k-1){
	if(s[i] == 'D'){
	  d++;
	}else if(s[i] == 'M'){
	  dm += d;
	  m++;
	}else if(s[i] == 'C'){
	  ans += dm; 
	}

	if(s[i-k+1] == 'D'){
	  d--;
	  dm -= m;
	}else if(s[i-k+1] == 'M'){
	  m--;
	}

      }else{
	if(s[i] == 'D'){
	  d++;
	}else if(s[i] == 'M'){
	  dm += d;
	  m++;
	}else if(s[i] == 'C'){
	  ans += dm; 
	}
      }
    }
    cout<<ans<<endl;
  }
  return 0;
}


Measured memory_bytes: 1948
//#include <bits/stdc++.h>
#include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
#include <climits>
#include <iomanip>
#include <stack>
#include <bitset>

#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, j, k) for(int i = (int)(j); i < (int)(k); ++i)
#define ROF(i, j, k) for(int i = (int)(j); i >= (int)(k); --i)
#define FORLL(i, n, m) for(long long i = n; i < (long long)(m); i++)
#define SORT(v, n) sort(v, v+n)
#define REVERSE(v) reverse((v).begin(), (v).end())

using namespace std;
using ll = long long;
const ll MOD=1000000007LL;
typedef pair<int, int> P;

ll ADD(ll x, ll y) { return (x+y) % MOD; }
ll SUB(ll x, ll y) { return (x-y+MOD) % MOD; }
ll MUL(ll x, ll y) { return x*y % MOD; }
ll POW(ll x, ll e) { ll v=1; for(; e; x=MUL(x,x), e>>=1) if (e&1) v = MUL(v,x); return v; }
ll DIV(ll x, ll y) { /*assert(y%MOD!=0);*/ return MUL(x, POW(y, MOD-2)); }

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

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

  int n, k;
  cin >> n >> k;
  int nC2 = (n-1)*(n-2)/2;
  //作れない
  if(nC2<k){
    cout << -1 << endl;
    return 0;
  }
  // 1 -> N-1 + i -> j (i, j >= 2)
  cout << (n-1)+nC2-k << endl;
  // 1 -> N-1
  FOR(i, 2, n+1) {
    cout << 1 << " " << i <<endl;
  }
  int cnt = 0;
  // i -> j (i, j >= 2)
  FOR(i, 2, n+1) {
    FOR(j, i+1, n+1) {
      if(cnt == nC2-k) break;
      cout << i << " " << j << endl;
      cnt++; 
    }
    if(cnt == nC2-k) break;
  }
  return 0;
}


Measured memory_bytes: 256