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

const int maxn=5e5+10;

void read(int &x)
{
	char c=getchar(); x=0;
	while (c<'0'||c>'9') c=getchar();
	while (c>='0'&&c<='9') x=x*10+c-'0',c=getchar();
}

int n,k,p[maxn],q[maxn],deg[maxn];
int tote,FIR[maxn],TO[maxn<<1],NEXT[maxn<<1];
priority_queue<int> pq;

namespace SegTree{
	int mn[maxn<<2];
#define lc (nd<<1)
#define rc (nd<<1|1)
#define mid ((s+t)>>1)

	void init()
	{
		memset(mn,0x3f3f3f3f,sizeof(mn));
	}

	void update(int nd,int s,int t,int id,int val)
	{
		if (s==t) {mn[nd]=val; return;}
		if (id<=mid) update(lc,s,mid,id,val);
		else update(rc,mid+1,t,id,val);
		mn[nd]=min(mn[lc],mn[rc]);
	}

	int query(int nd,int s,int t,int l,int r)
	{
		if (l<=s&&t<=r) return mn[nd];
		int Ans=0x7fffffff;
		if (l<=mid) Ans=min(Ans,query(lc,s,mid,l,r));
		if (r> mid) Ans=min(Ans,query(rc,mid+1,t,l,r));
		return Ans;
	}
}

void addedge(int u,int v)
{
	TO[++tote]=v;
	NEXT[tote]=FIR[u];
	FIR[u]=tote;
	deg[v]++;
}

int main()
{
	int i,x;
	read(n); read(k);
	for (i=1;i<=n;i++)
		read(p[i]),q[p[i]]=i;
	SegTree::init();
	for (i=n;i>=1;i--)
	{
		x=SegTree::query(1,1,n,q[i]-k+1,q[i]);
		if (x<=n) addedge(q[x],q[i]);
		x=SegTree::query(1,1,n,q[i],q[i]+k-1);
		if (x<=n) addedge(q[x],q[i]);
		SegTree::update(1,1,n,q[i],i);
	}
	for (i=1;i<=n;i++)
		if (!deg[i]) pq.push(i);
	for (i=n;i>=1;i--)
	{
		int u=p[i]=pq.top(); pq.pop();
		for (int p=FIR[u];p;p=NEXT[p])
			if (!(--deg[TO[p]])) pq.push(TO[p]);
	}
	for (i=1;i<=n;i++) q[p[i]]=i;
	for (i=1;i<=n;i++) printf("%d\n",q[i]);
}


Measured memory_bytes: 27764
N = int(input())
H = list(map(int, input().split()))
l=0
t_l = 0
for i in range(N-1):
  if H[i] >= H[i+1]:
    t_l = t_l + 1
    if l < t_l:
      l = t_l
  else:
    t_l=0
print(l)

Measured memory_bytes: 14252
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define all(x) (x).begin(),(x).end()
#define mp(x) make_pair((x))
#define pb push_back
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

using P = pair<pair<long,int>,pair<int,int>>;

class UnionFind{
public:
    vector<int> par,rank;
    UnionFind(int sz) : par(sz, -1), rank(sz,0){}
    int find(int x){
        if(par[x]<0) return x;
        else return par[x] = find(par[x]);
    }
    void unite(int x, int y){
        x = find(x); y = find(y);
        if(x==y) return;
        if(rank[x] < rank[y]){
            par[y] += par[x];
            par[x] = y;
        }
        else {
            par[x] += par[y];
            par[y] = x;
            if(rank[x]==rank[y]) rank[x]++;
        }
    }
    bool same(int x,int y){ return find(x)==find(y); }
    int size(int x){ return -par[find(x)]; }
};

int main()
{
    int n,m;
    cin>>n>>m;
    vector<P> vec(m);
    vector<int> costs(m);
    rep(i,m){
        int a,b,c;
        cin>>a>>b>>c;
        a--;b--;
        vec[i] = P({c,i},{a,b});
        costs[i] = c;
    }
    sort(all(vec));

    vector<bool> use(m,false);
    auto mst = [&](int notuse=-1){
        UnionFind uf(n);
        long res = 0;
        rep(i,m){
            auto p = vec[i];
            if(vec[i].fi.se == notuse) continue;
            int v = vec[i].se.fi;
            int u = vec[i].se.se;
            if(uf.same(u,v)) continue;
            else {
                use[vec[i].fi.se] = true;
                uf.unite(u,v);
                res += vec[i].fi.fi;
                if(uf.size(0)==n) break;
            }
        }
        if(uf.size(0)<n) return 123456789012678L;
        return res;
    };


    long total = mst();
    vector<int> cand;
    rep(i,m)if(use[i]) cand.pb(i);

    int a1=0;
    long a2 = 0;
    for(auto i : cand){
        long nc = mst(i);
        if(nc > total){
            a1++;
            a2 += costs[i];
        }
    }


    cout << a1 << " " << a2 << endl;

    return 0;
}

Measured memory_bytes: 4208
#include <bits/stdc++.h>
 
using namespace std;
 
#define lli long long int
#define REP(i,s,l) for(lli i=s;i<l;i++)
#define DEBUG 0
#define INF (1LL<<50)
#define MOD 1000000007



	lli data[200010]={0};
	lli flag[200010]={0};
	lli sum[200010]={0};
signed main(){

	lli n,q;
	cin>>n>>q;
	map<lli,vector<lli>> v;
	REP(i,0,n-1){
		lli a,b;
		cin>>a>>b;
		a--,b--;
		v[a].push_back(b);
		v[b].push_back(a);
	}

	REP(i,0,q){
		lli p,x;
		cin>>p>>x;
		p--;
		data[p] += x;
	}

	queue<lli> now;
	queue<lli> ans;

	ans.push(data[0]);
	now.push(0);
	flag[0]=1;

	while(now.size()){
		lli top = now.front();
		lli topAns = ans.front();
		now.pop();
		ans.pop();

		sum[top] = topAns;

		for(auto e:v[top]){
			if(flag[e]==1)continue;
			flag[e]=1;
			ans.push(topAns+data[e]);
			now.push(e);
		}
	}

	REP(i,0,n){
		cout<<sum[i]<<" ";
	}
	cout<<endl;


	return 0;
}

Measured memory_bytes: 33008
#include <iostream>
#include <vector>
#include <algorithm>
#include <fstream>
using namespace std;

