akhauriyash/Code-Regression huggingface dataset:
#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 RFOR(i,a,b) for(int i=(a)-1;i>=(b);i--)
#define rrep(i,n) RFOR(i,n,0)

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

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

	string a;
	cin >> a;

	ll n = a.size();

	// a[i] != a[j]であるi,jの個数を数える
	// b[i][j]をj+1番目以降でアルファベットiが出てくる回数とすると
	// 各jについてb[i][j]のうちアルファベットiとa[j-1]が異なるものをたせばよい

	ll b[26][n+1];
	rep(i,26) rep(j,n+1) b[i][j] = 0;

	rep(i,n) b[a[i]-'a'][0]++;

	rep(i,n-1){
		rep(j,26) b[j][i+1] = (a[i]-'a' == j ? b[j][i]-1:b[j][i]);
	}

	ll ans = 1;
	rep(i,n-1){
		rep(j,26) if(j != a[i]-'a') ans += b[j][i+1];
	}

	cout << ans << endl;
}

Measured memory_bytes: 41236
#include <stdio.h>

int linearSearch(int a[],int n,int key){
	int i = 0;
	a[n] = key;
	while(a[i] != key)i++;
	return i != n;
}

int main(void) {
	int A[10000+1];
	int n;
	scanf("%d",&n);
	for(int i = 0; i < n; i++)scanf("%d",&A[i]);
	int q;
	int sum = 0;
	scanf("%d",&q);
	for(int i = 0;i < q; i++){
		int key;
		scanf("%d",&key);
		sum += linearSearch(A,n,key);
	}
	printf("%d\n",sum);
	return 0;
}



Measured memory_bytes: 2108
#include <iostream>
#include <algorithm>
using namespace std;
int g[26]={0},v[26]={0};
void SW(int A,int B){
	swap(g[A],g[B]);
	swap(v[A],v[B]);
}
int CH(int N){
	for(int i=1;i<=N;i++){
		v[i]+=v[i-1];
		if(v[i]>g[i])return 0;
	}
	return 1;
}
int main(){
	int n;
	while(cin>>n,n){
		for(int i=1;i<=n;i++)cin>>v[i]>>g[i];
		for(int i=1;i<=n+1;i++)for(int j=1;j<n;j++)if(g[j]>g[j+1])SW(j,j+1);
		cout<<(CH(n)?"Yes":"No")<<endl;
	}
	return 0;
}


Measured memory_bytes: 1152
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {


        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        ArrayList a = new ArrayList();
        long ans = 0;
        for(int i = 0;i<n;i++){
            a.add(sc.nextLong());
        }
        Collections.sort(a);
        Collections.reverse(a);
        if(n ==2){
            System.out.println(a.get(0));
            System.exit(0);
        }
        if(n %2 ==0 ){
            ans += (long) a.get(0);
            for(int i = 0;i<(n-2)/2;i++){
                ans += (long) a.get(i+1)*2;
            }
            System.out.println(ans);
            System.exit(0);
        }else {
            ans += (long) a.get(0);
            for(int i = 0;i<(n-3)/2;i++){
                ans += (long) a.get(i+1) *2;
            }
            ans += (long)a.get((n-1)/2);
            System.out.println(ans);
            System.exit(0);
        }




    }


}


Measured memory_bytes: 58196
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
const ll MOD = 1e9+7;
const ll inf = (LLONG_MAX>>2);
int main(){
  ios::sync_with_stdio(0);
  cin.tie(0);
  //cout << fixed;
  //cout.precision(40);
  ll m,d,c;
  cin >> m;
  ll ans = 0;
  deque<pair<ll,ll>> q;
  for(ll i = 0; i < m; ++i){
    cin >> d >> c;
    if(d == 0) ans += c;
    else{
      if(!q.empty() and q.back().first == d){
        q.back().second += c;
      }
      else q.emplace_back(d,c);
    }
  }
  while(!q.empty()){
    ll len = q.size();
    bool act = false;
    deque<pair<ll,ll>> q2;
    while(!q.empty()){
      auto p = q.front();
      q.pop_front();
      if(p.first*p.second >= 10){
        ll k = (10+p.first-1)/p.first;
        act = true;
        ans += p.second/k*k;
        q2.emplace_back((p.first*k)%10+1,p.second/k);
        if(p.second%k) q2.emplace_back(p.first,p.second%k);
      }
      else{
        ans += p.second-1;
        if(p.second > 1) act = true;
        q2.emplace_back(p.first*p.second,1);
      }
    }
    q.clear();
    for(auto& p : q2){
      if(!q.empty() and q.back().first == p.first){
        q.back().second += p.second;
      }
      else q.emplace_back(p);
    }
    if(q.size() == len and !act) break;
  }
  ll crt = q.front().first;
  q.pop_front();
  while(!q.empty()){
    auto p = q.front();
    q.pop_front();
    crt += p.first;
    ++ans;
    if(crt >= 10){
      ++ans;
      crt = (crt%10)+1;
    }
  }
  cout << ans;
  return 0;
}


