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

int main()
{
  int ans = 1;
  string w;
  cin >> w;
  int W[26] = {0};
  for (int i = 0; i < w.size(); i++)
  {
    W[(int)w[i] - 97]++;
  }

  for (int i = 0; i < 26; i++)
  {
    if (W[i] % 2 != 0)
    {
      ans = 0;
    }
  }
  if (ans)
  {
    cout << "Yes" << endl;
  }
  else
  {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 3588
import java.util.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		boolean[] isNotPrimes = new boolean[100001];
		isNotPrimes[0] = true;
		isNotPrimes[1] = true;
		int[] counts = new int[100001];
		for (int i = 2; i < isNotPrimes.length; i++) {
		    counts[i] = counts[i - 1];
		    if (!isNotPrimes[i]) {
		        for (int j = 2; i * j < isNotPrimes.length; j++) {
		            isNotPrimes[i * j] = true;
		        }
		        if (!isNotPrimes[(i + 1) / 2]) {
		            counts[i]++;
		        }
		    }
		}
		int q = sc.nextInt();
		StringBuilder sb = new StringBuilder();
		for (int i = 0; i < q; i++) {
		    sb.append(- counts[sc.nextInt() - 1] + counts[sc.nextInt()]).append("\n");
		}
        System.out.print(sb);
    }
}



Measured memory_bytes: 69264
#include <iostream>
#include <cstring>

using namespace std;
typedef long long ll;

ll ans;
char cant[100005];

int main() {
  int n,k;
  cin >> n >> k;

  int r,s,p;
  cin >> r >> s >> p;
  string t;
  cin >> t;

  for(int i = 0; i < t.size(); i++) {
    if(i < k) {
      if(t[i] == 'r') {
	ans += p;
	cant[i] = 'p';
      }
      else if(t[i] == 's') {
	ans += r;
	cant[i] = 'r';
      }
      else {
	ans += s;
	cant[i] = 's';
      }
    }
    else {
      if(t[i] == 'r') {
	if(cant[i-k] == 'p') {
	  cant[i] == 'a';
	}
	else {
	  ans += p;
	  cant[i] = 'p';
	}
      }
      if(t[i] == 's') {
	if(cant[i-k] == 'r') {
	  cant[i] == 'a';
	}
	else {
	  ans += r;
	  cant[i] = 'r';
	}
      }
      if(t[i] == 'p') {
	if(cant[i-k] == 's') {
	  cant[i] == 'a';
	}
	else {
	  ans += s;
	  cant[i] = 's';
	} 
      }
    }
  }
  cout << ans << endl;
}
  


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

#define rep(i, a, b) for(int i = (a); i < (b); ++i)
#define per(i, a, b) for(int i = (b)-1; i >= (a); --i)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fst first
#define snd second

template<class T> bool ckmin(T& a, const T& b) { return b < a ? a = b, 1 : 0; }
template<class T> bool ckmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<pii> vii;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int main() {
  cin.tie(0)->sync_with_stdio(0);
  cin.exceptions(cin.failbit);

  int n, k;
  cin >> n >> k;

  vi a(n);
  rep(i,0,n) cin >> a[i];

  auto ok = [&](int x) {
    if (x==0) return false;
    int cuts = 0;
    rep(i,0,n) cuts += ((a[i]+x-1) / x) -1;
    return cuts <= k;
  };

  int ans = *max_element(all(a));
  per(j,0,31) {
    while (ans-(1<<j) > 0 and ok(ans-(1<<j))) ans -= (1<<j);
  }

  cout << ans << '\n';

}

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

int main() {
    ll N;
    ll K;
    cin >> N >> K;
    vector<ll> A(N), F(N);
    for (int i = 0; i < N; i++) {
        cin >> A[i];
    }
    for (int i = 0; i < N; i++) {
        cin >> F[i];
    }
    sort(A.begin(), A.end(), greater<ll>());
    sort(F.begin(), F.end());
    ll cost = 0;
    ll ans = F[N - 1] * A[0];
    ll l = -1;
    ll r = ans + 1;
    ll m;
    // for (int i = 0; i < N; i++) {
    //     cout<< F[i] << " " << A[i] << "\n";
    // }
    while (r - l > 1) {
        m = l + (r - l) / 2;
        cost = 0;
        for (int i = 0; i < N; i++) {
            if (A[i] * F[i] > m) {
                cost += (A[i] * F[i] - m + F[i] - 1) / F[i];
            }
        }
       
        if (cost <= K) {
            ans = m;
            r = m;
        } else {
            l = m;
        }
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 3328
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    int c = sc.nextInt();
    int x = Math.abs(b-a);
    int y = Math.abs(c-a);
    System.out.println(x < y ? "A" : "B");
  }
}


Measured memory_bytes: 35700
N,M = map(int,input().split())
H = list(map(int,input().split()))
A = []
B = []
for i in range(M):
    a,b = map(int,input().split())
    A.append(a)
    B.append(b)

All = [True]*N

for i in range(M):
    a = A[i]-1
    b = B[i]-1
    if H[a] > H[b]:
        All[b] = False
    elif H[a] < H[b]:
        All[a] = False
    else:
        All[a] = False
        All[b] = False

print(sum(All))


Measured memory_bytes: 22376
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <numeric>
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> Pll;

#define EPS (1e-7)
#define INF (1e14)
#define PI (acos(-1))

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

struct edge{
    ll from, to, cost;
};

int main() {
    int N, M, P;
    cin >> N >> M >> P;
    vector<edge> E(M);
    REP(i, M) {
        cin >> E[i].from >> E[i].to >> E[i].cost;
        E[i].from--;
        E[i].to--;
        E[i].cost = -1 * (E[i].cost - P);
    }

    vector<ll> G(N, INF);

    G[0] = 0;
    bool update = true;
    int j = 0;
    ll tmp = 0;
    while(update){
        update = false;
        if (j == N - 1){
            tmp = G[N - 1];
        }
        if (j == 2 * N){
            if (G[N - 1] >= tmp) break;
            cout << "-1" << endl;
            return 0;
        }
        REP(i, M){
            auto e = E[i];
            if (G[e.from] != INF && G[e.to] > G[e.from] + e.cost){
                if (j < N - 1) G[e.to] = G[e.from] + e.cost;
                else G[e.to] = -INF;
                update = true;
            }
        }
        j++;
    }
    ll ans = G[N - 1] > 0 ? 0 : -G[N - 1];
    //REP(i, N) cout << G[i] << endl;
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 384
n = int(input())
a = list(map(int, input().split()))
cost = [0]
for p in a:
	cost.append(cost[-1] + p)
def get_cost(l, r):
	return cost[r+1] - cost[l]

dp = [[float("inf") for _ in range(n)] for _ in range(n)]
for i, p in enumerate(a):
	dp[i][i] = 0

for g in range(1, n):
	for l in range(n-g):
		r = l + g
		for m in range(l, r):
			dp[l][r] = min(dp[l][r], dp[l][m] + dp[m+1][r] + get_cost(l, r))

#print(dp)
print(dp[0][n-1])

Measured memory_bytes: 48348
import java.util.*;
class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long a = sc.nextLong();
        long b = sc.nextLong();
        System.out.println(lcm(a,b));
    }
    static long lcm(long a, long b) {
        long t;
        long c=a;
        c *= b;
        while((t = a%b)!=0) {
            a = b;
            b = t;
        }
        return (long)(c/b);
    }
}

