akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>
#include <climits>
#include <set>
#include <algorithm>
#include <unordered_map>
#include <queue>
#include <iomanip>
#include <map>
#include <utility>
#include <numeric>
#include <chrono>
#include <ctime>
#include <bitset>
#include <iterator>
#include <cmath>
#include <stack>
#include <random>

#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define debug(x) cerr << #x << ": " << x << ", "
#define debugln(x) cerr << #x << ": " << x << '\n'

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

using namespace std;
using ll = long long;
using P = pair<ll, ll>;

constexpr ll mod = 1e9+7;
const double PI = acos(-1.0);
mt19937_64 engine(chrono::steady_clock::now().time_since_epoch().count());

vector<int> graph[100005];
vector<int> depth(100005);
int ans = 0;
int k;

int dfs(int p) {
  int ret = 0;
  for(auto e: graph[p]) {
    chmax(ret, dfs(e));
  }
  if (p == 1) return 0;
  ret++;
  if (ret >= k && depth[p] != 1) {
    ans++;
    ret = 0;
  }
  //debug(p); debugln(ret);
  return ret;
}

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

  int n; cin >> n >> k;
  vector<int> a(n+1);

  int cnt = 0;

  for(int i=1; i<=n; i++) {
    int a; cin >> a;
    if (a != 1) cnt++;
    if (i==1) {
      if (a != 1) {
        ans++;
      }
      continue;
    }
    graph[a].push_back(i);
  }
  /*if (k==1) {
    cout << cnt << endl;
    return 0;
  }*/

  for(auto e: graph[1]) {
    depth[e] = 1;
  }
  dfs(1);
  cout << ans << endl;
}


Measured memory_bytes: 11264
// finish date: 2018/03/04

#include <iostream>
#include <cmath>
#include <vector>
#include <bitset>
#include <algorithm>
#include <stack>
#include <queue>
#include <map>
#include <climits>

using namespace std;

#define FOR(i, a, b) for(int (i)=a;(i)<(b);(i)++)
#define rep(i, n)  FOR(i,0,n)
#define ll long long
#define vi vector<int>
#define vvi vector<vector<int>>
#define vvvi vector<vector<vector<int>>>
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vd vector<double>
#define vvd vector<vector<double>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define vs vector<string>
#define vc vector<char>
#define vvc vector<vector<char>>
#define bigmod 1000000007
#define INF 1050000000
#define pii pair<int,int>


int main() {
    int N;
    cin>>N;
    map<char,int> mp;
    rep(i,N){
        char c;
        cin>>c;
        mp[c]++;
    }
    if(mp.size()==3){
        cout<<"Three"<<endl;
    }else{
        cout<<"Four"<<endl;
    }


    return 0;
}





Measured memory_bytes: 768
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    from collections import Counter, deque
    from collections import defaultdict
    from itertools import combinations, permutations, accumulate, groupby, product
    from bisect import bisect_left,bisect_right
    from heapq import heapify, heappop, heappush
    from math import floor, ceil,pi,factorial
    from operator import itemgetter
    def I(): return int(input())
    def MI(): return map(int, input().split())
    def LI(): return list(map(int, input().split()))
    def LI2(): return [int(input()) for i in range(n)]
    def MXI(): return [[LI()]for i in range(n)]
    def SI(): return input().rstrip()
    def printns(x): print('\n'.join(x))
    def printni(x): print('\n'.join(list(map(str,x))))
    inf = 10**17
    mod = 10**9 + 7
#main code here!
    s=SI()
    n=len(s)
    ans=n
    pool=0
    for i in range(n):
        if s[i]=="T" and pool>0:
            pool-=1
            ans-=2
        if s[i]=="S":
            pool+=1
    print(ans)
            

                
    
    
    
            
if __name__=="__main__":
    main()


Measured memory_bytes: 9540
using System;

class Program
{
    static void Main(string[] args)
    {
        var trainPrice1 = Convert.ToInt32(Console.ReadLine());
        var trainPrice2 = Convert.ToInt32(Console.ReadLine());
        var busPrice1 = Convert.ToInt32(Console.ReadLine());
        var busPrice2 = Convert.ToInt32(Console.ReadLine());

        var trainMin = Math.Min(trainPrice1, trainPrice2);
        var busMin = Math.Min(busPrice1, busPrice2);
        Console.WriteLine(trainMin + busMin);
    }
}

Measured memory_bytes: 13268
#include <bits/stdc++.h>
typedef unsigned long long u64;
using namespace std;
int mod = 998244353;
int modpow(int n, int p) {
    int t = 1;
    while (p > 0) {
        if (p % 2 == 1) t = (u64) t * n % mod;
        p >>= 1;
        n = (u64) n * n % mod;
    }
    return t;
}
int modinv(int n) {
    return modpow(n, mod - 2);
}
int f[300005];
int ncr(int n, int k) {
    return (u64) f[n] * modinv(f[k]) % mod * modinv(f[n-k]) % mod;
}

void pre() {
    f[0] = 1;
    for (int i = 1; i <= 300000; i++) f[i] = (u64) f[i - 1] * i % mod;
}

int main() {
    pre();
    int n, a, b;
    u64 k;
    scanf("%d %d %d %lld", &n, &a, &b, &k);
    int t = 0;
    for (int count_a = 0; count_a <= n && count_a * a <= k; count_a++) {
        if ((k - ((u64) count_a * a)) % b == 0) {
            u64 count_b = (k - ((u64) count_a * a)) / b;
            if (count_b <= n) {
                t = (t + (u64) ncr(n, count_a) * ncr(n, count_b) % mod) % mod;
            }
        }
    }
    printf("%d\n", t);
}

Measured memory_bytes: 1408
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
#include <stack>
#include <set>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define INF (int)(1123456789)
#define LINF (long long int)(112345678901234567)
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
#define all(v) v.begin(), v.end()

const int N = (int)3e5;

ll mpow(ll a, ll b){
  if(b==0) return 1;
  else if(b%2==0){ll memo = mpow(a,b/2); return memo*memo%MOD;}
  else return mpow(a,b-1) * a % MOD;
}
ll lpow(ll a, ll b){
  if(b==0) return 1;
  else if(b%2==0){ll memo = lpow(a,b/2); return memo*memo;}
  else return lpow(a,b-1) * a;
}
ll gcd(ll a, ll b){
  if(b==0) return a;
  else return gcd(b, a%b);
}
vector<ll> kaijo_memo;
ll kaijo(ll n){
  if(kaijo_memo.size() > n) return kaijo_memo[n];
  if(kaijo_memo.size() == 0) kaijo_memo.push_back(1);
  while(kaijo_memo.size() <= n) kaijo_memo.push_back(kaijo_memo[kaijo_memo.size()-1] * kaijo_memo.size() % MOD);
  return kaijo_memo[n];
}
vector<ll> gyaku_kaijo_memo;
ll gyaku_kaijo(ll n){
  if(gyaku_kaijo_memo.size() > n) return gyaku_kaijo_memo[n];
  if(gyaku_kaijo_memo.size() == 0) gyaku_kaijo_memo.push_back(1);
  while(gyaku_kaijo_memo.size() <= n) gyaku_kaijo_memo.push_back(gyaku_kaijo_memo[gyaku_kaijo_memo.size()-1] * mpow(gyaku_kaijo_memo.size(), MOD-2) % MOD);
  return gyaku_kaijo_memo[n];
}

