akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#define rep(i, n) for(int i = 0; i < (n); i++)
using namespace std;
using P = pair<int, int>;
long mod = (long) 1e9 + 7;

long MAX(long x, long y){
    if(x > y){
        return x;
    } else {
        return y;
    }
}

long MIN(long x, long y){
    if(x < y){
        return x;
    } else {
        return x;
    }
}

int main(){
    
    long n, xmin, xmax, ymin, ymax, ans;
    cin >> n;
    vector<long> x(n,0), y(n,0), z(n,0), w(n,0);
    rep(i,n) cin >> x[i] >> y[i];
    
    xmin = x[0];
    xmax = x[0];
    ymin = y[0];
    ymax = y[0];
    rep(i,n){
        xmin = MIN(xmin, x[i]);
        xmax = MAX(xmax, x[i]);
        ymin = MIN(ymin, y[i]);
        ymax = MAX(ymax, y[i]);
    }

    rep(i,n) z[i] = x[i] - xmin + y[i] - ymin;
    rep(i,n) w[i] = x[i] - xmin + ymax - y[i];
    sort(z.begin(), z.end());
    sort(w.begin(), w.end());

    ans = MAX((z[n-1] - z[0]), (w[n-1] - w[0]));

    cout << ans << "\n";
    
    return 0;
}



Measured memory_bytes: 9220
#include <cstdio>
#include <climits>
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <stack>
#include <algorithm>
#include <random>
#include <iomanip>
#include <unordered_map>
#include <map>
#include <queue>
#include <functional>
#include <numeric>
#include <chrono>
#include <cstdlib>
using ll = long long;
using namespace std;

const ll MOD = 1e9 + 7;
//const double EPS = 1e(-12);
const double pi = acos(-1);
typedef pair<int, int> P;
#define REP(i, n) for (int(i) = 0; (i) < (n); ++(i))
#define repi(i, a, b) for (int i = int(a); i < int(b); ++i)
#define EPS 1e-4
#define OUTPUT(i) (cout << (ll)i << endl)
#define ALL(a) ((a).begin(), (a).end())

int N;
int c[11][11];

int A[210][210];

