akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <numeric>
using namespace std;
using Graph = vector<vector<int>>;
int ans=0;
int N,M;

// 深さ優先探索
void dfs(const Graph &G, int v,vector<int> seen) {
    seen[v] = 1; // v を訪問済にする
    if(accumulate(seen.begin(),seen.end(),0)==N)ans++;
    // v から行ける各頂点 next_v について
    for (auto next_v : G[v]) {
        if (seen[next_v]) continue; // next_v が探索済だったらスルー
        dfs(G, next_v, seen); // 再帰的に探索
    }
}

int main() {
    // 頂点数と辺数
    cin >> N >> M;

    // グラフ入力受取 (ここでは無向グラフを想定)
    Graph G(N);
    for (int i = 0; i < M; ++i) {
        int a, b;
        cin >> a >> b;
      a--;b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }

    // 頂点 0 をスタートとした探索
  vector<int> seen;
    seen.assign(N, 0); // 全頂点を「未訪問」に初期化
    dfs(G, 0, seen);
  cout << ans << endl;
}

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

#define _GLIBCXX_DEBUG
#define _LIBCPP_DEBUG 0

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  if (a + b >= c) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 3584
#include <iostream>
#include <stdio.h>
#include <cmath>
#include <vector>
#include <map>
#include <algorithm>

using namespace std;

int main() {
    int n;
    cin >> n;
    vector<long long int> a;
    long long int temp;
    long long int ans = 0;
    for (int i = 0; i < n; i++) {
        cin >> temp;
        a.push_back(temp);
        ans = ans ^ temp;
    }

    long long int lli;

    for (int i = 0; i < n; i++) {
        lli = ans ^ a[i];
        cout << lli << " ";
    }


    return 0;
}

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

int main()
{
    int N, K;
    int keta = 0;
    cin >> N >> K;
    while(1){
        N = (N - (N % K)) / K;
        keta = keta + 1;
        if(N <= 0){
            break;
        }
    }
    cout << keta << endl;
    system("pause");
    return 0;
}

Measured memory_bytes: 504
#include<iostream>
#include<vector>
#include<string>
using namespace std;
int main()
{
	int ans=1,i,n;
	cin >> n;
    string s;
    vector<string> vec;
	for (i=0;i<n;i++){
      cin >> s;
      vec.push_back(s);
    }
	sort(vec.begin(),vec.end());
    i=1;
    while(vec.size()>i){
      if (vec[i]!=vec[i-1]) ans++;
      i++;
    }
    
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 9096
#include <bits/stdc++.h>
#define fio ios_base::sync_with_stdio(false)
#define pdl cout << "*" << endl
#define MOD 1000000007
#define INF 1000000000
#define INFLL 1000000000000000000ll
#define ff first
#define ss second
#define long int64_t
using namespace std;
typedef pair<int, int> pii;
typedef pair<long, long> pll;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
uniform_int_distribution<> dis(0, INF<<1);
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1> void __f(const char* name, Arg1&& arg1){ cerr << name << " : " << arg1 << endl; }
template <typename Arg1, typename... Args> void __f(const char* names, Arg1&& arg1, Args&&... args)
{ const char* comma = strchr(names + 1, ','); cerr.write(names, comma - names) << " : " << arg1 << " | "; __f(comma+1, args...); }

const int N = 100001;

int a[N];
bool neg[N];

int main()
{
	fio;
	int n, t = 0;
	cin >> n;
	for(int i=1; i<=n; i++)
	{
		cin >> a[i];
		if(a[i] < 0)
		{
			neg[i] = true;
			t++;
		}
	}
	if(t == n)
	{
		int x = -INF;
		for(int i=1; i<=n; i++)
		{
			if(a[i] > x)
			{
				x = a[i];
				t = i;
			}
		}
		neg[t] = false;
	}
	if(t == 0)
	{
		int x = INF;
		for(int i=1; i<=n; i++)
		{
			if(a[i] < x)
			{
				x = a[i];
				t = i;
			}
		}
		neg[t] = true;
	}
	int c = -1, b = -1;
	t = 1;
	while(c < 0 or b < 0)
	{
		if(neg[t] and c < 0)
			c = t;
		else if(!neg[t] and b < 0)
			b = t;
		t++;
	}
	int nx = a[c], px = a[b];
	vector<pii> ans;
	for(int i=1; i<=n; i++)
	{
		if(i == c or i == b)
			continue;
		if(neg[i])
		{
			ans.emplace_back(px, a[i]);
			px -= a[i];
		}
		else
		{
			ans.emplace_back(nx, a[i]);
			nx -= a[i];
		}
	}
	ans.emplace_back(px, nx);
	cout << px - nx << endl;
	for(pii &it : ans)
		cout << it.ff << ' ' << it.ss << endl;
	return 0;
}

Measured memory_bytes: 3316
#pragma GCC optimize("Ofast")

//インクルード
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//イテレータあるけど順序保持しないmap
#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列

using namespace std;
using Graph = vector<vector<int>>; // グラフ型
typedef long long ll;

//マクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define FORD(i,a,b) for(ll i=(a);i>=(b);i--)
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))
#define INF 1000000000000 //10^12
#define MOD 10000007 //10^9+7
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define MAXR 100000 //10^5:最大のrange(素数列挙などで使用)

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 main() {
  // 高速化
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);


    ll K;
    cin >> K;

    cout << K * 2 *  M_PI  << "\n"; 

    return 0;



}


Measured memory_bytes: 3792
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define MOD 1000000007
#define rep(i,n) for(i=0;i<(n);i++)
#define loop(i,a,n) for(i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;

#define MAX_N 100

int reached[MAX_N][MAX_N]={};


int parent[MAX_N];
int ran[MAX_N];

void init(int n)
{
  int i;
  rep(i,n){
    parent[i]=i;
    ran[i]=0;
  }
}

int find(int x)
{
  if(parent[x]==x)
    return x;
  else
    return parent[x]=find(parent[x]);
}

void unite(int x,int y)
{
  x=find(x);
  y=find(y);
  if(x==y)return;

  if(ran[x]<ran[y])
    parent[x]=y;
  else{
    parent[y]=x;
    if(ran[x]==ran[y])ran[x]++;
  }
}

void dfs(int s, int v, vector<vi> g){
  reached[s][v]++;
  int i;
  rep(i,g[v].size())
    if(reached[s][g[v][i]]==0)dfs(s,g[v][i],g);

}

