akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <cassert>
#include <algorithm>
using namespace std;
typedef long long ll;



int dig(long long b, long long n){
	int ans = 0;
	while(n){
		n /= b;
		ans++;
	}
	return ans;
}
long long f(long long b, long long n){
	long long ans = 0;
	while( n ){
		ans += n % b;
		n /= b;
	}
	return ans;
}

int main(){
	long long n, s;
	cin >> n >> s;
	
	for(int i = 2 ; i <= 1000000 ; i++){
		if( f(i, n) == s ){
			cout << i << endl;
			return 0;
		}
	}
	
	
	long long ans = 1e18;

	vector<long long> itms;
	for(int i = 1 ; i <= 1000000 ; i++){
		if( n / i != n / (i+1) ){
			itms.push_back(n / i);
		}
	}	
	while(itms.back() != 0 ) itms.push_back(itms.back()-1);
	for(int i = 0 ; i + 1 < itms.size() ; i++){
	
		long long b_lb = itms[i];
		long long b_ub = itms[i+1];
		long long l = n / b_lb + 1, r = b_ub == 0 ? n : n / b_ub;
		
		if( dig(l, n) != 2 )
			continue;
		long long k = (n/l);
		
		long long solD = (s - n % r - k);		
		if(   (n % l - s + k) % k != 0 ) continue;

		long long sol = (n % l - s + k) / k + l;
		if( sol >= l && sol <= r && f(sol, n) == s ) {
			ans = min(ans, sol);			
		}
	
	}
	
	if( ans != 1e18 ){
		cout << ans << endl;
		return 0;
	}
	
	if( n == s ){
		cout << n + 1 << endl;
		return 0;
	}
	cout << -1 << endl;
	
}


Measured memory_bytes: 10348
# -*- coding: utf-8 -*-
from bisect import bisect_left

n = int(input())
l = sorted(list(map(int, input().split(' '))))

ans = 0
for i in range(n-1):
    for j in range(i+1, n):
        t = l[i]+l[j]
        idx = bisect_left(l, t)
        ans += max(0, idx-j-1)

print(ans)

Measured memory_bytes: 3188
#!/usr/bin/env python3
from itertools import accumulate
L, N = map(int, input().split())
X = [int(input()) for _ in range(N)]
Y = [L - x for x in X][::-1]

sx = [0] + list(accumulate(X))
sy = [0] + list(accumulate(Y))

ans = 0
for i in range(N):
    j = N - i - 1
    mn = min(i, j)

    now = X[i]
    now += 2 * (sx[i] - sx[i - mn]) + 2 * (sy[j] - sy[j - mn - (i < j)])
    ans = max(ans, now)

    now = Y[j]
    now += 2 * (sx[i] - sx[i - mn - (i > j)]) + 2 * (sy[j] - sy[j - mn])
    ans = max(ans, now)

print(ans)


Measured memory_bytes: 39396
n=int(input())
s=list(input())
fa=[n+1]*10
la=[-1]*10
for i in range(n):
    s[i]=int(s[i])
    if fa[s[i]]>n:
        fa[s[i]]=i
    la[s[i]]=i
ans=0
for i in range(10):
    for j in range(10):
        if fa[i]<la[j]:
            num=[0]*10
            for k in range(fa[i]+1,la[j]):
                num[s[k]]=1
            ans+=num.count(1)
print(ans)


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

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n, m; cin >> n >> m;
    vector<int> a(n); int all = 0;
    for (int i = 0; i < n; i++) {
        cin >> a[i]; all += a[i];
    }
    int cnt = 0;
    for (int i = 0; i < n; i++) {
        if (all <= 4 * m * a[i]) cnt++;
    }
    if (cnt >= m) cout << "Yes\n";
    else cout << "No\n";
    return 0;
}

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

int main(){
	int x=0;
	
	int n,max=0;
	cin>>n;
	int arr[n];
	
 string s;
 
 cin>>s;
 for(int i=0;i<n;i++){
 	if(s[i]=='I'){
 		x+=1;
	 }
	 if(s[i]=='D'){
	 	x-=1;
	 }
	 arr[i]=x;
 }
 	for(int i=0;i<n;i++){
 		if(max<arr[i]){
 			max=arr[i];
		 }
	 }
	 cout<<max;
 }


Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<iostream>
using namespace std;
inline int read(){
	int x;
	scanf("%d",&x);
	return x;
}

const int N=2e5+5;
const int M=2e5+5;

struct Edge{
	int v,nxt;
}e[M];
int first[N],Ecnt=0;
#define go(u) for(register int i=first[u],v=e[i].v;i;v=e[i=e[i].nxt].v)
inline void Add_edge(int u,int v){
	e[++Ecnt]=(Edge){v,first[u]};
	first[u]=Ecnt;
}

int fa[N];
int n,K,ans;

inline int dfs(int u,int dep){
	int maxdep=dep;
	go(u) maxdep=max(maxdep,dfs(v,dep+1));
	if(fa[u]!=1&&maxdep-dep==K-1) ans++,maxdep=dep-1;
	return maxdep;
}

inline void solve1(){
	for(int i=1;i<=n;i++) ans+=(read()!=1);
	printf("%d",ans);
	exit(0);
}

int main(){
	n=read(),K=read();
	if(K==1) solve1();
	fa[1]=read();
	ans+=(fa[1]!=1);
	fa[1]=1;
	for(int i=2;i<=n;i++){
		fa[i]=read();
		Add_edge(fa[i],i);
	}
	dfs(1,0);
	printf("%d",ans);
}

Measured memory_bytes: 4608
#include <algorithm>
#include <iostream>
#include <map>
#include <vector>

using namespace std;

const int M = 1e9+7;

int mpow(long long a, int n)
{
  if (n % 2) return mpow(a, n-1) * a % M;
  if (n == 0) return 1;
  return mpow(a * a % M, n / 2);
}

int main()
{
  int n; cin >> n;
  int a[10000]; for (int i = 0; i < n; ++i) cin >> a[i];
  
  vector<map<int, int> > primes(n);
  for (int i = 0; i < n; ++i) {
    int t = a[i];
    for (int j = 2; j*j <= t; ++j)
      while (t % j == 0) {++primes[i][j]; t /= j;}
    if (t != 1) ++primes[i][t];
  }
  
  map<int, int> mp;
  for (int i = 0; i < n; ++i) for (auto x: primes[i])
      mp[x.first] = max(mp[x.first], x.second);
  
  long long lcm = 1;
  for (auto x: mp) lcm = lcm * mpow(x.first, x.second) % M;
  
  int sum = 0;
  for (int i = 0; i < n; ++i) sum = (sum + lcm * mpow(a[i], M-2)) % M;
  
  cout << sum << endl;  
  return 0;
}

Measured memory_bytes: 3072
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(void)
{
  int r,d,x;
  cin >> r >> d >> x;
  for(int i = 1;i<=10;i++)
  {
      x = r * x - d;
      cout << x << endl;
  }
  return 0;
}