int d[11][11];
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    //cout << fixed << setprecision(7);

    ll N, M;
    cin >> N >> M;

    ll ans = 0;
    for (ll i = 1; i * i <= M; ++i)
    {
        if (M % i == 0)
        {
            ll a = i;
            ll b = M / i;
            if (a * N <= M && M % a == 0)
                ans = max(ans, a);
            if (b * N <= M && M % b == 0)
                ans = max(ans, b);
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#ifdef DEBUG

#else

#    pragma GCC optimize("O3,no-stack-protector")
#    pragma GCC optimize("unroll-loops")

#    if __cplusplus < 201703L
#        pragma GCC target("avx")
#    else
#        pragma GCC target("avx2")
#    endif

#endif
// 実数の場合
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define dump(x) cout << x << endl
typedef int64_t Int;
typedef long double Ld;

using namespace std;
using Graph = vector<vector<Int>>;

const double pi = M_PI;
const Int MOD = 1000000007;

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

    int n;
    cin >> n;
    map<int, int> m;
    for (int i = 0; i < n; i++) {
        int a;
        cin >> a;
        if (!m.insert({a, 1}).second) {
            m[a]++;
        }
    }

    Int ans = 0;
    for (auto e : m) {
        if (e.first < e.second) {
            ans += e.second - e.first;
        } else if (e.second < e.first) {
            ans += e.second;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 4736
K = int(input())
S = input()
mod = 10**9+7
N = len(S)

def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

n = N+K
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル

for i in range( 2, n + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )


ans = cmb(N+K-1, K, mod)*pow(25, K, mod)%mod

for i in range(1, K+1):
    cnt = pow(26, i, mod)
    cnt *= cmb(N+K-i-1, K-i, mod)*pow(25, K-i, mod)
    cnt %= mod
    ans += cnt
    ans %= mod

print(ans)

Measured memory_bytes: 188000
#include <bits/stdc++.h>
#include <string>
#include <algorithm>
#include <string.h>
#include <ctype.h>
#include <math.h>
#include <float.h>
#include <iomanip>
#include <iostream>
using namespace std;

int main()
{
    string A,B,C;
    cin>>A>>B>>C;

    cout <<A[0]<<B[0]<<C[0]<<endl;

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <memory.h>

void print(int *buff, int num) {
    for (int i = 0; i < num; ++i) {
        printf("%d", buff[i]);
        if (i < num - 1) {
            printf(" ");
        } else {
            printf("\n");
        }
    }
}

int main(void) {
    int num;
    
    fscanf(stdin, "%d", &num);
    
    int *buff = malloc(sizeof(int) * num);
    
    for (int i = 0; i < num; ++i) {
        fscanf(stdin, "%d", &buff[i]);
    }
    
    for (int i = 0; i < num; ++i) {
        int t = buff[i];
        for (int j = i - 1; j >= 0; --j) {
            if (buff[j] > t) {
                buff[j + 1] = buff[j];
                buff[j] = t;
            } else {
                break;
            }
        }

        print(buff, num);
    }
    
    free(buff);
    
    return 0;
}



Measured memory_bytes: 2104
#include <stdio.h>

int main(void)
{
	char s[6];
	int count = 0;

	for (int i = 0; i < 3; ++i)
	{
		s[i] = getchar();
		
	}
	for (int i = 0; i < 3; ++i)
	{
		if (s[i] == 'R')
		{
			++count;
			if (s[i + 1] == 'R')
			{
				++count;
				if (s[i + 2] == 'R')
				{
					++count;
					break;
				}
				else
				{
					break;
				}
			}
			else
			{
				break;
			}
		}
	}
	printf("%d\n", count);
}

Measured memory_bytes: 1576
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>

using namespace std;

class BRollerCoaster {
public:
void solve(std::istream& cin, std::ostream& cout) {
    int n, k;
    cin >> n >> k;
    vector<int> H(n);
    copy_n(istream_iterator<int>(cin), n, H.begin());

    int ans = 0;
    for (const auto &h: H)
        if (h >= k) ans++;

    cout << ans << endl;

}
};

int main() {
	BRollerCoaster solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 640
#include<iostream>
#include<cmath>
#include <iomanip>
using namespace std;

int main() {
  long double n,m,x,y,w,z;
  cin >> x>>y>>w>>z;
  n = x-w;
  m = y-z;
  
  cout << setprecision(10) <<sqrt(n*n+m*m) << endl;
    return 0;
}



Measured memory_bytes: 3288
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(10**6)

n = int(input())

ans = 0
for i in range(n):
    a, b = list(map(int, input().split()))
    if a == b:
        ans += 1
        if ans >= 3:
            print("Yes")
            exit()
    else:
        ans = 0
print("No")


Measured memory_bytes: 9188
#include <bits/stdc++.h>
#define ALL(a) (a).begin(),(a).end()
#define N_MAX 1000
#define ll long long int
using namespace std;

int main() {
	int N; cin >> N;
	vector<int> P(N),Q(N);
	for (int i = 0; i < N; i++) {
		cin >> P[i]; P[i]--;
	}
	for (int i = 0; i < N; i++) {
		cin >> Q[i]; Q[i]--;
	}

	vector<int> A(N);
	for (int i = 1; i <= N; i++) A[i] = i;

	int a = 0, b = 0, cnt = 0;
	do {
		cnt++;

		int cnta = 0;
		for (int i = 0; i < N; i++) {
			if (P[i] == A[i]) cnta++;
			else break;
			if (cnta == N) a = cnt;
		}

		int cntb = 0;
		for (int i = 0; i < N; i++) {
			if (Q[i] == A[i]) cntb++;
			else break;
			if (cntb == N) b = cnt;
		}
	} while (next_permutation(A.begin(), A.end()));

	cout << fabs(a-b) << endl;
}


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


#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

using namespace std;
typedef long long ll; typedef vector<int> VI; typedef pair<int,int> pii;
const int MD = (int)1e9 + 7; typedef vector<ll> VL;
void dbg(){ cerr << "\n"; }  template <class T, class ...T2>
void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }
template <class T> void amax(T& a,T b){ a=max(a,b);}

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

int main() {
	//cin.tie(0); ios_base::sync_with_stdio(false);
	int n, m, ans=0;
	cin >>n >>m;
	VL a(n);
	rep(i, n) cin >>a[i];
	
	ll z = a[0];
	rep(i, n) z = lcm(z, a[i]);
	ll z2 = a[0];
	rep(i, n) z2 = gcd(z2, a[i]);
	dbg(z, z2);
	
	if(m>=z/2) ans = (m-z/2) / z + 1;

	rep(i, n){
		if((z/a[i])%2==0) ans =0;
	}
	cout << ans <<"\n";
	
	return 0;
	
	dbg("sss");
	map<int,int> mp;
	rep(i, 100000){
		rep(j, n) {
			int qq =a[j] * (i+ 0.5);
			mp[qq]++;
		}
	}
	int xxxx=0;
	for(auto x :mp){
	  if(x.second==n)cerr<<x.first<<":"<<x.second<<" "; 
		if(xxxx++ >100) {cerr<<"\n";break;}
	}
	
	return 0;
}



Measured memory_bytes: 1024
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();
		int c = sc.nextInt();
		int[] b_m = new int[m];
		int[][] a_nm = new int[n][m];
		for (int i = 0; i < m; i++) {
			b_m[i] = sc.nextInt();
		}
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < m; j++) {
				a_nm[i][j] = sc.nextInt();
			}
		}
		sc.close();
		int count = 0;
		for (int i = 0; i < n; i++) {
			int ans = c;
			for (int j = 0; j < m; j++) {
				ans += a_nm[i][j] * b_m[j];
			}
			if (ans > 0) {
				count++;
			}
		}
		System.out.println(count);
	}

}


Measured memory_bytes: 22228
#include <iostream>
using namespace std;
const int N=2e5+10;

int n;
char str[N];
int b[N][2];//定义：b[N][2]到第i个字符W(0)和R(1)的个数 

int main(){
	cin>>n>>str+1;
	for(int i=1;i<=n;i++){
		if(str[i]=='R') b[i][1]=b[i-1][1]+1,b[i][0]=b[i-1][0]; 
		else b[i][1]=b[i-1][1],b[i][0]=b[i-1][0]+1;
	}
	
	int r=b[n][1];//红色个数
	cout<<b[r][0];
	return 0;
}


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

#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;

int main(){
	int n;
	cin>>n;
	int h[100];
	int ma=111;
	for (int i = 0; i < n; i++){
		cin>>h[i];
		ma=max(ma,h[i]);
	}

	int ans=0;
	for (int i = 1; i <= ma; i++){
		for (int j = 0; j < n; j++){
			if(h[j]>=i){
				ans++;
				while(h[j]>=i && j<n){
					j++;
				}
			}
		}
	}

	cout<<ans<<endl;



	return 0;
}
	


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#define lol(i,n) for(int i=0;i<n;i++)
#define mod 1000000007
typedef long long ll;

using namespace std;
ll n,k,a[100010];
int main(){
    cin>>n>>k;
    lol(i,n)cin>>a[i];
    sort(a,a+n);
    ll ans=1e9;
    lol(i,n-k+1)ans=min(ans,a[i+k-1]-a[i]);
    cout<<ans<<endl;
    return 0;
}


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

int main()
{
  	int n;
  	double d1=0.5,d2,d3;
    cout<<setprecision(8)<<fixed;
  	cin>>n;
  	if(n%2==0)
      cout<<d1<<endl;
  	else
    {
      	d2 = n/2 + 1;
        d3 = d2/n;
      	cout<<d3<<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 < (int)(n); ++i)
#define all(c) begin(c), end(c)
#define dump(x) cerr << __LINE__ << ":\t" #x " = " << (x) << endl

int n;
vector<int> a;

int solve(){
    int cnt[100010] = {};
    rep(i, n) ++cnt[a[i]];

    // rep(i,15) cout << cnt[i] << ' ';
    // cout << endl;

    rep(i, 100010){
        if(cnt[i] == 0) cnt[i] = 0;
        else if(cnt[i]%2 == 1) cnt[i] = 1;
        else cnt[i] = 2;
    }
    // rep(i,15) cout << cnt[i] << ' ';
    // cout << endl;
    
    int t = 0, o = 0;
    rep(i, 100010) if(cnt[i]) {
        if(cnt[i] == 2) t++; else o++;
    }
    dump(t);
    dump(o);
    o += t/4*4;
    t %= 4;
    if(t == 0){
        return o;
    } else if(t == 1){
        return o;
    } else if(t == 2){
        return o + 2;
    } else if(t == 3){
        return o + 2;
    }
    assert(false);
}

int main(){
    while(cin >> n){
        a.resize(n);
        rep(i,n) cin >> a[i];
        cout << solve() << endl;
    }
}


Measured memory_bytes: 1024
import sys
LI = lambda : [int(x) for x in sys.stdin.readline().split()]
NI = lambda : int(sys.stdin.readline())

N = NI()
data = [(a,i) for i,a in enumerate(LI())]
data.sort(reverse=True)

dp = [[0] * (N+1) for _ in range(N+1)]

for i in range(N):
    a, p = data[i]
    for j in range(i+1):
        dp[i+1][j+1] = max(dp[i+1][j+1],dp[i][j] + abs(N-1-j-p)*a)
        dp[i+1][j] = max(dp[i+1][j], dp[i][j] + abs(i-j-p)*a)
print(max(dp[-1]))


Measured memory_bytes: 100296
#include <iostream>
#include <utility>
#include <map>
#include <vector>
#include <algorithm>
#include <queue>
#include <math.h>
#include <stack>
#include <set>
#include <deque>
#include <cmath>

using namespace std;
typedef long long ll;
ll mod = 1e9+7;
//ll mod = 998244353;
#define rep(i,n) for(int i = 0; i < (n); ++i)
const ll LINF = 1001002003004005006ll;

int main() {
    ll n;
    cin >> n;
    if (n % 2 == 1) {
        cout << 0 << endl;
        return 0;
    }
    ll ans = 0;
    ll idx = 10;
    while(1) {
        if (idx > n) break;
        ans += n / idx;
        idx *= 5LL;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3600
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
using namespace std;
using ll = long long ;
using P = pair<int,int> ;
using pll = pair<long long,long long>;
constexpr int INF = 1e9;
constexpr long long LINF = 1e17;
constexpr int MOD = 1000000007;
constexpr double PI = 3.14159265358979323846;
int n;
ll k;
vector<ll> a(n);

bool ok(ll m){
    if(m==0) return false;
    ll cnt = 0;
    rep(i,n){
        cnt += (a[i]+m-1)/m;
    }
    cnt -= n;
    return cnt <= k;
}

int main(){
    cin >> n >> k;
    a.resize(n);
    rep(i,n) cin >> a[i];

    ll left = -1,right = INF + 100;
    while(right - left > 1LL){
        ll mid = (right + left)/2;
        if(ok(mid)) right = mid;
        else left = mid;
    }
    cout << right << endl;
    return 0;
}

Measured memory_bytes: 4720
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define VIEW(x) do {cerr << #x << ": "; for(auto i : x) cerr << i << " "; cerr << endl;} while(0)
#define ALL(x) (x).begin(),(x).end()
template<class T>bool umax(T &a, const T &b) {if(a<b){a=b;return 1;}return 0;}
template<class T>bool umin(T &a, const T &b) {if(b<a){a=b;return 1;}return 0;}

template<typename A,size_t N,typename T> void FILL(A (&array)[N],const T &val){fill((T*)array,(T*)(array+N),val);}
template<typename T> void FILL(vector<T> &v, const T &x) {fill(v.begin(), v.end(), x);}
template<typename T> void FILL(vector<vector<T>> &v, const T &x) {for(auto &i:v)fill(i.begin(), i.end(), x);}

int main() {
  char b; cin >> b;
  if(b=='A') puts("T");
  if(b=='T') puts("A");
  if(b=='C') puts("G");
  if(b=='G') puts("C");
}


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

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<=(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define Eunique(v) v.erase(unique(all(v)),v.end())
#define Eback(s) s.erase(s.end()-1,s.end())
#define rev(v) reverse(all(v))

typedef long long ll;

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<long long> vll;
typedef vector<vll> vvll;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<string> vs;

typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
typedef vector<pair<int,int>> vpii;
typedef vector<pair<ll,ll>> vpll;

const double pi = acos(-1.0);
const int mod=1000000007;
const int mod2=998244353;

ll powmod(ll a,ll b){ll c=1; while(b>0){ if(b&1){ c=a*c%mod; } a=a*a%mod; b>>=1; } return c;}
ll gcd(ll x, ll y) {return __gcd(x,y);}
ll lcm(ll x, ll y) {return x/__gcd(x,y)*y;}

int main()
{
  int N;cin>>N;
  vector<int> data(N);
  vector<int> ans(N);
  for(int i=0;i<N;i++){
      int a;cin>>a;a--;
      ans[a]=i+1;
  }
  for(int i=0;i<N;i++){
      cout<<ans[i]<<" ";
  }
   
}

 
    

Measured memory_bytes: 1536
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int INF = 0x3f3f3f3f;
const ll mod = 1e9 +7;
const ll MAXN = 2e5 + 5;

int a[MAXN];
int s[MAXN];

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	ll n,k;cin>>n>>k;
	for(int i=1;i<=n;i++){
		cin>>a[i];
		s[i]=s[i-1]+a[i];
	}
	int L;
	int ans=0;
	for(int i=k;i<=n;i++){
		if(s[i]-s[i-k]>ans){
			ans=s[i]-s[i-k];
			L=i;
		}
	}
	printf("%.10lf",(k+ans)/2.0);
	return 0;
}


Measured memory_bytes: 1792
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int w = sc.nextInt();
        int h = sc.nextInt();
        int x = sc.nextInt();
        int y = sc.nextInt();
        int r = sc.nextInt();
        if (x + r <= w && x - r >= 0 && y + r <= h && y - r >= 0) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }

    }

}




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

void solve(std::istream &in, std::ostream &out);

int main() {
#ifdef LOCAL
  freopen("../IO/f.in", "r", stdin);
//  freopen("../IO/f.out", "w", stdout);
#else
  std::ios_base::sync_with_stdio(false);
  std::cin.tie(nullptr);
  std::cout.tie(nullptr);
#endif
  solve(std::cin, std::cout);
  return 0;
}

struct point_t {
  int x, y;
  point_t() = default;
  point_t(int x, int y) : x(x), y(y) {}
  int quad() const {
    return y > 0 || (y >= 0 && x >= 0);
  }
  int64_t abs2() const {
    return (int64_t) x * x + (int64_t) y * y;
  }
  int64_t dot(point_t rhs) const {
    return (int64_t) x * rhs.x + (int64_t) y * rhs.y;
  }
  int64_t det(point_t rhs) const {
    return (int64_t) x * rhs.y - (int64_t) y * rhs.x;
  }
};

struct PolarAngleComparator {
  bool operator()(point_t a, point_t b) const {
    int c1 = a.quad(), c2 = b.quad();
    if (c1 != c2) {
      return c1 > c2;
    }
    auto orientation = a.det(b);
    if (orientation == 0) {
      return a.abs2() < b.abs2();
    } else {
      return orientation > 0;
    }
  }
};

void solve(std::istream &in, std::ostream &out) {
  int n;
  in >> n;
  vector<point_t> points(n);
  for (point_t &point : points) {
    in >> point.x >> point.y;
  }
  sort(points.begin(), points.end(), PolarAngleComparator());
  int64_t result = 0;
  int64_t sx = 0, sy = 0;
  for (int r = 0, l = 0; l < n; ++l) {
    if (points[l].x == 0 && points[l].y == 0) {
      continue;
    }
    while (r - l < n && (points[l].det(points[r % n]) > 0 ||
                         (points[l].det(points[r % n]) == 0 && points[l].dot(points[r % n]) >= 0))) {
      sx += points[r % n].x;
      sy += points[r % n].y;
      ++r;
      result = max(result, sx * sx + sy * sy);
    }
    sx -= points[l].x;
    sy -= points[l].y;
    result = max(result, sx * sx + sy * sy);
  }
  out << fixed << setprecision(12) << sqrt(result) << '\n';
}


Measured memory_bytes: 256
#include<stdio.h>
void CountingSort(int *,int *,int,int);
int main(){
  int i,n,k=0;
  scanf("%d",&n);
  int A[n];
  int B[n];
  for(i=0;i<n;i++){
    scanf("%d",&A[i]);
    if(A[i]>k) k=A[i];
  }
  CountingSort(A,B,k,n);
  for(i=1;i<n+1;i++){
    if(i==n) printf("%d\n",B[i]);
    else printf("%d ",B[i]);
    
  }
  return 0;
}

void CountingSort(int *A, int *B, int k,int n){
  int C[k+1],i,j;
  for(i = 0;i<k+1;i++){
    C[i] = 0;
  }
  /* C[i] に i の出現数を記録する */
  for(j=0;j<n;j++){
    C[A[j]]++;
  }
  /* C[i] に i 以下の数の出現数を記録する*/
  for(i=1;i<=k;i++){
    C[i] = C[i] + C[i-1];
  }
  for(j = n-1;j>=0;j--){
    B[C[A[j]]] = A[j];
    C[A[j]]--;
  }
}


Measured memory_bytes: 17360
// Problem I solution
// Prateek


#include<bits/stdc++.h>

using namespace std;

//dp[i][j]::::::
// i:::::curr_index......
// j::::: no of heads till now....



int n;
double p[3003];

double dp[3003][3003];

double solve(int index, int heads)
{
    if(heads<0)
    return 0;
    if(heads > index)
    return 0;
    if(dp[index][heads] !=-1)
    return dp[index][heads];
    
    dp[index][heads] = solve(index-1,heads-1)*p[index] + 
                        solve(index-1,heads)*(1-p[index]);
                        
    return dp[index][heads];
    
}

int main()
{
    cin>>n;
    
    int i,j;
    
    for(i=0;i<3003;i++)
    {
        for(j=0;j<3003;j++)
        dp[i][j] = -1;
    }
    
    
    
    for(i=1;i<=n;i++)
    {
        cin>>p[i];
    }
    
    dp[1][0] = 1-p[1];
    dp[1][1] = p[1];
    
    double v;
    for(i=0;i<=n;i++)
    v = solve(n,i);
    
    double ans=0;
    for(i=(n/2)+1;i<=n;i++)
    {
        ans += dp[n][i];
    }
    cout<<setprecision(12)<<ans<<endl;
    return 0;
}

Measured memory_bytes: 70912
// lcmとかはg++ -std=c++17 default.cppみたいなかんじで

#include <bits/stdc++.h>
#define mod 1000000007
#define INF 1001001001
#define ll long long
#define ln cout<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define double long double
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define rep1(i,n) REP(i,1,n+1)
using namespace std;

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

    ll a,b,c,d,m,n,maxi=0,f=0,mini=INF,sum=0;
    string str;
    map<string,ll> bm;
    set<string> s;
    map<string,ll> rm;

    //vector<vector<ll>> v(tate,vector<ll> (yoko));
    cin>>n;
    rep(i,n) {
        cin>>str;
        bm[str]++;
        s.insert(str);
    }
        cin>>n;

    rep(i,n) {
        cin>>str;
        rm[str]++;
    }
    for(auto itr=s.begin();itr!=s.end();itr++){
        bm[*itr]-=rm[*itr];
    }
    for(auto itr=s.begin();itr!=s.end();itr++){
        maxi=max(bm[*itr],maxi);
    }
    cout<<maxi<<endl;

    return 0;
}


Measured memory_bytes: 256
//#include "pch.h"
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <stdlib.h>
#include <time.h>

#include <vector>
#include <set>
#include <map>
#include <iostream>
#include <utility>
#include <queue>
#include <algorithm>
#include <functional>
#include <string>
#include <bitset>
#include <numeric>

#define ll long long
#define fri(n) for(i=0;i<(n);i++)
#define frj(n) for(j=0;j<(n);j++)
#define frk(n) for(k=0;k<(n);k++)
#define frl(n) for(l=0;l<(n);l++)
#define min(p,q) ((p)<(q)?(p):(q))
#define max(p,q) ((p)>(q)?(p):(q))
#define INF 1000000000000000000//10^18
#define INFINT 2000000001//2*10^9+1
#define MOD 1000000007
#define MODANOTHER 998244353
#define PI acos(-1)

#define vi vector<int>
#define vvi vector<vector<int>>
#define vvvi vector<vector<vector<int>>>
#define vd vector<double>
#define vvd vector<vector<double>>
#define vvvd vector<vector<vector<double>>>


#define int long long

using namespace std;


const int MAX = 510000;

ll mod_inverse(int a,int M){
	int x=M-2;
	ll temp=a;
	ll ret=1;
	//a^(MOD-1)==1(mod MOD)を利用
	//a^-1==a^(MOD-2) (mod MOD)を繰り返し二乗法で求める

	while(x!=0){
		if(x%2==1){
			ret=(ret*temp)%M;
		}
		temp=(temp*temp)%M;
		x=x/2;
	}
	return ret;
}

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++){
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 二項係数計算
long long COM(int n, int k){
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

signed compare_int(const void *a, const void *b)
{
	int *A = (int *)a;
	int *B = (int *)b;
	if (*A < *B) return 1;
	if (*A > *B) return -1;
	return 0;
}


int gcd(int a,int b){
	while(1==1){
		if(a==0||b==0){
			return a+b;
		}else if(a>b){
			a %= b;
		}else{
			b %= a;
		}
	}
}

signed main(void)
{
	//変数の宣言
	int n,m,q;
	int h,w;
	static int a[100010];
	static int s[100010];

	//よく使う変数
	int i,j,k,l;
	int flag=0;
	int ans=0;
	int count=0;
	int temp=0;
	int temp1=0;
	int temp2=0;
	int temp3=0;
	vector<int> vec;
	int max=0;
	int min=INFINT;
	int len=0;
	int sum=0;
	int ok=0;
	int ng=0;
	char dummy;
	static char stemp[100010];
	vvi graph;

	//データの読み込み


	scanf("%lld",&n);
	//scanf_s("%lld",&n);


	//scanf("%s",&s);
	//scanf_s("%s",&s,200010);


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

	for(i=0;i<q;i++){
	//scanf("%d",&s[i]);
	scanf_s("%d",&s[i]);
	}*/



	//	printf("nは%dです\n", n);
	//	printf("データの読み込み終了\n");
	//実際の処理

	//	clock_t start=clock();
	//	COMinit();
	m=n;
	vi vtemp(m+10,0);
	vvi dp(m+10,vtemp);

	for(i=1;i<=m;i++){
		for(j=1;j<=m;j++){
			dp[i][j]=gcd(i,j);
		}
	}



	for(i=1;i<=m;i++){
		for(j=1;j<=m;j++){
			vtemp[dp[i][j]]++;
		}
	}
	for(i=1;i<=m;i++){
		for(j=1;j<=m;j++){
			ans += dp[i][j]*vtemp[j];
		}
	}

	printf("%lld",ans);

	//	clock_t end=clock();

	//	printf("計算部分終了\n");

	//出力

	//printf("%d",(d[i-1][j-1]+1)/2);

	//	printf("time=%lf",(double)(end-start)/CLOCKS_PER_SEC);
	//	printf("結果の出力終了\n");

	return 0;
}



Measured memory_bytes: 4108
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int maxx = 2e5 + 7;
const int Inf = 1 << 30;
const LL INF = 1LL << 60;
int n;
int a[maxx];
vector <int> vec[maxx];

int main() {
	cin >> n;
	for(int i = 2; i <= n; i++) {
		cin >> a[i];
		vec[a[i]].push_back(i);
	}
	for(int i = 1; i <= n; i++) printf("%d\n", vec[i].size());
	return 0;
}

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

using namespace std;

const int MAX { 100010 };

int ps[MAX];
vector<int> adj[MAX];
bitset<MAX> found;

void connected_component(int u, set<int>& cc)
{
    if (found[u])
        return;

    found[u] = true;
    cc.insert(u);

    for (auto v : adj[u])
        connected_component(v, cc);
}

int solve(int N)
{
    int ans = 0;

    for (int i = 1; i <= N; ++i)
    {
        if (found[i])
            continue;

        // Determina o componente conectado das posições
        set<int> cc;
        connected_component(i, cc);

        // Cada elemento cujo valor é uma posição do componente
        // conectado pode ser reposicionado corretamente
        for (auto u : cc)
            ans += cc.count(ps[u]);
/*cout << "cc = ";
for (auto u : cc)
    cout << u << ' ';
cout << '\n';

cout << "xs = ";
for (auto u : cc)
    cout << ps[u] << ' ';
cout << '\n';
 */       
    }

    return ans;
}

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

    int N, M;
    cin >> N >> M;

    for (int i = 1; i <= N; ++i)
    {
        int p;
        cin >> p;

        ps[i] = p;
    }

    while (M--)
    {
        int x, y;
        cin >> x >> y;

        adj[x].push_back(y);
        adj[y].push_back(x);
    }

    cout << solve(N) << '\n';

    return 0;
}


Measured memory_bytes: 13824
import java.util.*;

class Main{
  public static void main(String[] args){
    Scanner sc=new Scanner(System.in);
    int n=sc.nextInt();
    int[] a=new int[n];
    for(int i=0;i<n;i++){
      a[i]=sc.nextInt();
    }
    int[] b=new int[n];
    b[0]=a[0];
    for(int i=1;i<n;i+=2){
      b[0]=b[0]-a[i]+a[i+1];
    }
    for(int i=1;i<n;i++){
      b[i]=a[i-1]*2-b[i-1];
    }
    for(int i=0;i<n;i++){
      System.out.print(b[i]+" ");
    }
    System.out.println();
  }
}

Measured memory_bytes: 64704
pow_6 = [6**i for i in range(11)]
pow_9 = [9**i for i in range(11)]
N = int(input())
log = [0]*N
def ans(n):
  if n in pow_6 or n in pow_9:
    return 1
  else:
    num6 = 0
    while pow_6[num6]<n:
      num6 += 1
    num6 -= 1
    num9 = 0
    while pow_9[num9]<n:
      num9 += 1
    num9 -= 1
    if log[n-pow_6[num6]]!=0:
      x = log[n-pow_6[num6]]
    else:
      x = ans(n-pow_6[num6])
      log[n-pow_6[num6]] = x
    if log[n-pow_9[num9]]!=0:
      y = log[n-pow_9[num9]]
    else:
      y = ans(n-pow_9[num9])
      log[n-pow_9[num9]] = y
    return min(x+1,y+1)
print(ans(N))

Measured memory_bytes: 3828
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin >> N;
    int a[N];
    rep(i, N) cin >> a[i];
    int ans = INF;
    REP(i, -100, 100) {
        int tmp = 0;
        rep(j, N) {
            tmp += (a[j] - i) * (a[j] - i);
        }
        ans = min(tmp, ans);
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.*;

public class Main {
    public static void main(String[] args) {
        PrintWriter out = new PrintWriter(System.out);
        FastScanner sc = new FastScanner();
        Strategy strategy = new MyStrategy();
        strategy.solve(out, sc);
        out.flush();
    }
}

class MyStrategy implements Strategy {
    @Override
    public void solve(PrintWriter out, FastScanner sc) {
        double n = sc.nextInt();

        if (n == 1) {
            out.println(1);
        } else if (n % 2 == 0) {
            out.println(0.5000000000);
        } else {
            out.println(((n+1) / 2) / n);
        }
    }
}

interface Strategy {
    void solve(PrintWriter out, FastScanner sc);
}

class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }
    public double nextDouble() { return Double.parseDouble(next());}
}


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

