akhauriyash/Code-Regression huggingface dataset:
N = int(input())

a = [int(input()) for i in range(N)]

b = a[0]
li = [0]
c = 1

while b != 2:
    li += [b-1]
    b = a[b-1]
    c += 1
    if c > N:
        print(-1)
        break
else:
    print(c)


Measured memory_bytes: 11008
import numpy as np
K, X = map(int, input().split())

tmp = X + K
tmp2 = X - K + 1

ans = np.arange(tmp2, tmp)
for i, v in enumerate(ans):
    print(' {}'.format(v), end='') if i > 0 else print('{}'.format(v), end='')
print('')


Measured memory_bytes: 14424
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define ALL(x) (x).begin(), (x).end()
#define REP(i ,n) for(int i = 0; i < (int)(n); i++)
#define pb push_back
typedef vector<int>vint;
typedef vector<ll>vll;
template<typename T> istream &operator>>(istream &is, vector<T> &vec){ for (auto &v : vec) is >> v; return is; }
template<typename A,typename B>inline bool chmin(A &a,const B &b){if(a>b){a=b;return true;}else{return false;}}
template<typename A,typename B>inline bool chmax(A &a,const B &b){if(a<b){a=b;return true;}else{return false;}}

int main()
{
    ll N,M,K;
    cin >> N >> M >> K;
    string ans = "No";
    REP(n,N+1){
        REP(m,M+1){
            if((M*n+N*m-2*n*m) == K){
                ans = "Yes";
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3604
#include <iostream>
#include <iomanip>
#include <string>
#include <string.h>
#include <math.h>
#include <cmath>
#include <vector>
#include <deque>
#include <set>
#include <map>
#include <algorithm>

typedef long long ll;
typedef unsigned long long ull;
typedef std::pair<int, int> intpair;
typedef std::pair<long long, long long> llpair;

#define mod 1000000007
#define rep(i, n) for(int i = 0; i < n; ++i)
#define REP(i, m, n) for(int i = m; i < n; ++i)
#define rrep(i, n) for(int i = n; i >= 0; --i)
#define RREP(i, m, n) for(int i = n; i >= m; --i)

using namespace std;

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

	int n;
	cin >> n;
	llpair* p;
	p = new llpair[n];
	rep(i, n) {
		ll num;
		cin >> num;
		p[i] = llpair(num, i);
	}

	sort(p, p + n);

	set<int> s;

	s.insert(n);
	s.insert(-1);
	s.insert(p[n - 1].second);


	ll ans = 0;
	rrep(i, n - 2) {
		s.insert(p[i].second);
		auto t = s.find(p[i].second);
		ll x, w, y, z;

		x = *--t;
		if (t == s.begin()) {
			w = x;
		}
		else {
			w = *--t;
			++t;
		}
		++t;

		y = *++t;
		if (t == s.find(n)) {
			z = y;
		}
		else {
			z = *++t;
		}

		ans += p[i].first * ((x - w)*(y - p[i].second) + (p[i].second - x)*(z - y));
	}

	cout << ans << "\n";
 }


Measured memory_bytes: 6528
h,w = map(int,input().split())
S = [input() for i in range(h)]

move = [[0,1],[0,-1],[1,0],[-1,0],[1,1],[-1,1],[1,-1],[-1,-1]]
for i in range(h):
    ans = []
    for j in range(w):
        cnt = "#"
        if S[i][j] == "#":
            ans.append("#")
            continue
        cnt = 0
        for mx,my in move:
            x,y = i+mx,j+my
            if 0 > x or x >= h or 0 > y or y >= w:continue
            if S[x][y] == "#":
                cnt += 1
        ans.append(str(cnt))
    print("".join(ans))




Measured memory_bytes: 3064
<?php

list($n, $m) = explode(' ', trim(fgets(STDIN)));

for($i = 0; $i < $n; $i++) {
    $work = explode(' ', trim(fgets(STDIN)));
    $a[] = $work;
}

for($i = 0; $i < $m; $i++) {
    $work = trim(fgets(STDIN));
    $b[] = $work;
}

for ($i = 0; $i < $n; $i++) {
    $sum = 0;
    for ($j = 0; $j < $m; $j++) {
        #printf("a[%s][%s]:%s\n", $i, $j, $a[$i][$j]);
        #printf("b[%s]:%s\n", $i, $j, $b[$j]);
        $sum += ((int)$a[$i][$j] * (int)$b[$j]);
    }
    #var_dump($sum);
    echo $sum .PHP_EOL;
}

Measured memory_bytes: 10964
n = gets.to_i
if n == 1
  puts "a"
  exit
end

q = [["a", "a"]]
ans = []
until q.empty?
  s, c_max = q.shift
  if s.size < n
    "a".upto(c_max) do |c|
      q << [s + c, c_max]
    end
    q << [s + ((c_max).ord + 1).chr, ((c_max).ord + 1).chr]
  else
    ans << s
  end
end
puts ans


Measured memory_bytes: 21624
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int N = scanner.nextInt();
		int x = N/1000;
		int y = 0;
		if (N%1000 != 0) {
			y = 1000*(x+1) - N;
		} else {
			y = 1000*x - N;
		}
		System.out.println(y);
	}
}


Measured memory_bytes: 35576
//#include <bits/stdc++.h>
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
//#include "boost/multiprecision/cpp_int.hpp"
//typedef boost::multiprecision::cpp_int ll;
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2

ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
typedef pair<dd,dd> d_d;
ll inf=(ll)1E16;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define fi first
#define se second
#define endl "\n"
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
//template<class T>void max(T a,T b){if(a<b)return b;else return a;}
//template<class T>void min(T a,T b){if(a>b)return b;else return a;}
//template<class T>bool Max(T&a, T b){if(a < b){a = b;return 1;}return 0;}
//template<class T>bool Min(T&a, T b){if(a > b){a = b;return 1;}return 0;}

//////////////////////////

void yes(){
    cout<<"Yes"<<endl;
}
void no(){
    cout<<"No"<<endl;
}

vector<string>ans;
ll n;
void dfs(string s,ll k,ll len){
    if(len==n){
        ans.pb(s);
        return;
    }
    rep(i,0,k){
        char ad=(char)('a'+i);
        ll nexk=k+1;
        rep(j,0,len-1){
            if(s[j]==ad){
                nexk=k;break;
            }
        }
        if(len==0)nexk=1;
        dfs(s+ad,nexk,len+1);
    }
}

int main(){fastio
    cin>>n;
    dfs("",0,0);
    SORT(ans);
    for(auto x:ans){
        cout<<x<<endl;
    }
    
    return 0;
}


Measured memory_bytes: 9716
import sys
import math

a1,a2,a3,a4,a5 = list(map(int,input().split()))

if a1 == 0:
    print(1)
elif a2 == 0:
    print(2)
elif a3 == 0:
    print(3)
elif a4 == 0:
    print(4)
elif a5 == 0:
    print(5)

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

int main(){
    vector<bool> prime(55556);
    for (int i = 0; i<55556; i++) prime[i] = true;
    prime[0] = false;
    prime[1] = false;
    for(int i = 2; i<=sqrt(55556); i++){
        if(prime[i]){
            for(int j = i*2; j<55556; j += i){
                prime[j] = false;
            }
        }
    }
    int n;
    cin >> n;
    int cnt = 0;
    bool flag;
    for(int i = 2; i<55556; i++){
        flag = false;
        if (prime[i] && i%5 == 1){
            cout << i;
            cnt++;
            flag = true;
        }
        if (cnt == n) break;
        if (flag) cout << " ";
    }
}


Measured memory_bytes: 256
// {{{ by unolight
#include <bits/stdc++.h>
#include <unistd.h>
#pragma GCC diagnostic ignored "-Wunused-result"
#pragma GCC diagnostic ignored "-Wunused-function"
#define SZ(x) ((int)(x).size())
#define ALL(x) begin(x),end(x)
#define RALL(x) rbegin(x),rend(x)
#define REP(i,n) for ( int i=0; i<int(n); i++ )
#define REP1(i,a,b) for ( int i=(a); i<=int(b); i++ )
#define MP make_pair
#define PB push_back
using namespace std;
typedef int64_t LL;
typedef pair<int,int> PII;
typedef vector<int> VI;

namespace { namespace unolight {
// Read Input
template<class T> void _R( T &x ) { cin>>x; }
void _R( int &x ) { scanf("%d",&x); }
void _R( int64_t &x ) { scanf("%" PRId64,&x); }
void _R( double &x ) { scanf("%lf",&x); }
void _R( char &x ) { scanf(" %c",&x); }
void _R( char *x ) { scanf("%s",x); }
void R() {}
template<class T, class... U> void R( T& head, U&... tail ) { _R(head); R(tail...); }
// Write Output
template<class T> void _W( const T &x ) { cout<<x; }
void _W( const int &x ) { printf("%d",x); }
void _W( const int64_t &x ) { printf("%" PRId64,x); }
void _W( const double &x ) { printf("%.16f\n",x); }
void _W( const char &x ) { putchar(x); }
void _W( const char *x ) { printf("%s",x); }
template<class T> void _W( const vector<T> &x ) { for (auto i = x.begin(); i != x.end(); _W(*i++)) if (i != x.cbegin()) putchar(' '); }
void W() {}
template<class T, class... U> void W( const T& head, const U&... tail ) { _W(head); putchar(sizeof...(tail)?' ':'\n'); W(tail...); }

#ifdef UNOLIGHT
#include "dump.hpp"
#else
#define dump(...)
#endif

template<class T> inline bool chmax( T &a, const T &b ) { return b>a ? a=b,true : false; }
template<class T> inline bool chmin( T &a, const T &b ) { return b<a ? a=b,true : false; }
template<class T> using MaxHeap = priority_queue<T>;
template<class T> using MinHeap = priority_queue<T, vector<T>, greater<T>>;
template<class T, class F=less<T>> void sort_uniq( vector<T> &v, F f=F() ) {
    sort(begin(v),end(v),f);
    v.resize(unique(begin(v),end(v))-begin(v));
}
// }}}

const int N=1000010;
VI p[N];
int cnt[N],mp[N];
void main() {    
    int n;
    R(n);
    REP(i,n) {
        int a;
        R(a);
        cnt[a]++;
    }
    int ok=1,ok2=1;
    for ( int i=2; i<N; i++ ) {
        if ( SZ(p[i]) ) continue;
        for ( int j=i; j<N; j+=i ) {
            p[j].PB(i);
            mp[i]+=cnt[j];
        }
        if ( mp[i]>1 ) ok=0;
        if ( mp[i]==n ) ok2=0;
    }
    if ( ok ) {
        W("pairwise coprime");
    } else if ( ok2 ) {
        W("setwise coprime");
    } else {
        W("not coprime"); 
    }
}

}} // {{{ main
int main() { unolight::main(); return 0; }
// }}}


Measured memory_bytes: 67068
#include <cstdio>
using namespace std;

const int S = 110;
const int N = 1e4 + 50;
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
int n, H, W, a[N], pai[S][S];

template <class T> inline void in(T &x) {
	x = 0; int f = 1; char ch = getchar();
	for (; ch<'0' || ch>'9';) {if (ch=='-') f=-1; ch = getchar();}
	for (; ch>='0' && ch<='9';) x = x*10 + ch-'0', ch = getchar();
	x *= f;
}

inline void work() {
	int x, y, tx, ty, now; in(H), in(W), in(n);
	for (int i = 1; i <= n; ++i) in(a[i]);
	for (now = x = y = 1; now <= n; ++now) {
		for (int i = 1; i <= a[now]; ++i) {
			pai[x][y] = now;
			for (int k = 0; k < 4; ++k) {
				if ((tx = x + dx[k]) > H || tx <= 0) continue;
				if ((ty = y + dy[k]) > W || ty <= 0) continue;
				if (!pai[tx][ty]) {x = tx, y = ty; break;}
			}
		}
	}
	for (int i = 1; i <= H; ++i) {
		for (int j = 1; j <= W; ++j) printf("%d ", pai[i][j]);
		putchar('\n');
	}
}

int main() {work(); return 0;}

Measured memory_bytes: 256
#include <cstdio>
#include <vector>

const int MN = 2005;

int N, K, eu[MN], ev[MN];
std::vector<int> G[MN];

int dep[MN];
void DFS(int u, int p) {
	for (int v : G[u]) if (v != p) dep[v] = dep[u] + 1, DFS(v, u);
}

int main() {
	scanf("%d%d", &N, &K);
	for (int i = 1; i < N; ++i) {
		scanf("%d%d", &eu[i], &ev[i]);
		G[eu[i]].push_back(ev[i]);
		G[ev[i]].push_back(eu[i]);
	}
	int Ans = N;
	if (K & 1) {
		for (int i = 1; i < N; ++i) {
			int u = eu[i], v = ev[i];
			dep[u] = dep[v] = 0;
			DFS(u, v), DFS(v, u);
			int cnt = 0;
			for (int j = 1; j <= N; ++j) if (dep[j] > K / 2) ++cnt;
			Ans = Ans > cnt ? cnt : Ans;
		}
	} else {
		for (int i = 1; i <= N; ++i) {
			dep[i] = 0, DFS(i, 0);
			int cnt = 0;
			for (int j = 1; j <= N; ++j) if (dep[j] > K / 2) ++cnt;
			Ans = Ans > cnt ? cnt : Ans;
		}
	}
	printf("%d\n", Ans);
	return 0;
}

Measured memory_bytes: 512
x=int(input())
next=[]
now=[1,2,3,4,5,6,7,8,9]

for _ in range(11):
  if x<=len(now):
    print(now[x-1])
    exit()
  else:
    x-=len(now)
    next=now
    now=[]
    for i in next:
      i=str(i)
      if i[-1]=='0':
        j=i+'0'
        k=i+'1'
        now+=[j]
        now+=[k]
      elif i[-1]=='9':
        j=i+'8'
        k=i+'9'
        now+=[j]
        now+=[k]
      else:
        j=i+str(int(i[-1])-1)
        k=i+str(int(i[-1]))
        l=i+str(int(i[-1])+1)
        now+=[j]
        now+=[k]
        now+=[l]

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

int main() {
  int a,b;
  cin>>a>>b;
  vector<string> A(a);
  string n="#";
  for(int i=0;i<b+1;i++){
    n+="#";
    if(i<b)
      continue;
    cout<<n<<endl;
  }
  for(int i=0;i<a;i++){
    cin>>A[i];
    cout<<"#"<<A[i]<<"#"<<endl;
  }
    cout<<n<<endl;
  
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i = a; i < b; i++)
#define REP(i,b) FOR(i,0,b)
#define RFOR(i,a,b) for (int i = a-1; i >= b; i--)
#define RREP(i,a) RFOR(i,a,0)
#define REPALL(i,v) for (int i = 0; i < v.size(); i++)
#define RREPALL(i,v) for (int i = v.size()-1; i >= 0; i--)
#define SORT(v) sort(v.begin(), v.end())
#define MIN_ELEMENT(v) min_element(v.begin(), v.end())
#define MAX_ELEMENT(v) max_element(v.begin(), v.end())
#define COUNT(v,n) count(v.begin(), v.end(), n);
void YES(bool flag) {cout<<(flag ? "YES" : "NO")<<endl;}
void Yes(bool flag) {cout<<(flag ? "Yes" : "No")<<endl;}
void yes(bool flag) {cout<<(flag ? "yes" : "no")<<endl;}
typedef long long ll;
typedef unsigned long long ull;
const int INF = 1e7;
const ll MOD = 1e9 + 7;



int main()
{
    ll r,d,x;
    cin>>r>>d>>x;
    REP(i,10) {
        x = r * x - d;
        cout<<x<<endl;
    }

    return 0;
}


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

int main(){
	int n,m,x; cin>>n>>m>>x;
	vector<int> B[n];
	int C[n];
	for(int i=0; i<n; i++){
		cin>>C[i];
		for(int j=0; j<m; j++){
			int x; cin>>x;
			B[i].push_back(x);
		}
	}
	ll ans = 1e18;
	ll arr[m];
	for(int mask=0; mask<(1<<n); mask++){
		memset(arr, 0, sizeof(arr));
		ll price=0;
		for(int i=0; i<n; i++){
			if(mask & 1<<i){
				price+=C[i];
				for(int j=0; j<m; j++){
					arr[j]+=B[i][j];
				}
			}
		}
		bool ok = true;
		for(int k=0; k<m; k++){
			if(arr[k]<x)ok=false;
		}
		if(ok)ans=min(ans, price);
	}
	cout<<(ans==1e18?-1:ans)<<endl;
}


Measured memory_bytes: 3576
#define _CRT_SECURE_NO_WARNINGS 1
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <queue>
#include <sstream>
#include <climits>
#include <cmath>
#include <functional>
#include <map>
#include <stack>
using namespace std;
#define M_PI 3.141592
#define FOR(i,n) for(int i=0;i<(int)n;i++)
#define FORI(i,k,n) for(int i=k;i<(int)n;i++)
#define toRad 2.0*M_PI/360.0
#define inin(x) int x;cin>>x;
#define all(x) x.begin(),x.end()
#define debug(x) cout<<#x<<" "<<x<<endl;
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define EPS 1e-12
#define pri_max 60000
typedef pair<int, int> pii;
typedef pair<double, double> pdd;
int dx[4] = { 0,1,0,-1 };
int dy[4] = { 1,0,-1,0 };

/*
bool memo[pri_max] = {};
vector<int> pri;
void calc()
{
	for (int i = 2; i < pri_max; i++)
	{
		if (memo[i] == false)
		{
			pri.push_back(i);
			for (int l = i; l < pri_max; l += i)
			{
				memo[l] = true;
			}
		}
	}
}*/

int main()
{
	vector<int> ans;
	int id;
	double hei, wei;
	while (scanf("%d,%lf,%lf", &id, &wei, &hei) != EOF)
	{
		if (wei / (hei*hei) >= 25.0)ans.push_back(id);
	}
	for (int i = 0; i < ans.size(); i++)
	{
		cout << ans[i] << endl;
	}

}

Measured memory_bytes: 1252
#include <bits/stdc++.h>
using namespace std;
string s[100];
int p[100];
pair<string, pair<int, int>> data[100];
int n;

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

    cin>>n;
    for(int i=0; i<n; i++)
    {
      cin>>s[i]>>p[i];
      data[i] = make_pair(s[i], make_pair(-p[i], i+1));
    }
    sort(data, data+n);

    for(int i=0; i<n; i++)
    {
      cout<<data[i].second.second<<endl;
    }

	return 0;
}