Measured memory_bytes: 23636
#include <iostream>
#include <cstdio>
#include <bits/stdc++.h>


using namespace std;

int num(int x){
  int ret = 0;
  while (x > 0){
    ret += x%10;
    x /= 10;
  }
  return ret;
}
int main(){
  int a, b, N, i, j, k, min=1000, sa, sb;
  cin >> N;
  for (a = 1; a < N; a++){
    b = N - a;
    sa = num(a);
    sb = num(b);
    if (sa + sb < min){
      min = sa + sb;
    }
  }
  cout << min << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <limits>
#include <algorithm>
#include <functional>

using namespace std;

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

	int n, m;
	cin >> n >> m;

	cout << (n - 1) * (m - 1);

	return 0;
}


Measured memory_bytes: 3632
#include<stdio.h>
#include<queue>
#include<utility>
#include<algorithm>
#include<iostream>
using namespace std;
int X,Y,Z,n;
#define ran 111111
int B[ran],C[ran], _B[ran];
pair<int,int> b[ran],c[ran];
bool usedb[ran], usedc[ran];
priority_queue<pair<int,int> > q;
int main(){
	scanf("%d%d%d",&X,&Y,&Z);
	n = X + Y + Z;
	long long int res = 0;
	for(int i=0; i<n; i++){
		int u,v,w;
		scanf("%d%d%d",&u,&v,&w);
		b[i] = make_pair(v-u,i);
		c[i] = make_pair(w-u,i);
		B[i] = v-u;
		C[i] = w-u;
		res += u;
	}
	sort(b,b+n);reverse(b,b+n);
	for(int i=0; i<n; i++)
		_B[b[i].second] = i;
	b[n] = make_pair(-2000000000, n);
	B[n] = -2000000000;
	_B[n] = n;
	sort(c,c+n);reverse(c,c+n);

	long long int sumc = 0, sumb = 0;
	for(int i=0; i<Z; i++){
		sumc += c[i].first;
		int id = c[i].second;
		usedc[id] = true;
		q.push(make_pair(B[id] - C[id], id));
	}
	int pntb = 0;
	for(int i=0; i<Y; i++){
		while(usedc[b[pntb].second])pntb++;
		sumb += b[pntb].first;
		usedb[b[pntb].second] = true;
		pntb ++;
	}

	long long int bes = sumb + sumc;
	for(int run=0; run<Y; run++){
		sumc += c[Z+run].first;

		int id = c[Z+run].second;
		q.push(make_pair(B[id] - C[id], id));
		usedc[id] = true;
		if(usedb[id]){
			sumb -= B[id];
			usedb[id] = false;

			while(usedc[b[pntb].second])pntb++;
			sumb += b[pntb].first;
			usedb[b[pntb].second] = true;
			pntb ++;
		}

		id = q.top().second;
		usedc[id] = false;
		sumc -= C[id];
		q.pop();

		if(_B[id] < pntb-1 && !usedb[id]){
			usedb[id] = true;
			sumb += B[id];
			pntb --;
			sumb -= B[b[pntb].second];
			usedb[b[pntb].second] = false;
			while(!usedb[b[pntb-1].second])pntb--;
		}

		bes = max(bes, sumb + sumc);
	}
	cout << bes + res << endl;
	return 0;
}

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

using VI = vector<int>;
using VVI = vector<VI>;
using PII = pair<int, int>;
using LL = long long;
using VL = vector<LL>;
using VVL = vector<VL>;
using PLL = pair<LL, LL>;
using VS = vector<string>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define MT make_tuple
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))

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

#define FF first
#define SS second

#define DUMP(x) cout<<#x<<":"<<(x)<<endl
template<class S, class T>
istream& operator>>(istream& is, pair<S,T>& p){
  return is >> p.FF >> p.SS;
}
template<class T>
istream& operator>>(istream& is, vector<T>& xs){
  for(auto& x: xs)
	is >> x;
  return is;
}
template<class S, class T>
ostream& operator<<(ostream& os, const pair<S,T>& p){
  return os << p.FF << " " << p.SS;
}
template<class T>
ostream& operator<<(ostream& os, const vector<T>& xs){
  for(unsigned int i=0;i<xs.size();++i)
	os << (i?" ":"") << xs[i];
  return os;
}
template<class T>
void maxi(T& x, T y){
  if(x < y) x = y;
}
template<class T>
void mini(T& x, T y){
  if(x > y) x = y;
}




const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL MOD = 1e9+7;

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

  int N;
  cin >> N;
  VL xs(N);
  cin >> xs;

  SORT(xs);

  VL anss;
  for(int i=max(0,N/2-1);i<=min(N-1,N/2+2);++i){
	auto xss = xs;
	xss.erase(begin(xss) + i);
	LL ans = abs(xs[i] - xs[0]);
	for(int b=0,e=N-2;b<e;){
	  ans += xss[e] - xss[b];
	  ++b;
	  if(b < e)
		ans += xss[e] - xss[b];
	  --e;
	}
	anss.PB(ans);

	ans = abs(xs[i] - xs[N-1]);
	for(int b=0,e=N-2;b<e;){
	  ans += xss[e] - xss[b];
	  --e;
	  if(b < e)
		ans += xss[e] - xss[b];
	  ++b;
	}
	
	anss.PB(ans);
  }

  cout << *max_element(ALL(anss)) << endl;

  return 0;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define NL            "\n"
