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

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	string s;
	bool f=true;
	cin>>s;
	map<string,int> cnt;
	for(int i=0;i<s.length();i++){
		cnt[s.substr(i,1)]++;
	}
	for(auto p:cnt){
		auto v=p.second;
		if(v%2!=0){
			f=false;
		}
	}
	if(f){
		cout<<"Yes"<<endl;
	}else{
		cout<<"No"<<endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<vector>
#include<algorithm>
using namespace std;


const long long INF = (1 << 31) - 1;

struct segtree{
  int size;
  vector<long long> updated;
  segtree(int n){
    size = 1;
    while(n>size){
      size *= 2;
    }
    updated.assign(2*size-1,INF);
  }
  void update(int a,int b,long long x,int k,int l,int r){
    if(b<=l||r<=a) return;
    if(a<=l&&r<=b) updated[k] = x;
    else{
      if(updated[k]>=0){
        updated[2*k+1] = updated[k];
        updated[2*k+2] = updated[k];
        updated[k] = -1;
      }
      update(a,b,x,2*k+1,l,(l+r)/2);
      update(a,b,x,2*k+2,(l+r)/2,r);
    }
  }
  void update(int a,int b,long long x){
    update(a,b+1,x,0,0,size);
  }
  long long find(int i,int k,int l,int r){
    if(i<l||r<=i) return -1;
    if(updated[k]>=0) return updated[k];
    else return max(find(i,2*k+1,l,(l+r)/2),find(i,2*k+2,(l+r)/2,r));
  }
  long long find(int i){
    return find(i,0,0,size);
  }
};

int main(){
  int n,q;
  scanf("%d %d",&n,&q);
  segtree st(n);
  for(int i=0;i<q;i++){
    int cmd;
    scanf("%d",&cmd);
    if(cmd==0){
      long long s,t,x;
      scanf("%lld %lld %lld",&s,&t,&x);
      st.update(s,t,x);
    }else if(cmd==1){
      int i;
      scanf("%d",&i);
      printf("%lld\n",st.find(i));
    }
  }
}

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

int measure(int,int);

int main(void){
    long a,b;
    int div;
    cin>>a>>b;
    div = measure(a,b);
    cout<<div<<endl;
    return 0;
}


int measure(int x, int y)
{	
	int z = y;
	while(x%y!=0)
	{
		z = x%y;
		x = y;
		y = z;	
	}
	return z;
}


Measured memory_bytes: 3108
def solve(n, a_list):
    total = [abs(item) for item in a_list]
    negative = [abs(item) for item in a_list if item < 0]
    # print(negative)
    if len(negative) % 2 == 0:
        return sum([abs(item) for item in a_list])
    else:
        minimum = sorted(total)[0]
        return sum([abs(item) for item in a_list]) - 2 * minimum


def input_from_console():
    n = int(input())
    a = list(map(int, input().split()))
    return n, a


def main():
    n, a_list = input_from_console()
    print(solve(n, a_list))


if __name__ == "__main__":
    main()

Measured memory_bytes: 19444
#include<iostream>
#include<cmath>
#include<cstring>
using namespace std;
bool used[101][101];
int mas[101][101],sx,sy,gx,gy,w,h;
int d[]={0,1,0,-1};
int dfs(int,int,int);
int main(){
  int n,c,d,x,y,tate,yoko;
  while(cin >> w >> h && w||h){
    memset(used,false,sizeof(used));
    memset(mas,-1,sizeof(mas));
    cin >> sy >> sx >> gy >> gx >> n;
    sy--,sx--,gx--,gy--;
    while(n--){
      cin >> c >> d >> y >> x;
      x--,y--;
      d==0 ? (tate=2,yoko=4) : (tate=4,yoko=2);
      for(int i=x;i<x+tate;i++){
	for(int j=y;j<y+yoko;j++){
	  mas[i][j] = c;
	}
      }
    }
    dfs(sx,sy,mas[sx][sy]);
    cout << (used[gx][gy]?"OK":"NG") << endl;
  }
}
int dfs(int x,int y,int color){
  used[x][y] = true;
  for(int i=0;i<4;i++){
    int nx=x+d[i],ny=y+d[3-i];
    if(x>=0&&x<h&&y>=0&&y<w&&mas[nx][ny]==color&&used[nx][ny]==false){
	dfs(nx,ny,color);
      }
  }
}

Measured memory_bytes: 1224
def main():
    n, m = map(int, input().split())
    all_patterns = 2**n
    DP = [10**9] * all_patterns
    DP[0] = 0
    for _ in range(m):
        cost, types = map(int, input().split())
        to_open = list(map(int, input().split()))

        openable = 0
        for open in to_open:
            openable += 1 << (open-1)

        for opened in range(all_patterns):
            pattern = opened | openable
            new_cost = DP[opened] + cost
            if DP[pattern] > new_cost:
                DP[pattern] = new_cost

    full_open = 2**n - 1
    ans = DP[full_open]
    if ans == 10 ** 9:
        ans = -1
        
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3188
N = int(input())
H = list(map(int,input().split()))
safe = True
for i in reversed(range(N-1)):
  if H[i] > H[i+1]:
    H[i] -=1
for i in range(N-1):
  if H[i] > H[i+1]:
    safe = False
    break
print('Yes' if safe else 'No')

Measured memory_bytes: 85040
#define _CRT_SECURE_NO_DEPRECATE
#define _USE_MATH_DEFINES
#include <iostream>
#include <cmath>
#include <string>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <memory.h>
#include <set>
#include <ctime>
#include <map>
#include <cstring>
#include <iterator>
#include <queue>
#include <assert.h>
#include <bitset>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <functional>

//#pragma comment(linker, "/STACK:512000000")

using namespace std;

#define pb emplace_back
#define mp make_pair
#define all(a) (a).begin(), (a).end()
#define forn(i, n) for (int i = 0; i < (n); ++i)
#define forab(i, a, b) for (int i = (a); i < (b); ++i)

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int infi = 1e9 + 7;
const ll infl = (ll)1e18 + (ll)7;

ll ar[5010];
ll dp[5010][5010][2];
ll ndp[5010][2];
void upd(ll& a, ll b) {
    a = min(a, b);
}
vector<vector<int> > g;
int dfs(int v, int p = -1) {
    int sz = 1;
    forn(i, 5010)
        dp[v][i][0] = dp[v][i][1] = infl;
    if (ar[v] > 0)
        dp[v][0][0] = ar[v];
    else
        dp[v][0][1] = ar[v];
    for (int to : g[v]) {
        if (to == p)
            continue;
        int cur_sz = dfs(to, v);
        forn(i, cur_sz + sz)
            ndp[i][0] = ndp[i][1] = infl;
        forn(i, cur_sz) {
            int flag = 0;
            if (dp[to][i][0] < infl / 2 || dp[to][i][1] < 0)
                flag = 1;
            ll a = dp[to][i][0];
            ll b = min(dp[to][i][0], dp[to][i][1]);
            forn(j, sz) {
                upd(ndp[i + j][0], a + dp[v][j][0]);
                upd(ndp[i + j][1], b + min(dp[v][j][0], dp[v][j][1]));
                if (flag) {
                    upd(ndp[i + j + 1][0], dp[v][j][0]);
                    upd(ndp[i + j + 1][1], dp[v][j][1]);
                }
            }
        }
        sz += cur_sz;
        forn(i, sz)
            dp[v][i][0] = ndp[i][0], dp[v][i][1] = ndp[i][1];
    }
    return sz;
}

int32_t main() {
    cin.sync_with_stdio(false);
    cin.tie(0);
    //srand(time(NULL));
    //freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
    //freopen("customs.in", "r", stdin); freopen("customs.out", "w", stdout);
    int n;
    cin >> n;
    forn(i, n)
        cin >> ar[i];
    g.resize(n);
    forn(i, n - 1) {
        int u, v;
        cin >> u >> v;
        --u, --v;
        g[u].pb(v);
        g[v].pb(u);
    }
    dfs(0);
    for (int i = 0; i < n; ++i) {
        if (dp[0][i][0] < infl / 2 || dp[0][i][1] < 0) {
            cout << i << '\n';
            return 0;
        }
    }
    assert(0);


    return 0;
}

Measured memory_bytes: 392576
def distance(i, j, x, y):
    return min([abs(j - i), abs(x - i) + 1 + abs(j - y), abs(y - i) + 1 + abs(j - x)])


if __name__ == '__main__':
    n, x, y = tuple([int(i) for i in input().split()])
    x, y = min(x, y), max(x, y)

    dists = [0 for k in range(n)]
    for i in range(1, n):
        for j in range(i + 1, n + 1):
            d = distance(i, j, x, y)
            dists[d] += 1

    for k in dists[1:]:
        print(k)


Measured memory_bytes: 3444
#include<cstdio>

int main(){
    int x;
    int s = 0;
    for(int i = 0;; i++){
        scanf("%d\n",&x);
        if(x == 0){
            break;
        }
        s++;
        printf("Case %d: %d",s,x);
        printf("\n");
    }
    return 0;
}


Measured memory_bytes: 2572
#include <iostream>

int main()
{
    using namespace std;

    int K, S;
    int count = 0;
    cin >> K >> S;

    for (int x = 0; x <= K; ++x)
    {
        for (int y = 0; y <= K; ++y)
        {
            if ((S - (x + y) <= K) && (S - (x+y) >= 0))
            {
                ++count;
            }
        }
    }

    cout << count;

    return 0;
}

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

int max(int *array, int n) {
  int max = 0;
  for (int i = 0; i < n; i++) {
    if (max < array[i]) max = array[i];
  }
  return max;
}

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

int main() {
  int n;
  int ls[105];
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> ls[i];
  }
  int max_l = max(ls, n);
  int sum_l = sum(ls, n) - max_l;
  if (sum_l > max_l) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
int a,b,c,d,e,f,g,h;
long  int A[101][101]={0},B[101][101]={0},C[101][101]={0};

scanf("%d %d %d",&a,&b,&c);
for(d=0;d<a;d++){
for(e=0;e<b;e++){
scanf("%d",&A[d][e]);
}
}
for(d=0;d<b;d++){
for(e=0;e<c;e++){
scanf("%d",&B[d][e]);
}
}
for(f=0;f<a;f++){
for(d=0;d<b;d++){
for(e=0;e<c;e++){
	C[f][e]+=A[f][d]*B[d][e];
}
}
}
for(d=0;d<a;d++){
for(e=0;e<c;e++){
printf("%ld",C[d][e]);
if(e!=c-1)
printf(" ");
else
printf("\n");
}
}
return 0;
}

