akhauriyash/Code-Regression huggingface dataset:
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <tuple>
# include <unordered_map>
# include <numeric>
# include <complex>
# include <bitset>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
typedef pair<LL, LL> P;
constexpr int INF = 2000000000;
constexpr int HINF = INF / 2;
constexpr double DINF = 100000000000000000.0;
constexpr long long LINF = 9223372036854775807;
constexpr long long HLINF = 4500000000000000000;
constexpr long long MMOD = 500000004;
const double PI = acos(-1);
int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
# define ALL(x)      (x).begin(),(x).end()
# define UNIQ(c)     (c).erase(unique(ALL((c))), end((c)))
# define mp          make_pair
# define eb          emplace_back
# define FOR(i,a,b)  for(int i=(a);i<(b);i++)
# define RFOR(i,a,b) for(int i=(a);i>=(b);i--)
# define REP(i,n)    FOR(i,0,n)
# define INIT        std::ios::sync_with_stdio(false);std::cin.tie(0)

int n, k, a[101010];
LL rui[101010];//rui[i]までの和

int main() {
	cin >> n >> k;
	REP(i, n)cin >> a[i];
	REP(i, n) {
		if (i) {
			rui[i] = rui[i - 1] + (a[i]>0 ? a[i] : 0);
		}
		else rui[i] = (a[i]>0?a[i]:0);
	}
	LL ans = 0;
	REP(i, n - k + 1) {
		LL num = rui[i - 1] + (rui[n - 1] - rui[i + k-1]);
		LL num2 = 0;
		LL num3 = 0;
		for (int j = i; j <= i + k - 1; j++) {
			num2 += a[j];
		}
		ans = max( ans,max(num + num2,num));
	}
	cout << ans << endl;
}

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

