akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define int long long
#define ff first
#define ss second
#define len(x) (int)(x.size())
#define all(x) x.begin(), x.end()
using namespace std;
using ll = long long;
using ii = pair<int, int>;
#define MAXN 200010
int nxt[MAXN];
bitset<MAXN> visited;

int32_t main(){
	int n, k;
	scanf("%lld %lld", &n, &k);
	for(int i=1; i<=n; ++i)
		scanf("%lld", &nxt[i]);
	
	int ans = 1;
	visited[1] = true;
	while(k--){
		if(visited[nxt[ans]]){ ++k; break; }
		ans = nxt[ans];
		visited[ans] = true;
	}
	if(k<=0){
		printf("%lld\n", ans);
		return 0;
	}
	visited.reset();
	int tam = 1;
	int x = ans;
	visited[x] = true;
	while(not visited[nxt[x]]){
		x = nxt[x];
		visited[x] = true; 
		++tam;
	}
	k%=tam;
	while(k--)
		ans = nxt[ans];
	printf("%lld\n", ans);
}



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

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

ll ppow(ll a,ll b){
	a%=MOD;
	ll res=1;
	while(b){
		if(b&1)res=(res*a)%MOD;
		a=(a*a)%MOD;
		b>>=1;
	}
	return res;
}
class Fact{
	vector<ll>fact;
	vector<ll>inv;
public:
	Fact(){}
	Fact(int n){
		n=n*2+10;
		fact=inv=vector<ll>(n);
		fact[0]=inv[0]=1;
		for(int i=1;i<n;i++){
			fact[i]=(fact[i-1]*i)%MOD;
		}
		inv[n-1]=ppow(fact[n-1],MOD-2);
		for(int i=n-2;i>=0;i--){
			inv[i]=(inv[i+1]*(i+1))%MOD;
		}
	}
	ll get(int n){
		return fact[n];
	}
	ll get_inv(int n){
		return inv[n];
	}
	ll nPr(int n,int r){
		return fact[n]*inv[n-r]%MOD;
	}
	ll nCr(int n,int r){
		return nPr(n,r)*inv[r]%MOD;
	}
	ll nrP(int n,int r){
		return nPr(n+r,n);
	}
	ll nrC(int n,int r){
		return nCr(n+r,n);
	}
};

int main(){
	int n,m;cin>>n>>m;
	Fact fac(m);
	ll U=fac.nCr(m,n)*fac.get(n)%MOD;
	U*=U;
	U%=MOD;
	for(int i=1;i<=n;i++){
		ll d=fac.nCr(n,i)*fac.nCr(m,i)%MOD*fac.get(i)%MOD;
		ll e=fac.nCr(m-i,n-i)*fac.get(n-i)%MOD;
		(e*=e)%=MOD;
		(d*=e)%=MOD;
		if(i&1)(U+=MOD-d)%=MOD;
		else (U+=d)%=MOD;
	}
	cout<<U<<endl;
}

Measured memory_bytes: 18756
#include<iostream>
#include<cstdlib>
#include<string>
#include<vector>
#include<map>
#include<unordered_map>
#include<queue>
#include<algorithm>
#include<iomanip>
using namespace std;
using ll = long long int;
const int mod = 1e9 + 7;
#define rep(i, a, b) for(ll i = a;i < b; i++)

int main() {

	int s, w;
	cin >> s >> w;

	if (s > w) cout << "safe" << endl;
	else cout << "unsafe" << endl;

	return 0;
}


Measured memory_bytes: 3600
#include <iostream>
#include <algorithm>
#include <map>
#include <string>
#include <vector>
#include <cmath>
#include <random>
#include <climits>
#include <unordered_map>

#define mod 1000000007

using namespace std;
using ll = long long;

void solve(){
    int n;
    cin >> n;
    int c[n], s[n], f[n];

    for(int i = 0; i < n-1; i++){
        cin >> c[i] >> s[i] >> f[i];
    }
    for(int i = 0; i < n-1; i++){
        int time = s[i]+c[i];
        for(int j = i+1; j < n-1; j++){
            if(time < s[j]){
                time = s[j];
            }
            while(time % f[j] != 0){
                time++;
            }
            time += c[j];
        }
        cout << time << endl;
    }
    cout << 0 << endl;
}

int main(){
    solve();
    return 0;
}



Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int x = sc.nextInt();
        int a = sc.nextInt();

        if (x < a) {
            System.out.println("0");
        } else {
            System.out.println("10");
        }
    }
}


Measured memory_bytes: 21588
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i ,n) for(int i = 0 ; i < (n) ; i ++ )
#define all(x) (x).begin(),(x).end()
using ll = long long;
using namespace std;

int main() {
  string s;
  cin>>s;
  int a,b,c,d;
  a=s[0]-'0';
  b=s[1]-'0';
  c=s[2]-'0';
  d=s[3]-'0';
 // cout<<a<<b<<c<<d<<endl;
  vector<char> op(3);
  int sum;
  for(int bit=0;bit<(1<<3);bit++){
    sum=a;
    rep(i,3){
       
      if(bit&(1<<i)){       
        op[i]='+';
        sum+=(s[i+1]-'0');
      }
      else{
        op[i]='-';
        sum-=(s[i+1]-'0');
     
      }
         //cout<<sum<<endl;
    }
    
    if(sum==7){
      cout<<a<<op[0]<<b<<op[1]<<c<<op[2]<<d<<"=7"<<endl;
      break;
    }
  }
  
}



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

//template
#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 ALL(v) (v).begin(),(v).end()
typedef long long int ll; typedef pair<ll, ll> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<typename A,size_t N,typename T>void Fill(A(&array)[N],const T &val){fill((T*)array, (T*)(array+N), val);}
const int inf = 0x3fffffff; const ll INF = 0x3fffffffffffffff;
//template end



int main(){
    int a,b; scanf("%d%d",&a,&b);
    printf("%d\n",max(0,a-2*b));
    return 0;
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0;i < (n);i++)
#define all(v) v.begin(),v.end()
#define dec(n) cout << fixed << setprecision(n);
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using vl = vector<ll>;
using vvl = vector<vl>;

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

ll mod(ll a){
  return (a % 1000000007);
}

ll lcm(ll a,ll b){
  return (a*b)/gcd(a,b);
}


int main(){
  ll n,m; cin >> n >> m; vl high(n); vector<bool> ok(n,true);
  ll cnt = 0;
  
  rep(i,n) cin >> high[i];
  
  rep(i,m){
    ll a,b; cin >> a >> b; a--; b--;
    

    if(ok[a]||ok[b]){
      if(high[a] > high[b]){
        ok[b] = false;
      }
      else if(high[a] < high[b]){
        ok[a] = false;
      }
      else{
        ok[a] = false;
        ok[b] = false;
      }
    }
  
  }
  
  rep(i,n){
    if(ok[i]) cnt++;
  }
  
  cout << cnt << endl;
}

