akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>
#include <tuple>
#include <climits>

using namespace std;

using ll = long long;

constexpr ll INF = LLONG_MAX / 3;

class segtree {
  private:
    int n;
    vector<ll> local, global;
    void update_impl(int l, int r, ll x, int k, int a, int b) {
      if (r <= a || b <= l) return;
      local[k] = min(local[k], x);
      if (l <= a && b <= r) {
        global[k] = min(global[k], x);
        return;
      }
      int m = (a + b) / 2;
      update_impl(l, r, x, 2 * k, a, m);
      update_impl(l, r, x, 2 * k + 1, m, b);
    }
    ll minimum_impl(int l, int r, int k, int a, int b) {
      if (r <= a || b <= l) return INF;
      if (l <= a && b <= r) return local[k];
      int m = (a + b) / 2;
      ll left = minimum_impl(l, r, 2 * k, a, m),
         right = minimum_impl(l, r, 2 * k + 1, m, b);
      return min({left, right, global[k]});
    }
  public:
    segtree(int n_) {
      n = 1;
      while (n < n_)
        n *= 2;
      global.assign(2 * n, INF);
      local.assign(2 * n, INF);
    }
    void update(int l, int r, ll x) {
      update_impl(l, r, x, 1, 0, n);
    }
    ll minimum(int l, int r) {
      return minimum_impl(l, r, 1, 0, n);
    }
};

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  int n, m;
  cin >> n >> m;
  segtree tree(n);
  vector<tuple<int, int, ll>> edges(m);
  for (auto& t : edges)
    cin >> get<0>(t) >> get<1>(t) >> get<2>(t);
  sort(begin(edges), end(edges));
  tree.update(0, 1, 0);
  for (auto&& tup : edges) {
    int f, t;
    ll l;
    tie(f, t, l) = tup;
    f--; t--;
    ll current = tree.minimum(f, t + 1);
    tree.update(f, t + 1, current + l);
  }
  ll dist = tree.minimum(n - 1, n);
  cout << (dist == INF ? -1 : dist) << endl;
}

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

int main(){
  int M=1e9+7,n,m;
  int64_t ans=1; //長さ0の部分列の分はあらかじめ足しておく
  cin>> n >> m;
  vector<int> s(n),t(m);
  unordered_map<int,set<int>> ms;
  for (int i=0; i<n; i++) cin>> s[i];
  for (int i=0; i<m; i++) cin>> t[i];
  
  for (int i=0; i<n; i++) ms[s[i]].insert(i);
  vector<int> a(n);
  for (int i=0; i<m; i++){
    int k=0,num=0,var;
    for (int j: ms[t[i]]){
      while (k<j){
        num+=a[k]; num%=M;
        k++;
      }
      var=num;
      num+=a[j]; num%=M;
      a[j]+=var+1;a[j]%=M;
      k++;
    }
  }
  for (int i: a){ ans+=i; ans%=M;}
  cout<< ans <<endl;
}

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

#define endl ("\n")
#define all(x) (x).begin(),(x).end()
#define print(x) cout << (x)
#define println(x) cout << (x) << endl

template<typename Type>
Type gcd(const Type a,const Type b){return(b==0)?a:gcd(b,a%b);}
template<typename Type>
Type lcm(const Type a,const Type b){return(a/gcd(a,b))*b;}

template<typename Type>
void sort(vector<Type>& v){
	sort(all(v));
}

int main(){
	ll N;
	cin >> N;
	cout << (N/500*1000+(N%500)/5*5);
}

Measured memory_bytes: 256
n,q = list(map(int, input().split()))
s = input()
ans = [0]*(n+1)
lr=[list(map(int, input().split())) for _ in range(q)]
for i in range(1,n):
    
    if s[i-1]=='A' and s[i]=='C':
        ans[i+1] = ans[i] + 1
    else:
        ans[i+1]= ans[i]
#print(ans)
for i in range(q):
    print(ans[lr[i][1]]-ans[lr[i][0]])
        

Measured memory_bytes: 29532
#include <iostream>
#include <string>
#include <vector>
#include <climits>
#include <algorithm>
#include <set>

using namespace std;

int main() {
  int N;
  cin >> N;
  int a[2][N];
  int ans[2][N];
  for (int i=0; i<2; i++) {
    for (int j=0; j<N; j++) {
      cin >> a[i][j];
      ans[i][j] = 0;
    }
  }
  for (int i=0; i<2; i++) {
    for (int j=0; j<N; j++) {
      if (i>0 && j>0) {
        ans[i][j] = max(ans[i-1][j], ans[i][j-1]) + a[i][j];
      } else if (i>0) {
        ans[i][j] = ans[i-1][j] + a[i][j];
      } else if (j>0) {
        ans[i][j] = ans[i][j-1] + a[i][j];
      } else {
        ans[i][j] = a[i][j];
      }
      // cout << i << ',' << j << ' ' << ans[i][j] << endl;
    }
  }
  cout << ans[1][N-1] << endl;
}

Measured memory_bytes: 256
n = int(input())
l = sorted(list(int(input()) for _ in range(n)))
a = sum(l)
if a%10!=0:
  print(a)
else:
  for i in l:
    if (a-i)%10!=0:
      print(a-i)
      break
    else:
      continue
  else:
    print(0)
  


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T &a, T b){if(a < b){ a = b; return true;} return false;}

int main(){
    int n; cin >> n;
    vector<int> a(n), b(n), c(n);
    int dp[n+1][3]; //dp[i][j]はi日目にjをした場合の最大値
    for(int i = 0; i < n; i++){
        cin >> a[i] >> b[i] >> c[i];
    }
    for(int i = 0; i < n; i++){
        for(int j = 0; j < 3; j++){
            dp[i][j] = 0;
        }
    }
    dp[0][0] = a[0]; dp[0][1] = b[0]; dp[0][2] = c[0];
    for(int i = 1; i < n; i++){
        chmax(dp[i][0], max(dp[i-1][1], dp[i-1][2])+a[i]);
        chmax(dp[i][1], max(dp[i-1][2], dp[i-1][0])+b[i]);
        chmax(dp[i][2], max(dp[i-1][0], dp[i-1][1])+c[i]);
    }
    cout << max(max(dp[n-1][0], dp[n-1][1]), dp[n-1][2]) << endl;
}

Measured memory_bytes: 2560
import java.util.Scanner;

public class Main{

	public static void main(String[] args) {
		Scanner scn = new Scanner(System.in);
		int N = scn.nextInt();
		long[] A = new long[N];
		for(int i =0 ;i < N;i++) {
			A[i] = scn.nextLong();
		}

		long[] B = new long[N];
		int a = 0,b = N-1;
		int n = N-1;
		while(a<=b) {
			B[a] = A[n];
			n--;
			if(n!=-1) {
				B[b] = A[n];
			}
			n--;
			a++;
			b--;
		}
		for(int i = 0;i < N;i++) {
			System.out.print(B[i] + " ");
		}
	}

}


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