#define _SAD()        ios::sync_with_stdio(0),cin.tie(0), cout.tie(0);
#define SZ(s)         s.size()
#define SRT(x,y)      sort(x,x+y)
#define REV(a,b)      reverse(a,a+b)
#define VSRT(x)       sort(x.begin(),x.end())
#define VREV(x)       reverse(x.begin(),x.end())
int main()
{
    _SAD()
    int n,m,x,cnt=0,ans=0;
    cin>>n>>m>>x;
    for(int i=0;i<m;i++)
    {
        cin>>n;
        if(n>=x)
        {
            cnt++;
        }
        else
        {
            ans++;
        }
    }
    cout<<min(ans,cnt)<<NL;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    string s,ss="ABC";
    int n,k=-1,ans=0;
    cin>>n>>s;
    while (s.find(ss,k+1)!=string::npos)
    {
        k=s.find(ss,k+1);
        ans++;
    }
    cout<<ans;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
map<int,pair<int,long long> > mp;
long long a[200005];
int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	long long N;
	cin>>N;
	for(long long i=0;i<N;i++)
	{
		cin>>a[i];
		mp[a[i]].first++;
		long long r=mp[a[i]].first;
		mp[a[i]].second=r*(r-1)/2;
	}
	long long res=0;
	map<int,pair<int,long long> >::iterator it=mp.begin();
	for(;it!=mp.end();it++)
	{
		res+=it->second.second;
	}
	for(long long i=0;i<N;i++)
	{
		pair<int,long long> orin=mp[a[i]];
		mp[a[i]].first--;
		long long v=mp[a[i]].first;
		mp[a[i]].second=v*(v-1)/2;
		long long ans=res-(orin.second-mp[a[i]].second);
		cout<<ans<<endl;
		mp[a[i]]=orin;
	}
	return 0;
}

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

#define CPP_STR(x) CPP_STR_I(x)
#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_STR_I(args...) #args
#define CPP_CAT_I(x,y) x ## y

using i8  = int8_t;
using u8  = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;

using f32 = float;
using f64 = double;

#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define REPS(i, n) for(i64 i = 1; i <= n; ++i)
#define RREP(i, n) for(i64 i = n - 1; i >= 0 ; --i)
#define RREPS(i, n) for(i64 i = n; i >= 1; --i)

#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))

#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

#define pb push_back
#define mp make_pair
#define F first
#define S second

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; }

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

template<typename T, size_t N>
i64 SIZE(const T (&)[N]) { return static_cast<i64>(N); }


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

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


#define MAX_N 100'000

int main() {
    i64 Q; cin >> Q;

    vector<bool> is_prime(MAX_N + 1, true);
    is_prime[0] = false;
    is_prime[1] = false;
    for (i64 i = 2; i <= sqrt(MAX_N) + 0.5; i++) {
        if (!is_prime[i]) continue;
        for (i64 j = i * 2; j <= MAX_N; j += i) {
          is_prime[j] = false;
        }
    }

    vector<i64> like2017(MAX_N + 1, 0);
    for (i64 i = 3; i <= MAX_N; i += 2) {
        if (is_prime[i] && is_prime[(i + 1) / 2]) {
          like2017[i] = 1;
        }
    }

    vector<i64> C(MAX_N + 2, 0);
    REP(i, MAX_N + 1) {
        C[i + 1] = C[i] + like2017[i];
    }

    i64 l, r;
    REP(i, Q) {
        cin >> l >> r;
        cout << C[r + 1] - C[l] << endl;
    }

    return 0;
}

Measured memory_bytes: 2176
rInt :: String -> Int
rInt str = read str

getSortString :: Int -> Int -> String
getSortString a b
	| a <= b	= show a ++ " " ++ show b
	| otherwise	= show b ++ " " ++ show a

main :: IO ()
main = do
	input <- getLine
	let abList = map rInt $ words input
	let	a = head abList
		b = last abList
	if a == 0 && b == 0
		then return ()
		else do	putStrLn $ getSortString a b
			main

Measured memory_bytes: 4124
class UnionFind:
    # 初期化
    def __init__(self, n):
        # 根なら-size, 子なら親の頂点
        self.par = [-1] * n
        # 木の高さ
        self.rank = [0] * n

    # 検索
    def find(self, x):
        if self.par[x] < 0:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]

    # 併合
    def unite(self, x, y):
        x = self.find(x)
        y = self.find(y)
        # 異なる集合に属する場合のみ併合
        if x != y:
            # 高い方をxとする。
            if self.rank[x] < self.rank[y]:
                x,y = y,x
            # 同じ高さの時は高さ+1
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1
            # yの親をxとし、xのサイズにyのサイズを加える
            self.par[x] += self.par[y]
            self.par[y] = x

    # 同集合判定
    def same(self, x, y):
        return self.find(x) == self.find(y)

    # 集合の大きさ
    def size(self, x):
        return -self.par[self.find(x)]


n = int(input())
p = [int(input()) for i in range(n)]

already = [0 for i in range(n+1)]
group = UnionFind(n+1)
for x in p:
    already[x]=1
    if already[x-1]==1:
        group.unite(x,x-1)

ans = n
for x in p:
    ans=min(ans,n-group.size(x))

print(ans)

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

template <typename T>
struct Dijkstra {
  struct Edge {
    int to;
    T cost;
  };
  vector<int> prev;
  vector<vector<Edge>> g;
  Dijkstra(int n) : prev(n, -1), g(n) {}

  void addEdge(int u, int v, T w) {
    g[u].push_back({v, w});
    g[v].push_back({u, w});
  }
  vector<T> build(int s) {
    vector<T> dist(g.size(), -1);
    using Node = pair<T, int>;
    priority_queue<Node, vector<Node>, greater<Node>> pq;
    pq.push({dist[s] = 0, s});

    while (!pq.empty()) {
      auto d = pq.top().first;
      auto u = pq.top().second;
      pq.pop();
      if (dist[u] < d) continue;
      for (auto&& v : g[u]) {
        if (dist[v.to] < 0 || dist[v.to] > dist[u] + v.cost) {
          dist[v.to] = dist[u] + v.cost;
          prev[v.to] = u;
          pq.push({dist[v.to], v.to});
        }
      }
    }
    return dist;
  }
  vector<int> getPath(int t) {
    vector<int> path;
    for (; t != -1; t = prev[t]) path.push_back(t);
    reverse(begin(path), end(path));
    return path;
  }
};

void dfs(int& res, Dijkstra<int>& g, vector<bool>& used, int s) {
  used[s] = true;
  for (auto&& t : g.g[s]) {
    if (used[t.to]) continue;
    if (g.g[t.to].size() < 2) continue;
    res += t.cost;
    dfs(res, g, used, t.to);
  }
}

int main() {
  int n;
  while (cin >> n, n) {
    int sum = 0;
    Dijkstra<int> g(n);
    vector<int> p(n - 1);
    for (int i = 0; i < n - 1; i++) cin >> p[i];
    for (int i = 0; i < n - 1; i++) {
      int d;
      cin >> d;
      sum += d;
      g.addEdge(i + 1, p[i] - 1, d);
    }
    map<int, int> mp;
    int c = 0;
    for (int u = 0; u < n; u++) {
      if (g.g[u].size() < 2) continue;
      for (auto&& v : g.g[u]) {
        if (g.g[v.to].size() < 2) continue;
        if (mp.find(u) == mp.end()) mp[u] = c++;
        if (mp.find(v.to) == mp.end()) mp[v.to] = c++;
      }
    }
    Dijkstra<int> sg(c);
    for (int u = 0; u < n; u++) {
      if (g.g[u].size() < 2) continue;
      for (auto&& v : g.g[u]) {
        if (g.g[v.to].size() < 2) continue;
        sg.addEdge(mp[u], mp[v.to], v.cost);
      }
    }

    int longest = 0;
    int s = -1;
    vector<int> d;

    if (c > 0) {
      longest = 0;
      d = sg.build(0);
      for (int i = 0; i < c; i++) {
        if (d[i] > longest) {
          longest = d[i];
          s = i;
        }
      }
      longest = 0;
      d = sg.build(s);
      for (int i = 0; i < c; i++) {
        if (d[i] > longest) {
          longest = d[i];
        }
      }
    }

    int res = 0;
    vector<bool> used(c, false);
    if (s != -1) dfs(res, sg, used, s);

    int ans = sum + res * 2 - longest;
    cout << ans << endl;
  }
}