int main(void) {
  int i,j;
  while(1){
    int n;
    cin>>n;
    if(n==0)break;
    vector<vi> g(n);
    vector<double> p(n);
    rep(i,n){
      cin>>p[i];
      int m;
      cin>>m;
      rep(j,m){
	int a;
	cin>>a;
	a--;
	g[i].push_back(a);	
      }
    }

    rep(i,n)rep(j,n)reached[i][j]=0;

    rep(i,n)dfs(i,i,g); //reached[i][j]を埋める

    init(100);//UF

    rep(i,n)loop(j,i+1,n)
      if(reached[i][j] && reached[j][i])unite(i,j);//UF

    double ans=1;

    int q;
    rep(q,n){
      bool c=true;//qに到達可能なものがない
      double tmp=1;//強連結成分qの全体の確率

      rep(i,n)if(find(parent[i])==q){//iがqに属する場合

	tmp*=p[i];

	//jがiと異なる強連結成分に属し、jがiに到達可能の場合
	rep(j,n)if(find(parent[i])!=find(parent[j]) && reached[j][i]){
	  c=false;
	}

      }

      if(c && fabs(tmp-1)>EPS) ans*=1-tmp;
  
    }

    cout<<shosu(10)<<ans<<endl;

  }
}



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

//#define int long long
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ms(a, b) memset((a), (b), sizeof(a))
#define len(a) (int)((a).size())
#define all(a) (a).begin(), (a).end()
#define lb lower_bound
#define ub upper_bound
#define fore(i, a, b) for (int i = (a), _b = (b); i < _b; ++i)
#define fort(i, a, b) for (int i = (a), _b = (b); i <= _b; ++i)
#define ford(i, a, b) for (int i = (a), _b = (b); i >= _b; --i)
#define bug(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
    cerr << name << ": " << arg1 << '\n';
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
    const char* comma = strchr(names + 1, ',');
    cerr.write(names, comma - names) << " : " << arg1 << " /";
    __f(comma + 1, args...);
}

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

typedef long long ll;
typedef double db;
typedef pair<int, int> pi;
typedef pair<int, pi> ti;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pi> vpi;
typedef vector<ti> vti;
typedef vector<vpi> vvpi;

const int inf = (int)0x3f3f3f3f3f3f3f3f;
const int ninf = (int)0xc0c0c0c0c0c0c0c0;
const ll M = (ll)1e9 + 7;

ll f(ll x) {
    if (x == 1) return 1;
    else return 2 * f(x / 2) + 1;
}

main() {
//    freopen("CP.inp", "r", stdin);
//    freopen("CP.out", "w", stdout);
    ll x; cin >> x;
    cout << f(x) << '\n';
}


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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define MAXN 100010

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

int main() {
    int n, k;
    cin >> n >> k;
    int h[MAXN];

    for(int i=1; i<=n; i++) {
        cin >> h[i];
    }
    vector<ll> dp(n+1, ll(INF));

    dp[1] = 0;
    for(int now=1; now<=n; ++now) {
        for(int next=now+1; next<=min(n, now+k); ++next) {
            dp[next] = min(dp[next], dp[now]+ abs(h[now]-h[next]));
        }
    }
    
    cout << dp[n] << endl;
}



Measured memory_bytes: 1408
#include <stdio.h>

int main(){

	int a,b,c,x,check;
	int result = 0;

	scanf("%d %d %d",&a,&b,&c);

	for(x = a; x <= b; x++){
		check = c % x;

		if(check == 0){
			result += 1;
		}
	}

	printf("%d\n",result);

	return 0;
}

Measured memory_bytes: 596
#include "bits/stdc++.h"
#define in std::cin
#define out std::cout
#define rep(i,N) for(LL i=0;i<N;++i)
typedef long long int LL;

int main()
{
	LL N, A, B, C, D;
	std::string S;
	in >> N >> A >> B >> C >> D >> S;

	bool flag1 = true, flag2 = true, flag3 = true;
	S = "#" + S + "#";
	for (LL i = A; i < C; ++i)
	{
		if (S[i] == '#' && S[i + 1] == '#')
		{
			flag1 = false;
			break;
		}
	}
	for (LL i = B; i < D; ++i)
	{
		if (S[i] == '#' && S[i + 1] == '#')
		{
			flag2 = false;
			break;
		}
	}
	if (C > D)
	{
		flag3 = false;
		for (LL i = B - 1; i < D; ++i)
		{
			if (S[i] == '.' && S[i + 1] == '.' && S[i + 2] == '.')
			{
				flag3 = true;
				break;
			}
		}
	}

	out << (flag1 && flag2 && flag3 ? "Yes" : "No") << std::endl;
}


Measured memory_bytes: 772
#include <bits/stdc++.h>
using namespace std;
using int64 = long long;
#define int int64
#define rep(i, n) for(int i=0; i<n; i++)
#define FOR(i, a, b) for(int i=a; i<b; i++)
#define SORT(x) sort(x.begin(), x.end())
#define GSORT(x) sort(x.begin(), x.end(), greater<int>())
#define mk make_pair
#define fi first
#define se second
#define pb push_back
#define ALL(x) x.begin(), x.end()
#define V(T) vector<T>
typedef pair<int, int> P;
typedef pair<P, P> PP;
typedef vector<int> vi;
typedef vector<vi> vvi;
int max(int a, int b) {if(b>a) return b; else return a;}
int min(int a, int b) {if(b<a) return b; else return a;}

signed main() {
    int K, N;
    cin >> K >> N;
    vi A(N);
    rep(i, N) cin >> A[i];

    int mxd = abs(K-A[N-1]+A[0]);
    rep(i, N-1) {
        mxd = max(mxd, abs(A[i]-A[i+1]));
    }

    cout << K-mxd << endl;
    
 
    return 0;
}

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

int main(void){
    int n; cin>>n;
    vector <int> num(1,n);
    for(int i=0;i<1000000;i++){
        if(num[i]%2==0) num.push_back(num[i]/2);
        else num.push_back(3*num[i]+1);
        for(int j=0;j<num.size()-1;j++){
            if(num[i+1]==num[j]) {cout<<i+2<<endl; return 0;}
        }
    }
    
}

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

typedef struct R
{
  char s[11];
  int p;
} R;


int main(void)
{
  int i,j,N;
  scanf("%d",&N);
  R r[N];
  int ans[N];
  
  for(i = 0;i < N;i++) {
    scanf("%s %d",r[i].s,&r[i].p);
    ans[i] = i + 1;
  }  
    
  for(i = 0;i < N;i++) {
    int buf0;
    R buf1;
    for(j = 0;j < N - 1;j++) {
      if(strcmp(r[j].s,r[j + 1].s) > 0) {
        buf0 = ans[j];
        buf1 = r[j];
        ans[j] = ans[j + 1];
        r[j] = r[j + 1];
        ans[j + 1] = buf0;
        r[j + 1] = buf1;
      } else if(strcmp(r[j].s,r[j + 1].s) == 0) {
        if(r[j].p < r[j + 1].p) {
          buf0 = ans[j];
          buf1 = r[j];
          ans[j] = ans[j + 1];
          r[j] = r[j + 1];
          ans[j + 1] = buf0;
          r[j + 1] = buf1;
        }
      }  
    }
  }
  
  for(i = 0;i < N;i++) {
    printf("%d\n",ans[i]);
  }
  
  return 0;
}