int main(){
double x1,y1,x2,y2;
double ans;
cin>>x1>>y1>>x2>>y2;
ans=sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));
printf("%.5lf\n",ans);
return 0;
}


Measured memory_bytes: 3204
#include<bits/stdc++.h>
#define LL long long
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPA(i,n) for(int i=1;i<(n);++i)
#define foreach(i, n) for(auto &i:(n))
#define PII pair<int,int>
#define PLI pair<long long, int>
#define PLL pair<long long, long long>
#define MOD ((int)1e9 + 7)
#define INF ((int)1e9+5)
#define INFLL ((LL)4e18)
#define ALL(x) (x).begin(),(x).end()
#define BIT(x) (1 << (x))
using namespace std;

bool check(vector<int> line){
	for(int i=0;i<line.size()-1;++i){
		if(line[i] > line[i+1])return false;
	}
	return true;
}

int main(){
	int n;
	cin >> n;
	vector<int> line(n);
	foreach(i, line)cin>>i;
	REP(i, n){
		REP(j, n){
			swap(line[i], line[j]);
			if(check(line)){
				cout << "YES" << endl;
				return 0;
			}
			swap(line[i], line[j]);
		}
	}
	cout << "NO" << endl;
	return 0;
}


Measured memory_bytes: 256
#include<math.h>
#include<stdio.h>
int main()
{
    int h,m,s,n;
    scanf("%d",&n);
    s=n%60;
    m=(n/60)%60;
    h=(n/3600)%60;
    printf("%d:%d:%d\n",h,m,s);
    return 0;
}



Measured memory_bytes: 2764
// !Start && !End 
//  0 se divide
//https: //www.youtube.com/watch?v=6Nb-prB-4P0&list=RD6Nb-prB-4P0&start_radio=1

// https: //www.youtube.com/watch?v=eYDI8b5Nn5s
// Electrify my OOOoooooOOOoooOOOOOoooooOOOooo!
#pragma optimise GCC(-O2)
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define pii pair<ll,ll>
#define ve(x) vector<x>
#define f(a,b,c) for(int a=b;a<c;a++)
#define foto(x,v) for(auto x:v)
#define read(t) ll t; cin>>t;
#define reads(t) string t; cin>>t;
#define readarr(arr,n) ll arr[n]; f(i,0,n) cin>>arr[i];
#define forstl(i,v) for(auto &i: v)
#define ln endl
#define Endl endl
#define dbg(x) cout<<#x<<" = "<<x<<ln;
#define dbg2(x,y) cout<<#x<<" = "<<x<<" & "<<#y<<" = "<<y<<ln;
#define dbgstl(v) cout<<#v<<" = \n"; { int c=0; forstl(it,v) \
cout<<"    Term "<< ++c <<" = "<<it<<ln;} cout<<ln;
#define dbgstlp(v) cout<<#v<<" = \n"; { int c=0; forstl(it,v) \
cout<<"    Term "<< ++c <<" = "<<it.fi<<" , "<<it.se<<ln;} cout<<ln;
#define dbgarr(v,s,e) cout<<#v<<" = "; f(i,s,e) cout<<v[i]<<", "; cout<<ln;
#define addEdge(tr,k) f(i,0,k) { ll x,y; cin>>x>>y, tr[x].push_back(y), tr[y].push_back(x);}
#define all(v) v.begin(),v.end()

mt19937_64 rang(chrono::high_resolution_clock::now().time_since_epoch().count());
int rng(int lim) { uniform_int_distribution<int> uid(0, lim - 1); return uid(rang); }

//														GLOBAL VARS
ll INF =LLONG_MAX;
const ll M= 1000000007;

//														USEFUL FUNCTIONS
ll powm(ll ,ll);

// 														MAIN
int main()
{ 
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	cout.tie(NULL);
    //It gets easier day by day, but the hard part is to........
    read(n)
    readarr(a,n)
    sort(a,a+n);
    ll ans = 1;
    map<ll,ll> mp;
    f(i,0,n)
    {
        mp[a[i]]++;
    }
    bool flag = 1;
    if(n%2)
    {
        if(mp[0] != 1) flag = 0;
        for (int i = 2 ;i<n;i+=2)
        {
            if(mp[i] != 2) flag = 0;
        }
    }
    else
    {
        for (int i = 1 ;i<n;i+=2)
        {
            if(mp[i] != 2) flag = 0;
        }
    }
    if(!flag) cout<<0;
    else
    {
        if(n%2) cout<<powm(2,(n-1)/2);
        else cout<< powm(2,n/2);
    }
    
}










//													FUNCTIONS DECLARATIONS
ll powm(ll a, ll b) {
	ll res=1;
	while(b) {
		if(b&1)
			res=(res*a)%M;
		a=(a*a)%M;
		b>>=1;
	}
	return res;
}


Measured memory_bytes: 6144
#include "bits/stdc++.h"
using namespace std;
 
////////////// Prewritten code follows. Look down for solution. ////////////////

#define int long long
#define endl '\n'
#define fs first
#define sc second
#define pb push_back
#define len(x) ((int)(x).size())     
#define all(x) (x).begin(), (x).end()
#define test int _; cin >> _; while(_--)
#define fastio ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);

typedef pair<int, int> pii;
typedef long long ll;
typedef long double ld;

const ll LINF = 0x3f3f3f3f3f3f3f3f;
const int INF = 0x3f3f3f3f;
const ll MOD = 1e9+7;

ll gcd(ll a, ll b){return (b == 0LL ? a : gcd(b, a%b));}
inline ll mod(ll a, ll b){return ((a%b)+b)%b;}
inline ll expo(ll b, ll p, ll m = MOD){
  ll ans = 1; 
  while(p > 0){
    if(p&1LL) ans = mod(ans*b, m); 
    b = mod(b*b, m); 
    p >>= 1LL;
  } 
  return ans;
}
 
////////////////////////// Solution starts below. //////////////////////////////

int dp[405][405];
int v[405], pref[405];
int n;

int solve(int l, int r){
  if(l == r) return 0;
  if(dp[l][r] != -1) return dp[l][r];
  int& ans = dp[l][r];
  ans = LINF;
  for(int k = l; k < r; k++){
    ll val = solve(l, k) + solve(k+1, r);
    val += pref[r] - pref[l-1];
    ans = min(ans, val);
  }
  return dp[l][r] = ans;
}

int32_t main(){
  fastio;
  cin >> n;
  memset(dp, -1, sizeof dp);
  for(int i = 1; i <= n; i++){
    cin >> v[i];
    pref[i] = pref[i-1] + v[i];
  }
  cout << solve(1, n) << endl;
  return 0;
}

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

int main()
{
    string S, T;
    cin >> S;
    cin >> T;

    int match = 0;
    for (int i=0; i<3; i++) {
        if (S[i] == T[i]) {
            match++;
        }
    }
    cout << match << endl;
    return 0;
}

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

