akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
const int maxn=3e5;
int a[maxn+5],b[maxn+5],c[maxn+5],d[maxn+5];
int n,m,q,x,y;
int main()
{

    ios::sync_with_stdio(false);
    cin.tie(0);
    cin>>x>>y>>n>>m>>q;
    for(int i=1;i<=n;++i) cin>>a[i];
    for(int i=1;i<=m;++i) cin>>b[i];
    for(int i=1;i<=q;++i) cin>>c[i];
    sort(a+1,a+n+1);reverse(a+1,a+n+1);
    sort(b+1,b+m+1);reverse(b+1,b+m+1);
    for(int i=1;i<=x;++i) d[i]=a[i];
    for(int i=1;i<=y;++i) d[i+x]=b[i];
    sort(d+1,d+x+y+1);
    long long ans=0;
    for(int i=1;i<=x+y;++i) ans+=d[i];
    sort(c+1,c+q+1);reverse(c+1,c+q+1);
    int now=1;
    for(int i=1;i<=q&&now<=x+y;++i,++now)
        if(d[now]<c[i]) ans+=c[i]-d[now];
        else break;
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3456
using System;
using System.Linq;
using System.Collections.Generic;

namespace AtCoder
{
    class Program
    {
        public static void Main(string[] args)
        {
            int s = int.Parse(Console.ReadLine());
            int n = 1;
            int[] a = new int[1000001];
            for (int i = 0; i < 1000001; i++) { a[i] = 0; }
            a[s] = 1;
            while (n <= 1000000)
            {
                n++;
                s = f(s);
                if (a[s] == 1) { break; }
                a[s] = 1;
            }
            Console.WriteLine("{0}", n);
        }

        public static int f(int n)
        {
            return ((n % 2) == 0) ? n / 2 : 3 * n + 1;
        }
    }
}

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

int main(){
  int m,k;
  cin>>m>>k;
  if(m==0){
    cout<<(k==0?"0 0":"-1")<<endl;
  }
  else if(m==1){
    cout<<(k==0?"0 0 1 1":"-1")<<endl;
  }
  else{
    if(k>=(1<<m))cout<<-1<<endl;
    else{
      for(int i=0; i<(1<<m); ++i)if(i!=k)cout<<i<<" ";
      cout<<k<<" ";
      for(int i=(1<<m)-1; i>=0; --i)if(i!=k)cout<<i<<" ";
      cout<<k<<endl;
    }
  }
}

Measured memory_bytes: 3632
#include <iostream>
using namespace std;
int main()
{
   long long int h,w;
  cin>>h>>w;
    
    if(h==1 || w==1)
      cout<<1<<endl;
    else
    {
      long long int black1 = ceil(w/2);
  
    long long int cnt1 = ceil(h/2);
  
   cout<<(black1)*(cnt1) + (w-black1)*(h-cnt1)<<endl; 
    }
    
}

Measured memory_bytes: 3120
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
constexpr Int MOD = 1e9 + 7;
int main()
{
    Int N; cin >> N;
    for (Int h = 1; h <= 3500; h++) {
        for (Int n = 1; n <= 3500; n++) {
            Int x = N*n*h;
            Int y = 4*h*n - N*n - N*h;
            if (y > 0 && x % y == 0) {
                Int w = x/y;
                cout << h << ' ' << n << ' ' << w << endl;
                return 0;
            }
        }
    }
    return 0;
}


Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))
s = sum(A)
q, m = divmod(s, N*(N+1)//2)
if m != 0:
    print("NO")
    exit()
D = [A[i]-A[i-1]-q for i in range(N)]
for d in D:
    if d > 0 or d%N != 0:
        print("NO")
        exit()
print("YES")


Measured memory_bytes: 14588
#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <cstdio>

#define rep(i, n) for(int i = 0; i < (n); i++)
#define MP make_pair
#define X first
#define Y second

using namespace std;

typedef vector<int> vi;
typedef long long ll;
typedef pair<int, int> P;

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

struct edge{
	int to;
	double dist;
	int c;
	edge(int t, double d, int c_){to = t, dist = d, c = c_;}
};

struct state{
	int pos;
	double total;
	int speed;
	int prev;
	state(int p, double t, int s, int pr){pos = p, total = t, speed = s, prev = pr;}
	bool operator<(const state &r)const{
		return total > r.total;
	}
};

const double INF = 1e30;

int main(){
	//freopen("test.txt", "r", stdin);
	int n, m;
	while(cin >> n >> m, n|m){
		int s, g;
		cin >> s >> g;
		s--, g--;
		vector<vector<edge> > G(n);
		rep(i, m){
			int x, y, d, c;
			cin >> x >> y >> d >> c;
			x--, y--;
			G[x].push_back(edge(y, d, c));
			G[y].push_back(edge(x, d, c));
		}

		priority_queue<state> q;
		q.push(state(s, 0, 0, s));

		vector<vector<vi> > visit(31, vector<vi>(n, vi(n, 0))); //speed, pos, prev

		double ans = INF;
		while(!q.empty()){
			state st = q.top();
			q.pop();

			if(visit[st.speed][st.pos][st.prev]) continue;
			visit[st.speed][st.pos][st.prev] = 1;

			if(st.speed == 1 && st.pos == g){
				ans = st.total;
				break;
			}

			rep(i, G[st.pos].size()){
				if(st.prev == G[st.pos][i].to) continue;
				for(int j = -1; j <= 1; j++){
					state next = st;
					next.speed += j;
					if(next.speed <= 0 || next.speed > G[st.pos][i].c) continue;
					next.pos = G[st.pos][i].to;
					next.prev = st.pos;
					next.total += G[st.pos][i].dist/next.speed;
					q.push(next);
				}
			}
		}

		if(ans == INF) cout << "unreachable" << endl;
		else printf("%.8lf\n", ans);
	}


	return 0;
}

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

int main() {
  long long a,b,c;
  long long tmpA,tmpB,tmpC;
  int cnt = 0;
  
  cin >> a >> b >> c;
  
  // 奇数
  if(a % 2 == 1 || b % 2 == 1 || c % 2 == 1){
    cout << 0;
    return 0;
  }
  // 同値
  if(a == b && b == c){
    cout << -1;
    return 0;
  }
  
  for(int i = 0; i <= 1000; i++){
    if(a % 2 == 1 || b % 2 == 1 || c % 2 == 1){
      cout << cnt;
      break;
    }
    
    tmpA = a;
    tmpB = b;
    tmpC = c;
    a = (tmpB + tmpC) / 2;
    b = (tmpA + tmpC) / 2;
    c = (tmpA + tmpB) / 2;
    
    cnt++;
  }
}


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

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

int main() {
    int n;
    cin >> n;
    cout << n * n * n << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define forloop(n) for(int i = 0; i < n; i++)
#define ll long long
/*ll sum(vector<ll> vec, int left, int right){
	if(right == left){
		return vec[0];
	}
	return vec[right] + sum(vec, left, right-1);
}*/
int main(){
	int n, m, k; cin>>n>>m>>k;
	vector<vector<char>> vec;
	for(int i = 0; i < n ;i++){
		vector<char> temp(m);
		for(int j = 0; j < m; j++){
			cin>>temp[j];
		}
		vec.push_back(temp);
	}
	vector<vector<int>> res(n);
	int sayi = 1;
	int check = 0;
	for(int i = 0; i < n; i++){
		int count = 0;
		for(int j = 0; j < m; j++){
			if(vec[i][j] == '#'){
				count++;
				if(count > 1){
					sayi++;
				}
			}
			res[i].push_back(sayi);
		}
		if(count > 0){
			check++;
		}else{
			sayi--;
		}
		if(check == 1 && sayi >= 1){
			for(int k = i-1; k >= 0; k--){
				for(int j = 0; j < m; j++){
					res[k][j] = res[k+1][j];
				}
			}
			check++;
			//count++;
			sayi++;
			continue;
		}
		if(count == 0 && check >= 1){
			for(int j = 0; j < m; j++){
				res[i][j] = res[i-1][j];
			}
		}
		sayi++;
	}
	for(int i = 0; i < n; i++){
		for(int j = 0; j < m; j++){
			cout<<res[i][j]<<" ";
		}
		if(i < n-1) cout<<endl;
	}
	return 0;
}

Measured memory_bytes: 1536
#include <bits/stdc++.h>
using namespace std;
int main(){
	int a, b;
	cin>>a>>b;
	int last = 0;
	for(int i = 1; i <= 999; ++i){
		int tower = 0;
		for(int j = 1; j <= i; ++j){
			tower += j;
		}
		if(tower - last == b - a && tower - b == last - a){
			cout<<tower - b<<endl;
			return 0;
		}
		last = tower;
	} 
	return 0;
}


Measured memory_bytes: 256
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
/*
//#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
*/

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
/*
//#if __cplusplus >= 201103L
#include <array>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
*/
using namespace std;
#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define mp(a,b) make_pair(a,b)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl

#define uni(x) x.erase(unique(all(x)),x.end())
template<class T,class U>inline void chmin(T &t,U f){if(t>f)t=f;}
template<class T,class U>inline void chmax(T &t,U f){if(t<f)t=f;}
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) > (b) ? (b) : (a))

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> P;
typedef pair<P, int> PPI;