Measured memory_bytes: 10328
#include<bits/stdc++.h>
using namespace std;
int main() {
	int N, A, B; cin >> N >> A >> B;
	int res = 0;
	for (int i = 1; i <= N; i++)
	{
		int c = i, tmp = 0;
		while (c)
		{
			tmp += c % 10;
			c /= 10;
		}
		if(tmp >= A && tmp <= B) res += i;
	}
	cout << res << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include "bits/stdc++.h"
using namespace std;
#define print(x) cout<<x<<endl;
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define REP(i,a) for(ll i=0;i<a;i++)
#define jkl ll debug = 0;
#define RREP(i,a) for(ll i=a-1;i>=0;i--)
#define rrep(i,a,b) for(ll i=a-1;i>=b;i--)
#define printall(n,array) {for(ll i=0;i<n;i++){cout<<array[i]<<" ";}cout<<endl;}
#define U() cout<<endl;
#define mp make_pair
typedef long long ll;
typedef pair<ll, ll> Pi;
typedef pair<ll, Pi> V;
typedef vector<ll> VE;
const ll mod = 1e9 + 7; //10^9+7

int main(){
    ll h, w, k;
    cin >> h >> w >> k;
    ll dp[102][10];
    REP(i, 102)REP(j, 10)dp[i][j] = 0;
    dp[0][0] = 1;
    REP(i, h){
        REP(l, w){
            ll x = 0, y = 0, z = 0;
            REP(j, 1<<(w-1)){
                bool f = false;
                bool fl = false;
                REP(k, w-1){
                    if((1<<k)&j){
                        if(f){fl = true; break;}
                        f = true;
                    }else{
                        f = false;
                     }
                }
                if(fl)continue;
                if(l>=1 && (j&(1<<(l-1))))x++;
                else if(l<=w-2 && (j&(1<<(l))))z++;
                else y++;
            }
            dp[i+1][l-1] += (dp[i][l] * x) % mod;
            dp[i+1][l-1] %= mod;
            dp[i+1][l] += (dp[i][l] * y) % mod;
            dp[i+1][l] %= mod;
            dp[i+1][l+1] += (dp[i][l] * z) % mod;
            dp[i+1][l+1] %= mod;
        }
    }
    print(dp[h][k-1]);
}

Measured memory_bytes: 256
#import<bits/stdc++.h>
using namespace std;
int a,b,c,i,j,k,m,n,s,w[105];
main()
{
scanf("%d",&n);
for(;i<n;s+=w[i++])scanf("%d",w+i);m=s;
for(i=0;i<n;i++)
k+=w[i],a=k*2<s?s-2*k:k*2-s,m=a<m?a:m;
printf("%d",m);
}

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

#define int long long
#define ll long long
#define pb push_back
#define mp make_pair
#define f(i,a,n) for(int i=a ; i<(int)n ; i++)
#define rf(i,n,a) for(int i=n ; i>=a ; i--)
#define F first
#define S second
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()
#define fast ios:: sync_with_stdio(false),cin.tie(nullptr);

typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef pair<pii,int> ppi;
typedef vector<pii> vpi;

const int inf = 1e9;
const int inf64 = 1e18;
const int MOD = inf + 7;
const int N = 1e5 + 5;
void solve(){
   int x;
   cin >> x;
   for(int i=-1100 ; i<=1100 ; i++) {
      for(int j=-1100 ; j<=1100 ; j++) {
         if(i*i*i*i*i - j*j*j*j*j == x) {
            cout <<  i << " " << j ;
            return;
         }
      }
   }
}

int32_t main(){
   fast;
   int t = 1;
//   cin >> t;
   while(t--)  solve();   
}


Measured memory_bytes: 3652
using System;
class Program
{
    static void Main(string[] args)
    {
        string[] s = Console.ReadLine().Split(' ');
        int A = int.Parse(s[0]);
        int B = int.Parse(s[1]);
        if (A <= 5)
            Console.WriteLine(0);
        else if (A <= 12)
            Console.WriteLine(B / 2);
        else
            Console.WriteLine(B);
    }
}


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

int main() {
    int N, K;
    cin >> N >> K;
    int ans = 0;
    rep(i, N) {
        int x;
        cin >> x;
        if (x - 0 <= K - x) {
            ans += 2*(x - 0);
        } else {
            ans += 2*(K - x);
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
    int k, s, ans = 0;
    cin >> k >> s;
    for(int i = 0; i <= k; i++){
        for(int j = 0; j <= k; j++){
            if(s - i - j > k || s - i - j < 0) continue;
            ans += 1;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
//
//  main.cpp
//  selection_sort
//
//  Created by ???????????? on 2017/10/02.
//  Copyright ?? 2017 ????????????. All rights reserved.
//

#include <iostream>
#include<stdio.h>

using namespace std;

int N = 1000;

void swap(int* a, int* b){
    int temp = *a;
    *a = *b;
    *b = temp;
}

int main(int argc, const char * argv[]) {
    
    int n, i, j, minj, sw;
    int A[N];
    
    //get n and A
    scanf("%d", &n);
    for ( i = 0; i < n; i++ ) scanf("%d", &A[i]);
    
    sw = 0;
    for(i = 0; i < n-1; i++){
        minj = i;
        for(j = i+1; j < n; j++){
            if(A[minj] > A[j]){
                minj = j;
            }
        }
        if(i!=minj){
            sw++;
            swap(&A[i], &A[minj]);
        }
    }
    
    for(i = 0; i < n; i++){
        if(i){cout<<" ";}
        cout << A[i];
    }
    cout << endl;
    cout << sw << endl;
    return 0;
}

Measured memory_bytes: 3244
n = int(input())
arr = list(map(int, input().split()))

def insertionSort(arr, n):
    print(*arr)
    for i in range(1, n):
        v = arr[i]
        j = i - 1
        while j >= 0 and arr[j] > v:
            arr[j + 1] = arr[j]
            j -= 1
        arr[j + 1] = v
        print(*arr)


insertionSort(arr, n)



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

#define int long long
#define rep(i, a, n) for (int i = a; i < n; i++)
#define pb push_back
#define eb emplace_back
#define dump(x) cout << #x << " = " << (x) << endl
#define chk() cout << "now" << endl;
#define ALL(x) (x).begin(), (x).end()
#define SORT(c) sort((c).begin(), (c).end())
#define SORTG(c) sort(ALL(c), greater<int>());
#define fi first
#define se second
int INF = 1e9 + 7;

typedef pair<int, int> P;
typedef vector<int> vi;

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

int dp[100001] = {};  // dp[i] 足場iに行くまでに支払うコストの最小値
int n;
vi h;

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

  cin >> n;
  rep(i, 0, n) {
    int H;
    cin >> H;
    h.pb(H);
  }

  dp[1] = 0;
  dp[2] = abs(h[1] - h[0]);
  rep(i, 3, n + 1) {
    dp[i] = min(dp[i - 1] + abs(h[i - 1] - h[i - 2]),
                dp[i - 2] + abs(h[i - 1] - h[i - 3]));
  }
  cout << dp[n] << endl;
  return 0;
}


Measured memory_bytes: 1908
import std.stdio;
import std.array;
import std.conv;
import std.algorithm;
void main() {
	int[] counter = new int[100];
	string s;
	while( (s=readln()).length != 0 ){
		string[] input = split(s);
		int a = to!int(input[0]);
		counter[a-1]++;
	}
	auto l = reduce!(max)(counter);
	for(int i=0;i<100;i++){
		if(counter[i] == l) writefln("%d",i+1);
	}
}

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

def get_H(cx, cy):
   for x, y, h in z:
      if h > 0:
         return abs(x - cx) + abs(y - cy) + h

def check_H(cx, cy, H):
   for x, y, h in z:
      if h != max(H - abs(x - cx) - abs(y - cy), 0):
         return False
   return True


for cx in range(101):
   for cy in range(101):
      H = get_H(cx, cy)
      if check_H(cx, cy, H):
         print(cx, cy, H)
         exit()


Measured memory_bytes: 3064
import java.util.LinkedList;
import java.util.List;
import java.util.ListIterator;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		new Main().mainrun();
	}

	Scanner scan;

	int N,K;
	private List<Integer> Digits;


	private void mainrun() {
		scan = new Scanner(System.in);

		N = scan.nextInt();
		K = scan.nextInt();
		int max = -1;
		Digits = new LinkedList<>();

		for(int i = 0;i < N;i++) {
			int num = scan.nextInt();
			Digits.add(num);
			max = Math.max(max, num);
		}

		ListIterator<Integer> li;
		li = Digits.listIterator();

		if(N - K ==1) {
			System.out.println(max);
			return ;
		}

		while(K != 0) {
			int num1 = li.next();
			int num2 = li.next();

			li.previous();
			
			if(num1 < num2) {
				li.previous();
				li.remove();

				if(li.nextIndex() >= 1) {
					li.previous();
				}
				K--;
			}

			if(li.nextIndex() == Digits.size() -1) {
				while(K != 0) {
					li.remove();
					li.previous();
					K--;
				}
			}
		}

		Digits.forEach(System.out::print);

		System.out.println();

		scan.close();
	}

}



Measured memory_bytes: 111328
#include "bits/stdc++.h"
#define int long long
#define endl '\n'
using namespace std;
 
typedef long long ll;
typedef long double ld;
#define db(x) cerr << #x << ": " << x << '\n';
#define read(a) int a; cin >> a;
#define reads(s) string s; cin >> s;
#define readb(a, b) int a, b; cin >> a >> b;
#define readc(a, b, c) int a, b, c; cin >> a >> b >> c;
#define readarr(a, n) int a[(n) + 1] = {}; FOR(i, 1, (n)) {cin >> a[i];}
#define readmat(a, n, m) int a[n + 1][m + 1] = {}; FOR(i, 1, n) {FOR(j, 1, m) cin >> a[i][j];}

#define print(a) cout << a << endl;
#define printarr(a, n) FOR (i, 1, n) cout << a[i] << " "; cout << endl;
#define printv(v) for (int i: v) cout << i << " "; cout << endl;
#define printmat(a, n, m) FOR (i, 1, n) {FOR (j, 1, m) cout << a[i][j] << " "; cout << endl;}
#define all(v) v.begin(), v.end()
#define sz(v) (int)(v.size())
#define rz(v, n) v.resize((n) + 1);
#define pb push_back
#define fi first
#define se second
#define vi vector <int>
#define pi pair <int, int>
#define vpi vector <pi>
#define vvi vector <vi>
#define setprec cout << fixed << showpoint << setprecision(20);
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define FORD(i, a, b) for (int i = (a); i >= (b); i--)
const ll inf = 1e18;
const ll mod = 1e9 + 7;
const ll N = 2e5 + 1;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

long long binpow(long long a, long long b, long long m = mod) {
    a %= m;
    long long res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a % m;
        a = a * a % m;
        b >>= 1;
    }
    return res;
}
 
signed main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	
	read(n);
	int x = binpow(10, n) - 2*binpow(9, n) + binpow(8, n);
    x %= mod;
    cout << (x + mod*5) % mod;
}



















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

int main() {
	// your code goes here
	int n;
	cin>>n;
	string arr[n];
	set<string>s;
	for(int i=0;i<n;i++){
		cin>>arr[i];
		s.insert(arr[i]);
	}
	cout<<s.size();
	return 0;
}

Measured memory_bytes: 25480
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <cfloat>
#include <stack>
#include <queue>
#include <vector>
#include <string>
#include <iostream>
#include <set>
#include <map>
#include <time.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


int main(){

	int N,L;
	scanf("%d %d",&N,&L);

	int loc[N],move[N];

	for(int i = 0; i < N; i++)scanf("%d",&loc[i]);
	for(int i = 0; i < N; i++)scanf("%d",&move[i]);

	reverse(loc,loc+N);
	reverse(move,move+N);

	ll pre[L],current[L];

	for(int i = 0; i < L; i++)pre[i] = 0;

	for(int i = 0; loc[0]+i*move[0] <= L-1; i++){
		pre[loc[0]+i*move[0]] = 1;
		if(move[0] == 0)break;
	}

	for(int i = 1; i <= L-1; i++){
		pre[i] += pre[i-1];
	}

	if(N == 1){
		printf("%lld\n",pre[L-1]);
		return 0;
	}

	int pos,right = L-1;

	for(int rabbit = 1; rabbit <= N-1; rabbit++){
		for(int i = 0; i <= L-1; i++)current[i] = 0;

		if(move[rabbit] == 0){
			current[loc[rabbit]] = pre[right]-pre[loc[rabbit]];
		}else{

			for(int i = 0; (pos = loc[rabbit]+i*move[rabbit]) < L-1; i++){
				current[pos] = pre[right]-pre[pos];
				if(current[pos] < 0)current[pos] += MOD;
			}
		}

		for(int i = 0; i <= L-1; i++)pre[i] = current[i];
		for(int i = 1; i <= L-1; i++){
			pre[i] += pre[i-1];
			pre[i] %= MOD;
		}
	}

	ll ans = 0;
	for(int i = 0; i < L; i++){
		ans += current[i];
		ans %= MOD;
	}

	printf("%lld\n",ans%MOD);

	return 0;
}

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

#define pb push_back
#define eb emplace_back

typedef long long ll;
typedef unsigned long long ull;

using namespace std;

ll bp(ll a, ll d, ll m) {
    if (d == 0) {
        return 1;
    }
    auto h = bp(a, d / 2, m);
    auto hh = (h * h) % m;
    if (d % 2) {
        hh = (hh * a) % m;
    }
    return hh;
}


void oneCase() {
    double r;
    cin >> r;
    cout << setprecision(10) <<2 * r * M_PI;
}

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

    int t = 1;
//    cin >> t;
    while (t--) {
       oneCase();
    }

    return 0;
}


