akhauriyash/Code-Regression huggingface dataset:
import sys


def solve():
    input = sys.stdin.readline
    mod = 10 ** 9 + 7
    n = int(input().rstrip('\n'))
    a = list(map(int, input().rstrip('\n').split()))
    ls = [0] * 65
    for i in range(65):
        for v in a:
            ls[i] += v >> i & 1
    t = 0
    for i in range(65):
        t += ls[i] * (n - ls[i]) * 2 ** i
        t %= mod
    print(t % mod)


if __name__ == '__main__':
    solve()


Measured memory_bytes: 124568
#include<bits/stdc++.h>
using namespace std ;
int main()
{
    string s1 = "dream" ;
    string s2 = "dreamer" ;
    string s3 = "erase" ;
    string s4 = "eraser" ;
    reverse(s1.begin() , s1.end() ) ;
    reverse(s2.begin() , s2.end() ) ;
    reverse(s3.begin() , s3.end() ) ;
    reverse(s4.begin() , s4.end() ) ;

    string s ;
    cin >> s ;

    reverse(s.begin() , s.end()) ;

    string temp = "" ;
    int flag = 1 ;

    for(int i = 0 ; i < s.size() ; i++)
    {
        temp +=s[i] ;
        if(temp == s1)temp = "" ;
        if(temp == s2)temp = "" ;
        if(temp == s3)temp = "" ;
        if(temp == s4)temp = "" ;
        else if(temp.size() > 7)
        {
            flag = 0 ;
            break ;
        }
    }
    if(temp.size() > 0)flag = 0 ;

    if(flag == 0)cout << "NO" << endl ;
    else cout << "YES" << endl ;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
#define sz(x) int(x.size())
using namespace std;
typedef long long ll;
const int inf = 1001001001;

int dx[] = {1,0};
int dy[] = {0,1};
 
int h,w;
vector<string> g;


int main(){
  cin >> h >> w;
  g.resize(h);
  rep(i,h) cin >> g[i];


  static int dp[100][100];
  rep(i,100){
    rep(j,100){
      dp[i][j] = inf;
    }
  }

  if(g[0][0] == '#') dp[0][0] = 1;
  else dp[0][0] = 0;
  
  rep(i,h){
    rep(j,w){
      rep(k,2){
        int ny = i + dy[k];
        int nx = j + dx[k];
        if(ny>h-1 || nx>w-1) continue;
        if(g[i][j] == '.' && g[ny][nx] == '#'){
          dp[ny][nx] = min(dp[ny][nx], dp[i][j]+1);
        }
        else dp[ny][nx] = min(dp[ny][nx], dp[i][j]);
      }
    }
  }
  cout << dp[h-1][w-1] << endl;
}


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

int main()
{
    int w, h, x, y, r; 
    cin >> w >> h;
    cin >> x >> y >> r;
    
    if(r<=x && x<=w-r && r<=y && y<=h-r){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 3124
#include <iostream>
#include <string>
#include <math.h>

using namespace std;

int main()
{
	int a, b, c, x, tmp, ans = 0;
	cin >> a >> b >> c >> x;
	for (int i = 0; i <= a; i++) {
		for (int j = 0; j <= b; j++) {
			for (int k = 0; k <= c; k++) {
				tmp = i * 500 + j * 100 + k * 50;
				if (tmp == x) { ans++; }
			}
		}
	}
	cout << ans << endl;
}



Measured memory_bytes: 256
import bisect, collections, copy, heapq, itertools, math, string, sys
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = float('inf')
def I(): return int(input())
def F(): return float(input())
def SS(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LSS(): return input().split()

def resolve():
    S = SS()
    
    if S == 'RRR':
        print(3)
    elif 'RR' in S:
        print(2)
    elif 'R' in S:
        print(1)
    else:
        print(0)

if __name__ == '__main__':
    resolve()


Measured memory_bytes: 10048
#include<bits/stdc++.h>
#define maxn 500005
using namespace std;
int read(){
	int x=0,c;while(!isdigit(c=getchar()));
	while(x=x*10+c-'0',isdigit(c=getchar()));
	return x;
}
int n,sum[maxn];
char s[maxn];
int main(){
	n=read();
	scanf("%s",s+1);
	for(int i=1;i<=n;i++){
		sum[i]=sum[i-1]+(s[i]=='W');
	}
	int ans=n,res;
	for(int i=1;i<=n;i++){
		res=sum[i-1]+n-i-sum[n]+sum[i];
		ans=min(ans,res);
	}
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 1664
#include <bits/stdc++.h>
#define FOR(i, a, n) for(ll i = (ll)a; i < (ll)n; i++)
#define rep(i, n) FOR(i, 0, n)
#define ALL(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;

constexpr int Mod = 998244353;
constexpr int mod = 1e9 + 7;
constexpr ll inf = 1LL << 60;

template <typename T> constexpr bool chmax(T &a, const T b) {
    if(a >= b) return false;
    a = b;
    return true;
}
template <typename T> constexpr bool chmin(T &a, const T b) {
    if(a <= b) return false;
    a = b;
    return true;
}

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

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

    int N, Q;
    cin >> N >> Q;
    vector<ll> A(N);
    rep(i, N) cin >> A[i];
    reverse(A.begin(), A.end());

    vector<ll> sum(N + 1), evensum(N + 1);
    rep(i, N) {
        sum[i + 1] = sum[i] + A[i];
        evensum[i + 1] = evensum[i] + (i % 2 == 0 ? A[i] : 0);
    }

    vector<ll> ths, vals;
    rep(i, (N - 1) / 2) {
        ll th = (A[i + 1] + A[i * 2 + 2]) / 2 + 1;
        ll val = (sum[i + 1] - sum[0]) + (evensum[N] - evensum[i * 2 + 2]);
        ths.push_back(th);
        vals.push_back(val);
    }
    reverse(ths.begin(), ths.end());
    reverse(vals.begin(), vals.end());
    while(Q--) {
        ll x;
        cin >> x;
        int it = upper_bound(ths.begin(), ths.end(), x) - ths.begin();
        if(it == 0)
            cout << sum[(N + 1) / 2] - sum[0] << endl;
        else
            cout << vals[it - 1] << endl;
    }

    return 0;
}

Measured memory_bytes: 5108
using System;
using static AtCoderTemplate.MyLibrary;

namespace AtCoderTemplate
{
    class Program
    {
        static void Main(string[] args)
        {
            int k = int.Parse(Console.ReadLine());
            string s = Console.ReadLine();

            if(s.Length <= k)
            {
                Console.WriteLine(s);
            }else{
                string output = s.Substring(0,k) + "...";
                Console.WriteLine(output);
            }
            //Console.WriteLine("Hello World!");
        }
    }
    //2回位使ったら追加する
    class MyLibrary
    {
        public static int[] ToIntArray(string[] stringArray)
        {
            int length = stringArray.Length;
            int[] intArray = new int[length];
            for (int i = 0; i < length; i++)
            {
                intArray[i] = int.Parse(stringArray[i]);
            }
            return intArray;
        }
    }
}


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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcountll

#define INF 1e16
#define mod 1000000007

int N;
int L[101];

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

  cin>>N;
  rep(i,N)cin>>L[i];

  bool ok=true;
  rep(i,N){
    int sum=0;
    rep(j,N){
      if(i!=j)sum+=L[j];
    }
    if(L[i]>=sum)ok=false;
  }
  if(ok)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(i, 0, (n))
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define LAR(a, b) ((a)=max((a),(b)))
#define SML(a, b) ((a)=min((a),(b)))
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vl = vector<ll>;
using pii = pair<int, int>;
using vpii = vector<pair<int, int>>;
template<typename T>
using pque = priority_queue<T, vector<T>, greater<T>>;
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define ALL(a) (a).begin(), (a).end()
#ifdef LOCAL_DEBUG
#define DEBUG(...) printf(__VA_ARGS__)
#else
#define DEBUG(...)
#endif

#define N 16384
int a[N], b[N];
int c[N];

int main(){
	int h, n; scanf("%d%d", &h, &n);
	REP(i, n) scanf("%d%d", a+i, b+i);
	fill(c, c+N, INT_MAX / 2);
	c[0] = 0;
	REP(i, n){
		REP(j, h){
			SML(c[min(j + a[i], h)], c[j] + b[i]);
		}
	}
	printf("%d\n", c[h]);
}



Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int N = 100005;

int n;
string s;

bool val = false;
bitset<N> ans;

int main() {
    cin.sync_with_stdio(0); cin.tie(0);
    cin >> n >> s;
    int variations[4][2] = {{0, 1}, {0, 0}, {1, 0}, {1, 1}};

    for (int v = 0; v < 4; ++v) {
        ans.reset();
        ans[0] = variations[v][0];
        ans[1] = variations[v][1];

        for (int i = 1; i < n - 1; ++i) {
            if (!ans[i]) {
                if (s[i] == 'o') ans[i + 1] = ans[i - 1];
                else ans[i + 1] = !ans[i - 1];
            } else {
                if (s[i] == 'o') ans[i + 1] = !ans[i - 1];
                else ans[i + 1] = ans[i - 1];
            }
        }

        bool good = true;
        if (ans[n - 1]) {
            if (s[n - 1] == 'o' && ans[n - 2] == ans[0]) {
                good = false;
            } else if (s[n - 1] == 'x' && ans[n - 2] != ans[0]) {
                good = false;
            }
        } else {
            if (s[n - 1] == 'o' && ans[n - 2] != ans[0]) {
                good = false;
            } else if (s[n - 1] == 'x' && ans[n - 2] == ans[0]) {
                good = false;
            }
        }

        if (ans[0]) {
            if (s[0] == 'o' && ans[1] == ans[n - 1]) {
                good = false;
            } else if (s[0] == 'x' && ans[1] != ans[n - 1]) {
                good = false;
            }
        } else {
            if (s[0] == 'o' && ans[1] != ans[n - 1]) {
                good = false;
            } else if (s[0] == 'x' && ans[1] == ans[n - 1]) {
                good = false;
            }
        }

        if (good) {
            val = true;
            break;
        }
    }

    if (!val) {
        cout << -1;
        return 0;
    }

    for (int i = 0; i < n; ++i) {
        if (!ans[i]) cout << 'S';
        else cout << 'W';
    }
}


Measured memory_bytes: 3756
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 2e5 + 5;
int par[maxn];
int find(int x){return par[x] < 0 ? x : par[x] = find(par[x]);}
int main()
{
    memset(par, -1, sizeof(par));
    int n, m;
    cin >> n >> m;
    for (int i = 0; i < m; ++i){
        int u, v;
        cin >> u >> v;
        int pu = find(u), pv = find(v);
        if (pu != pv){
            par[pu] += par[pv];
            par[pv] = pu;
        }
    }
    cout << -*min_element(par + 1, par + 1 + n) << endl;
    return 0;
}


Measured memory_bytes: 4404
//
//  main.cpp
//  usaco
//
//  Created by 김현수 on 2020/08/30.
//  Copyright © 2020 김현수. All rights reserved.
//

#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
int main()
{
    int a, b;
    scanf("%d %d", &a, &b);
    if((a*b)%2!=0)
    {
        printf("Yes");
    }
    else if((a*b)%2==0)
    {
        printf("No");
    }
}


Measured memory_bytes: 3788
#include <stdio.h>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <iostream>
#include<math.h>
using namespace std;

int main() {
	int A, B, K, c = 0,ans=0;
	cin >> A >> B >> K;
	map<int,int>a;
	while (ans < max(A,B)) {
		ans++;
		if (A%ans == 0 && B%ans == 0) {
			c++;
			a[c]=ans;
		}

	}
	cout << a[c-K+1] << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int64_t n,k;
  cin>>n>>k;
  int64_t p=1000000007;
  int64_t s=0; 
  for(int64_t i=k;i<=n+1;i++)
    s=(s+1+(n-i+1)*i%p)%p;
  cout<<s<<endl;
}

Measured memory_bytes: 3624
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
using datas=pair<ll,ll>;
using tdata=pair<ll,datas>;
using vec=vector<ll>;
using mat=vector<vec>;
using pvec=vector<datas>;
using pmat=vector<pvec>;
#define For(i,a,b) for(i=a;i<b;i++)
#define bFor(i,a,b) for(i=a;i>=b;i--)
#define rep(i,N) For(i,0,N)
#define rep1(i,N) For(i,1,N)
#define brep(i,N) bFor(i,N-1,0)
#define all(v) (v).begin(),(v).end()
#define allr(v) (v).rbegin(),(v).rend()
#define vsort(v) sort(all(v))
#define vrsort(v) sort(allr(v))
#define mod 1000000007
#define endl "\n"
#define output(v) do{bool f=0;for(auto i:v){cout<<(f?" ":"")<<i;f=1;}cout<<endl;}while(0)

int main(){
  ll i,j,N,M,K,cnt,ans=0;
  cin>>N>>K;
  pvec v(N);
  rep(i,N){
    cin>>v[i].first>>v[i].second;
    if((v[i].first|K)==K)ans+=v[i].second;
  }
  rep(i,30){
    if(!(K&(1LL<<i)))continue;
    M=K>>(i+1)<<1;
    rep(j,i){
      M=M*2+1;
    }
    cnt=0;
    rep(j,N)if((v[j].first|M)==M)cnt+=v[j].second;
    ans=max(ans,cnt);
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 1792
// {{{
#include <iostream>
#include <iomanip>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <complex>
#include <vector>
#include <list>
#include <set>
#include <unordered_set>
#include <queue>
#include <stack>
#include <map>
#include <unordered_map>
#include <string>
#include <algorithm>
#include <numeric>
using namespace std;

#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define FOR(i, a, b) for(ll i = static_cast<ll>(a); i < static_cast<ll>(b); i++)
#define FORR(i, a, b) for(ll i = static_cast<ll>(a); i >= static_cast<ll>(b); i--)
#define REP(i, n) for(ll i = 0ll; i < static_cast<ll>(n); i++)
#define REPR(i, n) for(ll i = static_cast<ll>(n); i >= 0ll; i--)
#define ALL(x) (x).begin(), (x).end()

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> IP;
typedef pair<ll, LP> LLP;

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

constexpr int INF = 100000000;
constexpr ll LINF = 10000000000000000ll;
constexpr int MOD = static_cast<int>(1e9 + 7);
constexpr double EPS = 1e-9;

static inline ll mod(ll x, ll m)
{
    ll y = x % m;
    return (y >= 0 ? y : y+m);
}

// }}}

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

inline ll lcm(ll a, ll b)
{
    // a*b may be overflowed
    return a / gcd(a, b) * b;
}

ll lcm(vector<ll> &v)
{
    size_t s = v.size();
    ll ret = 1ll;
    REP(i, s){
        if(ret % v[i] != 0) ret = lcm(ret, v[i]);
    }
    return ret;
}

ll N, M;
vector<ll> a;

void solve()
{
    ll m = lcm(a);
    REP (i, N) {
        if ((m / a[i]) % 2 == 0) {
            cout << 0 << endl;
            return;
        }
    }
    if (m > M) {
        cout << 0 << endl;
    } else {
        ll ans = 0;
        for (ll i = m; i <= M; i += 2*m) {
            ans++;
        }
        cout << ans << endl;
    }
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> N >> M;
    a.resize(N);
    REP (i, N) {
        cin >> a[i];
        a[i] /= 2;
    }
    solve();
    return 0;
}

// vim:set foldmethod=marker:


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

#define MP make_pair
#define PB push_back
#define ALL(x)      (x).begin(),(x).end()
#define REP(i,n)    for(int i=0;i<(n);i++)
#define REP1(i,n)   for(int i=1;i<(n);i++)
#define REP2(i,d,n) for(int i=(d);i<(n);i++)
#define RREP(i,n)   for(int i=(n);i>=0;i--)
#define CLR(a)      memset((a),0,sizeof(a))
#define MCLR(a)     memset((a),-1,sizeof(a))
#define RANGE(x,y,maxX,maxY) (0 <= (x) && 0 <= (y) && (x) < (maxX) && (y) < (maxY))

typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef vector<VI > VVI;
typedef vector<string> VS;
typedef vector<LL> VLL;
typedef pair<int,int> PII;

const int INF = 0x3f3f3f3f;
const LL INFL = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-9;

const int DX[]={1,0,-1,0},DY[]={0,-1,0,1};



int main(){
    int H, W;
    cin >> H >> W;
    REP(i, H) {
        string s;
        cin >> s;
        cout << s << endl;
        cout << s << endl;
    }
    return 0;
}



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

int main()
{

  long long int N,K;
  cin>>N>>K;
  int A=0;
  while( N > ( pow(K,(A+1) )-1))
  {
    //cout<<((pow(K,(A+1))-1)/(K-1))<<" "<<A+1<<endl;
    A++;
  }
  //cout<<((pow(K,(A+1))-1)/(K-1))<<endl;
           A++;
  cout<<A<<endl;
}


Measured memory_bytes: 512
import java.util.Scanner;

class Main {

	public static void main(String[] args) {

		int count = 0;
		String x;

		Scanner sc = new Scanner(System.in);

		String str = sc.next();

		for (int i1 = 0, i2 = 1; i2 <= str.length(); i1++, i2++) {

			x = str.substring(i1, i2);

			if (x.equals("1")) {

				count++;

			}

		}

		System.out.println(count);

		sc.close();

	}
}

Measured memory_bytes: 35508
H,W = map(int,input().split())
L = []
for i in range(H):
  L.append(list(map(int,input().split())))
i = 0
j = 0
cnt = 0
anslist = []
num = 0
while num < H*W-1:
  if L[i][j]%2 == 0:
    if i%2 == 0 and j == W-1:
      i += 1
    elif i%2 == 0:
      j += 1
    elif i%2 != 0 and j == 0:
      i += 1
    else:
      j -= 1
  else:
    befi,befj = i+1,j+1
    L[i][j] -= 1
    if i%2 == 0 and j == W-1:
      i += 1
    elif i%2 == 0:
      j += 1
    elif i%2 != 0 and j == 0:
      i += 1
    else:
      j -= 1
    L[i][j] += 1
    afti,aftj = i+1,j+1
    anslist.append([befi,befj,afti,aftj])
    cnt += 1
  num += 1
print(cnt)
for i in range(len(anslist)):
  print(anslist[i][0],anslist[i][1],anslist[i][2],anslist[i][3])

Measured memory_bytes: 30292
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

int n, m;

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

	cin >> n >> m;

	cout << 1900 * m * pow(2, m) + 100 * (n - m) * pow(2, m) << endl;

}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>

using namespace std;

int main(){
  int N, M, l, r;
  cin >> N >> M;
  int ml = -1, mr = N + 1;
  for (int i=0; i<M; i++){
    cin >> l >> r;
    ml = max(ml, l);
    mr = min(mr, r);
  }
  cout << (mr >= ml ? mr - ml + 1 : 0) << endl;
  return 0;
}

Measured memory_bytes: 256
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees#, log2
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10**9 + 7
#from decimal import *

N = INT()
D = LIST()
M = INT()
T = LIST()

d = Counter(D)
t = Counter(T)

for x in t:
	if d[x] < t[x]:
		print("NO")
		break
else:
	print("YES")

Measured memory_bytes: 58816
N=int(input())
S=[input() for _ in range(N)]

MARCH=[0]*5
for i in range(N):
  if S[i][0]=="M":
    MARCH[0]+=1
  elif S[i][0]=="A":
    MARCH[1]+=1
  elif S[i][0]=="R":
    MARCH[2]+=1
  elif S[i][0]=="C":
    MARCH[3]+=1
  elif S[i][0]=="H":
    MARCH[4]+=1

ans=0
for i in range(3):
  for j in range(i+1,4):
    for k in range(j+1,5):
      ans+=MARCH[i]*MARCH[j]*MARCH[k]
print(ans)

Measured memory_bytes: 9772
#include<stdio.h>
int main(){
  int hill[11];
  int i,j,tmp;
  for(i=0;i<10;i++){
    scanf("%d",&hill[i]);
  }
  for(i=0;i<10;i++){
    for(j=i+1;j<10;j++){
      if(hill[i]<hill[j]){
	tmp = hill[i];
	hill[i] = hill[j];
	hill[j] = tmp;
      }
    }
  }
  for(i=0;i<3;i++){
    printf("%d\n",hill[i]);
  }
  return 0;
}

Measured memory_bytes: 600
import std.stdio;
import std.conv, std.array, std.algorithm, std.string;
import std.math, std.random, std.range, std.datetime;
import std.bigint;

int n;
string s;
int[] os;
void main(){
	n = readln.chomp.to!int;
	s = readln.chomp;
	
	os = s.map!(x => (x == 'o')? 1: 0).array;
	
	int[] sheeps;
	
	char[] ans = cast(char[]) "-1";
	sheeps = getSheeps(0, 0);
	if(sheeps.isOK) ans = sheeps.map!(x => x? 'S': 'W').array;
	sheeps = getSheeps(0, 1);
	if(sheeps.isOK) ans = sheeps.map!(x => x? 'S': 'W').array;
	sheeps = getSheeps(1, 0);
	if(sheeps.isOK) ans = sheeps.map!(x => x? 'S': 'W').array;
	sheeps = getSheeps(1, 1);
	if(sheeps.isOK) ans = sheeps.map!(x => x? 'S': 'W').array;
	
	ans.writeln;
	}

int[] getSheeps(int a1, int a2){
	int[] sheeps = [a1, a2];
	sheeps.length = n;
	for(int i = 2; i < n; i ++){
		if((sheeps[i - 2] + sheeps[i - 1] + os[i - 1]) % 2){
			sheeps[i] = 1;
			}
		else sheeps[i] = 0;
		}
	return sheeps;
	}

bool isOK(int[] sheeps){
	if((sheeps[n - 2] + sheeps[n - 1] + sheeps[0] + os[n - 1]) % 2)
			return false;
	if((sheeps[n - 1] + sheeps[0] + sheeps[1] + os[0]) % 2)
			return false;
	return true;
	}

Measured memory_bytes: 4476
#include<iostream>
#include<cstdio>
using namespace std;
int main(void){
    int n,a,b,i;
    cin >> n;
    for(i=0;i<n;i++){
        cin >> a >> b;
        a = a%b;
        if(a == 0) cout << b << endl;
        else cout << a << endl;
    }
    return 0;
}



Measured memory_bytes: 3112
#include<iostream>
using namespace std;
int main(){
	int n,m;cin>>n>>m;
	int al=0,ar=n;
	for(int i=0;i<m;i++){
		int l,r;cin>>l>>r;
		al=max(al,l);ar=min(ar,r);
	}
	cout<<max(ar-al+1,0)<<endl;
}

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 candy = 0;
    for(int i = 1;i <= n;i++){
      candy += i;
    }
    System.out.println(candy);
  }
}

Measured memory_bytes: 23252
let () =
  let shift (c0,c1,c2,c3,c4,c5,c6,c7)
    = (c7,c0,c1,c2,c3,c4,c5,c6) and
      get_int (c0,c1,c2,c3,c4,c5,c6,c7) =
      c0*10000000+c1*1000000+c2*100000+c3*10000+c4*1000+c5*100+c6*10+c7 and
      to_tuple = fun s t u v w x y z -> (s,t,u,v,w,x,y,z) and
      f x y = if y > x then y-x else 0
  in
  let rec read () =
    try let (p0,p1,p2,p3,p4,p5,p6,p7) =
          Scanf.scanf " %d %d %d %d %d %d %d %d\n" to_tuple in
        let c = (4,1,4,1,2,1,2,1) and
            diff (c0,c1,c2,c3,c4,c5,c6,c7) =
              (f c0 p0)+(f c1 p1)+(f c2 p2)+(f c3 p3)+(f c4 p4)+(f c5 p5)+(f c6 p6)+(f c7 p7)
        in
        let rec loop c min_c min n  = function
            0 -> min_c
          | i ->
             let intc = get_int c in
             if (diff c) < min || ((diff c) = min && intc < n) then
               loop (shift c) c (diff c) intc (i-1)
             else
               loop (shift c) min_c min n (i-1)
        in
        let (c0,c1,c2,c3,c4,c5,c6,c7) = loop  c c 99999999 99999999 8 in
        Printf.printf "%d %d %d %d %d %d %d %d\n" c0 c1 c2 c3 c4 c5 c6 c7
        ;read ()
    with
      End_of_file -> ()
  in read ()
;;

Measured memory_bytes: 2632
const t={input:require('fs').readFileSync('/dev/stdin','utf8').split(/[\s]/),n:(arg:number=0):any=>{if(arg){const a=[];for(let i=0;i<arg;i++){a.push(t.n())}return a}else{const a=t.input[0];t.input.shift();return Number(a)}},s:(arg:number=0):any=>{if(arg){const a=[];for(let i=0;i<arg;i++){a.push(t.s())}return a}else{const a=t.input[0];t.input.shift();return String(a)}},c:(arg:number=0):any=>{if(arg){const a=[];for(let i=0;i<arg;i++){a.push(t.c())}return a}else{let a=t.input[0].split('');const b=a[0];a.shift();if(a.length>0){t.input[0]=a.join('')}else{t.input.shift()}return String(b)}},o:(...arg)=>{console.log(...arg)},abs:(a)=>{return Math.abs(a)},min:(...a)=>{return Math.min(...a)},max:(...a)=>{return Math.max(...a)},floor:(a)=>{return Math.floor(a)},asc:(ar:number[])=>{return ar.sort((a,b)=>{return a-b})},desc:(ar:number[])=>{return ar.sort((a,b)=>{return b-a})},sw:(a,arr:any[],op:'=='|'>='|'>'|'<='|'<'='==')=>{for(let i=0;i<arr.length;i+=2){if(eval(a+op+arr[i]))return arr[i+1];}return arr[arr.length-1]}};
const main=()=>{
  let [n,x]=t.n(2)
  let l=t.n(n)
  let ans=0
  let i=0
  while(x>=ans){
    ans+=l[i]
    i++
  }
  t.o(i)
}
main()


Measured memory_bytes: 7500
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops") 
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
#define int long long
#define fr(i,a,b) for(int i = a ; i <= b ; ++i)
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) begin(x), end(x)
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x).size()
#define pb push_back
#define fst first
#define snd second
using namespace __gnu_pbds;
using ordered_set =
 tree<int, null_type,less<int>,
 rb_tree_tag,tree_order_statistics_node_update>;
//find_by_order(k):returns iterator to kth element starting from 0
//order_of_key(k):returns count of elements strictly smaller than k
typedef long long ll;typedef pair<int, int> pii;
typedef vector<int> vi;typedef long double ld;
template<class T>
using min_heap = priority_queue<T,vector<T>,greater<T>>; 
template<typename T> T gcd(T a, T b){return(b?__gcd(a,b):a);}
template<typename T> T lcm(T a, T b){return(a*(b/gcd(a,b)));}
template<typename T> 
void remdup(vector<T>& v) {
	sort(all(v)); v.erase(unique(all(v)), v.end());
}
template<typename T> void re(vector<T> &v) {trav(i,v) cin >> i;}
void unsyncIO() { ios_base::sync_with_stdio(0); cin.tie(0); }
#ifdef np
#include "C:\Users\navodit\Desktop\mycodes\pr.h"
#else
#define trace(...)
#endif

#define MOD 1000000007  

void solve(){
	int n ; 
	cin >> n; 
	int ans =0 ;
	for(int i = 2 ; i<= sqrt(n); ++i){
		if(n%i==0){
			int cnt = 0 ;
			while(n%i==0) n/=i,cnt++;;	
			int cv = 1 ;
			while(cv<=cnt){
				ans++;
				cnt-=cv;
				cv++;
			}
		}
	}
	if(n>1) ans++;
	cout << ans << endl;
}
signed main() {
	unsyncIO();
	int tt =1 ;
	// cin >> tt;
	rep(i,0,tt) solve();













#ifdef np
	cout <<endl<<endl<< "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
	return 0;
}


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

int main() {
	int n;
	
	while( cin >> n ) {
		if (!n) break;
		
		int i, j;
		int cnt = 0;
		for( i = 1; i < n; i++ ) {
			int s = 0;
			for( j = 0; j < n; j++ ) {
				s += i+j;
				//i + … + i+j
				if ( s == n )
					cnt++;
			}
		}
		cout << cnt << endl;
	}
	return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define REP(i,n) for (ll i = 0; i < (n); ++i)
#define RREP(i, n) for (ll i = (n) - 1; i >= 0; --i)
#define ALL(v) (v).begin(), (v).end()
template<class T>
using reverse_priority_queue = priority_queue<T, vector<T>, greater<T>>;

const string YES = "Yes";
const string NO = "No";

int main(){
    ll d, t, s;
    cin >> d >> t >> s;
    if(d <= t * s){
        cout << YES << endl;
    }else{
        cout << NO << endl;
    }
    return 0;
}


Measured memory_bytes: 3636
<?php

while(fscanf(STDIN, "%d %d", $a, $b)){
    if($a < $b)
        printf("%d %d\n", $a, $b);
    elseif($a > $b)
        printf("%d %d\n", $b, $a);
    elseif($a == $b && $a >0)
        printf("%d %d\n", $b, $a);
    elseif($a == 0 && $b == 0)
        break;
    
}


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

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

	int cnt = 0;
	for( int x = 0; x <= k ; x++ ) {
		for( int y = 0; y <= k ; y++ ) {
			int z = s - ( x + y );
			if( 0 <= z and z <= k ) {
				cnt++;
			}
		}
	}

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

Measured memory_bytes: 256
import java.util.*;

public class Main{
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    //ここから4行配列として数列を受け取る
    Integer a[] = new Integer[N];
    for(int i = 0; i < N; i++){
      a[i] = sc.nextInt();
    }
    //配列を降順に並び替える
    Arrays.sort(a, Comparator.reverseOrder());

    for(int i = 1; i < N; i++){
      if(a[i-1].equals(a[i])){
        System.out.println("NO");
        return;
      }
    }
    System.out.println("YES");
    return;
  }
}


Measured memory_bytes: 95192
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr
n=int(input())
s=factorization(n)
ans=0
for i in s:
  k=i[0]
  l=i[1]
  p=1
  while l>=0:
    ans+=1
    l-=p
    p+=1
  ans-=1
if n==1:
  print(0)
else:
  print(ans)

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


using pi=pair<int,int>;
const long long INF=99999999999999;
struct edge{
	int to,cost;
};

using graph=vector<vector<edge>>;

vector<int> djikstra(vector<vector<edge>> &G,int start){
	vector<int> dist(G.size(), INF);
	priority_queue<pi,vector<pi>,greater<pi>> que;
	dist[start]=0;
	// pair(その時点での最短経路,頂点の番号)
	que.push(make_pair(dist[start],start));
	while(!que.empty()){
		int cost=que.top().first;
		int idx=que.top().second;
		que.pop();
		
		if(dist[idx]<cost)continue;
		for(edge e:G[idx]){
			if(dist[e.to]<=cost+e.cost) continue;
			dist[e.to]=cost+e.cost;
			que.push(make_pair(dist[e.to],e.to));
		}
	}
	return dist;
}

signed main(){
	int N,X,Y; cin>>N>>X>>Y;
	graph G(N);
	edge tmp; tmp.cost=1;
	for(int i=1;i<N;i++){
		tmp.to=i;
		G[i-1].push_back(tmp);
		tmp.to=i-1;
		G[i].push_back(tmp);
	}
	tmp.to=X-1; G[Y-1].push_back(tmp);
	tmp.to=Y-1; G[X-1].push_back(tmp);
	vector<int> ans(N);
	for(int i=0;i<N;i++){
		vector<int> dis=djikstra(G,i); //ここでO(N)かかる
		for(int i=0;i<N;i++){ //ここでもO(N)かかる
			if(dis[i]==0)continue;
			ans[dis[i]]++;
		}
	}
	for(int i=1;i<N;i++)cout<<ans[i]/2<<endl;
	return 0;

	
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i,n,m) for(int i=n;i<(int)(m);i++)
#define rrep(i,n,m) for(int i=((int)(n)-1);i>=m;i--)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;
using namespace std;
int main(){
    int n;
    cin>>n;
    string s,t;
    cin>>s>>t;
    
    int ans=2*n;
    rep(i,0,n+1){
        if(s.substr(n-i,i)==t.substr(0,i)) ans=2*n-i;
    }
    
    cout<<ans<<endl;
}



Measured memory_bytes: 256
#include <set>
#include <queue>
#include <cmath>
#include <bitset>
#include <cstdio>
#include <cstdlib>
#include <vector>
#include <cstring>
#include <iostream>
#include <algorithm>
#define debug(x) cerr<<#x<<'='<<x<<endl
#define set0(x) memset(x,0,sizeof(x))
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pii;
template<typename T> void read(T &x){
	x = 0;char ch = getchar();ll f = 1;
	while(!isdigit(ch)){if(ch == '-')f*=-1;ch=getchar();}
	while(isdigit(ch)){x = x*10+ch-48;ch=getchar();}x*=f;
}

int n,q[220];
bool query(){
	cout<<"? ";
	for(int i=1;i<=n*2;i++){
		if(q[i])cout<<i<<' ';
	}
	cout<<endl;
	cout.flush();
	char res[20];
	cin>>res;
	if(res[0] == 'R'){
		return 1;
	}else{
		return 0;
	}
}
char cknow[220];
int main() {
	cin>>n;
	for(int i=1;i<=n;i++){
		q[i] = 1;
	}
	bool st = query();
	int l = 1,r = n+1;
	while(l+1!=r){
		int mid = (l+r)/2;
		set0(q);
		//cout<<"Mid "<<mid<<endl;
		for(int j=0;j<n;j++){
			q[mid+j] = 1;
		}
		bool cu = query();
		if(cu == st){
			l = mid;
		}else{
			r = mid;
		}
	}
	set0(q);
	for(int j=0;j<n;j++){
		q[r+j] = 1;
	}
	cknow[r+n-1] = 'R';
	for(int i=1;i<=2*n;i++){
		if(!q[i]){
			//cout<<"Get "<<i<<endl;
			swap(q[i],q[r+n-1]);
			if(query() == st){
				cknow[i] = 'B';
			}else{
				cknow[i] = 'R';
			}
			//cout<<"Got "<<i<<' '<<cknow[i]<<endl;
			swap(q[i],q[r+n-1]);
		}
	}
	int cpo = 0;
	for(int i=1;i<=2*n;i++){
		if(!q[i] && cknow[i] == 'B'){
			cpo = i;
		}
		q[i]^=1;
	}
	for(int i=1;i<=2*n;i++){
		if(!q[i]){
			//cout<<"Get2 "<<i<<endl;
			swap(q[i],q[cpo]);
			if(query() == st){
				cknow[i] = 'B';
			}else{
				cknow[i] = 'R';
			}
			//cout<<"Got "<<i<<' '<<cknow[i]<<endl;
			swap(q[i],q[cpo]);
		}
	}
	if(st == 1){
		for(int j=1;j<=n*2;j++){
			if(cknow[j] == 'R')cknow[j] = 'B';
			else cknow[j] = 'R';
		}
	}
	cout<<"! "<<(cknow+1)<<endl;
	cout.flush();
	return 0;
}


Measured memory_bytes: 724
#include <vector>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <math.h>
#include <list>

using namespace std;

int sum_digit(int n) {
	if (n == 0) return 0;
	else return n % 10 + sum_digit(n / 10);
}
int absolute(int a) {
	if (a < 0) return -a;
	else return a;
}

long long factorial_109(int n){
  long long number = 1;
  for(int i = n; i > 1; i--){
  	number *= i;
    number %= 1000000007;
  }
  return number;
}
int main()
{
  int N,M; cin >> N >> M;
  
  long long ans = factorial_109(N)* factorial_109(M) % 1000000007 ;
  if(abs(M-N) == 0){
    ans *= 2;
    ans %= 1000000007;
  }
  if(abs(M-N) > 1) ans = 0;
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr double INF{1e9};
constexpr int MAGIC_PRIME{1000000000 + 7};
constexpr array<int, 4> dy{-1, 1, 0, 0};
constexpr array<int, 4> dx{0, 0, -1, 1};
constexpr int div_ru(int a, int b)
{
    return (a - b + 1) / b;
}
ll pow_mod(ll b, ll e, ll m)
{ // https://atcoder.jp/contests/atc002/tasks/atc002_b
    ll r = 1;
    for (; e > 0; e >>= 1)
    {
        if (e & 1)
            r = (r * b) % m;
        b = (b * b) % m;
    }
    return r;
}
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);

    int r, d;
    ll x;
    cin >> r >> d >> x;

    for (int i = 0; i < 10; i++)
    {
        x = r * x - d;
        cout << x << endl;
    }

    return 0;
}
// 　　　　　　_......_
// 　　　　 , ´　 <＊y　♪
// 　　　　 i,（i ﾉﾉﾊ）_）
// 　　　　ﾉ_iﾊﾟ ヮﾟﾉﾊ
// 　　　 　 ,´i'_ｿﾉj,〈つ　))
// 　　　　〈_,ﾉ＾＾＾ヽ.´
// 　　　　 .＾＾i_ｿ_ｿ^´
// 　　　　 ￣￣ ￣　
// vector<vector<int>> mm(h, vector<int>(w, -1));


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#include "atcoder/all"
using namespace atcoder;
#define int long long
#define REP(i, n) for (int i = 0; i < (int)n; ++i)
#define RREP(i, n) for (int i = (int)n - 1; i >= 0; --i)
#define FOR(i, s, n) for (int i = s; i < (int)n; ++i)
#define RFOR(i, s, n) for (int i = (int)n - 1; i >= s; --i)
#define ALL(a) a.begin(), a.end()
#define IN(a, x, b) (a <= x && x < b)
template<class T>istream&operator >>(istream&is,vector<T>&vec){for(T&x:vec)is>>x;return is;}
template<class T>inline void out(T t){cout << t << "\n";}
template<class T,class... Ts>inline void out(T t,Ts... ts){cout << t << " ";out(ts...);}
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;}
constexpr int INF = 1e18;

