akhauriyash/Code-Regression huggingface dataset:
from itertools import combinations
import numpy as np
n,m,x = map(int,input().split())
money_ls = [0] * n
ex_ls = [0] * n
for i in range(n):
    in_ = list(map(int, input().split()))
    money_ls[i] = in_[0]
    ex_ls[i] = in_[1:]

min_money = float('inf')


book_ls = [i for i in range(n)]
for num in range(1,n+1):
    for inds in combinations(book_ls, num):
        res = True
        money = 0
        ex_now = [0] * m
        for ind in inds:
            money += money_ls[ind]
            for i in range(m):
                ex_now[i] += ex_ls[ind][i]
        for i in range(m):
            if ex_now[i] < x:
                res = False
        if res:
            min_money = min(money, min_money)
if min_money == float('inf'):
    min_money = -1
print(min_money)

Measured memory_bytes: 27072
a = input()
a = a.rstrip().split(" ")
goal2 = int(a[0])
sekisyosuu = int(a[1])
start = int(a[2])

b = input()
sekisyo = b.rstrip().split(" ")

#print(sekisyo)

up=0
dn=0
for i in range(len(sekisyo)):
    if int(sekisyo[i])>=int(start):
        up = up+1
        i+=1
    else:
        dn = dn+1
        i +=1
    
#print(up)
#print(dn)

if int(up)<int(dn):
    print(up)
else:
    print(dn)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define REP(i,n) for (int i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define MOD 1000000007
int main(){
    int AB=0,AW=0,BB=0,BW=0,n;
    string s;
    cin>>s;
    n=s.length();
    REP(i,n){
        if(i%2==0){
            if(s[i]-'0'==0) AB++;
            else AW++;
        }
        else{
            if(s[i]-'0'==0) BB++;
            else BW++;
        }
    }
    cout<<min((n/2+n%2)-AB+n/2-BW,(n/2+n%2)-AW+n/2-BB)<<endl;
}

Measured memory_bytes: 512
/*input
1 2 3

*/
#include <iostream>
#include <bits/stdc++.h>
#include <math.h> 

using namespace std;
#define gc getchar_unlocked
#define fo(i,n) for(ll i=0;i<n;i++)
#define Fo(i,k,n) for(ll i=k;k<n?i<n:i>n;k<n?i+=1:i-=1)
#define ll long long
#define si(x)	scanf("%d",&x)
#define sl(x)	scanf("%lld",&x)
#define ss(s)	scanf("%s",s)
#define pi(x)	printf("%d\n",x)
#define pl(x)	printf("%lld\n",x)
#define ps(s)	printf("%s\n",s)
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
#define PI 3.1415926535897932384626
#define ms(a,x) memset(a, x, sizeof(a));
typedef pair<int, int>	pii;
typedef pair<ll, ll>	pl;
typedef vector<int>		vi;
typedef vector<ll>		vl;
typedef vector<pii>		vpii;
typedef vector<pl>		vpl;
typedef vector<vi>		vvi;
typedef vector<vl>		vvl;
int mpow(int base, int exp); 
void ipgraph(int m);
void dfs(int u, int par);
const ll mod = 1000000007;
const int N = 3e5, M = N;
const int MAX = 1e5;




int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll a,b,c;cin>>a>>b>>c;
    cout<<c<<" "<<a<<" "<<b<<endl;
    return 0;
}		

Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;

typedef int_fast64_t ll;
typedef int_fast64_t intt;
typedef int_fast64_t tmp_m;
#define deb(x) cout << #x << ' ' << x << endl
#define rep(i, a, b) for (tmp_m i = a; i < b; ++i)
#define repp(i, a, b) for (tmp_m i = a; i >= b; --i)
#define pb push_back
#define st stack
#define pa pair
#define vc vector
#define qu queue
#define pq priority_queue
#define fr first
#define sc second
#define mp map
const intt mod = 1e9 + 7;

struct pr {
  intt x;
  intt y;
  intt dst;
  pr() {}
  pr(intt x, intt y, intt dst) : x(x), y(y), dst(dst) {}
  inline bool operator<(const pr& b) const {
    if (dst != b.dst) return dst > b.dst;
    if (x != b.x) return x > b.x;
    return y > b.y;
  }
};

struct point {
  intt x;
  intt y;
  point() {}
  point(intt x, intt y) : x(x), y(y) {}
  inline bool operator<(const point& b) const {
    if (x != b.x) return x > b.x;
    return y > b.y;
  }
};

inline bool spoint(point a, point b) {
  if (a.x != b.x) return a.x < b.x;
  return a.y < b.y;
}

inline bool spr(pr a, pr b) {
  if (a.dst != b.dst) return a.dst < b.dst;
  if (a.x != b.x) return a.x < b.x;
  return a.y < b.y;
}



void solve() {
  intt n;
  cin >> n;
  string s;
  cin >> s;
  intt r = 0, b = 0, g = 0;
  rep(i, 0, n){
    if(s[i] == 'R')r++;
    if(s[i] == 'G')g++;
    if(s[i] == 'B')b++;
  }
  intt ans = r * b * g;
  // intt ans = 0;
  rep(i, 0, n){
    rep(j, i + 1, n){
      if(j + j - i > n - 1)continue;
      if(s[i] != s[j] && s[i] != s[j + j - i] && s[j] != s[j + j - i])--ans;
    }
  }
  cout << ans << endl;  
}

int main() {
  // remove if interactive
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  srand(time(0));
  // memset(dp, -1, sizeof dp);
  solve();
  return 0;
}


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

vector<vector<int>>to;
vector<int>ans;
void dfs(int v, int p = -1){
  rep(i,to[v].size()){
    int u = to[v][i];
    if(u == p) continue;
    ans[u] += ans[v];
    dfs(u, v);
  }
}
  

int main() {
  int n, q;
  cin >> n >> q;
  to.resize(n);
  int a, b;
  rep(i,n-1){
    cin >> a >> b;
    --a; --b;
    to[a].push_back(b);
    to[b].push_back(a);
  }
  ans.resize(n);
  int p, x;
  rep(i,q){
    cin >> p >> x;
    --p;
    ans[p] += x;
  }
  dfs(0);
  rep(i,n) cout << ans[i] << endl;
  
  return 0;
}

Measured memory_bytes: 23424
n, $m = gets.strip.split.map(&:to_i)
k = []
$s = []

$m.times do |i|
    ks = gets.strip.split.map(&:to_i)
    k << ks[0]
    $s << ks[1..-1]
end
$p = gets.strip.split.map(&:to_i)

