akhauriyash/Code-Regression huggingface dataset:
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <bits/stdc++.h>
#include<queue>
#include <numeric>
using namespace std;
 
//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
 
//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}
 template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
 
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
 
//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define fore(i,a) for(auto &i:a)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
 
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
 
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
 



int main(){
    int A,B;
    cin >> A >> B;
    int ans=0;
    int num_A=0,num_B=0;
    bool exist=false;
    for(int i=0;i<=10000;++i){
        num_A=floor(i*0.08);
        num_B=floor(i*0.1);
        if(num_A==A && num_B==B){
            ans=i;
            exist=true;
            break;
        }
    }
    if(exist){
    cout << ans;
    }
    else{
        cout << -1;
    }
    } 

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

int main(){
  ll n;
  cin >> n;
  ll y3 = (n-1)/j9 + 1;
  ll x3 = j9 - (n%j9);
  if(n%j9 == 0)  x3 = 0;
  cout << "0 0 1000000000 1 " << x3 << " " << y3;
}

Measured memory_bytes: 3600
#include <iostream>

using namespace std;

int main()
{
	int S,h,m,s,t1,t2;
	cin >> S;
	h = S/3600;
	t1 = S%3600;
	m = t1/60;
	s = t1 % 60;
	cout<<h<<":"<<m<<":"<<s<<endl;
	return 0;
 } 


Measured memory_bytes: 3124
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
int n,m;
main()
{
	while(cin>>n,n)
	{
		vector<int>hp(n);
		for(int i=0;i<n;i++)cin>>hp[i];
		sort(hp.begin(),hp.end());
		cin>>m;
		vector<pair<int,int> >s,a;
		for(int i=0;i<m;i++)
		{
			string t;int mp,d;
			cin>>t>>mp>>t>>d;
			if(t=="Single")s.push_back({mp,d});
			else a.push_back({mp,d});
		}
		vector<int>S(hp.back()+1,1e9);
		S[0]=0;
		for(pair<int,int>p:s)
		{
			for(int j=1;j<p.second&&j<=hp.back();j++)S[j]=min(S[j],p.first);
			for(int j=0;j+p.second<=hp.back();j++)
			{
				S[j+p.second]=min(S[j+p.second],S[j]+p.first);
			}
		}
		vector<int>A(hp.back()+1,1e9);
		A[0]=0;
		for(pair<int,int>p:a)
		{
			for(int j=1;j<p.second&&j<=hp.back();j++)A[j]=min(A[j],p.first);
			for(int j=0;j+p.second<=hp.back();j++)
			{
				A[j+p.second]=min(A[j+p.second],A[j]+p.first);
			}
		}
		long ans=1e9;
		for(int i=0;i<=hp.back();i++)
		{
			long now=A[i];
			for(int j=0;j<n;j++)if(hp[j]>i)
			{
				now+=S[hp[j]-i];
			}
			ans=min(ans,now);
		}
		cout<<ans<<endl;
	}
}



Measured memory_bytes: 3604
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <utility>
#include <vector>
#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define reps(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; --i)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; --i)
#define INF 1000000000000
#define MOD 1000000007
#define CHOOSE(a) CHOOSE2 a
#define CHOOSE2(a0, a1, a2, a3, a4, x, ...) x
#define debug_1(x1) cout << #x1 << ": " << x1 << endl
#define debug_2(x1, x2) \
    cout << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << endl
#define debug_3(x1, x2, x3)                                                 \
    cout << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " \
         << x3 << endl
#define debug_4(x1, x2, x3, x4)                                             \
    cout << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " \
         << x3 << ", " #x4 << ": " << x4 << endl
#define debug_5(x1, x2, x3, x4, x5)                                         \
    cout << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " \
         << x3 << ", " #x4 << ": " << x4 << ", " #x5 << ": " << x5 << endl
#ifdef _DEBUG
#define debug(...)                                                        \
    CHOOSE((__VA_ARGS__, debug_5, debug_4, debug_3, debug_2, debug_1, ~)) \
    (__VA_ARGS__)
#else
#define debug(...)
#endif

using namespace std;
using ll = long long;

