akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define For(i,a,b) for(int i=(a);i<=(b);++i)
#define Ford(i,a,b) for(int i=(a);i>=(b);--i)
#define fio(s) freopen(s".inp","r",stdin)
#define foo(s) freopen(s".out","w",stdout)
#define task "test"
using namespace std;
typedef long long LL;
const LL N=3009,OO=1e9+7;
LL n;
long double ans,H[N],T[N],dp[N][N],cnt[N][N];
int main(){
    //fio(task); foo(task);
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cin>>n;
    For(i,1,n){
        cin>>H[i]; T[i]=(long double)(1)-H[i];
    }
    dp[1][0]=T[1]; dp[1][1]=H[1];
    For(i,2,n) dp[i][0]=dp[i-1][0]*T[i];
    For(i,2,n)
    For(j,1,n){
        dp[i][j]=dp[i-1][j-1]*H[i]+dp[i-1][j]*T[i];
    }
    For(i,n/2+1,n) ans+=dp[n][i];
    cout.precision(11);
    cout<<fixed<<ans;
    return 0;
}


Measured memory_bytes: 141696
from itertools import product

H, W, K = map(int, input().split())
C = [list(input()) for _ in range(H)]

ans = 0

for bit in product((0, 1), repeat=H):
    for bit2 in product((0, 1), repeat=W):
        k = 0
        for i in range(H):
            for j in range(W):
                if C[i][j] == '#' and bit[i] and bit2[j]:
                    k += 1
        if k == K:
            ans += 1

print(ans)

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

///******************************** C o n t a i n e r ********************************///

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;
typedef map<int,int> mii;
typedef map<ll,int> mli;

///*********************************** C o n s t ***********************************///

int const N=1e6+3;
const double PI = acos(-1);

///********************************** M a r c o ***********************************///

#define pb push_back
#define F first
#define S second
#define test int tc; cin>>tc; while(tc--)
#define forn(i,n) for(i=0;i<n;i++)
#define rforn(i,n) for(i=n-1;i>=0;i--)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define sz(x) x.size()
#define el <<'\n'
#define sp <<' '
#define print(a) {for(auto x:a)cout<<x<<" ";cout<<endl;}
#define mem(a,b) memset(a, b, sizeof(a))
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) (a*(b/gcd(a,b)))
#define sqr(a) (a)*(a)

#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define file() freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define fraction() cout.unsetf(ios::floatfield); cout.precision(10); cout.setf(ios::fixed,ios::floatfield);

///*********************************** F u n c t i o n ***********************************///

///ll powmod(ll a,ll b){ll p=MOD;a%=p;if(!a) return 0;ll pr=1;while(b>0){if(b&1){pr*=a;pr%=p;--b;}a*=a;a%=p;b/=2;}return pr;}
///bool isPrime(ll n){ if(n<=1)return false;if(n<=3)return true;if(n%2==0 or n%3==0)return false;for(ll i=5;i*i<=n;i+=6){if(n%i==0n%(i+2)==0)return false;}return true;}

///************************************************ C o d e ************************************************///
///-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=///



void _case()
{
    char a;
    cin>>a;
    if(a>='a') cout<<'a' el;
    else cout<<'A' el;

}

main()
{
///    test
///    while(1)
        _case();

}


///Thank you.


///Brainless_Loco Terminates Here!


Measured memory_bytes: 3668
n = input()
for i in range(n):
    s = raw_input()
    temp = []
    for j in range(len(s)):
        temp.append(s[j])
    temp.sort()
    minNum = temp[::]
    maxNum = temp[-1::-1]
    ans = 0
    for j in range(len(maxNum)):
        ans *= 10
        ans += int(maxNum[j]) - int(minNum[j])
    print(ans)

Measured memory_bytes: 4224
import sys
n,k,q = map(int,input().split())
if k > q:
    for _ in range(n):
        print("Yes")
    sys.exit()
p = [0 for i in range(n)]

for __ in range(q):
    number = int(input())
    p[number - 1] += 1

for x in range(n):
    if k - q + p[x] >= 1:
        print("Yes")
    else:
        print("No")

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

typedef long long int ll;
typedef unsigned long long int ull;
#define rep(i,n) for(auto i=0;i<(n);i++)
#define rep1(i,n) for(auto i=1;i<=(n);i++)
#define all(x) (x).begin(),(x).end()

using namespace std;


struct init{ init(){ cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20); }; }aaaaaaa;
int dy[]={1, 0, -1, 0, 0};
int dx[]={0, 1, 0, -1, 0};


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

    vector<int> posOf(n+1);
    rep(i, n) posOf[a[i]] = i;

    ll sum = 0;
    set<ll> minPoss = {-1, n};
    rep1(i, n){
        int pos = posOf[i];
        minPoss.insert(pos);
        ll l = *(--minPoss.find(pos));
        ll r = *(++minPoss.find(pos));
        sum += abs(l-pos) * abs(r-pos) * i;
    }
    cout << sum << endl;

    return 0;
}



Measured memory_bytes: 11264
#include <bits/stdc++.h>
using namespace std;
#define N 200005
#define mod 1000000007
#define pp pair<ll,ll>
typedef long long int ll;
typedef long double ld;
typedef vector<pp> vpl;
#define MP make_pair
#define endl "\n"
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep1(i,n) for(ll i=1;i<n;i++)
#define rrep(i,n) for(ll i=n-1;i>=0;i--)
#define repb(i,n) for(ll i=1;i<n-1;i++) 
#define trace(i,a) for(auto i=a.begin();i!=a.end();i++)    
void fastIO(void);
 
void decimal(int);
ll modmulti(ll, ll, ll);
ll modadd(ll, ll, ll);
ll modpower(ll, ll, ll);
ll gcd(ll, ll );
ll modinv(ll, ll);
 

int main()
{
  // decimal(1);
   fastIO();
   ll n;
   cin>>n;
   ll a[n],b[n],c[n-1];
   rep(i,n) cin>>a[i];
   rep(i,n) cin>>b[i];
   rep(i,n-1) cin>>c[i];
   ll sat=0;
   sat+=b[a[0]-1];
   rep1(i,n){
      sat+=b[a[i]-1];
      if(a[i]==a[i-1]+1) sat+=c[a[i-1]-1];
   }
   cout<<sat<<endl;
}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
void fastIO(void)
{  ios_base::sync_with_stdio(false);
   cin.tie(0);
   cout.tie(0);
}
 
