akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<algorithm>
#include<vector>
#include<bits/stdc++.h>
using namespace std;

#define int long long

#define pb push_back
#define mp make_pair
#define st first
#define nd second
typedef pair < int , int > pp;
const int mod = 1e9 + 7;
const int N   = 1e5 + 5;

int A[N],B[N],C[N],n,i,j,k,t,ans;

signed main(){
    cin >> n;
    for(i=1;i<=n;i++) scanf("%lld",&A[i]);
    for(i=1;i<=n;i++) scanf("%lld",&B[i]);
    for(i=1;i<=n;i++) scanf("%lld",&C[i]);
    sort(A+1 , A+n+1);
    sort(B+1 , B+n+1);
    sort(C+1 , C+n+1);
    
    for(i=j=k=1;i<=n;i++){
        
        for(; C[i] > B[j] && j <= n ; j++){
            for(; B[j] > A[k] && k <= n ; k++);
            t += k-1;
        }
        
        ans += t;
    }
    
    cout << ans;
    return 0;
}

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

const int MAX_N = 1e5+2, MOD=1e9+7;
int N, K;
int a[MAX_N],b[MAX_N];
vector<int> G[MAX_N];
bool ok;

void add_edge(int from, int to)
{
	G[from].push_back(to);
	G[to].push_back(from);
}

ll dfs(int x, int par)
{
	int cnt = 0;
	ll res = 1LL;
	for(int i=0;i<G[x].size();++i){
	    int y = G[x][i];
	    if(y != par){
			ll choice = 1LL*(K-1-cnt-((x==1)?0:1));
			if(choice <= 0){
				ok = false;
				return 0;
			}
	        (res *= choice*dfs(y,x)%MOD)%=MOD;
	        cnt++;
	    }
	}
	return res;
}
 
void solve()
{
	for(int i=1;i<=N;++i)if((int)G[i].size()+1>K){
		cout << 0 << '\n';
		return;
	}
	ok = true;
	ll ans = 1LL*K*dfs(1,0)%MOD;
	if(!ok) cout << 0 << '\n';
	else cout << ans << '\n';
}

int main()
{
	cin >> N >> K;
	for(int i=0;i<N-1;++i){
		cin >> a[i] >> b[i];
		add_edge(a[i],b[i]);
	}
	solve();
	return 0;
}

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

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> ii;
typedef tuple<ll, ll, ll> iii;
typedef vector<ll> vi;
typedef vector<ii> vii;
typedef vector<iii> viii;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
#define REP(i,n) for (ll i = 0; i < n; ++i)
#define REPR(i,n) for (ll i = n-1; i >= 0; --i)
#define FOR(i,m,n) for (ll i = m; i < n; ++i)
#define FORR(i,m,n) for (ll i = n-1; i >= m; --i)
#define FORE(x,xs) for (const auto& x : xs)
#define ALL(v) v.begin(), v.end()
#define CHMIN(x,y) x = min(x, y)
#define CHMAX(x,y) x = max(x, y)

const int MAX = 2e5+10;

int N;
int A[MAX];

vi solve() {
    vi ans, check(MAX);
    REP (i, N) check[A[i]]++;

    ll all = 0;
    REP (i, MAX) all += check[i] * (check[i] - 1) / 2;
    REP (i, N) ans.push_back(all - check[A[i]] + 1);
    return ans;
}

int main() {
    cin >> N;
    REP (i, N) cin >> A[i];
    FORE (x, solve()) cout << x << endl;
}

Measured memory_bytes: 5076
s = input()

if s=="SAT":
  print(1)
elif s=="FRI":
  print(2)
elif s=="THU":
  print(3)
elif s=="WED":
  print(4)
elif s=="TUE":
  print(5)
elif s=="MON":
  print(6)
else:
  print(7)

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

#define ll long long

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

    int n;
    cin >> n;

    int a[n];

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

    //sort(a, a+n);

    int i = 0;
    int j = n-1;
    int sum_l = a[i];
    int sum_r = a[j];

    while(j - i >= 2){
        if (sum_l < sum_r){
            i++;
            sum_l += a[i];
        }else if (sum_l > sum_r){
            j--;
            sum_r += a[j];
        }else {
            i++;
            sum_l += a[i];
        }
    }

    cout << abs(sum_l - sum_r) << endl;

    return 0;
}



Measured memory_bytes: 256
import numpy as np
import sys

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    divisors.sort()
    return divisors

if __name__ == "__main__":
    X = int(input())
    divs = make_divisors(X)
    #print(divs)
    a = 0
    while True:
        for d in divs:
            b_p = 0
            b_n = 0
            while True:
                b_p += d
                b_n -= d
                #print(b_p)
                if a**5 - b_p**5 == X:
                    #print(a)
                    #print(b_p)
                    print(a,b_p)
                    #print("{} {}".format(int(a), int(b_p)))
                    sys.exit()
                if a**5 - b_n**5 == X:
                    #print("{} {}".format(int(a), int(b_n)))
                    print(a,b_n)
                    sys.exit()
                if b_p > a:
                    #print('break')
                    break
        a += 1

Measured memory_bytes: 27144
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> int_pair;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define CLR(mat) memset(mat, 0, sizeof(mat))
const int N=100001;
 
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	ll n,k=0,a[N],l[2];
	cin>>n;
	CLR(a);CLR(l);
	FOR(i,1,n+1){
		cin>>a[i];
	}
	sort(a,a+N);
	for(int i=N-1;i>=0;i--){
		if(a[i]==a[i-1]){
			l[k]=a[i];
			--i;
			k++;
		}
		if(k==2)break;
	}
	cout<<l[0]*l[1]<<endl;
	return 0;
}

Measured memory_bytes: 1024
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//イテレータあるけど順序保持しないmap
#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列

// vectorの重複削除
// std::sort(test.begin(), test.end());
// test.erase(std::unique(test.begin(), test.end()), test.end());

using namespace std;
using ll = long long;
using P = pair<int, int>; // vector<P> ba(n); みたいな感じですぐ使える ba[i] = P(a, b); make_pairをしなくてもいい
// typedef vector<int> v;
template <class T>ostream &operator<<(ostream &o,const vector<T>&v){o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}
#define debug(v) {cerr<<"\033[1;36m[debug]\033[m "<<#v<<" : "<<v<<endl;}
#define rep(i, c) for(int i = 0; i < int(c); i++)
#define ALL(x) (x).begin(), (x).end() //sort(ALL(obj))みたいな
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値
#define pb push_back //
// const int MOD = 1000000007;
// string alpha="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
// printf("%.20f\n", ans); あれ
// const double PI = 3.141592653589793238462643383;



