akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef vector<int> VI;

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; }
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()


int main() {
    int n;
    cin >> n;
    vector<int> a(n), b(n), c(n);
    rep (i, n) {
        cin >> a[i];
    }
    rep (i, n) {
        cin >> b[i];
    }
    rep (i, n) {
        cin >> c[i];
    }
    sort(all(a));
    sort(all(b));
    sort(all(c));
    vector<ll> bc(n+1);
    rep (i, n) {
        int p = b[i];
        auto it = upper_bound(all(c), p);
        int q = distance(it, c.end());
        bc[i] = q;
    }
    rep (i, n) {
        bc[n-1-i] += bc[n-i];
    }
    ll ans = 0;
    rep (i, n) {
        int p = a[i];
        auto it = upper_bound(all(b), p);
        int q = distance(it, b.end());
        int r = distance(b.begin(), it);
        ans += bc[r];
    }
    cout << ans << endl;
}

Measured memory_bytes: 2176
C=[]
3.times{C << gets.split.map(&:to_i)}
if C[0][0]-C[0][1]==C[1][0]-C[1][1] && C[0][0]-C[0][1]==C[2][0]-C[2][1] &&
    C[0][1]-C[0][2]==C[1][1]-C[1][2] && C[0][1]-C[0][2]==C[2][1]-C[2][2] &&
    C[0][0]-C[1][0]==C[0][1]-C[1][1] && C[0][0]-C[1][0]==C[0][2]-C[1][2] &&
    C[0][0]-C[2][0]==C[0][1]-C[2][1] && C[0][0]-C[2][0]==C[0][2]-C[2][2]
    puts "Yes"
else
    puts "No"
end


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

using namespace std;
using ll = long long;

int main() {
    int n = 0;
    cin >> n;
    vector<ll> v(n);
    vector<ll> ma(n);
    vector<ll> mi(n);
    int MAX = 0;
    int MIN = 1001001;
    for(int i = 0;i < n;i++){
        int tmp = 0;
        cin >> tmp;
        v[i] = tmp;
        ma[i] = max(MAX,tmp);
        MAX = max(MAX,tmp);
        mi[i] = min(MIN,tmp);
        MIN = min(MIN,tmp);
    }
    int cnt = 0;
    for(int i = 0;i < n;i++){
        if(ma[i] >= v[i] && mi[i] >= v[i]){
            cnt ++;
        }
    }
    cout << cnt << endl;
    return 0;
}

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

using namespace std;
struct Point{
    double x,y;
    Point(double _x=0,double _y=0):x(_x),y(_y){}
    Point operator + (Point p){return Point(x+p.x,y+p.y);}
    Point operator - (Point p){return Point(x-p.x,y-p.y);}
    Point operator * (double a){return Point(a*x,a*y);}
    Point operator / (double a){return Point(x/a,y/a);}
    double norm(){return x*x+y*y;}//模的平方
    double ABS() {return sqrt(norm());}//模
};
//线段
struct Segment{
    Point p1,p2;
};
//点积
double dot(Point a,Point b){
    return a.x*b.x+a.y*b.y;
}
//叉积
double cross(Point a,Point b){
    return a.x*b.y-a.y*b.x;
}
Point Projection(Point p,Segment s){
    Point alp=p-s.p1;
    Point beta=s.p2-s.p1;
    double res=dot(alp,beta)/beta.norm();
    return s.p1+(beta*res);
}
//点到直线的距离
double PLDis(Point a,Segment s){
    double A=s.p1.y-s.p2.y;
    double B=s.p2.x-s.p1.x;
    double C=(s.p1.x-s.p2.x)*s.p1.y-(s.p1.y-s.p2.y)*s.p1.x;
    return fabs(A*a.x+B*a.y+C)/sqrt((A*A+B*B));
}
bool cmp(Point a,Point b){
    if(a.x==b.x) return a.y<b.y;
    return a.x<b.x;
}
//计算圆和直线的交点
vector<Point> CCL(Segment s,Point o,double r){
    vector<Point> res;
    Point x=Projection(o,s);
    double dis=PLDis(o,s);
    if(dis>r){//距离>r没有交点
        return res;
    }
    if(dis==r){
        res.push_back(x);
        res.push_back(x);
    }
    double beta=sqrt(r*r-dis*dis);
    Point pp=s.p2-s.p1;
    pp=pp/pp.ABS();//单位向量
    Point ans1=x-pp*beta;
    Point ans2=x+pp*beta;
    res.push_back(ans1);
    res.push_back(ans2);
    return res;
}
int main(){
    Point c;
    double r;
    scanf("%lf %lf %lf",&c.x,&c.y,&r);
    int q;
    scanf("%d",&q);
    while(q--){
        Segment s;
        scanf("%lf %lf %lf %lf",&s.p1.x,&s.p1.y,&s.p2.x,&s.p2.y);
        vector<Point> ans=CCL(s,c,r);
        sort(ans.begin(),ans.end(),cmp);
        printf("%.10lf %.10lf %.10lf %.10lf\n",ans[0].x,ans[0].y,ans[1].x,ans[1].y);
    }
    return 0;
}


Measured memory_bytes: 3232
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
int m, n, a[10], a_2[10], ID[100001];
int dp[100001][10];
int table[] = { 0, 2, 4, 6, 8, 1, 3, 5, 7, 9};

int rec( int now, int sum ){
  if(now == n + 1) return sum % 10 == 0;
  if(~dp[now][sum % 10]) return dp[now][sum % 10];

  int ret = 0;
  if(~ID[now]){
    ret += rec( now + 1, sum + ID[now]);
  }else{
    if(now & 1)
      for(int i = 0 ; i < m ; i++ ){
        ret += rec( now + 1, sum + a[i]);
      }
    else
      for(int i = 0 ; i < m ; i++ ){
        ret += rec( now + 1, sum + a_2[i]);
      }
  }
  return dp[now][sum % 10] = ret;
}

int main(){
  fill_n( *dp, 100001 * 10, -1);
  cin >> n;
  for(int i = n ; i ; i-- ){
    char c;
    cin >> c;
    if(c == '*') ID[i] = -1;
    else ID[i] = i % 2 ? c - '0' : table[c - '0'];
  }
  cin >> m;
  for(int i = 0 ; i < m ; i++ ){
    cin >> a[i];
    a_2[i] = table[a[i]];
  }
  cout << rec( 1, 0) << endl;
}

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

