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

int main(){
  int H,W,N;
  int tmp=0;
  cin >> H >> W >> N;
  if(H > W){
    tmp = H;
  }else{
    tmp = W;
  }
  double ans=0;
  ans = (N + tmp -1) / tmp;
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using PII = pair<ll, ll>;
#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
template<typename T> void chmin(T &a, const T &b) { a = min(a, b); }
template<typename T> void chmax(T &a, const T &b) { a = max(a, b); }
struct FastIO {FastIO() { cin.tie(0); ios::sync_with_stdio(0); }}fastiofastio;
#ifdef DEBUG_ 
#include "../program_contest_library/memo/dump.hpp"
#else
#define dump(...)
#endif
const ll INF = 1LL<<60;

int main(void) {
    ll n;
    string s;
    cin >> n >> s;

    if(s.substr(0, n/2) == s.substr(n/2)) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}

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

typedef long long ll;

#define p_ary(ary,a,b,i) do { cout << "["; for (int (i) = (a);(i) < (b);++(i)) cout << ary[(i)] << ((b)-1 == (i) ? "" : ", "); cout << "]\n"; } while(0)
#define p_map(map,it) do {cout << "{";for (auto (it) = map.begin();;++(it)) {if ((it) == map.end()) {cout << "}\n";break;}else cout << "" << (it)->first << "=>" << (it)->second << ", ";}}while(0)

void dfs(int i,int c,vector<int>& color,vector<vector<int>>& edges,int* a) {
    color[i] = c+1;
    a[c]++;
    for (int j : edges[i]) {
        if (color[j] == c+1) a[0] = -1000;
        if (color[j] == 0) dfs(j,c^1,color,edges,a);
    }
}

int main() {
    int n,m;
    int ans = 1000000;
    cin >> n >> m;
    vector<int> color(n,0);
    vector<vector<bool>> a(n,vector<bool>(n,false)),dp(n+1,vector<bool>(n+1,false));
    vector<vector<int>> edges(n);
    for (int i = 0;i < m;++i) {
        int u,v;
        cin >> u >> v;
        u--;v--;
        a[u][v] = a[v][u] = true;
    }
    for (int i = 0;i < n;++i) a[i][i] = true;
    for (int i = 0;i < n;++i) for (int j = 0;j < n;++j) if (!a[i][j]) edges[i].push_back(j);
    dp[0][0] = true;
    int j = 0;
    for (int i = 0;i < n;++i) if (color[i] == 0) {
        int b[2] = {0,0};
        dfs(i,0,color,edges,b);
        if (b[0] < 0) {
            cout << "-1" << endl;
            exit(0);
        }
        for (int i = 0;i < n;++i) for (int k = 0;k < 2;++k) if (dp[j][i]) dp[j+1][i+b[k]] = true;
        j++;
    }
    for (int i = 1;i <= n;++i) if (dp[j][i]) ans = min(ans,(i*(i-1)+(n-i)*(n-i-1))/2);
    cout << ans << endl;
}

Measured memory_bytes: 3328
#include <bits/stdc++.h>
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
using i64 = int64_t;
using f80 = __float80;
static const int dy[4] = {0,1,0,-1}, dx[4] = {1,0,-1,0};
constexpr i64 INF = 1'010'000'000'000'000'017LL;
constexpr i64 MOD = 1'000'000'007LL;
#define _overload3(_1,_2,_3,name,...) name
#define repi(i,start,end) for(i64 i=(start);i<(end);++i)
#define _rep(i,n) repi(i,0,n)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define rrep(i,start,end) for(i64 i=(start);i>end;--i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define v(T) vector<T>
#define vv(T) v(v(T))
typedef v(i64) vi;
typedef v(vi) vvi;
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return true;}return false;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return true;}return false;}
template<typename T> ostream &operator<<(ostream &os, const vector< T > &v){
  rep(i,v.size()) os << v[i] << (i + 1 != v.size() ? " " : "");
  return os;
}
template<typename T> istream &operator>>(istream &is, vector< T > &v){
  for(T &in : v) is >> in;
  return is;
}

void Main()
{
  i64 N;
  cin >> N;

  vvi E(N);
  i64 a, b;
  rep(i, N - 1){
    cin >> a >> b;
    a--;
    b--;
    E[a].emplace_back(b);
    E[b].emplace_back(a);
  }

  vi C(N);
  cin >> C;

  sort(rrng(C));

  i64 M = accumulate(rng(C), 0LL);
  M -= C[0];

  vi D(N, -1);
  queue<i64> que;
  que.push(0);
  D[0] = C[0];
  i64 i = 1;
  while(!que.empty()){
    i64 nxt = que.front();
    que.pop();
    for(auto &p : E[nxt]){
      if(D[p] != -1) continue;
      D[p] = C[i++];
      que.push(p);
    }
  }

  cout << M << "\n";
  cout << D << "\n";
}

int main()
{
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  Main();
}

Measured memory_bytes: 1152
use std::cmp;
use std::collections::BinaryHeap;
use std::io::Read;

fn calc(segments: &Vec<(i32, i32)>) -> i64 {
    let n = segments.len();
    let mut left_heap = BinaryHeap::new();
    let mut right_heap = BinaryHeap::new();
    let mut used = vec![false; n];

    for i in 0..n {
        left_heap.push((segments[i].0, i));
        right_heap.push((-segments[i].1, i));
    }

    let mut res = 0i64;
    let mut pos = 0;
    for i in 0..n {
        let heap = if i % 2 == 0 {
            &mut left_heap
        } else {
            &mut right_heap
        };

        let mut next = 0;
        while let Some((_, index)) = heap.pop() {
            if !used[index] {
                next = index;
                break;
            }
        }
        used[next] = true;

        let (l, r) = segments[next];

        if pos > r {
            res += (pos - r) as i64;
            pos = r;
        } else if pos < l {
            res += (l - pos) as i64;
            pos = l;
        }
    }
    res += (pos as i64).abs();
    return res;
}

#[allow(non_snake_case)]
fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();
    let mut iter = buf.split_whitespace();

    let n = iter.next().unwrap().parse().unwrap();
    let segments: Vec<(i32, i32)> = (0..n)
        .map(|_| {
            let l: i32 = iter.next().unwrap().parse().unwrap();
            let r: i32 = iter.next().unwrap().parse().unwrap();
            (l, r)
        })
        .collect();
    let reverse_segments = segments.iter().map(|&(l, r)| (-r, -l)).collect();
    println!("{}", cmp::max(calc(&segments), calc(&reverse_segments)));
}


