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

typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define REP(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) std::cout << x << '\n'
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define sz(x) ((int)(x).size())
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { ll g = gcd(a, b); return a / g * b; }
const int dx[4] = { 1, 0, -1,  0 };
const int dy[4] = { 0, 1,  0, -1 };
const int INF = INT_MAX / 2;
const ll  inf = LLONG_MAX / 2;
const int mod = 1000000007;
const int MAX_N = 101010;
const long double PI = acos(-1);

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(10);
	/*------------------------------*/

	int n;
	cin >> n;
	string s;
	cin >> s;

	int ans = 0;
	for (int i = 1; i < n; i++) {
		int cnt = 0;
		for (int a = 0; a < 26; a++) {
			bool l = false, r = false;
			for (int j = 0; j < i; j++) {
				if (s[j] == a + 'a') {
					l = true;
				}
			}
			for (int j = i; j < n; j++) {
				if (s[j] == a + 'a') {
					r = true;
				}
			}
			if (l && r) {
				cnt++;
			}
		}
		chmax(ans, cnt);
	}

	out(ans);

	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
char st[200010];
int main()
{
  scanf("%s",st);
  long long num=0;
  for (int i=0;st[i];++i){
    num = num+st[i]-'0';
    num%=9;
  }
  if (num%9==0)
    printf("Yes");
  else
    printf("No");
}

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

using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
typedef long long ll;

int main(){
  string s;
  cin >> s;
  int asn = 0;
  if(s[0]!=s[1] && s[1]!=s[2] && s[0]!=s[2])cout << "Yes" << endl;
  else cout << "No" << endl;
}


Measured memory_bytes: 256
val =input().split(" ")
n,m =[int(i) for i in val]

a=[]
b=[]

for i in range(n):
    val1=input().split(" ")
    val2=[int(j) for j in val1]
    a.append(val2)


for i in range(m):
    b.append(int(input()))


c = int(0)


for i in range(n):
    for j in range(m):
        c += a[i][j]*b[j]
        
    print(c)
    c = 0



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

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

ans = 0
pre = -1
for a in A:
    ans += B[a-1]
    if pre + 1 == a:
        ans += C[pre-1]
    pre = a

print(ans)



Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
using namespace std;

typedef long long ll;

int n;
int c[100003];
int ans;

int main() {
	cin >> n;
	int a;
	for (int i = 0; i < n; ++i) {
		cin >> a;
		++c[a]; ++c[a + 1]; ++c[a + 2];
	}
	for (int i = 0; i <= 100002; ++i) {
		ans = max(ans, c[i]);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 640
#include "bits/stdc++.h"

#define ALL(g) (g).begin(),(g).end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i, x, n) for(int i = x; i >= n; i--)
#define rrep(i, n) RREP(i,n,0)
#define pb push_back
#pragma GCC optimize ("-O3")

using namespace std;

// #define DEBUG_IS_VALID

#ifdef DEBUG_IS_VALID
#define DEB 1 
#else
#define DEB 0
#endif
#define DUMPOUT cout
#define dump(...) if(DEB) DUMPOUT<<"  "<<#__VA_ARGS__<<" :["<<__LINE__<<":"<<__FUNCTION__<<"]"<<endl<<"    "; if(DEB) dump_func(__VA_ARGS__)
template<typename T1,typename T2>ostream& operator << (ostream& os, pair<T1,T2> p){cout << "(" << p.first << ", " << p.second << ")"; return os;}
template<typename T>ostream& operator << (ostream& os, vector<T>& vec) { os << "{"; for (int i = 0; i<vec.size(); i++) os << vec[i] << (i + 1 == vec.size() ? "" : ", "); os << "}"; return os; }
template<typename T>ostream& operator << (ostream& os, set<T>& st){for(auto itr = st.begin(); itr != st.end(); itr++) cout << *itr << (next(itr)!=st.end() ? ", " : ""); cout << "}"; return os;}
template<typename T1,typename T2>ostream& operator << (ostream& os, map<T1,T2> mp){cout << "{"; for(auto itr = mp.begin(); itr != mp.end(); itr++) cout << "(" << (itr->first) << ", " << (itr->second) << ")" << (next(itr)!=mp.end() ? "," : ""); cout << "}"; return os; }

void dump_func(){DUMPOUT << endl;}
template <class Head, class... Tail>void dump_func(Head&& head, Tail&&... tail){ DUMPOUT << head; if (sizeof...(Tail) == 0) { DUMPOUT << " "; } else { DUMPOUT << ", "; } dump_func(std::move(tail)...);}
template<class T> inline bool chmax(T& a,T const& b){if(a>=b) return false; a=b; return true;}
template<class T> inline bool chmin(T& a,T const& b){if(a<=b) return false; a=b; return true;}

using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;

const int mod=1e9+7,INF=1<<29;
const double EPS=1e-12,PI=3.1415926535897932384626;
const ll lmod = 1e9+7,LINF=1LL<<59; 

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int H,W; cin >> H >> W ;
  vvl a(H,vl(W));
  rep(i,H) rep(j,W) cin >> a[i][j] ;
  int N = H + W;
  vector<vvl> dp(N-1,vvl(H,vl(H,-1)));
  dp[0][0][0] = a[0][0];
  rep(i,N-2) rep(x1,H) rep(x2,H){
    if(dp[i][x1][x2]==-1) continue;
    rep(s,2) rep(t,2){
      int nx1,ny1,nx2,ny2;
      nx1 = x1+s;
      ny1 = i+1-nx1;
      nx2 = x2+t;
      ny2 = i+1-nx2;
      if(!(nx1<H && ny1<W && nx2<H && ny2<W)) continue;
      if(nx1==nx2 && ny1==ny2) chmax(dp[i+1][nx1][nx2],dp[i][x1][x2]+a[nx1][ny2]);
      else chmax(dp[i+1][nx1][nx2],dp[i][x1][x2]+a[nx1][ny1]+a[nx2][ny2]);
    }
  }
  dump(dp);
  cout << dp[N-2][H-1][H-1] << endl;
  return 0;
}


Measured memory_bytes: 128768
#define DEBUG 0

#include <bits/stdc++.h>
using namespace std;

#if DEBUG
// basic debugging macros
int __i__,__j__;
#define printLine(l) for(__i__=0;__i__<l;__i__++){cout<<"-";}cout<<endl
#define printLine2(l,c) for(__i__=0;__i__<l;__i__++){cout<<c;}cout<<endl
#define printVar(n) cout<<#n<<": "<<n<<endl
#define printArr(a,l) cout<<#a<<": ";for(__i__=0;__i__<l;__i__++){cout<<a[__i__]<<" ";}cout<<endl
#define print2dArr(a,r,c) cout<<#a<<":\n";for(__i__=0;__i__<r;__i__++){for(__j__=0;__j__<c;__j__++){cout<<a[__i__][__j__]<<" ";}cout<<endl;}
#define print2dArr2(a,r,c,l) cout<<#a<<":\n";for(__i__=0;__i__<r;__i__++){for(__j__=0;__j__<c;__j__++){cout<<setw(l)<<setfill(' ')<<a[__i__][__j__]<<" ";}cout<<endl;}

// advanced debugging class
// debug 1,2,'A',"test";
class _Debug {
    public:
        template<typename T>
        _Debug& operator,(T val) {
            cout << val << endl;
            return *this;
        }
};
#define debug _Debug(),
#else
#define printLine(l)
#define printLine2(l,c)
#define printVar(n)
#define printArr(a,l)
#define print2dArr(a,r,c)
#define print2dArr2(a,r,c,l)
#define debug
#endif

// define
#define MAX_VAL 999999999
#define MAX_VAL_2 999999999999999999LL
#define EPS 1e-6
#define mp make_pair
#define pb push_back

// typedef
typedef unsigned int UI;
typedef long long int LLI;
typedef unsigned long long int ULLI;
typedef unsigned short int US;
typedef pair<int,int> pii;
typedef pair<LLI,LLI> plli;
typedef vector<int> vi;
typedef vector<LLI> vlli;
typedef vector<pii> vpii;
typedef vector<plli> vplli;

// ---------- END OF TEMPLATE ----------
#define MOD 998244353

char S[300000];
deque<int> pos[3];
vpii v[2];
int main() {
    int i;
    int N;
    scanf("%d",&N);
    for (i = 0; i < 3*N; i++) scanf(" %c",&S[i]);

    int j,r = 0,g = 0,b = 0;
    LLI ways = 1;
    for (i = 0; i < 3*N; i++) {
        if (S[i] == 'R') r++,pos[0].pb(i);
        else if (S[i] == 'G') g++,pos[1].pb(i);
        else b++,pos[2].pb(i);
        if ((r >= 1) && (g >= 1) && (b >= 1)) {
            vpii z;
            z.pb(mp(pos[0][0],0));
            z.pb(mp(pos[1][0],1));
            z.pb(mp(pos[2][0],2));
            sort(z.begin(),z.end());
            v[0].pb(mp(z[1].first,1)),v[0].pb(mp(z[2].first,-1));
            v[1].pb(mp(z[0].first,1)),v[1].pb(mp(z[1].first,-1));
            r--,g--,b--;
            pos[0].pop_front(),pos[1].pop_front(),pos[2].pop_front();
        }
    }
    for (i = 0; i < 2; i++) {
        int c = 0;
        sort(v[i].begin(),v[i].end());
        for (j = 0; j < v[i].size(); j++) {
            if (v[i][j].second == 1) c++;
            else ways *= c,ways %= MOD,c--;
        }
    }
    for (i = 1; i <= N; i++) ways *= i,ways %= MOD;
    printf("%lld\n",ways);

    return 0;
}



Measured memory_bytes: 4716
#include <bits/stdc++.h>
using namespace std;
int n,m,s[500005],l[500005],r[500005],ans;vector<int>v[500005];
void add(int x,int v){for(;x<=m;x+=x&-x) s[x]+=v;}
int que(int x){int r=0;for(;x;x-=x&-x) r+=s[x];return r;}
int main()
{
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++) scanf("%d%d",&l[i],&r[i]),v[r[i]-l[i]+1].push_back(i);
	for(int i=1;i<=m;i++,ans=0)
	{
		for(int j=0;j<v[i].size();j++) add(l[v[i][j]],1),add(r[v[i][j]]+1,-1);
		for(int j=i;j<=m;j+=i) ans+=que(j);
		n-=v[i].size();printf("%d\n",ans+n);
	}
}

