akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<cstdio>
#include<cstdlib>
#include<queue>
#include<list>
#include<deque>
#include<cmath>
#include<unordered_map>
#include<unordered_set>
#include<numeric>

using namespace std;

using ll = int64_t;

/// <summary>
/// 単純なcoutの時に使う
/// </summary>
#define co(a) cout<<a<<"\n"


/// <summary>
/// [beg, end)の範囲を，添え字indexでループするfor文に置換します
/// </summary>
#define rep(i,a) for(ll i=0; i<a; ++i)
#define reps(i, a, b) for(ll i = a; i < b; ++i)

/// <summary>
/// 迷路等で使う方向のベクトル
/// </summary>
const vector<ll> dx = { 0, 1, 0, -1 }, dy = { 1, 0, -1, 0 };

/// <summary>
/// デバッグ時に使う
/// </summary>
#define DEBUG(x)     std::cout << #x << " : " << x << "\n"

///////////////////////////////////////////////////////////////////////////

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

	vector<ll> A (N + 1);

	rep (i, N + 1) {
		cin >> A[i];
	}

	vector<ll> B (N);

	rep (i, N) {
		cin >> B[i];
	}

	ll ans = 0;
	rep (i, N) {
		if (A[i] >= B[i]) {
			ans += B[i];
			continue;
		}

		ans += A[i];

		ll hoge = B[i] - A[i];

		if (A[i + 1] >= hoge) {
			A[i + 1] -= hoge;
			ans += hoge;
		}
		else {
			ans += A[i + 1];
			A[i + 1] = 0;
		}
	}

	cout << ans << endl;
}



Measured memory_bytes: 1792
/* Simplicity and Goodness */

#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>

// using namespace __gnu_pbds;
using namespace std;
// typedef tree<int, null_type, less<int>, rb_tree_tag,
//             tree_order_statistics_node_update> indexed_set;

void my_dbg() { cout << endl; }
template<typename Arg, typename... Args> void my_dbg(Arg A, Args... B)
{ cout << ' ' << A; my_dbg(B...); }
#define dbg(...)  cout << "(" << #__VA_ARGS__ << "):", my_dbg(__VA_ARGS__)

#define scn(n) scanf("%d", &n)
#define lscn(n) scanf("%lld", &n)
#define pri(n) printf("%d ", (int)(n))
#define prin(n) printf("%d\n", (int)(n))
#define lpri(n) printf("%lld ", n)
#define lprin(n) printf("%lld\n", n)
#define rep(i,a,b) for(int i=(int)(a); i<(int)(b); i++)
#define pb push_back
#define mp make_pair
#define F first
#define S second

using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;

const int inf = INT_MAX;
const int ninf = INT_MIN;
const int mod = 1e9+7;
const int N = 3e3+2;

/* dp[i][j] : Longest common subsequence using first i chars in s and first j chars in t
*/
int dp[N][N];

void solve()
{
    string s, t;
    cin >> s >> t;

    dp[0][0] = 0;

    rep(i, 1, s.size() + 1) {
        rep(j, 1, t.size() + 1) {
            if(s[i-1] == t[j-1]) {
                dp[i][j] = 1 + dp[i-1][j-1];
            } else {
                dp[i][j] = max(dp[i-1][j], dp[i][j-1]);
            }
        }
    } 

    int i = (int) s.size(), j = (int) t.size();

    string ts = "";

    while(i and j) {
        if(dp[i][j] > dp[i-1][j] and dp[i][j] > dp[i][j-1]) {
            ts += s[i-1];
            i --; j --;
        } else if(dp[i][j] == dp[i-1][j]) {
            i --;
        } else {
            j --;
        }
    }

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

    cout << ts << '\n';
}   

int main()
{
    int t = 1;
    // scn(t);
    
    while(t --) {
        solve();
    }
    return 0;
}

Measured memory_bytes: 38776
import re
S = str(input())
T = str(input())
S = S.replace("?",".")

for i in range(len(S)-len(T),-1,-1):
  if re.match(S[i:i+len(T)],T):
    S = S.replace('.','a')
    print(S[:i]+T+S[i+len(T):])
    exit()

print('UNRESTORABLE')


Measured memory_bytes: 3188
#include <iostream>
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
int main(void){
    ll n; cin >> n;
    ll tmp = n;
    if(n%2==1)cout<<0<<endl;
    else{
        ll sum = 0;
        sum += n/10;
        n/=10;
        ll base = 5LL;
        //cout << n << "," <<base << endl;
        while(n/base>=1){
            sum += n/base;
            base *= 5;
        }
        cout << sum << endl;
    }
}



Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;


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

    public void solve(String[] args) {
        MyScanner scanner = new MyScanner();
        int x = scanner.nextInt();
        int t = scanner.nextInt();
        if (t>x) {
        	System.out.println(0);
        }else {
        	System.out.println(x-t);
        }




    }

    private class MyScanner {
        String[] s;
        int i;
        BufferedReader br;
        String reg = " ";
        MyScanner () {
            s = new String[0];
            i = 0;
            br = new BufferedReader(new InputStreamReader(System.in));
        }
        public String next() {
            try {
                if (i < s.length) return s[i++];
                String line = br.readLine();
                while (line.equals("")) {line = br.readLine();}
                s = line.split(reg, 0);
                i = 0;return s[i++];
            } catch (Exception e) {e.printStackTrace();}
            return null;
        }
        public int nextInt() {
            try {return Integer.parseInt(next());} catch (Exception e) {e.printStackTrace();}
            return -1;
        }
        public double nextDouble() {
            try {return Double.parseDouble(next());} catch (Exception e) {e.printStackTrace();}
            return -1;
        }
        public long nextLong()  {
            try {return Long.parseLong(next());} catch (Exception e) {e.printStackTrace();}
            return -1;
        }
    }
}

Measured memory_bytes: 23120
package main

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

var (
	sc = bufio.NewScanner(os.Stdin)
)

func main() {
	for sc.Scan() {
		chunks := strings.Split(sc.Text(), " ")
		a, _ := strconv.Atoi(chunks[0])
		b, _ := strconv.Atoi(chunks[1])
		fmt.Println(len(fmt.Sprint(a + b)))
	}
}

Measured memory_bytes: 1076
N, M, X = [int(i) for i in input().split()]
CA = []
for i in range(N):
    CA.append([int(j) for j in input().split()])