Measured memory_bytes: 852
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;

#define REP(i,n) for(long long i = 0; i < (n); i++)
#define FOR(i, m, n) for(long long i = (m);i < (n); ++i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SPEED cin.tie(0);ios::sync_with_stdio(false);

template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
template<class T> using PQ = priority_queue<T>;
template<class T> using PQR = priority_queue<T,vector<T>,greater<T>>;

constexpr long long MOD = (long long)1e9 + 7;
constexpr long long MOD2 = 998244353;
constexpr long long HIGHINF = (long long)1e18;
constexpr long long LOWINF = (long long)1e15;
constexpr long double PI = 3.1415926535897932384626433;

template <class T> vector<T> multivector(size_t N,T init){return vector<T>(N,init);}
template <class... T> auto multivector(size_t N,T... t){return vector<decltype(multivector(t...))>(N,multivector(t...));}
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template <class T, class U>ostream &operator<<(ostream &o, const map<T, U>&obj) {o << "{"; for (auto &x : obj) o << " {" << x.first << " : " << x.second << "}" << ","; o << " }"; return o;}
template <class T>ostream &operator<<(ostream &o, const set<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const multiset<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const vector<T>&obj) {o << "{"; for (int i = 0; i < (int)obj.size(); ++i)o << (i > 0 ? ", " : "") << obj[i]; o << "}"; return o;}
template <class T, class U>ostream &operator<<(ostream &o, const pair<T, U>&obj) {o << "{" << obj.first << ", " << obj.second << "}"; return o;}
template <template <class tmp>  class T, class U> ostream &operator<<(ostream &o, const T<U> &obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr)o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
void print(void) {cout << endl;}
template <class Head> void print(Head&& head) {cout << head;print();}
template <class Head, class... Tail> void print(Head&& head, Tail&&... tail) {cout << head << " ";print(forward<Tail>(tail)...);}
template <class T> void chmax(T& a, const T b){a=max(a,b);}
template <class T> void chmin(T& a, const T b){a=min(a,b);}
void YN(bool flg) {cout << (flg ? "YES" : "NO") << endl;}
void Yn(bool flg) {cout << (flg ? "Yes" : "No") << endl;}
void yn(bool flg) {cout << (flg ? "yes" : "no") << endl;}

