akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#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 equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
const ll mod = 1000000007;
//const ll mod = 998244353;
const int inf = 1e9 + 10;
const ll INF = 1e18;
const ld EPS = 1e-10;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

const ll MAX_V = 1e5;

struct edge {
  ll to, cap, rev;
};

vector<edge> G[MAX_V];
vector<bool> used(MAX_V, false);

void add_edge(ll from, ll to, ll cap, ll rcap=0) {
  G[from].push_back({to, cap, (ll)G[to].size()});
  G[to].push_back({from, rcap, (ll)G[from].size() - 1});
}

ll dfs(ll v, ll t, ll f) {
  if (v == t) return f;
  used[v] = true;
  rep(i, G[v].size()) {
    edge &e = G[v][i];
    if (!used[e.to] && e.cap > 0) {
      ll d = dfs(e.to, t, min(f, e.cap));
      if (d > 0) {
        e.cap -= d;
        G[e.to][e.rev].cap += d;
        return d;
      }
    }
  }
  return 0;
}

ll max_flow(ll s, ll t) {
  ll flow = 0;
  while (1) {
    rep(i, used.size()) used[i] = false;
    ll f = dfs(s, t, INF);
    if (f == 0) return flow;
    flow += f;
  }
}


int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout << fixed << setprecision(25);

  int h, w;
  cin >> h >> w;
  vector<vector<char>> a(h, vector<char>(w));
  rep(i, h) rep(j, w) cin >> a[i][j];

  int s = h + w, t = s + 1;
  rep(i, h) {
    rep(j, w) {
      if (a[i][j] != '.') add_edge(i, h + j, 1, 1);
      if (a[i][j] == 'S') add_edge(s, i, INF), add_edge(s, h + j, INF);
      if (a[i][j] == 'T') add_edge(i, t, INF), add_edge(h + j, t, INF);
    }
  }
  ll ans = max_flow(s, t);
  if (ans >= INF) ans = -1;
  cout << ans << '\n';


  




  
  return 0;
}

Measured memory_bytes: 6440
#include <iostream>
#include <vector>

using namespace std;

const int INIVAL = (1<<31) - 1;

class SegmentTree{
public:
    int n; //array size
    vector<int> D; //minimum values for the range represented by node i of the segment tree
    //
    void initRMQ(int n_);
    void update(int k, int x);
    int findMin(int a, int b);
    int query(int node, int start, int end_, int l, int r);
    //
    void printTree();
};

void getin();

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

void getin(){
    SegmentTree ist;
    int N, L, a;
    //
    cin >> N >> L;
    ist.initRMQ(N);
    vector<int> out(N-L+1);
    // get the whole array
    for (int i = 0; i < N; i++) {
        cin >> a;
        ist.update(i,a);
    }
    // calculate output
    for (int i = 0; i < N-L; i++) {
        cout << ist.findMin(i, i+L-1) << " ";
    }
    cout << ist.findMin(N-L, N-1);
    cout << endl;
}

void SegmentTree::initRMQ(int n_) {
    n = 1;
    while (n<n_) {n *= 2;}
    D = vector<int>(2*n-1, INIVAL);
}

void SegmentTree::printTree() {
    cout << "segtree: " << endl;
    for (int i = 0; i < D.size(); i++) {
        cout << fixed << this->D[i] << "\t";
    }
    cout << endl;
}

void SegmentTree::update(int k, int x) {
    k += n - 1;
    D[k] = x;
    while (k > 0) {
        k = (k-1)/2;
        D[k] = min(D[k*2+1], D[k*2+2]);
    }
}

int SegmentTree::findMin(int a, int b) {
    return query(0, 0, n-1, a, b);
}

// given searching range a[l], ... a[r]
int SegmentTree::query(int node, int start, int end_, int l, int r) {
    if ((r < start) || (end_ < l)) {
        // the range presented by the current node is completely outside the given (searching) range
        return INIVAL;
    }
    else if ((l <= start) && (end_ <= r)) {
        // completely inside the given range
        return D[node];
    }
    else { // partly inside and partly outside
        int mid = (start+end_)/2;
        int vl = query(2*node+1, start, mid, l, r);
        int vr = query(2*node+2, mid+1, end_, l, r);
        return min(vl, vr);
    }
}



Measured memory_bytes: 19256
#include <iostream>
#include <algorithm>
#include <string>
#include <math.h>
#include <bitset>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include<iomanip>

#define i64 int64_t
#define ff(ii,nn,mm) for(int ii=nn;ii<mm;ii++)
#define ffrvs(ii,nn,mm) for(int ii=nn;ii>=mm;ii--)
#define srt(vvv) sort(vvv.begin(),vvv.end())
#define srtrvs(vvv) reverse(vvv.begin(),vvv.end())
#define Graph vector<vector<int>>
i64 inf = 1000000007;
i64 giant = 4000000000000000037;

using namespace std;

//メモリ置き場
int n, k;
i64 sum = 0;
vector<i64> hp;

//inputします
void input() {
	cin >> n >> k;
	hp.resize(n);
	ff(i, 0, n) {
		cin >> hp[i];
		sum += hp[i];
	}
	srt(hp);
	srtrvs(hp);
}

//ライブラリ置き場


//main
int main() {
    input();
	if (k > n)k = n;
	ff(i, 0, k) {
		sum -= hp[i];
	}
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<P,int> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-8;
const ll mod=1e9+7;
const int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};

int n,m;
vi a,b;
vvi g;

void dfs(int v,int t){
	b[v]=t;
	for(auto u:g[v]) if(b[u]==-1) dfs(u,t);
}

int main(){
	cin>>n>>m;
	a=vi(n);
	b=vi(n,-1);
	g=vvi(n);
	for(int i=0;i<n;i++){
		cin>>a[i];
		a[i]--;
	}
	for(int i=0;i<m;i++){
		int u,v;
		cin>>u>>v;
		u--;v--;
		g[u].push_back(v);
		g[v].push_back(u);
	}
	int res=0,t=0;
	for(int i=0;i<n;i++) if(b[i]==-1) dfs(i,t++);
	for(int i=0;i<n;i++) if(b[i]==b[a[i]]) res++;
	cout<<res<<endl;
}

Measured memory_bytes: 8576
#include<stdio.h>
#include<math.h>

