akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>
#include<algorithm>
#include<set>
#include<cassert>
#include<cstring>

using namespace std;

bool can[5][10];

typedef pair<int,int> P;

struct Info{
  string s;
  int hit, blow;
};

P getHit_Blow(const string& a, const string& b){
  P res(0,0);
  for(int i = 0; i < (int)a.length(); i++) if(a[i] == b[i]) res.first++;

  for(int i = 0; i < (int)a.length(); i++)
    for(int j = 0; j < (int)b.length(); j++) if(a[i] == b[j]) res.second++;

  res.second -= res.first;
  //  if(res.first == 3 && res.second == 1) cout << a << " " << b << endl;
  assert(res.first >= 0 && res.second >= 0);
  return res;
}

bool isValid(const string& s, const vector<Info>& v){
    for(int i = 0; i < (int)v.size(); i++){
    P p = getHit_Blow(v[i].s, s);
    if(p.first != v[i].hit || p.second != v[i].blow) return false;
  }
  return true;
}

string findCritical(const vector<string>& v, const vector<string>& possible){
  
  for(int i = 0; i < (int)possible.size(); i++){
    set<P> s;
    for(int j = 0; j < (int)v.size(); j++){
      P p = getHit_Blow(possible[i], v[j]);
      if(s.find(p) != s.end()) break;
      s.insert(p);
    }
    if(s.size() == v.size()) return possible[i];
  }
  return "????";
}

void generate(vector<string>& possible){
  possible.clear();

  for(int i = 0; i < 10; i++){
    for(int j = 0; j < 10; j++){
      if(i == j) continue;
      for(int k = 0; k < 10; k++){
	if(i == k || j == k) continue;
	for(int l = 0; l < 10; l++){
	  if(i == l || j == l || k == l) continue;
	  string s = "????";
	  s[0] = i+'0';
	  s[1] = j+'0';
	  s[2] = k+'0';
	  s[3] = l+'0';
	  possible.push_back(s);
	}
      }
    }
  }
  sort(possible.begin(), possible.end());
}

vector<string> erase(const vector<string>& v, const vector<Info>& in){
  vector<string> res;
  for(int i = 0; i < (int)v.size(); i++){
    bool flg = true;
    for(int j = 0; j < (int)in.size(); j++) if(v[i] == in[j].s && in[j].hit != 4) flg = false;
    if(flg) res.push_back(v[i]);
  }
  return res;
}


int main(){
  vector<string> possible;
  generate(possible);
  int N;
  while(cin >> N && N){
    vector<Info> v(N);
    memset(can, true, sizeof(can));
    for(int i = 0; i < N; i++) cin >> v[i].s >> v[i].hit >> v[i].blow;
    vector<string> ans;

    for(int i = 0; i < (int)possible.size(); i++)
      if(isValid(possible[i], v)) ans.push_back(possible[i]);
    
    ans = erase(ans, v);
    if(ans.size() == 1) cout << ans[0] << endl;
    else cout << findCritical(ans, possible) << endl;
  }
  return 0;
}

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

int main(void){
    int S,cnt=0;
    cin>>S;
    for(int i=0;i<3;i++){
        if(S%10==1)
            cnt++;
        S/=10;
    }
    cout<<cnt<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>

int main() {
    int a, b, c;
    int ans;
    std::cin >> a >> b >> c;
    if (a != b && b != c && c != a) {
        ans = 3;
    } else if (a == b && b == c && c == a) {
        ans = 1;
    } else {
        ans = 2;
    }
    std::cout << ans << std::endl;
    return 0;
}

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

using namespace std;

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

    string L;
    cin >> L;
    int n = L.size();
    constexpr int MOD = 1'000'000'007;
    vector<int> dp1(n + 1, 0), dp2(n + 1, 0);
    dp1[0] = 1;

    for (int i = 0; i < n; ++i) {
        if (L[i] == '1') {
            // set bit in a or in b
            dp1[i + 1] = (dp1[i + 1] + 2LL * dp1[i]) % MOD;
            // don't set the bit
            dp2[i + 1] = (dp2[i + 1] + dp1[i]) % MOD;
        } else {
            dp1[i + 1] = dp1[i];
        }
        dp2[i + 1] = (dp2[i + 1] + 3LL * dp2[i]) % MOD;
    }
    //cout << dp1[n] << " " << dp2[n] << endl;
    cout << (dp1[n] + dp2[n]) % MOD << "\n";


    return 0;
}

Measured memory_bytes: 1232
import sys
from heapq import heapify, heappush, heappushpop

def main():
    input = sys.stdin.readline
    N = int(input())

    A = list(map(int, input().split()))

    F = [0 for _ in range(N+1)]
    B = [0 for _ in range(N+1)]
    F[0] = sum(A[:N])
    B[N] = sum(A[2*N:])

    Ffactors = []
    Bfactors = []
    for i in range(N):
        heappush(Ffactors, A[i])
        heappush(Bfactors, -A[3*N-1-i])

    for i in range(1, N+1):
        F[i] = F[i-1] + A[N-1+i] - heappushpop(Ffactors, A[N-1+i])
        B[N-i] = B[N+1-i] + A[2*N-i] + heappushpop(Bfactors, -A[2*N-i])

    ans = -float('inf')
    for i in range(N+1):
        ans = max(ans, F[i] - B[i])

    return ans


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


Measured memory_bytes: 37212
#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
//#include <regex>

/* g++ -g -std=c++0x */
/* g++ -g -std=c++11 */

using namespace std;

// freopen("input.txt", "rt", stdin);
// freopen("output.txt", "wt", stdout);

#define ALL(c)          (c).begin(), (c).end()
#define ALLR(c)         (c).rbegin(), (c).rend()
#define FOR(i,a,b)      for (int i=(a); i < (b); ++i)
#define FORR(i,a,b)     for (int i=(a); i > (b); --i)
#define FOR_ALL(i,c)    for (__typeof((c).begin()) i=(c).begin();   \
                             i != (c).end(); ++i)
#define FOR_ALLR(i,c)   for (__typeof((c).rbegin()) i=(c).rbegin(); \
                             i != (c).rend(); ++i)
#define SZ(array)       (sizeof(array)/sizeof(array[0]))
#define lc(x)           (x<<1)     /* 2*x */
#define rc(x)           (x<<1 | 1) /* 2*x+1 */
#define lowbit(x)       (x & (-x)) /* 0b10100 -> 0b100 */

typedef long long       LL;
typedef map<int,int>    MII;
typedef pair<int,int>   PII;
typedef set<int>        SI;
typedef vector<bool>    VB;
typedef vector<double>  VD;
typedef vector<int>     VI;
typedef vector<string>  VS;

