akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <iomanip>
#include <math.h>
//#include <unistd.h>
//#include <stdio.h>
#define rep(i,x) for(ll i = 0;i<x;i++)
#define all(a) (a).begin(),(a).end()
using ll = long long;
using ld = long double;
using namespace std;
using dou = double;
const ll inf = 2147483647;
const ll INF = 1LL << 60;
const ld pi = 3.14159265358;
const ll mod = 1000000007;
typedef pair<ll,ll> P;
using graph = vector<vector<ll>>;
template<class T> inline bool chmax(T& a, T b){if(a < b){a = b; return true;}return false;}
template<class T> inline bool chmin(T& a, T b){if(a > b){a = b; return true;}return false;}
ll gcd(ll a,ll b){
    if(a < b)swap(a,b);
    if(a % b == 0)return b;
    else return gcd(b,a%b);
}
//素数判定O(sqrt(N))
bool isp(ll n){
    bool res = true;
    if(n == 1)return false;
    else{
        for(ll i = 2;i * i <= n;i++){
            if(n % i == 0){
                res = false;
                break;
            }
        }
        return res;
    }
}

ll fac[510000], finv[510000], inv[510000];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < 510000; i++){
        fac[i] = fac[i - 1] * i % mod;
        inv[i] = mod - inv[mod%i] * (mod / i) % mod;
        finv[i] = finv[i - 1] * inv[i] % mod;
    }
}

// 二項係数計算
ll nCk(ll n, ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
}
//nのm乗をMODで割ったあまりO(logN)
ll modpow(ll n,ll m,ll MOD){
    ll res = 1;
    while(m){
        if(m & 1)res = (res * n) % MOD;
        m >>= 1;
        n *= n;
        n %= MOD;
    }
    return res;
}

//printf("%.10f\n", N);
/*  vector<ll> vec = {1,2,5,6,8,9,10};
    cout << binary_search(all(vec),5) << endl; -> true*/
/*
    vector<ll> vec = {1,2,5,6,8,9,10};
    auto n = upper_bound(all(vec),4);
    cout << *n << endl; -> 5*/

//    cout << fixed << setprecision(15);

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll N,L;
    cin >> N >> L;
    ll ans = 0;
    ll cnt = INF;
    for(ll i = L;i < N + L;i++){
        if(abs(cnt) > abs(i)){
            cnt = i;
        }
        ans += i;
    }
    cout << ans - cnt << endl;
}
//30 -50
//-50 ~ -21

Measured memory_bytes: 3596
#include <iostream>
#include <iomanip>
#include <string>
#include <map>
#include <math.h>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <set>
#include <queue>
#include <sstream>
#include <stack>
#include <deque>
#include <memory.h>
#include <cassert>
#include <ctime>
#include <climits>
#include <list>
#include <time.h>
#include <unordered_map>
#include <bitset>
#include <exception>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef unsigned long long ull;
#define pb push_back
#define mp make_pair
#define FILE "file"
#define lc v << 1
#define rc (v << 1) + 1
#define inf 1e+9
#define linf ll(1e+18)
#define dinf 1e+14

typedef long long ll;
#define pb push_back
#define mp make_pair

void solve()
{
    int n;
    cin >> n;
    
    double res = 0;
    for(int i = 0; i < n; i++)
    {
        double x;
        string t;
        cin >> x >> t;
        if(t == "BTC")
        {
            res += x * 380000.0;
        }
        else
        {
            res += x;
        }
    }
    
    cout << fixed << setprecision(12) << res;
}

