akhauriyash/Code-Regression huggingface dataset:
//package BestPizzia;
import java.util.*;
public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int base = sc.nextInt();
		int per = sc.nextInt();
		int basecal = sc.nextInt();
		Integer[] cal = new Integer[N];
		int idx = N;
		int maxcal = 0;
		int parcal;
		for(int i = 0; i < N; i++) cal[i] = sc.nextInt();
		Arrays.sort(cal, Collections.reverseOrder());
		while(true) {
			int sumcal = basecal;
			for(int i = 0; i < idx; i++) sumcal += cal[i];
			parcal = sumcal / (base + per * idx);
			if(maxcal < parcal) maxcal = parcal; 
			idx--;
			if(idx == 0) break;
		}
		if(maxcal < basecal / base) maxcal = basecal / base;
		System.out.println(maxcal);
	}

}

Measured memory_bytes: 18176
N,C = [int(val) for val in raw_input().split(" ")]

table = [[0]*(10**5) for i_c in range(C)]

for i_n in xrange(N):
    s_i, t_i, c_i = [int(val) for val in raw_input().split(" ")]
    for loc in xrange(s_i-1, t_i-1):
        table[c_i-1][loc] = 1
    if s_i>1:
        table[c_i-1][s_i-2] = 1

req = 0
for loc in xrange(10**5):
    tmp = sum([table[i_c][loc] for i_c in xrange(C)])
    if tmp > req:
        req = tmp

print req

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

typedef long long int int64;

#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define ABS(a) ((a)>(0)?(a):-(a))

const int mod=1000000007;
int modPow(int r,int n){
  int t=1;
  int s=r;
  while(n>0){
    if(n&0x01) t=(int64)t*s%mod;
    s=(int64)s*s%mod;
    n>>=1;
  }
  return t;
}

int *dp=NULL;
int calc(char *t,char *s,int n){
  int *dp2=dp+2*(n+1);
  int *dp1=dp+1*(n+1);
  int *dp0=dp+0*(n+1);
  int i;
  for(i=0;i<=n;i++){
    dp2[i]=dp1[i]=dp0[i]=0;
  }
  for(i=n-1;i>=0;i--){
    dp2[i]=dp2[i+1];
    if(s[i]==t[2]) dp2[i]++;
  }
  for(i=n-1;i>=0;i--){
    dp1[i]=dp1[i+1];
    if(s[i]==t[1]){
      dp1[i]+=dp2[i+1];
      dp1[i]%=mod;
    }
  }
  for(i=n-1;i>=0;i--){
    dp0[i]=dp0[i+1];
    if(s[i]==t[0]){
      dp0[i]+=dp1[i+1];
      dp0[i]%=mod;
    }      
  }
  return dp0[0];
}

void run(void){
  char *s=(char *)malloc(sizeof(char)*(100000+1));
  scanf("%s",s);
  int n=0;
  while(s[n]!='\0') n++;
  dp=(int *)malloc(sizeof(int)*3*(n+1));
  int cnt=0;
  int i;
  for(i=0;i<n;i++) if(s[i]=='?') cnt++;
  int64 ans=0;
  ans+=(int64)calc("ABC",s,n)*modPow(3,cnt);
  ans+=(int64)calc("AB?",s,n)*modPow(3,cnt-1);
  ans+=(int64)calc("A?C",s,n)*modPow(3,cnt-1);
  ans+=(int64)calc("?BC",s,n)*modPow(3,cnt-1);
  ans+=(int64)calc("A??",s,n)*modPow(3,cnt-2);
  ans+=(int64)calc("?B?",s,n)*modPow(3,cnt-2);
  ans+=(int64)calc("??C",s,n)*modPow(3,cnt-2);
  ans+=(int64)calc("???",s,n)*modPow(3,cnt-3);
  printf("%lld\n",ans%mod);
}

int main(void){
  run();
  return 0;
}


