akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

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

#define DEBUG(x) cout << #x << ": " << (x) << endl
#define DEBUG_VEC(v) cerr<<#v<<": ";REP(__i,(v).size())cerr<<((v)[__i])<<", ";cerr<<endl
#define PRINT(x) cout << x << endl
#define all(x) x.begin(),x.end()

int main() {
    string s;
    cin >> s;
    int ans = 0;
    int N = s.size();
    for(int i=0;i<int(N/2);i++){
        if(s[i]!=s[N-1-i])ans++;
    }

    cout << ans << endl;


}



Measured memory_bytes: 384
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author lucasr
 */
public class Main {
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		MyScanner in = new MyScanner(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		BSubstring solver = new BSubstring();
		solver.solve(1, in, out);
		out.close();
	}

	static class BSubstring {
		public void solve(int testNumber, MyScanner sc, PrintWriter out) {
			char[] S = sc.next().toCharArray();
			char[] T = sc.next().toCharArray();
			int ans = T.length;

			for (int i = 0; i + T.length <= S.length; i++) {
				int tmp = 0;
				for (int j = 0; j < T.length; j++) {
					if (T[j] != S[i + j]) tmp++;
				}
				ans = Math.min(ans, tmp);
			}

			out.println(ans);
		}

	}

	static class MyScanner {
		private BufferedReader br;
		private StringTokenizer tokenizer;

		public MyScanner(InputStream is) {
			br = new BufferedReader(new InputStreamReader(is));
		}

