akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define int long long
using namespace std;
const double pi=acos(-1);
struct node
{
	int x,y;
	double ang;
}a[400010];
inline bool cmp(node x,node y)
{
	return x.ang<y.ang;
}
signed main()
{
	int n;
	int sx=0,sy=0,ans=0;
	scanf("%lld",&n);
	for(register int i=1;i<=n;i++)
	{
		scanf("%lld%lld",&a[i].x,&a[i].y);
		a[i].ang=atan2(a[i].y,a[i].x);
	}
	sort(a+1,a+n+1,cmp);
	for(register int i=1,p=1;i<=n;i++)
	{
		while(p<i+n && a[p].ang-a[i].ang<pi)
		{
			sx+=a[p].x;
			sy+=a[p++].y;
			ans=max(ans,sx*sx+sy*sy);
		}
		sx-=a[i].x;
		sy-=a[i].y;
		ans=max(ans,sx*sx+sy*sy);
		a[i+n].x=a[i].x;
		a[i+n].y=a[i].y;
		a[i+n].ang=a[i].ang+2*pi;
	}
	printf("%.11lf\n",sqrt(ans));
	return 0;
}

Measured memory_bytes: 384
#include<iostream>

using namespace std;

const int N = (int) 1e5;
int n,k;
long long a[N+5],ans=(long long)2e15;
int main()
{

    cin>>n>>k;
    for(int i=1;i<=n;i++)
        cin>>a[i];
    for(int i=1;i+k-1<=n;i++)
    {
        int l=i,r=i+k-1;
        ans=min(ans,a[r]-a[l]+min(abs(a[l]),abs(a[r])));
    }
    cout<<ans;
    return 0;
}


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


