akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
using namespace std;
typedef long long int lint;
typedef pair<lint, lint> plint;
typedef pair<double long, double long> pld;
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((lint)(x).size())
#define POW2(n) (1LL << (n))
#define FOR(i, begin, end) for(lint i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(lint i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
template<typename T1, typename T2> pair<T1, T2> operator+(const pair<T1, T2>& l, const pair<T1, T2>& r) { return make_pair(l.first + r.first, l.second + r.second); }
template<typename T1, typename T2> pair<T1, T2> operator-(const pair<T1, T2>& l, const pair<T1, T2>& r) { return make_pair(l.first - r.first, l.second - r.second); }
const lint MOD = 1e9 + 7, INF = 1e18;

lint N;
int main() {
	cin.tie(0); ios_base::sync_with_stdio(false);
	cin >> N;
	cout << N + N * N + N * N * N;
}


Measured memory_bytes: 3632
#include <cstdio>
#include <bits/stdc++.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <cmath>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#define rep(i,n) for (int i=0;i<n;i++)
using ll = long long;
using namespace std;

void solve(){

}
int main (){
    ios::sync_with_stdio(0);
    cin.tie(0);
    ll n;
    cin >> n;
    vector<ll> a(n);
    rep(i,n) cin >> a[i];
    sort(a.begin(),a.end());
    ll cnt=0;
    if(a[n/2]==a[n/2-1]){
        cout << 0;
        return 0;
    }else{
        cout << a[n/2]-a[n/2-1];
    }
        
    

    return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define INF 9999999999
#define m0(x) memset(x,0,sizeof(x))
//#define fill(x,y) memset(x,y,sizeof(x))
#define print(x) cout<<x<<endl;
#define pe(x) cout<<x<<" ";
#define lb(v,n) lower_bound(v.begin(), v.end(), n);
#define ub(v,n) upper_bound(v.begin(), v.end(), n);
#define int long long


using namespace std;

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


int dy[4] = { 0,0,1,-1 };
int dx[4] = { 1,-1,0,0 };
int dxx[9] = { 0, 0,0,1,1,1,-1,-1,-1 };
int dyy[9] = { 0, 1,-1,0,1,-1,0,1,-1 };

const int MOD = 1e9 + 7;
const double PI = acos(-1);


int l[100010], r[100010];
int cum[100010];
signed main() {
	int N, Q; cin >> N >> Q;
	string S; cin >> S;
	m0(cum);
	REP(i, Q) {
		cin >> l[i] >> r[i];
	}

	int n = S.size();
	REP(i, n - 1) {
		if (S.substr(i, 2) == "AC") {
			cum[i + 2] = 1;
		}
	}
	REP(i, n) {
		cum[i + 1] += cum[i];
	}
	REP(i, Q) {
		int res = cum[r[i]] - cum[l[i]];
		print(res);
	}
}




Measured memory_bytes: 3456
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        try (Scanner sc = new Scanner(System.in)) {
            String S = sc.next();
            System.out.println(S.charAt(2) == S.charAt(3) && S.charAt(4) == S.charAt(5) ? "Yes" : "No");
        }
    }
}


Measured memory_bytes: 23252
package main

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

var sc = bufio.NewScanner(os.Stdin)

func scanInt() int {
	sc.Scan()
	iv, _ := strconv.Atoi(sc.Text())
	return iv
}

func init() {
	sc.Split(bufio.ScanWords)
}