int main(){
    // あとで消す
    //std::ifstream in("ain2.txt");
    //std::cin.rdbuf(in.rdbuf());

    int P,Q,R,minv;

    cin >> P ;
    cin >> Q ;
    cin >> R ;

    minv = P+Q;
    if(Q+R<minv) minv = Q+R;
    if(R+P<minv) minv = R+P;

    cout << minv << endl;

    return 0;
}


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

typedef long long ll;
ll MOD = 1e9+7;

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

Measured memory_bytes: 256
n = input().split()
A = int(n[0])
B = int(n[1])
K = int(n[2])

tmp = []
for i in range(100):
    if A % (i+1) == 0:
        if B % (i+1) == 0:
            tmp.append(i+1)

tmp.reverse()
print(str(tmp[K-1]))

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define INF 1e18
#define int long long
#define Rep(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) Rep(i, 0, n)
#define all(a) (a).begin(), (a).end()
using namespace std;
typedef pair<int, int> P;
typedef pair<int, P> PP;
const int mod = 1000000007;

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

    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    int now = 0;
    for (int cnt = 1; now != -1; cnt++)
    {
        int nxt = a[now] - 1;
        a[now] = 0;
        if (nxt == 1)
        {
            cout << cnt << endl;
            return 0;
        }
        now = nxt;
    }
    cout << -1 << endl;
}

Measured memory_bytes: 1148
/* Atcoder abc168a
 * See tasks at: https://atcoder.jp/contests/abc168/tasks/abc168_a
 */
#include <bits/stdc++.h>

#define until(symbol, max) for (int symbol = 0; (symbol) < (max); (symbol)++)

using namespace std;
using ll = long long;
int main()
{
    int n;
    cin >> n;

    switch (n % 10)
    {
    case 2:
    case 4:
    case 5:
    case 7:
    case 9:
        cout << "hon";
        break;
    case 0:
    case 1:
    case 6:
    case 8:
        cout << "pon";
        break;
    case 3:
        cout << "bon";
        break;
    }
    
    return 0;
}


Measured memory_bytes: 3636
n = int(input())
numbers =list(map(int,input().split()))
sornum =sorted(numbers, reverse=True)

ans =0
d_min = sornum[0]

for i in range(n-1):
   d =abs(sornum[0]/2-sornum[i+1])
   if d<d_min:
      d_min =d
      ans = sornum[i+1]

print('{} {}'.format(sornum[0], ans))

Measured memory_bytes: 14056
import sys
input = sys.stdin.readline

def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

def main():
    #各行では連続した区間
    #行ごとに見ないと話が進まん，降りるタイミぐは各列高々3000こ，来るタイミングも同様
    
    mod=10**9+7
    R,C,K=MI()
    S=[[0]*(C+1) for _ in range(R+1)]

    
    for i in range(K):
        r,c,v=MI()
        S[r][c]=v
        
        
    dp1=[[0]*(C+1)for _ in range(R+1)]
    dp2=[[0]*(C+1)for _ in range(R+1)]
    dp3=[[0]*(C+1)for _ in range(R+1)]
    # dp[i][j][k]はi行j列まで見てその行でk個以下
    
    for i in range(R+1):
        for j in range(C+1):
            #S(i,j)からの移動を考える
            
            #右へ移動，-,拾わない，拾う
            if j+1<=C:
                dp1[i][j+1]=max(dp1[i][j+1],dp1[i][j],S[i][j+1])
                dp2[i][j+1]=max(dp2[i][j+1],dp2[i][j],dp1[i][j]+S[i][j+1])
                dp3[i][j+1]=max(dp3[i][j+1],dp3[i][j],dp2[i][j]+S[i][j+1])
            
            #下へ
            if i+1<=R:
                temp=max(dp1[i][j],dp2[i][j],dp3[i][j])
                dp1[i+1][j]=temp+S[i+1][j]
                
    ans=max(dp1[-1][-1],dp2[-1][-1],dp3[-1][-1])
        
    # for i in range(R+1):
    #     print(dp[i])
        
    print(ans)
                
        
    

main()


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

int main()
{
    int n, i, x;
    bool res=true;

    cin>>n;

    for(i=0; i<n; i++){
        cin>>x;
        if(x%2 == 0){
            if(x%3 != 0 && x%5 != 0)
                res=false;
        }
    }

    if(res)
        cout<<"APPROVED";
    else
        cout<<"DENIED";
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String args[]) {
        try (Scanner in = new Scanner(System.in)) {
            int N = in.nextInt();

            int max = -1;
            int maxN = -1;
            for (int n = 1; n <= N; n++) {
                int times = times(n);
                if (times > max) {
                    max = times;
                    maxN = n;
                }
            }
            System.out.println(maxN);
        }
    }

    private static int times(int n) {
        for (int i = 0;; i++) {
            if (n % 2 == 0) {
                n /= 2;
            } else {
                return i;
            }
        }
    }
}


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