int main() {
    int x;
    cin >> x;
    if (x >= 30)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 3100
#単一始点最短経路問題
#負の辺があっても動作する

#最短経路を求める
#計算量O(N * M)

INF = 10 ** 15
#入力
# N = int(input()) #頂点の数
# M = int(input()) #辺の数
N, M, P = map(int, input().split())

# 入力は1-index
# 内部で0-indexにして処理
G = []
for _ in range(M): #M個の辺の情報を受け取る
    l, r, s = map(int, input().split()) #lからrへ重みsの辺が存在
    G += [[l-1, r-1, -(s-P)]] #有向グラフのときはここだけ
    # G += [[r-1, l-1, s]] #無向グラフのときはこの行も必要

#メイン文
d = [INF] * N #最短距離を記録しておくリスト
# prev = [-1] * N
negative = [False] * N
def restore(g): #gまでの最短経路を復元
    path = []
    g -= 1 #0-indexに直す
    path.append(g)
    g = prev[g]
    count = 0
    while g != -1:
        # print ('C')
        path.append(g)
        g = prev[g]
        count += 1
        if count == N + 2:
            break
    path.reverse()
    return path

def shortest_path(s): #S番目の頂点から各頂点への最短距離を求める
    s -= 1
    for i in range(N):
        d[i] = INF
    d[s] = 0
    count = 0
    while count < N - 1:
        count += 1
        for i in range(M): #無向グラフのときは辺は実質的には2倍
            e = G[i]
            if d[e[0]] != INF and d[e[1]] > d[e[0]] + e[2]:
                d[e[1]] = d[e[0]] + e[2]
    
    count = 0
    while count < N:
        count += 1
        for i in range(M): #無向グラフのときは辺は実質的には2倍
            e = G[i]
            if d[e[0]] == INF:
                continue
            if d[e[0]] != INF and d[e[1]] > d[e[0]] + e[2]:
                d[e[1]] = d[e[0]] + e[2]
                negative[e[1]] = True
            if negative[e[0]]:
                negative[e[1]] = True


#呼び出しスタート地点を入れる
shortest_path(1)
if negative[N - 1]:
    print (-1)
    # print (d)
    exit()
# print (d)
else:
    print (max(0, -d[N - 1]))

Measured memory_bytes: 51564
#include <stdio.h>
#include <string.h>
#include <iostream>
#include <string>
#include <vector>

using namespace std;

int main(void)
{
	string s;
	vector<char> t;
	int suu;

	cin >> s;
	t.push_back(s[0]);
	t.push_back(s[s.length() - 1]);
	suu = s.length() - 2;

	cout << t[0] << suu << t[1] << endl;
	

	return (0);
}

Measured memory_bytes: 256
L, R = map(int, input().split())

import math

#L<=i<j<=R
# i*j mod 2019の最小値

if R - L > 2030:
    L = 0
    R = 2019

result = 2019
for i in range(L, R+1):
    for j in range(i+1, R+1):
        tmp = (i * j) % 2019
        result = min(tmp, result)
        
print(result)

Measured memory_bytes: 3060
x, n = map(int, input().split())
if n == 0:
  print(x)
else:
  p = list(map(int, input().split()))
  diffs = [i-x for i in range(102)]
  for p_i in p:
    diffs[p_i] = 1000
    ans = 1000
    for n in diffs:
      if abs(ans) > abs(n):
        ans = n
  print(x+ans)

Measured memory_bytes: 9196
#include<bits/stdc++.h>
using namespace std;
                    
                    
int main(){
    int N;
    cin >> N;
    vector<int> P;
    for(int i = 0;i < N;i++){
        int p;
        cin >> p;
        P.push_back(p);
    }           
    
    int min_num = P.at(0);
    int ans = 1;

    for(int i: P){
        if(min_num > i){
            ans += 1;
            min_num = i;
        }
    }

    printf("%d", ans);
    printf("\n");
}

Measured memory_bytes: 1400
S = input()
count = 0
for i in range(len(S)):
    if((i+1)%2==1):
        if(S[i]=="L"):
            count = 1
            break
    else:
        if(S[i]=="R"):
            count = 1
            break
            
if(count==0):
    print("Yes")
else:
    print("No")

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

typedef long long lint;
typedef pair<int, int> P;
#define REP(i, x, n) for(int i = x ; i < n ; ++i)
#define rep(i, n) for(int i = 0 ; i < n ; ++i)
#define repr(i, n) for(int i = n - 1 ; i >= 0 ; --i)
#define ALL(x) (x).begin(), (x).end()
#define SORT(x) sort((x).begin(), (x).end())

const int IINF = 1e9 + 10;
const long long LLINF = (long long)1e18 + 10;
const long long MOD = (long long)1e9 + 7;
const int dx4[] = {1, 0, -1, 0}, dy4[] = {0, 1, 0, -1};
const int dx8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dy8[] = {0, -1, -1, -1, 0, 1, 1, 1};
const double EPS = 1e-8;

int main(){
    int n;
    cin >> n;
    vector<lint> t(n + 2), a(n + 2);
    t[0] = 0;
    a[n + 1] = 0;
    REP(i, 1, n + 1){
        cin >> t[i];
    }
    REP(i, 1, n + 1){
        cin >> a[i];
    }
    lint ans = 1;
    REP(i, 1, n + 1){
        if(t[i - 1] < t[i] && a[i] > a[i + 1]){
            if(t[i] != a[i]){
                ans = 0;
            }
        }else if(t[i - 1] < t[i]){
            if(t[i] > a[i]){
                ans = 0;
            }
        }else if(a[i] > a[i + 1]){
            if(t[i] < a[i]){
                ans = 0;
            }
        }else{
            ans *= min(t[i], a[i]);
            ans %= MOD;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1792
using System;

namespace _1_csharp
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] tap = new int[2];
            string[] str = Console.ReadLine().Split(" ");
            for (int i = 0; i < str.Length; i++){
                tap[i] = int.Parse(str[i]);
            }

            int count = 1;
            int num = 0;
            while (count < tap[1])
            {
                num++;
                count = (tap[0] - 1) * num + 1;
            }
            System.Console.WriteLine(num);
        }
    }
}


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

typedef long long lint;
typedef pair<int, int> P;
#define REP(i, x, n) for(int i = x ; i < n ; ++i)
#define rep(i, n) for(int i = 0 ; i < n ; ++i)
#define repr(i, n) for(int i = n - 1 ; i >= 0 ; --i)
#define ALL(x) (x).begin(), (x).end()
#define SORT(x) sort((x).begin(), (x).end())

const int IINF = 1e9 + 10;
const long long LLINF = (long long)1e18 + 10;
const long long MOD = (long long)1e9 + 7;
const int dx4[] = {1, 0, -1, 0}, dy4[] = {0, 1, 0, -1};
const int dx8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dy8[] = {0, -1, -1, -1, 0, 1, 1, 1};
const double EPS = 1e-8;