$swstate = [0] * n
$count = 0
def ns(ni)
    if ni == 0 then
        $swstate[ni] = 0
        while true do
            # check
            flag = true
            $m.times do |i|
                flag = flag && ($s[i].count{ |sidx| $swstate[sidx - 1] > 0 } % 2 == $p[i])
            end
            $count += 1 if flag
            break if $swstate[ni] == 1
            $swstate[ni] = 1
        end
    else
        $swstate[ni] = 0
        ns(ni - 1)
        $swstate[ni] = 1
        ns(ni - 1)
    end
end

ns(n - 1)
puts $count


Measured memory_bytes: 1788
using System;

class MainClass
{
	public static void Main (string[] args)
	{
		string str = Console.ReadLine ();
		string[]spStr = str.Split(' ');

		int a = int.Parse (spStr[0]);
		int b = int.Parse (spStr[1]);


		int d = a / b;
		int r = a % b;
		decimal f = (decimal)a/ b;

		Console.WriteLine (d + " " + r + " " + f);
	}
}

Measured memory_bytes: 9196
#include <algorithm>
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <cmath>

using namespace std;
using ll = long long;
using ull = unsigned long long;

constexpr ll LLINF {1001002003004005006};//ll = 9*LLINF
constexpr int INTINF {1000000000};//int = 2*INTINF

#define  rep(i,n)   for(int i = 0; i < (n); ++i)
#define rrep(i,n)   for(int i = 1; i <= (n); ++i)
#define drep(i,n)   for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for(int i = s; i < t;  ++i)

template<typename T>
void maxs(T& x, T&& y) {
  x=std::max(x,y);
}
template<typename T>
void maxs(T& x, T& y) {
  x=std::max(x,y);
}

template<typename T>
void mins(T& x, T&& y) {
  x=std::min(x,y);
}
template<typename T>
void mins(T& x, T& y) {
  x=std::min(x,y);
}


constexpr int contest_num {26};
constexpr int order_max_cnt {25000}; // TODO : changeble

ll calc_satisfy(const vector<vector<ll>>& S, const vector<ll>& C, const vector<int>& order, const int& D) {
  ll answer {};
  vector<int> fin_day(contest_num, -1);
  rep(i, D) {
    answer += S[i][order[i]-1];
    fin_day[order[i]-1] = i;
    rep(j, contest_num) {
      answer -= C[j]*(i-fin_day[j]);
    }
  }
  return answer;
}

#include <random>

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

  int D;
  cin >> D;
  vector<ll> c(contest_num);
  rep(i, contest_num) cin >> c[i];
  vector<vector<ll>> s(D, vector<ll>(contest_num));
  rep(i, D) {
    rep(j, contest_num) {
      cin >> s[i][j];
    }
  }
  //vector<int> order(D);
  //rep(i, D) cin >> order[i];
  //int M;
  //cin >> M;
  //vector<std::pair<int, int>> query(M);
  //rep(i, M) cin >> query[i].first >> query[i].second;
  //rep(i, M) {
  //  order[query[i].first-1] = query[i].second;
  //  calc_satisfy(s, c, order, D);
  //}
  std::random_device rnd;

  ll max_params {-LLINF};
  vector<int> max_order(D);
  rep(i, contest_num) {
    vector<int> order(D, i+1);
    ll tmp = calc_satisfy(s, c, order, D);
    if (max_params < tmp) {
      max_order = order;
    }
  }
  rep(i, order_max_cnt) {
    vector<int> order(D);
    rep(j, D) {
      order[j] = (rnd() % contest_num) +1;
    }
    ll tmp = calc_satisfy(s, c, order, D);
    if (max_params < tmp) {
      max_order = order;
    }
  }
  rep(i, D) cout << max_order[i] << '\n';
}


Measured memory_bytes: 3764
#include <bits/stdc++.h>
 
using namespace std;
 
#define all(v) (v).begin(), (v).end()
#define sz(v) (int)(v).size()
 
typedef long long ll;


int main()
{
    char ch;
    scanf(" %c", &ch);
    printf("%c\n", ++ch);
}



Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
    int n,h,w;
    cin >> n >> h >> w;
    int cnt=0;
    int a,b;
    for(int i=0;i<n;i++)
    {
        cin >> a >> b;
        if(a>=h&&b>=w) cnt++;
    }
    cout << cnt << endl;
    return 0;
}


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

int main()
{
    int N;
    cin >> N;
    
    vector<int64_t> ans(N+2,0);
    
    ans[0] = 2;
    ans[1] = 1;
    
    for(int i=2;i<N+1;i++)
    {
        ans[i] = ans[i-2] + ans[i-1];
    }
    
    cout << ans[N] << endl;
    
    return 0;
}



Measured memory_bytes: 256
import collections

def prime_factorize(n):
    a = []
    while n%2 == 0:
        a.append(2)
        n //=  2
    f = 3
    while f*f <= n :
        if n % f ==0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a


if __name__=="__main__":
    N = int(input())
    count = 0
    counter = collections.Counter(prime_factorize(N))
    output = 0
    for prime in counter:
        num_prime = 1
        count = 1
        while True:
            if counter[prime] >= num_prime:
                output += 1
                count += 1
                num_prime += count
            else:
                break
    print(output)