Measured memory_bytes: 20352
#include <cstdio>
#include <cstring>
#include <ctime>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <string>
#include <queue>
#include <map>
#include <stack>
#include <vector>
#include <algorithm>
#include <set>
#include <deque>
#include <utility>
#include <chrono>
#include <sstream>
#include <iomanip>
#define INF 1 << 30
#define MOD 1000000007;
#define pi 3.14159265358979
#define rep(i, n) for (int (i) = 0; (i) < (int)(n); (i)++)
#define rer(i, l, r) for (int (i) = (int)(l); (i) <= (int)(r); (i)++)
#define reu(i, l, r) for (int (i) = (int)(l); (i) < (int)(r); (i)++)
#define D(x) cout << x << endl
#define d(x) cout << x
#define all(x) (x).begin(), (x).end()
#define pub(x) push_back(x)
#define pob() pop_back()
#define puf(x) push_front(x)
#define pof() pop_front()
#define mp(x, y) make_pair((x), (y))
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<long long> vll;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef pair<long, long> pll;
template<typename T, typename U> inline void amin(T &x, U y) { if (y < x) x = y; }
template<typename T, typename U> inline void amax(T &x, U y) { if (x < y) x = y; }
static const int dx[] = {0, 0, 1, -1};
static const int dy[] = {-1, 1, 0, 0};

int main() { 
  int a;
  cin >> a;
  if (a < 1200) {
    D("ABC");
  } else {
    D("ARC");
  }
  return 0;
}



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

const int MAX_POINTS = 100001;

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

	int t[MAX_POINTS], x[MAX_POINTS], y[MAX_POINTS];
	t[0] = x[0] = y[0] = 0;
	for ( int i = 0; i < N; ++i ) {
		cin >> t[i + 1] >> x[i + 1] >> y[i + 1];
	}

	bool can = true;
	int diff, dt;
	for ( int i = 0; i < N; ++i ) {
		diff = ::abs( x[i + 1] - x[i] ) + ::abs( y[i + 1] - y[i] );
		dt = t[i + 1] - t[i];

		if ( dt < diff || ( diff % 2 ) != ( dt % 2 ) ) {
			can = false;
			break;
		}
	}
	cout << ( can ? "Yes" : "No" ) << endl;
	return 0;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
#include <vector>
#include <string>
#include <map>
using namespace std;

