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

using namespace std;

#define S scanf
#define P printf
#define G getline
#define SZ size()
#define C clear()
#define B begin()
#define F front()
#define T top()
#define E end()
#define EM empty()
#define V vector
#define Q queue
#define DQ deque
#define PQ priority_queue
#define ST stack
#define FI first
#define SE second
#define PI acos(-1)
#define PS push
#define PP pop()
#define PSF push_front
#define PSB push_back
#define PPF pop_front()
#define PPB pop_back()
#define MP make_pair
#define LL long long int
#define ULL unsigned long long int
#define PII pair<int,int>
#define PSI pair<string,int>
#define PIS pair<int,string>
#define PLI pair<long long int,int>
#define PLL pair<long long int,long long int>
#define MII map<int,int>
#define MSI map<string,int>
#define MIS map<int,string>
#define MLI map<long long int,int>
#define FAST() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)





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






int main()
{
    FAST();

//    freopen("input.txt","r",stdin);
//    freopen("output.txt","w",stdout);

    LL n,k;
    cin >> n >> k;
    n%=k;
    cout << min(n,k-n);
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(){
    int x, y, a;
    scanf("%d %d", &x, &y);
    while(x != 0 || y != 0){
        if(x > y){
            a = x;
            x = y;
            y = a;
        }
        printf("%d %d\n", x, y);
        scanf("%d %d", &x, &y);
    }
}

Measured memory_bytes: 1748
#include<algorithm>
#include<iostream>
#include<string>
#include<cstdlib>
#include<cstring>
#include<cmath>
using namespace std;
int a[8][14],b[8][14];
int fn(int x,int y,int z){
  int ct=0;
  if(b[x][y]==-1){
    if(0){
    }else if(a[x][y]==z){
      b[x][y]=1;
      ct++;
      ct+=fn(x-1,y,z);
      ct+=fn(x+1,y,z);
      ct+=fn(x,y-1,z);
      ct+=fn(x,y+1,z);
    }else if(a[x][y]=='O'){
      b[x][y]=1;
    }
  }
  return ct;
}
int main(){
  int g,h,i,j,k,l,m;
  int n;
  cin>>n;
  for(i=0;i<n;i++){
    memset(a,-1,sizeof(a));
    for(j=1;j<13;j++){
      for(k=1;k<7;k++){
	char s;
	cin>>s;
	if(s!='.')
	  a[k][j]=s;
      }
    }
    h=1;    
    for(g=-1;h;g++){
      h=0;
      for(j=1;j<13;j++){
	for(k=1;k<7;k++){
	  if(a[k][j]!=-1&&a[k][j]!='O'){
	    memset(b,-1,sizeof(b));
	    if(fn(k,j,a[k][j])>3){
	      for(l=1;l<13;l++){
		for(m=1;m<7;m++){
		  if(b[m][l]==1)
		    a[m][l]=-1;
		}
	      }
	      h=1;
	    }
	  }
	}
      }
      for(j=1;j<7;j++){
	for(k=12;;){
	  for(;k>0&&a[j][k]!=-1;k--);
	  for(l=k;l>0&&a[j][l]==-1;l--);
	  if(l>0){
	    a[j][k]=a[j][l];
	    a[j][l]=-1;
	  }else
	    break;
	}
      }
    }
    cout<<g<<endl;;
  }
  return 0;
}

Measured memory_bytes: 0
#!/usr/bin/ruby
require'rational'
gets;x=gets.split.map(&:to_i).reduce{|s,e|s=s.gcd(e)}
m={}
1.step(Math.sqrt(x).to_i){|i|m[i]=m[x/i]=1 if x%i==0}
m.keys.sort.each{|e|p e}

Measured memory_bytes: 2440
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#define REP(i,a) for (int i = 0;i < (a);++i)
#define FOR(i,a,b) for (int i = (a);i < (b); ++i)
#define FORR(i,a,b) for (int i = (a);i >= (b); --i)
#define ALL(obj) (obj).begin,(obj).end()
#define SORT(list) sort(ALL((list)));
using namespace std;
using ll = long long;
int main(){
    string s;
    cin >> s;
    int hamming_distanceA=0,hamming_distanceB=0;
    REP(i,s.length()){
        if(i%2==s[i]-'0'){
            hamming_distanceA++;
        }
        else{
            hamming_distanceB++;
        }
    }
    cout << min(hamming_distanceA,hamming_distanceB)<< endl;
    return 0;
}

Measured memory_bytes: 512
#include<stdio.h>
#define MAX 500001

void heap(int);
int n, i, tree[MAX];

int main() {
  scanf("%d", &n);
  for(i = 1; i <= n; i++){
    scanf("%d",&tree[i]);
  }
  for(i = n/2; i > 0; i--) {
    heap(i);
  }
  for(i = 1; i <= n; i++){
    printf(" %d",tree[i]);
  }
  printf("\n");

  return 0;
}

void heap(int x){
  int largest, l, r, temp;
    l = 2*x;
    r = 2*x+1;
    if(l <= n && tree[l] > tree[x]) {
      largest = l;
    }else{
       largest = x;
    }
    if(r <= n && tree[r] > tree[largest]){
      largest = r;
    }
    if(largest != x){
        temp = tree[x];
        tree[x] = tree[largest];
        tree[largest] = temp;
        heap(largest);
    }
}



Measured memory_bytes: 3720
package main

import "fmt"

func main() {
	var N, M int
	fmt.Scanf("%d %d\n", &N, &M)
	var a, b int
	if N == 1 {
		a = 0
	} else if N == 2 {
		a = 1
	} else {
		a = 1
		for i := 0; i < N; i++ {
			if N-2 < (i + 1) {
				a = a * (i + 1)
			}
		}
		a = a / 2
	}
	if M == 1 {
		b = 0
	} else if M == 2 {
		b = 1
	} else {
		b = 1
		for i := 0; i < M; i++ {
			if M-2 < (i + 1) {
				b = b * (i + 1)
			}

		}
		b = b / 2
	}
	fmt.Println(a + b)
}


Measured memory_bytes: 512
n, m = map(int, input().split())
l = list(map(int, input().split()))

import fractions
from functools import reduce

def lcm_base(x, y):
  return (x * y) // fractions.gcd(x, y)

def lcm_list(numbers):
  return reduce(lcm_base, numbers, 1)

#print(lcm_list(l))

x = lcm_list(l)

for i in range(n):
  if (x//l[i])%2 == 0:
    print(0)
    exit()

ans = (m*2)//lcm_list(l)
if ans%2 == 1:
  print((ans+1)//2)
else:
  print(ans//2)

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

int main(){
	long long a,b,cnt=0;
	cin >> a >> b;
	for(int i=0;i<=a;i++){
		for(int j=b-i;j>=0;j--){
			if(j>a || b-i-j>a) continue;
			if(b-i-j>=0) cnt++;
		}
	}
	cout << cnt << endl;
	return 0;
}

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

const string s = "aeiou";

int main(){

	char c;
	scanf("%c", &c);

	int f = s.find(c);

	string ans = f != string::npos ? "vowel" : "consonant";

	cout << ans << '\n';

	return 0;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
	"strings"
)

var sc = bufio.NewReaderSize(os.Stdin, 1024*1024*1)

func main() {
	list := getStdinIntArr()

	min := math.MaxInt32
	for i := 0; i < 3; i++ {
		for j := 0; j < 3; j++ {
			if i == j {
				continue
			}
			if list[i]+list[j] < min {
				min = list[i] + list[j]
			}
		}
	}

	fmt.Printf("%d\n", min)
}

func getStdin() string {
	return readLine()
}
func getStdinArr() []string {
	str := getStdin()
	list := strings.Split(str, " ")
	return list
}
func getStdinInt() int {
	str := getStdin()
	rtn, _ := strconv.Atoi(str)
	return rtn
}
func getStdinIntArr() []int {
	str := getStdin()
	list := strings.Split(str, " ")
	rtn := make([]int, len(list))
	for idx, val := range list {
		rtn[idx], _ = strconv.Atoi(val)
	}
	return rtn
}

func getStdinIntArr64() []int64 {
	str := getStdin()
	list := strings.Split(str, " ")
	rtn := make([]int64, len(list))
	for idx, val := range list {
		rtn[idx], _ = strconv.ParseInt(val, 10, 64)
	}
	return rtn
}

func readLine() string {
	buf := make([]byte, 0, 0)
	for {
		l, p, e := sc.ReadLine()
		if e != nil {
			panic(e)
		}
		buf = append(buf, l...)
		if !p {
			break
		}
	}
	return string(buf)
}


Measured memory_bytes: 640
#include<iostream>
#include<vector>
#include<cstdio>
using namespace std;
const int MAXN=2000000;

vector<int> p(MAXN);

int main(){
  int n,k;cin>>n>>k;
	for(int i=0;i<n;i++){
      cin>>p[i];
    }
  double sum=0;
  for(int i=0;i<k;i++){
    sum+=(double)(p[i]+1)/2.0;
  }
  double ans=sum;
  double tmp=sum;
  for(int i=k;i<n;i++){
    tmp=tmp+(double)(p[i]+1)/2.0-(double)(p[i-k]+1)/2.0;
    if(tmp>ans) ans=tmp;
  }
  printf("%.10f\n",ans);
  return 0;
}

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

int main() {
    int N,R;
    cin >> R >> N;
    if(R>=10){
        cout << N;
    }else{
        cout << N+100*(10-R);
    }
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(void) {
  int a, b, c, d, beg, end;
  scanf("%d %d %d %d", &a, &b, &c, &d);
  if (a < c)
    beg = c;
  else
    beg = a;

  if (b < d)
    end = b;
  else
    end = d;

  if (end - beg <= 0)
    printf("0\n");
  else
    printf("%d\n", end - beg);
  return 0;
}

Measured memory_bytes: 384
#include "bits/stdc++.h"

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define bit(n) (1LL << (n))
#define sz(x) ((int)(x).size())
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define en '\n'
#define pb push_back
#define P pair<int, int>

typedef long long ll;
using namespace std;

ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { ll g = gcd(a, b); return a / g * b; }
const int dx[4] = { 1, 0, -1,  0 };
const int dy[4] = { 0, 1,  0, -1 };
const int INF = (int)1e9;
const ll  inf = (ll)1e18;
const int mod = 1000000007;

struct aaa {
	aaa() {
		cin.tie(0);
		ios::sync_with_stdio(0);
		cout << fixed << setprecision(20);
	};
}aaaaa;

int main() {
	int n, m;
	cin >> n >> m;

	map<int, int> mp;

	rep(i, n) {
		int k;
		cin >> k;
		rep(j, k) {
			int a;
			cin >> a;
			mp[a]++;
		}
	}

	int ans = 0;
	for (auto it : mp) {
		if (it.second == n) {
			ans++;
		}
	}

	cout << ans << endl;
}

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

int main(){
    int n, num;
    cin>>n;
    vector<int>v;
    long int sum=0, ls=0;
    for(int i=0;i<n;i++){
        cin>>num;
        v.push_back(num);
        
    }
    for(int i=0;i<n;i++){
        ls+=v[i];
        
    }
    int m, ind, x;
    cin>>m;
    for(int i=0;i<m;i++){
       sum=ls;
       cin>>ind;
       cin>>x;
       sum-=v[ind-1];
       sum+=x;
       cout<<sum<<endl;
    }
    return 0;
}

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

int main() {
    int n, r;
    cin >> n >> r;
    if (n >= 10) cout << r << endl;
    else cout << r + 100 * (10 - n) << endl;
}

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

int main() {
	bool card[4][14] = { {0} };
	char a;
	int n=0,b=0,f=0;

	cin >> n;
	for (int i = 0;i < n;i++) {
		cin >> a >> b;
		if (a == 'S') f = 0;
		if (a == 'H') f = 1;
		if (a == 'C') f = 2;
		if (a == 'D') f = 3;
		
		card[f][b] = 1;
	}

	for (int j = 0;j < 4 ;j++) {
		for (int k = 1;k <= 13;k++) {
			if (card[j][k] != 1) {
				if (j == 0) cout << "S " << k << endl;
				if (j == 1) cout << "H " << k << endl;
				if (j == 2) cout << "C " << k << endl;
				if (j == 3) cout << "D " << k << endl;
			}
		}
	}
}

Measured memory_bytes: 3096
#include<bits/stdc++.h>
#define ll long long
using namespace std;
ll n, k;
ll a[101];
ll dp[102][100005] = {0};
const int mod = 1e9 + 7;
ll add(ll x, ll y) {
	return (x + y + mod) % mod;
}

int main() {

	cin >> n >> k;
	for (ll i = 0; i < n; i++)cin >> a[i];
	for (ll i = 0; i <= a[0] and i <= k; i++)dp[0][i] = 1LL;
	for (ll i = 1; i < n; i++) {
		vector<ll> pref(k + 1, 0);
		pref[0] = dp[i - 1][0];
		for (ll j = 1; j <= k; j++)pref[j] = add(dp[i - 1][j] , pref[j - 1]);
		for (ll j = 0; j <= k; j++)
			if (j > a[i])dp[i][j] = add(0LL , pref[j] - pref[j - a[i] - 1]);
			else dp[i][j] = add(dp[i - 1][j] , (j > 0 ? pref[j - 1] : 0)) ;
	}

	cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
	cout << dp[n - 1][k];

}

//  dp[i][j]=dp[i-1][j] +pref[j-1]

Measured memory_bytes: 82660
import Control.Monad
type Coord= [Int]
main = do
    [n, d] <- map read . words <$> getLine
    a <- comb . map (map read . words) <$> replicateM n getLine
    print $ length $ filter isInt $ map sub2 $ a

sub2 :: (Coord, Coord) -> Float
sub2 (a, b) = sqrt $ realToFrac $ sum $ zipWith (\a b -> (a - b) ^ 2) a b

isInt :: Float -> Bool
isInt n = n == fromInteger (round n)

comb :: [Coord] -> [(Coord, Coord)]
comb [] = []
comb (x:xs) = [(x, y) | y <- xs] ++ comb xs


Measured memory_bytes: 1020
#include<bits/stdc++.h>
#define all(v) v.begin(), v.end()
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define all(v) v.begin(), v.end()

using namespace std;
typedef long long LL;
const LL MOD = 1e9 + 7;
const double PI = 2 * acos(0);
int ans[10001];

int main() {
	int N;
	scanf("%d", &N);
	for (int i = 1; i <= N; i++) {
		if (i * i > N) break;
		for (int j = 1; j <= N; j++) {
			if (i * i + j * j + i * j > N) break;
			for (int k = 1; k <= N; k++) {
				int tmp = i * i + j * j + k * k + i * j + i * k + j * k;
				if (tmp > N) break;
				ans[tmp]++;
			}
		}
	}
	for (int i = 1; i <= N; i++) {
		printf("%d\n", ans[i]);
	}
}

Measured memory_bytes: 3808
#include <bits/stdc++.h>
using namespace std;
void debug() {cout<<endl;}
template<typename T,typename... Args>
void debug(T x,Args... args) {cout<<x<<" ";debug(args...);}
#define forn(i,a,b) for(int i=a;i<b;++i)
#define SZ(x) int(x.size())
#define pb push_back
#define F first
#define S second
#define endl "\n"
typedef long long ll;
typedef pair<int, int> pii;

int main() {
    ios::sync_with_stdio(0); cin.tie(0);
    int k, x;
    cin >> k >> x;
    bool sp = false;
    forn(i, x-k+1, x+k) {
        if (sp) cout << " ";
        sp = true;
        cout << i;
    }
}


Measured memory_bytes: 3572
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ll long long
#define rep(i,n) for(ll i=0;i<(n);i++)
#define pll pair<ll,ll>
#define pii pair<int,int>
#define pq priority_queue
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define endl '\n'
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define lb(c,x) distance(c.begin(),lower_bound(all(c),x))
#define ub(c,x) distance(c.begin(),upper_bound(all(c),x))

using namespace std;

const ll INF=1e15;

int main() {
    ll n,k;
    cin >> n >> k;
    vector<ll> a(n),s(n+1);
    map<ll,ll> m;
    rep(i,n){
        cin >> a[i];
        s[i+1]=s[i]+a[i];
    }
    for(ll i=1;i<=n;i++){
        s[i]-=i;
        s[i]%=k;
    }
    ll ans=0;
    for(ll i=0;i<=n;i++){
        ans+=m[s[i]];
        if(i>=k-1) m[s[i-k+1]]--;
        m[s[i]]++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 18752
import sys
sys.setrecursionlimit(5000)

c_list = []


def dps(h_i, w_i, h, w, done_list):
    if h_i >= h or w_i >= w or h_i < 0 or w_i < 0:
        return
    if c_list[h_i][w_i] == 1 and done_list[h_i][w_i] == False:
        done_list[h_i][w_i] = True
        for d_h in [-1,0,1]:
            for d_w in [-1, 0, 1]:
                if d_h == 0 and d_w == 0: continue
                n_h, n_w = h_i + d_h, w_i + d_w
                if n_h >= h or n_w >= w or n_h < 0 or n_w < 0: continue

                dps(h_i-1, w_i, h, w, done_list)
                dps(h_i+1, w_i, h, w, done_list)

                dps(h_i, w_i-1, h, w, done_list)
                dps(h_i, w_i+1, h, w, done_list)

                dps(h_i-1, w_i-1, h, w, done_list)
                dps(h_i-1, w_i+1, h, w, done_list)

                dps(h_i+1, w_i-1, h, w, done_list)
                dps(h_i+1, w_i+1, h, w, done_list)

        
def main():
    global c_list
    c_list = []
    w,h = map(int, input().split())
    if w == 0 and h == 0:
        return False

    for i in range(h):
        c_list.append(list(map(int,input().split())))

    done_list = [[False for _ in range(w)] for _i in range(h)]
    cnt = 0
    for h_i in range(h):
        for w_i in range(w):
            if not done_list[h_i][w_i] and c_list[h_i][w_i] == 1:
                dps(h_i, w_i, h, w, done_list)
                cnt += 1
    return cnt

if __name__ == "__main__":
    rl = []
    while True:
        res = main()
        if res is False: break
        else:
            rl.append(res)
    for r in rl:
        print(r)


Measured memory_bytes: 8216
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#include <set>
#include <tuple>
#define mkp make_pair
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
const ll MOD=1e9+7;

#define MAX_N 200020
ll inv[MAX_N+10],fac[MAX_N+10],ifac[MAX_N+10];

void setComb(){
  inv[0]=1;inv[1]=1;fac[1]=1;ifac[1]=1;fac[0]=1;ifac[0]=1;
  for(int i=2;i<MAX_N;i++){
    inv[i]=(-MOD/i)*inv[MOD%i]%MOD;
    fac[i]=fac[i-1]*i%MOD;
    ifac[i]=ifac[i-1]*inv[i]%MOD;

    inv[i]=(inv[i]+MOD)%MOD;
    fac[i]=(fac[i]+MOD)%MOD;
    ifac[i]=(ifac[i]+MOD)%MOD;
  }
  return;
}

ll comb(ll n,ll k){
  if(n<k||n<0||k<0) return 0;
  else return ((fac[n]*ifac[k]%MOD*ifac[n-k]%MOD+MOD)%MOD);
}

ll hcomb(ll n,ll r){
  if(n==0&&r==0) return 1;
  else if(n<0||r<0) return 0;
  else return comb(n+r-1,r-1);
}

int N,A,B,C;

ll a[100010],b[100010];

void add(ll &a,ll b){
    a=(a+b)%MOD;
}

void mul(ll &a,ll b){
    a=a*b%MOD;
}

ll mod_pow(ll x,ll n){
    ll res=1;
    x%=MOD;
    while(n>0){
        if(n&1) res=res*x%MOD;
        x=x*x%MOD;
        n/=2;
    }
    return res;
}

int main(){
  cin>>N>>A>>B>>C;

  setComb();

  ll x=A;
  mul(x,inv[(A+B)]);
  ll y=B;
  mul(y,inv[(A+B)]);
  ll z=100-C;
  mul(z,inv[100]);
  z=mod_pow(z,MOD-2);

  a[0]=1;
  b[0]=1;
  for(int i=1;i<=N;i++){
      a[i]=a[i-1]*x%MOD;
      b[i]=b[i-1]*y%MOD;
  }

  ll ans=0;
  for(int x=N;x<=2*N-1;x++){
      ll c=z*x%MOD;

      ll res=comb(x-1,N-1);
      ll p=a[N]*b[x-N]%MOD;
      ll q=a[x-N]*b[N]%MOD;

      res=res*((p+q)%MOD)%MOD;

      mul(res,c);
      add(ans,res);
  }

  cout<<ans<<endl;



  return 0;
}


Measured memory_bytes: 6528
#include <stdio.h>

int main(void)
{
  int a[100000], i, k = 0, l, m, n;

  scanf("%d", &n);

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

  for (i = 0; i < n; i++) {
    l = a[i];
    m = a[l - 1] - 1;
    if (l != -1 && m == i) {
      k++;
      a[i] = -1;
      a[a[i] - 1] = -1;
    }
  }

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

  return 0;
}


Measured memory_bytes: 512
#include <string>
#include <iostream>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;

const double EPS = 1e-9;

int main(){
	static bool prime[50000];
	fill(prime, prime+50000, true);
	prime[0] = prime[1] = false;

	for(int i = 0; i < 50000; i++){
		if(prime[i]){
			for(int j = i*2; j < 50000; j+=i){
				prime[j] = false;
			}
		}
	}

	int n;
	while(cin >> n){
		if(n == 0){
			break;
		}
		int count = 0;
		for(int i = 0; i <= n/2; i++){
			if(prime[i] && prime[n-i]){
				count++;
			}
		}
		cout << count << endl;
	}

	
    return 0;
}

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

vector<int64_t> divisor(int64_t n){
  vector<int64_t> div;
  for(int64_t i=1;i*i<= n;++i) {
    if(n%i==0) {
      div.push_back(i);
      if(i*i!=n) div.push_back(n/i);
    }
  }
  sort(begin(div),end(div));
  return (div);
}


int main(){
  int64_t N;
  cin>>N;
  vector<int64_t> v=divisor(N),w=divisor(N-1);
  int64_t ans=0;
  for(int i=1;i<v.size();++i){
    int64_t m=N,p=v[i];
    while(m%p==0){
      m /= p;
    }
    if(m%p==1) ++ans;
  }
  for(int i=1;i<w.size();++i){
    int64_t m=N,p=w[i];
    if(m%p==1 && p<=N) ++ans;
  }

  cout<<ans<<endl;
}


Measured memory_bytes: 384
#include <stdio.h>
int main()
{int n;
	scanf("%d\n",&n);
	int i,f,l,m,p,a[n];
	for(i=0;i<n;i++)
	{
		scanf("%d",&a[i]);
	}
	for(i=0,l=0;i<n;i++)
	{for(m=1,p=0;m<n;m++)
	{
		if(m<=i){
			continue;}
			f=a[i]*a[m];
			p=p+f;
	}
		l=l+p;
	}
	printf("%d",l);
	return 0;
	}

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

int main()
{
	int i,N,T,c[1001],t[1001];
	int cans=10000;
	cin >> N >> T;
	for(i=1;i<=N;i++){
		cin >> c[i] >> t[i];
	}

	//結果
	for(i=1;i<=N;i++){
		if(t[i]<=T && c[i] < cans)
		{
			cans=c[i];
		}
	}

	if(cans>=10000)
	{
		cout << "TLE" << endl;
	}else cout << cans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>//atcoder.089.C
using namespace std;
int main(){
	long long n,m,i,j,b=0;
	cin>>n;
	long long a[6]={0};
	string s[n+1];
	for(i=1;i<=n;i++){
		cin>>s[i];
		if(s[i][0]=='M')a[1]++;
		if(s[i][0]=='A')a[2]++;
		if(s[i][0]=='R')a[3]++;
		if(s[i][0]=='C')a[4]++;
		if(s[i][0]=='H')a[5]++;
	}
	for(i=1;i<=3;i++){
		if(a[i]!=0)
			for(j=i+1;j<=4;j++){
				if(a[j]!=0)
					for(m=j+1;m<=5;m++){
						if(a[m]!=0)b=b+a[i]*a[j]*a[m];
					}
			}
	}
	cout<<b;
	return 0;
}

Measured memory_bytes: 6144
#include <bits/stdc++.h>
#define ll long long

using namespace std;

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

        int a, b;

        cin >> a >> b;

        if(a > 8 || b > 8) {
                cout << ":(" << endl;
        } else {
                cout << "Yay!" << endl;
        }
        return 0;

}


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

using namespace std; 
#define REP(i, n) for (int i = 0; i < (n); i++)

typedef long long ll;

int main(int argc, char const *argv[])
{
    cin.tie(0);
   	ios::sync_with_stdio(false);
    int N; cin >> N;
    vector<string> v;
    unordered_map<string,int> ump;
    REP(i, N) {
        string s; cin >> s;
        v.push_back(s);
        ump[s]++;
        if(ump[s] >= 2) {
            cout << "No" << endl;
            return 0;
        }
    }
    char pre = v[0].back();
    for (int i = 1; i < N; i++) {
        if (pre != v[i].front()) {
            cout << "No" << endl;
            return 0;
        }
        pre = v[i].back();
    }
    cout << "Yes" << endl;
    return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;

class Procon
{
    public Procon() { }
    static void Main(string[] agrs)
    {
        new Procon().Do();
    }

    Scanner cin;

    public void Do()
    {
        cin = new Scanner();
        int N = cin.nextInt();
        int M = cin.nextInt();
        int X = cin.nextInt();
        int Y = cin.nextInt();
        int[] x = cin.arrayInt();
        int[] y = cin.arrayInt();

        int max = -100000;
        for (int i = 0; i < N; i++)
        {
            max = Math.Max(x[i], max);
        }

        int min = 100000;
        for (int i = 0; i < M; i++)
        {
            min = Math.Min(y[i], min);
        }

        if (max < min && max < Y && X < min)
        {
            Console.WriteLine("No War");
            return;
        }
        Console.WriteLine("War");
    }
}

class Scanner
{
    string[] s;
    int i;
    int max_i;

    public Scanner()
    {
        s = new string[0];
        max_i = 0;
        i = 0;
    }

    public string nextString()
    {
        if (i >= s.Length)
        {
            s = Console.ReadLine().Split(' ');
            max_i = s.Length;
            i = 0;
            if (max_i == 0)
            {
                return "";
            }
            return s[i++];
        }
        else
        {
            return s[i++];
        }
    }

    public int nextInt()
    {
        return int.Parse(nextString());
    }


    public long nextLong()
    {
        return long.Parse(nextString());
    }

    public double nextDouble()
    {
        return double.Parse(nextString());
    }

    public string[] arrayString()
    {
        return Console.ReadLine().Split(' ');
    }

    public int[] arrayInt()
    {
        string[] str = Console.ReadLine().Split(' ');
        int[] array = new int[str.Length];
        for (int i = 0; i < str.Length; i++)
        {
            array[i] = int.Parse(str[i]);
        }
        return array;
    }

    public long[] arrayLong()
    {
        string[] str = Console.ReadLine().Split(' ');
        long[] array = new long[str.Length];
        for (int i = 0; i < str.Length; i++)
        {
            array[i] = long.Parse(str[i]);
        }
        return array;
    }

    public double[] arrayDouble()
    {
        string[] str = Console.ReadLine().Split(' ');
        double[] array = new double[str.Length];
        for (int i = 0; i < str.Length; i++)
        {
            array[i] = double.Parse(str[i]);
        }
        return array;
    }
}


Measured memory_bytes: 13140
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key

typedef long long ll;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef long double ld; 
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
typedef set<int>::iterator sit;
typedef map<int,int>::iterator mit;
typedef vector<int>::iterator vit;

int a[100001];
vi adj[100001];
int h[100001];
int ans, k;

void dfs(int u, int p)
{
	h[u] = 1;
	for(int i = 0; i < adj[u].size(); i++)
	{
		int v = adj[u][i];
		dfs(v, u);
		h[u] = max(h[u], h[v] + 1);
	}
	if(u != 1 && p != 1 && h[u] >= k)
	{
		ans++; h[u] = 0;
	}
}

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	int n; cin >> n >> k;
	for(int i = 1; i <= n; i++)
	{
		cin >> a[i];
	}
	ans = 0;
	if(a[1] != 1)
	{
		a[1] = 1;
		ans++;
	}
	for(int i = 2; i <= n; i++)
	{
		adj[a[i]].pb(i);
	}
	//now we have a tree
	dfs(1, -1);
	cout << ans;
}	

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

using namespace std;

#define sqr(x) ((x) * (x))
#define all(v) (v).begin(), (v).end()
#define vi vector<int>
#define vvi vector<vi>

typedef long long ll;

int main() {
  int N, M;
  ll ans = 0;
  cin >> N >> M;
  vi A(N, 0);
  vector<pair<int, int>> pair_BC(M);
  for (int i = 0; i < N; i++) {
    cin >> A[i];
  }
  sort(all(A));
  for (int i = 0; i < M; i++) {
    int B, C;
    cin >> B >> C;
    pair_BC[i] = make_pair(C, B);
  }
  sort(all(pair_BC), greater<pair<int, int>>());
  int i = 0;
  for (auto x : pair_BC) {
    int j = 0;
    while (j < x.second && x.first > A[i]) {
      A[i] = x.first;
      i++;
      j++;
    }
  }
  for (int i = 0; i < N; i++) {
    ans += A[i];
  }
  cout << ans << endl;
  return 0;
}

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

int n;
long long sum;
int x[200000];

int main(){
    cin >> n;
    vector<int> sx(n, 0);
    for(int i = 0; i < n; i++){
        cin >> sx[i];
        x[i] = sx[i];
    }
    int medi1 = n / 2 - 1;
    int medi2 = n / 2;
    sort(sx.begin(), sx.end());
    for(int i = 0; i < n; i ++){
        if(x[i] <= sx[medi1]){
            cout << sx[medi2] << endl;
        }else{
            cout << sx[medi1] << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 3712
#include<bits/stdc++.h>
using namespace std ;
#define rep(i,n) for(int i =0;i<n;i++)
#define ios ios_base::sync_with_stdio(0);cin.tie(0);

int main(){
	ios;
	int n,v[50];
	double ans[50];
	cin>>n;
	rep(i,n)
	{cin>>v[i];
	}
	sort(v,v+n);
	ans[0]=v[0];
	rep(i,n-1)
	{double a=(ans[i]+v[i+1])/2.0;
	 ans[i+1]=a;
	}
	cout<<ans[n-1]<<endl;
	return 0;
}


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

int main()
{

        string O, E;
        cin >> O >> E;
        int len = O.length() + E.length();
        int oc = 0;
        int ec = 0;
        for (int i = 0; i < len; ++i) {
                if ((i+1) % 2) {
                        cout << O[oc];
                        oc++;
                }
                else {
                        cout << E[ec];
                        ec++;
                }
        }
        cout << endl;



}


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

#define N 36

typedef struct{

  char c;
  int n;

} Card;

void bubble_sort(Card*, int);
void selec_sort(Card*, int);

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

  int i;
  int num;

  Card card[N],bubble[N],selec[N];

  scanf("%d",&num);

  for( i = 0 ; i < num ; i++ ){
    scanf(" %c%d",&card[i].c,&card[i].n);

    bubble[i] = selec[i] = card[i];
  }

  bubble_sort(bubble,num);
  selec_sort(selec,num);

  for( i = 0 ; i < num ; i++ ){

    if( i == num-1 ){
      printf("%c%d\n",bubble[i].c,bubble[i].n);
    }else{
      printf("%c%d ",bubble[i].c,bubble[i].n);
    }

  }

  printf("Stable\n");

  for( i = 0 ; i < num ; i++ ){

    if( i == num-1 ){
      printf("%c%d\n",selec[i].c,selec[i].n);
    }else{
      printf("%c%d ",selec[i].c,selec[i].n);
    }

  }

  for( i = 0 ; i < num ; i++ ){

    if( selec[i].c != bubble[i].c && selec[i].n == bubble[i].n ){
      printf("Not stable\n");
      return 0;
    }

  }

  printf("Stable\n");

  return 0;
}

void bubble_sort(Card *a, int n){

  int i,j;
  int tempn;
  char tempc;

  for( i = 0 ; i < n ; i++ ){
    for( j = n-1 ; j > i ; j-- ){

      if( a[j].n < a[j-1].n ){
        tempn = a[j].n;
        a[j].n = a[j-1].n;
        a[j-1].n = tempn;

        tempc = a[j].c;
        a[j].c = a[j-1].c;
        a[j-1].c = tempc;
      }

    }

  }

}

void selec_sort(Card *a, int n){

  int i,j,mini;
  int tempn;
  char tempc;

  for( i = 0 ; i < n ; i++ ){
    mini = i;
    for( j = i ; j < n ; j++ ){
      if( a[j].n < a[mini].n ){
        mini = j;
      }
    }

    if( i != mini ){
      tempn = a[i].n;
      a[i].n = a[mini].n;
      a[mini].n = tempn;

      tempc = a[i].c;
      a[i].c = a[mini].c;
      a[mini].c = tempc;
    }

  }


}

Measured memory_bytes: 608
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
int main() {
	int n, b=0, r=0;
	char s;
	cin >> n;
	for (int x = 0; x < n; ++x) {
		cin >> s;
		if (s == 'B')b = b + 1;
		else r = r + 1;
	}
	if (b < r)cout<<"Yes" << endl;
	else cout << "No" << endl;

}

Measured memory_bytes: 256
while True:
    N, X = map(int, input().split())
    if(N == 0)and(X == 0):
        exit(0)
    ans = 0
    for a in range(1, N-1):
        for b in range(a+1, N):
            for c in range(b+1, N+1):
                if a+b+c == X:
                    ans += 1
    print(ans)



Measured memory_bytes: 5596
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,l,r) for(long long i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define REPS(i,n) FOR(i,1,n+1)
#define RFOR(i,l,r) for(long long i=(l);i>=(r);--i)
#define RREP(i,n) RFOR(i,n-1,0)
#define RREPS(i,n) RFOR(i,n,1)
#define int long long
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define SZ(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true; }return false; }
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true; }return false; }
const int INF = 1e18;

const int M_battle = 1000* 999 /2 + 100;

int d[M_battle], longest_path;
vector<int> G[M_battle];
int ans;
int seen[M_battle];

int dfs(int k){
    if(seen[k] == 2) return d[k];
    seen[k] = 1;
    for(auto e: G[k]){
        if(seen[e] == 1){
            cout << -1 << endl;
            exit(0);
        }
        chmax(d[k],dfs(e)+1);
    }
    seen[k] = 2;
    return d[k];
}

signed main(){
    int n; cin >> n;
    const int bat = n*(n-1)/2;
    REP(i,n){
        int a[n-1];
        REP(j,n-1){
            cin >> a[j];
            a[j]--;
        }
        REP(j,n-2){
            int x = i, y = a[j], z = i, w = a[j+1];
            if(y > x)swap(x,y);
            if(w > z)swap(z,w);
            int now = x - y + (n*2 -y -1) * y / 2;
            int next = z - w + (n*2 -w -1) * w / 2;
            if(!j)G[0].pb(now);
            G[now].pb(next);
        }
    }
    cout << dfs(0) << endl;
}

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

int main() {
   
 
  
    string s,t;
    cin>>s>>t;
    for(int i = 0 ; i <s.size();i++){
        if(s[i]!=t[i]){
            cout<<"No";
            return 0;
        }
    }
    if(s.size()+1 == t.size()){
        cout<<"Yes";
        return 0;
    }
    cout<<"No";
 
 
 
    
 
    return 0;
}

Measured memory_bytes: 3624
#include<iostream>
using namespace std;
int main(void)
{
	int n, a, YJSNPI[10][100];
	char ch;

	cin >> n;

	for (int i = 0; i < n; i++)
	{
		cin >> ch >> a;
		if (ch == 'S')
			YJSNPI[0][a]=a;
		else if (ch == 'H')
			YJSNPI[1][a]=a;
		else if (ch == 'C')
			YJSNPI[2][a]=a;
		else if (ch == 'D')
			YJSNPI[3][a]=a;
	}
	for (int i = 1; i <= 13; i++)
	{
		if (YJSNPI[0][i] != i)
			cout << 'S' << " " << i << endl;
	}
	for (int i = 1; i <= 13; i++)
	{

		if (YJSNPI[1][i] != i)
			cout << 'H' << " " << i << endl;
	}
	for (int i = 1; i <= 13; i++)
	{

		if (YJSNPI[2][i] != i)
			cout << 'C' << " " << i << endl;
	}
	for (int i = 1; i <= 13; i++)
	{
		if (YJSNPI[3][i] != i)
			cout << 'D' << " " << i << endl;
	}
	return 0;
}




Measured memory_bytes: 3100
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
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;
}

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
const ll mod = 998244353;
ll r, g, b;
int main() {
    //cout.precision(10);
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N;
    cin >> N;
    string S;
    cin >> S;
    ll ans = 1;
    for(ll i = 1; i <= N; i++) {
        ans = ans * i % mod;
    }
    cerr << ans << endl;
    for(int i = 0; i < S.size(); i++) {
        //cerr << i << " " << r << " " << g << " " << b << " " << ans << endl;
        if(S[i] == 'B') {
            if(r == 0 && g == 0) {
                b++;
                continue;
            } else if(r != 0 && g == 0) {
                if(r > b) ans *= (r - b);
                ans %= mod;
                b++;
            } else if(r == 0 && g != 0) {
                if(g > b) ans *= (g - b);
                ans %= mod;
                b++;
            } else if(r != 0 && g != 0) {
                ans *= min(r, g);
                ans %= mod;
                r--;
                g--;
            }
        }
        if(S[i] == 'G') {
            if(b == 0 && r == 0) {
                g++;
                continue;
            } else if(b != 0 && r == 0) {
                if(b > g) ans *= (b - g);
                ans %= mod;
                g++;
            } else if(b == 0 && r != 0) {
                if(r > g) ans *= (r - g);
                ans %= mod;
                g++;
            } else if(b != 0 && r != 0) {
                ans *= min(b, r);
                ans %= mod;
                b--;
                r--;
            }
        }
        if(S[i] == 'R') {
            if(g == 0 && b == 0) {
                r++;
                continue;
            } else if(g != 0 && b == 0) {
                if(g > r) ans *= (g - r);
                ans %= mod;
                r++;
            } else if(g == 0 && b != 0) {
                if(b > r) ans *= (b - r);
                ans %= mod;
                r++;
            } else if(g != 0 && b != 0) {
                ans *= min(b, g);
                ans %= mod;
                g--;
                b--;
            }
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 720
import java.util.Arrays;
import java.util.Comparator;
import java.util.PriorityQueue;
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int M = sc.nextInt();
    AB[] ab = new AB[N];
    PriorityQueue<Integer> queue = new PriorityQueue<>(Comparator.reverseOrder());
    for (int i = 0; i < N; i++) {
      ab[i] = new AB(sc.nextInt(), sc.nextInt());
    }
    Arrays.sort(ab, (a, b) -> a.a - b.a);
    int ans = 0;
    int ptr = 0;
    for (int i = 1; i <= M; i++) {
      while (ptr < ab.length && ab[ptr].a <= i) {
        queue.add(ab[ptr].b);
        ptr++;
      }
      if (queue.isEmpty()) continue;
      ans += queue.poll();
    }

    System.out.println(ans);
  }

  static class AB {
    int a, b;

    AB(int a, int b) {
      this.a = a;
      this.b = b;
    }
  }
}

Measured memory_bytes: 84744
import java.math.BigInteger;
import java.util.Scanner;

class Main {

	public static void main(String[] args) {

		Scanner sc = null;
		int x = 0;
		BigInteger factorial = new BigInteger("1");
		int count = 0;
		try {
			sc = new Scanner(System.in);

			while ((x = sc.nextInt()) != 0) {
				for (int i = 1; i <= x; i++) {

					factorial =  factorial.multiply(new BigInteger(String.valueOf(i)));

				}
				String[] str = String.valueOf(factorial).split("");

				for (int i = str.length - 1; Integer.parseInt(str[i]) == 0; i--) {

					count++;

				}
				System.out.println(count);
				factorial = new BigInteger("1");
				count = 0;

			}

		} finally {
			sc.close();
		}

	}

}

Measured memory_bytes: 237820
package main

import (
        "fmt"
        "math"
)

func main() {
        var m int
        fmt.Scanf("%d", &m)
        debt := 100.0
        for i := m; i > 0; i-- {
                debt = math.Ceil(debt*1.05)
        }
        fmt.Printf("%d\n", int(debt*1000))
}



Measured memory_bytes: 1124
#include<iostream>
#include<string>
#include <cstdio>
#include<vector>
#include<map>
#include<utility>
#include<list>
#include<algorithm>
#include <ctype.h>
#include<deque>
using namespace std;
using ll = long long int;

int n, m;
int cnt[31];
int main(void) {
	cin >> n >> m;
	for (int i = 0; i < n; i++) {
		int ki;
		cin >> ki;
		for (int j = 0; j < ki; j++) {
			int aij;
			cin >> aij;
			cnt[aij]++;
		}
	}
	int ret = 0;
	for (int i = 1; i <= m; i++) {
		if (cnt[i] == n)
			ret++;
	}
	cout << ret << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
 
int main() {
  int A,B,C;
	cin>>A>>B>>C;
	if(A+B>=C)cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
}

Measured memory_bytes: 3588
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
using namespace std;
typedef long long ll;
const int INF=1001001001;
int main(){
  int a,b,c;
  cin>>a>>b>>c;
  int ans=a*b/2;
  cout<<ans<<endl;
  return 0;
}


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

int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  for(int i=0;i<n;i++){
    cin >> a[i];
  }
  int mn=a[0],mx=a[0];
  for(int i=1;i<n;i++){
    if(mn>a[i])
      mn=a[i];
    if(mx<a[i])
      mx=a[i];
  }
  cout << mx-mn << endl;
}


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

int main()
{
    int box[130]={};
    char str[30];
    scanf("%s",str);
    for(int i=0;i<strlen(str);i++){
        box[(int)str[i]] ++;
    }
    for(int i=0;i<130;i++){
        if(box[i]>1){
            cout << "no" << endl;
            return 0;
        }
    }
    cout << "yes" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int n;
string ss="Snuke";
string ff="Fennec";
vector<int>g[100010];
int main()
{
	cin>>n;
	for(int i=1;i<n;i++)
	{
		int x,y;
		cin>>x>>y;
		g[x].push_back(y);
		g[y].push_back(x);
	}
	vector<int>c(n+1);
	queue<int>q;
	q.push(1);q.push(n);
	c[1]=1;
	c[n]=2;
	int f=1,s=1;
	while(!q.empty())
	{
		int x=q.front();
		q.pop();
		for(int i=0;i<g[x].size();i++)
		{
			int y=g[x][i];
			if(c[y]==0)
			{
				q.push(y);
				c[y]=c[x];
				if(c[y]==1)f++;
				else s++;
			}
		}
	}
	if(f>s)cout<<ff;
	else cout<<ss;
	return 0;
}

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

int n;
struct P { double x, y;};
vector<P> p;

double dist(P a, P b) {
  double dx = a.x-b.x;
  double dy = a.y-b.y;
  return sqrt(dx*dx + dy*dy);
}
double f(double x, double y) {
  double res = 0;
  rep(i,n) {
    res = max(res, dist((P){x,y}, p[i]));
  }
  return res;
}

double g(double x) {
  double l = 0, r = 1000;
  rep(i,80) {
    double c1 = (l*2+r)/3;
    double c2 = (l+r*2)/3;
    if (f(x,c1) > f(x,c2)) l = c1; else r = c2;
  }
  return f(x,l);
}

int main() {
  cin >> n;
  p = vector<P>(n);
  rep(i,n) cin >> p[i].x >> p[i].y;

  double l = 0, r = 1000;
  rep(i,80) {
    double c1 = (l*2+r)/3;
    double c2 = (l+r*2)/3;
    if (g(c1) > g(c2)) l = c1; else r = c2;
  }

  double ans = g(l);
  printf("%.10f\n", ans);
  return 0;
}

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

int main() {
    int n,m,i,j,temp,ans=0;
    char tempc;
    bool xchar[28];
    bool ychar[28];
    vector<string>s,t;
    string  temps,tempt;
    cin>>n;
    for(i=0;i<n;i++){
        cin>>temps;
        s.push_back(temps);
    }
    cin>>m;
    for(i=0;i<m;i++){
        cin>>temps;
        t.push_back(temps);
    }
    vector<int> snum(n+m,0);
    vector<int> tnum(m,0);

    for(i=0;i<n;i++){
        snum[i]=0;
        for(j=0;j<n;j++){
            if(s[i]==s[j])snum[i]++;
        }
        for(j=0;j<m;j++){
            if(s[i]==t[j])snum[i]--;
        }
    }

    for(int kazu:snum){
       // cout<<kazu<<endl;
        if(kazu>ans)ans=kazu;
    }

    cout<<ans<<endl;
    //std::cout << ans << std::endl;
    return 0;
}


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

static inline int vv(const std::vector<int>& s) {
    int v = 0;
    for (const auto ss: s) {
        v *= 10;
        v += ss;
    }
    return v;
}

int main() {
    int n; std::cin >> n;
    std::vector<int> s(n);
    for (int i = 0; i < n; i++) {
        s[i] = i + 1;
    }

    int p = 0;
    for (int i = 0; i < n; i++) {
        int v; std::cin >> v;
        p *= 10; p+= v;
    }
    int q = 0;
    for (int i = 0; i < n; i++) {
        int v; std::cin >> v;
        q *= 10; q+= v;
    }

    int a, b;
    int cnt = 1;
    do {
        int v = vv(s);
        if (p == v) {
            a = cnt;
        }
        if (q == v) {
            b = cnt;
        }
        cnt++;
    } while (std::next_permutation(s.begin(), s.end()));
    std::cout << std::abs(a - b) << std::endl;
    return 0;
}

Measured memory_bytes: 3132
N, K = map(int,input().split())
A = list(map(int,input().split()))
A.sort()
fact = [1]
mod = 10**9+7
for i in range(1, N+1):
    fact.append(fact[i-1]*i % mod)
ifact = [None]*(N+1)
ifact[N] = pow(fact[N], mod-2, mod)
for i in range(N, 0, -1):
    ifact[i-1] = i*ifact[i] % mod
def comb(n,k):
    if n < k:
        return 0
    elif n == 0 or k == 0:
        return 1
    return (fact[n]*ifact[k]*ifact[n-k]) % mod
ans = 0
for i in range(N):
    ans -= comb(N-i-1, K-1)*A[i]
    ans += comb(i, K-1)*A[i]
    ans %= mod
print(ans)

Measured memory_bytes: 20824
#include<iostream>
using namespace std;
static const int N=100;
int main()
{
	int M[N][N];
	int n,u,k,v;
	cin>>n;
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<n;j++)
		M[i][j]=0;
	}
	for(int i=0;i<n;i++)
	{
		cin>>u>>k;
		u--;
		for(int j=0;j<k;j++)
		{
			cin>>v;
			v--;
			M[u][v]=1;
		}
	}
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<n;j++)
		{
			if(j)cout<<" ";
			cout<<M[i][j];
		}
		cout<<endl;
	}
	return 0;
}

Measured memory_bytes: 3120
#include <cstdio>
#include <vector>
#include <algorithm>
#include <cstdint>

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

  intmax_t T[100010]={};

  for (int i=0; i<N; ++i) {
    int s, t, c;
    scanf("%d %d %d", &s, &t, &c);
    --c;
    T[t] ^= 1 << c;
    if (T[s] & (1 << c)) {
      T[s] ^= 1 << c;
    } else {
      T[s-1] ^= 1 << c;
    }
  }

  int res=0;
  for (int i=1; i<=100000; ++i) {
    T[i] ^= T[i-1];
    res = std::max(res, __builtin_popcount(T[i]));
  }

  //for (int i=0; i<100; ++i) {
  //  fprintf(stderr, "%jd%c", T[i], i<99? ' ':'\n');
  //}

  printf("%d\n", res);
}


Measured memory_bytes: 896
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		final Scanner sc = new Scanner(System.in);
		final int N = sc.nextInt();
		final int[] A = new int[N];
		
		for (int i = 0; i < N; i++) {
			A[i] = sc.nextInt();
		}

		int max = -1;
		int second = -1;
		
		for (int i = 0; i < N; i++) {
			final int a = A[i];
			if (a > max) {
				second = max;
				max = a;
			} else if (a > second) {
				second = a;
			}
		}
		
		for (int i = 0; i < N; i++) {
			if (A[i] == max) {
				System.out.println(second);
			} else {
				System.out.println(max);
			}
		}
	}
}