Measured memory_bytes: 1408
def arc094C():
    abc = input().split()
    abc = list(map(int, abc))
    abc.sort()

    count = 0
    count += abc[2] - abc[1]
    tmp = abc[2] - (abc[0] + count)
    count += [tmp // 2 + 2, tmp // 2][tmp % 2 == 0]

    print(count)


arc094C()

Measured memory_bytes: 3060
import java.io.PrintWriter
import java.util.*
import java.math.*

val pw = PrintWriter(System.out)

fun main(args: Array<String>) {
    val s = read()
    val t = read()
    

    var ans = "No"
    for(i in 0 until s.length) { 
        var s_ = ""
        for(j in i until s.length) {
            s_ += s[j]
        }
        for(j in 0 until i) {
            s_ += s[j]
        }
        if(s_==t) {
            ans = "Yes"
        }
    }

    println(ans)

    pw.flush()
}

fun inputList() = 
    readLine()!!.split(" ").map(String::toInt)

fun sum_digits(num_: Long): Long {
    var num = num_
    var rtn: Long = 0
    while(num != 0.toLong()) {
        val tmp = num % 10
        rtn += tmp
        num /= 10
    }
    return rtn
}

/****** Decrared Functions ******/

// IO
fun read() = readLine()!!
fun readInt() = read().toInt()
fun readLong() = read().toLong()
fun readDouble() = read().toDouble()
fun readListOfString() = read().split(" ")
fun readListOfInt() = readListOfString().map { it.toInt() }
fun readListOfLong() = readListOfString().map { it.toLong() }
fun readListOfDouble() = readListOfString().map { it.toDouble() }


fun println(value : Any) {
    pw.println(value)
}

fun gcd(a: Long, b: Long): Long = 
    if(b != 0L) a else gcd(b, a % b)

fun lcm(a: Long, b: Long) = 
    if(b==0L) a else gcd(b, a % b)


Measured memory_bytes: 38424
N,M=map(int,input().split())
L=[0]*N
c={}
mod=1000000007
for i in range(M):
  k=int(input())
  c[k]=0
for i in range(N):
  if i==0:
    L[i]=1
  elif i==1:
    if L[0]==0:
      L[i]=1
    else:
      L[i]=2
  else:
    L[i]=(L[i-1]+L[i-2])%mod
  if i+1 in c:
    L[i]=0
print(L[N-1])

Measured memory_bytes: 20028
import Control.Applicative
import Control.Monad
import Control.Monad.ST
import qualified Data.ByteString as BS
import Data.Functor
import Data.Function
import Data.Monoid
import Data.Maybe
import Data.List
import qualified Data.Foldable as Foldable
import qualified Data.Set as Set
--import qualified Data.Sequence as Sequence
import Data.List.Split
import Data.Bits
import Data.Char
import Data.Ix
import Data.Ratio
import Data.Ord
import Data.Tuple
import Data.Array
--import Data.Array.Unboxed
--import Data.Array.IArray
import Data.Array.MArray
import Data.Array.IO
import Data.Array.ST
import Data.IORef
import Data.STRef
-- import System.IO.Unsafe

-- templete
readInt = read :: String -> Int
readInteger = read :: String -> Integer
readDouble = read :: String -> Double
getInt = readLn :: IO Int
getInts = map readInt . words <$> getLine
getInteger = readLn :: IO Integer
getIntegers = map readInteger . words <$> getLine
getDouble = readLn :: IO Double
getDoubles = map readDouble . words <$> getLine
sjoin :: (Show a) => [a] -> String
sjoin = unwords . map show
cond :: a -> a -> Bool -> a
cond t f c = if c then t else f
apply2 :: (a -> a -> b) -> [a] -> b
apply2 f [x,y] = f x y
apply3 :: (a -> a -> a -> b) -> [a] -> b
apply3 f [x,y,z] = f x y z
apply4 :: (a -> a -> a -> a -> b) -> [a] -> b
apply4 f [x,y,z,w] = f x y z w
fnTuple :: (a -> b, a -> c) -> a -> (b, c)
fnTuple (f,g) a = (f a, g a)
replace :: (Eq a) => a -> a -> [a] -> [a]
replace x y = map (\z -> if z==x then y else z)
binMap :: (a -> a -> b) -> [a] -> [b]
binMap f (x:xs@(y:_)) = f x y : binMap f xs
binMap _ _ = []
splitRec :: Int -> [a] -> [[a]]
splitRec _ [] = []
splitRec n xs = let (y,ys) = splitAt n xs in y : splitRec n ys
infixl 7 `divCeil`
divCeil :: Integral a => a -> a -> a
x `divCeil` y = (x+y-1) `div` y
coverC :: Ord a => (a, a) -> a -> Bool
coverC (l,r) x = l<=x && x<=r
coverH :: Ord a => (a, a) -> a -> Bool
coverH (l,r) x = l<=x && x<r
ibsearch :: (Int -> Bool) -> (Int,Int) -> Int
ibsearch f (ok,ng) = if abs (ok-ng) <= 1 then ok else let mid = (ok + ng) `div` 2 in ibsearch f (if f mid then (mid,ng) else (ok,mid))
-- templete



main = do
    sa <- getInts
    unless (all (==0) sa) $ do
      maximum .  flip zip ['A'..'E'] . map sum . (sa:) <$> replicateM 4 getInts >>= \(c,s) -> putStrLn (s:' ':show c)
      main


Measured memory_bytes: 4080
#include <stdlib.h>
#include <stdio.h>
#include <iostream>
using namespace std;
 
  
 int main(){
    int n; cin>>n; int arr[n]; 
    for (int i = 0; i < n; ++i)
    {
        cin>>arr[i];

    }
   int paircount=0; int singlecount=0;
     for (int i = 0; i < n; ++i)
     {  
       int j= i+1;
       if(i!=n-1 && arr[j]==j+1 && arr[i]==i+1){paircount++;i++; }
       else if ( i!=n-1 && arr[i]==i+1 && arr[j]!=j+1){ singlecount++;}
       else if (i==n-1 && arr[i]==i+1 ){ singlecount++; }
     }
     int total =paircount + singlecount;
     cout<<total;
  
  return 0; 
 }

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define eps 1e-9
#define pi acos(-1)
#define nmax 200
#define f(c,a,b) for(int c=a; c<=b; c++)

using namespace std;
typedef double db;
struct P{
    db x, y;
    P(){}
    P(db x, db y) : x(x) , y(y) {}
    P operator - (P a){ return P(x-a.x, y-a.y); }
    db dot(P a){ return x*a.x+y*a.y; }
    db clen() { return sqrt(x*x+y*y); }
    db times(P a){ return x*a.y-y*a.x; }
}po[nmax];
typedef P V;
int n;

int sign(db x){ return x<-eps ? -1 : x>eps; }

int contain(P a){
    bool flag=false;
    f(i,1,n){
        P b = po[i]-a, c = po[i-1]-a;
        if( !sign(b.times(c)) && b.dot(c)<eps ) return 1;
        if(b.y < c.y) { P t=b; b=c; c=t; }
        if(c.times(b)>eps && b.y>eps && c.y<eps ) flag=!flag;
    }    
    return flag?2:0;
}

int main(){
    //freopen("owo.in","r",stdin);
    cin >> n;
    f(i,1,n) scanf("%lf%lf", &po[i].x, &po[i].y);
    po[0] = po[n];
    int q;
    cin >> q;
    while(q--) {
        P in;
        scanf("%lf%lf", &in.x, &in.y);
        printf("%d\n", contain(in));
    }
    return 0;
}


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

int main()
{

	int h,w;
	cin >> h >> w;

	string matrix[h];

	for (int i = 0; i < h; ++i)
	{
		cin >> matrix[i];
	}

	for (int i = 0; i < h + 2; ++i)
	{
		for (int j = 0; j < w + 2; ++j)
		{
			if (i == 0 || i == h + 1) cout << '#';
			else if (j == 0 || j == w + 1) cout << '#';
			else cout << matrix[i-1][j-1];
		}
		cout << endl;
	}

	return 0;
}

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

typedef long long LL;

const int mod=1000000007;

int Power(int a,int k){int res=1;for (;k;k>>=1,a=(LL)a*a%mod) if (k&1) res=(LL)res*a%mod;return res;}

int dp[3000][3000],sum[3000][3000];

int main(){
  int n;
  scanf("%d",&n);
  for (int j=0;j<=n;++j) sum[0][j]=1;
  for (int i=1;i<=n;++i)
	for (int j=1;j<=n;++j){
	  dp[i][j]=sum[i-1][j-3];
	  sum[i][j]=(dp[i][j]+sum[i][j-1])%mod;
	}
  int ans=0;
  for (int i=1;i<=n;++i) ans=(ans+dp[i][n])%mod;
  printf("%d\n",ans);
  return 0;
}

Measured memory_bytes: 50556
def chmin(a, b)
  a > b ? b : a
end
n = gets.to_i
a = gets.split.map(&:to_i)
ans = 100000000000000
(-100..100).each do |i|
    sum = 0
    a.each do |j|
        sum += ((j - i) * (j - i))
    end
    if sum < ans
        ans = chmin(ans, sum)
    end
end
puts ans

Measured memory_bytes: 3836
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define srep(i,s,t) for(int i = s; i < t; ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
#define yn {puts("Yes");}else{puts("No");}
#define MAX_N 500005

int ans[MAX_N];
vector<P> keep[MAX_N];
int n;
int v[MAX_N], w[MAX_N];

int nap[1025][100001];

int main() {
    int n;
    cin >> n;
    srep(i,1,n+1)cin >> v[i] >> w[i];
    int Q; cin >> Q;
    rep(loop, Q){
        int vv, L;
        cin >> vv >> L;
        keep[vv].push_back(P(loop,L));
    }

    srep(i,1,min(n+1,1025)){
        if(i == 1){
            nap[i][w[i]] = v[i];
        }else{
            rep(j,100001)nap[i][j] = nap[i/2][j];
            drep(j,100001){
                if(j+w[i] <= 100000) nap[i][j+w[i]] = max(nap[i][j+w[i]], nap[i/2][j] + v[i]);
            }
        }
    }

    srep(i,1,1025){
        srep(j,1,100001){
            nap[i][j] = max(nap[i][j], nap[i][j-1]);
        }
        rep(j,keep[i].size()){
            int x = keep[i][j].first;
            int L = keep[i][j].second;
            ans[x] = nap[i][L];
        }
    }

    srep(i,1025,n+1){
        if(keep[i].size() == 0) continue;
        vector<P> p;
        int ii = i;
        while(ii >= 1025){
            p.push_back(P(v[ii], w[ii]));
            ii /= 2;
        }
        int tmp = 0;
        int m = p.size();
        rep(j,1<<m){
            int jj = j;
            int ww = 0;
            int vv = 0;
            rep(k,m){
                if(jj % 2 == 1){
                    ww += p[k].second;
                    vv += p[k].first;
                }
                jj /= 2;
            }
            rep(lop,keep[i].size()){
                int x = keep[i][lop].first;
                int L = keep[i][lop].second;
                if(L < ww) continue;
                ans[x] = max(ans[x], vv + nap[ii][L-ww]);
            }
        }
            
    }


    rep(i,Q) cout << ans[i] << endl;
    return 0;
}




Measured memory_bytes: 420848
#include <iostream>
#include <stdio.h>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include <numeric>
#include <queue>
#include <numeric>
#include <iomanip>
#include <sstream>

#define rep(i,n) for((i)=0;i<(int)(n);i++)
#define max(a,b) (a < b ? b : a)
#define min(a,b) (a > b ? b : a)

using namespace std;


int main() {
	string S[55];
	int H, W;
	cin >> H >> W;
	int i, j, k;
	rep(i, W+2)S[0] += 'B';
	rep(i, H){
		string s;
		cin >> s;
		S[i+1] = 'B' + s + 'B';
	}
	rep(i, W+2)S[H+1] += 'B';
	for (i = 1; i <= H; i++) {
		for (j = 1; j <= W; j++) {
			if (S[i][j] == '#')continue;

			S[i][j] = '0';
			if (S[i - 1][j - 1] == '#')S[i][j] += 1;
			if (S[i - 1][j] == '#')S[i][j] += 1;
			if (S[i - 1][j + 1] == '#')S[i][j] += 1;
			if (S[i][j - 1] == '#')S[i][j] += 1;
			if (S[i][j] == '#')S[i][j] += 1;
			if (S[i][j + 1] == '#')S[i][j] += 1;
			if (S[i + 1][j - 1] == '#')S[i][j] += 1;
			if (S[i + 1][j] == '#')S[i][j] += 1;
			if (S[i + 1][j + 1] == '#')S[i][j] += 1;
		}
	}
	for (i = 1; i <= H; i++) {
		S[i].erase(S[i].begin());
		S[i].erase(S[i].end() - 1);
		cout << S[i] << endl;
	}

	return 0;
}

Measured memory_bytes: 256
/*
　　　∫ ∫ ∫
　　　ノヽ
　　（＿　 ）
　（＿　　　 ）
（＿＿＿＿＿＿ ）
　ヽ(´･ω･)ﾉ　
　　 |　 /
　　 UU
*/
#pragma region macro
#include <bits/stdc++.h>
typedef long long int64;
using namespace std;
typedef vector<int> vi;
const int MOD = (int)1e9 + 7;
const int64 INF = 1LL << 62;
const int inf = 1<<30;
const char bn = '\n';
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; }
#define REP(i, n) for (int i = 0; i < (n); i++)
#define FOR(i,s,n) for (int i = s; i < (n); i++)
#define ALL(obj) (obj).begin(), (obj).end() //コンテナじゃないと使えない!!
#define debug(x) cerr << #x << ": " << x << "\n";
#define mp make_pair
template <typename T>
ostream& operator<<(ostream& os, const vector<T> &V){
    int N = V.size();
    REP(i,N){
        os << V[i];
        if (i!=N-1) os << " ";
    }
    os << "\n";
    return os;
}
template <typename T,typename S>
ostream& operator<<(ostream& os, pair<T,S> const&P){
    os << "(";
    os << P.first;
    os << " , ";
    os << P.second;
    os << ")";
    return os;
}
template <typename T>
ostream& operator<<(ostream& os, set<T> &S){
    auto it=S.begin();
    while(it!=S.end()){
        os << *it;
        os << " ";
        it++;
    }
    os << "\n";
    return os;
}
template <typename T>
ostream& operator<<(ostream& os, deque<T> &q){
    for(auto it=q.begin();it<q.end();it++){
        os<<*it;
        os<<" ";
    }
    os<<endl;
    return os;
}
template <typename T,typename S>
ostream& operator<<(ostream& os, map<T,S> const&M){
    for(auto e:M){
        os<<e;
    }
    os<<endl;
    return os;
}
vector<pair<int,int>> dxdy = {mp(0,1),mp(1,0),mp(-1,0),mp(0,-1)};
#pragma endregion
//fixed<<setprecision(10)<<ans<<endl;



int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    string S; cin >> S;
    int N = S.size();

    vector<vector<int>> next(N);
    vector<int> last(26,N);
    for(int i=N-1;i>=0;i--){
        last[S[i]-'a'] = i;
        next[i] = last;
    }

    vector<int> DP(N+1,N);
    vector<int> memo(N+1,0);
    DP[N] = 1;
    for(int i=N-1;i>=0;i--){
        REP(c,26){
            int to = next[i][c];
            if(to==N){
                memo[i] = c;
                DP[i] = 1;
                break;
            }
            if(chmin(DP[i],DP[to+1]+1)){
                memo[i] = c;
            }
        }
    }
    
    debug(DP)
    debug(memo)
    string ans = "";
    for(int now=0; now<N ;){
        // debug(now)
        int next_char = memo[now];
        ans += next_char + 'a';
        if(now == next[now][next_char]){
            now++;
        }else{
            now = next[now][next_char]+1;
        }
        // debug(now)
    }
    cout << ans << bn;


}

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

