akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i <= n; i++)
#define FORR(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());
 
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;

ll h, w;
vll dx = {1, 0, -1, 0};
vll dy = {0, 1, 0, -1};

vvll a(51, vll(51));

bool isin(ll y, ll x){
    return (y >= 0 && y < h && x >= 0 && x < w);
}

ll bfs(ll y, ll x){
    vvll d(h, vll(w, -1));
    queue<P> que;
    que.push(P{y, x});
    d[y][x] = 0;
    while(!que.empty()){
        ll cy = que.front().first, cx = que.front().second;
        que.pop();
        REP(i, 4){
            ll ny = cy + dy[i], nx = cx + dx[i];
            if(!isin(ny, nx) || d[ny][nx] != -1 || a[ny][nx]) continue;
            que.push(P{ny, nx});
            d[ny][nx] = d[cy][cx] + 1;
        }
    }
    return d[h - 1][w - 1];
}
int main(){
	cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> h >> w;
    ll black = 0;
    char c;
    REP(i, h){
        REP(j, w){
            cin >> c;
            if(c == '#'){
                a[i][j] = 1;
                black++;
            }
        }
    }
    if(bfs(0, 0) == -1){
        cout << -1 << endl;
        return 0;
    }
    ll res = h * w - black - bfs(0, 0) - 1;
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <numeric>
#include <array>
#include <cmath>
#include <memory>
using namespace std;
//変数デバッグ
#define DEB(variable) cout << #variable << '=' << variable << endl

//for簡易表記(引数ミス防止)
#define FOR(LoopVariable,numberOFbegin,numberOFend) for (int LoopVariable = (numberOFbegin); (LoopVariable) < (numberOFend); (LoopVariable)++)
#define DEFOR(LoopVariable,numberOFbegin,numberOFend) for (int LoopVariable = (numberOFbegin)-1; (LoopVariable) >= (numberOFend); (LoopVariable)--)
#define REP(LoopVariable,numberOFend) for(int LoopVariable = 0;(LoopVariable)<(numberOFend);LoopVariable++)

constexpr long long int linf = numeric_limits<long long int>::max()-5;
constexpr int inf= numeric_limits<int>::max()-5;
constexpr long long int mod = 1000000007;

int main(){

    int a,b;
    cin >> a >> b;
    cout<<(a-1)*(b-1)<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<cmath>
#include<math.h>
#include<ctype.h>
#include<algorithm>
#include<bitset>
#include<cassert>
#include<cctype>
#include<cerrno>
#include<cfloat>
#include<ciso646>
#include<climits>
#include<clocale>
#include<complex>
#include<csetjmp>
#include<csignal>
#include<cstdarg>
#include<cstddef>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<cwchar>
#include<cwctype>
#include<deque>
#include<exception>
#include<fstream>
#include<functional>
#include<iomanip>
#include<ios>
#include<iosfwd>
#include<iostream>
#include<istream>
#include<iterator>
#include<limits>
#include<list>
#include<locale>
#include<map>
#include<memory>
#include<new>
#include<numeric>
#include<ostream>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<stdexcept>
#include<streambuf>
#include<string>
#include<typeinfo>
#include<utility>
#include<valarray>
#include<vector>
#include<string.h>
#include<stdlib.h>
#include<stdio.h>
using namespace std;

//Author: Jiangsu Nanjing Li Zongtai
//强壮标记*10000,手牌*10000,血量10000 lyl+hzj也打不死我哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈~~~~

const int inf=2147483647;

bool bb[1111];
bool bb2[1111];

int main()
{
int a,b,c,d;

cin>>a>>b>>c>>d;

for(int i=a;i<=b;i++)
{
bb[i]=1;
}

for(int i=c;i<=d;i++)
{
bb2[i]=1;
}

int ans=0;

for(int i=0;i<=100;i++)
{
if(bb[i]&&bb2[i]) ans++;
}

if(ans) ans--;

cout<<ans<<endl;

return 0;
}


Measured memory_bytes: 256
import java.util.*;
    public class Main {// Main
        public static void main(String[] args){
            Scanner sc = new Scanner(System.in);
            int n = sc.nextInt();
            int[] a = new int[n];
            int sum1 = 0;
            int sum2 = 0;
            for(int i=0;i<n;i++) { a[i] = sc.nextInt(); sum2+=a[i]; }
            int min = Math.abs(sum2-sum1);
            for(int i=0;i<n;i++){
                sum1 += a[i];
                sum2 -= a[i];
                int x = Math.abs(sum2-sum1);
                if(x<min) min = x;
            }
            System.out.println(min);
        }
    }							

Measured memory_bytes: 22868
f _ [] = 0
f [] _ = 0
f (x:xs) (y:ys) =
    if x == y then 1 + f xs ys else 0

solve :: String -> String -> Int
solve _ [] = 0
solve [] _ = 0
solve s t = max (f s t) (solve (tail s) t)

main :: IO ()
main = do
    n <- readLn :: IO Int
    s <- getLine :: IO String
    t <- getLine :: IO String
    print $ 2 * n - solve s t

Measured memory_bytes: 508
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,k,s,mx=1e9;
	scanf("%d%d%d",&n,&k,&s);
	for(int i=0;i<k;i++)printf("%d ",s);
	if(s!=mx)for(int i=k;i<n;i++)printf("%d ",mx);
	else for(int i=k;i<n;i++)printf("%d ",1);
}

Measured memory_bytes: 1280
N = int(input())
A = list(map(int,input().split()))
c = 0
while 1:
    if list(map(lambda x: x%2, A)) == [0 for _ in range(N)]:
        A = list(map(lambda x: x//2, A))
        c += 1
    else:
        break
print(c)

Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
int main(void){
    long long x;
    cin >> x;
    if(x%11 == 0) cout << x/11*2 << endl;
    else if(x%11 <=6) cout << x/11*2 + 1 << endl;
    else cout << x/11*2 + 2 << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

class Main {

	public static void main(String args[]){

		Scanner scan = new Scanner(System.in);
		String s = scan.next();
		int n = 4;
		int x[] = new int[n];
		for(int i = 0;i < n; i++)
			x[i] = s.charAt(i)-'0';

		String X[] = new String[(int) Math.pow(2,n-1)];
		int sum = 0;
		String S ="";

		for(int i = 0; i < Math.pow(2,n-1); i++){
			sum = x[0];
			S = String.valueOf(x[0]);
			for(int j = 0; j < n-1; j++){

				if((1 & (i>>j)) == 1){
					sum += x[j+1];
					S += "+" + String.valueOf(x[j+1]);
				}
				else{
					sum -= x[j+1];
					S += "-" + String.valueOf(x[j+1]);
				}
			}
			if(sum == 7){
				System.out.print(S+"=7");
				break;
			}
		}
	}
}


Measured memory_bytes: 23252
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i, a, b) for(ll i=(a); i<(b); i++)
#define PER(i, a, b) for(ll i=(a); i>=(b); i--)
#define rep(i, n) REP(i, 0, n)
#define per(i, n) PER(i, n, 0)
#define ALL(a)  (a).begin(),(a).end()
const ll INF = 1e18+18;
const ll MAX = 200000;
const ll MOD = 1000000007;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define YES(n) cout << ((n) ? "YES" : "NO") << endl;



int main(){
  ll D, G;
  cin>>D>>G;
  vector<ll> P(D), C(D);
  rep(i, D){
    cin>>P[i]>>C[i];
  }
  ll Ans=INF;
  for(ll i=0; i<(1<<D); i++){
    ll Point=0;
    ll Cou=0;
    rep(j, D){
      if(i&(1<<j)){
        Point+=C[j];
        Point+=(100*(j+1))*P[j];
        Cou+=P[j];
      }
    }
    //cout<<Point;
    if(Point>=G){
      Ans=min(Ans,Cou);
      continue;
    }
    //cout<<'&';
    for(ll j=D-1; j>=0; j--){
      if(i&(1<<j))continue;
      ll K=(G-Point)/((j+1)*100);
      if((G-Point)%((j+1)*100)>0)K++;
      if(K<=P[j]-1){
        Cou+=K;
        break;
      }else{
        Cou=INF;
        break;
      }
    }
	Ans=min(Ans, Cou);

  }
  cout<<Ans<<endl;
} 

Measured memory_bytes: 3600
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#define MOD 1000000007
#define INF 1 << 30

using namespace std;
typedef long long ll;

int main(void) {
	int num, i;
	double ans;
	cin >> num;
	if (num % 2 == 0)
		ans = 0.5;
	else
		ans = (double)((num / 2) + 1) / (double)num;
	printf("%.9lf\n", ans);
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <cstdio>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <iomanip>
#include <queue> 
 
using namespace std;
 
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);

	int H, A;

	cin >> H >> A;

	int x = H / A;

	if(A * x < H) {
		x++;
	}

	cout << x << endl;
}

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

using namespace std;

//----------------------- Print Function ----------------------//

inline void print() {
    cout << endl;
}
template <typename First, typename... Rest>
void print(const First &first, const Rest &... rest) {
    cout << first << ' ';
    print(rest...);
}

template <typename T>
void print(const vector<T> &v) {
    for (auto e : v) cout << e << ' ';
    cout << endl;
}

//------------------------- Libraries -------------------------//

//--------------------------- Solve ---------------------------//

const long long INF = 1LL<<60;

void solve() {
    int N, K; cin >> N >> K;
    vector<int> P(N);
    vector<long long> C(N);
    for (int i = 0; i < N; i++) cin >> P[i], P[i]--;
    for (int i = 0; i < N; i++) cin >> C[i];

    vector<pair<int, long long>> vp(N); // ループ内の回数、ループ内の得点 
    for (int i = 0; i < N; i++) {
        long long score = 0;
        int num = 0, pos = i;
        do {
            num++;
            pos = P[pos];
            score += C[pos];
        } while (pos != i);
        vp[i] = make_pair(num, score);
    }

    long long ans = -INF;
    for (int i = 0; i < N; i++) {
        int loop_num = vp[i].first;
        long long loop_score = vp[i].second;
        long long score = 0;
        int k = K;

        if (loop_score > 0 && K / loop_num > 0) {
            score += loop_score * (K / loop_num - 1);
            k -= (K / loop_num - 1) * loop_num;
            // 最後から二番目のループ
            int pos = i;
            do {
                k--;
                pos = P[pos];
                score += C[pos];
                ans = max(ans, score);
            } while (pos != i && k > 0);
            // 最後のループ
            if (k > 0) {
                do {
                    k--;
                    pos = P[pos];
                    score += C[pos];
                    ans = max(ans, score);
                } while (pos != i && k > 0);
            }
        }

        else {
            int pos = i;
            do {
                k--;
                pos = P[pos];
                score += C[pos];
                ans = max(ans, score);
            } while (pos != i && k > 0);
        }
    }

    cout << ans << '\n';
}

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

    solve();

    return 0;
}

Measured memory_bytes: 3812
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));

            return;
        }

        public void Solve(ConsoleInput cin)
        {

            var N = cin.ReadLong;

            const long mod = 1000000007;

            long ans = 1;
            for (long i = 1; i <= N; i++){
                ans = ans * i % mod;
            }

            WriteLine(ans);

        }
    }

    public static class Extensions
    {
        public static string Reverse(this string sourse)
        {
            char[] chrAry = sourse.ToCharArray();
            Array.Reverse(chrAry);
            return new string(chrAry);
        }
    }

    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }
        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); } }
        public int ReadInt { get { return int.Parse(Read); } }
        public long ReadLong { get { return long.Parse(Read); } }
        public double ReadDouble { get { return double.Parse(Read); } }
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret; }
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret; }
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret; }
    }
}