#define INF INT_MAX/3
#define MAX_N 1000
#define M_INF 1000000000
ll n,m,v,i;
void solve(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  std::vector<P> v(4);
  
  cin>>v[0].fi>>v[1].fi>>v[2].fi>>v[3].fi;
  cin>>n;

  cout<<(n/2)*min(8*v[0].fi,min(4*v[1].fi,min(2 * v[2].fi,v[3].fi))) + (n%2)*min(4*v[0].fi,min(2 * v[1].fi,v[2].fi))<<endl;
}

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


Measured memory_bytes: 256
#!/usr/bin/env python
import sys
sys.setrecursionlimit(10**9)
from collections import deque,defaultdict
import heapq
from itertools import combinations
import bisect
from decimal import Decimal


a,b=map(str,input().split())
b=Decimal(b)
a=int(a)
p=list(str(a*b))
ans=''
for i in p:
    if i=='.':
        break
    ans+=i
print(ans)


Measured memory_bytes: 10060
/*
    CP Submission
*/

#include<bits/stdc++.h>

using namespace std;

/* Shortcuts */
#define mp make_pair
#define pb push_back
#define all(x) x.begin(), x.end()
#define val(x) cout << #x << ": " << (x) << endl;
#define log(x) cout << (x) << endl;
#define sz(x) (int)(x.size())

/* typedefs */
typedef long long ll;
typedef pair<int,int> ii;
typedef pair<string,int> si;
typedef pair<int,ii> iii;
typedef vector <si> vsi;
typedef vector <ii> vii;
typedef vector <int> vi;
typedef vector <vi> vvi;
typedef vector <char> vc;
typedef vector <string> vs;
typedef map <string,vs> msvs;
typedef map <string,int> msi;
typedef map <string,string> mss;

string doOp(string s){
    char tmp = s[s.length() - 1];
    s.erase(s.begin() + s.length() - 1);

    s.insert(s.begin(), tmp);

    return s;

}

