akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define endl "\n"
#define ll long long
#define pll pair<ll,ll>
#define vll vector<ll>
#define vint vector<int>
#define usll unordered_set<ll>
#define sll set<ll>
#define mllll map<ll,ll>
#define pb push_back
#define mp make_pair
#define forr(i, n) for(ll int i = 0; i < n; i++)
#define forr1(i,n) for(ll int i=1;i<n;i++)
#define forra(i,a,b) for(ll int i=a;i<b;i++)
#define arrin(a,n) forr(i,n) cin>>a[i];
#define arrout(a,n) forr(i,n) {cout<<a[i]<<' ';} cout<<'\n';
#define umap unordered_map
typedef long long int lli;
typedef long int li;
using namespace std;
bool primes[1000000+1];
void sieve(lli n){
	 primes[0]=false;
	 primes[1]=false;
	 for(lli i{2};i<=n;i++){primes[i]=true;}
	 for(lli i{2};i<=sqrt(n);i++){
			 if(primes[i]==true){
				for(lli j{2};j*i<=n;j++){primes[i*j]=false;}
			 }
	 }
}
bool comp(pair<int,int> &a, pair<int,int> &b) 
{
    return (a.first < b.first);
}
lli gcd(lli a,lli b){
	if(a==0) return b;
	return gcd(b,a%b);
}
lli fastpow(long long base, long long n)
{
    if(n==0)
       return 1;
    if(n==1)
    return base;
    long long halfn=fastpow(base,n/2);
    if(n%2==0)
        return ( halfn * halfn );
    else
        return ( ( ( halfn * halfn ) ) * base );
}
void bfs(int s, vector<int> v[], bool vis[])
{
    queue<int> q;
    q.push(s);
    vis[s]=true;
    while(!q.empty())
    {
        int a=q.front();
        q.pop();
        //process node 'a'
        for(auto x : v[a])
        {
            if(!vis[x])
            {
                q.push(x);
                vis[x]=true;
                //e[x] = e[a]+1; where e[i] is distance from 0/root and e[0/root]=0
            }
        }
    }
}
void dfs(int s, vector<int> v[], bool vis[])
{
    //process node 's'
    vis[s]=true;
    for(auto x : v[s])
    {
        if(!vis[x])
        {
            dfs(x,v,vis);
        }
    }
}


int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	lli a,b;
	cin>>a>>b;
	cout<<a*b<<endl;
	return 0;
}


Measured memory_bytes: 3656
#include<stdio.h>
#include<stdlib.h>

#define F 4

const int mod[F]={1000000009,1000000021,1000000033,1000000087};

typedef struct hashNode{
  int hash[F];
} node;

node add(node a,node b){
  node x;
  for(int i=0;i<F;i++){
    x.hash[i]=a.hash[i]+b.hash[i];
    if(x.hash[i]>=mod[i]) x.hash[i]-=mod[i];
  }
  return x;
}

node minus(node a,node b){
  node x;
  for(int i=0;i<F;i++){
    x.hash[i]=a.hash[i]-b.hash[i];
    if(x.hash[i]<0) x.hash[i]+=mod[i];
  }
  return x;
}

int isZero(node a){
  for(int i=0;i<F;i++) if(a.hash[i]>0) return 0;
  return 1;
}

void run(void){
  int n,k;
  scanf("%d%d",&n,&k);
  int *a=(int *)calloc(n,sizeof(int));
  int i,j;
  for(i=0;i<n;i++) scanf("%d",a+i);
  node *dp=(node *)calloc(k,sizeof(node));
  for(i=0;i<F;i++) dp[0].hash[i]=1;
  for(i=0;i<n;i++){
    for(j=k-1;j-a[i]>=0;j--){
      dp[j]=add(dp[j],dp[j-a[i]]);
    }
  }
  node *dp2=(node *)calloc(k+1,sizeof(node));
  int ans=0;
  for(i=0;i<n;i++){
    if(a[i]>=k) continue;
    for(j=0;j<a[i];j++) dp2[j]=dp[j];
    for(j=a[i];j<k;j++){
      dp2[j]=minus(dp[j],dp2[j-a[i]]);
    }
    for(j=k-1;j>=k-a[i] && isZero(dp2[j]);j--);
    if(j<k-a[i]) ans++;
  }
  printf("%d\n",ans);
}

