akhauriyash/Code-Regression huggingface dataset:
#include <iostream>

using namespace std;

int main(){
    string str;
    while(cin >> str,str!="0"){
        int n=str.size();
        int D[n];
        for(int i=0;i<n;i++){
            D[i]=((i&1)==1?-1:1)*(str[i]-'0');
        }
        int C[n]; fill(C,C+n,0);
        for(int i=0;i<n;i++){
            int sum=0;
            if(D[i]==0&&(i>0?C[i-1]:0)==0)continue;
            for(int j=i;j<n;j++){
                sum+=D[j];
                sum%=11;
                if(!sum){
                    if(D[i]==0){
                        C[j]+=(i>0?C[i-1]:0);
                    }else{
                        C[j]+=1+(i>0?C[i-1]:0);
                    }
                    break;
                }
            }
        }
        int count=0;
        for(auto& c:C)count+=c;
        cout << count << endl;
    }
    return 0;
}

Measured memory_bytes: 3880
#pragma GCC optimize("Ofast")

#include <bits/stdc++.h>
using namespace std;

const int MN = 500012;

int n, q;
int a[MN];
int fr[MN];
pair<int, pair<int, int>> queries[MN];
int cur = 0;
int res[MN];

inline void add(int c) {
  fr[c]++;
  if (fr[c] == 1) cur++;
}

inline void remove(int c) {
  fr[c]--;
  if (fr[c] == 0) cur--;
}

int main (void) {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> n >> q;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
  }
  for (int i = 0; i < q; i++) {
    int l, r;
    cin >> l >> r;
    queries[i] = make_pair(i, make_pair(l, r));
  }
  int sz = (int) sqrt(n);
  sort(queries, queries + q, [sz](auto& a, auto& b) {
    if (a.second.first / sz != b.second.first / sz)
      return a.second.first < b.second.first;
    return a.second.second < b.second.second;
  });
  int l = queries[0].second.first, r = l;
  add(a[l]);
  for (int i = 0; i < q; i++) {
    auto [tl, tr] = queries[i].second;
    while (l > tl) add(a[--l]);
    while (r < tr) add(a[++r]);
    while (l < tl) remove(a[l++]);
    while (r > tr) remove(a[r--]);
    res[queries[i].first] = cur;
  }
  for (int i = 0; i < q; i++)
    cout << res[i] << '\n';
  return 0;
}



Measured memory_bytes: 15520
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/integer/common_factor.hpp>
#include <boost/integer/common_factor_rt.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>

using std::string;
using std::vector;
using std::set;
using std::multiset;
using std::unordered_set;
using std::map;
using std::multimap;
using std::unordered_map;
using std::pair;
using std::cin;
using std::cout;

typedef uintmax_t    ull;
typedef intmax_t     ll;
typedef uint64_t     ul;
typedef uint32_t     ui;
typedef uint8_t      uc;

typedef boost::multiprecision::number<boost::multiprecision::cpp_dec_float<1000>> cpp_dec_float_1000;

constexpr char CRLF  = '\n';
constexpr char SPACE = ' ';
constexpr char VECTOR_COUT_SEPARATOR = SPACE;
constexpr ll INF = 1000'000'007;

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; }
template<class T> std::ostream& operator<< (std::ostream& os, const std::vector<T>& vc) { for(auto it = vc.begin(); it != vc.end(); ++it) { if (std::next(it) == vc.end()) os << *it; else os << *it << VECTOR_COUT_SEPARATOR; } return os; }
template<class T1, class T2> inline std::ostream & operator<< (std::ostream & os, const std::pair<T1, T2> & p) { return os << p.first << ' ' << p.second; }

using Vector = vector<vector<ui>>;
Vector g_edge;
vector<int> g_memo;
ll g_cnt = 0;

void rec(int cur)
{
  bool emp = true;
  for (int next = 0; next < g_edge[cur].size(); ++next) {
    if (cur == next) {
      continue;
    }
    if (g_edge[cur][next] && !g_memo[next]) {
      emp = false;
      g_memo[next] = 1;
      rec(next);
      g_memo[next] = 0;
    }
  }
  if (emp) {
    if (boost::accumulate(g_memo, 1, [](auto r, auto i) { return i & r; })) {
      ++g_cnt;
    }
  }
  return;
}

void solve(void)
{
  int N, M; cin >> N >> M;
  vector<vector<ui>> way(N, vector<ui>(N));
  for (int i = 0; i < M; ++i) {
    int a, b; cin >> a >> b;
    --a; --b;
    way[a][b] = 1;
    way[b][a] = 1;
  }
  g_edge = std::move(way);
  g_memo.resize(N);

  g_memo[0] = 1;
  rec(0);

  cout << g_cnt << CRLF;
  return;
}

int main(void)
{
  std::ios_base::sync_with_stdio(false);
  std::cin.tie(0);

  solve();

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define dunk(a) cout << (a) << endl
#define rall(a) (a).rbegin(),(a).rend()
const int INF = 2e9;
using namespace std;
using Graph = vector<vector<int>>;
typedef pair<int,int> P;
typedef long long ll;

int main(){
    int a, b; cin >> a >> b;

    if(b<10) a*=10;
    else if (b<100) a*=100;
    else a*=1000;

    int num = a+b;
    bool jud = false;

    for(int i = 1; i*i<=num; i++){
        if(i*i == num){
            jud = true;
        }
    }

    if(jud)  cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
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 % 2 == 0) {
      System.out.println("Even");
    } else {
      System.out.println("Odd");
    }
  }
}

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

int main() {
    string S;
    cin >> S;
    int N = (int)S.size();

    vector<int> res(N);
    for (int ri = 0; ri < 2; ri++) {
        int cnt = 0;
        for (int i = 0; i < N; i++) {
            if (S[i] == 'R') {
                cnt++;
            } else {
                res[i] += cnt / 2;
                res[i - 1] += (cnt + 1) / 2;
                cnt = 0;
            }
        }

        reverse(res.begin(), res.end());
        reverse(S.begin(), S.end());
        for (int i = 0; i < N; i++) {
            if (S[i] == 'L')
                S[i] = 'R';
            else
                S[i] = 'L';
        }
    }
    for (int i = 0; i < N; i++)
        cout << res[i] << " ";
    cout << endl;
    return 0;
}

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

