akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
///Welcome to Nasif's Code
#define bug printf("bug\n");
#define bug2(var) cout<<#var<<" "<<var<<endl;
#define co(q) cout<<q<<endl;
#define all(q) (q).begin(),(q).end()
typedef long long int ll;
typedef unsigned long long int ull;
const int MOD = (int)1e9+7;
const int MAX = 1e6;
#define pi acos(-1)
#define inf 1000000000000000LL
#define FastRead    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int arr[MAX];
int main()
{
    FastRead
    //freopen("output.txt", "w", stdout);
    ll ans=1,n;
    cin>>n;
    for(ll i=1;i<=n;i++){
        ans=(ans*i)%MOD;
    }
    cout<<ans<<endl;



    return 0;
}


Measured memory_bytes: 3592
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int MAXN = 500005;
ll a[MAXN],ans;
int main()
{
	int n;
	cin >> n;
	for(int i=1; i<=3*n; i++) cin >> a[i];
	sort(a+1,a+1+3*n);
	for(int i=3*n-1,j=0; j<n; j++,i-=2) ans += a[i];
	cout << ans << '\n';
	return 0;
}


Measured memory_bytes: 2560
/*#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>

#include <boost/rational.hpp>
*/
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
using ll = long long;
using ld = long double;
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
#define rep3(i, n) for (ll i = 1; i < (ll)(n+1); i++)
#define rep4(i, s, n) for (ll i = (s); i < (ll)(n+1); i++)
#define repr(i,n) for (ll i = (n-1); i>=0;i--)
#define repr3(i,n) for(ll i = (n);i>0;i--)
#define repr4(i,s,n) for(ll i = (n);i>=(s);i--)
#define stlen(s) ll s.size()-1
#define all(v) v.begin(), v.end()
#define cout(n) cout<<std::fixed<<std::setprecision(n)
using Graph = vector<vector<int>>;
using Graphw = vector<vector<pair<ll,ll>>>;
#define INF1  INT_MAX;
#define INF2  LLONG_MAX;
#define PI  3.14159265358979323846;
#define MOD 1000000007;
/*
namespace mp = boost::multiprecision;
// 任意長整数型
using Bint = mp::cpp_int;
// 仮数部長が32の浮動小数点数型
using Real32 = mp::number<mp::cpp_dec_float<32>>;
// 仮数部長が1024の浮動小数点数型
using Real1024 = mp::number<mp::cpp_dec_float<1024>>;
// 有理数型
using Rat = boost::rational<Bint>;
*/
const int mod = 1000000007;


int main() {
string S;
cin>>S;
int b=0,r=0;
rep(i,S.size()){
    if(S[i]=='1')b++;
    else r++;
}
cout<<2*min(b,r)<<endl;
return 0;
}

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

int main(){
  int N, M;
  cin >> N >> M;
  vector<int> K(M);
  vector<vector<int>> S(M, vector<int>(0));
  vector<int> P(M);
  int s;
  for(int i=0; i<M; i++){
    cin >> K.at(i);
    for(int j=0; j<K.at(i); j++){
      cin >> s;
      S.at(i).push_back(s-1);
    }
  }
  for(int i=0; i<M; i++){
    cin >> P.at(i);
  }
  int Ans=0;
  vector<int> swi(N);
  for(int i=0; i<(int)pow(2, N); i++){
    int u=i;
    for(int j=0; j<N; j++){
      swi.at(j)=u%2;
      u/=2;
    }
    int r=1;
    for(int j=0; j<M; j++){
      int w=0;
      for(int k=0; k<K.at(j); k++){
        w+=swi.at(S.at(j).at(k));
      }
      w%=2;
      if(w!=P.at(j)){
        r=0;
        break;
      }
    }
    if(r==1){
      Ans++;
    }
  }
  cout << Ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<vector>
#include<cmath>
#include<cstdio>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb(in,tmp) in.push_back(tmp)
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
using namespace std;
bool sc(string num,string in){
  bool han=true;
  rep(i,8){
    if(num[i]=='*')continue;
    if(num[i]!=in[i])han=false;
  }
  return han;
}

int main(){
  int n,m;
  while(cin>>n>>m,n||m){
    vector<string>num(n);
    vector<int>money(n);
    rep(i,n){
      cin>>num[i]>>money[i];
    }
    int sum=0;
    rep(i,m){
      string in;
      cin>>in;
      rep(j,n)
	if(sc(num[j],in))sum+=money[j];
    }
    cout<<sum<<endl;			 
  }

}

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

ll i,j,k,l;
vector<ll> dp(200001),cnt(10000);

int main(){
    int n,p;cin>>n>>p;
    string s;
    cin>>s;

    cnt.resize(p);//余りごとに分類

    //同じあまりの2数を選択することを考える

    for(i=0;i<200001;i++){dp[i]=0;}
    for(i=0;i<p;i++){cnt[i]=0;}
    
    cnt[0]++;//0を選択する場合もある　p=2019で、1817181712114なら12114と0を選んで引き算

    ll pow_ten=1,ans=0;
    if(!(p==2 || p==5)){//10と互いに素な素数の場合
        for(i=s.size()-1;i>=0;i--){
            //下から順にpで割ったあまりを考える→同じあまりの2数をこの中から選んで、差がpで割れれば題意を満たす
            dp[i]=(dp[i+1]+(s[i]-'0')*pow_ten)%p;
            pow_ten*=10;
            pow_ten%=p;
            cnt[dp[i]]++;
        }

        for(i=0;i<p;i++){
        ans+=cnt[i]*(cnt[i]-1)/2;
        }
    }else{
        for(i=0;i<s.size();i++){
            if((int)(s[i]-'0')%p==0){
                ans+=(i+1);
            }
        }
    }   

    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 2304
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i,n) for(int i=0;i<n;++i)
#define MOD (int) 1e9+7
#define INF (int) 2e9

int main(){
    int n;
    cin >> n;
    vector<int> v(n);
    rep(i, n){
        cin >> v[i];
    }
    sort(v.begin(), v.end());

    double r = pow((double)1/2, 1);
    double sum= 0;
    for (int i = 0; i < n; i++)
    {
        if(i==0){
            r = pow((double)1/2, n-1);
        }else{
            r = pow((double)1/2, n-i);
        }
        sum += v[i] * r;
    }
    
    cout << sum << endl;
    // printf("%d\n", N);
    return 0;
}

Measured memory_bytes: 384
#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;

  vector<int> p;
  rep(i, N) {
    int t;
    cin >> t;
    p.push_back(t);
  }

  sort(p.begin(), p.end());

  int ans = 0;
  rep(i, K) ans += p[i];

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3604
#include<bits/stdc++.h>
using namespace std;
#define int  long long
#define tc(t)  int t; cin>>t; while(t--)
#define f(n)    for(int i=0;i<n;i++)
#define endl   "\n"







int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
     int n,m;
     cin>>n>>m;
     vector<pair<int,string>>v(m);
     vector<pair<int,int>>dp(n,{0,0});
     for(int i=0;i<m;i++){
         int q;
         string verdict;
         cin>>q>>verdict;
         v[i]={q,verdict};
     }

     int correct=0,penality=0;
     for(int i=0;i<m;i++)
     {
       int qn=v[i].first;
       string verdict=v[i].second;
       if(verdict=="WA")
       {
           if(dp[qn-1].second==0)
           {dp[qn-1].first++;}

       } else{
           if(dp[qn-1].second==0) {
               dp[qn - 1].second = 1;
               correct++;
               penality+=dp[qn-1].first;
           }
       }


     }
     cout<<correct<<" "<<penality<<endl;










}