int l, r;

int main()
{
    cin >> l >> r;
    long long b = 1e9 * 2 + 1;
    for (int i = l; i <= min(l + 2019, r); ++i)
        for (int j = i + 1; j <= min(l + 2019, r); ++j)
            b = min(b, (1ll * i * j) % 2019);
    cout << b << endl;
    return 0;
}

Measured memory_bytes: 256
a,b,k=map(int,input().split())
al=a+k
bs=b-k
if k>(b-a)/2:
	for i in range(a,b+1):
		print(i)
else:
	for i in range(a,al):
		print(i)
	for j in range(bs+1,b+1):
		print(j)

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

int n,c[N][4],e[4][4],f[N];
long long h[N],ans;

int query(int c[]){
	long long tmp=((c[0]*1000ll+c[1])*1000+c[2])*1000+c[3];
	int x=lower_bound(h+1,h+4*n+1,tmp)-h;
	return h[x]==tmp?f[x]:0;
}

void modify(int c[],int t){
	f[lower_bound(h+1,h+4*n+1,((c[0]*1000ll+c[1])*1000+c[2])*1000+c[3])-h]+=t;
	f[lower_bound(h+1,h+4*n+1,((c[1]*1000ll+c[2])*1000+c[3])*1000+c[0])-h]+=t;
	f[lower_bound(h+1,h+4*n+1,((c[2]*1000ll+c[3])*1000+c[0])*1000+c[1])-h]+=t;
	f[lower_bound(h+1,h+4*n+1,((c[3]*1000ll+c[0])*1000+c[1])*1000+c[2])-h]+=t;
}

int read(){
	int x=0,f=1;char ch=getchar();
	for (;!isdigit(ch);ch=getchar()) if (ch=='-') f=-f;
	for (;isdigit(ch);ch=getchar()) x=x*10+ch-'0';
	return x*f;
}
 
int main(){
	n=read();
	for (int i=1;i<=n;i++){
		c[i][0]=c[n+i][1]=c[2*n+i][2]=c[3*n+i][3]=read();
		c[i][1]=c[n+i][2]=c[2*n+i][3]=c[3*n+i][0]=read();
		c[i][2]=c[n+i][3]=c[2*n+i][0]=c[3*n+i][1]=read();
		c[i][3]=c[n+i][0]=c[2*n+i][1]=c[3*n+i][2]=read();
	}
	for (int i=1;i<=4*n;i++)
		h[i]=((c[i][0]*1000ll+c[i][1])*1000+c[i][2])*1000+c[i][3];
	sort(h+1,h+4*n+1);h[4*n+1]=1e12;
	for (int i=1;i<=n;i++)
		modify(c[i],1);
	
	for (int i=1;i<=4*n;i++)
		for (int j=i+1;j<=4*n;j++)
			if (i%n!=j%n){
				modify(c[i],-1);modify(c[j],-1);
				e[0][0]=c[i][1];e[0][1]=c[i][0];e[0][2]=c[j][1];e[0][3]=c[j][0];
				e[1][0]=c[i][2];e[1][1]=c[i][1];e[1][2]=c[j][0];e[1][3]=c[j][3];
				e[2][0]=c[i][3];e[2][1]=c[i][2];e[2][2]=c[j][3];e[2][3]=c[j][2];
				e[3][0]=c[i][0];e[3][1]=c[i][3];e[3][2]=c[j][2];e[3][3]=c[j][1];
				long long tmp=query(e[0]);modify(e[0],-1);
				tmp*=query(e[1]);modify(e[1],-1);
				tmp*=query(e[2]);modify(e[2],-1);
				ans+=tmp*query(e[3]);
				modify(e[0],1);modify(e[1],1);modify(e[2],1);
				modify(c[i],1);modify(c[j],1);
			}
	printf("%lld\n",ans/12);
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){
  int i,j,n,q,c=0;
  int S[10000];
  int T[500];

  scanf("%d",&n);

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

  scanf("%d",&q);

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

  for(i=0;i<q;i++){
    for(j=0;j<n;j++){
      if(S[j]==T[i]){
	c++;
	break;
      }
    }
  }

  printf("%d\n",c);

  return 0;
}



Measured memory_bytes: 2108
#include <stdio.h>
#include <string.h>

int main(void)
{
	int inning,out_count,score,base[4];
	int i,j,ruisya;
	char event[10];
	
	scanf("%d",&inning);
	for(i=0;i<inning;i++)
	{	//初期化
		for(j=0;j<4;j++)
			base[j]=0;
		score=0;
		ruisya=0;
		out_count=0;
		//1ニングのイベント
		while(out_count<3)
		{
			scanf("%s",event);
			if(strcmp(event,"HIT")==0)	//ヒット時
			{
				base[ruisya]=1;
				ruisya++;
				if(ruisya==4)
				{
					score++;
					ruisya--;
				}
			}
			else if(strcmp(event,"HOMERUN")==0)	//ホームラン時
			{
				score+=ruisya+1;
				for(j=0;j<4;j++)
					base[j]=0;
				ruisya=0;
			}
			else if(strcmp(event,"OUT")==0)	//アウト時
			{
				out_count++;
			}
		}
		printf("%d\n",score);	//1イニング終了時の得点
		
	}
	return 0;
}

Measured memory_bytes: 596
n,m,r=map(int, input().split())
s=[[10**9]*n for i in range(n)]
t=list(map(int, input().split()))
for i in range(m):
    a,b,c=map(int, input().split())
    s[a-1][b-1]=c
    s[b-1][a-1]=c
 
for k in range(n):
    for i in range(n):
        for j in range(n):
            s[i][j]=min(s[i][j],s[i][k]+s[k][j])
ans=float('inf')
from itertools import permutations
for i in permutations(t):
    an=0
    for j in range(r-1):
        an+=s[i[j]-1][i[j+1]-1]
    ans=min(ans,an)
print(ans)

Measured memory_bytes: 46808
#include <bits/stdc++.h>
using namespace std;
int main(){
  string S,T;cin>>S>>T;
  int i;
  for(i=0;i<S.size();i++){
    if(S.substr(S.size()-i,i)==T.substr(0,i)&&S.substr(0,S.size()-i)==T.substr(i,S.size()-i))break;
  }
  if(i==S.size())cout<<"No"<<endl;
  else cout<<"Yes"<<endl;
}

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

using namespace std;

int main(void)
{
    int n,t;
    int min,b = 0,counter = 0;
    vector<int> a;

    cin>>n>>t;


    for(int i = 0;i < n;i++)
    {
	int temp;
	cin>>temp;

	a.push_back(temp);
    }

    min = a[0];

    for(int i = 1;i < n;i++) {
	if(a[i] > min)
	{
	    if(a[i]-min > b)
	    {
		b = a[i]-min;
		counter = 1;
	    } else if(a[i]-min == b)
		counter++;
	} else {
	    min = min < a[i] ? min : a[i];
	}
    }

    cout<<counter<<endl;

    return 0;
}


