akhauriyash/Code-Regression huggingface dataset:
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; ++i)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = int64_t;
using ld = long double;
using P = pair<int, int>;
using vs = vector<string>;
using vi = vector<ll>;
using vvi = vector<vi>;
template<class T> using PQ = priority_queue<T>;
template<class T> using PQG = priority_queue<T, vector<T>, greater<T> >;
const int INF = 100010001;
const ll LINF = (ll)INF*INF*10;
template<typename T1, typename T2>
inline bool chmax(T1 &a, T2 b) {return a < b && (a = b, true);}
template<typename T1, typename T2>
inline bool chmin(T1 &a, T2 b) {return a > b && (a = b, true);}
template<typename T1, typename T2>
istream &operator>>(istream &is, pair<T1, T2> &p) { return is >> p.first >> p.second;}
template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p) { return os << p.first << ' ' << p.second;}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, q;
    cin >> n >> q;
    vi a(n);
    rep(i, n) {
        cin >> a[i];
    }
    vi sum(n+1), sumk(n+1);
    rep(i, n) {
        sumk[i+1] = sumk[i];
        sumk[i+1] += a[i];
        sum[i+1] = sum[i];
        if((~i&1) == (n&1)) {
            sum[i+1] += a[i];
        }
    }

    vi place(n, int(1e9+1));
    for(int i = n-2; i >= 0; i--) {
        int taka = n-1-i;
        int ao = i-taka;
        if(ao >= 0) {
            place[i] = (a[ao]+a[i]+2)>>1;
        } else {
            place[i] = 0;
        }
    }

    while(q--) {
        int x;
        cin >> x;
        auto itr = upper_bound(all(place), x);
        int num = itr-place.begin();
        ll ans = sumk[n] - sumk[num];
        int j = (num<<1)-n;
        if(j < 0) j = 0;
        ans += sum[j];
        cout << ans << '\n';
    }
}

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

using namespace std;

const int mod = 1e9 + 7;

int fast_pow(int x, int y, int z = mod) {
  long long ret = 1;
  for (; y; y >>= 1, x = (long long)x * x % z) {
    if (y & 1)
      ret = ret * x % z;
  }
  return ret;
}

int main(int argc, char *argv[]) {
  std::ios_base::sync_with_stdio(false);
  map<int, map<int, long long>> f;
  set<int> se;
  int n;
  cin >> n;
  vector<int> a(n, 0);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    se.insert(a[i]);
  }
  for (auto x : se) {
    if (x <= a[0]) {
      f[0][x] = fast_pow(2, a[0] - x + 1);
    }
  }
  f[0][0] = fast_pow(2, a[0]);
  se.insert(0);
  for (int i = 1; i < n; i++) {
    for (auto x : se) {
      if (x <= a[i]) {
        if (x > a[i - 1]) {
          f[i][x] = f[i - 1][a[i - 1]] * fast_pow(2, a[i] - x + 1) % mod;
        } else {
          if (a[i] > a[i - 1]) {
            f[i][x] = (f[i - 1][x] + f[i - 1][a[i - 1]]) * fast_pow(2, a[i] - a[i - 1]) % mod;
          } else {
            f[i][x] = (f[i - 1][x] + f[i - 1][a[i]]) % mod;
          }
        }
      }
    }
  }
  cout << f[n - 1][0] << endl;
  return 0;
}


Measured memory_bytes: 640
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        List<Integer> operations = new ArrayList<>();
        int[] b = new int[n];
        for (int i = 0; i < n; i++) {
            b[i] = sc.nextInt();
        }
        for (int i = 1; i <= n; i++) {
            int lower = 0;
            for (int j = n - 1; j >= 0; j--) {
                if (b[j] == i) {
                    if (i + lower - 1 <= operations.size()) {
                        operations.add(i + lower - 1, b[j]);
                    } else {
                        System.out.println(-1);
                        return;
                    }
                }
                if (b[j] <= i) {
                    lower++;
                }
            }
        }
        for (int i : operations) {
            System.out.println(i);
        }
    }
}


Measured memory_bytes: 23124
#include <bits/stdc++.h>
using namespace std;
using Int = long long int;
template<typename T> void swap(T *t1, T *t2){ T* tmp=t1; t1=t2; t2=tmp;}
Int tmpi = 0;
double tmpd = 0.0;


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

    Int a, b;
    cin >> a >> b;
    Int sum = 0;
    for(Int i=0; i<2; i++){
        if(a > b){
            sum+=a;
            a--;
        }else{
            sum+=b;
            b--;
        }
    }
    cout << sum << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <iomanip>
using namespace std;
typedef long long unsigned int ll;
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define MOD 1000000007

#define REP(i,n) for(int i=0;i<n;i++)
#define REPS(i,f,n) for(int i=(f);i<(n);i++)
#define EACH(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)

#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

int dy4[]={0, 0, 1, -1};
int dx4[]={1, -1, 0, 0};
int dx8[]={0, 0, 1, -1, 1, 1, -1, -1};
int dy8[]={1, -1, 0, 0, 1, -1, -1, 1};

// https://beta.atcoder.jp/contests/abc093/tasks/abc093_b

int main() {
    int A, B, K; cin >> A >> B >> K;

    set<int> st;
    for (int i = A; i < A+K; i++) {
        if (i > B) break;
        st.insert(i);
    }
    for (int i = B; i > B-K; i--) {
        if (i < A) break;
        st.insert(i);
    }

    for (int t : st) {
        cout << t << "\n";
    }

    return 0;
}


Measured memory_bytes: 256
import numpy as np
import bisect
n = int(input())
A = sorted(list(map(int, input().split())))
B = list(map(int, input().split()))
C = sorted(list(map(int, input().split())))

ans = 0
for b in B:
    ans += bisect.bisect_left(A, b) * (n - bisect.bisect_right(C, b))
print(ans)

Measured memory_bytes: 31488
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		try (Scanner sc = new Scanner(System.in)) {
			char[] taps = sc.next().toCharArray();
			for (int i = 0; i < taps.length; i++) {
				if (i % 2 != 0 && taps[i] == 'R') {
					System.out.println("No");
					return;
				}
				if (i % 2 == 0 && taps[i] == 'L') {
					System.out.println("No");
					return;
				}
			}
			System.out.println("Yes");
		}
	}
}