int main()
{
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    //freopen("/Users/bekhzodsoliev/Desktop/C++/cp/cp/file.in", "r", stdin);freopen("/Users/bekhzodsoliev/Desktop/C++/cp/cp/file.out", "w", stdout);
    
    int t = 1;
    //cin >> t;
    
    while(t--)
    {
        solve();
    }
    
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <deque>
#include <fstream>
#include <functional>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>
using namespace std;
using ll = long long;
#define fst first
#define snd second

/* clang-format off */
template <class T, size_t D> struct _vec { using type = vector<typename _vec<T, D - 1>::type>; };
template <class T> struct _vec<T, 0> { using type = T; };
template <class T, size_t D> using vec = typename _vec<T, D>::type;
template <class T> vector<T> make_v(size_t size, const T& init) { return vector<T>(size, init); }
template <class... Ts> auto make_v(size_t size, Ts... rest) { return vector<decltype(make_v(rest...))>(size, make_v(rest...)); }
template <class T> inline void chmin(T &a, const T& b) { if (b < a) a = b; }
template <class T> inline void chmax(T &a, const T& b) { if (b > a) a = b; }
/* clang-format on */

struct UnionFind {
  vector<int> parent;  // parent[root] is the negative of the size.
  UnionFind(int n)
      : parent(n, -1){};
  bool unite(int u, int v) {
    u = root(u);
    v = root(v);
    if (u == v) return false;
    if (parent[u] > parent[v]) swap(u, v);
    parent[u] += parent[v];
    parent[v] = u;
    return true;
  }
  bool find(int u, int v) {
    return root(u) == root(v);
  }
  int root(int u) {
    return parent[u] < 0 ? u : parent[u] = root(parent[u]);
  }
  int size(int u) {
    return -parent[root(u)];
  }
};

bool check(const vec<int, 2>& A, const vec<int, 2>& B, int L) {
  int N = A.size(), M = A[0].size();
  vector<UnionFind> uf(N, UnionFind(M + 1));
  int rem = M;
  while (rem > 0) {
    vector<int> cnt(M, 0);
    for (int i = 0; i < N; i++) {
      int j = uf[i].size(0) - 1;
      ++cnt[A[i][j]];
    }
    bool cont = false;
    for (int k = 0; k < M; k++) {
      if (cnt[k] > L) {
        cont = true;
        --rem;
        for (int i = 0; i < N; i++) {
          int j = B[i][k];
          uf[i].unite(j, j + 1);
        }
      }
    }
    if (!cont) {
      return true;
    }
  }
  return false;
}

int main() {
#ifdef DEBUG
  ifstream cin("in.txt");
#endif
  int N, M;
  while (cin >> N >> M) {
    vec<int, 2> A = make_v(N, M, -1);
    vec<int, 2> B = make_v(N, M, -1);
    for (int i = 0; i < N; i++) {
      for (int j = 0; j < M; j++) {
        cin >> A[i][j];
        --A[i][j];
        B[i][A[i][j]] = j;
      }
    }
    int fail = 0, pass = N;
    while (pass - fail > 1) {
      int L = (fail + pass) / 2;
      if (check(A, B, L)) {
        pass = L;
      } else {
        fail = L;
      }
    }
    cout << pass << endl;
  }
  return 0;
}


Measured memory_bytes: 1380
N = int(input())
S = input()
res = 1000000
prev_W = 0
prev_E = S.count('E')
for i in range(N):
    if i >= 1: prev_W += S[i-1].count('W')
    prev_E -= S[i].count('E')
    res = min(res,prev_W + prev_E)
print(res)

Measured memory_bytes: 3700
count = int(input())
line = input().split()
A = int(line[0])
B = int(line[1])
pivot = "NG"
lis = []
for i in range(A,B+1):
    lis.append(i)
    if i % count == 0:
        pivot = "OK"
        print(pivot)
        break
        
if pivot == "NG":
    print("NG")

Measured memory_bytes: 9192
#include "bits/stdc++.h"

typedef long long ll;
#define all(x) (x).begin(), (x).end()  // sortなどの引数を省略
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define max3(x, y, z) max(x, max(y, z))
#define min3(x, y, z) min(x, min(y, z))

#ifdef _MSC_FULL_VER  //デバッグ出力
#define dout cout
#define debug() if (true)
#define check(x) std::cout << "★" << #x << "の値:" << (x) << endl
#define pass(x) std::cout << "☆" << x << endl
#else
#define dout \
  if (false) cout
#define debug() if (false)
#define check(x) \
  if (false) cout << "★" << #x << "の値:" << (x) << endl
#define pass(x) \
  if (false) cout << "☆" << x << endl
#endif

using namespace std;
int main(){
  int N;
  cin >> N;
  vector<int> list(N);
  vector<int> list2(N);
  vector<int> s(N);
  rep(i, N) { s[i]=i+1;}
  rep(i, N) { cin >> list[i]; }
  rep(i, N) { cin >> list2[i]; }
  int cnt = 0;
  int a=0;
  int b=0;
  do {
    cnt++;
    if (s==list)a=cnt;
    if (s == list2) b = cnt;
  } while (next_permutation(s.begin(), s.end()));
  cout << abs(a-b);
}
/*
//よく使うやつ
int N;
cin >> N;
vector<int> list(N);
rep(i,N) {
  cin >> list[i];
}
//配列(スタックとしても使える)
vector<int> list;
list.at(i)
vector<vector<int>> list(10, vector<int>(10));
//ソート クイックだからO(NlogN)
sort(all(list));
sort(all(list), greater<int>());

//配列の内容表示
dout << "====listの内容====\n";
for (int edp = 0; edp < N; edp++) dout << list[edp] << endl;
dout << "====ここまで====\n";


//配列の最小最大(Nは要素数)
*min_element(all(c))
*max_element(all(c))

//a[0]からa[N]を逆順にする(計算量はO(N))
reverse(all(a));
//listの末尾に要素を追加
list.push_back(10);
//listの末尾から要素を削除
list.pop_back();
//空ですか？
list.empty()



//キュー(待ち行列)
//定義
queue<int> a;
//追加
a.push(x);
//取る
a.pop();
//チェック
a.front()
//サイズ
a.size()
//空ですか
a.empty()



//優先度付きキュー※全部計算量がO(NlogN)あるので注意
// int 型の要素を持ち、最も小さい値を取り出す形の priority_queue を定義
priority_queue<int, vector<int>, greater<int>> Q1;
// double 型の要素を持ち、最も大きい値を取り出す形の priority_queueを定義
priority_queue<double, vector<double>, less<double>> Q2;
//追加
a.push(x);
//取る
a.pop();
//一番小さいの教えて下さい
a.top()
//サイズ
a.size()
//空ですか
a.empty()



//部分文字列
//添字3から5文字
s.substr(3,5)
//添字3から全部
s.substr(3)

//入れ替え
swap(a,b);



// int 型の番地に string 型の変数を記録する場合（2^31 要素の string型配列と同じような感じ）
map<int, string> mp;
for (auto itr =mp.begin(); itr != mp.end(); itr++) {
    //順番にマップを眺める。itr->firstでキー、itr->secondがバリュー
}

//ソート済みのaの中で初めてx以上になるインデックスを返す
lower_bound(all(a), x) - a

//next_permutation
do {
  //ここにパーテーションがくる
} while (next_permutation(s.begin(), s.end()));

//set
set<int> hoge;
hoge.insert(50);  //hogeに挿入。重複は無視される。
hoge.insert(20);  //内部は小さい順に並ぶ
hoge.erase(50);   //hogeから消し去る。
//40以上である最小の要素を指すイテレーターを返す。
//もちろんそんなものはないからEndが出力される
auto itr1 = Set.lower_bound(40);
if (itr1 == Set.end()) cout << "End" << endl;
else cout << (*itr1) << endl;

//pair
//たくさんつくる
vector<pair<int,string>> hoge(10);
//参照
hoge[0].first
sort(all(hoge), greater<pair<int, string>>());




*/


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10 ** 7)
n = int(input())
#隣接リスト
adjacent_list = [[] for i in range(n+1)]
#入力されたデータを保存しておくやつ
data = [None] * (n - 1)
#最終的に色を入れておくやつ。
#edgedata[(1,2)] => 1->2の辺の色を入れておく
edgedata = {}
for i in range(n-1):
    a, b = list(map(int, input().split()))
    data[i] = [a, b]
    adjacent_list[a].append(b)
    adjacent_list[b].append(a)
#つながってるノードが一番多いやつを保存しておく
max_node = 0
#探索が終わったやつを入れる
finished = set()
for i in range(1,n):
    if len(adjacent_list[i]) > len(adjacent_list[max_node]):
        max_node = i
#kには色の種類を入れる
k = len(adjacent_list[max_node])
#print("k => {}".format(k))
def dfs(node, num):
    #隣接リストの中身を、つながってるノード順にソート
    node_list = sorted(adjacent_list[node], key = lambda x:len(adjacent_list[x]))
    #さっきつかったいろは使わないようにする
    color_list = [i for i in range(1,len(node_list) + 2) if i != num]
    c_i = 0
    finished.add(node)
    for i in node_list:
        #まだ見てなかったら、dfsを掛ける
        if i not in finished:
            #小さいほうから大きいほうに文字を並べ、ハッシュに値を保存
            #print("{}".format(color_list))
            #print("c_i =>{}  node =>{}".format(c_i,node))
            edgedata[(min(node, i), max(node, i))] = color_list[c_i]
            #color_list[c_i]は使ったので、使った色として引数で渡す。
            dfs(i, color_list[c_i])
            #この色は使ったから、一個ずらす
            c_i += 1
#一番のノードを根とし、dfsをかける
dfs(k,-1)
print(k)
for i in data:
    print(edgedata[tuple(i)])
#output k


Measured memory_bytes: 134040
#include<bits/stdc++.h>
using namespace std;
const int maxn=100005;