using namespace std;

int main()
{
    string N;
    cin>>N;
    int sum=0;
    int num = stoi(N);
    for(int i=0;i<N.size();i++)
    {
        sum+=(N[i]-'0');
    }
    if(num%sum==0)
    {
        cout<<"Yes";
    }
    else{
        cout<<"No";
    }
    return 0;
}



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

using namespace std;

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

#define MOD 1000000007
#define REP(i, N) for (int i = 0; i < N; ++i)
#define REP1(i, N) for (int i = 1; i <= N; ++i)
#define RREP(i, N) for (int i = N - 1; i >= 0; --i)
#define ALL(a) a.begin(), a.end()

int dp[5050];

int main() {
  int n;
  cin >> n;
  string s;
  cin >> s;
  int ans = 0;
  for (int l = n - 1; l >= 1; --l) {
    REP(i, n) dp[i] = 0;
    for (int i = n - 1 - l; i >= 0; --i) {
      if (s[i] == s[i + l]) {
        dp[i] = min(dp[i + 1] + 1, l);
      } else {
        dp[i] = 0;
      }
      ans = max(ans, dp[i]);
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 384
import sys
from collections import defaultdict
stdin = sys.stdin
read_int = lambda : list(map(int,stdin.readline().split()))
read_str = lambda : stdin.readline().rstrip()

N = read_int()[0]
S = read_str()
d = defaultdict(int)

for cap in S:
    d[cap] += 1
d = dict(d)

if __name__ == "__main__":
    if d['R'] > d['B']:
        print('Yes')
    else:
        print('No')



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

int main(){
    ll N;
    cin >> N;
    vector<ll> a(N+1);
    vector<vector<ll>> G(N+1);
    ll ans = 0;
    rep(i, 1, N+1){
        cin >> a[i]; 
        G[a[i]].push_back(i);
    }
    rep(i, 1, N+1){
        for(auto g : G[i]){
            if(a[i] == g) ans++;
        }
    }
    cout << ans/2 << endl;
    return 0;
}

Measured memory_bytes: 6528
#include <bits/stdc++.h>
using namespace std;
template <class T> inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T> inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return 1;
    }
    return 0;
}
typedef long long int ll;

#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define endl "\n"
const double EPS = 1e-7;
const int INF = 1 << 30;
const ll LLINF = 1LL << 60;
const double PI = acos(-1);
const int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

//-------------------------------------

vector<int> toposort(vector<vector<int>> &g, vector<int> &h) {
    int n = g.size();
    stack<int> st;
    for(int i = 0; i < n; i++) {
        if(h[i] == 0) {
            st.push(i);
        }
    }
    vector<int> toposorted;
    while(st.size()) {
        int u = st.top();
        st.pop();
        toposorted.emplace_back(u);
        for(auto v : g[u]) {
            h[v]--;
            if(h[v] == 0) {
                st.push(v);
            }
        }
    }
    return toposorted;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, m;
    cin >> n >> m;
    vector<int> a(n - 1 + m), b(n - 1 + m);
    vector<vector<int>> g(n);
    // 入次数
    vector<int> h(n, 0);
    for(int i = 0; i < n - 1 + m; i++) {
        cin >> a[i] >> b[i];
        a[i]--;
        b[i]--;
        g[a[i]].emplace_back(b[i]);
        h[b[i]]++;
    }
    auto sorted = toposort(g, h);
    // 振り直した頂点番号
    vector<int> rev(n);
    for(int i = 0; i < n; i++) {
        rev[sorted[i]] = i;
    }

    vector<int> ans(n, sorted[0]);
    ans[sorted[0]] = -1;
    for(int i = 0; i < n - 1 + m; i++) {
        if(ans[b[i]] == -1) {
            continue;
        }
        if(rev[ans[b[i]]] < rev[a[i]]) {
            ans[b[i]] = a[i];
        }
    }
    for(int i = 0; i < n; i++) {
        cout << ans[i] + 1 << endl;
    }
}


Measured memory_bytes: 8824
n = gets.to_i
x = gets.split.map(&:to_i)

if x.uniq.count == 1
  if x.uniq.first == 0
    puts "Yes"
    exit
  else
    puts "No"
    exit
  end
end

if x.uniq.count == 2
  a, b = x.uniq.sort
  unless a == 0
    puts "No"
    exit
  end

  unless n % 3 == 0
    puts "No"
    exit
  end

  unless x.count(0) == (n / 3)
    puts "No"
    exit
  end

  puts "Yes"
  exit
end

unless x.uniq.count == 3
  puts "No"
  exit
end

a, b, c = x.uniq
a_count = x.count(a)
b_count = x.count(b)
c_count = x.count(c)

unless a_count == b_count
  puts "No"
  exit
end

unless a_count == c_count
  puts "No"
  exit
end

m1, m2, m3 = [a, b, c].sort
result = true
while m3 > 0 do
  b1 = m1 % 2
  b2 = m2 % 2
  b3 = m3 % 2
  if [b1, b2, b3].count(1) == 1
    result = false
    break
  end

  if [b1, b2, b3].count(1) == 3
    result = false
    break
  end

  m1 /= 2
  m2 /= 2
  m3 /= 2
end

if result
  puts "Yes"
else
  puts "No"
end

Measured memory_bytes: 13756
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#define ll long long
#define ALL(x) (x).begin(),(x).end()
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define vi vector<int>
#define vvi vector<vector<int>>
#define inf 10000000
using namespace std;

int main() {
	int N; cin >> N;
	int list[3];
	list[0] = 0, list[1] = 0, list[2] = 0;
	for (int i = 0; i < N; i++) {
		int x; cin >> x;
		if (x % 4 == 0) {
			list[0]++;
		}
		else if (x % 2 == 0) {
			list[1]++;
		}
		else {
			list[2]++;
		}
	}

	bool flag = false;
	if (list[1] == 0) {
		if (list[2] <= list[0] + 1) {
			flag = true;
		}
		else {
			flag = false;
		}
	}
	else {
		if (list[2] <= list[0]) {
			flag = true;
		}
		else {
			flag = false;
		}
	}

	if (flag) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}

Measured memory_bytes: 3608
#include<iostream>
using namespace std;
int main()
{
	int a,b,c;
	cin>>a>>b>>c;
	if((a==b&&c!=a)||(a==c&&b!=a)||(b==c&&a!=b)){
		cout<<"Yes"<<endl;
		return 0;
	}
	cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 3632
x, y = map(int, input().split())

ls_1 = [1, 3, 5, 7, 8, 10, 12]
ls_2 = [4, 6, 9, 11]
ls_3 = [2]

if ((x in ls_1) and (y in ls_1)) or ((x in ls_2) and (y in ls_2)) or ((x in ls_3) and (y in ls_3)):
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3064
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayDeque;
import java.util.ArrayList;

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] inputs = br.readLine().split(" ");
		int n = Integer.parseInt(inputs[0]);

		ArrayList<Node> nodes = new ArrayList<>(n);
		for ( int i = 0; i < n; i++ ) {
			nodes.add(new Node());
		}

		for ( int i = 0; i < n - 1; i++ ) {
			inputs = br.readLine().split(" ");
			int u = Integer.parseInt(inputs[0]) - 1;
			int v = Integer.parseInt(inputs[1]) - 1;
			int w = Integer.parseInt(inputs[2]);
			nodes.get(u).nexts.add(new Edge(v, w));
			nodes.get(v).nexts.add(new Edge(u, w));
		}
		br.close();

		ArrayDeque<Integer> q = new ArrayDeque<>();
		q.add(0);
		int[] tree = new int[n];
		tree[0] = 1;
		while ( !q.isEmpty() ) {
			int idx = q.poll();

			for ( Edge e : nodes.get(idx).nexts ) {
				if ( tree[e.to] == 0 ) {
					q.add(e.to);

					if ( e.dist % 2 == 0 ) tree[e.to] = tree[idx];
					else tree[e.to] = tree[idx] * (-1);
				}
			}
		}

		for ( int i : tree ) {
			System.out.println(Math.max(i, 0));
		}
	}
}