Measured memory_bytes: 3784
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <vector>
#include <queue>
#include <algorithm>

using namespace std;

//typedef pair<int,int> P;



int main(){
	int N;
	char s[300001];

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

	int e[300001];
	int w[300001];
	e[0] = 0;
	w[0] = 0;

	for(int i=0;i<N;i++){
		e[i+1] = e[i];
		w[i+1] = w[i];
		if(s[i]=='E')  e[i+1]++;
		if(s[i]=='W')  w[i+1]++;
	}

	int min = N;
	for(int i=0;i<N;i++){
		int sum = 0;
		sum += w[i];
		sum += e[N]-e[i+1];

		if(min > sum) min = sum;
	}

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

	return 0;
}


Measured memory_bytes: 2944
#include <bits/stdc++.h>
#include <stdlib.h>
#include <string>
#include <iostream>
#include <algorithm>
#include <map>
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef pair<int, int> P;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()

ll ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}

int main(){
  string N; cin >> N;
  ll n = N.size();
  ll K; cin >> K;
  ll dp[105][4][2];
  rep(i, 105)rep(j, 4)rep(k, 2) dp[i][j][k] = 0;
  dp[0][0][0] = 1;
  rep(i, n)rep(j, 4)rep(k, 2){
    ll nd = ctoi(N[i]);
    rep(d, 10){//dは次に追加する数
      ll ni = i +1, nj = j, nk = k;
      if (d != 0) nj++;//dが0でないならjを1増やす
      if (nj > K) continue;
      if (k == 0){//smaller flagがたっていないとき
        if (d > nd) continue;//dの値が今の桁の数より大きいならばなにもしない
        if (d < nd) nk = 1;//dの値が今の桁の数未満ならばsmaller flagを立てる
      }
      dp[ni][nj][nk] += dp[i][j][k];
    }
  }
  ll ans = dp[n][K][0] + dp[n][K][1];
  cout << ans << endl;
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define pii pair<int,int>
#define pll pair<ll, ll>
#define pil pair<int,ll>
#define pli pair<ll,int>
#define ppi pair<pii,int>
#define pip pair<int,pii>
#define pdd pair<double, double>
#define f first
#define s second
#define MOD 1000000007
#define mkp make_pair
#define M_PI 3.14159265358979323846
#define FOR(i,l,r) for (int i=l;i<=r;i++)
#define LOR(i,l,r) for (ll i=l;i<=r;i++)
#define FORD(i,r,l) for (int i=r;i>=l;i--)
#define LORD(i,r,l) for (ll i=r;i>=l;i--)
#define INF 1000000000
#define CL(x) memset(x,0,sizeof(x))
#define DEB(x) cout << #x << " : " << x << '\n'
#define ALL(x) x.begin(), x.end()
#define SZ(x) x.size()
#define UI(x) (int)(x-'A')
#define LI(x) (int)(x-'a')
typedef long long ll;

ll A,B;

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

    cin>>A>>B;
    cout<<max( (A+B), max(A-B, A*B) )<<'\n';

    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
#define ll long long int
 
#define REP(i, n) for(int i = 0; i < (n); i++)
#define SREP(i, s) for(int i = 0; i < (s.size()); i++)
#define SORT(v, n) sort(v, v+n);
#define GSORT(v, n) sort(v, v+n, greater<int>());
#define VSORT(v) sort(v.begin(),v.end());
#define VGSORT(v) sort(v.begin(),v.end(),greater<int>());
#define REV(a) reverse(begin(a),end(a));

int main(){
	ios::sync_with_stdio(false);cin.tie(0);
////////////////////////////////////////////	
	int n;
	cin >> n;
	int a[n];
	REP(i,n) cin >> a[i];
	bool bb=1;
	int ans=0;
	int now=1;
	while(bb){
		now=a[now-1];
		ans++;
		if(now==2) bb=0;
		if(ans>100001) break;
	}
	cout << (bb ? -1 : ans) << endl;
	
//////////////////////////////////////////////
}


Measured memory_bytes: 640
#include <algorithm>
#include <bitset>
#include <cctype>
#include <complex>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;

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();}
template<class T> inline T sqr(T x) {return x*x;}

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