Measured memory_bytes: 256
import java.util.*;

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

	public Main(){
		new AOJ2252().doIt();
	}
	
	class AOJ2252{
		void doIt(){
			String a = "qwertasdfgzxcvbyuiophjklnm";
			char[] data = a.toCharArray();
			boolean[] isRL = new boolean[a.length()];
			HashMap<Character, Boolean> map = new HashMap<Character, Boolean>();
			for(int i=0;i<15;i++)isRL[i] = true;
			for(int i=0;i<a.length();i++)map.put(data[i], isRL[i]);
			while(in.hasNext()){
				char input[] = in.next().toCharArray();
				if(input[0]=='#')break;
				int cnt = 0;
				boolean before = map.get(input[0]);
				for(int i=1;i<input.length;i++){
//					System.out.println(map.get(input[i]));
					if(map.get(input[i])!=before)cnt++;
					before = map.get(input[i]);
				}
				System.out.println(cnt);
			}
		}
	}
}

Measured memory_bytes: 20432
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000
#define int long long

signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin >> N;
    int A[100010];
    rep(i, N) cin >> A[i];
    sort(A, A + N, greater<int>());
    vector<int> v;
    rep(i, N - 1) {
        if (A[i] == A[i + 1]) {
            v.push_back(A[i]);
            i++;
        }
    }
    if (v.size() < 2) {
        cout << "0" << endl;
    } else {
        cout << v[0] * v[1] << endl;
    }
    
    return 0;
}


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

