akhauriyash/Code-Regression huggingface dataset:
#define NDEBUG
NDEBUG


#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cstring>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <memory>
#include <queue>
#include <random>

#define FOR(i, n) for (int i = 0; i < (n); ++i)


using namespace std;

// TC_REMOVE_BEGIN
/// caide keep
bool __hack = std::ios::sync_with_stdio(false);
/// caide keep
auto __hack1 = cin.tie(nullptr);
// TC_REMOVE_END


// Section with adoption of array and vector algorithms.


//#include <ext/pb_ds/tree_policy.hpp>
//#include <ext/pb_ds/assoc_container.hpp>
//
//template <class T> using StdTree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;


namespace template_util {
    

    constexpr int bytecount(uint64_t x) {
        return x ? 1 + bytecount(x >> 8) : 0;
    }

    template<int N>
    struct bytetype {
        
    };

    
    /// caide keep
    template<uint64_t N>
    struct minimal_uint : bytetype<bytecount(N)> {
    };
}


template<class T>
T next(istream& in) {
    T ret;
    in >> ret;
    return ret;
}

template<class T>
vector<T> next_vector(istream& in, size_t n) {
    vector<T> ret(n);
    for (size_t i = 0; i < n; ++i) {
        ret[i] = next<T>(in);
    }
    return ret;
}


void solve(istream& in, ostream& out) {
  auto n = next<int>(in);
  auto a = next_vector<int>(in, n);
  int minId = 0, maxId = 0;
  FOR(i, n) {
    if (a[i] < a[minId]) {
      minId = i;
    }
    if (a[i] > a[maxId]) {
      maxId = i;
    }
  }
  int id = minId;
  if (a[minId] + a[maxId] >= 0) {
    id = maxId;
  }
  vector<pair<int, int>> res;
  FOR(i, n) {
    if (i != id) {
      res.push_back({id, i});
      a[i] += a[id];
    }
  }

  if (a[0] >= 0) {
    FOR(i, n) if (i) {
      res.push_back({i-1, i});
    }
  } else {
    for (int i = n-1; i > 0; --i) {
      res.push_back({i, i-1});
    }
  }
  out << res.size() << "\n";
  for (auto& p : res) {
    out << p.first + 1 << ' ' << p.second + 1 << "\n";
  }
}


//#include <fstream>


int main() {
//  ifstream fin("bridges.in");
//  ofstream fout("bridges.out");
    solve(cin, cout);
//  solve(fin, fout);
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
 
int main() {
    int h, a;
    cin >> h >> a;
    if (h % a == 0) cout << h / a << endl;
    else cout << h / a + 1 << endl;
    return 0;
}

Measured memory_bytes: 256
const M: u64 = 1000_000_007;

fn main() {
    proconio::input! {
        n: usize,
        a: [u64; n],
    }
    let mut s = 0;
    for i in 1..n {
        s = (s + a[i]) % M;
    }

    let mut r = 0;
    for i in 0..(n - 1) {
        r = (r + (a[i] * s % M)) % M;
        if s < a[i + 1] {
            s += M;
        }
        s -= a[i + 1];
    }

    println!("{}", r);
}


Measured memory_bytes: 5588
N,M = map(int,input().split())
A = [-1]*N
ans = 0
for i in range(M):
    s,c = map(int,input().split())
    if A[s-1]!=-1 and A[s-1]!=c:ans=-1
    else:
        A[s-1]=c
if N==1:
    print(max(A[0],0) if ans!=-1 else ans)
    exit()
for i in range(N):
    if i==0 and A[i]==0:ans=-1
    if A[i]==-1:A[i]=0
    if i==0:A[i]=max(A[i],1)
    A[i] = str(A[i])
print(-1 if ans==-1 else "".join(A))

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <set>

#define PI 3.1415926535897

typedef long long ll;

using namespace std;

int main() {
	ll x;

	cin >> x;

	ll a, b;
	bool flag = true;

	for (ll i = -120; i <= 120 && flag; i++) {
		for (ll j = -120; j <= 120; j++) {
			if (pow(i, 5) == x + pow(j, 5)) {
				a = i;
				b = j;
				flag = false;
				break;
			}
		}
	}

	cout << a << " " << b;
}

Measured memory_bytes: 4028
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define MOD 1000000007
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
using P = pair<int,int>;

int main()
{
  int N;
  cin >> N;
  string S;
  cin >> S;
  stack<char> st;
  REP(i,N){
    if(st.size()!=0&&st.top()=='('&&S.at(i)==')'){
      st.pop();
    }else{
      st.push(S.at(i));
    }
  }
  while(st.size()!=0){
    if(st.top()=='('){
      S=S+')';
    }else if(st.top()==')'){
      S='('+S;
    }
    st.pop();
  }

  cout << S << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main () {
  string S;
  cin >> S;
  int count = 0, flag = 1, front = 0, back = S.size() -1;
  while(front <= back && flag == 1){
    if(S.at(front) == S.at(back)){
	  front++;
      back--;
    } else {
      if(S.at(front) == 'x'){
        count++;
        front++;
      } else if (S.at(back) == 'x'){
        count++;
        back--;
      } else {
        flag = 0;
      }
    }
  }
  cout << (flag ? count : -1) << endl;
  return 0;
}

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

int main(){
    ll a, v, b, w, t;
    cin >> a >> v >> b >> w >> t;

    if(a < b){
        if(a + v*t >= b + w*t) cout << "YES" << endl;
        else cout << "NO" << endl;
    } 
    else{
        if(a - v*t <= b - w*t) cout << "YES" << endl;
        else cout << "NO" << endl;
    }
}

Measured memory_bytes: 3628
#include<iostream>
#include<string>
#include<cmath>
#include <algorithm>
#include <stdio.h>



using namespace std;

int N,K;
int A[300000];


int main()
{

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


  /*
  for(int i=0;i<=N;i++)
    cout<<i<<"  "<<A[i]<<endl;


  cout<<"================="<<endl;
  sort(A,A+(N+1));

  for(int i=0;i<=N;i++)
    cout<<i<<"  "<<A[i]<<endl;
  */

  int ans=0;
  sort(A,A+(N+1));
  
  for(int i=N-K;i>=0;i--)
    ans+=A[i];
  

  cout<<ans<<endl;

  return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define inf 1000000000
#define INF 1000000000000000
#define ll long long
#define ull unsigned long long
#define M (int)(1e9+7)
#define P pair<int,int>
#define PLL pair<ll,ll>
#define FOR(i,m,n) for(int i=(int)m;i<(int)n;i++)
#define RFOR(i,m,n) for(int i=(int)m;i>=(int)n;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,n,0)
#define all(a) a.begin(),a.end()
#define IN(a,n) rep(i,n){ cin>>a[i]; }
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define PI 3.14159265
#define F first
#define S second
#define PB push_back
#define EB emplace_back
#define int ll
void init(){
  cin.tie(0);
  ios::sync_with_stdio(false);
}


main(){
  int n;
  cin>>n;
  vector<P> a(110000),b(110000);
  rep(i,110000){
    a[i].S=i;
    b[i].S=i;
  }

  rep(i,n){
    int c;
    cin>>c;
    if(i%2){
      a[c].F++;
    }else{
      b[c].F++;
    }
  }

  sort(all(a));
  sort(all(b));
  reverse(all(a));
  reverse(all(b));

  if(a[0].S!=b[0].S){
    cout<<n-a[0].F-b[0].F<<endl;
  }else{
    cout<<n-max(a[0].F+b[1].F,a[1].F+b[0].F)<<endl;
  }

}


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

using namespace std;
typedef long long ll;
#define int ll

#define REP(i,n) for(ll i=0;i<n;++i)
#define SORT(name) sort(name.begin(), name.end())
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))
#if 1
#  define DBG(fmt, ...) printf(fmt, ##__VA_ARGS__)
#else
#  define DBG(fmt, ...)
#endif

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const double DINF = std::numeric_limits<double>::infinity();
const int MOD = 1000000007;
#define MAX_N 110

signed main()
{
    string s, t;
    vector<char> s_sort, t_sort;
    cin >> s >> t;
    REP(i, s.length()) { s_sort.push_back(s[i]); }
    REP(i, t.length()) { t_sort.push_back(t[i]); }
    SORT(s_sort);
    sort(t_sort.begin(), t_sort.end(), greater<char>());
    s = ""; t = "";
    REP(i, s_sort.size()) {
        s += s_sort[i];
    }
    REP(i, t_sort.size()) {
        t += t_sort[i];
    }
    if(s < t) {
        printf("Yes\n");
    } else {
        printf("No\n");
    }
    return 0;
}


Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
	var x int
	var y int

	fmt.Scan(&x)
	fmt.Scan(&y)

	if x == 2 || y == 2 {
		fmt.Println("No")
	} else if x >= 8 {
		if (y-x)%2 == 0 {
			fmt.Println("Yes")
		} else {
			fmt.Println("No")
		}
	} else if y < 8 {
		if (y-x)%2 == 0 {
			fmt.Println("Yes")
		} else {
			fmt.Println("No")
		}
	} else if x < 8 && y > 7 {
		if (y-x)%2 == 1 {
			fmt.Println("Yes")
		} else {
			fmt.Println("No")
		}
	}
}


