akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;

#define rep(i,n) for(ll i=0;i<(n);++i)
using ll = long long;
using pll = pair<ll,ll>;
constexpr ll INF = (1LL<<60);
constexpr ll MOD = (1e9+7);
//constexpr ll MOD = (998244353);
template<class T> bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T> bool chmin(T &a,const T &b){if(a>b){a=b;return 1;}return 0;}
#if loc||debg||local||debug
void dump(){cerr<<endl;}
template<class T,class... Ts> void dump(T&& h, Ts&&... t){cerr<<h<<", ";dump(forward<Ts>(t)...);}
#else
template<class T,class... Ts> void dump(T&& h, Ts&&... t){}
#endif
template<class T> istream &operator>>(istream&is,vector<T>&v){for(auto &elemnt:v)is>>elemnt;return is;}
template<class T,class U> istream &operator>>(istream&is,pair<T,U>&p){is>>p.first>>p.second;return is;}
template<class T> ostream &operator<<(ostream& os,vector<T>const& v){for(auto const& vi:v)os<<vi<<" ";return os;}
template<class T>vector<T> vec(size_t a){return vector<T>(a);}
template<class T, class... Ts>auto vec(size_t a, Ts... ts){return vector<decltype(vec<T>(ts...))>(a, vec<T>(ts...));}
template<class T>vector<T> _vec(size_t a,T v){return vector<T>(a,v);}
template<class T, class... Ts>auto _vec(size_t a, Ts... ts){return vector<decltype(_vec<T>(ts...))>(a, _vec<T>(ts...));}

template<class T>
class Union_Find {
private:
  T n;
  vector<T> parent;
public:
  Union_Find(T v){
    n=v;
    parent.resize(n,-1);
  }
  T root(T v){
    if(parent[v]<0)return v;
    return parent[v]=root(parent[v]);
  }
  T size(T v){
    return -parent[root(v)];
  }
  bool connect(T a,T b){
    a=root(a);
    b=root(b);
    if(a==b)return false;
    if(size(a)<size(b)) swap(a,b);
    parent[a]+=parent[b];
    parent[b]=a;
    return true;
  }
  bool same(T a,T b){
    return root(a)==root(b);
  }
  T operator[](T a){
    return root(a);
  }
  bool operator()(T a,T b){
    return connect(a,b);
  }
};

int main(){

  int n;
  cin>>n;
  auto a = vec<ll>(n,n);
  cin>>a;

  auto b = a;
  bool is_shortest = true;
  rep(k,n)rep(i,n)rep(j,n){
    if(chmin(a[i][j],a[i][k]+a[k][j]))is_shortest=false;
  }
  if(!is_shortest){
    cout<<(-1)<<endl;
    return 0;
  }

  struct edge{
    ll f,t,c;
    edge(){}
    edge(ll f,ll t,ll c):f(f),t(t),c(c){}
    bool operator< (edge const& rhs){
      return c < rhs.c;
    }
  };
  vector<edge> E;
  E.reserve(n*n);
  rep(i,n)rep(j,n){
    if(i<=j)continue;
    E.emplace_back(i,j,a[i][j]);
  }
  sort(E.begin(),E.end());

  ll ans = 0;
  auto d = _vec<ll>(n,n,INF);
  for(auto e:E){
    if(chmin(d[e.f][e.t],e.c)){
      d[e.t][e.f] = e.c;
      ans += e.c;
      rep(i,n)rep(j,n){
        chmin(d[i][j],d[i][e.f]+d[e.f][j]);
        chmin(d[i][j],d[i][e.t]+d[e.t][j]);
      }
      rep(i,n)rep(j,n){
        chmin(d[i][j],d[i][e.f]+d[e.f][j]);
        chmin(d[i][j],d[i][e.t]+d[e.t][j]);
      }
    }
  }
  cout<<(ans)<<endl;

}

Measured memory_bytes: 3456
#include <iostream>
#include <algorithm>
using namespace std;
int main()
{
    auto fRev = false;
    string s;
    cin >> s;
    int q;
    cin >> q;
    for (auto i = 0; i < q; ++i)
    {
        char t;
        cin >> t;
        if (t == '1')
        {
            fRev = !fRev;
        }
        else
        {
            char f, c;
            cin >> f >> c;
            if (!fRev && f == '1' || fRev && f == '2')
            {
                s.insert(s.begin(), c);
            }
            else
            {
                s.push_back(c);
            }
        }
    }
    if (fRev)
        reverse(s.begin(), s.end());

    cout << s << endl;

    return 0;
}

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