#define int int_fast64_t

string s;

bool can(int a, int b) {
  bool last_was_dot=false;
  for (int i = a; i < b; ++i) {
    if (s[i] == '.')
      last_was_dot=true;
    else if (s[i] == '#') {
      if (!last_was_dot)
        return false;
      last_was_dot = false;
    } else {
      assert(false);
    }
  }
  return true;
}

bool has_hideout(int a, int b) {
  int dotcnt=0;
  for (int i = a; i < b; ++i) {
    if (s[i] == '.') {
      if (++dotcnt == 3)
        return true;
    } else if (s[i] == '#') {
      dotcnt = 0;
    } else {
      assert(false);
    }
  }
  return false;
}


bool solve() {
  int n, a, b, c, d; cin >> n >> a >> b >> c >> d;
  --a; --b;
  cin >> s;
  if (c < d) {
    return can(a, c) && can(b, d);
  }
  if (!has_hideout(b-1, d+1))
    return false;
  return can(a, c) && can(b, d);
}

signed main() {
  ios_base::sync_with_stdio(false), cin.tie(nullptr);
  cout << (solve() ? "Yes\n" : "No\n");
}



Measured memory_bytes: 592
#include<iostream>
using namespace std;
//Strongly Connected Components
#include<vector>
struct SCC{
	int n;
	vector<int>comp,order;
	vector<bool>used;
	vector<vector<int> >G,RG;
	SCC(int _n=0):n(_n),comp(_n,-1),used(_n,false),G(_n),RG(_n){}
	void add_edge(int from,int to)
	{
		G[from].push_back(to);
		RG[to].push_back(from);
	}
	void copy(const vector<vector<int> >&H)
	{
		for(int i=0;i<H.size();i++)
		{
			for(int j=0;j<H[i].size();j++)
			{
				G[i].push_back(H[i][j]);
				RG[H[i][j]].push_back(i);
			}
		}
	}
	int operator[](int u)const{return comp[u];}
	void dfs(int u)
	{
		used[u]=true;
		for(int i=0;i<G[u].size();i++)if(!used[G[u][i]])dfs(G[u][i]);
		order.push_back(u);
	}
	void rdfs(int u,int cnt)
	{
		comp[u]=cnt;
		for(int i=0;i<RG[u].size();i++)if(comp[RG[u][i]]==-1)rdfs(RG[u][i],cnt);
	}
	int build()
	{
		for(int i=0;i<n;i++)if(!used[i])dfs(i);
		int cnt=0;
		for(int i=n-1;i>=0;i--)if(comp[order[i]]==-1)rdfs(order[i],cnt++);
		return cnt;
	}
	int build(vector<vector<int> >&H)
	{
		int ret=build();
		H.assign(ret,vector<int>());
		for(int i=0;i<n;i++)
		{
			for(int j=0;j<G[i].size();j++)
			{
				if(comp[i]!=comp[G[i][j]])
					H[comp[i]].push_back(comp[G[i][j]]);
			}
		}
		return ret;
	}
};
int N,M;
main()
{
	cin>>N>>M;
	SCC P(N);
	for(int i=0;i<M;i++)
	{
		int u,v;cin>>u>>v;
		P.add_edge(u,v);
	}
	int K=P.build();
	cout<<K<<endl;
	vector<vector<int> >ans(K);
	for(int i=0;i<N;i++)ans[P[i]].push_back(i);
	for(int i=0;i<K;i++)
	{
		cout<<ans[i].size();
		for(int v:ans[i])cout<<" "<<v;
		cout<<endl;
	}
}


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