Measured memory_bytes: 512
[N, M] = [int(i) for i in input().split()]
H = [int(i) for i in input().split()]
dic = {}
for i in range(M):
    [a, b] = [int(i) for i in input().split()]
    if a in dic:
        dic[a].append(b)
    else:
        dic[a] = [b]
    if b in dic:
        dic[b].append(a)
    else:
        dic[b] = [a]

ans = 0
for i in range(1, N+1):
    s = H[i-1]
    t = 0
    if i in dic:
        for j in range(len(dic[i])):
            if s <= H[dic[i][j]-1]:
                t += 1
                break
        if t == 0:
            ans += 1
    else:
        ans += 1

print(ans)

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

const long long MOD = 998244353;

long long inv[10000005];
long long invFact[10000005];
long long fact[10000005];

long long powmod(long long a, long long b){
    long long x = 1;
    long long y = a;
    while(b){
        if(b&1){ x = (x*y)%MOD; }
        y = (y*y)%MOD;
        b >>= 1;
    }
    return x;
}

inline long long ncr(long long a, long long b){
    return fact[a]*((invFact[a-b]*invFact[b])%MOD)%MOD;
}

int main(){
    int N;
    scanf("%d", &N);

    inv[1] = 1;
    for(int i = 2; i <= N; i ++){
        inv[i] = inv[MOD%i]*(MOD-MOD/i)%MOD;
    }

    fact[0] = 1;
    invFact[0] = 1;
    for(int i = 1; i <= N; i ++){
        fact[i] = (fact[i-1]*i)%MOD;
        invFact[i] = (invFact[i-1]*inv[i])%MOD;
    }

    long long tempPow2 = 1;
    long long ans = 0;
    for(int i = N; i > (N>>1); i --){
        ans += tempPow2*ncr(N, i)%MOD;

        tempPow2 += tempPow2;
        if(tempPow2 >= MOD){tempPow2 -= MOD;}
    }
    //printf("ans(%d)=%lld\n", N, ans);
    ans = (ans+ans)%MOD;
    long long finalAns = (powmod(3, N)-ans+MOD)%MOD;

    printf("%lld", finalAns);
    return 0;
}



Measured memory_bytes: 234624
import java.io.*;
import java.util.*;
import java.math.BigInteger;
public class Main {

static long[] list=new long[87];

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

//   String nyuA=sc.nextLine();
 //  String nyuB=sc.nextLine();
 
   String[] s=sc.nextLine().split(" ");
 //    String[] t=sc.nextLine().split("");

//int N=Integer.parseInt(nyuA);
int A=Integer.parseInt(s[0]);
int B=Integer.parseInt(s[1]);

String C=s[0]+s[1];
int num=Integer.parseInt(C);
int hei=(int)Math.sqrt(num);
if(num==hei*hei)
System.out.println("Yes");
else
System.out.println("No");



}

}



Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
 
#define mod 1000000007
#define INF 1000000000

#define mp make_pair
#define pb push_back
#define mt make_tuple
#define eb emplace_back
#define all(x) begin(x), end(x)
#define len(x) ((int)(x).size())
#define contains(a, x) (a.find(x) != end(a))
#define rep(i, n) for (int i = 0; i < (int)n; ++i)
#define F(i,a,b) for(int i = (int)(a); i < (int)(b); ++i)
#define RF(i,a,b)for(int i = (int)(a); i >= (int)(b); --i)

using dbl = double;
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vvl = vector<long long>;
using pi = pair<int,int>;

#define fast() {ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);}
#define log(x) cout << x << endl;


int main() {

	ll X;
	cin >> X;

	ll t = int(sqrt<ll>(2*X)+.5);
	log(t);

	return 0;
}





Measured memory_bytes: 256
using System;

class Tester
{
    static void Main(string[] args)
    {
        string x = Console.ReadLine();
         
        const char Space = ' ';

        char[] delimiters = new char[] { Space };

        string[] result = x.Split(delimiters);

        int a = int.Parse(result[0]);
        int b = int.Parse(result[1]);

        if(1<=a&&a<=100&&1<=b&&b<=100)
        {
            Console.WriteLine("{0} {1}", a * b, a * 2 + b * 2);
        }
    }
}