		public String next() {
			while (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
			return tokenizer.nextToken();
		}

	}
}



Measured memory_bytes: 32800
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <map>
#include <numeric>
#include <cmath>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <complex>
#include <string.h>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <iomanip>
#include <sys/time.h>
#include <tuple>
#include <random>
using namespace std;

#define endl '\n'
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define UNIQ(v) (v).erase(unique((v).begin(), (v).end()), (v).end())

typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;
typedef complex<double> comp;
typedef vector< vector<ld> > matrix;
struct pairhash {
public:
    template<typename T, typename U>
    size_t operator()(const pair<T, U> &x) const {
	size_t seed = hash<T>()(x.first);
	return hash<U>()(x.second) + 0x9e3779b9 + (seed<<6) + (seed>>2);
    }
};
const int inf = 1e9 + 9;
const ll mod = 1e9 + 7;
const double eps = 1e-8;
const double pi = acos(-1);

int n, m;
int l[100100], r[100100];

int solve() {
    int L = -inf, R = inf;
    for (int i = 0; i < m; i++) {
        L = max(L, l[i]);
        R = min(R, r[i]);
    }
    return max(0, R-L+1);
}

void input() {
    cin >> n >> m;
    for (int i = 0; i < m; i++) cin >> l[i] >> r[i];
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(15);

    input();
    cout << solve() << endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
      
#define FOR(i,a,b) for(ll i = (a); i < (ll)(b); i++)
#define REP(i,n) FOR(i,0,n)
#define YYS(x,arr) for(auto& x:arr)
#define PW(x) (1LL<<(x))
#define SZ(x) ((ll)(x).size())

#define pb emplace_back
#define fi first
#define se second

using namespace std;

using ld = long double;
using ll = long long int;

const ll INF = (ll)1e9 + 10;
const ll INFLL = (ll)1e18 + 10;
const ll MOD = 1e9+7;
     
template<class T> T &chmin( T &a , const T &b ){ return a = min(a,b); }
template<class T> T &chmax( T &a , const T &b ){ return a = max(a,b); }
template<class T> void UNIQUE(vector<T> &a){ a.erase(unique(a.begin(), a.end()), a.end()); }

template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
  os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
  for(int i = 0; i < v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
  for(int i = 0; i < v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}

ll in(){long long int x; assert(scanf("%lld", &x) == 1); return x;}
ld fin(){double x; assert(scanf("%lf", &x) == 1); return x;}
char yuyushiki[1000010]; string stin(){assert(scanf("%s", yuyushiki) == 1); return yuyushiki;}

// head

struct Mod{
  unsigned n;
  Mod() : n(0){}
  Mod( ll x ){
    if( x < 0 ) n = x%MOD+MOD;
    else n = x%MOD;
  }
};
Mod operator + ( Mod a  , Mod b ){ return Mod( a.n + b.n ); }
Mod operator +=( Mod &a , Mod b ){ return a = a + b; }
Mod operator - ( Mod a ){ return Mod( MOD - a.n ); }
Mod operator - ( Mod a  , Mod b ){ return Mod( a.n + MOD - b.n ); }
Mod operator -=( Mod &a , Mod b ){ return a = a - b; }
Mod operator * ( Mod a  , Mod b ){ return Mod( (ll)a.n * b.n ); }
Mod operator *=( Mod &a , Mod b ){ return a = a * b; }
Mod modpow( Mod x , ll k ){
  Mod res = 1;
  while( k ){
    if( k & 1 ) res *= x;
    k /= 2;
    x *= x;
  }
  return res;
}
ll extgcd( ll a , ll b , ll &x , ll &y ){
  ll d = a;
  if( b != 0 ){
    d = extgcd( b , a % b , y , x );
    y -= a / b * x;
  } else {
    x = 1, y = 0;
  }
  return d;
}
Mod inv( Mod a ){ ll x, y; assert( extgcd( a.n , MOD , x , y ) == 1 ); return Mod( x ); }
Mod operator / ( Mod a  , Mod b ){ return Mod( (ll)a.n * inv(b).n ); }
Mod operator /=( Mod &a , Mod b ){ return a = a / b; }

int main(){

  int n = in();
  set<int> ss;
  REP(i, n){
    int a = in();
    ss.insert(a);
  }
  cout << SZ(ss) << endl;
  
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string.h>
#include<cmath>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack> 
#define  ll long long
using namespace std;
int a[100005],x,n;
int find(int x)
{
	int mid,t=0,l=0,r=n-1;
	while(l<=r)
	{
		mid=(l+r)/2;
		if(a[mid]>x)
		{
			r=mid-1;
		}
		else if(a[mid]<x)
		{
			l=mid+1;
		}
		else if(a[mid]==x)
		{
			t=1;
			break;
		}	
	 } 
	return t; 
}
int main()
{
int m,sum1=0;
cin>>n;
for(int i=0;i<n;i++)
cin>>a[i];
cin>>m;
for(int i=0;i<m;i++)
{
	cin>>x;
	sum1=sum1+find(x);
}
cout<<sum1<<"\n"; 
return 0;
}


Measured memory_bytes: 3500
//#include <bits/stdc++.h>
//#include <stdio.h>
#include<iostream>
#include<cstdio>
#include<bitset>
#include<algorithm>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<string>
#include<string.h>
#include<cmath>
#include<utility>
#include<functional>
#include<map>
#include<set>
#include<cctype>
#include<fstream>


#define FOR(i, a, b) for( int i=(a);i<=(b);i++)
#define RFOR(i, a, b) for( int i=(a);i>=(b);i--)
#define LFOR(i, a, b) for( long long int i=(a);i<=(b);i++)
#define LRFOR(i, a, b) for(long long int i=(a);i>=(b);i--)
#define MOD 1000000007
#define INF 1000000000 //2000000000
#define LLINF 1000000000000000000 //9000000000000000000
#define PI 3.14159265358979
#define MAXI 7500000

using namespace std;
typedef long long int ll;
typedef pair< long long int, long long  int> P;

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


int main(void) {
	int n, T;
	int c[1001], t[1001];
	int mini = INF;

	cin >> n >> T;
	FOR(i, 1, n) {
		cin >> c[i] >> t[i];
		if (t[i] <= T) {
			mini = min(mini, c[i]);
		}
	}

	if (mini == INF) {
		cout << "TLE" << endl;
	}
	else {
		cout << mini << endl;
	}
	

	return 0;
}

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

int main(){
  vector<int> v;

  for (int i = 0; i < 3; i++) {
    int x;
    cin >> x;
    v.push_back(x);
  }

  sort(v.rbegin(), v.rend());

  int ans = 0;
  while (true) {
    if (v[0] == v[1] && v[1] == v[2]) {
      break;
    }
    ans++;
    v[2]++;
    sort(v.rbegin(), v.rend());
    if (v[0] != v[2]) {
      v[2]++;
    }
    else {
      v[1]++;
    }
    sort(v.rbegin(), v.rend());
  }

  cout << ans << endl;

  return 0;
}


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

using namespace std;

// MACROS

#define ll long long
#define ull unsigned long long
#define ld long double

#define vi vector<int>
#define vll vector<ll>
#define vld vector<ld>
#define u_s unordered_set

#define pii pair<int,int>
#define pll pair<ll,ll>

#define FOR(i, n) for (ll (i) = 0; i < n; i++)
#define FORN(i, a, b) for (ll (i) = a; i < b; i++)
#define FORE(i, l) for (auto (i) : l)

#define pb push_back
#define pob pop_back
#define emp emplace

#define in(n) cin >> (n);
#define debug(n) cout << #n << ": " << n << '\n';

// FUNCTIONS

template< typename T >
inline T gcd(T a, T b) { if (b) return gcd(b, a % b); return a; }

template< typename T >
inline T ext_gcd(T a, T b, T & x, T & y) { if (a == 0) { x = 0; y = 1; return b; } T x1, y1; T g = ext_gcd(b % a, a, x1, y1); x = y1 - (b / a) * x1; y = x1; return g; }

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
    ll a, b, k;
    cin >> a >> b >> k;    
    ll x = max(a - k, 0LL);
    ll y = max(b - max(k - a, 0LL), 0LL);
    cout << x << " " << y << '\n';
}



Measured memory_bytes: 256
N = int(input())
AB = [list(map(int, input().split())) for i in range(N)]
CD = [list(map(int, input().split())) for i in range(N)]

AB.sort(reverse=True)
CD.sort()

AB_used = set()
CD_used = set()
for index_ab, ab in enumerate(AB):
    mx = float('inf')
    my = float('inf')
    i = -1
    j = -1
    if index_ab in AB_used:
        continue
    for index_cd, cd in enumerate(CD):
        if index_cd in CD_used:
            continue
        if (ab[0] < cd[0]) & (ab[1] < cd[1]) & (cd[1] < my) & (cd[0] < mx):
            i, j = index_ab, index_cd
            my = cd[1]
    if (i != -1) & (j != -1):
        AB_used.add(i)
        CD_used.add(j)

print(len(AB_used))





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

public class Main {
	private static void solve(){
		//Implement solution here.
		int n = ni();
		int[] a = na(n);
		int[] x = new int[n];
		boolean plus = true;
		for(int i = 0; i < n; i++) {
			if(plus) {
				x[0] += a[i];
			} else {
				x[0] -= a[i];
			}
			plus = !plus;
		}
		for(int i = 1; i < n; i++) {
			x[i] = (a[i - 1] - x[i - 1]/2) * 2;
		}		
		Arrays.stream(x).forEach(v -> System.out.print(v + " "));
	}

	//Switch input source (stdin/file)
	private static BufferedReader br  = new BufferedReader(new InputStreamReader(System.in));
	public static void main(String[] args){
		String debugDataPath = System.getenv("DD_PATH");        
		if(debugDataPath != null){
			try{
				br = new BufferedReader(new InputStreamReader(new FileInputStream(new File(debugDataPath))));
			}catch(Exception e){
				throw new RuntimeException(e);
			}
		}
		solve();
	}

	//Input read utility
	private static StringTokenizer tokenizer = null;
	public static String next() {
		while (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				tokenizer = new StringTokenizer(br.readLine());
			} catch (Exception e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken();
	}
	//Get next single int
	private static int ni() {
		return Integer.parseInt(next());
	}
	//Get next single long
	private static long nl() {
		return Long.parseLong(next());
	}
	//Get next single double
	private static double nd() {
		return Double.parseDouble(next());
	}
	//Get next int array from one line
	private static int[] na(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = ni();
		return a;
	}
	//Get next char array from one line
	private static char[] ns() {
		return next().toCharArray();
	}
	//Get next long array from one line
	private static long[] nal(int n) {
		long[] a = new long[n];
		for (int i = 0; i < n; i++)
			a[i] = nl();
		return a;
	}
}

Measured memory_bytes: 46868
a = input()
b = input()

aa = len(a)

bb = len(b)

dp = [[0]*(bb+1) for i in range(aa+1)]

for i in range(aa):
	for j in range(bb):
		if a[i] == b[j]:
			dp[i+1][j+1] = dp[i][j] + 1
		else:
			dp[i+1][j+1] = max(dp[i][j+1],dp[i+1][j])

ans = ""

while aa > 0 and bb > 0:
	if a[aa-1] == b[bb-1]:
		aa -= 1
		bb -= 1
		ans += a[aa]
	elif dp[aa][bb-1] > dp[aa-1][bb]:
		bb -= 1
	else:
		aa -= 1
print(ans[::-1])

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

int main() {
  int H, W;
  cin >> H >> W;

  vector<vector<char>> a(H);
  for (int i = 0; i < H; ++i) {
    a[i].reserve(W);
    for (int j = 0; j < W; ++j) {
      char c;
      cin >> c;
      a[i].push_back(c);
    }
  }

  for (int i = 0; i < W + 2; ++i) {
    cout << '#';
  }
  cout << endl;

  for (int i = 0; i < H; ++i) {
    cout << '#';
    for (int j = 0; j < W; ++j) {
      cout << a[i][j];
    }
    cout << '#' << endl;
  }

  for (int i = 0; i < W + 2; ++i) {
    cout << '#';
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
  int sum[100];
  int in, max, i;

  for(i = 0; i < 100; i++)
    sum[i] = 0;

  while(scanf("%d", &in) != EOF)
    {
      sum[in]++;
    }

  max = 0;
  for(i = 0; i < 100; i++){
    if(max < sum[i])
      max = sum[i];
  }

  for(i = 0; i < 100; i++){
    if(max == sum[i])
      printf("%d\n", i);
  }
  return 0;
}

Measured memory_bytes: 596
#include <climits>
#include <iostream>
using namespace std;
using int64    = long long;
using PII      = pair<int, int>;
const int MAXN = 100005;
const int INF  = 0x3f3f3f3f;

int64 a[MAXN], cnt[MAXN];

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
#ifdef LOCAL
    freopen("in.txt", "r", stdin);
#endif
    int n;
    cin >> n;
    for (int i = 0; i <= n; i++)
        cin >> a[i];
    cnt[0] = 1;
    int64 sum = 0;
    for (int i = 0; i <= n; i++)
        sum += a[i];
    for (int i = 0; i < n; i++) {
        // cout << a[i] << " " << cnt[i] << endl;
        if (a[i] > cnt[i]) {
            cout << -1 << endl;
            return 0;
        }
        cnt[i + 1] = min(3 * sum, (cnt[i] - a[i]) * 2);
    }
    if (a[n] > cnt[n])
        cout << -1 << endl;
    else {
        cnt[n] = a[n];
        for (int i = n - 1; i>=0 ; i--) {
            cnt[i] = min(cnt[i], cnt[i + 1] + a[i]);
        }
        int64 ans = 0;
        for (int i = 0; i <= n; i++) {
            ans += cnt[i];
        }
        cout << ans << endl;
    }
}


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

int main() {
	string str;
	cin >> str;
	int l = str.length();

	for (int i = 0; i < l - 1; i++) {

		for (int j = i + 1; j < l; j++) {

			if (str[i] == str[j]) {

				cout << "no" << endl;
				return 0;
			}
		}
	}

	cout << "yes" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <string.h>
#include <math.h>
typedef long long ll;
#define MAX(x, y)	(((x) > (y))? (x) : (y))
#define MIN(x, y)	(((x) < (y))? (x) : (y))
#define ABS(x)		(((x) < 0)? (-1*(x)) : (x))
#define REP(i,x,y)	for (int (i)=(x);(i)<(y);(i)++)
#define REP_(i,x,y)	for ((i)=(x);(i)<(y);(i)++)
#define MEMCLR(X)	memset((X),0,sizeof((X)))

using namespace std;
typedef pair<int, int> Point;
typedef vector<vector<Point>> Graph;

int A,B,C;
map<string,int> a;

int main() {
	string s;
	
	cin >> A >> B >> C;
	
	if ( A+B >= C) cout << "Yes";
	else cout << "No";

	return 0;
}


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

int main()
{

    ll x,i,j,p,m,d,k,n,a,b=0;

    cin>>x;

    a=x/500;
    a=a*1000;

    b=x%500;
    b=b/5;
    b=b*5;
    a+=b;



    b=x/5;
    b=b*5;

    cout<<max(a,b)<<endl;


    return 0;
}


Measured memory_bytes: 256
import collections
n, p = map(int, input().split())
def prime_factorize(n):
	a = []
	while n % 2 == 0:
		a.append(2)
		n //= 2
	f = 3
	while f * f <= n:
		if n % f == 0:
			a.append(f)
			n //= f
		else:
			f += 2
	if n != 1:
		a.append(n)
	return a
b = collections.Counter(prime_factorize(p))
x = 1
for i,j in b.items():
	if j >= n:
		x *= i**(j//n)
if n == 1:
	print (p)
else:
	print (x)

Measured memory_bytes: 3316
from itertools import product
import copy

H, W, K = map(int, input().split())

c_ = [input() for i in range(H)]
c = [[0] * W for i in range(H)]


for i in range(H):
    for j in range(W):
        if c_[i][j] == "#":
            c[i][j] = 1

ans = 0
for idxs in product(range(2), repeat=H+W):
    tmp_c = copy.deepcopy(c)

    for idx, j in enumerate(idxs):
        if j == 1:
            if idx < H:
                for x in range(W):
                    tmp_c[idx][x] = 0
            else:
                for x in range(H):
                    tmp_c[x][idx-H] = 0

    cnt = 0
    for i in range(H):
        for j in range(W):
            if tmp_c[i][j] == 1:
                cnt += 1
                
    if cnt == K:
        ans += 1

print(ans)

Measured memory_bytes: 9332
#include <iostream>
#include <cmath>
using namespace std;
int f(long long n){
	int ans = 0;
	while(n != 1){ if(n%3) return -1; ans++; n /= 3; }
	return ans;
}

int main(){
	long long d;
	cin >> d;
	if(f(d) != -1){
		cout << f(d) << endl;
	}else{
		cout << (int)ceil( log(d) / log(3) ) << endl;
	}
	
}

Measured memory_bytes: 0
#include <stdio.h>
int main()
{
	int n,x;
	scanf("%d",&n);
	int ans = 0;
	for (int i = 1;i<= n;i++)
	{
		scanf("%d",&x);
		if (i%2==1 && x%2==1)
			ans++;
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 1724
#include <iostream>
#include <iomanip> // << fixed << precision(10)
#include <vector>
#include <string>
#include <map>
#include <set>
#include <cmath>
#include <algorithm>
using namespace std;

#define FOR(i,s,t) for(int i=s;i<t;i++)
#define REP(i,n) FOR(i,0,n)
#define PRINT(s) cout << s << "\n"
#define SORT(A) sort(A.begin(), A.end())
#define EACHPRINT(A, T) for_each(begin(A), end(A), [&](T i){ cout << i << " "; });cout << "\n"

typedef long lint;
typedef pair<lint, lint> P;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    lint N; cin >> N;
    lint H; cin >> H;
    lint W; cin >> W;

    lint res = (N-H+1)*(N-W+1);
    cout << res << "\n";

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stack>
#include <math.h>

using namespace std;


int main(){

    int n,tmp;
    scanf("%d",&n);

    int L[n],length = 0,left,right,m;

    for(int i=0; i < n; i++){
        scanf("%d",&tmp);

        if(i == 0){
            L[0] = tmp;
        }else{
            if(L[length] < tmp){
                length++;
                L[length] = tmp;
            }else{
            	left = 0,right = length+1;
            	m = left;
            	while(true){
            		if(L[m] >= tmp){
            			for(;m >= 0 && L[m] >= tmp; m--);
            			L[m+1] = tmp;
            			break;
            		}else{
            			left = m;
            			m = (left+right)/2;
            		}
            	}
            }
        }
    }

    printf("%d\n",length+1);

    return 0;
}

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

//define gcd and lcm (using 64bit)
ll gcd(ll a,ll b){
    if (a < b) {
        //^はxor(bitwise operator)。以下三行でswap(a,b)を行っている。
        a ^= b;
        b ^= a;
        a ^= b;
    }
    //only when b==0,this program finds that b means false and returns a.
    return b ? gcd(b, a % b) : a;
}

ll lcm(ll a,ll b){
    return a * b / gcd(a, b);
}


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

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

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

    int a,b,c,d;

    cin >> a;
    cin >> b;
    cin >> c;
    cin >> d;

    cout << min(a,b)+min(c,d) << '\n';
    
    return 0;
}


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

typedef long long ll;
const int INF = 1e8;
// const ll INF = 1LL << 60;
typedef pair<int, int> P;

ll K, N;
vector<ll> A;

int main() {
    cin >> K >> N;
    A.resize(N);
    rep(i, N) {
        cin >> A[i];
    }

    ll dist = 0;
    rep(i, N) {
        if (i == N - 1) {
            ll tmp = K - A[N - 1] + A[0];
            dist = max(tmp, dist);
        } else {
            ll tmp = A[i + 1] - A[i];
            dist = max(tmp, dist);
        }
    }
    cout << K - dist << endl;
}

Measured memory_bytes: 1792
integer(16) N,comb(1:600),cnt(1:600)
character(5000) ans
read*,N
comb(1)=1
do i = 2,600
  comb(i) = comb(i-1)* (i+6) / (i-1)
end do
do i=600,1,-1
  cnt(i) = N / comb(i)
  N =mod(N,comb(i))
end do

ans=""
do i=1,600
  ans=trim(ans)//"FESTIVA"//repeat("L",cnt(i))
end do
print"(A)",trim(ans)
end

Measured memory_bytes: 860
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<map>
#include<iomanip>
#include<sstream>
#include<vector>
#include<stack>
#include<math.h>
using namespace std;


int main() {
	//cout << fixed << setprecision(10);
	long long int n, m, res[200] = {}, b[105], memo =0, key,index,ax;
	string str;
	cin >> n;
	if (n % 2 == 0) {
		cout << n * (n - 2)/2<<endl;
		for (int i = 1; i <= n - 1; i++) {
			for (int j = i; j <= n; j++) {
				if (i + j != n + 1&&i!=j) {
					cout << i << " " << j << endl;
				}
			}
		}
	}
	else {
		cout << (n-1) * (n - 3) / 2+n-1 << endl;
		for (int i = 1; i < n - 1; i++) {
			for (int j = i; j < n; j++) {
				if (i + j != n  && i != j) {
					cout << i << " " << j << endl;
				}
			}
		}

		for (int i = 1; i <= n - 1; i++) {
			cout << i << " " << n << endl;
		}
	}
}

Measured memory_bytes: 256
#include <iostream>                                                    
#include <cmath>                                                       
#include <climits>                                                     
#define rep(i, n) for(int i = 0; i < n; i++)                           
                                                                       
using namespace std;                                                   
                                                                       
int main(){                                                            
  int N;                                                               
  int A[100000];                                                       
  cin >> N;                                                            
  rep(i, N) cin >> A[i];                                               
                                                                       
  int total = abs(A[N-1]) + abs(A[0]);                                 
  rep(i, N-1) total += abs(A[i+1]-A[i]);                               
                                                                       
  //cout << "d" << total << endl;                                      
                                                                       
  rep(i, N){                                                           
    if(i==0){                                                          
      int val = total -abs(A[0])-abs(A[1]-A[0])+abs(A[1]);             
      cout << val << endl;                                             
    }                                                                  
    else if(i==N-1){                                                   
      int val = total -abs(A[N-1])-abs(A[N-1]-A[N-2])+abs(A[N-2]);     
      cout << val << endl;                                             
    }                                                                  
    else{                                                              
      int val = total - abs(A[i]-A[i-1])-abs(A[i+1]-A[i])+abs(A[i+1]-A\
[i-1]);                                                                
      cout << val << endl;                                             
    }                                                                  
  }                                                                    
                                                                       
  return 0;                                                            
} 

Measured memory_bytes: 1664
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        ABC095_C solver = new ABC095_C();
        solver.solve(1, in, out);
        out.close();
    }

    static class ABC095_C {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int a = in.nextInt();
            int b = in.nextInt();
            int c = in.nextInt();
            int x = in.nextInt();
            int y = in.nextInt();
            int minAB = Math.min(x, y);
            int cost = 0;
            if (a + b < 2 * c) {
                cost += a * x;
                cost += b * y;
            } else {
                cost += minAB * 2 * c;
                x -= minAB;
                y -= minAB;
                if (0 < x) {
                    if (a < c * 2) {
                        cost += a * x;
                    } else {
                        cost += c * 2 * x;
                    }
                }
                if (0 < y) {
                    if (b < c * 2) {
                        cost += b * y;
                    } else {
                        cost += c * 2 * y;
                    }
                }
            }

            out.print(cost);
        }

    }
}



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

typedef long long ll;
const ll INF = 1010000000000000017LL;
const ll MOD = 1000000007LL;

#define REP(i, n) for(ll i = 0 ; i < n; i++)

//#define DEBUG(fmt, ...)
#define DEBUG(fmt, ...) fprintf(stderr, fmt "\n", ##__VA_ARGS__)

int main(){
    std::cout<<std::fixed<<std::setprecision(10);

    ll H, W;

    cin >> H >> W;

    if( H == 1 || W == 1 ){
        cout << 1 << endl;
        return 0;
    }

    if((H*W) % 2 == 1 ){
        cout << (H*W/2)+1 << endl;
    }else{
        cout << H*W/2 <<endl;
    }
}


Measured memory_bytes: 256
import java.util.*; 

class Main{
public static void main(String[] args){
	Scanner sc=new Scanner(System.in);
        int h=sc.nextInt();
        int w=sc.nextInt();

  		String[][] a=new String[h][w];
		for(int c=0;c<h;c++){
          	String s=sc.next();
    		a[c]=s.split("");
    	}
  		 int[] d=new int[w];
    	for(int b=0;b<w;b++){
          int count=0;
          for(int c=0;c<h;c++){
          if(a[c][b].equals(".")){
            count++;
          }
          }
          if(count!=h){
           d[b]=1;
          }
        }
     
  for(int c=0;c<h;c++){
    String ans="";
    int count2=0;
    for(int f=0;f<w;f++){
     if(a[c][f].equals(".")){
     count2++;
     }
    }
    if(count2!=w){
    for(int e=0;e<w;e++){
    if(d[e]==1){
      ans+=a[c][e];
    }
    }
    System.out.println(ans);
    }
  }

    	
    }
}

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

int main() {
  string s;
  cin >> s;
  int N = s.size();
  int m = 0, p = 0;
  for (int i = 0; i < N; i++) {
    if (s[i] == 'T') p++;
    else p--;
    m = max(m,p);
  }
  cout << 2*m << endl;
}

Measured memory_bytes: 3688
#!/usr/bin/env python3
#第一回日本最強プログラマー学生選手権-予選- B

import sys
import math
import bisect
sys.setrecursionlimit(1000000000)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

n,k = LI()
a = LI()
x = [0]*n
y = [0]*n
for i in range(n):
    s,t = 0,0
    for j in range(i,n):
        if a[i] > a[j]:
            s += 1
    for j in range(i):
        if a[i] > a[j]:
            t += 1
    x[i] = s
    y[i] = t
ans = 0
for i in range(n):
    ans += k*(2*x[i] + (x[i]+y[i])*(k-1))//2
    ans %= mod
print(ans)


Measured memory_bytes: 42476
n = gets.chomp.split(" ").map {|item| item.to_i }

stores = []
n[0].times do |index|
    name, point = gets.chomp.split(" ")
    store = [name, point.to_i, index]
    stores.push(store)
end

stores.sort!{|a, b|
    comp_result = a[0].casecmp(b[0])
    if comp_result == 0
        b[1] <=> a[1]
    else
        comp_result
    end
}
stores.each do |store|
    puts store[2] + 1
end

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

int main(){
    long long int dp[120][30]={0},num[110]={0},n;
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>num[i];
    }
    dp[0][num[0]]=1;
    for(int i=1;i<n-1;i++){
        for(int j=0;j<=20;j++){
            if(dp[i-1][j]>0){
                int sum=j+num[i];
                if(sum<=20)dp[i][sum]+=dp[i-1][j];
                sum=j-num[i];
                if(sum>=0)dp[i][sum]+=dp[i-1][j];
            }
        }
    }
    cout<<dp[n-2][num[n-1]]<<endl;
    return 0;
}

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


int main(){
    int n;
    string s;
    cin>>n>>s;
    if(n==1){
        cout<<1<<endl;
    }else{
    int ans=1;
    
    for(int i=1;i<n;i++){
        if(s[i]!=s[i-1]){
            ans++;
        }
    }
    cout<<ans<<endl;
}}


Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <queue>
#include <cmath>
#include <algorithm>
#include <string>

using namespace std;

int main()
{
    int s, w;
    cin >> s >> w;
    if (w >= s)
        cout << "unsafe" << endl;
    else
        cout << "safe" << endl;
    return 0;
}

Measured memory_bytes: 3628
fun main() {
    val l = Integer.parseInt(readLine())
    var ans = 0
    for (i in 1 until l+1) {
        for (j in 1 until l+1) {
            for (k in 1 until l+1) {
                ans += gcd(i, gcd(j, k))
            }
        }
    }
    println(ans)
}

fun gcd(a: Int, b: Int): Int {
    var aGcd = a
    var bGcd = b
    var gcdGcd: Int
    while (true) {
        gcdGcd = aGcd % bGcd
        aGcd = bGcd
        bGcd = gcdGcd
        if (gcdGcd == 0) break
    }
    return aGcd
}

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

using namespace std;
using ll = long long;

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

	ll a, b, c, k;

	cin >> a >> b >> c >> k;

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

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

		}

	}

