akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using static System.Console;
using static System.Math;
using static MyIO;
using static MyUtil;

public class A
{
	public static void Main() => (new Solver()).Solve();
}

public class Solver
{
	public void Solve()
	{
		int N = GetInt();
		var A = GetInts(N);

		var ans = new List<String>();
		ans.Add(string.Join(" ", A));
		for(int i = 1; i < N; i++)
		{
			int v = A[i];
			int j = i - 1;
			while(j >= 0 && A[j] > v)
			{
				A[j + 1] = A[j];
				j--;
			}
			A[j + 1] = v;
			ans.Add(string.Join(" ", A));
		}

		WriteLine(string.Join("\n", ans));
	}
}

public static class MyIO
{
	private static string[] args = null;
	private static int num = -1;
	private static int used = -1;

	private static string getArg()
	{
		if(used == num)
		{
			args = Console.ReadLine().Split(' ');
			num = args.Length;
			used = 0;
		}
		return args[used++];
	}

	public static int GetInt() => int.Parse(getArg());
	public static long GetLong() => long.Parse(getArg());
	public static double GetDouble() => double.Parse(getArg());
	public static decimal GetDecimal() => decimal.Parse(getArg());
	public static string GetString() => getArg();
	public static char GetChar() => getArg()[0];
	public static int[] GetInts(long N) => Enumerable.Range(0, (int)N).Select(_ => GetInt()).ToArray();
	public static long[] GetLongs(long N) => Enumerable.Range(0, (int)N).Select(_ => GetLong()).ToArray();
	public static double[] GetDoubles(long N) => Enumerable.Range(0, (int)N).Select(_ => GetDouble()).ToArray();
	public static decimal[] GetDecimals(long N) => Enumerable.Range(0, (int)N).Select(_ => GetDecimal()).ToArray();
	public static string[] GetStrings(long N) => Enumerable.Range(0, (int)N).Select(_ => GetString()).ToArray();
}

public static class MyUtil
{
	public static void chmax<T>(ref T x, T y) where T : IComparable<T>
	{
		if(x.CompareTo(y) < 0)
			x = y;
	}

	public static void chmin<T>(ref T x, T y) where T : IComparable<T>
	{
		if(x.CompareTo(y) > 0)
			x = y;
	}

	public static void swap<T>(ref T x, ref T y)
	{
		T tmp = x;
		x = y;
		y = tmp;
	}
}


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

int cnt[10];
string str;
bool done;
bool ok(int pos){
    if(pos == 10)return true;
    if(cnt[pos] == 0)return ok(pos + 1);
    if(cnt[pos] >= 3){
	cnt[pos] -= 3;
	if(ok(pos)){
	    cnt[pos] += 3;
	    return true;
	}
	cnt[pos] += 3;
    }
    if(cnt[pos] >= 2 && !done){
	done = true;
	cnt[pos] -= 2;
	if(ok(pos)){
	    done = false;
	    cnt[pos] += 2;
	    return true;
	}
	cnt[pos] += 2;
	done = false;
    }
    if(pos > 7)return false;
    if(cnt[pos] && cnt[pos + 1] && cnt[pos + 2]){
	cnt[pos]--;
	cnt[pos + 1]--;
	cnt[pos + 2]--;
	if(ok(pos)){
	    cnt[pos]++;
	    cnt[pos + 1]++;
	    cnt[pos + 2]++;
	    return true;
	}
	cnt[pos]++;
	cnt[pos + 1]++;
	cnt[pos + 2]++;
    }
    return false;
}

int main(){
    while(cin >> str){
	done = false;
	fill(cnt, cnt + 10, 0);
	vector<int> ans;
	for(int i = 0;i < 13;i++){
	    cnt[str[i] - '0']++;
	}
	for(int i = 1;i <= 9;i++){
	    if(cnt[i] == 4)continue;
	    cnt[i]++;
	    if(ok(1))ans.push_back(i);
	    cnt[i]--;
	}
	for(int i = 0;i < ans.size();i++){
	    cout << ans[i];
	    if(i != ans.size() - 1) cout << " ";
	}
	if(ans.size() == 0)cout<< 0;
	cout << endl;
    }
    return 0;
}

Measured memory_bytes: 1204
N=int(input())
A=[int(x) for x in input().split()]
A=[0]+A+[0]
dist=[0]*(N+1)
S=0
for i in range(N+1):
    S+=abs(A[i]-A[i+1])
for i in range(1,N+1):
    dist[i]=S+abs(A[i-1]-A[i+1])-(abs(A[i-1]-A[i])+abs(A[i]-A[i+1]))

for i in range(1,N+1):
    print(dist[i])

Measured memory_bytes: 20608
import java.io.IOException;
import java.io.InputStream;
import java.util.*;
import java.lang.Math;
import java.math.*;

public class Main {
    public static void main(String[] args) {
        FS reader = new FS();
        // write reader
        long n = reader.nextLong();
        if (n % 2 == 1) System.out.println(0);
        else {
            BigDecimal N   = new BigDecimal(n);
            BigDecimal ans = new BigDecimal(0);
            BigDecimal mod = new BigDecimal(10);
            while (N.compareTo(mod) >= 0) {
                ans = ans.add(N.divide(mod, BigDecimal.ROUND_DOWN));
                mod = mod.multiply(new BigDecimal(5));
            }
            System.out.println(ans);
        }
    }

    // Read Class
    static class FS {
        private final InputStream in = System.in;
        private final byte[] buffer = new byte[1024];
        private int ptr = 0;
        private int buflen = 0;
        private boolean hasNextByte() {
            if (ptr < buflen) {
                return true;
            } else {
                ptr = 0;
                try {
                    buflen = in.read(buffer);
                } catch (IOException e) {
                    e.printStackTrace();
                }
                if (buflen <= 0) {
                    return false;
                }
            }
            return true;
        }
    
        private int readByte() { return hasNextByte() ? buffer[ptr++] : -1;}
        private boolean isPrintableChar(int c) {return 33 <= c && c <= 126;}
        private void skipUnprintable() {while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;}
    
