akhauriyash/Code-Regression huggingface dataset:
#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; }
//---------------------------------------------------------------------------------------------------
map<ll, int> enumpr(ll n) {
    map<ll, int> V;
    for (ll i = 2; i*i <= n; i++) while (n%i == 0) V[i]++, n /= i;
    if (n > 1) V[n]++;
    return V;
}
ll fastpow(ll x, ll n) {
    ll ret = 1;
    while (0 < n) {
        if ((n % 2) == 0) x *= x, n >>= 1;
        else ret *= x, --n;
    }
    return ret;
}
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧  
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     
　　　　／　　　＼　 　  |　|     
　　　 /　　 /￣￣￣￣/　　|  
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿  
　 　　　＼/＿＿＿＿/　（u　⊃  
---------------------------------------------------------------------------------------------------*/





ll N, P;
//---------------------------------------------------------------------------------------------------
void _main() {
    cin >> N >> P;
    auto ep = enumpr(P);

    ll ans = 1;
    fore(p, ep) ans *= fastpow(p.first, p.second / N);
    cout << ans << endl;
}

Measured memory_bytes: 256
n=int(input())
if 400<=n<600: print(8)
if 600<=n<800: print(7)
if 800<=n<1000: print(6)
if 1000<=n<1200: print(5)
if 1200<=n<1400: print(4)
if 1400<=n<1600: print(3)
if 1600<=n<1800: print(2)
if 1800<=n<2000: print(1)


Measured memory_bytes: 61960
#include <iostream>
#include <iomanip> // << fixed << setprecision(xxx)
#include <algorithm> // do { } while ( next_permutation(A, A+xxx) ) ;
#include <vector>
#include <string> // to_string(nnn) // substr(m, n) // stoi(nnn)
#include <complex>
#include <tuple> // get<n>(xxx)
#include <queue>
#include <stack>
#include <map> // if (M.find(key) != M.end()) { }
#include <set> // S.insert(M);
// if (S.find(key) != S.end()) { }
// for (auto it=S.begin(); it != S.end(); it++) { }
// auto it = S.lower_bound(M);
#include <cctype>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib> // atoi(xxx)
using namespace std;

#define DEBUG 0 // change 0 -> 1 if we need debug.
// insert #if<tab> by my emacs. #if DEBUG == 1 ... #end

typedef long long ll;

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

// const int C = 1e6+10;
// const ll M = 1000000007;

typedef tuple<int, bool> state;

int N;
int M;
vector<int> V[100010];
int visited[100010];

vector<ll> W[3];

int main () {
  cin >> N >> M;
  for (auto i = 0; i < M; ++i) {
    int u, v;
    cin >> u >> v;
    u--; v--;
    V[u].push_back(v);
    V[v].push_back(u);
  }
  fill(visited, visited+100010, 0);
  for (auto i = 0; i < N; ++i) {  
    if (visited[i] != 0) continue;
    bool is_there_odd = false;
    ll cnt = 0;
    stack<state> S;
    S.push(state(i, false));
    while (!S.empty()) {
      int now = get<0>(S.top());
      bool cl = get<1>(S.top());
      int col = (cl ? 1 : 2);
      S.pop();
      if (visited[now] == 0) {
        visited[now] = col;
        // cerr << "visited[" << now << "] = " << col << endl;
        ++cnt;
        for (auto x : V[now]) {
          if (visited[x] == 0) {
            // cerr << x << endl;
            S.push(state(x, !cl));
          } else {
            if (col == visited[x]) {
              is_there_odd = true;
            }
          }
        }
      }
    }
    /*
    cerr << "i = " << i << ", cnt = "
         << cnt << ", is_there_odd = " << is_there_odd << endl;
    */
    if (cnt == 1) {
      W[2].push_back(cnt);
    } else if (is_there_odd) {
      W[1].push_back(cnt);
    } else {
      W[0].push_back(cnt);
    }
  }
  ll i = (ll)W[2].size();
  ll q = (ll)W[0].size();
  ll p = (ll)W[1].size();
  //cerr << p << " " << q << " " << i << endl;
  ll ans = i * i + 2 * i * (N - i) + p * p + 2 * p * q + 2 * q * q;
  cout << ans << endl;
}


Measured memory_bytes: 8064
#include<iostream>
#include<vector>
#include <cmath>
#include <map>
#include <set>
#include <algorithm>
#include <string>
#define rep(i,n) for (int i= 0;i<(n);++i)
using namespace std;
typedef long long ll;
int main(){
    ll X ;
    cin >> X ; 
    ll n ;
    n = X / 100 ;
    if(X < 100){
        cout << 0 << endl;
    }else{
        if(5 * n >= (X % 100) )cout << 1 << endl;
        else cout << 0 << endl;

    }
    return 0;
}

Measured memory_bytes: 3640
#include <iostream>
#include <fstream>
#include <cstdio>
#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <stack>
#include <queue>
#include <algorithm>
#include <string.h>
#include <string>
#include <math.h>
#include <iomanip>
#include <cassert>
#include <random>
using namespace std;

#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
#define pb push_back
#define FOR(i, n) for(int i = 0; i < (n); i++)
typedef pair<int, int> pii;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;

const int mod = 1e9 + 7;
const int mod2 = 998244353;

void fact_init(int n);
ll exp(ll taban, ll us, ll md);
ll ebob(ll a, ll b);
ll ekok(ll a, ll b);
ll komb(ll a, ll b);

vector<ll> fact;
vector<ll> inv_fact;
void fact_init(int n){
    fact.resize(n+5);
    inv_fact.resize(n+5);
    fact[0] = inv_fact[0] = 1;
    for(int i = 1; i <= n; i++){
        fact[i] = (fact[i-1] * i) % mod;
        inv_fact[i] = exp(fact[i], mod-2, mod);
    }
}
ll exp(ll taban, ll us, ll md) {
    ll carpan = taban % md;
    if(carpan == 0) return 0;
    ll temp = us;
    ll res = 1;
    while(temp){
        if(temp % 2) res = (res*carpan) % md;
        temp /= 2;
        carpan = (carpan*carpan) % md;
    }
    return res;
}
 
ll ebob(ll a, ll b){
    if(!a)return b;
    return ebob(b%a, a);
}

ll ekok(ll a, ll b){
    return (a*b)/ebob(a, b);
}