	return 0;
}

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

int main() {
  int N;
  cin >> N;
  vector<string> s(N);
  rep(i,N) {
    cin >> s.at(i);
  }
  int M;
  cin >> M;
  vector<string> t(M);
  rep(j,M) {
    cin >> t.at(j);
  }
  
  int cand = 0;
  vector<bool> sChecked(N,false);
  
  rep(i,N) {
    if ( sChecked.at(i) ) {
      continue;
    }
    int count = 0;
    string pivot = s.at(i);
    rep(ii,N) {
      if ( s.at(ii) == pivot ) {
        count++;
        if ( sChecked.at(ii) == false ) {
          sChecked.at(ii) = true;
        }
      }
    }
    rep(jj,M) {
      if ( t.at(jj) == pivot ) {
        count--;
      }
    }
    if ( count > cand ) {
      cand = count;
    }
  }
  int answer = cand;
  cout << answer << endl;
}


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

struct edge{
    int u, v;
    edge(int u, int v) : u(u), v(v) {}
    bool operator<(const edge& other) const{
        if(u == other.u){
            return v < other.v;
        }
        return u < other.u;
    }
};
vector<int> graph[100005];
vector<edge> edges;
bool num_used[100005];
map<edge, int> colors;

void dfs(int u, int pre = -1, int color = 0){
    int c = color;
    for(int i = 0; i < (int)graph[u].size(); ++i){
        int v = graph[u][i];
        if(v == pre)    continue;
        if(color == 1)    ++c;
        else if(color == 0){
            ++c;
        }
        else{
            if(c == color)  c = 1;
            else if(c == color - 1) c = color + 1;
            else        ++c;
        }
        int tu = u, tv = v;
        if(tu > tv) swap(tu, tv);
        colors[edge(tu, tv)] = c;
        num_used[c] = true;
        dfs(v, u, c);
    }

    return;
}

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

    int n;
    cin >> n;
    for(int i = 0; i < n-1; ++i){
        int a, b;
        cin >> a >> b;
        --a, --b;
        if(a > b)   swap(a, b);
        edges.push_back(edge(a, b));
        graph[a].push_back(b);
        graph[b].push_back(a);
    }
    dfs(0);
    int cnt = 0;
    for(int i = 1; i < n; ++i){
        if(num_used[i]) ++cnt;
    }
    cout << cnt << "\n";
    for(int i = 0; i < n-1; ++i){
        cout << colors[edge(edges[i].u, edges[i].v)] << "\n";
    }
}

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