        public boolean hasNext() { skipUnprintable(); return hasNextByte();}
        public String next() {
            if (!hasNext()) throw new NoSuchElementException();
            StringBuilder sb = new StringBuilder();
            int b = readByte();
            while(isPrintableChar(b)) {
                sb.appendCodePoint(b);
                b = readByte();
            }
            return sb.toString();
        }
        public int nextInt() {
            return (int)nextLong();
        }
        public long nextLong() {
            if (!hasNext()) throw new NoSuchElementException();
            long n = 0;
            boolean minus = false;
            int b = readByte();
            if (b == '-') {
                minus = true;
                b = readByte();
            }
            if (b < '0' || '9' < b) {
                throw new NumberFormatException();
            }
            while(true) {
                if ('0' <= b && b <= '9') {
                    n *= 10;
                    n += b - '0';
                } else if(b == -1 || !isPrintableChar(b)) {
                    return minus ? -n : n;
                } else {
                    throw new NumberFormatException();
                }
                b = readByte();
            }
        }
    }
}



Measured memory_bytes: 22868
#include<stdio.h> 
typedef struct{
  
  int left,right,parent;
  
}node;
  
int main(){ 
  int id,n,i,j,d,t,x,c;
  node A[100000];
 
  scanf("%d",&n);
  for(i=0;i<n;i++)
    A[i].parent = A[i].right = A[i].left = -1; 
  for(i=0;i<n;i++){
    scanf("%d %d",&id,&t); 
    for(j=0;j<t;j++){
      scanf("%d",&c);
      A[c].parent = id;
      if(j == 0)A[id].left = c;
      else A[x].right = c;
      x = c;
    }
  }
 
  for(i=0;i<n;i++){  
    x = A[i].parent;
    d = 0;
    while(x != -1){
      x = A[x].parent;
      d++;
    }
 
    printf("node %d: parent = %d, depth = %d, ",i,A[i].parent,d);
    if(A[i].parent == -1)printf("root, [");
    else if(A[i].left == -1)printf("leaf, [");
    else printf("internal node, [");
 
    x = A[i].left;
    if(x != -1){
      printf("%d",A[i].left);
      while(A[x].right != -1){
    printf(", %d",A[x].right);
    x = A[x].right;
      }
    }
    printf("]\n");
  }
    return 0;
}

Measured memory_bytes: 1784
# coding : utf-8

a, b, c, d = map(int, input().split())

ab = abs(b - a)
ac = abs(c - a)
bc = abs(c - b)

ans = 'No'

if ac <= d:
    ans = 'Yes'

elif ab <= d and bc <= d:
    ans = 'Yes'

print(ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/integer/common_factor.hpp>
#include <boost/integer/common_factor_rt.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>

using std::string;
using std::vector;
using std::set;
using std::multiset;
using std::unordered_set;
using std::map;
using std::multimap;
using std::unordered_map;
using std::pair;
using std::cin;
using std::cout;

typedef uintmax_t    ull;
typedef intmax_t     ll;
typedef uint64_t     ul;
typedef uint32_t     ui;
typedef uint8_t      uc;

typedef boost::multiprecision::number<boost::multiprecision::cpp_dec_float<1000>> cpp_dec_float_1000;

constexpr char CRLF  = '\n';
constexpr char SPACE = ' ';
constexpr char VECTOR_COUT_SEPARATOR = SPACE;
constexpr ll INF = 1000'000'007;

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; }
template<class T> std::ostream& operator<< (std::ostream& os, const std::vector<T>& vc) { for(auto it = vc.begin(); it != vc.end(); ++it) { if (std::next(it) == vc.end()) os << *it; else os << *it << VECTOR_COUT_SEPARATOR; } return os; }
template<class T1, class T2> inline std::ostream & operator<< (std::ostream & os, const std::pair<T1, T2> & p) { return os << p.first << ' ' << p.second; }

void solve(void)
{
  int a, b, c; cin >> a >> b >> c;
  auto ans = (a+b+c >= 22) ? "bust" : "win";
  cout << ans << CRLF;
  return;
}

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

  solve();

  return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using ll = long long;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repk(i, k, n) for (int i = k; i < n; i++)
#define MOD 1000000007
#define INF 1e9
#define PIE 3.14159265358979323

template <class T>
inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T>
inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template <class T>
T GCD(T a, T b) {
    if (b == 0)
        return a;
    else
        return GCD(b, a % b);
}
template <class T>
inline T LCM(T a, T b) {
    return (a * b) / GCD(a, b);
}

using namespace std;
//#inculude <bits/stdc++.h>
#define int long long

signed main() {
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    int sum = 0;
    rep(i, n) {
        if (i == 0)
            sum += abs(a[0]);
        else if (i == n - 1)
            sum += abs(a[n - 1])+abs(a[n-1]-a[n-2]);
        else
            sum += abs(a[i] - a[i-1]);
    }
    rep(i, n) {
        int ans = sum;
        if (i == 0)
            ans = ans - abs(a[0]) - abs(a[1] - a[0]) + abs(a[1]);
        else if (i == n - 1)
            ans =
                ans - abs(a[n - 1] - a[n - 2]) - abs(a[n - 1]) + abs(a[n - 2]);
        else
            ans = ans - abs(a[i] - a[i - 1]) - abs(a[i + 1] - a[i]) +
                  abs(a[i + 1] - a[i - 1]);
        cout << ans << endl;
    }
}


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

// #define int long long
#define rep(i, n) for (long long i = (long long)(0); i < (long long)(n); ++i)
#define reps(i, n) for (long long i = (long long)(1); i <= (long long)(n); ++i)
#define rrep(i, n) for (long long i = ((long long)(n)-1); i >= 0; i--)
#define rreps(i, n) for (long long i = ((long long)(n)); i > 0; i--)
#define irep(i, m, n) for (long long i = (long long)(m); i < (long long)(n); ++i)
#define ireps(i, m, n) for (long long i = (long long)(m); i <= (long long)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) long long(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;
using vtp = vector<tuple<ll,ll,ll>>;
using vb = vector<bool>;

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 ll INF = 1e9;
const ll MOD = 1e9+7;
const ll LINF = 1e18;



signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  ll x; cin>>x;
  ll tmp=100;
  ll cnt=0;
  while(true){
    cnt++;
    tmp+=tmp*0.01;
    if(tmp>=x){
      cout<<cnt<<endl;
      return 0;
    }
  }
}