int main(){
    int n, m, k;
    cin >> n >> m >> k;
    bool flag = false;
    rep(i, n + 1){
        rep(j, m + 1){
            flag |= i * (m - j) + j * (n - i) == k;
        }
    }
    if(flag){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
def ncr(n, r, p): 
    num = den = 1 
    for i in range(r): 
        num = (num * (n - i)) % p 
        den = (den * (i + 1)) % p 
    return (num * pow(den,  
            p - 2, p)) % p 

s = int(input())
mod = 10**9+7

if s<3:
    res =0
elif s==3:
    res = 1
else:
    res = 0
    for i in range(1, s//3+1):
        n = s-2*i-1
        r = i-1
        res = (res%mod + ncr(n, r, mod)%mod)%mod

print(res)

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

int main() {
	int z[100]={},max=0,i;
	
	while(cin>>i){
		++z[i-1];
		
		if(z[i-1] > max)max = z[i-1];
	}
	
	for(i=0;i<100;++i){
		if(z[i]==max)cout<<i+1<<endl;
	}
	
	return 0;
}

Measured memory_bytes: 1160
#include<iostream>
#include<cmath>
#include<cstdio>
using namespace std;

int main(){
  double a, b, C;
  double S, L, h;
  double PI=acos(-1);

  cin >> a >> b >> C;

  S=0.5*a*b*sin(C*PI/180);
  L=a+b+sqrt(a*a+b*b-2*a*b*cos(C*PI/180));
  h=S*2/a;

  printf("%lf\n%lf\n%lf\n", S, L, h);

  return 0;
}

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

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

  if ( a == 'H'){
   if ( b == 'H') cout << "H" << endl;
    else cout << "D" << endl;
  }
  
  if ( a == 'D'){
    if ( b == 'H') cout << "D" << endl;
    else cout << "H" << endl;
  }
    
			       

  return 0;

}


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

int main(void)
{
	int N;
	int count = 1;
	cin >> N;
	int highest;
	cin >> highest;
	for (int i = 1; i < N; i++) {
		int H;
		cin >> H;
		if (highest <= H) {
			count++;
			highest = H;
		}

	}
	cout << count << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define REP(i, n) FOR(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define bit(x) (1L << (x))
using ll = long long;
using namespace std;

template<typename T>
vector<T> make_v(size_t a,T b){return vector<T>(a,b);}
 
template<typename... Ts>
auto make_v(size_t a,Ts... ts){
        return vector<decltype(make_v(ts...))>(a,make_v(ts...));
}

set<ll> div(ll x) {
        set<ll> r;

        for (ll d = 1; d * d <= x; d++) {
                if (x % d == 0) {
                        r.insert(d);
                        r.insert(x / d);
                }
        }

        return r;
}

int main() {
        ll n;
        cin >> n;

        auto s1 = div(n), s2 = div(n - 1);
        
        s1.insert(s2.begin(), s2.end());
        
        int ans = 0;
        for (ll k : s1) {
                if (k == 1) continue;

                ll x = n;
                while (x >= k) {
                        if (x % k == 0) {
                                x /= k;
                        } else {
                                x %= k;
                        }
                }

                if (x == 1) ans++;
        }

        cout << ans << endl;

        return 0;
}


Measured memory_bytes: 512
import re

def main():
    stack = []
    input_str = list(map(str,input().split()))
    for i in range(len(input_str)):
        ch = input_str[i]
        if ch == "+":
            stack[-2] = stack[-2] + stack[-1]
            stack.pop() 
        elif ch == "-":
            stack[-2] = stack[-2] - stack[-1]
            stack.pop() 
        elif ch == "*":
            stack[-2] = stack[-2] * stack[-1]
            stack.pop()
        
        else:
            stack.append(int(ch))
    print(stack[0])


    
if __name__ == '__main__':
    main()



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

using namespace std;
string A,B;

int lcs[3001][3001];

int main()
{

    cin >> A >> B;


    for (int i = 0 ; i <= A.size() ; i++){
        for (int j = 0 ; j <= B.size() ; j++){
            if (i == 0 || j == 0)lcs[i][j] = 0;
            else if (A[i-1] == B[j - 1])lcs[i][j] = lcs[i - 1][j - 1] + 1;
            else {
                lcs[i][j] = max(lcs[i - 1][j] , lcs[i][j - 1]);
            }
        }
    }


    string ans = "";

    int i = A.size();
    int j = B.size();

    while(lcs[i][j] != 0){
        if (lcs[i][j] != max(lcs[i][j-1], lcs[i-1][j])){
            ans+= A[i - 1];
            i--;
            j--;
        }
        else if (lcs[i][j] == lcs[i][j - 1]){
            j--;
        }
        else if (lcs[i][j] == lcs[i - 1][j]){
            i--;
        }
    }

    reverse(ans.begin() , ans.end());

    cout << ans << endl;



    return 0;
}


Measured memory_bytes: 38784
#include <bits/stdc++.h>
#define REP(i,N) for (int i =0; i < (N); ++i)
#define ALL(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;

int main(){
  int N;
  cin>>N;
  //double A[N];
  vector<double> V(N);
  REP(i,N){cin>>V.at(i);}
  double ans;
  sort(ALL(V));
  ans = V[0];
  REP(i,N-1){ans = (ans+V[i+1])/2;}
  cout<<ans;
}


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

long long int N, x, a[2123];
long long int b[2123], ans;

int main(void)
{
	scanf("%lld%lld", &N, &x);
	for (long long int i = 0; i < N; ++i) { scanf("%lld", &a[i]); }

	for (long long int i = 0; i < N; ++i)
	{
		b[i] = a[i];
		ans += a[i];
	}
	for (long long int k = 0; k < N; ++k)
	{
		long long int res = 0;
		for (long long int i = 0; i < N; ++i)
		{
			res += b[i];
		}
		ans = std::min(ans, res + k*x);
		long long int pre = (-k - 1 + N) % N;
		for (long long int i = 0; i < N; ++i)
		{
			b[i] = std::min(b[i], a[pre]);
			pre = (pre + 1 + N) % N;
		}
	}

	printf("%lld\n", ans);
	return 0;
}

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

int n = 4;

void solve(){
	int s; cin >> s;
	for (int i = 0; i < 10; i++){
		string str = to_string(s*s);
		if (str.size() < 8){
			string str2;
			for (int j = 0; j < 8 - str.size(); j++) str2+='0';
			str2 += str;
			str = str2;
		}
		string ret = "0000";
		for (int j = 0; j < 4; j++){
			ret[j] = str[j + 2];
		}
		int ans = stoi(ret);
		cout << ans << endl;
		s = ans;
	}
}

int main(){
	int num; cin >> num;
	for (int i = 0; i < num; i++){
		cout << "Case " << i + 1 << ":" << endl;
		solve();
	}
	return 0;
}

Measured memory_bytes: 1248
/*                   
                                             ::                     ::       
                                             ':                     :        
                                              :.                    :        
                                           ;' ::                   ::  '     
                                          .'  ';                   ;'  '.    
                                         ::    :;                 ;:    ::   
                                         ;      :;.             ,;:     ::   
                                         :;      :;:           ,;"      ::   
                                         ::.      ':;  ..,.;  ;:'     ,.;:   
                                          "'"...   '::,::::: ;:   .;.;""'    
                                              '"""....;:::::;,;.;"""         
                                          .:::.....'"':::::::'",...;::::;.   
                                         ;:' '""'"";.,;:::::;.'""""""  ':;   
                                        ::'         ;::;:::;::..         :;  
                                       ::         ,;:::::::::::;:..       :: 
                                       ;'     ,;;:;::::::::::::::;";..    ':.
                                      ::     ;:"  ::::::"""'::::::  ":     ::
                                       :.    ::   ::::::;  :::::::   :     ; 
                                        ;    ::   :::::::  :::::::   :    ;  
                                         '   ::   ::::::....:::::'  ,:   '   
                                          '  ::    :::::::::::::"   ::       
                                             ::     ':::::::::"'    ::       
                                             ':       """""""'      ::       
                                              ::                   ;:        
                                              ':;                 ;:"        


                                                     P_r_A_d_Y
*/
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define endl "\n"
#define mod 1000000007
#define inf 1e18
const int N = 300005;
#define fastIO ios_base::sync_with_stdio(false); cin.tie(NULL);
void cs(int &x)
{
  cout<<"Case #"<<x<<": ";
}
bool cmp(int a,int b)
{
  return a>b;
}
int32_t main()
{
  fastIO;
  // int t;cin>>t;
  // int x=1;
  // while(t--)
  // {
     int n;cin >> n;
     if(n>=30)
      cout<<"Yes"<<endl;
    else
      cout<<"No"<<endl;

  //}
  return 0;
}

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

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

    ll a1 = min(a, b), b1 = max(a, b);

    ll games;
    if((b1-a1) % 2 == 0) games = (b1-a1) / 2;
    else {
        if(a1-1 < n-b1){
            games = a1-1;
            b1 = b1-a1+1; a1=1;
        }
        else{
            games = n-b1;
            a1 = a1+n-b1; b1=n;
        }
        if((b1-a1) % 2 == 0) games += (b1-a1)/2;
        else games += (b1-a1)/2 + 1;
    }

    cout << games;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
using namespace std;
using namespace __gnu_pbds;
 
using ll = long long;
using ldb = long double;
using pa = pair < ll, ll >;
using vec = vector < ll >;
 
template < typename T > using index_set = tree < T, null_type, less < T >, rb_tree_tag, tree_order_statistics_node_update >;
template < typename T > using MinPriorityQueue = priority_queue < T, vector < T >, greater < T > >;

#define pb push_back
#define po pop_back
#define mp make_pair
#define mt make_tuple
#define F  first
#define S  second
#define f(i,x,n) for(ll i=x;i<n;i++) 
#define all(c) c.begin(),c.end()
#define str string
#define edl "\n"
#define add insert
#define cot continue
#define fast() ios_base::sync_with_stdio(false);cin.tie(NULL)


const int MOD = 1e9 + 7, INF = INT_MAX, N = 1e5 + 10;
const double PI = acos(-1);
const ll LINF = LLONG_MAX;

int main() 
{

    fast();
      
    // #ifndef ONLINE_JUDGE
    //         freopen("input.txt", "r", stdin);
    //         freopen("output.txt","w",stdout);
    // #endif
    ll a,n;
    
    cin>>a>>n;
    cout<<max(a+n,max(a-n,a*n));
    
    





  

    cerr << "Time taken: " << int((clock() * 1000.) / CLOCKS_PER_SEC) << "ms\n";
    return 0;
}
 

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

public class Main {
   
	public static void main(String[] args) throws IOException {
		InputReader in = new InputReader(System.in);
		int n = in.readInt();
		int arr [] = new int[n]; 
		for(int i  = 0; i<n; i++) 
			arr[i] = in.readInt();
			
		Arrays.sort(arr);
		System.out.println(arr[arr.length-1] - arr[0]); 
		}
}
class InputReader {

	private InputStream stream;
	private byte[] buf = new byte[1024];
	private int curChar;
	private int numChars;
	private SpaceCharFilter filter;

	public InputReader(InputStream stream) {
		this.stream = stream;
	}

	public int read() {
		if (numChars == -1)
			throw new InputMismatchException();
		if (curChar >= numChars) {
			curChar = 0;
			try {
				numChars = stream.read(buf);
			} catch (IOException e) {
				throw new InputMismatchException();
			}
			if (numChars <= 0)
				return -1;
		}
		return buf[curChar++];
	}

	public int readInt() {
		int c = read();
		while (isSpaceChar(c))
			c = read();
		int sgn = 1;
		if (c == '-') {
			sgn = -1;
			c = read();
		}
		int res = 0;
		do {
			if (c < '0' || c > '9')
				throw new InputMismatchException();
			res *= 10;
			res += c - '0';
			c = read();
		} while (!isSpaceChar(c));
		return res * sgn;
	}

	public String readString() {
		int c = read();
		while (isSpaceChar(c))
			c = read();
		StringBuilder res = new StringBuilder();
		do {
			res.appendCodePoint(c);
			c = read();
		} while (!isSpaceChar(c));
		return res.toString();
	}

	public long readLong() {
		int c = read();
		while (isSpaceChar(c)) {
			c = read();
		}
		int sgn = 1;
		if (c == '-') {
			sgn = -1;
			c = read();
		}
		long res = 0;
		do {
			if (c < '0' || c > '9') {
				throw new InputMismatchException();
			}
			res *= 10;
			res += c - '0';
			c = read();
		} while (!isSpaceChar(c));
		return res * sgn;
	}
	
	public boolean isSpaceChar(int c) {
		if (filter != null)
			return filter.isSpaceChar(c);
		return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
	}

	public String next() {
		return readString();
	}

	public interface SpaceCharFilter {
		public boolean isSpaceChar(int ch);
	}
}


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

using namespace std;

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

#define F first
#define S second
#define PB push_back
#define MK make_pair
#define REP(i, a, b) for (int i=a; i < b; i++)


bool sort_by(vi c, vi d){
	return c.S < d.S;
}

int main() {
	int N, D, X;
	cin >> N >> D >> X;
	int eaten = N;
	REP(i, 0, N){
		//int n, j = 1;
		int n;
		cin >> n;
		eaten += (D-1)/n;
		/*while(j*n + 1 <= D){
			eaten +=1;
			++j;
		}*/
	}
	cout << eaten + X;

}


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

int main(){
  int A,B,C,D;
  scanf("%d%d%d%d",&A,&B,&C,&D);
  if(A + B > C + D){
    printf("Left");
  }else if(A + B == C + D){
    printf("Balanced");
  }else{
    printf("Right");
  }
}


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

using namespace std;

int main(){
    int N, cnt = 0;
    string S;

    cin >> N >> S;

    for(int i = 0; i < N - 2; i ++){
        if(S.substr(i, 3) == "ABC")cnt ++;
    }

    cout << cnt << endl;

    return 0;
}

Measured memory_bytes: 3600
#include <algorithm>
#include <iostream>
#define REP(i,n) for(int i=0; i<(int)(n); i++)

#include <queue>
#include <cstdio>
#include <complex>

inline int getInt(){ int s; scanf("%d", &s); return s; }

#include <set>
using namespace std;

typedef complex<double> P;

class UnionFind{
private:
  vector<int> id;

  int getId(int i){
    if(i == id[i]) return i;
    return id[i] = getId(id[i]);
  }
public:
  UnionFind(int size = 0){ init(size); }
  ~UnionFind(){}
  void init(int size){
    id = vector<int>(size);
    for(int i = 0; i < size; i++)
      id[i] = i;
  }
  void unite(int i, int j){
    int next = min( getId(i), getId(j) );
    id[getId(i)] = id[getId(j)] = next;
  }
  int operator [](int i){ return getId(i); }
  int count(){
    set<int> s;
    for(int i = 0; i < (int)id.size(); i++)
      s.insert(getId(i));
    return s.size();
  }
};

int main(){
  const int w = getInt();
  const int h = getInt();
  const int n = getInt();
  vector<P> v(n);

  REP(i,n){
    const int x = getInt();
    const int y = getInt();
    v[i] = P(x, y);
  }

  UnionFind uf(n + 2);
  vector<pair<double, pair<int, int> > > pq;

  const int left  = n;
  const int right = n + 1;

  REP(i,n){
    pq.push_back(make_pair(v[i].real(), make_pair(left, i)));
    pq.push_back(make_pair(w - v[i].real(), make_pair(right, i)));

    REP(j,i){
      const double dist = std::abs(v[i] - v[j]) / 2.0;
      pq.push_back(make_pair(dist, make_pair(i, j)));
    }
  }

  sort(pq.begin(), pq.end());

  double ans = 0.0;
  for(int i = 0; uf[left] != uf[right]; i++){
    ans = pq[i].first;
    const int a = pq[i].second.first;
    const int b = pq[i].second.second;
    uf.unite(a, b);
  }

  printf("%.8f\n", ans);

  return 0;
}

Measured memory_bytes: 3132
#include<iostream>
#include<string>
#include<stdio.h>
#include <algorithm>
#include <set>
#include<math.h>
#include<vector>
#include<iomanip>
#include <cstdio>

using namespace std;

int main(){
    double w,h,x,y;cin >> w >> h >> x >> y;
    double m=0.0;
    int cnt = 0;
    m = (w*h) /2;
    if(x*2 == w && y*2 == h)cnt = 1;
    cout << fixed << setprecision(10) << m << " " << cnt << endl;
}

Measured memory_bytes: 3748
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, from, to) for (ll i = from; i < (to); ++i)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define pb push_back
using ll = long long;
using ld=long double;
using vin=vector<int>;
using vvin=vector<vin>;
using vll=vector<ll>;
using vvll=vector<vll>;
using vst=vector<string>;
using P = pair<ll,ll>;
const int inf=1e9+7;
const ll INF=9e18;
template <typename T> bool chmin(T &a, const T& b){if(a > b){a = b;return true;}return false;}
template <typename T> bool chmax(T &a, const T& b){if(a < b){a = b;return true;}return false;}
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };

ll modpow(ll x, ll y) {
    ll res = 1;
    while (y) {
        if (y % 2) res = 1LL * res * x % inf;
        y >>= 1;
        x = 1LL * x * x % inf;
    }
    return res;
}

int main(){cout<<fixed<<setprecision(20);
		   ll n;
           cin>>n;
           ll ans=0;
           ans+=2*modpow(9,n)%inf-modpow(8,n);
           ans%=inf;
           ans=modpow(10,n)-ans;
           ans%=inf;
           if(ans<0)ans+=inf;  
           cout<<ans<<endl;
}

Measured memory_bytes: 3628
#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>
#define chmin(a, b) ((a)=min((a), (b)))
#define chmax(a, b) ((a)=max((a), (b)))
#define fs first
#define sc second
#define eb emplace_back
using namespace std;

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

const ll MOD=1e9+7;
const ll INF=1e18;
const double pi=acos(-1);
const double eps=1e-10;

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

int main(){
    int n, q; cin>>n>>q;
    string s; cin>>s;

    vector<int> sum(n+10, 0);
    for(int i=0; i<n; i++){
        if(i+1 < n && s[i] == 'A' && s[i+1] == 'C'){
            sum[i+1] = sum[i];
            sum[i+2] = sum[i+1] + 1;
            i++;
        }
        else sum[i+1] = sum[i];
    }

    while(q--){
        int a, b; cin>>a>>b;
        cout << sum[b] - sum[a] << endl;
    }
}

Measured memory_bytes: 1408
N = int(input())
a = list(map(int,input().split()))
center = 0
M = N//2
parity = N%2
capacity = [0 for _ in range(M)]
failed = False
for i in range(N):
    if a[i]%2 == parity:
        failed = True
        break
    if a[i] < 0 or a[i] > N-1:
        failed = True
        break
    if a[i] == 0:
        center += 1
    else:
        j = (N-a[i])//2
        capacity[j] += 1
if parity == 1 and center != 1:
    failed = True
answer = 1
MOD = 10**9+7
for c in capacity:
    if c!=2:
        failed = True
        break
    else:
        answer *= 2
        answer %= MOD

if failed:
    print(0)
else:
    print(answer)


Measured memory_bytes: 14008
#include <iostream>
#include <string.h>

using namespace std;

int main()
{
	string strS, strT;
	int nS, nT;
	
	cin >> strS;
	cin >> strT;
	nS = strS.size();
	nT = strT.size();
	if (nS + 1 != nT)
		cout << "No"<< endl;
	if (strncmp(strS.c_str(), strT.c_str(), nS) ==0)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
	
	return EXIT_SUCCESS;
}


Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pi atan(1.0)*4
#define pb(x) push_back(x)
#define in(x) insert(x)
#define fl(x,y) for(ll i=x;i<y;i++)
#define vi vector<long long>
#define vs  vector<string>
#define vp(vi,x) cin>>x; vi.pb(x);
string en="\n";
string t="hello";
string Y="YES\n";
string N="NO\n";
#define E end()
#define B begin()
#define sz size()
#define EM empty()
#define fi first
#define se second
#define clr clear()
#define sqr(a) (a*a)
#define mk make_pair
#define mem(a,b) memset(a,b,sizeof(a))
#define all(cont) cont.begin(),cont.end()
/*bool isprm(LL a){for(LL i=2;i*i<=a;i++){if(a%i==0)return false;}return true;}
bool palin(string a){for(int i=0;i<a.sz;i++){if(a.at(i)!=a.at(a.sz-i-1))return 0;} return 1;}
bool isVowel(char ch){ ch=toupper(ch); if(ch=='A'||ch=='U'||ch=='I'||ch=='O'||ch=='E') return true; return false;}
int toInt(string s){int sm;stringstream ss(s);ss>>sm;return sm;}
LL bpow(LL a,LL b){if(b==0)return 1;LL r=bpow(a,b/2);if(b%2)return r*r*a;else return r*r;}
LL binpow(LL a,LL b){LL r=1;while(b>0){if(b&1)r=r*a;a=a*a;b>>=1;}return r;}
LL binpow(LL a,LL b,LL m){a%=m;LL r=1;while(b>0){if(b&1) r=r*a%m;a=a*a%m; b>>=1;}return r;}
template<typename T>inline T gcd(T a,T b){if(a<0)return gcd(-a,b);if(b<0)return gcd(a,-b);return (b==0)?a:gcd(b,a%b);}
template<typename T>inline T lcm(T a,T b) {if(a<0)return lcm(-a,b);if(b<0)return lcm(a,-b);return a*(b/gcd(a,b));}
*/
bool isVowel(char ch){ ch=toupper(ch); if(ch=='A'||ch=='U'||ch=='I'||ch=='O'||ch=='E') return true; return false;}
int main()
{
    ll a,b,c,t,n,k,p,q,r,y,yy,sum,ct=0,flag=0;
    string s,s1,s2,s3;
    set<ll>st;
    char ch;
    map<ll,ll>mp;
    vector<ll>v,vv,vz;

      cin>>a>>b>>c;

       cout<<(a+b)*(c/2)<<endl;
}





Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
#define MAX_N 100010
typedef long long lint;
typedef pair<int,int> P;
const int    INF=(int)1e9;
const int    MOD=(int)1e9+7;
const double EPS=(double)1e-10;
struct Accelerate_Cin{
    Accelerate_Cin(){
        cin.tie(0); ios::sync_with_stdio(0);cout<<fixed<<setprecision(20);
    };
};

//Ｏ(α(n)) < Ｏ(log n) 非常に高速

int par[MAX_N],rank1[MAX_N];
int N,M,p[MAX_N];

//n要素で初期化
void init(int n){
  for(int t=0;t<n;t++){
    par[t]=t;
    rank1[t]=0;
  }
}

//木の根を求める。
int find(int x){
  if(par[x]==x){
    return x;
  }else{
    return par[x]=find(par[x]);
  }
}

//xとｙの集合を併合。
void unite(int x, int y){
  x=find(x);
  y=find(y);
  if(x==y)return;

  if(rank1[x]<rank1[y]){
    par[x]=y;
  }else{
    par[y]=x;
    if(rank1[x]==rank1[y])rank1[x]++;
  }
}

//xとｙが同じ集合に属するかどうか。
bool same(int x, int y){
  return find(x)==find(y);
}


signed main(){
  cin>>N>>M;
  for(int t=1;t<=N;t++)cin>>p[t];

  init(N+10);

  for(int t=1;t<=M;t++){
    int x,y;cin>>x>>y;
    unite(x,y);
  }

  int cont=0;
  for(int t=1;t<=N;t++){
    if(same(t,p[t]))cont++;
  }

  cout<<cont<<"\n";
  return 0;
}


Measured memory_bytes: 1408
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author champon
 */

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for(ll i=0; i<n; i++)
#define repr(i, s, e) for(ll i=s; i>=e; i--)
#define reps(i, s, e) for(ll i=s; i<=e; i++)
#define inf 1e18
#define all(v) v.begin(),v.end()
#define ceil(a, b) (a+b-1)/b
#define ok cout << "ok" << endl;
#define sp << " " <<
template<typename T> inline bool chmax(T &a, T b){ if(a<b) a=b; return a<b; }
template<typename T> inline bool chmin(T &a, T b){ if(b<a) a=b; return b<a; }
template<typename T> void vdeb(T v){
    cout << "#vector set debug" << endl;
    for(auto vv : v) cout << vv << " ";
    cout << endl;
}
template<typename T1, typename T2> void adeb(T1 arr[], T2 n){
    cout << "#adebug" << endl;
    for(int i=0; i<=n; i++) cout << arr[i] << " ";
    cout << endl;
}
template<typename T1> void mdeb(T1 mp){
    cout << "#map pair debug" << endl;
    for(auto const& m : mp) cout << m.first sp m.second << endl;
}
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){ fill((T*)array, (T*)(array+N), val); }
void ans(bool b){ cout << (b ? "Yes" : "No") << endl; }
void ans2(bool b){ cout << (b ? "YES" : "NO") << endl; }
int dx[] = {1, 0, -1, 0, 1, -1, 1, -1};
int dy[] = {0, 1, 0, -1, 1, -1, -1, 1};


class ACantWaitForHoliday {
public:
	void solve(std::istream& in, std::ostream& out) {
        string s;
        in >> s;

        int res;
        if(s == "SAT"){
            res = 1;
        }
        if(s == "SUN"){
            res = 7;
        }
        if(s == "MON"){
            res = 6;
        }
        if(s == "TUE"){
            res = 5;
        }
        if(s == "WED"){
            res = 4;
        }
        if(s == "THU"){
            res = 3;
        }
        if(s == "FRI"){
            res = 2;
        }

        out << res;
	}
};


int main() {
	ACantWaitForHoliday solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <string>
#include <math.h>
#include<algorithm>
using namespace std;

int main(){
  int N;
  cin >> N;
  int ans=10000;
  int j,k;
  int A,B;
  for(int i=1;i<N;i++){
    j=N-i;
    k=i;
    A=0;
    B=0;
   while(k>0){
    A+=k%10;
     k/=10;
   }
    while(j>0){
     B+=j%10;
      j/=10;
    }
     ans=min(ans,A+B); 
  }
  cout << ans << endl;
  return 0;}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
  int n;
  long long int ans;
  ans=1;
  scanf("%d",&n);
  long long int a[100005];
  for(int i=0;i<n;i++)
  {
      scanf("%lld",&a[i]);
      if(!a[i])
      {
          printf("0\n");
          return 0;
      }
  }
 for(int i=0;i<n;i++)
  {
    long long int temp;
    temp=ans*a[i];
    if(ans>temp||temp>1000000000000000000)
    {  printf("-1\n"); return 0;}
    ans=temp;
  }
  printf("%lld",ans);
  return 0;
}


Measured memory_bytes: 2464
n,q=map(int,input().split())
s=input()
con=[0]
c=False
for i in range(n):
    if s[i]=='A':
        c=True
        con.append(con[-1])
        continue
    if c:
        if s[i]=='C':
            con.append(con[-1]+1)
            c=False
            continue
        else:
            con.append(con[-1])
            c=False
            continue
    con.append(con[-1])    
for j in range(q):
    l,r=map(int,input().split())
    print(max(0,con[r]-con[l]))



Measured memory_bytes: 11476
#ifdef DEBUG

#else

#    pragma GCC optimize("O3,no-stack-protector")
#    pragma GCC optimize("unroll-loops")

#    if __cplusplus >= 201703L
#        pragma GCC target("avx2")
#    else
#        pragma GCC target("avx")
#    endif

#endif
// 実数の場合
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define dump(x) cout << x << endl
typedef int64_t Int;
typedef long double Ld;

using namespace std;
using Graph = vector<vector<Int>>;

const double pi = M_PI;
const Int MOD = 1000000007;

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

    string s;
    cin >> s;

    cout << s[0] << s.size() - 2 << s[s.size() - 1] << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <ctype.h>
#include <map>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <cctype>
#include <queue>
#include <set>
#define PI 3.14159265359
#define REP(i,n) for(int i=0;i<(int)n;++i)
#define REP1(j,n) for(int j=0;j<(int)n;++j)
#define REPD(i,n) for(int i=n;i>=0;--i)
#define REPD1(j,n) for(int j=n;j=>0;--j)
#define REPS(i,n) for(int i=1;i<=(int)n;++i)
#define REPS1(j,n) for(int j=1;j<=(int)n;++j)
#define rep(i,a,n) for(int i=a;i<=(int)n;++i)
#define SZ(x) ((int)(x).size())	//size() unsigned -> int
#define DescSort(a) sort(a.begin(),a.end(),std::greater<int>())

using namespace std;
typedef long long ll;
const ll INF=1e9+7;

int main(void) {
	vector<int> tower(999);
	tower[1] = 1;
	rep(i, 2, 998) {
		tower[i] += tower[i - 1] + i;
	}
	int a, b;
	cin >> a >> b;
	int ans1,ans2;
	rep(i, 1, 998) {
		ans1 = tower[i] - a;
		ans2 = tower[i + 1] - b;
		if (ans1 == ans2)break;
	}
	cout << ans1 << endl;
	return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AOJ_ITP_1_2_C
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] s = Console.ReadLine().Split(' ');
            int a = int.Parse(s[0]);
            int b = int.Parse(s[1]);
            int c = int.Parse(s[2]);

            int tmp;
            if (a > b)
            {
                tmp = a; a = b; b = tmp;
            }
            if(b > c)
            {
                tmp = b; b = c; c = tmp;
            }
            if(a > b)
            {
                tmp = a; a = b;b = tmp;
            }
            Console.WriteLine(a + " " + b + " " + c);
        }
    }
}



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