Measured memory_bytes: 256
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(100000)
a_max = 0
class Node:
    def __init__(self):
        self.edge = []
        self.color = {}
    
    def ap_edge(self,e):
        self.edge.append(e)

    def rm_edge(self,e):
        self.edge.remove(e)
    
    def co_edge(self,n, c):
        self.color[n] = c


def solve(N: int, a: "List[int]", b: "List[int]"):
    nodes = [Node() for _ in range(N)]

    for ai, bi in zip(a,b):
        nodes[ai-1].ap_edge(bi)
        nodes[bi-1].ap_edge(ai)

    # a_max = 0

    def s_node(node_num, prev_c):
        global a_max
        el = nodes[node_num-1].edge

        # print("node_num:{} el:{}".format(node_num, el))
        if len(el)>0:
            if prev_c not in range(1,len(el)+1):
                c_list = range(1,len(el)+1)
                a_max = max(a_max, len(el))
            else:
                c_list = list(range(1,len(el)+2))
                c_list.pop(prev_c-1)
                a_max = max(a_max, len(el)+1)
            
            # print("c_list:{} prev_c:{}".format(c_list, prev_c))

            for node_n, c_ in zip(el, c_list):
                # 親の頂点に対する処理
                nodes[node_num-1].co_edge(node_n, c_) # 子のエッジの色を持つ
                # 子の頂点に対する処理
                nodes[node_n-1].rm_edge(node_num) # 親のエッジを削除
                s_node(node_n, c_)

    s_node(1,0)

    print(a_max)
    # ans = []
    for ai, bi in zip(a,b):
        if bi in nodes[ai-1].edge:
            ans = (nodes[ai-1].color[bi])
        else:
            ans = (nodes[bi-1].color[ai])
        print(ans)
    # print(max(ans))
    # [print(c_) for c_ in ans]


    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    a = [int()] * (N - 1)  # type: "List[int]"
    b = [int()] * (N - 1)  # type: "List[int]"
    for i in range(N - 1):
        a[i] = int(next(tokens))
        b[i] = int(next(tokens))
    solve(N, a, b)

if __name__ == '__main__':
    main()


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


int main()
{
	int judge = 0;
	string s;
	char c = '\0';
	int cnt = 0;

	for (int i = 0; i < 3; i++) {
		cin >> s;
		if (s[0] == c) judge++;
		while (s[cnt]) {
			cnt++;
		}
		c = s[cnt-1];
		cnt = 0;
	}
	if (judge == 2) cout << "YES" << endl;
	else cout << "NO" << endl;

    return 0;
}



Measured memory_bytes: 256
N, T = map( int, input().split())
S = list( map( int, input().split()))
S.append(10**10)
ans = 0
now = 0
for i in range(1,N+1):
    if S[i] - now >= T:
        ans += T
    else:
        ans += S[i] - now
    now = S[i]
print(ans)

Measured memory_bytes: 25196
/*
  AOJ 1100
  Title:
  @kankichi573
*/
#include <stdio.h>
int n,xx0,yy0,xx1,yy1,xx00,yy00;
main()
{
  double s;
  int i,cnt=0;
    
  while(scanf("%d",&n) && n)
    {
      cnt++;
      s=0.0;
      scanf("%d %d",&xx0,&yy0);
      xx00=xx0;yy00=yy0;
      for(i=1;i<n;i++)
	{
	  scanf("%d %d",&xx1,&yy1);
	  s+=(xx0-xx1)*(yy0+yy1)/2.0;
	  xx0=xx1;yy0=yy1;
	}
      s+=(xx0-xx00)*(yy0+yy00)/2.0;
      printf("%d %.1lf\n",cnt,-s);
    }
  return(0);
}

Measured memory_bytes: 636
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdio>
#include <bits/stdc++.h>
#include <unordered_map>
#include <unordered_set>
#include <queue>

#define pb push_back
     
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;
     
bool debug = false;
     

struct state
{
    ll a,b,c;

    state(ll a, ll b, ll c) : a(a), b(b), c(c)
    {

    }

  bool operator==(const state &other) const
  { return (a == other.a
            && b == other.b
            && c == other.c);
  }
};


struct KeyHasher
{
    size_t operator()(const state& k) const
  {
    //using std::size_t;
    //using std::hash;
    //using std::string;

    return ((hash<ll>()(k.a)
               ^ (hash<ll>()(k.b) << 1)) >> 1)
               ^ (hash<ll>()(k.c) << 1);
  }
};  


void solve(ll casen)
{
    ll res = 0;
    
    cout << "Case #" << casen << ": " << res << endl;
}

int main()
{
    // $ g++ -std=c++14 -Wshadow -Wall -o c C.cpp

    // !!! Here, unordered map was too slow!!!
    std::ios::sync_with_stdio(false);
    cin.tie(NULL);
    
    /*
    ll t;
    cin >> t;

    for (int i = 0; i < t; i++)
    {
        solve(i+1);
    }
    */

    ll n;
    cin >> n;

    ll d = n%10;

    if (d == 3)
        cout << "bon" << endl;
    else if (d == 0 || d== 1 || d == 6 || d == 8)
        cout << "pon" << endl;
    else
        cout << "hon" << endl;

    return 0;
}

Measured memory_bytes: 3632
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<cmath>
using namespace std;
void File(){
	freopen("A.in","r",stdin);
	freopen("A.out","w",stdout);
}
#define REP(i,a,b) for(register int i=a;i<=b;++i)
#define DREP(i,a,b) for(register int i=a;i>=b;--i)
#define MREP(i,x) for(register int beg[x];i;i=E[i].last)
#define ll long long
#define inf (0x3f3f3f3f)
int a,b,c,ans,cnt;
int main(){
	//File();
	scanf("%d%d%d",&a,&b,&c);
	int Max=max(a,max(b,c));
	ans+=(Max-a)/2;
	ans+=(Max-b)/2;
	ans+=(Max-c)/2;
	a=Max-(a+(Max-a)/2*2);
	b=Max-(b+(Max-b)/2*2);
	c=Max-(c+(Max-c)/2*2);
	if(a+b+c==1)cout<<ans+2<<endl;
	else if(a+b+c==2)cout<<ans+1<<endl;
	else if(a+b+c==3)cout<<ans+3<<endl;
	else cout<<ans<<endl;
	return 0;
}


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

persons = []
checks = []
for _ in range(N):
    persons.append(list(map(int, input().split())))
for _ in range(M):
    checks.append(list(map(int, input().split())))

for px, py in persons:
    i = 0
    min_dist = -1
    for k, (cx, cy) in enumerate(checks):
        m = abs(px-cx) + abs(py-cy)
        if k==0 or (k>0 and m < min_dist):
            i = k
            min_dist = m
    print(i+1)



Measured memory_bytes: 9108
package main

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

type restaurant struct {
	name  string
	point int

	index int
}

type restaurants []restaurant

func (r restaurants) Len() int {
	return len(r)
}

func (r restaurants) Less(i, j int) bool {
	if r[i].name == r[j].name {
		return r[i].point > r[j].point
	}

	return r[i].name < r[j].name
}

