akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;
public class Main{
    public static void main(String[]args){
	int i,n;
	Scanner sca = new Scanner(System.in);
	n=sca.nextInt();
	for(i=0;i<n;i++){
	    System.out.println(solveLCS(sca.next(),sca.next()));
	}
    }
    public static int solveLCS(String a,String b){
	int i,j;
	String[]x=a.split("");
	String[]y=b.split("");
	int[][]cont=new int[x.length+1][y.length+1];
	for(i=0;i<=x.length;i++)cont[i][0]=0;
	for(i=0;i<=y.length;i++)cont[0][i]=0;
	for(i=1;i<=x.length;i++){
	    for(j=1;j<=y.length;j++){
		if(x[i-1].equals(y[j-1])){
		    cont[i][j]=cont[i-1][j-1]+1;
		}else if(cont[i][j-1]>cont[i-1][j]){
			cont[i][j]=cont[i][j-1];
	        }else{
		    cont[i][j]=cont[i-1][j];
		    }
		
		}
	}
	    return cont[x.length][y.length];
    }
}



Measured memory_bytes: 64148
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <utility>
using namespace std;

typedef long long ll;
ll MOD = 1e9+7;

int number[10]={-1,2,5,5,4,5,6,3,7,6};
string dp[10100];//i本のマッチ棒で作ることのできる最大の数の組

int main()
{
	int n,m;
	char a[9];
	cin>>n>>m;
	for(int i=0;i<m;i++)
		cin>>a[i];
	//sort(a,a+m, greater<>());
	fill(dp,dp+10100,"0");
	//初期値は1ケタの整数
	for(int i=0;i<m;i++)
		dp[number[a[i]-'0']]=max(dp[number[a[i]-'0']], string(1, a[i]));
	//ここからdp
    
    for(int i=1;i<10001;i++)
	{
        if(dp[i]!="0")
		{
			for(int j=0;j<m;j++)
			{
				int targetindex=i+number[a[j]-'0'];
				string temp=dp[i]+a[j];
				if(temp.size()>dp[targetindex].size())
					dp[targetindex]=temp;
				else if(temp.size()==dp[targetindex].size() && temp>dp[targetindex])
					dp[targetindex]=temp;
			}
		}
	}
	cout<<dp[n]<<endl;
	return 0;
}


Measured memory_bytes: 46208
#include <bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPR(i, n) for (int i = n - 1; i >= 0; i--)
#define INF 1145141919
#define LLINF 1145148101919
#define PI 3.14159265359
int dy[] = {0, 0, 1, -1};
int dx[] = {1, -1, 0, 0};
int ny, nx;
typedef long long ll;
using namespace std;

ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }

ll lcm(ll m, ll n)
{
    if ((0 == m) || (0 == n))
        return 0;
    return ((m / gcd(m, n)) * n);
}

ll llpow(ll x, ll y)
{
    ll ans = 1;
    REP(i, y)
    ans *= x;
    return ans;
}

int ctoi(char c)
{
    if (c >= '0' && c <= '9')
    {
        return c - '0';
    }
    return 0;
}

class UnionFind
{
public:
    vector<ll> par; // 各元の親を表す配列
    vector<ll> siz; // 素集合のサイズを表す配列(1 で初期化)

    // Constructor
    UnionFind(ll sz_) : par(sz_), siz(sz_, 1LL)
    {
        for (ll i = 0; i < sz_; ++i)
            par[i] = i; // 初期では親は自分自身
    }
    void init(ll sz_)
    {
        siz.assign(sz_, 1LL); // assign: 再代入
        par.resize(sz_);      // resize: 再確保
        for (ll i = 0; i < sz_; ++i)
            par[i] = i; // 初期では親は自分自身
    }

    // Member Function
    // Find
    ll root(ll x)
    { // 根の検索
        while (par[x] != x)
        {
            x = par[x] = par[par[x]]; // x の親の親を x の親とする
        }
        return x;
    }

    // Union(Unite, Merge)
    bool merge(ll x, ll y)
    {
        x = root(x);
        y = root(y);
        if (x == y)
            return false;
        // merge technique（データ構造をマージするテク．小を大にくっつける）
        if (siz[x] < siz[y])
            swap(x, y);
        siz[x] += siz[y];
        par[y] = x;
        return true;
    }

    bool issame(ll x, ll y)
    { // 連結判定
        return root(x) == root(y);
    }

    ll size(ll x)
    { // 素集合のサイズ
        return siz[root(x)];
    }
};

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

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

template <typename Container>
bool exist_in(const Container &c, const typename Container::value_type &v)
{
    return (c.end() != std::find(c.begin(), c.end(), v));
}

vector<ll> decom;

void decompositPrime(ll n)
{
    ll a = 2;
    while (n >= a * a)
    {
        if (n % a == 0)
        {
            decom.push_back(a);
            n /= a;
        }
        else
        {
            a++;
        }
    }
    decom.push_back(n);
}

int ctoi_alpha(char c)
{
    if (c >= 'a' && c <= 'z')
    {
        return c - 'a';
    }
    return 0;
}