#print(CA)
mcost = 10**10


for i in range(2**N):
    learn = [0]*M
    cost = 0
    bn = str(bin(i))[2:].zfill(N)
    #print(bn)
    for j,b in enumerate(bn):
        if b == "1":
            cost += CA[j][0]
            for m in range(M):
                learn[m] += CA[j][m+1]
                
    learn.sort()
    #print(learn)
    if learn[0] >= X:
        mcost = min(mcost, cost)

if mcost == 10**10:
    mcost = -1

print(mcost)

Measured memory_bytes: 9192
# -*- coding: utf-8 -*-
import sys
import math
from bisect import bisect_left
from bisect import bisect_right
from collections import defaultdict
from heapq import heappop, heappush
import itertools
import random
from collections import deque
from decimal import *
import queue

input = sys.stdin.readline

def inputInt(): return int(input())
def inputMap(): return map(int, input().split())
def inputList(): return list(map(int, input().split()))
def inputStr(): return input()[:-1]

inf = float('inf')
mod = 1000000007

#-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
#-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-

def main():
	N = inputInt()
	A = inputList()

	A.sort()
	A = A[::-1]

	ansans = []
	pgt = queue.Queue()
	for i,val in enumerate(A):
		if i == 0:
			pgt.put(val)
		else:
			tmp = pgt.get()
			ansans.append(tmp)
			pgt.put(val)
			pgt.put(val)

	print(sum(ansans))


#-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
#-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
if __name__ == "__main__":
	main()


Measured memory_bytes: 117580
#include<bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
using LL = long long;
const LL LINF = 1e18;
using namespace std;
#define COUT(v) cout<<(v)<<endl
#define CIN(n)  int(n);cin >> (n)
#define SCIN(n) string(n);cin >> (n)
#define YES(n) cout<<((n)? "YES" : "NO")<<endl
#define Yes(n) cout<<((n)? "Yes" : "No")<<endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE"  ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) <<endl

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

#define FOREACH(x,a) for(auto& (x) : (a) )

#define ALL(obj) (obj).begin(),(obj).end()

#define P pair<int,int>
#define I vector<int>
#define S set<int>
#define pb(v) push_back(v)
#define V vector
#define rt return
#define rmsame(a) sort(ALL(a)),a.erase(unique(ALL(a)), a.end())

class Edge{
public:
    int from,to,value;
    Edge(int a,int b,int c){
        from = a;
        to = b;
        value = c;
    }
    Edge(int a,int b){
        from = a;
        to = b;
    }
};

int main(){
    CIN(N);
    COUT(N/1000==1?"ABD":"ABC");
    return 0;
}


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

using namespace std;


int main(){
  string S;
  cin >> S;
  int length = S.length();
  int cnt = 0;
  // cout << length << endl;
  for(int i = 0; i < length; i++){
    if(S.substr(i,1) == "o") cnt++;
  }
  if(15 - length + cnt >= 8) cout << "YES"  << endl;
  else cout << "NO" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
const int INF=1145141919,MOD=1e9+7;
const long long LINF=8931145141919364364,LMOD=998244353;
// const int dx[]={1,0,-1,0,1,1,-1,-1},dy[]={0,-1,0,1,1,-1,-1,1};

int main(){
    int n; cin>>n;
    long long a,b; cin>>a>>b;
    long long x[n]; rep(i,n) cin>>x[i];
    long long ans=0;
    for(int i=1;i<n;i++){
        ans+=min(a*(x[i]-x[i-1]),b);
    }
    cout<<ans<<endl;
    return 0;
}


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

int n,K,arr[2][6001][2001];

int d[2][3]={{0,2,4},{1,3,5}};
void add(int idx,int x,int y) {
    for(int i=0;i<2;i++) {
        for(int j=0;j<3;j++) {
            arr[idx][(y+d[i][j]*K)%(6*K)+1][(x+i*K)+1]++;
        }
    }
}
int sum(int idx,int y1,int x1,int y2,int x2) {
    return arr[idx][y2][x2]-arr[idx][y1-1][x2]-arr[idx][y2][x1-1]+arr[idx][y1-1][x1-1];
}
int main() {
    scanf("%d%d",&n,&K);
    for(int i=0;i<n;i++) {
        int x,y;
        char ch;
        scanf("%d %d %c",&x,&y,&ch);
        y%=2*K; x%=2*K;
        if( (y<K && x<K) || (y>=K && x>=K)){
            y%=K;x%=K;
        } else {
            y%=K; x%=K; y+=K;
        }

        if(ch=='W') add(0,x,y);
        else add(1,x,y);
    }

    for(int i=1;i<=4*K;i++)for(int j=1;j<=2*K;j++) {
        for(int k=0;k<2;k++) arr[k][i][j] += arr[k][i-1][j]+arr[k][i][j-1] - arr[k][i-1][j-1];
    }
    
    int ans=0;
    for(int i=1;i<=2*K;i++) for(int j=1;j<=K+1;j++) {
        ans = max(ans, sum(0,i,j,i+K-1,j+K-1) + sum(1,i+K,j,i+2*K-1,j+K-1));
    }
    printf("%d\n",ans);

    return 0;
}


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

using namespace std;
typedef long long ll;
typedef pair<int, int> pair2;
typedef pair<int, pair<int, int> > pair3;
typedef pair<int, pair<int, pair<int, int > > > pair4;
#define MAXN 200013
#define INF 1000000000000000000LL
#define MOD 1000000007LL
#define IINF 1000000000
#define mp make_pair
#define pb push_back
#define all(x) x.begin(), x.end()

int order[MAXN];

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

	int n;

	cin >> n;

	for (int i = 0; i < n; i++) {
		int v;
		cin >> v;

		order[v] = i + 1;
	}

	for (int i = 1; i <= n; i++) {
		cout << order[i] << ' ';
	}
	cout << endl;
}

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

int main() {
	int n;
	cin >> n;
	vector<int> a(n), b(n), c(n-1);
	rep(i, n) {
		int A;
		cin >> A;
		A--;
		a[i] = A;
	}
	rep(i, n) cin >> b[i];
	rep(i, n - 1) cin >> c[i];
	
	int ans = 0;
	int mem = -2;
	rep(i, n) {
		ans += b[a[i]];
		if (a[i] == mem + 1) {
			ans += c[mem];
		}
		mem = a[i];
	}

	cout << ans << endl;
}

