akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize("Ofast")
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"

using namespace std;

using u8 = uint8_t;
using u16 = uint16_t;
using u32 = uint32_t;
using u64 = uint64_t;
using i8 = int8_t;
using i16 = int16_t;
using i32 = int32_t;
using i64 = int64_t;

constexpr char newl = '\n';
constexpr double eps = 1e-10;

#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define F0R(i,b) FOR(i,0,b)
#define RFO(i,a,b) for (int i = ((b)-1); i >=(a); i--)
#define RF0(i,b) RFO(i,0,b)
#define fi first
#define se second
#define debug(x) cout << #x << ": " << x << '\n';
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()

template<typename T1, typename T2> inline void chmin(T1& a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1& a, T2 b) { if (a < b) a = b; }
template<class T> void Print(vector<T> v) {
  F0R(i, v.size()) {
    cout << v[i] << ' ';
  }
  cout << newl;
}

#if 1


// INSERT ABOVE HERE
signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);

  int a;
  cin >> a;

  cout << (8 - (a - 400) / 200);
}
#endif


Measured memory_bytes: 3604
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>
#include <limits>
#include <numeric>

using namespace std;

int main() {
    int p, q, r;
    cin >> p >> q >> r;
    
    auto opt1 = p + q;
    auto opt2 = q + r;
    auto opt3 = r + p;
    vector<int> opts = {opt1, opt2, opt3};
    sort(opts.begin(), opts.end());
    
    cout << opts[0] << endl;
    
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	static int[][] table;
	static long[][] memo;
	static int N;
	static int W;

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

		N = sc.nextInt();
		W = sc.nextInt();
		long max = 0;

		table = new int[N][2];
		for (int i = 0; i < N; i++) {
			table[i][0] =sc.nextInt();
			table[i][1] =sc.nextInt();
		}

		memo = new long[N+1][W+1];

		Main main = new Main();

		System.out.println(main.DP(0, W));
	}

	public long DP(int step,int lim) {
		long ans = 0;
		if (memo[step][lim] != 0) {
			ans = memo[step][lim];
		}else {
			if (step == N) {
				ans = 0;
			}else {
				int target_w = table[step][0];
				int target_v = table[step][1];
				if (lim - target_w < 0 ) {
					ans = DP(step + 1, lim);
				}else {
					long use = DP(step + 1, lim - target_w) + target_v;
					long nouse = DP(step + 1, lim);

					ans = Math.max(use, nouse);
				}
			}
			memo[step][lim] = ans;
		}

		return ans;
	}
}


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

#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define repr(i,n) for(int i=(int)(n-1);i>=0;i--)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout << #x" = " << x << endl
#define print(x) cout << x << endl
#define maxch(x,y) x=max(x,y)
#define minch(x,y) x=min(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt(x) bitset<32>(x).count()

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<P, int> PPI;
typedef pair<int, P> PIP;
typedef pair<ll, ll> PL;
typedef pair<P, ll> PPL;
typedef set<int> S;

#define INF INT_MAX/3
#define MAX_N 1000000001

int n;
vector<int> a(200020);
vector<int> b(200020);