//std::cout << std::defaultfloat << std::setprecision(10);
////////////////////////////////////////
int main()
{
    ll S; cin >> S;
    int width, height;
    const int res = 1000000000;

    width = (res - S % res) % res;
    height = (S + width) / res;

    cout << "0 0 1000000000 1 " << width << " " << height << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
int main(){
  std::vector<int> v(3);
  rep(i,3)std::cin >> v[i];

  int ans=0;
  while (!((v[0]==v[1]) && (v[1]==v[2]) )) {

    sort(v.begin(),v.end());
    // std::cout << v[0] << ' '<<v[1]<<' ' <<v[2]<<'\n';
    if(v[0]+1<= v[2] && v[1]+1<=v[2]){
      v[0]++;
      v[1]++;
    }
    else if(v[0]+2<=v[2])v[0]+=2;
    else {
      ans+=2;
      break;
    }
    ans++;
  }
  std::cout << ans << '\n';
  return 0;
}


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

fn read<T: std::str::FromStr>() -> T {
    let stdin = std::io::stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

type Graph = Vec<Vec<usize>>;

fn bfs(g: &Graph, s: usize) -> (Vec<Option<usize>>, Vec<Option<usize>>) {
    let n = g.len();
    let mut dist = vec![None; n];
    let mut prev = vec![None; n];
    let mut pool = VecDeque::new();

    dist[s] = Some(0);
    pool.push_back(s);

    while let Some(v) = pool.pop_front() {
        for &w in g[v].iter() {
            if dist[w].is_some() {
                continue;
            }
            dist[w] = dist[v].map(|x| x + 1);
            prev[w] = Some(v);
            pool.push_back(w);
        }
    }
    (dist, prev)
}

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

    let mut g = vec![vec![]; n];
    for _ in 0..n {
        let u: usize = read();
        let k: usize = read();
        for _ in 0..k {
            let v: usize = read();
            g[u - 1].push(v - 1);
        }
    }

    let (dist, _) = bfs(&g, 0);

    for (v, &d) in dist.iter().enumerate() {
        if let Some(d) = d {
            println!("{} {}", v + 1, d);
        } else {
            println!("{} {}", v + 1, -1);
        }
    }
}



Measured memory_bytes: 5028
N = int(input())
A = list(map(int,input().split()))
# print(A)
RGB = [1,0,0]
M = 1000000007

c = 3

f = False
if A[0] != 0:
    f = True

for i in range(1,N):
    try:
        cnt = RGB.count(A[i])
        idx = RGB.index(A[i])
    except:
        f = True
        break
    c = (c * cnt)%M
    RGB[idx] += 1
    # print(RGB)
if f:
    print(0)
else:
    print(c)

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

typedef long long ll;
typedef struct pair<int,int> P;
int p[1001]={};
int x[1001]={};
int y[1001]={};

vector<int> v[1001];


int main() {
	int n;
	cin>>n;
	bool flg=false;
	if(n%10==9)flg=true;
	if(n/10==9)flg=true;
	if(flg){
		cout<<"Yes"<<endl;
	}else{
		cout<<"No"<<endl;
	}
	return 0;
}


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

int main(){
  int V,E;
  cin>>V>>E;
  int dp[100100]={};
  
  //DAG　入力
  int t,s; 
  vector<vector<int>> G(V); 

  //ノードの入力次数を記録するテーブル
  int table[100010]={};

  for(int i=0;i<E;i++){
    cin>>s>>t;
    s--;
    t--;   
    G[s].push_back(t);
    table[t]++; 
  }
  
  //初期の入力のない辺をキューに挿入
  queue<int>Q;
  for(int i=0;i<V;i++){
    if(table[i]==0){
      Q.push(i);
    }
  }

  while(Q.size() != 0){
    int temp=Q.front();
    Q.pop();
    for(int i=0; i<G[temp].size(); i++){
      table[G[temp][i]]--;
      if(table[G[temp][i]]==0){
        Q.push(G[temp][i]);
        dp[G[temp][i]]=max(dp[G[temp][i]],dp[temp]+1);
      }
    }
  }
  int ans=0;
  for(int i=0;i<V;i++){
    ans=max(ans,dp[i]);
  }
  cout<<ans<<endl;
    
  return 0;
}


Measured memory_bytes: 9584
a, b = list(map(int, input().split()))
if a % 2 == 0:
    c = [int(a * 12.5), int((a + 1) * 12.5)]
else:
    c = [int(a * 12.5) + 1, int((a + 1) * 12.5) - 1]
d = [b * 10, b * 10 + 9]
if c[1] < d[0] or d[1] < c[0]:
    print(-1)
else:
    print(max(c[0], d[0]))


Measured memory_bytes: 38384
import heapq  # heapqライブラリのimoprt
N = int(input())
V =list(map(int,input().split()))
heapq.heapify(V)  # リストを優先度付きキューへ、忘れない

for i in range(N-1):
 min1 = heapq.heappop(V)  # 最小値の取り出し
 min2 = heapq.heappop(V)  # 最小値の取り出し
 num = (min1+min2)/2
 heapq.heappush(V,num)  # 要素の挿入

ans = heapq.heappop(V)
print(ans)

Measured memory_bytes: 3060
//Code by Mukul Totla
#include<bits/stdc++.h>
using namespace std;
#define ll long long
void sublime(){ 
      #ifndef ONLINE_JUDGE 
    freopen ("input.txt", "r", stdin);
    freopen ("output.txt", "w", stdout);
    #endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
      }
    
int main()
{   
   //sublime();
   ll n,x,t;
   ll i;
   string str;
   cin>>str;
   ll ans=0;
   for(i=0; i<str.length(); i++)
    ans+=(int)(str[i]-'0');
   if(ans%9==0)
    cout<<"Yes";
 else
    cout<<"No";
    return 0;
}

Measured memory_bytes: 3716
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  vector<string> blue(N);
  for (int i = 0; i < N; i++) {
    cin >> blue.at(i);
  }
  
  int M;
  cin >> M;
  vector<string> red(M);
  for (int i = 0; i < M; i++) {
    cin >> red.at(i);
  }
  int X = 0;
  
  for (int i = 0; i < N; i++) {
    int count = 1;
    for (int h = i+1; h < N; h++) {
      if (blue.at(i) == blue.at(h)) {
        count++;
      }
    }
    for (int j = 0; j < M; j++) {
      if (blue.at(i) == red.at(j)) {
        count--;
      }
    }
    if (count > X) {
      X = count;
    }
  }
  cout << X << endl;
}
      
    
  
  

Measured memory_bytes: 256
// Problem : D - Anything Goes to Zero
// Contest : AtCoder - AIsing Programming Contest 2020
// URL : https://atcoder.jp/contests/aising2020/tasks/aising2020_d
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
using namespace std;
#define int long long
#define io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define pb push_back
#define all(x) begin(x),end(x)
#define setbits(x)  __builtin_popcount(x)
int mod = 1e9+7;
int inf = 4e18;
const int N = 5e5+5;
int pwrTwo[N];
int getMod(string str, int n, int k) 
{ 

	// pwrTwo[i] will store ((2^i) % k) 
	int pwrTwo[n]; 
	pwrTwo[0] = 1 % k; 
	for (int i = 1; i < n; i++) 
	{ 
		pwrTwo[i] = pwrTwo[i - 1] * (2 % k); 
		pwrTwo[i] %= k; 
	} 

	// To store the result 
	int res = 0; 
	int i = 0, j = n - 1; 
	while (i < n) 
	{ 

		// If current bit is 1 
		if (str[j] == '1') 
		{ 

			// Add the current power of 2 
			res += (pwrTwo[i]); 
			res %= k; 
		} 
		i++; 
		j--; 
	} 
	return res; 
}
int help(int n)
{
	int ct = 0;
	while(n!=0)
	{
		int xxx = setbits(n);
		n = n%xxx;
		++ct;
	}
	return ct;
}		
signed main()
{
    io
    int tt = 1;
    //cin>>tt;
    while(tt--)
    {
		int n;
		cin>>n;
		string s;
		cin>>s;
		int ct  = 0;
		for(int i=0;i<n;++i)
		{
			if(s[i]=='1')
			++ct;
		}
		int pwrmore[n],pwrless[n];
		pwrmore[0] = 1%(ct+1);
		if(ct!=1)
		pwrless[0] = 1%(ct-1);
		for(int i=1;i<n;++i)
		{
			pwrmore[i] = pwrmore[i-1]*(2%(ct+1));
			pwrmore[i]%=(ct+1);
		}
		if(ct!=1)
		for(int i=1;i<n;++i)
		{
			pwrless[i] = pwrless[i-1]*(2%(ct-1));
			pwrless[i]%=(ct-1);
		}
		int more = getMod(s,n,ct+1);
		int less = 0;
		if(ct!=1)
		 less = getMod(s,n,ct-1);
		//cout<<more<<" "<<less<<"\n";
		for(int i=0;i<n;++i)
		{
			if(s[i]=='1')
			{
				if(ct==1)
				{
					cout<<0<<"\n";
					continue;
				}
				else
				{
					int xxx = (less+ct-1-pwrless[n-1-i])%(ct-1);
					cout<<help(xxx)+1<<"\n";
				}	
			}
			else // '0'
			{
				int xxx = (more+pwrmore[n-1-i])%(ct+1);
				cout<<help(xxx)+1<<"\n";
			}
		}
    }
    return 0;
}