#define all(a)  (a).begin(),(a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define pb push_back
#define mp make_pair
#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 range(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  range(i,0,n)
#define clr(a,b) memset((a), (b) ,sizeof(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

const double eps = 1e-10;
const double pi  = acos(-1.0);
const ll INF =1LL << 62;
const int inf =1 << 29;

int main(void){
	string a;
	cin >> a;
	int n=a.size();
	rep(i,n) a[i]=((a[i]-'A')+23)%26+'A';
	cout << a << endl;
	return 0;
}

Measured memory_bytes: 1180
#include<bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
const long long mod = 1e9+7;
const int dx[4] = {0,1,0,-1};
const int dy[4] = {1,0,-1,0};
//////////////////////////////////


int main() {
    int n; cin >> n;
    vector<int> x(n);
    vector<int> y(n);
    for(int i=0; i<n; i++) cin >> x[i] >> y[i];
    if(n == 1) {
        cout << 1 << endl;
        return 0;
    }
    map<pair<int, int>, int> mp;
    for(int i=0; i<n; i++) {
        for(int j=0; j<n; j++) {
            if(i == j) continue;
            int dx = x[i]-x[j];
            int dy = y[i]-y[j];
            mp[{dx, dy}]++;
        }
    }

    int ans = 1e9;
    for(auto i=mp.begin(); i!=mp.end(); i++) {
        //cerr << i->first.first << " " << i->first.second << " " << i->second << endl;
        ans = min(ans, n - i->second);
    }
    cout << ans << endl;

    return 0;
}




// EOF


Measured memory_bytes: 384
#include<bits/stdc++.h>
 