Measured memory_bytes: 15260
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define FOR(i,start,end) for(int i=start;i<=end;i++)
const int INF = 1001001001;
typedef long long ll;
const ll MOD=1000000007;
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; }
template<class T>auto MAX(const T& a) { return *max_element(a.begin(),a.end()); }
template<class T>auto MIN(const T& a) { return *min_element(a.begin(),a.end()); }
template<class T, class U>U SUM(const T& a, const U& v) { return accumulate(a.begin(),a.end(), v); }
template<class T, class U>U COUNT(const T& a, const U& v) { return count(a.begin(),a.end(), v); }
template<class T, class U>int LOWER(const T& a, const U& v) { return lower_bound(a.begin(),a.end(), v) - a.begin(); }
template<class T, class U>int UPPER(const T& a, const U& v) { return upper_bound(a.begin(),a.end(), v) - a.begin(); }
int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
int LCM(int a, int b) { int g = GCD(a, b); return a / g * b; }

int main(void){
    // Your code here!
    string s;cin >> s;
    int con = 0;
    rep(i,s.size()/2){
        if (s[i] != s[s.size()-1-i]){
            con++;
        }
    }
    cout << con << endl;
}


Measured memory_bytes: 384
# 1は除外
# ・N-1の約数は全て対象
# ・Nの約数でsqrt(N)以下の数について、Nで割れなくなるまで割って、最後にあまりが1になればOK
# ・N自身は必ず対象
# これを足し合わせる

N = int(input())

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    return divisors
  
# N-1の約数の個数
ans = len(make_divisors(N-1)) - 1

def check(n,x):
  # xで割った余りがxの倍数でなくなるまでxで割る
  # xの倍数でなくなったときにxで割って1余ればOK
  while n % x == 0:
    n //= x
  return (n % x == 1)

# Nの約数で2以上sqrt(N)以下の数
for i in range(2,int(N ** 0.5) + 1):
  if N % i == 0:
    if check(N,i):
      ans += 1

# N自身も対象
ans += 1

print(ans)


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

using namespace std;
using ll = long long int;
using P = pair<int, int>;

#define roop(i, n) for(int i = 0;i < n;i++)

int main(void){

    ll x;
    cin >> x;

    ll start = 100;
    int i;
    for(i = 0;;i++){
        if(start >= x) break;
        start *= 1.01;
    }

    cout << i << endl;


    return 0;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
typedef long long int ll;
using namespace std;
map<ll,ll>vis;
 vector<ll>adj[100005];
ll dp[ll(2e5+1)];
void dfs(ll i){
    vis[i]++;
for(auto it:adj[i]){
    if(vis[it]==0){
        dfs(it);
    }
    dp[i]=max(dp[i],dp[it]+1);
}
}
int main(){
    ll n,m;
    cin>>n>>m;
    while(m--){
        ll p,q;
        cin>>p>>q;
        adj[p].push_back(q);
    }
    for(ll i=1;i<=n;i++){
        if(vis[i]==0){
            dfs(i);
        }}
        ll ans=0;
        for(ll i=1;i<=n;i++)ans=max(ans,dp[i]);
        cout<<ans<<endl;

return 0;
}


Measured memory_bytes: 16896
n=int(input())
a=list(map(int,input().split()))
from collections import Counter
x=Counter(a)
ans=0
for i in x:
    p=x[i]
    ans+=p*(p-1)//2
for i in a:
    print(ans-x[i]*(x[i]-1)//2+(x[i]-1)*(x[i]-2)//2)

Measured memory_bytes: 24748
N=int(input());g={i:[]for i in range(N)}
for i in range(N-1):a,b=map(int,input().split());g[a-1].append(b-1);g[b-1].append(a-1)
c=sorted(list(map(int,input().split())));n=[0]*N;s=[0];print(sum(c[:-1]))
while s:
 d=s.pop()
 n[d]=c.pop()
 for m in g[d]:
  if n[m]==0:
   s.append(m)
print(' '.join(map(str,n)))

Measured memory_bytes: 6520
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <algorithm>
#include <sstream>
#include <map>
#include <set>
#include <queue>

#define REP(i,k,n) for(int i=k;i<n;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1<<30
#define pb push_back
#define mp make_pair

using namespace std;
typedef long long ll;
typedef pair<int,int> P;

struct edge {
	int from,to;
	int cost;

	edge(int t,int c) : to(t),cost(c) {}
	edge(int f,int t,int c) : from(f),to(t),cost(c) {}

	bool operator<(const edge &e) const {
		return cost < e.cost;
	}
};

vector<edge> G[5005];
vector<int> g[5005];
int C[5005], R[5005], d[5005];

void dijkstra(int s,int n) {
	priority_queue<P,vector<P>,greater<P> > que;
	fill(d,d+n,INF);

	d[s] = 0;
	que.push(P(0,s));

	while(que.size()) {
		P p = que.top();
		que.pop();

		int v = p.second;
		if(d[v] < p.first) continue;

		rep(i,G[v].size()) {
			edge e = G[v][i];
			if(d[e.to] > d[v] + e.cost) {
				d[e.to] = d[v] + e.cost;
				que.push(P(d[e.to],e.to));
			}
		}
	}
}

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

	memset(C, 0, sizeof(C));
	memset(R, 0, sizeof(R));
	rep(i, n) cin >> C[i] >> R[i];
	rep(i, m) {
		int s, t;
		cin >> s >> t;

		s--;
		t--;

		g[s].push_back(t);
		g[t].push_back(s);
	}

	rep(i, n) {
		fill(d, d + n, INF);

		priority_queue<P, vector<P>, greater<P> > que;
		que.push(mp(0, i));

		d[i] = 0;

		while(que.size()) {
			P p = que.top();
			que.pop();

			int v = p.second;

			if(d[v] < p.first) continue;

			rep(i, g[v].size()) {
				if(d[g[v][i]] > d[v] + 1) {
					d[g[v][i]] = d[v] + 1;
					que.push(mp(d[v] + 1, g[v][i]));
				}
			}
		}

		rep(j, n) {
			if(i == j) continue;
			if(d[j] <= R[i]) {
				G[i].push_back(edge(j, C[i]));
			}
		}
	}

	dijkstra(0, n);

	cout << d[n-1] << endl;

	return 0;
}

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

int main() {
int N, M;
cin >> N >> M;
vector<int> A(M);
vector<int> B(M);
vector<int> C(N);
vector<int> H(N);
for(int i = 0; i < N; i++){
cin >> H.at(i);}
for(int i = 0; i < M; i++){
cin >> A.at(i) >> B.at(i);}
for(int i = 0; i < M; i++){
if(H.at(A.at(i) - 1) < H.at(B.at(i) - 1)){
C.at(A.at(i) - 1)--;}
if(H.at(A.at(i) - 1) > H.at(B.at(i) - 1)){
C.at(B.at(i) - 1)--;}
if(H.at(A.at(i) - 1) == H.at(B.at(i) - 1)){
C.at(A.at(i) - 1)--;
C.at(B.at(i) - 1)--;}}
int count = 0;
for(int i = 0; i < N; i++){
if(C.at(i) == 0) count++;}
cout << count << endl;}


Measured memory_bytes: 4796
IDENTIFICATION DIVISION.
PROGRAM-ID. PROGRAM_ID.

DATA DIVISION.
WORKING-STORAGE SECTION.
01 ln         PIC X(30).
01 A          PIC 9(10).
01 B          PIC 9(10).
01 ans        PIC 9(10).
01 zs         PIC Z(9)9.

PROCEDURE DIVISION.
  ACCEPT ln.
  UNSTRING ln DELIMITED BY SPACE INTO A B.
  IF A <= 9 AND B <= 9
    MULTIPLY A BY B GIVING ans
    MOVE ans TO zs
    DISPLAY FUNCTION TRIM(zs)
  ELSE
    DISPLAY -1
  END-IF.
  STOP RUN.


Measured memory_bytes: 3784
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pi;
#define debug(x) cout << #x << ": " << x << endl
#define repn(i, a, b) for(int i = (a); i < (b); i++)
#define rep(i, a) for(int i = 0; i < (a); i++)
#define all(v) v.begin(), v.end() 
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define endl '\n'

int dp[100005];

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	//freopen("input.in", "r", stdin);
	//freopen("output.out", "w", stdout);
	int n, k;
	cin >> n >> k;
	int s[n];
	rep(i, n){
		cin >> s[i];
		dp[i] = 1e9;
	}
	dp[0] = 0;
	repn(i, 1, n){
		repn(j, 1, k + 1) if(i - j >= 0){
			dp[i] = min(dp[i], dp[i - j] + abs(s[i] - s[i - j]));
		}
	}
	cout << dp[n - 1] << endl;
	return 0;
}
/*
Things to look out for:
	- Integer overflows
	- Array bounds
	- Special cases
Be careful!
*/


Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#define lsb(x) ((x) & (-x))
using namespace std;