Measured memory_bytes: 123292
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<list>
#include<iomanip>
#include<cmath>
#include<cstring>
using namespace std;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 2e9
#define MOD 1000000007
//#define MOD 998244353
#define LINF (long long)4e18
#define jck 3.141592

using ll = long long;
using Pi = pair<int,int>;
using Pl = pair<ll,ll>;

vector<vector<int>> G;
vector<bool> visited;
int dp[1010*1010/2];
bool ok = true;

int dfs(int i){
	if(dp[i] != -1) return dp[i];
	if(visited[i] && dp[i] == -1){
		ok = false;
		return -1;
	}
	visited[i] = true;

	int res = 1;
	for(int v : G[i]){
		res = max(res,dfs(v)+1);
	}
	return dp[i] = res;
}

int main(){
	int N; cin >> N;
	G.resize(N*(N-1)/2);
	visited.resize(N*(N-1)/2,false);
	memset(dp,-1,sizeof(dp));
	vector<vector<int>> A(N,vector<int>(N-1));
	rep(i,N)rep(j,N-1){
		cin >> A[i][j];
		A[i][j]--;
	}
	int nowid = 0;
	vector<vector<int>> id(N,vector<int>(N));
	rep(i,N)rep(j,N-1){
		if(i > A[i][j]){
			id[i][A[i][j]] = nowid;
			id[A[i][j]][i] = nowid;
			nowid++;
		}
	}
	rep(i,N)rep(j,N-2){
		G[id[i][A[i][j]]].push_back(id[i][A[i][j+1]]);
	}
	int ans = 0;
	rep(i,N*(N-1)/2){
		ans = max(ans,dfs(i));
	}
	if(!ok){
		cout << -1 << endl;
		return 0;
	}
	cout << ans << endl;

}
   


