akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
ll binpow(ll a,ll b)
{
    ll res=1;
    while(b>0)
    {
        if(b&1)
            res=res*a;
        a=a*a;
        b/=2;
    }
    return res;
}
int main()
{
    ll n,a,b,c;
    cin>>n>>a>>b>>c;
    string s[n];
    vector<char> as;
    bool k=true;
    for(int x=0;x<n;x++)
        cin>>s[x];
    for(int x=0;x<n;x++)
    {
        if(s[x]=="AB")
        {   if(a==b && b==1)
              {
                  if(x<n-1 && s[x+1]=="BC")
                  {
                    as.pb('B');
                    --a;
                    ++b;
                  }
                  else
                  {
                   as.pb('A');
                    --b;
                    ++a;
                  }
                  continue;
              }
            if(a>=0 && b>=0)
            {
                if(a>b)
                    {as.pb('B');
                    --a;
                    ++b;
                    }
                else
                    {as.pb('A');
                    --b;
                    ++a;}
            }
        }
        else if(s[x]=="BC")
        {
            if(b>=0 && c>=0)
            {   if(c==b && b==1)
              {
                  if(x<n-1 && s[x+1]=="AC")
                  {
                    as.pb('C');
                    --b;
                    ++c;
                  }
                  else
                  {
                   as.pb('B');
                    ++b;
                    --c;
                  }
                  continue;
              }

                if(b>=c)
                    {as.pb('C');
                    --b;
                    ++c;
                    }
                else
                    {as.pb('B');
                    --c;
                    ++b;}
            }
        }
        else
        {
            if(a>=0 && c>=0)
            {   if(c==a && a==1)
              {
                  if(x<n-1 && s[x+1]=="AB")
                  {
                    as.pb('A');
                    ++a;
                    --c;
                  }
                  else
                  {
                   as.pb('C');
                    ++c;
                    --a;
                  }
                  continue;
              }
                if(a>=c)
                    {as.pb('C');
                    --a;
                    ++c;
                    }
                else
                    {as.pb('A');
                    --c;
                    ++a;}
            }
        }
        if(a<0 || b<0 || c<0)
            k=false;
    }
    if(k)
    {
        cout<<"Yes\n";
        for(auto it : as)
            cout<<it<<"\n";
    }
    else
        cout<<"No\n";
}


Measured memory_bytes: 6856
#include<cstdio>
        int main()
        {
        	long long int a[100];
        	int n;
        	a[0]=2ll,a[1]=1ll;
        	while(~scanf("%d",&n)){
        		for(int i=2;i<=n;i++)
        		{
        			a[i]=a[i-1]+a[i-2];
        		}
        	printf("%lld\n",a[n]);}
        	return 0;
        }

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007

ll a[10],ans,n;
void cal(){
	ll sum=0;
	bool c3,c5,c7,c0;
	c3=c5=c7=c0=false;
	for(ll i=0;i<10;i++){
		sum=sum*10+a[i];
		if(a[i]==3){
			c3=true;
		}
		else if(a[i]==5){
			c5=true;
		}
		else if(a[i]==7){
			c7=true;
		}
		else if(c3||c5||c7){
			return;
		}
	}
	if(c3&&c5&&c7){
		if(sum<=n){
			ans++;
			//cout <<sum<<endl;
		}
	}
}
void dep(ll now){
	if(now==10){
		cal();
		return ;
	}
	a[now]=0;dep(now+1);
	a[now]=5;dep(now+1);
	a[now]=3;dep(now+1);
	a[now]=7;dep(now+1);
}
int main() {
	cin>>n;
	dep(0);
	cout <<ans;
	// your code goes here
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

#define MAX_SIZE 2000000

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

	int V[MAX_SIZE];
	int i;
	for (i = 0; i < n; i++) {
		int tmp;
		scanf("%d", &tmp);
		V[i] = tmp;
	}

	int max_value = -999999999;

	int min_value = V[0];
	for (i = 1; i < n; i++) {
		if (max_value < (V[i] - min_value)) {
			max_value = V[i] - min_value;
		}
		if (min_value > V[i]) {
			min_value = V[i];
		}
	}

	printf("%d\n", max_value);
	return 0;
}

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

int n, l, x, total;