Measured memory_bytes: 4060
x,y = map(int,input().split())
n = 0
mod = 10**9+7
ans = 0
if not (x+y)%3:
  n = (x+y)//3
  x-=n
  y-=n
  if x>=0 and y>=0:
    ans = 1
    for i in range(x):
      ans = ans*(n-i)*pow(i+1,mod-2,mod)%mod
print(ans)

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

int main() {
  int n; cin >>n;
  vector<int>p(n);
  for(int i=0; i<n; ++i){
    cin >> p[i];
  }
  int count =0;
  
  for(int i=1; i<n-1; ++i){
    if((p[i-1]<p[i]) && (p[i]<p[i+1])){
      count++;
    }
    if((p[i-1]>p[i]) && (p[i]>p[i+1])){
      count++;
    }
  }
  
  
  cout << count << endl;
}
  
  

Measured memory_bytes: 256
#include <algorithm>
#include <iomanip>
#include <iostream>
#include <set>
#include <string>
#include <vector>
#define SORT(a) sort((a).begin(), (a).end())
#define RSORT(a) sort((a).rbegin(), (a).rend())
#define REP(i, n) for (int i = 0; i < n; i++)
#define RREP(i, n) for (int i = n; 0 <= i; i--)
#define FOR(i, start, end) for (int i = start; i < end; i++)
#define FORSTEP(i, start, end, step) for (int i = start; i < end; i += step)
#define ALL(a) a.begin(), a.end()
typedef long long ll;
const int INF = 100100100;
using namespace std;

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

    string s;
    cin >> s;

    bool f  = false;
    int red = 0, blue = 0;

    REP(i, s.size()) {
        if (s[i] == '0')
            red++;
        else {
            blue++;
        }
    }

    int ans = min(red, blue) * 2;
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 512
#include<stdio.h>
main()
{
	int K, X;
	scanf("%d", &K);
	scanf("%d", &X);
	if(K>=1 && K<=100 && X>=1 && X<=100000){
		if(K*500>=X){
			printf("Yes");
		}
		else{
			printf("No");
		}
	}
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define repk(i,k,n) for (ll i = k; i < (ll)(n); ++i)
#define MAX 500000001000000000
#define MOD 1000000007
typedef long long  ll;

using namespace std;

int ans, cnt;

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

	int N;
	cin >> N;

	N = N % 10;

	if (N == 3) {
		cout << "bon" << endl;
		return 0;
	}
	else if (N == 0 || N == 1 || N == 6 || N == 8) {
		cout << "pon" << endl;
		return 0;
	}
	else{
		cout << "hon" << endl;
		return 0;

	}

	return 0;
}

Measured memory_bytes: 3648
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#define df 0
int n,f[100];
int p[100][11];

int calc(int x);
int main(){
  scanf("%d",&n);
  int i,j;
  for(i=0;i<n;i++){
    int b=1,s=0;
    for(j=0;j<10;j++){
      int a;
      scanf("%d",&a);
      if(a)s+=b;
      b*=2;
    }
    f[i]=s;
  }
  for(i=0;i<n;i++){
    for(j=0;j<=10;j++){
      scanf("%d",&p[i][j]);
    }
  }
  if(df){
    printf("%d\n",f[0]);
  }
  
  int max=calc(1);
  for(i=2;i<(1<<10);i++){
    int temp=calc(i);
    if(max<temp)max=temp;
  }

  
  printf("%d",max);
  return 0;
}

int calc(int x){
  int i,s=0;
  for(i=0;i<n;i++){
    s+=p[i][__builtin_popcount(x&f[i])];
  }
  return s;
}