int main(){
    int n;
    cin>>n;
    vector<int> p(n);
    for(int i=0;i<n;i++){
        cin>>p.at(i);
    }

    int count=0;
    for(int i=1;i<n-1;i++){
        if((p.at(i-1)<p.at(i)&&p.at(i)<p.at(i+1))||(p.at(i-1)>p.at(i)&&p.at(i)>p.at(i+1))) count++;
    }
    cout<<count<<endl;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(1000000)
import functools
P = 1000000007

@functools.lru_cache(maxsize=None)
def f(n):
    if n == 0:
        return 1
    else:
        s = 0
        for i in range(3,n+1):
            s += f(n-i)
        return s % P

S=int(input())
print(f(S))


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

using namespace std;
typedef long long int ll;
typedef pair<ll, ll > pi;  
typedef pair<pair<ll, ll >, ll > pii;  
vector<ll > vec;
vector<vector<ll > > vec2;
ll MOD = 1000000007;
ll INF = 1145141919454519;

int main() {

    ll A, B, C, D;
    cin >> A >> B >> C >> D;

    cout << max(0LL ,min(B, D) - max(A, C)) << endl;

}

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

int main() {
    int A, B;
    char op;
    std::cin >> A >> op >> B;

    if (op == '+') {
        std::cout << A + B << std::endl;
    } else {
        std::cout << A - B << std::endl;
    }

    return 0;
}


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


int main()
{

  ios::sync_with_stdio(0);
  cin.tie(0);
  int n;
  cin>>n;
  bool t=false;
  for(int i=1; i<10; i++){
    if(n%i==0){
        int a=n/i;
        if(a<=9){t=true; break;}
    }
  }
  if(t){cout<<"Yes";}
  else{cout<<"No";}
  return 0;
}

Measured memory_bytes: 3640
# -*- coding: utf-8 -*-
n = int(input())
al = list(map(int, input().split()))
bl = list(map(int, input().split()))

res = 0
for i in range(n):
    if al[i]<bl[i]:
        res += al[i]
        bl[i] -= al[i]
        al[i] = 0
    else:
        res += bl[i]
        al[i] -= bl[i]
        bl[i] = 0

    if bl[i]>0:
        if al[i+1]<bl[i]: 
            res += al[i+1]
            bl[i] -= al[i+1]
            al[i+1] = 0
        else:
            res += bl[i]
            al[i+1] -= bl[i]
            bl[i] = 0

print(res)

Measured memory_bytes: 82020
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
	ll A,B,C;
	cin>>A>>B>>C;
	if(C-A-B>1){
		cout<<(C+B)-(C-A-B)+1<<endl;
	}else cout<<B+C<<endl; 
} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
	int H, W; 
	cin >> H >> W; 
	int C[30] = {}; 
	for(int i = 0; i < H * W; i++){
		char c; cin >> c; 
		C[c - 'a'] ++; 
	}
	int res[5] = {}; 
	for(int i = 0; i < 26; i++){
		res[C[i] % 4] ++; 
	}
	string ans = "Yes"; 
	if(H % 2 == 0 && W % 2 == 0){
		if(res[1] || res[2] || res[3]) ans = "No"; 
	}
	else if(H % 2 == 1 && W % 2 == 0){
		if(res[1] || res[3]) ans = "No"; 
		else if(res[2] > W/2) ans = "No"; 
	}
	else if(W % 2 == 1 && H % 2 == 0){
		if(res[1] || res[3]) ans = "No"; 
		else if(res[2] > H/2) ans = "No"; 
	}
	else if(W % 2 == 1 && H % 2 == 1){
		if(res[1] + res[3] != 1) ans = "No"; 
		else if(res[2] + res[3] > (H-1)/2 + (W-1)/2) ans = "No"; 
	}
	cout << ans << endl; 
}

Measured memory_bytes: 256
/*COMPETITIVE PROGRAMMING C++ TEMPLATE */

#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <string>
#include <cmath>
#include <iostream>
#include <stack>
#include <queue>
#include <climits>
#include <iomanip>

#define all(x) x.begin(), x.end()
#define debug(x) cout << #x << " = " << x << "\n"
#define MOD 998244353

const long double PI = 3.141592653589793236L;

typedef long long int ll;
typedef long double ld;

using namespace std;

void solve()
{
    ll n, x, m;
    cin >> n >> x >> m;

    vector<ll> a;
    set<ll> S;

    ll r = 0;

    for(int i = 0; i < n; i++)
    {
        if(S.find(x % m) != S.end())
        {
            r = x % m;
            break;
        }
        else {
            S.insert(x % m);
            a.push_back(x % m);
            x *= x;
            x %= m;
        }
    }

    int pos = 0;
    ll ans = 0;

    while(pos < a.size())
    {
        if(a[pos] == r)
        {
            break;
        }
        ans += a[pos];
        pos++;
        n--;
    }

    int p = pos;

    ll sum = 0;
    ll N = a.size() - pos;
    while(pos < a.size())
    {
        sum += a[pos];
        pos++;
    }

    if(N == 0)
    {
        cout << ans << "\n";
        return;
    }

    ans += sum * (n / N);

    for(int i = 0; i < n % N; i++)
    {
        ans += a[p + i];
    }


    cout << ans << "\n";




    

}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int T = 1;
    //cin >> T;

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

    return 0;
}





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

// template {{{
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#define lb lower_bound
#define ub upper_bound
#define f first
#define s second
#define resz resize

#define sz(x) int((x).size())
#define all(x) (x).begin(), (x).end()

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define F0R(i, a) for (int i = 0; i < (a); i++)
#define FORd(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define F0Rd(i, a) for (int i = (a)-1; i >= 0; i--)
#define trav(a, x) for (auto& a : x)

#define sort_by(x, y) sort(all(x), [&](const auto& a, const auto& b) { return y; })

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vd = vector<double>;
using vs = vector<string>;

using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pdd = pair<double, double>;

using vpii = vector<pii>;
using vvpii = vector<vpii>;
using vpll = vector<pll>;
using vvpll = vector<vpll>;
using vpdd = vector<pdd>;
using vvpdd = vector<vpdd>;

template<typename T> void ckmin(T& a, const T& b) { a = min(a, b); }
template<typename T> void ckmax(T& a, const T& b) { a = max(a, b); }