Measured memory_bytes: 3356
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
using namespace std;
const int INF = 0x3f3f3f3f;
const int MAXN = 100005;

int parent(int u) { return u / 2; }
int left(int u) { return u * 2; }
int right(int u) { return u * 2 + 1; }

int main(){
	int n, A[MAXN];
	cin >> n;
	for(int i = 1; i <= n; i++)
		cin >> A[i];
	for(int i = 1; i <= n; i++){
		cout << "node " << i << ": key = " << A[i] << ", ";
		if(i > 1)
			cout << "parent key = " << A[parent(i)] << ", ";
		if(left(i) <= n)
			cout << "left key = " << A[left(i)] << ", ";
		if(right(i) <= n)
			cout << "right key = " << A[right(i)] << ", ";
		cout << endl;

	}
	return 0;
}

Measured memory_bytes: 3092
#include<cstdio>
#include<algorithm>
inline void read(int&r)
{
	register char c;r=0;
	do c=getchar();
	while(c<'0'||c>'9');
	do r=r*10+c-'0',c=getchar();
	while(c>='0'&&c<='9');
}

int L=1,first[131073],head[131073],_L,n;
struct ac{ int to,nx; }e[1000000];
inline void addedge(int u,int a,int v,int b)
{
	u=u<<1|a,v=v<<1|b;
	e[L].to=v,e[L].nx=first[u],first[u]=L++;
	u^=1,v^=1;
	e[L].to=u,e[L].nx=first[v],first[v]=L++;
}


int st[131073],top;
int b[131073],timer;
bool dfs(int u)
{
	if(b[u^1]==timer)
		return false;

	b[u]=timer;
	st[top++]=u;

	for(int j=first[u];j;j=e[j].nx)
		if(!(b[e[j].to]==timer||dfs(e[j].to)))
			return false;
	return true;
}


bool check(int u)
{
	top=0;
	if(dfs(u<<1|1))return true;
	while(top)b[st[--top]]=0;
	return dfs(u<<1);
}


#define x first
#define y second
#define lc now<<1
#define rc now<<1|1
std::pair<int,int>a[20000],s[131073];
int pos[10000];

void init(int now=1,int l=0,int r=n-1)
{
	if(l==r)
	{
		if(~pos[a[l].y])
		{
			int u=pos[a[l].y];
			addedge(u,1,now,0);
			addedge(u,0,now,1);
			a[l].y=now;
		}
		else
			a[l].y=pos[a[l].y]=now;
		s[now].x=s[now].y=a[l].x;
		s[rc].x=2e9;
		return;
	}
	int m=(l+r)>>1;
	init(lc,l,m);
	init(rc,m+1,r);
	s[now].x=s[lc].x;
	s[now].y=s[rc].y;
	addedge(now,0,lc,0);
	addedge(now,0,rc,0);
}

void link(int u,int L,int R,int now=1,int l=0,int r=n-1)
{
	if(L<=l&&s[now].y<=R)return addedge(u,1,now,0);
	int m=(l+r)>>1;
	if(L<=m)link(u,L,R,lc,l,m);
	if(s[rc].x<=R)link(u,L,R,rc,m+1,r);
}

void copy(int now=1,int l=0,int r=n-1)
{
	head[now<<1]=first[now<<1];
	head[now<<1|1]=first[now<<1|1];
	if(l<r)
	{
		int m=(l+r)>>1;
		copy(lc,l,m);
		copy(rc,m+1,r);
	}
}

void paste(int now=1,int l=0,int r=n-1)
{
	first[now<<1]=head[now<<1];
	first[now<<1|1]=head[now<<1|1];
	if(l<r)
	{
		int m=(l+r)>>1;
		paste(lc,l,m);
		paste(rc,m+1,r);
	}
}

bool twosat(int now=1,int l=0,int r=n-1)
{
	if(!check(now))return false;
	if(l<r)
	{
		int m=(l+r)>>1;
		if(!twosat(lc,l,m))return false;
		if(!twosat(rc,m+1,r))return false;
	}
	return true;
}



bool work(int d)
{
	L=_L,paste();
	for(int i=0;i<n;i++)
		link(a[i].y,i+1,a[i].x+d-1);

	return ++timer,twosat();
}


int main()
{
	int i,l=1e9,m,r=1;read(n);
	for(i=0;i<n;i++)pos[i]=-1;n<<=1;
	for(i=0;i<n;i++)
	{
		read(a[i].x);
		a[i].y=i>>1;
		a[i].x<l&&(l=a[i].x);
		a[i].x>r&&(r=a[i].x);
	}
	std::sort(a,a+n);

	init(),_L=L,copy();

	r-=l,l=0;
	while(l<r)
	{
		m=(l+r+1)>>1;
		if(work(m))l=m;
		else r=m-1;
	}
	printf("%d\n",l);
}

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

using namespace std;
 
inline int Arrange(const int start,vector<int> &par){
	if(start!=par[start]) return par[start]=Arrange(par[start],par);
	return start;
}

inline void Unify(const int x,const int y,vector<int> &par){
	par[Arrange(x,par)]=Arrange(y,par);
	return ;
}

inline vector<int> UnionFind(const int n,const vector<pair<int,int>> edge){
	vector<int> par;
	for(int i=0;i<n;i++) par.push_back(i);
	for(int i=0;i<edge.size();i++) Unify(edge[i].first,edge[i].second,par);
	for(int i=0;i<n;i++) Arrange(i,par);
	return par;
}
 
int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);

	int n,m; cin>>n>>m;
	vector<int> v;
	for(int i=0;i<n;i++){
		int k; cin>>k;
		v.push_back(k-1); 
   }
   vector<pair<int,int>> edge;
	for(int i=0;i<m;i++){
		int x,y; cin>>x>>y;
		edge.push_back(make_pair(x-1,y-1));
	}
	vector<int> p=UnionFind(n,edge);
	int ans=0;
	for(int i=0;i<n;i++) ans+=(p[i]==p[v[i]]); 
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3188
#include <math.h>
#include <ctype.h>
#include <limits.h>
#include <assert.h>

#include <vector>
#include <numeric>
#include <iostream>
#include <algorithm>
#include <functional>

