akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cctype>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <functional>
using namespace std; 
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define FORD(i,a,b) for(int i=(a);i>=(b);i--)
inline bool EQ(double a, double b) { return fabs(a-b) < 1e-9; }
const int INF = 1<<29;
typedef long long ll;
inline int two(int n) { return 1 << n; }
inline int test(int n, int b) { return (n>>b)&1; }
inline void set_bit(int & n, int b) { n |= two(b); }
inline void unset_bit(int & n, int b) { n &= ~two(b); }
inline int last_bit(int n) { return n & (-n); }
inline int ones(int n) { int res = 0; while(n && ++res) n-=n&(-n); return res; }
template<class T> void chmax(T & a, const T & b) { a = max(a, b); }
template<class T> void chmin(T & a, const T & b) { a = min(a, b); }
/////////////////////////////////////////////////////////////////////
int main()
{int n ,k;
	cin>>n>>k;
	vector <int> s(n);
	for(auto &i : s)
		cin>>i;
	vector <bool> dp(k+1);
	for(int stone = 0;stone<=k;stone++)
		for(auto e:s)
			if((stone>=e)&&!dp[stone-e])
				dp[stone] = true;
	puts(dp[k]?"First":"Second");
    return 0;
}

Measured memory_bytes: 3596
#include<bits/stdc++.h>
using namespace std;
long MOD=1e9+7,n,k,ans=1,l,r,flg=1,a[1<<18],x,y;
int main(){
  cin>>n>>k;
  r=n-1;
  for(int i=0;i<n;i++)cin>>a[i];
  sort(a,a+n);
  if(k%2)ans=a[r],r--,k--,flg=(ans<0?-1:1);
  while(k){
    x=a[l]*a[l+1],y=a[r]*a[r-1];
    if(x*flg>y*flg)ans*=x%MOD,ans%=MOD,l+=2;
    else ans*=y%MOD,ans%=MOD,r-=2;
    k-=2;
  }
  cout<<(ans+MOD)%MOD<<endl;
}


Measured memory_bytes: 5196
n,m=map(int,input().split())
g = [[] for _ in range(n)]

for _ in range(m):
    a, b = map(int,input().split())
    g[a-1].append(b-1)
    g[b-1].append(a-1)

from collections import deque

d = [None] * n
def bfs(u):
    queue = deque([u])
    d[u] = 0
    while queue:
        v = queue.popleft()
        for i in g[v]:
            if d[i] is None:
                d[i] = d[v] + 1
                queue.append(i)
cnt=0
for i in range(n):
    if d[i] is None:
        cnt+=1
        bfs(i)
print(cnt-1)

Measured memory_bytes: 26592
D, N = [int(x) for x in raw_input().split()]
if D==0:
  if N<100:
    print N
  else:
    print 101
elif D==1:
  if N<100:
    print N*100
  else:
    print 10100
else:
  if N<100:
    print N*10000
  else:
    print 1010000

Measured memory_bytes: 2568
import copy
import sys
import math

def main():
	n = int(input())
	k = int(input())
	s = str(n)
	if(k == 1):
		print(s[0])
		sys.exit()
	for i in s[:k]:
		if(i!='1'):
			print(i)
			sys.exit()
	print(1)


def listtodict(a):
	b = {}
	for i in a:
		try:
			b[i] += 1
		except:
			b[i] = 1
	return b

def base_10_to_n(X, n):
	X_dumy = X
	out = ''
	while X_dumy>0:
		out = str(X_dumy%n)+out
		X_dumy = int(X_dumy/n)
	if(out == ''): return '0'
	return out

main()

Measured memory_bytes: 38384
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update

using namespace std;
using namespace __gnu_pbds;

typedef tree<long long, int, less<long long>, rb_tree_tag, tree_order_statistics_node_update> ordered_map;

const int MAXN = 100005;

int n, a, b, cnt[MAXN];
long long d, x[MAXN], y[MAXN];
bool visited[MAXN];
map<long long, ordered_map> posX, posY;

int count(ordered_map &m, long long lo, long long hi) {
    return m.order_of_key(hi + 1) - m.order_of_key(lo);
}

int popFirst(ordered_map &m, long long lo, long long hi) {
    auto it = m.lower_bound(lo);
    if (it == m.end() || it->first > hi)
        return -1;
    int id = it->second;
    m.erase(it);
    return id;
}

int main() {
    cin >> n >> a >> b;
    for(int u = 1; u <= n; ++u) {
        cin >> x[u] >> y[u];
        // x = x + y; y = x - y
        x[u] = x[u] + y[u];
        y[u] = x[u] - 2 * y[u];
    }
    d = max(abs(x[a] - x[b]), abs(y[a] - y[b]));

//    for(int u = 1; u <= n; ++u)
//        printf("%d %d\n", x[u], y[u]);

    for(int u = 1; u <= n; ++u) {
        posX[x[u]][y[u]] = u;
        posY[y[u]][x[u]] = u;
    }

    for(int u = 1; u <= n; ++u) {
        cnt[u] = count(posX[x[u] - d], y[u] - d, y[u] + d);
        cnt[u] += count(posX[x[u] + d], y[u] - d, y[u] + d);
        cnt[u] += count(posY[y[u] - d], x[u] - d + 1, x[u] + d - 1);
        cnt[u] += count(posY[y[u] + d], x[u] - d + 1, x[u] + d - 1);
    }

    queue<int> q;
    q.push(a); visited[a] = true;
    q.push(b); visited[b] = true;

    while (!q.empty()) {
        int u = q.front(); q.pop();

        vector<int> toAdd;
        int v;
        while ((v = popFirst(posX[x[u] - d], y[u] - d, y[u] + d)) != -1)
            toAdd.push_back(v);
        while ((v = popFirst(posX[x[u] + d], y[u] - d, y[u] + d)) != -1)
            toAdd.push_back(v);
        while ((v = popFirst(posY[y[u] - d], x[u] - d, x[u] + d)) != -1)
            toAdd.push_back(v);
        while ((v = popFirst(posY[y[u] + d], x[u] - d, x[u] + d)) != -1)
            toAdd.push_back(v);

        for(v: toAdd) {
            if (!visited[v]) {
                visited[v] = true;
                q.push(v);
            }
        }
    }

    long long ans = 0;
    for(int u = 1; u <= n; ++u)
        if (visited[u])
            ans += cnt[u];
    ans /= 2;

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 67200
//#include <bits/stdc++.h>
#include<iostream>
#include<string>
#include<queue>
#include<vector>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)//初期値a,i<bの範囲でループ
#define REP(i,n) FOR(i,0,n)//初期値0,i<nの範囲でループ
using namespace std;
typedef long long ll;//int64
typedef unsigned long long ull;

int q;
int l[100010],r[100010];

int c[100010];
int f[100010];
int n[100010];
int main(){

    cin>>q;
    REP(i,q)cin>>l[i]>>r[i];

    FOR(i,2,100001)f[i]=1;
    for(int i=2;i*i<=100000;i++){
        for(int j=i*i;j<=100000;j+=i){
            f[j]=0;
        }
    }
    for(int i=2;i<=100000;i++){
        if(f[i]&&f[(i+1)/2])n[i]=1;
    }

    REP(i,100001){
        c[i+1]=c[i]+n[i+1];
    }

    REP(i,q){
        cout<<(c[r[i]]-c[l[i]-1])<<endl;
    }

    

    

    return 0;
}

Measured memory_bytes: 2560
n = gets.to_i
xs = gets.split.map(&:to_i).sort
if n == 2
  puts "#{xs[1]} #{xs[0]}"
else
a = xs[-1]
ys = xs.map{|x|[(a/2.0-x).abs, x]}.sort_by{|item|item[0]}.map{|item|item[1]}
puts "#{a} #{ys[0]}"
end


Measured memory_bytes: 17392
import java.awt.geom.Point2D;
import java.lang.Character.Subset;
import java.util.*;

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

	class AOJ0109{
		char[] line;
		int pos;

		int exp(){
			int r = term();
			while(true){
				char c = line[pos++];
				if(c=='+')r+=term();
				else if(c=='-')r-=term();
				else break;
			}
			return r;
		}

		int term(){
			int r = fact();
			while(true){
				char c = line[pos++];
				if(c=='*') r*=fact();
				else if(c=='/')r/=fact();
				else break;
			}
			pos--;
			return r;
		}

		int fact(){
			char c = line[pos++];
			if(c=='(')return exp();
			if(c=='-')return -fact();
			if(c=='+')return fact();
			int x = c-'0';
			while(true){
				c = line[pos++];
				if(Character.isDigit(c)){
					x *= 10;
					x += c-'0';
				}
				else break;
			}
			pos--;
			return x;
		}
		void doIt(){
			String a = in.next();
			line = a.toCharArray();
			pos = 0;
			System.out.println(exp());
		}

		public AOJ0109() {
			int n = in.nextInt();
			while(n--!=0)doIt();
		}
	}
}