int main() {
    int N; cin >> N;
    vector<int> A(N);
    for(int i = 0; i < N; ++i){
        cin >> A[i];
    }
    int ans = 0;
    int idx = 1;
    for(int i = 0; i < N; ++i){
        if(A[i]==idx){
            idx++;
        }
        else{
            ans++;
        }
    }
    if(ans==N) ans = -1;
    cout << ans << endl;


    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define FIN         ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define ii          pair<int,int>
#define F           first
#define S           second
#define pb          push_back
#define all(x)      (x).begin(),(x).end()
#define rall(x)     (x).rbegin(),(x).rend()
#define fore(i,a,b) for(int i = a;i < b; i+= 1)
#define forr(i,a)   for(int i = a; i >= 0; i--)
#define fori(i,m)   for(auto i = m.begin(); i != m.end(); i++) 
#define w(t)        while(t--)
#define sz(s)       int(s.size())
#define cls(a,car)  memset(a,car,sizeof (a))
#define db(x)       cerr << #x << " is " << x << '\n'
#define FI          freopen("input.txt", "r", stdin)
#define FO          freopen("output.txt", "w", stdout)
#define EjecuteTime cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n"
#define angle(x)    double(x * acos(-1) / 180.0)
using namespace std;
typedef long long   ll;
typedef vector<int> vi;
typedef vector<ii>  vii;
const int N = 1e4 + 5;
const ll mod = 1e9 + 7;
const double E = 1e-6;
//int dx[] = {0, -1}, dy[] = {-1, 0};
//int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};
//int dx[] = {1, 1, 0, -1, -1, -1, 0, 1}, dy[] = {0, 1, 1, 1, 0, -1, -1, -1};
//int dx[] = {2, 1, -1, -2, -2, -1, 1, 2}, dy[] = {1, 2, 2, 1, -1, -2, -2, -1};
// fflush(stdout)
// cout << flush
// a + b = a ^ b + 2 * (a & b)
void solve(){
    int n, x, t;
    cin >> n >> x >> t;
    int aux = n / x + (n % x != 0);
    cout << aux * t << '\n';
}
int main(){
    FIN;
    int t = 1;
    //cin >> t;
    for(int i = 1; i <= t; i++){
        solve();
    }
    //EjecuteTime;
    return 0;
}       


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

const int INF = INT_MAX / 2;
#define repi(i, m, n) for (int i = m; i < n; i++)
#define rep(i, n) repi(i, 0, n)
#define rrep(i, n) repi(i, 1, n + 1)

class RAQ {
 public:
  int n = 1;
  vector<int> node[3], lazy;
  void init(int N) {
    while (n < N) n *= 2;
    node[2].resize(2 * n - 1);
    lazy.resize(2 * n - 1);
  }
  void lazy_evaluate(int k, int l, int r) {
    node[2][k] += lazy[k] * (r - l);
    if (k < n - 1) rrep(i, 2) {
        lazy[2 * k + i] += lazy[k];
      }
    lazy[k] = 0;
  }
  void update(int a, int b, int x, int k, int l, int r) {
    lazy_evaluate(k, l, r);
    if (r <= a || b <= l) return;
    if (a <= l && r <= b) {
      lazy[k] += x;
      lazy_evaluate(k, l, r);
      return;
    }
    update(a, b, x, k * 2 + 1, l, (l + r) / 2);
    update(a, b, x, k * 2 + 2, (l + r) / 2, r);
    // node[0][k] = max(node[0][k * 2 + 1], node[0][k * 2 + 2]);
    // node[1][k] = min(node[1][k * 2 + 1], node[1][k * 2 + 2]);
    node[2][k] = node[2][k * 2 + 1] + node[2][k * 2 + 2];
  }
  int calc(int a, int b, int k, int l, int r, int f) {
    lazy_evaluate(k, l, r);
    if (r <= a || b <= l) return 0;
    if (a <= l && r <= b) return node[f][k];
    int vl = calc(a, b, k * 2 + 1, l, (l + r) / 2, f);
    int vr = calc(a, b, k * 2 + 2, (l + r) / 2, r, f);
    return vl + vr;
  }
  void add(int a, int b, int x) { update(a, b, x, 0, 0, n); }
  int get_sum(int a, int b) { return calc(a, b, 0, 0, n, 2); }
};

main() {
  int n, qn;
  string s;
  cin >> n >> s >> qn;
  RAQ cc[26];
  repi(i, 0, 26) cc[i].init(n + 1);
  repi(i, 0, n) cc[s[i] - 'a'].add(i + 1, n + 1, 1);
  repi(i, 0, qn) {
    int qt;
    cin >> qt;
    if (qt == 1) {
      int iq;
      char cq;
      cin >> iq >> cq;
      iq--;
      if (s[iq] != cq) {
        cc[s[iq] - 'a'].add(iq + 1, n + 1, -1);
        cc[cq - 'a'].add(iq + 1, n + 1, 1);
        s[iq] = cq;
      }
    } else {
      int lq, rq;
      cin >> lq >> rq;
      lq--;
      int req = 0;
      repi(i, 0, 26) {
        if (cc[i].get_sum(rq, rq + 1) > cc[i].get_sum(lq, lq + 1)) req++;
      }
      cout << req << endl;
    }
  }
}


Measured memory_bytes: 216068
#include <bits/stdc++.h>
using namespace std;
void debug() {cout<<endl;}
template<typename T,typename... Args>
void debug(T x,Args... args) {cout<<x<<" ";debug(args...);}
#define forn(i,a,b) for(int i=a;i<b;++i)
#define SZ(x) int(x.size())
#define pb push_back
#define F first
#define S second
#define endl "\n"
typedef long long ll;
typedef pair<int, int> pii;

bool valide(int n) {
    for (int i = 1; i*i <= n; ++i) {
        if (n%i == 0 && i == n/i) return true;
    }
    return false;
}

int main() {
    ios::sync_with_stdio(0); cin.tie(0);
    
    string a, b;
    cin >> a >> b;
    
    if (valide(stoi(a+b)) || valide(stoi(b+a))) {
        cout << "Yes\n";
    } else {
        cout << "No\n";
    }
    
}

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

int n,m; vector<ll> c;

ll dfs(ll a, ll b, ll c){
  
  if( a == 0 && b == 0){ return 0;}
  
  ll res = 1e8;
  
  if( c & 1){return  dfs( a >> 1, b >> 1, c >> 1);}
  
  if( b & 1){
    return dfs( c >> 1, b >> 1, a >> 1)+1+dfs((a|b|c)>>1, 0,0) ;
  }
  
  if( a & 1){
    return dfs( a>>1,b>>1,c>>1)+1+2*dfs((a|b|c)>>1,0,0)+1;
  }
  
}
  
int main(){ 
  while( cin >> n >> m){
    
    if( n == 0 && m == 0){ break;}
   
    c = vector<ll> (3,0);
    
    for(ll i = 0; i < 3; i++){
    
      ll k; cin >> k;
      for(ll j = 0; j < k; j++){
        ll a; cin >> a; c[i] |= (1LL << (a-1));
      }
    }
    
    
    ll res = min(dfs(c[0],c[1],c[2]),dfs(c[2],c[1],c[0]));
    
    
    if( res > m){ res = -1;}
    
    cout << res << endl;
    
  }
  
  return 0;
}


Measured memory_bytes: 3088
#include<iostream>
using namespace std;
int main(){
	string a;
  cin>>a;
    long long r=0,n=a.size();
  for(long long i=0;i<n;i++){
  	r+=(a[i]-48);
  }
  if(r%9)	cout<<"No";
  else	cout<<"Yes";
}

Measured memory_bytes: 3356
#include <iostream>
#include <string> 
#include <vector> 
#include <algorithm> 
#include <utility> 
#include <tuple> 
#include <cstdint> 
#include <cstdio> 
#include <map> 
#include <queue> 
#include <set> 
#include <stack> 
#include <deque> 
#include <unordered_map> 
#include <unordered_set> 
#include <bitset> 
#include <cctype> 
#include<math.h>
using namespace std;
//#define int long long
#define m_p make_pair
#define mod 1000000007
#define rep(i,n)  for(int i=0; i<(int)(n); i++)
#define all(v)  v.begin(),v.end()
#define vecin(v) for(int i=0; i<(int)v.size(); i++)cin>>vec[i];
using namespace std;

int jousu(int, int);
int jousu(int x00, int y00) {
	int z00 = 1;
	for (int i = 0; i < y00; i++) {
		z00 *= x00;
	}
	return z00;
}
int kurai(int x00, int y00) {
	int z00 = (x00 % jousu(10, y00)) / jousu(10, y00 - 1);
	return z00;
}
int keta(int x00) {
	int z00 = x00;
	int w00 = 0;
	while (z00 != 0) {
		z00 /= 10;
		w00++;
	}
	return w00;
}



int main() {
	int n, m,s;
	cin >> n >> m;
	vector<pair<int, int>>vec(m);
	vector<int>vec2(3,-1);
	for (int i = 0; i < m; i++) {
		cin >> vec[i].first >> vec[i].second;
	}
	if (n == 1) {
		s = 0;
	}
	else if (n == 2) {
		s = 10;
	}
	else if (n == 3) {
		s = 100;
	}
	if (n == 3) {
		for (int i = 0; i < m; i++) {
			if (vec2[vec[i].first - 1] >= 0 && vec2[vec[i].first - 1] != vec[i].second) {
				printf("-1");
				return 0;
			}
			if (vec[i].first == 3) {
				s = (s / 10 * 10) + vec[i].second;
			}
			else if (vec[i].first == 2) {
				s = (s / 100 * 100) + (s % 10) + (vec[i].second * 10);
			}
			else if (vec[i].first == 1) {
				s = (s % 100) + (vec[i].second * 100);
			}
			vec2[vec[i].first - 1] = vec[i].second;
		}
	}
	if (n == 2) {
		for (int i = 0; i < m; i++) {
			if (vec2[vec[i].first - 1] >= 0 && vec2[vec[i].first - 1] != vec[i].second) {
				printf("-1");
				return 0;
			}
			if (vec[i].first == 2) {
				s = (s / 10 * 10) + vec[i].second;
			}
			else if (vec[i].first == 1) {
				s = (s%10) + (vec[i].second * 10);
			}
			vec2[vec[i].first - 1] = vec[i].second;
		}
	}
	if (n == 1) {
		for (int i = 0; i < m; i++) {
			if (vec2[vec[i].first - 1] >= 0 && vec2[vec[i].first - 1] != vec[i].second) {
				printf("-1");
				return 0;
			}
			if (vec[i].first == 1) {
				s = vec[i].second;
			}
			vec2[vec[i].first - 1] = vec[i].second;
		}
	}
	if (n == 3 && s / 100 == 0) {
		printf("-1");
		return 0;
	}
	else if (n == 2 && s / 10 == 0) {
		printf("-1");
		return 0;
	}
	printf("%d", s);
}


Measured memory_bytes: 256
import numpy as np
from collections import deque
from collections import defaultdict
import heapq
import collections
import itertools
import bisect

X, Y, Z, K = list(map(int, input().split()))
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
A = sorted(A, reverse=True)
B = sorted(B, reverse=True)
C = sorted(C, reverse=True)
i, j, k = 0, 0, 0
heap = [(-A[i] - B[j] - C[k], i, j, k)]
heapq.heapify(heap)
used_set = set([(i, j, k)])
for _ in range(K):
    oisi, i, j, k = heapq.heappop(heap)
    print(-oisi)
    if (i+1, j, k) in used_set:
        pass
    elif(i+1 < len(A)):
        used_set.add((i+1, j, k))
        heapq.heappush(heap, (-A[i+1]-B[j]-C[k], i+1, j, k))
    if (i, j+1, k) in used_set:
        pass
    elif(j+1 < len(B)):
        used_set.add((i, j+1, k))
        heapq.heappush(heap, (-A[i] - B[j+1] - C[k], i, j+1, k))
    if (i, j, k+1) in used_set:
        pass
    elif(k+1 < len(C)):
        used_set.add((i, j, k+1))
        heapq.heappush(heap, (-A[i]-B[j]-C[k+1], i, j, k+1))


Measured memory_bytes: 13896
N = int(input())
B = list(map(int, input().split()))

A = [0] * N

for i in range(len(B)):
    A[i] = B[i]
    A[i+1] = B[i]

    if i > 0:
        if A[i] > B[i-1]:
            A[i] = B[i-1]

print(sum(A))


Measured memory_bytes: 3060
import sys
def main():
    N, M, P = map( int, input().split())
    INF = 1e18
    d = list()
    for _ in range(M):
        a, b, c = map( int, input().split())
        a, b = a-1, b-1
        d.append((a,b,P-c))
    V = [INF]*N
    V[0] = 0
    for _ in range(N):
        for (s,t,cost) in d:
            if V[s] != INF:
                V[t] = min(V[t], V[s] + cost)

    for _ in range(N):
        for (s,t,cost) in d:
            if V[s] != INF:
                if V[t] > V[s] + cost:
                    V[t]=-INF

    if V[-1] == -INF:
        print(-1)
    else:
        print( max(-V[-1], 0))
if __name__ == '__main__':
    main()


Measured memory_bytes: 49368
import sys
sys.setrecursionlimit(100000)


def rootedTree(node,parent,root,num):
    A.append([node,parent,root,num])
    for root_num,num in root:
            rootedTree(root_num,node,tree[root_num],num)


n=int(input())
AB=[list(map(int,input().split()))+[i+1] for i in range(n-1)]
A=[]
tree=[[] for i in range(n+1)]
for a,b,c in AB:
    tree[a] +=[[b,c]]

rootedTree(1,0,tree[1],0)
ans=[0]*n
for node,parent,root,num in A:
    flag=0
    for i,j in enumerate(root):
        if ans[num]==i+1:flag=1
        ans[j[1]]=i+1+flag

print(max(ans))
for i in range(1,n):print(ans[i])

Measured memory_bytes: 86724
def main():
	INF = 10**9+7
	N, M = map(int, input().split())
	dist = [[INF for _ in range(N+1)] for _ in range(N+1)]
	for i in range(1, N+1):
		for j in range(1, N+1):
			if i == j:
				dist[i][j] = 0
	a, b, c = [0]*M, [0]*M, [0]*M
	for i in range(M):
		a[i], b[i], c[i] = map(int, input().split())
		dist[a[i]][b[i]] = min(dist[a[i]][b[i]], c[i])
		dist[b[i]][a[i]] = min(dist[b[i]][a[i]], c[i])
	for k in range(1, N+1):
		for i in range(1, N+1):
			for j in range(1, N+1):
				dist[i][j] = min(dist[i][j], dist[i][k]+dist[k][j])
	ans = M
	for i in range(M):
		shrotest = False
		for j in range(1, N+1):
			if dist[j][a[i]]+c[i] == dist[j][b[i]]:
				shrotest = True
		if shrotest:
			ans -= 1
	print(ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 3428
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <numeric>
#include <sstream>
//#include <fstream>

using namespace std;

#define M 100000000

int t[100][100];

void mst (vector <int>& pi, vector <int>& cost )
{
	int n = pi.size();
	int i;

	vector <bool> v (n, false );

	do{
		int mincost = M;
		int u;

		// costªÅ¬ÆÈém[huðIð·é
		for (i = 0; i < n; ++i ){
			if (!v[i] && cost[i] < mincost ){
				mincost = cost[i];
				u = i;
			} // end if
		} // end for

		v[u] = true;
	
		for (i = 0; i < n; ++i ){
			// Ü¾ÜÜêÄ¢È¢m[hÌRXgÌXV
			if (!v[i] && t[u][i] < cost[i] ){
				cost[i] = t[u][i];
				pi[i] = u;
			} // end if
		} // end for		 
		
	} while ((int)count (v.begin(), v.end(), true ) != n );// end while
}

int main()
{

//	cut here before submit 
//	freopen("testcase.cdl", "r", stdin);

	string str = "";
	int n,m;	// n: jÕÌÓ m: jÕðÔ¹Ì

	while (getline (cin, str ) ) {
		stringstream ssn(str);
		ssn >> n;
		if (n == 0){
			break;
		} // end if
		getline (cin, str );
		stringstream ssm (str );
		ssm >> m;

		int i, j;
		for (i = 0; i < 100; ++i ){
			for (j = 0; j < 100; ++j ){
				t[i][j] = M;
			} // end for
		} // end for 

		for (i = 0; i < m; ++i ){
			int from, to, dist;
			getline (cin, str );
				while (str.find(',') != string::npos ){
				str = str.replace (str.find (','), 1, " " );
			} // end while
			stringstream ss (str );
			ss >> from >> to >> dist;
			t[from][to] = dist;
			t[to][from] = dist;
		} // end for

		vector <int> len (n, M );
		vector <int> path (n, -1 );
		len[0] = 0;
		path[0] = -1;

		mst (path, len );

		int res = accumulate (len.begin(), len.end(), 0 );
		
		map <int, int> edge;
		for (i = 0; i < n; ++i ){
			int curr = i;
			while (path[curr] != -1 ){
				edge[curr] = path[curr];
				curr = path[curr];
			} // end while

		} // end for

		cout << (res/100 - edge.size() ) << endl;

	} // end while

	return 0;
}

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

int main(void) {
    int n, k;
    cin >> n >> k;
    
    int ans = 0;
    --n;
    while (n > 0) {
        ++ans;
        n -= (k-1);
    }
    cout << ans << endl;
    
}

Measured memory_bytes: 256
import java.util.Scanner

object Main {
  def main(args: Array[String]): Unit = {
    val sc = new Scanner(System.in)
    val Array(a, b, c, x, y) = sc.nextLine.split(" ").map(_.toInt)
    if (x < y) println(Array(a * x + b * y, 2 * c * x + b * (y - x), 2 * c * y).min)
    else println(Array(a * x + b * y, 2 * c * y + a * (x - y), 2 * c * x).min)
  }
}


Measured memory_bytes: 27444
#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>
#include <set>
#include <vector>
#include <map>
#include <list>
#include <stack>
#define REP(i, n) for(i=0; i<n; i++)
#define REPR(i, n) for(i=n; i>=0; i--)
#define FOR(i, m, n) for(i=m; i<n; i++)
#define max(a, b) ((a)>(b) ? (a):(b))
#define min(a, b) ((a)<(b) ? (a):(b))
#define INF 10000000000
#define MOD 1000000007LL
using namespace std;
typedef long long ll;
typedef pair<ll, ll> p;
typedef pair<double, double> doup;

int main(void) {
    ll a[3];
    ll i;
    for(i=0; i<3; i++)
        cin >> a[i];
    sort(a, a+3);
    
    cout << a[1]-a[0]+a[2]-a[1];
    
    
    
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define l first
#define r second
using namespace std;
pair<int,int> a[200010];
priority_queue<int,vector<int>,greater<int> > ql,qr;
int main()
{
	int n,m,rem;scanf("%d%d",&n,&m);rem=n;
	for (int i=1;i<=n;i++) scanf("%d%d",&a[i].l,&a[i].r);
	sort(a+1,a+n+1);
	for (int i=1;i<=n;i++)
		if (a[i].l==ql.size()) {ql.push(a[i].r);qr.push(ql.top());ql.pop();}
		else {ql.push(a[i].r);rem--;}
	for (int i=ql.size()+1;i<=m;i++) if ((!qr.empty())&&(qr.top()<=i)) {rem--;qr.pop();}
	printf("%d\n",rem);
}

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

ll solnD(ll n,ll cap,vector<ll> &w,vector<ll> &v){
	ll dp[n][cap+1];
	ll ans=0;
	for(int i=0;i<n;i++){
		for(int ws=0;ws<=cap;ws++){
			if(i==0){
				if(ws==w[i]) dp[i][ws] = v[i];
				else dp[i][ws] = 0;
				ans = max(ans,dp[i][ws]);
				continue;
			}
			bool condn = ws>=w[i];
			if(ws==w[i]) dp[i][ws] = v[i];
			else dp[i][ws] = 0;
			ll kk = max(dp[i-1][ws],condn?(dp[i-1][ws-w[i]]+v[i]):0);
			dp[i][ws] = max(dp[i][ws],kk);
			ans = max(dp[i][ws],ans);
		}
	}
	return ans;
}
int main(){
	ll n,cap;
	cin>>n>>cap;
	vector<ll> v(n);
	vector<ll> w(n);
	for(int i=0;i<n;i++) cin>>w[i]>>v[i];
	cout<<solnD(n,cap,w,v)<<endl;
}


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

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader input =new BufferedReader (new InputStreamReader (System.in));
		String str = input.readLine( );
		int s = Integer.parseInt(str);
		int answer = 0;

		for(int i=s; i>0; i--){
			answer = answer + i;
		}

		System.out.println(answer);
	}

}


Measured memory_bytes: 8276
#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>

using namespace std;

int main(){
    int N; cin >> N;
    vector<int> A(N);
    int max_A = 0;
    for(int i=0;i<N;i++){
        cin >> A[i];
        max_A = max(max_A, A[i]);
    }
    sort(A.begin(), A.end());
    int m = ( max_A%2==0 ? max_A/2 : (max_A+1)/2);
    int dist = 2e9;

    int j = 0;
    for(int i=0;A[i]<max_A;i++){
        if(dist > abs(m - A[i])){
            j = i;
            dist = abs(m - A[i]);
        }
    }
    cout << max_A << " " << A[j] << endl;
    return 0;
}

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

using namespace std;

const int MOD= 1e9+7;
const int N=1e3+1;
int dp[N][N];

int main(){
int H,W;
cin>>H>>W;

char grid[H][W];
for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            cin>>grid[i][j];
        }
}