ll nCr(ll n, ll r){
  if(n == r) return 1;//0個の丸と-1個の棒みたいな時に時に効く？不安.
  if(n < r || r < 0) return 0;
  ll ret = 1;
  ret *= kaijo(n); ret %= MOD;
  ret *= gyaku_kaijo(r); ret %= MOD;
  ret *= gyaku_kaijo(n-r); ret %= MOD;
  return ret;
}


int main(void){
  ll h,w,k;
  cin>>h>>w>>k;
  vector<string> S;
  vector<vector<int>> ans;
  rep(i,h){
    string s;
    cin>>s;
    S.push_back(s);
  }
  rep(i,h){
    ans.push_back(vector<int>());
    rep(j,w){
      ans[i].push_back(-1);
    }
  }
  int num = 1;
  rep(y,h){
    int fx = -1;
    rep(x,w){
      if(S[y][x] == '#'){
        fx = x;
        break;
      }
    }
    if(fx == -1) continue;

    rep(x,w){
      if(x <= fx){
        ans[y][x] = num;
        continue;
      }
      if(S[y][x] == '#'){
        num++;
      }
      ans[y][x] = num;
    }
    num++;
  }

  int fy = -1;
  rep(y,h){
    if(ans[y][0] != -1){
      fy = y;
      break;
    }
  }

  int num_y = fy;
  rep(y,h){
    if(ans[y][0] != -1){
      num_y = y;
      continue;
    }
    rep(x,w){
      ans[y][x] = ans[num_y][x];
    }
  }
  rep(y,h){
    rep(x,w){
      cout<<ans[y][x]<<" ";
    }
    cout<<endl;
  }
  return 0;
}


Measured memory_bytes: 1536
import sys
def S(): return sys.stdin.readline().rstrip()
def I(): return int(sys.stdin.readline().rstrip())
def MI(): return map(int,sys.stdin.readline().rstrip().split())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LS(): return list(sys.stdin.readline().rstrip().split())

n,m,x = MI()
c = [LI() for _ in range(n)]
ans = []

for i in range(2**n):
    c_sum = 0
    a = [0]*m
    for j in range(n):
        c_sum += int(format(i, '0'+ str(n) +'b')[j])*c[j][0]
        for k in range(m):
            a[k] += int(format(i, '0'+ str(n) +'b')[j])*c[j][k+1]
    if min(a) >= x:
        ans.append(c_sum)
if ans == []:
    print(-1)
else:
    print(min(ans))


Measured memory_bytes: 9108
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long x,rem,rep;
    cin>>x;
    rem = x % 11;
    rep = 2*(x / 11);
    if(rem <= 6 && rem > 0)
        rep+=1;
    else if(rem > 6)
        rep+=2;
    cout<<rep<<endl;
    return 0;
}


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

using namespace std;

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

    int total = 0;
    for (int i = 0; i < m; i++) {
        int cur; cin >> cur;
        total += cur;
    }
    // cout << total << " " <<  m << endl;
    if (total > n) cout << -1;
    else cout << n - total;


    return 0;
}


Measured memory_bytes: 3636
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
#define loop(i, a, b) for(li i=a; i<=b; i++)
#define stuff ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
using namespace std;
typedef long long li;
typedef long double ld;
typedef pair<int, int> ii;
typedef pair<li, li> lii;
typedef vector<int> vi;
typedef vector<li> vli;
typedef vector<ii> vii;
typedef vector<lii> vlii;
li mod = 1e9+7;
li expo(li base, li exponent)
{
	li ans=1;
	while(exponent)
	{
		if(exponent&1) ans = (ans*base)%mod;
		base = (base*base)%mod;
		exponent >>= 1;
	}
	return ans;
}
li gcd(li x, li y)
{
	if(y==0) return x;
	return gcd(y, x%y);
}


typedef tree<li, null_type, less<li>,
rb_tree_tag, tree_order_statistics_node_update> ordered_set;

int main()
{
	stuff;
	// #ifndef ONLINE_JUDGE 
	// freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);
	// freopen("error.txt", "w", stderr);
	// #endif

	li r;
	cin >> r;
	double pi = 3.14159265358979;
	double ans = 2*(pi)*r;
	cout << fixed << setprecision(8) << ans;
	return 0;
}


Measured memory_bytes: 3788
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <math.h>
#include <stdio.h>
#define rep(i, a, b) for(int i = a; i < (b); ++i)
using namespace std;
typedef long long ll;


int main() {
    
    double d;
    double t;
    double s;
    cin >> d >> t >> s;
   
    if(d/s <= t) {
        cout << "Yes" << endl;
    }else {
        cout << "No" << endl;
    }
  
     return 0;
}


Measured memory_bytes: 3708
class Integer
  def divisors
    divisor_list = Array.new(0)
    upper_range = self

    if self == 1
      divisor_list << 1
      return divisor_list
    end
    
    for i in 1..self / 2
      if i >= upper_range
        break
      end
      
      if self % i == 0
        divisor_list << i
        if i != self / i
          divisor_list << self / i
        end
        upper_range = self / i
      end
    end

    divisor_list.sort!
  end
end

nums = gets.split.map{|num_str| num_str.to_i}
a = nums[0]
b = nums[1]
c = nums[2]

puts c.divisors.keep_if {|divisor| divisor >= a}.keep_if {|divisor| divisor <= b}.size