typedef long long ll;
typedef unsigned long long ull;
ll a[200005];
const int mod=1e9+7;
void shit(){
    string s,t;
    int max_=-1;
    cin>>s>>t;
    for(int i=0;i<s.size();i++)
    {
        int temp=0;
        int ii=i;
        //cout<<ii<<" sa"<<endl;
        for(int j=0;j<t.size();j++)
        {
            //cout<<j<<endl;
            if(ii<s.size()&&s[ii]==t[j])
            {
                //cout<<ii<<" "<<j<<" ";
                //cout<<temp<<endl;
                temp++;
                ii++;
            }
            else
            {
                if(temp>max_&&j-temp<=ii-temp&&t.size()-j<=s.size()-ii)
                {
                    max_=temp;
                }
                temp=0;
            }
        }
        if(temp>max_&&t.size()-temp<=ii-temp&&0<=s.size()-ii)
        {
            max_=temp;
        }
    }
    cout<<t.size()-max_;
}

void slove(){
    ll n;
    cin>>n;
    ll sum=0;
    ll res=0;
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
        sum=(sum+a[i]%mod)%mod;
    }
    for(int i=0;i<n;i++)
    {
        res=((sum-a[i]+mod)%mod*a[i]%mod+res)%mod;
    }
    if(res%2==0)
        cout<<res/2;
    else
        cout<<((res+mod)/2)%mod;
}