func (r restaurants) Swap(i, j int) {
	r[i], r[j] = r[j], r[i]
}

func main() {
	N := nextInt()
	rs := make([]restaurant, N)
	for i := 0; i < N; i++ {
		rs[i] = restaurant{name: nextString(), point: nextInt(), index: i + 1}
	}

	sort.Sort(restaurants(rs))

	for _, r := range rs {
		fmt.Println(r.index)
	}
}

// Input. ----------

var sc = bufio.NewScanner(os.Stdin)

func init() {
	sc.Buffer([]byte{}, math.MaxInt64)
	sc.Split(bufio.ScanWords)
}

func nextInt() int {
	sc.Scan()
	i, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}

	return i
}

func nextFloat() float64 {
	sc.Scan()
	f64, err := strconv.ParseFloat(sc.Text(), 64)
	if err != nil {
		panic(err)
	}

	return f64
}

func nextString() string {
	sc.Scan()
	if err := sc.Err(); err != nil {
		panic(err)
	}

	return sc.Text()
}

// ---------- Input.

// Util. ----------

func abs(x int) int {
	return int(math.Abs(float64(x)))
}

func min(x, y int) int {
	return int(math.Min(float64(x), float64(y)))
}

func max(x, y int) int {
	return int(math.Max(float64(x), float64(y)))
}

// ---------- Util.


Measured memory_bytes: 640
A = list(map(int, input().split()))
votes = list(map(int, input().split()))
check = []
total = 0
for i in votes:
    total +=i
for i in votes:
  if i >= ((1/4)/A[1])*total:
    check.append(i)
if len(check) >= A[1]:
  print ("Yes")
else:
  print ("No")

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#define rep(i, n)   for(int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;

int main(){
    ll n ,k;    cin >> n >> k;
    if(n >= k)  n = n%k;
    cout << min(n, abs(n-k)) << endl;
}


Measured memory_bytes: 256
from collections import deque
def bfs():
    #sからそのマスまでの最短距離を保存する配列
    d = [[float("inf")]*m for _ in range(n)]
    dx = [1,0,-1,0]
    dy = [0,1,0,-1]
    #s,gの座標を得る
    sx,sy = 0,0
    gx,gy = n-1,m-1
    #キューにs座標をセットしてsのマスを0にする
    q = deque([])
    q.append((sx,sy))
    d[sx][sy] = 0
    
    #全部の行けるところをqueに入れてsからの距離を＋1ずつしていく
    while q:
        p = q.popleft()
        #gでbreakしなければ行ける全てのマスまでの最短距離を求める事になる
        if p[0] == gx and p[1] == gy:
            break
        #上下左右のマスを調べる
        for k in range(4):
            xi,yi = p[0]+dx[k],p[1]+dy[k]
            #そのマスにいけて行ったことないなら、そこを起点に再起＋そこまでの距離を求める
            if 0 <= xi < n and 0 <= yi < m and maze[xi][yi] != "#" and d[xi][yi] == float("inf"):
                q.append((xi,yi))
                d[xi][yi] = d[p[0]][p[1]] + 1

    #gまでの最短距離を返す
    return d[gx][gy]

n,m = map(int, input().split())
maze = [list(input()) for _ in range(n)]
c = 0
for i in range(n):
    for j in range(m):
        if maze[i][j] == ".":
            c += 1
res = bfs()
#到達できるなら
if 0 < res < float("inf"):
    print(c - res -1)
else:
    print(-1)

Measured memory_bytes: 3316
#include <iostream>
using namespace std;
int main(void)
{
    bool ok = 1;
    string s,t;
    cin >> s >> t;
    if(t.length() == s.length() + 1)
    {
        for (int i = 0; i < s.length() ; i ++ )
        {
            if (s[i] != t[i])
            {
                ok = 0;
                break;
            }
        }
        if (ok) cout << "Yes" << endl;
        else cout<< " No" << endl;
    }
    else cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 3040
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,o,n) for(long long i = o;i<n;i++)
#define oneforall ios::sync_with_stdio(false);cin.tie(0);
#define all(v) (v).begin(),(v).end()
#define ini(...) int __VA_ARGS__; in(__VA_ARGS__)
#define inl(...) long long __VA_ARGS__; in(__VA_ARGS__)
#define ins(...) string __VA_ARGS__; in(__VA_ARGS__)
#define int long long 
const long long INF=1e18;
void in(){} template <typename T,class... U> void in(T &t,U &...u){ cin >> t; in(u...);}
void out(){cout << "\n";} template <typename T,class... U> void out(const T &t,const U &...u){ cout << t; if(sizeof...(u)) cout << " "; out(u...);}
typedef vector<int> vi;
typedef vector<long long> vl;
typedef long long ll;
typedef vector<pair<long, long > > vpll;
typedef vector<pair<int, int > > vpii;
#define FORR(x,arr) for(auto& x:arr)

/*
bool isprime(int x){
	for(int i = 2;i*i<=x;i++){
		if(x%i == 0)return false;
	}
	return x!=1;
}
int gcd(int a, int b) 
{ 
    if (a == 0) 
       return b; 
    if (b == 0) 
       return a; 
   
    if (a == b) 
        return a; 
   
    if (a > b) 
        return gcd(a-b, b); 
    return gcd(a, b-a); 
} 
*/


//3111111111111111111111111111111






	void solve(){
		ini(n);
		ini(x1);
		ini(x);
		FOR(i,0,1000){
			if((n*i)>=x1 and (n*i)<=x){
				return out("OK");
			}
		}
		return out("NG");


	}









































int32_t main() {
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall 
	oneforall

	solve();
	


	return 0;
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define pii pair <ll,ll>
#define vl vector <ll>
#define vp vector <pair<ll,ll>>
//#define sort(x) sort(x.begin(), x.end())
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n,i,a = -1,b = -1,c = 1,j,k;
    cin>>n;
    ll p[n],q[n], x[n];
    for(i=0;i<n;i++)
        cin>>p[i];
    for(i=0;i<n;i++)
        cin>>q[i];
    for(i=0;i<n;i++)
        x[i] = i+1;
    while(a == -1 or b == -1)
    {
        // for(i=0;i<n;i++)
        //     cout<<x[i]<<" ";
        // cout<<endl;
        for(i=0;i<n;i++)
            if(x[i] != p[i])
                break;
        if(i == n)
            a = c;
        for(i=0;i<n;i++)
            if(x[i] != q[i])
                break;
        if(i == n)
            b = c;
        c++;
        for(i=n-2;i>=0;i--)
            if(x[i] < x[i+1])
            {
                k = i+1;
                for(j=i+2;j<n;j++)
                    if(x[j] > x[i] and x[k] > x[j])
                        k = j;
                swap(x[i],x[k]);
                sort(x+i+1,x+n);
                break;
            }
    }
    cout<<abs(a-b);
    return 0;
}


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

num_negative = len(list(filter(lambda e: e < 0, a)))