bool flag=true;
for(int i=0;i<W;i++){
 if(grid[0][i]=='#')flag=false;
 if(flag){
    dp[0][i]=1;
 }else{
  dp[0][i]=0;
 }
}

flag=true;
for(int i=0;i<H;i++){
 if(grid[i][0]=='#')flag=false;
 if(flag){
    dp[i][0]=1;
 }else{
    dp[i][0]=0;
 }
}

for(int i=1;i<H;i++){
    for(int j=1;j<W;j++){
        if(grid[i][j]!='#'){
            dp[i][j]=(dp[i-1][j]%MOD+dp[i][j-1]%MOD)%MOD;
        }else{
           dp[i][j]=0;
        }
    }
}

cout<<dp[H-1][W-1]<<endl;
/*
for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
        cout<<dp[i][j]<<" ";
    }
    cout<<endl;
}
*/


return 0;
}


Measured memory_bytes: 5120
package main

import (
  "bufio"
  "os"
  "strconv"
  "strings"
  "fmt"
)

var reader = bufio.NewReaderSize(os.Stdin, 1000000)
var writer = bufio.NewWriter(os.Stdout)
func NextLine() string {
  var line, buffer []byte
  var isPrefix bool = true
  var err error
  for isPrefix {
    line, isPrefix, err = reader.ReadLine()
    if err != nil { panic(err) }
    buffer = append(buffer, line...)
  }
  return string(buffer)
}
func NextInt() int {
  var n int
  n, _ = strconv.Atoi(NextLine())
  return n
}
func Write(s interface{}) {
  fmt.Fprintln(writer, s)
}
func WriteIntVec(A []int) {
  S := make([]string, len(A))
  for i, a := range A {
    S[i] = strconv.Itoa(a)
  }
  Write(strings.Join(S, " "))
}
func Output() {
  _ = writer.Flush()
}