Measured memory_bytes: 8528
#include<iostream>
#include<algorithm>
#include<cstring>
#include<string>
using namespace std;
int execute(int i, int a[])
{
	return a[i];
}
int main()
{
	int n;
	int a[100000];
	int b;
	int i;
	int count=0;
	int count2 = 1;
	int t;
	cin >> n;

	for (i = 0; i < n; i++)
	{
		cin >> a[i];
		if (a[i] == 2)
		{
			count++;
		}
	}

	if (count == 0)
	{
		cout << "-1";
		return 0;
	}

	t = execute(0,a);

	//cout << t << "값은이렇다\n" << endl;

	while (t != 2)
	{
		
		t = execute(t-1, a);
		count2++; 

		if (t == 2)
		{
			break;
		}
		if (count2 > n)
		{
			break;
		}

	}
	if (t == 2)
	{
		cout << count2;
	}
	else if (count2 > n)
	{
		cout << "-1";
	}


	return 0;
}



Measured memory_bytes: 640
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
#include <string>
#include <cmath>
#include <queue>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define INF 1<<30

int main() {
  string color[] = {"black", "blue", "lime", "aqua", "red", "fuchsia", "yellow", "white"};
  string s;
  while(cin >> s, s!="0") {
    int rgb[3];
    REP(i,3)
      sscanf(s.substr(i*2+1,2).c_str(), "%x", rgb+i);
    int mi = INF;
    int ans;
    REP(i,8) {
      int hoge = 0;
      REP(j,3) {
        if (i<<j & 4)
          hoge += pow(255 - rgb[j], 2);
        else
          hoge += pow(rgb[j], 2);
      }
      if (hoge < mi) {
        mi = hoge;
        ans = i;
      }
    }
    cout << color[ans] << endl;
  }
}

Measured memory_bytes: 0
#include <iostream>


using namespace std;

int main() {
  long long n,b,r,s,cat,rest;
  cin>>n>>b>>r;
  s=r+b;
  cat=n/s;
  rest=n%s;
  if(rest<b)
  cout<<b*cat+rest;
  else
   cout<<b*cat+b;
    return 0;
}

Measured memory_bytes: 384
#include <iostream>

using namespace std;
#include <string>
typedef long long int ll;

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

  int H[N];
  int h_=0;

  int max_ = 0;
  int time=0;
  int now_h;
  cin >> now_h;

  for (size_t i = 1; i < N; i++) {
    cin >> h_;
    if(h_<=now_h){
      time += 1;
      now_h=h_;
    }else{
      max_ = max(time,max_);
      now_h = h_;
      time=0;
      now_h=h_;
    }
  }

  max_ = max(time,max_);

  cout << max_;

  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		while(true){
			int H = sc.nextInt();
			int W = sc.nextInt();
			if(H == 0 && W == 0) break;
			
		for(int i=0; i < H; i++){
			for(int j=0; j < W; j++){
				System.out.print("#");
			}
			System.out.println("");
			}
		System.out.println("");
		}
		sc.close();
	}
}


Measured memory_bytes: 32464
// ABC178E.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//

#include <iostream>
#include <vector>
#include <algorithm>
#define rep(i,n) for(int i=0;i<(n);++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
int main()
{
    int n;
    cin >> n;
    vector<int>a(n), b(n);

    rep(i, n) {
        int x, y;
        cin >> x>> y;
        a[i] = x + y;
        b[i] = x - y;
    }
    sort(a.rbegin(), a.rend());
    sort(b.rbegin(), b.rend());
    
    ll ans = max(a.at(0) - a.at(n-1), b.at(0) - b.at(n-1));

    cout << ans << endl;
}


Measured memory_bytes: 4440
//Himanshu Shukla
#pragma GCC optimize("O2")
#include <bits/stdc++.h>
using namespace std;
#define FASTIO ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0)
//#define file_input
//#define multitest
//#define measure_time
#define ll long long
#define v32 vector<int>
#define v64 vector<ll>
#define s32 set<int>
#define s64 set<ll>
#define graph vector<v32>
#define p32 pair<int, int>
#define p64 pair<ll, ll>
#define sz(v) (ll)(v).size()
#define fi first
#define se second
#define ln '\n'
#define debug(x) cerr << (#x) << ": " << (x) << ln
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
inline ll add(ll a, ll b, ll m) { return (((a % m + b % m) % m + m) % m); }
inline ll mul(ll a, ll b, ll m) { return (((a % m * b % m) % m + m) % m); }
const double EPS = 1e-6;
const ll MOD = 1e9 + 7;
template <typename T, typename U>
ostream &operator<<(ostream &out, const pair<T, U> &p)
{
	out << '[' << p.fi << ", " << p.se << ']';
	return out;
}
template <template <typename, typename...> class ContainerType, typename ValueType, typename... Args>
void print_container(const ContainerType<ValueType, Args...> &c)
{
	cout << "{ ";
	for (const auto &v : c)
		cout << v << ' ';
	cout << '}' << ln;
}