Measured memory_bytes: 11220
//median 33min
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1e18;
const ll MOD = 1e9 + 7;
#define all(v) v.begin(), v.end()
#define repi(i, n, init) for (ll i = init; i < (n); i++)
#define repd(i, n, init) for (ll i = (n); i >= init; i--)
#define repm(i, m) for (auto i = m.begin(); i != m.end(); i++)

int main()
{
    ll A, B, C, X, Y;
    cin >> A >> B >> C >> X >> Y;

    ll Ans = 0, m = 0;
    m = min(A + B, C * 2);
    Ans = m * min(X, Y);
    if (X == min(X, Y))
    {
        Y -= X;
        X = 0;
        m = min(B,C*2);
    }
    else
    {
        X -= Y;
        Y = 0;
        m = min(A,C*2);
    }
    Ans += X * m + Y * m;
    cout << Ans << endl;
    return 0;
}

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

int main(){
  string S;
  cin >> S;
  
  vector<bool> b(26);
  for (int i = 0; i < 26; i++){
    b.at(i) = false;
  }
  
  for (int i = 0; i < S.size(); i++){
    b.at(S.at(i)-'a') = true;  
  }
  
  for (int i = 0; i < 26; i++){
    if(b.at(i)==0){
      cout << char(i+97) << endl;
      return 0;
    }
    
  }
  cout << "None" << endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define rep(i,a,b) for(ll i=ll(a);i<ll(b);i++)
#define irep(i,a,b) for(ll i=ll(a);i>=ll(b);i--)
using ll = long long;
using namespace std;

ll GCD(ll a, ll b) { return b ? GCD(b, a%b) : a; }
//sort(a, a + N, greater<ll>())   // descend
//sort(a, a+N)                    //  ascend

/**
void comb(vector<vector <ll> > &v) {
	rep (i,0,v.size()) {
		v[i][0] = 1;
		v[i][i] = 1;
	}
	rep (k,1,v.size()) {
		rep (j,1,k) {
			v[k][j] = (v[k - 1][j - 1] + v[k - 1][j]);
		}
	}
}
/*main内でnCn~nC0 生成 **
vector<vector<ll> > v(n + 1, vector<ll>(n + 1, 0));
comb(v);
*/

int main() {
	ll mod = 1000000007;
	ll n;
	cin>>n;
	string s;
	cin>>s;
	ll cnt[50]={0};
	ll p=0;
	rep(j,0x61,0x7b){
		rep(i,0,n){
			if(s[i]==j) cnt[p]++;
		}
		p++;
	}
	ll ans=1;
	rep(i,0,p) {
		if(cnt[i]>=1) ans*=(cnt[i]+1)%mod;
		ans=ans%mod;
	}
	cout<<(ans-1)%mod;

}

Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <queue>
#include <climits>
#include <cmath>
#include <algorithm>
#include <unordered_set>
using namespace std;

// UnionFind
struct UnionFind {
  vector<int> d;
  UnionFind(int n=0): d(n,-1) {}
  int find(int x) {
    if (d[x] < 0) return x;
    return d[x] = find(d[x]);
  }
  bool unite(int x, int y) {
    x = find(x); y = find(y);
    if (x == y) return false;
    if (d[x] > d[y]) swap(x,y);
    d[x] += d[y];
    d[y] = x;
    return true;
  }
  bool same(int x, int y) { return find(x) == find(y);}
  int size(int x) { return -d[find(x)];}
  int root(int x) { return d[x];}
};

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

  int32_t N, M;
  cin >> N >> M; 
  UnionFind uf(N);
  for (int i = 0; i < M; i++) {
    int A,B;
    cin >> A >> B;
    uf.unite(A-1, B-1);
  }
  int res = 0;
  for (int i = 0; i < N; i++) {
    if (uf.root(i) < 0) {
      res++;
    }
  }
  cout << res - 1 << endl;
  

  return 0;
}


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

