akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define endl '\n'
#define fast ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define zy -2147382637
#define bql 2147483647
#define ll long long
#define ull unsigned long long
#define ld long double
#define maxn 100010
#define rp(i, l, r) for (int i = l; i <= r; i++)
#define rb(i, r, l) for (int i = r; i >= l; i--)
#define fi first
#define se second
#define pb push_back
#define mp make_pair

using namespace std;
ll prime(ll x){
   if(x<=1)return false;
   for(int i=2;i<=int(sqrt(x));i++){
	   if(x%i==0)return false;
   }return true;
}
ll gcd(ll a,ll b){ll r;while(b>0){r=a%b;a=b;b=r;}return a;}
ll powmod(ll a,ll b,ll mod) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
template <typename T>
inline void read(T &x) {
	char c = getchar(); int w = 1; x = 0;
	while (!isdigit(c))
		(c == '-') && (w = -w), c = getchar();
	while (isdigit(c))
		x = (x << 1) + (x << 3) + (c ^ '0'), c = getchar();
	x *= w;
}
const int dx[8] = {-1, 1, 0, 0, -1, 1, -1, 1},
		  dy[8] = {0, 0, -1, 1, -1, -1, 1, 1};
bool cmp(ll a,ll b){
	return a>b;
}
int main(){
	fast;
	ll n;
	cin>>n;
	cout<<n*(n-1)/2<<endl;
	return 0;
	return 0;
}/*『你强归你强，我永不示弱』*/


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include <cstdlib>  
#include <cmath>   
#include<cctype>
#include<string>
#include<set>
#include <map>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include <deque>
#include <climits>
#include <typeinfo>
#include <utility>
using namespace std;

int main() {
	int a,b;
	cin >> a>>b;
	cout <<a*b <<" "<<2*(a+b)<< endl;
	return 0;
}


Measured memory_bytes: 3080
#include <bits/stdc++.h>
using namespace std;
 
int main() {

  vector<int> vec(5);
 
  cin >> vec.at(0) >> vec.at(1) >> vec.at(2) >> vec.at(3) >> vec.at(4);
  
  int n;
  cin >> n; 

  if(vec.at(4)-vec.at(3) > n || vec.at(4)-vec.at(2) > n || vec.at(4)-vec.at(1) > n || vec.at(4)-vec.at(0) > n
    || vec.at(3)-vec.at(2) > n || vec.at(3)-vec.at(1) > n || vec.at(3)-vec.at(0) > n
    || vec.at(2)-vec.at(1) > n || vec.at(2)-vec.at(0) > n || vec.at(1)-vec.at(0) > n){
    cout << ":(" << endl;
  }else {
     cout << "Yay!" << endl;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define mp make_pair
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
#define inf (int)(1e9+7)
#define abs(x) (x >= 0 ? x : -(x))
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<typename T> inline T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }



int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    
    int n, m, l;
    cin >> n >> m >> l;
    ll d[n][n];
    rep(i, n) rep(j, n) d[i][j] = 1e18;
    rep(i, m) {
        int s, t, c;
        cin >> s >> t >> c;
        s--; t--;
        d[s][t] = c;
        d[t][s] = c;
    }
    
    rep(i, n) d[i][i] = 0;
    rep(k, n) rep(i, n) rep(j, n) {
        if (d[i][k] + d[k][j] < d[i][j]) d[i][j] = d[i][k] + d[k][j];
    }

    rep(i, n) rep(j, n) {
        if (d[i][j] <= l) d[i][j] = 1;
        else d[i][j] = 1e18;
    }
    
    rep(k, n) rep(i, n) rep(j, n) {
        if (d[i][k] + d[k][j] < d[i][j]) d[i][j] = d[i][k] + d[k][j];
    }
    
    int q;
    cin >> q;
    rep(i, q) {
        int s, t;
        cin >> s >> t;
        s--; t--;
        if (d[s][t] == 1e18) cout << -1 << endl;
        else cout << d[s][t] - 1 << endl;
    }
}


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

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

    int ans,count;
    ans=0;
    bool flag;
    flag=false;
    count=0;
    for(int i=0; i< s.size(); i++){
        if( s[i] == 'A' && (!flag) ){
            flag=true;
            count=i;
        }
        if(flag){
            if( s[i] == 'Z' ){
                ans = i - count + 1;
            }
        }
    }

    cout << ans << endl;

    return 0;
}

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

int main() {
  string w;
  int ans = 0;
  vector<string> T;
  cin >> w;
  int i = 0;
  while(1){
      string t;
      cin >> t;
      if(t == "END_OF_TEXT"){
          break;
      }
      T.push_back(t);
  }
  for(i = 0; i < T.size(); i++){
      for(int j = 0; j < T.at(i).size(); j++){
          if(isupper(T.at(i).at(j))){
              T.at(i).at(j) += 32;
          }
      }
      if(w == T.at(i)){
          ans++;
      }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3032
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int x[] = new int[n + 1];
		x[n] = sc.nextInt();
		for(int i = 0; i < n; i++) { 
			x[i] = sc.nextInt();
		}
		Arrays.sort(x);
		int d = x[1] - x[0];
		for(int i = 1; i + 1 <= n; i++) {
			d = gcd(d, x[i + 1] - x[i]);
		}
		System.out.println(d);
	}
	
	static int gcd(int x, int y) {
		int w;
		while(x % y != 0) {
			w = y;
			y = x % y;
			x = w;
		}
		return y;
	}
}

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

using namespace std;

#define RI register int

int read() {
  int q = 0;
  char ch = ' ';
  while (ch < '0' || ch > '9') ch = getchar();
  while (ch >= '0' && ch <= '9') q = q * 10 + ch - '0', ch = getchar();
  return q;
}

const int mod = 1e9 + 7, N = 100005;

int n, ans;
int a[N], du[N], cir[N], vis[N], footL[N], sum[N], f[N];

int qm(int x) { return x >= mod ? x - mod : x; }
void workcir(int x) {
  int now = 0, fr = 0, ed = 0, frL = 0;
  while (cir[x]) {
    ++now, cir[x] = 0;
    if (footL[x]) {
      if (!fr)
        ed = fr = now, frL = footL[x];
      else {
        int kl = (footL[x] < now - ed) + (footL[x] <= now - ed);
        ans = 1LL * ans * kl % mod, ed = now;
      }
    }
    x = a[x];
  }
  if (!fr)
    ++sum[now];
  else {
    int kl = (frL < now - ed + fr) + (frL <= now - ed + fr);
    ans = 1LL * ans * kl % mod;
  }
}