void solve()
{
	int n;
	cin >> n;
	v64 arr(n, 0), cnt(n + 1, 0);
	ll sum = 0;
	for (int i = 0; i < n; i++)
	{
		cin >> arr[i];
		cnt[arr[i]]++;
	}
	for (int i = 1; i < n + 1; i++)
		sum += (cnt[i] * (cnt[i] - 1) / 2);
	for (int i = 0; i < n; i++)
	{
		ll ans = sum - (cnt[arr[i]] * (cnt[arr[i]] - 1) / 2);
		ll temp = cnt[arr[i]] - 1;
		ans += (temp * (temp - 1) / 2);
		cout << ans << ln;
	}
	return;
}

int main()
{
	FASTIO;
#ifdef file_input
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	clock_t start, stop;
	int t = 1;
#ifdef multitest
	cin >> t;
#endif
#ifdef measure_time
	start = clock();
#endif
	for (int tc = 1; tc < t + 1; tc++)
		solve();
#ifdef measure_time
	stop = clock();
	cerr << "Time :" << fixed << setprecision(5) << double(stop - start) / double(CLOCKS_PER_SEC) << "s" << ln;
#endif
	return 0;
}


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

#define itn int
#define vi vector<int>
#define pb push_back
#define srt sort(v.begin(), v.end())
#define retunr return

//int infiint = std::numeric_limits<int>::max();
//float infiflt = std::numeric_limits<float>::infinity();


int main() {
    std::ios::sync_with_stdio(false);
    cin.tie(0);
    //freopen("input.txt", "rt", stdin);

    int n,r;
    cin >> n >> r;
    if(n>=10)
    	cout << r;
    else cout << r+100*(10-n);


    return 0;
}


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

int d[100002][20];

int power2(int n){
    int res = 1;
    for(int i = 0; i < n; i++) res *= 2;
    return res;
}

int main()
{
    int n;
    cin >> n;
    int x[100002];
    for(int i = 0; i < n; i++) cin >> x[i];
    int l;
    cin >> l;
    for(int i = 0; i < n; i++){
        d[i][0] = (upper_bound(x, x + n, x[i] + l) - x) - 1;
    }
    for(int j = 1; j < 20; j++){
        for(int i = 0; i < n; i++){
            d[i][j] = d[d[i][j - 1]][j - 1];
        }
    }
    int q;
    cin >> q;
    for(int i = 0; i < q; i++){
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        if(a > b) swap(a, b);
        int ans = 0;
        while(d[a][0] < b){
            for(int j = 0; j < 20; j++){
                if(d[a][j] >= b){
                    a = d[a][j - 1];
                    ans += power2(j - 1);
                    break;
                }
            }
        }
        ans++;
        cout << ans << endl;
    }
}

Measured memory_bytes: 9088
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n, x;
    n = sc.nextInt();
    if (n >= 3 && n <= 10000) {
      for (int i = 1; i <= n; i++) {
        if (i % 3 == 0) {
          System.out.print(" " + i);
        } else {
          x = i;
          while (x != 0) {
            if (x % 10 == 3) {
              System.out.print(" "+ i);
              break;
            }
            x /= 10;
          }
        }
      }
      System.out.print("\n");
    }
  }
}

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

using namespace std;

using ll = long long;
using ld = long double;

const int INF = (1 << 30) - 1;
const ll INF64 = ((ll)1 << 62) - 1;
const double PI = 3.1415926535897932384626433832795;

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

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

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

	string s;
	cin >> s;

	set<char> se;
	for (auto c : s) {
		se.emplace(c);
	}

	if (se.size() == 1) {
		cout << 0 << endl;
		return 0;
	}

	int ans = INF;
	for (auto v : se) {
		int score = 0, cnt = 0;
		for (auto c : s) {
			if (v != c) {
				cnt++;
				continue;
			}

			score = max(score, cnt);
			cnt = 0;
		}

		score = max(score, cnt);
		ans = min(ans, score);
	}

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


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

using namespace std;

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

int n;
vector<int> a;

void solve() {
    double avg = 0;
    rep(i, n) avg += a[i];
    avg /= n;
    int ans = 0;
    rep(i, n) if (a[i] <= avg) ans++;
    cout << ans << endl;
}

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


Measured memory_bytes: 3136
#include <bits/stdc++.h>
using namespace std;
template<class T> ostream& operator<<(ostream &os, vector<T> V) {
os << "[ "; for(auto v : V) os << v << " "; return os << "]";}
template<class L, class R> ostream& operator<<(ostream &os, pair<L,R> P) {
    return os << "(" << P.first << "," << P.second << ")";}

#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cout << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...) 1
#endif
typedef long long ll;
typedef double ld;
#define pll pair<ll,ll>
#define pii pair<int, int>
#define pb push_back
#define mp(x, y) make_pair((x), (y))
#define F first
#define S second
#define I insert
#define vi vector<int>
#define vll vector<ll>
#define vpll vector<pll>
#define vpii vector<pii>
#define all(x) (x).begin(), (x).end()
#define sz(x) (ll)(x).size()

const ll Mod = 1e9 + 7;
const int N = 1e5 + 7;
pii A[N];
int main(){
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	int n , x; cin >> n;
	for(int i = 1; i <= n ; i++){
		cin >> A[i].F;
		A[i].S = i;
	}
	sort(A+1 , A+n+1);
	for(int i = 1;i <= n ;i++)
		cout << A[i].S << ' ';
	cout << endl;
	return 0;
}


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

using namespace std;
using ll = long long;

int main(int argc, const char *argv[]) {
  ll n;
  cin >> n;

  vector<ll> va(n);
  for (ll i = 0; i < n; ++i) {
    cin >> va[i];
  }

  ll cur = 0, money = 1000, k = 0;
  bool b = true;
  vector<ll> ans{1000};
  while (cur < n) {
    ll i = cur;
    if (b) {
      // 増えるところを見つける
      while (i < n - 1 && va[i] > va[i + 1]) {
        i++;
      }

      // 全て買う
      ll cnt = money / va[i];
      money -= va[i] * cnt;
      k += cnt;
      ans.push_back(money);
    } else {
      // 減るところを見つける
      while (i < n - 1 && va[i] <= va[i + 1]) {
        i++;
      }

      // 全て売る
      money += va[i] * k;
      k = 0;
      ans.push_back(money);
    }

    b = !b;
    cur = i + 1;
  }

  cout << *max_element(ans.begin(), ans.end()) << '\n';
  return 0;
}

Measured memory_bytes: 3612
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <vector>
#include <cmath>
#include <queue>
#include <stack>
using namespace std;
typedef long long lli;
const double pi = atan(1) * 4.0;
double a, b, x;

void ReadInput()
{
    cin >> a >> b >> x;
}