Measured memory_bytes: 17176
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define MOD 1000000007
#define all(ppp) ppp.begin(),ppp.end()
#define out(ppp) cout<<(ppp)<<endl
#define out1(ppp) cout<<(ppp) 

#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
#define pb push_back

typedef long double ld;
typedef complex<ld> cd;
 
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
 
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<vi> vvi;
typedef vector<bool> vb;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;
typedef vector<vpi> vvpi;

typedef set<pi> spi;

const int INF=INT_MAX;




int main(){
    int N;
    cin>>N;
    vi P(N);
    F0R(i,N) cin>>P[i];

    ll count=1;
    int mini=P[0];
    FOR(i,1,N){
        if(P[i]<mini){
            mini=P[i];
            count++;
        }
    } 
    out(count);
    return 0;
}


Measured memory_bytes: 1024
n = int(input())
a = list(map(int, input().split()))

migi = [0 for i in range(n)]
hidari = [0 for i in range(n)]
for i in range(n):
    idx = i+a[i]
    if idx < n:
        migi[idx] += 1
    idx = i-a[i]
    if idx >= 0:
        hidari[idx] += 1
ans = 0
for i in range(n):
    ans += migi[i] * hidari[i]

print(ans)

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

int main()
{
     int m, f, r, sum;
     while(1) 
     {
          cin >> m >> f >> r;
            if ( m == (-1) && f == (-1) && r == (-1) )break;
           else{
                            sum = m + f;
                            if ( m != (-1) && f != (-1) && sum >= 80)cout << "A";
                            if ( m == (-1) || f == (-1) )cout << "F";
                           else if ( m != (-1) && f != (-1) && sum >= 65 && sum < 80)cout << "B";
                            else if ( m != (-1) && f != (-1) && sum >= 50 && sum < 65)cout << "C";
                            else if ( m != (-1) && f != (-1) && sum >= 30 && sum < 50 && r >= 50 )cout << "C";
                            else if ( m != (-1) && f != (-1) && sum >= 30 && sum < 50 && r <= 50 )cout << "D";
                            else if ( m != (-1) && f != (-1) && sum < 30)cout << "F";
                  }
            cout << endl;
     }
return 0;
}

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

N = int(input().split()[0])