#define lol long long
#define gcd(x,y) __gcd(x,y)
#define mt make_tuple
#define mp make_pair
#define fi first
#define se second
#define fixed(x) fixed<<setprecision(x)
using namespace std;
using pii=pair<int,int>;
template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }
template <class A> inline lol abs(A &a) { return (a < 0 ? -a : a); }
bool inLine(int x,int y,int mx,int my){return (x>=0&&y>=0&&x<mx&&y<my);}
const lol inf=(1LL<<62);
const int MOD=(1e9)+7;
const int mod=998244353;
const int dx[]={1,0,-1,0,1,1,-1,-1};
const int dy[]={0,1,0,-1,1,-1,1,-1};

signed main(){
  int n,k;
  cin >>n>>k;
  vector<int> l(k),r(k);
  for(int i=0;i<k;i++) cin >>l[i]>>r[i];
  vector<lol> ans(n+10,0);
  ans[0]=0;
  lol sum=1;
  for(int i=1;i<n;i++){
    sum+=ans[i];
    sum%=mod;
    ans[i]=sum;
    for(int j=0;j<k;j++){
      if(i+l[j]<=n) ans[i+l[j]]+=ans[i],ans[i+l[j]]%=mod;
      if(i+r[j]+1<=n) ans[i+r[j]+1]-=ans[i],ans[i+r[j]+1]%=mod;
    }
  }
  cout <<((ans[n]%mod)+mod)%mod<<'\n';
  return(0);
}

Measured memory_bytes: 4832
#include <stdio.h>
#include <stdlib.h>
#include <math.h>


int main(void)
{
    int n;
    scanf("%d", &n);
    int l[n];
    for (int i=0; i < n; i++){
        scanf("%d", &l[i]);
    }

    int max = 0;
    for (int i=0; i < n; i++){
        if (max < l[i]) max = l[i];
    }

    int sum = 0;
    for (int i=0; i < n; i++){
        sum += l[i];
    }

    if (2*max < sum){
        printf("Yes\n");
    }
    else {
        printf("No\n");
    }


    

    return 0;
} 



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

int main(){
	int w[10], k[10];
	for(int i=0; i<10; ++i) scanf(" %d", &w[i]);
	for(int i=0; i<10; ++i) scanf(" %d", &k[i]);
	
	sort(w, w+10, greater<int>());
	sort(k, k+10, greater<int>());
	
	int p=0, q=0;
	for(int i=0; i<3; ++i) p+=w[i];
	for(int i=0; i<3; ++i) q+=k[i];
	
	printf("%d %d\n", p, q);
	return 0;
}

Measured memory_bytes: 1204
#include <bits/stdc++.h>
using namespace std;
#define rep(i, l, r) for(int i=(l); i<(r); ++i)
typedef long long ll;
typedef unsigned long long ull;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
 
/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
    sizeは(int)とキャストしよう
    ごちゃごちゃ場合分けを考える前に全探索は考えましたか？
    詰まった時に、別の分野の問題として考え直す（これdpでは？、グラフとしてみればいいのでは？）
    多くの問題はパターンマッチだが、パターンに落とし込むまでが難しく、そのための訓練としてわからない問題をあれこれ色々な角度から考察してみるのではないか
    cin.tie(0);
    ios::sync_with_stdio(false);<- これら、printfとかと併用しない方が良さそう

*/

const ll mod = 1e9+7;

void chmod(ll &M){
    if(M >= mod) M %= mod;
    else if(M < 0){
        M += (abs(M)/mod + 1)*mod;
        M %= mod;
    }
}

int getl(int i, int N) { return i==0? N-1:i-1; };
int getr(int i, int N) { return i==N-1? 0:i+1; };

/* <--------------------------------------------> */

const int inf=1<<29;

vector<vector<int>> d(10, vector<int>(10, inf));

void floyd(){
    rep(k, 0, 10){
        rep(i, 0, 10){
            if(d[i][k]==inf) continue;
            rep(j, 0, 10){
                if(d[j][k]==inf) continue;
                chmin(d[i][j], d[i][k]+d[k][j]);
            }
        }
    }
}

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

    int n, z, w; cin >> n >> z >> w;
    vector<int> a(n);
    rep(i, 0, n) cin >> a[i];
    if(n==1) cout << abs(a[n-1]-w) << endl;
    else cout << max(abs(a[n-1]-w), abs(a[n-2]-a[n-1])) << endl;
    
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		int d = sc.nextInt();
		sc.close();
		int diffAB = (a>b)?a-b:b-a;
		int diffBC = (b>c)?b-c:c-b;
		int diffAC = (a>c)?a-c:c-a;
		System.out.println(((diffAB<=d && diffBC<=d) || diffAC<=d)?"Yes":"No");
	}
}

Measured memory_bytes: 20820
#include <algorithm>
#include <cassert>
#include <cmath>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;

template <typename T> inline constexpr bool chmin(T &a, T b) {
  if (b < a) {
    a = b;
    return true;
  }
  return false;
}
template <typename T> inline constexpr bool chmax(T &a, T b) {
  if (b > a) {
    a = b;
    return true;
  }
  return false;
}
template <typename ite>
void print_ite(ite start, ite end, char sp = ' ', char en = '\n') {
  for (auto i = start; i != end; i++)
    cout << *i << sp;
  cout << en;
}
template <typename ite> void scan_ite(ite start, ite end) {
  for (auto i = start; i != end; i++)
    cin >> (*i);
}
inline void Yes(bool condition) { cout << (condition ? "Yes\n" : "No\n"); }

int main() {
  int n;
  cin >> n;
  unordered_set<string> s;
  for (int i = 0; i < n; i++) {
    string st;
    cin >> st;
    s.insert(st);
  }
  cout << s.size() << endl;
}


Measured memory_bytes: 13828
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <tuple>
#include <algorithm>
#include <map>
using namespace std;
#define REP(n) for(int i=0;i<n;i++)

#define INF_32 0x7fffffff;

long long get_753(long long n,long long N) {
	long long ret = 0;
	long long tmp = n;
	int dec[10] = { 0 };
	if (N < n) {
		return 0;
	}
	else {
		while (tmp>0) {
			dec[tmp % 10] = 1;
			tmp /= 10;
		}
		if (dec[3] && dec[5] && dec[7]) {
			ret += 1;
		}
	}
	ret += get_753(n*10+3,N);
	ret += get_753(n * 10 + 5,N);
	ret += get_753(n * 10 + 7,N);
	return ret;
}

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

	int ans = get_753(0,N);
	
	

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

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        String t = sc.next();
        int a = Integer.parseInt(sc.next());
        int b = Integer.parseInt(sc.next());
        String u = sc.next();
        if (s.equals(u)) {
            a--;
        }
        if (t.equals(u)) {
            b--;
        }
        System.out.println(String.format("%s %s", a, b));
        sc.close();
    }
}