int main() {
  int n;
  cin>>n;
  //int a;
  bool ans = false;
  rep(i,n) {
    char num; cin>>num;
    if (num == 'Y') {
      cout << "Four" << endl;
      return 0;
    }
  }
  cout << "Three" << endl;
}


Measured memory_bytes: 3048
#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define REP(i, n) FOR(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define bit(x) (1L << (x))
using ll = long long;
using namespace std;

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

int main() {
  int h, w, n; cin >> h >> w >> n;
  int y, x; cin >> y >> x;
  --y; --x;
  string s, t; cin >> s >> t;

  int l = 0, r = w - 1, u = 0, d = h - 1;

  for(int i=n-1; i>=0; i--){
    // L
    if(t[i] == 'R') l = max(0, l - 1);
    if(s[i] == 'L') l += 1;
    
    // R
    if(t[i] == 'L') r = min(w - 1, r + 1);
    if(s[i] == 'R') r -= 1;
  
    // U
    if(t[i] == 'D') u = max(0, u - 1);
    if(s[i] == 'U') u += 1;

    // D
    if(t[i] == 'U') d = min(h - 1, d + 1);
    if(s[i] == 'D') d -= 1;

    // check
    if(r < l || d < u){
      cout << "NO" << endl;
      return 0;
    }
  }

  bool ok = l <= x && x <= r && u <= y && y <= d;
  cout << (ok ? "YES" : "NO") << endl;
  
  return 0;
}


Measured memory_bytes: 776
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String S = (String) sc.nextLine();
		if (S.charAt(2) == S.charAt(3)) {
			if (S.charAt(4) == S.charAt(5)) {
				System.out.println("Yes");
			} else {
				System.out.println("No");
			}
		} else {
			System.out.println("No");
		}

		sc.close();
	}
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
#define D(x) cout << #x << "=" << x << endl
#define De(...)
using namespace std; 

int _; 
 
inline int gcd(int a,int b)
{
    while(b^=a^=b^=a%=b);
    return a;
}

int k;

int main()
{
	//for(scanf("%d",&_);_;_--)
	scanf("%d",&k);
	int ans=k*360/gcd(k,360);
	printf("%d\n",ans/k);
	return 0;
}


Measured memory_bytes: 3812
if __name__ == "__main__":
    S = input()
    word_arr = ["A","T","G","C"]
    max_count,count = 0,0
    for c in S:
        if c in word_arr:
            count += 1
        else:
            max_count = max(count,max_count)
            count = 0
    max_count = max(count,max_count)
    print(max_count)

Measured memory_bytes: 9116
#include <bits/stdc++.h>
using namespace std;
 
int main(){
    int A, B, C;
    cin >> A >> B >> C;

    int cost = 0;
    int a = abs(B-A);
    int b = abs(C-B);
    int c = abs(C-A);
    
    cout << a + b + c - max(a, max(b, c)) << endl;
}

Measured memory_bytes: 256
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr


arr = factorization(int(input()))
res = 0

if arr[0][0] != 1:
    
    for i in arr:
        cnt = 1
        while(i[1]>=cnt):
            i[1] -= cnt
            cnt += 1
            res +=1
            
print(res)


Measured memory_bytes: 9376
/** "Ever tried.
         Ever failed.
               No matter.
                   Try Again.
                        Fail again.
                             Fail better.**/
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define ll long long
#define bp  __builtin_popcount
#define pb push_back
#define loop(i,n) for(int i = 0;i < int(n);i++)
#define sz(s) (int)(s.size())
#define all(x) x.begin(), x.end()
#define allr(x) x.rbegin(), x.rend()
#define setdp memset(dp,-1,sizeof(dp))
#define db(x) cout<<" LOOK "<<(#x)<<" = "<<x <<'\n'
#define NumofDigits(n)   ((long long)log10(n)+1)
#define arr array
using namespace std;
using namespace __gnu_pbds;
typedef tree<int,null_type,less<int>,rb_tree_tag, tree_order_statistics_node_update> indexed_set;
const int maxn=1e5+5;
const  double EPS = 1e-9;
const int MOD = 1e9+7;
/*
ll gcd(ll a, ll b) { return !b ? a : gcd(b, a % b); }
ll lcm(ll a, ll b) { return (a / gcd(a, b)) * b; }
ll fastpow(ll b, ll p)
{if(!p)return 1;ll ret = fastpow(b, p >> 1);ret *= ret;if(p&1)ret*= b;return ret;}
int dx[] = {- 1, 0, 0, 1, 0 };
int dy[] = { 0,- 1, 1, 0, 0 };*/
inline void File()
{
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
#endif
}

int main()
{
    ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
    int n,k;
    cin>>n>>k;
    ll ans=0;
    for(int i=0;i<n;i++)
    {
        int x;
        cin>>x;
        int mn=min(x,abs(k-x));
        ans+=(mn*2);
        mn=1e9;
    }
    cout<<ans<<endl;
}


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

int main() {
	int n;
	cin >> n;
	string s;
	cin >> s;
	vector<vector<int>>weS(n, vector<int>(2,0));
	for (int i = 0; i < n; i++) {
		if (i == 0) {
			if (s.at(i) == 'W')weS.at(i).at(0)++;
			else weS.at(i).at(1)++;
		}
		else {
			if (s.at(i) == 'W') {
				weS.at(i).at(0) = weS.at(i - 1).at(0) + 1;
				weS.at(i).at(1) = weS.at(i - 1).at(1);
			}
			else {
				weS.at(i).at(0) = weS.at(i - 1).at(0);
				weS.at(i).at(1) = weS.at(i - 1).at(1) + 1;
			}
		}
	}
	ll ans = 1000000;
	for (int i = 0; i < n; i++) {
		ll e, w;
		if (i == 0) {
			e = 0;
			w = weS.at(n - 1).at(0) - weS.at(i).at(0);
		}
		else {
			e = weS.at(i - 1).at(1);
			w = weS.at(n - 1).at(0) - weS.at(i).at(0);
		}
		//cout << "e:" << e << " w:" << w << endl;
		ll res = n - e - 1 - w;
		//cout << res << endl;
		ans = min(ans, res);
	}
	cout << ans << endl;
}