if N % 2 == 0:
    total_n = 0
    count = 1
    while True:
        p = (N // 2) // (5 ** count)
        total_n += p
        count += 1
        if p <= 0:
            break
    ans = total_n
else:
    ans = 0

print(ans)


Measured memory_bytes: 2940
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;
using static System.Math;
using static System.Array;

class Program
{
    public static void Main()
    {
        var n = int.Parse(ReadLine());
        var s = ReadLine();
        int[] m = new int[n + 1];
        for(int i = 1; i <= n; i++)
        {
            int temp = 0;
            if(s[i - 1] == 'I')
                temp = 1;
            else
                temp = -1;
            m[i] = m[i - 1] + temp;
        }
        WriteLine(m.Max());
    }
}


Measured memory_bytes: 18592
#include<iostream>
#include<algorithm>
#include<stack>
#include<vector>
#include<queue>
#include<cstring>
#include<cmath>
#include<cstdio>
using namespace std;
int main(){
    unsigned long long A,C;
double B;
cin>>A>>B;
C=B*1000;
C=C*A/1000;
cout<<C<<endl;
return 0;
}


Measured memory_bytes: 3692
#include <bits/stdc++.h>
#define ll long long
#define pq priority_queue
using namespace std;
const ll INF=(ll)1e9;
const ll MOD=(ll)1e9+7;
const ll MAX=100100;
vector<int> dx={1,0,-1,0},dy={0,1,0,-1};
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 main(){
    ll N,X,Y;
    cin>>N>>X>>Y;
    vector<vector<ll>> v(N,vector<ll> (N));
    vector<ll> ans(N,0);
    for(ll i=0;i<N;i++){
        for(ll j=0;j<N;j++) v[i][j]=abs(i-j);
    }
    
    v[X-1][Y-1]=1;
    v[Y-1][X-1]=1;
    
    for(ll i=0;i<N;i++){
        for(ll j=0;j<N;j++){
            v[i][j]=min(v[i][j],abs(X-i-1)+abs(Y-j-1)+1);
        }
    }
    
    for(ll i=0;i<N;i++){
        for(ll j=i+1;j<N;j++){
            ans[v[i][j]]++;
        }
    }
    for(ll i=1;i<N;i++) cout<<ans[i]<<endl;
}


Measured memory_bytes: 31616
#include<iostream>

int main(void){
	int a, b;
	
	std::cin >> a >> b;
	
	if (a < b) std::cout << "a < b" << std::endl;
	else if (a > b) std::cout << "a > b" << std::endl;
	else std::cout << "a == b" << std::endl;
	
	return 0;
}

Measured memory_bytes: 1156
#include<cstdio>
#include<algorithm>
#include<cmath>
#define fo(i,a,b) for(i=a;i<=b;i++)
#define fd(i,a,b) for(i=a;i>=b;i--)
using namespace std;
typedef long long ll;
typedef double db;
const int maxn=200000+10,maxlen=maxn*4,mo=924844033,GG=5;
int size[maxn],h[maxn],go[maxn*2],nxt[maxn*2];
int w[maxlen],a[maxlen],b[maxlen],tt[maxlen],c[maxlen],rev[maxlen],fac[maxn],inv[maxn];
int i,j,k,l,t,n,m,tot,len,ans,ni;
db ce;
void add(int x,int y){
    go[++tot]=y;
    nxt[tot]=h[x];
    h[x]=tot;
}
int qsm(int x,int y){
    if (!y) return 1;
    int t=qsm(x,y/2);
    t=(ll)t*t%mo;
    if (y%2) t=(ll)t*x%mo;
    return t;
}
void dfs(int x,int y){
    a[n]++;
    int t=h[x];
    size[x]=1;
    while (t){
        if (go[t]!=y){
            dfs(go[t],x);
            a[size[go[t]]]--;
            size[x]+=size[go[t]];
        }
        t=nxt[t];
    }
    a[n-size[x]]--;
}
void prepare(){
    w[0]=1;
    w[1]=qsm(GG,(mo-1)/len);
    fo(i,2,len) w[i]=(ll)w[i-1]*w[1]%mo;
    fo(i,0,len-1){
        int p=0;
        for(int j=0,tp=i;j<ce;j++,tp/=2) p=(p<<1)+(tp%2);
        rev[i]=p;
    }
    ni=qsm(len,mo-2);
}
void DFT(int *a,int sig){
    int i;
    fo(i,0,len-1) tt[rev[i]]=a[i];
    for(int m=2;m<=len;m*=2){
        int half=m/2,bei=len/m;
        fo(i,0,half-1){
            int wi=sig>0?w[i*bei]:w[len-i*bei];
            for(int j=i;j<len;j+=m){
                int u=tt[j],v=(ll)tt[j+half]*wi%mo;
                tt[j]=(u+v)%mo;
                tt[j+half]=(u-v)%mo;
            }
        }
    }
    if (sig==-1)
        fo(i,0,len-1) tt[i]=(ll)tt[i]*ni%mo;
    fo(i,0,len-1) a[i]=tt[i];
}
void NTT(){
    DFT(a,1);DFT(b,1);
    fo(i,0,len-1) a[i]=(ll)a[i]*b[i]%mo;
    DFT(a,-1);
    fo(i,0,len-1) c[i]=a[i];
}
int main(){
    scanf("%d",&n);
    fo(i,1,n-1){
        scanf("%d%d",&j,&k);
        add(j,k);add(k,j);
    }
    dfs(1,0);
    fac[0]=1;
    fo(i,1,n) fac[i]=(ll)fac[i-1]*i%mo;
    inv[n]=qsm(fac[n],mo-2);
    fd(i,n-1,0) inv[i]=(ll)inv[i+1]*(i+1)%mo;
    fo(i,0,n) a[i]=(ll)a[i]*fac[i]%mo;
    fo(i,0,n) b[i]=inv[i];
    reverse(b,b+n+1);
    len=1;
    while (len<=2*n) len*=2;
    ce=log(len)/log(2);
    prepare();
    NTT();
    fo(i,1,n){
        ans=(ll)inv[i]*c[n+i]%mo;
        (ans+=mo)%=mo;
        printf("%d\n",ans);
    }
}

Measured memory_bytes: 35072
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define ll long long
#define endl '\n'
using namespace std;
const int N = 1e5 + 5;

int n, m, a[N], label[N], label2[N];
ll k;
ll x[N], d[N], ans[N];

vector <vector <int> > cycles;
bool vis[N];
void DFS(int v)
{
    cycles.back().pb(v);
    vis[v] = true;
    if(vis[label[v]])
        return;
    DFS(label[v]);
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);

    cin >> n;
    for(int i = 1; i <= n; i++)
    {
        cin >> x[i];
        d[i] = x[i] - x[i - 1];
        label[i] = i;
    }

    cin >> m >> k;
    for(int i = 1; i <= m; i++)
    {
        cin >> a[i];
        swap(label[a[i]], label[a[i] + 1]);
    }
    for(int i = 1; i <= n; i++)
    {
        if(!vis[i])
        {
            cycles.pb(vector <int> ());
            DFS(i);
        }
    }

    for(int i = 0; i < cycles.size(); i++)
    {
        int sz = k % (int)cycles[i].size();
        for(int j = 0; j < cycles[i].size(); j++)
            label2[cycles[i][(j + sz) % cycles[i].size()]] = cycles[i][j];
    }

    for(int i = 1; i <= n; i++)
        ans[label2[i]] = d[i];

    for(int i = 1; i <= n; i++)
        ans[i] = ans[i] + ans[i - 1];

    for(int i = 1; i <= n; i++)
        cout << fixed << setprecision(9) << ans[i] << endl;

    return 0;
}


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

using namespace std;

int main() {
  int n;
  cin >> n;
  vector< pair<int,int> > ans;

  if (n & 1) {
    for (int i = 1; i <= n; i++) {
      for (int j = i + 1; j <= n; j++) {
        if (i + j != n) {
          ans.emplace_back(i, j);
        }
      }
    }
  } else {
    for (int i = 1; i <= n; i++) {
      for (int j = i + 1; j <= n; j++) {
        if (i + j != n + 1) {
          ans.emplace_back(i, j);
        }
      }
    }
  }

  cout << ans.size() << '\n';
  for (auto i : ans) {
    cout << i.first << ' ';
    cout << i.second << '\n';
  }
  return 0;
}


Measured memory_bytes: 384
package main

import "fmt"

func main() {
	var (
		n int
		m int
		c int
	)
	_, _ = fmt.Scan(&n, &m, &c)
	b := make([]int, 0)
	for i := 0; i < m; i++ {
		var tmp int
		_, _ = fmt.Scan(&tmp)
		b = append(b, tmp)
	}
	count := 0
	for i := 0; i < n; i++ {
		val := 0
		for j := 0; j < m; j++ {
			var tmp int
			_, _ = fmt.Scan(&tmp)
			val += tmp * b[j]
		}
		if val + c > 0 {
			count++
		}
	}
	fmt.Println(count)
}

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

