akhauriyash/Code-Regression huggingface dataset:
//{{{
#include<algorithm>
#include<cmath>
#include<deque>
#include<fstream>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<random>
#include<set>
#include<sstream>
#include<sys/time.h>
#include<unordered_map>
#include<unordered_set>
#include<vector>
using ll = long long;
enum : int { M = (int)1e9 + 7 };
enum : ll { MLL = (ll)1e18L + 9 };
using namespace std;
#ifdef LOCAL
#include"rprint2.hpp"
#else
#define FUNC(name) template <ostream& out = cout, class... T> void name(T&&...){ }
FUNC(printde) FUNC(printdbe) FUNC(printdwe) FUNC(printdu) FUNC(printe) FUNC(printe0);
#endif
template <template <class T, class = std::allocator<T>> class V, class E>
istream& operator >> (istream& in, V<E>& v){ for(auto& e : v){ in >> e; } return in; }
//}}}

struct ExGCDRet{
    ll gcd, a, b;
    friend ostream& operator << (ostream& out, ExGCDRet& e) {
        return out << e.gcd << '(' << e.a << ',' << e.b << ')';
    }
};
ExGCDRet exGCD(ll xx, ll yy){
    // (a2 a1) = (a1 a0)(1 1 )
    // (b2 b1) = (b1 b0)(0 -q)
	ll a0 = 1, b0 = 0, a1 = 0, b1 = 1;
	while(yy){
        auto ret = lldiv(xx, yy);
        xx = yy;
        yy = ret.rem;
		ll a2 = a0 - ret.quot * a1;
        ll b2 = b0 - ret.quot * b1;
        printde(a0, a1, a2);
        printde(b0, b1, b2);
        a0 = a1; b0 = b1;
        a1 = a2; b1 = b2;
	}
	return {xx, a0, b0};
}

map<ll, int> factorization(ll n){
    map<ll, int> fs;
    for(int i = 2; i <= sqrt(n); i++){
        while(n % i == 0){
            fs[i]++;
            n /= i;
        }
    }
    if(n > 1){
        fs[n]++;
    }
    return fs;
}

ll solve(ll n){
    auto fs = factorization(2 * n);
    vector<pair<ll, int>> fs2(fs.begin(), fs.end());
    int n2 = fs2.size();
    printde(fs2);
    ll ans = n & 1 ? n - 1 : 2 * n - 1;
    for(int bits = 0; bits < (1 << n2); bits++){
        ll num1 = 1, num2 = 1;
        for(int i = 0; i < n2; i++){
            for(int j = 0; j < fs2[i].second; j++){
                (bits >> i & 1 ? num1 : num2) *= fs2[i].first;
            }
        }
        if(num1 == 1 || num2 == 1){
            continue;
        }
        auto ret = exGCD(num1, num2);
        ll k1 = abs(num1 * ret.a), k2 = abs(num2 * ret.b);
        ll cand = k1;
        ans = min(ans, cand);
        printde(num1, num2, ret);
        printde(k1, k2, cand);
    }
    return ans;
}

int main(){
    cin.tie(0); ios::sync_with_stdio(false);
    ll n; cin >> n;
    if(n == 1){
        cout << 1 << '\n';
        return 0;
    }
    cout << solve(n) << '\n';
    // cout << min(solve(n, n), solve(n, n * 2)) << '\n';
    // for(int n = 1; n < 10000; n++){
    //     // auto ans = solve(n, n);
    //     auto ans = min(solve(n, n), solve(n, n * 2));
    //     for(ll i = 1; i < ans; i++){
    //         if(i * (i + 1) / 2 % n == 0){
    //             printde(n, ans, i);
    //             return 0;
    //         }
    //     }
    // }
}