int main(){
  int a,b,c,d,e,k;
  cin >> a >>b >> c >> d >> e >> k;
  if(b - a <= k &&
  c - a <= k &&
  d - a <= k &&
  e - a <= k &&
  c - b <= k &&
  d - b <= k &&
  e - b <= k &&
  d - c <= k &&
  e - c <= k &&
  e - d <= k )cout << "Yay!" << endl;
  else cout << ":(" <<endl;

}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main(void){
    int a,b,c ;
    scanf ("%d%d%d",&a,&b,&c) ;
    for (int i=1; i>0; i++){
        if (a*i%b==c) {
            printf ("YES\n") ;
            exit (0) ;
        }
        if (i>1 && a*i%b==a%b){
            printf ("NO\n") ;
            exit (0) ;
        }
    }
    return 0 ;
}

Measured memory_bytes: 128
#include <iostream>

int main(){
    using namespace std;

    while( true ){
        int a;
        int b;
        char op;
        cin >> a >> op >> b;
        
        if( op == '?' ){ break; }

        int answer = 0;
        if( op == '+' ){
            answer = a + b;
        }else if( op == '-' ){
            answer = a - b;
        }else if( op == '*' ){
            answer = a * b;
        }else if( op == '/' ){
            answer = a / b;
        }

        cout << answer << endl;
    }
    
    return 0;
}

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

int main()
{
  ll N;
  cin >> N;
  string S;
  cin >> S;
  string T;
  cin >> T;
  for (int i=0; i<N; i++) {
    cout << S[i] << T[i];
  }
  cout << 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;
using ll = long long;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll N;
  cin >> N;
  ll nm = 0;
  ll abmn = 1e18;
  ll ans = 0;
  vector<int> A(N);
  REP(i, N) cin >> A[i];
  for(ll i = 0; i < N; i++) {
    if(A[i] < 0) nm++;
    ll tmp = abs(A[i]);
    abmn = min(abmn, tmp);
  }
  for(ll i = 0; i < N; i++) {
    ans += abs(A[i]);
  }
  if(nm % 2 != 0) { ans -= abmn * 2; }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
#define ll long long
#define Test int t;cin>>t;while(t--)
#define PI acos(-1)
#define endl "\n"
#define fx(x) fixed<<setprecision(x)
#define sz(s) s.size()
#define all(v) (v).begin(),(v).end()
#define allr(v) (v).rbegin(),(v).rend()
const double eps=1e-9;
const int mod=1e9+7;
int dx[]={-1,-1,-1,0,0,1,1,1};
int dy[]={-1,0,1,-1,1,-1,0,1};
ll gcd(ll x,ll y) {return(!y)?x:gcd(y,x%y);}
ll lcm(ll x,ll y) {return((x/gcd(x,y))*y);}
using namespace std;
void fast(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
}
int n,w;
vector<pair<ll,ll> >v;
ll dp[101][100001];
ll solve(int idx,int we){
    if(idx==n)return 0;
    ll &ret=dp[idx][we];
    if(ret){return ret;}
    ret=solve(idx+1,we);
    if(v[idx].second+we<=w)ret=max(ret,v[idx].first+solve(idx+1,v[idx].second+we));
    return ret;
}
int main()
{
    cin>>n>>w;
    v.resize(n);
    for(int i=0;i<n;i++){
        cin>>v[i].second>>v[i].first;
    }
    cout<<solve(0,0);
    return 0;
}


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

struct RA {
	using type1 = ll;
	using type2 = ll;
	static type1 id1() { return 0; }
	static type2 id2() { return 0; }
	static type1 op1(const type1& l, const type1& r) { return l + r; }
	static type1 op2(const type1& l, const type2& r) { return l + r; }
	static type2 op3(const type2& l, const type2& r) { return l + r; }
};

template <typename M>
class LazySegmentTree {
	using T1 = typename M::type1;
	using T2 = typename M::type2;
	const int n;
	vector<T1> data;
	vector<T2> lazy;
	int size(int n) {
		int res = 1;
		while (res < n) res <<= 1;
		return res;
	}
	void push(int node) {
		if (lazy[node] == M::id2()) return;
		if (node < n) {
			lazy[node * 2] = M::op3(lazy[node * 2], lazy[node]);
			lazy[node * 2 + 1] = M::op3(lazy[node * 2 + 1], lazy[node]);
		}
		data[node] = M::op2(data[node], lazy[node]);
		lazy[node] = M::id2();
	}
	void suc(int l, int r, int node, int lb, int ub, T2 val) {
		if (ub <= l || r <= lb) return;
		if (l <= lb && ub <= r) {
			lazy[node] = M::op3(lazy[node], val);
			return;
		}
		push(node);
		int c = (lb + ub) / 2;
		suc(l, r, node * 2, lb, c, val);
		suc(l, r, node * 2 + 1, c, ub, val);
		data[node] = M::op1(M::op2(data[node * 2], lazy[node * 2]), M::op2(data[node * 2 + 1], lazy[node * 2 + 1]));
	}
	T1 sub(int l, int r, int node, int lb, int ub) {
		if (ub <= l || r <= lb) return M::id1();
		if (l <= lb && ub <= r) return M::op2(data[node], lazy[node]);
		push(node);
		int c = (lb + ub) / 2;
		return M::op1(sub(l, r, node * 2, lb, c), sub(l, r, node * 2 + 1, c, ub));
	}
public:
	LazySegmentTree(int n_) : n(size(n_)), data(n * 2, M::id1()), lazy(n * 2, M::id2()) {}
	void update(int l, int r, T2 val) {
		suc(l, r + 1, 1, 0, n, val);
	}
	T1 find(int l, int r) {
		return sub(l, r + 1, 1, 0, n);
	}
};

int main()
{
	ios::sync_with_stdio(false), cin.tie(0);
	int n, q, type, s, t, x;
	cin >> n >> q;
	LazySegmentTree<RA> lst(n);
	while (q--) {
		cin >> type;
		if (type) {
			cin >> x; x--;
			printf("%lld\n", lst.find(x, x));
		}
		else {
			cin >> s >> t >> x; s--, t--;
			lst.update(s, t, x);
		}
	}
	return 0;
}

Measured memory_bytes: 6976
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> iint;
typedef pair<ll,ll> llll;
#define ALL(x) (x).begin(),(x).end()
const ll zero = 0;
const ll one = 1;
const ll INF = 9223372036854775807; //10^18
const int inINF = 2147483647; //10^9
const ll MOD = 1000000007; //10^9+7
const ll MOD2 = 998244353;
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

int main(){
    ll N;
    cin >> N;
    ll ans;
    for (ll i = 1; i*i <= N; i++) {
        if(N % i == 0){
            ans = i;
        }
    }
    printf("%lld\n", ans + N / ans - 2);

}

Measured memory_bytes: 3760
#include "bits/stdc++.h"
using namespace std;
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define ll long long int
#define int ll
// #define double long double
//#define slld(t) scanf("%lld",&t)
//#define sd(t) scanf("%d",&t)
//#define pd(t) printf("%d\n",t)
//#define plld(t) printf("%lld\n",t)
#define vec vector < int >
#define vecp vector < pair < int , int > >
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define debug(x)   cerr<<#x<<": "<<x<<endl
#define pii pair < int , int >
#define pll pair < ll , ll > 
#define debug(x)   cerr<<#x<<": "<<x<<endl
#define mod  1000000007
#define N   100005
#define MAX 300005
#define mod1 1000000007
#define mod2 998244353
#define bitcnt __builtin_popcountll
#define PI acos(-1)
//#define endl "\n"
#define inf 1e+15

signed main(){
  fast;
 int x ,y , z;
 cin>>x>>y>>z;
 int ans = min(x+y , y+z);
 ans = min(ans , z+x);
 cout<<ans<<endl;
}
  


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

int main() {
    ll w,h,x,y;
    cin >> w >> h >> x >> y;
    double s=w*h/2.0;
    int flag = (x*2==w && y*2==h) ? 1 : 0;
    cout << s << ' ' << flag << endl;
}

Measured memory_bytes: 256
n = int(input())
c = input()
c = list(c)
r = 0
w = 0
for i in range(n):
    if c[i] == 'R':
        r += 1
    else:
        w += 1
ans = min(r,w)
t = 0
v = 0
for i in range(ans):
    if c[i] == 'R':
        t -= 1
for i in range(ans):
    if c[n-i-1] == 'W':
        v -= 1
if r <= w:
    ans = ans + t
else:
    ans = ans + v
print(ans)

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

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



Measured memory_bytes: 4836
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<map>
#include<algorithm>
using namespace std;
map <pair<string,string>,int> mp;
int main()
{
	int n;
	long long ans=0;
	string s,a,b;
	cin>>n;
	cin>>s;
	mp.clear();
	for(int i=0;i<(1<<n);i++)
	{
		a="";
		b="";
		for(int j=0;j<n;j++)
			if(i&(1<<j))
				a+=s[j];
			else
				b+=s[j];
		mp[make_pair(a,b)]++;
	}
	for(int i=0;i<(1<<n);i++)
	{
		a="";
		b="";
		for(int j=1;j<=n;j++)
			if(i&(1<<j))
				a+=s[n+n-j];
			else
				b+=s[n+n-j];
		ans+=mp[make_pair(a,b)];
	}
	printf("%lld",ans);
	return 0;
}

Measured memory_bytes: 69376
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;

public class Main {

	public static void main(String[] args) throws IOException {

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		try {

			int[] height = new int[10];

			for (int i = 0; i < 10; i++) {

				height[i] = Integer.parseInt(br.readLine());

			}

			Arrays.sort(height);

			for (int j = 9; j > 6; j--) {
				System.out.println(height[j]);
			}

		} finally {
			br.close();
		}

	}
}

Measured memory_bytes: 17032
// https://atcoder.jp/contests/agc002/tasks/agc002_b

#include <algorithm>
#include <cmath>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <tuple>
#include <vector>
using namespace std;

typedef long long ll;
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, m;
    cin >> n >> m;
    vector<int> v(n + 1, 1); //各箱にあるボースの数
    set<int> st; //赤いボールがある可能性のある箱番号
    // 赤いボールは1番にあり
    st.insert(1);

    for (int i = 0; i < m; i++) {
        int x, y;
        cin >> x >> y;
        v[x]--;
        v[y]++;
        if (st.count(x) == 1) {
            if (v[x] == 0) {
                st.erase(x);
            }
            st.insert(y);
        }
    }

    cout << st.size() << endl;

    return 0;
}

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