signed main(){
	int Q;
	cin >> Q;
	while(Q--) {
		int N, M, A, B;
		cin >> N >> M >> A >> B;
		out(floor_sum(N, M, A, B));
	}
}

Measured memory_bytes: 3640
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
typedef long long ll;
const int N = 1000100;
int ww[N];
int main()
{
	int n,m;
	int i;
	scanf("%d%d",&n,&m);
	for(i=0;i<N;i++)
		ww[i] = 2*N;
	for(i=0;i<m;i++)
	{
		int a,b;
		scanf("%d%d",&a,&b);
		ww[a] = min(ww[a],b);
	}
	int ans=0,w=0;
	for(i=1;i<n;i++)
	{
		if(ww[i] == 2*N)
			continue;
		if(w < i)
		{
			ans ++;
			w = ww[i]-1;
		}
		else if(ww[i]-1 < w)
			w = ww[i]-1;
	}
	printf("%d\n",ans);
	return 0;
}

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

struct grid{
  char g[12][12];
  int cnt;
};

void fill(grid &gr,char C,char c,int x,int y){
  if(gr.g[y][x] != C){
    return;
  }
  gr.g[y][x] = c;
  fill(gr,C,c,x+1,y);
  fill(gr,C,c,x-1,y);
  fill(gr,C,c,x,y+1);
  fill(gr,C,c,x,y-1);
}