Measured memory_bytes: 3156
#include <bits/stdc++.h>
#define ld long double
#define LL long long
#define Accel ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define Re(a,b) memset(a,b,sizeof a)
#define F first
#define S second
#define MP make_pair
#define PB push_back
#define ALL(X) (X).begin(), (X).end()
#define FOR(I, A, B) for (int I = (A); I <= (B); I++)
#define REP(I, N) for (int I = 0; I < (N); I++)
#define PII pair<int,int>
#define PLL pair<LL,LL>
#define SZ(a) ((int)a.size())
#define endl "\n" 
//#pragma GCC optimize(2)
using namespace std;
//typedef complex<double>C;
//const double PI(acos(-1.0));
//const double eps(1e-8);
//for(int mask=i;mask>0;mask=(mask-1)&i)
//int a[25]= { 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97 };
//__gcd, atan2(y,x)=y/x , __int128
//c(n,k)=c(n-1,k-1)+c(n-1,k)
//c(i,r),i for r to n =c(n+1,r+1)
//void add(int x){while(x<N)BIT[x]++,x+=x&-x;}
//int sum(int x){int s=0;while(x){s+=BIT[x];x-=x&-x;}return s;}
//int find(int x){return x==p[x]?x:p[x]=find(p[x]);}
//
//log() = ln() , log(x)/log(y)=log(y)-base-x
//INT_MAX 127,INT_MIN 128
//int dw[4][2]={{0,1},{1,0},{0,-1},{-1,0}};
//int dw[8][2]={{0,1},{1,0},{0,-1},{-1,0},{1,1},{1,-1},{-1,1},{-1,-1}};
//cout<<fixed<<setprecision(12)<<ans<<endl;
//__builtin_popcount(mask)
const int N=3e5+10;
const int M=998244353;
LL n,a,b,k;
LL f[N];
LL pw(LL a,LL b){LL t=1;for(;b;b>>=1,a=a*a%M)b&1?t=t*a%M:0;return t;}
int main(){Accel
	cin>>n>>a>>b>>k;
	f[1]=n;
	f[0]=1;
	FOR(i,2,n){
		f[i]=f[i-1]*(n+1-i)%M*pw(i,M-2)%M;
	}
	LL ans=0;
	FOR(i,0,n){
		LL t=k-a*i;
		if(t<0)continue;
		//cout<<k<<endl;
		if(t%b==0){
			LL j=t/b;
			//cout<<i<<" "<<j<<endl;
			
			if(j<=n){
				ans=ans+f[i]*f[j]%M;
				ans%=M;
			}
		}
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 2560
#include <stdio.h>
   
int main()
{
  int a, i;    
  int n[3000] = {0}, m[3000] = {0};
 
  for (i = 0; i < 3000; i++){
    scanf("%d %d", &n[i], &m[i]);
    if (n[i] == 0 && m[i] == 0){
      break;
    }
    if (n[i] > m[i]){
      a = n[i];
      n[i] = m[i];
      m[i] = a;
    }
  }

  for (i = 0; i < 3000; i++){
     if (n[i] == 0 && m[i] == 0){
      break;
    }
    printf("%d %d\n", n[i], m[i]);
  }

  return 0;
}

Measured memory_bytes: 632
#include<fstream>
#include<string>
#include<iostream>
#include<sstream>
#include<iterator>
#include<cmath>
 
using namespace std;
 
int main(){
 int A;
 int B;
 cin >> A >> B;
 if((A+B)%2==0){
 cout << (A+B)/2 << endl;}
  else{
    cout << "IMPOSSIBLE" << endl;}
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
#include <string>
#include <cmath>
#include <cassert>
#include <queue>
#include <set>
#include <map>
#include <valarray>
#include <bitset>
#include <stack>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define chmax(a,b) (a<(b)?(a=b,1):0)
#define chmin(a,b) (a>(b)?(a=b,1):0)
#define valid(y,x,h,w) (0<=y&&y<h&&0<=x&&x<w)
const int INF = 1<<29;
const double EPS = 1e-8;
const double PI = acos(-1);
typedef pair<int,int> pii;
typedef long long ll;

int main() {
  int L;
  while(cin >> L) {
    int A,B,C,D;
    cin >> A >> B >> C >> D;
    cout << L-max((A+C-1)/C,(B+D-1)/D) << endl;
  }
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
#pragma GCC optimize("Ofast")

using namespace std;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
typedef long long ll;
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REP(i,num,n) for(int i=num, i##_len=(n); i<i##_len; ++i)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
#define print(x) (cout << (x) << endl)
#define pb push_back
#define mp make_pair
#define sz(x) int(x.size())
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
#define fs first
#define sc second
// 多倍長
#include <boost/rational.hpp>
#include <boost/multiprecision/cpp_int.hpp>
using boost::rational;
using boost::multiprecision::cpp_int;

const int INF = 1e9;
const ll LLINF = 1e16;
const ll MOD = 1e9+7;
template<class T> inline void add(T &a, T b){a = ((a+b) % MOD + MOD) % MOD;};

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

// 指定した文字cが文字列に何文字入ってるか
ll stringcount(string s, char c) {
    return count(s.cbegin(), s.cend(), c);
}


// 割り算の切り上げ処理
template<typename T>
T rp(T a, T b) {
  return (a + b - 1) / b;
}

// 桁和
template<typename T>
T digsum(T n) {
    T res = 0;
    while(n > 0) {
        res += n%10;
        n /= 10;
    }
    return res;
}

// 回文判定
bool kai (string s) {
    string t{s};
    reverse(begin(t), end(t));
    return s == t;
}

using pint = pair<int, int>;
using pll = pair<ll, ll>;


vector<string> split(const string &s, char delim) {
    vector<string> elems;
    string item;
    for (char ch: s) {
        if (ch == delim) {
            if (!item.empty())
                elems.push_back(item);
            item.clear();
        }
        else {
            item += ch;
        }
    }
    if (!item.empty())
        elems.push_back(item);
    return elems;
}


int ng[500];
int dp[500];

int main(void)
{
    cout.tie(0);
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    ll n,k;
    cin >> n >> k;
    vector<ll> a(n);
    rep(i, n) {
        cin >> a[i];
    }
    int j = 0;
    REP(i, k, n){
        if(a[i] > a[j]) print("Yes");
        else print("No");
        j++;
    }



    

}



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

#define         pb         push_back
#define         sf(x)      scanf("%d",&x)
#define         sfl(x)     scanf("%lld",&x)
#define         pf(x)      printf("%d\n",x)
#define         pfl(x)     printf("%lld\n",x)
#define         endl       '\n'
#define         pii        pair<int,int>
#define         mapii      map<int,int>
#define         mapll      map<ll,ll>
#define         mapci      map<char,int>
#define         mapcl      map<char,ll>
#define         mapsi      map<string,int>
#define         mapsl      map<string,ll>
#define         pll        pair<ll,ll>
#define         vi         vector<int>
#define         vl         vector<ll>
#define         vd         vector<double,double>
#define         all(c)     c.begin(),c.end()
#define         F          first
#define         S          second
#define         mp         make_pair
#define        ftc(x)      cerr << #x << ": " << x << " " << endl;
#define         PI         acos(-1)
#define         lcm(a,b)   ((a*b)/__gcd(a,b))
//int dx[] = {0,1,0,-1};
//int dy[] = {-1,0,1,0};

//   cout<<std::setprecision(12)<<
vl v;
bool ok(ll x)
{
    ll prv=x%10,l;
    while(x)
    {
        l = (x%10);
        if(abs(prv-l)>1)
            return false;
        prv = x%10;
        x /= 10;
    }
    return true;
}
void pre(ll x)
{
    if(x >= 4234566668)
        return ;
    v.pb(x);
    ll m = x%10;
    if(m == 9)
    {
        pre((x*10) + m);
        pre((x*10) + 8);
    }
    else if(m == 0)
    {
        pre((x*10));
        pre((x*10) + 1);
    }
    else
    {
        pre((x*10) + m);
        pre((x*10) + (m+1));
        pre((x*10) + (m-1));
    }
}
int main()
{

    ll a,i,j,k,l,m,n,ta;

    for(i=1; i<=9; i++)
        pre(i);
    sort(all(v));
    unique(all(v));
    v.resize(distance(all(v)));

    cin >> a;
    cout<<v[a-1]<<endl;


}


Measured memory_bytes: 1400
// AOJ 0092: Square Searching
// 2017.8.12 bal4u@uu
// 2017.11.1 retry

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int dp[1002][1002];
char map[1002][1005];

int main()
{
    int n, r, c, t, ans;
    char buf[10];

    while (fgets(buf, 10, stdin) && *buf != '0') {
		n = atoi(buf);
		for (r = 1; r <= n; r++) fgets(map[r]+1, 1005, stdin);

//		memset(dp, 0, sizeof(dp));
		for (ans = 0, r = 1; r <= n; r++) for (c = 1; c <= n; c++) {
			if (map[r][c] == '*') dp[r][c] = 0;
			else {
				t = dp[r-1][c-1];
				if (dp[r  ][c-1] < t) t = dp[r  ][c-1];
				if (dp[r-1][c  ] < t) t = dp[r-1][c  ];
				dp[r][c] = ++t;
				if (t > ans) ans = t;
			}
        }
        printf("%d\n", ans);
    }
    return 0;
}

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

int main()
{
    int N;
    string A, B, C;
    cin >> N >> A >> B >> C;

    int ans = 0;
    for (int i = 0; i < N; i++)
    {
        int count = 0;
        if (A[i] == B[i])
            count++;
        if (A[i] == C[i])
            count++;
        if (B[i] == C[i])
            count++;

        if (count == 0)
        {
            ans += 2;
        }
        else if (count == 1)
        {
            ans += 1;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
int main() {
  int N, K;
  
  cin >> N >> K;
 
  int res = 1;
  rep (i, N) {
      if (res * 2 < res + K)
        res *= 2;
      else
        res += K;
  }
  
  cout << res << endl;
}

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

int main(){
  int X[110];
  
  int N,K,ans = 0;
  cin >> N >> K;
  
  for (int i = 0;i < N; i++){
    cin >> X[i];
  }
  
  for (int i = 0;i < N; i++){
    int temp = min(X[i],K - X[i]);
    ans += temp;
  }
  cout << 2 * ans << endl;
}

Measured memory_bytes: 3628
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <math.h>
#include <string>
#include <numeric>
#include <algorithm>
#include <utility>


using std::cout;
using std::cin;
using namespace std;
typedef long long ll;
typedef unsigned long long ull;


ll gcd(ll a, ll b) {
    while (b != 0) {
        auto tmp = a;
        a = b;
        b = tmp % a;
    }
    return a;
}

ll lcm(ll a, ll b) {
    return (a * b) / gcd(a, b);
}

int isPrime(int a) {
    for (int i = 2; i * i <= a; ++i) {
        if (a % i == 0) {
            return 0;
        }
    }
    return 1;
}




void oneCase () {
    int n;
    cin >> n;
    map<int, int> counter;
    for (int i = 0; i < n; ++i) {
        int a;
        cin >> a;
        ++counter[a];
    }
    priority_queue<int> heap;
    for (auto it : counter) {
        heap.emplace(it.second);
    }
    while (true) {
        if (heap.top() == 1) {
            break;
        }
        auto count = heap.top();
        heap.pop();
        if (count < 2) {
            heap.push(count - 2);
        } else {
            if (heap.empty()) {
                cout << 1 << "\n";
                return;
            }
            auto count2 = heap.top();
            heap.pop();
            heap.push(count - 1);
            if (count2 > 1) {
                heap.push(count2 - 1);
            }
        }
    }
    cout << heap.size() << "\n";
}





int main() {
    int t = 1;
//    cin >> t;
    while (t > 0) {
        oneCase();
        --t;
    }

    return 0;
}

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

int main(){
  int n,m; cin >> n >> m;
  vector<int> l(m),r(m);
  for(int i=0; i<m; i++) cin>>l[i]>>r[i];
  int left = *max_element(l.begin(),l.end());
  int right = *min_element(r.begin(),r.end());  
  cout << max(0, right-left+1) << endl;
  return 0;
}


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

using namespace std;

#define SZ(x) (int)(x.size())

using ll = long long;
using ld = long double;
using P = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
const double eps = 1e-10;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1ll<<50;

template<typename T>
void printv(const vector<T>& s) {
  for(int i=0;i<(int)(s.size());++i) {
    cout << s[i];
    if(i == (int)(s.size())-1) cout << endl;
    else cout << " ";
  }
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);

  int x, a, b; cin >> x >> a >> b;
  if(abs(x - a) < abs(x - b)) cout << "A" << endl;
  else cout << "B" << endl;
}


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

#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define pf printf
#define sc scanf
#define sf(num) scanf("%d",&num)
#define sff(num1,num2) scanf("%d %d",&num1,&num2)
#define sfff(num1,num2,num3) scanf("%d %d %d",&num1,&num2,&num3);
#define sl(num) scanf("%lld",&num)
#define sll(num1,num2) scanf("%lld %lld",&num1,&num2)
#define slll(num1,num2,num3) scanf("%lld %lld %lld",&num1,&num2,&num3);
#define rep(i,n) for(i=1;i<=n;i++)
#define rep0(i,n) for(i=0;i<n;i++)
#define reps(i,a,n) for(i=a;i<=n;i++)
#define pb push_back
#define mpp make_pair
#define MOD 1000000007
#define fi first
#define se second
#define N 100005
#define mem(ara,n) memset(ara,n,sizeof(ara))
#define memb(ara) memset(ara,false,sizeof(ara))
#define all(x) (x).begin(),(x).end()
#define sq(x) ((x)*(x))
#define pi pair<int,int>
#define pii pair<pair<int,int>,pair<int,int> >
#define db(x) cout<<#x<<" :: "<<x<<"\n";
#define dbb(x,y) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\n";
#define fr freopen("input.txt","r",stdin);
#define fw freopen("output.txt","w",stdout);
#define TIME cerr<<"Time : "<<(double)clock()/(double)CLOCKS_PER_SEC<<"s\n";
typedef long long int ll;
using namespace std;
int main()
{
    int i,n,k;
    vector<int>vec,vec2;
    sf(n);
    rep0(i,n)
    {
        sf(k);
        vec2.pb(k);
        vec.pb(k);
    }
    sort(all(vec),greater<>());
    rep0(i,n)
    {
        if(vec2[i]==vec[0])
            cout<<vec[1]<<endl;
        else
            cout<<vec[0]<<endl;
    }
}


Measured memory_bytes: 3436
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {
	public static final String plus = "+";
	public static final String minus = "-";
	public static final String kake = "*";
    public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
		String strInt = null;
		int intStr = 0;
		int numInt1 = 0;
		int numInt2 = 0;
		int total = 0;
		List<Integer> stack = new ArrayList<Integer>(100);
		while(sc.hasNext()){
			strInt = sc.next();
			if(strInt.equals(plus)){
				numInt2 = stack.get(stack.size() - 1);
				stack.remove(stack.size() - 1);
				numInt1 = stack.get(stack.size() - 1);
				stack.remove(stack.size() - 1);
				total = numInt1 + numInt2;
				stack.add(total);
			}else if(strInt.equals(minus)){
				numInt2 = stack.get(stack.size() - 1);
				stack.remove(stack.size() - 1);
				numInt1 = stack.get(stack.size() - 1);
				stack.remove(stack.size() - 1);
				total = numInt1 - numInt2;
				stack.add(total);
			}else if(strInt.equalsIgnoreCase(kake)){
				numInt2 = stack.get(stack.size() - 1);
				stack.remove(stack.size() - 1);
				numInt1 = stack.get(stack.size() - 1);
				stack.remove(stack.size() - 1);
				total = numInt1 * numInt2;
				stack.add(total);
			}else{
				intStr = Integer.parseInt(strInt);
				stack.add(intStr);
			}
		}
		total = stack.get(stack.size() - 1);
		System.out.println(total);
	}
}

Measured memory_bytes: 26252
'use strict';
(function(input){
  input=input.trim().split(/\n/).map(str=>str.split(/\s+/).map(x=>x-0));
  const N=input[0][0];
  const W=input[0][1];
  const dp=[];//dp[i][w]で重さwまでで最初のi個から選ぶときの価値の最大
  for(let i=0;i<=N;i++){
    dp[i]=[];
    for(let w=0;w<=W;w++){
      dp[i][w]=0;
    }
  }
  for(let i=1;i<=N;i++){
    let wi=input[i][0];
    let vi=input[i][1];
    for(let w=0;w<=W;w++){
      dp[i][w]=dp[i-1][w];
      if(w>=wi&&dp[i][w]<(dp[i-1][w-wi]+vi))
        dp[i][w]=dp[i-1][w-wi]+vi;
    }
  }
  //console.log(dp);
  console.log(dp[N][W]);
})(require('fs').readFileSync('/dev/stdin','utf8'));


Measured memory_bytes: 202564
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<iomanip>
#include<algorithm>
using namespace std;
const int maxn=1005;
int n,k;
int main()
{
    int n;
    cin>>n;
    int t=sqrt(n);
    cout<<t*t<<endl;
    return 0;
}


Measured memory_bytes: 384
#https://atcoder.jp/contests/abc161/submissions/11510702

k = int(input())
ans = [i for i in range(1,10)]
#1,2,3,4,5,6,7,8,9
i = 0

#全探索
#みぎにずらした時に1の位にくる数字ごとに分岐
for i in range(k):
    now = ans[i]
    if str(now)[-1] == '0':
        ans.append(now*10)
        ans.append(now*10+1)
    elif str(now)[-1] == '9':
        ans.append(now*10+8)
        ans.append(now*10+9)
    else:
        ans.append(now*10+now%10-1)
        ans.append(now*10+now%10)
        ans.append(now*10+now%10+1)
    if len(ans) > k:
        break

print(ans[k-1])



Measured memory_bytes: 7184
import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;

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

        Integer n = sc.nextInt();
        Integer[] a = new Integer[n];

        for(int i = 0; i < n; i++){
            a[i] = sc.nextInt();
        }
        
        boolean f = true;
        Integer[] b = new Integer[n];
        
        for(int i = n; i >= 1; i--){
            int count = 0;
            for(int j = i; j <= n; j += i){
                if(j != i && b[j-1] == 1){
                    count++;
                }
            }

            if(a[i-1] == 0){
                b[i-1] = (count % 2);
            } else {
                b[i-1] = ((count + 1) % 2);
            }
        }

        int c = 0;
        for(int i = 0; i < n; i++){
            if(b[i] == 1){
                c++;
            }
        }
        System.out.println(c);
        for(int i = 0; i < n; i++){
            if(b[i] == 1){
                System.out.print(i+1 + " ");
            }
        }
        System.out.println();


    }
}

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

int main() {
	int n;
	int ans;
	int arr[100100];
	scanf("%d",&n);
	ans = n;
	for(int i = 1; i <= n; i++)
		scanf("%d",&arr[i]);
	sort(&arr[1], &arr[n+1]);
	for(int j = 1; j < n; j++)
		if(arr[j] == arr[j+1]){
			ans -= 2;
			arr[j+1] = 0;
		}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 512
n=gets.chomp.to_i
y=[]
for i in 0..n-1
  y[i]=gets.chomp.split(" ").map{|s| s.to_i}
end
y.sort!{|a,b| a[1]<=>b[1]}
t=0
f=true
for i in 0..n-1
  t+=y[i][0]
  if t>y[i][1]
    f=false
    break
  end
end

if f
  puts "Yes"
else
  puts "No"
end

Measured memory_bytes: 18168
import bisect

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

    divisors.sort()
    return divisors

def solv():
    N, M = map(int, input().split())
    divisors = make_divisors(M)
    l_i, r_i = bisect.bisect_left(divisors, N), bisect.bisect_right(divisors, N)
    print(M//divisors[min(l_i, r_i)])

if __name__ == '__main__':
    solv()


Measured memory_bytes: 38640
from bisect import bisect_left as bl, bisect_right as br, insort
import sys
import heapq
#from math import *
from collections import defaultdict as dd, deque
def data(): return sys.stdin.buffer.readline().strip().decode()
def mdata(): return map(int, data().split())
out=sys.stdout.write
#sys.setrecursionlimit(100000)
INF=int(10e9)


n,m=mdata()
dp=[0]*n
g=[set() for i in range(n)]
par=[i for i in range(n)]
chl=[0]*n
for i in range(m):
    x,y=mdata()
    g[x-1].add(y-1)
    chl[y-1]=1
vis=[0]*n
for i in range(n):
    if chl[i]==0:
        s1=deque()
        s1.append(i)
        while s1:
            a=s1[-1]
            if vis[a]==1:
                if a!=i:
                    dp[par[a]]=max(dp[par[a]],dp[a]+1)
                s1.pop()
                continue
            vis[a]=1
            for j in g[a]:
                if vis[j]==0:
                    s1.append(j)
                    par[j]=a
                else:
                    dp[a]=max(dp[a],dp[j]+1)
print(max(dp))





Measured memory_bytes: 70064
package main

import (
	"fmt"
)

func main() {
	var oRaw, eRaw string
	fmt.Scan(&oRaw)
	fmt.Scan(&eRaw)

	o := []rune(oRaw)
	e := []rune(eRaw)

	var limit int
	if len(o) > len(e) {
		limit = len(e)
	} else {
		limit = len(o)	
	}
	for i := 0; i < limit; i++ {
		fmt.Print(string(o[i]))
		fmt.Print(string(e[i]))
	}

	if len(e) - len(o) == 1 {
		fmt.Print(string(e[len(e)-1]))
	}
	if len(o) - len(e) == 1 {
		fmt.Print(string(o[len(o)-1]))
	}
}

Measured memory_bytes: 512
#include<iostream>
using namespace std;
int main() {
    int x[10000];
    int i =0;
    while(1){
        cin>>x[i];
        if(x[i]==0) break;
        i++;
    }
    
    for(size_t j = 0; j < i; j++)
    {
        cout<<"Case "<<j+1<<":"<<" "<<x[j]<<endl;
    }
    
}


Measured memory_bytes: 3088
from collections import Counter
inputs = open(0).readlines()

n = int(inputs[0])
*D, = map(int, inputs[1].split())
mod = 998244353

nbs = [0] * (max(D)+1)
for k, v in Counter(D).items():
    nbs[k] = v

if D[0] != 0 or nbs[0] != 1:
    print(0)
else:
    ans = 1
    for n0, n1 in zip(nbs, nbs[1:]):
        ans = ans * pow(n0, n1, mod) % mod
    print(ans)

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

int main()
{
  int N;
  cin >> N;
  
  int T = 0;//Tは座っている人数の合計
  int l, r;
  
  for(int i = 0; i < N; i++)
  {
    cin >> l >> r;
    T += r - l + 1;
  }
  cout << T << endl;
}

Measured memory_bytes: 256
n=int(input())
a=list(map(int,input().split()))

b=0
minus=0
low=abs(a[0])
for i in range(n):
    if a[i]>0:
        b += a[i]
    else:
        b -= a[i]
        minus += 1
    if abs(a[i])<low:
        low = abs(a[i])

print(b if minus%2==0 else b-2*low)

Measured memory_bytes: 14332
#include <iostream>

using namespace std;

bool prime[100005];
int ans[100005];

int main() {
  for(int i = 2; i < 100005; i++) {
    if(prime[i]) continue;
    for(int j = i + i; j < 100005; j+= i) {
      prime[j] = true;
    }
  }
  int q;
  cin >> q;
  for(int i = 3; i < 100005; i+= 2) {
    if(!prime[i] && !prime[(i+1)/2])ans[i]++;
  }
  for(int i = 1; i < 100005; i++) {
    ans[i] += ans[i-1];
  }

  for(int i = 0; i < q; i++) {
    int l,r;
    cin >> l >> r;
    cout << ans[r] - ans[l-1] << endl;
  }
}

       

	


Measured memory_bytes: 1152
#include <iostream>
#include <algorithm>
#include <cstdio>

using namespace std;
#define long long long

int const N = 1e5 + 10;

int n, act[N][3], f[N][3];

int main()
{
//    freopen("tam.inp", "r", stdin);
    cin.tie(nullptr); ios_base::sync_with_stdio(false);

    cin >> n;
    for (int i = 1; i <= n; ++i)
        for (int j = 0; j < 3; ++j) cin >> act[i][j];

    for (int i = 1; i <= n; ++i)
        for (int j = 0; j < 3; ++j)
            for (int cur = 0; cur < 3; ++cur) if (j != cur)
                f[i][j] = max(f[i][j], f[i - 1][cur] + act[i][j]);

    cout << max({f[n][0], f[n][1], f[n][2]});

    return 0;
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
 
int n, cnt[5];
 
/*
K = (X+1)*p0 + (Y+1)*p1 + (Z+1)*p2 + (K+1)*p3
K - Kp3 = (X+1)*p0 + (Y+1)*p1 + (Z+1)*p2 + p3
K (1 - p3) = (X+1)*p0 + (Y+1)*p1 + (Z+1)*p2 + p3
K = ((X+1)*p0 + (Y+1)*p1 + (Z+1)*p2 + p3) / (1 - p3)
*/
 
double dp[305][305][305];
 
double solve(int a, int b, int c){
    if(a < 0 || b < 0 || c < 0) return 0;
    if(a+b+c == 0) return 0;
    if(dp[a][b][c] != -1) return dp[a][b][c];
    double x = (1 + solve(a-1, b, c)) * a * 1.0/n;
    double y = (1 + solve(a+1, b - 1, c)) * b * 1.0/n;
    double z = (1 + solve(a, b+1, c-1)) * c * 1.0/n;
    
    double prob = (n-a-b-c) * 1.0/n;
    double k = (x+y+z+prob)/(1 - prob);
    return dp[a][b][c] = k;
}
 
int main(){
    cin >> n;
    for(int i = 0; i < n; i++){
        int x; cin >> x;
        cnt[x]++;
    }
    for(int i = 0; i <= n; i++)
        for(int j = 0; j <= n; j++)
            for(int k = 0; k <= n; k++)
                dp[i][j][k] = -1;
    //cout << cnt[1] << " " << cnt[2] << " " << cnt[3] << endl;
    printf("%.9lf\n", solve(cnt[1], cnt[2], cnt[3]));
	return 0;
}

Measured memory_bytes: 219392
#include<iostream>
#include<array>
#include<algorithm>

using namespace std;

int main(){
    array<pair<long long,long long>, 100000>a;
    long long n, h,max = 0, count = 0;
    cin>>n>>h;
    for(int i = 0; i < n; i++){
        cin>>a.at(i).second>>a.at(i).first;
        if(max < a.at(i).second){
            max = a.at(i).second;
        }
    }
    sort(a.begin(),a.end());
    for(int i = 99999; i > 99999 - n; i--){
        if(a.at(i).first > max){
            count++;
            h -= a.at(i).first;
            if(h <= 0) break;
        }else{
            break;
        }
    }
    if(h > 0){
        count += h/max;
        if(h%max != 0) count++;
    }
    cout<<count<<endl;
}

Measured memory_bytes: 1792
def ave(b,c):
    return b//2 + c//2
def rest(a,b,c):
    return ave(b,c), ave(a,c), ave(b,a)
a, b, c = map(int, input().split())
ans = 0
while 1:
    if a % 2 == 1 or b % 2 == 1 or c % 2 == 1 :
        print(ans)
        break
    d, e, f = rest(a,b,c)
    if (a, b, c) == (d, e, f):
        print(-1)
        break
    ans += 1
    a, b, c = d, e, f

Measured memory_bytes: 8984
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) 
	{
		Scanner sc = new Scanner(System.in);
		
		while(true)
		{
			int n = sc.nextInt();
			int r = sc.nextInt();
			
			if(n == 0 && r == 0)return;
			
			LinkedList<Integer> l = new LinkedList<>();
			
			for(int i = 0; i < n; i++)
			{
				l.add(n-i);
			}
			
			for(int i = 0; i < r; i++)
			{
//				System.out.println(l);
				int j = sc.nextInt()-1;
				int qty = sc.nextInt();
				
				ArrayList<Integer> l0 = new ArrayList<>();
				
				for(int k = 0; k < qty; k++)
				{
					l0.add(l.get(j));
					l.remove(j);
				}
				
//				System.out.println(l);
//				System.out.println("l0 " + l0);
				for(int k = qty-1; k >= 0; k--)
				{
					l.addFirst(l0.get(k));
				}
			}
			
			System.out.println(l.getFirst());
		}

	}

}



Measured memory_bytes: 38496
#include <bits/stdc++.h>
using namespace std;
const int maxn = 100100;
using ii = pair<int,int>;
vector<int> e[maxn];
bool has = true;
int solve(int root, int par){
	if(e[root].size() == 1) return root;
	int bads = 0;
	for(int nxt : e[root]){
		if(nxt == par) continue;
		int val = solve(nxt, root);
		if(val != -1) bads++;
	}
	if(bads > 1) has = false;
	if(bads == 1) return -1;
	return root;
}
int main(){
	int n; cin >> n;
	if(n == 2){
		cout << "Second" << endl;
		return 0;
	}
	for(int i = 0; i < n - 1; i++){
		int u, v; cin >> u >> v;
		e[u].push_back(v);
		e[v].push_back(u);
	}
	int rt = -1;
	for(int i = 1; i <= n; i++) if(e[i].size() > 1) rt = i;
	has &= -1 == solve(rt, 0);
	if(!has) cout << "First" << endl;
	else cout << "Second" << endl;
	return 0;
}


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

#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for (int i = x; i < n; i++)
#define OP(m) cout << m << endl
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;

int main()
{
    int n;
    cin >> n;
    if (n < 1000)
        printf("ABC\n");
    else
        printf("ABD\n");
    return 0;
}

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

int n, m;
int a[111111];
int k, ans, p;

int main(){

  cin >> n >> m;
  for(int i=1;i<n;i++) cin >> k, a[i] = a[i-1] + k;

  while(m--){
    cin >> k;
    ans += abs(a[p+k]-a[p]);
    ans %= 100000;
    p += k;
  }

  cout << ans << endl;
}

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

using namespace std;

int main(void) {
	long long N, M;
	cin >> N >> M;
	if(N > M) {
		long long t = N;
		N = M;
		M = t;
	}
	if(N > 1) {
		cout << (N - 2) * (M - 2) << '\n';
	} else if(M > 1) {
		cout << (M - 2) << '\n';
	} else {
		cout << "1\n";
	}
	return 0;
}



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

int main(){
  int m1, d1, m2, d2;
  cin >> m1 >> d1 >> m2 >> d2;
  if ((m1+1)%12 == m2%12) cout << 1 << endl;
  else cout << 0 << endl;
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int search(int A[],int n,int key){

int i = 0;
A[n]= key;
	while(A[i] != key)i++;
	return i != n;
}


int main(void){
	int i,n,A[10000+1],q,key,sum =0;
	scanf("%d",&n);
	
	for(i=0; i<n; i++) scanf("%d",&A[i]);
	scanf("%d",&q);
	
	for(i=0; i<q; i++){
		scanf("%d",&key);
		if(search(A,n,key)) sum++;
	}
	
	printf("%d\n", sum);
	
return 0;
}


Measured memory_bytes: 2084
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int n,m,a,b;
    cin>>n>>m;
    multimap<int, int> map;
    std::deque<int> deq(200001,0);
    for (int i=0;i<m;i++) {
        cin>>a>>b;
        map.emplace(a,b);
        deq[a]=1;
    }
    int flag=0;
    auto p=map.equal_range(1);
    for (auto itr=p.first;itr!=p.second;itr++) {
        if (deq[itr->second]==1) {
            auto q=map.equal_range(itr->second);
            for (auto itr2=q.first;itr2!=q.second;itr2++) {
                if (itr2->second==n) {
                    cout<<"POSSIBLE"<<endl;
                    flag=1;
                    break;
                }
            }
        }
        if (flag==1) {
            break;
        }
    }
    if (flag==0) {
        cout<<"IMPOSSIBLE"<<endl;
    }
}

Measured memory_bytes: 10496
#include<bits/stdc++.h>
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define MOD	1000000007
#define int	long long
#define pii pair<int,int> 
#define vi vector<int>
using namespace std;

int32_t main(){
	int ans = 0;
	int n;
	cin >> n;
	
	for(int i = 1; i <= n; i++){
		if(i % 3 && i % 5)
			ans += i;
	}
	cout << ans;

	return 0;
}



Measured memory_bytes: 3596
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<cstring>
#include<cstdio>
using namespace std;

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(n) rep(i,n)
#define all(n) n.begin(),n.end()
typedef long long ll;

const int MAXN = 101;

ll x[MAXN];

int main()
{
    int n , m, p;
    while(cin >> n >> m >> p && n)
    {
        ll sum = 0;
        m--;
        REP(n) { cin >> x[i]; sum += x[i] ;}

        ll ans = 0;
        
        if(x[m] != 0) ans = (100 - p) * sum / x[m];
        cout << ans << endl;
    }

    return 0;
}

Measured memory_bytes: 0
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector> 
#include<limits>
#include<numeric>
#include<type_traits>
#include<math.h>
using namespace std;
typedef long long ll;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i = (int)(a); i < (int)(b); i++)
#define in(x) cin >> x
#define out(str) cout << str << endl

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

ll N,A[5],pos,mini=1e16;

int main(){
    cin>>N;
    rep(i,5){
        cin>>A[i];
        if(mini>A[i]){
            pos=i;
            mini=A[i];
        }
    }
    if(N%mini==0){
        out(N/mini+4);
    }
    else{
        out(N/mini+5);
    }
}


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

using namespace std;

string s;
long long int cnt[26];
int main(void)
{
	cin.tie(0);
	ios::sync_with_stdio(false);

	cin >> s;
	int n = s.length();
	long long int res = n;
	res = res*(res + 1)/2;
	for(int i=0;i<n;i++)
	{
		cnt[s[i]-'a']++;
	}
	for(int i=0;i<26;i++)
	{
		res -= ((cnt[i])*(cnt[i]+1)/2);
	}
	res += 1;
	cout << res << '\n';
	return 0;
}

Measured memory_bytes: 720
#include <iostream>
#include <cmath>
#include <string>
#include <vector>

using namespace std;

typedef long long ll;

#define for(i, a, b) for(int (i)=a;(i)<(b);++(i))
#define rep(i, n)    for(i, 0, n)
#define sz(x)        ((int)(x).size())
#define inf          1<<25

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

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

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

int main() {
    string s;
    cin >> s;
    
    int c = 0;
    rep(i, 3) if (s[i] == '1') c++;
    
    cout << c << endl;
    return 0;
}

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

int main() {
    int N;
    cin >> N;
    string S1, S2;
    cin >> S1 >> S2;

    bool prev;
    long long res;
    int i;
    if(S1[0] == S2[0]) {
        prev = true;
        res = 3;
        i = 1;
    } else {
        prev = false;
        res = 6;
        i = 2;
    }

    for(; i<N; ++i) {
        if(S1[i] == S2[i]) {
            if(prev) res *= 2;
            res %= mod;
            prev = true;
        } else {
            if(prev) res *= 2;
            else res *= 3;
            res %= mod;
            prev = false;
            ++i;
        }
    }

    cout << res << endl;
}

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

#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define size_t unsigned long long
#define ll long long
#define rep(i,a) for(int i=0;i<(a);i++)
#define repr(i,a) for(int i=(int)(a)-1;i>=0;i--)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define FORR(i,a,b) for(int i=(int)(b)-1;i>=a;i--)
#define ALL(a) a.begin(), a.end()
using namespace std;
int si() { int x; scanf("%d", &x); return x; }
long long sl() { long long x; scanf("%lld", &x); return x; }
string ss() { string x; cin >> x; return x; }
void pi(int x) { printf("%d ", x); }
void pl(long long x) { printf("%lld ", x); }
void pd(double x) { printf("%.15f ", x); }
void ps(const string &s) { printf("%s ", s.c_str()); }
void br() { putchar('\n'); }

const ll MOD = 1e9 + 7;
const ll INF = 1e9 + 5;
typedef pair<ll, ll> P;

const ll N = 1e5+5;

class UnionFind {
  int par[N]; // 親
  int rank[N]; // 木の深さ
  unsigned size_;
public:
  void init(int n) {
    for (int i=0; i < n; i++) {
      par[i] = i;
      rank[i] = 0;
    }
  }
  unsigned size() {return size_;}
  // 木の根を求める
  int find(int x) {
    if(par[x] == x) {
     return x;
    } else {
     return par[x] = find(par[x]);
    }
  }
  // xとyの属する集合を併合
  void unite(int x, int y) {
    x = find(x);
    y = find(y);
    if(x == y) return;

    if(rank[x] < rank[y]) {
      par[x] = y;
    } else {
      par[y] = x;
      if(rank[x] == rank[y]) rank[x]++;
    }
  }
  // xとyが同じ集合に属するかいなか
  bool same(int x, int y) {
    return find(x) == find(y);
  }
};


// 返り値はそうコスト

struct point {ll number,x,y;};
struct edge {point u,v;ll cost;};

bool comp(const edge& e1, const edge& e2) {
  return e1.cost < e2.cost;
}

bool comp_x(const point& e1, const point& e2) {
  return e1.x < e2.x;
}

bool comp_y(const point& e1, const point& e2) {
  return e1.y < e2.y;
}

edge es[2*N];
ll n, E; // 頂点数と辺数

ll kruskal() {
  sort(es, es+E, comp); // edge.cost が小さい順にソートする
  UnionFind uf;
  uf.init(n);  // Union-Findの初期化
  ll res = 0;
  rep(i,E) {
    edge e = es[i];
    // cout << e.u.number << " : " << e.v.number << endl;
    if(!uf.same(e.u.number, e.v.number)) {
      uf.unite(e.u.number,e.v.number);
      res += e.cost;
    }
  }
  return res;
}

int main () {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  ll a,b;
  cin >> n;
  point p[n];
  rep(i,n) {
    cin >> a >> b;
    p[i] = (point) {i,a,b};
  }
  sort(p,p+n, comp_x);
  rep(i,n-1) {
    es[i] = (edge) {p[i],p[i+1],abs(p[i+1].x - p[i].x)};
  }
  sort(p,p+n, comp_y);
  E = 2*(n-1);
  rep(i,n-1) {
    es[i+n-1] = (edge) {p[i],p[i+1],abs(p[i+1].y - p[i].y)};
  }


  // rep(i,E) cout << es[i].u.number << endl;
  cout << kruskal() << endl;
}


Measured memory_bytes: 14336
n,k=map(int, input().split())
a=list(map(int, input().split()))
from itertools import accumulate
for _ in range(min(50,k)):
    new=[0]*n
    for i in range(n):
        j=a[i]
        l=max(0,i-j)
        r=min(n-1,i+j)
        new[l]+=1
        if r+1<n:
            new[r+1]-=1
    new=list(accumulate(new))
    a=new
print(*a)

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

int main() {
  string s;cin>>s;
  if (s=="Sunny") cout<<"Cloudy";
  else if (s=="Cloudy") cout<<"Rainy";
  else cout<<"Sunny";
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <stack>
#include <algorithm>
#include <iostream>
#include <string>
#include <map>


int main() {

    int N;
    std::cin >> N;

    std::vector<int> os;
    std::vector<int> ps;
    std::vector<int> qs;

    int p, q;
    for (int i = 0; i < N; ++i) {
        std::cin >> p;
        ps.push_back(p);
        os.push_back(p);
    }
    for (int i = 0; i < N; ++i) {
        std::cin >> q;
        qs.push_back(q);
    }
    sort(os.begin(), os.end());
    int a = 0;
    int b = 0;
    int i = 0;
    do {
        bool found = true;
        for (int i = 0; i < N; ++i) {
            if (ps[i] != os[i]) {
                found = false;
                break;
            }
        }

        if (found) {
            a = i;
        }
        found = true;
        for (int i = 0; i < N; ++i) {
            if (qs[i] != os[i]) {
                found = false;
                break;
            }
        }
        if (found) {
            b = i;
        }
        i += 1;
    } while (std::next_permutation(os.begin(), os.end()));

    std::cout << abs(a - b) << "\n";

    return 0;
}


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

using namespace std;

typedef long long ll; 
typedef pair<int, int> ii; 
typedef vector<ii> vii;
typedef vector<int> vi;

typedef vector<ll> vll;
#define  fastio         ios:: sync_with_stdio(0);cin.tie(0);cout.tie(0);cout<<fixed;cout<<setprecision(10);
#define MAX 1000000007
#define pb push_back
#define mp make_pair
#define loop(i,n) for (int i = 0; i < n; ++i)
#define arr_print(arr, n) loop(i, n){cout<<arr[i]<<" ";}cout<<endl;

const int INF = 0x3f3f3f3f;

int main()
{

    int n;
    cin >> n;

    vll adj[n+1];


    int arr[n];

    for (int i = 1; i < n; i++)
    {
        cin >> arr[i];
        adj[arr[i]].pb(i+1);
    }

    for(int i = 1; i <= n; i++)
    {
        cout << adj[i].size() << endl;
    }
}

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

#define ll long long
#define endl "\n"
#define vi vector<int>
#define pb push_back
#define F first
#define S second

unsigned long long power(unsigned long long x,
                         int y, int p)
{
	unsigned long long res = 1; // Initialize result

	x = x % p; // Update x if it is more than or
	// equal to p

	while (y > 0) {
		// If y is odd, multiply x with result
		if (y & 1)
			res = (res * x) % p;

		// y must be even now
		y = y >> 1; // y = y/2
		x = (x * x) % p;
	}
	return res;
}

// Returns n^(-1) mod p
unsigned long long modInverse(unsigned long long n, int p)
{
	return power(n, p - 2, p);
}

// Returns nCr % p using Fermat's little
// theorem.
unsigned long long nCrModPFermat(unsigned long long n,
                                 int r, int p)
{
	// Base case
	if (r == 0)
		return 1;

	// Fill factorial array so that we
	// can find all factorial of r, n
	// and n-r
	unsigned long long fac[n + 1];
	fac[0] = 1;
	for (int i = 1; i <= n; i++)
		fac[i] = (fac[i - 1] * i) % p;

	return (fac[n] * modInverse(fac[r], p) % p * modInverse(fac[n - r], p) % p) % p;
}

void solve() {

}

int main() {
#ifndef ONLINE_JUDGE
	freopen("manish.txt", "r", stdin);
	//freopen("ps.txt", "w", stdout);
#endif
	int t;
	//cin >> t;
	t = 1;
	while (t--) {
		int n;
		cin >> n;
		ll mod = 1e9 + 7;

		ll ans = (power(10, n, mod) - 2 * power(9, n, mod) % mod + power(8, n, mod) + mod) % mod;

		cout << ans << endl;

	}
	return 0;
}

Measured memory_bytes: 3592
import fractions
n, m = map(int, input().split())
ns = input()
ms = input()

# n, m = 10**5, 31111
# print(math.gcd(n, m))

gcd = fractions.gcd(n, m)
lcm = n * m // gcd
# print(lcm, lcm // n, lcm // m)
lcmN = lcm // n
lcmM = lcm // m

# for i in range(lcm):
#     if (i % (lcmN)) == 0:
#         print(ns[i // lcmN], end="")
#     else:
#         print(".", end="")
# print()
# for i in range(lcm):
#     if (i % (lcmM)) == 0:
#         print(ms[i // lcmM], end="")
#     else:
#         print(".", end="")

s = []
for i in range(0, n, lcmM):
    s.append(ns[i])
for i in range(0, m, lcmN):
    if ms[i] != s[i // lcmN]:
        print(-1)
        exit()
print(lcm)


Measured memory_bytes: 5468
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;

void main()
{
    auto ab = readln.split.to!(long[]);
    auto A = ab[0]-1;
    auto B = ab[1];
    long[60] bs;
    foreach (long i; 0..60) {
        bs[i] += B/(1L<<(i+1))*(1L<<i) + max(0, B%(1L<<(i+1)) - ((1L<<i)-1));
        if (A > 0) bs[i] -= A/(1L<<(i+1))*(1L<<i) + max(0, A%(1L<<(i+1)) - ((1L<<i)-1));
    }
    long r;
    foreach (i; 0..60) {
        if (bs[i]&1) r |= 1L<<i;
    }
    writeln(r);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define MD 1000000007
typedef long long int ll;
typedef pair<ll, ll> P;
template <typename T>
std::string tostr(const T &t){std::ostringstream os;os << t;return os.str();}
int dx[4]={1, 0, -1, 0}, dy[4]={0, 1, 0, -1};
 
int main()
{
    int n,k;
    cin>>n>>k;
    double ans=0.0;
    for(int i=1;i<=n;i++){
        int tmp=i,cnt=0;
        while(tmp<k){
            tmp*=2;
            cnt++;
        }
        double tmp2=0.5,tmp1=0.5;
        for(int j=0;j<cnt-1;j++) tmp1*=tmp2;
        if(cnt==0) tmp1=1.0;
        ans+=((double)1/(double)n)*tmp1;   
    }
    printf("%.12lf\n",ans);
    return 0;
}

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

int main()
{
  string o, e;
  cin >> o >> e;
  
  for(unsigned int i = 0; i < e.length(); ++i){
    cout << o[i];
    cout << e[i];
  }
  if(o.length() != e.length()) cout << o.back() << endl;
}

Measured memory_bytes: 3596
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String[] line = sc.nextLine().split(" ");
        ArrayDeque<Integer> stack = new ArrayDeque<>();
        for (String x : line) {
            char c = x.charAt(0);
            if (c == '+' || c == '-' || c == '*') {
                int second = stack.pop();
                int first = stack.pop();
                if (c == '+') {
                    first += second;
                } else if (c == '-') {
                    first -= second;
                } else {
                    first *= second;
                }
                stack.push(first);
            } else {
                stack.push(Integer.parseInt(x));
            }
        }
       System.out.println(stack.pop());
    }
}


Measured memory_bytes: 26220
#include<bits/stdc++.h>
#define ll int
using namespace std;
typedef pair<ll, ll > Pair;

int main(){
  ll n;
  scanf("%d",&n);
  vector <Pair> v(n);
  for(auto &x : v)
	scanf("%d%d",&x.first,&x.second);
  
  sort(v.begin(),v.end(),[](Pair x, Pair y){
	  if(x.second <= y.second){
		  if(x.first > y.first && x.second == y.second)
			return false;
		  return true;
	  }
	  return false;
  });
  
  bool flag = true;
  long long int  now = 0;
 
  for(int i = 0 ; i < n; i++){
	   now += v[i].first;
	  if(now > v[i].second){
		  flag = false;
		  break ;
	  }
  }
  
  puts(flag?"Yes":"No");
  
  return 0;
}


Measured memory_bytes: 1792
#include <iostream>

using namespace std;

int main() {
    uint64_t n;
    cin >> n;
    n %= 10;
    if (n == 2 || n == 4 || n == 5 || n == 7 || n == 9) {
        cout << "hon";
        return 0;
    }
    if (n == 0 || n == 1 || n == 6 || n == 8) {
        cout << "pon";
        return 0;
    }
    cout << "bon";
    return 0;
}

Measured memory_bytes: 3644
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long ll;
typedef pair<ll,ll> P;
const ll mod=1000000007;
const ll LINF=1LL<<60;
const int INF=1<<30;
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; }
ll copy(ll x){return x;}
int main(){
	ll n;cin>>n;
	vector<ll> a(100005,0);
	ll ans = 0;	
	for(int i = 0; i < n; i++) {
		ll x;cin>>x;
		a[x]++;
		ans += x;
	}
	int q;cin>>q;
	for(int i = 0; i < q; i++) {
		ll b,c;cin>>b>>c;
		ll x = a[b];
		ans += a[b] * c;
		ans -= a[b] * b;
		a[c] += x;
		a[b] = 0;
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 3976