using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;

#define fi first
#define se second

const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll MOD3 = 1812447359;
const ll INF = 1ll << 62;
const double PI = 2 * asin(1);

void yes() {printf("yes\n");}
void no() {printf("no\n");}
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

int N, M;
vector <int> Graph[int(1e5+5)];
bool visited[int(1e5+5)];
int DP[int(1e5+5)];

int Solve(int num){
  if (visited[num]) return DP[num];

  visited[num] = true;
  int ans = 0;
  for (int i = 0; i < Graph[num].size(); i++){
    int next = Graph[num][i];
    ans = max(ans, Solve(next) + 1);
  }
  return DP[num] = ans;
}

int main(){
  cin >> N >> M;
  for (int i = 0; i < M; i++){
    int X, Y; cin >> X >> Y;
    Graph[X].push_back(Y);
  }

  int ans = 0;
  for (int i = 1; i <= N; i++){
    ans = max(ans, Solve(i));
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 11416
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define rep1(i, n) FOR(i, 1, n+1)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; --i)
#define whole(x) (x).begin(),(x).end()
#define rwhole(x) (x).rbegin(), (x).rend()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
#define P pair<int, int>
#define debug(var) cerr << "[" << #var << "] " << var << endl
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define vi vector<int>
#define vl vector<ll>
#define pb push_back
#define eb emplace_back
#define pr(s) cout << (s) << '\n'
const ll mod = 1000000007;
const int dx[] = {-1,0,1,0};
const int dy[] = {0,-1,0,1};


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int n;
    cin >> n;
    string s;
    int k;
    cin >> s >> k;
    k--;
    for (char& c: s) {
        if (c!=s[k]) c = '*';
    }
    
    pr(s);
    return 0;
}


Measured memory_bytes: 3652
#pragma region template
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const long long MOD = 1e9 + 7, MAX = 1e18, larg = 1e5, INF = -1e9;
long long A, B, C, D, E, F, G, H, I, J, K, L, N, M, O, P, Q, S, T, U, V, W, x, y, z;
long long max_value = INF, max_index = -1;
typedef long long ll;
typedef pair<ll, ll> Pa;