int main(void){
    string s,t;
    cin>>s>>t;
    int n = s.size(), m = t.size();
    int pos = -1;
    rep(i,n-m+1){
        bool ok = true;
        rep(j,m){
            if(s[i+j]=='?')continue;
            if(s[i+j]!=t[j])ok=false;
        }
        if(ok)pos=i;
    }
    if(pos>=0){
        rep(j,m) s[pos+j]=t[j];
        rep(i,n) if(s[i]=='?') s[i] = 'a';
        cout<<s<<endl;
    }else{
        cout<<"UNRESTORABLE"<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <iomanip>
using namespace std;
#define INF 1e9
#define PI acos(-1)
typedef long long ll;
typedef pair<int, int> p_ii;


int main() {
	
	int n;
	cin >> n;
	vector<int> a(n);
	for (int i = 0; i < n; i++)cin >> a[i];

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

	ans -= n;

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
int main()
{
    int x=0,i;
    char a[10],b[10];
    scanf("%s", a);
    scanf("%s", b);
    for(i=0;i<3;i++){
        if(a[i] == b [i]){
            x++;
        }
    }
    printf("%d\n", x);
    return 0;
}


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

using namespace std;

#define fRead(x)        freopen(x,"r",stdin)
#define fWrite(x)       freopen (x,"w",stdout)

#define LL              long long
#define ULL             unsigned long long
#define ff              first
#define ss              second
#define pb              push_back
#define PI              acos(-1.0)
#define mk              make_pair
#define pii             pair<int,int>
#define pll             pair<LL,LL>


#define min3(a,b,c)     min(a,min(b,c))
#define max3(a,b,c)     max(a,max(b,c))
#define min4(a,b,c,d)   min(a,min(b,min(c,d)))
#define max4(a,b,c,d)   max(a,max(b,max(c,d)))
#define SQR(a)          ((a)*(a))
#define FOR(i,a,b)      for(int i=a;i<=b;i++)
#define ROF(i,a,b)      for(int i=a;i>=b;i--)
#define REP(i,b)        for(int i=0;i<b;i++)
#define MEM(a,x)        memset(a,x,sizeof(a))
#define ABS(x)          ((x)<0?-(x):(x))

#define SORT(v)         sort(v.begin(),v.end())
#define REV(v)          reverse(v.begin(),v.end())
#pragma GCC target ("avx2")
#pragma GCC optimization ("O2")
#pragma GCC optimization ("unroll-loops")
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define FastRead        ios_base::sync_with_stdio(0);cin.tie(nullptr);
#ifdef VAMP
#define debug(...) __f(#__VA_ARGS__, __VA_ARGS__)
template < typename Arg1 >
void __f(const char* name, Arg1&& arg1)
{
    cout << name << " = " << arg1 << std::endl;
}
template < typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args)
{
    const char* comma = strchr(names+1, ',');
    cout.write(names, comma - names) << " = " << arg1 <<" | ";
    __f(comma+1, args...);
}
#else
#define debug(...)
#endif

const LL nax = 1<<18;
struct Tree {
  LL mi[nax*2], ma[nax*2];
  Tree() {
    fill_n(mi, nax*2, 1e9);
    fill_n(ma, nax*2,-1e9);
  }
  void set(LL i, LL v) {
    i += nax;
    mi[i] = ma[i] = v;
    for (i /= 2; i; i /= 2) {
      mi[i] = min(mi[i*2], mi[i*2+1]);
      ma[i] = max(ma[i*2], ma[i*2+1]);
    }
  }
  LL query(LL l, LL r) {
    l += nax, r += nax;
    LL qmi = mi[l], qma = ma[l];
    for (; r-l > 1; l/=2, r/=2) {
      if (l%2==0) {
	qmi = min(qmi, mi[l+1]);
	qma = max(qma, ma[l+1]);
      }
      if (r%2) {
	qmi = min(qmi, mi[r-1]);
	qma = max(qma, ma[r-1]);
      }
    }
    return qma-qmi;
  }
} tree[16];

LL k;
void setpoint(LL i) {
  LL a[5];
  for (LL l = 0; l < k; l++)
    cin >> a[l];
  for (LL j = 0; j < 1<<k-1; j++) {
    LL sum = a[k-1];
    for (LL l = 0; l < k-1; l++)
      sum += (j>>l&1 ? 1:-1)*a[l];
    tree[j].set(i, sum);
  }
}


int main()
{
    #ifdef VAMP
        clock_t tStart = clock();
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
    LL n;
    cin >> n;
    k = 2;
    for (LL i = 0; i < n; i++) setpoint(i);

    LL l = 0 , r = n;
    LL ans = 0;
    for (LL j = 0; j < 1<<k-1; j++)
        ans = max(ans, tree[j].query(l, r));

    cout << ans << "\n";
    #ifdef VAMP
        fprintf(stderr, "\n>> Runtime: %.10fs\n", (double) (clock() - tStart) / CLOCKS_PER_SEC);
    #endif
}


Measured memory_bytes: 134668
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<iostream>

using namespace std;

int main()
{
	int n;
	int s[105];
	while(cin>>n){
		int sum=0;
		for(int i=1;i<=n;i++){
			cin>>s[i];
			sum+=s[i];
		}
		sort(s+1,s+1+n);
		if (sum%10==0){
			for(int i=1;i<=n;i++){
				if ((sum-s[i])%10!=0){
					cout<<sum-s[i]<<endl;
					return 0;
				}
			}
			cout<<"0"<<endl;
		}
		else
			cout<<sum<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
template<class _Tp>_Tp max(_Tp a,_Tp b){if(a>b) return a;return b;}
template<class _Tp>_Tp min(_Tp a,_Tp b){if(a<b) return a;return b;}
template<class _Tp>void ckmax(_Tp &a,_Tp b){if(a<b) a=b;}
template<class _Tp>void ckmin(_Tp &a,_Tp b){if(a>b) a=b;}
template<class _Tp>void sswap(_Tp &a,_Tp &b){_Tp c=a;a=b;b=c;}
int read(){
	char ch=getchar();bool f=1;int x=0;
	while((ch<'0' || ch>'9') && ch!='-') ch=getchar();
	if(ch=='-') f=0,ch=getchar();
	while(ch>='0' && ch<='9'){x=x*10+(ch&15);ch=getchar();}
	return f?x:-x;
}
#define N 300010
class Point{
    public:int x,y;
    bool friend operator <(Point a,Point b){return a.x<b.x;}
}p[N];
class tree{
	public:int l,r,w,tag;
}t[N*4];
#define ls (x<<1)
#define rs ((x<<1)|1)
void pushu(int x){
    if(t[x].l==t[x].r)return;
    t[x].w=max(t[ls].w,t[rs].w);
}
void pushd(int x){
    int tag=t[x].tag;
    t[ls].tag+=tag;t[ls].w+=tag;
    t[rs].tag+=tag;t[rs].w+=tag;
    t[x].tag=0;
}
void build(int x,int l,int r){
    t[x].l=l;t[x].r=r;
	t[x].tag=0;t[x].w=0;
    if(l==r)return;
    int mid=(l+r)/2;
    build(ls,l,mid);
    build(rs,mid+1,r);
}
void update(int x,int l,int r,int val){
    if(l<=t[x].l&&t[x].r<=r){
        t[x].tag+=val;
        t[x].w+=val;
        return;
    }
    if(t[x].tag&&t[x].l!=t[x].r)pushd(x);
    if(l<=t[ls].r)update(ls,l,r,val);
    if(r>=t[rs].l)update(rs,l,r,val);
    pushu(x);
}
int stk[2][N],top0,top1,ans,w,h,n;
void solve(){
    build(1,1,n);
    std::sort(p+2,p+n+1);
    top0=top1=0;
    stk[0][0]=stk[1][0]=1;
    update(1,1,n,h*2);
    for(int i=2;i<=n;++i){
        update(1,1,i-1,(p[i].x-p[i-1].x)*2);
        ckmax(ans,t[1].w);
        if(p[i].y*2>=h){
            update(1,stk[0][top0],i-1,(p[i].y-h)*2);
            while(top0&&p[stk[0][top0]].y>=p[i].y){
                update(1,stk[0][top0-1],stk[0][top0]-1,(p[i].y-p[stk[0][top0]].y)*2);
                top0--;
            }++top0;
            stk[0][top0]=i;
        }else{
            update(1,stk[1][top1],i-1,-p[i].y*2);
            while(top1&&p[stk[1][top1]].y<=p[i].y){
                update(1,stk[1][top1-1],stk[1][top1]-1,(p[stk[1][top1]].y-p[i].y)*2);
                top1--;
            }++top1;
            stk[1][top1]=i;
        }
    }
}
int main(){
	w=read();h=read();n=read()+2;
    for(int i=2;i<n;++i)
    	p[i].x=read(),p[i].y=read();
    p[n].x=w;p[n].y=h;
    solve();
    sswap(w,h);
    for(int i=2;i<=n;++i)
        sswap(p[i].x,p[i].y);
    solve();
    printf("%d\n",ans);
}

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

long long n, x;
long long memo[55][2] = {0};

long long solve(long long now, long long p);

int main() {
  cin >> n >> x;
  memo[0][0] = memo[0][1] = 1;
  for(int i = 1; i <= n; ++i) {
    memo[i][0] = memo[i - 1][0] * 2 + 1;
    memo[i][1] = memo[i - 1][1] * 2 + 3;
  }
  cout << solve(n, x) << endl;
  return 0;
}

long long solve(long long now, long long p) {
  if(now == 0) return p == 1;
  if(p < 2) return 0;
  if(memo[now][1] <= p) return memo[now][0];
  if(memo[now][1] / 2 + 1 == p) return memo[now - 1][0] + 1;
  if(memo[now][1] / 2 + 1 < p)
    return solve(now - 1, p - (memo[now][1] / 2) - 1) +
           memo[now - 1][0] + 1;
  else
    return solve(now - 1, p - 1);
}


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


int main() {
	
	int a, b, k;
	cin >> a >> b >> k;
	if(b-a+1 <= k*2){
		for(int i=a; i<=b; i++) cout << i << endl;
	}
		
	else{ 
		for(int i=a; i<a+k; i++) cout << i << endl;
		for(int i=b-k+1; i<=b; i++) cout << i << endl;
	}
	
	return 0;
}

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

int main() {
    int n, m;
    cin >> n >> m;
    vector<string> s(n);
    for (int i = 0; i < n; ++i) cin >> s[i];
    
    map<pair<int, int>, int> mp;
    int start = 0;
    int pre_sum = 0;
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < m; ++j) {
            if (s[i][j] == 'o') {
                mp[{i, j}] = start++;
                pre_sum += i + j;
            }
        }
    }
    int v = start + n * m + 2;
    mcf_graph<int, int> g(v);
    int a = v - 2, b = v - 1;

    int cost_max = 10000;
    vector<vector<bool>> seen(n, vector<bool>(m));
    auto bfs = [&](int i, int j) {
        seen.assign(n, vector<bool>(m, false));
        queue<pair<int, int>> q;
        q.emplace(i, j);
        seen[i][j] = true;
        g.add_edge(mp[{i, j}], start + m * i + j, 1, 0);
        while (!q.empty()) {
            auto [vi, vj] = q.front();
            q.pop();
            for (int k = 0; k < 2; ++k) {
                int ni = vi + k, nj = vj + (1 - k);
                if (ni >= n || nj >= m) continue;
                if (s[ni][nj] == '#') continue;
                if (seen[ni][nj]) continue;
                q.emplace(ni, nj);
                seen[ni][nj] = true;
                g.add_edge(mp[{i, j}], start + m * ni + nj, 1, 0);
            }
        }
    };

    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < m; ++j) {
            if (s[i][j] != '#') g.add_edge(start + m * i + j, b, 1, cost_max - (i + j));
            if (s[i][j] == 'o') bfs(i, j);
        }
    }

    for (int i = 0; i < start; ++i) g.add_edge(a, i, 1, 0);

    auto [flow, cost] = g.flow(a, b);
    int ans = -(cost - flow * cost_max);
    ans -= pre_sum;
    cout << ans << '\n';

}