int P[50010];
map<int,int> idx;

int prime() {
  int i=3,j,k,cnt=1;
  P[0] = 2;
  for(i=3;i<=60000;i+=2){
    k=0;
    for(j=3;j<=sqrt(i);j+=2){
      if(i%j==0){
	k=1;
	break;
      }
    }
    if(k==0) {
      P[cnt] = i;
      cnt++;
    }
  }
  return cnt;
}

int main(){
  int n,cnt;
  cnt = prime();
  while(cin >> n){
    for(int i=0;i<cnt;i++){
      if(n == P[i]){
	cout << P[i-1] << " " << P[i+1] << endl;
	break;
      }
      else if(n < P[i]){
	cout << P[i-1] << " " << P[i] << endl;
	break;
      }
    }
  }
}

Measured memory_bytes: 1188
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int H = sc.nextInt();
		int W  =sc.nextInt();
		int N = sc.nextInt();
		sc.close();
		int num = Math.max(H, W);
		int cnt = 0;
		int mul = 0;
		while(mul < N){
			mul = num * cnt;
			cnt++;
		}
		System.out.println(cnt-1);

	}

}

Measured memory_bytes: 22868
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<list>
#include<set>
#include<map>
#include<utility>
#include<queue>
#include<cmath>

#define rep(i,x) for(int i=0;i<(int)(x);i++)
#define reps(i,x) for(int i=1;i<=(int)(x);i++)
#define rrep(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define rreps(i,x) for(int i=((int)(x));i>0;i--)

