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

int h,w;
vector<string> field;
string s;
int p,cnt;
int y,x;
int dir;
int dy[]={-1,0,1,0};
int dx[]={0,1,0,-1};
int used[50][50][1001][4];

void program();
void statement();
void _if();
void _while();
void act();
bool expr();

void skip(){
    int icnt=0;
    int wcnt=0;
    while(icnt>=0 && wcnt>=0){
        if(s[p]=='[') icnt++;
        if(s[p]==']') icnt--;
        if(s[p]=='{') wcnt++;
        if(s[p]=='}') wcnt--;
        p++;
    }
}

void flip(){
    dir=(dir+2)%4;
}
bool iswall(){
    return field[y+dy[dir]][x+dx[dir]]=='#';
}
bool end(){
    return p>=s.size() || s[p]==']' || s[p]=='}';
}

void program(){
    while(!end()){
        statement();
    }
    return;
}

void statement(){
    if(s[p]=='['){
        _if();
        return;
    }
    if(s[p]=='{'){
        _while();
        return;
    }
    act();
    return;
}

void _if(){
    assert(s[p]=='[');
    p++;
    if(!expr()){
        skip();
        return;
    }
    program();
    assert(s[p]==']');
    p++;
    return;
}

void _while(){
    while(true){
        if(used[y][x][p][dir]){
            throw "nonFin";
        }
        used[y][x][p][dir]=true;

        int prep=p;
        assert(s[p]=='{');
        p++;
        if(!expr()){
            skip();
            return;
        }
        program();
        assert(s[p]=='}');
        p=prep;
    }
}

void judge(){
    if(field[y][x]=='g') throw "Fin";
}

void act(){
    cnt++;
    char op=s[p];
    p++;
    switch(op){
        case '^':
            if(!iswall()){
                y=y+dy[dir];
                x=x+dx[dir];
            }
            judge();
            return;
        case 'v':
            flip();
            if(!iswall()){
                y=y+dy[dir];
                x=x+dx[dir];
            }
            flip();
            judge();
            return;
        case '<':
            dir=(dir+3)%4;
            return;
        case '>':
            dir=(dir+1)%4;
            return;
    }
    throw "Act Error";
}

bool expr(){
    bool hoge=(s[p]!='~');
    if(s[p]=='~') p++;
    char op=s[p];
    p++;
    switch(op){
        case 'N':
            return !((dir==0)^hoge);
        case 'E':
            return !((dir==1)^hoge);
        case 'S':
            return !((dir==2)^hoge);
        case 'W':
            return !((dir==3)^hoge);
        case 'C':
            return !(iswall()^hoge);
        case 'T':
            return hoge;
    }
    throw "Error Check";
}

void run(){
    cnt=0,p=0,dir=0;
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            if(field[i][j]=='s'){
                y=i;
                x=j;
            }
        }
    }
    try{
        program();
    }catch(const char* ex){
        if(ex=="Fin"){
            return;
        }
        else if(ex=="nonFin"){
            cnt=-1;
            return;
        }
        else{
            cout<<ex<<endl;
            abort();
        }
    }
    return;
}

int main(){
    cin>>h>>w;
    field.resize(h);
    for(int i=0;i<h;i++) cin>>field[i];
    cin>>s;
    run();
    if(field[y][x]!='g') cnt=-1;
    cout<<cnt<<endl;
    return 0;
}

Measured memory_bytes: 25560
#include <bits/stdc++.h>
using namespace std;
#define NIL -1

int main() {
  int A[3][3];

  for (int i = 0; i < 3; i++) {
    for (int j = 0; j < 3; j++) {
      int tmp;
      cin >> tmp;
      A[i][j] = tmp;
    }
  }

  int N;
  cin >> N;
  for (int i = 0; i < N; i++) {
    int tmp;
    cin >> tmp;
    for (int j = 0; j < 3; j++) {
      for (int k = 0; k < 3; k++) {
        if (A[j][k] == tmp) A[j][k] = NIL;
      }
    }
  }

  bool isBingo = false;
  //縦
  if (A[0][0] == A[1][0] && A[1][0] == A[2][0]) isBingo = true;
  if (A[0][1] == A[1][1] && A[1][1] == A[2][1]) isBingo = true;
  if (A[0][2] == A[1][2] && A[1][2] == A[2][2]) isBingo = true;

  if (A[0][0] == A[0][1] && A[0][1] == A[0][2]) isBingo = true;
  if (A[1][0] == A[1][1] && A[1][1] == A[1][2]) isBingo = true;
  if (A[2][0] == A[2][1] && A[2][1] == A[2][2]) isBingo = true;

  if (A[0][0] == A[1][1] && A[1][1] == A[2][2]) isBingo = true;
  if (A[0][2] == A[1][1] && A[2][0] == A[1][1]) isBingo = true;

  if (isBingo) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}


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

int main(){
    string a,b,c;
    cin >> a >> b >> c;
    printf("%c%c%c\n",a[0]-'a'+'A',b[0]-'a'+'A',c[0]-'a'+'A');
    return 0;
}

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

#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, n, m) for(int (i) = (n); (i) < (m); ++(i))

constexpr int INF = 1e9;
// constexpr ll INF = 1LL<<61;
constexpr ll mod = 1e9+7;