Measured memory_bytes: 7336
n=int(input())
ans=[]
tes=[[] for _ in range(n)]

for j in range(n):
    a=int(input())
    for h in range(a):
        x,y=map(int,input().split())
        tes[j].append(x)
        tes[j].append(y)

for i in range(2**n):
    f=0
    m=0
    rel=[0 for _ in range(n)]
    for j in range(n):
        if (i>>j)&1:
            rel[j]=1
            m+=1
            
    
    for j in range(n):
        
        for q in range(len(tes[j])//2):
            if rel[j]==1 and tes[j][2*q+1]!=rel[tes[j][2*q]-1]:
                f=1
    if f==0:
        ans.append(m)
print(max(ans))
            
    
        
    
    
    
        
        
    
    
    
    
        


Measured memory_bytes: 69268
import re

S = input()
lmax = 0

for i in range(len(S)):
    for j in range(i, len(S)):
        ss = S[i:j+1]
        l = re.findall(r'[^ACGT]', ss)
        if len(l) == 0:
            lmax = max(lmax, len(ss))
        else:
            continue
print(lmax) 

Measured memory_bytes: 3188
import math
def solve(line):
    r=line[0]
    area = round((r*r*math.pi),6)
    circumference = round((2*r*math.pi),6)
    print('{0} {1}'.format(area,circumference))



    
def answer():
    line = list(map(float,input().split()))
    solve(line)

if __name__ =='__main__':
    answer()


Measured memory_bytes: 5640
import java.io.PrintWriter

fun next() = readLine()!!
fun nextInt() = next().toInt()
fun nextLong() = next().toLong()
fun nextDouble() = next().toDouble()
fun nextList() = next().split(" ")
fun nextIntList() = nextList().map(String::toInt)
fun nextLongList() = nextList().map(String::toLong)
fun nextDoubleList() = nextList().map(String::toDouble)

val pw = PrintWriter(System.out)
fun print(s: Any = "") = pw.print(s)
fun println(s: Any = "") = pw.println(s)

fun main(args: Array<String>) {
    main()
    pw.flush()
}

fun main() {
    val (T, X) = nextDoubleList()
    println(T / X)
}

Measured memory_bytes: 37672
#include<bits/stdc++.h>
namespace imzzy{
	#define endl '\n'
	#define ccf std::cout<<"f**k"<<endl
	#define rgi register int
	#define ll long long
	class fastin{private:int _ch,_f;
	public:inline fastin&operator>>(char&c){c=getchar();return*this;}
	template<typename _Tp>inline fastin&operator>>(_Tp&_x){
	_x=0;while(!isdigit(_ch))_f|=(_ch==45),_ch=getchar();
	while(isdigit(_ch))_x=(_x<<1)+(_x<<3)+(_ch^48),_ch=getchar();
	_f&&(_x=-_x,_f=0);return*this;}fastin(){_ch=_f=0;}
	}fin;class fastout{private:int _num[32],_head;
	public:inline fastout&operator<<(char c){putchar(c);return*this;}
	template<typename _Tp> inline fastout&operator<<(_Tp _x){
	_Tp _k;if(_x==0){putchar('0');return *this;}if(_x<0)putchar('-'),_x=-_x;
	while(_x>0)_k=_x/10,++_head,_num[_head]=(_x-(_k<<1)-(_k<<3))^48,_x=_k;
	while(_head>0)putchar(_num[_head]),--_head;return*this;}fastout(){_head=0;}
	}fout;inline void P_INIT(){
	#ifdef D_STDOUT_UNBUFFERED
	setbuf(stdout,NULL);
	#endif
}}using namespace imzzy;
// ----------------------------
// #define int ll
// using namespace std;
const int maxn=100004,maxm=27;
const ll mod=201010091201201201ll,inf=1201201201;

int a[maxn];
signed main()
{P_INIT();
	// freopen("yy.in","r",stdin);
	// freopen("yy.out","w",stdout);
	int n,m,t=0; fin>>n>>m;
	for(rgi i=1;i<=m;++i) fin>>a[i],t+=a[i]&1;
	if(n==1&&m==1) return printf("1\n1\n1"),0;
	if(m==1) return printf("%d\n2\n1 %d",n,n-1),0;
	if(t>2) return puts("Impossible"),0;
	int p=1;
	for(rgi i=1;i<=m;++i) if(a[i]&1) std::swap(a[i],a[p]),p=m;
	for(rgi i=1;i<=m;++i) fout<<a[i]<<' '; fout<<endl;
	++a[1],--a[m];
	if(a[m]==0) --m; fout<<m<<endl;
	for(rgi i=1;i<=m;++i) fout<<a[i]<<' ';
	return 0;
}
// ----------------------------
// by imzzy

Measured memory_bytes: 3768
//#include<bits/stdc++.h>
#include<iostream>
#include<cmath>
#include<cstdio>
#include<vector>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<utility>
#include<algorithm>
#include<cstring>
#include<sstream>
#include <iomanip>

using namespace std;

typedef long long ll ;
typedef double db;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef vector< pair<int,int> > vii;
const double pi = 2*acos(0) ;

#define pf		  	printf
#define sf			  scanf
#define pb(a)         push_back(a)
#define mp			make_pair
#define fi			 first
#define se			 second
#define for0(i,n)        for(int i=0;i<n;i++)
#define for1(i,n)        for(int i=1;i<=n;i++)
#define forab(i,a,b)       for(int i=a;i<=b;i++)
#define lcm(a, b)     ((a)*((b)/gcd(a,b)))
#define sq(a)		   (a)*(a)
#define nw				"\n"
#define abs(x)		fabs(x)
#define pcase(z,x)    cout<<"Case "<<z<<": "<<x<<"\n"
int main()
{
	
	int i,n,k;
	cin>>n>>k;
	db res=0;
	for(i=1 ; i<=n ; i++){
		int t=i,cnt=0;
		while(1){
			if(t>=k) break;
			t = t*2;
			cnt++;
			}
		res += (1.0/n)*pow((0.5), cnt);
		//cout<<res<<nw;
		}
	pf("%0.10lf\n",res);
	return 0;
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
// header {{{
#include <bits/stdc++.h>
using namespace std;
#define CPP_STR(x) CPP_STR_I(x)
#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_STR_I(args...) #args
#define CPP_CAT_I(x,y) x ## y
#define ASSERT(expr...) assert((expr))
using i8  = int8_t;
using u8  = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;
using f32 = float;
using f64 = double;
using f80 = __float80;
// }}}
constexpr i64 INF = 1'010'000'000'000'000'017LL;
constexpr i64 MOD = 1'000'000'007LL;
constexpr f64 EPS = 1e-12;
constexpr f64 PI = 3.14159265358979323846;
// util {{{
#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))

template<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }
template<typename T, size_t N>
i64 SIZE(const T (&)[N]) { return static_cast<i64>(N); }
template<typename T, typename U, typename Comp=less<>>
bool chmax(T& xmax, const U& x, Comp comp={}) {
    if(comp(xmax, x)) {
        xmax = x;
        return true;
    }
    return false;
}

template<typename T, typename U, typename Comp=less<>>
bool chmin(T& xmin, const U& x, Comp comp={}) {
    if(comp(x, xmin)) {
        xmin = x;
        return true;
    }
    return false;
}
// }}}

// init {{{
struct ProconInit {
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;

    ProconInit() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(IOS_PREC);
        if(AUTOFLUSH)
            cout << unitbuf;
    }
} PROCON_INIT;
// }}}