Measured memory_bytes: 9068
#include <algorithm>
#include <iostream>
#include <queue>
#include <cmath>
#include <string>
#include <iterator>
#include <map>
#include <set>
#include <iomanip>
#include <vector>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using Graph = vector<vector<int>>;
int dx[] = {0, 1, 0, -1};
int dy[] = {1, 0, -1, 0};
#define INF 100000000000
#define MAX 200001
#define MOD 1000000007

int main(){
    ll N;
    ll ans = 0;
    cin >> N;
    vector<ll> d(61, 0);
    for(int i = 0; i < N; i++){
        ll A;
        cin >> A;
        for(int j = 59; j >= 0; j--){
            ll c = pow(2, j);
            if(A >= c){
                d[j]++;
                A -= c;
            }
        }
    }
    for(int i = 0; i <= 59; i++){
        ll cnt = (N - d[i]) * d[i];
        cnt %= MOD;
        ll cc = pow(2, i);
        cc %= MOD;
        ll c = cc * cnt;
        c %= MOD;
        ans += c;
        ans %= MOD;
    }
    cout << ans << endl;
}

Measured memory_bytes: 4036
#include <iostream>

int top,front,migi;

int north(){
	int bottom=7-top;
	top=front;
	front=bottom;
	return 0;
}
int east(){
	int left=7-migi;
	migi=top;
	top=left;
	return 0;
}
int west(){
	int bottom=7-top;
	top=migi;
	migi=bottom;
	return 0;
}
int south(){
	int back=7-front;
	front=top;
	top=back;
	return 0;
}
int right(){
	int back=7-front;
	front=migi;
	migi=back;
	return 0;
}
int left(){
	int left=7-migi;
	migi=front;
	front=left;
	return 0;
}

int main(){
	int i,n,ans=1;
	char order[10];
	while(1){
		std::cin >> n;
		if(!n) break;
		top=1;front=2;migi=3;
		for(i=0;i<n;i++){
			std::cin >> order;
			if(order[0]=='N') north();
			else if(order[0]=='S') south();
			else if(order[0]=='E') east();
			else if(order[0]=='W') west();
			else if(order[0]=='R') right();
			else left();
			ans+=top;
		}
		std::cout<<ans<<std::endl;ans=1;
	}
}

Measured memory_bytes: 1164
def solve(a):
	if type(a[0]) is int:
		return sum(sorted(a)[:len(a)/2+1])/2 + len(a)
	else:
		return sum(sorted(solve(i) for i in a)[:len(a)/2+1])
for i in range(input()):
	A = eval(raw_input().replace("][","],["))
	print solve(A)

Measured memory_bytes: 9424
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll gcd(ll x, ll y){
  if(y==0) return x;
  gcd(y, x%y);
}
ll lcm(ll x, ll y){
  return (ll)x/gcd(x, y)*y;
}
int main() {
  int n;
  cin >> n;
  vector<ll> t(n);
  for(int i=0; i<n; i++){
    cin >> t[i];
  }
  ll lcmm = t[0];
  for(int i=1; i<n; i++){
    lcmm = lcm(lcmm, t[i]);
  }
  cout << lcmm << endl;
}

Measured memory_bytes: 256
#include<stdio.h>

int len(char* str);

int cmp(char* s, char* t);

void sort(char* str, int rev);

int main() {
	char s[100], t[100];
	scanf("%s", &s);
	scanf("%s", &t);
	sort(s, 1);
	sort(t, -1);
	printf(cmp(s, t) == 1 ? "Yes" : "No");

	
}

void sort(char* str, int rev) {
	int i, j;
	for (i = 0; i < len(str); i++) {
		for (j = 0; j < len(str) - 1 - i; j++) {
			if (rev * (str[j] - str[j + 1]) > 0) {
				char temp = str[j];
				str[j] = str[j + 1];
				str[j + 1] = temp;
			}
		}
	}
}

int len(char *str){
	int i = 0;
	while (str[i] != '\0') i++;
	return i;
}

int cmp(char* s, char* t) {
	int i;
	for (i = 0; i <= len(t); i++) {
		if (s[i] < t[i]) return 1;
		else if (t[i] < s[i]) return -1;
	}
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <deque>
#include <algorithm>
#include <numeric>
#include <string>
#include <cstring>
#include <list>
#include <unordered_set>
#include <tuple>
#include <cmath>
#include <limits>
#include <type_traits>
#include <iomanip>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <set>
#include <bitset>
#include <regex>
#include <random>
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;
#define rep(i,n)for(ll i=0;i<n;++i)
#define exout(x) printf("%.10f\n", x)
const double pi = acos(-1.0);
const ll MOD = 1000000007;
const ll INF = 1e18;
const ll MAX_N = 201010;

//組み合わせの余りを求める
ll fac[MAX_N], finv[MAX_N], inv[MAX_N];
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX_N; 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;
	}
}

