akhauriyash/Code-Regression huggingface dataset:
(* Vicfred
 * https://atcoder.jp/contests/abc144/tasks/abc144_b
 * implementation
 * *)

let main =
    Scanf.scanf "%d" @@ fun n ->
      print_endline @@ if
        Array.fold_left (Array.fold_left ( || )) false @@
        Array.init 9 @@ fun i ->
          Array.init 9 @@ fun j -> n = (i+1)*(j+1)
    then "Yes"
    else "No"



Measured memory_bytes: 3748
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> mp;
ll inf =  1e9;
int f(int a,int b){
    for(int i=0;i<32;i++){
	if( ( (a>>i)&1 ) != ( (b>>i)&1 ) ) return i; 
    }
    return -1;
}

int main(){
    ll n;
    cin>>n;
    for(int i=0;i<n-1;i++){
	cout<<1+f(i,i+1);
	for(int j=i+2;j<n;j++){
	    cout<<' '<<1+f(i,j);
	}
	cout<<endl;
    }
    return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
int main() {
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  if (a+b > c+d) cout << "Left" << endl;
  else if (a+b < c+d) cout << "Right" << endl;
  else cout << "Balanced" << endl;
  return 0;
}

Measured memory_bytes: 256
//#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define trav(x,a) for (const auto& x: a)
#define sz(x) (int)(x).size()
#define mem(a,v) memset((a), (v), sizeof (a))
#define enl printf("\n")
#define case(t) printf("Case #%d: ", (t))
#define ni(n) scanf("%d", &(n))
#define nl(n) scanf("%lld", &(n))
#define nai(a, n) for (int _i = 0; _i < (n); _i++) ni(a[_i])
#define nal(a, n) for (int _i = 0; _i < (n); _i++) nl(a[_i])
#define pri(n) printf("%d\n", (n))
#define prl(n) printf("%lld\n", (n))
#define pii pair<int, int>
#define pll pair<long long, long long>
#define vii vector<pii>
#define vll vector<pll>
#define vi vector<int>
#define vl vector<long long>
#define pb push_back
#define mp make_pair
#define st first
#define nd second
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef cc_hash_table<int,int,hash<int>> ht;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> oset;
const double pi = acos(-1);
const int mod = 998244353;
const int inf = 1e9 + 7;
const int N = 6e3 + 5;
const double eps = 1e-9;
int a[N], dp[N][N];
int add(int x, int y) { return x+y < mod ? x+y : x+y-mod; }
int mul(int x, int y) { return x * 1ll * y % mod; }

int main() {
  int n, s; scanf("%d %d", &n, &s);
  for (int i = 1; i <= n; i++) {
    scanf("%d", a+i);
  }
  int ans = 0;
  for (int i = 1; i <= n; i++) {
    for (int j = 0; j <= s; j++)
      dp[i][j] = dp[i-1][j];
    for (int j = a[i]; j <= s; j++)
      dp[i][j] = add(dp[i][j], dp[i-1][j-a[i]]);
    dp[i][a[i]] = add(dp[i][a[i]], i);
    ans = add(ans, dp[i][s]);
  }
  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 71296
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <random>
#include <chrono>
#include <queue>
#include <math.h>
#include <string>
#include <sstream>
#include <stack>
#define inf 1e9+7
#define pb push_back
#define make make_pair
#define kaku(a) cout << a << endl;
 
using namespace std;
 
#define ll long long
#define rep(i,n) for(ll i=0;i<n;i++)
#define PI 3.14159265359
long long gcd(long long a,long long b){ return b==0?a:gcd(b,a%b);}
long long lcm(long long a,long long b){ return a/gcd(a,b)*b;}

typedef pair<ll,ll> Pair;
typedef set<ll> Set;

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



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
const ll MAX = 1001001;
const ll MOD = 1000000007;
int main()
{
    ll n, a, b;
    cin >> n >> a >> b;
    vector<ll> p(n);
    ll x = 0;
    ll y = 0;
    ll z = 0;
    rep(i, n)
    {
        cin >> p[i];
        if (p[i] <= a)
        {
            x++;
        }
        else if (p[i] > b)
        {
            z++;
        }
        else
        {
            y++;
        }
    }

    cout << min({x, y, z}) << endl;
}

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

int main(){
	int a, b;
	cin >> a >> b;
	int ans = a + b;
	ans = max(ans, a - b);
	ans = max(ans, a * b);
	
	
	
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <limits>
#include <cmath>

using namespace std;

int main() {
    size_t n;
    cin >> n;
    std::vector<size_t> p(n, 0);
    for (size_t i = 0; i < n; ++i)
        cin >> p[i];
    size_t x = p.front();
    size_t c = 0;
    for (size_t i = 0; i < n; ++i) {
        auto a = p[i];
        if (a < x)
            x = a;
        if (a <= x)
            ++c;
    }
    cout << c << endl;
    return 0;
}




Measured memory_bytes: 1792
def main():
    from bisect import bisect_left
    from bisect import bisect_right

    N = int(input())

    An = map(int, input().split())
    Bn = map(int, input().split())
    Cn = map(int, input().split())

    A = sorted(An)
    C = sorted(Cn)

    print(sum(bisect_left(A, Bi) * (N - bisect_right(C, Bi)) for Bi in Bn))
    return


main()


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

int q;
int main()
{
    cin >> q;
    while (q--)
    {
        long long a, b, c, d;
        cin >> a >> b >> c >> d;
        (a < b || d < b || a % b > c || c < b - __gcd(b, d)) ? cout << "No\n" : cout << "Yes\n";
    }
    return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
import sys, random, itertools, math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float, input().split()))
def LI_(): return list(map(lambda x: int(x)-1, input().split()))
def II(): return int(input())
def IF(): return float(input())
def S(): return input().rstrip()
def LS(): return S().split()
def IR(n): return [II() for _ in range(n)]
def IR_(n): return [II() - 1 for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = 1e10

# 解説AC
# ナニコレこんなの解けるの？ｗ
# 数え上げはだいたいDP
# ICPCのも水パフォに見えてきた
# このようなDPの問題をもっと解きたい

#solve
def solve():
    n = II()
    m = 2 * 10 ** 5
    c = [m] + IR_(n) + [m]
    dp0 = [0] * (n + 1)
    dp1 = [0] * (m + 1)
    dp1[c[0]] = 1
    for i in range(n + 1):
        if c[i] != c[i + 1]:
            dp0[i] += dp1[c[i]]
            dp0[i] %= mod
            dp1[c[i + 1]] += dp0[i]
            dp1[c[i + 1]] %= mod
        else:
            dp0[i] = dp0[i - 1]
    print(dp0[-1])
    return


#main
if __name__ == '__main__':
    solve()


Measured memory_bytes: 62684
#include<bits/stdc++.h>
using namespace std;
class ParseError{};
class ZeroDivisionError{};

vector<bool> Var(string S,map<string,pair<int,int>>& m,map<string,bool>& isVar){
    vector<bool> res(256,false);
    if(isVar[S]){
        for(int i = m[S].first;i <= m[S].second;i++){
            res[i] = true;
        }
    }else{
        res[stoi(S)] = true;
    }
    return res;
}

vector<bool> operate(vector<bool>& arg1,vector<bool>& arg2,string op){
    vector<bool> res(256,false);
    if(op == "+"){
         for(int i = 0;i < 256;i++){
            for(int j = 0;j < 256;j++){
                if(arg1[i] && arg2[j]){
                    res[(i+j)%256] = true;
                }
            }
        }
        return res;
    }
    if(op == "-"){
        for(int i = 0;i < 256;i++){
            for(int j = 0;j < 256;j++){
                if(arg1[i] && arg2[j]){
                    res[(i-j+256)%256] = true;
                }
            }
        }
        return res;
    }
    if(op == "*"){
        for(int i = 0;i < 256;i++){
            for(int j = 0;j < 256;j++){
                if(arg1[i] && arg2[j]){
                    res[(i*j)%256] = true;
                }
            }
        }
        return res;
    }
    if(op == "/"){
        for(int i = 0;i < 256;i++){
            for(int j = 0;j < 256;j++){
                if(arg1[i] && arg2[j]){
                    if(j == 0){
                        throw ZeroDivisionError();
                    }
                    res[(i/j)%256] = true;
                }
            }
        }
        return res;
    }
    throw ParseError();
}

int main(){
    int M;
    cin >> M;
    map<string,pair<int,int>> m;
    map<string,bool> isVar;
    for(int i = 0;i < M;i++){
        string name;
        int lb,ub;
        cin >> name >> lb >> ub;
        m[name] = make_pair(lb,ub);
        isVar[name] = true;
    }
    int n;
    cin >> n;
    stack<vector<bool>> s;
    for(int i = 0;i < n;i++){
        string tmp;
        cin >> tmp;
        if(tmp != "+" && tmp != "-" && tmp != "*" && tmp != "/"){
            s.push(Var(tmp,m,isVar));
        }else{
            auto b = s.top();
            s.pop();
            auto a = s.top();
            s.pop();
            try{
                auto res = operate(a,b,tmp);
                s.push(res);
            }catch(ZeroDivisionError err){
                cout << "error" << endl;
                return 0;
            }catch(ParseError err){
                cerr << "unexpected operator:" << tmp << endl;
                return 1;
            }
        }
    }
    cout << "correct" << endl;
}


Measured memory_bytes: 3316
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
#define LL long long
#define MOD 1000000007

LL mod_pow(LL x,LL n,LL mod){
    if (n == 0) {
        return 1;
    }
    LL res = mod_pow(x * x % mod, n / 2, mod);
    if (n & 1) {
        res = res*x %mod;
    }
    return res;
}

LL mul(LL l, LL r){
    LL ret = 1;
    for (int i = 0; i < l - r + 1; i++) {
        ret *=i + r;
        ret %= MOD;
    }
    return ret;
}

LL comb(LL n,LL x){
    LL ret1 = mul(n,n-x+1);
    LL ret2 = mul(x,1);
    LL ret3 = mod_pow(ret2,MOD-2,MOD);
    return ret1 * ret3  % MOD;
}


int main(void){
    int n,a,b;
    scanf("%d %d %d", &n,&a,&b);
    LL ans =  mod_pow(2,n,MOD) - 1 - comb(n,a) - comb(n,b);   
    ans = (ans%MOD + MOD) % MOD;
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 128
from collections import deque

h, w = map(int, input().split())
S = []
for _ in range(h):
    s = str(input())
    S.append(s)

deque = deque()
deque.append([0,0])
Visited=[[-1 for _ in range(w)] for _ in range(h)]
Visited[0][0] = 0

while deque:
    now = deque.popleft()
    x_now = now[0]
    y_now = now[1]

    Cands = []
    For_cands = [-1,0,1]
    for i in For_cands:
        for j in For_cands:
            if i == j or i == j*-1:
                continue
            if x_now + i < w and x_now +i >=0 and y_now +j < h and y_now + j >=0:
                if S[y_now+j][x_now+i] == '.':
                    Cands.append([x_now+i, y_now+j])
    for cands in Cands:
        if Visited[cands[1]][cands[0]] != -1:
            continue
        deque.append(cands)
        Visited[cands[1]][cands[0]] = Visited[y_now][x_now] + 1

goal_dist = Visited[h-1][w-1]

white = 0
for i in range(h):
    white += S[i].count('.')

ans = white - goal_dist -1
if goal_dist == -1:
    ans = -1
print(ans)

Measured memory_bytes: 3316
#include<bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
int a[N];
int b[N];
int c[N];

int main(){
	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	int x, y, as, bs, cs; cin >> x >> y >> as >> bs >> cs;
	for(int i = 0; i < as; i++)cin >> a[i];
	for(int i = 0; i < bs; i++)cin >> b[i];
	for(int i = 0; i < cs; i++)cin >> c[i];
	sort(a, a + as);
	reverse(a, a + as);
	sort(b, b + bs);
	reverse(b, b + bs);
	vector<int> v;
	for(int i = 0; i < x; i++){
		v.push_back(a[i]);
	}
	for(int i = 0; i < y; i++){
		v.push_back(b[i]);
	}
	sort(c, c + cs);
	reverse(c, c + cs);
	for(int i = 0; i < min(x+y, cs); i++){
		v.push_back(c[i]);
	}
	sort(v.begin(), v.end());
	reverse(v.begin(), v.end());
	long long ans = 0;
	for(int i = 0; i < x+y; i++){
		ans += v[i];
	}
	cout << ans << endl;
}

Measured memory_bytes: 3572
#include <bits/stdc++.h>
#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 long long ll;

int main(){
    string S, T;
    cin >> S >> T;

    int lenS = S.length();
    int lenT = T.length();
    int ans = 10001;
    int temp = 0;


    for(int i = 0; i <= lenS - lenT; i++){
        temp = 0;
        for(int j = 0; j < lenT; j++){
            if (S[i + j] != T[j]){
                temp++;
            }
        }
        if (temp < ans){
            ans = temp;
        }
    }

    if (ans == 10001){ans = 0;}

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3632
#include <iostream>
#include <vector>
#include <string>
#include <unordered_map>
#include <unordered_set>

int main()
{
	std::unordered_set<int> N;

	for (int i = 0; i < 4; ++i) {
		int x;
		std::cin >> x;
		N.insert(x);
	}

	if (N.size() != 4) {
		std::cout << "NO\n";
		return 0;
	}

	if (N.find(1) != N.end() &&
	    N.find(9) != N.end() &&
	    N.find(7) != N.end() &&
	    N.find(4) != N.end()) {
		std::cout << "YES\n";
	} else {
		std::cout << "NO\n";
	}
}


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

int main(){
  string s,t;
  cin >> s >>t;
  string ans = "Yes";
  for(int i=0;i<s.length();i++){
    if(s[i]!=t[i]){
      ans = "No";
      break;
    }
  }
  cout << ans;
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
void sortx (int a[], int n);
void arrayPrintf(int a[] , int n);

const int MAX_N = 200000;
int a[MAX_N];
int b[MAX_N];

int main(void)
{
    int n;
    cin >> n;

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

    /*
    for( int i = 0; i < n; i++){
        b[i] = a[i];
        //arrayPrintf(b, i+1);
        sortx(b, i+1);
        //arrayPrintf(b, i+1);
    }
    */

    if( n % 2 == 0){
        for( int i = 0; i < n/2; i++){
            b[i] = a[n-1-i*2]; 
        }
        for( int i = n/2; i < n; i++){
            b[i] = a[i*2-n]; 
        }
    }

    if( n % 2 == 1){
        for( int i = 0; i < n/2 + 1; i++){
            b[i] = a[n-1-i*2]; 
        }
        for( int i = n/2 + 1; i < n; i++){
            b[i] = a[i*2-n]; 
        }
    }
    arrayPrintf(b, n);
    return 0;
}

void sortx (int a[], int n)
{
    for( int i = 0; i < n/2; i++){
        a[i] += a[n - 1 - i];
        a[n - 1 - i] = a[i] - a[n - 1 - i];
        a[i] -= a[n - 1 - i];
    }
}

void arrayPrintf(int a[] , int n)
{
    for( int i = 0; i < n; i++){
        printf("%d ", a[i]);
    }    
}

Measured memory_bytes: 3712
#include <string>
#include <vector>
#include <iostream>
#include <sstream>
    
typedef struct LettersInfo {
    std::string letters;
    unsigned int count;
} lettersInfo_s;
    
int main()
{
    std::string paramStr;
    std::getline(std::cin, paramStr);
    
    std::vector<lettersInfo_s*> lettersList;
    
    std::string letters;
    std::istringstream stream(paramStr);
    
    unsigned int maxLength = 0;
    std::string maxLengthStr;
    
    while (std::getline(stream, letters, ' ')) {
        unsigned int len = letters.size();
        if ( len != 0) {
            if ( maxLength < len ) {
                maxLengthStr = letters;
                maxLength = len;
            }
   
            unsigned int loopCount;
            for (loopCount = 0; loopCount < lettersList.size(); loopCount++) {
                if ( lettersList[loopCount]->letters == letters ) {
                    ++lettersList[loopCount]->count;
                    break;
                }
            }
   
            if (loopCount == lettersList.size()) {
                lettersInfo_s* plettersInfo = new lettersInfo_s();
                plettersInfo->letters = letters;
                ++plettersInfo->count;
                lettersList.push_back(plettersInfo);
            }
        }
    }
    
    unsigned int maxCount = 0;
    std::string maxCountStr;
    while( lettersList.size() > 0 ) {
   
        lettersInfo_s* plettersInfo = lettersList.back();
   
        unsigned int count = plettersInfo->count;
        if (maxCount < count) {
            maxCountStr = plettersInfo->letters;
            maxCount = count;
        }
        delete plettersInfo;
        lettersList.pop_back();
    }
    
    std::cout << maxCountStr << " " << maxLengthStr << std::endl;
    
    return 0;
}

Measured memory_bytes: 3084
#include <stdio.h>
#include <stdlib.h>
#include <memory.h>
typedef struct team{
    int id;
    int u;
    int a;
    int p;
}team;
team t[300];

int c(const void *v1,const void *v2){
    team *x=(team *)v1;
    team *y=(team *)v2;
    return x->id-y->id;
}
int main(void){
    int num,i,w,sum,line[300];
    team temp,temp1;
    for(;sum=0,memset(t,0,sizeof(t)),memset(line,0,sizeof(line)),scanf("%d",&num),num;){
        for(i=0;i<num;i++)
            scanf("%d %d %d %d",&t[i].id,&t[i].u,&t[i].a,&t[i].p);
        qsort(t,num,sizeof(team),c);
        for(i=1;i<num;i++){
            temp=t[i];
            w=i;
            while(w>0){
                if(t[w-1].a < temp.a){
                    t[w]=t[w-1];
                    w--;
                }
                else if(t[w-1].a == temp.a && t[w-1].p > temp.p){
                    t[w]=t[w-1];
                    w--;
                }
                else
                    break;
            }
            t[w]=temp;
        }
        for(i=0;i<num;i++){
            if(sum < 10 && line[t[i].u] < 3){
                printf("%d\n",t[i].id);
                line[t[i].u]++;
                sum++;
            }
            else if(sum < 20 && line[t[i].u] < 2){
                printf("%d\n",t[i].id);
                line[t[i].u]++;
                sum++;
            }
            else if(sum < 26 && line[t[i].u] == 0){
                printf("%d\n",t[i].id);
                line[t[i].u]++;
                sum++;
            }
        }
    }
    return 0;
}

Measured memory_bytes: 652
#include <iostream>

struct RECT_DOUBLE {
  double l;
  double r;
  double t;
  double b;
};

std::istream& operator >> (std::istream& is, RECT_DOUBLE& r)
{
  is >> r.l >> r.b >> r.r >> r.t;
  return is;
}

bool IsOverlap(const RECT_DOUBLE& rectA, const RECT_DOUBLE& rectB)
{
  bool lapHori = !(rectA.l > rectB.r || rectB.l > rectA.r);
  bool lapVert = !(rectA.b > rectB.t || rectB.b > rectA.t);

  return lapHori && lapVert;
}

int main(void)
{
  RECT_DOUBLE rectA, rectB;

  while (std::cin >> rectA >> rectB) {
    std::cout << (IsOverlap(rectA, rectB) ? "YES" : "NO") << std::endl;
  }

  return 0;
}



Measured memory_bytes: 3164
#include<bits/stdc++.h>
using namespace std;
void solve() {
	int n ;
	cin >> n ;
	vector<int> dp(3 , 0) ;
	for(int i = 0 ; i < n ; i++){
		vector<int> arr(3 , 0) ;
		for(int j = 0 ; j < 3 ; j++)
			cin >> arr[j] ;
		vector<int> temp(3 , 0) ;
		for (int j = 0 ; j < 3 ; j++) {
			for (int k = 0 ; k < 3 ; k++)
				if (j != k) {
					temp[k] = max(temp[k] , dp[j] + arr[k]) ;
				}
		}
		dp = temp ;
	}
	cout << *max_element(dp.begin() , dp.end()) ;
}

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


Measured memory_bytes: 3536
#include <iostream>
#define int long long
using namespace std;

signed main() {
  int N;
  cin >> N;
  
  if (N % 2 == 1) {
    cout << 0 << endl;
    return 0;
  }
  
  int ans = 0;
  int cnt = 5;
  while (cnt < N) {
    ans += N / (cnt * 2);
    cnt *= 5;
  }
  
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

using namespace std;
using ll = long long;
using vpii = vector<pair<int, int>>;
using vpll = vector<pair<ll, ll>>;

int		main(void)
{
	int N;
	cin >> N;
	vector<int> X(N);
	for (int i = 0; i < N; i++)
		cin >> X[i];
	int ans = 1e9;
	for (int P = 0; P < 100; P++)
	{
		int sum = 0;
		for (int i = 0; i < N; i++)
			sum += pow((X[i] - P), 2);
		ans = min(ans, sum);
	}
	cout << ans << endl;
}



Measured memory_bytes: 256
from itertools import accumulate


def pascal(arr, n):
    for i in range(n+1):
        for j in range(i+1):
            if j == 0 or j == i:
                arr[i][j] = 1
            else:
                arr[i][j] = arr[i-1][j-1]+arr[i-1][j]
    return arr


N, A, B = map(int, input().split())
v = sorted([int(x) for x in input().split()], reverse=True)
ans_c = 0
ans_v = [x for x in accumulate(v)]
tmp = v[0]
lft = 0
rgt = N-1
comb = [[0 for _ in range(N+1)] for _ in range(N+1)]
pascal(comb, N)
for i in range(N):
    if v[i] != tmp:
        if i >= A:
            rgt = i-1
            break
        else:
            tmp = v[i]
            lft = i
if lft == 0 and rgt != 0:
    for i in range(A, min(rgt+1, B)+1):
        ans_c += comb[rgt+1][i]
else:
    ans_c = comb[rgt-lft+1][A-lft]
print(ans_v[A-1]/A)
print(ans_c)


Measured memory_bytes: 3064
import java.util.*;

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

        int sum = 0;
        sum = a + b;
        if(sum > a + c){
            sum = a + c;
        }
        if(sum > b + c){
            sum = b + c;
        }
        System.out.println(sum);
    }
}

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

int main(void){
    int a,b;
    cin >> a >> b;
    if(a<b){
        rep(i,b){
            cout << a;
        }
    }else{
        rep(i,a){
            cout << b;
        }
    }
    cout << endl;
}

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

namespace ABC073A
{
    class Program
    {
        static void Main(string[] args)
        {
            string n;
            n = Console.ReadLine();
            if (n[0] == '9' || n[1] == '9')
                Console.WriteLine("Yes");
            else
                Console.WriteLine("No");
            Console.ReadKey();
        }
    }
}


Measured memory_bytes: 13140
#include "bits/stdc++.h"
using namespace std;

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

    int count = 0;
    for(int i = A; i <=B;i++){
        int a = i % 10;
        int b = i/10 % 10;
        int c = i/100 % 10;
        int d = i/1000 % 10;
        int e = i/10000 % 10;

        if(a==e && b==d){
            count ++ ;
        }
    }

    cout << count << endl;
}

Measured memory_bytes: 256
n,k=map(int,input().split())
ans=0
mod=10**9+7
for i in range(k,n+2):
  mx=int(n*(n+1)/2-(n-i+1)*(n-i)/2)
  mn=int(i*(i-1)/2)
  #print(mx,mn)
  ans+=mx-mn+1
  ans=ans%mod
  #print("ans",ans)
print(ans)

Measured memory_bytes: 9196
n = int(input())
ans = 0
cou = 10 ** 10
for i in range(n):
  a = int(input())
  ans += a
  if a % 10 != 0:
    cou = min(cou,a)
if ans % 10 == 0:
  if cou % 10 == 0:
    print(0)
  else:
    print(ans-cou)
else:
  print(ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define ms(x, n) memset(x,n,sizeof(x));
#define rep(i, n) for(int i = 0; i < (int)n; ++i)
#define rep1(i, n) for(int i = 1; i <= (int)n; ++i)
#define pb push_back
#define PI acos(-1.0)
#define LONG_LONG_MAX 9223372036854775807
#define LONG_LONG_MIN -9223372036854775808
typedef long long int ll;
typedef unsigned long long int ull;
using namespace std;

const int maxn = 100;
int n;

int main()
{
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    cin >> n;
    vector<int> a(n);
    rep(i, n) {
        cin >> a[i];
    }
    sort(a.begin(), a.end());
    double temp = (a[0] + a[1]) / 2.0;
    for (int i = 2; i < n; ++i) {
        temp = (a[i] + temp) / 2.0;
    }
    cout << temp << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
using namespace std;
int main(){
  int n;cin>>n;
  int a[n];
  for(int i = 0; n > i; i++)cin >> a[i];
  long long b[n];
  b[0] = a[0];
  for(int i = 1; n > i; i++){
    b[i] = b[i-1]+a[i];
  }
  //b[n-1]
  long long mn = 1000000000;
  for(int i = 1; n-1 > i; i++){
    long long tmp = max(b[n-1]-(b[i]*2),(b[i]*2)-b[n-1]);
    mn = min(tmp,mn);
  }
  if(n == 2){
    mn = abs(a[1]-a[0]);
  }
  cout << mn << endl;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define ll long long
#define li long
#define pb push_back
#define mem(arr,x) memset(arr,x,sizeof(arr))

long double a[3000];
long double dp[1500][3000];

long double probOfHeads(int countOfT,int n)
{
  if(n==0)
  return 1.0;
  if(dp[countOfT][n]!=-1.0)
  return dp[countOfT][n];
  long double ans=0.0;
  ans+= probOfHeads(countOfT,n-1)*a[n-1];
  if(countOfT>0)
  ans+= probOfHeads(countOfT-1,n-1)*(1.0-a[n-1]);
  return dp[countOfT][n]=ans;
}
int main() 
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n,i,j;
    cin>>n;
    for(i=0;i<n;i++)
    cin>>a[i];
    int countOfT;
    if(n%2==0)
    countOfT=n/2-1;
    else
    countOfT=n/2;
    for(i=0;i<=countOfT;i++)
      for(j=0;j<=n;j++)
        dp[i][j]=-1.0;

    cout<<fixed<<std::setprecision(10);
    cout<<probOfHeads(countOfT,n);
    return 0;
}

Measured memory_bytes: 74276
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
int a[3];
cin >> a[0];
cin >> a[1];
cin >> a[2];
sort(a,a + 3);
if (a[0] == 5 && a[1] == 5 && a[2] == 7){
  cout << "YES\n";
}
else{
  cout << "NO\n ";
}
return 0;   
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define is(a, b) a == b
#define len(v) ll(v.size())

const ll mod=1e9+7;

//vector書き出し
template <class T>
void cout_vec(const vector<T> &vec1){
  rep(i,len(vec1)){
    cout<<vec1[i]<<' ';
  }
  cout<<'\n';
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a,b,c;
    cin>>a>>b>>c;
    if(a==b && b==c){
      cout<<"Yes"<<endl;
    }else{
      cout<<"No"<<endl;
    }
}

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

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

ll conbinationMemo[100][100];

void cmemoInit(){
    rep(i, 100){
        rep(j, 100){
            conbinationMemo[i][j] = -1;
        }
    }
}
 
ll nCr(ll n, ll r){
    if(conbinationMemo[n][r] != -1) return conbinationMemo[n][r];
    if(r == 0 || r == n){
        return 1;
    } else if(r == 1){
        return n;
    }
    return conbinationMemo[n][r] = (nCr(n - 1, r) + nCr(n - 1, r - 1));
}
 
ll nPr(ll n, ll r){
    r = n - r;
    ll ret = 1;
    for (ll i = n; i >= r + 1; i--) ret *= i;
    return ret;
}
//-----------------------ここから-----------
int main(void){
    ll n;
    cin >> n;
    vector<ll> ng(1001000, false);
    map<ll,ll> mp;
    rep(i, n){
        ll a;
        cin >> a;
        mp[a]++;
    }
    ll ans = 0;
    for(auto &i : mp){
        if(ng[i.first]) continue;
        ng[i.first] = true;
        for(int j = i.first; j < 1001000; j += i.first){
            ng[j] = true;
        }
        if(i.second == 1) ans++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 23496
#include <iostream>

using namespace std;

int main(){
	string str, cmd, arg2;
	int n, arg0, arg1;

	cin >> str >> n;

	for(int i = 0; i < n; i++){
		cin >> cmd >> arg0 >> arg1;
		if(cmd == "print"){
			cout << str.substr(arg0, arg1-arg0+1) << endl;
			continue;
		}
		if(cmd == "reverse"){
			string tmp1 = str.substr(0, arg0);
			string rev  = str.substr(arg0, arg1-arg0+1);
			string tmp2 = str.substr(arg1+1, str.size()-arg1);
			char tmp;
			int revSize = rev.size();
			for(int i = 0; i < revSize/2; i++){
				tmp = rev[i];
				rev[i] = rev[revSize-i-1];
				rev[revSize-i-1] = tmp;
			}
			str = tmp1 + rev + tmp2;
		}
		if(cmd == "replace"){
			cin >> arg2;
			string tmp1 = str.substr(0, arg0);
			string tmp2 = str.substr(arg1+1, str.size()-arg1);
			str = tmp1 + arg2 + tmp2;
		}
	}
}

Measured memory_bytes: 3212
#include <iostream>
#include <algorithm>
#include <vector>
#define ll long long int
using namespace std;

int main(){
  vector<int>a(5);
  int b[5]={0,1,1,2,2};
  for(int i=0;i<3;++i){
    int n,m;
    cin>>n>>m;
    ++a[n];++a[m];
  }
  sort(a.begin(),a.end());
  bool ok=true;
  for(int i=0;i<5;++i){
    if(a[i]!=b[i])ok=false;  
  }
  if(ok)cout<<"YES"<<endl;
  else cout<<"NO"<<endl;
}


Measured memory_bytes: 888
#include <iostream>
#include <vector>
#include <set>
using namespace std;
int gcd(int a, int b) {
  if(b == 0) return a;
  gcd(b, a % b);
}
int main() {
  int n;
  cin >> n;
  vector<long long> monster(n);
  for(int i = 0; i < n; i++) {
    unsigned long long a;
    cin >> a;
    monster[i] = a; 
  }
  int g = gcd(monster[0], monster[1]);
  for(int i = 0; i < monster.size() - 1; i++) {
    g = gcd(g, monster[i]);
  }
  
  cout << g << endl;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define ll long long
#define all(x) (x).begin(),(x).end()
#define rep(i, n) for(ll i = 0; i < n; i++)
const ll INF = 1LL << 60;

int main(){
    int M, N, A, B, C;
    string s1, s2;
    cin >> s1;
    if(s1[0] == 'R'&&s1[1] == 'R' && s1[2] == 'R')cout << 3 << endl;
    else if(s1[0] == 'R' && s1[1] == 'R')cout << 2 << endl;
    else if(s1[1] == 'R' && s1[2] == 'R')cout << 2 << endl;
    else if(s1[0] =='S'&&s1[1] == 'S' && s1[2] == 'S')cout << 0 << endl;
    else cout << 1 << endl;

}


Measured memory_bytes: 3620
def read():
    return int(input())


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


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


N = read()
A = readlist()

sum_1 = sum([A[i] % 2 for i in range(N)])
if sum_1 % 2:
    print("NO")
else:
    print("YES")



Measured memory_bytes: 14104
def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getList():
    return list(map(int, input().split()))
def getArray(intn):
    return [int(input()) for i in range(intn)]
def input():
    return sys.stdin.readline().rstrip()
def rand_N(ran1, ran2):
    return random.randint(ran1, ran2)
def rand_List(ran1, ran2, rantime):
    return [random.randint(ran1, ran2) for i in range(rantime)]
def rand_ints_nodup(ran1, ran2, rantime):
  ns = []
  while len(ns) < rantime:
    n = random.randint(ran1, ran2)
    if not n in ns:
      ns.append(n)
  return sorted(ns)

def rand_query(ran1, ran2, rantime):
  r_query = []
  while len(r_query) < rantime:
    n_q = rand_ints_nodup(ran1, ran2, 2)
    if not n_q in r_query:
      r_query.append(n_q)
  return sorted(r_query)

from collections import defaultdict, deque, Counter
from sys import exit
from decimal import *
import heapq
import math
from fractions import gcd
import random
import string
import copy
from itertools import combinations, permutations, product
from operator import mul
from functools import reduce
from bisect import bisect_left, bisect_right

import sys
sys.setrecursionlimit(1000000000)
mod = 10 ** 9 + 7


#############
# Main Code #
#############

N, K = getNM()
P = [i - 1 for i in getList()]
C = getList()

ignore = [-1] * N
ans = -float('inf')
for i in range(N):
    if ignore[i] >= 0:
        continue
    ### ループ生成 ###
    ignore[i] = 1
    opt_l = [i]
    to = P[i]
    while ignore[to] == -1:
        opt_l.append(to)
        ignore[to] = 1
        to = P[to]
    ###
    ### 作成したループで得点リスト生成 ###
    n = len(opt_l)
    point = [0] * n
    for i in range(n):
        point[i] = C[opt_l[i]]
    ###
    ### 得点リスト内の連続する区間の総和のうちの最大値を累積和を使って求める ###
    sum_roop = sum(point)
    # ループの累積和作成
    imos = [0]
    point += point
    for i in range(len(point)):
        imos.append(imos[i] + point[i])
    #
    ran = min(n, K)
    for i in range(n):
        # 区間の大きさran以下についての総和を求める
        for j in range(1, ran + 1):
            if sum_roop >= 0:
                opt = imos[i + j] - imos[i] + ((K - j) // n) * sum_roop
            else:
                opt = imos[i + j] - imos[i]
            ans = max(ans, opt)
    ###
print(ans)

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

int cnt = 0;

void insertionSort(int arr[], int n, int g){
	int tmp;
	int j;
	for(int i = g; i < n; i++){
		tmp = arr[i];
		j = i - g;
		while(j >= 0 && arr[j] > tmp){
			arr[j + g] = arr[j];
			j = j - g;
			cnt++;
		}
		arr[j + g] = tmp;
	}
}

int G[] = {1, 4, 13, 40, 121, 364, 1093, 3280, 9841, 29524, 88753, 265270, 797161}; 

void shellSort(int arr[], int n, int gn){
	int cnt = 0;
	for(int i = gn - 1; i >= 0; i--){
		insertionSort(arr, n, G[i]);
	}
}

void printG(int n){
	for(int i = n - 1; i >= 0; i--){
		cout << G[i];
		if(i != 0){
			cout << ' ';
		}
	}
	cout << endl;
}

void printArr(int arr[], int n){
	for(int i = 0; i < n; i++){
		cout << arr[i] << endl;
	}
}

int main(){
	int n;
	int arr[1000000];
	cin >> n;
	for(int i = 0; i < n; i++){
		cin >> arr[i];
	}
	for(int i = 0; i < n; i++){
		if(n <= G[i]){
			if(i == 0){ i++; }
			shellSort(arr, n, i);
			cout << i << endl;;
			printG(i);
			break;
		}
	}

	cout << cnt << endl;
	printArr(arr, n);

	return 0;
}


Measured memory_bytes: 7044
#include <bits/stdc++.h>
using namespace std;
#define fst first
#define snd second
typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
#define pb push_back
#define for_tests(t, tt) int t; scanf("%d", &t); for(int tt = 1; tt <= t; tt++)
#ifndef ONLINE_JUDGE
#define debug(args...) fprintf(stderr,args)
#else
#define debug(args...)
#endif //ONLINE_JUDGE
template<typename T> inline T abs(T t) { return t < 0? -t : t; }
const ll modn = 1000000007;
inline ll mod(ll x) { return x % modn; }
#define IOS() ios::sync_with_stdio(0),cin.tie(0)

const int MAXN = 3003;

int n, m, k;
ll dp[4][MAXN][MAXN];
ll M[MAXN][MAXN];

ll go(int i, int j, int c){
    if(i >= n || j >= m) return 0;
    ll &r = dp[c][i][j]; 
    if(r != -1) return r;
    if(c == 0) return r = 0;
    r = 0;
    r = max(r, go(i, j+1, c-1) + M[i][j]);
    r = max(r, go(i+1, j, 3) + M[i][j]);
    r = max(r, go(i+1, j, 3));
    r = max(r, go(i, j+1, c));
    return r;
}

int main (){
	scanf("%d%d%d", &n, &m, &k);
    memset(dp, -1, sizeof(dp));
	for(int a=0;a<k;a++){
        int i, j;
        ll x;
        scanf("%d%d%lld", &i, &j, &x);
        i--;j--;
        M[i][j] = x;
	}
    printf("%lld\n", go(0,0,3));
}



Measured memory_bytes: 356340
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;

int gcd(int x, int y) {
  if (y == 0) return x;
  return gcd(y, x % y);
}

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  vector<int> l(n), r(n);
  for (int i = 0; i < n; i++) cin >> a[i];
  for (int i = 0; i < n - 1; i++) l[i + 1] = gcd(a[i], l[i]);
  for (int i = n - 1; i >= 1; i--) r[i - 1] = gcd(a[i], r[i]);
  int ans = 1;
  for (int i = 0; i < n; i++) {
    ans = max(ans, gcd(l[i], r[i]));
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
#define exrep(i, a, b) for(long long i = a; i <= b; i++)
#define rep(i,n)for(long long i=0;i<(long long)(n);i++)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> P;
typedef vector<ll> vl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vector<ll> > vvl;
typedef vector<vector<P> > vvp;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
 
const ll MOD=1e9+7;
const ll INF=1e18;
const int MAX=510000;
const double pi=acos(-1);
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false); 
  
  ll x;
  cin >> x;
  exrep(a,-2000,2000){
    exrep(b,-2000,2000){
      if(pow(a,5)-pow(b,5)==x){
        cout << a << " " << b << endl;
        return 0;
      }
    }
  }
  return 0;     
}


Measured memory_bytes: 4180
// clang-format off
#include <bits/stdc++.h>

#define mp make_pair
#define fst first
#define snd second
#define forn(i,n) for (int i = 0; i < int(n); i++)
#define forn1(i,n) for (int i = 1; i <= int(n); i++)
#define popcnt __builtin_popcount
#define ffs __builtin_ffs
#define ctz __builtin_ctz
#define clz __builtin_clz
#define all(a) (a).begin(), (a).end()
 
using namespace std;

using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pli = pair<ll,int>;
using pil = pair<int,ll>;
using pll = pair<ll,ll>;
template <typename T> using vec = vector<T>;
using vi = vec<int>;
using vl = vec<ll>;
template <typename T> using que = queue<T>;
template <typename T> using deq = deque<T>;

template <typename T> T id(T b) {return b;};
template <typename T> void chmax(T &x, T y) {if (x < y) x = y;}
template <typename T> void chmin(T &x, T y) {if (x > y) x = y;}
template <typename S, typename K> bool contains(S &s, K k) { return s.find(k) != s.end(); }
void fastio() { ios_base::sync_with_stdio(false); cin.tie(nullptr); }
constexpr ll TEN(int n) { if (n == 0) return 1LL; else return 10LL*TEN(n-1); }
// clang-format on

const int MAX_N = 200000;
int n;
int a[MAX_N];

int main() {
    fastio();

    cin >> n;
    forn(i, n) {
        cin >> a[i];
    }

    sort(a, a + n);

    int x = a[n - 1];
    int y = -1;
    int temp = INT_MAX;
    forn(i, n - 1) {
        if (temp > abs(x - 2 * a[i])) {
            temp = abs(x - 2 * a[i]);
            y = a[i];
        }
    }

    cout << x << " " << y << endl;

    return 0;
}

Measured memory_bytes: 640
from bisect import bisect_left, bisect_right
n, m = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
# print(a)

a_cnt = [0] * (2 * a[-1] + 5)
for ai in a:
    a_cnt[ai] += 1
for i in reversed(range(len(a_cnt) - 1)):
    a_cnt[i] += a_cnt[i + 1]
a_cs = [0] * (n + 1)
for i in range(n):
    a_cs[i + 1] = a_cs[i] + a[n - 1 - i]


def check(x):
    # M回の握手の幸福度の最小値をx以上にできるか
    # つまり、M回の任意の握手の幸福度をx以上にできるか
    cnt = 0
    for ai in a:
        if x >= ai:
            cnt += a_cnt[x - ai]
        else:
            cnt += n
    return cnt >= m


lb = 1  # True
ub = 2 * a[-1] + 3  # False
while ub - lb > 1:
    mid = (ub + lb) // 2
    if check(mid):
        lb = mid
    else:
        ub = mid

# print(lb)

ans = 0
cnt = 0
for ai in a:
    if lb >= ai:
        idx = a_cnt[lb - ai]
    else:
        idx = n
    ans += ai * idx + a_cs[idx]
    cnt += idx
ans -= lb * (cnt - m)
print(ans)


Measured memory_bytes: 17940
#include <algorithm>
#include <iterator>
#include <iostream>
#include <iomanip>
#include <cassert>
#include <utility>
#include <string>
#include <vector>
#include <limits>
#include <queue>
#include <cmath>
#include <map>
#include <set>

using namespace std;

using ll = long long;

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

    for(int k = 0; ; ++k) {
        if(1 + k * A - k >= B) {
            cout << k << endl;
            return 0;
        }
    }

    return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#include "ext/pb_ds/assoc_container.hpp"
#include "ext/pb_ds/tree_policy.hpp"

using namespace std;
using namespace __gnu_pbds;

template <typename T> using order_set = tree <T, null_type, less <T>, rb_tree_tag, tree_order_statistics_node_update>;

#define ll         long long int
#define endl       '\n'
#define pii        pair <int, int>
#define mk         make_pair

static const int maxn = 3e5 + 5;
static const int logn = 19;

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


      int n;
      cin >> n;
      vector <int> arr(n + 1);
      for (int i = 1; i <= n; i++) {
            cin >> arr[i];
      }
      order_set <pii> os;
      for (int i = 1; i <= n; i++) {
            os.insert({i - arr[i], i});
      }
      ll ans = 0;
      for (int i = 1; i <= n; i++) {
            os.erase(os.find({i - arr[i], i}));
            int sum = i + arr[i];
            int cnt1 = os.order_of_key({sum + 1, -1});
            int cnt2 = os.order_of_key({sum, -1});
            ans += (cnt1 - cnt2);
      }
      cout << ans;
}


Measured memory_bytes: 16344
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int H,A;
    cin>>H>>A;
    if(H%A==0)
    {
        cout<<H/A<<"\n";
    }
    else
    {
        cout<<(H/A)+1<<"\n";
    }
    return 0;
}

Measured memory_bytes: 764
import java.util.Scanner;

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

        if (scanner.hasNextLine()) {
            String line = scanner.nextLine();
            if (line.length() != 26) {
                for (char c = 'a'; c <= 'z'; ++c) {
                    boolean notFound = true;
                    for (int i = 0; i < line.length(); ++i) {
                        if (line.charAt(i) == c) {
                            notFound = false;
                            break;
                        }
                    }
                    if (notFound) {
                        System.out.println(line + c);
                        break;
                    }
                }
            } else if (line.equals("zyxwvutsrqponmlkjihgfedcba")) {
                System.out.println(-1);
            } else {
                for (int i = 24; i >= 0; --i) {
                    for (char c = (char)(line.charAt(i) + 1); c <= 'z'; ++c) {
                        boolean notFound = true;
                        for (int j = 0; j <= i; ++j) {
                            if (line.charAt(j) == c) {
                                notFound = false;
                                break;
                            }
                        }
                        if (notFound) {
                            System.out.println(line.substring(0, i) + c);
                            return;
                        }
                    }
                }
            }
        }
    }
}

Measured memory_bytes: 22996
#include <iostream>
#include <map>
#include <algorithm>
#include <string>
#include <vector> 
#include <numeric>
#include <cmath>
#include <queue>
#include <iomanip>
#include <functional>


#define CHMAX(a,b) a = std::max(a,b)
#define CHMIN(a,b) a = std::min(a,b)
#define MAXMIN(a,b,c) std::max(a,min(b,c))
#define CHABS(a) a = std::abs(a) 
#define COUT(a) std::cout << a << std::endl
#define CERR(a) std::cerr << a << std::endl
#define FOR(n) for(lli i = 0; i < n; i++)

using namespace std;
using lli = long long int;
using pll = pair<lli, lli>;
using tlll = tuple<lli, lli, lli>;
using vll = vector<lli>;

lli mod197 = 1000000007LL;
lli INF = 10000000000000;

// ax + by = gcd(a,b) 最大公約数
template< typename T >
T extgcd(T a, T b, T& x, T& y) {
	T d = a;
	if (b != 0) {
		d = extgcd(b, a % b, y, x);
		y -= (a / b) * x;
	}
	else {
		x = 1;
		y = 0;
	}

	return d;
}

lli num[200000] = {};
lli a[200000] = {};


lli n, k;

void dfs(lli i, lli count, lli left) {

	if (left == 0) {
		cout << i + 1 << endl;
		return;
	}

	//cerr << i << " " << count << " " << left << endl;

	if (num[i] == -1) {
		num[i] = count;
	}
	else {
		if (count - num[i] == 0) {
			left = 0;
		}
		else {
			//cerr << "count - num[i]" << (count - num[i]) << endl;
			left %= (count - num[i]);
		}
		if (left == 0) {
			cout << i + 1 << endl;
			return;
		}
	}
	dfs(a[i], count + 1, left - 1);

	return;
}

//dp[turn][win or lose] = score
// 0 : r.1 : s,2 : p
lli dp[100001][3] = {};

int main(void) {

	lli n, k, r, s, p;
	cin >> n >> k >> r >> s >> p;

	string t;
	cin >> t;

	lli answer = 0;

	for (lli i = 0; i < k; i++) {


		for (lli j = 0; j <= n / k + 1; j ++) {
			dp[j][0] = dp[j][1] = dp[j][2] = 0;
		}

		lli count = 0;
		for (lli j = i; j < n; j += k) {

			for (lli m = 0; m < 3; m++) {
				//rを今出す
				if (m != 0) {
					if (t[j] == 's') {
						CHMAX(dp[count + 1][0], r + dp[count][m]);
					}
					else
						CHMAX(dp[count + 1][0], dp[count][m]);
				}

				//s
				if (m != 1) {
					if (t[j] == 'p') {
						CHMAX(dp[count + 1][1], s + dp[count][m]);
					}
					else
						CHMAX(dp[count + 1][1], dp[count][m]);
				}
				//p
				if (m != 2) {
					if (t[j] == 'r') {
						CHMAX(dp[count + 1][2], p + dp[count][m]);
					}
					else
						CHMAX(dp[count + 1][2], dp[count][m]);
				}

			}

			count++;
		}

		//cerr << i << " " << std::max({ dp[count][0], dp[count][1] ,dp[count][2] }) << endl;
		answer += std::max({ dp[count][0], dp[count][1] ,dp[count][2] });

	}


	cout << answer << endl;

	return 0;
}

Measured memory_bytes: 4608
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define mkp make_pair
#define rep(i,s,f) for(i=s;i<f;i++)
#define db cout<<'h'<<'i'<<endl 
#define pb push_back
#define pii pair<int,int>
#define F first
#define S second
#define B begin()
#define E end()
#define vi vector<int>
#define vii vector<pair<int,int>>
#define boost ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define PI 3.14159265
#define mod 1000000007
#define mod2 998244353
#define space 100005
//<<fixed << setprecision(9)

int main()
{
    int n,i,j,t;
    boost;

    cin>>n;
    string s;
    cin>>s;
    if(n<3200) cout<<"red";
    else cout<<s;

    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int int_fast64_t
using namespace std;
main() {
    int a, b; cin >> a >> b;
    string x, y; cin >> x >> y;
    int GG = __gcd(a, b);
    int LL = a * b / GG;
    int La = LL / a;
    int Lb = LL / b;
    int p = 0, q = 0;
    while(p != a and q != b) {
        if(LL / a * p == LL / b * q) {
            if(x[p] != y[q]) return cout << "-1", 0;
        }
        if(La * p < Lb * q) p ++;
        else q ++;
    }
    cout << LL;
}

Measured memory_bytes: 512
#include<stdio.h>
int main(){
    int a,b,c;
    scanf("%d %d",&a,&b);
    if(a==1){
        if(b==2){
            c=3;}
        else{
            c=2;}
    }
    else if(a==2){
        if(b==3){
            c=1;}
        else{
            c=3;}
    }
    else {
        if(b==1){
            c=2;}
        else{
            c=1;}
    }
    printf("%d\n",c);

return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main(){
  long int a,b,c,k,ans;
  cin>>a>>b>>c>>k;
  ans=0;
  if(a>=k) ans=k;
  else{
    if(a<=k&&k<=a+b) ans=a;
    else ans=a-(k-a-b);
  }
  cout<<ans<<endl;
}


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

using namespace std;

struct CWW{CWW(){ios::sync_with_stdio(false);cin.tie(0);}}cww;

typedef long long LL;
const LL MOD=1e9+7;
typedef vector<int> V;
typedef vector<V> VV;

#define SZ 300000
LL fact[SZ];
struct INIT{INIT(){fact[0]=1;for(int i=1;i<SZ;i++)fact[i]=fact[i-1]*i%MOD;}}init;
// a x + b y = gcd(a, b)
// O(log (a+b) )
LL extgcd(LL a, LL b, LL &x, LL &y) {
  LL g = a; x = 1; y = 0;
  if (b != 0) g = extgcd(b, a % b, y, x), y -= (a / b) * x;
  return g;
}

// mを法とするaの逆元
// O(log a)
LL invMod(LL a) {
	LL x, y;
	if (extgcd(a, MOD, x, y) == 1)return (x + MOD) % MOD;
	else	 return 0; // unsolvable
}
// 組み合わせnCk (mod MOD)
// O(n)
LL Comb(LL n,LL k){
	LL u=fact[n];
	LL d=(fact[k]*fact[n-k])%MOD;
	return  (u*invMod(d))%MOD;
}
int main(){
    LL H,W,A,B;
    cin>>H>>W>>A>>B;
    LL res=Comb(H+W-2,H-1);
    for(LL i=1;i<=B;i++)
	res+=MOD-Comb(H-A+i-2,i-1)*Comb(A-1+W-i,A-1)%MOD;
    cout<<res%MOD<<endl;
    return 0;
}


Measured memory_bytes: 2560