//--------------------------------------------------------------------

signed main() {
    int n;
    string s,t;
    cin>>n;
    cin>>s>>t;

    string newst;
    REP(i,n){
        newst += s.at(i);
        newst += t.at(i);
    }

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

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int a[100],b[100];
int main(){
    int n,m,cnt=0;
    scanf("%d %d",&n,&m);
    a[0]=2;
    for(int i=1;i<n;i++){
        a[i]=a[i-1]+2;
    }
    b[0]=1;
    for(int i=1;i<m;i++){
        b[i]=b[i-1]+2;
    }
    for(int i=0;i<n+m;i++){
        for(int j=i;j<m+n;j++){
            if(i<m && j<m && i!=j && (b[i]+b[j]) % 2 == 0){
                cnt++;
            }
            if(i<n && j<n && i!=j && (a[i]+a[j]) % 2 == 0){
                cnt++;
            }
        }
        
    }
    printf("%d",cnt);
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>

using namespace std;

#define FOR(i,k,n) for(int i=(k); i<(int)n; ++i)
#define REP(i,n) FOR(i,0,n)
#define FORIT(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

template<class T> void debug(T begin, T end){ for(T i = begin; i != end; ++i) cout<<*i<<" "; cout<<endl; }

typedef long long ll;
const int INF = 100000000;
const double EPS = 1e-8;
const int MOD = 1000000007;

int main(){
  int a,b,c,d,e,f;
  while(cin>>a>>b>>c>>d>>e>>f,a+b+c+d+e+f){
    int A = a+d;
    int B = b+e;
    int C = c+f;
    int ans = 0;
    REP(i,3){
      if(A-i >= 0 && B-i >= 0 && C-i >= 0)
        ans = max(ans, (A-i)/3+(B-i)/3+(C-i)/3 + i);
    }
    cout<<ans<<endl;
  }
  return 0;
}

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

n = int(input())
s = [input() for _ in range(n)]

c = [0 for _ in range(5)]
t = 'MARCH'

for i in range(n):
    for j in range(5):
        if s[i][0] == t[j]:
            c[j] += 1
ans = 0 
for i in range(5):
    for j in range(i+1, 5): 
        for k in range(j+1, 5): 
            ans += c[i]*c[k]*c[j]
print(ans)


Measured memory_bytes: 16268
#include<stdio.h>

int main(){

	int a,b,c,n1,n2,n3;

	scanf("%d %d %d",&a,&b,&c);
	if(a<=b&&b<=c){
		n1=a; n2=b; n3=c;
	}else if(a<=c&&c<=b){
		n1=a; n2=c; n3=b;
	}else if(b<=a&&a<=c){
		n1=b; n2=a; n3=c;
	}else if(b<=c&&c<=a){
		n1=b; n2=c; n3=a;
	}else if(c<=a&&a<=b){
		n1=c; n2=a; n3=b;
	}else if(c<=b&&b<=a){
		n1=c; n2=b; n3=a;
	}

	printf("%d %d %d\n",n1,n2,n3);

	return 0;
}

Measured memory_bytes: 596
#include<algorithm>
#include<climits>
#include<cmath>
#include<cstdlib>
#include<iomanip>
#include<iostream>
#include<numeric>
#include<string>
using namespace std;

long gcd(long x, long y) { if (x > y) { return gcd(y, x); } long r; while (y != 0) { r = x % y; x = y; y = r; }return x; }
long lcm(long x, long y) { return(x / gcd(x, y)) * y; }
void indexsort(long* first, long* last, long* func) { sort(first, last, [&](long a, long b) {return func[a] < func[b]; }); }
//--------------------

int main() {

	long N; cin >> N;
	long X[200009], copy[200009]; for (int i = 0; i < N; i++) { cin >> X[i]; copy[i] = X[i]; }
	sort(copy, copy + N);

	for (int i = 0; i < N; i++) if (X[i] >= copy[N / 2]) cout << copy[N / 2 - 1] << endl; else cout << copy[N / 2] << endl;

}

Measured memory_bytes: 5376
from sys import stdin
##  input functions for me
def ria(sep = ''):
    if sep == '' :
        return list(map(int, input().split())) 
    else: return list(map(int, input().split(sep)))
def rsa(sep = ''):
    if sep == '' :
        return input().split() 
    else: return input().split(sep)
def ri(): return int(input())
def rd(): return float(input())
def rs(): return input()
##

## main ##
S = rs()
N = len(S)

mi = int(1e9)
for p in range(2):
    cnt = 0
    for i in range(N):
        if S[i] != chr(ord('0') + ((i % 2) ^ p)): cnt += 1
    mi = min(mi, cnt)

print(mi)






Measured memory_bytes: 3188
using System;
using System.Collections.Generic;//list用
using System.Text;//StringBuilder用
using System.Collections;
using System.Linq;
class Program
{
    static List<int> s = new List<int>();
    static decimal result;
static Hashtable ht=new Hashtable();
static StringBuilder sb = new StringBuilder();
static int N,M,K;
static long[,] table;
    static void Main()
    {
Read1();
      Read2();
      int tmp=0;
      int tmp2=0;
      result=1000;
for(int i=0;i<N;i++){
  tmp=0;tmp2=0;
for(int j=0;j<i;j++){tmp+=s[j];}
for(int j=i;j<N;j++){tmp2+=s[j];}
  result=Math.Min(Math.Abs(tmp-tmp2),result);
}
                    Console.WriteLine(result.ToString());

    }


    static void Read1()//1項
    {
        string tmp = Console.ReadLine();
        N = int.Parse(tmp);
    }
 
    static void Read2()//複数項（項目数Ｎ）
    {
        string[] tmp = Console.ReadLine().Split(' ');
        for (int i = 0; i < N; i++) { s.Add(int.Parse(tmp[i])); }
    }
    static void Read3()//1行複数項
   {
       string[] tmp = Console.ReadLine().Split(' ');
       for (int i = 0; i < tmp.Length; i++) { s.Add(int.Parse(tmp[i])); }
    }
    static void Read4()//NK１行
    {
        string[] tmp = Console.ReadLine().Split(' ');
       N = int.Parse(tmp[0]);
       K = int.Parse(tmp[1]);
    }
    static void Read5()//N行K項
    {

 
    }


}

Measured memory_bytes: 13268
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
using namespace std;
#define MOD 1000000007
#define INF (1<<29)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long Int;
typedef pair<Int, Int> P;

int h, w, a, b;

int main(){
    cin >> h >> w >> a >> b;
    for(int i = 0;i < h;i++){
        for(int j = 0;j < w;j++){
            cout << ((i<b) ^ (j<a));
        }cout << endl;
    }
    return 0;
}


Measured memory_bytes: 1280
const stdin = require('fs').readFileSync('/dev/stdin', 'utf8')

const [a, b, c] = stdin.split('\n')[0].split(' ').map(Number)

const sorted = [a,b,c].sort((p,v)=>v-p)

const res = sorted[0] * 10 + sorted[1] + sorted[2]

console.log(res)

Measured memory_bytes: 7372
#include<bits/stdc++.h>
using namespace std;
int main() {
  int N, M;
  cin >> N >> M;
  
  //vector<vector<int>> vec(M,vector<int>(2));
  
  if(N %2 == 1){
    for(int i=0; i<M; i++){
      cout << N-i << " " << i+1 << endl;
    }
  }
  
  else{
    int L = N/2;
    L /= 2;
    int a = L;
    int b = L+1;
    for(int i=0; i<min(M,L); i++){
      cout << a << " " << b << endl;
      a--;
      b++;
    //vec[i][0] = N-i;
    //vec[i][1] = i+1;
    }
    int x = N/2;
    x += (x+1)/2;
    int y = x+1;
    x--;
    for(int i=0; i<M-L; i++){
      cout << x << " " << y << endl;
      x--;
      y++;
    }
  }
  
  //vector<vector<int>> vec(M,vector<int>(2));
  /*for(int i=0; i<M; i++){
    cout << N-i << " " << i+1 << endl;
    //vec[i][0] = N-i;
    //vec[i][1] = i+1;
  }*/
  
  /*for(int i=0; i<N; i++){
    for(int j=0; j<M; j++){
      cout << vec[j][0] << " " << vec[j][1] << " ";
      vec[j][0]--;
      if(vec[j][0] == 0){
        vec[j][0] = N;
      }
      vec[j][1]--;
      if(vec[j][1] == 0){
        vec[j][1] = N;
      }
    }
    cout << endl;
  }*/

}




Measured memory_bytes: 3624
inf = 10 ** 15
mod = 10 ** 9 + 7
n = input()
c = int(n[-1])
hon = [2
,
4
,
5
,
7
,
9]
pon = [0
,
1
,
6
,
8]

if c in hon:
    print('hon')
elif c in pon:
    print('pon')
else:
    print('bon')

Measured memory_bytes: 61664
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <functional> 
#include <vector>

using namespace std;

int main(){

    int n,a,b,c,d;
    cin >> n;

    a = n/1000;
    b = (n/100)%10;
    c = (n/10)%10;
    d = n%10;

    cout << a;
    if(a +b +c +d == 7){cout << "+" << b << "+" << c << "+";}
    else if(a +b +c -d == 7){cout << "+" << b << "+" << c << "-";}
    else if(a +b -c +d == 7){cout << "+" << b << "-" << c << "+";}
    else if(a +b -c -d == 7){cout << "+" << b << "-" << c << "-";}
    else if(a- b+ c +d == 7){cout << "-" << b << "+" << c << "+";}
    else if(a -b+ c- d == 7){cout << "-" << b << "+" << c << "-";}
    else if(a -b -c +d == 7){cout << "-" << b << "-" << c << "+";}
    else if(a -b- c -d == 7){cout << "-" << b << "-" << c << "-";}
    cout << d << "=7";
    return 0;
}

Measured memory_bytes: 256
import math
from collections import Counter
def total(n):
    return int((-1 + math.sqrt(1 + 8 * n)) / 2); 
def isPrime(n) : 
  
    # Corner cases 
    if (n <= 1) : 
        return False
    if (n <= 3) : 
        return True
  
    # This is checked so that we can skip  
    # middle five numbers in below loop 
    if (n % 2 == 0 or n % 3 == 0) : 
        return False
  
    i = 5
    while(i * i <= n) : 
        if (n % i == 0 or n % (i + 2) == 0) : 
            return False
        i = i + 6
  
    return True
  
def primeFactors(n): 
    tot = 0
    a = []
    while n % 2 == 0: 
        a.append(2)
        n = n / 2
          

    for i in range(3,int(math.sqrt(n))+1,2): 

        while n % i== 0: 
            a.append(i)
            n = n / i 

    if n > 2: 
        a.append(n)
    for i, j in Counter(a).items():
        tot+=total(j)
    return tot


def sol():
    n = int(input())
    if n == 1:
        print(0)
        return
    if isPrime(n):
        print(1)
        return

    print(primeFactors(n))
    
sol()


Measured memory_bytes: 68380
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
constexpr lint MOD = 1000000007;
lint N;

int main()
{
    cin >> N;
    int digit = 0;
    lint tmp = N;
    while (tmp)
    {
        digit++;
        tmp >>= 1;
    }
    vector<vector<lint>> dp(digit+1, vector<lint>(3));
    dp[0][0] = 1;
    for (int i = 1; i <= digit; i++) {
        if (N >> (digit-i) & 1) {
            dp[i][0] = dp[i - 1][0];
            dp[i][1] = dp[i - 1][0] + dp[i - 1][1];
            dp[i][2] = 2 * dp[i - 1][1] + 3 * dp[i - 1][2];
        }
        else {
            dp[i][0] = dp[i - 1][0] + dp[i - 1][1];
            dp[i][1] = dp[i - 1][1];
            dp[i][2] = dp[i - 1][1] + 3 * dp[i - 1][2];
        }
        for (auto &v : dp[i]) v %= MOD;
    }
    cout << accumulate(dp[digit].begin(), dp[digit].end(), 0LL) % MOD << endl;
}


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

#define N               200005
#define ff              first
#define ss              second
#define ll              long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<ll,ll>
#define vi              vector<ll>
#define mii             map<ll,ll>
#define pq_max          priority_queue<ll>
#define pq_min          priority_queue<ll,vi,greater<ll> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            ll x; cin>>x; while(x--)
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());

typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> pbds;


void fio(){
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
}

int main(){
    fio();

    ll d,t,s;
    cin>>d>>t>>s;

    ll d1 = s * t;
    if(d1 >= d) cout<<"Yes";
    else cout<<"No";

    return 0;
}

Measured memory_bytes: 3660
#include <iostream>
#include <algorithm>
#include <string>
#include <unordered_map>
#include <math.h>
#include <bitset>
#include <vector>
using namespace std;
 
int main() {
    vector<int> d;
    int a,b,c;
    cin >> a >> b >> c;
    d.push_back(a);
    d.push_back(b);
    d.push_back(c);
    sort(d.begin(),d.end());
    cout << d[2]-d[1]+d[1]-d[0] << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll, ll> Pll;
#define debug(var)  do{std::cout << #var << " : ";view(var);}while(0)
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

const int MOD = 1000000007;
const int INF = 1e9;

const int mod = 1000000007;
const int inf = 1e9;
#define PI acos(-1);
int dx[4] = {1,-1,0,0};
int dy[4] = {0,0,1,-1};
int ddx[8] = {1,1,1,-1,-1,-1,0,0};
int ddy[8] = {0,1,-1,0,1,-1,1,-1};


int main(){
    int a, b;
    cin >> a >> b;
    cout << (a-1) * (b-1) << endl;
}

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

int solve()
{
	int a,b;
	cin>>a>>b;
	return a*b;
}

int main()
{
	int t;
	t=1;
	while(t--)
	{
		cout<<solve()<<'\n';
	}
}



Measured memory_bytes: 3556
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
using namespace std;
#define rep(i, a, b) for(int i = a; i < (b); ++i)
typedef long long ll;
int main() {
    int N;
    cin >> N;
    vector<int>H(N);
 
    rep(i, 0, N){
        cin >> H[i];
    }
    ll ans = 0;
    ll preN = 0;
    rep(i, 0, N){
        if(preN >= H[i]){
            preN = H[i];
        } else {
            ans += H[i]-preN;
            preN = H[i];
        }
    }
    
    cout << ans << endl;
    return 0;
}


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

using namespace std;

typedef long long LL;
typedef pair<LL, LL> pLL;

int blackcount(int N, int W, char tbl[][6],int p, int q)
{
	int count = 0;
	for (int i = 0; i < N; i++) {
		if ((p >> i) % 2 == 0) {
			for (int j = 0; j < W; j++) {
				if ((q >> j) % 2 == 0) {
					if (tbl[i][j] == '#') {
						count++;
					}
				}
			}
		}
	}
	return count;
}

int main(void)
{
	int N, W, K, ans = 0;
	cin >> N >> W >> K;
	char tbl[6][6];
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < W; j++) {
			cin >> tbl[i][j];
		}
	}
	for (int i = 0; i < 1 << N; i++) {
		for (int j = 0; j < 1 << W; j++) {
			if (K == blackcount(N, W, tbl, i, j))
			{
				ans++;
			}
		}
	}
	cout << ans << endl;

	return 0;

}

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