int main(void){
  run();
  return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <utility>

using namespace std;
typedef long long ll;

int main() {
    ll q, h, s, d;
    cin >> q >> h >> s >> d;
    ll n;
    cin >> n;
    q *= 4;
    h *= 2;
    ll min = q;
    if(q <= h && q <= s) min = q;
    else if(h <= q && h <= s) min = h;
    else min = s;
    if(2*min < d) {
        cout << min * n << endl;
    } else {
        cout << (n/2)*d + (n%2)*min << endl;
    }


}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;    
#define ll long long
int main(){
    ios::sync_with_stdio(false) ,cin.tie(0);
    ll n , m , sum = 0;
    cin >> n >> m ;
    while(m--) {
        ll x;
        cin >> x;
        sum += x;
    }
    cout <<(sum <= n ? n-sum : -1);
}



Measured memory_bytes: 3652
// AOJ 0600 Baumkuchen
// 2017.12.5 bal4u@uu

#include <stdio.h>
#include <stdlib.h>

int a[100002], p[100002];
long long s[100002];

char buf[15], *bp;
int getint()
{
	int n = 0;
	while (*bp >= '0') n = (n<<3) + (n<<1) + (*bp++ & 0xf);
	return n;
}

int main()
{
	int n, i, ii, f;
	long long sum, l, m, r;

	fgets(bp=buf, 15, stdin), n = getint();
	for (sum = 0, i = 0; i < n; i++) {
		fgets(bp=buf, 15, stdin);
		sum += a[i] = getint();
	}
	
	l = 0, r = sum + 1;
	while (l + 1 < r) {
		m = (l+r) >> 1;
		for (i = 0; i < n; i++) {
			if (!i) s[i] = p[i] = 0;
			else p[i] = p[i-1] - 1, s[i] = s[i-1] - a[i-1];
			
			while (s[i] < m) {
				ii = i + p[i];
				if (ii >= n) ii -= n;
				s[i] += a[ii], p[i]++;
			}
		}
	
		for (f = 0, i = 0; i < n; i++) {
			ii = i + p[i];
			if (ii >= n) ii -= n;
			if (sum - s[i] - s[ii] >= m) f = 1;
		}
		if (f) l = m; else r = m;
    }
	printf("%lld\n", l);
	return 0;
}

Measured memory_bytes: 3316
#include <bits/stdc++.h>
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
//#define int long long
typedef long long ll;
using namespace std;
const int MOD = 1000000007;
const int INF = 1010000000;
const double EPS = 1e-10;
const pair<int,int> fd[] = {make_pair(1,0),make_pair(-1,0),make_pair(0,1),make_pair(0,-1)}; 

vector<int> init(int size){
  vector<int> par(size,-1);
  return par;
}

int root(int x, vector<int>& par){
  if(par[x] < 0){
    return x;
  }else{
    return par[x] = root(par[x],par);
  }
}

bool same(int x, int y, vector<int>& par){
  return root(x, par) == root(y, par);
}

void unite(int x, int y, vector<int>& par){
  x = root(x, par), y = root(y, par);
  if(same(x,y, par))return;
  par[x] += par[y];
  par[y] = x;
}

int size(int x, vector<int>& par){
  return -par[root(x, par)];
}

int pow(int x, int n){
  if(n == 0)return 1;
  if(n % 2 == 0)return pow(x * x % MOD, n/2);
  else return x * pow(x, n-1) % MOD;
}


signed main(){
  int n;cin>>n;
  cout << (n-2)*180 << endl;
}


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

using namespace std;
using ll = long long;

#define REP(i,m,n) for(ll (i)=(m),i##_len=(n);(i)<(i##_len);++(i))
#define FORR(i,v) for(auto (i):v)
#define ALL(x) (x).begin(), (x).end()
#define _PR(x) cout << (x) << endl
#define _PS(x) cout << (x) << " "
#define SZ(x) ((int)(x).size())
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define pb push_back

int main()
{
    ll N;
    cin >> N;
    string S;
    cin >> S;

    REP(i,0,S.length()){
        cout << ((char)((S[i]-'A'+N) % 26 + 'A'));
    }
    _PR("");

    return 0;
}

/*



*/

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <numeric>
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

vector<long long> divdiv (long long a){
vector<long long> p(2);

  if (a % -2 == -1){
    p[0] = a / -2 + 1;
    p[1] = 1;
  }else {
    p[0] = a / -2;
    p[1] = a % -2;
  }

  return p;
}

int main() {

  long long N;

  cin >> N;

  if (N == 0){
    cout << 0 << endl;
    return 0;
  }

  vector<int> ans;

  while (N != 1) {
    vector<long long> p = divdiv(N);

    ans.push_back(p[1]);
    N = p[0];
  }
  ans.push_back(1);
  for (int i = ans.size() - 1; i  >= 0; i--){
    cout << ans[i];
  }
  cout << endl;

  //cout << (N % -2) << endl;
  //cout << (N / -2) << endl;

  return 0;
}


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

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

  vector<ll> dp(2019, 0);
  std::vector<ll> ndp(2019, 0);

  ll ans = 0;
  rep(i, n) {
    fill(ndp.begin(), ndp.end(), ll{0});
    int k = s[i] - '0';
    rep(j, 2019) {
      int nj = (10 * j + k) % 2019;
      ndp[nj] += dp[j];
    }
    ndp[k] += 1;
    ans += ndp[0];
    dp = ndp;
  }

  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3756
import java.util.*;

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

        int A = sc.nextInt();
        int B = sc.nextInt();

        if(A*B>=100 || A>=10 || B>=10){
            System.out.println(-1);
        }
        else if(A*B<100 && A<10 && B<10){
            System.out.println(A*B);
        }
    }
}

Measured memory_bytes: 21716
#include <iostream>
#include <numeric>
inline int read(){
	int x=0,f=1;char c=getchar();
	while(!isdigit(c)){if(c=='-')f=-1;c=getchar();}
	while(isdigit(c)){x=x*10+c-'0';c=getchar();}
	return x*f;
}

int cnt[1000001];
int main(){
  int n = read();
  int o = 0, g;
  int ex = n/4;

  for(int i=0;i<ex;i++){
    int num = read();
    if(num==1) o++;
    if(i==0) g = num;
    else g = std::gcd(g, num);
    cnt[num]++;

    num = read();
    if(num==1) o++;
    g = std::gcd(g, num);
    cnt[num]++;

    num = read();
    if(num==1) o++;
    g = std::gcd(g, num);
    cnt[num]++;

    num = read();
    if(num==1) o++;
    g = std::gcd(g, num);
    cnt[num]++;
  }

  for(int i=0;i<n%4;i++){
    int num = read();
    if(num==1) o++;
    g = std::gcd(g, num);
    cnt[num]++;
  }

  if(n - o > 80000){
    if(g==1) printf("setwise coprime\n");
    else printf("not coprime\n");
    return 0;
  }

  int max_S = 0;
  for(int i=2;i<=1000000;i++){
    int S = 0;
    for(int j=i;j<=1000000;j+=i) S += cnt[j];
    if(max_S<S) max_S = S;
  }
  if(max_S<2) printf("pairwise coprime\n");
  else if(max_S != n) printf("setwise coprime\n");
  else printf("not coprime\n");
}


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

using namespace std;

#define sim template <class c
#define ris return *this
#define dor > debug &operator<<
#define eni(x)                                                                        \
	sim > typename enable_if<sizeof dud<c>(0) x 1, debug &>::type operator<<(c i) \
	{
sim > struct rge
{
	c b, e;
};
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c *x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug
{
#ifdef LOCAL
	~debug()
	{
		cerr << endl;
	}
	eni(!=) cerr << boolalpha << i;
	ris;
} eni(==) ris << range(begin(i), end(i));
}
sim, class b dor(pair<b, c> d)
{
	ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d)
{
	*this << "[";
	for (auto it = d.b; it != d.e; ++it)
		*this << ", " + 2 * (it == d.b) << *it;
	ris << "]";
}
#else
	sim dor(const c &)
	{
		ris;
	}
#endif
}
;
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

#define forn(i, n) for (ll i = 0; i < int(n); i++)
#define rfor(n, i) for (ll i = (n - 1); i >= 0; --i)
#define all(V) V.begin(), V.end()
#define rall(V) V.rbegin(), V.rend()
#define len(V) (int)V.size()
#define ll long long
#define ld long double
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define endl '\n'
#define M_PI 3.14159265358979323846
#define EPS 1e-7