int main(){
    LL N, C, K;
    cin >> N >> C >> K;
    vector<LL>  T(N);
    for(int i = 0;i < N;i++)    cin >> T[i];
    sort(T.begin(), T.end());
    LL count = 0;
    LL t = 0;
    LL ans = 0;
    for(int i = 0;i < N;i++){
        if(count == 0 || count == C || T[i] > t){
            t = T[i]+K;
            ans++;
            count = 1;
        }else{
            count++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>

using namespace std;
#define MAX_SIZE 100

//bool judge(const string& str)
//{
//	int size = str.length();
//	int C_idx = -1;
//	int F_idx = -1;
//
//	for (int i = 0; i < size; ++i)
//	{
//		if (str[i] == 'C')
//		{
//			C_idx = i;
//			break;
//		}
//
//	}
//
//	for (int i = size - 1; i >= 0; --i)
//	{
//		if (str[i] == 'F')
//		{
//			F_idx = i;
//			break;
//		}
//
//	}
//	if (C_idx == -1 || F_idx == -1)	return false;
//	if (C_idx < F_idx)	return true;
//	else	return false;
//}

int find(int* a, int choose, const int T)
{
	int res = 0;
	int retIdx = -1;
	for (int i = 0; i < T ; ++i)
	{
		if (a[i] > res && i != choose)
		{
			res = a[i];
			retIdx = i;
		}
	}
	return retIdx == -1 ? choose : retIdx;
}

int compute(const int K, const int T, int* a)
{
	int res = 0;
	int oldChoose = -1;
	for (int i = 0; i < K; ++i)
	{
		int newChoose = find(a, oldChoose, T);
		//cout << newChoose << " ";
		if (newChoose == oldChoose)	++res;
		--a[newChoose];
		oldChoose = newChoose;
	}
	//cout << endl;
	return res;
}

int main(int argc, char* argv[])
{
	int K = 0;
	cin >> K;
	int T = 0;
	cin >> T;
	int* a = new int[T];
	for (int i = 0; i < T; ++i)
	{
		cin >> a[i];
	}
	int res = compute(K, T, a);
	cout << res << endl;
	//cin.get();
	//cin.get();
	delete[] a;
	return 0;
}



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

a2=[a[n-1]]
for i in range(n-1,0,-1):
    a2.append(a2[-1]+a[i-1])
ans=0
for i in range(n-1):
    ans = ( ans + (a[i]*a2[-i-2]) )%(10**9+7)
print(ans)


Measured memory_bytes: 31676
string = input()
result = []
j=0
for i in range(len(string)):
    if string[i]=='0':
        result.append('0')
    elif string[i]=='1':
        result.append('1')
    elif string[i]=='B' and len(result)>=1 and result[-1] in ['0','1']:
        del result[-1]
str_result="".join(result)
print(str_result)

Measured memory_bytes: 3064
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<array>
#include<map>
#include<iomanip>
#include<assert.h>
using namespace std;
typedef long long int llint;
typedef long double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
//cout<<setprecision(20)
//cin.tie(0);
//ios::sync_with_stdio(false);
const llint mod=1000000007;
const llint big=4.19e18+1;
const long double pai=3.141592653589793238462643383279502884197;
const long double eps=1e-15;
template <class T,class U>void mineq(T& a,U b){if(a>b){a=b;}}
template <class T,class U>void maxeq(T& a,U b){if(a<b){a=b;}}
llint gcd(llint a,llint b){if(a%b==0){return b;}else return gcd(b,a%b);}
llint lcm(llint a,llint b){return a/gcd(a,b)*b;}
template<class T> void SO(T& ve){sort(ve.begin(),ve.end());}
template<class T> void REV(T& ve){reverse(ve.begin(),ve.end());}
int LBI(vector<int>&ar,llint in){return lower_bound(ar.begin(),ar.end(),in)-ar.begin();}
int UBI(vector<int>&ar,llint in){return upper_bound(ar.begin(),ar.end(),in)-ar.begin();}
int main(void){
	string str;cin>>str;
	int K,i,j,n=str.size();cin>>K;
	vector<string>aaa;
	for(i=0;i<n;i++){
		for(j=1;j<=K&&i+j<=n;j++){
			aaa.pub(str.substr(i,j));
		}
	}
	SO(aaa);
	aaa.erase(unique(aaa.begin(),aaa.end()),aaa.end());
	//for(auto it:aaa){cerr<<it<<" ";}
	cout<<aaa[K-1]<<endl;
	return 0;
}

Measured memory_bytes: 1660
#include <iostream>
#include <cmath>
using namespace std;
using P = pair<long long int, long long int>;
int main(){
    long long int n;
    cin >> n;
    long long int ans1 = 1;
    long long int ans2 = n;
    long long int lim = sqrt(n)+2;
    for(long long int i = 2; i < lim; i++){
        if(n % i == 0){
            ans1 = i;
            ans2 = n/i;
        }
    }

    cout << ans1 + ans2 - 2 << endl;
}

Measured memory_bytes: 256
def main():
    N = int(input())
    dist = [list(map(int, input().split())) for _ in range(N)]

    update = False
    for k in range(N):
        for i in range(N):
            for j in range(N):
                if not (dist[i][k] and dist[k][j]): continue  # パスなし
                d = dist[i][k] + dist[k][j]
                if dist[i][j] > d:
                    dist[i][j] = d
                    update = True

    if update:
        print(-1)
        return

    ans = 0
    for j in range(N):
        for i in range(j):
            for k in range(N):
                if not (dist[i][k] and dist[k][j]): continue  # パスなし
                d = dist[i][k] + dist[k][j]
                if d == dist[i][j]: break  # divisible
            else:
                ans += dist[i][j]
    print(ans)


if __name__ == '__main__':
    main()

# import sys
# input = sys.stdin.readline
# 
# sys.setrecursionlimit(10 ** 7)
# 
# (int(x)-1 for x in input().split())
# rstrip()
#
# def binary_search(*, ok, ng, func):
#     while abs(ok - ng) > 1:
#         mid = (ok + ng) // 2
#         if func(mid):
#             ok = mid
#         else:
#             ng = mid
#     return ok


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

int main() {
  vector<int> v(5);
  for(int i = 0; i < 5; i++)
    cin >> v.at(i);
  int k;
  cin >> k;
  sort(v.begin(), v.end());
  if(v.at(4) - v.at(0) > k)
    cout << ":(" << endl;
  else
    cout << "Yay!" << endl;
  
}

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

using namespace std;
typedef long long ll;

const int N=1e5+10;
int n;
int v[N][2],w[N];

int gr[N];
bool comp(int x,int y){
        return w[x]>w[y];
}
ll f[N];
ll fcom[N];
int p[N];
vector <int> imp[N];
int main(){
        cin>>n;
        for(int i=1;i<n;i++)
                cin>>v[i][0]>>v[i][1]>>w[i];
        for(int i=1;i<n;i++) p[i]=i;
        sort(p+1,p+n,comp);
        

        for(int i=1;i<=n;i++){
                gr[i]=i;
                imp[i].push_back(i);
        }

        for(int i=1;i<n;i++){
                int use=p[i];
                int x=gr[v[use][0]],y=gr[v[use][1]];
                if (imp[x].size()>imp[y].size()) swap(x,y);
                fcom[x]+=1LL*imp[y].size()*w[use];
                fcom[y]+=1LL*imp[x].size()*w[use];
                for(auto per:imp[x]){
                        f[per]+=fcom[x]-fcom[y];
                        gr[per]=y;
                        imp[y].push_back(per);
                }
        }
        for(int i=1;i<=n;i++) cout<<f[i]+fcom[gr[i]]<<"\n";
}


Measured memory_bytes: 13944
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

struct para
{
    long long int w, v;
};

// 重さ 昇順
bool wasc(para a, para b)
{
    if (a.w < b.w)
        return true;

    return false;
}

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

    long long int  N, W;
    cin >> N >> W;

    vector<para> p(N);

    for (int i = 0; i < N; i++) cin >> p[i].w >> p[i].v;

    // 重さ 昇順
    sort(p.begin(), p.end(), wasc);

    // 重さ 4通り グループ分け
    vector<long long int> a, b, c, d;

    for (int i = 0; i < N; i++)
    {
        if (p[i].w == p[0].w) a.push_back(p[i].v);

        if (p[i].w == p[0].w + 1) b.push_back(p[i].v);

        if (p[i].w == p[0].w + 2) c.push_back(p[i].v);

        if (p[i].w == p[0].w + 3) d.push_back(p[i].v);
    }

    sort(a.begin(), a.end());
    sort(b.begin(), b.end());
    sort(c.begin(), c.end());
    sort(d.begin(), d.end());

    // 価値 降順
    reverse(a.begin(), a.end());
    reverse(b.begin(), b.end());
    reverse(c.begin(), c.end());
    reverse(d.begin(), d.end());

    // 価値 降順 累積和
    for (int i = 1; i < (signed)a.size(); i++) a[i] += a[i - 1];
    for (int i = 1; i < (signed)b.size(); i++) b[i] += b[i - 1];
    for (int i = 1; i < (signed)c.size(); i++) c[i] += c[i - 1];
    for (int i = 1; i < (signed)d.size(); i++) d[i] += d[i - 1];

    long long int ans = 0;
    for (int i = 0; i <= (signed)a.size(); i++)
    {
        for (int j = 0; j <= (signed)b.size(); j++)
        {
            for (int k = 0; k <= (signed)c.size(); k++)
            {
                // グループ A B C 重さ 合計
                long long int
                    wag = i * p[0].w + j * (p[0].w + 1) + k * (p[0].w + 2);

                // 制限超過
                if (wag > W) continue;

                // グループ D 数
                // グループ A B C 重さ 合計 から 算出
                long long int l = (W - wag) / (p[0].w + 3);

                if ((int)d.size() < l) l = d.size();

                long long int s = 0LL;

                if (i != 0LL) s += a[i - 1];

                if (j != 0LL) s += b[j - 1];

                if (k != 0LL) s += c[k - 1];

                if (l != 0LL) s += d[l - 1];

                if (s > ans) ans = s;
            }
        }
    }
    cout << ans;
    return 0;
}

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

int main() {
	string s;
	cin>>s;
	if(s[2]==s[3]&&s[4]==s[5]){
	    cout<<"Yes"<<endl;
	}
	else{
	    cout<<"No"<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧  
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     
　　　　／　　　＼　 　  |　|     
　　　 /　　 /￣￣￣￣/　　|  
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿  
　 　　　＼/＿＿＿＿/　（u　⊃  
---------------------------------------------------------------------------------------------------*/






int N, A, B;
//---------------------------------------------------------------------------------------------------
void _main() {
    cin >> N;
    if (N == 1) printf("Hello World\n");
    else {
        cin >> A >> B;
        int ans = A + B;
        printf("%d\n", ans);
    }
}

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

int main(){
    int N,a[10],i;
    scanf("%d",&N);
    for (i=0;i<N;i++) {
        scanf("%d", &a[i]);
    }
    int max=a[0];
    for (i=1;i<N;i++){
        if (a[i]>max){
            max=a[i];
        }
    }
    int total=0;
    int count=0;
    for (i=0;i<N;i++){
        if (a[i]==max&&count==0){
            a[i]=a[i]/2;
            count++;
        }
        total+=a[i];
    }
    printf("%d",total);
    return 0;
}

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

#define int int64_t

const int maxn = 80;

int n;
int a[maxn], ans[maxn];

signed main () {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	cin >> n;
	for (int i = 0; i < n; ++i) {
		cin >> a[i];
		ans[i] = 1000;
	}
	for (int i = 0; i < n; ++i) {
		for (int buy = i; buy < n; ++buy) {
			for (int sell = buy; sell < n; ++sell) 
				ans[sell] = max(max(max(ans[i], ans[buy]), ans[sell]), max(ans[i], ans[buy]) % a[buy] + (max(ans[i], ans[buy]) / a[buy]) * a[sell]);
		}
	}
	cout << ans[n - 1] << '\n';
}


Measured memory_bytes: 3644
#include <iostream>
#include <set>
#include <string>


int main(void){
	std::string s = "";
	int N = 0;
	std::set<std::string> goods;

	std::cin >> N;
	for(int i = 0; i < N; i++){
		std::cin >> s;
		goods.insert(s);
	}

	std::cout << goods.size() << std::endl;
	return 0;
}


Measured memory_bytes: 19208
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		int K = sc.nextInt();

		int sl = A + K ;
		int bl = B - K ;

		for(int i = 0 ; i <= B-A; i++) {
			if(A+i < sl || A+i > bl) {
				System.out.println(A+i);
			}
		}
	}

}


Measured memory_bytes: 21844
N = int(input())
A = [int(i) for i in input().split()]
B = [int(i) for i in input().split()]
if sum(A) < sum(B):
    print(-1)
else:
    num, fix = 0, 0
    for i in range(N):
        if A[i] - B[i] <  0:
            num += 1
            fix += B[i] - A[i]
    if num != 0:
        ret = []
        for i in range(N):
            if A[i] - B[i] > 0:
                ret.append(A[i] - B[i])
        ret.sort(reverse=True)
        su = 0
        for i in range(len(ret)):
            su += ret[i]
            num += 1
            if su >= fix:
                break
    print(num)

Measured memory_bytes: 18356
#include "bits/stdc++.h"
using namespace std;
#define mod 1000000007
#define all(c) begin(c),end(c)
template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
using ll = long long;
using vi = vector<int>; using vs = vector<string>;
int dd[] = { 0, 1, 0, -1, 0 }; //→↓←↑

void solve()
{
	int N;
	string S;
	cin >> N >> S;

	ll ans = 0;
	for (int i = 0; i < 1 << N; i++)
	{
		string A = "";
		string B = "";
		for (int j = 0; j < N; j++)
		{
			if ((i >> j & 1) == 1)
			{
				A += S[j];
			}
			else
			{
				B += S[j];
			}
		}
	/*	ll dp = new ll[A.size() + 1][];
		for (int j = 0; j < A.size() + 1; j++)
		{
			dp[j] = new ll[B.size() + 1];
		}*/
		//vector<vector<ll>> dp(A.size() + 1, vector<ll>(B.size() + 1));
		ll dp[20][20][2];
		dp[0][0][N % 2] = 1;

		for (int j = N; j < N + N; j++)
		{
			//vector<vector<ll>> next(A.size() + 1, vector<ll>(B.size() + 1));
			int p = j % 2;
			int q = (j + 1) % 2;
			for (int k = 0; k < A.size() + 1; k++)
			{
				for (int l = 0; l < B.size() + 1; l++)
				{
					dp[k][l][q] = 0;
				}
			}

			for (int k = 0; k < A.size(); k++)
			{
				if (S[j] == A[A.size() - k - 1])
				{
					for (int l = 0; l < B.size() + 1; l++)
					{
						dp[k + 1][l][q] += dp[k][l][p];
					}
				}
			}
			for (int k = 0; k < B.size(); k++)
			{
				if (S[j] == B[B.size() - k - 1])
				{
					for (int l = 0; l < A.size() + 1; l++)
					{
						dp[l][k + 1][q] += dp[l][k][p];
					}
				}
			}
		}
		ans += dp[A.size()][B.size()][0];
	}
	cout << ans << endl;
}

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0); cout.tie(0);
  int n; cin >> n;
  vector<int> a(n+1,-1);
  for(int i=1;i<=n;i++)
    cin >> a[i];
  int maxres = 0;
  int res = 0;
  for(int i=n;i>0;i--) {
    if (a[i] <= a[i-1]) {
      res++;
    } else {
      maxres = max(maxres,res);
      res = 0;
    }
  }
  cout << maxres;
  return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
#define PI acos(-1.0)
#define INF 1000000000
#define pow10 tipa_pow10
using namespace std;
const int mod = 1000 * 1000 * 1000 + 7;
int dpT[105][105][105];
int a , b , c;
int dp(int a , int b , int c)
{
    if(a == b && b == c)
        return 0;
    if(a > 100 || b > 100 || c > 100)
        return INF;
    if(dpT[a][b][c] != -1)
        return dpT[a][b][c];
    int ans = INF;
    ans = min(ans , 1 + dp(a + 2 , b , c));
    ans = min(ans , 1 + dp(a , b + 2 , c));
    ans = min(ans , 1 + dp(a  , b , c + 2));

    ans = min(ans , 1 + dp(a + 1 , b + 1 , c));
    ans = min(ans , 1 + dp(a , b + 1 , c + 1));
    ans = min(ans , 1 + dp(a + 1 , b , c + 1));
    return dpT[a][b][c] = ans;
}
int main()
{
    memset(dpT , -1 , sizeof dpT);
    ios_base::sync_with_stdio(0);
    cin >> a >> b >> c;
    cout << dp(a , b , c);

}



Measured memory_bytes: 4736
#!/usr/bin/env python3
while True:
    n, m, a = map(int, input().split())
    if n == 0:
        exit()
    hpq = sorted(list(map(int, input().split())) for _ in range(m))[::-1]
    for h, p, q in hpq:
        if a == p:
            a = q
        elif a == q:
            a = p
    print(a)




Measured memory_bytes: 5884
## coding: UTF-8
s = input().split()
t = [int(p) for p in s]

a = []
H = t[0]
W = t[1]
for i in range(H):
    a.append(input())

#上と下に入れる行を作る
b = ''
for i in range(W+2):
    b += '.'

#上と下と右と左に空きマスを挿入する
a.insert(0, b)
for i in range(1, 1+H):
    a[i] = '.' + a[i] + '.'
a.append(b)

#print(a)

def detect(l, h, w):
    answer = 'ng'
    dx = [1, -1, 0, 0]
    dy = [0, 0, 1, -1]
    for i in range(4):
        if(l[h + dy[i]][w + dx[i]] == '#'):
            answer = 'ok'
    return answer


final_answer = 'Yes'
for i in range(len(a)):
    for j in range(len(a[i])):
        if(a[i][j] == '#'):
            #print('i:{}, j:{}, answer:{}'.format(i,j,detect(a,i,j)))
            if(detect(a,i,j) == 'ng'):
                final_answer = 'No'

print(final_answer)



Measured memory_bytes: 3064
N,M = map(int,input().split())
a = set([i for i in range(1, N+1)])
H = [int(i) for  i in input().split()]
for i in range(M):
  A,B = map(int,input().split())
  if H[A-1]>H[B-1]: 
    a.discard(B)
  elif H[A-1]<H[B-1]:
    a.discard(A)
  else:
    a.discard(A)
    a.discard(B)
print(len(a))


Measured memory_bytes: 27400
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
typedef long long ll;
typedef unsigned int uint;
using namespace std;
typedef pair<int, int> P;

bool check(vector<int> v, int md) {
    vector <P> now;
    now.push_back(P(0, -1));
    for (int i = 0; i < v.size(); i++) {
        int t = now[now.size() - 1].first;
        if (t < v[i]) {
            now.push_back(P(v[i], 0));
        } else {
            for (;;) {
                P z = now[now.size() - 1];
                if (z.first > v[i]) {
                    now.pop_back();
                } else {
                    int x = v[i];
                    for (;;) {
                        if (x <= 0) {
                            return false;
                        }
                        if (now[now.size() - 1].first != x) {
                            now.push_back(P(x, 0));
                        }
                        if (now[now.size() - 1].second < md - 1) {
                            now[now.size() - 1].second++;
                            break;
                        } else {
                            x--;
                            now.pop_back();
                        }
                    }
                    break;
                }
            }
        }
    }
    return true;
}

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

    int n;
    cin >> n;
    vector<int> v;
    bool is_1 = true;
    for (int i = 0; i < n; i++) {
        int a;
        cin >> a;
        v.push_back(a);
        if (i > 0) {
            if (v[i-1] >= v[i]) {
                is_1 = false;
            }
        }
    }

    if (is_1) {
        cout << "1\n";
        return 0;
    }

    int bg = 2;
    int ed = 1000000005;
    while (bg < ed) {
        int md = (bg + ed) / 2;
        if (check(v, md)) {
            ed = md;
        } else {
            bg = md + 1;
        }
    }

    cout << bg << "\n";
    return 0;
}