long  sol(long  i){
	long  sum=0;
	long  c=0;
	for(long j=1;;j++){
		if(j+sum>i)
			break;
		sum+=j;
		c++;
	}
	return c;
}
void solve(){
	long long x;
	cin>>x;
	long long count=0;
	for (long long i=2; i<=sqrtl(x); i++){
		if(x%i==0){
			long c=0;
			while(x%i==0){
				x/=i;
				c++;
			}
		    count+=sol(c);	
		}
    }
	
	if(x>1)
       count++;	
	cout<<count;
}

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	
	solve();
	return 0;
}


Measured memory_bytes: 3696
n = int(input())
a = []
b = []
for i in range(n):
    t, m = map(int, input().split())
    a.append(t)
    b.append(m)
ans = 0
for i in range(n):
    if((ans + a[-1 - i]) % b[-1 - i]!=0):
        ans += b[-1 - i] - (ans + a[-1 - i]) % b[-1 - i]
print(ans)


Measured memory_bytes: 11148
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<algorithm>
#include<queue>
#include<map>
#include<set>
#include<vector>
#include<functional>
#include <random>
#include<iostream>
#include<iomanip>
using namespace std;

string S = "";

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

	for (int i = 0; i < N; i++) {
		S = "a" + S;
	}

	cout << S << "\n";

	while (true) {
		int kaeruketa = N;
		for (int i = N - 1; i > 0; i--) {
			/*S[i-1]までで、'a'からS[i]まで全部使われていたらok*/
			bool detekita[10];
			for (int j = 0; j < N; j++) {
				detekita[j] = false;
			}
			for (int j = 0; j < i; j++) {
				detekita[S[j] - 'a'] = true;
			}
			bool zenbudetekita = true;
			for (int j = 0; j <= S[i] - 'a'; j++) {
				if (!detekita[j]) {
					zenbudetekita = false;
				}
			}
			if (zenbudetekita) {
				kaeruketa = i;
				break;
			}
		}
		if (kaeruketa == N) { return 0; }
		else {
			S[kaeruketa] += 1;
			for (int j = kaeruketa+1; j < N; j++) {
				S[j] = 'a';
			}
		}
		cout << S << "\n";
	}






}

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