Measured memory_bytes: 892
import java.util.*;

public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String str = sc.next();
		String ans = "No";
		for (int i=0; i < str.length(); i++) {
			String st = str.substring(i, i+1);
			if(st.equals("9")) {
				ans = "Yes";
			}
		}
		System.out.print(ans);
	}
}

Measured memory_bytes: 21844
import itertools
h,w,k = map(int,input().split())
s = ["" for _ in range(h)]
for i in range(h):
  si = str(input())
  s[i] = si
lh = [i for i in range(h)]
lw = [j for j in range(w)]
sh = [0 for _ in range(h)]
sw = [0 for _ in range(w)]
for i in range(h):
  for j in range(w):
    if s[i][j] == "#":
      sh[i] += 1
      sw[j] += 1  
g = sum(sh) - k
c = 0
for i in range(h+1):
  for vh in itertools.combinations(lh,i):
    for j in range(w+1):
      for vw in itertools.combinations(lw,j):
        t = 0
        for hx in vh:
          t += sh[hx] 
        for hy in vw:
          t += sw[hy]
        for hx in vh:
          for hy in vw:
            if s[hx][hy] == "#":
              t -= 1
        if t == g:
          c += 1
print(c)

Measured memory_bytes: 68436
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

#define ll long long
#define INF 1<<31-1
#define LNF 9223372036854775807
#define PI 3.14159265358979
#define MIN(x,y) ((x)<(y)?(x):(y))
#define MAX(x,y) ((x)<(y)?(y):(x))
#define FOR(i,a,n) for(i=a;i<n;i++)
#define MOD 1000000007
//#define MOD 998244353
#define NUM 200010
 
void swap(int* a,int* b){int tmp=*a;*a=*b;*b=tmp;}
int abs(int a){if(a<0)return -a;return a;}
int dup(int a,int d){if(a%d==0)return a/d;else return a/d+1;}
int mod(int a,int m){if(a<0)return a%m+m;else return a%m;}

void swapl(ll* a,ll* b){ll tmp=*a;*a=*b;*b=tmp;}
ll absl(ll a){if(a<0)return -a;return a;}
ll dupl(ll a,ll d){if(a%d==0)return a/d;else return a/d+1;}
ll modl(ll a,ll m){if(a<0)return a%m+m;else return a%m;}

ll GCD(ll a,ll b){ll c=1,tmp=MAX(a,b);b=MIN(a,b);a=tmp;while(c!=0){c=a%b;a=b;b=c;}return a;}
ll LCM(ll a,ll b){return a*b/GCD(a,b);}

ll factorial(ll n, ll m) {return n < m ? 1 : n*factorial(n-1, m);}

int upll(const void*a, const void*b){return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;}
int downll(const void*a, const void*b){return*(ll*)a<*(ll*)b?1:*(ll*)a>*(ll*)b?-1:0;}
void sortup(ll*a,int n){qsort(a,n,sizeof(ll),upll);}
void sortdown(ll*a,int n){qsort(a,n,sizeof(ll),downll);}

// ll dp[]

int main(){
  ll x;
  scanf("%lld", &x);
  if(x>= 30){
      printf("Yes\n");
  }else{
      printf("No\n");
  }
  return 0;
}

Measured memory_bytes: 1648
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

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