void solve()
{
    long long a, b, c, d;
    cin>>a>>b>>c>>d;
    long long ans = max(a*c, max(a*d, max(b*c, b*d)));
    cout<<ans<<endl;
}
int main() {
   
      solve();
    
    return 0;
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
const int INF=0x3fffffff;
const ll MOD=1000000007;
const ll MODD=998244353;
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
template<typename T> bool chmax(T &m, const T q) { if (m < q) {m = q; return true;} else return false; }
template<typename T> bool chmin(T &m, const T q) { if (m > q) {m = q; return true;} else return false; }
 
int main()
{
    ll l, r, ans=0;
    cin >> l >> r;
    if(r < l+2019){
      if(l%2019 < r%2019){
        ans=2019;
        REP(i, l, r){
          REP(j, i+1, r+1){
            ans = min(ans, i*j%2019);
          }
        }
      }
    }
    cout << ans << "\n";
}

Measured memory_bytes: 256
import sys

MOD = 1000000007

def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

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

N = int(input())
A = list(map(int, sys.stdin.readline().split()))

L = 1
for i in range(N):
    L = lcm(L, A[i])

ans = 0

for i in range(N):
    ans += L // A[i]

print(ans % MOD)


Measured memory_bytes: 4084
N, K = map(int, input().split())

ans = 0
if K == 0:
    ans = N ** 2
else:
    for b in range(K + 1, N + 1):
        q, r = N // b, N % b
        ans += q * (b - K) + max(0, r + 1 - K)
        
print(ans)

Measured memory_bytes: 3060
/*
Atcoder Beginner Contest 144
B-81
全探索の問題

*/
#include <iostream>
using namespace std;
int main(void){
  int n;

  cin >> n;
int answer = 0;
int ansCount = 0;
for(int i = 0; i < 9; i++){
    for(int j = 0; j < 9; j++){
        answer = (i + 1)*(j + 1);
        if(answer == n){
            ansCount++;
            cout << "Yes" << endl;
            return 0;
        }
    }
}
if(ansCount== 0){
    cout << "No" << endl;
}
  
  return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <array>
#include <algorithm>

int min = 99999;
int time_[5];

int check_(std::array<int, 5> flag ){
  int rtn = 0;
  for(int i=0; i<5; i++){
    if ( flag[i] == 1 ) rtn++;
  }
  return rtn;
}

void dfs (std::array<int, 5> flag, int sum, std::string str) {
  if ( check_(flag) == 5 ) {
    min = std::min(min, sum);
    return;
  }
  if ( check_(flag) == 4 ) {
    for(int i=0; i<5; i++){
      if ( flag[i] == 0 ){
        std::array<int,5> flag_ = flag; flag_[i] = 1;
        std::string str_ = str + (" " + std::to_string(i));
        dfs( flag_, sum+time_[i], str_);
      }
    }
    return;
  }
  if ( check_(flag) < 4 ){
    for(int i=0; i<5; i++){
      if ( flag[i] == 0 ){
        std::array<int,5> flag_ = flag; flag_[i] = 1;
        std::string str_ = str + (" " + std::to_string(i));
        if ( (sum+time_[i])% 10 == 0 ) dfs( flag_, sum+time_[i], str_);
        else dfs( flag_, 10*(((sum+time_[i])/10)+1), str_);
      }
    }
    return;
  }
}

int main (void){

  for(int i=0; i<5; i++){
    std::cin >> time_[i];
  }
  std::array<int, 5> flag = {0};
  dfs(flag, 0, "");

  std::cout << min << std::endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <cmath>
#include <vector>
#include <algorithm>
#include <numeric>
#include <array>
#include <queue>
using namespace std;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define pow(x) x*x
#define ll long long
static const int MAX = 10000;
static const ll INFTY = 1e12;
using Edge = pair<int,int>;
using Graph = vector<vector<Edge> >;

// 入力
int N;
Graph G;

// res は答え
vector<int> res;

// v を c に塗る。p は v の親
void dfs(int v, int p, int c) {
    res[v] = c;
    for (auto e : G[v]) {
        if (e.first == p) continue;
        if (e.second & 1) dfs(e.first, v, 1-c);
        else dfs(e.first, v, c);
    }
}

int main() {
    cin >> N;
    G.assign(N, vector<Edge>());
    for (int i = 0; i < N-1; ++i) {
        int u, v, w; cin >> u >> v >> w;
        --u, --v;
        G[u].push_back(Edge(v, w));
        G[v].push_back(Edge(u, w));
    }
    res.assign(N, 0);
    dfs(0, -1, 1);
    for (auto v : res) cout << v << endl;
}
/*
                   _ooOoo_
                  o8888888o
                  88" . "88
                  (| -_- |)
                  O\  =  /O
               ____/`---'\____
             .'  \\|     |//  `.
            /  \\|||  :  |||//  \
           /  _||||| -:- |||||-  \
           |   | \\\  -  /// |   |
           | \_|  ''\---/''  |   |
           \  .-\__  `-`  ___/-. /
         ___`. .'  /--.--\  `. . __
      ."" '<  `.___\_<|>_/___.'  >'"".
     | | :  `- \`.;`\ _ /`;.`/ - ` : | |
     \  \ `-.   \_ __\ /__ _/   .-` /  /
======`-.____`-.___\_____/___.-`____.-'======
                   `=---='
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
         pass System Test!
*/

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

int main()
{
    vector <int> a(3);

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

    sort(a.begin(),a.end());
    int ans[]={5,5,7};
    for(int i=0;i<3;i++)
    {
        if(a[i]!=ans[i])
        {
            cout<<"NO"<<endl;
            return 0;
        }
    }
    cout<<"YES"<<endl;
    
    return 0;
}

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

using namespace std;

int main(){
	string s;
	cin >> s;
	int cnt = 0;
	int max_cnt = 0;
	for(int i = 0; i < 3; i++){
		if(s[i]=='S'){
			max_cnt = max(max_cnt,cnt);
			cnt = 0;
		}else{
			++cnt;
		}
	}
	max_cnt = max(max_cnt,cnt);
	cout << max_cnt << "\n";
	return 0;
}


Measured memory_bytes: 3548
#!/usr/bin/env python3
r, c, k = map(int, input().split())
items = [[0] * (c+1) for _ in range(r+1)]
for _ in range(k):
    R, C, V = map(int, input().split())
    items[R][C] = V

dp1 = [[0] * (c+1) for _ in range(r+1)]
dp2 = [[0] * (c+1) for _ in range(r+1)]
dp3 = [[0] * (c+1) for _ in range(r+1)]

for i in range(1, r+1):
    for j in range(1, c+1):
        dp1[i][j] = max(dp1[i][j-1], dp1[i-1][j] + items[i][j], dp2[i-1][j] + items[i][j], dp3[i-1][j] + items[i][j])
        dp2[i][j] = max(dp2[i][j-1], dp1[i][j-1] + items[i][j])
        dp3[i][j] = max(dp3[i][j-1], dp2[i][j-1] + items[i][j])

ans = max(dp1[r][c], dp2[r][c], dp3[r][c])
print(ans)

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

using i64 = long long;

vector<int> v;
i64 sum, n, r, t;

static i64 root(i64 sum) {
	if (sum % (n * (n + 1LL) / 2))
		return -1;
	return sum / (n * (n + 1LL) / 2); }

int main() {
#ifdef HOME
	freopen("agc10b.in", "r", stdin);
	freopen("agc10b.out", "w", stdout);
#endif
	ios::sync_with_stdio(false);
	cin.tie(0), cout.tie(0);

	cin >> n;
	v.resize(n);
	
	for (auto &i: v)
		cin >> i, sum+= i;

	if ((r = root(sum)) < 0) {
		cout << "NO\n";
		return 0; }

	for (int d, i = 0; i < n; ++i) {
		d = v[(i + 1) % n] - v[i];
		if ((r - d) % n != 0 || r < d) {
			cout << "NO\n";
			return 0; }
		t+= (r - d) / n; }

	if (r == t)
		cout << "YES\n";
	else
		cout << "NO\n";

	return 0; }


Measured memory_bytes: 640
#include<cstdio>
char s[1001];
typedef long long ll;
ll num[1000];
int main(){
  int h,w;
  scanf("%d%d",&h,&w);
  num[0]=1;
  for(int i=1;i<w;i++)num[i]=0;
  for(int i=0;i<h;i++){
    scanf("%s",s);
    num[0]=(s[0]=='.')?num[0]:0;
    for(int j=1;j<w;j++){
      num[j]=(s[j]=='.')?((num[j-1]+num[j])%1000000007):0;
    }
  }
  printf("%lld",num[w-1]);
  return 0;
}


Measured memory_bytes: 128
import bisect
N,K=map(int,input().split())
V=list(map(int,input().split()))

sV=sorted(V)
ans=0
for i in range(N):
  for j in range(N-i+1):
    if i+j<=K:
      if i+j>=N:
        L=sV
      else:
        L=V[:i]+V[N-j:]
        L.sort()
      k=bisect.bisect_left(L,0)
      kans=sum(L[min(max(0,K-i-j),k):])
      ans=max(ans,kans)
print(ans)

Measured memory_bytes: 40944
#include<bits/stdc++.h>
#include<iomanip>
#include<numeric>

using namespace std;
using ll = long long;
constexpr int mo = 1e9+7;
constexpr int mo2 = 998244353;
constexpr int  mod = mo;
constexpr int inf = 1<<30;

int main(){
    int n;
    cin>>n;
    vector<double> v(n);
    for(auto &a : v)cin>>a;
    
    sort(v.begin(),v.end());
    double cur;
    for(int i=0;i<n-1;++i){
        cur = (v[i] + v[i+1])/2;
        v[i+1] = cur;
    }
    cout << fixed;
    cout << setprecision(10);
    cout << v[n-1] << endl;
    
    return 0;
}



Measured memory_bytes: 256
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
import functools
def s(): return input()
def k(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def X(): return list(input())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 9)
mod = 10**9+7
cnt = 0
ans = 0
inf = float("inf")

a,b = I()
if a <= b*2:
    print(0)
else:
    print(a-b*2)


Measured memory_bytes: 10172
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; (i) < (n); ++ (i))
#define loop(i,a,n) for (int i = (a); (i) < (n); ++ (i))
#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF (int)1e9
#define MOD 0
//#define int ll
using namespace std;
typedef vector<int> vi;

signed main(){
    string s;
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> s;
    int a,counta = 0,countb = 0;
    rep(i, (int)s.size()) {
        if(s[i] == '0') {
            counta++;
        } else {
            countb++;
        }
    }
    a = abs(counta - countb);
    cout << s.size() - a << endl;
    return 0;
}

Measured memory_bytes: 512
// includes {{{
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<tuple>
#include<cmath>
#include<random>
#include<cassert>
#include<bitset>
#include<cstdlib>
// #include<deque>
// #include<multiset>
// #include<cstring>
// #include<bits/stdc++.h>
// }}}
using namespace std;
using ll = long long;

int main() {
  std::ios::sync_with_stdio(false), std::cin.tie(0);
  int n, m;
  cin >> n >> m;
  priority_queue<int> st;
  for(int i = 0; i < n; i++) {
    int x;
    cin >> x;
    st.push(x);
  }
  while(m--) {
    int x = st.top();
    st.pop();
    x /= 2;
    st.push(x);
  }
  ll ans = 0;
  while(st.size()) ans += st.top(), st.pop();
  cout << ans << endl;
  return 0;
}


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

const int N = 1e5 + 5;

int in[N], dis[N];
vector<int> g[N];
bitset<N> vis;

void dfs(int u) {
    vis[u] = 1;
    for (int v : g[u]) {
        dis[v] = max(dis[v], dis[u] + 1);
        --in[v];
        if (in[v] == 0 and !vis[v]) {
            dfs(v);
        }
    }
}

int main() { 
    ios_base::sync_with_stdio(0); 
    cin.tie(0);
    int n, m;
    cin >> n >> m;
    for (int i = 0; i < m; i++) {
        int u, v;
        cin >> u >> v;
        g[u].push_back(v);
        ++in[v];
    }
    for (int i = 1; i <= n; i++) {
        if (in[i] == 0 and !vis[i]) {
            dfs(i);
        }
    }
    int len = 0;
    for (int i = 1; i <= n; i++) {
        len = max(len, dis[i]);
    }
    cout << len << '\n';
}

Measured memory_bytes: 11264
nums = list(input())
calc_cnt = len(nums) - 1

def vaule_check():
    for i in range(2**calc_cnt):
        formation = str(nums[0])
        for j in range(calc_cnt):
            if ((i >> j) & 1):
                formation+='+' + nums[j+1]
            else:
                formation+='-' + nums[j+1]
        
        if eval(formation) == 7:
            return formation + '=7'

print(vaule_check())


Measured memory_bytes: 3060
package main

import "fmt"

func main() {
	var a, b, c string
	fmt.Scan(&a, &b, &c)
	t := byte('a')
	for {
		if t == 'a' {
			if len(a) == 0 {
				fmt.Println("A")
				return
			}
			t = a[0]
			a = a[1:]
		} else if t == 'b' {
			if len(b) == 0 {
				fmt.Println("B")
				return
			}
			t = b[0]
			b = b[1:]
		} else {
			if len(c) == 0 {
				fmt.Println("C")
				return
			}
			t = c[0]
			c = c[1:]
		}
	}
}


Measured memory_bytes: 512
import Control.Monad
import Data.List
import Control.Arrow

getInts :: IO [Int]
getInts = do s <- getLine
             return $ map read $ words s

getLines :: Int -> IO [String]
getLines n = replicateM n $ getLine


takeN :: Int -> [Int] -> [(Int, Int)]
takeN k xs = zip xs (drop (k-1) xs)

cost :: (Int, Int) -> Int
cost (n, x) = let mn = - minimum [0, n, x]
                  mx = maximum [0, n, x]
              in (mn * 2 + mx) `min` (mx * 2 + mn)


main = do [n, k] <- getInts
          xs <- getInts
          let res = minimum [ cost pr | pr <- takeN k xs ]
          print res


Measured memory_bytes: 75132
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 1e5+9;
int p[N];
inline int read() {
    int s = 1, a = 0; char ch = getchar();
    while (ch < '0' || ch > '9') {if (ch == '-') s = -1; ch = getchar();}
    while (ch >= '0' && ch <= '9') {a = a * 10 + ch - '0'; ch = getchar();}
    return s * a;
}
int main() {
    int n = read();
    for (int i = 1; i <= n; i++) p[i] = read();
    int res = 0;
    for (int i = 1; i < n; i++) if (p[i] == i) res++, swap(p[i], p[i + 1]);
    if (p[n] == n) res++;
    return 0 * printf("%d\n", res);
}


Measured memory_bytes: 640
void main() {
	auto S = rs;
	auto T = rs;
	string ans = 'z'.repeat(100).to!string;

	foreach(i; 0..S.length-T.length+1) {
		bool ok = true;
		foreach(j; i..i+T.length) {
			if(S[j] == '?') continue;
			if(S[j] != T[j-i]) {
				ok = false;
				break;
			}
		}

		if(ok) {
			string res = "";
			foreach(j; 0..S.length) {
				// not in the range of T
				if(i <= j && j < i + T.length) {
					res ~= T[j-i];
				} else {
					res ~= (S[j] == '?' ? 'a' : S[j]);
				}
			}
			ans = min(ans, res);
		}
	}
	writeln(ans == 'z'.repeat(100).to!string ? "UNRESTORABLE" : ans);
}

// ===================================

import std.stdio;
import std.string;
import std.conv;
import std.algorithm;
import std.range;
import std.traits;
import std.math;
import std.container;
import std.bigint;
import std.numeric;
import std.conv;
import std.typecons;
import std.uni;
import std.ascii;
import std.bitmanip;
import core.bitop;

T readAs(T)() if (isBasicType!T) {
	return readln.chomp.to!T;
}
T readAs(T)() if (isArray!T) {
	return readln.split.to!T;
}

T[][] readMatrix(T)(uint height, uint width) if (!isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		res[i] = readAs!(T[]);
	}
	return res;
}

T[][] readMatrix(T)(uint height, uint width) if (isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		auto s = rs;
		foreach(j; 0..width) res[i][j] = s[j].to!T;
	}
	return res;
}

