akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>

using namespace std ;

long long lcm(long long  a,long long  b)
{
    return a*b/__gcd(a,b);
}


int main () {

    long long a , b , c , d , ans=0 ,div=0,k;

    cin >> a >> b >> c >> d ;
    k=lcm(c,d) ;
    a-- ;
    div+=(b/c-a/c) ;
   // cout << div << endl ;
    div+=(b/d-a/d) ;
  //  cout << div << endl ;
    div-=(b/k-a/k) ;
  //  cout << div << endl ;
    long long num=abs(b-a) ;
   // cout << num << endl ;
    ans=num-div ;



    cout << ans ;

    return 0 ;
}


Measured memory_bytes: 256
#include <vector>
#include <algorithm>
#include <numeric>
#include <cstdio>
using namespace std;
char T[10][10000];
int main(){
	int Y,X,i,j,r,y;
	for(;scanf("%d%d",&Y,&X),Y;printf("%d\n",r)){
		for(j=0;j<Y;j++)for(i=0;i<X;i++)scanf("%hhd",T[j]+i);

		vector<int> itx(X);iota(itx.begin(),itx.end(),0);
		vector<int> ity(Y);iota(ity.begin(),ity.end(),0);
		for(r=y=0;y<1<<Y;y++){
			r=max(r,accumulate(itx.begin(),itx.end(),0,[&](int s,int &i){
				int s0=accumulate(ity.begin(),ity.end(),0,[&](int s,int &j){
					return s+((y>>j&1)==T[j][i]);
				});
				return s+max(s0,Y-s0);
			}));
		}
	}
}

Measured memory_bytes: 1144
#include <bits/stdc++.h>
//#include <ext/pb_ds/tree_policy.hpp>
//#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
//using namespace __gnu_pbds;

#define ll    long long
#define PR    pair<ll, ll>

const int N = 3e5 + 5;
const int MOD = 1e9 + 7;
const double PI = 2 * acos(0.0);
//template<typename T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

int main() {
//    ios::sync_with_stdio(false);
//    cin.tie(0);
    ll x;
    cin >> x;
    for (ll i = -1000; i <= 1000; i++) {
        for (ll j = -1000; j <= 1000; j++) {
            ll a = i * i * i * i * i;
            ll b = j * j * j * j * j;
            if (a - b == x) {
                cout << i << " " << j << '\n';
                return 0;
            }
        }
    }
    return 0;
}


Measured memory_bytes: 3636
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		String[] s  = new String[N];
		for (int i=0; i<N; i++) {
			s[i] = sc.next();
		}
		int M = sc.nextInt();
		String[] t  = new String[M];
		for (int i=0; i<M; i++) {
			t[i] = sc.next();
		}
		Map<String, Integer> map = new HashMap<String, Integer>();
		for (int i=0; i<N; i++) {
			Integer c = map.get(s[i]);
			if (c == null) c = 1;
			else c++;
			map.put(s[i], c);
		}		
		for (int i=0; i<M; i++) {
			Integer c = map.get(t[i]);
			if (c == null) c = -1;
			else c--;
			map.put(t[i], c);
		}		
		int res = 0;
		Iterator<Integer> it = map.values().iterator();
		while (it.hasNext()) {
			Integer c = it.next();
			if (c>0)
			res = Math.max(c, res);
		}
		System.out.println(res);
	}
}


Measured memory_bytes: 21844
def dfs(nodes, graphs, start, departed_times, finished_times, current_time)
  departed_times[start] = current_time
  current_time += 1
  (1..nodes).each do |new_node|
    if graphs[start].include?(new_node) && departed_times[new_node].nil?
      current_time = dfs(nodes, graphs, new_node, departed_times, finished_times, current_time)
    end
  end
  finished_times[start] = current_time
  current_time + 1
end

nodes = gets.to_i
departed_times = Array.new(nodes + 1)
finished_times = Array.new(nodes + 1)
graphs = Array.new(nodes + 1) do [] end
nodes.times do |i|
  numbers = gets.chomp.split(" ").map(&:to_i)
  node = numbers[0]
  graph_number = numbers[1]
  graph_number.times do |j|
    graphs[i + 1].push(numbers[j + 2])
  end
end
current_time = 1
for i in (1..nodes) do
  current_time = dfs(nodes, graphs, i, departed_times, finished_times, current_time) if departed_times[i].nil?
end
nodes.times do |i|
  puts "#{i + 1} #{departed_times[i + 1]} #{finished_times[i + 1]}"
end

Measured memory_bytes: 8848
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <numeric>
#include <cmath>
#include <cassert>

using namespace std;

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

#define all(x) x.begin(),x.end()

const ll mod = 1e9+7;
const ll INF = 1e9;

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

int main()
{
	int a,b,c;
	cin>>a>>b>>c;
	cout<<((a<=c&&c<=b)?"Yes":"No")<<endl;
	return 0;
}

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

typedef long long ll;
typedef unsigned long long ull;

int main()
{
    ll N, x;
    cin >> N >> x;
    ll ai;
    ll res = 0;
    ll prev = 0;
    for(int i=0;i<N;i++){
        cin >> ai;
        if(prev+ai > x){
            res += (prev+ai) - x;
            prev = x-prev;
        }else{
            prev = ai;
        }
    }
    cout<<res<<endl;

    return 0;
}

Measured memory_bytes: 256
process.stdin.resume();
process.stdin.setEncoding('utf8');

var input_lines = [];
var reader = require('readline').createInterface({
  input: process.stdin,
  output: process.stdout
});

reader.on('line', (line) => {
  input_lines.push(line)
})

reader.on('close', () => {
  value = parseInt(input_lines[0])
  while (value - 1000 > 0) {
    value = value - 1000;
  }
  console.log(1000 - value)
})

Measured memory_bytes: 29980
let n = Scanf.sscanf (read_line ()) "%d" @@ fun n -> n
let p = Array.init n @@ fun _ -> int_of_string (read_line ())

let () =
  let t = Array.make (n + 1) 0 in
  Printf.printf "%d\n" @@ Array.fold_left (fun m i -> 
    t.(i) <- t.(i - 1) + 1; min m (n - t.(i))
  ) n p

Measured memory_bytes: 6400
#include <iostream>
#include <vector>
#include <iomanip>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

// 入力
int N;
vector<double> p;

// DP テーブル
double dp[3100][3100];