ll komb(ll a, ll b){
    if(a < b) return 0;
    return fact[a] * (inv_fact[a-b] * inv_fact[b] % mod) % mod;
}
const int N = 3e5 + 5;

int main(){
    ios::sync_with_stdio(false); cin.tie(NULL);
	ll a, b, c, d; cin>>a>>b>>c>>d;
	cout<<(max({a*c, a*d, b*c, b*d}))<<"\n";
}

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

ll mod = 1e9 + 7;

struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

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

  mint ans = 0;
  mint two_factor = 1;
  for(int d = 0; d <= 60; d++) {
    mint odd = 0;
    mint even = 0;
    for(int i = 0; i < n; i++) {
      if(a[i] & (1ll << d)) {
        odd += 1;
      } else {
        even += 1;
      }
    }
    ans += (odd * even) * two_factor;
    two_factor = two_factor * 2;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 2560
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <numeric>
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, k, n) for(int i = (k); i < (int)(n); i++)
using namespace std;
using ll = long long;

int main(){
    int A,B;
    cin >> A >> B;
    if(A <= 8 && B <= 8){
        cout << "Yay!" << endl;
    }else{
        cout << ":(" << endl;
    }
    return 0;
}

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

int n;
int num[110];
long long int dp[110][21];
long long int ans = 0;
int main()
{
  cin >> n;
  for(int i = 1; i <= n; i++)
    cin >> num[i];

  dp[1][num[1]] = 1;
  for(int i = 2; i <= n - 1; i++)
    for(int j = 0; j <= 20; j++){
      if(j + num[i] <= 20)
	dp[i][j] += dp[i - 1][j + num[i]];
      if(j - num[i] >= 0)
	dp[i][j] += dp[i - 1][j - num[i]];
    }


  cout << dp[n - 1][num[n]] << endl;
  return 0;
}

Measured memory_bytes: 1172
number = int(input())
cards = list(map(int, input().split()))


def insertionSort(A, N):
    print(" ".join(map(str, A)))
    for i in range(1, N):
        j = i - 1
        while A[j] > A[i] and j >= 0:
            A[i], A[j] = A[j], A[i]
            j -= 1
            i -= 1
        print(" ".join(map(str, A)))

insertionSort(cards, number)


Measured memory_bytes: 5608
#include<bits/stdc++.h>
using namespace std;
template<typename T = int>T in() { T x; cin >> x; return x; }
#define REP(i,n) for(int i=0;i<(n);++i)
#define R_UP(a,b) (((a)+(b)-1)/(b))
#define ALL(obj) (obj).begin(),(obj).end()
int main()
{
	int n = in();
	int k = in();
	int l1 = 0;
	REP(i, n)
	{
		static int cnt = 0;
		if (in() == 1)
		{
			l1 = cnt;
		}
		cnt++;
	}
	int l2 = n - l1 - 1;
	int m = l1 - l1 / (k - 1) * (k - 1);
	cout << l1 / (k - 1) + R_UP(m + l2, k - 1) << endl;
}

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

int main(){
    int a;
    string s;
    cin >> a >> s;
    if (a >= 3200) cout << s << endl;
    else cout << "red" << endl;
}

Measured memory_bytes: 3608
#include<bits/stdc++.h>
using namespace std;
#define F(i,a,b) for(int i=a;i<=(b);++i)
#define F2(i,a,b) for(int i=a;i<(b);++i)
#define dF(i,a,b) for(int i=a;i>=(b);--i)
#define debug(...) fprintf(stderr,__VA_ARGS__)
#define Debug debug("Passing [%s] in LINE %d\n",__FUNCTION__,__LINE__)
#define MN 300005
#define MM 600005
#define ll long long
#define mod 998244353
typedef pair<int,int> pii;
#define pb push_back
#define mp make_pair
#define fi first
#define se second
int n,m,q,k;
int a[MN],b[MN],f[MN],g[MN];
int h[MN],nxt[MM],to[MM],tot;
inline void ins(int x,int y){nxt[++tot]=h[x];to[tot]=y;h[x]=tot;}
int main(){
	scanf("%d%d",&n,&m);
	F(i,1,m)if(i%10>1&&i/10>1&&(i%10)*(i/10)<=n)++q;
	printf("%d\n",q);
	return 0;
}

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

int main()
{
    string s;
    cin >> s;
    int n = int (s.size());

    bool fumiyasui = true;

    for(int i = 0; i < n; ++i)
    {
        if((i + 1) % 2 == 0 && s[i] == 'R')
            fumiyasui = false;
        if((i + 1) % 2 != 0 && s[i] == 'L')
            fumiyasui = false;
    }

    cout << (fumiyasui ? "Yes" : "No") << "\n";
    return 0;
}

Measured memory_bytes: 3624
#include <math.h>
#include <stdio.h>
int main(void){
    int n,i;
    double x[1001]={0};
    double y[1001]={0};
    double d1=0,square=0,d2,cubic=0,d3,d4;


    scanf("%d",&n);

    for(i=0; i<n; i++){
        scanf("%lf",&x[i]);
    }

    for(i=0; i<n; i++){
        scanf("%lf",&y[i]);
    }

    for(i=0; i<n; i++){
        d1 += fabs(x[i]-y[i]);
    }

    for(i=0; i<n; i++){
        square += pow(fabs(x[i]-y[i]),2);
    }
    d2=sqrt(square);

    for(i=0; i<n; i++){
        cubic += pow(fabs(x[i]-y[i]),3);
    }
    d3=cbrt(cubic);

    d4=fabs(x[0]-y[0]);
    for(i=1; i<n; i++){
        d4 = (fabs(x[i]-y[i]) > d4) ? fabs(x[i]-y[i]) : d4;
    }
    printf("%lf\n%lf\n%lf\n%lf\n",d1,d2,d3,d4);

    return 0;
}



Measured memory_bytes: 2112
n=int(input())
p=input().split()
p=list(map(int,p))

mul=1
i=0

if 0 in p:
  print(0)
else:
  while mul<=1000000000000000000 and i!=n:
    mul=mul*p[i]
    i+=1
  if mul>1000000000000000000 or i!=n:
    print(-1)
  else:
    print(mul)

Measured memory_bytes: 21596
#include<iostream>
#include<string>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<vector>
#include<functional>
#include<iomanip>
#include<queue>
#include<cassert>
#include<tuple>
#include<set>
#include<map>
#include<list>
#include<bitset>
#include<utility>
#include<numeric>