int main(){
    int N, M; cin >> N >> M;
    int a[N], b[N]; rep(i,N) cin >> a[i] >> b[i];
    int c[M], d[M]; rep(i,M) cin >> c[i] >> d[i];

    rep(i,N){
        int dist = abs(a[i]-c[0]) + abs(b[i]-d[0]);
        int index = 1;
        rep(j,M){
            if(dist > abs(a[i]-c[j]) + abs(b[i]-d[j])){
                index = j+1;
                dist = abs(a[i]-c[j]) + abs(b[i]-d[j]);
            }
        }
        cout << index << endl;
    }

    
}

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

using namespace std;

int main()
{ int n,l;
 scanf("%d%d",&n,&l);
  string s[n];
  int i;
 for(i=0;i<n;++i)
     cin>>s[i];
 
 sort(s,s+n);
 for(i=0;i<n;++i)
      cout<<s[i];
}
   
    

Measured memory_bytes: 256
#include<stdio.h>
#include<stdbool.h>
const int mod = 1e9 + 7;
int N, M, dp[1<<17] = {1};
bool A[1<<17] = {};
int main(){
	scanf("%d%d", &N, &M);
	while(M--){
		int a;
		scanf("%d", &a);
		A[a]++;
	}
	for(int i=1; i<=N; i++){
		if(i>1) dp[i] += dp[i-2];
		dp[i] += dp[i-1];
		dp[i] %= mod;
		if(A[i]) dp[i] = 0;
	}
	printf("%d\n", dp[N]);
	return 0;
}


Measured memory_bytes: 2220
import std.algorithm;
import std.array;
import std.conv;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

int readint() {
    return readln.chomp.to!int;
}

int[] readints() {
    return readln.split.map!(to!int).array;
}

