akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;

public class Main {

    static long mod = 1_000_000_007L;
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long ans = 0L;
        int n = sc.nextInt();
        int[] a = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = sc.nextInt();
        }
        int[] b = new int[1000001];
        for (int i = 0; i < n; i++) {
            int c = a[i];
            int d = (int)Math.sqrt(c) + 1;
            for (int j = 2; j < d; j++) {
                int cnt = 0;
                while(c % j == 0){
                    cnt++;
                    c /= j;
                }
                b[j] = Math.max(b[j], cnt);
            }
            if(1 < c) b[c] = Math.max(b[c], 1);
        }
        long lcm = 1L;
        for (int i = 2; i < 1000001; i++) {
            if(0 < b[i]){
                lcm *= modPow(i, b[i]);
                lcm %= mod;
            }
        }
        for (int i = 0; i < n; i++) {
            ans += lcm * modPow(a[i], (int)mod-2);
            ans %= mod;
        }
        System.out.println(ans);
        sc.close();

    }

    private static long modPow(long base, int exp) {
        long ret = 1;
        while(exp > 0){
            if((exp & 1) == 1){
                ret = ret * base %mod;
            }
            base = base * base %mod;
            exp >>= 1;
        }
        return ret;
    }

}


Measured memory_bytes: 38292
#include <bits/stdc++.h>
using namespace std;
#define si(a) scanf("%d",&a)
#define sll(a) scanf("%lld",&a)
#define sl(a) scanf("%ld",&a)
#define pi(a) printf("%d\n",a)
#define pl(a) printf("%ld\n",a)
#define pll(a) printf("%lld\n",a) 
#define sc(a) scanf("%c",&a)a
#define pc(a) printf("%c",a)
#define ll long long
#define mod 1000000007

#define pb push_back
#define mp make_pair
#define f first
#define s second
#define INF INT_MAX
#define fr(i,a,b) for(int i=a;i<=b;i++)
#define VI vector<int>
#define VL vector<ll>
#define PI pair<int,int>
#define PL pair<ll,ll>
long double PIE=acos(-1);
//////////////////////////////////////////////////////////////
const ll N=1e5+5;
ll Ans=1;
bool done[1000009];
vector < ll > primes;

void FindPrime(ll N)
{
    done[1] = 1;
    for(int i=2;i<=N;i++)
	{
        if(done[i]) continue;
        for(int j=i*2;j<=N;j+=i)
		{
            done[j] = 1;
        }
        primes.push_back(i);
    }
}

ll solve(ll Num)
{
    for(int i=0;i<primes.size();i++)
	{
    	int p=primes[i];
        if(p*p*p > Num) break;
        ll Count = 1;
        while(Num%p == 0)
		{
            Num /= p,Count++;
        }
        Ans *= Count;
    }
    ll sq = (ll)sqrt(Num);
    if(!done[Num]) 
	Ans *= 2;
    else if(sq*sq == Num && !done[sq]) 
	Ans *= 3;
    else if(Num != 1) 
	Ans *= 4;
    return Ans;
}


ll fact[N], invfact[N];



ll pow(ll a, ll b, ll m)
{
	ll ans=1;
	while(b)
	{
		if(b&1)
			ans=(ans*a)%m;
		b/=2;
		a=(a*a)%m;
	}
	return ans;
}

ll modinv(ll k)
{
	return pow(k, mod-2, mod);
}


ll nCr(ll x, ll y)
{
	if(y>x)
		return 0;
	ll num=fact[x];
	num*=invfact[y];
	num%=mod;
	num*=invfact[x-y];
	num%=mod;
	return num;
}

void initinv()
{
	fact[0]=1;
	fr(i,1,N)
	{
		fact[i]=(i*fact[i-1])%mod;
	}
	invfact[N]=modinv(fact[N]);
	for(int i=N-1;i>=1;i--)
	{
		invfact[i]=((i+1)*invfact[i+1])%mod;
	}
}
///////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////
VI v[100005];
int indeg[100005];
int vis[100005];
int sze[100005];
void dfs(int s)
{
	vis[s]=1;
	int sz=0;
	for(int i=0;i<v[s].size();i++)
	{
		if(!vis[v[s][i]])
		dfs(v[s][i]);
	}
	for(int i=0;i<v[s].size();i++)
	{
		sz=max(sz,sze[v[s][i]]);
	}
	sze[s]=1+sz;
}
int main()
{
	int n,m;
	cin>>n>>m;
	fr(i,1,m)
	{
		int x,y;
		cin>>x>>y;
		v[x].pb(y);
		indeg[y]++;
	}
	int mx=-1;
	fr(i,1,n)
	{
		if(!vis[i]&&indeg[i]==0)
		{
			dfs(i);
			mx=max(mx,sze[i]);
		}
	}
	cout<<mx-1;
    return 0;
}





Measured memory_bytes: 14868
#include <bits/stdc++.h>
using namespace std;
int main(){
    int N;
    cin>>N;
    int ans=N;
    map<int,int>m;
    int a;
    for(int i=0;i<N;i++){
        cin>>a;
        if(m[a]==1){ans--;}
        m[a]=1;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repp(i, a, b) for (int i = a; i <= (b); ++i)
#define repr(i, a, b) for (int i = a; i >= (b); --i)
#define bit(n) (1LL << (n))
#define len(x) ((ll)(x).size())
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1000000007;
const double EPS = 1e-9;

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;
}


/* mint、表示は変数名.x */
struct mint {
  ll x;
  mint(ll x = 0) : x((x % MOD + MOD) % MOD) {
  }
  mint& operator+=(const mint a) {
    if ((x += a.x) >= MOD)
      x -= MOD;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += MOD - a.x) >= MOD)
      x -= MOD;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= MOD;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res -= a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res *= a;
  }
  /* 変数名.pow(n) */
  mint pow(ll t) const {
    if (!t)
      return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1)
      a *= *this;
    return a;
  }

  // 以降はMODが素数のみ
  mint inv() const {
    return pow(MOD - 2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res /= a;
  }
};


map<int, int> prime_factor(int n) {
  map<int, int> res;
  for (int i = 2; i * i <= n; i++) {
    while (n % i == 0) {
      ++res[i];
      n /= i;
    }
  }
  if (n != 1)
    res[n] = 1;
  return res;
}

/* a^n (MOD) の計算 O(log n) */
ll modpow(ll a, ll n) {
  ll res = 1;
  while (n > 0) {
    if (n & 1)
      res = res * a % MOD;
    a = a * a % MOD;
    n >>= 1;
  }
  return res;
}