using namespace std;

#define debug(x) '[' << #x << " is: " << x << "] "
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.precision(10);
	cout << fixed;
	int k,x;
	cin>>k>>x;
	for(int i=x-k+1;i<x+k;i++)
		cout << i << ' ';
	cout << endl;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) throws Exception {
		// Scanner sc = new Scanner(new System.in);
		// Scanner sc = new Scanner(new File("in1.txt"));
		// Scanner sc = new Scanner(new File("in2.txt"));
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		// BufferedReader br = new BufferedReader(new FileReader("in1.txt"));
		int N = Integer.parseInt(br.readLine());
		// sc.nextInt();
		
		// int r0 = sc.nextInt();
		// int r1 = sc.nextInt();
		int r0 = Integer.parseInt(br.readLine());
		int r1 = Integer.parseInt(br.readLine());
		int max_profit = r1 - r0;
		int min_r = Math.min(r0, r1);
		// while (sc.hasNextInt()) {
		for (int i = 2; i < N; i++) {
			// int r = sc.nextInt();
			int r = Integer.parseInt(br.readLine());
			max_profit = Math.max(max_profit, r - min_r);
			min_r = Math.min(min_r, r);
		}
		System.out.println(max_profit);
	}
}

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

int main() {
	int n;
	cin >> n;
	int a[n];
	for(int i = 0; i < n; ++i){
		cin>>a[i];
	}
	int ans = 0;
	int count = 0;
	for(int i = 0; i <= n - 2; ++i){
		if(a[i]>=a[i+1]) count++;
		else{
			ans = max(ans, count);
			count = 0;
		}
	}
	cout<<max(ans, count);
	return 0;
}

Measured memory_bytes: 640
n = int(input())
a = list(map(int, input().split()))
m = max(a)

def closest(x):
    res = None
    min_diff = None
    for k in a:
        if k == m:
            continue
        diff = abs(k - x)
        if res is None or min_diff > diff:
            min_diff = diff
            res = k
    return res