int Next[maxn][2],cnt;
char shit[maxn];
void add()
{
    int root=0;
    int l=strlen(shit);
    for(int i=0;i<l;i++)
    {
        int t=shit[i]-'0';
        if(Next[root][t]==-1){
            Next[root][t]=cnt++;
        }
        root=Next[root][t];
    }
}
long long dfs(int u,int dep,long long l)
{
    if(Next[u][0]==-1&&Next[u][1]==-1)
         return 0;
    long long sg=0;
    if(Next[u][0]==-1||Next[u][1]==-1)
    {
        long long tmp=l-dep;
        sg=sg^(tmp&(-tmp));
    }
    if(Next[u][0]!=-1)
        sg^=dfs(Next[u][0],dep+1,l);
    if(Next[u][1]!=-1)
        sg^=dfs(Next[u][1],dep+1,l);
    return sg;
}
int main()
{
    memset(Next,-1,sizeof(Next));
    cnt=1;
    int n;
    long long l;
    scanf("%d%lld",&n,&l);
    for(int i=1;i<=n;i++)
    {
        scanf("%s",shit);
        add();
    }
    long long sg=dfs(0,0,l);
    if(sg) puts("Alice");
    else puts("Bob");
    return 0;
}


Measured memory_bytes: 5760
N = int(input())
H = list(map(int, input().split()))

max = 0
i = 0
while N > i:
    count = 0
    j = i
    while N-1 > j:
        if H[j] >= H[j+1]:
            count += 1
            j += 1
        else:
            break
    if count > max:
        max = count
    i = j+1

print(max)

Measured memory_bytes: 14252
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<set>
#include<map>
#include<queue>
#define REP(i,a) for (int i = 0;i < (a);++i)
#define FOR(i,a,b) for (int i = (a);i < (b); ++i)
#define FORR(i,a,b) for (int i = (a);i >= (b); --i)
#define ALL(obj) (obj).begin,(obj).end()
#define SORT(list) sort(ALL((list)));
#define MOD 1000000007
using namespace std;
using ll = long long;
int main(){
    priority_queue<int>q;
    int n;
    cin >> n;
    REP(i,n){
        int a;
        cin >> a;
        q.push(a);
    }
    int a = q.top();
    q.pop();
    q.push(a/2);
    int answer = 0;
    REP(i,n){
        answer += q.top();
        q.pop();
    }
    cout << answer << endl;
    return 0;
}

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

using namespace std;

struct DrinkInfo{
        unsigned long long A;
        int B;
        bool operator<(const DrinkInfo &another) const
        {
                return  A< another.A;
        };
};