Measured memory_bytes: 16900
#include<iostream>
#include <climits>
#include<vector>
#include<numeric>
#include<algorithm>
#include<string>
#include<cmath>
#include<set>
#include<map>
#include<stack>
#include<queue>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;

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

void shellSort(vector<ll> &A, int n) {
	int cnt = 0;
	vector<int> G;
	G.push_back(1);
	for (int i = 1;G[i - 1] <= n / 4;i++) G.push_back(2 * G[i - 1]);
	reverse(G.begin(), G.end());
	int m = G.size();
	for (int i = 0;i < m;i++) cnt += insertionSort(A, n, G[i]);
	cout << m << "\n";
	for (int i = 0;i < m;i++) {
		if (i != m - 1) cout << G[i] << " ";
		else cout << G[i] << "\n";
	}
	cout << cnt << "\n";
	for (int i = 0;i < n;i++) cout << A[i] << "\n";
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int n;
	cin >> n;
	vector<ll> A(n);
	REP(i, n) cin >> A[i];
	shellSort(A, n);

	return 0;
}


Measured memory_bytes: 10652
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define f(a, b) for (ll i = a; i <= b; i++)
#define pb push_back
#define pf push_front
#define mp make_pair
using namespace std;
#define N 200005
const ll INF = 1000000000000000001;
const ll MOD = 1000000007;

//vector< vector<ll> > g(N);
//vector< pair<ll, pair< ll, ll > > > g(N);
//ll vis[N] = {0}, par[N] = {0}, child[N] = {0},cnt = 0;


void solve(){
    string s, t; cin >> s >> t;
    ll ans = -INF, n = s.size(), m = t.size();
    for(ll i=0; i+m<=n; i++){
        ll cnt=0;
        for(ll j=0; j< m; j++){
            if(t[j] == s[i+j]) cnt++;
        }
        ans = max(ans, cnt);
    }
    cout << m- ans << "\n";
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    #ifndef ONLINE_JUDGE
        freopen("input.txt","r",stdin);
        freopen("out.txt","w",stdout);
    #endif
   //ll t;cin >> t;for(ll index=1; index<=t; index++){
        //cout << "Case #" << index << ": " ;
        solve();
   // }
    return 0;
}

Measured memory_bytes: 3612
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long ll;
const int MOD = 1000000007;
int main()
{
  int N;
  cin >> N;
  vector<ll>A(N);
  rep(i,N)cin >> A[i];
  vector<ll>d(N+1),xd(N+1);
  d[0]=0;xd[0]=0;
  rep(i,N)d[i+1]=d[i]+A[i];
  rep(i,N)xd[i+1]=xd[i]^A[i];

  ll ans=0;
  int r=0;
  rep(l,N){
    while (r<N&&(xd[r+1]^xd[l])==d[r+1]-d[l])r++;
    ans+=r-l;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 4992
from collections import Counter


def solve(s, ch):
    ret = 0
    dist = -1
    n = len(s)
    l = [0]*n
    for i in reversed(range(n)):
        if s[i] == ch:
            dist = 0
        elif dist == -1:
            l[i] = dist
        else:
            dist += 1
            l[i] = dist
    if max(l) > l.count(-1):
        ret = max(l)
    else:
        ret = l.count(-1)
    return ret


s = input()
C = Counter(s)
ans = len(s)+2
for i, v in C.most_common():
    ans = min(ans, solve(s, i))
print(ans)


Measured memory_bytes: 3316
#include <iostream>
#include <algorithm>
#include <array>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <string>
#include <tuple>
#include <utility>
#include <functional>
#include <sys/time.h>
#include <iomanip>

using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
#define REP(i, m, n) for(int i = (m); i < (n); ++i)
#define rep(i, n) REP(i, 0, n)
#define all(s) (s).begin(), (s).end()
#define pb push_back
#define fs first
#define sc second
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;}
template <typename T>
ll pow2(const T n){return (1LL << n);}
void setp(const int n){cout << fixed << setprecision(n);}
constexpr int INF = 1e9+1;
constexpr ll LINF = 1e18+1;
constexpr ll MOD = 1e9+7;
//constexpr ll MOD = 998244353;
constexpr ld EPS = 1e-11;
const ld PI = acos(-1);

constexpr int BEAM_SIZE = 2000;
constexpr int SZ = 26;
constexpr int D = 365;
array<int, SZ> C;
int SUM = 0;
array<array<int, SZ>, D> S;

struct State {
	array<short, SZ> last = {};
	array<char, D> ans;
	int score = 0, sum = 0;

	void update_score(int d, int t) {
		score += S[d][t];
		sum -= C[t] * (d + 1 - last[t]);
		last[t] = d + 1;
		sum += SUM;
		score -= sum;
	}

	int next_eval(int d, int t){
		int res = score;
		res += S[d][t];
		res += C[t] * (d + 1 - last[t]);
		res -= sum + SUM;
		return res;
	}

	int eval() const {
		return score;
	}

	State place(int d, int t) {
		State res = *this;
		res.ans[d] = t;
		res.update_score(d, t);
		return res;
	}

	array<char, D> answer() {
		return ans;
	}
};

array<char, D> solve() {
	State initial_state;
	using f = function<bool(State&, State&)>;
	priority_queue<State, vector<State>, f> cur([](State& a, State& b){return a.eval() > b.eval();});
	cur.push(initial_state);
	priority_queue<State, vector<State>, f> nxt([](State& a, State& b){return a.eval() > b.eval();});
	rep(d, D){
		while(!nxt.empty()) nxt.pop();
		while(!cur.empty()){
			State now = cur.top(); cur.pop();
			rep(t, SZ){
				if(nxt.size() < BEAM_SIZE || now.next_eval(d, t) > nxt.top().eval()) nxt.push(now.place(d, t));
				if(nxt.size() > BEAM_SIZE) nxt.pop();
			}
		}
		swap(cur, nxt);
	}

	State res;
	while(!cur.empty()){
		if(cur.size() == 1) res = cur.top();
		cur.pop();
	}
	cerr << res.eval() << endl;
	return res.answer();
}

int main(void){
	int tmp;
	cin >> tmp;
	rep(i, SZ) cin >> C[i];
	rep(i, SZ) SUM += C[i];
	rep(i, D) rep(j, SZ) cin >> S[i][j];

	auto ans = solve();
	for (char i : ans) cout << (int)i + 1 << endl;

	return 0;
}


Measured memory_bytes: 5136
import sys, os

f = lambda:list(map(int,input().split()))
if 'local' in os.environ :
    sys.stdin = open('./input.txt', 'r')

def solve():
    n, m = f()
    s = [ input() for i in range(n)]


    for i in range(n+2):
        if i == 0 or i == n+1:
            for j in range(m+2):
                print('#', end = '')
            print()
        else:
            print('#',end = '')
            print(s[i-1], end = '')
            print('#')


solve()


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

int main(){
  int H1,M1,H2,M2,K;
  cin >> H1 >> M1 >> H2 >> M2 >> K;
  
  int wake = (H2-H1)*60 + M2-M1;
  int x = wake - K;
  cout << x << endl;
}

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

 #define   ll      long long 
 #define   pb      push_back
 #define   mp      make_pair

 typedef vector<int> vi;
 typedef vector<ll> vl;
 typedef pair<int,int> pii;
 typedef map<int,int> mii;
 const int MAX = 1000001; 
  
int factor[MAX] = { 0 }; 
  
void generatePrimeFactors() 
{ 
    factor[1] = 1; 
  
    // Initializes all the positions with their value. 
    for (int i = 2; i < MAX; i++) 
        factor[i] = i; 
  
    // Initializes all multiples of 2 with 2 
    for (int i = 4; i < MAX; i += 2) 
        factor[i] = 2; 
  
    // A modified version of Sieve of Eratosthenes to 
    // store the smallest prime factor that divides 
    // every number. 
    for (int i = 3; i * i < MAX; i++) { 
        // check if it has no prime factor. 
        if (factor[i] == i) { 
            // Initializes of j starting from i*i 
            for (int j = i * i; j < MAX; j += i) { 
                // if it has no prime factor before, then 
                // stores the smallest prime divisor 
                if (factor[j] == j) 
                    factor[j] = i; 
            } 
        } 
    } 
} 
ll calculateNoOFactors(int n) 
{ 
    if (n == 1) 
        return 1; 
  
    ll ans = 1; 
  
    // stores the smallest prime number 
    // that divides n 
    ll dup = factor[n]; 
  
    // stores the count of number of times 
    // a prime number divides n. 
    ll c = 1; 
  
    // reduces to the next number after prime 
    // factorization of n 
    ll j = n / factor[n]; 
  
    // false when prime factorization is done 
    while (j != 1) { 
        // if the same prime number is dividing n, 
        // then we increase the count 
        if (factor[j] == dup) 
            c += 1; 
   else { 
            dup = factor[j]; 
            ans = ans * (c + 1); 
            c = 1; 
        } 
  
        // prime factorizes a number 
        j = j / factor[j]; 
    } 
  
    // for the last prime factor 
    ans = ans * (c + 1); 
  
    return ans;
} 
 int main()
 {
      ios_base::sync_with_stdio(false);
      cin.tie(NULL);

      ll t;
      t=1;
      //cin>>t;
      generatePrimeFactors() ;
      ll a[1+1000000];
      a[1]=0;
 
      for(int i=2;i<=1000000;i++)
      	a[i]=calculateNoOFactors(i-1)+a[i-1] ;

      while(t--)
      {
         int n;
         cin>>n;
         
       cout<<a[n]<<endl;  

      }

      return 0;
 }




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

using namespace std;
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
constexpr int MOD = 1000000007;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
constexpr int dx[] = {1, 0, -1, 0, 1, 1, -1, -1};
constexpr int dy[] = {0, -1, 0, 1, 1, -1, -1, 1};

template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){os << "["; for (const auto &v : vec) {os << v << ","; } os << "]"; return os; }