void decimal(int n){
   cout<<fixed;
   cout<<setprecision(n);
}
ll modmulti(ll a, ll b, ll m){
   return ((a%m)*(b%m))%m;
}
ll modadd(ll a, ll b, ll m){
   return ((a%m)+(b%m)+m)%m;
}
ll modpower(ll a, ll n, ll m){
   if(n==0)
      return 1;
   ll result = 1;
   while(n>0){
      if(n%2==1)
         result = modmulti(result,a,m);
      a = modmulti(a,a,m);
      n = n/2;
   }
   return result;
}
ll gcd(ll a, ll b){
   if(b==0)
      return a;
   return gcd(b,a%b);
}
ll modinv(ll a, ll m){
   return modpower(a,m-2,m);
}

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

using namespace std;

#define ll long long int
#define ld long double
#define loop(i, n) for (int i = 0; i < n; i++)
#define loops(i, s, n) for (int i = s; i < n; i++)
#define pb push_back
#define mp make_pair
#define all(v) v.begin(),v.end()
#define sz(x) ((int)(x).size())
#define fi first
#define se second
#define deb(x) cout<< #x << '=' << x <<endl
#define MOD 1000000007

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int x , y;
    cin>>x>>y;
    bool f = 0;
    for(int i = 0; i<=100; i++){
        if(y >= (i*4) && (y - (i*4))%2 == 0){
            int a = (y - (i*4))/2;
            if(a + i == x){
                f = 1;
                break;
            }
        }
    }
    if(f){
        cout<<"Yes\n";
    }else{
        cout<<"No\n";
    }
}

Measured memory_bytes: 3668
x, y = gets.chomp.split.map(&:to_i)

f = false
0.upto(100) do |a|
  0.upto(100) do |b|
    if (2 * a + 4 * b == y) && (a + b == x)
      f = true
      break
    end
  end
end

if f
  puts "Yes"
else
  puts "No"
end


Measured memory_bytes: 14376
#include<stdio.h>
int main()
{
    int A,B,C,x=1,y=2,z=3;
    scanf("%d%d",&A,&B);
    if(A==x&&B==y)
        printf("%d",z);
    else if(A==y&&B==z)
        printf("%d",x);
    else if(A==z&&B==x)
        printf("%d",y);
    else if(A==y&&B==x)
        printf("%d",z);
    else if(A==z&&B==y)
        printf("%d",x);
        else if (A==x&&B==z)
        printf("%d",y);
    return 0;
}

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