func main() {
  N := NextInt()
  P := make([][]int, N - 1)
  for i := range P {
    P[i] = make([]int, N - 1 - i)
    for j := range P[i] {
      n := (i + 1) ^ (N - j)
      b := 1
      for ; n > 0; b++ {
        if n % 2 > 0 { break }
        n /= 2
      }
      P[i][N - 2 - i - j] = b
    }
    WriteIntVec(P[i])
  }
  Output()
}

Measured memory_bytes: 3968
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<set>

using namespace std;


int main(){

    int k,s;
    cin >> k >> s;
    int ans = 0;
    for(int i=0;i<=k;i++){
        for(int j=0;j<=k;j++){
            int z = s-i-j;
            if(i+j+z == s && z<=k && 0<=z) ans++;
        }
    }
    cout << ans <<endl;
}


Measured memory_bytes: 256
# from math import factorial,sqrt,ceil
# from itertools import permutations as permus
# from fractions import gcd
# from collections import deque,Counter
# from decimal import Decimal, getcontext
# # getcontext().prec = 1000
# # eps = Decimal(10) ** (-100)

# import numpy as np
# from scipy.sparse.csgraph import shortest_path, dijkstra, floyd_warshall, bellman_ford, johnson
# from scipy.sparse import csr_matrix

# strlist = "abcdefghijklmnopqrstuvwxyz"
N,A,B = map(int,input().split())
S = input()