void Solve()
{

    double c = 2.0 * x / (a * b);
    if(c <= a)
    {
        double ang = atan(c / b);
        if(ang < 0) ang += pi;
        cerr << c << '\n';
        cerr << ang << '\n';
        double ans = pi / 2 - ang;
        cout << fixed << setprecision(9);
        cout << ans * 180.0 / pi << '\n';
    }
    else
    {
        // 3 1 8
        double k = b - (2.0 * x / (a * a) - b);
        cerr << k << '\n';
        double ang = atan(a / k);
        double ans = pi / 2 - ang;
        cout << fixed << setprecision(9);
        cout << ans * 180.0 / pi << '\n';
    }
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    ReadInput();
    Solve();
}


Measured memory_bytes: 256
n,m = map(int,input().split())
import math

if abs(m-n) == 1:
    ans = math.factorial(n) * math.factorial(m)
elif n == m:
    ans = 2*math.factorial(n) * math.factorial(m)
else:
    ans = 0

mod = 10**9+7
print(ans%mod)

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

int main(void)
{
    //string a,b;
    int a,b,c,d;
    //char a,b,c;
    int i=0;
    //char a,b='.';
    cin>>a>>b;
    if(b<a) cout<<a-1;
    else cout<<a;
    return 0;
}



Measured memory_bytes: 256
#include <iostream>
using namespace std;
int c[4][4];
int a[4],b[4];
bool ini()
{
	for(int i=1;i<=3;i++)
	 a[i]=-1,b[i]=-1;
}
bool che()
{
	for(int i=1;i<=3;i++)
	 for(int j=1;j<=3;j++)
	  {
	  	if(a[i]+b[j]!=c[i][j])
	  	 return false;
	  }
	  return true;
}
int main()
{
	for(int i=1;i<=3;i++)
	  for(int j=1;j<=3;j++)
	   {
	   	  cin>>c[i][j];
	   }
	   int x=1;
	   while(x<=100)
	   {
	   	 ini();
	   	a[1]=x;
	   	b[1]=c[1][1]-a[1];
	   	a[2]=c[2][1]-b[1];
	   	a[3]=c[3][1]-b[1];
	   	b[2]=c[3][2]-a[3];
	   	b[3]=c[3][3]-a[3];
	   	if(che())
	   	break;
	   	else
	   	x++;
	   }
	   if(x<=100)
	   cout<<"Yes";
	   else
	   cout<<"No";
	   return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
typedef long long ll;
const long long INF = 1LL << 60;
typedef pair<int, int> P;
int main()
{
    int N;
    cin >> N;
    vector<int> P(N), Q(N), T(N);

    rep(i, N) T[i] = i + 1;

    rep(i, N) cin >> P[i];
    rep(i, N) cin >> Q[i];

    int p, q, now;
    p = 0;
    q = 0;
    now = 1;

    bool flag_p = true, flag_q = true;
    do {
        ll res = 0;
        if (p == 0) {
            rep(i, N) {
                if (T[i] != P[i]) {
                    flag_p = false;
                    break;
                }
            }
        }
        if (flag_p) {
            p = now;
            flag_p = false;
        }
        if (q == 0) {
            rep(i, N) {
                if (T[i] != Q[i]) {
                    flag_q = false;
                    break;
                }
            }
        }
        if (flag_q) {
            q = now;
            flag_q = false;
        }
        if (p == 0) flag_p = true;
        if (q == 0) flag_q = true;
        now++;
    } while (next_permutation(T.begin(), T.end()));

    cout << abs(p - q) << endl;
    return 0;
}

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

using namespace std;
const int N=5e5+5,mod=1e9+7;
#define ll long long
int a[N];
pair<int,int> Best[N];
void update(pair<int,int> &p,int idx)
{
    if(a[idx]>a[p.first]) swap(idx,p.first);
    if(a[idx]>a[p.second]&&idx!=p.first) swap(idx,p.second);
}
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    int n;
    cin>>n;
    for(int i=0;i<(1<<n);i++)
    {
        cin>>a[i];
        pair<int,int>p={1<<n,1<<n};
        for(int j=0;j<n;j++)
        {
            int t=(1<<j);
            t=(~t);
            t=(i&t);
            if(t==i) continue;
            update(p,Best[t].first);
            update(p,Best[t].second);
        }
        update(p,i);
        Best[i]=p;
    }
    int ans=0;
    for(int i=1;i<(1<<n);i++)
    {
        ans=max(ans,a[Best[i].first]+a[Best[i].second]);
        cout<<ans<<'\n';
    }
    return 0;
}


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

int main() {
	ios_base::sync_with_stdio(0);cin.tie(0);
	vector<string> s;
	int n,l;
	cin>>n>>l;
	for(int i=0;i<n;++i){
		string x;
		cin>>x;
		s.push_back(x);
	}
	sort(s.begin(),s.end());
	for(string& x:s)
		cout<<x;
	cout<<'\n';
}




Measured memory_bytes: 3644
M,D=map(int,input().split())
count=0
if D < 20:
    print(count)
else:
    for m in range(1,M+1):
        for d in range(20,D+1):
            a = d//10
            b = d%10
            if b>1 and a*b==m:
                count+=1
    print(count)

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

using LL = long long;
using LD = long double;
 
LL mod = 1e9+7;

LL H[100001];

bool comp (LL a, LL b) {
	return H[a] > H[b];
}

int main()
{

	for (LL i = 0; i < 100001; ++i) {
		H[i] = 0;
	}
	LL n, m;
	cin >> n >> m;

	vector<LL> h(n);

	for (auto &e : h) {
		cin >> e;
	}

	for (LL i = 0; i < n; ++i) {
		H[i] = h[i];
	}

	vector<vector<LL>> adj(n);

	for (LL i = 0; i < m; ++i) {
		LL a, b;
		cin >> a >> b;
		a--, b--;
		adj[a].push_back(b);
		adj[b].push_back(a);
	}

	for (auto &v : adj) {
		sort(v.begin(), v.end(), comp);
	}

	LL cnt = 0;
	for (LL i = 0; i < n; ++i) {
		if (adj[i].size() == 0 || h[i] > h[adj[i][0]]) {
			cnt++;
		}
	}
	cout << cnt << "\n";

}

Measured memory_bytes: 10588
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int K = sc.nextInt();
        int X = sc.nextInt();
        int Y = sc.nextInt();
        System.out.println( solve(N, K, X, Y) );
    }

    private static int solve(int N, int K, int X, int Y) {
        if( N > K ) {
            return K * X + (N - K) * Y;
        } else {
            return N * X;
        }
    }
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep1(i, n) for(int i = 1; i <= (int)(n); i++)
#define showmap(is, js, x) {rep(i, is){rep(j, js){cout << x[i][j] << " ";}cout << endl;}}
#define show(x) {for(auto i: x){cout << i << " ";} cout<<endl;}
#define showm(m) {for(auto i: m){cout << m.x << " ";} cout<<endl;}
typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> llP;
ll gcd(int x, int y){ return y?gcd(y, x%y):x;}
ll lcm(ll x, ll y){ return (x*y)/gcd(x,y);}


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

    cout << a*b << endl;
}