int main(){
    cin.sync_with_stdio(false);
    cin >> n;
    rep(i, n) {
        cin >> a[i];
        b[a[i]] = i;
    }

    S st;
    ll ans = 0, l, r;
    repl(i, 1, n + 1) {
        auto p = st.insert(b[i]);
        if (p.fi == st.begin()) {
            l = -1;
        } else {
            l = *(--p.fi);
            p.fi++;
        }
        p.fi++;
        if (p.fi == st.end()) {
            r = n;
        } else {
            r = *p.fi;
        }
        ans += (b[i] - l) * (r - b[i]) * i;
    }

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

Measured memory_bytes: 11264
import math
from typing import List, Counter, Tuple
from collections import Counter
from itertools import permutations, zip_longest, groupby


def read_int() -> int:
    return int(input().strip())


def read_ints() -> List[int]:
    return list(map(int, input().strip().split(' ')))

modulo = 10**9+7


def merge(A, start, end, divisors):
    if start == end:
        return Counter(divisors[A[start]])
    mid = start+(end-start)//2
    left = merge(A, start, mid, divisors)
    right = merge(A, mid+1, end, divisors)
    for r in right:
        left[r] = max(left[r], right[r])
    return left

def solve() -> int:
    N = read_int()
    A = read_ints()
    M = 10**6+1
    divisors: List[List[int]] = [[] for _ in range(M)]
    for i in range(2, M):
        if len(divisors[i]) == 0:
            for j in range(i, M, i):
                temp = j
                while temp%i == 0:
                    divisors[j].append(i)
                    temp //= i
    lcd_counter = merge(A, 0, N-1, divisors)
    lcd = 1
    for k in lcd_counter:
        lcd = (lcd*pow(k, lcd_counter[k], modulo))%modulo
    answer = 0
    for a in A:
        answer = (answer+(lcd*pow(a, modulo-2, modulo))%modulo)%modulo
    return answer


if __name__ == '__main__':
    print(solve())


Measured memory_bytes: 211204
n, q = map(int, input().split())
s = input()

acn = []
acn.append(0)
for i in range(n-1):
	if s[i:i+2] == "AC":
		new = 1
	else:
		new = 0
	acn.append(new+acn[i])

for i in range(q):
	l, r = map(int, input().split())
	print(acn[r-1]-acn[l-1])


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

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

int main(){
    int K;
    cin >> K;
    int64_t ans = 0;
    rep2(i, 1, K + 1){
        rep2(j, 1, K + 1){
            rep2(k, 1, K + 1){
                ans += gcd(i, gcd(j, k));
            }
        }
    }
    cout << ans << endl;

    return 0;
}


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

#define     ll              long long
#define     ld              long double
#define     fi              first
#define     se              second
#define     sz(x)           x.size()
#define     mp              make_pair
#define     pb              push_back
#define     eb              emplace_back
#define     all(x)          begin(x), end(x)
#define     rall(x)         rbegin(x), rend(x)
#define     rep(i, x, n)    for (ll i = x; i < n; i++)
#define     fastio()        ios_base::sync_with_stdio(NULL); cin.tie(0); cout.tie(0)
#define     int             long long
using       namespace std;
using       namespace __gnu_pbds;
using       namespace __gnu_cxx;

mt19937     rng(chrono::steady_clock::now().time_since_epoch().count());

typedef     vector<int>     vi;
typedef     vector<vi>      vvi;
typedef     pair<int, int>  ii;
typedef     vector<ii>      vii;
typedef     vector<ll>      vl;
typedef     vector<vl>      vvl;
typedef     pair<ll, ll>    pll;
typedef     vector<pll>     vll;

inline void EXECUTE_TIME() {cout << endl << setprecision(10) << fixed << "CPU Time: " << clock() / double(CLOCKS_PER_SEC) << " sec(s)\n";}

template <class T> inline T RD(T &a) {T x; cin >> x; return a = x;}
template <class T> inline T gcd(T a, T b) {if (b) return gcd(b, a % b); else return a;}
template <class T> inline T lcm(T a, T b) {return a / gcd(a,b) * b;}
template<typename T> using ordered_set=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
typedef trie<string, null_type, trie_string_access_traits<>, pat_trie_tag, trie_prefix_search_node_update> pref_trie;

const int maxn = 105, maxw = 1e5 + 5, inf = 1e12;

int dp[maxn][maxw];
int w[maxn], v[maxn];

signed main()
{
//    freopen("test.inp","r",stdin);
//    freopen("test.out","w",stdout);
	fastio();

    ll n, W;
	cin >> n >> W;
	for (ll i = 0; i < n; i++) cin >> w[i] >> v[i];

	for (ll i = 0; i < maxn; i++){
		for (ll j = 0; j < maxw; j++) {
            dp[i][j] = inf;
		}
	}

	for (ll i = 0; i < maxw; i++) dp[0][i] = inf;

	dp[0][0] = 0;

	for (ll i = 1; i <= n; i++){
		for (ll j = 0; j < maxw; j++){
			if (j + v[i-1] < maxw) dp[i][j + v[i - 1]] = min(dp[i][j + v[i - 1]], dp[i - 1][j] + w[i - 1]);
			dp[i][j] = min(dp[i][j], dp[i-1][j]);
		}
	}

	ll mx = 0;

	for (ll j = 0; j < maxw; j++){
		for (int i = 0; i <= n; i++){
			if (dp[i][j] <= W) mx = max(mx, j);
		}
	}

	cout << mx;
}


Measured memory_bytes: 85612
(n,m)=gets.split.map(&:to_i)
h=gets.split.map(&:to_i)
ab=(0...m).map{gets.split.map(&:to_i)}.each_with_object((0...n).map{[]}){|(a,b),memo| memo[a-1]<<b-1 ;memo[b-1]<<a-1 ;   }

r = (0...n).select{|i|  ab[i].all?{|k| h[k] < h[i]  } }

print r.size



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

int main() {
        int n, j, k;
        long s = 10000000000;
        long p,  m = -2000000001;
        cin >> n;
        long R[200000];
        for(j=0; j<n; j++)
                cin >> R[j];
        for(j=0; j<n; j++) {
                if(R[j]<s){
                        s=R[j];
                        for(k=j+1; k< n; k++){
                                if((p=R[k]-R[j])>m)
                                        m=p;
                        
                        }       
                }
        }
        cout << m << endl;
}



Measured memory_bytes: 4696
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    int a[n],cnt=0,c=0;
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
        if(a[i]%2==0){
            cnt++;
        }
    }
    for(int i=0; i<n;i++)
    {
        if(a[i]%2==0 && (a[i]%3==0 || a[i]%5==0)){
            c++;
        }
    }
    if(c==cnt){
        cout<<"APPROVED"<<endl;
    }
    else cout<<"DENIED"<<endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#define rep(i,n) for(int i = 0; i < (n); i++)
using namespace std;

const int INF = 100100100;

int main()
{
    int n, m, x;
    cin>>n>>m>>x;
    vector<int>v1(n);
    vector<vector<int>>v2(n,vector<int>(m));
    rep(i,n){
        cin>>v1[i];
        rep(j,m) cin>>v2[i][j];
    }

    int ans = INF;
    rep(s,1<<n){
        int cost = 0;
        vector<int>v3(m);
        rep(i,n){
            if(s>>i&1){
                cost += v1[i];
                rep(j,m) v3[j] += v2[i][j];
            }
        }
        bool ok = true;
        rep(j,m) if(v3[j] < x) ok = false;
        if(ok) ans = min(ans,cost);
    }
    if(ans == INF) cout<<-1<<endl;
    else cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3604
def main():

    N = int(input())
    # L, R, d = map(int, input().split())
    A = [int(i) for i in input().split()]
    ans = 0
    for v in A[0::2]:
        if v % 2 == 1:
            ans += 1

    print(ans)

if __name__ == '__main__':
    main()

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

using namespace std;
typedef long long int ll;
typedef pair <ll,ll> P;
#define REP(i, n) for(ll i = 0LL; i < (ll)(n); i++)
#define REPR(i, n) for(ll i = n-1; i >= 0LL; i--)
#define FOR(i, n, m) for(ll i = n; i < (ll)(m); i++)
#define PRINT(x) cout << x << endl
#define ALL(v) v.begin(), v.end()
#define INF (ll)1e18
#define INFD 1e18
#define PI 3.14159265358979
#define MOD 1000000007
// #define MOD 998244353
#define VL vector<ll>

vector<ll> dx = {-1, 1, 0, 0};
vector<ll> dy = {0, 0, 1, -1};

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; }

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

	vector<ll> A(N);
	REP(i, N) cin >> A[i];

	ll l = 0;
	ll r = 0;
	ll sum = 0;
	ll xsum = 0;
	ll cnt = 0;
	while(r < N) {
		if (sum + A[r] == (xsum ^ A[r])) {
			sum += A[r];
			xsum ^= A[r];
			cnt += r-l+1;
			r++;
		} else {
			sum -= A[l];
			xsum ^= A[l];
			l++;
		}
	}
	PRINT(cnt);
	return 0;
}


Measured memory_bytes: 1792
n=int(input())
sp=[[] for i in range(n)]
for i in range(n):
  s,p=input().split()
  sp[i] = [i+1, s, int(p)]
sp = sorted(sorted(sp, key=lambda x:x[2], reverse=True), key=lambda x:x[1])
for i in range(n):
  print(sp[i][0])

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

