akhauriyash/Code-Regression huggingface dataset:
/* 
 * Project: AtCoder Beginners Contest 140 A - Password
 * Author: toms74209200 <https://github.com/toms74209200>
 *
 * Created on 2020/08/21
 * Copyright (c) 2020 toms74209200
 * 
 * This software is released under the MIT License.
 * http://opensource.org/licenses/mit-license.php
 */
#include <cstdio>
#include <cstdint>
#include <cmath>
using namespace std;

uint16_t n;

void solve() {

    uint32_t pattern = pow(n, 3);
    printf("%d\n", pattern);

}

int main() {

    scanf("%hd", &n);

    solve();

}

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

int main()
{
	int N;
	string W[105];
	set < string > st;
	bool flag = true;

	cin >> N >> W[0];
	st.insert(W[0]);
	for ( int i = 1; i < N; i++ ) {
		cin >> W[i];
		if ( W[i - 1].back() == W[i].front() && st.find(W[i]) == st.end() ) {
			st.insert(W[i]);
		} else {
			flag = false;
		}
	}
	
	if ( flag ) {
		cout << "Yes" << endl;
	} else {
		cout << "No" << 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>
#define leading zero str.erase(0, min(str.find_first_not_of('0'), str.size()-1));
using namespace __gnu_pbds;
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
string text="abcdefghijklmnopqrstuvwxyz";
const int maxn=1e6+7;
//        .--------------.
//        | Try First One|
//        '--------------'
//                |     .--------------.
//                |     |              |
//                V     V              |
//              .--------------.       |
//              |      AC.     |<---.  |
//              '--------------'    |  |
//              (True)|  |(False)   |  |
//           .--------'  |          |  |
//           |           V          |  |
//           |  .--------------.    |  |
//           |  |   Try Again  |----'  |
//           |  '--------------'       |
//           |                         |
//           |  .--------------.       |
//           '->| Try Next One |-------'
//              '--------------'
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin>>n;
    double a[n+2];
    for(int i=0;i<n;i++)cin>>a[i];
    sort(a,a+n);
    double sum=a[0];
    for(int i=1;i<n;i++)sum=(sum+a[i])/2;
    printf("%f",sum);
}


Measured memory_bytes: 3832
using System;
using System.Collections.Generic;
class Program
{
	static void Main(string[] args)
	{
		int N = int.Parse(Console.ReadLine());
		long ans = 999999999999999999;
		string[] str = Console.ReadLine().Split();
		long[]A = new long[N];
		long sum = 0;
		for(var i=0;i<N;i++){
			A[i] = long.Parse(str[i]);
			sum += A[i];
		}
		long a1 = sum;
		long a2 = 0;
		for(var i=0;i<N-1;i++){
			a1 -= A[i];
			a2 += A[i];
			ans = Math.Min(ans,Math.Abs(a1-a2));
		}
		Console.WriteLine(ans);
	}
}


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

int main() {
  int a;
  cin >> a;

  cout << a + a * a + a * a * a << endl;

  return 0;
}

/*
*/


Measured memory_bytes: 3580
#include <iostream>
#define ll long long
using namespace std;
ll l,r;
int main()
{
    scanf("%lld%lld",&l,&r);
    if((r-l)>2019)
        printf("0\n");
    else
    {
        ll ans=2019;
        for(ll i=l;i<r;i++)
        {
            for(ll j=i+1;j<=r;j++)
            {
                ll x=i%2019;
                ll y=j%2019;
                ll t=x*y%2019;
                ans=min(ans,t);
            }
        }
        printf("%lld\n",ans);
    }
    return 0;
}


Measured memory_bytes: 256
import sys
x,y = map(int, input().split( ))
mod = 10**9+7

def chs(s,t,mod):
    nume =  1
    for i in range(s-t+1,s+1):
        nume *= i
        nume %= mod 
    deno = 1
    for i in range(1,t+1):
        deno *= i
        deno %= mod
    deno = pow(deno,mod-2,mod)
    
    return (nume*deno%mod)
if (x+y)%3!=0:
    print(0)
    sys.exit()
a = (x+y)//3
x-=a
y-=a
if x<0 or y<0:###
    print(0)
    sys.exit()
print(chs(x+y,y,mod))

Measured memory_bytes: 39280
/*                         _
                        _ooOoo_
                       o8888888o
                       88" . "88
                       (| -_- |)
                       O\  =  /O
                    ____/`---'\____
                  .'  \\|     |//  `.
                 /  \\|||  :  |||//  \
                /  _||||| -:- |||||_  \
                |   | \\\  -  /'| |   |
                | \_|  `\`---'//  |_/ |
                \  .-\__ `-. -'__/-.  /
              ___`. .'  /--.--\  `. .'___
           ."" '<  `.___\_<|>_/___.' _> \"".
          | | :  `- \`. ;`. _/; .'/ /  .' ; |
          \  \ `-.   \_\_`. _.'_/_/  -' _.' /
===========`-.`___`-.__\ \___  /__.-'_.'_.-'================

                  Please give me AC.
*/

#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <numeric>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <utility>

using namespace std;

using int64 = long long;
using uint64 = unsigned long long;
using vi = vector<int>;
using vl = vector<int64>;
using pii = pair<int, int>;
using pll = pair<int64, int64>;

#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(v) (v).begin(), (v).end()
#define print(x) cout << (x) << '\n'
#define print2(x, y) cout << (x) << ' ' << (y) << '\n'
#define print3(x, y, z) cout << (x) << ' ' << (y) << ' ' << (z) << '\n'
#define printn(v) rep(i, (v).size() - 1) cout << (v)[i] << ' '; cout << (v)[n - 1] << '\n';
#define debug(x) cerr << #x << ": " << (x) << '\n'
#define debug2(x, y) cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << '\n'
#define debug3(x, y, z) cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << ", " << #z << ": " << (z) << '\n'
#define dbg(v) for (size_t _ = 0; _ < v.size(); ++_){cerr << #v << "[" << _ << "] : " << v[_] << '\n';}
// constant
const int INF = (1<<30) - 1;
const int64 INF64 = (1LL<<62) - 1;

// End of template.


int main(){
    cout << fixed << setprecision(15);
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int n;
    cin >> n;
    if (n == 1)
        print(0);
    else if (n == 2)
        print(1);
    else
        print((n - 1) / 2);

    return 0;
}



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

using namespace std; 

#define pb push_back
#define fi first
#define se second
#define all(vec) vec.begin(),vec.end()
#define f(i,a,b) for(int i=a;i<b;i++)
#define fr(i,a,b) for(int i=a;i>=b;i--)
#define fp(i,a,b,p) for(int i=a;i<b;i+=p)
#define SZ(x) (int)x.size()

typedef  vector<string> vs;
typedef  vector<int> vi;
typedef  vector<long long> vl;	


int main(){
	
	int n;
	
	cin >> n ; 
	
	if(n<1000){
		cout <<"ABC" << endl;
	}else{
		cout <<"ABD" << endl;
	}
	

  
 return 0;
}


Measured memory_bytes: 256
def myAnswer(N:int,S:list) -> None:
   dic = {}
   for s in S:
      if(s in dic.keys()):
         dic[s]+=1
      else:
         dic[s]=1
   MAX = max(dic.values())
   dic2 = sorted(dic.items())
   for key,value in dic2:
      if(MAX == value):
         print(key)
   

def modelAnswer():
   tmp=1
def main():
   N = int(input())
   S = []
   for _ in range(N):
      S.append(input())
   myAnswer(N,S[:])
if __name__ == '__main__':
   main()

Measured memory_bytes: 47248
#include <iostream>
#include <algorithm>
#include <numeric>

using namespace std;

int main()
{
    int N, X;
    int m[110];
    cin >> N >> X;
    for (int i = 0; i < N; i++) cin >> m[i];

    int total = accumulate(m, m + N, 0);
    int min = *min_element(m, m + N);
    cout << N + (X - total) / min << endl;
}


Measured memory_bytes: 256
n = int(input())
s = input()
D = [[0] * n for i in range(n)]

for i in range(n):
    D[0][i] = int(s[0]==s[i])
    D[i][0] = int(s[0]==s[i])
D[0][0] = 0

for i in range(1,n):
    for j in range(i+1,n):
        mae = D[i-1][j-1]
        if s[i] == s[j]:
            if j-i <= mae:
                D[i][j] = mae
            else:
                D[i][j] = mae + 1

#print(D)

print(max([max(D[i]) for i in range(n)]))


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

#include <atcoder/all>
#define For(i, a, b) for (int(i) = (int)(a); (i) < (int)(b); ++(i))
#define rFor(i, a, b) for (int(i) = (int)(a)-1; (i) >= (int)(b); --(i))
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
#define fi first
#define se second
using namespace std;
using namespace atcoder;
typedef long long lint;
typedef unsigned long long ulint;
typedef pair<int, int> pii;
typedef pair<lint, lint> pll;
template <class T>
bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template <class T>
bool chmin(T &a, const T &b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T>
T div_floor(T a, T b) {
    if (b < 0) a *= -1, b *= -1;
    return a >= 0 ? a / b : (a + 1) / b - 1;
}
template <class T>
T div_ceil(T a, T b) {
    if (b < 0) a *= -1, b *= -1;
    return a > 0 ? (a - 1) / b + 1 : a / b;
}

constexpr lint mod = 1000000007;
constexpr lint INF = mod * mod;
constexpr int MAX = 200010;

int main() {
    int n, d;
    scanf("%d%d", &n, &d);
    int x[n][2];
    rep(i, n) rep(j, 2) scanf("%d", &x[i][j]);
    two_sat ts(n);
    rep(i, n) For(j, i + 1, n) {
        rep(k, 2) rep(l, 2) if (abs(x[i][k] - x[j][l]) < d) {
            ts.add_clause(i, k ^ 1, j, l ^ 1);
        }
    }
    bool ok = ts.satisfiable();
    puts(ok ? "Yes" : "No");
    if (ok) {
        auto v = ts.answer();
        rep(i, n) printf("%d\n", x[i][v[i]]);
    }
}

Measured memory_bytes: 3864
def f(n):
    if n == 1:
        return 1
    divs = {}
    div = 3
    while n > 1:
        if n % div == 0:
            n //= div
            if div in divs:
                divs[div] += 1
            else:
                divs[div] = 1
        else:
            div += 2
    ans = 1
    for div in divs.values():
        ans *= div + 1
    return ans


N = int(input())
ans = 0
for n in range(1, N + 1, 2):
    if f(n) == 8:
        ans += 1
print(ans)


Measured memory_bytes: 3064
#include<cstdio>

int main(){
	int N;
	scanf("%d", &N);
	int sum = 0, min_distance = 100000, a[N];
	for (int i = 0; i < N; ++i){
		int tmp;
		scanf("%d", &tmp);
		sum += tmp;
		a[i] = tmp*N;
	}
	int answer;
	for (int i = 0; i < N; ++i){
		if(a[i] == sum){
			printf("%d\n", i);
			return 0;
		}
		if(a[i] < sum && sum - a[i] < min_distance) answer = i, min_distance = sum - a[i];
		if(a[i] > sum && a[i] - sum < min_distance) answer = i, min_distance = a[i] - sum;
	}
	printf("%d\n", answer);
	return 0;
}

Measured memory_bytes: 128
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")

#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstring>
#include <deque>
#include <forward_list>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;
typedef long long ll;
typedef pair<ll, int> P;
typedef bitset<16> BS;

const ll MOD = 1E+09 + 7;
const ll INF = 1E18;
const int MAX_N = 1E+05;
const int MAX_M = 2E+05;

struct edge {
    int to;
    ll cost;
};

int N, M;

vector<edge> G[MAX_N + 1];
ll d[MAX_N + 1];
bool used[MAX_N + 1];
int L[MAX_M], R[MAX_M];
ll D[MAX_M];

void dfs(int t, int l);

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

    cin >> N >> M;

    for (int i = 0; i < M; i++) {
        cin >> L[i] >> R[i] >> D[i];
        G[L[i]].push_back((edge) { R[i], D[i] });
        G[R[i]].push_back((edge) { L[i], -D[i] });
    }

    fill(d, d + N + 1, INF);
    bool ans = true;
    for (int i = 1; i <= N; i++) {
        if (!used[i]) {
            dfs(i, 0);
        }
    }
    for (int i = 0; i < M; i++) {
        if (d[R[i]] - d[L[i]] != D[i]) {
            ans = false;
        }
    }
    if (ans) {
        cout << "Yes\n";
    } else {
        cout << "No\n";
    }

    /*
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < N; j++) {
            cout << "i = " << i << ", j = " << j << ", dp = " << dp[i][j] << "\n";
        }
    }
    */

    return 0;
}

void dfs(int t, int l)
{
    used[t] = true;
    d[t] = l;
    bool res = true;
    for (const auto& e : G[t]) {
        if (!used[e.to]) {
            dfs(e.to, l + e.cost);
        }
    }
    return;
}


Measured memory_bytes: 22984
#include <iostream>
#include <algorithm>

using namespace std;

int main(int argc, char *argv[]) {
  int pasta[3], juice[2];
  for (int i = 0; i < 3; i++)
    cin >> pasta[i];
  for (int i = 0; i < 2; i++)
    cin >> juice[i];
  sort(pasta, pasta + 3);
  sort(juice, juice + 2);
  cout << pasta[0] + juice[0] - 50 << endl;
  return 0;
}

Measured memory_bytes: 1176
from itertools import accumulate

N, K = map(int, input().split())
A = list(map(int, input().split()))


# Aの要素をK回以下の操作ですべてdの倍数にできるならば真を返す関数
def f(d):
    B = sorted(a % d for a in A)
    C = [d - b for b in B]
    X = list(accumulate(B))
    Y = list(accumulate(C))
    return any(
        X[j] == (Y[-1] - Y[j]) <= K
        for j in range(N)
    )


# 解の候補はsum(A)の約数である
S = sum(A)
ans = max(
    (
        S // d if f(S // d) else
        d if f(d) else
        0
    )
    for d in range(1, int(S**0.5) + 2)
    if S % d == 0
)

print(ans)


Measured memory_bytes: 45660
#include <bits/stdc++.h>
using namespace std;
using i64 = int64_t;
constexpr i64 MOD = 1e9 + 7;

i64 modpow(i64 a, i64 n, i64 mod) {
    if (n == 0) return 1;
    if (n % 2 == 0) {
        i64 t = modpow(a, n / 2, mod);
        return t * t % mod;
    }
    return a * modpow(a, n - 1, mod) % mod;
}

int main() {
    i64 m, n;
    cin >> m >> n;
    cout << modpow(m, n, MOD) << endl;
}


Measured memory_bytes: 3100
#include <iostream>
#include <vector>
#include <cmath>
#include <string>
#include <climits>
#include <iomanip>
#include <algorithm>
#include <queue>
#include <map>
#include <tuple>
#include <iostream>
#include <deque>
#include <array>
#include <set>
#include <functional>
#include <memory>
#include <stack>
#include <numeric>
#include <climits>
#include <cfloat>
struct Next {
	int next_skill, need;
};
struct Skill {
	int upper_limit, importance;
};
std::vector<long long int> add_with_range(const std::vector<long long int>& memo, const int lower_limit, const int upper_limit, const long long int importance) {
	std::vector<long long int> result(memo.size(), LLONG_MIN);
	std::deque<int> deque;
	for (auto i = lower_limit; i < memo.size(); ++i) {
		while (!deque.empty() && i - deque.front() > upper_limit) {
			deque.pop_front();
		}
		while (!deque.empty() && memo[deque.back()] - deque.back() * importance < memo[i - lower_limit] - (i - lower_limit) * importance) {
			if (memo[i - lower_limit] == LLONG_MIN) throw "fail";
			deque.pop_back();
		}
		if (memo[i - lower_limit] != LLONG_MIN) deque.push_back(i - lower_limit);
		if (!deque.empty()) result[i] = memo[deque.front()] + (i - deque.front()) * importance;
	}
	return result;
}

std::vector<long long int> search(std::vector<std::vector<Next>>& node, const int current, const std::vector<Skill>& skills, const std::vector<long long int>& memo) {
	if (node[current].empty()) {
		return add_with_range(memo, 0, skills[current].upper_limit, skills[current].importance);
	}
	else {
		std::sort(node[current].begin(), node[current].end(), [](const Next& a, const Next& b) {return a.need < b.need; });
		std::vector<long long int> result(memo.size(), LLONG_MIN);
		auto prev = memo;
		for (const auto &next: node[current]) {
			prev = search(node, next.next_skill, skills, prev);
			auto temp = add_with_range(prev, next.need, skills[current].upper_limit, skills[current].importance);
			for (auto i = next.need; i < result.size(); ++i) {
				result[i] = std::max(result[i], temp[i]);
			}
		}
		prev = add_with_range(memo, 0, skills[current].upper_limit, skills[current].importance);
		for (auto i = 0; i < result.size(); ++i) result[i] = std::max(result[i], prev[i]);
		return result;
	}

}
int main() {
	while (true) {
		int n, k; std::cin >> n >> k; if (n == 0 && k == 0) break;
		std::vector<Skill> skills(n); for (auto& s : skills) std::cin >> s.upper_limit; for (auto& s : skills) std::cin >> s.importance;
		std::vector<std::vector<Next>> node(n);
		std::vector<int> parent(n), lower_limit(n);
		for (auto i = 1; i < n; ++i) std::cin >> parent[i];
		for (auto i = 1; i < n; ++i) std::cin >> lower_limit[i];
		for (auto i = 1; i < n; ++i) {
			node[parent[i] - 1].push_back({ i, lower_limit[i] });
		}
		auto result = search(node, 0, skills, std::vector<long long int>(k + 1, 0LL));
		std::cout << result.back() << std::endl;
	}
}


Measured memory_bytes: 159644
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		String S = scanner.nextLine();

		int I = 0;

		StringBuilder sb = new StringBuilder(S);
		for (int i = 0; i < 4; i ++) {
			if(sb.charAt(i) == '+') {
				I ++;
			} else if (sb.charAt(i) == '-') {
				I --;
			}
		}

		System.out.println(I);

	}

}


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

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

    static class C {
        public void solve(int testNumber, MyScanner in, PrintWriter out) {
            int H = in.Int();
            int W = in.Int();
            int K = in.Int();
            char[][] c = new char[H][W];
            for (int i = 0; i < H; i++) {
                c[i] = in.next().toCharArray();
            }

            int ans = 0;
            int hm = 1 << H;
            int wm = 1 << W;
            for (int h = 0; h < hm; h++) {
                for (int w = 0; w < wm; w++) {
                    int cnt = 0;
                    for (int i = 0; i < H; i++) {
                        if (((1 << i) & h) > 0) continue;
                        for (int j = 0; j < W; j++) {
                            if (((1 << j) & w) > 0) continue;
                            if (c[i][j] == '#') cnt++;
                        }
                    }
                    if (cnt == K) ans++;
                }
            }
            out.println(ans);
        }

    }

    static class MyScanner {
        private BufferedReader in;
        private StringTokenizer st;

        public MyScanner(InputStream stream) {
            in = new BufferedReader(new InputStreamReader(stream));
        }

        public String next() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    String rl = in.readLine();
                    if (rl == null) {
                        return null;
                    }
                    st = new StringTokenizer(rl);
                } catch (IOException e) {
                    return null;
                }
            }
            return st.nextToken();
        }

        public int Int() {
            return Integer.parseInt(next());
        }

    }
}



