akhauriyash/Code-Regression huggingface dataset:
a,b=map(int,input().split())
def gcd(a,b):
    if b==0:
        return a 
    return gcd(b,a%b)
g=gcd(a,b)

from math import sqrt as S
#print(gcd(a,b))
def get_div(x):
    if x==1:
        return [1]
    div=[1,x]
    for i in range(2,int(S(x))+1):
        if x%i==0:
            div.append(i)
            if i!=x//i:
                div.append(x//i)
    return div 
div=get_div(g)
p=10**6+5 
def sieve():
    l=[1]*p 
    i=2 
    while i*i<=p:
        if l[i]:
            for j in range(i*i,p,i):
                l[j]=0 
        i+=1 
    l[0]=0 
    return l 
isp=sieve()
cnt=0 
def pr(n):
    if n<=1:
        return 0 
    return all(n%i for i in range(2,int(S(n))+1))
for i in div:
    if i<=10**6:
        if isp[i]:
            cnt+=1 
    else:
        if pr(i):
            cnt+=1 
print(cnt)

Measured memory_bytes: 48236
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt(), q = sc.nextInt();
		String s = sc.next();
		int ac[] = new int[s.length() + 1];
		for (int i = 1; i < s.length(); i++) {
			ac[i] = s.charAt(i - 1) == 'A' && s.charAt(i) == 'C' ? 1 : 0;
		}
		int psa[] = new int[s.length() + 1];
		for (int i = 1; i <= s.length(); i++) {
			psa[i] = psa[i - 1] + ac[i];
		}

		for (int i = 0; i < q; i++) {
			int l = sc.nextInt(), r = sc.nextInt();
			System.out.println(psa[r - 1] - psa[l - 1]);
		}
	}

}


Measured memory_bytes: 59432
import java.util.Scanner;
import java.util.Stack;

class Main {

    public static void main(String[] args) {
        new Main().compute();
    }

    void compute() {
        Scanner sc = new Scanner(System.in);
        int A = sc.nextInt();
        int B = sc.nextInt();
        if (A == B) {
            System.out.println("Draw");
        } else if (B != 1 && (A == 1 || A > B)) {
            System.out.println("Alice");
        } else {
            System.out.println("Bob");
        }
    }
}


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

 int main()
 {
     char s[6];
     //cin>>s[6];
     int flag = 0;
     for(int i = 0; i < 6; i++)
     {
         cin>>s[i];
         if(s[i] == '1')
         {
             flag++;
         }
         else
         {
             continue;
         }
     }
     cout<<flag<<endl;
     return 0;
 }


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << x << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){return o<<"("<<p.fs<<","<<p.sc<<")";}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){o<<"sz = "<<vc.size()<<endl<<"[";for(const T& v:vc) o<<v<<",";o<<"]";return o;}

struct UnionFind{
	int par[2000],rank[2000],mn[2000];
	void init(int N){rep(i,N) par[i]=i,rank[i]=0,mn[i]=1e9;}
	int find(int x){
		if(par[x]==x) return x;
		return par[x]=find(par[x]);
	}
	bool same(int x,int y){
		return find(x)==find(y);
	}
	void unite(int x,int y){
		x=find(x),y=find(y);
		if(x==y) return;
		if(rank[x]<rank[y]) par[x]=y,chmin(mn[y],mn[x]);
		else{
			par[y]=x,chmin(mn[x],mn[y]);
			if(rank[x]==rank[y]) rank[x]++;
		}
	}
}UF;

int N;
const int MN=2000;
int A[MN];
bool used[MN];
int ans[MN];
typedef vector<int> VI;
map<int,VI> p2ids;
vector<int> r2vs[2000];

bool can[MN];
int gcd(int x,int y){
	if(y==0) return x;
	return gcd(y,x%y);
}
int main(){
	cin>>N;
	rep(i,N) cin>>A[i];
	sort(A,A+N);
	rep(i,N){
		int a=A[i];
		for(int x=2;x<=10000;x++){
			if(a%x==0){
				while(a%x==0) a/=x;
				p2ids[x].pb(i);
			}
		}
		if(a>1){
			p2ids[a].pb(i);
		}
	}
	rep(i,N) can[i]=1;
	rep(i,N){
		UF.init(N);
		for(auto it:p2ids){
			const VI& vc = it.sc;
			int r = -1;
			for(int v:vc) if(!used[v]){
				if(r!=-1) UF.unite(r,v);
				r=v;
			}
		}
		rep(v,N) r2vs[v].clear();
		rep(v,N) if(!used[v]) r2vs[UF.find(v)].pb(v);
		int mx=0,ag=-1;
		rep(r,N) if(!used[r] && !r2vs[r].empty()){
			VI& vs = r2vs[r];
			int mn=1e9,arg=-1;
			for(int v:vs) if(can[v]){
				if(mn>A[v]){
					mn=A[v];
					arg=v;
				}
			}
			assert(arg!=-1);
			if(mx<mn){
				mx=mn;
				ag=arg;
			}
		}
		ans[i]=ag;
		used[ag]=1;
		rep(j,N) if(!used[j]){
			if(gcd(A[ag],A[j])==1){
				if(A[ag]<A[j]) can[j]=0;
			}else{
				can[j]=1;
			}
		}
	}
	rep(i,N) cout<<A[ans[i]]<<" ";
	puts("");
}

Measured memory_bytes: 2816
#include <bits/stdc++.h>
#define ll long long int
#define forr(i,n) for(int i=0;i<n;i++)
#define mod 1000000007
#define oo 100000000000000000
using namespace std;

bool pairWise(vector<int> &v){
    unordered_map<int,int> m;
    int n = v.size();
    for(int i=n-1;i>=0;i--){
        int x = v[i];
        for(int j=2;j*j<=x;j++){
            if(x%j==0){
                if(m[j]>0) return false;
                else m[j]++;
                while(x%j==0) x = x/j;
            }
        }
        if(x!=1){
            if(m[x]>0) return false;
            else m[x]++;
        }
    }
    return true;
}


bool g1(vector<int> &v){
    int g = 0;
    for(auto &i: v) g = __gcd(g , i);
    return (g==1);
}

void _sol(){
    int n; cin >> n;
    vector<int> v(n);
    for(auto &i: v ) cin >> i;
    if(pairWise(v)) cout << "pairwise coprime";
    else if(g1(v)) cout << "setwise coprime";
    else cout << "not coprime";

}


int main() {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    _sol();
}