Measured memory_bytes: 8664
#include <bits/stdc++.h>
#include <algorithm>
using namespace std;
long long int Inv(long long int a, long long int m) {
	long long int c[50];
  	long long int e[50];  
  	c[0] = (m-2) % 2, e[0] = (m-2) / 2; 
  	for (int i = 0; i < 49; ++i){
     		c[i+1] = e[i] % 2; e[i+1] = e[i] / 2;  
  	}
	long long int d[50]; 
  	d[0] = a; 
  	for (int j = 0; j < 49; ++j){
     		d[j+1] = (d[j] * d[j]) % m; 
  	}
  	long long int Q = 1; 
	for(int k = 0; k < 49; ++k){
  		if(c[k] == 1) Q = (Q * d[k]) % m; 
	}
	return Q;
}
int main(){
	int N; cin >> N; 
	pair<int, int> A[200010] = {}; 
	for(int i = 0; i < N; i++){
		cin >> A[i].first; A[i].second = 1; 
	}
	for(int i = N; i < N*2; i++){
		cin >> A[i].first; A[i].second = 2; 
	}
	sort(A, A+N*2); 
	long long int P = 1e9 + 7; 
	long long int Fac[200010] = {}; 
	Fac[0] = 1; 
	for(int i = 1; i < 200005; i++){
		Fac[i] = (Fac[i-1] * i) % P; 
	}
	vector<int> L = {}; 
	int count = 1; 
	for(int i = 1; i <= N*2; i++){
		if(A[i].second == A[i-1].second) count ++; 
		else{
			L.push_back(count); count = 1; 
		}
	}
	int B[200010] = {}; B[0] = L[0]; 
	for(int i = 1; i < L.size(); i++){
		if(i % 2) B[i] = B[i-1] - L[i]; 
		else B[i] = B[i-1] + L[i]; 
	}
	long long int ans = 1; 
	for(int i = 0; i < (L.size()+2)/2; i++){
		if(B[i*2] * B[i*2+1] > 0){ 
			int a = max(abs(B[i*2]), abs(B[i*2+1])); 
			int b = min(abs(B[i*2]), abs(B[i*2+1])); 
			ans *= Fac[a]; ans = ans % P; 
			ans *= Inv(Fac[b], P); ans = ans % P; 
		}
		else{
			int a = abs(B[i*2]); 
			int b = abs(B[i*2+1]); 
			ans *= Fac[a]; ans = ans % P; 
			ans *= Fac[b]; ans = ans % P; 
		}
	}
	cout << ans << endl; 
}

Measured memory_bytes: 4852
n = int(input())
L = [[] for _ in range(n+1)]
R = [[] for _ in range(n+1)]
for _ in range(n-1):
    u, v, w = map(int, input().split())
    w %= 2
    L[u] += [[u, v, w]]
    R[v] += [[v, u, w]]
P = [[] for _ in range(2*n+2)]
P[1] += (L[1]+R[1])
L[1] = R[1] = []
for i in range(1, 2*n):
    for _, v, w in P[i]:
        P[i+2-w] += (L[v]+R[v])
        L[v] = R[v] = []
A = []
for p in P[1::2]: A += p
B = set([u for u, *_ in A])
for i in range(1, n+1): print(1 if i in B else 0)

Measured memory_bytes: 107800
#include <iostream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <cmath>
#include <limits>
#include <climits>
#include <utility>
#include <algorithm>
#include <numeric>

using namespace std;

using ll = long long;
using ull = unsigned long long;

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

    vector<ll> A(N);
    for (int i = 0; i < N; ++i) {
        cin >> A[i];
    }

    ll ans = 0;
    for (int i = 40; i >= -1; --i) {
        if (i != -1 && !(K & (1LL << i))) {
            continue;
        }

        ll tmp = 0;
        for (int j = 40; j >= 0; --j) {
            ll mask = (1LL << j);

            ll c = 0;
            for (int k = 0; k < N; ++k) {
                if (A[k] & mask) {
                    ++c;
                }
            }

            if (j > i) {
                if (K & mask) {
                    tmp += mask * (N-c);
                } else {
                    tmp += mask * c;
                }
            } else if (j == i) {
                tmp += mask * c;
            } else {
                tmp += mask * max(c, N-c);
            }
        }

        ans = max(ans, tmp);
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 1400
#include<bits/stdc++.h>
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vii vector<int>
#define vll vector<ll>
#define lb lower_bound
#define pb push_back
#define mp make_pair
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=a;i<b;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define INF (1 << 30) - 1
#define LLINF (1LL << 61) - 1
// #define int ll
using namespace std;
const int MOD = 1000000007;
const int MAX = 510000;
 
ll n,e;
ll d[16][16];
ll dp[1<<16][16];
 
// すでに訪れた頂点の集合がS、現在頂点がv
ll rec(ll S,ll v){
    if(dp[S][v]>=0){
        return dp[S][v];
    }
    if(S==(1<<n)-1 && v==0){
        // 全ての頂点を訪れて戻ってきた
        return dp[S][v]=0;
    }
 
    ll res=INF;
    for(ll u=0;u<n;u++){
        if(!(S>>u & 1)){
            // 次に頂点uに移動する
            res=min(res,rec(S | 1<<u ,u) +d[v][u]);
        }
    }
    return dp[S][v] =res;
}
 
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    rep(i,1<<16)rep(j,16){
        dp[i][j]=-1;
    }
    rep(i,20)rep(j,20){
        d[i][j]=INF;
    }
    ll ans=INF;
    cin>>n>>e;
    rep(i,e){
        ll a,b,c;
        cin>>a>>b>>c;
        d[a][b]=c;
    }
    if(rec(0,0)==INF){
        cout<<-1<<endl;
    }
    else{
        cout<<rec(0,0)<<endl;
    }
    return 0;
}


Measured memory_bytes: 11404
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vint = vector<int>;
using vvint = vector<vint>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vchar = vector<char>;
using vvchar = vector<vchar>;
using vp = vector<P>;
using vpp = vector<pair<P, P>>;
using vvp = vector<vp>;

#define rep(i, n) for (int i = 0; i < n; ++i)
#pragma region Debug
istream &operator>>(istream &is, P &a)
{
    return is >> a.first >> a.second;
}
ostream &operator<<(ostream &os, const P &a) { return os << "(" << a.first << "," << a.second << ")"; }

template <typename T>

void view(const std::vector<T> &v)
{
#ifndef ONLINE_JUDGE
    for (const auto &e : v)
    {
        std::cout << e << " ";
    }
    std::cout << std::endl;
#endif
}
template <typename T>
void view(const std::vector<std::vector<T>> &vv)
{
    for (const auto &v : vv)
    {
        view(v);
    }
}
#pragma endregion