class Node {

	ArrayList<Edge> nexts = new ArrayList<>();
}

class Edge {

	int	to		= 0;
	int	dist	= 0;

	public Edge(int t, int d) {
		to = t;
		dist = d;
	}
}

Measured memory_bytes: 75112
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <queue>
#include <vector>
#include <string>
#include <sstream>
#include <utility>
#include <deque>
#include <numeric>
#include <map>
#define rep(i,n) for (int i = 0; i < (n); ++i)
 
using namespace std;
 
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef long long ll;
 
int main () {
	ll N;
    cin >> N;
    vector<ll> A(N);
	rep(i,N) {
		cin >> A[i];
	}
    ll offset = A[0];
    map<int64_t,int> left;
    map<int64_t,int> right; 
    rep(i,N) {
        int64_t l = i - A[i] + offset;
        if (left.count(l)) {
            left[l]++;
        } else {
            left[l] = 1;
        }
        int64_t r = i + A[i] + offset;
        if (right.count(r)) {
            right[r]++;
        } else {
            right[r] = 1;
        }
    }
    ll ans = 0;
    rep(i,N) {
        int64_t l = i - A[i] + offset;
        if (right.count(l)) {
            ans += right[l];
        }
        int64_t r = i + A[i] + offset;
        if (left.count(r)) {
            ans += left[r];
        }
    }
    cout << ans/2 << endl;
    return 0;
}