int main() {
  vector<int> vec(3);
  for (int i = 0; i < 3; i++) {
  cin >> vec.at(i);
}

  int p=0;
  int k=0;
  
    for (int i = 0; i < 3; i++) {
      if(vec.at(i)==5){
        p++;
      }
      if(vec.at(i)==7){
        k++;
      }
    }
  
  if(p==2&&k==1){
    cout<<"YES"<<endl;
  }
  else{
    cout<<"NO"<<endl;
  }
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;
using ll =long long int;
using le =long double;
int main(){
    int N;
    cin >> N;
    vector<int> A(N);
    vector<int> T(N);

    for(int i=0; i<N; i++){
        cin >> A[i] >> T[i];
    }
    
    ll a = 1;
    ll t = 1;

    for(int j=0; j<N; j++){
        ll n;
        n = max(ceil(le(a)/A[j]), ceil(le(t)/T[j]));
        a = n*A[j];
        t = n*T[j];
    }

    cout << a + t << endl;

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
int main(){
        int n,d,l,m=0;
        double r,e=0;
        scanf("%d %d",&n,&d);
        int x[n][d];
        for(int i=0;i<n;i++){
                for(int j=0;j<d;j++)scanf("%d",&x[i][j]);
        }
        for(int i=0;i<n-1;i++){
                for(int k=i+1;k<n;k++){
                        for(int j=0;j<d;j++)r=r+(x[i][j]-x[k][j])*(x[i][j]-x[k][j]);
                        r=sqrt(r);
                        l=r;
                        e=l;
                        if(r==e)m++;
                        r=0;
                }
        }
        printf("%d",m);
        return 0;
}

Measured memory_bytes: 128
// inputに入力データ全体が入る
function Main(input) {
  input = Number(input);
  if (input > 81) {
    console.log('No')
    return
  }
  const nums = [1,2,3,4,5,6,7,8,9]
  var check
  for (var num of nums) {
    for (var n of nums) {
      var result = num * n
      if (result === input){
        check = true
      }
    }
  }
  if (check) {
    console.log('Yes')
  } else {
  	console.log('No')
  }
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn main() {
    let n: i32 = read();

    println!("{}", if n % 2 == 0 {n / 2} else {n / 2 + 1});
}

Measured memory_bytes: 4352
#include<iostream>
#include<string>
#include<typeinfo>
#include<vector>
#include<algorithm>
using namespace std;
int main()
{
	int h,w;
	cin >> h >> w;
	
	char c;
	int cnt=0;
	for(int i=0; i<h*w; i++){
		cin >> c;
		if(c=='#'){
			cnt++;
		}
	}
	if(cnt==h+w-1){
		cout << "Possible" << endl;
	}else{
		cout << "Impossible" << endl;
	}
	
	return 0;
}

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

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int n, e;
    vector <int> h;

    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> e;
        h.push_back(e);
    }

    int i = 0, max = 0, current = 0;
    while (i < n - 1) {
        if (h[i] >= h[i+1]) {
            current++;
            i++;
        }
        else {
            i++;
            if (current > max) max = current;
            current = 0;
        }
    }
    if (current > max) max = current;
    cout << max << '\n'; 

    return 0;
}

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

int main(void){
    vector<int> a;
    vector<int> option;
    int k=0,n=0,i=0,j=0;
    int output = 0;

    cin >> k >> n;

    for (i=0;i<n;i++){
        cin>>j;
        a.push_back(j);
    }

    for (i=0;i<n;i++){
        if (i==0){
            option.push_back(a[a.size() -1 ] - a[0]);
        }else{
            j = k - a[i];
            j += a[i-1];
            option.push_back(j);
        }
    }

    output = k;
    for(i=0;i<option.size();i++){
        if (output >= option[i]){
            output = option[i];
        }
    }

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

Measured memory_bytes: 2548
//kalyanchirla
//#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <cstdio>
#include <cstdlib>
#include <climits>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <iomanip>
//setbase - cout << setbase (16)a; cout << 100 << endl; Prints 64
//setfill -   cout << setfill ('x') << setw (5); cout << 77 <<endl;prints xxx77
//setprecision - cout << setprecision (14) << f << endl; Prints x.xxxx
//cout.precision(x)  cout<<fixed<<val;  // prints x digits after decimal in val
using namespace std;
#define int long long
#define f(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) f(i,0,n)
#define csl ios_base::sync_with_stdio(false);cin.tie(NULL)
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define pii pair<int,int>
#define vi vector<int>
#define mii map<int,int>
#define setbits(x) __builtin_popcountll(x)
#define zrobits(x) __builtin_ctzll(x)
#define mod 1000000007
int32_t main()
{ 
    csl;

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

    int arr[n+1];
    for(int i=0;i<=n;i++) arr[i]=0;

    while(m--)
    {
        int a,b;
        cin >> a >> b;
        arr[a]++;
        arr[b]++;
    }
    for(int i=1;i<=n;i++)
    {
        cout << arr[i] << "\n";
    }
}

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

using namespace std;
int main(){
  int64_t x,y;
  cin >> x >> y;
  int64_t a = max(x , y);
  int64_t b = min(x , y);
  while(b != 0){
    int64_t t = b;
    b = a % b;
    a = t;
  }
  int64_t o;
 o = x / a * y;
  cout <<o<<endl;
}
    


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int
#define pii pair<int,int >
#define F first
#define S second
#define mod 1000000000
ll maxi=mod;
int n,m,x;
/// cout <<"Case #"<<it<<": ";
using namespace std;
void solve(int mat[13][13],int cost[],int curr[],int i,int tot){

    int flag=0;
    for(int it=0;it<m;it++){
        if(curr[it]<x) {flag=1;}
    }
    if(flag!=1){
            //for(int it=0;it<m;it++) cout << curr[it]<<" ";
            //cout << endl;
            ///cout << tot << endl;
            maxi=min(maxi,(ll)tot); return ;
    }
    if(i>=n) return;
    solve(mat,cost,curr,i+1,tot);
    tot=tot+cost[i];
    for(int j=0;j<m;j++) {
        curr[j]+=mat[i][j];
    }
    solve(mat,cost,curr,i+1,tot);
    for(int j=0;j<m;j++) {
        curr[j]-=mat[i][j];
    }

}
int main()
{   ios_base::sync_with_stdio(false);
    cin.tie(NULL);

     cin >> n >> m >> x; ///cout << x << endl;
    int mat[13][13];int cost[n];
    for(int i=0;i<n;i++){
        cin >> cost[i];
        for(int j=0;j<m;j++){
            cin >> mat[i][j];
        }
    }
    ///for(int i=0;i<n;i++){
      //  for(int j=0;j<m;j++) cout << mat[i][j]<<" ";
     //   cout << endl;
    //}
    //for(int i=0;i<n;i++) cout << cost[i]<<" ";
    //cout << endl;
    int curr[m]={0};int tot=0;
    solve(mat,cost,curr,0,tot);
    if(maxi==mod) cout <<-1 << endl;
    else cout << maxi << endl;
    return 0;
}


Measured memory_bytes: 3660
//#define _GLIBCXX_DEBUG

#include<bits/stdc++.h>
#define PI 3.14159265359
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
const int INF= 1e9+5;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll> >vvl;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> T;
const ll MOD=1000000007LL;
int main(){
  ll n;cin>>n;
  vl c(n-1),s(n-1),f(n-1);
  rep(i,n-1)cin>>c[i]>>s[i]>>f[i];
  rep(i,n){
    ll t=0;
    ll place=i;
    while(place<n-1){
      t=max(s[place],((t+f[place]-1)/f[place])*f[place]);
      t+=c[place];
      place++;
    }
    cout<<t<<endl;
  }
}

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

int main() {
  int n;
  cin >> n;
  n = n % 10;
  if (n == 2 or n == 4 or n == 5 or n == 7 or n == 9) {
    cout << "hon" << endl;
  } else if (n == 0 or n == 1 or n == 6 or n == 8) {
    cout << "pon" << endl;
  } else {
    cout << "bon" << endl;
  }
  return 0;
}

Measured memory_bytes: 3540
import Control.Applicative ((<$>), (<*>))
import Control.Monad
import Data.List

main :: IO ()
main = do
  [n, c, k] <- getl $ map read . words
  solve c k <$> replicateM n (getl read) >>= print

solve :: Int -> Int -> [Int] -> Int
solve c k ts = f sts 0
  where
    sts = sort ts
    f [] b = b
    f (x:xs) b = f (drop (length es) xs) (b+1)
      where
        ds = takeWhile (\y -> y <= x + k) xs
        es = take (c-1) ds
          
getl :: (String -> a) -> IO a
getl f = f <$> getLine


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

ll A, B;

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

    if (A % 2 == 0) {
        if (B % 2 == 0) {
            int x = ((B - A) / 2) % 2;
            cout << B + x << endl;
        }
        else {
            cout << ((B - A) / 2 + 1) % 2 << endl;
        }
    }
    else {
        if (B % 2 == 0) {
            int y = ((B - A) / 2) % 2;
            cout << (A ^ B) - y << endl;
        }
        else {
            int z = ((B - A) / 2) % 2;
            cout << A - z << endl;
        }
    }
    
    return 0;
    
}

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

using namespace std;

int main(){

	int a,b;
	cin>>a>>b;

	for(int i = 1;i<100*100;i++){
		int a1 = i * 8/100;
		int b1 = i * 10/100;

		if(a1 == a && b1 == b){
			cout<<i;
			return 0;
		}
	}

	cout<<-1;

}

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

const int maxn = 105;
int val[maxn], n, m;
int tot = 0, cnt = 0;
int main(){
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++) scanf("%d",&val[i]), tot += val[i];
	std::sort(val+1,val+n+1);
	for(int i=n;i;i--){
		if(val[i] * 4 * m >= tot) cnt ++;
	}
	if(cnt >= m) printf("Yes\n");
	else printf("No\n");
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define LL long long 
const int N=2e5+9;
using namespace std;
char s[N],a[N];
int zong;
int work(int l,int r)
{
	LL all=0;
	while(1)
	{
		LL num1=0,pos1,pos2,num2=0;
		for(pos1=l-1;pos1>=0;--pos1) 
		{
			if(s[pos1]!='x')
			{
				break;
			}
			else num1++;
		}
		for(int i=r+1;i<zong;++i)
		{
			if(s[i]!='x') 
			{
				pos2=i;
				break;
			}
			else num2++;
		}
		if(pos1<0)
		{
			all=all+max(num1,num2)-min(num1,num2);
			return all;
		}
		all=all+max(num1,num2)-min(num1,num2);
		l=pos1;r=pos2;
	}
}
int main()
{
	scanf("%s",s);
	int len=strlen(s);
	zong=len;
	int tot=0;
	for(int i=0;i<len;++i)
	 if(s[i]!='x')
	  a[++tot]=s[i];
	int flag=1;
	for(int i=1;i<=tot/2;++i)
	  if(a[i]!=a[tot-i+1])
	   flag=0;
	if(!flag) 
	{
	 printf("-1\n");
     return 0;
	}
if(tot==0)
{
	printf("0\n");
	return 0;
}
    if(tot&1)
    {
    	int all=0;
    	int pos;
    	for(int i=0;i<len;++i)
    	{
    		if(s[i]!='x') all++;
    		if(all==(tot+1)/2)
    		{
    			pos=i;
    			break;
			}
		}
		cout<<work(pos,pos)<<endl;
	}
	else 
	{
		int all=0;
		int pos1,pos2;
		for(int i=0;i<len;++i)
		{
			if(s[i]!='x') all++;
			if(all==(tot+1)/2) 
			{
				pos1=i;break;
			}
		}
		all=0;
		for(int i=len-1;i>=0;--i)
		{
			if(s[i]!='x') all++;
			if(all==(tot+1)/2)
			{
				pos2=i;
				break;
			}
		}
		cout<<work(pos1,pos2)<<endl;
	}
	return 0;
}
/*
aaaxa
*/



Measured memory_bytes: 384
#include <iostream>
#include<algorithm>
#include<set>
#include<queue>
#include<bitset>
#include<list>
#define rep(i,j,n) for(int i=j;i<n;i++)
using namespace std;
#define int long long
struct edge{long long to,cost;};
struct st{int rate,way,num;};
typedef pair<int,int>P;
#define inf 1000000007

signed main(){
    int q,x;string com;
    cin>>q;
    list<int> v;
    rep(i,0,q){
        cin>>com;
        if(com[0]=='i'){
            cin>>x;
            v.push_front(x);
        }else if(com[6]=='L')v.pop_back();
        else if(com[6]=='F')v.pop_front();
        else{
            cin>>x;
            for(list<int>::iterator it=v.begin();it!=v.end();it++)if(*it==x){
                v.erase(it);
                break;
            }
        }
    }int i=0;
    for(list<int>::iterator it=v.begin();it!=v.end();it++){
        if(i++)cout<<" ";
        cout<<*it;
    }cout<<endl;
    return 0;
}


Measured memory_bytes: 34396
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<map>
using namespace std;

static const int INF=1e9;
typedef long long ll;

bool compare_by_second(pair<ll, ll> a,pair<ll, ll> b)
{
    if(a.second != b.second){
        return a.second > b.second;
    }else{
        return a.first > b.first;
    }    
}

int main(){
    ll N,M; cin >> N >> M;
    ll A[N];
    for(int i=0;i<N;i++){
        cin >> A[i];
    }
    sort(A,A+N);
    priority_queue<ll> que;
    vector<pair<ll,ll> > D(M);
    for(int i=0;i<M;i++){
        ll B,C; cin >> B >> C;
        D[i]=make_pair(B,C);
    }
    sort(D.begin(),D.end(),compare_by_second);
    for(int i=0;i<M;i++){
        while(D[i].first--){
            que.push(D[i].second);
        }
        if(que.size()>=N) break;
    }
    for(int i=0;i<N;i++){
        if(que.empty()) break;
        if(que.top()>=A[i]){
            //cout << que.top() << endl;
            A[i]=que.top();
            que.pop();
        }else{
            break;
        }
    }
    ll ans=0;
    for(int i=0;i<N;i++){
        ans+=A[i];
    }
    cout << ans << endl;
}


Measured memory_bytes: 4724
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vll = vector<long long>;
using vp = vector<pair<int, int>>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using vvll = vector<vector<long long>>;
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 (b<a) {a=b; return 1;} return 0;}