int main(){string s[100];int n,L;
cin>>n>>L;
REP(i,n)cin>>s[i];
SORT(s,n);
string ans={};
REP(i,n)ans+=s[i];
cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const ll mod=1e9+7;
int dy[]={1,-1,0,0};
int dx[]={0,0,1,-1};


int main(){
    int N;
    cin>>N;
    vector<int> a(N);

    for(int i=0;i<N;i++){
        cin>>a[i];
    }

    vector<int> tops;
    tops.push_back(a[0]);
    for(int i=1;i<N;i++){
        auto iter=lower_bound(tops.rbegin(),tops.rend(),a[i]);
        int comp=tops.rend()-iter;
        if(comp==tops.size()) tops.push_back(a[i]);
        else{
            tops[comp]=a[i];
        }

    }
    cout<<tops.size()<<endl;
/*
    vector<int> test(2);
    test[0]=5; test[1]=3;
    cout<<test.rend()-lower_bound(test.rbegin(),test.rend(),4)<<endl;

*/

    return 0;
}


Measured memory_bytes: 1276
#include<stdio.h>
#include<stdlib.h>
#include<math.h>

typedef long long int int64;

#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define ABS(a) ((a)>(0)?(a):-(a))

#define POS(i,j) ((i)*v+(j))

const int inf=20000000*100+1;

int warshallFloyd(int *d,int v){
  int i,j,k;
  for(k=0;k<v;k++){
    for(i=0;i<v;i++){
      if(d[POS(i,k)]==inf) continue;
      for(j=0;j<v;j++){
        if(d[POS(k,j)]==inf) continue;
        d[POS(i,j)]=MIN(d[POS(i,j)],d[POS(i,k)]+d[POS(k,j)]);
      }
    }
  }
  for(i=0;i<v;i++) if(d[POS(i,i)]<0) return 1;
  return 0;
}

void run(void){
  int v,e;
  scanf("%d%d",&v,&e);
  int *d=(int *)malloc(sizeof(int)*v*v);
  int i,j;
  for(i=0;i<v;i++){
    for(j=0;j<v;j++){
      d[POS(i,j)]=i==j?0:inf;
    }
  }
  for(i=0;i<e;i++){
    int s,t,dd;
    scanf("%d%d%d",&s,&t,&dd);
    d[POS(s,t)]=dd;
  }
  if(warshallFloyd(d,v)){
    printf("NEGATIVE CYCLE\n");
  } else {
    for(i=0;i<v;i++){
      if(d[POS(i,0)]==inf){
        printf("INF");
      } else {
        printf("%d",d[POS(i,0)]);
      }
      for(j=1;j<v;j++){
        if(d[POS(i,j)]==inf){
          printf(" INF");
        } else {
          printf(" %d",d[POS(i,j)]);
        }
      }
      printf("\n");
    }
  }
  free(d);
  return;
}

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



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

namespace atcorder
{
    class Program
    {
        static void Main(string[] args)
        {
            string strArray = Console.ReadLine();

            int start = Int32.Parse(strArray);
 
            while( start <= 100003 )
            {
                if( IsPrime( start ) )
                {
                    Console.WriteLine(start);
                    return;
                }
                start++;
            }
        }

        public static bool IsPrime(int num)
        {
            if (num < 2) return false;
            else if (num == 2) return true;
            else if (num % 2 == 0) return false; // 偶数はあらかじめ除く

            double sqrtNum = Math.Sqrt(num);
            for (int i = 3; i <= sqrtNum; i += 2)
            {
                if (num % i == 0)
                {
                    // 素数ではない
                    return false;
                }
            }

            // 素数である
            return true;
        }
    }
}


Measured memory_bytes: 11092
/*------------------------------------
........Bismillahir Rahmanir Rahim....
..........created by Abdul Aziz.......
------------------------------------*/
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <cstring>
#include <unordered_map>
#include <queue>
#define   mod  998244353
#define   int  long long 
#define   ld   long double
#define   pb   push_back
#define   vi  vector<int> 
#define   dbg(x)  cerr << #x << " = " << x << '\n'
#define   sz(x)  (int)x.size()
#define   all(a) (a.begin(),a.end())
#define   ff   first
#define   ss   second
#define   pii  pair<int,int> 
#define   lcm(a,b) (a*b)/__gcd(a,b) 
using namespace std;

inline void solve(){
    int n,fsum=0,ssum=0,ans=0,sum=0; cin>>n; 
    vi a(n),b(n);
    for (int &i: a) cin>>i, fsum += i; 
    for (int &i: b) cin>>i, ssum += i; 
    if (fsum<ssum) cout << -1 << endl, exit(0);
    priority_queue<int> pq;
    for (int i=0;i<n;i++){
        if (a[i]<b[i]) ans++,sum += (b[i]-a[i]);
        else pq.push(a[i]-b[i]);
    }
    while (sum>0){
        sum -= pq.top();
        pq.pop();
        ans++;
    }
    cout << ans << endl;
}

signed main()
{
    int n=1; // cin>>n;
    while (n--) solve();
    return 0;
}


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

using namespace std;
typedef long long ll;
#define rep(i, n) for(int i=0; i<(int)n; i++)
    
int main(){
    int A, X; cin >> X >> A;
    if(X<A) cout << 0 << endl;
    else cout << 10 << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <limits>
#include <vector>
#include <cstdio>
#include <bits/stdc++.h>
#include <set>
#include <map>
#include <stdio.h>
#include <string.h>
#include <stack>
#include <queue>
#include <deque>
#include <numeric>
#include<bits/stdc++.h>
#include <utility>

#define ALL(obj) (obj).begin(), (obj).end()
#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define RFOR(i,a,b) for(int i = (a); (b) <= i; i--)
#define REP(i,n) for(int i = 0; i < (n); i++)
#define RREP(i,n) for(int i = n; n <= i; i--)
#define ABS(a) ((a < 0) ? ((-1)*(a)) : (a))
#define elif else if
#define MOD 1000000007
#define INF (1<<29)

using namespace std;
using ll = long long;
map <int ,int> mpa,mpb;
typedef pair<ll, ll> P;
priority_queue<P, vector<P>, greater<P>> pque;

int main(){
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  int N;
  cin >> N;
  cout << N*(N+1)/2 << endl;
  return 0;
}

Measured memory_bytes: 256
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, gcd
from itertools import accumulate, permutations, combinations, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7
 
X = INT()
 
a = 100
ans = 0
 
while a < X:
	a = int(1.01*a)
	ans += 1
 
print(ans)

Measured memory_bytes: 10040
#include<stdio.h>

char c;

int main(){
	getchar();
	getchar();
	getchar();
	getchar();
	getchar();
	c=getchar();
  if(c=='1'){puts("TBD"); return 0;}
	c=getchar();
  if(c>'4'){puts("TBD"); return 0;}
  if(c<'4'){puts("Heisei"); return 0;}
	getchar();
	c=getchar();
  if(c<'3'){puts("Heisei"); return 0;}
	c=getchar();
  if(c=='0'){puts("Heisei"); return 0;}
  if(c=='1'){puts("TBD"); return 0;}
}


Measured memory_bytes: 128
import math
import sys
from operator import itemgetter

# N, K = map(int, input().split())
# h = list(map(int, input().split()))
# S = [input() for _ in range(H)]
# X = [[0 for j in range(100)] for i in range(200)]


### input
T, X = map(int, input().split())
print(T/X)

## solve



Measured memory_bytes: 3060
#include<iostream>
using namespace std;
int graph[10][10];
int N, M;
int func(int p, int pass[10]) {
	bool flag = true;
	for (int i = 0; i < N; i++) if (pass[i] == 0)flag = false;
	if (flag)return 1;
	int passed[10];
	for (int i = 0; i < N; i++)passed[i] = pass[i];
	int route = 0;
	for (int i = 0; i < N; i++) {
		if (graph[p][i] == 1 && passed[i] == 0) {
			passed[i] = 1;
			route += func(i, passed);
			passed[i] = 0;
		}
	}
	return route;
}
int main() {
	cin >> N >> M;
	int pass[10];
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < N; j++) {
			graph[i][j] = 0;
		}
	}
	pass[0] = 1;
	for (int i = 1; i < N; i++)pass[i] = 0;
	int a, b;
	for (int i = 0; i < M; i++) {
		cin >> a >> b;
		graph[a - 1][b - 1] = 1;
		graph[b - 1][a - 1] = 1;
	}
	cout << func(0, pass) << endl;
}

Measured memory_bytes: 256
use std::collections::HashSet;
use std::io::Read;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();
    let mut iter = buf.split_whitespace();
    let ab: usize = iter.next().unwrap().parse().unwrap();
    let bc: usize = iter.next().unwrap().parse().unwrap();

    println!("{}", ab * bc / 2);
}


Measured memory_bytes: 4352
import copy

def bubble(A, N):
    for i in range(0, N-1):
        for j in range(N-1, i, -1):
            if A[j][1] < A[j-1][1]:
                A[j], A[j-1] = A[j-1], A[j]
    return A

def selction(A, N):
    for i in range(0, N-1):
        minj = i
        for j in range(i+1, N):
            if A[j][1] < A[minj][1]:
                minj = j
        A[i], A[minj] = A[minj], A[i]
    return A
        
n = int(input())
a = list(map(str, input().split()))

b = copy.copy(a)
c = copy.copy(a)
bubble(b, n)
print(*b)
print("Stable")
selction(c, n)
print(*c)
if c == b:
    print("Stable")
else:
    print("Not stable")


Measured memory_bytes: 6344
#include <stdio.h>
int main () 
{
	int a, b, c;
	scanf("%d %d %d", &a, &b, &c) ;
	if(a==b&&a!=c) {
		printf("Yes\n") ;
	}
	else if(a==c&&a!=b) {
		printf("Yes\n") ;
	}
	else if(b==c&&b!=a) {
		printf("Yes\n") ;
	}	
	else if (a==b==c) {
		printf("No\n") ;
	}
	else {
		printf("No\n") ;
	}
}

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