Measured memory_bytes: 35664
#include <bits/stdc++.h>
#include <iomanip>
#include <math.h>
#define ll long long
#define lld double
#define vi vector<int>
#define pii pair<int,int>
#define piii pair<pii, ll>
#define pb push_back
#define mp make_pair
#define fs first
#define sc second
#define ppb pop_back
#define d0(x) cout<<x<<" "
#define d1(x) cout<<(x)<<"\n"
#define d2(x,y) cout<<x<<" "<<y<<"\n"
#define d3(x,y,z) cout<<x<<" "<<y<<" "<<z<<endl
#define d4(x,y,z,w) cout<<x<<" "<<y<<" "<<z<<" "<<w<<endl
#define d5(x,y,z,w,s) cout<<x<<" "<<y<<" "<<z<<" "<<w<<" "<<s<<endl
using namespace std;
const ll mod = 998244353;

ll dp[3001][3001];ll dp1[3001][3001];int N,S;int a[3001];
void solve(int t)
{
    cin>>N>>S;
    for(int i=1;i<=S;i++)
        for(int j=0;j<=N;j++)
        {
            dp[j][i]=0;
            dp1[j][i]=0;
        }
    //dp[0][0]=0;
    for(int i=1;i<=N;i++)
            cin>>a[i];

    for(int i=1;i<=N;i++)
    {
        for(int j=0;j<=S-a[i];j++)
        {
            dp[i][j+a[i]] = (dp[i][j+a[i]]+dp1[i-1][j])%mod;
        }
        dp[i][a[i]] = (dp[i][a[i]]+i)%mod;
        for(int j=0;j<=S;j++)
            dp1[i][j] = (dp[i][j]+dp1[i-1][j])%mod;
    }
    ll ans = 0;
    for(int i=1;i<=N;i++)
    {
        ans = (ans+dp[i][S]*(N-i+1))%mod;
    }
    cout<<ans<<"\n";


}


int main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int T=1;
    //cin>>T;
    for(int t=1;t<=T;t++)
        solve(t);
}


Measured memory_bytes: 141056
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

using pi = pair<int,int>;

int main(){
    int w,h,t,p;
    while(cin >>w >>h >>t >>p,w){
        vector<int> dir(t),c(t);
        rep(i,t) cin >>dir[i] >>c[i];
        vector<pi> hole(p);
        rep(i,p){
            int x,y;
            cin >>x >>y;
            hole[i] = {y,x};
        }

        vector<vector<pi>> a(h,vector<pi>(w));
        rep(i,h)rep(j,w) a[i][j] = {i,j};

        auto F = [&](int d, int z){
            if(d==1){
                int mx = w;
                rep(i,h)rep(j,w){
                    if(a[i][j].se < z) a[i][j].se = z + (z-1-a[i][j].se);
                    mx = min(mx, a[i][j].se);
                }
                rep(i,h)rep(j,w) a[i][j].se -= mx;
            }
            else{
                int my = h;
                rep(i,h)rep(j,w){
                    if(a[i][j].fi < z) a[i][j].fi = z + (z-1-a[i][j].fi);
                    my = min(my, a[i][j].fi);
                }
                rep(i,h)rep(j,w) a[i][j].fi -= my;
            }
        };

        rep(i,t) F(dir[i],c[i]);

        rep(k,p){
            int ans = 0;
            rep(i,h)rep(j,w)if(a[i][j] == hole[k]) ++ans;
            cout << ans << endl;
        }
    }
    return 0;
}



Measured memory_bytes: 3024
#include "bits/stdc++.h"
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

using ll = long long;

const int nax = 405;
const ll INF = 1e18L + 5; // 10^18+5
ll dp[nax][nax];
// dp[i][j] - the minimum total cost of combining interval [i,j] into one vertex

int main() {
    int n;
    scanf("%d", &n);
    vector<int> a(n);
    for(int& x : a) {
        scanf("%d", &x);
    }
    auto sum = [&](int L, int R) {
        ll s = 0;
        for(int i = L; i <= R; ++i) {
            s += a[i];
        }
        return s;
    };
    for(int L = n - 1; L >= 0; --L) {
        for(int R = L; R < n; ++R) {
            if(L == R) {
                dp[L][R] = 0;
            }
            else {
                dp[L][R] = INF;
                ll s = sum(L, R);
                for(int i = L; i <= R - 1; ++i) {
                    dp[L][R] = min(dp[L][R], dp[L][i] + dp[i+1][R] + s);
                }
            }
        }
    }
    
    printf("%lld\n", dp[0][n-1]);
}

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

typedef long long  ll;

ll MOD = 1000000007;
ll INF = 100000000;
double PI = 3.1415926535;

template<typename T>
void remove(std::vector<T>& vector, unsigned int index)
{
    vector.erase(vector.begin() + index);
}

using Graph = vector<vector<pair<ll,ll>>>;

int main(){
  string S;cin >> S;
  cout << count(S.begin(),S.end(),'1') << endl;
}

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

int main(){
  int n,p[11],max = 0,maxpoint;
  cin >> n;
  for(int i = 0; i < n; i++){
    cin >> p[i];
    if(max < p[i]){
      max = p[i];
      maxpoint = i;
    }
  }

  int sum = 0;
  for(int i = 0; i < n; i++){
    if(i == maxpoint)sum += p[i]/2;
    else sum += p[i];
  }
  cout << sum << endl;
  return 0;
}

Measured memory_bytes: 256
#if __has_include("debug.h")
    #include "debug.h"
#else  
#include <bits/stdc++.h>
using namespace std;
#define d(...) 2;
#endif

#define int long long int
#define ld long double

#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define endl "\n"      

#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define ff first
#define ss second
#define eps 1e-10
#define PI acos(-1LL)

#define gcd(a,b)            __gcd((a),(b))
#define lcm(a,b)            ((a*b)/gcd(a,b))