#define nl                std::cout << "\n"
#define in(x)             std::cin  >> (x)
#define out(x)            std::cout << (x) << " "
#define err(x)            std::cerr << #x << "=" << (x) << " | "

#define inn(x)            int x; in(x)
#define rep(i, n)         for (int i =  0 ; i < (n); ++i)
#define per(i, n)         for (int i = (n) - 1; i > -1; --i)
#define repr(i, l, r)     for (int i = (l); i < (r); ++i)

#define no                puts("NO")
#define yes               puts("YES")

using ll  = long long int;
using vi  = std::vector<int>;
using ii  = std::pair<int, int>;
using iii = std::pair< ii, int>;
using vii = std::vector<ii>;

const int N = 1010101;
const int MD = 1e9 + 7;

void solve() {
    inn(n);
    int h[n]; rep(i, n) in(h[i]);
    int dp[n] = {0};

    dp[1] = abs(h[1] - h[0]);
    repr(i, 2, n) {
        dp[i] = std::min(dp[i - 1] + abs(h[i] - h[i - 1]),
                         dp[i - 2] + abs(h[i] - h[i - 2]));
    }
    out(dp[n - 1]);
}

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

    //inn(t); repr(tc, 1, t + 1)
    solve();

    return 0;
}


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

using namespace std;
using ll = long long;

int main(){
    string s;
    cin >> s;
    int count = 0, MAX = 0;
    for(int i = 0; i < s.size(); i++){
        if(s[i] == 'A' || s[i] == 'C' || s[i] == 'G' || s[i] == 'T'){
            count++;
        }else{
            count = 0;
        }
        MAX = max(count, MAX);
    }
    cout << MAX << endl;
    return 0;
}

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

int main(void){
  double x1, y1, x2, y2, x, y, m, n, l, s=0, S;
  scanf("%lf,%lf %lf,%lf",&x1,&y1,&x2,&y2);
  
  n=hypot(x1-x2,y1-y2);
  
  while(scanf("%lf,%lf",&x,&y)!=EOF){
    m=hypot(x1-x,y1-y);
    l=hypot(x2-x,y2-y);
    S=(n+m+l)/2;
    s+=sqrt(S*(S-n)*(S-m)*(S-l));
    n=m;
    x2=x;
    y2=y;
  }
  
  printf("%f\n",s);
  return 0;
}


Measured memory_bytes: 2044
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <math.h>
#include <algorithm>
#include <chrono>
#include <queue>
#include <functional>

#define out(t) cout << (t) << "\n"

using namespace std;

typedef unsigned long long ull;
typedef long long ll;
typedef unsigned int uint;

int popcount(uint x) {
    x -= x >> 1 & 0x55555555;
    x = (x & 0x33333333) + (x >> 2 & 0x33333333);
    x = x + (x >> 4) & 0x0F0F0F0F;
    return x * 0x01010101 >> 24;
}

int tzcnt(uint x) {
    return popcount(~x & x - 1);
}

struct Point {
    int x, y;

    Point(int p, int q) : x(p), y(q) {}
};

int sum[17];

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

    string N;
    cin >> N;

    sum[0] = N[0] - '0';
    for (int i = 1; i < N.length(); ++i) {
        sum[i] = sum[i - 1] + (N[i] - '0');
    }

    int ans = sum[N.length() - 1];

    for (int i = 0; i < N.length(); ++i) {
        ans = max(ans, (int)(sum[i] - 1 + (N.length() - i - 1) * 9));
    }

    out(ans);
    
    int aaa;
    cin >> aaa;
}

Measured memory_bytes: 256
#include <algorithm>  
#include <iostream>  
#include <sstream>  
#include <string>  
#include <cstring>
#include <vector>  
#include <queue>  
#include <set>  
#include <map>  
#include <cstdio>  
#include <cstdlib>  
#include <cctype>  
#include <cmath>  
#include <list>  
#include <cassert>
#include <ctime>
#include <climits>
using namespace std;  

#define PB push_back  
#define MP make_pair  
#define SZ(v) ((int)(v).size())  
#define FOR(i,a,b) for(int i=(a);i<(b);++i)  
#define REP(i,n) FOR(i,0,n)  
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)  
#define REPE(i,n) FORE(i,0,n)  
#define FORSZ(i,a,v) FOR(i,a,SZ(v))  
#define REPSZ(i,v) REP(i,SZ(v))  
typedef long long ll;
typedef unsigned long long ull;
ll gcd(ll a,ll b) { return b==0?a:gcd(b,a%b); }

const int MAXLEN=200000;

char s[MAXLEN+1]; int n;

int dp[MAXLEN+1][5];

int solve() {
	FORE(i,1,n) FORE(j,1,4) {
		dp[i][j]=INT_MIN;
		if(j>i) continue;
		if(i==j) { dp[i][j]=1; continue; }
		FORE(k,1,4) if(dp[i-j][k]!=INT_MIN) {
			if(k==j) { bool same=true; REP(x,j) if(s[i-j-k+x]!=s[i-j+x]) same=false; if(same) continue; }
			dp[i][j]=max(dp[i][j],dp[i-j][k]+1);
		}
	}
	int ret=INT_MIN; FORE(j,1,4) ret=max(ret,dp[n][j]); return ret;
}

void run() {
	scanf("%s",s); n=strlen(s);
	printf("%d\n",solve());
}

int main() {
	run();
	return 0;
}


Measured memory_bytes: 4352
var input=require("fs").readFileSync("/dev/stdin","utf8");
let arr = input.split(" ");
var i, j;
for(let cnt=0;cnt<3;cnt++){
for(i=0;i<3;i++){
    if(arr[i]>arr[i+1]){
        j=arr[i]
        arr[i]=arr[i+1]
        arr[i+1]=j
    }
}
}

console.log("%d %d %d",arr[0],arr[1],arr[2]);


Measured memory_bytes: 15348
import java.util.*;
import java.io.*;

public class Main {
	static int mod = (int) 1e9 + 7;
	static int DX[] = { -1, 0, 1, 0 }, DY[] = { 0, -1, 0, 1 };
	static final int INF = Integer.MAX_VALUE / 3;
	static final long LINF = Long.MAX_VALUE / 3;

	public static void main(String[] args) {
		FastScanner fs = new FastScanner(System.in);
		int m = fs.nextInt();
		int k = fs.nextInt();
		
		StringBuilder sb = new StringBuilder();
		if(k==0) {
			for(int i=0;i<(1<<m);i++) {
				sb.append(i + " " + i + " ");
			}
			System.out.println(sb.toString());
			return;
		}
		
		if(k>=(1<<m)) {
			System.out.println(-1);
			return;
		}
		
		int t = 0;
		for(int i=0;i<(1<<m);i++) {
			if(i==k)continue;
			t ^= i;
		}
		if(t != k) {
			System.out.println(-1);
			return;
		}
		
		sb.append(k + " ");
		for(int i=0;i<(1<<m);i++) {
			if(i==k)continue;
			sb.append(i + " ");
		}
		sb.append(k + " ");
		for(int i=(1<<m)-1; i>= 0; i--) {
			if(i==k)continue;
			sb.append(i + " ");
		}
		System.out.println(sb.toString());
	}