bool check(grid &gr,char C,int x,int y){
  bool flag = true;
  for(int i=1;i<=y;i++){
    for(int j=1;j<=x;j++){
      if(C != gr.g[i][j]){
        flag = false;
        break;
      }
    }
  }
  return flag;
}

int main(){
  while(1){
    int x,y;
    cin >> x >> y;
    if(x==0 && y==0)
      break;
    grid st;
    for(int i=1;i<=y;i++){
      for(int j=1;j<=x;j++){
          cin >> st.g[i][j];
      }
    }

    st.cnt = 0;
    queue<grid> q;
    q.push(st);

    while(1){
      grid data = q.front();
      q.pop();
      char C;
      C = data.g[1][1];
      if(check(data,C,x,y)){
        cout << data.cnt << endl;
        break;
      }
      if(C != 'R'){
        grid tmp = data;
        tmp.cnt = tmp.cnt+1;
        fill(tmp,C,'R',1,1);
        q.push(tmp);
      }
      if(C != 'G'){
        grid tmp = data;
        tmp.cnt = tmp.cnt+1;
        fill(tmp,C,'G',1,1);
        q.push(tmp);
      }
      if(C != 'B'){
        grid tmp = data;
        tmp.cnt = tmp.cnt+1;
        fill(tmp,C,'B',1,1);
        q.push(tmp);
      }
    }
  }
  return 0;
}




