akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<stdlib.h>
#include<cassert>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=500000004;
const double EPS=1e-6;
const double PI=acos(-1.0);
int ABS(int a){return max(a,-a);}
long long ABS(long long a){return max(a,-a);}
char in[510000];
vector<int>v;
vector<vector<int> >g;
int dp[510000][4];
int solve(vector<int> t){
	int n=t.size();
	for(int i=0;i<=n;i++)for(int j=0;j<4;j++)dp[i][j]=-mod;
	dp[0][0]=0;
//for(int i=0;i<n;i++)printf("%d ",t[i]);printf("\n");
	for(int i=0;i<n;i++)for(int j=0;j<4;j++){
		if(dp[i][j]<0)continue;
		if(j==0){
			dp[i+1][0]=max(dp[i+1][0],dp[i][0]);
			if(t[i]==1){
				dp[i+1][1]=max(dp[i+1][1],dp[i][0]+1);
				dp[i+1][2]=max(dp[i+1][2],dp[i][0]+1);
			}else{
				dp[i+1][3]=max(dp[i+1][3],dp[i][0]+1);
			}
		}else if(j==1){
			dp[i+1][0]=max(dp[i+1][0],dp[i][1]);
		}else if(j==2){
			if(t[i]==0){
				dp[i+1][1]=max(dp[i+1][1],dp[i][2]+1);
				dp[i+1][2]=max(dp[i+1][2],dp[i][2]+1);
			}
		}else if(j==3){
			if(t[i]==1){
				dp[i+1][1]=max(dp[i+1][1],dp[i][3]+1);
			}else{
				dp[i+1][3]=max(dp[i+1][3],dp[i][3]+1);
			}
		}
	}
	return max(max(dp[n][0],dp[n][1]),dp[n][2]);
}
int main(){
	int a;scanf("%d",&a);
	scanf("%s",in);
	int p=0;
	int cnt=0;
	for(int i=0;i<a;i++){
		if(in[i]=='1'){
	//		printf("%d %d %d\n",i,p,cnt);
			if(p){
				if(cnt>1){
					g.push_back(v);
					v.clear();
				}else{
					v.push_back(cnt);
				}
			}
			p=1;
			cnt=0;
		}else cnt++;
	}
	g.push_back(v);
	int ret=0;
	for(int i=0;i<g.size();i++)ret+=solve(g[i]);
	printf("%d\n",ret);
}

Measured memory_bytes: 14832
# coding: utf-8
from __future__ import unicode_literals
from __future__ import print_function
import sys

LEFT = "L"
RIGHT = "R"
UP = "U"
DOWN = "D"

def move(x,y):
    xs = RIGHT*x if x > 0 else LEFT*(-x)
    ys = UP*y if y > 0 else DOWN*(-y)
    return ys + xs

def main():
    sx, sy, tx, ty = map(int,sys.stdin.read().split())

    x = tx - sx
    y = ty - sy

    ans = ""
    ans += move(x,y)
    ans += move(-x,-y)
    ans += LEFT + move(x+1,y+1) + DOWN
    ans += RIGHT + move(-(x+1),-(y+1)) + UP

    sys.stdout.write(ans)

if __name__ == '__main__':
    main()  


Measured memory_bytes: 2816
def execute(w, h, n, xya):
    s = [[1 for _ in range(w)] for _ in range(h)]
    for x, y, a in xya:
        for xi in range(w):
            for yi in range(h):
                if a == 1:
                    if xi < x:
                        s[yi][xi] = 0
                if a == 2:
                    if xi >= x:
                        s[yi][xi] = 0
                if a == 3:
                    if yi < y:
                        s[yi][xi] = 0
                if a == 4:
                    if yi >= y:
                        s[yi][xi] = 0
    return sum(map(sum, s))


if __name__ == '__main__':
    w, h, n = map(int, input().split())
    xya = []
    for _ in range(n):
        xya.append(list(map(int, input().split())))
    print(execute(w, h, n, xya))


Measured memory_bytes: 3064
#include<iostream>
using namespace std;
int main(){
	while(1){
		int n,w,h,x,y,s,t,ans=0;
		int field[200][200]={};
		cin >> n;
		if(n==0)	break;
		cin >> w >> h;
		for(int i=0;i<n;i++){
			cin >> x >> y;
			field[y][x]=1;
		}
		cin >> s >> t;
		for(int i=1;i<=h-t+1;i++){
			for(int j=1;j<=w-s+1;j++){
				int cnt=0;
				for(int Y=i;Y<i+t;Y++){
					for(int X=j;X<j+s;X++){
						if(field[Y][X]==1)	cnt++;
					}
				}
				ans = max(ans,cnt);
			}
		}
		cout << ans << endl;
	}
}


Measured memory_bytes: 3232
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <ctype.h>
#include <map>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <cctype>
#include <queue>
#include <set>
#include <list>
#define PI 3.14159265359
#define rep(i,a,n) for(int i=a;i<(int)n;++i)
#define SZ(x) ((int)(x).size())	//size() unsigned -> int
#define DescSort(a) sort(a.begin(),a.end(),std::greater<int>())

using namespace std;
typedef long long ll;
const ll INF=1e9+7;