void main() {
    auto xs = readints;
    long q = xs[0];
    long h = xs[1];
    long s = xs[2];
    long d = xs[3];
    long one = min(q * 4, h * 2, s);
    long two = min(one * 2, d);

    auto n = readint;
    long ans = (n / 2) * two + (n % 2) * one;
    writeln(ans);
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>

int main(void){
    int K,len,i;
    char S[100];

    scanf("%d",&K);
    scanf("%s",S);

    len = strlen(S);

    if(len<=K){
        printf("%s",S);
    }else if(len>K){
        for(i=0;i<K;i++){
            printf("%c",S[i]);
        }
        printf("...");
    }

    return 0;
}

Measured memory_bytes: 1732
#include<stdio.h>
int main(){
char a[110];
int i,b,c=0,ans=0;
while(scanf("%c",&a[0])!=EOF){
for(i=1;;i++){
scanf("%c",&a[i]);
if(a[i]=='\0' || a[i]=='\n'){
break;
}
}
b=i-1;
for(i=0;i<b;i++){
if(a[i]!=a[b]){
c++;
break;
}
b--;
}
if(c==0){
ans++;
}
c=0;
for(i=0;i<105;i++){
a[i]='\0';
}
}
printf("%d\n",ans);
return 0;
}


Measured memory_bytes: 1996
#include <bits/stdc++.h>
#define maxn 500005
#define ll long long
#define mod 1000000007
using namespace std;

typedef pair<ll, ll> P;

int n, k;

int main()
{
    cin >> n >> k;
    if (k > (n - 1) * (n - 2) / 2)
        printf("-1");
    else
    {
        int add = (n - 1) * (n - 2) / 2 - k;
        printf("%d\n", add + n - 1);
        for (int i = 2; i <= n; i++)
            printf("1 %d\n", i);
        for (int i = 2; i <= n; i++)
        {
            if (add == 0)
                break;
            for (int j = i + 1; j <= n; j++)
            {
                if (add == 0)
                    break;
                printf("%d %d\n", i, j);
                add--;
            }
        }
    }

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define F(i,a,b) for(int i=(a);i<=(b);++i)
#define F2(i,a,b) for(int i=(a);i<(b);++i)
#define dF(i,a,b) for(int i=(a);i>=(b);--i)
#define dF2(i,a,b) for(int i=(a);i>(b);--i)
#define dF3(i,a,b) for(int i=(a)-1;i>=(b);--i)
using namespace std;typedef long long ll;typedef double ld;int INF=0x3f3f3f3f;int INF2=0x7fffffff;ll LNF=0x3f3f3f3f3f3f3f3f;ll LNF2=0x7fffffffffffffff;

int n,q;
int a[1001], A[1001];
int b[1001], c[1001];
int B[1001], C[1001];
ll sum1,sum2;
int K[1001],cnt;
int Ans[1001],tot;

int main(){
	scanf("%d",&n);
	F(i,1,n) scanf("%d",a+i), (i&1?b:c)[(i+1)/2]=a[i];
	F(i,1,(n+1)/2)
		if(b[i]>0) B[i]=1, sum1+=b[i];
	F(i,1,n/2)
		if(c[i]>0) C[i]=1, sum2+=c[i];
	if(sum1==0&&sum2==0){
		int maxi=1;
		F(i,2,n) if(a[maxi]<a[i]) maxi=i;
		printf("%d\n%d\n",a[maxi],n-1);
		F(i,1,maxi-1) puts("1");
		dF(i,n-maxi+1,2) printf("%d\n",i);
		return 0;
	}
	if(sum1>sum2){
		F(i,1,n) if(i&1) A[i]=B[(i+1)/2];
	}
	else{
		F(i,1,n) if(!(i&1)) A[i]=C[i/2];
	}
	printf("%lld\n",max(sum1,sum2));
	int l=n+1,r=0;
	F(i,1,n) if(A[i]) l=min(l,i), r=max(r,i);
	F(i,1,l-1) Ans[++tot]=1;
	dF(i,n-l+1,r-l+2) Ans[++tot]=i;
	F(i,l,r) if(A[i]) ++cnt; else ++K[cnt];
	F(i,1,cnt-1){
		F(j,1,K[i]/2) Ans[++tot]=3;
		Ans[++tot]=2;
	}
	printf("%d\n",tot);
	F(i,1,tot) printf("%d\n",Ans[i]);
	return 0;
}

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

int n, m;
char arr[21][21];
int dis[21][21], INF = 1000000000;
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
int bst, idx1, idx2;

bool isValid(int i, int j) {
    return i >= 0 && i < n && j >= 0 && j < m && arr[i][j]=='.';
}

void reset() {
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < m; ++j) {
            dis[i][j] = INF;
        }
    }
}

void bfs(int ii, int jj) {
    queue<pair<int, int>> q;
    q.emplace(ii, jj);
    dis[ii][jj] = 0;
    while (!q.empty()) {
        auto p = q.front();
        q.pop();
        int i = p.first, j = p.second;
        for (int k = 0; k < 4; ++k) {
            int ni = i + dx[k];
            int nj = j + dy[k];
            if (isValid(ni, nj) && dis[ni][nj] > dis[i][j]+1) {
                dis[ni][nj] = dis[i][j]+1;
                q.emplace(ni, nj);
            }
        }
    }

}

int get_best() {
    int mx = 0;
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < m; ++j) {
            if (dis[i][j] != INF) {
                mx = max(mx, dis[i][j]);
            }
        }
    }
    return mx;
}
int check(int i, int j) {
    reset();
    bfs(i, j);
    int mx = get_best();
    vector<vector<int>> v(n, vector<int>(m));
    for (int i = 0; i <n; ++i) {
        for (int j = 0; j < m; ++j) {
            v[i][j] = dis[i][j];
        }
    }
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j <m; ++j) {
            if (v[i][j] == mx) {
                reset();
                bfs(i, j);
                bst = max(bst, get_best());
            }
        }
    }
    return bst;
}
int main() {
    scanf("%d%d", &n, &m);
    for (int i = 0; i < n; ++i) {
        scanf("%s", arr[i]);
    }
    int mx = 0;
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < m; ++j) {
            if (arr[i][j] == '.') {
                mx = max(mx, check(i, j));
            }
        }
    }
    printf("%d\n", mx);
    return 0;
}



Measured memory_bytes: 256
#include <algorithm>
#include <functional>
#include <cmath>
#include <vector>
#include <set>
#include <cstdlib>
#include <iostream>
#include <string>
#include <cstring>
using namespace std;


int main()
{
	int k, x;
	cin >> k >> x;
	for (int i = x - (k - 1); i <= x + (k - 1); i++)
		cout << i << ' ';

}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A[] = new int[100]; 
		int N = sc.nextInt(); 
		int D = sc.nextInt(); 
		int X = sc.nextInt(); 
		int cnt = 0;
		for(int i = 0; i < N; i++) {
			A[i] = sc.nextInt();
			for(int j = 1; j <= D; j = j+A[i]) {
				cnt++;
			}
		}
		System.out.println(X+cnt);
	}
}