template <std::int_fast64_t Modulus> class modint {
	using u64 = std::int_fast64_t;
public:
	u64 a;
	constexpr modint(const u64 x = 0) noexcept : a(x% Modulus) {}
	constexpr u64& value() noexcept { return a; }
	constexpr const u64& value() const noexcept { return a; }
	constexpr modint operator+(const modint rhs) const noexcept {
		return modint(*this) += rhs;
	}
	constexpr modint operator-(const modint rhs) const noexcept {
		return modint(*this) -= rhs;
	}
	constexpr modint operator*(const modint rhs) const noexcept {
		return modint(*this) *= rhs;
	}
	constexpr modint operator/(const modint rhs) const noexcept {
		return modint(*this) /= rhs;
	}
	constexpr modint& operator+=(const modint rhs) noexcept {
		a += rhs.a;
		if (a >= Modulus) {
			a -= Modulus;
		}
		return *this;
	}
	constexpr modint& operator-=(const modint rhs) noexcept {
		if (a < rhs.a) {
			a += Modulus;
		}
		a -= rhs.a;
		return *this;
	}
	constexpr modint& operator*=(const modint rhs) noexcept {
		a = a * rhs.a % Modulus;
		return *this;
	}
	constexpr modint& operator/=(modint rhs) noexcept {
		u64 exp = Modulus - 2;
		while (exp) {
			if (exp % 2) {
				*this *= rhs;
			}
			rhs *= rhs;
			exp /= 2;
		}
		return *this;
	}
};
#pragma endregion

int main() {
	string s;
	cin >> s;
	cin >> K;
	set<string> subs;
	for (int i = 0; i < s.length(); i++) {
		for (int j = i; j < min((int)s.length(), i+5); j++) {
			subs.insert(s.substr(i, j - i + 1));
		}
	}
	for (auto itr = subs.begin(); itr != subs.end(); ++itr,K--) {
		if (K == 1) cout << *itr;
	}
}



Measured memory_bytes: 1664
#include<bits/stdc++.h>
using namespace std;
#define set_null(a,n) memset(a,0,sizeof(a))
#define pi acos(-1)
#define ll long long int
#define fr(a,b) for(int p=a;p<b;p++)
#define modulo 1000000007

int main()
{
    int n,m;
    cin>>n>>m;
    if(n<=m)
    {
        cout<<"unsafe\n";
    }
    else{
        cout<<"safe\n";
    }

    return 0;
}



Measured memory_bytes: 3636
n, k = map(int, input().split())
a = [int(_) for _ in input().split()]
MOD = 10**9+7

cnt = 0
for i in range(n):
    for j in range(i+1, n):
        if a[i] > a[j]:
            cnt += 1
ans = cnt * k

dic = dict()
for i in range(n):
    if a[i] in dic:
        dic[a[i]] += 1
    else:
        dic.setdefault(a[i], 1)
dic = sorted(dic.items())
cnt = 0
s = dic[0][1]
for i in range(1, len(dic)):
    cnt += s * dic[i][1]
    s += dic[i][1]
rep = k * (k-1) // 2
ans = (ans + cnt * rep) % MOD
print(ans)

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

typedef long long ll;

int main(void){
    ll dis, n, m, d[200010], k[10010];
    while(cin >> dis){//全長
        if(dis==0) break;
        cin >> n;//店舗数
        cin >> m;//注文数
        d[1]=0;
        d[n+1]=dis;
        for(ll i=2; i<=n; i++){
            cin >> d[i];
            d[n+i]=dis+d[i];
        }
        for(ll i=1; i<=m; i++){
            cin >> k[i];
        }
        sort(d+1, d+(2*n+1));
        sort(k+1, k+(m+1));
        
        ll ans=0;
        for(ll i=1; i<=m; i++){
            ll under=1, upper=2*n+1;
            //cout << "k[" << i << "]=" << k[i] <<"\n";
            while(upper-under>1LL){
                ll mid=(under+upper)/2;
                //cout << "d[" << mid << "]=" << d[mid] <<"\n";
                ll a=abs(d[mid]-k[i]);
                ll b=abs(d[mid-1]-k[i]);
                //cout << "a=" << a << "b=" << b << "\n";
                if(a<b){
                    under=mid;
                }
                else{
                    upper=mid;
                }
            }
            ans+=abs(k[i]-d[under]);
        }
        cout << ans << "\n";
        
    }
    
    return 0;
}


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

int d[101]={0};
int f[101]={0};
int AdjM[101][101]={0};
int lapse=0;

void dfs(int cur){
    ++lapse;
    d[cur]=lapse;
    //cerr<<"visiting "<<cur<<" "<<lapse<<"\n";
    for(int dst=1;dst<101;++dst){
        if(AdjM[cur][dst]!=0 && d[dst]==0){
            dfs(dst);
        }
    }
    ++lapse;
    f[cur]=lapse;
}

int main(){
    int N;
    cin>>N;
    int id,edgnum,adj;
    for(int i=0;i<N;++i){
        cin>>id>>edgnum;
        for(int j=0;j<edgnum;++j){
            cin>>adj;
            AdjM[id][adj]+=1;
        }
    }

    for(int i=1;i<=N;++i){
        if(d[i]==0){
            dfs(i);
        }
    }

    for(int i=1;i<=N;++i){
        cout<<i<<" "<<d[i]<<" "<<f[i]<<"\n";
    }
}

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

using namespace std;

#define fr(i, n) for(ll i = 0; i < n; i++)
#define frr(i, n) for(ll i = 1; i <= n; i++)
#define frm(i, n) for(ll i = n-1; i >= 0; i--)

#define pb push_back
#define f first
#define s second

typedef long long ll;
typedef pair<ll,ll> pii;
typedef pair<double, double> ponto;
typedef vector<vector<ll>> matrix;

#define mem(v, k) memset(v, k, sizeof(v));

#define db cout << "Debug" << endl;

#define mp make_pair
#define pq priority_queue

#define mx(a, b) a = max(a, b);
#define mod(a, b) a = a%b;

#define MAXN 100010
#define MOD 1000000007
#define MAXL 30
#define ROOT 1
#define INF 987654321

ll x, y, a, b, c;

ll r[MAXN], g[MAXN];
ll ans = 0;
pq<ll> notColor;
pq<ll, vector<ll>, greater<ll>> chosen;

void build(){
	cin >> x >> y >> a >> b >> c;

	frr(i, a){
		cin >> r[i];
	}

	sort(r + 1, r + a + 1);

	for(ll j = a; j > a - x; j--){
		chosen.push(r[j]);
		ans+=r[j];
	}


	frr(i, b){
		cin >> g[i];
	}

	sort(g + 1, g + b + 1);

	for(ll j = b; j > b - y; j--){
		chosen.push(g[j]);
		ans+=g[j];
	}

	fr(i, c){
		ll aux;
		cin >> aux;
		notColor.push(aux);
	}
}