#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = (n)-1; i >= 0; i--)
#define rep1(i,n) for(int i = 1; i <= (n); i++)
#define rrep1(i,n) for(int i = (n); i > 0; i--)

#define ll long long
#define pi pair<int, int>
#define pll pair<ll, ll>

#define MOD 1000000007
#define INF 1000000000000000LL

using namespace std;

int main(){
  int h,w,k;cin>>h>>w>>k;
  vector<string>c(h);
  rep(i, h)cin>>c[i];

  int result=0;
  for(int i=0; i<1<<h; i++)for(int j=0;j<1<<w;j++){
    int hbit = i;
    int wbit = j;
    int count=0;
//cout<<hbit<<' '<<wbit<<"------------"<<endl;
    rep(y, h)rep(x, w){
//cout<<y<<' '<<x<<endl;
      //if(hbit>>y & 1)cout<<"h"<<endl;
      if(hbit>>y & 1)continue;
      //if(wbit>>x & 1)cout<<"w"<<endl;
      if(wbit>>x & 1)continue;
      //cout<<c[y][x]<<endl;
      if(c[y][x]=='#')count++;
    }
//cout<<count<<"=========="<<endl;
    if(count==k)result++;
  }

  cout<<result<<endl;

  return 0;
}

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

using ll =long long;

//最大公約数
ll gcd(ll a, ll b)
{
   if (a%b == 0)
   {
       return(b);
   }
   else
   {
       return(gcd(b, a%b));
   }
}
//最小公倍数
ll lcm(ll a, ll b)
{
   return a * b / gcd(a, b);
}

int f(ll A){
  if(A==1){return 0;}
  
  A=pow(2,A-1)+f(A-1);
  cout<<A<<"..";
  return A;
}
int main()
{
ll H;
  cin>>H;
  ll sum=0;
  ll counter=0;
 
  while(H>1){
    H=floor(H/2);
 //     cout<<H<<",";
    counter++;
  }
  counter++;
 // cout<<"counter="<<counter;
  for(ll i=1;i<counter+1;i++){
    sum+=pow(2,i-1);
  //  cout<<sum<<" ";
  }
 // cout<<endl;
  //cout<<f(3);
  cout<<sum<<endl;
}



Measured memory_bytes: 256
def main():
    import sys
    from collections import deque

    input = sys.stdin.readline

    N, W = map(int, input().split())
    dp = [0]*(W+1)

    for _ in [0]*N:
        v, w, m = map(int, input().split())
        
        for ofs in range(w):
            q = deque()
            for j in range(W+1):
                wj = ofs + j*w
                if wj > W:
                    break
                src = dp[wj] - j*v
                while q and q[-1][1] <= src:
                    q.pop()
                q.append((j, src))

                if q:
                    ni, nv = q[0]
                    dp[wj] = nv + j*v
                    if ni == j - m:
                        q.popleft()
    print(max(dp))


if __name__ == '__main__':
    main()


Measured memory_bytes: 7612
#include <iostream>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>

using namespace std;
 
int main() {
	int a,b,t,un;
    int sum = 0;
	cin >> a >> b >> t;
	sum = t/a * b;
	if(a > t){
		cout << 0 << endl;
	}else{
	cout << sum << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define N 100005
#define MOD 1000000007
#define dd double
#define vi vector<int>
#define vll vector<ll>
#define forr(i, n) for(int i = 0; i < n; i++)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep1(i,b) for(int i=1;i<=b;i++)
#define pb push_back
#define mp make_pair
#define clr(x) x.clear()
#define sz(x) ((int)(x).size())
#define ms(s, n) memset(s, n, sizeof(s))
#define F first
#define S second
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define int ll
ll po(ll a, ll x, ll m) { if (x == 0) {return 1;} ll ans = 1; ll k = 1;  while (k <= x) {if (x & k) {ans = ((ans * a) % m);} k <<= 1; a *= a; a %= m; } return ans; }
// Udhar kya dekh rha h idhar dekh le
int32_t main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);

	int n, x, t;
	cin >> n >> x >> t;
	int ans  = (n + x - 1) / x;
	ans *= t;
	cout << ans << "\n";
	return 0;
}

Measured memory_bytes: 3604
def gcd(m, n):
    r = m % n
    return gcd(n, r) if r else n

N, X = map(int, input().split())
*P, = map(int, input().split())
g = abs(X - P[0])
for i in range(1, N):
    g = gcd(g, abs(X - P[i]))
print(g)

Measured memory_bytes: 14224
#include <iostream>
#include <vector>
#include <algorithm>
#include <unordered_map>
#include <ctime>
#include <set>
#include <sstream>
#include <bitset>
#include <queue>
#include <stack>
#include <deque>
#include <cmath>
#define ll long long
using namespace std;

int main() {
    int n;
    cin >> n;
    int ans = n % 10;
//    while ( n > 0) {
//        ans = n % 10;
//        n /= 10;
//    }
    if (ans == 3) {
        cout << "bon";
    }else if (ans == 0 || ans == 1 || ans == 6 || ans == 8) {
        cout << "pon";
    }else cout << "hon";
}


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

typedef long long ll;
const int NMAX = 2e5 + 10;
const int MOD = 1e9 + 7;
int main(int argc, char const *argv[])
{
	ll n;
	ll ans;
	scanf("%lld",&n);
	ans = n;
	for(register ll i = 1;i * i <= n;i++)
		if(n % i == 0)
			ans = min(ans , i + n/i - 2);
	printf("%lld\n",ans );
	return 0;
}