int main() {
    cin >> N;
    p.resize(N);
    for (int i = 0; i < N; ++i) cin >> p[i];
    
    // 初期条件
    dp[0][0] = 1.0;
    
    // DP ループ
    for (int i = 0; i < N; ++i) {
        for (int j = 0; j <= i; ++j) {
            dp[i+1][j+1] += dp[i][j] * p[i];
            dp[i+1][j] += dp[i][j] * (1.0 - p[i]);
        }
    }
    
    // 答え
    double res = 0.0;
    for (int j = (N+1)/2; j <= N; ++j) res += dp[N][j];
    cout << fixed << setprecision(10) << res << endl;
}

Measured memory_bytes: 72320
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <algorithm>
#include <cstring>
#include <cstdio>
#include <fstream>
#include <sstream>
#include <cstring>
using namespace std;
typedef long long ll;

int n, x;
int ps[40];

bool isp[1000010];
void sieve(){
    const int N = 1000000;
    memset(isp, true, sizeof(isp));
    
    isp[0] = false;
    isp[1] = true;
    
    for(int p=2;p*p<=N;p++)if(isp[p]){
        for(int j=p*p;j<=N;j+=p)isp[j] = false;
    }
}

bool can[1000010];
void gen(){
    memset(can, false, sizeof(can));
    can[0] = true;
    
    for(int sum=0;sum<x;sum++){
        for(int i=0;i<n;i++){
            if(sum + ps[i] <= x){
                can[sum + ps[i]] |= can[sum];
            }
        }
    }
}


int main(){
    sieve();
    
    while(cin >> n >> x){
        if(n == 0 && x == 0)break;
        
        for(int i=0;i<n;i++)cin >> ps[i];
        gen();
    
        int res = -1;
        for(int sum=x;sum>=1;sum--)if(can[sum] && isp[sum]){
            res = sum;
            break;
        }
        
        if(res == -1){
            cout << "NA" << endl;
        } else {
            cout << res << endl;
        }
    }
    
    return 0;
}

Measured memory_bytes: 3120
#include<bits/stdc++.h>
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int c1=0;
    int c2=0,c3=0,c4=0;
    int n;
    string a;
    cin>>n;
    while(n--)
    {
        cin>>a;
        if(a=="AC")
        {
            c1++;
        }
        else if(a=="WA")
        {
            c2++;
        }
        else if(a=="TLE")
        {
            c3++;
        }
        else
        {
            c4++;
        }  
    }
    cout<<"AC x "<<c1<<'\n';
    cout<<"WA x "<<c2<<'\n';
    cout<<"TLE x "<<c3<<'\n';
    cout<<"RE x "<<c4<<'\n';
}

Measured memory_bytes: 3644
N = int(input())
S = input()

count_white = [0] * (N + 1)
count_black = [0] * (N + 1)

for i in range(N - 1, -1, -1):
    if S[i] == ".":
        count_white[i] = count_white[i + 1] + 1
    else:
        count_white[i] = count_white[i + 1]

for i in range(0, N):
    if S[i] == "#":
        count_black[i + 1] = count_black[i] + 1
    else:
        count_black[i + 1] = count_black[i]

ans = float("inf")

for i in range(N + 1):
    temp = count_white[i] + count_black[i]
    if temp < ans:
        ans = temp

print(ans)


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