Measured memory_bytes: 8624
#include <bits/stdc++.h>
// statics
using namespace std;
using int64 = int_fast64_t;
using PAIR = pair<int, int>;
constexpr int INF = 1 << 30;
constexpr int64 LINF = 1LL << 60;
constexpr int MOD = 1e9 + 7;
constexpr int MAX_N = 1e5 + 1;

// init/input
#define int int64
#define INIT ios::sync_with_stdio(false);cin.tie(0);
#define VAR(type, ...) type __VA_ARGS__;MACRO_VAR_Scan(__VA_ARGS__);
template<typename T> void MACRO_VAR_Scan(T &t) {cin>>t;}
template<typename First, typename...Rest> void MACRO_VAR_Scan(First &first, Rest&...rest) {cin>>first;MACRO_VAR_Scan(rest...);}
#define VEC(type, c, n) vector<type> c(n);for(auto &&i:c)cin>>i;

// out
#define OUT(dist) cout<<(dist);
#define FOUT(n, dist) cout<<fixed<<setprecision(n)<<(dist);
#define SP cout<<" ";
#define BR cout<<"\n";
#define debug(x) cerr<<#x<<":"<< (x);BR;

// utility
#define ALL(a) (a).begin(), (a).end()
#define EACH(i, a) for(auto &&i:(a))
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define RFOR(i, a, b) for(int i=(b)-1;i>=0;--i)
#define REP(i, n) for(int i=0;i<(n);++i)
#define RREP(i, n) for(int i=(n)-1;i>=0;--i)

signed main() {
  INIT;
	VEC(int, a, 3);
	sort(ALL(a));
	reverse(ALL(a));
	int ans = a[0] * 10 + a[1] + a[2];
	OUT(ans)BR;
  
  return 0;
}


Measured memory_bytes: 256
N, M = map(int, input().split())
l = [-1, -1, -1]
for i in range(N+1):
  for j in range(N-i+1):
    if 1000 * i + 5000 * j + 10000 * (N-i-j) == M:
      l = [i, j, N-i-j]
      break
print(l[2], l[1], l[0])


Measured memory_bytes: 2940
#include<bits/stdc++.h>
#define INF 9223372036854775807LL
#define inf 1000000007
#define SYOU(x) setprecision(x+1)
#define abs(x,y) (max(x,y)-min(x,y))
#define lol long long
#define mp make_pair
#define fi first
#define se second
using namespace std;
lol a,b,x,y;
lol i[101];
signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    lol c,d=0,e=0,f=0,g=1,h=0;
    cin >>a;
    for(int n=1;n<=a;n++){
	cin >>b;
	if(b!=n) d++;
    }
    if(d==2||d==0) cout <<"YES\n";
    else cout <<"NO\n";
    return (0);
}


Measured memory_bytes: 256
//http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0522

#include <iostream>
#include <string>
using namespace std;

int main(){
  int i;
 
  while (1){
    char word[10000];
    int count= 0;
    int JOI = 0;
    int IOI = 0;

    cin >> word ;

    if (cin.eof()) break;

    for (i=0; word[i] != '\0'; i++){
      count++;
    }

    for (i=0; i < count - 2; i++){
      if (word[i] == 'J' && word[i+1] == 'O' && word[i+2] == 'I'){
	JOI++;
      }
      else if (word[i] == 'I' && word[i+1] == 'O' && word[i+2] == 'I'){
	IOI++;
      }
    }

    cout << JOI << "\n" << IOI << "\n";
  }
  return 0;
}

    
      

    
      
  

Measured memory_bytes: 1148
#include <bits/stdc++.h>
#define ss second
#define ff first
#define all(x) x.begin(), x.end()

using namespace std;
using ll = long long;
using pii = pair<ll, ll>;

const ll oo = 1e18 + 7;
const ll mod = 1e9 + 7, maxn = 2e5 + 10;  
const long double PI = acos(-1);
int cnt = 1, ps[maxn], sz[maxn];

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

void uni(int a, int b){
    a = find(a);
    b = find(b);

    if (a == b) return;

    ps[a] = b;
    sz[b] += sz[a];
    cnt = max(cnt, sz[b]);
}

void init(){
    iota(ps, ps+maxn, 0);
    for (int i=0; i<maxn; i++) sz[i] = 1;
}

int main (){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n,m;
    cin >> n >> m;
    init();

    for (int i=0; i<m; i++){
        int a, b;
        cin >> a >> b;
        uni(--a, --b);
    }

    cout << cnt << endl;
    return 0;   
}