a2 = [abs(e) for e in a]
if num_negative % 2 == 0:
    print(sum(a2))
else:
    print(sum(a2) - 2 * min(a2))


Measured memory_bytes: 14224
#include<bits/stdc++.h>
#define ull unsigned long long
using namespace std;
const int N=3e5+5;
char s[N];
ull base=233,inv=7204522363551799129,f[N],X=1,Y,ans=0;
int n;
map<ull,int> mp;
int main()
{
	scanf("%d",&n);getchar();
	scanf("%s",s+1);
	for(int i=1;i<=n;i++)
	{
		f[i]=f[i-1];
		if(s[i]=='+') f[i]+=X;
		if(s[i]=='-') f[i]-=X;
		if(s[i]=='<') X*=base;
		if(s[i]=='>') X*=inv;
		mp[f[i]]++;
	}
	X=1;
	for(int i=1;i<=n;i++)
	{
		ans+=mp[f[n]*X+Y];
		if(s[i]=='+') Y+=X;
		if(s[i]=='-') Y-=X;
		if(s[i]=='<') X*=base;
		if(s[i]=='>') X*=inv;
		mp[f[i]]--;
	}
	printf("%llu",ans);
}


Measured memory_bytes: 33664
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <queue>
#include <algorithm>
using namespace std;
typedef unsigned int uint;
typedef long long ll;
typedef pair<int, int> P;
const int c_INF = 111111111;
const int c_mINF = -111111111;
const int c_YET = -1;
const int c_Dx[4] = { 0,0,1,-1 };
const int c_Dy[4] = { 1,-1,0,0 };



int main() {
	int N;
	char S[200005];

	scanf("%d", &N);
	scanf("%s", S);

	int ans = 1;

	for (int i = 0; i < N-1; i++) {
		if (S[i] != S[i + 1]) {
			ans++;
		}
	}

	printf("%d", ans);

}



/*         提出前の確認事項

・デバッグ用の関数は＜＜コメント化＞＞しているか？
・すべての＜＜入力例＞＞は試したか？
・＜＜限界値分析＞＞はしたか？
・＜＜出力の改行＞＞の有無は確認したか？
・文字列の＜＜スペル＞＞は確認したか？
　　　　　　　　↓
	 ＜＜提出先＞＞に注意して提出！！
*/

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

sushi = [list(map(int, input().split())) for _ in range(n)]

# 左のある箇所まで行ってから、右のある箇所まで行って終了
# 右のある箇所まで行ってから、左のある箇所まで行って終了
# のどっちか。「最初から右／左の一方向だけ行って終了」もあるが、上記2つの特殊パターンとして扱えることに解説を読んで気づいた。
value_sum = [0] * (n+1)
for i in range(n):
	value_sum[i+1] = value_sum[i] + sushi[i][1]
value_sum_inv = [0] * (n+1)
for i in range(n):
	value_sum_inv[i+1] = value_sum_inv[i] + sushi[n-1 - i][1]

max_arr = [0] * (n+1)
# max_arr = 始点からsushi[n]まで時計回りに進んでよい（その前に止まっても良い）ときの最適スコア
# [0, s[0]まで、s[1]まで、……]
for i in range(n):
	max_arr[i+1] = max(max_arr[i], value_sum[i+1] - sushi[i][0])

max_arr_inv = [0] * (n+1)
# max_arr_inv = 始点からsushi[n-1 - i]まで反時計回りに進んでよい（その前に止まっても良い）ときの最適スコア
# [0, s[n-1]まで、s[n-2]まで、……]
for i in range(n):
	max_arr_inv[i+1] = max(max_arr_inv[i], value_sum_inv[i+1] - (c - sushi[n-1 - i][0]) )

"""print(max_arr)
print(max_arr_inv)
"""
ans = 0 #移動なし

now = max_arr[n]
ans = max(ans, now)

for i in range(n-1, -1, -1): #最初に左に行くときの到達点
	now = value_sum_inv[n - i] - 2 * (c - sushi[i][0]) + max_arr[i]
	ans = max(ans, now)

now = max_arr_inv[n]
ans = max(ans, now)

for i in range(n): #最初に右に行くときの到達点
	now = value_sum[i+1] - 2 * (sushi[i][0]) + max_arr_inv[n-1 - i]
	ans = max(ans, now)
"""	print(now)
	print( value_sum[i+1] , (sushi[i][0]) , max_arr_inv[n-1 - i])
"""
print(ans)


Measured memory_bytes: 44816
import java.util.*;

public class Main {
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] timeArray = new int[n];
        int sum = 0;
        for (int i=0;i<n;i++){
            timeArray[i] = sc.nextInt();
            sum += timeArray[i];
        }
        int m = sc.nextInt();
        for (int j=0;j<m;j++){
            int index = sc.nextInt()-1;
            int x = sc.nextInt();
            System.out.println(sum-(timeArray[index]-x));
        }
    }
}

Measured memory_bytes: 23764
import java.util.*;

/**
 * B Main
 *
 * @date 2020.09.19
 * @author 焼き鮭 <yaki-shake@up-tri.me>
 */

public class Main {
  Scanner sc;

  public static void main(String[] args) {
    new Main().execute();
  }

  public void execute() {
    this.sc = new Scanner(System.in);
    String[] s = sc.next().split("");
    String[] t = sc.next().split("");

    int min = t.length;
    for (int i = 0; i < s.length; i++) {
      int cnt = 0;
      if (s.length - i >= t.length) {
        for (int j = 0; j < t.length; j++) {
          if (!s[i + j].equals(t[j])) {
            cnt++;
          }
        }
        if (min > cnt) {
          min = cnt;
        }
      }
    }

    System.out.println(min);
  }
}


Measured memory_bytes: 28592
using System;

public class hello
{
    public static void Main()
    {
        var n = int.Parse(Console.ReadLine().Trim());
        for (int i = 0; i < n; i++)
        {
            string[] line = Console.ReadLine().Trim().Split(' ');
            var s = int.Parse(line[0]);
            var d = int.Parse(line[1]);
            Console.WriteLine(Rec(s, d));
        }
    }
    static int Rec(int s, int d)
    {
        var ans = 0;
        if (s == d) return 0;
        if (s % 2 != 0) { ans++; s++; }
        if (d % 2 != 0) { ans++; d--; }
        ans += Rec(s / 2, d / 2);
        return ans;
    }
}



Measured memory_bytes: 17952
import numpy as np

H, W, A, B = list(map(int, input().split()))

C = np.zeros([H, W])

C[0:H-B, 0:W-A] = 1
C[H-B:H, W-A:W] = 1

for i in range(H):
    d = ""
    for j in range(W):
        d += str(int(C[i, j]))

    print(d)

Measured memory_bytes: 22876
#include <stdio.h>
int main(void){
    int n,k,q;
    scanf("%d%d%d",&n,&k,&q);
    int a[n],i,t=q-k+1;
    for(i=0;i<n;i++) a[i]=0;
    int x;
    for(i=0;i<q;i++){
        scanf("%d",&x);
        a[x-1]+=1;
    }
    for(i=0;i<n;i++){
        if(a[i]>=t) printf("Yes\n");
        else printf("No\n");
    }
    return 0;
}