Measured memory_bytes: 128
// Problem : D - I hate Factorization
// Contest : AtCoder - AtCoder Beginner Contest 166
// URL : https://atcoder.jp/contests/abc166/tasks/abc166_d
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

// Muallif: Azimjon Mehmonali o'g'li

#include <stdio.h>
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<ii> vii;

#define sqr(x) (x) * (x)
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define ALL(a) a.begin(), a.end()
#define rALL(a) a.rbegin(), a.rend()
#define SORT(a) sort(ALL(a))
#define sc scanf
#define pr printf
#define xatop(a) cerr << #a << " = " << a << endl;
#define jsatr xatop(__LINE__)
#define INF 1000000000
#define mod 1000000007

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

	for (int a = -1000; a < 1000; a++) {
		for (int b = -1000; b < 1000; b++) {
			if (1ll * a * a * a * a * a - 1ll * b * b * b * b * b == x) {
				cout << a << " " << b << endl;
				return 0;
			}
		}
	}

	return 0;
}


Measured memory_bytes: 3552
#include <bits/stdc++.h>
#define WHOLE(v) (v).begin(), (v).end()
#define REV_WHOLE(v) (v).rbegin(), (v).rend()
using i64 = int64_t;
using namespace std;
const i64 MOD = 1e9 + 7;
int64_t powmod(int64_t a, int64_t p) {
    int64_t value = 1;
    for (int64_t mul = a; p > 0; p >>= 1, mul = (mul * mul) % MOD) {
        if (p & 1) value = (value * mul) % MOD;
    }
    return value;
}
int main() {
    int N;
    cin >> N;
    map<int, int> m;
    for(int i = 0; i < N; i++) {
        int a;
        cin >> a;
        if(!m.count(a))m[a] = 0;
        m[a]++;
    }
    for(int i = (N - 1) % 2; i < N; i += 2) {
        if( (i == 0 && m[i] != 1) || (i != 0 && m[i] != 2)) {
            cout << 0 << endl;
            return 0;
        }
        m.erase(i);
    }
    if(m.size()) {
        cout << 0 << endl;
    } else {
        cout << powmod(2, N / 2) << endl;
    }
    return 0;
}

Measured memory_bytes: 3200
read A
read B
read C
read X

count=0

for (( a = 0; a <= A; a++ )); do
    for (( b = 0; b <= B; b++ )); do
        c=$(( (X - a * 500 - b * 100) / 50 ))
        (( c >= 0 && c <= C )) && count=$(( count + 1 ))
    done
done

echo ${count}


Measured memory_bytes: 376
#include <stdio.h>

int main(int argc,char* argv[]){
  
  for(;;){
    int h,m,s;
    int sum;
    int rest;

    scanf("%d %d %d",&h,&m,&s);
    if(h == -1 && m == -1 && s == -1){
      break;
    }

    sum = h*3600 + m*60 + s;
    rest = 7200 - sum;

    printf("%02d:%02d:%02d\n",rest/3600,(rest%3600)/60,(rest%3600)%60);
    rest *= 3;
    printf("%02d:%02d:%02d\n",rest/3600,(rest%3600)/60,(rest%3600)%60);
  }
  
  return 0;
  
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 1000000000
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;

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

int main(){
    cin.tie(0);
   	ios::sync_with_stdio(false);
  int A,B;
  cin >> A >> B;
  int cnt=0;
  for(int i = A;i <= B;i++){
    int s = i % 10, t = i / 10000 % 10;
    int u = i / 10 % 10, v = i / 1000 % 10;
    if(s == t && u == v) cnt++;
  }
  cout << cnt << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
int main() {
	int n;
	double xa, ya, ra, xb, yb, rb;
	double distance, diff;
	scanf (" %d", &n);
	while (n--) {
		scanf(" %lf %lf %lf %lf %lf %lf", &xa, &ya, &ra, &xb, &yb, &rb);

		distance = hypot(xa - xb, ya - yb);
		diff = ra - rb;

		if (ra + rb < distance)
			puts("0");
		else if (fabs(diff) <= distance)
			puts("1");
		else
			printf("%d\n", (int)copysign(2.0, diff));
	}
	return 0;
}

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

#define ll long long
#define pb push_back
#define vi vector<int>
#define FOR(i, a, b) for(int i = a; i < b; i++)
#define sizeOf(A) (sizeof(A))/(sizeof(A[0]))
#define odd(x) ((x) % (2))

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

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

    if ((x <= 7 && odd(x)) || (x >=8 && !(odd(x)))) {
        x = 1;
    } else if (x == 4 || x == 6 || x == 9 || x == 11) {
        x = 2;
    } else {
        x = 3;
    }
    if ((y <= 7 && odd(y)) || (y >=8 && !(odd(y)))) {
        y = 1;
    } else if (y == 4 || y == 6 || y == 9 || y == 11) {
        y = 2;
    } else {
        y = 3;
    }
    (x == y) ? cout << "Yes\n" : cout << "No\n";
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdtr1c++.h>
// typedef __int128 int128;
// typedef __float128 float128;

using namespace std;
using namespace rel_ops;
typedef long long ll;
typedef long double ld;
typedef complex<ld> pt;
typedef vector<pt> pol;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<ld> vd;
typedef vector<vd> vvd;
typedef pair<ll, ll> pii;
typedef vector<pii> vpii;
#define pb push_back


int main(){

  // freopen("A.in", "r", stdin);

  ll N;
  cin >> N;


  ll abc[100010][4];

  ll f[100010][4];
  for (ll i = 1; i <= N; ++i) {
    cin >> abc[i][1] >> abc[i][2] >> abc[i][3];
    if(i == 1) f[i][1] = abc[i][1], f[i][2] = abc[i][2], f[i][3] = abc[i][3];
    else f[i][1] = max(abc[i][1] + f[i-1][2], abc[i][1] + f[i-1][3]),
           f[i][2] = max(abc[i][2] + f[i-1][1], abc[i][2] + f[i-1][3]),
           f[i][3] = max(abc[i][3] + f[i-1][1], abc[i][3] + f[i-1][2]);
  }

  cout << max(max(f[N][1], f[N][2]), f[N][3]) << endl;


}


Measured memory_bytes: 6528
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;
import java.lang.ArithmeticException;

import static java.lang.Integer.parseInt;

/**
 * Zero Division Checker
 */
public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line;
		String[] words;

		Main main = new Main();

		Map<String, Mono> vars = new HashMap<>();

		//
		int m = parseInt(br.readLine());
		for (int i = 0; i < m; i++) {
			words = br.readLine().split(" ");
			vars.put(
					words[0],
					main.new Mono(
							parseInt(words[1]),
							parseInt(words[2])
					)
			);
		}

		//parse
		int n = parseInt(br.readLine());
		StringTokenizer st = new StringTokenizer(br.readLine());
		Deque<Exp> stack = new ArrayDeque<>();

		for (int i = 0; i < n; i++) {
			String e = st.nextToken();
			if ("+-*/".contains(e)) {
				Exp a, b;
				Op op;
				b = stack.pop();
				a = stack.pop();
				switch (e) {
					case "+":
						op = main.new Add();
						break;
					case "-":
						op = main.new Subtract();
						break;
					case "*":
						op = main.new Multiply();
						break;
					case "/":
						op = main.new Divide();
						break;
					default:
						op = null;
				}
				stack.push(main.new Bin(a, b, op));
			} else {
				if (vars.containsKey(e)) {
					stack.push(vars.get(e));
				} else {
					stack.push(main.new Mono(parseInt(e)));
				}
			}
		}

		//solve
		Exp exp = stack.pop();
		try {
			exp.eval();
			System.out.println("correct");
		} catch (ArithmeticException e) {
			System.out.println("error");
		}
	}

	//Operator
	interface Op {
		int eval(int a, int b);
	}

	class Add implements Op {
		@Override
		public int eval(int a, int b) {
			return (a + b) % 256;
		}
	}

	class Subtract implements Op {
		@Override
		public int eval(int a, int b) {
			return (a - b + 256) % 256;
		}
	}

	class Multiply implements Op {
		@Override
		public int eval(int a, int b) {
			return (a * b) % 256;
		}
	}

	class Divide implements Op {
		@Override
		public int eval(int a, int b) {
			return (a / b) % 256;
		}
	}

	//
	interface Exp {
		Exp eval();

		int lb();

		int ub();
	}

	class Mono implements Exp {
		int lb, ub;

		Mono(int lb) {
			this(lb, lb);
		}

		Mono(int lb, int ub) {
			this.lb = lb;
			this.ub = ub;
		}

		public Mono eval() {
			return this;
		}

		public int lb() {
			return lb;
		}

		public int ub() {
			return ub;
		}
	}

	class Bin implements Exp {
		int lb = 256, ub = -1;
		Exp a, b;
		Op op;

		Bin(Exp a, Exp b, Op op) {
			this.a = a;
			this.b = b;
			this.op = op;
		}

		public Exp eval() {

			if (a instanceof Bin) a.eval();
			if (b instanceof Bin) b.eval();

			int alb = a.lb(), aub = a.ub();
			int blb = b.lb(), bub = b.ub();

			for (int i = alb; i <= aub; i++) {
				for (int j = blb; j <= bub; j++) {
					int r = op.eval(i, j);
					lb = Math.min(lb, r);
					ub = Math.max(ub, r);
				}
			}
			return new Mono(lb, ub);
		}

		public int lb() {
			return lb;
		}

		public int ub() {
			return ub;
		}
	}
}