Measured memory_bytes: 27700
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
constexpr int INF = 1 << 30;

struct Edge {
  int src, dst, cost, color;
  Edge(int a, int b, int c = 1, int d = 1) : src(a), dst(b), color(c), cost(d) {}
};
using Edges = vector<Edge>;
using Graph = vector<Edges>;

struct EulerTour {
  int N, cnt = 0;
  Graph g;
  vector<int> cost, rnk, ord;
  vector<pair<int,int>> depth;

  EulerTour (int n, Graph &g) : g(g), rnk(n), cost(n), ord(n*2) {
    for(N = 1; N < n * 2; N<<=1);
    depth.resize(N * 2 - 1);

    dfs();
    
    for(int i = N - 2; i >= 0; --i) depth[i] = min(depth[i * 2 + 1], depth[i * 2 + 2]);
  }

  void dfs(int v = 0, int p = -1, int d = 0, int c = 0) {
    rnk[v] = cnt, cost[v] = c;
    depth[cnt + N - 1] = make_pair(d, cnt), ord[cnt] = v;
    ++cnt;

    for(Edge e : g[v]) {
      if(e.dst == p) continue;
      dfs(e.dst, v, d + 1, c + e.cost);
      depth[cnt + N - 1] = make_pair(d, cnt), ord[cnt] = v;
      ++cnt;
    }
  }