int main(){
    ll A,B,C,K;
    cin >> A >> B >> C >> K;
    ll ans = 0;
    if(K <= A) ans = K;
    else if(K <= A + B) ans = A;
    else{
        ll tmp = K - (A + B);
        ans = A - tmp;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3624
H,W,K = map(int,input().split())
data_list = [list(input()) for i in range(H)]
ans = 0
for i in range(1<<H):
    for j in range(1<<W):
        Black = 0
        for ii in range(H):
            for jj in range(W):
                if(data_list[ii][jj] == "#" and (i>>ii) & 1 == 0 and (j>>jj) & 1 == 0):
                    Black+=1
        if(Black == K):
            ans += 1

print(ans)

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

int main() {
    int n;
    cin>>n;
    vector<int>arr(n);
    for(int i=0;i<n;i++)
        cin>>arr[i];
    int ans=1;
    for(int i=0;i<n;i++){
        if(arr[i]%2==0){
            if(arr[i]%3==0 || arr[i]%5==0)
                continue;
            else
                ans=0;
        }
    }
    if(ans==1)
        cout<<"APPROVED";
    else
        cout<<"DENIED";
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;
int main(){
	int a,b;
	char s[20];
	bool t=1;
	scanf("%d%d",&a,&b);
	scanf("%s",s);
	for(int i=0;i<a+b+1;i++){
		if(!(s[i]>='0'&&s[i]<='9')&&i!=a){
			t=0;
		}
	}
	if(s[a]!='-'){
		t=0;
	}
	printf("%s",(t?"Yes":"No"));
return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#define DEBUG

int main()
{
    int n, i;
    double sum = 0;
    double in[100] = {};

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

    //solve
    for(i = 0; i < n; i++)
    {
        in[i] = 1 / in[i];
        sum += in[i];
    }
    double ans = 1 / sum;

    //write
    printf("%f\n", ans);

    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <string>

using namespace std;

int main(){
    int N;
    cin >> N;
    int p, q;
    // vector<int> P(N), Q(N);
    string P = "", Q = "";
    for(int i = 0; i < N; ++i){
        cin >> p;
        P += to_string(p);
    }
    for(int i = 0; i < N; ++i){
        cin >> q;
        Q += to_string(q);
    }
    int perSize = 1;
    for(int i = N; i > 0; --i){
        perSize *= i;
    }
    // vector<string> table(perSize);
    vector<int> tmp(N);
    int tableIndex = 0;
    int Pindex , Qindex;
    iota(tmp.begin(), tmp.end(), 1);
    do{
        string Stmp = "";
        for(int i = 0; i < N; ++i){
            Stmp += to_string(tmp[i]);
        }
        // table[tableIndex] = Stmp;
        // cout << table[tableIndex] << Stmp  << endl; 
        if(Stmp == P) Pindex = tableIndex;
        if(Stmp == Q) Qindex = tableIndex;
        tableIndex++;
    }while(next_permutation(tmp.begin(), tmp.end()));
    cout << abs(Qindex - Pindex) << endl;

    return 0;   
}

Measured memory_bytes: 256
#include <stdio.h>

#define MAX 1000

int main() {
  int n;
  int A[MAX];
  int v;
  int j;

  scanf("%d", &n);
  for(int i = 0; i < n; i++) {
    scanf("%d", &A[i]);
    if(n < 1 && n > 100) {
      printf("Error: out of range.");
      return -1;
    }
  }

  /* for(int i = 0; i < n; i++) { */
  /*   printf("%d", A[i]); */
  /* } */

  for(int i = 1; i < n; i++) {
    printf("%d", A[0]);
    for(int i = 1; i < n; i++) {
      printf(" %d", A[i]);
    }
    printf("\n");
    v = A[i];
    j = i - 1;
    while (j >= 0 && A[j] >= v) {
      A[j + 1] = A[j];
      A[j] = v;
      j--;
    }
  }
  printf("%d", A[0]);
  for(int i = 1; i < n; i++) {
    printf(" %d", A[i]);
  }
  printf("\n");
}

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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef pair<ull, ull> pullull;
typedef pair<ll, int> plli;
typedef pair<int, pii> pipii;
typedef vector<vector<int> > mati;
typedef vector<vector<double> > matd;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<vector<vector<ll>>> vvvll;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<vector<vector<bool>>> vvvb;
typedef vector<pll> vpll;

#define FOR(i,x,y) for(ll i=(ll)x; i<(ll)y; ++i)
#define REP(i,y) FOR(i, 0, y)
#define RFOR(i,x,y) for(ll i=(ll)x; i>=(ll)y; --i)
#define RREP(i,x) RFOR(i, x, 0)
#define ALL(a) a.begin(), a.end()
#define pb push_back

inline void IN(void){
  return;
}

template <typename First, typename... Rest>
void IN(First& first, Rest&... rest){
  cin >> first;
  IN(rest...);
  return;
}

inline void OUT(void){
  cout << "\n";
  return;
}

template <typename First, typename... Rest>
void OUT(First first, Rest... rest){
  cout << first << " ";
  OUT(rest...);
  return;
}

constexpr int INF = (1<<30);
constexpr ll INFLL = 1LL<<62;
constexpr long double EPS = 1e-12;
constexpr ll MOD = (ll)((1E+9)+7);

int main(){
  ll N, K;
  IN(N,K);

  ll ans = N-(K-1)-1;
  if(K==1) ans = 0;

  OUT(ans);

  return 0;
}

Measured memory_bytes: 256
s = str(input())
n = len(s)
for i in range((n-1)//2):
  if s[i] != s[(n-1)//2-i-1]:
    print("No")
    exit()
for i in range((n-1)//2):
  if s[i] != s[i-1+(n+3)//2]:
    print("No")
    exit()
print("Yes")
    
  
    
    
    
    
  

Measured memory_bytes: 2940
#include <iostream>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <algorithm>

#define rep(i, N) for(int (i) = 0; (i) < (N); (i) ++)
typedef long long ll;

using namespace std;

int main(){
    int N;
    cin >> N;
    vector<int> as(N, 0);
    vector<int> bs(N, 0);
    vector<int> cs(N, 0);
    rep(i, N){
        cin >> as[i];
    }
    rep(i, N){
        cin >> bs[i];
    }
    rep(i, N){
        cin >> cs[i];
    }
    sort(as.begin(), as.end());
    sort(cs.begin(), cs.end());
    ll ans = 0;
    rep(i, N){
        auto iter1 = lower_bound(as.begin(), as.end(), bs[i]);
        ll a_num = iter1 - as.begin();
        auto iter2 = upper_bound(cs.begin(), cs.end(), bs[i]);
        ll c_num = cs.end() - iter2;
        ans += a_num * c_num;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1408
#include<stdio.h>

int main(void){
	int a;
	int b;
	int c;
	int k;

	while( (scanf("%d %d", &a,&b) != EOF) && (a>=0 && b>=0)){

	k=1;

		for(c=(a+b)/10;c!=0;k++)
			c/=10;

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


		return 0;
}

Measured memory_bytes: 600
package main

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

var stdin = bufio.NewScanner(os.Stdin)

func main() {
	n := func() float64 { stdin.Scan(); i, _ := strconv.Atoi(stdin.Text()); return float64(i) }()
	h := round(n / 2)
	fmt.Printf("%.10f", h/n)
}

func round(f float64) float64 {
	return math.Floor(f + .5)
}


Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
int main(void){
    int n,m,x; cin>>n>>m>>x;
    int a[101]={},anow;
    for(int i=0;i<m;i++){
        cin>>anow;
        a[anow]=1;
    }
    int sum=0;
    for(int i=0;i<x;i++){
        sum+=a[i];
    }
    cout<<min(sum,m-sum);
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt(); long T = sc.nextLong();
		long ans = 0;
		long time = sc.nextLong();
		for(int i = 1; i < N; i++) {
			long t = sc.nextLong();
			if(time + T < t) {
				ans += T;
				time = t;
			}else {
				ans += t - time;
				time = t;
			}
		}
		System.out.println(ans + T);
	}
}

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

typedef long long ll;
typedef long double ld;

#define pb push_back
#define sort(s) sort(s.begin(),s.end())
#define reverse(s) reverse(s.begin(),s.end())
#define rep(i,n) for(ll (i)=0;(i)<(n);(i)++)

const ll mod = 1e9+7;

//最大公約数
ll gcd(ll a, ll b) {
    return b ? gcd(b, a%b) : a;
}

//最小公倍数
ll lcm(ll a, ll b) {
    return a / gcd(a, b) * b;
}

//素数判定
bool isPrime(ll x){
    ll i;
    if(x < 2)return 0;
    else if(x == 2) return 1;
    if(x%2 == 0) return 0;
    for(i = 3; i*i <= x; i += 2) if(x%i == 0) return 0;
    return 1;
}

//桁和
int digsum(ll n) {
    int res = 0;
    while(n > 0) {
        res += n%10;
        n /= 10;
    }
    return res;
}

//桁数
int dignum(ll n) {
    int res = 0;
    while(n > 0) {
        res++;
        n /= 10;
    }
    return res;
}

//文字列中の特定の文字カウント
ll stringcount(string s,char c){
    return count(s.cbegin(),s.cend(),c);
}

//階乗
ll ka(ll i){
    ll res=1;
    while(i>0){
        res=res*i;
        i--;
    }
    return res;
}
 
//ncr
ll ncr(ll x,ll y){
    ll a = x;
    ll b = 1;
    if(y>(x/2)){
        y=x-y;
    }
    for(ll i=1;i<y;i++){
        a*=x-i;
        b*=i+1;
    }
    return a/b;
}

//フィボナッチ数列 -92
ll f(ll x){
    ll dp[x+1];
    dp[1]=1;
    dp[2]=1;
    for(ll i=3;i<=x;i++){
        dp[i]=dp[i-1]+dp[i-2];
    }
    return dp[x];
}



int main(){
    int n;
    cin >> n;
    ll a[n];
    rep(i,n) cin >> a[i];

    ll x = gcd(a[0],a[1]);

    for(int i=2;i<n;i++){
        x = gcd(x,a[i]);
    }

    int count=0;

    while(true){
        if(x%2==0){
            count++;
            x/=2;
        }else{
            break;
        }
    }

    cout << count << endl;
}

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

int main() {
    int N;
    cin >> N;
    
    pair<int, int> x[N];
    // (x_n, n)を保持
    
    for (int i = 0; i < N; ++i) {
        cin >> x[i].first;
        x[i].second = i + 1;
    }
    sort(x, x + N);
    // x_nでソート

    int a[N * N + 1], now = 0;
    fill(a, a + N * N + 1, -1);
    // aは1-indexed 埋まってなければ-1
    // 今a[now]まで埋まっている

    // x_nの小さい方から埋めていく
    for (int i = 0; i < N; ++i) {
        int idx, n;
        tie(idx, n) = x[i];
        a[idx] = n;

        // -1の箇所にnを左から詰めていく
        for (int j = 0; j < n - 1; ++j) {
            while (true) {
                if (a[++now] < 0) {
                    a[now] = n;
                    break;
                }
            }
        }

        // idxより左側にn-1個埋められなかったらアウト
        if (now > idx) {
            cout << "No" << endl;
            return 0;
        }
    }

    // 大小反転して同じことをする
    now = N * N + 1;
    for (int i = N - 1; i >= 0; --i) {
        int idx, n;
        tie(idx, n) = x[i];

        for (int j = n; j < N; ++j) {
            while (true) {
                if (a[--now] < 0) {
                    a[now] = n;
                    break;
                }
            }
        }

        if (now < idx) {
            cout << "No" << endl;
            return 0;
        }
    }

    cout << "Yes" << endl;
    for (int i = 1; i <= N * N; ++i) {
        cout << a[i] << " ";
    }
    cout << endl;

    return 0;
}

Measured memory_bytes: 2176
#include<bits/stdc++.h>
#include <vector>
  using namespace std;
  #define ll  long long
   
  
long long n,i,k,j;


int  main() {
  
  ll a , b;
  cin >> a >> b;
  cout << a*b;
 
  
}


   
   
      
        
        
    

  	
      
      	


    


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

#define fo(i,s,t) for(int i = s; i <= t; ++ i)
const int maxn = 200001;
const int inf = 1<<30;

int n, p[maxn], q[maxn], tot;
int mn_odd[20][maxn], mn_even[20][maxn];
struct node
{
	int s, t, v1, v2, id;
	node(){}
	node(int _,int __,int ___,int ____,int _____){s=_;t=__;v1=___;v2=____;id=_____;}
	friend bool operator<(node a, node b){return p[a.v1] > p[b.v1];}
}h;
priority_queue<node> pq;

int rmq(int mk, int l,int r)
{
	int k = log((double)(r-l+1))/log(2.0);
	if(mk == 1)
	{
		if(p[mn_even[k][l]] < p[mn_even[k][r-(1<<k)+1]]) 
			return mn_even[k][l];
		else
			return mn_even[k][r-(1<<k)+1];
	}
	else
	{
		if(p[mn_odd[k][l]]< p[mn_odd[k][r-(1<<k)+1]])
			return mn_odd[k][l];
		else
			return mn_odd[k][r-(1<<k)+1];
	}
}
int main()
{
	scanf("%d",&n); fo(i,0,n-1) scanf("%d",&p[i]); p[n] = inf;
	fo(i,0,n-1) 
		if(i%2==0) mn_even[0][i] = i, mn_odd[0][i] = n; 
		else mn_odd[0][i] = i, mn_even[0][i] = n;
	fo(j,1,19) fo(i,0,n-1) 
		if(i+(1<<(j-1)) >= n) break;
		else 
		{
			if(p[mn_even[j-1][i]] < p[mn_even[j-1][i+(1<<(j-1))]])
				mn_even[j][i] = mn_even[j-1][i];
			else
				mn_even[j][i] = mn_even[j-1][i+(1<<(j-1))];
			if(p[mn_odd[j-1][i]] < p[mn_odd[j-1][i+(1<<(j-1))]])
				mn_odd[j][i] = mn_odd[j-1][i];
			else
				mn_odd[j][i] = mn_odd[j-1][i+(1<<(j-1))];
		}
	int p1, p2, p3;
	pq.push(node(0,n-1,-1,-1,1));
	while(!pq.empty())
	{
		h = pq.top(); pq.pop();
		p1 = rmq(h.id,h.s,h.t); p2 = rmq(h.id^1,p1+1,h.t);
		// cout << h.s << ' ' << p1 << ' ' << p2 << ' ' << h.t << endl;
		q[++tot] = p[p1]; q[++tot] = p[p2];
		if(h.s<p1-1) pq.push(node(h.s,p1-1,rmq(h.id,h.s,p1-1),rmq(h.id^1,rmq(h.id,h.s,p1-1)+1,p1-1),h.id));
		if(p1+1<p2-1) pq.push(node(p1+1,p2-1,rmq(h.id^1,p1+1,p2-1),rmq(h.id,rmq(h.id^1,p1+1,p2-1)+1,p2-1),h.id^1));
		if(p2+1<h.t) pq.push(node(p2+1,h.t,rmq(h.id,p2+1,h.t),rmq(h.id^1,rmq(h.id,p2+1,h.t)+1,h.t),h.id));
	}
	fo(i,1,tot) printf("%d ",q[i]);
	return 0;
}


Measured memory_bytes: 35188
#include <bits/stdc++.h>
using namespace std;
int main(void){
    
    int N, P, f=200001, ans=0;
    cin >> N ;
    for(int i=0; i<N; i++){
        cin >> P;
        if(f>P){
            ans++;
            f=P;
        }
    }
    cout << ans << endl;
    
}

Measured memory_bytes: 256
#pragma GCC optimize("O3")  
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define endl "\n"
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) (a*b)/gcd(a,b)
#define mem(z,i) memset(z,i,sizeof(z))
#define eps 1e-7
#define I (int)
const int mod=(int)1e9+7;
const long long INF = 1000000000000000000LL;
//const int WASTE=∞;
//#define int long long
int power(int a,int b,int m){
	int i=1;
	while(b){
		if(b%2)
			i=(i*a)%mod;
		b/=2;
		a=(a*a)%mod;
	}
	return i;	
}
const int N=1e5+5;
int n,h,a[10001],b[10001];
int dp[10001];
int f(int x,int c){
	if(x<=0)
		return dp[0]=c;
	if(dp[x]!=-1) return dp[x]+c;
	
	int i=INT_MAX;
	for(int y=1;y<=n;y++)
		i=min(i,f(x-a[y],b[y]));
	dp[x]=i;
	return dp[x]+c;
}
signed main() {
	ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
    cin>>h>>n;
    for(int x=1;x<=n;x++)
    	cin>>a[x]>>b[x];
    for(int x=0;x<10001;x++) dp[x]=-1; 
    int ans=f(h,0);
    cout<<ans;
	return 0;
}

Measured memory_bytes: 768
//q073.cpp
//Thu Sep  3 22:01:38 2020

#include <iostream>
#include <string>
#include <queue>
#include <map>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <math.h>
#include <set>
#define INTINF 2147483647
#define LLINF 9223372036854775807
#define MOD 1000000007
#define rep(i,n) for (int i=0;i<(n);++i)

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

//nCk を1000000007で割った余りの計算。
const ll MAX = 1000010;
ll 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;
	}
}

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

int main(){
	ll x,y;
	cin >> x >> y;

	ll total = -1;
	ll par = -1;
	for (ll i=0;i<1000010;i++){
		ll a = 1*i;
		ll b = 2*i;
		if (b>y) break;
		if ((x-a)%2==0 && (x-a)/2==y-b){
			total = i+y-b;
			par = i;
			break;
		}
	}

	if (total==-1){
		cout << 0 << endl;
		return 0;
	}

	COMinit();
	cout << COM(total,par) << endl;
}

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

int A,B;
string S;

int main()
{
    scanf("%d%d",&A,&B);
    cin >> S;
    for(int i = 0; i < A; i++)if('0' > S[i] || S[i] > '9')
    {
        printf("No\n");
        return 0;
    }
    if(S[A] != '-')
    {
        printf("No\n");
        return 0;
    }
    for(int i = A + 1; i < A + 1 + B; i++)if('0' > S[i] || S[i] > '9')
    {
        printf("No\n");
        return 0;
    }
    printf("Yes\n");
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cmath>
using namespace std;
int S(long long x)
{
	int r=0;
	while(x)
		r+=x%10,x/=10;
	return r;
}
int main()
{
	long long k,p=2,q=1;
	scanf("%d",&k);
	while(k)
	{
		long long n=p*q-1,m=ceil((double)p/10.0)*q*10-1;
		if(n*S(m)>m*S(n))
			p=ceil((double)p/10.0),q*=10;
		else
		{
			printf("%lld\n",n);
			k--,p++;
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
 int N;
  cin>>N;
  vector<int>B(N-1);
  for(int i=0;i<N-1;i++)
    cin>>B.at(i);
  vector<int>A(N);
  A.at(0)=B.at(0);
  A.at(N-1)=B.at(N-2);
for(int i=1;i<N-1;i++)
  A.at(i)=min(B.at(i),B.at(i-1));
  int ans=0;
  for(int i=0;i<N;i++)
    ans+=A.at(i);
  cout<<ans<<endl;
    return 0;
}

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

int main()
{
int N;
int K;

	ios::sync_with_stdio( false );
	cin.tie( 0 );

	cin >> N;
	cin >> K;

	if( N % K == 0 )
		cout << 0 << endl;
	else
		cout << 1 << endl;

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int gi() {
    int x=0,o=1;char ch=getchar();
    while((ch<'0'||ch>'9')&&ch!='-') ch=getchar();
    if(ch=='-') o=-1,ch=getchar();
    while(ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();
    return x*o;
}
int n;
int main() {
    n=gi();
    if(n==3) return puts("2 5 63"),0;
    if(n==4) return puts("2 5 20 63"),0;
    if(n==6) return puts("2 3 4 5 6 10"),0;
    for(int x=1;x<=5000;x++)
        for(int y=1;y<=2500;y++) {
            int z=n-2*x-2*y;
            if(0<=z&&z<=5000) {
                x*=2,y*=2;
                int cnt=0;
                for(int i=1;i<=30000;i++)
                    if(i%2==0&&i%3!=0) {
                        printf("%d ",i),++cnt;
                        if(cnt==x) break;
                    }
                cnt=0;
                for(int i=1;i<=30000;i++)
                    if(i%2!=0&&i%3==0) {
                        printf("%d ",i),++cnt;
                        if(cnt==y) break;
                    }
                for(int i=6;i<=6*z;i+=6) printf("%d ",i);
                return 0;
            }
        }
    return 0;
}


Measured memory_bytes: 384
/* C++標準ヘッダファイル */
/* 文字列ライブラリ */
#include <string>

/* コンテナライブラリ */
#include <array>
#include <vector>
#include <deque>
#include <list>
#include <forward_list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <stack>
#include <queue>

/* アルゴリズムライブラリ */
#include <algorithm>

/* 数値演算ライブラリ */
#include <cmath>
#include <math.h>

/* 入出力ライブラリ */
#include <iostream>

/* std使用<-namespace */
using namespace std;

/* define */
#define rpt(i, n) for(ll i = 0; i < (n); i++)  // リピート
#define PI (acos(-1))  // 円周率pi

/* typedef */
// long long
typedef long long ll;

// pair
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
typedef pair<double, double> d_d;


/* main関数 */
int main(void) {
	double a, b, x;
	cin >> a >> b >> x;
	double s = x / a, rad;

	if (s <= a * b / 2) {
		rad = atan(a * pow(b, 2) / 2 / x);
	}
	else {
		rad = atan(2 * (b / a - x / pow(a, 3)));
	}

	printf("%.10f", rad / PI * 180);

	return 0;
}


Measured memory_bytes: 384
import java.io.*;
import java.util.*;

public class Main {
    static class Writer {
        PrintWriter cout;

        Writer() throws IOException {
            cout = new PrintWriter(System.out);
        }

        Writer(String name) throws IOException {
            cout = new PrintWriter(new FileWriter(name));
        }

        StringBuilder out = new StringBuilder();

        void print(Object a) {
            out.append(a);
        }

        void close() {
            cout.print(out.toString());
            cout.close();
        }
    }

    static class Reader {
        BufferedReader in;

        Reader() throws IOException {
            in = new BufferedReader(new InputStreamReader(System.in));
        }

        Reader(String name) throws IOException {
            in = new BufferedReader(new FileReader(name));
        }

        StringTokenizer tokin = new StringTokenizer("");

        String next() throws IOException {
            if (!tokin.hasMoreTokens()) {
                tokin = new StringTokenizer(in.readLine());
            }
            return tokin.nextToken();
        }

        int nextInt() throws IOException {
            return Integer.parseInt(next());
        }

        long nextLong() throws IOException {
            return Long.parseLong(next());
        }
    }


    static long gcd(long a, long b) {
        if (b == 0) {
            return a;
        } else {
            return gcd(b, a % b);
        }
    }

    public static void main(String args[]) throws IOException {
        Reader in = new Reader();
        Writer out = new Writer();
        long n = in.nextInt();
        long m = in.nextInt();
        String s = in.next();
        String t = in.next();
        long L = (n * m) / gcd(n, m);
        long Ls = L / n;
        long Lt = L / m;
        boolean must = true;
        long HOK = (Ls * Lt) / gcd(Ls, Lt);
        int sd = (int) (HOK / Ls);
        int td = (int) (HOK / Lt);
        for (int i = 0; i * HOK < L; i++) {
            if (s.charAt(sd * i) != t.charAt(td * i)) {
                must = false;
                break;
            }
        }
        if (must) {
            out.print(L);
        } else {
            out.print("-1");
        }
        out.close();
    }
}

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

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

  vector<int> a(n);
  rep (i, n) cin >> a[i];

  int ans = 1001001001;
  rep (i, n) {
    if (a[i] % 2 == 0) {
      int ans_ = 0;
      while (true) {
        if (a[i] > 0 && a[i] % 2 == 0) {
          ans_++;
          a[i] /= 2;
        }
        else {
          break;
        }
      }
      ans = min(ans, ans_);
    }
    else {
      break;
    }
  }

  if (ans == 1001001001) {
    cout << 0 << endl;
  }
  else {
    cout << ans << endl;
  }

  return 0;
}



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

struct pos {
	int l, r;
};

int main()
{
	int n, q, *sum;
	register int i, j, output;
	char *s, *result;
	struct pos *section;

	scanf("%d%d", &n, &q);

	if ((s = (char *)malloc(sizeof(char) * (n + 1))) == NULL)
		return 1;
	if ((result = (char *)malloc(sizeof(char) * n)) == NULL)
		return 1;
	if ((section = (struct pos *)malloc(sizeof(struct pos) * q)) == NULL)
		return 1;
	if ((sum = (int *)malloc(sizeof(int) * n)) == NULL)
		return 1;

	scanf("%s", s);
	for (i = 0; i < q; i++) 
		scanf("%d%d", &section[i].l, &section[i].r);

	for (i = 0; i < n; i++) {
		if (s[i] == 'A' && s[i + 1] == 'C')
			result[i] = 1;
		else
			result[i] = 0;
	}

	sum[0] = result[0];
	for (i = 1; i < n; i++)
		sum[i] = sum[i - 1] + result[i];

	for (i = 0; i < q; i++) {
		printf("%d\n", sum[section[i].r - 2] - sum[section[i].l - 2]);
	}

    free(s);
	free(result);
	free(section);
	free(sum);

	return 0;
		}
	


Measured memory_bytes: 2176
import sys
from collections import Counter
import numpy as np

n, *s = sys.stdin.read().split()
n = int(n)

def comb_2(n):
    return n * (n - 1) // 2

def main():
    t = [''.join(sorted(t)) for t in s]
    v = np.array(list(Counter(t).values()), dtype=np.int64)
    return np.sum(comb_2(v))

if __name__ == '__main__':
    ans = main()
    print(ans)

Measured memory_bytes: 37008
using System;

namespace helloworld
{
    class Program
    {
        static void Main(string[] args)
        {
            var totalSecond = int.Parse(Console.ReadLine());
            var hour = (int)(totalSecond / 3600);
            var minute = (int)(totalSecond % 3600 / 60);
            var second = totalSecond % 60;

            Console.WriteLine(hour + ":" + minute + ":" + second);
        }
    }
}

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

#define    int               long long int
 #define    sp(x)                 setprecision(x)
#define    bp(x)           __builtin_popcount(x)
 #define  ld         long double
 #define  f(i,j,n)            for(int i = j; i <= n; i++)
#define  r(i,n,j)       for(int i = n; i >= j; i--)
 #define  all(container)       container.begin() , container.end()
#define  sz(container)   (int)container.size()
 #define  ff             first
#define  ss             second
 #define  pii      pair <int , int>
#define  sp(x)       setprecision(x)
 #define  endl    "\n"
#define  mod  1000000007
 #define  pb    push_back
#define  mp    make_pair
 #define  T     int ttt; cin >> ttt; while(ttt--)
#define fast ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL);

int power(int x, int y, int p)  
{  
    int res = 1;    
    x = x % p; 
    if (x == 0) return 0; 
    while (y > 0)  
    {     
        if (y & 1)  
            res = (res*x) % p;  
        y = y>>1; 
        x = (x*x) % p;  
    }  
    return res; 
}
const int N=1000009;
int spf[N];
void solve() 
{ 
    spf[1] = 1; 
    for (int i=2; i<N; i++)  
        spf[i] = i; 
    for (int i=4; i<N; i+=2) 
        spf[i] = 2; 
  
    for (int i=3; i*i<N; i++) 
    {  
        if (spf[i] == i) 
        { 
            for (int j=i*i; j<N; j+=i) 
                if (spf[j]==j) 
                    spf[j] = i; 
        } 
    } 
} 
bool vis[N];
int32_t main()
{
    fast
    solve();
    int n,x,ff=1;
    cin>>n;
    int a[n+1];
    f(i,1,n)    cin>>a[i];
    r(i,n,1){
        x=a[i];
        vector<int>v;
        while(x!=1){
            if(vis[spf[x]]==1)    ff=0;
            v.pb(spf[x]);
            x=x/spf[x];
        }
        f(j,0,sz(v)-1)   vis[v[j]]=1;
    }
    if(ff)  cout<<"pairwise coprime";
    else{
        x=0;
        f(i,1,n)
            x=__gcd(x,a[i]);
        if(x==1)    cout<<"setwise coprime";
        else    cout<<"not coprime";
    }

}

Measured memory_bytes: 20180
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <numeric>
#include <map>
#include <iomanip>
#include <limits.h>

using namespace std;    
typedef long long ll;
typedef pair<ll, ll> pll;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
const bool DEBAG = false;

int main(){

    string s;
    cin >> s;

    ll ans = 1;
    bool skip = false;
    for(int i = 1; i < s.size() ; i++){

        if(s[i] == s[i-1]){
            if(skip){
                //i += 1;
                skip = false;
                ans ++;
            }
            else{ // 一個とびでかつ同じ
                i ++;
                skip = true;
                ans ++;
                if(i == s.size()) ans --; // over
            }
        }
        else{
            skip = false;
            ans ++;
        }
    }
    //if(!flag) ans ++;
    cout << ans << endl;

}

Measured memory_bytes: 640
#include <iostream>
#include <cmath>
#include <string>

int main()
{
	int N;
	std::cin >> N;
	std::string C;
	std::cin >> C;

	int r = 0;
	for (char x : C)
		if (x == 'R')
			r++;

	int ans = 0;
	for (int i = 0; i < r; i++)
		if (C[i] == 'W')
			ans++;
	std::cout << ans << std::endl;
	return 0;
}

Measured memory_bytes: 3708
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, c) for (int i = 0; i < (int)c; i++)
#define all(v) v.begin(), v.end()
using ll = long long;
using P = pair<int, int>;
const int inf = 1000000000; //10^9
const ll MOD = 1e9 + 7;
//加算代入演算子は+=！！！！！
//int 2^31 10^9まで
int main()
{
    string s, t;
    cin >> s >> t;
    bool ans = true;
    rep(i, s.length()) {
        if(s[i] != t[i]) {
            ans = false;
        }
    }
    if(ans) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3628
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <map>
#include <string>
typedef long long ll;
using namespace std;

// abc165
// 再帰かつ変更する状態を初期値として与えない場合は，グローバル変数で書く傾向がありそう
// 何をすれば次のステップに繋げられるか
// 終了条件

// 自分でも解いてみる
int n,m,q;
int ans = 0;
vector<int> a,b,c,d;
vector<int> A;
int dfs(vector<int> A){
    // 終了条件が A.size() == n+1である理由
    // はじめの1は再帰処理を記述するためで，文字列自体は初めの1を除く
    if (A.size() == n+1) {
        // for debug
        // for (int i = 0; i < A.size(); i++) {
        //     cout << A[i];
        // }
        // cout << endl;
        // 得点の更新
        int tmp = 0;
        for (int i = 0; i < q; i++) {
            if (A[b[i]] - A[a[i]] == c[i]) {
                tmp+=d[i];
            }
        }
        ans = max(ans,tmp);
        return 0;
    }
    A.push_back(A.back());
    // 自分で書いて間違っていた部分
    // for (int i = 1; i < n; i++) {
    //     A.push_back(A.back()+1);
    //     dfs(A);
    // }
    while (A.back() <= m) {
        dfs(A);
        A.back()++;
    }
    return 0;
}

int main() {
    cin >> n >> m >> q;
    a = b = c = d = vector<int>(q);
    for (int i = 0; i < q; i++) {
        cin >> a[i] >> b[i] >> c[i] >> d[i];
    }
    A = vector<int>(1,1);
    // for (int i = 0; i < A.size(); i++) {
    //     cout << A[i] << endl;
    // }
    dfs(A);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3188
#include<iostream>
#include<cstdio>
#include<string>
#include<cstdlib>
#include<cstring>
using namespace std;
int main()
{
	long long a,b,k;
	cin>>a>>b;
	if((a*a-b*b)%(2*a-2*b)==0)
		cout<<(a*a-b*b)/(2*a-2*b);
	else
		cout<<"IMPOSSIBLE";
	return 0;
}

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

int main(){
  int n,m;
  cin >> n >> m;
  char a[n+2][m+2];
  for(int i=0;i<m+2;i++){
    a[0][i]='.';
    a[n+1][i]='.';
  }
  for(int i=0;i<n+2;i++){
    a[i][0]='.';
    a[i][m+1]='.';
  }
  for(int i=1;i<n+1;i++){
    for(int j=1;j<m+1;j++){
      cin >> a[i][j];
    }
  }
  bool ans=true;
  for(int i=0;i<n+2;i++){
    for(int j=0;j<n+2;j++){
      if(a[i][j]=='#'){
        if(a[i-1][j]=='.'&&a[i+1][j]=='.'&&a[i][j-1]=='.'&&a[i][j+1]=='.'){
          ans=false;
        }
      }
    }
  }
  cout << (ans?"Yes":"No") << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <math.h>
using namespace std;
inline int gcd(int x, int y) {
	int z = x % y;
	if (!z) return y;
	else gcd(y, z);
}
int main() {
	int x, y, z;
	cin >> x >> y;
	if (x < y) swap(x, y);
	cout << gcd(x,y) << endl;
	return 0;
}

Measured memory_bytes: 3088
#include<stdio.h>
#include<math.h>

#define PI 3.14159265

void koch(double x1,double y1,double x2,double y2,int n){
  double x3,y3,x4,y4,x5,y5,s,t;
  
  if(n==0) return;

  if(n!= 0){
    s=sin(PI/3);
    t=cos(PI/3);

  x3=(2*x1+x2 )/3;
  y3=(2*y1+y2 )/3;
  x5=(x1+2*x2 )/3;
  y5=(y1+2*y2 )/3;
  x4=x3+(x5-x3)*t+(y5-y3)*s;
  y4=y3-(x5-x3)*s+(y5-y3)*t;
  koch(x1,y1,x3,y3,n-1);
  printf("%.8f %.8f\n",x3,fabs(y3));
  koch(x3,y3,x4,y4,n-1 );
  printf("%.8f %.8f\n",x4,fabs(y4));
  koch(x4,y4,x5,y5,n-1 );
  printf("%.8f %.8f\n",x5,fabs(y5));
  koch(x5,y5,x2,y2,n-1);
  }
  return;
}


main(){
  int n;
  double x1=0,y1=0,x2=100,y2=0;
  
  scanf("%d",&n);
  printf("%1.8f %1.8f\n",x1,y1);
  
  if(n>=0 || n<=6){
    koch(x1,y1,x2,y2,n);
  }
  
  printf("%.8f %.8f\n",x2,y2);
  return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef long long lli;
typedef long double lld;
#define mod 1000000007
#define mod2 998244353
#define fori(n) for (int i = 0; i < n; i++)
#define forj(n) for (int j = 0; j < n; j++)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define fast ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define endl "\n"
#define sortvec(a) sort(a.begin(), a.end())
#define watch(x) cerr << "\n" << (#x) << " is " << (x) << endl
#define cerr if(true) cerr

template <typename T, typename U>
ostream &operator<<(ostream &out, const pair<T, U> &p)
{
    out << "(" << p.first << ", " << p.second << ")";
    return out;
}
template <template <typename, typename...> class ContainerType, typename ValueType, typename... Args>
void print(const ContainerType<ValueType, Args...> &c)
{
    for (const auto &v : c)
        cout << v << ' ';
    cout << '\n';
}

void print() { cout << '\n'; }
template <typename T, typename... Args>
void print(T a, Args... args)
{
    cout << a << " ";
    print(args...);
}

lli llipower(lli x, lli y, lli p = LLONG_MAX)
{
    lli res = 1;
    x = x % p;
    while (y > 0)
    {
        if (y & 1)
            res = (res * x) % p;
        y = y >> 1;
        x = (x * x) % p;
    }
    return res;
}
lli binarySearch(vector<int> arr, int l, int r, int x)
{
    if (r >= l)
    {
        lli mid = l + (r - l) / 2;
        if (arr[mid] == x)
            return mid;
        if (arr[mid] > x)
            return binarySearch(arr, l, mid - 1, x);
        return binarySearch(arr, mid + 1, r, x);
    }
    return -1;
}

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


int main(){
    int a,b;
    cin>>a>>b;
    cout<<a*b<<endl;
}

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

int main(){
  int R,G,B,N;
  int result=0;
  cin >> R >> G >> B >> N;
  for(int r=0; r<=N; r++){
    for(int g=0; g <=N; g++){
      int b = N - r*R - g*G;
      if(b < 0) break;
      if(b%B==0) result++;
  
    }
  }
  cout<<result<<endl;

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;
#define dame { puts("-1"); return 0;}
#define yn {puts("YES");}else{puts("NO");}
  
int main() {
  int N;
  cin >> N;
  vi L(N);
  rep(i,N) {
    cin >> L[i];
  }
  sort(rng(L));
  ll ans = 0;
  rep(i,N) {
    srep(j,i+1,N) {
      int a = L[i];
      int b = L[j];
      auto rit = lower_bound(rng(L),a+b);
      rit--;
      ans += max(0,(int)(rit - (L.begin()+j)));
    } 
  }
  cout << ans << endl;
  return 0;
}

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

/* メモリ食い過ぎ注意 */
#define int long long

typedef long long ll;

ll gcd(ll a, ll b)
{
    if (a < b)
        gcd(b, a);
    if (b == 0)
        return a;
    int r;
    while ((r = a % b))
    {
        a = b;
        b = r;
    }
    return b;
}

/* define const */
const ll INF = (1ll << 60);
const ll MOD = (ll)1e9 + 7;
/* end defineing */

signed main()
{
    int a, b;
    cin >> a >> b;

    if (a + b >= 10)
        cout << "error" << endl;
    else
        cout << a + b << endl;
}


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

typedef struct {
    int to, did;
}Edge;

int N;
vector<vector<Edge>> G;
vector<int> P, D;
vector<bool> done;
vector<pair<int, int>> par;
vector<bool> is_leaf;

// weight, idx
pair<int, int> dfs(int u, int p){
    pair<int, int> r(0, u);
    for(int i=0; i<G[u].size(); i++){
        auto e = G[u][i];
        if(e.to == p || is_leaf[e.to])
            continue;
        
        par[e.to] = make_pair(u, i);
        auto t = dfs(e.to, u);
        t.first += D[e.did];
        if(r.first < t.first)
            r = t;
    }
    return r;
}
pair<int, int> diameter(){
    par.clear();
    par.resize(N, {-1, -1});
    for(int i=0; i<N; i++) if(!is_leaf[i]){
        auto r = dfs(i, -1);
        auto t = dfs(r.second, -1);
        return make_pair(r.second, t.second);
    }
    //Not Implemented
    return pair<int, int>();
}

int main(){
    while(cin >> N, N){
        P.clear();
        P.resize(N-1);
        for(auto &v: P)
            cin >> v;
        D.clear();
        D.resize(N-1);
        for(auto &v: D)
            cin >> v;
        G.clear();
        G.resize(N);
        for(int i=0; i<N-1; i++){
            G[i+1].push_back({P[i]-1, i});
            G[P[i]-1].push_back({i+1, i});
        }
        
        int ans = 0;
        is_leaf.clear();
        is_leaf.resize(N, false);
        done.clear();
        done.resize(N-1, false);
        for(int i=0; i<N; i++){
            if(G[i].size() == 1){
                ans += D[G[i][0].did];
                done[G[i][0].did] = true;
                is_leaf[i] = true;
            }
        }
        auto path = diameter();
        int v = path.second;
        while(true){
            auto p = par[v];
            if(p.first < 0) break;
            
            int did = G[p.first][p.second].did;
            done[did] = true;
            ans += D[did]*2;
            v = p.first;
            if(v == path.first)
                break;
        }
        for(int i=0; i<N-1; i++) if(!done[i])
            ans += D[i]*3;
        cout << ans << endl;
    }
    
    return 0;
}

Measured memory_bytes: 3308
N = int(input())
a = []
for _ in range(N):
    a.append(int(input()))

idx = 0
success = False
for i in range(N):
    idx = a[idx]-1
    if idx == 1:
        print("%d"%(i+1))
        success = True
        break
        
if success == False:
    print("%d"%(-1))

Measured memory_bytes: 7192
#include<iostream>
#include<algorithm>
#include <iostream> 
#include <algorithm> 
#include<string>
#include<queue>
#include<utility>
#include<fstream>
#include<queue>
#include<set>
#include<stack>
#include<bits/stdc++.h>
#define ll long long int
#define ull unsigned long long int
#define I(a) scanf("%d",&a)
#define I2(a,b) scanf("%d%d",&a,&b)
#define I3(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define L(a) scanf("%lld",&a)
#define L2(a,b) scanf("%lld%lld",&a,&b)
#define L3(a,b,c) scanf("%lld%lld%lld",&a,&b,&c)
#define PI(a) printf("%d",a)
#define PL(a) printf("%lld",a)
#define PT(t) printf("Case %d: ",t)
#define PB push_back
#define x first
#define y second
#define xx first.first
#define xy first.second
#define yx second.first
#define yy second.second
#define SC scanf
#define PC printf
#define NL printf("\n")
#define SET(a) memset(a,0,sizeof a)
#define SETR(a) memset(a,-1,sizeof a)
#define SZ(a) ((int)a.size())-1
#define f(i,a,b) for(int i=a;i<=b; i++)
#define fr(i,a,b) for(int i=a;i<=b; i++)
#define frr(i,a,b) for(int i=a;i>=b; i--)
#define frv(i,a)  for(int i=0;i<a.size();i++)
#define pi 2.0*acos(0.0)
#define R(a) freopen(a, "r", stdin);
#define W(a) freopen(a, "w", stdout);
#define CB(x) __builtin_popcount(x)
#define STN(a) stringtonumber<ll>(a)
#define lol printf("BUG\n")
#define Endl "\n"
#define mk make_pair
using namespace std;
template <class T> inline T BM(T p, T e, T M)
{
    ll ret = 1;
    for(; e > 0; e >>= 1)
    {
        if(e & 1) ret = (ret * p) % M;
        p = (p * p) % M;
    }
    return (T)ret;
}
template <class T> inline T gcd(T a, T b)
{
    if(b == 0)return a;
    return gcd(b, a % b);
}
template <class T> inline T mdINV(T a, T M)
{
    return BM(a, M - 2, M);
}
template <class T> inline T PW(T p, T e)
{
    ll ret = 1;
    for(; e > 0; e >>= 1)
    {
        if(e & 1) ret = (ret * p);
        p = (p * p);
    }
    return (T)ret;
}
 
 
template <class T>bool ISLEFT(T a, T b, T c)
{
    if(((a.xx - b.xx) * (b.yy - c.yy) - (b.xx - c.xx) * (a.yy - b.yy)) < 0.0)return 1;  //Uporer dike //A,b,c, x okkher ordera sorted
    else return 0;
}
 
 
typedef pair<int,int >P;
//////////////////////////
/////////////////////////
//
#define mx 100000
int main(){
   int n = 5;
   int ar[6];
   for(int i=1;i<=5;i++){
       cin>>ar[i];
   }
   int res = 2000000;
   do{
       int ti = 0;

       for(int i=1;i<=5;i++){
           ti = (ti + 9) / 10;
           ti *= 10;
           ti += ar[i];
       }
       res = min(res,ti);

   }while(next_permutation(ar+1,ar+n+1));
   cout<<res<<Endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#define endl  "\n"
#define ll long long
#define int long long
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cin.exceptions(cin.failbit);cout.tie(NULL);
using namespace std;
bool isPrime(int n)
{
    if (n <= 1)
        return false;
    if (n <= 3)
        return true;
    if (n % 2 == 0 || n % 3 == 0)
        return false;
    for (int i = 5; i * i <= n; i += 6)
    {
        if ((n % i == 0) || (n % (i + 2) == 0))
            return false;
    }
    return true;
}
int32_t main()
{
	set<int> s;
	int n,k;
	cin >> n >> k;
	for(int i=0;i<k;i++)
	{
		int d;
		cin >> d;
		for(int j=0;j<d;j++)
		{
			int x;
			cin >>x;
			s.insert(x);
		}
	}
	cout << n-s.size();
	
	
}


Measured memory_bytes: 3632
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int D = scan.nextInt();
        int N = scan.nextInt();
        System.out.println(solve(D, N));
    }
    public static int solve(int D, int N) {
        if (D == 0) {
            return N != 100 ? N : 101;
        }
        if (N != 100) {
            return (int) Math.pow(100, D) * N;
        }
        return (int) Math.pow(100, D+1) + (int) Math.pow(100, D);
    }
}


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

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

  vector<int> perm(n);
  rep(i, n) perm[i] = i;

  double sum_d = 0;
  int k = 0;
  do {
    ++k;
    rep(i, n-1) sum_d += sqrt(pow(x[perm[i+1]] - x[perm[i]], 2) + pow(y[perm[i+1]] - y[perm[i]], 2));
  } while (next_permutation(perm.begin(), perm.end()));
  double ave_d = sum_d / k;
  printf("%.7f\n", ave_d);
  return 0;
}

Measured memory_bytes: 3780
-- https://github.com/minoki/my-atcoder-solutions
import Data.Int (Int64)

main = do
  n <- readLn :: IO Int64
  print $ minimum [ a + b - 2
                  | d <- [1..floor (sqrt (fromIntegral n) :: Double)]
                  , n `rem` d == 0
                  , let a = d; b = n `quot` d
                  ]


Measured memory_bytes: 892
#!venv/bin/python
from collections import defaultdict 

N = int(input())
P = [int(x) for x in input().split()]

cnt = 0
for i in range(1,N-1):
    if sorted([P[i-1],P[i],P[i+1]])[1] == P[i]:
        cnt += 1

print(cnt)


Measured memory_bytes: 3444
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cctype>
using namespace std;

const string kInf = "zzzzzzzzzzzzzzzzzzzzz";

struct Rule {
  int l, r1, r2;

  Rule(int _l, int _r1, int _r2) {
    l = _l, r1 = _r1, r2 = _r2;
  }
};

int N, M, C, R;
int ch_num[128];
vector< Rule > vrl;
vector< vector< string > > fs;
vector< vector< bool > > fb;

void init_and_read(void);
void parse_rule(int, const string &, int, int);
void solve(void);
void cal_zero_ln(int);

int main() {
  while (cin >> N >> M, N + M) {
    init_and_read();
    solve();
  }

  return 0;
}

void init_and_read(void) {
  vrl.clear();
  fill(&ch_num[0], &ch_num[128], -1);
  C = 1;
  for (int i = 0; i < N; ++i) {
    string str;
    int ln;

    cin >> str, ln = str.length();
    for (int j = 0; j < ln; ++j) {
      if (str[j] == '=')  continue;
      if (ch_num[str[j]] == -1) ch_num[str[j]] = C++;
    }

    parse_rule(ch_num[str[0]], str, 2, ln);
  }
}

void parse_rule(int lv, const string &rs, int i, int ln) {
  switch (ln - i) {
    case 0:
      vrl.push_back(Rule(lv, 0, 0));
      break;
    case 1:
      vrl.push_back(Rule(lv, ch_num[rs[i]], 0));
      break;
    case 2:
      vrl.push_back(Rule(lv, ch_num[rs[i]], ch_num[rs[i + 1]]));
      break;
    default:
      vrl.push_back(Rule(lv, ch_num[rs[i]], C));
      parse_rule(C++, rs, i + 1, ln);
  }
}

void solve(void) {
  R = vrl.size();
  fs.clear(), fs.resize(max(M + 1, 2), vector< string >(C, kInf));
  fb.clear(), fb.resize(max(M + 1, 2), vector< bool >(C, false));

  fs[0][0] = "", fb[0][0] = true;
  for (int i = 0; i < 128; ++i)
    if (islower(char(i)) && ch_num[i] != -1)
      fs[1][ch_num[i]] = string(1, char(i)), fb[1][ch_num[i]] = true;

  cal_zero_ln(0);
  for (int i = 1; i <= M; ++i) {
    for (int j = 1; i - j > 0; ++j)
      for (int k = 0; k < R; ++k) {
        int l = vrl[k].l, r1 = vrl[k].r1, r2 = vrl[k].r2;
        if (fb[j][r1] && fb[i - j][r2])
          fs[i][l] = min(fs[i][l], fs[j][r1] + fs[i - j][r2]), fb[i][l] = true;
        if (fb[i - j][r1] && fb[j][r2])
          fs[i][l] = min(fs[i][l], fs[i - j][r1] + fs[j][r2]), fb[i][l] = true;
      }

    cal_zero_ln(i);
  }

  if (ch_num['S'] != -1 && fb[M][ch_num['S']])
    cout << fs[M][ch_num['S']] << endl;
  else
    cout << "-" << endl;
}

void cal_zero_ln(int ln) {
  for (int i = 0; i < C; ++i)
    for (int j = 0; j < R; ++j) {
      int l = vrl[j].l, r1 = vrl[j].r1, r2 = vrl[j].r2;
      if (fb[ln][r1] && fb[0][r2])
        fs[ln][l] = min(fs[ln][l], fs[ln][r1] + fs[0][r2]), fb[ln][l] = true;
      if (fb[0][r1] && fb[ln][r2])
        fs[ln][l] = min(fs[ln][l], fs[0][r1] + fs[ln][r2]), fb[ln][l] = true;
    }
}

Measured memory_bytes: 1540