int main() {
    int _=1;
//    cin>>_;
    while (_--){
        slove();
    }
    return 0;
}

Measured memory_bytes: 5188
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
typedef vector<vector<P>> vvP;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;

int main() {
    ll n;
    cin >> n;

    if(n%111 == 0) {
        out(n);
    }
    else {
        ll a = n/111;
        out(111*(a+1));
    }

    re0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <complex>
#include <utility>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <tuple>
#include <cmath>
#include <bitset>
#include <cctype>
#include <set>
#include <map>
#include <unordered_map>
#include <numeric>
#include <functional>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define PRINT(V) cout << V << "\n"
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())
using namespace std;
using ll = long long;
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; }
inline void Yes(bool condition){ if(condition) PRINT("Yes"); else PRINT("No"); }
template<class itr> void cins(itr first,itr last){
    for (auto i = first;i != last;i++){
        cin >> (*i);
    }
}
template<class itr> void array_output(itr start,itr goal){
    string ans = "",k = " ";
    for (auto i = start;i != goal;i++) ans += to_string(*i)+k;
    if (!ans.empty()) ans.pop_back();
    PRINT(ans);
}
ll gcd(ll a, ll b) {
    return a ? gcd(b%a,a) : b;
}
const ll INF = 1e15;
const ll MOD = 1000000007;
const ll MOD2 = 998244353;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> tri;
typedef pair<double,double> point;
const ll MAX = 30000;
constexpr ll nx[8] = {1,0,-1,0,1,-1,1,-1};
constexpr ll ny[8] = {0,1,0,-1,1,1,-1,-1};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    string s;
    cin >> n >> s;
    ll l = 0,r = n-1;
    while (s[l] == 'R'){
        l++;
    }
    while (s[r] == 'W'){
        r--;
    }
    ll R = 0,W = 0;
    rep(i,l,r+1){
        if (s[i] == 'R') R++;
        else W++;
    }
    ll ans = 0,ans2 = 0;
    rep(i,R){
        if (s[l+i] == 'W') ans++;
    }
    rep(i,W){
        if (s[r-i] == 'R') ans2++;
    }
    PRINT(min(ans,ans2));
}


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