Measured memory_bytes: 25164
n = int(input())

maxcnt = 0
ans = 0
for i in range(1,n+1):
  cnt = 0
  for j in range(1,n):
    if i % 2**j == 0:
      cnt += 1
    else:
      if maxcnt < cnt:
        maxcnt = cnt
        ans = i
      else:
        break
if ans == 0:
  print(1)
else:
  print(ans)

Measured memory_bytes: 3060
N = int(input())
h = list(map(int, input().split()))

INF = 10 ** 12
dp = [INF] * 100010

dp[0] = 0

for i in range(1, N):
    dp[i] = min(dp[i], dp[i-1] + abs(h[i] - h[i-1]))
    if i >= 2:
        dp[i] = min(dp[i], dp[i-2] + abs(h[i] - h[i-2]))

print(dp[N-1])

Measured memory_bytes: 13980
package main

import (
	"fmt"
	"math"
)

func main() {
	var n int
	fmt.Scan(&n)
	for i := 0; i < n; i++ {
		var xa, ya, ra, xb, yb, rb float64
		fmt.Scan(&xa, &ya, &ra, &xb, &yb, &rb)
		// println(xa, ya, ra, xb, yb, rb)
		dis := math.Sqrt((xa-xb)*(xa-xb) + (ya-yb)*(ya-yb))
		if dis + ra < rb {
			fmt.Println(-2)
		} else if dis + rb < ra {
			fmt.Println(2)
		} else if dis > rb + ra {
			fmt.Println(0)
		} else {
			fmt.Println(1)
		}
	}
}


Measured memory_bytes: 1112
//#define __USE_MINGW_ANSI_STDIO 0
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef pair<int, int> PII;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define IN(a, b, x) (a<=x&&x<b)
#define MP make_pair
#define PB push_back
const int INF = (1LL<<30);
const ll LLINF = (1LL<<60);
const double PI = 3.14159265359;
const double EPS = 1e-12;
const int MOD = 1000000007;
#define int ll

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }

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

int n;
ll a[200010], b[200010];

bool check(int m) {
  REP(i, n) {
    int tmp = i==0 ? 0 : b[i-1];
    int itr1 = lower_bound(b+i, b+i+n, tmp+m) - b;
    // cout << b[itr1]+m << " " << *lower_bound(b+i, b+i+n, b[itr1]+m) << endl;
    int itr2 = lower_bound(b+i, b+i+n, b[itr1]+m) - b;
    // cout << "i:" << i << " " << itr1 << " " << itr2 << " " << a[itr1] << " " << a[itr2] << endl;
    if(b[n+i-1] - b[itr2] >= m) return true;
  }
  return false;
}

signed main(void)
{
  cin >> n;
  REP(i, n) cin >> a[i];
  FOR(i, n, 2*n) a[i] = a[i-n];
  b[0] = a[0];
  FOR(i, 1, 2*n) b[i] = a[i] + b[i-1];

  // [low, high)
  ll low=1, high=b[n-1];
  while(high-low>1) {
    ll mid = (low+high)/2;
    // cout << low << " " << mid << " " << high << endl;
    if(check(mid)) {
      low = mid;
    } else {
      high = mid;
    }
  }
  cout << low << endl;

  return 0;
}

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

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