int ri() {
	return readAs!int;
}

double rd() {
	return readAs!double;
}

string rs() {
	return readln.chomp;
}

Measured memory_bytes: 256
#include<cstdio>
struct N{int p,l,r;};
N T[100000];
int n,d,k,c,r,i,j,m,o,D[100000];
void R(int r,int d){
  D[r]=d;
  if(~T[r].r)R(T[r].r,d);
  if(~T[r].l)R(T[r].l,d+1);
}
main(){
  for(scanf("%d",&n);j<n;++j)T[j].p=T[j].l=T[j].r=-1;
  for(;i++<n;)
    for(scanf("%d%d",&d,&k),j=0;j<k;r=c){
      scanf("%d",&c);
      T[c].p=d;
      j++?T[r].r=c:T[d].l=c;
    }
  for(;!D[m];++m)if(!~T[m].p)R(m,0);
  for(;o<n;++o){
    printf("node %d: parent = %d, depth = %d, ",o,T[o].p,D[o]);
    printf(~T[o].p?~T[o].l?"internal node, [":"leaf, [":"root, [");
    for(i=0,j=T[o].l;~j;)printf(i++?", %d":"%d",j),j=T[j].r;
    printf("]\n");
  }
}

Measured memory_bytes: 7412
import sys
from math import sqrt


