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

namespace cover_2d {
    double eps = 1e-9;
    using Point = complex<double>;
    struct Circle {
        Point p; double r;
    };
    double dist(Point p, Point q) {
        return abs(p - q);
    }
    double area2(Point p, Point q) {
        return (conj(p)*q).imag();
    }
    bool in(const Circle& c, Point p) {
        return dist(c.p, p) < c.r + eps;
    }
    Circle INVAL = Circle{ Point(0, 0), -1 };
    Circle mCC(Point a, Point b, Point c) {
        b -= a; c -= a;
        double d = 2 * (conj(b)*c).imag(); if(abs(d) < eps) return INVAL;
        Point ans = (c*norm(b) - b * norm(c)) * Point(0, -1) / d;
        return Circle{ a + ans, abs(ans) };
    }
    Circle solve(vector<Point> p) {
        mt19937 gen(0x94949); shuffle(p.begin(), p.end(), gen);
        Circle c = INVAL;
        for(int i = 0; i < p.size(); ++i) if(c.r < 0 || !in(c, p[i])) {
            c = Circle{ p[i], 0 };
            for(int j = 0; j <= i; ++j) if(!in(c, p[j])) {
                Circle ans{ (p[i] + p[j])*0.5, dist(p[i], p[j])*0.5 };
                if(c.r == 0) {
                    c = ans; continue;
                }
                Circle l, r; l = r = INVAL;
                Point pq = p[j] - p[i];
                for(int k = 0; k <= j; ++k) if(!in(ans, p[k])) {
                    double a2 = area2(pq, p[k] - p[i]);
                    Circle c = mCC(p[i], p[j], p[k]);
                    if(c.r < 0) continue;
                    else if(a2 > 0 && (l.r<0 || area2(pq, c.p - p[i]) > area2(pq, l.p - p[i]))) l = c;
                    else if(a2 < 0 && (r.r < 0 || area2(pq, c.p - p[i]) < area2(pq, r.p - p[i]))) r = c;
                }
                if(l.r < 0 && r.r < 0) c = ans;
                else if(l.r < 0) c = r;
                else if(r.r < 0) c = l;
                else c = l.r <= r.r ? l : r;
            }
        }
        return c;
    }
};

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

    vector<complex<double>> v;
    for(int i = 0; i < n; i++)
    {
        int x, y;
        scanf("%d%d", &x, &y);
        v.push_back({ (double)x, (double)y });
    }

    auto c = cover_2d::solve(v);
    printf("%.10lf\n", c.r);
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
using namespace std;
int gcd(int x,int y){
  if(x%y == 0) return y;
  else return gcd(y,x%y);
}
int A[1000000];
int main(){
  int N,i,j,k,a;scanf("%d",&N);
  int B[N];
  for(i=0;i<N;i++){
    scanf("%d",&a);
    B[i] = a;
    A[a]++;
  }
  bool ok = true;int t;
  for(i=2;i<=1000000;i++){
    t = 0;
    for(j=i;j<=1000000;j+=i){
      t += A[j];
    }
    ok &= t<=1;
  }
  if(ok){
    printf("pairwise coprime\n");return 0;
  }
  int ans = B[0];
  for(i=1;i<N;i++) ans = gcd(ans,B[i]);
  printf(ans == 1 ? "setwise coprime\n":"not coprime\n");
}

Measured memory_bytes: 11524
import sys
from fractions import gcd

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60


def lcm(a, b):
    return a // gcd(a, b) * b