Measured memory_bytes: 3632
N=int(input())
if N%10==2 or N%10==4 or N%10==5 or N%10==7 or N%10==9:
  print("hon")
elif N%10==0 or N%10==1 or N%10==6 or N%10==8:
  print("pon")
elif N%10==3:
  print("bon")

Measured memory_bytes: 9180
#include <iostream>
#include "stdio.h"

using namespace std;

int main() {
  int a,b,c;
  int cc = 0;

  scanf("%d%d%d", &a,&b,&c);

  while(a <= b) {
    if (c % a == 0) {
      cc++;
    }

    a++;
  }

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

  return 0;
}



Measured memory_bytes: 3228
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		try {
			String s = sc.next();
			int len = s.length() - 1;// lenは最後の一文字はチェック不要のため-1する
			char ch;
			for (int i = 0; i < len; i++) {
				ch = s.charAt(i);
				if (s.lastIndexOf(ch) != i) {
					System.out.println("no");
					return;
				}
			}
			System.out.println("yes");

		} finally {
			sc.close();
		}
	}
}

Measured memory_bytes: 23764
//E
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll ans;
vector<ll>v,A,B,C;
int main(){
	int x,y,a,b,c;
	cin >> x >> y >> a >> b >> c;
	for(int i = 1;i <= a;i++){
		ll x;cin >> x;A.push_back(x);
	}
	for(int i = 1;i <= b;i++){
		ll x;cin >> x;B.push_back(x);
	}
	for(int i = 1;i <= c;i++){
		ll x;cin >> x;C.push_back(x);
	}
	sort(A.begin(),A.end());
	sort(B.begin(),B.end());
	sort(C.begin(),C.end());
	reverse(A.begin(),A.end());
	reverse(B.begin(),B.end());
	reverse(C.begin(),C.end());
	for(int i = 0;i < x;i++)v.push_back(A[i]);
	for(int i = 0;i < y;i++)v.push_back(B[i]);
	for(int i = 0;i < c;i++)v.push_back(C[i]);
	sort(v.begin(),v.end());
	reverse(v.begin(),v.end());
	for(int i = 0;i < x+y;i++)ans += v[i];
	cout << ans;
	return 0;
}


Measured memory_bytes: 8816
#include <stdio.h>
#include <limits.h>
#include <math.h>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <cstring>
#include <string>
#include <sstream>
#include <algorithm>
#include <iomanip>
#include <iostream>

#define VARIABLE(x) cerr << #x << "=" << x << endl
#define BINARY(x) static_cast<bitset<16> >(x);
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define REP(i,m,n) for (int i=m;i<(int)(n);i++)
#define if_range(x, y, w, h) if (0<=(int)(x) && (int)(x)<(int)(w) && 0<=(int)(y) && (int)(y)<(int)(h))

const int INF = 100000000;
typedef double D;
const double EPS = 1e-8;
const double PI = 3.14159;
int dx[4]={-1, 0, 1, 0}, dy[4]={0, -1, 0, 1};
using namespace std;
typedef pair<int, int> P;

/** Problem0120 : Patisserie **/
const int MAX_N = 12;

double W;
vector<double> size;
double dp[1<<MAX_N][MAX_N];
int N;

int sig(double a, double b) {
	if(a < b - EPS) return -1;
	if(a > b + EPS) return +1;
	return 0;
}

double rec(int S, int v)
{
	//printf("(S, v, w) = (%d, %d, %.2f)\n", S, v, w);
	
	if (dp[S][v]>=0)
		return dp[S][v];
	
	if (S==(1<<N)-1) {
		return dp[S][v] = size[v];
	}
	
	double res=INF;
	rep(u, N) {
		if (!(S>>u&1)) {
			double d = sqrt((size[u]+size[v])*(size[u]+size[v]) - (size[u]-size[v])*(size[u]-size[v]));
			res  = min(res, rec(S|1<<u, u)+d);
		}
	}
	
	return dp[S][v] = res;
}

int main()
{
	string in;
	while (getline(cin, in)) {
		size.clear();
		
		stringstream ss(in);
		ss>>W;
		double d;
		while (ss>>d) {
			size.push_back(d);
		};
		N=(int)size.size();
		
		memset(dp, -1, sizeof(dp));
			
		double ans=INF;
		rep(i, N) {
			ans = min(ans, rec(1<<i, i)+size[i]);
		}
		//cout << ans << " " << W << endl;
		cout << (sig(ans, W)!=1?"OK":"NA") << endl;
	}
}

Measured memory_bytes: 1640
#include<bits/stdc++.h>
using namespace std;
/*
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

#define pbds tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
*/
#define MOD     1000000007
#define int     long long int
#define fastIO  ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define PI      3.1415926535897932384626
#define pb      push_back
#define clr(x)  memset(x, 0, sizeof(x))
#define MP      make_pair
const int N=1e5+1;

int gcd(int a,int b){if(a==0)return b;return gcd(b%a,a);}
int lcm(int a,int b){return (max(a,b)/gcd(a,b))*min(a,b);}
int powermodm(int x,int n,int M){int result=1;while(n>0){if(n % 2 ==1)result=(result * x)%M;x=(x*x)%M;n=n/2;}return result;}
int gcdExtended(int a, int b, int *x, int *y){if (a == 0){*x = 0, *y = 1;return b;}int x1, y1;int gcd = gcdExtended(b % a, a, &x1, &y1);*x = y1 - (b / a) * x1;*y = x1;return gcd;}
int modInverse(int a, int m){int x, y;int g = gcdExtended(a, m, &x, &y);if (g != 1)return -1;else{int res = (x % m + m) % m;return res;}}
bool isPrime(int a){if(a==1) return false;if(a==2) return true;if(a%2==0) return false;int root=sqrt(a);for(int i=3;i<=(int)root;i+=2){if(a%i==0)return false;}return true;}

vector<int> g[N];
int len[N];

int dfs(int u)
{
    if(len[u]!=0)
        return len[u];
    if(g[u].size()==0)
    {
        len[u]=0;
        return len[u];
    }
    int val=0;
    for(auto it:g[u])
    {
        val=max(val,dfs(it)+1);
    }
    len[u]=val;
    return len[u];
}