Measured memory_bytes: 256
import math
K = int(input())

ans = 0

for i in range(K):
    for j in range(i+1):
        for k in range(j+1):
            a, b, c = i+1, j+1, k+1
            gcd = math.gcd(math.gcd(a, b), c)
            if a != b and b != c and a != c:
                ans += gcd*6
            elif a == b == c:
                ans += gcd
            elif a==b or b==c or a==c:
                ans += gcd*3


print(ans)

Measured memory_bytes: 9072
#include <stdlib.h>
#include <string>
#include <vector>
#include <algorithm>
#include <iostream>


/*
	HOME-  Volume0-0008
	Submit Statistics
	 
	PCK 2003
	Sum of 4 Integers
	Time Limit : 1 sec, Memory Limit : 32768 KB
	English version is here

	Sum of 4 Integers

	50 ÈºÌ³Ì® n ðüÍµA0 ` 9 ÌÍÍÌ® a, b, c, d ÌgÅ

	        a + b + c + d = n

	ð½·àÌÌgÝí¹ðoÍ·évOðì¬µÄº³¢B

	á¦ÎAn ª 35 ÌÆ«A(a, b, c, d) Í (8,9,9,9)A(9,8,9,9)A(9,9,8,9)A(9,9,9,8) Ì 4 ÊèÅ·ÌÅA¦Í 4 ÆÈèÜ·B
	Input

	¡Ìf[^Zbgª^¦çêÜ·Bef[^ZbgÉ n ªPsÉ^¦çêÜ·BüÍÌÅãÜÅµÄº³¢B
	Output

	ef[^Zbg²ÆÉAa, b, c, d ÌgÝí¹ÂðPsÉoÍµÄº³¢B
	Sample Input

	35
	1

	Output for the Sample Input

	4
	4
*/

using namespace std;


int main()
{
	string s;
	
	while (getline(cin, s))
	{
		int n;
		sscanf(s.c_str(), "%ld", &n);
		
		int x = 0;
		for (int a = 0; a <= 9; a++)
		for (int b = 0; b <= 9; b++)
		for (int c = 0; c <= 9; c++)
		for (int d = 0; d <= 9; d++)
		{
			if (n == (a + b + c + d))
			{
				x++;
			}
		}
		
		printf("%d\n", x);
	}

	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr ll MOD = 1e9 + 7;
//constexpr ll MOD = 998244353;
//constexpr ll MOD = ;
ll mod(ll A, ll M) {return (A % M + M) % M;}
constexpr ll INF = 1LL << 60;
template<class T> bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template<class T> bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
ll divceil(ll A, ll B) {return (A + (B - 1)) / B;}
#define FINALANS(A) do {cout << (A) << '\n'; exit(0);} while (false)

int main()
{
  ll A, P;
  cin >> A >> P;

  P += 3 * A;
  cout << P / 2 << endl;
}

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

ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
constexpr int mod = 1e9 + 7;

struct mint {
  ll x; // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint &operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint &operator-=(const mint a) {
    if ((x += mod - a.x) >= mod) x -= mod;
    return *this;
  }
  mint &operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res -= a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res *= a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1) a *= *this;
    return a;
  }
  mint inv() const { return pow(mod - 2); }
  mint &operator/=(const mint a) { return (*this) *= a.inv(); }
  mint operator/(const mint a) const {
    mint res(*this);
    return res /= a;
  }
  friend ostream &operator<<(ostream &os, const mint &a) { return (os << a.x); }
};
struct combination {
  vector<mint> fact, ifact;
  combination(int n) : fact(n + 1), ifact(n + 1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i - 1] * i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i - 1] = ifact[i] * i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n] * ifact[k] * ifact[n - k];
  }
};

int main() {
  int x, y, z;
  cin >> x >> y >> z;
  cout << z << " " << x << " " << y << endl;
}


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

vector<bool> v;

void outputprime(int n){ // vector is used
	v.push_back(false);
	v.push_back(false);
	for(int i = 2; i <= n; i++){
		v.push_back(true);
	}
	for(int i = 2; i*i <= n; i++){
		if (v[i] == false){
			continue;
		} else{
			for (int j = 2*i; j <= n; j+=i){
				v[j] = false;
			}
		}
	}
	int num = 0;
	for(int i = 2; i <= n; i++){
		if (v[i]){
			num++;
		}
	}
}