void work() {
  for (RI i = 1; i <= n; ++i) {
    if (du[i]) continue;
    int x = i, len = 0;
    while (!cir[x]) x = a[x], ++len;
    footL[x] = len;
  }
  ans = 1;
  for (RI i = 1; i <= n; ++i)
    if (cir[i]) workcir(i);
  for (RI i = 1; i <= n; ++i) {
    if (!sum[i]) continue;
    f[0] = 1;
    for (RI j = 1; j <= sum[i]; ++j) {
      if (i > 1 && (i & 1))
        f[j] = qm(f[j - 1] + f[j - 1]);
      else
        f[j] = f[j - 1];
      if (j > 1) f[j] = qm(f[j] + 1LL * f[j - 2] * (j - 1) % mod * i % mod);
    }
    ans = 1LL * ans * f[sum[i]] % mod;
  }
}

int main() {
  n = read();
  for (RI i = 1; i <= n; ++i) a[i] = read(), ++du[a[i]];
  for (RI i = 1; i <= n; ++i) {
    if (vis[i]) continue;
    int x = i;
    while (!vis[x]) vis[x] = i, x = a[x];
    if (vis[x] != i) continue;
    while (!cir[x]) cir[x] = 1, x = a[x];
  }
  for (RI i = 1; i <= n; ++i)
    if ((cir[i] && du[i] > 2) || (!cir[i] && du[i] > 1)) return puts("0"), 0;
  work();
  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 2176
# 拡張ユークリッド互除法
# ax + by = gcd(a,b)の最小整数解を返す
def egcd(a, b):
    if a == 0:
        return (b, 0, 1)
    else:
        g, y, x = egcd(b % a, a)
        return (g, x - (b // a) * y, y)


# mを法とするaの乗法的逆元
def modinv(a, m):
    g, x, y = egcd(a, m)
    if g != 1:
        raise Exception('modular inverse does not exist')
    else:
        return x % m


def comb(n, max_k, mod):
    """
    (n,k) := n個からk個選ぶ組み合わせ
    k = 0~max_Kまでを計算して返す
    """
    res = [1]*(max_k+1)
    t = 1
    for i in range(max_k+1):
        res[i] *= t
        t *= n-i
        t %= mod

    n = reduce(lambda x,y: (x*y)%mod, range(1,max_k+1), 1)
    n = modinv(n, mod)

    for i in reversed(range(max_k+1)):
        res[i] *= n
        res[i] %= mod
        n *= i
        n %= mod
    return res

from functools import reduce
def solve(N,K):
    MOD = 10**9+7


    r1 = comb(N-K+1, min(K, N-K+1), MOD)
    r2 = comb(K-1, K-1, MOD)

    r1 += [0]*max(0,K+1-len(r1))
    return [(a*b)%MOD for a,b in zip(r1[1:],r2)]


if __name__ == '__main__':
    N,K = map(int,input().split())
    print(*solve(N,K), sep='\n')

Measured memory_bytes: 41968
while True:
    a,op,b = map(str,input().split())
    a=int(a)
    b=int(b)
    if op=="?":
        break
    
    elif op=="+":
        print(a+b)
        
    elif op=="-":
        print(a-b)
        
    elif op=="*":    
        print(a*b)
        
    elif op=="/":    
        print(a//b)


Measured memory_bytes: 5596
# 繰り返し二乗法
def pow(base,exponent)
  raise ArgumentError if exponent < 0
  # 指数が0の時は結果は1です
  return 1 if exponent==0
  # 結果が出る変数を用意
  result = 1
  # 指数が1なら終了
  while exponent != 1 do
    # 指数が奇数の時、その時の底はここでresultに掛けてしまい、指数を一つ減らす
    if exponent.odd? then
      result *= base
      exponent -= 1
    end
    # 指数を2で割る
    exponent /= 2
    # 底の2乗を新たな底とする
    base *= base
    base = base % MOD
    # 繰り返す
  end
  result *= base
  # 結果を返す
  return result % MOD
end
MOD = 998244353
n,m,k = gets.chomp.split.map(&:to_i)

# K組までのm*(m-1)を計算
# 1~n-1を計算しておいて、最後からk+1個を使えば良い
memo = [m%MOD]
1.upto(n-1) do |i|
  memo[i] = memo[i-1] * (m-1) % MOD
end

ans = memo.last

def set_fac(n)
  1.upto(n-1) do |i|
    @fac[i] = @fac[i-1] * i % MOD
  end

  # 最も大きいのは最後のやつ
  # mod pにおけるaの逆元はa^(p-2)つまり mod pの状況で bで割ってから pのあまりというのはb^(p-2)をかけるのに等しい
  @rfac[-1] = pow(@fac[-1], MOD - 2)
  (n-2).downto(0) do |i|
    @rfac[i] = @rfac[i+1] * (i+1) % MOD
  end
end

@fac = Array.new(n, 1)
@rfac = Array.new(n)

set_fac(n)

1.upto(k) do |i|
  ans += memo[n-i-1] * @fac[n-1] * @rfac[i] * @rfac[n-i-1] % MOD
end

p ans % MOD




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

int main() 
{ 
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll k, a, b;
    cin >> k >> a >> b;
    if((b/k)*k >= a) {
        cout << "OK\n";
    } else {
        cout << "NG\n";
    }
    return 0; 
}

Measured memory_bytes: 3652
#include<cstdio>
int main(){
	int a,b,c;
	scanf("%d %d %d",&a,&b,&c);
	if(a != b && b != c && a != c) printf("3\n");
	else if(a == b && b == c) printf("1\n");
	else printf("2\n");
	return 0;
}


Measured memory_bytes: 128
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <map>
#include <set>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000
#define sz(x) ((int)(x).size())
#define fi first
#define sec second
#define SORT(x) sort((x).begin(),(x).end())
#define all(x) (x).begin(),(x).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
int cal[101];
int n,a,b,c;
bool C(double x)
{
	vector<double> vec;
	for(int i=0;i<n;i++)
	{
		double k=cal[i]-x*b;
		vec.pb(k);
	}
	sort(vec.begin(),vec.end(),greater<double>());
	double sum=0.0;
	for(int i=0;i<n;i++)
	{
		sum+=vec[i];
		if(sum>=x*a-c)return true;
	}
	return false;
}
int main()
{
	cin >> n;
	cin >> a >> b;
	cin >> c;
	for(int i=0;i<n;i++)
	{
		cin >> cal[i];
	}
	double lb=0.0,rb=INF;
	for(int i=0;i<100;i++)
	{
		double mid=(lb+rb)/2;
		if(C(mid))lb=mid;
		else rb=mid;
	}
	cout << (int)lb << endl;
	return 0;
}

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

//using namespace boost::multiprecision;
using namespace std;
typedef long long ll;
//typedef unsigned long long ll;
const double EPS = 1e-9;
#define rep(i, n) for (int i = 0; i < (n); ++i)
//#define rep(i, n) for (ll i = 0; i < (n); ++i)
//#define sz(x) ll(x.size())
typedef pair<int, int> P;
//typedef pair<ll, int> P;
//typedef pair<ll, ll> P;
//const double INF = 1e10;
const ll INF = LONG_LONG_MAX / 100;
//const ll INF = (1ll << 31) - 1;
//const ll INF = 1e15;
const ll MINF = LONG_LONG_MIN;
//const int INF = INT_MAX / 10;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
//typedef pair<int, int> P;
//typedef pair<double, double> P;
#define ret() return 0;

bool contain(set<char> &s, char a) { return s.find(a) != s.end(); }

//ifstream myfile("C:\\Users\\riku\\Downloads\\0_00.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);
const int mod = 1000000007;
//const ll mod = 1e10;
typedef priority_queue<long long, vector<long long>, greater<long long> > PQ_ASK;

vector<pair<ll, int >> factorize(ll n) {
    vector<pair<ll, int >> res;

    for (ll i = 2; i * i <= n; i++) {
        if (n % i != 0) {
            continue;
        }
        res.emplace_back(i, 0);
        while (n % i == 0) {
            n /= i;
            res.back().second++;
        }
    }

    if (n != 1) res.emplace_back(n, 1);
    return res;

}

ll pow2(ll a, ll b) {
    ll res = a;
    for (ll i = 1; i < b; i++) {
        res *= a;
    }
    return res;
}

int main() {
    ll n, p;
    cin >> n >> p;

    auto f = factorize(p);

    ll ans = 1;
    for (auto e : f) {
        if (e.second < n) continue;
        ans *= pow2(e.first, (e.second / n));
    }

    cout << ans << endl;

}

Measured memory_bytes: 256
s = input()
q = int(input())

u = []
for i in range(q):
    u.append(list(map(str,input().split())))

from collections import deque
l = deque([])
r = deque([])

x = 1
for i in range(q):
    if int(u[i][0]) == 1:
        x = x*(-1)
    else:
        if int(u[i][1])*x == 1 or int(u[i][1])*x == -2:
            l.append(u[i][2])
        else:
            r.append(u[i][2])
if x == 1:
    print(''.join(l)[::-1]+s[::x]+''.join(r))
else:
    print(''.join(r)[::-1]+s[::x]+''.join(l))

Measured memory_bytes: 114648
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const double EPS=1e-6;
const double PI=acos(-1.0);
int ABS(int a){return max(a,-a);}
long long ABS(long long a){return max(a,-a);}
int p[11];
int g[210][210];
int main(){
	int a,b,c;
	scanf("%d%d%d",&a,&b,&c);
	for(int i=0;i<c;i++){
		scanf("%d",p+i);p[i]--;
	}
	std::sort(p,p+c);
	for(int i=0;i<a;i++)for(int j=0;j<a;j++)g[i][j]=mod;
	for(int i=0;i<a;i++)g[i][i]=0;
	for(int i=0;i<b;i++){
		int s,t,u;scanf("%d%d%d",&s,&t,&u);s--;t--;
		g[s][t]=g[t][s]=u;
	}
	for(int k=0;k<a;k++)for(int i=0;i<a;i++)for(int j=0;j<a;j++)
		g[i][j]=min(g[i][j],g[i][k]+g[k][j]);
	int ret=mod;
	do{
		int tmp=0;
		for(int i=0;i<c-1;i++){
			tmp+=g[p[i]][p[i+1]];
		}
		ret=min(ret,tmp);
	}while(next_permutation(p,p+c));
	printf("%d\n",ret);
}

Measured memory_bytes: 384
using System;
using System.Linq;
using System.Collections.Generic;
using System.IO;

namespace atcorder2
{
    class Program
    {
        public static long Read()
        {
            return long.Parse(Console.ReadLine());
        }

        public static long[] Reads()
        {

            return Console.ReadLine().Split().Select(long.Parse).ToArray();
        }

       




        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);


            var ab = Reads();
            var a = ab[0];
            var b = ab[1];
            var s = Console.ReadLine();
            var ans = "Yes";
            for (int i = 0; i < s.Length; i++)
            {
                bool f = false;
                if (i != a &&'0' <= s[i] && s[i] <= '9') f = true;
                else if (i==a&&s[i] == '-') f = true;

                if (!f) ans = "No";
            }
            Console.WriteLine(ans);


            Console.Out.Flush();
        }
    }
}




Measured memory_bytes: 11348
#include <iostream>
#include <iomanip>
#include <fstream>
#include <string>
#include <vector>
#include <array>
#include <map>
#include <set>
#include <stack>
#include <cstdint>
#include <cmath>
#include <algorithm>
#include <utility>
#include <numeric>
#include <functional>
#include <cassert>

using namespace std;
typedef int64_t ll;
typedef uint64_t ull;

constexpr ll INF = 1000000000;/* 1e+9a */

void solve(istream &cin) {
    ll N;
    if (!(cin >> N)) { return; }
    ll K;
    cin >> K;
    vector<ll> h;
    for (int i = 0; i < N; ++i) {
        ll tmp;
        cin >> tmp;
        h.push_back(tmp);
    }
    vector<ll> cost(N, INF);
    cost[0] = 0;
    for (ll i = 1; i < N; ++i) {
        for (ll j = max(ll{0}, i-K); j < i; ++j) {
            cost[i] = min(cost[i], cost[j] + abs(h[j] - h[i]));
        }
    }
    cout << cost.back() << endl;

}

int main(int argc, char *argv[]) {
    string FileName("EDPC"), Modifier("MEPH_");
    string ExecutionName = Modifier + FileName;
    string sub(argv[0]);
    // /home/USER/.../MEPH_X -> MEPH_X
    if (sub.size() > ExecutionName.size())
        sub = sub.substr(sub.size() - ExecutionName.size(), ExecutionName.size());

    cout << setprecision(16) << scientific;
    if (sub != ExecutionName) {
        cin.tie(0);
        ios::sync_with_stdio(false);
        while (cin) { solve(cin); }
    } else {
        cerr << sub << " test" << endl;
        string inFile = FileName + ".txt";
        auto fs = fstream(inFile, fstream::in);
        while (fs) { solve(fs); }
    }
}


Measured memory_bytes: 1908
#include <bits/stdc++.h>
using namespace std;
int n, napw;
int w[100], v[100];
int memo[101][10001];
int solve(int i, int j){

    if(memo[i][j] != -1) return memo[i][j];
    int ret;
    if(i == n) ret = 0;
    else if(j < w[i]) ret = solve(i + 1, j);
    else {
        int retp[3] = { solve(i + 1, j),
                        solve(i + 1, j - w[i]) + v[i],
                        solve(i, j - w[i]) + v[i] };
        sort(retp, retp + 3);
        ret = retp[2];
    }
    return memo[i][j] = ret;
}
int main(){

    cin >> n >> napw;
    for(int i = 0; i < n; ++i)
        cin >> v[i] >> w[i];
    memset(memo, -1, sizeof(memo));
    cout << solve(0, napw) << endl;
}

Measured memory_bytes: 5752
N = int(input())
S = [input(), input()]

if S[0][0] == S[1][0]:
    ans = 3
    pre = 1
    skp = 0
else:
    ans = 6
    pre = 0
    skp = 1

mod = 10**9+7
for i in range(1,N):
    if skp:
        skp = 0
        continue
    if S[0][i] == S[1][i]:
        if pre:
            ans = ans*2%mod
        else:
            pre = 1
    else:
        skp = 1
        if pre:
            ans = ans*2%mod
            pre = 0
        else:
            ans = ans*3%mod
print(ans)


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

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

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

  //a=97
  vector<int> all(26);
  int ans=0;

  rep(i,n){
    int j = s.at(i)-97;
    all.at(j)++;
  }
  
  rep(i,n){
    vector<int> x(26);
    rep(j,i){
      int l=s.at(j)-97;
      x.at(l)++;
    }
    
    int count=0;
    rep(k,26){
      if(x.at(k)&&(all.at(k)-x.at(k))) count++;
    }

    ans = max(ans, count);
  }

  cout << ans;
}

Measured memory_bytes: 3640
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace A
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] vs = RArInt();
            Console.WriteLine(vs[0] - vs[1] + 1);
        }
        static string RSt() { return Console.ReadLine(); }
        static int RInt() { return int.Parse(Console.ReadLine().Trim()); }
        static long RLong() { return long.Parse(Console.ReadLine().Trim()); }
        static double RDouble() { return double.Parse(Console.ReadLine()); }
        static string[] RArSt(char sep = ' ') { return Console.ReadLine().Trim().Split(sep); }
        static int[] RArInt(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Trim().Split(sep), e => int.Parse(e)); }
        static long[] RArLong(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Trim().Split(sep), e => long.Parse(e)); }
        static double[] RArDouble(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Trim().Split(sep), e => double.Parse(e)); }
        static string WAr<T>(IEnumerable<T> array, string sep = " ") { return string.Join(sep, array.Select(x => x.ToString()).ToArray()); }
    }
}


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