int main()
{
    int n;
    cin >> n;
    map<int, int> m;
    vint a(n), b(n);
    rep(i, n)
    {
        cin >> a[i];
        m[a[i]]++;
    }
    rep(i, n)
    {
        cin >> b[i];
        m[b[i]]++;
    }
    for (P p : m)
    {
        if (p.second > n)
        {
            cout << "No" << endl;
            return 0;
        }
    }
    vint c(n + 1), d(n + 1);
    int cp = 0, dp = 0;
    for (int i = 1; i <= n; i++)
    {
        int now = a[cp];
        c[i] = c[i - 1];
        if (now == i)
        {
            while (a[cp] == now)
            {
                c[i]++;
                cp++;
            }
        }
    }
    for (int i = 1; i <= n; i++)
    {
        int now = b[dp];
        d[i] = d[i - 1];
        if (now == i)
        {
            while (b[dp] == now)
            {
                d[i]++;
                dp++;
            }
        }
    }
    int y = 0;

    for (int i = 1; i <= n; i++)
    {
        y = max(y, c[i] - d[i - 1]);
    }

    // rotate
    vint newB(n);
    rep(i, n)
    {
        newB[(i + y) % n] = b[i];
    }
    cout << "Yes" << endl;
    rep(i, n) printf("%d ", newB[i]);
    cout << endl;
    return 0;
}

Measured memory_bytes: 16304
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define ll long long
#define db double
#define ld long double
#define rep(i,n) for(ll i=0;i<n;i++)
#define rev(i,n) for(ll i=n;i>=0;i--)
#define rep_a(i,a,n) for(ll i=a;i<n;i++)
#define pb push_back
#define sz(v) ((int)(v).size())
#define all(v) (v).begin(), (v).end()
#define debug(x) do { std::cerr << #x << ": " << x << std::endl; } while (0);
#define debugg(x,y) do { std::cerr << #x << ": " << x << "  "<< #y << ": " << y << std::endl; } while (0);
#define debugggg(i,j,k,ans) std::cerr << #i << ": " << i << "  "<< #j << ": " << j <<#k << ": " << k <<#ans << ": " << ans << std::endl;
const long long mod = 998244353;
const long long MOD = 1000000007;

typedef vector<ll>              vll;
typedef vector<string>          vstr;
typedef vector<char>            vchar;
typedef vector<pair<ll,ll> >    vpll;
typedef set<ll>                 sll;
typedef set<string>             sstr;
typedef set<pair<ll,ll> >       spll;
typedef map<ll,ll>              mllll;
typedef map<string,ll>          mstrll;
typedef queue<ll>               qll;
int solve()
{
  int n;cin>>n;vll a(n);
  rep(i,n)cin>>a[i];
  sort(all(a));
  int ans = 0;
  rep(i,n)
  {
    rep_a(j,i+1,n)
    {
      if(a[i] == a[j])continue;
      int sum = a[i]+a[j];
      rep_a(k,j+1,n)
      {
        if(a[k]<sum && a[k]!=a[j])ans++;
      }
    }
  }
    return ans;
}
 
int main()
{
  fast;
	// #ifndef ONLINE_JUDGE
	// freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);
	// #else
	// #endif
	cout<<solve()<<endl;;
	// #ifndef ONLINE_JUDGE
	// cout<<"\nTime Elapsed: "<<1.0*clock()/ CLOCKS_PER_SEC <<" Sec\n";
	// #endif
	return 0;
}

Measured memory_bytes: 3620
a=int(input())
for i in range(a):
    x,y,z=[int(i) for i in input().split() ]
    if (x*x==z*z+y*y)or(y*y==z*z+x*x)or(z*z==x*x+y*y):
        print("YES")
    else:
        print("NO")

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

using namespace std;

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

#define int ll

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

	int ans = 0;
	for(int i=0;i<s.length();i++) if(s[i]=='1') ans++;
	cout << ans << endl;

	return 0;
}


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

vector<long> calc(vector<long> A){
  
  
  if (A.size() == 1)
    return A;
  else {
    
    long sum = 0;
    for (int i = 0; i < A.size(); i++){
      sum = A.at(i) + sum*10;
    }
    vector<long> C;
    C.push_back(sum);
//    cout << sum << endl;

    for (int i = 0; i < A.size()-1; i++){
      long left = 0;
      for (int j = 0; j <= i; j++){
        left = A.at(j) + left*10;
//        cout << "LEFT: " << left << endl;
      }
      
      vector<long> right(A.size()-1-i);
      int index = 0;
      for (int j = 0; j < A.size(); j++){
        if (i < j){   
          right.at(index) = A.at(j);
          index++;
        }
      } 
      for (int r : calc(right)){
        C.push_back(r + left);
//        cout << "PUSH: " << r + left << endl; 
      }
    }
    
    return C;
    
  }
}

int main() {
  long S;
  cin >> S;
  
  vector<long> A(10);
  for (int i = 0; i < 10; i++){
    if (S == 0)
      A.pop_back();
    else
      A.at(i) = S%10;
      S = S/10;
  }
  
  reverse(A.begin(), A.end());
  
  for (long a : A){
//    cout << a << endl;
  }
  
  long sum = 0;
  for (long c : calc(A)){
    sum += c;
//    cout << "SUB:" << c << endl;
  }
  
  cout << sum << endl;
}


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