def main():
    N, M, *A = map(int, read().split())
    A = [a // 2 for a in A]

    power = 1
    while all(a % 2 == 0 for a in A):
        A = [a // 2 for a in A]
        power *= 2

    if any(a % 2 == 0 for a in A):
        print(0)
        return

    l = 1
    for a in A:
        l = lcm(l, a)
        if l > M:
            print(0)
            return

    l *= power
    ans = (M + l) // (2 * l)
    print(ans)
    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 16104
/*
 * FileName:     bubble
 * CreatedDate:  2020-04-12 14:03:02 +0900
 * LastModified: 2020-04-12 14:10:23 +0900
 */

#include <stdio.h>
int count=0;
void bubble(int a[],int n){
    for(int i=0;i<n;i++){
        for(int j=n-1;j>i;j--){
            if(a[j]<a[j-1]){
                int tmp=a[j-1];
                a[j-1]=a[j];
                a[j]=tmp;
                count++;
            }
        }
    }
}
int main(void){
    int n;
    scanf("%d",&n);
    int a[n];
    for(int i=0;i<n;i++){
        scanf("%d", &a[i]);
    }
    bubble(a,n);
    printf("%d",a[0]);
    for(int i=1;i<n;i++){
        printf(" %d",a[i]);
    }
    printf("\n%d\n",count);

    return 0;
}



Measured memory_bytes: 2112
#include<stdio.h>
#include<math.h>
#include<string.h>


int main(){
	long long int uriage[4000][3],n,no,tanka,su,i,j,newflag,naflag;
	
	while(0<=scanf("%lld",&n)){
		if(n==0) break;
		
		memset(uriage,0,sizeof(uriage));
		
		for(i=0;i<n;i++){
			scanf("%lld%lld%lld",&no,&tanka,&su);
			
			newflag=0;
			
			for(j=0;j<n;j++){
				if(uriage[j][0]==no && uriage[j][2]==1){
					uriage[j][1]+=tanka*su;
					newflag=1;
					break;
				}
			}
			
			if(newflag==0){
				for(j=0;j<n;j++){
					if(uriage[j][2]==0){
						uriage[j][1]+=tanka*su;
						uriage[j][0]=no;
						uriage[j][2]=1;
						break;
					}
				}
			}
		}
		naflag=0;
		for(i=0;i<n;i++){
			if(uriage[i][2]==0)break;
			if(uriage[i][1]>=1000000){
				printf("%lld\n",uriage[i][0]);
				naflag=1;
			}
		}
		if(naflag==0)printf("NA\n");
	}
	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <sstream>
#include <stack>
#include <iomanip>
#include <numeric>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cstdlib>
#include <map>
#include <set>
#include <vector>
#include <utility>
#include <queue>
#include <cmath>

#define BEGIN(x) x.begin()
#define END(x) x.end()
#define ALL(x) BEGIN(x), END(x)
#define PAIR make_pair
#define VEC(type) vector<type >
#define endl '\n'

#define FOR(i, A, B) for(auto i = (A);i != (B); i++)
#define FORD(i, A, B) for(auto i = (A);i != (B); i--)

#define READRANGE(begin, end) FOR(it, begin, end) cin >> *it
#define READVEC(V) READRANGE(BEGIN(V), END(V))

using namespace std;

typedef long long lint;
typedef pair<int, int> Pii;
typedef pair<int, lint> Pil;
typedef pair<lint, lint> Pll;
typedef pair<lint, int> Pli;

// ---- BEGIN LIBRARY CODE ----
// ---- END LIBRARY CODE ----
void io_init()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
};

int main(int argc, char **argv)
{
    io_init();

    // Actual program code starts here.
    string S;
    cin >> S;
    const int N = S.size();

    VEC(int) lefts, rights;
    FOR(i, 0, N)
        if (S[i] == 'L')
            lefts.push_back(i);
        else
            rights.push_back(i);

    VEC(int) Answer(N, 0);

    FOR(i, 0, N) {
        if (S[i] == 'R') {
            // find first left turn to right of i.
            int l = *lower_bound(ALL(lefts), i);
            // i -> i + 1 -> ... -> l -> (l - 1) -> l ...
            int dest = l - (l - i) % 2;
            Answer[dest]++;
        }
        else {
            int r = upper_bound(ALL(rights), i - 1) - rights.begin();
            r = rights[r - 1];

            int dest = r + (i - r) % 2;
            Answer[dest]++;
        }
    }

    FOR(i, 0, N)
        cout << Answer[i] << " ";
    cout << endl;
    return 0;
};


Measured memory_bytes: 1612
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;

int main()
{
	int n;
	cin>>n;
	ll a[16][16];
	for(int i=0; i<n; i++){
		for(int j=0; j<n; j++){
			cin>>a[i][j];
		}
	}
	ll s[1<<16]={}; ll dp[1<<16]={};
	for(int i=0; i<(1<<n); i++){
		for(int j=0; j<n; j++){
			if((i&(1<<j))==0) continue;
			for(int k=j+1; k<n; k++){
				if(i&(1<<k)) s[i]+=a[j][k];
			}
		}
		dp[i]=s[i];
	}
	for(int i=1; i<(1<<n); i++){
		for(int j=i; j>0; j=(j-1)&i){
			if(j==i) continue;
			dp[i]=max(dp[i], dp[i-j]+dp[j]);
		}
	}
	cout<<dp[(1<<n)-1]<<endl;
	return 0;
}

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

#define cnd(c, a, b) (c ? a : b);
#define fl(x,y,z) for(int x=y;x<z;x++)
#define fe(x,y,z) for(int x=y;x<=z;x++)
#define fge(x,y,z) for(int x=y;x>=z;x--)

#define debug(x) std::cerr << #x << " --> " << x << "\n";
#define fastIO std::ios_base::sync_with_stdio(false);std::cin.tie(0);std::cout.tie(0);
#define pb push_back
#define pob pop_back
 
#define ln '\n'
typedef long long int ll;

ll mod=1e9+7;

void decrypt() {
	ll n, ans, tmp, sum;
	vector<ll> in, cum;
	cin>>n;
	sum = 0;
	fl(i,0,n) {
		cin>>tmp;
		sum += tmp;
		in.pb(tmp);
	}
	tmp = 0;
	fl(i,0,n) {
		sum -= in[i];
		cum.pb(sum);
	}
	ans = 0;
	fl(i,0,n-1) {
		ans = (ans%mod + (in[i]%mod)*(cum[i]%mod))%mod;
	}
	cout<<((ans+mod)%mod)<<ln;
	return;
}

int main() {
    fastIO
    int t = 1;
    // cin >> t;
    fl(i,0,t) {
    	// cout << "Case #"<< i+1 <<": ";
    	decrypt();
    }
    return 0;
}

Measured memory_bytes: 7948
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define rep(i,n) for(ll i=0;i<n;++i)
#define ocut cout
#define ouct cout
#define itn int

struct Union{
  vector<ll> par;
  Union(ll a){
  par=vector<ll>(a,-1);
  }
  ll find(ll a){
    if(par[a]<0){
      return a;
    }
    else{
      return par[a]=find(par[a]);
    }
  }
  bool same(ll a,ll b){
    return (find(a)==find(b));
  }
  ll size(ll a){
    return -par[find(a)];
  }
  void unite(ll a,ll b){
    ll c=find(a),d=find(b);
    if(c==d)
      return;
    if(size(c)<size(d)){
      swap(c,d);
    }
    par[c]+=par[d];
    par[d]=c;
  }
};

int main(){
  ll n,m,b=0;
  cin >> n >> m;
  ll a[m];
  rep(i,m){
    cin >> a[i];
    b+=a[i];
  }
  if(n-b<-1)b=n+1;
  cout << n-b;
}


Measured memory_bytes: 3712
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
  int n,a; cin >> n >> a;
  vector<int> x(n);
  for(int i=0; i<n; i++) cin >> x[i];
  ll dp[60][60][2510];
  for(int i=0; i<60; i++){
    for(int j=0; j<60; j++){
      for(int k=0; k<2510; k++){
        dp[i][j][k]=0;
      }
    }
  }
  for(int i=0; i<=n; i++) dp[i][0][0]=1;
  for(int i=0; i<n; i++){
    for(int j=0; j<n; j++){
      for(int k=0; k<=n*50; k++){
        if(k<x[i]) dp[i+1][j+1][k]+=dp[i][j+1][k];
        else dp[i+1][j+1][k]+=dp[i][j][k-x[i]]+dp[i][j+1][k];
      }
    }
  }
  ll res=0;
  for(int i=1; i<=n; i++){
    for(int j=0; j<=n*50; j++){
      if(j%i==0&&j/i==a) res+=dp[n][i][j];
    }
  }
  //cout << dp[n][1][8] << endl;
  cout << res << endl;
}

Measured memory_bytes: 70784
import sys

input = lambda: sys.stdin.readline().rstrip()


def factorize(n):
    b = 2
    fct = dict()
    while b * b <= n:
        while n % b == 0:
            n //= b
            if b in fct:
                fct[b] += 1
            else:
                fct[b] = 1
        b = b + 1
    if n > 1:
        if n in fct:
            fct[n] += 1
        else:
            fct[n] = 1
    return fct


def solve():
    N = int(input())
    prime_list = factorize(N)

    if N == 1:
        print(0)
        exit()

    ans = 0
    for p, num in prime_list.items():
        i = 1
        m = 1
        while True:
            if num >= m:
                ans += 1
            else:
                break
            i += 1
            m += i

    print(ans)


if __name__ == '__main__':
    solve()


Measured memory_bytes: 9232
#include <stdio.h>
#define N 101

int A[N][N], n, i, j, u, k, v;

int main(){

  scanf("%d",&n);
  for(i = 0; i < n; i++){
    scanf("%d%d", &u, &k);
    for(j = 0; j < k; j++){
      scanf("%d", &v);
      A[u-1][v-1] = 1;
    }
  }

  for(i = 0; i < n; i++){
    for(j = 0; j < n; j++){
      //if(A[i][j] == 1) printf("1");
      //eelse printf("0");
      printf("%d",A[i][j]);
      if(j < n - 1) printf(" ");
    }
    printf("\n");
  }
  return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>					
using namespace std;	
int main()	
{	
int n;
cin>>n;
string s;
 cin>>s;
 int ans = 0;
 for(int i =0;i<s.size();i++){
 if(s[i]=='A'&&s[i+1]=='B'&&s[i+2]=='C'){
 ans++;
 }
 if(i+3>s.size()){
 	break;
 } 
 }
 cout<<ans;
	return 0; 									
 }

Measured memory_bytes: 256
N = int(input())
L_list = list(map(int, input().split()))

count = 0
i = 0
while i < N:
    a = L_list[i]
    j = 0
    while j < i:
        b = L_list[j]
        k = 0
        while k < j:
            c = L_list[k]
            k += 1
            if a == b or b == c or c == a:
                continue
            if a + b > c and b + c > a and c + a > b:
                count += 1
        j += 1
    i += 1
                
print(count)



Measured memory_bytes: 9052
#include <bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ll long long int
#define pb push_back
#define fi first
#define se second
#define ld long double
#define vi vector<vector<ll> >
using namespace std;
const int MOD=1000000007;
const int MOD2=15000007;
const ll MAX=9187201950435737471;
const int N=100005;
const int INF=1e17;
const long double PI=acos(-1);

int a[2003][2003];

void solve(int T){
    map<int,int>mp;
    int n,x,y;
    cin>>n>>x>>y;
    for(int i=1;i<=n;i++){
        for(int j=1;j<=n;j++){
            a[i][j]=abs(i-j);
        }
    }
    a[x][y]=1;
    a[y][x]=1;
    for(int i=1;i<=n;i++){
        for(int j=i+1;j<=n;j++){
            if(i==j-1){
                mp[a[i][j]]++;
            }
            else {
                a[i][j]=min(a[i][j],a[i][x]+a[j][y]+1);
                mp[a[i][j]]++;
            }
        }
    }
    for(int i=1;i<n;i++){
        if(mp.count(i)){
            cout<<mp[i]<<"\n";
        }
        else cout<<"0\n";
    }
}

int main() {
    fastio
    int T=1;
    //cin>>T;
    for(int i=1;i<=T;i++){
        solve(i);
        //if(i<T)cout<<"\n";
    }
    return 0;
}





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

int main(){
    int W,H,x,y,r;
    cin>>W>>H>>x>>y>>r;
    
    if(r<=x&&x+r<=W&&r<=y&&y+r<=H){
        cout<<"Yes"<<endl;
        
    }else{
        cout<<"No"<<endl;}
    
    return 0;
}


Measured memory_bytes: 3092
#include <iostream>
#include <math.h> 
#include <string> 
#include <algorithm>
using namespace std;

int main() {

	long N, K; cin >> N >> K;
	//Kが奇数ならabcはKの倍数。
	//Kが偶数ならabcはKの倍数または半倍数。
	long res;
	long ak = N / K; ak = ak * ak * ak;
	long fk = (N + K / 2) / K; fk = fk * fk * fk;

	res = (K % 2 == 0) ? ak + fk : ak;

	cout << res << endl;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
using datas=pair<ll,ll>;
using ddatas=pair<double,double>;
using tdata=pair<ll,datas>;
using vec=vector<ll>;
using mat=vector<vec>;
using pvec=vector<datas>;
using pmat=vector<pvec>;
#define For(i,a,b) for(i=a;i<(ll)b;i++)
#define bFor(i,a,b) for(i=a;i>=(ll)b;i--)
#define rep(i,N) For(i,0,N)
#define rep1(i,N) For(i,1,N)
#define brep(i,N) bFor(i,N-1,0)
#define all(v) (v).begin(),(v).end()
#define allr(v) (v).rbegin(),(v).rend()
#define vsort(v) sort(all(v))
#define vrsort(v) sort(allr(v))
#define endl "\n"
#define pb push_back
#define output(v) do{bool f=0;for(auto outi:v){cout<<(f?" ":"")<<outi;f=1;}cout<<endl;}while(0)
const ll mod=1000000007;
const ll inf=1LL<<60;
const double PI = acos(-1);
const double eps = 1e-9;
template<class T> inline bool chmax(T& a,T b){bool x=a<b;if(x)a=b;return x;} 
template<class T> inline bool chmin(T& a,T b){bool x=a>b;if(x)a=b;return x;} 
 
void startupcpp(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<fixed<<setprecision(15);
}
 
double distance(ddatas& x,ddatas& y){
  double a=x.first-y.first,b=x.second-y.second;
  return sqrt(a*a+b*b);
}
 
ll modinv(ll a) {
  ll b=mod,u=1,v=0,t;
  while(b){
    t=a/b;
    a-=t*b; swap(a,b);
    u-=t*v; swap(u,v);
  }
  return (u+mod)%mod;
}
 
ll moddevide(ll a,ll b){return (a*modinv(b))%mod;}
 
vec modncrlistp,modncrlistm;
 
ll modncr(ll n,ll r){
  ll i,size=modncrlistp.size();
  if(size<=n){
    modncrlistp.resize(n+1);
    modncrlistm.resize(n+1);
    if(!size){
      modncrlistp[0]=modncrlistm[0]=1;
      size++;
    }
    For(i,size,n+1){
      modncrlistp[i]=modncrlistp[i-1]*i%mod;
      modncrlistm[i]=modinv(modncrlistp[i]);
    }
  }
  return modncrlistp[n]*modncrlistm[r]%mod*modncrlistm[n-r]%mod;
}
 
ll modpow(ll a,ll n){
  ll res=1;
  while(n){
    if(n&1)res=res*a%mod;
    a=a*a%mod;
    n>>=1;
  }
  return res;
}
 
ll gcd(ll a,ll b){if(!b)return a;return (a%b==0)?b:gcd(b,a%b);}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
 
ll countdigits(ll n){
  ll ans=0;
  while(n){n/=10;ans++;}
  return ans;
}
 
ll sumdigits(ll n){
  ll ans=0;
  while(n){ans+=n%10;n/=10;}
  return ans;
}
void judgement(int a){
  if(a){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
  if(a){
    cout<<"YES"<<endl;
  }else{
    cout<<"NO"<<endl;
  }
}
int main(){
  startupcpp();
  ll i,j,N,K=1024,ans=-inf,res,cnt;
  cin>>N;
  mat v(N,vec(10)),cost(N,vec(11));
  vec ch(10);
  rep(i,N)rep(j,10)cin>>v[i][j];
  rep(i,N)rep(j,11)cin>>cost[i][j];
  while(K-->1){
    rep(i,10){
      if(K&(1<<i))ch[i]=1;
      else ch[i]=0;
    }
    res=0;
    rep(i,N){
      cnt=0;
      rep(j,10)cnt+=ch[j]&v[i][j];
      res+=cost[i][cnt];
    }
    chmax(ans,res);
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 256
from collections import deque
from sys import stdin
q = deque()
input()
for s in stdin:
    c, *k = s.split()
    k = k[0] if k else None
    if c[0] == 'i':
        q.appendleft(k)
    elif c[0] == 'd':
        if c[6:7] == 'F':
            q.popleft()
        elif c[6:7] == 'L':
            q.pop()
        else:
            if k in q:
                q.remove(k)
print(*q)


Measured memory_bytes: 69764
import java.util.*;

class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String s = sc.next();
    String su = "Sunny";
    String cl = "Cloudy";
    String ra = "Rainy";
    if(s.equals(su)) {
      System.out.println(cl);
    } else if(s.equals(cl)) {
      System.out.println(ra);
    } else {
      System.out.println(su);
    }
  }
}

Measured memory_bytes: 21716
//by xiqiao
#include<bits/stdc++.h>
#define maxn 200005
using namespace std;
typedef long long ll;
int n;
char s[maxn];
int f[maxn],g[maxn],high[maxn],low[maxn],out[maxn],in[maxn];
vector <int> v[maxn];
void dfs(int x,int last){
	if(s[x]=='1')in[x]=1;
	for(int i=0;i<(int)v[x].size();i++)if(v[x][i]!=last){
		dfs(v[x][i],x);
		f[x]=max(f[v[x][i]]+1,f[x]);
		in[x]|=in[v[x][i]];
	}
}
void dfs2(int x,int last){
	int mx1=0,mx2=0,cut=0;
	for(int i=0;i<(int)v[x].size();i++)if(v[x][i]!=last){
		if(f[v[x][i]]+1>mx1)mx2=mx1,mx1=f[v[x][i]]+1;
		else if(f[v[x][i]]+1>mx2)mx2=f[v[x][i]]+1;
		cut+=in[v[x][i]];
	}
	for(int i=0;i<(int)v[x].size();i++)if(v[x][i]!=last){
		int y=v[x][i];
		if(f[y]+1==mx1)g[y]=max(g[x]+1,mx2+1);
		else g[y]=max(g[x]+1,mx1+1);
		out[y]=out[x];
		if(cut-in[y] || s[x]=='1')out[y]=1;
		dfs2(y,x);
	}
}
void dfs3(int x,int last){
	int mx1=g[x],mx2=0;
	for(int i=0;i<(int)v[x].size();i++)if(v[x][i]!=last){
		int y=v[x][i];
		if(f[y]+1>mx1)mx2=mx1,mx1=f[y]+1;
		else if(f[y]+1>mx2)mx2=f[y]+1;
	}
	high[x]=min(mx2+1,mx1-1);
	if(s[x]=='1')low[x]=0;
	else{
		low[x]=high[x]+1;
		if(out[x])low[x]=min(low[x],g[x]);
		for(int i=0;i<(int)v[x].size();i++)if(v[x][i]!=last){
			int y=v[x][i];
			if(in[y])low[x]=min(low[x],f[y]+1);
		}
	}
	for(int i=0;i<(int)v[x].size();i++)if(v[x][i]!=last){
		dfs3(v[x][i],x);
	}
}
int main(){
	//freopen("1.in","r",stdin);
	scanf("%d",&n);
	for(int i=1;i<n;i++){
		int x,y;scanf("%d%d",&x,&y);
		v[x].push_back(y);v[y].push_back(x);
	}
	scanf("%s",s+1);
	dfs(1,0);dfs2(1,0);
	dfs3(1,0);
	ll ans=0;
	for(int i=1;i<=n;i++)ans+=high[i]-low[i]+1;//cout<<low[i]<<" "<<high[i]<<endl;
	ans++;
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 28032
R, G, B = [int(x) for x in input().strip().split(" ")]
K = int(input().strip())

success = False
while K > 0:
    if R >= G:
        G *= 2
    elif G >= B:
        B *= 2
    if R < G < B:
        success = True
        break
    K -= 1
print("Yes" if success else "No")

Measured memory_bytes: 9180
def check():
    s=input()
    t=input()

    d={}

    for i in range(len(s)):
        si=s[i]
        ti=t[i]
        if not si in d:
            d[si]=ti
        else:
            if d[si]==ti:
                continue
            else:
                return "No"
            
    vals=d.values()
    if len(vals)==len(set(vals)):
        return "Yes"
    else:
        return "No"
print(check())

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

int main(){
  while(1){
    int rn,wn,c,r;
    cin>>rn>>wn>>c>>r;
    if(rn==0) break;
    int i=wn*c-rn;
    if(i<=0){
      cout<<0<<endl;
    }
    else if(i%r==0){
      cout<<i/r<<endl;
    }else{
      cout<<i/r+1<<endl;
    }
  }
 

  return 0;
}
   
 
      
 
  
   
  
	
	  
	  
	  
	  
	  
	  
     
  
  
  
  
  

  

 
  


 

    
  



Measured memory_bytes: 3072
N = int(input())
S = input()
total = S.count('R') * S.count('G') * S.count('B')
cnt = 0

for i in range(0, N-2):
    for j in range(i+1, N-1):
        if S[i] == S[j]:
            continue
        k = 2 * j - i
        if k > N - 1:
            break
        if S[i] == S[k] or S[j] == S[k]:
            continue
        cnt += 1
print(total - cnt)

Measured memory_bytes: 9204
N, K = map(int, input().split())
A = list(map(int, input().split()))
mod = 10**9+7
ans = 0

# 普通の転倒数を求める
normal = 0
for i in range(N):
    for j in range(i+1, N):
        if A[i] > A[j]:
            normal += 1
un_normal = 0
for i in range(N):
    for j in range(N):
        if A[i] > A[j]:
            un_normal += 1
print((normal * K + un_normal * K * (K-1) // 2) % mod)


Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef vector<int> VI;
 
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
const int mod=1e9+7;

int main(){
  long double r,c;int n;cin>>r>>c>>n;
  vector<pair<long double,int>> t;
  int ctr=0;
  rep(i,n){
    long double x1,y1,x2,y2;cin>>x1>>y1>>x2>>y2;
    if((x1!=0&&x1!=r)&&(y1!=0&&y1!=c))continue;
    if((x2!=0&&x2!=r)&&(y2!=0&&y2!=c))continue;
    t.push_back(make_pair(atan2(y1-c/2,x1-r/2),ctr*2));
    t.push_back(make_pair(atan2(y2-c/2,x2-r/2),ctr*2+1));
    ctr++;
  }
  sort(all(t));
  stack<int> s;
  rep(i,t.size()){
    int sc=t[i].second;
    int opp=(sc%2?sc-1:sc+1);
    if(s.empty()||s.top()!=opp){
      s.push(sc);
    }
    else{
      s.pop();
    }//cout<<(int)s.size()<<endl;
    //cout<<(s.empty()?100:s.top())<<endl;
  }
  cout<<(s.size()?"NO":"YES")<<endl;
}


Measured memory_bytes: 10476
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<map>
#include<set>
#include <sstream>
#include<queue>
#include<stack>
#include<functional>
#include<math.h>
#include <iomanip>
#include <numeric>
#include <iterator>
#include <math.h>
#include <list>
#include <bits/stdc++.h>

using namespace std;

int main(void){
  long N ,W ;
  cin >> N >> W;
  

  cout << abs((N-2)*(W-2)) << endl;
  

  return 0;
}

Measured memory_bytes: 3640
import java.util.Scanner;

class Main {
  public static void main(String args[]) {
	  	Scanner scanner = new Scanner(System.in);
	  	boolean J = true;
	  	int a = 0;
	  	
	  	while(J) {
	  		
		  	int  x = scanner.nextInt();			//入力
		  	String s = scanner.next();
		  	int  y = scanner.nextInt();
	  		
		  	switch(s){
		  	case "+":
		  		System.out.println(x + y);
		  		break;
		  	case "-":
		  		System.out.println(x - y);
		  		break;
		  	case "*":
		  		System.out.println(x * y);
		  		break;
		  	case "/":
		  		System.out.println(x / y);
		  		break;
		  	case "?":
		  		a = 1;
			  	break;
			default:
			  	break;
		  	}

		  	if(a == 1)
		  		break;
		  	
  		}
        scanner.close();
  }
}


Measured memory_bytes: 26220
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0;i < n;i++)
#define REP(i,n,k) for(int i = n;i < k;i++)
#define P(p) cout << (p) << endl;
#define sP(p) cout << setprecision(15) << fixed << p << endl;
#define vi vector<int>
#define printv(v) for(int i = 0;i < v.size();i++)P(v[i]);
#define printt(a,b) cout << a << " " << b << endl; 
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
 
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
int dx[] = { 1, -1 , 0 , 0};
int dy[] = { 0,  0,  1, -1};
int MOD = 1e9 + 7;
 
void solve() {
    int a,b;
    cin >> a >> b;
    if(b%a == 0){
        P(a+b);
    }else{
        P(b-a);
    }
}
 
int main() {
  solve();
  return 0;
}

Measured memory_bytes: 256
#include<cmath>
#include<iostream>
#include<cstdio>
using namespace std;
int main(){
    double x1,x2,y1,y2,x,y;
    cin >> x1 >> y1 >> x2 >> y2;
    x = x1 - x2;
    y = y1 - y2;
    
    printf("%f\n",sqrt(pow(x,2)+pow(y,2)));
    return 0;
}


Measured memory_bytes: 3188
import sys

N = int(input())
mylist=[]

for i in range(N):
  s = input().split()
  mylist += [[int(s[0]),int(s[1])]]

mylsit = sorted(mylist, key=lambda x:x[1])

mysum = 0
for i in mylsit:
  mysum += i[0]
  if mysum <= i[1]:
    continue
  else:
    print('No')
    sys.exit()
print('Yes')

  

Measured memory_bytes: 39632
H, W = map(int, input().split())
lastcol = []
anslist = []
for y in range(H) :
    A = list(map(int, input().split()))
    for x, a in enumerate(A) :
        if x == W-1 :
            lastcol.append(a)
        elif a%2 :
            anslist.append((y+1, x+1, y+1, x+2))
            A[x+1] += 1
for y, a in enumerate(lastcol) :
    if y == H-1 :
        pass
    elif a%2 :
        anslist.append((y+1, W, y+2, W))
        lastcol[y+1] += 1

print(len(anslist))
for ans in anslist :
    print(*ans)

Measured memory_bytes: 24228
#include <iostream>
#include <map>
#include <set>
#include <cmath>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <string>
#include <vector>
#include <iomanip>
#include <sstream>
#include <utility>
#include <iterator>
#include <algorithm>
#include <functional>
#define rep(i, n) for(int i = 0;i < n;i++)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define pq priority_queue<int,vector<int>,greater<int>>
#define ll long long
//#define int long long

using namespace std;

typedef pair<int, int> pi;
int n, m, a, b, c[101];
string s;
int main() {
	cin >> n >> m;
	rep(i, m) {
		cin >> a >> b;
		c[a - 1]++;
		c[b - 1]++;
	}
	rep(i, n) {
		cout << c[i] << endl;
	}
	return 0;
}

Measured memory_bytes: 384
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>
#include<stack>
#include<queue>
#include<vector>
#include<algorithm>
#include<string>
#include<iostream>
#include<set>
#include<map>
#include<bitset>

using namespace std;
typedef long long ll;
#define i_7 1000000007
#define i_5 1000000005

ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    else return c+i_7;
}
typedef pair<int,int> i_i;
typedef pair<ll,ll> l_l;
#define inf 100000000/*10^8*/
#define rep(i,l,r) for(int i=l;i<=r;i++)
const double EPS=1E-8;

////////////////////////////////////////


int main() {
    int n;cin>>n;
    ll a[5];memset(a,0,sizeof(a));
    char mar[6]="MARCH";
    rep(i,0,n-1){
        char s[15];cin>>s;
        rep(j,0,4){
            if(s[0]==mar[j])a[j]++;
        }
    }
    ll ans=0;
    rep(i,0,4){
        rep(j,i+1,4){
            rep(k,j+1,4){
                ans+=a[i]*a[j]*a[k];
            }
        }
    }
    
    cout<<ans;
    return 0;
}


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

struct JOB{
	int day;
	int reward;
	
	friend bool operator<(const JOB a,const JOB b) {
		if(a.reward!=b.reward)
			return a.reward<b.reward;
		return 0;
	}
};

bool cmp(JOB a,JOB b) {
	return a.day>b.day;
} 

int main(int argc,char **argv) {
	int n,m;
	cin>>n>>m;
	JOB job[n];
	
	int a,b;
	for(int i=0;i<n;i++) {
		scanf("%d%d",&a,&b);
		job[i].day=m-a;
		job[i].reward=b;
	}
	
	sort(job,job+n,cmp);
	
	priority_queue<JOB> q;
	int ans=0;
	int now=0;
	for(int i=m-1;i>=0;i--) {
		while(now<n && job[now].day>=i)
			q.push(job[now++]);
		if(!q.empty()) {
			ans+=q.top().reward;
			q.pop();
		}
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 2168
#include <bits/stdc++.h>
#include <iostream>
using namespace std;
int main(){
  int x,y,T;
  cin >> x >> y >> T;
  int a = max(x,y);
  int b = min(x,y);
  while(b > 0){
  	a %= b;
  	int c = a;
  	a = b;
  	b = c;
  }
  cout << x * y / a / a * T << endl;
}



Measured memory_bytes: 3096
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>   
#include<limits.h>
using namespace std;
#define i64  long long
#define lint long long

#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807

bool prime_check(int A)
{
  if( A < 2) return 0;
  for (int i = 2; i <= sqrt(A); i++)
  {
    if(A%i == 0)return 0;
  }
  return 1;
}
void solve()
{
  int N;
  cin>>N;
  vector<int> vec(N,0);
  for (int i = 0; i < N; i++)
  {
    cin>>vec[i];
  }
  int count = 0;

  for (int i = 0; i < N; i++)
  {
    count += int(prime_check(vec[i]));
  }

  cout<<count<<endl;
  
  
  return;
}

int main(int argc, const char *argv[])
{

  solve();

  return 0;
}



Measured memory_bytes: 3096
let
    n::Int = parse(Int, readline())
    x::Vector{Int} = map(x -> parse(Int, x), split(readline()))
    l::Int = parse(Int, readline())
    q::Int = parse(Int, readline())
    const lg = 20
    F = Array(Int, lg, n)
    B = Array(Int, lg, n)
    for i = 1:n
        F[1,i] = searchsortedlast(x, x[i]+l)
        B[1,i] = searchsortedfirst(x, x[i]-l)
    end

    for fe = 2:lg
        for i = 1:n
            F[fe,i] = F[fe-1,F[fe-1,i]]
            B[fe,i] = B[fe-1,B[fe-1,i]]
        end
    end

    for i = 1:q
        a::Int, b::Int = map(x -> parse(Int, x), split(readline()))
        ans = 1
        if a < b
            for fe = lg:-1:1
                if F[fe,a] < b
                    a = F[fe,a]
                    ans += 2^(fe-1)
                end
            end
        else
            for fe = lg:-1:1
                if B[fe,a] > b
                    a = B[fe,a]
                    ans += 2^(fe-1)
                end
            end
        end
        println(ans)
    end
end


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

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

  queue<long long> que;
  for(int i = 1; i <= 9; i++)
    que.push(i);

  int cnt = 0;
  long long num;
  while(cnt < k){
    num = que.front();
    que.pop();
    cnt++;

    if(num % 10 != 0)  que.push(num * 10 + num % 10 - 1);
    que.push(num * 10 + num % 10);
    if(num % 10 != 9)  que.push(num * 10 + num % 10 + 1);

  }

  cout << num << endl;
  
}


Measured memory_bytes: 1792
vert = [False] * 8
hori = [False] * 8
topright = [False] * (8 * 2 - 1)
topleft = [False] * (8 * 2 - 1)
queens = []
skip_row = []


def put_queen(x, y):
    vert[x] = True
    hori[y] = True
    topright[x + y] = True
    topleft[7 + (x - y)] = True
    queens.append((x, y))


def elim_queen(x, y):
    vert[x] = False
    hori[y] = False
    topright[x + y] = False
    topleft[7 + (x - y)] = False
    queens.remove((x, y))


def is_blank(x, y):
    if not vert[x] and not hori[y] and not topright[x+y] and not topleft[7+(x-y)]:
        return True


def search_blank_in_row(y):
    blanks = []
    for x in range(8):
        if is_blank(x, y):
            blanks.append(x)
    return blanks


def put_queen_in_row(y):
    #print("put_queen_row",y, queens)
    if y == 8:
        return True     # 8 Queens have already been existed; reached the solution.
    if y in skip_row:
        return put_queen_in_row(y + 1)   # skip rows where a queen already exists as the precondition

    for x in search_blank_in_row(y):
        put_queen(x, y)
        if put_queen_in_row(y + 1):
            return True
        else:
            elim_queen(x, y)    # can't put next queen; eliminate it
    return False    # all candidate blanks are failed


def main():
    # prepare
    n = int(input())
    for i in range(n):
        x, y = map(int, input().split())
        put_queen(x, y)
        skip_row.append(y)

    # 8 queen main
    put_queen_in_row(0)

    # draw queens
    board = [list('........') for x in range(8)]
    for q_x, q_y in queens:
        board[q_x][q_y] = 'Q'
    [print(''.join(x)) for x in board]
    return


main()


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

#define repeat(i, n) for (auto i = decltype(n)(); (i) < (n); (i)++)

const int64_t mod = 1e9 + 7;

string toBinary(int64_t n) {
    if (n < 2) return to_string(n);
    else return toBinary(n / 2) + to_string(n % 2);
}

int64_t dp[100][2][2];

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

    int64_t n;
    cin >> n;

    string bin = toBinary(n);

    dp[0][0][0] = 1;

    repeat (i, bin.size()) {
        for (int less : {0, 1}) {
            for (int carry : {0, 1}) {
                for (int x : {0, 1}) {
                    for (int ncarry : {0, 1}) {
                        if (carry == 1 and x == 1 and ncarry == 0) continue;
                        if (carry == 0 and x == 1 and ncarry == 1) continue;

                        int d = ncarry ^ x;
                        if (!less and d > bin[i] - '0') continue;
                        (dp[i + 1][less | d < bin[i] - '0'][ncarry] += dp[i][less][carry]) %= mod;
                    }
                }
            }
        }
    }

    int64_t ans = (dp[bin.size()][0][0] + dp[bin.size()][1][0]) % mod;
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
using namespace std;
int main()
{
	int n;
	int a[51];
	int b[51];
	int c[51];
	long long int ans = 0;
	cin >> n;
	for (int i=1;i<=n;i++)
	{
		cin >> a[i];
	}
	for (int i=1;i<=n;i++)
	{
		cin >> b[i];
	}
	for (int i=1;i<=n-1;i++)
	{
		cin >> c[i];
	}
	for (int i=1;i<=n;i++)
	{
		ans += b[a[i]];
		if(a[i+1]-a[i]==1)
		{
			ans += c[a[i]];
		}
	}
	cout << ans;
	
	return 0;
}

Measured memory_bytes: 256
from collections import Counter

if __name__ == "__main__":
    n = int(input())
    v = list(map(int, input().split()))
    even = v[0::2]
    odd = v[1::2]

    even_num = Counter(even).most_common(2)
    odd_num = Counter(odd).most_common(2)
    even_num.append((0, 0))
    odd_num.append((0, 0))

    if even_num[0][0] != odd_num[0][0]:
        print(n-even_num[0][1]-odd_num[0][1])
    else:
        print(min(n-even_num[1][1]-odd_num[0][1],
                  n - even_num[0][1]-odd_num[1][1]))


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

int main(){
    string S,T;
    cin>>S>>T; 
    ll c,l=0;
    for(ll i=0;i<S.length()-T.length()+1;++i){
        c=0;
        for(ll j=0;j<T.length();++j){
            //cout<<S[i+j]<<","<<T[j]<<" ";
            if(S[i+j]==T[j]){
                c++;
            }
        }
        cout<<endl;
        l=max(c,l);
    }
    cout<<T.length()-l;
}

Measured memory_bytes: 3628
#include <stdio.h>
void rec(int);
void print();
int gyou[8],retsu[8],leftdown[15],rightdown[15],array[8][8];
int main(){
  int i,j,num,gyo,ret;
  for(i=0;i<8;i++){
    gyou[i]=0;
    retsu[i]=0;
  }
  for(i=0;i<15;i++){
    leftdown[i]=0;
    rightdown[i]=0;
  }
  for(i=0;i<8;i++){
    for(j=0;j<8;j++){
      array[i][j]=0;
    }
  }
  scanf("%d",&num);
  for(i=0;i<num;i++){
    scanf("%d%d",&gyo,&ret); 
    array[gyo][ret]=1;
    
  }
  rec(0);
  
  return 0;
}

void rec(int sum){
  int i;
 
  if(sum==8){
    print();
    return;
  }
  for(i=0;i<8;i++){
    if(retsu[i]==1 || leftdown[sum+i]==1 || rightdown[sum-i+7]==1) continue;
    gyou[sum]=i;
    retsu[i]=1;
    leftdown[sum+i]=1;
    rightdown[sum-i+7]=1;
    
    rec(sum+1);
    gyou[sum]=0;
    retsu[i]=0;
    leftdown[sum+i]=0;
    rightdown[sum-i+7]=0;
  }
  
}
    
void print(){   /*output*/
  int i,j;
  for(i=0;i<8;i++){
    for(j=0;j<8;j++){
      if(array[i][j]==1){
	if(gyou[i]!=j) return;
      }
    }
  }
  
  for(i=0;i<8;i++){
    for(j=0;j<8;j++){
      if(gyou[i]==j) printf("Q");
      else printf(".");
    }
    printf("\n");
  }
}



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

using namespace std;

int main() {
  int n, k;
  cin >> n >> k;
  vector<bool> d(10);
  for (int i = 0; i < k; i++) {
    int foo;
    cin >> foo;
    d[foo] = true;
  }

  auto check = [&](int i) {
    while (i) {
      if (d[i % 10]) return false;
      i /= 10;
    }
    return true;
  };

  while (true) {
    if (check(n)) {
      cout << n << '\n';
      break;
    }
    n++;
  }
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<queue>
#include<algorithm>
using namespace std;
char s[100005];
int ma[205];
int main()
{
	scanf("%s",s);
	int len=strlen(s);
	ma['p']=1,ma['q']=4,ma['b']=2,ma['d']=3;
	for(int i=0;i<len;i++)
	{
		if(ma[s[i]]+ma[s[len-i-1]]!=5)
		{
			printf("No");
			return 0;
		}
	}
	printf("Yes");
}

Measured memory_bytes: 384
/// In The Name Of God

#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,sse3,sse4,popcnt,abm,mmx")

#include <bits/stdc++.h>

#define f first
#define s second

#define pb push_back
#define pp pop_back
#define mp make_pair

#define sz(x) (int)x.size()
#define sqr(x) ((x) * 1ll * (x))
#define all(x) x.begin(), x.end()

#define Kazakhstan ios_base :: sync_with_stdio(0), cin.tie(0), cout.tie(0);

#define nl '\n'
#define ioi exit(0);

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

const int N = (int)2000 + 7;
const int inf = (int)1e9 + 7;
const int mod = (int)1e9 + 7;
const ll linf = (ll)1e18 + 7;

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

using namespace std;

int n;
int a[3][N], dp[3][N];
int main() {
	#ifdef IOI2018
		freopen ("in.txt", "r", stdin);
	#endif
	Kazakhstan
	cin >> n;
	for (int i = 1; i <= 2; i++) {
		for (int j = 1; j <= n; j++) {
			cin >> a[i][j];
		}
	}
	for (int i = 1; i <= 2; i++) {
		for (int j = 1; j <= n; j++) {
			dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]);
			dp[i][j] += a[i][j];
		}
	}
	cout << dp[2][n];
	ioi
}


Measured memory_bytes: 256
/* [Template].cpp 
Example code to use when starting new code. This particular problem was problem 
977A_Wrong_Subtraction from CodeForces

Compile: g++  -o B.exe B.cpp 
Execute: ./B
*/ 

#include <cstdio>
#include <iostream>
#include <cmath> 
#include <limits> 
#include <iomanip>
#include <cstring> 
#include <bits/stdc++.h>
#include <string>  
using namespace std;

int main() { 	
	int n, new_side, result = 0; 
	vector<int> sides; 
	bool check_if_entered; 
	
	cin >> n; 
	for(int i = 0; i < n; i++) {
		cin >> new_side; 
		sides.push_back(new_side); 
	}
	
	for(int i = 0; i < n; i++) {
		for(int j = 0; j < i; j++) {
			for(int k = 0; k < j; k++) {
				if(sides[i] + sides[j] > sides[k] && 
					sides[i] + sides[k] > sides[j] && 
					sides[j] + sides[k] > sides[i] && 
					sides[i] != sides[j] && 
					sides[i] != sides[k] && 
					sides[j] != sides[k]) {
						result++; 
					}
			}
		}
	}
	
	cout << result << endl; 
	
	return 0; 
} 


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

int main(){

    int h, w; cin >> h >> w;
    
    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            string snuke; cin >> snuke;
            if(snuke == "snuke"){
                cout << (char)(j + 'A') << i + 1 << endl;
            }
        }
    }

    
    return 0;
}

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

int main() {
	ios_base::sync_with_stdio( false );

	int a, b, c;
	cin >> a >> b >> c;

	int result = 0;
	result += a != b;
	result += a != c;
	result += b != c;

	cout << max( result, 1 ) << endl;
}


Measured memory_bytes: 256
import sys


def get():
    return list(map(int, input().split()))


# 未完成
a = get()
b = []
for i in range(a[1]):
    array = get()
    b.append(array)
count = 0
flag = False

while (not flag and count < 1000):
    keta = 1
    ans = [int(count / 100) % 10, int(count / 10) % 10, count % 10]
    if sum(ans) != 0 and ans[0] == 0 and ans[1] != 0:
        keta = 2
    elif sum(ans) != 0 and ans[0] != 0:
        keta = 3
    if a[0] != keta:
        count += 1
        continue
    if (a[1] == 0):
        flag = True

    for i in range(len(b)):
        if keta == 3:
            if ans[b[i][0]-1] == b[i][1]:
                flag = True
            else:
                flag = False
                break
        if keta == 2:
            if b[i][0] < 3 and ans[b[i][0]] == b[i][1]:
                flag = True
            else:
                flag = False
                break
        if keta == 1:
            if b[i][0] < 2 and ans[b[i][0] + 1] == b[i][1]:
                flag = True
            else:
                flag = False
                break
    count += 1

if flag:
    print(count - 1)
else:
    print(-1)


Measured memory_bytes: 38768
local MOD=1000000007
local N=io.read"*n"
local K=io.read"*n"
 
local r=0
for i=K,N+1 do
local min=i*(i-1)/2
local max=(N-i+1+N)*i/2
r=(r+max-min+1)%MOD
end
print(r)

Measured memory_bytes: 2768
#include <bits/stdc++.h>
#define int long long
using namespace std;

int f(int n) {
  int ans = 0;
  for(int i = 1; i * i < n; ++i) {
    for(int j = 1; j * j < n; ++j) {
      if(i*i + j*j >= n) break;
      int left = n - i*i - j*j - i*j;

      int b = i+j;
      int c = -left;
      long double sd = sqrtl(b*b - 4*c);
      long double ans1 = (-b + sd) / 2;
      long double ans2 = (-b - sd) / 2;
      int f1 = round(ans1);
      int f2 = round(ans2);
      if(f1 >= 1 && f1 * f1 + (i + j) * f1 == left) ans += 1;
      if(f2 != f1 && f2 >= 1 && f2 * f2 + (i + j) * f2 == left) ans += 1;
    }
  }
  return ans;
}


int32_t main() {
  ios::sync_with_stdio(0); cin.tie(0);
  int n;
  cin >> n;
  for(int i = 1; i <= n; ++i) {
    cout << f(i) << '\n';
  }
}

Measured memory_bytes: 3664
n = int(input())
xy = [list(map(int, input().split())) for _ in range(n)]
import math

ans = 0
for a in xy:
  t = 0
  for b in xy:
    if a == b:
      continue
    t += math.sqrt((b[1] - a[1])**2 + (b[0] - a[0]) **2)
  ans += t  
print(ans/n)

Measured memory_bytes: 3060
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
using namespace std;
const int maxn = 200005;
char s[maxn];
int main()
{
    int i,len,start,e;
    scanf("%s",s);
    len = strlen(s);
    for(i = 0;s[i] != '\0';i++)
    {
        if(s[i] == 'A')
        {
            start = i;
            break;
        }
    }
    for(i = len-1;i >= 0;i--)
    {
        if(s[i] == 'Z')
        {
            e = i;
            break;
        }
    }
    printf("%d\n",e-start+1);
    return 0;
}


Measured memory_bytes: 384
import java.util.Scanner;

class Main{
	public static void main(String[] args) {
		Scanner stdIn=new Scanner(System.in);
		int n=stdIn.nextInt(),s=0,t=n;
		do {
			s+=t%10;
			t/=10;
		}while(t!=0);
		System.out.print(n%s==0?"Yes":"No");
	}
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pi;
typedef complex <double> cp;
#define debug(a) cout<<#a<<":"<<a<<endl;
#define fr freopen("in.txt","r",stdin);
#define Fill(x,a) memset(x,a,sizeof(x))
#define cpy(a,b) memcpy(a,b,sizeof(a))
const double PI = acos(-1);
const int INF=0x3f3f3f3f;
const int N=1e6+7;
const int mod=998244353;
int maxn,minn;
int T,n,m,q,k;
struct aaa{
	int l,r;
}arr[N];

struct aa{
	int l,r,v;
	int lazy;
}ans[N];
void build(ll p,ll l,ll r){
    ll mid;
    ans[p].l=l;
    ans[p].r=r;
    ans[p].lazy=0;
    if(l==r){
        ans[p].v=0;
        return ;
    }
    mid=(l+r)>>1;
    build(p<<1,l,mid);
    build(p<<1|1,mid+1,r);
    ans[p].v=ans[p<<1].v+ans[p<<1|1].v;
    return ;
}
void push_down(ll p){
    if(!ans[p].lazy)
        return ;
    ans[p<<1].lazy=(ans[p<<1].lazy + ans[p].lazy)%mod;
    ans[p<<1|1].lazy= (ans[p<<1|1].lazy + ans[p].lazy)%mod;
    ans[p<<1].v= (ans[p<<1].v + ans[p].lazy)%mod;
    ans[p<<1|1].v= (ans[p<<1|1].v + ans[p].lazy)%mod;
    ans[p].lazy=0;
    return ;
}
void update(ll p,ll l,ll r,ll k){
    if(ans[p].r<l||ans[p].l>r)
        return ;
    if(l<=ans[p].l&&r>=ans[p].r){
        ans[p].lazy= (ans[p].lazy + k ) % mod;
        ans[p].v= (ans[p].v + k ) % mod;
        return ;
    }
    push_down(p);
    update(p<<1,l,r,k);
    update(p<<1|1,l,r,k);
    ans[p].v=(ans[p<<1].v+ans[p<<1|1].v)%mod;    
    return ;
}
ll query(ll p,ll l,ll r){
    if(ans[p].r<l||ans[p].l>r)
        return 0;
    if(l<=ans[p].l&&r>=ans[p].r)
        return ans[p].v;
    push_down(p);
    return (query(p<<1,l,r)+query(p<<1|1,l,r)) % mod;
}

int main(){
	cin >> n >> k;
	for(int i = 1;i <= k; i ++ ){
		scanf("%d%d",&arr[i].l,&arr[i].r);
	}
	build(1,1,n);
	int l,r;
	update(1,1,1,1);
	for(int i =1; i <= n; i ++ ){
		for(int j = 1; j <= k; j ++ ){
			l = i + arr[j].l ;
			r = i + arr[j].r ;
			if(l > n){
				continue;
			}
			r = min(n,r);
			update(1,l,r,query(1,i,i));
		}
	}
	cout << query(1,n,n) << endl;
	 


	return 0;
}



Measured memory_bytes: 11920
import * as fs from "fs";
 
let input = (fs.readFileSync("/dev/stdin", "utf8") as string).split("\n");
var token = input[0].split(" ").map(x => parseInt(x));
var cnt5 = 0;
var cnt7 = 0;
var result = "YES"
token.forEach(e => {
if(e == 7) { 
    cnt7++
}
}
)
if (cnt7 != 1) {
    result = "NO"
}

console.log(result);



Measured memory_bytes: 9420
#include <bits/stdc++.h>
#define fi first
#define se second
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define space putchar(' ')
#define enter putchar('\n')
#define eps 1e-10
#define MAXN 100005
//#define ivorysi
using namespace std;
typedef long long int64;
typedef unsigned int u32;
typedef double db;
template<class T>
void read(T &res) {
    res = 0;T f = 1;char c = getchar();
    while(c < '0' || c > '9') {
	if(c == '-') f = -1;
	c = getchar();
    }
    while(c >= '0' && c <= '9') {
	res = res * 10 +c - '0';
	c = getchar();
    }
    res *= f;
}
template<class T>
void out(T x) {
    if(x < 0) {x = -x;putchar('-');}
    if(x >= 10) {
	out(x / 10);
    }
    putchar('0' + x % 10);
}
int N,A;
int x[55];
int64 dp[2][55 * 55 * 2];
int V = 2505;
void Solve() {
    read(N);read(A);
    for(int i = 1 ; i <= N ; ++i) {
	read(x[i]);
	x[i] -= A;
    }
    int cur = 0;
    dp[cur][V] = 1;
    for(int i = 1 ; i <= N ; ++i) {
	memset(dp[cur ^ 1],0,sizeof(dp[cur ^ 1]));
	for(int j = 0 ; j <= 2 * V ; ++j) {
	    if(j + x[i] >= 0) {
		dp[cur ^ 1][j + x[i]] += dp[cur][j];
	    }
	    dp[cur ^ 1][j] += dp[cur][j];
	}
	cur ^= 1;
    }
    out(dp[cur][V] - 1);enter;
}

int main() {
#ifdef ivorysi
    freopen("f1.in","r",stdin);
#endif
    Solve();
    return 0;
}


Measured memory_bytes: 384