using namespace std;

template<class value_t,class weight_t>
class item{
public:
	value_t v;
	weight_t w;
	item(){}
	item(const value_t& v,const weight_t& w):v(v),w(w){}
};

template<class value_t,class weight_t>
value_t zero_one_knapsack(vector<item<value_t,weight_t>> I,const weight_t& W){
	auto enumerate=[](decltype(I) J){
		decltype(I) res={{0,0}};
		for(const auto& x:J){
			decltype(I) tmp1=res,tmp2=res,tmp3;
			for(auto& y:tmp2) y.v+=x.v, y.w+=x.w;

			merge(tmp1.begin(),tmp1.end(),tmp2.begin(),tmp2.end(),back_inserter(tmp3),
				[](const auto& y1,const auto& y2){
					return make_pair(y1.w,-y1.v)<make_pair(y2.w,-y2.v);
				});

			res.clear();
			for(const auto& y:tmp3) if(res.empty() || res.back().v<y.v) res.emplace_back(y);
		}
		return res;
	};

	int n=I.size();
	decltype(I) I1=enumerate({I.begin(),I.begin()+n/2});
	decltype(I) I2=enumerate({I.begin()+n/2,I.end()});

	value_t res=0;
	for(int i1=0,i2=int(I2.size())-1;i1<I1.size();i1++){
		while(i2>0 && I1[i1].w+I2[i2].w>W) i2--;
		if(I1[i1].w>W) break;
		res=max(res,I1[i1].v+I2[i2].v);
	}
	return res;
}

int main(){
	int n; scanf("%d",&n);
	vector<int> v(n),w(n);
	rep(i,n) scanf("%d%d",&v[i],&w[i]);

	int q; scanf("%d",&q);
	rep(_,q){
		int u,W; scanf("%d%d",&u,&W); u--;

		vector<item<int,int>> I;
		while(1){
			I.emplace_back(v[u],w[u]);
			if(u==0) break;
			u=(u-1)/2;
		}

		printf("%d\n",zero_one_knapsack(I,W));
	}

	return 0;
}


Measured memory_bytes: 5604
// Made by Luis Miguel Baez
// es.luismiguelbaez@gmail.com
 
#include <bits/stdc++.h>
 
using namespace std;
 
#define endl '\n'
#define precise(n,k) fixed << setprecision(k) << n
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
 
#define uint  unsigned int
#define ll    long long
#define ull   unsigned long long
#define ld    long double
 
#define pii   pair<int, int>
#define piii  pair<int, pair<int, int>>
#define pll   pair<ll, ll>
 
#define F  first
#define S  second
#define PB push_back
#define MP make_pair
 
#define debug(...) "[" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
 
string to_string(string s) {
    return '"' + s + '"';
}
 
string to_string(bool b) {
    return (b ? "true" : "false");
}
 
template <typename A, typename B>
string to_string(pair<A, B> p) {
    return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
 
template <typename A, typename T>
string to_string(A v) {
    bool first = true;
    string res = "{";
    for (const T &x : v) {
        if (!first) {
            res += ", ";
        }
        first = false;
        res += to_string((T)x);
    }
    res += "}";
    return res;
}
 
// add templates here

template<class T>
void println(const vector<T> &data) {
    cout << to_string<vector<T>, T>(data) <<endl;
}
 
template<class T>
void println(const T &data) {
    cout << to_string((T)data) << endl;
}
 
const int MOD = int(1e9+7);
const int oo  = int(1e9 + 20);
const ll lloo  = (ll)(1e18 + 10);

int toInt(char num) {
    return num - '0';
}

void solve() {
    int n, L;
    cin >> n >> L;
    int sum = 0;
    int mini = oo;
    int diff = oo;
    for(int i = 1; i <= n; ++i) {
        sum += (L + i - 1);
        if(diff > abs( 0 - (L + i - 1)) )  {
            mini = (L + i - 1);
            diff = abs( 0 - (L + i - 1));
        }
    }
    cout << (sum - mini) << endl;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    
    solve();
    
    return 0;
}

Measured memory_bytes: 3644
#include <iostream>
#include <string>
#include <sstream>
#include <cassert>
using namespace std;

int main()
{
  int A, B, K;
  cin >> A >> B >> K;

  int cnt = 0;
  int C = min(A, B);
  for (; C > 0; --C) {
    if (!(A % C) && !(B % C)) {
      if (++cnt == K) {
        cout << C << endl;
        return 0;
      }
    }
  }

  return 0;
}


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

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

	if (a > c) {
		swap(a, c);
		swap(b, d);
	}

	
	if (b < c) { //patern1
		cout << 0 << endl;
	}
	else if (c <= b && b <= d) {
		cout << b - c << endl;
	}
	else if (c <= b && b > d) {
		cout << d - c << endl;
	}
	



	return (0);
}

Measured memory_bytes: 256
#pragma region include
#include <iostream>
#include <iomanip>
#include <stdio.h>

#include <sstream>
#include <algorithm>
#include <cmath>
#include <complex>

#include <string>
#include <cstring>
#include <vector>
#include <tuple>
#include <bitset>

#include <queue>
#include <complex>
#include <set>
#include <map>
#include <stack>
#include <list>

#include <fstream>
#include <random>
//#include <time.h>
#include <ctime>
#pragma endregion //#include
/////////
#define REP(i, x, n) for(int i = x; i < n; ++i)
#define rep(i,n) REP(i,0,n)
/////////
#pragma region typedef
typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;
#pragma endregion //typedef
////定数
const int INF = (int)1e9;
const LL MOD = (LL)1e9+7;
const LL LINF = (LL)1e18;
const double PI = acos(-1.0);
const double EPS = 1e-9;
/////////
using namespace::std;

/*
N:項数 D:初項 X:項差
項数は玉左右移動の分で、玉の数の2倍ある。
*/
LD f(int N,LD D,LD X){
	//LD ans = 1.0*(D + D+X*(N-1) )*N/2/N;
	LD ans = 1.0*(2.0*D + X*(N-1) )/2.0;
	//cerr << ans << " ";
	LD res;
	LD nextD,nextX;//初項と、項差
	nextD = 1.0*(1.0*(N+2)*D + 5*X)/(N);
	nextX = 1.0*(4+N)*X/(N);
	if( N > 2 ){
		//cerr << nextD << " " << nextX << endl;
		ans += f(N-2,nextD,nextX) ;
	}
	return ans;
}
void solve(){
	int N;
	LD d,x;
	cin >> N >> d >> x;
	LD ans = f(2*N,d,x);
	cout << ans << endl;
}
#pragma region main
signed main(void){
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	std::cout << std::fixed;//小数を10進数表示
	cout << setprecision(16);//小数点以下の桁数を指定//coutとcerrで別	
	
	solve();
}
#pragma endregion //main()