print(m, closest(m // 2))


Measured memory_bytes: 62704
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>().split_whitespace()
        .map(|e| e.parse().ok().unwrap()).collect()
}

fn main() {
    let nums: Vec<i32> = read_vec();
    let (a, b) = (nums[0], nums[1]);
    let mut height0 = 0;
    for i in 0..b-a {
        height0 += i;
    }
    println!("{}", height0 - a);
}


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

int main() {
  int a,b,c;
  while(cin >> a >> b >> c && a!=-1) {
    bool f=0;
    for(int i=2; i<17; i++) {
      int x=0,z=a;
      string s="";
      while(z) {
        s+=(char)(z%i+'0');
        z/=i;
      }
      reverse(s.begin(),s.end());
      bool ff=1;
      for(int j=0; j<s.size(); j++) {
        if(!isdigit(s[j])) ff=0;
        else if(s[i]-'0'>=i) ff=0;
      }
      if(!ff) continue;
      stringstream ss;
      ss << s;
      ss >> x;
      if(x==b) f=1;
    }
    if(!f) {
      cout << -1 << endl;
      continue;
    }
    for(int k=a+1; k<=c; k++) {
      int r=1<<29;
      for(int i=2; i<17; i++) {
        int x=0,z=k;
        string s="";
        while(z) {
          s+=(char)(z%i+'0');
          z/=i;
        }
        reverse(s.begin(),s.end());
        bool ff=1;
        for(int j=0; j<s.size(); j++) {
          if(!isdigit(s[j])) ff=0;
          else if(s[i]-'0'>=i) ff=0;
        }
        if(!ff) continue;
        stringstream ss;
        ss << s;
        ss >> x;
        if(b<=x) r=min(r,x);
      }
      b=r;
    }
    cout << b << endl;
  }
  return 0;
}

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

int main(){
    int n; cin>>n;
    
    vector<int> h(n);
    
    for(int i=0; i<n; i++) cin>>h[i];

    int count=0,ans=0;

    for(int i=0; i<n-1; i++){
        if(ans < n - i - 1){
            count = 0;
            int j=i;
            while(h[j] >= h[j+1]){
                if(j==n-1) break;
                count++;
                j++;
            }
        ans = max(count,ans);
        }
    }

    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include<string>
#include<cstring>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;
#define PI 3.141592653589793

long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

int main(){
  int s, t, d; cin >> d >> t >> s;
  if(s*t>=d) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 3592
#include<stdio.h>
#include<math.h>

int main(void){

  int n=0,x,i,j;
  char s[5];

  scanf("%s",s);

  for(i=0;i<3;i++){
    if(s[i] == s[i+1]){
      printf("Bad");
      break;
    }
    else
      n++;
  }

  if(n == 3)
  printf("Good");

  return 0;
}


Measured memory_bytes: 128
import std.stdio;
import std.range;
import std.array;
import std.algorithm;
import std.string;
import std.conv;

void main(){
    auto n = readln();
    auto s = readln().chomp();
    solve(s).writeln();
}

int solve(string s){
    int allE = s.filter!((ch) => ch == 'E').array().length.to!int;
    int allW = s.filter!((ch) => ch == 'W').array().length.to!int;
    int checkedE;
    int checkedW;
    int[] collection;
    foreach(dir; s) {
        if(dir == 'E'){
            checkedE++;
        }else{
            checkedW++;
        }
        if(dir == 'W'){
            collection ~= checkedW + (allE - checkedE) - 1;
        }else{
            collection ~= checkedW + (allE - checkedE);
        }
        // writefln("checkedE:%s chekedW:%s allE:%s leader:%s collection:%s", checkedE, checkedW, allE, dir, collection);
    }
    return collection.sort!("a < b")[0];
}

Measured memory_bytes: 4052
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;

int main()
{
    int n; cin >> n;
    vector<int> x(n);
    for(int i=0; i<n; i++)
        cin >> x[i];


    sort(x.begin(), x.end());
    int min_ans = 10000000;
    for(int i=x[0]; i<=x[n-1]; i++){
        int ans = 0;
        for(int j=0; j<n; j++){
            ans += pow(i - x[j], 2);
        }
        min_ans = min(min_ans, ans);
    }

    cout << min_ans << endl;

    return 0;
    

    
}

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

#define M_PI       3.14159265358979323846

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }
inline int readInt() { int x; scanf("%d", &x); return x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<int, PII> TIII;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;

//container util

//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SQ(a) ((a)*(a))
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,s,n) for(int i=s;i<(int)n;++i)
#define REP(i,n) FOR(i,0,n)
#define MOD 1000000007

const int N = 200010;
int h[N], a[N];
LL dat[600010];

struct segtree {
public:
	int N;
	segtree() {}
	segtree(int n) {
		N = 1;
		while (N < n) N *= 2;
		for (int i = 0; i < 2 * N - 1; i++)
			dat[i] = 0;
	}
	// update k th element
	void update(int k, LL a) {
		k += N - 1; // leaf
		dat[k] = a;
		while (k > 0) {
			k = (k - 1) / 2;
			dat[k] = max(dat[k * 2 + 1], dat[k * 2 + 2]);
		}
	}
	LL query(int a, int b) { return query(a, b, 0, 0, N); }
	LL query(int a, int b, int k, int l, int r) {
		if (r <= a || b <= l) return 0;
		if (a <= l && r <= b) return dat[k];
		int m = (l + r) / 2;
		return max(query(a, b, k * 2 + 1, l, m), query(a, b, k * 2 + 2, m, r));
	}
};

int main() {
	int n;
	scanf("%d", &n);
	REP(i, n)scanf("%d", &h[i]);
	REP(i, n)scanf("%d", &a[i]);
	segtree st(n+1);
	LL ret = 0;
	REP(i, n) {
		auto val = st.query(0, h[i]) + a[i];
		ret = max(ret, val);
		st.update(h[i], val);
	}
	cout << ret << endl;
	return 0;
}

Measured memory_bytes: 6528
#include <stdio.h>
int main(){
	double w,h,x,y;
	scanf("%lf%lf%lf%lf",&w,&h,&x,&y);
	double s= w*h/2;
	printf("%f ",s);
	
	if(x==w/2 && y==h/2) printf("1\n");
	else printf("0\n");
	
	return 0;
}

Measured memory_bytes: 128
import java.util.Scanner;

public class Main {
    public static void main(String[] args) throws Exception {
        // System.out.println("Hello Java");
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        if (s.equals("ABC"))
            System.out.println("ARC");
        if (s.equals("ARC"))
            System.out.println("ABC");
        sc.close();
    }
}

Measured memory_bytes: 26836
/* ****TCIITB**** */

#include<bits/stdc++.h>
#define io          ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0); 
#define ll          long long
#define pb          push_back
#define	endl		'\n'
#define pii         pair<ll int,ll int>
#define vi          vector<ll int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define hell        1000000007
#define rep(i,a,b)	for(ll int i=a;i<b;i++)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
#define time        cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
using namespace std;

#define N  100005

int main()
{
	
	io
	
	ll n,a,b;
	cin>>n>>a>>b;
	ll cnt=0;
	rep(i,a,b+1)
	{
		if(i%n==0)
			cnt++;
	}
	if(cnt)
		cout<<"OK";
	else
		cout<<"NG";
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
#define endl "\n"
using namespace std;

#define ll long long
const long long llINF = 1LL << 60;
const int iINF = 0x20000000;
template<class T> inline bool chmin(T& a, T b) { if (b < a) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

void execute();
int main() 
{
    cin.tie(nullptr);
    ios::sync_with_stdio(false);// cin と scanfの併用禁止
    cout << fixed << setprecision(15);
    execute();
    return 0;
}


void execute()
{
    ll K;
    cin >> K;

    set<ll> s;

    ll o = 1;
    ll v = 7;
    do
    {
        while(v < K) {v = v * 10 + 7;o++;}
        v = v % K;
        if(0 == v) {cout << o << endl; return;}
        auto result = s.insert(v);
        if(!result.second) break;
    }while(true);

    cout << -1 << endl; 
}


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


int main(){

    
    char a, b;


    cin >> a >> b;


    if( a == 'H' ){

        cout << b << endl;

        }

    else{

        if( b == 'H' ) cout << 'D' << endl;

        else cout << 'H' << endl;

        }


    return 0;

    }


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

#define int long long
#define vvi vector<vector<int>>
#define vec vector
#define pq priority_queue
#define all(v) (v).begin(), (v).end()
#define uniqueV(x) sort(x.begin(), x.end()); x.erase(unique(x.begin(), x.end()), x.end());
#define rep(i, n) for (int (i) = (0); (i) < (n); ++(i))
#define repp(i, m, n) for (int (i) = (m); (i) < (n); ++(i))
#define dbg(x) cerr << #x << ": " << x << endl;
#define dbg2(x, y) cerr<<"("<<#x<<", "<<#y<<") = "<<"("<<x<<", "<<y<<")"<<endl;
#define dbg3(x, y, z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = "<<"("<<x<<", "<<y<<", "<<z<<")"<<endl;
#define dbgB(value, size) cerr<<#value<<": "<<bitset<size>(value) << endl;
#define line() cerr << "---------------" << endl;

const int dx[] = {1, -1, 0, 0};
const int dy[] = {0, 0, -1, 1};
const double PI = 3.14159265358979323846;

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; }

template<typename T>
void print1(T begin, T end) {
	while (begin != end) {
		cerr << (*begin) << " ";
		*begin++;
	}
	cerr << endl;
}

template<typename T>
void print2(T Array, int height, int width) {
	for (int i = 0; i < height; i++) {
		for (int j = 0; j < width; j++) {
			cerr << " " << Array[i][j];
		}
		cerr << endl;
	}
}

void print() { std::cerr << endl; }
template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
	std::cerr << head << " ";
	print(std::forward<Tail>(tail)...);
}

template<class T>
void Add(T &a, const T &b, const T &mod=1000000007) {
	int val = ((a % mod) + (b % mod)) % mod;
	if (val < 0) { val += mod; }
	a = val;
}

template <typename X, typename T> auto vectors(X x, T a) { return vector<T>(x, a); }
template <typename X, typename Y, typename Z, typename... Zs> auto vectors(X x, Y y, Z z, Zs... zs) { auto cont = vectors(y, z, zs...); return vector<decltype(cont)>(x, cont); }

// ------------------------------------------------------------------------------------------

int a, b;

int f(int n) {
	return n * (n+1) / 2;
}

signed main() {
	cin >> a >> b;
	int c = b - a;

	for (int i = 1; i < 999; i++) {
		int x = f(i);
		int y = f(i+1);
		int dif = y - x;
		if (dif == c) {
			cout << x - a << endl;
			return 0;
		}
	}

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <functional>
#include <cstdlib>
#include <sstream>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <complex>
#include <vector>
#include <bitset>
#include <cstdio>
#include <cmath>
#include <time.h>
#include <tuple>
#define all(c) ((c).begin(),(c).end())
#define rall(c) ((c).rbegin(),(c).rend())
//#define sort(v,n) sort(v,v+n)
#define ll long long
#define fi first
#define se second
#define inf 999999999
using namespace std;
const ll MOD = 1e9 + 7;
const double PI = acos(-1.0);
//---------------------------------------------------------------------------------------------//
bool a[300000];
inline void sosuu() {
	for (int i = 0; i < 300000; i++) {
		a[i] = 1;
	}
	int now = 2;
	while (now<=150000) {
		if (a[now]) {
			for (int i = now * 2; i < 300000; i += now) {
				a[i] = 0;
			}
		}
		now++;
	}
	a[0] = 0;
	a[1] = 0;
}


int main() {
	sosuu();
	int n, p;
	while (cin >> n >> p) {
		if (n == -1)return 0;
		int cont = 0;
		bool flag = 0;
		vector<int> v;
		for (int i = n+1;i<300000; i++) {
			for (int j = n+1;j<=i; j++) {
				if (a[i] && a[j]) {
					cont++;
					v.push_back(i + j);
				}
				else {
					continue;
				}
				if (cont == p+1000) {
					flag = 1;
					break;
				}
			}
			if (flag)break;
		}
		sort(v.begin(), v.end());
		//for (int i = 0; i < v.size(); i++)cout << "v" << v[i] << endl;
		cout << v[p - 1] << endl;
	}
	return 0;
}

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

int main(){
  int n, k, d, a;
  cin >> n >> k;
  vector<bool> A(n, false);
  
  for(int i = 0; i < k; i++){
    cin >> d;
    for(int j = 0; j < d; j++){
      cin >> a;
      A.at(a - 1) = true;
    }
  }
  int count = 0;
  for(int i = 0; i < n; i++){
    if(!A.at(i)) count++;
  }
  
  cout << count << endl;
  
}

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

int main(){
	int H,W,i,j;
	while(1){
		cin>>H>>W;
			if(H==0&&W==0)break;
		for(i=0;i<H;i++){
			for(j = 0;j < W;j++){
				cout<<"#";
			}
		cout<<endl;
		}
	cout<<endl;
	}
return 0;
}



Measured memory_bytes: 3084
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.lang.reflect.Array;
import java.util.Arrays;
import java.util.ArrayList;
import java.util.Collections;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */

public class Main {
    public static void main(String[] args) {
        InputStream    inputStream    = System.in;
        OutputStream outputStream = System.out;
        InputReader    in                      = new InputReader(inputStream);
        PrintWriter      out                    = new PrintWriter(outputStream);
        Task                 solver               = new Task();
        solver.solve(1, in, out);
        out.close();
    }

    static class Task {
    	public void solve(int testNumber, InputReader in, PrintWriter out) {
    		int X = in.nextInt();
    		int A = in.nextInt();
    		int B = in.nextInt();
    		X -= A;
    		while(X - B >= 0) {
    			X -= B;
    		}
    		out.println(X);
    	}
    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}



Measured memory_bytes: 23380
#include <cstdio>
#include <cmath>
#include <cstring>
#include <deque>
#include <vector>
using namespace std;

typedef long long ll;
const int N = 1e5 + 5;
vector<int> edge[N];
deque<int> dque;
bool vis[N];
int n, m;

int has_next(int u) {
    for (int v: edge[u]) {
        if (!vis[v]) return v;
    }
    return 0;
}

void solve() {
    int f = 1, b = edge[1][0];
    vis[f] = vis[b] = true;
    dque.push_back(f);
    dque.push_back(b);
    while (f = has_next(f)) {
        vis[f] = true;
        dque.push_front(f);
    }
    while (b = has_next(b)) {
        vis[b] = true;
        dque.push_back(b);
    }
    printf("%d\n", dque.size());
    for (int i=0; i<dque.size(); ++i) {
        printf("%d%c", dque[i], i+1==dque.size() ? '\n' : ' ');
    }
}

int main() {
    scanf("%d%d", &n, &m);
    for (int i=1; i<=m; ++i) {
        int u, v;
        scanf("%d%d", &u, &v);
        edge[u].push_back(v);
        edge[v].push_back(u);
    }
    solve();
    return 0;
}


Measured memory_bytes: 6784
# @uthor : Kaleab Asfaw
import sys

input = sys.stdin.readline

def main(a, b, c, k):
    for i in range(k):
        if b <= a: b*= 2
        elif c <= b: c *= 2
    if b > a and c > b:
        return "Yes"
    return "No"
    
    


a, b, c = list(map(int, input().split()))
k = int(input())
print(main(a, b, c, k))




Measured memory_bytes: 9180
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <bitset>
#include <set>
#include <cmath>
using namespace std;

int main(){
    long long N, L;
    cin >> N >> L;
    vector<string> s(N);
    for(int i=0; i<N; i++)
        cin >> s[i];

    vector<vector<int>> v;
    v.push_back({-1, -1});

    for(int i=0; i<N; i++){
        int pos = 0;
        for(int j=0; j<s[i].size(); j++){
            int x = s[i][j] - '0';
            if(v[pos][x] == -1){
                v[pos][x] = v.size();
                v.push_back({-1, -1});
            }
            pos = v[pos][x];
        }
    }

    queue<pair<int, int>> que;
    que.push(make_pair(0, 0));
    vector<int> dep;
    while(!que.empty()){
        int s, d;
        tie(s, d) = que.front();
        que.pop();
        int cnt = 0;
        for(int i=0; i<2; i++)
            if(v[s][i] != -1){
                que.push(make_pair(v[s][i], d+1));
                cnt++;
            }
        if(cnt == 1)
            dep.push_back(d);
    }

    long long ans = 0;
    for(auto x : dep){
        long long tmp = L - x;
        tmp = tmp&(-tmp);
        ans ^= tmp;
    }
    cout << (ans!=0 ? "Alice" : "Bob") << endl;
    return 0;
}


Measured memory_bytes: 7344
#include<iostream>
#include<algorithm>
#include<functional>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<tuple>
#include<stack>
#include<queue>
#include<deque>
#include<sstream>
#include<stdio.h>
#include<math.h>
#include<stdlib.h>
#include<bitset>
#include<time.h>
#include<cstdlib>
#include<cassert>
#define ll long long
using namespace std;

int n,m,r;
vector<int> v;
ll dp[300][300];
const ll inf=(ll)1e14;
                 
int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.precision(10);
  cout<<fixed;
#ifdef LOCAL_DEFINE
    freopen("in", "r", stdin); 
    freopen("out","w",stdout);
#endif
  cin>>n>>m>>r;
  for(int i=0;i<r;i++){
    int a;cin>>a;
    a--;
    v.push_back(a);
  }
  for(int i=0;i<300;i++){
    for(int j=0;j<300;j++){
      dp[i][j]=inf;
    }
  }
  for(int i=0;i<m;i++){
    int a,b;
    ll c;
    cin>>a>>b>>c;
    a--;b--;
    dp[a][b]=c;
    dp[b][a]=c;
  }
  for(int k=0;k<n;k++){
    for(int i=0;i<n;i++){
      for(int j=0;j<n;j++){
        dp[i][j]=min(dp[i][j],dp[i][k]+dp[k][j]);
      }
    }
  }
  ll ans=(ll)1e14;
  sort(v.begin(),v.end());
  do{
    ll temp=0;
    for(int i=0;i<(int)v.size()-1;i++){
      temp+=dp[v[i]][v[i+1]];
    }
    //for(int i=0;i<(int)v.size();i++)cout<<v[i]<<" ";
    //cout<<endl;
    ans=min(ans,temp);
  }while(next_permutation(v.begin(),v.end()));
  cout<<ans<<endl;
#ifdef LOCAL_DEFINE
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
  return 0;
}

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

#define ll long long
#define Fi first
#define Se second
#define Pb push_back
#define vi vector<int>
#define vvi vector<vector<int>>
#define vvp vector<vector<pair<int,int>>>

const int INF = 1e9;
const int MOD = 1e9+7;

#define all(v) v.begin(),v.end()
#define output_s(a) printf("%s\n",(a).c_str())

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define Rep(i,n,m) for(int i=(int)(n);i<(int)(m);i++)
#define RepS(i,n,m) for(int i=(int)(n);i<=(int)(m);i++)
#define RRepS(i,n,m) for(int i=(int)(n);i>=(int)(m);i--)
#define RepA(x) for(auto &item:(x))

void CINT(){}
template <class Head,class... Tail>
void CINT(Head&& head,Tail&&... tail){
    cin>>head;
    CINT(move(tail)...);
}    
#define CIN(...) int __VA_ARGS__;CINT(__VA_ARGS__)
#define LCIN(...) ll __VA_ARGS__;CINT(__VA_ARGS__)
#define SCIN(...) string __VA_ARGS__;CINT(__VA_ARGS__)

template<typename TypeInt> //最大公約数
TypeInt GCD(TypeInt a,TypeInt b){
    if(a%b==0) return b;
    else return GCD(b,a%b);
}
template<typename TypeInt> //最小公倍数
TypeInt LCM(TypeInt a,TypeInt b){
    return a*b/GCD(a,b);
}

//library----------------------------------------------


int main(){
    CIN(N);
    bool flag = false;
    if(N<=81){
        RRepS(i,9,1){
            if(N%i==0&&N/i<10) {flag=true;break;}
        }
    }
    printf(flag?"Yes":"No");
    return 0;
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;
public class Main
{
	public static void main(String arg[])
	{
		Scanner in=new Scanner(System.in);
		for(;;)
		{
			int n=in.nextInt();
			if(n==0)
				return;
			int H=in.nextInt();
			int W=in.nextInt();
			int base[][]=new int[H+1][W+1];
			for(int i=0;i<H;i++)
				Arrays.fill(base[i], 0);
			for(int i=0;i<n;i++)
			{
				int h=in.nextInt();
				int w=in.nextInt();
				base[h][w]=1;
			}

			int S=in.nextInt();
			int T=in.nextInt();
			int max=0;
			for(int s=1;s<=H;s++)
				for(int t=1;t<=W;t++)
				{
					int cnt=0;
					for(int p=s;p<S+s;p++)
						for(int q=t;q<T+t;q++)
						{
							if(p>H||q>W)
								break;
							if(base[p][q]==1)
								cnt++;
						}
					max=Math.max(cnt, max);
				}
			System.out.println(max);
		}
	}
}

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

#define FOR(i, a, b) for(int i = a; i < b; i ++)
#define FORS(i, a, b, c) for(int i = a; i < b; i += c)
#define FORN(i, a, b) for(int i = a; i <= b; i ++)
#define FORD(i, a, b) for(int i = a-1; i >= b; i --)
#define FORE(i, b) for(auto &i:b)
#define REP(i, b) FOR(i, 0, b)
#define REPN(i, b) FORN(i, 0, b)
#define SQ(i) (i*i)
#define ALL(a) a.begin(), a.end()
#define ALLA(a,n) a, a+n
#define SORT(a) sort(ALL(a))
#define SORTA(a, n) sort(ALLA(a, n))
#define REV(a) reverse(ALL(a))
#define REVA(a, n) reverse(ALLA(a, n))
#define MAX(a, b) a = max(a, b)
#define MIN(a, b) a = min(a, b)
#define IN(a, b) (a.find(b) != a.end())
#define BACK(a) a.back(); a.RB()
#define QBACK(a) a.top(); a.pop()
#define PRINT(a) FORE(i, a) cout << i << " "; cout << endl

#define PB  push_back
#define RB  pop_back
#define RF  pop_front
#define INS insert
#define F   first
#define S   second
#define UM  unordered_map
#define US  unordered_set
#define PQ  priority_queue

#define IO ios_base::sync_with_stdio(false); cin.tie(NULL)

typedef long long ll;
typedef unsigned long long ull;

typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<ll> vll;
typedef pair<int,int> pi;
typedef pair<double,double> pd;
typedef pair<ll,ll> pll;
typedef queue<int> qi;
typedef queue<double> qd;
typedef queue<ll> qll;
typedef US<int> si;
typedef US<double> sd;
typedef US<ll> sll;
typedef vector<vi> mi;
typedef vector<vd> md;
typedef vector<vll> mll;
typedef vector<pi> vpi;
typedef vector<pd> vpd;
typedef vector<pll> vpll;


int main(){
  IO; string s; cin >> s;
  if(s[1]=='B')cout<<"ARC";
  else cout<<"ABC";
}


Measured memory_bytes: 3652
import java.util.*;

public class Main {

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

        if(S.equals("AAA") || S.equals("BBB")){
            System.out.println("No");
        } else {
            System.out.println("Yes");
        }

    }

}









Measured memory_bytes: 23252
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<map>
#include<math.h>

#define rep(i,a,n) for(int (i)=(a);(i)<(n);(i)++)
#define rrep(i,a,n) for(int (i)=(a);(i)>=(n);(i)--)

#define INF 1000000000
#define MOD 1000000007

typedef  long long ll;

using namespace std;

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

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

double euclid_distance(double a,double b){
    return sqrt(a*a+b*b);
}

ll gcd(ll  a,ll b){
    ll r;
    if(a < b){
        ll tmp;
        tmp = a;
        a = b;
        b = tmp;
    }
    while(r = a % b){
        a = b;
        b = r;
    }
    return b;
}

void Integer_factorization(long long int b,long long int n){
    long long int a = 2;
    long long int count = 0;
    long long int ans = 1;
    long long int ndash = n;
    if(b == 1) cout << n << endl;
    else{
    while(ndash >= a*a){
        if(n % a  == 0){
            count++;
            n/=a;

        if(count % b == 0){
            ans *= a;
        }
        }else{a++;count = 0;}
    }

    cout<<  ans << endl;
    }
}

ll wa(ll a,ll c,ll d,ll cd){
    ll t1 = (a-1)/c;
    ll t2 = (a-1)/d;
    ll t3 = (a-1)/cd;
    return  a-1-t1-t2+t3;
}

void solve() {
    ll a,b,c,d,cd;
    cin >> a >> b >> c >> d;
     
    cd = c*d/gcd(c,d);

    cout << wa(b+1,c,d,cd)-wa(a,c,d,cd) << endl;


}
int main() {

	cin.tie(0);
	ios::sync_with_stdio(false);

	solve();

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <algorithm>
#include <utility>
#include <iomanip>
#include <queue>
#include <functional>
#include <stack>
#include <map>
#include <vector>
#include <cmath>
#define ll long long
#define REP(i,n) for(int i=0;i<(n);i++)
#define PB push_back
#define MP make_pair
using namespace std;
int main(){
    for(;;){
        int n;
        cin>>n;
        if(n==0)
            break;
        int a[n];
        int tot=0;
        for(int i=0;i<n;i++){
            cin>>a[i];
            tot+=a[i];
        }
        tot/=n;
        int res=0;
        for(int i=0;i<n;i++){
            if(a[i]<=tot)
                res++;
        }
        cout<<res<<endl;
    }
}



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

using namespace std;

long long c[102][102], f[102][102];
const auto inf = 1145141919810364364ll;

int main()
{
	int N, b;
	auto a = 0ll;
	cin >> N;
	for (int i = 1; i <= N; i++) {
		for (int j = i + i; j <= N; j += i)
			c[i][j] = inf;
		cin >> b;
		if (b > 0) a += c[i][N + 1] = b;
		else c[0][i] = -b;
	}
	for (;;) {
		int p[102] = {};
		queue<int> q;
		q.push(0);
		while (!q.empty()) {
			int i = q.front();
			q.pop();
			for (int j = N + 2; --j;) {
				if (f[i][j] == c[i][j] || p[j])
					continue;
				p[j] = i + 1;
				if (j == N + 1) goto pnz;
				q.push(j);
			}
		}
		break;
	pnz:
		auto r = inf;
		for (int i = N + 1; i; i = p[i]) {
			p[i]--;
			r = min(r, c[p[i]][i] - f[p[i]][i]);
		}
		a -= r;
		for (int i = N + 1; i; i = p[i]) {
			f[p[i]][i] += r;
			f[i][p[i]] -= r;
		}
	}
	cout << a << endl;
	return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#include <math.h>  
#include <string>
#include <cstdio>
#include <iostream>
#include <algorithm> 

using namespace std;

// typedef signed long long ll;
typedef unsigned long long ull;
typedef vector< pair<int, int> > vec_int_pairs;
typedef vector<ull>  vecint;
typedef vector< vector<ull> > vecint2;
typedef vector< vec_int_pairs > graph;
typedef map<int, int> int_int_map;

int main() {
	int n;
	ull W;
	cin >> n >> W;
	
	vecint w, v;
	
	for (int i = 0; i < n; ++i) {
		int wi, vi;
		cin >> wi >> vi;
		w.push_back(wi);
		v.push_back(vi);
	}
	
	vecint2 dp(W + 1, vecint(n, 0));
	
	ull ans = 0;
	
	for (ull weight = 0; weight <= W; ++weight) {
		for (int i = 0; i < n; ++i) {
			ull res = 0;
			
			if (i - 1 >= 0) {
				res = max(res, dp[weight][i - 1]);
			}
			if (weight >= w[i]) {
				res = max(res, (i - 1 >= 0 ? dp[weight - w[i]][i - 1] : 0) + v[i]);
			}
			
			dp[weight][i] = res;
			
			ans = max(ans, res);
		}
	}
	
	cout << ans << endl;
}


Measured memory_bytes: 82304
#include <iostream>
#include <cstdio>
using namespace std;
int a[32] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 
14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
int k;
int main() {
	cin >> k;
	cout << a[k - 1];
	return 0;
}

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

int main()
{
    int n;
    std::cin >> n;
    std::map<int,int> mp;
    for(int i = 0; i < n; i++){
        int t;
        std::cin >> t;
        mp[t]++;
    }
    bool res = true;
    for(auto i : mp){
        if(i.second != 1)res = false;
    }
    std::cout << (res ? "YES" : "NO") << std::endl;
}

Measured memory_bytes: 9600
// بِسمِ اللہِ  الرَّحم?نِ  الرَّ حِیم
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define MOD 1000000007
#define ll long long
#define pb push_back
#define all(v) v.begin(),v.end()
#define INF 1e18
#define N 100100
#define PI 3.141592653589793238
typedef pair<ll,ll> pll;
ll power(ll a,ll b)
{
    if(b==1)return a;
    if(b==0)return 1;
    ll temp=power(a,b/2);
    ll ans=temp*temp;
    if(b&1)
        ans*=a;
    return ans;
}
ll power(ll a,ll b,ll p)
{
    a=a%p;
    if(b==1)return a;
    if(b==0)return 1;

    ll temp=power(a,b/2,p);
    ll ans=(temp*temp)%p;
    if(b&1)
        ans=(a*ans)%p;
    return ans%p;
}
ll inv(ll a,ll m)
{
    return power(a,m-2,m);
}
//code begins
void solve(){
    ll n,d;cin>>n>>d;
    ll cnt=0;
    while(n--){
        ll x,y;cin>>x>>y;
        if(x*x+y*y<=d*d)cnt++;
    }
    cout<<cnt<<endl;
}
signed main()
{
//    freopen("input.txt","r",stdin);
//    freopen("output.txt","w",stdout);

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

//    ll t;cin>>t;while(t--)
    solve();
    return 0;
}


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

using namespace std;
#define sync   freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);freopen("error.txt","w",stderr);
#define ll long long
#define INF 10e9+5
int main(){
	// sync;
	ll n,w;
	cin>>n>>w;
	vector<int> weight(n,0),value(n,0);
	ll tot_val=0;
	for(int i=0;i<n;i++){
		cin>>weight[i]>>value[i];
		tot_val+=value[i];
	}
	//dp[i] min wight to get total value i
	vector<ll> dp(tot_val+1,INF);
		dp[0]=0;
		for(int i=0;i<n;i++){
			for(int val_already=tot_val-value[i];val_already>=0;val_already--){
				// cout<<dp[val_already+value[i]]<<" ";
				dp[val_already+value[i]]=min(dp[val_already+value[i]],dp[val_already]+weight[i]);
				// cout<<dp[val_already+value[i]]<<endl;
			}

		}
	
	ll ans=0;
	for(int i=0;i<tot_val+1;i++){

		if(dp[i]<=w){
			ans=max(ans,(ll)i);
		}
	}		
cout<<ans;
}

Measured memory_bytes: 3940
import java.util.*;
 
public class Main {
  public static void main(String[] args) {
      Scanner sc = new Scanner(System.in);
      int N = Integer.parseInt(sc.next());
      int X = Integer.parseInt(sc.next());
      
      int i = 0;
      int D = 0;
      int bound=1;
      while(D <= X && i < N) {
          D = D + Integer.parseInt(sc.next());
          i++;
          if(D <= X)
          	bound+=1;
      }

      System.out.println(bound);
 
      sc.close();
      
  }
}

Measured memory_bytes: 23252
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
typedef long long ll;
struct st {
	ll sum;
	int index;

	bool operator<(const st& right)const {
		return sum == right.sum?index<right.index:sum<right.sum;
	}
	bool operator==(const st& right)const {
		return sum == right.sum;
	}
};

int n;
ll a[100000 * 2], ans = 0;
vector<st> sums;

int main() {
	cin >> n;
	ll sum = 0;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		sum += a[i];
		sums.push_back(st{ sum,i });
	}
	sort(sums.begin(), sums.end());

	/*for (int i = 0; i < sums.size(); i++) {
		cout << sums[i].sum << " ";
	}
	cout << endl;*/

	sum = 0;
	for (int i = 0; i <= n; i++) {
		//cout << "a" << endl;
		vector<st>::iterator low = lower_bound(sums.begin(), sums.end(), st{ sum, i });
		vector<st>::iterator up = upper_bound(sums.begin(), sums.end(), st{ sum, n });
		//cout << "b" << endl;
		//if (low == sums.end())cout << "end" << endl;
		//else cout << (*low).sum << endl;

		/*while (true) {
			//cout << "c" << endl;
			if (low == sums.end() || (*low).sum > sum)break;
			if ((*low).index < i) {
				++low;
				continue;
			}
			++low;
			ans++;
			//cout << "c" << endl;
		}*/
		ans += std::distance(low, up);
		sum += a[i];
		//cout << "d" << endl;
	}

	cout << ans << endl;
}

Measured memory_bytes: 7408
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef double db;

#define fr first
#define sc second
#define pb push_back
#define rep(i,x) for(ll i=0;i<x;i++)
#define rep1(i,x) for(ll i=1;i<=x;i++)
#define rrep(i,x) for(ll i=x-1;i>=0;i--)
#define rrep1(i,x) for(ll i=x;i>0;i--)

ll a,b;
ll A[5000],B[5000];
vector<ll> v[1000];
ll now;
ll ans=0;
ll cnt;

int main()
{
	scanf("%lld%lld",&a,&b);
	rep(i,a){
		scanf("%lld",&A[i]);
		A[i]--;
		v[A[i]].pb(i);
	}
	rep(i,b){
		scanf("%lld",&B[i]);
		B[i]--;
	}
	rep(i,b){
		cnt=0;
		now=-1;
		while(1){
			ll id=upper_bound(v[B[i+cnt]].begin(),v[B[i+cnt]].end(),now)-v[B[i+cnt]].begin();
			if(id==v[B[i+cnt]].size()) break;
			now=v[B[i+cnt]][id];
			cnt++;
		}
		ans=max(ans,cnt);
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 3444
//C - Factors of Factorial: 
//Assunto: Math/ Fatorial/ Divisores
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define loop(i, a, b) for(int i = a; i < b; i++)
#define loopBack(i, a, b) for(int i = a; i >= b; i--)
#define INF INT_MAX
#define LINF LLONG_MAX
#define DINF DBL_MAX
#define MAX 100050
#define MOD 1000000007
using namespace std;
typedef long long int ll;
typedef pair<int, int> ii;

map<int, int> factors;

void primeFactor(int x) {
    for(int i = 2; i * i <= x; i++) {
        while(x % i == 0) {
            factors[i]++;
            x /= i;
        }
    }
    if(x > 1) factors[x]++;
}

ll solve(int n) {
    ll a = 1;
    for(int i = n; i > 0; i--) primeFactor(i);
    for(auto x : factors) a = ((a % MOD) * ((x.se+1) % MOD)) % MOD;
    return a % MOD;
}

int main() {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    //freopen("in.txt", "r", stdin);
    //freopen("out.txt", "w", stdout);
    int n;
    ll ans;

    cin >> n;
    ans = solve(n);
    cout << ans << "\n";
}

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

int main(){
	int s;
	cin>>s;
	vector<int> A;
	int memory = s;
	A.push_back(memory);
	int M=1;
	while(1){	
		M += 1;
		if(memory%2==0){
			memory = memory/2;
		}	else if(memory%2==1){
			memory = 3*memory + 1;
		}
		auto it = find(A.begin(), A.end(), memory);
		if(it != A.end()){
			break;
		}
		A.push_back(memory);
	}
	cout<<M;
	return 0;
}	
				


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

#define REP(i,s,n) for(int i=s;i<n;i++)
#define rep(i,n) REP(i,0,n)
#define foreach(c,itr) for(__typeof((c).begin()) itr=(c).begin();itr!=(c).end();itr++)

using namespace std;

int h,w;
char a[12][12];
int dx[] = {-1,+0};
int dy[] = {+0,-1};
map<vector<int>,int> dp[12*12];

int uf[20];

inline void init() { rep(i,20) uf[i] = i; }

int find(int x) {
  if( uf[x] == x ) return x;
  return uf[x] = find(uf[x]);
}

void unit(int x,int y){
  x = find(x), y = find(y);
  if( x != y ) uf[x] = y;
}

bool isValid(int x,int y) { return 0 <= x && x < w && 0 <= y && y < h; }

vector<int> getState(vector<int> state,int x){
  if( state[x] == -1 ) state[x] = 123456;
  init();
  rep(i,w) rep(j,w) if( state[i] != -1 && state[j] != -1 && ( state[i] == state[j] || ( abs(i-j) == 1 && !( min(i,j) == x && max(i,j) == x+1 ) ) ) ) unit(i,j);

  int index = 0;
  vector<int> ret(w,-1);
  rep(i,w) if( state[i] != -1 && ret[i] == -1 ) {
    ret[i] = index++;
    rep(j,w) if( find(i) == find(j) ) ret[j] = ret[i];
  }
  return ret;
}

/*
  -1 : ???
  0<= : ???
 */
void compute(){
  {
    vector<int> init(w,-1);
    dp[0][init] = 0;
  }
  rep(y,h) rep(x,w) {
    int next = y * w + x + 1;
    foreach(dp[y*w+x],itr){
      vector<int> state = itr->first;
      int score = itr->second;

      // white
      if( a[y][x] != '#' ){
	bool success = true;
	rep(i,2) {
	  int nx = x + dx[i], ny = y + dy[i];
	  if( !isValid(nx,ny) ) continue;
	  if( state[nx] == -1 ) { success = false; break; }
	}
	if( success ) {
	  vector<int> nstate = state;
	  nstate[x] = -1;
	  success = false;
	  if( state[x] != -1 ) {
	    rep(i,w) if( i != x && state[i] == state[x] ) { success = true; break; }
	    if( x == w-1 && y == h-1 && state[x] >= 0 ) {
	      bool ok = false;
	      bool found = false;
	      rep(i,w) {
		if( i != x && state[x] == state[i] ) { ok = true; break; }
		if( i != x && state[i] >= 0 ) found = true;
	      }
	      if( !found || ok ) success = true;
	    }
	  } else success = true;

	  if( success ) {

	    if( !dp[next].count(nstate) || dp[next][nstate] < score ) dp[next][nstate] = score;
	  }
	}
      }

      // black
      if( a[y][x] != '.' ) {
	if( x-1 >= 0 && state[x-1] >= 0 && state[x-1] == state[x] ) continue;
	vector<int> nstate = getState(state,x);
	if( !dp[next].count(nstate) || dp[next][nstate] < score+1 ) dp[next][nstate] = score + 1;
      } 
    }
  }
  int maxi = -1;
  foreach(dp[h*w],itr) {
    bool success = true;
    rep(i,w) if( (itr->first)[i] > 0 ) { success = false; break; }
    if( success ) maxi = max(maxi,itr->second);
  }
  cout << maxi << endl;
}

int main(){
  cin >> h >> w;
  rep(i,h) {
    string s;
    cin >> s;
    rep(j,w) a[i][j] = s[j];
  }
  compute();
  return 0;
}

Measured memory_bytes: 42196
K = input().split()
N = int(K[0])
K = int(K[1])

count = 0
for b in range(K+1, N+1):
    siki1 = int((N-K)/b)
    siki2 = int((N-b+1)/b)
    if siki1 <= siki2:
        count += (b-K)*siki1
    elif siki1 > siki2:
        count += (b-K)*siki1
        count -= (b-N-1)*(siki1 - siki2)
        count -= b*(int((siki1*(siki1+1))/2) - int((siki2*(siki2+1))/2))

if K != 0:
    for a in range(K, N+1):
        count += N-a
if K == 0:
        for a in range(1, N+1):
            count += N-a

print(count)

Measured memory_bytes: 3064