def dist(x, d, i, j):
    res = 0
    for k in range(d):
        res += (x[i][k] - x[j][k]) ** 2
    return res


def main():
    input = sys.stdin.buffer.readline
    n, d = map(int, input().split())
    x = [list(map(int, input().split())) for _ in range(n)]
    ans = 0
    for i in range(n - 1):
        for j in range(i + 1, n):
            if sqrt(dist(x, d, i, j)).is_integer():
                ans += 1
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 9192
#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
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
const int INFTY =2147483647;
int main(){
    ll n,ans=0;
    cin>>n;
    FOR(i,1,n+1) ans+=(((n/i)*(n/i+1))/2)*i;
    cout<<ans<<endl;
}

Measured memory_bytes: 3632
#include <iostream>
using namespace std;
#define MAX 100005
#define NIL -1

struct Node
{
    int p, l, r;
};

Node T[MAX];
int n, D[MAX];

void print(int u)
{
    int i, c;
    cout << "node " << u << ": ";
    cout << "parent = " << T[u].p << ", ";
    cout << "depth = " << D[u] << ", ";

    if (T[u].p == NIL)
        cout << "root, ";
    else if (T[u].l == NIL)
        cout << "leaf, ";
    else
        cout << "internal node, ";

    cout << "[";
    for (i = 0, c = T[u].l; c != NIL; i++, c = T[c].r)
    {
        if (i)
            cout << ", ";
        cout << c;
    }
    cout << "]" << endl;
}

void rec(int u, int p)
{
    D[u] = p;
    if (T[u].r != NIL)
        rec(T[u].r, p);
    if (T[u].l != NIL)
        rec(T[u].l, p + 1);
}

int main()
{
    int i, j, d, v, c, l, r;
    cin >> n;
    for (i = 0; i < n; i++)
        T[i].p = T[i].l = T[i].r = NIL;

    for (i = 0; i < n; i++)
    {
        cin >> v >> d;
        for (j = 0; j < d; j++)
        {
            cin >> c;
            if (j == 0)
                T[v].l = c;
            else
                T[l].r = c;
            l = c;
            T[c].p = v;
        }
    }
    for (i = 0; i < n; i++)
    {
        if (T[i].p == NIL)
            r = i;
    }

    rec(r, 0);

    for (i = 0; i < n; i++)
        print(i);

    return 0;
}


Measured memory_bytes: 7744
#include <bits/stdc++.h>
using namespace std;
long long dp[2001];
const int M = 1e9+7;
long long solve(int S){
    if (S==0)
        return 1;
    if (S<3)
        return 0;
    if (dp[S]!=-1)
        return dp[S];
    int ans = 0;
    for (int i=3; i<=S; i++){
        ans = (ans+solve(S-i))%M;
    }
    return dp[S] = ans;

}
int main(){
    ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
    memset(dp, -1, sizeof(dp));
    int no;
    cin >> no ;
    cout << solve(no) << "\n";
}

Measured memory_bytes: 3668
//#include "IntMod.h"
//typedef IntMod<1000000007> MInt;

//#include "Union_Find.h"

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

using namespace std;
#define REP(i,a,n) for(int i = (a); i < (int)(n); ++i)
#define REPM(i,n,a) for(int i = ((n) - 1); i >= (a); --i)
#define EPS 0.0001
#define INF 0x3FFFFFFF
#define INFLL 0x3FFFFFFF3FFFFFFF
#define INFD 1.0e+308
#define FLOAT setprecision(16)
typedef long long LL;
typedef unsigned long long ULL;
typedef pair<LL, LL> PP;