/* check if a key is in container C */
template <class C>
inline bool in_(const typename C::key_type& k, const C& A)
{ return A.find(k) != A.end(); }
inline bool in_(const string& s, const string& S)
{ return S.find(s) != string::npos; }

int main()
{
/* #ifndef ONLINE_JUDGE */
/*     freopen("foo", "rt", stdin); */
/* #endif */
    std::ios::sync_with_stdio(false);

    int n;
    while (cin >> n) {
        LL a = 2, b = 1, c;
        int m = n - 1;
        if (m == 0) {
            cout << b << endl;
            return 0;
        }
        else
            while (m--) {
                c = a + b;
                a = b;
                b = c;
            }
        cout << c << endl;
    }
}



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

using namespace std;

#define Q int t; scanf("%d", &t); for(int q=1; q<=t; q++)
typedef long long int lli;
typedef pair<int, int> pi;
typedef pair<int, pi> node;


int main()
{
    lli gc = 0;
    int n;
    cin >> n;
    for(int i=0; i<n; i++){
        lli a;
        cin >> a;
        gc = __gcd(a, gc);
    }
    cout << gc << "\n";

    return 0;
}


Measured memory_bytes: 3576
#include <iostream>
using namespace std;
int main(void){
    
    int r;
    cin >>r;
    
    if(r<1200){
        cout <<"ABC";
    }else if(r<2800){
        cout <<"ARC";
    }else{
        cout <<"AGC";
    }
    
    cout <<endl;
    
}


Measured memory_bytes: 256
fun main(args: Array<String>) {
    val (n, m, x) = readLine()!!.split(' ').map(String::toInt)
    val a = readLine()!!.split(' ').map(String::toInt)
    var p = -a.binarySearch(x) - 1
    println(Math.min(p, a.size - p))
}


Measured memory_bytes: 38304
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        // write your code here
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int K = sc.nextInt();

        long sum = 0;
        ModLib modlib = new ModLib((long)1e9 + 7);
        for(int k = K ; k <= N+1 ; k++){
            long num = modlib.add(modlib.mult(k, modlib.sub(modlib.add(N, 1), k)), 1);
            sum = modlib.add(sum, num);
        }

        System.out.println(sum);
    }
}

class ModLib {
    final long mod;

    public ModLib(long mod) {
        this.mod = mod;
    }

    public long add(long a, long b) {
        return (a + b) % mod;
    }

    public long sub(long a, long b) {
        return (a - b + mod) % mod;
    }

    public long mult(long a, long b) {
        return ((a % mod) * (b % mod)) % mod;
    }

    /*
        aのx乗を求める。
        O(logx)
     */
    public long pow(long a, long x) {
        long res = 1;
        while (x > 0) {
            if (x % 2 == 1) res = mult(res, a);
            a = mult(a, a);
            x >>= 1;
        }

        return res;
    }

    public long inv(long a) {
        return pow(a, mod - 2);
    }

    public long div(long a, long b) {
        return mult(a, inv(b));
    }
}

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

using namespace std;

long long prime = 1000000007;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, k;
    cin >> n >> k;
    long long answer = 0;
    for (long long k0 = k; k0 <= n + 1; ++k0) {
        long long from = (k0 - 1) * k0 / 2;
        long long to = (n + n - k0 + 1) * k0 / 2;
        answer += to - from + 1;
    }
    answer %= prime;
    cout << answer << endl;
    return 0;
}


Measured memory_bytes: 3648
#include <iostream>
#include <vector>
#include <utility>
#include <map>
#include <algorithm>
#include <queue>
#include <cmath>

using namespace std;

int main() {
	int n, k, digit=0;
	cin >> n >> k;

	while(n >= k){
		n = n / k;
		digit++;
	}

	cout << digit+1 << endl;
	return 0;
}

Measured memory_bytes: 888
n, k = map(int, input().split())
aa = list(map(int, input().split()))
mod = int(10**9+7)
total = 0
for i in range(n):
    for j in range(i+1, n):
        a = aa[i]
        b = aa[j]

        if a < b:
            total += k * (k-1) // 2
            total %= mod
        if a > b:
            total += k * (k+1) // 2
            total %= mod

print(total)

Measured memory_bytes: 3188
#include <stdio.h>
int gcd(int a, int b)
{
    int t = a;
    a = a>b?a:b;
    b = t + b - a;
    while (b)
    {
        int t = a%b;
        a = b;
        b = t;
    }
    return a;
}
int main()
{
    int a, b;
    scanf("%d%d", &a, &b);
    printf("%d\n", gcd(a, b));
    return 0;
}



Measured memory_bytes: 2732
package main

import (
	"fmt"
)