int main(){
    int n,m;
    cin >> n >> m;
    vector<int> ac(n), pena(n);
    rep(i,m){
        int p;
        string q;
        cin >> p >> q;
        p--;
        if (ac[p]) continue;
        if (q == "AC"){
            ac[p] = 1;
        }
        else {
            pena[p]++;
        }
    }
    int AC = 0 , PENA = 0;
    rep(i,n){
        AC += ac[i];
        if (ac[i]) PENA += pena[i];
    }
    cout << AC << " " << PENA << endl;
}

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

#define ll long long
#define ld long double
#define ft first
#define sd second
#define pb push_back
using namespace std;
// const ll mod = 1e9+7;
const ll mod = 998244353;

ll power(ll a, ll b, ll m = mod) {
    ll x = 1;
    while(b) {
        if(b & 1) {
            x = 1ll * x * a % m;
        }
        a = 1ll * a * a % m;
        b /= 2;
    }
    return x;
}

const int N = 1e6+9;
int a[N];

signed main() {  
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);    
    
    int n; cin >> n;
    for(int i = 1; i <= n; i++) {
        int foo; cin >> foo;
        if(i == 1 && foo != 0 || i != 1 && foo == 0) {
            cout << "0\n"; return 0;
        }
        a[foo]++;
    }
    ll ans = 1;
    for(int i = 1; i < n; i++) {
        ans = ans * power(a[i-1], a[i]) % mod;
    }
    cout << ans << "\n";

    
    


    return 0;
    
}


Measured memory_bytes: 640
//Author - Rahil Malhotra
#include <bits/stdc++.h>
using namespace std;
 
template <typename T> void print(T t) { cout<<t<<endl; }
template<typename T, typename... Args> void print(T t, Args... args) { cout<<t<<" "; print(args...); }
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl '\n'
#define int long long
#define double long double

#define type pair<int,pair<int,int>>
#define x first
#define y second

int n,m;
int arr[200005][2];
int mini[200005];
int tree[1000005];
int lazy[1000005];

void propogate(int i,int l,int r)
{
    tree[i]=lazy[i];
    if(l!=r)
    {
        if(lazy[i*2]==0)
            lazy[i*2]=lazy[i];
        else
            lazy[i*2]=min(lazy[i*2],lazy[i]);
        if(lazy[i*2+1]==0)
            lazy[i*2+1]=lazy[i];
        else
            lazy[i*2+1]=min(lazy[i*2+1],lazy[i]);
    }
    lazy[i]=0;
}
void build(int i,int l,int r)
{
    if(l==r)
    {
        tree[i]=1e12;
        return;
    }
    int mid=(l+r)/2;
    build(i*2,l,mid);
    build(i*2+1,mid+1,r);
    tree[i]=min(tree[i*2],tree[i*2+1]);
}
void update(int i,int l,int r,int l1,int r1,int val)
{
    if(lazy[i])
        propogate(i,l,r);
    if(l1>r1 || l>r1 || l1>r)
        return;
    if(l1<=l && r<=r1)
    {
        tree[i]=val;
        if(l!=r)
        {
            if(lazy[i*2]==0)
                lazy[i*2]=val;
            else
                lazy[i*2]=min(lazy[i*2],val);
            if(lazy[i*2+1]==0)
                lazy[i*2+1]=val;
            else
                lazy[i*2+1]=min(lazy[i*2+1],val);
        }
        return;
    }
    int mid=(l+r)/2;
    update(i*2,l,mid,l1,r1,val);
    update(i*2+1,mid+1,r,l1,r1,val);
    tree[i]=min(tree[i*2],tree[i*2+1]);
}
int query(int i,int l,int r,int l1,int r1)
{
    if(l1>r1 || l>r1 || l1>r)
        return 1e12;
    if(lazy[i])
        propogate(i,l,r);
    if(l1<=l && r<=r1)
        return tree[i];
    int mid=(l+r)/2;
    return min(query(i*2,l,mid,l1,r1),query(i*2+1,mid+1,r,l1,r1));
}
int32_t main()
{
    IOS;
    cin>>n>>m;
    for(int i=1;i<=n;i++)
        cin>>arr[i][0]>>arr[i][1];

    build(1,1,m+2);
    for(int i=1;i<=m;i++)
        if(i<arr[1][0] || i>arr[1][1])
            update(1,1,m+2,i,i,1);

    int ans=0;
    for(int i=2;i<=n+1;i++)
    {   
        //print(query(1,1,m+2,1,m));
        mini[i]=i-2+query(1,1,m+2,1,m);
        int get=query(1,1,m+2,arr[i][0],arr[i][1]);
        int low=arr[i][0];
        int high=arr[i][1];
        while(low<high)
        {
            int mid=(low+high+1)/2;
            if(query(1,1,m+2,mid,arr[i][1])>=1e12)
                high=mid-1;
            else
                low=mid;
        }
        int ans=arr[i][1]+1-low+query(1,1,m+2,low,arr[i][1]);
        update(1,1,m+2,arr[i][0],arr[i][1],1e12);
        if(query(1,1,m+2,arr[i][1]+1,arr[i][1]+1)>ans)
            update(1,1,m+2,arr[i][1]+1,arr[i][1]+1,ans);
    }   
    for(int i=2;i<=n+1;i++)
        if(mini[i]>1e11)
            cout<<-1<<endl;
        else
            cout<<mini[i]<<endl;
}


Measured memory_bytes: 16472
#include <iostream>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <list>
#include <vector>
#include <complex>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <bitset>
#include <ctime>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cassert>
#include <cstddef>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <sstream>
#include <fstream>
#include <functional>