void solve();

int32_t main()
{
    #ifdef DEBUG
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
    #endif 

    fast
    
    int t = 1;
	// cin>>t;
	
	while(t--)
	    solve();
	return 0;  
}

void solve()
{
	int i,j;
	int n;
	cin>>n;


	vector<int>a(n);

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

	int now=1,cnt=0;

	for(i=0;i<n;i++)
	{
		if(a[i]==now)
		{
			cnt++;
			now++;
		}
	}
	if(cnt==0)
	{
		cout<<-1<<endl;
	}
	else
	{
		cout<<n-cnt<<endl;
	}

}

Measured memory_bytes: 4776
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define rep(i,m,n) for(int i=(int)(m);i<(int)(n);++i)
#define rREP(i,m,n) for(int (i)=(n)-1; (i)>=(m);--(i))
#define all(x) (x).begin(),(x).end()
#define out(y,x,h,w) (y)<0||(x)<0||(y)>=(h)||(x)>=(w)
constexpr int INF = 1000000001;
constexpr ll mod = 1000000007;
constexpr double PI = 3.1415926535897932;

template<class T>inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
template<class T>inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}
inline void init() {
	cin.tie(nullptr); cout.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

int main() {
	init();

	string s, t; cin >> s >> t;
	map<char, int>a, b;
	rep(i, 0, s.size()) {
		a[s[i]]++;
		b[t[i]]++;
	}
	map<int, int>c, d;
	for (auto p : a) {
		c[p.second]++;
	}
	for (auto p : b) {
		d[p.second]++;
	}
	if (c.size() != d.size()) {
		puts("No");
		return 0;
	}
	bool is = true;
	for (auto p : c) {
		if (d.count(p.first)) {
			if (p.second != d[p.first]) {
				is = false;
			}
		}
		else {
			is = false;
		}
	}
	cout << (is ? "Yes" : "No") << "\n";

	return 0;
}

Measured memory_bytes: 916
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define rep2(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
using namespace std;
using ll = long long;
template<typename ll_t,ll_t mod>
class basic_modint{
public:
    ll_t x_;
    basic_modint(ll_t x=0):x_((x%mod+mod)%mod){}
    basic_modint& operator+=(const basic_modint a)       { if((x_+=     a.x_)>=mod)x_-=mod; return *this; }
    basic_modint& operator-=(const basic_modint a)       { if((x_+= mod-a.x_)>=mod)x_-=mod; return *this; }
    basic_modint& operator*=(const basic_modint a)       { (x_*=a.x_)%=mod; return *this; }
    basic_modint  operator+ (const basic_modint a) const { basic_modint res(*this); return res+=a; }
    basic_modint  operator- (const basic_modint a) const { basic_modint res(*this); return res-=a; }
    basic_modint  operator* (const basic_modint a) const { basic_modint res(*this); return res*=a; }
    basic_modint  pow(ll_t t) const { if(t==0)return 1; basic_modint a = pow(t>>1); a*=a; if(t%2==1)a*=(*this); return a; }
    basic_modint  inv() const { return pow(mod-2); }
    basic_modint& operator/=(const basic_modint a)       { return (*this) *= a.inv(); }
    basic_modint  operator/ (const basic_modint a) const { basic_modint res(*this); return res/=a; }
    friend istream& operator>>(istream& ist, basic_modint& a) { ist>>a.x_; return ist; }
    friend ostream& operator<<(ostream& ost, basic_modint& a) { ost<<a.x_; return ost; }
    bool operator==(const basic_modint a){return x_==a.x_; }
    bool operator!=(const basic_modint a){return x_!=a.x_; }
};
using mint = basic_modint<ll,ll(1e9+7)>;
int main(){
    int n;
    string s;
    cin >> n >> s;
    if(s[0]!=s[2*n-1] || s[0]=='W'){
        cout << 0 << endl;
        return 0;
    }
    string d;
    d.push_back('L');
    rep2(i,1,2*n){
        if((d.back()=='L')==(s[i]==s[i-1]))d.push_back('R');
        else d.push_back('L');
    }
    vector<mint> l(2*n,0),r(2*n,0);
    l[0]=1;
    rep2(i,1,2*n){
        if(d[i]=='L'){
            l[i]=l[i-1]+1;
            r[i]=r[i-1];
        }else{
            l[i]=l[i-1];
            r[i]=r[i-1]+1;
        }
    }
    if(l[2*n-1]!=r[2*n-1]){
        cout << 0 << endl;
        return 0;
    }
    mint ans=1;
    rep2(i,1,2*n){
        if(d[i]=='R'){
            ans*=(l[i-1]-r[i-1]);
        }
    }
    rep2(i,1,1+n)ans*=i;
    cout << ans << endl;
    return 0;
}

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

int main() {
  int n, x, y;
  cin >> n >> x >> y;

  vector<int> sum(n+1);
  for (int k = 1; k < n; k++) {
    vector<int> dp(n+1);
    for (int i = k+1; i < n+1; i++) {
      if (k > y) {
        dp.at(i) = i - k;
      }
      else if (k > x) {
        if (i > y) {
          dp.at(i) = dp.at(y) + i - y;
        }
        else {
          dp.at(i) = min(i - k, k - x + 1 + y - i);
        }
      }
      else {
        if (i > y) {
          dp.at(i) = i - k - (y - x - 1);
        }
        else if (i > x) {
          dp.at(i) = min(i - k, y - k + 1 - (i - x));
        }
        else {
          dp.at(i) = i - k;
        }
      }
    }
    //cout << k;
    rep(i, n+1) {
      //cout << dp.at(i);
      sum.at(dp.at(i))++;
    }
    //cout << endl;
  }
  sum.at(0) = 0;

  for (int k = 1; k < n; k++) {
    cout << sum.at(k) << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int MAX=2*1e5;
vector<int> link(MAX+1), sz(MAX+1, 1);
int find(int a){
	while(a!=link[a]) a=link[a];
	return a;
}
bool unite(int a, int b){
	a=find(a);
	b=find(b);
	if(a==b) return false;
	if(sz[a]<sz[b]) swap(a, b);
	link[b]=a;
	sz[a]+=sz[b];
	sz[b]=0;
	return true;
}
int main(){
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	int n, m;
	cin >> n >> m;
	for(int i=1; i<=n; i++) link[i]=i;
	while(m--){
		int u, v;
		cin >> u >> v;
		unite(u, v);
	}
	cout << *max_element(sz.begin(), sz.end());
}

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

struct st{
    int c, id;
}a[(int)1e5+1];

bool cmp(st a, st b){
    return a.c<b.c;
}

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

    int n;
    cin>>n;

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

        a[i].id = i;
    }

    sort(a,a+n,cmp);

    cout<<a[0].id+1;

    for(int i=1;i<n;i++)
        cout<<' '<<a[i].id+1;
}


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

int main() {
  string N;
  cin >> N;
  
  if (N[0] == N[1] && N[0] == N[2] && N[0] == N[3])
    cout << "Yes" << endl;
  else if (N[0] == N[1] && N[0] == N[2])
    cout << "Yes" << endl;
  else if (N[1] == N[2] && N[1] == N[3])
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}

Measured memory_bytes: 256
alpha = ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z"]
n = int(input())
ans = []
a = 0
for num in range(1, 12):
  a += 26 ** num
  if n <= a:
    n -= (a - 26 ** num)
    break

for i in range(num, 0, -1):
  for j in range(26):
    if n <= 26 ** (i-1) * (j+1):
      n -= 26 ** (i-1) * j
      ans.append(alpha[j])
      break

print("".join(ans))

Measured memory_bytes: 9236
using System;
using System.Linq;

namespace ABC051
{
    class C
    {
        static void Main(string[] args)
        {
            int[] input = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int sx = input[0];
            int sy = input[1];
            int tx = input[2];
            int ty = input[3];

            string s = "";
            for (int i = 0; i < 2; i++)
            {

                for (int u = 0; u < Math.Abs(sy - ty); u++)
                {
                    s += "U";
                }

                for (int r = 0; r < Math.Abs(sx - tx); r++)
                {
                    s += "R";
                }
                if (i == 1) s += "DR";

                for (int d = 0; d < Math.Abs(sy - ty); d++)
                {
                    s += "D";
                }

                for (int l = 0; l < Math.Abs(sx - tx); l++)
                {
                    s += "L";
                }
                if (i == 1) s += "U";

                if (i == 0)
                {
                    s += "L";
                    tx++;
                    ty++;
                }
            }
            Console.WriteLine(s);
        }
    }
}


Measured memory_bytes: 37076
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(c) begin(c), end(c)
#define dump(x) cerr << __LINE__ << ":\t" #x " = " << (x) << endl

int main() {
    int a, b, c;
    while(cin >> a >> b >> c) {
        int ans = min(c, b / a);
        cout << ans << endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
// type alias
typedef long long LL;
typedef pair<int,int> II;
typedef tuple<int,int,int> III;
typedef vector<int> VI;
typedef vector<string> VS;
typedef unordered_map<int,int> MAPII;
typedef unordered_set<int> SETI;
template<class T> using VV=vector<vector<T>>;
// minmax
template<class T> inline T SMIN(T& a, const T b) { return a=(a>b)?b:a; }
template<class T> inline T SMAX(T& a, const T b) { return a=(a<b)?b:a; }
// repetition
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)
#define REPE(i,n)  for(int i=0;i<=(n);++i)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i=0;i<(n);++i)
#define FORR(x,arr) for(auto& x:arr)
#define SZ(a) int((a).size())
// collection
#define ALL(c) (c).begin(),(c).end()
// DP
#define MINUS(dp) memset(dp, -1, sizeof(dp))
#define ZERO(dp) memset(dp, 0, sizeof(dp))
// stdout
#define println(args...) fprintf(stdout, ##args),putchar('\n');
// debug cerr
template<class Iter> void __kumaerrc(Iter begin, Iter end) { for(; begin!=end; ++begin) { cerr<<*begin<<','; } cerr<<endl; }
void __kumaerr(istream_iterator<string> it) { (void)it; cerr<<endl; }
template<typename T, typename... Args> void __kumaerr(istream_iterator<string> it, T a, Args... args) { cerr<<*it<<"="<<a<<", ",__kumaerr(++it, args...); }
template<typename S, typename T> std::ostream& operator<<(std::ostream& _os, const std::pair<S,T>& _p) { return _os<<"{"<<_p.first<<','<<_p.second<<"}"; }
#define __KUMATRACE__ true
#ifdef __KUMATRACE__
#define dump(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); __kumaerr(_it, args); }
#define dumpc(ar) { cerr<<#ar<<": "; FORR(x,(ar)) { cerr << x << ','; } cerr << endl; }
#define dumpC(beg,end) { cerr<<"~"<<#end<<": "; __kumaerrc(beg,end); }
#else
#define dump(args...)
#define dumpc(ar)
#define dumpC(beg,end)
#endif

// $ cp-batch BA | diff BA.out -
// $ g++ -std=c++14 -Wall -O2 -D_GLIBCXX_DEBUG -fsanitize=address BA.cpp && ./a.out

/*
 
 2/28/2019
 
 15:31-
 
 */

int A,B;

void solve() {
  cout<<(B%A==0?A+B:B-A)<<endl;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout<<setprecision(12)<<fixed;
  
  cin>>A>>B;
  solve();
  
  return 0;
}


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

int main() {
	int H,W;
	while(true){
		cin>>H>>W;
		if(H==0&&W==0){
			break;
		}
		for(int i=0;i<H;i++){
			if(i==0||i==H-1){
				for(int a=0;a<W;a++){
					cout<<"#";
				}
			}
			else{
				for(int a=0;a<W;a++){
					if(a==0||a==W-1){
						cout<<"#";
					}
					else{
						cout<<".";
					}
				}
			}
			cout<<"\n";
		}
		cout<<"\n";
	}
	return 0;
}


Measured memory_bytes: 1120
N=int(input())
A=list(map(int,input().split()))
B=list(map(int,input().split()))

if sum(A)>sum(B):
  print("No")
else:
  cnt=sum(B)-sum(A)
  for i in range(N):
    if A[i]<B[i]:
      cnt-=(B[i]-A[i])//2+(B[i]-A[i])%2
  print("Yes" if cnt>=0 else "No")

Measured memory_bytes: 4596