akhauriyash/Code-Regression huggingface dataset:
from collections import Counter
mod = 10 ** 9 + 7
n = int(input())
l = [int(i) for i in input().split()]
c = Counter(l)

if c.most_common()[0][1] > 2:
    print(0)
elif c.most_common()[-1][1] == 1 and c[0] != 1:
    print(0)
elif n % 2 == 1 and c[0] != 1:
    print(0)
else:
    print(2 ** (len(c)-1) % mod if n % 2 == 1 else 2 ** len(c) % mod)


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

inline void ioThings() {
  ios::sync_with_stdio(0);
  cin.tie(0);
#ifdef LOCAL
  freopen("io\\in.txt", "r", stdin);
  freopen("io\\out.txt", "w", stdout);
#define debug(x) cerr << #x << ": <" << (x) << ">\n"
#else
#define debug(x)
#endif
}

#define rep(i, n) for (int i = 0; i < n; i++)
#define dotc()    int tcs; if (cin >> tcs) rep(tc, tcs)
#define sz(x)     (int)x.size()
#define eb        emplace_back
#define pb        push_back
#define mp(x, y)  make_pair(x, y);
#define all(x)    x.begin(), x.end()
#define rall(x)   x.rbegin(), x.rend()
#define fi        first
#define se        second
#define mod       1000000007

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using si = set<int>;
using ii = pair<int, int>;
using vii = vector<ii>;

int main() {
  ioThings();

  string s, t;
  cin >> s >> t;
  rep(i, sz(s)) {
    if (s[i] != t[i]) {
      cout << "No";
      return 0;
    }
  }
  cout << "Yes";

  return 0;
}


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

  vector<pair<int, int> > ten;
  int m;

int gcd(int x, int y){
  if(x>y)return gcd(y, x);
  if(x==0)return y;
  return gcd(x, y%x);
}

int calc(vector<pair<int, int> > &pairs){
  map<pair<int, int>, int > katamuki;
  for(int i=0;i<m/2;i++){
    pair<int, int> pairr = make_pair(ten[pairs[i].first].first - ten[pairs[i].second].first, ten[pairs[i].first].second - ten[pairs[i].second].second  );
    if(pairr.first == 0)katamuki[make_pair(0, 1)]++;
    else{
      if(pairr.first < 0){
      pairr.first *= -1;
      pairr.second *= -1;
    }
    int fuck = gcd(pairr.first, abs(pairr.second));
      pairr.first /= fuck;
      pairr.second /= fuck;
    katamuki[pairr]++;

  }
}
int ans=0;
for(auto i:katamuki){
  ans += i.second * (i.second - 1)/2;
}
return ans;
}

int dfs(vector<pair<int, int> > &pairs , set<int> &rest){
  if(pairs.size() == m/2)return calc(pairs);
  int maxx = 0;
  int i = *rest.begin();
  rest.erase(i);
    for(auto j: rest){
      pairs.push_back(make_pair(i, j));
      set<int> rest2 = rest;
      rest2.erase(j);
      maxx=max(maxx, dfs(pairs, rest2));
      pairs.pop_back();
    }
    return maxx;
}

int main(){
  scanf("%d", &m);
  for(int i=0;i<m;i++){
    int x,y;
    scanf("%d%d", &x, &y);
    ten.push_back(make_pair(x, y));
  }
  vector<pair<int, int> > pairs;
  set<int> rst;
  for(int i=0;i<m;i++)rst.insert(i);
  int ans = dfs(pairs, rst);
  printf("%d\n", ans);

  return 0;
}



Measured memory_bytes: 3204
package main

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

func main() {
	r := bufio.NewReader(os.Stdin)

	var n int
	fmt.Fscanf(r, "%d\n", &n)

	freq := make(map[int]int64)
	a := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Fscanf(r, "%d", &a[i])
		freq[a[i]]++
	}

	tot := int64(0)
	for _, v := range freq {
		tot += v * (v - 1) / 2
	}

	w := bufio.NewWriter(os.Stdout)
	defer w.Flush()

	for i := 0; i < n; i++ {
		f, _ := freq[a[i]]
		nways := tot - (f * (f - 1) / 2) + ((f - 1) * (f - 2) / 2)
		fmt.Fprintf(w, "%d\n", nways)
	}
}


Measured memory_bytes: 14720
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
#define INF 1007654321
#define PI 3.14159265358979
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define repp(i, s, e) for(int i = (s); i <= (e); ++i)
#define sz(x) ((int)x.size())
#define all(x) x.begin(), x.end()
#define FAST_IO() ios::sync_with_stdio(0); cin.tie(0)
template<typename T>
ostream& operator<<(ostream &os, const vector<T> &v) { for (auto x : v) os << x << " "; return os << "\n"; }

const int MOD = 1e9 + 7;
const int MAXV = 1e5;