Measured memory_bytes: 9464
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define double long double
#define rep(i,n) for(int i=0;i<n;i++)
#define mod 1000000007 // 10^9+7
int n,r=0,b=0;
string s;
signed main(){
    cin>>n>>s;
    rep(i,n){
        if(s[i]=='R')r++;
        else b++;
    }
    if(r>b)puts("Yes");
    else puts("No");
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define int long long
#define inf 1000000007
#define LINF 1000000000000000007LL
#define ll long long
using namespace std;
int dp[51][51][2700];
signed main(){
	int n,k;
	cin>>n>>k;
	dp[0][0][0]=1;
	for(int i=1;i<=n;i++){
		for(int j=0;j<=i-1;j++){
			for(int k=0;k<=2500;k++){
				if(j>0){
					dp[i][j-1][k+2*j] += dp[i-1][j][k]*j*j;
					dp[i][j-1][k+2*j] %= inf;
				}
				dp[i][j][k+2*j] += dp[i-1][j][k]*(2*j+1);
				dp[i][j][k+2*j] %= inf;
				dp[i][j+1][k+2*j] += dp[i-1][j][k];
				dp[i][j+1][k+2*j] %= inf;
			}
		}
	}
	cout<<dp[n][0][k]<<endl;
	return 0;
}

Measured memory_bytes: 53120
import math
def comb(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

n = int(input())

if n%2 == 0:
    print(comb(n//2, 1)**2)
elif n%2 == 1:
    print(comb(n//2+1, 1)*comb(n//2, 1))

Measured memory_bytes: 3060
#include <iostream>

using namespace std;


void maxheapify(int [], int, int);
void build_heap(int heap[], int n);

int main()
{
	int n;
	cin >> n;
	int * heap = new int[n+1];
	
	for (int i = 1; i < n+1; i++)
	{
		cin >> heap[i];
	}
	
	build_heap(heap, n);
	
	for (int i = 1; i < n+1; i++)
	{
		cout << ' ' << heap[i];
	}
	cout << endl;
}


void maxheapify(int heap[], int n, int node)
{
	int max = node, l = 2 * node, r = 2 * node + 1;
	if (l <= n && heap[node] < heap[l])
		max = l;
	if (r <= n && heap[max] < heap[r])
		max = r;
	
	if (max != node)
	{
		swap(heap[node], heap[max]);
		maxheapify(heap, n, max);
	}
}


void build_heap(int heap[], int n)
{
	for (int i = n/2; i >= 1; i--)
		maxheapify(heap, n, i);
}




//自己设计的函数 
//void maxheapify(int heap[], int n, int node)
//{
//	int l = 2 * node, r = 2 * node + 1;
//	if (l > n || r > n) return;
//	if (l <= n)
//	{
//		maxheapify(heap, n, l);
//		if (heap[node] < heap[l])
//			swap(heap[node], heap[l]);
//	}
//	if (r <= n)
//	{
//		maxheapify(heap, n, r);
//		if (heap[node] < heap[r])
//			swap(heap[node], heap[r]);
//	}
//}
//
////自己设计的函数 
//void build_heap(int heap[], int n)
//{
//	for (int i = 1; i <= n/2; i++)
//		maxheapify(heap, n, i);
//}




//求最大值的编号 
//int max_index(int heap[], int n, int root);
//{
//	int max = root;
//	int l = 2 * root;
//	int r = 2 * root + 1;
//	if (l <=  n)
//	{
//		int index_maxl = max_index(heap, n, l);
//		if (heap[root] < heap[index_maxl]);
//		
//	}
//	if (r <=  n)
//	{
//		maxr = max_index(heap, n, l);
//		max = heap[max] < heap[maxr]?maxr:max;
//	}
//	return max;
//}



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

int main() {
    /* 入力受け取り */
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; ++i) cin >> a[i];

    /* しゃくとり法 */
    long long res = 0;
    int right = 0;
    int sum = 0; // AND 和
    for (int left = 0; left < n; ++left) {
        while (right < n && (sum ^ a[right]) == (sum + a[right])) {
            sum += a[right];
            ++right;
        }
        res += right - left;
        if (left == right) ++right;
        else {
            sum -= a[left]; // a[left] を削除 (sum ^= a[left] でも OK)
        }
    }

    cout << res << endl;
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
#define err(args...) {}
#ifdef DEBUG
#include "_debug.cpp"
#endif
using namespace std;
using ll = long long;
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n, x;
    cin >> n >> x;
    vector<int> v;
    v.push_back(x);
    for(int i = 0; i < n; i++) {
        cin >> x;
        v.push_back(x);
    }
    sort(v.begin(), v.end());
    int g = 0;
    for(int i = 1; i < v.size(); i++) {
        g = __gcd(g, v[i] - v[i - 1]);
    }
    cout << g << endl;
    return 0;
}


Measured memory_bytes: 892
a,b,c,d = input().split(' ')

a = int(a)
b = int(b)
c = int(c)
d = int(d)
 
r1 = c // b
r2 = a // d 

for i in range(1000):
  c -= b
  if c <= 0 :
    print('Yes')
    break
  a -= d
  if a <= 0:
    print('No')
    break
  

Measured memory_bytes: 9184
#include <bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a), i##_max = (b); i < i##_max; ++i)
#define RFOR(i, a, b) for (int i = (b)-1, i##_min = (a); i >= i##_min; --i)
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define RREP(i, n) for (int i = (n)-1; i >= 0; --i)
#define ALL(obj) (obj).begin(), (obj).end()

using namespace std;
using vi = vector<int>;
using vl = vector<int64_t>;
using vd = vector<double>;
using pi = pair<int, int>;
using pd = pair<double, double>;
using i64 = int64_t;
using u64 = uint64_t;

constexpr i64 INF = 1LL << 32;
constexpr int MOD = 1000000007;

template <typename T>
void print(vector<T> &v) {
  REP(i, v.size()) {
    if (i) cout << " ";
    cout << v[i];
  }
  cout << endl;
}

void floyd(vector<vl> &d) {
  auto n = d.size();
  REP(k, n) {
    REP(i, n) {
      if (d[i][k] == INF) continue;
      REP(j, n) {
        if (d[k][j] == INF) continue;
        d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
      }
    }
  }
}

int main() {
  int n, e, u, v, c;
  cin >> n >> e;
  vector<vl> d(n, vl(n, INF));
  REP(i, n) d[i][i] = 0;
  REP(i, e) {
    cin >> u >> v >> c;
    d[u][v] = c;
  }
  floyd(d);
  bool negative = false;
  REP(i, n) if (d[i][i] < 0) negative = true;

  if (negative) {
    cout << "NEGATIVE CYCLE" << endl;
  } else {
    REP(i, n) {
      REP(j, n) {
        auto item = d[i][j];
        if (j) cout << " ";
        if (item == INF)
          cout << "INF";
        else
          cout << item;
      }
      cout << endl;
    }
  }
}


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

bool w[105];
vector<int> v[105];

int main() {
    ll l,r;
    cin >> l >> r;
    ll nin=INF;
    if (r>l+2019){
        cout << 0 << endl;
        return 0;
    }
    for (ll i=l;i<r;i++){
        for (ll j=i+1;j<=r;j++){
            nin = min(nin,(i*j)%2019) ; 
        }
    }
    cout << nin << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <climits>
#include <string>
#include <bitset>
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define fin(ans) cout<<(ans)<<endl
#define STI(s) atoi(s.c_str())
#define mp(p,q) make_pair(p,q)
#define pb(n) push_back(n)
#define Sort(a) sort(a.begin(),a.end())
#define Rort(a) sort(a.rbegin(),a.rend())
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
const int P = 1000000007;
const int INF = INT_MAX;
const long long LLINF = 1LL<<60;
//g++ -std=c++1z main.cpp
//.\a.exe

int main(void){ios::sync_with_stdio(false);cin.tie(0);
///////////////////////////////////////////////////////
int n,m,a=0,b=0,ans=0,h=0;
cin >> n;
string s[n];
for(int i=0;i<n;i++){
	cin >> s[i];
}
cin >> m;
string t[m];
for(int i=0;i<m;i++){
	cin >> t[i];
}
 
for(int i=0;i<n;i++){a=0;b=0;
	for(int j=0;j<n;j++){
	      if(s[i]==s[j]){
		   a++;
	      }   
	for(int h=0;h<m;h++){
		  if(s[i]==t[h]){
			b++;
			}
		  }
	}
	ans = max(a-b/n,ans);
    }

cout << ans << endl;






///////////////////////////////////////////////////////
return 0;}

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

#define REP(i, a, b) for (int i = int(a); i < int(b); i++)
#define dump(val) cerr << __LINE__ << ":\t" << #val << " = " << (val) << endl

using namespace std;

typedef long long int lli;

template<typename T>
vector<T> make_v(size_t a, T b) {
    return vector<T>(a, b);
}

template<typename... Ts>
auto make_v(size_t a, Ts... ts) {
    return vector<decltype(make_v(ts...))>(a, make_v(ts...));
}

int main() {
    int a;
    cin >> a;
    if (a == 1) {
        cout << "Hello World" << endl;
    } else {
        int n, m;
        cin >> n >> m;
        cout << n + m << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main()
{
    int a[10000], N, i;
    double sum = 0;
    scanf("%d", &N);
    for (i = 1; i <= N; i++)
    {
        scanf("%d", &a[i]);
    }
    for (i = 1; i <= N; i++)
    {
        sum = sum + 1.0 / a[i];
    }
    printf("%lf", 1.0 / sum);
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <functional>
using namespace std;
#define rep(i, n) for(int i=0; i<n; ++i)
typedef long long ll;
//必要な宣言

int main() {
  int A, B, C, X;
  cin >> A >> B >> C >> X;
  int cnt = 0;

  for(int a=0; a<=A; ++a) {
    for(int b=0; b<=B; ++b) {
      for(int c=0; c<=C; ++c) {
        if(a*500+b*100+c*50 == X) ++cnt;
      }
    }
  }

  cout << cnt << endl;

  return 0;
}


Measured memory_bytes: 384
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<queue>
using namespace std;
#define inf 0x3f3f3f3f
int main()
{
    int n,R=0,B=0;
    char c;
    scanf("%d",&n);
    getchar();
    for(int i=1;i<=n;i++)
    {
        scanf("%c",&c);
        if(c=='R')
            R++;
        else
            B++;
    }

    if(R>B)printf("Yes\n");
    else
        printf("No\n");
    return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<queue>
#include<stack>
#include<vector>
#include<set>
#include<map>
#include<algorithm>
#include<cstring>
#include<string>
#include<cassert>
#include<cmath>
#include<climits>
#include<iomanip>
#include<bitset>
#include<unordered_map>

using namespace std;

#define rep(i,m,n) for(int (i)=(int)(m);(i)<(int)(n);(i)++)
#define rep2(i,m,n) for(int (i)=(int)(n)-1;(i)>=(int)(m);(i)--)
#define REP(i,n) rep(i,0,n)
#define FOR(i,c) for(decltype((c).begin())i=(c).begin();i!=(c).end();++i)
#define ll long long
#define ull unsigned long long
#define all(hoge) (hoge).begin(),(hoge).end()
#define en '\n'
typedef pair<ll, ll> P;
constexpr long long INF = 1LL << 60;
constexpr int INF_INT = 1 << 25;
constexpr long long MOD = (ll)1e9 + 7;
typedef vector<ll> Array;
typedef vector<Array> Matrix;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;


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

struct Edge {
	int to, cap, rev;
	Edge(int _to, int _cap, int _rev) {
		to = _to; cap = _cap; rev = _rev;
	}
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

void add_edge(Graph& G, int from, int to, int cap, bool revFlag, int revCap) {
	G[from].push_back(Edge(to, cap, G[to].size()));
	if (revFlag)G[to].push_back(Edge(from, revCap, G[from].size() - 1));
}



void solve() {
	ll n, k;
	cin >> n >> k;
	Array a(n);
	REP(i, n) cin >> a[i];

	Matrix next(61,Array(n,n+1));//添字iが消えた後の位置
	Array first(202020, n);
	Array pre(202020, n);
	REP(i, n) {
		if (first[a[i]] == n) {
			first[a[i]] = i;
			pre[a[i]] = i;
			continue;
		}

		next[0][pre[a[i]]] = i - pre[a[i]] + 1;
		next[0][i] = n + first[a[i]] - i + 1;
		pre[a[i]] = i;
	}

	REP(i, 60) {
		REP(j, n) {
			next[i + 1][j] = next[i][j] + next[i][(j+next[i][j])%n];//ダブリング
		}
	}

	ll pos = 0;
	while (pos < n*k) {
		int i = -1;
		while (pos + next[i+1][pos%n] <= n * k) i++;
		if (i == -1) {
			cout << a[pos%n] << " ";
			pos++;
		}
		else {
			pos += next[i][pos%n];
		}
	}
	cout << en;
}

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

	solve();
	//int t; cin >> t; REP(i, t) solve();

	return 0;
}


Measured memory_bytes: 101604
creds = [i[::-1] for i in ['dreamer', 'eraser', 'dream', 'erase']]
s = input()[::-1]
t = ""
index = 0
done_ = False
while len(s) != 0:
    done = False
    for cred in creds:
        if s.startswith(cred):
            s = s[len(cred):]
            done = True
            continue
    if not done:
        done_ = True
        break


if not done_:
    print("YES")
else:
    print("NO")


Measured memory_bytes: 134168
#include <iostream>
#include<algorithm>
#include<cctype>
#include<string>

using namespace std;
int main()
{string str;
    int n;
    char k;
    int m;
    while(cin>>str){
        if(str=="-")break;
    cin>>n;
        for(int i=0; i<n; i++){
            cin>>m;
            for(int j=0; j<m; j++){
                k=str[0];
                str.erase(str.begin());
                str.push_back(k);
            }
        }
        cout<<str<<endl;
}
    
    return 0;
}

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

int main() {
    int N;
    cin >> N;
    int p[N];
    int q[N];
    for (int i = 0; i < N; ++i) cin >> p[i];

    for (int i = 0; i < N; ++i) q[i] = p[i];

    sort(q,q+N);

    int unsameCount= 0;
    for (int i = 0; i < N; ++i){
        if(p[i] != q[i] ){
            unsameCount++;
        }
    }

    if(unsameCount<=2) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }

    return 0;
}

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

int dp[1000005][2];

int main() {

  rep(i, 1000005) rep(j, 2) { dp[i][j] = 100100100; }

  string S;
  cin >> S;
  reverse(S.begin(), S.end());
  // 最大桁を一つ追加
  S += '0';

  int N = S.size();
  dp[0][0] = 0;
  rep(i, N) rep(j, 2) {
    rep(a, 10) {
      int x = S[i] - '0';
      x += j;
      int b = a - x;
      int ni = i + 1;
      int nj = 0;
      if (b < 0) {
        b += 10;
        nj = 1;
      }
      dp[ni][nj] = min(dp[ni][nj], dp[i][j] + a + b);
    }
  }

  cout << dp[N][0] << endl;
}

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


int main() {
    char words[3][15];
    for (int i = 0; i < 3; ++i) {
        scanf("%s ", words[i]);
    }
    for (int j = 1; j < 3; ++j) {
        if (words[j][0] != words[j-1][strlen(words[j-1])-1]){
            printf("NO\n");
            return 0;
        }
    }

    printf("YES\n");
    return 0;

}

Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <cassert>
using namespace std;

void print_vector(const vector<int>& vec, const int n) {
  for(int i = 0; i < n; i++) {
    cout << vec[i];
    if(i != n - 1) {
      cout << " ";
    } else {
      cout << endl;
    }
  }
}

void insertion_sort(vector<int>& vec, int n) {
  print_vector(vec, n);
  for(int i = 1; i < n; i++) {
    int v = vec[i];
    int j = i - 1;
    while(j >= 0 && vec[j] > v) {
      vec[j + 1] = vec[j];
      j--;
    }
    vec[j + 1] = v;
    print_vector(vec, n);
  }
}

int main() {
  int n;
  cin >> n;
  vector<int> vec(n);
  for(auto& v : vec) {
    cin >> v;
  }
  insertion_sort(vec, n);
  return 0;
}



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

int main(){
   int N, M;
   cin >> N >> M;

   int sum;
   vector<int> syukudai_nissuu(M);
   for (int i=0; i<M; i++){
      cin >> syukudai_nissuu.at(i);
   }
   sum = accumulate(syukudai_nissuu.begin(), syukudai_nissuu.end(), 0);

   if (N-sum >= 0){
      cout << N-sum << endl;
   }else{
      cout << -1 << endl;
   }
}



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

ll C(int n, int k){
    ll ans = 1;
    for (int i = n; i >= n-k+1; i--){
        ans *= i;
    }
    
    for (int i = 1; i <= k; i++){
        ans /= i;
    }
    return  ans;
}

int main(){
#ifdef LOCAL
    freopen("./input.txt", "r", stdin);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    
    string n;
    cin >> n;
    int k;
    cin >> k;
    
    int len = n.length();
    if(len == k){
        int nn = stoi(n);
        int cnt = 0;
        for (int i = 1; i <= nn; i++){
            string t = to_string(i);
            int ok = 1;
            if(t.length()!= k)continue;
            for (auto c : t) {
                if(c == '0') ok = 0;
            }
            if(ok) cnt++;
        }
        cout << cnt << "\n";
        return 0;
    }
    
    ll ans = 0;
    
 
    
    int cnt_nonezero = 0;
    for (int i = 0; i < len; i++){
        if(n[i]!='0'){
            cnt_nonezero ++;
            
            ll tmp =  C(len- i-1, k-cnt_nonezero+1);
             for (int i = 0; i < k-cnt_nonezero+1; i++){
                 tmp *= 9;
             }
            
            ll ttmp = (n[i] - '1') *  C(len-i-1, k-cnt_nonezero);
            for (int i = 0; i < k-cnt_nonezero; i++){
                ttmp *= 9;
            }
            
            tmp += ttmp;
            ans += tmp;
            if(cnt_nonezero >= k){
                ans ++;
                break;
            }
            
        }
        
    }
    cout << ans << "\n";
    
    
    return 0;
}


Measured memory_bytes: 256
# import math
import fractions
import numpy as np
from itertools import accumulate, chain, islice, starmap
N = int(input())
numbers = list(map(int, input().split()))
# numbers = [2, 4, 8, 8]
# N = len(numbers)


def calculate_maximum_subgcd_with_np_ufunc(numbers):
    gcd = np.frompyfunc(fractions.gcd, 2, 1)
    cumgcds = gcd.accumulate(numbers, dtype=np.object).astype(np.int)
    sub_cumgcds = np.roll(cumgcds, 1)
    sub_cumgcds[0] = 0
    reverse_cumgcds = gcd.accumulate(
        numbers[::-1], dtype=np.object).astype(np.int)
    sub_reverse_cumgcds = np.roll(reverse_cumgcds, 1)
    sub_reverse_cumgcds[0] = 0
    return np.max(gcd(sub_cumgcds, sub_reverse_cumgcds[::-1]))


def calculate_maximum_subgcd_with_func(numbers):
    operation = fractions.gcd
    cumgcds = accumulate(numbers, operation)
    sub_cumgcds = islice(chain([0], cumgcds), len(numbers))
    reverse_cumgcds = accumulate(numbers[::-1], operation)
    sub_reverse_cumgcds = islice(chain([0], reverse_cumgcds), len(numbers))
    sub_gcds = starmap(operation, zip(sub_cumgcds, list(sub_reverse_cumgcds)[::-1]))
    return max(sub_gcds)


# calculate_maximum_subgcd = calculate_maximum_subgcd_with_np_ufunc
calculate_maximum_subgcd = calculate_maximum_subgcd_with_func

print(calculate_maximum_subgcd(numbers))


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

int main () {
  int A, B;
  cin >> A >> B;
  cout << max(A+B, max(A-B, A*B)) << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
///////////////////////////////////////////
const long long int INF = 1LL<<60;
const long long int Mod = 1000000007;
using ll = long long int; using ci = const int;
using vi = vector<int>;  using Vi = vector<long long int>;
using P = pair<int, int>;  using PLL = pair<ll, ll>;
using matrix = vector<vector<ll>>;
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define rp(i,N) for(ll i = 0; i < (ll)N; i++)
#define repi(i,a,b) for(ll i = ll(a); i < ll(b); ++i)
template<class T>bool chmax(T &former, const T &b) { if (former<b) { former=b; return true; } return false; }
template<class T>bool chmin(T &former, const T &b) { if (b<former) { former=b; return true; } return false; }
template<class T>T sqar(T x){ return x*x; }//sqrt(x)は平方根;
#define Sort(v) std::sort(v.begin(), v.end(), std::greater<decltype(v[0])>()) //降順でVをソート
#define p_queue(v) priority_queue<v, vector<v>, greater<v> >
template<class T> inline void princ(T x){cout<<x<<" ";}; 
template<class T> inline void print(T x){cout<<x<<"\n";};
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
///////////////////////////////////////////////////////////////////////////////////

void solve(){
    int n,k;
    cin >> n >> k;
    string s;
    cin>> s;
    s[k-1]='a'+(s[k-1]-'A');
    print(s);
    return;
}
int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    std::cout<<std::fixed<<std::setprecision(30);
    solve();
    return 0;
}

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

int main() {
  long long N,Q,H,S,D;
  long long ans,q,h,s,d;
  cin>>Q>>H>>S>>D>>N;
  q=4*Q;
  h=2*H;
  S=min(S,min(q,h));
  if(2*S<D){
    ans=S*N;
  }
  else{
    ans=N/2*D+N%2*S;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
import heapq

n, m = list(map(int, input().split()))
a = list(map(int, input().split()))
a = list(map(lambda x: x*(-1), a))
heapq.heapify(a)
for i in range(m):
    p = heapq.heappop(a) * -1 // 2 * -1
    heapq.heappush(a, p)
print(sum(a)* -1)

Measured memory_bytes: 14180
s = gets.chomp.split(//)
n = s.size
ans = Array.new(n,0)
a = 0
s.each_with_index do |c,i| #前から
  if c == "R"
    a += 1
  elsif a != 0
    ans[i] += a/2
    ans[i-1] += (a+1)/2
    a = 0
  end
end
ans.reverse!
s.reverse_each.with_index do |c,j| # 後ろから
  if c == "L"
    a += 1
  elsif a != 0
    ans[j] += a/2
    ans[j-1] += (a+1)/2
    a = 0
  end
end
puts ans.reverse.join(" ")


Measured memory_bytes: 13436
#include <iostream>
#include <algorithm>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<iomanip>
#define sqr(x) (x)*(x)
using namespace std;
long long n,m,a,k,i,j,num[500005],ans=1<<25,pos[500005],l,r;
int main()
{
	ios_base::sync_with_stdio(0);
	cin>>n;
	for (i=1;i<=n;i++)
	{
		cin>>num[i];
		pos[num[i]]=i;
	}
	for (i=1;i<=n;i++)
	{
		j=i;
		while (j<n&&pos[j+1]>pos[j]) j++;
		ans=min(ans,n-(j-i+1));
		i=j;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 5888
/*------------------------------------
........Bismillahir Rahmanir Rahim....
..........created by Abdul Aziz.......
------------------------------------*/
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <cstring>
#include <unordered_map>
#include <queue>
#define   mod  998244353
#define   int  long long 
#define   ld   long double
#define   pb   push_back
#define   vi  vector<int> 
#define   dbg(x)  cerr << #x << " = " << x << '\n'
#define   sz(x)  (int)x.size()
#define   ff   first
#define   ss   second
#define   pii  pair<int,int>
using namespace std;

inline void solve(){
    int n,a,b,ans=0;
    cin>>n>>a>>b;
    for (int i=1;i<=n;i++){
        int h=i,sum=0;
        while (h){
            sum += h%10;
            h/=10;
        }
        if (sum>=a and sum<=b) ans += i;
    }
    cout << ans << endl;
}

signed main()
{
    int n=1; // cin>>n;
    while (n--) solve();
    return 0;
}


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

#define REP(i,n) for(int i=0;i<(int)n;i++)
#define REP1(i,j,n) for(int i=j;i<(int)n;i++)
#define pb(x) push_back(x)
#define fi first
#define se second
#define all(x) x.begin(),x.end()
#define double long double
#define mp(x,y) make_pair(x,y)

typedef long long ll;

using namespace std;


ll solve(multiset<pair<int,int> >m1,multiset<pair<int,int> >m2,int s){
	int p=s;
	ll r=0;
	int l=0;
	while((int)m1.size()){
		if(!p){
			auto it=--m1.end();
			pair<int,int>bL=*it;
			int lft=bL.fi,rght=bL.se;
			int nxL=l<=lft?lft:l>=rght?rght:l;
			r+=abs(l-nxL);
			l=nxL;
			m1.erase(it);
			m2.erase(mp(rght,lft));
		}else{
			auto it=m2.begin();
			pair<int,int>sR=*it;
			int lft=sR.se,rght=sR.fi;
			int nxL=l<=lft?lft:l>=rght?rght:l;
			r+=abs(l-nxL);
			l=nxL;
			m2.erase(it);
			m1.erase(mp(lft,rght));
		}
		// cout<<l<<"\n";
		p^=1;
	}
	// cout<<r<<" "<<l<<"\n";
	return r+abs(l);
}

int main() {

        
    ios_base::sync_with_stdio(0);
    cin.tie(0);

    int n;
    cin>>n;
    multiset<pair<int,int> >m1,m2;
    while(n--){
    	int l,r;
    	cin>>l>>r;
    	if(l>r)swap(l,r);
    	m1.insert(mp(l,r));
    	m2.insert(mp(r,l));
    }

    cout<<max(solve(m1,m2,0),solve(m1,m2,1))<<"\n";
    
    return 0;
}

Measured memory_bytes: 21120
"""
AtCoder :: Beginner Contest 174 :: Logs
https://atcoder.jp/contests/abc174/tasks/abc174_e
"""
import sys
from math import ceil


def main():
    """Main program."""
    log_count, cut_count = (int(i) for i in sys.stdin.readline().split())
    logs = [int(i) for i in sys.stdin.readline().split()]
    high = max(logs)
    low = 1
    soln = high
    # Binary search for the answer.
    while low <= high:
        mid = (low + high) // 2
        cuts_needed = sum([int(ceil(log / mid)) - 1 for log in logs])
        if cuts_needed <= cut_count:
            soln = min(soln, mid)
            high = mid - 1
        else:
            low = mid + 1
    print(soln)


if __name__ == '__main__':
    main()


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

namespace UnionFindTree {
  template<std::size_t N>
  void Init(int (&ps)[N]) {
    for(int i = 0; i < (int)N; ++i) ps[i] = i;
  }
  template<std::size_t N>
  int Find(int (&ps)[N], int x) {
    return ps[x] == x ? x : ps[x] = Find(ps, ps[x]);
  }
  template<std::size_t N>
  void Unite(int (&ps)[N], int x, int y) {
    x = Find(ps, x);
    y = Find(ps, y);
    if( x == y ) return;
    if( rand() & 0x01 ) std::swap(x, y);
    ps[x] = y;
  }
  template<std::size_t N>
  bool Same(int (&ps)[N], int x, int y) {
    return Find(ps, x) == Find(ps, y);
  }
};
using namespace UnionFindTree;

// http://atc001.contest.atcoder.jp/tasks/unionfind_a
void Verify_1() {
  int par[112345];
  int n, q;
  scanf("%d %d", &n, &q);
  Init(par);
  for(int i = 0; i < q; ++i) {
    int c, x, y;
    scanf("%d %d %d", &c, &x, &y);
    if( c == 0 ) {
      Unite(par, x, y);
    }
    else {
      puts(Same(par, x, y) ? "Yes" : "No");
    }
  }
}

// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=DSL_1_A
void Verify_2() {
  int par[11234];
  int n, q;
  scanf("%d %d", &n, &q);
  Init(par);
  for(int i = 0; i < q; ++i) {
    int c, x, y;
    scanf("%d %d %d", &c, &x, &y);
    if( c == 0 ) {
      Unite(par, x, y);
    }
    else {
      puts(Same(par, x, y) ? "1" : "0");
    }
  }
}


int main() {
  Verify_2();
  return 0;
}

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

int main()
{
	long long int n, m;
	cin >> m >> n;
	typedef bitset<32> bbl;
	bbl a(m), b(n);
	cout << (a&b) << endl;
	cout << (a | b) << endl;
	cout << (a^b) << endl;
	return 0;
}


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

int main() {
  string S;
  cin >> S;
  
  if (S.at(0)==S.at(1)||S.at(1)==S.at(2)||S.at(2)==S.at(3))
    cout << "Bad" << endl;
  else 
    cout << "Good" << endl;
 
}

Measured memory_bytes: 256
a=input()
flag=False
for i in ["+","-"]:
    for j in ["+","-"]:
        for k in ["+","-"]:
            cnt=int(a[0])
            if i=="+":
                cnt+=int(a[1])
            else:
                cnt-=int(a[1])
            if j=="+":
                cnt+=int(a[2])
            else:
                cnt-=int(a[2])
            if k=="+":
                cnt+=int(a[3])
            else:
                cnt-=int(a[3])
            if cnt==7:
                print(a[0]+i+a[1]+j+a[2]+k+a[3]+"=7")
                flag=True
                break
        if flag==True:
            break
    if flag==True:
        break

Measured memory_bytes: 3064
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

n, k = map(int, input().split())
a = list(map(int, input().split()))
MOD = 10 ** 9 + 7

plus_zero = []
minus = []

for i in a:
    if i >= 0:
        plus_zero.append(i)
    if i < 0:
        minus.append(-i)

from collections import deque

plus_zero = deque(sorted(plus_zero, reverse=True))
minus = deque(sorted(minus, reverse=True))
ans_lst = []
# 境界条件: k == n
if k == n:
    ans_lst.extend(a)
# 負
elif len(plus_zero) == 0 and (k % 2) != 0:
    for _ in range(k):
        ans_lst.append(-minus.pop())
# 正 or 0
else:
    while len(ans_lst) != k:
        if len(ans_lst) == k-1:
            ans_lst.append(plus_zero.popleft())
        else:
            if len(plus_zero) == 0:
                ans_lst.append(minus.popleft())
                ans_lst.append(minus.popleft())
                continue
            if len(plus_zero) == 1:
                if (k - len(ans_lst)) % 2 == 0:
                    ans_lst.append(minus.popleft())
                    ans_lst.append(minus.popleft())
                else:
                    ans_lst.append(plus_zero.popleft())
                continue
            if len(minus) < 2:
                ans_lst.append(plus_zero.popleft())
                continue
            if len(plus_zero) >= 2 and len(minus) >= 2:
                if (plus_zero[0] * plus_zero[1]) >= (minus[0] * minus[1]):
                    ans_lst.append(plus_zero.popleft())
                else:
                    ans_lst.append(minus.popleft())
                    ans_lst.append(minus.popleft())
                continue
# functools.reduceはTLEをくらう場合があるので気をつける
ans = 1
for i in ans_lst:
    ans = (ans * i) % MOD
print(ans)


Measured memory_bytes: 113700
#include <bits/stdc++.h>
#define rep(i, n) for(ll i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
const double PI=acos(-1);

int main(){
    ll n; cin >> n;
    vector<ll> b(n), ans;
    rep(i, n) cin >> b[i];
    rep(i, n){
        ll index = -1;
        rep(j, b.size()) if(b[j] == j+1) index = j;
        if(index != -1){
            ans.push_back(b[index]);
            b.erase(b.begin()+index);
        }
    }
    if(!b.empty()){
        cout << -1 << endl;
        return 0;
    }
    reverse(ans.begin(), ans.end());
    for(auto i : ans) cout << i << endl;
    return 0;
}

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

water_sum = sum(a)
kotae = [-1 for _ in range(n)]

# 和を足しておく
kotae[0] = water_sum

# 全体の和からほかの山の水量を引いて行って山0の水量を求める
for i in range(n // 2):
    kotae[0] -= 2*a[(1+2*i) % n]

# 漸化式でほかのすべてを求める
for i in range(1, n):
    kotae[i] = 2*a[i-1] - kotae[i-1]

print(" ".join(map(str, kotae)))

Measured memory_bytes: 19092
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>

using namespace std;
typedef pair<int, int> P;

int N;
vector<int> in;

int main() {
	cin >> N;
	int M = 0, m = 1145141919;
	int Midx, midx;
	for (int i = 0; i < N; i++) {
		int a;
		cin >> a;
		in.push_back(a);
		if (M < a)M = a, Midx = i;
		if (m > a)m = a, midx = i;
	}

	cout << 2 * N - 1 << endl;

	if (abs(M) > abs(m)) {
		for (int i = 0; i < N; i++) {
			in[i] += M;
			cout << Midx + 1 << " " << i + 1 << endl;
		}
		for (int i = 0; i < N - 1; i++) {
			cout << i + 1 << " " << i + 2 << endl;
		}
	}else {
		for (int i = 0; i < N; i++) {
			in[i] += m;
			cout << midx + 1 << " " << i + 1 << endl;
		}
		for (int i = N - 2; i >= 0; i--) {
			cout << i + 2 << " " << i + 1 << endl;
		}
	}

	return 0;
}

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

const long long MOD = 1000000007;
const long long INF = 1LL << 60;
const int INT_INF = 1000000000;

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

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  ll N, K;
  cin >> N >> K;
  vector<ll> A(N);
  for (auto &it : A)
    cin >> it;
  vector<int> used(N);
  used[1 - 1]++;
  int cnt = 0;
  cnt++;
  int next = A[0];
  vector<int> to;
  bool twice = false;
  while (true)
  {
    if (cnt == K)
    {
      cout << next << endl;
      return 0;
    }
    next = A[next - 1];
    cnt++;
    used[next - 1]++;
    if (used[next - 1] == 2)
      twice = true;
    if (used[next - 1] == 3)
      break;
    if (twice)
    {
      to.push_back(next);
    }
  }
  // cerr << cnt << endl;
  // cerr << to.size() << endl;
  K -= cnt;
  //for (auto &it : to)
  //cerr << it << endl;
  ll idx = K % to.size();
  ll ans = to[idx];
  cout << ans << endl;
  return 0;
}


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

int main() {
  int N,p,w,g,y;
  cin >> N;
  p=0;
  w=0;
  g=0;
  y=0;
  
  string si;
  for (int i=0;i<N;i++){
    cin >> si;
    if (si=="P"){
      p=1;
    }
    else if (si=="W"){
      w=1;
    }
    else if (si=="G"){
      g=1;
    }
    else if (si=="Y"){
      y=1;
    } 
  }
  if (p==1&&w==1&&g==1&&y==1){
    cout << "Four" << endl;
  }
  else {
    cout << "Three" <<endl;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int p;
string a;
int main()
{
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	cin>>a;
	p=a.size();
	cout<<a[0];
	cout<<p-2;
	cout<<a[p-1];
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = 1 << 29;
 
int main() {
	ll a,b,c,k;
	cin >> a >> b >> c >> k;
	if (k % 2 == 1) {
		cout << b - a << endl; 
	} 
	else cout << a - b << endl;
	return 0;
}

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

int main(void) {
  ll n, k;
  cin >> n >> k;
  ll now = 0;
  vector<pair<ll, ll>> vp(n);
  rep (i, n) {
    ll a, b;
    cin >> a >> b;
    vp[i] = make_pair(a, b);
  }
  sort(vp.begin(), vp.end());
  rep (i, n) {
    ll a = vp[i].first;
    ll b = vp[i].second;
    now += b;
    if (now >= k) {
      cout << a << endl;
      return 0;
    }
  }
  return 0;
}


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

int main(){
	int k;
	cin >> k;
	if(k%2==0) cout << (k/2) * (k/2) << endl;
	else cout << (k/2 + 1) * (k/2) << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define pb push_back
const int maxn=1e6+10;
const int mod=1e9+7;
const double pi=3.1415926535;
int w[3005],v[3005];
int dp[3005][3005][2];


int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n,t;
    cin>>n>>t;
    for(int i=1;i<=n;i++)
    {
        cin>>w[i]>>v[i];
    }
    int ans=0;
    for(int i=1;i<=n;i++)
    {
        for(int j=0;j<=t-1;j++)
        {
            dp[i][j][1]=max(dp[i-1][j][1],dp[i-1][j][0]+v[i]);
            if(j>=w[i])
            {
                dp[i][j][0]=max(dp[i-1][j][0],dp[i-1][j-w[i]][0]+v[i]);
                dp[i][j][1]=max(dp[i][j][1],dp[i-1][j-w[i]][1]+v[i]);
            }
            else
            {
                dp[i][j][0]=dp[i-1][j][0];
            }
            ans=max(ans,dp[i][j][1]);
            ans=max(ans,dp[i][j][0]);
        }
    }
    cout<<ans<<'\n';






}


Measured memory_bytes: 74112
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second
 
#define bit(n,k) ((n>>k)&1) //*n no k bit me 1 or 0*/

const int mx=100010;
const ll mod=1e9+7;

// matrix pow mod
void matpom(ll*mat,int size,ll n,int m){
  ll*temp=(ll*)malloc(size*size*sizeof(ll));
  ll*ans=(ll*)malloc(size*size*sizeof(ll));  
  rep(i,size)rep(j,size)ans[i*size+j] = i==j;
  while(n){
    if(n%2){
      rep(i,size*size)temp[i]=0;
      rep(i,size)rep(j,size)rep(k,size)temp[i*size+j]=(temp[i*size+j]+ans[i*size+k]*mat[k*size+j])%m;
      rep(i,size*size)ans[i]=temp[i];
    }
    rep(i,size*size)temp[i]=0;
    rep(i,size)rep(j,size)rep(k,size)temp[i*size+j]=(temp[i*size+j]+mat[i*size+k]*mat[k*size+j])%m;
    rep(i,size*size)mat[i]=temp[i];
    n/=2;
  }
  rep(i,size*size)mat[i]=ans[i];
  free(temp); free(ans);
}

ll a[50][50];         //in case of matrix pow mod //not vector
int main(){
  ll n,k;
  cin >> n >> k;
  rep(i,n)rep(j,n){ cin>>a[i][j]; }
  matpom((ll*)a,50,k,mod);
  ll ans = 0;
  rep(i,n)rep(j,n){ (ans+=a[i][j])%=mod; }
  cout << ans << endl;
  return 0;
}

/*
https://kyopro-friends.hatenablog.com/entry/2019/01/12/231035
dp[n][i][j]=(頂点iから頂点jへ行く長さnのパスの個数)
dp[n][i][j]=∑k dp[n−1][i][k]∗a[k][j]
となるわね。ところで、この積の形、よくみると行列の積と同じね！
dp[n][i][j]を(i,j)成分とする行列をDPnと書くことにすると、さっきの漸化式は
DPn=DPn−1A
になるわ。
DP0は明らかに単位行列だから、DPn=Anね。
求める答えは∑i,jdp[K][i][j]だから、AKを計算すれば求められるわよ。
行列累乗で解く問題は、次の２つのポイントを抑えておくといいわ。どっちも決め手になるほどじゃないけど……
・ポイント１：制約をみる
N≤50くらい、Kは109とか1018とかの大きな値、みたいな制約の問題は、サイズN×Nの行列をK乗するかも。
・ポイント２：繰り返し
今回の状態遷移の式を見ると、回数nが遷移に影響しないわね。
こういうふうに同じ状態遷移を何度も繰り返すものは、行列累乗かも。
*/

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

int main(void) {
    bool zohe[26] = {}, flag = true;
    string s;
    cin >> s;
    for (int i = 0; i < s.size(); i++) {
        if (zohe[s[i] - 'a']) {
            flag = false;
            break;
        }
        else zohe[s[i] - 'a'] = true;
    }
    cout << (flag ? "yes" : "no") << endl;
}


Measured memory_bytes: 256