int main() {
  int n;
  cin >> n;
  int t=n,fn=0;
  
  rep(i,n){
    fn += t%10;
    t /= 10;
  }
  
  if(n%fn==0){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef vector<int> vi;
typedef pair<int,int> ii;
#define inf 1e9
#define F first
#define S second
#define dbg(x) cout<<#x<<" value : "<<x<<"\n";
#define rep(i,j,k) for(int i = (j); i <= (k); i++)
#define rep__(i,j,k) for(int i = (j); i < (k); i++)
#define per(i,j,k) for(int i = (j); i >= (k); i--)
#define per__(i,j,k) for(int i = (j); i > (k); i--)
#define mst(a,b) memset(a,b,sizeof(a))
#define sf(n) scanf("%d",&n)
#define stf(n,m) scanf("%d%d",&n,&m)
#define pf(n) printf("%d\n",n)
#define slf(n) scanf("%lld",&n)
#define plf(n) printf("%lld\n",n)
priority_queue<int,vector<int>,greater<int> > q;
const int N=25;
const int mod=1e9+7;
int n,a[N],b[N],c[N];
string s,f;
int main()
{
	sf(n);
	rep(i,1,n)sf(a[i]);
	rep(i,1,n)sf(b[i]);
	rep(i,1,n-1)sf(c[i]);
	int ans=0;
	a[0]=-2;
	rep(i,1,n){
		ans+=b[a[i]];
		if(a[i]==a[i-1]+1)ans+=c[a[i-1]];
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
hlist = []
wlist = []
 
while(1):
    h, w = map(int, input().split())
    if h == 0 and w == 0:
        break
 
    hlist.append(h)
    wlist.append(w)
 
for h, w in zip(hlist, wlist):
    for i in range(h):
        for j in range(w):
            print("#", end="")
        print()
    print()


Measured memory_bytes: 7004
#!/usr/bin/env python3

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

n = I()
for i in range(10**6+1):
    if (i * 108) // 100 == n:
        print(i)
        quit()
print(":(")

Measured memory_bytes: 66632
using System;

class Program
{
    public static void Main(string[] args) {
        int n = int.Parse(Console.ReadLine());
        int[] p = new int[n];
        for (int i = 0; i < n; i ++) p[i] = int.Parse(Console.ReadLine());
        Array.Sort(p);
        int sum = 0;
        sum += p[n-1]/2;
        for (int i = 0; i < n-1; i ++) sum += p[i];
        Console.WriteLine(sum);
    }
}

Measured memory_bytes: 11092
import java.util.Scanner;
import java.util.Arrays;
public class Main {
    public static void main(String[] args) {
        Scanner sc= new Scanner(System.in);
        int N = sc.nextInt();
        int K = sc.nextInt();
        int[] value = new int [N];
        for(int i = 0; i< N; i++) value[i] = sc.nextInt();
       Arrays.sort(value);
      int ans = 0;
      for(int i = 0; i < K; i++) ans += value[i];
      System.out.println(ans);
    } 
}

Measured memory_bytes: 30100
import sys
input = sys.stdin.readline

def main():
    S = input().replace('\n', '')
    Q = int(input())

    flg = 0
    head = ""
    tail = ""
    for _ in range(Q):
        query = input().split()
        if len(query) == 1:
            head, tail = tail, head
            flg += 1
        else:
            T, F, C = query
            if int(F) == 1:
                head += C
            else:
                tail += C
    if flg % 2:
        print(head[::-1] + S[::-1] + tail)
    else:
        print(head[::-1] + S + tail)
main()

Measured memory_bytes: 10020
using System;

class main
{
    static void Main(string[] args)
    {
        var n = int.Parse(Console.ReadLine());        
        for( int i = 0; i < n; i++ )
        {
            string[] s1 = Console.ReadLine().Split(' ');
            double x1 = double.Parse(s1[0]);
            double y1 = double.Parse(s1[1]);
            double x2 = double.Parse(s1[2]);
            double y2 = double.Parse(s1[3]);
            double x3 = double.Parse(s1[4]);
            double y3 = double.Parse(s1[5]);
            double a = Math.Sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2));
            double b = Math.Sqrt((x2 - x3) * (x2 - x3) + (y2 - y3) * (y2 - y3));
            double c = Math.Sqrt((x3 - x1) * (x3 - x1) + (y3 - y1) * (y3 - y1));
            double r = (a * b * c) / Math.Sqrt((a + b + c) * (-a + b + c) * (a - b + c) * (a + b - c));
            double x = (((x1 * x1 + y1 * y1) * (y2 - y3)) + ((x2 * x2 + y2 * y2) * (y3 - y1)) + ((x3 * x3 + y3 * y3) * (y1 - y2))) / ((x1 * (y2 - y3)) + (x2 * (y3 - y1)) + (x3 * (y1 - y2))) * 0.5;
            double y = (((x1 * x1 + y1 * y1) * (x2 - x3)) + ((x2 * x2 + y2 * y2) * (x3 - x1)) + ((x3 * x3 + y3 * y3) * (x1 - x2))) / ((y1 * (x2 - x3)) + (y2 * (x3 - x1)) + (y3 * (x1 - x2))) * 0.5;
            Console.WriteLine("{0:F3} {1:F3} {2:F3}", x, y, r);
        }
    }
}

Measured memory_bytes: 5740
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define ff first
#define ss second
#define pii pair <int,int>
#define pll pair <ll,ll>
#define testcase() int t; cin>>t; while(t--)
#define forn(i,n) for(int i=0;i<n;i++)
#define forn1(i,n) for(int i=1;i<=n;i++)
#define vll vector <ll>
#define vi vector <int>
#define all(v) v.begin(),v.end()

ll M = 1e9 + 7;
double pi = acos(-1.0);
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
ll powerm(ll x,ll y){ ll res=1; while(y){ if(y&1) res=(res*x)%M; y=y>>1; x=(x*x)%M;} return res%M; }
ll power(ll x,ll y){ ll res=1; while(y){ if(y&1) res=(res*x); y=y>>1; x=(x*x);} return res; }
ll gcd(ll a,ll b){if(b>a)return gcd(b,a); if(b==0)return a; return gcd(b,a%b);}

int main() {
	
	//ifstream cin("input.txt");
	//ofstream cout("output.txt");
	ios_base::sync_with_stdio(false); 
    cin.tie(NULL); 
	
	int n; cin>>n;
	string s; cin>>s;
	int c = 0;
	forn(i,n)
	{
		if(s[i]=='R') c++;
	}
	int g = c;
	forn(i,g)
	{
		if(s[i]=='R') c--;
	}
	cout<<c;

	return 0;
}


Measured memory_bytes: 3748
#include <iostream>
#include <stdio.h>
using namespace std;

int main(void){
  int n,x;
  int cnt=0;
  while(1){
    cin >> n >> x;
    if(n==0&&x==0) break;
    for (int i=1;i<=n;i++) {
      for (int j=1;j<=n;j++) {
        for (int k=1;k<=n;k++) {
          if ((i!=j)&&(j!=k)&&(i!=k)&&((i+j+k)==x)) {
            cnt++;
          }
        }
      }
    }
    cout << cnt/6 << endl;
    cnt = 0;
  }
}


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

#define inf 1.1e9
#define LINF 1.1e18
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define BIT(x,n) bitset<n>(x)
#define PI 3.14159265358979323846

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

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

template< typename T >
struct FordFulkerson {

	struct FlowEdge {
		int to;
		T cap,rev;
		FlowEdge() {}
		FlowEdge(int to,T cap,T rev):to(to),cap(cap),rev(rev) {}
	};

	vector< vector<FlowEdge> > G;
	vector<int> used;

	FordFulkerson() {}
	FordFulkerson(int n) {
		G.resize(n);
		used.resize(n);
	}

	void add_edge(int from,int to,T cap,int type) {
		G[from].emplace_back(to,cap,(int)G[to].size());
		if(type==0) G[to].emplace_back(from,0,(int)G[from].size()-1);
		else G[to].emplace_back(from,cap,(int)G[from].size()-1);
	}

	T dfs(int v,const int t,T flow) {
		if(v==t) return flow;
		used[v]=1;
		for(auto &e:G[v]) {
				if(!used[e.to]&&e.cap>0) {
				T d=dfs(e.to,t,min(flow,e.cap));
				if(d>0) {
					e.cap-=d;
					G[e.to][e.rev].cap+=d;
					return d;
				}
			}
		}
		return 0;
	}

	T max_flow(int s,int t,T lim) {
		T flow=0;
		while(true) {
			fill(ALL(used),false);
			T d=dfs(s,t,inf);
			if(d==0) return flow;
			flow+=d;
		}
		return flow;
	}

	T max_flow(int s,int t) {
		return max_flow(s,t,inf);
	}
};

int h,w;
string fld;
set<P> st;
P S,T;

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

	cin>>h>>w;
	FordFulkerson<ll> F(h+w+2);
	REP(i,h) {
		cin>>fld;
		REP(j,w) {
			if(fld[j]=='S') {
				F.add_edge(h+w,i+w,inf,0);
				F.add_edge(h+w,j,inf,0);
				S=P(i,j);
			}
			else if(fld[j]=='T') {
				F.add_edge(i+w,h+w+1,inf,0);
				F.add_edge(j,h+w+1,inf,0);
				T=P(i,j);
			}
			else if(fld[j]=='o') {
				st.insert(P(i,j));
			}
		}
	}
	if(S.fi==T.fi||S.se==T.se) {
		cout<<-1<<endl;
		return 0;
	}
	for(auto m:st) F.add_edge(m.fi+w,m.se,1,1);
	cout<<F.max_flow(h+w,h+w+1)<<endl;

	return 0;
}


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

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

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

int main(){
	int r;
	cin>>r;
	cout<<3*r*r<<endl;

	return 0;
}


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

int main(){
	double w,h,x,y;
	cin>>w>>h>>x>>y;
	printf("%.6f ",w*h/2);
  	if(w/2==x && h/2==y) puts("1");
  	else puts("0");
}

Measured memory_bytes: 256
import itertools

N = int(input())
L_list = list(map(int, input().split()))

list_comb = list(itertools.combinations(L_list, 3))

result_sum = 0
for i in list_comb:
    if i[0] == i[1] or i[1] == i[2] or i[2] == i[0]:
        continue
    if i[0]+i[1]>i[2] and i[1]+i[2]>i[0] and i[2]+i[0]>i[1]:
        result_sum += 1
print(result_sum)

Measured memory_bytes: 90456
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define For(i,n,k) for(ll i=(n);i<(k);i++)
ll n;
double ans;
const ll MOD = 1000000007;
void Main(){    
    cin>>n;
    if(n%2==0){
        cout<<"0.500000000"<<endl;
    }
    else{
        double odd=1+n/2;
        cout<<setprecision(10)<<odd/n<<endl;
    }
}
int main(){
    Main();
    return 0;
}


Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.UncheckedIOException;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author mikit
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        LightScanner in = new LightScanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        BAtCoDeerPaintingBallsWithAtCoDeer solver = new BAtCoDeerPaintingBallsWithAtCoDeer();
        solver.solve(1, in, out);
        out.close();
    }

    static class BAtCoDeerPaintingBallsWithAtCoDeer {
        public void solve(int testNumber, LightScanner in, PrintWriter out) {
            int n = in.ints(), k = in.ints();
            int ans = k;
            for (int i = 1; i < n; i++) {
                ans *= (k - 1);
            }
            out.println(ans);
        }

    }

    static class LightScanner {
        private BufferedReader reader = null;
        private StringTokenizer tokenizer = null;

        public LightScanner(InputStream in) {
            reader = new BufferedReader(new InputStreamReader(in));
        }

        public String string() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new UncheckedIOException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int ints() {
            return Integer.parseInt(string());
        }

    }
}