template <class T, class U>
istream& operator>>(istream& ist, pair<T, U>& right) { return ist >> right.first >> right.second; }
template <class T, class U>
ostream& operator<<(ostream& ost, pair<T, U>& right) { return ost << right.first << ' ' << right.second; }
template <class T, class TCompatible, size_t N>
void Fill(T(&dest)[N], const TCompatible& val) { fill(begin(dest), end(dest), val); }
template <class T, class TCompatible, size_t M, size_t N>
void Fill(T(&dest)[M][N], const TCompatible& val) { for (int i = 0; i < M; ++i) Fill(dest[i], val); }
//sum, 累積和
// 負のときの割り算に注意
#if 1
#include <array>
#include <unordered_set>
#include <unordered_map>
template<class T>
using PriorityQ = priority_queue<T, vector<T>, greater<T> >;	// コスト小を優先
#endif

//#include "Union_Find.h"

int N;
string S;
vector<bool> ans;
int main() {
	cin >> N >> S;
	S += S.substr(0, 2);
	REP(k, 0, 4) {
		ans = { !(k & 2), !(k & 1) };
		REP(i, 2, N + 2) {
			bool b = (S[i - 1] == 'o') == ans[i - 1];
			ans.push_back(b ? ans[i - 2] : !ans[i - 2]);
		}
		if (ans[0] == ans[N] && ans[1] == ans[N + 1]) {
			REP(i, 0, N) {
				cout << (ans[i] ? 'S' : 'W');
			}
			cout << endl;
			return 0;
		}
	}
	cout << -1 << endl;
	return 0;
}

Measured memory_bytes: 512
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;


public class Main {
	public static void main(String[] args) throws IOException{


		// 読み込み
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line;
		String[] temp;

		line=br.readLine();
		temp=line.split(" ");

		String a = temp[0];
		String b = temp[1];
		String c = temp[2];

		if (!a.substring(a.length()-1).equals(b.substring(0,1))){
			System.out.println("NO");
		}else if(!b.substring(b.length()-1).equals(c.substring(0,1))){
			System.out.println("NO");
		}else{
			System.out.println("YES");
		}

	}
}


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

using ll =  long long;
using pint =  pair<int,int>;
using vint = vector<int>;
using vvint = vector<vint>;
using vpint = vector<pint>;

#define repi(i,start,end) for(int (i)=(start),TemPNuM=(int)(end);(i)<TemPNuM;++(i))
#define rep(i,end) repi((i),0,(end))
#define rfor(x,v) for(auto& (x) : (v))
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define fsort(v,lambda) sort(all((v)),(lambda))
#define vin(v) rep(i,(v).size())cin >> (v)[i];
#define vpin(v) rep(i,(v).size())cin>>v[i].first>>v[i].second
//最終奥義 #define int long long
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
void put_double(double obj){printf("%.12f\n",obj);};
//lambda: [](int x, int y){return x<y;}

signed main(void){
    ll n,a,b;cin>>n>>a>>b;
    if(a+b==0){
        cout << 0 << endl;
        return 0;
    }
    ll ans=n/(a+b)*a;
    if(n%(a+b)>a){
        ans+=a;
    }else{
        ans+=n%(a+b);
    }
    if(a==0) ans=0;

    cout << ans << endl;

    return 0;
}


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

#define int             long long
#define FOR( i, m, n )  for( int (i) = (m); (i) < (n); (i)++ )
#define REP( i, n )     FOR( i, 0, n )
#define REPR( i, m )    for( int (i) = (m); (i) >= 0; (i)-- )
#define REPONE( i, n )  FOR( i, 1, n + 1 )
#define ALL( a )        (a).begin(), (a).end()
#define MP              make_pair

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

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

const int INF = 1e9;
const int MOD = 1e9 + 7;

signed main(){
    int a, b; cin >> a >> b;
    if( a % 3 == 0 || b % 3 == 0 || ( a + b ) % 3 == 0 ){
        cout << "Possible" << endl;
    }else{
        cout << "Impossible" << endl;
    }
}

Measured memory_bytes: 256
import java.util.*;
public class Main{
	public static final Scanner in =  new Scanner(System.in);
	public static void main(String args []){
		int n = in.nextInt();
		int a = n/500;
		int sum =0;
		sum+=a*1000;
		n=n%500;
		int b = n/5;
		sum+=b*5;
		System.out.print(sum);
		
	
		
	}
}


Measured memory_bytes: 21844
import java.util.Scanner;

public class Main {
    public static void main(final String[] args) {
        final Scanner scanner = new Scanner(System.in);
        long n = scanner.nextLong();
        if (n % 2 == 1) {
            System.out.println(0);
            return;
        }

        long division = 10;
        long answer = 0;
        while (true) {
            final long divieded = n / division;
            if (divieded == 0) {
                break;
            }

            answer += divieded;
            division *= 5;
        }

        System.out.println(answer);
    }
}


Measured memory_bytes: 23252
from collections import Counter

N = int(input())
A = [int(x) for x in input().split()]
Q = int(input())

S = sum(A)
cnt = Counter(A) # Listなど
ans = [0] * Q
for i in range(Q):
    B, C = [int(x) for x in input().split()]
    S += (C - B) * cnt[B]
    cnt[C] += cnt[B]
    cnt[B] = 0
    ans[i] = S

for i in range(Q):
    print(ans[i])

Measured memory_bytes: 27028
def root(x):
    while P[x] != x:
        x = P[x]
    return x
def mark(x):
    P[x-1] = x-1
def query(x):
    v = root(x-1) +1
    return v

while True:
    N,Q = map(int,input().strip().split(" "))
    if N == Q == 0:
        break
    P = []
    P.append(0)
    for i in range(N-1):
        p_i = int(input().strip()) -1
        P.append(p_i)
    s = 0
    for j in range(Q):
        op = input().strip().split(" ")
        if op[0] == "M":
            mark(int(op[1]))
        else:
            s += query(int(op[1]))
    print(s)


Measured memory_bytes: 9556
s= gets.chomp
s1=s[0..1].to_i
s2=s[2..3].to_i