Measured memory_bytes: 21972
#include <bits/stdc++.h>
typedef long double ld;
const int inf = 1e9 + 1;
using namespace std;
int main() {
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(nullptr);
    // freopen("input.txt", "r", stdin);
    cout << setprecision(20);
    int n;
    int m;
    cin >> n >> m;
    vector<vector<int>> edj(n);
    for (int i = 0; i < m; i++) {
        int x, y;
        cin >> x >> y;  
        edj[x - 1].push_back(y - 1);
    }
    vector<ld> exp(n, 0);
    vector<ld> p(n, 0);
    p[0] = 1;
    for (int i = 0; i < n; i++) {
        for (size_t j = 0; j < edj[i].size(); j++) {
            p[edj[i][j]] += p[i] / edj[i].size();
        }
    }
    for (int i = n - 2; i >= 0; --i) {
        for (size_t j = 0; j < edj[i].size(); j++) {
            exp[i] += exp[edj[i][j]];
        }
        exp[i] /= edj[i].size();
        exp[i]++;
    }
    ld ans = exp[0];
    ld old_ans = ans;
//    cout << ans << endl;
    for (int i = 0; i < n - 1; i++) {
        for (size_t j = 0; j < edj[i].size(); j++) {
            if (edj[i].size() > 1) {
                ld locexp = exp[i]*edj[i].size() - exp[edj[i][j]]-1;
                locexp /= edj[i].size() - 1;
                ld locans = old_ans + p[i] * (locexp - exp[i]);
//                cout << i << " " << edj[i][j] << " " << p[i] << " " << old_ans << " " << locans << " " << exp[i] << " "
//                     << locexp << " " << exp[edj[i][j]] << endl;
                if (locans < ans) {
//                    cout << i << " " << edj[i][j] << " " << p[i] << endl;
                    ans = locans;
                }
            }
        }
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 1408
#include<cstdio>
#include<iostream>
using namespace std;
int adj[101][101], d[101], visited[101];
int n, INFTY = (1<<30);
void dijkstra()
{
  for(int i=0; i<n; i++)
  {
    visited[i] = 0; d[i] = INFTY;
  }
  d[0] = 0;

  while(1)
  {
    int minc = INFTY, u=-1;
    for(int i=0; i<n; i++)
    {
      if(d[i] < minc && visited[i] == 0)
      {
        minc = d[i];
        u = i;
      }
    }
    if(minc == INFTY) break;
    visited[u] = 1;
    for(int i=0; i<n; i++)
    {
      if(adj[u][i] != -1 && visited[i]==0)
      {
        if(d[i] > d[u] + adj[u][i])
          d[i] = d[u] + adj[u][i];
      }
    }
  }
  for(int i=0; i<n; i++)
    printf("%d %d\n", i, d[i]);
}
int main()
{
  scanf("%d", &n);
  int u, k, c, v;
  for(int i=0; i<n; i++)
    for(int j=0; j<n; j++)
      adj[i][j] = -1;
  for(int i=0; i<n; i++)
  {
    scanf("%d%d", &u, &k);
    for(int j=0; j<k; j++)
    {
      scanf("%d%d", &v, &c);
      adj[u][v] = c;
    }
  }
  dijkstra();

  return 0;
}



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

using namespace std;

int main () {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    long long x, k, d; cin >> x >> k >> d;
    x = abs(x);
    long long p = min(k, x / d);
    x -= p * d; k -= p;
    if (k % 2 == 0) {
        cout << x << endl;
    }
    else {
        cout << d - x << endl;
    }
    return 0;
}



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

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

  int H, A;
  cin >> H >> A;

  int ans = 0;
  while (H > 0) {
    H -= A;
    ans++;
  }

  cout << ans << endl;

  return 0;
}


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

using namespace std;

int main() {
  int n, m;
  cin >> n >> m;
  if ( n >= m ) {
    cout << 0 << endl;
    return 0;
  }
  vector<int> l;
  for (int i = 0; i < m; i++) {
    int a;
    cin >> a;
    l.push_back(a);
  }
  sort(l.begin(), l.end());
  vector<int> d_l;
  for (int i = 0; i < m - 1; i++) {
    d_l.push_back(l[i + 1] - l[i]);
  }
  sort(d_l.begin(), d_l.end());

  int sum = 0;
  for (int i = 0; i < n - 1; i++) {
    sum += d_l[m - 2 - i];
  }
  int l_last = l[m - 1] - l[0];
  cout << l_last - sum << endl;
  return 0;
}

Measured memory_bytes: 1400
#include<iostream>
#include<algorithm>
#include<vector>
#include<functional>
#include<numeric>
#include<climits>
 
using namespace std;
 
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	long long n, m, x;
	cin >> n >> m;
	long long xx = 0;
	long long yy = 0;
	long long mod = 1000 * 1000 * 1000 + 7;
	for (long long i = 0; i < n; i++) {
		cin >> x;
		xx += (2 * i + 1 - n)*x;
		xx %= mod;
	}
	for (long long i = 0; i < m; i++) {
		cin >> x;
		yy += (2 * i + 1 - m)*x;
		yy %= mod;
	}

	cout << (xx*yy)%mod << endl;
	return 0;
}

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

using namespace __gnu_pbds;
using namespace std;

#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
// order_of_key (val): returns the no. of values less than val
// find_by_order (k): returns the kth largest element.(0-based)

#define ll long long int
#define ld long double
#define ff first
#define ss second
#define pb push_back
#define pi pair<ll,ll>
#define all(X) X.begin(),X.end()

// for pair comparison function(ascending order) use return (i1.ff < i2.ff);

/* string operations :
   str.substr (x,y) : returns a substring str[x],str[x+1],...str[x+y-1]
   str.substr (x) : returns a substring str[x],... end of string
   str.find(qtr) : returns the first occurenece of qtr in str.
   builtin functions :
   __builtin_popcount(n) : no. of set bits in n.
   __builtin_parity(n) : parity of no. of set bits
   __builtin_clz(n) : no. of leading zeros before 1
   __builtin_ctz(n) : no of zeros from last to first occurrence of 1
*/

const int M = (1<<20)+5;
const int md = 1e9+7;

ll pwr(ll a,ll n,ll m)
{
	ll p=1;
	while(n>0)
	{
		if(n%2==1)
			p=(p*a)%m;
		a=(a*a)%m;
		n=n/2;
	}
	return p;
}

ll binlen(ll a)
{
	ll v = 0;
	for(ll i=0;i<61;++i)
	{
		v += (1ll<<i);
		if(a<=v) return i;
	}
}

string str[M];
ll ar[10];
string qtr;

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

	ll a,b,c,i,j,d,n;

	cin >> n >> ar[0] >> ar[1] >> ar[2];

	for(i=1;i<=n;++i)
		cin >> str[i];

	for(i=1;i<=n;++i)
	{
		a = str[i][0]-'A';
		b = str[i][1]-'A';
		if(i == n || str[i+1] == str[i])
		{
			if(ar[a]>ar[b])
			{
				ar[a]--;
				ar[b]++;
				qtr.pb((char)(b+'A'));
			}
			else
			{
				ar[a]++;
				ar[b]--;
				qtr.pb((char)(a+'A'));
			}
		}
		else
		{
			c = str[i+1][0]-'A';
			d = str[i+1][1]-'A';
			if(a == c)
			{
				if(ar[b] != 0)
				{
					ar[a]++;
					ar[b]--;
					qtr.pb((char)(a+'A'));
				}
				else
				{
					ar[a]--;
					ar[b]++;
					qtr.pb((char)(b+'A'));
				}
			}
			if(b == c)
			{
				if(ar[a] != 0)
				{
					ar[a]--;
					ar[b]++;
					qtr.pb((char)(b+'A'));
				}
				else
				{
					ar[a]++;
					ar[b]--;
					qtr.pb((char)(a+'A'));
				}
			}
			if(b == d)
			{
				if(ar[a] != 0)
				{
					ar[a]--;
					ar[b]++;
					qtr.pb((char)(b+'A'));
				}
				else
				{
					ar[a]++;
					ar[b]--;
					qtr.pb((char)(a+'A'));
				}
			}
			if(a == d)
			{
				if(ar[b] != 0)
				{
					ar[a]++;
					ar[b]--;
					qtr.pb((char)(a+'A'));
				}
				else
				{
					ar[a]--;
					ar[b]++;
					qtr.pb((char)(b+'A'));
				}
			}
		}
		if(min({ar[0],ar[1],ar[2]}) < 0)
		{
			cout << "No" << endl;
			return 0;
		}
	}

	cout << "Yes" << endl;
	for(auto v:qtr)
		cout << v << "\n";
}

	

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