Measured memory_bytes: 3668
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
using namespace std;
#define rep(N) for(int i=0;i<N;i++)
#define rep2(N1,N2) for(int i=0;i<N1;i++)for(int j=0;j<N2;j++)
#define rep3(N1,N2,N3)for(int i=0;i<N1;i++)for(int j=0;j<N2;j++)for(int k=0;k<N3;k++)
#define For(i,N) for(int i=0;i<N;i++)
void yn(bool b) {
	if (b)printf("yes\n");
	else printf("no\n");
}

void Yn(bool b) {
	if (b)printf("Yes\n");
	else printf("No\n");
}

void YN(bool b) {
	if (b)printf("YES\n");
	else printf("NO\n");
}

int main(){
	long int N,K;
	cin >> K>>N;
	vector<long int>A(N);
	vector<long int>B(N);
	long int mx = 0;
	long int mn = K;
	rep(N) {
		cin >> A[i];
	}
	rep(N - 1)
		mx = max(mx, abs(A[i] - A[i + 1]));
	mx = max(mx, A[0] + K - A[N - 1]);
	cout << K - mx;
}

Measured memory_bytes: 3328
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		 
		//ある値の最大値
		int k = scanner.nextInt();
		// 合計値
		int s = scanner.nextInt();
		int count = 0;
		
		for (int i = 0; i <=k; i++) {
			for (int j = 0; j <= k; j++) {
				int t = s - i - j;
				if (t >= 0 && t <= k) {
					count ++;
				}
			}
		}
		System.out.println(count);
	}
}


Measured memory_bytes: 9804
package main

import "fmt"

func main() {
	var n, t, min int
	c := 1
	fmt.Scan(&n)
	fmt.Scan(&min)
	for i := 1; i < n; i++ {
		fmt.Scan(&t)
		if t < min {
			c++
			min = t
		}
	}
	fmt.Println(c)
}


Measured memory_bytes: 5504
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

int main(){
    int a, b, c;
    int i;

    scanf("%d %d %d", &a, &b, &c);
    int S;
    int d;
    d = (a+b+c)/2;
    S = sqrt(d*(d-a)*(d-b)*(d-c));
    printf("%d\n", S);
    return 0;
}

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


int main() {
	int A, B, C, D;
	cin >> A >> B >> C >> D;
	int ans;
	if(min(B, D) - max(A, C) <= 0){
		ans = 0;
	}
	else{
		ans = min(B, D) - max(A, C);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T> V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> > Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T> mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }
 
// ================================================= //
 
/*
 update : [s,t)にxを加算する
 query : [s,t) の総和を出力する
 */
const ll INIT = 0;
struct SegTree {
    int N;
    ll init_v;
    vector<ll> node, lazy;
     
    SegTree(int _N):init_v(INIT) {
        N = 1;
        while (N < _N) N *= 2;
        node.resize(2 * N - 1, init_v);
        lazy.resize(2 * N - 1, init_v);
    }
     
    void lazy_evaluate(int k) {
        node[k] += lazy[k]; // add のため加算
        if (k < N - 1) {
            lazy[2 * k + 1] += lazy[k] / 2; // add のため加算
            lazy[2 * k + 2] += lazy[k] / 2;
        }
        lazy[k] = 0;
    }
     
    /* [a,b) 引数の範囲に注意!! s~tまでを更新→update(s,t+1,~) */
    ll update(int a, int b, int x) { return update(a, b, 0, 0, N, x); }
    ll update(int a, int b, int k, int l, int r, int x) {
        if (r <= a || b <= l) {
            lazy_evaluate(k); // nodeを参照する前には必ず更新
            return node[k];
        }
        if (a <= l && r <= b) {
            lazy[k] += (r - l) * x; // 参照区間が指定区間を完全に含んでいれば, 参照区間長*加算値分nodeに加算される
            lazy_evaluate(k);
            return node[k];
        }
        else {
            lazy_evaluate(k);
            ll vl = update(a, b, 2 * k + 1, l, (l + r) / 2, x);
            ll vr = update(a, b, 2 * k + 2, (l + r) / 2, r, x);
            return node[k] = vl + vr;
        }
    }
     
    /* [a,b) 引数の範囲に注意!! */
    ll query(int a, int b) { return query(a, b, 0, 0, N); }
    ll query(int a, int b, int k, int l, int r) {
        if (r <= a || b <= l) return init_v;
        if (a <= l && r <= b) {
            lazy_evaluate(k);
            return node[k];
        }
        else {
            lazy_evaluate(k);
            ll vl = query(a, b, 2 * k + 1, l, (l + r) / 2);
            ll vr = query(a, b, 2 * k + 2, (l + r) / 2, r);
            return vl + vr;
        }
    }
};
 
 
int main(void) {
    cin.tie(0); ios::sync_with_stdio(false);
    int n,q; cin >> n >> q;
     
    SegTree ST(n);
//    BIT bit(n);
    while(q--){
        int com; cin >> com;
        if(com == 0){
            int s,t,x; cin >> s >> t >> x;
           ST.update(s-1,t,x);
        }else{
            int s,t; cin >> s >> t;
            cout << ST.query(s-1,t) <<endl;
        }
    }
     
    return 0;
}


Measured memory_bytes: 7080
import math
from functools import reduce

N = int(input())
S = [int(input()) for _ in range(N)]

def lcm_base(x, y):
    return (x * y) // math.gcd(x, y)


def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)


def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

print(lcm_list(S))

Measured memory_bytes: 9468
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <queue>
#include <string.h>
#include <vector>

using namespace std;
typedef long long ll;

struct Task {
  ll time;
  ll limit;

  Task (ll time = -1, ll limit = -1) {
    this->time = time;
    this->limit = limit;
  }

  bool operator>(const Task &t) const {
    return limit > t.limit;
  }    
};

int main() {
  int N;
  cin >> N;
  priority_queue <Task, vector<Task>, greater<Task>> pque;

  for (int i = 0; i < N; ++i) {
    ll time, limit;
    cin >> time >> limit;

    pque.push(Task(time, limit));
  }

  ll current_time = 0;

  while (!pque.empty()) {
    Task task = pque.top();
    pque.pop();

    current_time += task.time;

    if (current_time > task.limit) {
      cout << "No" << endl;
      return 0;
    }
  }

  cout << "Yes" << endl;

  return 0;
}


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

typedef long long int ll;