Measured memory_bytes: 2868
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long n,a,b;
    cin>>n>>a>>b;
    if(n>1&&b>=a||n==1&&a==b)
        cout<<(n-2)*(b-a)+1<<endl;
    else
        cout<<0<<endl; 
    return 0; 
}

Measured memory_bytes: 256
def D():
    n, k = map(int, input().split())
    a = list(map(int, input().split()))
    next = a[0]
    path = [1]
    visited = [True] + [False]*(n-1)
    while not visited[next-1]:
        k -= 1
        if k==0:
            print(next)    
            break
        path.append(next)
        visited[next-1] = True 
        next = a[next-1]
    if k!=0:
        cyclic = path[path.index(next):]
        print(cyclic[k%(len(cyclic))-1])

D()

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

using namespace std;

#define INF 1001001001  //int32_t
#define MOD 1000000007
#define MOD2 

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

#define mkp make_pair
#define pb push_back

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

int main(){

    bool flag=false;
    ll ans=0,sum=0;

    int h,w;
    cin >>h>>w;

    vector<vector<int>> minmp(10,vector<int>(10,INF));

    for (int i = 0; i < 10; i++){
        for (int j = 0; j < 10; j++){
            int c;
            cin >>c;
            minmp[i][j] = c;
        }
    }

    for (int k = 0; k < 10; k++){
        //int ki=k/10,kj=k%10;

        for (int i = 0; i < 10; i++){
            for (int j = 0; j < 10; j++){
                //if(i==j)minmp[i][j]=0;

                minmp[i][j] = min(minmp[i][j],minmp[i][k] + minmp[k][j]);
            }
        }
    }
    
    /*
    for (int i = 0; i < 10; i++){
        for (int j = 0; j < 10; j++){
            printf("%6d ",minmp[i][j]);
        }
        puts("");
    }
    */

    for (int i = 0; i < h; i++){
        for (int j = 0; j < w; j++){
            int a;
            cin >>a;
            if(a == -1)continue;

            ans += minmp[a][1];
        }
        
    }
    

    //cout <<fixed<<setprecision(16)<< << endl;
    cout << ans << endl;

    //if(flag)cout << "Yes" <<endl;
    //else cout << "No" <<endl;
    
    return 0;
}


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