  pair<int, int> rmq(int a, int  b, int i = 0, int l = 0, int r = -1) {
    if(r == -1) r = N;
    if(r <= a || b <= l) return make_pair(INF, 0);
    if(a <= l && r <= b) return depth[i];

    auto L = rmq(a, b, i * 2 + 1, l, (l + r) / 2);
    auto R = rmq(a, b, i * 2 + 2, (l + r) / 2, r);
    return min(L, R);
  }

  int lca(int x, int y) { return ord[ rmq( min(rnk[x], rnk[y]), max(rnk[x], rnk[y]) + 1).second ]; }
  int dist(int x, int y) { return cost[x] + cost[y] - cost[lca(x, y)] * 2; }
};

// -------------------------

struct Q { 
  int id, x, y, z;
  Q(int id, int x, int y, int z) : id(id), x(x), y(y), z(z) {}
};

int n, q, a, b, c, d, ans[100010], color_cnt[100010], cost_cnt[100010];
vector<vector<Q>> Qs;
Graph g;

void dfs(int v, int p) {
  for(Q q : Qs[v]) {
    int tmp = color_cnt[q.x] * q.y - cost_cnt[q.x];
    ans[q.id] += tmp * q.z;
  }

  for(Edge e : g[v]) {
    if(e.dst == p) continue;
    ++color_cnt[e.color], cost_cnt[e.color] += e.cost;
    dfs(e.dst, v);
    --color_cnt[e.color], cost_cnt[e.color] -= e.cost;
  }
}