using namespace std;
typedef long long ll;
#define out(ans) cout << ans << endl;
const long long mod = 1e9 + 7;

int main(int argc, char const *argv[]) {
  int n, m, tmp;
  cin >> n >> m;
  vector<bool> a(n, true);
  vector<int> ans(n+1, 0);
  for (int i = 0; i < m; i++) {
    cin >> tmp;
    a[tmp] = false;
  }
  ans[0] = 1;
  if (a[1]) {
    ans[1] = 1;
  } else {
    ans[1] = 0;
  }

  for (int i = 2; i < n+1; i++) {
    ans[i] = (a[i - 1] ? ans[i - 1] : 0) + (a[i - 2] ? ans[i - 2] : 0);
    ans[i] %= mod;
  }
  cout << ans[n];

  return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
#define ft(i,l,r) for(register int i=l;i<=r;i++)
#define fd(i,r,l) for(register int i=r;i>=l;i--)
using namespace std;
int n,a;
int main()
{
	cin>>n>>a;
	if(n%500<=a) cout<<"Yes";
	else cout<<"No";
	return 0;
}

Measured memory_bytes: 256
from collections import Counter, deque
N, K = map(int, input().split())
P = list(map(int, input().split()))
ans = N - K + 1


# 変化しないものを数える
LIS = [-1] * N
LIS[-1] = 1
LIS_MIN_NOW = P[-1]
for i in reversed(range(N - 1)):
    p = P[i]
    if p < LIS_MIN_NOW:
        LIS_MIN_NOW = p
        LIS[i] = LIS[i + 1] + 1
    else:
        LIS_MIN_NOW = p
        LIS[i] = 1
LIS = LIS[:N - K + 1]


def slide_min(A, K):
    deq, ret = deque([]), []
    for k in range(len(A)):
        while deq and A[deq[-1]] >= A[k]:
            deq.pop()
        deq.append(k)

        if k < K - 1:
            continue

        if deq[0] + K <= k:
            deq.popleft()
        ret.append(A[deq[0]])

    return ret


# スライド最小値・最大値を計算
MIN = slide_min(P, K)
MAX = list(map(lambda x: -x, slide_min(list(map(lambda x: -x, P)), K)))


for i in range(N - K + 1):
    flg = False
    if LIS[i] >= K:
        flg = True

    if (i + 1 < N - K + 1) and (P[i] == MIN[i]) and (P[i + K] == MAX[i + 1]):
        flg = True

    ans -= flg

if len([l for l in LIS if l >= K]):
    ans += 1
print(ans)


Measured memory_bytes: 43544
N = int(input())
A = [int(x) for x in input().split()]

result = True


for i in range(N):
    if A[i] % 2 == 0:
        if A[i] % 3 != 0 and A[i] % 5 != 0:
            result = False
            break
            

if result == True:
    print("APPROVED")
else:
    print("DENIED")


Measured memory_bytes: 2940
#include<bits/stdc++.h>
#define LL long long
#define Mod 1000000007
using namespace std;
int n,m; char str[5005];
int f[2][5005];
int main(){
	scanf("%d%s",&n,str);
	m=strlen(str);
	f[0][0]=1;
	for(int i=1;i<=n;++i){
		int I=i&1;
		f[I][0]=(f[I^1][0]+f[I^1][1])%Mod;
		for(int j=1;j<=n;++j)
			f[I][j]=((LL)f[I^1][j-1]+f[I^1][j-1]+f[I^1][j+1])%Mod;
	}
	int Ans=f[n&1][m];
	for(int i=1;i<=m;++i) Ans=(LL)Ans*500000004%Mod;
	printf("%d",Ans);
	return 0;
}

Measured memory_bytes: 256
N, K = map(int, input().split())
A = list(map(lambda s: int(s) - 1, input().split()))

V = [-1] * N
V[0] = 0
H = [0]
for i in range(1, K + 1):
    n = A[H[i - 1]]
    H.append(n)
    if V[n] != -1:
        start_L = V[n]
        L = H[start_L:i]
        break
    V[n] = i

if len(H) == K + 1:
    ans = H[K]
else:
    t = len(L)
    ans = L[(K - start_L) % t]
print(ans + 1)


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

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

 vector<vector<char>> chart(N,vector<char>(M));
 vector<vector<char>> answer(N,vector<char>(M));
 vector<bool> row(N,false);
 vector<bool> col(M,false);
 for (int i = 0; i < N; i++) {
   for (int j = 0; j < M; j++){
    cin >> chart.at(i).at(j);
   }
 }
 for (int i = 0; i < N; i++) {
   for (int j = 0; j < M; j++){
    if ((chart.at(i).at(j) == '#')){
      row.at(i) = true;
      col.at(j) = true;
    }
   }
 }
 for (int i = 0; i < N; i++) {
  if(row.at(i)) {
   for (int j = 0; j < M; j++){
    if (col.at(j))  cout << chart.at(i).at(j);
   }
   cout << endl; 
  }
 } 
}

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