Measured memory_bytes: 5168
#include <bits/stdc++.h>
#include <math.h>
#define _GLIBCXX_DEBUG
using namespace std;
int main() {
  
  int N,K;cin>>N>>K;
  vector<int> vec(N);
  for(int i=0;i<N;i++){
    cin>>vec[i];
  }
  
  int ans=0;
  for(int i=0;i<N;i++){
    if(vec[i]>=K){
      ans++;
    }
    else{
      ans=ans;
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 3676
import sys
sys.setrecursionlimit(300000)

def I(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def MI0(): return map(lambda s: int(s) - 1, sys.stdin.readline().split())
def LMI(): return list(map(int, sys.stdin.readline().split()))
def LMI0(): return list(map(lambda s: int(s) - 1, sys.stdin.readline().split()))
MOD = 10 ** 9 + 7
INF = float('inf')


N = I()
A = LMI()
ans = 0
for i, a in enumerate(A):
    if i % 2 == 0 and a % 2 != 0:
        ans += 1
print(ans)

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

int main(){
  int n;
  long long int k;
  cin >> n >> k;
  long long int ans=0;
  int a[n]={};
  for(int i=0; i<n; i++){
    cin >> a[i];
  }
  int l=0, m=0;
  for(int i=0; i<n-1; i++){
    for(int j=i+1; j<n; j++){
      if(a[i]>a[j]) l++;
      if(a[i]<a[j]) m++;
    }
  }
  long long int k_sum_1 = ((k%1000000007)*((k+1)%1000000007)/2)%1000000007;
  long long int k_sum_2 = ((k%1000000007)*((k-1)%1000000007)/2)%1000000007;
  ans = ((k_sum_1*l)%1000000007+(k_sum_2*m)%1000000007)%1000000007;
  cout << ans << endl;
  return 0;
}

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

int main() {
  int n;
  cin >> n;

  int ans = 0;
  int search = 1;
  while ( n-- > 0 ) {
    int a;
    cin >> a;
    if ( a == search ) {
      search++;
    } else {
      ans++;
    }
  }
  ans = ( search == 1 ) ? -1 : ans;

  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3576
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <algorithm>
#include <functional>
#include <map>

using namespace std;
using ll = long long;
using pll = pair<ll,ll>;

#define reps(i,s,n) for(int (i) = (s) ;(i) < (n); (i)++)
#define rep(i,n) reps(i,0,n)

int main(){
    int h,w;
    cin >> h >> w;

    map<char,int> mp;
    string str;
    rep(i,h){
        cin >> str;
        rep(j,str.length()){
            mp[ str[j] ]++;
        }
    }
    int cnt_2=0,cnt_odd=0,cnt_n4=0;
    for(auto e: mp){
        if(e.second % 4 == 2 && e.second > 2) { 
            cnt_n4++;
        }
        if(e.second == 2){
            cnt_2++;
        }else if(e.second % 2 == 1){
            cnt_odd++;
        }
    }
    


bool f = false;
    if(h % 2 == 0 && w % 2 == 0){
        if(cnt_2 == 0 && cnt_odd == 0 && cnt_n4 == 0){
            f = true;
        }
    }else if(h % 2 == 0 && w % 2 == 1){
        if(cnt_odd == 0 && (h)/2 >= cnt_2+cnt_n4){
            f = true;
        }
    }else if(h % 2 == 1 && w % 2 == 0){
        if(cnt_odd == 0 && (w)/2 >= cnt_2+cnt_n4){
            f = true;
        }
    }else if(h % 2 == 1&& w % 2 == 1){
        if(cnt_odd == 1 && ((h-1)+(w-1))/2 >= cnt_2 +cnt_n4)
        {
            f = true;
        }
    }
    if(f)cout << "Yes" << endl;
    else cout << "No" << endl;
    
    return 0;
}

Measured memory_bytes: 256
import java.util.ArrayDeque;
import java.util.Deque;
import java.util.Scanner;

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

			int H = scan.nextInt();
			int W = scan.nextInt();
			int N = scan.nextInt();

			int[] a = new int[N];
			GM[][] map = new GM[H][W];
			for (int i = 0; i < H; i++) {
				for (int j = 0; j < W; j++) {
					map[i][j] = new GM(i , j);

				}
			}
			for (int i = 0; i < N; i++) {
				a[i] = scan.nextInt();
			}
			
			int mode = 0;
			int Y = 0;
			int X = 0;
			
			map[Y][X].num = 1;
			
			int[] dy = { 1, 0, -1, 0 };
			int[] dx = { 0, 1, 0, -1 };
			int allcount = 1;
			
			Deque<GM>que = new ArrayDeque<GM>();
			Deque<GM>st = new ArrayDeque<GM>();
			que.addFirst(map[Y][X]);
			st.addFirst(map[Y][X]);
			map[Y][X].se = true;

			
				
				while(!que.isEmpty()) {
					if(allcount==H*W)break;
					GM p = que.removeLast();
					int y = p.y+dy[mode];
					int x = p.x+dx[mode];
					
					if(0<=y&&y<H&&0<=x&&x<W) {
						if(map[y][x].se==false) {
							que.addFirst(map[y][x]);
							st.addFirst(map[y][x]);
							map[y][x].se = true;
							allcount++;
							
							//System.out.println(y+" "+x+"  "+allcount);
							
							
							
							
	
						}else {
							que.addLast(p);
							mode = (mode+1)%4;
							//System.out.println(y+" "+x+" 変更");

						}
					}else {
						que.addLast(p);
						mode = (mode+1)%4;
						//System.out.println(y+" "+x+"　変更 ");

						
						}
					}
				
				//System.out.println(st.size());
				
				
				for(int i = 0;i<N;i++) {
					for(int j = 0;j<a[i];j++) {
						GM p = st.removeLast();
						p.num=i+1;
					}
				}
				
				
				
				
				
			
				
				
				
				/*
				int sy = 0;
				int sx = 0;

				outside: for (int j = 0; j < H; j++) {
					for (int z = 0; z < W; z++) {
						if (map[j][z].se == false) {
							sy = j;
							sx = z;
							break outside;
						}
					}
				}

				//System.out.println(sy + " " + sx);

				int irocount = a[i];

				Deque<GM> que = new ArrayDeque<GM>();
				que.addFirst(map[sy][sx]);
				map[sy][sx].se = true;
				map[sy][sx].num = i + 1;
				irocount--;
				if (irocount == 0)
					continue;

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

				outside: while (!que.isEmpty()) {
					GM p = que.removeLast();
					for (int j = 0; j < 4; j++) {
						int Y = p.y + dy[j];
						int X = p.x + dx[j];
						if (0 <= Y && Y < H && 0 <= X && X < W) {
							if (map[Y][X].se == false) {
								que.addFirst(map[Y][X]);
								//System.out.println("追加 " + Y + " " + X);
								map[Y][X].se = true;
								map[Y][X].num = i + 1;
								irocount--;
								if (irocount == 0)
									break outside;
							}
						}

					}

				}*/
		

			

			for (int i = 0; i < H; i++) {
				for (int j = 0; j < W; j++) {
					System.out.print(map[i][j].num);
					System.out.print(" ");
				}
				System.out.println();
			}

		}

	}

	static class GM {
		int y;
		int x;
		boolean se;
		int num=0;

		GM(int Y, int X) {
			y = Y;
			x = X;
		}

	}

}


Measured memory_bytes: 34864
N = int(input())

X = N / 1.08

x1 = int(X)
x2 = int(X + 0.999999999)

if int(x1 * 1.08) == N:
    print(x1)
elif int(x2 * 1.08) == N:
    print(x2)
else:
    print(':(')

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,(n)-1,0)
#define all(v) v.begin(), v.end()
#define endk '\n'
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;
const ld eps = 1e-10;
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b){if(a>b) a=b;}
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b){if(a<b) a=b;}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n; cin >> n;
  vector<ll> A(n), sum(n+1);
  rep(i, n) {
    cin >> A[i];
    sum[i+1] = sum[i] + A[i];
  }
  ll ans = longinf;
  {
    ll tmp = 0;
    ll cnt = 0;
    rep(i, n) {
      if(i%2==0) {
        if(sum[i+1]+tmp<=0) {
          cnt += 1-(sum[i+1]+tmp);
          tmp += 1-(sum[i+1]+tmp);
        }
      } else {
        if(sum[i+1]+tmp>=0) {
          cnt += (sum[i+1]+tmp)+1;
          tmp -= (sum[i+1]+tmp)+1;
        }
      }
    }
    chmin(ans, cnt);
  }
  {
    ll tmp = 0;
    ll cnt = 0;
    rep(i, n) {
      if(i%2==0) {
        if(sum[i+1]+tmp>=0) {
          cnt += (sum[i+1]+tmp)+1;
          tmp -= (sum[i+1]+tmp)+1;
        }
      } else {
        if(sum[i+1]+tmp<=0) {
          cnt += 1-(sum[i+1]+tmp);
          tmp += 1-(sum[i+1]+tmp);
        }
      }
    }
    chmin(ans, cnt);
  }
  cout << ans << endk;
  return 0;
}