int main()
{
    ll n;
    cin >> n;


    if(n % 1000 == 0){
        cout << 0;
    }
    else{
        cout << (n / 1000 + 1) * 1000 - n;
    }
    return 0;
    
}


Measured memory_bytes: 3632
#include <iostream>
#include <cstdint>
#include <array>
#include <vector>
#include <bitset>

typedef std::bitset<10> Flag;

template<typename T>
std::ostream& operator<<(std::ostream &os, const std::vector<T> &v)
{
  for (typename std::vector<T>::size_type i = 0; i < v.size(); ++i) {
    os << v[i];
    if (i + 1 < v.size()) { os << ' '; }
  }
  return os;
}

int main()
{
  unsigned N;
  std::cin >> N;
  
  std::vector<Flag> F(N);
  for (unsigned n = 0; n < N; ++n) {
    F[n] = Flag(0);
    for (unsigned i = 0; i < 10; ++i) {
      int f;
      std::cin >> f;
      
      F[n] <<= 1;
      F[n].set(0, f);
    }
  }
  
  std::vector< std::array<int64_t, 11> > P(N);
  for (unsigned n = 0; n < N; ++n) {
    for (unsigned c = 0; c < 11; ++c) {
      std::cin >> P[n][c];
    }
  }
  
  int64_t max = -1e+10;
  for (unsigned f = 1; f < (1 << 10); ++f) {
    Flag flag(f);
    
    int64_t sum = 0;
    for (unsigned n = 0; n < N; ++n) {
      unsigned c = (flag & F[n]).count();
      sum += P[n][c];
    }
    max = std::max(sum, max);
  }
  std::cout << max << std::endl;
  
  return 0;
}

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

int main(){
	int n,d,x;
	cin>>n>>d>>x;
	int a[n];
	for(int i=0;i<n;i++){
		cin>>a[i];
		x+=(d+a[i]-1)/a[i];
	}
	cout<<x;
	return 0;
}


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

int main(){

    int n,m;
    cin>>n>>m;
    int *ans=new int[n];
    int *heights=new int[n];
    int *path=new int[2*m];
    
    for(int i=0;i<n;i++){
        cin>>heights[i];
    }
    
    for(int i=0;i<m;i++){
        cin>>path[2*i];
        cin>>path[2*i+1];
        path[2*i]-=1;
        path[2*i+1]-=1;
    }//02/ 12/ 13

    for(int i=0;i<m;i++){
        if(heights[path[2*i]] < heights[path[2*i+1]]){
            ans[path[2*i]]=1;
        }else if(heights[path[2*i]] > heights[path[2*i+1]]){
            ans[path[2*i+1]]=1;
        }else{
            ans[path[2*i]]=1;
            ans[path[2*i+1]]=1;
        }
    }
    
    int count=0;
    for(int i=0;i<n;i++){
        if(ans[i]==0)count++;
    }
    cout << count << endl;
    
    delete[] ans;
    delete[] heights;
    delete[] path;

  return 0;
}

Measured memory_bytes: 4776
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string s,a;
    int i,j,x=0;
    cin>>s>>a;

    for(i=0;i<s.size();i++)
    {
        if(s[i]==a[i])
            x++;
    }

    cout<<x<<endl;

    return 0;
}


Measured memory_bytes: 384
#pragma GCC optimize("O3")
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;

using ll = long long;
using P = pair<int, int>;
using T = tuple<int, int, int>;

template <class T> inline T chmax(T &a, const T b) {return a = (a < b) ? b : a;}
template <class T> inline T chmin(T &a, const T b) {return a = (a > b) ? b : a;}

constexpr int MOD = 1e9 + 7;
constexpr int inf = 1e9;
constexpr long long INF = 1e18;

#define all(a) (a).begin(), (a).end()

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

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

    string k; cin>>k;
    int d; cin>>d;
    int n = k.size();

    vector<vector<vector<ll>>> dp(n+1, vector<vector<ll>>(d, vector<ll>(2, 0)));
    dp[0][0][0] = 1;

    for(int i=0; i<n; i++){
        int cur = k[i] - '0';
        for(int pre=0; pre<d; pre++){
            for(int flg=0; flg<2; flg++){
                if(dp[i][pre][flg] == 0) continue;
                for(int j=0; j<=(flg?9:cur); j++){
                    dp[i+1][(pre+j)%d][flg||j<cur] += dp[i][pre][flg];
                    dp[i+1][(pre+j)%d][flg||j<cur] %= MOD;
                }
            }
        }
    }

    cout << (dp[n][0][0] + dp[n][0][1] - 1 + MOD) % MOD << endl;

    return 0;
}

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

ll n, k;
const int MAX_N = 20000;
vector<int> bit;

int bit_sum(int i) {
  int s = 0;
  while(i > 0) {
    s += bit[i];
    i -= i & (-i);
  }
  return s;
}

void bit_add(int i, int val) {
  while(i <= n) {
    bit[i] += val;
    i += i & (-i);
  }
}

int main () {
  scanf("%d%d", &n, &k);

  vector<ll> s(n+1);

  s[0] = 0;
  rep(i,n) {
    int a;
    scanf("%d", &a);
    s[i+1] = s[i] + (a - k);
  }

  vector<ll> ss(s);
  sort(ss.begin(), ss.end());

  for(int i = 0; i <= n; i++) {
    s[i] = distance(ss.begin(), lower_bound(ss.begin(), ss.end(), s[i])) + 1;
  }

  bit = vector<int>(n+2, 0);
  ll c = 0;
  for(int i = n; i >= 0; i--) {
    c += bit_sum(s[i] - 1);
    bit_add(s[i], 1);
  }

  printf("%lld\n", ll(n)*(n+1)/2 - c);

  return 0;
}


Measured memory_bytes: 4096
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define F first
#define S second
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int,int>;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
ll gcd(ll a, ll b) { return b?gcd(b, a%b):a;}
ll lcm(ll a, ll b) { return a*b/gcd(a,b);}
ll MOD=1000000007;

int main(){
  string s;cin>>s;
  if(s=="AAA" or s=="BBB"){
    cout<<"No"<<endl;
  }else{
    cout<<"Yes"<<endl;
  }
}

Measured memory_bytes: 256
use std::collections::HashMap;

fn main() {
    let l1 = read_vec::<i32>();
    let l2 = read_vec::<i32>();
    println!("{}", q4(l1[0], l1[1], l2));
}