using namespace std;

typedef long long LL;

struct cww{cww(){
    ios::sync_with_stdio(false);cin.tie(0);
}}star;
#define fin "\n"
#define FOR(i,bg,ed) for(int i=(bg);i<(ed);i++)
#define REP(i,n) FOR(i,0,n)

#define fi first
#define se second
#define pb push_back

template <typename T>inline void chmin(T &l,T r){l=min(l,r);}
template <typename T>inline void chmax(T &l,T r){l=max(l,r);}

template <typename T>
istream& operator>>(istream &is,vector<T> &v){
    for(auto &it:v)is>>it;
    return is;
}
int N;
LL s[112345];
int win(LL r,LL c){
    if(c==N){
        return (s[c]-r)%2;
    }
    if(r+1<=s[c+1]){
        return win(r+1,c+1);
    }
    if(s[c+1]<r){
        return (s[c]-r)%2;
    }
    else{
        return (s[c]-r)%2||!win(r,c+1);
    }
}
    
int main(){
    cin>>N;
    REP(i,N)
        cin>>s[i+1];
    sort(s+1,s+N+1);
    reverse(s+1,s+N+1);
    if(win(1,1))cout<<"First"<<endl;
    else cout<<"Second"<<endl;
    
    return 0;
}


Measured memory_bytes: 2560
# https://atcoder.jp/contests/agc036/tasks/agc036_a
import sys
sys.setrecursionlimit(12345678)
import itertools
from collections import Counter
from collections import defaultdict
from collections import deque
import bisect
from heapq import heappush, heappop