// 二項係数計算
long long COM(ll n, ll k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

//最大公約数
ll gcd(ll x, ll y) {
	return y ? gcd(y, x % y) : x;
}

ll lcm(ll x, ll y) {
	if (x == 0 || y == 0)return 0;
	return (x / gcd(x, y) * y);
}

ll dx[4] = { 0,0,-1,1 };
ll dy[4] = { -1,1,0,0 };
char notes[110][10];

//long longしか使わない
//素数は1より大きい
//lower_boundは指定したkey以上の要素の一番左のイテレータをかえす
//upper_boundは指定したkeyより大きい要素の一番左のイテレータをかえす
int main() {
	ll n;
	cin >> n;
	vector<string>s(n);
	ll ans = 0;
	ll a = 0, b = 0, c = 0;
	rep(i, n) {
		cin >> s[i];
		ll k = s[i].length();
		rep(j, k - 1) {
			if (s[i][j] == 'A' && s[i][j + 1] == 'B')ans++;
		}
		if (s[i][0] == 'B')b++;
		if (s[i][k - 1] == 'A')a++;
		if (s[i][0] == 'B' && s[i][k - 1] == 'A')c++;
	}
	if (a == b && b == c && a != 0)a--;
	ans += min(a, b);
	cout << ans << endl;
	return 0;
}


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

typedef long long ll;

int main() {
	ll n, a, b, c, d, e; cin >> n >> a >> b >> c >> d >> e;
	ll num = n - 1;
	cout << max({ num / a,num / b,num / c,num / d,num / e }) + 5 << endl;

	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <vector>
#include <queue>
#include <stack>
#include <algorithm>

using ll = long long int;
const int INF = (1<<30);
const ll INFLL = (1ll<<60);
const ll MOD = (ll)(1e9+7);

#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	a = (a<MOD)?a:(a-MOD);
	b = (b<MOD)?b:(b-MOD);
	a += b;
	a = (a<MOD)?a:(a-MOD);
}

std::string c[10];

int main(void){
	int n[2],mask[2],i,j,k,cnt,ans=0;
	for(i=0; i<2; ++i){
		std::cin >> n[i];
	}
	std::cin >> k;
	for(i=0; i<n[0]; ++i){
		std::cin >> c[i];
	}
	for(mask[0]=0; mask[0]<(1<<n[0]); ++mask[0]){
		for(mask[1]=0; mask[1]<(1<<n[1]); ++mask[1]){
			cnt = 0;
			for(i=0; i<n[0]; ++i){
				if(mask[0]&(1<<i)){
					continue;
				}
				for(j=0; j<n[1]; ++j){
					if(mask[1]&(1<<j)){
						continue;
					}
					if(c[i][j]=='#'){
						++cnt;
					}
				}
			}
			if(cnt == k){
				++ans;
			}
		}
	}
	std::cout << ans << std::endl;
	return 0;
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
#include <cstring>
#include <limits>
using namespace std;
#define ll long long int
#define X first
#define Y second
#define fw(i, start, end) for (ll i = start; i < end; ++i)
#define fe(i, start, end) for (ll i = start; i <= end; ++i)
#define L(T)  \
    ll T;     \
    cin >> T; \
    while (T--)
#define FASTIO                   \
    ios::sync_with_stdio(false); \
    cin.tie(nullptr);            \
    cout.tie(nullptr);
#define endl '\n'

double dp[302][302][302];
double ev[302][302][302];

int main()

{
    FASTIO
    ll n;
    cin >> n;
    ll
        a[n + 5];
    int one = 0, two = 0, three = 0;
    fe(i, 1, n)
    {
        cin >> a[i];
        if (a[i] == 1)
            one++;
        if (a[i] == 2)
        {
            two++;
        }
        if (a[i] == 3)
            three++;
    }
    memset(dp, -1, 0);
    // cout << "one  " << one << "  two  " << two << "  three  " << three << endl;
    dp[one][two][three] = 1;
    for (ll k = n; k >= 0; k--)
    {
        for (ll j = n; j >= 0; j--)
        {
            for (ll i = n; i >= 0; i--)
            {
                if (i == 0 && j == 0 && k == 0)
                    continue;
                if (i + j + k > n)
                    continue;
                double pw = (double)(n - (i + j + k)) / n;
                double ew = pw / (1 - pw) + 1;
                ev[i][j][k] += ew * dp[i][j][k];
                if (i != 0)
                {
                    dp[i - 1][j][k] += (double)((double)(dp[i][j][k] * i) / (i + j + k));
                    ev[i - 1][j][k] += (double)((double)(ev[i][j][k] * i) / (i + j + k));
                }
                if (j != 0)
                {
                    dp[i + 1][j - 1][k] += (double)((double)(dp[i][j][k] * j) / (i + j + k));
                    ev[i + 1][j - 1][k] += (double)((double)(ev[i][j][k] * j) / (i + j + k));
                }
                if (k != 0)
                {
                    dp[i][j + 1][k - 1] += (double)((double)(dp[i][j][k] * k) / (i + j + k));
                    ev[i][j + 1][k - 1] += (double)((double)(ev[i][j][k] * k) / (i + j + k));
                }
            }
        }
    }
    double ans = ev[0][0][0];
    // cout << ans << "\n";
    printf("%.18lf\n", ans);
    return 0;
}

Measured memory_bytes: 430336
using System;
using System.Collections.Generic;
public class ABC126A {
    public static void Main() {
        int N, K;
        string[] str = System.Console.ReadLine().Split(' ');
        N = int.Parse(str[0]);
        K = int.Parse(str[1]);
        string S = System.Console.ReadLine();
        string ans = "";
        for(int i = 0; i< S.Length; i++) {
            if (i == K - 1) {
               ans += char.ToLower(S[K - 1]);
            } else {
               ans += S[i];
            }
        }
        System.Console.WriteLine(ans);
    }
}

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

typedef long long ll;

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

int main(){
    int N;
    cin >> N;

    vector<int> A(N),B(N),C(N);
    rep(i,N) cin >> A.at(i);
    rep(i,N) cin >> B.at(i);
    rep(i,N) cin >> C.at(i);

    sort(A.begin(),A.end());
    sort(B.begin(),B.end());
    sort(C.begin(),C.end());

    ll num = 0;
    for(auto itr=B.begin(); itr!=B.end(); itr++){
        ll a_num = 0;
        ll c_num = 0;
        auto itr_a = lower_bound(A.begin(), A.end(), *itr);
        auto itr_c = upper_bound(C.begin(), C.end(), *itr);
        a_num = itr_a - A.begin();
        if(itr_c != C.end()) c_num = C.end() - itr_c;
        num += a_num*c_num;

    }
    cout << num << endl;
    return 0;

} 


Measured memory_bytes: 4600
import java.util.Scanner;

public class Main{
  public static void main(String[] args){
    Scanner scanner = new Scanner(System.in);
    String N = scanner.next();
    boolean a = N.charAt(0) == '7' || N.charAt(1) == '7' || N.charAt(2) == '7';
    String answer = a ? "Yes" : "No";
    System.out.println(answer);
  }
}

Measured memory_bytes: 26932
#include<iostream>
#include<string>
using namespace std;
int main(){
  string str;
  cin >> str;
  while(str[0]!='0'){
    int i,o=0;
    for(i=0;i<str.size();i++){
      o+=str[i]-'0';
    }
    cout << o << endl;
    cin >> str;
  }
  return 0;
}


Measured memory_bytes: 3128
mod=998244353
n,s=map(int,input().split())
a=list(map(int,input().split()))
dp=[[0]*(s+1) for _ in range(n+1)]
dp[0][0]=1;ans=0
for i in range(n):
	for j in range(s+1):
		dp[i+1][j]+=dp[i][j]
		dp[i+1][j]%=mod
		if j+a[i]<=s:
			if j==0:
				dp[i+1][a[i]]+=i+1
			else:
				dp[i+1][j+a[i]]+=dp[i][j]
				dp[i+1][j+a[i]]%=mod
		if j+a[i]==s:
			ans+=dp[i+1][j+a[i]]*(n-i)
			ans%=mod
print(ans)


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

using namespace std;

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

    int result = 0;

    vector<int> B;
    int num;
    for(int i=0;i<N;i++){
        cin >> num;
        B.push_back(num);
    }

    result += B[0];

    for(int i=1; i<N;i++){
        result += min(B[i-1],B[i]);
    }

    result += B[N];

    cout << result << endl;
}

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

int main(){
  int N;  //根つき木とすることで、単一インデックスで辺を指定する
  
  cin >> N;
  
  vector<int> color(N,-1); // -1は未確定
  
  vector<vector<int>> to(N);
  
  vector<pair<int,int>> vec;
  for(int i = 0; i < N-1; i++){ 
    int a,b; cin >> a >> b; a--; b--;
    to[a].push_back(b); to[b].push_back(a);
    vec.push_back({a,b});
  }
  
  queue<int> Q; Q.push(0); color[0] = 0; 
  
  vector<bool> visited(N,false);
  
  visited[0] = true;
  
  int S = 0;
  
  map<pair<int,int>,int> mp;
  
  while(!Q.empty()){ 
    int p = Q.front(); Q.pop();
    
    visited[p] = true;
    
    S = max(S,(int)to[p].size());
    
    int paint = 1;
   
    for(auto ne : to[p]){
      if( visited[ne]){continue;} //親へは飛ばない
      
      if( paint == color[p]){ paint++;}
      
      color[ne] = paint;
      
      mp[{p,ne}] = paint;
      
      Q.push(ne); paint++;
    }
  }
  
  cout << S << endl;
  
  for(int i = 0; i < N-1; i++){
    cout << mp[vec[i]] << endl;
  }
  
  
  return 0;
}

Measured memory_bytes: 13428
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
const long double PI = acos(-1.0L);
const long long MOD = 1000000007LL;
//const long long MOD = 998244353LL;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
template<class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true;} return false; }
template<class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true;} return false; }
///////////////////////////////////////////////////////////////////////////////////////////////////

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

    ll ans = 0;
    for (ll i = 1; i*i <= N; i++) {
        if (N%i==0) {
            if (i < N/i-1) ans += N/i-1;
        }
    }

    cout << ans << endl;
}


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