#define PB push_back
#define PF push_front
#define LB lower_bound
#define UB upper_bound
#define fr(x) freopen(x,"r",stdin)
#define fw(x) freopen(x,"w",stdout)
#define iout(x) printf("%d\n",x)
#define lout(x) printf("%lld\n",x)
#define REP(x,l,u) for(int x = (l);x<=(u);x++)
#define RREP(x,l,u) for(int x = (l);x>=(u);x--)
#define mst(x,a) memset(x,a,sizeof(x))
#define PII pair<int,int>
#define PLL pair<ll,ll>
#define MP make_pair
#define se second
#define fi first
#define dbg(x) cout<<#x<<" = "<<(x)<<endl;
#define sz(x) ((int)x.size())
#define cl(x) x.clear()

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

const int maxn = 200010;
const int mod = 1e9+7;
const int MAX = 1000000010;
const double eps = 1e-6;
const double PI = acos(-1);

template<typename T> inline void read(T &x){
x=0;T f=1;char ch;do{ch=getchar();if(ch=='-')f=-1;}while(ch<'0'||ch>'9');do x=x*10+ch-'0',ch=getchar();while(ch<='9'&&ch>='0');x*=f;
}

template<typename A,typename B> inline void read(A&x,B&y){read(x);read(y);}
template<typename A,typename B,typename C> inline void read(A&x,B&y,C&z){read(x);read(y);read(z);}
template<typename A,typename B,typename C,typename D> inline void read(A&x,B&y,C&z,D&w){read(x);read(y);read(z);read(w);}
template<typename A,typename B> inline A fexp(A x,B p){A ans=1;for(;p;p>>=1,x=1LL*x*x%mod)if(p&1)ans=1LL*ans*x%mod;return ans;}
template<typename A,typename B> inline A fexp(A x,B p,A mo){A ans=1;for(;p;p>>=1,x=1LL*x*x%mo)if(p&1)ans=1LL*ans*x%mo;return ans;}