Measured memory_bytes: 40224
def n_mul(m, l, u):
    return u // m - (l-1) // m

def gcd(a, b):
    if b == 0:
        return a
    else:
        return gcd(b, a%b)

def lcm(a, b):
    return a * b // gcd(a, b)

a, b, c, d = [int(i) for i in input().split()]
C = n_mul(c, a, b)
D = n_mul(d, a, b)
CD = n_mul(lcm(c, d), a, b)
ans = (b+1-a) - (C+D-CD)
print(ans)


Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdio>
#include <cmath>

using namespace std;

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

bool f(const int N, const int Y) {
  for(int x = 0; x <= N; x++) {
    int	a = 10 * x;
    if(a > Y) break;
    //    if(a + (N-x)*5 < Y) continue;                                             
    for(int y = 0; x+y <= N; y++) {
      int b = a + 5 * y;
      if(b > Y) break;
      int z = N-(x+y);
      int c = b + z;
      if(c > Y) break;
      if(c ==	Y) {
        printf("%d %d %d\n", x, y, z);
        return true;
      }
    }
  }

  return false;
}

int main() {
  int N, Y;
  cin >> N >> Y;
  bool ans = f(N, Y/1000);
  if(ans == false) printf("%d %d %d\n", -1, -1, -1);
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
  static const int MAX=100;
  static const int INF=(1<<21);
  static const int WHI=0;
  static const int GRA=1;
  static const int BLA=2;
  int n,M[MAX][MAX];
  int prim(){
    int u,minv;
    int d[MAX],p[MAX],color[MAX];
    for(int i=0;i<n;i++){
      d[i]=INF;
      p[i]=-1;
      color[i]=WHI;
    }
    
    d[0]=0;
    while(1){
      minv=INF;
      u=-1;
      for(int i=0;i<n;i++){
	if(minv>d[i]&&color[i]!=BLA){
	  u=i;
	  minv=d[i];
	}
      }

      if(u==-1){
	break;
      }
      color[u]=BLA;

      for(int v=0;v<n;v++){
	if(color[v]!=BLA&&M[u][v]!=INF){
	  if(M[u][v]<d[v]){
	    d[v]=M[u][v];
	    p[v]=u;
	    color[v]=GRA;
	  }

	}
      }
    }

    int sum=0;
    for(int i=0;i<n;i++){
      if(p[i]!=-1){
	sum+=M[i][p[i]];
      }
    }
    return sum;
  }

  int main(){
    cin>>n;
    for(int i=0;i<n;i++){
      for(int j=0;j<n;j++){
	int e;
	cin>>e;
	if(e==-1){
	  M[i][j]=INF;
	}else{
	  M[i][j]=e;
	}
      }
    }
    
    cout<<prim()<<endl;
    return 0;
  }



Measured memory_bytes: 3108
N,M = list(map(int, input().split()))
S = []
for i in range(M):
    tmp = list(map(int, input().split()))
    t = 0
    for j in tmp[1:]:
        t += 1 << (j - 1)
    S.append(t)
P = list(map(int, input().split()))

ans = 0
for i in range(1 << N):
    f = 0
    for s, p in zip(S, P):
        t = i & s
        c = bin(t).count('1') % 2
        if c == p:f+=1
            
    if f == M:
        ans += 1
print(ans)


Measured memory_bytes: 3064
#include<iostream>
#include<string>
#include<vector>
#include<cstdio>
#include<sstream>
#include<algorithm>
#include<cmath>
#include<map>
using namespace std;
int ta[4];
string dx[]={"A","B","AB","O"};
int main(){
	
	int a;string b;
	while(cin>>a){
	cin.ignore();cin>>b;
	for(int j=0;j<4;j++)if(b==dx[j])ta[j]++;
	}
	for(int j=0;j<4;j++)cout<<ta[j]<<endl;
	return 0;
}

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

using namespace std;

int main(){
    string str;
    int i = 0, size = 0, max = 0;

    cin >> str;
    while(str[i] != '\0'){
        if(str[i] == 'A' || str[i] == 'G' || str[i] == 'C' || str[i] == 'T'){
            size++;
            if(size > max){
                max = size;
            }
            //cout << "plus count" << endl;
        }else{
            size = 0;
            //cout << "reset" << endl;
        }
        i++;
    }

    cout << max << endl;    
}

Measured memory_bytes: 256
import java.util.*;
import java.io.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int W = sc.nextInt();
        int a = sc.nextInt();
        int b = sc.nextInt();
        
        if(a+W<b) System.out.println(b-(a+W));
        else if(b+W<a) System.out.println(a-(b+W));
        else System.out.println(0);
    }
}