Measured memory_bytes: 21460
#include <cmath>
#include <cstdio>
#include <iostream>
#include <vector>

#define EPS (1e-10)
#define equals(a,b) (fabs((a)-(b)) < EPS)

using namespace std;

class Point {
  public:
  double x, y;

  Point(double x = 0, double y = 0) : x(x), y(y) {}

  Point operator + (Point p) { return Point(x + p.x, y + p.y); }
  Point operator - (Point p) { return Point(x - p.x, y - p.y); }
  Point operator * (double a) { return Point(a * x, a * y); }
  Point operator / (double a) { return Point(x / a, y / a); }

  double abs() {return sqrt(norm()); }
  double norm() { return x * x + y * y; }

  bool operator < (const Point &p) const{
    return x != p.x ? x < p.x : y < p.y;
  }

  bool operator == (const Point &p) const{
    return fabs(x - p.x) < EPS && fabs(y - p.y) < EPS;
  }

};

typedef Point Vector;

typedef struct Segment{
  Point p1, p2;
}Segment;
 
typedef Segment Line;


double dot(Vector a, Vector b){
  return a.x * b.x + a.y * b.y;
}

double cross(Vector a, Vector b){
  return a.x * b.y - a.y * b.x;
}

bool isOrthogonal(Vector a, Vector b){
  return equals(dot(a, b), 0.0);
}
bool isOrthogonal(Point a1, Point a2, Point b1, Point b2){
  return isOrthogonal(a1 - a2, b1 - b2);
}
bool isOrthogonal(Segment s1, Segment s2){
  return equals(dot(s1.p2 - s1.p1, s2.p2 - s2.p1), 0.0);
}
 
bool isParallel(Vector a, Vector b){
  return equals(cross(a, b), 0.0);
}
bool isParallel(Point a1, Point a2, Point b1, Point b2){
  return isParallel(a1 - a2, b1 - b2);
}
bool isParallel(Segment s1, Segment s2){
  return equals(cross(s1.p2 - s1.p1, s2.p2 - s2.p1), 0.0);
}


int main() {
  int q;
  scanf(" %d", &q);
  for(int i=0; i < q; ++i) {
    Segment a ,b;
    scanf(" %lf %lf %lf %lf %lf %lf %lf %lf", &a.p1.x, &a.p1.y, &a.p2.x, &a.p2.y, &b.p1.x, &b.p1.y, &b.p2.x, &b.p2.y );

    if(isParallel(a,b)) {
      printf("2\n");
    } else if(isOrthogonal(a,b)) {
      printf("1\n");
    } else {
      printf("0\n");
    }
  }
}