long long N, ans, a[10005];
vector<int> num;
int main() {
	scanf("%lld", &N);
	outputprime(1000007);
	for (int i = 0; i < 10000; i++) {
		a[i] = i * (i + 1) / 2;
	}
	long long time = 1;
	//cout << "!" << endl;
	for (long long i = 1; i * i <= N; i++) {
		//cout << i << endl;
		if (v[i]) {
			//cout << i << endl;
			//cout << i << endl;
			num.push_back(0);
			long long temp = N;
			while(temp % i == 0) {
				num.back() = num.back() + 1;
				temp = temp / i;
				time = time * i;
			}
		}
		//cout << i << endl;
	}
	//cout << "@" << endl;
	if (time != N) {
		num.push_back(1);
	}
	for (auto x:num) {
		int temp = upper_bound(a, a + 10000, x) - a - 1;
		ans += temp;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 4116
A,B = [int(x) for x in input().split()]
K = 50
h,w = 2*K,2*K
cntA = A-1
cntB = B-1
print(h,w)
for i in range(h):
    pr = ''
    if(i<K):
        for j in range(w):
            if(cntA>0):
                if((i%2==0 and j%2==0)):
                    pr += '.'
                    cntA -= 1
                else:
                    pr += '#'
            else:
                pr += '#'
    else:
        pr = ''
        for j in range(w):
            if(cntB>0 and i>K):
                if((i%2==0 and j%2==0)):
                    pr += '#'
                    cntB -= 1
                else:
                    pr += '.'
            else:
                pr += '.'
    print(pr)


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

using namespace std;
long long a[200005];
long long cnt[200005];
long long ans=0;
const long long MOD=1e9+7;
int main(){
	int n;
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>a[i];
	}
	cnt[1]=a[1];
	for(int i=2;i<=n;i++){
		cnt[i]=(cnt[i-1]+a[i])%MOD;
	}
	for(int i=1;i<=n;i++){
		ans+=a[i]%MOD*(cnt[n]-cnt[i])%MOD;
		ans=ans%MOD;
	}
	cout<<(ans+MOD)%MOD;
	return 0;
}

Measured memory_bytes: 6684
N = input()
A = list(map(int, input().split()))
flag = 0
for a in A:
  if(a % 2 == 0):
    if( not(a % 3 == 0 or a % 5 == 0)):
      print('DENIED')
      flag = 1
      break
if(flag == 0):
  print('APPROVED')
      

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

typedef long long ll;
typedef long double ld;
typedef vector<vector<int>> Graph;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
#define pi 3.14159265359
#define inf 2147483647
#define INF 9223372036854775807
#define mod 1000000007
#define mod2 998244353

int main() {
	int sx, sy, tx, ty; cin >> sx >> sy >> tx >> ty;
	string ans;
	int r = tx - sx, u = ty - sy;
	for(int i = 0; i < u; i++) ans += 'U';
	for(int i = 0; i < r; i++) ans += 'R';
	for(int i = 0; i < u; i++) ans += 'D';
	for(int i = 0; i <= r; i++) ans += 'L';
	for(int i = 0; i <= u; i++) ans += 'U';
	for(int i = 0; i <= r; i++) ans += 'R';
	ans += "DR";
	for(int i = 0; i <= u; i++) ans+= 'D';
	for(int i = 0; i <= r; i++) ans+= 'L';
	ans += 'U';
	cout << ans << endl;
	return 0;
}


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

typedef long long ll;

#define optimize() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define file() freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define tt int t; cin>>t; while(t--)
#define nl cout<<"\n";
#define sp cout<<" ";
#define rep(i, a, b) for(long long i=a; i<b; i++)

const int INF = 1e9 + 7;
const int MOD = 1e9 + 7;
double PI = 4*atan(1);

int main()
{
    optimize();

    int n;
    cin>> n;

    int p[n], sum= 0;

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

    sum-= (*max_element( p, p+n))/2;

    cout << sum;
    nl;

    return 0;
}

Measured memory_bytes: 3596
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif


using namespace std;

// #define int long long
struct Fast {Fast(){std::cin.tie(0);ios::sync_with_stdio(false);}} fast;

inline bool inside(int y, int x, int H, int W) {return y >= 0 && x >= 0 && y < H && x < W;}
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

const int MOD = 1e9 + 7;
const int INF = INT_MAX;

signed main() {
    Fast();

    int n, i;
    cin >> n >> i;
    cout << (n - i + 1) << endl;
    return 0;
}








Measured memory_bytes: 888
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

#define pb push_back
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define debug(x) cerr << #x << " : " << x << '\n'

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;
typedef string str;
typedef pair<ll, ll> pll;
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

const ll Mod = 1000000007LL;
const int Maxn = 2e5 + 10;
const ll Inf = 2242545357980376863LL;
const ll Log = 30;

set<ll> st;
ll a[Maxn];
ll cnt[Maxn];

int main(){
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	ll n, k;
	cin >> n >> k;
	for(int i = 1; i <= n; i++) cin >> a[i];
	a[n + 1] = -1;
	for(int i = 1; i < k; i++) st.insert(a[i]);
	ll ans = 0; ll t = 10;
	ll cnt = 1;
	for(int i = 2; i < k; i++){
		if(a[i] > a[i - 1]) cnt ++;
		else cnt = 1;
	}
	ll fl = 0;
	for(int i = 1; i + k - 1 <= n; i++){
		if(a[i + k - 1] > a[i + k - 2]) cnt ++;
		else cnt = 1;
		st.insert(a[i + k - 1]);
		if(cnt < k){
			if((*st.begin()) == a[i] && (*st.rbegin()) < a[i + k]) t++;
			else ans ++; 
		} else {
			fl = 1;
		}
		st.erase(a[i]);
	}
	cout << ans + fl;
	return 0; 
}

/*

                                 ____              ,----..               ,----..
   ,---,                       ,'  , `.           /   /   \             /   /   \
  '  .' \                   ,-+-,.' _ |          /   .     :           /   .     :
 /  ;    '.              ,-+-. ;   , ||         .   /   ;.  \         .   /   ;.  \
:  :       \            ,--.'|'   |  ;|        .   ;   /  ` ;        .   ;   /  ` ;
:  |   /\   \          |   |  ,', |  ':        ;   |  ; \ ; |        ;   |  ; \ ; |
|  :  ' ;.   :         |   | /  | |  ||        |   :  | ; | '        |   :  | ; | '
|  |  ;/  \   \        '   | :  | :  |,        .   |  ' ' ' :        .   |  ' ' ' :
'  :  | \  \ ,'        ;   . |  ; |--'         '   ;  \; /  |        '   ;  \; /  |
|  |  '  '--'          |   : |  | ,             \   \  ',  /          \   \  ',  /
|  :  :                |   : '  |/               ;   :    /            ;   :    /
|  | ,'                ;   | |`-'                 \   \ .'              \   \ .'
`--''                  |   ;/                      `---`                 `---`
                       '---'

*/


Measured memory_bytes: 11264
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
    const long long p = pow(10,18);
    int n;
    cin >> n;
    ll a[n];
    ll ans = 1;
    for(int i = 0; i < n; i++){
        cin >> a[i];
        if(a[i] == 0)
            ans = 0;
    }
    if(ans == 0){
        cout << '0' << endl;
        return 0;
    }
    ll q = 0;
    for(int i = 0; i < n; i++){
        ans *= a[i];
        if(ans > p || ans < q){
            cout << "-1" << endl;
            return 0;
        }
        q = ans;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4372
import std.stdio, std.array, std.string, std.conv, std.algorithm;
import std.typecons, std.range, std.random, std.math, std.container;
import std.numeric, std.bigint, core.bitop, std.bitmanip;

void main() {
    auto s = readln.split.map!(to!int);
    auto N = s[0];
    auto M = s[1];
    auto A = readln.split.map!(to!long).array;
    auto B = N.iota.map!(_ => readln.split.map!(to!long).array).array;
    auto C = new long[](N);
    foreach (i; 0..N-1) C[i+1] = C[i] + A[i];
    
    auto table = new long[][](N+1, N+1);
    auto st = new SegmentTree!(Tuple!(long, int), (a, b) => max(a, b), tuple(-(1L<<59), -1))(N);
    auto stack = new Tuple!(int, int)[](N+10);

    foreach (m; 0..M) {
        foreach (i; 0..N) st.assign(i, tuple(B[i][m], i));
        stack[0] = tuple(0, N-1);
        int sp = 0;
        while (sp >= 0) {
            auto l = stack[sp][0];
            auto r = stack[sp][1];
            sp -= 1;
            auto t = st.query(l, r);
            auto v = t[0];
            auto p = t[1];
            table[l][p] += v;
            table[l][r+1] -= v;
            table[p+1][p] -= v;
            table[p+1][r+1] += v;
            if (l <= p-1) stack[++sp] = tuple(l, p-1);
            if (r >= p+1) stack[++sp] = tuple(p+1, r);
        }
    }

    long ans = 0;
    foreach (i; 0..N) foreach (j; 0..N) table[i][j+1] += table[i][j];
    foreach (j; 0..N) foreach (i; 0..N) table[i+1][j] += table[i][j];
    foreach (i; 0..N) foreach (j; i..N) ans = max(ans, table[i][j] - C[j] + C[i]);
    ans.writeln;
}


class SegmentTree(T, alias op, T e) {
    T[] table;
    int size;
    int offset;

    this(int n) {
        assert(bsr(n) < 29);
        size = 1 << (bsr(n) + 2);
        table = new T[](size);
        fill(table, e);
        offset = size / 2;
    }

    void assign(int pos, T val) {
        pos += offset;
        table[pos] = val;
        while (pos > 1) {
            pos /= 2;
            table[pos] = op(table[pos*2], table[pos*2+1]);
        }
    }

    T query(int l, int r) {
        return query(l, r, 1, 0, offset-1);
    }

    T query(int l, int r, int i, int a, int b) {
        if (b < l || r < a) {
            return e;
        } else if (l <= a && b <= r) {
            return table[i];
        } else {
            return op(query(l, r, i*2, a, (a+b)/2), query(l, r, i*2+1, (a+b)/2+1, b));
        }
    }
}

Measured memory_bytes: 221564
#include<iostream>
#include<cmath>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<cassert>

#define REP(i,s,n) for(int i=s;i<n;i++)
#define rep(i,n) REP(i,0,n)
#define inf (1<<29)
#define EPS (1e-10)
#define COUNTER_CLOCKWISE 1
#define CLOCKWISE -1 
#define ONLINE_BACK 2
#define ONLINE_FRONT -2
#define ON_SEGMENT 0
#define equals(a,b) (fabs((a)-(b)) < EPS)

using namespace std;

//

class Point
{
  public:
  double x,y;

  Point(double x = -1,double y = -1): x(x),y(y){}

  Point operator + (Point p ){return Point(x+p.x,y+p.y);}
  Point operator - (Point p){return Point(x-p.x,y-p.y);}
  Point operator * (double a){return Point(a*x,a*y);}
  Point operator / (double a){return Point(x/a,y/a);}//※イケメンに限る

  bool operator < (const Point& p) const
  { return x != p.x?x<p.x:y<p.y; }

  bool operator == (const Point& p)const
  { return fabs(x-p.x) < EPS && fabs(y-p.y) < EPS; }

};

struct Segment
{
  Point p1,p2;
  Segment(Point p1 = Point(-1,-1),Point p2 = Point(-1,-1)):p1(p1),p2(p2){}
};

typedef Point Vector;
typedef Segment Line;
typedef vector<Point> Polygon;

ostream& operator << (ostream& os,const Point& a)
{
  os << "(" << a.x << "," << a.y << ")";
}

double dot(Point a,Point b){ return a.x*b.x + a.y*b.y; }

double cross(Point a,Point b){ return a.x*b.y - a.y*b.x; }

double norm(Point a){ return a.x*a.x+a.y*a.y; }

double abs(Point a){ return sqrt(norm(a)); }

Point rotate(Point a,double rad){ return Point(cos(rad)*a.x - sin(rad)*a.y,sin(rad)*a.x + cos(rad)*a.y); }

double toRad(double agl){ return agl*M_PI/180.0; }

//

struct Node
{
  Point p;
  double v;
  Node(Point p=Point(),double v=inf):p(p),v(v){}
};

int N;

void compute(vector<Node> &vec)
{
  Point cur = vec[0].p;
  //cout << "(" << cur.x << "," << cur.y << ")\n";
  double eps = 0.99,d = 10000;
  double mdist;
  while(d > EPS)
    {
      int index = -inf;
      mdist = -inf;
      rep(j,vec.size())
	{
	  double dist = abs(vec[j].p-cur) / vec[j].v;
	  if(!equals(mdist,dist) && mdist < dist)
	    {
	      mdist = dist;
	      index = j;
	    }
	}
      
      Vector dept = vec[index].p - cur;
      dept = (dept/abs(dept)) * d;
      cur = cur + dept;
      d *= eps;
    }

  cout << setiosflags(ios::fixed) << setprecision(10) << mdist << endl;

}

int main()
{
  while(cin >> N,N)
    {
      vector<Node> vec(N);
      rep(i,N)cin >> vec[i].p.x >> vec[i].p.y >> vec[i].v;
      compute(vec);
    }
  return 0;
}

Measured memory_bytes: 1292
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double dd;
const int mod=1e9+7;
const int N = 1e5+5;

int n,k,x,y,ans;

int main(){
  // freopen("input.txt","r",stdin);
  cin>>n>>k>>x>>y;
  for(int i = 1;i <= k && i <= n;i++){
    ans += x;
  }
  for(int i = k+1;i <= n;i++) ans += y;
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(void)
{
  int a,b,f,s,gcd,lcm,temp;
  
  while(1){
    
    
    if(scanf("%d %d",&a,&b)==EOF)
      return(0);
  
    if(a<b){
      f=b;s=a;}
    else{
      f=a;s=b;}
    while(f%s!=0){
      
      temp=f%s;
      f=s;
      s=temp;
    }
    gcd=s;
    lcm = a/gcd*b;
    printf("%d %d\n",gcd,lcm);
  }
  return(0);

}
  

Measured memory_bytes: 592
/**
 * @copyright (c) 2020 Daisuke Hashimoto
 */

#include <bits/stdc++.h>
using namespace std;
using Pair = pair<int64_t, int64_t>;
constexpr int64_t kInf = INT64_MAX / 2L;

// std::cout << std::setprecision(20) << 1.1 << endl;

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

  int64_t N;
  cin >> N;
  bool is_okay = false;
  while(N>0) {
    if(N%10 == 7) {
    is_okay = true;
    }
    N/=10;
  }
  if(is_okay) {
  cout << "Yes" << endl;
  } else {
  cout << "No" << endl;
  }

  return 0;
}


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

using namespace std;

// input
int n,k;

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

    cin >> n >> k;

    if(n % k == 0){
        cout << 0 << "\n";
    }
    else{
        cout << 1 << "\n";
    }


    
}

Measured memory_bytes: 256
import itertools
N,M=map(int,input().split())
edges={tuple(sorted(map(int,input().split()))) for i in range(M)}
ans=0
for i in itertools.permutations(range(2,N+1),N-1):
    l=[1]+list(i)
    ans+=sum(1 for edge in zip(l,l[1:]) if tuple(sorted(edge)) in edges)==N-1
print(ans)

Measured memory_bytes: 9044
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <queue>
#include <list>
#include <cmath>
#include <stack>
#include <iomanip>

using namespace std;
typedef long long ll;
using Pll = pair<ll,ll>;

const ll INF = 1LL<<60;
const ll MOD = 1000000007;

//cout << fixed << setprecision(10);
vector<ll> H;
ll N,A,B;

bool pos(ll K){
    ll num=0;
    bool jg=false;
    for(int i=0;i<N;i++){
        if(H[i]-K*B<=0)continue;
        else{
            num+=ceil((double)(H[i]-K*B)/A);
            if(num>INF) jg=true;
        }
    }
    return ((num<=K||jg) ? true : false);
}

int main() {
    cin >> N >> A >> B;
    A-=B;
    H.assign(N,0);
    for(int i=0;i<N;i++) cin >> H[i];
    ll ux=INF,bx=0;
    while(ux>bx+1){
        ll mid = (ux+bx)/2;
        if(pos(mid)) ux = mid;
        else bx = mid;
    }

    cout << ux << endl;

    return 0;
}

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

#define MOD 1000000007

signed main(){
  Int n;
  cin>>n;
  vector<int> p(n+1);
  for(Int i=1;i<=n;i++) cin>>p[i];
  vector<vector<int> > G(n+1);
  for(Int i=1;i<=n;i++) G[p[i]].emplace_back(i);
  vector<vector< map<int,int> > > dp(n+1);

  vector<int> c(n+1,0),po(n+1,1);
  for(Int i=0;i<n;i++) po[i+1]=(Int)po[i]*2%MOD;
  
  function<void(int, int)> dfs=[&](int v,int d){
    c[d]++;
    dp[v].resize(3);
    
    int idx=-1;
    for(int u:G[v]){
      dfs(u,d+1);
      if(idx<0||dp[idx][0].size()<dp[u][0].size()) idx=u;
    }
    
    if(~idx) swap(dp[v],dp[idx]);

    if(G[v].size()>1u){
      for(int u:G[v]){
	if(u==idx) continue;
	for(auto p:dp[u][1]){
	  int i=p.first;
	  vector<Int> t({dp[v][0][i],dp[v][1][i],dp[v][2][i]});
	  dp[v][0][i]=dp[v][1][i]=dp[v][2][i]=0;
	  for(int j=0;j<3;j++){
	    for(int k=0;k<3;k++){
	      dp[v][min(2,j+k)][i]+=t[j]*dp[u][k][i]%MOD;
	      dp[v][min(2,j+k)][i]%=MOD;
	    }
	  }
	}
      }
    
      for(auto p:dp[v][2]){
	int i=p.first;
	dp[v][0][i]+=dp[v][2][i];
	dp[v][0][i]%=MOD;
	dp[v][2][i]=0;
      }
    }
    
    dp[v][0][d]=1;
    dp[v][1][d]=1;
    
    for(int u:G[v]) dp[u].clear();
  };
  dfs(0,0);
  int ans=0;
  for(auto p:dp[0][1]){
    int i=p.first;
    ans+=(Int)dp[0][1][i]*po[n+1-c[i]]%MOD;
    ans%=MOD;
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 121344
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <math.h>
#include <limits.h>
#define swap(type,a,b) do{type t=a;a=b;b=t;}while(0);
#define ll long long
#define INF 100000000
#define MOD 1000000007
#define SIZE 100005
#define FOR(i,a,n) for(i=(a);i<(n);i++)
int MAX(int a,int b){ return a>b?a:b; }
int MIN(int a,int b){ return a<b?a:b; }
int comp(const void* a,const void* b){
	return *(int*)a-*(int*)b;
}
char str[100001];
int main(void)
{
	int n,a,b,p=0,q=0,i;
	scanf("%d%d%d",&n,&a,&b);
	scanf("%s",str);
	FOR(i,0,n){
		if(str[i]=='c') puts("No");
		else if(str[i]=='a'&&p<a+b){
			puts("Yes");
			p++;
		}
		else if(str[i]=='b'&&p<a+b&&q<b){
			puts("Yes");
			p++,q++;
		}
		else puts("No");
	}
	return 0;
}


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

#define all(x) x.begin(), x.end()

int main() {
        int n;
        scanf("%d", &n);
        vector<int> a(n), b(n), c(n);
        for (int i = 0; i < n; i ++) scanf("%d", &a[i]);
        for (int i = 0; i < n; i ++) scanf("%d", &b[i]);
        for (int i = 0; i < n; i ++) scanf("%d", &c[i]);
        sort(all(a));
        sort(all(b));
        sort(all(c));
        vector<long long> bigger(n);
        for (int i = 0; i < n; i ++) {
                auto it = upper_bound(all(c), b[i]);
                bigger[i] = c.end() - it;
        }
        for (int i = n - 2; i >= 0; i --) bigger[i] += bigger[i + 1];
        long long ans = 0;
        for (int i = 0; i < n; i ++) {
                auto it = upper_bound(all(b), a[i]);
                int j = it - b.begin();
                ans += bigger[j];
        }
        printf("%lld\n", ans);
        return 0;
}



Measured memory_bytes: 2176
N = int(input())
ans = 0
for i in range(1, N+1):
  j = N - i + 1
  ans += i * j

tree = [[] for i in range(N)]
for i in range(N-1):
  u, v = map(int, input().split())
  l, r = min(u, v), max(u, v)
  ans -= l * (N-r+1)

print(ans)

Measured memory_bytes: 23356
#include <stdio.h>

int main(void)
{
	int a, b, i, count;
	double c;
	while(scanf("%d %d", &a, &b) != EOF){
		c = a + b;
		count = 0;
		for(i = 0;i < 15;i++){
			if(c >= 1){
				c /= 10;
				count++;
			}
		}
		printf("%d\n", count);
	}

	return 0;
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)
#define VL vector<ll>
#define VS vector<string>
#define VB vector<bool>
#define VP vector<pair<ll,ll>>
#define VVL vector<vector<ll>>
#define VVP vector<vector<pair<ll,ll>>>
#define PL pair<ll,ll>
#define ALL(v) (v).begin(), (v).end()
ll d1[4] = {1, -1, 0, 0};
ll d2[4] = {0, 0, 1, -1};

vector<ll> Zalgo(string S){
    ll N = S.size();
    vector<ll> ret(N);
    ret[0] = N;
    ll i = 1, j = 0;
    while(i < N){
        while(i + j < N && S[j] == S[i+j]) j++;
        ret[i] = j;
        if(j == 0){
            i++;
            continue;
        }
        ll k = 1;
        while(i + k < N && k + ret[k] < j){
            ret[i+k] = ret[k];
            k++;
        }
        i += k;
        j -= k;
    }
    return ret;
}

int main(){
    ll N;
    string S;
    cin >> N >> S;

    ll ans = 0;
    rep(i, 0, N){
        string T = S.substr(i);
        auto lcp = Zalgo(T);

        rep(j, 0, lcp.size()){
            ll l = min(lcp[j], j);
            ans = max(ans, l);
        }
    }

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

Measured memory_bytes: 256
#include <bits/stdc++.h> 
#define F first 
#define S second 
#define MAX 10000003 
using namespace std; 

typedef long long int ll; 
const ll mod = 1000000007;

ll max(ll a, ll b) { return (a > b)? a : b; } 
  
ll knapSack(ll W, ll wt[], ll val[], ll n) 
{ 
   ll i, w; 
   ll K[n+1][W+1]; 
   for (i = 0; i <= n; i++) 
   { 
       for (w = 0; w <= W; w++) 
       { 
           if (i==0 || w==0) 
               K[i][w] = 0; 
           else if (wt[i-1] <= w) 
                 K[i][w] = max(val[i-1] + K[i-1][w-wt[i-1]],  K[i-1][w]); 
           else
                 K[i][w] = K[i-1][w]; 
       } 
   } 
   return K[n][W]; 
}  

int main() 
{ 
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n,w;
    cin>>n>>w;
    ll a[n],b[n];
    for(ll x=0; x<n; x++){
        cin>>a[x]>>b[x];
    }
    cout<<knapSack(w, a,b,  n) <<"\n";
    return 0;
}


Measured memory_bytes: 79232
#include<stdio.h>
#include<math.h>

int main()
{
    int n,t;
    scanf("%d",&n);
    for(int i=1;i<=9;i++)
    {
        for(int j=1;j<=9;j++)
        {
            t=i*j;
            if(t!=n)
                continue;
                if(t==n)
                    break;
        }
        if(t==n)
        break;
    }
    if(t==n)
    printf("Yes\n");

    else
    printf("No\n");
return 0;
}


Measured memory_bytes: 128
count = gets.chomp.to_i

line = gets.chomp.split("")

x = 0
list = []
count.times { |i|
    x += 1 if line[i] == "I"
    x -= 1 if line[i] == "D"
    list << x
}

if list.max >= 0
    puts list.max
else
    puts 0
end

Measured memory_bytes: 1788
# include <bits/stdc++.h>
# define rep(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
# define reps(i, n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
# define rrep(i, n) for(int i=((int)(n)-1); i>=0; --i)
# define rreps(i, n) for(int i=((int)(n)); i>0; --i)
# define ALL(x) (x).begin(), (x).end()
# define SZ(x) ((int)(x).size())
# define pb push_back
# define optimize_cin() cin.tie(0); ios::sync_with_stdio(false)
# define MSG(x) std::cout << #x << " : " << x << "\n";
using namespace std;
using lint = long long;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int N, K;
string S;

int main()
{
    cin >> N >> K;
    cin >> S;
    S[K - 1] = S[K - 1] + 0x20;

    cout << S << "\n";
    

    return 0;
}


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

int main(){
	string s;
	cin >> s;
	string yaki = "YAKI";
	for(int i = 0; i < 4; ++i){
		if(s[i] != yaki[i]){
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
	return 0;
}

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

bool harshad(int n)
{
  int t = n;
  int sum = 0; 
  while(t > 0)
  {
    sum += t % 10;
    t /= 10;
  }
  if(n % sum == 0) return true;
  else return false;
}

int main()
{
  int N; cin >> N;
  if(harshad(N)) cout << "Yes" << endl;
  else cout << "No" << endl;
}

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


#define f(i,a,b) for(int i=(int)(a);i<=(int)(b);i++)
#define char_f(i,a) for(int i=(int)(a);(char)s[i]!='\0';i++)
#define rf(i,a,b) for(int i=(int)(a);i>=(int)(b);i--)
#define llf(i,a,b) for(long long int i=(long long int)(a);i<=(long long int)(b);i++)
#define llrf(i,a,b) for(long long int i=(long long int)(a);i>=(long long int)(b);i--)



#define ll long long
#define fi first
#define se second
#define pb push_back
#define pob pop_back
#define mem(ara) memset((ara),0,sizeof(ara))
#define memn(ara) memset((ara),-1,sizeof(ara))
#define bb begin()
#define ee end()
#define em emplace
#define eb emplace_back





#define si set<int>
#define sd set<double>
#define sll set<long long int>
#define ss set<string>
#define sc set<char>

#define pii pair<int,int>
#define pli pair<long long int,int>
#define pil pair<int,long long int>
#define pll pair<long long int,long long int>
#define pci pair<char,int>
#define pic pair<int,char>
#define pcl pair<char,long long int>
#define plc pair<long long int,char>

#define pss pair<string,string>
#define pcc pair<char,char>

#define pis pair<int,string>
#define psi pair<string,int>
#define pls pair<long long int,string>
#define psl pair<string,long long int>
#define pdd pair<double,double>
#define pcs pair<char,string>
#define psc pair<string,char>



#define vi  vector<int>
#define vll vector<long long int>
#define vd vector<double>
#define vs vector<string>
#define vc vector<char>
#define vii vector<pii>



#define mod 1000000007
#define mx (1<<30)-1
#define llmx (1ll<<62)
#define n_size 100005
#define g_size 10000005
double PI=acos(-1);
#define eps 1e-9



///unsigned int uMAX=4294967295;
///unsigned ll int ullMAX=18446744073709551615;


int power(int a,int b){
    int r=1;
    while(b){
        if(b & 1){
            r=r*a;
            b--;
        }
        a=a*a;
        b>>=1;
    }
    return r;
}


int arr[g_size];



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

	int n,m,T,res;

	int maxi=-mx,mini=mx,count=0;

	int i,j,k;

	bool flag;

	string s1,s2;

	char s[100000];

	int ara[n_size],ara2[n_size];

	cin>>k;

	vi v;

	rf(i,32,1){
        int l=1;
        int r=10;
        while(r-l>1){
            int mid=(l+r)/2;
            int x=power(i,mid);
            if(x>k) r=mid;
            else{
                v.pb(x);
                l=mid;
            }
        }
	}

	auto z=max_element(v.bb,v.ee);

	cout<<*z<<endl;
}



Measured memory_bytes: 3660
s = input()
x = []
l = len(s)
for i in range(l):
    x.append(int(s[i]))

sum = 0
for n in range(2**(l-1)):
    bin_str = format(n,'0'+str(l-1)+'b')
    prev = 0
    for i in range(l-1):
        if bin_str[i]=='0':
            prev = prev*10 + x[i]
        else:
            sum += prev*10 + x[i]
            prev = 0
    sum += prev*10 + x[l-1]

print(sum)


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

void solve() {
    long long n;
    cin >> n;
    string ans;
    while(n) {
        n--;
        char t = n%26 + 'a';
        ans = t + ans;
        n /= 26;
    }
    cout << ans;
}

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


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

 
int main(){
  int n;
  cin >> n;
  int ans = 0;
  vector<int> a(n);
  rep(i,n) cin >> a[i];
  for (int i = 0;i < n; i++){
    for (int j = 0; j < n; j++){
      ans = max(ans,abs(a[i]-a[j]));
    }
  }
  cout << ans << endl;
  return 0; 
}



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

int H, W, K ,  AnsField[300][300], num=0;
char Field[300][300];

void solve(int col_start, int col_end){
    // solve col
    vector<int> row_cake;
    int i,j,k, v1, v2;
    for(i=col_start;i<=col_end;i++){
        for(j=0;j<W;j++){
            if(Field[i][j]=='#') row_cake.push_back(j);
        }
    }
    sort(row_cake.begin(), row_cake.end());
    for(i=0;i<row_cake.size();i++){
        v1 = 0; v2 = row_cake[i];
        if(i>0) {
            v1 = row_cake[i-1]+1;
        }
        if(i==row_cake.size()-1 && row_cake[i-1] != W-1){
            v2 = W-1;
        }
        num ++;
        for(j=col_start;j<=col_end;j++){
            for(k=v1;k<=v2;k++){
                AnsField[j][k] = num;
            }
        }
    }

}

// void print_vec(vector<int> vec){
//     for(int i=0;i<vec.size();i++){
//         printf("%d ", vec[i]);
//     }
//     printf("\n");
// }

int main(){
    int i,j, v1, v2;
    vector<int> vec;
    string s;
    int check = scanf("%d %d %d", &H, &W, &K);
    // char s[W];
    // printf("%d %d %d", H,W,K);
    vector<int> cnt(H, 0);

    for(i=0;i<H;i++){
        for(j=0;j<W;j++){
            // cin >> Field[i][j];
            scanf(" %c", &Field[i][j]);
            // cin >> s;
            // cout << s << "\n";
            if (Field[i][j] == '#')  cnt[i]++;
        }
    }

    for(i=0;i<H;i++){
        if(cnt[i]>0)vec.push_back(i);
    }


    for(i=0;i<vec.size();i++){
        v1 = 0, v2 = vec[i];
        if(i>0) v1 = vec[i-1]+1;
        if(i==vec.size()-1 && vec[vec.size()-1] != H-1){
            v2 = H-1;
        }


        solve(v1, v2);
    }
    for(i=0;i<H;i++){
        for(j=0;j<W;j++){
            if(j==0) printf("%d", AnsField[i][0]);
            else printf(" %d", AnsField[i][j]);
            if(j==W-1) printf("\n");
        }
    }

    return 0;

}

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

int main(){
  int M,N,l,i=0,a[10000],j=0;
  cin >> M >> N;
  while(cin>>l){
    a[i] = l;
    i++;
  }
  while(j<N){
    M = M-a[j];
    j++;
  }
  if(M>=0){
    cout << M;
  }
  else{
    cout << -1;
  }
}

Measured memory_bytes: 3632
#include <numeric>
#include<iostream>
#include<set>
#include<queue>
#include<vector>
#include<map>
#include<stack>
#include <cstdio>
#include<algorithm>
#include <sstream>
#include<string>
#include<string.h>
#include <cmath>
#include <iomanip>
#include <string>
#include<list>
using namespace std;
#define int long long
#define inf 1000000007
#define rep(i,j,n) for(int i=j;i<n;i++)
typedef pair<int,int>  P;
double pi = 3.141592653589793;
//使うやつはここから下に置こうな
struct edge{int to,cost;};
vector<int> es[114];
signed main(){
    string s;cin>>s;
    int ans=inf;
    rep(i,0,26){
        char ch=i+'a';
        int count=0;
        int maxi=-1;
        rep(j,0,s.size()){
            if(s[j]==ch){
               maxi=max(maxi,count);
                count=0;
            }
            else count++;
        }
        maxi=max(maxi,count);
        ans=min(ans,maxi);
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256