int main(){
        int N,M;
        unsigned long long ans=0;
        cin>>N>>M;

        DrinkInfo info[N];
        for(int i=0; i<N; i++) cin>>info[i].A>>info[i].B;

        sort(info,info+N);

        for(int i=0; i<N; i++){
                if(M<=info[i].B){
                        ans+=info[i].A*M;
                        break;
                }else{
                        ans+=info[i].A*info[i].B;
                        M-=info[i].B;
                }

        }

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


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


using namespace std;


int main(){
    int n;
    int a=0;
    int b=0;
    vector <int> card;
    cin>>n;
    for(int i=0; i<n; ++i){
        int m;
        cin>>m;
        card.push_back(m);
        sort(card.begin(), card.end(), greater<int>());
    }
    for(int i=0; i<n; ++i){
        if(i%2==0){
            a+=card[i];
        }
        else{
            b+=card[i];
        }
    }
    cout<<a-b<<endl;


}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<stdio.h>
#include<cmath>
#include<stack>
#include<set>
#include<map>
#include<stdio.h>
#include<functional>
#include<queue>

using ll = long long;

using namespace std;

ll mod = 1000000007;

ll n_pow(ll a, ll n) {
	if (n == 0)return 1;
	ll t = n_pow(a, n / 2);
	t *= t;
	t %= mod;
	if (n % 2 == 1)t *= a;
	return t % mod;
}

const int INF = 1001001001;
//const ll INF = 1e18;

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

ll cal_gcd(ll a, ll b) {
	ll m = max(a, b);
	ll n = min(a, b);
	while (m%n != 0) {
		ll b = m % n;
		m = n;
		n = b;
	}
	return n;
}

vector<pair<ll, ll>> prime_factorize(ll N) {
	vector<pair<ll,ll>> res;
	for (long long a = 2; a * a <= N; ++a) {
		if (N % a != 0) continue;
		long long ex = 0; 
		while (N % a == 0) {
			++ex;
			N /= a;
		}
		res.push_back({ a, ex });
	}
	if (N != 1) res.push_back({ N, 1 });
	return res;
}

int main() {
	int x;
	cin >> x;
	int gcd = cal_gcd(x, 360);
	int lcm = (x / gcd) * 360;
	cout << lcm / x << endl;
	return 0;
}


Measured memory_bytes: 3624
n = int(input())
w = list(map(int, input().split()))

s1, s2 = 0, sum(w)
ans = sum(w)

for i in range(n):
  s1 += w[i]
  s2 -= w[i]
  ans = min(ans, abs(s1 - s2))
print(ans)

Measured memory_bytes: 3060
#include <stdio.h>
 
int main() {
 
  int n,c;
  int a[101] = {0};
  int d,i,j;
  int flag;
 
 
  scanf("%d",&n);
 
  c = 0;
 
  for(i = 0;i<n;i++) {
 
    scanf("%d" ,&a[i]);
 
  }
 
  flag = 1;
 
  while(flag) { 
    flag = 0;
 
    for(j=n-1;j>=1;j--) {
       
      if(a[j] < a[j-1]) {
    d = a[j];
    a[j] = a[j-1];
    a[j-1] = d;
    c++;
    flag = 1;
      } 
    }
     
  }
 
  for(i=0;i<n;i++) {
    printf("%d",a[i]);
    if(i != n-1) printf(" ");
 
}
  printf("\n%d\n",c);
 
  return 0;
 
}


Measured memory_bytes: 2112
#include<bits/stdc++.h>
#define INF (1e9)
#define N 20
using namespace std;
typedef pair<int,int> P;
typedef pair<int,P> P1;

int w,h,idlen,sid,ans;
string s[N];
vector<int> id;
vector<P> edge[11];

int bfs(int sy,int sx,int gy,int gx){
  int d[N][N];
  int dy[4]={-1,0,1,0};
  int dx[4]={0,1,0,-1};
  queue<P1> q;
  for(int i=0;i<h;i++)
    for(int j=0;j<w;j++)d[i][j]=INF;
  d[sy][sx]=0;
  q.push(P1(0,P(sy,sx)));
  while(!q.empty()){
    P1 t=q.front(); q.pop();
    int c=t.first;
    int y=t.second.first,x=t.second.second;
    if(d[y][x]<c)continue;
    for(int i=0;i<4;i++){
      int ny=y+dy[i],nx=x+dx[i];
      if(ny<0||nx<0||h<=ny||w<=nx)continue;
      if(s[ny][nx]=='x')continue;
      if(d[ny][nx]>c+1){
	d[ny][nx]=c+1;
	q.push(P1(d[ny][nx],P(ny,nx)));
      }
    }
  }
  return d[gy][gx];
}

int dijkstra(){
  
  int d[(1<<idlen)][idlen];
  
  priority_queue<P1,vector<P1>,greater<P1> > q;
  
  for(int i=0;i<(1<<idlen);i++)
    for(int j=0;j<idlen;j++)d[i][j]=INF;
  
  
  d[(1<<sid)][sid]=0;
  
  q.push(P1(0,P((1<<sid),sid)));
  
  while(!q.empty()){
    P1 t=q.top(); q.pop();
    int S=t.second.first;
    int c=t.first,u=t.second.second;
    
    if(d[S][u]<c)continue;
    
    if(S==(1<<idlen)-1)return c;
    
    for(int i=0;i<(int)edge[u].size();i++){
      int nu=edge[u][i].first;
      int nc=edge[u][i].second;
      if((S&(1<<nu)))continue;
      if(d[(S|(1<<nu))][nu]>c+nc){
	d[(S|(1<<nu))][nu]=c+nc;
	q.push(P1(c+nc,P((S|(1<<nu)),nu)));
      }
    }
  }
  return -1;
}

int main(){
  while(1){
    cin>>w>>h;
    if(!w&&!h)break;
    for(int i=0;i<h;i++){
      cin>>s[i];
      for(int j=0;j<w;j++){
	if(s[i][j]=='.'||s[i][j]=='x')continue;
	if(s[i][j]=='o')sid=id.size();
	id.push_back(w*i+j);
      }
    }
    idlen=id.size();
    for(int i=0;i<idlen;i++)
      for(int j=i;j<idlen;j++){
	if(i==j)continue;
	int y1=id[i]/w,x1=id[i]%w;
	int y2=id[j]/w,x2=id[j]%w;
	int d=bfs(y1,x1,y2,x2);
	edge[i].push_back(P(j,d));
	edge[j].push_back(P(i,d));
      }
    ans=dijkstra();
    if(ans!=INF)cout<<ans<<endl;
    else cout<<-1<<endl;
    id.clear();
    for(int i=0;i<idlen;i++)edge[i].clear();
  }
  return 0;
}

Measured memory_bytes: 1320
// #define _GLIBCXX_DEBUG // for STL debug (optional)
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;

#define debug(...) fprintf(stderr, __VA_ARGS__)
#define int long long int
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
typedef pair<int, int> pii;
typedef long long ll;
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const ll INF = 1001001001001001LL;
const ll MOD = 1000000007LL;
 
signed main() {
    int A, B; cin >> A >> B;
    if(A >= 13) cout << B << endl;
    else if(6 <= A and A <= 12) cout << B / 2 << endl;
    else cout << 0 << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <set>
#include <sstream>
#include <bitset>
#include <stack>
#include <cstdlib>

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

typedef long long ll;

using namespace std;

int main() {
    
    int n,x;
    cin >> n >> x;
    
    vector<int> m(n);
    FOR(i, 0, n){
        cin >> m[i];
        x -= m[i];
    }
    
    int min = *min_element(m.begin(),m.end());
    
    cout << x/min + n << endl;
    
    return 0;
}


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

namespace AtCorder
{
	public class Program
	{
		static void Main(string[] args)
		{
			var cin = new Scanner();
			int n = cin.Int();
			if (n == 0) {
				Console.WriteLine("0");
				return;
			}

			var rev = new List<int>();
			int div = 1;
			int sign = 1;
			while (n != 0) {
				int d = n / div;
				if (d % 2 != 0) {
					rev.Add(1);
					n -= sign * div;
				} else {
					rev.Add(0);
				}

				div *= 2;
				sign *= -1;
			}

			var sb = new StringBuilder();
			int m = rev.Count;
			for (int i = m - 1; i >= 0; --i) {
				sb.Append(rev[i] == 0 ? "0" : "1");
			}

			Console.WriteLine(sb.ToString());
		}
	}

	public class Scanner
	{
		private readonly char[] delimiter_ = new char[] { ' ' };
		private string[] buf_;
		private int index_;

		public Scanner()
		{
			buf_ = new string[0];
			index_ = 0;
		}

		public string Next()
		{
			if (index_ < buf_.Length) {
				return buf_[index_++];
			}

			string st = Console.ReadLine();
			while (st == "") {
				st = Console.ReadLine();
			}

			buf_ = st.Split(delimiter_, StringSplitOptions.RemoveEmptyEntries);
			if (buf_.Length == 0) {
				return Next();
			}

			index_ = 0;
			return buf_[index_++];
		}

		public int Int() => int.Parse(Next());
		public long Long() => long.Parse(Next());
		public double Double() => double.Parse(Next());

		public int[] ArrayInt(int N, int add = 0)
		{
			int[] Array = new int[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Int() + add;
			}
			return Array;
		}

		public long[] ArrayLong(int N, long add = 0)
		{
			long[] Array = new long[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Long() + add;
			}
			return Array;
		}

		public double[] ArrayDouble(int N, double add = 0)
		{
			double[] Array = new double[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Double() + add;
			}
			return Array;
		}
	}
}

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

int main(void){
    int i,j,k;
    int N;
    int A[30],B[30],C[30];
    int answer = 0;
    
    scanf("%d",&N);
    for(i = 0;i < N-1;i++){
        scanf("%d\n",&A[i]);
    }
    scanf("%d",&A[i]);
    for(i = 0;i < N-1;i++){
        scanf("%d\n",&B[i]);
    }
    scanf("%d",&B[i]);
    for(i = 0;i < N-2;i++){
        scanf("%d\n",&C[i]);
    }
    scanf("%d",&C[i]);
    
    for(i = 0;i < N;i++){
        answer +=  B[A[i]-1];
        if(i != 0){
            if(A[i-1] == (A[i] - 1)){
                answer += C[A[i-1]-1];
            }
        }
    }
    
    printf("%d\n",answer);
    
    return 0;
}













Measured memory_bytes: 128
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-11;
const ll mod=1e9+7;
const int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};

int main(){
	while(1){
		int n,m;
		cin>>n>>m;
		if(n==0) break;
		vi a(n);
		int res=-1;
		for(int i=0;i<n;i++) cin>>a[i];
		for(int i=0;i<n;i++) for(int j=i+1;j<n;j++) if(a[i]+a[j]<=m) res=max(res,a[i]+a[j]);
		if(res==-1) cout<<"NONE"<<endl;
		else cout<<res<<endl;
	}
}


Measured memory_bytes: 3116
N = int(input())
L = list(map(int,input().split()))

p = 0
q = 0
r = 0

for i in range(N) :
    if L[i] % 4 == 0 :
        p += 1
    else :
        if L[i] % 2 == 0 :
            q += 1
        else :
            r += 1

if q == 0 :
    if p >= r-1 :
        ans = "Yes"
    else :
        ans = "No"
else :
    if p >= r :
        ans = "Yes"
    else :
        ans = "No"
        
print(ans)

Measured memory_bytes: 14252
import java.io.*;

/**
 * C3
 */
public class Main {

    public static void main(String[] args) throws IOException {
        DualList arr = new DualList();
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

        String line = br.readLine();
        int len = Integer.parseInt(line);
        for(int i=0; i<len; i++){
            String[] command = br.readLine().split(" ");
            switch (command[0]) {
                case "insert":
                    arr.insert(Integer.parseInt(command[1]));
                    break;
                case "delete":
                    arr.delete(Integer.parseInt(command[1]));
                    break;
                case "deleteFirst":
                    arr.deleteFirst();
                    break;
                case "deleteLast":
                    arr.deleteLast();
                    break;
            }
        }
        System.out.println(arr.dump());
    }
}

class InnerList{
    public InnerList prev = null;
    public InnerList next = null;
    public int self;
    public InnerList(int num){
        this.self = num;
    }
}

class DualList{
    public InnerList first = new InnerList(-1);
    public InnerList last = new InnerList(-1);

    public DualList(){
        this.first.next = this.last;
        this.last.prev = this.first;
    }

    public void insert(int x){
        InnerList inner = new InnerList(x);
        inner.prev = this.first;
        inner.next = this.first.next;
        this.first.next.prev = inner;
        this.first.next = inner;
    }

    public void delete(int x){
        InnerList current = this.first;
        while(true){
            current = current.next;
            if(current.next == null) break;
            if(current.self==x){
                del(current);
                break;
            }
        }
    }

    public void deleteFirst(){
        del(this.first.next);
    }

    public void deleteLast(){
        del(this.last.prev);
    }

    public String dump(){
        StringBuffer val = new StringBuffer();
        InnerList current = this.first.next;
        while(true){
            if(current.next == null) break;
            val.append(current.self);
            val.append(" ");
            current = current.next;
        }
        return val.toString().trim();
    }

    private void del(InnerList x){
        x.prev.next = x.next;
        x.next.prev = x.prev;
    }
}


Measured memory_bytes: 189024
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace __gnu_pbds;
using namespace __gnu_cxx;
using namespace std;

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

// Order Statistic Tree

/* Special functions:

        find_by_order(k) --> returns iterator to the kth largest element counting from 0
        order_of_key(val) --> returns the number of items in a set that are strictly smaller than our item
*/

typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>
ordered_set;

const int MAXN = 2e5+7;

int a[3][MAXN];

void cant() {
    cout << "No" << endl;
    exit(0);
}

int perm[MAXN];
int flipped[MAXN];

typedef long long LL;
vector< int >parts[2];
//ordered_set bam[2];
ordered_set dan[2];
//LL cnt[2];
int xoor[2];

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

    for (int i = 0; i < 3; i++) {
        for (int j = 0; j < n; j++) {
            cin >> a[i][j];
        }
    }

    for (int j = 0; j < n; j++) {
        if (a[0][j] < a[2][j]) {
            if (a[0][j] != a[1][j]-1) cant();
            if (a[2][j] != a[1][j]+1) cant();
            flipped[j] = 0;
        } else {
            if (a[0][j] != a[1][j]+1) cant();
            if (a[2][j] != a[1][j]-1) cant();
            flipped[j] = 1;
        }
        perm[j] = a[1][j]/3;
    }

    for (int i = 0; i < n; i++) {
        parts[i&1].push_back(perm[i]);
//        bam[i&1].insert(perm[i]);
    }

    sort(all(parts[0]));
    sort(all(parts[1]));

    for (int i = 0; i < parts[0].size(); i++) {
        if (i > 0) {
            if (parts[1][i-1] > parts[0][i]) cant();
        }
        if (i < parts[1].size()) {
            if (parts[0][i] > parts[1][i]) cant();
        }
    }

//    cout << "sort ok" << endl;
//    for (int i = 0; i < n; i++) cout << perm[i] << " ";
//    cout << endl;
//    for (int i = 0; i < n; i++) cout << flipped[i] << " ";
//    cout << endl;

    for (int i = n-1; i >= 0; i--) {
        int v = i&1;
        xoor[v] ^= flipped[i];

        int way = dan[v].order_of_key(perm[i]);
        dan[v].insert(perm[i]);

//        cout << i << " => " << way << endl;
        xoor[v^1] ^= way&1;
    }

//    for (int i = 0; i < n; i++) cout << flipped[i] << " ";
//    cout << endl;

    if (xoor[0] || xoor[1]) cant();

    cout << "Yes" << endl;

    return 0;
}