const int MAXN = 100010;
int d[MAXN];
int main() {
	int n;
	cin>>n;
	for (int i=0; i<n; i++)
		cin>>d[i];
	sort(d, d+n);
	if (d[n/2] == d[n/2-1])
		cout<<0<<endl;
	else
		cout<<d[n/2]-d[n/2-1]<<endl;
	return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <algorithm>

using namespace std;

int main()
{
	int N, K;
	cin >> N >> K;
	
	int *h = new int[N];
	for (int i = 0; i < N; ++i)
	{
		cin >> h[i];
	}
	
	sort(h, h + N);
	
	int min = 1000000000;
	for (int i = 0; i < N - K + 1; ++i)
	{
		int tmp = h[i + K - 1] - h[i];
		if (tmp < min) min = tmp;
	}
	
	cout << min;
}

Measured memory_bytes: 764
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
 
const int inf = 1e9;
const ll linf = 1e18;
const ll mod = 1e9 + 7;
 
int main() {
    int x[10][10];
    int n, d;
    cin >> n >> d;

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

    int cnt = 0;
    for (int i = 0; i < n - 1; i++) {
        for (int j = i + 1; j < n; j++) {
            int dist = 0;
            for (int k = 0; k < d; k++) dist += (x[i][k] - x[j][k]) * (x[i][k] - x[j][k]);

            for (int k = 0; k * k <= dist; k++) {
                if (k * k == dist) {cnt++; break;}
            }
        }
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <queue>
#include <algorithm>
#include <numeric>
#include <cstdio>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <cassert>
#include <climits>

using namespace std;

//typedef __int64 lint;

const double EPS = 1e-10;
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, 1, 0, -1};
const int INF = 1001001001;
//const lint INFLL = (__int64)1001001001001001001;

#define clear(a) memset((a), 0, sizeof(a))
#define mclear(a) memset((a), -1, sizeof(a))

#define show(x) cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

int main()
{
	int N, K;
	int k[10000];
	
	while (scanf("%d", &N) && N){
		for (int i = 0; i < N; i++)
			scanf("%d", k + i);
		
		sort(k, k + N);
		
		if (k[N - 1] < 2){
			printf("NA\n");
		}
		else {
			int sum = 0;
			for (int i = 0; i < N; i++){
				if (k[i] != 0) sum++;
			}
			printf("%d\n", sum + 1);
		}
	}
	return (0);
}

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

int main() {

  int N;
  string ans;
cin>>N;
  
  for(int i=1; i<10; i++){
 if(N%i==0 && N/i<10){ans="Yes";break;}
    else{ans="No";}
  }
	cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <math.h>
#include <iomanip>
#include <bitset>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <utility>
#include <set>
#include <queue>
using namespace std;
typedef long long int ll;
typedef long double ld;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
typedef pair<ll,ll> pairs;
vector<pairs> p;
bool pairCompare(const pair<double,ll>& firstElof, const pair<double,ll>& secondElof){
    return firstElof.first < secondElof.first;
}
bool pairCompareSecond(const pair<double,ll>& firstElof, const pair<double,ll>& secondElof){
    return firstElof.second < secondElof.second;
}
#define MAX_N 100100
#define MOD 1000000007
bool x[MAX_N];
ll num[MAX_N];
ll fibl[MAX_N]={0};
// 四方向への移動ベクトル
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

ll fib(ll a){
    if (fibl[a]!=0)return fibl[a];
    if (a==0){
        return 0;
    }else if (a==1){
        return 1;
    }
    return fibl[a]=fib(a-1)+fib(a-2);
}
 
ll eratosthenes(ll n) {
    int p = 0;
    for (ll i=0; i<=n; ++i) x[i] = true;
    x[0] = x[1] = false;
    for(int i=2; i<=n; ++i) {
        if(x[i]) {
            p++;
            for(int j=2*i; j<=n; j+=i) x[j] = false;
        }
        
        num[i] = p;
    }
    return p;
}
 
ll gcd(ll a,ll b){
    if (a%b==0)return(b);
    else return(gcd(b,a%b));
}
 
ll keta(ll N){
    int tmp{};
    while( N > 0 ){
        tmp += ( N % 10 );
        N /= 10;
    }
    N = tmp;
    return N;
}

void  base_num(ll data,ll base){
    if(data==0) return;
    ll next=abs(data)%abs(base);
    if(data<0) next=(abs(base)-next)%abs(base);
    base_num((data-next)/base,base);
    cout << next;
}


int main(){
    ll n,ans=0;
    cin >> n;
    ll a[n],b[200100];
    fill(b,b+200100,0);
    for (ll i=0;i<n;i++){
        cin>> a[i];
        if (a[i]+i+1<n){
            b[a[i]+i+1]=b[a[i]+i+1]+1;
        }
    }
    for (ll i=0;i<n;i++){
        if (i+1-a[i]>=0){
            ans+=b[i+1-a[i]];
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 6292
#include<bits/stdc++.h>
using namespace std;
int alllen=0;
struct str
{
	char s[270];
	int len;
	str(){ len=0; }
	bool operator < (const str &t)
	const
	{
		return len>t.len;
	}
	void ins(char c)
	{
		s[++len]=c;
	}
};
int query(str ss)
{
	printf("? ");
	for(int i=1;i<=ss.len;++i) putchar(ss.s[i]);
	putchar('\n'); fflush(stdout); 
	int x; scanf("%d",&x); 
	if(!alllen) return x;
	else return alllen-x;
}
void answer(str ss)
{
	printf("! ");
	for(int i=1;i<=ss.len;++i) // printf("%d ",ss.s[i]);
		putchar(ss.s[i]);
	putchar('\n');
	fflush(stdout);
}
str merge(str S,str T)
{
	int lens=S.len;
	for(int i=1,las=0;i<=T.len;++i)
	{
		S.ins(T.s[i]);
		for(int j=S.len;j>las+1;--j)
			swap(S.s[j],S.s[j-1]);
		las++; int x=query(S);
		while(x!=lens+i)
		{
			swap(S.s[las],S.s[las+1]);
			++las,x=query(S);
		}
	}
	return S;
}
priority_queue<str>q;
signed main()
{
	int tmp=0;
	for(int c='0';c<='9';++c)
	{
		str now;
		for(int i=1;i<=128;++i)
			now.ins(c);
		int match=query(now);
		tmp+=(match=128-match);
		if(!match) continue;
		str nx;
		for(int i=1;i<=match;++i)
			nx.ins(c);
		q.push(nx);
	}
	
	for(int c='a';c<='z';++c)
	{
		str now;
		for(int i=1;i<=128;++i)
			now.ins(c);
		int match=query(now);
		tmp+=(match=128-match);
		if(!match) continue;
		str nx;
		for(int i=1;i<=match;++i)
			nx.ins(c);
		q.push(nx);
	}
	
	
	for(int c='A';c<='Z';++c)
	{
		str now;
		for(int i=1;i<=128;++i)
			now.ins(c);
		int match=query(now);
		tmp+=(match=128-match);
		if(!match) continue;
		str nx;
		for(int i=1;i<=match;++i)
			nx.ins(c);
		q.push(nx);
	}
	
	alllen=tmp;
	
	while(q.size()>1)
	{
		str fir=q.top(); q.pop();
		str sec=q.top(); q.pop();
		q.push(merge(fir,sec));
	}
	answer(q.top());
}
/*
100110010
*/

Measured memory_bytes: 3860
#include<iostream>
using namespace std;
int main(){
  int n,m,l;
  long  nm[101][101],ml[101][101],nl[101][101]={};

  cin>>n>>m>>l;
  for(int i=0;i<n;i++){
      for(int j=0;j<m;j++){
        cin>>nm[i][j];
      }
  }    
  for(int i=0;i<m;i++){
    for(int j=0;j<l;j++){
        cin>>ml[i][j];
    }
  }
  for(int i=0;i<n;i++){
    for(int j=0;j<m;j++){
      for(int k=0;k<l;k++){
          nl[i][k]+=nm[i][j]*ml[j][k];
      }
    }
  }
  for(int i=0;i<n;i++){
    for(int j=0;j<l-1;j++){
        cout<<nl[i][j]<<" ";
    }
    cout<<nl[i][l-1]<<endl;
  }
  return 0;
}



Measured memory_bytes: 3328
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main() {
  int n, k;
  cin >> n >> k;
  vector<int> h(n);
  for (int i = 0; i < n; i++) {
    cin >> h[i];
  }
  sort(h.begin(), h.end());
  int ans = 1e9;
  for (int i = 0; i <= n - k; i++) {
    ans = min(ans, h[i + k - 1] - h[i]);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <string>
#include <tr1/unordered_set>

using namespace std;
using namespace std::tr1;
typedef long long ll;

ll s2ll(const string &s){
	ll x = 0;
	for(int i = 0; i < s.size(); ++i){
		x = (x << 4) | (s[i] - '0');
	}
	return x;
}

ll make_mask(int left, int right){
	ll m = 0x1111111111111111ll;
	m &= ~((1ll << (left << 2)) - 1);
	m &= ((1ll << (right << 2)) - 1);
	return m;
}

ll rotate(int k, ll x, ll m){
	x += m;
	ll c = ((x & (x >> 2)) >> 1) & 0x1111111111111111ll;
	x &= ~(c | (c << 1) | (c << 2) | (c << 3));
	x &= (1ll << (k << 2)) - 1;
	return x;
}

int dfs(int k, ll s, ll g){
	if(k == 0){ return 0; }
	if((s & 15) == (g & 15)){ return dfs(k - 1, s >> 4, g >> 4); }
	const ll m = 0x1111111111111111ll;
	ll t = s;
	while((t & 15) != (g & 15)){ t = rotate(k, t, m); }
	int answer = k;
	for(int i = 1; i <= k; ++i){
		ll n = (1ll << (i << 2)) - 1;
		answer = min(answer, dfs(k - 1, ((s & ~n) | (t & n)) >> 4, g >> 4));
	}
	return answer + 1;
}

int main(){
	while(true){
		int k;
		cin >> k;
		if(k == 0){ break; }
		string s1, s2;
		cin >> s1 >> s2;
		if(s1 == s2){
			cout << 0 << endl;
			continue;
		}
		ll initial = s2ll(s1), unlocked = s2ll(s2);
		cout << dfs(k, initial, unlocked) << endl;
	}
	return 0;
}

Measured memory_bytes: 1212
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  vector<int> value(N);
  vector<int> cost(N);
 
  for (int i = 0; i < N; i++) {
    cin >> value.at(i);
	}
  for (int i = 0; i < N; i++) {
    cin >> cost.at(i);
	}
  int get=0;
 
  for (int i = 0; i < N; i++) {
    if(cost.at(i)<value.at(i)){
      get=get+value.at(i)-cost.at(i);
    	}
	}
  cout << get << endl;
}
  

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

int main() {
    string s;
    cin >> s;
    int n = s.length();
    int a = (n - 1) / 2;
    int b = (n + 3) / 2;

    //条件1
    for (int i = 0; i < a; i++)
    {
        if (s[i] != s[n - (i + 1)]) {
            cout << "No" << endl;
            return 0;
        }
    }

    //条件2
    for (int i = 0; i < (a - 1 / 2); i++)
    {
        if (s[i] != s[a - (i + 1)])
        {
            cout << "No" << endl;
            return 0;
        }
    }

    //条件3
    for (int i = b; i < n; i++)
    {
        if (s[i - 1] != s[n - (i - b + 1)])
        {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdlib>
#include<string>
#include<map>
#include<algorithm>
#include<vector>
#include <queue>
#include<cmath>
using namespace std;
typedef long long ll;

const int INF = 1001001001;
int n;
vector<int> to[1005];

vector<int> bfs(int sv){
    vector<int> dist(n,INF), pre(n,-1);
    queue<int> q;
    dist[sv] = 0;
    q.push(sv);
    while(!q.empty()){
        int v=q.front(); q.pop();
        for(int u : to[v]){
            if(dist[u] != INF) continue;
            pre[u] = v;
            dist[u] = dist[v]+1;
            q.push(u);
        }
    }
    
    pair<int,int> best(INF,-1);
    for(int v(0);v<n;v++){
        if(v==sv)continue;
        for(int u : to[v]){
            if(u == sv){
                best = min(best,make_pair(dist[v],v));
            }
        }
    }
    if(best.first == INF) return vector<int>(n+1);
    int v = best.second;
    vector<int> res;
    while(v != -1){
        res.push_back(v);
        v = pre[v];
    }
    return res;
}

int main(){
    int m;
    cin >> n >> m;
    
    for(int i(0);i<m;i++){
        int a,b;
        cin >> a >> b;
        --a;--b;
        to[a].push_back(b);
    }
    
    vector<int> ans(n+1);
    for(int s(0);s<n;s++){
        auto now=bfs(s);
        if(now.size() < ans.size()) ans = now;
    }
    if(ans.size() == n+1){
        cout << -1 << endl;
        return 0;
    }
    cout << ans.size() << endl;
    for(int v : ans){
        cout << v+1 << endl;
    }
    return 0;
}






Measured memory_bytes: 384
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.*;
 

public class Main {	
	
	public static void main(String[] args) throws Exception {
		
		//int N = scan.nextInt();
		//long L = scan.nextLong();
		//double D = scan.nextDouble();
		//char[] A = scan.next().toCharArray();
		int N = scan.nextInt();
		
		out.println(N+N*N+N*N*N);
		out.flush();
	}
	
	static FastScanner scan = new FastScanner();
	static PrintWriter out = new PrintWriter(System.out);			 
	static long MOD = 1_000_000_007;

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

	//GCD最大公約数を返す
	static long gcd(long a, long b){
		if(b == 0) return a;
		return gcd(b, a%b);
	}

	//aとbの最小公倍数を返す
	static long lcm (long a, long b) {
		return ((a/gcd(a,b))*b);
	}
	
	//入力
	//https://qiita.com/p_shiki37/items/a0f6aac33bf60f5f65e4
	static class FastScanner {
	    private final InputStream in = System.in;
	    private final byte[] buffer = new byte[1024];
	    private int ptr = 0;
	    private int buflen = 0;
	    private boolean hasNextByte() {
	        if (ptr < buflen) {
	            return true;
	        }else{
	            ptr = 0;
	            try {
	                buflen = in.read(buffer);
	            } catch (IOException e) {
	                e.printStackTrace();
	            }
	            if (buflen <= 0) {
	                return false;
	            }
	        }
	        return true;
	    }
	    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
	    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
	    public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
	    public String next() {
	        if (!hasNext()) throw new NoSuchElementException();
	        StringBuilder sb = new StringBuilder();
	        int b = readByte();
	        while(isPrintableChar(b)) {
	            sb.appendCodePoint(b);
	            b = readByte();
	        }
	        return sb.toString();
	    }
	    public long nextLong() {
	        if (!hasNext()) throw new NoSuchElementException();
	        long n = 0;
	        boolean minus = false;
	        int b = readByte();
	        if (b == '-') {
	            minus = true;
	            b = readByte();
	        }
	        if (b < '0' || '9' < b) {
	            throw new NumberFormatException();
	        }
	        while(true){
	            if ('0' <= b && b <= '9') {
	                n *= 10;
	                n += b - '0';
	            }else if(b == -1 || !isPrintableChar(b)){
	                return minus ? -n : n;
	            }else{
	                throw new NumberFormatException();
	            }
	            b = readByte();
	        }
	    }
	    public int nextInt() {
	        long nl = nextLong();
	        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
	        return (int) nl;
	    }
	    public double nextDouble() { return Double.parseDouble(next());}
	}
}


Measured memory_bytes: 32700
#include <stdio.h>

int main(void)
{
    int i;
    int s, e;
    int n;
    
    scanf("%d", &n);
    
    while (n--){
        scanf("%d%d", &s, &e);
        
        if (e > s){
            for (i = s; i <= e; i++){
                printf("%d%c", i, i == e ? '\n' : ' ');
            }
        }
        else {
            if ((0 <= s && s <= 5)){
                for (i = s; i >= e; i--){
                    printf("%d%c", i, i == e ? '\n' : ' ');
                }
            }
            else {
                for (i = s; i <= 9; i++){
                    printf("%d ", i);
                }
                if (0 <= e && e <= 5){
                    for (i = 5; i >= e; i--){
                        printf("%d%c", i, i == e ? '\n' : ' ');
                    }
                }
                else {
                    printf("5 4 3 2 1 0 ");
                    for (i = 1; i <= e; i++){
                        printf("%d%c", i, i == e ? '\n' : ' ');
                    }
                }
            }
        }
    }
    
    return (0);
}

Measured memory_bytes: 0
import java.io.*;
import java.util.Scanner;


public class Main {

	private static Scanner sc;
	private static Printer pr;

	private static void solve() {
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();

		long p = Math.min(c, a + b + 1);

		pr.println(p + b);
	}

	// ---------------------------------------------------
	public static void main(String[] args) {
		sc = new Scanner(System.in);
		pr = new Printer(System.out);
			
		solve();
			
		pr.close();
		sc.close();
	}

	static class Printer extends PrintWriter {
		Printer(OutputStream out) {
			super(out);
		}
	}
}


Measured memory_bytes: 21972
import java.util.*;
class Main{
     public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
    
        System.out.printf("%d %d %.5f",a/b,a%b,(double)a/(double)b);
      
    }
}


Measured memory_bytes: 26560
#include <iostream>

using namespace std;

int main () {

    unsigned long N, x;
    cin >> N >> x;

    unsigned long a[N];

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

    unsigned long sum = 0;
    if (a[0] > x){
      sum += (a[0] - x);
        a[0] -= (a[0] - x);
        
    }
    for (int j=0; j<N-1; j++){
        if(a[j]+a[j+1] > x){
          sum += (a[j] + a[j+1] - x);
            a[j+1] -= (a[j] + a[j+1] - x);
            
        }
    }

    cout << sum << "\n";
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,n1,n2) for(int i=n1;i<n2;i++)
#define bFOR(i,n1,n2) for(int i=n1;i>=n2;i--)
#define speed_up    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

typedef long long int ll;
typedef pair<int,int> Pi;
const int INF=(ll)(1LL<<31)-1;
const ll INFl=(ll)9223372036854775807;
const int MAX=10000;
const ll MOD=(ll)1e9+7;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a, b)*b;}
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

int h,w;
int grid[22][22];
int ans=INF;

void dfs(int times,Pi p){
	
	if(times>=10)
		return;
	for(int i=0;i<4;i++){
		int nx=p.second+dx[i];
		int ny=p.first+dy[i];
		if(!(nx>=0&&nx<w&&ny>=0&&ny<h)||grid[ny][nx]==1){
			continue;
		}
		while(nx>=0&&nx<w&&ny>=0&&ny<h){
			if(grid[ny][nx]==3){
				ans=min(ans,times+1);
				return;
			}
			if(!(nx+dx[i]>=0&&nx+dx[i]<w&&ny+dy[i]>=0&&ny+dy[i]<h)){
				break;
			}
			if(grid[ny+dy[i]][nx+dx[i]]==1){
				grid[ny+dy[i]][nx+dx[i]]=0;
				dfs(times+1,Pi(ny,nx));
				grid[ny+dy[i]][nx+dx[i]]=1;
				break;
			}
			ny+=dy[i];nx+=dx[i];
		}
	}
	return;
}
vector<int> an;
int main(){
	while(1){
		ans=INF;
		cin>>w>>h;
		if(w==0&&h==0)break;
		int sh,sw;
		REP(i,h)
			REP(j,w){
				cin>>grid[i][j];
				if(grid[i][j]==2){
					sh=i;
					sw=j;
				}
			}
		dfs(0,Pi(sh,sw));
		if(ans==INF)an.push_back(-1);
		else an.push_back(ans);
	}
	REP(i,an.size()){
		cout<<an[i]<<endl;
	}
	return 0;
}


Measured memory_bytes: 3068
n = int(input())
s = input()
cnt = 0
for i in range(1000):
    p = '{:03}'.format(i)
    s2 = s
    for j in range(3):
        if s2.find(p[j]) == -1:
            break
        s2 = s2[s2.find(p[j]) + 1:]
    else:
        cnt += 1
print(cnt)

Measured memory_bytes: 3060
#include <iostream>
#define MAX 50
using namespace std;

int n, pre[MAX], in[MAX], post[MAX];
int pre_index = 0, post_index = 0, in_index[MAX];

void Reconstruction(int left, int right)
{
	if (left >= right) return;
	
	int root = pre[pre_index++];
	Reconstruction(left, in_index[root]);
	Reconstruction(in_index[root]+1, right);
	
	post[post_index++] = root;
}

int main ()
{
	
	cin >> n;
	for (int i = 0;i < n;i++)
	{
		cin >> pre[i];
	}
	for (int i = 0;i < n;i++)
	{
		cin >> in[i];
		in_index[in[i]] = i;
	}
	
	Reconstruction(0, n);
	
	cout << post[0];
	for (int i = 1;i < n;i++)
	{
		cout << " " << post[i];
	}
    cout << endl;
	return 0;
 } 


Measured memory_bytes: 3132
a=input()
b=input()
c=input()
t='a'
u=''
while True:
  u=t.upper()
  if t=='a':
    t=a[:1]
    a=a[1:]
  elif t=='b':
    t=b[:1]
    b=b[1:]
  else:
    t=c[:1]
    c=c[1:]
  if t=='':
    print(u)
    break


Measured memory_bytes: 3060
#define _USE_MATH_DEFINES
#include  <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <string>
#include<math.h>
#include<iomanip>
#include<stdio.h>
#include <stdlib.h>
#include<stdio.h>
#include <queue>
#include<map>
#include <sstream>
#include<set>
#include<stack>

//#include<bits/stdc++.h>


using namespace std;


int main() {

	long long int n, p;
	cin >> n >> p;
	long long int r = 0;
	long long int ans = 1;
	//p /= n;

	long long int i = 2;
	for (; i*i <= p; i ++) {
		r = 0;
	//	cout << p << endl;
		while (p&&p%i == 0) {
			p /= i;
			r++;
		//	cout << i << endl;
		}
		r /= n;
		for(int j=0;j<r;j++)ans *= i;
	}
	if (n == 1)ans *= p;
	cout << ans << endl;

	return 0;


}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <fstream>
#include <string>
#include <math.h>
#include <cstdlib>
#include <cstdint>
#include <istream>
#include <sstream>
#include <cctype>
#define fore(i,x,y) for(ll i=(x);i<(y);i++)
#define disp(a) cout << a << endl;
typedef long long ll;
using namespace std;

bool comp(const int& a, const int& b) {
	return a > b;
}

int main()
{
	ll N, M;
	vector<ll> H;
	vector<vector<ll>> vec;
	cin >> N >> M;
	vector<ll> ANS(N,0);
	for (int i = 0; i < N;i++) {
		ll t;
		cin >> t;
		H.push_back(t);
	}
	for (int i = 0; i < M; i++) {
		ll t,tt;
		vector<ll> tmp;
		cin >> t >> tt;
		//cout << H[t - 1] << " " << H[tt - 1] << endl;
		if (H[t - 1] == H[tt - 1]) {
			ANS[t - 1] = 1;
			ANS[tt - 1] = 1;
		}
		else if (H[t - 1] < H[tt - 1]) {
			ANS[t - 1] = 1;
		}
		else {
			ANS[tt - 1] = 1;
		}

	}
	size_t n_count = count(ANS.begin(), ANS.end(), 0);
	cout << n_count << endl;
	//cout << "##########" << endl;
	//for (int i = 0; i < ANS.size(); i++) {
		//cout << ANS[i] << " ";
	//}

}

Measured memory_bytes: 4660
cnt=0
def merge(A,left,mid,right):
    global cnt
    n1=mid-left
    n2=right-mid
    L=A[left:mid]+[1000000000]
    R=A[mid:right]+[1000000000]

    i=0
    j=0
    for k in range(left,right):
        if L[i]<=R[j]:
            A[k]=L[i]
            i+=1
        else:     
            A[k]=R[j]
            j+=1
            cnt+=mid -left - i

def mergeSort(A,left,right):
    global cnt

    if left+1< right:
        mid = int((left + right)/2)
        mergeSort(A, left, mid)
        mergeSort(A, mid, right)
        merge(A, left, mid, right)
n=int(input())
S=list(map(int,input().split()))
mergeSort(S,0,n)
print(cnt)


Measured memory_bytes: 27468
package main

import(
    "fmt"
    "sort"
    "strings"
)



func main() {
    var s string
    fmt.Scan(&s)
    a := 0
    b := 0
    for i:=0;i<len(s);i++{
       if s[i]=='A'{
           a = i
           break
       }
   }
   for i:=len(s)-1;i>=0;i--{
       if s[i]=='Z'{
           b = i
           break
       }
   }
   fmt.Println(b-a+1)
}





// Pairsort
type Pair struct {
    first,second int64
}

type By func(p1, p2 *Pair) bool

func (by By) Sort(pairs []Pair) {
    ps := &pairSorter{
            pairs : pairs,
            by: by,
    }
    sort.Sort(ps)
}

type pairSorter struct {
    pairs []Pair
    by func(p1, p2 *Pair) bool
}

func (s *pairSorter) Len() int {
    return len(s.pairs)
}

func (s *pairSorter) Swap(i, j int) {
    s.pairs[i], s.pairs[j] = s.pairs[j], s.pairs[i]
}

func (s *pairSorter) Less(i, j int) bool {
    return s.by(&s.pairs[i], &s.pairs[j])
}

func first (p1, p2 *Pair) bool {
        return p1.first < p2.first
}

func second (p1, p2 *Pair) bool {
        return p1.second < p2.second
}
// end



func abs32(a int) int {
    if a<0{
        return -a
    }
    return a
}

func abs64(a int64) int64 {
    if a<0{
        return -a
    }
    return a
}

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

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

func min64(a, b int64) int64 {
    if a >= b {
        return b
    }
    return a
}

func max64(a, b int64) int64 {
    if a >= b {
        return a
    }
    return b
}

func gcd(a, b int64) int64 {
    if a % b == 0 {
        return b
    } else {
        return gcd(b, a%b)
    }
}

func lcm(a, b int64) int64 {
    return a / gcd(a, b) * b
}

func scanNums(len int) (nums []int){
    var num int
    for i:=0; i<len; i++{
        fmt.Scan(&num)
        nums = append(nums,num)
    }
    return
}

func scanNums64(len int) (nums []int64){
    var num int64
    for i:=0; i<len; i++{
        fmt.Scan(&num)
        nums = append(nums,num)
    }
    return
}

func scanString(len int) (str []string){
    var s string
    for i:=0; i<len; i++{
        fmt.Scan(&s)
        str = append(str,s)
    }
    return
}

func makeTwoNums(n,m int) ([][]int){
    Nums := make([][]int, n)
    for i:=0; i<n; i++{
        Nums[i] = make([]int, m)
    }
    return Nums
}

func sortString(s string) string{
    t := strings.Split(s, "")
    sort.Strings(t)
    return strings.Join(t, "")
}

func reverseString(s string) string{
    t := []rune(s)
    for i,j := 0, len(s)-1 ; i < j ; i, j = i+1, j-1 {
        t[i], t[j] = t[j], t[i]
    }
    return string(t)
}

func inside(h,w,H,W int) bool{
    if h>=0 && h<H && w>=0 && w<W{
        return true
    }
    return false
}


Measured memory_bytes: 2048
#include <iostream>
#include <map>
#include <algorithm>

using namespace std;

int main()
{
    int n; cin >> n;
    map<string, int> s;
    int mx = 0;
    for (int i = 0; i < n; ++i) {
        string tmp;
        cin >> tmp;
        s[tmp] += 1;
        if (s[tmp] > mx) mx = s[tmp];
    }

    for (auto it : s) {
        if (it.second == mx) cout << it.first << endl;
    }

    return 0;
}

Measured memory_bytes: 25216
fun main(args: Array<String>) {
    val (a,b) = readLine()!!.split(" ").mapIndexed{ s ,i-> s.toLong()+i.toLong()-1 }
        .map{num->
            Array(62){i->
                2.toLong() shl i}.map{i->
                ((num-num%i)/2 + Math.max(num%i+1-i/2,0))%2
            }
        }
    var result:Long = 0
    for(i in 61 downTo  0) {
        if(a[i] != b[i]){
            result+= (1.toLong() shl i)
        }
    }
    println(result)
}

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

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SORT(c) sort((c).begin(),(c).end())
#define INF 999999999
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

int main()
{
	int input,output;
	vector<int> a;
	while(cin >> input) a.push_back(input);
	SORT(a);
	output = a[1] - a[0];
	output += a[2] - a[1];
	cout << output << endl;
	return 0;
}

Measured memory_bytes: 256
S=input()
N=len(S)
ans=[0]*N

cnt_o=1
cnt_e=0
idx=0
f=True   #True=R
for i in range(1,N):
    if f==True:
        if S[i]=="R":
            temp=cnt_e
            cnt_e=cnt_o
            cnt_o =temp+1
        else:
            ans[i-1]+=cnt_o
            ans[i]=cnt_e
            cnt_o=1
            cnt_e=0
            f=False
            idx=i
    else:
        if S[i]=="L":
            temp=cnt_e
            cnt_e=cnt_o
            cnt_o=temp+1
        else:
            ans[idx]+=cnt_o
            ans[idx-1]+=cnt_e
            cnt_o=1
            cnt_e=0
            f=True

ans[idx]+=cnt_o
ans[idx-1]+=cnt_e

for i in range(N):
    print(str(ans[i]),end=" ")




Measured memory_bytes: 4864
n = int(input())
p = list(map(int, input().split()))
cnt = 0
for i in range(1, n - 1):
  if min(p[i - 1], p[i], p[i + 1]) < p[i] < max(p[i - 1], p[i], p[i + 1]):
    cnt += 1
print(cnt)

Measured memory_bytes: 3060
using System;
using System.Collections;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Collections.Generic;
namespace Collections
{
	class program
	{
    //static long MAX_LONG = 5000000000000000;
		static void Main(string[] args)
		{

			// 入力
      //int[] input = Console.ReadLine().Split().Select(p => int.Parse(p)).ToArray();
      //int N = input[0];
      long N = long.Parse(Console.ReadLine());
      if(N == 0)
        {
          Console.WriteLine("0");
          return;
        }
      long[] bi = new long[100]; // (-2)^iを格納する
      bi[0] = 1;
      long sum = 0;
      char[] ret = new char[100];

      int cnt = 0;
      for(int i=0; ; i++)
      {
        // sum >= Nになるまでたす
        if(i>0)
        {
          bi[i] = bi[i-1] * -2;
        }
        if(N>0)
        {
          if(bi[i] > 0)
          {
            sum += bi[i];
            ret[i] = '1';
          }
          else
          {
            ret[i] = '0';
          }

          if(sum >= N)
          {
          cnt = i;
            break;
          }
        }
        else
        {
          if(bi[i] < 0)
          {
            sum += bi[i];
            ret[i] = '1';
          }
          else
          {
            ret[i] = '0';
          }

          if(sum <= N)
          {
          cnt = i;
            break;
          }
        }

      }
//Console.WriteLine(sum + " debug1 " + cnt);
      // sum = Nになるまでマイナスする
      for(int i = cnt; i>=0 ; i--)
      {
        if(N>0)
        {
          if(bi[i] > 0)
          {
            if(sum - bi[i] >= N)
            {
              ret[i] = '0';
              sum -= bi[i];
            }
          }
          else
          {
            if(sum + bi[i] >= N)
            {
              ret[i] = '1';
              sum += bi[i];
            }
          }
        }
        else
        {
          if(bi[i] < 0)
          {
            if(sum - bi[i] <= N)
            {
              ret[i] = '0';
              sum -= bi[i];
            }
          }
          else
          {
            if(sum + bi[i] <= N)
            {
              ret[i] = '1';
              sum += bi[i];
            }
          }
        }

      }

      // これが終わったらNになっているはず
      for(int i=cnt; i>=0; i--)
      {
        Console.Write(ret[i]);
      }
      Console.WriteLine();

    }
	}
}


Measured memory_bytes: 13140
#include <cstdio>
#include <string>
#include <algorithm>
#include <iostream>

using namespace std;

char t[5'009];

int main() {
  int n, k;
  scanf("%d%d", &n, &k);
  scanf("%s", t);
  string s = string(t);
  string rs = string(t);
  reverse(rs.begin(), rs.end());
  s += rs;
  string best = s.substr(0, n);
  for (int i = 0; i < n; ++i) {
    best = min(best, s.substr(i, n));
  }
  int pref = 0;
  while (pref < n && best[pref] == best[0]) {
    ++pref;
  }
  --k;
  int len = pref;
  while (k > 0 && len < n) {
    --k;
    len *= 2;
  }
  len = min(len, n);
  string ans = string(len, best[0]);
  if (len < n) {
    ans += best.substr(pref, n - len);
  }
  printf("%s\n", ans.c_str());
}


Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <utility>
#include <map>
#include <list>
#include <climits>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <bitset>
#include <string>

// #define cerr if(false)cerr
#define watch(x) cerr << "> " << #x << ": " << x << "\n";

using namespace std;

template <typename T>
std::ostream &operator <<(std::ostream &out, vector<T> &v) {
	for (typename vector<T>::size_type i = 0; i < v.size(); ++i)
		out << v[i] << " ";
	out << "\n";
    return out;
}
template <typename T, typename N>
std::ostream &operator <<(std::ostream &out, vector<pair<T, N> > &v) {
	for (size_t i = 0; i < v.size(); ++i)
		out << "(" << v[i].first << ", " << v[i].second << ") ";
	out << "\n";
    return out;
}
template <typename T>
std::ostream &operator <<(std::ostream &out, vector<vector<T> > &v) {
	for (size_t i = 0; i < v.size(); ++i) {
		for (size_t j = 0; j < v[i].size(); ++j) {
			out << v[i][j] << " ";
		}
		out << "\n";
	}
   	return out;
}

int main() {

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

	int n;
	cin >> n;

	long long tuples = 0;
	for (int a = 1; a <= n; ++a) {
		for (int b = 1; b <= n; ++b) {
			if (n - a * b >= 1) {
				++tuples;
			} else {
				break;
			}
		}
	}

	cout << tuples << "\n";

	return 0;

}

Measured memory_bytes: 3652
N, K = (int(x) for x in input().split())
S = input()

con = {
    'A':'a',
    'B':'b',
    'C':'c'
    }
ans = []
for i,s in enumerate(S):
    if i == K-1:
        ans.append(con[S[K-1]])
    else:
        ans.append(S[i])

ans = ''.join(ans)
print(ans)

Measured memory_bytes: 3064
n=int(input())
c=[int(input()) for _ in range(n)]
color_sum=[0]*200001
dp=[0]*(n+1)
dp[0]=1
dp[1]=1
color_sum[c[0]]+=1
# i個目まで考えたときの解。求めるのはdp[n]
# dp[i]:i個目より前で、i個目と同じ色の石があるところをjとして、dp[j-1]の和+dp[i-1]
for i in range(1,n): #二個目からn-1個目の計算をする。
  dp[i+1]=dp[i]
  if c[i]==c[i-1]:
    continue
  dp[i+1]+=color_sum[c[i]]
  color_sum[c[i]]=dp[i+1]
print(dp[n]%(pow(10,9)+7))

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

class UnionFind {
public:
    UnionFind(int64_t n) {
        //parが負の場合, このグループに属する要素数 * (-1)を示す
		//parが正の場合, 親の値を返す
        par_.resize(n, -1);
		// rankは木の深さ
		rank_.resize(n, 0);
    }
 
    //根を求める
    int64_t root(int64_t x) {
        return (par_[x] < 0 ? x : par_[x] = root(par_[x]));
    }
 
    //xとyの属する集合を併合
    void unite(int64_t x, int64_t y) {
        x = root(x);
        y = root(y);
        if (x == y) {
            return;
        }
 
		// xのサイズがyのサイズより大きいとき
		if(rank_[x] > rank_[y]) {
        	//要素数を足す(負の数だがそのまま足せば良い)
        	par_[x] += par_[y];
        	//yをxに繋げる
        	par_[y] = x;
		} else {
			par_[y] += par_[x];
			par_[x] = y;
			if(rank_[x] == rank_[y]) {
				rank_[y]++;
			}
		}
    }
 
    //xとyが同じ集合に属するか否かを判定
    bool same(int64_t x, int64_t y) {
        return (root(x) == root(y));
    }
 
    //xと同じ集合に属する要素数を返す
    int64_t size(int64_t x) {
        x = root(x);
        return -par_[x];
    }
private:
    vector<int64_t> par_;
	vector<int64_t> rank_;
};
 
int main(){
	int64_t N, M, K;
	cin >> N >> M >> K;

	UnionFind uf(N);
	vector<int64_t> blocks(N, 0), friends(N, 0);

	for(int m=0;m<M;m++) {
		int64_t a, b;
		cin >> a >> b;
		a--, b--;
		uf.unite(a,b);
		friends[a]++;
		friends[b]++;
	}

	for(int k=0;k<K;k++) {
		int64_t c, d;
		cin >> c >> d;
		c--, d--;
		if(uf.same(c, d)) {
			blocks[c]++;
			blocks[d]++;
		}
	}
	for(int i=0;i<N;i++) {
		if(i==0) cout << uf.size(i) - friends[i] - blocks[i] - 1;
		else cout << " " << uf.size(i) - friends[i] - blocks[i] - 1;
	}
	cout << endl;
}

Measured memory_bytes: 3968
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <set>
#include <vector>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <numeric>
#include <functional>
using namespace std;

#define Rep(b, e, i) for(int i = b; i <= e; i++)
#define Repr(e, b, i) for(int i = e; i >= b; i--)
#define rep(n, i) Rep(0, n-1, i)
#define repr(n, i) Repr(n-1, 0, i)
#define all(v) (v).begin(), (v).end()
#define pb(v) push_back(v)
#define uniq(v) (v).erase(unique(all(v)),(v).end())
#define bitcnt(x) __builtin_popcount(x)

typedef long long ll;

void solve(void){
    ll N, M;
    cin >> N >> M;
    if (N <= 0 && 0 <= M) {
        cout << "Zero" << endl;
        return;
    }
    else if (0 < N || (M-N)&1) {
        cout << "Positive" << endl;
        return;
    }
    
    cout << "Negative" << endl;
}

int main(void){
  solve();
  //cout << "yui(*-v・)yui" << endl;
  return 0;
}


Measured memory_bytes: 256
import collections

N = int(input())
S = input()
tonum = {"R": 0, "G": 1, "B": 2}
ans = 0
for i in range(1, N - 1):
    d = tonum[S[i]]
    c2 = collections.Counter()
    for j in range(i + 1, N):
        c2[tonum[S[j]]] += 1
    for j in range(i):
        dj = tonum[S[j]]
        if dj == d:
            continue
        dk = 3 - d - dj
        ans += c2[dk]
        kk = i + (i - j)
        if kk < N and tonum[S[kk]] == dk:
            ans -= 1
print(ans)


Measured memory_bytes: 69452
from sys import stdin
nii=lambda:map(int,stdin.readline().split())
lnii=lambda:list(map(int,stdin.readline().split()))
from collections import deque

n,u,v=nii()
u-=1
v-=1

tree=[[] for i in range(n)]
for i in range(n-1):
  a,b=nii()
  a-=1
  b-=1
  tree[a].append(b)
  tree[b].append(a)

dist_a=[-1 for i in range(n)]
dist_a[v]=0

dist_t=[-1 for i in range(n)]
dist_t[u]=0


def BFS(dist,s):
  que=deque()
  que.append(s)

  while que:
    x=que.popleft()
    for i in tree[x]:
      if dist[i]==-1:
        que.append(i)
        dist[i]=dist[x]+1
  return dist

dist_a=BFS(dist_a,v)
dist_t=BFS(dist_t,u)

ans=0
for i in range(n):
  if dist_a[i]>dist_t[i]:
    ans=max(ans,dist_a[i]-1)

print(ans)

Measured memory_bytes: 33732
def gcd(a,b):
    if a<b:
        a,b=b,a
    while b!=0:
        a,b=b,a%b
    return a
def lcm(a,b):
    return a*b//gcd(a,b)
a=1
for _ in range(int(input())):
    a=lcm(a,int(input()))
print(a)

Measured memory_bytes: 3064