Measured memory_bytes: 15872
#include<iostream>
#include<string>
#include<vector>
#include<iomanip>
#include<algorithm>
#include<queue>
#include<stack>
#include<map>
#include<math.h>
using namespace std;
#define ll long long
int main(){
	ll i,j,k;
	ll ans;
	ll a,b,N,K;
	ll l,r,t;
	cin >> N >>K;
	ll A[N],F[N];
	long long zero=0;
	for(i=0;i<N;i++){
		cin >> A[i];
	}
	for(i=0;i<N;i++){
		cin >> F[i];
	}
	sort(A,A+N);
	sort(F,F+N);
	l=-1,r=1000000000000000;
	ll sum;
	while(r-l>1){
		t=(l+r)/2;
		sum=0;
		for(i=0;i<N;i++){
			sum+=max(A[N-1-i]-t/F[i],zero);
		}
		if(K>=sum)r=t; else l=t;
	}
	cout << r;
    return 0;
}


Measured memory_bytes: 3328
using System;

namespace HelloWorld
{
    class Program
    {
        static void Main(string[] args)
        {
            for (int i = 1; i > 0; i++)
            {
                int x = int.Parse(Console.ReadLine());
                if (x == 0) break;
                else Console.WriteLine("Case {0}: {1}", i, x);
            }

        }
    }
}


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