func main() {
	var a, b, c, d int
	fmt.Scan(&a, &b, &c, &d)
	ans := a * c
	tmp := a * d
	if tmp > ans {
		ans = tmp
	}
	tmp = b * c
	if tmp > ans {
		ans = tmp
	}
	tmp = b * d
	if tmp > ans {
		ans = tmp
	}
	if a >= 0 && 0 >= b {
		tmp = 0
		if tmp > ans {
			ans = tmp
		}
	}
	if d >= 0 && 0 >= c {
		tmp = 0
		if tmp > ans {
			ans = tmp
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 1768
#include <bits/stdc++.h>
using namespace std;
#define  rep(i, n) for(int i = 0; i < n; i++) 
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  INF 1LL << 60
typedef long long int LL;
typedef long long int ll;
#define pll pair<ll, ll>
#define F first
#define S second
const int MOD = 1000000007;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return true; } return false; }
//sort(all(x))とするとソートできるよ
// 10^x は pow(10,(x)) 
// 任意のlogは　対数の底の変換を使う    log(N) / log(任意の底)

int main(){
    int N,K;cin >> N >> K ;
    vector<LL> H(N);
    rep(i,N)cin >> H[i];
    if(K > N)K = N;
    sort(rall(H));
    LL ans = 0;
    rep(i,K){
        H[i] = 0;
    }
    rep(i,N)ans += H[i];
    cout << ans << endl;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define lson k<<1
#define rson k<<1|1
int prime(ll t)
{
    ll sq=sqrt(t)+1;
    for(int i=2;i<sq;i++)
    {
        if(t%i==0)
            return i;
    }
    return -1;
}
bool check(ll t)
{
    int i=prime(t);
    if(i==-1)
        return 1;
    while(t%i==0)t/=i;
    return t==1;
}
set<int> st;
int main()
{
    ll n;
    cin >> n;
    if(n==1)
    {
        cout << 0;
        return 0;
    }
    ll sq=sqrt(n)+1;
    int ans=0;
    for(ll i=2;i<sq;i++)
    {
        if(n%i==0)
        {
            if(!check(i))continue;
            ans++;
            n/=i;
            sq=sqrt(n)+1;
            st.insert(i);
        }
    }
    for(ll i=sq-1;i>0;i--)
    {
        if(n%i==0)
        {
            ll ti=n/i;
            if(st.count(ti) || !check(ti))continue;
            ans++;
            n/=ti;
            i=sqrt(n);
            st.insert(ti);
        }
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 3684
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll Maxn=1e5+10;
ll A[Maxn],sum[2][Maxn];
int main() {
    ios::sync_with_stdio(false);
    ll N = 0;
    cin>>N;
    for(ll i=1;i<=N;i++){
        cin>>A[i];
        if(i%2){
            sum[0][i]=sum[0][i-1]+A[i];
            sum[1][i]=sum[1][i-1]-A[i];
        }else{
            sum[0][i]=sum[0][i-1]-A[i];
            sum[1][i]=sum[1][i-1]+A[i];
        }
    }
    for(ll i=1;i<=N;i++){
        if(i%2){
            cout<<sum[1][i-1]+(sum[0][N]-sum[0][i-1])<<" ";
        }else{
            cout<<sum[0][i-1]+(sum[1][N]-sum[1][i-1])<<" ";
        }
    }
    return 0;
}


Measured memory_bytes: 5956
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
ll a7=1000000007;
ll inf=1000000000000000;

ll min(ll a,ll b){
    if(a<b)return a;
    return b;
}
ll max(ll a,ll b){
    if(a>b)return a;
    return b;
}

int main(){
    ll n;cin>>n;
    ll aa[n],bb[n],cc[n];
    vector<ll> a,b,c;
    for(ll i=0;i<n;i++){
        cin>>aa[i];
        a.push_back(aa[i]);
    }
    for(ll i=0;i<n;i++){
        cin>>bb[i];
        b.push_back(bb[i]);
    }
    for(ll i=0;i<n;i++){
        cin>>cc[i];
        c.push_back(cc[i]);
    }
    sort(a.begin(),a.end());
    sort(b.begin(),b.end());
    sort(c.begin(),c.end());
    ll ans=0;
    ll ca[n];
    ll cb[n]; //b[i]より小さいa[j]のjの個数；
    ll ccc[n];
    for(ll i=0;i<n;i++){
        ca[i]=1;
    }
    ll count=0;
    ll d;
    for(ll i=0;i<n;i++){
        d=count;
        if(i==0){
            cb[i]=0;
        }else{
            cb[i]=cb[i-1];
        }
        for(ll j=d;j<n;j++){
            if(b[i]>a[j]){
                count++;
                cb[i]+=ca[j];
            }else{
                j=inf;
            }
        }
    }
    count=0;
    for(ll i=0;i<n;i++){
        d=count;
        if(i==0){
            ccc[i]=0;
        }else{
            ccc[i]=ccc[i-1];
        }
        for(ll j=d;j<n;j++){
            if(c[i]>b[j]){
                count++;
                ccc[i]+=cb[j];
            }else{
                j=inf;
            }
        }
    }
    for(ll i=0;i<n;i++){
        ans+=ccc[i];
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 7412
#include <bits/stdc++.h>
#include <atcoder/segtree>
#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 sp(n) cout << fixed << setprecision(n)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
typedef long long ll;
using namespace std;
using namespace atcoder;
int op(int a, int b) { return max(a, b); }

int e() { return -1; }

int target;

bool f(int v) { return v < target; }
int main(void){
    ll n,k;cin>>n>>k;
    vector<int> a(n),c;
    rep(i,n)cin>>a[i];
    vector<int> b(310000,0);
    segtree<int, op, e> seg(b);
    rep(i,n){
        int x=a[i],l=a[i]-k,r=a[i]+k+1;
      	chmax(l,0);
      	chmin(r,301000);
        int buf=seg.prod(l,r);
        seg.set(a[i],buf+1);
    }
    int res=seg.all_prod();
    cout<<res<<endl;
}

Measured memory_bytes: 9856
//
// Created by sark2 on 22-10-2019.
//

#include "bits/stdc++.h"

using namespace std;
#define PB push_back
#define IOS cin.sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define CASES int t;cin>>t;while(t--)
#define MP make_pair

using ll = long long;
using ld = long double;

ll mod = 1e9 + 7;




int main() {
    IOS

    ll n; cin>>n;
    set<pair<ll,ll>>st;

    for(ll i = 1; i*i <= n; i++){
        if(n%i == 0){
            st.insert({i,n/i});
        }
    }

    ll ans = LLONG_MAX;

    for(auto i : st){
        ans = min(ans, i.first + i.second -2);
    }

    cout<<ans;



}


Measured memory_bytes: 512
#include<bits/stdc++.h>
#define N 100005
using namespace std;
int n,m,a[1005];
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++)scanf("%d",&a[i]);
	int ans=0;
	for(int i=2;i<=n-1;i++)if(a[i]>a[i-1]&&a[i]<a[i+1])ans++;
	else if(a[i]<a[i-1]&&a[i]>a[i+1])ans++;
	printf("%d\n",ans);
	
	return 0;
}

Measured memory_bytes: 256
import sys
readline = sys.stdin.readline
 
 
def st(line):
    tmp = ''
    for l in line:
        if l == '\n':
            yield tmp
        elif l == ' ':
            yield tmp
            tmp = ''
        else:
            tmp += l
 
 
def solve():
    N = int(input())
    As = st(readline())
 
    d = dict()
    total = 0
    for a in As:
        a = int(a)
 
        if a in d:
            d[a] += 1
        else:
            d[a] = 1
        total += a
 
    Q = int(input())
    queries = (map(int, readline().strip().split()) for _ in range(Q))
 
    for que in queries:
        b, c = que
 
        if b not in d:
            print(total)
            continue
 
        n_b = d[b]
        d[b] = 0
 
        if c not in d:
            d[c] = 0
 
        d[c] += n_b
        total += (c - b) * n_b
 
        print(total)
 
 
def main():
    solve()
 
 
if __name__ == "__main__":
    main()

Measured memory_bytes: 15240
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
void pr(){ln;}
template<Z A,Z...B>void pr(const A &a,const B&...b){cout<<a<<' ';pr(b...);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1e9+7,MAXL=1LL<<61,dx[8]={-1,0,1,0,-1,-1,1,1},dy[8]={0,1,0,-1,-1,1,1,-1};
typedef pair<ll,ll> P;

void Main() {
  ll x;
  R x;
  vector<P> v;
  REP(i,-1000,1000) v.pb(P(i*i*i*i*i,i));
  sort(all(v));
  rep(i,v.size()) {
    rep(j,v.size()) {
      if(v[j].F-v[i].F==x) {
        pr(v[j].S,v[i].S);
        return;
      }
    }
  }
}

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


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

#define pb push_back

const int mxn = 10000;
int n, t = 0;
vector<int> adj[mxn];
int a[mxn], val[mxn];

long long dfs(int v, int p) {
	long long ans = 0;	
	for (int w : adj[v]) if (w != p)
		ans += dfs(w,v);
	a[v] = val[t++];
	return ans + (p == -1 ? 0 : a[v]);
}

int main() {
	cin >> n;
	for (int e = 0; e < n-1; e++) {
		int a, b; cin >> a >> b;
		adj[--a].pb(--b); adj[b].pb(a);
	}
	for (int i = 0; i < n; i++) 
		cin >> val[i];
	sort(val,val+n);
	cout << dfs(0,-1) << endl;
	for (int i = 0; i < n; i++)
		cout << a[i] << " ";
	cout << endl;
    return 0;
}

Measured memory_bytes: 1536
#include <iostream>
#include <vector>
#include <climits>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <string>
#include <bitset>
#include <utility>
#include <numeric>
#include <queue>
#include <stack>

using ll = long long;
using namespace std;

constexpr int MOD = 1e9 + 7;
constexpr ll MOD_LL = ll(1e9) + 7;

int main(void) {
	int n, m, c;
	cin >> n >> m >> c;
	
	vector<int> b(m);
	for(int i = 0; i < m; ++i) {
		cin >> b[i];
	}
	
	int ans = 0;
	for(int i = 0; i < n; ++i) {
		int sum = 0;
		
		for(int j = 0; j < m; ++j) {
			int a;
			cin >> a;
			sum += a * b[j];
		}
		
		sum += c;
		
		if( sum > 0 ) ans++;
	}
	
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
let m = 1039999

let split_on_char sep s =
  let open String in
  let r = ref [] in
  let j = ref (length s) in
  for i = length s - 1 downto 0 do
    if get s i = sep then begin
      r := sub s (i + 1) (!j - i - 1) :: !r;
      j := i
    end
  done;
  sub s 0 !j :: !r

let to_x = Array.make 128 0

let to_key s =
  let n = String.length s in
  let rec doit i p acc =
    if i = n then acc
    else doit (i + 1) (5*p) (acc + p*(to_x.(Char.code s.[i]))) in
  doit 0 1 0

let to_h1 k = k mod m
let to_h2 k = 1 + (k mod (m - 1))

let insert s t =
  let k = to_key s in
  let h1 = to_h1 k in
  let h2 = to_h2 k in
  let rec doit i =
    let h = (h1 + h2*i) mod m in
    if t.(h) = s then ()
    else if t.(h) = "\000" then t.(h) <- s
    else doit (i + 1) in
  doit 0

let find s t =
  let k = to_key s in
  let h1 = to_h1 k in
  let h2 = to_h2 k in
  let rec doit i =
    let h = (h1 + h2*i) mod m in
    if t.(h) = s then true
    else if t.(h) = "\000" then false
    else doit (i + 1) in
  doit 0

let () =
  to_x.(Char.code 'A') <- 1;
  to_x.(Char.code 'C') <- 2;
  to_x.(Char.code 'G') <- 3;
  to_x.(Char.code 'T') <- 4;
  let n = read_int () in
  let t = Array.make m "\000" in
  for _ = 0 to n - 1 do
    match split_on_char ' ' (read_line ()) with
    | ["find"; s] -> print_endline (if find s t then "yes" else "no")
    | [_; s] -> insert s t
    | _ -> assert false
  done

Measured memory_bytes: 20940
"use strict";
    
const main = arg => {
    arg = arg.trim().split("\n");
    const N = parseInt(arg[0]);
    const a = arg[1].split(" ").map(n=>parseInt(n));

    let odd  = 0;
    let even = 0;
    let four = 0;
    
    for(let i=0; i<N; i++) {
        if(a[i] % 4 === 0) {
            four++;
        } else if(a[i] % 2 === 0) {
            even++;
        } else {
            odd++;
        }
    }
    
    let answer = "No";
    
    // 4の倍数が奇数より多い
    if(odd <= four) {
        answer = "Yes";
    // 4の倍数 + 1が奇数と同じ かつ 2の倍数はない
    } else if(four + 1 === odd && even === 0) {
        answer = "Yes";
    }
    
    console.log(answer);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));


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

int main(){
  int K,T; cin >> K >> T;
  int res=0;
  for(int i=0; i<T; i++){
    int a; cin >> a;
    if(a>(K-a+1)){
      res+=(a-K+a-1);
    }
  }
  cout << res << endl;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
	"strings"
)

func main() {
	var n int
	fmt.Scan(&n)
	var s string
	fmt.Scan(&s)
	if n/strings.Count(s, "R") < 2 {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}

}


Measured memory_bytes: 640
log = console.log;

var stdin = require("fs").readFileSync("/dev/stdin", "UTF-8");
var lines = stdin
  .split("\n")
  .filter(v => v !== "")
  .map(v => v.split(" ").map(Number));

var N = lines[0];
a = lines[1];

colors = Array(8).fill(0);
supers = 0;

a.forEach(rate => {
  if (rate <= 399) colors[0] = 1;
  else if (rate <= 799) colors[1] = 1;
  else if (rate <= 1199) colors[2] = 1;
  else if (rate <= 1599) colors[3] = 1;
  else if (rate <= 1999) colors[4] = 1;
  else if (rate <= 2399) colors[5] = 1;
  else if (rate <= 2799) colors[6] = 1;
  else if (rate <= 3199) colors[7] = 1;
  else if (rate >= 3200) supers += 1;
});

const colorcount = colors.reduce((a, b) => a + b);

if (supers === 0) {
  console.log(colorcount, colorcount);
} else if (supers >= 1 && colorcount === 0) {
  console.log(1, supers);
} else {
  console.log(colorcount, colorcount + supers);
}


Measured memory_bytes: 7752
def make_div(n):
    divs = []
    
    for i in range(1, int(n**0.5)+1):
        if n%i==0:
            divs.append(i)
            
            if i!=n//i:
                divs.append(n//i)
    
    divs.sort()
    
    return divs

N = int(input())
d = make_div(N)
d = d[1:]
s = set()

for di in d:
    N2 = N
    
    while N2%di==0:
        N2 //= di
    
    if (N2-1)%di==0:
        s.add(di)

d = make_div(N-1)
d = d[1:]

for di in d:
    s.add(di)

print(len(s))

Measured memory_bytes: 39152
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,n) for(int i=0;i<n;i++)
#define why(n,x) int n;while(cin >>n,n!=x)
#define iFOR(i,x,n)for(int i=x;i<n;i++)
#define unless(flg) if ( !(flg) )
#define read cin<<
#define echo cout<<
#define fin <<'\n'
#define __ <<" "<<
#define bash push_back
#define alles(x) x.begin(),x.end()
#define SWAP(a,b) ((a != b) && (a += b,b = a - b,a -= b))
#define cinf(i,n,x) for(int UNCH = (i); UNCH < (n); UNCH++) cin>>x[UNCH];
#define ABS(x) (x)<0 ? -(x) : (x)
#define int long long
int dx[]={1,0,-1,0,1,1,-1,-1};
int dy[]={0,-1,0,1,-1,1,-1,1};
const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
bool inside(int x,int y,int w,int h){
  return (x>=0 && y>=0 && x<w && y<h);}
typedef long long ll;
typedef pair < int , int >  pii;
typedef vector < int > vit;
typedef map < string , int > mstit;
typedef vector < pii > vpi ;
typedef greater < pii > gpi;
typedef priority_queue < pii , vpi , gpi > dijk ;

int n , a , b;
int h[100005];

bool Judge(int X){
    int plus =0;
    FOR(i,n){
        int j = 0;
        if( h[i] - b*X > 0){
            int chek = h[i] - b*X ;
            chek = (chek+a-b-1) / (a-b);
            plus += chek;
        }
    }
    return ( plus > X ) ? false : true;
}

signed main(){
    cin.tie(0), ios::sync_with_stdio(false);
    cin >> n>> a>> b;
    cinf(0,n,h);
    sort(h,h+n);
    int ok = INF,ng = -1;
    while(ok - ng > 1) {
        int mid = (ng + ok) >> 1 ;
        (Judge(mid) ? ok  : ng ) = mid;
    }
    cout << ok fin;
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef double db; 
typedef string str;
 
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
 
typedef vector<int> vi; 
typedef vector<bool> vb; 
typedef vector<ll> vl; 
typedef vector<db> vd; 
typedef vector<str> vs; 
typedef vector<pi> vpi;
 
#define sz(x) (int)(x).size()
#define f first
#define s second
#define all(x) x.begin(), x.end()
#define sor(x) sort(all(x))
#define ins insert 
#define ft front() 
#define bk back()
#define pf push_front 
#define pb push_back
#define endl '\n'
 
const ll MOD = 1e9+7; // 998244353;
const ll INF = 1e18;
const int n = 5e5;

int main() {
   ios_base::sync_with_stdio(false); cin.tie(nullptr);
   str s; cin >> s;
   vi res(sz(s));
   res[sz(s) - 1] = 1;
   for (int i = sz(s) - 2; i >= 0; i--)
      res[i] = res[i + 1] * 10 % 2019;
   int cur = 0;
   vl cnt(2019); cnt[0]++;
   for (int i = sz(s) - 1; i >= 0; i--) {
      cur += res[i] * (s[i] - '0');
      cur = cur % 2019;
      cnt[cur]++;
   }
   ll ans = 0;
   for (int i : cnt)
      ans += i * (i - 1) / 2;
   cout << ans;
   return 0;
}

Measured memory_bytes: 4308
n = int(input())
l = list(map(int, input().split()))
c = 1

bean = True
for i in range(1, n):
  bean = True
  for j in range(i, 0, -1):
    if l[j-1] > l[i]:
      bean = False
  if bean:
    c += 1

print(c)




Measured memory_bytes: 3068
#include<bits/stdc++.h>
using namespace std;long n,m,a,b,e[1<<17];vector<int>G[1<<17];int f(int u,int s=1){e[u]=1;for(int v:G[u])e[v]||(s+=f(v));return s;}main(){cin>>n>>m;for(;cin>>a>>b;G[a].push_back(b))G[b].push_back(a);a=min(f(1),f(2));cout<<n*~-n/2-a*(n-a)-m<<endl;}

Measured memory_bytes: 10624
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

n = int(readline())
w = read().decode().rstrip().split()

if len(set(w)) != n:
    print('No')
    exit()
for i in range(1, n):
    if w[i - 1][-1] != w[i][0]:
        print('No')
        exit()
print('Yes')


Measured memory_bytes: 9240
#include <iostream>
#include <algorithm>
#include <map>
#include <vector>
#include <string>
#include <queue>
using namespace std;

static const int N = 100;
static const int INFTY = (1<<21);

int n, M[N][N];
int d[N];

void bfs(int s) {
	queue<int> q;
	q.push(s);
	for(int i = 0; i < n; i++) d[i] = INFTY;
	d[s] = 0;
	int u;
	while(!q.empty()){
		u = q.front(); q.pop();
		for(int v = 0; v < n; v++){
			if(M[u][v] == 0) continue;
			if(d[v] != INFTY) continue;
			d[v] = d[u] + 1;
			q.push(v);
		}
	}
	for(int i = 0; i < n; i++){
		cout << i + 1 << " " << ((d[i] == INFTY) ? (-1) : d[i]) << endl;
	}
}

int main() {
	int u, k, v;

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

	for(int i = 0; i < n; i++){
		cin >> u >> k;
		u--;
		for(int j = 0; j < k; j++){
			cin >> v;
			v--;
			M[u][v] = 1;
		}
	}

	bfs(0);
	
	return 0; 
}


Measured memory_bytes: 3124
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#include<map>
#include<iomanip>
#include<queue>
#include<stack>
#include<time.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<=n;i++)
#define ggr getchar();getchar();return 0;
#define prique priority_queue
constexpr auto mod = 1000000007;
#define inf 1e15
#define key 1e9
using namespace std;
typedef pair<int, int>P;
template<class T> inline void chmax(T& a, T b) {
	a = std::max(a, b);
}
template<class T> inline void chmin(T& a, T b) {
	a = std::min(a, b);
}
//combination(Nが小さい時はこれを使う)
const int MAX = 330000;
int fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % mod;
		inv[i] = mod - inv[mod % i] * (mod / i) % mod;
		finv[i] = finv[i - 1] * inv[i] % mod;
	}
}
int COMB(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
}

bool prime(int n) {
	int cnt = 0;
	for (int i = 1; i <= sqrt(n); i++) {
		if (n % i == 0)cnt++;
	}
	if (cnt != 1)return false;
	else return n != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x / gcd(x, y) * y;
}

//繰り返し二乗法（Nが大きい時の場合のcombination)
int mod_pow(int x, int y, int m) {
	int res = 1;
	while (y) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}
int kai(int x, int y) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= (i % mod); res %= mod;
	}
	return res;
}
int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x, y) * mod_pow(kai(y, y), mod - 2, mod) % mod;
}
//UnionFind
class UnionFind {
protected:
	int* par, * rank, * size;
public:
	UnionFind(unsigned int size) {
		par = new int[size];
		rank = new int[size];
		this->size = new int[size];
		rep(i, size) {
			par[i] = i;
			rank[i] = 0;
			this->size[i] = 1;
		}
	}
	int find(int n) {
		if (par[n] == n)return n;
		return par[n] = find(par[n]);
	}
	void unite(int n, int m) {
		n = find(n);
		m = find(m);
		if (n == m)return;
		if (rank[n] < rank[m]) {
			par[n] = m;
			size[m] += size[n];
		}
		else {
			par[m] = n;
			size[n] += size[m];
			if (rank[n] == rank[m])rank[n]++;
		}
	}
	bool same(int n, int m) {
		return find(n) == find(m);
	}
	int getsize(int n) {
		return size[find(n)];
	}
};
int dight_sum(int n) {
	int sum = 0;
	rep(i, 20)sum += (n % (int)pow(10, i + 1)) / (pow(10, i));
	return sum;
}
int n;
int x[114], y[114], h[114];
signed main() {
	cin >> n;
	rep(i, n)cin >> x[i] >> y[i] >> h[i];
	for (int i = 0; i <= 100; i++) {
		for (int j = 0; j <= 100; j++) {
			int hi;
			rep(k, n) {
				if (h[k] != 0) {
					hi = h[k] + abs(x[k] - i) + abs(y[k] - j);
					break;
				}
			}
			int cnt = 0;
			rep(k, n) {
				int p = abs(i - x[k]), q = abs(j - y[k]);
				if (max(hi - p - q, (int)0) == h[k])cnt++;
			}
			if (cnt == n) {
				cout << i << " " << j << " " << hi << endl;
				ggr
			}
		}
	}
	ggr
}

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

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<string> vs;
typedef pair<int, int> P;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()