int main(){

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    string s, t;
    cin>>s>>t;

    for(int i = 0; i <= s.length(); i++){
        if(s == t){
            log("Yes");
            return 0;
        }
        s = doOp(s);
    }
    log("No");

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=2e5+5;
int n,m,ans=0,father[N],sum[N];
int Findfather(int x){
    return father[x]==x?x:father[x]=Findfather(father[x]);
}

void Union(int x,int y){
    x=Findfather(x),y=Findfather(y);
    if(x!=y) father[y]=x,sum[x]+=sum[y];
}

void init(){
    for(int i=0;i<=n;i++)
        father[i]=i,sum[i]=1;
}

int main(){
    cin>>n>>m;
    init();
    while(m--){
        int u,v;
        cin>>u>>v;
        Union(u,v);
    }
    for(int i=1;i<=n;i++) if(Findfather(i)==i) ans=max(ans,sum[i]);
    cout<<ans;
}


Measured memory_bytes: 5392
#include <bits/stdc++.h>
using namespace std;
#define idfc ios_base::sync_with_stdio(false),cin.tie(nullptr),cout.tie(nullptr)
#define ll long long
#define pb emplace_back
#define mp make_pair
#define nt _int128
#define ld long double
long double PI =3.14159265358979323846;


const ll modo=2147483647;
const ll inf=1e16;
const ll ms=(500000) +5;

//int bit[26][ms]={0};
int ar[ms];

set<int> ss[26];

int main()
{
    int n;
    cin>>n;
    int i;
    char e;
    for(i=1;i<=n;i++)
    {
        cin>>e;
        ar[i]=e-97;
        ss[ar[i]].insert(i);
    }
    int q;
    cin>>q;
    int ty;
    int p; int t;
    int l,r;int ans=0;
    while (q--)
    {
        cin>>ty;
        if(ty==1)
        {
            cin>>i;
            cin>>e;
            p=ar[i];
            t=e-97;
            ss[p].erase(i);
            ss[t].insert(i);
            ar[i]=t;
        }
        else{
            cin>>l>>r;
            ans=0;
            for(i=0;i<26;i++)
            {
                auto it=ss[i].lower_bound(l);
                if(it!=ss[i].end()&&(*it)<=r)ans++;
            }
            cout<<ans<<"\n";
        }
    }
}


Measured memory_bytes: 25728
#python ABC_130_B.py

line1 = list(map(int, input().split(" ")))
L = list(map(int, input().split(" ")))

N = line1[0]
X = line1[1]

D = 0
count = 1

for i in range(N):
	D = D + L[i]
	if D<=X:
		count = count + 1

print(count)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
using namespace std;
using namespace __gnu_pbds;
using ll = long long;
using _TYPE = int;
typedef tree< _TYPE, null_type, less< _TYPE >, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
#define IO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)

int main() {
    IO;
    string  s, t;
    cin >> s >> t;
    int ans = 0;
    for(int i = 0; i < (int) s.size(); i++) {
        ans += (s[i] != t[i]);
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 3836
import sys
def input(): return sys.stdin.readline().rstrip()
def main():
    s=input()
    if len(s)==26:
        for i in range(25,0,-1):
            if s[i]<s[i-1]:
                continue
            else:
                sx=s[i-1]
                for j in range(1,25):
                    sy=chr(ord(sx)+j)
                    if sy in s[i:]:
                        print(s[:i-1]+sy)
                        sys.exit()
        else:
            print(-1)
    else:
        for i in range(26):
            if chr(ord('a')+i) in s:
                continue
            print(s+chr(ord('a')+i))
            break

if __name__=='__main__':
    main()

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define FORR(i,a,b) for (int i=(a);i>=(b);i--)
#define pb push_back
#define pcnt __builtin_popcount
#define show(x) cout<<#x<<" = "<<x<<endl;
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define fi first
#define se second
#define rng(a) (a.begin()),(a.end())
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define sz(x) (int)(x).size()
#define mp make_pair

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
typedef set<int> si;
typedef pair<ll,ll> pll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<pll> vpll;
typedef set<ll> sl;
typedef __int128_t lll;
typedef pair<lll,lll> plll;
typedef vector<lll> vlll;
template<typename T>string join(vector<T>&v)
{stringstream s;FOR(i,0,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename A, size_t N, typename T>void Fill(A (&array)[N], const T&v)
{fill((T*)array,(T*)(array+N),v);}
ll gcd(ll a,ll b){if(a>b)swap(a,b);for(;a>0;b%=a,swap(a,b));return b;}
int modpow(ll a,ll n,int m){if(a==0)return a;ll p=1;for(;n>0;n/=2,a=a*a%m)if(n&1)p=p*a%m;return(int)p;}
void dout(double d){printf("%.12f\n",d);}

const int iinf = 1e9;
const ll linf = 1e18;
const int mod = 1e9+7;
const double pi = acos(-1);
const double eps = 1e-10;
bool p[2005][2005];
int m[2005][2005];
vector<string> s;
int h, w, ans = 0;
main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> h >> w;
  s.resize(h);
  FOR(i, 0, h) cin >> s[i];
  FOR(i, 1, h) FOR(j, 1, w) p[i][j] = (s[i][j]==s[i][j-1]&&s[i-1][j]!=s[i-1][j-1] || s[i][j]!=s[i][j-1]&&s[i-1][j]==s[i-1][j-1]);
  FOR(j, 0, w) m[0][j] = 1;
  FOR(i, 1, h) FOR(j, 0, w) m[i][j] = (p[i][j] ? 1 : m[i-1][j]+1);
  FOR(i, 0, h){
    stack<pii> st;
    st.push(mp(-1, 0));
    FOR(j, 0, w+1){
      pii t = st.top();
      int idx = j;
      while(t.se > m[i][j]){
        maxs(ans, (j-t.fi)*t.se);
        idx = t.fi;
        st.pop();
        t = st.top();
      }
      st.push(mp(idx, m[i][j]));
      st.push(mp(j, i+1));
    }
  }
  cout << ans << endl;
  return 0;
}

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

#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define repn(i, n) for(int (i) = 1; (i) <= (n); (i)++)
#define repr(i, n) for(int (i) = (n-1); (i) >= 0; (i)--)
#define all(x) (x).begin(), (x).end()
#define lint long long
#define ulint unsigned long long
#define fi first
#define se second
#define setpre(x) cout << fixed << setprecision(x)
#define ii(x) int x; cin >> (x)
#define ii2(x, y) int x, y; cin >> (x) >> (y)
#define ii3(x, y, z) int x, y, z; cin >> (x) >> (y) >> (z)
#define out(x) cout << (x) << endl
#define yn(x) cout << ((x)?("Yes"):("No")) << endl
#define YN(x) cout << ((x)?("YES"):("NO")) << endl
#define bit_c(x) __builtin_popcountll(x)

inline void logger(){ cout << endl; }
template<typename A, typename... B>
void logger(const A& a, const B&... b){
    cout << a << " , ";
    logger(b...);
}

typedef pair<lint, lint> P;
const lint MOD = 1000000007;
const lint MOD9 = 998244353;
const lint INF = MOD * MOD;
const int MAX = 200005;

/* ...o(^-^)o... */
bool ok[MAX], seen[MAX];
int dfs(int s){
    seen[s] = true; int res = 1;
    if(ok[s]) res += dfs(s + 1);
    return res;
}

int main(){
    int n; cin >> n; vector<int> vec(n), inv(n);
    rep(i, n){
        int p; cin >> p; p--;
        vec[i] = p; inv[p] = i;
    }

    rep(i, n-1){
        if(inv[i] < inv[i+1]) ok[i] = true;
    }

    int ans = 1;
    rep(i, n-1){
        if(seen[i]) continue;
        ans = max(ans, dfs(i));
    }
    out(n - ans);
}

Measured memory_bytes: 2176
#include <stdio.h>

int main(void)
{
  int N, K, Q;
  scanf("%d%d%d", &N, &K, &Q);
  int score[N];
  for(int i = 0; i < N; i++)
    score[i] = 0;
  for(int i = 0 ; i < Q; i++){
    int j;
    scanf("%d", &j);
    score[j-1]++;
  }
  for(int i = 0; i < N; i++)
    printf(Q-score[i] < K ? "Yes\n" : "No\n");
}


Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<ll>;
using vii = vector<vi>;
using Pll = pair<ll, ll>;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(v) v.begin(), v.end()
#define sz(x) ((int) x.size())
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define F first
#define S second
const int MOD = 1000000007;
template<class T> void print(const T& t){ cout << t << endl; }
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; }

int main(){
  ll k, s;
  cin >> k >> s;
  ll count = 0;
  rep(x,k+1){
    rep(y,k+1){
      if(s-x-y<=k&&s-x-y>=0){
          count++;
        }
    }
  }
  print(count);
}


Measured memory_bytes: 256
/**********************************************
 * author : deepak nayan
 * file   : e:/Solutions/atcoder/abc149_a.cpp
 * time   : Sat May  2 18:51:06 2020
 * quest  : A - Strings
 *********************************************/
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>

using namespace std;

int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  string s, t;
  cin >> s >> t;
  cout << t << s << "\n";
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;
  for(int i=0;i<n;i++){
    int a,b;
    cin>>a>>b;
    a%=b;
    if(a==0) a=b;
    cout<<a<<endl;
  }
  return 0;
}



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

void main_()
{
    ll N;
    cin >> N;
    vector<ll> As;
    As.reserve(N);
    copy_n(istream_iterator<ll>(cin), N, back_inserter(As));
    vector<ll> Bs;
    Bs.reserve(N);
    copy_n(istream_iterator<ll>(cin), N, back_inserter(Bs));
    vector<ll> Cs;
    Cs.reserve(N);
    copy_n(istream_iterator<ll>(cin), N, back_inserter(Cs));

    sort(begin(As), end(As));
    sort(begin(Bs), end(Bs));
    vector<ll> Bs_var;
    Bs_var.reserve(N);
    for (ll i = 0; i < N; i++) {
        auto it = lower_bound(begin(As), end(As), Bs[i]);
        auto var = distance(begin(As), it);
        if (i == 0) {
            Bs_var.push_back(var);
        } else {
            Bs_var.push_back(Bs_var[i - 1] + var);
        }
    }

    ll ans = 0;
    for (ll i = 0; i < N; i++) {
        auto it = lower_bound(begin(Bs), end(Bs), Cs[i]);
        if (it == begin(Bs)) {
            continue;
        }
        auto it_var = begin(Bs_var) + distance(begin(Bs), it) - 1;
        ans += *it_var;
    }

    cout << ans << endl;
}
int main()
{
    cin.tie(nullptr);
    cout.tie(nullptr);
    ios_base::sync_with_stdio(false);
    main_();
    return 0;
}


Measured memory_bytes: 3456
#include <bits/stdc++.h>
using namespace std;
 
typedef long long int lli;
 
int main ()
{
string str;
cin>>str;
 
for (lli i=0; i <4; i++) cout<<str [i ];
 
cout <<" ";
for (lli i=4; i <12; i++) cout <<str [i];
cout <<endl;
return 0;
}

Measured memory_bytes: 256
# n=int(input())
# a,b=map(int, input().split())
# c=list(map(int, input().split()))
# s=[list(map(int,list(input()))) for i in range(h)]  # 二次元配列入力　二次元マップみたいな入力のとき

# a=100
# b=0.987654321
# print('{0:06d}-{1:6f}'.format(a,b))  # 0埋めのときの出力
# 000100-0.987654

import numpy as np
import math
import copy

s = list(input())

cnt = 0

for elem in s:
    if elem == 'o':
        cnt += 1
    if cnt == 8:
        print('YES')
        exit()

if (15 - len(s)) + cnt >= 8:
    print('YES')
else:
    print('NO')

Measured memory_bytes: 21872
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstdio>

using namespace std;

struct P {
	int s, e;
	P() {};
	P(int s, int e) : s(s), e(e) {}
};
bool operator <(const P& p1, const P& p2) {
	return p1.e < p2.e;
}

int GetTime() {
	int h, m, s;
	scanf("%d:%d:%d", &h, &m, &s);
	return (h * 60 + m) * 60 + s;
}
int main() {
	int n;
	while ( cin >> n, n ) {
		vector<P> v;
		for (int i = 0; i < n; ++i) {
			int s = GetTime();
			int e = GetTime();
			v.push_back( P(s, e) );
		}
		sort( v.begin(), v.end() );

		vector<int> ans;
		for (int i = 0; i < n; ++i) {
			int pos = -1;
			int E = -1;
			for (int j = 0; j < ans.size(); ++j) {
				if (ans[j] <= v[i].s && ans[j] > E) {
					pos = j;
					E = ans[j];
				}
			}
			if (pos < 0) {
				ans.push_back(v[i].e);
			}
			else {
				ans[pos] = v[i].e;
			}
/*			vector<int>::iterator it = upper_bound(ans.begin(), ans.end(), v[i].s);
			if (it == ans.begin() || --it == ans.begin() ) {
				ans.push_back(v[i].e);
			}
			else {
				*it = v[i].e;
			}
*/
		}
		cout << ans.size() << endl;
	}
}

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

vector<int>v;
int dp[100005];
int inf=1000000;
int calculate(int i,int n)
{
    if(i==n-1) return 0;
    if(i>n-1) return inf;
    if(dp[i]!=-1) return dp[i];
    int first=0,second=inf;
    first=calculate(i+1,n)+abs(v[i]-v[i+1]);
    if(i+2<n)
    {
        second=calculate(i+2,n)+abs(v[i]-v[i+2]);
    }
//    cout << i << " ";
//    cout << first << " " << second << endl;
    return dp[i]=min(first,second);
}

int main()
{
    int n,i,a;
    cin >> n;
    for(i=0;i<n;i++)
    {
        cin >> a;
        v.push_back(a);
    }
    memset(dp,-1,sizeof(dp));
    cout << calculate(0,n) << endl;
}


Measured memory_bytes: 11936
#include <bits/stdc++.h>
#define DEBUG if(0)
#define lli long long int
#define ldouble long double
using namespace std;

const int maxN = 1e5; int n;
const lli inf = 1e18;
struct Problem
{
  lli l, r;
  void read() { scanf("%lld %lld", &l, &r); }
};
Problem problems[maxN];

int main()
{
  while (scanf("%d", &n) != EOF)
  {
    lli maxL = -inf, minR = inf;
    for (int i = 0; i < n; i ++)
    {
      problems[i].read();
      maxL = max(maxL, problems[i].l);
      minR = min(minR, problems[i].r);
    }

    lli ans = 0;
    // maxL and minR will have to either be in the same contest or not

    // if they're in the same contest:
    for (int i = 0; i < n; i ++)
      ans = max(ans, max(0LL, minR - maxL + 1) + problems[i].r - problems[i].l + 1);

    // if they're not in the same contest:
    vector<pair<lli, lli>> t;
      // If a problem is in maxL group: max(0, problems[i].r - maxL + 1), let's call this a
      // If a problems is in minR group: max(0, minR - problems[i] + 1), let's call this b
      // sort the pairs (a, b) ascending by a and descending by b, let's call the vector of pairs t
        // actually, b doesn't need any particular order
      // now find the index i in which maximizes: min(t[0 : i].a) + min(t[i + 1 : n - 1].b)
    for (int i = 0; i < n; i ++)
      t.push_back({max(0LL, problems[i].r - maxL + 1), max(0LL, minR - problems[i].l + 1)});
    sort(t.begin(), t.end());

    lli curr = t[0].second;
    for (int i = 1; i < n; i ++)
    {
      ans = max(ans, curr + t[i].first);
      curr = min(curr, t[i].second);
    }
    printf("%lld\n", ans);
  }

  return 0;
}

Measured memory_bytes: 3956
#include<bits/stdc++.h>
#define max(a,b) (a>b?a:b)
#define min(a,b) (a>b?b:a)
#define lowbit(x) (x&-x)
#define F first
#define S second 
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int inf=0x3f3f3f3f; 
const int maxn=1e5+10;
int main()
{
	ll n,a,b;
	cin>>n>>a>>b;
	if(n<=a) {
		cout<<n;
		return 0;
	}else if(n>a&&n<a+b){
		cout<<a;
		return 0;
	}
	if(n%(a+b)==0) cout<<n/(a+b)*a;
	else cout<<n/(a+b)*a+min(a,n%(a+b));
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		String S = stdIn.next();
		String T = stdIn.next();
		int change = 0;
		for(int i=0;i<S.length();i++) {
			if(S.charAt(i) != T.charAt(i)) {
				change++;
			}
		}
		System.out.println(change);
		stdIn.close();
	}

}


Measured memory_bytes: 41484
#include <bits/stdc++.h>
using namespace std;
int main(){

  int S,K,x,y,z,ans=0;
  cin >> K >> S;
  for (x=0;x<=K;x++){
    for (y=0;y<=K;y++){
      z = S - x - y;
      if ((0<=z)&&(z<=K)){
        ans++;
      }
    }
  }
  cout << ans << endl;
}

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

int main(){
    int n;
    cin >> n;
    int v[n+2], c[n+2];
        for (int i = 0; i < n; i++){
            cin >> v[i];        
    }
            for (int i = 0; i < n; i++){
            cin >> c[i];        
    }
    int res = 0;
    for (int bit = 0; bit < (1<<n); ++bit)
        {
            int val = 0;
            for(int i = 0; i < n; i++){
                if(bit & (1<<i)){
                    val += v[i] - c[i];
                }
            }
            if(res < val) res = val;

        }
        cout << res;

}
    // for (int i = 0; i < ; i++){
        
    // }


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<utility>
#include<string>
#include<cmath>
#include<cstring>
#include<queue>
#include<map>
#include<climits>
#include<set>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
using namespace std;
typedef pair<int, int> pii;
typedef long long int ll;
typedef pair<ll, ll> pll;
//int dx[4] = { 1,0,0,-1 };
//int dy[4] = { 0,1,-1,0 };
#define MOD 1000000007
#define ARRAY_MAX 55

const int INF = 1e9 + 7;


int main() {


	ios::sync_with_stdio(false);
	cin.tie(0);

	int h, w, a, b;
	cin >> h >> w >> a >> b;
	cout << h * w - a * w - (h - a)*b << endl;

	




	return 0;
}

Measured memory_bytes: 256
N = int(input())
def counter(array):
    from collections import Counter
    return list(Counter(array).most_common())

L = []
C = []
for _ in range(N):
    L.append(list(input()))
s = set(L[0])
for l in L:
    s &= set(l) 
    c = counter(l)
    C.append(c)
if s == set():
    print()
    quit()
L = []
for char in s:
    cnt = 10**10
    for c in C:
        for x in c:
            if x[0] == char:
                cnt = min(cnt,x[1])
    L.append((char,cnt))
L.sort()
ans = ""
for x in L:
    ans += x[0] * x[1]
print(ans)


Measured memory_bytes: 40048
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
using namespace std;
#define loop(i,N) for(ll (i)=0; (i)<(N);++(i))
struct _OMAZINAI_ { _OMAZINAI_() { std::ios::sync_with_stdio(false); std::cin.tie(0); } } __omazinai_instance__;
#define INF (1LL<<61 + 1<<29)
#define YesNo(x) {std::cout << ((x)?"Yes":"No") << std::endl;}
#define YESNO(x) {std::cout << ((x)?"YES":"NO") << std::endl;}
#define OddEven(x) {std::cout << ((x)%2?"Odd":"Even") << std::endl;}
#define ODDEVEN(x) {std::cout << ((x)%2?"ODD":"EVEN") << std::endl;}
typedef long long int ll;
void _INPUT_IMPL_() {};
template <class T, class... Args> void _INPUT_IMPL_(T& dest, Args&... args) { cin >> dest; _INPUT_IMPL_(args...); }
void _OUTPUT_IMPL_() {};
template <class T, class... Args> void _OUTPUT_IMPL_(T dest, Args... args) { cout<< dest << (sizeof...(Args)?" ":""); _OUTPUT_IMPL_(args...); }
#define in(type, ...) type __VA_ARGS__; _INPUT_IMPL_(__VA_ARGS__)
#define in_v(type, name, cnt) vector<type> name(cnt); loop(i, cnt) cin >> name[i];
#define sort_v(v) std::sort(v.begin(), v.end())
#define out(...) _OUTPUT_IMPL_(__VA_ARGS__)
//小さい方に寄る
#define space_op(x, y, a, b, c) ([](auto x_, auto y_, auto a_, auto b_, auto c_){if(x_<y_)return a_;if(x_>y_)return c_;return b_;}(x,y,a,b,c))
#define space_out(x, y, a, b, c) out(space_op(x, y, a, b, c))

int main() {
	in(ll, a);
	in(char, op);
	in(ll, b);
	out(op == '+' ? a + b : a - b);
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <deque>
#include <cstdio>
#include <set>
#include <map>
#include <bitset>
#include <stack>
#include <cctype>
using namespace std;
int par[200020];

int root(int x) {
	if (par[x] == x) {
		return x;
	}
	else {
		return par[x] = root(par[x]);
	}
}
int main() {
	int n, q, p, a, b;
	int x, y;
	cin >> n >> q;
	for (int i = 0; i < n; i++) {
		par[i] = i;
	}
	for (int j = 0; j < q; j++) {
		cin >> p >> a >> b;
		if (p == 0) {
			x = root(a);
			y = root(b);
			if (x != y) {
				par[x] = y;
			}
		}
		else {
			if (root(a) == root(b)) {
				cout << "1" << endl;
			}
			else {
				cout << "0" << endl;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 4148
#include<bits/stdc++.h>
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;

int main() {

    fast

    int n;
    cin>>n;

    int arr[202];

    for(int i=0;i<n;i++)cin>>arr[i];
    int res=0;

    for(int i=0;i<n;i++){
        for(int j=i+1;j<n;j++){
            res+=(arr[i]*arr[j]);
        }
    }
    cout<<res;




	return 0;
}





Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void) {
	long long n, m;
	cin >> n >> m;
	long long ans = 0;
	ans += min(n, m / 2);
	m = m - ans * 2;
	ans = ans + (m / 4);
	cout << ans << "\n";
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#define INF 0x3f3f3f3f
#define MOD 1000000007
using namespace std;
int dx[4]={0,0,-1,1};
int dy[4]={-1,1,0,0};

int main(){
	int N,A;
	int x[51]={},maxi;
	long long int dp[51][51][2600]={};
	cin>>N>>A;
	maxi=A;
	for(int i=1;i<=N;i++){
		cin>>x[i];
		maxi=max(maxi,x[i]);
	}
	dp[0][0][0]=1;
	for(int i=1;i<=N;i++){
		for(int j=0;j<=N;j++){
			for(int k=0;k<=N*maxi;k++){
				if(j>0 && k>=x[i])
					dp[i][j][k]=dp[i-1][j-1][k-x[i]]+dp[i-1][j][k];
				else if(k<x[i])
					dp[i][j][k]=dp[i-1][j][k];
			}
		}
	}
	long long int sum=0;
	for(int i=1;i<=N;i++){
		sum+=dp[N][i][i*A];
	}
	cout<<sum<<endl;
	return 0;
}

Measured memory_bytes: 53120
#include <bits/stdc++.h>
     
    using namespace std;
     
    int main() {
        int x, y;
        long long int W, H;
        cin >> W >> H >> x >> y;
     
        float max_area = W * H / 2.0;
        cout << max_area << " ";
        if((x + x == W) && (y + y == H)) {
            cout << "1" << endl;
        } else {
            cout << "0" << endl;
        }
    }

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc=new Scanner(System.in);
        long H=sc.nextLong();
        long W=sc.nextLong();
        long ans=0L;
        
        if(H==1||W==1){
            System.out.println(1);
            return;
        }
        
        if(W%2==0){
            ans=H*(W/2);
        }else{
            if(H%2==0){
                ans=W*(H/2);
            }else{
                ans=W*((H-1)/2)+(W+1)/2;
            }
        }
        
        System.out.println(ans);
    }
}


Measured memory_bytes: 22100
//Waqt Ha Badal Jayega//

#include <bits/stdc++.h>
#define mod 1000000007
#define ll long long int
#define ld long double
using namespace std;


int main()
{

#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

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

	string s, t;
	cin >> s >> t;
	int flag=0;
	for(int i=0;i<s.size();i++)
	{
		if(s[i]!=t[i])
		{
			flag=1;
		}
	}
	if(flag)
	{
		cout<<"No\n";
	}
	else
	{
		cout<<"Yes\n";
	}
	return 0;

}

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

using namespace std;

int main()
{
    string s;int ans=INT_MIN,c=0;
    cin>>s;
    for(int i=0;i<3;i++)
    {
        if(s[i]=='R' )
        {
            c++;
        }
        else{
            c=0;
        }
        ans=max(c,ans);
    }
    cout<<ans;
    return 0;
}


Measured memory_bytes: 3616
#include <iostream>
#include <string>

using std::cout;
using std::endl;
using std::cin;
using std::string;
int main() {
	int sum;
	string s;
	char zero = '0';
	while (1)
	{
		sum = 0;
		getline(cin, s);
		//cin >> s;
		if (s == "0") break;

		for (size_t i = 0; i < s.size(); i++)
		{
			sum += (int)(s[i] - zero);
		}
		cout << sum << endl;
	}
	return 0;
}

Measured memory_bytes: 3160
def main():
    S = input()
    K = int(input())
    for i in range(len(S)):
        if S[i] != '1':
            can = S[i]
            cannum = i + 1
            break
    print('1' if set(S) == {'1'} or K < cannum else can)

if __name__ == '__main__':
    main()

Measured memory_bytes: 38384
#include <iostream>
#include <algorithm>
#include <tuple>
#include <vector>
#include <string>

using namespace std;

int h, w;
vector<vector<char>> s;
vector<vector<int>> score;

int main(int argc, char const *argv[])
{
    cin >> h >> w;
    s = vector<vector<char>>(h, vector<char>(w));
    score = vector<vector<int>>(h, vector<int>(w, 1001001001));

    for (int i = 0; i < h; i++)
    {
        for (int j = 0; j < w; j++)
        {
            cin >> s.at(i).at(j);
        }
    }

    if (s[0][0] == '.')
    {
        score[0][0] = 0;
    }
    else
    {
        score[0][0] = 1;
    }

    for (int i = 0; i < h; i++)
    {
        for (int j = 0; j < w; j++)
        {
            if (s[i][j] == '.')
            {
                if (i == h - 1 && j == w - 1)
                {
                    break;
                }
                if (i == h - 1)
                {
                    if (s[i][j + 1] == '#')
                        score[i][j + 1] = min(score[i][j] + 1, score[i][j + 1]);
                    else if (s[i][j + 1] == '.')
                        score[i][j + 1] = min(score[i][j+1], score[i][j]);
                    continue;
                }
                else if (j == w - 1)
                {
                    if (s[i + 1][j] == '#')
                        score[i + 1][j] = min(score[i][j] + 1, score[i + 1][j]);
                    else if (s[i + 1][j] == '.')
                        score[i + 1][j] = min(score[i+1][j], score[i][j]);
                    continue;
                }
                if (s[i + 1][j] == '#') //下
                    score[i + 1][j] = min(score[i][j] + 1, score[i + 1][j]);
                else if (s[i + 1][j] == '.')
                    score[i + 1][j] = min(score[i+1][j],score[i][j]);

                if (s[i][j + 1] == '#') //右
                    score[i][j + 1] = min(score[i][j] + 1, score[i][j + 1]);
                else if (s[i][j + 1] == '.')
                    score[i][j + 1] = min(score[i][j+1] ,score[i][j]);
            }
            else
            {
                if (i == h - 1 && j == w - 1)
                {
                    break;
                }
                if (i == h - 1)
                {
                    score[i][j + 1] = min(score[i][j], score[i][j+1]);
                    continue;
                }
                else if (j == w - 1)
                {
                    score[i + 1][j] = min(score[i+1][j], score[i][j]);
                    continue;
                }

                score[i + 1][j] = min(score[i+1][j], score[i][j]);
                score[i][j + 1] = min(score[i][j+1], score[i][j]);
            }
        }
    }

    cout << score[h - 1][w - 1] << endl;

    /*
    for (int i = 0; i < h; i++)
    {
        for (int j = 0; j < w; j++)
        {
            cout << score[i][j] << " ";
        }
        cout << endl;
    }
    */

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<queue>
using namespace std;
typedef long long llint;

llint n,k;
llint p[200001];
llint sum[200001];
void input(){
  cin >> n >> k;
  for(int i=0;i<n;i++){
    cin >> p[i];
  }

}

void solve(){
  input();
  llint ans=0;
  for(int i=0;i<n;i++) sum[i]=sum[i-1]+p[i]+1;
  for(int i=0;i+k-1<n;i++) ans=max(ans, sum[i+k-1]-sum[i-1]);
  printf("%0.10f\n",ans*0.5);
}
int main(void){
  solve();
  return 0;
}


Measured memory_bytes: 3328
INF = float('inf')
N, M, P = map(int, input().split())
edge = []
for i in range(M):
    a, b, c = map(int, input().split())
    edge.append((a - 1, b - 1, c - P))

d = [-INF] * N
d[0] = 0

for i in range(N - 1):
    for a, b, c in edge:
        if d[b] < d[a] + c:
            d[b] = d[a] + c

ans = d[-1]

for i in range(N - 1):
    for a, b, c in edge:
        if d[b] < d[a] + c:
            d[b] = INF

if ans != d[-1]:
    print(-1)
else:
    print(max(0, d[N - 1]))


Measured memory_bytes: 50796
# B問題
W, H , N = map(int, input().split())
xya = []
for i in range(N):
    xya.append(list(map(int, input().split())))
"""
面積を求めるには2点(原点と点(W, H))が分かれば良い
2点の移動を見る
"""
# 初期値
A = [0, 0]   # 原点
C = [W, H]   # 入力された点

# 点A, Cを移動させる関数
def drow(x, y, a):
    if a == 1 and x >= A[0]:
        A[0] = x
    elif a == 2 and x <= C[0]:
        C[0] = x
    elif a == 3 and y >= A[1]:
        A[1] = y
    elif a == 4 and y <= C[1]:
        C[1] = y

flag = True
for i in range(N):   # 入力された各点を移動させる
    drow(xya[i][0], xya[i][1], xya[i][2])
    if A[0] >= C[0] or A[1] >= C[1]:   # 面積が0になる時
        flag = False
        break
if flag:
    print((C[0]-A[0])*(C[1]-A[1]))
else:
    print(0)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define pb push_back
#define fi first
#define se second
using namespace std;
typedef vector<int> vi;
typedef pair<int,int> pii;

int main(){
	int a, b;
	cin >> a >> b;
	if (a > 12) cout << b << '\n';
	else if ( a > 5) cout << b/2 << '\n';
	else cout << 0 << '\n';
	return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#include<iostream>
#include<cstring>
using namespace std;
const int maxh=10;
string mp[maxh];
int main()
{
    int h,w,k;
    cin>>h>>w>>k;
    for(int i=0;i<h;i++)
        cin>>mp[i];
    int ans=0;
    for(int i=0;i<(int)(1<<h);i++)
        for(int j=0;j<(int)(1<<w);j++)
        {
            int cnt=0;
            for(int r=0;r<h;r++)
                for(int c=0;c<w;c++)
                    if(!((1<<r)&i)&&!((1<<c)&j)&&mp[r][c]=='#')
                        cnt++;
            if(cnt==k) ans++;
        }
    cout<<ans<<'\n';
    return 0;
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;


int main(){
  int N, x;
  cin >> N >> x;
  vector<int> v;
  rep(i,N){
    int a;
    cin >> a;
    v.push_back(a);
  }

  sort(ALLOF(v));

  int ret = 0;
  rep(i,N){
    if(i<N-1){
      if(v[i]<=x){
        ret++;
        x -= v[i];
      }
    }else{
      if(v[i] == x){
        ret++;
        x -= v[i];
      }
    }
  }

  cout << ret << endl;
  return 0;
}



Measured memory_bytes: 256
import java.io.IOException;
import java.io.InputStream;
import java.util.Arrays;
import java.util.Collections;
import java.util.NoSuchElementException;

public class Main {
	//FastScannerクラス、普通の Scannerクラスだとメモリと時間を大幅に喰らうので高速化する内部クラス。
	
	public static void main(String[]args) {
		FastScanner sc = new FastScanner(System.in);
		int N = Integer.valueOf(sc.next());
		Integer []x = new Integer[N];
		Integer []X = new Integer[N];
		
		for(int i = 0;i<N;i++) {
			x[i] = Integer.valueOf(sc.next());
			X[i] = x[i];
		}
		
		Arrays.sort(x,Collections.reverseOrder());//降順にソート
		
		for(int i = 0;i<N;i++) {
			//System.out.print(x[i]);
			//System.out.print(" ");
			//System.out.println(X[i]);
		}
		
		int num = (N-1+1)/2;
		
		for(int i = 0;i<N;i++) {
			if(X[i]<x[num-1])
				System.out.println(x[num-1]);
			else
				System.out.println(x[num-1+1]);
		}
		
		
	}
		
	
	
	static class FastScanner {
		 
		private final InputStream in;
		private final byte[] buffer = new byte[1024];
		private int ptr = 0;
		private int buflen = 0;
 
		public FastScanner(InputStream source) {
			in = source;
		}
 
		private boolean hasNextByte() {
			if (ptr < buflen) {
				return true;
			} else {
				ptr = 0;
				try {
					buflen = in.read(buffer);
				} catch (IOException e) {
					e.printStackTrace();
				}
				if (buflen <= 0) {
					return false;
				}
			}
			return true;
		}
 
		private int readByte() {
			if (hasNextByte()) return buffer[ptr++];
			else return -1;
		}
 
		private static boolean isPrintableChar(int c) {
			return 33 <= c && c <= 126;
		}
 
		private void skipUnprintable() {
			while (hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;
		}
 
		public boolean hasNext() {
			skipUnprintable();
			return hasNextByte();
		}
 
		public String next() {
			if (!hasNext()) throw new NoSuchElementException();
			StringBuilder sb = new StringBuilder();
			int b = readByte();
			while (isPrintableChar(b)) {
				sb.appendCodePoint(b);
				b = readByte();
			}
			return sb.toString();
		}
 
		public long nextLong() {
			if (!hasNext()) throw new NoSuchElementException();
			long n = 0;
			boolean minus = false;
			int b = readByte();
			if (b == '-') {
				minus = true;
				b = readByte();
			}
			if (b < '0' || '9' < b) {
				throw new NumberFormatException();
			}
			while (true) {
				if ('0' <= b && b <= '9') {
					n *= 10;
					n += b - '0';
				} else if (b == -1 || !isPrintableChar(b)) {
					return minus ? -n : n;
				} else {
					throw new NumberFormatException();
				}
				b = readByte();
			}
		}
	}

}


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

void fnInput(vector<int>& rvnTrg, vector<int>& rvnSch)
{
  int nSchCnt;
  cin >> nSchCnt;

  for (int i = 0; i < nSchCnt; i++)
  {
    int nSch;
    cin >> nSch;
    rvnSch.push_back(nSch);
  }

  int nTrgCnt;
  cin >> nTrgCnt;

  for (int i = 0; i < nTrgCnt; i++)
  {
    int nTrg;
    cin >> nTrg;
    rvnTrg.push_back(nTrg);
  }
}

void fnLinearSch(const vector<int>& cnrvnTrg, const vector<int>& cnrvnSch, int& rnFnd)
{
  for (auto itvnTrg = begin(cnrvnTrg); itvnTrg != end(cnrvnTrg); itvnTrg++)
    for (auto itvnSch = begin(cnrvnSch); itvnSch != end(cnrvnSch); itvnSch++)
      if (*itvnTrg == *itvnSch)
      {
        rnFnd++;
        break;
      }
}

void fnResultOut(int nFnd)
{
  cout << nFnd << endl;
}

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

  vector<int> vnTrg, vnSch;
  int nFnd = 0;

  fnInput(vnTrg, vnSch);
  fnLinearSch(vnTrg, vnSch, nFnd);
  fnResultOut(nFnd);

  return 0;
}

Measured memory_bytes: 3188
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
    char[] cs;

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

    void run() {
        FastReader sc = new FastReader();
        cs = sc.next().toCharArray();
        solve();
    }

    void solve() {
        boolean[] odds = new boolean[26];
        for (int i = 0; i < cs.length; i++) {
            if (!odds[cs[i] - 'a']) {
                odds[cs[i] - 'a'] = true;
            } else {
                odds[cs[i] - 'a'] = false;
            }
        }
        boolean flag = true;
        for (int i = 0; i < odds.length; i++) {
            if (odds[i]) {
                flag = false;
                break;
            }
        }
        if (flag) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }

    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new
                    InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements())
            {
                try
                {
                    st = new StringTokenizer(br.readLine());
                }
                catch (IOException e)
                {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt()
        {
            return Integer.parseInt(next());
        }

        long nextLong()
        {
            return Long.parseLong(next());
        }

        double nextDouble()
        {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try
            {
                str = br.readLine();
            }
            catch (IOException e)
            {
                e.printStackTrace();
            }
            return str;
        }
    }
}


Measured memory_bytes: 21332
l=[i for i in str(input())]
A=int(''.join(l[:2]))
B=int(''.join(l[2:]))

if A==0 or A>=13:
  if B==0 or B>=13:
    print('NA')
  else:
    print('YYMM')
elif A>=1 and A<=12:
  if B==0 or B>=13:
    print('MMYY')
  else:
    print('AMBIGUOUS')
  

Measured memory_bytes: 3060