int main() {
    cin.tie(0); ios_base::sync_with_stdio(false);
    cin >> n >> q;
    g.resize(n); Qs.resize(n);
    for(int i = 0; i < n-1; ++i) {
      cin >> a >> b >> c >> d;
      --a, --b;
      g[a].emplace_back(a, b, c, d);
      g[b].emplace_back(b, a, c, d);
    }

    EulerTour et(n, g);

    for(int i = 0 ; i < q; ++i) {
      cin >> c >> d >> a >> b;
      --a, --b;
      int e = et.lca(a, b);
      Qs[a].emplace_back(i, c, d,  1);
      Qs[b].emplace_back(i, c, d,  1);
      Qs[e].emplace_back(i, c, d, -2);

      ans[i] += et.cost[a] + et.cost[b] - et.cost[e] * 2;
    }
    dfs(0, -1);

    for(int i = 0; i < q; ++i) cout << ans[i] << '\n';
    return 0;
}

Measured memory_bytes: 36084
i,n;char a[100001],s[100001];f(x,y){*a=x;a[1]=y;for(i=1;i<n-1;i++)a[i+1]=a[i]==87^a[i-1]==87^s[i]=='o'?83:87;if(*a==87^*s=='o'^a[n-1]==a[1]||a[n-1]==87^s[n - 1]=='o'^a[n-2]==*a)return 0;puts(a);exit(0);}main(){scanf("%d%s",&n,&s);f(83,83);f(83,87);f(87,83);f(87,87);puts("-1");}