using namespace std;
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define FOR(i, a, b) for (int (i) = (a); (i) < (b); (i)++)
#define RREP(i, a) for(int (i) = (a) - 1; (i) >= 0; (i)--)
#define FORR(i, a, b) for(int (i) = (a) - 1; (i) >= (b); (i)--)
#define DEBUG(C) cerr << #C << " = " << C << endl;
using LL = long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<LL>;
using VVL = vector<VL>;
using VD = vector<double>;
using VVD = vector<VD>;
using PII = pair<int, int>;
using PDD = pair<double, double>;
using PLL = pair<LL, LL>;
using VPII = vector<PII>;
template<typename T> using VT = vector<T>;
#define ALL(a) begin((a)), end((a))
#define RALL(a) rbegin((a)), rend((a))
#define SORT(a) sort(ALL((a)))
#define RSORT(a) sort(RALL((a)))
#define REVERSE(a) reverse(ALL((a)))
#define MP make_pair
#define FORE(a, b) for (auto &&a : (b))
#define EB emplace_back
#define GREATER(T) T, VT<T> greater<T>
template<typename T> inline bool chmax(T &a, T b){if (a < b){a = b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if (a > b){a = b;return true;}return false;}

const int INF = 1e9;
const int MOD = INF + 7;
const LL LLINF = 1e18;

const int MAX = 1e5 + 10;
int N;
int A[MAX];

int main(void) {
    cin >> N;
    REP(i, N) {
        cin >> A[i];
    }

    LL ans = 1;
    int cnt[3] = {-1, -1, -1};
    REP(i, N) {
        VI cand;
        REP(j, 3) {
            if (cnt[j] + 1 == A[i]) {
                cand.EB(j);
            }
        }

        if (cand.size() == 0) {
            cout << 0 << endl;
            return 0;
        }

        if (cnt[cand[0]] >= 0) {
            (ans *= (cand.size() + (cand.size() + 1)) / 2) %= MOD;
        }
        cnt[cand[0]]++;
    }

    int exists_cnt = 0;
    REP(i, 3) if (cnt[i] >= 0) {
        exists_cnt++;
    }

    (ans *= (exists_cnt == 1 ? 3 : 6)) %= MOD;

    cout << ans << endl;
}


Measured memory_bytes: 640
#include <iostream>
#include <cstdio>
#include <math.h>

using namespace std;

typedef long long int ll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
const int MOD = 1000000007;
const int INF = INT_MAX;



int main(int argc, char const *argv[])
{
    ll n;
    cin >> n;


    ll a, b, res;
    res = n;
    for (int i=1; i <= pow(n, 0.5); i++){
        if (n%i == 0){
            a = i;
            b = n/i;
            if (a+b-2 < res){
            res = a+b-2;
            }
        }
    }

    cout << res << endl;

    return 0;
}




//              g++ -std=c++1z  

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> mp;
ll inf =  1e9;


int main(){
 char a;
 cin>>a;
 if( a >= 'A' && a <= 'Z' ){
  cout<<'A'<<endl;
 }else{
  cout<<'a'<<endl;
 }
    return 0;
}


Measured memory_bytes: 3632
#include "bits/stdc++.h"
using namespace std;
#define Rep(i,n) for(int i=0;i<(int)(n);i++)
#define For(i,n1,n2) for(int i=(int)(n1);i<(int)(n2);i++)
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define RREP(i,n) for(ll i=((ll)(n)-1);i>=0;i--)
#define FOR(i,n1,n2) for(ll i=(ll)(n1);i<(ll)(n2);i++)
#define RFOR(i,n1,n2) for(ll i=((ll)(n1)-1);i>=(ll)(n2);i--)
#define all(a)  (a).begin(),(a).end()
#define SORT(a) sort((a).begin(),(a).end())
#define oorret 0
#define oor(x) [&](){try{x;} catch(const out_of_range& oor){return oorret;} return x;}()
#define IOS cin.tie(0),ios::sync_with_stdio(false)
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
template<typename T1, typename T2> inline bool chmin(T1& a, T2 b) { if (a > b) { a = b; return 1; }return 0; }
template<typename T1, typename T2> inline bool chmax(T1& a, T2 b) { if (a < b) { a = b; return 1; }return 0; }
template<class Type>struct is_vector : std::false_type {};
template<class ValueType, class Alloc>struct is_vector<std::vector<ValueType, Alloc>> : std::true_type {};
template <typename T> inline ostream& operator << (ostream& out, const vector<T>& v) {
    if (v.empty())return out;
    constexpr bool is_vector_v = is_vector<T>::value;
    if (is_vector_v)for (auto itr = v.begin(); itr != v.end();)out << (*itr), out << ((++itr != v.end()) ? "\n" : "");
    else for (auto itr = v.begin(); itr != v.end();)out << (*itr), out << ((++itr != v.end()) ? " " : "");
    return out;
}
inline void put() {}
template<class T> inline void put(const T& first) { std::cout << first << "\n"; }
template<class T, class... N> inline void put(const T& first, const N& ... rest) { std::cout << first << " "; put(rest...); }
inline void putn() {}
template<class T, class... N> inline void putn(const T& first, const N& ... rest) { std::cout << first << "\n"; putn(rest...); }

int main() {
    IOS;
    int n;
    cin >> n;
    vector<int> a(n);
    vector<int> c(n,0);
    REP(i,n){
        cin >> a[i];
        c[a[i]]++;
    }
    int ma = *max_element(all(a));
    bool flag=true;
    if(ma==1){
        if(n>2){
            flag=false;
        }
    }else if(ma%2==0){
        FOR(i,ma/2+1,ma+1){
            if(c[i]<2){
                flag=false;
            }
        }
        if(c[ma/2]<1){
            flag=false;
        }
        REP(i,n){
            if(c[i]>0){
                if(i==ma/2){
                    if(c[i]>1){
                        flag=false;
                    }
                }else if(ma/2+1>i||i>ma+1){
                    flag=false;
                }
            }
        }
    }else{
        FOR(i,ma/2+1,ma+1){
            if(c[i]<2){
                flag=false;
            }
        }
        REP(i,n){
            if(c[i]>0){
                if(i==ma/2+1){
                    if(c[i]>2){
                        flag=false;
                    }
                }else if(ma/2+1>i||i>ma+1){
                    flag=false;
                }
            }
        }
    }
    if(flag){
        put("Possible");
    }else{
        put("Impossible");
    }
    return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("O3", "unroll-loops")
//#pragma GCC target("avx2")
#include <bits/stdc++.h>
#include <stdio.h>

using namespace std;
#define ull unsigned long long
#define si short int
#define ll long long
#define piii pair<pair<int, int>, int>
#define piiii pair<pair<int, int>, pair<int, int>>

/*-----------------------------------------------------MATH------------------------------------------------*/
inline ll gcd(ll a, ll b) {
    while (b) {
        a %= b;
        swap(a, b);
    }
    return a;
}

inline ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

inline int pwm(ll xx, ll pow, int MD) {
    if (pow < 0) { pow = pow % (MD - 1) + MD - 1; }
    ll mlt = 1;
    while (pow) {
        if (pow & 1) {
            mlt *= xx;
            mlt %= MD;
        }
        xx *= xx;
        pow >>= 1;
        xx %= MD;
    }
    return (int) mlt;
}

inline ll gcdex(ll a, ll b, ll &x, ll &y) {
    if (b == 0) {
        x = 1;
        y = 0;
        return a;
    }
    ll xx, yy;
    ll gc = gcdex(b, a % b, yy, xx);
    x = xx;
    y = yy - (a / b) * xx;
    return gc;
}

inline int inv(ll r, int _mod) { return pwm(r % _mod, _mod - 2, _mod); }

inline int64_t hilbertOrder(int x, int y, int pow, int rotate) {
    if (pow == 0) {
        return 0;
    }
    int hpow = 1 << (pow - 1);
    int seg = (x < hpow) ? (
            (y < hpow) ? 0 : 3
    ) : (
                      (y < hpow) ? 1 : 2
              );
    seg = (seg + rotate) & 3;
    const int rotateDelta[4] = {3, 0, 0, 1};
    int nx = x & (x ^ hpow), ny = y & (y ^ hpow);
    int nrot = (rotate + rotateDelta[seg]) & 3;
    int64_t subSquareSize = int64_t(1) << (2 * pow - 2);
    int64_t ans = seg * subSquareSize;
    int64_t add = hilbertOrder(nx, ny, pow - 1, nrot);
    ans += (seg == 1 || seg == 2) ? add : (subSquareSize - add - 1);
    return ans;
}

/*-----------------------------------------------------MATH------------------------------------------------*/
ll mod = 1e9 + 7;
vector<int> arr;
void solve() {
    int n;
    cin>>n;
    for(int i=0;i<n;i++){
        int a;
        cin>>a;
        arr.push_back(a);
    }
    int mn=n+1;
    int ans=0;
    for(int i=0;i<n;i++){
        mn=min(arr[i], mn);
        if(arr[i]==mn) ans++;
    }
    cout<<ans;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    //freopen("C:\\Users\\Maximus\\CLionProjects\\Codeforces\\BestTeam\\output.txt", "r", stdin);
    //freopen("C:\\Users\\Maximus\\CLionProjects\\Codeforces\\BestTeam\\output.txt", "w", stdout);
    unsigned int beg_time = clock();

    int n = 1;
    for (int i = 0; i < n; i++) solve();


    unsigned int end_time = clock();
    //cout<<endl<<endl<<end_time-beg_time;

    return 0;
}

Measured memory_bytes: 1400
#include <iostream>

using namespace std;

int main()
{
    int a,b,c,k,count=0;
    cin>>a>>b>>c>>k;
    
    while(b<=a){
        b*=2;
        count++;
    }
    if(count>k) cout<<"No\n";
    else{
        while(c<=b){
            c*=2;
            count++;
        }
        if(count>k) cout<<"No\n";
        else cout<<"Yes\n";
    }
    

    return 0;
}

Measured memory_bytes: 3616
n = int(input())
string = ["", ".,!? ", "abc", "def", "ghi",
          "jkl", "mno", "pqrs", "tuv", "wxyz"]
for i in range(n):
    s = input()
    count = 0
    num = int(s[0])
    for c, c1 in zip(s, s[1:]):
        if c == c1:
            count += 1
        else:
            if num != 0:
                print(string[num][count % len(string[num])], end="")
            else:
                pass
            num = int(c1)
            count = 0
    print()



Measured memory_bytes: 5624
#include<bits/stdc++.h>
using namespace std;
int main(){
  int i,n;
  long long int s=0;
  cin>>n;
  for(i=1;i<=n;i++){
    if(i%3!=0 && i%5!=0 && i%15!=0) s+=i;
  }
  cout<<s<<endl;
  return 0;
}

Measured memory_bytes: 3640
def solve():
    N, M = map(int, input().split())
    edges = [[] for _ in [0]*N]
    r_edges = [[] for _ in [0]*N]

    for _ in [0]*M:
        a, b = map(int, input().split())
        edges[a].append(b)
        r_edges[b].append(a)

    c = kosaraju(edges, r_edges)
    group = [0]*N
    for i in range(len(c)):
        for v in c[i]:
            group[v] = i

    result = []
    append = result.append
    for _ in [0]*int(input()):
        a, b = map(int, input().split())
        append("1" if group[a] == group[b] else "0")

    print("\n".join(result))


def kosaraju(edges, reverse_edges):
    import sys
    sys.setrecursionlimit(10**7)
    v_count = len(edges)
    order = [0]*v_count
    k = [1]

    def get_order(v):
        order[v] = 1
        [None for dest in edges[v] if order[dest] == 0 and get_order(dest)]
        order[v] = k[0]
        k[0] += 1

    def get_components(v):
        order[v] = 0
        return [v] + [_v for dest in reverse_edges[v] if order[dest] > 0 for _v in get_components(dest)]

    [None for v in range(v_count) if order[v] == 0 and get_order(v)]
    return [get_components(v) for v, _ in sorted(enumerate(order), key=lambda x: x[1], reverse=True) if order[v] > 0]

if __name__ == "__main__":
    solve()

Measured memory_bytes: 35104
#include <iostream>

using namespace std;

int main()
{
    int x1, y1, x2, y2; cin >> x1 >> y1 >> x2 >> y2;
    int x3 = 0, y3 = 0, x4 = 0, y4 = 0;

    x3 = x2 + y1 - y2;
    y3 = y2 + x2 - x1;
    x4 = x1 + y1 - y2;
    y4 = x2 + y1 - x1;

    cout << x3 << " " << y3 << " " << x4 << " " << y4 << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define For(aa,bb,cc) for(int aa=(bb);aa<=(int)(cc);++aa)
using namespace std;
int n,m;
map<int,int>G;

template<class T>void read(T &x){
	x=0;char c=getchar();bool symbol=0;
	while(!isdigit(c)) symbol|=c=='-',c=getchar();
	while(isdigit(c)) x=(x<<1)+(x<<3)+(c^48),c=getchar();
	x=symbol?-x:x;
}

int main(){
	int x;
	read(n);
	For(i,1,n){
		read(x);
		if(!G.count(x)) G[x]=1;
		else ++G[x];
	}
	read(m);
	For(i,1,m){
		read(x);
		if(G[x]==0){
			puts("NO");
			return 0;
		}
		else --G[x];
	}
	puts("YES");
	return 0;
}

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



int main() {
	long long n,ans,n3,n5,n15;
	cin>>n;
	n3 = n/3;
	n5 = n/5;
	n15 = n/15;
	n3 = 3*(n3*(n3+1)/2);
	n5 = 5*(n5*(n5+1)/2);
	n15 = 15*(n15*(n15+1)/2);
	ans = n3+n5-n15;
	ans = n*(n+1)/2 - ans;
	cout<<ans<<endl;
}


Measured memory_bytes: 3636
*> DENTIFICATION DIVISIONでは、プログラムの名前を記述するところ。
IDENTIFICATION DIVISION.
PROGRAM-ID. SORTNUM.

DATA DIVISION.
    WORKING-STORAGE SECTION.
      
      01 N PIC 999.
      01 INT PIC X(3).
      01 D1 PIC 9.
      01 D2 PIC 9.
      
      01 CNT PIC 9.

*> PROCEDURE DIVISIONでは、プログラムが行う処理を書いていく。
PROCEDURE DIVISION.
    MAIN SECTION.
    	
      	ACCEPT N.
      
      	PERFORM N TIMES
      		ACCEPT INT
      		
      		UNSTRING INT DELIMITED ' '
      			INTO D1 D2
      		
      		IF D1 = D2 THEN
      			ADD 1 TO CNT
      			
      			IF CNT = 3 THEN
      				DISPLAY 'Yes'
      				EXIT PERFORM
      			END-IF
      		ELSE
      			MOVE 0 TO CNT
      		END-IF
      	END-PERFORM.
      	
      	IF CNT NOT = 3 THEN
      		DISPLAY 'No'
      	END-IF.
      	


*> プログラム終了！！お疲れ様でした。
    STOP RUN.


Measured memory_bytes: 3940
import math
import collections

n = int(input())
mod = 10**9+7

def prime_factorize(n: int) -> list:
    a = []

    while n%2 == 0:
        a.append(2)
        n //= 2

    f = 3
    while f*f <= n:
        if n%f == 0:
            a.append(f)
            n //= f
        else:
            f += 2

    if n != 1:
        a.append(n)

    return a

fac = prime_factorize(math.factorial(n))
c = collections.Counter(fac)

ans = 1
for v in c.values():
    ans *= v+1
    ans %= mod

print(ans)


Measured memory_bytes: 3316
#include<iostream>
#include<cmath>
#include<algorithm>
#include<vector>
#include<queue>
#include<functional>

#define P pair<int,int>

using namespace std;

int main(){

  int v,e,r;
  cin >> v >> e >>r;
  vector<vector<P>> G(v);
  for(int i=0;i<e;i++){
    long long int s,t,d;
    cin >> s >> t >> d;
    G[s].push_back({d,t});
  }

  vector<bool> seen(v,false);
  vector<long long> dist(v,10000000000);

  dist[r]=0;
  seen[r]=1;

  priority_queue<P,vector<P>,greater<P>> que;
  que.push(P(0,r));

  while(!que.empty()){
    P p = que.top();
    que.pop();
    int u = p.second;
    if(dist[u] < p.first){
      continue;
    }
    for(int i=0;i<G[u].size();i++){
      P e = G[u][i];
      if(dist[e.second] > dist[u] + e.first){
        dist[e.second] = dist[u] + e.first;
        que.push(P(dist[e.second],e.second));
      }
    }
  }
  
  for(int i=0;i<v;i++){
    if(dist[i]!=10000000000)cout << dist[i] <<endl;
    else cout << "INF" << endl;
  }
  




}


Measured memory_bytes: 13420
#define _CRT_SECURE_NO_WARNINGS
#include <cstdio>
#include <vector>
#include <string>
#include <iostream>
#include <algorithm>
#include <map>
#include <iterator>
#include <functional>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <fstream>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <list>
#include <sstream>
#include <complex>
#include <stdio.h>
#include <unordered_set>
using namespace std;
#pragma GCC optimize("O3")
#pragma GCC target("sse4")

typedef long double LD;
typedef long long LL;
typedef pair<int, int> PII;
typedef pair<LD, LD> PDD;
typedef pair<LL, LL> PLL;
typedef vector<int> VI;
typedef vector<LL> VLL;
typedef vector<char> VCH;
typedef vector<LD> VLD;
typedef vector<string> VS;
typedef vector<VS> VSS;
typedef vector<VI> VVI;
typedef vector<VLL> VVLL;
typedef vector<VCH> VVCH;
typedef vector<PII> VPII;
typedef vector<PLL> VPLL;
typedef vector<PDD> VPDD;
#define MP make_pair
#define PB push_back
#define X first
#define Y second
#define next fake_next
#define prev fake_prev
#define left fake_left
#define right fake_right

#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define RFOR(i,b,a) for(int i = (b) - 1; i >= (a); --i)
#define REP(i, t) FOR(i,0,t)
#define ALL(a) a.begin(), a.end()
#define SZ(a) (int)((a).size())

const LD PI = acos(-1.0);
const LL mod = 1000000007;
const LL INF = 1e9;
const LL LINF = 1e18;
const LL MAXN = 100 + 1;
const LL MAXS = 100 + 1;
const LL MAXT = 100 + 1;

int main()
{
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	//freopen("In.txt", "r", stdin);
	//freopen("In.txt", "w", stdout);

	int n, p;
	cin >> n >> p;

	VI a(n);
	FOR(i, 0, n)
		cin >> a[i], a[i] %= 2;

	LL ans = 0;
	int one = 0;
	FOR(i, 0, n)
		if (a[i] & 1)
			++one;

	int zero = n - one;

	if (p == 1 && one == 0)
	{
		cout << 0;
		return 0;
	}

	ans = (1LL << zero);

	if (one)
		ans *= (1LL << (one - 1));

	cout << ans;
	cin >> n;
	return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
 
public class Main {
	public void exec() throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter out = new PrintWriter(System.out);
    	int n = Integer.parseInt(br.readLine());
    	int[] x = parseInts(br.readLine().split(" "));
    	int[] y = parseInts(br.readLine().split(" "));
    	long sum1 = 0,sum2 = 0,sum3 = 0;
    	int max=0;
		for(int i=0; i<n; i++) {
			int d = Math.abs(x[i]-y[i]);
			int d2 = d*d;
			sum1 += d;
			sum2 += d2;
			sum3 += d*d2;
			max = Math.max(d, max);
		}
    	out.printf("%.5f\n",(double)sum1);
    	out.printf("%.5f\n",Math.sqrt(sum2));
    	out.printf("%.5f\n",Math.cbrt(sum3));
    	out.printf("%.5f\n",(double)max);
        out.flush();
    }
	
	private int[] parseInts(String[] s) {
		int[] v = new int[s.length];
		for(int i=0; i<s.length; i++) {
			v[i] = Integer.parseInt(s[i]);
		}
		return v;
	}
	
    public static void main(String[] args) throws IOException {
        new Main().exec();
    }
}

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

#define vec              vector<int>
#define vecll            vector<ll>
#define vecd             vector<double>
#define vecst            vector<string>
#define vecb             vector<bool>
#define v2(v,n,m,init)   vector<vector<int>>  v(n, vector<int>(m, init))
#define vb2(v,n,m,init)  vector<vector<bool>> v(n, vector<bool>(m, init))
#define vll2(v,n,m,init) vector<vector<ll>>   v(n, vector<ll>(m, init))

#define rep(i,n)         for(ll i=(ll)0; i<(ll)n; i++)
#define REP(i,m,n)       for(ll i=(ll)m; i<(ll)n; i++)
#define arr(var, n)      vec var(n); rep(i,n){cin >> var[i];}
#define arrll(var, n)    vecll var(n); rep(i,n){cin >> var[i];}
#define arrst(var, n)    vecst var(n); rep(i,n){cin >> var[i];}
#define all(var)         (var).begin(), (var).end()
#define sortall(var)     sort(all(var))
#define uniqueall(v)     v.erase(unique(v.begin(), v.end()), v.end());
#define pb(var)          push_back(var)
#define prt(var)         cout << (var) << "\n"
#define prtd(n, var)     cout << fixed << setprecision(n) << (var) << "\n"
#define prtfill(n, var)  cout << setw(n) << setfill('0') << (var);
#define prt2(v1, v2)     cout << (v1) << " " << (v2) << "\n"
#define prt3(v1, v2, v3) cout << (v1) << " " << (v2) << " " << (v3) << "\n"
#define prtall(v)        rep(i,v.size()){cout<<v[i]<<(i!=v.size()-1?" ":"\n");}
template <typename T>
bool chmax(T &a, const T& b){if(a<b){a=b; return true;} return false;}
template <typename T>
bool chmin(T &a, const T& b){if(a>b){a=b; return true;} return false;}
//------------------------------------------------------------------

int main(void){
  int n;
  cin >> n;
  ll ans=0;
  REP(i,1,n){
    REP(j,1,n){
      if(i*j>=n) break;
      if(n-i*j>0) ans++;
    }
  }

  prt(ans);
}


Measured memory_bytes: 3652
#include<iostream>
#include<cstdio>
#include<cmath>
#include<algorithm>
using namespace std;
int a[5]; 

int cmp(int a,int b){
	return a>b;
}

int main(){
	int maxnum=-1;
	for(int i=1;i<=3;i++){
		cin>>a[i];
	}
	sort(a+1,a+1+3,cmp);
	cout<<abs(a[1]-a[2])+abs(a[2]-a[3]);
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int64_t N, K;
  cin >> N >> K;
  vector<int64_t> vec(N);
  for(int i=0; i<N; i++){
    cin >> vec[i];
  }
  vector<int64_t> sum(N+1);
  for(int i=0; i<N; i++){
    sum[i+1] = sum[i] + vec[i];
    sum[i+1] %= K;
  }
  
  for(int i=0; i<N+1; i++){
    sum[i] -= i;
    if(sum[i] < 0){
      sum[i] += K*(abs(sum[i])/K + 1);
    }
    sum[i] %= K;
  }
 
  
  int64_t ans = 0;
  
  map<int64_t,int64_t> mp;
  for(int i=0; i<N+1; i++){
    if(mp.count(sum[i])){
      mp[sum[i]]++;
    }
    else{
      mp[sum[i]] = 1;
    }
    if(i >= K){
      mp[sum[i-K]]--;
    }
    ans += mp[sum[i]] - 1;
  }
  cout << ans << endl;
}

Measured memory_bytes: 15872
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

var scanner = bufio.NewScanner(os.Stdin)

func next() string {
	scanner.Scan()
	return scanner.Text()
}

func nexts(n int) []string {
	strings := make([]string, n)
	for i := 0; i < n; i++ {
		strings[i] = next()
	}
	return strings
}

func nextInt() int {
	i, _ := strconv.Atoi(next())
	return i
}

func chmin(a int, b int) int {
	if a > b {
		return b
	}
	return a
}

func chmax(a int, b int) int {
	if a > b {
		return a
	}
	return b
}

type Task struct {
	Cost     int
	Deadline int
}

type Tasks []Task

func (t Tasks) Len() int {
	return len(t)
}

func (t Tasks) Swap(i, j int) {
	t[i], t[j] = t[j], t[i]
}

func (t Tasks) Less(i, j int) bool {
	return t[i].Deadline < t[j].Deadline
}

func main() {
	scanner.Split(bufio.ScanWords)

	n := nextInt()
	tasks := make([]Task, n)

	for i := 0; i < n; i++ {
		tasks[i] = Task{
			Cost:     nextInt(),
			Deadline: nextInt()}
	}

	sort.Sort(Tasks(tasks))

	time := 0
	for i := 0; i < n; i++ {
		time += tasks[i].Cost
		if time > tasks[i].Deadline {
			fmt.Println("No")
			return
		}
	}

	fmt.Println("Yes")
}


Measured memory_bytes: 6272
#include<iostream>
#include<cstring>
using namespace std;
int q;
int main(){
  cin>>q;
  for(int z=0;z<q;z++){
    string a,b;
    cin>>a>>b;
    int n=a.size(),m=b.size();
    int dp[n+1][m+1];
    memset(dp,0,sizeof(dp));
    for(int i=0;i<n;i++){
      for(int j=0;j<m;j++){
        if(a[i]==b[j]){
          dp[i+1][j+1]=dp[i][j]+1;
        }else{
          dp[i+1][j+1]=max(dp[i][j+1],dp[i+1][j]);
        }
      }
    }
    cout<<dp[n][m]<<endl;
  }
}


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

using namespace std;

using ll = long long;

template <class T>
struct BIT {
    int n;
    vector<T> data;
    BIT(int n) : n(n), data(n) {}
    T sum(int i) {
        T res{};
        for (; i >= 0; i = (i & (i + 1)) - 1)
            res += data[i];
        return res;
    }
    void add(int i, T val) {
        for (; i < n; i |= i + 1)
            data[i] += val;
    }
};

struct _IN {
    _IN() {
        ios::sync_with_stdio(0);
        cin.tie(0);
    }
    template <typename T>
    operator T() const {
        T x;
        cin >> x;
        return x;
    }
    template <typename Container>
    void operator()(Container& c) {
        for (auto& x : c)
            cin >> x;
    }
} IN;

int main() {
    int N = IN, K = IN;
    BIT<int> bit(N + 1);
    for (int i = 0; i < N; i++) {
        int x = IN;
        bit.add(max(0, i - x), 1);
        bit.add(min(N - 1, i + x) + 1, -1);
    }
    while (K > 1) {
        BIT<int> bit2(N + 1);
        bool good = true;
        for (int i = 0; i < N; i++) {
            int x = bit.sum(i);
            if (x < N)
                good = false;
            bit2.add(max(0, i - x), 1);
            bit2.add(min(N - 1, i + x) + 1, -1);
        }
        if (good)
            break;
        bit = bit2;
        K--;
    }
    for (int i = 0; i < N; i++) {
        cout << bit.sum(i) << " ";
    }
    cout << endl;
}


Measured memory_bytes: 4984