int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n,i;
	cin >> n >> i;
	cout << n - i + 1 << endl;
 	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <queue>
#include <vector>
#include <string>
#define rep(i,n) for(int i=0;i<(n);++i)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const long long INF = 1LL << 60;
const int MAX = 1000005;
const int MOD = 1000000007;

const int MAXN = 1005;
const int MAXV = 1000000;
vector<int> to[MAXV];
int id[MAXN][MAXN];

int toId(int i,int j){
  if(i > j) swap(i,j);
  return id[i][j];
  //頂点番号を返す関数
}

bool visited[MAXV];
bool calculated[MAXV];
int dp[MAXV];

int dfs(int v){
  if(visited[v]){
    if(!calculated[v]) return -1;
    return dp[v];
  }
  visited[v] = true;
  dp[v] = 1;
  for(auto &u:to[v]){
    int res = dfs(u);
    if(res == -1) return -1;
    dp[v] = max(dp[v],res+1);
  }
  calculated[v] = true;
  return dp[v];
}

int main(){
  int n; cin >> n;
  vector<vector<int>> a(n,vector<int>(n-1));
  rep(i,n){
    rep(j,n-1){
      cin >> a[i][j];
      a[i][j]--;
    }
  }
  int v=0;
  rep(i,n){
      rep(j,n){
          if(i < j){
            id[i][j] = v++;
          }
      }
  }
  rep(i,n){
    rep(j,n-1){
      a[i][j] = toId(i,a[i][j]);
    }
    rep(j,n-2){
      to[a[i][j+1]].push_back(a[i][j]);
    }
  }
  int ans = 0;
  rep(i,v){
    int res = dfs(i);
    if(res == -1){
      cout << -1 << endl;
      return 0;
    }
    ans = max(ans,dfs(i));
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 52992
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.IOException;
import java.util.Set;
import java.util.TreeSet;

public class Main {

    @SuppressWarnings("unchecked")
    public static void main(String args[]) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));
        int n = Integer.parseInt(br.readLine());
        Set<String> dictionary = new TreeSet<String>();
        while (n-- > 0) {
            String[] command = br.readLine().split(" ");
            switch (command[0]) {
                case "insert":
                    dictionary.add(command[1]);
                    break;
                case "find":
                    bw.append(dictionary.contains(command[1]) ? "yes\n" : "no\n");
                    break;
            }
        }
        bw.flush();
    }

}


Measured memory_bytes: 191200
#include<bits/stdc++.h>
#define int ll
typedef long long ll;
using namespace std;
inline int read()
{
  char c; int sign=1;
  while ((c=getchar())<'0'||c>'9')
    if (c=='-') sign=-1;
  int res=(c-'0');
  while ((c=getchar())>='0'&&c<='9')
    res=(res<<1)+(res<<3)+c-'0';
  return res*sign;
}
inline void print(int x)
{
  if (x>9) print(x/10);
  putchar(x%10+'0');
}
inline void write(int x)
{
  if (x<0) putchar('-'),x=-x;
  print(x);
}
const int maxn=200005;
const ll P=1e9+7;
const int T=2005;
ll jc[maxn];
int a[maxn],n,m;
ll X[maxn],Y[maxn];
ll mp[4050][4050];
ll fac[maxn],inv[maxn],ifac[maxn];
int C(int x, int y) {
    return 1ll*fac[x]* ifac[y]%P*ifac[x-y]%P;
}
signed main()
{
  n=read();
  inv[0]=inv[1]=1;
  fac[0]=ifac[0]=1;
  for (int i=2;i<=10000;i++) inv[i]=1ll*(P-P/i)*inv[P%i]%P;
  for (int i=1;i<=10000;i++) fac[i]=1ll*fac[i-1]*i%P;
  for (int i=1;i<=10000;i++) ifac[i]=1ll*ifac[i-1]*inv[i]%P;
  for (int i=1;i<=n;i++) X[i]=read(),Y[i]=read();
  for (int i=1;i<=n;i++) mp[T-X[i]][T-Y[i]]++;
  for (int i=1;i<=T+T;i++)
  {
    for (int j=1;j<=T+T;j++)
    {
      mp[i][j]=(mp[i][j]+mp[i-1][j]+mp[i][j-1])%P;
    }
  }
  ll ans=0;
  for (int i=1;i<=n;i++) ans=(ans+mp[T+X[i]][T+Y[i]])%P;
  for (int i=1;i<=n;i++) ans=(ans+P-C(2*X[i]+2*Y[i],2*X[i]))%P;
  printf("%lld\n",(ans*inv[2])%P);
}

Measured memory_bytes: 133976
import java.util.*;

public class Main{

    public static void main(String[] args){

	Scanner sc = new Scanner(System.in);

	int a = sc.nextInt();
	int b = sc.nextInt();

	if(a<=b) System.out.println(a);

	if(a>b) System.out.println(a-1);
    }
}