using namespace std;


int main(void){

	int a[10], b[10];

	for (int i = 0; i < 10; i++){
		cin >> a[i];
	}
	for (int i = 0; i < 10; i++){
		cin >> b[i];
	}
	sort(a, a + 10);
	sort(b, b + 10);

	cout << (a[9] + a[8] + a[7]) << " " << (b[9] + b[8] + b[7]) << endl;

	return 0;
}

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

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

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

    int ans = 0;
    if(k >= a) {
        ans += a;
        k -= a;
    } else {
        cout << k;
        return 0;
    }

    if(k >= b) {
        k -= b;
    } else {
        cout << ans;
        return 0;
    }

    ans -= k;
    cout << ans;
    return 0;
}


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

using namespace std;

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

  string judge;  
  if (a > b) {
    judge = "a > b";
  } else if (a < b) {
    judge = "a < b";
  } else {
    judge = "a == b";
  }  

  cout << judge << endl;

  return 0;
}



Measured memory_bytes: 3144
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef long double ld;
#define rep(i, a, n) for (int i = a; i < n; i++)
#define per(i, a, n) for (int i = n - 1; i >= a; i--)
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define sz(x) ((int)(x).size())
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define INF 1000000000
#define MOD 1000000007

void solve() {
    int n,q;
    cin >> n;
    vi ar(n);
    ll s = 0;
    map<int, int> mp;
    for (auto& i: ar) {
        cin >> i;
        mp[i]++;
        s += i;
    }
    cin >> q;
    rep(i,0,q) {
        int a,b;
        cin >> a >> b;
        s += (b-a) * mp[a];
        mp[b] += mp[a];
        mp[a] = 0;
        cout << s << "\n";
    }
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    int t = 1;
    // cin >> t;
    while (t--)
        solve();
    return 0;
}


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

int main() {
	string s,t;
	cin >> s >> t;

	string ss;
	int ans=0, cnt=0;
	for(int i=0;i<=s.size()-t.size();i++){
		ss = s.substr(i, t.size());
		for(int j=0;j<t.size();j++){
			if(ss.at(j) == t.at(j)) cnt++;
		}
		if(cnt>ans) ans=cnt;
		cnt=0;
	}
	cout << t.size() - ans << endl;
	return 0;
}


Measured memory_bytes: 3560
#include<stdio.h>

int main(){
  int x=0,y=0,z=0;
  int A[2001] = {};
  int i=0,j=0;

  scanf("%d", &x);

  for(i=0;i<x;i++){

    scanf("%d", &y);

    A[0] =1;

    for(j=2000; j >=0; j--){
      if(A[j] && j+y < 2001){
	A[j+y] =1;
      }
    }
  }

  scanf("%d", &z);

  for(i=0;i<z; i++){
    scanf("%d", &y);
    if(A[y]){
      printf("yes\n");
    }
    else
      printf("no\n");
  }
  return 0;
}

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

// Begin Header {{{
using namespace std;

#ifndef DEBUG
#define dump(...)
#endif

#define all(x) x.begin(), x.end()
#define rep(i, n) for (intmax_t i = 0, i##_limit = (n); i < i##_limit; ++i)
#define reps(i, b, e) for (intmax_t i = (b), i##_limit = (e); i <= i##_limit; ++i)
#define repr(i, b, e) for (intmax_t i = (b), i##_limit = (e); i >= i##_limit; --i)
#define var(Type, ...) Type __VA_ARGS__; input(__VA_ARGS__)

constexpr size_t    operator""_zu(unsigned long long value) { return value; };
constexpr intmax_t  operator""_jd(unsigned long long value) { return value; };
constexpr uintmax_t operator""_ju(unsigned long long value) { return value; };

constexpr int INF = 0x3f3f3f3f;
constexpr intmax_t LINF = 0x3f3f3f3f3f3f3f3f_jd;

template <class T, class Compare = less<>>
using MaxHeap = priority_queue<T, vector<T>, Compare>;
template <class T, class Compare = greater<>>
using MinHeap = priority_queue<T, vector<T>, Compare>;

inline void input() {}
template <class Head, class... Tail>
inline void input(Head&& head, Tail&&... tail) {
    cin >> head;
    input(forward<Tail>(tail)...);
}

template <class T>
inline istream& operator>>(istream &is, vector<T> &vec) {
    for (auto &e: vec) {
        is >> e;
    }
    return is;
}

inline void output() { cout << "\n"; }
template <class Head, class... Tail>
inline void output(Head&& head, Tail&&... tail) {
    cout << head;
    if (sizeof...(tail)) {
        cout << " ";
    }
    output(forward<Tail>(tail)...);
}

template <class T>
inline ostream& operator<<(ostream &os, const vector<T> &vec) {
    static constexpr const char *delim[] = {" ", ""};
    for (const auto &e: vec) {
        os << e << delim[&e == &vec.back()];
    }
    return os;
}

template <class T>
inline vector<T> makeVector(const T &initValue, size_t sz) {
    return vector<T>(sz, initValue);
}

template <class T, class... Args>
inline auto makeVector(const T &initValue, size_t sz, Args... args) {
    return vector<decltype(makeVector<T>(initValue, args...))>(sz, makeVector<T>(initValue, args...));
}