Measured memory_bytes: 37632
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template<class T> using oset=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
#define pb push_back
#define N 200001
#define ll long long
#define int ll 
#define pi pair<int , int>
#define pip pair<pair ,int>
#define mp make_pair 
#define f first
#define s second
#define mod 998244353
ll Mod(ll x, ll y, int p) 
{ll res = 1; x = x % p;
while (y > 0) 
{if(y & 1) res = (res*x) % p; 
y = y>>1;x = (x*x) % p; 
}return res; 
}
int* getlps(string pattern){
 int len = pattern.length();
 int * lps = new int[len];
 lps[0] = 0;
 int i = 1 , j = 0;
 while(i < len){
  if(pattern[i] == pattern[j]){
	  lps[i] = j+1;
   i++;
   j++;
  }
  else{
		if(j != 0){
		 j = lps[j-1];
		}
		else{
		 lps[i] = 0;
		 i++;
		}
  }
 }
 return lps;
}
class Triplet{
 public:
 int x ;
 int y ;
 int gcd;
};
Triplet extendedEuclid(int a , int b){
 if(b == 0){Triplet ans; ans.gcd = a;ans.x = 1;ans.y = 0;return ans;}
 Triplet smallAns = extendedEuclid(b , a%b);
 Triplet ans;
 ans.gcd = smallAns.gcd;
 ans.x = smallAns.y;
 ans.y = smallAns.x - (a/b)*smallAns.y;
 return ans;
}
int mmInverse(int a , int m){
 Triplet ans = extendedEuclid(a , m);
 return ans.x;
}
int32_t main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int arr[3];
for(int i = 0 ; i < 3 ;i++){
 cin>>arr[i];
}
sort(arr , arr+3);
if(arr[0] == arr[1] && arr[1] != arr[2]){
 cout<<"Yes"<<endl;
 return 0;
}
if(arr[1] == arr[2] && arr[0] != arr[1]){
 cout<<"Yes"<<endl;
 return 0;
}
cout<<"No"<<endl;
}