def main():
    S = int(input())

    y = -(-S // (10 ** 9))
    x = y * (10 ** 9) - S

    print(0, 0, 10 ** 9, 1, x, y)


if __name__ == '__main__':
    main()


Measured memory_bytes: 38256
#include <bits/stdc++.h>
#define ll long long
using namespace std;
 
int main() {
  int n;
  cin >> n;
  vector<pair<int, int>> vp(n);
  for (int i = 0; i < n; i++) {
    int a;
    cin >> a;
    vp.at(i).first = a;
    vp.at(i).second = i + 1;
  }

  sort(vp.begin(), vp.end());

  for (int i = 0 ; i < n; i++) {
    if (i < n - 1)
    cout << vp.at(i).second << " ";
    else
    cout << vp.at(i).second << endl;
  }
}

Measured memory_bytes: 1536
def e_all_you_can_eat():
    N, T = [int(i) for i in input().split()]
    Dishes = sorted([[int(i) for i in input().split()] for j in range(N)])

    # dp[i][j]: i 番目までの料理を j 分以内に完食できるように選んだとき、満足度の和の最大値
    dp = [[0] * (T + 1) for _ in range(N + 1)]
    ans = 0
    dp[0][0] = 0  # 食べていないときの満足度は 0 とする
    for i in range(1, N + 1):
        for j in range(T):
            dp[i][j] = dp[i - 1][j]  # i 番目を食べなかった場合

            # i 番目を食べることにした場合
            # (最後の料理は、ラストオーダー時刻が来ていなければ
            # 頼んで食いっぱなしにしてよいので、下の条件分岐と独立に考えてよい)
            ans = max(ans, dp[i][j] + Dishes[i - 1][1])

            # i 番目の料理を食べて j 分になることが可能なとき
            # (この条件を満たさないなら、i 番目の料理を食うと j 分以内に収まらない)
            if j - Dishes[i - 1][0] >= 0:
                dp[i][j] = max(dp[i][j],
                               dp[i - 1][j - Dishes[i - 1][0]] + Dishes[i - 1][1])
    return ans

print(e_all_you_can_eat())

Measured memory_bytes: 116312
#include <algorithm>
#include <bitset>
#include <cstdio>
#include <cstdlib>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#define REP(i, b, n) for (Int i = b; i < Int(n); i++)
#define rep(i, n) REP(i, 0, n)
using namespace std;
using Int = long long;
Int inf = 1000000000000000001LL;
using vi = vector<Int>;
using vvi = vector<vi>;

Int GCD(Int a, Int b){
if(b==0) return a;
if(a < b) return GCD(b, a);
unsigned r;
while ((r=a%b)) {
a = b;
b = r;
}
return b;
}

int main() {
    string S;
    cin >> S;
    int ans =0;
    int blue = 0;
    int red =0;
    rep(i,S.size()){
        if(S[i] == '0'){
            red++;
        }else{
            blue++;
        }
    }

    ans = min(red,blue)*2;

    cout << ans;
    return 0;
}

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

using namespace std;

typedef long long ll;
const ll INF = 1LL<<60;

ll gcd(ll a, ll b) {
  if(b == 0) return a;
  return gcd(b, a % b);
}

template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

ll modpow(ll a, ll n, ll mod) {
  ll res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}

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

  int N;
  cin >> N;

  vector<vector<pair<int, int>>> xy(N);

  int A, x, y;
  for(int i = 0; i < N; i++){
    cin >> A;
    for(int j = 0; j < A; j++){
      cin >> x >> y;
      x--;
      xy[i].push_back(make_pair(x, y));
    }
  }

  int ans = 0;
  for(int bit = 0; bit < (1<<N); ++bit){
    bool is_ok = true;
    int tmp_ans = 0;
    for(int i = 0; i < N; ++i){
      if(bit & (1<<i)){//i番目の人が正直
        tmp_ans++;
        //全部あっているか確認
        for(int j = 0; j < xy[i].size(); j++){
          x = xy[i][j].first;
          y = xy[i][j].second;
          if(bit & (1<<x)){
            if(y == 0){
              is_ok = false;
            }
          }else{
            if(y == 1){
              is_ok = false;
            }
          }
        }
      }
    }
    if(is_ok){
      chmax(ans, tmp_ans);
    }
  }

  cout << ans << endl;


  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define erep(i,a,b) for(int i=a;i<=(int)(b);++i)
#define per(i,a,b) for(int i=(b);i>(a);--i)
#define eper(i,a,b) for(int i=((int)(a));i>=b;--i)
#define pb push_back
#define mp make_pair
#define INF 2000000000
#define MOD 1000000007
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a/gcd(a, b)*b;}