if s1.between?(1,12)
  if s2.between?(1,12)
    puts 'AMBIGUOUS'
  else
    puts 'MMYY'
  end
else
  if s2.between?(1,12)
    puts 'YYMM'
  else
    puts 'NA'
  end
end


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

typedef long long ll;

int main()
{
  string s;
  cin>>s;
  
  ll n = s.length();
  ll cnt = 0; 
  
  for(int i=0;i<n/2;i++)
  {
    if(s[i]!=s[n-i-1])
      cnt++;
  }
  
  cout<<cnt;
  return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize "trapv" 
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define rep(i,a,n)     for(int i=a;i<n;i++)
#define rep3(n)        for(int i=0;i<n;i++)
#define inarr(arr,n)   rep(i,a,n)cin>>arr[i]
#define ll             long long int
#define pb             push_back
#define all(v)         v.begin(),v.end()
#define endl           "\n"
#define eb             emplace_back
#define x              first
#define y              second
#define gcd(a,b)       __gcd(a,b)
#define mem1(a)        memset(a,-1,sizeof(a))
#define pres(a,x)      a.find(x)!=a.end()
#define sz(a)          (int)a.size()
#define pii            pair<int,int>
#define IOS            ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define ret            return 0
#define pi             3.1415926536
#define hell           1000000007
#define narak          998244353
#define elasped_time 1.0 * clock() / CLOCKS_PER_SEC
const int inf1=1e9;
const ll inf2=1e18;
const int N=100000;
using namespace std;
using namespace __gnu_pbds;
#define ordered_set tree<pii, null_type,less<pii>, rb_tree_tag,tree_order_statistics_node_update>
int dirs[4][2] ={{1,0},{-1,0},{0,1},{0,-1}};
int isprime[N+10];
void sieve(int n){
   rep(i,1,n+1)isprime[i]=i;
   for(int p=2;p*p<=n;p++){
       if(isprime[p]){
           for(int i=p*p;i<=n;i+=p){
               isprime[i]=0;
           }
       }
   }
}
int phi[N+10];
ll xymodp(ll x,ll y,ll p){
    ll a=1;
    x%=p;
    while(y){
        if(y&1)a=(a*x)%p;
        x=(x*x)%p;
        y/=2;
    }
    return a;
}
int solve(){
 int n,k;cin>>n>>k;           
 ll ans=0;
 for(int i=1;i<=k;i++){
     ans=(ans+phi[i]*xymodp(k/i,n,hell)%hell)%hell;
 }           
 cout<<ans<<endl;
 ret;
}
int main(){
    IOS;
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    sieve(100000);
    for(int i=1;i<=100000;i++)phi[i]=i;
    for(int i=2;i<=100000;i++){
        if(isprime[i]){
            for(int j=i;j<=100000;j+=i){
                phi[j]-=phi[j]/i;
            }
        }
    }
    #ifdef cat
    cat();
    #endif
    int t=1;//cin>>t;
    while(t--){
        solve();
    }
    ret;
}
 

Measured memory_bytes: 4388
def main():
    MOD = 10**9 + 7
    N, M = list(map(int, input().split(' ')))
    X = list(map(int, input().split(' ')))
    Y = list(map(int, input().split(' ')))
    X.sort()
    Y.sort()
    heights = [Y[i + 1] - Y[i] for i in range(M - 1)]
    widths = [X[j + 1] - X[j] for j in range(N - 1)]
    # first row
    row_areas = [0 for _ in range(M - 1)]
    first_row_area, norm_first_row_area = 0, 0
    for j, w in enumerate(widths):
        first_row_area += (1 + 0) * (M - 0 - 1) * (j + 1) * (N - j - 1) * w * heights[0]
        first_row_area %= MOD
        norm_first_row_area += (j + 1) * (N - j - 1) * w
        norm_first_row_area %= MOD
    row_areas[0] = first_row_area
    # rest rows
    for i in range(1, M - 1):
        area = (i + 1) * (M - i - 1) * norm_first_row_area * heights[i]
        area %= MOD
        row_areas[i] = area
    # answer
    ans = 0
    for a in row_areas:
        ans += a
        ans %= MOD
    print(ans)


if __name__ == '__main__':
    main()

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

int main() {
    ll mod = 1e9+7;
    int N;
    cin >> N;
    string S;
    cin >> S;
    vector<vector<ll>> dp(N, vector<ll>(N, 0));
    for (int i = 0; i < N; i++) dp[0][i] = 1;
    
    for (int i = 1; i < N; i++) {
        if (S[i-1] == '<') {
            dp[i][0] = dp[i-1][0];
            for (int j = 1; j < N-i; j++) dp[i][j] = (dp[i-1][j]+dp[i][j-1])%mod;
        }else {
            dp[i][N-i-1] = dp[i-1][N-i];
            for (int j = N-i-2; j >= 0; j--) dp[i][j] = (dp[i-1][j+1]+dp[i][j+1])%mod;
        }
    }
    cout << dp[N-1][0] << endl;
    return 0;
}

Measured memory_bytes: 73676
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
typedef pair<int,int>P;
 
int main() {
  int a,b;
  cin>>a>>b;
  vector<int>v1(a);
  for(int i=0;i<a;i++){
    cin>>v1.at(i);
  }
  sort(v1.begin(),v1.end());
  int count=0;
  for(int j=0;j<b;j++){
    count+=v1.at(j);
  }
  cout<<count<<endl;
}

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

using namespace std;
#define int long long

signed main(){
    int N,A,B;
    cin >> N >> A >> B;
    
    int tmp = 0;
    if(A+B<=N) tmp = 0;
    else tmp = abs(N-A-B);
    cout << min(A,B) << " " << tmp << endl;
    
    return 0;
}


Measured memory_bytes: 256
def main():
    N, M = map(int, input().split())
    odd = 0
    even = 0
    if N >= 2:
        odd = N*(N-1)//2
    if M >= 2:
        even = M*(M-1)//2
    print(odd+even)
if __name__ == "__main__":
    main()

Measured memory_bytes: 3060
/*
                   _ooOoo_
                  o8888888o
                  88" . "88
                  (| -_- |)
                  O\  =  /O
               ____/`---'\____
             .'  \\|     |//  `.
            /  \\|||  :  |||//  \
           /  _||||| -:- |||||-  \
           |   | \\\  -  /// |   |
           | \_|  ''\---/''  |   |
           \  .-\__  `-`  ___/-. /
         ___`. .'  /--.--\  `. . __
      ."" '<  `.___\_<|>_/___.'  >'"".
     | | :  `- \`.;`\ _ /`;.`/ - ` : | |
     \  \ `-.   \_ __\ /__ _/   .-` /  /
======`-.____`-.___\_____/___.-`____.-'======
                   `=---='
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
            佛祖保佑       永无BUG
*/
#include<stdio.h>
#include<string.h>
char s[101];
int main()
{
	int i=0,pd=0;
	scanf("%s",s);
	int len=strlen(s);
	for(int i=0;i<len;i++)
	{
		if(s[i]=='C'&&pd==0) pd++;
		if(s[i]=='F'&&pd==1) pd++;
		if(pd==2) 
		{
			printf("Yes");
			return 0;
		}
	}
	printf("No");
	return 0;
}

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

using ll = long long;
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define FORR(i, m, n) for (int i = (m); i >= (n); i--)
#define REP(i, n) FOR(i, 0, (n))
#define REPR(i, n) FORR(i, (n) - 1, 0)
#define REP1(i, n) FOR(i, 1, (n) + 1)
#define ALL(c) (c).begin(), (c).end()
#define sz(v) (int)v.size()
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;}
const int MOD = 1000000007;
const int INF = 1000000001;
const ll LINF = 1000000001000000001LL;
const char EOL = '\n';