Measured memory_bytes: 23764
#A問題
S = list(str(input()))
mae = ""
flag = 0
for i in range(4):
    if i == 0:
        mae = S[i]
    else:
        if mae == S[i]:
            flag = 1
            break
        else:
            mae = S[i]
            
if flag == 1:
    print("Bad")
else:
    print("Good")

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

int main(){
    int N,X;
    cin >> N >> X;
    vector<int> L(N);
    for(int i = 0;i < N;i++) cin >> L[i];
    int sum = 0;
    int cnt = 0;
    int i = 0;
    while(sum <= X){
        cnt += 1;
        if(i == N) break;
        sum += L[i];
        if(cnt == N+1) break;
        i++;
    }
    cout << cnt << endl;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>


int main() {
	int n;
	int C[10001];
	int i;
	int m, l;
	m = 10001;
	int *pC = C;
	scanf("%d", &n);
	while (m--) {
		*(pC++) = 0;
	}

	for (i = 0; i < n; ++i) {
		scanf("%d", &m);
		++C[m];
	}

	m = 10001;
	pC = C;
	while (m--) {
		n = *(pC++);
		if (n-- != 0) {
			l = 10000 - m;
			printf("%d", l);
			while (n--) {
				printf(" %d", l);
			}
			break;
		}
	}
	while (m--) {
		n = *(pC++);
		if (n != 0) {
			l = 10000 - m;
			while (n--) {
				printf(" %d", l);
			}
		}
	}
	printf("\n");


	return 0;
}

Measured memory_bytes: 644
#include<bits/stdc++.h>
using namespace std;
int main(){
    int l=0,r,d;
    int n,x;
    cin>>n;
    for(int i=1;i<=n;i++){
        cin>>r;
        if(i%2&&r%2) l++;
    }
    cout<<l<<endl;
    return 0;
}



Measured memory_bytes: 3556
#include<bits/stdc++.h>
using namespace std;
int main(){
    int a, b;
    cin >> a >> b;
    int ctr = 0;
    int t = 1;
    while(t<b){
        ctr++;
        t = ctr*a + (-ctr+1);
    }
    cout << ctr;
    return 0;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
	"strconv"
)

func main() {
	var s string
	fmt.Scan(&s)
	ans := 0
	n := uint(len(s) - 1)
	for i := 0; i < (1 << n); i++ {
		k := uint(0)
		for j := uint(0); j < n; j++ {
			end := j + 1
			if i&(1<<j) != 0 {
				x, err := strconv.Atoi(s[k:end])
				if err != nil {
					panic("parse error")
				}
				ans += x
				k = end
			}
		}
		x, err := strconv.Atoi(s[k:])
		if err != nil {
			panic("parse error")
		}
		ans += x
	}
	fmt.Println(ans)
}


Measured memory_bytes: 512
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
int main(void)
{
  int nn,pp;
  while(1){
    int i;
    int n[50]={0};
    int p[50]={0};
    int wan;
    scanf("%d %d",&nn,&pp);
    if(nn==0 && pp==0)
      break;
    wan=pp;
    for(i=0;;i++){
      if(i==nn)
	i=0;
      if(wan==0){
	wan=n[i];
	n[i]=0;
      }else{
	wan--;
	n[i]++;
      }

   

      if(pp==n[i])
	break;
    }
    printf("%d\n",i);
  }

  return 0;
}

Measured memory_bytes: 596
#include<bits/stdc++.h>
using namespace std;
int main()
{
        vector<int>v(10);
        for(int i=0;i<10;++i)cin>>v[i];
        sort(v.begin(),v.end(),greater<int>());
        for(int i=0;i<3;++i)cout<<v[i]<<endl;
        return 0;
}


Measured memory_bytes: 3108
#include<bits/stdc++.h>
using namespace std;
long long x;
int main(){
    cin>>x;
    long long nw=100;
    double rate=1.01;
    int ans=0;
    while(nw<x){
        nw=(double)(nw)*rate;
        ans++;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3632
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <cmath>
#include <iomanip>
using namespace std;

#define int long long
typedef pair<int, int> P;
#define rep(i, n) for (int i=0; i<(n); i++)
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end())
#define _1 first
#define _2 second
#define pb push_back
#define INF 1145141919
#define MOD 1000000007

int fact[1000001];

int modpow(int x, int k) {
  int a = 1;
  while (k > 0) {
    if (k & 1) a = (1LL*a*x) % MOD;
    x = (1LL*x*x) % MOD;
    k >>= 1;
  }
  return a;
}

int inv(int x) {
  return modpow(x, MOD-2);
}

int nCr(int n, int k) {
  if (n < 0 || k < 0 || n < k) return 0;
  return (1LL * fact[n] * inv((1LL*fact[k]*fact[n-k]) % MOD)) % MOD;
}

int N, M;
int L[3000], R[3000];
int T[3001];
string S;
int dp[3001][3001];

signed main() {
  ios::sync_with_stdio(false); cin.tie(0);
  fact[0] = 1;
  for (int i=1; i<=1000000; i++) {
    fact[i] = (1LL*i*fact[i-1]) % MOD;
  }

  cin >> N >> M >> S;
  rep(i, N) T[i+1] = T[i] + (S[i] == '1');
  map<P, bool> ss;
  rep(i, M) {
    cin >> L[i] >> R[i];
    L[i]--, R[i]--;
    if (ss[P(L[i], R[i])]) L[i] = R[i] = -1;
    else {
      ss[P(L[i], R[i])] = true;
    }
  }
  vector<P> qs;
  rep(i, M) {
    if (L[i] == -1) continue;
    bool f = true;
    rep(j, M) {
      if (L[j] == -1) continue;
      if (i == j) continue;
      // j contains i
      if (L[j] <= L[i] && R[i] <= R[j]) {
        f = false;
        break;
      }
    }
    if (!f) continue;
    qs.pb(P(L[i], R[i]));
  }
  dp[0][0] = 1;
  int s = 1;
  rep(i, qs.size()) {
    int l = qs[i]._1, r = qs[i]._2;
    bool end = true;
    int n = 0;
    int nl = N;
    if (i+1 < qs.size()) {
      nl = qs[i+1]._1;
      if (r >= nl) {
        end = false;
        n = r-nl+1;
      }
    }
    int ll = l;
    if (i > 0) ll = max(ll, qs[i-1]._2+1);
    int ones = T[r+1] - T[ll];
    if (end) {
      int len = r-l+1;
      long long e = 0;
      rep(k, N+1) {
        e += (1LL * dp[i][k] * nCr(len, ones+k)) % MOD;
        e %= MOD;
      }
      s = (1LL*s*e) % MOD;
      dp[i+1][0] = 1;
    }
    else {
      int det = nl-l;
      rep(k, (ll-l)+1) {
        if (k > N) break;
        if (dp[i][k] == 0) continue;
        int r = ones+k;
        rep(nk, n+1) {
          if (r < nk) break;
          // r-nk, nk
          dp[i+1][nk] += (1LL * nCr(det, r-nk) * dp[i][k]) % MOD;
          dp[i+1][nk] %= MOD;
        }
      }
    }
  }
  cout << s << "\n";
  return 0;
}


Measured memory_bytes: 38144
#include <fstream>
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <bitset>
#include <iomanip>
 
using namespace std;
typedef long long ll;
typedef unsigned long long ull;

int main(int argc, const char * argv[]) {
    int X; cin >> X;
    int ans = 0;
    ans += 1000 * (X / 500);
    X %= 500;
    ans += 5 * (X / 5);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python
# -*- coding: utf-8 -*-


class Node(object):

  def __init__(self, idx):
    self.idx = idx
    self.jump = None
    self.step = None


def main():
  N, K = map(int, input().split())
  nodes = [Node(i) for i in range(N)]

  for i, a in enumerate(map(int, input().split())):
    nodes[i].jump = nodes[a - 1]

  current = nodes[0]
  current.step = 0

  while current.jump.step is None:
    current.jump.step = current.step + 1
    current = current.jump

  loop = current.step - current.jump.step + 1

  if K >= current.jump.step:
    remain = (K - current.jump.step) % loop
    current = current.jump
  else:
    remain = K
    current = nodes[0]

  for _ in range(remain):
    current = current.jump

  print(current.idx + 1)


if __name__ == '__main__':
  main()


Measured memory_bytes: 109640
#include <cstdio>
#include <algorithm>

using namespace std;

int main()
{
    int k,a,b;
    scanf("%d",&k);
    scanf("%d %d",&a,&b);
    for(int i=a;i<=b;i++)
    {
        if(i%k==0)
        {
            printf("OK\n");
            return 0;
        }
    }
    printf("NG\n");
    return 0;
}


Measured memory_bytes: 1648