Measured memory_bytes: 512
// abc130_c
#include <bits/stdc++.h>
#ifdef LOCAL
#include "../cxx-prettyprint/prettyprint.hpp"
#endif
using namespace std;

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

#define REP(i, n) for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n) for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define REP_REV(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (int (i) = (int)(n) - 1 ; (i) >= m ; --(i))
#define ALL(x) x.begin(), x.end()

#define INF ((1 << 29)-1)
#define MOD (1000000007)

#define print2D(h, w, arr) REP(i, h) { REP(j, w) cout << arr[i][j] << " "; cout << endl; }
template<class T> void print(const T& x){cout << x << endl;}
template<class T, class... A> void print(const T& first, const A&... rest) { cout << first << " "; print(rest...); }
struct PreMain {PreMain(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(20);}} premain;

int main() {
#ifdef LOCAL
    ifstream in("../arg.txt"); cin.rdbuf(in.rdbuf());
#endif

    double W, H, x, y;
    cin >> W >> H >> x >> y;

    double ans = W * H / 2;
    if (2 * x == W && 2 * y == H){
        print(ans, 1);
    } else {
        print(ans, 0);
    }



    return 0;
}


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

int main() {
  int a, b;
  cin >> a >> b;
  int ans;
  if (a >= 13) {
    ans = b;
  } else if (a >= 6) {
    ans = b / 2;
  } else {
    ans = 0;
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3580
/*Author: Gautam*/
 
 
#include<bits/stdc++.h>
#define FastIO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;
#define MOD 1000000007
#define ull unsigned long long int
#define newline cout<<endl
 
 
/* TYPE DEFINITIONS */
typedef     long long int        ll;
typedef     vector<ll>     vi;
typedef     pair<ll,ll>   pi;
 
 
 
/* MATH */
bool isPrime(ull n) 
{ 
    if (n <= 1)  return false; 
    if (n <= 3)  return true; 
    if (n%2 == 0 || n%3 == 0) return false; 
  
    for (ull i=5; i*i<=n; i=i+6) 
        if (n%i == 0 || n%(i+2) == 0) 
           return false; 
  
    return true; 
} 
 
ll pow(ll a,ll b,ll m)
{
    ll res=1;
    while(b>0)
    {
        if(b&1)res=(res*a)%m;
        a=(a*a)%m;
        b>>=1;
    }
    return res;
}
 
  
//
/* MACROS */
 
#define  all(A)         (A).begin() , (A).end()
#define  arrall(A,n)    (A),((A)+(n))
#define  rall(A)        (A).rbegin() , (A).rend()
#define  sz(A)          (int)(A).size()
#define  pb             push_back
#define  ppb            pop_back
#define  mp             make_pair
#define  ln(X)          (int)(X).length()
#define  square(X)      ((X)*(X))
#define  cube(X)        ((X)*(X)*(X))
#define  forn(i, n)  for (int i = 0; i < int(n); i++)
#define  forr(i, n)  for (int i = int(n - 1); i >= 0; i--)
#define  fora(i, a, b)  for (int i = int(a); i <= int(b); i++)
#define  forb(i, a, b)  for (int i = int(a); i >= int(b); i--)
#define  fore(it, a)    for(__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++) 
std::vector<pi> v[100005];
bool visited[100005];
bool color[100005];
void dfs(int s,ll su)
{
	if(visited[s])return;
	visited[s]=true;
	if(su&1)color[s]=true;
	for(auto i:v[s])
	{
		dfs(i.first,su+i.second);
	}
}
void solve()
{
	int n;
	cin>>n;
	forn(i,n-1)
	{
		int a,b,w;
		cin>>a>>b>>w;
		v[a].pb({b,w});
		v[b].pb({a,w});
	}
	fora(i,1,n)
	{
		if(!visited[i])
		{
			dfs(i,0);
		}
	}
	for(int i=1;i<=n;i++)
	{
		cout<<color[i]<<endl;
	}

}
 
int main()
{
 
    
    FastIO;
    ll t=1;
    //cin>>t;
    while(t--)
    {
        solve();
    }
}

Measured memory_bytes: 8832
K, N = map(int, input().split())
A = map(int, input().split())
dist = [0] * K
for a in A:
    dist[a] = 1
d = dist.index(1)
ans = 0
count = 0
for i in range(K):
    if dist[(d + i) % K] == 1:
        ans = max(ans, count)
        count = 0
    else:
        count += 1
ans = max(ans, count)
print(K - ans - 1)

Measured memory_bytes: 26292
H, W = map(int, input().split())

ans = 0

if W == 1 or H == 1:
    print(1)
    quit()
else:
    if W % 2 == 0:
        if H % 2 == 0:
            ans += (W // 2) * (H // 2)
            ans += (W // 2) * (H // 2)
        else:
            ans += (W // 2) * ((H // 2) + 1)
            ans += (W // 2) * (H // 2)
    else:
        if H % 2 == 0:
            ans += ((W // 2) + 1) * (H // 2)
            ans += (W // 2) * (H // 2)
        else:
            ans += ((W // 2) + 1) * ((H // 2) + 1)
            ans += (W // 2) * (H // 2)

print(ans)


Measured memory_bytes: 3064