int main(){
	int N,K,min,i,left,right;
	scanf("%d %d",&N,&K);
	int x[N];
	for(i=0;i<N;i++) scanf("%d",&x[i]);
	
	min=2*abs(x[0])+2*abs(x[N-1]);
	
	for(i=0;i<=N-K;i++){
		left=x[i],right=x[K-1+i];
		if((left>0&&right>0)||(left<0&&right<0)){
			if(abs(left)>abs(right)){
				if(min>abs(left)) min=abs(left);
			}
			else{
				if(min>abs(right)) min=abs(right);
			}
		}
		else{
			if(min>2*abs(left)+abs(right)) min=2*abs(left)+abs(right);
			if(min>abs(left)+2*abs(right)) min=abs(left)+2*abs(right);
		}
	}
	
	printf("%d",min);
}

Measured memory_bytes: 512
flg = False
s = input()
s1, s2, s3, s4 = s[:1], s[1:2], s[2:3], s[3:4]
if s1 == s2 and s3 == s4:
	flg = True
elif s1 == s3 and s2 == s4:
	flg = True
elif s1 == s4 and s2 == s3:
	flg = True

if s1==s2 and s1==s3:
	flg = False

if flg == True:
	print("Yes")
else:
	print("No")
print()

Measured memory_bytes: 3064
N,M = [int(s) for s in input().split()]
pre_lst=[]
for i in range(N):
  pre_lst.append([int(s) for s in input().split()])
lst = sorted(pre_lst, key=lambda x: x[0])
count=0
cost=0
for e in lst:
  count+=e[1]
  cost+=e[0]*e[1]
  if(count>=M):
    cost-=e[0]*(count-M)
    break
print(cost)


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

using namespace std;
using ll = long long;

#define REP(i, n) for (ll i = 0; i < n; i++)
#define INF 9223372036854775807
#define all(x) (x).begin(), (x).end()

ll ts = 1000000007;

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

  string s;
  cin >> s;

  cout << (s.find("AC") != std::string::npos ? "Yes" : "No") << "\n";
}

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

int main() {
    int N; long long C, K;
    cin >> N >> C >> K;
    vector<long long> T(N);
    for (int i = 0; i < N; i++) cin >> T[i];
    sort(T.begin(), T.end());

    long long ans = 0;
    for (int i = 0; i < N;) {
        long long limit = T[i] + K;
        long long person = 0;
        while (person < C && i + person < N) {
            if (T[i + person] <= limit) person++;
            else break;
        }
        ans++;
        i += person;
    }
    cout << ans << endl;
}

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

using namespace std;
using LL = long long;

constexpr int N = 1e5 + 5;

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

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

    vector< bool> inS(26, false), inT(26, false);
    for (char &c : s) inS[c - 'a'] = true;
    for (char &c : t) inT[c - 'a'] = true;

    for (int i = 0; i < 26; i++) {
        if (inT[i] && !inS[i]) return cout << "-1\n", 0;
    }

    int n = s.size();
    vector< vector< int>>nxt(n + 5, vector< int>(26, -1));
    for (int i = n - 1; i >= 0; i--) {
        for (int j = 0; j < 26; j++) {
            nxt[i][j] = nxt[i + 1][j];
        }
        nxt[i][s[i] - 'a'] = i;
    }   

    LL result = 0;
    int pos = 0;

    for (const char& c : t) {
        if (nxt[pos][c - 'a'] == -1) {
            result += n;
            pos = 0;
        }
        pos = nxt[pos][c - 'a'] + 1;
    }

    cout << result + pos << endl;
}

Measured memory_bytes: 13904
import copy
N, M, Q = map(int, input().split())
A = []
B = []
C = []
D = []
ans = 0
def dfs(l):
    if len(l) == N+1:
        global ans
        now = 0
        for i in range(Q):
            if(l[B[i]] - l[A[i]] == C[i]):
                now += D[i]
        ans = max(ans, now)
    else:
        tmp = copy.copy(l)
        tmp.append(l[-1])
        while tmp[-1] <= M:
            dfs(tmp)
            tmp[-1] += 1

for i in range(Q):
    a, b, c, d = map(int, input().split())
    A.append(a)
    B.append(b)
    C.append(c)
    D.append(d)

dfs([1])
print(ans)

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

using namespace std;
// ascending order
#define vsort(v) sort(v.begin(), v.end())
// descending order
#define vsort_r(v) sort(v.begin(), v.end(), greater<int>())
#define vunique(v) unique(v.begin(), v.end())
#define mp make_pair
#define ts(x) to_string(x)
#define rep(i, a, b) for(int i = (int)a; i < (int)b; i++)
#define repm(i, a, b) for(int i = (int)a; i > (int)b; i--)
#define bit(a) bitset<8>(a)
#define des_priority_queue priority_queue<int, vector<int>, greater<int> >
#define all(v) (v).begin(), (v).end()
typedef long long ll;
typedef pair<int, int> P;
const ll INF = 1e18;

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

	ll a, b;
	cin >> a >> b;

	if(1ll <= a) cout << "Positive" << endl;
	else if(a <= 0ll and 0ll <= b) cout << "Zero" << endl;
	else {
		ll tmp = abs(a - b) + 1;
		if(tmp % 2 == 0) cout << "Positive" << endl;
		else cout << "Negative" << endl;
	}
}


Measured memory_bytes: 256
from operator import itemgetter

def main():
    N = int(input())
    
    red = [[int(i) for i in input().split()] for i in range(N)]
    blue = [[int(i) for i in input().split()] for i in range(N)]

    # 青よりx,y座標のが小さい赤の中で、最もyが大きいものから削除するため
    # 青はxでソート、赤はyで大きい順でソートする
    sort_red = sorted(red, key=itemgetter(1), reverse=True)
    sort_blue = sorted(blue, key=itemgetter(0))

    cnt = 0
    for b in sort_blue:
        for r in sort_red:
            if r[0] < b[0] and r[1] < b[1]:
                cnt += 1
                sort_red.remove(r)
                break
    print(cnt)


main()

Measured memory_bytes: 38896
N = int(input())
c = list(input())

iRs = []
iWs = []
for i in range(N):
    i_inv = N - 1 - i
    if c[i] == 'W':
        iWs.append(i)
    if c[i_inv] == 'R':
        iRs.append(i_inv)
iRs.append(-1)
iWs.append(N)

ans = 0
for i in range(min(len(iRs), len(iWs))):
    iW = iWs[i]
    iR = iRs[i]
    #
    if iW >= iR:
        break
    else:
        ans += 1

print(ans)