Measured memory_bytes: 7420
/*
これを入れて実行
g++ code.cpp
./a.out
 */
 
#include <iostream>
#include <stdio.h>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <unordered_map>
#include <cmath>
#include <math.h>
#include <tuple>
#include <iomanip>
#include <bitset>
#include <functional>
 
using namespace std;
typedef long long ll;
typedef long double ld;
 
int dy4[4] = {-1, 0, +1, 0};
int dx4[4] = {0, +1, 0, -1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};
 
const long long INF = 1LL << 60;
const ll MOD = 1e9 + 7;
 
bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}
 
ll gcd(ll a, ll b){
	if (b == 0)return a;
	return gcd(b, a % b);
}
 
ll lcm(ll a, ll b){
    return a / gcd(a, b) * b;
}
 
ll nCr(ll n, ll r){
    if(r == 0 || r == n){
        return 1;
    } else if(r == 1){
        return n;
    }
    return (nCr(n - 1, r) + nCr(n - 1, r - 1));
}
 
ll nPr(ll n, ll r){
    r = n - r;
    ll ret = 1;
    for (ll i = n; i >= r + 1; i--) ret *= i;
    return ret;
}
 
//-----------------------ここから-----------
int main(void){
    int n, k;
    cin >> n >> k;

    int ans = 0;
    while(n > 0){
        n /= k;
        ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <string>
#include<limits>
#include<cstdlib>
#include<functional>
#include<cassert>
#include <cstdio>
#include <stack>
#include <queue>
#define fi(p) for(int i=0;i<(p);i++)
using namespace std;
int N;
int L;
int P;
const int MAX_N = 100000;
const int MAX_W = 100000;


int A[MAX_N+1];
int B[MAX_N+1];

void solve() {
	int K;
	cin >> K;
	int x = K / 2;
	int y = K - x;

	cout << x * y << endl;
	
	
	
}

int main()
{
	solve();

	int a;//止める用
	cin >> a;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cmath>
#include <vector>
#include <algorithm>
using namespace std;



int main() {

	
	int A;
	int B;
	int xA;
	int xB;
	double minxA;
	double maxxA;
	double minxB;
	double maxxB;
	double res_d;
	int res_int = -1;


	cin >> A;
	cin >> B;
	// 最大と最小のx(価格)を計算
	for (int i = 0; i < 1010; i++) {
		xA = (i * 8) / 100;
		xB = (i * 10) / 100;
		if (xA == A && xB == B) {
			res_int = i;
			break;
		}
	}

	cout << res_int << endl;
	return 0;
}

Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
#define PI 3.14159265359
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
const long long INF= 1e+18+1;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll> >vvl;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> T;
const ll MOD=1000000007LL;
string abc="abcdefghijklmnopqrstuvwxyz";
string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
struct UnionFind {
    vector<ll> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(ll N) : par(N) { //最初は全てが根であるとして初期化
        for(ll i = 0; i < N; i++) par[i] = i;
    }

    ll root(ll x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(ll x, ll y) { // xとyの木を併合
        ll rx = root(x); //xの根をrx
        ll ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(ll x, ll y) { // 2つのデータx, yが属する木が同じならtrueを返す
        ll rx = root(x);
        ll ry = root(y);
        return rx == ry;
    }
};
int main(){
  ll n,m;cin>>n>>m;
  vl p(n);
  rep(i,n){
    cin>>p[i];
    p[i]--;
  }
  UnionFind tree(2*n);
  rep(i,n){
    tree.unite(i,p[i]+n);
  }
  rep(i,m){
    ll x,y;
    cin>>x>>y;
    x--;y--;
    tree.unite(x+n,y+n);
  }
  ll count=0;
  rep(i,n){
    if(tree.same(i,i+n))count++;
  }
  cout<<count<<endl;
}
  

Measured memory_bytes: 2560
from collections import deque
n = int(input())
nodes = [list(map(int,input().split())) for _ in range(n-1)]
p = [[] for y in range(n+1)]
for node in nodes:
  p[node[0]].append(node[1])
  p[node[1]].append(node[0])

queue = deque([[1,0]])
fen = [float('inf')]*(n+1)
visited = [0]*(n+1)
visited[1] = 1
while 0 < len(queue):
  tmp = queue.popleft()
  if tmp[0] == n:
    path = tmp[1] - 1
    continue
  fen[tmp[0]] = tmp[1]
  for x in p[tmp[0]]:
    if visited[x] == 0:
      queue.append([x,tmp[1]+1])
      visited[x] = 1

queue2 = deque([[n,0]])
visited = [0]*(n+1)
visited[n] = 1
snu = [float('inf')]*(n+1)
while 0 < len(queue2):
  tmp = queue2.popleft()
  if tmp[0] == 1:
    continue
  snu[tmp[0]] = tmp[1]
  for x in p[tmp[0]]:
    if visited[x] == 0:
      queue2.append([x,tmp[1]+1])
      visited[x] = 1
countf,counts = 0,0
for i in range(1,n+1):
  if fen[i] <= snu[i]:
    countf += 1
  else:
    counts += 1
print('Fennec') if counts < countf else print('Snuke')


Measured memory_bytes: 43568
# ABC113C - ID
import sys
input = sys.stdin.readline

def main():
    N, M = tuple(map(int, input().split()))
    P = [[] for _ in range(N + 1)]  # prefectures
    for num in range(M):
        pref, year = tuple(map(int, input().split()))
        P[pref] += [(year, num)]
    ans = []
    P = [sorted(p) for p in P]
    for pref_idx, pref in enumerate(P[1:], 1):
        if pref:
            for city_idx, (_, num) in enumerate(pref, 1):
                x = "{:06}{:06}".format(pref_idx, city_idx)
                ans += [(num, x)]
    print(*[i[1] for i in sorted(ans)], sep="\n")

if __name__ == "__main__":
    main()

Measured memory_bytes: 46100
#include<bits/stdc++.h>
#define int long long 
using namespace std;
const int N=3005;
long long a[N],sum[N],dp[N][N];
void dfs(int l,int r)
{
	if(r-l==1)
	{
		dp[l][r]=max(a[l],a[r]);
		return;
	}
	if(!dp[l+1][r])
		dfs(l+1,r);
	if(!dp[l][r-1])
		dfs(l,r-1);
	dp[l][r]=max(a[l]+sum[r]-sum[l]-dp[l+1][r],a[r]+sum[r-1]-sum[l-1]-dp[l][r-1]);
}
main()
{
	int n;
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%lld",&a[i]);
		dp[i][i]=a[i];
		sum[i]=sum[i-1]+a[i];	
	} 
	if(n==1)
	{
		printf("%lld\n",a[1]);
		return 0;
	}
	dfs(1,n);
	int sum1=dp[1][n],sum2=sum[n]-dp[1][n];
	printf("%lld\n",sum1-sum2);
	return 0;
}


Measured memory_bytes: 70144
#include <bits/stdc++.h>
#define rep(n) for(lint I = 0; (I) < (lint)(n); ++(I))
#define repeat(i, n) for(lint i = 0; (i) < (lint)(n); ++(i))
#define repeat_to(i, n) for(lint i = 0; (i) <= (lint)(n); ++(i))
#define repeat_from(i, m, n) for(lint i = (m); (i) < (lint)(n); ++(i))
#define repeat_from_to(i, m, n) for(lint i = (m); (i) <= (lint)(n); ++(i))
#define el cout<<endl
#define dump(x) cout<<" "<<#x<<"="<<x
#define vdump(v) for(size_t I=0; I<v.size(); ++I){cout<<" "<<#v<<"["<<I<<"]="<<v[I];} cout<<endl
using namespace std;
using lint = long long;
using ld = long double;

int main(void) {
    int n;
    cin >> n;
    string s1, s2;
    cin >> s1 >> s2;
    
    lint ans = 1;
    const lint MOD = 1e9 + 7;
    repeat(i, n) {
        if (s1[i] == s2[i]) {
            if (i == 0) {
                ans *= 3;
                ans %= MOD;
            }
            else if (s1[i-1] == s2[i-1]) {
                ans *= 2;
                ans %= MOD;
            }
        }
        else {
            if (i == 0) {
                ans *= 6;
                ans %= MOD;
            }
            else if (s1[i-1] != s1[i]) {
                if (s1[i-1] == s2[i-1]) {
                    ans *= 2;
                    ans %= MOD;
                }
                else {
                    ans *= 3;
                    ans %= MOD;
                }
            }
        }
    }
    cout << ans << endl;
            
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cstring>
#include <algorithm>
#include <map>
using namespace std;

char ch[1000];
int n,m;

int putA(char x){
	for(int i = 1 ; i <= n ; i++){
		if( ch[i] == '#' ){
			ch[i] = x;
			break;
		}
	}
	return 0;
}
int putB(char x){
	for(int i = n ; i >= 1 ; i--){
		if(ch[i] == '#' && ch[i-1] != 'A' && ch[i+1] != 'A' ){
			ch[i] = x;
			return 0;
		}
	}
	// else
	putA(x);
}

int putC(char x){
	
	for(int i = 1 ; i <= n ; i++){
		if( ch[i] != '#'){
			if( i+1 <= n && ch[i+1] == '#' ){ ch[i+1] = x; return 0; }
			if( i-1 >= 1 && ch[i-1] == '#' ){ ch[i-1] = x; return 0; }
		}
	}
	if( n % 2 ){
		ch[(n+1)/2] = x;
	}else{
		ch[n/2+1] = x;
	}
}
int putD(char x){
	int distance = 0 , idx = 0;
	for(int i = 1 ; i <= n ; i++){
		int best = 10000;
		for(int j = 1 ; j <= n ; j++){
			if( ch[j] != '#' ) best = min(abs(i-j),best);
		}
		if( best > distance ){
			idx = i;
			distance = best;
		}
	}
	ch[idx] = x;
}
int main(){
	while(cin >> n >> m && n){
		for(int i = 0 ; i < 1000 ; i++) ch[i] = '#';
		for(int i = 0 ; i < m ; i++){
			char c;
			cin >> c;
			if( c == 'A' ) putA(c);
			if( c == 'B' ) putB(c);
			if( c == 'C' ) putC(c);
			if( c == 'D' ) putD(c);
			/*for(int j = 1 ; j <= n ; j++)
				cout << ch[j];
			cout << endl;
			*/
		}
			for(int i = 1 ; i <= n ; i++)
				cout << ch[i];
			cout << endl;


	}
}

Measured memory_bytes: 1152
def main(n, choices):
    results = [[0, 0, 0] for _ in range(n)]
    results[0] = choices[0]
    for i in range(1, n):
        results[i][0] = choices[i][0] + max(results[i - 1][1], results[i - 1][2])
        results[i][1] = choices[i][1] + max(results[i - 1][0], results[i - 1][2])
        results[i][2] = choices[i][2] + max(results[i - 1][0], results[i - 1][1])
    return max(results[-1])


if __name__ == '__main__':
    N = int(input())
    C = []
    for _ in range(N):
        C.append(list(map(int, input().split())))
    print(main(N, C))


Measured memory_bytes: 47368
#include <bits/stdc++.h>
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define REP(i,n) for(int i=0;i<n;i++)
#define FORq(i, m, n) for(int i = m;i <= n;i++)
#define SCD(n) scanf("%d",&n)
#define SCD2(m,n) scanf("%d%d",&m,&n)
#define PRINTD(n) printf("%d\n",n)
#define DEBUG printf("%s\n","debug")
using namespace std;
//////////////////////////////////////////////////////
const int MAX = 1002;
const int p = 1000000007;
bool prime[MAX];
bool dic[MAX];




bool Isprime(int num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false; // 偶数はあらかじめ除く

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            // 素数ではない
            return false;
        }
    }

    // 素数である
    return true;
}

bool IsPrime(int num)
{
    if (dic[num]) {
         return prime[num];
    } else {
         dic[num] = true;
         return prime[num] = Isprime(num);
      }
}

int main() {
    int N;
    SCD(N);
    int a[MAX] = {};
    int i = 2;
    
    FORq(j,2,N){
        int n = j;
        
        while(i<=n){
            if (!IsPrime(i)){
                i++;
                continue;
            }
        
            if ((n%i) == 0){
                a[i] = (a[i] + 1) % p;
                n = n/i;
                continue;
            }else{
                i++;
                continue;
            }
        }
        i = 2;
    }
    
    long long ans = 1;
    
    REP(i,MAX){
        ans = (ans * ((1 + a[i]) % p)) % p;
    }
    
    PRINTD(ans);
    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long a,b,c;
    scanf("%lld%lld%lld",&a,&b,&c);
    if(a+b>=c)
    {
        cout<<b+c<<endl;
    }
    else{
        cout<<(a+b)*2+1-a<<endl;
    }
}


Measured memory_bytes: 256
#include <cstdio>
#include <vector>
#include <algorithm>
#include <functional>

using namespace std;

typedef long long ll;

int main() {
    ll x, y, z, k;
    scanf("%lld%lld%lld%lld", &x, &y, &z, &k);
    vector<ll> a(x), b(y), c(z), ab(x * y), abh(min(k, x * y)), abc(min(k, x * y) * z);
    for (ll i = 0; i < x; ++i) scanf("%lld", a.begin() + i);
    for (ll i = 0; i < y; ++i) scanf("%lld", b.begin() + i);
    for (ll i = 0; i < z; ++i) scanf("%lld", c.begin() + i);
    for (ll i = 0; i < x; ++i) for (ll j = 0; j < y; ++j) ab.at(i * y + j) = a.at(i) + b.at(j);
    sort(ab.begin(), ab.end(), greater<ll>());
    sort(c.begin(), c.end(), greater<ll>());
    for (ll i = 0; i < min(k, x * y); ++i) abh.at(i) = ab.at(i);
    for (ll i = 0; i < min(k, x * y); ++i) for (ll j = 0; j < z; ++j) abc.at(i * z + j) = abh.at(i) + c.at(j);
    sort(abc.begin(), abc.end(), greater<ll>());
    for (ll i = 0; i < k; ++i) printf("%lld\n", abc.at(i));
    return 0;
}


Measured memory_bytes: 31616
#include <bits/stdc++.h>
#define rep(i,N) for (int i = 0; i < (N); ++i)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
int main(void){
  int a, b;
  cin >> a >> b;

  if ((a - b) % 2 == 0) cout << (a + b) / 2 << endl;
  else cout << "IMPOSSIBLE" << endl;
}


Measured memory_bytes: 3604
#!/usr/bin/env python3

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

def nCr(n,r):
    return fact[n]*pow(fact[n-r],mod-2,mod)*pow(fact[r],mod-2,mod) % mod

r1,c1,r2,c2 = LI()

n = r2+c2+2
fact = [1]*(n+1)
for i in range(1,n+1):
    fact[i] = i*fact[i-1]
    fact[i] %= mod

ans = nCr(r2+c2+2,r2+1) -1
ans -= nCr(r2+c1+1,r2+1) - 1
ans -= nCr(r1+c2+1,c2+1) - 1
ans += nCr(r1+c1,c1) - 1
ans %= mod
print(ans)

Measured memory_bytes: 55660
#!/usr/bin/perl

use strict;
use warnings;
use integer;

my $n = <STDIN>;
for (my $i=$n**0.5; $i>=1; $i--)
{
    if ($n%$i==0)
    {
        my $ans = $i+$n/$i-2;
        print "$ans\n";
        exit;
    }
}

Measured memory_bytes: 768
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<vector>
#include<utility>
#include<string>
#include<stack>
#include<queue>
#include<set>
#include<math.h>
#include <map>
using namespace std;
typedef long long int ll;
#define repi(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,a) repi(i,0,a)
#define all(u) u.begin(),u.end()
#define pl pair<ll,ll>
#define fi first
#define se second
#define inf 1000000007
#define mp(a,b) make_pair(a,b)
#include<unordered_map>

string s;
ll x,y;
vector<ll>F;
bool dpx[8010][16010];
bool dpy[8010][16010];
ll dx;
ll dy;


int main() {
    cin >> s;
    cin >> x >> y;
    ll temp = 0;
    dpx[0][8000] = true;
    dpy[0][8000] = true;
    dpy[1][8000] = true;
    rep(i,s.size()){
        if(s[i] == 'T'){
            F.push_back(temp);
            temp = 0;
        }
        else if(s[i] == 'F' && i == s.size()-1){
            temp++;
            F.push_back(temp);
        }
        else temp++;
    }
    rep(i,F.size()){
        if (i%2) dy+=F[i];
        else dx+=F[i];
    }
    
    for(ll i=0; i<F.size();i++){
        if (i == 0){
            dpx[i+1][8000+F[i]] = true;
        }
        else if(i%2==0){
            for(ll j = 8000-dx; j<=8000+dx;j++){
                if (((j-F[i]>=0)&&dpx[i-1][j-F[i]]) || (j+F[i]<16010&&dpx[i-1][j+F[i]])){
                    dpx[i+1][j]=true;
                }
            }
        }
        else{
            for(ll j = 8000-dy; j<=8000+dy;j++){
                if (((j-F[i]>=0)&&dpy[i-1][j-F[i]]) || (j+F[i]<16010&&dpy[i-1][j+F[i]])){
                    dpy[i+1][j]=true;
                }
            }
        }
    }
    ll X,Y;
    if (F.size()%2){
        X = F.size();
        Y = X-1;
    }
    else{
        X = F.size()-1;
        Y = F.size();
    }
    if (dpx[X][x+8000] == true && dpy[Y][8000+y] == true){
        cout << "Yes" << endl;
    }
    else cout << "No" << endl;
    
    return 0;
}


Measured memory_bytes: 248448
#include<bits/stdc++.h>
using namespace std;
long long f(int a){
  if (a < 0) return 0;
  return 1LL * a * (a - 1) / 2;
}
int main() {
  int n;
  cin >> n;
  vector<int> a(n), cnt(n + 1);
  for (auto& x : a) cin >> x, cnt[x]++;
  long long sum = 0;
  for (int i = 0; i <= n; i++) sum += f(cnt[i]);
  for (int k = 0; k < n; k++) {
    cout << sum - cnt[a[k]] + 1 << endl;
  }
}

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

int main() {
  int N, M;
  cin >> N >> M;
  vector<int>A(2*M);
  for(int i=0; i<2*M; i++)cin >> A.at(i);
  
  vector<int>ANS(N);
  for(int i=0; i<2*M; i++){
    ANS.at(A.at(i)-1) ++;
  }
  
  for(int i=0; i<N; i++)cout << ANS.at(i) <<endl;
}


Measured memory_bytes: 3636
#include <stdio.h>

int main(void)
{
	char c;

	while (1){
		scanf("%c", &c);
		if (c == '\n'){
			printf("\n");
			break;
		}
		
		printf("%c", (((c - 'A') -  3 + 26) % 26) + 'A');
	}
	
	return (0);
}

Measured memory_bytes: 524
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
using namespace std;
typedef long long int lli;

bool dfs(int p, vector<vector<pair<int, int> > > &adj, vector<lli> &pos, vector<bool> &used){
    used[p] = true;
    for(int i=0; i<(int)adj[p].size(); i++){
        int npos = adj[p][i].first;
        int d = adj[p][i].second;
        if(used[npos]){
            if(pos[p]+d != pos[npos]){
                return false;
            }
        }else{
            bool ret;
            pos[npos] = pos[p] +d;
            ret = dfs(npos, adj, pos, used);
            if(!ret) return false;
        }
    }
    return true;;
}

int main(){
    int n,m;
    cin >> n >> m;
    vector<vector<pair<int, int> > > adj(n);
    for(int i=0; i<m; i++){
        int l,r,d;
        cin >> l >> r >> d;
        l--; r--;
        adj[l].push_back(make_pair(r, d));
        adj[r].push_back(make_pair(l, -d));
    }

    bool ans = true;
    vector<lli> pos(n, 0);
    vector<bool> used(n, false);
    for(int i=0; i<n && ans; i++){
        if(!used[i]){
            ans = dfs(i, adj, pos, used);
        }
    }
    if(ans){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }   
    return 0;
}


Measured memory_bytes: 14208
#include "bits/stdc++.h"
using namespace std;

constexpr long long INF = 1000000000000000000, MOD = 1000000007;

int main() {
	vector<long long> Fib;
	Fib.push_back(1), Fib.push_back(1);
	while (1) {
		Fib.push_back(Fib[Fib.size() - 2] + Fib[Fib.size() - 1]);
		if (Fib[Fib.size() - 1] > INF) {
			Fib.pop_back();
			break;
		}
	}
	vector<vector<pair<long long, long long> > > Pair(Fib.size());
	Pair[1].push_back({ 1, 2 });
	for (int i = 1; i < Fib.size() - 1; i++) {
		for (int j = 0; j < Pair[i].size(); j++) {
			Pair[i + 1].push_back({ Pair[i][j].second, Pair[i][j].first + Pair[i][j].second });
		}
		Pair[i + 1].push_back({ Pair[i][0].first + Pair[i][0].second, Pair[i][0].first + Pair[i][0].first + Pair[i][0].second });
	}
	int Q;
	cin >> Q;
	for (int q = 0; q < Q; q++) {
		long long X, Y;
		cin >> X >> Y;
		if (X > Y) swap(X, Y);
		if (X == 1 || Y == 2) {
			cout << 1 << ' ' << (X * Y) % MOD << endl;
			continue;
		}
		int A = -1;
		for (int i = 0; ; i++) {
			if (Fib[i] <= X && Fib[i + 1] <= Y) A++;
			else break;
		}
		cout << A << ' ';
		long long B = 0;
		for (int i = 0; i < A; i++) {
			long long P = Pair[A][i].first, Q = Pair[A][i].second;
			if (P <= X) B += (Y - Q + P) / P, B %= MOD;
			if (Q <= X) B += (X - Q + P) / P, B %= MOD;
		}
		cout << B << endl;
	}
}


Measured memory_bytes: 4404