Measured memory_bytes: 896
N, A, B = gets.split.map(&:to_i)

if N == 1
    if A == 1 && B == 1
        print 1
    else
        print -1
    end

elsif N == 2
    if A == 2 && B == 1
        print '1 2'
    elsif A == 1 && B == 2
        print '2 1'
    else
        print -1
    end

# 1 2 3 4 5 ...
elsif B == 1
    if A == N
        print (1..N).to_a.join(' ')
    else
        print -1
    end

#####   middle = 3, wide = 13
#####
###
#
#
elsif A + B - 1 <= N && N <= A * B 
    stairs = Array.new(B){Array.new()}
    middle = (N - A + B - 2) / (B - 1)
    wide = N - A + middle
    wide.times do |i|
        stairs[i % B].unshift(N - i)
    end
    stairs[0] = (1..(N - wide)).to_a + stairs[0]
    result = []

    str = ''
    stairs.each_with_index do |stair, i|
        str << ' ' if i > 0
        str << stair.join(' ')
    end
    print str

else
    print -1 
end


Measured memory_bytes: 26396
// #include<bits/stdc++.h>
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <limits.h>
#include <time.h>
#include <map>
#include <set>
#include <vector>
#include <functional>
#include <algorithm>
#include <stack>
#include <list>
#include <queue>
#include <bitset>
// #include <iostream>
// #include <iomanip>
// #include <sstream>
using namespace std;
#define all(cont) cont.begin(), cont.end()
#define rall(cont) cont.end(), cont.begin()
#define pb push_back
#define mp make_pair
#define fs first
#define sc second
#define pf printf
#define sf scanf
#define test_ fr(_iii_, 0, 66)cerr<<'>';cerr<<" in\n"
#define deb(x) fr(_iii_, 0, 66)cerr<<'>';cerr<<#x"="<<x<<"\n"
#define deb_array(a, _iiii_, n) fr(_iii_, _iiii_, 66)cerr<<'>'; cerr<<'\n';fr(_iii_,_iiii_,n)cerr<<a[_iii_]<<(_iii_==n-1?"\n":" ");fr(_iii_, _iiii_, 66)cerr<<'>'; cerr<<"\n"
#define deb_matrix(a, h, w) fr(_iii_, 0, 66)cerr<<'>'; cerr<<'\n';fr(_iii_, 0, h){fr(j, 0, w) {cerr << a[_iii_][j] << ' ';}cerr << '\n';}fr(_iii_, 0, 66)cerr<<'>'; cerr<<"\n"
#define fr(i, a, b) for(int i = a ; i < (int)b ; i++)
#define frr(i, a, b) for(int i = a ; i >= (int)b ; i--)
#define tr(it, var) for(__typeof(var.begin()) it = var.begin(); it != var.end(); it++)
#define trr(rit, var) for(__typeof(var.rbegin()) rit = var.rbegin(); rit != var.rend(); rit++)
#define its(x) static_cast< ostringstream & >( ( ostringstream() << dec << x ) ).str()
#define boost ios_base::sync_with_stdio(false); cin.tie(NULL)
#define ln puts("")
#define mems(a) memset(a, 0, sizeof(a))
#define has(cont, x) ((cont).find((x)) != (cont).end())
#define sz(x) ((int)(x).size())
//typedef
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<bool> vb;
typedef vector<ll> vll;
//bitmask
int on_bit(int x, int pos) {x |= (1 << pos); return x;}
int off_bit(int x, int pos) {x &= ~(1 << pos); return x;}
bool is_on_bit(int x, int pos) {return ((x & (1 << pos)) != 0);}
int flip_bit(int x, int pos) {x ^= (1 << pos); return x;}
int lsb(int x) {return x & (-x);}
int on_bit_all(int x, int pos) {x = (1 << pos)-1; return x;}
//constants
const double EPS = 1e-9;
const double PI = 2*acos(0.0);
const int INF = 0x3f3f3f3f;
const int MOD = 1e9+7;
//moves
const int dx1[] = {0, 1, 0, -1};
const int dy1[] = {1, 0, -1, 0};
const int dx2[] = {-1, -1, -1, 0, 0, 1, 1, 1};
const int dy2[] = {-1, 0, 1, -1, 1, -1, 0, 1};

ll gcd(ll a, ll b) {return b?gcd(b,a%b):a;}

char a[5];