Measured memory_bytes: 3836
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef int Int;
typedef pair<Int, Int> pii;
typedef pair<Int, double> pid;
typedef pair<double, double> pdd;
typedef pair<Int, pii> pip;
typedef pair<pii, Int> ppi;
typedef pair<double, Int> pdp;
typedef vector<Int> veci;
typedef vector<double> vecd;
typedef vector<int> veci;
typedef vector<ll> vecll;
typedef vector<double> vecd;
typedef vector<pii> vecpii;
typedef vector<ppi> vecppi;
typedef vector<veci> mati;
typedef vector<vecll> matll;
typedef vector<vecd> matd;
#define PB(x) push_back(x)
#define EB(x) emplace_back(x)
#define ALL(x) x.begin(),x.end()
#define SZ(x) (x).size()
#define CLR(x) memset(x,0,sizeof x)
#define pdebug() printf("%d\n",__LINE__)
#define REP(i, a, b) for(int i = (a);i <= (b);i++)
#define FORO(i, n) REP(i,0,(int)n-1)
#define FORI(i, n) REP(i,1,(int)n)
#define FORIT(i, t) for(auto i = t.begin();i != t.end();i++)
#define eps 1e-6
#define sqr(x) ((x)*(x))
#define dist(_a, _b) sqrt(sqr(_a.A-_b.A)+sqr(_a.B-_b.B))
#define norm(_a) sqrt(sqr(_a.A)+sqr(_a.B))
#define DEBUG 1
#if DEBUG
#define DUMP(a) do { std::cout << #a " = " << (a) << ", "; } while(false)
#define DUMPLN(a) do { std::cout << #a " = " << (a) << std::endl; } while(false)
#else
#define DUMP(a)
#define DUMPLN(a)
#endif
template<typename T, typename U>
inline void getMin(T &a, U b) { if (a > b) a = b; }
template<typename T, typename U>
inline void getMax(T &a, U b) { if (a < b) a = b; }
template<typename T>
vector<T> getVector(const int n) { return vector<T>(n); }
template<typename T>
vector<T> getVector(const int n, const T a) { return vector<T>(n, a); }
template<typename T>
vector<T> getEmptyVector() { return vector<T>(); }
template<typename T>
void appendAll(vector<T> &a, vector<T> b) { a.insert(a.end(), b.begin(), b.end()); }
template <class T1, class T2> ostream &operator<<(ostream &os, const pair<T1, T2> &a) { return os << "(" << a.first << ", " << a.second << ")"; };
// #define X first
// #define Y second
const int dx[4] = {1, -1, 0, 0};
const int dy[4] = {0, 0, 1, -1};
const ll MOD = 1000000007;
const int MAXN = 1 << 17;
const int inf = 1 << 27;
const ll llinf = 1LL << 50;
const int NIL = -inf;
int popcount(int x) { return __builtin_popcount(x); }


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

    int N;
    cin >> N;
    veci L(N);
    FORO(i, N) cin >> L[i];

    int ans = 0;
    for(int i = 0;i < N;i++) {
        for(int j = i + 1;j < N;j++) {
            if(L[i] == L[j]) continue;
            for(int k = j + 1;k < N;k++) {
                if(L[i] == L[k] || L[j] == L[k]) continue;
                vector<int> v = {L[i], L[j], L[k]};
                sort(ALL(v));
                if(v[2] < v[0] + v[1]) {
                    //DUMP(i); DUMP(j); DUMPLN(k);
                    ans++;
                }
            }
        }
    }
    cout << ans << endl;
    return 0;
}


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

using namespace std;

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  sort(a.begin(), a.end());
  vector<int> v(1000001, true);

  for (int i = 0; i < n; i++) {
    if (!v[a[i]]) continue;
    for (int j = a[i] * 2; j <= a.back(); j += a[i]) {
      v[j] = false;
    }
  }
  int ans = 0;
  for (int i = 0; i < n; i++) {
    if (0 == i) {
      if (a[i] == a[i + 1]) continue;
    } else if (i == n - 1) {
      if (a[i] == a[i - 1]) continue;
    } else if (a[i] == a[i - 1] || a[i] == a[i + 1]) {
      continue;
    }

    if (v[a[i]]) ans++;
  }
  cout << ans << endl;

  return 0;
}

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

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

const ll mod = 1000000007;