int main() {
    FAST_IO();
    int A, B, C, X, Y; cin >> A >> B >> C >> X >> Y;
    C = 2*C;
    A = min(A, C);
    B = min(B, C);
    int ans = 0;
    if(A + B <= C) {
        ans = A * X + B * Y;
    } else {
        int Z = min(X, Y);
        X -= Z;
        Y -= Z;
        ans = A * X + B * Y + C * Z;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
S = input()

min_X = 10000000000
ans = abs(min_X - 753)
for i in range(len(S) - 2):
    X = int(S[i : i+3])
    if abs(X - 753) < ans:
        min_X = X
        ans = abs(X - 753)
        
print(ans)

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

#pragma GCC optimize("O3")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

int dp[1000005];

const long long MOD = 1e9+7;

int main(){
    int N, H, D;
    scanf("%d%d%d", &N, &H, &D);

    long long retainWays = 0;
    long long fact = 1;
    for(int i = 1; i <= N; i ++){
        fact = fact*i%MOD;
        retainWays += fact;
    }
    retainWays %= MOD;

    //printf("retainWays=%lld\n", retainWays);

    dp[0] = fact;
    int slidingWindowSum = dp[0];
    for(int i = 1; i < H; i ++){
        dp[i] = slidingWindowSum*retainWays%MOD;

        slidingWindowSum += dp[i];
        if(i >= D){slidingWindowSum -= dp[i-D];}

        if(slidingWindowSum >= MOD){slidingWindowSum -= MOD;}
        else if(slidingWindowSum < 0){slidingWindowSum += MOD;}

        //printf("dp[%d]=%lld\n", i, dp[i]);
    }

    printf("%d", slidingWindowSum);
    return 0;
}


Measured memory_bytes: 4096
#include <stdio.h>

int main(){
	long int value;
    long int sum=0;
    scanf("%ld", &value);
    for(long int i=1;i<=value;i++){
    	if((i%3 != 0) && (i%5!=0)){
        	sum+=i;
        }
    }
    printf("%ld", sum);
}

Measured memory_bytes: 1736
#include <iostream>
#include <fstream>
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <iomanip>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <sstream>
#include <string>
#include <vector>
using namespace std;

#pragma comment(linker, "/STACK:400000000")

#define EPS 1e-9
#define INF MOD
#define MOD 1000000007LL
#define fir first
#define foreach(it,X) for(it=X.begin();it!=X.end();it++)
#define iss istringstream
#define ite iterator
#define ll long long
#define mp make_pair
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<n;i++)
#define pi pair<int,int>
#define pb push_back
#define sec second
#define sh(i) (1LL<<i)
#define sst stringstream
#define sz size()
#define vi vector<int>
#define vc vector
#define vl vector<ll>
#define vs vector<string>

int n,dy[]={0,1},dx[]={1,0};
string s[10];
// 0
//1 3
// 2

string rot90(string s){
    return s[3]+s.substr(0,3);
}

int enc(char c){
    if(c=='R')return 0;
    if(c=='r')return 1;
    if(c=='G')return 2;
    if(c=='g')return 3;
    if(c=='B')return 4;
    if(c=='b')return 5;
    if(c=='W')return 6;
    if(c=='w')return 7;
    cout<<"ERROR: "<<(int)c<<endl;
    assert(0);
}

#define id(y,x) ((y)*3+(x))

int f(int y,int x,int* used_,string* state_){
    if(y==3)return 1;
    if(x==3)return f(y+1,0,used_,state_);
    int used[10],res=0;
    string state[10];
    rep(i,9)used[i]=used_[i],state[i]=state_[i];
    rep(i,9)if(!used[i]){
        string t=s[i];
        rep(j,4){
            t=rot90(t);
            if(y>0){
                int a=enc(t[0]),b=enc(state[id(y-1,x)][2]);
                if((a+b)%2==0 || a/2!=b/2)continue;
            }
            if(x>0){
                int a=enc(t[1]),b=enc(state[id(y,x-1)][3]);
                if((a+b)%2==0 || a/2!=b/2)continue;
            }
            used[i]=1;
            state[id(y,x)]=t;
            res+=f(y,x+1,used,state);
            used[i]=0;
        }
    }
    return res;
}

int main(){
	cin>>n;
    rep(tc,n){
        rep(i,9)cin>>s[i];
        int used[10]={};
        string state[10];
        cout<<f(0,0,used,state)<<endl;
    }
}

Measured memory_bytes: 928
def main():
    H, W = map(int, raw_input().split())
    a = []
    result = []
    for i in range(H):
        a.append(map(int, raw_input().split()))
    # print a
    for i in range(H):
        for j in range(W):
            if a[i][j] %2 == 0:
                continue
            else:
                # if you can move a coin to the right, do so
                if j + 1 < W:
                    result.append([i+1,j+1,i+1,j+2])
                    a[i][j] = a[i][j]-1
                    a[i][j+1] = a[i][j+1]+1
                # if you are the right edge and you can move a coin to the bottom, do so
                elif j+1 == W and i+1 < H:
                    result.append([i+1,j+1,i+2,j+1])
                    a[i][j] = a[i][j]-1
                    a[i+1][j] = a[i+1][j]+1
                # else:
                    # print('mo')
                    # print(i+1)
                    # print(j+1)
    print(len(result))
    for i in range(len(result)):
        for j in range(len(result[i])):
            if j == len(result[i]) - 1:
                print(result[i][j])
            else:
                print(result[i][j]),

if __name__ == '__main__':
    main()


Measured memory_bytes: 33912
x,y=map(int,input().split(" "))
if(((y-2*x)%2)==0):
    if(((y-2*x)//2)>=0):
        if(((y-2*x)//2)<=x):
            print("Yes")
        else:
            print("No")
    else:
        print("No")
else:
    print("No") 

Measured memory_bytes: 9184
#include <iostream>      // cout, endl, cin
#include <string>        // string, to_string, stoi
#include <vector>        // vector
#include <algorithm>     // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility>       // pair, make_pair
#include <tuple>         // tuple, make_tuple
#include <cstdint>       // int64_t, int*_t
#include <cstdio>        // printf
#include <map>           // map
#include <queue>         // queue, priority_queue
#include <set>           // set
#include <stack>         // stack
#include <deque>         // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset>        // bitset
#include <cctype>        // isupper, islower, isdigit, toupper, tolower
#include <cmath>

using namespace std;
typedef long long ll;

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
#define all(a) (a).begin(), (a).end()

int main()
{
        int N, A, B, ans = 0;
        cin >> N;
        int cnt = 0, tmp = N;
        while (N > 0)
        {
                cnt += N % 10;
                N /= 10;
        }
        if (tmp % cnt == 0)
                puts("Yes");
        else
        {
                puts("No");
        }

        return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner scan = new Scanner(System.in);
    String str_scan = scan.nextLine();
    // int型へ変換
    var N = Integer.parseInt(str_scan);

    String str_scan2 = scan.nextLine();
    // スペース区切りで分ける
    var str = str_scan2.split(" ");

    int L[] = new int[N];
    int ans = 0;

    for (var x = 0; x < N;x++){
      L[x] = Integer.parseInt(str[x]);
    }

    for (var i = 0;i < N-2;i++){
      for (var j = i+1; j < N-1;j++){
        for (var k = j+1; k < N;k++){
          if((L[i] == L[j]) || (L[j] == L[k]) || (L[i] == L[k])){

          }else if ((L[i] < L[j] + L[k]) && (L[j] < L[i] + L[k]) && (L[k] < L[i] + L[j])){
            ans++;
          }
        }
      }
    }

    System.out.println(ans);
    scan.close();
  }
}

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

int n, m;
ll a[101010];

int main()
{
  cin >> n >> m;
  cin >> a[0];
  int cnt1 = 0;
  while(a[0] % 2 == 0)
  {
    cnt1++;
    a[0] /= 2;
  }
  rep(i, n - 1)
  {
    cin >> a[i + 1];
    int cnt2 = 0;
    while(a[i + 1] % 2 == 0)
    {
      cnt2++;
      a[i + 1] /= 2;
    }
    if(cnt1 != cnt2)
    {
      cout << "0" << endl;
      return 0;
    }
  }
  
  ll s = 1;
  while(--cnt1)
  {
    s *= 2;
  }
  
  map<ll, int> scm;
  rep(i, n)
  {
    s = (s / __gcd(s, a[i])) * a[i];
    if(s > m)
    {
      cout << "0" << endl;
      return 0;
    }
  }
  
  cout << ((m / s) + 1) / 2 << endl;
  
  return 0;
}

Measured memory_bytes: 1024
#include <stdio.h>
#include <stdint.h>
#include <inttypes.h>
#include <math.h>

int main(int argc, char *argv[])
{
    int64_t a;
    _Float128 b;
    {
        // 手動で読み込む
        int d1, d2;
        scanf("%" SCNd64 " %d.%d", &a, &d1, &d2);
        int d = d1 * 100 + d2;
        b = (_Float128)d / 100.0F128;
    }
    printf("%" PRIi64 "\n", (int64_t)((_Float128)a * b));
}


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

// coins.cpp
// author: Seong Yong-ju ( @sei40kr )
// Copyright (c) 2018 Seong Yong-ju

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

using namespace std;

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

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

  int ans = 0;
  REP(i, a + 1) {
    REP(j, b + 1) {
      REP(k, c + 1) { ans += 500 * i + 100 * j + 50 * k == x ? 1 : 0; }
    }
  }

  cout << ans << endl;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000

int sum[100020][31];

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, C;
    cin >> N >> C;
    rep(i, N) {
        int s, t, c;
        cin >> s >> t >> c;
        s--; t--; c--;
        sum[s][c]++;
        sum[t + 1][c]--;
    }
    rep(i, 30) {
        rep(j, 100010) {
            sum[j + 1][i] += sum[j][i];
        }
    }
    int ans = 0;
    rep(i, 100010) {
        int tmp = 0;
        rep(j, C) {
            tmp += min(1, sum[i][j]);
        }
        ans = max(ans, tmp);
    }
    cout << ans << endl;

    return 0;
}


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

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<=(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define Eunique(v) v.erase(unique(all(v)),v.end())
#define Eback(s) s.erase(s.end()-1,s.end())
#define rev(v) reverse(all(v))
#define minvec(v) *min_element(all(v))
#define maxvec(v) *max_element(all(v))
#define pb push_back
#define pf push_front
#define mod 1000000007
#define m_p make_pair
#define DOUBLE fixed << setprecision(15)
#define OK puts("OK")
#define OK1 puts("OK1")
#define OK2 puts("OK2")
#define SIZE(s) (int)s.size()
#define INF ((1LL<<62)-(1LL<<31))
#define zero(x,n) setw(x) << setfill('0') << n

typedef long long ll;

typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<double> vd;
typedef vector<char> vc;
typedef vector<string> vs;

typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
typedef vector<pair<int,int>> vpii;
typedef vector<pair<ll,ll>> vpll;

const double pi = acos(-1.0);

template<class A, class B>
ostream& operator<<(ostream& ost, const pair<A, B>&p) {
	ost << "{" << p.first << ", " << p.second << "} ";
	return ost;
}

template<class T>
ostream& operator<<(ostream& ost, const vector<T>&v) {
	ost << "{";
	for (int i = 0; i<(int)v.size(); i++) {
		if (i)ost << " ";
		ost << v[i];
	}
	ost << "} \n";
	return ost;
}

template<class A, class B>
ostream& operator<<(ostream& ost, const map<A, B>&v) {
	ost << "{";
	for (auto p:v) {
		ost << "{" << p.first << ", " << p.second << "} ";
	}
	ost << "} ";
	return ost;
}

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 gcd(ll x, ll y) {return __gcd(x,y);}
ll lcm(ll x, ll y) {return x/__gcd(x,y)*y;}

int main()
{
	ll a,b,c,k;
	cin >> a >> b >> c >> k;
	cout << (k%2?b-a:a-b) << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key
#define INF 1e18

typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<int> vi;
typedef vector < pair<int, int> > vii;
typedef long double ld;
typedef tree<pair<int,int>, null_type, less<pair<int,int> >, rb_tree_tag, tree_order_statistics_node_update> pbds;
typedef set<int>::iterator sit;
typedef map<int,int>::iterator mit;
typedef vector<int>::iterator vit;

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll n, t1, x1, y1;
	ll t=0, x=0, y=0;
	cin >> n;
	for(int i = 0; i < n; i++){
		cin >> t1 >> x1 >> y1;
		if(abs(t1-t)<abs(x1-x)+abs(y1-y) || abs(t1-t)%2!=(abs(x1-x)+abs(y1-y))%2){
			cout << "No";
			return 0;
		}
		t=t1;
		x=x1;
		y=y1;
	}
	cout << "Yes";
	return 0;
}


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

typedef long long lint;
typedef long double ldouble;
#define REP(i, x, n) for(int i = x ; i < n ; i++)
#define rep(i, n) REP(i, 0, n)
#define repr(i, n) for(int i = n - 1 ; i >= 0 ; i--)
#define SORT(c) sort((c).begin(), (c).end())

const int IINF = 1e9 + 10;
const lint LLINF = 1e18;
const lint MOD = 1e9 + 7;
const lint inv = MOD - 2;

int main(){
    lint n, m;
    cin >> n >> m;
    lint ans = (1900 * m + 100 * (n - m)) * pow(2, m);
    cout << ans << endl;
    return 0;
}

// 問題の答えをans, 1回の実行にかかる時間をt, ACの確率をpとする
// ans = t + (1 - p) * ans
// p * ans = t
// ans = t / p

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	int ans=0;
	string s;
	cin>>s;
	int l=s.size();
	for(int i=1;i<l;i++){
		if((s[i-1]=='W'&&s[i]=='B') || (s[i-1]=='B'&&s[i]=='W')) ans++;
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define oo 0x3f3f3f3f

int main()
{
    ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int n;
    cin>>n;
    multiset<ll>A[4];
    vector<array<int,2>>points;
    for(int i=0; i<n; i++)
    {
        int x,y;
        cin>>x>>y;
        points.push_back({x,y});
        A[0].insert({x+y});
        A[1].insert({-x+y});
        A[2].insert({x-y});
        A[3].insert({-x-y});
    }

    ll res = 0;
    for(auto&p : points)
    {
        int x = p[0];
        int y = p[1];
        A[0].erase(A[0].find(x+y));
        A[1].erase(A[1].find(-x+y));
        A[2].erase(A[2].find(x-y));
        A[3].erase(A[3].find(-x-y));

        res = max(res, x+y + *A[3].rbegin());
        res = max(res, -x+y + *A[2].rbegin());
        res = max(res, x-y + *A[1].rbegin());
        res = max(res, -x-y + *A[0].rbegin());

        A[0].insert({x+y});
        A[1].insert({-x+y});
        A[2].insert({x-y});
        A[3].insert({-x-y});
    }

    cout<<res;
}


Measured memory_bytes: 42448
#include <algorithm>
#include <iostream>
#include <queue>
using namespace std;
static const int MAX = 10000;
static const int INFTY = (1 << 20);
static const int WHITE = 0;
static const int GRAY = 1;
static const int BLACK = 2;

int n;
vector<pair<int, int> > adj[MAX]; // 重み付き有向グラフの隣接リスト表現(重み，位置)
void dijkstra()
{
    priority_queue<pair<int, int> > PQ; // 優先度付きキューPQを設定
    int color[MAX]; // 訪問状態
    int d[MAX]; // 最短コストを初期化
    for (int i = 0; i < n; i++) {
        d[i] = INFTY; // 最短コストを初期化
        color[i] = WHITE; // 訪問状態を初期化
    }
    // 始点の最短コスト，訪問状態
    d[0] = 0;
    PQ.push(make_pair(0, 0));
    color[0] = GRAY;

    while (!PQ.empty()) {
        pair<int, int> f = PQ.top();
        PQ.pop();
        int u = f.second; // 現在の位置にPQの先頭の位置を代入

        color[u] = BLACK; // uは訪問完了に

        //最小値を取り出し，それが最短でなければ無視
        if (d[u] < f.first * (-1)) {
            continue;
        }

        for (int j = 0; j < adj[u].size(); j++) {
            int v = adj[u][j].first; // vはu->jの重み
            if (d[v] > d[u] + adj[u][j].second) { // vまでの重さと，uまでの重さとu->jの重さを比べる
                d[v] = d[u] + adj[u][j].second;
                // priority_queueはデフォルトで大きい値を優先するため-1をかける
                PQ.push(make_pair(d[v] * (-1), v));
                color[v] = GRAY;
            }
        }
    }

    for (int i = 0; i < n; i++) {
        cout << i << " " << (d[i] == INFTY ? -1 : d[i]) << endl;
    }
}
int main()
{
    int k, u, v, c;

    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> u >> k;
        for (int j = 0; j < k; j++) {
            cin >> v >> c;
            adj[u].push_back(make_pair(v, c));
        }
    }

    dijkstra();

    return 0;
}


Measured memory_bytes: 8068
#include <bits/stdc++.h>
#define rep(i,n) for (int i = (0); i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(x) (x).begin(),(x).end()
#define rrng(x) (x).rbegin(),(x).rend()
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define show(x) cout << #x << " = " << (x) << endl
#define show2(x,y) cout << #x << " = " << (x) << ", " << #y << " = " << (y) << endl
#define show3(x,y,z) cout << #x << " = " << (x) << ", " << #y << " = " << (y) <<  ", " << #z << " = " << (z) << endl
#define showv(v) rep(i,v.size()) printf("%d%c", v[i], i==v.size()-1?'\n':' ')
#define showv2(v) rep(j,v.size()) showv(v[j])
#define showt(t,n) rep(i,n) printf("%d%c", t[i], i==n-1?'\n':' ')
#define showt2(t,r,c) rep(j,r) showt(t[j],c)
#define showvp(p) rep(i,p.size()) printf("%d %d\n", p[i].first, p[i].second);
#define printv(v) rep(i,v.size()) printf("%d\n", v[i])
#define printt(t,n) rep(i,n) printf("%d\n", t[i])
#define incl(v,x) find(rng(v),x)!=v.end()
#define incls(s,c) s.find(c)!=string::npos
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define bit(n,k) ((n>>k)&1) // nのk bit目
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define uni(x) x.erase(unique(rng(x)),x.end())
#define SP << " " <<
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vs = vector<string>;
using P = pair<int, int>;
using T = tuple<int, int, int>;
using vp = vector<P>;
using vt = vector<T>;
const int mod = 1000000007;
const double EPS = 1e-9;
const int INF = (1<<30)-1;
const ll INFLL = (1LL<<62)-1;
#define dame { puts("No"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
inline int in() { int x; scanf("%d",&x); return x;}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
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 main () {
  int n;
  cin >> n;
  string s;
  cin >> s;

  int need_left = 0;
  int pointer = 0;
  rep(i,n) {
    if (s[i] == '(') ++pointer;
    else {
      if (pointer == 0) ++need_left;
      else --pointer;
    }
  }
  int need_right = pointer;

  string ans = string(need_left,'(') + s + string(need_right,')');
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
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; }
 
/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
    sizeは(int)とキャストしよう
    ごちゃごちゃ場合分けを考える前に全探索は考えましたか？
*/

int main(){
    string a, b; cin >> a >> b;
    
    if(a.size() > b.size()) cout << "GREATER" << endl;
    else if(a.size() < b.size()) cout << "LESS" << endl;
    else if(a < b) cout << "LESS" << endl;
    else if(a > b) cout << "GREATER" << endl;
    else cout << "EQUAL" << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    
    string S;
    cin >> S;
    
    if(S[0] == 'S') cout << "Cloudy" << endl;
    if(S[0] == 'R') cout << "Sunny" << endl;
    if(S[0] == 'C') cout << "Rainy" << endl;
    
    
}


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


int main(){
    int n,q; cin >> n >> q;
    string S; cin >> S;
    vector<char> s(n);
    vector<int> num(n+10);
    for(int i=0;i<n;i++){
        s[i] = S[i];
    }


    for(int i=0;i<n-1;i++){
        if(s[i] == 'A' && s[i+1] == 'C'){
            num[i]++;
        }
    }
    for(int i=0;i<n-1;i++){
        num[i] += num[i-1];
    }
	int ans;
    for(int i=0;i<q;i++){
        int l,r; 
        cin >> l >> r;
        l-=2; r-=2;
        ans = num[r] - num[l] ;
      cout << ans << endl;
      }
}

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

typedef long long int ll;

using namespace std;

void SieveOfEratosthenes(int n,vector <int> &primes) 
{ 
    // Create a boolean array "prime[0..n]" and initialize 
    // all entries it as true. A value in prime[i] will 
    // finally be false if i is Not a prime, else true. 
    bool prime[n+1]; 
    memset(prime, true, sizeof(prime)); 
  
    for (int p=2; p*p<=n; p++) 
    { 
        // If prime[p] is not changed, then it is a prime 
        if (prime[p] == true) 
        { 
            // Update all multiples of p greater than or  
            // equal to the square of it 
            // numbers which are multiple of p and are 
            // less than p^2 are already been marked.  
            for (int i=p*p; i<=n; i += p) 
                prime[i] = false; 
        } 
    } 
  
    // Print all prime numbers 
    for (int p=2; p<=n; p++) 
       if (prime[p]) 
          primes.push_back(p);
} 

ll max(ll a,ll b)
{
	if(a>b)
		return a;
	return b;
}

ll power(ll x, ll y,ll mod) 
{ 
    ll temp; 
    if( y == 0) 
        return 1; 
    temp = power(x, y/2,mod); 
    if (y%2 == 0) 
        return (temp*temp)%mod; 
    else
        return (((x*temp)%mod)*temp)%mod; 
} 

void find(vector <int> &a,ll n,int size,int i,int cur,int d,bool *flag)
{
    double y=(d/cur);
        ll temp=cur-1+ceil(y);
        if(temp<=n)
            *flag=1;
    while(i<size)
    {
        
        //cur*=a[i];
        find(a,n,size,i+1,cur*a[i],d,flag);
        //cur/=a[i];
        i++;
    }
}

int main()
{
    
   
    int n,m;
    cin>>n>>m;
    if(n==m)
        cout<<"Yes\n";
    else
        cout<<"No\n";


	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define sz(x) (int)x.size()
#define int long long
typedef pair<int,int>pii;
typedef vector<int> vi;
typedef vector<vi> vii;
const int mxN=2e5+5;
//did u check when n=1?
//is mxN correct?
int n,M,pai[mxN],dp[mxN],ans[mxN],aux[mxN];
int pref[mxN],suf[mxN];
int mod(int a){int ret=a%M;if(ret<0)ret+=M;return ret;}
vi adj[mxN];
void solve(int i,int p=-1){
    //calcula pra cada subarvore
    int ans=1;
    for(int j:adj[i])if(j!=p){
        solve(j,i);
        ans=mod(ans*dp[j]);
    }
    dp[i]=mod(ans+1);
}
void dfs(int i,int p=-1){
    if(i==0){
        ans[i]=mod(dp[i]-1);
        pref[0]=1;
        suf[sz(adj[i])]=1;
        for(int k=0;k<sz(adj[i]);k++){
            int j=adj[i][k];
            pref[k+1]=mod(pref[k]*dp[j]);
        }
        for(int k=sz(adj[i])-1;k>=0;k--){
            int j=adj[i][k];
            suf[k]=mod(suf[k+1]*dp[j]);
        }
        for(int k=0;k<sz(adj[i]);k++){
            int j=adj[i][k];
            ans[j]=mod(pref[k]*suf[k+1]);
        }
    }
    else{
        ans[i]=mod(ans[i]+1);
        int r=ans[i];
        pref[0]=1;
        suf[sz(adj[i])]=1;
        for(int k=0;k<sz(adj[i]);k++){
            int j=adj[i][k];
            pref[k+1]=pref[k];
            if(j==p)continue;
            ans[i]=mod(ans[i]*dp[j]);
            pref[k+1]=mod(pref[k]*dp[j]);
        }
        for(int k=sz(adj[i])-1;k>=0;k--){
            int j=adj[i][k];
            suf[k]=suf[k+1];
            if(j==p)continue;
            suf[k]=mod(suf[k+1]*dp[j]);
        }
        for(int k=0;k<sz(adj[i]);k++){
            int j=adj[i][k];
            if(j==p)continue;
            ans[j]=mod(pref[k]*suf[k+1]);
            ans[j]=mod(ans[j]*r);
        }
        

    }
    for(int j:adj[i]){
        if(j==p)continue;
        dfs(j,i);
    }

}
int32_t main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cin>>n>>M;
    for(int i=0;i<n-1;i++){
        int a,b;cin>>a>>b;a--;b--;
        adj[a].pb(b);
        adj[b].pb(a);
    }
    solve(0);
    dfs(0);
    for(int i=0;i<n;i++)cout<<mod(ans[i])<<"\n";
}

Measured memory_bytes: 18732
n = input()
ns = [int(i) for i in n]
for i in range(-1,2,2):
    for j in range(-1,2,2):
        for k in range(-1,2,2):
            if(ns[0]+i*ns[1]+j*ns[2]+k*ns[3]==7):
                ans = str(ns[0])
                if(i == -1):
                    ans += '-'
                else:
                    ans += '+'
                ans += str(ns[1])
                if(j == -1):
                    ans += '-'
                else:
                    ans += '+'
                ans += str(ns[2])
                if(k == -1):
                    ans += '-'
                else:
                    ans += '+'
                ans += str(ns[3])
                print(ans + '=7')
                exit()


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
 
typedef pair<ll,ll> pairs;
vector<pairs> p;
bool pairCompare(const pair<double,ll>& firstElof, const pair<double,ll>& secondElof){
    return firstElof.first < secondElof.first;
}
#define MAX_N 1000100
bool x[MAX_N];
ll num[MAX_N];
ll fibl[MAX_N]={0};
 
ll fib(ll a){
    if (fibl[a]!=0)return fibl[a];
    if (a==0){
        return 0;
    }else if (a==1){
        return 1;
    }
    return fibl[a]=fib(a-1)+fib(a-2);
}
 
ll eratosthenes(ll n) {
    int p = 0;
    for (ll i=0; i<=n; ++i) x[i] = true;
    x[0] = x[1] = false;
    for(int i=2; i<=n; ++i) {
        if(x[i]) {
            p++;
            for(int j=2*i; j<=n; j+=i) x[j] = false;
        }
        
        num[i] = p;
    }
    return p;
}
 
ll gcd(ll a,ll b){
    if (a%b==0)return(b);
    else return(gcd(b,a%b));
}
 
ll keta(ll N){
    int tmp{};
    while( N > 0 ){
        tmp += ( N % 10 );
        N /= 10;
    }
    N = tmp;
    return N;
}

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



Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <algorithm>
#include <numeric>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <map>
#include <set>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000
#define sz(x) ((int)(x).size())
#define fi first
#define sec second
#define SORT(x) sort((x).begin(),(x).end())
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define repn(i,a,n) for(int (i)=(a);(i)<(int)(n);(i)++)
#define EQ(a,b) (abs((a)-(b))<eps)
#define MOD 1000000007
ll dp[300][300];
int n;
char c[300];
int main()
{
    scanf("%d",&n);
    for(int i=0;i<n;i++)cin >> c[i];
    dp[0][0]=1ll;
    for(int i=0;i<n;i++)
    {
        if(c[i]=='-')for(int j=0;j<=n;j++)dp[i+1][j]=dp[i][j];
        if(c[i]=='D')
        {
            for(int j=0;j<=i;j++)
            {
                if(j>0)dp[i+1][j-1] = (dp[i+1][j-1]+(((dp[i][j]*j)%MOD)*j%MOD))%MOD;
                dp[i+1][j] = (dp[i+1][j]+((dp[i][j]*j)%MOD))%MOD;
            }
        }
        if(c[i]=='U')
        {
            for(int j=0;j<=i;j++)
            {
                dp[i+1][j+1] = (dp[i+1][j+1]+dp[i][j])%MOD;
                dp[i+1][j] = (dp[i+1][j]+((dp[i][j]*j)%MOD))%MOD;
            }
        }
    }
    printf("%lld\n",dp[n][0]);
    return 0;
}

Measured memory_bytes: 3648
//hinagata.cpp
//作成日
//更新日
//目的
//手段
/*includes*/
#include <bits/stdc++.h>
/*namespace*/
using namespace std;
using ll= long long;
/*define macro*/
#define REP(i,n) for(ll i=0;i<(n);i++)
#define REPi(i,a,b) for(ll i=(a);i<(b);i++)
#define REPRi(i,a,b) for(ll i=(a);i>(b);i--)
#define ALL(x) (x).begin(),(x).end()

int main(){
    ll H;
    cin>>H;
    //inputend
    ll kaime=1;
    ll sum_att=0;
    while(1){
        if(H==1){
            cout<<sum_att+ll(pow(2,kaime-1))<<endl;
            return 0;
        }else{
            H=(H-H%2)/2;
            sum_att+=ll(pow(2,kaime-1));
            kaime+=1;
        }
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#define rep(i, n) for(int i=0; i<n; i++)

using namespace std;

int main(){
  int R, G, B, N;
  cin >> R >> G >> B >> N;
  //入力終了

  int ans = 0;
  rep(r, N+1){
    rep(g, N/G+1){
      // Rr+Gg+Bb=N より
      // (N-Rr-Gg)/B = b
      //が自然数となればよい
      double tmp = (double)(N - R*r - G*g)/B;

      //割り切れるという条件
      if(tmp == (int)tmp ){
	//さらに，自然数という条件
	if(tmp >= 0)
	  ans++;
      }
    }
  }

  //解答
  cout << ans << endl;
  
  return 0;
}


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

long long N, A[21][21], dp[1 << 21], mod = 1000000007;

int main() {
	cin >> N;
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < N; j++) cin >> A[i][j];
	}
	dp[0] = 1;
	for (int i = 0; i < (1 << N); i++) {
		if (dp[i] == 0) continue;
		int cnt = 0;
		for (int j = 0; j < N; j++) { if ((i&(1 << j)) != 0) cnt++; }

		for (int j = 0; j < N; j++) {
			if ((i&(1 << j)) != 0) continue;
			if (A[cnt][j] == 1) {
				dp[i + (1 << j)] += dp[i];
				if (dp[i + (1 << j)] >= mod) dp[i + (1 << j)] -= mod;
			}
		}
	}
	cout << dp[(1 << N) - 1] << endl;
	return 0;
}

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

int main(){
    int n, m;
    cin >> n >> m;
    vector<int> H(n);
    vector<int> good_tenbo;

    for (int i = 0; i < n; i++){
        cin >> H.at(i);
        good_tenbo.push_back(0);
    }
    for (int i = 0; i < m; i++){
        int a, b;
        cin >> a >> b;
        good_tenbo.at(a-1) = max(good_tenbo.at(a-1), H.at(b-1));
        good_tenbo.at(b-1) = max(good_tenbo.at(b-1), H.at(a-1));
    }
    int ans = 0;
    for (int i = 0; i < n; i++){
        ans += H.at(i) > good_tenbo.at(i);
    }
    cout << ans << endl;
    return 0;   
}

Measured memory_bytes: 4324
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
int main()
{
    int A, B;
    cin >> A >> B;
    int h, w;
    int G[100][100] = {};
    h = 100;
    w = 100;
    cout << h << ' ' << w << endl;
    for (int i = 0; i < 50; i++)
    {
        for (int j = 0; j < 100; j++)
        {
            G[i][j] = 1;
        }
    }
    for (int i = 1; i < 24; i++)
    {
        for (int j = 1; j < 49; j++)
        {
            if (A > 1)
            {
                if (i % 2 == 0)
                    G[i * 2][j * 2] = 0;
                else
                    G[i * 2][j * 2] = 0;
                A--;
            }
        }
    }
    for (int i = 26; i < 49; i++)
    {
        for (int j = 1; j < 49; j++)
        {
            if (B > 1)
            {
                if (i % 2 == 0)
                    G[i * 2][j * 2] = 1;
                else
                    G[i * 2][j * 2] = 1;
                B--;
            }
        }
    }
    for (int i = 0; i < h; i++)
    {
        for (int j = 0; j < w; j++)
        {
            if (G[i][j] == 1)
            {
                cout << "#" << flush;
            }
            else
            {
                cout << "." << flush;
            }
        }
        cout << endl;
    }
    cin >> A;
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#include <time.h>
#include <stack>
#include <array>
#define popcount __builtin_popcount
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;

int main()
{
	int n;
	cin>>n;
	int x[101];
	for(int i=0; i<n; i++) cin>>x[i];
	int ans=1e9;
	for(int p=0; p<=100; p++){
		int s=0;
		for(int j=0; j<n; j++){
			s+=(x[j]-p)*(x[j]-p);
		}
		ans=min(ans, s);
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		Scanner cin = new Scanner(System.in);
		while(true){
			int N = cin.nextInt();
			if(N==0){
				break;
			}
			int[] b = new int[N];
			for(int i = 0; i < N;i++){
				b[i]=cin.nextInt();
			}
			Arrays.sort(b);
			long[] sum = new long[N-1];
			long sumsum=0;
			for(int i = 0; i < N-1;i++){
				if(i==0){
					sum[i]=b[i];
				}
				else{
					sum[i]=sum[i-1]+b[i];
				}
				sumsum+=sum[i];
			}
			System.out.println(sumsum);
		}
	}
}

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

Measured memory_bytes: 600
using System;
using System.Collections.Generic;

namespace test
{
    class MainClass
    {
        public static void Main(string[] args)
        {

            //問題167
            string[] line = Console.ReadLine().Split(' ');

            int A = int.Parse(line[0]);
            int B = int.Parse(line[1]);
            int C = int.Parse(line[2]);
            int K = int.Parse(line[3]);


            int ans = 0;
            //for (int i = 0; i < K; i++)
            //{
            //    if (A > 0)
            //    {
            //        ans += 1;
            //        A--;
            //    }
            //    else if (B > 0)
            //    {
            //        B--;
            //    }
            //    else
            //    {
            //        ans--;
            //        C--;
            //    }
            //}

            if (A - K >= 0)
            {
                ans += K;
            }
            else
            {
                ans += A;
                if (A + B - K >= 0)
                {
                    
                }
                else
                {
                    ans -= K - A - B;
                }

            }

            Console.WriteLine(ans);
        }


    }
}


Measured memory_bytes: 27340
#include <math.h>
#include <stdlib.h>
#include <algorithm>
#include <array>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;

#define rep(i, n) for (int i = 0; i < (n); i++)
#define loop(i, a, n) for (int i = a; i < (n); i++)
#define all(in) in.begin(), in.end()
const int INF = 1e9;
const int MOD = 1e9 + 7;
int main() {
    int N, M;
    cin >> N >> M;
    string A[N], B[M];
    rep(i, N) cin >> A[i];
    rep(i, M) cin >> B[i];
    bool exist = false;
    rep(iy, N) {
        rep(ix, N) {
            if (ix + M - 1 >= N || iy + M - 1 >= N) continue;
            bool match = true;
            rep(ky, M) {
                rep(kx, M) {
                    if (A[ky + iy][kx + ix] != B[kx][ky]) match = false;
                }
            }
            if (match) exist = true;
        }
    }
    if (exist) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}

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

int main(void) {
	int a, b;
	string ans;

	cin >> a >> b;
	if (b < 0) {
		if ((b - a) % 2 == 0)
			ans = "Negative";
		else
			ans = "Positive";
	}
	else if (a <= 0 && b >= 0)
		ans = "Zero";
	else
		ans = "Positive";

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


Measured memory_bytes: 256
from collections import Counter
from string import ascii_lowercase

n = int(input())
sss = [input() for _ in range(n)]
flags = {c: 1 << (ord(c) - 97) for c in ascii_lowercase}

trie_chr = [-1]
trie_children = [{}]
trie_counter = [0]
trie_fin = [0]
l = 1

for s in sss:
    node = 0
    trie_counter[node] += 1
    for i in range(len(s) - 1, 0, -1):
        c = ord(s[i]) - 97
        if c in trie_children[node]:
            node = trie_children[node][c]
            trie_counter[node] += 1
        else:
            trie_chr.append(c)
            trie_children.append({})
            trie_fin.append(0)
            trie_children[node][c] = l
            trie_counter.append(1)
            node = l
            l += 1
    trie_fin[node] |= flags[s[0]]

ans = 0

for s in sss:
    cnt = Counter(s)
    flag = 0
    for c in cnt:
        flag |= flags[c]
    node = 0
    if len(s) > 1 and trie_fin[node] > 0:
        ans += bin(trie_fin[node] & flag).count('1')

    for i in range(len(s) - 1, 1, -1):
        c = s[i]
        cnt[c] -= 1
        if cnt[c] == 0:
            flag ^= flags[c]
        k = ord(c) - 97
        node = trie_children[node][k]
        if trie_counter[node] == 1:
            break
        if trie_fin[node] > 0:
            ans += bin(trie_fin[node] & flag).count('1')

print(ans)


Measured memory_bytes: 310404
/*
#include<iostream>
using namespace std;

int A[100005];

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

int main() {
    int n;
    cin >> n;
    for (int i=0; i<n; i++) cin >> A[i];
    int idx = partition(0, n-1);
    for (int i=0; i<n; i++) {
        if (i == idx) cout << "[";
        cout << A[i];
        if (i == idx) cout << "]";
        cout << (i != n-1 ? " " : "\n");
    }
}
*/

#include<stdio.h>
#define MAX 100000

int A[MAX], n;

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

int main() {
    int i, q;

    scanf("%d", &n);
    for (i = 0; i < n; i++) scanf("%d", &A[i]);

    q = partition(0, n - 1);

    for (i = 0; i < n; i++) {
        if (i) printf(" ");
        if (i == q) printf("[");
        printf("%d", A[i]);
        if (i == q) printf("]");
    }
    printf("\n");

    return 0;
}


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

#define rep(i,n) for(ll i=0;i<n;++i)
#define all_map(itr,mp) for(auto itr=mp.begin();itr!=mp.end();itr++)
#define ALL(a) (a).begin(),(a).end()

using namespace std;
using ll  = long long;
using pll = pair<ll, ll>;

const ll MOD  = 1e9+7;
const ll LINF = 1LL << 60;
const int INF = 1e9 + 7;

//組み合わせの計算
const ll MAX = 510000;
ll fac[MAX], finv[MAX], inv[MAX];
//初期化
void COMinit() {
    fac[0]  = fac[1]  = 1;
    finv[0] = finv[1] = 1;
    inv[1]  = 1;

    for(int i = 2; i < MAX; ++i){
        fac[i]  = fac[i - 1] * i % MOD;
        inv[i]  = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
//nCk
ll COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;

    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main(){
    string s;
    int n, k;

    cin >> s >> k;
    n = s.size();

    //dp[i][j][l] :上からi桁めでj個０でない桁がある個数(l=0 ちょうどn l=1 nより小さい)
    ll dp[120][5][2] = {};
    dp[0][0][0] = 1;

    rep(i, n){
        rep(j, k+1){
            //前の桁の引継ぎ
            dp[i+1][j][1] += dp[i][j][1];
            //既にnより小さいなら１〜９まで全て選べる
            dp[i+1][j+1][1] += dp[i][j][1]*9;
            //制約ちょうどの場合
            if(s[i] != '0'){
                //現在の桁を０にすればそのまま
                dp[i+1][j][1] += dp[i][j][0];
                //i桁の数-1個使うなら次の桁からnより小さくできる
                dp[i+1][j+1][1] += dp[i][j][0]*(s[i]-'1');
                //ギリギリで攻めて行く
                dp[i+1][j+1][0] += dp[i][j][0];
            } 
            else {
                dp[i+1][j][0] += dp[i][j][0];
            }
        }
    }

    cout << dp[n][k][0] + dp[n][k][1] << endl;
}

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

int main(){
    long long a,b,c;
    cin >> a >> b >> c;

    if(c-a-b>0){
        if(2*(a*c+b*c+a*b)<a*a+b*b+c*c){
            cout << "Yes" << endl;
        }else{
            cout << "No" << endl;
        }
    }else{
        cout << "No" << endl;
    }
    
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
int main()
{
    int a,b,x;
    while(~scanf("%d %d %d",&a,&b,&x))
    {
       if(x>=a&&x<=b)
        printf("Yes\n");
       else
        printf("No\n");
    }
    return 0;
}


Measured memory_bytes: 128