fn q4(n:i32, m:i32, a:Vec<i32>) -> i64 {
    let mut map = HashMap::<i32,i32>::new();
    let mut ans:i64 = 0;
    let mut acc:i32 = 0;
    map.insert(acc, 1);
    for i in 0..n {
        acc = (acc + a[i as usize]) % m;

        let count = map.entry(acc).or_insert(0);
        ans += *count as i64;
        *count += 1;
    }

    ans
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>().split_whitespace().map(|e| e.parse().ok().unwrap()).collect()
}

Measured memory_bytes: 8444
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define uli unsigned long long int
#define INF 999999999
#define rep(i,m,n) for(lli i = m;i < n;i++)
#define pb(n) push_back(n)
#define Sort(n) sort(n.begin(), n.end())
#define Rev(n) reverse(n.begin(),n.end())
#define Out(S) cout << S << endl
#define NeOut(S) cout << S
#define HpOut(S) cout << setprecision(20) << S << endl;
#define Vecpr vector<pair<lli,lli>>
#define mod 1000000007;
bool is_prime(lli x) {
  for(lli i = 2; i * i <= x; i++) {
    if(x % i == 0) return false;
  }
  return true;
}
int main() {
  lli A,B,C=1,D=0,E=0,F=0,G=0,H=0,N,M;
  string S;
  cin >> S;
  A=S.size();
  vector<int>P(A,0),Q(0,0),L(0,0);
  rep(i,1,A){
    if(S[i]=='R'&&S[i-1]=='L')Q.pb(i-1);
    if(S[i]=='L'&&S[i-1]=='R')L.pb(i-1);
  }
  Q.pb(A-1);
  B=L.size();
  rep(i,0,B){
    if(i!=0)P[L[i]]=Q[i]-Q[i-1];
    else P[L[i]]=Q[i]+1;
  }
  rep(i,0,B){
    if(P[L[i]]%2==0){
      P[L[i]]/=2;
      P[L[i]+1]=P[L[i]];
    }else{
      if((L[i]-Q[i])%2==0){
        P[L[i]]=P[L[i]]/2+1;
        P[L[i]+1]=P[L[i]]-1;
      }
      else{
        P[L[i]]=P[L[i]]/2;
        P[L[i]+1]=P[L[i]]+1;
      }
    }
  }
  rep(i,0,A){
    NeOut(P[i]);
    NeOut(" ");
  }
  cout << endl;
}

Measured memory_bytes: 1532
#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 ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 
#define ll long long int
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define pll pair<ll,ll>
#define all(x) x.begin(),x.end()
#define sz(x) (ll)x.size() 