int main() {
  int n;
  cin>>n;
  vector<int>a(n);
  rep(i,n){
    cin>>a.at(i);
  }
  sort(a.begin(),a.end());
  int ans=0;
  rep(i,n-2){
    rep2(j,i+1,n-1){
      int d=a.at(i)+a.at(j);
      ans+=lower_bound(a.begin(),a.end(),d)-a.begin()-j-1;
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
import java.util.*;

public class Main{
	public static int n;
	public static int [] arr;
	public static int[] dp;
	public static int minCost(int pos)
	{
		if(pos>=n-1) 
			return 0;
		if(dp[pos]!=-1)
			return dp[pos];
		int onestep=Integer.MAX_VALUE;
		int twostep=Integer.MAX_VALUE;
		if(pos+1<n)
		{
			onestep=Math.abs(arr[pos]-arr[pos+1])+minCost(pos+1);
		//	System.out.println(onestep);
		}
		if(pos+2<n)
		{
			twostep=Math.abs(arr[pos]-arr[pos+2])+minCost(pos+2);
			//System.out.println(twostep);
		}
		return dp[pos]=Math.min(onestep, twostep);
	}
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner in=new Scanner(System.in);
		n=in.nextInt();
		arr=new int[n];
		dp=new int[n];
		for(int i=0;i<n;i++)
			arr[i]=in.nextInt();
		Arrays.fill(dp,-1);
		System.out.println(minCost(0));
		
	}

}


Measured memory_bytes: 71468
#pragma GCC optimize ("O3")
#pragma GCC target ("tune=native")
#pragma GCC target ("avx")

#include <bits/stdc++.h>

// 汎用マクロ
#define ALL_OF(x) (x).begin(), (x).end()
#define REP(i,n) for (long long i=0, i##_len=(n); i<i##_len; i++)
#define RANGE(i,is,ie) for (long long i=(is), i##_end=(ie); i<=i##_end; i++)
#define UNIQUE(v) (v).erase(unique((v).begin(), (v).end()), (v).end())
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 (a > b) {a = b; return 1;} return 0; }
#define INF 0x7FFFFFFF
#define LINF 0x7FFFFFFFFFFFFFFFLL
#define Yes(q) (q ? "Yes" : "No")
#define YES(q) (q ? "YES" : "NO")
#define DUMP(q) cerr << "[DEBUG] " #q ": " << (q) << " at " __FILE__ ":" << __LINE__ << endl
#define DUMPALL(q) cerr << "[DEBUG] " #q ": ["; REP(dumpall_i, (q).size()) { cerr << q[dumpall_i] << (dumpall_i == (q).size() - 1 ? "" : ", "); } cerr << "] at " __FILE__ ":" << __LINE__ << endl

// gcc拡張マクロ
#define gcd __gcd
#define popcount __builtin_popcount
#define popcountll __builtin_popcountll

// エイリアス
using  ll = long long;
using ull = unsigned long long;
using  ld = long double;
using namespace std;

// モジュール


// 処理内容
int main() {
    
    int a, b, c;
    cin >> a >> b >> c;
    cout << Yes((a <= c && c <= b) || (a >= c && c >= b)) << endl;
    
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define jaldi ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
int main() {

    jaldi

    long long int n;
    cin>>n;
    vector<long long int> a(n);
    for(long long int i=0;i<n;i++) {
        cin>>a[i];
    }
    long long int maxi = a[0];
    long long int ans =0;
    for(long long int i=1;i<n;i++) {
        if(a[i]<maxi) {
            ans+=(maxi-a[i]);
        }
        else {
            maxi = a[i];
        }
    }
    cout<<ans<<'\n';
}


Measured memory_bytes: 4780
s = input()
l = len(s)
ans = [0 for i in range(l)]

cntR = 0
cntL = 0
for i in range(l):

    if s[i] == 'R':
        cntR += 1
    else:
        if cntR > 0:
            ans[i - 1] += (cntR + 1) // 2
            ans[i] += cntR // 2
        cntR = 0
    j = l - 1 - i
    if s[j] == 'L':
        cntL += 1
    else:
        if cntL > 0:
            ans[j + 1] += (cntL + 1) // 2
            ans[j] += cntL // 2
        cntL = 0

print(" ".join(map(str, ans)))


Measured memory_bytes: 10484
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define int ll
#define rep(i,n) for(int i=0;i<n;i++)
#define all(in) in.begin(), in.end()
#define INF (sizeof(int) == 4 ? (int)1e9:(int)1e18)
#define EPS 0.0000000001
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
template<typename Head, typename Value> auto vectors(const Head &head, const Value &v) { return vector<Value>(head, v); }
template<typename Head, typename... Tail> auto vectors(Head x, Tail... tail) { auto inner = vectors(tail...); return vector<decltype(inner)>(x, inner); }
using ld  = long double;
using pii = pair<int,int>;
using piii = pair<int,pii>;
int W,H;
int dx[]={0,0,1,-1}, dy[]={1,-1,0,0};
bool valid(int x,int y){return (0<=x&&x<W)&&(0<=y&&y<H);}
signed main(){
    int N,L; cin >> N >> L;
    int ans = (1LL << 60);
    vector<int>res(N);
    sort(all(res));
    rep(i,N) res[i] = L + i;
    auto itr = lower_bound(all(res),0LL);
    cout << accumulate(all(res),0LL) - (itr != res.end() ? *itr  :res.back()) << endl;
}


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

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

int main(){
	int n;
	vector<int> a;
	cin >> n;
	a.resize(n);
	rep(i,n)	cin >> a[i];
	sort( a.begin(), a.end() );
	cout << a[0];
	for( int i=1; i<n; i++ )
		cout << " " << a[i];
	cout << endl;
	return 0;
}

Measured memory_bytes: 8984
#include <iostream>
#include <iomanip>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <algorithm>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
const ll mod=1e9+7;

int main(){
	string S;
	cin >> S;
	ll K;
	cin >> K;

	ll l = S.length();
	ll count=1; //同じ文字が連続する個数
	ll one=0; //Sの場合の回数
	ll two=0; //S+Sの場合の回数

	char prev=S[0];
	for(int i=1; i<l; i++){
		if(prev==S[i]){
			count++;
		}else{
			two+=count/2;
			count=1;
		}
		prev=S[i];
	}
	one=two;
	if(prev==S[l-1]){
		one+=count/2;
	}
	for(int i=0; i<l; i++){
		if(prev==S[i]){
			count++;
		}else{
			two+=count/2;
			count=1;
		}
		prev=S[i];
	}
	if(prev==S[l-1]){
		two+=count/2;
	}

	if(count==l*2){ //"aaa"などの場合
		if(K%2==0){ //Kが偶数
			cout << two*(K/2) << endl;
		}else{ //Kが奇数
			cout << one + two*(K/2) << endl;
		}
	}else{
		cout << one + (two-one)*(K-1) << endl;
	}
	return 0;
}

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

using namespace std;

typedef long long ll;

const int MAX_N = 1000001;

int N, primeCount;
bool isPrime[MAX_N];
set<int> sa;

int gcd(int a, int b) {
  if(a == 0) return b;
  return gcd(b % a, a);
}

void sieve() {
  for(int i = 2; i < MAX_N; ++i) isPrime[i] = 1;
  for(int i = 2; i * i < MAX_N; ++i) {
    if(!isPrime[i]) continue;
    for(int j = i; i * j < MAX_N; ++j) {
      isPrime[i * j] = 0;
    }
  }
  for(int i = 2; i < MAX_N; ++i) {
    if(isPrime[i]) ++primeCount;
  }
}

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

  sieve();

  cin >> N;
  int all = 0;
  for(int i = 0; i < N; ++i) {
    int num;
    cin >> num;
    all = gcd(all, num);
    sa.insert(num);
  }

  if(all != 1) cout << "not coprime\n";
  else {
    set<int> pfactors; pfactors.clear();
    for(int a: sa) {
      if(isPrime[a]) {
        if(pfactors.find(a) != pfactors.end()) {
          cout << "setwise coprime\n";
          return 0;
        }
        pfactors.insert(a);
      } else {
        for(int j = 2; j * j <= a; ++j) {
          if(a % j == 0) {
            if(isPrime[j]) {
              if(pfactors.find(j) != pfactors.end()) {
                cout << "setwise coprime\n";
                return 0;
              }
              pfactors.insert(j);
            }
            if(j * j < a && isPrime[a / j]) {
              if(pfactors.find(a / j) != pfactors.end()) {
                cout << "setwise coprime\n";
                return 0;
              }
              pfactors.insert(a / j);
            }
          }
        }
      }
    }
    cout << "pairwise coprime\n";
  }
  return 0;
}

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

#define ll long long

#define fr(i,a,b) for (ll i = (a), _b = (b); i <= _b; i++)
#define frr(i,a,b) for (ll i = (a), _b = (b); i >= _b; i--)
#define rep(i,n) for (ll i = 0, _n = (n); i < _n; i++)
#define repr(i,n) for (ll i = n - 1; i >= 0; i--)
#define fill(ar,val) memset(ar, val, sizeof(ar))
#define fill0(ar) fill((ar), 0)
#define debug(x) cout<<#x<<": "<<x<<endl

#define ld double
#define pb push_back
#define mp make_pair
#define ff first
#define ss second

typedef pair<int, int> ii;
typedef pair<ii, int> iii;
typedef vector<ii> vii;
typedef vector<int> vi;

#define INF 1000000000000000000

ll n,m;
vector<ll> ed[100001];
ll vis[100001];
ll max1[100001];

ll DFS(ll src, ll par)
{
    vis[src] = 1;

    rep(i,ed[src].size())
    {
        if(ed[src][i]==par)
            continue;
        if(vis[ed[src][i]])
            max1[src] = max(max1[src], max1[ed[src][i]]);
        else
        {
            DFS(ed[src][i],src);
            max1[src] = max(max1[src], max1[ed[src][i]]);
        }
    }

    max1[src]++;
    return max1[src];
}

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

    cin >> n >> m;

    rep(i,m)
    {
        ll x,y;
        cin >> x >> y;

        ed[x].pb(y);
    }

    fr(i,1,n)
    {
        max1[i] = -1;
    }

    fr(i,1,n)
    {
        if(!vis[i])
            DFS(i,0);
    }

    ll ans = 0;

    fr(i,1,n)
    {
        ans = max(ans, max1[i]);
    }

    cout << ans << endl;
}

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

#define F first
#define S second
#define PB push_back
#define MP make_pair
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define read(x) int x; cin>>x;
#define print(x) for(int i=0; i<(int) x.size(); i++) cout<<x[i]<<" "; cout<<endl;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> pi;

const ll INFLL = (ll) 1e16;
const int INF = (int) 1e8;

vector<bool> visited((int) 2e5+5, false);
vector<ll> path;
vector<ll> teleport((int) 2e5+5);
ll cycle_begins;

void dfs(int source) {
	if(visited[source]) {
		cycle_begins = source;
	} else {
		visited[source] = true;
		path.push_back(source);
		dfs(teleport[source]);
	}
}

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	ll n, k;
	cin>>n>>k;
	
	for(int i=1; i<=n; i++) {
		ll t; cin>>t;
		teleport[i] = t;
	}
	dfs(1);
	
	ll non_cycle = 0;
	for(int i=0; i<(int) path.size(); i++) {
		if(path[i] == cycle_begins) break;
		non_cycle++;
	}
	
	ll cycle = (ll) path.size() - non_cycle;
	//cout<<non_cycle<<" "<<cycle<<endl;
	if(k<non_cycle) cout<<path[k]<<endl;
	else {
		k-=non_cycle;
		cout<<path[non_cycle+(k%cycle)]<<endl;
	}
	
	return 0;
}