int n,S;

int x[maxn],Ans[maxn],cnt;

ll p[maxn];

int main(){
	read(n,S);
	REP(i,1,n)read(x[i],p[i]);
	ll ans=0;
	int l=1,r=n;
	while(x[l]<S&&S<x[r]){
		if(p[l]>=p[r]){
			p[l]+=p[r];
			Ans[++cnt]=x[r];
			r--;
		}
		else{
			p[r]+=p[l];
			Ans[++cnt]=x[l];
			l++;
		}
	}
//	cout<<l<<' '<<r<<endl;
	if(x[l]>S)RREP(i,r,l)Ans[++cnt]=x[i];
	if(x[r]<S)REP(i,l,r)Ans[++cnt]=x[i];
	Ans[++cnt]=S;
//	REP(i,1,cnt)cout<<Ans[i]<<' ';cout<<endl;
	REP(i,1,cnt-1)ans+=abs(Ans[i]-Ans[i+1]);
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 1792
#include <stdio.h>
#include <stdlib.h>
int main(void){
  int a,b,c,d;
scanf("%d",&a);
scanf("%d",&b);
scanf("%d",&c);
scanf("%d",&d);

if(abs(a-c) <= d || (abs(a-b) <= d && abs(b-c) <= d)){
 printf("Yes");
} else {
 printf("No");
}

return 0;
} 

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define P pair<ll,ll>
#define FOR(I,A,B) for(ll I = ll(A); I < ll(B); ++I)
#define FORR(I,A,B) for(ll I = ll((B)-1); I >= ll(A); --I)
#define TO(x,t,f) ((x)?(t):(f))
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //xi>=v  x is sorted
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //xi>v  x is sorted
#define NUM(x,v) (POSU(x,v)-POSL(x,v))  //x is sorted
#define REV(x) (reverse(x.begin(),x.end())) //reverse
ll gcd(ll a,ll b){if(a%b==0)return b;return gcd(b,a%b);}
ll lcm(ll a,ll b){ll c=gcd(a,b);return ((a/c)*(b/c)*c);}
#define NEXTP(x) next_permutation(x.begin(),x.end())
const ll INF=ll(1e18)+ll(7);
const ll MOD=1000000007LL;
#define out(a) cout<<fixed<<setprecision((a))


int main(){ 
	ll n,q,rn,bn;
	cin >> n >> q;
	rn = sqrt(n);
	bn = ceil((double)n/rn);
	vector<ll> a(n,2147483647LL),b(bn,2147483647LL);
	FOR(i,0,q){
		ll com,x,y,ans=2147483647LL;
		cin >> com >> x >> y;
		if(com){//find
			FOR(j,x,y+1){
				ans = min(ans,a[j]);
				if(j%rn==0 && (j+rn)<=y){
					ans = min(ans,b[j/rn]);
					j += rn-1;
				}
			}
			cout << ans << endl;
		}else{//update
			a[x] = y;
			ll ind = x/rn;
			b[ind] = 2147483647LL;
			FOR(j,ind*rn,(ind+1)*rn){
				b[ind] = min(b[ind],a[j]);
			}
		}
	}
}


Measured memory_bytes: 3584