int main(){
  int a[100]={0},num,kaisu=0,j,i,t;

  cin >>num;
  for(i=0; i<num;i++){
    cin>>a[i];
}


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

  for(j=num-1;j>i;j--){

    if(a[j]<a[j-1]){
      t=a[j];a[j]=a[j-1];a[j-1]=t;
      kaisu++;
    }

  }
 }


 for(int i=0;i<num;i++){
   cout<<a[i];
   if(i<num-1) cout<<" ";
 }
 cout << endl;
 cout<<kaisu<<endl;

 return 0;
}

Measured memory_bytes: 3096
#include <bits/stdc++.h>
using namespace std;
 
using ll = int64_t;
constexpr ll mod = ll(1e9 + 7);
 
template <typename A, typename B>
string to_string(pair<A, B> p);
 
template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p);
 
template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p);
 
string to_string(const string& s) {
  return '"' + s + '"';
}
 
string to_string(const char* s) {
  return to_string((string) s);
}
 
string to_string(bool b) {
  return (b ? "true" : "false");
}
 
string to_string(vector<bool> v) {
  bool first = true;
  string res = "{";
  for (int i = 0; i < static_cast<int>(v.size()); i++) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(v[i]);
  }
  res += "}";
  return res;
}
 
template <size_t N>
string to_string(bitset<N> v) {
  string res = "";
  for (size_t i = 0; i < N; i++) {
    res += static_cast<char>('0' + v[i]);
  }
  return res;
}
 