Measured memory_bytes: 7136
#include <bits/stdc++.h>
using namespace std;
#define rep(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(v) v.begin(), v.end()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using ll = long long;
const ll mod = 1e9+7; int INF=INT_MAX; ll LLINF = 1LL << 60;
const vector<int> d8x = {1, 0, -1, 0, 1, -1, -1, 1}; vector<int> d8y = {0, 1, 0, -1, 1, 1, -1, -1};
const vector<int> d4x = {1, 0, -1, 0}; vector<int> d4y = {0, 1, 0, -1};

//

int main(){
    ll n,m; cin>>n>>m;
    vector<ll> x(m);
    rep(i,0,m) cin>>x[i];
    if(n>=m){
        cout<<0<<endl;
        return 0;
    }
    sort(all(x));
    ll breadth=x[m-1]-x[0];
    vector<ll> dist(m-1);
    rep(i,1,m){
        dist[i-1]=x[i]-x[i-1];
    }
    sort(all(dist));
    reverse(all(dist));
    ll ans=breadth;
    rep(i,0,n-1){
        ans-=dist[i];
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 1792
from collections import deque
import sys
input = sys.stdin.readline
n,m = map(int,input().split())
l = [[] for i in range(n)]
for i in range(m):
  a,b = map(int,input().split())
  l[a-1].append(b-1)
  l[b-1].append(a-1)
visited = [-1]*n
deq = deque([0])
c = 0
visited[0] = 0
while deq:
  cur = deq.popleft()
  c += 1
  for i in l[cur]:
    if visited[i] == -1:
      deq.append(i)
      visited[i] = cur
if c == n:
  print('Yes')
  for i in visited[1:]:
    print(i+1)
else:
  print('No')

Measured memory_bytes: 92432
#include <bits/stdc++.h>
#define ld long double
#define endl "\n"
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb(x) push_back(x)
#define mp(a,b) make_pair(a,b)
#define ms(v,x) memset(v,x,sizeof(v))
#define all(v) v.begin(),v.end()
#define ff first
#define ss second
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define per(i, a, b) for(int i = b-1; i>=a ; i--)
#define trav(a, x) for(auto& a : x)
#define allin(a , x) for(auto a : x)
#define td(v) v.begin(),v.end()
#define sz(v) (int)v.size()
#define int long long
using namespace std;
typedef vector<int> vi;
#define y1 abacaba
#define left sefude
typedef long long ll;
typedef pair<int,int> pii;
inline ll mod(ll n, ll m ){ ll ret = n%m; if(ret < 0) ret += m; return ret; }
ll gcd(ll a, ll b){return (b == 0LL ? a : gcd(b, a%b));}
ll exp(ll a,ll b,ll m){
    if(b==0LL) return 1LL;
    if(b==1LL) return mod(a,m);
    ll k = mod(exp(a,b/2,m),m);
    if(b&1LL){
        return mod(a*mod(k*k,m),m);
    }
    else return mod(k*k,m);
}


int32_t main(){
  fastio;
  int n,k;
  cin>>n>>k;
  vector<int> v(n);
  for(int i=0;i<n;i++){
    cin>>v[i];
  }
  sort(all(v));
  int res=0;
  for(int i=0;i<k;i++){
    res+=v[i];
  }
  cout << res << endl;

  // Math -> gcd it all
  // Did u check N=1? Did you switch N,M?
}

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

int main(){
long long k;
  cin>>k;
  long long mod;
  mod=7;
  int count =1;
  for(int i=0;i<10000000;i++){

    if(i==9999999){
      cout<<-1<<endl;
    }

  else if(mod%k==0){
cout<<count<<endl;
      break;
    }
    else if(mod>k){
mod%=k;
    }
    else{
   mod*=10;
    mod+=7;
    count++;
  }
}
}


Measured memory_bytes: 3616
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
#define ll long long

int main(){
  int N;
  cin >> N;
  vector<int> l(N);
  for(int i=0; i<N; i++){
    cin >> l[i];
  }
  sort(l.begin(), l.end());
  ll ans=0;
  for(int i=N-1; i>=0; i--){
    for(int j=i-1; j>=0; j--){
      auto itr = lower_bound(l.begin(), l.end(), l[i]+l[j]);
      ll ng = distance(itr, l.end());
      ans += (N-1 - i) - ng;
    }
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("O3")
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
using P=pair<int,int>;
template<class T> using V=vector<T>; 
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
const ll inf=(1e18);
const ll mod=1000000007;
ll gcd(ll a,ll b) {return b ? gcd(b,a%b):a;}
ll lcm(ll c,ll d){return c/gcd(c,d)*d;}
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
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 (a>b) { a=b; return 1; } return 0; }
int main(){
  int num;
    num=10e6;

    V<bool>prime(num,true);
    prime[0]=false;
    for(int i=0;i*i<num;i++){
        if(prime[i]){
            for(int j=2;(i+1)*j<=num;j++){
                prime[(i+1)*j-1]=false;
            }
        }
    }
    int n;
    cin>>n;
    n--;
    for(int i=n;i<num;i++){
        if(prime[i]){
            cout<<i+1<<endl;
            return 0;
        }
    }
}


Measured memory_bytes: 1536
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <bitset>
#include <cmath>
#include <string>
#define FI first
#define SE second
#define VE vector<int>
#define PB push_back
#define PA pair<int,int>
#define MA make_pair
#define LL long long
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ROF(i,a,b) for(int i=b-1;i>=a;i--)
#define YES(i) cout<<(i?"YES":"NO")<<endl
#define Yes(i) cout<<(i?"Yes":"No")<<endl
using namespace std;
//
const int INF=1e9+7;
//
int main(){
  int H,W;
  int A[25][25];
  cin>>H>>W;
  FOR(i,0,H){
    FOR(j,0,W){
      cin>>A[i][j];
    }
  }
  int ans=INF;
  FOR(i,0,H){
    FOR(j,0,W){
      int cnt=0;
      FOR(k,0,H){
        FOR(l,0,W){
          cnt+=min(abs(i-k),abs(j-l))*A[k][l];
        }
      }
      ans=min(ans,cnt);
    }
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 3084
n = int(input())
al = list(map(int, input().split()))
al.sort()

c_sum = al[0]
cnt = 1
for a in al[1:]:
    if c_sum*2 >= a:
        c_sum += a
        cnt += 1
    else:
        c_sum += a
        cnt = 1

print(cnt)

Measured memory_bytes: 86168
#include<iostream>
#include<cstdio>
#include<cmath>
using namespace std;
int N;
int y[100],x[100];

int main(){
  for(int tc=1;;tc++){
    cin>>N;
    if(N==0)break;
    int ans=0;
    for(int i=0;i<=N;i++){
      if(i<N)cin>>x[i]>>y[i];
      else x[i]=x[0],y[i]=y[0];
      if(i)ans+=(x[i-1]*y[i])-(x[i]*y[i-1]);
    }
    cout<<tc<<' ';
    printf("%.1f\n",abs(ans*0.5));
  }
  return 0;
}

Measured memory_bytes: 1236
N, M = map(int,input().split())
l = [0]*(N+1)
for i in range (M):
    L, R = map(int,input().split())
    l[L - 1] += 1
    l[R] -= 1

for i in range (1, N):
    l[i] += l[i-1]

print (sum(1 for x in l if x == M))

Measured memory_bytes: 6900
#E A, B, C = gets.chomp.split.map(&:to_i)
S = gets.chomp.chars

# Detect `LR` address.
# Wa want to treat RR..RLL..L pairs

r = []
1.upto(S.size - 1).each do |i|
  if (S[i-1] == 'L') && (S[i] == 'R')
    r << i
  end
end

chunks = []
prevI = 0
r.each do |i|
  chunks << S[prevI..(i-1)]
  prevI = i
end
chunks << S[prevI..-1]

r = []
chunks.each do |chunk|
  firstL = -1
  0.upto(chunk.size - 1).each do |i|
    char = chunk[i]
    if char == 'L'
      firstL = i
      break
    end
  end
  
  odd = chunk.size / 2  # 1, 3, ..
  even = chunk.size - odd  # 0, 2, ..
  
  a = Array.new(chunk.size, 0)
  if (firstL % 2) == 0
    a[firstL] = even
    if firstL >=1
      a[firstL-1] = odd
    end
  else
    a[firstL] = odd
    if firstL >=1
      a[firstL-1] = even
    end
  end
  r << a
end

print r.map { |a| a.join(" ") }.join(" ")

Measured memory_bytes: 28156
import sys
from math import gcd

def solve(K: int):

    ans = 0

    for i in range(1, K+1):
        for j in range(1, K+1):
            for k in range(1, K+1):
                ans += gcd(gcd(i, j), k)

    print(ans)

    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    K = int(next(tokens))  # type: int
    solve(K)

if __name__ == '__main__':
    main()


Measured memory_bytes: 9052
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
#include<stdbool.h>
typedef long long ll;
typedef long double ld;
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define repp(i,l,r,k)for(ll i=(l);i<(r);i+=(k))
#define rrep(i,l,r)for(ll i=(l);i>=(r);i--)
#define INF (1LL<<60)
#define MOD1 1000000007
#define MOD2 998244353
#define MAX_N (1 << 17)
#define YES printf("Yes\n")
#define NO printf("No\n")
#define PN printf("\n")

void swap(ll *a, ll *b){ll c;c=*b;*b=*a;*a=c;}
ll max2(ll a,ll b){return a>=b?a:b;}
ll min2(ll a,ll b){return a>=b?b:a;}
ll min3(ll a, ll b, ll c){return (a<=b && a<=c) ? a : b<=c ? b : c;}
ll max3(ll a, ll b, ll c){return (a>=b && a>=c) ? a : b>=c ? b : c;}
ll minn(ll n, ll a[n]){ll b=INF;rep(i,0,n) b=min2(b,a[i]);return b;}
ll maxn(ll n, ll a[n]){ll b=-INF;rep(i,0,n) b=max2(b,a[i]);return b;}
ll ABS(ll a){return a>=0?a:(-a);}
ll POW(ll a, ll b){ll c=1;rep(i,0,b) c*=a;return c;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
ll mod(ll n){return n%=MOD1;}
int upll(const void*a, const void*b){return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;}
int downll(const void*a, const void*b){return*(ll*)a<*(ll*)b?1:*(ll*)a>*(ll*)b?-1:0;}
void sortup(ll*a,int n){qsort(a,n,sizeof(ll),upll);}
void sortdown(ll*a,int n){qsort(a,n,sizeof(ll),downll);}

typedef struct{ ll a , b;}fr;
int cmp1( const void *p, const void *q ) { return ((fr*)p) ->a - ((fr*)q)->a;}
int cmp2( const void *p, const void *q ) { return ((fr*)q) ->a - ((fr*)p)->a;}
void strsortup(fr*a,int n){qsort(a,n,sizeof(fr),cmp1);}
void strsortdown(fr*a,int n){qsort(a,n,sizeof(fr),cmp2);}

/*nが素数かどうか判定*/
ll judge_prime(ll n){
    if(n==2) return 1;
    if(n==1 || n%2==0) return 0;
    ll a=sqrt(n); if(a%2==0) a--;
    repp(i,3,a+1,2){if(n%i==0) return 0;}
    return 1;
}

int main(void){
    // char ;
    ll n,prime[55556]={};
    scanf("%lld",&n);
    // ll [n];
    rep(i,2,55556){
        if(judge_prime(i)&&i%5==1){
            prime[i]=1;
        }
    }
    ll j=0;
    rep(i,0,n){
        while(prime[j]==0){
            j++;
        }
        printf("%lld ",j);
        j++;
    }
    printf("\n");
    return 0;
}


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

#define REP(i,n) for(long long i = 0; i < (n); i++)
#define FOR(i, m, n) for(long long i = (m);i < (n); ++i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SPEED cin.tie(0);ios::sync_with_stdio(false);

template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
template<class T> using PQ = priority_queue<T>;
template<class T> using PQR = priority_queue<T,vector<T>,greater<T>>;

constexpr long long MOD = (long long)1e9 + 7;
constexpr long long MOD2 = 998244353;
constexpr long long HIGHINF = (long long)1e18;
constexpr long long LOWINF = (long long)1e15;
constexpr long double PI = 3.1415926535897932384626433;

template <class T> vector<T> multivector(size_t N,T init){return vector<T>(N,init);}
template <class... T> auto multivector(size_t N,T... t){return vector<decltype(multivector(t...))>(N,multivector(t...));}
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template <class T, class U>ostream &operator<<(ostream &o, const map<T, U>&obj) {o << "{"; for (auto &x : obj) o << " {" << x.first << " : " << x.second << "}" << ","; o << " }"; return o;}
template <class T>ostream &operator<<(ostream &o, const set<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const multiset<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const vector<T>&obj) {o << "{"; for (int i = 0; i < (int)obj.size(); ++i)o << (i > 0 ? ", " : "") << obj[i]; o << "}"; return o;}
template <class T, class U>ostream &operator<<(ostream &o, const pair<T, U>&obj) {o << "{" << obj.first << ", " << obj.second << "}"; return o;}
template <template <class tmp>  class T, class U> ostream &operator<<(ostream &o, const T<U> &obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr)o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
void print(void) {cout << endl;}
template <class Head> void print(Head&& head) {cout << head;print();}
template <class Head, class... Tail> void print(Head&& head, Tail&&... tail) {cout << head << " ";print(forward<Tail>(tail)...);}
template <class T> void chmax(T& a, const T b){a=max(a,b);}
template <class T> void chmin(T& a, const T b){a=min(a,b);}
void YN(bool flg) {cout << (flg ? "YES" : "NO") << endl;}
void Yn(bool flg) {cout << (flg ? "Yes" : "No") << endl;}
void yn(bool flg) {cout << (flg ? "yes" : "no") << endl;}

int main() {
	ll x;
	double p;
	cin >> x >> p;
	p /= 100.;
	printf("%.10f",(x+1)/2/p);

	return 0;
}


Measured memory_bytes: 256
while True:
    m,f,r=map(int,input().split())
    if(m == -1 and f == -1 and r == -1):
        break
    elif(m==-1 or f == -1):
        print("F")
    elif(m+f >= 80):
        print("A")
    elif(m+f >= 65):
        print("B")
    elif(m+f >= 50):
        print("C")
    elif(m+f >= 30):
        if(r >= 50):
            print("C")
        else:
            print("D")
    elif(m+f < 30):
        print("F")


Measured memory_bytes: 5592
import scala.math.{min,max}

object Main {
    def main(args: Array[String]) {
        var input = io.Source.stdin.getLines().mkString("\n");
        var ss = input.split('\n').toList;
        val xs = to_array_int(ss(0));
        val n = xs(0);
        val m = xs(1) - 1;
        var s = ss(1).toArray;
        s(m) = s(m).toLower;
        println(s.mkString(""));
    }
    def to_array_int(s: String): Array[Int] = {
        return s.split(' ').map(_.toInt).toArray;
    }
}


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


#include <assert.h>    // LON
#include <math.h>    // sqrt()


using namespace std;
#define rep(i, n) for (ll i = 0; i < (n); ++i)
//#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) ll(x.size())
typedef long long ll;
//typedef pair<int, int> P;
typedef pair<ll, ll> P;
//const double INF = 1e10;
const ll INF = LONG_LONG_MAX;
const ll MINF = -10e10;
//const int INF = INT_MAX;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)


//ifstream myfile("C:\\Users\\riku\\Downloads\\0_00.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);

//typedef priority_queue<P, vector<P>, greater<P>> PQ_ASK;
const int mod = 1000000007;


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

    vector<int> ball(n);

    rep(i, n) {
        cin >> ball[i];
    }

    int ans = 0;

    for (int b : ball) {
        int i = abs(b - k);
        int j = b;

        int l = min(i, j);
        ans += l + l;
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
def main():
    N, K = map(int, input().split())
    h = list(map(int, input().split()))

    DP = [10**10 for _ in range(N)]
    DP[0] = 0
    DP[1] = abs(h[0]-h[1])
    
    for i in range(2, N):
        DP[i] = min(DP[k]+abs(h[i]-h[k]) for k in range(max(0, i-K), i))    
    print(DP[N-1])
main()

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

void mkprimes(int64_t N, vector<int64_t> &primes) {
  vector<bool> isprime(N + 1);
  for (int64_t i = 0; i <= N; i++) {
    isprime[i] = true;
  }
  isprime[0] = false;
  isprime[1] = false;

  for (int64_t i = 2; i <= N; i++) {
    if (isprime[i]) {
      primes.push_back(i);
      for (int64_t j = 2 * i; j <= N; j += i) {  // 素数iの倍数は素数ではない
        isprime[j] = false;
      }
    }
  }
}

int main() {
  int64_t N;
  cin >> N;
  map<int64_t, int64_t> uniq;
  // map<int, int> uniq;
  for (int64_t i = 0; i < N; i++) {
    int64_t x;
    cin >> x;
    if (uniq.count(x) == 0) {
      uniq[x] = 0;
    }
    uniq[x]++;
  }

  // エラトステネスのふるい風味
  vector<int64_t> search;
  unordered_set<int64_t> isprime;
  for (auto x : uniq) {
    search.push_back(x.first);
    isprime.insert(x.first);
  }

  sort(search.begin(), search.end());
  int64_t maxnum = search[search.size() - 1];

  vector<int64_t> primes;
  for (auto s : search) {
    if (isprime.count(s) > 0) {
      primes.push_back(s);
      for (int64_t j = 2 * s; j <= maxnum; j += s) {
        isprime.erase(j);
      }
    }
  }

  int64_t result = 0;
  for (auto pr : primes) {
    if (uniq.at(pr) == 1) {
      result++;
    }
  }
  cout << result << endl;
}


Measured memory_bytes: 28484
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
int main() {
 int H,W;
 cin>>H>>W;
 char s[100][100];
 for(int i=1;i<=H;i++){
     for(int j=1;j<=W;j++){
         cin>>s[i][j];
     }
 }
 for(int i=1;i<=H;i++){
     for(int j=1;j<=W;j++){
         int count=0;
         if(s[i][j]=='#'){continue;}
         else if(s[i][j]=='.'){
             
             if(s[i+1][j]=='#'){count++;}
             if(s[i-1][j]=='#'){count++;}
             if(s[i][j+1]=='#'){count++;}
             if(s[i][j-1]=='#'){count++;}
             if(s[i+1][j+1]=='#'){count++;}
             if(s[i+1][j-1]=='#'){count++;}
             if(s[i-1][j+1]=='#'){count++;}
             if(s[i-1][j-1]=='#'){count++;}
             }
             s[i][j]=(char)(count+'0');
     }
 }
  for(int i=1;i<=H;i++){
     for(int j=1;j<=W;j++){
         cout<<s[i][j];}
         cout<<endl;
  }
 return 0;}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll MOD = 1000000007;
ll INFL = 1ll << 60;
ll INF = 1 << 30;

int main() {
  vector<int> v(4, 0);
  int a;
  for (int i = 0; i < 6; i++) {
    cin >> a;
    v[a - 1]++;
  }
  bool ans = true;
  for (int i = 0; i < 4; i++) {
    if (v[i] >= 3)
      ans = false;
  }

  cout << (ans ? "YES" : "NO") << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define SORT(a) sort(a.begin(), a.end())
#define RSORT(a) sort(a.rbegin(), a.rend())
#define REP(i, n) for (int i = 0; i < n; i++)
#define RREP(i, n) for (int i = n; 0 <= i; i--)
#define FOR(i, start, end) for (int i = start; i < end; i++)
#define RFOR(i, start, end) for (int i = start; end <= i; i--)
#define ALL(a) a.begin(), a.end()
#define MOD(a) a %= 1'000'000'007
#define INF32 1'050'000'000
#define INF64 4'000'000'000'000'000'000
using ll = long long;
using namespace std;
template <class T> inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

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

    int N;
    cin >> N;
    string a, b, c;
    cin >> a >> b >> c;
    int ans = 0;
    REP(i, N) {
        if (a[i] == b[i] && b[i] == c[i]) {

        } else if (a[i] == b[i] || b[i] == c[i] || c[i] == a[i])
            ans++;
        else
            ans += 2;
    }

    std::cout << ans << '\n';

    return 0;
}

Measured memory_bytes: 256
use std::io;
use std::io::prelude::*;
fn main() {
    let stdin = io::stdin();
    let s1 = readline(&stdin);
    let s2 = readline(&stdin);
    
    let v1: Vec<u32> = s1.split(' ').map(|x| x.parse().expect("parse error")).collect();
    let mut v2: Vec<u32> = s2.split(' ').map(|x| x.parse().expect("parse error")).collect();
    v2.sort();
    let mut x:u32 = v1[1];
    let n = v1[0];
    let mut counter = 0;
    for i in v2 {
        if x < i {
            break;
        }
        x = x - i;
        counter = counter + 1;
    }
    if x > 0  && counter == n{
        counter = counter - 1;
    }
    
    println!("{}", counter);
}

fn readline(stdin: &io::Stdin) -> String {
    stdin.lock().lines().next()
                .expect("input error").unwrap()
}

Measured memory_bytes: 4352
program c20829

implicit none
integer(16) :: a, b, c, d, e, n, a1, b1, c1, d1, e1, a2, b2, c2, d2, e2, z

n = 0

read *, a
read *, b
read *, c
read *, d
read *, e

a1 = mod(a, 10)
b1 = mod(b, 10)
c1 = mod(c, 10)
d1 = mod(d, 10)
e1 = mod(e, 10)

!print *, a1, b1, c1, d1, e1

!stop

z = 10

if(z > a1 .and. a1 .ne. 0) then
 z = a1
end if

if(z > b1 .and. b1 .ne. 0) then
 z = b1
end if

if(z > c1 .and. c1 .ne. 0) then
 z = c1
end if

if(z > d1 .and. d1 .ne. 0) then
 z = d1
end if

if(z > e1 .and. e1 .ne. 0) then
 z = e1
end if

!print *, z

n = n + ceiling(real(a)/10) * 10
n = n + ceiling(real(b)/10) * 10
n = n + ceiling(real(c)/10) * 10
n = n + ceiling(real(d)/10) * 10
n = n + ceiling(real(e)/10) * 10
n = n - 10 + z

print *, n

end program c20829

Measured memory_bytes: 2764
#include <iostream>
#include <vector>
#include <map>
using namespace std;

const int divisor = 1000000007;

int main(){
	vector<int> ansvec;

	// 100000!までの数をdivisorで割った余りを格納しておく
	int* factmodary = new int[100001];
	long long fact = 1;
	for (int i = 1; i <= 100000; i++){
		fact *= i;
		fact %= divisor;
		factmodary[i] = (int)fact;
	}

	for (;;){
		int N, R;
		cin >> N;
		if (N == 0) break;
		cin >> R;

		int* word = new int[N];
		for (int i = 0; i < N; i++) word[i] = i + 1; //まず0番目の単語を入れておく

		for (int i = 0; i < R; i++){
			int s, t;
			cin >> s >> t;
			/* swap */
			int tmp = word[s - 1]; word[s - 1] = word[t - 1]; word[t - 1] = tmp;
		}

		//word[i]をkey, word[i]より小さい数がそれ以前にいくつ使われていたかをvalueとして格納するmap
		map<int, int> bubblehist;
		bubblehist[word[0]] = 0;

		long long ans = factmodary[N-1] * (word[0] - 1);

		for (int i = 1; i < N; i++){
			int facttime = word[i] - 1;
			int bubblenum;
			map<int, int>::iterator it = bubblehist.lower_bound(word[i]);

			if (it != bubblehist.end()){
				bubblenum = it->second;
			}
			else {
				bubblenum = bubblehist.rbegin()->second + 1;
			}
			pair<int, int> p;
			p.first = word[i];
			p.second = bubblenum;
			bubblehist.insert(--it, p);
			for (map<int, int>::iterator it2 = bubblehist.upper_bound(word[i]); it2 != bubblehist.end(); it2++) ++(it2->second);

			facttime -= bubblenum;
			ans += (long long)factmodary[N - (i + 1)] * facttime;
			ans %= divisor;
		}

		delete[] word;
		ansvec.push_back((int)ans);
	}

	for (vector<int>::iterator it = ansvec.begin(); it != ansvec.end(); it++){
		cout << *it << endl;
	}

	delete[] factmodary;
	return 0;
}

Measured memory_bytes: 6552
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define until(x) while(!(x))
#define unless(x) if(!(x))
#define all(x) (x).begin(),(x).end()
#define mp make_pair
#define F first
#define S second


int32_t main(){
	int h,n,ans=0,t;
	cin>>h>>n;
	while(n--){
		cin>>t;
		ans+=t;
	}
	if(ans>=h){
		cout<<"Yes";
	}
	else {
		cout<<"No";
	}
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <functional>
#include <bitset>
#include <numeric>
#include <complex>
#include <cassert>
#include <random>
using namespace std;
using ll = long long;

int main() {
	ll n; cin >> n;
	if (n == 2) {
		cout << 1 << endl;
		return 0;
	}
	ll ans = 0;
	for (ll i = 1; i*i <= n; i++) {
		if ((n - 1) % i == 0) {
			ans += (i > 1) + (i*i != n - 1);
		}
	}
	vector<ll> divs;
	for (ll i = 2; i*i <= n; i++) {
		if (n%i == 0) {
			divs.push_back(i);
			if (i*i != n) divs.push_back(n / i);
		}
	}
	divs.push_back(n);
	for (ll d : divs) {
		ll w = n;
		while (w%d == 0) {
			w /= d;
		}
		ans += w%d == 1;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 384
#include <stdio.h>
using namespace std;

int main()
{
  char ch;
  int counter[26] = {0};
  while ((ch = getchar()) != EOF)
  {
    if (ch >= 'A' && ch <= 'Z') {
      ch = ch + 32;
    }
    if (ch >= 'a' && ch <= 'z')
    {
      int num = ch - 'a';
      counter[num]++;
    }
  }
  for (int i = 0; i < 26; i++)
  {
    printf("%c : %d\n", i + 'a', counter[i]);
  }
  return 0;
}


Measured memory_bytes: 2688
#include<stdio.h>
#include<string.h>
int main()
{
	long long int i=0,a=100,b;
	scanf("%lld", &b);
	while (a < b)
	{
		a=a*1.01;
		i++;
	}
	printf("%lld", i);
	return 0;
}

Measured memory_bytes: 1728
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int a[] = new int[3];
    for (int i = 0; i < 3; i++){
      a[i] = sc.nextInt();
    }
    Arrays.sort(a);
    System.out.println(a[2]-a[0]);
  }
}


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

int main(){
  int N;
  cin>>N;
  vector<int> kokuban(N);
  for(int i=0; i<N; i++){
    int A;
    cin>>A;
    kokuban.at(i)=A;
  }
  int count=0;
  int amari=0;
  bool even=true;
  while(even){
    for(int i=0; i<N; i++){
      amari+=kokuban.at(i)%2;
      if(amari==0){
        kokuban.at(i)=kokuban.at(i)/2;
      }
      else{
        amari++;
        break;
      }
    } //i
    if(amari==0){
      count++;
    }
    else{
      even=false;
    }
  } //while
  cout<<count<<endl;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using P = pair<int, int>;
#define PI acos(-1)
#define Mod (int)1000000007
#define Rep(i, n) for (int i = 0; i < (int)(n); i++)
#define BitRep(i, n) for (int i = 0; i < (int)(1 << n); i++)
#define All(vec) vec.begin(), vec.end()
#define Sum(vec) accumulate(vec.begin(), vec.end(), 0)
#define Sort(vec) sort(vec.begin(), vec.end())
#define Reverse(vec) reverse(vec.begin(), vec.end())
#define Count(vec, x) count(vec.begin(), vec.end(), x)
#define Next_permutation(vec) next_permutation(vec.begin(), vec.end())
#define Find(S, s) S.find(s) != string::npos

int main() {
    int N;
    cin >> N;
    vector<double> p(N);
    Rep(i, N) cin >> p[i];
    vector<vector<double>> dp(N + 1, vector<double>(N + 1));
    dp[0][0] = 1;
    Rep(i, N) {
        Rep(j, i + 1) {
            dp[i + 1][j + 1] += dp[i][j] * p[i];
            dp[i + 1][j] += dp[i][j] * (1.0 - p[i]);
        }
    }
    double ans = 0.0;
    for (int i = N / 2 + 1; i <= N; i++) {
        ans += dp[N][i];
    }
    printf("%.9f\n", ans);
    return 0;
}

Measured memory_bytes: 73700
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <string>
#include <cmath>
#include <iomanip>
#include <numeric>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())
#define INF (ll)1e18
#define MOD (ll)1e9 + 7

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> V;
typedef map<int, int> M;

int main()
{
    int N, K, a[112345];
    ll sum[112345], sump[112345];

    cin >> N >> K;

    sum[0] = 0;
    sump[0] = 0;

    REP(i, N)
    {
        cin >> a[i];
        sum[i + 1] = sum[i] + a[i];
        sump[i + 1] = sump[i] + max(0, a[i]);
    }

    ll res = 0;
    for (int i = 0; i < N - K + 1; i++)
    {
        ll other = sump[N] - (sump[i + K] - sump[i]);
        ll black = sum[i + K] - sum[i];

        if (black > 0)
            res = max(res, other + black);
        else
            res = max(res, other);
    }

    cout << res << endl;

    return 0;
}

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

int power(int a, int n) {
    int res = 1;
    while (n > 0) {
        if (n & 1) res = res * a;
        a = a * a;
        n >>= 1;
    }
    return res;
}

int keta(int N) {
  int j = 0;
  for (int i = 0; i <= 7; i++) {
    if (N >= power(10,i) && N < power(10,i+1)) {
      j = i + 1;
      break;
    }
  }
  return j;
}
    

int main() {
  int N;
  cin >> N;
  int cnt = 0;
  for(int i = 1; i <= N; i++) {
    if (keta(i) % 2 == 1) cnt++;
  }
  cout << cnt << endl;
}


Measured memory_bytes: 3612
import java.util.*;
import java.lang.Math;

public class Main{
	public static void main(String args[]){
		Scanner sc = new Scanner(System.in);
		double r = sc.nextDouble();
		System.out.printf("%.6f %.6f\n", r * r * Math.PI, r * 2 * Math.PI);
	}
}




Measured memory_bytes: 28216
#include<iostream>

using namespace std;

int main(){

    int A, B;
    int tmp = 0;

    cin >> A >> B;

    tmp = A + B;

    if(tmp < A * B){
        tmp = A * B;
    }
    
    if(tmp < A - B){
        tmp = A - B;
    }

    cout << tmp << endl;

    return 0;
}

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

namespace Program
{
    public class ABC080D
    {
        static class Console_
        {
            private static Queue<string> param = new Queue<string>();
            public static int NextInt() => int.Parse(NextString());
            public static long NextLong() => long.Parse(NextString());
            public static string NextString()
            {
                if (param.Count == 0) foreach (var item in Console.ReadLine().Split(' ')) param.Enqueue(item);
                return param.Dequeue();
            }
        }
        static public void Main(string[] args)
        {
            var N = Console_.NextInt();
            var C = Console_.NextInt();

            var time = new uint[100000];
            for (int i = 0; i < N; ++i)
            {
                var s = Console_.NextInt();
                var t = Console_.NextInt();
                var c = Console_.NextInt();
                var mask = (uint)1 << (c - 1);
                time[s - 1] ^= mask;
                time[t - 1] ^= mask;
            }

            var maxCh = 0;
            uint state = 0;
            for (int i = 0; i < 100000; ++i)
            {
                var chk = state | time[i];
                state ^= time[i];
                var chCount = 0;
                uint mask = 1;
                for (int j = 0; j < 30; ++j)
                {
                    if ((chk & mask) != 0) ++chCount;
                    mask <<= 1;
                }
                if (maxCh < chCount) maxCh = chCount;
            }

            Console.WriteLine(maxCh);
        }
    }
}


Measured memory_bytes: 15456
#include<cstdio>


int ans[1024];
int w,h,k;
bool b[22][22];//??°???

int d(int,int);

int main(void){
  int i,j;
  char c[20][20];
  int p,q;//???????????§?¨?

    k =0;
  while(true){
    //??\???
    scanf("%d%d",&w,&h);
    if(w==0 && h==0)break;
    
    for(i=0;i<h;i++){
	scanf("%s",c[i]);
//printf("%d,%s\n",i,c[i]);
      }
//printf("%c\n",c[0][1]);
    for(i=0;i<h;i++){
      for(j=0;j<w;j++){
        if(c[i][j] =='@'){
            p=i;
            q=j;
        }
          if(c[i][j] =='#'){
              b[i][j] = false;
            
          }else {
              b[i][j] = true;
          }
      }
    }
      ans[k] = 1;
      //printf("Ok");
    d(p,q);
      k++;
  }
    for (i=0;i<k;i++){
        printf("%d\n",ans[i]);
    }
  return 0;
}
int d(int p,int q){
  int i,j,p1,q1;
    b[p][q]  = false;
  for(i=0;i<4;i++){
    if(i==0){
      p1=p+1;
      q1=q;
    } else if(i==1){
      p1=p-1;
      q1=q;
    }else if(i==2){
      p1=p;
      q1=q+1;
    }else {
      p1=p;
      q1=q-1;
    }
    if(p1>=0 && p1<h && q1>=0 && q1<w){
      if(b[p1][q1] == true){
	ans[k]++;
          
        d(p1,q1);
      }
    }
  }
  return 0;
}
     
	

Measured memory_bytes: 2588
from collections import deque

N = int(input())
graph = [[] for _ in range(N)]
for i in range(N):
  X = list(map(int, input().split()))
  for j in range(2, len(X)):
    graph[i].append(X[j]-1)
    
dist = [-1] * N
dist[0] = 0

q = deque([])
q.append(0)

while q:
  x = q.popleft()
  for next_x in graph[x]:
    if(dist[next_x] > -1):
      continue
    dist[next_x] = dist[x] + 1
    q.append(next_x)
    
for i in range(N):
  print(i+1, dist[i])


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


int main()
{
	//freopen("in.txt","r",stdin);
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	long long int n,m,k;
    cin>>n>>m>>k;
    long long int arr[n];
    long long int brr[m];
    long long int x;
    long long int count=0;
    for(long long int i=0;i<n;i++)
    {
        cin>>x;
        if(i==0)
        arr[i]=x;
        else
        {
            arr[i]=arr[i-1]+x;
        }
        if(arr[i]<=k)
        count = max(count,i+1);
    }
    for(long long int i=0;i<m;i++)
    {
        cin>>x;
        if(i==0)
        brr[i]=x;
        else
        {
            brr[i]=brr[i-1]+x;
        }
        if(brr[i]<=k)
        count=max(count,i+1);
    }
    for(long long int i=0;i<n;i++)
    {
        if(arr[i]<k)
        {
            long long int index = upper_bound(brr,brr+m,k-arr[i])-brr;
            count = max(count,i+1+index);
        }
    }
    cout<<count<<"\n";
   

		

	return 0;
}

Measured memory_bytes: 6772
a, b, c, d = map(int, input().split())

t = [0]*101
for i in range(a, b):
    t[i] += 1

for i in range(c, d):
    t[i] += 1

ans = 0
for _t in t:
    if _t == 2:
        ans += 1
print(ans)


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

const int MAXN = 55;
const int MAXK = 2505;
const int MOD = 1000000007;

int n, k, dp[MAXN][MAXN][MAXK];
int main(){
	scanf("%d %d", &n, &k);
	
	if(k % 2 == 1){
		printf("0\n");
		return 0;
	}
	k /= 2;
	
	for(int i = n; i >= 0; i--)
	for(int j = 0; j <= i; j++)
	for(int r = 0; r <= k; r++){
		if(i == n){
			if(j == 0 && r == 0)dp[i][j][r] = 1;
			else dp[i][j][r] = 0;
		}else{
			dp[i][j][r] = 0;
			if(r >= j){
				dp[i][j][r] = (dp[i][j][r] + dp[i + 1][j][r - j]) % MOD;
				dp[i][j][r] = (dp[i][j][r] + 2LL * j * dp[i + 1][j][r - j]) % MOD;
			}
			if(r >= j + 1){
				dp[i][j][r] = (dp[i][j][r] + dp[i + 1][j + 1][r - (j + 1)]) % MOD;
			}
			if(j > 0 && r >= j - 1){
				dp[i][j][r] = (dp[i][j][r] + 1LL * j * j * dp[i + 1][j - 1][r - (j - 1)]) % MOD;
			}
		}
	}
	
	printf("%d\n", dp[0][0][k]);
	
	return 0;
}


Measured memory_bytes: 27008
# -*- coding: utf-8 -*-
a,b = list(map(int,input().split()))
#最大公約数

#最大公約数
import fractions
abgcd = fractions.gcd(a, b)

def prime_factorize(N):
    #素因数分解
    from collections import defaultdict
    factorize = defaultdict(int)
    while N%2 == 0:
        factorize[2]+=1
        N //= 2
    i=1
    while i*i <=N:
        i += 2
        if N%i: continue
        while N%i == 0:
            factorize[i] += 1
            N //= i
    if N!=1:factorize[N]=1
    return factorize

print(len(prime_factorize(abgcd).keys())+1)

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

using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define debug(x) cout << #x << ": " << x << endl
#define out(x) cout << x << endl
//#define int long long int
const int MOD = 1000000007;
const ll LINF = (ll)1e18 - 1;
const int INF = 1e9 - 1;
const double EPS = 0.000000001;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

void print(const vector<int> &v) {
  for(auto x : v) {
    cout << x << " ";
  }
  cout << endl;
}

signed main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  VI a(n);
  rep(i,n) cin >> a[i];
  int ans = 0;
  rep(i,n) {
    while(a[i] % 2 == 0) {
      ans++;
      a[i] >>= 1;
    }
  }
  out(ans);
  return 0;
}


Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Scanner;

class Ope{
	int h1, w1, h2, w2;
	public Ope(int H1, int W1, int H2, int W2) {
		h1 = H1; w1 = W1; h2 = H2; w2 = W2;
	}
}
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int H = sc.nextInt(), W = sc.nextInt();
		int[][] a = new int[H][W];
		for(int i = 0; i < H; i++) for(int j = 0; j < W; j++) a[i][j] = sc.nextInt();
		ArrayList<Ope> operation = new ArrayList<Ope>();
		for(int i = 0; i < H; i++) {
			for(int j = 0; j < W; j++) {
				if(a[i][j] % 2 == 0) continue;
				if(j + 1 < W) {
					a[i][j]--;
					a[i][j + 1]++;
					operation.add(new Ope(i + 1, j + 1, i + 1, j + 2));
				}else if(i + 1 < H){
					a[i][j]--;
					a[i + 1][j]++;
					operation.add(new Ope(i + 1, j + 1, i + 2, j + 1));
				}
			}
		}
		System.out.println(operation.size());
		for(Ope op : operation) {
			System.out.println(op.h1+" "+op.w1+" "+op.h2+" "+op.w2);
		}
	}
}

Measured memory_bytes: 101232
f = lambda:map(int,input().split())
n,k = f()
x = list(f())
d = 10**9
for i in range(n-k+1):
  l,r = x[i],x[i+k-1]
  d = [min(d,max(-l,r)),min(d,(r-l)+min(-l,r))][l<0<r]
print(d)

Measured memory_bytes: 14096
// atcoder/abc051/C/main.cpp
// author: @___Johniel
// github: https://github.com/johniel/

#include <bits/stdc++.h>

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

typedef long long int lli;
typedef unsigned long long ull;
typedef complex<double> point;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << "," << p.second << ")"; return os; }
template<typename P, typename Q> istream& operator >> (istream& is, pair<P, Q>& p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; each (i, v) os << i << ","; os << ")"; return os; }
template<typename T> istream& operator >> (istream& is, vector<T>& v) { each (i, v) is >> i; return is; }

template<typename T> inline T setmax(T& a, T b) { return a = std::max(a, b); }
template<typename T> inline T setmin(T& a, T b) { return a = std::min(a, b); }

int main(int argc, char *argv[])
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);

  int si, sj, ti, tj;
  while (cin >> si >> sj >> ti >> tj) {
    cout << string(ti - si, 'R') + string(tj - sj, 'U') + string(ti - si, 'L') + string(tj - sj, 'D') +
      "D" +
      string(ti - si + 1, 'R') + string(tj - sj + 1, 'U') + "LU" + string(ti - si + 1, 'L') + string(tj - sj + 1, 'D') +
      "R"
         << endl;

  }

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define P pair<int,int>
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<n;i++)
#define all(v) v.begin(),v.end()
#define pb push_back
template<class T>void chmax(T &a,T b){if(a<b)a=b;}
template<class T>void chmin(T &a,T b){if(a>b)a=b;}
constexpr int INF=1000000000000000000;
constexpr int mod=1000000007;
int dx[]={0,1,0,-1},dy[]={1,0,-1,0};
int kaijo[2000010];
int gcd(int a,int b){
    if(b==0)return a;
    return gcd(b,a%b);
}
int lcm(int a,int b){
    return a/gcd(a,b)*b;
}
bool prime(int a){
    if(a==1)return false;
    for(int i=2;i*i<=a;i++){
        if(a%i==0)return false;
    }
    return true;
}
void init_fact(){
    kaijo[0]=1;
    for(int i=1;i<=2000000;i++){
        kaijo[i]=kaijo[i-1]*i;
        kaijo[i]%=mod;
    }
}
int modpow(int a,int b){
    if(b==0)return 1;
    if(b%2)return modpow(a,b-1)*a%mod;
    int memo=modpow(a,b/2);
    return memo*memo%mod;
}
int comb(int a,int b){
    if(!kaijo[0])init_fact();
    return kaijo[a]*modpow(kaijo[a-b],mod-2)%mod*modpow(kaijo[b],mod-2)%mod;
}
int inv(int x){
    x=modpow(x,mod-2);
    return x;
}
bool kosa(double ax,double ay,double bx,double by,double cx,double cy,double dx,double dy){
    double ta=(cx-dx)*(ay-cy)+(cy-dy)*(cx-ax);
    double tb=(cx-dx)*(by-cy)+(cy-dy)*(cx-bx);
    double tc=(ax-bx)*(cy-ay)+(ay-by)*(ax-cx);
    double td=(ax-bx)*(dy-ay)+(ay-by)*(ax-dx);
    return tc*td<0&&ta*tb<0;
}
string s;
int dp[1000010][2];
signed main(){
    cin>>s;
    rep(i,1000010)rep(j,2)dp[i][j]=INF;
    dp[0][0]=0;
    rep(i,s.size()){
        int t=s[i]-'0';
        dp[i+1][0]=min({dp[i+1][0],dp[i][0]+t,dp[i][1]+t});
        dp[i+1][1]=min(dp[i+1][1],dp[i][1]+9-t);
        dp[i+1][1]=min(dp[i+1][1],dp[i][0]+11-t);
    }
    cout<<min(dp[s.size()][0],dp[s.size()][1])<<endl;
    return 0;
}

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

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

int main(int argc, const char * argv[]) {
    int N;
    
    cin >> N;
    vector<int> A(N);
    for (int i = 0; i < N; i++) {
        cin >> A[i];
    }
    
    int a = A[0];
    for (int i = 1; i < N; i++) {
        a = gcd(a, A[i]);
    }
    cout << a << endl;
    
    return 0;
}

Measured memory_bytes: 640
/*
ざっと解説します。
最適に動くはずなのでYさんを動かすとスコア減ります。動かしてはいけません。
であればYさんの行動を決めつけられるようにするといいです。
そのためにはXさんが全部取るか1枚残すかのどっちかのみです。
https://twitter.com/Nafmo2/status/929346117317173248
*/
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<stack>
#include<queue>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<utility>
typedef long long int ll;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<signed(n);i++)
#define EREP(i,n) for(int i=1;i<=signed(n);i++)
#define ALL(a) (a).begin(),(a).end()
using std::cout;
using std::vector;
using std::endl;
using std::cin;
using std::string;
using std::min;
using std::max;
//#define EVEL 1
#ifdef EVEL
#define DEB(X) cout << #X << ":" <<X<<" " ;
#define TF(f) f ? cout<<"true  " : cout<<"false ";
#define END cout<<"\n";
#else
#define DEB(X) {}
#define TF(f) {}
#define END {}
#endif
const int MOD = 1000000007;
const ll INF = 9e18;
typedef std::pair<int,int> P;
//struct edge {int to,cost;};
#define VMAX 100000+10
    ll X,Y;
    ll ans;
    ll Z,W,N,A[3000];
int main(){
    //std::ios_base::sync_with_stdio(false);
    cin>>N>>Z>>W;
    ans=0;
    REP(i,N){cin>>A[i];}
    if(N==1)ans=abs(A[N-1]-W);
    else ans=max(abs(A[N-1]-W),abs(A[N-2]-A[N-1]));
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n= sc.nextInt();
		int x=sc.nextInt();
		int t = sc.nextInt();
		if(n%x==0){System.out.println(""+n*t/x);}
		else{System.out.println(""+((n/x)+1)*t);}
	}
}

Measured memory_bytes: 38688
N, M = list(map(int,input().split()))
C = [0 for _ in range(M)]
for _ in range(N):
    A = list(map(int, input().split()))
    A.pop(0)
    for a in A:
        C[a-1] += 1

ans = 0
for c in C:
    if c == N:
        ans += 1

print(ans)

Measured memory_bytes: 3060
def main():
    import sys
    input = sys.stdin.readline
    x, a, b = list(map(int, input().split()))
    if b - a <= 0:
        print("delicious")
    elif b - a > x:
        print("dangerous")
    elif b - a <= x:
        print("safe")


if __name__ == '__main__':
    main()

Measured memory_bytes: 38256