	//MOD culculations
	static long plus(long x, long y) {
		long res = (x + y) % mod;
		return res < 0 ? res + mod : res;
	}

	static long sub(long x, long y) {
		long res = (x - y) % mod;
		return res < 0 ? res + mod : res;
	}

	static long mul(long x, long y) {
		long res = (x * y) % mod;
		return res < 0 ? res + mod : res;
	}

	static long div(long x, long y) {
		long res = x * pow(y, mod - 2) % mod;
		return res < 0 ? res + mod : res;
	}

	static long pow(long x, long y) {
		if (y < 0)
			return 0;
		if (y == 0)
			return 1;
		if (y % 2 == 1)
			return (x * pow(x, y - 1)) % mod;
		long root = pow(x, y / 2);
		return root * root % mod;
	}
}

//高速なScanner
class FastScanner {
	private BufferedReader reader = null;
	private StringTokenizer tokenizer = null;

	public FastScanner(InputStream in) {
		reader = new BufferedReader(new InputStreamReader(in));
		tokenizer = null;
	}

	public String next() {
		if (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				tokenizer = new StringTokenizer(reader.readLine());
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken();
	}

	public String nextLine() {
		if (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				return reader.readLine();
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken("\n");
	}

	public long nextLong() {
		return Long.parseLong(next());
	}

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

	public double nextDouble() {
		return Double.parseDouble(next());
	}

	public int[] nextIntArray(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = nextInt();
		return a;
	}

	public long[] nextLongArray(int n) {
		long[] a = new long[n];
		for (int i = 0; i < n; i++)
			a[i] = nextLong();
		return a;
	}
}

Measured memory_bytes: 47576
#include<iostream>
#include<string>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
using namespace std;


int del(string s){
	bool hoge=true;
	string temp;
	while(hoge){
		hoge=false;
		int dt[s.size()];
		rep(i,s.size())dt[i]=0;
		rep(i,s.size()){
			if(i==0)dt[i]=1;
			else{
				if(s[i-1]==s[i])dt[i]=dt[i-1]+1;
				else dt[i]=1;
			}
		}
		temp="";
		for(int i=s.size()-1;i>=0;i--){
			if(dt[i]>3){
				hoge=true;
				i-=dt[i];
				i++;
			}else temp+=s[i];
		}
		s=temp;
	}
	return temp.size();
}

int func(string s){
	int mians=s.size();
	rep(p,s.size()){
		string alt=s;
		loop(c,1,4){
			alt[p]=(char)(c+'0');
			int left,right;left=right=p;
			while(alt[right]==alt[p])right++;
			while(alt[left]==alt[p])left--;
			if((right-1-left)<4)continue;
			mians=min(mians,del(alt));
		}
	}
	return mians;
}

int main(){
	int n;
	while(cin>>n,n){
		string s="";
		char ch;
		rep(i,n){cin>>ch;s+=ch;}
		cout<<func(s)<<endl;
	}
	return 0;
}

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

using namespace std;

int main(int argc, char const *argv[])
{
	int n;
	int tem;
	int sum;


	while(1){
		cin>>n;
		if(n==0) break;

		sum=0;
		vector<int> v;
		for(int i1=0; i1<n; i1++){
			cin>>tem;
			v.push_back(tem);
			sum+=tem;
		}
		sort(v.begin(), v.end());
		sum-=(v[0]+v[v.size()-1]);
		cout<<sum/(n-2)<<endl;
		
	}

	return 0;
}

Measured memory_bytes: 1220
#include <stdio.h>

int main() {
    int a[] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    int k;
    scanf("%d",&k);
    printf("%d\n",a[k-1]);
    return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin >> n;
    int h_ans=0,t_ans=0;
    for(int i=0;i<n;i++){
        string t,h;
        cin >> t >> h;
        if(t==h){
            h_ans+=1;
            t_ans+=1;
        }
        else if(t>h)t_ans+=3;
        else h_ans+=3;
    }  
    cout  << t_ans << " " << h_ans << endl;
}


Measured memory_bytes: 3200
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string s, t;
  cin >> s >> t;
  int ans = t.size();

  for (int i = 0; i < s.size(); i++) {
    if (i + t.size() > s.size()) continue; 
    int check = 0;
    for (int j = 0; j < t.size(); j++) {
      if (s.at(i + j) != t.at(j)) {
        check++;
      }
    }
    if (check < ans) ans = check; 
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 3616
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
typedef vector<int> vi;
#define rep(i,n) for(int i=0; i<n; i++)

int main(void) {
  int N;
  cin >> N;
  vi p(N);
  rep(i,N) {
    cin >> p[i];
  }
  vi sorted = p;
  sort(sorted.begin(), sorted.end());
  int count = 0;
  rep(i,N) {
    if(p[i] != sorted[i]) count++;
  }

  if(count == 2 || count == 0) cout << "YES" << endl;
  else cout << "NO" << endl;

  return 0;
}

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

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

    int n;
    cin >> n;
    vector<int> students(n);

    for (int i = 0; i < n; i++) {
        int num;
        cin >> num;
        students[num - 1] = i + 1;
    }

    for (int i = 0; i < n; i++) {
        cout << students[i];
        cout << (i != n - 1 ? " " : "\n");
    }
}

Measured memory_bytes: 1280
import bisect, copy, heapq, math
import sys
from collections import *
from functools import lru_cache
from itertools import accumulate, combinations, permutations, product
def input():
    return sys.stdin.readline()[:-1]
def ruiseki(lst):
    return [0]+list(accumulate(lst))
sys.setrecursionlimit(5000000)
mod=pow(10,9)+7
al=[chr(ord('a') + i) for i in range(26)]
direction=[[1,0],[0,1],[-1,0],[0,-1]]

n=int(input())
t=list(map(int,input().split()))
a=list(map(int,input().split()))

kakutei=[-1]*n
kakutei[0]=t[0]
kakutei[-1]=a[-1]
for i in range(n-1):
    if t[i]<t[i+1]:
        kakutei[i+1]=t[i+1]
    if a[-2-i]>a[-1-i]:
        kakutei[-2-i]=a[-2-i]
# print(kakutei)
ans=1
if n==1 and t[0]!=a[0]:
    ans=0
for i in range(n):
    if kakutei[i]>min(t[i],a[i]):
        ans=0

for i in range(n):
    if kakutei[i]==-1:
        ans*=min(t[i],a[i])
    ans%=mod

print(ans)

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

using namespace std;

string n, m;

int DP[3003][3003];

int main(void)
{
	
	cin >> n >> m;
	
	for(int i=1;i<=n.size();i++)
	{
		
		for(int j=1;j<=m.size();j++)
		{
			
			DP[i][j]=max(DP[i-1][j], DP[i][j-1]);
			
			if( n[i-1]==m[j-1] )
			{
				
				DP[i][j]=max(DP[i-1][j-1]+1, DP[i][j] );
				
			}
			
		}
		
	}

	string wynik;
	
	int p=0;
	
	int i=n.size();
	int j=m.size();
	
	while( i>0 && j>0 )
	{
		
		if (n[i-1]==m[j-1] && DP[i][j] == DP[i-1][j-1]+1)
		{
			
			wynik += n[i-1];
			i--;
			j--;
			
		}
		else
		{
			
			if( DP[i][j]==DP[i-1][j] )
			{
				
				i--;
				
			}
			else
			{
				
				j--;
			}
			
		}
		
	}
	
	reverse(wynik.begin(), wynik.end());
	
	cout << wynik;
	
	return(0);
	
}

Measured memory_bytes: 35456
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <queue>
#include <string>
#include <set>
#include <bitset>
#include <unordered_map>
#include <cmath>

using namespace std;
using ll = long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;
template <class T>
using Vvec = vector<vector<T> >;

const double pi = 4*atan(1);

int main()
{
    double a, b, x;
    cin >> a >> b >> x;

    if(2*x<=a*a*b){
        double t = 2.0 * x / a / b;
        printf("%.8f\n", atan(b/t)*180.0/pi);
    }
    else{
        double t = (a*a*b-x) / a / a * 2.0;
        printf("%.8f\n", atan(t/a)*180.0/pi);
    }
}

Measured memory_bytes: 256
def main():
	c1 = input()
	c2 = input()
	
	if c1[0] == c2[-1] and c1[1] == c2[1] and c1[-1] == c2[0]:
	    print("YES")
	else:
	    print("NO")
        
if __name__ == "__main__": main()

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define fastio ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define range(i,l,h) for(int i=l;i<h;i++)
#define endl '\n'
#define I INT_MAX
#define L INT_MIN
#define all(c) (c).begin(), (c).end()
#define pb push_back
#define ll long long
#define ull unsigned long long
#define vi vector<int>
#define vt vector
using namespace std;
using std::ios;
constexpr int MOD=1e9+7;
constexpr int mod=998244353;
const int mxn=200005;

map<ll,ll> f;

void fact(ll a)
{
  for(int i=2;i*i<=a;i++)
  {
    if(a%i==0)
    {
      while(a%i==0)
      {
        a/=i;
      }
      f[i]++;
    }
  }
  if(a!=1)f[a]++;
}


int main()
{
  int n;
  cin>>n;
  vt<ll> a(n);
  range(i,0,n)
  {
    cin>>a[i];
  }

  bool ok=1;

  range(i,0,n)
  {
    fact(a[i]);
  }

  for(auto i:f)
  {
    if(i.second>1)
    {
      ok=0;
      break;
    }
  }

  int pc=0;
  
  if(ok)
  {
    cout<<"pairwise coprime";
  }
  else 
  {
    ll hcf=a[0];
    range(i,1,n)
      hcf=__gcd(a[i],hcf);
    if(hcf==1)
    cout<<"setwise coprime";
    else 
      cout<<"not coprime";
  } 

}


Measured memory_bytes: 15848
n,m,c=map(int,input().split())
b=[int(i) for i in input().split()]
ans=0
for i in range(n):
    a=[int(i) for i in input().split()]
    su=[a[i]*b[i] for i in range(m)]
    if sum(su)+c>0:
        ans+=1
print(ans)

Measured memory_bytes: 3060
#include<iostream>
#define ll long long
using namespace std;
int main(){
	ll int N,a[104],b[104],i,cnt,flag;
	cin>>N;
	for(i=0;i<N;i++){
	cin>>a[i]>>b[i];}
	cnt=0;flag=0;
	for(i=0;i<N;i++){
		if(a[i]==b[i]) cnt++;
		else cnt=0;
	if(cnt==3) flag=1;}
	if(flag) cout<<"Yes";
	else cout<<"No";
return 0;}

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

using namespace std;
typedef long long ll;

bool check(int i, int t ,vector<vector<int> > &s) {
    for (int j = 0; j < 20; j++) {
        if (s[t+1][j] - s[i][j] > 1)
            return false;
    }
    return true;
}

int main() {
    int n;  cin >> n;
    vector<ll> a(n);
    for (int i = 0; i < n; i++)
        cin >> a[i];

    vector<vector<int> > b(n, vector<int>(20, 0)), s(n+1, vector<int>(20, 0));
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < 20; j++) {
            b[i][j] = a[i] % 2;
            a[i] /= 2;
            s[i+1][j] = s[i][j] + b[i][j];
        }
    }
    