int32_t main()
{
    int n,m;
    cin >> n >> m;
    while(m--)
    {
        int u,v;
        cin >> u >> v;
        u--;
        v--;
        g[u].pb(v);
    }
    for(int i=0;i<n;i++)
    {
        dfs(i);
    }
    int ans=0;
    for(int i=0;i<N;i++)
        ans=max(ans,len[i]);
    cout << ans;
    return 0;
}



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

public class AtCoderA
{
    static void Main()
    {
        var sc = new Scanner();

        string s = sc.Next();

        bool ok = true;

        for (int i = 0; i < s.Length; i++)
        {
            if (i % 2 == 0)
            {
                if (s[i] != 'h')
                {
                    ok = false;
                }
            }
            else
            {
                if (s[i] != 'i')
                {
                    ok = false;
                }
            }
        }

        if (s.Length % 2 == 1)
        {
            ok = false;
        }

        string answer = ok ? "Yes" : "No";

        Console.WriteLine(answer);
    }

    class Scanner
    {
        private string[] _line;
        private int _index;
        private const char Separator = ' ';

        public Scanner()
        {
            _line = new string[0];
            _index = 0;
        }

        public string Next()
        {
            while (_index >= _line.Length)
            {
                _line = Console.ReadLine().Split(Separator);
                _index = 0;
            }

            return _line[_index++];
        }

        public int NextInt() => int.Parse(Next());
        public long NextLong() => long.Parse(Next());
        public double NextDouble() => double.Parse(Next());
        public decimal NextDecimal() => decimal.Parse(Next());
        public char NextChar() => Next()[0];
        public char[] NextCharArray() => Next().ToCharArray();

        public string[] Array()
        {
            _line = Console.ReadLine().Split(Separator);
            _index = _line.Length;
            return _line;
        }

        public int[] IntArray() => Array().Select(int.Parse).ToArray();
        public long[] LongArray() => Array().Select(long.Parse).ToArray();
        public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
        public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
    }
}


Measured memory_bytes: 25864
#include <bits/stdc++.h>
using namespace std;
 
typedef long long T;
 
struct point { 
    T x,y;
    int i; 
    point operator - (const point &rhs) {
        return {x-rhs.x, y-rhs.y};
    }
    T dot(const point &rhs) {
        return x*rhs.x + y*rhs.y;
    }
    T cross(const point &rhs) {
        return x*rhs.y - y*rhs.x;
    }
    T len2() {
        return x*x + y*y;
    }
};
 
int compare(T x, T y) {
    if(y-x > 0) return -1;
    if(x-y > 0) return 1;   
    return 0;
}
 
T cross(point p, point q, point r) { return (r-q).cross(p-q); }
 
int turn(point p, point q, point r) { return compare(cross(p,q,r), 0); }
 
int cw(point p, point q, point r) { return turn(p,q,r) < 0; }
 
 /*
double angle(point p, point q, point r) 
{
    point v = r - q;
    point u = p - q;
    return acos(v.dot(u) / sqrt(v.len2() * u.len2())); 
}
*/
//T dot(point p, point q) { return p.x * q.x + p.y * q.y; }
// modulo^2 de un punto (distance to origin)
double norm2(point p) { return p.x * p.x + p.y * p.y; }


double angle(point a, point o, point b) // angle AOB (radians)
{
   point u = {a.x - o.x, a.y - o.y}; // u: vector oa
   point v = {b.x - o.x, b.y - o.y}; // v: vector ob
   return acos(u.dot(v) / sqrt(norm2(u) * norm2(v))); // dot product
}

 
bool cmp(const point &p, const point &q)
{
    return p.x < q.x || (p.x == q.x && p.y < q.y);
}
 
vector<point> convex_hull(vector<point> &p)
{
    int n = (int)p.size(), k = 0;
    vector<point> h(2 * n);
    sort(p.begin(), p.end(), cmp);
    for(int i = 0; i < n; i++) 
    {
        while(k >= 2 && cw(h[k-2], h[k-1], p[i])) k--;
        h[k++] = p[i];
    }
    for(int i = n - 2, t = k + 1; i >= 0; i--) 
    {
        while(k >= t && cw(h[k-2], h[k-1], p[i])) k--;
        h[k++] = p[i];
    }
    h.resize(k); h.pop_back(); 
    return h;
}
 
int main()
{
    ios_base::sync_with_stdio(false); cin.tie(0);
    cout << fixed << setprecision(10);
    int n,m;
    vector<point> p,h;
    double ans[105];
    while(cin >> n)
    {
        p = vector<point>(n);
        for(int i = 0; i < n; i++)
        {
            cin >> p[i].x >> p[i].y;
            p[i].i = i;
        }
        h = convex_hull(p);
        for(int i = 0; i < n; i++)
            ans[i] = 0;
        m = h.size();
        for(int i = 0; i < m; i++)
            ans[h[i].i] = (M_PI - angle(h[(i-1+m)%m], h[i], h[(i+1)%m])) / (2*M_PI);
        for(int i = 0; i < n; i++)
            cout << ans[i] << '\n';
    }
    return 0;
} 

Measured memory_bytes: 256
def main():
    y = 0
    N = int(input())
    for _ in range(N):
        t = input()
        x = float(t.strip().split(' ')[0])
        u = t.strip().split(' ')[1]
        if u == 'BTC':
            y += 380000.0 * x
        else:
            y += x

    print(y)
    return

if __name__ == '__main__':
    main()

 

Measured memory_bytes: 2940
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2, gcd
from itertools import accumulate, permutations, combinations, combinations_with_replacement, 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, insort, insort_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 
#mod = 998244353
from decimal import *
#import numpy as np
#decimal.getcontext().prec = 10

N, X = MAP()

p = [0]*(N+1) #レベルNバーガーのパティ枚数
p[0] = 1
q = [0]*(N+1) #レベルNバーガーの総枚数
q[0] = 1

for i in range(1, N+1):
	p[i] = 2*p[i-1] + 1
	q[i] = 2*q[i-1] + 3

ans = 0
i = N
while 0 < X:
	while 0 < X < q[i]:
		i -= 1
		X -= 1
	if 0 < X:
		X -= q[i]
		ans += p[i]
	if 0 < X:
		X -= 1
		ans += 1

print(ans)

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

ll M = 1000000007;

//べき乗高速化
ll mpow(ll x, ll n){
	ll ans = 1;
	while(n != 0){
		if (n&1) ans = ans * x % M;
		x = x*x % M;
		n  = n >> 1;
	}
	return ans;
}