int main(void) {
	int a, b;
	cin >> a >> b;
	int out = 1, ans = 0;
	while (out < b) {
		out--;
		out += a;
		ans++;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 384
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main {
    public static void main(String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st;
        PrintWriter pw = new PrintWriter(System.out);
        
        try {
            st = new StringTokenizer(br.readLine());
            int n = Integer.parseInt(st.nextToken());
            int m = Integer.parseInt(st.nextToken());
            int k = Integer.parseInt(st.nextToken());
            st = new StringTokenizer(br.readLine());
            long[] a = new long[n];
            for(int i=0 ; i<n ; i++) {
                a[i] = Integer.parseInt(st.nextToken());
            }
            st = new StringTokenizer(br.readLine());
            long[] b = new long[m];
            for(int i=0 ; i<m ; i++) {
                b[i] = Integer.parseInt(st.nextToken());
            }

            for(int i=1 ; i<n ; i++) {
                a[i] += a[i-1];
            }
            for(int i=1 ; i<m ; i++) {
                b[i] += b[i-1];
            }

            int max = 0;
            for(int i=0 ; i<n ; i++) {
                long rem = k - a[i];
                if(rem >= 0) {
                    int l = 0;
                    int r = m-1;
                    int ans = -1;
                    while(l<=r) {
                        int mid = (l+r)/2;
                        if(b[mid] <= rem) {
                            ans = mid;
                            l = mid+1;
                        }
                        else {
                            r = mid-1;
                        }
                    }
                    max = Math.max(max, (i+1) + (ans+1));
                }
            }

            for(int i=0 ; i<m ; i++) {
                if(b[i] <= k) {
                    max = Math.max(max, (i+1));
                }
            }

            pw.println(max);
        }
        finally {
            pw.flush();
            pw.close();
        }
    }
}


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

vector<vector<int>> g;
int p = 1e9 + 7, k;
long f(int u, int v) {
	long r = 1, i = k;
	if (u) i--;
	for (int w : g[v]) {
		if (w == u) continue;
		(r *= --i) %= p;
		(r *= f(v, w)) %= p;
	}
	return r;
}
int main() {
	int n;
	cin >> n >> k;
	g.resize(n + 1);
	for (int i = 1; i < n; i++) {
		int a, b;
		scanf("%d%d", &a, &b);
		g[a].push_back(b);
		g[b].push_back(a);
	}
	cout << f(0, 1)*k%p << endl;
	return 0;
}


Measured memory_bytes: 11520
import numpy as np
from copy import deepcopy
H, W = map(int, input().split())
A = [list(input()) for _  in range(H)]

output = np.array(A)
A = np.array(A)
delcol = []
delrow = []

for i in range(H):
	if all([A[i][j]=='.' for j in range(W)]):
		delrow.append(i)
		continue
for j in range(W):
	if all([A[i,j]=='.' for i in range(H)]):
		delcol.append(j)

output = np.delete(output, delrow, 0)
output = np.delete(output, delcol, 1)

h, w = output.shape
for i in range(h):
	sentence = ''
	for j in range(w):
		sentence += output[i,j]
	print(sentence)





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

X, Y = [0]*N, [0]*N
X[0] = a[0]
Y[-1] = a[-1]

for i in range(1,N):
    X[i] = X[i-1] + a[i]
    Y[-i-1] = Y[-i] + a[-i-1]

ans = 99999999999999

for i in range(N-1):
    ans = min(abs(X[i]-Y[i+1]),ans)
print(ans)

Measured memory_bytes: 29096
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
#define ALL(c) (c).begin(), (c).end()
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v, x) (std::find(v.begin(), v.end(), x) != v.end())

using namespace std;
using ll = long long;

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; }
constexpr int INF = 1001001001;
constexpr long long INFL = (1LL<<60);
constexpr double eps = (1e-9);

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

  ll n, d;
  cin >> n >> d;
  int ans = 0;
  rep(i, n) {
    ll x, y;
    cin >> x >> y;
    if (x * x + y * y <= d * d) ans++;
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3656
s =str(input())
if len(s)%2 !=0:
  print("No")
  exit()
for i in range(len(s)):
  if i % 2==0:
    if s[i]!="h":
      print("No")
      exit()
  else:
    if s[i]!="i":
      print("No")
      exit()
print("Yes")
  

Measured memory_bytes: 2940
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int mod = 1000000007;

int main() {
    ios::sync_with_stdio(false);
    string s;
    int a = 0, b = 0;
    cin >> s;
    for (int i = 0; i < s.length(); i++) {
        if (s[i] == 'A' || s[i] == 'C' || s[i] == 'G' || s[i] == 'T') a++;
        else a = 0;
        b = max(b, a);
    }
    cout << b;
}


Measured memory_bytes: 256
#include <iostream>
#include <boost/multiprecision/cpp_int.hpp>

using bint = boost::multiprecision::cpp_int;
int main()
{
    bint N, K;
    std::cin >> N >> K;
    // 全部Kの倍数
    bint n_k = N / K;
    bint ans = 0;
    // aaa
    if (n_k >= 1) {
        ans += n_k;
    }
    // aab
    if (n_k >= 2) {
        ans += 3 * n_k * (n_k - 1);
    }
    // abc
    if (n_k >= 3) {
        ans += n_k * (n_k - 1) * (n_k - 2);
    }
    if (K % 2 != 0) {
        std::cout << ans << std::endl;
    } else {
        bint n_k;
        if (N - K / 2 >= K) {
            n_k = (N - K / 2) / K + 1;
        } else if (N - K / 2 >= 0) {
            n_k = 1;
        } else {
            n_k = 0;
        }

        // aaa
        if (n_k >= 1) {
            ans += n_k;
        }
        // aab
        if (n_k >= 2) {
            ans += 3 * n_k * (n_k - 1);
        }
        // abc
        if (n_k >= 3) {
            ans += n_k * (n_k - 1) * (n_k - 2);
        }
        std::cout << ans << std::endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int(i) = 0; (i) < (n); (i)++)
#define all(x) (x).begin(), (x).end()
typedef long long ll;

int main()
{
    int n, x, y;
    cin >> n;
    if (n == 1)
    {
        cout << "Hello World" << endl;
    }
    else
    {
        cin >> x >> y;
        cout << x + y << endl;
        ;
    }
    return 0;
}

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

int main(void) {
	int max,i;
	double xa,ya,ra,xb,yb,rb;
	double dist;
	scanf("%d",&max);
	for(i=0;i<max;i++) {
		scanf("%lf %lf %lf %lf %lf %lf",
			&xa,&ya,&ra,&xb,&yb,&rb);
		dist=(xa-xb)*(xa-xb)+(ya-yb)*(ya-yb);
		if(dist<(ra-rb)*(ra-rb)) {
			if(ra<rb)printf("-2\n"); else printf("2\n");
		} else if(dist>(ra+rb)*(ra+rb))printf("0\n");
		else printf("1\n");
	}
	return 0;
}

Measured memory_bytes: 0
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iostream>
#include <sstream>
#include <functional>
#include <map>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <stack>
#include <deque>
#include <set>
#include <list>
#include <numeric>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> P;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const ll INF = 1LL<<29;
const ll mod = 1e9+7;
#define rep(i,n) for(int (i)=0;(i)<(ll)(n);++(i))
#define repd(i,n,d) for(ll (i)=0;(i)<(ll)(n);(i)+=(d))
#define all(v) (v).begin(), (v).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset((m),(v),sizeof(m))
#define chmin(X,Y) ((X)>(Y)?X=(Y),true:false)
#define chmax(X,Y) ((X)<(Y)?X=(Y),true:false)
#define fst first
#define snd second
#define UNIQUE(x) (x).erase(unique(all(x)),(x).end())
template<class T> ostream &operator<<(ostream &os, const vector<T> &v){int n=v.size();rep(i,n)os<<v[i]<<(i==n-1?"":" ");return os;}

int main(){
	string s;
	cin>>s;
	cout<<s.substr(0, 4)<<" "<<s.substr(4)<<endl;
	return 0;
}


Measured memory_bytes: 764
#include <cstring>
#include <map>
#include <unordered_map>
#include <string>
#include <list>
#include <vector>
#include <algorithm>
#include <queue>
#include <stack>
#include <cstdio>
#include <iostream>
#include <set>
#include <unordered_set>
using namespace std;

#define MAX(a,b) (a>b?a:b)
#define MIN(a,b) (a<b?a:b)
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int ui;
typedef pair<int, int> pii;

int gi() {
    int a;
    scanf("%d", &a);
    return a;
}

ll gli() {
    ll a;
    scanf("%lld", &a);
    return a;
}

int c[3];
#define M 1000000007

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    ll r = 1;
    int n = gi();
    memset(c, 0, sizeof(c));
    for (int i = 0; i < n; i++) {
        int x = gi();
        int w;
        int m = 0;
        for (int j = 0; j < 3; j++)
            if (c[j] == x) {
                w = j;
                m++;
            }
        if (m == 0) {
            printf("0\n");
            return 0;
        }
        r *= m; r %= M;
        c[w]++;
    }

    cout << r << endl;

    return 0;
}


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

int main(){
    long long X, Y;
    cin >> X >> Y;
    
    long long num = 1;
    long long val = X;
    while(true){
        val = X * (long long)round(pow(2, num));
        if(val > Y){break;}
        num++;
    }

    cout << num << endl;
    return 0;
}


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

int main(){
  int s=0;
  vector<int> vec(5);
  for(int i=0;i<5;i++){
    cin>>vec[i];
  }
  for(int i=0;i<5;i++){
    if(vec[i]==0){
      s=i+1;
    }
  }
  cout<<s<<endl;
}

Measured memory_bytes: 3572
#include <algorithm>
#include <cstdlib>
#include <iostream>

using namespace std;

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

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

  const int ans = min({abs(a - b) + abs(b - c), abs(a - c) + abs(c - b),
                       abs(b - a) + abs(a - c), abs(b - c) + abs(c - a),
                       abs(c - a) + abs(a - b), abs(c - b) + abs(b - a)});
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
c = []
for i in range(3):
    l = [int(x) for x in input().split()]
    c+=l
n = int(input())
che = [False]*9
ans = "No"
for i in range(n):
    b = int(input())
    for j in range(9):
        if c[j] == b:
            che[j] = True
#bingo check
for i in range(3):
    if che[i] and che[i+3] and che[i+6]:
        ans = "Yes"
        break
    elif che[i*3] and che[i*3 +1] and che[i*3 +2]:
        ans = "Yes"
        break
if ans == "No":
    if che[0] and che[4] and che[8]:
        ans = "Yes"
    elif che[2] and che[4] and che[6]:
        ans = "Yes"
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using i64 = int_fast64_t;
#define repeat(i, a, b) for(int i = (a); (i) < (b); ++(i))
#define rep(i, n) repeat(i, 0, n)

void solve() {
    int n;
    std::cin >> n;
    std::vector<int> a(n), b(n), c(n);
    rep(i, n) std::cin >> a[i];
    rep(i, n) std::cin >> b[i];
    rep(i, n) std::cin >> c[i];
    std::sort(begin(a), end(a));
    std::sort(begin(b), end(b));
    std::sort(begin(c), end(c));
    i64 ans = 0;
    rep(i, n) {
        int t = b[i];
        i64 ta = std::distance(a.begin(), std::lower_bound(begin(a), end(a), t));
        i64 tc = std::distance(std::upper_bound(begin(c), end(c), t), c.end());
        // std::cout << ta << " " << tc << std::endl;
        ans += ta * tc;
    }
    std::cout << ans << std::endl;
}

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

Measured memory_bytes: 1408
#include <bits/stdc++.h>
int main()
{
  int ans = 0,min = 0;
  for(int i =0,a; i < 5; i++){std::cin >> a,ans += (a+9)/10*10,min=std::max(min,(a+9)/10*10-a);}
  std::cout << ans - min<<std::endl;
  return 0;
}


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

using namespace std;
typedef long long LL;

int main() {
  int N;
  cin >> N;
  vector<int> xs;
  vector<int> ys;
  for (int i = 0; i < N; i++) {
    int x, y;
    cin >> x >> y;
    xs.push_back(x);
    ys.push_back(y);
  }

  double ans = 0;
  for (int i = 0; i < N; i++)
    for (int j = 0; j < i; j++) {
      int dx = xs[i] - xs[j];
      int dy = ys[i] - ys[j];
      ans += hypot(dx, dy);
    }
  cout << setprecision(15);
  cout << ans / (N)*2 << endl;

  return 0;
}

Measured memory_bytes: 256
import queue

n, quantum = map(int, input().split())
q = queue.Queue()
for _ in range(n):
    name, time = input().split()
    q.put([name, int(time)])

spend_time = 0
while q.qsize() > 0:
    name, time = q.get()
    tmp = min(quantum, time)
    spend_time += tmp
    time -= tmp
    if time == 0:
        print('{} {}'.format(name, spend_time))
    else:
        q.put([name, time])



Measured memory_bytes: 14164
#include <bits/stdc++.h>
#define pb push_back
using namespace std;
const int INF=0x3f3f3f3f;
const int maxn=105;

struct Edge {
	int from,to,cap,flow;
	Edge(int u,int v,int c,int f):from(u),to(v),cap(c),flow(f) {}
};

int n,m;
vector<Edge>edges;
vector<int>G[maxn];
int a[maxn],p[maxn];

int maxflow (int s,int t) {
	int flow=0;
	while (1) {
		memset(a,0,sizeof(a));
		queue<int>q;
		q.push(s);
		a[s]=INF;
		while (q.size()) {
			int x=q.front(); q.pop();
			for (int id:G[x]) {
				Edge &e=edges[id];
				if (!a[e.to] && e.cap>e.flow) {
					p[e.to]=id;
					a[e.to]=min(a[x],e.cap-e.flow);
					if (a[t]) break;
					q.push(e.to);
				}
			}
			if (a[t]) break;
		}
		if (!a[t]) break;
		for (int u=t;u!=s;u=edges[p[u]].from) {
			edges[p[u]].flow+=a[t];
			edges[p[u]^1].flow-=a[t];
		}
		flow+=a[t];
	}
	return flow;
}

int main() {
	cin>>n>>m;
	for (int i=0;i<m;i++) {
		int u,v,c; cin>>u>>v>>c;
		edges.pb(Edge(u,v,c,0));
		edges.pb(Edge(v,u,0,0));
		int id=edges.size()-2;
		G[u].pb(id);
		G[v].pb(id+1);
	}
	cout<<maxflow(0,n-1)<<'\n';
}


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

#define debug(x) cout <<"DEBUG"<<" "<< #x << ":" << x << '\n'
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   // 0-indexed昇順
#define rep1(i,n) for(int i = 1; i <= ((int)(n)); i++) // 1-indexed昇順
#define rrep(i,n) for(int i = ((int)(n)-1); i >= 0; i--)  // 0-indexed降順
#define rrep1(i,n) for(int i = ((int)(n)); i >= 1; i--)   // 1-indexed降順
#define all(x) (x).begin(),(x).end()

using namespace std;

template<typename T>
using vec = vector<T>;
using i32 = int_fast32_t;
using i64 = int_fast64_t;
using u32 = uint_fast32_t;
using u64 = uint_fast64_t;
using ll = long long;
using ld = long double;
using vi = vec<int_fast32_t>;
using vl = vec<int_fast64_t>;
using vld = vec<ld>;
using vii = vec<vi>;  // 2次元配列
using PII = pair<int_fast32_t, int_fast32_t>;

template<class T>
using maxheap = std::priority_queue<T>;
template<class T>
using minheap = std::priority_queue<T, std::vector<T>, std::greater<T>>;

template<class T,class U> inline bool chmax(T &a, const U &b){if(a<b){a=b;return 1;}return 0;}
template<class T,class U> inline bool chmin(T &a, const U &b){if(a>b){a=b;return 1;}return 0;}

const ld Pi = std::acos(-1.0L);
constexpr ll infll = (1LL<<62)-1;
constexpr int inf = (1<<30)-1;
const int mod = 1000000007;
// const int mod = 998244353;


/*FUNCs=================================================*/


/*MAIN==================================================*/
signed main(){
    int START_TIME = clock();
    cin.tie(nullptr);
    ios::sync_with_stdio(false);   //cin cout 高速化
//    cout << fixed << setprecision(15);

    string s,t;
    i32 n,m,p,q,r;
    cin >> n >> s;
    vi csumR(n+1); rep(i,n) csumR[i+1] += csumR[i] + (s[i]=='R' ? 1 : 0);
    vi csumG(n+1); rep(i,n) csumG[i+1] += csumG[i] + (s[i]=='G' ? 1 : 0);
    vi csumB(n+1); rep(i,n) csumB[i+1] += csumB[i] + (s[i]=='B' ? 1 : 0);

//    debug => ok
//    for(auto i : csumR) cout << i << ' ';
//    cout << '\n';    for(auto i : csumG) cout << i << ' ';
//    cout << '\n';    for(auto i : csumB) cout << i << ' ';
//    cout << '\n';

    i32 cnt = 0;
    for(i32 i = 0; i < n-2; ++i) {
        for(i32 j = i+1; j < n-1; ++j) {
            if(s[i]==s[j]) continue;
//            cout << s[i] << ' ' << s[j] << '\n';  // debug

            char chh1 = min(s[i], s[j]);
            char chh2 = max(s[i], s[j]);
//            cout << chh1 << ' ' << chh2 << '\n';  // debug


            if(chh1 == 'G' && chh2 == 'R') {
                cnt += csumB[n] - csumB[j+1];
                if(j+j-i < n) cnt -= (s[j+j-i]=='B' ? 1 : 0);
            }
            else if(chh1 == 'B' && chh2 == 'G') {
                cnt += csumR[n] - csumR[j+1];
                if(j+j-i < n) cnt -= (s[j+j-i]=='R' ? 1 : 0);
            }
            else if(chh1 == 'B' && chh2 == 'R') {
                cnt += csumG[n] - csumG[j+1];
                if(j+j-i < n) cnt -= (s[j+j-i]=='G' ? 1 : 0);
            }
//            else cout << "!" << '\n';  // debug
//            debug(cnt);
        }
    }

    /**
     * WA * 4 .. large case
     */
    cout <<  cnt       << '\n';

    // printf("ExecutionTime: %d /ms\n",1000*(int)((clock()-START_TIME)/CLOCKS_PER_SEC));
}


Measured memory_bytes: 3768
#include <iostream>

using namespace std;

struct Point{
	int x,y;
	Point( int dx, int dy ) : x(dx), y(dy) {}
	Point(){}
};

Point jump[12] = { Point( -1, -2 ),Point( 0, -2 ), Point( 1, -2 ),
	Point( 2, -1 ), Point( 2, 0 ), Point( 2, 1 ),
	Point( -1, 2 ), Point( 0, 2 ), Point( 1, 2 ),
	Point( -2, -1 ), Point( -2, 0 ), Point( -2, 1 ) };

bool saiki( const Point& k, int n, const Point* s, int t ){
	if( t == n ) return true;
	bool stage[10][10];

	for( int i = 0;i < 10;i++ ){
		for( int j = 0;j < 10;j++ ){
			stage[i][j] = false;
		}
	}

	for( int i = 0;i < 3;i++ ){
		for( int j = 0;j < 3;j++ ){
			if( i + s[t].x - 1 > -1 && j + s[t].y - 1 > -1 && i + s[t].x - 1 < 10 && j + s[t].y - 1 < 10 ) stage[i + s[t].x - 1][j + s[t].y - 1] = true;
		}
	}

	for( int i = 0;i < 12;i++ ){
		if( k.x + jump[i].x > -1 && k.y + jump[i].y > -1 && k.y + jump[i].y < 10 && k.x + jump[i].x < 10 ) if( stage[k.x + jump[i].x][k.y + jump[i].y] ) if( saiki( Point( k.x + jump[i].x, k.y + jump[i].y ), n, s, t + 1 ) ) return true;
	}

	return false;
}


int main(int argc, char const* argv[])
{
	Point k;
	int n;
	Point s[10];

	while( cin >> k.x >> k.y && k.x != 0 && k.y != 0 ){
		cin >> n;
		for( int i = 0;i < n;i++ ) cin >> s[i].x >> s[i].y;

		if( saiki( k, n, s, 0 ) ) cout << "OK" << endl;
		else cout << "NA" << endl;
	}
	return 0;
}

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

int main() {
  int N;
  cin >> N;
  vector<int> A = {0}, B = {0};
  for (int i = 0; i < N; i++) {
    int a;
    cin >> a;
    A.push_back(A.back() + a);
  }

  for (int i = 0; i < N; i++) {
    int a;
    cin >> a;
    B.push_back(B.back() + a);
  }

  int maxim = 0;
  for (int i = 0; i < N; i++) {
    maxim = max(maxim, A[i + 1] + B.back() - B[i]);
  }
  cout << maxim << endl;

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(a); (i)<(b); ++(i))
#define rFor(i, a, b) for(int (i)=(a)-1; (i)>=(b); --(i))
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef unsigned long long ulint;
typedef pair<int, int> pii;
typedef complex<double> xy_t;
typedef vector<lint> poly;
template<class T>bool chmax(T &a, const T &b){if(a<b){a=b; return true;} return false;}
template<class T>bool chmin(T &a, const T &b){if(a>b){a=b; return true;} return false;}

constexpr lint mod = 998244353;
constexpr lint INF = mod*mod;
constexpr int MAX = 100010;

int main(){
    int n;
    string s, t;
    cin>>n>>s>>t;
    string u;
    rep(i, n){
        u+=s[i];
        u+=t[i];
    }
    cout<<u<<"\n";
}

Measured memory_bytes: 256
object Main extends App {

  def caesar(ch: Char): Char = ch match {
    case 'a' => 'b'
    case 'b' => 'c'
    case 'c' => 'd'
    case 'd' => 'e'
    case 'e' => 'f'
    case 'f' => 'g'
    case 'g' => 'h'
    case 'h' => 'i'
    case 'i' => 'j'
    case 'j' => 'k'
    case 'k' => 'l'
    case 'l' => 'm'
    case 'm' => 'n'
    case 'n' => 'o'
    case 'o' => 'p'
    case 'p' => 'q'
    case 'q' => 'r'
    case 'r' => 's'
    case 's' => 't'
    case 't' => 'u'
    case 'u' => 'v'
    case 'v' => 'w'
    case 'w' => 'x'
    case 'x' => 'y'
    case 'y' => 'z'
    case 'z' => 'a'
    case x => x
  }

  def loop(input: String): String = {
    if (input.contains("the") || input.contains("this") || input.contains("that")) {
      println(input)
      input
    }
    else {
      loop(input map caesar)
    }
  }

  val sc = new java.util.Scanner(System.in)
  while(sc.hasNext()) {
    loop(sc.nextLine())
  }

}

Measured memory_bytes: 44968
#include <bits/stdc++.h>
#include <limits>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
#define fi(i,n) for( ll i=0 ; i<n ; i++ )
#define f(i, a, b) for( ll i=a ; i<b ; i++ )
#define vi vector<int>
#define pb push_back
#define MOD 1000000007
ll digits(ll n)
{
    return floor(log10(double(n))) + 1;
}
ll SieveOfEratosthenes(ll n)
{
    vector<bool>prime(n+1);
    int ans = 0;
    for(int i =0;i<=n;i++)
        prime[i] = true;
    prime[1] = false;
    for (ll p=2; p*p<=n; p++)
    {
        if (prime[p] == true)
        {
            for (ll i=p*p; i<=n; i += p)
                prime[i] = false;
        }
    }
    for(int i = 2;i<=n;i++)
    {
        if(prime[i])
        {
            ans++;
        }
    }
    return ans;
}
void permute(string a, int l, int r)
{
    if (l == r)
    {
        cout<<a<<endl;
    }
    else
    {
        for (int i = l; i <= r; i++)
        {
            swap(a[l], a[i]);
            permute(a, l+1, r);
        }
    }
}
ll modularExponentiation(ll x,ll n,ll M)
{
    ll result = 1;
    ll ans = 1;

    while(n>0)
    {
        if(n % 2 ==1)
        {
            result = (result*x)%MOD;
            ans = (ans + result)%MOD;
        }
        n = n/2;
        if(n>0)
        {

            x = x*x;
        }
    }
    return ans;
}
int d, x, y;
void extendedEuclid(int A, int B) {
    // for computing modular inverse
    // make b as Mod such that gcd of mod and a is 1
    // also the coeff x here will denote the modular inverse of a
    if(B == 0) {
        d = A;
        x = 1;
        y = 0;
    }
    else {
        extendedEuclid(B, A%B);
        int temp = x;
        x = y;
        y = temp - (A/B)*y;
        // x = y1
        // y = x1 - y1*(a/b);
    }
}
ll fact(ll n)
{
    ll ans = 1;
    for(ll i = 1;i<=n;i++)
        ans = (ans%MOD * i%MOD)%MOD;
    return ans%MOD;
}
ll maxpower(ll n,ll k)
{
    ll count = 0;
    while(n>0)
    {
        n = n/k;
        if(n>0)
            count++;
    }
    return count;
}
bool written(ll n,ll k,string s,ll power)
{
    while(power>=0 && n>0)
    {
            ll x = pow(k,power);
            if(n - x>=0)
            {
                if(s[power] == '1')
                    return false;
                n = n - x;
            }
            power--;
    }
    cout<<n<<endl;
    if(n!=0)
        return false;
    return true;
}
void improvise(string s,ll n,ll k,ll power)
{
    for(int i = power;i>=0;i--)
    {
        ll x = pow(k,i);
        if(n - x>=0)
        {
            s[i] = '1';
            n = n - pow(k,i);
        }
    }
}
int main()
{
    ll n;
    cin>>n;
    int arr[n];
    int sum = 0;
    fi(i,n)
    {
        cin>>arr[i];
        sum += arr[i];
    }
    int x1 = sum/n;
    int x2 = sum/n + 1;
    ll ans1 = 0;
    ll ans2 = 0;
    fi(i,n)
    {
        ans1 = ans1 + (arr[i] - x1)*(arr[i] - x1);
        ans2 = ans2 + (arr[i] - x2)*(arr[i] - x2);
    }
    cout<<min(ans1,ans2);



}



Measured memory_bytes: 3684
#include<stdio.h>
int main()
{
	int m,n,i,k,j;
	char a[105];
	scanf("%d%d",&m,&n);
	  for(i=1;i<=m;i++)
	    {
	    	scanf("%s",a);
	   	 if(i==1)
	      {
			for(j=1;j<=n+2;j++)
	    	  	printf("#");
	    	  	printf("\n");
	      }
			   for(j=0;j<n;j++)
			      {
			      	if(n==1)  {  printf("#%c#\n",a[0]); break;}
			      	if(j==0)  printf("#%c",a[0]);
			      	if(j==n-1) printf("%c#\n",a[j]);
			      	if((j!=0) && (j!=n-1)) printf("%c",a[j]);
				  }  
			if(i==m)	
				{
				 for(j=1;j<=n+2;j++)
	    	  	    printf("#");
					  printf("\n");
				}
		}
return 0;
 } 

Measured memory_bytes: 128
N,A,B = map(int, input().split())
b = 0
ans = 0

if A == 0:
  ans = 0
elif N < A:
  ans = N
elif N < A+B:
  ans = A
else:
  x = N // (A+B)
  y = N % (A+B)
  ans = A * x + min(y, A)

print(ans)

Measured memory_bytes: 3060
n = int(input())
sortsecond = lambda val : val[1]
a = []
time = 0
[a.append(list(map(int,input().split()))) for i in range(n)]
b = sorted(a, key=sortsecond)
for o,i in b:
    if time + o <= i:
        time+=o
    else :
        print("No")
        break
else:
    print("Yes")

Measured memory_bytes: 55060
#include<algorithm>
#include<iostream>
#include<vector>

std::vector<int> a, b;
int hit, blow;

int main()
{
	while( 1 ){
		hit = blow = 0;
		a.clear();
		b.clear();
		
		for( int i = 0; i < 4; i++ ){
			int n;
			if( !( std::cin >> n ) ) goto end;
			a.push_back( n );
		}
		
		for( int i = 0; i < 4; i++ ){
			int n;
			if( !( std::cin >> n ) ) goto end;
			b.push_back( n );
		}
		
		for( int i = 0; i < 4; i++ ){
		 	if( a[i] == b[i] ){
			 	hit++;
			}
		}
		
		for( int i = 0; i < 4; i++ ){
			blow += std::count( a.begin(), a.end(), b[i] );
		}
		blow -= hit;
		
		std::cout << hit << " " << blow << std::endl;
	}

end:

 	return 0;
}

Measured memory_bytes: 1212
#include <algorithm>
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <string>
#include <sstream>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <queue>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using namespace std;
typedef long long int ll;

bool isSameParity(int a,int b){
	if( abs(a-b) % 2 == 0)return true;
	return false;
}

int main()
{
	int num[3];
	cin>>num[0]>>num[1]>>num[2];
	sort(num,num+3);
	int ans = 0;
	if( isSameParity(num[0],num[1]) == false){
		//cout<<"isNot Same parity"<<endl;
		if( isSameParity(num[2],num[0]) == true){
			num[0]++;
			num[2]++;
			ans++;
		}else{
			num[1]++;
			num[2]++;
			ans++;
		}
	}
	ans += (num[1] - num[0])/2 + (num[2] - num[1]);
	cout<<ans<<endl;
	return 0;
}



Measured memory_bytes: 256
open Hashtbl
let s = read_line ()
let t = read_line ()
let n = String.length s
let hs, ht = create n, create n
let f (s, t, h) = String.iteri (fun i c -> replace h c @@ try i :: find h c with _ -> [i]) s;
  iter (fun _ is -> List.(iter (fun j -> if t.[hd is] <> t.[j] then (print_endline "No"; exit 0))) is) h
let _ = List.iter f [(s, t, hs); (t, s, ht)] ; print_endline "Yes"

Measured memory_bytes: 16512
import java.util.*;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		String s = sc.next();
		int x = 0;
		int max = 0;
		for(int i=0; i<s.length(); i++){
			if(s.charAt(i)=='I')x++;
			else x--;
			if(x>max)max=x;
		}
		System.out.println(max);
	}
}

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