int main() {
	sf("%s",a);
	fr(i,0,strlen(a)){
		pf("%c",(a[i]=='9'?'1':'9'));
	}
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int a[1 << 19];
int n;
typedef pair <int, int> pii;
pii dp[1 << 19];
const int inf = 1e9;

void update(pii &p, pii q) {
	if(a[p.first] <= a[q.first] && p.first != q.first) {
		p.second = p.first;
		p.first = q.first;
	}
	if(a[p.first] <= a[q.second] && p.first != q.second) {
		p.second = p.first;
		p.first = q.second;
	}
	if(a[p.second] <= a[q.first] && q.first != p.first) {
		p.second = q.first;
	}
	if(a[p.second] <= a[q.second] && q.second != p.first) {
		p.second = q.second;
	}
}

int main() {
	scanf("%d", &n);
	for(int i = 0; i < (1 << n); i++) {
		scanf("%d", &a[i]);
		dp[i] = pii(i, 1 << n); 
	}
	a[1 << n] = 0;
	for(int i = 0; i < (1 << n); i++) {
		for(int j = 0; j < n; j++) {
			if(((i >> j) & 1) == 0) {
				update(dp[i ^ (1 << j)], dp[i]);
			}
		}
	}
	for(int i = 1; i < (1 << n); i++) {
		int sum = 0;
		if(dp[i].first != dp[i].second) {
			sum = a[dp[i].first] + a[dp[i].second];
		}
		for(int j = 0; j < n; j++) {
			if(((i >> j) & 1) == 1) {
				int mask = i | ((1 << j) - 1);
				mask ^= 1 << j;
				if(dp[mask].first != dp[mask].second) {
					sum = max(sum, a[dp[mask].first] + a[dp[mask].second]);
				}
			}
		}
		printf("%d\n", sum);
	}
	return 0;
}

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

string IntToString(int number)
{
  stringstream ss;
  ss << number;
  return ss.str();
}

int main(){

	while(true){
		int mm[1001]={0};
		string s;
		int m,n;
		cin >> m >> n;
		int num = m;
		int index = 0;

		if(m==0&&n==0){
			break;
		}

		for(int i=1;i<=n;i++){
			cin >> s;
			if(num != 1){
				if(i%3==0 && i%5==0){
					if(s!="FizzBuzz"){
						mm[index] = 1;
						num--;
					}
				}else if(i%3==0){
					if(s!="Fizz"){
						mm[index] = 1;
						num--;
					}
				}else if(i%5==0){
					if(s!="Buzz"){
						mm[index] = 1;
						num--;
					}
				}else{
					if(s!=IntToString(i)){
						mm[index] = 1;
						num--;
					}
				}

				for(int j=index+1;true;j++){
					if(j==m){
						j=0;
					}
					if(mm[j] == 0){
						index = j;
						break;
					}
				}
				
			}
		}

		bool flag = false;
		for(int i=0;i<m;i++){
			if(mm[i]==0){
				if(flag){
					cout << " ";
				}
				cout << i+1;
				flag = true;
			}
		}
		cout << endl;
	}
}

Measured memory_bytes: 1236
// C.

#include <iostream>
#include <sstream>
#include <algorithm>
#include <vector>
#include <map>

using namespace std;

typedef long long LL;

int main(int argc, char* argv[]) {
	int n;
	cin >> n;
	map<string, LL> m;
	for (int i = 0; i < n; ++i) {
		string s;
		cin >> s;
		sort(s.begin(), s.end());
		m[s] += 1;
	}
	LL ans = 0;
	for (auto kv : m) {
		ans += ((kv.second - 1) * kv.second) / 2;
	}
	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 11136
#include <bits/stdc++.h>
using namespace std;
using ull = unsigned long long;
using i64 = int64_t;
using u64 = uint64_t;

#define CPP_STR(x) CPP_STR_I(x)
#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_STR_I(args...) #args
#define CPP_CAT_I(x,y) x ## y

constexpr int64_t MOD = 1'000'000'007LL;

#define INT(NAME) int NAME; cin>>NAME;
#define INT64(NAME) int64_t NAME; cin>>NAME;
#define VECTOR(NAME, TYPE, SIZE) std::vector<TYPE> NAME((SIZE));\
    for(int xxxx_i=0; xxxx_i<SIZE; xxxx_i++) cin>>NAME[xxxx_i];
#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)    

char getother(char a, char b) {
    char x = min(a, b);
    char y = max(a, b);
    assert(x != y);

    if (x=='G'&&y=='R') return 'B';
    if (x=='B'&&y=='G') return 'R';
    else return 'G';
}

void solve() {
    INT(N)
    string S;
    cin>>S;

    map<char, vector<int>> posmap;
    REP(i,N){
        posmap[S[i]].push_back(i);
    }
    ull ans = 0;
    REP(i, N-2) {
        FOR(j, i+1, N-1) {
            if (S[i]==S[j]) continue;

            char other = getother(S[i], S[j]);
            const auto& pos = posmap[other];

            // find k > j
            auto it = upper_bound(pos.begin(), pos.end(), j);
            ans += (pos.end() - it);

            // has k=2j-i?
            ans -= binary_search(pos.begin(), pos.end(), j+j-i);
        }
    }
    cout << ans << endl;
}

int main() {
    solve();

    return 0;
}

Measured memory_bytes: 3672
#include <iostream>
#include <vector>
#include <map>
#include <queue>

using namespace std;

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

    map<int, vector<int>> X;
    for(int i=0; i<N; i++){
        int A, B;
        cin >> A >> B;
        X[A].push_back(B);
    }

    long sum = 0;
    priority_queue<int> Q;
    for(int i=M; i>0; i--){
        for(auto it = X[M-i+1].begin(); it!=X[M-i+1].end(); it++){
            Q.push(*it);
        }

        if(!Q.empty()){
            sum += Q.top();
            Q.pop();
        }
    }

    cout << sum;

    return 0;
}

Measured memory_bytes: 10880
import java.io.*;
import java.math.*;
import java.util.*;
import java.util.stream.*;

class Main {
    static final BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    static final PrintWriter pw = new PrintWriter(System.out);
    public static void main(String[] args) throws IOException {
        String[] inputs = br.readLine().split(" ");
        type = Integer.parseInt(inputs[0]);
        int min = Integer.parseInt(inputs[1]);

        sum = new long[type+2];
        bottom = new long[type+2];
        top = new long[type+2];
        for(int i = 0; i <= type + 1; i++) {
            sum[i] = -1;
            bottom[i] = -1;
            top[i] = -1;
        }
        
        long ans = 0;
        bottom[min] = 0;
        for(int i = 0; i < min; i++) {
            bottom[min] += i;
        }
        top[min] = 0;
        for(int i = 0; i < min; i++) {
            top[min] += type - i;
        }

        for(int i = min; i <= type + 1; i++) {
            ans = modAdd(ans, sum(i));
        }

        pw.println(ans);
        pw.flush();
    }
    static long modAdd(long x, long y) {
        return (x + y) % 1000000007;
    }

    // num個選んだ時の合計の種類
    static long sum(int num) {
        if(num == 1) {
            sum[1] = type + 1;
            return sum[1];
        }
        if(sum[num] != -1) return sum[num];

        sum[num] = top(num) - bottom(num) + 1;
        return sum[num];
    }

    static long top(int num){
        if(num == 1) {
            top[1] = type;
            return top[1];
        }
        if(top[num] != -1) return top[num];
        top[num] = top(num-1) + type - num + 1;
        return top[num];
    }
    static long bottom(int num){
        if(num == 1) {
            bottom[1] = 0;
            return bottom[1];
        }
        if(bottom[num] != -1) return bottom[num];
        bottom[num] = bottom(num-1) + num - 1;
        return bottom[num];
    }

    static int type;
    static long sum[];
    static long bottom[];
    static long top[];
}

Measured memory_bytes: 38344
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		int ans0 = 0;
		int ans1 = 0;
		for (int i = 0; i < s.length(); i++) {
			int target = s.charAt(i)-'0';
			if (i % 2 == 0) {
				if (0 == target) {ans0++;}
				if (1 == target) {ans1++;}
			}else {
				if (0 ==  target) {ans1++;}
				if (1 ==  target) {ans0++;}
			}
		}
		System.out.println(Math.min(ans0, ans1));
	}

}




Measured memory_bytes: 39336
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int a,b,c;
    cin >> a >> b >> c;

    int sum = 0;

    for(int i = 0; i < b; i++){
        if(c % (i+1) == 0){
            sum++;
        }
    }

    for(int i = 0; i < a-1; i++){
        if(c % (i+1) == 0){
            sum--;
        }
    }

    cout << sum << endl;
} 


Measured memory_bytes: 3092
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <map>
#include <set>
#include <string>
#include <cstring>
#include <sstream>
#include <cmath>
#include <functional>
#include <fstream>
#include <cstdlib>
typedef long long ll;
const ll MOD = 1e9+7;


#define REP(i, N) for (int i = 0; i < (N); i++)
#define REPP(i, a, b) for (int i = (a); i < (b); i++)
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define VSORT(c) sort((c).begin(),(c).end())
#define SZ(x) ((int)(x).size())
//vvintを作る　マクロで　 #define vvint(N,M) vector<vector<int>>

using namespace std;

//繰り返し２乗法(a^nをO(log(n))で求める)
ll modpow(ll n, ll a){
    if(n == 1) return a;
    if(n%2 == 0){
        ll t = modpow(n/2,a)%MOD;
        return (t*t)%MOD;
    }else{
        return (a * modpow(n-1,a))%MOD;
    }
}