template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto &x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}
 
template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
 
template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ")";
}
 
template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ", " + to_string(get<3>(p)) + ")";
}
 
void debug_out() { cerr << endl; }
 
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
 
#ifdef COMPETITIVE_PROGRAMMING_LOCAL
#define dbg(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define dbg(...) if(0){}
#endif

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

  ll n,m,cnt=0;
  cin >> n >> m;
  vector<ll> A(n);
  for (auto& x : A) cin >> x;
  ll sum = accumulate(A.begin(), A.end(), 0LL);
  double limit = double(sum)/(4*m);
  // dbg(limit);
  // dbg(m);
  for (int i = 0; i < n; ++i) {
    if (A[i] < limit) {
      
    } else {
//      dbg(A[i]);
      ++cnt;
    }
  }
//  dbg(cnt);
  if (cnt >= m) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }

}


Measured memory_bytes: 3640
X, K, D = map(int, input().split())
if(K < abs(X)//D):
  print(abs(X)-D*K)
else:
  L = abs(X)//D
  K2 = K-L
  if(K2 % 2 == 0):
    print(abs(X)-D*L)
  else:
    print(abs(abs(X)-D*(L+1)))

Measured memory_bytes: 61672
#include<bits/stdc++.h>
using namespace std;
#define fast ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ll long long int
int main(){
ll n,a,b,q,r;
cin>>n>>a>>b;
if(a==0)
cout<<0;
else
{
q=n/(a+b);
r=n%(a+b);
if(r>=a)
cout<<q*a+a;
else
cout<<q*a+r;

}
return 0;

}

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

typedef long long int ll;
typedef pair<ll, ll> p_ll;
typedef vector<pair<ll, ll>> vec_p; //vector<pair<ll, ll>> pairs(n) ,pairs.at(i) = make_pair(i*i, i)

#define ture ture
#define flase false
#define falg flag

#define REP(i, x) for (ll i = 0; i < (ll)(x); i++)
#define REPS(i, x) for (ll i = 1; i <= (ll)(x); i++)
#define RREP(i, x) for (ll i = ((ll)(x)-1); i >= 0; i--)
#define RREPS(i, x) for (ll i = ((ll)(x)); i > 0; i--)
#define all(x) (x).begin(), (x).end()

const ll MOD = pow(10, 9) + 7;
const ll LLINF = pow(2, 61) - 1;//llの最大9*10^18
const int INF = pow(2, 30) - 1;

ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }

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

    ll N;
    string S;
    cin >> N;

    if(N%1000==0){
        cout << 0 << endl;
    }
    else{
        cout << (N / 1000 + 1)*1000-N << endl;
    }
}