template <class Func>
class FixPoint : Func {
public:
    explicit constexpr FixPoint(Func&& f) noexcept : Func(forward<Func>(f)) {}

    template <class... Args>
    constexpr decltype(auto) operator()(Args&&... args) const {
        return Func::operator()(*this, std::forward<Args>(args)...);
    }
};

template <class Func>
static inline constexpr decltype(auto) makeFixPoint(Func&& f) noexcept {
    return FixPoint<Func>{forward<Func>(f)};
}

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

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

template <class T>
inline T diff(const T &a, const T &b) noexcept {
    return a < b ? b - a : a - b;
}
// End Header }}}

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    vector<intmax_t> x(3);
    input(x);

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

    output(x[0] + x[1]);

    return 0;
}


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

typedef vector<ll> vll;

ll knapsack(vll& w, vll& v, int N, int W) {
	vector<vll> dp(N + 1, vll(W + 1, 0));
	
	for(int i = 0; i < N + 1; ++i) {
		for(int j = 0; j < W + 1; ++j) {
			if(i == 0 || j == 0) {
				dp[i][j] = 0;
			}
			else {
				if(w[i-1] <= j) {
					dp[i][j] = max(dp[i-1][j-w[i-1]] + v[i-1], dp[i-1][j]);
				}
				else {
					dp[i][j] = dp[i-1][j];
				}
			}
		}
	}
	return dp[N][W];
}
int main() {
	// your code goes here
	int N, W;
	cin >> N >> W;
	
	vll w(N, 0);
	vll v(N, 0);
	
	for(int i = 0; i < N; ++i ) {
		cin >> w[i] >> v[i];
	}
	
	cout << knapsack(w, v, N, W) << endl;
	
	return 0;
}

Measured memory_bytes: 80256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.HashMap;
import java.util.Map;

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		int n = Integer.parseInt(br.readLine());

		Map<Integer, Long> map = new HashMap<>();
		int a[] = new int[n];

		String str[] = br.readLine().split(" ");
		for (int i = 0; i < n; i++) {
			int aa = Integer.parseInt(str[i]);
			a[i] = aa;

			if (map.containsKey(aa))
				map.put(aa, map.get(aa) + 1);
			else
				map.put(aa, 1L);
		}

		long res = 0;
		for (int key : map.keySet()) {
			res += map.get(key) * (map.get(key) - 1) / 2;
		}

		for (int i = 0; i < n; i++) {
			long val = map.get(a[i]);
			long before = val * (val - 1) / 2;
			long after = (val - 1) * (val - 2) / 2;
			System.out.println(res - before + after);
		}
	}
}

Measured memory_bytes: 74884
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)

using namespace std;
typedef long long unsigned int ll;


int main() {
	int n;
	cin >> n;
	vector<int> x(n);
	REP(i, n)cin >> x[i];
	sort(x.begin(),x.end());
	int sum = 0;
	REP(i, x.size()) {
		if (i % 2 == 0)sum += x[i];
		else sum -= x[i];
	}
	cout << abs(sum);
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int n,book;
int main(){
	while(1){
		cin >> n;
		if(n==0)break;
		for(int i=0;i<9;i++){
			cin >>book;
			n-=book;
		}
		cout << n<<endl;
	}
	return 0;
}

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

using namespace std;
using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
#define REP(i,n) for(ll i = 0;i < (ll)n;i++)
#define REPD(i,n) for(ll i = (ll)n - 1;i >= 0;i--)
#define ALL(x) (x).begin(),(x).end()
#define FILLl(n,first_dimension_size,value) fill((ll*)n,(ll*)(n+first_dimension_size),value)
#define FILL(n,first_dimension_size,value) fill((int*)n,(int*)(n+first_dimension_size),value)
#define INF (1 << 30)
#define MOD 1000000007
//int dy[4] = {-1,0,0,1};
//int dx[4] = {0,1,-1,0};



int main(){

  ll n;
  cin >> n;
  cout << (int)sqrt(n)*(int)sqrt(n) << endl;
  


  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(){
  int a,b,c,tmp;
  scanf("%d%d%d",&a,&b,&c);
  if (a > b ){
    tmp=a;
    a=b;
    b=tmp;
  };
  if(a > c){
    tmp=a;
    a=c;
    c=tmp;
  };
  if (b > c){
    tmp=b;
    b=c;
    c=tmp;
  };
 printf("%d %d %d\n",a,b,c);  
  return 0;
}

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

using namespace std;

using int64 = long long;

template<typename T>
vector<vector<vector<T>>>
Make3DVector(int d1, int d2, int d3, T default_value) {
  return vector<vector<vector<T>>>(
      d1,
      vector<vector<T>>(d2, vector<T>(d3, default_value)));
}

constexpr int64 P = 1000000007;

// Verified: ABC133E, ABC132D, ABC130E
struct FiniteField {
 private:
  int64 x;
 public:
  FiniteField(int64 input_x) : x(input_x) {}
  FiniteField() : x(0) {}
  int64 Value() { return x; }
  inline FiniteField operator+(FiniteField o) {
    FiniteField r(*this); r += o; return r;
  }
  inline FiniteField operator-(FiniteField o) {
    FiniteField r(*this); r -= o; return r;
  }
  inline FiniteField operator* (FiniteField o) {
    FiniteField r(*this); r *= o; return r;
  }
  inline FiniteField operator/ (FiniteField o) {
    FiniteField r(*this); r /= o; return r;
  }
  inline void operator+= (FiniteField o) { x = (x + o.x) % P; }
  inline void operator-= (FiniteField o) { x = (x + P - o.x) % P; }
  inline void operator*= (FiniteField o) { x = (x * o.x) % P; }
  void operator/=(FiniteField o) {
    int64 p = P - 2; while (p) { if (p % 2) { *this *= o; } o *= o; p /= 2; }
  }
};

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

  string input;
  int mod;
  cin >> input >> mod;
  int n = input.size();

  auto dp = Make3DVector(n + 1, 2, mod, FiniteField(0));
  dp[0][0][0] = 1;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < 2; j++) {
      for (int k = 0; k < mod; k++) {
        if (j == 0) {
          int cur_d = input[i] - '0';
          for (int d = 0; d < cur_d; d++) {
            dp[i + 1][1][(k + d) % mod] += dp[i][0][k];
          }
          dp[i + 1][0][(k + cur_d) % mod] += dp[i][0][k];
        } else {
          // j == 1
          for (int d = 0; d < 10; d++) {
            dp[i + 1][1][(k + d) % mod] += dp[i][1][k];
          }
        }
      }
    }
  }
  FiniteField ans = dp[n][0][0] + dp[n][1][0] - 1;
  cout << ans.Value() << endl;
}


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

typedef unsigned long ul;
typedef unsigned long long ull;
typedef pair<ul, ul> P;

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

    int64_t b2 = (int64_t)llround(b * 100.0);
    cout << a * b2 / 100 << endl;

    return 0;
}