Measured memory_bytes: 22612
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++) 
#define ALL(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
int N;
//??¨????????????????????????
bool is_prime[ 999999 + 1 ];
int E( const int N )
{
    int cnt{};
    for( int i = 0; i <= N; i++ )
    {
        is_prime[ i ] = true;//?????????
    }    
    for( int i = 2; i <= N; i++ )
    {
        if( is_prime[ i ] )
        {
            for( int j = 2 * i; j <= N; j += i )
            {
                is_prime[ j ] = false;
            }
            cnt++;
        }
    }
    return cnt;
}
int main()
{
    while( cin >> N )
    {
        cout << E( N ) << endl;
    }
    return 0;
}

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

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i,n) cin >> a.at(i);
    sort(a.rbegin(), a.rend());
    ll h = 0, w = 0;
    rep(i,n-1) {
        if (a.at(i) == a.at(i+1) && h == 0) {
            h = a.at(i);
            i += 2;
        }
        if (i < n && a.at(i) == a.at(i+1)) {
            w = a.at(i);
            break;
        }
    }
    cout << h * w << endl;
    return 0;
}

Measured memory_bytes: 3704
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n; i++)
#define PI 3.14159265359
#define INF 1000100100000000000
#define MOD 1000000007
#define all(x) (x).begin(),(x).end()
typedef long long ll;
#define P pair<int, int>
#define PP pair<P,P>
#define T tuple<int,int,int> 
using namespace std;

int main(){
    ll ans;
    ll a,b,c,d; cin >> a >> b >> c >> d;
    if((a<0 && b<0) && (c<0 || d<0)) ans=a*c;
    else if((a<0 && b<0) && (c>=0 && d>=0)) ans=b*c;
    else if(a<0 && b>=0 && c<0 && d>=0) ans=max(a*c,b*d);
    else if(a<0 && b>=0 && c>=0 && d>=0) ans=b*d;
    else if(a<0 && b>=0 && c<0 && d<0) ans=a*c;
    else if(a>=0 && b>=0 && c<0 && d<0) ans=a*d;
    else ans=b*d;
    cout << ans << endl;
return 0;
}



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

using ll = long long;
using Pi = pair<int, int>;
using Pl = pair<ll, ll>;
using vint = vector<int>;
using vvint = vector<vint>;
using vvvint = vector<vvint>;
using vdouble = vector<double>;
using vvdouble = vector<vdouble>;
using vvvdouble = vector<vvdouble>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using uint = unsigned int;
using ull = unsigned long long;

template<typename T> using uset = unordered_set<T>;
template<typename T1, typename T2> using umap = unordered_map<T1, T2>;

constexpr int INF = (1 << 30) - 1;
constexpr ll LLINF = 1LL << 60;
constexpr int dy[] = {1, 0, -1, 0, 1, -1, -1, 1};
constexpr int dx[] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr char el = '\n';
constexpr int mod = 1000000007;
constexpr int mod2 = 998244353;
template<typename T> T gcd(T a, T b) { return (b ? gcd(b, a % b) : a); }
template<typename T> T lcm(T a, T b) { return (a / gcd(a, b) * b); }
template<typename T1, typename T2>
inline bool chmin(T1 &a, T2 b) { return (a > b && (a = b, true)); }
template<typename T1, typename T2>
inline bool chmax(T1 &a, T2 b) { return (a < b && (a = b, true)); }

template<typename T>
vector<T> makeVector(size_t a, T b) { return (vector<T>(a, b)); }
template<typename... Ts>
auto makeVector(size_t a, Ts... ts) { 
	return (vector<decltype(makeVector(ts...))>(a, makeVector(ts...)));
}

template<typename T>
bool isin(T y, T x, T h, T w) { return (0 <= y && 0 <= x && y < h && x < w); }
template<typename T>
bool isin1(T y, T x, T h, T w) { return (0 < y && 0 < x && y <= h && x <= w); }

template<typename T>
ostream& operator <<(ostream &os, vector<T> &v) {
	if (v.size()) {
		os << v[0];
		for (int i = 1; i < v.size(); i++) os << " " << v[i];
	}
	return (os);
}

template<typename T>
istream& operator >>(istream &is, vector<T> &v) {
	for (auto &u : v) is >> u;
	return (is);
}

template<typename T1, typename T2>
istream& operator >>(istream &is, pair<T1, T2> &p) {
	return (is >> p.first >> p.second);
}


void Main() {
	priority_queue<Pl> d1, d2;
	int N; cin >> N;
	vll A(N), B(N);
	for (int i = 0; i < N; i++) {
		cin >> A[i] >> B[i];
		d1.emplace(A[i]+B[i], i);
		d2.emplace(A[i]+B[i], i);
	}

	bitset<100005> flag;
	ll point = 0;
	for (int i = 0; i < N; i++) {
		if (i&1) {
			while (!d2.empty() && flag[d2.top().second]) {
				d2.pop();
			}
			point -= B[d2.top().second];
			flag[d2.top().second] = true;
			d2.pop();
		} else {
			while (!d1.empty() && flag[d1.top().second]) {
				d1.pop();
			}
			point += A[d1.top().second];
			flag[d1.top().second] = true;
			d1.pop();
		}
	}
	cout << point << endl;
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(0);
	cout << fixed << setprecision(20);
	Main();
	return (0);
}



Measured memory_bytes: 8252
#include <bits/stdc++.h>
using namespace std;
#define finish(x) return cout << x << endl, 0
#define ll long long

const int N = 3001;

int a, b, c, d, dp[N][N], mod = 998244353;

int solve(int x, int y){
    if(x == a && y == b) return 1;
    int &ret = dp[x][y];
    if(ret != -1) return ret;
    ret = 0;
    if(x > a) ret = (ret + 1LL * y * solve(x - 1, y)) % mod;
    if(y > b) ret = (ret + 1LL * x * solve(x, y - 1)) % mod;
    if(x > a && y > b) ret = (ret - 1LL * (x - 1) * (y - 1) % mod * solve(x - 1, y - 1) % mod + mod) % mod;
    return ret;
}
int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    memset(dp, -1, sizeof dp);
    cin >> a >> b >> c >> d;
    cout << solve(c, d) << endl;
}


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