int main() {
	cin >> n >> l;
	for (int i=1; i<=n; i++) {
		total=total+l+i-1;
	}
	if (l>=0) {
		total=total-l;
	}
	else {
		if (n<1-l) {
			total=total-l-n+1;
		}
	}
	cout << total << endl;
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
using namespace std;
typedef long long int lli;
typedef unsigned long long int ulli;
#define vec(s) vector

#define vvec(s) vector<vector
>
typedef vector<lli> vi;
typedef vector<vi> vvi;
typedef pair<lli,lli> pii;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define YN(x) cout<<(x?"Yes":"No")<<endl;
#define out(s) cout<<s<<endl;
#define pb(s) push_back(s);
#define sp " ";
#define INF 10000000000
#define LINF 9000000000000000000
#define all(s) s.begin(),s.end()
void vout(vi v){
    for(int i=0;i<v.size();i++)
    cout<<v.at(i)<<endl;
}
int main(){
    lli n,k;
    cin >> n >> k;
    lli ans = (log(n)) / ((log)(k));
    out(ans+1);
}

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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ull mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template < typename T >
void vprint(T &v){
	REP(i, v.size()){
		cout << v[i] << " ";
	}
	cout << endl;
}

int main(){
	ll a, b;
	cin >> a >> b;
	if(a+b==15){
		cout << '+' << endl;
	}else if(a*b==15){
		cout << '*' << endl;
	}else{
		cout << 'x' << endl;
	}
    return 0;
}

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

#define rng(i, a, b) for (int i = int(a); i < int(b); i++)
#define rep(i, b) rng(i, 0, b)
#define gnr(i, a, b) for (int i = int(b) - 1; i >= int(a); i--)
#define per(i, b) gnr(i, 0, b)

using namespace std;

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

int n, m, q;
vector<int> a, b, c, d;

ll calcSum(vector<int> &A) {
  ll sum = 0;
  rep(i, q) {
    if (A[b[i]] - A[a[i]] == c[i]) {
      sum += d[i];
    }
  }
  return sum;
}

ll dfs(vector<int> &A) {
  if (A.size() == n) {
    return calcSum(A);
  }
  ll res = INT_MIN;
  int last = A.empty() ? 1 : A.back();
  for (int i = last; i <= m; i++) {
    A.push_back(i);
    res = max(res, dfs(A));
    A.pop_back();
  }
  return res;
}

int main() {
  cin >> n >> m >> q;
  a.resize(q), b.resize(q), c.resize(q), d.resize(q);
  rep(i, q) {
    int aa, bb, cc, dd;
    cin >> aa >> bb >> cc >> dd;
    aa--;
    bb--;
    a.at(i) = aa;
    b.at(i) = bb;
    c.at(i) = cc;
    d.at(i) = dd;
  }
  vector<int> A = vector<int>();
  ll res = dfs(A);
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 3612
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧  
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     
　　　　／　　　＼　 　  |　|     
　　　 /　　 /￣￣￣￣/　　|  
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿  
　 　　　＼/＿＿＿＿/　（u　⊃  
---------------------------------------------------------------------------------------------------*/






int N;
vector<pair<int, int>> E[101010];
//---------------------------------------------------------------------------------------------------
int ans[101010];
void dfs(int cu, int pa = -1, int col = 0) {
	ans[cu] = col;
	fore(p, E[cu]) {
		if (p.first == pa) continue;

		if (p.second % 2 == 0) dfs(p.first, cu, col);
		else dfs(p.first, cu, 1 - col);
	}
}
//---------------------------------------------------------------------------------------------------
void _main() {
	cin >> N;
	rep(i, 0, N - 1) {
		int a, b, c; cin >> a >> b >> c;
		a--; b--;

		E[a].push_back({ b,c });
		E[b].push_back({ a,c });
	}

	dfs(0);

	rep(i, 0, N) printf("%d\n", ans[i]);
}

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

using namespace std ;

std :: priority_queue < string, vector < string >, greater < string > > Q ;

int main ( )  {
	string s, t ;
	cin >> s >> t ;
	string ans ;
	for ( int i = 0 ; i < s.length ( ) ; ++ i )  {
		ans = s ;
		if ( s [i] == t [0] || s [i] == '?' )  {
			int j ;
			for ( j = 0 ; j < t.length ( ) ; ++ j )  {
				if ( s [i + j] == t [j] || s [i + j] == '?' )  ans [i + j] = t [j] ;
				else  break ;
			}
			if ( j == t.length ( ) )  {
				for ( int k = 0 ; k < s.length ( ) ; ++ k )
					if ( ans [k] == '?' )  {
						ans [k] = 'a' ;
					}
				Q.push ( ans ) ;
			}
		}
	}
	if ( Q.empty ( ) )  {
		return puts ( "UNRESTORABLE" ), 0 ;
	}
	ans = Q.top ( ) ;
	for ( int i = 0 ; i < ans.length ( ) ; ++ i )  {
		putchar ( ans [i] ) ;
	}
	puts ( "" ) ;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
    static int[] heap = new int[2000000];
    static int h = 0;
    static StringBuilder sb = new StringBuilder();

    public static void main(String[] args) throws IOException {
        BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
        String s;
        do {
            s = bf.readLine();
            if (s.charAt(2) == 's') {
                insert(Integer.parseInt(s.substring(7)));
            }else if (s.charAt(2)=='t'){
                extractMax();
            }
        } while (s.length() != 3);
        System.out.print(sb);
    }

    private static void extractMax() {
        sb.append(heap[1]).append("\n");
        change(1,h);
        h--;
        maxHeapify(1);
    }

    private static void insert(int m) {
        h++;
        heap[h] = m;
        int k =h;
        while (k / 2 > 0) {
            k=k/2;
            maxHeapify(k);
        }
    }

    private static void bulidMaxHeap() {
        for (int i = h  / 2; i > 0; i--) {
            maxHeapify(i);
        }
    }

    private static void maxHeapify(int i) {
        int l = 2 * i;
        int r = 2 * i + 1;
        int largest = i;
        if (l <= h && heap[l] > heap[i]) {
            largest = l;
        }
        if (r <= h && heap[r] > heap[largest]) {
            largest = r;
        }
        if (largest != i) {
            change(i, largest);
            maxHeapify(largest);
        }
    }

    private static void change(int i, int j) {
        int i1 = heap[i];
        heap[i] = heap[j];
        heap[j] = i1;
    }
}


Measured memory_bytes: 123152
#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define fi first
#define se second
#define mp make_pair
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,K,A,B;
string S;
string alpha = "abcdefghijklmnopqrstuvwxyz";
string ALPHA = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
vec pa(51,-1),num(51,-1);

ll dfs(ll level, ll &eat){
    if(eat == 0) return 0;
    if(level == 0){
        --eat;
        return 1;
    }
    ll ans = 0;
    //バン
    --eat;
    if(eat == 0) return ans;
    //N-1レベル
    if(eat >= num.at(level-1)){
        eat -= num.at(level-1);
        ans += pa.at(level-1);
    }else{
        ans += dfs(level-1,eat);
    }
    if(eat == 0) return ans;
    //パティ
    --eat;
    ++ans;
    if(eat == 0) return ans;
    //N-1レベル
    if(eat >= num.at(level-1)){
        eat -= num.at(level-1);
        ans += pa.at(level-1);
    }else{
        ans += dfs(level-1,eat);
    }
    if(eat == 0) return ans;
    //バン
    --eat;
    return ans;
}

int main(){
    cin>>N>>K;
    rep(i,51){
        pa.at(i) = (1LL<<(i+1))-1;
        num.at(i) = (1LL<<(i+2))-3;
    }
    cout<<dfs(N,K)<<endl;
}


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

int main()
{
    constexpr int INF = 1000000000;
    
    int h = 0;
    int n = 0;
    std::cin >> h >> n;
    
    std::vector<std::vector<int>> dp(n + 1, std::vector<int>(h + 1, INF));
    dp.at(0).at(0) = 0;
    
    for(int i = 0; i < n; ++i)
    {
        int a = 0;
        int b = 0;
        std::cin >> a >> b;
        for(int j = 0; j <= h; ++j)
        {
            dp.at(i + 1).at(j) = std::min(dp.at(i + 1).at(j), dp.at(i).at(j));
            dp.at(i + 1).at(std::min(j + a, h)) = std::min(
                dp.at(i + 1).at(std::min(j + a, h)),
                dp.at(i + 1).at(j) + b);
        }
    }
    
    std::cout << dp.at(n).at(h) << std::endl;
}

Measured memory_bytes: 39424
#include<bits/stdc++.h>
using namespace std;
const int N=2005;
int l[N][N],r[N][N],n,m,ans=-1;
char c[N][N];
int main()
{
	cin>>n>>m;
	for(int i=0;i<n;i++)cin>>c[i];
	for(int i=0;i<n;i++)
	{
		int ji=0,last=0;
		for(int j=0;j<m;j++)
		{
			if(c[i][j]=='#')
			{
				for(int k=last;k<j;k++)l[i][k]=ji;
				ji=0;
				last=j+1;
			}
			else
				ji++;
		}
		for(int k=last;k<m;k++)l[i][k]=ji;
	}
	for(int j=0;j<m;j++)
	{
		int ji=0,last=0;
		for(int i=0;i<n;i++)
		{
			if(c[i][j]=='#')
			{
				for(int k=last;k<i;k++)r[k][j]=ji;
				ji=0;
				last=i+1;
			}
			else
				ji++;
		}
		for(int k=last;k<n;k++)r[k][j]=ji;
	}
	for(int i=0;i<n;i++)
		for(int j=0;j<m;j++)
			if(c[i][j]=='.')
				ans=max(ans,l[i][j]+r[i][j]-1);
	cout<<ans<<endl;
	return 0;
}
/*
8 8
..#...#.
....#...
##......
..###..#
...#..#.
##....#.
#...#...
###.#..#
*/

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

int main() {
  int x, y, z;
  cin >> x >> y >> z;

  int t = x;
  x = y;
  y = t;

  t = x;
  x = z;
  z = t;

  cout << x << " " << y << " " << z << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
int main (void){
 int n;
 int i;
 int a[10000];
 int max;
 int min;
 long int totall=0;
  scanf("%d",&n);
for(i=0;i<n;i++){
  scanf("%d",&a[i]);
}
max=min=a[0];
  for(i=0;i<n;i++){
if(max<a[i]){
max=a[i];
}
if(min>a[i]){
min=a[i];
}
totall=totall+a[i];
}
printf("%d %d %ld\n",min,max,totall);
return 0;
}

Measured memory_bytes: 636
#include <bits/stdc++.h>
#define REP(i,n,N) for(int i=n;i<N;i++)
#define p(S) cout<<(S)<<endl
#define ck(n,a,b) ((a)<=(n)&&(a)<(b))
#define F first
#define S second
using namespace std;
const double inf=1e9;
double dist[30][1<<8];
int main(){
	int n,m,p,a,b;
	while(cin>>n>>m>>p>>a>>b,n){
		a--;b--;
		int t[8];
		REP(i,0,n) cin>>t[i];
		vector<pair<int,int>> edge[30];//dist,node
		REP(i,0,p){
			int x,y,z;
			cin>>x>>y>>z;
			x--;y--;
			edge[x].push_back({z,y});
			edge[y].push_back({z,x});
		}
		REP(i,0,m) REP(j,0,(1<<n))dist[i][j]=inf;
		priority_queue<pair<double,pair<int,int>>> pq;//dist,baken,node
		pq.push({0,{0,a}});
		dist[a][0]=0;
		//Dijkstra
		while(!pq.empty()){
			auto now=pq.top();pq.pop();
			double nd=-now.F;
			int nb=now.S.F,nn=now.S.S;
			if(nd>dist[nn][nb]) continue;
			if(nb==(1<<n)-1) continue;
			for(auto e:edge[nn]){
				double nxd=e.F;
				int nxn=e.S;
				REP(i,0,n){
					if(nb &(1<<i)) continue;
					if(dist[nxn][nb|(1<<i)]>nd+nxd/t[i]){
						dist[nxn][nb|(1<<i)]=nd+nxd/t[i];
						pq.push({-dist[nxn][nb|(1<<i)],{nb|(1<<i),nxn}});
					}
				}
			}
		}
		double mn=inf;
		REP(i,0,(1<<n)) mn=min(mn,dist[b][i]);
		if(mn==inf){
			p("Impossible");
			continue;
		}
		printf("%.4lf\n",mn);
	}

	return 0;
}

Measured memory_bytes: 4504
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <vector>
#define Rep(i, n) for(int i=0;i<n;++i)
#define rep(i, n) for(int i=1;i<=n;++i)
#define ll long long int
#define INF 1e9
#define LINF 1e18
#define MOD 1000000007
#define PI 3.14159265359
#define EPS 1e-10
#define All(a) (a).begin(), (a).end()

using namespace std;
using P = pair<ll, ll>;
 
int dx[4] = {0, 1, 0, -1};
int dy[4] = {1, 0, -1, 0};

/**
 * Usage:
 * 
 * G[from].push_back(Edge(to, weight));
 * using Graph = vector<vector<Edge>>;
 * 
 */ 
struct Edge {
  int to;     
  ll weight; 
  Edge(int t, ll w) : to(t), weight(w) { }
};

/**
 * Usage:
 * 
 * chmin(old, new);
 * chmax(old, new);
 * 
 */ 
template<class T> inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template<class T> inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}

template<typename T>
void printv(vector<T>& v) {
  if (v.size() == 0) {
    cout << "\n";
    return;
  }

  Rep(i, v.size()) {
    cout << v[i] << ((i + 1 < v.size()) ? ' ' : '\n');
  }
}



int N, K;
vector<ll> h;

int main () {
  cin >> N >> K;
  rep(i, N) {
    ll tmp;
    cin >> tmp;
    h.push_back(tmp);
  }

  sort(All(h), greater<ll>());

  ll ans = 0;

  for (int i=K;i<h.size();++i) {
    ans += h[i];
  }

  cout << ans << "\n";
}

Measured memory_bytes: 2420
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;

int N;
int x[100010], y[100010], w[100010];
map<pii, int> mp;

int calc(pii p) {
  int res1 = mp[p], res2 = mp[p];
  res1 += mp[pii(p.first, p.second + 1)];
  res1 += mp[pii(p.first + 1, p.second)];
  res1 += mp[pii(p.first + 1, p.second + 1)];
  res2 += mp[pii(p.first, p.second - 1)];
  res2 += mp[pii(p.first + 1, p.second)];
  res2 += mp[pii(p.first + 1, p.second - 1)];
  return max(res1, res2);
}

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  cin >> N;
  for (int i = 0; i < N; i++) {
    cin >> x[i] >> y[i] >> w[i];
    mp[pii(x[i], y[i])] = w[i];
  }

  int ans = 0;
  for (int i = 0; i < N; i++) {
    ans = max(ans, calc(pii(x[i], y[i])));
  }
  cout << ans << " / " << 1 << endl;

  return 0;
}


Measured memory_bytes: 41820
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<functional>
#include<vector>
#include<queue>
#include<stack>
#include<set>
using namespace std;
#define MOD 1000000007
#define f(i,n) for(int i=0;i<int(n);i++)
#define N (1000)
#define PI 3.1415926536
struct V{
	long long x, y;
	int nu;
};
int n;
vector<V>a;
vector<V>con;
bool z;
bool compare(const V& v1, const V& v2){
	if (v1.x != v2.x)return v1.x < v2.x;
	else return v1.y < v2.y;
}

void convex_make(void){
	sort(a.begin(), a.end(), compare);
	int k = 0;
	V co[N];
	f(i, n){
		z = true;
		while (k > 1 && z){
			if ((co[k - 1].x - co[k - 2].x)*(a[i].y - co[k - 1].y) >= (co[k - 1].y - co[k - 2].y)*(a[i].x - co[k - 1].x))k--;
			else z = false;
		}
		co[k] = a[i];
		k++;
	}
	int t = k;
	for (int i = n - 2; i >= 0; i--){
		z = true;
		while (k > t&&z){
			if ((co[k - 1].x - co[k - 2].x)*(a[i].y - co[k - 1].y) >= (co[k - 1].y - co[k - 2].y)*(a[i].x - co[k - 1].x))k--;
			else z = false;
		}
		co[k] = a[i];
		k++;
	}
	con.clear();
	f(i, k - 1)con.push_back(co[i]);
	return;
}

int main(void){
	long long x, y;
	int cosi;
	double ans[N];
	f(i, N)ans[i] = 0.000000000;
	long double  da, db, dc;
	scanf("%d", &n);
	f(i, n){
		scanf("%lld %lld", &x, &y);
		a.push_back({ x, y, i });
	}
	convex_make();
	cosi = con.size();
	da = sqrt((((con[0].x) - (con[cosi - 1].x))*((con[0].x) - (con[cosi - 1].x))) + (((con[0].y) - (con[cosi - 1].y))*((con[0].y) - (con[cosi - 1].y))));
	db = sqrt((((con[0].x) - (con[1].x))*((con[0].x) - (con[1].x))) + (((con[0].y) - (con[1].y))*((con[0].y) - (con[1].y))));
	dc = sqrt((((con[cosi - 1].x) - (con[1].x))*((con[cosi - 1].x) - (con[1].x))) + (((con[cosi - 1].y) - (con[1].y))*((con[cosi - 1].y) - (con[1].y))));
	ans[con[0].nu] = (acos(-((da*da) + (db*db) - (dc*dc)) / (2 * da*db))) / (2 * PI);
	for (int i = 1; i < (cosi - 1); i++){
		da = sqrt((((con[i].x) - (con[i - 1].x))*((con[i].x) - (con[i - 1].x))) + (((con[i].y) - (con[i - 1].y))*((con[i].y) - (con[i - 1].y))));
		db = sqrt((((con[i].x) - (con[i + 1].x))*((con[i].x) - (con[i + 1].x))) + (((con[i].y) - (con[i + 1].y))*((con[i].y) - (con[i + 1].y))));
		dc = sqrt((((con[i - 1].x) - (con[i + 1].x))*((con[i - 1].x) - (con[i + 1].x))) + (((con[i - 1].y) - (con[i + 1].y))*((con[i - 1].y) - (con[i + 1].y))));
		ans[con[i].nu] = (acos(-((da*da) + (db*db) - (dc*dc)) / (2 * da*db))) / (2 * PI);
	}
	cosi = con.size();
	da = sqrt((((con[0].x) - (con[cosi - 1].x))*((con[0].x) - (con[cosi - 1].x))) + (((con[0].y) - (con[cosi - 1].y))*((con[0].y) - (con[cosi - 1].y))));
	db = sqrt((((con[cosi - 2].x) - (con[cosi - 1].x))*((con[cosi - 2].x) - (con[cosi - 1].x))) + (((con[cosi - 2].y) - (con[cosi - 1].y))*((con[cosi - 2].y) - (con[cosi - 1].y))));
	dc = sqrt((((con[cosi - 2].x) - (con[0].x))*((con[cosi - 2].x) - (con[0].x))) + (((con[cosi - 2].y) - (con[0].y))*((con[cosi - 2].y) - (con[0].y))));
	ans[con[cosi - 1].nu] = (acos(-((da*da) + (db*db) - (dc*dc)) / (2 * da*db))) / (2 * PI);
	f(i, n){
		printf("%f\n", ans[i]);
	}

	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<algorithm>
#include<string.h>
using namespace std;
int a[100005];
int main()
{
    int n,flag=0;
    long long p,q;
    scanf("%d",&n);
    for(int i=0;i<n;i++)
        scanf("%d",&a[i]);
    sort(a,a+n);
    for(int i=n-1;i>0;)
    {
        if(a[i]==a[i-1]&&flag==0)
        {
            p=a[i];
            flag=1;
            i=i-2;
        }
        else if(a[i]==a[i-1]&&flag==1)
        {
            q=a[i];
            flag=2;
            break;
        }
        else if(a[i]!=a[i-1])
            i--;
    }
    if(flag!=2)
        printf("0\n");
    else
        printf("%lld\n",p*q);
    return 0;
}

Measured memory_bytes: 512
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdio>
#include <cmath>
#define MAXN
#define MAXM
using namespace std;
int n,m;

int main()
{
	int maxn=-999,sum=0;
	scanf("%d",&n);
	for (int i=1,a;i<=n;i++)
	{
		scanf("%d",&a);
		if (a>=maxn)
		{
			maxn=a;
			sum++;
		}
	}
	printf("%d",sum);
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdlib>
#include <map>
#include <iomanip>
#include <set>
#include <stdio.h>
#include <ctype.h>
using namespace std;
#define pie 3.141592653589793238462643383279
#define mod 1000000007
#define INF 1145141919364364
#define int long long
#define all(vec) vec.begin(),vec.end()
#define P pair<int,int>
#define S second
#define F first
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x / gcd(x, y)*y;
}
bool prime(int x) {
	for (int i = 2; i <= sqrt(x); i++) {
		if (x%i == 0)return false;
	}
	return true;
}
int kai(int x, int y) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= i; res %= mod;
	}
	return res;
}
int mod_pow(int x, int y, int m) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x, y) * mod_pow(kai(y, y), mod - 2, mod) % mod;
}