#define PB push_back
#define all(a)  (a).begin(),(a).end()
#define ALL(v) begin(v), end(v)
#define DWN(a)  (a).begin(),(a).end(), greater<int>()
#define rep(i, m) for (int i = 0; i < m; i++)
#define REP(i, n, m) for (int i = n; i < m; i++)
#define V vector<int>
#define VV vector<V>
#define VVV vector<VV>

using namespace std;

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

const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };
const int INF = (int)1e9;
const ll inf = (ll)1e18;
const ll MOD{ (ll)1e9 + 7 };
const long double EPS = 1e-10;

int N, M, R;
int d[202][202];
vector<int> v;

int main() {
	cin >> N >> M >> R;
	rep(i, R) {
		int r;
		cin >> r;
		r--;
		v.push_back(r);
	}
	rep(i, N) {
		rep(j, N) {
			if (i == j) d[i][j] = 0;
			else d[i][j] = INF;
		}
	}
	rep(i, M) {
		int a, b, c;
		cin >> a >> b >> c;
		a--; b--;
		d[a][b] = d[b][a] = c;
	}
	rep(k, N) {
		rep(i, N) {
			rep(j, N) {
				d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
			}
		}
	}
	sort(v.begin(), v.end());
	int ans = INF;
	do {
		int sm = 0;
		rep(i, R - 1) {
			sm += d[v[i]][v[i + 1]];
		}
		ans = min(ans, sm);
	} while (next_permutation(v.begin(), v.end()));
	cout << ans << endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,l,r) for(ll i=(l);i<(r);i++)
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    if(abs(a-b)<=d&&abs(b-c)<=d||abs(a-c)<=d)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 256
function main(arg) {
    const [_n , _k] = arg.replace(/\r?\n/g,"").split(" ")
    const n = Number(_n)
    const k = Number(_k)

    if( k % n == 0 ){
      console.log(n + k)
    } else {
      console.log(k - n)
    }
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 7500
#include<bits/stdc++.h>
using namespace std;
#define fastio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

int dp[(int)1e5][3];

int main(){
    fastio;
    int n;
    cin >> n;
    int a,b,c;
    cin >> dp[0][0] >> dp[0][1] >> dp[0][2];
    for(int i=1; i<n; i++){
        cin >> a >> b >> c;
        dp[i][0] = max(max(dp[i-1][1]+a,dp[i-1][2]+a),dp[i-1][0]);
        dp[i][1] = max(max(dp[i-1][0]+b,dp[i-1][2]+b),dp[i-1][1]);
        dp[i][2] = max(max(dp[i-1][0]+c,dp[i-1][1]+c),dp[i-1][2]);
    }
    cout << max(max(dp[n-1][0],dp[n-1][1]),dp[n-1][2]) <<"\n";
    return 0;
}


Measured memory_bytes: 4820
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

//INSERT ABOVE HERE
signed main(){
  Int n,k;
  cin>>n>>k;
  vector<Int> vs(n);
  for(Int i=0;i<n;i++) cin>>vs[i];

  Int ans=0;
  for(Int i=0;i<=n;i++){
    for(Int j=0;j<=n;j++){
      if(i+j>n) continue;
      if(i+j>k) continue;
      
      Int res=0;
      priority_queue<Int> pq;
      for(Int a=0;a<i;a++){
        res+=vs[a];
        pq.emplace(-vs[a]);
      }
      for(Int a=0;a<j;a++){
        res+=vs[n-(a+1)];
        pq.emplace(-vs[n-(a+1)]);
      }
      
      Int d=k-(i+j);
      while(!pq.empty()&&d){
        if(pq.top()<=0) break;
        res+=pq.top();pq.pop();
        d--;
      }      
      chmax(ans,res);
    }
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 384
#include <stdio.h>

int main(void)
{
	int a,b,ans,keta;
	
	while(scanf("%d %d",&a,&b)!=EOF)
	{
		keta=0;
		ans=a+b;
		do
		{
			ans=ans/10;
			keta++;
		}while(ans>0);
		printf("%d\n",keta);
	}
	return 0;
}

Measured memory_bytes: 600
#include <algorithm>
#include <iostream>
#include <stdio.h>

#define MAX_N 101

using namespace std;

int A[MAX_N];

int main() {
  int N, M, X;
  cin >> N >> M >> X;
  int left = 0;
  int right = 0;
  for (int i = 0; i < M; ++i) {
    int a;
    cin >> a;
    if (a < X) {
      ++left;
    } else {
      ++right;
    }
  }
  printf("%d\n", min(left, right));
}

Measured memory_bytes: 3216
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define watch(x) cout << (#x) << " is " << (x) << endl
#define debug cout << "hi" << endl

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;

const int MOD = 1e9 + 7;
const int INF32 = 1<<30;
const ll INF64 = 1LL<<60;

int main()
{
	#ifndef ONLINE_JUDGE
	freopen(".in.txt", "r", stdin);
	freopen(".out.txt", "w", stdout);
	#endif
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll a, b, c, d; cin >> a >> b >> c >> d;
	cout << max({a * c, a * d, b * c, b * d});

	return 0;
}

Measured memory_bytes: 3628
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <complex>
using namespace std;

#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define all(x) (x).begin(),(x).end()
#define mp make_pair
#define pb push_back
#define EPS 1e-8
#define DEB 0

int n,m,z,h;
int edge[64][64];
int edge2[200][200];
vector<pair<int,int> > v;


/*
  vector<int> a, vector<int> b
  03:08 sec	2000 KB

  const vector<int>& a, const vector<int>& b
  03:06 sec	1700 KB
  */

vector<int> calc(const vector<int>& a, const vector<int>& b){
	vector<int> ret;
	rep(i,h){
		rep(j,h){
			int sum = 0;
			rep(k,h){
				sum |= a[i*h+k]*b[k*h+j];
			}
			ret.pb(sum);
		}
	}
	return ret;
}

vector<int> multi(vector<int>& matrix, int k){
	if( k==1 ) return matrix;

	vector<int> tmp = multi(matrix,k/2);
	if( k%2 ){
		return calc(matrix,calc(tmp,tmp));
	}else{
		return calc(tmp,tmp);
	}
}

int main(){

	while(scanf(" %d%d%d ",&n,&m,&z),n|m|z){
		rep(i,64)rep(j,64)edge[i][j]=0;
		rep(i,200)rep(j,200)edge2[i][j]=0;
		
		v.clear();
		rep(i,m){
			int s,d; scanf("%d%d",&s,&d);
			edge[s][d] = edge[d][s] = 1;
		}
		
		//REP(i,1,n+1)edge[i][i]=1;
		edge[1][1] = 1;
		
		REP(i,1,n+1){
			REP(j,1,n+1)if( edge[j][i]==1 ){
				v.pb(mp(i-1,j-1));
			}
		}

		rep(i,v.size()){
			rep(j,v.size()){
				if( v[i].first!=v[j].first && v[i].first==v[j].second && v[i].second!=v[j].first ){
					edge2[i][j] = 1;
				}
			}
		}
		h = v.size();
		vector<int> mat;
		rep(i,v.size()){
			rep(j,v.size()){
				mat.pb(edge2[i][j]);
			}
		}

#if DEB
		rep(i,v.size()){
			printf("(%d,%d)\n",v[i].first, v[i].second);
		}
		rep(i,v.size()){
			rep(j,v.size()){
				printf("%d ",mat[i*h+j]);
			}
			puts("");
		}
#endif

		
		vector<int> hoge = multi(mat,z);

#if DEB
		printf("z:%d\n",z);
		rep(i,v.size()){
			rep(j,v.size()){
				printf("%d ",hoge[h*i+j]);
			}
			puts("");
		}
#endif
		bool f = false;
		rep(i,v.size())if( v[i].first==n-1 ){
			if( hoge[i]>0 ){
				f = true;
				break;
			}
		}
		puts(f?"yes":"no");
	}
	return 0;
}

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

public class Main {
    FastScanner in;
    PrintWriter out;

    void solve() {
        int n = in.nextInt();
        int[] a = new int[n];
        final int MAX = (int) 1e6 + 10;
        int[] cnt = new int[MAX];
        for (int i = 0; i < n; i++) {
            a[i] = in.nextInt();
            cnt[a[i]]++;
        }
        for (int i = MAX - 1; i >= 1; i--) {
            for (int j = i + i; j < MAX; j += i) {
                cnt[j] += cnt[i];
            }
        }
        int res = 0;
        for (int i = 0; i < n; i++) {
            if (cnt[a[i]] == 1) {
                res++;
            }
        }
        out.println(res);
    }


    final int mod = 988244353;

    int mul(int x, int y) {
        return (int) ((x * 1L * y) % mod);
    }

    int add(int x, int y) {
        x += y;
        return x >= mod ? (x - mod) : x;
    }

    void run() {
        try {
            in = new FastScanner(new File("Main.in"));
            out = new PrintWriter(new File("Main.out"));

            solve();

            out.close();
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        }
    }

    void runIO() {

        in = new FastScanner(System.in);
        out = new PrintWriter(System.out);

        solve();
        out.close();
    }

    class FastScanner {
        BufferedReader br;
        StringTokenizer st;

        public FastScanner(File f) {
            try {
                br = new BufferedReader(new FileReader(f));
            } catch (FileNotFoundException e) {
                e.printStackTrace();
            }
        }

        public FastScanner(InputStream f) {
            br = new BufferedReader(new InputStreamReader(f));
        }

        String next() {
            while (st == null || !st.hasMoreTokens()) {
                String s = null;
                try {
                    s = br.readLine();
                } catch (IOException e) {
                    e.printStackTrace();
                }
                if (s == null)
                    return null;
                st = new StringTokenizer(s);
            }
            return st.nextToken();
        }

        boolean hasMoreTokens() {
            while (st == null || !st.hasMoreTokens()) {
                String s = null;
                try {
                    s = br.readLine();
                } catch (IOException e) {
                    e.printStackTrace();
                }
                if (s == null)
                    return false;
                st = new StringTokenizer(s);
            }
            return true;
        }

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

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

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

    public static void main(String[] args) {
        new Main().runIO();
    }
}

Measured memory_bytes: 58980
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <unordered_map>
#include <set>
#include <regex>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include<tuple>

using namespace std;

int main() {
	int N;

	cin >> N;

	for (int i = 0; i * 4 <= N; i++) {
		if ((N - i * 4) % 7 == 0) {
			cout << "Yes" << endl;
			return 0;
		}

	}

	cout << "No" << endl;

	return 0;
}

Measured memory_bytes: 256
// Author : Mohamed Sameh
#include <bits/stdc++.h>
typedef long long ll ;
#define pb push_back
#define f first
#define s second
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define SZ(a) (int)a.size()
#define Flush fflush(stdout);
using namespace std ;
const int M = 1e5 + 2 ;
int n;
int a[M];
int dp[M];
int solve (int i )
{
    if (i >= n )return 1e9 ;
    if (i == n-1 )return 0 ;
    int &ret = dp[i];
    if (~ret)return ret ;
    return ret = min ( abs (a[i] - a[i+1]) + solve(i+1) ,abs (a[i] - a[i+2]) +  solve( i +2 )  );
}
int main()
{
    scanf ("%d" , &n );
    for (int i =0 ; i < n ;i++)scanf ("%d" , a+i );
    a[n] =0 ;
    a[n+1] = 0;
    memset(dp , -1 ,sizeof dp );
    cout << solve(0) <<"\n";
}


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

using namespace std;

typedef long long ll;

const int maxn = 1e6+10;

int n,m,q;
int da[1010][1010];
int dp[1010][1010];

inline int read()
{
    int X=0,w=0; char ch=0;
    while(!isdigit(ch)) w|=ch=='-',ch=getchar();
    while(isdigit(ch)) X=(X<<3)+(X<<1)+(ch^48),ch=getchar();
    return w?-X:X;
}


int main()
{
    n =read(),m =read(),q= read();
    for(int i = 0;i<n;i++){
        for(int j = 0;j<m;j++){
            char u;
            cin>>u;
            if(u == '#')da[i][j] = 1;
            else da[i][j] = 0;
        }
    }
    int res = 0;
    for(int i = 0;i<(1<<n);i++){
        for(int j = 0;j<(1<<m);j++){
            int cnt = 0;
            for(int ni =0;ni<6;ni++){
                if(!((1<<ni)&i)) continue;
                for(int nj = 0;nj<6;nj++){
                    if(!((1<<nj)&j)) continue;
                    if(da[ni][nj]==1)cnt++;
                }
            }
            if(cnt == q) res++;
        }
    }
    cout<<res<<endl;
    return 0;
}


Measured memory_bytes: 3656
#include <bits/stdc++.h>
using namespace std;
#define int long long
vector <pair <int ,int>> wv;
int dp[110][100010];
signed main()
{
	//freopen("out.txt","w", stdout);
	int n, w;
	cin >> n >> w;
	for (int i = 1; i <= n; i++){
		int w, v;
		cin >> w >> v;
		wv.emplace_back(w, v); 
	}
	sort(wv.begin(), wv.end());
	for (int item = 1; item <= n; item++){
		for (int remain_w = 1; remain_w <= w; remain_w++){
			if (wv[item-1].first > remain_w){
				dp[item][remain_w] = dp[item-1][remain_w];
			}else{
				dp[item][remain_w] = max(dp[item-1][remain_w - wv[item-1].first] + wv[item-1].second, dp[item-1][remain_w] );
			}
		}
	}
	cout << dp[n][w];
}

Measured memory_bytes: 79360
#pragma region header
#include <bits/stdc++.h>
using namespace std;

#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_CAT_I(x,y) x ## y
//#define CPP_STR(x) CPP_STR_I(x)
//#define CPP_STR_I(args...) #args
//#define ASSERT(expr...) assert((expr))

using i8 = int8_t;
using u8 = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;
using f32 = float;
using f64 = double;
//using f80 = __float80;
#pragma endregion

#pragma region const
constexpr i64 INF = 1'010'000'000'000'000'017LL;
constexpr i64 MOD = 1'000'000'007LL;
constexpr f64 EPS = 1e-12;
constexpr f64 PI = 3.14159265358979323846;
#pragma endregion

#pragma region util
#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))

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

template<typename T, typename U, typename Comp = less<>>
bool chmax(T& xmax, const U& x, Comp comp = {}) {
	if (comp(xmax, x)) {
		xmax = x;
		return true;
	}
	return false;
}
template<typename T, typename U, typename Comp = less<>>
bool chmin(T& xmin, const U& x, Comp comp = {}) {
	if (comp(x, xmin)) {
		xmin = x;
		return true;
	}
	return false;
}
#pragma endregion

#pragma region init
struct ProconInit {
	static constexpr int IOS_PREC = 15;
	static constexpr bool AUTOFLUSH = false;

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

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

	i64 ans = 0;
	REP(i, 2)
	{
		if (A > B)
		{
			ans += A;
			--A;
		}
		else
		{
			ans += B;
			--B;
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define s(x) (x).begin(),(x).end();
using namespace std;
typedef long long ll; 
typedef vector<int> vi;
int main(){
  string num;
  cin>>num;
  char op[3];
  for (int i = 0; i < (1<<3); i++)
  {
    int sm = num[0]-'0';
    rep(j,3){
      if(i & (1<<j)){
        op[j]='+';
        sm += num[j+1]-'0';
      }
      else{
        op[j]='-';
        sm -= num[j+1]-'0';
      }
    }
    
    if(sm == 7){
      break;
    }
  }
  rep(i,3)cout<<num[i]<<op[i];
  cout<<num[3]<<"=7"<<endl;


}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int n;
int c[4]={0};  //c[1] B...A
int num=0;
int ask(string t)
{
	int len=t.length();
	int num=0;
	int pos=0;
	while((pos=t.find("AB",pos))!=string::npos)
	{
		num++;
		pos=pos+2;
		if(pos>=len)break;
	}
	return num;
}
int main()
{
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		string t;
		cin>>t;
		int len=t.length();
		num+=ask(t);
	//	cout<<ask(t)<<endl;
		if(t[0]=='B'&&t[len-1]=='A')
		   c[1]++;
		if(t[0]=='B'&&t[len-1]!='A')
		   c[2]++;
		if(t[0]!='B'&&t[len-1]=='A')
		   c[3]++;		    
	}
	if(c[1]==0)
	  num=num+min(c[2],c[3]);
	  else if(c[2]+c[3]==0)
	       num+=c[1]-1;
	       else 
	           num+=min(c[2],c[3])+c[1];
	
    cout<<num<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
long long MAX(long long a,long long b){return a<b?b:a;}
int main(){
  long long a=1,n,m,i;
  scanf("%lld %lld",&n,&m);
  for(i=2;i*i<=m;i++){
    if(m%i)continue;
    if(i  *n<=m)a=MAX(a,i  );
    if(m/i*n<=m)a=MAX(a,m/i);
  }
  if(n==1)a=m;
  printf("%lld\n",a);
  return 0;
}
//i*n<=m m%i==0 MAX i


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

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

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

using f32 = float;
using f64 = double;

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

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

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

#define pb push_back
#define mp make_pair

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

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

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


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

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


int main() {
    i64 N; cin >> N;
    vector<i64> A(N);
    REP(i, N) cin >> A[i];

    deque<i64> B;
    bool rev = false;
    REP(i, N) {
        if (rev) B.push_front(A[i]);
        else B.push_back(A[i]);
        rev = !rev;
    }

    if (rev) {
        for (auto it = B.rbegin(); it != B.rend(); it++) cout << (*it) << " ";
        cout << endl;
    } else {
        for (auto it = B.begin(); it != B.end(); it++) cout << (*it) << " ";
        cout << endl;
    }

    return 0;
}


Measured memory_bytes: 6276
#include<bits/stdc++.h>
using namespace std;
int main()
{
   string s;
   getline(cin,s);
   if(s[0]==s[1]||s[1]==s[2]||s[2]==s[3])
   {
       cout<<"Bad";
   }
    else {
        cout<<"Good";
    }
}


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

using namespace std;

#define int long long

main() {
#ifdef HOME
    freopen("input.txt", "r", stdin);
#endif // HOME
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n, ans = 0, i = 2;
    cin >> n;
    while (i * i <= n) {
        if (n % i == 0) {
            int cnt = 0;
            while (n % i == 0) n /= i, cnt++;
            int x = 1;
            while (cnt >= x) {
                cnt -= x, ans++, x++;
            }
        }
        ++i;
    }
    if (n > 1) ans++;
    cout << ans << '\n';
    return 0;
}



Measured memory_bytes: 3648
#include <iostream>

using namespace std;
const long long MAXN = 2e5+5;
long long pref[MAXN];
long long pref2[MAXN];
long long arr[MAXN];
int main() {
    long long n;
    cin>>n;
    for(long long i=1;i<=n;i++){
        cin>>arr[i];
        pref[i] = pref[i-1]+arr[i];
        pref2[i] = pref2[i-1]+arr[i];
    }
    long long ans = 0;
    long long carry = 0;
    for(long long i=1;i<=n;i++){
        if(i%2){
            if(pref[i]<=0){
                ans+=abs(1-pref[i]);
                carry+=abs(1-pref[i]);
            }
        }else{
            if(pref[i]>=0){
                ans+=abs(pref[i]+1);
                carry-=abs(pref[i]+1);
            }
        }
        pref[i+1]+=carry;
    }
    
    long long res =ans;
 
    ans = 0;
    carry = 0;
    for(long long i=1;i<=n;i++){
        if(!(i%2)){
            if(pref2[i]<=0){
                ans+=abs(1-pref2[i]);
                carry+=abs(1-pref2[i]);
            }
        }else{
            if(pref2[i]>=0){
                ans+=abs(pref2[i]+1);
                carry-=abs(pref2[i]+1);
            }
        }
        
        pref2[i+1]+=carry;
       // cout<<pref[i+1]<<endl;
    }
    
    cout<<min(res,ans)<<endl;
}

Measured memory_bytes: 3584
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.List;

public class Main {
	static List<Integer> path;

	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] sa = br.readLine().split(" ");
		int n = Integer.parseInt(sa[0]);
		int a = Integer.parseInt(sa[1]);
		int b = Integer.parseInt(sa[2]);
		int[] h = new int[n];
		for (int i = 0; i < n; i++) {
			h[i] = Integer.parseInt(br.readLine());
		}
		br.close();

		long start = 0;
		long end = 1000000000;
		while (Math.abs(end - start) > 1) {
			long mid = (end + start) / 2;
			if (calc(h, mid, a, b)) {
				end = mid;
			} else {
				start = mid;
			}
		}
		System.out.println(end);
	}

	static boolean calc(int[] h, long t, int a, int b) {
		long all = b * t;
		long one = a - b;
		long cnt = 0;
		for (int i = 0; i < h.length; i++) {
			long r = h[i] - all;
			if (r > 0) {
				cnt += (r + one - 1) / one;
				if (cnt > t) {
					return false;
				}
			}
		}
		return true;
	}
}


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

int main(){
  int n,q;
  cin>>n>>q;
  int om=0;
  for(int i=0; i<q; i++){
    int q1,q2;
    cin>>q1>>q2;
    
    if(q1==1){
      om=(om+q2)%n;
    }else{
      cout<<((q2+om-1)%n)+1<<endl;
    }
  }
}


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

int main(){
    int n;
    std::cin>>n;
    std::vector<int> an(n,0);

    for (int i = 0; i < n; i++)
    {
        std::cin>>an[i];
    }

    int q,beg,end,t;
    std::cin>>q;
    for(int i=0;i<q;i++){
        std::cin>>beg>>end>>t;
        std::swap_ranges(&an[beg],&an[end],&an[t]);
    }

    for(int i=0;i<n;i++){std::cout<<(i? " ":"")<<an[i];}
    std::cout<<std::endl;
    return 0;    
}


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

using ll = long long;
using Pi = pair<int, int>;
using Pl = pair<ll, ll>;
using vint = vector<int>;
using vvint = vector<vint>;
using vvvint = vector<vvint>;
using vdouble = vector<double>;
using vvdouble = vector<vdouble>;
using vvvdouble = vector<vvdouble>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using uint = unsigned int;
using ull = unsigned long long;

template<typename T> using uset = unordered_set<T>;
template<typename T1, typename T2> using umap = unordered_map<T1, T2>;

constexpr int INF = (1 << 30) - 1;
constexpr ll LLINF = 1LL << 60;
constexpr int dy[] = {1, 0, -1, 0, 1, -1, -1, 1};
constexpr int dx[] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr char el = '\n';
constexpr int mod = 1000000007;
constexpr int mod2 = 998244353;
template<typename T> T gcd(T a, T b) { return (b ? gcd(b, a % b) : a); }
template<typename T> T lcm(T a, T b) { return (a / gcd(a, b) * b); }
template<typename T1, typename T2>
inline bool chmin(T1 &a, T2 b) { return (a > b && (a = b, true)); }
template<typename T1, typename T2>
inline bool chmax(T1 &a, T2 b) { return (a < b && (a = b, true)); }
template<typename T>
bool isin(T y, T x, T h, T w) { return (0 <= y && 0 <= x && y < h && x < w); }
template<typename T>
bool isin1(T y, T x, T h, T w) { return (0 < y && 0 < x && y <= h && x <= w); }

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

template<typename T>
istream& operator >>(istream &is, vector<T> &v) {
	for (auto &u : v) is >> u;
	return (is);
}

template<typename T1, typename T2>
istream& operator >>(istream &is, pair<T1, T2> &p) {
	return (is >> p.first >> p.second);
}


void Main() {
	int N; cin >> N;
	string S; cin >> S;
	vector<vector<Pi>> G(N+1);

	int pos = -1;
	int cnt = 0;
	for (int i = 2; i < N; i++) {
		if (S[i] == '1' && S[i-1] == '0' && S[i-2] == '1') {
			pos = i-2;
		}
		if (S[i] == '0') {
			pos = -1;
			cnt = 0;
		} else if (pos != -1) {
			G[pos].emplace_back(i+1, ++cnt);
		}
	}
	pos = -1;
	cnt = 0;
	for (int i = N-3; i >= 0; i--) {
		if (S[i] == '1' && S[i+1] == '0' && S[i+2] == '1') {
			pos = i+2;
		}
		if (S[i] == '0') {
			pos = -1;
			cnt = 0;
		} else if (pos != -1) {
			G[i].emplace_back(pos+1, ++cnt);
		}
	}
	
	vint dp(N+1, -INF);
	dp[0] = 0;

	for (int u = 0; u <= N; u++) {
		if (u > 0) chmax(dp[u], dp[u-1]);
		for (auto &e : G[u]) {
			chmax(dp[e.first], dp[u] + e.second);
		}
	}
	cout << dp[N] << endl;

}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(0);
	cout << fixed << setprecision(20);
	Main();
	return (0);
}


Measured memory_bytes: 35356
#include <iostream>
#include <string>
#include <regex>
using namespace std;
int main() {
  string input;
  cin >> input;
  regex pattern("^A[a-z]+C[a-z]+$");
  if (regex_match(input, pattern))
  {
    cout << "AC" << endl;
  }
  else
  {
    cout << "WA" << endl;
  }
  return 0;
}


Measured memory_bytes: 3680
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define l long
#define pb push_back
int main() {
	// your code goes here
	ios_base::sync_with_stdio(false); 
    cin.tie(NULL); 
	double w,h,x,y;
	cin>>w>>h>>x>>y;
	double ans=(w*h)/2;
	cout<<fixed<<setprecision(10)<<ans<<' ';
	if( 2*x==w && 2*y==h ) cout<<1;
	else cout<<0;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<bits/stdc++.h>
#include <stdio.h>
#include<unordered_map>
#define Amr_Abdelazim ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ll long long
#define ld long double
#define pll pair<ll,ll>
#define vll vector<ll>
#define vvll vector<vector<ll> >
#define vpll vector<pair<ll,ll> >
#define P complex<ld>
#define X real()
#define Y imag()
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define rep(i,n)   for(int i=0;i<n;i++)
#define repp(i,s,n)   for(int i=s;i<=n;i++)
#define print(v) {for(auto i:v)cout<<i<<" ";cout<<"\n";}
#define mkp make_pair
#define clr(ar,v) memset(ar,v,sizeof(ar));
#define TC ll amr_abdelazim;cin>>amr_abdelazim;while(amr_abdelazim--)
#define popcnt(x) __builtin_popcount(x)
#define EPS 1e-9
#define INF 1000000000000000009
#define heeer cout<<"heeeeeeeeer\n";
using namespace std;
//freopen("output.txt", "w", stdout);
//freopen("input.txt", "r", stdin);
const int mod = 1000000007;
const double pi = acos(-1);
class cmp{
public:
	bool operator() (ll &A, ll &B){
		return A > B;
	}
};
bool by_sec(const pll &a, const pll &b){
	if ((abs(a.first) == abs(b.first)))
		return (abs(a.second) < abs(b.second));
	return (abs(a.first) < abs(b.first));
}
bool byth(const tuple<ll, ll, ld>& a, const tuple<ll, ll, ld>& b){
	return (get<2>(a) < get<2>(b));
}
ld dist(P a, P b){
	return (ld)abs(a - b);
}
ll fact[1000009], inv[1000009];
ll fp(ll a, ll b){
	if (b == 0)
		return 1;
	ll ans = fp(a, b / 2);
	ans = (ans * ans)%mod;
	if (b % 2 != 0)
		ans = (ans * (a%mod))%mod;
	return ans;
}
void FacInv(ll n){
	fact[0] = inv[0] = 1;
	for (ll i = 1; i <= n; i++)
	{
		fact[i] = ((i%mod) * fact[i - 1] % mod) % mod;
		inv[i] = fp(fact[i], mod - 2);
	}
}
ll ncr(ll n, ll r){
	return (((fact[n] * inv[r]) % mod) * inv[n - r]) % mod;
}
ll gcd(ll a, ll b){
	if (b == 0)return a;
	return gcd(b, a%b);
}
ll max(ll a, ll b){
	if (a >= b)return a;
	else return b;
}
ll min(ll a, ll b){
	if (a <= b)return a;
	else return b;
}
const int N = 2 * 1000000 + 9;
ll n;
ld dp[300 + 9][300 + 9][300 + 9];
ld fun(ll a,ll b,ll c){
	//cout << a << " " << b << " " << c << "\n";
	if (a == 0 && b == 0 && c == 0)return 0;
	ld &ans = dp[a][b][c];
	ld x =  (ld)n/(a + b + c);
	if (ans == -1){
		ans = 0;
		if (a > 0){
			ans += fun(a - 1, b, c)*((ld)a / (ld)(a + b + c)) + (x*((ld)a / (ld)(a + b + c)));
		}
		if (b > 0){
			ans += fun(a + 1, b - 1, c)*((ld)b / (ld)(a + b + c)) + (x*((ld)b / (ld)(a + b + c)));
		}
		if (c > 0){
			ans += fun(a, b + 1, c - 1)*((ld)c / (ld)(a + b + c)) + (x*((ld)c / (ld)(a + b + c)));
		}
	}
	return ans;
}
ll c[5];
int main()
{
	Amr_Abdelazim
		rep(i, 300 + 8)rep(j, 300 + 8)rep(k, 300 + 8)dp[i][j][k] = -1;
	cin >> n;
	vll v(n);
	rep(i, n)cin >> v[i],c[v[i]]++;
	cout << fixed << setprecision(9) << fun(c[1],c[2],c[3]) << "\n";
		
	
	return 0;
}


Measured memory_bytes: 463020
#include <iostream>
#include <set>
#include <initializer_list>

using namespace std;

int main()
{
    string s;
    set<char> right = {'y', 'u', 'i', 'o', 'p', 'h', 'j', 'k', 'l', 'n', 'm'};
    while (cin >> s, s!="#") {
        int lastr = right.count(s[0]);
        int count = 0;
        for (char c: s) {
            int key = right.count(c);
            if (key != lastr) {
                lastr = key;
                count++;
            }
        }
        cout << count << endl;
    }
    return 0;
}

Measured memory_bytes: 3180
import numpy as np
N = int(input())
A = np.array(input().split(), np.int64)
MOD = 10**9+7

U = 10**6 + 10
T = np.zeros(U, np.bool)
T[2] = 1
T[3::2] = 1

for p in range(3,U,2):
  if p*p>U:
    break
  if T[p]==1:
    T[p*p::p+p] = 0

M = np.where(T[:1000])[0].tolist()

B = A.copy()
lcm = 1
for p in M:
  e = 0
  while np.any(A%p==0):
    A[A%p==0] //= p
    e += 1
  lcm *= p**e
  lcm %= MOD
for x in set(A.tolist()):
  lcm *= x
  lcm %= MOD
x = sum(pow(c, MOD-2, MOD) for c in B.tolist())
print(x*lcm%MOD)

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

using namespace std;
using ll = long long;
using ld = long double;
const int MOD = 1e9 + 7;

int main() {
	int x;
	cin >> x;
	string r = "";
	string a = "ACL";
	for (int i = 0; i < x; i++) {
		r += a;
	}
	cout << r << endl;
}


Measured memory_bytes: 3632
#include<stdio.h>

int main()
{
    int l[10], sum = 0, n, max = 0;
    scanf("%d", &n);
    for(int i = 0; i < n; i++)
    {
        scanf("%d", &(l[i]));
        sum += l[i];
        if(max < l[i]) max = l[i];
    }
    if(max < sum - max)
    {
        printf("Yes");
    }
    else
    {
        printf("No");
    }
    return 0;
}

Measured memory_bytes: 128
import std.stdio;
import std.algorithm;
import std.string;
import std.range;
import std.array;
import std.conv;
import std.complex;
import std.math;
import std.ascii;
import std.bigint;
import std.container;
import std.typecons;

auto readInts() {
	return array(map!(to!int)(readln().strip().split()));
}
auto readInt() {
	return readInts()[0];
}
auto readLongs() {
	return array(map!(to!long)(readln().strip().split()));
}
auto readLong() {
	return readLongs()[0];
}

const real eps = 1e-10;

void main(){
	auto notPrime = new bool[](200000);
	notPrime[0] = notPrime[1] = true;
	for(int i; i < notPrime.length; ++i) {
		if(!notPrime[i]) {
			for(int j = 2; i*j < notPrime.length; ++j) {
				notPrime[i*j] = true;
			}
		}
	}
	int[] primes;
	for(int i; i < notPrime.length; ++i) {
		if(!notPrime[i]) {
			primes ~= i;
		}
	}
	while(true) {
		auto np = readInts();
		auto n = np[0];
		auto p = np[1];
		if(n < 0) {
			return;
		}
		auto plist = primes.assumeSorted.upperBound(n)[0..p].array;
		int[] sum;
		for(int i; i < plist.length; ++i) {
			for(int j = i; j < plist.length; ++j) {
				sum ~= plist[i] + plist[j];
			}
		}
		writeln(sum.sort[p-1]);
	}
}

Measured memory_bytes: 6192
A, B = list(map(int, input().split()))

def gcd(x, y):
  b = max(x, y)
  s = min(x, y)
  r = b % s
  while r != 0:
    b = s
    s = r
    r = b % s
  return s

def lcm(x, y):
  return (x * y) // gcd(x,y)


print(lcm(A, B))

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

#ifdef LOCAL
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
#else
#define trace(...) 42
#endif
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 << "\t|";
    __f(comma + 1, args...);
}

#define print(x) for(auto it : x) cout<< it << ' '; cout << '\n';
typedef long long ll;
typedef unsigned long long ull;
#define mem1(a)           memset(a,-1,sizeof(a))
#define mem0(a)           memset(a,0,sizeof(a))

const int MOD = 1e9 + 7;
ll mod(ll a) { return (ll) (a % MOD + MOD) % MOD; }
ll mul(ll a, ll b) { return (ll) mod(mod(a) * mod(b));}

ll dp[1000][1000];

int main() {
    ios::sync_with_stdio(false); cin.tie(0);
    int h, w; cin >> h >> w;
    vector<string> a(h);
    for (int i = 0; i < h; i++)
        cin >> a[i];
    dp[0][0] = 1;
    for (int r = 0; r < h; r++) {
        for (int c = 0; c < w; c++) {
            if (r == 0 && c == 0) continue;
            if (a[r][c] == '#') {
                dp[r][c] = 0;
            } else {
                ll up = r > 0 ? dp[r - 1][c] : 0;
                ll left = c > 0 ? dp[r][c - 1] : 0;
                dp[r][c] = (up + left) % MOD;
            }
        }
    }
//    for (int r = 0; r < h; r++) {
//        for (int c = 0; c < w; c++) {
//            cout << dp[r][c];
//        }
//    }
    cout << dp[h - 1][w - 1] << '\n';
    return 0;
}


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

const int N=110000;
struct Edge {
    int go,next;
} eg[N<<1];
int last[N],tot;
int fa[N],dis[N],sz[N];

void addedge(int x,int y)
{
    eg[tot]={y,last[x]};
    last[x]=tot++;
}

void dfs(int u,int f,int d)
{
    fa[u]=f;dis[u]=d;sz[u]=1;
    for (int i=last[u];i!=-1;i=eg[i].next) {
        int v=eg[i].go;
        if (v==f) continue;
        dfs(v,u,d+1);
        sz[u]+=sz[v];
    }
}

int main()
{
    int n;
    scanf("%d",&n);
    tot=0;
    memset(last,-1,sizeof(last));
    for (int i=1;i<n;i++) {
        int x,y;
        scanf("%d%d",&x,&y);
        addedge(x,y);
        addedge(y,x);
    }
    dfs(1,0,0);
//    for (int i=1;i<=n;i++) {
//        printf("%d ",dis[i]);
//    }
//    puts("");
//    for (int i=1;i<=n;i++) {
//        printf("%d ",fa[i]);
//    }
//    puts("");
//    for (int i=1;i<=n;i++) {
//        printf("%d ",sz[i]);
//    }
//    puts("");
    int d=dis[n]-1;
    int h=0,x=n;
    while ((h+1+h+1)<=d) {
        x=fa[x];++h;
    }
    puts(n-sz[x]>sz[x]?"Fennec":"Snuke");
    return 0;
}


Measured memory_bytes: 9728
from fractions import gcd

N = int(input())
A = tuple(map(int, input().split()))

gcd_left, gcd_right = [0] * N, [0] * N
gcd_left[0] = A[0]
gcd_right[-1] = A[-1]
for i in range(1, N):
    gcd_left[i] = gcd(gcd_left[i - 1], A[i])
for i in range(N - 2, -1, -1):
    gcd_right[i] = gcd(gcd_right[i + 1], A[i])

gcd_left = [gcd_right[-1]] + gcd_left
gcd_right = gcd_right + [gcd_left[1]]
ans = 1
for i in range(N):
    ans = max(ans, gcd(gcd_left[i], gcd_right[i + 1]))
print(ans)


Measured memory_bytes: 16236