Measured memory_bytes: 12496
#include <stdio.h>
int main(void)
{
    double r, S ,L, PI=3.14159265358979323846;
    
    scanf("%lf",&r);
    
    S = r* r* PI;
    L = 2* r* PI;
    
    printf("%.6f %.6f",S ,L);
    
    return 0;
}

Measured memory_bytes: 652
n,a,b,c,d=map(int,input().split())
a-=1
b-=1
c-=1
d-=1

s=input()

if c<d or c<b:
    #先にbをdに運んでから、aをCに運べばいい
    if s[b:d+1].count("##")==0 and s[a:c+1].count("##")==0:
        print("Yes")
    else:
        print("No") 
else:
    if s[b-1:d+2].count("...")==0:
        print("No")
    else:
        if s[b:d+1].count("##")==0 and s[a:c+1].count("##")==0:
            print("Yes")
        else:
            print("No") 






Measured memory_bytes: 40816
#include <bits/stdc++.h>
#include <stdio.h>
#include <cmath>

using namespace std;

#define rep(i,n) for(long long i=0; i<(long long)(n);i++)
//rep…「0からn-1まで」の繰り返し
#define rep2(i,s,n) for(long long i=s; i<=(long long)(n);i++)
//rep2…「sからnまで」の繰り返し
#define repr(i,s,n) for(long long i=s;i>=(long long)(n);i--)
//repr…「ｓからnまで」の降順の繰り返し

typedef long long ll;

const ll inf = 1e18+7;
const ll mod = 1e9+7;

//階乗
int factorial(int k){
    int result=1;
    for (int i=1;i<=k;++i){
        result*=i;
    }
    return result;
}

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

    ll G=0,ans=0;

    rep2(i,1,k){
        rep2(j,1,k){
            rep2(l,1,k){
                G=__gcd(i,j);
                ans+=__gcd(G,l);
            }
        }
    }

    cout<<ans<<endl;
}



Measured memory_bytes: 3632
#include <cstdio>

using namespace std;

int main(){
  int min,max,sum,n,score;

  while(1){
    scanf("%d",&n);
    if(!n) break;

    max=0;min=10000;sum=0;

    for(int i=0;i<n;i++){
        scanf("%d",&score);
        if(max<score) max=score;
        if(min>score) min=score;
        sum+=score;
    }

    printf("%d\n",(sum-max-min)/(n-2));
  }
    return 0;
}

Measured memory_bytes: 1028
from math import gcd

K = int(input())

gcds = [[None] * (K+1) for _ in range(K+1)]
for i in range(1, K+1):
    for j in range(i, K+1):
        gcds[i][j] = gcds[j][i] = gcd(i, j)

ans = 0
for i in range(1, K+1):
    for j in range(1, K+1):
        g = gcds[i][j]
        for k in range(1, K+1):
            ans += gcds[g][k]

print(ans)

Measured memory_bytes: 9256
#include <iostream>
    #include <math.h>
    #include <vector>
    #include <string>
    using namespace std;
    
    int func(int n){
        int out =(n%2==0) ? (n/2) : (3*n + 1);
        return out;
    }

    int main() {
        int n;cin>>n;
        int max =0;
        int sum=0;
        for(int i =0;i<n;i++){
            int p; cin >> p;
            sum+=p;
            max = (max < p) ? p: max;
        }
        cout << sum - max/2 <<endl;
    
        return 0;
    }

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int x;
    string a;
    cin>>x>>a;
    int len=a.length();
    if(len<=x)
        cout<<a<<endl;
    else
    {
        for(int i=0;i<x;i++)
        {
            cout<<a[i];
        }
        cout<<"..."<<endl;
    }

    return 0;
}



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

//関数
    
    
    
    
//main関数
int main() {
    
    
    
    //入力
    int A,B,C;
    cin>>A>>B>>C;
    
    
    
    
    
    
    
    
    
    
    //計算
    
    
    
    
    
    
    
    
    
    
    
    //出力
    cout<<B+min(A+B+1,C)<<endl;
}

Measured memory_bytes: 256
def abc144b():
    n = int(input())

    start = 1
    end = 9
    ans = 'No'

    # シンプルな全探索
    for i in range(start, end + 1):
        for j in range(start, end + 1):
            if n == i * j:
                ans = 'Yes'
                break
    print(ans)


if __name__ == '__main__':
    abc144b()

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

#define rep(i, m, n) for(int(i) = (int)(m); i < (int)(n); ++i)
#define rep2(i, m, n) for(int(i) = (int)(n)-1; i >= (int)(m); --i)
#define REP(i, n) rep(i, 0, n)
#define REP2(i, n) rep2(i, 0, n)
#define all(hoge) (hoge).begin(), (hoge).end()
#define en '\n'
using ll = long long;
using ull = unsigned long long;
using ld = long double;
template <class T>
using vec = vector<T>;
template <class T>
using vvec = vector<vec<T>>;
typedef pair<ll, ll> P;
constexpr long long INF = 1LL << 60;
constexpr int INF_INT = 1 << 25;
constexpr long long MOD = (ll)1e9 + 7;
//constexpr long long MOD = 998244353LL;
using ld = long double;
static const ld pi = 3.141592653589793L;
typedef vector<ll> Array;
typedef vector<Array> Matrix;

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

struct Edge {
    ll to, rev;
    long double cap;
    Edge(ll _to, long double _cap, ll _rev) {
        to = _to;
        cap = _cap;
        rev = _rev;
    }
};
using Edges = vector<Edge>;
using Graph = vector<Edges>;

void add_edge(Graph &G, ll from, ll to, long double cap, bool revFlag,
              long double revCap) {
    G[from].push_back(Edge(to, cap, (ll)G[to].size()));
    if(revFlag)
        G[to].push_back(Edge(from, revCap, (ll)G[from].size() - 1));
}

void solve() {
    ll n;
    cin >> n;
    vec<ll> a(n), b(n), c(n);
    REP(i, n) { cin >> a[i]; }
    REP(i, n) { cin >> b[i]; }
    REP(i, n) { cin >> c[i]; }
    sort(all(a));
    sort(all(b));
    sort(all(c));

    ll ans = 0;
    REP(i, n) {
        ll cc = c.end() - upper_bound(all(c), b[i]);
        ll aa = lower_bound(all(a), b[i]) - a.begin();
        ans += aa * cc;
    }
    cout << ans << en;
}

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

    solve();

    /*
    ll t;
    cin >> t;
    REP(i, t) { solve();}
    */

    return 0;
}


Measured memory_bytes: 5560