int l(const pair <int, int> & x)
{
    return x.second - x.first + 1;
}

bool op(const pair <int, int> & a, const pair <int, int> & b)
{
    return l(a) < l(b);
}

pair <int, int> v[300010];
int aib[100010];
int libere;

void update(int x, int val);
int query(int x);

int main()
{
    ios_base :: sync_with_stdio(0);
    int n, m;

    cin >> n >> m;
    libere = n;

    for (int i(0); i < n; i++)
        cin >> v[i].first >> v[i].second;

    sort(v, v + n, op);
    int cnt(0);
    v[n] = { -1e8, 1e8 };

    for (int i(1); i <= m; i++) {
        while (l(v[cnt]) <= i) {
            libere--;
            update(v[cnt].second + 1, -1);
            update(v[cnt].first, 1);
            cnt++;
        }
        int ans(libere);

        for (int j(i); j <= m; j += i)
            ans += query(j);

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

int query(int x)
{
    int ans(0);
    while (x) {
        ans += aib[x];
        x -= lsb(x);
    }
    return ans;
}

void update(int x, int val)
{
    if (x == 0)
        return;
    while (x < 100010) {
        aib[x] += val;
        x += lsb(x);
    }
}


Measured memory_bytes: 3712
#include<iostream>
using namespace std;
int main()
{
	int y,m,d;
	while(cin>>y>>m>>d) 
	{
		int n=y*10000+m*100+d;
		if(n<=1868*10000+9*100+7) cout<<"pre-meiji"<<endl;
		else if(n<=1912*10000+7*100+29) cout<<"meiji"<<" "<<y-1868+1<<" "<<m<<" "<<d<<endl;
		else if(n<=1926*10000+12*100+24) cout<<"taisho"<<" "<<y-1912+1<<" "<<m<<" "<<d<<endl;
		else if(n<=1989*10000+1*100+7) cout<<"showa"<<" "<<y-1926+1<<" "<<m<<" "<<d<<endl;
		else cout<<"heisei"<<" "<<y-1989+1<<" "<<m<<" "<<d<<endl;
	}
  return 0;
}

Measured memory_bytes: 1164
#include <iostream>
#include <vector>
#include <string.h>

using namespace std;
bool IsPrime[10500];
vector<int> Prime;

void calc()
{
	memset(IsPrime, 1, sizeof(IsPrime));
	for(int i = 2; i < 10500; ++i)
	{
		if(IsPrime[i])
		{
			Prime.push_back(i);
			for(int j = 2 * i; j < 10500; j += i)
			{
				IsPrime[j] = false;
			}
		}
	}
}

void solve()
{
	calc();
	int n;
	while(cin >> n, n)
	{
		int count = 0;
		while(Prime[count] < n)
		{
			count++;
		}
		if(Prime[count] != n)
		{
			count--;
		}
		for(int i = count; i >= 0; --i)
		{
			if(Prime[i] - Prime[i - 1] == 2)
			{
				cout << Prime[i - 1] << " " << Prime[i] << endl;
				break;
			}
		}
	}
}

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

Measured memory_bytes: 932
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
#define INF 999999999
#define rep(i,n) for(int i=0;i<n;i++)
const int MOD = 1000000007;


int main(){
    int a,b;    cin>> a >> b;
    if(a-2*b<0)cout << 0 <<endl;
    else cout << a-2*b <<endl;
}




Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
 
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long int
#define mod 1000000007
 
using namespace std;
 
signed main()
{
    fast;
    string s;
    cin>>s;

    string s1 = s.substr(0,2);
    string s2 = s.substr(2,2);

    if ( s1 == "00" && s2 == "00" )
    {
        cout<<"NA"<<endl;
        return 0;
    }

    if ( s1 > "12" &&  s2 <= "12" && s2 > "00" )
    {
        cout<<"YYMM"<<endl;
    }
    else if ( s2 > "12" && s1 <= "12" && s1 > "00" )
    {
        cout<<"MMYY"<<endl;
    }
    else if ( s1 <= "12" && s2 <= "12" && s1 >= "00" && s2 >= "00" )
    {
        if ( s1 == "00" )
        {
            cout<<"YYMM"<<endl;
        }
        else if ( s2 == "00" )
        {
            cout<<"MMYY"<<endl;
        }
        else
        {
            cout<<"AMBIGUOUS"<<endl;
        }
        
        
    }
    else
    {
        cout<<"NA"<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
int main() {
    int N;
    while (cin >> N && N){
        int a[N];
        int c =0;
        for(int i=0;i<N;i++){
            cin >> a[i];
        }
        for(int j=0;j<N;){
            if(a[j]%2==0){
                a[j]/=2;
                c++;
            }
            else{
                j++;
            }
        }
        cout << c << endl;
    }
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main{
	public static void main(String[] args){
		Scanner scan = null;
		try{
			scan = new Scanner(System.in);
			System.out.printf("%d\n",(int)Math.pow(scan.nextInt(),3));

		}finally{
			if(scan !=null)scan.close();
		}

	}
}

Measured memory_bytes: 17380
// g++ -std=c++11 a.cpp
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>   
#include<map>
#include<set>
#include<unordered_map>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(ll i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define FOR(i,a) for(auto i:a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define show1d(v) rep(i,v.size())cout<<" "<<v[i];cout<<endl<<endl;
#define show2d(v) rep(i,v.size()){rep(j,v[i].size())cout<<" "<<v[i][j];cout<<endl;}cout<<endl;
using namespace std;
//kaewasuretyuui
typedef long long ll;
//#define int ll
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
#define mt make_tuple
typedef tuple<int,int,int> tp;
typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
//template<class C>constexpr int size(const C &c){return (int)c.size();}
//template<class T,size_t N> constexpr int size(const T (&xs)[N])noexcept{return (int)N;}
const double PI=acos(-1);
const double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
int idx(vi a,int c){
	return lower_bound(all(a),c)-a.begin();
}
int main(){
	int n;
	while(cin>>n,n){
		vi x(n+4),y(n+4);
		rep(i,n+4)cin>>x[i]>>y[i];
		vi X,Y;
		rep(i,n+4)X.pb(x[i]),X.pb(x[i]+1);
		rep(i,n+4)Y.pb(y[i]),Y.pb(y[i]+1);
		sort(all(X));X.erase(unique(all(X)),X.end());
		sort(all(Y));Y.erase(unique(all(Y)),Y.end());
		int N=X.size(),M=Y.size();
		vvi dp(N,vi(M));
		int t=1;
		rep(i,n){
			int a=idx(X,x[i]),b=idx(Y,y[i]);
			dp[a][b]=t;
			t*=-1;
		}
		rep(i,N-1)rep(j,M)dp[i+1][j]+=dp[i][j];
		rep(i,N)rep(j,M-1)dp[i][j+1]+=dp[i][j];
		int a=min(min(x[n],x[n+1]),min(x[n+2],x[n+3]));
		int b=max(max(x[n],x[n+1]),max(x[n+2],x[n+3]));
		int c=min(min(y[n],y[n+1]),min(y[n+2],y[n+3]));
		int d=max(max(y[n],y[n+1]),max(y[n+2],y[n+3]));
		a=idx(X,a);b=idx(X,b);c=idx(Y,c);d=idx(Y,d);
		loop(i,a,b)loop(j,c,d)dp[i][j]=0;
		
		ll sum=0;
		rep(i,N)rep(j,M)if(dp[i][j])sum+=(ll)(X[i+1]-X[i])*(Y[j+1]-Y[j]);
		cout<<sum<<endl;
	}
}









Measured memory_bytes: 3068
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,a) for(int i=0;i<(a);i++)
const ll MOD=1000000007;
//const ll MOD=998244353;
 
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int A,B; cin>>A>>B;
  if(A>=B){
    rep(i,A) cout<<B;
  }else{
    rep(i,B) cout<<A;
  }
  cout<<endl;
  return 0;
}

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

using namespace std;
typedef long long ll;
// #define int ll
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef pair<int, int> PII;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define IN(a, b, x) (a<=x&&x<b)
#define MP make_pair
#define PB push_back
#ifdef int
const ll INF = (1LL<<60);
#else
const int INF = (1LL<<30);
#endif
const double PI = 3.14159265359;
const double EPS = 1e-12;
const int MOD = 1000000007;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }

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

int r[505];
double dp[505];
signed main(void)
{
  int n;
  cin >> n;
  REP(i, n) cin >> r[i];

  REP(i, n) {
    dp[i] = r[i];
    REP(j, i) {
      chmax(dp[i], dp[j] + 2*sqrt(r[i]*r[j]));
    }
  }
  // REP(i, n) cout << dp[i] << " "; cout << endl;
  double ret = 0;
  REP(i, n) chmax(ret, dp[i]+r[i]);
  cout << fixed << setprecision(15) << ret << endl;

  return 0;
}

Measured memory_bytes: 3252
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n,i,ans,cou;
  cin>>n;
  ans=0;
  
  vector<int> vec(n); 
  for(i=0; i<n; i++){
    cin>>vec.at(i);
  }
  cou=0;
  for(i=0; i<n-1; i++){
    if(vec.at(i)<vec.at(i+1)){
      ans=max(ans,cou);
      cou=0;
    }
    else{
      cou=cou+1;
    }
  }
  ans=max(ans,cou);
  cout<<ans;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n)for(int i=0;i<(n);i++)
const int M = 1e9 + 7;

int main(void){
  string s,t;cin>>s>>t;
  long long ans=0,cur=0,n=s.length(),m=t.length(),x;
  bool ok=true;
  vector<set<int>>vs(26);
  rep(i,26)vs[i].insert(M);
  rep(i,n)vs[s[i]-'a'].insert(i+1);
  rep(i,m){
    x=t[i]-'a';
    cur=*vs[x].upper_bound(cur);
    if(cur==M)++ans,cur=*vs[x].begin();
    if(cur==M)ok=false;
  }

  (ans*=n)+=cur;
  printf("%lld\n",ok?ans:-1);
  return 0;
}


Measured memory_bytes: 8628
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <limits.h>
#include <queue>
#include <map>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
#define REP(i, n) for(int i=0; i<n; i++)

map<int, int> A;
int main(){
    int N;
    cin >> N;
    REP(i,N){
        int a;
        cin >> a;
        if(A[a] <= 1){
            A[a]++;
        }
        else if(A[a] == 2){
            A[a] = 1;
        }
    }

    int s = 0;
    int d = 0;
    for(auto&& a : A){
        if(a.second == 1) s++;
        else d++;
    }
    //printf("s:%d\td:%d\n",s,d);
    while(d > 1){
        d -= 2;
        s += 2;
    }
    //if(d == 1){
    //    d--;
    //}
    int ans = s;
    cout << ans << endl;
    return 0;
}


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

int main() {
    int N, answer;
    cin >> N;
    answer = 0;
    for(int i = 0; i < N; i++){
        for(int j = 0; j < N; j++){
            if((4 *(i) + 7 *(j)) == N ){
                answer++;
            }
        }
    }
    if(answer > 0){
        cout << "Yes" << endl;
    }
    else if(answer == 0){
        cout << "No" << endl;
    }
}

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

int main() {
  int n;
  cin >> n;
  
  vector<int> h(n);
  for (int i = 0; i < n; i++) {
    cin >> h.at(i);
  }
  
  int ans = 1;
  for(int i = 1; i < n; i++) {
    int count = 0;
    for(int j = 0; j < i; j++) {
     if(h.at(j) <= h.at(i)) {
      count++;
     }
    }
    if(count == i) {
      ans++;
    }
  }
  
  cout << ans << endl;
}


Measured memory_bytes: 256
#pragma region template
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const long long MOD = 1e9 + 7, MAX = LLONG_MAX, larg = 1e5, INF = -1e9;
long long A, B, C, D, E, F, G, H, I, J, K, L, N, M, O, P, Q, R, S, T, U, V, W;
typedef long long ll;
typedef pair<ll, ll> Pa;


Pa arr[100000];
int main() {
	cin >> N >> M;
	ll cnt = 0;
	rep(i, M) {
        cin >> A >> B;
        arr[i] = Pa(B, A);
	}
    sort(arr, arr+M);
    ll prev = -1;
    rep(i, M){
        if(prev <= arr[i].second) {
            prev = arr[i].first;
            cnt++;
        }
    }
    cout << cnt;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define inf INT_MAX
#define INF LLONG_MAX
#define ll long long
#define ull unsigned long long
#define M (int)(1e9+7)
#define P pair<int,int>
#define PLL pair<ll,ll>
#define FOR(i,m,n) for(int i=(int)m;i<(int)n;i++)
#define RFOR(i,m,n) for(int i=(int)m;i>=(int)n;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,n,0)
#define all(a) a.begin(),a.end()
#define IN(a,n) rep(i,n){ cin>>a[i]; }
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define F first
#define S second
#define PB push_back
#define EB emplace_back
#define int ll
#define vi vector<int>
#define IP pair<int,P>
#define PI pair<P,int>
#define PP pair<P,P>
#define Yes(f){cout<<(f?"Yes":"No")<<endl;}
#define YES(f){cout<<(f?"YES":"NO")<<endl;}


signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<fixed<<setprecision(20);

  int n,k;
  cin>>n>>k;
  vector<IP> v;
  rep(i,n){
    int a=i,b=n+(i+n/2)%n;
    v.PB(IP(a+b,P(a,b)));
  }

  sort(all(v));
  int sk=inf;
  rep(i,n){
    sk=min(sk,2*n+i-v[i].F);
  }

  if(sk<k){
    cout<<-1<<endl;
  }else{
    rep(i,n){
      cout<<v[i].S.F+k<<' '<<v[i].S.S+k<<' '<<2*n+i+k<<endl;
    }
  }

  


}

Measured memory_bytes: 5232
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
const long double PI = (acos(-1));
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
int ctoi(char c)
{
    switch (c)
    {
    case '0':
        return 0;
    case '1':
        return 1;
    case '2':
        return 2;
    case '3':
        return 3;
    case '4':
        return 4;
    case '5':
        return 5;
    case '6':
        return 6;
    case '7':
        return 7;
    case '8':
        return 8;
    case '9':
        return 9;
    default:
        return 0;
    }
}
int main()
{
    string s;
    cin >> s;
    char beg = s[0];
    char en = s[s.size() - 1];
    int number = s.size() - 2;
    cout << beg << to_string(number) << en << endl;
}

Measured memory_bytes: 256
#define ENABLE_DEBUG 1
// Kana's kitchen {{{
#include<bits/stdc++.h>
#define ALL(v) std::begin(v),std::end(v)
#define LOOP(k) for(i64 ngtkana_is_a_genius=0; ngtkana_is_a_genius<(i64)k; ngtkana_is_a_genius++)

using i32 = std::int_least32_t;
using i64 = std::int_least64_t;
using u32 = std::uint_least32_t;
using u64 = std::uint_least64_t;
using usize = std::size_t;

template <class T, class U> using pair = std::pair<U, T>;
template <class T> using diag_pair = std::pair<T, T>;
template <class... Args> using tuple = std::tuple<Args...>;
template <class T> using vec = std::vector<T>;
template <class T> using numr = std::numeric_limits<T>;

#ifdef NGTKANA
#include<debug.hpp>
#else
#define DEBUG(...)(void)0
#endif
/*}}}*/

int main() {
    std::cin.tie(nullptr);
    std::ios::sync_with_stdio(false);
    std::cout << std::setprecision(15) << std::fixed;

    vec<usize> a(101);
    LOOP (3) {
        usize x;
        std::cin >> x;
        a.at(x) = true;
    }
    std::cout << std::accumulate(ALL(a), 0) << '\n';
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define rep(i, n) ;for (int i = 0;i < (int)(n);i++)
#define rep2(i, s, n) ;for (int i = s; i < (int)(n);i++)
#define ALL(vec)  (vec).begin(),(vec).end()
#define pi 3.1415926535897932384626433832795
#define MAX_INF 9223372036854775807
#define MIN_INF (922337203685477587+1)
#define sosuu 1000000007

int main() {
  string s;
  cin >>  s;
  int a,b,c;
  a=s[0]-'0';
  b=s[1]-'0';
  c=s[2]-'0';
  if(a==b){
  if(b>=c){
    cout << a<<a<<a<<endl;
    return 0;
  }
    else{
    cout << a+1<<a+1<<a+1<<endl;
    return 0;
  }
      
  }
  else if(a>b){
    cout << a<<a<<a<<endl;
    return 0;
  }
  
    else{
    cout << a+1<<a+1<<a+1<<endl;
    return 0;
  }
    
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>

#define int long long
#define MOD7 1000000007
#define MOD9 1000000009

#define rep(i, n) for (int i = 0; i < (n); i++)
#define itrep(i, a) for (auto i = (a).begin(); i != (a).end(); i++)
#define REP(i, a, n) for (int i = (a); i <= (n); i++)
#define all(a) (a).begin(), (a).end()
#define mp(a, b) make_pair((a), (b))

using namespace std;

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

template<class T> void inputVector(vector<T>& v, int n) {
    v.resize(n);
    for (int i = 0; i < v.size(); i++) cin >> v[i];
}

signed main() {
	int N;
	cin >> N;

	int A, B;
	cin >> A >> B;

	int num = abs(A - B);

	cout << (num % 2 ? "Borys" : "Alice") << endl;

    return 0;
}


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

#include <cstdio>

using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repc(i, s, n) for (int i = (s); i <= (n); i++)
#define rrep(i, n) for (int i = (n) - 1; i >= 0; i--)
#define rrepc(i, s, n) for (int i = (s); i >= (n); i--)
typedef long long ll;
typedef unsigned long long ull;

int main()
{
	string s, t;
	map<char, vector<int>> sindex;
	vector<int>::iterator it;
	int prenum = -1, num = 1;
	int s_size, t_size;
	ull cnt = 0;
	ull ans = 0;

	for (char c = 'a'; c <= 'z'; c++) sindex[c].push_back(-1);

	cin >> s >> t;

	s_size = s.length();
	t_size = t.length();

	rep(i, s_size) {
		if (sindex[s[i]][0] == -1) sindex[s[i]].clear();
		sindex[s[i]].push_back(i + 1);
	}

	rep(i, t_size) {
		if (sindex[t[i]][0] == -1) {
			cout << -1 << endl;
			return 0;
		}

		it = upper_bound(sindex[t[i]].begin(), sindex[t[i]].end(), prenum);

		if (it == sindex[t[i]].end()) {
			num = sindex[t[i]][0];
			cnt++;
		}
		else num = *it;

		prenum = num;
	}

	ans = (ull)s_size * cnt + (ull)num;

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 1344
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC085C {
    class Program {
        static void Main(string[] args) {
            int[] input = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
            int N = input[0];
            int Y = input[1];
            int x = 0;
            int y = 0;
            int z = 0;
            bool ok = false;
            while (x <= N && x * 10000 <= Y) {
                int remain = Y - x * 10000;
                int billRemain = N - x;
                y = 0;
                bool b = false;
                while(y <= billRemain && y * 5000 <= remain) {
                    if(y * 5000 + (billRemain - y) * 1000 == remain) {
                        b = true;
                        ok = true;
                        z = billRemain - y;
                        break;
                    }
                    y++;
                }
                if (b) {
                    break;
                }
                x++;
            }
            if (!ok) {
                x = -1;
                y = -1;
                z = -1;
            }
            // Console.Write("改行なし a = {0} b = {1} c = {2}", a, b, c)//改行なし出力
            // Console.WriteLine("改行あり a = {0} b = {1} c = {2}", a, b, c);//改行付き出力
            Console.WriteLine(x.ToString() + " " + y.ToString() + " " + z.ToString());
        }
    }
}

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

int main(void){
  int n;
  cin >> n;
  long long a[n];
  for(int i = 0; i < n; i++) cin >> a[i];
  sort(a, a + n);
  long long sn = a[n - 1];
  int ans = n - 1;
  for(int i = 0; i < n - 1; i++){
    long long temp = abs(a[i] - a[n - 1]);
    temp = max(temp, a[i]);
    if(sn >= temp){
      ans = i;
      sn = temp;
    }
  }
  cout << a[n - 1] << " " << a[ans] << endl;
  return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define inf 0x3f3f3f3f
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef double dd;
const int N = 1e4+5;
const dd eps = 1e-8;
const int mod = 1e9+7;

ll a,b,c;


int main(){
  ios::sync_with_stdio(false);
  // freopen("input.txt","r",stdin);
  cin>>a>>b;
  for(dd i = 1;i <= N;i++){
    int a1 = floor(i*0.08);
    int a2 = floor(i*0.1);
    if(a1 == a && a2 == b){
      cout<<i<<endl;
      return 0;      
    }
  }
  cout<<"-1"<<endl;  
  return 0;
}


Measured memory_bytes: 256
/*ॐ नमो भगवते वासुदेवाय नमः*/
#include<bits/stdc++.h>
using namespace std;

#define int long long
#define F first
#define S second
#define all(x) (x).begin(), (x).end()
#define allrev(x) (x).rbegin(), (x).rend()
#define pb push_back
#define pf push_front
#define fori(i, a, n) for(int i = a; i < n; ++i)
#define MAX(x) (*max_element(all(x)))
#define MIN(x) (*min_element(all(x)))
#define sortarr(a, n) sort(a, a + n)
#define sortvec(V) sort(all(V))

struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }
    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};

typedef unordered_map<int, int, custom_hash> u_map;
typedef unordered_set<int, int, custom_hash> u_set;
typedef vector<int> V;
typedef pair<int , int> pairi;
typedef set<int> seti;
typedef priority_queue<int> p_queue;
typedef deque<int> deqi;

const int MOD = 1e9+7;
const int INF = 1e9+8;
const double pi = 3.14159265359;

int binpow(int a, int b, int m) {
    a %= m;
    int res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a % m;
        a = a * a % m;
        b >>= 1;
    }
    return res;
}

void solve()
{
    int n, sum = 0;
    cin >> n;
    V a(n);
    for(auto & i : a)   cin >> i, sum += i;
    int sum1 = sum/n, sum2;
    if(sum % n) sum2 = sum/n + 1;
    int ans = 0, ans1 = 0;
    for(auto i : a) ans += ((sum1 - i) * (sum1 - i));
    for(auto i : a) ans1 += ((sum2 - i) * (sum2 - i));
    cout << min(ans, ans1) << endl;
}

signed main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
    solve();
    cerr << "Time elapsed : " << 1.0 * clock() / CLOCKS_PER_SEC << " sec \n ";
}

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

typedef long long ll;

const int MN = 1e7 + 12;

ll f[MN];

int main (void) {
  ios::sync_with_stdio(false);cin.tie(0);
  for (int i = 1; i < MN; i++)
    for (int j = i; j < MN; j += i)
      f[j]++;
  int n; cin >> n;
  ll res = 0;
  for (ll i = 1; i <= n; i++)
    res += i * f[i];
  cout << res << '\n';
  return 0;
}



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

#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define RFOR(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define LL long long
#define INF INT_MAX/3

const double EPS = 1e-14;
const double PI  = acos(-1.0);


void output(int n, char c) {
  REP (i, n) printf("%c", c);
}

int main(){
  int sx, sy, tx, ty;

  scanf("%d %d %d %d", &sx, &sy, &tx, &ty);

  output(tx - sx, 'R');
  output(ty - sy, 'U');
  output(tx - sx, 'L');
  output(ty - sy + 1, 'D');
  output(tx - sx + 1, 'R');
  output(ty - sy + 1, 'U');
  output(1, 'L');
  output(1, 'U');
  output(tx - sx + 1, 'L');
  output(ty - sy + 1, 'D');
  output(1, 'R');
  printf("\n");
}


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

int main()
{
    int N, K;
    cin >> N >> K;
    long long ans = 1;
    for (int i = 0; i < N; ++i) {
        ans = min(2 * ans, ans + K);
    }
    cout << ans << endl;
}


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

int main() {
    int S,W;
    cin >> S>>W;
    if(S<=W){
        cout << "unsafe" << endl;
    }else{
        cout << "safe" << endl;
    }
}

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

int main(void){
    int n, k, q;
    std::cin >> n >> k >>q;
    std::vector<int> at(n);
    for(int i = 0; i < q; i++){
        int a;
        std::cin >> a;
        a--;
        at[a]++;
    }
    for(int i = 0; i < n; i++){
        if(k - q + at[i] > 0) std::cout << "Yes" << std::endl;
        else std::cout << "No" << std::endl;
    }
    return 0;
}

Measured memory_bytes: 3796
s1 = input()
s1r = s1[::-1]
n1 = len(s1)
s2 = s1[:(n1-1)//2]
s2r = s2[::-1]
s3 = s1[-(n1-1)//2:]
s3r = s3[::-1]
if s1 == s1r and s2 == s2r and s3 == s3r:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 9000
import java.util.*;

public class Main {
	public static void main(String[] args){
 
        Scanner sc = null;
        sc = new Scanner(System.in);
        int n = sc.nextInt();
        int d = sc.nextInt();
        double w_num = 0;
        long p = 0;
        long q = 0;
        double sqNum = 0;
        int ans = 0;
        for (int i = 0; i < n; i++) {
            p = sc.nextLong();
            q = sc.nextLong();
            w_num = (double)Math.pow(p, 2) + (double)Math.pow(q, 2);
            sqNum = (double)Math.sqrt(w_num);
            if (sqNum <= d){
                ans += 1;
            }
          }
          sc.close();
        System.out.println(ans);
      
      }
}

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

#define N 200000
#define M 100

int main(){
	long int n, i, j,flag = 0, ans = 0;

	cin >> n;
	if (n != 2) {
		for (i = n; i <= 1000000; i++) {
			for (j = 2; j <= i / 2; j++) {
				if (i % j == 0) {
					flag = 1;
				}
			}
			if (flag == 0) {
				ans = i;
				break;
			}
			flag = 0;
		}
	}
	else {
		ans = 2;
	}

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

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define Rep(i,n) for(int i=0;i<n;i++)
#define For(i,n1,n2) for(int i=n1;i<n2;i++)
#define REP(i,n) for(ll i=0;i<n;i++)
#define RREP(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,n1,n2) for(ll i=n1;i<n2;i++)
#define put(a) cout<<a<<"\n"
#define all(a)  (a).begin(),(a).end()
#define SORT(a) sort((a).begin(),(a).end())
#define oorret 0
#define oor(x) [&](){try{x;} catch(const out_of_range& oor){return oorret;} return x;}()
typedef long long ll;
typedef pair<int, int> P;
template<typename T1,typename T2> inline bool chmin(T1 &a,T2 b){if(a>b){a=b;return 1;}return 0;}
template<typename T1,typename T2> inline bool chmax(T1 &a,T2 b){if(a<b){a=b;return 1;}return 0;}

int main(){
    int n;
    cin >> n;
    int a = n;
    vector<int> b(1e7,0);
    b[a] = 1;
    const int inf = 1e7;
    REP(i,inf){
        if(a%2==0){
            a /= 2;
        }else{
            a = a*3+1;
        }
        if(b[a]==0){
            b[a]=1;
        }else{
            put(i+2);
            break;
        }
    }
    return 0;
}


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

#define _USE_MATH_DEFINES
#include<cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iterator>
#include<iomanip>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
#include<complex>

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

//typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;
typedef vector< vector<int> > mat;

template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return true; } return false; }

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD =  (int)1e9 + 7;
const double EPS = 1e-9;

int get_gcd(int n, int m) {
	if (n < m) swap(n, m);
	while (m) {
		swap(n, m);
		m %= n;
	}
	return n;
}

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

	int K;
	cin >> K;
	int ans = 0;
	rep(i, 1, K + 1)rep(j, 1, K + 1)rep(k, 1, K + 1)
	{
		ans += get_gcd(get_gcd(i, j), k);
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 3608
#include <stdio.h>
#include <string.h>
#define slimit 1001    /*文字列数限界*/
#define climit 7    /*命令文字数限界*/

int main(void){
    /*宣言部*/
        /*input:加工対象文字列, command:命令文字列, buf:バッファ用文字列*/
    char input[slimit]={0}, command[climit]={0}, buf[slimit]={0};    
    int cnum, arg1, arg2, x, y;    /*cnum:命令数, arg1:1番目引数,
                                 arg2:2番目引数, x:ループ変数, y:ループ変数*/
    
    /*入力部*/
    scanf("%s\n%d", input, &cnum);    /*加工対象文字列と命令数を読み取る*/
        /*命令とそれに続く引数は受取・実行時に行う*/
        
    /*命令・引数受取・実行部*/
    for(x=0; cnum>x; x++){    /*命令数回ループ*/
        /*命令・引数受取部*/
            /*命令と2番目までの引数の読み取り*/
        scanf("%s %d %d", command, &arg1, &arg2);
        
        /*命令実行部*/
        if (0 == strcmp("print", command)){    /*print命令処理*/
                /*指定文字部分だけをバッファにコピー*/
            strncpy(buf, &input[arg1], (arg2-arg1)+1);
            printf("%s\n", buf);    /*バッファを表示*/
        
        }else if (0 == strcmp("reverse", command)){    /*reverse命令処理*/
            strncpy(buf, &input[arg1], (arg2-arg1)+1);
                /*指定文字部分だけをバッファにコピー*/
            for(y=0; (arg2-arg1)+1>y; y++){    /*バッファ文字数分ループ*/
                    /*バッファを後ろから順に読み込み
                        加工対象の指定された所から代入*/
                input[arg1+y] = buf[arg2-arg1-y];
            }
        }else if (0 == strcmp("replace", command)){    /*replace命令処理*/
            scanf("%s", &buf); /*入力バッファに残ってる3番目の引数を受け取る*/
        
            for(y=0; (arg2-arg1)+1>y; y++){    /*バッファ文字数分ループ*/
                    /*バッファを指定文字数分だけ加工対象の指定位置に代入*/
                input[arg1+y] = buf[y];
            }
        }
        
        strncpy(buf, "", slimit);    /*次の命令に影響を残さないために
                                        バッファをナル文字で埋める*/
    }
    
    return 0;
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define pb push_back
#define all(v) v.begin(),v.end()
#define fi first
#define se second
#define bigger (char)toupper
#define smaller (char)tolower
using namespace std;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<string> vs;
typedef vector<char> vc;
typedef long long ll;
typedef unsigned long long ull;

int main() {
    int X;
    cin>>X;
    vi v={1,4,8,9,16,25,27,32,36,49,64,81,100,121,125,128,144,169,196,216,225,243,256,289,324,343,361,400,441,484,512,529,576,625,676,729,784,841,900,961,1000};
    int N=v.size();
    int answer;
    rep(i,N) {
        if(v[i]<=X) answer=v[i];
    }
    cout<<answer<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>
#include <tuple>
#include <cstdio>
#include <bitset>
#include <sstream>
#include <iterator>
#include <numeric>
#include <map>
#include <cstring>
#include <set>
#include <functional>
#include <iomanip>

using namespace std;

//#define DEBUG_ //!!提出時にコメントアウト!!
#ifdef DEBUG_
	#define dump(x)  cerr << #x << " = " << (x) << endl;
#else
	#define dump(x)  ;
#endif

#define equals(a,b) (fabs((a)-(b)) < EPS)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SZ(x) ((int)(x).size())
#define pb push_back
#define eb emplace_back

//#define int long long

typedef long long LL;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

template <typename T>
std::string printVector(const std::vector<T> &data)
{
    std::stringstream ss;
    std::ostream_iterator<T> out_it(ss, ", ");
    ss << "[";
    std::copy(data.begin(), data.end() - 1, out_it);
    ss << data.back() << "]";
    return ss.str();
}

template <typename T>
void print_array(const T &ary, int size){
    REP(i,size){
        cout << ary[i] << " ";
    }
    cout << endl;
}

const int MOD = 1e9+7;
const LL LINF = 1001002003004005006ll;
const int INF = 1001001001;
const double EPS = (1e-10);
const int MAX_N = 1e5+10;

VVI g;
int dp[MAX_N];

int dfs(int v){
    if(dp[v] != -1) return dp[v];
    int res = 0;
    for(int u : g[v]){
        chmax(res,dfs(u)+1);
    }
    return dp[v] = res;
}

signed main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << setprecision(12);
    int N,M; cin >> N >> M;
    g.resize(N);
    memset(dp,-1,sizeof(dp));
    REP(i,M){
        int x,y; cin >> x >> y;
        x--; y--;
        g[x].eb(y);
    }
    int ans = 0;
    REP(i,N){
        dump(i)
        dump(dfs(i))
        chmax(ans,dfs(i));
    }
    cout << ans << endl;


}


Measured memory_bytes: 8192
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val v = (n / 1.08).toInt()
    when (n) {
        ((v - 1) * 1.08).toInt() -> println(v - 1)
        (v * 1.08).toInt() -> println(v)
        ((v + 1) * 1.08).toInt() -> println(v + 1)
        else -> println(":(")
    }
}

Measured memory_bytes: 31736
def gcd(a,b):
  while b>0:
    a,b=b,a%b
  return a
 
x,y=map(int,input().split())
S=input()
T=input()
GCD=gcd(x,y)
LCM=(x * y) // GCD
 
x_new=x//GCD
y_new=y//GCD
for i in range(0,GCD):
  if S[(x_new)*i]==T[(y_new)*i]:
    result=LCM
  else:
    result=-1
    break
print(result)

Measured memory_bytes: 3316
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace AtCoder
{
	public class Program
	{
		// ABC103-B
		static void Main(string[] args)
		{
			string S = Console.ReadLine();
			string T = Console.ReadLine();
			if (S.Length != T.Length) {
				Console.WriteLine("No");
				return;
			}
			int len = S.Length;
			for (int i = 0; i < len; i++) {

				bool f = true;
				for (int j = 0; j < len; j++) {
					int k = (i + j) % len;
					if (S[j] != T[k]) {
						f = false;
						break;
					}
				}
				if (f) {
					Console.WriteLine("Yes");
					return;
				}

			}
			Console.WriteLine("No");
			return;
		}
	}

}


Measured memory_bytes: 11092