ll power(ll x,ll y,ll p) 
{ 
    ll res = 1;      
    x = x % p;  
    while (y > 0) 
    { 
        if (y & 1) 
            res = (res*x) % p; 
        y = y>>1; 
        x = (x*x) % p;   
    } 
    return res; 
} 
ll cnt[2005];
int main()
{
    ios_base::sync_with_stdio(false);
	ll n,i,j,k,x,y,t,m;

	cin >> n >> x >> y;
	for(i=1;i<=n;i++)
	{
		for(j=i+1;j<=n;j++)
			cnt[min(abs(x-i)+abs(y-j)+1,j-i)]++;
	}
	for(i=1;i<=n-1;i++)
		cout<<cnt[i]<<endl;
	// cout<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ri register
#define int long long
using namespace std;
inline int read()
{
    int s=0, w=1; ri char ch=getchar();
    while(ch<'0'||ch>'9') { if(ch=='-') w=-1; ch=getchar(); }
    while(ch>='0'&&ch<='9') s=(s<<3)+(s<<1)+(ch^48), ch=getchar();
    return s*w;
}
signed main()
{
    int a,b;
    a=read(), b=read();
    if(a==1&&b==1) puts("1");
    else if(a==1 || b==1) printf("%lld\n",max(a,b)-2);
    else printf("%lld\n",(a-2)*(b-2));
    return 0;
}

Measured memory_bytes: 3680
import sys
from heapq import heappush, heappop

inf = 1<<30

def solve():
    N, M, s = map(int, sys.stdin.readline().split())
    Adj = [[] for i in range(N)]

    for i in range(M):
        ui, vi, ci = map(int, sys.stdin.readline().split())
        Adj[ui].append((vi, ci))

    d = dijkstra(N, Adj, s)

    for di in d:
        print(di if di < inf else 'INF')

def dijkstra(N, Adj, s):
    d = [inf] * N
    d[s] = 0
    pq = [(0, s)]
    fixed = 0

    while pq:
        di, v = heappop(pq)

        if di > d[v]:
            continue

        for u, c in Adj[v]:
            if d[v] + c < d[u]:
                d[u] = d[v] + c
                heappush(pq, (d[u], u))

        fixed += 1

        if fixed == N - 1:
            break

    return d

if __name__ == '__main__':
    solve()

Measured memory_bytes: 92820
#include<iostream>
#include<cmath>

using namespace std;

int main()
{
  double a, b, c, d, x1, x2, y1, y2, z1, z2, s1, s2, t1, t2, r = 6378.1;
  while(true)
  {
    cin >> a >> b >> c >> d;
    if(a == b && b == c && c == d && d == -1)
      break;
    s1 = (90 - a) * M_PI / 180.0;
    t1 = b * M_PI / 180.0;
    s2 = (90 - c) * M_PI / 180.0;
    t2 = d * M_PI / 180.0;
    x1 = r * sin(s1) * cos(t1);
    y1 = r * sin(s1) * sin(t1);
    z1 = r * cos(s1);
    x2 = r * sin(s2) * cos(t2);
    y2 = r * sin(s2) * sin(t2);
    z2 = r * cos(s2);

    cout << (int)((r * acos(1 - (pow(x1 - x2, 2) + pow(y1 - y2, 2) + pow(z1 - z2, 2)) / (2 * r * r))) + 0.5) << endl\
;

  }
}

Measured memory_bytes: 1272
from collections import deque

n = int(input())
queue = deque()

for _ in range(n):
    tmp = input().split()
    cmd = tmp[0]
    if cmd == 'insert':
        queue.appendleft(tmp[1])
    elif cmd == 'delete':
        try:
            queue.remove(tmp[1])
        except ValueError:
            pass
    elif cmd == 'deleteFirst':
        queue.popleft()
    else:
        queue.pop()

print(' '.join(queue))



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

int main() {
  int n;
  cin >> n;
  vector<char> s(n);
  for(int i=0; i<n; i++) cin >> s[i];
  vector<int> ans(4);
  for(int i=0; i<n; i++) {
  	if(s[i] == 'P') ans[0] = 1;
    if(s[i] == 'W') ans[1] = 1;
    if(s[i] == 'G') ans[2] = 1;
    if(s[i] == 'Y') ans[3] = 1;
  }
  int sum = 0;
  for(int i=0; i<4; i++) if(ans[i] == 1) sum++;
  if(sum == 3) cout << "Three" << endl;
  if(sum == 4) cout << "Four" << endl;
}

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

int main()
{
	int n, m, l;
	int A[100][100], B[100][100];
        long int C[100][100] = {};
	int i, j;

	cin >> n >> m >> l;

	//??????A?????\???
	for (j = 0; j < n; j++)
	{
		for (i = 0; i < m; i++)
		{
			cin >> A[j][i];
		}
	}

	//??????B?????\???
	for (j = 0; j < m; j++)
	{
		for (i = 0; i < l; i++)
		{
			cin >> B[j][i];
		}
	}

	//??????C????¨????
	for (j = 0; j < n; j++)
	{
		for (i = 0; i < l; i++)
		{
			for (int k = 0; k < m; k++)
			{
				C[j][i] += A[j][k] * B[k][i];
			}
		}
	}

	//??????C?????¨???
	for (j = 0; j < n; j++)
	{
		for (i = 0; i < l; i++)
		{
			cout << C[j][i] ;
			if (i != l - 1)
			{
				cout << " ";
			}
		}

		cout << endl;
	}

	


	return 0;
}

Measured memory_bytes: 1324
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <functional>
#include <queue>
#include <string>
#include <cstring>
#include <numeric>
#include <cstdlib>
#include <cmath>
using namespace std;

typedef long long ll;

#define INF 10e10
#define REP(i,n) for(int i=0; i<n; i++)
#define REP_R(i,n,m) for(int i=m; i<n; i++)
#define MAX 100

int main() {
  string s,t;
  cin >> s;
  cin >> t;

  int lim = s.size();

  string ss = s, tt = t;
  int count = 0;

  for (int i = lim-1; i >=0; --i) {


      bool flag = false;
      for (int j = 0; j < lim; ++j) {
        int a = (i+j) % lim;
        if (s[a] != t[j]) {
          flag = true;
          break;
        }
      }

      if (flag) {
        continue;
      } else {
        cout << "Yes" << endl;
        return 0;
      }
  }

  cout << "No" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,a,b) for(ll i=ll(a);i<ll(b);i++)
#define irep(i,a,b) for(ll i=ll(a);i>=ll(b);i--)
#define pb push_back
#define mp make_pair
#define pll pair<ll,ll>
#define F .first
#define S .second 
using ll=long long;
using ld=long double;
using namespace std;
const ll mod=1e9+7;
ll x[110000];
main(){
  ll n,cut,tmp=0;
  cin>>n;
  rep(i,0,n)cin>>x[i];
  sort(x,x+n);
  while(tmp+1<n){
    sort(x,x+n);
    rep(i,tmp,n){
      if(x[i]!=0){tmp=i;cut=x[i];break;}
    }
    rep(i,tmp+1,n)x[i]%=cut;
  }
  cout<<x[n-1];
}

Measured memory_bytes: 1024
#: Author - Soumya Saurav
import sys,io,os,time
from collections import defaultdict
from collections import Counter
from collections import deque
from itertools import combinations
from itertools import permutations
import bisect,math,heapq
alphabet = "abcdefghijklmnopqrstuvwxyz"

input = sys.stdin.readline

########################################
n = int(input())
print("ACL"*n)









'''
# Wrap solution for more recursion depth
#submit as python3
import collections,sys,threading
sys.setrecursionlimit(10**9)
threading.stack_size(10**8)



threading.Thread(target=solve).start()
'''


Measured memory_bytes: 67280
import java.util.Scanner;

public class Main {
    public static void main(String... args) {
        // 入力
        Scanner sc = new Scanner(System.in);
        String s = sc.next();

        int result1 = 0;
        int result2 = 0;

        char temp = '0';
        for (int i = 0; i < s.length(); i++) {
            if (s.charAt(i) == temp) {
                result1++;
            } else {
                result2++;
            }

            if (temp == '0') {
                temp = '1';
            } else {
                temp = '0';
            }
        }

        System.out.println(result1 < result2 ? result1 : result2);
    }
}


Measured memory_bytes: 26104
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<utility>
#include<set>
#include<stack>
#include<list>
#include<deque>
#include<bitset>
#include<iomanip>
#include<cstring>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<climits>
#include<cmath>
#include<cctype>


#define pb push_back
#define mp make_pair
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define ren(i,a,b) for(int i=a;i>=b;i--)
#define ff first
#define ss second
#define pll pair<long long int,long long int>
#define pii pair<int,int>
#define vll vector<long long int>
#define vii vector<int>
#define gi(n) scanf("%d",&n)
#define gll(n) scanf("%lld",&n)
#define gstr(n) scanf("%s",n)
#define gl(n) cin >> n
#define oi(n) printf("%d",n)
#define oll(n) printf("%lld",n)
#define ostr(n) printf("%s",n)
#define ol(n) cout << n
#define os cout<<" "
#define on cout<<"\n"
#define o2(a,b) cout<<a<<" "<<b
#define all(n) n.begin(),n.end()
#define present(s,x) (s.find(x) != s.end())
#define cpresent(s,x) (find(all(s),x) != s.end())
#define tr(container, it) for(__typeof(container.begin()) it = container.begin(); it != container.end(); it++)
using namespace std;

typedef unsigned long long int ull;
typedef long long int ll;
typedef long double ld;
typedef vector<vector<ll> > mat;

const int N=2e5+5;

ll c[N],s=0,n,q;


int main()
{ios_base::sync_with_stdio(false);
cin.tie(0);
cin>>n;
rep(i,1,n)
{
	ll x;
	cin>>x;
	s+=x;
	c[x]++;
}
cin>>q;
while(q--)
{
	ll b,d;
	cin>>b>>d;
	s-=c[b]*b;
	c[d]+=c[b];
	s+=c[b]*d;
	c[b]=0;
	
	ol(s);on;
}
return 0;
}



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

int main() {

    ll N;
    cin >> N;

    ll ul;
    ul = ceil(sqrt(N));

    for (ll i = ul; i > 0; i--) {
        if (N % i == 0) {
            cout << (i - 1) + (N / i - 1) << endl;
            break;
        }
    }

    return 0;
}


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

using namespace std;

int main(){
  	int N;
    cin >> N;
	vector<int> d(N, 0);
  	for (int i = 0; i < N; i++){
      cin >> d[i];
    }
    
  	sort(d.begin(), d.end() );
    int M = N / 2;
    int K = d[M] - d[M-1];
  
    cout << K << endl;
}


Measured memory_bytes: 640
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace AtCoder
{
	class Program
	{
		static void Main(string[] args)
		{
			var firstLine = Console.ReadLine().Split(' ').Select(value => int.Parse(value)).ToArray();
			
			Console.WriteLine(firstLine[0] <= firstLine[2] && firstLine[1] >= firstLine[2] ? "Yes" : "No");
		}
	}
}


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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<int, int> Pi;
typedef vector<ll> Vec;
typedef vector<int> Vi;
typedef vector<string> Vs;
typedef vector<vector<ll>> VV;

#define REP(i, a, b) for(ll i=(a); i<(b); i++)
#define rep(i, n) REP(i, 0, n)
const int INF=1e9;
const int MAX=100005;
const int MOD=1000000007;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define ALL(v) v.begin(), v.end()
#define dbg(x_) cerr << #x_ << ":" << x_ << endl;
#define pb(x) push_back(x)
#define mp(a, b) make_pair(a,b)
#define Each(a,b) for(auto &a :b)
#define REPM(i, mp) for (auto i = mp.begin(); i != mp.end(); ++i)
#define dbgmap(mp) for (auto i = mp.begin(); i != mp.end(); ++i) { cout << i->first <<":"<<i->second << endl;}
#define sum(v) accumulate(ALL(v),0)
#define fi first
#define se second

template<typename T1, typename T2>
ostream &operator<<(ostream &s, const pair<T1, T2> &p) { return s<<"("<<p.first<<", "<<p.second<<")"; }

// vector
template<typename T>
ostream &operator<<(ostream &s, const vector<T> &v) {
    int len=v.size();
    for(int i=0; i<len; ++i) {
        s<<v[i];
        if(i<len-1) s<<"	";
    }
    return s;
}

// 2 dimentional vector
template<typename T>
ostream &operator<<(ostream &s, const vector<vector<T> > &vv) {
    int len=vv.size();
    for(int i=0; i<len; ++i) {
        s<<vv[i]<<endl;
    }
    return s;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin>>n;
    Vec h(n);

    rep(i,n){
        cin>>h[i];
    }
    ll ans=0;


    ll count = 0;
    rep(i,n){
        if(i>0){
           if(h[i]<=h[i-1]){
               count ++;
               ans = max(ans,count);
           }else{
               count = 0;
           }
        }
    }
    cout<<ans<<endl;
    return  0;
}


Measured memory_bytes: 1024
class UnionFind:
    def __init__(self, n: int) -> None:
        self.forest = [-1] * n

    def union(self, x: int, y: int) -> None:
        x = self.findRoot(x)
        y = self.findRoot(y)
        if x == y:
            return
        if self.forest[x] > self.forest[y]:
            x,y = y,x
        self.forest[x] += self.forest[y]
        self.forest[y] = x
        return

    def findRoot(self, x: int) -> int:
        if self.forest[x] < 0:
            return x
        else:
            self.forest[x] = self.findRoot(self.forest[x])
            return self.forest[x]

    def issame(self, x: int, y: int) -> bool:
        return self.findRoot(x) == self.findRoot(y)
    
    def size(self,x: int) -> int:
        return -self.forest[self.findRoot(x)]

n,m,k = map(int,input().split())
l = [[] for _ in range(n)]
u = UnionFind(n)
for _ in range(m):
    a,b = map(int,input().split())
    a -= 1
    b -= 1
    u.union(a,b)
    l[a].append(b)
    l[b].append(a)

for _ in range(k):
    c,d = map(int,input().split())
    c -= 1
    d -= 1
    if u.issame(c,d):
        l[c].append(d)
        l[d].append(c)

for i in range(n):
    q = u.size(i)
    w = len(l[i])
    print(q-w-1, end=" ")



Measured memory_bytes: 34760
//#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <stack>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <string>
#include <map>
#include <bitset>
using namespace std;

#define ll long long int
#define pb push_back
#define FastIO cin.sync_with_stdio(false),cin.tie(NULL)
#define file freopen("input.txt", "r", stdin),freopen("output.txt", "w", stdout)

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

ll min(ll a, ll b){
    if(a<b) return a;
    return b;}

const ll N = 1e6 + 5, INF = 1e18, MOD = 1e9 + 7, M = 6000;
int a[N], b[N];
bool c[N];
vector<int> prm;

void f(int n){
	int sq = sqrt(n);
	for(int i = 0; prm[i] <= sq; i++){
		if(n % prm[i] == 0){
			while(n % prm[i] == 0)n /= prm[i];
			b[ prm[i] ]++;
		}
	}
	if(n > 1)b[n]++;
}

int main(){
	//FastIO;
	
	for(int i = 2; i < N; i++){
		if(!c[i]){
			for(int j = i; j < N; j+= i)c[j] = true;
			prm.pb(i);
		}
	}

	int n;
	cin >> n;

	int tp = 0;
	for(int i = 0; i < n; i++){
		cin >> a[i];
		if(i)tp = __gcd(tp, a[i]);
		else tp = a[i];
	}

	for(int i = 0; i < n; i++)f(a[i]);

	if(*max_element(b, b+N) > 1 && tp == 1) cout << "setwise coprime";
	else if(tp == 1) cout << "pairwise coprime";
	else cout << "not coprime";


	return 0;
}




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

int main()
{
ll n , k ;
cin >> n >> k ;
ll r , s , p ;
cin >> r >> s >> p ;
string t ;
cin >> t ;
string ss="";
rep(i,n){
  if(i>=k&&ss[i-k]==t[i]){ss+='w';continue;}
  if(t[i]=='r')ans+=p;
  if(t[i]=='s')ans+=r;
  if(t[i]=='p')ans+=s;
  ss+=t[i];
}
cout << ans << endl;
return 0;
}

Measured memory_bytes: 640
#include <stdio.h>
#include <string.h>

unsigned long long ipow(unsigned long long x, unsigned long long y)
{
    unsigned long long r;
    
    r = 1;
    while (y-- > 0){
        r *= x;
    }
    
    return (r);
}


int main(void)
{
    int L, N;
    char snake[102];
    unsigned long long len_o;
    unsigned long long len_x;
    unsigned long long sum;
    int i;
    
    scanf("%d%d", &L, &N);
    scanf("%s", snake);
    strcat(snake, "x");
    L++;

    sum = 0;
    len_o = 0;
    len_x = 0;
    for (i = 0; i <= L; i++){
        if (snake[i] == 'x'){
            len_x++;
        }
        if (len_o == 0){
            if (snake[i] == 'o'){
                len_o = 1;
            }
        }
        else {
            if (snake[i] == 'o'){
                len_o++;
            }
            else {
                sum += 3 * (ipow(2, N) - 1) * (len_o - 1) + len_o;
                len_o = 0;
            }
        }
    }
    
    sum += len_x - 1;
    
    printf("%llu\n", sum);

    return (0);
}



Measured memory_bytes: 2112
#include <bits/stdc++.h>
using namespace std;
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define reprrev(i,a,b) for(int i=b-1;i>=a;i--) // [a, b)
#define reprev(i,n) reprrev(i,0,n)
typedef long long ll;
typedef unsigned long long ull;
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)とキャストしよう
    cin.tie(0);
    ios::sync_with_stdio(false);<- これら、printfとかと併用しない方が良さそう