int f(long long a, long long b) {
    int d_a = 1;
    while (a / 10 != 0){
        d_a++;
        a /= 10;
    }

    int d_b = 1;
    while (b / 10 != 0){
        d_b++;
        b /= 10;
    }

    return max(d_a, d_b);
}



int main() {
  long long n;
  cin >> n;
  
  int ans = 1000000;
  for (int i = 1; i < 100010; i++) {
    if (n % i == 0) {
      ans = min(ans, f(i, n/i));
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define l long
#define pb push_back
#define mp make_pair
#define mt make_tuple
int main() {
	// your code goes here
	//ifstream cin("input.txt");
	//ofstream cout("output.txt");
	ios_base::sync_with_stdio(false); 
    cin.tie(NULL); 
	
	int n; cin>>n;
	cout<<n*n*n;
	
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
const int MOD=1000000007;
const int INF=1000000000;
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<ll,ll> P;
int N;
ll Z,W,a[2005];
ll ans=0;
priority_queue<ll,vector<ll> > Bluepq;
priority_queue<ll,vector<ll>,greater<ll> > Redpq;
int main(void)
{
  cin >> N >> Z >> W;
  for (int i = 1; i <= N; ++i)
    {
      cin >> a[i];
    }
  ans=max(ans,abs(a[N]-W));
  if(N>2)
    {
      ans=max(ans,abs(a[N]-a[N-1]));
    }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
N=int(input())
s=input()

sa=s[:N]
sb=s[N:]

import itertools
ALLIST=list(itertools.product((0,1),repeat=N))

from collections import defaultdict
STRA = defaultdict(int)
STRB = defaultdict(int)

for i in ALLIST:
    red_a=""
    blue_a=""
    red_b=""
    blue_b=""
    for j in range(N):
        if i[j]==0:
            red_a+=sa[j]
            red_b+=sb[j]
        else:
            blue_a+=sa[j]
            blue_b+=sb[j]

    STRA[(red_a[::-1],blue_a[::-1])]+=1
    STRB[(red_b,blue_b)]+=1

ANS=0
for key in STRA:
    ANS+=STRA[key]*STRB[key]

print(ANS)

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

#define ll long long
#define fi first
#define sec second

ll n,m,k,x,x2,y,y2,sol=0,rep,cnt,sad;
char c;
string s;
vector <ll> V;

int main()
{
    cin >> s;
    if (s[0]=='7' || s[1]=='7' || s[2]=='7') cout << "Yes";
    else cout << "No";
}


Measured memory_bytes: 3516
function main(input) {
  const inputs = input.trim().split('\n');
  var N = inputs[0];
  var nums = inputs[1].split(' ').map((n) => BigInt(n - 0));

  if (nums.indexOf(BigInt(0)) >= 0) {
    console.log(0);
    return;
  }

  var output = BigInt(1);
  for (var i = 0; i < nums.length; i++) {
    if ((('' + output).length + ('' + nums[i]).length) > 20) {
      console.log(-1);
      return;
    }
    output *= nums[i];
    if (output > Math.pow(10, 18)) {
      console.log(-1);
      return;
    }
  }
  console.log('' + output);
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 50300
#include <iostream>
using namespace std ;
int main ()
{
int sum=0;
int h,n,arr[100000];
cin>>h>>n;
for(int i =0;i<n;i++)
{
cin>>arr[i];
}
for(int j = 0 ; j < n ; j++)
{
	h-=arr[j];
}
if(h<=0)
	cout<<"Yes";
else 
	cout<<"No";
return 0 ;
}

Measured memory_bytes: 640
n,m,c=map(int,input().split())
b=list(map(int,input().split()))

cnt=0
for _ in range(n):
  a=list(map(int,input().split()))
  tmp=0
  for i in range(m):
    tmp+=a[i]*b[i]
  if tmp+c>0:
    cnt+=1
    
print(cnt)

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

long long GCD(long long a,long long b){
  long long A=a;
  a=max(a,b);
  b=min(A,b);
  while(b!=0){
    A=a;
    a=b;
    b=A%b;
    //cout<<a<<b;
  }
  return a;
}

int main() {
  long long N,M,a,c=0;
  cin>>N>>M;
  a=GCD(N,M);
  if(a==1){
    c=0;
  }
  //cout<<a;
 long double A=a;
  for(int i=1;i<=sqrt(a);i++){
    if(a%i==0){
      c++;
      while(a%i==0&&i!=1){
        a/=i;
        //cout<<a<<endl;
      }
      
    }
  }
  if(a!=1){
    c++;
  }
  cout<<c;
}

Measured memory_bytes: 256
import java.util.*;
import static java.lang.System.*;
public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(in);
        String s=sc.next();
        int n=s.length();
        int k=sc.nextInt();
        HashSet<String> set=new HashSet<>();
        for (int i = 1; i <=k; i++) {
            for (int j =1; j <= n+1-i; j++) {
                set.add(s.substring(j-1, i+j-1));
            }
        }
        String[] sub=new String[set.size()];
        set.clear();
        int c=0;
        for (int i = 1; i <= k; i++) {
            for (int j = 1; j <= n+1-i; j++) {
                int q1=set.size();
                set.add(s.substring(j-1, i+j-1));
                int q2=set.size();
                if(q1!=q2){
                    sub[c]=s.substring(j-1, i+j-1);
                    c++;
                }
            }
        }
        Arrays.sort(sub);
        out.println(sub[k-1]);
    }
}

Measured memory_bytes: 28736
#include <bits/stdc++.h>
using namespace std;
int main(){
    vector<int> v ={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    int k;
    cin>>k;
    cout<<v.at(k-1)<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MOD 1000000007
#define INF 1e9
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()

int main(){
    int sx,sy,tx,ty;
    cin>>sx>>sy>>tx>>ty;
    string ans;
    int ud=ty-sy;
    int lr=tx-sx;
    rep(i,ud){
        ans+='U';
    }
    rep(i,lr) ans+='R';
    rep(i,ud) ans+='D';
    rep(i,lr) ans+='L';
    ans+='L';
    rep(i,ud+1) ans+='U';
    rep(i,lr+1) ans+='R';
    ans+='D';
    ans+='R';
    rep(i,ud+1) ans+='D';
    rep(i,lr+1) ans+='L';
    ans+='U';
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#define _USE_MATH_DEFINES
#include <cmath>
#include<algorithm>
using namespace std;
int main()
{
    int a[10],i;
    for(i=0;i<10;i++)cin>>a[i];
    sort(a,a+10);
    for(i=9;i>6;i--)cout<<a[i]<<endl;
    return 0;
}

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

struct StCoin
{
  StCoin() :
    m_nCoin(0), m_nNum(0)
  { }
  StCoin(int nCoin, int nNum) :
    m_nCoin(nCoin), m_nNum(nNum)
  { }

  int m_nCoin;
  int m_nNum;
};

void fnInput(vector<StCoin>& rvoCoin, int& rnTrgKin)
{
  int nNum500, nNum100, nNum50;
  cin >> nNum500 >> nNum100 >> nNum50;

  int i = 0;
  StCoin oCoin500(500, nNum500);
  rvoCoin[i++] = oCoin500;
  StCoin oCoin100(100, nNum100);
  rvoCoin[i++] = oCoin100;
  StCoin oCoin50(50, nNum50);
  rvoCoin[i] = oCoin50;

  cin >> rnTrgKin;
}

void fnRcsSch(int nPos, int nTrgKin, const vector<StCoin>& cnrvoCoin, int& rnSuccess)
{
  if (!nTrgKin)
  {
    rnSuccess++;
    return;
  }
  if (nTrgKin < 0)              return;
  if (nPos == cnrvoCoin.size()) return;

  for (int i = 0; i <= cnrvoCoin[nPos].m_nNum; i++)
    fnRcsSch(nPos + 1, nTrgKin - cnrvoCoin[nPos].m_nCoin * i, cnrvoCoin, rnSuccess);
}

void fnExhSch(int nTrgKin, const vector<StCoin>& cnrvoCoin)
{
  int nSuccess = 0;
  fnRcsSch(0, nTrgKin, cnrvoCoin, nSuccess);
  cout << nSuccess << endl;
}

int main()
{
  vector<StCoin> voCoin(3);
  int nTrgKin;

  fnInput(voCoin, nTrgKin);
  fnExhSch(nTrgKin, voCoin);

  return 0;
}
 

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

int main(){
	int a,b;
	while(cin >> a >> b){
		int n = a + b;
		int cou = 0;
		while(n >= 10) {
			n = n / 10;
			++cou;
		}
		cout << cou+1 << endl;
	}
    return 0;
}

Measured memory_bytes: 1160
n=int(input())
a=list(map(int,input().split()))
if n%2==0:
	sta=[1,1]
	s=3
else:
	sta=[0]
	s=2

for i in range(s,n)[::2]:
	sta.append(i)
	sta.append(i)

if sorted(sta)!=sorted(a):
	print(0)
	exit()

i=int(n/2)
print(pow(2,i,10**9+7))

Measured memory_bytes: 13812
import java.util.Scanner;

public class Main {

	static int p,q,n,a,ans;;
	static double pq;
	public static void main(String[] args) {
		Scanner cin = new Scanner(System.in);
		while(true){
			p=cin.nextInt();
			q=cin.nextInt();
			a=cin.nextInt();
			n=cin.nextInt();
			if(p+q+a+n==0){
				break;
			}
			ans=0;
			pq = (double)p/(double)q;
			for(double i = 1;i<a;i++){
				a(1.0/i,(int)i,(int)i,1);
			}
			System.out.println(ans);
		}
	}
	static void a(double d,int e,int f,int count){
		//System.out.println(d+" " + e+" " +count);
		if(count>n){
			//System.out.println("return count");
			return;
		}
		if(sameDouble(pq,d)){
			ans++;
			//System.out.println("answer "+d+" " + e+" " +count);
			return;
		}
		else if(d>pq){
			//System.out.println("return "+d+" " + e+" " +count);
			return;
		}
		for(int i = f;i*e<=a;i++){
			a(1.0/(double)i+d,i*e,i,count+1);
		}
	}
	static boolean sameDouble(double a,double b){
		double c = 0.0000000001;
		return b<a+c&&a-c<b;
	}
}

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

int main(){
    int n;
    cin >> n;
    cout << n/2 + n%2 << endl;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
#define rep(i,n) for (int i=0;i<(n);++i)



bool check_bit(int mask, int pos) // pos ... zero-indexed.
{
    /*
     - check_bit(2(0010), 1) -> true
     - check_bit(1(0001), 1) -> false
     - check_bit(1(0001), 0) -> true
     */
    return ((mask & (1 << pos)) != 0) ? true : false;
}


int main()
{
    int v[4];
    rep(i, 4) v[i] = getchar() - '0';

    int mask_size = (1 << 3);
    for (int mask=0; mask<mask_size; ++mask) {
        int pre = v[0];
        for (int pos=0; pos<3; ++pos) {
            if (check_bit(mask, pos)) {
                pre -= v[pos+1];
            } else {
                pre += v[pos+1];
            }
        }
        if (pre == 7) {
            cout << v[0] << (check_bit(mask, 0)?'-':'+') <<
                    v[1] << (check_bit(mask, 1)?'-':'+') <<
                    v[2] << (check_bit(mask, 2)?'-':'+') <<
                    v[3] << "=7" << endl;
            return 0;
        }
    }

    return 1;
}

Measured memory_bytes: 256
import Control.Monad
import Control.Applicative
import Data.List

main = do
  xs <- map (map read . words) . lines <$> getContents
  mapM_ putStrLn $ map (\[x,y] -> show x ++ " " ++ show y) $ map gl xs

gcd' :: Int -> Int -> Int
gcd' a b
  | b == 0 = a
  | otherwise = gcd b ( a `mod` b )

gl :: [Int] -> [Int]
gl [a, b] = [g, a * b `div` g]
  where
    g = gcd' a b

Measured memory_bytes: 4088