ll solve(ll H, ll W) {
  ll ans = 1LL << 61;
  for(ll i = 1; i <= H - 1; i++) {
    ll i_ = i + (H - i) / 2;
    if (i_ == i) continue;
    ll ma1 = max({(H - i_) * W, (i_ - i) * W, i * W});
    ll mi1 = min({(H - i_) * W, (i_ - i) * W, i * W});
    ll j_ = W / 2;
    ll ma2 = max({(H - i) * j_, (H - i) * (W - j_), i * W});
    ll mi2 = min({(H - i) * j_, (H - i) * (W - j_), i * W});
    ans = min({ans, ma1 - mi1, ma2 - mi2});
  }
  return ans;
}

void solve() {
  ll H, W;
  cin >> H >> W;
  if (H == 2 && W == 2) {
    cout << 1 << endl;
    return;
  }
  cout << min(solve(H, W), solve(W, H)) << endl;
}

int main() {
  std::cin.tie(0);
  std::ios::sync_with_stdio(false);
  cout.setf(ios::fixed);
  cout.precision(16);
  solve();
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
int main()
{
	int n, k;
	bool okasi[200];
	int i, j, ans;
	int d, a;

	ans = 0;
	for (i = 0; i < 200; i++) {
		okasi[i] = false;
	}
	cin >> n >> k;
	for (i = 0; i < k; i++) {
		cin >> d;
		for (j = 0; j < d; j++) {
			cin >> a;
			okasi[a] = true;
		}
	}

	for (i = 1; i <= n; i++) {
		if (okasi[i] == false) {
			ans++;
		}
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define MV 200001
#define LMV 21
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define ins insert
#define sz size

void FLASH() {ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);}
void SETF() {cout.ios_base::setf(ios_base::fixed);}
void UNSETF() {cout.ios_base::unsetf(ios_base::fixed);}

typedef long long ll;
typedef long double ld;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
typedef pair<PII, int> PPII;
typedef pair<PLL, ll> PPLL;
typedef map<int, int> MII;
typedef map<ll, ll> MLL;
typedef map<PII, int> MPII;
typedef map<PLL, ll> MPLL;

int ar[MV];
ll arr[MV];

void solve(int T)
{
	ll n;
	cin>>n;
	if(n & 1)
	std::cout<<(((n-1)/2)*n)<<"\n";
	else std::cout<<((n/2)*(n-1))<<"\n";
	return;
}

int main(void)
{
	FLASH();
	int T;
	T = 1;
	while(T--)
	solve(T);
	return 0;
}

Measured memory_bytes: 256
n,k=map(int,input().split())
A=[]
for i in range(n):
  A.append(int(input())-k)
AA,BB=[0]*(n+1),[0]*(n+1)
AA[-2]=A[-1]
BB[-2]=A[-1]
for i in reversed(range(n-1)):
  AA[i]=AA[i+1]+A[i]
  BB[i]=BB[i+1]+A[i]
BB.sort()
cur=1
D=dict()
D[BB[0]]=cur
for i in range(1,n+1):
  if BB[i]==BB[i-1]:
    continue
  else:
    cur+=1
    D[BB[i]]=cur
AAA=[0]*(n+1)
for i in range(n+1):
  AAA[i]=D[AA[i]]

nn=18
BIT=[0]*(2**nn)
BIT.insert(0,0)
def bitsum(BIT,i):
  s=0
  while i>0:
    s+=BIT[i]
    i-=i&(-i)
  return s
def bitadd(BIT,i,x):
  while i<=2**nn:
    BIT[i]+=x
    i+=i&(-i)
  return BIT

ans=0
for i in range(n+1):
  ans+=i-bitsum(BIT,AAA[i]-1)
  bitadd(BIT,AAA[i],1)
print(ans)


Measured memory_bytes: 88792
N, K=map(int, input().split())
h=list(map(int, input().split()))
dp = [10**5] * N
dp[0] = 0
for i in range(1, N):
    x = max(0, i-K)
    dp[i] = min([dp[j]+abs(h[j]-h[i]) for j in range(x, i)])
print(dp[-1])

Measured memory_bytes: 52448
def main():
    n = int(input())
    nums = list(range(1,n+1))
    ans = 0
    for num in nums:
        cnt = n//num
        curr_sum = cnt*(2*num+(cnt-1)*num)//2
        ans += curr_sum
    print(ans)


if __name__ == "__main__":
    main()

Measured memory_bytes: 141576
#include <stdio.h>
int main (void){
    char ins[13]={'\0'}; //末尾に\0が入るので13文字分メモリ確保
    scanf("%s",ins);
    int loop1;
    for(loop1=0;loop1<=3;loop1++){
        printf("%c",ins[loop1]);
    }
    printf(" ");
    for(loop1=4;loop1<=11;loop1++){
        printf("%c",ins[loop1]);
    }
    printf("\n");
    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>

using namespace std;

typedef long long ll;
typedef pair<int, int> P;

int N, M;
ll xx[1000], yy[1000], zz[1000];

struct th{
    ll x;
    ll y;
    ll z;
};

ll a[1000];
ll dp[1010][1010];
ll si[3];

int main() {
    cin >> N >> M;
    for (int i = 0; i < N; i++) {
        cin >> xx[i] >> yy[i] >> zz[i];
    }


    for (int i = 0; i <= N; i++){
        dp[i][0] = 0;
    }
    for(int i = 1; i <= M; i++){
        dp[0][i] = LONG_MIN;
    }

    ll res = LONG_MIN;
    for(int k = 0; k < 8; k++){
        si[0] = 1 - (k % 2) * 2;
        si[1] = 1 - ((k>>1) % 2) * 2;
        si[2] = 1 - ((k>>2) % 2) * 2;

        for(int i = 1; i <= N; i++){
            for(int j = 1; j <= min(M, i); j++){
                ll stay = dp[i - 1][j];
                ll pick = dp[i - 1][j - 1] + si[0] * xx[i - 1] + si[1] * yy[i - 1] + si[2] * zz[i - 1];
                if(i == j){
                    dp[i][j] = pick;
                    continue;
                }
                if (stay > pick) {
                    dp[i][j] = stay;
                } else {
                    dp[i][j] = pick;
                }
            }
        }
        if(res < dp[N][M]){
            res = dp[N][M];
        }
    }

    cout << res << endl;

    return 0;
}

Measured memory_bytes: 7424
n = gets.strip.to_i
a = n.times.map { gets.strip }

correct = 'Yes'
last_word = a[0][0]
if a.uniq.size == n
  a.each_with_index do |s, i|
    unless last_word.eql?(s[0])
      correct = 'No'
      break
    end
    last_word = s[-1]
  end
else
  correct = 'No'
end

puts correct


Measured memory_bytes: 1916
//#pragma GCC optimize("O3")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,tune=native")
//#pragma GCC optimize ("unroll-loops")
#include <bits/stdc++.h>
 
using namespace std;
 
using ll = long long;
using ld = long double;

const int N = 1e5 + 5;

int a[N];
int pref[N];

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    int n;
    cin >> n;
    for (int i = 1; i <= n; i++) {
        cin >> a[i];
        pref[i] = __gcd(pref[i - 1], a[i]);
    }
    int ans = 0;
    int g = 0;
    for (int i = n; i >= 1; i--) {
        ans = max(ans, __gcd(pref[i - 1], g));
        g = __gcd(g, a[i]);
    }
    cout << ans;
    return 0;
}

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

using namespace std;

using ll = long long;
using ull = unsigned long long;
template<class T> using v = vector<T>;

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

template<class T> T read() { T x{}; cin >> x; return x; }
template<class T> v<T> read(int N){ v<T> x(N); REP(i, N) cin >> x[i]; return x; }

template<class T>
void write(const T &x){ cout << x << endl; }
void write(double x){ printf("%.15f\n", x); }

const double PI=3.14159265358979323846;

double kaijo(ll N){
    double ret = 1;
    for(ll i = 1; i <= N; ++i){ ret *= i; }
    return ret;
}

const int MAX = 1000000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

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

int main() {
    auto X = read<ll>();
    auto Y = read<ll>();
    auto N = (X + Y) / 3;
    if( (X + Y) % 3 != 0 ||
         X < N ||
         Y < N){
        write(0);
        return 0;
    }
    auto K = min(X - N, Y - N);
    
    COMinit();
    ll ans = COM(N, K);
    
    write(ans);
}



Measured memory_bytes: 23680
#include<bits/stdc++.h>
using namespace std;
//<<setprecision(20)

#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep1(i, n) for (ll i = 1; i <= (ll)(n); i++)
#define INF 1000000000000
#define MOD 1000000007
using ll = long long;
using Graph = vector<vector<int>>;

int main(){
  int N,X,Y; cin>>N>>X>>Y;
  Graph G(N);
  //グラフ入力
  for(int i = 1; i < N; i++){
    G.at(i).push_back(i-1);
    G.at(i-1).push_back(i);
  }
  G.at(X-1).push_back(Y-1);
  G.at(Y-1).push_back(X-1);

  vector<int> res(N);//res[i]は距離iの経路の数。

  rep(i,N){
    //BFSのデータ構造
    queue<int> que;
    vector<int> dist(N,-1);

    //スタートをiとしてBFSする。初期化
    que.push(i);
    dist.at(i) = 0;
    
    while(!que.empty()){
      int v = que.front();
      que.pop();
      for(int nv: G.at(v)){
        if(dist.at(nv)!=-1)continue;//探索済み
        que.push(nv);
        dist.at(nv)=dist.at(v)+1;
      }
    }

    //resに経路の最短距離をメモ
    rep(i,N)res.at(dist.at(i))++;
  }
  for(int i = 1; i < N; i++)cout<<res.at(i)/2<<endl;
  return 0;
}

Measured memory_bytes: 384
function main(input) {
   input = input.trim();
  const inp = input.split("\n");
  const a = inp[0].split("");
  const b = inp[1].split("");
  var ans = 0;
  for ( i = 0; i < 3; i++) {
	if (a[i]==b[i]) {
		ans++;
		}
    }
  console.log(ans);
  
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 29556
import java.util.*;

public class Main {
  public static void main(String... args) {
    Scanner scan = new Scanner(System.in);
    
    int x = scan.nextInt();
    int a = scan.nextInt();
    
    if (x < a) System.out.println(0);
    if (x >= a) System.out.println(10);
  }
}

Measured memory_bytes: 21844
import sys
sys.setrecursionlimit(10**7) #再帰関数の上限,10**5以上の場合python
import math
from copy import copy, deepcopy
from copy import deepcopy as dcp
from operator import itemgetter
from bisect import bisect_left, bisect, bisect_right#2分探索
#bisect_left(l,x), bisect(l,x)#aはソート済みである必要あり。aの中からx未満の要素数を返す。rightだと以下
from collections import deque, defaultdict
#deque(l), pop(), append(x), popleft(), appendleft(x)
#q.rotate(n)で → にn回ローテート
from collections import Counter#文字列を個数カウント辞書に、
#S=Counter(l),S.most_common(x),S.keys(),S.values(),S.items()
from itertools import accumulate,combinations,permutations,product#累積和
#list(accumulate(l))
from heapq import heapify,heappop,heappush
#heapify(q),heappush(q,a),heappop(q) #q=heapify(q)としないこと、返り値はNone
from functools import reduce,lru_cache#pypyでもうごく
#@lru_cache(maxsize = None)#maxsizeは保存するデータ数の最大値、2**nが最も高効率
from decimal import Decimal

def input(): 
    x=sys.stdin.readline()
    return x[:-1] if x[-1]=="\n" else x
def printe(*x):print("## ",*x,file=sys.stderr)
def printl(li): _=print(*li, sep="\n") if li else None
def argsort(s, return_sorted=False): 
    inds=sorted(range(len(s)), key=lambda k: s[k])
    if return_sorted: return inds, [s[i] for i in inds]
    return inds
def alp2num(c,cap=False): return ord(c)-97 if not cap else ord(c)-65
def num2alp(i,cap=False): return chr(i+97) if not cap else chr(i+65)
def matmat(A,B):
    K,N,M=len(B),len(A),len(B[0])
    return [[sum([(A[i][k]*B[k][j]) for k in range(K)]) for j in range(M)] for i in range(N)]
def matvec(M,v):
    N,size=len(v),len(M)
    return [sum([M[i][j]*v[j] for j in range(N)]) for i in range(size)]
def T(M):
    n,m=len(M),len(M[0])
    return [[M[j][i] for j in range(n)] for i in range(m)]
def binr(x): return bin(x)[2:]
def bitcount(x): #xは64bit整数
    x= x - ((x >> 1) & 0x5555555555555555)
    x= (x & 0x3333333333333333) + ((x >> 2) & 0x3333333333333333)
    x= (x + (x >> 4)) & 0x0f0f0f0f0f0f0f0f 
    x+= (x >> 8); x+= (x >> 16); x+= (x >> 32) 
    return x & 0x7f

def main():
    mod = 1000000007
    #w.sort(key=itemgetter(1),reverse=True)  #二個目の要素で降順並び替え

    N = int(input())
    #N, K = map(int, input().split())
    A = tuple(map(int, input().split())) #1行ベクトル
    #L = tuple(int(input()) for i in range(N)) #改行ベクトル
    #S = tuple(tuple(map(int, input().split())) for i in range(N)) #改行行列
    cur=1000
    curk=0
    for i,a in enumerate(A):
        if i==N-1:
            cur+=a*curk
            curk=0
            continue

        if a<=A[i+1]:
            x=cur//a
            curk+=x
            cur-=x*a
        else:
            cur+=a*curk
            curk=0
    print(cur)





if __name__ == "__main__":
    main()

Measured memory_bytes: 72728
import java.io.IOException;
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws IOException {

		new Main().run();
	}

	private void run() throws IOException {
		Scanner scanner = new Scanner(System.in);
		while (true) {
			n = scanner.nextInt();
			u = scanner.nextInt();
			if ((n | u) == 0)
				break;
			need = new int[n];
			int all = 0;
			unit = new int[n];
			num = new int[n];
			for (int i = 0; i < n; i++) {
				unit[i] = num[i] = scanner.nextInt();
				all += unit[i];
				int k = scanner.nextInt();
				for (int j = 0; j < k; j++) {
					int x = scanner.nextInt();
					need[i] |= (1 << x);
				}
			}
			if (all == u) {
				System.out.println(n);
				continue;
			}
			Arrays.sort(num);
			int sum = 0;
			for (int i = n - 1; i >= 0; i--) {
				sum += num[i];
				if (sum >= u) {
					m = i;
					break;
				}
			}

			for (int i = 1; i < n; i++) {
				v = new boolean[1 << n];
				if (slove(0, 0, 0, i)) {
					System.out.println(i);
					break;
				}
			}
		}

	}

	private boolean slove(int bit, int one, int have, int depth) {
		if (u <= have)
			return true;
		if (one == depth)
			return false;
		for (int i = 0; i < n; i++) {
			int a = bit | (1 << i);
			if (v[a] || (bit | need[i]) != bit)
				continue;
			v[a] = true;
			if (slove(a, one + 1, have + unit[i], depth))
				return true;
		}
		return false;
	}

	int m;
	int n, u;
	int[] need, unit, num;
	int ans;
	boolean[] v;
}

Measured memory_bytes: 156320
#include <algorithm>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <queue>
#include <stack>
#include <unordered_set>
#include <utility>
#include <vector>
using std::cerr;
using std::cin;
using std::cout;
using std::endl;

void OutputError(std::string s) {
  cerr << "\033[93m" << s << "\033[m" << endl;
  return;
}

int main(void) {
  cout << std::fixed << std::setprecision(10);
  cin.tie(0);
  std::ios::sync_with_stdio(false);
  int n;
  cin >> n;
  std::unordered_set<int64_t> set;
  for (int i = 0; i < n; i++) {
    int m1;
    cin >> m1;
    if (set.find(m1) == set.end()) {
      set.insert(m1);
    } else {
      set.erase(m1);
    }
  }
  cout << set.size() << endl;

  return 0;
}


Measured memory_bytes: 4256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
template<class T> using vc = vector<T>;
template<class T> using vvc = vector<vector<T>>;

const ll MOD = 1e9 + 7;
// const ll MOD = 998244353;
const ll INF = 1e16;
const ld EPS = 1e-11;
const ld PI = acos(-1.0L);
#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define repr(i, n) for (ll i = (n)-1; i >= 0; i--)
#define repe(i, l, r) for (ll i = (l); i < (r); i++)
#define reper(i, l, r) for (ll i = (r)-1; i >= (l); i--)

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

void init() {cin.tie(0);ios::sync_with_stdio(false);cout << fixed << setprecision(15);}
//--------------------------------------------------------------------------------//
ll bd[4][3][10];
int main() {
    init();
    ll N;
    cin >> N;
    rep(i,N){
        ll a, b, c, d;
        cin >> a >> b >> c >> d;

        bd[a - 1][b - 1][c - 1] += d;
    }

    rep(i,4){
        rep(j,3){
            rep(k,10){
                cout << " " << bd[i][j][k];
            }
            cout << endl;
        }
        if(i!=3)cout << "####################" << endl;
    }
}


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

#define vec                vector<int>
#define vecll              vector<ll>
#define vecst              vector<string>
#define vecb               vector<bool>
#define vec2(var, n, m)    vector<vector<int>> var(n, vector<int>(m, 0))
#define vecll2(var, n, m)  vector<vector<ll>> var(n, vector<ll>(m, 0))

#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 f_sum(var)       accumulate(all(var), 0)
#define f_sumll(var)     accumulate(all(var), 0LL)
#define chmin(v1, v2)    v1 = min(v1, v2)
#define chmax(v1, v2)    v1 = max(v1, v2)
#define mp(v1, v2)       make_pair(v1, v2)
#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");}
void prtok(bool ok){prt(ok ? "Yes" : "No");}
//----------------------------------------------------------------

int main(void) {
  ll a, b, c, x, y;
  cin >> a >> b >> c >> x >> y;

  ll ans = 1e18;
  rep(i,max(x,y)+1){
    ll tmp = 2*c*i + max(x-i, 0ll)*a + max(y-i, 0ll)*b;
    chmin(ans, tmp);
  }

  prt(ans);
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>

using namespace std;

long long calc(long long x) {
    long long cnt = (x + 1) / 2;
    long long ans = cnt % 2;
    if (x%2==0) { ans ^= x; }
    return ans;
}
int main(void) {
    long long int a, b;
    cin >> a >> b;

    long long ans = calc(a - 1) ^calc(b);

    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <math.h>
#include <string>
#include <algorithm>
#include <ctype.h>
#include <vector>
#include <numeric>
#include <map>
using namespace std;

#define ll long long int
#define rep(i, a, n) for (int i = a; i < n; i++)
#define INF 1e9
#define LINF 1e17
#define MOD (int)(1e9 + 7)
#define pi 3.141592653589
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vi vector<int>
#define vll vector<ll>
#define ALL(a) (a).begin(), (a).end()
#define sort_v(a) sort(a.begin(), a.end())
#define fi first
#define se second

void print(bool c)
{
    if (c)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}

void Print(bool c)
{
    if (c)
        cout << "YES" << endl;
    else
        cout << "NO" << endl;
}

ll gcdll(ll a, ll b)
{
    while (1)
    {
        if (a < b)
            swap(a, b);
        if (b == 0)
            break;
        a %= b;
    }
    return a;
}

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

bool cmp(const pii &a, const pii &b)
{
    if (a.second != b.second)
        return a.second < b.second;
    return a.first < b.first;
}


int main()
{
    int n;
    cin >> n;
    vll a(n + 1), b(n);
    rep(i, 0, n + 1) cin >> a[i];
    rep(i, 0, n) cin >> b[i];
    ll ans = 0;
    rep(i, 0, n)
    {
        if (b[i] > a[i])
        {
            ans += a[i];
            b[i] -= a[i];
            if (b[i] > a[i + 1])
            {
                ans += a[i + 1];
                a[i + 1] = 0;
            }
            else
            {
                ans += b[i];
                a[i + 1] -= b[i];
            }
        }
        else
        {
            ans += b[i];
            a[i] -= b[i];
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 1792
#include<stdio.h>
   int main(void){
     int r,c,i,j,sumwid=0,sumver=0,gt=0;
       scanf("%d %d",&r,&c);
       int num[r][c];
       for(i=0;i<r;i++){
          for(j=0;j<c;j++){
             scanf(" %d",&num[i][j]);
          }
      }
      for(i=0;i<r;i++){
         sumwid=0;
         for(j=0;j<c;j++){
            printf("%d ",num[i][j]);
            sumwid=num[i][j]+sumwid;
         }
         printf("%d\n",sumwid);
      }

      for(j=0;j<c;j++){
         sumver=0;
         for(i=0;i<r;i++){
           sumver=num[i][j]+sumver;
        }
         printf("%d ",sumver);
         gt=sumver+gt;
      }
      printf("%d\n",gt);
      return 0;
 }


Measured memory_bytes: 2140
#include <bits/stdc++.h>
using namespace std;
int main(){
	long long x, n=100,m=1;
	scanf("%lld", &x);
	if(x<=n){
		printf("1"); 
	}
	if(x>n){
		for(m=1; n<x; m++){
			n=n+n*0.01;
		}
	} 
	printf("%lld", m-1);
	return 0;
}

Measured memory_bytes: 3828
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <algorithm>
#include <climits>
#include <cstring>
#include <cmath>
#include <stack>
#include <iomanip>
#include <tuple>
#include <functional>
#include <cfloat>
#include <map>
#include <set>
#include <array>
#include <stdio.h>
#include <string.h>
using ll = long long;
using ull = unsigned long long;
using namespace std;
#define int long long
#define CONTAINS_VEC(v,n) (find((v).begin(), (v).end(), (n)) != (v).end())
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
#define ARY_SORT(a, size) sort((a), (a)+(size))
#define REMOVE(v,a) (v.erase(remove((v).begin(), (v).end(), (a)), (v).end()))
#define REVERSE(v) (reverse((v).begin(), (v).end()))
#define ARY_REVERSE(v,a) (reverse((v), (v)+(a)))
#define REP(i, n) for (int (i)=0; (i) < (n); (i)++)
#define CONTAINS_MAP(m, a) (m).find((a)) != m.end()
#define CONTAINS_SET(m, a) (m).find((a)) != m.end()
void YesNo(bool b) { cout << (b ? "Yes" : "No") << endl; }
void YESNO(bool b) { cout << (b ? "YES" : "NO") << endl; }

int N;
int A[81];

vector<int> down;
vector<int> up;

signed main()
{
	cin >> N;
	REP(i, N) cin >> A[i];

	int bottom = A[0];


	for (int i = 1; i < N; i++)
	{
		if (bottom > A[i])
		{
			bottom = A[i];
		}
		else if (bottom < A[i])
		{
			down.push_back(bottom);
			up.push_back(A[i]);
			bottom = A[i];
		}
	}

	int kane = 1000;
	int kabu = 0;
	for (int i = 0; i < up.size(); i++)
	{
		int cnt = kane / down[i];
		int buy = cnt * down[i];
		kane -= buy;
		int sell = cnt * up[i];
		kane += sell;
	}

	cout << kane << endl;
}



Measured memory_bytes: 3200
# -*- coding: utf-8 -*-

x1, x2, x3, x4, x5 = map(int, input().split())

if x1 == 0:
  print(1)
elif x2 == 0:
  print(2)
elif x3 == 0:
  print(3)
elif x4 == 0:
  print(4)
else:
  print(5)

Measured memory_bytes: 9108
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String str = sc.nextLine();
        int count = 0;
        for (int i = 0; i < 4; i++) {
            if (str.charAt(i) == '+') {
                count++;
            } else {
                count--;
            }
        }
        System.out.println(count);
    }
}

Measured memory_bytes: 21204
// Created by Krishna Ashok
#pragma GCC optimization("O3")
//#pragma GCC optimization("unroll-loops")
#include <bits/stdc++.h>
using namespace std;

//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds; 
//typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> Tree;

#define dbg(x) cout<<#x<<"="<<x<<'\n'
#define ll long long
#define pr pair<int,int>
#define pb push_back
#define ff first
#define ss second
#define vi vector<int>
#define For(i,n,a) for(int i=a;i<(n);++i)
#define Forr(i,n) for(int i=n-1;i>=0;i--)
#define fin ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define MOD 1000000007
#define all(x) (x).begin(),(x).end()
#define sz(a) (int)a.size()
#define Fill(a,b) memset(a,b,sizeof(a));
#define fileio freopen("http://in.in", "r", stdin),freopen("out.out", "w", stdout);
#define sd(x) scanf("%d",&x)
#define sld(x) scanf("%lld",&x)
const int INF=1e9;

void topsort(int u,vector<bool> &vis,vector<vi> &adj,stack<int> &order){
	vis[u]=true;
	for(int v:adj[u]){
		if(!vis[v])topsort(v,vis,adj,order);
	}
	order.push(u);
}


void solve(){
	int n,m,x,y;
	cin>>n>>m;
	vector<vi> adj(n+1);
	for(int i=0;i<m;i++){
		cin>>x>>y;
		adj[x].push_back(y);
	}
	stack<int> order;
	vector<int> dist(n+1,-INF);
	dist[0]=INF;
	vector<bool> vis(n+1,false);
	for(int i=1;i<=n;i++){
		if(!vis[i])topsort(i,vis,adj,order),dist[i]=0;
	}
	while(!order.empty()){
		int u=order.top();
		order.pop();
		if(dist[u]==-INF)continue;
		for(int v:adj[u]){
			if(dist[v]==-INF)dist[v]=dist[u]-1;
			else dist[v]=min(dist[v],dist[u]-1);
		}
	}

	cout<<*min_element(all(dist))*-1<<endl;

}



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

Measured memory_bytes: 12860
from collections import Counter

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

def comb2(n):
    return n * (n - 1) // 2

cnt = Counter(A)
ans = 0

for c in cnt.values():
    if c >= 2:
        ans += comb2(c)

for i in range(N):
    print(ans - cnt[A[i]] + 1)

Measured memory_bytes: 88012
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#define BASE 9000
#define MAX BASE*2
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
bool dp[2][2][MAX]={};
signed main(){
  ll x,y,cnt=0,dr=0,fc=0,v;
  bool first=true;
  string s;
  vector<ll> vals[2];
  cin >> s >> x >> y;
  for(auto c:s){
    if(c=='F'){
      if(first){
        fc++;
      }else{
        cnt++;
      }
    }else{
      if(!first&&cnt!=0){
        vals[dr].push_back(cnt);
      }
      first=false;
      cnt = 0;
      dr = !dr;
    }
  }
  if(s.back()=='F'&&!first&&cnt!=0){
    vals[dr].push_back(cnt);
  }
  dp[0][0][fc+BASE]=true;
  dp[1][0][0+BASE]=true;
  for(int k=0;k<2;k++){
    for(int i=0;i<vals[k].size();i++){
      for(int j=0;j<MAX;j++){
        if(dp[k][0][j]){
          v = j+vals[k][i];
          dp[k][1][v]=true;
          v = j-vals[k][i];
          dp[k][1][v]=true;
        }
      }
      for(int j=0;j<MAX;j++){
        dp[k][0][j] = dp[k][1][j];
        dp[k][1][j] = false;
      }
    }
  }
  if(dp[0][0][x+BASE]&&dp[1][0][y+BASE]){
    cout <<"Yes\n";
  }else{
    cout <<"No\n";
  }
}


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

int main() {
  int n;
  cin >> n;
  vector<int> p(n);
  for(int i = 0; i < n; i++){
      cin >> p[i];
  }
  int ans = 0;
  int minNum = p[0];
  for(int i =0; i<n; i++){
      if(p[i] > minNum){
      } else{
          minNum = p[i];
          ans++;
      }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1024