const int mod = 1000000007;
struct mint {
    long long x;
    mint(long long x=0) : x((x % mod + mod) % mod) {}
    mint operator-() const { return mint(-x);}
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod - a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
    mint operator+(const mint a) const { return mint(*this) += a;}
    mint operator-(const mint a) const { return mint(*this) -= a;}
    mint operator*(const mint a) const { return mint(*this) *= a;}
    mint pow(long long t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }
    // for prime mod
    mint inv() const { return pow(mod-2);}
    mint& operator/=(const mint a) { return *this *= a.inv();}
    mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

struct combination {
    vector<mint> fact, ifact;
    combination(int n) : fact(n+1), ifact(n+1) {
        assert(n < mod);
        fact[0] = 1;
        for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
        ifact[n] = fact[n].inv();
        for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
    }
    mint operator()(int n, int k) {
        if (k < 0 || k > n) return 0;
        return fact[n]*ifact[k]*ifact[n-k];
    }
};
// combination c(max);
// mint c(n, k)

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    int n, k;
    cin >> n >> k;
    vi a(n);
    rep(i, n) cin >> a[i];
    sort(all(a));
    mint ans = 0;
    combination c(n);
    for (int i = n-1; i >= 1; --i) {
        ans += c(i, k-1) * a[i];
    }
    for (int i = 0; i < n-1; ++i) {
        ans -= c(n-1-i, k-1) * a[i];
    }
    cout << ans << endl;
}

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

int main(){

  int N, M, ans;
  cin >> N >> M;
  long a[N], b[N], c[M], d[M], r;
  for(int i=0; i<N; i++){
    cin >> a[i] >> b[i];
  }
  for(int i=0; i<M; i++){
    cin >> c[i] >> d[i];
  }

  for(int i=0; i<N; i++){
    ans = 1;
    r = abs(a[i]-c[0]) + abs(b[i]-d[0]);
    for(int j=1; j<M; j++){
      ans = abs(a[i]-c[j]) + abs(b[i]-d[j]) < r ? j+1 : ans ;
      r = min(r, abs(a[i]-c[j]) + abs(b[i]-d[j]));
    }
    cout << ans << endl;
  }

  return 0;
}


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

using namespace std;

typedef long long ll;

const int MAXN = 5005;
const int MAXM = 10000005;
const int MOD = 1000000007;

int n,A,ans;
int fac[MAXM];
int inv[MAXM];
int v[MAXN][MAXN];

int power(int a,int b)
{
	int res = 1;
	while (b)
	{
		if (b & 1)
			res = (ll)res * a % MOD;
		a = (ll)a * a % MOD;
		b >>= 1;
	}
	return res;
}

ll C(int x,int y)
{
	return (ll)fac[x] * inv[y] % MOD * inv[x - y] % MOD;
}

ll getv(int l,int r)
{
	return (ll)fac[r] * inv[l - 1] % MOD;
}

int main()
{
	scanf("%d%d",&n,&A);
	fac[0] = 1;
	for (int i = 1;i <= n;i++)
		fac[i] = (ll)fac[i - 1] * i % MOD;
	inv[n] = power(fac[n],MOD - 2);
	for (int i = n;i >= 1;i--)
		inv[i - 1] = (ll)inv[i] * i % MOD;
	for (int i = 1;i <= A;i++)
	{
		int res = 0,ed = min(i + 1,A);
		for (int j = 0;j <= i;j++)
			(res += (j & 1 ? -1ll : 1ll) * C(i,j) * fac[i - j] % MOD * getv(i - j,i - j + n - A - 1) % MOD * getv(i - j + n - A + 1,i - j + n - ed) % MOD) %= MOD;
		(ans += res) %= MOD;
	}
	printf("%d\n",(ans + MOD) % MOD);
	return 0;
}