Measured memory_bytes: 18636
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi=vector<int>;using vvi=vector<vi>;using vl=vector<ll>;
using P=pair<int,int>;using PL=pair<ll,ll>;using vp=vector<P>;
const int INF=1<<30,MOD=1000000007;const ll LINF=1ll<<60;
#define _ol3(_1,_2,_3,name,...) name
#define _rep(i,n) _repi(i,0,n)
#define _repi(i,a,b) for(int i=a,i##_l=(b);i<i##_l;++i)
#define REP(...) _ol3(__VA_ARGS__,_repi,_rep,)(__VA_ARGS__)
#define REPR(i,n) for(int i=n-1;i>=0;--i)
#define REPA(i,v) REP(i,v.size())
#define all(v) (v).begin(),(v).end()
#define bit(n) (1ll<<(n))
#define clamp(n,mi,ma) max(min(n,ma),mi)
#define uniq(v) sort(all(v));v.erase(unique(all(v)),v.end())
#define pb push_back
#define F first
#define S second
#define endl '\n'
#define cho(n,a,b) cout<<((n)?a:b)<<endl
#define YES(n) cho(n,"YES","NO")
#define Yes(n) cho(n,"Yes","No")
#define Poss(n) cho(n,"Possible","Impossible")
template<class T>bool chmax(T&a,const T&b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T&a,const T&b){if(a>b){a=b;return 1;}return 0;}
template<class T>ostream&operator<<(ostream&o,const vector<T>&v){for(const T&i:v)o<<i<<' ';return o;}
template<class T>istream&operator>>(istream&i,vector<T>&v){for(T&j:v)i>>j;return i;}
template<class T,class U>ostream&operator<<(ostream&o,const pair<T,U>&p){return o<<p.F<<' '<<p.S;}
template<class T,class U>istream&operator>>(istream&i,pair<T,U>&p){return i>>p.F>>p.S;}
template<class T>ostream&operator<<(ostream&o,const set<T>&v){for(const T&i:v)o<<i<<' ';return o;}
template<class T>ostream&operator<(ostream&o,const T&t){return o<<t;}
template<class T>istream&operator>(istream&i,T&t){return i>>t;}
#ifndef LOCAL
struct ostdmy{
template<class T>ostdmy&operator<<(const T&t){return*this;}
template<class T>ostdmy&operator<(const T&t){return*this;}};ostdmy cer_;
#define cerr cer_
#endif
int main(){
    cin.tie(0);ios::sync_with_stdio(0);
    vi a(5);
    cin>a;
    int ans=0;
    int ma=0;
    REP(i,5){
        cerr<<(a[i]+9)/10*10<<' '<<a[i]<<endl;
        chmax(ma,(a[i]+9)/10*10-a[i]);
        ans+=(a[i]+9)/10*10;
    }
    cerr<<ma<<endl;
    cout<ans-ma<endl;
    return 0;
}


Measured memory_bytes: 256
// #pragma GCC optimize("O3")
#include <bits/stdc++.h>

using namespace std;

using ll = long long;
using vll = vector<ll>;
using vii = vector<int>;
using pii = pair<int, int>;
template <typename T = vii> 
using vec = vector<T>;

const ll INF = 1e18, MOD = 1e9 + 7;

const int MAX = 1e6;

int main() {
    cin.tie(NULL);
    ios_base::sync_with_stdio(false);
    // freopen("in.in", "r", stdin);
    
    int n;
    cin >> n;
    vec<pii> v(n);
    for (int i = 0; i < n; i++) {
        cin >> v[i].first;
        v[i].second = i;
    }
    sort(v.begin(), v.end());
    vii res(n);
    const int m = n / 2;
    for (int i = 0; i < n; i++) {
        res[v[i].second] = v[m - (m <= i)].first;
    }
    for (int e : res) {
        cout << e << '\n';
    }
}

Measured memory_bytes: 4608
#include <iostream>

using namespace std;