void solve(){
	while(!notColor.empty() && notColor.top() > chosen.top()){
		ans-=chosen.top();
		chosen.pop();
		ans+=notColor.top();
		chosen.push(notColor.top());
		notColor.pop();
	}
}

int main(){
	ios::sync_with_stdio(false);
	build();
	solve();

	cout << ans << endl;
}


Measured memory_bytes: 5104
def solve():
    N = int(input())
    A = list(map(int, input().split()))
    ans = 0
    while True:
        if all([x % 2 == 0 for x in A]):
            ans += 1
            A = list(map((lambda x: x//2), A))
        else:
            print(ans)
            return
    
solve()

Measured memory_bytes: 3060
N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))

answer = sum(B)
for i in range(len(A)-1):
  if A[i+1] == A[i]+1:
    answer += C[A[i]-1]

print(answer)
  

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

using namespace std;

const long long MOD = 1000000007LL;
long long GCD(long long a, long long b){return b == 0 ? a : GCD(b, a % b);}

int main(){

    cin.sync_with_stdio(0); cin.tie(0); cout.tie(0);

    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    long long a, b;
    string c, d;

    cin >> a >> b >> c >> d;

    unsigned long long lcm = a / GCD(a, b) * b;

    for(int i = 0; i < GCD(a, b); ++i){
        //cout << i * lcm / a << " " << i * lcm / b << endl;
        if(c[i * (lcm / b)] != d[i * (lcm / a)]){
            cout << -1;
            return 0;
        }
    }

    cout << lcm;

    return 0;
}


Measured memory_bytes: 640
import sys
input = sys.stdin.readline
n = int(input())
l = input().split()
for i in range(n):
    l[i] = int(l[i])
l.sort()
sum = 0
for i in range(n-1):
    sum += l[i]
if l[n-1] < sum:
    print("Yes")
else:
    print("No")

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

using namespace std;

class UnionFind {
public:
  vector<int> parent;

  UnionFind(int n) : parent(n, -1) {
  }

  int root(int x) {
    if (parent[x] < 0) {
      return x;
    } else {
      return parent[x] = root(parent[x]);
    }
  }

  bool issame(int x, int y) {
    return root(x) == root(y);
  }

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

  bool unite(int x, int y) {
    int rx = root(x), ry = root(y);
    if (rx == ry) return false;
    if (parent[rx] > parent[ry]) swap(rx, ry);
    parent[rx] += parent[ry];
    parent[ry] = rx;
    return true;
  }
};

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N, M;
  cin >> N >> M;
  vector<int> P(N);
  for (int i = 0; i < N; i++) {
    cin >> P[i];
    P[i]--;
  }
  UnionFind uf(N);
  for (int i = 0; i < M; i++) {
    int x, y;
    cin >> x >> y;
    uf.unite(x - 1, y - 1);
  }
  int res = 0;
  for (int i = 0; i < N; i++) {
    if (uf.issame(i, P[i])) res++;
  }
  cout << res << '\n';
  return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
using namespace std;
typedef long long ll;
ll gcd(ll a,ll b){return b!=0?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}

int main(){
    ll h,w;
    cin>>h>>w;
    vector<string> pic(h),pic2(2*h);
    rep(i,h) cin>>pic[i];
    rep(i,2*h) cout<<pic[i/2]<<endl;
    return 0;
}

Measured memory_bytes: 256
#![allow(unused_imports)]

//input
use proconio::input;
use proconio::marker::{Bytes, Chars};
//use std::io::Read;

//collections
//use std::collections::BTreeMap;
//use std::collections::BTreeSet;
//use std::collections::HashMap;
//use std::collections::HashSet;
//use std::collections::VecDeque;
//use std::collections::BinaryHeap;

//use std::cmp::*;

fn main() {
    input! {
        a: i64,
        b: i64,
        c: i64,
        mut k: i64,
    }
    let mut ans = 0i64;

    if k >= a {
        ans += a;
        k -= a;
    } else {
        ans += k;
        k = 0;
    }

    if k >= b {
        k -= b;
    } else {
        k = 0;
    }
    if k >= c {
        ans -= c;
        k -= c;
    } else {
        ans -= k;
        k = 0;
    }

    println!("{}", ans);
}


Measured memory_bytes: 2176
#include <cstdio>
#include <algorithm>
using namespace std;
int n,k;

int main(){
    scanf("%d%d",&n,&k);
    long long sum = 0;
    for(int b=k+1;b<=n;b++){
        sum += (n+1)/b*max(0,b-k) + max((n+1)%b - k, 0);
    }
    if (k==0)sum -= n;
    printf("%lld",sum);
}


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

#define len(x) (int)(x).size()
#define fi first
#define se second
#define fast_io ios_base::sync_with_stdio(0) , cin.tie(0) , cout.tie(0)
#define pb push_back
#define all(x) (x).begin() , (x).end()
typedef long long ll;
typedef long double ld;
using namespace std;
const int N = 2e3 + 10;
int n , k;
vector < int > g[N];
int dfs(int v , int p , int len){
    if(len > k / 2)return 0;
    int curr = 1;
    for(auto u : g[v])if(u != p){
        curr += dfs(u , v , len + 1);
    }
    return curr;
}
signed main(){
    cin >> n >> k;
    vector<pair<int,int>>edges;
    for(int i = 0; i < n - 1;++i){
        int u , v;
        cin >> u >> v;
        --u , --v;
        edges.pb({u,v});
        g[u].pb(v) , g[v].pb(u);
    }
    int ans = n;
    if(!(k&1)){
        for(int i = 0; i < n; ++i){
            ans = min(ans , n - dfs(i , -1 , 0));
        }
    }else{
        for(int i = 0 ; i < n - 1; ++i){
            ans = min(ans , n - (dfs(edges[i].fi,edges[i].se,0)+dfs(edges[i].se,edges[i].fi,0)));
        }
    }
    cout << ans;
    return 0;
}
/*
4 3
1 2 1 2 7
1 3 2 1 8
2 3 3 2 6
6
4 3
1 2 1 2 7
1 3 2 1 8
2 3 3 2 6
6
4 3
1 2 1 2 7
1 3 2 1 8
2 3 3 2 6
6
4 3
1 2 1 2 7
1 3 2 1 8
2 3 3 2 6
6
4 3
1 2 1 2 7
1 3 2 1 8
2 3 3 2 6
6

4 3
1 2 1 2 7
1 3 2 1 8
2 3 3 2 6
6
*/


Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <algorithm>
#include <climits>

using namespace std;

int N, M;
vector<int> P;

int solve(){
    vector<int> sums(N*N+N+2);
    for(int i=0; i<N; ++i){
        for(int j=0; j<N; ++j){
            sums[i*N+j]=P[i]+P[j];
        }
    }
    for(int i=0; i<N; ++i){
        sums[N*N+i]=P[i];
    }
    sums[N*N+N]=0;
    sums[N*N+N+1]=INT_MAX;
    sort(sums.begin(), sums.end());

    int ans;
    auto p=lower_bound(sums.begin(), sums.end(), M);
    if(*p==M) return M;
    else ans=*(p-1);

    for(int i=0; i<N; ++i){
        for(int j=0; j<N; ++j){
            int rest=M-P[i]-P[j];
            if(rest==0) return M;
            else if(rest<0);
            else{
                auto p=lower_bound(sums.begin(), sums.end(), rest);
                if(*p==rest) return M;
                else ans=max(ans, *(p-1)+P[i]+P[j]);
            }
        }
    }
    return ans;
}

int main(){
    while(true){
        cin >> N >> M;
        if(N==0 && M==0) break;
        P.resize(N);
        for(int i=0; i<N; ++i){
            cin >> P[i];
        }
        cout << solve() << endl;
    }
    return 0;
}



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


void solve(long long K, long long A, long long B){
    for (long long i = A; i <= B; i++) {
        if (i % K == 0) {
            cout << "OK" << endl;
            return;
        }
    }
    cout << "NG" << endl;
}

// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long K;
    scanf("%lld",&K);
    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    solve(K, A, B);
    return 0;
}