signed main() {
  int N;
  cin >> N;
  vector<int> A(N);
  rep(i, N) {
    cin >> A[i];
  }

  map<int, int> factor;
  vector<map<int, int>> mp(N);


  rep(i, N) {
    mp[i] = prime_factor(A[i]);
    for (pair<int, int> item : mp[i]) {
      int Fi = item.fi;
      int Se = item.se;
      chmax(factor[Fi], Se);
    }
  }

  mint multi = 1;
  for (auto item : factor) {
    auto Fi = item.fi;
    auto Se = item.se;
    multi *= modpow(Fi, Se);
  }


  mint ans = 0;
  rep(i, N) {
    mint temp = multi;
    temp /= A[i];
    ans += temp;
  }
  cout << ans.x << "\n";
}


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

/* Returns true if the date lies before 30 April 2019, or equal to it */
bool parse_date(string str)
{
    // Define a new stream named newStream
    stringstream newStream(str);
    
    int year, month, date;
    char slash;
    
    // String the stream and extract the input
    newStream >> year >> slash;
    newStream >> month >> slash;
    newStream >> date;
    
    if(year > 2019) return false;
    if(year < 2019) return true;
    
    // So now year == 2019
    if(month > 4) return false;
    if(month < 4) return true;
    
    // So now, month == 4, month of april
    
    if(date > 30) return false;
    if(date <= 30) return true;
}

int main() {
	string str;
	cin >> str;
	
	if(parse_date(str)) cout << "Heisei" << endl;
	else cout << "TBD" << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
main()
{
    char a[200],b[200];
    int t,i,k,l;
    scanf("%s%s",&a,&b);
    k=strlen(a);
    l=strlen(b);
   if(k>l)
        printf("GREATER\n");
   else if(k<l)
        printf("LESS\n");
   else{
    for(i=0;i<k;i++)
    {
        if(a[i]>b[i]){
        printf("GREATER\n");
        break;}
         else if(a[i]<b[i]){
        printf("LESS\n");
        break;}
        else
        {
            if(i==(k-1))
                printf("EQUAL\n");

            }

    }
   }


    return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<vector>
#include<queue>
#include <string>
#include <sstream>
#include <queue>
#include <complex>
#include <map>
#include <algorithm>
#include <cmath>
#include <iomanip>
using namespace std;

#define ll int64_t
const long MOD = 1e9 + 7;

int main()
{
  int a,b; //かっている数//最大100

  cin >> a >> b;

  long sq=0;
  sq =a*b -a -b +1;


  cout << sq;
  return 0;
}


Measured memory_bytes: 256
import sys, math, collections, heapq, itertools
from bisect import bisect_left
F = sys.stdin
def single_input(): return F.readline().strip("\n")
def line_input(): return F.readline().strip("\n").split()
def gcd(a, b):
    a, b = max(a, b), min(a, b)
    while a % b > 0: a, b = b, a % b
    return b
  
def solve():
    Q = int(single_input())
    n, a, b = map(int, line_input())
    left, right = [-a], [a]
    heapq.heapify(left)
    heapq.heapify(right)
    minans =  b
    for i in range(1, Q):
        queri = [int(i) for i in line_input()]
        if queri[0] == 1:
            a, b = queri[1:]
            minans += b
            left_upper = -1 * heapq.heappop(left)
            right_lower = heapq.heappop(right)
            if left_upper <= a <= right_lower:
                heapq.heappush(left, -a)
                heapq.heappush(left, -1 * left_upper)
                heapq.heappush(right, a)
                heapq.heappush(right, right_lower)
            elif a < left_upper:
                minans += left_upper - a
                heapq.heappush(left, -a)
                heapq.heappush(left, -a)
                heapq.heappush(right, left_upper)
                heapq.heappush(right, right_lower)
            else:
                minans += a - right_lower
                heapq.heappush(left, -1 * left_upper)
                heapq.heappush(left, -1 * right_lower)
                heapq.heappush(right, a)
                heapq.heappush(right, a)
        else:
            left_lower = -1 * heapq.heappop(left)
            print(left_lower, minans)
            heapq.heappush(left, -1 * left_lower)
    return 0
  
if __name__ == "__main__":
    solve()

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

int main(){
	int a, b, c;
	cin >> a >> b >> c;

	if( a<=b && b<=c ){
		cout << a << " " << b << " " << c << endl;
	}else if( a<=c && c<=b ){
		cout << a << " " << c << " " << b << endl;
	}else if( b <=a && a<=c ){
		cout << b << " " << a << " " << c << endl;
	}else if( b<=c && c<=a ){
		cout << b << " " << c << " " << a << endl;
	}else if( c<=a && a<=b ){
		cout << c << " " << a << " " << b << endl;
	}else{
		cout << c << " " << b << " " << a << endl;
	}
	return 0;

}


Measured memory_bytes: 3076
#define _CRT_SECURE_NO_WARNINGS
////#define _USE_MATH_DEFINES
#include<stdio.h>
//#include<stdlib.h>
//#include<math.h>
//#include<string.h>
//#include<time.h>
#define P(type,x) fprintf(stdout,"%"#type"\n",x)

int main() {
	int n, d[1000][5],i,p,q,r,f,c;
	while (fscanf(stdin, "%d", &n),n) {
		f = 1;
		for (i = 0; i < n; i++)
			fscanf(stdin, "%d%d%d%d", &d[i][0], &d[i][1], &d[i][2], &d[i][3]),
			d[i][4] = 4 * (d[i][1] + d[i][3]) + 9 * d[i][2];
		fscanf(stdin, "%d%d%d%d", &p, &q, &r,&c);
		for (i = 0; i < n; i++) if (d[i][1] <= p&&d[i][2] <= q&&d[i][3] <= r&&d[i][4] <= c) P(d, d[i][0]), f = 0;
		if (f) puts("NA");
	}
	return 0;
}

Measured memory_bytes: 636
/*
 * ID: 0358
 */

#include <stdio.h>

int main(void)
{
    int mine, friends, book;
    scanf("%d %d %d", &mine, &friends, &book);

    if (mine >= book)
        puts("0");
    else if (mine + friends >= book)
        printf("%d\n", book - mine);
    else
        puts("NA");

    return 0;
}



Measured memory_bytes: 2056
_n=gets
as=gets.strip.split.map(&:to_i).sort.reverse
alice_n=0
bob_n=0
cnt=0
as.each do |n| 
    if cnt%2==0
        alice_n+=n
    else
        bob_n+=n
    end

    cnt+=1
end

puts alice_n-bob_n

Measured memory_bytes: 14336
def P(s):
 L=[0]*26;R=P=0
 for i in range(D):t=I[i+D][0]-1;P+=s-(i+1-L[t])*C[t];R+=I[i][t]-P;L[t]=i+1
 return R
(D,),C,*I=[list(map(int,o.split()))for o in open(0)]
for d,q in I[2*D + 1:]:I[d-1+D][0]=q;print(P(sum(C)))

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

#define CPP_STR(x) CPP_STR_I(x)
#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_STR_I(args...) #args
#define CPP_CAT_I(x,y) x ## y

using i8  = int8_t;
using u8  = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;

using f32 = float;
using f64 = double;

#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define REPS(i, n) for(i64 i = 1; i <= n; ++i)
#define RREP(i, n) for(i64 i = n - 1; i >= 0 ; --i)
#define RREPS(i, n) for(i64 i = n; i >= 1; --i)

#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))

#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

#define pb push_back
#define mp make_pair

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

template<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }

template<typename T, size_t N>
i64 SIZE(const T (&)[N]) { return static_cast<i64>(N); }


struct ProconInit {
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;

    ProconInit() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(IOS_PREC);
        if(AUTOFLUSH)
            cout << unitbuf;
    }
} PROCON_INIT;