void YN(bool flg){if(flg) cout << "YES" << endl; else cout << "NO" << endl;}
void Yn(bool flg){if(flg) cout << "Yes" << endl; else cout << "No" << endl;}
void yn(bool flg){if(flg) cout << "yes" << endl; else cout << "no" << endl;}

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

int MAX = 1000010;

int main()
{   
    int n;
    cin >> n;
    vi a(n);
    rep(i, n) cin >> a[i];

    vi b(MAX);
    for(auto x : a) {
        if(b[x] >= 2) continue;
        for(int i=x; i < MAX; i+=x) b[i]++;
    }

    int ans = 0;
    for(auto x : a) {
        if(b[x]-1==0) ans++;
    }

    cout << ans << endl;

    return 0;
}


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

int main(){
  int N;
  cin >> N;
  map<char,int64_t> m;
  string name="MARCH";
  for(int i=0;i<name.size();i++){
    m[name.at(i)]=0;
  }
  int64_t ans=0;
  for(int i=0;i<N;i++){
    string S;
    cin >> S;
    if(m.count(S.at(0))){
      m.at(S.at(0))++;
    }
  }
  for(int i=0;i<name.size();i++){
    for(int j=i+1;j<name.size();j++){
      for(int k=j+1;k<name.size();k++){
        ans+=m.at(name.at(i))*m.at(name.at(j))*m.at(name.at(k));
      }
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
from collections import Counter

n, p = map(int, input().split(" "))
s = list(map(int, input()))

ans = 0
if 10 % p == 0: # p = 2, 5
    for i, num in enumerate(s, 1):
        if num % p == 0:
            ans += i
    print(ans)
    exit()

s = s[::-1]
power = 1
t = [0] * len(s)
t[0] = s[0] % p
for i in range(1, len(s)):
    power = power * 10 % p
    t[i] = (t[i-1] + s[i] * power) % p

counter = Counter(t)
for i in counter.values():
    ans += i * (i-1) // 2
ans += counter[0]
print(ans)

# count = [0] * p
# count[0] = 1
# for i in t:
#     ans += count[i]
#     count[i] += 1
# print(ans)


Measured memory_bytes: 13308
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <utility>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <queue>
#include <map>
using namespace std;
typedef long long ll;
const int INF = 1<<30; 
const int MOD = 1e9 + 7;
const int dy[] = {1, 0, -1, 0};
const int dx[] = {0, 1, 0, -1};
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    int h[n + 1];
    for(int i = 0; i < n; i++) cin >> h[i];
    ll cost[n + 1] = {};
    for(int i = 1; i <= n; i++) cost[i] = INF;
    for(int step = 0; step < n; step++)
    {
        cost[step + 1] = min(cost[step] + abs(h[step] - h[step + 1]), cost[step + 1]);
        cost[step + 2] = min(cost[step] + abs(h[step] - h[step + 2]), cost[step + 2]);
    }
    cout << cost[n - 1] << endl;
    return 0;
}



Measured memory_bytes: 1408
#include<stdio.h>
#define MAX 100000

int parent(int i){
  return i/2;
}

int left(int i){
  return 2*i;
}

int right(int i){
  return 2*i+1;
}

int main(){
  int H,i,A[MAX+1];

  scanf("%d",&H);
  for(i=1;i<=H;i++){
    scanf("%d",&A[i]);
  }

  for(i=1;i<=H;i++){
    printf("node %d: key = %d, ",i,A[i]); 
    if(parent(i) >= 1)
      printf("parent key = %d, ",A[parent(i)]);
    if(left(i) <= H )
      printf("left key = %d, ",A[left(i)]);
    if(right(i) <= H)
      printf("right key = %d, ",A[right(i)]);
    printf("\n");
  }

  return 0;
}



Measured memory_bytes: 2048
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author champon
 */

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define inf 1e18
#define ceill(a, b) (a+b-1)/b
#define ok cout << "ok" << endl;
#define sp << " " <<
ll mod = 1e9+7;
void ans(bool b, ostream& out=cout){ out << (b ? "Yes" : "No") << endl; }
void ans2(bool b, ostream& out=cout){ out << (b ? "YES" : "NO") << endl; }
template<typename T> inline bool chmax(T &a, T b){ if(a<b) a=b; return a<b; }
template<typename T> inline bool chmin(T &a, T b){ if(b<a) a=b; return b<a; }
template<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val){fill((T*)array, (T*)(array+N), val);}
int dx[] = {1, 0, -1, 0, 1, -1, 1, -1};
int dy[] = {0, 1, 0, -1, 1, -1, -1, 1};

#ifndef INCLUDE_DEBUG_HPP
#define INCLUDE_DEBUG_HPP

class debug
{
public:
    template<typename T> void vdeb(T vec);
    template<typename T1, typename T2> void adeb(T1 *arr, T2 n);
    template<typename T> void mdeb(T mp);
};

#endif //INCLUDE_DEBUG_HPP

template<typename T> void debug::vdeb(T vec)
{
    cout << "#vector set debug" << endl;
    for(auto vv : vec) cout << vv << " ";
    cout << endl;
}

template<typename T1, typename T2> void debug::adeb(T1 *arr, T2 n)
{
    cout << "#adebug" << endl;
    for(int i=0; i<=n; i++) cout << arr[i] << " ";
    cout << endl;
}

template<typename T> void debug::mdeb(T mp)
{
    cout << "#map pair debug" << endl;
    for(auto const& m : mp) cout << m.first sp m.second << endl;
}
debug dbg;

bool comp(pair<int, int> const& p1, pair<int, int> const& p2){
    if(p1.first == p2.first) return p1.second > p2.second;
    else return p1.first < p2.first;
}

bool comp2(pair<int, int> const& p1, pair<int, int> const& p2){
    if(p1.first == p2.first) return p1.second < p2.second;
    else return p1.first > p2.first;
}

ll dp[10010];

class ECrestedIbisVsMonster {
public:
	void solve(std::istream& in, std::ostream& out)
	{
	    int h, n;
	    in >> h >> n;
	    vector<int> a(n), b(n);
	    for(int i=0; i<n; i++){
	        in >> a[i] >> b[i];
	    }

	    ll dp[20010];
	    Fill(dp, inf);
	    dp[0] = 0;

	    for(int i=0; i<=h; i++){
	        for(int j=0; j<n; j++) {
                if(i + a[j] >= h) dp[h] = min(dp[h], dp[i] + b[j]);
                else dp[i+a[j]] = min(dp[i+a[j]], dp[i] + b[j]);
            }
	    }

	    out << dp[h] << endl;
	}
};


int main() {
	ECrestedIbisVsMonster solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
#include <complex>
using namespace std;

using ll = long long;
using ull = uint64_t;
using P = pair<int, int>;
constexpr double EPS = 1e-9;
constexpr int INF = 1001001001;
// constexpr int mod = 1000000007;
constexpr int mod = 998244353;

template<class T>
inline bool chmax(T& x, T y){
    if(x < y){
        x = y;
        return true;
    }
    return false;
}
template<class T>
inline bool chmin(T& x, T y){
    if(x > y){
        x = y;
        return true;
    }
    return false;
}

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

    int n;
    cin >> n;
    vector<int> a(n);
    for(int i = 0; i < n; ++i)  cin >> a[i];
    int MaxIdx = max_element(a.begin(), a.end()) - a.begin();
    int MinIdx = min_element(a.begin(), a.end()) - a.begin();
    vector<P> ans;
    if(a[MaxIdx] >= abs(a[MinIdx])){
        for(int i = 0; i < n; ++i){
            if(i == MaxIdx) continue;
            ans.emplace_back(MaxIdx, i);
        }
        for(int i = 0; i + 1 < n; ++i){
            ans.emplace_back(i, i + 1);
        }
    }
    else{
        for(int i = 0; i < n; ++i){
            if(i == MinIdx) continue;
            ans.emplace_back(MinIdx, i);
        }
        for(int i = n - 1; i - 1 >= 0; --i){
            ans.emplace_back(i, i - 1);
        }
    }
    cout << ans.size() << '\n';
    for(auto p : ans)   cout << p.first + 1 << ' ' << p.second + 1 << '\n';
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
#define rep(i, z, n) for(int i = z; i < n; i++)
#define repB(i, z, n) for(int i = n - 1; i >= z; i--)
#define all(v) v.begin(), v.end()
typedef long long ll;
#define PI 3.14159265358979
//const int64_t INF = 1LL << 60;
const int INF = 1 << 29;
const int64_t MOD = 1000000007;
//const int64_t INF = 998244353;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using namespace std;
//#define P pair<int, int>
typedef pair<int, int> P;

int main(){
    int64_t N;
    cin >> N;
    vector<int64_t> A(N);
    rep(i, 0, N){
        cin >> A.at(i);
    }
    rep(i, 0, N){
        if(A.at(i) == 0){
            cout << 0 << endl;
            return 0;
        }
    }
    int64_t ans = 1;
    rep(i, 0, N){
        if ((ans + int64_t(pow(10, 18))) / ans <= A.at(i)){
            cout << - 1 << endl;
            return 0;
        }
        else{
            ans *= A.at(i);
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 4048
#include<cstdio>
#include<cmath>
#include<string>
#include<iostream>
#include<algorithm>
#include<utility>
#include<vector>
#include<map>
#include<set>
#include<limits>
#include<bitset>
#include<array>
#include<numeric>
#include<iomanip>
#include<functional>
#include<deque>

using namespace std;
typedef long long int ll;

#define C cout<<
#define E <<endl

#define SIZ 200010
#define VCN 200010

int n,t,w[SIZ],v[SIZ];

vector<vector<ll>> dp;

vector<vector<ll>> v2vec(int x,int y,int value=0){ return vector<vector<ll>>(y,vector<ll>(x,value)); }

int main(){
    cin>>n>>t;
    for(int i=0;i<n;i++){
        cin>>w[i]>>v[i];
    }
    
    int xsiz=VCN;
    int ysiz=n;
    
    ll m=0;
    
    bool debug=0;
    
    dp=v2vec(xsiz+1,ysiz+1,-1);
    dp[0][0]=0;
    for(int y=0;y<ysiz;y++){
        for(int x=0;x<xsiz+1;x++){
            if(dp[y][x]==-1)continue;
            dp[y+1][x]=dp[y+1][x]==-1 ? dp[y][x]:min(dp[y+1][x],dp[y][x]);
            if(x+v[y]<=VCN and dp[y][x]+w[y]<=t){
                dp[y+1][x+v[y]]=dp[y+1][x+v[y]]==-1 ? dp[y][x]+w[y]:min(dp[y+1][x+v[y]],dp[y][x]+w[y]);
            }
        }
    }
    
    for(int i=0;i<dp[ysiz].size();i++){
        if(dp[ysiz][i]!=-1 and m<i)m=i;
    }
    //C dp[ysiz][xsiz] E;
    
    C m E;
    
    if(debug){
        for(int y=0;y<ysiz+1;y++){
            for(int x=0;x<xsiz+1;x++){
                C dp[y][x]<<" ";
            }
            C "" E;
        }
    }
}

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

int main(){
    int n,m;
    while(scanf("%d%d",&n,&m)==2){
        int M=m*m,N=n*n;
        char a[n+3][n+3],b[m+3][m+3],A[M+3],B[N+3];
        int i,j,k,l;
        getchar();

        for(i=0,k=0;i<n;i++){
            for(j=0;j<n;j++)
                scanf("%c",&a[i][j]);
            getchar();
        }

        for(i=0,k=0;i<m;i++){
            for(j=0;j<m;j++)
                scanf("%c",&b[i][j]);
            getchar();
        }

        for(i=0;i<n;i++){
            for(j=0;j<n;j++){
                if(i+m-1>=n || j+m-1>=n) continue;
                if(a[i][j]==b[0][0]){
                    for(k=0;k<m;k++){
                        for(l=0;l<m;l++){
                            if(a[i+k][j+l]!=b[k][l])
                                break;
                        }
                        if(l!=m) break;
                    }
                }
                if(k==m)
                    break;
            }
            if(k==m)
                break;
        }

        if(k!=m) printf("No\n");
        else printf("Yes\n");
    }
    return 0;
}


Measured memory_bytes: 256
/*.....Bismillahir Rahmanir Rahim.....*/
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <cstring>
#include <unordered_map>
#include <queue>
#define   mod  998244353
#define   int  long long 
#define   ld long double
#define   pb push_back
#define  sz(x)  (int)x.size()
#define  ff first
#define  ss second
#define  pii  pair<int,int>
using namespace std;

inline void solve(){ 
	int  n,s=0;
	cin >> n ;
	for (int i=1;i<=n;i++) 
		if (i%3 != 0 && i%5 !=0) s += i;
	cout << s << endl ;
}

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


Measured memory_bytes: 3632
use std::io::{stdin, Read, StdinLock};
use std::str::FromStr;

#[allow(dead_code)]
struct Scanner<'a> {
    cin: StdinLock<'a>,
}
#[allow(dead_code)]
impl<'a> Scanner<'a> {
    fn new(cin: StdinLock<'a>) -> Scanner<'a> {
        Scanner { cin: cin }
    }

    fn read<T: FromStr>(&mut self) -> Option<T> {
        let token = self.cin.by_ref().bytes().map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>();
        token.parse::<T>().ok()
    }

    fn input<T: FromStr>(&mut self) -> T {
        self.read().unwrap()
    }

    fn vec<T: FromStr>(&mut self, len: usize) -> Vec<T> {
        (0..len).map(|_| self.input()).collect()
    }

    fn mat<T: FromStr>(&mut self, row: usize, col: usize) -> Vec<Vec<T>> {
        (0..row).map(|_| self.vec(col)).collect()
    }
}

use std::collections::BTreeMap;
fn main() {
    let cin = stdin();
    let cin = cin.lock();
    let mut sc = Scanner::new(cin);

    let n: usize = sc.input();
    let arr: Vec<usize> = sc.vec(n - 1);

    let mut map = BTreeMap::new();
    for i in 1..=n {
        map.entry(i).or_insert(0);
    }
    for x in arr {
        map.entry(x).and_modify(|x| *x += 1).or_insert(1);
    }

    for x in map.values() {
        println!("{}", x);
    }
}


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

using namespace std;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, i = 0,j=-1;
    string str;
    cin >> str;
    N = str.length();
    for(;i<=N/2 && j!=N-i;++i)for(j=i;j<N-i-1&&str[j]==str[j+1];++j){}
    cout << N+1-i << "\n";
    return 0;
}


Measured memory_bytes: 512
#include<iostream>
using namespace std;
int main()
{
    int n,x,s=0;
    cin>>n;
    while(n!=0)
    {
       x=n%10;
       if(x==7)
       {
          s++;
          break;
       }  
       n/=10;     
    }
    if(s>0)
    {
        cout<<"Yes\n";
    }
    else
    {
        cout<<"No\n";
    }
    return 0;
}

Measured memory_bytes: 3552
#include<stdio.h>
int main(void){
	int x,a[2];
	scanf("%d %d %d",&a[0],&a[1],&a[2]);
	if(a[0]>a[1]){
		x=a[0];
		a[0]=a[1];
		a[1]=x;
	}
	if(a[1]>a[2]){
		x=a[1];
		a[1]=a[2];
		a[2]=x;
	}
	if(a[0]>a[1]){
		x=a[0];
		a[0]=a[1];
		a[1]=x;
	}
printf("%d %d %d\n",a[0],a[1],a[2]);
return 0;
}

Measured memory_bytes: 596
#include <iostream>
#include <math.h>

using namespace std;

int n;
double rad[502], c[502], d[502], dsum[502], ans=0;

double calcD(int i, int j){
	if (rad[i]==rad[j]){
		return rad[i]*2;
	}else if (i==0){
		return rad[j];
	}else{
		return sqrt((rad[i]+rad[j])*(rad[i]+rad[j])-(rad[i]-rad[j])*(rad[i]-rad[j]));
	}
}

int main(){
	cin >> n;
	
	rad[0] = 0;
	for (int i=1; i<=n; i++){
		cin >> rad[i];
	}
	
	c[0] = 0;
	c[1] = rad[1];
	
	for (int i=2; i<=n; i++){
		for (int j=0; j<i; j++){
			c[i] = max(c[i], calcD(j, i)+c[j]);
		}
	}
	
	for (int i=1; i<=n; i++){
		// printf("c[%d] = %f\n", i, c[i] );
		ans = max(ans, c[i] + rad[i]);
	}
	
	printf("%.8f\n", ans);
	
	return 0;
}


Measured memory_bytes: 3284
#include "bits/stdc++.h"
using namespace std;
#define Would
#define you
const long long INF = 1e18;
const long long MOD = 1e9 + 7;
const double pi = acos(-1);
const int SIZE = 1 << 17;
int dx[] = { 1,0,-1,0 }, dy[] = { 0,1,0,-1 }, alp[30];
long long fac[100005], finv[100005], inv[100005];

int main() {
	int a, b;
	char k[575][575];
	cin >> a >> b;
	for (int i = 0; i < a; ++i) {
		for (int j = 0; j < b; ++j) {
			cin >> k[i][j];
		}
	}
	for (int i = 0; i < a; ++i) {
		for (int j = 0; j < b; ++j) {
			char out = '.';
			if (j == 0 || (i % 2 == 1 && j != b - 1) || k[i][j] == '#') { out = '#'; }
			cout << out;
		}
		cout << endl;
	}
	cout << endl;

	for (int i = 0; i < a; ++i) {
		for (int j = 0; j < b; ++j) {
			char out = '.';
			if (j == b - 1 || (i % 2 == 0 && j != 0) || k[i][j] == '#') { out = '#'; }
			cout << out;
		}
		cout << endl;
	}
}

Measured memory_bytes: 1024