ll n, c, k, ans;
vector<ll> v;  
int main() {
 ios::sync_with_stdio ( false );
 cin.tie ( 0 );
    cin >> n >> c >> k;
    rep(i, 0, n) {
        ll x; cin >> x;
        v.pb(x);
    }
    sort(v.begin(), v.end());
    v[n] = INF;
    rep(i, 0, n) {
        ll now = v[i], cnt = 1, x = v[i];
        while (v[i+1] <= now + k && cnt < c) {
            cnt++, i++;
        }
        ans++;
    }
    cout << ans << endl;
    return 0;
}


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

int find(string s,string t)
{
  int ans=0;
  for(int i=0;i<s.size();i++)
  {
    if(s[i]!=t[i])
      ans++;
  }
  return ans;
}
int main()
{
  int ans=INT_MAX;
  string s;string t;cin>>s>>t;
  for(int i=0;i<=s.size()-t.size();i++)
  {
    string str=s.substr(i,t.size());
    ans=min(ans,find(str,t));
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 3616
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;


public class Main {

	private BufferedReader reader = new BufferedReader(new InputStreamReader(System.in), 1);

	private String inputData = null;

	public String[] data = null;

	public int num = 0;

	public int count = 0;

	public HashMap<Integer, Integer> humanData = new HashMap<Integer, Integer>();

	public ArrayList<Integer> topId = new ArrayList<Integer>();

	public ArrayList<Integer> topLength = new ArrayList<Integer>();

	public static void main(String[] args) {
		new Main().start();
		System.exit(0);
	}

	public void start() {
		while (true) {
			try {
				this.inputData = reader.readLine();
			} catch (IOException e) {
				e.printStackTrace();
			}

			this.data = this.inputData.split(" ");

			if (this.data.length == 1) {
				if (this.data[0].equals("0")) {
					break;
				}
				try {
					this.num = Integer.parseInt(this.data[0]);
				} catch (Exception e) {
					continue;
				}

			}

			this.humanData.clear();

			for (int i = 0; i < this.num; i++) {
				try {
					this.inputData = reader.readLine();
				} catch (IOException e) {
					e.printStackTrace();
				}
				this.data = this.inputData.split(" ");

				this.humanData.put(Integer.parseInt(data[0]),
						Integer.parseInt(data[1]) + Integer.parseInt(data[2]));

			}

			Iterator<Integer> itId = this.humanData.keySet().iterator();
			int numCount = 0;
			while (itId.hasNext()) {
				int id = itId.next();
				if (numCount == 0) {
					this.topId.add(id);
					this.topLength.add(this.humanData.get(id));
				} else {
					if (this.topLength.get(count) <= this.humanData.get(id)) {
						this.topId.set(this.count, id);
						this.topLength.set(this.count, this.humanData.get(id));
					}
				}
				numCount++;
			}

			this.count++;

		}

		for (int i = 0; i < this.topId.size(); i++) {
			System.out.println(this.topId.get(i) + " " + this.topLength.get(i));
		}

	}

}

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

int main () {
  string s;
  int index1, index2, i;
  cin >> s;
  
  for(i=0; i<s.size();i++){
    if(s[i]=='A'){
      index1=i;
      break;
    }
  }
    
  for(i=s.size()-1; i>-1;i--){
    if(s[i]=='Z'){
      index2=i;
      break;
    }
  }
  
  cout << index2-index1+1;
}





Measured memory_bytes: 3724
#include<bits/stdc++.h>
using namespace std;
int main(int argc, char const *argv[]) {
    int n;
    scanf("%d", &n);
    int dp[2][3];
    int f = 0, a, b, c;
    dp[f][0] = dp[f][1] = dp[f][2] = 0;
    f = 1 - f;
    for(int i=0;i<n;++i){
        scanf("%d %d %d", &a, &b, &c);
        dp[f][0] = a + max(dp[1-f][1], dp[1-f][2]);
        dp[f][1] = b + max(dp[1-f][0], dp[1-f][2]);
        dp[f][2] = c + max(dp[1-f][0], dp[1-f][1]);
        f = 1 - f;
    }
    int ans = max(dp[1-f][0],dp[1-f][1]);
    ans = max(ans,dp[1-f][2]);
    printf("%d\n", ans);

    return 0;
}

Measured memory_bytes: 3708
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7/*998244353*/;
const ll INF = 1LL << 60;
ll mod_pow(ll, ll, ll); ll mod_fact(ll, ll); ll mod_inv(ll, ll); ll gcd(ll, ll); ll lcm(ll, ll);
//
int rec(vector<vector<int>>& graph, vector<int>& dp, int i){
    if(dp[i] != -1) return dp[i];
    int res = 0;
    for(auto to : graph[i]){
        res = max(res, rec(graph, dp, to) + 1);
    }
    return dp[i] = res;
}
int main(){
    int n, m;
    cin >> n >> m;
    vector<vector<int>> graph(n, vector<int>());
    vector<int> dp(n, -1);
    for(int i = 0; i < m; i++){
        int x, y;
        cin >> x >> y;
        x--; y--;
        graph[x].push_back(y);
    }
    int ans = 0;
    for(int i = 0; i < n; i++){
        ans = max(ans, rec(graph, dp, i));
    }
    cout << ans << "\n";
}

Measured memory_bytes: 8832
import numpy as np

nums = list(map(int, input().split()))
# N = int(input())

nums.sort()

min_  = nums[0]
mid = nums[1]
max_ = nums[2]

ans = 0
if (max_ - mid) % 2 == 1:
    mid += 1
    min_ += 1
    ans += 1
ans += (max_ - mid) // 2


if (max_ - min_) % 2 == 1:
    mid += 1
    max_ += 1
    ans += 1
ans += (max_ - min_) // 2

print(ans)

Measured memory_bytes: 12480