func main() {
	n, x := scanInt(), scanInt()
	ans := 0
	a := make([]int, n)
	for i := range a {
		a[i] = scanInt()
		if d := a[i] - x; d > 0 {
			ans += d
			a[i] = x
		}
	}

	for i := range a[:n-1] {
		if d := a[i] + a[i+1] - x; d > 0 {
			ans += d
			a[i+1] -= d
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 3072
ns = list(map(int, list(input())))

if ns[0] + ns[1] + ns[2] + ns[3] == 7:
    print("{}+{}+{}+{}=7".format(ns[0], ns[1], ns[2], ns[3]))
elif ns[0] + ns[1] + ns[2] - ns[3] == 7:
    print("{}+{}+{}-{}=7".format(ns[0], ns[1], ns[2], ns[3]))
elif ns[0] + ns[1] - ns[2] + ns[3] == 7:
    print("{}+{}-{}+{}=7".format(ns[0], ns[1], ns[2], ns[3]))
elif ns[0] + ns[1] - ns[2] - ns[3] == 7:
    print("{}+{}-{}-{}=7".format(ns[0], ns[1], ns[2], ns[3]))
elif ns[0] - ns[1] + ns[2] + ns[3] == 7:
    print("{}-{}+{}+{}=7".format(ns[0], ns[1], ns[2], ns[3]))
elif ns[0] - ns[1] + ns[2] - ns[3] == 7:
    print("{}-{}+{}-{}=7".format(ns[0], ns[1], ns[2], ns[3]))
elif ns[0] - ns[1] - ns[2] + ns[3] == 7:
    print("{}-{}-{}+{}=7".format(ns[0], ns[1], ns[2], ns[3]))
elif ns[0] - ns[1] - ns[2] - ns[3] == 7:
    print("{}-{}-{}-{}=7".format(ns[0], ns[1], ns[2], ns[3]))


Measured memory_bytes: 3064
/*|In The Name Of Allah|*/

#include <bits/stdc++.h>

using namespace std;

const int N = 1e5+5;

int h;
int n;
int ar[N];

int main(){
    cin >> h >> n;
    int sum = 0;
    for(int i = 1; i <= n; i++){
        int x;
        cin >> x;
        sum += x;
    }
    if(sum >= h){
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}


Measured memory_bytes: 256
// ------------------------------------
// Date:2018/ 3/ 7
// Problem:ABC 077 SmallMultiple d.cpp
//
// ------------------------------------

#include <bits/stdc++.h>

using namespace std;

#define EACH(i,a) for (auto&& i : a)
#define FOR(i,a,b) for(int i=(int)a;i<(int)b;++i)
#define RFOR(i,a,b) for(int i=(int)b-1;i>=(int)a;--i)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(a) (a).begin(),(a).end()
#define debug(x) cerr << #x << ":" << x << endl
#define MIN(a, b) ((a) < (b) ? a : b)

typedef long long ll;

// static const int MOD = 1000000007;
static const int INF = 1e9 + 1;

// V:頂点 / line[from][to]:辺
struct Line {
  Line(int _cost, int _to)
    : cost(_cost), to(_to){}
  int cost;
  int to;
};

vector< Line > l[101010];
int d[101010];

void dijkstra()
{
  // q{cost, from}
  priority_queue< pair< int, int >, vector< pair< int, int > >, greater< pair< int, int > > > q;
  fill(d, d + 101010, INF);
  d[1] = 0;
  q.push(make_pair(0, 1));
  
  while (!q.empty()) {
    int cost, from;
    tie(cost, from) = q.top();
    q.pop();

    if (d[from] < cost) continue;

    REP(to, l[from].size()) {
      Line ml = l[from][to];
      if (d[from] + ml.cost < d[ml.to]) {
	d[ml.to] = d[from] + ml.cost;
	q.push(make_pair(d[ml.to], ml.to));
      }
    }
  }
}

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int K;
  cin >> K;
  REP(i, K) {

    // 次の頂点に対して重み1の辺を追加(K本目の線は最後用に作っておく)
    l[i].emplace_back(Line(1, (i + 1) % K));

    // 10倍の頂点に対して重み0の辺を追加
    l[i].emplace_back(Line(0, (i * 10) % K));
  }

  int ans = 1;
  dijkstra();

  ans += d[0];
  cout << ans << endl;
  
  return 0;
}



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

typedef double du ;
typedef string st ;
typedef long long ll ;
typedef long double ld ;
typedef long long int lli ;

#define vi vector <lli>
#define loop(num) for (lli i = 0 ; i < num ; i ++ )
#define loopcin(num , ar ) for (lli i = 0 ; i < num ; i ++ ) {cin >> ar [i] ;}
#define loopcout(num , ar) for (lli i = 0 ; i < num ; i ++ ) {cout << ar [i] << ' '; }

#define forr(num1 , num2) for (lli i = num1 ; i < num2 ; i ++ )
#define forrcin(num1 , num2 , ar ) for (lli i = num1 ; i < num2 ; i ++ ) {cin >> ar [i] ;}
#define forrcout(num1 , num2 , ar) for (lli i = num1 ; i < num2 ; i ++ ) {cout << ar [i] << ' '; }

#define D2forrcin(num1_1 , num1_2 , num2_1 , num2_2 , A ) for (lli i = num1_1 ; i < num1_2 ; i ++){ for (lli j = num2_1 ; j < num2_2 ; j++){cin >> A[i][j] ;}}
#define D2forrcout(num1_1 , num1_2 , num2_1 , num2_2 , A ) for (lli i = num1_1 ; i < num1_2 ; i ++){ for (lli j = num2_1 ; j < num2_2 ; j++){cout << A[i][j] << ' ' ;}cout << endl ;}

#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl

#define F first
#define S second

#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

int main ()
{
    fastio;
    lli r , d , x , su ;
    cin >> r >> d >> x ;
    su = x ;
    for (lli i = 0 ; i < 10 ; i ++)
    {
        su = r * su - d ;
        cout << su << endl ;
    }
    
    return 0 ;
}

/*___________________________________________________________________functions___________________________________________________________________________*/



Measured memory_bytes: 256
/*
AuThOr Gwj
*/
#include<bits/stdc++.h>
#define rb(a,b,c) for(int a=b;a<=c;++a)
#define rl(a,b,c) for(int a=b;a>=c;--a)
#define LL long long
#define IT iterator
#define PB push_back
#define II(a,b) make_pair(a,b)
#define FIR first
#define SEC second
#define FREO freopen("check.out","w",stdout)
#define rep(a,b) for(int a=0;a<b;++a)
#define KEEP while(1)
#define SRAND mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define random(a) rng()%a
#define ALL(a) a.begin(),a.end()
#define POB pop_back
#define ff fflush(stdout)
#define fastio ios::sync_with_stdio(false)
#define debug_pair(A) cerr<<A.FIR<<" "<<A.SEC<<endl;
using namespace std;
const int INF=0x3f3f3f3f;
typedef pair<int,int> mp;
typedef pair<mp,mp> superpair;
int main(){
	fastio;
	int m,n;
	cin>>n>>m;
	int l,r;
	r=n;
	l=n-m;
	int cnt=0;
	while(l<r){
		cnt++;
		if(cnt>m){
			break;
		}
		cout<<l<<" "<<r<<endl;
		l++,r--;
	}
	l=1,r=m;
	while(l<r){
		cnt++;
		if(cnt>m){
			break;
		}
		cout<<l<<" "<<r<<endl;
		l++,r--;
	}
	return 0;
}


Measured memory_bytes: 3652
N, M, *L = map(int, open(0).read().split())
dic = [[] for i in range(N+1)]
for a,b in zip(*[iter(L)]*2):
  dic[a] += [b]
  dic[b] += [a]

log = set([1])
pre = [1]
p = 1
while True:
  for v in dic[p]:
    if v not in log:
      break
  else:
    break
  p = v
  pre.append(v)
  log.add(v)
log = set()
ans = []
while True:
  if pre:
    p = pre.pop()
    log.add(p)
    ans.append(p)
    continue
  for v in dic[p]:
    if v not in log:
      break
  else:
    break
  p = v
  ans.append(v)
  log.add(v)
print(len(ans))
print(*ans)

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

//dp[i][j][k] マス(i, j)の偏りがkになるか
bool dp[81][81][80 * 2 * 80 + 1];

int main() {
    int h, w;
    cin >> h >> w;
    vector<vector<int>> a(h, vector<int>(w)), b(h, vector<int>(w));
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            cin >> a.at(i).at(j);
        }
    }
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            cin >> b.at(i).at(j);
        }
    }

    dp[0][1][0] = dp[1][0][0] = true;

    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            for (int k = 0; k <= 80 * 2 * 80; k++) {
                int d = abs(a.at(i).at(j) - b.at(i).at(j));
                dp[i + 1][j + 1][k] |= dp[i][j + 1][abs(k - d)] | dp[i + 1][j][abs(k - d)];
                if (k + d <= 80 * 2 * 80) 
                    dp[i + 1][j + 1][k] |= dp[i][j + 1][k + d] | dp[i + 1][j][k + d];
            }
        }
    }
    
    /*for (int i = 0; i <= h; i++) {
        for (int j = 0; j <= w; j++) {
            cout << i << ", " << j << endl;
            for (int k = 0; k <= 200; k++) {
                if (dp[i][j][k]) cout << k << endl;
            }
        }
    }*/
    
    for (int i = 0; i <= 80 * 2 * 80; i++) {
        if (dp[h][w][i]) {
            cout << i << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 81280
#include<iostream>
#include<vector>
using namespace std;
int main()
{
	vector<int>a;
	string s;cin>>s;
	int n=s.size(),ans=0,preans=1;
	for(int i=0;i<n;i++)a.push_back(s[i]-48);
	a.push_back(100);
	for(;ans!=preans;)
	{
		preans=ans;
		for(vector<int>::iterator it=a.begin();it!=a.end();)
		{
			if(*it+*(it+1)==1)
			{
				a.erase(it);
				a.erase(it);
				ans+=2;
			}
			else it++;
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 1020
W, H, N = [int(x) for x in input().split()]
H_lst = []
for i in range(H):
    W_lst = []
    for j in range(W):
        W_lst.append(0)
    H_lst.append(W_lst)
for n in range(N):
    x, y, a = [int(x) for x in input().split()]
    if a == 1:
        for i in range(H):
            for j in range(x):
                H_lst[i][j] = 1
    elif a == 2:
        for i in range(H):
            for j in range(x, W):
                H_lst[i][j] = 1
    elif a == 3:
        for i in range(y):
            for j in range(W):
                H_lst[i][j] = 1
    elif a == 4:
        for i in range(y, H):
            for j in range(W):
                H_lst[i][j] = 1
s = 0
for i in range(H):
    for j in range(W):
        if H_lst[i][j] == 0:
            s += 1
print(s)


Measured memory_bytes: 3064
X,Y=map(int,input().split())
ans=False
for i in range(1,X+1):
    t=X-i
    if (2*i)+(4*t)==Y:
        ans=True
        break
    elif (2*t)+(4*i)==Y:
        ans=True
        break
    else:
        continue
print('Yes' if ans==True else 'No')

Measured memory_bytes: 9184
#include"bits/stdc++.h"
#define int long long
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(a);i<(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define itr(i,x) for(auto i=(x).begin();i!=(x).end();++i)
#define All(x) (x).begin(),(x).end()
#define rAll(x) (x).rbegin(),(x).rend()
using namespace std;
using Graph=vector<vector<int>>;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
const int mod=1000000007;
int gcd(int x,int y){return y?gcd(y,x%y):x;}
int lcm(int x,int y){return x*y/gcd(x,y);}
int roundup(int a,int b){return	(a-1)/b+1;}
void YN(bool flg){cout<<(flg?"YES":"NO")<<endl;}
void Yn(bool flg){cout<<(flg?"Yes":"No")<<endl;}
void yn(bool flg){cout<<(flg?"yes":"no")<<endl;}

signed main(){
	int n,k;cin>>n>>k;
	int k1=n/k;
	int ans=k1*k1*k1;
	if(k%2==0){
		int t=(n+k/2)/k;
		ans+=t*t*t;
	}
	cout<<ans<<endl;
}


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

int main(){
  int n,m;
  cin>>n>>m;
  if(m==0 || n==0){
	  cout<<"0 0";
	  exit(0);
  }
  map<int, int> m1;
  vector<int> v(n+1,0);
  int x;
  string s;
  for(int i=0;i<m;i++){
	  cin>>x>>s;
	  if(s=="AC")
	   v[x]=1;
	  else if(s=="WA" && v[x]==0)
	   m1[x]+=1;
  }
  int p=0,ac=0;
  for(int i=0;i<=n;i++){
	  
	  if(v[i]==1){
		  ac+=1;
		  p=p+m1[i];
	  }
  }
  cout<<ac<<" "<<p; 
}


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

using namespace std;
const int maxn = 1e5 + 5;
int n, m;
vector<int> a[maxn];
int f[maxn];

int dp(int u)
{
    if (f[u] != -1) return f[u];
    f[u] = 0;
    for(int v: a[u]) f[u] = max(f[u], dp(v) + 1);
    return f[u];    
}

int main()
{
    #ifdef NTMA 
        freopen("abc.inp", "r", stdin);
    #endif
    memset(f, 255, sizeof(f));
    cin >> n >> m;
    while (m--){
        int u, v;
        cin >> u >> v;
        a[u].push_back(v);
    }
    int ans = 0;
    for(int i=1; i<=n; ++i) ans = max(ans, dp(i));
    cout << ans;
    return 0;
}

Measured memory_bytes: 7424
#include <stdio.h>
int main(){
	int A,B;
	scanf("%d %d",&A,&B);
	if(A==1){
    	A=14;
	}
	if(B==1){
    	B=14;
	}
	if(A>B){
    	printf("Alice");
    }else if(A<B){
    	printf("Bob");
    }else{
    	printf("Draw");
    }
	return 0;
}

Measured memory_bytes: 128
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <tuple>
#include <stack>
#include <bitset>

using namespace std;
typedef long long ll;

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

    ll N;
    cin >> N;
    ll ans = 0;
    ans = (N + 1) * N / 2 - N;
    cout << ans << endl;
    
    return 0;
}
    


Measured memory_bytes: 3164
#include <iostream>
#include<cstdlib>
#include<queue>
#include<set>
#include<vector>
#include<string>
#include<algorithm>
#include<stack>
#include<map>
#include<cstdio>
using namespace std;
#define rep(i,a) for(int i=0;i<a;i++)
#define mp make_pair
#define pb push_back
#define P pair<int,int>
#define ll __int64
//#define ll long long
const int INF=111111111;
int n,k;
int a[111111];
const int N=5005;
const int K=5005;
bool dp[N][K];
int t[N];

void dynamic_programming(int x){
	rep(i,N)rep(j,K)dp[i][j]=0;
	int pos=0;
	rep(i,n)if(x!=i)t[pos++]=a[i];

	dp[0][0]=1;
	rep(i,pos){
		rep(j,K+1){
			if(dp[i][j]){
				if(j+t[i]<=K){dp[i+1][j+t[i]]=1;}
				dp[i+1][j]=1;
			}
		}
	}

	//rep(i,k+1)if(dp[pos][i])cout<<i<<" ";
}

int main(){
	cin>>n>>k;
	rep(i,n)cin>>a[i];
	sort(a,a+n);

	int ans=0;
	int l=-1,r=n,mid=(l+r)/2;

	while(r-l>1){
		//cout<<mid<<endl;
		bool is=0;
		dynamic_programming(mid);
		if(k-a[mid]<=0)is=1;
		else for(int j=k-a[mid];j<k;j++)if(dp[n-1][j])is=1;
		if(!is)l=mid;//不要
		else r=mid;
		mid=(r+l)/2;
	}

	cout<<r<<endl;
	return 0;
}


Measured memory_bytes: 24960
import std.stdio, std.string, std.conv, std.algorithm;

void main() {
    int[] tmp = readln.split.to!(int[]);
    int h = tmp[0], w = tmp[1];
    string[] grid = new string[h];
    foreach (i; 0 .. h) {
        string s = readln.chomp;
        grid[i] = s;
    }
    int[][] a = new int[][](h, w);
    foreach (i; 0 .. h) {
        foreach (j; 0 .. w) {
            if (j == 0) {
                if (grid[i][j] == '.') a[i][j] = 1;
                else a[i][j] = 0;
            } else {
                if (grid[i][j] == '.') a[i][j] = a[i][j-1] + 1;
                else a[i][j] = 0;
            }
        }
    }
    int[][] b = new int[][](h, w);
    foreach (i; 0 .. h) {
        foreach_reverse (j; 0 .. w) {
            if (j == w - 1) {
                if (grid[i][j] == '.') b[i][j] = 1;
                else b[i][j] = 0;
            } else {
                if (grid[i][j] == '.') b[i][j] = b[i][j+1] + 1;
                else b[i][j] = 0;
            }
        }
    }
    int[][] c = new int[][](h, w);
    foreach (j; 0 .. w) {
        foreach (i; 0 .. h) {
            if (i == 0) {
                if (grid[i][j] == '.') c[i][j] = 1;
                else c[i][j] = 0;
            } else {
                if (grid[i][j] == '.') c[i][j] = c[i-1][j] + 1;
                else c[i][j] = 0;
            }
        }
    }
    int[][] d = new int[][](h, w);
    foreach (j; 0 .. w) {
        foreach_reverse (i; 0 .. h) {
            if (i == h - 1) {
                if (grid[i][j] == '.') d[i][j] = 1;
                else d[i][j] = 0;
            } else {
                if (grid[i][j] == '.') d[i][j] = d[i+1][j] + 1;
                else d[i][j] = 0;
            }
        }
    }
    int ans = 0;
    foreach (i; 0 .. h) {
        foreach (j; 0 .. w) {
            ans = max(ans, a[i][j]+b[i][j]+c[i][j]+d[i][j]-3);
        }
    }
    ans.writeln;
}

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

using namespace std;

typedef uint64_t u64;
typedef int64_t s64;
typedef uint32_t u32;
typedef int32_t s32;
typedef vector<s32> vs32;
typedef vector<u32> vu32;
typedef vector<s64> vs64;
typedef vector<u64> vu64;

const double PI=3.14159265358979323846;

#define MAX(x, y) ((x) < (y) ? (y) : (x))
#define MIN(x, y) ((x) > (y) ? (y) : (x))

#define rep(i, N) for(int i = 0; i < N; ++i)

#define CEIL(x, y) (((x) + (y) - 1) / (y))
#define MOD 1000000007ULL

int partition(vs32& A, int p, int r)
{
  int x = A[r];
  int i = p - 1;

  for (int j  = p; j < r; ++j)
  {
    if (A[j] <= x)
    {
      ++i;
      swap(A[i], A[j]);
    }
  }
  swap(A[i + 1], A[r]);

  return i + 1;
}

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

    int n;
    cin >> n;

    vs32 A;
    A.resize(n);
    rep (i, n)
    {
      cin >> A[i];
    }

    int idx = partition(A, 0, n - 1);

    rep (i, n)
    {
      if (i > 0) cout << " ";
      if (i == idx) cout << "[";
      cout << A[i];
      if (i == idx) cout << "]";
    }
    cout << "\n";
    return 0;
}



Measured memory_bytes: 3264
#include<stdio.h>
#include <string.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main(){
  char S[110];
  
  scanf("%s", S);

  int len = strlen(S);
  rep(i, len)
    printf("x");
    printf("\n");
  
  return 0;
} 

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

string str;
int p;

int negate_(int f) { return 2 - f; }

int add(int a, int b) {
  if (a == 2 || b == 2) {
    return 2;
  } else if (a == 0 && b == 0) {
    return 0;
  } else {
    return 1;
  }
}
int mult(int a, int b) {
  if (a * b == 0) {
    return 0;
  } else if (a * b == 4) {
    return 2;
  } else {
    return 1;
  }
}

int P, Q, R;

int term(char c) {
  switch (c) {
    case 'P':
     return P;
    case 'Q':
      return Q;
    case 'R':
      return R;
  }
}

int formula() {
  if (str[p] == '-') {
    p++; // read -
    int f = formula();
    return negate_(f);
  } else if (isdigit(str[p])) {
    int f = str[p] - '0';
    p++; // read [0-2]
    return f;
  } else if (isalpha(str[p])) {
    int f = term(str[p]);
    p++; // read [P-R]
    return f;
  } else {
    p++; // read (
    int a = formula();
    if (str[p] == '*') {
      p++; // read *
      int b = formula();
      p++; // read )
      return mult(a, b);
    } else {
      p++; // read +
      int b = formula();
      p++; // read )
      return add(a, b);
    }
  }
}

int main() {
  while (cin >> str and str != ".") {
    p = 0;
    int ans = 0;
    for (P = 0; P < 3; P++) 
      for (Q = 0; Q < 3; Q++)
        for (R = 0; R < 3; R++)
          if (p = 0, formula() == 2) 
            ans++;
    cout << ans << endl;
  }
}

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

using namespace std;

int N, Y;

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

    int bn[3];
    bn[0] = bn[1] = bn[2] = 0;

    bn[2] = (Y % 5000) / 1000;
    Y -= 1000 * bn[2];
    N -= bn[2];

    for (; Y > 0 && N > 0;) {
        int rel = Y - N * 5000;

        if (rel > 0) {
            bn[0]++;
            Y -= 10000;
            N--;
        }
        else if (rel < 0) {
            bn[2] += 5;
            Y -= 5000;
            N -= 5;
        }
        else {
            bn[1] += Y / 5000;
            Y = N = 0;
        }
    }

    if (Y | N) {
        cout << "-1 -1 -1";
    }
    else {
        cout << bn[0] << " " << bn[1] << " " << bn[2] << endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <map>
#include <sstream>

using namespace std;

int main() {
  string s;
  string out;
  getline(cin,s);
  for (int i=0; i < (int)s.length(); i++) {
    if (s[i] == 'B' && out.length() > 0) out.erase(out.length()-1);
    else if (s[i] != 'B') out.push_back(s[i]);
  }
  cout << out << endl;
  return 0;
}


Measured memory_bytes: 3536
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define REP(i, n) rep(i, 0, n)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define int long long
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e12;

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int ans = 0, n, k;
    cin >> n >> k;
    rep(i, 0, n){
        int x;
        cin >> x;
        ans += 2 * min(x, k - x);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
/*
 * BugHunt.cpp
 *
 *  Created on: Oct 12, 2013
 *      Author: Hesham
 */
#include<iostream>
#include<string>
#include<map>
#include<ctime>
#include<vector>
#include<queue>
#include<stack>
#include<set>
#include<algorithm>
#include<sstream>
#include<iomanip>
#include<cstring>
#include<bitset>
#include<fstream>
#include<cmath>
#include<cassert>
#include <stdio.h>
#include<ctype.h>
using namespace std;
struct Key{
	map<int, int> keyVal;
	int sz;
	Key(){}
	Key(int szsz) : sz(szsz){

	}
};
map<char, Key > arr;
void declaration(string l){
	char n = l[0];
	int i = 0;
	while(l[i] < '0' || l[i] > '9')
		++i;
	int sz = 0;
	while(l[i] >= '0' && l[i] <= '9'){
		sz = sz * 10 + l[i] - '0';
		++i;
	}
	arr[n] = Key(sz);
}
int evaluateAssign(string l, bool left, char& n){
	stack<char>s;
	int val = 0;
	for(int k = 0; k < l.size(); ++k){
		if((l[k] >= 'a' && l[k] <= 'z') || (l[k] >= 'A' && l[k] <= 'Z'))
			s.push(l[k]);
		if(l[k] >= '0' && l[k] <= '9')
			val = val * 10 + l[k] - '0';
		if(l[k] == '[')
			continue;
		if(l[k] == ']'){
			char a = s.top();
			s.pop();
			if(val >= arr[a].sz)
				return -1;
			if(s.empty() && left){
				n = a;
				return val;
			}
			if(arr[a].keyVal.find(val) == arr[a].keyVal.end())
				return -1;
			val = arr[a].keyVal[val];
		}
	}
	return val;
}
vector<string> split(string l){
	int i = 0;
	string s;
	while(i < l.size() && l[i] != '=')
		s += l[i++];
	vector<string> res;
	res.push_back(s);
	++i;
	s = "";
	while(i < l.size())
		s += l[i++];
	if(s.size())
		res.push_back(s);
	return res;
}
int main(){
	//freopen("in.txt", "r", stdin);
	string line;
	int ans = 0;
	int nLine = 1;
	while(cin >> line){
		if(line == "."){
			if(nLine == 1)
				break;
			cout << ans << endl;
			arr.clear();
			nLine = 1;
			ans = 0;
			continue;
		}
		vector<string>exp = split(line);
		if(exp.size() == 1)
			declaration(line);
		else{
			char a;
			int indx = evaluateAssign(exp[0], 1, a);
			int val = evaluateAssign(exp[1], 0, a);
			if((indx == -1 || val == -1) && !ans)
				ans = nLine;
			else
				arr[a].keyVal[indx] = val;
		}
		++nLine;
	}
}

Measured memory_bytes: 1260
#include <iostream>
#include <cstdint>
#include <cmath>
#include <string>
#include <vector>
#include <map>
#include <algorithm>

int main(void)
{
    int64_t n, m;
    std::cin >> n >> m;
    std::vector<int64_t> m_list(m, 0);

    for (int64_t i=0; i<n; ++i) {
        int64_t k;
        std::cin >> k;
        for (int64_t j=0; j<k; ++j) {
            int64_t a;
            std::cin >> a;
            m_list.at(a-1)++;
        }
    }

    int64_t count = 0;
    for (int64_t i=0; i<m; ++i) {
        if (m_list.at(i) == n) count++;
    }

    std::cout << count << std::endl;

    return 0;
}

Measured memory_bytes: 256
A, B = [int(i) for i in input().split(" ")]
if B == 1:
  print(0)
elif B <= A:
  print(1)
else:
  if (B-1)%(A-1) == 0:
    print((B - 1) // (A - 1))
  else:
    print((B - 1) // (A-1) + 1)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
/* clang-format off */
#define MOD 1000000007
#define INF 1000000000
#define REP(i, n) for (ll i = 0, i##_len = (n); i < i##_len; ++i)
#define ALL(a) (a).begin(), (a).end()
#define __DEBUG__
#ifdef __DEBUG__
#define CH_P(a) cout <<"check_point("<<#a<<")" << "\n";
#define DEBUG(x) cout<<#x<<":"<<x<<"\n"
#define DEBUGS(v) cout << #v << ":";for(auto x:v){cout<<x<<" ";}cout<<"\n"
#endif
#ifndef __DEBUG__
#define CH_P(a) 
#define DEBUG(x) 
#define DEBUGS(v) 
#endif
/* clang-format on */

void is_prime_cal(ll n, vector<bool> &is_prime) {
  // nまでの素数を生成
  // vector<bool> is_prime(n + 1, true);
  vector<bool> tmp(n + 1, true);
  is_prime = tmp;
  for (ll i = 0; i <= n; i++) {
    if (!is_prime.at(i)) continue;
    if (i == 0 || i == 1) is_prime.at(i) = false;
    if (is_prime.at(i)) {
      for (ll j = 2; j * i <= n; j++) {
        is_prime.at(j * i) = false;
      }
    }
  }
}

void prime_gen(ll n, vector<ll> &prime) {
  // nまでの素数を生成
  vector<bool> is_prime(n + 1, true);
  for (ll i = 0; i <= n; i++) {
    if (!is_prime.at(i)) continue;
    if (i == 0 || i == 1) is_prime.at(i) = false;
    if (is_prime.at(i)) {
      for (ll j = 2; j * i <= n; j++) {
        is_prime.at(j * i) = false;
      }
    }
  }
  REP(i, n + 1) {
    if (is_prime[i]) prime.push_back(i);
  }
}

void factorization(ll n, vector<bool> is_prime, set<ll> &f) {
  // 準備:is_prime_genでis_primeを生成しておく
  // factor[i].first = i番目の素数
  // factor[i].second = 指数
  vector<ll> prime;

  ll check_num = (ll)(sqrt(n));
  REP(i, check_num + 1) {
    if (is_prime.at(i)) prime.push_back(i);
  }
  for (auto &p : prime) {
    if (n % p == 0) f.insert(p);
    while (n % p == 0) n /= p;
    if (n == 1) break;
  }
  if (n != 1) {
    f.insert(n);
  }
}

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

  ll n;
  cin >> n;
  vector<ll> a(n);
  REP(i, n) { cin >> a[i]; }

  ll g = a[0];
  REP(i, n) { g = gcd(g, a[i]); }
  if (g != 1) {
    cout << "not coprime" << endl;
    return 0;
  }

  set<ll> fac;
  vector<bool> is_prime;
  is_prime_cal(sqrt(*max_element(ALL(a))), is_prime);
  bool fp = true;
  REP(i, n) {
    set<ll> f;
    factorization(a[i], is_prime, f);
    for (auto x : f) {
      if (fac.count(x)) {
        fp = false;
        break;
      }
      fac.insert(x);
    }
    if (!fp) break;
  }

  if (fp)
    cout << "pairwise coprime" << endl;
  else
    cout << "setwise coprime\n";

  return 0;
}


Measured memory_bytes: 11028
#include<bits/stdc++.h>
/*   -- AUTHOR -- 
  ---- cervotrex ---- 
*/
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define ll long long int
#define eb emplace_back
#define mk make_pair
#define all(arr) arr.begin(),arr.end()
#define mod 1000000007
const ll INF = 1LL << 60;
const int MAX_N = 1000005;

template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
#define ook order_of_key
#define fbo find_by_order
// ordered_set <int> s  ;
// auto x=s.find_by_order(k);
// s.order_of_key(val);

vector<vector<int> > adj;
vector<bool> vis;

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int t=1;
  // cin>>t;
  while(t--){
    int n; cin>>n;
    vector<int> a(n);
    int ans=0;
    for(int i=0;i<n;i++){
      int k; cin>>k;
      if(i%2==0&&k%2)
        ans++;
    }
    cout<<ans<<"\n";
  }
  return 0;
}

Measured memory_bytes: 3612
import scala.annotation.tailrec
import scala.collection.mutable
import scala.io.StdIn._
object Main extends App {
  val MAX = 200000000.0
  val MIN = -MAX
  val n = readInt()
  val coordinates = mutable.Map[Char, List[Coordinate]]().withDefaultValue(Nil)
  for (_ ← 0 until n) {
    val Array(x, y, d) = readLine.trim.split(' ')
    coordinates(d.head) ::= Coordinate(x.toDouble, y.toDouble)
  }
  val constMinX = List('U', 'D').flatMap(coordinates).minByOption(_.x).map(_.x).getOrElse(MAX)
  val constMaxX = List('U', 'D').flatMap(coordinates).maxByOption(_.x).map(_.x).getOrElse(MIN)
  val constMinY = List('L', 'R').flatMap(coordinates).minByOption(_.y).map(_.y).getOrElse(MAX)
  val constMaxY = List('L', 'R').flatMap(coordinates).maxByOption(_.y).map(_.y).getOrElse(MIN)
  val minUp = coordinates('U').minByOption(_.y).map(_.y).getOrElse(MAX)
  val maxUp = coordinates('U').maxByOption(_.y).map(_.y).getOrElse(MIN)
  val minDown = coordinates('D').minByOption(_.y).map(_.y).getOrElse(MAX)
  val maxDown = coordinates('D').maxByOption(_.y).map(_.y).getOrElse(MIN)
  val minRight = coordinates('R').minByOption(_.x).map(_.x).getOrElse(MAX)
  val maxRight = coordinates('R').maxByOption(_.x).map(_.x).getOrElse(MIN)
  val minLeft = coordinates('L').minByOption(_.x).map(_.x).getOrElse(MAX)
  val maxLeft = coordinates('L').maxByOption(_.x).map(_.x).getOrElse(MIN)

  val changeTime = List(0, constMinY - minUp, minDown - constMinY, constMinX - minRight, minLeft - constMinX, constMaxY - maxUp, maxDown - constMaxY, constMaxX - maxRight, maxLeft - constMaxX, (minDown - minUp) / 2, (maxDown - maxUp) / 2, (minLeft - minRight) / 2, (maxLeft - maxRight) / 2).filter(_ >= 0)

  println(
    "%.15f".format(changeTime.map{t ⇒
      val minX = List(constMinX, minRight + t, minLeft - t).min
      val maxX = List(constMaxX, maxRight + t, maxLeft - t).max
      val minY = List(constMinY, minUp + t, minDown - t).min
      val maxY = List(constMaxY, maxUp + t, maxDown - t).max
      (maxX - minX) * (maxY - minY)
    }.min)
  )

  implicit class Scope[T](val receiver: T) extends AnyVal {
    def let[A](@inline func: T ⇒ A): A = func(receiver)
    def tap(@inline func: T ⇒ Unit): T = {
      func(receiver)
      receiver
    }
  }
  implicit class Wrap[T](val receiver: List[T]) extends AnyVal {
    def minByOption[A: Ordering](@inline keySelector: T ⇒ A): Option[T] = {
      receiver match {
        case Nil ⇒ None
        case _ ⇒ Some(receiver.minBy(keySelector))
      }
    }
    def maxByOption[A: Ordering](@inline keySelector: T ⇒ A): Option[T] = {
      receiver match {
        case Nil ⇒ None
        case _ ⇒ Some(receiver.maxBy(keySelector))
      }
    }
  }
}
case class Coordinate(x: Double, y: Double)

Measured memory_bytes: 78684
# 入力が10**5とかになったときに100ms程度早い
import sys
read = sys.stdin.readline


def read_ints():
    return list(map(int, read().split()))


def read_a_int():
    return int(read())


def read_matrix(H):
    '''
    H is number of rows
    '''
    return [list(map(int, read().split())) for _ in range(H)]


def read_map(H):
    '''
    H is number of rows
    文字列で与えられた盤面を読み取る用
    '''
    return [read()[:-1] for _ in range(H)]


def read_col(H, n_cols):
    '''
    H is number of rows
    n_cols is number of cols

    A列、B列が与えられるようなとき
    '''
    ret = [[] for _ in range(n_cols)]
    for _ in range(H):
        tmp = list(map(int, read().split()))
        for col in range(n_cols):
            ret[col].append(tmp[col])

    return ret


N = read_a_int()
L = read_ints()
L.sort()
# import numpy as np
# L = np.array(L)
from bisect import bisect_left

cnt = 0
for i in range(N):
    a = L[i]
    for j in range(i+1, N):
        b = L[j]
        # ここで二分探索するか
        cnt += bisect_left(L, a+b) - (j+1)
        # L_tmp = L[j+1:]
        # cnt += np.sum(L_tmp < b+a)

print(cnt)


Measured memory_bytes: 3188
/* author:hellojim */
#include<bits/stdc++.h>
#include<iostream>
#include<string>
#include<cmath>
#include<cstdio>
#include<cctype>
#include<cstring>
#include<iomanip>
#include<cstdlib>
#include<ctime>
#include<set>
#include<map>
#include<utility>
#include<queue>
#include<vector>
#include<stack>
#include<sstream>
#include<algorithm>
#define forn(i,a,b)for(int i=(a),_b=(b);i<=_b;i++)
#define fore(i,b,a)for(int i=(b),_a=(a);i>=_a;i--)
#define rep(i,n)for(int i=0,_n=n;i<n;i++)
#define ll long long
#define pii pair<int,int>
#define vi vector<int>
#define vpii vector<pii>
#define m_p make_pair
#define re return
#define pb push_back
#define si set<int>
#define ld long double
#define X first
#define Y second
#define st string
#define ull unsigned long long
#define mod 1000000007
#define INF 1000000007
#define x1 XZVJDFADSPFOE
#define y1 GASDIJSLDAEJF
#define x2 DFDAJKVOHKWIW
#define y2 PSFSAODSXVNMQ
#define LLINF 0x3f3f3f3f3f3f3f3fLL
using namespace std;
inline void read(int &x)
{
	short negative=1;
    x=0;
    char c=getchar();
    while(c<'0' || c>'9')
    {
		if(c=='-')
			negative=-1;
		c=getchar();
	}
    while(c>='0' && c<='9')
        x=(x<<3)+(x<<1)+(c^48),c=getchar();
    x*=negative;
}
ll quickpower(ll n,ll k){
	ll ans=1;
	while(k){
		if(k%2){
			ans*=n;
			ans%=mod;
		}
		n*=n;
		n%=mod;
		k/=2;
	}
	return ans;
}
string int_to_string(int n)
{
	string s="";
	while(n)
	{
		int now=n%10;
		s+=now+'0';
		n/=10;
	}
	reverse(s.begin(),s.end());
	return s;
}
int string_to_int(string s)
{
	int n=0;
	rep(i,s.size())
	{
		n*=10;
		n+=s[i]-'0';
	}
	return n;
}
bool used[200100];
vector<ll>v[200100];
ll n,m;
ll ans=0;
ll dfs(int x)
{
	ll res=0;
	used[x]=1;
	rep(i,v[x].size())
	{
		if(!used[v[x][i]])
		{
			res+=dfs(v[x][i]);
		}
	}
	return res+1;
}
int main()
{
	ios::sync_with_stdio(0);
	//think twice,code once
	cin>>n>>m;
	rep(i,m)
	{
		ll a,b;
		cin>>a>>b;
		a--,b--;
		v[a].pb(b);
		v[b].pb(a);
	}
	ans=0;
	rep(i,n)
	{
		if(!used[i])ans=max(ans,dfs(i));
	}
	cout<<ans<<endl;
	return 0;
}



Measured memory_bytes: 24128
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<map>
#include<math.h>

typedef  long long ll;

#define rep(i,a,n) for(ll (i)=(a);(i)<(n);(i)++)
#define rrep(i,a,n) for(ll (i)=(a);(i)>=(n);(i)--)

#define INF ll 1 << 60
#define MOD 1000000007


using namespace std;

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

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

int gcd(long long int a,long long int b){
    long long int r;
    if(a < b){
        int tmp;
        tmp = a;
        a = b;
        b = tmp;
    }
    while(r = a % b){
        a = b;
        b = r;
    }
    return a;
}


void ys(){
    cout << "Yes" << endl;
}

void yb(){
    cout << "YES" << endl;
}

void ns(){
    cout << "No" << endl;
}

void nb(){
    cout << "NO" << endl;
}

int dig(int d){
    int ans = 1;
    if(d == 0) return ans;
    while(d != 0){
        d--;
        ans*=100;
    }
    return ans;
}

ll divisors(ll n) {
    vector<ll> res;

    for(ll i = 1; i*i <= n; ++i) {
        if(n % i != 0) continue;
        res.push_back(i-1);
        if(n/i == i) continue;
        res.push_back((n/i)-1);
    }

    ll ans = 0;

    rep(i,0,res.size()){
        if(res[i] != 0)
        if(n/res[i] == n%res[i]) ans += res[i];
    } 
    return ans;
}
vector<string> ans;
void solve(void){
    ll a,b,c,x,y;
    cin >> a >> b >> c >> x >> y;
    ll ans = 0;
    if(a+b >= 2*c){
        ans=2*c*min(x,y);
////// OK
        if(min(x,y) == x){
            y -= x;
            x = 0;
            ans+=min(2*c,b)*y;
        }else {
            x -= y;
            y = 0;
            ans+=min(2*c,a)*x;
        }
    }else{
        ans = x*a+y*b;
    }
    cout << ans << endl;
}

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

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

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

using namespace std;

template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}
template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

int main(){
    ll n; cin >> n;
    vector<ll> v(n);
    rep(i,n) {
        cin >> v[i];
    }
    sort(v.begin(), v.end());
    ll q; cin >> q;
    int count = 0;
    rep(i, q) {
        ll tmp; cin >> tmp;
        if(binary_search(v.begin(), v.end(), tmp))
            count++;
    }
    cout << count << endl;
}



Measured memory_bytes: 3520
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
	Scanner sc = new Scanner(System.in);
	int N = sc.nextInt();
	if(N%10==2 || N%10==4 || N%10==5 || N%10==7 || N%10==9)
	    System.out.print("hon");
	else if(N%10==0 || N%10==1 || N%10==6 || N%10==8)
	    System.out.print("pon");
	else
	    System.out.print("bon");
    }
}


Measured memory_bytes: 35680
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#define FOR(i,k,n)  for(int i = (k);i < (n);++i)
#define REP(i,n)    FOR(i,0,n)

using namespace std;
using ll = int64_t;
using vecint = vector<int>;
using vecll = vector<ll>;
constexpr ll MOD = 998244353;

int main()
{
  int n;
  cin>>n;
  string s;
  cin>>s;
  int cnt[3] = {0, 0, 0};
  ll sum = 1;
  for(auto&& c : s) {
    string rgb = "RGB";
    auto id = boost::find(rgb, c) - begin(rgb);
    auto oid1 = (id+1)%3;
    auto oid2 = (id+2)%3;
    auto& cnt0 = cnt[id];
    auto& cnt1 = cnt[oid1];
    auto& cnt2 = cnt[oid2];
    if (cnt1 && cnt2) {
      sum *= min(cnt1, cnt2);
      --cnt1; --cnt2;
    } else if (cnt0 < cnt1) {
      sum *= cnt1 - cnt0;
      ++cnt0;
    } else if (cnt0 < cnt2) {
      sum *= cnt2 - cnt0;
      ++cnt0;
    } else { // cnt0 >= cnt1, cnt2
      ++cnt0;
    }
    sum %= MOD;
  }
  FOR(i,1,n+1) {
    sum *= i;
    sum %= MOD;
  }
  cout<<sum<<endl;
  return 0;
}


Measured memory_bytes: 900
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define f first
#define s second
#define go ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define mem(arr,v) memset(arr,v,sizeof(arr))
/*bool sortbysec(const pair<int,int> &a,
              const pair<int,int> &b)
{
    return (a.second < b.second);
} */
int main()
{
     double n,t,a,mn=INT_MAX,v,pk,kk,pos;
     cin>>n>>t>>a;
     for(int i=1;i<=n;i++)
     {
         cin>>v;
         kk=t-v*0.006;
         if(kk>a)
            pk=kk-a;
         else
            pk=a-kk;
         if(mn>pk)
         {
             pos=i;
             mn=pk;
         }
     }
     cout<<pos<<endl;
}



Measured memory_bytes: 256
n,k=map(int,input().split())
h=list(map(int,input().split()))
dp=[0]*n
for i in range(1,n):
  dp[i]=dp[i-1]+abs(h[i-1]-h[i])
  for j in range(2,min(k+1,i+1)):
    dp[i]=min(dp[i],dp[i-j]+abs(h[i-j]-h[i]))
print(dp[-1])


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

const int Maxn = 105;
const int Inf = 1000000000;

int n, m;
char B[Maxn][Maxn];
int dp[Maxn][Maxn];

int main()
{
    scanf("%d %d", &n, &m);
    for (int i = 0; i < n; i++)
        scanf("%s", &B[i]);
    fill((int*)dp, (int*)dp + Maxn * Maxn, Inf);
    dp[0][0] = B[0][0] == '#';
    for (int i = 0; i < n; i++)
        for (int j = 0; j < m; j++) {
            if (i + 1 < n)
                dp[i + 1][j] = min(dp[i + 1][j], dp[i][j] + (B[i][j] != B[i + 1][j]));
            if (j + 1 < m)
                dp[i][j + 1] = min(dp[i][j + 1], dp[i][j] + (B[i][j] != B[i][j + 1]));
        }
    int res = dp[n - 1][m - 1] + (B[n - 1][m - 1] == '#');
    res /= 2;
    printf("%d\n", res);
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main (){
 
 int H1, M1, H2, M2, K;
 
 scanf("%d %d %d %d %d", &H1, &M1, &H2, &M2, &K);
 
 int sum = ((H2 - H1)*60) + (M2 - M1);
 int ans = sum - K;
 
 printf("%d", ans);
 return 0;
}

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

const int mod = 1e9 + 7;
const int N = 4e3 + 7;
int dp[N][N], n, S;

void add(int &a, int b) {
  a += b;
  if (a >= mod) {
    a -= mod;
  }
}

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0); cout.tie(0);
  dp[0][0] = 1;
  for (int i = 0; i < N - 1; ++i) {
    for (int j = 0; j < N - 1; ++j) {
      add(dp[i + 1][j], dp[i][j]);
      add(dp[i + 1][j + 1], dp[i][j]);
    }
  }
  cin >> S;
  S -= 3;
  int answer = 0;
  for (int i = 1; S >= 0; i++, S -= 3) {
    add(answer, dp[S + i - 1][i - 1]);
  }
  cout << answer << "\n";
    

}



Measured memory_bytes: 65900
a,b,c,x,y = map(int, input().split())

pair = min(x,y)
cost = 0

if a + b > 2 * c:
    cost = 2 * c * pair
else:
    cost = (a + b) * pair

if (x - pair) > (y - pair):
    if a > 2 * c:
        cost = cost + 2 * c * (x - pair)
    else:
        cost = cost + a * (x - pair)

else:
    if b > 2 * c:
        cost = cost + 2 * c * (y - pair)
    else:
        cost = cost + b * (y - pair)

print(cost)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = s; i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << endl;
#define CFYN(n) cout << ( (n) ? "YES":"NO") << endl;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;

int main(void)
{
    IOS
    const string D = "delicious";
    const string S = "safe";
    const string G = "dangerous";

    int x,a,b;
    cin >> x >> a >> b;
    string ans = "";
    if (a-b >= 0) ans = D;
    else if (b-a <= x) ans = S;
    else ans = G;

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 384
#include <cstdio>
#include <cmath>
#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <algorithm>
#include <queue>
#include <map>
using namespace std;
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define REP(i,n) for(ll i=0;i<n;i++)
#define REPR(i,n) for(ll i=n-1;i>=0;i--)
 
typedef long long ll;
#define INF 1e18
 
#define MOD 2019
 
int main(){
	long long int A, B, N;
	cin >> A >> B >> N;
	/*long long int max = -1000000000;
	int i = B-1;
	if(i > N){
	    i = N;
	}
	while(i <= N){
	    long long int temp = (A*i)/B - A * (i/B);
	    if(temp > max){
	        max = temp;
	    }
	    cout << temp << endl;
	    i += B;
	}*/
	
	if(B <= N){
	    cout << (A* (B-1)) / B - A * ((B-1) / B) << endl;
	}else{
	    cout << (A* N) / B - A * (N / B) << endl;
	}
	return 0;
}

Measured memory_bytes: 3528
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <sstream>
#include <algorithm>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <list>
#include <cstdio>
#include <iostream>
#include <cmath>
#include <climits>
#include <bitset>
#include <functional>
#include <numeric>
#include <ctime>
#include <cassert>
#include <cstring>
#include <fstream>
#include <iomanip>

using namespace std;

#define FOR(i, a, b) for(int (i)=(a);(i)<(b);(i)++)
#define IFOR(i, a, b) for(int (i)=(a);(i)<=(b);(i)++)
#define RFOR(i, a, b) for(int (i)=(a);(i)>=(b);(i)--)
#define REP(i, n) FOR((i), 0, (n))

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

int main() {
    int h, n;
    cin >> h >> n;
    vector<int> a(n);
    REP(i, n){
        cin >> a[i];
    }
    if(accumulate(a.begin(), a.end(), 0) >= h)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<set>
#include<bitset>
#include<map>

#define fo(i,a,b) for(int i=a;i<=b;i++)
#define fd(i,a,b) for(int i=a;i>=b;i--)

using namespace std;

typedef long long LL;
typedef double db;

int get(){
	char ch;
	while(ch=getchar(),(ch<'0'||ch>'9')&&ch!='-');
	if (ch=='-'){
		int s=0;
		while(ch=getchar(),ch>='0'&&ch<='9')s=s*10+ch-'0';
		return -s;
	}
	int s=ch-'0';
	while(ch=getchar(),ch>='0'&&ch<='9')s=s*10+ch-'0';
	return s;
}

const int N = 2e+5+5;

struct edge{
	int x,nxt;
}e1[N*2],e2[N*2];
int h1[N],h2[N],tot1,tot2;
int n,X,Y;
int dep2[N],dep1[N];
bool bz1[N],bz2[N];
int fa[N][20];
int ans;
db tim;

void inse(int x,int y,int *h,edge *e,int &tot){e[++tot].x=y;e[tot].nxt=h[x];h[x]=tot;}

void dfs2(int x){
	bz2[x]=1;
	fo(i,1,tim)fa[x][i]=fa[fa[x][i-1]][i-1];
	for(int p=h2[x];p;p=e2[p].nxt)
	if (!bz2[e2[p].x]){
		dep2[e2[p].x]=dep2[x]+1;
		fa[e2[p].x][0]=x;
		dfs2(e2[p].x);
	}
}

int getdis(int x,int y){
	int tmp=dep2[x]+dep2[y];
	if (dep2[x]<dep2[y])swap(x,y);
	fd(i,tim,0)
	if (fa[x][i]&&dep2[fa[x][i]]>=dep2[y])x=fa[x][i];
	if (x==y)return tmp-2*dep2[x];
	fd(i,tim,0)
	if (fa[x][i]!=fa[y][i])x=fa[x][i],y=fa[y][i];
	return tmp-2*dep2[x]+2;
}

void dfs1(int x){
	bz1[x]=1;
	if (dep1[x]>=dep2[x])return;
	ans=max(ans,2*dep2[x]);
	for(int p=h1[x];p;p=e1[p].nxt)
	if (!bz1[e1[p].x]){
		dep1[e1[p].x]=dep1[x]+1;
		dfs1(e1[p].x);
		int d=getdis(x,e1[p].x);
		if (d>2)ans=1e+9;
	}
}

int main(){
	n=get();X=get();Y=get();
	fo(i,2,n){int x=get(),y=get();inse(x,y,h1,e1,tot1);inse(y,x,h1,e1,tot1);}
	fo(i,2,n){int x=get(),y=get();inse(x,y,h2,e2,tot2);inse(y,x,h2,e2,tot2);}
	tim=log(n)/log(2);
	dfs2(Y);
	dfs1(X);
	printf("%d\n",ans==1e+9?-1:ans);
	return 0;
}

Measured memory_bytes: 31232
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,x,y,z,a=0,b=0,c=0,t;
  int q[110];
  for(int i=0; i<110; i++) q[i] = 1;
  cin >> n;
  cin >> x;
  for(int i=0; i<x; i++){
    cin >> t;
    q[t] *= 2;
  }
  cin >> y;
  for(int i=0; i<y; i++){
    cin >> t;
    q[t] *= 3;
  }
  cin >> z;
  for(int i=0; i<z; i++){
    cin >> t;
    q[t] *= 5;
  }
  for(int i=1; i<=n; i++){
    //cout << q[i] << " ";
    if(q[i]%5 == 0) a++; //aがcの全体
    if(q[i]%10 == 0) b++; //AかつC
    if(q[i]%30 == 0) c++; //AかつBかつC
    //30 = 2*3*5
  }
  //cout << a << " " << b << " " << c << endl;
  cout << a-b+c << endl;
  return 0;
}



Measured memory_bytes: 3092