Measured memory_bytes: 3652
import java.util.Scanner;

public class Main {
    public static void main(String[] args) throws Exception {
        
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        
        int total = 0;
        for(int i = 1; i <= N; i++){
            int numOfdigits = String.valueOf( i ).length();
            if (numOfdigits % 2 == 1){
                total++;
            }
        }
        
        System.out.println(total);
    }
}


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

typedef long long ll;
typedef pair<ll, ll> P;

#define pb push_back
#define rep(i, n) for(int i = 0; i < (n); i++)
#define FOR(i, a, n) for(int i = a; i < (n); i++)
#define mod (ll)(1e9+7)
#define int ll
#define INF 100000000

__attribute__((constructor))
void initial() {
  cin.tie(0);
  ios::sync_with_stdio(false);
}

signed main() {
  ll a, b, c, n;
  ll x[1000], y[1000], z[1000], re[1000], ch[1000];
	while(cin >> a >> b >> c && (a || b || c)) {
    rep(i, 1000) ch[i] = 2;
    cin >> n;
    rep(i, n) {
      cin >> x[i] >> y[i] >> z[i] >> re[i];
      if(re[i] == 1) {
        ch[x[i]] = ch[y[i]] = ch[z[i]] = 1;
      }
    }
    rep(i, n) {
      if(re[i] == 1) continue;
      if(ch[x[i]] == 1 && ch[y[i]] == 1) ch[z[i]] = 0;
      if(ch[z[i]] == 1 && ch[y[i]] == 1) ch[x[i]] = 0;
      if(ch[x[i]] == 1 && ch[z[i]] == 1) ch[y[i]] = 0;
    }
    FOR(i, 1, a + b + c + 1) {
      cout << ch[i] << endl;
    }
  }
	return 0;
}


Measured memory_bytes: 3168
#include <stdio.h>
int main(){
  int i,j,k,v,N;
 int A[100]; 
scanf("%d",&N);
if((1<=N)&&(N<=100)){
for(i=0;i<N;i++){
scanf("%d",&A[i]);
 printf("%d",A[i]);
 if(i<N-1){
   printf(" ");
 }
}
 printf("\n");
for(i=1;i<N;i++){
v = A[i];
j = i - 1;
while((j>=0)&&(A[j]>v)){
A[j+1]=A[j];
j--;
}
A[j+1]=v;
for(k=0;k<N;k++){  
printf("%d",A[k]);
 if(k<N-1){
   printf(" ");
 }
}
printf("\n");
}
}
else printf("error");
return 0;
}



Measured memory_bytes: 2128
use proconio::*;


fn check(b: &[usize], n: usize) -> i32 {
    let mut is_prime = vec![true; 1000001];
    is_prime[0] = false;
    is_prime[1] = false;

    let mut ret = 0;
    for i in 0..1000001 {
        if !is_prime[i] {
            continue;
        }

        let mut j = i*2;
        let mut cnt = b[i];
        while j < 1000001 {
            is_prime[j] = false;
            cnt += b[j];
            j += i;
        }

        if cnt == n {
            return 2;
        }
        if cnt > 1 {
            ret = 1;
        }
    }

    ret
}

fn main() {
    input!{
        n: usize,
        a: [usize; n],
    }

    let mut b = vec![0; 1000001];
    for &i in a.iter() {
        b[i] += 1;
    }

    println!("{}", match check(&b, n) {
        0 => "pairwise coprime",
        1 => "setwise coprime",
        _ => "not coprime",
    });
}


Measured memory_bytes: 25056
import java.util.*;

public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int N = Integer.parseInt(sc.next());
		Map<String, Integer> map = new HashMap<String, Integer>();
		for(int i = 0; i < N; i++) {
			String str = sc.next();
			if(map.get(str) == null) {
				map.put(str, 1);
			} else {
				int cnt = map.get(str);
				map.put(str, ++cnt);
			}
		}
		int M = Integer.parseInt(sc.next());
		for(int i = 0; i < M; i++) {
			String str = sc.next();
			if(map.get(str) == null) {
				map.put(str, -1);
			} else {
				int cnt = map.get(str);
				map.put(str, --cnt);
			}
		}
		
		int max = 0;
		for(int i : map.values()) {
			max = Math.max(max, i);
		}
		System.out.println(max);
	}
}


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

#define fill(a,val) memset(a, (val), sizeof a)
#define pb push_back
#define lli long long int
#define scantype int
#define endl "\n"
#define unique(x) x.erase(unique(x.begin(),x.end()), x.end())
#define sort_f(x)  sort(x.begin(),x.end());
#define sort_r(x)  sort(x.rbegin(),x.rend());

lli MOD  = 1000000007;
lli inf = 1e15;

