akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;
using namespace std;
const int MOD = 1000000007;
const int INF = 1010000000;
const double EPS = 1e-10;
const array<pair<int,int>,4> fd{make_pair(1,0),make_pair(-1,0),make_pair(0,1),make_pair(0,-1)}; 

int main(){
  int n;cin>>n;int a[100000];rep(i,n)cin>>a[i];sort(a,a+n);
  int ans = 0, pre = a[0], count = 1;
  repd(i,1,n){
    if(a[i] == pre){
      count++;
    }else{
      pre = a[i];
      if(!!(count%2)){
        ans++;
      }
      count = 1;
    }
  }
  if(!!(count%2))ans++;
  cout << ans << endl;
}




Measured memory_bytes: 640
#include<stdio.h>
#define N 100
int main(){
	int i,n,v,j,k;
	int A[N];
	scanf("%d",&n);
	for(k = 0; k < n;k++)
			scanf("%d",&A[k]);

	for(i = 0;i < n; i++){
		v = A[i];
		j = i - 1;
		while(j >= 0 && A[j] > v){
			A[j+1] = A[j];
			j--;
		}
		A[j+1] = v;
		for(k = 0; k < n;k++){
			printf("%d",A[k]);
			if(k != (n-1))
				printf(" ");
		}
		printf("\n");
	}

	return 0;
}


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


int main(){
    int n,m;
    cin >> n >> m;
    vector<int> array(m);
    for(int i=0;i<m;i++){
        cin >> array.at(i);
    }
    sort(array.begin(),array.end());
    vector<int> dev(m-1);
    for(int i=0;i<array.size()-1;i++){
        dev.at(i) = array.at(i+1) - array.at(i);
    }
    sort(dev.begin(),dev.end());
    int sum = 0;
    if(n < m){
        int k = dev.size();
        for(int i=k-n;i>=0;i--){
            //cout << i << endl;
            sum += dev.at(i);
        }
    }
    cout << sum << endl;
}

Measured memory_bytes: 3980
n = int(input())
A = list(map(int,input().split()))

flag = 0
ans = 1000
cnt = 0
for i in range(n-1):
    if flag == 0 and A[i] < A[i+1]:
        cnt += ans//A[i]
        ans %= A[i]
        flag = 1
    elif flag == 1 and A[i] > A[i+1]:
        ans += cnt*A[i]
        cnt = 0
        flag = 0
print(ans + cnt*A[n-1])


Measured memory_bytes: 61752
#include<bits/stdc++.h>
using namespace std;
bool cmp(const vector<long>&A,const vector<long>&B){
  for(long i=0;i<A.size();i++)if(A[i]!=B[i])return 0;
  return 1;
}
int main(){
  long N;cin>>N;
  vector<long>X(N),Y(N);
  for(long i=0;i<N;i++)cin>>X[i];
  for(long i=0;i<N;i++)cin>>Y[i];
  vector<long>P(N);for(long i=0;i<N;i++)P[i]=i+1;
  long i=0;
  long a,b;
  do{
    if(cmp(X,P))a=i;
    if(cmp(Y,P))b=i;
    i++;  
  }while(next_permutation(P.begin(),P.end()));
  cout<<abs(a-b)<<endl;
}

/*



*/

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

using namespace std;

using LL = long long;

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

template<typename S, typename T>
ostream& operator << (ostream& out, const pair<S, T>& p) {
    return out << "{" << p.first << ", " << p.second << "}";
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    
    LL N;
    cin >> N;
    --N;
    LL K = 26;
    int d = 1;
    
    while(true) {
        if(N < K) {
            string S;
            for(int i = 0; i < d; ++i) {
                S += 'a' + (N % 26);
                N /= 26;
            }
            for(int i = d - 1; i >= 0; --i) {
                cout << S[i];
            }
            cout << "\n";
            return 0;
        } else {
            N -= K;
            K *= 26;
            ++d;
        }
    }
    
    
    return 0;
}