const int mnx = 1e6 + 9;
const int mod = 1e9 + 7;

ll n;
ll a, b;

int main() {

cin >> n;
cin >> a >> b;

ll k = b - a;

if(k % 2 == 0){ cout << "Alice\n"; }
else cout << "Borys\n";

return 0;

}


Measured memory_bytes: 256
package main

import (
	"fmt"
	"math"
)

func distance(x1, y1, x2, y2 int) int {
	return int(math.Abs(float64(x1-x2)) + math.Abs(float64(y1-y2)))
}

func main() {
	var n int
	fmt.Scan(&n)

	t, x, y := make([]int, n+1), make([]int, n+1), make([]int, n+1)
	for i := 1; i <= n; i++ {
		fmt.Scan(&t[i], &x[i], &y[i])
	}

	for i := 0; i < n; i++ {
		dist := distance(x[i], y[i], x[i+1], y[i+1])
		time := t[i+1] - t[i]
		if dist > time ||
			(dist%2 == 0 && time%2 == 1) ||
			(dist%2 == 1 && time%2 == 0) {
			fmt.Println("No")
			return
		}
	}
	fmt.Println("Yes")
}


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

#define ll long long
using namespace std;
#define MAXN 3001
#define MOD 998244353
void solve()
{
    ll A,B,C,D;
	//cerr<<S;
	cin>>A>>B>>C>>D;
	ll Z[MAXN][MAXN];
	Z[A][B]=1;
	for(int i=A+1; i<=C; ++i)
		Z[i][B] = (Z[i-1][B]*B)%MOD;
	for(int i=B+1; i<=D; ++i)
		Z[A][i] = (Z[A][i-1]*A)%MOD;
	for(int i=A+1; i<=C; ++i)
		for(int j=B+1; j<=D; ++j)
		{
			Z[i][j] = (Z[i-1][j]*j + Z[i][j-1]*i + MOD - (Z[i-1][j-1]*(i-1)*(j-1))%MOD)%MOD;
			//assert((Z[i-1][j] + Z[i][j-1]*j)%MOD == Z[i][j]);

		}
	/*
	for(int i=A; i<=C; ++i,cerr<<endl)
		for(int j=B; j<=D; ++j)
			cerr<<Z[i][j]<<" ";
	cerr<<endl;*/
	cout<<Z[C][D]<<endl;
}

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

		
	return 0;
}


Measured memory_bytes: 73888
/*
ID: anonymo14
TASK: wormhole
LANG: C++                 
*/
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pair<int,int>> vpii;

#define F first
#define S second
#define PU push
#define PUF push_front
#define PUB push_back
#define PO pop
#define POF pop_front
#define POB pop_back

#define REP(i,a,b) for(int i=a; i<=b; i++)

#define MOD 1000000007

void solve(int test_case) {//223
	int n;
	cin>>n;
	cout<<n*2/__gcd(2,n);
}

int main() {
	
	////// FILE BASED IO////
	//freopen("wormhole.in", "r", stdin);
	//freopen("wormhole.out", "w", stdout);
	///////////////
	
	ios::sync_with_stdio(0);
	cin.tie(0);
	int t=1;
	//cin>>t;
	REP(i,1,t) {
		solve(i);
	}
	return 0;
}	


Measured memory_bytes: 3584
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;
import java.util.ArrayList;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author silviase
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        DDivGame solver = new DDivGame();
        solver.solve(1, in, out);
        out.close();
    }

    static class DDivGame {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            long n = in.nextLong();
            ArrayList<Integer> pr = Prime.eratosthenesSieve(2000000);
            int res = 0;
            for (long prime : pr) {
                int cnt = 0;
                while (n % prime == 0) {
                    //if(cnt == 0) out.println(prime);
                    n /= prime;
                    cnt++;
                }

                //if (cnt > 0) out.println(cnt);
                int plus = cnt < 1 ? 0 :
                        cnt < 3 ? 1 :
                                cnt < 6 ? 2 :
                                        cnt < 10 ? 3 :
                                                cnt < 15 ? 4 :
                                                        cnt < 21 ? 5 :
                                                                cnt < 28 ? 6 :
                                                                        cnt < 36 ? 7 :
                                                                                cnt < 45 ? 8 :
                                                                                        cnt < 55 ? 9 : 10;
                //if(plus > 0) out.println("p:" + plus);
                res += plus;
            }
            if (n != 1) res++;
            out.println(res);
        }

    }

    static class Prime {
        public static ArrayList<Integer> eratosthenesSieve(int n) {
            // n 以下の素数を列挙する, O(N*log(log N))
            ArrayList<Integer> prime = new ArrayList<>();
            ArrayList<Integer> nums = new ArrayList<>();
            for (int i = 2; i <= n; i++) {
                nums.add(i);
            }
            while (nums.get(0) <= Math.sqrt(n)) {
                int nxtPrime = nums.get(0);
                prime.add(nxtPrime);
                nums.removeIf(x -> (x % nxtPrime == 0));
            }
            prime.addAll(nums);
            return prime;
        }

    }
}



Measured memory_bytes: 111084
import sys

n = int(input())
rs = [ [i+1, input().split()] for i in range(n) ]
#print(rs)

rs = sorted(rs, key=lambda a:int(a[1][1]), reverse=True)
rs = sorted(rs, key=lambda a:a[1][0])

for r in rs:
    print(r[0])

Measured memory_bytes: 3060
#include <iostream>
#include <stdio.h>
#include <math.h> 
#include <algorithm>
#include <numeric>
#include <functional>
#include <vector>
#include <string>
#include <numeric>
#include <bitset>
#include <queue>
#include <map>

using namespace std;


int main() {

	//input
	int n,t;
	cin >> n >> t;

	vector<int> cost;
	vector<int> time;
	vector<int> time2;
	vector<int> ans_c;
	vector<int> ans_t;

	for (int i = 0; i < n; ++i) {
		int tmp_c, tmp_t;
		cin >> tmp_c >> tmp_t;
		cost.push_back(tmp_c);
		time.push_back(tmp_t);
		time2.push_back(tmp_t);
	}

	sort(time2.begin(), time2.end());
	if (time2[0] > t) {
		cout << "TLE" << endl;
		return 0;
	}

	for (int i = 0; i < time.size(); ++i) {
		if (time[i] <= t) {
			ans_t.push_back(time[i]);
			ans_c.push_back(cost[i]);
		}
	}

	sort(ans_c.begin(), ans_c.end());
	cout << ans_c[0] << endl;
	
	return 0;
}