void solve()
{	
	int n; cin >> n;
	vector<ll> a(n);
	forn (i, n) cin >> a[i];
	vector<ll> res(n);
	if (n % 2 == 0)
	{
		res[n / 2] = a[0];
		int c = 1;
		for (int i = 1; i <= n / 2; i++)
		{
			res[n / 2 - i] = a[c];
			c++;
			res[n / 2 + i] = a[c];
			c++;
		}
		res[0] = a[n - 1];
	}
	else
	{
		int c = 1;
		res[n / 2] = a[0];
		for (int i = 1; i <= n / 2; i++)
		{
			res[n / 2 + i] = a[c];
			c++;
			res[n / 2 - i] = a[c];
			c++;
		}
	}
	
	forn(i, n) cout << res[i] << ' ';
}

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


Measured memory_bytes: 6360
def split_returner(chardata):
        chardata = str(chardata).split(" ")
        for i in range(0,len(chardata)):
            chardata[i] = int(chardata[i])
        return chardata

ab = split_returner(str(input()))
result = 0
for i in range(0,2):
    if ab[0] > ab[1]:
        result+= ab[0]
        ab[0] = ab[0] -1
    else:
        result += ab[1]
        ab[1] = ab[1] - 1
print(result)

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

int main () {

    int N;
    scanf("%d", &N);

    int a[N];

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

    int ans = 0;

    for (int i = 0; i < N; i++) {
        ans += (a[i] - 1);
    }
    printf("%d\n", ans);

    return 0;
}

Measured memory_bytes: 256
fun main(args: Array<String>) {
    val (h, w) = readLine()?.split(" ")?.map(String::toInt) ?: return
    val m = mutableListOf<CharArray>()
    repeat(h) {
        m.add(readLine()?.toCharArray() ?: return)
    }

    0.until(h).forEach { y ->
        0.until(w).forEach { x ->
            val p = m[y][x]
            var count = 0
            if (p == '.') {
                if (y - 1 >= 0) {
                    if (m[y - 1][x] == '#') {
                        count++
                    }
                    if (x - 1 >= 0) {
                        if (m[y - 1][x - 1] == '#') {
                            count++
                        }
                    }
                    if (x + 1 < w) {
                        if (m[y - 1][x + 1] == '#') {
                            count++
                        }
                    }
                }
                if (x - 1 >= 0) {
                    if (m[y][x - 1] == '#') {
                        count++
                    }
                }
                if (x + 1 < w) {
                    if (m[y][x + 1] == '#') {
                        count++
                    }
                }
                if (y + 1 < h) {
                    if (m[y + 1][x] == '#') {
                        count++
                    }
                    if (x - 1 >= 0) {
                        if (m[y + 1][x - 1] == '#') {
                            count++
                        }
                    }
                    if (x + 1 < w) {
                        if (m[y + 1][x + 1] == '#') {
                            count++
                        }
                    }
                }
                m[y][x] = count.toString().first()
            }
        }
    }
    println(m.joinToString("\n") { it.joinToString(separator = "") })
}


Measured memory_bytes: 37996
# input
N, K = map(int, input().split())
S = list(input())

if S[K - 1] == "A":
    S[K - 1] = "a"
elif S[K - 1] == "B":
    S[K - 1] = "b"
else:
    S[K - 1] = "c"

print("".join(S))

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=1;i<=n;i++)
# define ALL(x) (x).begin(), (x).end()
# define SZ(x) ((int)(x).size())
# define pb push_back
using namespace std;


int main(){
    int n,d=0,e=0;
    cin>>n;
    vector<int> a(n);
    rep(i,n) cin>>a[i];
    
    if(n % 2 != 0){
        rep(i,n) if(a[i]%2!=0) d++;
        if(d % 2==0){
            cout<<"YES"<<endl;
            return 0;
        }else{
            cout<<"NO"<<endl;
            return 0;
        }
    }
    else{
        rep(i,n){
            if(a[i]%2!=0) d++;
            else e++;
        }
        if(d%2==0 && e%2==0){
            cout<<"YES"<<endl;
                return 0;
            }else{
                cout<<"NO"<<endl;
                return 0;
            }
        }
    return 0;
}