Measured memory_bytes: 3648
// Sky's the limit :)
#include <bits/stdc++.h>
using namespace std;
#define int long long

signed main() {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    
    int T = 1; 
    // cin >> T; 
    while (T--) {
        int n;
        cin >> n;

        int x = 26, y = 1;
        while(n > x) {
            n -= x;
            x *= 26;
            y++;
        }
        n--;

        string s;
        while(y--) {
            int x = n % 26;
            s += (char)(x + 'a');
            n /= 26; 
        }
        reverse(s.begin(), s.end());
        
        cout << s << '\n';     
    }
    
    return 0;
}



Measured memory_bytes: 3664
#include <iostream>

int main()
{
    char S[3];
    std::cin >> S;

    int ans = 700;
    for (int i = 0; i < 3; i++) {
        if (S[i] == 'o') ans += 100;
    }

    std::cout << ans << std::endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define REP(i, n) for(int i = 1; i < n; i++)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(), v.rend()
#define P pair<int, int>
typedef long long ll;
const ll mod = 1e9+7;

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

//繰り返し自乗法による累乗計算
//a**n
ll pow(ll a, ll n){
  if(n == 0) return 1;
  if(n%2 == 0){
    ll res = pow(a, n/2);
    return res * res;
  }
  return a * pow(a, n-1);
}
//繰り返し自乗法によるmod累乗計算
//a**n (mod)
ll modpow(ll a, ll n){
  if(n == 0) return 1;
  if(n%2 == 0){
    ll res = modpow(a, n/2);
    return res * res % mod;
  }
  return a * modpow(a, n-1) % mod;
}
//組み合わせ
//nCa
ll com(ll n, ll a){
  ll x = 1, y = 1;
  rep(i,a){
    x *= n-i;
    y *= i+1;
  }
  ll res = x / y;
  return res;
}
//組み合わせ(mod)
//nCa (mod)
ll modcom(ll n, ll a){
  ll x = 1, y = 1;
  rep(i, a){
    x = x * (n-i) % mod;
    y = y * (i+1) % mod;
  }
  ll ans = x * modpow(y, mod-2) % mod;
  return ans;
}
//gcd 最大公約数
ll gcd(ll x, ll y){
  if(x % y == 0) return y;
  return gcd(y, x%y);
}
//lcm 最小公倍数
ll lcm(ll x, ll y){
  return x * y / gcd(x, y);
}
//ngcd n個の最大公約数
ll ngcd(vector<ll> a){
  ll res;
  res = a[0];
  for(ll i = 1; i < a.size() && res != 1; i++) {
    res = gcd(a[i], res);
  }
  return res;
}
//nlcm n個の最小公倍数
ll nlcm(vector<ll> a) {
  ll res;
  res = a[0];
  for (ll i = 1; i < a.size(); i++) {
    res = lcm(res, a[i]);
  }
  return res;
}
// 素数判定
bool isprime(ll x){
  ll i;
  if(x < 2) return false;
  else if(x == 2) return true;
  if(x % 2 == 0) return false;
  for(i = 3; i*i <= x; i += 2){
    if(x % i == 0) return false;
  }
  return true;
}
// 桁和
ll digsum(ll x){
  ll res = 0;
  while(x > 0){
    res += x % 10;
    x /= 10;
  }
  return res;
}


int main(){
  int a, b;
  char op;
  cin >> a >> op >> b;
  if(op == '+') cout << a+b << endl;
  else cout << a-b << endl;
} 






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

int main()
{
  int N, T, A, minN=0;
  double min=1000;
  cin >> N >> T >> A;
  vector<int> H(N);
  rep(i, N){
    cin >> H.at(i);
    if (abs((T-H.at(i)*0.006)-A)<min){
      min=abs((T-H.at(i)*0.006)-A);
      minN=i+1;
    }
  }
  cout << minN << endl;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int R,G,B,N;
    cin >> R >> G >> B >> N;
    int r=0;
    for(int i=0; i<=N/R; i++){
        for(int j=0; j<=N/G; j++){
            if(N-i*R-j*G>=0 && (N-i*R-j*G)%B==0)r++;
        }
    }
    cout << r <<"\n";
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define ll long long
using ull = unsigned long long;
using namespace std;
#define dump(x)                             \
    if (dbg) {                              \
        cerr << #x << " = " << (x) << endl; \
    }
#define overload4(_1, _2, _3, _4, name, ...) name
#define FOR1(n) for (ll i = 0; i < (n); ++i)
#define FOR2(i, n) for (ll i = 0; i < (n); ++i)
#define FOR3(i, a, b) for (ll i = (a); i < (b); ++i)
#define FOR4(i, a, b, c) for (ll i = (a); i < (b); i += (c))
#define FOR(...) overload4(__VA_ARGS__, FOR4, FOR3, FOR2, FOR1)(__VA_ARGS__)
#define FORR(i, a, b) for (int i = (a); i <= (b); ++i)
#define bit(n, k) ((n >> k) & 1) /*nのk bit目*/
namespace mydef {
const int INF = 1ll << 60;
const int MOD = 1e9 + 7;
template <class T>
bool chmin(T& a, const T& b) {
    if (a > b) {
        a = b;
        return 1;
    } else
        return 0;
}
template <class T>
bool chmax(T& a, const T& b) {
    if (a < b) {
        a = b;
        return 1;
    } else
        return 0;
}
void Yes(bool flag = true) {
    if (flag)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}
void No(bool flag = true) {
    Yes(!flag);
}
void YES(bool flag = true) {
    if (flag)
        cout << "YES" << endl;
    else
        cout << "NO" << endl;
}
void NO(bool flag = true) {
    YES(!flag);
}
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T& val) {
    std::fill((T*)array, (T*)(array + N), val);
}
bool dbg = false;
}  // namespace mydef
using namespace mydef;
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(), (v).end()
#define SZ(x) ((int)(x).size())
#define vi vector<int>
#define vvi vector<vector<int>>
#define vp vector<pair<int, int>>
#define vvp vector<vector<pair<int, int>>>
#define pi pair<int, int>
//#define P pair<int, int>
//#define V vector<int>
//#define S set<int>
#define asn ans

int N, M, H[101010];
vi G[101010];

void solve() {
    int ans = 0;
    FOR (N) {
        int flag = 1;
        for (auto& e : G[i]) {
            if (H[e] >= H[i])
                flag = 0;
        }
        ans += flag;
    }
    cout << ans << endl;
}

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

    cin >> N >> M;
    FOR (N)
        cin >> H[i];
    FOR (M) {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        G[a].pb(b);
        G[b].pb(a);
    }

    solve();
    return 0;
}


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