Measured memory_bytes: 23124
def pow(x, n, m):
    res = 1
    if n > 0:
        res = pow(x, n // 2, m)
        if n % 2 == 0:
            res = (res * res) % m
        else:
            res = (((res * res) % m) * x) % m
    return res

def comb(n, r):
    numerator, denominator = 1, 1
    for i in range(n - (r - 1), n + 1):
        numerator = (numerator * i) % (10**9 + 7)
    for i in range(1, r + 1):
        denominator = (denominator * i) % (10**9 + 7)
    inv = pow(denominator, 10**9 + 7 - 2, 10**9 + 7)
    return (numerator * inv) % (10**9 + 7)

def mod_minus(a, b, m):
    if a < b:
        return a + m - b
    else:
        return a - b

n, a, b = map(int, input().split())
count = pow(2, n, 10**9 + 7) - 1
count = mod_minus(count, comb(n, a), 10**9 + 7)
count = mod_minus(count, comb(n, b), 10**9 + 7)
print(count)

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

using namespace std;
#define all(a)a.begin(),a.end()
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
const int mod= int(1e9)+7;
using P = pair<ll,ll>;
using ld=long double;

int main(){
    ll n;cin >>n;
    map<ll,int>mp;
    for (int i = 0; i < n; ++i) {
        ll a;cin >>a;
        mp[a-1]++;
        mp[a]++;
        mp[a+1]++;
    }
    ll mx=0;
    for(auto u:mp){
        if(mx<u.second){
           mx=u.second;
        }
    }
    cout <<mx<<endl;
    return 0;
}

Measured memory_bytes: 6144
def Next(): return input()
def NextInt(): return int(Next())
def NextInts(): return map(int,input().split())
def Nexts(): return map(str,input().split())
def NextIntList(): return list(map(int,input().split()))
def RowInts(n): return [input() for i in range(n)]

n = NextInt()
ans = 0
for i in range(1, n):
    now = i
    while now < n:
        now += i
        ans += 1
print(ans)

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

using namespace std;

int main()
{
  int n, k;
  cin >> n >> k;

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

  vector<long> cum_sum(n + 1, 0);
  for (int i = 0; i < n; i++)
  {
    cum_sum[i + 1] = cum_sum[i] + (p[i] + 1);
  }

  long ek_max = 0;
  for (int i = 0; i + k <= n; i++)
  {
    ek_max = max(ek_max, cum_sum[i + k] - cum_sum[i]);
  }

  cout << fixed << setprecision(10) << (double) (ek_max) / 2.0 << endl;

}

Measured memory_bytes: 3328
#include<stdio.h>

int main()
{
	int h, w, i, j;

	while (1){
		scanf("%d %d", &h, &w);

		if (h == 0 && w == 0) return 0;

		for (i = 1; i <= h; i++){
			for (j = 1; j <= w; j++)
			{
				if (i == 1 || j==1 || j==w || i== h)
				printf("#");
				else printf(".");
			}
			printf("\n");
		}
		printf("\n");
	}
	return 0;

}

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

using namespace std;

int main(){
	int a,b,c;
  	cin >> a >> b >> c;
  
 	int temp = 0;
	temp = a;
  	a = b;
  	b = temp;
  
  	temp = a;
  	a = c;
  	c = temp;
  	
  	cout << a << " "<< b <<" " << c << endl; 
  
}

Measured memory_bytes: 256
def input_int():
    return(int(input()))

def input_int_list():
    return(list(map(int,input().split())))

def input_int_map():
    return(map(int,input().split()))

def run():
    target = input_int()
    print(count_pattern(target - 1))

def count_pattern(target: int) -> int:

    count_num = 0
    for a in range(1, target):
        max_num = target // a

        if max_num == 0:
            break

        count_num += max_num

    # target / targetのパターンで1を追加
    return count_num + 1

run()


Measured memory_bytes: 9192
import numpy as np
import sys
read = sys.stdin.read
r1, c1, r2, c2 = map(int, read().split())
MOD = 10 ** 9 + 7


def cumprod(A, MOD=MOD):
    L = len(A)
    Lsq = int(L**.5 + 1)
    A = np.resize(A, Lsq**2).reshape(Lsq, Lsq)
    for n in range(1, Lsq):
        A[:, n] *= A[:, n - 1]
        A[:, n] %= MOD
    for n in range(1, Lsq):
        A[n] *= A[n - 1, -1]
        A[n] %= MOD
    return A.ravel()[:L]


def make_fact(U, MOD=MOD):
    x = np.arange(U, dtype=np.int64)
    x[0] = 1
    fact = cumprod(x, MOD)
    x = np.arange(U, 0, -1, dtype=np.int64)
    x[0] = pow(int(fact[-1]), MOD - 2, MOD)
    fact_inv = cumprod(x, MOD)[::-1]
    fact.flags.writeable = False
    fact_inv.flags.writeable = False
    return fact, fact_inv


fac, finv = make_fact(2 * 10**6 + 10, MOD)


def comb(n, k, mod=MOD, fac=fac, finv=finv):
    if n < k:
        return 0
    if n < 0 or k < 0:
        return 0
    return fac[n] * (finv[k] * finv[n - k] % mod) % mod


answer = comb(r2 + c2 + 2, r2 + 1) - comb(r1 + c2 + 1, r1) - \
    comb(c1 + r2 + 1, c1) + comb(r1 + c1, r1)
answer %= MOD
print(answer)


Measured memory_bytes: 90600
#include <iostream>
#include <iomanip>
#include <vector>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <cstring>
#define rep(i, N) for (int i = 0; i < (int)N; i++)
using namespace std;
typedef long long ll;
const ll LLINF = 9223372036854775807;
const int MOD = 1000000007;

int main() {
  int N, K; cin >> N >> K;
  int result = N%K==0 ? 0 : 1;
  cout << result << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const unsigned int MOD = 1000000007;
#define ll long long
#define PI 3.1416
string day[]={"SUN","MON","TUE","WED","THU","FRI","SAT"};
int main() {
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    int a,b;
    while(cin>>a>>b){
        a<b?cout<<"0"<<endl:cout<<"10"<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#define N 21
int check(int *,int,int,int);
int main(){
  int i,j,k,num[N],Q,n,q,cnt=0,flag=0,x;
  scanf("%d",&n);
  for(i=0;i<n;i++)
    scanf("%d",&num[i]);
  scanf("%d",&q);
  for(i=0;i<q;i++){
    scanf("%d",&Q);
    if(check(num,Q,-1,n)==1)
      printf("yes\n");
    else{
      printf("no\n");
    }
  }
  
  return 0;
}
int check(int num[],int sum,int n,int maxn){

    
  int i;
  if(sum==0){
    return 1;
  }
  else if(n==maxn-1){
    return 0;
  }
  else if(check(num,sum-num[n+1],n+1,maxn)==1||check(num,sum,n+1,maxn)==1){
    return 1;
  }
}


				   



Measured memory_bytes: 2048
# -*- coding: utf-8 -*-
n,m = map(int, input().split())
graph = [[] for j in range(n)]

for i in range(m):
    a,b = map(int, input().split())
    graph[a-1].append(b-1)
    graph[b-1].append(a-1)

used = [False]*n
used[0] = True

def DFS(v,used):
    if all(used):
        return 1
    ans = 0
    for i in graph[v]:
        if used[i]:
            continue
        used[i] = True
        ans += DFS(i,used)
        used[i] = False
    return ans
  
print(DFS(0,used))

Measured memory_bytes: 9212
#include<iostream>
#include<vector>
#include<queue>
#include<stack>
#include<string>
#include<cmath>
#include<algorithm>
#include<bitset>
#include<map>
#include<unordered_map>
#include<functional>
#include<set>
#include<numeric>

#pragma region
using namespace std;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define rep(i,n) FOR(i,0LL,n)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define rrep(i,n) RFOR(i,0LL,n)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define COUNT(a,y,x) upper_bound(all(a), y) - lower_bound(all(a), x)
#define UNIQUE(a) sort(all(a)); a.erase(unique(all(a)), a.end())
#define SUM(a) accumulate(all(a),0LL)
#define pb push_back
#define endl '\n'
typedef long long int ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef vector<string> vs;
typedef map<ll, ll> MAP;
const ll inf = 2222222222222222222LL;
const ll mod = 1000000007LL;

ll n = 0, m = 0, ans = 0, cnt = 0, tmp = 0, ma = -inf, mi = inf;
string s;
bool ok = true, flag = false;
ll dx[5] = { 1,-1,0,0,0 }, dy[5] = { 0,0,1,-1,0 };
ll ddx[9] = { 1,-1,0,0,1,1,-1,-1,0 }, ddy[9] = { 0,0,1,-1,1,-1,1,-1,0 };
#pragma endregion
#define MAX 222222




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

	vll a;
	cin >> n;
	rep(i, n) {
		cin >> tmp;
		a.pb(tmp);
	}
	sort(all(a));
	FOR(i, 1, n) {
		tmp = (a[i] - a[0]) / (n + 1);
		a[i] -= tmp * (n + 1);
		cnt += tmp;
	}
	rep(i, n) a[i] += cnt;
	ans = cnt;
	if (a[0] >= n) {
		tmp = a[0] - n + 1;
		ans += tmp * n;
		rep(i, n) a[i] -= tmp;
	}

	while (1) {
		ok = true;
		rep(i, n) {
			if (a[i] >= n) {
				rep(j, n) {
					if (i == j) continue;
					a[j]++;
				}
				a[i] -= n;
				ok = false;
				ans++;
				break;
			}
		}
		if (ok) break;
	}
	cout << ans << endl;


	return 0;
}


Measured memory_bytes: 256
/*
これを入れて実行
g++ code.cpp
./a.out
 */
 
#include <iostream>
#include <stdio.h>
#include <vector>
#include <string>
#include <cstring>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <cmath>
#include <math.h>
#include <tuple>
#include <iomanip>
#include <bitset>
#include <functional>
#include <cassert>
#include <random>

#define all(x) (x).begin(),(x).end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
using namespace std;
typedef long long ll;
typedef long double ld;
 
int dy4[4] = {-1, 0, +1, 0};
int dx4[4] = {0, +1, 0, -1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};
 
const long long INF = 1LL << 60;
const ll MOD = 1e9 + 7;
 
bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}
 
ll gcd(ll a, ll b){
	if (b == 0)return a;
	return gcd(b, a % b);
}
 
ll lcm(ll a, ll b){
    return a / gcd(a, b) * b;
}

ll conbinationMemo[100][100];

void cmemoInit(){
    rep(i, 100){
        rep(j, 100){
            conbinationMemo[i][j] = -1;
        }
    }
}
 
ll nCr(ll n, ll r){
    if(conbinationMemo[n][r] != -1) return conbinationMemo[n][r];
    if(r == 0 || r == n){
        return 1;
    } else if(r == 1){
        return n;
    }
    return conbinationMemo[n][r] = (nCr(n - 1, r) + nCr(n - 1, r - 1));
}
 
ll nPr(ll n, ll r){
    r = n - r;
    ll ret = 1;
    for (ll i = n; i >= r + 1; i--) ret *= i;
    return ret;
}
//-----------------------ここから-----------
int main(void){
    ll n;
    cin >> n;
    vector<ll> a(n);
    rep(i, n) cin >> a[i];
    ll ans = 0;

    ll sum = 0;
    rep(i, n){
        ans += sum * a[i];
        ans %= MOD;
        sum += a[i];
        sum %= MOD;
    }
    cout << ans << endl;
}   

Measured memory_bytes: 4840
//Himanshu Shukla
#pragma GCC optimize("O2")
#include <bits/stdc++.h>
using namespace std;
#define FASTIO ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0)
//#define file_input
//#define multitest
//#define measure_time
#define ll long long
#define v32 vector<int>
#define v64 vector<ll>
#define s32 set<int>
#define s64 set<ll>
#define graph vector<v32>
#define p32 pair<int, int>
#define p64 pair<ll, ll>
#define sz(v) (ll)(v).size()
#define fi first
#define se second
#define ln '\n'
#define debug(x) cerr << (#x) << ": " << (x) << ln
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
inline ll add(ll a, ll b, ll m) { return (((a % m + b % m) % m + m) % m); }
inline ll mul(ll a, ll b, ll m) { return (((a % m * b % m) % m + m) % m); }
const double EPS = 1e-6;
const ll MOD = 1e9 + 7;
template <typename T, typename U>
ostream &operator<<(ostream &out, const pair<T, U> &p)
{
	out << '[' << p.fi << ", " << p.se << ']';
	return out;
}
template <template <typename, typename...> class ContainerType, typename ValueType, typename... Args>
void print_container(const ContainerType<ValueType, Args...> &c)
{
	cout << "{ ";
	for (const auto &v : c)
		cout << v << ' ';
	cout << '}' << ln;
}

const int N = 4e5 + 5;
ll fact[N], ifact[N], inv[N];

void pre()
{
	inv[1] = fact[0] = fact[1] = ifact[0] = ifact[1] = 1;
	for (int i = 2; i < N; i++)
	{
		inv[i] = mul(MOD - MOD / i, inv[MOD % i], MOD);
		fact[i] = mul(fact[i - 1], i * 1ll, MOD);
		ifact[i] = mul(ifact[i - 1], inv[i], MOD);
	}
}

ll nCr(ll n, ll r)
{
	if (n < r)
		return 0;
	return (mul(fact[n], mul(ifact[r], ifact[n - r], MOD), MOD));
}

void solve()
{
	ll n, k;
	cin >> n >> k;
	pre();
	ll ans = 0;
	for (ll i = 0; i < min(k + 1, n); i++)
		ans = add(ans, mul(nCr(n, i), nCr(n - 1, i), MOD), MOD);
	cout << ans << ln;
	return;
}

int main()
{
	FASTIO;
#ifdef file_input
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	clock_t start, stop;
	int t = 1;
#ifdef multitest
	cin >> t;
#endif
#ifdef measure_time
	start = clock();
#endif
	for (int tc = 1; tc < t + 1; tc++)
		solve();
#ifdef measure_time
	stop = clock();
	cerr << "Time :" << fixed << setprecision(5) << double(stop - start) / double(CLOCKS_PER_SEC) << "s" << ln;
#endif
	return 0;
}


Measured memory_bytes: 9600
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <limits.h>

#define YesNo(b) ((b) ? "Yes" : "No")
#define YESNO(b) ((b) ? "YES" : "NO")

using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;


int main()
{
	int K, X;
	cin >> K >> X;

	cout << YesNo(500 * K >= X) << endl;
}

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

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

    int ans;
    if (a - 2 * b >= 0) {
        ans = a - 2 * b;
    } else {
        ans = 0;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
n, a, b = gets.split.map(&:to_i)

if a == b 
  puts 1
elsif a < b && n > 1 
  # 引くと最小値の場合が除外されてしまうので1を足す
  puts (n - 2) * (b - a) + 1
else
  puts 0
end


Measured memory_bytes: 1788
// Need to git gud and reach 1900+
#include <bits/stdc++.h>
using namespace std;

#define ok puts("ok")
#define ll long long
#define pb push_back
#define mk make_pair
#define fr first
#define sc second
#define vi vector < int >
#define pi pair < int, int >

const int N = 1e5 + 7;
const int INF = 1e9 + 7;

int n, k;

main(){ // If you don't know what to do, check the text box at the bottom
    cin >> n >> k;
    k--;
    n--;
    cout << (k + n - 1) / n;
}

/*
    Totally not inspired by BenQ's template
    Things you should do:
    1. Look for stupid typos in code e.g 1 instead of -1 etc
    2. Check if there is no infinite loops
    3. "Measure twice, cut once"
    4. Stay focused
*/


Measured memory_bytes: 256
<?php

define('IS_DEBUG', false);

$inputArray = getStdin();
array_shift($inputArray);

$res = [];
foreach ($inputArray as $input) {
  // 0ではじまる
  if (preg_match('`^0`', $input)) {
    list($tmp, $x) = explode(' ', $input);
    $res[] = $x;
  }
  // 1ではじまる
  elseif (preg_match('`^1`', $input)) {
    list($tmp, $x) = explode(' ', $input);
    echo $res[$x]."\n";
  }
  // 2ではじまる
  elseif (preg_match('`^2`', $input)) {
    array_pop($res);
  }
}

function getStdin()
{
  if (IS_DEBUG) {
    $buf = file_get_contents(dirname(__FILE__).'/input.txt');
    $inputArray = explode("\n", str_replace(["\r\n", "\r", "\n"], "\n", $buf));
  }
  else {
    while ($buf = fgets(STDIN)) {
      $inputArray[] = trim($buf);
    }
  }

  return $inputArray;
}




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

int main()
{
    ios::sync_with_stdio(false);
    string s1 = "AC";
    string s2;
    cin >> s2;
    int x = s2.find(s1);
    if(x == -1) cout << "No" << endl;
    else cout << "Yes" << endl;
    return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
n,a,b = list(map(int,input().split()))

def combination(n, r, mod=10**9+7):
    n1, r = n+1, min(r, n-r)
    numer = denom = 1
    for i in range(1, r+1):
        numer = numer * (n1-i) % mod
        denom = denom * i % mod
    return numer * pow(denom, mod-2, mod) % mod

#くり返し2乗法
def pow(x, n, mod=10**9+7):
    ans = 1
    while(n > 0):
        if(bin(n & 1) == bin(1)):
            ans = (ans*x)%mod
        x = (x*x)%mod
        n = n >> 1 #ビットシフト
    return ans
ret=0
ret=pow(2,n)-1
ret -= combination(n,a)
ret -= combination(n,b)
print(ret%(10**9+7))

Measured memory_bytes: 3064
#include<stdio.h>

static const int N=100;

int main(){

  int i,j,k,l,n,p[N+1],m[N+1][N+1];

  scanf("%d",&n);


  for(i=1;i<=n;i++){

    scanf("%d%d",&p[i-1],&p[i]);

  }

  for(i=1;i<=n;i++)m[i][i]=0;

  for(l=2;l<=n;l++){
    for(i=1;i<=(n-l)+1;i++){
      j=i+l-1;
    m[i][j]=(1<<21);
    for(k=i;k<=j-1;k++){
      if(m[i][j]>m[i][k]+m[k+1][j]+p[i-1]*p[k]*p[j])
      m[i][j]=m[i][k]+m[k+1][j]+p[i-1]*p[k]*p[j];
    }
  }
  }


  printf("%d\n",m[1][n]);

  return 0;

}


Measured memory_bytes: 2116
#include<iostream>
#include<math.h>
#include<string>
#include<algorithm>
#include<vector>
#include<cstring>
#define ll long long int
#define lp(i,n) for(ll i=0;i<n;i++)
#define loop(i,a,b) for(ll i=a;i<b;i++)
using namespace std;
ll max(ll a,ll b){
    return a>b?a:b;
}
int main(){
    ll t;
    t=1;
    //cin>>t;
    while(t--)
    {
        ll n,w;
        cin>>n>>w;
        ll weight[n];
        ll value[n];
        lp(i,n)
        {
            cin>>weight[i];
            cin>>value[i];
        }
        ll dp[n+1][w+1];
        memset(dp,0,sizeof(dp));
        // lp(i,n+1)
        //     dp[i][0]=0;
        lp(i,w+1)
            if(weight[0]<=i)
            dp[0][i]=value[0];  
        loop(i,1,n)
        loop(j,1,w+1){
            if(j>=weight[i])
                dp[i][j]=max(dp[i-1][j-weight[i]]+value[i],dp[i-1][j]);
            else
            {
                dp[i][j]=dp[i-1][j];
            }
                
        }
        cout<<dp[n-1][w]<<endl;
    }
    
    return 0;
}

Measured memory_bytes: 79104
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#include<deque>
#include<numeric>
#include<queue>
#include<stack>
#include<cstring>
#include<limits>
#include<functional>
#include<unordered_set>
#include<iomanip>
#include<cassert>
#include<regex>
#include<bitset>
#include<complex>
#include<chrono>
#include<random>
#define rep(i,a) for(int i=(int)0;i<(int)a;++i)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(),x.end()
using ll=long long;
constexpr ll mod = 1e9 + 7;
constexpr ll INF = 1LL << 60;

ll gcd(ll n, ll m) {
	ll tmp;
	while (m!=0) {
		tmp = n % m;
		n = m;
		m = tmp;
	}
	return n;
}

ll lcm(ll n, ll m) {
	return abs(n * m) / gcd(n, m);//gl=xy
}
 
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
 
using namespace std;
//ここから

void solve(){
  int n;
  cin>>n;
  vector<int>a(n);
  rep(i,n)cin>>a[i];
  vector<int>v(n);
  for(int i=n;i>=1;--i){
    int sum=0;
    for(int j=i-1;j<n;j+=i){
      sum+=v[j];
    }
    if(sum%2!=a[i-1])v[i-1]=1;
  }
  int cnt=0;
  rep(i,n){
    if(v[i])++cnt;
  }
  cout<<cnt<<endl;
  rep(i,n){
    if(v[i])cout<<i+1<<endl;
  }
}

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


Measured memory_bytes: 2560
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <climits>
#include <vector>
#include <map>
#include <set>
#include <list>
#include <stack>
#include <queue>
#include <algorithm>
#include <iostream>
#include <string>

#define REP(i,n) for(long long i=0;i<n;++i)
#define REPR(i,n) for(long long i=n;i>=0;--i)
#define REPI(itr,v) for(auto itr=v.begin();itr!=v.end();++itr)
#define REPIR(itr,v) for(auto itr=v.rbegin();itr!=v.rend();++itr)
#define FOR(i,a,b) for(long long i=a;i<b;++i)
#define SORT(v,n) sort(v, v+n)
#define SORTV(v) sort(v.begin(), v.end())
#define ALL(v) v.begin(),v.end()
#define llong long long
#define INF 999999999
#define MOD 1000000007
#define pb push_back
#define pf push_front
#define MP make_pair
#define SV(v) {for(long long sitr=0;sitr<v.size();++sitr){cin>>v[sitr];}}

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

using namespace std;

typedef pair<int,int> pii;

int main(){

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

  string s[30];
  REP(i,h){
    cin >> s[i];
  }

  llong mx = 0;
  REP(i,h){
    REP(j,w){
      if(s[i][j] == 'B'){
        REP(ii,h){
          REP(jj,w){
            if(s[ii][jj] == 'B'){
              
              mx = max(mx, abs(i - ii) + abs(j - jj));
            }
          }
        }
      }
    }
  }

  cout << mx << endl;
  return 0;
}




Measured memory_bytes: 3240
import sys

input = sys.stdin.readline


def main():
    N, K = map(int, input().split())
    S = input().rstrip()

    n_LR_change = 0
    for i in range(N - 1):
        if S[i] != S[i + 1]:
            n_LR_change += 1

    ans = min(N - 1, (N - 1) - n_LR_change + 2 * K)
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 3316
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 200000 + 5;
ll a[N];

int main(){
	ll n;
	scanf("%lld",&n);
	ll sum = 0;
	for(ll i = 0; i < n; i++){
		scanf("%lld",&a[i]);
		sum ^= a[i];
	}
	for(ll i = 0; i < n; i++){
		cout << (sum^a[i]);
		if(sum == n-1)
			cout << endl;
		else
			cout << " ";
	}
	return 0;
}

Measured memory_bytes: 5060
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <cstring>
#include <utility>
#include <numeric>
#include <unordered_map>

using namespace std;

int main(){

    int H, W, N;
    cin >> H >> W >> N;
    vector<pair<int, int>> AB(N);
    int a, b;
    for(int i = 0; i < N; i++){
        cin >> a >> b;
        a--;
        b--;
        AB[i] = make_pair(a, b);
    }

    unordered_map<long long, int> cntMap;
    for(auto p: AB){
        for(int i = -1; i <= 1; i++){
            for(int j = -1; j <= 1; j++){
                int x = p.first + i;
                int y = p.second + j;
                if(1 <= x && x < H - 1 && 1 <= y && y < W - 1){
                    cntMap[(long long)x * W + y]++;
                }
            }
        }
    }

    vector<long long> ans(10);
    for(auto temp: cntMap){
        ans[temp.second]++;
    }
    ans[0] = (long long)(H - 2) * (W - 2);
    for(int i = 1; i <= 9; i++){
        ans[0] -= ans[i];
    }

    for(auto temp: ans){
        cout << temp << endl;
    }

    return 0;
}

Measured memory_bytes: 37392
#include <stdio.h>

int main(void)
{
    int A, B, c, d, e, MAX;
    scanf("%d", &A);
    scanf("%d", &B);

    c = A + B;
    d = A - B;
    e = A * B;

    MAX = c;
    if (d > MAX)
        MAX = d;

    if (e > MAX)
        MAX = e;

    printf("%d", MAX);
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
using namespace std;
int main(void) {
  int n, m;
  cin >> n >> m;
  int l, r;
  vector<int> imos(n+2, 0);
  for (int i = 0; i < m; i++) {
    cin >> l >> r;
    imos[l]++;
    imos[++r]--;
  }
  int sum = 0, ans = 0;
  for (int i = 0; i <= n; i++) {
    sum += imos[i];
    if (sum == m)
      ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 640
import java.util.*;

public class Main {
    public static int calculateNum(int k) {
        int a = 7, index = 1;
        for (int i = 0; i <= k; i++) {
            if (a % k == 0) return index;
            else {
                a = (a * 10 + 7) % k;
                index++;
            }
        }
        return -1;
    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int K = 0;

        while(sc.hasNext()){
            K = sc.nextInt();
        }
        sc.close();
        System.out.println(calculateNum(K));
    }
}

Measured memory_bytes: 35748
#include <iostream>
#include <utility>
#include <stdint.h>

using namespace std;

int main()
{
  uint32_t maxValue = 0;
  
  int N, W;
  cin >> N >> W;

  uint32_t Weight[N+1];
  uint16_t Value[N+1];
  
  for (int n=1; n<=N; ++n) {
    cin >> Weight[n] >> Value[n];
    maxValue += Value[n];
  }

  uint32_t dp[N+1][maxValue+1];

  for (int n=0; n<=N; ++n)
    dp[n][0] = 0;
  for (int v=1; v<=maxValue; ++v)
    dp[0][v] = W+1;

  for (int n=1; n<=N; ++n) {
    for (int v=1; v<=maxValue; ++v) {
      if (v >= Value[n])
	dp[n][v] = min(dp[n-1][v], dp[n-1][v-Value[n]]+Weight[n]);
      else
	dp[n][v] = dp[n-1][v];
    }
  }

  int ans = 0;
  for (int v=1; v<=maxValue; ++v) {
    if (dp[N][v]<=W)
      ans = v;
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 39680
#include<cstdio>
#include<cstring>
char s[200010];
int main() {
	scanf("%s",s+1); int L=strlen(s+1),ans=0;
	for (int i=1,j; i<=L; ++i) {
		for (j=i; s[j]==s[j+1]; ++j) ;
		int l=j-i+1;
		switch (l%3) {
			case 0:ans+=l/3*2; break;
			case 1:ans+=l/3*2+1; break;
			case 2:ans+=l/3*2+2,++j; break;
		}
		j>L&&l%3==2&&(--ans);
		i=j;
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 1016
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using P = pair<ll, ll>;
#define rep(i, n)  for (int i = 0; i <  (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
#define all(x) (x).begin(), (x).end()
const ll INF = ll(1e18)+1;

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

    ll n;
    cin >> n;
    vector<ll> ai(n);
    rep(i,n) cin >> ai[i];

    ll money = 1000;
    ll stock = 0;

    vector<vector<ll>> bsvec(99,vector<ll>(2,0));
    ll mode = 0;

    bsvec[0][1] = ai[n-1];
    bsvec[0][0] = ai[n-1];

    rep(i,n-1){
        if(ai[n-2-i] <= bsvec[mode][0]) bsvec[mode][0] = ai[n-2-i];
        else{
            mode++;
            bsvec[mode][0] = ai[n-2-i];
            bsvec[mode][1] = ai[n-2-i];
        }
    }

    ll temp,temp2;
    rep(i,mode+1){
        if(bsvec[mode-i][0] != bsvec[mode-i][1]){
            money = money / bsvec[mode-i][0] * (bsvec[mode-i][1] - bsvec[mode-i][0]) + money;
        }
    }

    cout << money;
}

Measured memory_bytes: 3612
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
inline ll gcd(ll a,ll b)
{
    if(!b) return a;
    else{
        while(1){
            ll t=a%b;
            if(t==0) return b;
            else{
                a=b; b=t;
            }
        }
    }
}

int main(){
    int n;
    cin>>n;
    int sum=0;
    for(ll i=1;i<=n;i++){
        for(ll j=1;j<=n;j++){
            for(ll k=1;k<=n;k++){
                sum+=gcd(i,gcd(j,k));
            }
        }
    }
    cout<<sum;
    return 0;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define rep(i, N) for (long long int i=0; i<(int)N; i++)
#define rep1(i, N) for (long llint i=1; i<(int)N; i++)

using namespace std;

int r;

int main() {
  cin >> r;
  cout << r*r << endl;
}

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

#define null				""
#define all(dat)			dat.begin(), dat.end()
#define over(msg)			cout << msg << endl, exit(0);
#define loop(i, to)			for (int i = 0; i < to; ++i)
#define cont(i, to)			for (int i = 1; i <= to; ++i)
#define foreach(i, dat)		for (__typeof(dat.begin()) i = dat.begin(); i != dat.end(); ++i)

typedef long long			num;

using namespace std;

int n;
num a[405], pre[405], dp[405][405];

num get_sum(int l, int r) {
	return pre[r] - pre[l - 1];
}

int main() {
	ios_base::sync_with_stdio(0);
	cin >> n;
	cont (i, n) {
		cin >> a[i];
		pre[i] = pre[i - 1] + a[i];
	}
	cont (i, n) {
		cont (j, n) {
			dp[i][j] = 1e15;
		}
		dp[i][i] = 0;
	}
	cont (len, n) {
		cont (l, n) {
			int r = len + l - 1;
			if (r > n)  break;
			for (int m = l; m < r; ++m) {
				dp[l][r] = min(dp[l][r], dp[l][m] + dp[m + 1][r] + get_sum(l, m) + get_sum(m + 1, r));
			}
		}

	}
	cout << dp[1][n] << endl;
}


Measured memory_bytes: 1536
#include <iostream>
using namespace std;
int main(void)
{
    int d;
    while (cin >> d)
    {
        int f = 0;
        int n = 1;
        while (n*d <= 600 - d)
        {
            f += n * d * n * d * d;
            n++;
        }
        cout << f << endl;
    }
    return 0;
}



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

using namespace std;

#define ll long long
#define ld long double
#define P pair<ll, ll>

#define FORm(i, m) for (auto i = m.begin(); i != m.end(); i++)

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

#define sortAl(v) sort(all(v))
#define sortAlr(v)          \
  sort(v.begin(), v.end()); \
  reverse(v.begin(), v.end())

#define cout(n) cout << fixed << setprecision(n)

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

template <class T>
inline void chmax(T &a, T b) {
  a = std::max(a, b);
}
template <class T>
inline void chmin(T &a, T b) {
  a = std::min(a, b);
}

#define mod (ll)(1e9 + 7)
#define INF LLONG_MAX

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

  ll n, k;
  string s;
  cin >> n >> k;
  cin >> s;

  s[k - 1] += 'a' - 'A';
  cout << s << endl;

  return 0;
}


Measured memory_bytes: 256
MOD = 10**9 + 7
K = int(input())
S = input()


N = len(S)
M = K+N
s = [pow(26,K,MOD)]

r26 = pow(26,MOD-2,MOD)
for i in range(1,K+1):
    t = s[-1]
    t *= r26
    t *= 25
    t *= N+i-1
    t *= pow(i,MOD-2,MOD)
    t %= MOD
    s.append(t)


ans = sum(s) % MOD
print(ans)





Measured memory_bytes: 208500
main() {
int w,h,x,y,r;
scanf("%d",&w);
scanf("%d",&h);
scanf("%d",&x);
scanf("%d",&y);
scanf("%d",&r);
if ( (x-r>=0) && (x+r<=w) && (y-r>=0) && (y+r<=h) ) printf("Yes\n");
else printf("No\n");
  return 0;
}

Measured memory_bytes: 584
using System;
using System.Collections.Generic;
using System.Linq;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            ABC093_A();
        }

        static void ABC093_A()
        {
            var S = Console.ReadLine();
            Console.WriteLine(S.Contains("a") && S.Contains("b") && S.Contains("c") ? "Yes" : "No");
        }
    }
}

Measured memory_bytes: 11092
#include <bits/stdc++.h>
using namespace std;
int main()
{
  string S;
  cin >> S;
  int N = S.size();
  vector<char> A(N);
  vector<char> B(N);
  for (int i = 0; i < N-1; i += 2){
    A.at(i) = '1';
    B.at(i) = '0';
    A.at(i+1) = '0';
    B.at(i+1) = '1';
  }
  if (N % 2 == 1){
    A.at(N-1) = '1';
    B.at(N-1) = '0';
  }
  int a = 0;
  int b = 0;
  for (int i = 0; i < N; i++){
    if (S.at(i) == A.at(i)){
      a++;
    } else {
      b++;
    }
  }
  cout << min(a, b) << endl;
  return 0;
}

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

int main() {
  int A, B;
  cin >> A >> B;
  
  if(A==B){
    cout << A+B << endl;
  }
  else if(A>B){
    cout << A+A-1 << endl;
  }
  else if(A<B){
    cout << B+B-1 << endl;
  }
}

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

std::string
operator ""_s(char const* str, std::size_t){
    return str;
}

std::string
operator *(std::string const& str, int n){
    if( n < 1 ) return "";
    std::string result;
    result.reserve(str.length() * n);
    for(int i = 0 ; i < n ; ++i){
        result += str;
    }
    return result;
}

int
main(){
	int K;
    std::cin >> K;
    auto result = "ACL"_s * K;
    std::cout << result << std::endl;
    return 0;
}

Measured memory_bytes: 3548
n = int(input())
h = list(map(int, input().split(" ")))
dp = [float("inf") for _ in range(n)]
dp[0] = 0
for i in range(1, n):
    dp[i] = min(dp[i], dp[i - 1] + abs(h[i] - h[i - 1]))
    if i > 1:
        dp[i] = min(dp[i], dp[i - 2]  + abs(h[i] - h[i - 2]))

print(dp[n-1])


Measured memory_bytes: 20544
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);

        String S = scanner.next();
        String T = scanner.next();

        if (T.startsWith(S) && T.length() == S.length() + 1) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
}


Measured memory_bytes: 35616
#include<stdio.h>

int main(void)
{
	int N;
	int i, j;

	scanf("%d", &N);

	for (i = 1; i < 10; i++) {
		if (N / i < 10 && N % i == 0) {
			for (j = 1; j < 10; j++) {
				if (N / j < 10 && N % j == 0) {
					printf("Yes\n");
					return 0;
				}
			}
		}
	}
	printf("No\n");

	return 0;
}

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

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

    vector <int> counter(26, 0);
    long long ans = 1;

    for (auto c: s){
        int ord = c - 'a';
        //cout << ord << endl;
        counter.at(ord) += 1;
    }

    for (auto cnt: counter){
        ans *= cnt + 1;
        ans %= 1000000007;
    }

    cout << ans - 1 << endl;
}

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

int w, h;
string s[100];
int eNum[100][10001];
int wNum[100][10001];

int main() {
	int i, j;
	cin >> w >> h;
	for (i = 0; i < h; i++) cin >> s[i];
	for (i = 0; i < h; i++) {
		for (j = 1; j <= w; j++) {
			eNum[i][j] = eNum[i][j - 1] + (s[i][j - 1] == 'E');
			wNum[i][j] = wNum[i][j - 1] + (s[i][j - 1] == 'W');
		}
	}
	
	int minTotal = 1145141919;
	int ans;
	for (j = 0; j <= w; j++) {
		int total = 0;
		for (i = 0; i < h; i++) total += eNum[i][j];
		for (i = 0; i < h; i++) total += wNum[i][w] - wNum[i][j];
		if (minTotal > total) {
			minTotal = total;
			ans = j;
		}
	}
	
	cout << ans << " " << ans + 1 << endl;
	return 0;
}

Measured memory_bytes: 12396
#include<iostream>
#include<string>
#include<sstream>
#include<cstring>

using namespace std;

int main(){
  string s;
  getline(cin,s);
  for(int i=0;i < s.size();i++){
    if(isupper(s[i])){
      s[i] = tolower(s[i]);
    }else if(islower(s[i])){
      s[i] = toupper(s[i]);
    }
  }
  cout << s << endl;
  return 0;
}


Measured memory_bytes: 3156
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define rep(i, n) for (int i = 0; i < (n); i++)
#define reps(i, n, s) for (int i = (s); i < (n); i++)

typedef long long ll;
using namespace std;
const int INF = 1<<29;
struct Edge
{
    int to;
    ll cost;
};
using Graph = vector<vector<Edge>>;

set<pair<int, int>> isUsed;

void dijkstra(const Graph &G, int s)
{
    priority_queue<pair<ll, int>, vector<pair<ll, int>>, greater<pair<ll, int>>> q;
    vector<ll> d((int)G.size(), INF);
    vector<vector<int>> path((int)G.size());

    q.push({0, s});
    d[s] = 0;

    while (!q.empty())
    {
        auto cur = q.top();q.pop();
        ll cur_dist = cur.first;
        int v = cur.second;
        if (cur_dist > d[v]) continue;
        for (auto e : G[v])
        {
            if (d[e.to] > d[v] + e.cost)
            {
                d[e.to] = d[v] + e.cost;
                q.push({d[v] + e.cost, e.to});

                path[e.to].clear();
                path[e.to].pb(v);
            }
            else if (d[e.to] == d[v] + e.cost)
            {
                path[e.to].pb(v);
            }
        }
    }

    rep(v, (int)G.size())
    {
        for (auto u : path[v])
        {
            isUsed.insert(mp(min(u, v), max(u, v)));
        }
    }
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, m;
    cin >> n >> m;
    Graph G(n);

    rep(i, m)
    {
        int a, b;
        ll c;
        cin >> a >> b >> c;
        a--, b--;
        G[a].pb(Edge{b, c});
        G[b].pb(Edge{a, c});
    }

    //任意の点開始の最短経路を求める
    rep(i, n)
    {
        dijkstra(G, i);
    }
    cout << m - (int)isUsed.size() << endl;
 //   system("pause");
    return 0;
}

Measured memory_bytes: 384
max_lr = 10 ** 5

sieve = [True] * (max_lr + 1)
sieve[0] = False
sieve[1] = False
for i in range(2, max_lr + 1):
    if not sieve[i]:
        continue
    for j in range(i * i, max_lr + 1, i):
        sieve[j] = False

cs = [0] * (max_lr + 1)
for i in range(3, max_lr + 1, 2):
    if sieve[i] and sieve[(i + 1) // 2]:
        cs[i] = 1
for i in range(1, max_lr + 1):
    cs[i] += cs[i - 1]

Q = int(input())
for _ in range(Q):
    l, r = map(int, input().split())
    print(cs[r] - cs[l - 1])


Measured memory_bytes: 7156
#include "bits/stdc++.h"
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <queue>
#include <algorithm>
#include <numeric>
#include <random>
#include <stdio.h>
#include <bitset>
#define _USE_MATH_DEFINES
#include <math.h>

using namespace std;

typedef long long LL;
typedef long double LD;
typedef string ST;


#define REP(i,n) for(LL (i)=0;(i)<(n);(i)++)
#define ALL(v) v.begin(), v.end()
#define PRINTLN(v) {LL i=0; for(auto (a): v ){   cerr <<i << " : "<<  a << endl; i++;}}
#define PRINTSP(v) for(auto (a): v ) {cerr << a << " ";} cerr << endl

void func() {
  LL N;
  cin >> N;


  LL i_max = 1;
  for (LL i = 1; i <= sqrt(N); i++) {
    if (N % i == 0) {
      i_max = i;
    }
  }
  cout << i_max + N/i_max-2;
}

#ifdef CALC_TIME 
#include <windows.h>
int main()
{
  LARGE_INTEGER freq;
  QueryPerformanceFrequency(&freq);
  LARGE_INTEGER start, end;
  QueryPerformanceCounter(&start);
  // 何かの処理
  func();
  QueryPerformanceCounter(&end);
  double time = static_cast<double>(end.QuadPart - start.QuadPart) * 1000.0 / freq.QuadPart;
  fprintf(stderr, "\n%lf[ms]\n", time);
  return 0;
}
#else 
int main()
{
  func();
  return 0;
}
#endif





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

int main() {
    int n;
    cin >> n;
    map<string, int> m;
    string s;
    int maxx = -1;
    int tmp;
    rep(i, n){
        cin >> s;
        if (!(m.count(s))) {
            m.insert(make_pair(s, 1));
        } else {
            ++m[s];
        }
        maxx = max(maxx, m[s]);
    }

    for (auto x : m) {
        if (x.second == maxx) {
            cout << x.first << endl;
        }
    }
    
    return 0;
}

Measured memory_bytes: 19264
#include<bits/stdc++.h>
#include <ext/numeric>
#define     __        ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define     pi        acos(-1)
#define     ll        long long int
#define     mem(a)    memset(a,0,sizeof(a))
#define     mems(a)   memset(a,-1,sizeof(a))
#define     pii       pair<int,int>
#define     N         1000
using namespace std;

char ch[N][N];

int color[N][N];

int ar[]={-1,1,0,0};
int ac[]={0,0,-1,1};

queue < pii > q;

void bfs(int r, int c)
{
    pair < int , int > top;

    int u,v;

    while(!q.empty())
    {
        top = q.front();

        q.pop();

        u=top.first;

        v=top.second;

        for(int i=0;i<4;i++)
        {
           int h = u + ar[i];
           int w = v + ac[i];

           if(h>=0 && h<=r && w>=0 && w<=c && color[h][w]==-1 && ch[h][w]=='.')
           {
               q.push(make_pair(h,w));

               color[h][w] = color[u][v]+1;
           }
        }
    }
    return;
}

int main(){
    __;
/*
#ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
#endif
*/
    int n,m,ans=0;

    cin >> n >> m;

    for(int i=0;i<n;i++)
    {
        for(int j=0;j<m;j++)
        {
            cin >> ch[i][j];

            if(ch[i][j]=='#') {

                    q.push(make_pair(i,j));

                    color[i][j] = 0;
            }

            else color[i][j] = -1;
        }
    }

    bfs(n-1,m-1);

    for(int i=0;i<n;i++)
    {
        for(int j=0;j<m;j++)
        {
           if(ans < color[i][j]) ans = color[i][j];
        }
    }

    cout << ans << endl;

   return 0;
}


Measured memory_bytes: 13328
n, m = map(int, input().split())
sc = []
for i in range(m):
    sc.append(list(map(int, input().split())))
if n == 1:
    a = 0
else:
    a = 10 ** (n - 1)
for i in range(a, 10 ** n):
    test = str(i)
    flag = True
    for j in range(m):
        s = sc[j][0]
        c = sc[j][1]
        if test[s - 1] != str(c):
            flag = False
            break
    if flag == False:
        continue
    else:
        print(i)
        break
else:
    print(-1)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int vst[15][15];
int tag=0;
void dfs(int n,int x)
{
    if(tag)return;
    if(n==4){tag=1;return;}
    for(int y=1;y<=4;y++)
    {
        if(vst[x][y])
        {
            vst[x][y]=0;
            vst[y][x]=0;
            dfs(n+1,y);
            vst[x][y]=1;
            vst[y][x]=1;
        }
    }
}
int main()
{
    for(int i=1;i<=3;i++)
    {
        int x,y;
        scanf("%d%d",&x,&y);
        vst[x][y]=1;
        vst[y][x]=1;
    }
    for(int i=1;i<=4;i++)dfs(1,i);
    if(tag)printf("YES");
    else printf("NO");
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main(){

	int n;
	while(cin>>n&&n!=0){
		vector<int> nums;
		int t;
		for(int i = 0; i < n; i++){
			cin>>t;
			nums.push_back(t);
		}
		int s;
		cin>>s;
		int ub=n-1;
		int lb=0;
		int cnt=0;
		while(1){
			if(lb<0||ub<0||ub>=n||lb>=n||ub<lb)
				break;
			cnt++;
			int mid=ub+lb;
			mid/=2;
			if(nums[mid]==s||ub==lb){
				break;
			}
			else if(nums[mid]>s){
				ub=mid-1;
			}
			else if(nums[mid]<s){
				lb=mid+1;
			}
		}
		cout<<cnt<<endl;
	}

	return 0;
}

Measured memory_bytes: 0
#include<iostream>
#include<vector>
using namespace std;
int main(){
  int N=0,K=0;
  int ans=0;  
  cin >> N >> K;
  vector<int> h(N);
  for(int i = 0; i < N; i++){
    cin >> h[i];
    if(h[i]>=K) ans++;
  }
  cout << ans << endl;
return 0;
}

Measured memory_bytes: 640
#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;

    vector<lint> p;
    lint res = 0;

    REP(_, N) {
      lint a; cin >> a;p.push_back(a);
      res += a;
    }

    lint M = *max_element( p.begin(), p.end() );

    res -= M/2;
    PRINT(res);

    return 0;
}


Measured memory_bytes: 256