int main(void) {
	int a,b,c;
	int k;
	bool flag = 0;
	cin >> a >> b >> c;
	cin >> k;
	for (int x = 0; x <= k; x++) {
		for (int y = 0; y <= k - x;y++) {
			for (int z = 0; z <= k - x - y; z++) {
				if ((a*pow(2, x) < b*pow(2, y)) && (b*pow(2, y) < c*pow(2, z))) {
					flag = 1;
					break;
				}
			}
			
		}
	}
	if (flag == 1)cout << "Yes";
	else cout << "No";
	return 0;
}

Measured memory_bytes: 4020
from collections import defaultdict
n = int(input())
s = input()

a = s[:n]
b = s[n:][::-1]
d = defaultdict(int)
e = defaultdict(int)

for bit in range(1 << n):
    x = ""
    y = ""
    z = ""
    w = ""
    for i in range(n):
        if bit >> i & 1:
            x += a[i]
            z += b[i]
        else:
            y += a[i]
            w += b[i]
    d[x+'ω'+y] += 1
    e[z+'ω'+w] += 1

print(sum([e[k] * v for k, v in d.items()]))


Measured memory_bytes: 222320
#include<bits/stdc++.h>
using namespace std;
int main(){
	long long int x,y,a,b,c;
	cin>>x>>y>>a>>b>>c;
	long long r[x+y+c];
	long long p[a],q[b];
	for(int i=0;i<a;i++){
		cin>>p[i];
	}
	sort(p,p+a);
	int ind=0;
	for(long long i=a-1;i>a-x-1;i--){
		r[ind]=p[i];
		ind++;
	}
		for(int i=0;i<b;i++){
		cin>>q[i];
	}
	sort(q,q+b);
	 ind=x;
	for(long long i=b-1;i>b-y-1;i--){
		r[ind]=q[i];
		ind++;
	}
	ind=x+y;
	for(long long i=ind;i<x+y+c;i++){
		cin>>r[i];
	}
	
	sort(r,r+x+y+c);
	long long ans=0;
	for(long long i=x+y+c-1;i>c-1;i--){
		ans+=r[i];
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3968
<?php
    fscanf(STDIN, "%d", $n);
    $line = fgets(STDIN);
    $lines = explode(" ", $line);
    
    $ave = round(array_sum($lines)/count($lines));
    $cost = 0;
    
    for ($i = 0; $i < $n; $i++) {
        $cost += ($lines[$i]-$ave)**2;
    }
    
    echo $cost;
?>

Measured memory_bytes: 4604
using System;
class Program
 {
        static void Main(string[] args)
        {
    　　int a= int.Parse(Console.ReadLine()); //標準入力
          string length = Console.ReadLine();
          string[] words = length.Split(' ');

//Console.WriteLine("{0}", words.Length == a);//改行付き出力
        
          int count = 0;
          for(int i= 0;i<a;i++){
          	for(int j= i;j<a;j++){
              for(int k =j;k<a;k++){
                if(i==k||j==k||i==j){
                	continue;
                }else{
                  int l1;
                  int l2;
                  int l3;
                  l1 = int.Parse(words[i]);
                  l2 = int.Parse(words[j]);
                  l3 = int.Parse(words[k]);
                  bool b1;
                  bool b2;
                  bool b3;
                  b1 = (l1 + l2 > l3);
                  b2 = (l2 + l3 > l1);
                  b3 = (l3 + l1 > l2);
                  if(l1!=l2&&l2!=l3&&l3!=l1){
                  	
                  if(b1&&b2&&b3){
                    count++;
                  }
                  }
                }
              }
            }
          }
          Console.WriteLine("{0}", count);//改行付き出力
        
　　　　}
 }

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

#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define MIN(a) *min_element(all(a))
#define MAX(a) *max_element(all(a))
#define SUM(a, b) accumulate(all(a), b)
#define REP(i, n) for(int (i)=0; (i)<(n); (i)++)
#define RREP(i, n) for(int (i)=(n)-1; (i)>=0; (i)--)
#define FOR(i, m, n) for(int (i)=(m); (i)<(n); i++)
#define FORR(i, m, n) for(int (i)=(n)-1; (i)>=(m); i--)
#define ios() cin.tie(0), ios::sync_with_stdio(false)
#define debug(x) cerr << #x << " = " << x << endl
//#define int long long

typedef long long ll;
typedef unsigned long long ull;
//ll const MOD = 998244353;
ll const MOD = 1e9+7;
ll const INF = 1e18;

template<typename T> int size(const T& a){return (int)a.size();}
template<typename T> T Div(T a, T b){return (a + b - 1) / b;}
template<typename T> bool chmin(T& a, const T& b){if(a > b){a = b; return true;} return false;}
template<typename T> bool chmax(T& a, const T& b){if(a < b){a = b; return true;} return false;}



signed main(){
    int n;
    cin >> n;
    vector<tuple<string, int, int>> v(n);
    REP(i, n){
        string a;
        int b;
        cin >> a >> b;
        auto tp = make_tuple(a, b, i+1);
        v[i] = tp;
    }

    sort(all(v), [](auto a, auto b){
        if(get<0>(a) == get<0>(b)){
            return get<1>(a) > get<1>(b);
        }else{
            return get<0>(a) < get<0>(b);
        }
    }
    );
    for(auto i : v) cout << get<2>(i) << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ

		Scanner sc = new Scanner(System.in);
		int r = sc.nextInt();
		int D = sc.nextInt();
		int x = sc.nextInt();

		for (int i=0; i<10; i++) {
			x = r*x-D;
			System.out.println(x);
		}
	}

}

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

typedef long long ll;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define each(itr,c) for(__typeof(c.begin()) itr=c.begin(); itr!=c.end(); ++itr)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second

struct MaxSegTree{
    int n; vector<int> dat;
    //?????????
    MaxSegTree(int _n){
        n=1;
        while(n<_n) n*=2;
        dat=vector<int>(2*n-1,-1);
    }
    //k??????(0-indexed)?????????a?????´??°
    void update(int k, int a){
        k+=n-1;
        dat[k]=a;
        //??´??°
        while(k>0){
            k=(k-1)/2;
            dat[k]=max(dat[2*k+1],dat[2*k+2]);
        }
    }
    //k??????(0-indexed)?????????a????????????
    void add(int k, int a){
        k+=n-1;
        dat[k]+=a;
        //??´??°
        while(k>0){
            k=(k-1)/2;
            dat[k]=max(dat[2*k+1],dat[2*k+2]);
        }
    }
    int get(int k){
        return dat[k+n-1];
    }
    //?????¨??????????????????????????¨???
    int _query(int a, int b, int k, int l, int r){
        if(r<=a || b<=l) return -1;

        if(a<=l && r<=b) return dat[k];
        else{
            int vl=_query(a,b,2*k+1,l,(l+r)/2);
            int vr=_query(a,b,2*k+2,(l+r)/2,r);
            return max(vl,vr);
        }
    }
    //[a,b)????????§???????±???????
    int query(int a, int b){
        return _query(a,b,0,0,n);
    }
};

int main()
{
    int n,d;
    while(cin >>n >>d,n)
    {
        MaxSegTree st(n);
        vector<int> m(n);
        vector<vector<int>> c(n);
        rep(i,n)
        {
            scanf(" %d", &m[i]);
            c[i]=vector<int>(m[i]);

            int sum=0;
            rep(j,m[i])
            {
                scanf(" %d", &c[i][j]);
                sum+=c[i][j];
            }
            st.update(i,sum);
        }

        int total=0;
        rep(i,n) total+=m[i];

        bool valid=true;
        rep(T,total)
        {
            bool update=false;
            rep(i,n)
            {
                if(m[i]==0) continue;

                int others_max=max(st.query(0,i),st.query(i+1,n));
                int focus=st.get(i);

                if(others_max-(focus-c[i][m[i]-1])<=d)
                {
                    st.add(i,-c[i][m[i]-1]);
                    --m[i];
                    update=true;
                    break;
                }
            }

            if(!update)
            {
                valid=false;
                break;
            }
        }

        string ans="No";
        if(valid) ans="Yes";
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 3288
A,B,K = map(int,input().split())

for i in range(1,K+1):
  if i % 2 != 0:
    cookie = A
    if cookie % 2 == 0:
      pass
    else:
      cookie -= 1
    B += cookie/2
    A = cookie/2
  else:
    cookie = B
    if cookie % 2 == 0:
      pass
    else:
      cookie -= 1
    A += cookie/2
    B = cookie/2

print(int(A),int(B))

    


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

int main () {
  int a, b, c;
  cin >> a >> b >> c;
  if (a < b && b < c) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 3100
#include<iostream>
#include<algorithm>
#include<cstring>
using namespace std;

bool s[50][100];
int main(){
	int n,q;
	while(cin>>n>>q,n||q){
		memset(s,false,sizeof(s));
		for(int i=0;i<n;i++){
			int m;
			cin>>m;
			for(int j=0;j<m;j++){
				int d;
				cin>>d;
				s[i][d-1]=true;
			}
		}
		int ans=-1;
		int max=0;
		for(int i=0;i<100;i++){
			int c=0;
			for(int j=0;j<n;j++){
				if(s[j][i])c++;
			}
			if(q<=c && max<c){
				max=c;
				ans=i;
			}
		}
		cout<<ans+1<<endl;
	}
	return 0;
}

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

#define ll long long
#define ull unsigned long long 
#define endl '\n'
#define pii pair<int, int>
#define all(a) a.begin(),a.end()
int main(){
    int a, b;
    cin >> a >> b;
    if(a<=0 && b>=0){
        cout << "Zero";
    }
    else if(a<0 && b<0){
        if((b-a+1)&1)
            cout << "Negative";
        else
            cout << "Positive";
    }
    else if(a>0 && b>0){
        cout << "Positive";
    }
    else{
        if((-a)&1)
            cout << "Negative";
        else
            cout << "Positive";
    }
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
using LL = long long int;
#define incID(i, l, r) for(int i = (l)    ; i <  (r); ++i)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); --i)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); ++i)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); --i)
#define inc(i, n)  incID(i, 0, n)
#define dec(i, n)  decID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define dec1(i, n) decII(i, 1, n)
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))
#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define MT make_tuple
#define FI first
#define SE second
#define FR front()
#define BA back()
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
auto setmin   = [](auto & a, auto b) { return (b <  a ? a = b, true : false); };
auto setmax   = [](auto & a, auto b) { return (b >  a ? a = b, true : false); };
auto setmineq = [](auto & a, auto b) { return (b <= a ? a = b, true : false); };
auto setmaxeq = [](auto & a, auto b) { return (b >= a ? a = b, true : false); };
#define SI(v) static_cast<int>(v.size())
#define RF(e, v) for(auto & e: v)
#define until(e) while(! (e))
#define if_not(e) if(! (e))
#define ef else if
#define UR assert(false)
#define IN(T, ...) T __VA_ARGS__; IN_(__VA_ARGS__);
void IN_() { };
template<typename T, typename ... U> void IN_(T &  a, U &  ... b) { cin >> a; IN_(b ...); };
template<typename T                > void OUT(T && a            ) { cout << a << endl; }
template<typename T, typename ... U> void OUT(T && a, U && ... b) { cout << a << " "; OUT(b ...); }

// ---- ----

const int M = 1'000'000 / 2;

int A[M + 1], B[M + 1];
int main() {
	IN(int, n);
	int aa = 0, bb = 0, cc = 0;
	inc(i, n) {
		IN(string, s);
		int mi = 0, sum = 0;
		RF(c, s) {
			sum += (c == '(' ? +1 : -1);
			setmin(mi, sum);
		}
		int a = -mi, b = sum - mi;
		if(a < b) {
			A[a] += sum;
			setmax(aa, a);
		}
		ef(a > b) {
			B[b] += sum;
			setmax(bb, b);
		}
		else { setmax(cc, a); }
	}
	
	int mi = 0, sum = 0;
	incII(i, 0, aa) {
		if(A[i] == 0) { continue; }
		setmin(mi, sum - i);
		sum += A[i];
	}
	setmin(mi, sum - cc);
	decII(i, 0, bb) {
		if(B[i] == 0) { continue; }
		sum += B[i];
		setmin(mi, sum - i);
	}
	
	OUT(mi >= 0 && sum == 0 ? "Yes" : "No");
}


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



int main(){
  int l;
  bool ana[201];
  
  cin>>l;
  for(int i=1;i<=201;i++){
    ana[i]=false;
  }
  stack<int> neko;
  for(int i=1;i<=l;i++){
    int c;
    cin>>c;
    if(c>0){
      if(ana[c]){
        cout<<i<<endl;
        return 0;
      }
      neko.push(c);
      ana[c]=true;
      continue;
    }
    if(!neko.empty()){
      if(neko.top()==c*-1){
        neko.pop();
        ana[c*-1]=false;
        continue;
      }
    }
    cout<<i<<endl;
    return 0;
    
    
    
  }
  cout<<"OK"<<endl;
  
  
  
  
  
  
}



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

int k ,t,a[101];
int main(){
	cin >> k>>t;
	int sum = 0;
	for (int i=0;i<t;i++){
		cin >>a[i];
		sum += a[i];
	}
	sort(a,a+t);
	int result = a[t-1]-(sum-a[t-1]);
	if(result>0) cout << result-1;
	else cout << 0;
	return 0;
}

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



void solve(int L){
    if(L % 3 == 0) {
        float answer = float((L/3)*(L/3)*(L/3));
        printf("%8f", float(answer));
        return;
    }
    float a = float(L)/3;
    printf("%8f", float(a*a*a));
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    int L;
    scanf("%d",&L);
    solve(L);
    return 0;
}


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

class CARD{
  public:
  int B;
  long C;  
  
  bool operator<(const CARD &c) const
  {
    return C > c.C;
  };

};

int main(){
  int N,M;
  cin >> N >> M;
  vector<int> A(N);
  vector<CARD> card(M);
  for(int i=0;i<N;i++){
    cin >> A[i];    
  }
  for(int i=0;i<M;i++){
    cin >> card[i].B >> card[i].C;
  }

  sort(A.begin(),A.end(),greater<int>());
  sort(card.begin(),card.end());

  vector<long> ans;
  for(int i=0,j=0;ans.size()<N;){
    if(j<M){
      if(A[i]<card[j].C){
	ans.push_back(card[j].C);
	card[j].B--;
	if(card[j].B<=0){
	  j++;
	}
      }else{
	ans.push_back(A[i]);
	i++;
      }
    }else{
      ans.push_back(A[i]);
      i++;
    }
  }

  long long sum=0;
  for(int i=0;i<N;i++){
    sum+=ans[i];
  }
  cout << sum << endl;

  return 0;
}

Measured memory_bytes: 3320
def main():
  def f(i,x):
    while i<=n:
      b[i]+=x
      i+=i&-i
  def g(i):
    s=0
    while i:
      s+=b[i]
      i-=i&-i
    return s
  (n,q,*w),a,*t=[[*map(int,t.split())]for t in open(0)]
  b=[0]*-~n
  *map(f,range(1,n+1),a),
  for q,l,r in t:
    if q:w+=g(r)-g(l),
    else:f(l+1,r)
  print(' '.join(map(str,w)))
main()

Measured memory_bytes: 174784
#include<bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i) 
#define rrep(i, a, b) for (int i = (a); i < (b); ++i)
#define PI acos(-1)
#define pcnt __builtin_popcountll
#define rng(a) a.begin(), a.end()
#define rrng(a) a.rbegin(), a.rend()
#define sz(x) (int)(x).size()
#define v(T) vector<T>
#define vv(T) v(v(T))
#define fi first
#define se second

using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using LP = pair<ll, ll>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using tl = tuple<ll, ll, ll>;

template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
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; }

ll INF = 1001001001;
ll LINF = 1001001001001001001ll;

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

    string s; cin>>s;
    s = s.substr(0, 3);
    cout<<s<<endl;
}

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

int main() {
	int n;
	cin >> n;
	long long a[100010], b[100010];
	for (int i = 0;i < n;i++) {
		cin >> a[i] >> b[i];
	}
	long long ans = 0;
	for (int i = n - 1;i >= 0;i--) {
		ans += (b[i] - ((a[i] + ans) % b[i])) % b[i];
	}
	cout << ans << endl;
}


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

int n;
int A[410];
int cum[410];
int dp[410][410];

int f(int l, int r){
     if(l==r) return 0;

     int&ans=dp[l][r];
     if(ans!=-1) return ans;
     
     ans=LLONG_MAX;
     for(int i=l;i<r;i++){
          int cost=0;
          if(l==0)cost+=cum[i];
          else cost+=cum[i]-cum[l-1];
          cost+=cum[r]-cum[i];

          ans=min(ans, cost+f(l, i)+f(i+1, r));
     }

     return ans;
}


int32_t main(){
     cin>>n;
     memset(dp, -1, sizeof(dp));
     for(int i=0;i<n;i++)cin>>A[i];
     cum[0]=A[0];
     for(int i=1;i<n;i++)cum[i]=cum[i-1]+A[i];

     cout<<f(0, n-1);
}

Measured memory_bytes: 1536