Measured memory_bytes: 3248
const int tt = 10000;

#include<iostream>
#include<string>
#include<sstream>
using namespace std;

string toStr(int n);
string intToString(int n);

int main() {
  int a, b, c, d, e, f;
  
  while(cin >> a >> b >> c >> d >> e >> f) {
    c = c * tt;
    f = f * tt;

    int det = a * e - b * d;

    int x = ( e * c - b * f) / det;
    int y = (-d * c + a * f) / det;
    cout << toStr(x) << " " << toStr(y) << endl;
  }
}

string toStr(int n) {
  string pm, val;
  
  if (n < 0) {
    pm = "-";
    n = -n;
  } else {
    pm = "";
  }

  int ipart = n / tt;
  int fpart = (n - ipart * tt) + tt + 5;

  val = pm + intToString(ipart) + "." + intToString(fpart).substr(1, 3);
  return val;
}

string intToString(int n) {
  stringstream ss;
  ss << n;
  return ss.str();
}

Measured memory_bytes: 1224
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define REP(i, a, b) for (int i = a; i < b; i++)
typedef long long ll;
using namespace std;

int main() {
  int n;
  cin >> n;
  string s;
  cin >> s;
  int count = 0;
  rep(i, n - 2) {
    if (s[i] == 'A' && s[i + 1] == 'B' && s[i + 2] == 'C') count++;
  }
  cout << count << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
#include <list>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <tuple>
#include <deque>

using namespace std;

/*
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef vector<pii> vpii;
*/

typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<long long, long long> pll;
typedef vector<pll> vpll;

typedef long double ld;
typedef vector<ld> vld;

typedef vector<bool> vb;

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define reps(i, n) for (ll i = 1; i <= (n); i++)
#define rrep(i, n) for (ll i = (n) - 1; i >= 0; i--)
#define rreps(i, n) for (ll i = (n); i >= 1; i--)
#define all(v) (v).begin(), (v).end()

template <class T> void chmin(T& a, T b) { a = min(a, b);}
template <class T> void chmax(T& a, T b) { a = max(a, b);}

constexpr int INF = 1 << 30;
constexpr ll INFL = 1LL << 60;
constexpr ll MOD = 1000000007;
constexpr ld EPS = 1e-12;
constexpr ld PI = 3.14159265358979323846;

void solve() {
    ll h, w;
    cin >> h >> w;
    vector<string> a;
    for(ll i = 0; i < h; i++) {
        string s;
        cin >> s;
        bool remove = true;
        for(ll j = 0; j < w; j++) if(s[j] == '#') remove = false;
        if(!remove) a.push_back(s);
    }
    vll v;
    for(ll i = 0; i < w; i++) {
        bool remove = true;
        for(ll j = 0; j < a.size(); j++) if(a[j][i] == '#') remove = false;
        if(remove) v.push_back(i);
    }
    for(ll i = 0; i < a.size(); i++) {
        for(ll j = 0; j < w; j++) {
            if(!binary_search(v.begin(), v.end(), j)) cout << a[i][j];
        }
        cout << endl;
    }
    return;
}

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

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


#define ll long long
#define MOD 1000000007
#define PI 3.1415


int main(){
    string s;
    cin>>s;
    
    if(s.at(1)=='S'){
        if(s.at(0)=='R'||s.at(2)=='R'){
            cout<<1<<endl;
        }else{
            cout<<0<<endl;
        }
    }else{
        int a=1;
        if(s.at(0)=='R')a++;
        if(s.at(2)=='R')a++;
        cout<<a<<endl;
    }
}



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

int main(){
  int n=0,k=0;
  cin>>n>>k;
  int arr[n+1]={0};
  cin>>arr[1];
  for(int i=2;i<=n;i++){
    cin>>arr[i];
  }
  long long int dp[n+1]={0};
  arr[0]=1e5;
  for(int i=2;i<=n;i++){
    dp[i]=dp[i-1]+abs(arr[i-1]-arr[i]);
    for(int j=2;j<=k && j<=i;j++){
      if(dp[i]>dp[i-j]+abs(arr[i-j]-arr[i])) dp[i]=dp[i-j]+abs(arr[i-j]-arr[i]);
    }
    
  }
  cout<<dp[n]<<endl;
  cin>>n;
  return 0;
}


Measured memory_bytes: 1408
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int MAXN = 2e5 + 7;
int n, pre[MAXN], nxt[MAXN];
ll a[MAXN], b[MAXN], low[MAXN], up[MAXN], num[MAXN], cnt1[MAXN], cnt2[MAXN];
void deal(ll* a, ll* cnt)
{
    for (int i = 1; i <= n; i++)
    {
        low[i] = up[i] = a[i]; num[i] = 1;
        pre[i] = i - 1;
        nxt[i - 1] = i;
        cnt[i] = cnt[i - 1];
        while (pre[i] && up[i] > low[pre[i]])
        {
            while (up[i] > low[pre[i]]) low[pre[i]] *= 4, up[pre[i]] *= 4, cnt[i] += num[pre[i]] * 2;
            num[i] += num[pre[i]]; up[i] = up[pre[i]];
            pre[i] = pre[pre[i]];
            nxt[pre[i]] = i;
        }
    }
    // for (int i = 0; i <= n; i++) printf("%lld%c", cnt[i], " \n"[i == n]);
}
int main()
{
    scanf("%d", &n);
    for (int i = 1; i <= n; i++) scanf("%lld", &a[i]), b[i] = a[i] * 2;
    deal(b, cnt1);
    for (int i = 1; i <= n / 2; i++) swap(a[i], a[n + 1 - i]);
    deal(a, cnt2);
    ll ans = 1e18;
    for (int i = 0; i <= n; i++)
        ans = min(ans, i + cnt1[i] + cnt2[n - i]);
    printf("%lld\n", ans);
    return 0;
}

Measured memory_bytes: 12800
import java.util.*;

public class Main{
   Scanner in = new Scanner(System.in);

   void solve(){
        int n = in.nextInt(), k = in.nextInt();
        int[] a = new int[n];
        for(int i = 0; i < n; i++){
            a[i] = in.nextInt();
        }
        Arrays.sort(a);
        ArrayList<Integer> list = new ArrayList<>();
        int count  = 1;
        for(int i = 1; i < n; i++){
            if(a[i] != a[i - 1]){
                list.add(count);
                count = 1;
            }else{
                count++;
            }
        }
        list.add(count);
        Collections.sort(list);
        int size = list.size();
        int ans = 0, idx = 0;
        while(size > k){
            if(idx >= list.size()) break;
            ans += list.get(idx);
            size--;
            idx++;
        }
        System.out.println(ans);
   }

   public static void main(String[] args){
       new Main().solve();    
   }
}

Measured memory_bytes: 81168