int main(){
	ll n;
	cin >> n;
	ll ans = mpow(10, n);
	ans -= 2 *mpow(9,n);
	ans %= M;
	ans += mpow(8, n);
	ans %= M;
	if(ans < 0){
		ans += M;
	}
	cout << ans << endl;
    return 0;
}



Measured memory_bytes: 3632
n,k=map(int,input().split())
x=list(map(int,input().split()))
ans=10**9+7
for i in range(n-k+1):
    temp=x[i+k-1]-x[i]+min(abs(x[i]),abs(x[i+k-1]))
    if temp<ans: ans=temp
print(ans)

Measured memory_bytes: 19844
import sys
import math
input = sys.stdin.readline

N = int(input())

ans = 0
for i in range(1, int(math.sqrt(N)) + 1):
    if not N % i:
        if ans:
            ans = min(ans, i + (N // i) - 2)
        else:
            ans = i + (N // i) - 2
    else:
        continue

print(ans)

Measured memory_bytes: 3064
import java.util.*;
import java.awt.geom.*;
public class Main {
	int [][] map;
	int ans;
	String [][] boards;
	boolean isused [];

	private void doit(){
		Scanner sc = new Scanner(System.in);
		int datasetcount = 1;
		while(true){
			int n = sc.nextInt();
			if(n == 0) break;
			double [] xlist = new double[n * 2];
			double [] ylist = new double[n * 2];
			double [][] inputlist = new double[n][4];
			for(int i = 0; i < n; i++){
				double inputx = sc.nextDouble();
				double inputy = sc.nextDouble();
				double inputr = sc.nextDouble();
				//calc a vertex
				for(int j = 0; j < 2; j++){
					double x;
					if(j == 0){
						x = inputx - inputr;
					}
					else{
						x = inputx + inputr;
					}
					inputlist[i][j] = x;
					xlist[i * 2 + j] = x;
				}
				for(int j = 0; j < 2; j++){
					double y;
					if(j == 0){
						y = inputy - inputr;
					}
					else{
						y = inputy + inputr;
					}
					inputlist[i][j + 2] = y;
					ylist[i * 2 + j] = y;
				}
				
			}
			Arrays.sort(xlist);
			Arrays.sort(ylist);
			//debug
//			for(int i = 0; i < xlist.length; i++){
//				System.out.print(xlist[i] + " ");
//			}
//			System.out.println();
//			for(int i = 0; i < ylist.length; i++){
//				System.out.print(ylist[i] + " " );
//			}
//			System.out.println();
			
			//create a mesh
			boolean [][] mesh = new boolean[ylist.length -1][xlist.length -1];
			for(int i = 0; i < n; i++){
//				double firstXvalue = inputlist[i][0];
//				double firstYvalue = inputlist[i][1];
//				double lastXvalue = inputlist[i][2];
//				double lastYvalue = inputlist[i][3];
				int firstXind = Arrays.binarySearch(xlist, inputlist[i][0]);
				int lastXind  = Arrays.binarySearch(xlist, inputlist[i][1]);
				int firstYind = Arrays.binarySearch(ylist, inputlist[i][2]);
				int lastYind  = Arrays.binarySearch(ylist, inputlist[i][3]);
				//System.out.println("valuedebug= " + inputlist[i][0] + " " + inputlist[i][1] + " " + inputlist[i][2] + " " + inputlist[i][3]);
				//System.out.println("indexdebug= " + firstXind + " " + lastXind + " " + firstYind + " " + lastYind);
				for(int meshY = firstYind; meshY < lastYind; meshY++){
					for(int meshX = firstXind; meshX < lastXind; meshX++){
						mesh[meshY][meshX] = true;
					}
				}
			}
			
			//calc a area
			double res = 0.0;
			for(int i = 0; i < mesh.length; i++){
				for(int j = 0; j < mesh[i].length; j++){
					if(mesh[i][j]){
						double sideX = xlist[j + 1] - xlist[j];
						double sideY = ylist[i + 1] - ylist[i];
						double nowarea = sideX * sideY;
						res += nowarea;
					}
				}
			}
			//debug
//			System.out.println("meshdebug= ");
//			for(int i = 0; i < mesh.length; i++){
//				for(int j = 0; j < mesh.length; j++){
//					System.out.print(mesh[i][j] + " ");
//				}
//				System.out.println();
//			}
			System.out.printf("%d %.2f\n",datasetcount++, res);
		}
	}

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

Measured memory_bytes: 13000
import scala.io.StdIn._
object Main extends App {
  val Array(n, m, s, t) = readLine.trim.split(' ').map(_.toInt)
  val dimensions = Array.fill(n){Nil: List[Int]}
  val damages = readLine.trim.split(' ').map(_.toInt)
  val minDamage = Array.fill(n){Int.MaxValue}
  for (_ ← 0 until m){
    val Array(a, b) = readLine.trim.split(' ').map(_.toInt - 1)
    dimensions(a) ::= b
  }
  val minBit = MinBit(n).reversed
  minBit.decrease(s - 1, 0)
  minDamage(s - 1) = 0
  for (d ← 0 until t) {
    minDamage(d) = minBit(d)
    for (to ← dimensions(d)) {
      if (minDamage(to) > damages(to) + minDamage(d)) {
        minDamage(to) = damages(to) + minDamage(d)
        minBit.decrease(to, minDamage(to))
      }
    }
  }
  println(minDamage(t - 1))


}
trait MinBit {
  def apply(position: Int): Int
  def decrease(position: Int, newValue: Int): Unit
  def reversed: MinBit
  def size: Int
}
object MinBit {
  def apply(size: Int): MinBit = new MinBitImpl(size)
  private class MinBitImpl(val size: Int) extends MinBit {
    private val array = Array.fill(size){Int.MaxValue}
    def apply(position: Int): Int = {
      if (position >= 0) {
        Math.min(array(position), apply(position - ((position + 1) & ~position)))
      }else {
        Int.MaxValue
      }
    }
    def decrease(position: Int, newValue: Int): Unit = {
      if (position < size && array(position) > newValue) {
        array(position) = newValue
        decrease(position + ((position + 1) & ~position), newValue)
      }
    }
    override def reversed: MinBit = new Reversed(this)
  }
  private class Reversed(private val bit: MinBit) extends MinBit {
    def size = bit.size
    def apply(position: Int): Int = bit(size - position - 1)
    def decrease(position: Int, newValue: Int) = bit.decrease(size - position - 1, newValue)
    override def reversed: MinBit = bit
  }
}


Measured memory_bytes: 166608
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD=1000000007;
#define INF 1LL<<30
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()


int main(){
    int x;
    cin>>x;
    if(x>=30) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}



Measured memory_bytes: 3620