int main() {
  int S;
  cin >> S;
  vector<int> T(4);
  T.at(0) = S/1000;
  T.at(1) = S/100 - T.at(0)*10;
  T.at(2) = S/10 - T.at(0)*100 - T.at(1)*10;
  T.at(3) = S - T.at(0)*1000 - T.at(1)*100 - T.at(2)*10;
  
  if(T.at(0) == T.at(1) || T.at(1) == T.at(2) || T.at(2) == T.at(3)){
    cout << "Bad" << endl;
  }
  else{
    cout << "Good" << endl;
  }
}

Measured memory_bytes: 256
import math

N = int(input())

X_f = math.floor(N/1.08)
X_c = math.ceil(N/1.08)

if math.floor(X_f * 1.08) == N:
    print(X_f)
elif math.floor(X_c * 1.08) == N:
    print(X_c)
else:
    print(":(")

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

using namespace std;

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

    vector<int> nums(3);
    cin >> nums[0] >> nums[1] >> nums[2];
    sort(nums.begin(), nums.end(), greater<int>());
    cout << nums[0] * 10 + nums[1] + nums[2] << endl;
    return 0;
}


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

using namespace std;

const long long MOD = 1000000007LL;
long long GCD(long long a, long long b){return b == 0 ? a : GCD(b, a % b);}
long long fast_exp(long long base, long long exp, long long mod = MOD) {
    long long tot = 1;
    for(;exp > 0;exp >>= 1) {
       if((exp & 1) == 1) tot = tot * base % mod;
       base = base * base % mod;
    }
    return tot;
}

long long grid[100][100];

int main(){

    cin.sync_with_stdio(0); cin.tie(0); cout.tie(0);

    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    int a, b; cin >> a >> b;
    --a; --b;

    for(int i = 0; i < 100; i += 2){
        for(int j = 0; j < 100; j += 2){
            if(b == 0) break;
            grid[i][j] = 1;
            --b;
        }
    }

    for(int i = 50; i < 100; ++i)
        for(int j = 0; j < 100; ++j)
            grid[i][j] = 1;

    for(int i = 51; i < 100; i += 2){
        for(int j = 0; j < 100; j += 2){
            if(a == 0) break;
            grid[i][j] = 0;
            --a;
        }
    }

    cout << "100 100\n";

    for(int i = 0; i < 100; ++i){
        for(int j = 0; j < 100; ++j)
            cout << (grid[i][j] == 0 ? "." : "#");
        cout << "\n";
    }

    return 0;

}


Measured memory_bytes: 384
a = input()
b = input()
c = input()
la, lb, lc = len(a), len(b), len(c)

M = 4000
M2 = 20000
M2offset = 10000


def canInserts(n, m):
    r = [True]*M2
    for i in range(len(n)):
        for j in range(len(m)):
            if n[i] != m[j] and n[i] != '?' and m[j] != '?':
                r[i-j+M2offset] = False
    return r


ab = canInserts(a, b)
ac = canInserts(a, c)
bc = canInserts(b, c)

ans = M2
for bi in range(-M, M+1):
    if not ab[bi+M2offset]:
        continue
    for ci in range(-M, M+1):
        if ac[ci+M2offset] and bc[ci-bi+M2offset]:
            l = min(0, bi, ci)
            r = max(la, bi+lb, ci+lc)
            t = r-l
            if ans > t:
                ans = t
print(ans)

Measured memory_bytes: 50140
#include <bits/stdc++.h>
#define Would
#define you
#define please
#define rep(i, n) for(int i=0; i<n; i++)
#define repr(i, n) for(int i=n-1; i>0; i--)

using namespace std;

void solve() {
	int n; cin >> n;
	vector<int> A(n + 1), B(n);
	rep(i, n + 1) scanf("%d", &A[i]);
	rep(i, n) scanf("%d", &B[i]);

	long long res = 0, left, right;
	rep(i, n) {
		left = min(A[i], B[i]);
		res += left;
		A[i] -= left;
		B[i] -= left;

		right = min(A[i + 1], B[i]);
		res += right;
		A[i + 1] -= right;
	}
	cout << res << endl;
}

int main(void) {
	solve();
	Would you please return 0;
}

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