Measured memory_bytes: 3788
#include<bits/stdc++.h>
#include<algorithm>
using namespace std;
int main(){
//	freopen(".in","r",stdin);
//	freopen(".out","w",stdout);
	int n,m;
	cin>>n>>m;
	cout<<n*(n-1)/2+m*(m-1)/2<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    while (a>0&&c>0){
        c-=b;
        if (c<=0){
            cout<<"Yes\n";
            return 0;
        }
        a-=d;
        if (a<=0){
            cout<<"No\n";
            return 0;
        }
    }
}

Measured memory_bytes: 3644
function Main(input) {
  input = input.split(" ");
  //console.log(input);
  kido(input[0], input[1], input[2]);
  
}

function kido(a, b, c) {
  a = parseInt(a);
  b = parseInt(b);
  c = parseInt(c);
	if (b + c < a) {
		var ans = 0;
		
	} else {
		var ans = (b + c) - a;
		
	}
	
	console.log(ans);
	
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
#include <iostream>
#include <algorithm>
#include <string>
#include <math.h>
#include <cstdint>
#include <sstream>
#include <map>
#include <vector>
#include <queue>
#include <iomanip>

using namespace std;
typedef long long ll;

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

ll ans, mx, sum, mn = 1e8, cnt;

ll first,sec;
int main(){
	string s;
	cin>>s;
	for(ll i=0; i<s.size(); i++){
		if(s[i]=='A'||s[i]=='C'||s[i]=='G'||s[i]=='T'){
			cnt++;
		}
		else {
			mx=max(mx,cnt);
			cnt=0;
		}
	}
	mx=max(mx,cnt);
	cout<<mx<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); i++)
#define ALL(a) a.begin(), a.end()
#define RALL(a) a.rbegin(), a.rend()
using namespace std;
using ll = long long;
const ll MOD = 1000000007;
const ll INF = MOD * MOD;
const int inf = (1<<29);

int main() {

    ll N, K;
    cin >> N >> K;

    vector<pair<ll, ll>> VP(N);
    
    for(ll i = 0; i < N; i++) {
        ll a, b;
        cin >> a >> b;        
        VP[i] = make_pair(a, b);
    }

    sort(ALL(VP));

    ll a, b = 0, cnt = 0;
    for(ll i = 0; i < N; i++) {
        a = VP[i].first;
        b += VP[i].second;        
        if (b >= K) break;
    }
    
    cout << a << endl;
    
    return 0;
}

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

#define rp(i,n) for(int i=0;i<n;i++)
#define rep(i,m,n) for(int i=m;i<=n;i++)
#define lrp(i,n) for(long long i=0;i<n;i++)
#define lrep(i,m,n) for(long long i=m;i<=n;i++)
#define sort(a) sort(a.begin(),a.end())
#define reverse(a) reverse(a.begin(),a.end())
#define pb push_back
#define elif else if
#define vcin(a); rp(i,a.size()){cin>>a[i];}
#define vcout(a); rp(i,a.size()){cout<<a[i]<<endl;}
typedef vector<int> vi;
typedef vector<long long> vl;
typedef vector<string> vs;
typedef vector<char> vc;
typedef long long ll;
typedef string S;
typedef pair<int,int> P;

bool isOK(int index, int key,vi a) {
    if (a[index] >= key) return true;
    else return false;
}

int binary_search(int key,vi a) {
    int left = -1;
    int right = (int)a.size();
    while (right - left > 1) {
        int mid = left + (right - left) / 2;
        
        if (isOK(mid, key,a)) right = mid;
        else left = mid;
    }
    return right;
}

int modpow(int a,int b,int p){
    if(b==0){
        return 1;
    }elif(b%2==0){
        return modpow((a*a)%p,b/2,p);
    }else{
        return (a*modpow(a,b-1,p))%p;
    }
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    if(n==1){
        cout << "Hello World" << endl;
        return 0;
    }elif(n==2){
        int a,b;
        cin >> a >> b;
        cout << a+b << endl;
        return 0;
    }
}


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

#define rep(i,n) for(int i=0; i<n; i++)

int main(){
  int n;
  while(true){
    cin>>n;
    if(n==0)break;
    int sum=0;
    vector<int> v;
    rep(i,n){
      int tmp;
      cin>>tmp;
      sum+=tmp;
      v.push_back(tmp);
    }
    sort(v.begin(), v.end());
    cout<<(sum-v[0]-v[n-1])/(n-2)<<endl;
  }
  return 0;
}

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

using namespace std;

int n , m , x , y , a , mn = 200 , mx = -200;