void scan(scantype &x);
lli powermod(lli _a,lli _b,lli _m){lli _r=1;while(_b){if(_b%2==1)_r=(_r*_a)%_m;_b/=2;_a=(_a*_a)%_m;}return _r;}
lli string_to_number(string s){lli x=0; stringstream convert(s); convert>>x; return x;}
lli add(lli a,lli b){lli x = (a+b)%MOD; return x; }
lli mul(lli a,lli b){lli x = (a*b)%MOD; return x; }
lli sub(lli a,lli b){lli x = (a-b+MOD)%MOD; return x; }
lli divi(lli a,lli b){lli x = a;lli y = powermod(b,MOD-2,MOD);lli res = (x*y)%MOD;return res;}


int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    if(a+b>c+d)
    {
        cout<<"Left";
    }
    else if(a+b<c+d)
    {
        cout<<"Right";
    }
    else
    {
        cout<<"Balanced";
    }
    return 0;
}

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

int main()
{

int x,y;
cin>>x>>y;

for(int index = 0;index<=x;index++)
{
    if((2*index+(x-index)*4)==y)
    {
        cout<<"Yes"<<endl;
        return 0;
    }
    
    
}
cout<<"No"<<endl;

    return 0;
}


Measured memory_bytes: 3580
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <assert.h>
#include <numeric>
#include <math.h>
#include <climits>

using namespace std;
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
typedef long long ll;

template <typename T>
T gcd(T a, T b) {
    if(a < b) gcd(b, a);
    if (b == 1) return 1;
    T r;
    while ((r=a%b)) {
        a = b;
        b = r;
    }
    return b;
}


int main() {
    ll N;
    cin >> N;
    //vector<string> S;
    ll cnt = 0;
    ll lastA = 0;
    ll firstB = 0;
    ll BandA = 0;
    REP(i, N) {
        string s;
        cin >> s;
        //S.push_back(s);
        REP(j, s.length()-1) {
            if (s[j] == 'A' && s[j+1] == 'B') {
                cnt++;
            }
        }
        if (s[0] == 'B' &&  s[s.length()-1] != 'A') firstB++;
        if (s[s.length()-1] == 'A' && s[0] != 'B') lastA++;
        if (s[0] == 'B' && s[s.length()-1] == 'A') BandA++;
    }
    if (BandA > 0) {
        cnt += BandA-1;
        if (lastA > 0) {
            cnt++;
            lastA--;
        }
        if (firstB > 0) {
            cnt++;
            firstB--;
        }
    }
    

    cnt += min(lastA, firstB);
    
    cout << cnt << endl;
}


Measured memory_bytes: 384
using System;
using System.Linq;

namespace _0609
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            int m = int.Parse(Console.ReadLine());
            int[] a = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int[,] b = new int[m, n];
            int[] c = new int[n];
            for (int i = 0; i < m; i++)
            {
                int[] x = Console.ReadLine().Split().Select(int.Parse).ToArray();
                for (int j = 0; j < n; j++)
                {
                    b[i, j] = x[j];
                }
            }
            for (int i = 0; i < m; i++)
            {
                for (int j = 0; j < n; j++)
                {
                    if (b[i, j] == a[i])
                    {
                        c[j]++;
                    }
                    else
                    {
                        c[a[i] - 1]++;
                    }
                }
            }
            for (int i = 0; i < n; i++)
            {
                Console.WriteLine(c[i]);
            }
        }
    }
}

Measured memory_bytes: 9616
#include <bits/stdc++.h>  // g++ -std=c++14 -o a a.cpp

using namespace std;

typedef pair<int, int> P;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define repto(i, n) for(int i = 0; i <= (n); i++)
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end()) // ユニークなvectorにする。連続した値を除去して切り出す。
#define _1 first
#define _2 second
#define pb push_back
#define INF 1145141919
#define MOD 1000000007
#define DEBUG(x) cout << #x << ": " << x << endl;

__attribute__((constructor))
void initial() {
  cin.tie(0);
  ios::sync_with_stdio(false);
}

int main() {
  int N;
  cin >> N;
  rep(i, N) {
    int x, y, b, p, ret;
    cin >> x >> y >> b >> p;
    ret = x * b + y * p;

    if (b >= 5 && p >= 2) {
      ret = ret / 10 * 8;
    }

    if (b >= 5 && p < 2) {
      ret = min(ret, (x * b + y * 2) / 10 * 8);
    }

    if (b < 5 && p >= 2) {
      ret = min(ret, (x * 5 + y * p) / 10 * 8);
    }
    cout << ret << endl;
  }
}


Measured memory_bytes: 3172
#include<bits/stdc++.h>
#define forr(i, a, b) for(int i = (a); i < (b); i++)
#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = 1; i <= (n); i++)
#define ALL(a) (a.begin()),(a.end())
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll, ll> LP;
const ll LINF = 1LL<<60;
const int INF = 1001001001;
const int MOD = 1000000007;

/* --------------------------------------------------- */
int gcd(int a, int b) {
	if (b == 0) { return a; }
	if (a < b) { return gcd(b, a); }
	return gcd(b, a % b);
}

int main() {
    int n, x;
    cin >> n >> x;
    int ans = 0;
    rep(i, n) {
        int a;
        cin >> a;
        ans = gcd(ans,abs(x - a));
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for (long long i = 0; i < (n); ++i)
//g++ -std=c++11 

using namespace std;

long long N;
vector<long long> P;
vector<long long> Q;
int main(){
	cin >> N;
	rep(i, N) {
		long long tmp;
		cin >> tmp;
		P.push_back(tmp);
	}
	rep(i, N) {
		long long tmp;
		cin >> tmp;
		Q.push_back(tmp);
	}


	vector<long long> arr;
	rep(i, N) {
		arr.push_back(i+1);
	}

	long long idx = 0;
	long long pidx = -1;
	long long qidx = -1;
	do {
		bool pok = true;
		rep(i, N) {
			if(arr[i] != P[i]) {
				pok = false;
			}
		}
		if(pidx == -1 && pok) {
			pidx = idx;
		}


		bool qok = true;
		rep(i, N) {
			if(arr[i] != Q[i]) {
				qok = false;
			}
		}
		if(qidx == -1 && qok) {
			qidx = idx;
		}
		idx++;
	} while (std::next_permutation(arr.begin(), arr.end()));

	cout << abs(pidx - qidx) << endl;

}



Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
#define modulo 1000000007
#define mod(mod_x) ((((long long)mod_x+modulo))%modulo)
#define Inf 10000000000000000



int main(){
	
	int a,b,c;
	cin>>a>>b>>c;
	
	set<int> S;
	S.insert(a);
	S.insert(b);
	S.insert(c);
	
	cout<<S.size()<<endl;
	
    return 0;
}



Measured memory_bytes: 256