AplusB = A+B

ans = []
for i in range(len(S)):
    if S[i]=="a" and AplusB>0:
        ans.append("Yes")
        AplusB -= 1
    elif S[i]=="b" and AplusB>0 and B>0:
        ans.append("Yes")
        AplusB -= 1
        B -= 1
    else:
        ans.append("No")

print(*ans,sep="\n")
# print(*ans)   # unpackして出力。間にスペースが入る
# for row in board:
#     print(*row,sep="")    #unpackして間にスペース入れずに出力する
# print("{:.10f}".format(ans))
# print("{:0=10d}".format(ans))


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

int W[110];

int N;
int main (){
    cin >> N;
    for(int i=1; i<=N; i++) cin >> W[i];

    int ans = 9999999;
    for(int i=1; i<N; i++) {
        int suma = 0;
        int sumb = 0;
        for(int j=1; j<= N; j++) {
            if(j <= i) suma += W[j];
            else sumb += W[j];
        }
        ans = min(abs(suma - sumb), ans);
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
typedef long long ll;
int main() {
    // ifstream in("data1.txt");
    // cin.rdbuf(in.rdbuf());
    int N = 6;
    vector<int> v(N);
    rep(i, N) cin >> v[i];
    string s = "Yay!";
    for(int i = 0; i < N; i++){
        for(int j = 0 + i; j < N; j++){
            if(v[5] < (v[j] - v[i])){
                s = ":(";
            }
        }
    }

    cout << s << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>

using namespace std;

int main()
{
	int n;
	long long int s[200001], a;
	s[0]=0;
	scanf("%d", &n);
	for(int i=1; i<=n; i++){
		scanf("%lld", &a);
		s[i]=s[i-1]+a;
	}
	sort(s, s+n+1);
	long long int i1, i2;
	long long int x, ans=0;
	for(int i=0; i<=n; i++){
		if(i==0){
			i1=0;
			i2=0;
			x=s[0];
		}else if(x==s[i]){
			i2++;
		}else{
			ans=ans+(i2-i1+1)*(i2-i1)/2;
			x=s[i];
			i1=i;
			i2=i;
		}
	}
	ans=ans+(i2-i1+1)*(i2-i1)/2;
	printf("%lld\n", ans);

	return 0;
}

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

using namespace std;

#ifdef DEBUG_MODE
	#define DBG(n) n;
#else
	#define DBG(n) ;
#endif
#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define rep(i,s,g) for(ll (i) = (s);(i) < (g);++i)
#define rrep(i,s,g) for(ll (i) = (s);i >= (g);--(i))
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {for(int W = 0;W < (n);W++)cerr << v[W] << ' ';cerr << endl << endl;}
#define SHOW2d(v,i,j) {for(int aaa = 0;aaa < i;aaa++){for(int bbb = 0;bbb < j;bbb++)cerr << v[aaa][bbb] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define MOD 1000000007
#define EPS 1e-7

typedef long long ll;
typedef pair<ll,ll> P;
double high[66];
int n,r;

bool check(double mid){
	for(int i = 30-r;i < 30+r;i++){
		DBG(cerr << "hidh " << i << ' ' << high[i] << ' ' << high[i+1] << endl;)
		if(i != 30-r && i != 30+r && high[i] < mid)return false;
		double A = sqrt((i-30)*(i-30) + (high[i]-mid)*(high[i]-mid));
		double B = sqrt((i-29)*(i-29) + (high[i]-mid)*(high[i]-mid));
		DBG(cerr << "AB " <<  A << ' ' << B << endl;)
		if(min(A,B) < r + EPS)return false;
	}
	return true;
}

int main(){
	while(cin >> r >> n,r|n){
		//初期
		REP(i,66)high[i] = 0;
		
		
		REP(i,n){
			int a,b;
			double c;
			cin >> a >> b >> c;
			for(int j = a;j < b;j++){
				high[j+30] = max(high[j+30],c);
			}
		}
		
		double tb = 100;
		double ub = -100;
		DBG(SHOW1d(high,66));
		REP(i,1000){
			double mid = (tb + ub) / 2;
			DBG(cerr << endl << "mid " << mid << endl << endl;)
			if(check(mid))ub = mid;
			else tb = mid;
		}
		
		cout << Decimal << (double)(ub+r) << endl;
	}
	return 0;
}


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

int main() {
	ios_base::sync_with_stdio(false);

	int n, p;
	cin >> n >> p;
	vector <int> digits;
	digits.resize(n);
	for (int i = 0; i < n; ++i) {
		char c;
		cin >> c;
		digits[i] = c - '0';
	}
	long long ans = 0;
	if (p == 2 || p == 5) {
		for (int i = 0; i < n; ++i) {
			if (digits[i] % p == 0) {
				ans += i + 1;
			}
		}
	}
	else {
		long long r = 0;
		long long r10 = 1;
		map <int, int> m;
		for (int i = n - 1; i >= 0; --i) {
			long long tmp = digits[i] % p;
			r10 *= 10;
			r10 %= p;
			tmp = (tmp * r10) % p;
			r = (r + tmp) % p;
			ans += m[r];
			if (r == 0) {
				ans++;
			}
			m[r]++;
		}
	}

	cout << ans << endl;
}

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

using namespace std;
using ll = long long;

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

    int n;
    cin >> n;
    vector<int> x(n);
    for(int i = 0; i < n; ++i) cin >> x.at(i);

    int mean = 0;
    for(int xi: x) mean += xi;
    mean /= n;
    
    int ans1 = 0, ans2 = 0;
    for(int xi: x) ans1 += (xi - mean) * (xi - mean);
    for(int xi: x) ans2 += (xi - mean - 1) * (xi - mean - 1);

    printf("%d\n", ans1 < ans2 ? ans1 : ans2);

    return 0;
}

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

long int n;
long int a[200000] = {0};

int main(void)
{
	long int i, j, k, l, m, n;
	long int count = 0;
	long int num = 1;
	
	scanf("%ld", &n);
	
	for(i = 0; i < n; i++) {
		scanf("%ld", &a[i]);
		if(a[i] == num) {
			num++;
		} else {
			count++;
		}
	}
	
	if(n == count) {
		printf("-1\n");
	} else {
		printf("%ld\n", count);
	}
	
	return 0;
}

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

int main(){
  int x, y;
  cin >> x >> y;
  if(x==2){
    if(y==2) cout << "Yes" << endl;
    else cout << "No" << endl;
    }
  else if(x==4 || x==6 || x==9 || x==11){
    if(y==4 || y==6 || y==9 || y==11) cout << "Yes" << endl;
    else cout << "No" << endl;
  }
  else{
    if(y==1 || y==3 || y==5 || y==7 || y==8 || y==10 || y==12) cout <<"Yes" << endl;
    else cout << "No" << endl;
  }
}

Measured memory_bytes: 256
A, B, C, X, Y = map(int, input().split())

# Cを購入する数をiとして、その時の最小値を求める
ans = 10 ** 9
for i in range(max(X + 1, Y + 1)):
    amount = C * 2 * i + A * max(X - i, 0) + B * max(Y - i, 0)
    ans = min(ans, amount)

print(ans)

Measured memory_bytes: 3060
#include <iostream>
#include <math.h>
#include <algorithm>
#include <functional> 
#include <string>
#include <vector>

#include <cstring>
#include <set>
#include <map>
#include <queue>
#include <utility>
#include <limits.h>

using namespace std;

typedef long long LL;

#define rep(i,n) for (int i = 0; i < (n); ++i)
#define dump(c) { for (auto it = c.begin(); it != c.end(); ++it) if (it == c.begin()) cout << *it; else cout << ' ' << *it; cout << endl; } 
#define dumpMap(m) { for (auto it: m) cout << it.first << "=>" << it.second << ' '; }

const int MOD = 1000000007;

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

    vector<int> w(N);
    vector<int> v(N);

    int sumV = 0;
    for (int i = 0; i < N; ++i) {
        cin >> w[i] >> v[i];
        sumV += v[i];
    }

    vector<LL> dp(sumV+1, W+1);
    dp[0] = 0;

    for (int i = 0; i < N; ++i) { //! checking up to i-th item (where i is in 1..N range)
        for (LL val = sumV; 0 <= val - v[i]; --val) {
            if (dp[val-v[i]] + w[i] < dp[val]) {
                dp[val] = dp[val-v[i]] + w[i];
            }
        }
    }

    int ans = 0;
    for (int j = 0; j <= sumV; ++j) {  //! value to get
        if (dp[j] <= W) {
            ans = max(ans, j);
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 1024
N,M=map(int,input().split())
LR=[list(map(int, input().split())) for _ in range(M)]
left=0
right=N+1
ans=0
for i in range(M):
	left=max(left,LR[i][0])
	right=min(right,LR[i][1])
ans=right-left+1
if ans<0:
	print(0)
else:
	print(ans)

Measured memory_bytes: 29380
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))

ans = 0
for i in range(n-1):
    ans += b[a[i]-1]
    if a[i]+1 == a[i+1]:
        ans += c[a[i]-1]
ans += b[a[-1]-1]

print(ans)

Measured memory_bytes: 38256
#include <stdio.h>
#include <math.h>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <cstring>
#include <string>
#include <sstream>
#include <algorithm>
#include <iomanip>
#include <iostream>

#define VARIABLE(x) cerr << #x << "=" << x << endl
#define BINARY(x) cerr << #x << "=" << static_cast<bitset<16> >(x) << endl;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define REP(i,m,n) for (int i=m;i<(int)(n);i++)
#define if_range(x, y, w, h) if (0<=(int)(x) && (int)(x)<(int)(w) && 0<=(int)(y) && (int)(y)<(int)(h))

const int INF = 10000000;
typedef double D;
const D EPS = 1e-8;
const double PI = 3.14159;
int dx[4]={-1, 0, 1, 0}, dy[4]={0, -1, 0, 1};
using namespace std;
typedef pair<int, int> II;

/** Problem0090 : Overlaps of Seals **/

struct  P {
	D x, y;
	P() {}
	P(D x_, D y_) : x(x_), y(y_) {}
};

struct  C {
	P p; D r;
	C(){}
	C(P p_, D r_) : p(p_), r(r_) {}
};

P operator +(P a, P b) { return P(a.x + b.x, a.y + b.y); }
P operator -(P a, P b) { return P(a.x - b.x, a.y - b.y); }
P operator *(P a, D b) { return P(a.x * b, a.y * b); }
P operator /(P a, D b) { return P(a.x / b, a.y / b); }
P vec(P from, P to) { return to - from; }
D inp(P a, P b) { return a.x*b.x + a.y*b.y; }
D outp(P a, P b) { return a.x*b.y - a.y*b.x; }
D norm(P p) { return inp(p, p); }
D abs(P p) { return sqrt(norm(p)); }
int sig(D a, D b) {
	if(a < b - EPS) return -1;
	if(a > b + EPS) return +1;
	return 0;
}
P rot90(P p) { return P(-p.y, p.x);}
// NaN
vector<P> cCC(C a, C b) {
	D d = abs(b.p - a.p);
	D x = (d*d + a.r*a.r - b.r*b.r) / (2*d);
	D y = sqrt(a.r*a.r - x*x);
	P v = (b.p - a.p) / d;
	vector<P> res;
	res.push_back(a.p + v*x + rot90(v)*y);
	res.push_back(a.p + v*x - rot90(v)*y);
	return res;
}

int main()
{
	int N;
	while (cin>>N, N) {
		vector<P> points;
		rep(k, N) {
			P p; char c;
			cin >>p.x>>c>>p.y;
			points.push_back(p);
		}
		
		int ans=1;
		rep(i, N) {
			P p1 = points[i];
			rep(j, N) {
				if (i!=j) {
					P p2 = points[j];
					if (sig(abs(p2-p1), 2.0) <= 0) {
						P ip1 = cCC(C(p1, 1), C(p2, 1))[0];
						P ip2 = cCC(C(p1, 1), C(p2, 1))[1];
						
						int tmp1=2, tmp2=2;
						rep(k, N) {
							if (k!=i && k!=j) {
								P p = points[k];
								if (sig(abs(p-ip1), 1.0) <= 0) {
									tmp1++;
								} if (sig(abs(p-ip2), 1.0) <= 0) {
									tmp2++;
								}
							}
						}
						ans = max(max(ans, tmp1), tmp2);
					}
				}
			}
		}
		cout << ans << endl;
	}
}

Measured memory_bytes: 1244
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long ll;
typedef pair<ll,ll> P;
const ll mod=1000000007;
const ll LINF=1LL<<60;
const int INF=1<<30;

int main(){
	ll n,c;cin>>n>>c;

	vector<ll> xr(n + 2,0LL);
	vector<ll> xl(n + 2,0LL);
	vector<ll> vr(n + 2,0LL);
	vector<ll> vl(n + 2,0LL);
	vector<ll> sumr(n + 2,0LL);
	vector<ll> suml(n + 2,0LL);
	for(int i = 1; i <= n; i++) {
		cin>>xr[i]>>vr[i];
		vl[n - i + 1] = vr[i];
		xl[n - i + 1] = (c - xr[i]);
		sumr[i] = sumr[i - 1] + vr[i];
	}

	for(int i = 1; i <= n; i++) {
		suml[i] = suml[i - 1] + vl[i];
	}

	

	vector<ll> cr(n + 2,0LL);
	for(int i = n; i >= 1; i--) {
		cr[i] = max(cr[i + 1] ,sumr[n] - sumr[i] - (c - xr[i + 1]));
	}

	vector<ll> cl(n + 2,0LL);
	for(int i = n; i >= 1; i--) {
		cl[i] = max(cl[i + 1],suml[n] - suml[i] - (c - xl[i + 1]));
	}

	// for(int i = 1; i <= n; i++) {
	// 	cout << xl[i] << " " << vl[i] <<" " << cl[i] << endl;
	// }



	ll ans = 0LL;
	for(int i = 1; i <= n; i++) {
		ll tmp1 = sumr[i] - xr[i];
		ans = max(ans,tmp1);
		ll tmp2 = suml[i] - xl[i];
		ans = max(ans,tmp2);
		ll tmp3 = sumr[i] - 2 * xr[i] + cr[i]; 
		ans = max(ans,tmp3);
		ll tmp4 = suml[i] - 2 * xl[i] + cl[i]; 
		ans = max(ans,tmp4);
	}
	cout << ans << endl;



	return 0;
}

Measured memory_bytes: 6528
// #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>

#define FOR(i, a, b) for (int i = (a); i < int(b); ++i)
#define RFOR(i, a, b) for (int i = (b)-1; i >= int(a); --i)
#define REP(i, n) FOR(i, 0, n)
#define REP1(i, n) FOR(i, 1, int(n) + 1)
#define RREP(i, n) RFOR(i, 0, n)
#define RREP1(i, n) RFOR(i, 1, int(n) + 1)
#define ALL(c) begin(c), end(c)

int _ = (
#ifndef LOCAL
    std::cin.tie(nullptr), std::ios::sync_with_stdio(false),
#endif
    std::cout.precision(10), std::cout.setf(std::ios::fixed));

using ll = long long;
using ull = unsigned long long;
using ld = long double;
template <typename T> using vec = std::vector<T>;
using namespace std;

int main() {
  ull N;
  cin >> N;

  constexpr ull M = 1000000007;
  ull answer = 1;
  REP1(i, N) {
    answer *= i;
    answer %= M;
  }
  cout << answer << endl;
  return 0;
}


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

#define F first
#define S second
#define MP make_pair
#define pb push_back
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define LCM(a, b) (a) / __gcd((a), (b)) * (b)
#define CEIL(a, b) (a)/(b)+(((a)%(b))?1:0)
#define ln '\n'

using namespace std;
using LL = long long;
using ldouble = long double;
using P = pair<int, int>;
using LP = pair<LL, LL>;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1e9 + 7;
static const int SIZE = 200005;

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

vector<LL> Div(LL n) {
    vector<LL> ret;
    for(LL i = 1; i * i <= n; ++i) {
        if(n % i == 0) {
            ret.pb(i);
            if(i * i != n) ret.pb(n / i);
        }
    }
    sort(all(ret));
    return ret;
}

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

    int a, b, c, d, e, f;
    cin >> a >> b >> c >> d >> e >> f;
    double mx = 0.0;
    int resa = 100 * a, resb = 0;

    for(int i = 0; i <= f; i += 100 * a) {
        for(int j = 0; i + j <= f; j += 100 * b) {
            if(i == 0 && j == 0) continue;
            for(int k = 0; k + i + j <= f; k += c) {
                for(int l = 0; l + k + i + j <= f; l += d) {
                    int wa = i + j;
                    double su = k + l;
                    double mxsu = double(wa) / 100.0 * e;
                    if(su > mxsu) continue;
                    if(mx < (100 * su) / (wa + su)) {
                        mx = (100 * su) / (wa + su);
                        resa = wa + su;
                        resb = su;
                    }
                }
            }
        }
    }
    cout << resa << " " << resb << endl;
    return 0;
}



Measured memory_bytes: 256