int main() { int H; int W; cin >> H >> W;
vector<string> str(H + 2);
for(int i = 0; i < W + 2; i++) str.at(0) = '.' + str.at(0);
for(int i = 1; i < H + 1; i++) cin >> str.at(i);
for(int i = 1; i < H + 1; i++) str.at(i) = '.' + str.at(i) + '.';
for(int i = 0; i < W + 2; i++) str.at(H + 1) = '.' + str.at(H + 1);
string ans = "Yes";

for(int i = 1; i < H + 1; i++){
  for(int j = 1; j < W + 1; j++){
    if(str.at(i).at(j) == '#'){
      if(str.at(i - 1).at(j) == '.'){
        if(str.at(i).at(j - 1) == '.'){
          if(str.at(i).at(j + 1) == '.'){
            if(str.at(i + 1).at(j) == '.'){
              ans = "No";
              break;
            }
          }
        }
      }
    }
  }
}
cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
import collections
n = int(input())
list_a = list(map(int, input().split()))
count = collections.Counter(list_a)
sort_count = sorted(count.items(), reverse=True)
rect = []
for k, v in sort_count:
  if v >= 4:
    rect.append(k)
    break
  if v >= 2:
    rect.append(k)
    if len(rect) >= 2:
      break
if len(rect) == 0:
  print(0)
elif len(rect) == 1:
  print(rect[0] ** 2)
else:
  print(rect[0] * rect[1])


Measured memory_bytes: 21412
#include<iostream>
using namespace std;
int main(){
	int H,W;
	while(1){
		cin>>H>>W;
	for(int i=0;i<H;i++){
    for(int k=0;k<W;k++){
		cout<<"#";
	}
	cout<<endl;
	}
	if(H==0&&W==0){
			break;
	}cout<<endl;
	}
	
return 0;
}


Measured memory_bytes: 3100
#include <bits/stdc++.h>
#define ull unsigned long long
#define ll long long
#define il inline
#define db double
#define ls rt << 1
#define rs rt << 1 | 1
#define pb push_back
#define mp make_pair
#define pii pair<int, int>
#define X first
#define Y second
#define pcc pair<char, char>
#define vi Vtor<int>
#define vl Vtor<ll>
#define rep(i, x, y) for(int i = x; i <= y; i ++)
#define rrep(i, x, y) for(int i = x; i >= y; i --)
#define rep0(i, n) for(int i = 0; i < (n); i ++)
#define per0(i, n) for(int i = (n) - 1; i >= 0; i --)
#define ept 1e-9
#define INF 0x3f3f3f3f
#define sz(x) (x).size()
#define ALL(x) (x).begin(), (x).end()
using namespace std;
inline int read()
{
	int x = 0, f = 1; 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;
}
inline ll read1()
{
	ll x = 0, f = 1; 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;
}
const int N = 200010;

int n, k, q;
int a[N], nw[N], tt[N];
int tot, cnt;
int ans = 0x7fffffff;

vector<int> V;

int main()
{
	n = read();
	k = read();
	q = read();
	rep(i, 1, n)
	{
		a[i] = read();
		V.pb(a[i]);
	}
    sort(ALL(V));
    V.erase(unique(ALL(V)), V.end());
    int nn = V.size();
    rep(x, 0, nn - 1)
    {
        int t = V[x];
        tot = 0;
        int L = 1;
        rep(i, 1, n)
        {
            if (a[i] < t)
            {
                if (i - 1 >= L)
                {
                    int l = L, r = i-1;
                    cnt = 0;
                    rep(j, l, r) nw[++ cnt] = a[j];
                    sort(nw + 1, nw + cnt + 1);
                    int y = cnt - k + 1;
                    rep(j, 1, y) tt[++ tot] = nw[j];
                }
                L = i + 1;
            }
        }
        if (L <= n)
        {
            int l = L, r = n;
            cnt = 0;
            rep(j, l, r) nw[++ cnt] = a[j];
            sort(nw + 1, nw + cnt + 1);
            int y = cnt - k + 1;
            rep(j, 1, y) tt[++ tot] = nw[j];
        }
        sort(tt + 1, tt + tot + 1);
        if (tot >= q)
            ans = min(ans, tt[q] - t);
    }
    printf("%d\n", ans);
    return 0;
}


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

int main()
{
    int n;
    int a[10];

    cin >> n;

    while( n-- )
    {
        stack<int> b, c;
        b.push(0);
        c.push(0);

        for( int i = 0; i < 10; i++ )
            cin >> a[i];

        for( int i = 0; i < 10; i++ )
        {
            if( b.top() == 0 || c.top() == 0 )
            {
                if( a[i] > b.top() )
                    b.push(a[i]);
                else
                    c.push(a[i]);
            }
            else if( b.top() > c.top() )
            {
                if( a[i] > b.top() )
                    b.push(a[i]);
                else
                {
                    if( a[i] > c.top() )
                        c.push(a[i]);
                    else
                    {
                        cout << "NO" << endl;
                        break;
                    }
                }
            }
            else
            {
                if( a[i] > c.top() )
                    c.push(a[i]);
                else
                {
                    if( a[i] > b.top() )
                        b.push(a[i]);
                    else
                    {
                        cout << "NO" << endl;
                        break;
                    }
                }
            }
        }
        if( b.size() + c.size() == 12 )     //初期値0が2つのスタックに入っている。
            cout << "YES" << endl;
    }
    return 0;
}


Measured memory_bytes: 3016
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define chmax(a, b) a = (a >= b ? a : b)
#define chmin(a, b) a = (a <= b ? a : b)
#define out(a) cout << a << endl
#define outa(a, n) { rep(_, n) cout << a[_] << " "; cout << endl; }
#define outp(a, n) { cout << endl; rep(_, n) cout << a[_].F << " " << a[_].S << endl; }
#define sz(v) (int)v.size()
#define inf (int)(1e9+7)
#define abs(x) (x >= 0 ? x : -(x))
#define ceil(a, b) a / b + !!(a % b)
#define FIX(a) fixed << setprecision(a)
#define LB(v, n) (int)(lower_bound(all(v), n) - v.begin())
#define UB(v, n) (int)(upper_bound(all(v), n) - v.begin())
ll pow(ll a, int b) { return b ? pow(a * a, b / 2) * (b % 2 ? a : 1) : 1; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }


int k;
vector<int> a(100000);

ll bin(int key) {
    ll l = 0, r = (ll)k * inf;
    
    while (1) {
        // out(l << " " << r);
        ll mid = (l + r) / 2;
        
        ll M = mid;
        rep(i, k) {
            mid -= mid % a[i];
        }
        
        if (key == 0) {
            if (mid >= 2) r = M;
            else l = M;
        } else {
            if (mid <= 2) l = M;
            else r = M;
        }
        if (l + 1 == r) break;
    }
    if (key == 0) return r;
    return l;
}

int main() {
    cin >> k;
    rep(i, k) cin >> a[i];
    
    ll a = bin(0), b = bin(1);
    if (a > b) out(-1);
    else out(a << " " << b);
    
}


Measured memory_bytes: 640
//----------------------------templates
    #pragma GCC optimize ("Ofast")
    #pragma GCC target ("tune=native")
    #pragma GCC target ("avx")
    //----------------------------
    #include <bits/stdc++.h>
    using namespace std;

    typedef long long ll;
    typedef unsigned long long ull;
    #define int ll

    #define FOR(i,j,n) for (int i=(int)(j);i<(n);i++)
    #define REP(i,n) for (int i=0;i<(int)(n);i++)
    #define REPS(i,n) for (int i=1;i<=(int)(n);i++)
    #define REPN(i,n) for (int i=(int)(n)-1;i>=0;i--)
    #define REPNS(i,n) for (int i=(int)(n);i>0;i--)

    #define I(n) scanf("%lld", &(n))
    #define LL(n) scanf("%lld", &(n))
    #define pb(n) push_back((n))
    #define mp(i,j) make_pair((i),(j))
    #define eb(i,j) emplace_back((i),(j))
    #define y0 y3487465
    #define y1 y8687969
    #define j0 j1347829
    #define j1 j234892
    #define uniq(v) v.erase( unique(v.begin(), v.end()), v.end() )

    #define all(x) (x).begin(),(x).end()
    #define sz(x) ((int)(x).size())

    typedef vector<int> vi;
    typedef pair<int,int> pi;
    typedef vector<pi> vpi;
    typedef vector<vi> vvi;
    typedef vector<vpi> vvpi;
    typedef vector<vvi> vvvi;

    const int mod = 1000000007;

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

int n,m,a,b;

signed main(){
    I(n); I(m);
    vvi cl = vvi(n+1,vi());

    REP(i,m){
        I(a); I(b);
        cl[a].pb(b);
        cl[b].pb(a);
    }

    FOR(i,2,n){
        if(sz(cl[i]) <= 1) continue;
        sort(all(cl[i]));
        if (cl[i][0] == 1 && cl[i][sz(cl[i])-1] == n){
            cout << "POSSIBLE" << endl;
            return 0;
        }
    }
    cout << "IMPOSSIBLE" << endl;
}

Measured memory_bytes: 12776
// Problem : A - Kth Term
// Contest : Panasonic Programming Contest 2020
// URL : https://atcoder.jp/contests/panasonic2020/tasks/panasonic2020_a
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
using namespace std;

#define int long long
#define IOS ios::sync_with_stdio(false);cin.tie(nullptr);
#define endl "\n"
#define debug(x) cerr<<#x<<" = "<<(x)<<endl;

typedef vector<int> vi;

int32_t main()
{
	IOS;
	vector<int> v = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
	int k;
	cin >> k;
	cout << v[k-1] << endl;		
	return 0;
}


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

const int N = 1e6 + 7;
const int INF = 1e9 + 7;

char s[105][105];
char sm = '.', bg = '#';
int a, b, c, ans;

main(){
	cin >> a >> b;
	if (a > b){
        swap(sm, bg);
        swap(a, b);
	}
    for (int i = 0; a > 1; i += 2){
        if (i == 0)
            b--;
        for (int j = 0; j < 99; j++){
            if (a == 1 || j % 2 == 0)
                s[i][j] = bg;
            else {
                s[i][j] = sm;
                a--;
            }
            s[i + 1][j] = bg;
        }
        if (a == 1)
            c = i + 2;
    }
    for (int j = 0; j < 99; j++)
        s[c][j] = sm;
    c++;
    for (int i = 0; b > 0; i += 2){
        for (int j = 0; j < 99; j++){
            if (b == 0 || j % 2 == 0){
                s[i + c][j] = sm;
            }
            else {
                s[i + c][j] = bg;
                b--;
            }
            s[i + c + 1][j] = sm;
            ans = max(i + c + 1, ans);
        }
    }
    int t = 0;
    cout << ans + 1 << " " << 99 << endl;
    for (int i = 0; i < ans + 1; i++){
        for (int j = 0; j < 99; j++){
            cout << s[i][j];
        }
        cout << endl;
    }
}


Measured memory_bytes: 256
/*
このコード、と～おれ!
Be accepted!
∧＿∧　
（｡･ω･｡)つ━☆・*。
⊂　　 ノ 　　　・゜+.
　しーＪ　　　°。+ *´¨)
 　　　　　　　　　.· ´¸.·*´¨) ¸.·*¨)
		  　　　　　　　　　　(¸.·´ (¸.·'* ☆
					*/

#include <stdio.h>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstring>
#include <vector>
#include <numeric>
#include <iostream>
#include <random>
#include <map>
#include <unordered_map>
#include <queue>
#include <regex>

#pragma GCC optimize("Ofast")
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define rep1(i, n) for(int i = 1; i <= (n); ++i)
#define rep2(i, n) for(int i = 2; i < (n); ++i)
#define repr(i, n) for(int i = n; i >= 0; --i)
#define reprm(i, n) for(int i = n - 1; i >= 0; --i)
#define printynl(a) printf(a ? "yes\n" : "no\n")
#define printyn(a) printf(a ? "Yes\n" : "No\n")
#define printYN(a) printf(a ? "YES\n" : "NO\n")
#define printin(a) printf(a ? "possible\n" : "inposible\n")
#define printdb(a) printf("%.50lf\n", a)//少数出力
#define printdbd(a) printf("%.16lf\n", a)//少数出力(桁少なめ)
#define prints(s) printf("%s\n", s.c_str())//string出力
#define all(x) (x).begin(), (x).end()
#define allsum(a, b, c) ((a + b) * c / 2)//等差数列の和、初項,末項,項数
#define pb push_back
#define priq priority_queue
#define rpriq priq<int, vector<int>, greater<int>>
#define deg_to_rad(deg) (((deg)/360.0)*2.0*PI)
#define rad_to_deg(rad) (((rad)/2.0/PI)*360.0)
#define Please return
#define AC 0

using ll = long long;

constexpr int INF = 1073741823;
constexpr int MINF = -1073741823;
constexpr ll LINF = ll(4661686018427387903);
constexpr ll MOD = 1000000007;
const double PI = acos(-1);

using namespace std;

void scans(string& str) {
	char c;
	str = "";
	scanf("%c", &c);
	if (c == '\n')scanf("%c", &c);//最初の改行対策
	while (c != '\n' && c != -1) {
		str += c;
		scanf("%c", &c);
	}
}

void scanc(char& str) {
	char c;
	scanf("%c", &c);
	if (c == -1)return;
	while (c == '\n') {
		scanf("%c", &c);
	}
	str = c;
}

double acot(double x) {
	return PI / 2 - atan(x);
}

/*-----------------------------------------ここからコード-----------------------------------------*/


int main() {
	
	int a, b, c, d;
	scanf("%d%d%d%d", &a, &b, &c, &d);
	printf("%d\n", a * b - c * b - d * a + c * d);
	
	Please AC;
}


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

using namespace std;

int main() {
	int a, b;
	scanf("%d %d", &a, &b);
	int res = (16 - 2 * min(a, b)) / 2;
	int cur = max(a, b) - min(a, b);
	if (cur <= res) {
		puts("Yay!");
	} else {
		puts(":(");
	}
	return 0;
}

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

int main(){
  string s;
  int a,n=0;
  char c;
  
  
  cin>>s;
  a=s.size();
  for(int i=0;i<a;i++){
    if (s.at(i)==s.at(a-i-1)){
      continue;
    }else{n++;}
  }
  cout<<n/2<<endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main()
{
	int i=0,j=0,k=0,l=0;
	char str[20+10],str2[20+10];
	scanf("%s",str);
	while(str[j] != '\0')
	{
		j++;
	}
	while(k<j)
	{
		str2[k] = str[j-k-1];
		k++;
	}
	str2[k]='\0';
	printf("%s\n",str2);

}

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

vector<int> to[200010];

void dfs(int i, int &gr, vector<int> &group){
  if(group[i]!=-1) return;
  group[i]=gr;
  for(auto x : to[i]){
    dfs(x,gr,group);
  }
}

int main(){
  int n,m;
  cin>>n>>m;
  rep(i,m){
    int a,b;
    cin>>a>>b;
    a--;b--;
    to[a].push_back(b);
    to[b].push_back(a);
  }
  vector<int> group(n);
  rep(i,n) group[i]=-1;
  int tmp=0;
  rep(i,n){
    if(group[i]==-1){
      dfs(i,tmp,group);
      tmp++;
    }
  }
  map<int,int> mp;
  rep(i,n){
    mp[group[i]]++;
  }
  int ans=0;
  for(auto x : mp){
    ans=max(ans,x.second);
  }
  cout<<ans<<endl;
}

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

int main() {
  int N;
  cin >> N;
  
  vector<int> C(N-1), S(N-1), F(N-1);
  for (int i = 0; i < N-1; i++) {
    cin >> C.at(i) >> S.at(i) >> F.at(i);
  }
  
  int max = 0, imax = 0;
  for (int i = 0; i < N-1; i++) {
    int t = S.at(i) + C.at(i);
    for (int j = i + 1; j < N-1; j++) {
      if (t < S.at(j)) {
        t = S.at(j) + C.at(j);
      }
      else {
        if ( t % F.at(j) == 0 ) {
          t += C.at(j);
        }
        else {
          t += C.at(j) + F.at(j) - t % F.at(j);
        }
      }
    }
    cout << t << endl;
  }
  cout << 0 << endl;
}

Measured memory_bytes: 256
#include <iostream>


using namespace std;

const int INF = 1000000001;
const int MAX = 500000;
int cnt;
int S[MAX] = {0}, L[1 + MAX/2] = {0}, R[1 + MAX/2] = {0};


void merge(int* A,int left,int mid,int right)
{
	int n1,n2,n,i,j;
	n1 = mid - left;
	n2 = right - mid;

	for(int i = 0; i < n1; i++)
	{
		L[i] = A[left + i];
	}
	for(int i = 0; i < n2; i++)
	{
		R[i] = A[mid + i];
	}

	L[n1] = INF;
	R[n2] = INF;

	i = 0;
	j = 0;

	for(int k = 0; k < right - left; k++)
	{
		if (L[i] <= R[j] )
		{
			A[left + k] = L[i];
			i++;
		}else
		{
			A[left + k] = R[j];
			j++;
		}

		cnt++;
	}
}


void mergesort(int* A,int left,int right)
{
	int mid;

	if(left + 1 < right)
	{
		mid = (left + right) / 2;
		mergesort(A,left,mid);
		mergesort(A,mid,right);
		merge(A,left,mid,right);
	}
}

int main()
{
	int N;
	cnt = 0;

	cin >> N;

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

	mergesort(S,0,N);

	for(int i = 0; i < N; i++)
	{
		if (i == N-1)
		{
			cout << S[i] <<endl;
		}else
		{
			cout << S[i] << " ";
		}
	}

	cout << cnt << endl;

	return 0;
}
	

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

long long n, k, a[100005] = {0}, b[100005] = {0}, t = 0;
long long memo[35] = {0};

long long solve();

int main() {
  cin >> n >> k;
  for(long long i = 0; i < n; ++i) cin >> a[i] >> b[i];
  memo[0] = 1;
  for(long long i = 1; i < 32; ++i)
    memo[i] = 2 * memo[i - 1];
  while(memo[t] <= k) ++t;
  t = max(t - 1, 0LL);
  cout << solve() << endl;
  return 0;
}

// decided x ~ t
long long solve() {
  long long ans = 0, now = 0;
  for(long long i = 0; i < n; ++i)
    if((k | a[i]) == k) ans += b[i];
  for(long long x = t; x >= 0; --x) {
    now = 0;
    for(long long i = 0; i < n; ++i) {
      if(k >= memo[x] && memo[x] > a[i])
        now += b[i];
      else if(k >= memo[x] && a[i] >= memo[x])
        a[i] -= memo[x];
    }
    if(k >= memo[x]) k -= memo[x];
    ans = max(ans, now);
  }
  return ans;
}

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

int main(){
    int N;
    cin >> N;
    vector <int> s1 (0);
    vector <int> s10(0);

    rep(i,N){
        int d;
        cin >> d;
        if(d % 10 == 0){
            s10.push_back(d);
        }
        else{
            s1.push_back(d);
        }
    }

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

    int sum1 = 0;
    int sum10= 0;
    rep(i,s10.size()){
        sum10 += s10[i];
    }
    rep(i,s1.size()){
        sum1 += s1[i];//zero kamo
    }

    if(s1.size() == 0){
        cout << 0 << endl;
        return 0;
    }
    else{
        if(sum1 % 10 == 0){
            cout << sum1 + sum10 - s1[0] << endl;
        }
        else{
            cout << sum1 + sum10 << endl;
        }
    }
}


Measured memory_bytes: 256
const main = stdin => {
  const input = stdin.trim().split('\n')

  const [a, b, c, d] = input[0].split(' ').map(x => BigInt(x))

  let aMax = 0
  if (a * c > a * d) {
    aMax = a * c
  } else {
    aMax = a * d
  }

  let bMax = 0
  if (b * c > b * d) {
    bMax = b * c
  } else {
    bMax = b * d
  }

  if (aMax > bMax) {
    console.log(aMax.toString())
  } else {
    console.log(bMax.toString())
  }
}


// 標準入力
main(require("fs").readFileSync("/dev/stdin", "utf8"))


Measured memory_bytes: 29696
//C
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdalign>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif

//ここまで毎回include
//以下プログラム

using namespace std;

int main() {
	int n;
	cin >> n;
	vector<string> data(n);
	for (int i = 0; i < n; i++) {
		cin >> data.at(i);
	}
	sort(data.begin(), data.end());
	long long m, a, r, c, h;
	m = 0;
	a = 0;
	r = 0;
	c = 0;
	h = 0;
	for (int i = 0; i < n; i++) {
		if (data.at(i).substr(0, 1) == "M") {
			m++;
		}
		else if (data.at(i).substr(0, 1) == "A") {
			a++;
		}
		else if (data.at(i).substr(0, 1) == "R") {
			r++;
		}
		else if (data.at(i).substr(0, 1) == "C") {
			c++;
		}
		else if (data.at(i).substr(0, 1) == "H") {
			h++;
		}
	}
	long long sum = m * a * r + m * a * c + m * a * h + m * r * c + m * r * h + m * c * h + a * r * c + a * r * h + a * c * h + r * c * h;
	cout << sum << endl;
	
}



Measured memory_bytes: 6144
/* ---------- STL Libraries ---------- */
// IO library
#include <cstdio>
#include <fstream>
#include <iomanip>
#include <ios>
#include <iostream>

// algorithm library
#include <algorithm>
#include <cmath>
#include <numeric>
#include <random>
#include <cstring>

// container library
#include <array>
#include <bitset>
#include <deque>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <vector>
#include <stack>

/* ---------- Namespace ---------- */
using namespace std;

/* ---------- Type ---------- */
using ll = long long;
#define int ll
#define P pair<ll, ll>

/* ---------- Constants  */
const double PI = 3.141592653589793238462643383279;
const ll MOD = 1e9 + 7;
const int INF = 1LL << 55;

/* v-v-v-v-v-v-v-v-v Main Part v-v-v-v-v-v-v-v-v */
signed main() {
    string str;
    cin >> str;
    if (str[0] == str[1] || str[1] == str[2] || str[2] == str[3]) {
        cout << "Bad" << endl;
    } else {
        cout << "Good" << endl;
    }
    return 0;
}

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

int main() {
	while (true) {
		int H, W;
		cin >> W >> H;
		if (W == 0 && H == 0) {
			break;
		}
		for (int i = 1; i <= W; i++) {
			for (int j = 1; j <= H; j++) {
				if ((i+j)%2==1) {
					cout << ".";
				}
				else {
					cout << "#";
				}
			}
			cout << endl;
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 3072
#include <bits/stdc++.h>
#define LL long long
using namespace std;
struct node
{
	LL dir, val;
}A[100000 + 100];
LL N, L, T;
inline int cmp(node x, node y)
{
	return x.val < y.val;
}
int main()
{
	scanf("%lld%lld%lld", &N, &L, &T);
	for (LL i = 1; i <= N; ++i)
		scanf("%lld%lld", &A[i].val, &A[i].dir);
	LL now = 0;
	for (LL i = 1; i <= N; ++i)
	{
		if (A[i].dir == 1)
		{
			now += T / L + (T % L + A[i].val >= L);
			A[i].val = (A[i].val + T) % L;
		}
		else 
		{
			now -= T / L + (A[i].val - T % L < 0);
			A[i].val = (A[i].val - T % L + L) % L;
		}
	}
	sort(A + 1, A + N + 1, cmp);
	now = (now % N + N) % N;
	now ++;
	for (LL i = now; i <= N; ++i)
		printf("%lld\n", A[i].val);
	for (LL i = 1; i < now; ++i)
		printf("%lld\n", A[i].val);
	return 0;
}

Measured memory_bytes: 2816
#include<stdio.h>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long ll;
ll mod = 1000000007;
#define SIZE 400000
ll inv[SIZE + 1];
ll kai[SIZE + 1];
ll invkai[SIZE + 1];
void invinit()
{
	inv[1] = 1;
	for (int i = 2; i <= SIZE; i++)
	{
		inv[i] = mod - (mod / i)*inv[mod%i] % mod;
	}
	kai[0] = invkai[0] = 1;
	for (int i = 1; i <= SIZE; i++)
	{
		kai[i] = kai[i - 1] * i%mod;
		invkai[i] = invkai[i - 1] * inv[i] % mod;
	}
}
ll com(ll a, ll b)
{
	if (b < 0 || a < b)return 0;
	return (invkai[b] * invkai[a - b]) % mod*kai[a] % mod;
}
ll dp[17][1 << 16];
int main()
{
	int num, gen;
	scanf("%d%d", &num, &gen);
	invinit();
	vector<int>v;
	for (int i = 0; i < gen; i++)
	{
		int z;
		scanf("%d", &z);
		z--;
		v.push_back(z);
	}
	reverse(v.begin(), v.end());
	dp[0][0] = 1;
	for (int i = 0; i < gen; i++)
	{
		for (int p = 0; p < (1 << num); p++)
		{
			dp[i + 1][p] = (dp[i + 1][p] + dp[i][p]) % mod;
			int rem = (1 << num) - v[i] - 1;
			for (int j = 0; j < num; j++)if (p&(1 << j))rem -= (1 << j);
			for (int j = 0; j < num; j++)if ((p&(1 << j)) == 0)dp[i + 1][p | (1 << j)] = (dp[i + 1][p | (1 << j)] + dp[i][p] * com(rem, (1 << j) - 1)) % mod;
		}
	}
	ll ans = 0;
	for (int p = 0; p < (1 << num); p++)
	{
		int c1 = 0, rem = (1 << num) - 1;
		for (int i = 0; i < num; i++)if (p&(1 << i))rem -= (1 << i), c1++;
		ll t = dp[gen][p];
		for (int i = 0; i < num; i++)
		{
			if ((p&(1 << i)) == 0)
			{
				t = t*com(rem, (1 << i))%mod;
				rem -= 1 << i;
			}
		}
		if (c1 % 2 == 0)ans = (ans + t) % mod;
		else ans = (ans + mod - t) % mod;
	}
	ll tim = 1;
	for (int i = 0; i < num; i++)tim = tim*kai[1<<i] % mod;
	printf("%lld\n", ans*tim%mod*(1 << num) % mod);
}

Measured memory_bytes: 17792
//For higher stack size use g++ -O2 -std=c++11 -Wall -Wl,--stack=268435456 a.cpp -o a.exe in cmd
    #include <bits/stdc++.h>
    #include <cstdio>
    #include <cstring>
    #include <cmath>
    #include <cstring>
    #include <chrono>
    #include <complex>
    #define ll long long
    #define ld long double
    #define vi vector<int>
    #define vll vector<ll>
    #define vvi vector < vi >
    #define pii pair<int,int>
    #define pll pair<long long, long long>
    #define mod 1000000007
    #define inf 1000000000000000001;
    #define all(c) c.begin(),c.end()
    #define mp(x,y) make_pair(x,y)
    #define mem(a,val) memset(a,val,sizeof(a))
    #define eb emplace_back
    #define pb push_back
    #define f first
    #define s second
    #define pi 3.14159265359
    
    
    using namespace std;
    int main()
    {
        std::ios::sync_with_stdio(false);
        int T;
        T=1;
        // cin.ignore(); must be there when using getline(cin, s)
        while(T--)
        {
            ll r;
            cin>>r;
            ld ans=2*pi*r;
            printf("%.9Lf\n",ans);
        }
        return 0;
    }


Measured memory_bytes: 3768
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;
int main() {
    int N, M;
    cin >> N >> M;
    int a[M], b[M];
    int Result[N] = {};
    for(int i = 0; i < M; i++) {
        cin >> a[i] >> b[i];
        Result[a[i] - 1] += 1;
        Result[b[i] - 1] += 1;
    }
    for(int i = 0; i < N; i++) {
        cout << Result[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#define pb(a) push_back(a)

using namespace std;

typedef vector<vector<char> > field_t;

typedef pair<int, int> point_t;

point_t operator+(const point_t &lhs, const point_t &rhs)
{
    point_t p = { lhs.first + rhs.first, lhs.second + rhs.second };
    return p;
}

bool operator==(const point_t &lhs, const point_t &rhs)
{
    return (lhs.first == rhs.first) && (lhs.second == rhs.second);
}

bool is_in_field(int col, int row, const point_t &point)
{
    const int c = point.second;
    const int r = point.first;
    return (0 <= c && c < col) && (0 <= r && r < row);
}

int solve(int col, int row, field_t &field, const point_t &start, const point_t &goal)
{
    // 2. 各マスの訪問履歴(memo)を作成する
    //    memoにはスタートからそのマスまでの歩数を格納する(初期値は0)
    vector<vector<int>> memo;
    for(int i = 0; i < row; ++i) {
        vector<int> v(col, 0);
        memo.push_back(v);
    }

    // 移動方向(上下左右)
    const point_t points[] = {
        { -1, 0 }, { 1, 0 }, { 0, -1 }, { 0, 1 },
    };

    // 3. スタートのマスをキューに格納する
    queue<point_t> q;
    q.push(start);

    // 11. 4から10をキューが空になるまで繰り返す
    while( !q.empty() ) {
        // 4. キューの先頭から一マス取得する
        point_t cur = q.front(); q.pop();

        // 5. 取り出したマスがゴールなら終了
        if(cur == goal) {
            return memo[cur.first][cur.second];
        }

        for(const auto &point : points) {
            // 6. 手順4で取り出したマス(cur)から上下左右の何れかに移動する
            point_t next = cur + point;
            // 7. 移動先のマス(next)が迷路外でないことを確認する(迷路外の場合は手順6に戻る)
            if( is_in_field(col, row, next) ) {
                const char s = field[next.first][next.second];
                // 8. 移動先のマス(next)が道またはゴールであることを確認する(道でもゴールでもない場合は手順6に戻る)
                if(s == '0' || s == 'g') {
                    // 9. 移動先のマス(next)が未訪問であることを確認する(訪問済みの場合は手順6に戻る)
                    if(memo[next.first][next.second] == 0) {
                        // 10. 移動先のマス(next)をキューに格納し、訪問履歴を更新する
                        q.push(next);
                        memo[next.first][next.second] = memo[cur.first][cur.second] + 1;
                    }
                }
            }
        }
    }
    return -1;
}

int main(){
  point_t start, goal;
  field_t field;
  int H,W;
  string temp;
  cin >> H;
  cin >> W;
  int a = 0;
  for (int i=0; i<H; i++) {
    vector<char> v;
    cin >> temp;
    for (int j=0; j<W; j++) {
      if (i == 0 && j == 0) {
        v.pb('s');
        start.first = 0;
        start.second = 0;
      } else if(i == H - 1 && j == W-1) {
        v.pb('g');
        goal.first = H-1;
        goal.second = W-1;
      } else if (temp[j] == '#') {
        v.pb('1');
        a++;
      } else {
        v.pb('0');
      }
    }
    field.push_back(v);
  }
  int result = solve(W, H, field, start, goal);
  // 最短歩数はsolveで計算する
  if (result == -1) {
    cout << -1 << endl;
  } else {
    cout << H*W - (result + 1) - a << endl;
  }
  // cout << solve(W, H, field, start, goal) << endl;
  return 0;
}


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

/*
 * 
 */
int main(int argc, char** argv) {
    int size,a,b,c,i;
    scanf("%d",&size);
    fflush(stdin);
    for(i=0;i<size;i++){
        scanf("%d %d %d",&a,&b,&c);
        if(a*a==b*b+c*c||b*b==a*a+c*c||c*c==a*a+b*b)printf("YES\n");
        else printf("NO\n");
    }    
    return (EXIT_SUCCESS);
}

Measured memory_bytes: 584
#include<bits/stdc++.h>
#include <math.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define lper(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9;
const ll INF=4e18;
const ll dy[4]={1,0,-1,0};
const ll dx[4]={0,-1,0,1};
int main() {
  int A;
  int B;
  cin >>A>>B;
  int C=A-2*B;
  if( C>=0) {
cout << C << endl;
  }
else {
cout << 0 << endl;
}
}
  
  

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

#include <complex>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#define debug(x) cerr << #x << " = " << (x) << endl;


#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 100010


int dfs(string s){
  
  bool flag = true;
  for(int i=1;i+1<s.size();i++){
    flag &= '0' <= s[i] && s[i] <= '9';
  }

  if(flag){
    return stoi(s.substr(1, s.size()-2))/2 + 1;
  }

  vector<int> vec;
  
  for(int i=1;i+1<s.size();){

    int l = i, r = 0;
    int c = 0;
    
    for(int j=i;;j++){
      if(s[j] == '[') c++;
      if(s[j] == ']'){
        c--;
        if(c == 0){
          r = j+1;
          break;
        }
      }
    }

    vec.push_back(dfs(s.substr(l,r-l)));

    if(s[r] == ']') break;
    
    i = r;
  }

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

  int res = 0;

  for(int i=0;i<vec.size()/2 + 1 ;i++){
    res += vec[i];
  }

  return res;
}

void solve(){
  string s;

  cin >> s;

  
  cout << dfs(s) << endl;
}

int main(){
  int t;

  scanf("%d",&t);

  while(t--){
    solve();
  }
  
  return 0;
}

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

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int testcase=1;
    //cin>>testcase;
    for(int p=0;p<testcase;p++){
    ll x=0,y=0;
     cin>>x>>y;
    if(y%2!=0)
    cout<<"No";
    else if(y<x*2 || y>x*4)
    cout<<"No";
    else cout<<"Yes";
        
    }

    return 0;
}


Measured memory_bytes: 3648
N, M = map(int, input().split())

highs = list(map(int, input().split()))

loads = [set([]) for _ in range(N)]

for _ in range(M):
    a, b = map(int, input().split())
    loads[a - 1].add(b - 1)
    loads[b - 1].add(a - 1)
# print(highs)
# print(loads)
count = 0
for i, tower_loads in enumerate(loads):
    highest = True
    for load in tower_loads:
        if highs[i] <= highs[load]:
            highest = False
            break
    if highest:
        # print(i)
        count += 1
print(count)


Measured memory_bytes: 108340
#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
#define REP(i,j,n) for(int i=(int)(j);i<=(int)(n);i++)
#define MOD 1000000007
#define int long long
#define ALL(a) (a).begin(),(a).end()
#define vi vector<int>
#define vii vector<vi>
#define pii pair<int,int>
#define priq priority_queue<int>
#define disup(A,key) distance(A.begin(),upper_bound(ALL(A),(int)(key)))
#define dislow(A,key) distance(A.begin(),lower_bound(ALL(A),(int)(key)))
int gcd(int X,int Y){
  if(X<Y)
    swap(X,Y);
  while(1){
    if(X%Y==0)
      break;
    int Z=X%Y;
    X=Y;
    Y=Z;
    }
  return Y;
  }
signed main(){
  int N,ans;
  cin>>N>>ans;
  rep(j,1,N){
    int X;
    cin>>X;
    ans=gcd(ans,X);
    }
  cout<<ans<<endl;
  }

Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Tarek
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        ACoffee solver = new ACoffee();
        solver.solve(1, in, out);
        out.close();
    }

    static class ACoffee {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            String s = in.next();
            if (s.charAt(2) == s.charAt(3) && (s.charAt(4) == s.charAt(5))) out.println("Yes");
            else out.println("No");
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

    }
}



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

int main(){
  int N;
  cin>>N;
  vector<int> vec(N);
  
  for(int i=0;i<N;i++)
    cin>>vec.at(i);
  
  sort(vec.begin(),vec.end());
  cout<<vec.back()-vec.at(0)<<endl;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
#include<string.h>
#include<set>
#include<stdio.h>
#include<math.h>
#include<queue>
#include<map>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cstring>
#include <cstdio>
#include <cstdlib>
#include<stack>
#include<vector>
map<int,int>TM;
int main()
{
    int a,b,c;
    cin>>a>>b>>c;
    for(int i=0;i<=a;i++)
    {
        for(int j=0;j<=b;j++)
        {
            TM[b*i+a*j-2*(i*j)]=1;
        }
    }
    if(TM[c]==1)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 13056
#include<bits/stdc++.h>
using namespace std;
int gcdEx(int a, int b, int *x, int *y){if(!a){*x=0;*y=1;return b;}
int x1,y1,gcd=gcdEx(b%a,a,&x1,&y1); *x=y1-(b/a)*x1;*y=x1; return gcd;}
int modI(int b, int m)      {int x,y;gcdEx(b,m,&x,&y);return (x%m+m)%m;}
typedef long long           ll;
typedef pair<int, int>      pii;
typedef vector<int>         vi;
typedef vector<pii>         vii;
typedef set<int>            si;
typedef map<string, int>    msi;
#define all(x) (x).begin(), (x).end()
#define make_unique(x) sort(all((x))); (x).resize(unique(all((x))) - (x).begin())
#define loop(i,b,n)           for(int i=b;i<n;i++)
#define loopv(b,n,a)         for(int i=b;i<n;i+=a)
#define loopr(b,n)           for(int i=n;i>=0;i--)

#define sum(a)     ( accumulate ((a).begin(), (a).end(), 0ll))
#define mine(a)    (*min_element((a).begin(), (a).end()))
#define maxe(a)    (*max_element((a).begin(), (a).end()))
#define mini(a)    ( min_element((a).begin(), (a).end()) - (a).begin())
#define maxi(a)    ( max_element((a).begin(), (a).end()) - (a).begin())
#define lowb(a, x) ( lower_bound((a).begin(), (a).end(), (x)) - (a).begin())
#define uppb(a, x) ( upper_bound((a).begin(), (a).end(), (x)) - (a).begin())

#define start_routine() int begtime = clock();
#define end_routine() int endtime = clock(); \
                      cerr << "\n\n" << "Time elapsed: " << \
                      (endtime - begtime)*1000/CLOCKS_PER_SEC << " ms\n\n"; \
                      return 0
#define mp                  make_pair
#define ff                  first
#define ss                  second
#define pb                  push_back
#define MOD                 1000000007
#define modA(a,b)           (((a%MOD)+(b%MOD))%MOD)
#define modS(a,b)           (((((a%MOD)-(b%MOD))%MOD)<0)?(int)(MOD+((a%MOD)-(b%MOD))%MOD):(int)(((a%MOD)-(b%MOD))%MOD))
#define modM(a,b)           (int)((((ll)(a%MOD))*((ll)(b%MOD)))%MOD)
#define modD(a,b)           ((modI(b,MOD)*(a%MOD))%MOD)
ll modP(ll x, ll y)         {ll r=1; x%=MOD; while(y>0){if(y&1){r=(r*x)%MOD;}
y=y>>1; x=(x*x)%MOD;} return r;}
#define trace1(x)               cerr<<#x<<": "<<x<<endl
#define trace2(x, y)               cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
//#define ONlo
int main()
{
//  freopen("input.txt","r",stdin);
    ll t=1;
//    cin>>t;
    while(t--)
    {
        ll n;
        cin>>n;
        vector<ll> arr(n);

                ll u,v;
       ll ans=0;
        loop(i,0,n)
        {
            cin>>arr[i];
        }
        long long  sum = 0;
    for (ll i = 0; i < 60; i++)
    {
        ll zc = 0, oc = 0;
        long long  idsum = 0;
        for (ll j = 0; j < n; j++)
        {
            if (arr[j] % 2 == 0)
                zc++;
            else
                oc++;
            arr[j] /= 2;
        }
        idsum =modM( modM(oc , zc) , modP(2,i));
    sum =modA(sum,idsum);
    }
    sum=sum%MOD;
        cout<<sum;
    }


return 0;
}



Measured memory_bytes: 2560