#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define INF 2e10

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; }
typedef long long ll;
typedef std::pair<ll, ll> P;
int gcd(int a,int b){return b?gcd(b,a%b):a;}

using namespace std;


int main()
{
    char c;
    cin >> c;

    if(c == 'A') cout << 'T';
    if(c == 'C') cout << 'G';
    if(c == 'G') cout << 'C';
    if(c == 'T') cout << 'A';

    return 0;
}


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

h = list(map(int, input().split()))
res_val = abs(A - (T - h[0] * 0.006))
res_idx = 0

for i in range(1, N):
  val = abs(A - (T - h[i] * 0.0060))
  if val < res_val:
    res_val = val
    res_idx = i

print(res_idx + 1)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, sum;
  cin >> N;
  sum = 0 ;
  
  for (int i = 0; i < N; i++) {
    int l, r;
    cin >> l >> r; 
    sum += r - l + 1 ;
  }
  cout << sum << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int h,w;
  cin >> h >> w;
  vector<string>s(h);
  int i,j;
  for(i=0;i<h;i++)cin>>s[i];
  int ans = 1<<30;
  int tmp[h][w];
  for(i=0;i<h;i++){
    for(j=0;j<w;j++){
      tmp[i][j]=1<<30;
    }
  }
  queue<pair<pair<int,int>,pair<int,char> > >que;
  if(s[0][0]=='#'){
    que.push(make_pair(make_pair(0,0),make_pair(1,'#')));
  }else{
    que.push(make_pair(make_pair(0,0),make_pair(0,'.')));
  }
  while(!que.empty()){
    int change = que.front().second.first;
    char color = que.front().second.second;
    int y = que.front().first.first;
    int x = que.front().first.second;
    char opp;
    bool chk = true;
    if(tmp[y][x]<=change)chk=false;
    else{
      tmp[y][x]=change;
    }
    if(color=='#')opp='.';
    else opp='#';
    que.pop();
    int aa = 0;
    if(color=='.')aa=1;
    if(x==w-1 && y==h-1){
      if(ans > change)ans = change;
    }else if(change<ans && chk){
      if(x<w-1){
        if(s[y][x+1]==color)que.push(make_pair(make_pair(y,x+1),make_pair(change,color)));
        else que.push(make_pair(make_pair(y,x+1),make_pair(change+aa,opp)));
      }
      if(y<h-1){
        if(s[y+1][x]==color)que.push(make_pair(make_pair(y+1,x),make_pair(change,color)));
        else que.push(make_pair(make_pair(y+1,x),make_pair(change+aa,opp)));
      }
    }
    
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 384
def lscan; gets.split.map(&:to_i); end

x,k,d = lscan

x = x.abs

m = x/d

if m >= k
  x -= d*k
  p x
  exit
end

x -= d*m
k -= m

if k.even?
  p x
else
  p (x-d).abs
end

Measured memory_bytes: 14368
N,K = map(int,input().split())

def Base_10_to_n(X, n):
    if (int(X/n)):
        return Base_10_to_n(int(X/n), n)+str(X%n)
    return str(X%n)

x2 = Base_10_to_n(N, K) # x2 = K進数表示
print(len(list(str(x2))))

Measured memory_bytes: 2940
from collections import deque
n = int(input())
path = [{} for _ in range(n)]
for _ in range(n-1):
  u,v,w = map(int,input().split())
  u -= 1
  v -= 1
  path[u][v] = w
  path[v][u] = w

q = deque([(0,0)])
reached = [True] + [False]*(n-1)
ans = [0]*n
while q:
  p,c = q.popleft()
  for i,d in path[p].items():
    if reached[i]:continue
    if d&1:
      ans[i] = 1 - c
    else:
      ans[i] = c
    reached[i] = True
    q.append((i,ans[i]))
for i in ans:
  print(i)


Measured memory_bytes: 48220
#include <iostream>
#include <vector>
#include <unordered_map>
#include <map>
#include <set>
#include <iomanip>
#include <cassert>
#include <algorithm>
#include <string>
#include <queue>
#include <cstring>
#include <cmath>

using namespace std;

namespace fastinput
{
	/** Interface */

	inline int readChar();
	template <class T = int> inline T readInt();
	template <class T> inline void writeInt(T x, char end = 0);
	inline void writeChar(int x);
	inline void writeWord(const char *s);

	/** Read */

	static const int buf_size = 16384;

	inline int getChar() {
		static char buf[buf_size];
		static int len = 0, pos = 0;
		if (pos == len)
			pos = 0, len = fread(buf, 1, buf_size, stdin);
		if (pos == len)
			return -1;
		return buf[pos++];
	}

	inline int readChar() {
		int c = getChar();
		while (c <= 32)
			c = getChar();
		return c;
	}

	template <class T>
	inline T readInt() {
		int s = 1, c = readChar();
		T x = 0;
		if (c == '-')
			s = -1, c = getChar();
		while ('0' <= c && c <= '9')
			x = x * 10 + c - '0', c = getChar();
		return s == 1 ? x : -x;
	}

	/** Write */

	static int write_pos = 0;
	static char write_buf[buf_size];

	inline void writeChar(int x) {
		if (write_pos == buf_size)
			fwrite(write_buf, 1, buf_size, stdout), write_pos = 0;
		write_buf[write_pos++] = x;
	}

	template <class T>
	inline void writeInt(T x, char end) {
		if (x < 0)
			writeChar('-'), x = -x;

		char s[24];
		int n = 0;
		while (x || !n)
			s[n++] = '0' + x % 10, x /= 10;
		while (n--)
			writeChar(s[n]);
		if (end)
			writeChar(end);
	}

	inline void writeWord(const char *s) {
		while (*s)
			writeChar(*s++);
	}

	struct Flusher {
		~Flusher() {
			if (write_pos)
				fwrite(write_buf, 1, write_pos, stdout), write_pos = 0;
		}
	} flusher;
}

using namespace fastinput;

const int N = 1e5;

int main()
{
	::ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	string s;
	cin >> s;
	int k;
	cin >> k;
	for (auto &x : s)
		if (x != 'a')
		{
			if ('z' - x + 1 <= k)
			{
				k -= 'z' - x + 1;
				x = 'a';
			}
		}
	if (k != 0)
		s.back() += k % 26;
	cout << s << endl;
	
	return 0;
}

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

int main() {
  int N, K;
  cin >> N >> K;
  int A[N];
  for(int i = 0; i < N; i++) {
    cin >> A[i];
  }
  sort(A, A + N, greater<int>());
  int ans = 0;
  for(int i = 0; i < K; i++) {
    ans += A[i];
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;

const int inf = 999999999;
const double pi = acos(-1);
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};

#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define mod(i) ((i)%(ll)(1e9 + 7))
#define divm(a,b) (mod(a * modpow((ll)b,(ll)(1e9+5))))
#define rsort(a,b,c) sort(a, b, greater<c>())
#define vsort(v) sort(v.begin(), v.end());
#define ft first
#define sd second
#define pb push_back
#define it insert
#define sz(x) ((int)(x).size())
#define lb(a,n,k) (lower_bound(a,a+n,k) - a) 
#define vlb(a,k)  (lower_bound(a.begin(),a.end(),k) - a.begin())
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define ret return

ll modpow(ll i,ll j){ ll tmp=1; while(j){ if(j%2)tmp=mod(tmp*i);i=mod(i*i);j/=2;}return tmp;}
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; }

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

ll n,a,b,h[100005] = {};

bool boon(ll k){
    ll t[100005] = {};
   // cout << k << ": ";
   ll kk  = k;
    rep(i,0,n){
        t[i] = h[i];
        t[i] -= b*k;
       // cout << t[i] << " ";
        if(t[i] > 0){
            kk -= (t[i]+(a-b)-1)/(a-b);
            if(kk < 0)return false;
        }
    }
    //cout << endl;
    return true;
}

int main(){
	cin >> n >> a >> b;
    rep(i,0,n)cin >> h[i];
    sort(h,h+n);
    ll l = 1,r = (h[n-1]+b-1)/b;
    ll k;
    
    r = 1000000002;
    while(l < r){
        k = (l+r)/2;

        if(boon(k)) r = k;
        else l = k+1;
    }
    k = (l+r)/2;

    if(boon(k))cout << k << endl;
    else cout << k-1 << endl;
	return  0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <iomanip>
#include <cstring>
#define _CRT_SECURE_NO_WARNINGS
using namespace std;

int swap(int &a,int &b){
	int c;
	c=a;
	a=b;
	b=c;

	return 0;
}



int main(){
	int i=1;
	while(1){
		int x;
		cin>>x;
		if(x==0)
			break;
		cout<<"Case "<<i<<": "<<x<<endl;
		i++;
	}
	return 0;
}

Measured memory_bytes: 1160
# include<iostream>
# include<algorithm>
# include<cstring>
# include<string>
# include<cmath>
# include<queue>
# include<stack>
# include<set>
# include<vector>
# include<cstdio>
# include<cstdlib>
# include<map>
# include<deque>
# include<limits.h>

# define deb(x) printf("# x=%d\n",x)
# define deb_d(x) printf("# x=%lf\n",x)
# define ccout(x) printf("%d\n",x)

typedef long long ll;

using namespace std;

int a[3];
int ans;

int main(void){
	while(scanf("%d %d %d",&a[0],&a[1],&a[2])!=EOF){
		ans=0;
		sort(a,a+3);
		ans+=a[2]-a[1];
		while(a[0]<a[1]){
			a[0]+=2;
			ans++;
		}
		if(a[0]!=a[1]){
			ans++;
		}
		cout<<ans<<endl;
	}
	
	return 0;
}

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 int ll;
typedef pair<int, int> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

const int INF = 1e9;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
	int n;
	string s;
	int q;
	cin >> n >> s >> q;
	vector<set<int>> st(26);
	rep(i,n){
		st[(s[i]-'a')].insert(i);
	}
	rep(i,26) st[i].insert(INF);
	rep(qi,q){
		int k;
		cin >> k;
		if(k == 1){
			int i;
			char c;
			cin >> i >> c;
			--i;
			if(s[i] == c) continue;
			auto idx = st[(s[i]-'a')].find(i);
			st[(s[i]-'a')].erase(idx);
			s[i] = c;
			st[(c-'a')].insert(i);
		}
		else{
			int l, r;
			cin >> l >> r;
			--l; --r;
			int ans = 0;
			rep(i,26){
				auto idx = st[i].lower_bound(l);
				if(*idx <= r) ++ans;
			}
			cout << ans << endl;
		}
	}
    return 0;
}

Measured memory_bytes: 27212
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <map>
#include <set>
#include <functional>
#include <stack>
#include <cmath>
#include <string>
#define SIZE 300005
#define LINF 100000000000000000LL

using namespace std;
typedef long long int ll;
typedef pair <int,int> P;

struct L
{
	ll a,b;//ax+b
	L(ll a=0,ll b=0):a(a),b(b){}
	ll get(ll x)
	{
		return a*x+b;
	}
};
bool down(L p,L q,L r)//0>p.a>q.a>r.a
{
	return (p.b-q.b)*(r.a-p.a)<(p.b-r.b)*(q.a-p.a);
}
struct getmx
{
	L que[SIZE];
	int sz;
	
	void init()
	{
		sz=0;
	}
	void push(L l)//l.a : 減少
	{
		while(sz>=2&&down(que[sz-2],que[sz-1],l)) sz--;
		que[sz++]=l;
	}
	ll get(ll x)//x : 増加
	{
		while(sz>=2&&que[sz-1].get(x)<=que[sz-2].get(x)) sz--;
		//printf("%d : %lld %lld\n",sz,que[sz-1].a,que[sz-1].b);
		return que[sz-1].get(x);
	}
};
getmx que;
int n;
ll T[SIZE],S[SIZE];
ll left[SIZE],right[SIZE];
ll dp[SIZE];
ll memo[SIZE];

void solve(int l,int r)
{
	if(l+1==r) return;
	int m=(l+r)/2;
	que.init();
	if(l==0) que.push(L(1,1));
	else que.push(L(-(l-1),left[l-1]+(ll) (l-1)*(ll) (l-2)/2+S[l-1]));
	for(int i=l;i<m;i++) que.push(L(-i,left[i]+(ll) i*(ll) (i-1)/2+S[i]));
	for(int i=m;i<r;i++) memo[i]=que.get(i)+(ll) i*(ll) (i+1)/2-S[i]+right[i];
	que.init();
	for(int i=r-1;i>=m;i--) que.push(L(i,right[i]+(ll) i*(ll) (i+1)/2-S[i]));
	for(int i=m-1;i>=l;i--) memo[i]=que.get(-(i-1))+(ll) (i-1)*(ll) (i-2)/2+(i==0?0:S[i-1]+left[i-1]);
	ll mx=-LINF;
	for(int i=r-1;i>=m;i--)
	{
		mx=max(mx,memo[i]);
		dp[i]=max(dp[i],mx);
	}
	mx=-LINF;
	for(int i=l;i<m;i++)
	{
		mx=max(mx,memo[i]);
		dp[i]=max(dp[i],mx);
	}
	solve(l,m);
	solve(m,r);
}
int main()
{
	int n;
	scanf("%d",&n);
	for(int i=0;i<n;i++)
	{
		scanf("%lld",&T[i]);
		S[i]=T[i];
		if(i>0) S[i]+=S[i-1];
	}
	que.init();
	que.push(L(1,1));
	for(int i=0;i<n;i++)
	{
		left[i]=que.get(i)+(ll) i*(ll) (i+1)/2-S[i];
		left[i]=max(left[i],0LL);
		if(i>0) left[i]=max(left[i],left[i-1]);
		que.push(L(-i,left[i]+(ll) i*(ll) (i-1)/2+S[i]));
	}
	que.init();
	for(int i=n-1;i>=0;i--)
	{
		if(i==n-1) right[i]=0;
		else
		{
			right[i]=que.get(-i)+(ll) i*(ll) (i-1)/2+S[i];
			right[i]=max(right[i],right[i+1]);
		}
		que.push(L(i,right[i]+(ll) i*(ll) (i+1)/2-S[i]));
	}
	//for(int i=0;i<n;i++) dp[i]=max(0LL,(ll) n*(ll) (n+1)/2LL-S[n-1]);
	for(int i=0;i<n;i++) dp[i]=1LL-T[i];
	solve(0,n);
	//for(int i=0;i<n;i++) printf("%lld %lld : %lld\n",left[i],right[i],dp[i]);
	int Q;
	scanf("%d",&Q);
	while(Q--)
	{
		int p,x;
		scanf("%d %d",&p,&x);p--;
		printf("%lld\n",max(dp[p]-x+T[p],right[p]+(p==0?0:left[p-1])));
	}
	return 0;
}


Measured memory_bytes: 21248