Measured memory_bytes: 640
# include<bits/stdc++.h>
using namespace std ;
int main () {
// input
int N; cin >> N ;
vector <int > V ( N );
for ( int i = 0; i < N ; ++ i ) {
cin >> V [ i ];
}
vector <int > C ( N );
for ( int i = 0; i < N ; ++ i ) {
cin >> C [ i ];
}
// compute
int ans = 0;
for ( int i = 0; i < N ; ++ i ) {
if ( V [ i ] > C [ i ]) {
ans += V [ i ] - C [ i ];
}
}
// output
cout << ans << endl ;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
#include <math.h>
#include <array>

int main(void) {
	int N;
	std::cin >> N;
	double n = static_cast<double>(N) / 1.08;
	
	
	int x = ceil(n);
	if (n < 12) {
		std::cout << N;
	}
	else if (x - n >= 1.0 / 1.08) {
		std::cout << ":(";
	}
	else {
		std::cout << x;
	}

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(I,X,Y) for(int (I)=(X);(I)<(Y);(I)++)
#define REP(I,X,Y) for(int (I)=(Y)-1;(I)>=(X);(I)--)
#define ALL(X) (X).begin(),(X).end()
#define INF 1000000007
#define LINF 1000000000000000007
typedef long long ll;
using namespace std;

int main(){
  int H,W;
  cin >> H >> W;
  int a[H][W];
  vector<vector<int>> v(H);
  vector<int> lasting;
  vector<tuple<int,int,int,int>> ans;
  FOR(i,0,H)FOR(j,0,W)cin >> a[i][j];
  FOR(i,0,H)FOR(j,0,W)a[i][j] %= 2;
  FOR(i,0,H)FOR(j,0,W)if(a[i][j])v[i].push_back(j);
  FOR(i,0,H){
    if((v[i].size())%2){
      FOR(j,0,((int)v[i].size())/2){
        int l = v[i][2*j]+1;
        int r = v[i][2*j+1]+1;
        FOR(k,l,r)ans.push_back(make_tuple(i+1,k,i+1,k+1));
      }
      int l = v[i][(int)v[i].size()-1]+1;
      int r = W;
      FOR(k,l,r)ans.push_back(make_tuple(i+1,k,i+1,k+1));
      lasting.push_back(i);
    }
    else if(v[i].size()){
      FOR(j,0,((int)v[i].size())/2){
        int l = v[i][2*j]+1;
        int r = v[i][2*j+1]+1;
        FOR(k,l,r)ans.push_back(make_tuple(i+1,k,i+1,k+1));
      }
    }
  }
  FOR(i,0,((int)lasting.size())/2){
    int l = lasting[2*i]+1;
    int r = lasting[2*i+1]+1;
    FOR(k,l,r)ans.push_back(make_tuple(k,W,k+1,W));
  }
  cout << ans.size() << endl;
  for(auto x:ans)printf("%d %d %d %d\n",get<0>(x),get<1>(x),get<2>(x),get<3>(x));
}


Measured memory_bytes: 6128
a, b, k = input().split()
a = int(a)
b = int(b)
k = int(k)

first_a = a
a -= k if k < a else a
k -= first_a if a == 0 else 0
b -= 0 if a != 0 else k
b = 0 if b < 0 else b

print(a, end=" ")
print(b)


Measured memory_bytes: 3060
h, w = map(int, input().split())
n = int(input())
alist = list(map(int, input().split()))
cmap = [[-1 for _ in range(w)] for _ in range(h)]
i = 0
for ai, a in enumerate(alist):
  ai += 1
  for _a in range(a):
    if ((i + _a) // w) % 2 == 0:
      cmap[(i + _a) // w][(i + _a) % w] = ai
    else:
      cmap[(i + _a) // w][-((i + _a) % w + 1)] = ai
  i += a

for cm in cmap:
  print(*cm, sep=' ')


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

#define int long long
#define fast_io(); ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define loop(i,a,b) for(int i=a;i<b;i++)
#define all(x) x.begin(),x.end()
#define us unordered_set
#define um unordered_map
#define ms multiset
#define mm multimap
#define pb push_back
#define pf push_front
#define ins insert
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define _max max_element
#define _min min_element
#define tc(T) int T; cin>>T; while(T--)
#define q(q) int q; cin>>q; while(q--)
#define pi 3.1415926535897932384626433832
const int pinf=((int)2e18);
const int ninf=((int)-2e18);
const int mod=1000000007;

using namespace std;

int power(int x,int n,int M)
{
    if(n==0)
        return 1;
    else if(n%2 == 0)
        return power((x*x)%M,n/2,M);
    else
        return (x*power((x*x)%M,(n-1)/2,M))%M;
}

bool vowel(char c)
{
    return(c=='a' or c=='e' or c=='i' or c=='o' or c=='u' or c=='A' or c=='E' or c=='I' or c=='U' or c=='O');
}

bool cp(int n)
{
    if(n<2)
        return 0;

    for(int i=2;i<=sqrt(n);i++)
    {
        if(n%i==0)
            return false;
    }
    return true;
}

int32_t main()
{
    fast_io();

    //FILE *fptr1=freopen("in.txt","r",stdin);
    //FILE *fptr2=freopen("out.txt","w",stdout);

    int n;
    cin>>n;
    vector <int> a(n);
    int mn,mx;
    loop(i,0,n)
    {
        cin>>a[i];
        mn=a[0];
        mx=a[0];
    }

    int c=1;
    loop(i,1,n)
    {
        mn=min(mn,a[i]);
        mx=max(mx,a[i]);
        if(a[i]==mn)
        {
            c++;
        }
    }
    cout<<c;

    return 0;
}


Measured memory_bytes: 4796
class UnionFind():
    def __init__(self, n):
        self.parent = [-1 for _ in range(n)]
        # 正==子: 根の頂点番号 / 負==根: 連結頂点数

    def find(self, x):
        if self.parent[x] < 0:
            return x
        else:
            self.parent[x] = self.find(self.parent[x])
            return self.parent[x]

    def unite(self, x, y):
        x, y = self.find(x), self.find(y)
        if x == y:
            return False
        else:
            if self.size(x) < self.size(y):
                x, y = y, x
            self.parent[x] += self.parent[y]
            self.parent[y] = x

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def size(self, x):
        x = self.find(x)
        return -self.parent[x]

    def is_root(self, x):
        return self.parent[x] < 0

n, m = map(int, input().split())
p = list(map(int, input().split()))
pair_list = []
count = 0
for i in range(m):
    array = list(map(int,input().split()))
    array[0] -=1 ; array[1] -= 1
    pair_list.append(array)

uf = UnionFind(len(p))

for i in range(m):
    uf.unite(pair_list[i][0], pair_list[i][1])

for i in range(n):
    uf.find(i)

for i in range(n):
    if p[i] == i+1:
        count += 1
    else:
        if uf.same(p[i]-1, p[p[i]-1]-1) is True:
            count += 1
        else:
            continue
print(count)


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

using E = System.Linq.Enumerable;

public class Program
{
    public static void Main()
    {
        var n = int.Parse(Console.ReadLine());
        var seqA = new int[n + 1][];
        for (int i = 1; i < seqA.Length; ++i)
        {
            seqA[i] = Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray();
        }

        var numGames = (n * (n - 1)) / 2;
        var adjList = new int[numGames + 1][];
        for (int i = 1; i < adjList.Length; ++i)
        {
            adjList[i] = new int[2];
        }

        Func<int, int, int> gameId = (_x, _y) => 0;
        gameId = (x, y) => x < y ? y - x + numGames - (n - x + 1) * (n - x) / 2 : gameId(y, x);

        var unplayableAtFirstDay = new List<int>();
        for (int i = 1; i < seqA.Length; ++i)
        {
            for (int j = 1; j < seqA[i].Length; ++j)
            {
                int h = gameId(i, seqA[i][j]);
                int t = gameId(i, seqA[i][j - 1]);
                unplayableAtFirstDay.Add(h);
                for (int k = 0; k < adjList[t].Length; ++k)
                {
                    if (adjList[t][k] > 0)
                    {
                        continue;
                    }

                    adjList[t][k] = h;
                    break;
                }
            }
        }
        adjList[0] = unplayableAtFirstDay.ToArray();

        var day = adjList[0].Length > 0 ? Dfs(E.Repeat(int.MinValue, adjList.Length).ToArray(), adjList, new bool[adjList.Length], 0) : -1;
        Console.WriteLine(day);
    }

    static int Dfs(int[] memo, int[][] adjList, bool[] path, int t)
    {
        if (path[t])
        {
            return memo[t] = -1;
        }
        if (memo[t] != int.MinValue)
        {
            return memo[t];
        }

        var r = 1;
        path[t] = true;
        for (int i = 0; i < adjList[t].Length; ++i)
        {
            int h = adjList[t][i];
            if (h < 1)
            {
                break;
            }
            
            var rr = Dfs(memo, adjList, path, h);
            if (rr < 0)
            {
                r = rr;
                break;
            }
            r = Math.Max(r, rr + 1);
        }
        path[t] = false;

        return memo[t] = r;
    }
}


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

#define fastio {\
    ios::sync_with_stdio(0);\
    cin.tie(0);\
}

#define file {\
    freopen("io\\in.txt", "r", stdin);\
    freopen("io\\out.txt", "w", stdout);\
    freopen("io\\err.txt", "w", stderr);\
}

#ifdef LOCAL
#define debug(args...) {\
    string _s(#args);\
    replace(_s.begin(), _s.end(), ',', ' ');\
    stringstream _ss(_s);\
    istream_iterator<string> _it(_ss);\
    debug1(_it, args);\
}

#pragma GCC diagnostic ignored "-Wunused-parameter"
void debug1(istream_iterator<string> it) {
    cerr << endl;
}
#pragma GCC diagnostic pop

template<class T, class... Args>
void debug1(istream_iterator<string> it, T a, Args... args) {
    cerr << '>' << *it << " = " << a << "; ";
    debug1(++it, args...);
}
#else
#define debug(args...)
#define cerr if (false) cerr
#endif

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using si = set<int>;
using ii = pair<int, int>;
using vii = vector<ii>;

#define rep(i, n)   for (int i = 0; i < n; i++)
#define dotc()      int tcs; if (cin >> tcs) rep(tc, tcs)
#define sz(x)       (int)x.size()
#define eb          emplace_back
#define pb          push_back
#define mp          make_pair
#define mt          make_tuple
#define all(x)      x.begin(), x.end()
#define rall(x)     x.rbegin(), x.rend()
#define fi          first
#define se          second

const int inf(0x3fffffff);
const int mod(1000000007);
const double pi(acos(-1.0));

signed main() {
    fastio;
#ifdef LOCAL
    file;
#endif

    int n;
    cin >> n;
    vi a(n + 1);

    for (int i = 1;; i++) {
        if (i * i + 2 + i + 1 + i > n) break;
        for (int j = 1;; j++) {
            if (i * i + j * j + 1 + i * j + i + j > n) break;
            for (int k = 1;; k++) {
                if (i * i + j * j + k * k + i * j + i * k + j * k > n) break;
                a[i * i + j * j + k * k + i * j + i * k + j * k]++;
            }
        }
    }

    for (int i = 1; i <= n; i++) cout << a[i] << '\n';

    return 0;
}


Measured memory_bytes: 3572
#include <bits/stdc++.h>
using namespace std;
     
int c[3][3];

void solve() {
    int a[3], b[3];
    a[0] = 0;
    b[0] = c[0][0];
    b[1] = c[0][1];
    b[2] = c[0][2];
    a[1] = c[1][0] - b[0];
    a[2] = c[2][0] - b[0];

    if (c[1][1] == a[1] + b[1] && c[1][2] == a[1] + b[2] && c[2][1] == a[2] + b[1] && c[2][2] == a[2] + b[2]) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}

int main() {
    for (int i = 0; i < 3; i++) {
        for (int j = 0; j < 3; j++) {
            cin >> c[i][j];
        }
    }
    solve();
}

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

int main() {
    int times, length;
    cin >> times >> length;

    string previous, current, next;

    for(int i = 0; i < times; i++) {
        if(i == 0) {
            cin >> current >> next;
        } else if(i == times - 1) {
            current = next;
        } else {
            current = next;
            cin >> next;
        }
        for(int j = 0; j < length ; j++) {
            int count = 0;
            if(current.at(j) == '.') {
                // check previouline
                if(i != 0) {
                    if(j != 0 && previous.at(j - 1) == '#') {
                        count++;
                    }
                    if(previous.at(j) == '#') count++;
                    if((j != length -1) && previous.at(j + 1) == '#') {
                        count++;
                    }
                }            
                // check current
                if(j != 0 && current.at(j - 1) == '#') {
                    count++;
                }
                if((j != length -1) && current.at(j + 1) == '#') {
                    count++;
                }
                // check next
                if(i != times - 1) {
                    if(j != 0 && next.at(j - 1) == '#') {
                        count++;
                    }
                    if(next.at(j) == '#') count++;
                    if((j != length -1) && next.at(j + 1) == '#') {
                        count++;
                    }
                }            
                current.at(j) = '0' + count;
            }
        }
        cout << current << endl;
        previous = current;
    }


    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(int i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

int main() {
  char c;
  cin >> c;
  if(c == 'A')
    cout << 'T' << endl;
  else if(c == 'T')
    cout << 'A' << endl;
  else if(c == 'C')
    cout << 'G' << endl;
  else
    cout << 'C' << endl;
}

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

int main() {
	ll A, B, K;
	cin >> A >> B >> K;

	if (A >= K) A -= K;
	else if (A < K) {
		K -= A;
		A = 0;
		if (B >= K) B -= K;
		else if (B < K) {
			B = 0;
		}
	}

	cout << A << " " << B << endl;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
# 入力
n = int(input())

# 処理

def gen_prime():
    primes = []
    n = 2
    while True:
        is_prime_flag = True
        for p in primes:
            if n % p == 0:
                is_prime_flag = False
                break
        if is_prime_flag:
            primes.append(n)
            yield n
        n += 1

MAX_N = 55555

ns = []

for p in gen_prime():
    if p > MAX_N or len(ns) >= n:
        break

    if p % 5 == 1:
        ns.append(p)

ans = " ".join(map(str, ns))

# 出力
print(ans)


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int a, b, c;
  cin >> a >> b >> c;
  int num;
  num = b / a;
  if(num > c) {
      cout << c <<'\n';
  } else {
      cout << num << '\n';
  }
}

Measured memory_bytes: 256
import Control.Applicative
import Text.Printf

solver :: Int -> Int -> Double
solver a b = fromIntegral a / fromIntegral b


main :: IO()
main = do
  (a:b:_) <- map (read :: String -> Int) . words <$> getLine
  printf "%d %d %.5f\n" (a `div` b) (a `mod` b) (solver a b)

Measured memory_bytes: 3872
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<math.h>
#include<queue>
#include<deque>
#include<stack>
#include<cstdio>
#include<utility>
#include<set>
#include<list>
#include<cmath>
#include<stdio.h>
#include<string.h>
#include<iomanip>
using namespace std;
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define REP(i, n) FOR(i, 0, n - 1)
#define NREP(i, n) FOR(i, 1, n)
using ll = long long;
using pii = pair<int, int>;
using piii = pair<pii, pii>;
const int dx[4] = { 0, -1, 1, 0 };
const int dy[4] = { -1, 0, 0, 1 };
const int INF = 1e9 + 7;
int gcd(int x, int y) {
	if (x < y)swap(x, y);
	if (y == 0)return x;
	return gcd(y, x%y);
}

template<class T1, class T2> void chmin(T1 &a, T2 b) { if (a>b)a = b; }

template<class T1, class T2> void chmax(T1 &a, T2 b) { if (a<b)a = b; }
template<class T>
void Add(T &a, const T &b, const T &mod = 1000000007) {
	int val = ((a % mod) + (b % mod)) % mod;
	if (val < 0) { val += mod; }
	a = val;
}
////////////////////////////////////////
// vector v において、x の前方と後方の index を求める
template<class T> int former(const vector<T> &v, T x) {
	return upper_bound(v.begin(), v.end(), x) - v.begin() - 1;
}
template<class T> int latter(const vector<T> &v, T x) {
	return lower_bound(v.begin(), v.end(), x) - v.begin();
}

int main() {
	int A, B, Q;
	cin >> A >> B >> Q;
	vector<ll>s(A), t(B);
	for (int i = 0; i < A; ++i)cin >> s[i];
	for (int i = 0; i < B; ++i)cin >> t[i];
	s.push_back(1e17); s.push_back(-1e17); sort(s.begin(), s.end());
	t.push_back(1e17); t.push_back(-1e17); sort(t.begin(), t.end());
	for (int i = 0; i < Q; ++i) {
		ll x; cin >> x;
		ll res = 1e20;
		//最初にs（前方に行くか後方に行くか場合分け)
		for (int j = 0; j < 2; ++j) {
			ll first = (j ? s[former(s, x)] : s[latter(s, x)]);
			for (int k = 0; k < 2; ++k) {
				ll second = (k ? t[former(t, first)]:t[latter(t, first)]);
				chmin(res, abs(x - first) + abs(first - second));
			}
		}
		for (int j = 0; j < 2; ++j) {
			ll first = (j ? t[former(t, x)] : t[latter(t, x)]);
			for (int k = 0; k < 2; ++k) {
				ll second = (k ? s[former(s, first)] : s[latter(s, first)]);
				chmin(res, abs(x - first) + abs(first - second));
			}
		}
		cout << res << endl;
	}
	return 0;
}

Measured memory_bytes: 2912
#include <bits/stdc++.h>
using namespace std;
#define int long long int
#define endl "\n"
const int mod=1e9+7;
const int INF =LONG_LONG_MAX;
inline int gcd(int a,int b){if(a==0) return b;return gcd(b%a,a);}
inline int pow(int a,int n,int mod){if(n==0)return 1;int p=pow(a,n/2,mod);p=(p%mod*p%mod)%mod;if(n%2) return (p%mod*a%mod)%mod;else return p;}
vector<int>adj[100001];
vector<int>visited(100001,0);
vector<int>ans;
vector<int>dist(100001,0);
vector<int>degree(100001,0);
void dfs(int s)
{
    visited[s]=1;
    for(int i=0;i<adj[s].size();i++)
    {
        int child=adj[s][i];
        if(!visited[child])
        {
            dist[child]=max(dist[child],dist[s]+1);
            degree[child]--;
            if(degree[child]==0)
                dfs(child);
        }
    }
    ans.push_back(s);
}
int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int n,m;
    cin>>n>>m;

    for(int i=0;i<m;i++)
    {
        int x,y;
        cin>>x>>y;
        degree[y]++;
        adj[x].push_back(y);
    }
   for(int i=1;i<=n;i++)
   {
       if(!visited[i]&&degree[i]==0)
        dfs(i);
   }
    vector<int>dp(n+1,0);
  int max1=-1;
    for(int i=1;i<=n;i++)
    {
        max1=max(max1,dist[i]);
    }
    cout<<max1<<endl;
    return 0;
}


Measured memory_bytes: 12916
import java.io.*;
import java.util.*;
public class Main {        
    public static void main(String args[]) {
        int n=II();
        char s[]=IS().toCharArray();
        int ctr=0;
        for(int i=0;i<n;i++){
            if(s[i]=='R')
                ctr++;
        }
        int ans=0;
        for(int i=0;i<ctr;i++){
            if(s[i]!='R')
                ans++;
        }
        System.out.println(ans);
    }
    
    ////////////////////////////////////
    static scan in=new scan(System.in);
    static int II() {
        return in.nextInt();
    }
    static long IL() {
        return in.nextLong();
    }
    static int[] IIA(int n) {
        int a[]=new int[n];
        for(int i=0;i<n;i++) {
            a[i]=II();
        }
        return a;
    }
    static String IS() {
        return in.next();
    }
    static char IC(){
        return in.next().charAt(0);
    }
    static String[] ISA(int n) {
        String a[]=new String[n];
        for(int i=0;i<n;i++) {
            a[i]=IS();
        }
        return a;
    }
    static char[] ICA(int n) {
        char a[]=new char[n];
        for(int i=0;i<n;i++) {
            a[i]=IC();
        }
        return a;
    }
}
class scan
{
    public static BufferedReader reader;
    public static StringTokenizer token;

    scan(InputStream str)
    {
        reader=new BufferedReader(new InputStreamReader(str));
        token=null;
    }

    static int nextInt()
    {
        while(token==null||!token.hasMoreTokens())
        {
            try { token=new StringTokenizer(reader.readLine());   }
            catch(IOException e){  throw new RuntimeException(e); }
        }
        return Integer.parseInt(token.nextToken());
    }

    static long nextLong()
    {
        while(token==null||!token.hasMoreTokens())
        {
            try { token=new StringTokenizer(reader.readLine());   }
            catch(IOException e){  throw new RuntimeException(e); }
        }
        return Long.parseLong(token.nextToken());
    }

    static String next()
    {
        while(token==null||!token.hasMoreTokens())
        {
            try { token=new StringTokenizer(reader.readLine());   }
            catch(IOException e){  throw new RuntimeException(e); }
        }
        return token.nextToken();
    }

}

Measured memory_bytes: 29936
#include <cstdio>
#include <iostream>
#include <string>
#include <sstream>
#include <stack>
#include <algorithm>
#include <cmath>
#include <queue>
#include <map>
#include <set>
#include <cstdlib>
#include <bitset>
#include <tuple>
#include <assert.h>
#include <fstream>
#include <bitset>
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; }

const long long INF = 1LL << 60;
const long long MOD = 1000000007LL;
const long long MAX = 500000LL;
using namespace std;
typedef unsigned long long ull;
typedef  long long ll;
using T = tuple<ll, ll, ll>;


struct SegmentTree {
private:
	ll n;
	vector<ll> node;
public:
	SegmentTree(vector<ll> v) {
		ll sz = v.size();
		n = 1; while (sz > n) n *= 2;
		node.resize(2 * n - 1, INF);

		for (ll i = 0; i < sz; i++) {
			node[i + n - 1] = v[i];
		}
		for (ll i = n - 2; i >= 0; i--) {
			node[i] = min(node[i * 2 + 1], node[i * 2 + 2]);
		}
	}

	void update(ll x, ll val) {
		x += n - 1;
		node[x] = val;

		while (x > 0) {
			x = (x - 1) / 2;
			node[x] = min(node[x * 2 + 1], node[x * 2 + 2]);
		}
	}

	ll getmin(ll a, ll b, ll k = 0, ll l = 0, ll r = -1) {
		if (r < 0) r = n;
		if (r <= a || b <= l) return INF;
		if (a <= l && r <= b) return node[k];

		ll vl = getmin(a, b, 2 * k + 1, l, (l + r) / 2);
		ll vr = getmin(a, b, 2 * k + 2, (l + r) / 2, r);
		return min(vl, vr);
	}
};


int main()
{	
	ll N, Q;
	cin >> N >> Q;

	ll ini = 1;
	for (ll i = 0; i < 31; i++) {
		ini *= 2;
	}
	ini--;
	vector<ll> a(N, ini);
	SegmentTree seg(a);
	for (ll i = 0; i < Q; i++) {
		ll c, x, y;
		cin >> c >> x >> y;
		if (c == 0) {
			seg.update(x, y);
		}
		else {
			cout << seg.getmin(x, y + 1) << endl;
		}
	}
	return 0;
}



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

int main() {
    long H;
    cin >> H;
    
    int N = log2(H);
    long ans = 1;

    for(int i = 0; i < N; ++i){
        ans = ans * 2 + 1;
    }

    cout << ans << endl;
}

Measured memory_bytes: 512
import java.util.*;


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

        ArrayList<Character> anagramA = new ArrayList<Character>();
        for(int i = 0; i < a.length(); i++){
            char c = a.charAt(i);
            int insertIndex = anagramA.size();
            for(int j = 0; j < anagramA.size(); j++){
                if(insertIndex == anagramA.size() && c <= anagramA.get(j)){
                    insertIndex = j;
                }
            }
            anagramA.add(insertIndex, c);
        }
        ArrayList<Character> anagramB = new ArrayList<Character>();
        for(int i = 0; i < b.length(); i++){
            char c = b.charAt(i);
            int insertIndex = anagramB.size();
            for(int j = 0; j < anagramB.size(); j++){
                if(insertIndex == anagramB.size() && c >= anagramB.get(j)){
                    insertIndex = j;
                }
            }
            anagramB.add(insertIndex, c);
        }

        String ans = "No";

        for(int i = 0; i < Math.min(anagramA.size(), anagramB.size()); i++){
            if(anagramA.get(i) < anagramB.get(i)){
                ans = "Yes";
                break;
            }else if(anagramA.get(i) > anagramB.get(i)){
                break;
            }else if(i == Math.min(anagramA.size(), anagramB.size())-1 && anagramA.size() < anagramB.size()){
                ans = "Yes";
            }
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 21844
#include <iostream>
#include <algorithm>
#include <cmath>

typedef long long ll;

using namespace std;

int main(void){
	ll n; cin >> n;
	ll ans = 0;
	
	for(ll i=1; i<sqrt(n); i++){
		ll p = n/i - 1;
		if(n % i != 0) continue;
		if(p <= i) continue;
		ans += p;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<vector>
#include<deque>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<algorithm>
#include<functional>
#include<utility>
#include<bitset>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<cstdio>
using namespace std;
long long n,m,cnt,ans;
pair<int,int>a[101010];
int main()
{
	cin>>n>>m;
	for(int i=0;i<n;i++)
	{
		cin>>a[i].first>>a[i].second;
	}
	sort(a,a+n);
	priority_queue<int>pq;
	for(int i=1;i<=m;i++)
	{
		while(cnt<n && a[cnt].first<=i)
		{
			pq.push(a[cnt].second);
			cnt++;
		}
		if(!pq.empty())
		{
			ans+=pq.top();
			pq.pop();
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 1660
#include <iostream>

using namespace std;

int main(){
  int h1, m1, h2, m2, k;
  cin >> h1 >> m1 >> h2 >> m2 >> k;

  h1 = h1 * 60;
  h2 = h2 * 60;
  int time1 = h1 + m1;
  int time2 = h2 + m2;
  int ans = time2 - time1 - k;

  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3632
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <math.h>
#define MOD 1000000007
typedef long long ll;
using namespace std;

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

  int r=0;
  for(int i=1;;i++){
    if(pow(2,i)<=L) r=i;
    else break;
  }

  int R=pow(2,r);
  int n=r+1;
  int m=2*r;
  vector<int> a,b,c;
  for(int i=1;i<=r;i++){
    a.push_back(i);
    b.push_back(i+1);
    c.push_back(0);
    a.push_back(i);
    b.push_back(i+1);
    c.push_back(pow(2,i-1));
  }

  for(int i=r;i>0;i--){
    if(L-pow(2,i-1)>=R){
      a.push_back(i);
      b.push_back(n);
      c.push_back(L-pow(2,i-1));
      L-=pow(2,i-1);
      m++;
    }
  }

  cout<<n<<" "<<m<<endl;
  for(int i=0;i<m;i++){
    cout<<a[i]<<" "<<b[i]<<" "<<c[i]<<endl;
  }

  return 0;
}


Measured memory_bytes: 384
#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 = 1e9;
ll 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 = (r * 2 + l) / 3;
    f(x, c1) > f(x, c2) ? l = c1 : 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 = (r * 2 + l) / 3;
    g(c1) > g(c2) ? l = c1 : r = c2;
  }

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


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <numeric>
#include <unordered_map>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <memory>


using namespace std;

typedef long long ll;
typedef unsigned long long ull;
long long MOD = 1e9 + 7;
constexpr ll INF = 1e17;

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

    int n;
    cin >> n;

    map<string, ll> hashMap;

    ll ans = 0;
    for (int i = 0; i < n; i++)
    {
        string s;
        cin >> s;
        std::sort(s.begin(), s.end());
        hashMap[s]++;
    }
    for (const auto& e : hashMap) {
        ans += e.second * (e.second - 1) / 2;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 11264
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>

using namespace std;

int main(void){
  int N,T,A;
  cin >>N;
  cin >>T>>A;
  int H[N];
  int point;
  double min=1<<30;
  double diff;
  for (int i=0;i<N;i++) {
    cin >>H[i];
    
    if (A-(T-H[i]*0.006)<0){
      diff=-(A-(T-H[i]*0.006));
    }else{
      diff=A-(T-H[i]*0.006);
    }
    if (min>diff){
      point=i;
      min=diff;
    }
  }
  cout <<point+1<<endl;
  return 0;
}


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

namespace AtCoder.E
{
    public class Program
    {
        public static void Main() { var r = GetResult(); Debug.WriteLine(r); Console.Write(r); }

        private static object GetResult()
        {
            var (H, W, M) = Read3Longs();
            var hCount = new long[H];
            var wCount = new long[W];
            var existsBom = new HashSet<string>();
            for (var i = 0; i < M; i++)
            {
                var (h, w) = Read2Longs();
                h--; w--;//インデックス変換
                hCount[h]++;
                wCount[w]++;
                existsBom.Add(h + "-" + w);
            }

            var hMax = hCount.Max();
            var wMax = wCount.Max();

            // 無謀な計算を排除
            if (hMax == 0) return wMax;
            if (wMax == 0) return hMax;

            var hMaxIndexes = Enumerable.Range(0, (int)H)
                .Where(x => hCount[x] == hMax).ToList();
            var wMaxIndexes = Enumerable.Range(0, (int)W)
                .Where(x => wCount[x] == wMax).ToList();

            foreach (var hIndex in hMaxIndexes)
            {
                foreach (var wIndex in wMaxIndexes)
                {
                    if (!existsBom.Contains(hIndex + "-" + wIndex))
                    {
                        return hMax + wMax;
                    }
                }
            }

            return hMax + wMax - 1;
        }

        #region Console.Read

        public static string ReadText() { return Console.ReadLine(); }
        public static List<string> ReadTexts() { return Console.ReadLine().Split(' ').ToList(); }
        public static long ReadLong() { return long.Parse(Console.ReadLine()); }
        public static (long, long) Read2Longs() { var ls = ReadLongs(); return (ls[0], ls[1]); }
        public static (long, long, long) Read3Longs() { var ls = ReadLongs(); return (ls[0], ls[1], ls[2]); }
        public static (long, long, long, long) Read4Longs() { var ls = ReadLongs(); return (ls[0], ls[1], ls[2], ls[3]); }
        public static (long, long, long, long, long) Read5Longs() { var ls = ReadLongs(); return (ls[0], ls[1], ls[2], ls[3], ls[4]); }
        public static List<long> ReadLongs() { return Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToList(); }

        #endregion
    }
}


Measured memory_bytes: 76928
N = int(input())
A = list(map(int, input().split()))

A.sort(reverse = True)

T = []
for i in range(N-1):
    if i > 1 and  A[i] == A[i-1] and not(A[i] == A[i-2]): continue
    if i == 1 and A[i] == A[i-1]: continue

    if A[i] == A[i+1]:
        T.append(A[i])
    if len(T) >= 2: break

if len(T) < 2: print(0)
else: print(T[0]*T[1])
    


Measured memory_bytes: 14252
#include<stdio.h>
#include<stdlib.h>

void run(void){
  int n,k;
  scanf("%d%d",&n,&k);
  int a[100];
  int i,j;
  for(i=0;i<n;i++) scanf("%d",a+i);
  int *dp=(int *)calloc(k+1,sizeof(int));
  for(i=1;i<=k;i++){
    int win=0;
    for(j=0;j<n && a[j]<=i;j++){
      if(dp[i-a[j]]==0){
	win=1;
      }
    }
    dp[i]=win;
  }
  printf("%s\n",dp[k]?"First":"Second");
}

int main(void){
  run();
  return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a[]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    int k;
    cin>>k;
    cout<<a[k-1]<<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() {
    string s;
    cin >> s;
    int red = 0,blue = 0;
    rep(i,s.length()){
        if(s[i] == '0'){
            red++;
        }else{
            blue++;
        }
    }
    if(red > blue){
        cout << blue * 2 << endl;
    }else{
        cout << red * 2 << endl;
    }
    return 0;
}

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

int main(){
  string s;
  cin >> s;
  //bool ac=true;
  string ac="AC";
  int counter=0,res=0;
  if(s[0]=='A'){
    for(int i=2;i<s.size()-1;++i){
      if(s[i]=='C'){
        counter++;
      }
    }
    if(counter!=1){
      ac="WA";
    }
    for(int i=0;i<s.size();++i){
      if((int)s[i]>=(int)'a'&&(int)s[i]<=(int)'z')res++;
    }
    if(res!=s.size()-2)ac="WA";
  }else{
    ac="WA";
  }

  cout << ac << endl;
}


Measured memory_bytes: 256