int main(){
    long long N,A,B,C,D;
    cin >> N >> A >> B >> C >> D;

    for(int i=0;i<N-1;i++){
        long long left  = C*i - (N-1-i)*D;
        long long right = D*i - (N-1-i)*C;

        if(left <= B-A && B-A <= right){
            cout << "YES" << endl;
            return 0;
        }
    }

    cout << "NO" << endl;
    return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
# ITP1_8_C
# 文字のカウント

alphabet = "abcdefghijklmnopqrstuvwxyz"
ansdict = {}
data = ""

try:
    while 1:
        data += input()        
except EOFError:
    pass

data = data.lower()

for i in data:
    if i in ansdict.keys():
        ansdict[i] += 1
    else:
        ansdict[i] = 1
for i in alphabet:
    print("{} : {}".format(i, ansdict.get(i, 0)))
    


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

#define int long long
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define all(v) (v).begin(),(v).end()
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
#define pb push_back
#define fi first
#define se second
template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

struct T{
    int l,r,x;
    T(int a,int b,int c):l(a),r(b),x(c){}
    bool operator<(const T &t)const{
        if(t.l!=l)return l<t.l;
        if(t.r!=r)return r<t.r;
        return x<t.x;
    }
};

signed main(){
    int N,Q;
    scanf("%lld%lld",&N,&Q);
    set<T>s;
    s.insert(T(0,N,0));
    s.insert(T(N,1001001001,1001001001));
    while(Q--){
        int a,b;
        scanf("%lld%lld",&a,&b);
        auto it=s.lower_bound(T(a,-1,-1));
        if(it->l!=a){
            it--;
            int l=it->l,r=it->r,x=it->x;
            s.erase(it);
            s.insert(T(l,a,x));
            s.insert(T(a,r,x));
        }

        while(b){
            it=s.lower_bound(T(a,-1,-1));
            it--;
            bool isend=false;
            if(it==s.begin())isend=true;
            else{
                auto jt=it;
                jt--;
                if((jt->x-it->x)*(it->r-it->l)>b)isend=true;
            }
            int l=it->l,r=it->r,x=it->x;
            if(isend){
                s.erase(it);
                x+=b/(it->r-it->l);
                b%=(it->r-it->l);
                if(b){
                    s.insert(T(l,l+b,x+1));
                    s.insert(T(l+b,r,x));
                }
                else{
                    s.insert(T(l,r,x));
                }
                b=0;
            }
            else{
                auto jt=it;
                jt--;
                b-=(jt->x-it->x)*(it->r-it->l);
                l=jt->l;
                x=jt->x;
                s.erase(it);s.erase(jt);
                s.insert(T(l,r,x));
            }
        }
    }

    each(it,s){
        if(it->l==N)break;
        rep(i,it->r-it->l)printf("%lld\n",it->x);
    }
    return 0;
}


Measured memory_bytes: 7680
#include <iostream>
#include <stack>

using namespace std;


int main()
{
    int n;

    cin >> n;

    while(n!=0) {
        int color;
        stack<pair<int,int> > board; // color, length

        for(int i=0; i<n; ++i) {
            cin >> color;
            if(i%2==0) {
                if(board.empty()) {
                    board.push(make_pair(color,1));
                } else {
                    pair<int,int> b=board.top();
                    if(b.first!=color) {
                        board.push(make_pair(color,1));
                    } else {
                        board.pop();
                        board.push(make_pair(color,b.second+1));
                    }
                }
            } else {
                pair<int,int> b=board.top(); board.pop();
                if(board.empty()||b.first==color) {
                    board.push(make_pair(color,b.second+1));
                } else {
                    pair<int,int> bb=board.top(); board.pop();
                    board.push(make_pair(color,bb.second+b.second+1));
                }
            }
        }

        int ans=0;
        while(!board.empty()) {
            pair<int,int> b=board.top(); board.pop();
            if(b.first==0) ans+=b.second;
        }

        cout << ans << endl;

        cin >> n;
    }
    return 0;
}

Measured memory_bytes: 3000
N=int(input())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
C=list(map(int,input().split()))


sum=sum(B)
cnt=0
for i in range(1,N):
  if A[i-1]+1==A[i]:
    s=A[i]-1
    cnt=C[s-1]+cnt

print(sum+cnt)

Measured memory_bytes: 3064
#ifndef UTIL_INCLUDED
#define UTIL_INCLUDED

#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define ALL(V) (V).begin(), (V).end()
#define ALLR(V) (V).rbegin(), (V).rend()
// #define DEBUGGING

template <typename T> using V = vector<T>;
template <typename T> using VV = V<V<T>>;
template <typename T, typename U> using P = pair<T, U>;
using ll = int64_t;
using PLL = P<ll, ll>;

template <typename T> const T& var_min(const T &t) { return t; }
template <typename T> const T& var_max(const T &t) { return t; }
template <typename Head, typename... Tail> const Head& var_min(const Head &head, const Tail&... tail) { return min(head, var_min(tail...)); }
template <typename Head, typename... Tail> const Head& var_max(const Head &head, const Tail&... tail) { return max(head, var_max(tail...)); }
template <typename T, typename... Tail> void chmin(T &t, const Tail&... tail) { t = var_min(t, tail...); }
template <typename T, typename... Tail> void chmax(T &t, const Tail&... tail) { t = var_max(t, tail...); }

namespace __init {

struct InitIO {
    InitIO() {
        cin.tie(0);
        ios_base::sync_with_stdio(false);
        cout << fixed << setprecision(30);
    }
} init_io;

}

#ifndef DEBUG_FILE
#ifdef DEBUGGING
#include "../debug.cpp"
#else
#define DEBUG(...) 0
#endif
#endif

#endif

const ll MOD = 998244353;

bool check(ll a, ll b, ll c) {
    return a + b > c && b + c > a && c + a > b;
}

int main() {
    ll N;
    cin >> N;
    V<ll> A;
    V<ll> sum(N + 1);
    for(ll i = 0; i < N; i++) {
        ll a;
        cin >> a;
        A.push_back(a);
    }
    sort(ALL(A));
    for(ll i = 0; i < N; i++) {
        ll a = A[i];
        sum[i + 1] = sum[i] + a;
    }

    V<ll> dp(sum[N] + 1, 0);
    dp[0] = 1;
    for(ll i = 0; i < N; i++) {
        for(ll j = sum[N]; j >= 0; j--) {
            (dp[j] *= 2) %= MOD;
            if(j >= A[i]) (dp[j] += dp[j - A[i]]) %= MOD;
        }
    }
    ll ans = 1;
    DEBUG(dp);
    for(ll i = 0; i < N; i++) (ans *= 3) %= MOD;
    for(ll i = sum[N] / 2 + (sum[N] % 2); i < dp.size(); i++) {
        ll tmp = dp[i] * 3;
        tmp %= MOD;
        tmp = MOD - tmp;
        (ans += tmp) %= MOD;
    }
    if(sum[N] % 2 == 0) {
        V<ll> dp(sum[N] + 1, 0);
        dp[0] = 1;
        for(ll i = 0; i < N; i++) {
            for(ll j = sum[N]; j >= 0; j--) {
                if(j >= A[i]) (dp[j] += dp[j - A[i]]) %= MOD;
            }
        }
        (ans += dp[sum[N] / 2] * 3 % MOD) %= MOD;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1664
let log2 n = log n /. log 2.

let _ =
  Scanf.scanf "%d %d" @@ fun n k ->
    let sum = ref 0. in
    let n' = float n in
    let k' = float k in
    for i = 1 to n do
      let p = max 0. (log2 (k' /. float i)) |> ceil in
      sum := !sum +. 1. /. n' *. (0.5 ** p)
    done;
    Printf.printf "%.12f\n" !sum

Measured memory_bytes: 2560
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#include<cmath>
#include<queue>
#include<vector>
#include<ctime>
#include<map>
#include<bitset>
#include<set>
#define LL long long
#define mp(x,y) make_pair(x,y)
#define pll pair<long long,long long>
#define pii pair<int,int>
using namespace std;
inline int read()
{
	int f=1,x=0;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}
int stack[20];
template<typename T>inline void write(T x)
{
	if(x<0){putchar('-');x=-x;}
    if(!x){putchar('0');return;}
    int top=0;
    while(x)stack[++top]=x%10,x/=10;
    while(top)putchar(stack[top--]+'0');
}
template<typename T>inline void pr1(T x){write(x);putchar(' ');}
template<typename T>inline void pr2(T x){write(x);putchar('\n');}
const int MAXN=3005;
struct edge{int x,y,next;}a[2*MAXN];int len,last[MAXN];
void ins(int x,int y){len++;a[len].x=x;a[len].y=y;a[len].next=last[x];last[x]=len;}
int cal[MAXN],id[MAXN],n,vis[MAXN];
bool cmp(int n1,int n2){return cal[n1]<cal[n2];}
int main()
{
	n=read();
	for(int i=1;i<=n;i++)cal[i]=read(),id[i]=i;
	for(int i=1;i<n;i++)
	{
		int x=read(),y=read();
		ins(x,y);ins(y,x);
	}sort(id+1,id+1+n,cmp);
	for(int i=1;i<=n;i++)
	{
		int x=id[i];
		for(int k=last[x];k;k=a[k].next)
		{
			int y=a[k].y;
			if(cal[y]<cal[x]&&!vis[y])vis[x]=1;
		}
	}
	for(int i=1;i<=n;i++)if(vis[i])pr1(i);
	puts("");
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<cmath>
#include<map>
#include<iomanip>
#include<numeric>
#include<queue>
#include<functional>
#include<tuple>
#include<math.h>
#include<bitset>
#include<stack>
#include<set>
#define rip(i,n) for(int i=0;i<n;i++)
#define ll long long
#define ld long double
#define pi 3.1415926
#define MOD 998244353
#define sec setprecision
using namespace std;
ll gcd(ll a, ll b)
{
	if (a % b == 0)	return(b);
	else return(gcd(b, a % b));
}
ll lcm(ll a, ll b)
{
	return a * b / gcd(a, b);
}
ll pow(ll x, ll n,ll m) {
	if (n == 0)
		return 1;
	if (n % 2 == 0)
		return pow(x * x % m, n / 2, m);
	else
		return x * pow(x, n - 1, m) % m;
}
ll pow(ll x, ll n) {
	if (n == 0)
		return 1;
	else if (x == 1)return(1);
	else if (n % 2 == 0)
		return pow(x * x , (n / 2));
	else
		return x * pow(x, n - 1);
}
int ketasuu(ll h) {
	if (h < 0)return(-(ketasuu(-h)));
	else if (h < 10)return(1);
	else return(1 + ketasuu(h / 10));
}
const int MAX = 510000;
long long fac[MAX], finv[MAX], inv[MAX];
void cominit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (ll i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 二項係数計算
long long com(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main() {
	int n;
	cin >> n;
	int k = n % 10;
	if (k == 3)cout << "bon" << endl;
	else if (k == 0 || k == 1 || k == 6 || k == 8)cout << "pon" << endl;
	else cout << "hon" << endl;
}


Measured memory_bytes: 3640
#include <complex.h>
#include <math.h>
#include <iostream>
#include <stdio.h>
#include <complex>
#include <cmath>
using namespace std;
typedef long long ll;
int mod= 1000000007;
ll po(ll a,ll b){
	if (b==0)return 1;
	ll z = po(a,b/2);
	z = z*z%mod;
	if(b%2==1)z = z*a%mod;
	return z;
}

int main(){
	ll kai[500005];
	kai[0]=1;
	for(int i=1;i<500005;i++){
		kai[i]=(kai[i-1]*i)%mod;
	}
	ll invkai[500005];
	invkai[0]=1;
	for(int i=1;i<500005;i++){
		invkai[i]=po(kai[i],1000000005)%mod;
	}
	ll H,W,A,B,count=0;
	cin>>H>>W>>A>>B;
	for(int i=B;i<W;i++){
		count +=(kai[H-A-1+i]*invkai[H-A-1]%mod*invkai[i]%mod)*(kai[A-2+W-i]*invkai[A-1]%mod*invkai[W-i-1]%mod);
		count = count%mod;
	}
	cout << count << endl;
}

Measured memory_bytes: 8064
#include<iostream>
#include <string>
#include<vector>
#include<algorithm>
typedef long long ll;

using namespace std;
int main()
{
	int n;
	cin >> n;
	vector<int> as(n);
	for (int i = 0; i < n; i++) {
		cin >> as[i];
	}
	sort(as.begin(), as.end());
	cout << as[n - 1] - as[0];
	return 0;
}

Measured memory_bytes: 256
fun main(args: Array<String>) {
	val (x, y) = readLine()!!.split(" ").map{ it.toInt() }
	val a = intArrayOf(1, 3, 5, 7, 8, 10, 12)
	val b = intArrayOf(4, 6, 9, 11)
	val c = intArrayOf(2)
	if ((x in a && y in a) || (x in b && y in b) || (x in c && y in c)) {
		println("Yes")
	} else {
		println("No")
	}
}


Measured memory_bytes: 37980
from collections import Counter

import sys


def input():
    return sys.stdin.readline()[:-1]


N = int(input())
A = list(map(int, input().split()))
ac = Counter(A)

a_sum = sum(A)
Q = int(input())
for _ in range(Q):
    b, c = map(int, input().split())

    if b in ac:
        a_sum += (c-b)*ac[b]
        ac[c] += ac[b]
        del ac[b]
    print(a_sum)


Measured memory_bytes: 21276
// dfmt off
T lread(T=long)(){return readln.chomp.to!T;}T[] lreads(T=long)(long n){return iota(n).map!((_)=>lread!T).array;}
T[] aryread(T=long)(){return readln.split.to!(T[]);}void arywrite(T)(T a){a.map!text.join(' ').writeln;}
void scan(L...)(ref L A){auto l=readln.split;foreach(i,T;L){A[i]=l[i].to!T;}}alias sread=()=>readln.chomp();
void dprint(L...)(lazy L A){debug{auto l=new string[](L.length);static foreach(i,a;A)l[i]=a.text;arywrite(l);}}
static immutable MOD=10^^9+7;alias PQueue(T,alias l="b<a")=BinaryHeap!(Array!T,l);import std;
// dfmt on

void main()
{
    long N, A, B;
    scan(N, A, B);
    if (B < A)
    {
        writeln(0);
        return;
    }
    if (N == 1 && A != B)
    {
        writeln(0);
        return;
    }
    long m = A * (N - 1) + B;
    long M = A + B * (N - 1);
    writeln(M - m + 1);
}


Measured memory_bytes: 3584
#include <iostream>
#include <map>
#include <string>

using namespace std;
int main(void) {
    int n;
    cin >> n;
    map<string, int> m;
    map<string, int>::iterator it;
    string t;
    for (int i = 0; i < n; i++) {
        cin >> t;
        it = m.find(t);
        if (it == m.end()) {
            m[t] = 1;
        }
        else {
            it->second++;
        }
    }
    int max = 0;
    for (it = m.begin(); it != m.end(); it++) {
        //cout << it->first << " " << it->second << '\n';
        max = it->second > max ? it->second : max;
    }
    for (it = m.begin(); it != m.end(); it++) {
        if (it->second == max) {
            cout << it->first << '\n';
        }
    }
}

Measured memory_bytes: 25216
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <math.h>
#include <vector>
#include <string>
#include <queue>
#include <numeric>

using namespace std;

typedef long long int ll;
typedef long int li;

bool compare_by_b(pair<int, int> a, pair<int, int> b) {
    if(a.second != b.second){
        return a.second < b.second;
    }else{
        return a.first < b.first;
    }
}

int fnc(int k){
    if(k%5==0)return 1;
    if(k%5==1)return 4;
    if(k%5==2)return 16;
    if(k%5==3)return 2;
    if(k%5==4)return 8;
}

int main() {
    ll ans=0;
    ll n,k;
    cin >> n >> k;
	if(k==1);
  	else ans = n - k;
  	cout << ans << endl;
    return 0;
}

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

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

const int MAX = 1e5 + 10;
const int INF = 1e9;
const int MOD = 1e9 + 7;

int N, A[MAX];

int main(){
    cin >> N;
    rep(i, N) cin >> A[i];

    sort(A, A+N);

    ll ans = 1;
    if(N % 2){
        if(A[0] != 0){
            cout << 0 << endl;
            return 0;
        }
        for(int i = 1; i < N; i+=2){
            if(A[i] == i + 1 && A[i+1] == i + 1){
                ans *= 2;
                ans %= MOD;
            } else {
                cout << 0 << endl;
                return 0;
            }
        }
    } else {
        for(int i = 0; i < N; i+=2){
            if(A[i] == i + 1 && A[i+1] == i + 1){
                ans *= 2;
                ans %= MOD;
            } else {
                cout << 0 << endl;
                return 0;
            }
        }
    }

    cout << ans << endl;
}

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

int main(void){
    string s;
    cin >> s;
    
    bool ab[26] = {false};
    int i;
    for(i = 0; i < s.length(); i++){
        ab[s[i] - 'a'] = true;
    }
    
    for(i = 0; i < 26; i++){
        if(!ab[i]){
            cout << (char)(i + 'a') << endl;
            return 0;
        }
    }
    
    cout << "None" << endl;
    
    return 0;
}


Measured memory_bytes: 512
#include<stdio.h>
#include<stdlib.h>

#define max(a,b) ((a)>(b)?(a):(b))

int compare_int(const void *a,const void *b){
	if( *(long long*)b>*(long long*)a)return 1;
	if( *(long long*)b==*(long long*)a)return 0;
	if( *(long long*)b<*(long long*)a)return -1;
}

struct sushi{
	long long d;
	int t;
};

long long heap[100000],sz=0;

void prio_push(long long x){
	int i=sz++;
	while(i>0){
		int p=(i-1)/2;
		if(heap[p]<=x)break;
		heap[i]=heap[p];
		i=p;
	}
	heap[i]=x;
}

long long prio_pop(){
	long long ret=heap[0];
	long long x=heap[--sz];
	int i=0;
	while(i*2+1<sz){
		int a=i*2+1,b=i*2+2;
		if(b<sz&&heap[b]<heap[a])a=b;
		if(heap[a]==x)break;
		heap[i]=heap[a];
		i=a;
	}
	heap[i]=x;
	return ret;
}

long long prio_r(){
	return heap[0];
}

int main(){
	int n,k;long long i;
	struct sushi td[100000];
	long long ans=0,v=0,anss[100000]={0};
	int va[100001]={0};
	scanf("%d%d",&n,&k);
	for(i=0;i<n;i++)scanf("%d%lld",&td[i].t,&td[i].d);
	qsort(td,n,sizeof(struct sushi),compare_int);
	for(i=0;i<k;i++){
		ans+=td[i].d;
		if(va[td[i].t]>0)prio_push(td[i].d);
		va[td[i].t]++;
	}
	for(i=0;i<=n;i++)v+=(va[i]>0?1:0);
	int vv=v;
	for(i=0;i<=n;i++)anss[i]=ans;
	for(i=k;i<n;i++){
		if(va[td[i].t]==0&&sz>0&&v<=k){
			long long tmp=prio_pop();
			v++;
			anss[v]=anss[v-1]-tmp+td[i].d;
			va[td[i].t]++;
//			anss[v]+=v*v;
		}
	}
	for(i=vv;i<=v;i++)ans=max(ans,anss[i]+i*i);
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 4476
/*
This code By @1353055672(Ligen)
[Warning]You're not excepted to understand this code!
RP++
*/
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<queue>
#define ll long long
#define ull unsigned long long
#define mn 1000020
#define FOR(a,b,c) for (int a=b;a<=c;a++)
#define FORD(a,b,c) for (int a=b;a>=c;a--)
using namespace std;
inline ll read(){
    ll x=0,f=1;
    char c=getchar();
    while (c<'0'||c>'9'){
        if (c=='-')f=-1;
        c=getchar();
    }
    while (c>='0'&&c<='9'){
        x=x*10+c-'0';
        c=getchar();
    }
    return x*f;
}
inline int Max(int a,int b){return (a>b)?a:b;}
inline int Min(int a,int b){return (a<b)?a:b;}
inline int Abs(int x){return (x<0)?-x:x;}
int a[100020];
int main(){
	int n=read(),k=read(),x;
	a[0]=-1;
	FOR(i,1,n){
		a[i]=read();
		if(a[i]==0||(a[i-1]<0&&a[i]>0))x=i;
	}
	int ans=2147483647,l=(a[x]==0)?Max(1,x-k+1):Max(1,x-k);
//	cout<<l<<' '<<x<<endl;
	FOR(i,1,n){
		if(i+k-1>n)break;
		if(a[i]<=0&&a[i+k-1]<=0)ans=Min(ans,Abs(a[i]));else
		if(a[i]<=0&&a[i+k-1]>=0)ans=Min(ans,Min(Abs(a[i])*2+a[i+k-1],a[i+k-1]*2+Abs(a[i])));
		else ans=Min(ans,a[i+k-1]);
//		cout<<i<<' '<<ans<<endl;
	}
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 640
namespace Test
{
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;

    public class Test
    {
        public static void Main(string[] args)
        {
            var test = new Test();
            var n = test.ConvertIntArray(test.ReadInput());
            
            if(n[0] == n[1])
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }
        }

        public string[] ReadInput()
        {
            return Console.ReadLine().Split(' ');
        }

        public int[] ConvertIntArray(string[] x)
        {
            var convertedArray = new int[x.Length];
            for (var i = 0; i < x.Length; i++)
            {
                convertedArray[i] = int.Parse(x[i]);
            }

            return convertedArray;
        }

        public double[] ConvertDoubleArray(string[] x)
        {
            var convertedArray = new double[x.Length];
            for (var i = 0; i < x.Length; i++)
            {
                convertedArray[i] = int.Parse(x[i]);
            }

            return convertedArray;
        }

        public long[] ConvertLongArray(string[] x)
        {
            var convertedArray = new long[x.Length];
            for (var i = 0; i < x.Length; i++)
            {
                convertedArray[i] = long.Parse(x[i]);
            }

            return convertedArray;
        }

        public int CountContainWords(string source, string word)
        {
            var count = 0;
            var loopCount = source.Length - (word.Length - 1);
            for (var i = 0; i < loopCount; i++)
            {
                if (source.Substring(i, word.Length) == word)
                {
                    count++;
                }
            }
            return count;
        }
    }
}

Measured memory_bytes: 13140
#include<iostream>
#include<string>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<vector>
#include<functional>
#include<iomanip>
#include<queue>
#include<cassert>
#include<tuple>
#include<set>
#include<map>
#include<list>
#include<bitset>
#include<utility>
#include<numeric>

#define pb push_back
#define mp make_pair
#define all(a)  (a).begin(),(a).end()
#define dwn(a)  (a).begin(),(a).end(), greater<int>()
#define rep(i, m) for (int i = 0; i < m; i++)
#define REP(i, n, m) for (int i = n; i < m; i++)
#define V vector<int>
#define VV vector<V>
#define VVV vector<VV>

using namespace std;

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

const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };
const int INF = (int)1e9;
const ll inf = (ll)1e18;
const ll MOD{ (ll)1e9 + 7 };
const long double EPS = 1e-10;

int main() {
	int a, b, c;
	cin >> a >> b;
	cout << a + b / 2 << endl;
	return 0;
}

Measured memory_bytes: 256
n = int(input())
L = list(map(int,input().split()))
cnt = 0
for i in range(n-2):
    if (L[i+1]>L[i]) and (L[i+1] < L[i+2]):
        cnt += 1
    if (L[i+1]<L[i]) and (L[i+1] > L[i+2]):
        cnt += 1
print(cnt)

Measured memory_bytes: 9176
N=int(input())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
C=list(map(int,input().split()))

count=0
for i in range(0,len(A)-1):
  if A[i]+1==A[i+1]:
    count=count+C[A[i]-1]
    
print(sum(B)+count)

Measured memory_bytes: 3064
#include <cstdio>
#include <cstdlib>

typedef struct {
    int idx;
    int per;
    int year;
    char id[16];
} City;

int compCity(const void* aa, const void* bb) {
    City* a = (City*)aa;
    City* b = (City*)bb;

    if (a->per < b->per) return -1;
    else if (a->per > b->per) return 1;
    else if (a->year < b->year) return -1;
    return 1;
}

int compIdx(const void* aa, const void* bb) {
    City* a = (City*)aa;
    City* b = (City*)bb;

    if (a->idx < b->idx) return -1;
    return 1;
}

int main() {
    int N = 0, M = 0;
    scanf("%d %d", &N, &M);
    City *city = new City[M]();
    for (int i = 0; i < M; i++) {
        city[i].idx = i;
        scanf("%d %d", &(city[i].per), &(city[i].year));
    }

    qsort(city, M, sizeof(City), compCity);

    for (int i = 0, j = 1, p = city[0].per; i < M; i++) {
        if (p != city[i].per) {
            j = 1;
            p = city[i].per;
        }
        sprintf(city[i].id, "%06d%06d", p, j++);
    }

    qsort(city, M, sizeof(City), compIdx);

    for (int i = 0; i < M; i++) {
        printf("%s\n", city[i].id);
    }

    delete[] city;
    return 0;
}


Measured memory_bytes: 6996
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i,n) for(ll i = 0; i<(ll)(n); i++)
#define REPS(i,n) for (ll i = 1; i<=(ll)(n); i++)
#define REPD(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define FORD(i,a,b) for(ll i=(a);i>=(b);i--)
#define pb push_back
#define MOD 1000000007
#define MOD2 998244353
#define PI 3.141592653
#define INF 100000000000000 //14

int main(){
    ll n, k; cin >> n >> k;
    vector<ll> a(n);
    REP(i,n) cin >> a[i];
    vector<ll> b(n,0);
    ll cnter = 0;
    REP(cnter,50){
        REP(i,n){
            ll l = max(0ll,i-a[i]);
            ll r = min(n-1,i+a[i]);
            b[l]++;
            if (r+1<n) b[r+1]--;
        }
        FOR(i,1,n-1) b[i]+=b[i-1];
        if (k==cnter+1){
            REP(i,n) cout << min(n,b[i]) << " ";
            cout << endl;
            return 0;
        }
        
        REP(i,n) a[i]=b[i];
        REP(i,n) b[i]=0;
    }
    REP(i,n) cout << n << " "; 
    cout << endl;
    return 0;
}

Measured memory_bytes: 6420
#include<bits/stdc++.h>
#define REP(i,x) for(int i=0,i##_len=(x);i<i##_len;++i)
#define rep(i,a,b) for(int i=(a),i##_len(b);i<i##_len;++i)
#define All(x) begin(x),end(x)
#define rAll(x) rbegin(x),rend(x)
using namespace std;
using ll = long long;

int main(){
    int N;cin>>N;
    vector<int> x(N),y(N),h(N);
    REP(i,N) cin>>x[i]>>y[i]>>h[i];
    rep(i,1,N) if(h[0]==0&&h[i]>0){
        swap(x[0],x[i]);
        swap(y[0],y[i]);
        swap(h[0],h[i]);
    }
    REP(X,101) REP(Y,101){
        int H = h[0]+abs(X-x[0])+abs(Y-y[0]);
        bool ok=true;
        REP(i,N){
            if(max(H-abs(X-x[i])-abs(Y-y[i]),0)!=h[i]) ok=false;
        }
        if(ok){
            cout<<X<<" "<<Y<<" "<<H<<endl;
        }
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
  using namespace std;
#define ll long long
#define fw(p) for(int w=0;w<(p);w++)
#define fx(p) for(int x=0;x<(p);x++)
#define fy(p) for(int y=0;y<(p);y++)
#define fz(p) for(int z=0;z<(p);z++)
#define fyg(p,g) for(int y=(g);y<(p);y++)
#define fzg(p,g) for(int z=(g);z<(p);z++)
#define ce(d) cout<<d<<endl;
#define vecp(p) int aa;cin>>aa;(p).push_back(aa);
#define vecpl(p) long long aa;cin>>aa;(p).push_back(aa);
#define vecps(p) string aa;cin>>aa;(p).push_back(aa);
#define vecp2(p) cin>>aa;(p).push_back(aa);
#define vecpl2(p) long long ab;cin>>ab;(p).push_back(ab);
#define vecps2(p) string ab;cin>>ab;(p).push_back(ab);
#define set0(k,n) for(int nn=0;nn<(n);nn++){ (k).push_back(0); }
#define sorts(c) sort((c).begin(),(c).end());
#define reverses(c) reverse((c).begin(),(c).end());
#define vec(b) vector<int> (b);
#define vecl(b) vector<long long> (b);
#define vecs(b) vector<string> (b);
#define vecsize(b,size) vector<int> (b)((size));
#define pb(b,a) (b).push_back((a));
#define doublece(a,b) cout<<(a)<<' '<<(b)<<endl;
#define pairs(s) vector<pair<int,int>> (s);
#define pairsl(s) vector<pair<ll,ll>> (s);
#define pairss(s) vector<pair<string,string>> (s);
#define pairsp(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairspl(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairsps(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairsREV(s) (s).push_back(make_pair(bb,aa));
#define pairslREV(s) (s).push_back(make_pair(bb,aa));
#define pairssREV(s) (s).push_back(make_pair(bb,aa));
#define MOD 1000000007

int main() {
	
	int a,b,h;
	cin>>a>>b>>h;
	ce((a+b)*h/2)
}

Measured memory_bytes: 256
def comb(n,k,p):
  """power_funcを用いて(nCk) mod p を求める"""
  from math import factorial
  if n<0 or k<0 or n<k: return 0
  if n==0 or k==0: return 1
  a=factorial(n) %p
  b=factorial(k) %p
  c=factorial(n-k) %p
  return (a*power_func(b,p-2,p)*power_func(c,p-2,p))%p
def power_func(a,b,p):
  """a^b mod p を求める"""
  if b==0: return 1
  if b%2==0:
    d=power_func(a,b//2,p)
    return d*d %p
  if b%2==1:
    return (a*power_func(a,b-1,p ))%p
Mod=10**9+7
n=int(input())
cnt=0
m=n//3
for i in range(0,m):
  cnt+=comb(n-2*i-3,n-3*(i+1),Mod)
print(cnt%Mod)

Measured memory_bytes: 9232
#include <algorithm>
#include <cctype>
#include <complex>
#include <iomanip>
#include <iostream>
#include <queue>
#include <set>
#include <string>
#include <vector>

using std::cin;
using std::cout;
using std::endl;

using std::string;
using std::to_string;
using std::vector;
using std::set;
using std::queue;
using std::priority_queue;

using std::min;
using std::max;
using std::sort;
using std::abs;

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

    if(op == '+'){
        cout << (a + b) << endl;
    }else{
        cout << (a - b) << endl;
    }

    return 0;
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline
ins = lambda: input().rstrip()
ini = lambda: int(input().rstrip())
inm = lambda: map(int, input().split())
inl = lambda: list(map(int, input().split()))
out = lambda x: print('\n'.join(map(str, x)))

a, b = inm()
print(max(a+b, a-b, a*b))

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

colors = set()
free_num = 0
for rate in a:
    if rate < 400:
        colors.add("grey")
    elif rate < 800:
        colors.add("brown")
    elif rate < 1200:
        colors.add("green")
    elif rate < 1600:
        colors.add("sky")
    elif rate < 2000:
        colors.add("blue")
    elif rate < 2400:
        colors.add("yellow")
    elif rate < 2800:
        colors.add("orange")
    elif rate < 3200:
        colors.add("red")
    else:
        free_num += 1
if len(colors) > 0:        
    print(len(colors), free_num + len(colors))
else:
    print(1, free_num)

Measured memory_bytes: 3064
/******************************\
*  Everyone has a different way of thinking, so God Created us
Hope You Respect My Way..,Thank You ):  *
*                            *
*   Created by : Murad   *
\******************************/
//std::transform(s1.begin(), s1.end(), s1.begin(),::tolower);
#include<bits/stdc++.h>
using namespace std;
#define pi 3.1415926536
#define forn(i,a,b)for(int i=a;i<b;i++)
#define LL long long
#define MP make_pair
#define ff first
#define ss second
#define INF 2147483647
#define _INF -2147483647
#define pq priority_queue
#define MM multimap
#define PB push_back
#define ipair pair<int,int>
#define lpair pair<LL,LL>
#define MAXN 100004
#define El3zba ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define modd 1000000007
LL MMIN(LL a, LL b)
{
	if (a <= b)
		return a;
	else
		return b;
}
LL MMAX(LL a, LL b) {
	if (a >= b)
		return a;
	else
		return b;
}
int main()
{
	El3zba;
	int a, b, c, sum = 0;
	cin >> a >> b >> c;
	sum = a + b + c;
	cout << sum - max({ a,b,c })<<endl;
	return 0;
}

Measured memory_bytes: 256
input_line=input().split(" ")
S,T=input_line[0],input_line[1]
input_line=input().split(" ")
A,B=int(input_line[0]),int(input_line[1])
U=input()
if S==U:
    A=A-1
else:
    B=B-1

print(str(A)+" "+str(B))

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,l,r) for(long long i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define int long long
const int MOD=1e9+7;
const int INF=1e20;

signed main(){
    int N;cin>>N;
    map<string,int>memo;
    char after;
    bool ok=true;
    for(int i=0;i<N;i++){
        string S;cin>>S;
        if(memo[S]!=0||(i!=0&&S[0]!=after)){
            ok=false;
            break;
        }
        memo[S]++;
        after=S[S.size()-1];
    }
    if(ok) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
  size_t A, B;
  cin >> A >> B;
  if (A >= 13) {
    cout << B <<endl;
  } else if (A >= 6) {
    cout << B / 2 << endl;
  } else {
    cout << 0 << endl;
  }

  return 0;
}

Measured memory_bytes: 256
mod = 10 ** 9 + 7
def comb(n, r):
    if n < r:return 0
    if n < 0 or r < 0:return 0
    return fa[n] * fi[r] % mod * fi[n - r] % mod
r1, c1, r2, c2 = map(int, input().split())
fa = [1] * (r2 + c2 + 3)
fi = [1] * (r2 + c2 + 3)
for i in range(1, r2 + c2 + 3):
    fa[i] = fa[i - 1] * i % mod
    fi[i] = pow(fa[i], mod - 2, mod)
def ans(r, c):
    return fa[r + c + 2] * fi[r + 1] * fi[c + 1] % mod - 1
print((ans(r2, c2) - ans(r2, c1 - 1) - ans(r1 - 1, c2) + ans(r1 - 1, c1 - 1)) % mod)

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

bool Prime(int in){
	for (int i = 3; i <= sqrt(in); i += 2){
		if (in%i == 0)	return false;
	}
	return true;
}

vector<int> kakunou(vector<int> in){
	in.push_back(2);
	in.push_back(3);

	for (int i = 5; i < 51000; i += 2){
		if (Prime(i))	in.push_back(i);
	}
	return in;
}

int main(){
	int in;
	vector<int> vec;

	vec = kakunou(vec);

	while (cin >> in, !cin.eof()){
		vector<int>::iterator it = vec.begin();
		while (1){
			if (*it >= in){
				--it;
				cout << *it << " ";
				++it;
				if (*it == in)	++it;
				cout << *it << endl;
				break;
			}
			++it;
		}
	}

	return 0;
}

Measured memory_bytes: 1296
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        
        int intNum = sc.nextInt();
        
        int h =intNum / 3600;
        
        int m =(intNum -(h * 3600)) / 60;
        
        int s =((intNum -(h * 3600)) - ( m * 60 ));
        
        System.out.println(h +":"+ m + ":" + s);
    }
}



Measured memory_bytes: 26200