*/

const ll mod = 1e9+7;

void chmod(ll &M){
    if(M >= mod) M %= mod;
    else if(M < 0){
        M += (abs(M)/mod + 1)*mod;
        M %= mod;
    }
}

ll modpow(ll x, ll n){
    if(n==0) return 1;
    ll res=modpow(x, n/2);

    if(n%2==0) return res*res%mod;
    else return res*res%mod*x%mod;
}

int getl(int i, int N) { return i==0? N-1:i-1; };
int getr(int i, int N) { return i==N-1? 0:i+1; };


// 線分 ab の偏角 返り値は[-π, π]
double argument(const pair<double, double> &a, const pair<double, double> &b){
    double ax=a.first, ay=a.second, bx=b.first, by=b.second;
    return atan2(by-ay, bx-ax);
}

/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */


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

    int n; cin >> n;
    vector<ll> a(n), b(n);
    rep(i, n) cin >> a[i];
    rep(i, n) cin >> b[i];

    ll ans = 0;
    reprev(k, 29){
        ll T = 1<<k;
        rep(i, n) { a[i] %= 2*T; b[i] %= 2*T; }
        sort(b.begin(), b.end());

        ll cnt = 0;
        rep(i, n){
            cnt += lower_bound(b.begin(), b.end(), 2*T-a[i]) - lower_bound(b.begin(), b.end(), T-a[i]);
            cnt += lower_bound(b.begin(), b.end(), 4*T-a[i]) - lower_bound(b.begin(), b.end(), 3*T-a[i]);
        }

        if(cnt%2 == 1) ans += T;
    }
    cout << ans << endl;
    
    return 0;
}

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