/// confirm df==0 ///


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define LL long long
using namespace std;
const int maxn=1000+9;
int main(){
	LL x[maxn],y[maxn],z[maxn],s[maxn];
	int n,m;cin>>n>>m;
	for(int i=1;i<=n;++i)cin>>x[i]>>y[i]>>z[i];
	LL ans=-1;
	for(int msk=0;msk<8;++msk){
		int cx=(msk>>0)&1;
		int cy=(msk>>1)&1;
		int cz=(msk>>2)&1;
		for(int i=1;i<=n;++i){
			s[i]=0;
			s[i]+=cx?x[i]:-x[i];
			s[i]+=cy?y[i]:-y[i];
			s[i]+=cz?z[i]:-z[i];
		}
		sort(s+1,s+1+n);
		LL _a=0;
		for(int i=n-m+1;i<=n;++i){
			_a+=s[i];
		}
		if(_a>ans)ans=_a;
	}
	printf("%lld",ans);
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<bitset>
#include<stack>
using namespace std;
#define MOD 1000000007
#define INF (1<<29)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long Int;
typedef pair<Int, Int> P;


vector<Int> edge[55000];
bitset<50000> bits[55000];
Int x[110000], y[110000];
int main(){
    Int n, m, t, t1 = -1, t2 = -1;
    cin >> n >> m >> t;
    for(int i = 0;i < m;i++){
        cin >> x[i] >> y[i];x[i]--,y[i]--;
        edge[x[i]].push_back(y[i]);
        edge[y[i]].push_back(x[i]);
    }
    if(t == 1){
        for(int i = 0;i < n;i++){
            bits[i].set(i);
        }
        for(int i = m-1;i >= 0;i--){
            bits[x[i]] |= bits[y[i]];
            bits[y[i]] |= bits[x[i]];
        }
        int t = -1;
        for(int i = 0;i < n;i++){
            bits[0] &= bits[i]; 
        }
        for(int i = 0;i < n;i++){
            if(bits[0][i]){
                t = i;
            }
        }
        if(t == -1){
            cout << -1 << endl;
            return 0;
        }
        vector<int> ok(n, 0);
        string ans(m, 'v');
        ok[t] = 1;
        for(int i = m-1;i >= 0;i--){
            if(ok[x[i]])ans[i] = '^';
            ok[x[i]] |= ok[y[i]];
            ok[y[i]] |= ok[x[i]];
        }
        cout << ans << endl;
        return 0;
    }

    if(n == 2){
        cout << -1 << endl;
        return 0;
    }
    vector<int> to(n, 0), cnt(n, 1);
    string ans(m, '^');
    for(int i = 0;i < n;i++){
        to[i]  = i;
    }
    for(int i = m-1;i >= 0;i--){
        if(cnt[to[x[i]]] > 1){
            ans[i] = 'v';
            cnt[to[y[i]]]++;
            cnt[to[x[i]]]--;
            to[x[i]] = to[y[i]];
        }
        else{
            cnt[to[x[i]]]++;
            cnt[to[y[i]]]--;
            to[y[i]] = to[x[i]];
        }     //   for(auto elem:to)cout << elem << " ";cout << endl;
    }
    cout << ans << endl;
        
    
    return 0;
}

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

int A[1000000], n;

int main(){
    cin >> n;
    for(int i = 0; i < n; i++){
        scanf("%d", &A[i]);
    }

    int q, k, sum = 0;
    cin >> q;
    for(int i = 0; i < q; i++){
        scanf("%d", &k);
        if(*lower_bound(A, A + n, k) == k) sum++;
    }
    cout << sum << endl;
}


Measured memory_bytes: 3524
#include<iostream>
#include<cstdio>
using namespace std;
typedef long long ll;
const int maxn = 200005;
int n;
ll ans;
int head[maxn], nxt[maxn << 1], tail[maxn << 1], ecnt;

void addedge(int u, int v) {
	nxt[++ecnt] = head[u];
	head[u] = ecnt;
	tail[ecnt] = v;
}

void dfs(int u, int p) {
	for (int e = head[u]; e; e = nxt[e]) {
		int v = tail[e];
		if (v != p) {
			int mn = min(v, u), mx = max(v, u);
			ans -= (ll)mn * (n - mx + 1);
			dfs(v, u);
		}
	}
}

int main() {
	scanf("%d", &n);
	for (int i = 1; i <= n - 1; i++) {
		int u, v; scanf("%d%d", &u, &v);
		addedge(u, v); addedge(v, u);
	}
	for (int i = 1; i <= n; i++) ans += (ll)i * (n - i + 1); // contribution for nodes
	dfs(1, 0); // contribution for edges
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 13316
// ███▓▓▓▓▓▓▓▓▓╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬▓▓▓╬╬╬╬╬╬▓█
// ███▓███████▓▓╬╬╬╬╬╬╬╬╬╬╬╬▓███▓▓▓▓█▓╬╬╬▓█
// ███████▓█████▓▓╬╬╬╬╬╬╬╬▓███▓╬╬╬╬╬╬╬▓╬╬▓█
// ████▓▓▓▓╬╬▓█████╬╬╬╬╬╬███▓╬╬╬╬╬╬╬╬╬╬╬╬╬█
// ███▓▓▓▓╬╬╬╬╬╬▓██╬╬╬╬╬╬▓▓╬╬╬╬╬╬╬╬╬╬╬╬╬╬▓█
// ████▓▓▓╬╬╬╬╬╬╬▓█▓╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬▓█
// ███▓█▓███████▓▓███▓╬╬╬╬╬╬▓███████▓╬╬╬╬▓█
// ████████████████▓█▓╬╬╬╬╬▓▓▓▓▓▓▓▓╬╬╬╬╬╬╬█
// ███▓▓▓▓▓▓▓╬╬▓▓▓▓▓█▓╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬▓█
// ████▓▓▓╬╬╬╬▓▓▓▓▓▓█▓╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬▓█
// ███▓█▓▓▓▓▓▓▓▓▓▓▓▓▓▓╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬▓█
// █████▓▓▓▓▓▓▓▓█▓▓▓█▓╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬▓█
// █████▓▓▓▓▓▓▓██▓▓▓█▓╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██
// █████▓▓▓▓▓████▓▓▓█▓╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██
// ████▓█▓▓▓▓██▓▓▓▓██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██
// ████▓▓███▓▓▓▓▓▓▓██▓╬╬╬╬╬╬╬╬╬╬╬╬█▓╬▓╬╬▓██
// █████▓███▓▓▓▓▓▓▓▓████▓▓╬╬╬╬╬╬╬█▓╬╬╬╬╬▓██
// █████▓▓█▓███▓▓▓████╬▓█▓▓╬╬╬▓▓█▓╬╬╬╬╬╬███
// ██████▓██▓███████▓╬╬╬▓▓╬▓▓██▓╬╬╬╬╬╬╬▓███
// ███████▓██▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓╬╬╬╬╬╬╬╬╬╬╬████
// ███████▓▓██▓▓▓▓▓╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬▓████
// ████████▓▓▓█████▓▓╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬▓█████
// █████████▓▓▓█▓▓▓▓▓███▓╬╬╬╬╬╬╬╬╬╬╬▓██████
// ██████████▓▓▓█▓▓▓╬▓██╬╬╬╬╬╬╬╬╬╬╬▓███████
// ███████████▓▓█▓▓▓▓███▓╬╬╬╬╬╬╬╬╬▓████████
// ██████████████▓▓▓███▓▓╬╬╬╬╬╬╬╬██████████
// ███████████████▓▓▓██▓▓╬╬╬╬╬╬▓███████████
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <numeric>
#include <cstring>
#include <ctime>
#include <cstdlib>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <cmath>
#include <bitset>
#include <cassert>
#include <queue>
#include <deque>
#include <cassert>
#define pb push_back
#define point pair <int, int>
#define x first
#define y second
#define files(FileName) read(FileName); write(FileName)
#define read(FileName) freopen((FileName + ".in").c_str(), "r", stdin)
#define write(FileName) freopen((FileName + ".out").c_str(), "w", stdout)
using namespace std;

template<typename T1, typename T2>inline void chkmin(T1 &x, T2 y) { if (x > y) x = y; }
template<typename T1, typename T2>inline void chkmax(T1 &x, T2 y) { if (x < y) x = y; }
typedef long long base;


const string FILENAME = "input";
const int MAXN = 3e5 + 10, p = 1e9 + 7, END = 3e5;

int n;
string s;
int nxt[MAXN][26];
int dp[MAXN];

int main(int argc, char const *argv[]) {
    ios::sync_with_stdio(false);
    //read(FILENAME);
    cin >> s;
    for (int i = 0; i < 26; ++i) {
        nxt[s.size()][i] = END;
    }
    for (int j = s.size(); j--;) {
        for (int i = 0; i < 26; ++i) {
            nxt[j][i] = nxt[j + 1][i];
        }
        nxt[j][s[j] - 'a'] = j;
    }
    for (int j = s.size() + 1; j--;) {
        dp[j] = 1e9;
        for (int i = 0; i < 26; ++i) {
            chkmin(dp[j], dp[nxt[j][i] + 1] + 1);
        }
    }
    //cout << dp[0] << endl;
    int L = 0;
    while (L < s.size()) {
        int c = 0;
        for (int j = 0; j < 26; ++j) {
            if (dp[nxt[L][j] + 1] < dp[nxt[L][c] + 1]) {
                c = j;
            }
        }
        cout << char(c + 'a');
        L = nxt[L][c] + 1; 
    }
    cout << endl;
}

Measured memory_bytes: 22676
#include <iostream>

using namespace std;

int main(){
  int n, k;
  
  bool p[101];
  for(int i = 1; i <= 100; i++) p[i] = false;
  
  cin >> n >> k;
  
  for(int i = 0; i < k; i++){
    int kosuu;
    cin >> kosuu;
    
    for(int j = 0; j < kosuu; j++){
      int person;
      cin >> person;
      p[person] = true;
    }
  }
  
  int answer = 0;
  for(int i = 1; i <= n; i++){
    if(!p[i]) answer++;
  }
  
  cout << answer << endl;
  return 0;
}

Measured memory_bytes: 3636
import fractions as f
a,b,c,d = map(int,input().split())

e = (c//f.gcd(c,d))*d


if a%c == 0:
    p = b//c - a//c +1
else:
    p = b//c - a//c
if a%d == 0:
    q = b//d - a//d +1
else:
    q = b//d - a//d
if a%e == 0:
    r = b//e - a//e +1
else:
    r = b//e - a//e  

print(b-a+1-p-q+r)

Measured memory_bytes: 5044
#include <bits/stdc++.h>
using namespace std;
#define repr(i, a, b) for (int i = a; i < b; i++)
#define rep(i, n) for (int i = 0; i < n; i++)
typedef long long ll;
#define mod 1000000007

ll gcd(ll x,ll y) {return y ? gcd(y,x%y) : x;} 
ll lcm(ll x,ll y) {return x/gcd(x,y)*y;}

int main(){
    string s;
    cin >> s;
    rep(i,s.size()){
        if(s[i]=='P') cout << 'P';
        else cout << 'D';
    }
    cout << endl;

    return 0;
}











Measured memory_bytes: 3752
#include <iostream>

using namespace std;
typedef long long  ll;
#define rep(i,s,n)for(ll i = s;i<n;i++)

int main() {
	int N; cin >> N;
	bool B[4];
	rep(i, 0, 4) {
		B[i] = false;
	}
	rep(i, 0, N) {
		char c;
		cin >> c;
		if (c == 'P') B[0] = true;
		if (c == 'W') B[1] = true;
		if (c == 'G') B[2] = true;
		if (c == 'Y') B[3] = true;
	}

	bool isFour = true;
	rep(j, 0, 4) {
		isFour &= B[j];
	}
	cout << ((isFour) ? "Four" : "Three") << endl;
	return 0;
}

Measured memory_bytes: 256
import java.io.IOException;
import java.io.InputStream;
import java.util.Arrays;
import java.util.NoSuchElementException;

public class Main {
	public static void main(String[] args) throws Exception {
		new Main().run();
	}

	public void run() throws Exception {
		Scanner sc = new Scanner();
		int N = sc.nextInt();
		int M = sc.nextInt();
		int X = sc.nextInt();
		int Y = sc.nextInt();
		int[] x = new int[N];
		int[] y = new int[M];
		for (int i = 0; i < N; ++i) {
			x[i] = sc.nextInt();
		}
		for (int i = 0; i < M; ++i) {
			y[i] = sc.nextInt();
		}
		Arrays.sort(x);
		Arrays.sort(y);
		for (int Z = X + 1; Z <= Y; ++Z) {
			if(x[x.length-1]<Z&&Z<=y[0]) {
				System.out.println("No War");
				return;
			}
		}
		System.out.println("War");
	}

	class Scanner {
		private final InputStream in = System.in;
		private final byte[] buffer = new byte[1024];
		private int ptr = 0;
		private int buflen = 0;

		private boolean hasNextByte() {
			if (ptr < buflen) {
				return true;
			} else {
				ptr = 0;
				try {
					buflen = in.read(buffer);
				} catch (IOException e) {
					e.printStackTrace();
				}
				if (buflen <= 0) {
					return false;
				}
			}
			return true;
		}

		private int readByte() {
			if (hasNextByte())
				return buffer[ptr++];
			else
				return -1;
		}

		private boolean isPrintableChar(int c) {
			return 33 <= c && c <= 126;
		}

		private void skipUnprintable() {
			while (hasNextByte() && !isPrintableChar(buffer[ptr]))
				ptr++;
		}

		public boolean hasNext() {
			skipUnprintable();
			return hasNextByte();
		}

		public String next() {
			if (!hasNext())
				throw new NoSuchElementException();
			StringBuilder sb = new StringBuilder();
			int b = readByte();
			while (isPrintableChar(b)) {
				sb.appendCodePoint(b);
				b = readByte();
			}
			return sb.toString();
		}

		public long nextLong() {
			if (!hasNext())
				throw new NoSuchElementException();
			long n = 0;
			boolean minus = false;
			int b = readByte();
			if (b == '-') {
				minus = true;
				b = readByte();
			}
			if (b < '0' || '9' < b) {
				throw new NumberFormatException();
			}
			while (true) {
				if ('0' <= b && b <= '9') {
					n *= 10;
					n += b - '0';
				} else if (b == -1 || !isPrintableChar(b)) {
					return minus ? -n : n;
				} else {
					throw new NumberFormatException();
				}
				b = readByte();
			}
		}

		int nextInt() {
			return (int) nextLong();
		}
	}

	void tr(Object... objects) {
		System.out.println(Arrays.deepToString(objects));
	}
}

Measured memory_bytes: 22228
/*
    Believe!
    @Author : tpriyanshu
*/
#include <bits/stdc++.h>
using namespace std;

typedef long long int lli;
typedef unsigned long int uli;
typedef pair<int,int> pi;
typedef pair<lli,lli> plli;
typedef vector<int> vi;
#define mod 1000000007
#define fastIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define point(n) fixed<<setprecision(n)
#define endl "\n"
#define mem(a,val) memset(a,val,sizeof(a))
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define w(x) lli x; cin>>x; while(x--)
#define forn(i, a, n) for (int i = a; i < int(n); ++i)
#define inf 1e18
#define N int(2*1e5+10)
#define all(v) v.begin(),v.end()
mt19937 rnd(time(NULL));

void out(vi& v) {
	for (lli i = 0; i < v.size(); i++) {
		cout << v[i]  << " ";
	}
	cout << endl;  
}
int main(){
    fastIO
    #ifndef ONLINE_JUDGE
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);
    #endif
    int n;
    cin>>n;
    set<string> v;
    forn(i,0,n) {
        string s;
        cin>>s;
        v.insert(s);
    }
    cout<<v.size();
    return 0;
}

Measured memory_bytes: 19204
#include <bits/stdc++.h>
#define MP make_pair
#define PB push_back
#define int long long
#define st first
#define nd second
#define rd third
#define FOR(i, a, b) for(int i =(a); i <=(b); ++i)
#define RE(i, n) FOR(i, 1, n)
#define FORD(i, a, b) for(int i = (a); i >= (b); --i)
#define REP(i, n) for(int i = 0;i <(n); ++i)
#define VAR(v, i) __typeof(i) v=(i)
#define FORE(i, c) for(VAR(i, (c).begin()); i != (c).end(); ++i)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
using namespace std;
template<typename TH> void _dbg(const char* sdbg, TH h) { cerr<<sdbg<<"="<<h<<"\n"; }
template<typename TH, typename... TA> void _dbg(const char* sdbg, TH h, TA... t) {
  while(*sdbg != ',')cerr<<*sdbg++; cerr<<"="<<h<<","; _dbg(sdbg+1, t...);
}
#ifdef LOCAL
#define debug(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#define debugv(x) {{cerr <<#x <<" = "; FORE(itt, (x)) cerr <<*itt <<", "; cerr <<"\n"; }}
#else
#define debug(...) (__VA_ARGS__)
#define debugv(x)
#define cerr if(0)cout
#endif
#define next ____next
#define prev ____prev
#define left ____left
#define hash ____hash
typedef long long ll;
typedef long double LD;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VLL;
typedef vector<pair<int, int> > VPII;
typedef vector<pair<ll, ll> > VPLL;

template<class C> void mini(C&a4, C b4){a4=min(a4, b4); }
template<class C> void maxi(C&a4, C b4){a4=max(a4, b4); }
template<class T1, class T2>
ostream& operator<< (ostream &out, pair<T1, T2> pair) { return out << "(" << pair.first << ", " << pair.second << ")";}
template<class A, class B, class C> struct Triple { A first; B second; C third;
  bool operator<(const Triple& t) const { if (st != t.st) return st < t.st; if (nd != t.nd) return nd < t.nd; return rd < t.rd; } };
template<class T> void ResizeVec(T&, vector<int>) {}
template<class T> void ResizeVec(vector<T>& vec, vector<int> sz) {
  vec.resize(sz[0]); sz.erase(sz.begin()); if (sz.empty()) { return; }
  for (T& v : vec) { ResizeVec(v, sz); }
}
typedef Triple<int, int, int> TIII;
template<class A, class B, class C>
ostream& operator<< (ostream &out, Triple<A, B, C> t) { return out << "(" << t.st << ", " << t.nd << ", " << t.rd << ")"; }
template<class T> ostream& operator<<(ostream& out, vector<T> vec) { out<<"("; for (auto& v: vec) out<<v<<", "; return out<<")"; }

const int kInf = 1e9;
set<VI> vis;
int Go(int a, int b, int c) {
  if (vis.count({a, b, c})) {
    return kInf;
  }
  vis.insert({a, b, c});
  if (a % 2 || b % 2 || c % 2) {
    return 0;
  }
  return 1 + Go((a + b) / 2, (a + c) / 2, (b + c) / 2);
}
int32_t main() {

  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(10);
  cerr << fixed << setprecision(10);
  cin.tie(0);
  //double beg_clock = 1.0 * clock() / CLOCKS_PER_SEC;
  
  int a, b, c;
  cin>>a>>b>>c;
  int res = Go(a, b, c);
  if (res > 1e8) {
    cout<<-1<<endl;
  } else {
    cout<<res<<endl;
  }
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;
using LLONG = long long;
const LLONG MOD = 1000000007;

int main()
{
    int N; cin >> N;
    vector<LLONG> as(N); for (auto &ai : as) cin >> ai;
    LLONG ans = 1;
    LLONG MAX = 1e18 + 1;
    sort(as.begin(), as.end());
    for (const auto ai : as)
    {
        if (ai == 0)
        {
            cout << 0 << endl;
            return 0;
        }
        if (MAX / ans < ai)
        {
            cout << -1 << endl;
            return 0;
        }
        ans *= ai;
    }
    if (ans > 1e18)
    {
        cout << -1 << endl;
    }
    else
    {
        cout << ans << endl;
    }
}

Measured memory_bytes: 4056
#include <iostream>
#include <vector>
#include <sstream>
using namespace std;

int main(){
    int m,n;
    string in;
    for(;;){
        cin>>m>>n;
        if(m==0&&n==0) break;
        vector<bool> islive(m,true);
        int nokori=m,at=0;
        for(int ix=1;ix<=n;ix++){
            cin>>in;
            for(;at<m;at++){
                if(islive[at]) break;
            }
            if(at==m){
                for(at=0;at<m;at++){
                    if(islive[at]) break;
                }
            }
            if(nokori>1){
                bool is=false;
                if(ix%3==0&&ix%5==0){
                    if(in!=string("FizzBuzz")) is=true;
                }else if(ix%3==0){
                    if(in!=string("Fizz")) is=true;
                }else if(ix%5==0){
                    if(in!=string("Buzz")) is=true;
                }else{
                    stringstream ss;
                    ss<<ix;
                    if(in!=ss.str()){
                        is=true;
                    }
                }
                if(is){
                    nokori--;
                    islive[at]=false;
                }
                at++;
            }
        }
        vector<int> out;
        for(int i=0;i<m;i++){
            if(islive[i]) out.push_back(i+1);
        }
        cout<<out[0];
        for(int i=1;i<out.size();i++){
            cout<<" "<<out[i];
        }
        cout<<endl;
    }
}

Measured memory_bytes: 952
import java.util.*;
  
public class Main {
    Scanner sc = new Scanner(System.in);
  
    public static void main(String[] args) {
        new Main(); 
    }
  
    public Main() {
        new aoj2011().doIt();
    }
    class aoj2011{
    	boolean map[][] = new boolean[51][31];
    	long dp[][] = new long[51][31];
    	int dp_table(int n){
    		int result = -1;
    		for(int i = 0;i < n;i++)dp[i][0] = 1L << i;
            for(int j = 1;j <= 30;j++){
                if(result != -1)break;
                for(int i = 0;i < n;i++){
                    if(!map[i][j]){
                        dp[i][j] = dp[i][j-1]; 
                        continue;
                    }
                    for(int k = 0;k < n;k++){
                        if(!map[k][j])continue;
                        dp[i][j]|=dp[k][j-1];
                        
                    }
                    if(dp[i][j]==(1L << n)-1){
                        result = j;
                        break;
                    }
                }
            }
            return result;
    	}
    	void set(int n){
    		for(int i = 0;i < n;i++){
    			for(int j = 0;j < 31;j++){
    				map[i][j] = false;
    				dp[i][j] = 0;
    			}
    		}
    	}
         void doIt(){
        	 while(true){
        		 int n = sc.nextInt();
        		 if(n == 0)break;
        		 set(n);
        		 for(int i = 0;i < n;i++){
        			 int num = sc.nextInt();
        			 for(int j = 0;j < num;j++){
        				 int pos = sc.nextInt();
        				 map[i][pos] = true;
        			 }
        		 }
                 System.out.println(dp_table(n));
//                 for(int i = 0;i < n;i++){
//                	 for(int j = 0;j < 30;j++){
//                		 System.out.print(dp[i][j]+" ");
//                	 }
//                	 System.out.println();
//                 }
             }
         }
     }
}

Measured memory_bytes: 100436
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        n: usize,
        mut l: [i64; n],
    }
    l.sort();
    let max = *l.last().unwrap();
    let others_sum = l.iter().rev().skip(1).sum::<i64>();
    let ans = if max < others_sum { "Yes" } else { "No" };
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <map>
#include <cstdio>
#include <string>
#include <cstdlib>
#include <cstring>
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef string str;
typedef std::pair<ll,ll> pl;
typedef std::map<string, ll> msl;
typedef std::map<ll, ll> mll;
typedef std::vector<ll> vl;
typedef std::vector<pl> vpl;
const long double EPS = 1e-9;

#define rep(i, n) for(ll (i) = 0; (i) < (n) ; (i)++ )
#define For(i, a, b) for(ll (i) = (a); (i) < (b) ; (i)++ )
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define tol(c) char((c)+0x20)
#define tou(c) char((c)-0x20)
#define pb push_back
#define mp make_pair
#define pr(a) cout << (a)
#define prl(a) cout << (a) << endl
#define prl2(a,b) cout << (a) << " " << (b) << endl
#define prs(a) cout << (a) << " "
#define yn(condition) if ((condition)) prl("Yes"); else prl("No");
#define YN(condition) if ((condition)) prl("YES"); else prl("NO");
#define rpr(i,n,ans) rep((i),(n)) prs((ans[(i)]))
#define cpr(i,n,ans) rep((i),(n)) prl((ans[(i)]))
#define in1(a) cin >> (a)
#define in2(a,b) cin >> (a) >> (b)
#define in3(a,b,c) cin >> (a) >> (b) >> (c)
#define in4(a,b,c,d) cin >> (a) >> (b) >> (c) >> (d)
#define rin1(i,n,a) rep((i),(n)) cin >> (a[(i)])
#define rin2(i,n,a,b) rep((i),(n)) cin >> (a[(i)]) >> (b[(i)])
#define rin3(i,n,a,b,c) rep((i),(n)) cin >> (a[(i)]) >> (b[(i)]) >> (c[(i)])
#define e1 first
#define e2 second
#define ctol(c) ll((c)) - ll('0')
#define ltos(n) to_string((n))
#define items(kv, v) for(auto &(kv): (v))
#define ndig(N, n) ctol(ll(ltos((N))[ll(ltos((N)).length()) - (n)]))
#define beto(a,b,c) (a) < (b) && (b) < (c)
#define betc(a,b,c) (a) <= (b) && (b) <= (c) 
#define rsort(a,n) sort(a,a+n,greater<>())

const ll mod = 1e9 + 7;
const ll INF = mod * mod;
const ll MAX_N = 100000;

int main(void){
    ll a, b;
    str s,t;

    in1(s);
    rep(i,s.length()) if(i%2==0) pr(s[i]);
    prl("");

    return 0;
}

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

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    int a[n];
    int b[n-1]; rep(i,n-1) cin >> b[i];

    a[0] = b[0];
    a[n-1] = b[n-2];
    for (int i = 1; i<(n-1); i++) {
        a[i] = min(b[i-1],b[i]);
    }
    ll ans = 0;
    rep(i,n) ans += a[i];
    cout << ans << "\n";
}

Measured memory_bytes: 3652
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <utility>
#include <tuple>
#include <algorithm>
#include <numeric>
#include <cstdio>
#include <cmath>
#define rep(i, n) for(int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

class UnionFind {
  vector<int> par, rank, potential;
public:
  UnionFind(int n) {
    par.resize(n, -1);
    rank.resize(n, 0);
    potential.resize(n, 0);
  }
  int root(int x) {
    if (par[x] < 0)
      return x;
    int r = root(par[x]);
    potential[x] += potential[par[x]];
    return par[x] = r;
  }
  int size(int x) {
    return -par[root(x)];
  }
  int weight(int x) {
    root(x);
    return potential[x];
  }
  bool isSame(int x, int y) {
    return root(x) == root(y);
  }
  bool unite(int x, int y, int w = 0) {
    w += weight(x);
    w -= weight(y);
    x = root(x);
    y = root(y);
    if(x == y) {
      return false;
    }
    if(rank[x] < rank[y]) {
      swap(x, y);
      w = -w;
    }
    if(rank[x] == rank[y])
      rank[x]++;
    par[x] += par[y];
    par[y] = x;
    potential[y] = w;
    return true;
  }
  int diff(int x, int y) {
    return weight(y) - weight(x);
  }
};

int main(){
  int N, M;
  cin >> N >> M;
  vector<int> X(M), Y(M), Z(M);
  rep(i, M) {
    cin >> X[i] >> Y[i] >> Z[i];
    X[i]--; Y[i]--;
  }
  UnionFind uf(N);
  rep(i, M)
    uf.unite(X[i], Y[i]);
  set<int> st;
  rep(i, N)
    st.insert(uf.root(i));
  cout << st.size() << endl;
  return 0;
}

Measured memory_bytes: 7296
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, c) for (int i = 0; i < (int)c; i++)
#define all(v) v.begin(), v.end()
using ll = long long;
using P = pair<int, int>;
const int inf = 1000000000; //10^9
const ll MOD = 1e9 + 7;
//加算代入演算子は+=！！！！！
//int 2^31 10^9まで
int main()
{
    int n;
    cin >> n;
    map<int, int> count_prime;
    for (int i = 2; i <= n; i++)
    {
        int temp = i;
        for (int j = 2; j <= temp; j++)
        {
            while (temp % j == 0)
            {
                temp /= j;
                count_prime[j]++;
            }
        }
    }
    ll ans = 1;
    for (auto p : count_prime)
    {
        ans = ((ans % MOD) * (p.second + 1) % MOD) % MOD;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iomanip>
#include<limits>
#include<thread>
#include<utility>
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#include<cmath>
#include<numeric>
#include<cassert>
#include<random>
#include<chrono>
#include<unordered_set>
#include<unordered_map>
#include<fstream>
#include<list>
#include<functional>
#include<bitset>
#include<complex>
#include<tuple>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef long double D;
typedef complex<D> P;
#define F first
#define S second
const ll E=1e18+7;
const ll MOD=1000000007;

template<typename T,typename U>istream & operator >> (istream &i,pair<T,U> &A){i>>A.F>>A.S; return i;}
template<typename T>istream & operator >> (istream &i,vector<T> &A){for(auto &I:A){i>>I;} return i;}
template<typename T,typename U>ostream & operator << (ostream &o,const pair<T,U> &A){o<<A.F<<" "<<A.S; return o;}
template<typename T>ostream & operator << (ostream &o,const vector<T> &A){ll i=A.size(); for(auto &I:A){o<<I<<(--i?" ":"");} return o;}
template<typename T>vector<T> & cset(vector<T> &A,T e=T()){for(auto &I:A){I=e;} return A;}

ll n,k;
vector<vector<ll>> edge;

ll cnt_child(ll w,ll p){
    ll ret=0;
    for(auto &I:edge[w]){
        if(I!=p){ret++;}
    }
    return ret;
}

ll dfs(ll w,ll p,ll num){
    ll ret=num;
    ll K=k-1;
    if(p!=-1){K--;}
    for(auto &I:edge[w]){
        if(I!=p){
            ret*=dfs(I,w,K);
            K--;
            ret%=MOD;
        }
    }
    return ret;
}



int main(){
    cin>>n>>k;
    edge.resize(n);
    for(int i=1;i<n;i++){
        ll a,b;
        cin>>a>>b;
        a--; b--;
        edge[a].push_back(b);
        edge[b].push_back(a);
    }
    ll ans=dfs(0,-1,k);
    ans%=MOD;
    if(ans<0){ans+=MOD;}
    cout<<ans<<endl;
    
    
    return 0;
}


Measured memory_bytes: 10368
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n,x;
  cin >> n >> x;
  int mini = 1000000;
  vector<int>m(n);
  int sum = 0;
  for(int i = 0;i < n;i++){
    cin >> m[i];
sum += m[i];
if(m[i] < mini){
mini = m[i]; }
  }
  int a = x-sum;
  int b = a/mini;
cout << n+b <<endl;
}





Measured memory_bytes: 256
import itertools
import math
N = int(input())
A =[0]*N
B =[0]*N
su =0
count=0
for i in range(N):
  A[i],B[i] =map(int, input().split())
for i in itertools.permutations(range(N)):
  count +=1
  for j in range(1,len(i)):
    su += math.sqrt((A[i[j]]-A[i[j-1]])**2+(B[i[j] ]-B[i[j-1]])**2)
print(su/count)    


Measured memory_bytes: 3064
;; -*- coding: utf-8 -*-
(eval-when (:compile-toplevel :load-toplevel :execute)
  (defparameter OPT
    #+swank '(optimize (speed 3) (safety 2))
    #-swank '(optimize (speed 3) (safety 0) (debug 0)))
  #+swank (progn (ql:quickload '(:cl-debug-print :fiveam))
                 (shadow :run)
                 (use-package :fiveam)))
#+swank (cl-syntax:use-syntax cl-debug-print:debug-print-syntax)

;; BEGIN_INSERTED_CONTENTS
(declaim (inline read-line-into))
(defun read-line-into (buffer-string &key (in *standard-input*) (terminate-char #\Space))
  "Receives ascii inputs and returns the string and the end position. Note that
the returned string will be reused.

This function calls READ-BYTE to read characters though it calls READ-CHAR
instead on SLIME because SLIME's IO is not bivalent."
  (declare (inline read-byte)) ; declaring (sb-kernel:ansi-stream in) will be faster
  (loop for c of-type base-char =
           #-swank (code-char (read-byte in nil #.(char-code #\Newline)))
           #+swank (read-char in nil #\Newline)
        for idx from 0
        until (char= c #\Newline)
        do (setf (char buffer-string idx) c)
        finally (when (< idx (length buffer-string))
                  (setf (char buffer-string idx) terminate-char))
                (return (values buffer-string idx))))

(defmacro dbg (&rest forms)
  #+swank
  (if (= (length forms) 1)
      `(format *error-output* "~A => ~A~%" ',(car forms) ,(car forms))
      `(format *error-output* "~A => ~A~%" ',forms `(,,@forms)))
  #-swank (declare (ignore forms)))

(defmacro define-int-types (&rest bits)
  `(progn
     ,@(mapcar (lambda (b) `(deftype ,(intern (format nil "UINT~A" b)) () '(unsigned-byte ,b))) bits)
     ,@(mapcar (lambda (b) `(deftype ,(intern (format nil "INT~A" b)) () '(signed-byte ,b))) bits)))
(define-int-types 2 4 7 8 15 16 31 32 62 63 64)

(declaim (inline println))
(defun println (obj &optional (stream *standard-output*))
  (let ((*read-default-float-format* 'double-float))
    (prog1 (princ obj stream) (terpri stream))))

(defconstant +mod+ 1000000007)

;; Body

(defun main ()
  (let* ((n (read))
         (a (- (read) 1))
         (b (- (read) 1))
         (c (- (read) 1))
         (d (- (read) 1))
         (s (make-string n :element-type 'base-char)))
    (read-line-into s)
    (labels ((reachable-p (start dest)
               (loop for i from start below dest
                     do (when (and (char= (char s i) #\#)
                                   (char= (char s (- i 1)) #\#))
                          (return-from reachable-p nil))
                     finally (return-from reachable-p t))))
      (if (and (reachable-p a c)
               (reachable-p b d))
          (if (< c d)
              (write-line "Yes")
              (loop for f from b to d
                    do (when (and (char= #\. (aref s f))
                                  (char= #\. (aref s (- f 1)))
                                  (char= #\. (aref s (+ f 1))))
                         (write-line "Yes")
                         (return-from main))
                    finally (write-line "No")))
          (write-line "No")))))

#-swank(main)


Measured memory_bytes: 29288
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define rep1(i,n) for(int i=1;i<=(int)n;i++)
#define sp(n) cout << fixed << setprecision(n)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
typedef long long ll;
using namespace std;
int main(void){
    ll n;cin>>n;
    map<ll,ll> mp;
    ll res=0;
    rep(i,n){
        ll a;cin>>a;
        mp[a]++;res+=a;
    }
    ll q;cin>>q;
    rep(i,q){
        ll b,c;cin>>b>>c;
        ll buf=mp[b];
        res+=((c-b)*buf);
        cout<<res<<endl;
        mp[b]=0;
        mp[c]+=buf;
    }
}

Measured memory_bytes: 9384
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <iostream>
using namespace std;
const int N = 1e5 + 5;
int ls[N], s[N], pos[N], num[N], n, a[N];
int sum[N * 4];
void add(int now, int l, int r, int pos) {
    sum[now]++;
    if(l == r) return;
    int mid = l + r >> 1;
    if(pos <= mid) add(now * 2, l, mid, pos);
    else add(now * 2 + 1, mid + 1, r, pos);
}
bool ask(int now, int l, int r, int L, int R) {
    if(l > R || L > r) return false;
    if(L <= l && r <= R) return (sum[now] != 0);
    int mid = l + r >> 1;
    return ask(now * 2, l, mid, L, R) | ask(now * 2 + 1, mid + 1, r, L, R);
}
bool ask(int pos) {
    while(pos) {
        if(sum[pos] != 0) return true;
        pos -= (pos & (-pos));
    }
    return false;
   //return ask(1, 1, n, 1, pos);
}
void add(int pos) {
   //add(1, 1, n, pos);
   while(pos <= n) {
        sum[pos]++;
        pos += (pos & (-pos));
    }
}
bool find(int x, int right) {
    int l = 1, r = n;
    for(int mid = l + r >> 1; l < r; mid = l + r >> 1) {
        if(ls[mid] < x) l = mid + 1;
        else r = mid;
    }
    while(ls[l] > x && l > 0) l--;
    if(l == 0) return false;
   // printf("ask = %d %d %d %d\n", l, ask(l), x, ls[l]);
    return ask(l);
    
}
bool check(int x) {
   // printf("test = %d\n", x);
    memset(sum, 0, sizeof(sum));
    for (int i = 1; i <= n; i++) {
        if(find(a[i] - x, i)) return true;
        add(num[i]);
        //printf("num = %d\n", num[i]);
        //rem[num[a[i]]] ++; 
    }    
    return false;
}
int main()
{
    int minn = 0, maxn = 0, m;
    scanf("%d%d", &n, &m);
    for (int i = 1; i <= n; i++) {
        scanf("%d", &a[i]);
        ls[i] = a[i];
        maxn = max(maxn, a[i]);
    }
    sort(ls + 1, ls + n + 1);
    for (int i = 1; i <= n; i++) {  
        num[i] = lower_bound(ls + 1, ls + n + 1, a[i]) - ls;
        pos[num[i]] = i;
        //cerr << num[i] << " "; 
        //
    }
    //cerr << "\n"; 
    //
    int l = minn, r = maxn;
    for (int mid = (l + r) >> 1; l < r; mid = (l + r) >>  1) {
    //printf("%d %d\n", l, r);
        if(check(mid)) l = mid + 1;
        else r = mid;
    }
    if(!check(l)) l--;
    memset(sum, 0, sizeof(sum));
    //printf("%d\n", l);
    int ans = 0;
    for (int i = 1; i <= n; i++) {
        if(find(a[i] - l, i)) ans++;
        add(num[i]);
    }
    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 3580
#include <iostream>
using namespace std;
 
int main() {
  int x, y;
  cin >> x >> y;
  int a[13] = {0, 1, 2, 1, 3, 1, 3, 1, 1, 3, 1, 3, 1};
  
  if (a[x] == a[y]) cout << "Yes";
  else cout << "No";
  return 0;
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		final int Amax = 1000001;
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] A = new int[N];
		for(int i=0; i<N; i++)
			A[i] = sc.nextInt();
		Arrays.sort(A);
		
		int[] cnt = new int[Amax];
		
		for (int x : A) {
			if(cnt[x] != 0) {
				cnt[x] =2;
				continue;
			}
			for(int i = x; i < Amax; i+= x ) {
				cnt[i] += 1;
			}			
		}
		int ans = 0;
		for(int x: A) {
			if(cnt[x] == 1)
				ans++;
		}
		System.out.println(ans);
		sc.close();
	}
}


Measured memory_bytes: 49988
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
using namespace std;
using Graph = vector<vector<int>>;
typedef long long ll;
typedef pair<int, int> P;
const int inf = 1 << 21;
const ll INF = 1LL << 60;
const ll mod = 1e9+7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};

int h, w, k;
char s[15][10005];

int main() {
    cin >> h >> w >> k;
    rep(i, h)rep(j, w) cin >> s[i][j];
    int ans = inf;

    // hを分解
    for(int bit=0; bit<1<<h-1; bit++){
        bool flag = true;
        vector<int> id(h);
        int g = 0;
        rep(i, h){
            id[i] = g;
            if (bit>>i & 1) g++;
        }
        g++;

        int cnts[15][10005];
        rep(i, g)rep(j, w) cnts[i][j] = 0;
        rep(i, h)rep(j, w) cnts[id[i]][j] += (s[i][j] - '0');

        int t_ans = g-1;
        vector<int> now(g);
        rep(j, w){
            bool ff = true;
            rep(i, g) now[i] += cnts[i][j];
            rep(i, g){
                if(now[i] > k){
                    ff = false;
                }
            }
            if (!ff){
                t_ans++;
                now = vector<int>(g);
                rep(i, g) now[i] = cnts[i][j];
                rep(i, g){
                    if(now[i] > k){
                        flag = false;
                    }
                }
                if (!flag){
                    t_ans = inf;
                    break;
                }
            }
            if (!flag) break;
        }
        chmin(ans, t_ans);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 384
/*
redcoder
01234567
abcdabc
0123456
*/

#include<bits/stdc++.h>
using namespace std;
int main()
{
	string s;
	cin>>s;
	int n = s.length();
	int ans=0;
        for(int i = 0; i < n/2;i++)
        {
           if(s[i]!=s[n-1-i])
           {
              ans+=1;
           }
        }
    cout << ans <<"\n";
}

Measured memory_bytes: 764
#include <cstdio>
#include <iostream>
#include <map>
#include <vector>
#include <algorithm>
 
using namespace std;
 
int gcd(int u, int v) {
int r;
while (0 != v) {
r = u % v; u = v; v = r;
}
return u;
}
 
map<pair<int,int>,int>x;
 
 
int main(void) {
 
	int N;
 
	scanf("%d",&N);
	
	int a,b,c;
 
	for(c=1;c<=3500;c++){
		if((4*c)-N>0){
		int div=gcd(N*c,(4*c)-N);
		x[make_pair(((4*c)-N)/div,(N*c)/div)]=c;
		}
	}
 
	for(a=1;a<=3500;a++){
		for(b=max(a,3*N/4);b<=3500;b++){
			int div=gcd(a+b,a*b);
			if(x[make_pair((a+b)/div,(a*b)/div)]>0){
				printf("%d %d %d\n",a,b,x[make_pair((a+b)/div,(a*b)/div)]);
				return 0;
			}
		}
	}
 
	return 0;
}

Measured memory_bytes: 164992