Measured memory_bytes: 3652
import sys
def input(): return sys.stdin.readline().rstrip()
def main():
    n=int(input())
    for a in range(n//4+1,3501):
        for b in range(n*a//(4*a-n),3501):
            if 4*a*b-n*(a+b)>0 and n*a*b%(4*a*b-n*(a+b))==0:
                print(a,b,n*a*b//(4*a*b-n*(a+b)))
                sys.exit()

if __name__=='__main__':
    main()


Measured memory_bytes: 3060
#include <bits/stdc++.h>
        using namespace std;
        #define int long long
const int MAX = 510000;
const int MOD = 1000000007;
//
int fac[MAX], finv[MAX], inv[MAX];

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

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

        signed main() {
                cout << std::setprecision(12); 
                COMinit();
        int n;
        cin>>n;
        int k[n+1];
        k[1]=1;
        for(int i=2;i<=n;i++)k[i]=(k[i-1]+inv[i])%MOD;
        int a,ans=0;
        for(int i=0;i<n;i++){
                cin>>a;
                ans=(ans+(((k[n-i]+k[i+1]-1)%MOD)*a)%MOD)%MOD;
        }
        cout<<(ans*fac[n])%MOD;

        
        
        


      }


        


Measured memory_bytes: 12928
#include<iostream>
#include<string>
using namespace std;
int main()
{
	string n;
	int ans=0;
	cin>>n;
	for(int i=0;i<n.length()-1;i++)
	{
		if(n[i]!=n[i+1])
		{
			ans++;
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 512
#include<stdio.h>
#include<algorithm>
using namespace std;
int n,k,i,j,srx[200001],sry,t,p;
int main()
{
   scanf("%d%d",&n,&k);
   for(i=1;i<=n;++i)
   {scanf("%d",&t);
   srx[t]++;}
   sort(srx+1,srx+n+1);
   for(i=n;i>n-k;--i)
   sry+=srx[i];
   printf("%d",n-sry);
   return 0;
}

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

int main() {
    int a,min,max,n;
    long sum;
    cin>>n;
    cin>>a;
    max = a;
    min = a;
    sum = a;
    for (int i = 0; i < n-1; ++i) {
        cin>>a;
        if (a<min) min = a;
        if (a>max) max = a;
        sum +=a;
    }
    cout<<min<<" "<<max<<" "<<sum<<endl;
    return 0;
}


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

int main() {
	// your code goes here
	int a,b,c,k,flag=0;
	cin>>a>>b>>c;
	cin>>k;
	if (b<=a && k>0)
	{
	    while (b<=a)
	    {
	        if (k==0)
	        {
	            flag=1;
	            break;
	        }
	        b = b*2;
	        k--;
	    }
	}
	if (c<=b && k>0 && flag==0)
	{
	    while (c<=b)
	    {
	        if (k==0)
	        {
	            flag=1;
	            break;
	        }
	        c = c*2;
	        k--;
	    }
	}
	if (flag==0 && b>a && c>b)
	    cout<<"Yes"<<"\n";
	else
	    cout<<"No"<<"\n";
	return 0;
}


Measured memory_bytes: 3600
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <vector>
#define rep(i,n) for(int i=0;i<n;i++)
#define ll long long int
#define MAX 1000000007

using namespace std;

int min(int a, int b){
	if(a<b)return a;
	else return b;
}

int main(void){
	int N,K;
	cin>>N>>K;
	double ans=0.0;
	double work=0.0;
	int cnt=2, m=min(N,K-1);
	rep(i,20){
		if(m*cnt > K)break;
		cnt*=2;
	}
	rep(i,m){
		int id = m-i;
		if(id*cnt < K)cnt*=2;
		ans+=1/(double)(cnt);
	}
	if(N>=K)ans+=(double)(N-K+1);
	ans/=(double)N;
	printf("%.16lf \n", ans);
	return 0;

}


Measured memory_bytes: 256
N = int(input())
if N == 1:
    print(0)
    exit()
A = [int(i) for i in input().split()]
A = [A[i] - i - 1 for i in range(N)]
A.sort()
if N == 2:
    print(abs(A[0] - A[1]))
    exit()

sum_A = [0, 0]
for i in range(N):
    sum_A[0] += abs(A[i] - A[N // 2])
sum_2 = 0
for i in range(N):
    sum_A[1] += abs(A[i] - A[N // 2 + 1])
print(min(sum_A))


Measured memory_bytes: 25836
#include<iostream>
#include<cstdio>
using namespace std;
int main()
{
	int n;
	int p[100];
	int r[100];
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		p[i]=0;
		r[i]=1;
	}
	int a,b,c,d;
	for(int i=0;i<n*(n-1)/2;i++){
		scanf("%d%d%d%d",&a,&b,&c,&d);
		if(c>d)p[a-1]+=3;
		else if(c<d)p[b-1]+=3;
		else{
			p[a-1]+=1;
			p[b-1]+=1;
		}
	}

	for(int i=0;i<n;i++){
		for(int j=i+1;j<n;j++){
			if(p[i]>p[j])r[j]++;
			if(p[i]<p[j])r[i]++;
		}
	}

	for(int i=0;i<n;i++)printf("%d\n",r[i]);
	return 0;
}

Measured memory_bytes: 1192
#define _USE_MATH_DEFINES
#include <iostream>
#include <sstream>
#include <cmath>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>

using namespace std;

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

int main(){
	int n,m;
	while(~scanf("%d",&n)){
		if(n==0) break;
		scanf("%d",&m);

		int* mincost = new int[n];
		bool* used = new bool[n];

		fill((bool*)used,(bool*)used + n,false);
		fill((int*)mincost,(int*)mincost + n,numeric_limits<int>::max());


		int** cost = new int*[n];
		for(int i=0;i<n;i++){
			cost[i] = new int[n];
			for(int j=0;j<n;j++){
				cost[i][j]=numeric_limits<int>::max();
			}
		}
		
		for(int i=0;i<m;i++){
			int from,to,dist;
			scanf("%d,%d,%d",&from,&to,&dist);
			cost[from][to] = min(cost[from][to],dist / 100 - 1);
			cost[to][from] = min(cost[to][from],dist / 100 - 1);
		}

		mincost[0]=0;

		int res=0;
		while(1){
			int v=-1;
			for(int u=0;u<n;u++){
				if(!used[u] && (v==-1 || mincost[u] < mincost[v])){
					v = u;
				}
			}

			if(v==-1) break;
			used[v] = true;		
			res+=mincost[v];
			
			for(int u=0;u<n;u++){
				mincost[u] = min(mincost[u],cost[v][u]);
			}
			
		}

		cout << res << endl;

		for(int i=0;i<n;i++){
			delete[] cost[i];
		}

		delete[] cost;
	}
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
#include <bitset>
using namespace std;
#define ll long long
#define fast ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define dcm(a) setprecision(a)<<fixed
#define MOD 1000000007
#define clr(memo, a) memset(memo,a,sizeof(memo))
#define PI acos(-1)
int const N=3e3+5;
double p[N];
double memo[N][N];
int n;
double dp(int i,int cnt){
if(i==n){
    if(cnt>n/2)
        return 1.0;
    return 0.0;
}
double &ret=memo[i][cnt];
if(ret!=-1.0)
    return ret;
return ret=dp(i+1,cnt+1)*p[i]+dp(i+1,cnt)*(1-p[i]);
}
void solve()
{


cin>>n;
  for(int i=0;i<=n;i++)
    for(int j=0;j<=n;j++)
    memo[i][j]=-1.0;
for(int i=0;i<n;i++)
    cin>>p[i];

cout<<setprecision(13)<<dp(0,0)<<endl;
}
int main()
{
    fast;
    solve();

    return 0;
}


Measured memory_bytes: 70912
#include<iostream>
using namespace std;
int bubbleSort(int A[],int N)
{
    int sum=0;
    bool flag=1;
    for(int i=0;flag;i++){
    flag=0;
    for(int j=N-1;j>=i+1;j--){
    if(A[j]<A[j-1]){
    swap(A[j],A[j-1]);
    flag=1;
    sum++;
    }
    }
    }
    return sum;
    }
int main(){
int A[100],N,sum;
cin>>N;
for(int i=0;i<N;i++)
    cin>>A[i];
sum=bubbleSort(A,N);
for(int i=0;i<N;i++)
{
    if(i) cout<<" ";
    cout<<A[i];
}
cout<<endl;
cout<<sum<<endl;
return 0;
}

Measured memory_bytes: 3088
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
using namespace std;
int main(){
    string x,y;
    cin >> x>>y;
    string ans ="NO";
    if(x.substr(0,1)==y.substr(2,1)&&x.substr(1,1)==y.substr(1,1)&&x.substr(2,1)==y.substr(0,1)){
        ans = "YES";
    } 
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <complex>
#include <math.h>
#include <set>
#include <vector>
#include <map>
#include <queue>
#include <stdio.h>
#include <stack>
#include <algorithm>
#include <list>
#include <ctime> 
#include <memory.h>
#include <assert.h>

using namespace std;

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const int INF = 1e9 + 1;
const ll LLINF = 1e18 + 1;

int main() {
    ll N;
    cin >> N;
    vector<ll> v(5);
    for(int i = 0; i < 5; i++) cin >> v[i];
    sort(v.begin(), v.end());

    cout << 4LL + ((N + v[0] - 1) / v[0]) << endl;
   
    return 0;
}

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


// --- DEBUG begin --- cut here ---
template <class... Args>
string dbgFormat(const char* fmt, Args... args) {
  size_t len = snprintf(nullptr, 0, fmt, args...);
  char buf[len + 1];
  snprintf(buf, len + 1, fmt, args...);
  return string(buf);
}

template <class Head>
void dbgLog(Head&& head) {
  cerr << head << endl;
}

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

#if DEBUG
  #define DLOG(...)        dbgLog(__VA_ARGS__)
  #define DFMT(...)        cerr << dbgFormat(__VA_ARGS__) << endl
  #define DCALL(func, ...) func(__VA_ARGS__)
#else
  #define DLOG(...)
  #define DFMT(...)
  #define DCALL(func, ...)
#endif

// operator<< definitions for some classes

template <typename T1, typename T2>
ostream& operator<< (ostream& os, const pair<T1,T2>& p) {
  os << "(" << p.first << ", " << p.second << ")";
  return os;
}

template <typename T>
ostream& operator<< (ostream& os, const vector<T>& v) {
  os << '[';
  for (auto it = v.begin(); it != v.end(); it++) {
    if (it != v.begin()) os << ", ";
    os << *it;
  }
  os << ']';

  return os;
}

template <typename T, typename T2, typename T3>
ostream& operator<< (ostream& os, const priority_queue<T, T2, T3>& orig) {
  priority_queue<T, T2, T3> pq(orig);
  bool first = true;
  os << '[';
  while (!pq.empty()) {
    T x = pq.top(); pq.pop();
    if (!first) os << ", ";
    os << x;
    first = false;
  }
  return os << ']';
}
// --- DEBUG end --- cut here ---

int main(int argc, char *argv[]) {
  // C-style stdio functions should not be used.
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout << setprecision(20);

  int N; cin >> N;
  vector<vector<int>> p(N);
  vector<vector<int>> q(N);
  for (int i = 0; i < N; i++) {
    int t; cin >> t;
    for (int j = 0; j < t; j++) {
      int x, y; cin >> x >> y; x--;
      p.at(i).push_back(x);
      q.at(i).push_back(y);
      DLOG("p,i,j,x", i, j, x);
      DLOG("q,i,j,x", i, j, y);
    }
  }

  auto countbit = [&](int x) -> int {
    int a = 0;
    for (int i = 0; i < N; i++) {
      if (x & (1 << i)) a++;
    }
    return a;
  };


  auto consis = [&](int s) -> bool {
    DLOG("checking", s);
    for (int j = 0; j < N; j++) {
      if (s & (1 << j)) {
	for (int k = 0; k < (int)p.at(j).size(); k++) {
	  DLOG("k", k);
	  int u = p.at(j).at(k);
	  int v = q.at(j).at(k);
	  if (((s >> u) & 1) != v) {
	    DLOG("j = ", j, "returning false", "u", u, "v", v, "k", k);
	    return false;
	  }
	  DLOG("ok");
	}
      }
    }
    return true;
  };
  
  int ans = 0;
  for (int s = 0; s < 1 << N; s++) {
    if (consis(s)) {
      DLOG("s", s, "consis");
      ans = max(ans, countbit(s));
    }else {
      DLOG("s", s, "inconsis");
    }
  }
  cout << ans << endl;
  return 0;
}



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

using namespace std;

using ll = long long;

ll solve(int n, vector<ll>& a, vector<ll>& sum, vector<ll>& sum2, ll x) {
    int idx = lower_bound(a.begin(), a.end(), x) - a.begin();
    if (idx == n) idx = n - 1;
    else if (idx > 0) {
        if (abs(a[idx - 1] - x) <= abs(a[idx] - x)) idx--;
    }

    if (idx == n - 1) return sum2[n - 1];
    int ok = idx, ng = n;
    while (ng - ok > 1) {
        int mid = (ok + ng) / 2;
        ll d = a[mid] - x;
        int idx2 = lower_bound(a.begin(), a.end(), x - d) - a.begin();
        int num = mid - idx2 + 1;
        if (num > n / 2 || n - num <= mid) ng = mid;
        else ok = mid;
    }
    ll res = sum[ok];

    int num = n - 1 - ok;
    int idx2 = ok - min(num, n / 2) + 1;
    if (idx2 > 0) res += sum2[idx2 - 1];
    return res;
}

ll solve2(int n, vector<ll>& a, ll x) {
    vector<pair<ll, int> > v;
    for (int i = 0; i < n; i++) {
        v.emplace_back(abs(a[i] - x), i);
    }
    sort(v.begin(), v.end());

    vector<int> used(n, false);
    ll res = 0;
    int ok = 0;
    for (int i = 0, j = n - 1; ;) {
        while (j >= 0) {
            if (!used[j]) break;
            j--;
        }
        if (j < 0) break;
        used[j] = true;
        res += a[j];

        while (i < n) {
            if (!used[v[i].second]) break;
            i++;
        }
        if (i == n) break;
        used[v[i].second] = true;
        ok = max(ok, v[i].second);
    }
    return res;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, q;
    cin >> n >> q;
    vector<ll> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }

    vector<ll> sum(n, 0);
    for (int i = n - 2; i >= 0; i--) {
        sum[i] = sum[i + 1] + a[i + 1];
    }

    vector<ll> sum2(n, 0);
    sum2[0] = a[0];
    sum2[1] = a[1];
    for (int i = 2; i < n; i++) {
        sum2[i] = sum2[i - 2] + a[i];
    }

    for (int i = 0; i < q; i++) {
        ll x;
        cin >> x;
        cout << solve(n, a, sum, sum2, x) << endl;
    }
    return 0;
}

Measured memory_bytes: 4096
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.HashMap;
import java.util.Map;
import java.util.StringTokenizer;

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

    static class Task {
        Map<Character, Integer> cnt = new HashMap<>();

        void solve(InputReader in, PrintWriter out) {
            for (char c : in.next().toCharArray()) {
                int v = cnt.containsKey(c) ? cnt.get(c) : 0;
                cnt.put(c, v + 1);
            }
            boolean yes = false;
            if (cnt.size() == 2) {
                yes = true;
                for (int v : cnt.values()) {
                    yes &= v == 2;
                }
            }
            out.println(yes ? "Yes" : "No");
        }
    }


    static class InputReader {
        BufferedReader reader;
        StringTokenizer tokenizer;

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

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

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

        int[] nextIntArray(int size) {
            int[] arr = new int[size];
            for (int i = 0; i < size; i++) {
                arr[i] = nextInt();
            }
            return arr;
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        long[] nextLongArray(int size) {
            long[] arr = new long[size];
            for (int i = 0; i < size; i++) {
                arr[i] = nextLong();
            }
            return arr;
        }
    }
}

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

void solve()
{
    long long t,n,m,i,j,k=0,kk=0,x,y,z=0,mn=0,mx,a[10],cnt=0;
    vector < ll > v;

    cin >> n >> m;

    for(i=0;i<n;i++)
    {
        cin >> x;
        v.push_back(x);
        mn+=x;
    }

    sort(v.begin(),v.end());
    reverse(v.begin(),v.end());

    for(i=0;i<n;i++)
    {
        double d1 = 1/(double)(4*m);
        double d2 = (double)v[i]/(double)mn;

        if(d2>=d1)
        {
            cnt++;
        }

    }

    if(cnt>=m)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }

}

int main()
{
     long long t,n,m,i,j,k=0,kk=0,x,y,z=0,mn,mx;

     //cin >> t;

     //while(t--)
     solve();

}


Measured memory_bytes: 256
#include<algorithm>
#include<climits>
#include<cmath>
#include<iomanip>
#include<iostream>
#include<list>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<utility>
#include<vector>

#define lint long long
#define REP(i, x, n) for(int i = x ; i < n ; i++)
#define rep(i, n) REP(i, 0, n)
#define repr(i, n) for(int i = n - 1 ; i >= 0 ; i--)
#define SORT(c) sort((c).begin(), (c).end())
#define SORT_INV(c) sort((c).begin(), (c).end(), greater<int>())
#define IINF (int)(1e9+10)
#define LLINF (lint)(1e18+10)

using namespace std;

int main(){
    lint x, y;
    cin >> x >> y;
    lint ans;
    if(x * y > 0){
        if(x <= y){
            ans = y - x;
        }else{
            ans = x - y + 2;
        }
    }else if(x * y < 0){
        ans = abs(abs(x) - abs(y)) + 1;
    }else{
        if(x <= y){
            ans = y - x;
        }else{
            ans = x - y + 1;
        }
    }
    cout << ans << endl;
    return 0;
}

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

typedef unsigned long long int ull;
typedef long long int ll;
typedef vector<ll> vi;

#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define nl cout<<'\n'
#define pb push_back
#define all(s) s.begin(),s.end()
#define bs binary_search

#define gcd(a,b) __gcd((a),(b))
#define lcm(a,b) (a)*(b)/(__gcd((a),(b)))

const int Mod=1e9+7;
#define sum(a,b) (((a)%Mod)+((b)%Mod))%Mod
#define sub(a,b) (((a)%Mod)-((b)%Mod))%Mod
#define mul(a,b) (((a)%Mod)*((b)%Mod))%Mod
#define digit(x) floor((log10(x))+1)


#define count1(x) __builtin_popcount(x)

#define dbg(x) cout << #x <<":"<<x<<endl;

bool isPowerOfTwo (int x)  
{  
    /* First x in the below expression is for the case when x is 0 */
    return x && (!(x&(x-1)));  
} 

ll pow(ll x, ll y, ll mod)
{
	int ans=1;
	while(y)
	{
		if(y&1)
			ans=(ans*x)%mod;
		y/=2;
		x=(x*x)%mod;
	}
	return ans;
}

int main()
{
	fast;
	ll n,k,cur,count,i,temp;
	cin >> n >> k;
	ll arr[n+1],vis[n+1];
	for(i=1;i<=n;i++)
	{
		cin >> arr[i];
		vis[i]=-1;
	}
	cur=1;
	vis[1]=0;
	count=0;
	while(true)
	{
		cur=arr[cur];
		//dbg(cur);
		count++;
		if(count==k)
			break;
		if(vis[cur]!=-1)
		{
			//count++;
			//cur=arr[cur];
			//dbg(count);
			temp=count-vis[cur];
			cur=arr[cur];
			break;
		}
		else
		{
			vis[cur]=count;
		}
		//dbg(cur);
	}
	//dbg(temp);
	//dbg(count);
	if(count==k)
	{
		cout << cur << endl;
		return 0;
	}
	//dbg(count);
	count++;
	k-=(count);
	//dbg(k);
	k%=temp;
	//dbg(k);
	//dbg(cur);
	while(k--)
	{
		cur=arr[cur];
	}
	//dbg(cur);
	//cur=arr[cur];
	cout << cur << endl;
}

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





int main() {
    int  n;
    cin >> n;
    if (n <= 111) {
        cout << 111 << endl;
   } else if (n <= 222) {
       cout << 222 << endl;
   } else if (n <= 333) {
       cout << 333 << endl;
   } else if (n <= 444) {
       cout << 444 << endl;
   } else if (n <= 555) {
       cout << 555 << endl;
   } else if (n <= 666) {
       cout << 666 << endl;
   } else if (n <= 777) {
       cout << 777<< endl;
   } else if (n <= 888) {
       cout << 888 << endl;
   } else if (n <= 999) {
       cout << 999 << endl;
   }
    return 0;
}

Measured memory_bytes: 256
open System
open System.Collections.Generic
open System.Linq
open System

// Following contents are my library. The Main processes are on the bottom of this code.

let puts = Console.WriteLine : 'a -> unit
let put = Console.Write : 'a -> unit
let read() = Console.ReadLine()
let reads () = Console.ReadLine().Split()
let read2 () = reads() |> (fun x -> x.[0], x.[1])
let read3 () = reads() |> (fun x -> x.[0], x.[1], x.[2])
let read4 () = reads() |> (fun x -> x.[0], x.[1], x.[2], x.[3])
let tmap2 f1 f2 (t1, t2) = (f1 t1, f2 t2)
let tmap3 f1 f2 f3 (t1, t2, t3) = (f1 t1, f2 t2, f3 t3)
let tmap4 f1 f2 f3 f4 (t1, t2, t3, t4) = (f1 t1, f2 t2, f3 t3, f4 t4)
let readAs f = read() |> f
let readAs2 f1 f2 = read2 () |> tmap2 f1 f2
let readAs3 f1 f2  f3 = read3 () |> tmap3 f1 f2 f3
let readAs4 f1 f2 f3 f4 = read4 () |> tmap4 f1 f2 f3 f4
let readInt () = readAs int64
let readInt2 () = readAs2 int64 int64
let readInt3 () = readAs3 int64 int64 int64
let readInt4 () = readAs4 int64 int64 int64 int64
let ensmallen l = l % 1000000007L
let manhattan x y = abs (fst x - fst y) + abs (snd x - snd y)
let sayYESNO b = if b then puts "YES" else puts "NO"
let sayYesNo b = if b then puts "Yes" else puts "No"
let generateSeq n f = seq { for _ in 1 .. n do yield f () }


let toIntArray (s:string) = s.ToCharArray() |> Array.map (fun c -> int c - int '0')



// The main contents of this submission are below this line.

let ( n, h, w) = readInt3()
generateSeq (int(n)) readInt2 |> Seq.filter (fun (a, b) -> a >= h && b >= w) |> Seq.length |> puts


Measured memory_bytes: 13524
#include<stdio.h>
#include<string.h>
long long xu(long long x,long long y)
{
    long long t,c;
    if(x>y) {t=x;x=y;y=t; }
    while(x!=0)
    {
        c=y%x; y=x; x=c;
    }
    return y;
}
int main()
{
    long long n,a[1000],i;
    while(~scanf("%lld",&n))
    {
     memset(a,0,sizeof(a));
     for(i=0;i<n;i++)
        scanf("%lld",&a[i]);
     for(i=0;i<n-1;i++)
        a[i+1]=a[i]/xu(a[i],a[i+1])*a[i+1];
     printf("%lld\n",a[n-1]);
    }
}


Measured memory_bytes: 128
import sys
input = sys.stdin.buffer.readline
from collections import deque

def main():
	N = int(input())
	edge = [[] for _ in range(N+1)]
	
	MOD = 10**9+7
	fac = [0]*(N+1)
	fac[0],fac[1] = 1,1
	invfac = [0]*(N+1)
	invfac[0],invfac[1] = 1,1

	for i in range(2,N+1):
		fac[i] = (fac[i-1]*i)%MOD

	invfac[-1] = pow(fac[-1],MOD-2,MOD)
	for i in range(N,0,-1):
		invfac[i-1] = (invfac[i]*i)%MOD
	
	for _ in range(N-1):
		a,b = map(int,input().split())
		edge[a].append(b)
		edge[b].append(a)

	proc = []
	parent = [0]*(N+1)
	q = deque([1])
	while q:
		now = q.pop()
		proc.append(now)
		for fol in edge[now]:
			if fol == parent[now]:
				continue
			parent[fol] = now
			q.append(fol)
	
	d_size = [0]*(N+1)
	d_dp = [1]*(N+1)

	for v in proc[::-1]:
		d_dp[v] *= fac[d_size[v]]
		d_dp[v] %= MOD
		p = parent[v]
		s = d_size[v]+1
		d_size[p] += s
		d_dp[p] *= d_dp[v]*invfac[s]
		d_dp[p] %= MOD
	
	u_size = [N-num-1 for num in d_size]
	u_dp = [1]*(N+1)
	
	for v in proc[1:]:
	    p = parent[v]
	    x = d_dp[p]
	    x *= u_dp[p]
	    x *= invfac[d_size[p]]
	    x *= fac[d_size[v]+1]
	    x *= pow(d_dp[v],MOD-2,MOD)
	    x %= MOD
	    x *= fac[u_size[v]-1]
	    x *= invfac[u_size[p]]
	    u_dp[v] = x%MOD
	
	u_size[1] = 0
	u_dp[1] = 1
	
	for i in range(1,N+1):
	    ret = d_dp[i]*u_dp[i]*fac[d_size[i]+u_size[i]]*invfac[d_size[i]]*invfac[u_size[i]]%MOD
	    print(ret)

if __name__ == "__main__":
	main()


Measured memory_bytes: 122672
#include <iostream>
#include <string>
#include <unordered_map>
#include <stdio.h>
#include <list>
#include <vector>
#include <algorithm>
#include <stack>
#include <climits>
#include <cmath>
#include <map>
#include <queue>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; ++i)
#define ALL(v) v.begin(), v.end()
typedef long long ll;

int gcd(int a,int b){return a%b==0 ? b : gcd(b,a%b);}

int main()
{
	int n,k;
	cin >> n >>k;
	vector<int> a(n);
	rep(i,n)cin >> a[i];
	//sort(ALL(a));
	int gg = a[0];

	rep(i,n)gg=gcd(gg,a[i]);
	//cout<<gg<<endl;

	rep(i,n)
	{
		if(a[i]>=k&&a[i]%gg==k%gg)
		{
			cout<<"POSSIBLE"<<endl;
			return 0;
		}
	}
	cout<<"IMPOSSIBLE"<<endl;
	return 0;
}

Measured memory_bytes: 640
a,v=map(int,input().split())
b,w=map(int,input().split())
t=int(input())

if a==b:
    print("YES")
else:
    if v>w:
        if abs(a-b)<=t*(v-w):
            print("YES")
        else:
            print("NO")
    else:
        print("NO")
        

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

using namespace std;

int D, N;
string S;
vector< string > p, pat;
set< string > used;
vector< int > graph[45][45];
int dp[45][45];
string now;
 
bool Levenshtein_Distance(int B, int E) {
  for(int i = B + 1; i <= E; i++) {
    int Dist = 1 << 30;
    for(int j = max(1, i - D); j <= min< int >(S.size(), i + D); j++) {
      dp[i][j] = min(min(dp[i - 1][j], dp[i][j - 1]) + 1, dp[i - 1][j - 1] + (now[i - 1] != S[j - 1]));
      Dist = min(Dist, dp[i][j]);
    }
    if(Dist > D) return(false);
  }
  return(true);
}
  
void rec(int idx)
{
  if(used.count(now)) return;
  used.insert(now);
  if(dp[now.size()][S.size()] <= D) {
    if(pat.size() > 5) pat.push_back("~");
    else pat.push_back(now);
  } 
  int nowSize = now.size();
  for(int i = p[0].size() - 1; i >= 0 && nowSize + p[0].size() - i <= S.size() + D; i--) {
    now += " ";
    for(int j = 0; j < graph[idx][i].size(); j++) {
      bool connect = true;
      for(int k = i; k < p[0].size(); k++) {
        now[nowSize + k - i] = p[graph[idx][i][j]][k];
        if(!Levenshtein_Distance(nowSize + k - i, nowSize + k - i + 1)) {
          connect = false;
          break;
        }
      }
      if(connect) rec(graph[idx][i][j]);
    }
  }
  now.resize(nowSize);
}
  
int main(){
    
  while(cin >> D >> N, D||N) {
    p.clear();
    used.clear();
    pat.clear();
 
    cin >> S;
    for(int i = 0; i < N; i++) {
      string pi;
      cin >> pi;
      p.push_back(pi);
    }
    sort(p.begin(), p.end());
    p.erase(unique(p.begin(), p.end()), p.end());
    for(int i = 0; i < 45; i++) {
      dp[i][0] = dp[0][i] = i;
    }
    for(int i = 1; i < 45; i++) {
      for(int j = 1; j < 45; j++) {
        if(abs(i - j) > D) dp[i][j] = 1 << 30;
      }
    }
    N = p.size();
 
    for(int i = 0; i < N; i++) {
      for(int j = 0; j < p[i].size(); j++) {
        graph[i][j].clear();
        for(int k = 0; k < N; k++) {
          if(p[i].substr(p[i].size() - j) == p[k].substr(0, j)) {
            graph[i][j].push_back(k);
          }
        }
      }
    }
     
    for(int i = 0; i < p.size(); i++) {
      now = p[i];
      if(!Levenshtein_Distance(0, p[0].size())) continue;
      rec(i);
    }
    cout << pat.size() << endl;
    if(pat.size() <= 5) {
      sort(pat.begin(), pat.end());
      for(vector< string >::iterator it = pat.begin(); it != pat.end(); it++) {
        cout << *it << endl;
      }
    }
  }
}

Measured memory_bytes: 22724
while True:
    x = int(input())
    if x == 0:
        break
    SCORE = len(str(x))
    ans = 0
    amari=x
    for i in range(SCORE+1):
        ans += amari//10**(SCORE-i)
        amari = amari%10**(SCORE-i)
    print(ans)


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

int main() {
  int K;
  string S;
  cin >> K >> S;
  if(S.size() <= K) cout << S << endl;
  else{
    for(int i = 0; i < K; i++){
      cout << S.at(i);
    }
    cout << "..." << endl;
  }
}


Measured memory_bytes: 3616
N,A,B,C = map(int, input().split())
l = [int(input()) for i in range(N) ]
def dfs(cur,a,b,c):
    if cur == N:
        if min(a, b, c) > 0:
                return abs(a-A) + abs(b-B) + abs(c-C) - 30
        else:
                return 10**9
    ret0 = dfs(cur+1, a, b, c)
    ret1 = dfs(cur+1, a + l[cur], b, c) + 10
    ret2 = dfs(cur+1, a, b + l[cur], c) + 10
    ret3 = dfs(cur+1, a, b, c + l[cur]) + 10
    return min(ret0,ret1,ret2,ret3)

print(dfs(0, 0, 0, 0))

Measured memory_bytes: 3064
#pragma GCC optimize("Ofast",3,"inline")
#include <bits/stdc++.h>
using namespace std;
long long n,ans1,f[100001],a[100001];
int main(){
   	cin>>n;
   	for(int i=1;i<=n;i++)
   		cin>>a[i];
    for(int i=n-1;i>=1;i--){
        if(a[i]>=a[i+1])f[i]=f[i+1]+1;
        ans1=max(ans1,f[i]); 
    }
    cout<<ans1;
}

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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;
vector< int64_t > divisor(int64_t n) {
    vector< int64_t > ret;
        for(int64_t i = 1; i * i <= n; i++) {
            if(n % i == 0) {
                ret.push_back(i);
                if(i * i != n) ret.push_back(n / i);
            }
        }
    sort(begin(ret), end(ret));
    return (ret);
}


int main() {
    //cout.precision(10);
    ll n, m;
    cin >> n >> m;
    vector<int64_t> v = divisor(m);
    ll ans = 1;
    for(int i = 1; i < v.size(); i++){
        ll div = v[i];
        if(div * n <= m){
            ans = div;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
using namespace std;
int main() {
	int n;
	while (cin >> n, n) {
		bool b[114][514] = {};
		for (int i = 1; i <= n; i++) {
			int k; cin >> k;
			for (int j = 0; j < k; j++) { int q; cin >> q; b[i][q] = true; }
		}
		vector<int>v;
		int k; cin >> k;
		for (int i = 0; i < k; i++) { int p; cin >> p; v.push_back(p); }
		int ans = -1;
		for (int i = 1; i <= n; i++) {
			for (int j = 0; j < v.size(); j++)
				if (!b[i][v[j]])goto cont;
			if (ans == -1)ans = i;
			else { cout << "-1\n"; goto end; }
			cont:;
		}
		cout << ans << endl;
	end:;
	}
}

Measured memory_bytes: 3212
#include <iostream>
#include <iomanip>
#include <vector>
#include <valarray>
#include <map>
#include <set>
#include <list>
#include <queue>
#include <stack>
#include <bitset>
#include <utility>
#include <numeric>
#include <algorithm>
#include <functional>
#include <complex>
#include <string>
#include <sstream>

#include <cstdio>
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <cmath>

using namespace std;

#define all(c) c.begin(),c.end()
#define repeat(i,n) for(int i=0;i<static_cast<int>(n);i++)
#define debug(x) #x << "=" << (x)
#define dump(x) cerr << debug(x) << " (L:" << __LINE__ << ")"<< endl

typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef vector<string> vs;

template<typename T>
ostream& operator<<(ostream& os, const vector<T>& vec){
    os << "[";
    for(int i = 0; i < vec.size(); i++){
        os << vec[i] << ",";
    }
    os << "]";
    return os;
}

template<typename T>
T input(){
    T t;
    cin >> t;
    return t;
}

template<typename T>
vector<T> input(const int N){
    vector<T> v(N);
    repeat(i,N) cin >> v[i];
    return v;
}

long long gcd(long long a, long long b){
    if(b == 0){
        return a;
    }
    return gcd(b, a % b);
}

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

long long mul(const long long& a, const long long& b, const long long& mod) {
    return ((a % mod) * (b % mod)) % mod;
}

long long power(const long long& x, const long long& y, const long long& mod) {
    if (y == 0) {
        return 1;
    } else if (y == 1) {
        return x % mod;
    } else {
        long long value = power(x, y / 2, mod);
        if (y % 2 == 0) {
            return mul(value, value, mod);
        } else {
            return mul(value, value, mod) * x % mod;
        }
    }
}

long long div(const long long& a, const long long& b, const long long& mod) {
    return mul(a, power(b, mod - 2, mod), mod);
}

map<long long, long long> factorials;
long long factorial(const long long& n, const long long& mod) {
    if (n == 0 || n == 1) {
        return 1;
    }
    if (factorials[n] != 0) {
        return factorials[n];
    }
    factorials[n] = n * factorial(n - 1, mod) % mod;
    return factorials[n] % mod;
}

long long combination(const long long& n, const long long& x, const long long& mod) {
    long long numerator = 1;
    long long denominator = 1;
    repeat(i, x) {
        numerator *= (n - i) % mod;
        numerator %= mod;
        denominator *= (i + 1) % mod;
        denominator %= mod;
    }
    return div(numerator, denominator, mod);
}

int main(){
    int N;
    int left, right;
    cin >> N;

    int total = 0;
    repeat (i, N) {
        cin >> left >> right;
        total += (right - left + 1);
    }
    cout << total << endl;
    return 0;
}


Measured memory_bytes: 384
#include "bits/stdc++.h"
using namespace std;

// GNU C Compiler
//template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }


/*
--------------------------------------------

	type

--------------------------------------------
*/
using LL = long long;
using ULL = unsigned long long;
//using pair<T1, T2> = p12;

/*
--------------------------------------------

	container

--------------------------------------------
*/
#define PB emplace_back
#define MP make_pair 
#define SZ(a) int((a).size())

/*
--------------------------------------------

	repetition

--------------------------------------------
*/
#define REP(n) for(int i=0; i<n; i++)
#define REPj(n) for(int j=0; j<n; j++)
#define REPinit(a,n) for(int i=a; i<n; i++)
#define REPinitj(a,n) for(int j=a; j<n; j++)

//algorithm
//#define SORT(c) sort((c).begin(),(c).end())

/*
--------------------------------------------

	constant

--------------------------------------------
*/
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

/*

	Optimizer

*/
//#pragma GCC optimize("Ofast")

int main(int argc, char const *argv[])
{
	int N;
	cin >> N;

	LL x;
	vector<LL> a(N+1,0);
	
	cin >> x;
	REP(N) cin >> a[i];

	ULL ans  = 0;
	REPinit(1,N+1) {
		if((a[i] + a[i-1]) > x) {
			ans += ((a[i] + a[i-1]) - x);
			a[i] -= ((a[i] + a[i-1]) - x);
		}
	}

	cout << ans << endl;

  return 0;
}


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


void init(){
    cin.tie(0);
    cin.sync_with_stdio(0);
}

#define ll long long
#define ld long double
#define ull unsigned long long
#define ull unsigned long long
#define mod 1000000007
#define pi (3.1415926)

#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))

#define scd(a)  scanf("%lld",&a)
#define scdd(a,b)	scanf("%lld%lld",&a,&b)
#define scddd(a,b,c)	scanf("%lld%lld%lld",&a,&b,&c)
#define ptab(a)	printf("%lld ",a)
#define pdn(a)	printf("%lld\n",a)
#define pddn(a,b)	printf("%lld %lld\n",a,b)
#define pdddn(a,b,c)	printf("%lld %lld %lld\n",a,b,c)

#define Filein(N) freopen("N.txt", "r", stdin);
#define Fileout(N) freopen("N.txt", "w", stdout);

#define forr(n) for(ll i=0;i<n;i++)
#define rev(n) for(ll i=n-1;i>=0;i--)
#define forp(x, y) for(ll i=x;i<y;i++)
#define loop( j, k, in) for (ll i=j ; i<k ; i+=in)

#define en "\n"
#define sp " "
#define eps 1.0E-14
#define l length()
#define preci(x) cout << fixed<<setprecision(x)
#define inf LONG_LONG_MAX
#define ninf LONG_LONG_MIN

ull fastpow(ull a,ull b)
{
  ull wynik=1;
  while (b)
  {
    if (b&1)wynik=(wynik*a)%mod;
    a=(a*a)%mod;
    b>>=1;
  }
  return wynik;
}

bool odd(int n)
    {
        int x = sqrt(n);
    for (int i=2 ; i<=x ; ++i)

    {
        if(n%i == 0)return false;
    }

    return true;
    }
ll fact(int n ){

long long fact =1;

for (int i =2 ;i<=n;++i)

{
    fact*=i;
}
return fact;
}

bool prim(long long a){

long long s = sqrt(a);

for (int i=2 ; i<= s ;++i){

    if (a % i == 0)return false;
}
return true;
}

ll sum (int n ){return ((n*(n+1)) / 2) ;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}

bool myfunction (string i,string j) /* this function to check who is grater in
sorting strings as numbers ////////
int n;
    cin>>n;
    vector <string> arr(n);
    for(int i=0;i<n;i++)
        cin>>arr[i];


    sort(arr.begin(),arr.end(),myfunction);

    for(int i=0;i<n;i++)1
        cout<<arr[i]<<endl;
*/
{
    int n=i.length();
    int m=j.length();
    if(n==m)
        return (i<j);

    return n<m;
}
long long solve (int a, int b)
{
    return min(a,min(b , (a+b) / 3));
}

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

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

    sort(a,a+n);

    for (int i=0 ; i<s;++i)ans+=a[i];

    cout << ans;
}




Measured memory_bytes: 3628
#include <iostream>
#include <climits>
#include <iomanip>
#include <sstream>
#include <cmath>
#include <algorithm>
#include <assert.h>
#include <vector>
#include <utility>
#include <string>
#include <bits/stdc++.h>
#include <fstream>
#include <chrono>
using namespace std;

typedef long long LL;

/*
        time complexty
auto start = chrono::steady_clock::now();
    ............

auto endd = chrono::steady_clock::now();
auto dif =   endd- start;
cout << chrono::duration<double, milli>(dif).count() <<"ms"<<endl;

*/




LL n , ans=1;
int main(){
    scanf("%lld",&n);
    map<int , int>mp;
    for (LL i = 1 ; i<=n ; i++){
        LL val = i;
        for (LL j = 2 ; j*j <= i ; j++ )
        {

            while(val%j==0)
            {
                mp[j]++;
                val/=j;
            }

        }

        if (val!=1)mp[val]++;
    }

for(auto i : mp)
{
         ans*=(i.second+1) %1000000007;
         ans%=1000000007;
}

cout <<ans ;
return 0 ;
}


Measured memory_bytes: 3708
import sys
readline = sys.stdin.readline
write = sys.stdout.write
flush = sys.stdout.flush

def query(i):
    write("%d\n" % i)
    flush()
    res = readline()
    if res == 'Vacant\n':
        exit(0)
    return ["Male\n", "Female\n"].index(res)

N = int(readline())

init = query(0)
left = 0; right = N
while 1:
    mid = (left + right) // 2
    res = query(mid)
    if res^init == mid%2:
        left = mid
    else:
        right = mid
print(left)


Measured memory_bytes: 3660
array1 = [int(input()) for i in range(6)]
array2 = array1[:5]
k = array1[5] 
 
for i in range(5):
  if (i < 4 and array2[4 - i] - array2[0] > k):
    print(':(')
    break
  if (i < 3 and array2[4 - i] - array2[1] > k):
    print(':(')
    break
  if (i < 2 and array2[4 - i] - array2[2] > k):
    print(':(')
    break
  if (i < 1 and array2[4 - i] - array2[3] > k):
    print(':(')
    break
  if (i == 4):
    print('Yay!')

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

int s[]={5,7,5,7,7};

int main(){
    int n;
    while(cin>>n&&n!=0){
        vector<int> w(n);
        string tmp;
        for(int i=0;i<n;i++){
            cin >> tmp;
            w[i] = tmp.size();
        }
        for(int i=0;i<n;i++){
            int x=0;
            int y=0;
            for(int j=i;j<n;j++){
                x += w[j];
                if(x==s[y]){
                    if(y==4){
                        cout << i+1 << endl;
                        goto lll;
                    }
                    x = 0;
                    y++;
                }else if(x>s[y]){
                    break;
                }
            }
        }
        lll:;
    }
    return 0;
}


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

int main() {
    int N, M;
    cin >> N >> M;
    vector<vector<int>> graph(N);
    for (int i = 0; i < M; ++i) {
        int A, B;
        cin >> A >> B;
        graph[A-1].push_back(B-1);
        graph[B-1].push_back(A-1);
    }
    for (auto& v : graph) {
        sort(v.begin(), v.end());
        auto it = unique(v.begin(), v.end());
        v.erase(it, v.end());
    }
    vector<bool> isChecked(N);
    vector<int> numConnected;
    vector<vector<int>> connectedGraph;

    for (int i = 0; i < N; ++i) {
        if (!isChecked[i]) {
            int num = 0;
            queue<int> Q;
            Q.push(i);
            isChecked[i] = true;
            vector<int> v;
            while (!Q.empty()) {
                auto q = Q.front();
                Q.pop();
                ++num;
                v.push_back(q);
                for (int x : graph[q]) {
                    if(!isChecked[x]) {
                        Q.push(x);
                        isChecked[x] = true;
                    }
                }
            }
            numConnected.push_back(num);
            connectedGraph.push_back(v);
        }
    }
    cout << *max_element(numConnected.cbegin(), numConnected.cend()) << endl;
    

}

Measured memory_bytes: 19660
#include<stdio.h>
#include<stdlib.h>

typedef struct node{
	int key;
	struct node *left;
	struct node *right;
}node;

void insert(node **p,int x){
	node *new=malloc(sizeof(node));
	new->key=x;
	new->left=NULL;
	new->right=NULL;
	
	while((*p)!=NULL){
		if((*p)->key > x)
			p=&((*p)->left);
		else
			p=&((*p)->right);
	}
	(*p)=new;
	
	return;
}

int find(node *p,int x){

	while(p!=NULL){
		if(p->key == x)return 1;
		
		if(p->key > x)
			p=p->left;
		else
			p=p->right;
	}
	
	return 0;
	
}

void inorder(node *p){
	
	if(p->left!=NULL)
		inorder(p->left);
	
	printf(" %d",p->key);
	
	if(p->right!=NULL)
		inorder(p->right);
	
	return;
}

void preorder(node *p){
	
	printf(" %d",p->key);
	
	if(p->left!=NULL)
		preorder(p->left);
	
	if(p->right!=NULL)
		preorder(p->right);
	
	return;
}

void print(node *root){
	inorder(root);
	printf("\n");
	
	preorder(root);
	printf("\n");
	
	return;
}

node * Delete(node *p,int x){
	
	if(p->key == x){
	
		if(p->left==NULL && p->right==NULL)/*葉*/
			return NULL;
		
		if(p->left==NULL || p->right==NULL){/*子1つ*/
			if(p->left!=NULL)
				return p->left;
			else
				return p->right;
		}
		
		node **q=&(p->right);
		while((*q)->left!=NULL)
			q=&((*q)->left);
		p->key=(*q)->key;
		(*q)=Delete((*q),(*q)->key);
		return p;
	
	}
	
	if(p->key > x)
		p->left=Delete(p->left,x);
	else
		p->right=Delete(p->right,x);
	
	return p;
	
}

int main(){
	int n,i,x;
	node *root=NULL;
	char com[10];
	
	scanf("%d",&n);
	
	for(i=0;i<n;i++){
		scanf("%s",com);
		
		switch(com[0]){
			case 'i':scanf("%d",&x);
					 insert(&root,x);
					 break;
			
			case 'f':scanf("%d",&x);
					 if(find(root,x))
					 	printf("yes\n");
					 else
					 	printf("no\n");
					 break;
					 
			case 'd':scanf("%d",&x);
					 root=Delete(root,x);
					 break;
					 
			case 'p':print(root);
					 break;
		}
	}
	
	return 0;
	
}


Measured memory_bytes: 14236
using System;
using System.Collections.Generic;
using System.Linq;

public class Program
{
    public static void Main(string[] args)
    {
        var ab = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToList();
        ab.Sort();
        for (int i = 0; i < ab[1]; i++)
        {
            Console.Write(ab[0]);
        }
    }
}

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

main(){
  int h1, h2, k1, k2, a, b, c, d;
  cin >> h1 >> h2 >> k1 >> k2;
  cin >> a >> b >> c >> d;
  int hiroshi = h1*a + h2*b + (h1/10)*c + (h2/20)*d;
  int kenjiro = k1*a + k2*b + (k1/10)*c + (k2/20)*d;

  if ( hiroshi > kenjiro ) cout << "hiroshi" << endl;
  else if ( hiroshi < kenjiro ) cout << "kenjiro" << endl;
  else cout << "even" << endl;
}



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

int s[10001];

int lsearch(int n,int key){

  s[n] = key;
  for(int i=0; i<n+1; i++){
    if(s[i]==key)return i;
  }
  return 0;
}

int main(){

  int n,q;
  int sum=0;
  int t;

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

  cin >> q;
  for(int i=0; i<q; i++){
    cin >> t;
    if(lsearch(n,t)!=n)sum++;
  }

  cout << sum << endl;

  return 0;
}

Measured memory_bytes: 1200
#include <bits/stdc++.h>
#define rp(i, n) for(int i = 0; i < n; i++)
#define rp2(i, a, n) for(int i = a; i < n; i++)

using namespace std;
using ll = long long;

int main(){
    int k, n;
    cin >> k >> n;
    vector<int> v(n);
    rp(i, n) cin >> v[i];
    v.push_back(v[0]+k);
    int l = 0;
    rp(i, n){
        l = max(l, v[i+1]-v[i]);
    }
    cout << k-l << endl;

    return 0;
}

Measured memory_bytes: 1792
leng=[]
diff=[]
for i in range(1,1000):
	h=i*(i+1)//2
	leng.append(h)
for i in range(0,len(leng)-1):
	diff.append(leng[i+1]-leng[i])
a,b=map(int,input().split())
d=abs(a-b)
#print(leng)
#print(diff)
try:
	pos=diff.index(d)
except:
	ans=1
#print(pos)
#print(leng[pos])
ans=leng[pos]-a
print(ans)

Measured memory_bytes: 3064