void solve();

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(numeric_limits<double>::max_digits10);
    solve();
    return 0;
}

ll gcd(ll m, ll n) {
    return n != 0 ? gcd(n, m % n) : m;
}

void solve() {
    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    int mx = 0;
    REP(i, n) {
        cin >> a[i];
        chmax(mx, a[i]);
    }
    int g = a[0];
    REP1(i, n - 1) g = gcd(g, a[i]);
    if (mx >= k && k % g == 0) {
        cout << "POSSIBLE" << EOL;
    } else {
        cout << "IMPOSSIBLE" << EOL;
    }
}


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

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

	if (a + b == 15)
		cout << "+" << endl;
	else if (a*b == 15)
		cout << "*" << endl;
	else
		cout << "x" << endl;

	return 0;
}

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

int main(){

string str;
string str2;

cin >> str;



int i;
for(i = 0; i < str.size(); i++){

	if(str[i] == '0' || str[i] == '1'){
		
		str2.push_back( str[i] );
	}
	else{

		if(str2[0] != '\0'){
		str2.pop_back();
		}
	}

}


cout << str2 << endl;


}

Measured memory_bytes: 256
#include <iostream>
#include<string>
using namespace std;
int main(){
	for (int i=1; ; i=i+1){
		int x;
		cin>>x;
		if(x==0){
			break;
		}
		
		cout<<"Case "<<i<<": "<<x<<endl;
		
	}
	return 0;
}



















Measured memory_bytes: 3076
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007

int main() {
	string s;
	cin>>s;
	for(ll i=0;i<s.size();i++){
		cout << "x";
	}
	// your code goes here
	return 0;
}

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

int a[4];

int main() {
	ios_base::sync_with_stdio(false); cin.tie(0);
	int n; cin >> n;
	for (int i = 1; i <= n; ++i) {
		int x; cin >> x;
		a[x % 4]++;
	}
	
	int t = a[1] + a[3];
	int lim0 = t - 1 + (t > 0 ? a[2] > 0 : 0);

	if (a[0] >= lim0) return printf("Yes\n"), 0;
	printf("No\n");
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

#define NIL -1
#define MAX 100005

struct Node {
    int parent = NIL;
    int left = NIL;
    int right = NIL;
};

Node T[MAX];

int getDepth(int u) {
    int d = 0;
    while (T[u].parent != NIL) {
        u = T[u].parent;
        ++d;
    }
    return d;
}

string getType(int u) {
    if (T[u].parent == NIL) {
        return "root";
    } else if (T[u].left == NIL) {
        return "leaf";
    } else {
        return "internal node";
    }
}

void printChildren(int u) {
    int c = T[u].left;
    if (c != NIL) {
        printf("%d", c);
        c = T[c].right;
    }
    while (c != NIL) {
        printf(", %d", c);
        c = T[c].right;
    }
}

int main() {
    int n;
    scanf("%d", &n);

    for (int i = 0; i < n; ++i) {
        int parentId;
        int k;
        scanf("%d", &parentId);
        scanf("%d", &k);
        int currerntChildId;
        int previousChildId;
        for (int j = 0; j < k; ++j) {
            scanf("%d", &currerntChildId);
            if (j == 0) {
                T[parentId].left = currerntChildId;
            }
            T[currerntChildId].parent = parentId;
            if (j > 0) {
                T[previousChildId].right = currerntChildId;
            }
            previousChildId = currerntChildId;
        }
    }

    for (int u = 0; u < n; ++u) {
        int depth = getDepth(u);
        string type = getType(u);
        printf("node %d: parent = %d, depth = %d, %s, [", u, T[u].parent, depth, type.c_str());
        printChildren(u);
        printf("]\n");
    }

    return 0;
}

Measured memory_bytes: 4376
N,M=map(int,input().split())
div=[]
for i in range(1,int(M**(1/2)+1)):
  if M%i==0:
    div.append(i)
    if i!=M//i:
      div.append(M//i)
ans=[]
for j in range(len(div)):
  if M-(N-1)*div[j]>0:
    ans.append(div[j])
print(max(ans))

Measured memory_bytes: 3188
#include<iostream>
#include<string>
using namespace std;
int main(){
	string s;
	while(1){
		int ss=0;
		cin>>s;
		for(int i=0;i<s.size();i++){
			ss+=(s[i]-'0');
			}
		if(ss==0)break;
		cout<<ss<<endl;;
	}
}



Measured memory_bytes: 3184
N=int(input())
A=list(map(int,input().split()))
if N==0:
  if A[0]==1:
    print(1)
  else:
    print(-1)
  exit()
if A[0]:
  print(-1)
  exit()
C=[A[N]]
for i in range(N):
  C.append(C[i]+A[-i-2])
C=C[::-1]
B=[1]
P=1
for i in range(N):
  if (B[i]<<1)<A[i+1]:
    print(-1)
    exit()
  P+=min((B[i]<<1),C[i+1])
  B.append(min((B[i]<<1),C[i+1])-A[i+1])
  if B[-1]<0:
    print(-1)
    exit()
print(P)

Measured memory_bytes: 97600