Measured memory_bytes: 33288
#include <bits/stdc++.h>
 
using namespace std;
 
#define lli long long int
#define REP(i,s,n) for(int i=s;i<n;i++)
#define MOD 1000000007
#define NUM 2520
#define DEBUG 0
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())
#define PI (3.141592653589794)
#define INF (1LL<<50)

signed main(){

	lli h,w,a,b;
	cin>>h>>w>>a>>b;

	REP(i,0,h){
		REP(j,0,w){
			cout<<(((i<b)^(j<a))?1:0);
		}
		cout<<endl;
	}

	return 0;
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a) for(int i = 0; i < (a); i++)
#define ALL(a) (a).begin(),(a).end()
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const long long LINF = 1e18;
const long long MOD = 1e9 + 7;

signed main(){
    int n;
    cin >> n;
    ll a[n];
    REP(i,n){
        cin >> a[i];
    }
    ll ans = a[0] - 1, now = 1;
    for(int i = 1; i < n; i++){
        if(a[i] == now + 1) now++;
        else ans += max(0LL, (a[i] - 1) / (now + 1));
    }
    cout << ans << endl;
    return 0;
}

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

int main() {
  int a,b,c,k;
  cin >> a >> b >> c >> k;
  int xa = min(a,k);
  k -= xa;
  int xb = min(b,k);
  k -= xb;
  int xc = k;
  int ans = xa - xc;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3584
import itertools
Num_lis = [0,1,2,3,4,5,6,7,8,9]
while True:
    
    num = 0
   
    n,s = map(int,input().split())
    if [n,s] == [0,0]:
        break
    Con_lis = list(itertools.combinations(Num_lis, n))
    for i in range(len(Con_lis)):
        Sum = 0
        for j in range(n):
            Sum += Con_lis[i][j]
        if Sum == s:
            num += 1
    print(num)

Measured memory_bytes: 7620
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vll = vector<long long>;
using vp = vector<pair<int, int>>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using vvll = vector<vector<long long>>;
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 (b<a) {a=b; return 1;} return 0;}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    string s;
    cin >> s;
    rep(bit, 1<<3) {
        int now = 0;
        string ans = "";

        rep(i, 4) {
            if (i == 0) {
                now += s[i] - '0';
                ans += s[i];
            } else {
                if (bit>>(i-1)&1) {
                    now += s[i] - '0';
                    ans += '+';
                    ans += s[i];
                } else {
                    now -= s[i] - '0';
                    ans += '-';
                    ans += s[i];
                }
            }
        }
        if (now == 7) {
            cout << ans << "=7" << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 256
//#define M_PI 3.14159265358979323846
#define _USE_MATH_DEFINES

//#define _GLIBCXX_DEBUG
//#define all(x) (x).begin(),(x).end()

#include <bits/stdc++.h>

#define TASK ""
#define sqr(x) ((x)*(x))
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
using namespace std;
const ll INFLL = numeric_limits<int>::max();
const ll INFINT = numeric_limits<int>::max();
const ld EPS = 1e-7;
const ll MOD = 1000000000;
const ll MAXN = 123456;

void run()
{
    string s;
    cin >> s;
    string ans = "";
    for(char c: s)
    {
        if(c=='B')
        {
            if(ans.size()) ans.pop_back();
        }
        else ans.push_back(c);
    }
    cout << ans;
}

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

#ifdef LOCAL
//#define STRESS
#ifdef STRESS
    freopen("input.txt", "w", stdout);
    cout << "1000 50\n";
    for (int i = 0; i < 999; i++)
    {
        for (int j = 0; j < 999; j++) cout << ".";
        cout << "X\n";
    }
    for (int j = 0; j < 1000; j++)
        if (j != 1000 / 50)cout << "X";
        else cout << ".";
    return 0;

#endif
    if (strcmp(TASK, "-") != 0)
    {
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    }
#else
    if (strcmp(TASK, "")   != 0)
    {
        freopen(TASK".in", "r", stdin)  ;
        freopen(TASK".out", "w", stdout)  ;
    }
#endif
    run();

    return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <iostream>
#include <stdio.h>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <functional>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include <math.h>
#include <complex>
#include <cassert>
#define rep(i,a,b) for (int i = (a); i < (b); i++)
using namespace std;
typedef long long int ll;
typedef complex<double> com;
typedef pair<int, int> P;
const int mod = 1e9 + 7;
const int MOD = 998244353;
const ll INF = 4e18;



int main() {
	ll n,a,b; cin >> n>>a>>b;
	vector<ll> h(n);
	rep(i, 0, n) cin >> h[i];
	ll l = -1, r = 1e10;
	ll ans = INF;
	while (r - l > 1) {
		ll mid = (l + r) / 2,cnt = 0;
		rep(i, 0, n) {
			if(b*mid<h[i])cnt += (h[i] - b * mid + a - b - 1) / (1LL*a - b);
		}
		if (cnt <= mid) {
			r = mid;
			ans = min(ans, mid);
		}
		else l = mid;
	}
	printf("%lld", ans);
	return 0;
}


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

int main(){
  long long a = 0;
  long long b = 0;
  long long k = 0;
  cin >> a >> b >> k;
  if(0 >= a+b-k){
    cout << 0 << " " << 0 << endl;
  }
  else{
    if(k - a >= 0){
      cout << 0 << " " << b + a - k << endl;
    }
    else if(k - a <= 0){
      cout << a - k << " " << b << endl;
    }
  }
}

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

long long int iti = 1;

int main(){
	while(true) {
		int n;
		cin >> n;
		if ( n == 0 ) break;
		vector<long int> yotei;
		vector<long long int> tizu;
		for ( int i = 0; i < n; i++ ) {
			int k;
			cin >> k;
			long int s = 0;
			for ( int j = 0; j < k; j++ ) {
				int l;
				cin >> l;
				s += iti << ( l - 1 );
			}
			yotei.push_back( s );
			tizu.push_back( iti << i );
		}
		int day = -1;
		for ( int i = 0; i < 30; i++ ) {
			vector<int> aeru;
			long long int watasu = 0;
			long long int k = iti << i;
			for ( int j = 0; j < n; j++ ) {
				if ( yotei[j] & k ) {
					aeru.push_back( j );
					watasu = watasu | tizu[j];
				}
			}
			k = iti << n;
			if ( watasu + 1 == k ) {
				day = i + 1;
				break;
			}
			for ( int j = 0; j < aeru.size(); j++ ) {
				tizu[ aeru[j] ] = watasu;
			}
		}
		cout << day << endl;
	}
	return 0;
}

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

#define INF (1LL<<60);
#define MOD 1000000007

int main(){
	long long N,K;	cin>>N>>K;
	long long cnt=0;

	for(long long i=K; i<=N+1; i++){
		long long min=i*(i-1)/2;
		long long max=i*(N+(N-i+1))/2;

		long long tmp=max-min+1;
		//if(tmp<0){
		//	cout<<"?";
		//	continue;
		//}
		cnt+=tmp;
		cnt%=MOD;
	}
	cout<<cnt<<endl;

	return 0;
}


Measured memory_bytes: 3636
let s(a,b)=(b,a)open List;;let rec($)d c=match d with|[x;y;z]->(match c with|'N'->[y;s x;z]|'S'->[s y;x;z]|'E'->[s z;y;x]|'W'->[z;y;s x]|'Z'->[x;z;s y]|_->[])|_->[]and p=function[]->true|x::t->for_all(fun z->not(mem x(concat(map(fun d->[d;d$'Z';d$'Z'$'Z';d$'Z'$'Z'$'Z'])[z;z$'N';z$'W';z$'E';z$'S';z$'S'$'S']))))t&&p t and d=ref[];;for _=1to read_int()do d:=Scanf.scanf"%d %d %d %d %d %d
"(fun a b c d e f->[(a,f);(b,e);(c,d)])::!d done;print_endline(if p!d then"Yes"else"No")

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

int main(void){
    string S;
    cin >> S;
    int count = 0;
    for (int i = 0; i < S.size(); i++) if (S[i] == 'R') count++;
    if (count == 2) {
        if (S[1] == 'S') cout << count - 1 << endl;
        else cout << count << endl;
    }
    else cout << count << endl;
}


Measured memory_bytes: 3588
#include <bits/stdc++.h>
#define ll long long
#define pi 3.14159265358979
#define mod 1000000007
#define rep(i,n) for(ll i=0;i<n;i++)
using namespace std;
const int INF = 1000100100;

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

Measured memory_bytes: 3628
#include <iostream>
#include "bits/stdc++.h"
using namespace std;
#define print(x) cout<<x<<endl;
#define rep(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a) for(int i=0;i<a;i++)
#define debug int debug = 0;
#define RREP(i,a) for(int i=a-1;i>=0;i--)
#define rrep(i,a,b) for(int i=a-1;i>=b;i--)
#define printall(n,array) {for(int i=0;i<n;i++){cout<<array[i]<<" ";}cout<<endl;}
#define U() cout<<endl;
typedef long long ll;
typedef pair<int, int> Pi;
typedef pair<int, Pi> V;
typedef vector<ll> VE;
const ll mod = 1e9 + 7; //10^9+7

int main(){
    ll x, y;
    ll cnt = 0;
    cin >> x >> y;
    ll now = x;
    while(now <= y){
        now *= 2;
        cnt++;
    }
    print(cnt);
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#define F first
#define S second
using namespace std;
typedef long long ll;

ll n, d, a, pos, k, ans, cnt[200005];
pair<ll, ll> b[200005];

int main() {
	ll i, j;
	cin >> n >> d >> a;
	for(i=0; i<n; i++) scanf("%lld%lld", &b[i].F, &b[i].S);
	sort(b, b+n);
	for(i=j=0; i<n; i++) {
		for(; j<n && b[j].F <= b[i].F + 2*d; j++);
		j--;
		k = max(0LL, (b[i].S - cnt[i]*a + a-1) / a);
		ans += k;
		cnt[i] += k;
		cnt[j+1] -= k;
		cnt[i+1] += cnt[i];
	}
	cout << ans;
	return 0;
}


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

int main() {
  
  int N, M, C, ans = 0;
  cin >> N >> M >> C;
  
  vector<int> b(M);  
  for (int i = 0; i < M ; i++){
    cin >> b.at(i);
  }
  
  for (int i = 0 ; i < N ; i++){
    int sums = 0;
    
    for (int j = 0 ; j < M ; j++){
      int A;
      cin >> A;
      sums += A * b.at(j);
    }
    
    sums += C;
    
    if (sums > 0){
      ans++;
    }
    
  }
  
  cout << ans << endl;
  
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<deque>
#include<algorithm>
#define mod 1000000007
#define int long long
using namespace std;
int a[114514];
int cnt[114514];
int kaijo[114514];
int kinv[114514];
int modpow(int x, int n, int md) {
	if (n == 0)return 1;
	int res = modpow(x*x%mod, n / 2, mod);
	if (n & 1)res = res*x%mod;
	return res%mod;
}

int comb( int n, int r){
	if (n < r)return 0;
	int ans = kaijo[n] * kinv[r];
	ans %= mod;
	return ans*kinv[n - r] % mod;
}
signed main() {
	int n;
	cin >> n;
	for (int i = 0; i <= n; i++)cin >> a[i];

	for (int i = 0; i <= n; i++)cnt[a[i]]++;
	int kas;
	for (int i = 0; i <= n; i++) {
		if (cnt[i] == 2)kas = i;
	}
	int l, r;//重なった数字がどこにあるか
	for (int i = 0; i <= n; i++) {
		if (a[i] == kas) {
			l = i;
			break;
		}
	}
	for (int i = l + 1; i <= n; i++) {
		if (a[i] == kas)r = i;
	}

	kaijo[0] = 1;
	for (int i = 1; i <= 114514; i++) {
		kaijo[i] = kaijo[i - 1] * i;
		kaijo[i] %= mod;
	}

	for (int i = 0; i <= 114514; i++) {
		kinv[i] = modpow(kaijo[i], mod - 2, mod);
	}

	for (int i = 1; i <= n + 1; i++) {
		int x = l + n - r;
		int y = i - 1;
		int ans = comb(x, y);
		int cmb = comb(n + 1, i);
		cout << (cmb - ans+mod) % mod << endl;
	}
}

Measured memory_bytes: 4608
#include <bits/stdc++.h>
#define sz(arr) (int)arr.size()
#define all(arr) arr.begin(), arr.end()

using namespace std;

void _cin() {}
template <class Head, class... Tail>
void _cin(Head&& head, Tail&&... tail) {
  cin >> head;
  _cin(forward<Tail>(tail)...);
}

#define Cin(T, ...) \
  T __VA_ARGS__;    \
  _cin(__VA_ARGS__)

int main() {
  Cin(string, s);

  s.insert(4, " ");

  puts(s.c_str());

  return 0;
}

Measured memory_bytes: 256
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

class Main{
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        int N = scan.nextInt();
        long[] A = new long[N];
        for(int i=0;i<N;++i)A[i]=scan.nextLong();
        Map<Long,Integer> map = new HashMap<>();
        map.put(0L,1);
        long sum=0;
        long ans = 0;
        for(int i=0;i<N;++i){
            sum+=A[i];
            if(map.containsKey(sum))ans+=map.get(sum);
            else map.put(sum, 0);
            map.put(sum, map.get(sum)+1);
        }
        System.out.println(ans);
    }
}

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

const int INF =1e9;
const int MOD =1e9+7;

using namespace std;

typedef long long ll;

#define REP(i, n) for (int i = 0; i < int(n); i++)
#define REPD(i, n) for (int i = n - 1; i >= 0; i--)
#define FOR(i, a, b) for (int i = a; i < int(b); i++)
#define FORD(i, a, b) for (int i = b - 1; i >= int(a); i--)
#define WRAP(y, x, h, w) (0 <= y && y < h && 0 <= x && x < w)

#define ALL(x) (x).begin(), (x).end()

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

int main()
{
int s,w;
cin>>s>>w;
if(s>w)
cout<<"safe"<<endl;
else
cout<<"unsafe"<<endl;

}

Measured memory_bytes: 3596
#include <cstring>
#include <cstdlib>
#include <iostream>
using namespace std;

constexpr int MAX = 10;

char A[MAX];
int M[MAX];
int priority[128];

int g;
string expression;

string parse(int p, int l, int r) {
	if(p == g) {
		if(expression[l] == '(') return parse(0, l + 1, r - 1);
		return expression.substr(l, r - l);
	}

	int start = l, end = r, inc = 1, l_p = p + 1, r_p = p;
	if(A[p] == 'L') {
		start = r - 1;
		end = l - 1;
		inc = -1;
		swap(l_p, r_p);
	}

	int cnt = 0;
	for(int i = start; i != end; i += inc) {
		if(!cnt && priority[expression[i]] == p) {
			return '(' + parse(l_p, l, i) + expression[i] + parse(r_p, i + 1, r) + ')';
		}
		if(expression[i] == '(') ++cnt;
		else if(expression[i] == ')') --cnt;
	}

	return parse(p + 1, l, r);
}

void solve() {
	cin >> g;

	for(int i = 0; i < g; ++i) {
		cin >> A[i] >> M[i];
		for(int j = 0; j < M[i]; ++j) {
			char c;
			cin >> c;
			priority[c] = i;
		}
	}

	int n;
	cin >> n;
	while(n--) {
		cin >> expression;
		cout << parse(0, 0, expression.size()) << endl;
	}
}

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

	int t;
	cin >> t;
	while(t--) {
		memset(priority, -1, sizeof(priority));
		solve();
		if(t) cout << endl;
	}
}

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

const int mod = 1e9+7;

int32_t main(){

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

    for(int x=a;x<=((int)(1e4));x+=a){
        if(x % b == c)
            return cout << "YES" , 0;
    }

    cout << "NO";

    return 0;
}

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

using namespace std;

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

    int N;
    cin >> N;

    int A[101] = {};
    int cnt = 0;
    for(int i = 0; i < N; ++i){
        cin >> A[i];
        if(A[i] % 2 == 0){
            ++cnt;
        }
    }

    int ans = pow(3, N) - pow(2, cnt);

    cout << ans << endl;    

    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)

int main(){
    ll N, A, B;
    cin >> N >> A >> B;
    string S;
    cin >> S;
    ll recA = 0, recB = 0, passed = 0;
    rep(i, 0, N){
        if(S[i] == 'a'){
            recA++;
            if(passed < A + B){
                passed++;
                cout << "Yes" << endl;
            }else{
                cout << "No" << endl;
            }
        }else if(S[i] == 'b'){
            recB++;
            if(recB <= B && passed < A + B){
                passed++;
                cout << "Yes" << endl;
            }else{
                cout << "No" << endl;
            }
        }else{
            cout << "No" << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 896
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<cstring>

using namespace std;
string st;
int g;
int main()
{
	cin>>st;
	for(int i=1;i<st.size();i++)
	if(st[i]!=st[i-1])g++;
	printf("%d\n",g);
	
	return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
const int INF = 1e9+5;
int main() {
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    //ios_base::sync_with_stdio(0); cin.tie(NULL);
    int n;
    cin >> n;
    vector<int> a(n);
    for (int &x:a) {
        scanf("%d", &x);
    }
    
    vector<int> dp(n, INF);
    dp[0] = 0;
    for (int i=0; i<n; i++) {
        for (int j:{i+1, i+2}) {
            if (j < n)
                dp[j] = min(dp[j], dp[i]+abs(a[i]-a[j]));
        }
    }
    cout << dp[n-1];
    //return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define int ll
#define rep(i,n) for(int i=0;i<n;i++)
#define all(in) in.begin(), in.end()
#define INF (sizeof(int) == 4 ? (int)1e9:(int)1e18)
#define EPS 0.0000000001
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
template<typename Head, typename Value> auto vectors(const Head &head, const Value &v) { return vector<Value>(head, v); }
template<typename Head, typename... Tail> auto vectors(Head x, Tail... tail) { auto inner = vectors(tail...); return vector<decltype(inner)>(x, inner); }
using ld  = long double;
const ld pi = acos(-1.0);
signed main(){
    ld a,b,x; cin >> a >> b >> x;
    if(a * a * b >  2 * x){
        ld  rad = (pi / 2) - atan((2 * x) / (a * b * b) );
        ld res = (rad * 180) / pi;
        printf("%.10Lf\n", res);
    } else {
        ld rad = atan((-2 * x  / (a * a * a) + (2 * b) / a));
        ld res = (rad * 180) / pi;
        printf("%.10Lf\n", res);
    }
}


Measured memory_bytes: 256
#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;

string s;
int d;
ll dp[10000][100][2];

int main() {
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	cin >> s >> d;
	for (int i = 0; i < s[0] - '0'; i++) {
		dp[0][i % d][0]++;
	}
	dp[0][(s[0] - '0') % d][1] = 1;
	for (int i = 1; i < s.length(); i++) {
		for (int k = 0; k < 10; k++) {
			for (int j = 0; j < d; j++) {	
				dp[i][(j + k) % d][0] += dp[i - 1][j][0];
				dp[i][(j + k) % d][0] %= MOD;
				if (k < s[i] - '0') {
					dp[i][(j + k) % d][0] += dp[i - 1][j][1];
					dp[i][(j + k) % d][0] %= MOD;
				}
				if (k == s[i] - '0') {
					dp[i][(j + k) % d][1] += dp[i - 1][j][1];
					dp[i][(j + k) % d][1] %= MOD;
				}
			}
		}
	}
	cout << (dp[s.length() - 1][0][0] + dp[s.length() - 1][0][1] - 1 + MOD) % MOD << endl;
	return 0;
}

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

int main() {
    ll N, D;
    cin >> N >> D;
    ll cnt = 0;
    for (int i = 0; i < N; ++i) {
        ll x, y;
        cin >> x >> y;
        if (sqrt(x * x + y * y) <= D) {
            cnt++;
        }
    }
    cout << cnt << endl;
}


Measured memory_bytes: 3648
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
#define mod ((int)1e9+7)
#define lim 1000000000000000007
#define lim1 18446744073709551615  //Unsigned
#define sq(a) ((a)*(a))
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define mms(v,i) memset(v,i,sizeof(v))
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define REP(i,a,b) for (int i = a; i <= b; i++)
#define REPN(i,a,b) for (int i = a; i >= b; i--)
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef pair<int,int> pi;
typedef pair<ll,ll> PL;
typedef pair<ll,int> PLI;
typedef pair<int,ll> PIL;
typedef pair<int,pair<int,int> > pii;
typedef pair<double,double> pdd;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;
typedef tree<pi,null_type,less<pi>,rb_tree_tag,tree_order_statistics_node_update> indexed_set_pair;
ll power(ll a,ll b) {
   ll res=1;
   while(b){
      if(b%2==1) res=(res*a)%mod;
      a=(a*a)%mod;
      b>>=1;
   }
   return res;
}
ll gcdll(ll a,ll b) {
    if (b==0) return a;
    return gcdll(b,a%b);
}
int gcd(int a,int b) {
    if (b==0) return a;
    return gcd(b,a%b);
}

struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};

const int N = (int)1e6+5;
const int M = (int)1e3+5;
const int Q = 102;
const int logN = 19;

const double pie = acos(-1);

int freq[N], sieve[N], a[N];
void solve() {
  int n;
  cin>>n;
  int overall_gcd = 0;
  REP(i,1,n) {
    cin>>a[i];
    freq[a[i]]++;
    overall_gcd = __gcd(overall_gcd, a[i]);
  }
  bool pairwise_coprime = true;
  REP(i,2,N-1) {
    int cnt_multiples = 0;
    for(int j=i;j<N;j+=i) {
      cnt_multiples += freq[j];
    }
    if(cnt_multiples > 1) {
      pairwise_coprime = false;
      break;
    }
  }
  if(pairwise_coprime) {
    cout << "pairwise coprime";
  }
  else if(overall_gcd == 1) {
    cout << "setwise coprime";
  }
  else {
    cout << "not coprime";
  }
}

int main() {
    //freopen("./sort/b2.in","r",stdin);
    //freopen("output.txt","w",stdout);

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

    int T=1;
    //cin>>T;
    REP(TC,1,T) {
        //cout<<"Case #"<<TC<<": ";
        solve();
        cout<<"\n";
    }
}


Measured memory_bytes: 11372
# -*- coding: utf-8 -*-

import sys
import math
from decimal import Decimal, ROUND_DOWN


debug = False

def log(text):
    if debug:
        print(text)

def parse_input(lines_as_string = None):

    global debug
    lines = []
    if lines_as_string is None:
        debug = False
        # for line in sys.stdin:
        #     lines.append(line)
        lines.append(input())
    else:
        debug = True
        lines = [e for e in lines_as_string.split("\n")][1:-1]

    tokens = lines[0].split(' ')
    a = tokens[0]
    b = tokens[1]

    return (a, b)


def solve(a0, b0):

    a = int(a0)    
    b = float(b0)
#    c =  math.floor(a * (b * 1000) // 1000)

#    b2 = int(math.floor(b * 100))
#    c = math.floor((a * b2) // 100)

    a =  Decimal(a0)
    b =  Decimal(b0)
    
    ab = a * b
    c = int(ab.quantize(Decimal('1.'), rounding=ROUND_DOWN))
    
    if debug:
        print(c)

    return c
    


def main():
    # 出力
    result = solve(*parse_input())
    if isinstance(result, list):
        for r in result:
            print("%s" % r, sep='')
    else:
        print("%s" % result, sep='')

if __name__ == '__main__':

    main()
	

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

using i64 = int64_t;
using u64 = uint64_t;
using f32 = float;
using f64 = double;
using f80 = __float80;

template<typename C>
i64 Size(const C& c) { return static_cast<i64>(c.size()); }

template<typename C>
void Sort(C &c) { std::sort(c.begin(), c.end()); }

template<typename C>
void SortR(C &c) { std::sort(c.rbegin(), c.rend()); }

template<typename T, typename U, typename Comp=std::less<>>
bool ChMax(T& x_max, const U& x, Comp comp={}) {
  if(comp(x_max, x)) {
    x_max = x;
    return true;
  }
  return false;
}

template<typename T, typename U, typename Comp=std::less<>>
bool ChMin(T& x_min, const U& x, Comp comp={}) {
  if(comp(x, x_min)) {
    x_min = x;
    return true;
  }
  return false;
}

struct ProconInit {
  static constexpr int IOS_PREC = 15;
  static constexpr bool AUTOFLUSH = false;

  ProconInit() {
    std::cin.tie(nullptr);
    std::ios::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(IOS_PREC);
    if (AUTOFLUSH) std::cout << std::unitbuf;
  }
} PROCON_INIT;

void solve() {
  i64 s; std::cin >> s;
  i64 w; std::cin >> w;

  std::cout << ((s > w) ? "safe" : "unsafe") << "\n";
}

signed main() {
  solve();

  return 0;
}


Measured memory_bytes: 3636
-- | Main entry point to the application.
module Main where
 
import Control.Applicative
import Control.Monad
import Data.List

gcnt cnt a b = if a < b then succ cnt else cnt

inneriter [a,b] rest cnt = (reverse $ min a b:max a b:rest, gcnt cnt a b)
inneriter (a:b:rest) sofar cnt = inneriter (min a b:rest) (max a b:sofar) (gcnt cnt a b)
inneriter a _ cnt = (a, cnt)

iter ns cnt = let (nlist, ncnt) = inneriter ns [] cnt in if ncnt == cnt then (reverse ns, cnt) else iter nlist ncnt

bubbsort ns = iter (reverse ns) 0

-- | The main entry point.
main :: IO ()
main = do
    _ <- getLine
    ns <- concatMap (fmap (read :: String -> Int) . words) . lines <$> getContents
    let (sortedlist, count) = bubbsort ns
    putStrLn $ unwords $ map show sortedlist
    print count

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

int main() {
    int N;
    cin >> N;
    vector<int64_t> L(N + 1);
    L[0] = 2LL;
    L[1] = 1LL;
    for (int i = 2; i <= N; i++){
        L[i] = L[i - 1] + L[i - 2];
    }
    cout << L[N] << endl;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define Phuong_ ios_base::sync_with_stdio(0); cin.tie(0);
#define REP(i,a,b) for(int i=a; i<=b; ++i)

/// easy access -------------
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
typedef pair<int,int> pi;
typedef tuple<bool, int, int> tp;
typedef vector<vector<int>> vv;
///-------------------------
const ll mod = 1e9+7;

int main()
{
    Phuong_; /// <3333
    int n;
    cin >> n;
    if (n<2) {
        cout << 0;
    } else {
        if (n==2) cout << 2 ; else {
            ll x,y,z;
            x=y=z=1;
            for(int i=0; i<n; ++i){
                x = (x * 10) % mod;
                y = (y * 9) % mod;
                z = (z * 8) % mod;
            }
            y = (y*2)%mod;
            x = (x-y)%mod;
            if (x<0) x+=mod;
            x = (x + z) %mod;
            cout << x << '\n';
        }
    }
    return 0;
}


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

using namespace std;

int main(void) {
    vector<int> time(5);
    vector<int> han(5);
    for (int i = 0; i < 5; ++i) {
        cin >> time[i];
        if (time[i] % 10 != 0) { han.push_back(10 - time[i] % 10); }
    }
    int sum = 0;
    std::vector<int>::iterator maxIt = std::max_element(han.begin(), han.end());

    int x = 0;
    for (int i = 0; i < 5; ++i) {
        if ((10 - time[i] % 10) == han[distance(han.begin(), maxIt)]) {
            x = i;
            break;
        }
    }

    for (int i = 0; i < 5; ++i) {
        if(x != i){
            sum += time[i];
            sum += (time[i] % 10 == 0) ? 0 : 10 - (time[i] % 10);
        }
    }

    sum += time[x];

    cout << sum << endl;
}

Measured memory_bytes: 256
N,M=map(int, input().split())
py=[list(map(int, input().split())) for _ in range(M)]
cnt=[0]*(N+1)
ids={}
for p,y in sorted(py, key=lambda x: x[1]):
	cnt[p] += 1
	ids[y] = "%06d%06d" % (p, cnt[p])
for _,y in py:
	print(ids[y])


Measured memory_bytes: 43856
#include<cstdint>
#include<cstring>
#include<iostream>
#include<vector>
#include<memory>
#include<algorithm>
#include<utility>

using namespace std;


char S[100];
int64_t cnt[26];

int main()
{
	cin >> S;

	int len = 3, ans = 0;

	for (int i = 0; i < len; ++i) {
		ans += S[i] == '1' ? 1 : 0;
	}
	
	cout << ans << endl;

    return 0; 
}



Measured memory_bytes: 256