int main() {
  string S;
  cin >> S;

  int ans = 0;
  rep(i, S.size()) {
    if (S[i] == '+')
      ans++;
    else
      ans--;
  }

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

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

using ll = long long;
using ull = unsigned long long;
using ld = long double;

#define MOD 1000000007LL

#define rep(i, n) for(ll (i) = 0LL;(i) < (ll)(n);(i)++)
#define rep2(i, s, e) for(ll (i) = (ll)(s);(i) < (ll)(e);(i)++)
#define repi(i, n) for(ll (i) = 0LL;(i) <= (ll)(n);(i)++)
#define repi2(i, s, e) for(ll (i) = (ll)(s);(i) <= (ll)(e);(i)++)
#define per(i, n) for(ll (i) = (ll)(n) - 1LL;(i) >= 0LL;(i)--)
#define per2(i, s, e) for(ll (i) = (ll)(s) - 1LL;(i) >= (ll)(e);(i)--)
#define peri(i, n) for(ll (i) = (ll)(n);(i) >= 0LL;(i)--)
#define peri2(i, s, e) for(ll (i) = (ll)(s);(i) >= (ll)(e);(i)--)
#define iter(i, it) for(auto &(i): (it))

template<typename T, typename U> ostream& operator<<(ostream &s, const pair<T, U> m) {
    cout << "(" << m.first << ", " << m.second << ")";
    return s;
}
template<typename T, typename U> ostream& operator<<(ostream &s, const map<T, U> m) {
    ll c = 0;
    cout << "{ ";
    iter(i, m) cout << i << (c++ == m.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const vector<T> &v) {
    cout << "{ ";
    rep(i, v.size()) cout << v[i] << (i == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const list<T> &v) {
    ll c = 0;
    cout << "{ ";
    iter(i, v) cout << i << (c++ == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}

int main(void) {
    set<ll> colors;
    rep(i, 3) {
        ll temp;
        cin >> temp;
        colors.insert(temp);
    }
    cout << colors.size() << endl;
    return 0;
}


Measured memory_bytes: 3580
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
typedef long long ll;
typedef double lf;
typedef pair<ll,ll> ii;
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(ll i=1;i<=n;i++)
#define RST(i,n) memset(i,n,sizeof i)
#define SZ(a) (int)a.size()
#define ALL(a) a.begin(),a.end()
#define X first
#define Y second
#define mkp make_pair
#define pb push_back
#define eb emplace_back
#define pob pop_back
#ifdef cold66
#define debug(...) do{\
    fprintf(stderr,"%s - %d (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
    _do(__VA_ARGS__);\
}while(0)
template<typename T>void _do(T &&_x){cerr<<_x<<endl;}
template<typename T,typename ...S> void _do(T &&_x,S &&..._t){cerr<<_x<<" ,";_do(_t...);}
template<typename _a,typename _b> ostream& operator << (ostream &_s,const pair<_a,_b> &_p){return _s<<"("<<_p.X<<","<<_p.Y<<")";}
template<typename It> ostream& _OUTC(ostream &_s,It _ita,It _itb)
{
    _s<<"{";
    for(It _it=_ita;_it!=_itb;_it++)
    {
        _s<<(_it==_ita?"":",")<<*_it;
    }
    _s<<"}";
    return _s;
}
template<typename _a> ostream &operator << (ostream &_s,vector<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a> ostream &operator << (ostream &_s,set<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a,typename _b> ostream &operator << (ostream &_s,map<_a,_b> &_c){return _OUTC(_s,ALL(_c));}
template<typename _t> void pary(_t _a,_t _b){_OUTC(cerr,_a,_b);cerr<<endl;}
#define IOS()
#else
#define debug(...)
#define pary(...)
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0);
#endif // cold66
//}
template<class T> inline bool chkmax(T &a, const T &b) { return b > a ? a = b, true : false; }
template<class T> inline bool chkmin(T &a, const T &b) { return b < a ? a = b, true : false; }
template<class T> using MaxHeap = priority_queue<T>;
template<class T> using MinHeap = priority_queue<T, vector<T>, greater<T>>;

const ll MAXn=1e5+5,MAXlg=__lg(MAXn)+2;
const ll MOD=1000000007;
const ll INF=0x3f3f3f3f;

int main(){
  IOS();
  ll n,k;
  cin>>n>>k;
  ll ans = 0;
  for(ll i=k+1;i<=n;i++){
    ll a = k;
    if( a<=0 ) a=1;
    ll x = (n-a)/i;
    a+=x*i;
    ans+=(i-k)*x;
    if( n-a+1>=i-k ) ans+=i-k;
    else ans+=n-a+1;
  }
  cout<<ans<<endl;
}


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

int main() {
  int N, M;
  cin >> N >> M;
  
  const int NMMAX = 50;
  int A[NMMAX], B[NMMAX];
  
  for (int i = 0; i < M; i++) {
    cin >> A[i] >> B[i];
  }
  
  int road[NMMAX];
  for (int i = 0; i < N; i++) {
    road[i] = 0;
  }
  
  for (int i = 0; i < M; i++) {
    road[A[i] - 1] += 1;
    road[B[i] - 1] += 1;
  }
  
  for (int i = 0; i < N; i++) {
    cout << road[i] << endl;
  }
}

Measured memory_bytes: 3544
#include <bits/stdc++.h>
#ifdef HIRO
#define d(f_, ...) printf((f_), ##__VA_ARGS__)
#else
#define d(f_, ...)
#endif

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<long long, long long> pllll;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector< pair<int, int> > vii;
typedef vector< pair<long long, long long> > vllll;
typedef map<int, int> mii;
typedef map<long long, long long> mllll;
typedef queue<int> qi;
typedef queue< pair<int, int> > qp;
#define mp make_pair
#define pi 3.14159265358979323846
#define MAX max_element
#define MIN min_element
#define all(v) v.begin(), v.end()
#define gt(T) greater<T>()
#define sum(v) accumulate(v.begin(), v.end(), 0ll)
#define uni(v) do{ \
  sort(v.begin(), v.end()); \
  decltype(v)::iterator result = unique(v.begin(), v.end()); \
  v.erase(result, v.end()); \
}while(0)
#define fi(init, n) for(int i = init; i < n; ++i)
#define fj(init, n) for(int j = init; j < n; ++j)
#define fk(init, n) for(int k = init; k < n; ++k)
#define zero(x) memset(x, 0, sizeof(x))
#define negative(x) memset(x, ~0, sizeof(x))
#define bitsum(x) __builtin_popcount(x)
const ll MOD = 1e9 + 7;
const int INF = 1e9;
const int di[] = { 0, 1, 0, -1 };
const int dj[] = { 1, 0, -1, 0 };

template<typename T>
T gcd(T a, T b) {
	return b ? gcd(b, a % b) : a;
}
template<typename T>
T lcm(T a, T b) {
	return a / gcd(a, b) * b;
}
template<typename T>
int finder(vector<T> vec, T number) {
	auto itr = find(vec.begin(), vec.end(), number);
	size_t index = distance(vec.begin(), itr);
	if (index != vec.size()) return 1;
	else return 0;
}
ll frac(ll n){
	if (n == 0) return 1;
	return (n * frac(n - 1)) % MOD;
}
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;
}

ll n;
string x = "357";
int dfs(string s) {
  if(stoll(s) > n)
    return 0;
  
  int res;
  // cout << s << endl;
  if(all_of(x.begin(), x.end(), [s](char c){ return s.find(c) != string::npos; }))
    res = 1;
  else
    res = 0;
  for(char c: x) {
    res += dfs(s + c);
  }
  return res;
}

int main(int argc, char** argv) {
#ifdef HIRO
  string quiz(argv[1]);
  string id(argv[2]);
  string filename("input/" + quiz + "/" + id + ".txt");
  ifstream fin(filename);
  if (fin.peek() == ifstream::traits_type::eof()) {
    cout << "No input.";
    return 0;
  }
  ifstream cin(filename);
  std::cin.rdbuf(cin.rdbuf());
#endif
  ll ans = 0;
  cin >> n;
  // ll n, m;
  // cin >> n >> m;
  // ll n, m, k;
  // cin >> n >> m >> k;
  ans = dfs("0");
  cout << ans << endl;
  return 0;
}



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


char    chess(int   h,  int w){
   if((h+w)%2==0){
    return  '#' ;
    }
    return  '.';
}
int main(void){
    // Your code here!
    int H,W;
    while(true){
        cin>>H>>W;
        if(H==0&&W==0){
            break;
        }
    
    for(int i=0;    i<H;    i++){
        for(int j=0;    j<W;    j++){
            cout<<chess(i,j);
        }
        cout<<endl;
    }
    cout<<endl;
}
}



Measured memory_bytes: 3084
#include<bits/stdc++.h>
#define enld '\n'
#define rep(i,n) for(int i=0; i<(n); i++)
using namespace std;
using ll = long long;
using P = pair<int,int>;
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("Ofast")
constexpr ll INF = 1e18;
constexpr int inf = 1e9;
constexpr ll mod2 = 1000000007;
constexpr ll mod = 998244353;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[6] = {1, 0, -1, 0,1,1};
const int dy[6] = {0, 1, 0, -1,1,-1};
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
// ---------------------------------------------------------------------------

// snukeさんのmodint
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};

// mint N;
//cout << N.x << endl;


int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int N,S;
    cin >> N >> S;
    vector<int> A(N);
    for(int i=0; i<N; i++) cin >> A[i];
    vector<mint> q(S+1,0);
    mint ans = 0;
    for(int i=0; i<N; i++){
        q[0] += 1;
        vector<mint> q2(S+1,0);
        for(int j=0; j<=S; j++){
            q2[j] += q[j];
            if(j+A[i] <= S) q2[j+A[i]] += q[j];
        }
        q = q2;
        ans += q[S];
    }
    cout << ans.x << enld;
    return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <tuple>
#include <stack>
#include <bitset>
#include <utility>
#include<iomanip>
// #include <numeric>
using namespace std;



typedef unsigned long ul;
typedef unsigned long long ull;
typedef long long ll;
typedef vector<ll> vint;
typedef vector<vector<ll>> vvint;
typedef vector<vector<vector<ll>>> vvvint;
typedef vector<string> vstring;
typedef vector<vector<string>> vvstring;
typedef vector<char> vchar;
typedef vector<vector<char>> vvchar;
typedef vector<long double> vdouble;
typedef vector<vector<long double>> vvdouble;
typedef vector<vector<vector<long double>>> vvvdouble;
typedef pair<ll,ll> pint;
typedef vector<pint> vpint;
typedef vector<bool> vbool;

#define rep(i,n) for(ll i=0;i<n;i++)
#define repf(i,f,n) for(ll i=f;i<n;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define INT_MAX 2147483647
#define LLONG_MAX 9223372036854775807
#define vmax(vec) *max_element(vec.begin(), vec.end())
#define vmin(vec) *min_element(vec.begin(), vec.end())
#define vsort(vec) sort(vec.begin(), vec.end())
#define vsortgr(vec) sort(vec.begin(), vec.end(), greater<ll>())
#define DIVIDER 1000000007


//
// struct Node{
//   vint children;
//   ll index;
//   ll prop;
// };
// struct edge{ll to; ll cost;};



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

// ll X,Y,Z,K;
// ll pmax = 30000000000;
// vint A,B,C;




// struct UnionFind {
//     vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2
//
//     UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
//         for(int i = 0; i < N; i++) par[i] = i;
//     }
//
//     int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
//         if (par[x] == x) return x;
//         return par[x] = root(par[x]);
//     }
//
//     void unite(int x, int y) { // xとyの木を併合
//         int rx = root(x); //xの根をrx
//         int ry = root(y); //yの根をry
//         if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
//         par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
//     }
//
//     bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
//         int rx = root(x);
//         int ry = root(y);
//         return rx == ry;
//     }
// };
//
vint divisor(ll n){ // nの約数
  vint ret;
  for(ll i=1;i*i<=n;i++){
    if(n%i == 0){
      ret.pb(i);
      if(i*i!=n) ret.pb(n/i);
    }
  }
  vsort(ret);
  return ret;
}

ll my_pow(ll x,ll y){
  ll rtn=1;
  rep(i,y) rtn*=x;
  return rtn;
}

ll get_digit_in(ll n, ll i){ // i桁目の数字を得る。
  for(ll j=0;j<i-1;j++){
    n/=10;
  }
  return n%10;
}

ll get_digit(ll n){
  ll rtn=0;
  while(n>0){
    n/=10;
    rtn++;
  }
  return rtn;
}



int main() {
  cout<<fixed<<setprecision(10);


  ll n,x;cin>>n>>x;
  vint l(n);rep(i,n)cin>>l[i];

  vint ans(n+1,0);

  rep(i,n){
    ans[i+1] = ans[i] + l[i];
  }

  auto it = upper_bound(ans.begin(), ans.end(), x);

  cout<<(it-ans.begin())<<endl;





}




//


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

public class Main {

  public static void main(String[] args) {
    Main m = new Main();
    m.exec();
  }

  private void exec() {
    Scanner scan = new Scanner(System.in);
    int x = scan.nextInt();
    int a = scan.nextInt();
    int b = scan.nextInt();

    
    if (Math.abs(x - a) < Math.abs(x - b)) {
      System.out.println("A");
    } else {
      System.out.println("B");
    }
  }
}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long

const long long MOD = 1000000007;

int main(){
  int a,b,c;
  cin >> a >> b;
  if(a>b){ 
    c=b;
    b=a;
    a=c;
  }
  
  rep(i,b){
    cout << a;
  }
  cout << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(obj) (obj).begin(),(obj).end()
const int mod=1e9+5;
struct edge{
  int to,id;
};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;cin>>n;
    vector<vector<edge>> g(n);
    vector<int> ans(n);
    rep(i,n-1){
      int a,b;cin>>a>>b;
      --a;--b;
      g[a].push_back((edge){b,i});
      g[b].push_back((edge){a,i});
    }
    
    queue<int> q;
    vector<bool> used(n,0);
    vector<int> pre(n,-1);
    q.push(0);
    used[0]=1;
    while(!q.empty()){
        int v=q.front();q.pop();
        int c=-1;
        rep(i,g[v].size()){
            int u=g[v][i].to,ei=g[v][i].id;
            if(used[u])c=ans[ei];
        }
        int k=1;
        rep(i,g[v].size()){
            int u=g[v][i].to,ei=g[v][i].id;
            if(used[u])continue;
            if(k==c)++k;
            ans[ei]=k;++k;
            q.push(u);
            used[u]=1;
        }
    }
    
    
    int mx=0;
    rep(i,n)mx=max(mx,int(g[i].size()));
    cout<<mx<<endl;
    rep(i,n-1)cout<<ans[i]<<endl;
    return 0;
}


Measured memory_bytes: 7424
sS = input().rstrip()
iL = len(sS)

sS1 = sS[0::2]
sS2 = sS[1::2]
iWin = 0
if sS1.count(sS1[0]) == len(sS1) and sS2.count(sS2[0]) == len(sS2):
    iWin = 2
elif sS[0] == sS[-1]:
    if iL % 2 == 1:
        iWin = 2
    else:
        iWin = 1
else:
    if iL % 2 == 1:
        iWin = 1
    else:
        iWin = 2



if iWin == 1:
    print("First")
else:
    print("Second")


Measured memory_bytes: 3316
K=int(input())
A=[1,2,3,4,5,6,7,8,9]+[0]*10*K
i=9
j=0
while i<K:
    if A[j]%10!=0 and A[j]%10!=9:
        A[i]=10*A[j]+A[j]%10-1;i+=1
        A[i]=10*A[j]+A[j]%10;i+=1
        A[i]=10*A[j]+A[j]%10+1;i+=1
    elif A[j]%10==0:
        A[i]=10*A[j]+A[j]%10;i+=1
        A[i]=10*A[j]+A[j]%10+1;i+=1
    else:
        A[i]=10*A[j]+A[j]%10-1;i+=1
        A[i]=10*A[j]+A[j]%10;i+=1
    j+=1
print(A[K-1])


Measured memory_bytes: 18676
#define _USE_MATH_DEFINES
#define INF 10000000
#include <iostream>
#include <sstream>
#include <cmath>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>
#include <list>

using namespace std;

typedef long long ll;
typedef pair <int,int> P;
typedef pair <int,P > PP;

static const double eps = 1e-8;

int getAvr(int* p,int n){
	int sum = 0;
	for(int i=0;i<n;i++){
		sum += p[i];
	}

	return sum/3;
}

void printIce(int* freq,int kind){
	if(freq[kind] == 0){
		printf("-\n");
		return;
	}

	for(int i=0;i<freq[kind];i++){
		printf("%s",(i == freq[kind] - 1) ? "*\n" : "*");
	}
}

int main(){
	int n;	
	while(~scanf("%d",&n)){
		if(n==0) break;

		int* freq = new int[10]();
		for(int i=0;i<n;i++){
			int kind;
			scanf("%d",&kind);
			freq[kind]++;
		}

		for(int i=0;i<10;i++){
			printIce(freq,i);
		}

		delete[] freq;
	}
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
int main() {
   int N;
   cin >>N;
   vector<string> b(N);
   for(int i=0; i<N; ++i){
       cin >> b.at(i);
   }
   int M;
   cin >> M;
   vector<string> r(M);
   for(int i=0; i<M; ++i){
       cin >> r.at(i);
   }
   int ans = 0;
   for(int i=0; i<N; ++i){
       int tmp=1;
       for(int j=i+1; j<N; ++j){
           if(b.at(i) == b.at(j)) ++tmp;
       }
       for(int j=0; j<M; ++j){
           if(b.at(i) == r.at(j)) --tmp;
       }
       
       if(ans < tmp) ans = tmp;
   }
   cout << ans << endl;
}

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

int main(void){
  long int x,y,a,b,c;
  cin >> x >> y >> a >> b >> c;
  vector<long int> p(a),q(b),r(c);
  long int i,A,B,C;
  for(i=0;i<a;i++){
    cin >> p.at(i);
  }
  for(i=0;i<b;i++){
    cin >> q.at(i);
  }
  for(i=0;i<c;i++){
    cin >> r.at(i);
  }
  
  sort(p.begin(),p.end());
  reverse(p.begin(),p.end());
  sort(q.begin(),q.end());
  reverse(q.begin(),q.end());
  sort(r.begin(),r.end());
  reverse(r.begin(),r.end());
  
  long int m=0;
  A=0;
  B=0;
  C=0;
  for(i=0;i<x+y;i++){
    if(C==c){
      if((p.at(A)>q.at(B)||B==y)&&A!=x){
        m=m+p.at(A);
        A++;
      }else{
        m=m+q.at(B);
        B++;
      }
    }else{
      if(A==x){
        if(q.at(B)>r.at(C)){
          m=m+q.at(B);
          B++;
        }else{
          m=m+r.at(C);
          C++;
        }
      }else if(B==y){
        if(p.at(A)>r.at(C)){
          m=m+p.at(A);
          A++;
        }else{
          m=m+r.at(C);
          C++;
        }
      }else{
        if(r.at(C)>max(p.at(A),q.at(B))){
          m=m+r.at(C);
          C++;
        }else if(p.at(A)>q.at(B)){
          m=m+p.at(A);
          A++;
        }else{
          m=m+q.at(B);
          B++;
        }
      }
    }
  }
  
  cout << m << endl;
}

Measured memory_bytes: 2560
#include <iostream>
using namespace std;
int N;
int F[101][5][2],P[101][11],open[11];
long long int ans=-1000000000;
long long int f(){
  long long int res=0;
  for(int i=0;i<N;i++){
    int c=0,d=0;
    for(int j=0;j<5;j++){
      for(int k=0;k<2;k++){
	if(F[i][j][k]==1 && open[d]==1)c++;
	d++;
      }
    }
    res+=P[i][c];
  }
  
  return res;
}

int main(){
  cin >> N;
  for(int i=0;i<N;i++){
    for(int j=0;j<5;j++){
      for(int k=0;k<2;k++){
	cin >> F[i][j][k];
      }
    }
  }
  for(int i=0;i<N;i++){
    for(int j=0;j<11;j++){
      cin >> P[i][j];
    }
  }

  for(int i=1;i<1<<10;i++){
    for(int j=0;j<10;j++)open[j]=0;
    int x=i,c=0;
    while(x>0){
      if(x%2==1)open[c]=1;
      x/=2;
      c++;
    }

    ans=max(f(),ans);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
using namespace std;
#define REP(i, j) for(int i = 0; i < (int)(j); ++i)
#define FOR(i, j, k) for(int i = (int)(j); i < (int)(k); ++i)
#define SORT(v) sort((v).begin(), (v).end())
#define REVERSE(v) reverse((v).begin(), (v).end())
typedef pair<int, int> P;
const int MAX_N = 210;
const int MAX_R = 1010;
const int INF = 1e8;

int main(){
  int N, M;
  while(cin >>N >>M && N){
    int L[MAX_N][MAX_N], S[MAX_N][MAX_N], dp[MAX_R][MAX_N], v[MAX_R];
    REP(i, MAX_N) REP(j, MAX_N) L[i][j] = S[i][j] = (i == j ? 0 : INF);
    REP(i, MAX_R) REP(j, MAX_N) dp[i][j] = INF;
    REP(i, M){
      int a, b, c; char t; cin >>a >>b >>c >>t;
      --a; --b;
      if(t == 'S') S[a][b] = S[b][a] = c;
      else L[a][b] = L[b][a] = c;
    }
    REP(k, N) REP(i, N) REP(j, N) L[i][j] = min(L[i][j], L[i][k] + L[k][j]);
    REP(k, N) REP(i, N) REP(j, N) S[i][j] = min(S[i][j], S[i][k] + S[k][j]);
    int R; cin >>R;
    REP(i, R){ cin >>v[i]; --v[i]; }
    REP(j, MAX_N) dp[0][j] = min(INF, S[v[0]][j] + L[j][v[0]]);
    FOR(i, 1, R){
      REP(j, N){
        REP(k, N){
          dp[i][j] = min(dp[i][j], dp[i - 1][k] + L[v[i - 1]][k] + S[k][j] + L[j][v[i]]);
          if(k == j) dp[i][j] = min(dp[i][j], dp[i - 1][j] + L[v[i - 1]][v[i]]);
        }}}
    int ans = INF;
    REP(i, N) ans = min(ans, dp[R - 1][i]);
    cout <<ans <<endl;
  }
  return 0;
}

Measured memory_bytes: 2336
N,K = map(int,input().split())
A = list(map(int, input().split()))

l = [1]
kanryou_town = [0]*(N+1)
kanryou_town[1] = 1
now_town = 1
loop_town = 0
for i in range(N):
    now_town = A[now_town-1]
    if kanryou_town[now_town] == 1:
        loop_town = l.index(now_town)
        break
    else:
        kanryou_town[now_town] = 1
        l.append(now_town)

loop_num = len(l)-loop_town
if K > loop_town:
    num = (K - loop_town)%loop_num + loop_town
else:
    num = K
#
# num = (K+1)%len(l)
# print(l)

print(l[num])

Measured memory_bytes: 95128
import java.util.Scanner

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)

    val allTreeNum = sc.nextInt()
    val d = sc.nextInt()
  	
  	val rangePerPerson = 2*d + 1
  	
  	val i = if((allTreeNum % rangePerPerson) > 0) {
      1
    } else { 0 }
  
  	print((allTreeNum / rangePerPerson) + i)
  
}

Measured memory_bytes: 31264
#include<bits/stdc++.h>
#define ll long long
#define pii pair<int,int>
#define vii vector<int>
#define vcc vector<char>
#define pll pair<long long, long long>
#define mem memset
#define sof sizeof
#define PB push_back
#define MP make_pair
#define TS to_string
#define F first
#define S second
#define endl '\n'
using namespace std;
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    
    
    {
        long long a,b,c,d,e,f,i,j,k,m,n,o,x,y;
        cin>>a;
        cout<<a+a*a+a*a*a<<"\n";
        
    }
}

Measured memory_bytes: 3580
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <algorithm>
#include <iomanip>
#include <string.h>

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

typedef long long lint;

using namespace std;

int main(){
  int N;
  cin>>N;
  cout<<(N+1)/2<<endl;
  return 0;
}


Measured memory_bytes: 256
using System;
using System.Linq;
using static System.Math;
using static System.Console;

partial class Program
{
    public static void Main(string[] args)
    {
        var n = int.Parse(ReadLine());
        var s = ReadLine();

        char cOld = s[0];
        n = s.Length;

        var wCount = 0;
        var bCount = 0;
        var blist = new int[n + 1];
        var wlist = new int[n + 1];

        for (int i = 0; i < s.Length; i++)
        {
            if (s[i] == '#')
            {
                wCount++;
            }
            if (s[n - 1 - i] == '.')
            {
                bCount++;
            }
            wlist[i + 1] += wCount;
            blist[n - 1 - i] += bCount;
        }
        WriteLine(wlist.Zip(blist, (w, b) => w + b).Min());
    }
}

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

int main()
{
    int n;
    int d;
    cin >> n >> d;
    int count=0;
    for(int i=0;i<n;i++){
        long double x,y;
        cin >> x >> y;
        long double dist = sqrt((x*x)+(y*y));
        if(dist<=d){
            count++;
        }
    }
    cout << count << endl;
    return 0;
}


Measured memory_bytes: 3844
N,x = map(int, input().split())
a = list(map(int, input().split()))

ans = 0
for i in range(N-1):
    dif = a[i]+a[i+1] - x
    if dif > 0:
        if dif<=a[i+1]:
            a[i+1] -= dif
        else:
            a[i+1] = 0
    ans += max(dif, 0)
    
print(ans)
        

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

int main(){
    int n, m;
    cin >> n >> m;
    if(abs(n-m)>1){
        cout << 0 << endl;
        return 0;
    }

    ll ans;
    if(abs(n-m)==1){
        ans = 1;
    }else{
        ans = 2;
    }
    for (int i = 1; i <= n; i++)
    {
        ans *= i;
        ans %= MOD;
    }
    for (int i = 1; i <= m; i++)
    {
        ans *= i;
        ans %= MOD;
    }

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

Measured memory_bytes: 256
import math
import numpy as np


#a, b, c, x = map(int, [input() for i in range(4)])
#z = list(map(int, input().split()))
#n, a, b = map(int, input().split())

#print(len(z))
#for i in z:
#    print(i)

n = input()
a = list(map(int, input().split()))
a = sorted(a,reverse = True)
print(sum(a[::2]) - sum(a[1::2]))


Measured memory_bytes: 12424
#include<iostream>
using namespace std;
int main(){
	int a,b,c;
	cin>>a>>b;
	c=a+b;
	if(c<24)
	cout<<c<<endl;
	else if(c==24)
	cout<<"0"<<endl;
	else cout<<c%24<<endl;
	return 0;
} 

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

int main(){
    string a,b;
    int count = 0;
    cin >> a >> b;
    rep(i,a.length()){
        if(a[i] != b[i])count++;
    }
        cout << count << endl;
    return 0;
}

Measured memory_bytes: 3832
c1 = list(map(int, input().split()))
c2 = list(map(int, input().split()))
c3 = list(map(int, input().split()))
x = min(c1)
y = min(c2)
z = min(c3)
for i in range(3):
  c1[i] -= x
  c2[i] -= y
  c3[i] -= z
print('NYoe s' [c1==c2==c3::2])

Measured memory_bytes: 3064
mod = 1000000007
eps = 10**-9


def main():
    import sys
    input = sys.stdin.readline

    N = int(input())

    div_num = [1] * (N+1)
    ans = 0
    for i in range(1, N+1):
        ans += i * div_num[i]
        for j in range(2, N+1):
            if i*j > N:
                break
            div_num[i*j] += 1
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 146420
N,C = map(int,input().split())
 
D = []
c = []
 
for i in range(C):
    D.append(list(map(int,input().split())))
for i in range(N):
    c.append(list(map(int,input().split()))) 
 
c1 = []
c2 = []
c3 = []
 
from itertools import product
 
for i,j in product(range(N),repeat=2):
    if (i+j)%3 == 0:
        c1.append(c[i][j])
    elif (i+j)%3 == 1:
        c2.append(c[i][j])
    else:
        c3.append(c[i][j])
val=[]
cnt=[[],[],[]]
 
 
for j in range(C):
    cnt[0].append(c1.count(j+1))
    cnt[1].append(c2.count(j+1))
    cnt[2].append(c3.count(j+1))
 
for i in product(range(C),repeat=3):
    dif = 0
    if i[0]!=i[1] and i[1]!=i[2] and i[2]!=i[0]:
        for j in range(C):
            dif += D[j][i[0]] * cnt[0][j]
            dif += D[j][i[1]] * cnt[1][j]
            dif += D[j][i[2]] * cnt[2][j]
        val.append(dif)
 
print(min(val))

Measured memory_bytes: 58332
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rep2(i, a, n) for(ll i = a; i < (ll)(n); i++)
#define memi cout << endl
#define kono(n) cout << fixed << setprecision(n)
#define all(c) (c).begin(), (c).end()
#define pb push_back
#define hina cout << ' '
#define in(n) cin >> n
#define in2(n, m) cin >> n >> m
#define in3(n, m, l) cin >> n >> m >> l
#define out(n) cout << n
const ll mei = (ll)1e9 + 7;

int main(){
  ll n, h, m;
  h = 0;
  in(n);
  m = n;
  rep(i, 10){
    h = h + (m % 10);
    m = m / 10;
  }
  if(n % h == 0)
    out("Yes");
  else
    out("No");
  memi;
}

Measured memory_bytes: 256
let print_array l =
  Array.fold_left (fun x y -> (if x = "" then "" else x^" ")^(string_of_int y)) "" l
  |> print_endline;;
let to_array s = Str.split (Str.regexp_string " ") s
                 |> List.map (fun x -> int_of_string x)
                 |> Array.of_list;;

let sort a =
  let rec loop ct = function
      i when i = Array.length a -> print_array a;string_of_int ct |> print_endline
    | i ->
       let mini = i in
       let rec loop2 m = function
           j when j = Array.length a -> m
         | j -> if a.(j) < a.(m) then loop2 j (j+1) else loop2 m (j+1)
       in
       let swap_mini = loop2 mini i in
       let swap_ct = if swap_mini != i then ct+1 else ct in
       let temp = a.(i) in
       a.(i) <- a.(swap_mini);
       a.(swap_mini) <- temp;
       loop swap_ct (i+1)
  in
  loop 0 0;;

let _ =
  let _ = read_int () and
      a = read_line () |> to_array
  in sort a;;

Measured memory_bytes: 2188
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define MAX_LEN (100000)
#define NUM_MOD (1000000007L)

int main(int argc, char *argv[]) {
  // read inputs
  char s[MAX_LEN + 1];
  scanf("%s", s);
  const long n = strlen(s);

  // calculate powers of 3
  long pow3[MAX_LEN + 1] = {};
  pow3[0] = 1;
  for (int i = 1; i <= n; i++) {
    pow3[i] = (pow3[i - 1] * 3) % NUM_MOD;
  }

  // count total number of ?s
  long num_q = 0;
  for (int i = 0; i < n; i++) {
    if (s[i] == '?') {
      num_q++;
    }
  }

  // solve
  long cnt_a = 0, cnt_q = 0, cnt_ab = 0, cnt_aq = 0, cnt_qb = 0, cnt_qq = 0;
  long ans = 0;
  for (int i = 0; i < n; i++) {
    switch (s[i]) {
      case 'A':
        cnt_a++;
        break;
      case 'B':
        cnt_ab += cnt_a;
        cnt_qb += cnt_q;
        break;
      case 'C':
        ans = (ans + cnt_ab * pow3[num_q] +
               cnt_aq * (num_q >= 1 ? pow3[num_q - 1] : 0) +
               cnt_qb * (num_q >= 1 ? pow3[num_q - 1] : 0) +
               cnt_qq * (num_q >= 2 ? pow3[num_q - 2] : 0)) %
              NUM_MOD;
        break;
      case '?':
        ans = (ans + (cnt_ab * (num_q >= 1 ? pow3[num_q - 1] : 0)) % NUM_MOD +
               (cnt_aq * (num_q >= 2 ? pow3[num_q - 2] : 0)) % NUM_MOD +
               (cnt_qb * (num_q >= 2 ? pow3[num_q - 2] : 0)) % NUM_MOD +
               (cnt_qq * (num_q >= 3 ? pow3[num_q - 3] : 0)) % NUM_MOD) %
              NUM_MOD;
        cnt_qq += cnt_q;
        cnt_aq += cnt_a;
        cnt_q++;
        break;
      default:
        printf("something is wrong...\n");
        exit(0);
        break;
    }
  }
  printf("%ld\n", ans);

  return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define pb emplace_back
typedef long long ll;
typedef pair<int,int> pint;

int a[101];
int main(){
    int n,x;
    cin>>n>>x;
    rep(i,n) cin>>a[i];
    sort(a,a+n);
    int cnt=0;
    rep(i,n)if(x>=a[i]) ++cnt,x-=a[i];
    if(cnt!=n||cnt==n&&x==0)cout<<cnt<<endl;
    else cout<<cnt-1<<endl;
    return 0;
}

Measured memory_bytes: 256
def minimizer(n,a,b):
  first=n*a
  second=b
  if first>second:
    return second
  else: 
    return first

inputing=input()
input_sep=inputing.split(" ")
input_sep=[int(i) for i in input_sep]
print(minimizer(int(input_sep[0]),int(input_sep[1]),int(input_sep[2])))

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
const int max_n = 1e5+5;
typedef long long ll;
ll n, X, x[max_n]; 
ll gcd(ll a, ll b){
    if(b == 0)  return a;
    return gcd(b, a%b);
}

int main(){
    cin >> n >> X;
    for(int i=0 ; i<n ; i++){
        cin >> x[i];
    }
    ll ans = abs(X-x[0]);
    for(int i=1 ; i<n ; i++){
         ans = gcd(ans, abs(X-x[i]));
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using pint = pair<int, int>;
using ll = long long;
using pll = pair<ll, ll>;
#define FOR(i, begin, end) for (int i = (begin), i##_end_ = (end); i < i##_end_; i++)
#define IFOR(i, begin, end) for (int i = (end)-1, i##_begin_ = (begin); i >= i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define FI first
#define SE second
#define endl "\n"
#define ciosup cin.tie(0);ios::sync_with_stdio(false);
#define eb emplace_back
constexpr ll INF = 1e9 + 7;
constexpr ll MOD = 1e9 + 7;

int main()
{
    ciosup;
    char b;
    cin >> b;
    char c = (b == 'A') ? 'T'
                        : (b == 'T') ? 'A'
                                     : (b == 'C') ? 'G'
                                                  : 'C';
    cout << c << endl;
}

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

#define N 1000003
#define L 14
#define NIL -1

char H[N][L];

int getChar(char ch){
  if(ch == 'A'){
    return 1;
  }else if(ch == 'C'){
    return 2;
  }else if(ch == 'G'){
    return 3;
  }else if(ch == 'T'){
    return 4;
  }else{
    return 0;
  }
}

long long getKey(char str[]){
  long long i,sum = 0,p = 1;

  for(i = 0;i < strlen(str);i++){
    sum += p * (getChar(str[i]));
    p *= 5;
  }
  return sum;
}

int h1(int key){
  return key % N;
}
int h2(int key){
  return 1 + (key % (N - 1));
}

int find(char str[]){
  long long key,i,h;
  key = getKey(str);
  for(i = 0;;i++){
    h = (h1(key) + i * h2(key)) % N;
    if(strcmp(H[h],str) == 0){
      return 1;
    }else if(strlen(H[h]) == 0){
      return 0;
    }
  }
  return 0;
}

int insert(char str[]){
  long long key,i,h;
  key = getKey(str);
  for(i = 0;;i++){
    h = (h1(key) + i *h2(key)) % N;
    if(strcmp(H[h],str) == 0){
      return 1;
    }else if(strlen(H[h]) == 0){
      strcpy(H[h],str);
      return 0;
    }
  }

  return 0;
}

int main(void){
  int h,i,n;
  char str[L],com[9];
  for(i = 0;i < N;i++){
    H[i][0] = '\0';
  }

  scanf("%d",&n);

  for(i = 0;i < n;i++){
    scanf("%s %s",com,str);

    if(com[0] == 'i'){
      insert(str);
    }else{
      if(find(str)){
	printf("yes\n");
      }else{
	printf("no\n");
      }
    }
  }
  return 0;
}



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


inline long long read()
{
	long long s=0,f=1; char ch;
	for(;ch<'0'||ch>'9';ch=getchar()) if(ch=='-') f=-1;
	for(;ch>='0'&&ch<='9';ch=getchar()) s=(s<<3)+(s<<1)+ch-'0';
	return s*f;
}
int main()
{
	int a,b;
	cin>>a>>b;
	if(a-(b<<1)<=0) puts("0");
	else cout<<a-(b<<1)<<endl;
}

Measured memory_bytes: 256
type mang=array[0..1000005] of longint;
var h,a,x,y:mang;
    n,m,dem:longint;
    kt:boolean;
procedure nhap;
var i:longint;
begin
   read(n,m);
   for i:=1 to m do
      begin
      read(x[i],y[i]);
      inc(h[x[i]]);
      end;

   for i:=1 to n do
      h[i]:=h[i-1]+h[i];

   for i:=1 to m do
      begin
      a[h[x[i]]]:=y[i];
      dec(h[x[i]]);
      end;
   h[n+1]:=m;

end;

procedure DFS(i:Longint);
var j:longint;
begin
   if kt=true then exit;
   for j:=h[i]+1 to h[i+1] do
      begin
         dem:=dem+1;
         if (a[j]=n ) and (dem=2) then
            begin
            kt:=true;
            exit;
            end;
         if dem<2 then DFS(a[j]);
         dem:=dem-1;
      end;
end;

procedure xuly;
begin
   kt:=false;
   dem:=0;
   DFS(1);
end;

procedure xuat;
begin
   if kt=true then write('POSSIBLE')
      else write('IMPOSSIBLE');
end;

begin

   nhap;
   xuly;
   xuat;

end.


Measured memory_bytes: 13184
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int Q = sc.nextInt();

		PriorityQueue<Integer> qL = new PriorityQueue<Integer>(Comparator.reverseOrder());
		PriorityQueue<Integer> qR = new PriorityQueue<Integer>();
		long sumA = 0;
		long sumB = 0;

		for (int i = 0; i < Q; i++) {
			int x = sc.nextInt();
			if (x == 1) {
				Integer a = sc.nextInt();
				sumB += sc.nextInt();
				qL.add(a);
				qR.add(a);
				if (qL.peek() > qR.peek()) {
					Integer tmpL = qL.poll();
					Integer tmpR = qR.poll();
					qL.add(tmpR);
					qR.add(tmpL);
					sumA += (tmpL - tmpR);
				}

				// for (int num : qL) {
				// 	System.out.print(num + ", ");
				// }
				// System.out.println();
				// for (int num : qR) {
				// 	System.out.print(num + ", ");
				// }
				// System.out.println();
			} else {
				if (qL.size() == 0) {
					System.out.println("0 0");
					continue;
				}
				Integer min = qL.peek();
				long sum = sumA + sumB;
				System.out.println(min + " " + sum);
			}
		}
	}
}


Measured memory_bytes: 152888
#include <iostream>
#include <cstdio>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <string>
#include <algorithm>

using namespace std;

int main() {
    int a[4], b[4];
    int c[4] = {10,50,100,500};
    int d, e = 0, ju, i;
    while (cin>>d, d){
        if( e ) cout<<endl;
        e++;
        int sum = 0;
        for(i = 0; i < 4; i++) {
            cin>>a[i];
            sum += a[i] * c[i];
        }
        sum -= d;
        for (i = 4; i--;) {
            b[i] = sum / c[i];
            sum %= c[i];
        }
        for (i = 0; i < 4; i++) {
            ju = a[i] - b[i];
            if (ju>0) cout<<c[i]<<' '<<ju<<endl;
        }
    }
}


Measured memory_bytes: 3100
#define ffor(i,a,b) for (int i=(a);i<(b);i++)
#define rfor(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define rep(i,n) for (int i=0;i<(n);i++)
#define rrep(i,n) for (int i=(n)-1;i>=0;i--)
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<cmath>
#include<string>
#include<stack>
#include<queue>
#define SIZE 100001
#define MOD 1000000007
#define INF 100000000
using namespace std;

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

	int N,M;
	int a[60],b[60],c[60],d[60];

	cin >> N >> M;
	rep(i,N) cin >> a[i] >> b[i];
	rep(i,M) cin >> c[i] >> d[i];

	int man_len;
	rep(i,N){
		int min = 1000000000;
		int memo = 0;
		rep(j,M){
			man_len = abs(a[i]-c[j])+abs(b[i]-d[j]);
			if(min > man_len){
				min = man_len;
				memo = j+1;
			}
		}
		cout << memo << endl;
	}

	return 0;
}

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

using Vec = std::vector<int>;

Vec get_vec() {
    int n;
    std::cin >> n;

    Vec vec{};
    for (int i = 0; i < n; ++i) {
        int a;
        std::cin >> a;
        vec.push_back(a);
    }

    return vec;
}

void print_eq_range(const Vec& vec) {
    int q;
    std::cin >> q;

    for (int j = 0; j < q; ++j) {
        int k;
        std::cin >> k;

        std::cout << std::distance(vec.begin(),
                                   std::lower_bound(vec.begin(), vec.end(), k))
                  << ' '
                  << std::distance(vec.begin(),
                                   std::upper_bound(vec.begin(), vec.end(), k))
                  << std::endl;
    }
}

int main(void) {
    Vec vec = get_vec();
    print_eq_range(vec);
}


Measured memory_bytes: 3520