Measured memory_bytes: 81856
#include<bits/stdc++.h>
#define rep(i,n)for(int i=0;i<n;++i)
#include<string>
using namespace std;
typedef long long ll;
int gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	while (b) {
		int r = a % b;
		a = b;
		b = r;
	}
	return a;
}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

int main() {
	int n;
	cin >> n;
	string s;
	cin >> s;
	bool sign = true;
	if (n % 2 != 0)sign=false;
	else if (n % 2 == 0) {
		for (int i = 0;i < n / 2;++i) {
			if (s[i] != s[n / 2 + i]) {
				sign=false;
			}
		}
	}
	if (sign)puts("Yes");
	else puts("No");
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <limits.h>
 
#define N 1000000
 
int main (void)
{
    long long a[N], node2[N] = {0}, node0[N] = {0};
    long long n, i, ans = 0;
 
    scanf("%lld", &n);
 
    for (i = 0; i < n + 1; i++) {
        scanf("%lld", &(a[i]));
    }
 
    if (n == 0 && a[0] == 1) {
        puts("1");
        return 0;
    } else if (n == 0 && a[0] != 1) {
        puts("-1");
        return 0;
    }
 
    if (a[0] != 0 || a[n] == 0) {
        puts("-1");
        return 0;
    }
 
    node2[0] = (long long)1;
    for (i = 1; i < n + 1; i++) {
        node2[i] = node2[i - 1] * (long long)2 - a[i];
        if (node2[i] > LLONG_MAX/2) node2[i] = LLONG_MAX/2;
 
        if (node2[i] < 0) {
            puts("-1");
            return 0;
        }
 
        node0[i] = a[i];
    }
 
    for (i = n; i > 0; i--) {
        ans += node0[i];
        if (node0[i] < node2[i - 1]) {
            node0[i - 1] += node0[i];
        } else {
            node0[i - 1] += node2[i - 1];
        }
    }
 
    ans += 1;
 
    printf("%lld", ans);
 
    return 0;
}

Measured memory_bytes: 18136
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <algorithm>

using namespace std;
typedef long long ll;
const ll mod = 1e9 + 7;

int sx, sy, tx, ty;
int main(int argc, const char * argv[]) {
  cin >> sx >> sy >> tx >> ty;

  const int dx = tx - sx, dy = ty - sy;
  
  cout << string(dy, 'U') << string(dx, 'R');
  cout << string(dy, 'D') << string(dx, 'L');
  cout << 'L' << string(dy + 1, 'U') << string(dx + 1, 'R') << 'D';
  cout << 'R' << string(dy + 1, 'D') << string(dx + 1, 'L') << 'U';
  cout << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
inline bool chmax (long long& a, long long b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}
int main() {
	int x, y, z;
	cin >> x >> y >> z;
	int n = x + y + z;
	vector<int> a(n), b(n), c(n);
	for (int i = 0; i < n; i++) cin >> a[i] >> b[i] >> c[i];
	vector<pair<int, int>> cai(n);
	vector<int> ba(n), bc(n);
	for (int i = 0; i < n; i++) {
		cai[i] = {c[i] - a[i], i};
		ba[i] = b[i] - a[i];
		bc[i] = b[i] - c[i];
	}
	sort(cai.begin(), cai.end());

	vector<long long> left(y + 1, 0), right(y + 1, 0);
	priority_queue<pair<int, int>> que;
	for (int i = 0; i < x + y; i++) {
		int cri = cai[i].second;
		que.emplace(ba[cri], cri);
		if (i < x) {
			left[0] += a[cri];
		} else {
			left[i - x + 1] = left[i - x] + a[cri] + que.top().first, que.pop();
		}
	}
	priority_queue<pair<int, int>> rue;
	for (int i = n - 1; i >= x; i--) {
		int cri = cai[i].second;
		rue.emplace(bc[cri], cri);
		if (x + y <= i) {
			right[0] += c[cri];
		} else {
			right[x + y - i] = right[x + y - i - 1] + c[cri] + rue.top().first, rue.pop();
		}
	}
	long long ret = 0;
	for (int i = 0; i <= y; i++) {
		chmax(ret, left[i] + right[y - i]);
	}
	cout << ret << endl;
	return 0;
}

Measured memory_bytes: 4608
#include <iostream>
#include <cmath>
#include <algorithm>
#include <map>
#include <string>
#include <vector>
#define FOR(i, a, b)  for(int i=a; i<b; ++i)
#define rFOR(i, a, b) for(int i=a-1; i>=b; --i)
#define REP(i, n) for(int i=0; i<n; ++i)
#define rREP(i, n) for(int i=n-1; i>=0; --i)
#define all(a)  a.begin(), a.end()
#define DEVIDENUM 998244353
using namespace std;

int main(){
  int n;
  while(true){
    cin >> n;
    if(n==0)  break;
    int ans = 0;
    FOR(i, 1, n){
      int sum=0;
      FOR(j, i, n){
        sum += j;
        if(sum==n){
          ans++;
          break;
        }else if(sum>n){
          break;
        }else{
          continue;
        }
      }
    }
    cout << ans << endl;
  }
  return 0;
}


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

int main(void){
    long long n, a, b;
    cin >> n >> a >> b;
    if (a > b) cout << 0 << endl;
    else if (n == 1) cout << (a == b ? 1 : 0) << endl;
    else cout << b * (n - 2) - a * (n - 2) + 1 << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define rep2(i, s, n) for (ll i = s; i < (ll)(n); i++)
#define repr(i, n) for (ll i = n; i >= 0; i--)
#define fi first
#define sc second
#define pb push_back
#define COUT(x) cout << (x) << "\n"
#define COUTF(x) cout << setprecision(15) << (x) << "\n"
#define ENDL cout << "\n"
#define DF(x) x.erase(x.begin())  // 先頭文字削除
#define ALL(x) x.begin(), x.end()
#define SZ(x) (ll) x.size()
#define SORT(x) sort(ALL(x))
#define REVERSE(x) reverse(ALL(x))
#define MAX(x, y, z) max(x, max(y, z))
#define MIN(x, y, z) min(x, min(y, z))
#define ANS cout << ans << "\n"
#define RETURN(x)    \
  cout << x << "\n"; \
  return 0
clock_t CLOCK;
#define START_TIMER CLOCK = clock()
#define SHOW_TIMER cerr << "time: " << (ld)(clock() - CLOCK) / 1000000 << "\n"
#define init() \
  cin.tie(0);  \
  ios::sync_with_stdio(false)
#define LINE cerr << "[debug] line: " << __LINE__ << "\n";
#define debug(x) cerr << "[debug] " << #x << ": " << x << "\n";
#define debugV(v)                       \
  cerr << "[debugV] " << #v << ":";     \
  rep(i, v.size()) cerr << " " << v[i]; \
  cerr << "\n";
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using mll = map<ll, ll>;
using qll = queue<ll>;
using P = pair<ll, ll>;

constexpr ll INF = 0x3f3f3f3f3f3f3f3f;
constexpr ld PI = 3.141592653589793238462643383279;
ll get_digit(ll x) {
  return to_string(x).size();
}

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

ll lcm(ll a, ll b) {
  return a / gcd(a, b) * b;
}

vector<P> factorize(ll n) {
  vector<P> result;
  for (ll i = 2; i * i <= n; ++i) {
    if (n % i == 0) {
      result.pb({i, 0});
      while (n % i == 0) {
        n /= i;
        result.back().second++;
      }
    }
  }
  if (n != 1) {
    result.pb({n, 1});
  }
  return result;
}

vll divisor(ll n) {
  vll ret;
  for (ll i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      ret.push_back(i);
      if (i * i != n) ret.push_back(n / i);
    }
  }
  SORT(ret);
  return (ret);
}

signed main() {
  init();
  // ll N;
  // cin >> N;

  vll A(3);
  rep(i, 3) cin >> A[i];
  SORT(A);
  ll ans = A[0] + A[1];
  ANS;
  return 0;
}

Measured memory_bytes: 3632
#include<stdio.h>

int main(void){
	int m;
	int count;
	
	while(scanf("%d",&m)){
		if(m==0)
		break;
		count = 0;
		m=1000-m;
		if(m>=500){
			m-=500;
			count++;
		}
		while(m>=100){
			m-=100;
			count++;
		}
		while(m>=50){
			m-=50;
			count++;
		}
		while(m>=10){
			m-=10;
			count++;
		}
		while(m>=5){
			m-=5;
			count++;
		}
		count+=m;
		printf("%d\n",count);
	}
	return 0;
}

Measured memory_bytes: 600
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b,c,d;
  cin >> a >> b >> c >> d;
  if(a <= c && b <= d){
    if(c <= b)
      cout << b-c << endl;
    else
      cout << 0 << endl;
  }
  else if(a >= c && b >= d){
    if(a <= d)
      cout << d-a << endl;
    else
      cout << 0 << endl;
  }
  else if(a <= c && d <= b)
    cout << d-c << endl;
  else if(c <= a && b <= d)
    cout << b-a << endl;
}
  
    

Measured memory_bytes: 256
#include<stdio.h>
int main(){
	int list[13][13];
	int n,i,j;
	int sum_v[13],sum_s[13];
	for(;scanf("%d",&n)&&n;){
		for(i=0;i<13;i++){sum_v[i]=0;sum_s[i]=0;}
		for(i=0;i<n;i++){
			for(j=0;j<n;j++){
				scanf("%d",&list[i][j]);
				printf("%5d",list[i][j]);
				sum_s[i]+=list[i][j];
				sum_v[j]+=list[i][j];
			}
			printf("%5d\n",sum_s[i]);
			sum_v[j]+=sum_s[i];
		}
		for(i=0;i<=n;i++){
			printf("%5d",sum_v[i]);
		}
		printf("\n");
	}


	return 0;
}

Measured memory_bytes: 0
package main

import (
	"fmt"
	"io"
	"os"
	"sort"

)

func main() {
	solve(os.Stdin, os.Stdout)
}

type inInfo struct {
	in    int
	after int
}

type inInfoSorter []inInfo

func (a inInfoSorter) Len() int      { return len(a) }
func (a inInfoSorter) Swap(i, j int) { a[i], a[j] = a[j], a[i] }
func (a inInfoSorter) Less(i, j int) bool {
	switch {
	case a[i].in > a[j].in:
		return true
	case a[i].in < a[j].in:
		return false
	case a[i].after > a[j].after:
		return true
	default:
		return false
	}
}

func sum(w []int) int {
	s := 0
	for _, v := range w {
		s += v
	}
	return s
}

type ptr []int

func (x ptr) top(i int) int {
	ptrs := []int(x)
	var his []int
	cur := i
	for ; cur >= 0 && ptrs[cur] != cur; cur = ptrs[cur] {
		his = append(his, cur)
	}
	for _, v := range his {
		ptrs[v] = cur - 1
	}
	if cur >= 0 {
		ptrs[cur] = cur - 1
	}
	return cur
}

func solve(stdin io.Reader, stdout io.Writer) {
	var n, m int
	var infos []inInfo

	fmt.Fscanln(stdin, &n, &m)

	for i := 0; i < n; i++ {
		var info inInfo
		fmt.Fscanln(stdin, &info.after, &info.in)
		infos = append(infos, info)
	}

	sort.Sort(inInfoSorter(infos))

	var ans = make([]int, m)
	var p = make([]int, m)
	for i := range p {
		p[i] = i
	}

	for _, w := range infos {
		i := ptr(p).top(m - w.after)
		if i >= 0 {
			ans[i] = w.in
		}
	}

	fmt.Fprintln(stdout, sum(ans))

}



Measured memory_bytes: 7424
#include <bits/stdc++.h>
#define mod 1000000007
#define pb push_back
#define ll long long
#define mp make_pair
using namespace std;
int main(){
	ll n;
	cin>>n;
	vector<ll> a,ans;
	vector< pair<ll,ll> > ma, ne;
	ll c = (1<<n);
	for(int i=0;i<c;i++){
		ll x;
		cin>>x;
		a.pb(x);
	}
	ma.pb(mp(a[0],0));
	ne.pb(mp(-1,-1));
	for(int i=1;i<c;i++){
		vector< pair<ll,ll> > ps;
		ps.pb(mp(a[i],i));
		for(int j=0;j<18;j++){
			if( (i>>j)%2 == 1 ){
				ll cur = i -(1<<j);
				ps.pb( ma[cur] );
				ps.pb( ne[cur] );
			}
		}
		sort( ps.begin(), ps.end() );
		reverse( ps.begin(), ps.end() );
		unique( ps.begin(), ps.end() );
		ma.pb(ps[0]);
		ne.pb(ps[1]);
	}
	ans.pb(0);
	for(int i=1;i<c;i++){
		ll ca = max(ans[i-1], ma[i].first+ne[i].first);
		ans.pb(ca);
	}
	for(int i=1;i<c;i++){
		cout<<ans[i]<<endl;
	}
	return 0;
}

Measured memory_bytes: 17468
def calc(N,p):
  ans = 0
  i = p
  while N>=i:
    ans += N//i
    i *= p
  return ans

def sieve(n):
  is_prime = [True for _ in range(n+1)]
  is_prime[0] = False
  for i in range(2, n+1):
    if is_prime[i-1]:
      j = 2 * i
      while j <= n:
        is_prime[j-1] = False
        j += i
  table = [i for i in range(1, n+1) if is_prime[i-1]]
  return table
  
from itertools import groupby, accumulate, product, permutations, combinations
def check(value,lis):
  ans = 0
  n = len(lis)
  for perm in permutations(value,n):
    for i in range(n):
      if perm[i]<lis[i]:
        break
    else:
      ans += 1
  return ans

def solve():
  N = int(input())
  table = sieve(N)
  v = []
  for p in table:
    v.append(calc(N,p))
  v.sort(reverse=True)
  ans = 0
  ans += check(v,[74])
  ans += check(v,[24,2])
  ans += check(v,[14,4])
  ans += check(v,[4,4,2])//2
  return ans
print(solve())

Measured memory_bytes: 9288
#include "bits/stdc++.h"
#include "math.h"
#include "string.h"
#include "algorithm"
 
using namespace std;
typedef int64_t ll;
typedef vector<int64_t> vll;
typedef vector<vll> vvll;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef pair<int,int> P;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SIZE(a) int((a).size())



int main(){
  int n,m;
  cin>>n>>m;
  vvb d(n+1,vb(n+1,false));
  REP(i,m){
    int a,b;
    cin>>a>>b;
    d[a][b]=true;
    d[b][a]=true;
  }
  vector<int> v(n);
  REP(i,n){
      v[i]=i+1;
  }
  int count=0;
  do{
    int tmp=0;
    REP(i,n-1){
      if(d[v[i]][v[i+1]]){
        tmp++;
      }
      else{break;}
    }
    if(tmp==n-1){
      count++;
    }
  }while(next_permutation(v.begin()+1,v.end()));
  cout<<count<<endl;

}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ll long long
#define pb push_back
#define fi first
#define se second 
#define mp make_pair
#define int long long
int ans;
int nCr(int n,int r)
{
    if(n == 1) return 0;
    return ((n*(n-1))/2);
}
signed main()
{
    IOS
    vector<string> vec;
    map<string,int> Hash;
    int n; cin>>n;
    string str;
    for(int i=0;i<n;i++)
    {
        cin>>str;
        sort(str.begin(),str.end());
        vec.pb(str);
    }
    for(int i=0;i<n;i++)
    {
        Hash[vec[i]]++;
    }
    ans =0;
    for(auto it : Hash)
    {
        ans += nCr(it.se,2);
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 12020
#include <bits/stdc++.h>
#define rep(i,a,n) for(int i=a;i<n;i++)
#define repb(i,a,b) for(int i=a;i>=b;i--)
#define all(a) a.begin(),a.end()
#define o(a) cout<<a<<endl
#define int long long
#define fi first
#define se second
using namespace std;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;

signed main(){
	int n;
	while(1){
		cin>>n;
		if(n==-1) break;
		double a[1010]={};
		double c=0;
		a[0]=1;
		rep(i,1,n){
			a[i]=sqrt(1+a[i-1]*a[i-1]);
			c+=asin(1.0/a[i]);
		}
		double y=a[n-1]*sin(c);
		double x=a[n-1]*cos(c);
		printf("%.10lf\n%.10lf\n", x,y);
	}

}

Measured memory_bytes: 1244
h = 0
w = 0
listh = []
listw = []
count = 0

while(True):
    h, w = map(int,input().split())
    if h ==0 and w == 0:
        break
    listh.append(h)
    listw.append(w)
    count += 1

for i in range(count):
    str = ''
    for h in range(listh[i]):
        if h == 0 or h == listh[i]-1:
            for w in range(listw[i]):
                str += '#'
            print(str)
            str = ''
        else:
            for w in range(listw[i]):
                if w == 0 or w == listw[i]-1:
                    str += '#'
                else:
                    str += '.'
            print(str)
            str = ''

    print('')


Measured memory_bytes: 5624
#include <bits/stdc++.h>
        using namespace std;
        #define el "\n"
        #define ll long long
        #define ull unsigned long long int
        #define pb push_back
        #define mp make_pair
        #define X first
        #define Y second
        #define M 1000000007
        #define all(v) v.begin(), v.end()
        long long pow(long long int a,long long int b,long long int MOD)
        {
            long long x=1,y=a; 
            while(b > 0)
            {
                if(b%2 == 1)
                {
                    x=(x*y);
                    if(x>MOD) x%=MOD;
                }
                y = (y*y);
                if(y>MOD) y%=MOD; 
                b /= 2;
            }
            return x;
        }
        long long modInverse(long long int n, long long int MOD)
        {
            return pow(n,MOD-2,MOD);
        }

        int main() {
          ios_base::sync_with_stdio(false);
          cin.tie(NULL);
          ll n,x;
          cin>>n>>x;
          ll a[n][x];
          memset(a,0,sizeof(a));
          for(int i=0;i<n;i++){
              for(int j=0;j<x;j++)cin>>a[i][j];
          }
          ll ans=0,cnt=0;
          for(int i=0;i<n;i++){
              for(int j=i+1;j<n;j++){
                  ans=0;
                  for(int k=0;k<x;k++){
                      ans+=abs(a[j][k]-a[i][k])*abs(a[j][k]-a[i][k]);
                  }
                  if((ll)sqrt(ans)*(ll)sqrt(ans)==ans)cnt++;
              }
          }
          cout<<cnt<<el;
          return 0;
        }


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

int n ,c;
int d[100][100];
int mas[500][500];
int cnt[3][100] = {};

long long change[3][100] = {};

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

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

    for(int i = 0;i < n;i++){
        for(int j = 0;j < n;j++){
            cin >> mas[i][j];
            mas[i][j]--;
        }
    }

    for(int i = 0;i < n;i++){
        for(int j = 0;j < n;j++){
            cnt[(j+(i%3))%3][mas[i][j]]++;
        }
    }

    for(int p = 0;p < 3;p++){
        for(int j = 0;j < c;j++){
            for(int k = 0;k < c;k++){
                change[p][k] += d[j][k] * cnt[p][j];
            }
        }
    }

    long long ans = LLONG_MAX;

    for(int i = 0;i < c;i++){
        for(int j = 0;j < c;j++){
            if(i != j){
                for(int k = 0;k < c;k++){
                    if(i != k && j != k){
                        ans = min(ans, change[0][i] + change[1][j] + change[2][k]);
                    }
                }
            }
        }
    }

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

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

int main() {
    rep(i,5) {
        int x;
        cin >>x;
        if(x==0){
            cout << i+1 << endl;
            return 0;
        }
    }
    return 0;
}


Measured memory_bytes: 3580
#define _USE_MATH_DEFINES
#include <math.h>
#include <iostream>
#include <iomanip>
#include <cstdlib>
#include <algorithm>

using namespace std;
typedef long long ll;

#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)

int main() {

    ll N,A,B;
    cin >> N >> A >> B;
    cout << B << " " << N << " " << A << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int d;
	cin>>d;
	switch(d)
	{
		case 22:cout<<"Christmas Eve Eve Eve"<<endl;break;
		case 23:cout<<"Christmas Eve Eve"<<endl;break;
		case 24:cout<<"Christmas Eve"<<endl;break;
		case 25:cout<<"Christmas"<<endl;break;
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
using namespace std;
int n;
int m[200005];
int main(){
	cin>>n;
	for(int i=0;i<n-1;i++){
		int v;
		cin>>v;
		m[v-1]+=1;
	}
	for(int i=0;i<n;i++)cout<<m[i]<<endl;
	return 0;
} 

Measured memory_bytes: 4368
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {

        Scanner sc = new Scanner(System.in);

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

        if( C >= A && C <= B){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }
    }
}


Measured memory_bytes: 21844
#include <stdio.h>
#include <vector>
#include <iostream>
#include <queue>
#include <bits/stdc++.h>

#define rep(i,n) for (int i=0;i<(n);++i)
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<vs> vvs;

typedef vector<pair<int, int>> vpi;
typedef vector<pair<ll, ll>> vpl;
typedef vector<tuple<int, int, int>> vti;

int main() {
    ios::sync_with_stdio(0); cin.tie(0);
    int a, b, t;
    cin >> a >> b >> t;
    cout << (t / a * b) << endl;
}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**6)
n,m = map(int,input().split())
graph = [[] for _ in range(n)]
for i in range(m):
    x,y = map(lambda z:z-1,map(int,input().split()))
    graph[x].append(y)


dp = [-1]*n #dp[i]はiからスタートした有向pathのうち最長のものの長さ
#print(graph)
def solve(i):
    if dp[i] != -1:#既に計算済み
        return dp[i]
    if len(graph[i]) == 0:#iが葉であるとき
        dp[i] = 0
        return 0
    max_length = 0
    for next_node in graph[i]:
        dp[next_node] = solve(next_node)
        max_length = max(max_length,dp[next_node])

    dp[i] = max_length + 1
    return dp[i]

ans = 0
for i in range(n):
    ans = max(ans,solve(i))


print(ans)

Measured memory_bytes: 165084
#include <stdio.h>
    #include <string.h>
    #include <stdlib.h>
    #include <ctype.h>
    #include <math.h>

    int main() {

        int a,b,x;
        
        scanf("%d %d %d",&a,&b,&x);
        
        if(a>x || a + b<x){
            printf("NO");
        }else{
            printf("YES");
        }
        
        
        return 0;

    }


Measured memory_bytes: 128
#include <stdio.h>

int main(int argc, char** argv)
{
	int n;
	short a[100000+2]={0};
	int total = 0;
	int i;
	
	scanf("%d", &n);
	for(i=0;i<n;++i){
		scanf("%hd", a+(i+1));
		total += (a[i]>a[i+1]?a[i]-a[i+1]:a[i+1]-a[i]);
	}
	total += (a[n]>a[n+1]?a[n]-a[n+1]:a[n+1]-a[n]);
	for(i=0;i<n;++i){
		int x, y, z;
		x=(a[i+0]>a[i+1]?a[i+0]-a[i+1]:a[i+1]-a[i+0]);
		y=(a[i+1]>a[i+2]?a[i+1]-a[i+2]:a[i+2]-a[i+1]);
		z=(a[i+0]>a[i+2]?a[i+0]-a[i+2]:a[i+2]-a[i+0]);
		printf("%d\n", total - x - y + z);
	}
	return 0;
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
#define db(x) cerr << #x << "=" << x << endl
#define db2(x, y) cerr << #x << "=" << x << "," << #y << "=" << y << endl
#define db3(x, y, z) cerr << #x << "=" << x << "," << #y << "=" << y << "," << #z << "=" << z << endl
#define dbv(v) cerr << #v << "="; for (auto _x : v) cerr << _x << ", "; cerr << endl
#define dba(a, n) cerr << #a << "="; for (int _i = 0; _i < (n); ++_i) cerr << a[_i] << ", "; cerr << endl
typedef long long ll;
typedef long double ld;
const ll MOD = 1000003;
const int MAXN = MOD;
ll fac[MAXN], invfac[MAXN];
ll inv[MAXN];
ll modex(ll a, ll p, ll m = MOD) {
	if (!p) return 1;
	if (p & 1) return a * modex(a, p - 1, m) % m;
	ll v = modex(a, p >> 1, m);
	return v * v % m;
}
int main() {
	fac[0] = 1;
	for (int i = 1; i < MAXN; ++i)
		fac[i] = fac[i - 1] * i % MOD;
	invfac[MAXN - 1] = modex(fac[MAXN - 1], MOD - 2);
	for (int i = MAXN - 2; i >= 0; --i)
		invfac[i] = invfac[i + 1] * (i + 1) % MOD;
	for (int i = 1; i < MAXN; ++i)
		inv[i] = invfac[i] * fac[i - 1] % MOD;
	int Q;
	scanf("%d", &Q);
	while (Q--) {
		ll x, d, n;
		scanf("%lld%lld%lld", &x, &d, &n);
		ll ans;
		if (!d) {
			ans = modex(x, n);
		} else if (n >= MOD) {
			ans = 0;
		} else if (!x) {
			ans = 0;
		} else {
			x = x * inv[d] % MOD;
			if (x + n - 1 >= MOD) ans = 0;
			else {
				// x(x+1)..(x+(n-1))
				ans = fac[x + n - 1] * invfac[x - 1] % MOD;
				ans = ans * modex(d, n) % MOD;
			}
		}
		printf("%lld\n", ans);
	}
}


Measured memory_bytes: 24320
a, b = gets.split.map(&:to_i)

a1 = (a / 0.08).ceil
b1 = (b / 0.10).ceil
a2 = (a.succ / 0.08).ceil
b2 = (b.succ / 0.10).ceil

puts ([*a1...a2] & [*b1...b2])[0] || -1


Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
#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++)
typedef long long ll;

int main() {
    int A, B;
    cin >> A >> B;
    cout << (A + B) % 24 << endl;
}


Measured memory_bytes: 256