int main(){
  string S;
  cin >> S;
  vector<ll> cnt(2019, 0);
  int N = S.size();
  ll x = 0;
  ll ans = 0;
  cnt[0] = 1;
  REP(i, N){
    x *=10;
    x += S[i] - '0';
    x %= 2019;
    ans += cnt[x];
    cnt[x]++;
    vector<ll> ncnt(2019, 0);
    REP(j, 2019){
      int id = (j * 10) % 2019;
      ncnt[id] = cnt[j];
    }
    cnt = ncnt;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3704
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define call(var) cout<<#var<<"="<<var<<endl;
using ll=long long;
using vi = vector<int>;
using vl = vector<ll>;
using vb = vector<bool>;
using Graph = vector<vi>;
using P = pair<int,int>;
const int MOD=(int)1e9+7;
const int INF=(int)1e9;
const ll LINF=(ll)1e18;
template<class t,class u> void chmax(t&a,u b){if(a<b)a=b;}
template<class t,class u> void chmin(t&a,u b){if(b<a)a=b;}

struct Edge{
    int ver;
    int wei;
    Edge(int v,int w) : ver(v),wei(w) {}
};
using WGraph = vector<vector<Edge>>;

int main(){
    int n;
    cin >> n;
    WGraph G(n);
    rep(i,n-1){
        int a,b,c;
        cin >> a >> b >> c;a--;b--;
        G[a].push_back(Edge(b,c));
        G[b].push_back(Edge(a,c));
    }
    vi ans(n,-1);
    queue<int> q;
    ans[0] = 0;
    q.push(0);
    while(q.size()){
        int v = q.front();
        q.pop();

        for(auto t : G[v]){
            if(ans[t.ver]!=-1) continue;
            q.push(t.ver);
            if(t.wei & 1) ans[t.ver] = !ans[v];
            else ans[t.ver] = ans[v];
        }
    }
    rep(i,n) cout << ans[i] << endl;
}

Measured memory_bytes: 6784
import heapq
size = int(input())
li = list(map(int,input().split()))
heapq.heapify(li)
while(len(li)>1):
    a = heapq.heappop(li)
    b = heapq.heappop(li)
    heapq.heappush(li,(a+b)/2)
print(li[0])


Measured memory_bytes: 3060
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder2 {
	class Program {
		static void Main(string[] args) {
          
				var inputArray = retreiveStringArray();
			var inputCount = 1;

			// 不正な入力は処理しない
			if (inputArray.Length != inputCount) {
				Console.WriteLine("invalid input");
				return;
			}
			var S = inputArray[0];

			switch (S) {
				case "SUN":
					Console.WriteLine(7);
					return;
				case "MON":
					Console.WriteLine(6);
					return;
				case "TUE":
					Console.WriteLine(5);
					return;
				case "WED":
					Console.WriteLine(4);
					return;
				case "THU":
					Console.WriteLine(3);
					return;
				case "FRI":
					Console.WriteLine(2);
					return;
				case "SAT":
					Console.WriteLine(1);
					return;
				default:
					break;
			}



		}

		/// <summary>
		/// スペースで区切られた文字列配列の入力を受け取る
		/// </summary>
		/// <returns></returns>
		private static string[] retreiveStringArray() {
			var inputArray = Console.ReadLine().Split(' ');
			return inputArray;
		}

		/// <summary>
		/// スペースで区切られた整数配列の入力を受け取る
		/// </summary>
		/// <returns></returns>
		private static long[] retreiveLongArray() {
			var inputArray = Console.ReadLine().Split(' ');
			var longArray = inputArray.Select(s => long.Parse(s));
			return longArray.ToArray();
		}


		/// <summary>
		/// 2組みずつの入力データ(数値)からTuppleListを作成する
		/// </summary>
		/// <param name="N"></param>
		/// <returns></returns>
		private static List<Tuple<long, long>> createLongTuppleList(long N) {
			var inpList = new List<Tuple<long, long>>();

			for (int i = 0; i < N; i++) {
				var inp = retreiveLongArray();
				var item1 = inp[0];
				var item2 = inp[1];
				inpList.Add(new Tuple<long, long>(item1, item2));
			}
			return inpList;
		}
	}
}


Measured memory_bytes: 25888
//~ while (clock()<=69*CLOCKS_PER_SEC)
//~ #pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
//~ #pragma GCC target ("avx2")
//~ #pragma GCC optimize("Ofast")
//~ #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//~ #pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;

template <typename T>
using ordered_set =
    tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

#define shandom_ruffle random_shuffle

using ll=long long;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
using vi=vector<int>;
using vll=vector<ll>;
const int nax=307;

int n;
int a, b, c;

double dp[nax][nax][nax];

int main()
{
	scanf("%d", &n);
	for (int i=1; i<=n; i++)
	{
		int x;
		scanf("%d", &x);
		if (x==1)
			a++;
		if (x==2)
			b++;
		if (x==3)
			c++;
	}
	for (int i=0; i<=n; i++)
	{
		for (int j=0; j<=n; j++)
		{
			for (int l=0; l<=n; l++)
			{
				if (!(i+j+l))
					continue;
				double p=(i+j+l)/((double)n);
				if (i)
					dp[i][j][l]+=dp[i-1][j+1][l]*i/(i+j+l);
				if (j)
					dp[i][j][l]+=dp[i][j-1][l+1]*j/(i+j+l);
				if (l)
					dp[i][j][l]+=dp[i][j][l-1]*l/(i+j+l);
				
				
				
				dp[i][j][l]+=1/p;
			}
		}
	}
	printf("%.11lf\n", dp[c][b][a]);
	return 0;
}


Measured memory_bytes: 223488
//Date and time of submission: 
 
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const ll N=1e5+5;
ll a,b;
int main() {
	ios_base::sync_with_stdio(false); 
	cin.tie(NULL);
	cin>>a>>b;
	if((a*b)&1)
	cout<<"Odd";
	else
	cout<<"Even";
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <cmath>
#include <map>
#include <climits>
#include <cassert>
#include <algorithm>
#include <utility>

using namespace std;
using Int = long long int;
using UInt = unsigned long long int;
using VI = vector<long long int>;
using VVI = vector<vector<long long int> >;

// 二つの値の最小値を求める関数
Int Min(const Int a, const Int b) {
    if (a <= b) {
        return a;
    } else {
        return b;
    }
}
// 絶対値を求める
UInt Abs(const Int a) {
    return a > 0 ? a : -a;
}
int main(void) {
    Int n, k;
    cin >> n >> k;
    n = (n % k);
    n = Min(n, Abs(n - k));
    cout << n << endl;
    return 0;
}



Measured memory_bytes: 3632
#include <stdio.h>
int main(){
	int a, b, d, r;
	double f;
	scanf("%d %d", &a, &b);
	d = a/b;
	r = a%b;
	f = (double)a/b;
	printf("%d %d %f\n", d, r, f);
	return 0;
}

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

signed main()
{
    double x1,y1,x2,y2,x3,y3; cin>>x1>>y1>>x2>>y2>>x3>>y3;

    double a=hypot(abs(x1-x2),abs(y1-y2));
    double b=hypot(abs(x2-x3),abs(y2-y3));
    double c=hypot(abs(x3-x1),abs(y3-y1));
    
    double s=(a+b+c)/2;
    double S=sqrt(s*(s-a)*(s-b)*(s-c));
    double r=S/s;

    double M=max({a,b,c});
    double ans=(M*r)/(2*r+M);

    cout<<fixed<<setprecision(10)<<ans<<endl;
}


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

using namespace std;
using ll = long long;


void suzuken() {
	ll b; scanf("%lld", &b); if (b == 0) exit(0);
	ll res = 0;
	ll tmp = 0;
	for (int i = 1; i <= 100000; i++) {
		ll sum = (1 + i) * i / 2;
		if (b < sum) break;
		if ((b - sum) % i == 0) {
			res = i;
			tmp = 1 + (b - sum) / i;
		}
	}
	cout << tmp << " " << res << "\n";
}
int main() {
	int kkt = 89;
	while (kkt) {
		suzuken();
	}
}


Measured memory_bytes: 3240
n, a, b = map(int, input().split())
m = 10 ** 9 + 7

def combn(n, r, m):
    X = Y = 1
    if n-r < r:
        r = n-r
    for i in range(1, r+1):
        Y = Y*i % m
        X = X*(n-i+1) % m
    Y = pow(Y, m-2, m)
    return X*Y
  
print((pow(2, n, m) - 1 - combn(n, a, m) - combn(n ,b, m)) % m)


Measured memory_bytes: 3060
#include <vector>
#include <algorithm>
#include <iostream>
#include <cassert>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <cstdio>
#include <ctime>
#include <map>
#include <set>
#include <chrono>
#include <queue>
#include <string>
#include <cassert>
#include <bitset>
#include <stack> 

#define INFLL 2000000000000000000
#define INF 2000000000
#define MOD 1000000007
#define BASE 77747
#define PI acos(-1.0)
#define MAXLEN 29

using namespace std;

typedef pair <int, int> pii;
typedef long long ll;
typedef vector <ll> vll;

class Matrix2D {
	public:
		Matrix2D(int rows, int cols) {
			data.resize(rows);
			for (int i = 0; i < rows; i++) data[i].resize(cols, 0);
		}
		void setValue(int i, int j, int val) {
			data[i][j] = val;
		}
		ll getValue(int i, int j) {
			return data[i][j];
		}
		ll rows() {
			return data.size();
		}
		ll cols() {
			return data[0].size();
		}
		static Matrix2D mult(Matrix2D a, Matrix2D b) {
			assert(a.cols() == b.rows());

			Matrix2D result(a.rows(), b.cols());
			for (int i = 0; i < a.rows(); i++) {
				for (int j = 0; j < b.cols(); j++) {
					ll sum = 0;
					for (int k = 0; k < a.cols(); k++) {
						sum += a.getValue(i, k) * b.getValue(k, j);

						sum %= MOD;
					}
					result.setValue(i, j, sum);
				}
			}
			return result;
		}
	private:
		vector < vector <ll> > data;
};


int main() {
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	int n;
	ll k;
	int go[50][50];
	cin >> n >> k;
	for (int i = 0; i < n; i++) for (int j = 0; j < n; j++) cin >> go[i][j];
	Matrix2D start(1, n);
	for (int i = 0; i < n; i++) start.setValue(0, i, 1);
	Matrix2D step(n, n);
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) if (go[j][i]) step.setValue(j, i, 1);
	}
	while (k) {
		if (k & 1) 
			start = Matrix2D::mult(start, step);
		step = Matrix2D::mult(step, step);
		k >>= 1;
	}
	ll ans = 0;
	for (int i = 0; i < start.rows(); i++) {
		for (int j = 0; j < start.cols(); j++) {
			ans += start.getValue(i, j);
			ans %= MOD;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 384
N = int(input())
A = [list(map(int,input().split())) for i in range(N)]
dpa = [0]*N
dpb = [0]*N
dpc = [0]*N
dpa[0] = A[0][0]
dpb[0] = A[0][1]
dpc[0] = A[0][2]
for i in range(1,N):
    a = A[i][0]
    b = A[i][1]
    c = A[i][2]
    dpa[i] = max(dpb[i-1]+a,dpc[i-1]+a)
    dpb[i] = max(dpa[i-1]+b,dpc[i-1]+b)
    dpc[i] = max(dpb[i-1]+c,dpa[i-1]+c)
Min = dpa[N-1]
Mmin = max(dpb[N-1],dpc[N-1])
print(max(Min,Mmin))


Measured memory_bytes: 42444
def main(heads, foots):
    """
    - foots != odd
    - 2*heads <= foots <= 4*heads
    """
    if foots%2 == 1:
        return 'No'
    else:
        if 2*heads <= foots <= 4*heads:
            return 'Yes' 
        else:
            return 'No'

if __name__ == '__main__':
    heads, foots = map(int, input().split())
    ans = main(heads, foots)
    print(ans)



Measured memory_bytes: 9100
import sys
int1 = lambda x: int(x) - 1
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(500000)

X = int(read())
cnt = 0
acc = 100
while acc < X:
    cnt += 1
    acc *= 1.01
    acc //= 1

print(cnt)


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

using namespace std;

const int MAXN = 300005;
const long long oo = 1e18;

int n, a[MAXN];
long long fl[MAXN], fr[MAXN];

int main() {
    scanf("%d", &n);
    for(int i = 0; i < 3*n; ++i)
        scanf("%d", &a[i]);

    long long sum = 0;
    priority_queue<int, vector<int>, greater<int> > ql;
    for(int i = 0; i < 3*n; ++i) {
        sum += a[i];
        ql.push(a[i]);
        if (ql.size() > n) {
            sum -= ql.top();
            ql.pop();
        }
        fl[i] = sum;
    }

    sum = 0;
    priority_queue<int> qr;
    for(int i = 3*n - 1; i >= 0; --i) {
        sum += a[i];
        qr.push(a[i]);
        if (qr.size() > n) {
            sum -= qr.top();
            qr.pop();
        }
        fr[i] = sum;
    }

    long long ans = -oo;
    for(int i = n-1; i < 2*n; ++i)
        ans = max(ans, fl[i] - fr[i+1]);
    printf("%lld", ans);

    return 0;
}


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

using namespace std;

int main() {

	long long n;
	cin >> n;

	long long res=0;
	for (int i = 1; i <= n; i++) {
		res += (long long)(n / i)*((n / i) + 1)*i / 2;
	}

	cout << res << endl;

	return 0;

}

Measured memory_bytes: 3596
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <cmath>
#include <iomanip>
#include <cassert>
#include <bitset>
using namespace std;

typedef pair<int, int> P;
#define rep(i, n) for (int i=0; i<(n); i++)
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end())
#define _1 first
#define _2 second
#define pb push_back
#define INF (1LL<<60)
#define MOD 1000000007

int N;
long long X[100000], R[100000];

double f(double p) {
  double h = 1e20;
  rep(i, N) {
    double d = abs(X[i] - p);
    h = min(h, R[i]*R[i] - d*d);
  }
  return sqrt(h);
}

signed main() {
  ios::sync_with_stdio(false); cin.tie(0);
  cin >> N;
  long long l = -INF, r = INF;
  rep(i, N) {
    cin >> X[i] >> R[i];
    l = max(l, 0LL+X[i]-R[i]);
    r = min(r, 0LL+X[i]+R[i]);
  }
  if (l >= r) {
    cout << "0.0" << "\n";
    return 0;
  }
  double lo = l, hi = r;
  rep(_, 100) {
    double a = (lo + lo + hi) / 3;
    double b = (lo + hi + hi) / 3;
    if (f(a) >= f(b)) hi = b;
    else lo = a;
  }
  cout << fixed << setprecision(20) << f(hi) << "\n";
  return 0;
}

Measured memory_bytes: 4860
#include <stdio.h>

void swap(int *nx, int *ny)
{
    int temp = *nx;
    *nx = *ny;
    *ny = temp;
}

void sort3(int *n1, int *n2, int *n3)
{
    if (*n1 > *n2) swap(n1, n2);
    if (*n2 > *n3) swap(n2, n3);
    if (*n1 > *n2) swap(n1, n2);
}

int main(void)
{
    int na, nb, nc;
    
    scanf("%d %d %d",&na,&nb,&nc);
    sort3(&na, &nb, &nc);
    
   printf("%d %d %d\n",na,nb,nc);
    
    return (0);
}



Measured memory_bytes: 2044
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <bitset>
#include <map>

#define REP(i,k,n) for(int i=k;i<n;i++)
#define rep(i,n) for(int i=0;i<n;i++)

using namespace std;

int n,j,y;

int main()
{
	cin >> j >> y;
	n = j + y;

	rep(i,1<<n)
	{
		bitset<12> bit(i);

		if(bit.count() == y)
		{
			string s = "";

			rep(j,n)
			{
				if(bit[j] == 0) s += "A";
				else s += "B";
			}

			reverse(s.begin(),s.end());
			int a=0,b=0;
			bool flag = true;

			rep(j,n)
			{
				if(s[j] == 'A') a++;
				else b++;

				if(a <= 3 && b == 5)
				{
					if(j != n-1)
					{
						flag = false;
						break;
					}
				}
				else if(a == 5 && b <= 3)
				{
					if(j != n-1)
					{
						flag = false;
						break;
					}
				}
			}

			if(flag) cout << s << endl;

		}
	}


	return 0;
}

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

struct UnionFind {
    vector<int> par;
    vector<int> siz;

    UnionFind(int N) : par(N), siz(N,1) {
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) {
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) {
        int rx = root(x);
        int ry = root(y);
        if (rx == ry) return;
        if(siz[rx] < siz[ry]) swap(rx, ry);
        siz[rx] += siz[ry];
        par[ry] = rx;
    }

    bool same(int x, int y) {
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }

    int size(int x){
      return siz[root(x)];
    }
};


int main(){
  int n,m,k;
  cin >> n >> m >> k;
  int a[m],b[m];

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

  int c[k],d[k];
  for(int i=0;i<k;i++){
    cin>>c[i] >> d[i];
    c[i] = c[i]-1;
    d[i] = d[i]-1;
  }

  UnionFind tree(n);

  for(int i =0;i<m;i++){
    if(!tree.same(a[i],b[i])){
      tree.unite(a[i],b[i]);
    }
  }

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

  for(int i=0;i<m;i++){
    if(tree.same(a[i],b[i])){
      ans[a[i]] = ans[a[i]]-1;
      ans[b[i]] = ans[b[i]]-1;
    }
  }
  for(int i=0;i<k;i++){
    if(tree.same(c[i],d[i])){
      ans[c[i]] = ans[c[i]]-1;
      ans[d[i]] = ans[d[i]]-1;
    }
  }
  for(int i=0;i<n;i++){
    if(i==n-1){
      cout << ans[i]+tree.size(i)-1 << endl;
    }
    else{
      cout << ans[i]+tree.size(i)-1 << ' ';  
    }
  }
}


Measured memory_bytes: 3584
#include <iostream>
#include <cstring>
using namespace std;
char n[10000];
int main() {
	cin>>n;
	int len = strlen(n);
	int i=0;
	if (n[i]==n[len-1]){
		cout<<"Yes";
	}
	else cout<<"No";
	return 0;
	

}


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

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"

using namespace std;
using ll = long long;

const ll MOD = 1000000007LL; // = 10^9 + 7
const double PI = 3.14159265358979;

void solve()
{
  ll n, a, b, c, d, e;
  cin >> n >> a >> b >> c >> d >> e;
  ll min_flow = min({a,b,c,d,e});
  ll ans = 4LL + (n - 1) / min_flow + 1LL;
  cout << ans;
}

int main()
{
  fastio;
  solve();

  return 0;
}

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

using namespace std;
typedef long long ll;

int main()
{
    ll i, c, j;
    ll p[10001] = {2};
    i = 1;
    c = 3;
    ll a, x;
    cin >> x;
    while (i < 10001 && p[i - 1] < x)
    {
        a = 0;
        for (j = 0; j < i; j++)
        {
            if (c % p[j] == 0)
            {
                a = 1;
                break;
            }
        }
        if (a == 0)
        {
            p[i] = c;
            i++;
        }
        c += 2;
    }
    cout << p[i - 1] << endl;
    return 0;
}

Measured memory_bytes: 384
import sys
N = int(input())
s = [input() for i in range(N)]
    
a = s.count("AC")
b = s.count("WA")
c = s.count("TLE")
d = s.count("RE")
 
print("AC"+" x "+str(a))
print("WA"+" x "+str(b))
print("TLE"+" x "+str(c))
print("RE"+" x "+str(d))

Measured memory_bytes: 16296
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
const long long INF=1e18,MOD=1e9+7;
bool comp(pair<string, pair<int,int>>a,pair<string, pair<int,int>>b){
	if(a.first!=b.first)return a.first<b.first;
	else return a.second.first>b.second.first;
}
int main(){
	ll n;
	cin>>n;
	vector<pair<string, pair<int, int>>> s(n);
	for(int i=0;i<n;i++){
		cin>>s[i].first>>s[i].second.first;
		s[i].second.second=i+1;
	}
	sort(s.begin(),s.end(),comp);
	for(int i=0;i<n;i++){
		cout<<s[i].second.second<<endl;
	}
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file  
#include <ext/pb_ds/tree_policy.hpp>  
#include <functional> // for less  
using namespace         std;
#define                 int long long
#define                 pb push_back
#define                 mp make_pair
#define st(arr,a)       memset(arr,a,sizeof arr)
#define                 nl cout<<'\n'
#define bitcount(x)     __builtin_popcountll(x)
const int MOD = 1000000007ll;
#define forn(i,a,b)     for(int i=a;i<=b;i++)
#define rfor(i,a,b)     for(int i=a;i>=b;i--)
#define all(x)          x.begin() , x.end()
#define pi pair<int,int>
#define X first
#define Y second
#define sz(A) (int)A.size()
#define N 1014159
#define  vi vector<int>
#define  v  vector
#define die exit(0)
#define alln(arr) arr+1 , arr+1+n
using namespace __gnu_pbds;  
typedef tree<int, null_type, less<int>, rb_tree_tag,  
            tree_order_statistics_node_update> oset; 

// order_of_key (k) : Number of items strictly smaller than k .
// find_by_order(k) : K-th element in a set (counting from zero).

#define in input_int()
#define ins input_string()
bool sb(int a,int i){return (a&(1LL<<i))>0;}
int p2(int a){return (1LL<<a);}
int input_int(){int a;cin>>a;return a;}
string input_string(){string s;cin>>s;return s;}
int dx[4] = {0, 1, 0, -1};
int dy[4] = {1, 0, -1, 0};



int n,m,k,a,b,c,d,x,y,arr[N];
string s;
void solve()
{
    set<int>dc[N];
    cin>>s;
    n=s.size();

    forn(i,0,n-1)
    {
        dc[s[i]-'a'].insert(i);
    }

    int odds=0;
    forn(i,0,25)
    {
        if(dc[i].size()%2)odds++;
    }

    if(odds>1)
    {
        cout<<-1;
        return;
    }
    if(n%2!=odds)
    {
        cout<<-1;
        return;
    }


    oset bc;
    forn(i,0,n-1)bc.insert(i);
    int ans=0;
    while(bc.size()>1)
    {   
        int ta=MOD,val=-1;
        forn(i,0,25)
        {
            if(dc[i].size()>1)
            {
                int a=*dc[i].begin(),b=*dc[i].rbegin();
                int at=bc.order_of_key(a)+bc.size()-bc.order_of_key(b+1);
                if(ta>at)
                {
                    ta=at;
                    val=i;
                }
            }
        }
        ans+=ta;
        int a=*dc[val].begin(),b=*dc[val].rbegin();
        bc.erase(a);
        bc.erase(b);
        dc[val].erase(a);
        dc[val].erase(b);
    }

    cout<<ans;    











}


signed main() 
{
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); 
    int t = 1;
    //cin>>t;
    forn(i,1,t)
    {
        //cout<<":Case #"<<i<<": ";
        solve();
        nl;
    }



    return 0;

}
//       clang++ c.cpp ; ./a.out < a.txt ;  

Measured memory_bytes: 73088
#include <bits/stdc++.h>
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 x;
int main() {
    cin >> x;
    int goh = 0;
    int goen = 0;
    goh = x / 500;
    x -= 500*goh;
    goen = x / 5;
    cout << goh*1000+ goen*5 << endl;
}

Measured memory_bytes: 256
N = int(input())
c = input()
W = 0
R = 0

for x in c:
  if x=='R':
    R += 1

ans = R
for x in c:
  if x=='W':
    W += 1
  else:
    R -= 1
    
  ans = min(ans,max(R,W))
  
print(ans)

Measured memory_bytes: 68044
#include <iostream>
#include <algorithm>
using namespace std;
int main(){
int  n, arr[105], y=1;
cin >> n;
for(int i=1; i<=n; i++){
cin >> arr[i];
}
sort(arr+1, arr+1+n);
for(int i=2; i<=n; i++){
    if(arr[i]!=arr[i-1]){
    y++;
    }
}
cout << y << endl;
return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 160;
int mo, n, k;
int f[N * 2][N][N], o;
#define add(x, y) ((x) = ((x) + (y)) % mo)
ll solve2() {
	f[0][0][0] = 1;
	for(int i = 1; i <= n; i++) {
		for(int x = 0; x < i; x++) {
			for(int y = 0; y < i; y++) if(f[i-1][x][y]) {
				for(int o = 0; o < 2; o++) {
					int _x = x, _y = y;
					if (i & 1) {
						_x = o ? x + 1 : 0;
						if (_x * 2 > k) continue;
					} else {
						_y = o ? y + 1 : 0;
						if (_y * 2 > k) continue;
					}
					add(f[i][_x][_y], f[i - 1][x][y]);
				}
			}
		}
	}
	ll ans = 0;
	for(int i = 0; i <= n; i++) {
		for(int j = 0; j <= n; j++) add(ans, f[n][i][j]);
	}
	return ans;
}

ll solve1() {
	f[o][0][0] = 1;
	int h = (k - 1) / 2, mid = n / 2 - h, t = (n + 1) / 2 - mid;
	for(int i = 1; i <= h; i++) { //only even
		memset(f[1 - o], 0, sizeof f[1 - o]);
		for(int j = 0; j < i; j++) if (f[o][0][j])
			for(int oo = 0; oo < 2; oo++) {
				add(f[1 - o][0][oo ? j + 1 : 0], f[o][0][j]);
			}
		o = 1 - o;	
	}
	for(int i = 1; i <= mid + t; i++) { //both
		memset(f[1 - o], 0, sizeof f[1 - o]);
		for(int j = 0; j <= k + 1; j++) {
			for(int w = 0; w * 2 <= n; w++) if (f[o][j][w]) {
				for(int o1 = 0; o1 < 2; o1++) {
					for(int o2 = 0; o2 < (i > mid ? 1 : 2); o2++) {
						int _w = o2 ? w + 1 : 0;
						int _j = 0;
						if (o1 == 0) _j = 0;
						else {
							if (j) _j = j + 1;
							if (o2) _j = max(_j, _w + 1);
						}
						if (_j <= k + 1) {
							add(f[1 - o][_j][_w], f[o][j][w]);
						}
					}
				}
			}
		}
		o = 1 - o;
	}
	ll ans = 0;
	for(int i = 0; i <= k + 1; i++) {
		for(int j = 0; j <= n; j++) {
			add(ans, f[o][i][j]);
		}
	}
	return ans;
}

int main() {
	cin >> n >> k >> mo;
	if (k & 1) {
		cout << solve1() << endl;
	} else {
		cout << solve2() << endl;
	}
}


Measured memory_bytes: 7568
def main():
  import sys
 
  n,m=map(int,input().split())
  LR=tuple([list(map(int,e.split())) for e in sys.stdin])
  left,right=-1*float("inf"),float("inf")
  
  for L,R in LR:
    if right<L or R<left:
      print(0)
      break
    else:
      tmp=sorted([left,right,L,R])
      left,right=tmp[1],tmp[2]
  else:
    print(right-left+1)
  
if __name__=="__main__":
  main()

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

int main(){
  int H,W;
  cin >> H>>W;
  vector<string> fi(H);
  for (int i = 0; i < H;i++){
    cin >> fi[i];
  }

  vector<vector<int>> dist(H, vector<int>(W, -1));
  using pir=pair < int, int >;
  queue<pir> que;
  dist[0][0] = 0;
  que.push(pir(0, 0));
  int black = 0;
  for (int i = 0; i < H; i++)
  {
    for (int j = 0; j < W;j++){
      if(fi[i][j]=='#'){
        black++;
      }
    }
  }
  int dx[4] = {0, 0, 1, -1};
  int dy[4] = {1, -1, 0, 0};

  while(!que.empty()){
    auto crt = que.front();
    que.pop();
    for (int i = 0; i < 4;i++){
      int nx = crt.second + dx[i];
      int ny = crt.first + dy[i];
      if(nx<0||nx>=W||ny<0||ny>=H){
        continue;
      }
      if(dist[ny][nx]!=-1){
        continue;
      }
      if(fi[ny][nx]=='#'){
        continue;
      }
      dist[ny][nx] = dist[crt.first][crt.second] + 1;
      que.push(pir(ny, nx));
    }
  }
  if(dist[H-1][W-1]==-1){
    cout << -1 <<endl;
  }
  else
  {
    //cout << black <<endl;
    //cout << dist[H - 1][W - 1] << endl;
    int ans = H * W - black - dist[H - 1][W - 1]-1;
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
int A,B;
cin>>A>>B;
int x=A+B;
int y=A-B;
int z=A*B;
if((x>y && x>z) || (x>=y && x>z) || (x>y && x>=z) || (x==y && x==z)){cout<<x;}
else if((y>x && y>z) || (y>=x && y>z) || (y>x && y>=z)){cout<<y;}
else if((z>y && z>x) || (z>=y && z>x) || (z>y && z>=x)){cout<<z;}

return 0;
}


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

int main()
{
 int num[5];
 
 for(int i=0; i<5; i++) cin >> num[i];

 for(int i=0; i<5; i++){
  for(int j=i+1; j<5; j++){
   if(num[i] < num[j]){
    int tmp = num[i];
    num[i] = num[j];
    num[j] = tmp;
   }
  }
 }

 for(int i=0; i<5; i++){
  cout << num[i];
  if(i == 4) break;
  cout << ' ';
 }
 cout << '\n';

 return 0;
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
using namespace std;
#define MAX_N 1000100
int n,dat[2*(MAX_N)-1];

void init(int n_){
  n=1;
  while(n<n_)n*=2;
  for(int i=0;i<2*n-1;i++)dat[i]=0;
}

void update(int k,int a){
  k+=n-1;
  dat[k]=a;
  while(k>0){
    k=(k-1)/2;
    dat[k]=max(dat[k*2+1],dat[k*2+2]);
  }
}

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



int main(){
  cin>>n;
  int tn=n;
  vector<int> a(100010),b;
  for(int i=0;i<n;i++){
    cin>>a[i];
    b.push_back(a[i]);
  }
  sort(b.begin(),b.end());
  for(int i=0;i<n;i++){
    a[i]=lower_bound(b.begin(),b.end(),a[i])-b.begin();
  }
  init(n);
  for(int i=0;i<tn;i++){
    int t=query(0,a[i]);
    if(dat[a[i]+n-1]>=t+1)continue;
    update(a[i],t+1);
  }
  cout<<query(0,tn)<<endl;
}



Measured memory_bytes: 4868
#include <iostream>
#include <stdio.h>
#include <string>
#include <math.h>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cassert>
#include <utility>
#include <numeric>
#include <cstring>
#include <map>
#include <set>
#include <cmath>
#define rep(i,n) for (int i=0; i<(n); ++i)

using namespace std;
using ll = long long;

int main (){
    int N;
    cin >> N;
    vector <int> A(N);

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

    sort(A.begin(),A.end());
    bool flag=true;
    for (int i=1;i<N;i++){
        if(A[i-1]==A[i]){
            flag=false;
            break;
        }

    }

    if (flag){
        cout << "YES";
    }
    else cout << "NO";



}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file  
#include <ext/pb_ds/tree_policy.hpp>  
#include <functional> // for less  
using namespace         std;
#define                 int long long
#define                 double long double
#define                 pb push_back
#define                 mp make_pair
#define st(arr,a)       memset(arr,a,sizeof arr)
#define                 nl cout<<'\n'
#define bitcount(x)     __builtin_popcountll(x)
const int MOD = 1000000007ll;
#define forn(i,a,b)     for(int i=a;i<=b;i++)
#define rfor(i,a,b)     for(int i=a;i>=b;i--)
#define all(x)          x.begin() , x.end()
#define pi pair<int,int>
#define X first
#define Y second
#define N 1014159
#define  vi vector<int>
#define  v  vector
#define die exit(0)
#define alln(arr) arr+1 , arr+1+n
using namespace __gnu_pbds;  
typedef tree<int, null_type, less<int>, rb_tree_tag,  
            tree_order_statistics_node_update> oset; 

int n,m,k,arr[N];

void solve()
{
    cin>>k;
    int ans = 0;
    n=1;
    while(k)
    {
    	k/=2;
    	ans+=n;
    	n*=2;
    }
    cout<<ans;
}


signed main() 
{
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); 
    int t = 1;
    //cin>>t;
    forn(i,1,t)
    {
        solve();
        nl;
    }



    return 0;

}

//       clang++ c.cpp ; ./a.out < a.txt ;  

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int maxn = (int)2e5 + 1, mod = (int)1e9 + 7;
int main() {
	int T = 1;
	// scanf("%d", &T);
	for(int Case = 1; Case <= T; ++Case) {
		int n;
		scanf("%d", &n);
		static int pw[maxn];
		pw[0] = 1;
		for(int i = 1; i <= n; ++i)
			pw[i] = (pw[i - 1] << 1) % mod;
		int zero = 0;
		map<pair<LL, LL>, pair<int, int> > ctr;
		for(int i = 0; i < n; ++i) {
			LL x, y;
			scanf("%lld%lld", &x, &y);
			if(!x && !y) {
				++zero;
				continue;
			}
			LL com = __gcd(abs(x), abs(y));
			int pos = 0;
			pair<LL, LL> cur = make_pair(x / com, y / com), best = cur;
			for(int j = 1; j < 4; ++j) {
				cur = make_pair(-cur.second, cur.first);
				if(cur < best) {
					best = cur;
					pos = j;
				}
			}
			auto &cnt = ctr[best];
			if(pos & 1) {
				++cnt.first;
			} else {
				++cnt.second;
			}
		}
		int ans = 1;
		for(auto &it : ctr) {
			auto &jt = it.second;
			int u = jt.first, v = jt.second;
			ans = (LL)ans * (pw[u] + pw[v] - 1) % mod;
		}
		ans = (ans + mod - 1 + zero) % mod;
		printf("%d\n", ans);
	}
	return 0;
}

Measured memory_bytes: 16912
#include<stdio.h>
int main(){
  int a[5],k;
  for(int i = 0;i < 5;i++){
    scanf("%d",&a[i]);
  }
  scanf("%d",&k);
  if(a[4] - a[0] > k){
    printf(":(\n");
    return 0;
  }
  printf("Yay!\n");
  return 0;
}

Measured memory_bytes: 128
#include<stdio.h>
int main(void)
{
	int a,b;
	scanf("%d",&a);
	scanf("%d",&b);
	if(a<b){
		printf("a < b\n");
	}
	if(a>b){
		printf("a > b\n");
	}
	if(a==b){
		printf("a == b\n");
	}
	return 0;
}

Measured memory_bytes: 1712
#include <cstdio>
#include <cstring>
#include <iostream>
using namespace std;
int a[100000+5];
int main()
{
	int n,i,j;
	scanf("%d",&n);
	int num=0;
	int num2=0;
	for(i=0;i<n;i++)
	{
		scanf("%d",&a[i]);
		if(a[i]%4==0) num++;
		if(a[i]%2==0&&a[i]%4!=0) num2++; 
	}
	if(num>=(n/2))
	printf("Yes\n");
	else if(n-num*2-num2<=0)
	printf("Yes\n");
	else
	printf("No\n");
}

Measured memory_bytes: 640
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
using namespace std;
typedef int_fast64_t ll;

constexpr int buff_size = 1 << 21;
char buff[buff_size], *ci, ct;
int A;

inline int readint() {
    A = 0;
    while ((ct = *ci++) >= '0') A = (A << 3) + (A << 1) + ct - '0';
    return A;
}

inline ll solve() {
    fread_unlocked(buff, 1, buff_size, stdin);
    ci = buff;
    int N = readint();
    int M = 2, cnt;
    ll ans = readint() - 1;
    while(--N) {
        int A = readint();
        if(A == M) M++;
        else if(A < M) continue; 
        else {
            ans += (cnt = A / M);
            if(A == cnt * M) ans--;
        }
    }
    return ans;
}

int main() {
    printf("%lld\n", solve());
	return 0;
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep_lr(i,l,r) for(int i=(l);i<(r);i++)
#define all(x) (x).begin(),(x).end()
#define V vector
typedef V<int> vi;
typedef V<vi> vvi;
typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;
constexpr int INF = INT_MAX >> 1;
constexpr ll LINF = 5000000000000000LL;
constexpr int MOD = 1000000007;

V<char> acgt = { 'A','C','G','T' };
ll mem[110][64];

ll dp(int i, int j) {
	if (mem[i][j] != -1)return mem[i][j];
	if (i == 3) {
		//AGC ACG GAC   
		if (j == 6 || j == 9 || j == 33)mem[i][j] = 0;
		else mem[i][j] = 1;
		return mem[i][j];
	}
	ll re = 0;
	int jj = j / 4;

	rep(k, 4) {
		int ind = k * 16 + jj;
		if (j % 4 == 1) {
			if (ind % 16 == 2)continue;
			if (ind / 16 == 0 && ind % 4 == 2)continue;
			if (ind / 4 == 2)continue;
			if (jj == 8)continue;
		}
		if (j / 4 == 1 && j % 4 == 2)continue;
		re += dp(i - 1, ind);
		re %= MOD;
	}
	mem[i][j] = re;
	return re;
}


int main() {

	int n;
	cin >> n;
	ll ans = 0;
	rep(i, n + 1)rep(j, 64)mem[i][j] = -1;
	rep(i, 64) {
		ans += dp(n, i);
		ans %= MOD;
	}
	cout << ans << endl;
}

Measured memory_bytes: 3596
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
#define INF 999999999
#define rep(i,n) for(int i=0;i<n;i++)
const int MOD = 1000000007;
ll cnt =0;

int main (){
  int n;    cin >> n;
  cout << 3*n*n << endl;
}

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



int main() {
  int a,b,count;cin >> a >> b;
  count = a-b+1;
  if(a>0){
    cout << "Positive" << endl;
    return 0;
  }else if(b<0){
    if(count%2 == 0){
      cout << "Positive" << endl;
      return 0;
    }else{
      cout << "Negative" << endl;
      return 0;
    }
  }else{
    cout << "Zero" << endl;
    return 0;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long int
#define fr(i, a, b) for (ll i = a; i < b; i++)
#define pb(v, a) v.push_back(a)
#define Sort(v) sort(v.begin(), v.end())
#define For(m) for (auto it = m.begin(); it != m.end(); it++)
#define mp(p1,p2) make_pair(p1,p2)
#define sz(a) (ll)a.size()
#define mod 1000000007
#define PI 3.14159265358979323846
#define pii pair<ll ,ll>
#define ppii pair<ll,pii>
using namespace std;
#define fast                                                                   \
 ios_base::sync_with_stdio(false);                                            \
 cin.tie(NULL);                                                               \
 cout.tie(NULL);
const ll MAXN = 3000005;
const ll inf = 1e18;
int main()
{
   fast
   ll a,b;
   cin >> a >> b;
   a--;
   b--;
   ll ans = b/a;
   ans+=(b%a!=0);
   cout << ans;

   return 0;      
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
    using namespace std;
    
    int main(){
        long n , a ;
        cin >> n >> a;
        n = n % 500;
        if(n <= a){
            cout <<  "Yes"  << endl;
        }else{
            cout <<  "No"  << endl;
        }
        
        return 0;
    }

Measured memory_bytes: 256
import java.util.Scanner;
import java.util.HashMap;
import java.util.List;
import java.util.ArrayList;
import java.util.Collections;


public class Main{
  public static void main(String[] args){
	Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int  max = 1;
    HashMap<String, Integer> tm = new HashMap<String,Integer>();
    List<String>keyList =new ArrayList<String>();
     
	for(int i =0; i<N; i++){
      String s = sc.next();
        if(tm.containsKey(s) == true){
           int number = tm.get(s) + 1;  //該当キーの値を１増やす準備
           tm.replace(s, number);
           if(max < number) max = number;
        }else{
           tm.put(s, 1);
           keyList.add(s);
        }
    }
    
    Collections.sort(keyList);
    
    for(int i=0; i<keyList.size(); i++){
      String s = keyList.get(i);
      int number = tm.get(s);
      if(number == max)
        System.out.println(s);
    }
    
  }
}


Measured memory_bytes: 89560
#include "bits/stdc++.h"
#define ll long long
#define fr first
#define sc second
using namespace std;

const int mnx = 1e6 + 9;
const int mod = 1e9 + 7;

ll n, k, a[mnx], t[mnx], h;
pair <ll, ll> z[mnx];

ll get(int x){
    ll res = 0;
    for(; x > 0; x -= (x & -x)){
        res += t[x];
    }
    return res;
}

void upd(int x){
    for(; x <= n; x += (x & -x)){
        t[x]++;
    }
}

void solve(){
    cin >> n >> k;

    for(int i = 1; i <= n; i++){
        cin >> a[i];
        a[i] -= k;
    }

    ll sum = 0;

    for(int i = 1; i <= n; i++){
        sum += a[i];
        z[i] = {sum, i};
    }

    sort (z + 1, z + n + 1);

    ll ans = 0;

    for(int i = 1; i <= n; i++){
        upd(z[i].sc);
        ans += get(z[i].sc);
        if(z[i].fr < 0) ans--;
    }

    cout << ans << '\n';
}


int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
    ll tt = 1;

//    scanf("%d", &tt);

    while(tt--){
        solve();
    }

    return 0;
}


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


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<string>
#include<iomanip>
#include<sstream>
#include<map>
#include<set>
#include<cmath>
using namespace std;
template<typename A, size_t N, typename T>
void Fill(A(&array)[N], const T& val) {
	std::fill((T*)array, (T*)(array + N), val);
}
#define rep(i,n) for(int i = 0;i < n;i++)
#define req(i,n) for(int i = 1;i <=n;i++)
#define rrep(i,n) for(int i = n -1;i >= 0;i--)
#define ALL(a) a.begin(),a.end()
typedef long long ll;
typedef long double ld;
const ll INF =  1LL << 60;
const int inf = 1 << 30;
int n, m, x, y,q,d;ll z, w=0, sum = 0, ans = 0;
const int MAX = 510000;
const int MOD = 1000000007;
int main(void) {
	cin >> n;
	req(i, 9) {
		if (n % i == 0 && n / i < 10) {
			cout << "Yes" << endl;
			return 0;
		}
	}cout << "No" << endl;
}

Measured memory_bytes: 3608
#include <algorithm>
// #include <cstdlib>
#include <cstring>
#include <cstdio>
#include <string>
#include <queue>
#include <cmath>
#include <set>
#include <map>
#include <bitset>
using namespace std;
typedef long long LL;
typedef double db;
const int oo=2139063143;
const int N=22;
const int P=1000000007;
const db eps=1e-7;
#define pritnf printf
//char buf[1<<22],*p1=buf,*p2=buf,obuf[1<<22],*O=obuf;
//#define getchar() (p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<21,stdin),p1==p2)?EOF:*p1++)
template <typename T>
inline void sc (T &x)
{
    x=0; static int p; p=1; static char c; c=getchar();
    while (!isdigit(c)) { if (c=='-') p=-1; c=getchar(); }
    while ( isdigit(c)) { x=(x<<1)+(x<<3)+(c-48); c=getchar(); }
    x*=p;
}
template <typename T>
inline void print (T x)
{
    if (x< 0) putchar('-'),x=-x;
    if (x>=10) print(x/10);
    putchar(x%10+'0');
}
template <typename T>
inline void pr (T x) { print(x),putchar('\n'); }
template <typename T1,typename T2>
void chkmax (T1 &A,T2 B) { A=A>=B?A:B; }
template <typename T1,typename T2>
void chkmin (T1 &A,T2 B) { A=A<=B?A:B; }

int n,k,f[1<<N|1][N],bit[1<<N|1],nx[1<<N|1][2],mi[N];
char t[1<<N];
int main ()
{
    // freopen (".in","r",stdin);
    // freopen (".out","w",stdout);
	sc(n),sc(k);
	int S=1<<(n+1);
	for (int s=0; s<=S; s++)
	{
		if (s) bit[s]=bit[s>>1]+1;
		nx[s][0]=nx[s][1]=-1;
		for (int i=0; i< bit[s]; i++)
			nx[s][s>>i&1]=i;
	}
	mi[0]=1;
	for (int i=1; i<=n+1; i++)
		mi[i]=mi[i-1]<<1|1;
	for (int i=0; i<=n; i++)
	{
		int m=1<<i;
		scanf ("%s",t);
		if (i) for (int j=0; j< m; j++) if (t[j]=='1')
			f[m+j][1]=1;
	}

	for (int i=1; i<=n; i++)
		for (int s=1; s<=S; s++) if (f[s][i])
		{
			int len=bit[s]-i,s2=s&mi[len-1],s1=s>>len,g=f[s][i];
			if (!len) continue;
			if (len> bit[s2])
			{
				f[s][i+1]+=g;
				int p=nx[s2][1];
				if (p!=-1)
				{
					int nx=(s1<<1|1)<<p;
					if (p) nx|=s2&mi[p-1];
					f[nx][i+1]+=g;
				}
			}
			else
			{
				f[s][i+1]+=g;
				int p=nx[s2][0];
				if (p!=-1)
				{
					int nx=(s1<<1)<<p;
					if (p) nx|=s2&mi[p-1];
					f[nx][i+1]+=g;
				}
				
			}
			f[s1][i]+=g;
		}
	int ans=0;
	for (int s=1; s<=S; s++)
		if (bit[s]> bit[ans]&&f[s][bit[s]]>=k) ans=s;
	// for (int s=1; s<=S; s++)
	// {
	// 	for (int i=bit[s]-2; i>=0; i--)
	// 		putchar((s>>i&1)+'0');putchar(' ');
	// 	printf("%d %d\n",s,f[s][bit[s]]);
	// }
	for (int i=bit[ans]-2; i>=0; i--)
		putchar((ans>>i&1)+'0');

    return 0;
}


Measured memory_bytes: 212096
import java.util.*;
import java.io.*;
public class Main
{
    public static void main(String args[])throws Exception
    {
        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
        PrintWriter pw=new PrintWriter(System.out);
        int q=Integer.parseInt(br.readLine());
        String str[]=br.readLine().split(" ");
        int a=Integer.parseInt(str[0]);
        int b=Integer.parseInt(str[1]);
        if(a%q==0||b%q==0||b/q-a/q>0)
        pw.println("OK");
        else
        pw.println("NG");
        /*for(int x=0;x<q;x++)
        {
            String str[]=br.readLine().split(" ");
            int n=Integer.parseInt(str[0]);
            int m=Integer.parseInt(str[1]);
            String s=br.readLine();
        }*/
        pw.flush();
        pw.close();
    }
}

Measured memory_bytes: 32588