Measured memory_bytes: 256
n = int(input())
a_ls = list(map(int, input().split()))
a_ls = [0] + a_ls
box_ls = [0] * (n+1)
root = n ** 0.5
for i in range(n,0,-1):
    if 2*i > n:
        box_ls[i] = a_ls[i]
    else:
        Sum = 0
        num = i + i
        # ここの条件式不安あり
        while num <= n:
            Sum += box_ls[num]
            num += i
        rest = Sum % 2
        if (rest == 1 and a_ls[i] == 1) or (rest == 0 and a_ls[i] == 0):
            box_ls[i] = 0
        else:
            box_ls[i] = 1
ans_ls = []
for box_name, ball_num in enumerate(box_ls[1:],1):
    if ball_num == 1:
        ans_ls.append(str(box_name))
M = len(ans_ls)
print(M)
if M > 0:
    print(' '.join(ans_ls))



Measured memory_bytes: 17840
#include <iostream>
#include <atcoder/modint>
#include <atcoder/lazysegtree>
using namespace std;
using namespace atcoder;

using mint = modint998244353;
struct S {
	mint a;
	int size;
};
struct F {
	mint a, b;
};
S op(S l, S r) { return S{ l.a + r.a, l.size + r.size }; };
S e() { return S{ 0,0 }; };
S mapping(F l, S r) { return S{ r.a * l.a + r.size * l.b, r.size }; };
F composition(F l, F r) { return F{ r.a * l.a, r.b * l.a + l.b }; };
F id() { return F{ 1,0 }; };

int main() {
	int N, Q;
	cin >> N >> Q;
	lazy_segtree<S, op, e, F, mapping, composition, id> seg(N);
	for (int i = 0; i < N; i++) {
		int a;
		cin >> a;
		seg.set(i, S{ a,1 });
	}
	for (int q = 0; q < Q; q++) {
		int t;
		cin >> t;
		if (t == 0) {
			int l, r, b, c;
			cin >> l >> r >> b >> c;
			seg.apply(l, r, F{ b,c });
		}
		else {
			int l, r;
			cin >> l >> r;
			cout << seg.prod(l, r).a.val() << endl;
		}
	}
}


Measured memory_bytes: 19268
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define repr(i, n) REPR(i, n, 0)
#define REPR(i, s, e) for(int i=(int)(s-1); i>=(int)(e); i--)
#define pb push_back
#define all(r) r.begin(),r.end()
#define rall(r) r.rbegin(),r.rend()
#define fi first
#define se second

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const ll INF = 1e18;
const ll MOD = 1e9 + 7;
const double EPS = 1e-8;

template<typename T> T chmax(T& a, const T& b){return a = (a > b ? a : b);}
template<typename T> T chmin(T& a, const T& b){return a = (a < b ? a : b);}

bool d[8][8];
bool y[8];
bool x[8];
map<int, bool> xy;
map<int, bool> yx;



bool check(int a, int b) {
    if(d[a][b] || y[a] || x[b] || yx[a-b] || xy[b+a]) return false;
    return true;
}

void update(int a, int b, bool c) {
    d[a][b] = c;
    y[a] = c;
    x[b] = c;
    yx[a-b] = c;
    xy[b+a] = c;
}

bool dfs(int n) {
    if(n == 8) return true;
    rep(i, 8) rep(j, 8) {
        if(check(i, j)) {
            update(i, j, 1);
            if(dfs(n+1)) return true;
            update(i, j, 0);
        }
    }
    return false;
}

int main(){
    int n;
    cin >> n;
    rep(i, n) {
        int a, b;
        cin >> a >> b;
        update(a, b, 1);
    }
    dfs(n);
    rep(i, 8) {
        rep(j, 8) cout << (d[i][j] ? 'Q' : '.');
        cout << endl;
    }
    return 0;
}


Measured memory_bytes: 3120
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace AthleteProgramming2
{

    class Point
    {
        double x, y;
        public Point(double x, double y)
        {
            this.x = x;
            this.y = y;
        }

        public Point()
        {

        }

        //??????-?????? p1=?????? p2=??????
        public static Point SubVector(Point p1,Point p2)
        {
            Point vector = new Point();
            vector.x = p1.x - p2.x;
            vector.y = p1.y - p2.y;
            return vector;
        }

        public static bool IsMinus(Point p1,Point p2)
        {
            if (p1.x * p2.y - p1.y * p2.x<=0)
            {
                return true;
            }else
            {
                return false;
            }
        }

    }

    class Triangle
    {
        Point p1, p2, p3;
        
        public Triangle(Point p1,Point p2,Point p3)
        {
            this.p1 = p1;
            this.p2 = p2;
            this.p3 = p3;
        }

        public static bool IsPointInTriange(Triangle triangle,Point p)
        {
            Point vector1 = Point.SubVector(triangle.p2, triangle.p1);
            Point vector2 = Point.SubVector(triangle.p3, triangle.p2);
            Point vector3 = Point.SubVector(triangle.p1, triangle.p3);
            Point pVector1 = Point.SubVector(p,triangle.p1);
            Point pVector2 = Point.SubVector(p,triangle.p2);
            Point pVector3 = Point.SubVector(p,triangle.p3);

            if (Point.IsMinus(pVector1,vector1) && Point.IsMinus(pVector2,vector2) && Point.IsMinus(pVector3,vector3)||
                !Point.IsMinus(pVector1,vector1)&&!Point.IsMinus(pVector2,vector2)&&!Point.IsMinus(pVector3,vector3))
            {
                return true;
            }else
            {
                return false;
            }


        }

    }

    class Program
    {
        static void Main()
        {
            string str;
            double[] array;
            bool isPointCenter = false;
            while ((str = Console.ReadLine()) != null)
            {
                array = str.Split(' ').Select(double.Parse).ToArray();
                Triangle triangle = new Triangle(new Point(array[0], array[1]), new Point(array[2], array[3]), new Point(array[4], array[5]));
                Point p = new Point(array[6], array[7]);
                isPointCenter = Triangle.IsPointInTriange(triangle, p);
                if (isPointCenter)
                {
                    Console.WriteLine("YES");
                }else
                {
                    Console.WriteLine("NO");
                }
            }
        }
    }
}

Measured memory_bytes: 9568
#include<bits/stdc++.h>
using namespace std;
int main()
{
	char a[1000];
	bool s=false;
	gets(a);
	int l;
	l=strlen(a);
	for(int i=0;i<l;i++)
	{
		for(int j=i+1;j<=l;j++)
		{
			if(a[i]=='C'&&a[j]=='F')
			s=true;
		}
	}
	if(s==true)
	cout<<"Yes"<<endl;
	if(s==false)
	cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 256