int main(void)
{
    int m,n,o=0,i,j,k;
    int sum=0,range=0;
    double ans=0.0,half;
    //long long int m,n,o,i,j,k=0;
    //vector <int> v;
    //float f,g,h;
    char c,d;
    string s,a,b;
    cin>>n;
    if(n%2==1) cout<<"No";
    else
    {
        cin>>s;
        a.assign(s,0,n/2);
        b.assign(s,n/2,n/2);
        if(a.compare(b)==0) cout<<"Yes";
        else cout<<"No";
    }
    return 0;
}




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

int		main(void)
{
	string a, b, c;

	cin >> a >> b >> c;
	if (a[a.size() - 1] == b[0] && b[b.size() - 1] == c[0])
		cout << "YES";
	else
		cout << "NO";
	cout << endl;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int s[201019];
int f[200121];
vector<int > v[201091];
void dfs(int x)
{
    f[x] = 1;
    int Z = 1;
    for (int i=0; i < v[x].size(); i++)
    {
        if(f[v[x][i]]) continue;
        dfs(v[x][i]);
        if(s[v[x][i]]==0 && Z) Z=0;
        else if(s[v[x][i]]==0) s[v[x][i]]++;
        s[x] += s[v[x][i]];
    }
}
main()
{
    int n;
    cin >> n;
    for (int i=0; i < n - 1; i++)
    {
        int a,b;
        cin >>a >> b;
        v[a].push_back(b);
        v[b].push_back(a);
    }
    int x = -1;
    for (int i =0; i < n; i++)
    {
        if (v[i].size() >=3) x = i;
    }
    if( x == -1)
    {
        cout << 1 << endl;
        return 0;
    }
    dfs(x);
    cout << s[x] << endl;
}


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

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

using namespace std;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;

const int INF = 1 << 30;
const long long INFL = 1LL << 62;
const int MOD = 1000000007;
const int MAX = 100000;
const int N = 300;

int a[N][N],x[N*N+1],y[N*N+1],l[MAX],r[MAX];
long long c[N*N+1];

int main() {
	int h,w,d;cin>>h>>w>>d;
	rep(i,h) rep(j,w) {
		int ta;cin>>ta;
		a[i][j]=ta;y[ta]=i;x[ta]=j;
	}
	rep1(i,h*w){
		if(i<=d) c[i]=0;
		else c[i]=c[i-d]+abs(x[i]-x[i-d])+abs(y[i]-y[i-d]);
	}
	int q;cin>>q;
	rep(i,q) cin>>l[i]>>r[i];
	rep(i,q) cout<<c[r[i]]-c[l[i]]<<endl;
}


Measured memory_bytes: 3836
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <iterator>
#include <assert.h>
#pragma warning(disable:4996) 
 
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223300000000000000
#define INF 2140000000
const long long MOD = 1000000007;
//const long long MOD = 998244353;

using namespace std;


const int max_comb=2100000;
vector<ll> fac(max_comb+1); //n! (mod M)
vector<ll> ifac(max_comb+1); //k!^(-1) (mod M)

ll mpow(ll x, ll n){ //x^n(mod M)
    ll ans = 1;
    while(n != 0){
        if(n&1) ans = ans*x % MOD;
        x = x*x % MOD;
        n = n >> 1;
    }
    return ans;
}

ll minv(ll x){
    return mpow( x, MOD-2 );
}

ll comb(int a, int b){     // C(a,b) = a! * b!^(-1) * (a-b)^(-1)
    if(a == 0 && b == 0)return 1;
    if(a < b || a < 0)return 0;
    ll tmp = ifac[a-b]* ifac[b] % MOD;
    return tmp * fac[a] % MOD;
}

ll perm(int a, int b){     // P(a,b) = a! * (a-b)!^(-1)
    if(b == 0)return 1;
    if(a < b || a < 0)return 0;
    ll tmp = ifac[a-b] % MOD;
    return tmp * fac[a] % MOD;
}

void pre_comb()
{
    fac[0] = 1;
    ifac[0] = 1;
    for(int i = 0; i<max_comb; i++){
        fac[i+1] = fac[i]*(i+1) % MOD; // n!(mod M)
        ifac[i+1] = ifac[i]*minv(i+1) % MOD; // k!^(-1) (mod M)
    }
    return;
}

void solve()
{
    int r0, c0, r1, c1;
    scanf("%d%d%d%d", &r0, &c0, &r1, &c1);
    pre_comb();

    ll ans0 = comb(r1 + c1 + 2, r1 + 1);
    ll ans1 = comb(r1 + c0 + 1, c0);
    ll ans2 = comb(r0 + c1 + 1, r0);
    ll ans3 = comb(r0 + c0, r0);
    ll ans = (ans0 - ans1 - ans2 + ans3 + MOD + MOD) % MOD;
    printf("%lld\n", ans);

    return;
}

int main(int argc, char* argv[])
{
#if 1
    solve();
#else
    int T; scanf("%d", &T);
    while(T--) {
        solve();
    }
#endif
    return 0;
}


Measured memory_bytes: 33024
import java.util.Scanner;
class Main{
public static void main(String[] args){
Scanner scan=new Scanner(System.in);
int a=1;

while(true){
String B=scan.next();
int b=Integer.parseInt(B);
if(b==0)
	break;
System.out.println("Case "+a+": "+b);
a=a+1;
}
}
}

Measured memory_bytes: 40632
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.function.BiFunction;

public class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(br.readLine());
		Obj[] arr = new Obj[n + 1];
		for (int i = 0; i < n; i++) {
			String[] sa = br.readLine().split(" ");
			Obj o = new Obj();
			o.x = Integer.parseInt(sa[0]);
			o.d = Integer.parseInt(sa[1]);
			arr[i] = o;
		}
		br.close();

		Obj o = new Obj();
		o.x = Integer.MAX_VALUE;
		o.d = 0;
		arr[n] = o;
		Arrays.sort(arr, (o1, o2) -> Long.compare(o2.x, o1.x));

		int mod = 998244353;
		SegTree<Integer> st = new SegTree<>(n + 1, Integer.MAX_VALUE, (v1, v2) -> Math.min(v1, v2));

		long[] dp0 = new long[n + 1];
		long[] dp1 = new long[n + 1];
		dp0[0] = 1;
		for (int i = 1; i <= n; i++) {
			dp0[i] = dp0[i - 1] + dp1[i - 1];
			dp0[i] %= mod;
			int idx = binarySearch(arr, arr[i].x + arr[i].d);
			int idx2 = st.query(idx, i);
			if (idx2 == Integer.MAX_VALUE) {
				idx2 = i;
			}
			dp1[i] = dp0[idx2 - 1] + dp1[idx2 - 1];
			dp1[i] %= mod;
			st.update(i, idx2);
		}
		System.out.println((dp0[n] + dp1[n]) % mod);
	}

	static class Obj {
		long x, d;
	}

	static int binarySearch(Obj[] arr, long x) {
		int ok = arr.length;
		int ng = -1;
		while (Math.abs(ok - ng) > 1) {
			int mid = (ok + ng) / 2;
			if (arr[mid].x < x) {
				ok = mid;
			} else {
				ng = mid;
			}
		}
		return ok;
	}

	static class SegTree<T> {
		// 親へのアクセス：(n - 1) / 2
		// 子へのアクセス：n * 2 + 1、n * 2 + 2
		int n = 2; // 要素（葉）の数
		int n2; // 全ノード数
		T NA;
		List<T> list;
		BiFunction<T, T, T> func;

		/**
		 * 初期化 O(N)
		 * @param num 要素（葉）の数
		 * @param na 単位元
		 * @param func 区間に対する操作が可能な関数（戻り値は新規オブジェクト）
		 */
		public SegTree(int num, T na, BiFunction<T, T, T> func) {
			while (n < num) n <<= 1;
			n2 = n * 2 - 1;
			NA = na;
			list = new ArrayList<T>(n2);
			for (int i = 0; i < n2; i++) list.add(NA);
			this.func = func;
		}

		/**
		 * 更新 O(logN)
		 * @param i インデックス（0～n-1）
		 * @param x 更新値
		 */
		void update(int i, T x) {
			i += n - 1; // arr上でのインデックス
			list.set(i, x);
			while (i > 0) {
				i = (i - 1) / 2;
				list.set(i, func.apply(list.get(i * 2 + 1), list.get(i * 2 + 2)));
			}
		}

		/**
		 * 取得 O(logN)
		 * インデックスl以上r未満の区間の値
		 */
		T query(int l, int r) {
			return query(l, r, 0, 0, n);
		}

		/**
		 * 取得 O(logN)
		 * インデックスl以上r未満の区間の値、beg, endにはノードkに対応する区間
		 * query(l, r, 0, 0, n);
		 */
		private T query(int l, int r, int k, int beg, int end) {
			if (end <= l || r <= beg) return NA; // 交差しない
			if (l <= beg && end <= r) return list.get(k); // 完全に含む
			T v1 = query(l, r, k * 2 + 1, beg, (beg + end) / 2);
			T v2 = query(l, r, k * 2 + 2, (beg + end) / 2, end);
			return func.apply(v1, v2);
		}
	}
}