Measured memory_bytes: 4776
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#define int long long
using namespace std;

int x, y;

signed main() {
	cin >> x >> y;
	
	int ans = 0;
	int a = x;
	while (a <= y) { ans++; a *= 2; }
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#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;

int main() {
    //cout.precision(10);
    int n;
    cin >> n;
    vector<int> a(n);
    for(int i = 0; i < n; i++){
        cin >> a[i];
    }
    sort(a.begin(), a.end());
    if(n == 2){
        if(a[1] == 1){
            cout << "Possible" << endl;
            return 0;
        }
        cout << "Impossible" << endl;
        return 0;
    }
    int distance = a.back() + 1;
    for(int i = 0; i < a.size(); i++){
        if(distance / 2 > a[i]){
            //cout << "hoge" << endl;
            cout << "Impossible" << endl;
            return 0;
        }
    }
    if((distance % 2) == 1){
        if(count(a.begin(), a.end(), distance / 2) != 1){
            //cout << "c" << endl;
            cout << "Impossible" << endl;
            return 0;
        }
    }
    if((distance % 2) == 0){
        if(count(a.begin(), a.end(), distance / 2) != 2){
            cout << "Impossible" << endl;
            return 0;
        }
    }
    for(int i = (distance - 1) / 2 + 1; i <= distance - 1; i++){
        if(count(a.begin(), a.end(), i) <= 1){
            //cout << "d" << endl;
            cout << "Impossible" << endl;
            return 0;
        }
    }
    cout << "Possible" << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main()
{
    string str[3];
    rep(i, 3)
      cin >> str[i];
    rep(i, 3) 
      cout<< str[i][i];
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int ara[1000006];
bool mark[1000006], vis[1000006], prime[1000006];
int main()
{
    int n;
    scanf("%d", &n);
    for(int i=0; i<n; i++)
    scanf("%d", &ara[i]), vis[ ara[i] ]= 1;
    sort(ara, ara+n);
    int g= ara[0];
    for(int i=1; i<n; i++)
    g= __gcd(g, ara[i]);
    if(g!=1)puts("not coprime");
    else
    {
        bool f= 1;
        for(int i=1; i<n && f; i++)
        if(ara[i]!=1)f&= (ara[i]!=ara[i-1]);
        if(f)
        {
            for(int i=2; i<=1000000 && f; i++)
            if(!prime[i])
            {
                for(int j=i; j<=1000000 && f; j+= i)
                {
                    if(j!=i)prime[j]= 1;
                    if(vis[j])
                    {
                        if(mark[i])f= 0;
                        else mark[i]= 1;
                    }
                }
            }
        }
        if(f)puts("pairwise coprime");
        else puts("setwise coprime");
    }
    return 0;
}


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

vector<int> par;


int find(int n){
	if(par[n]<0)return n;
	return par[n]=find(par[n]);
}

void uni(int a,int b){
	par[a]+=par[b];
	par[b]=a;
}
 
int main(){
	//freopen("input.in","r",stdin);
	//freopen("output.in","w",stdout);
	ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int i,j,k,n,m;
    cin>>n>>m;
    par=vector<int>(n+1,-1);
    int x,y;
    while(m--){
    	cin>>x>>y;
    	x=find(x);
    	y=find(y);
    	if(x!=y)uni(x,y);
    }
    cout<<-*min_element(par.begin(), par.end());


 
	
	
	
 
 
 
 
 
 
 
	return 0;
}

Measured memory_bytes: 3972
/* ---------- STL Libraries ---------- */
// IO library
#include <cstdio>
#include <fstream>
#include <iomanip>
#include <ios>
#include <iostream>

// algorithm library
#include <algorithm>
#include <cmath>
#include <numeric>
#include <random>

// container library
#include <array>
#include <bitset>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <vector>

/* ---------- Namespace ---------- */
using namespace std;

/* ---------- Type Abbreviation ---------- */
using ll = long long;

/* ---------- Constants  */
const ll MOD = 1e9 + 7;
// const int INF = 1 << 25;
// const ll INF = 1LL << 50;
// const double PI = acos(-1);
// const double EPS = 1e-10;
// mt19937 mert(LL(time(0)));

/* ---------- Short Functions ---------- */
template <typename T>
T gcd(T a, T b) {
    if (a > b) return gcd(b, a);
    return a == 0 ? b : gcd(b % a, a);
}

template <typename T, typename U>
T mypow(T b, U n) {
    if (n == 0) return 1;
    if (n == 1) return b /* % MOD */;
    if (n % 2 == 0) {
        return mypow(b * b /* % MOD */, n / 2);
    } else {
        return mypow(b, n - 1) * b /* % MOD */;
    }
}

/* v-v-v-v-v-v-v-v-v Main Part v-v-v-v-v-v-v-v-v */

bool isPrime(ll num) {
    for (int i = 2; i <= sqrt(num); i++) {
        if (num % i == 0) return false;
    }

    return true;
}

int main() {
    ll size = (ll) pow(10, 5) + 1;
    int sum[size];
    fill(sum, sum + size, 0);

    for (ll i = 3; i < size; i += 2) {
        if (isPrime(i) && isPrime((i + 1) / 2)) sum[i]++;
    }

    for (int i = 1; i < size; i++) {
        sum[i] += sum[i-1];
    }

    ll Q;
    cin >> Q;

    for (ll q = 0; q < Q; q++) {
        ll l, r;
        cin >> l >> r;
        cout << sum[r] - sum[l-1] << endl;
    }

    return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
    #include<ext/pb_ds/assoc_container.hpp>
    #include<ext/pb_ds/tree_policy.hpp>
    using namespace __gnu_pbds;
    using namespace std;
    template <typename T>
    using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
    # define ll long long
    # define int long long  //comment it out when MLE
    //# define endl "\n"
    #define gok ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    //# define m 163577857
    # define mo 998244353
    # define pi acos(-1)
    # define fi first
//    # define se second
    #define REP(i,n) for (int i = 1; i <= n; i++)
    const ll mod = 1000000007;
    //const int K = 2;
    //typedef vector<vector<int> > matrix;
/*
    int add(int a, int b,int mod) {
        a%=mod;
        b%=mod;
        a += b;
        if (a >= mod) a -= mod;
        if(a<0)
        {
            a += mod;
            a %= mod;
        }
        return a;
    }

    int mul(ll a, int b,int mod) {
        a%=mod;
        b%=mod;
        a *= b;
        a += mod;
        return a % mod;
    }
    int po(int a,int b,int mod)
    {
        if(b==0)
            return 1;
        if(b%2==0)
            return po(mul(a,a,mod),b/2,mod);
        return mul(a,po(mul(a,a,mod),(b-1)/2,mod),mod);
    }


    ll fact[1000003];
    ll inv[1000003];

    void fact0()
    {
        int i,j;
        fact[0]=1;
        for(i=1;i<=600000;i++)
        {
            fact[i]=i*fact[i-1]%mod;
        }
        inv[0]=1;
        inv[1]=1;
        ll p=mod;
        for (i=2; i<=600000; i++)
            inv[i] = (p - (p/i) * inv[p%i] % p) % p;

        for(i=2;i<=600000;i++)
        {
            inv[i]*=inv[i-1];
            inv[i]%=mod;
        }
    }
    int help(int a,int b)
    {
       // cout<<a<<" "<<b<<endl;
        int an = fact[a];
        //cout<<an<<endl;
        an *= inv[b];
        an %= mod;
        an *= inv[a-b];
        an %= mod;
        return an;
    }

    void random()
    {
      srand(time(0));
	for (int i = 0; i < n; i ++)
		perm[i] = i + 1;
	random_shuffle(perm, perm + n);
    }

*/



signed main(){
    gok
 int a,va,b,vb,t;
 cin>>a>>va>>b>>vb>>t;

 if(a==b)
    cout<<"YES";
 else if(va<=vb)
 {
     cout<<"NO";
 }
 else
 {
    int dis = abs(a-b);
    int sp = va-vb;
    int req = dis/sp;
    if(dis%sp)
        req++;
    if(req<=t)
        cout<<"YES";
    else
        cout<<"NO";
 }






}






Measured memory_bytes: 3640
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
using namespace std;
#define REP(i, limit) for(int i=0; i< limit; ++i)
#define LINT long long

struct four{
  int xy[4];
};

int main(){
  int H, W;
  cin >> H >> W;
  int a[H][W];
  vector<four> ans;
  REP(i, H){
    REP(j, W){
      cin >> a[i][j];
    }
  }
  four work;
  int sousa=0;

  if(H==1){
    REP(j, W-1){
      if(a[0][j]%2){
        ++sousa;
        work.xy[0]=1;
        work.xy[1]=j+1;
        work.xy[2]=1;
        work.xy[3]=j+2;
        ans.push_back(work);
        --a[0][j];
        ++a[0][j+1];
      }
    }
    goto end;
  }

  if(W==1){
    REP(i, H){
      if(a[i][0]%2){
        ++sousa;
        work.xy[0]=i+1;
        work.xy[1]=1;
        work.xy[2]=i+2;
        work.xy[3]=1;
        ans.push_back(work);
        --a[i][0];
        ++a[i+1][0];
      }
    }
    goto end;
  }

  REP(i, H){
    REP(j, W-1){
      if(a[i][j]%2){
        ++sousa;
        work.xy[0]=i+1;
        work.xy[1]=j+1;
        work.xy[2]=i+1;
        work.xy[3]=j+2;
        ans.push_back(work);
        --a[i][j];
        ++a[i][j+1];
      }
    }
  }
  REP(i, H-1){
    int j = W-1;
      if(a[i][j]%2){
        ++sousa;
        work.xy[0]=i+1;
        work.xy[1]=j+1;
        work.xy[2]=i+2;
        work.xy[3]=j+1;
        ans.push_back(work);
        --a[i][j];
        ++a[i+1][j];
      }
  }

  end:
  cout << sousa << endl;
  REP(i, ans.size()){
    REP(j, 3){
      cout << ans[i].xy[j] << " ";
    }
    cout << ans[i].xy[3];
    cout << endl;
  }



  return 0;
}


Measured memory_bytes: 5104
/* Akshat Sharma @akshat98 */
#include <iostream>
#include <bits/stdc++.h>
#define IOS  ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define mp   make_pair
#define pb   push_back
#define F    first
#define S    second
#define ll   long long
#define MOD  1000000007
#define MAX  1000000001
#define vi 	 vector<int>
#define vl   vector<ll>
#define vpi  vector<pair<int,int> >
#define vpl  vector<pair<ll,ll> >
#define rep(i,a,b) for(i=a;i<b;i++)
#define reqp(i,a,b) for(i=a;i<=b;i++)
#define ren for(i=0;i<n;i++)
#define ALL(a)  (a).begin(),(a).end()
using namespace std;
typedef pair<int,int>pii;
typedef pair<ll,ll>pll;


int main()
{
	#ifndef ONLINE_JUDGE
	// freopen("input_file.txt", "r", stdin);
	//freopen("output_file.txt", "w", stdout);
	#endif
	int i,j,k,l,n,test_case,m,r,a,b;
	test_case=1;
	//cin>>test_case;
	while(test_case--){
		cin>>a>>b;
		if(a<6){
			cout<<0;
		}else if(a<13){
			cout<<b/2;
		}else cout<<b;


	}
	
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define SZ(i) int(i.size())
#ifdef tmd
#define IOS()
#define debug(...) fprintf(stderr,"%s - %d (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);_do(__VA_ARGS__);
template<typename T> void _do(T &&x){cerr<<x<<endl;}
template<typename T, typename ...S> void _do(T &&x, S &&...y){cerr<<x<<", ";_do(y...);}
#else
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0);
#define endl '\n'
#define debug(...)
#endif

const int MAXN = 1000006;
const ll MOD = 1000000007;

ll n, a[MAXN];
/*********************GoodLuck***********************/
int main () {
    IOS();

    cin >> n;

    REP (i, n) {
        cin >> a[i];
    }
    sort(a, a+n);

    ll ans = 0;

    vector<ll> gp = {a[n-1]};
    for (int i=n-2; i>=0; i--) {
        ll stp = (gp.back() - a[i]) / (n + 1);
        debug(stp, gp.back(), a[i]);
        for (auto &el : gp) {
            el -= (n - SZ(gp) + 1) * stp;
        }
        ans += SZ(gp) * stp;
        for (int j=0; j<=i; j++) {
            a[j] += stp * SZ(gp);
        }
        gp.emplace_back(a[i]);
    }

    while (true) {
        sort(gp.begin(), gp.end());
        if (gp[n-1] < n) {
            break;
        } else if (gp[n-1] - gp[0] < n) {
            break;
        }
        gp[n-1] -= n;
        for (int i=0; i<n-1; i++) {
            gp[i]++;
        }
        ans++;
    }


    ll dl = max(0LL, gp[0] - (n-1));
    REP (i, n) {
        gp[i] -= dl;
        ans += dl;
    }

    while (true) {
        sort(gp.begin(), gp.end());
        if (gp[n-1] < n) {
            break;
        }
        gp[n-1] -= n;
        for (int i=0; i<n-1; i++) {
            gp[i]++;
        }
        ans++;
    }


    cout << ans<< endl;
    return 0;
}


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

#define rep(i, n) for(int i = 0; i < (n); ++i)

using namespace std;

using ll = long long;
using P = pair<int , int>;
  
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);

  int h, a; cin >> h >> a;
  cout << (h / a + (0 != h % a));
}


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

int main(){
  string O,E;
  cin>>O>>E;
  for(int i=0;i<E.size();i++)
    cout<<O[i]<<E[i];
  if(O.size()!=E.size())
    cout<<O[O.size()-1];
  cout<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <iomanip>
#include <algorithm>

using namespace std;
using ll = long long;
using pint = pair<int, int>;

int main() {
	string S;
	cin >> S;

	cout << (S == "ABC" ? "ARC" : "ABC") << endl;
}


Measured memory_bytes: 3584
#include <bits/stdc++.h>
#include<iostream>
#include<cmath>
#define rep(i,n) for(int i=0;i<(n);++i)
using namespace std;
using ll=long long;
using P=pair<int,int>;
const int INF=1001001001;

int main(){
   ll n; cin>>n;
   ll ans=1e18;
   for(ll i=1;i*i<=n;i++){
      if(n%i==0) ans=min(ans,i+n/i-2);
   }
   cout<<ans<<endl;
   return 0;
}


Measured memory_bytes: 256
//AUTHOR: RAVAN_2070
//PUNE INSTITUTE OF COMPUTER TECHNOLOGY
/*
    I LOVE CLARICE STARLING

     ♥LOVE♥        ♥LOVE♥
  ♥LOVE♥♥LOVE♥  ♥LOVE♥♥LOVE♥
♥LOVE♥♥LOVE♥♥LOVE♥♥LOVE♥♥LOVE♥
   ♥LOVE♥♥LOVE♥♥LOVE♥♥LOVE♥
      ♥LOVE♥♥LOVE♥♥LOVE♥
         ♥LOVE♥♥LOVE♥
            ♥LOVE♥
               ♥


    EXPLAINATION BELOW->
   

*/
#include<bits/stdc++.h>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vi;
typedef vector<pair<ll,ll>> vii;
typedef pair<ll,ll> pii;
typedef map<ll,ll> mii;
#define MOD7 1000000007
#define MOD9 1000000009
#define pi 3.1415926535
#define Test_cases ll TC;cin>>TC;while(TC--)
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(), x.rend()
#define sp(x) fixed<<setprecision(x)
#define sz(x) (ll)(x.size())
#define fo(i,a,b) for(i=a;i<b;i++)
#define foe(i,a,b) for(i=a;i<=b;i++)
vector<int>adj[100005];
ll h[100005];
int n,m;
void solve()
{
   cin>>n>>m;
   int i;
   foe(i,1,n)cin>>h[i];
   
   int a,b;
   fo(i,0,m)
   {
       cin>>a>>b;
       adj[a].pb(b);
       adj[b].pb(a);
   }
   
   int ans=0;
   foe(i,1,n)
   {
       if(sz(adj[i])==0)ans++;
       else
       {
           int j;
           int mx=h[i];
           int flag=1;
           fo(j,0,(int)sz(adj[i]))
           {
               if(mx<=h[adj[i][j]]){flag=0;break;}
           }
           if(flag)ans++;
       }
   }
   cout<<ans<<"\n";
}
int main()
{
   fastio
   solve();
  return 0;
}
//map<ll,ll,greater<int>> to sort in descending order ,in iterator declaration no greater<int>
//if you want to apply lowerbound on set use s.lower_bound(key),not the one used for vector
/* TIPS FOR DEBUGGING
 * Check if values are not overflowing (use long long where required)
 * Check if ranges are inclusive or not.
 * Check properly if greedy will work or not before using it.
 * Check EDGE CASES!! Seriously, even in 2B, saving 8 points by being
 * 2 minutes faster will bite you in the ass if you don't make sure
 * it works on edge cases.
 * Keep adding to this list.
*/


Measured memory_bytes: 9536
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
#define rc(x) return cout<<x<<endl,0
#define pb push_back
#define mkp make_pair
#define in insert
#define er erase
#define fd find
#define fr first
#define sc second
#define all(x) x.begin(),x.end()
#define lun(x) (int)x.size()
typedef long long ll;
typedef long double ld;
const ll INF=0x3f3f3f3f3f3f3f3f;
const ll llinf=(1LL<<60);
const int inf=(1<<30);
const int nmax=2e5+50;
const ll mod=1e9+7;
using namespace std;
int n,s[nmax],p[nmax],rs,i,l[nmax];
char c[nmax];
int main()
{
	//freopen("sol.in","r",stdin);
	//freopen("sol.out","w",stdout);
	//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
	ios_base::sync_with_stdio(false);cin.tie(0);cerr.tie(0);cout.tie(0);
    cin>>n;
    for(i=1;i<=n;i++)cin>>c[i];
    for(i=1;i<=n;i++)
    {
        p[i]=p[i-1]+(c[i]=='W');
        l[i]=l[i-1];
        if(c[i]=='R')l[i]=i;
    }
    for(i=n;i>=1;i--)s[i]=s[i+1]+(c[i]=='R');
    rs=n;
    for(i=0;i<=n;i++)
    {
        //rs=min(rs,p[i]+s[i+1]);
        if(s[i+1]>=p[l[i]])rs=min(rs,s[i+1]);
    }
    cout<<rs<<'\n';
	return 0;
}


Measured memory_bytes: 6144
import java.util.Scanner;
public class Main {
	public static void main(String[] args){
		Scanner stdIn=new Scanner(System.in);
		String S=stdIn.next();
		int A,B,C,D;
		A=Integer.valueOf(S.substring(0,1));
		B=Integer.valueOf(S.substring(1,2));
		C=Integer.valueOf(S.substring(2,3));
		D=Integer.valueOf(S.substring(3,4));
		int ans=A;
		for(int i=0;i<2;i++){
			for(int j=0;j<2;j++){
				for(int k=0;k<2;k++){
					if(i==0)
						ans+=B;
					else
						ans-=B;
					if(j==0)
						ans+=C;
					else
						ans-=C;
					if(k==0)
						ans+=D;
					else
						ans-=D;
					if(ans==7){
						String a="-";
						String b="-";
						String c="-";
						if(i==0)
							a="+";
						if(j==0)
							b="+";
						if(k==0)
							c="+";
						System.out.println(A+a+B+b+C+c+D+"=7");
						System.exit(0);
					}
					ans=A;
				}
			}
		}
	}
}

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

int main(){
  int n;
  double parent=0;
  cin >> n;
  rep(i,n) {
    double tmp;
    cin >> tmp;
    parent += 1/tmp;
  }
  cout << to_string(1/parent) << endl;
  return 0;
}

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

int main(void){
    long long n, a, b, c, d, e, ans=0;
    cin >> n >> a >> b >> c >> d >> e;
    long long mi = min(a, min(b, min(c, min(d, e))));
    cout << (n+mi-1)/mi+4 << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <queue>
#define INF		10000000
using namespace std;
typedef pair<int, int> P;

int h, w, n;
int count = 0;
char masu[1000][1000];
int d[1000][1000];
int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
int sgx[10], sgy[10];

void bfs(int a){
	queue<P> que;
	que.push(P(sgx[a], sgy[a]));
	d[sgy[a]][sgx[a]] = 0;
	while(que.size()){
		P p = que.front();
		que.pop();
		if(p.first == sgx[a+1] && p.second == sgy[a+1]) break;
		for(int i = 0; i < 4; i++){
			int nx = p.first+dx[i], ny = p.second+dy[i];
			if(0 <= nx && 0 <= ny && nx < w && ny < h && masu[ny][nx] != 'X' && d[ny][nx] == INF){
				que.push(P(nx,ny));
				d[ny][nx] = d[p.second][p.first]+1;
			}
		}
	}
	count += d[sgy[a+1]][sgx[a+1]];
}

void solve(){
	for(int i = 0; i < n; i++){
		for(int j = 0; j < 1000; j++){
			for(int k = 0; k < 1000; k++){
				d[j][k] = INF;
			}
		}
		bfs(i);
	}
	cout << count << endl;
}

int main(){
	for(int i = 0; i < 1000; i++)
		for(int j = 0; j < 1000; j++) masu[i][j] = 'X';
		
	cin >> h >> w >> n;
	for(int i = 0; i < h; i++){
		for(int j = 0; j < w; j++){
			cin >> masu[i][j];
			if(masu[i][j] == 'S'){
				sgx[0] = j;
				sgy[0] = i;
			}
			for(int k = 1; k < n+1; k++){
				if(masu[i][j] == '0'+k){
					sgx[k] = j;
					sgy[k] = i;
				}
			}
		}
	}
	solve();
}

Measured memory_bytes: 6096
#include <bits/stdc++.h>
using namespace std;
int main() {
	long long int n1,n2,cnt=1; cin>>n1>>n2;
	long long int n=__gcd(n1,n2); 
	for(long long int i=2;i*i<=n;i++) {
		if(n%i==0) {
			cnt++;
			while(n%i==0) n/=i;
		}
	}
	
	if(n>1) cnt++;
	cout<<cnt<<endl;
	
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ADD(a, b) a = (a + ll(b)) % mod
#define MUL(a, b) a = (a * ll(b)) % mod
#define MAX(a, b) a = max(a, b)
#define MIN(a, b) a = min(a, b)
#define rep(i, a, b) for(int i = int(a); i < int(b); i++)
#define rer(i, a, b) for(int i = int(a) - 1; i >= int(b); i--)
#define all(a) (a).begin(), (a).end()
#define sz(v) (int)(v).size()
#define pb push_back
#define sec second
#define fst first
#define debug(fmt, ...) Debug(__LINE__, ":", fmt, ##__VA_ARGS__)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<int, pi> ppi;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> mat;
typedef complex<double> comp;
void Debug() {cout << '\n'; }
template<class FIRST, class... REST>void Debug(FIRST arg, REST... rest){
	cout<<arg<<" ";Debug(rest...);}
template<class T>ostream& operator<<(ostream& out,const vector<T>& v) {
	out<<"[";if(!v.empty()){rep(i,0,sz(v)-1)out<<v[i]<<", ";out<<v.back();}out<<"]";return out;}
template<class S, class T>ostream& operator<<(ostream& out,const pair<S, T>& v){
	out<<"("<<v.first<<", "<<v.second<<")";return out;}
const int MAX_N = 200010;
const int MAX_V = 100010;
const double eps = 1e-6;
const ll mod = 1000000007;
const int inf = 1 << 29;
const ll linf = 1LL << 60;
const double PI = 3.14159265358979323846;
///////////////////////////////////////////////////////////////////////////////////////////////////

ll mod_pow(ll a, ll n) {
	if(n == 0) return 1;
	ll res = mod_pow(a, n / 2);
	if(n % 2 == 0) return res * res % mod;
	else return a * res % mod * res % mod;
}


ll N, K, M;
ll ans;
map<int, int> P;
vector<pi> vp;

map<vi, ll> dp[11];

ll diviser(const vi& vec) {
	ll n = 1;
	rep(i, 0, M) {
		n *= mod_pow(vp[i].fst, vec[i]);
	}
	return n;
}

ll loop(vi vec, int at) {
	if(dp[at].find(vec) != dp[at].end()) return dp[at][vec];
	if(at == 0) {
		ll l = diviser(vec);
		return dp[at][vec] = mod_pow(K, (l + 1) / 2);
	}
	else {
		int p = vec[at - 1];
		ll res = 0;
		if(p - 1 >= 0) {
			vec[at - 1] = p - 1;
			ADD(res, mod - loop(vec, at - 1));
		}

		vec[at - 1] = p;
		ADD(res, loop(vec, at - 1));
		return dp[at][vec] = res;
	}
}

void loop2(vi vec, int at) {
	if(at == M) {
		ll l = diviser(vec);
		if(l % 2 == 0) ADD(ans, (l / 2) * loop(vec, M) % mod);
		else ADD(ans, l * loop(vec, M) % mod);
		return;
	}
	vec.resize(at + 1);
	rep(i, 0, vp[at].sec + 1) {
		vec[at] = i;
		loop2(vec, at + 1);
	}
}

void solve() {
	cin >> N >> K;
	ans = 0;
	ll n = N;
	for(int i = 2; i * i <= n; i++) {
		while(n % i == 0) {
			n /= i;
			P[i]++;
		}
	}
	if(n != 1) P[n]++;

	vp = vector<pi>(all(P));
	M = sz(vp);


	loop2({}, 0);

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

int main() {
#ifndef LOCAL
	ios::sync_with_stdio(false);
    cin.tie(0);
#endif
    cout << fixed;
	cout.precision(20);
	srand((unsigned int)time(NULL));
#ifdef LOCAL
	//freopen("in.txt", "wt", stdout); //for tester
    freopen("in.txt", "rt", stdin);
#endif	
	solve();
#ifdef LOCAL
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
	return 0;
}



Measured memory_bytes: 1664
fun abc123b(args: Array<String>) {
    val numList = args.map { it.toInt() }
    val total = numList.map { if (it % 10 == 0) it / 10 * 10 else (it + 10) / 10 * 10 }.sum()
    val lastDiff = 10 - numList.map { if (it % 10 == 0) 10 else it % 10 }.min()!!
    println(total - lastDiff)
}

fun main(args: Array<String>) {
    abc123b(readLineList())
}

fun readLineList(): Array<String> {
    val lineList = mutableListOf<String>()
    while (true) {
        val line = readLine()
        if (line.isNullOrBlank()) {
            break
        } else {
            lineList.add(line!!)
        }
    }
    return lineList.toTypedArray()
}

Measured memory_bytes: 33916
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#include <sstream>
#include <iomanip>
#define rep(i,n) for(int i = 0; i < n; i++)
#define rep1(i,n) for(int i = 1; i <= n; i++)
#define co(x) cout << x <<endl
#define cs(x) cout << x <<" "
#define ALL(a) (a).begin(),(a).end()
typedef long long ll;
using namespace std;
vector<int> mapAlp(string);

int main()
{
	int n;
	cin >> n;
	vector<string> S(n);
	rep(i, n) cin >> S[i];
	vector<int> mapMin = mapAlp(S[0]);
	rep1(i, n-1) 
	{
		vector<int> map = mapAlp(S[i]);
		rep(j, 26)
		{
			mapMin[j] = min(mapMin[j], map[j]);
		}
	}
	string ans;
	rep(i, 26)
	{
		rep(j, mapMin[i])
		{
			ans.push_back((char)('a' + i));
		}
	}
	co(ans);
	return 0;
}

vector<int> mapAlp(string s)
{
	vector<int> res(26, 0);
	rep(i, s.size()) res[s[i] - 'a']++;
	return res;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {

  int a,b;
  string t,u;
  cin >> t >> u>>a>>b;
  string c;
  cin >> c;
  if(t==c)a--;
  if(u==c)b--;
  cout << a << " " << b << endl;
}


Measured memory_bytes: 3608
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0;i < n;i++)
#define rev(i, n) for(int i = n;i >= 0;i--)
#define Rep(i, m, n) for(int i = m;i < n;i++)
#define repeatrev(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define INF 999999999
#define itn int

using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;
typedef priority_queue<int> Pr;

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

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int k, x;
    cin >> k >> x;
    Rep(i, x - k + 1, x + k) cout << i << " ";

}

Measured memory_bytes: 256
#include <iostream> // cin, cout, cerr
#include <algorithm> // minmax, sort, swap
#include <numeric> // iota
#include <cstdio> // printf, scanf
#include <string> // string, stoi, to_string
#include <vector> // vector
#include <queue> // queue, priority_queue
#include <deque> // deque
#include <map> // key-value pairs sorted by keys
#include <set> // set
#include <iomanip> // cout<<setprecision(n)
#include <functional> // function<void(int)>
#include <cmath>

#ifdef DEBUG
#include "debug.hpp"
#else
#define debug(...)
#endif

#define int long long // at least int64 > 9*10^18
#define ENDL '\n'
#define rep(i,n) for(int i = 0; i < (n); i++)
#define print(i) std::cout << (i) << '\n'
#define all(v) (v).begin(), (v).end()
/* libraries */

signed main() {
	std::string s;
	std::cin >> s; // = N
	int n = s.size();
	std::vector<std::vector<int> > dp(n,std::vector<int>(2,0)); // n x 2
	dp[0][0] = s[0]-'0';
	dp[0][1] = 11-(s[0]-'0');
	rep(i,n-1) {
		int d = s[i+1]-'0';
		dp[i+1][0] = std::min(dp[i][0], dp[i][1]) + d;
		dp[i+1][1] = std::min(dp[i][0]+11-d, dp[i][1]+9-d);
	}
	print(std::min(dp[n-1][0],dp[n-1][1]));
	return 0;
}


Measured memory_bytes: 55940
#include <algorithm>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <vector>
#include <list>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
//#define cerr if(false) cerr
#ifdef DEBUG
#define show(...) cerr << #__VA_ARGS__ << " = ", debug(__VA_ARGS__);
#else
#define show(...) 42
#endif
using namespace std;
using ll = long long;
using pii = pair<int, int>;
template <typename T, typename S>
ostream& operator<<(ostream& os, pair<T, S> a) {
    os << '(' << a.first << ',' << a.second << ')';
    return os;
}
template <typename T>
ostream& operator<<(ostream& os, vector<T> v) {
    for (auto x : v) os << x << ' ';
    return os;
}
void debug() {
    cerr << '\n';
}
template <typename H, typename... T>
void debug(H a, T... b) {
    cerr << a;
    if (sizeof...(b)) cerr << ", ";
    debug(b...);
}
int f(vector<ll>a){
    vector<int>dp(a.size(),INT_MAX);
    rep(i,a.size()){
        *lower_bound(dp.begin(),dp.end(),a[i]) = (int)a[i];
    }
    return (int)(lower_bound(dp.begin(),dp.end(),INT_MAX)-dp.begin());
}
int main(){
    ll n, a, b;
    cin >> n >> a >> b;
    if(a + b - 1 > n or a * b < n){
        cout << -1 << endl;
        return 0;
    }
    vector<ll>ans;
    ans.reserve(n);
    rep(i,b)ans.push_back(b-i);
    if(a==1){
        rep(i,n)cout << ans[i] << " \n"[i == n -1];
        return 0;
    }
    ll num = (n-b)/(a-1);
    ll rem = (n-b)%(a-1);
    rep(i,rem){
        int sz = (int) ans.size();
        rep(j,num+1)ans.push_back(sz+num+1-j);
    }
    rep(i,a-1-rem){
        int sz = (int) ans.size();
        rep(j,num)ans.push_back(sz+num-j);
    }
    rep(i,n)cout << ans[i] << " \n"[i == n -1];
}


Measured memory_bytes: 4480
#include <iostream>
#include <cmath>
#include <iomanip>
using namespace std;
int main(void){
    double x1, x2, y1, y2;
    cin >> x1 >> y1;
    cin >> x2 >> y2;
    
    double d = pow(x1-x2, 2) + pow(y1-y2, 2);
    double x = sqrt(d);
    
    cout << fixed << setprecision(8) << x << endl;
}


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

int main(){
 char kata[19];
 scanf("%[^\n]", &kata);
 
 for(int i = 0; i<19; i++){
  if(kata[i]== ','){
   printf(" ");
  }
  else {
  printf("%c", kata[i]);
 }
}
 return 0;
}

Measured memory_bytes: 1584
import math

def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

N,K = [int(i) for i in input().split()]
for i in range(1,K+1):
    if (N-K+1)<i:
        print(0)
        continue
    print((combinations_count(N-K+1,i)*combinations_count(K-1,i-1))%(10**9+7))


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

int main(){
  int N,K;
  cin>>N>>K;
  vector<int> L(N);
  for(int i=0;i<N;i++){
    cin>>L.at(i);
  }
  
  sort(L.begin(),L.end());
  reverse(L.begin(),L.end());
  
  int ans = 0;
  for(int i=0;i<K;i++){
    ans += L.at(i);
  }
  
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 256