int main(){
    int n;
    int d;
    cin >> n >> d;
    int a = 2*d + 1;
    int ans;
    if(n%a == 0){
        ans = n/a;
    }
    else{
        ans = n/a+1;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import sys
import math
# sys.stdin=open('input.txt','r')
# sys.stdout=open('output2.txt','w')
from sys import stdin,stdout
from collections import deque,defaultdict
from math import ceil,floor,inf,sqrt,factorial,gcd,log2
from copy import deepcopy
ii1=lambda:int(stdin.readline().strip())
is1=lambda:stdin.readline().strip()
iia=lambda:list(map(int,stdin.readline().strip().split()))
isa=lambda:stdin.readline().strip().split()
mod=1000000007

n=ii1()
ans=1000*(1+ n//1000)
if n%1000==0:
    print(0)
else:
    print(ans-n)


Measured memory_bytes: 9548
object Main extends App {

  val n = scala.io.StdIn.readInt()
  val s = scala.io.StdIn.readLine()


  def solve() =  {
    var cnt = 0
    var prevChar: Char = ' '
    s.foreach { char =>
      if(char != prevChar) cnt += 1
      prevChar = char
    }
    cnt
  }

  println(solve)

}


Measured memory_bytes: 29048
#include<bits/stdc++.h>
#define MSET(x,y) memset(x,y,sizeof(x))
#define F first
#define S second
#define MP make_pair
#define PB push_back
#define SZ size()
#define M 100005
#define ll long long
#define ld long double
#define INF 1e18
#define endl "\n"
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
using namespace std;
ll MOD = 1000000007;
string yes = "YES\n";
string no = "NO\n";

int main() {
	ll n,x,t;
	cin>>n>>x>>t;
	ll ans = n/x;
	n = n%x;
	if(n!=0) ans++;
	cout<<ans*t<<endl;
}

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

int main()	{
	int n;
	cin >> n;
	long long array[n];
	for(int i = 0; i < n; i++)	{
		cin >> array[i];
	}
	long long dp[n];
	dp[0] = 0;
	dp[1] = abs(array[1] - array[0]);
	for(int i = 2; i < n; i++)	{
		dp[i] = min(abs(array[i] - array[i - 1]) + dp[i - 1], abs(array[i] - array[i - 2]) + dp[i - 2]);
	}
	cout << dp[n - 1];
}

Measured memory_bytes: 1792
#include <iostream>
#include <iomanip>
#include <math.h>
#include <string>
#include <algorithm>
#include <ctype.h>
#include <vector>
#include <numeric>
#include <map>
#include <queue>
using namespace std;

#define ll long long int
#define rep(i, a, n) for (int i = a; i < n; i++)
#define INF 1e9
#define LINF 1e17
#define MOD (int)(1e9 + 7)
#define pi 3.141592653589
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vi vector<int>
#define vll vector<ll>
#define ALL(a) (a).begin(), (a).end()
#define sort_v(a) sort(a.begin(), a.end())
#define fi first
#define se second

void print(bool c)
{
    if (c)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}

void Print(bool c)
{
    if (c)
        cout << "YES" << endl;
    else
        cout << "NO" << endl;
}

ll gcdll(ll a, ll b)
{
    while (1)
    {
        if (a < b)
            swap(a, b);
        if (b == 0)
            break;
        a %= b;
    }
    return a;
}

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

bool cmp(const pii &a, const pii &b)
{
    if (a.second != b.second)
        return a.second < b.second;
    return a.first < b.first;
}

int main()
{
    int k,x;
    cin>>k>>x;
    for(int i = max(-1000000,x-k+1); i<min(1000001,x+k);i++){
        (i==min(1000001,x+k)-1) ? (cout<<i<<endl) : (cout<<i<<" ");
    }
}


Measured memory_bytes: 256
import java.util.*;
public class Main {

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

		int N = sc.nextInt();
        int D = sc.nextInt();
        int X = sc.nextInt();
        int res = X;
        for (int i = 0; i < N; i ++) {
            res += (D-1) / sc.nextInt() + 1;     
        }

        System.out.println(res);
    }

}

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

int main() {
    int N;
    cin >> N;
    long long ct=1;
    long long temp=0;
    vector<long long> num(1010);
    vector<int>prime;
    for(int i=2;i<=1000;i++){
        prime.push_back(i);
    }
    int nu=2;
    int fl=0;
    while(nu*nu<=1000){
        for(int i=0;i<prime.size();i++){
            if(prime[i]==nu)continue;
            else{
                if(prime[i]%nu==0){
                    prime.erase(prime.begin()+i);
                    i--;
                }
            }
        }
        fl++;
        nu=prime[fl];
    }
    for(int i=1;i<=N;i++){
        for(int j=0;j<prime.size();j++){
            int temp=i;
            while(temp!=0 && temp%prime[j]==0) {
                num[prime[j]]++;
                temp/=prime[j];
            }
        }
    }
    for(int i=0;i<=prime.size()-1;i++){
        if(num[prime[i]]!=0){
             ct=(ct*(num[prime[i]]+1))%(1000000007);
        }
    }
    cout << ct << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>

using namespace std;

int num(int n);

int main()
{
	int n;

	while(true){
		cin >> n;
		if(n==0){break;}
		else{
			cout << num(n) << endl;
		}
	}  

	return 0;
}

int num(int n){
	
	int i, j;
	int count=0,flag=0;

	for(i=n+1; i<=2*n; i++){
		flag=0;
		if(i==2){count++;}
		else if((i%2) == 0){;}
		else{
			for(j=2; j <= sqrt(i); j++){
				if(i%j == 0){flag = 1;break;}
			}
			if(flag == 0){count++;}
		}
	}

	return count;
}

Measured memory_bytes: 1160
Dic = [1000, 961, 900, 841, 784, 729, 676, 625, 576, 529, 512, 484, 441, 400, 361, 343, 324, 289, 256, 243, 225, 216, 196, 169, 144, 128, 125, 121, 100, 81, 64, 49, 36, 32, 27, 25, 16, 9, 8, 4, 1]
x = gets.to_i
puts Dic.bsearch{|y| y <= x}


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

int main(){
    int n;
    cin>>n;
    vector<int> num(n);
    rep(i,n)cin>>num[i];
    int ans = 20021003;

    for(int i = 0; i < n; i++){
        int small=0;
        int big=0;
        for(int j = 0; j < n; j++){
            
            if(j<=i){
                small += num[j];
            }else{
                big += num[j];
            }
        }
        ans = min(ans, abs(small-big));
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <queue>
#include <iostream>
using namespace std;
int main() {
    int k; cin >> k;
    queue<long long> q;
    for (int i = 1; i < 10; i++) q.push(i);
    for (;;) {
        long long n = q.front(); q.pop();
        if (--k == 0) { cout << n << endl; break; }
        for (int d = max(0LL, n % 10 - 1); d <= min(9LL, n % 10 + 1); d++)
            q.push(10*n+d);
    }
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int64_t i = 0; i < (n); ++i)
#define repe(i, n) for (int64_t i = 0; i <= (n); ++i)
#define reps(i, s, n) for (int64_t i = (s); i < (n); ++i)
#define repse(i, s, n) for (int64_t i = (s); i <= (n); ++i)
#define repr(i, n) for (int64_t i = (n); i >= 0; --i)
const int64_t inf = (int64_t)1e18;
const int64_t mod = (int64_t)1e9 + 7;


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

  string S; cin >> S;
  int64_t N = S.length();

  int64_t ans_0, ans_1; ans_0 = ans_1 = 0;

  rep(i, N) {
    if (i & 1) {
      if (S[i] == '0') ans_0++;
      if (S[i] == '1') ans_1++;
    } else {
      if (S[i] == '1') ans_0++;
      if (S[i] == '0') ans_1++;
    }
  }

  cout << min(ans_0, ans_1) << endl;

  return 0;
}

Measured memory_bytes: 512
open System
open System.Collections
open System.Collections.Generic
open System.IO
open System.Linq

[<AutoOpen>] 
module input =
    let Str()  = Console.ReadLine()
    let Int()  = Str() |> int
    let Char() = Str() |> char
    let CharList()  = [ for c in Str() -> c ]
    let CharArray() = [|for c in Str() -> c|]
[<AutoOpen>] 
module parse =
    let c2s (c:obj) = 
        match c with
        | :? (char[])    as c -> new string(c)
        | :? (char list) as c -> c|>Array.ofList|>String
        | :?  char       as c -> c.ToString()
        | _ -> failwith ""
    let c2i c = c2s(c) |> int

let enumerateSplitElement(str:string) =
    let strArr = [|for c in str ->string c|] |> Array.rev    
    let rec f (elem:string) lis cnt =
        seq{
            if cnt=strArr.Length then 
                yield! [elem::lis]
            else
                yield! f (strArr.[cnt]+elem) lis         (cnt+1)
                yield! f  strArr.[cnt]       (elem::lis) (cnt+1)
        }
    f strArr.[0] [] 1

[<EntryPoint>]
let main _ = 
    let S = Str()

    let ans = 
        Seq.sumBy List.sum (enumerateSplitElement(S)
        |> Seq.map (fun x -> List.map(int64) x))

    printfn "%i" ans

    0
    



Measured memory_bytes: 14300
object Main extends App {

  import scala.io.StdIn._

  case class Cloth(a: Int, b: Int, c: Int)
  val Array(d, n) = readLine.trim.split(' ').map(_.toInt)
  val temp = List.tabulate(d){_ ⇒ readLine.trim.toInt}
  val clothes = Array.tabulate(n){_ ⇒
    val Array(a, b, c) = readLine.trim.split(' ').map(_.toInt)
    Cloth(a, b, c)
  }
  println(
    calMax(temp, clothes)
  )
  def calMax(temp: List[Int], clothes: Array[Cloth]): Int = {
    def sub(t: List[Int], cl: Array[Cloth], last: Int)(implicit memo: Array[Array[Option[Int]]]): Int = {
      memo(t.length)(last) match {
        case Some(r) ⇒ r
        case None ⇒ {
          (t match {
            case Nil ⇒ 0
            case h::r ⇒ cl.withFilter(c ⇒ (c.a to c.b).contains(h)).map(c ⇒ sub(r, cl, c.c) + (c.c - last).abs).max
          }).also{it ⇒ memo(t.length)(last) = Some(it)}
        }
      }
    }
    implicit val memo = Array.tabulate(temp.length){_ ⇒ Array.tabulate(101){_ ⇒ None: Option[Int]}}
    temp match {
      case Nil ⇒ 0
      case h::t ⇒ clothes.withFilter(c ⇒ (c.a to c.b).contains(h)).map(c ⇒ sub(t, clothes, c.c)).max
    }
  }
  implicit class ScopeFunc[T](val value: T) {
    def let[A](func: T ⇒ A): A = func(value)

    def also(func: T ⇒ Unit): T = {
      func(value)
      value
    }
  }
}

/*
 */


Measured memory_bytes: 83092
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#include <set>
#define MOD 1000000007
#define mkp make_pair
typedef long long ll;
using namespace std;

int Q;
vector<int> qry;
vector<ll> A,B;

int main(){
  cin>>Q;
  qry.resize(Q);
  A.resize(Q,0);
  B.resize(Q,0);
  for(int i=0;i<Q;i++){
    cin>>qry[i];
    if(qry[i]==2) continue;
    cin>>A[i]>>B[i];
  }

  priority_queue<ll> PQl;
  priority_queue<ll,vector<ll>,greater<ll>> PQr;

  ll suml=0,sumr=0;
  vector<pair<ll,ll>> res;
  ll dif=0;
  for(int i=0;i<Q;i++){
      if(qry[i]==2){
          ll ans=0;
          ll mid=PQl.top();
          ans=sumr-PQr.size()*mid+PQl.size()*mid-suml;
          res.push_back(mkp(PQl.top(),ans+dif));
      }else{
          dif+=B[i];
          if(PQl.empty()){
              PQl.push(A[i]);
              suml+=A[i];
          }else if(PQr.empty()){
              ll a=PQl.top();
              if(a<=A[i]){
                  PQr.push(A[i]);
                  sumr+=A[i];
              }else{
                  PQl.pop();
                  suml-=a;
                  PQr.push(a);
                  sumr+=a;
                  PQl.push(A[i]);
                  suml+=A[i];
              }
          }else{
              ll a=PQl.top();
              ll b=PQr.top();
              if(PQl.size()==PQr.size()){
                  if(A[i]<=b){
                      PQl.push(A[i]);
                      suml+=A[i];
                  }else{
                      PQr.pop();
                      sumr-=b;
                      PQl.push(b);
                      suml+=b;
                      PQr.push(A[i]);
                      sumr+=A[i];
                  }
              }else{
                  if(a<=A[i]){
                      PQr.push(A[i]);
                      sumr+=A[i];
                  }else{
                      PQl.pop();
                      suml-=a;
                      PQr.push(a);
                      sumr+=a;
                      PQl.push(A[i]);
                      suml+=A[i];
                  }
              }
          }
      }
  }

  for(int i=0;i<res.size();i++) cout<<res[i].first<<" "<<res[i].second<<endl;


  return 0;
}


Measured memory_bytes: 9708
#define cross(a1, b1, a2, b2) ((a1)*(b2)-(a2)*(b1))
int main(){
    double a[100],b[100],s,t,x;
    int n,c=1,i;
    for(;~scanf("%d",&n);printf("%.1lf\n",fabs(s-t)),c++){
        for(i=0;i<n;i++)scanf("%lf%lf",a+i,b+i);
        for(i=s=t=0;i<n-1;i++){
            if((x=cross(a[i],b[i],a[i+1],b[i+1]))>0)s+=fabs(x)/2.0;
            else t+=fabs(x)/2;
        }
        if((x=cross(a[i],b[i],a[0],b[0]))>0)s+=fabs(x)/2;
        else t+=fabs(x)/2;
    }
exit(0);}

Measured memory_bytes: 664
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    n = int(readline())
    mat = []
    for _ in range(n):
        a, b = map(int, readline().split())
        c = a + b
        mat.append([c, a, b])

    mat.sort(reverse=True)

    a_sum, b_sum = 0, 0

    for i in range(n):
        if i % 2 == 0:
            a_sum += mat[i][1]
        else:
            b_sum += mat[i][2]

    print(a_sum - b_sum)


if __name__ == '__main__':
    main()


Measured memory_bytes: 86648
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
#define rep(i,n) for (ll i=0; i<(n); ++i)
#define rep1(i,n) for (ll i=1; i<=(n); ++i)
typedef long long ll;
bool debug=false;
string yes = "Yes";
string no = "No";
const ll mod = 998244353;
const double e = 0.000000001;

int main(){
  ll n; cin >>n;
  vector<ll> v;
  rep(i,n){
    ll a; cin >> a;
    if(a==0){
      cout << 0;
      return 0;
    }
    v.push_back(a);
  }
  ll ans=1;
  ll r = (ll)pow(10,18);
  long double sumlog=0;
  for(auto e:v){
    sumlog+=log10l((long double)e);
    if(sumlog>18.000000){
      cout << -1;
      return 0;
    }
  }
  for(auto e:v){
    ans*=e;
    if(ans>r){
      cout << -1;
      return 0;     
    }
  }
  cout << ans;
  return 0;
}
// 999999999999999999

Measured memory_bytes: 4360
<?php
$nums = array (1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51);
$k = trim(fgets(STDIN));
echo $nums[$k - 1].PHP_EOL;

Measured memory_bytes: 3828
#include<bits/stdc++.h>
using namespace std;
long long z[1000001];
int main()
{
	long long n,p,x,ba=1;
	cin>>n>>p;
	if(n==1)
	{
		cout<<p;
		return 0;
	}
	x=p;
	for(long long t=2;t*t<=p;t++)
	{
		while(x%t==0)
		{ 
			x/=t;
			z[t]++;
		}
	}
	for(long long t=2;t*t<=p;t++)
	{
		if(z[t]>=n)
		{
			for(int i=0;i<z[t]/n;i++)
			{
				ba*=t;
			}
		}
	}
	cout<<ba;
	return 0;
} 

Measured memory_bytes: 2304
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;

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

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

// Self settings
// clang-format off
#define MAX_N 100000
#define MAX 100000
#define INFTY (1<<30)
#define EPS (1e-10)
#define equals(a, b) (fabs((a) - (b)) < EPS)
#define REP(i, N) for (int i = 0; i < (int)(N); ++i)
#define SLN(i,N) (i == N-1 ? "\n" : " ")
ll fact(ll n) { ll res = 1; for(ll i=2;i<=n;++i) res = res * i; return res;}
ll nCr(ll n, ll r) {return (fact(n)/fact(n-r)*fact(r)) ;}
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;}
const ll MOD = 1e9+7;
const ll INF = 1LL << 60;
const int inf = 1000100011;
class Point { public: double x, y; Point(double x = 0, double y = 0) : x(x), y(y) {} Point operator+(Point p) { return Point(x + p.x, y + p.y); } Point operator-(Point p) { return Point(x - p.x, y - p.y); } Point operator*(double a) { return Point(a * x, a * y); } Point operator/(double a) { return Point(x / a, y / a); } double abs() { return sqrt(norm()); } double norm() { return x * x + y * y; } bool operator<(const Point& p) const { return x != p.x ? x < p.x : y < p.y; } bool operator==(const Point& p) const { return fabs(x - p.y) < EPS && fabs(y - p.y) < EPS; } };
typedef Point Vector;
double norm(Vector a) { return a.x * a.x + a.y * a.y; }
double abs(Vector a) { return sqrt(norm(a));}
double dot(Vector a, Vector b) { return a.x * b.x + a.y * b.y; }
double cross(Vector a, Vector b) { return a.x * b.y - a.y * b.x; }
struct Segment { Point p1, p2; };
typedef Segment Line;
// clang-format on

int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N;
  cin >> N;
  vector<int> A(N);
  REP(i, N) cin >> A[i];

  map<int, int> mp;
  map<int, ll> mpa;
  REP(i, N) { mp[A[i]]++; }
  ll ans = 0;
  for (auto m : mp) {
    mpa[m.first] = ((ll)m.second * (m.second - 1)) / (ll)2;
    ans += (ll)mpa[m.first];
  }
  REP(k, N) {
    ll m = mp[A[k]];
    ans -= (ll)(m * (m - 1)) / (ll)2;
    m--;
    ans += (ll)(m * (m - 1)) / (ll)2;
    cout << ans << endl;
    ans -= (ll)(m * (m - 1)) / (ll)2;
    m++;
    ans += (ll)(m * (m - 1)) / (ll)2;
  }

  return 0;
}


Measured memory_bytes: 16280
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,k,q,a[100009];
    scanf("%d%d%d",&n,&k,&q);
    memset(a,0,sizeof(a));
    for(int i=1;i<=q;i++)
    {
        int x;
        scanf("%d",&x);
        a[1]++;
        a[x]--;
        a[x+1]++;
        a[n+1]--;
    }
    for(int i=1;i<=n;i++)
    {
        a[i]+=a[i-1];
        //printf("%d\n",k-a[i]);
        if(k-a[i]<=0)
            printf("No\n");
        else
            printf("Yes\n");
    }
    return 0;
}


Measured memory_bytes: 1024
using System;
using System.Collections.Generic;

namespace _20200328
{
    class Program
    {
        static void Main()
        {
            var firstLine = Console.ReadLine().Split(' ');
            var k = int.Parse(firstLine[0]);
            var n = int.Parse(firstLine[1]);
            var aStrList = Console.ReadLine().Split(' ');
            var aList = new List<int>();
            foreach (var aStr in aStrList)
            {
                aList.Add(int.Parse(aStr));
            }
            // An to A1
            var maxL = k - aList[aList.Count - 1] + aList[0];
            for (var i = 0; i < aList.Count - 1; ++i)
            {
                var ai = aList[i + 1] - aList[i];
                if (maxL < ai)
                {
                    maxL = ai;
                }
            }
            Console.WriteLine(k - maxL);
        }
    }
}


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

struct RSQ {
	using type = int;
	static const type id() { return 0; }
	static type op(const type& l, const type & r) { return l + r; }
};

template <typename M>
class SegmentTree {
	using T = typename M::type;
	const int n;
	vector<T> data;
	int size(int n) {
		int res;
		for (res = 1; res < n; res <<= 1);
		return res;
	}
public:
	SegmentTree(int n_) :
		n(size(n_)), data(n * 2, M::id()) {}
	void init(const vector<T>& data_) {
		for (int i = 0; i < (int)data_.size(); i++)
			data[i + n] = data_[i];
		for (int i = n - 1; i >= 0; i--)
			data[i] = M::op(data[i * 2], data[i * 2 + 1]);
	}
	void update(int p, T val) {
		p += n;
		data[p] = val;
		while (p >>= 1) data[p] = M::op(data[p * 2], data[p * 2 + 1]);
	}
	void add(int p, T val) {
		p += n;
		data[p] += val;
		while (p >>= 1) data[p] = M::op(data[p * 2], data[p * 2 + 1]);
	}
	T find(int l, int r) {
		l += n; r += n + 1;
		T res1 = M::id(), res2 = M::id();
		while (l < r) {
			if (l & 1) res1 = M::op(res1, data[l++]);
			if (r & 1) res2 = M::op(data[--r], res2);
			l >>= 1; r >>= 1;
		}
		return M::op(res1, res2);
	}
};

int main()
{
	ios::sync_with_stdio(false), cin.tie(0);
	int n, q, com, x, y;
	cin >> n >> q;
	SegmentTree<RSQ> st(n);
	while (q--) {
		cin >> com >> x >> y;
		if (com) {
			printf("%d\n", st.find(x - 1, y - 1));
		}
		else {
			st.add(x - 1, y);
		}
	}
	return 0;
}

Measured memory_bytes: 3752
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
int n;
ll x,a[200005],f[200005];

int main(){
	scanf("%d%lld",&n,&x);
	repn(i,n) scanf("%lld",&a[i]);
	repn(i,n) scanf("%lld",&f[i]);
	sort(a+1,a+n+1);
	sort(f+1,f+n+1,greater<ll>());
	ll lb = -1,ub = 2e12;
	while(ub-lb > 1){
		ll mid = (lb+ub)/2;
		ll need = 0;
		repn(i,n){
			ll x = mid / f[i];
			if(x < a[i]) need += a[i]-x;
		}
		if(need <= x) ub = mid;
		else lb = mid;
	}
	cout << ub << endl;
}

Measured memory_bytes: 3456
#include <stdio.h>

int main(){
   int a,b,c,k;

   scanf("%d %d %d",&a,&b,&c);
   scanf("%d",&k);
   for (;k>0 && a>=b;k--) b*=2;
   for (;k>0 && b>=c;k--) c*=2;
   if (c>b && b>a) puts("Yes");
   else            puts("No");
   return 0;
}

Measured memory_bytes: 1664
import sys


def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def I(): return int(sys.stdin.buffer.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]


h, w = LI()
a = SR(h)

print('#' * (w + 2))
for s in a:
    print('#' + s + '#')
print('#' * (w + 2))


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

using ll = long long;
#define rep(i, n) for (long long i = 0; i < (n); ++i)
#define repr(i, a, b) for (auto i = (a); i < (b); ++i)
#define itr(x) for (auto&& v : (x))
#define updatemax(t, v) ((t) = std::max((t), (v)))
#define updatemin(t, v) ((t) = std::min((t), (v)))

int main() {
  string s, t, u;
  ll a, b;
  cin >> s >> t >> a >> b >> u;
  cout << a - (s == u) << ' ' << b - (t == u) << endl;
}


Measured memory_bytes: 3632
#include<bits/stdc++.h>
#define ll long long int
#define pb push_back
#define pob pop_back
#define vl vector<ll>
#define mp make_pair
#define sz size()
#define fast ios::sync_with_stdio(0);cin.tie(0)
#define maxx 100005
#define edge pair<ll,ll>
using namespace std;
 
 
// ¦¦¦¦¦¦¦¦¦¦¦¦+++++++++++++++++¦¦¦++++++¦¦
// ¦¦¦¦¦¦¦¦¦¦¦¦¦++++++++++++¦¦¦¦¦¦¦¦¦¦+++¦¦
// ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦++++++++¦¦¦¦¦+++++++¦++¦¦
// ¦¦¦¦¦¦¦¦++¦¦¦¦¦¦++++++¦¦¦¦+++++++++++++¦
// ¦¦¦¦¦¦¦++++++¦¦¦++++++¦¦++++++++++++++¦¦
// ¦¦¦¦¦¦¦+++++++¦¦¦+++++++++++++++++++++¦¦
// ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦++++++¦¦¦¦¦¦¦¦¦++++¦¦
// ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦+++++¦¦¦¦¦¦¦¦+++++++¦ 
// ¦¦¦¦¦¦¦¦¦¦++¦¦¦¦¦¦¦+++++++++++++++++++¦¦
// ¦¦¦¦¦¦¦++++¦¦¦¦¦¦¦¦+++++++++++++++++++¦¦
// ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦+++++++++++++++++++¦¦
// ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦+++++++++++++++++++¦¦
// ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦+++++++++++++++++++¦¦
// ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦+++++++++++++++++++¦¦ 
// ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦++++++++++++++++++++¦¦
// ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦++++++++++++¦¦+¦++¦¦¦
// ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦+++++++¦¦+++++¦¦¦
// ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦+¦¦¦¦+++¦¦¦¦++++++¦¦¦
// ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦+++¦¦+¦¦¦¦¦+++++++¦¦¦¦
// ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦+++++++++++¦¦¦¦
// ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦+++++++++++++++++++¦¦¦¦¦
// ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦++++++++++++++++¦¦¦¦¦¦
// ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦+++++++++++¦¦¦¦¦¦¦
// ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦+¦¦¦+++++++++++¦¦¦¦¦¦¦¦
// ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦+++++++++¦¦¦¦¦¦¦¦¦
// ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦++++++++¦¦¦¦¦¦¦¦¦¦
// ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦++++++¦¦¦¦¦¦¦¦¦¦¦¦
 map<ll,ll>m;
int main()
{
	ll n;
	cin>>n;
	vector<double>v;
	ll i;
	double a;
	for(i=0;i<n;i++)
	{
		cin>>a;
		v.pb(a);
	}
	ll j;
	double dp[n+1][n+1];
	dp[0][0]=1.0;
	for(j=1;j<=n;j++)
	{
		dp[0][j]=0;
	}
	for(i=1;i<=n;i++)
	{
		for(j=0;j<=i;j++)
		{
			if(j==0)
			{
				dp[i][j]=(1.0-v[i-1])*dp[i-1][j];
			}
			else
			{
				dp[i][j]=(v[i-1])*dp[i-1][j-1]+(1-v[i-1])*dp[i-1][j];
			}
		}
		
	}
	double sum=0;
	for(i=n/2+1;i<=n;i++)
	{
		sum+=dp[n][i];
	}
	cout<<fixed<<setprecision(10)<<sum<<endl;
}

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

using namespace std;

#define ll  long long

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	ll c;
	cin >> n >> c;
	vector<ll> x(n + 1, 0);
	vector<ll> v(n + 1, 0);
	ll vallsum = 0;
	for (int i = 1; i <= n; i++) {
		cin >> x[i] >> v[i];
		vallsum += v[i];
	}

	ll vrsum = 0, vlsum = 0, dpr = 0, ans = 0;
	vector<ll> dpl(n + 1, 0);
	for (int i = n - 1; i >= 1; i--) {
		vlsum += v[i + 1];
		dpl[i] = max(dpl[i + 1], vlsum - (c - x[i + 1]) * 2);
	}

	for (int i = 1; i <= n; i++) {
		vlsum = vallsum - vrsum;
		vrsum += v[i];

		ans = max(ans, vrsum - x[i] + dpl[i]);
		ans=max(ans, vlsum - (c - x[i]) + dpr);
		dpr = max(dpr, vrsum - x[i] * 2);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 2560