ll modcmb(ll a, ll b){
    ll X = 1,Y = 1;
    for(int i = 1; i < b+1;i++){
        X = (X*(a-i+1))%MOD;
        Y = (Y*i)%MOD;
    }
    Y = modpow(MOD-2,Y);

    return (X*Y)%MOD;
}

int main(){
    
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n,a,b;
    cin >> n >> a >> b;
    
    ll ans = 0;
    ans = ((modpow(n,2))-1)%MOD;
    ans = (ans - modcmb(n,a) > -1)? ans - modcmb(n,a):ans - modcmb(n,a)+MOD;
    ans = (ans - modcmb(n,b) > -1)? ans - modcmb(n,b):ans - modcmb(n,b)+MOD;

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

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

#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define sz(x) int(x.size())

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

const double PI=3.14159265358979323846;

int mod = 1e9+7;
const long long INF = 1LL<<60;

template<typename T>
struct BIT {
  int n;
  vector<T> d;
  BIT(int n=0):n(n),d(n+1) {}
  void add(int i, T x=1) {
    for (i++; i <= n; i += i&-i) {
      d[i] += x;
    }
  }
  T sum(int i) {
    T x = 0;
    for (i++; i; i -= i&-i) {
      x += d[i];
    }
    return x;
  }
};

int main(){
  int N, D, A;
  cin >> N >> D >> A;
  vector<P> p(N);
  rep(i, N) cin >> p[i].first >> p[i].second;
  sort(p.begin(), p.end());

  ll ans = 0;
  BIT<ll> bit(N+1);
  rep(i, N){
    ll x = p[i].first;
    ll h = p[i].second;
    h -= bit.sum(i);
    if(h<=0) continue;
    ll num = (h+A-1) / A;
    ans += num;
    ll damage = num * A;
    bit.add(i, damage);
    int rx = min(x+2*D, 1001001001ll);
    rx += 1; // 1-indexedに直す
    int j = upper_bound(p.begin(), p.end(), P(rx, -1)) - p.begin();
    bit.add(j, -damage);
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3328
// #define _GLIBCXX_DEBUG // for STL debug (optional)
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;
using ll = long long int;
using int64 = long long int;
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const int INF = 1LL << 29;
const ll LONGINF = 1LL << 60;
const ll MOD = 1000000007LL;
 
int main() {
    int N; cin >> N;
    vector<ll> A(N), C(N);
    for(int i=0; i<N; i++) scanf("%lld", &A[i]), A[i]--, C[ A[i] ]++;

    ll ans = 0;
    for(int i=0; i<N; i++) {
        ans += C[i] * (C[i] - 1) / 2;
    }
    
    for(int i=0; i<N; i++) {
        ll res = ans;
        res -= C[ A[i] ] * (C[ A[i] ] - 1) / 2;
        C[ A[i] ]--;
        res += C[ A[i] ] * (C[ A[i] ] - 1) / 2;
        C[ A[i] ]++;
        printf("%lld\n", res);
    }
    return 0;
}


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

int main(){
    ll N, K;
    cin >> N >> K;

    ll a = N/K;
    N = N - K*a;

    ll x = LLONG_MAX;
    for(;;){
        N = abs(N - K);
        if(N >= x)
            break;
        x = N;
    }

    cout << x << endl;

}

Measured memory_bytes: 256
#include <stdio.h>
int main (){
int a,b,c,d,e;
 scanf ("%d%d",&a,&b);
  c=a+b;
  d=a-b;
  e=a*b;
 if (c<d||c<e){
   if(d>e){
 printf ("%d",d);
   }
  else{
  printf ("%d",e);
  }
 }
  else{
  printf ("%d",c);
  }
return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long ll;
int N;
ll A[100010],B[100010];
int main()
{
  cin >> N;
  for(int i=0;i<=N;++i){
    cin >> A[i];
  }
  for(int i=0;i<N;++i){
    cin >> B[i];
  }
  ll res=0;
  for(int i=N-1;i>=0;--i){
    if(A[i+1]>=B[i]){
      res+=B[i];
      continue ;
    }
    else{
      res+=A[i+1];
      B[i]-=A[i+1];
      if(A[i]>=B[i]){
	res+=B[i];
	A[i]-=B[i];
	continue ;
      }
      else{
	res+=A[i];
	A[i]=0;
	continue ;
      }
    }
  }
  cout << res << "\n";
  
  return 0;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
#include<queue>
#include<deque>
#include<vector>
#include<string>
#include<algorithm>
#include<stack>
#include<set>
//#define ll long long
#define MOD 1000000007
#define INF 214748364
using namespace std;
int read()
{
	int kk(0);
	bool fh=true;
	char ch=getchar();
	while(ch<'0'||ch>'9')
	{
		if(ch=='-')fh=false;
		ch=getchar();
	}
	while(ch<='9'&&ch>='0')
	{
		kk=(kk<<3)+(kk<<1)+(ch^48);
		ch=getchar();
	}
	return fh?kk:-kk;
}
int n,t,a,h[1010];
long double temp[1010];
int main()
{
	n=read();
	long double minn=INF;
	int mini;
	t=read(),a=read();
	for(int i=1;i<=n;i++)
	{
		h[i]=read();
		temp[i]=abs(a-(t-h[i]*0.006));
//		if(temp[i]<0)temp[i]*=-1;
		if(temp[i]<minn)
		{
			minn=temp[i];
			mini=i;
		}
	}
	printf("%d",mini);
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <unordered_map>
#include <map>
#include <set>
#include <algorithm>
#include <vector>
 
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
 
using namespace std;
typedef unsigned long long ul;
typedef long long ll;
typedef pair<int, int> PAIR;
 
int main() {
	char o = 10;
	char n;
	REP(i, 4) {
		cin >> n;
		if (o == n) {
			cout << "Bad";
			return 0;
		} else {
			o = n;
		}
	}
	cout << "Good";

	return 0;
}

Measured memory_bytes: 256
using System;

class Program {
  static void Main() {
    var s = Console.ReadLine();
    int[] a = new int[26];
    foreach (var c in s) {
      a[c - 'a']++;
    }
    for (int i = 0; i < 26; i++) {
      if (a[i] == 0) {
        Console.WriteLine((char)(i + 'a'));
        return;
      }
    }
    Console.WriteLine("None");
  }
}

Measured memory_bytes: 13116
import qualified Data.Vector.Unboxed as U
import qualified Data.ByteString.Char8 as C
import Data.List

r :: Int -> IO (U.Vector Int)
r n = U.unfoldrN n (C.readInt . C.dropWhile (==' ')) <$> C.getLine

r' :: IO [Int]
r'  =   unfoldr    (C.readInt . C.dropWhile (==' ')) <$> C.getLine

main = do
    [n,k] <- r'
    h <- r n

    let dp = U.constructN n (\dp_ ->
            if U.null dp_ then 0
                else let i = U.length dp_
                         refh = U.slice (max 0 (i-k)) (min i k) h
                         refd = U.slice (max 0 (i-k)) (min i k) dp_
                    in U.minimum (
                        U.zipWith (\dc hc -> dc + abs(h U.! i - hc)) refd refh
                        )
            )

    print $ U.last dp



Measured memory_bytes: 3708
import math


n,a,b=map(int,input().split())
mod=10**9+7

c1=1
c2=1

for i in range(n-a+1,n+1):
    c1*=i
    c1%=mod
for j in range(1,a+1):
    c1*=pow(j,mod-2,mod)
    c1%=mod
    
for i in range(n-b+1,n+1):
    c2*=i
    c2%=mod
for j in range(1,b+1):
    c2*=pow(j,mod-2,mod)
    c2%=mod

ans=pow(2,n,mod)-1

print((ans-c1-c2)%mod)


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

#ifdef LOCAL
#define debug(var) cerr << (#var) << " = " << (var) << endl;
#else
#define debug(var)
#endif

void init() {
  ios_base::sync_with_stdio(0);
  cin.tie(0); cout.tie(0);
}

const int N = 3000;

void solve() {
  int r, g, b, n; scanf("%d%d%d%d", &r, &g, &b, &n);
  int ans = 0;
  for (int i = 0; i <= N; ++i) {
    if (i*r > n) break;
    for (int j = 0; j <= N; ++j) {
      if (i*r+j*g > n) break;
      if ((n-i*r-j*g)%b) continue;
      ++ans;
    }
  }
  printf("%d", ans);
}

int main() {
  init();
  int t = 1; //scanf("%d", &t);
  while (t--) {
    solve();
  }
  return 0;
}


Measured memory_bytes: 3752
#include <iostream>
#include <iomanip>
#include <cmath>

using namespace std;

int main()
{
    int n;
    double sum = 0.0;
    double average = 0.0;
    int num[1001];
    
    while (cin >> n)
    {
        if (0 == n)
        {
            break;
        }
        
        sum = 0.0;
        average = 0.0;
        for (int i = 0; i < n; i++)
        {
            cin >> num[i];
            sum += num[i];
        }
        
        average = sum / n;
        sum = 0.0;
        for (int i = 0; i < n; i++)
        {
            sum += (num[i] - average) * (num[i] - average);
        }
    
        cout << setprecision(20) << sqrt(sum / n) << endl;
    }
    
    return 0;
}



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

using namespace std;

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

const int N = 2e5+10 , mod = 1e9+7;

long double get(ll x){
   long double l = 1 , r = mod;
   for(int i = 0 ; i < N ; i++){
      long double m = (l + r) / 2;
      if(m * m <= x)
         l = m;
      else
         r = m;
   }
   return l;
}

int32_t main(){
   ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
   ll a , b , c;
   cin >> a >> b >> c;
   long double gt = get(a * b);
   if(gt * 2 + a + b < c)
      cout << "Yes";
   else
      cout << "No";
   return 0;
}


Measured memory_bytes: 256
# ####################################################################
# import io
# import sys

# _INPUT = """\
# 10000

# 20

# """
# sys.stdin = io.StringIO(_INPUT)
# ####################################################################
# import sys
# def _p(*_a):
#   #return
#   _s=" ".join(map(str,_a))
#   #print(_s)
#   sys.stderr.write(_s+"\n")
# ####################################################################
# def _pa(_aa):
#   #return
#   for _a in _aa: _p(_a)
# ####################################################################
N = int(input())

A = [0]*(N+1)

X=Y=Z= int(pow(N, 1/2)) + 2
# _p(A)

for x in range(1,X):
  if pow(x,2) >= 10000: break

  for y in range(1,Y):
    if (pow(x,2)+pow(y,2)) >= 10000: break

    for z in range(1,Z):
      # n = pow((x+y),2) + pow((y+z),2) + pow((z+x),2) + x*y + y*z + z*x
      # if n > N: continue
      i = pow((x+y),2) + pow((y+z),2) + pow((z+x),2)
      if i % 2 == 1: continue
      n = i//2
      if n > N: continue
      A[n] = A[n]+1

for a in A[1:]:
  print(a)



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

int main(void)
{
    int x;
  	cin>>x;
    for(int i=1;i<=1000;i++){
        if(100*i<=x && x<=105*i){
            cout<<1<<endl;
            return 0;
        }
    }
    cout<<0<<endl;
    return 0;
}

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

int n;
long long a[100000];


void solve(){
  sort(a,a+n);
  long long d = 100000000000;
  int ans;
  for(int i=0; i<n-1; i++){
    if( abs(a[n-1]-2*a[i]) < d){
      ans = i;
      d = abs(a[n-1]-2*a[i]);
    }
  }
  cout << a[n-1] << ' ' << a[ans] << endl;
}

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

  solve();
}

Measured memory_bytes: 1024
n = int(input())
a = list(map(int, input().split()))

flg = 0

for i in range(n):
    if a[i] % 2 == 0:
        if a[i] % 3 != 0 and a[i] % 5 != 0:
            flg = 1

if flg == 1:
    print("DENIED")
else:
    print("APPROVED")


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

int main(){
  string s,t;
  cin >> s >> t;
  sort(s.begin(), s.end());
  sort(t.begin(), t.end());
  reverse(t.begin(), t.end());

  if(s < t) cout << "Yes" << endl;
  else      cout << "No"  << endl;
}

Measured memory_bytes: 256
// Code for A - Ferris Wheel
#include <bits/stdc++.h>

using namespace std;

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

  if (a >= 13) {
    cout << b << endl;
    return 0;
  }

  if (a >= 6) {
    cout << b / 2 << endl;
    return 0;
  }

  cout << 0 << endl;

	return 0;
}


Measured memory_bytes: 256
#include<limits.h>
#include<stdio.h>
#include<string.h>

inline int dif(int a,int b){ return a<b?b-a:a-b; }

int h,w,i,j,l,k;
int a[81][81];
char d[81][81][12801];

int main(void){
  scanf("%d%d",&h,&w);
  l=(h+w-1)*80;
  for(i=0;i<h;i++){
    for(j=0;j<w;j++){
      scanf("%d",&a[i][j]);
    }
  }
  for(i=0;i<h;i++){
    for(j=0;j<w;j++){
      scanf("%d",&k);
      a[i][j]=dif(k,a[i][j]);
    }
  }
  d[0][0][a[0][0]]=1;
  for(i=0;i<h;i++){
    for(j=0;j<w;j++){
      for(k=0;k<=l;k++){
        if(d[i][j][k]==1){
          d[i+1][j][k+a[i+1][j]]=1;
          d[i+1][j][dif(k,a[i+1][j])]=1;
          d[i][j+1][k+a[i][j+1]]=1;
          d[i][j+1][dif(k,a[i][j+1])]=1;
        }
      }
    }
  }
  for(k=0;k<=l;k++){
    if(d[h-1][w-1][k]==1)break;
  }
  printf("%d\n",k);
  return 0;
}

    

Measured memory_bytes: 81280