Measured memory_bytes: 107360
#!/usr/bin/env python3

import sys

DEBUG = False


def read(t):
    return t(sys.stdin.readline().rstrip())


def read_list(t, sep=" "):
    return [t(s) for s in sys.stdin.readline().rstrip().split(sep)]


def dprint(*args, **kwargs):
    if DEBUG:
        print(*args, **kwargs)
    return


MOD = int(1e9 + 7)


def mod_inv(a, b, mod):
    return (a * pow(b, mod - 2, mod)) % mod


def solve(as_):
    all_sum = 0
    for a in as_:
        all_sum = (all_sum + a) % MOD
    ans_x2 = 0
    for i in range(0, len(as_)):
        ans_x2 = (
            ans_x2 + ((MOD + (all_sum - as_[i]) % MOD) % MOD) * as_[i] % MOD) % MOD

    return mod_inv(ans_x2, 2, MOD)


def main():
    _n = read(int)
    as_ = read_list(int)
    print(solve(as_))


if __name__ == "__main__":
    main()


Measured memory_bytes: 93064
import java.io.*;
import java.util.ArrayList;
import java.util.Collections;

class Main {
    public static void main(String[] args) throws IOException {
	    	BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
	    	
	    	ArrayList<Integer> arr = new ArrayList<Integer>();
	    	for(int i=0;i<10;i++) {
	    		String str = reader.readLine();
	    		arr.add(Integer.parseInt(str));
	    	}
	    	Collections.sort(arr);
	    	Collections.reverse(arr);
	    	for(int i=0;i<3;i++) {
	    		System.out.println(""+arr.get(i));
	    	}
    }
}

Measured memory_bytes: 17068
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC133
{
    class Program
    {
        static void Main(string[] args)
        {
            string Str = Console.ReadLine().Trim();
            string[] StrArr = Str.Split(new[] { ' ' }, System.StringSplitOptions.RemoveEmptyEntries);
            ulong[] IntArr = StrArr.Select(ulong.Parse).ToArray();
            ulong l = IntArr[0];
            //uint r = IntArr[1];
            ulong r = IntArr[1] < l+2019 ? IntArr[1] : l +2019;
            var list = new List<ulong>();
            ulong val;
            for (ulong i = l; i <= r; i++)
            {
                for (ulong j = i+1; j <= r; j++)
                {
                    //Console.WriteLine("i,j:" + i + " " + j);
                    val = (i * j) % 2019;
                    if (val==0)
                    {
                        Console.WriteLine(0);
                        return;
                    }
                    list.Add(val);
                }

            }

            ulong minimum = list.Min();
            Console.WriteLine(minimum);
            Console.Read();

        }

    }
}


Measured memory_bytes: 13396
#include <iostream>
#include <numeric>
#include <vector>
	//#include<math.h>
	//#include <algorithm>
	//#include <functional>
	//#include <numeric>
	//#include<cmath>
#include <stdio.h> 
	//#include <cstdint>
	//#include <string>
	//#include <cstdlib>
	//#define pi 3.14159265359
using namespace std;


	int main() {

		uint64_t a;
		cin >> a;
		int n = 1;
		int num = 0;
		vector<uint64_t> b(a);
		for (int i = 0; i < a; i++) {
			cin >> b[i];
			if (b[i] == n) {
				n += 1;
			}
			else {
				num += 1;
			}
		}

		if (num == a) {
			cout << -1;
		}
		else {
			cout << num;
		}


		return 0;

	}

Measured memory_bytes: 1792
x, y, a, b, c = map(int, input().split())
p = list(map(int, input().split()))
q = list(map(int, input().split()))
r = list(map(int, input().split()))

p.sort(reverse=True)
q.sort(reverse=True)
r.sort(reverse=True)

p.append(0)
q.append(0)
r.append(0)

i, j, k = 0, 0, 0
ans = 0

# print(p)
# print(q)
# print(r)

for l in range(x + y):
    cand = [p[i], q[j], r[k]]
    # print(max(cand))
    index = cand.index(max(cand))
    if index == 0:
        ans += p[i]
        i += 1
        if i == x:
            i = a
    elif index == 1:
        ans += q[j]
        j += 1
        if j == y:
            j = b
    else:
        ans += r[k]
        k += 1
    