using namespace std;
#define rep(i,n) for (int i = 0; i < (int)(n); ++i)
#define reps(i,n) for (int i = 1; i <= (int)(n); ++i)
#define repd(i,n) for (int i = (int)(n - 1); i >= 0; --i)
#define repds(i,n) for (int i = (int)(n); i > 0; --i)
#define loop(i,x,n) for (int i = (int)(x); i < (n); ++i)
#define loops(i,x,n) for (int i = (int)(x); i <= (n); ++i)
#define loopd(i,x,n) for (int i = (int)(x); i > (n); --i)
#define loopds(i,x,n) for (int i = (int)(x); i >= (n); --i)
#define itrep(i,s) for (auto i = begin(s); i != end(s); ++i)
#define itrepd(i,s) for (auto i = --end(s); i != begin(s); --i)
#define all(f,x,...) [&](decltype(x)& whole) { return (f)(begin(whole), end(whole), ##__VA_ARGS__); }(x)
#define rall(f,x,...) [&](decltype(x)& whole) { return (f)(rbegin(whole), rend(whole), ##__VA_ARGS__); }(x)
using ll = long long;
using ld = long double;
constexpr ll inf = static_cast<ll>(1e17);
constexpr int iinf = static_cast<int>(1e9);
constexpr double dinf = 1e10;
constexpr ld ldinf = 1e17;
ll mod = static_cast<ll>(1e9 + 7);
std::ostream& endn(std::ostream& os) { return os.put(os.widen('\n')); }
template<class T> constexpr int sz(const T& a) { return (int)a.size(); }
template<class T> constexpr T pow2(const T a) { return a * a; }
template<class T, class ... Args> constexpr T mins(T& a, Args... args) { return a = min<T>({ a, args... }); }
template<class T, class... Args> constexpr T maxs(T& a, Args... args) { return a = max<T>({ a,args... }); }

std::vector<int> zarray(const std::string& s) {
    int c = 0;
    std::vector<int> A(s.size(), 0);
    for (int i = 1; i < (int)s.size(); i++) {
        if (i + A[i - c] < c + A[c]) {
            A[i] = A[i - c];
        }
        else {
            int j = std::max(0, c + A[c] - i);
            while (i + j < (int)s.size() && s[j] == s[i + j]) ++j;
            A[i] = j;
            c = i;
        }
    }
    A[0] = s.size();
    return A;
}

int n;
std::string s;
void solve() {
    cin >> n >> s;

    int ans = 0;
    rep(i, n) {
        auto v = zarray(s.substr(i));
        rep(j, n - i)
            maxs(ans, min(v[j], j));
    }

    cout << ans << endn;

}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
    cout << flush;
    return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import sys
# ----------------------------------------------------------------
# Use Solve Function

def solve(lines):
    N = int(lines.pop(0))
    if N < 1000:
        print("ABC")
    else:
        print("ABD")

#
# main
#

# 1. use list instead of stdin

# contents = '''\
# 5\
# '''
# lines = contents.split('\n')

# 2. use stdin

lines = [x.strip() for x in sys.stdin.readlines()]

#
# solve !!
#
solve(lines)

Measured memory_bytes: 3060
#![allow(unused_imports, unused_macros, dead_code)]

macro_rules! min {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        it.next().map(|z| it.fold(z, |x, y| min!(x, y)))
    }};
    ($x:expr) => ($x);
    ($x:expr, $($ys:expr),*) => {{
        let t = min!($($ys),*);
        if $x < t { $x } else { t }
    }}
}
macro_rules! max {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        it.next().map(|z| it.fold(z, |x, y| max!(x, y)))
    }};
    ($x:expr) => ($x);
    ($x:expr, $($ys:expr),*) => {{
        let t = max!($($ys),*);
        if $x > t { $x } else { t }
    }}
}
macro_rules! ewriteln {
    ($($args:expr),*) => { let _ = writeln!(&mut std::io::stderr(), $($args),*); };
}
macro_rules! trace {
    ($x:expr) => {
        #[cfg(debug_assertions)]
        eprintln!(">>> {} = {:?}", stringify!($x), $x)
    };
    ($($xs:expr),*) => { trace!(($($xs),*)) }
}
macro_rules! flush {
    () => {
        std::io::stdout().flush().unwrap();
    };
}
macro_rules! put {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        if let Some(x) = it.next() { print!("{}", x); }
        for x in it { print!(" {}", x); }
        println!("");
    }};
    ($x:expr) => { println!("{}", $x) };
    ($x:expr, $($xs:expr),*) => { print!("{} ", $x); put!($($xs),*) }
}

const M: i64 = 1_000_000_007;

fn main() {
    let mut sc = Scanner::new();
    let n: u64 = sc.cin();

    let mut ans = 0;
    for a in 1..n {
        let mut b_left = 1; // "0 < a * b < n" holds
        let mut b_right = n; // doesnt hold

        for _ in 0..30 {
            let mid = (b_left + b_right) / 2;
            if a * mid < n {
                b_left = mid;
            } else {
                b_right = mid;
            }
        }
        // trace!(a, b_left, b_right);
        ans += b_left;
    }

    put!(ans);
}

use std::collections::VecDeque;
use std::io::{self, Write};
use std::str::FromStr;

struct Scanner {
    stdin: io::Stdin,
    buffer: VecDeque<String>,
}
impl Scanner {
    fn new() -> Self {
        Scanner {
            stdin: io::stdin(),
            buffer: VecDeque::new(),
        }
    }
    fn cin<T: FromStr>(&mut self) -> T {
        while self.buffer.is_empty() {
            let mut line = String::new();
            let _ = self.stdin.read_line(&mut line);
            for w in line.split_whitespace() {
                self.buffer.push_back(String::from(w));
            }
        }
        self.buffer.pop_front().unwrap().parse::<T>().ok().unwrap()
    }
    fn chars(&mut self) -> Vec<char> {
        self.cin::<String>().chars().collect()
    }
    fn vec<T: FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.cin()).collect()
    }
}


Measured memory_bytes: 2164
#include<bits/stdc++.h>
#define PI 3.141592653589
#define ll long long
using namespace std;

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

  vector<ll> h(n);

  for(ll i=0; i<n; ++i){
    cin >> h[i];
  }
  
  sort(h.rbegin(), h.rend());
  
  
  for(ll i=0; i<min(n, k); ++i){
    h[i] = 0;
  }
    
  ll sum =0;

  for(ll i=0; i<n; ++i){
    sum += h[i];
  }

  cout << sum;
    


}


Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <iomanip>
#include <math.h>

using namespace std;