    long long ans = 0, t = 0;
    for (int i = 0; i < n; i++) {
        while (t+1 < n && check(i, t+1, s))
            t++;

        ans += t-i+1;
    }

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 51824
a, b = map(int, input().split())
c, d = a, b
l = []
m = []
n = []
t = 0
while b > 0:
    l.append(b%2)
    b //= 2
k = len(l)
for i in range(k):
    m.append(a%2)
    a //= 2
if d%2 == 1:
    l = [0]*(k)
if c%2 == 0:
    m = [0]*(k)
for i in range(k):
    n.append((l[i]+m[i])%2)
c = (c+1)//2*2
d = (d+1)//2*2
if (d-c)%4 == 2 or (d-c)%4 == 3:
    n[0] = (n[0]+1)%2
for i in range(k):
    t += n[i]*(2**i)
print(t)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPS(i, n) for(int i = 1, i##_len = (n); i < i##_len; ++i)
#define ALL(x) (x).begin(), (x).end()
#define PRINT(A) std::cout << (#A) << ":" << (A) << std::endl;
using namespace std;
#define repi(itr, ds) for(auto itr = ds.begin(); itr != ds.end(); itr++)

// vector
template <typename T>
istream &operator>>(istream &is, vector<T> &vec) {
  for(T &x : vec) is >> x;
  return is;
}
// pair
template <typename T, typename U>
ostream &operator<<(ostream &os, pair<T, U> &pair_var) {
  os << "(" << pair_var.first << ", " << pair_var.second << ")";
  return os;
}
// vector
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
  os << "{";
  for(int i = 0; i < vec.size(); i++) {
    os << vec[i] << (i + 1 == vec.size() ? "" : ", ");
  }
  os << "}\n   ";
  return os;
}
// map
template <typename T, typename U>
ostream &operator<<(ostream &os, map<T, U> &map_var) {
  os << "{";
  repi(itr, map_var) {
    os << *itr;
    itr++;
    if(itr != map_var.end()) os << ", ";
    itr--;
  }
  os << "}";
  return os;
}
// set
template <typename T>
ostream &operator<<(ostream &os, set<T> &set_var) {
  os << "{";
  repi(itr, set_var) {
    os << *itr;
    itr++;
    if(itr != set_var.end()) os << ", ";
    itr--;
  }
  os << "}";
  return os;
}

#define DUMPOUT cerr

void dump_func() { DUMPOUT << endl; }
template <class Head, class... Tail>
void dump_func(Head &&head, Tail &&... tail) {
  DUMPOUT << head;
  if(sizeof...(Tail) > 0) {
    DUMPOUT << ", ";
  }
  dump_func(std::move(tail)...);
}
#ifdef DEBUG_
#define DEB
#define dump(...)                                                             \
  DUMPOUT << "  " << string(#__VA_ARGS__) << ": "                             \
          << "[" << to_string(__LINE__) << ":" << __FUNCTION__ << "]" << endl \
          << "    ",                                                          \
      dump_func(__VA_ARGS__)
#else
#define DEB if(false)
#define dump(...)
#endif

typedef long long int ll;
const int MOD = 1e9 + 7;
const int INF = 1e9;

int main() {
  int N;
  string S1, S2;
  cin >> N >> S1 >> S2;

  vector<int> pattern = vector<int>();  // 0 -> タテ, 1 -> ヨコ
  REP(i, N) {
    if(S1[i] == S2[i]) {
      pattern.push_back(0);
    } else {
      pattern.push_back(1);
      i++;
    }
  }

  int prev = -1;
  ll ans = 1;
  for(auto p : pattern) {
    if(prev == -1) {
      if(p == 0) {
        ans = 3;
      } else {
        ans = 6;
      }
    } else if(prev == 0) {
      ans = ans * 2 % MOD;
    } else {
      if(p == 1) {
        ans = ans * 3 % MOD;
      }
    }
    prev = p;
  }
  cout << ans << endl;
}


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

int main() {
 string S;
 int ans=0;
 cin >> S;
 for(int i=0;i<4;i++){
   if(S[i]=='+'){
    ans++;
   }
   else{
    ans--;
   }
 }
  
 cout << ans << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
	int a,b,c,t;
	scanf("%d%d%d",&a,&b,&c);
	if(a>b){t=a;a=b;b=t;}
	if(b>c){t=b;b=c;c=t;}
	if(a>b){t=a;a=b;b=t;}
	printf("%d\n",c-a);
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define all(v) v.begin(), v.end()
#define vl vector<ll>
#define vi vector<int>
#define pii pair<int,int>
#define pb push_back
#define ff first
#define ss second
ll INF = 1e9;
const int N=100005;
ll w[N]{},dp[N]{},v[N]{};
void solve()
{
    ll n,k=1,m=0,i=1,j,x,y,l,r,z;
    ll ans=0,sum,weight=0;
    cin>>n>>weight;
    for(i=0;i<n;i++) cin>>w[i]>>v[i];
    for(i=0;i<weight;i++) dp[i]=-1;
    dp[0]=0;
    for(i=0;i<n;i++)
    {
        for(j=weight;j>=w[i];j--)
        {
            if(dp[j-w[i]]!=-1)
            dp[j]=max(dp[j],dp[j-w[i]]+v[i]);
        }
    }
    for(i=0;i<=weight;i++) ans=max(ans,dp[i]);
    cout<<ans;
}
int main()
{
    ios::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
     #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin) ;
    freopen("output.txt", "w", stdout) ;
    #endif 
    int t=1;
    //cin>>t;
    while(t--)solve();
    return 0;
}

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

int main() {
    int N;
    cin >> N;
    map<int, int> a;
    for(int i = 0; i<N; i++) {
        int x;
        cin >> x;
        a[x]++;
        a[x + 1]++;
        a[x - 1]++;
    }
    int res = 0;
    for(auto s : a) {
        res = max(res, s.second);
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 4736
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<(n);++i)
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; }
int gcd(int a,int b) { return b ? gcd(b,a%b) : a;}
int lcm(int a,int b) { return a/gcd(a,b)*b;}
void printb(unsigned int v) {
  unsigned int mask = (int)1 << (sizeof(v) * CHAR_BIT - 1);
  do putchar(mask & v ? '1' : '0');
  while (mask >>= 1);
}
void putb(unsigned int v) {putchar('0'), putchar('b'), printb(v), putchar('\n');}
#define ALL(W) (W).begin(),(W).end()

signed main(){
  int N,K;
  cin >> N >> K;
  map<int,int> mp;
  rep(i,N){
    int a;
    cin >> a;
    mp[a]++;
  }
  int A[N]={},c=0;
  for (auto p: mp) {
		int x = p.first;
		int n = p.second;
    A[c]=n;
    c++;
	}
  sort(A,A+c);
  if(c-K<=0){
    cout << 0 << endl;
    return 0;
  }
  int ans=0;
  rep(i,c-K) ans+=A[i];
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 14336
#include<bits/stdc++.h>
using namespace std;
#define MAXN 200005
#define INF 0x3f3f3f3f
#define MS(x, i) memset(x, i, sizeof x)
#define debug(x) cout << #x << ": " << x << endl
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define MOD 1000000007
#define NOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;


int a[MAXN];
int dp[MAXN];

inline ll read() {
    ll ret = 0, sgn = 1;
    char ch = getchar();
    while(ch < '0' || ch > '9'){
        if(ch == '-') sgn = -1;
        ch = getchar();
    }
    while (ch >= '0' && ch <= '9'){
        ret = ret*10 + ch - '0';
        ch = getchar();
    }

    return ret*sgn;
}

int main()
{
     NOS
    int n;
    cin >> n;
    map<string, int> mp;

    int maxnum = -1;
    for(int i = 0; i < n; i++)
    {
        string s;
        cin >> s;
        mp[s]++;

        maxnum = max(maxnum, mp[s]);
    }

    map<string, int>::iterator it;
    for(it = mp.begin(); it != mp.end(); it++)
    {
        if(it->second == maxnum)
            cout << it->first << endl;
    }
}


Measured memory_bytes: 23808
#include<bits/stdc++.h>
using namespace std;
int a[107];
int b[107];
int main(){
    int n;
    scanf("%d",&n);
    int cnt=0;
    int flag=0;
    for(int i=1;i<=n;i++){
        scanf("%d",&a[i]);
        if(a[i]>i)
            flag=1;
        if(!b[a[i]])
            b[a[i]]=a[i];
        else{
            for(int j=i-1;j>=a[i];j--){
                b[j+1]=b[j];
            }
            b[a[i]]=a[i];
        }
    }
    if(!flag){
        for(int i=1;i<=n;i++){
            printf("%d\n",b[i]);
        }
    }
    else
        printf("-1");
    return 0;
}


Measured memory_bytes: 256