Measured memory_bytes: 256
import sys
import math
import bisect
from sys import stdin,stdout
from math import gcd,floor,sqrt,log
from collections import defaultdict as dd
from bisect import bisect_left as bl,bisect_right as br

sys.setrecursionlimit(100000000)

ii     =lambda: int(input())
si     =lambda: input()
jn     =lambda x,l: x.join(map(str,l))
sl     =lambda: list(map(str,input().strip()))
mi     =lambda: map(int,input().split())
mif    =lambda: map(float,input().split())
lii    =lambda: list(map(int,input().split()))

ceil   =lambda x: int(x) if(x==int(x)) else int(x)+1
ceildiv=lambda x,d: x//d if(x%d==0) else x//d+1

flush  =lambda: stdout.flush()
stdstr =lambda: stdin.readline()
stdint =lambda: int(stdin.readline())
stdpr  =lambda x: stdout.write(str(x))

mod=1000000007


#main code
def minimumChar(S1, S2): 
    n, m = len(S1), len(S2) 
    ans = sys.maxsize 
    for i in range(m - n + 1): 
        minRemovedChar = 0
        for j in range(n): 
            if (S1[j] != S2[i + j]): 
                minRemovedChar += 1
        ans = min(minRemovedChar, ans) 
    return ans 
s=si()
p=si()
sol=minimumChar(p,s)
print(sol)


Measured memory_bytes: 9360
n=int(input())
a=[0]*(n+1)
for i in range(1, n+1):
  a[i]=int(input())
s=set()
b=1
while b not in s and b!=2:
  s.add(b)
  b=a[b]
if b==2:
  print(len(s))
else:
  print(-1)

Measured memory_bytes: 13164