int main() {
    int n,a;
    cin >> n >> a;
    int b[n];
    rep(i,n) b[i] = a+i;
    int s = 0;
    rep(i,n) s += b[i];
    int c[n];
    rep(i,n) c[i] = s-b[i];
    int ans = 1000000;
    rep(i,n) {
        if (abs(s-c[i]) < abs(s-ans)) {
            ans = c[i];
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3608
#include <iostream>
#include <fstream>
#include <vector>
#include <stack>
#include <queue>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <cstdio>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <map>
#include <set>

using namespace std;

typedef long long ll;
typedef pair<int,int> PP;

/*
    freopen("input","r",stdin);
    freopen("output","w",stdout);
*/

int N;

void make(string &s) {
	int n = N - 1;
	while (s[n] == '9') n--;
	s[n]++;
	for (int i = n + 1;i < N;i++) s[i] = '0';
	return;
}

int main() {
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    N = s.size();
    char pre = s[0];
    int res = 1;
    int p = 0; // Till this digit can be eliminated.
    for (int i = 1;i < N;i++) {
    	char crt = s[i];
    	if (pre == crt) {
    		// p is not changed.
    	}
    	else if (pre < crt) {
    		p = i; // 
    		pre = crt;
    	}
    	else {
    		// Eliminate till p.
    		make(s);
    		p++;
    		i--;
    		pre = s[p];
    		res++;
    	}
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 1172
s = input()
n = 753

minDiff = -1
for i in range(len(s) - 2):
    x = int(s[i]) * 100 + int(s[i + 1]) * 10 + int(s[i + 2])
    diff = abs(x - n)
    if minDiff < 0 or diff < minDiff:
        minDiff = diff
print(minDiff)

Measured memory_bytes: 3060
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"

using namespace std;

const long long int MOD = 1000000007;
//const int MOD = 998244353;
//const long long int MOD = 998244353;

int N, M, K, H, W, L, R;
//long long int N, M, K, H, W, L, R;


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

	cin >> N;
	vector<int>x(N);
	vector<int>y(N);
	for (int i = 0; i < N; i++) {
		cin >> x[i] >> y[i];
	}
	if (N == 1) {
		cout << 1 << endl;
		return 0;
	}
	int ans = MOD;
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < N; j++) {
			if (i == j)continue;
			int cx = x[j] - x[i];
			int cy = y[j] - y[i];
			int cnt = 0;
			for (int k = 0; k < N; k++) {
				for (int l = 0; l < N; l++) {
					if (cx == x[l] - x[k] && cy == y[l] - y[k])cnt++;
				}
			}
			ans = min(ans, N - cnt);
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
a = int(input())
b = int(input())
if a == 1:
  if b == 2:
    print(3)
  else:
    print(2)
elif a == 2:
  if b == 1:
    print(3)
  else:
    print(1)
elif a == 3:
  if b == 1:
    print(2)
  else:
    print(1)

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

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

    int count = 0;

    for(int i=a;i>=1;i--){
        if(a%i==0 && b%i==0) count++;
        if(count==k){
            cout << i << endl;
            return 0;
        }
    }

}

Measured memory_bytes: 256
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#define int long long
using namespace std;
signed main() {
	int A, B, C, D;
	cin >> A >> B >> C >> D;

	if (A + B > C + D) {
		cout << "Left" << endl;
	}
	else if (A + B == C + D) {
		cout << "Balanced" << endl;
	}
	else {
		cout << "Right" << endl;
	}
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
const int INF = 1000000000;
#define REP(i,s,n) for(int i=(int)(s);i<(int)(n);i++)
#define rep(i,n) REP(i, 0, n)
int yoko[10], tate[10];
int col[21];
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int w, d;
    while(cin >> w >> d && w){
        rep(i, w) cin >> yoko[i];
        rep(i, d) cin >> tate[i];
        memset(col, 0, sizeof(col));
        int sum = 0;
        rep(i, w){
            sum += yoko[i];
            col[yoko[i]]++;
        }
        rep(i, d){
            col[tate[i]]--;
            if(col[tate[i]] < 0) sum += tate[i];
        }
        cout << sum << endl;
    }
    return 0;
}

Measured memory_bytes: 1192
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef vector<int> V;
const long long MOD=1000000007LL;
const long long INFL=1LL << 60;
const int INF=1<<29;


int main() {
    int N;
    cin >>N;
    cout<<(N-2)*180<<endl;
    return 0;
}

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

int main(){
	int n;
	double w, h, bmi;
	while (~scanf("%d,%lf,%lf", &n, &w, &h)) {
		bmi = w / (h*h);
		if (bmi >= 25) {
			cout << n << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h> 
#define pb push_back
#define mp make_pair 
#define fr first
#define sc second
#define MOD 1000000007
#define len(x) x.size()
#define min3(a, b, c) min(a, min(b, c))
#define max3(a, b, c) max(a, max(b, c))
#define all(v) v.begin(), v.end()
#define alla(a,n) a, a + n
#define f(i, n) for (int i = 0; i < int(n); i++)
#define g(i, n) for (int i = 0; i < int(n-1); i++)
#define fj(j, n) for (int j = 0; j < int(n); j++)
#define fio ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL)

using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> pll;
typedef vector<ll> vll;
typedef vector<pll> vpll;
typedef vector<vll> vvll;
typedef vector<string> vs;

// Driver function to sort the vector elements by 
// second element of pair in descending order 
bool sortbysecdesc(const pair<int,int> &a, 
                   const pair<int,int> &b) 
{ 
       return a.second>b.second; 
} 

// Function to return gcd of a and b 
ll gcd(ll a, ll b) 
{ 
    if (a == 0) 
        return b; 
    return gcd(b % a, a); 
} 

//Function to return lcm of a and b
ll lcm(ll a,ll b)
{
    return (a*b)/gcd(a,b);
}

int32_t main() {
    fio;

    // int t ;
    // cin >> t ;

    // while( t-- ) {
        
        ll n;
        cin>>n;
        if(n%10==3)
        cout<<"bon"<<endl;
        else if(n%10==0 || n%10==1 || n%10==6 || n%10==8)
        cout<<"pon"<<endl;
        else
        cout<<"hon"<<endl;

    // }

    return 0 ;

}

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

#define pb push_back

#define ll long long

// download zambak book volume 1 phisics pdf free download

#define ft first

#define sd second

using namespace std;

const int N = 5050 ;

bool used[N];

ll z , r , w ;

ll p = -1 ;

int main(){
    ll a, b, cnt1 = 0, cnt2 = 0, x;
    cin >> a >> b >> x;
    cnt1 = a / x;
    cnt2 = b / x;
    if ( a % x == 0 ) cnt1--;
    cout << cnt2 - cnt1 << endl;
}


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

int main(){
	ios::sync_with_stdio(false);cin.tie(0);
	cout << fixed << setprecision(3);
////////////////////////////////////////////	
	int a,b;
	cin >> a >> b;
	b=b*2+1;
	int c=0;
	if(a%b==0) c=1;
	cout << (a/b)+1-c << endl;
//////////////////////////////////////////////
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline


def main():
    N = int(input())
    a = []
    for _ in range(N):
        a.append(int(input()))

    ans = sum(a)
    if ans % 10 != 0:
        print(ans)
        return

    b = list(filter(lambda x: x % 10 != 0, a))
    if b:
        print(ans - min(b))
    else:
        print(0)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
#include<cstdio>
#include<cstdlib>
#include<string>
#include<iostream>
using namespace std;

struct Node {
  int key;
  Node *r, *l, *p;
};

Node *root, *NIL;

void insert(int k){
  Node *y=NIL;
  Node *x=root;
  Node *z;

  z=(Node *)malloc(sizeof(Node));
  z->key=k;
  z->l=NIL;
  z->r=NIL;

  while(x!=NIL){
    y=x;
    if(z->key < x->key){
      x=x->l;
    }else{
      x=x->r;
    }
  }

  z->p=y;
  if(y==NIL){
    root=z;
  }else{
    if(z->key < y->key){
      y->l=z;
    }else{
      y->r=z;
    }
  }
}

void inorder(Node *u){
  if(u==NIL)return;
  inorder(u->l);
  printf(" %d", u->key);
  inorder(u->r);
}

void preorder(Node *u){
  if(u==NIL)return;
  printf(" %d", u->key);
  preorder(u->l);
  preorder(u->r);
}

int main(){
  int n, i, x;
  string com;

  scanf("%d", &n);

  for(i=0;i<n;i++){
    cin>>com;
    if(com=="insert"){
      scanf("%d", &x);
      insert(x);
    }else if(com=="print"){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }
  }
  return 0;
}



Measured memory_bytes: 26744
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ldb = long double;
using pa = pair < ll, ll >;
using vec = vector < ll >;

#define pb push_back
#define F  first
#define S  second
#define int ll
#define f(i,x,n) for(ll i=x;i<n;i++) 
#define all(c) c.begin(),c.end()
#define edl "\n"
#define ceils(s,n) (s+n-1)/n
#define str string
#define add insert
#define fast() ios_base::sync_with_stdio(false);cin.tie(NULL)

const int MOD = 1e9 + 7, N = 5e5 + 10;
const ll LINF = LLONG_MAX;
int a,b,c,d;
str s1,s2;
char ch;
int32_t main() {
    fast();
    cin >>a >> b ;
  if(a==b)
    cout << "Yes";
  else
    cout<<"No";
    return 0;
}
 

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

signed main(){
    int n,m;
    cin >> n >> m;
    int sum=0;
    rep(i,m){
        int a;
        cin >> a;
        sum+=a;
    }
    if(n<sum){
        printf("-1");
    }
    else{
        printf("%d\n",n-sum);
    }



}

Measured memory_bytes: 3764
#define __STDC_FORMAT_MACROS
#define p64 PRId64

#include <algorithm>
#include <cinttypes>
#include <cstdio>
#include <string>
#include <vector>

using namespace std;
using ll = int64_t;

vector<ll> va;
vector<ll> vb;
vector<ll> ta;
vector<ll> tb;

template<class T> void gc(T &x)
{
    char c;
    int s = 0;
    x = 0;

    c = getchar_unlocked();

    if (c == '-') s = 1;
    else if ('0' <= c && c <= '9')  x = c - '0';

    while (true)
    {
        c = getchar_unlocked();

        if (c < '0' || '9' < c) break;
        x = x * 10 + (c - '0');
    }

    if (s) x = -x;
}

int main()
{
    ll N;
    gc(N);

    va.resize(N);
    vb.resize(N);
    ta.resize(N);
    tb.resize(N);

    for (ll i = 0; i < N; i++)
    {
        gc(va[i]);
    }

    for (ll i = 0; i < N; i++)
    {
        gc(vb[i]);
    }

    sort(va.begin(), va.end());
    sort(vb.begin(), vb.end());

    ll amax = va[N - 1];
    ll bmax = vb[N - 1];

    ll d = 2;
    ll x = 1;
    ll ans = 0;
    while ((d >> 1) <= amax + bmax)
    {
        ll t0 = 1 << x;

        for (ll i = 0; i < N; i++)
        {
            ta[i] = va[i] % t0;
            tb[i] = vb[i] % t0;
        }

        // ソートは b だけ
        sort(tb.begin(), tb.end());

        ll a = 0;
        ll suma = 0;
        for (ll i = 0; i < N; i++)
        {
            ll t1 = 1 << (x - 1);
            ll t2 = 2 * t1;

            ll l = t1 - ta[i];
            ll h = t2 - ta[i];

            // [T - ai, 2T - ai) 区間 1
            ll l1 = lower_bound(tb.begin(), tb.end(), l) - tb.begin();
            ll u1 = lower_bound(tb.begin(), tb.end(), h) - tb.begin() - 1;

            ll t3 = 3 * t1;
            ll t4 = 4 * t1;

            l = t3 - ta[i];
            h = t4 - ta[i];

            // [3T - ai, 4T - ai) 区間 2
            ll l2 = lower_bound(tb.begin(), tb.end(), l) - tb.begin();
            ll u2 = lower_bound(tb.begin(), tb.end(), h) - tb.begin() - 1;

            a = 0;
            if (l1 == N)
            {
                // 区間 1 無し
                if (l2 == N)
                {
                    // 区間 2 無し
                    a = 0;
                }
                else
                {
                    // 区間 2 有り
                    a = u2 - l2 + 1;
                }
            }
            else if (l2 == N)
            {
                // 区間 2 無し
                a = u1 - l1 + 1;
            }
            else if (l2 <= u1 && l1 <= u2)
            {
                // 区間が交差する
                a = max(u1, u2) -min(l1, l2) + 1;
            }
            else
            {
                // 区間が交差しない
                a = u1 - l1 + u2 -l2 + 2;
            }
            suma += a;
        }

        if (suma % 2 == 0) suma = 0;
        else suma = 1;

        ans += suma * (1 << (x - 1));

        x++;
        d <<= 1;
    }

    printf("%" p64 "\n", ans);
    return 0;
}


Measured memory_bytes: 6528
void solve();

int main() {
	solve();
	return 0;
}

//////////////////////////////////////////////////
//////////////////////////////////////////////////
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <functional>
#include <limits.h>
#include <complex>
#include <assert.h>
#include <set>
using namespace std;
typedef pair<int, int> pii;
typedef long double ld;
typedef long long ll;
typedef complex<ld> Point;
int N, K;
vector<vector<ll>> dp;

int MOD = 1e9 + 7;

//N!を求める(O(N))
long long stair(int N, int mod = 1000000007) {
	long long temp = 1;
	if (mod != -1) {
		for (int i = 2; i <= N; i++) {
			temp = (temp * i) % mod;
		}
	}
	else {
		for (int i = 2; i <= N; i++) {
			temp = temp * i;
		}
	}
	return temp;
}

//0!,1!,...,N!を求める(O(N))
void stairs(int N, vector<long long>& vec, int mod = 1000000007) {
	long long temp = 1;
	vec.resize(N + 1);
	vec[0] = 1;
	vec[1] = 1;
	for (int i = 2; i <= N; i++) {
		if (mod != -1)temp = (temp * i) % mod;
		else temp *= i;
		vec[i] = temp;
	}
	return;
}

//繰り返し二乗法
//掛け算が定義されていることが必要
//O(log n)
template<class T>
T pow(T base, int p, T mod = -1) {
	if (p == 0)return 1;
	if (p == 1)return mod == -1 ? base % mod : base;
	int b = 1, c = 0;
	while (b <= p) {
		b *= 2;
		c++;
	}
	T* arr2 = new T[c];   //T[n] = T^(2^n)
	arr2[0] = mod == -1 ? base % mod : base;
	for (int n = 1; n < c; n++) {
		if (mod != -1)arr2[n] = (arr2[n - 1] * arr2[n - 1]) % mod;
		else arr2[n] = arr2[n - 1] * arr2[n - 1];
	}
	c--;
	T ans = arr2[c];
	b /= 2;
	p -= b;
	while (p > 0) {
		c--;
		b /= 2;
		if (p >= b) {
			if (mod != -1)ans = (ans * arr2[c]) % mod;
			else ans = ans * arr2[c];
			p -= b;
		}
	}
	return ans;
}

//0!,1!,...,N!の逆元(mod剰余)を求める
//O(log(mod)+N)
void stairInv(int N, vector<long long>& vect, int mod = 1000000007) {
	vect.resize(N + 1);
	long long temp = stair(N, mod);
	temp = pow(temp, mod - 2, (long long)mod);
	vect[N] = temp;
	for (long long n = N - 1; n >= 1; n--) {
		temp = (vect[n + 1] * (n + 1)) % mod;
		vect[n] = temp;
	}
	return;
}

//nCkを求める(mod剰余)
//O(N+log(mod)+max(n-k,k))
long long C(int n, int k, int mod = 1000000007) {
	if (n == k)return 1;
	if (k == 0)return 1;
	long long temp = stair(n, mod);
	vector<long long>* vect = new vector<long long>;
	stairInv(max(n - k, k), *vect, mod);
	temp = (temp * vect->at(n - k)) % mod;
	temp = (temp * vect->at(k)) % mod;
	delete vect;
	return temp;
}

void solve() {
	C(3, 3);
	cin >> N >> K;
	dp.resize(K + 1);
	for (int k = 0; k <= K; k++) {
		dp[k].resize(K + 1,0);
	}
	for (int k = 1; k <= K; k++)dp[k][1] = 1;
	dp[1][1] = 1;
	for (int k = 2; k <= K; k++) {
		for (int i = 2; i <= k; i++) {
			dp[k][i] = dp[k - 1][i] + dp[k - 1][i - 1];
			dp[k][i] %= MOD;
		}
	}
	for (int i = 1; i <= K; i++) {
		if (i > N - K + 1)cout << 0 << endl;
		else cout << (C(N - K + 1, i) * dp[K][i]) % MOD << endl;
	}
	return;
}

Measured memory_bytes: 31616
n = int(input())

#証言のリスト
l = [[-1] * n for i in range(n)]

for i in range(n):
    a = int(input())
    for j in range(a):
        x, y = map(int, input().split())
        #証言の記録
        l[i][x-1] = y

ans = 0

for i in range(2**n):
    Val = True
    for j in range(n):
        if (i >> j & 1) == 1:   #iにおけるjビット目が、1であれば
            for k in range(n):
                if l[j][k] == -1: continue
                if (i >> k & 1) != l[j][k]: Val = False
    if Val:
        res = 0
        num = i
        while num > 0:
            res += num % 2
            num //= 2
            ans = max(ans, res)

print(ans)

Measured memory_bytes: 42972
#include <iostream>
#include <algorithm>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <cmath>

#define AS(a) (sizeof(a)/sizeof(a[0]))
using namespace std;
long long int MOD = 1000000007;

int main() {
  int N,T;
  cin >> N >> T;
  int t[N];
  for(int i = 0; i < N; i++) {
    cin >> t[i];
  }

  int e_a = 0;
  long long int ans = 0;
  for(int i = 0; i < N; i++) {
    if(t[i] >= e_a) {
      ans += T;
    } else {
      ans += (T + t[i]) - e_a;
    }
    e_a = t[i] + T;
  }
  cout << ans << endl;

}


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

int main() {
  int A,B;cin>>A>>B;
  if(A==1&&B!=1) cout << "Alice" << endl;
  if(A==1&&B==1) cout << "Draw" << endl;
  if(A!=1&&B==1) cout << "Bob" << endl;
  if(A!=1&&B!=1){
    if(A>B) cout << "Alice" << endl;
    if(A<B) cout << "Bob" << endl;
    if(A==B) cout << "Draw" << endl;
  }
}


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

#ifdef ENABLE_DEBUG
template <typename T>
void debug(T value) {
  cerr << value;
}
template <typename T, typename... Ts>
void debug(T value, Ts... args) {
  cerr << value << ", ";
  debug(args...);
}
#define DEBUG(...)                              \
  do {                                          \
    cerr << " \033[33m (L" << __LINE__ << ") "; \
    cerr << #__VA_ARGS__ << ":\033[0m ";        \
    debug(__VA_ARGS__);                         \
    cerr << endl;                               \
  } while (0)
#else
#define debug(...)
#define DEBUG(...)
#endif

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int N;
  cin >> N;
  vector<i64> A(N + 1);
  REP(i, N + 1) cin >> A[i];
  vector<i64> ub(N + 1);
  ub[0] = 1;
  for (int i = 1; i <= N; ++i) {
    if (i < 60) {
      ub[i] = ub[i - 1] * 2;
    } else {
      ub[i] = ub[i - 1];
    }
  }

  vector<i64> imax(N + 1), imin(N + 1);
  for (int i = N; i >= 0; --i) {
    // DEBUG(i, A[i], imin[i], imax[i], ub[i]);
    if (A[i] + imin[i] > ub[i]) {
      cout << -1 << endl;
      return 0;
    }
    if (i == 0) break;
    imin[i - 1] = (A[i] + imin[i] + 1) / 2;
    imax[i - 1] = min(A[i] + imax[i], ub[i - 1] - A[i - 1]);
  }

  i64 ans = 0;
  for (int i = 0; i <= N; ++i) {
    ans += imax[i] + A[i];
    DEBUG(i, imax[i], A[i], ans);
    if (i < N) {
      imax[i + 1] = min(imax[i + 1], imax[i] * 2 - A[i + 1]);
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 6312
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
using namespace std;
int main(){
  int n,k,o;
  string s;
  o = 'A' - 'a';
  cin >> n >> k >> s;
  s[k - 1] = s[k - 1] - o;
  cout << s << '\n';
  return 0; 
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define maxn 100010
int n,odd[maxn],uno[maxn],a[maxn];
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
		scanf("%d",&a[i]);
	for(int i=2;i<=n;i+=2){
		++uno[a[i-1]];
		++odd[a[i]];
	}
	int max_odd=0,ci_odd=0,odd_data=-1,ci_odd_data=-1;
	int max_uno=0,ci_uno=0,uno_data=-1,ci_uno_data=-1;
	for(int i=0;i<maxn;i++){
		if(odd[i]>max_odd){
			ci_odd_data=odd_data;
			odd_data=i;
			ci_odd=max_odd;
			max_odd=odd[i];
		}else if(odd[i]>ci_odd){
			ci_odd_data=i;
			ci_odd=odd[i];
		}
		if(uno[i]>max_uno){
			ci_uno_data=uno_data;
			uno_data=i;
			ci_uno=max_uno;
			max_uno=uno[i];
		}else if(uno[i]>ci_uno){
			ci_uno_data=i;
			ci_uno=uno[i];
		}
	}
	if(odd_data!=uno_data)
		printf("%d",n-max_odd-max_uno);
	else{//最大值等于 
		int minn=2147483647;
		minn=min(minn, n-max_odd-ci_uno );
		minn=min(minn, n-ci_odd-max_uno );
		printf("%d",minn);
	}
	return 0;
}

Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define rep(i,m,n) for(int (i)=(m);(i)<(n);++(i))
#define rREP(i,m,n) for(int (i)=(n)-1;(i)>=(m);--(i))
#define all(x) (x).begin(),(x).end()
#define out(y,x,h,w) (y)<0||(x)<0||(y)>=(h)||(x)>=(w)
constexpr int INF = 1000000001;
constexpr ll mod = 1000000007;
constexpr double PI = 3.1415926535897932;
template<class T>inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
template<class T>inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}
inline void init() {
	cin.tie(nullptr); cout.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

int main() {
	init();

	int N; cin >> N;
	vector<string>vec(N);
	map<string, int>mp;
	rep(i, 0, N) {
		cin >> vec[i];
		int a; cin >> a;
		mp[vec[i]] = a;
	}
	string X; cin >> X;
	int ans = 0;
	bool ok = false;
	rep(i, 0, N) {
		if (ok)ans += mp[vec[i]];
		if (vec[i] == X)ok = true;
	}
	cout << ans << "\n";

	return 0;
}

Measured memory_bytes: 3604
import java.util.*;
import java.lang.*;

public class Main {
    public static void main(final String[] args) {
        final Scanner sc = new Scanner(System.in);
        //金額X
        final long X ;
        //　入れる値
        long tempX=100;

        X = sc.nextLong();

        int i = 0;
        int flag = 0;
        for (; flag == 0; i++) {
            tempX = (long) ( tempX* 1.01);	
            if(tempX>=X){
                flag=1;
            }
        }
		System.out.println(i);
}
}

Measured memory_bytes: 27056
//#include <tourist>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> p;
const int INF = 1e9;
const ll LINF = ll(1e18);
const int MOD = 1000000007;
const int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0};
const int Dx[8] = {0, 1, 1, 1, 0, -1, -1, -1}, Dy[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
#define rep(i, n) for (int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()
#define debug(v)          \
    cout << #v << ":";    \
    for (auto x : v)      \
    {                     \
        cout << x << ' '; \
    }                     \
    cout << endl;
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;
}
//cout<<fixed<<setprecision(15);有効数字15桁
//-std=c++14
//-std=gnu++17
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; }
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    vector<int> a(5);
    rep(i,5)cin>>a[i];
    rep(i,5){
        if(a[i]==0)return cout<<i+1<<"\n",0;
    }
}



Measured memory_bytes: 3612
s = input()
t = 0
if s == s[::-1]:
    if s[:(len(s) - 1)//2] == s[:(len(s) - 1)//2][::-1]:
        if s[(len(s) + 3)//2-1:] == s[(len(s) + 3)//2-1:][::-1]:
            t = 1
if t == 1:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 38256
#include <cstdio>
#include <cstring>

const int MAXN=2e5+5;
int n;
int cnt[26],a[MAXN];
char s[MAXN];

inline int chr_idx(char c){return c-'a';}

template<class T>
long long mge_sort(T a[],int l,int r){
	static T tmp[MAXN];
	if(l==r) return 0;
	int mid=l+r>>1;
	long long ret=mge_sort(a,l,mid)+mge_sort(a,mid+1,r);
	int lp=l,rp=mid+1,cur=l-1;
	while(lp<=mid && rp<=r){
		if(a[lp]<=a[rp]) tmp[++cur]=a[lp++];
		else{
			ret+=mid-lp+1;
			tmp[++cur]=a[rp++];
		}
	}
	while(lp<=mid) tmp[++cur]=a[lp++];
	while(rp<=r) tmp[++cur]=a[rp++];
	memcpy(a+l,tmp+l,(r-l+1)*sizeof(T));
	return ret;
}

inline void deal(){
	static int pos[26],pre[MAXN],nex[MAXN];
	static bool use[MAXN];
	memset(pos,-1,sizeof(pos));
	for(int i=n-1;i>=0;--i){
		nex[i]=pos[chr_idx(s[i])];
		pos[chr_idx(s[i])]=i;
	}
	memset(pos,-1,sizeof(pos));
	for(int i=0;i<n;++i){
		pre[i]=pos[chr_idx(s[i])];
		pos[chr_idx(s[i])]=i;
	}
	for(int i=0,x,y;i<n;++i){
		if(use[i]) continue;
		x=i,y=pos[chr_idx(s[i])];
		while(y!=-1){
			a[n-x-1]=y;
			use[x]=true;
			x=nex[x],y=pre[y];
		}
	}
}

inline bool spj(){
	int tot=0;
	for(int i=0;i<26;++i){
		if(cnt[i]&1) ++tot;
	}
	return tot==(n&1);
}

int main(){
	scanf("%s",s);
	n=strlen(s);
	for(int i=0;i<n;++i)
		++cnt[chr_idx(s[i])];
	if(!spj()){
		printf("-1");
		return 0;
	}
	deal();
	printf("%lld",mge_sort(a,0,n-1)>>1);
	return 0;
}

Measured memory_bytes: 3712
ans' (l:[]) = []
ans' ([x0,y0]:[x1,y1]:ls) =
  let dx = x1 - x0
      dy = y1 - y0
      a  = if dx*dy > 0
           then maximum [abs(dx), abs(dy)]
           else abs(dx) + abs(dy)
  in
    a:(ans' ([x1,y1]:ls))

ans x = sum $ ans' x

main = do
  l <- getLine
  c <- getContents
  let [w,h,n] = map read $ words l :: [Int]
      i = map (map read) $ map words $ lines c :: [[Int]]
      o = ans i
  print o



Measured memory_bytes: 4720