int a[3];

signed main() {
	cin >> a[0] >> a[1] >> a[2];
	sort(a, a + 3);
	if ((a[0] == a[1] && a[1] != a[2]) || (a[0] != a[1] && a[1] == a[2]))cout << "Yes" << endl;
	else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <stdbool.h>
#define LL long long
#define DB double
#define INF 1145141919810364364
#define PI 3.14159265358979
#define MIN(x,y) ((x)<(y)?(x):(y))
#define MAX(x,y) ((x)<(y)?(y):(x))
#define FOR(i,a,n) for(i=a;i<n;i++)
#define rep(i,n) FOR(i,0,n)
#define MOD 1000000007
//#define MOD 998244353
#define ERR 0.00000000000001
#define NUM 200010

void swap(LL* a,LL* b){LL tmp=*a;*a=*b;*b=tmp;}
void YN(int a){if(a==1)printf("Yes\n");if(a==0)printf("No\n");}
LL pwmn(LL a,LL n){LL ans=1;while(ans<a)ans*=n;return ans;}
LL GCD(LL a,LL b){LL c=1,tmp=MAX(a,b);b=MIN(a,b);a=tmp;while(c!=0){c=a%b;a=b;b=c;}return a;}
LL LCM(LL a,LL b){return a*b/GCD(a,b);}
int lcmp(const void* a,const void* b){if(*(LL*)a>*(LL*)b)return 1;if(*(LL*)a<*(LL*)b)return -1;return 0;}
int lcmpr(const void* a,const void* b){if(*(LL*)a>*(LL*)b)return -1;if(*(LL*)a<*(LL*)b)return 1;return 0;}
int ccmp(const void* a,const void* b){return *(char*)a-*(char*)b;}
int ccmpr(const void* a,const void* b){return *(char*)b-*(char*)a;}
int scmp(const void* a,const void* b){return strcmp((char*)a,(char*)b);}
int scmpr(const void* a,const void* b){return strcmp((char*)b,(char*)a);}
LL mod(LL a,LL m){if(a<0)return a%m+m;else return a%m;}
LL DIV(LL a,LL d){LL m=MOD,x=1,y=0,k;while(m){k=d/m;d-=k*m;swap(&m,&d);x-=k*y;swap(&x,&y);}return mod(a*mod(x,MOD),MOD);}
LL FAC(LL a){LL i,ans=1;FOR(i,1,a+1){ans*=i;if(MOD>0&&ans>MOD)ans%=MOD;}return ans;}
LL POW(LL a,LL n){LL ans=1;while(n>0){if(n&1)ans=ans*a%MOD;a=a*a%MOD;n>>=1;}return ans;}
LL fact[NUM],finv[NUM],inv[NUM];
void comi(){LL i;fact[0]=fact[1]=1;finv[0]=finv[1]=1;inv[1]=1;FOR(i,2,NUM){fact[i]=fact[i-1]*i%MOD;inv[i]=MOD-inv[MOD%i]*(MOD/i)%MOD;finv[i]=finv[i-1]*inv[i]%MOD;}}
LL com(LL n,LL k){if(n<k||n<0||k<0)return 0;return fact[n]*(finv[k]*finv[n-k]%MOD)%MOD;}

LL com2(LL n,LL k){
  if(n<k||n<0||k<0||(n|k)!=n)return 0;
  return 1;
}

int main(){
  LL N,i,a[1000005],b[1000005],flag=0,ans=0;
  char s[1000005];
  scanf("%lld %s",&N,s);
  rep(i,N)a[i]=s[i]-'0'-1,b[i]=a[i]%2;
  rep(i,N){
    if(a[i]==1)flag=1;
    ans=ans^(b[i]*com2(N-1,i));
  }
  if(flag==0){
    ans=0;
    rep(i,N)a[i]/=2;
    rep(i,N)ans=ans^(a[i]*com2(N-1,i));
    ans*=2;
  }

  printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 16768
#ifdef _MSC_VER
#include "stdc++.h"
#endif
#ifdef __GNUC__
#include<bits/stdc++.h>
#endif
using namespace std;

using ll = long long;

//vector
using vi = vector<int>;
using vii = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;

//constant
const double EPS = 1e-10;

#define REP(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, s, e) for (ll i = s; i < e; i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(), (x).rend()

//debug
#define DUMP(x)  cerr << #x << " = " << (x) << endl;
#define DEBUG(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl;

// vector
//template<typename T> vector<vector<T>> vv(ll H, ll W, T v) { return vector<vector<T>> vec(H, vector<T>(W, v)); }

// view vector
template<typename T> void view(T e) { cout << e << endl; }
template<typename T> void view(const vector<T>& v) { for (const auto& e : v) { cout << e << " "; } cout << endl; }
template<typename T> void view(const vector<vector<T> >& vv) { for (const auto& v : vv) { view(v); } }

// DP
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }




// ***************************************


int main(){

    int N;
    cin >> N;
    ll ans = 1;

    vll A(N);
    REP(i, N){
        ll a;
        cin >> a;
        if (a == 0){
            cout << 0 << endl;
            return 0;
        }
        A[i] = a;
    }

    ll th = 1e18;

    REP(i, N){
        if (ans > th / A[i]) {
            cout << -1 << endl;
            return 0;
        }
        ans *= A[i];
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3936
#if !defined(__clang__) && defined(__GNUC__)
#include <bits/stdc++.h>
#else
#include <cstdlib>
#include <climits>
#include <iostream>
#include <cstdint>
#include <vector>
#include <string>
#include <complex>
#include <bitset>
#include <queue>
#include <deque>
#include <stack>
#include <utility>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <regex>
#endif //  !defined(__clang__) && defined(__GNUG__)
#include <boost/lexical_cast.hpp>
#include <boost/algorithm/string.hpp>
#include <boost/multi_array.hpp>
#include <boost/optional.hpp>
#include <boost/math/common_factor_rt.hpp>

using namespace std;

int main()
{
    int64_t N;
    std::cin >> N;

    for (int h = 1; h <= 3500; ++h) {
        for (int n = 1; n <= 3500; ++n) {
            auto a = N * h * n;
            auto b = 4*h*n - N*n - N*h;
            if (b > 0 && a % b == 0) {
                std::cout << h << " " << n << " " << a/b << std::endl;
                return 0;
            }
        }
    }

    return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main{
	public static void main(String args[]){
		
		Scanner ob = new Scanner(System.in);
		int S = ob.nextInt();
		int W = ob.nextInt();

		if(W >= S){
			System.out.println("unsafe");
		}
		else{
			System.out.println("safe");
		}
	}
}

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

const ll MOD=LLONG_MAX;
const int INF=0x3f3f3f3f;
const ll INFL=0x3f3f3f3f3f3f3f3f;

ll ppow(ll a,ll b){
	a%=MOD;
	ll res=1;
	while(b){
		if(b&1)res=(res*a)%MOD;
		a=(a*a)%MOD;
		b>>=1;
	}
	return res;
}
class LCA{
public:
	vector<vector<pair<int,int>>>E;
	vector<vector<int>>par;
	vector<int>d1;
	vector<long long>d2;
	int MAX_LOG=22;
	int n;
	LCA(){}
	LCA(int N){
		n=N;
		E=vector<vector<pair<int,int>>>(n);
		par=vector<vector<int>>(MAX_LOG,vector<int>(n));
		d1=vector<int>(n);
		d2=vector<long long>(n);
	}
	void add_edge(int a,int b,int c){
		E[a].push_back(make_pair(c,b));
		E[b].push_back(make_pair(c,a));
	}
	void add_edge(int a,int b){
		E[a].push_back(make_pair(1,b));
		E[b].push_back(make_pair(1,a));
	}
private:
	void dfs(int u,int p,int a,long long b){
		par[0][u]=p;d1[u]=a;d2[u]=b;
		for(auto&v:E[u]){
			if(v.second!=p)dfs(v.second,u,a+1,b+v.first);
		}
	}
	bool flag=false;
	void init(){
		dfs(0,-1,0,0);
		for(int i=1;i<MAX_LOG;i++)for(int j=0;j<n;j++){
			if(par[i-1][j]==-1)par[i][j]=-1;
			else par[i][j]=par[i-1][par[i-1][j]];
		}
		flag=true;
	}
public:
	int lca(int u,int v){
		if(!flag)init();
		if(d1[u]>d1[v])swap(u,v);
		for(int i=0;i<MAX_LOG;i++){
			if((d1[v]-d1[u])>>i&1)v=par[i][v];
		}
		if(u==v)return u;
		for(int i=MAX_LOG-1;i>=0;i--){
			if(par[i][u]!=par[i][v]){
				u=par[i][u];
				v=par[i][v];
			}
		}
		return par[0][u];
	}
	long long dist(int u,int v){
		int l=lca(u,v);
		return d2[u]+d2[v]-d2[l]*2;
	}
};

class UnionFind {
	vector<int>par, sz;
public:
	UnionFind() {}
	UnionFind(int n) {
		par = sz = vector<int>(n);
		for (int i = 0; i < n; i++) {
			par[i] = i;
			sz[i] = 1;
		}
	}
	int find(int x) {
		if (par[x] == x)return x;
		return par[x] = find(par[x]);
	}
	void unite(int x, int y) {
		x = find(x); y = find(y);
		if (x == y)return;
		if (sz[x] > sz[y]) {
			par[y] = x;
			sz[x] += sz[y];
		}
		else {
			par[x] = y;
			sz[y] += sz[x];
		}
	}
	bool same(int x, int y) {
		return find(x) == find(y);
	}
	int size(int x) {
		return sz[find(x)];
	}
};

vector<P>E[60];
int u[60],v[60];
int sum[60];


int dfs(int v,int p){
	int res=0;
	for(auto u:E[v]){
		if(u.first==p)continue;
		res+=dfs(u.first,v);
		sum[v]+=sum[u.first];
	}
	return res+(sum[v]>0);
}

int main(){
	int n;cin>>n;
	LCA lca(n);
	rep(i,n-1){
		int a,b;scanf("%d%d",&a,&b);a--;b--;
		E[a].push_back(P(b,i));
		E[b].push_back(P(a,i));
		lca.add_edge(a,b);
	}
	int m;cin>>m;
	rep(i,m){
		scanf("%d%d",&u[i],&v[i]);
		u[i]--;v[i]--;
	}
	ll all=ppow(2,n-1);
	rep(i,1<<m){
		if(i==0)continue;
		int cnt=__builtin_popcount(i);
		memset(sum,0,sizeof(sum));
		rep(j,m){
			if(i>>j&1){
				sum[u[j]]++;
				sum[v[j]]++;
				int p=lca.lca(u[j],v[j]);
				sum[p]-=2;
			}
		}
		int a=dfs(0,-1);
		ll C=ppow(2,n-1-a);
		if(cnt%2)all-=C;
		else all+=C;
	}
	cout<<all<<endl;
}

Measured memory_bytes: 256
#pragma GCC optimize "O3"

#include<bits/stdc++.h>

using namespace std;

constexpr int N = 20;

int n, ans;
string tmp, ans_rev;
vector<string> words[N+1], cands[N+1];
vector<bool> vis[N+1];

bool valid(string &tar, string &s, string &rev) {
  for(size_t i = 0; i<s.size(); ++i) {
    if(rev[s[i]] != -1 && rev[s[i]] != tar[i])
      return false;
    if(rev[tar[i]] != -1 && rev[tar[i]] != s[i])
      return false;
  }
  return true;
}
void dfs(int l, size_t x, string &rev) {
  if(ans > 1)
    return;
  while(l && x >= words[l].size()) {
    x = 0;
    --l;
  }
  if(l == 0) {
    ans_rev = rev;
    ++ans;
    return;
  }
  string &tar = words[l][x];
  for(size_t j = 0; j<cands[l].size(); ++j) {
    if(vis[l][j])
      continue;
    string &s = cands[l][j];
    if(valid(tar, s, rev)) {
      string nrev = rev;
      size_t i = 0;
      for(; i<s.size(); ++i)
        if(nrev[s[i]] == -1) {
          if(nrev[tar[i]] != -1)
            break;
          nrev[s[i]] = tar[i];
          nrev[tar[i]] = s[i];
        }
      if(i != s.size())
        continue;
      vis[l][j] = true;
      dfs(l, x+1, nrev);
      vis[l][j] = false;
    }
  }
}
void cleanup(vector<string> &v) {
  sort(v.begin(), v.end());
  v.resize(unique(v.begin(), v.end()) - v.begin());
}
void init() {
  for(int i = 0; i<=N; ++i)
    words[i].clear(), cands[i].clear(), vis[i].clear();
  ans = 0;
}
void solve() {
  init();
  for(int i = 0; i<n; ++i) {
    cin >> tmp;
    for_each(tmp.begin(), tmp.end(), [](char &c) { c -= 'A'; });
    cands[tmp.size()].push_back(tmp);
  }
  for(int i = 0; i<=N; ++i)
    vis[i].resize(cands[i].size());
  vector<string> sent;
  bool cont = true;
  while(cont) {
    cin >> tmp;
    if(tmp.back() == '.') {
      tmp.pop_back();
      cont = false;
    }
    sent.push_back(tmp);
    for_each(tmp.begin(), tmp.end(), [](char &c) { c -= 'A'; });
    words[tmp.size()].push_back(tmp);
  }
  for(int i = 1; i<=N; ++i)
    cleanup(words[i]);
  string rev(26, -1);
  dfs(N, 0, rev);
  if(ans == 1) {
    for(size_t i = 0; i<sent.size(); ++i) {
      for(auto c : sent[i]) 
        putchar(ans_rev[c - 'A'] == -1 ? c : ans_rev[c - 'A'] + 'A');
      putchar(i+1 == sent.size() ? '.' : ' ');
    }
    puts("");
  } else
    puts("-.");
}
int main() {
  while(scanf("%d", &n) == 1 && n)
    solve();
}

Measured memory_bytes: 3236
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cmath>
#include <bitset>
using namespace std;
const double EPS = 1e-10;
const double INF = 1e12;

struct Point{
    double x,y,z;
    Point(double x, double y, double z):x(x), y(y), z(z){}
    Point(){}
    Point &operator +=(const Point &a){ x+=a.x; y+=a.y; z+=a.z; return *this; }
    Point &operator -=(const Point &a){ x-=a.x; y-=a.y; z-=a.z; return *this; }
    Point &operator *=(const double &a){ x*=a; y*=a; z*=a; return *this; }
    Point operator +(const Point &a) const{ return Point(x+a.x, y+a.y, z+a.z); }
    Point operator -(const Point &a) const{ return Point(x-a.x, y-a.y, z-a.z); }
    Point operator *(const double &a) const{ return Point(a*x, a*y, a*z); }
    Point operator -() { return Point(-x, -y, -z); }
};
double dot(const Point &a, const Point &b){
    return a.x*b.x +a.y*b.y +a.z*b.z;
}
Point cross(const Point &a, const Point &b){
    return Point(a.y*b.z -a.z*b.y, a.z*b.x -a.x*b.z, a.x*b.y -a.y*b.x);
}
double abs(const Point &a){
    return sqrt(dot(a, a));
}
Point unit(const Point &a){
    return a *(1/abs(a));
}
bool operator ==(const Point &a, const Point &b){
    return abs(a-b) < EPS;
}

Point projectionSP3(Point p, Point q, Point c){
    double t = dot(unit(q-p), c-p);
    return p +unit(q-p) *t;
}
Point reflectionSP3(Point p, Point q, Point c){
    Point proj = projectionSP3(p, q, c);
    return proj*2 -c;
}
double distanceSP3(Point p, Point q, Point c){
    Point r = projectionSP3(p, q, c);
    if(dot(q-p, r-p) < 0) return abs(c-p);
    if(dot(p-q, r-q) < 0) return abs(c-q);
    return abs(c-r);
}
Point crossopintLP3FS(Point p, Point q, Point c, double r){
    Point s = projectionSP3(p, q, c);
    double t = sqrt(r*r -abs(c-s)*abs(c-s));
    Point ret[2] = {s +unit(p-q)*t, s -unit(p-q)*t};
    return (abs(ret[0]-p) < abs(ret[1]-p))? ret[0]: ret[1];
}

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

        Point pos(0,0,0), dir;
        cin >> dir.x >> dir.y >> dir.z;
        vector<Point> p(n);
        vector<double> r(n);
        for(int i=0; i<n; i++){
            cin >> p[i].x >> p[i].y >> p[i].z >> r[i];
        }

        while(1){
            bool touch = false;
            Point npos(INF, INF, INF), ndir;
            Point ep = pos +unit(dir)*1e4;
            for(int i=0; i<n; i++){
                if(distanceSP3(pos, ep, p[i]) +EPS < r[i]){
                    Point ref = crossopintLP3FS(pos, ep, p[i], r[i]);
                    if(ref == pos) continue;
                    if(abs(pos -ref) > abs(pos -npos)) continue;
                    Point to = reflectionSP3(p[i], ref, pos);
                    npos = ref;
                    ndir = to -ref;
                    touch = true;
                }
            }
            if(!touch){
                break;
            }
            pos = npos;
            dir = ndir;
        }
        cout << fixed << setprecision(4);
        cout << pos.x << " " << pos.y << " " << pos.z << endl;
    }
    return 0;
}


Measured memory_bytes: 3268
function main(input){
  let lines = input.split("\n");
  let x = lines[0].split(" ")[0];
  let y = lines[0].split(" ")[1];
  
  if (x < y){
        [x, y] = [y, x]
  }
  while (y > 0){
    r = x % y
    x = y
    y = r
  }
  console.log(x)
}

main(require('fs').readFileSync('/dev/stdin', 'UTF-8'));


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

int main(){
  int N,K;
  string S;
  cin >> N >> K >> S;

  if(S.at(K-1) == 'A'){
    S.at(K-1) = 'a';
  }else if(S.at(K-1) == 'B'){
    S.at(K-1) = 'b';
  }else S.at(K-1) = 'c';

  cout << S << endl;
}


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

#include <bits/stdc++.h>
using namespace std;
vector<int> prime(0);


void primeGeneration(){
  int N=1000100;
  vector<bool> number(N,true);
  for(int i=2;i*i<=N;i++){
    for(int j=i+i;j<=N;j+=i){
      number[j]=false;
    }
  }
  for(int i=2;i<N;i++){
    if(number[i])prime.push_back(i);
  }
};


int main() {
  primeGeneration();
  string ans="pairwise coprime";
  int N;cin>>N;
  vector<int> A(N+1,-99999);
  for(int i=1;i<=N;i++)cin>>A[i];
  vector<bool> B(1001000,false);
  vector<int> C(1001000,0);
  for(int i=1;i<=N;i++){
    C[A[i]]++;
    if(A[i]==1||!B[A[i]])B[A[i]]=true;
    else ans="setwise coprime";
  };
  
  for(int i=0;i<prime.size();i++){
    int cnt=0;
    int j=prime[i];
    while(j<=1000100){
      if(B[j])cnt+=C[j];
      j+=prime[i];
    }
    if(cnt>=2){
      if(ans=="pairwise coprime")ans="setwise coprime";
      if(cnt==N){
        ans="not coprime";break;
      }
    }
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 11480
#include <bits/stdc++.h>
#define all(vec) vec.begin(), vec.end()
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
constexpr ll INF = (1LL << 30) - 1LL;
constexpr ll LINF = (1LL << 60) - 1LL;
constexpr double eps = 1e-9;
constexpr ll MOD = 1000000007LL;
template <typename T>
bool chmin(T& a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
};
template <typename T>
bool chmax(T& a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
};
template <typename T>
ostream& operator<<(ostream& os, vector<T> v) {
    for(int i = 0; i < v.size(); i++) {
        os << v[i] << (i + 1 == v.size() ? "\n" : " ");
    }
    return os;
}
template <typename T>
vector<T> make_v(size_t a) {
    return vector<T>(a);
}
template <typename T, typename... Ts>
auto make_v(size_t a, Ts... ts) {
    return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template <typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type fill_v(T& t, const V& v) {
    t = v;
}
template <typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type fill_v(T& t, const V& v) {
    for(auto& e : t) {
        fill_v(e, v);
    }
};
int main() {
    /* cin.tie(0);
    ios::sync_with_stdio(false);*/
    ll w, h, x, y;
    cin >> w >> h >> x >> y;
    double s = w * h;
    s /= 2.0;
    printf("%.10lf ", s);
    if(w%2==0&&h%2==0&&x==w/2&&y==h/2){
        cout << 1 << endl;
    }else{
        cout << 0 << endl;
    }
}


Measured memory_bytes: 256
#include<stdio.h>

int main(){
	char c;
	while(0<=scanf(" %c ",&c)){
		if(c=='A'){
			printf("X");
			continue;
		}else if(c=='B'){
			printf("Y");
			continue;
		}else if(c=='C'){
			printf("Z");
			continue;
		}
		printf("%c",'A'+(c-'A'-3)%26);
	}
	printf("\n");
	return 0;
}

Measured memory_bytes: 0
#include "bits/stdc++.h"
using namespace std;
#define rep(i,a,n) for(ll i=a;i<n;i++)
#define ALL(s) s.begin(),s.end()
const int M=100010;
const int MOD=1000000007;
const int INF=1000000007;
using ll=long long;

int main() {	
	int H,W,D,a,Q,l,r,ans=0;
	cin.tie(0);
	ios::sync_with_stdio(false);
	cin>>H>>W>>D;
	int dp1[90001]={},dp2[90001]={};
	rep(j,0,H)rep(i,0,W){
		cin>>a;
		dp1[a]=i+1;
		dp2[a]=j+1;
	}
	int d[900001]={};
	rep(i,D+1,90001)
		d[i]=d[i-D]+abs(dp1[i-D]-dp1[i])+abs(dp2[i-D]-dp2[i]);
	cin>>Q;
	rep(i,0,Q){
		cin>>l>>r;
		cout<<d[r]-d[l]<<endl;
	}
}


Measured memory_bytes: 5376
import sys
from math import log2

sys.setrecursionlimit(int(1e7))


def doubling():
    dfs(0, -1, 0)
    p0 = parent[0]
    for p1 in parent[1:]:
        for i in range(n):
            pi = p0[i]
            p1[i] = -1 if pi < 0 else p0[pi]
        p0 = p1


def dfs(u, p, d):
    parent[0][u] = p
    depth[u] = d
    for v in tree[u]:
        dfs(v, u, d + 1)


def lca(u, v):
    du, dv = depth[u], depth[v]
    if du > dv:
        u, v = v, u
        du, dv = dv, du
    for i, p in enumerate(parent):
        if (dv - du) >> i & 1:
            v = p[v]
    if u == v:
        return u
    for p in parent[logn - 1:None:-1]:
        pu, pv = p[u], p[v]
        if pu != pv:
            u, v = pu, pv
    return parent[0][u]


n = int(input())
tree = [set(map(int, input().split()[1:])) for _ in range(n)]

logn = int(log2(n)) + 1
parent = [[0] * n for _ in range(logn)]
depth = [0] * n

doubling()

q = int(input())
for _ in range(q):
    print(lca(*map(int, input().split())))



Measured memory_bytes: 154620
//#pragma GCC optimize("-O3")
/*
                C++
                encoding: UTF-8
                Last Modified: 16/Feb/20 05:33:16 PM
*/

#include <bits/stdc++.h>
#ifdef H4wk3ye
#	include <prettypr.hpp>
#endif

using namespace std;

// clang-format off

#define		int                    long long
#define		ve                     vector
#define		pb                     push_back
#define		endl                   "\n"
#define		ff                     first
#define		ss                     second
#define		pii                    pair<int, int>
#define		len(v)                 (int)v.size()
#define		all(v)                 v.begin(), v.end()
#define		reset(a, b)            memset(a, b, sizeof(a));
#define		fr(i, s, n)            for (int i = s ; i < n ; ++i)
#define		dfr(i, s, n)           for (int i = s ; i > n ; --i)

template < typename T > void pr (const T& t) {
    cout << t << "\n";
}

template < typename T, typename U, typename... ARGS >
void pr (const T& t, const U& u, const ARGS&... args) {
    cout << t << " ";
    pr (u, args...);
}

// clang-format on


signed main () {
    ios_base::sync_with_stdio (false), cin.tie (nullptr);
    ve<int> a(3);
    for(auto&i: a) cin>>i;
    sort(all(a));
    if ((a[0]==a[1] and a[0]!=a[2]) or (a[1]==a[2] and a[1]!=a[0])) {
        pr("Yes");
    } else{
        pr("No");
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  long long a,b,c,d,e=1;
  cin>>a>>b>>c>>d;
  while(a>0&&c>0){
    if((e%2)==1){
      c=c-b;
    }else
      a=a-d;
    e++;
  }if(a<=0)
    cout<<"No";
  else
    cout<<"Yes";
  return 0;
}

Measured memory_bytes: 3584
#include <bits/stdc++.h>
#define LL long long
#define db double
using namespace std;

#define MAXN 200200
#define MAXE 400400

typedef pair<int, int> pii;
#define X first
#define Y second
const LL INF = (1LL << 62) | 3;
#define Debug(...) fprintf(stderr, __VA_ARGS__)

template <typename T> inline void read(T &x) {
    int ch = getchar();
    bool fg = false;
    for (x = 0; !isdigit(ch); ch = getchar()) {
        if (ch == '-') {
            fg = true;
        }
    }
    for (; isdigit(ch); ch = getchar()) {
        x = x * 10 + ch - '0';
    }
    if (fg) {
        x = -x;
    }
}

template <typename T> inline bool chkmin(T& x, const T& y) { return y < x ? (x = y, true) : false; }
template <typename T> inline bool chkmax(T& x, const T& y) { return x < y ? (x = y, true) : false; }

long long a[7], n, m, k = (1LL << 60 | 10), b[7];

signed main() {
	read(n);
	for(int i = 1; i <= 5; i++) {
		read(a[i]);
		if(a[i] < k) k = a[i], m = i;
	}
	n = n + k - 1;
	n /= k;
	cout << n + 4 << endl; 
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std; 
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
#define ll long long
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define lson l,mid,rt<<1
#define rson mid+1,r,rt<<1|1
int a[500005]; 

int main(int argc, char** argv) {
	string s;
	cin>>s;
	ll ans=0,now=0,al=0;
	ans+=now;
	rep(i,0,s.length()-1)
	{
		if(s[i]=='<')
		{
			now++;
		}
		else now--;
		
		al=min(al,now);
	}
	rep(i,0,s.length()-1)
	{
		int nw=0,j;
		if(s[i]=='>')
		{
			j=i;
			while(s[j]=='>')
			{
				j++;
			}
			int now=j-1,p=al;
			while(s[now]=='>')
			{
				a[now+1]=p++;
				now--;
			}
			a[now+1]=max(p,a[now+1]);
			nw=j;
		}
		if(s[i]=='<')
		{
			j=i;
			int p=al+1;
			while(s[j]=='<')
			{
				a[j+1]=p++;
				j++;
			}
			nw=j;
		}
		i=j-1;
	}
	if(s[0]=='>')a[0]=a[1]+1;
	else a[0]=al;
	rep(i,0,s.length())
	{
		//cout<<a[i]-al<<" ";
		ans+=a[i]-al;
	}
	cout<<ans<<endl;

	return 0;
}

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

int n;
double ave;
int p;


int main(){
  cin >> n;
  vector<int> x(n);
  for(int i=0; i<n; i++){
    cin >> x[i];
    ave += x[i];
  }
  ave = ave / (double) n;
  if(ave - floor(ave) < 0.5){
    p = floor(ave);
  }
  else{
    p = ceil(ave);
  }
  int sum=0;
  for(int i=0; i<n; i++){
    sum += pow(x[i]-p, 2);
  }
  cout << sum << endl;
}

Measured memory_bytes: 256
'use strict'

function main(inp) {
  inp = inp.trim().split(' ').map(n => Number(n));
  const N = inp[0]
  const R = inp[1]
  console.log(N > 9 ? R : R + (100 * (10 - N)))
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));


Measured memory_bytes: 21064
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>
#include <queue>
#include <stack>

using namespace std;

typedef long long int ll;
typedef pair<int, int> Pii;

const ll mod = 1000000007;

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

  int n;
  cin >> n;

  ll ans = 0;
  for (int i = 1; i <= n; i++) {
    if (i % 3 != 0 && i % 5 != 0) ans += i;
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3636
#!/usr/bin python3
# -*- coding: utf-8 -*-

import sys
input = sys.stdin.readline

def main():
    a, b, c = map(int, input().split())
    x = ((c-a-b)**2-4*a*b > 0 ) and (c > a+b)
    print('NYoe s'[x::2])

if __name__ == '__main__':
    main()

Measured memory_bytes: 3060
from math import sqrt, ceil

N = int(input())

def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

def make_divisors(n):
    lower_divisors , upper_divisors = [], []
    i = 1
    while i*i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n//i)
        i += 1
    return lower_divisors + upper_divisors[::-1]

ans = 0
search_list = make_divisors(N)[1:]
if (N > 1) and (N not in search_list):
    search_list.append(N)

for i in search_list:
    if N%i == 0:
        fact = factorization(i)
        if len(fact) == 1:
            N = N // i
            if N >= 1:
                ans += 1
            else:
                break

print(ans)


Measured memory_bytes: 9552