print(ans)

Measured memory_bytes: 23328
def resolve():
  N, A, B= map(int, input().split(" "))
  S = list(input())

  sum_of_successful_candidate = 0
  sum_of_successful_b = 0

  for i, s in enumerate(S):
    if sum_of_successful_candidate >= A + B:
      for _ in range(N-i):
        print("No")
      return True

    if s == "a":
      sum_of_successful_candidate += 1
      print("Yes")
    elif s == "b" and sum_of_successful_b < B:
      sum_of_successful_candidate += 1
      sum_of_successful_b += 1
      print("Yes")
    else:
      print("No")

  return True


if __name__ == "__main__":
  resolve()

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

#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define MIN(a) *min_element(all(a))
#define MAX(a) *max_element(all(a))
#define SUM(a) accumulate(all(a), 0LL)
#define REP(i, n) for(int (i)=0; (i)<(n); (i)++)
#define RREP(i, n) for(int (i)=(n)-1; (i)>=0; (i)--)
#define FOR(i, m, n) for(int (i)=(m); (i)<(n); i++)
#define FORR(i, m, n) for(int (i)=(n)-1; (i)>=(m); i--)
#define debug(x) cerr << #x << " = " << x << endl
//#define int long long

typedef long long ll;
//ll const MOD = 998244353;
ll const MOD = 1e9+7;
int const inf = 1e9;
ll const INF = 1e18;

inline void ios_(){cin.tie(0); ios::sync_with_stdio(false);}
template<typename T> int size(const T& a){return (int)a.size();}
template<typename T> T Div(T a, T b){return (a + b - 1) / b;}
template<typename T> bool chmin(T& a, const T& b){if(a > b){a = b; return true;} return false;}
template<typename T> bool chmax(T& a, const T& b){if(a < b){a = b; return true;} return false;}



signed main(){
    int n;
    cin >> n;
    vector<int> v(n);
    for(auto& i :v) cin >> i;

    sort(all(v));

    double ans = v[0];
    REP(i, n-1){
        ans = (double) (ans + v[i+1]) / 2;
    }

    cout << fixed << setprecision(10) << ans << endl;
    return 0;
}


Measured memory_bytes: 256
import sys
import math
from collections import defaultdict

sys.setrecursionlimit(10**7)
def input():
    return sys.stdin.readline()[:-1]

mod = 998244353

def I(): return int(input())
def II(): return map(int, input().split())
def III(): return list(map(int, input().split()))
def Line(N,num):
    if N<=0:
        return [[]]*num
    elif num==1:
        return [I() for _ in range(N)]
    else:
        read_all = [tuple(II()) for _ in range(N)]
        return map(list, zip(*read_all))

#################

#時間計測

def use_divisors(n):
    l_divisors, r_divisors = [], []
    for i in range(1, int(n**0.5)+1):
        if n%i == 0:
            if (n//i)%2:
                l_divisors.append(i)
            if i != n//i:
                if (n//(n//i))%2:
                    r_divisors.append(n//i)
    return l_divisors + r_divisors[::-1]
 
N = I()
X = str(input())
Xr = ''.join('1' if c=='0' else '0' for c in X)

divisors = use_divisors(2*N)
C = dict.fromkeys(divisors,0)

for d in divisors:
    T = X[:d//2]
    Tr = Xr[:d//2]
    Tc = T+Tr
    count = int(T,2)
    if Tc*(N//d)+Tc[:N-d*(N//d)] <= X:
        count += 1
    C[d] = count
    for d1 in divisors:
        if d%d1==0 and d!=d1:
            C[d] -= C[d1]

ans = 0
for d in divisors:
    ans += d*C[d]
    ans %= mod

print(ans)

Measured memory_bytes: 86556
#include<iostream>
#include<string>
#include<cmath>
#include<queue>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<random>
#include<functional>
#include<algorithm>
#include<cstdio>
#include<bitset>
#include<unordered_map>
using namespace std;
//---------------------------------------------------
//ライブラリゾーン！！！！
typedef long long ll;
typedef long double ld;
#define str string
#define rep(i,j) for(ll i=0;i<(long long)(j);i++)
#define all(a) (a).begin(),(a).end()
const ll Mod = 1000000007;
const ll gosenchou = 5000000000000000;
short gh[2][4] = { { 0,0,-1,1 },{ -1,1,0,0 } };
struct P {
	ll pos, cost;
};
bool operator<(P a, P b) { return a.cost < b.cost; }
bool operator>(P a, P b) { return a.cost > b.cost; }
struct B {//隣接リスト表現
	ll to, cost;
};
struct E {//辺の情報を入れる変数
	ll from, to, cost;
};
bool operator<(E a, E b) {
	return a.cost < b.cost;
}
struct H {
	ll x, y;
};
bool operator<(H a, H b) {
	if (a.x != b.x) return a.x < b.x;
	return a.y < b.y;
}
bool operator>(H a, H b) {
	if (a.x != b.x) return a.x > b.x;
	return a.y > b.y;
}
bool operator==(H a, H b) {
	return a.x == b.x&&a.y == b.y;
}
bool operator!=(H a, H b) {
	return a.x != b.x || a.y != b.y;
}
ll gcm(ll i, ll j) {//最大公約数
	if (i > j) swap(i, j);
	if (i == 0) return j;
	return gcm(j%i, i);
}
ld rad(H a, H b) {
	return sqrt(pow(a.x - b.x, 2.0) + pow(a.y - b.y, 2.0));
}//rad＝座標上の2点間の距離
ll ari(ll a, ll b, ll c) {
	return (a + b)*c / 2;
}//等差数列の和
ll fact(ll x, ll k, ll p) {//最大値、個数、あまり
	ll sum = 1;
	for (int i = 0; i < k; i++) {
		sum *= (x--);
		sum %= p;
	}
	return sum;
}//階乗(正）
ll mod_pow(ll x, ll n, ll p) {
	ll res = 1;
	while (n > 0) {
		if (n & 1) res = res * x%p;
		x = x * x%p;
		n >>= 1;
	}
	return res;
}//x^n%p
short ctos(char a) {
	return (int)(a - '0');
}
#define int long long
const long long Inf = 4523372036854775807;
const int inf = 15000000000;
//----------------------------------------------------
//++++++++++++++++++++++++++++++++++++++++++++++++++++

signed main() {
	int n;
	int ans = Inf, T;
	cin >> n >> T;
	for (int i = 0; i < n; i++) {
		int c, t;
		cin >> c >> t;
		if (t <= T) {
			ans = min(ans, c);
		}
	}
	if (ans < Inf)
		cout << ans << endl;
	else cout << "TLE\n";
}

Measured memory_bytes: 256