char G[6][6];
char dup[6][6];

int main() {
    i64 H, W, K; cin >> H >> W >> K;
    REP(i, H) REP(j, W) cin >> G[i][j];

    i64 ans = 0;
    for (i64 bit = 0; bit < (1 << (H + W)); bit++) {
        REP(i, H) REP(j, W) dup[i][j] = G[i][j];

        REP(i, H) {
            if (bit & (1 << i)) {
                REP(j, W) {
                    dup[i][j] = '@';
                }
            }
        }

        REP(i, W) {
            if (bit & (1 << (i + H))) {
                REP(j, H) {
                    dup[j][i] = '@';
                }
            }
        }

        i64 cnt = 0;
        REP(i, H) {
            REP(j, W) {
                if (dup[i][j] == '#') cnt++;
            }
        }
        if (cnt == K) ans++;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3644
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
using namespace std;
int main() {
    int K, X; cin >> K >> X;
    int tmp = (X - K) + 1;
    for (int i = 0; i < (K - 1) * 2 + 1; ++i) {
        cout << tmp << " ";
        tmp++;
    }
    cout << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
const ll MOD = 1000000007;
const ll INF = 10000000000000000;
vector<int> x4 = {0, 1, 0, -1}, x8 = {0, 1, 1, 1, 0, -1, -1, -1};
vector<int> y4 = {1, 0, -1, 0}, y8 = {1, 1, 0, -1, -1, -1, 0, 1};
template<class T> struct edge { int from, to; T cost;};
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;}
template<class T> inline T powerM(T a,T b){if (b==0) return 1;
T tmp = powerM(a,b/2); if (b%2==0) return tmp*tmp%MOD; else return tmp*tmp%MOD*a%MOD; }
template<class T> inline T power(T a,T b,T m){ if (b==0) return 1;
  T tmp = power(a,b/2,m); if (b%2==0) return tmp*tmp%m; else return tmp*tmp%m*a%m; }
template<class T> inline T gcd(T a, T b){if (b==0) return a; return gcd(b, a%b);}
template<class T> inline T lcm(T a, T b){return a / gcd(a,b) * b;}
// ax+by=gcd(a,b)を解く
template<class T> inline T extgcd(T a,T b,T &x,T &y){if (b==0){x=1; y=0; return a;} T d=extgcd(b,a%b,y,x); y -= a/b*x; return d;}
void hey(){ cout <<"hey" <<endl; }


int main() {
  int n; cin >>n;
  set<int> s;
  rep(i, n){ int x; cin >>x; s.insert(x); }
  int res = 0;
  int q; cin >>q;
  rep(i, q){ int x; cin >>x; if (s.count(x)) res++; }
  cout <<res <<endl;
}


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

//087 c
int main(){
	int n,max=0;
	cin>>n;
	int a[3][n+1];
	for(int i=1; i<=2; i++){
		for(int j=1; j<=n; j++){
			cin>>a[i][j];
		}
	}
	
	for(int i=1; i<=n; i++){
		int s=0;
		for(int j=1; j<=i; j++){
			s+=a[1][j];
		}
		for(int j=i; j<=n; j++){
			s+=a[2][j];
		}
		if(s>max){
			max=s;
		}
	}
	cout<<max<<endl;
	
	return 0;
}

Measured memory_bytes: 256
N, M = map(int, input().split())
A = [int(input()) for _ in range(M)]
MOD = 10**9 + 7
is_safe = [True] * (N+2)
for a in A:
    is_safe[a+1] = False
dp = [0] * (N+2)
dp[1] = 1
for i in range(2, N+2):
    if is_safe[i]:
        dp[i] = dp[i-1] + dp[i-2]
        dp[i] %= MOD
    else:
        dp[i] = 0
print(dp[N+1])     

Measured memory_bytes: 8568
#include <iostream>
#include <vector>

using namespace std;

void printResult(vector<int> a) {
    for (int i = 0; i < a.size(); i++) {
        cout << a[i] << endl;
    }
}

int compare(int a, int b, vector<pair<string, int> >& arr) {
    if (arr[a].first > arr[b].first) {
        return 1;
    }
    if (arr[a].first < arr[b].first) {
        return -1;
    }
    if (arr[a].second < arr[b].second) {
        return 1;
    }

    return 0;
}

vector<int> f(vector<pair<string, int> > a) {

    vector<int> result;
    for (int i = 0; i < a.size(); i++) {
        result.push_back(i + 1);
    }

    for (int i = 0; i < a.size(); i++) {
        for (int j = a.size() - 1; j > i; j--) {
            if (compare(result[j - 1] - 1, result[j] - 1, a) == 1) {
                swap(result[j - 1], result[j]);
            }
        }
    }

    return result;
}

int main() {

    int n;
    cin >> n;

    vector<pair<string, int> > a;
    for (int i = 0; i < n; i++) {
        pair<string, int> p;
        cin >> p.first;
        cin >> p.second;
        a.push_back(p);
    }

    vector<int> result = f(a);
    printResult(result);

    return 0;
}


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

int main(){
#ifdef LOCAL
    freopen("./input.txt", "r", stdin);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    
    string st;
    cin>>st;
    int n = st.length();
    int s = -1, e = -1;
    for(int i = 0; i< n; i++){
        if(i+1<n&&st[i] == st[i+1]){s = i+1; e= i+2;break;}
        if(i+2<n&&st[i] == st[i+2]){s = i+1; e = i+3;break;}
    }
    cout<<s<<" "<<e<<endl;
    return 0;
}


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

public class Main{
	public static void main(String[] args)
	{
		Stack<Integer> s1 = new Stack<>();
		Scanner in1 = new Scanner(System.in);
		Scanner in = new Scanner(in1.nextLine());
		while(in.hasNext())
		{
			if(in.hasNextInt())
			{
				s1.push(in.nextInt());
			}else
			{
				String symbol = in.next();	
				
				if(symbol.equals("-"))
				{
					int val1 = s1.pop();
					int val2 = s1.pop();
					s1.push(val2 - val1);
				}else if(symbol.equals("+"))
				{
					s1.push(s1.pop() + s1.pop());
				}else if(symbol.equals("*"))
				{
					s1.push(s1.pop() * s1.pop());
				}
			}
			//System.out.println(s1.peek());
		}
		System.out.println(s1.pop());
		in.close();
	}
}



Measured memory_bytes: 26676
#include <iostream>
#include <cstdio>
#include <vector>
#include <queue>
#include <string>
#include <cmath>
#include <algorithm>

using namespace std;

#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define BIT(X, i) ((X>>i)&1)
#define REP(i, a, b) for(int i = (a); i < (b); ++i)
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define all(a) (a).begin(), (a).end()
#define r_all(a) (a).rbegin() (a).rend()

typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<ll, ll> pii;
typedef vector<pii> vii;
typedef priority_queue<ll> pq;

const int MOD = 1e9+7;
const int INF = (1<<30);
const ll INFL = (1L<<62);

int main() {
  string s; cin >> s;
  int ans1 = 0, ans2 = 0;
  rep(i, s.length()) {
    if ((i&1) == 0) {
      if (s[i] == '0') ans1++;
      if (s[i] == '1') ans2++;
    }
    if ((i&1) == 1) {
      if (s[i] == '1') ans1++;
      if (s[i] == '0') ans2++;
    }
  }
  cout << min(ans1, ans2) << endl;
  return 0;
}


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

using namespace std;

pair<int, int> getLongest(vector< vector< pair<int, int> > > &G, int v, int p = -1)
{
	pair<int, int> ret = make_pair(v, 0);

	for (int i = 0; i < G[v].size(); i++){
		if (G[v][i].first == p || G[G[v][i].first].size() == 1) continue;
		pair<int, int> tmp = getLongest(G, G[v][i].first, v);
		if (tmp.second + G[v][i].second > ret.second) ret = make_pair(tmp.first, tmp.second + G[v][i].second);
	}

	return (ret);
}

int main()
{
	int n;

	while (scanf("%d", &n) && n){
		vector< vector< pair<int, int> > > G(n);

		int ans = 0;
		int p[888], d[888];

		for (int i = 1; i < n; i++) scanf("%d", p + i);
		for (int i = 1; i < n; i++) scanf("%d", d + i);

		for (int i = 1; i < n; i++){
			G[p[i] - 1].push_back(make_pair(i, d[i]));
			G[i].push_back(make_pair(p[i] - 1, d[i]));
			ans += 3 * d[i];
		}

		for (int i = 0; i < n; i++){
			if (G[i].size() == 1) ans -= 2 * G[i][0].second;
		}

		pair<int, int> s1 = getLongest(G, 0);
		pair<int, int> s2 = getLongest(G, s1.first);

		printf("%d\n", ans - s2.second);
	}

	return (0);
}

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

using lint = long long;

int main() {
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    int a, b, c;
  	cin >> a >> b >> c;
  	if (a + b + c >= 22) cout << "bust\n";
  	else cout << "win\n";
}

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

int main(){
    int n;cin>>n;
    vector<int64_t> A(n);
    vector<int64_t> B(n);
    vector<int64_t> C(n);

    for(int i=0;i<n;i++) cin>>A.at(i);
    for(int i=0;i<n;i++) cin>>B.at(i);
    for(int i=0;i<n;i++) cin>>C.at(i);

    sort(A.begin(),A.end());
    sort(B.begin(),B.end());
    sort(C.begin(),C.end());

    int64_t result=0;

    for(int i=0;i<n;i++){
        int64_t key=B.at(i);
        int64_t inda=lower_bound(A.begin(),A.end(),key)-A.begin()-1;
        int64_t indc=upper_bound(C.begin(),C.end(),key)-C.begin();
        //cout << inda << " " << indc << endl;

        result += (inda+1)*(n-indc);
        
    }

    cout<<result<<endl;
    return 0;
}

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

const int MAX = 20;

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

    int sum = 0;
    rep(i,n){
        sum += i + l; 
    }
    int taste_worst = 1 + l - 1;
    int taste_best = n + l - 1;
    if(taste_worst * taste_best <= 0){
        cout << sum << endl;
    }else if( taste_worst < 0){
        cout << sum - taste_best << endl;
    }else{
        cout << sum - taste_worst << endl;
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define REP(i, n) for(ll i = 0; i < (ll)n; i++)
#define REPvec(itr, mp) for(auto itr = mp.begin();itr != mp.end(); itr ++)
#define all(x) x.begin(), x.end()
#define MOD 1000000007//1e9+7
using namespace std;
typedef long long ll;
typedef vector<int >    vecint;
typedef vector<ll >     vecll;
typedef vector<string > vecstr;
typedef vector<bool > vecbool;
////////////////////////////////////////////////
ll num(ll k, ll n, ll m){
  ll zero = 0;
  return max((ll)min((m - 2*k)/2, n + k),zero);
}
////////////////////////////////////////////////
int main()
{
  int n, k;
  cin >> n >> k;
  vecbool d(10,true);
  int tmp;
  REP(i,k){
    cin >> tmp;
    d[tmp] = false;
  }
  int i = n;
  while(true){
    string istr = to_string(i);
    bool ok = true;
    REP(i, istr.size()){
      int a = istr[i] - '0';
      if(!d[a]){
	ok = false;
	break;
      }
    }
    if(ok){
      cout << i << endl;
      return 0;
    }else{
      i++;
    }
  }
} 

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

int main() {
  int a,b,c;
  cin >> a >> b >>c;
  int d = min(a,b);
  int ans;
  for(int i = d;i > 0;i--){
    if(a%i ==0 && b%i == 0){
      c--;
    }
    if(c == 0){
      ans = i;
      break;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
n = int(input())
An = [int(x) for x in input().split()]

for i in range(n):
    if An[i] == 0:
        print(0)
        quit()

j = 10 ** 18
ans = 1
for i in range(n):
    if ans > j:
        print(-1)
        quit()
    ans *= An[i]

if ans > j :
    print(-1)
    
else :
    print(ans)



Measured memory_bytes: 21588
#include <iostream>
#include <vector>

using namespace std;

int main(){
  int n;
  std::cin >> n;
  vector<int> backet(4, 0);

  for(int i=0; i<n; i++){
    string temp;
    std::cin >> temp;
    if("WA" == temp){
      backet[1] += 1;
    }else if("AC" == temp){
      backet[0] += 1;
    }else if("TLE" == temp) {
      backet[2] += 1;
    }else if("RE" == temp) {
      backet[3] += 1;
    }
  }

  string ans_str[4] = {"AC", "WA", "TLE", "RE"};
  for(int i=0; i<backet.size(); i++){
    std::cout << ans_str[i] << " x " << backet[i] << '\n';
  }

  return 0;
}


Measured memory_bytes: 3248
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Text;
using System.Text.RegularExpressions;
using System.Linq;

class Magatro
{
    static int N;
    static int[] T;
    static int M;
    static int[] P, X;
    static void Main()
    {
        N = int.Parse(Console.ReadLine());
        T = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
        M = int.Parse(Console.ReadLine());
        P = new int[M];
        X = new int[M];
        for(int i = 0; i < M; i++)
        {
            string[] s = Console.ReadLine().Split(' ');
            P[i] = int.Parse(s[0]);
            X[i] = int.Parse(s[1]);
        }
        int sum = T.Sum();
        for(int i = 0; i < M; i++)
        {
            Console.WriteLine(sum - T[P[i] - 1] + X[i]);
        }

    }
}


Measured memory_bytes: 2904
while True:
    n,s = map(int,input().split())
    if n==0 and s==0 :
        break
    flg = []
    for i in range(2**10):
        if str(bin(i)).count('1') ==n:
            flg.append(i)

    cnt = 0
    for f in flg:
        if sum([i for i in range(10) if f>>i&1==1]) == s:
            cnt += 1
    print(cnt)


Measured memory_bytes: 5604
#include<stdio.h>
int main()
{
    int A,B,sum1=0,sum2=0,sum3=0;

    scanf("%d %d",&A,&B);
    sum1=A+B;
    sum2=A-B;
    sum3=A*B;
    if(sum1>=sum2&&sum1>=sum3)
    {
        printf("%d\n",sum1);
    }
    else if(sum2>=sum1&&sum2>=sum3)
    {
        printf("%d\n",sum2);
    }

    else
    {
        printf("%d\n",sum3);
    }

    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <bitset>
#include <cassert>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define srep(i,n,m) for(int i=n;i<m;i++)
#define elif else if
#define INF 1000000007
#define pi 3.141592653589793
using namespace std;
int saidaikouyakusuu(int a,int b){
    if(b==0) return a;
    return saidaikouyakusuu(b,a%b);
}
int saisyoukoubaisuu(int a,int b){
    return a*b/saidaikouyakusuu(a,b);
}
int n,m,cnt=0,aa[220000],ans=0,ab[220];
pair<int,int> pp[220000];
string s,ss[220000];
char c;
queue<int> que;
signed main(){
    cin>>n>>m>>cnt;
    rep(i,m){
        cin>>aa[i];
    }
    rep(i,n){
        ab[i]=ab[i-1];
        rep(j,m){
            if(i==aa[j]){
                ab[i]=ab[i-1]+1;
            }
        }
    }
    cout<<min(ab[cnt],m-ab[cnt])<<endl;
}

Measured memory_bytes: 10500
import sys
sys.setrecursionlimit(10**6)


def main(input, print):
    L, R, d = map(int, input().split())
    ans = 0
    for i in range(L, R+1):
        if i % d == 0:
            ans += 1
    print(ans)


if __name__ == '__main__':
    main(sys.stdin.readline, print)


Measured memory_bytes: 61632
#include<stdio.h>
int main(){
  char s[100000];
  scanf("%s",s);
  long i;
  long l;
  for(i=0;s[i]!='\0';++i);
  l=i;
  long c1=0;
  for(i=0;i<l;i++){
    if(i%2==1 && s[i]=='0') c1++;
    if(i%2==0 && s[i]=='1') c1++;
  }
  long c2=0;
  for(i=0;i<l;i++){
    if(i%2==1 && s[i]=='1') c2++;
    if(i%2==0 && s[i]=='0') c2++;
  }
  if(c1<c2) printf("%ld",c1);
  else printf("%ld",c2);
  return 0;
}


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

using namespace std;
using ll = long long;
ll arr[100005];

int main() {
    int n, m;
    scanf("%d %d", &n, &m);
    for (int i = 0; i < n; i++) {
        scanf("%lld", arr + i);
    }
    sort(arr, arr + n);
    vector<pair<ll, ll> > vp(m);
    for (int i = 0; i < m; i++)
        scanf("%lld %lld", &vp[i].second, &vp[i].first);
    sort(vp.rbegin(), vp.rend());
    int j=0;
    for(int i=0; i<m && j < n; j++){
        if(vp[i].first <= arr[j])
            break;

        arr[j] = vp[i].first;
        vp[i].second--;
        if(vp[i].second == 0) i++;
    }
    ll res = 0;
    for(int i=0; i<n; i++)
        res += arr[i];
    printf("%lld\n", res);
}

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

const int PRIME_MAX = 1000001;
bool isPrime[PRIME_MAX];
void init() {
	fill(isPrime, isPrime + PRIME_MAX, true);
	isPrime[0] = isPrime[1] = false;
	for (int i = 2; i * i <= PRIME_MAX; i++) {
		if (!isPrime[i]) continue;
		for (int j = (i << 1); j < PRIME_MAX; j += i) {
			isPrime[j] = false;
		}
	}
}

int main() {
	init();
	int n = 0;
	while (cin >> n, n) {
		int count = 0;
		for (int i = 2; i <= n / 2; i++) {
			if (isPrime[i] && isPrime[n - i]) count++;
		}
		cout << count << endl;
	}
}

Measured memory_bytes: 2136
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < n; ++i)
#define P pair<ll, ll>
#define Graph vector<vector<P>>
#define fi first
#define se second
constexpr ll mod = 1000000007;
constexpr ll INF = (1ll << 60);
constexpr double pi = 3.14159265358979323846;
template <typename T>inline bool chmax(T &a, T b){if (a < b){a = b;return 1;}return 0;}
template <typename T>inline bool chmin(T &a, T b){if (a > b){a = b;return 1;}return 0;}

int main(){
    ll n,m;cin>>n>>m;
    vector<P> ab(n);
    rep(i,n){
        cin>>ab[i].fi>>ab[i].se;
    }
    sort(ab.begin(),ab.end());

    ll ans=0,check=0;
    rep(i,n){
        if(check+ab[i].se<=m){
            ans+=(ab[i].se*ab[i].fi);
            check+=ab[i].se;
            if(check==m) break;
        }else{
            ans+=(m-check)*ab[i].fi;
            break;
        }
    }

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

Measured memory_bytes: 4800
import java.util.Scanner;

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

    long M = 1_000_000_007;
    int N = scanner.nextInt();
    int K = scanner.nextInt();
    int[] a = new int[N];
    for (int i = 0; i < N; i++) a[i] = scanner.nextInt();

    long[][] dp = new long[N][K + 1];
    for (int i = 0; i <= a[0]; i++) dp[0][i] = 1;
    for (int i = 1; i < N; i++) {
      long sum = 0;
      for (int j = 0; j <= K; j++) {
        sum += dp[i - 1][j];
        if (j > a[i]) sum -= dp[i - 1][j - a[i] - 1];
        dp[i][j] = sum % M;
      }
    }
    System.out.println(dp[N - 1][K]);
  }
}


Measured memory_bytes: 127060
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
int main() {
  int N, K;
  
  cin >> N >> K;
 
  int x;
  int sum = 0;
  rep (i, N) {
    cin >> x;
    
    if (x < K - x)
      sum += x * 2;
    else
      sum += (K - x) * 2;
  }
  
  cout << sum << endl;
}

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

int main() {
	string s;
	cin >> s;
	if (s == "Sunny") {
		cout << "Cloudy" << endl;
	}
	else if (s == "Cloudy") {
		cout << "Rainy" << endl;
	}
	else {
		cout << "Sunny" << endl;
	}

}

Measured memory_bytes: 256
n = int(input())
a = [list(map(int,input().split())) for _ in range(n)]

#後者が前者よりも大きい時に更新→DPテーブルを-infに初期化
def chmax(a,b):
    if(a< b):
        return b
    else:
        return a

dp = [[0 for i in range(3)] for j in range(n+1)]

#日数
for i in range(n):
    #前の手
    for late_day in range(3):
        for next_day in range(3):
            if late_day != next_day:
                dp[i][next_day] = chmax(dp[i][next_day], dp[i-1][late_day] + a[i][next_day])

print(max(dp[n-1][:]))

Measured memory_bytes: 47372
#include <memory.h>

#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <utility>
#include <vector>

using namespace std;

#define MOD 1000000007
#define INIT -1

long long int result[100][100010] = {};

int main() {
	int n, k;
	cin >> n >> k;
	long long int a[100];
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	for (int i = 0; i <= a[0]; i++) {
		result[0][i] = 1;
	}
	for (int i = 1; i < n; i++) {
		result[i][0] = 1;
		for (int j = 1; j <= k; j++) {
			result[i][j] = (result[i][j - 1] + result[i - 1][j]) % MOD;
			if (j - a[i] - 1 >= 0) {
				result[i][j] -= result[i - 1][j - a[i] - 1];
				result[i][j] += MOD;
				result[i][j] %= MOD;
			}
		}
	}
	cout << result[n - 1][k] << endl;
}

Measured memory_bytes: 78464
import sys


def main():
    N, K = map(int, input().split())
    A = list(map(int, input().split()))

    for i in range(K):
        imos = [0] * (N + 1)
        for j in range(N):
            # s = A[j]
            l, r = max(0, j - A[j]), min(j + A[j], N - 1)
            # print("l,r,s = {} {} {}".format(l, r, s))
            imos[l] += 1
            imos[r + 1] -= 1
        for k in range(N):
            imos[k + 1] = imos[k] + imos[k + 1]
        A = imos[:N]
        if A.count(N) == N:
            print(*A)
            sys.exit()

    print(*imos[:N])


if __name__ == "__main__":
    main()


Measured memory_bytes: 159332
#include<bits/stdc++.h>
using namespace std;
#define maxn 200010
const long long INF=1e18;
template <typename T>inline T read()
{
    register T sum=0;
    register char cc=getchar();
    int sym=1;
    while(cc!='-'&&(cc>'9'||cc<'0'))cc=getchar();
    if(cc=='-')sym=-1,cc=getchar();
    sum=sum*10+cc-'0';
    cc=getchar();
    while(cc>='0'&&cc<='9')sum=sum*10+cc-'0',cc=getchar();
    return sym*sum;
}
template <typename T>inline T read(T &a)
{
    a=read<T>();
    return a;
}
template <typename T,typename... Others> inline void read(T& a, Others&... b)
{
    a=read(a);
	read(b...);
}
int n,m,A,B,x[maxn];
long long f[maxn],tag[maxn<<2],val[maxn<<2][3];
void Effect(int k,long long v)
{
	for(int i:{0,1,2})
		val[k][i]+=v;
	tag[k]+=v;
}
void down(int k)
{
	if(tag[k])
	{
		Effect(k<<1,tag[k]);
		Effect(k<<1|1,tag[k]);
		tag[k]=0;
	}
}
void update(int k)
{
	for(int i:{0,1,2})
		val[k][i]=min(val[k<<1][i],val[k<<1|1][i]);
}
void build(int k,int l,int r)
{
	if(l==r)
	{
		val[k][0]=f[l];
		val[k][1]=f[l]+l;
		val[k][2]=f[l]-l;
		return ;
	}
	int mid=(l+r)>>1;
	build(k<<1,l,mid);
	build(k<<1|1,mid+1,r);
	update(k);
}
void change(int k,int l,int r,int x,long long y)
{
	if(l==r)
	{
		if(y<val[k][0])
		{
			val[k][0]=y;
			val[k][1]=y+l;
			val[k][2]=y-l;
		}
		return ;
	}
	down(k);
	int mid=(l+r)>>1;
	if(x<=mid)change(k<<1,l,mid,x,y);
	else change(k<<1|1,mid+1,r,x,y);
	update(k);
}
long long query(int k,int l,int r,int x,int y,int op)
{
	if(l>=x&&r<=y)
		return val[k][op];
	down(k);
	int mid=(l+r)>>1;
	long long res=INF;
	if(x<=mid)res=min(res,query(k<<1,l,mid,x,y,op));
	if(y>mid)res=min(res,query(k<<1|1,mid+1,r,x,y,op));
	return res;
}
int main()
{
	read(n,m,A,B);
	for(int i=1;i<=m;i++)
		read(x[i]);
	memset(f+1,0x7f,sizeof(long long)*n);
	f[A]=min(f[A],1ll*abs(B-x[1]));
	f[B]=min(f[B],1ll*abs(A-x[1]));
	build(1,1,n);
	for(int i=2;i<=m;i++)
	{
		long long v=query(1,1,n,1,x[i],2)+x[i];
		if(x[i]<n)v=min(v,query(1,1,n,x[i]+1,n,1)-x[i]);
		Effect(1,abs(x[i]-x[i-1]));
		change(1,1,n,x[i-1],v);
	}
	printf("%lld\n",val[1][0]);
    return 0;
}


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

using namespace std;

int main(){
  int a,b,k;
  cin >> a >> b >> k;
  int ans=0;
  int count=0;
  for(int i=min(a,b);i>=1;i--){
    if(a%i==0 && b%i==0){
      ans=i;
      count++;
      if(count==k){
        break;
      }
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
// Problem : C - Tax Increase
// Contest : AtCoder Beginner Contest 158
// URL : https://atcoder.jp/contests/abc158/tasks/abc158_c
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <algorithm>
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <vector>
#include <climits>

using namespace std;

int main()
{
    int a,b;
    cin>>a>>b;
    for(int t=13;t<100000;t++)
    {
    	int num = (t*0.08);
    	int num2 = (t*0.1);
    	if(num == a && num2 == b)
    	{
    		cout << t;
    		return 0;
    	}
    }
    cout << "-1";
    return 0;
}

Measured memory_bytes: 256
h, w = map(int, input().split())
# print(h, w)

# matrix = []
# for _ in range(h):
#     row = input()
#     if '#' not in row:
#         continue
#     else:
#         matrix.append(row)

# print(matrix)

matrix = [input() for _ in range(h)]
# print(matrix)
matrix = [row for row in matrix if '#' in row]
# print(matrix)

T_matrix = [col for col in zip(*matrix) if '#' in col]
# print(T_matrix)

# T_matrix = []

# for col in zip(*matrix):
#     if '#' not in col:
#         continue
#     else:
#         T_matrix.append(col)

# for row in matrix:
#     print(row)
# for row in zip(*T_matrix):
#     print(''.join(row))

print(*(''.join(row) for row in zip(*T_matrix)), sep='\n')


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
int main()
{
	string s;
	string t[10]={"000","111","222","333","444","555","666","777","888","999"};
	int i;
	cin>>s;
	for(i=0;i<10;i++){
		if(s.find(t[i])!=string::npos){cout<<"Yes"<<endl; return 0;}
	}
	cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 256
import sys

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()

n = ni()
hhh = na()
ans = 0
ct = 0
l = 0
li = []
for i in range(n - 1):
    if hhh[i] >= hhh[i + 1]:
        ct += 1
    else:
        ct = 0
    ans = max(ans, ct)
print(ans)

Measured memory_bytes: 14172
#include<iostream>
using namespace std;
int main() {
    long long int x,H,W;cin>>H>>W;
    if (W==1 || H==1) {
        x = 1;
    } else if (W%2==0 && H%2==0) {
        x = W/2*H;
    } else if (W%2==1 && H%2==0) {
        x = (W/2)*(H/2) + (W/2+1)*(H/2);
    } else if (W%2==1 && H%2==1) {
        x = (W/2)*(H/2) + (W/2+1)*(H/2+1);
    } else { // (W%2==0 && H%2==1)
        x = W/2*H;
    }
    cout << x << endl;
    return 0;
}

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

using namespace std;

#define MAX 100000007

struct KEY
{
	int a,b;
	vector<int> c;
	int cc;

};

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

	vector<KEY> keys(m);

	for(int i=0;i<m;i++)
	{
		int a,b;
		cin >> a >> b;
		keys[i].a=a;
		keys[i].b=b;
		keys[i].c=vector<int>(b);
		keys[i].cc=0;
		for(int j=0;j<b;j++)
		{
			int c;
			cin >> c;
			c--;
			keys[i].c[j]=c;

			keys[i].cc |= (1ll<<c);

		}
		//cerr << i << "! " << keys[i].cc << endl;
	}

	long long dp[1ll<<n];
	for(int i=0;i<(1ll<<n);i++)
		dp[i]=MAX;

	dp[0]=0;

	for(int i=0;i<(1ll<<n);i++)
	{
		for(int j=0;j<m;j++)
		{
			int nx=keys[j].cc;
			//cerr << nx << endl;
			nx |= i;
			//cerr << i << " " << j << " " << nx << endl;

			dp[nx]=min(dp[nx],dp[i]+keys[j].a);
		}
	}

	
	if(dp[(1ll<<n)-1]==MAX)
		cout << -1 << endl;
	else
		cout << dp[(1ll<<n)-1] << endl;



}

Measured memory_bytes: 384
#include<stdio.h>
int main(void)
{
  int n;
  double money,ans=0;
  char u[4];
  scanf("%d",&n);
  for(int i=0;i<n;i++){
    scanf("%lf%s",&money,u);
    if(u[0]=='J'){
      ans+=money;
    }else{
      ans+=380000*money;
    }
  }
  printf("%f",ans);
  return 0;
}


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

using namespace std;

typedef long long int li;
typedef long double ld;
typedef vector<li> vi;
typedef pair<li,li> pi;
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define B begin()
#define E end()
#define f(i,l,r) for(li i=l;i<=r;++i)
#define fr(i,l,r) for(li i=l;i>=r;--i)
#define u_map unordered_map
#define endl "\n"
#define debug(x) cout<<(x)<<endl;

li fastpow(li base,li exp,li M) 
{
    li res=1;
    while(exp>0) {
        if(exp&1)
            res=(res*base)%M;

        base=(base*base)%M;
        exp>>=1;
    }
    return res;
}

void solve()
{
    ld a,b;

    cin>>a>>b;

    cout<<(li)floor(a*b);
}

int main()
{    
    

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    li t=1;

    // cin>>t;

    while(t--)
    {
        solve();
    }

    return 0;
}

Measured memory_bytes: 3800
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
Int sx[40][40];
Int sy[40][40];
Int used[4][40][40];

signed main(){  
  cin.tie(0);
  ios::sync_with_stdio(0);
  Int n;
  while(cin>>n,n>=0){
    memset(sx,0,sizeof(sx));
    memset(sy,0,sizeof(sy));
    memset(used,0,sizeof(used));
    for(Int i=0;i<n;i++){
      char d;
      Int x,y;
      cin>>d>>x>>y;
      x*=4;y*=4;
      if(d=='x'){
	for(Int k=0;k<4;k++) sx[y][x+k]=1;
      }
      if(d=='y'){
	for(Int k=0;k<4;k++) sy[y+k][x]=1;
      }
    }
    
    Int dy[]={1,1,-1,-1};
    Int dx[]={1,-1,1,-1};
    Int y=1,x=3,d=0;
    
    auto in=[&](Int y,Int x){
      return 0<=y&&y<=32&&0<=x&&x<=32;
    };
    
    while(1){
      if(used[d][y][x]){
	y=1;x=3;
	break;
      }
      //cout<<d<<":"<<y<<" "<<x<<endl;
      used[d][y][x]=1;
      Int ny=y+dy[d],nx=x+dx[d];
      if(!in(ny,nx)) break;
      if(sx[ny][nx]) d^=2;
      if(sy[ny][nx]) d^=1;
      y=ny;x=nx;
    }

    cout<<x*25<<" "<<y*25<<endl;
  }
  return 0;
}



Measured memory_bytes: 3140
#include <stdio.h>
int main()
{
	int h1,s1,h2,s2;
	scanf("%d %d %d %d",&h1,&s1,&h2,&s2);
	int x,y;
	
	x=h1/s2;
	if(h1%s2!=0) x++;//2攻击次数 
	y=h2/s1;
	if(h2%s1!=0) y++;//1攻击次数 
	
	
	if(x<y) printf("No\n");
	else     printf("Yes\n");
	return 0;
} 

Measured memory_bytes: 1636
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;

void main()
{
    auto nm = readln.split.to!(int[]);
    auto N = nm[0];
    auto M = nm[1];
    int[][] G;
    G.length = N;
    foreach (_; 0..M) {
        auto ab = readln.split.to!(int[]);
        auto A = ab[0]-1;
        auto B = ab[1]-1;
        G[A] ~= B;
        G[B] ~= A;
    }

    auto es = new int[](N);
    long x, y, z;
    void walk(int i, int p, int c) {
        c = c == 1 ? 2 : 1;
        foreach (j; G[i]) if (j != p) {
            if (es[j] == 0) {
                if (c == 1) {
                    ++x;
                } else {
                    ++y;
                }
                es[j] = c;
                walk(j, i, c);
            } else if ((es[j] == 1 && c == 2) || es[j] == 2 && c == 1) {
                if (es[j] == 1) {
                    --x;
                } else {
                    --y;
                }
                ++z;
                es[j] = 3;
                walk(j, i, c);
            }
        }
    }
    es[0] = 1;
    ++x;
    walk(0, -1, 1);

    bool same(int i, int j) {
        return
            (es[i] == 1 && es[j] == 2) ||
            (es[i] == 2 && es[j] == 1) ||
            (es[i] == 3 && es[j] == 3);
    }

    auto memo = new bool[](N);
    memo[0] = true;
    long r;
    void solve(int i) {
        long n = (es[i] == 1 ? y : es[i] == 2 ? x : z);
        if (es[i] == 3) --n;
        foreach (j; G[i]) if (same(i, j)) --n;
        r += n;
        foreach (j; G[i]) if (!memo[j]) {
            memo[j] = true;
            solve(j);
        }
    }
    solve(0);
    writeln(r/2);
}

Measured memory_bytes: 24676
R, G, B, N = map(int, input().split())
def solve():
    ans = 0
    for i in range(N//R+1):
        b1 = N - i*R
        for j in range(b1//G+1):
            b2 = b1 - j*G
            if b2%B==0:
                ans += 1
    return ans
print(solve())

Measured memory_bytes: 3060
#pragma GCC optimize ("Ofast")

#include <bits/stdc++.h>
using namespace std;
typedef long long   signed int LL;
typedef long long unsigned int LU;
#define incID(i, l, r) for(LL i = (l)    ; i <  (r); ++i)
#define incII(i, l, r) for(LL i = (l)    ; i <= (r); ++i)
#define decID(i, l, r) for(LL i = (r) - 1; i >= (l); --i)
#define decII(i, l, r) for(LL i = (r)    ; i >= (l); --i)
#define inc(i, n)  incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define dec(i, n)  decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))
#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
template<typename T> bool setmin  (T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmax  (T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
LL mo(LL a, LL b) { assert(b > 0); a %= b; if(a < 0) { a += b; } return a; }
LL fl(LL a, LL b) { assert(b > 0); return (a > 0 ? a / b : (a - b + 1) / b); }
LL ce(LL a, LL b) { assert(b > 0); return (a < 0 ? a / b : (a + b - 1) / b); }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
#define bit(b, i) (((b) >> (i)) & 1)
#define BC __builtin_popcountll
#define SC static_cast
#define SI(v) SC<int>(v.size())
#define SL(v) SC<LL >(v.size())
#define RF(e, v) for(auto & e: v)
#define ef else if
#define UR assert(false)

// ---- ----

struct Graph {
	int n;
	vector<pair<int, int>> e;
	vector<vector<int>> g;
	
	Graph(int nn) {
		n = nn;
		e.clear();
		g = vector<vector<int>>(n);
	}
	void add(int a, int b) {
		e.EB(a, b);
		g[a].PB(b);
	}
};

int main() {
	int n, m;
	cin >> n >> m;
	Graph g(n);
	inc(i, m) {
		int s, t;
		cin >> s >> t;
		s--; t--;
		g.add(s, t);
	}
	sort(ALL(g.e));
	g.add(n - 1, 0);
	g.add(n - 1, 0);
	
	vector<double> P, E(n);
	inc(i, n) {
		vector<double> p(n), e(n);
		p[i] = 1;
		inc(j, m) {
			int a = g.e[j].FI;
			int b = g.e[j].SE;
			int q = SI(g.g[a]);
			p[b] += p[a] / q;
			e[b] += (e[a] + p[a]) / q;
		}
		E[i] = e.back();
		
		if(i == 0) { P = p; }
	}
	
	double ans = E[0];
	inc(i, n - 1) {
		double x = E[0], d = SI(g.g[i]);
		assert(d > 0);
		if(d == 1) { continue; }
		double Dp = 1 / (d - 1) - 1 / d;
		double Dm = 1 / (d - 1);
		RF(j, g.g[i]) { x += Dp * P[i] * E[j]; }
		RF(j, g.g[i]) { setmin(ans, x - Dm * P[i] * E[j]); }
	}
	
	printf("%.9f\n", ans);
	
	return 0;
}


Measured memory_bytes: 3188