int main()
{
  int N, D;
  cin >> N >> D;

  if (N % (D * 2 + 1) == 0) cout << N / (D * 2 + 1) << endl;
  else cout << N / (D * 2 + 1) +1 << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
bool p(int a){
    if(0 < a && a < 13) return true;
    else return false;
}
int main(){
    double n, k;
    cin >> n >> k;
    double sum = 0;
    for (int i = 1; i < n+1; i++)
    {
        int s = ceil(log2(k/i)) ;
        if(s>-1) sum += pow(0.5,s);
        else sum  += 1;
    }
    cout << fixed << setprecision(20) <<  sum/n << endl;
}

Measured memory_bytes: 4188
#include <bits/stdc++.h>
#include <sstream>
#include <iomanip>
#define ll long long
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define min_3(a,b,c) min(a,min(b,c))
#define max_3(a,b,c) max(a,max(b,c))
#define nout(ans) cout << (ans) << "\n"
#define sout(ans) cout << (ans) << " "
using namespace std;

const double pi = 3.14159265359;
const ll INF = 1e12;
const ll MOD = 1e9;
const ll N = 1e5 + 5;
/*
Decimal Places: cout << fixed << setprecision(n) << ans << endl

String to integer:
stringstream dark(s);
int x = 0; dark >> x;
*/

bool compare(const pair<int, int>&i, const pair<int, int>&j)
{
    return i.second < j.second;
}


ll n, W, w[102], v[102], dp[N], s=0;

void solve()
{
    cin >> n >> W;
    for (int i=1; i<=n; i++) cin >> w[i] >> v[i], s+=v[i];
    fill(dp,dp+N,INF);
    dp[0]=0;
    
    for (int i=1; i<=n; i++) {
        for (int j=s; j>=v[i]; j--) {
            dp[j] = min(dp[j], dp[j-v[i]] + w[i]);
        }
    }
    

    ll ans=0; 
    //for (int i=1; i<=s; i++) sout(dp[i]);
    for (int i=0; i<=s; i++) {
        if (dp[i]<=W) ans=max(ans, (ll)i);
    }nout(ans);
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    int t = 1;
    //cin >> t;
    for (int i=1; i<=t; i++)
    {
        solve();
    }
    return 0;
}

Measured memory_bytes: 4384
#include<stdio.h>
int main (void){
  int n,k,d[100],a[100][100],i,j,ans[100],aans=0;
  
  for(i=0;i<100;i++){for(j=0;j<100;j++){a[i][j]=0;}ans[i]=0;}
  scanf("%d%d",&n,&k);
  for(i=0;i<k;i++){
    scanf("%d",&d[i]);
    for(j=0;j<d[i];j++){scanf("%d",&a[i][j]);}  
  }
//  printf("%d %d\n",n,k); 
//    for(i=0;i<k;i++){printf("%d\n",d[i]);
//    for(j=0;j<d[i];j++){printf("%d ",a[i][j]);}  
//                   printf("\n");
//  }
  for(i=0;i<k;i++){for(j=0;j<d[i];j++){ans[a[i][j]-1]=1;}}
//  for(i=0;i<n;i++){printf("%d\n",ans[i]);}
  
  for(i=0;i<n;i++){if(ans[i]==0){aans++;}}
  printf("%d\n",aans);
}

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

#define iota(i,n,b,s) for(int i=int(b);i!=int((b)+(s)*(n));i+=(s))
#define range(i,n,m) iota(i,(((n)>(m))?((n)-(m)):((m)-(n))),(n),((n)>(m)?-1:1))
#define rep(i,n) iota(i,(n),0,1)
#define loop for(;;)

#define INF (1e9)
#define EPS (1e-9)
#define cons(a,b) (make_pair(a,b))
#define car(a) (a.first)
#define cdr(a) (a.second)
#define cadr(a) (car(cdr(a)))
#define cddr(a) (cdr(cdr(a)))
#define all(a) a.begin(), a.end()
#define trace(var) cerr<<">>> "<<#var<<" = "<<var<<endl;

typedef long long Integer;
typedef long double Real;
typedef vector<int> vi;
typedef vector<string> vs;
typedef map<string,int> Dictionary;
const Real PI = acos(-1);

template<class S, class T>
ostream& operator<<(ostream& os, pair<S,T> p) {
  os << '(' << car(p) << ", " << cdr(p) << ')';
  return os;
}

template<class T>
ostream& operator<<(ostream& os, vector<T> v) {
  if (v.size() == 0) {
    os << "(empty)";
    return os;
  }
  os << v[0];
  for (int i=1, len=v.size(); i<len; ++i) os << ' ' << v[i];
  return os;
}

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

char u[] = {'I', 'V', 'X', 'L', 'C', 'D', 'M'};
int v[] =  {1, 5, 10, 50, 100, 500, 1000};

int value_of (char c) {
  rep (i, 7) {
    if (c == u[i]) return v[i];
  }
}

int div(int a, int b, int n) {
  a %= b;
  a = a * 10;
  if (n == 1) return (a/b);
  return div(a, b, n - 1);
}
bool* PrimeSieve(int n) {
  bool*s = new bool[n];
  for (int i = 0; i < n; ++i) s[i] = true;
  s[0] = s[1] = false;
  for (int i = 2; i < n; ++i)
    if (s[i]) for (int j = i << 1; j < n; j += i) s[j] = false;
  return s;
}

int main() {

  Real a, b;
  cin >> a >> b;
  printf("%0.10Lf\n", (a * b / 3.305785));

  return 0;
}

Measured memory_bytes: 1224
#!/usr/bin/env python

from collections import deque
import itertools as it
import sys
import math

sys.setrecursionlimit(10000000)

S = ["", "',.!?", "abcABC", "defDEF", "ghiGHI", 
"jklJKL", "mnoMNO", "pqrsPQRS", "tuvTUV", "wxyzWXYZ"]

for line in sys.stdin:
    ans = ''
    k = 0
    cnt = 0
    line = list(line)
    line[-1] = "-1"
    for c in line:
        if int(c) == k:
            cnt += 1
        else:
            if k == 0:
                ans += ' ' * cnt
            else:
                ans += S[k][cnt % len(S[k])]
            cnt = 0
            k = int(c)
    print ans


Measured memory_bytes: 5016
import kotlin.*


fun main(args: Array<String>) {
    Program().solve()
}

class Program {
    fun solve() {
        val sc = MyScanner()
        val n = sc.nextLong()
        val ans = (n -1)*n/2
        println(ans)
    }
}

class MyScanner {
    private var ptr = 0
    private var l = listOf<String>()

    fun next(): String {
        while (l.size <= ptr) {
            l = readLine()!!.split(' ')
            ptr = 0
        }
        return l[ptr++]
    }

    fun nextInt() = next().toInt()
    fun nextLong() = next().toLong()
    fun nextDouble() = next().toDouble()
    fun nextCharArray() = next().toCharArray()
    fun nextChar() = next()[0]

    fun list(): List<String> {
        ptr = l.size
        return readLine()!!.split(' ')
    }

    fun intList() = list().map { s -> s.toInt() }
    fun longList() = list().map { s -> s.toLong() }
    fun doubleList() = list().map { s -> s.toDouble() }

    fun array() = list().toTypedArray()
    fun intArray() = intList().toIntArray()
    fun longArray() = longList().toLongArray()
    fun doubleArray() = doubleList().toDoubleArray()
}


Measured memory_bytes: 36384