int main()
{
	cin >> n >> m >> x >> y;
	for(int i = 0 ; i < n ; i++)
	{
		cin >> a;
		mx = max(a , mx);
	}
	for(int i = 0 ; i < m ; i++)
	{
		cin >> a;
		mn = min(a , mn);
	}
	for(int i = mx + 1 ; i <= mn ; i++)
	{
		if(i <= mn && i > x && i <= y)
		{
			cout << "No War";
			return 0;
		}
	}
	cout << "War";
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define rep2(i, l, r) for (int i = (l); i < (r); i++)
#define ALL(x) (x).begin(), (x).end()     //昇順
#define RALL(x) (x).rbegin(), (x).rend()  // 降順
#define pri(x) cout << (x) << "\n"
#define pri2(x, y) cout << (x) << " " << (y) << "\n"
#define pri3(x, y, z) cout << (x) << " " << (y) << " " << (z) << "\n"
const long long mod = 1e9 + 7;
typedef long long ll;
typedef priority_queue<int> PQ;
typedef vector<long long> VL; // VL a(n);
typedef vector<bool> VB;
typedef vector<double> VD;
typedef vector<string> VS;
typedef vector<char> VC;
typedef vector<VS> VSS;
typedef vector<VC> VCC;
typedef vector<VL> VLL; // VII a(n,VI(m)) n * m
typedef pair<ll, ll> PL;
typedef map<ll, ll> MP; // MP a;
typedef vector<pair<ll, ll>> PS; // PS a(n);

template <class T, class U>
bool chmax(T &a, U b) {
  if (a <= b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T, class U>
bool chmin(T &a, U b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
template <typename T>
ostream &operator<<(ostream &os, vector<T> &v) {
  os << "{";
  rep(i, (int)v.size()) { os << v[i] << (i < v.size() - 1 ? ", " : ""); }
  os << "}";
  return os;
}

// g++ -std=c++11 prac.cpp
// operator << (cout,a);
// chmin(min,a)

// O(√n) 
bool primeNumber(int n){  
    if(n < 2) return false;
    else{
        for(int i = 2; i * i <= n; i++){
            if(n % i == 0) return false;
        }
        return true;
    }
}

int main() {
  ll n,k,m,x=0,y=0,z = 0,h=0,w=0,ans=0,sum = 0, Max = -1, Min = 3e9+1;
  string s;
  bool ok=true; 
  cin >> n;
  VL t(n+1),a(n+1),b(n+1);
  rep(i,n+1){
    if(i==0){
      t[i] = 0;
      a[i] = 0;
      b[i] = 0;
    }
    else
      cin >> t[i] >> a[i] >> b[i];
  }

  for(int i=0; i<n;i++){
    x = t[i+1]-t[i];
    y = a[i]+b[i];
    z = a[i+1]+b[i+1];
    if(x%2 != abs(y-z)%2 || x < abs(y-z)){
      pri("No");
      return 0;
    }
  }
  pri("Yes");
  return 0;
}

Measured memory_bytes: 5484
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
void fastIO(){
  ios_base::sync_with_stdio(0); cin.tie(0);
}


int main(){
  fastIO();
  int n;
  cin>>n;
  vector<int>li(n);
  map<int,bool>vis;
  for(int i=0;i<n;i++){
  	cin>>li[i];
  	vis[li[i]]=false;
  }
  for(int i=0;i<n;i++){
  	if(vis[li[i]]){
  		vis[li[i]]=false;
  	}else{
		vis[li[i]]=true;
  	}
  }
  int ans = 0;
  for(map<int,bool>::iterator it=vis.begin();it!=vis.end();it++){
  	if(it->second){
  		ans++;
  	}
  }
  cout<<ans<<endl;
}




Measured memory_bytes: 5376
#include<stdio.h>
int main()
{
	int i,n,a[200010],ans,min;
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d",&a[i]);
	}
	min=a[0];
	ans=a[1]-a[0];
	for(i=1;i<n;i++){
		if(a[i]<min) min=a[i];
		else if(a[i]-min>ans) ans=a[i]-min;
	}
	printf("%d\n",ans);
	return 0;
}



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


#define fast() ios_base::sync_with_stdio(false); cin.tie(NULL)
#define debug(i) printf("\nDebug %d\n",i);
#define mod 1000000007
#define ll long long int

int main()
{	
	fast();

	int t;
	scanf("%d",&t);
	int ar[32]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51
};
	cout<<ar[t-1];
return 0;
}

Measured memory_bytes: 256
//Problem E
#include<bits/stdc++.h>
using namespace std;
const int N=100005;
int n,a[N];
char ch[N];
#define NO {printf("-1");return 0;}
int main(){
    scanf("%s",ch+1);n=strlen(ch+1);
    for(int i=1;i<=n;i++)a[i]=ch[i]^48;
    if(a[n]||!a[1])NO
    for(int i=1;i<n;i++)if(a[i]!=a[n-i])NO
    a[n]=1;int lust=1;
    for(int i=2;i<=n;i++)if(a[i]){
        for(int j=lust+1;j<=i;j++)printf("%d %d\n",lust,j);
        if(i<n)printf("%d %d\n",lust,i+1),lust=i+1;
        
    }
    return 0;
}

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

long long xabs(long long x)
{
  if(x < 0)
   x= x*-1;
  return x;
}
int main()
{
  long long x, k, d;

  cin >> x>>k>>d;

  x = xabs(x);
  if(x>=0){
    long long _k = x/d;
    if(_k <k)k-=_k;
    else{
        cout<< xabs(x- k*d)<<endl;
        return 0;
    }
    x = x-_k*d;
    //cout<<"@@"<<k<<endl;
    if(k%2==0){
      cout<<x<<endl;
    }else{
      cout<<xabs(x-d)<<endl;
    }
  }
  return 0;
}


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

int main(void) {
	unsigned short a=0, b=0;
	cin >> a >> b;
	unsigned buf[3] = { 0 };
	buf[0] = a + (a-1);
	buf[1] = b + (b-1);
	buf[2] = a + b;
	auto bi = a > b ? buf[0]: a==b?buf[2]:buf[1];
	cout << bi << endl;
	return 0;
}

Measured memory_bytes: 256
/*
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
*/
#include <bits/stdc++.h>

#define rep(i,n)  for(int i=0; i<(n); i++)
using ll = long long;
using namespace std;

int main()
{
  int n,k;
  cin >> n >> k;
  vector<int> p(n);
  rep(i,n){
    cin >> p[i];
  }

  int dp[200100], max = 0, count = 0;
  rep(i,k){
    dp[0] += p[i];
  }

  rep(i,n-k+1){
    if(dp[i] > max){
      max = dp[i];
      count = i;
    }
    dp[i+1] = dp[i] - p[i] + p[i+k];
  }

  double ans = 0;
  rep(i,k){
    ans += (p[count+i] * (p[count+i]+1)) / (2.0*p[count+i]);
  }

  cout << std::setprecision(7) << ans;

  return 0;
}


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


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

  int a2, b2;
  int a3, b3;

  if(a % 2 == 0){
    a2 = (a * 25) / 2;
    a3 = ((a + 1) * 25) / 2;
  }
  else{
    a2 = (a * 25) / 2 + 1;
    a3 = ((a + 1) * 25) / 2 - 1;
  }

  b2 = b * 10;
  b3 = (b + 1) * 10 - 1;
  bool f = false;

  for(int i = a2; i <= a3 ; i++){
    for(int j = b2; j <= b3; j++){
      if(i == j){
        cout << i << endl;
        f = true;
        break;
      }
    }
    if(f){
      break;
    }
    if(i == a3){
      cout << -1 << endl;
    }
  }

}

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


int main(){
	int n, k, q ; 
	cin>>n>>k>>q;
	vector<int>s(n,0);
	for(int i = 0 ; i < q ; i++){
		int k ; cin>>k;
		s[k-1]++;
	}



	for(int i = 0 ; i< n ; i++){
		if(q-s[i]<k){
			cout<<"Yes"<<endl;
		}
		else{
			cout<<"No"<<endl;
		}
	}
	
	int f ; cin>>f;
	
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
const int MX = 2e5+2;
struct point {
	int x, y, i;
};
/*
0 2
1 3
*/
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> set_t;
point arr[MX];
int cnt[4][MX], p2[MX], ans;
const int MOD = 998244353;
void add(int t) {
	ans += t;
	ans %= MOD;
}
void sub(int t) {
	add(MOD-t);
}
int main() {
	ios::sync_with_stdio(0);cin.tie(0);
	int n;
	cin >> n;
	for(int i=0; i<n; i++) {
		cin >> arr[i].x >> arr[i].y;
		arr[i].i = i;
	}
	sort(arr, arr+n, [](point x, point y) { return tie(x.x, x.y) < tie(y.x, y.y);});
	set_t st;
	for(int i=0; i<n; i++) {
		int p = st.order_of_key(arr[i].y);
		cnt[1][arr[i].i] = p;
		cnt[0][arr[i].i] = st.size()-p;
		st.insert(arr[i].y);
	}
	st.clear();
	for(int i=n-1; i>=0; i--) {
		int p = st.order_of_key(arr[i].y);
		cnt[3][arr[i].i] = p;
		cnt[2][arr[i].i] = st.size()-p;
		st.insert(arr[i].y);
	}
	p2[0] = 1;
	for(int i=1; i<=n; i++) {
		p2[i] = p2[i-1]*2;
		p2[i] %= MOD;
	}
	for(int i=0; i<n; i++) {
		add(p2[n]-1);
		sub(p2[cnt[0][i]+cnt[1][i]]);
		sub(p2[cnt[0][i]+cnt[2][i]]);
		sub(p2[cnt[2][i]+cnt[3][i]]);
		sub(p2[cnt[1][i]+cnt[3][i]]);
		for(int j=0; j<4; j++) {
			add(p2[cnt[j][i]]);
		}
	}
	cout << ans;
}

Measured memory_bytes: 15872
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#include<string.h>
char s1[100000];
char s2[100000];
int main()
{
    ll  a,b,c,d,e,j,k,l,test;
    char s;
    cin>>s;
    printf("%c\n",s+1);
    return 0;

}


Measured memory_bytes: 256
package main

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

var (
	input  = bufio.NewScanner(os.Stdin)
	tokens []string
)

// genTokens generates tokens from the input, and puts it into the tokens array.
func genTokens() {
	if !input.Scan() {
		panic("No more input")
	}

	nextFields := strings.Fields(input.Text())
	tokens = append(tokens, nextFields...)
}

// nextInt returns next int in its input, or panics if no input.
func nextInt() int {
	if len(tokens) == 0 {
		genTokens()
	}
	if len(tokens) == 0 {
		panic("No more input")
	}

	next := tokens[0]
	tokens = tokens[1:]

	ret, err := strconv.Atoi(next)
	if err != nil {
		panic(err)
	}
	return ret
}

// nextInt64 returns next int in its input, or panics if no input.
func nextInt64() int64 {
	if len(tokens) == 0 {
		genTokens()
	}
	if len(tokens) == 0 {
		panic("No more input")
	}

	next := tokens[0]
	tokens = tokens[1:]

	ret, err := strconv.ParseInt(next, 10, 64)
	if err != nil {
		panic(err)
	}
	return ret
}

// next returns the next string separated by spaces, or panics if no input.
func next() string {
	if len(tokens) == 0 {
		genTokens()
	}
	if len(tokens) == 0 {
		panic("No more input")
	}

	next := tokens[0]
	tokens = tokens[1:]

	return next
}

func main() {
	n := nextInt()
	for i := 1; i <= 9; i++ {
		for j := 1; j <= 9; j++ {
			if n == i * j {
				fmt.Println("Yes")
				return
			}
		}
	}
	fmt.Println("No")
}


Measured memory_bytes: 640
#include <iostream>
#include <cstdio>
#include <vector>
#include <cmath>
#include <cstring>
#include <numeric>
#include <algorithm>
#include <functional>
#include <array>
#include <map>
#include <queue>
#include <limits.h>
#include <set>
#include <stack>
#include <random>
#include <complex>
#define rep(i,s,n) for(int i = (s); (n) > i; i++)
#define REP(i,n) rep(i,0,n)
#define RANGE(x,a,b) ((a) <= (x) && (x) <= (b))
#define DUPLE(a,b,c,d) (RANGE(a,c,d) || RANGE(b,c,d) || RANGE(c,a,b) || RANGE(d,a,b))
#define INCLU(a,b,c,d) (RANGE(a,c,d) && (b,c,d))
#define PW(x) ((x)*(x))
#define ALL(x) (x).begin(), (x).end()
#define MODU 1000000007
#define bitcheck(a,b)   ((a >> b) & 1)
#define bitset(a,b)      ( a |= (1 << b))
#define bitunset(a,b)    (a &= ~(1 << b))
#define MP(a,b) make_pair((a),(b))
#define Manh(a,b) (abs((a).first-(b).first) + abs((a).second - ((b).second))
using namespace std;
typedef pair<int, int> pii;
typedef long long ll;

const pii Dir[8] = { //?????????
	{ 0,1 },{ 1,0 },{ 0,-1 },{ -1,0 },
	{ 1,1 },{ 1,-1 },{ -1,-1 },{ -1,1 }
};
template<typename A, size_t N, typename T>
void Fill(A(&array)[N], const T &val) {
	std::fill((T*) array, (T*) (array + N), val);
}

signed main() {
	int a, b, n;
	while (scanf("%d %d", &a, &b)) {
		if (a == 0)
			break;
		scanf("%d", &n);
		set<pii> st;
		REP(i, n) {
			pii cur;
			scanf("%d %d", &cur.first, &cur.second);

			st.insert(cur);
		}

		ll dp[17][17] = {};
		dp[1][1] = 1;


		for (int i = 2; a + b > i; i++) {
			rep(j, 1, a + 1) {
				if (dp[j][i - j]) {
					if (j + 1 <= a) {
						if (st.find({ j + 1, i - j }) == st.end())
							dp[j + 1][i - j] += dp[j][i - j];
					}
					if (i - j + 1 <= b) {
						if (st.find({ j, i - j + 1 }) == st.end())
							dp[j][i - j + 1] += dp[j][i - j];
					}
				}
			}
		}


		printf("%lld\n", dp[a][b]);
	}
	return 0;
}

Measured memory_bytes: 3136
using System;
using System.Collections.Generic;
class Program
{
	static void Main(string[] args)
	{
        // マップの作成
        List<char> acgt = new List<char>(){ 'A', 'C', 'G', 'T' };

		// 入力読み込み
        string s = Console.ReadLine();

		// 出力
		string temp = "";
		string max = "";
		int index = 0;
		// charの確認
		foreach(char c in s)
		{
			index++;
			if (acgt.Contains(c))
			{
				temp += c;

				// 末尾
				if (index == s.Length &&
					temp.Length > max.Length)
				{
					max = temp;
				}
			}
			else
			{
				if (temp.Length > max.Length)
				{
					max = temp;
				}

				temp = "";			
			}
		}
		//出力
		Console.WriteLine(max.Length);
	}
}

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

using namespace std;

inline char shift(char c, int i) {
  return char(((c + i) - 'a') % 26 + 'a');
}

int main() {
  string str;
  while (getline(cin, str)) {
    int n;
    for (int i = 0; i < 26; ++i) {
      string target;
      for (char c : str) {
        if ('a' <= c && c <= 'z')
          target += shift(c, i);
        else
          target += c;
      }
      for (string key : {"the", "this", "that"}) {
        size_t pos = target.find(key);
        if (pos != string::npos) {
          n = i;
          str = target;
          goto found;
        }
      }
    }

found:
    cout << str << endl;
  }
}

Measured memory_bytes: 1192