bool row( int a[][3]  )
{
    if( a[0][0] == 0 && a[0][1] == 0 && a[0][2] == 0 )
        return true;
    if( a[1][0] == 0 && a[1][1] == 0 && a[1][2] == 0 )
        return true;
    if( a[2][0] == 0 && a[2][1] == 0 && a[2][2] == 0 )
        return true;
    return false;
}
bool col( int a[][3])
{
    if( a[0][0]==0 && a[1][0]==0 && a[2][0]==0 )
        return true;
    if( a[0][1]==0 && a[1][1]==0 && a[2][1]==0 )
        return true;
    if( a[0][2]==0 && a[1][2]==0 && a[2][2]==0 )
        return true;
    return false;
}
bool diag( int a[][3])
{
    if( a[0][0] == 0 && a[1][1] == 0 && a[2][2] == 0)
        return true;
    if( a[0][2] == 0 && a[1][1] == 0 && a[2][0] == 0)
        return true;
    return false;
}
int main()
{
    int a[3][3];
    for(int i=0;i<3;i++)
    {
        for(int j=0;j<3;j++)
        {
            cin>>a[i][j];
        }
    }
    int n;
    cin>>n;
    for(int i=0;i<n;i++)
    {
        int temp;
        cin>>temp;
        bool found = false;
        for(int i=0;i<3;i++)
        {
            for(int j=0;j<3;j++)
            {
                if( a[i][j] == temp)
                {
                    a[i][j] =0;
                    found = true;
                    break;
                }
            }
            if( found ) break;
        }
    }

    bool ans = row(a) || col(a) || diag(a);
    if( ans )
        cout<<"Yes";
    else cout<<"No";

}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
#define finish(x) return cout << x << endl, 0
#define ll long long

int n;
vector <int> b;

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cin >> n;
    b.resize(n);
    for(auto &i : b) cin >> i;
    int all = 0;
    for(auto &i : b) all ^= i;
    for(auto &i : b) cout << (all ^ i) << " ";
    cout << endl;
}


Measured memory_bytes: 3996
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <tuple>
#include <vector>

using namespace std;

#define rep(i, n) for (int64_t i = 0; i < (n); i++)
#define irep(i, n) for (int64_t i = 0; i <= (n); i++)
#define rrep(i, n) for (int64_t i = (n)-1; i >= 0; i--)
#define rirep(i, n) for (int64_t i = n; i >= 0; i--)

int main() {
  int h, n;
  cin >> h >> n;
  rep(i, n) {
    int a;
    cin >> a;
    h -= a;
  }

  if (h <= 0) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}

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

int main(){
    int N; cin >> N;
    vector <int> A(N);
    rep(i,N) cin >> A[i];
    
    ll ans=0;
    rep(i,N) ans+=A[i]-1;
    cout << ans;
}

Measured memory_bytes: 256