akhauriyash/Code-Regression huggingface dataset:
a, b, c, d, e, f= (int(i) for i in input().split()) 

waterlist=[]
for i in range(0,f+100*a,100*a):
  for j in range(0,f+100*b,100*b):
    if i+j <=f:
      waterlist+=[i+j]
waterlist=list(set(waterlist))
#print(x)

sugarlist=[]
for i in range(int(f/c)+1):
  for j in range(int(f/d)+1):
    if c*i+d*j <=f:
      sugarlist+=[c*i+d*j]
sugarlist=list(set(sugarlist))
#print(y)

density=0

for i in range(len(waterlist)):
  for j in range(len(sugarlist)):
    if 0 < waterlist[i]+sugarlist[j] <= f and sugarlist[j]<=waterlist[i]/100*e:
      tmp=sugarlist[j]/(waterlist[i]+sugarlist[j])
      if density <= tmp:
        density = tmp
        ans1=waterlist[i]+sugarlist[j]
        ans2=sugarlist[j]
        
print(ans1,ans2)


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

int main()
{
	int N;
	cin >> N;
	vector<pair<long long, long long>> XL( N );
	for( int i = 0; i < N; i++ ) {
		long long X, L;
		cin >> X >> L;
		XL[i] = make_pair( X + L, X - L );
	}

	sort( XL.begin(), XL.end() );
	int l = 0;
	int r = 1;
	int ans = 0;
	while( r < N ) {
		if( XL[l].first <= XL[r].second ) {
			ans++;
			l = r;
			r++;
		}
		else {
			r++;
		}
	}
	ans++;

	cout << ans << endl;
}


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

int main()
{
    int n, k;
    cin >> n >> k;
    int r, s, p;
    cin >> r >> s >> p;
    string t;
    cin >> t;
    unordered_map<char, int> table;
    table['r'] = p;
    table['s'] = r;
    table['p'] = s;
    ll ans = 0;
    for (int i = 0; i < k; ++i)
    {
        char prev = t[i];
        ans += table[prev];
        for (int j = i + k; j < n; j += k)
        {
            if (t[j] != prev)
            {
                prev = t[j];
                ans += table[prev];
            }
            else
            {
                prev = 'n';
            }
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 3736
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
using namespace std;
int main() {
    int N; cin >> N;
    vector<int> P(N, 0);
    int tmp = 0, j = 0;
    for(int i = 0; i < N; i++) {
        cin >> P[i];
        if (tmp <= P[i]) {
            tmp = P[i], j = i;
        }
    }
    P[j] /= 2;
    int sum = 0;
    for (int i = 0; i < N; i++) sum += P[i];
    printf("%d\n", sum);
}


Measured memory_bytes: 3696
#include <bits/stdc++.h>
#include <string>
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <bitset>
typedef long long ll;
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
 
const int mod = 1000000007;
//const int mod = 998244353;
 

struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }
 
  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}
 
 
struct combination {
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
} c(200005);
 
vector<pair<long long, long long> > prime_factorize(long long N) {
    vector<pair<long long, long long> > res;
    for (long long a = 2; a * a <= N; ++a) {
        if (N % a != 0) continue;
        long long ex = 0; // 指数

        // 割れる限り割り続ける
        while (N % a == 0) {
            ++ex;
            N /= a;
        }

        // その結果を push
        res.push_back({a, ex});
    }

    // 最後に残った数について
    if (N != 1) res.push_back({N, 1});
    return res;
}
vector<long long> enum_divisors(long long N) {
    vector<long long> res;
    for (long long i = 1; i * i <= N; ++i) {
        if (N % i == 0) {
            res.push_back(i);
            // 重複しないならば i の相方である N/i も push
            if (N/i != i) res.push_back(N/i);
        }
    }
    // 小さい順に並び替える
    sort(res.begin(), res.end());
    return res;
}

// M * (M-1)^(N-1-K) * N-1 C K
int main(int argc, const char * argv[]) {
    ll H,N; cin >> H >>N;
    vector<ll> A(N);
    
    ll sum=0;
    for(ll i=0;i<N;i++){
        cin >> A[i];
        sum += A[i];
    }
    
    if(sum < H){
        cout <<"No" << endl;
    }else{
        cout << "Yes" << endl;
    }
    return 0;
}



Measured memory_bytes: 4096
#include <bits/stdc++.h>
using namespace std;
#define rep(i, a) for(int i=0; i<(int)(a); i++)
typedef long long ll;
const int inf = 1001001001;

void insertionSort(int a[], int n, int g, int *cnt)
{
  for (int i=g; i<n; i++) {
    int v = a[i];
    int j = i - g;
    while (j >= 0 && a[j] > v) {
      a[j+g] = a[j];
      j = j - g;
      *cnt += 1;
    }
    a[j+g] = v;
  }
}

void shellSort(int a[], int n)
{
  int cnt = 0;
  int m = 0;
  int G[100];
  for (int i=0; i<100; i++) {
    if (i==0) G[i] = n/2 + 1;
    else G[i] = G[i-1]/2 - 1;
    if (G[i] < 0) {
      G[i-1] = 1;
      G[i] = 0;
      m = i;
      break;
    }
  }

  for (int i=0; i<m; i++) {
    insertionSort(a, n, G[i], &cnt);
  }

  cout << m << endl;
  rep(i, m) {
    if (i) cout << " ";
    cout << G[i];
  }
  cout << endl << cnt << endl;
  rep(i, n) cout << a[i] << endl;
}

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

  return 0;
}



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

using namespace std;

#define all(x) begin(x), end(x)

using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using vi = vector<int>;

constexpr int MOD = 1e9 + 7;

int sum(int a, int b) {
    int c = a + b;
    if (c >= MOD)
        c -= MOD;
    return c;
}

int prod(int a, int b) {
    return 1LL * a * b % MOD;
}

int modpow(int b, int e) {
    if (e == 0) return 1;
    if (e & 1) return prod(b, modpow(b, e ^ 1));
    return modpow(prod(b, b), e >> 1);
}

inline int inv(int x) {
    return modpow(x, MOD - 2);
}

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

    int h, w, n;
    cin >> h >> w >> n;

    int max_f = h + w + 1;
    vi fact(max_f), tcaf(max_f);
    fact[0] = fact[1] = 1;
    for (int i = 2; i < max_f; ++i) {
        fact[i] = prod(fact[i - 1], i);
    }

    tcaf[max_f - 1] = inv(fact[max_f - 1]);
    for (int i = max_f - 2; i >= 0; --i) {
        tcaf[i] = prod(tcaf[i + 1], i + 1);
    }

    vector<pii> blocks;
    for (int i = 0; i < n; ++i) {
        int r, c;
        cin >> r >> c;
        --r; --c;
        blocks.emplace_back(r, c);
    }
    blocks.emplace_back(h - 1, w - 1);
    ++n;

    sort(all(blocks));

    // number of paths from 0, 0 to (r, c) with no blocks is
    // (r + c) choose r
    // precompute factorials and such
    //
    // now with blocks
    // let dp[i] = # of ways to get to block i where i is the first block encountered
    // then its (r + c) choose r - (dx + dy) choose dx far all other previous blocks
    vi dp(n);
    for (int i = 0; i < n; ++i) {
        int r, c;
        tie(r, c) = blocks[i];
        dp[i] = prod(fact[r + c], prod(tcaf[r], tcaf[c]));
        for (int j = 0; j < n; ++j) {
            if (j == i) continue;
            int dr = r - blocks[j].first;
            int dc = c - blocks[j].second;
            if (dr >= 0 and dc >= 0) {
                int cut = prod(fact[dr + dc], prod(tcaf[dr], tcaf[dc]));
                cut = prod(dp[j], cut);
                dp[i] = sum(dp[i], MOD - cut);
            }
        }
    }

    cout << dp.back() << '\n';

    return 0;
}


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

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

using namespace std;
using ll = long long;

void solve();

int main(void){
    int H, W; cin >> H >> W;
    string grid[H]; rep(i, H) cin >> grid[i];
    queue<pair<int, int>> bfs;
    rep(i, H)
        rep(j, W)
            if(grid[i][j] == '#') bfs.push(make_pair(i, j));
    int ans = 0;
    while(!bfs.empty()){
        queue<pair<int, int>> work;
        while(!bfs.empty()){
            work.push(bfs.front());
            bfs.pop();
        }
        while(!work.empty()){
            pair<int, int> op = work.front();
            work.pop();
            int x = op.first, y = op.second;
            if(x-1 >= 0 && grid[x-1][y] == '.'){grid[x-1][y] = '#'; bfs.push(make_pair(x-1, y));}
            if(y-1 >= 0 && grid[x][y-1] == '.'){grid[x][y-1] = '#'; bfs.push(make_pair(x, y-1));}
            if(y+1 <= W-1 && grid[x][y+1] == '.'){grid[x][y+1] = '#'; bfs.push(make_pair(x, y+1));}
            if(x+1 <= H-1 && grid[x+1][y] == '.'){grid[x+1][y] = '#'; bfs.push(make_pair(x+1, y));}
        }
        if(!bfs.empty()) ans++;
    }
    cout << ans << endl;
    return 0;
}

void solve(){}

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

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

void dfs(int y, int x)
{
	f[y][x] = '0';

	for(int d=0; d<4; d++)
	for(int l=1; l<=3; l++)
	{
		int nx = x+dx[d]*l;
		int ny = y+dy[d]*l;
		if(0<=nx&&nx<8&&0<=ny&&ny<8)
		if(f[ny][nx] == '1')
		{
			dfs(ny,nx);
		}
	}
}

int main()
{
	int n,sx,sy;
	
	cin >> n;
	for(int i=1; i<=n; i++)
	{
		for(int y=0; y<8; y++)
		{
			cin >> f[y];
		}

		cin >> sx >> sy;
		dfs(sy-1,sx-1);

		cout << "Data " << i << ":\n";
		for(int y=0; y<8; y++)
		{
			cout << f[y] << endl;
		}
	}
}

Measured memory_bytes: 0
#include <stdio.h> 

int main(void) 
{ 

   int H, W,i,j; 
   while(scanf("%d %d",&H,&W) != EOF){
     if(H == 0 && W == 0){
       break;
     }

     for (i = 1; i <= H; i++) { 
         for (j = 1; j <= W; j++) { 
             printf("#"); 

         } 
           printf("\n"); 
        
     } 
    printf("\n");
   }
   return 0; 

} 


Measured memory_bytes: 2056
#include <iostream>

using namespace std;
long long maxa=(1e16)+1000;
long long V[55];
long long K;
long long T[55];
int main()
{
    cin>>K;
    if(K==0)
    {
        cout<<"4\n3 3 3 3";
        return 0;
    }
    for(int i=1;i<=50;i++)
        T[i]=49+K/50;
    K%=50;
    for(int i=1;i<=K;i++)
    {
        T[i]+=51;
        for(int j=1;j<=50;j++)T[j]--;
    }
    cout<<50<<"\n";
    for(int i=1;i<=50;i++)cout<<T[i]<<" ";
    return 0;
}


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

using namespace std;
using namespace std::chrono;

#define rep(i,a,b) for(int i = a;i<(b);++i)
#define trav(a,v) for(auto& a : v)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()

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

ll big = 1000000007ll;
ll big2 = 1000000009ll;
ll n,m,T,k,q,x;

vector<ll> A;
ll ans = 0;
bool done = 0;
ll l = 0;

void doit(){
    sort(all(A));
    if(done)return;
    if(A[n-1] < n){
        done = 1;
        return;
    }
    ans++;
    A[n-1]-=n;
    for(ll c1 = 0; c1 < n-1; c1++){
        A[c1]++;
    }
}

void solve(){
    sort(all(A));
    if(done)return;
    if(A[n-1] < n){
        done = 1;
        return;
    }
    l = n-1;
    if(l > 0){
        while(A[l-1] >= A[n-1]-n-1){
            l--;
            if(l == 0)break;
        }
    }
    ll c = n-l;
   // cout << ans << " " << l << "\n";
    if(l == 0){

        k = max(0ll,A[n-1] - 2*n - 3);
        ans += n*k;
        for(ll c1 = 0; c1 < n; c1++){
            A[c1] -= k;
        }
        while(!done){
            doit();
        }
    }
    else{
        k = max((A[n-1] - A[l-1])/(n+1) - 2*(n+2) , 0ll);
        k = min(k, (A[l] - n + 0) / (n - c + 1) - 2*(n+1));
        k = max(k,0ll);
        ans += k*c;
        for(ll c1 = 0; c1 < l; c1++){
            A[c1] += k*c;
        }
        for(ll c1 = l; c1 < n; c1++){
            A[c1] -= k*(n-c+1);
        }
        for(ll c1 = 0; c1 < 10000; c1++){
            doit();
        }
        solve();
    }
}

int main()
{
   // freopen("input.txt","r",stdin);
    //freopen("autput.txt","w",stdout);
    ll a,b,c,d,e;


    cin >> n;
    l = n-1;
    for(ll c1 = 0; c1 < n; c1++){
        cin >> a;
        A.push_back(a);
    }

    solve();
    cout << ans << "\n";


    return 0;
}


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

fn main() {
    let n = parse_line::<usize>();
    let a = parse_values::<usize>(n);
    let mut set = HashSet::with_capacity(n);
    for a_item in a {
        if !set.insert(a_item) {
            println!("NO");
            return;
        }
    }
    println!("YES");
}

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

fn parse_values<T: std::str::FromStr>(n: usize) -> Vec<T> {
    let line = parse_line::<String>();
    let mut split = line.split_whitespace();
    let mut values = Vec::with_capacity(n);
    for _ in 0..n {
        let v = split.next().unwrap().parse::<T>().ok().unwrap();
        values.push(v);
    }
    values
}


Measured memory_bytes: 11512
#include <iostream>
#include<algorithm>
#include<string>
#include <cmath>
#include <vector>
#include <map>
#include <cstdio>
#include <iomanip>
#include<set>
#include <numeric>
#pragma region Macros
#define int long long
#define double long double
constexpr int MOD = 1000000007;
constexpr double PI = 3.14159265358979323846;
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define REP(i,n) for(int i=1;i<=n;i++)
#define LAST(x) x[x.size()-1]
#define ALL(x) (x).begin(),(x).end()
#define swap(a,b) (a += b,b = a - b,a -= b)
#define DIVCEIL(a,b) ((a+b-1)/b)
//int CHMAX

int intpow(int a, int n) {
	// a^nのint ver
	rep(i, n - 1)
		a *= a;
	return a;
}
int MODPOW(int a, int n, int mod) {
	// a^n mod
	int ans = 1;
	while (n > 0) {
		if (n & 1)
			ans = ans * a % mod;
		a = a * a % mod;
		n >>= 1;
	}
	return ans;
}
int FACT(int a) {
	if (a == 0)
		return 1;
	else
		return a * FACT(a - 1);
}
int MODFACT(int a, int mod) {
	if (a == 0)
		return 1;
	else
		return (a * FACT(a - 1)) % mod;
}
int nPr(int n, int r) {
	int s = n - r + 1;
	int sum = 1;
	for (int i = s; i <= n; i++)
		sum *= i;
	return sum;
}
int MODnPr(int n, int r, int mod) {
	int s = n - r + 1;
	int sum = 1;
	for (int i = s; i <= n; i++) {
		sum *= i;
		sum = sum % MOD;
	}
	return sum;
}
//int nCr(int n, int r)
int nCr2(int n, int r) {
	return FACT(n) / (FACT(r) * FACT(n - r));
}
int GCD(int a, int b)
{
	if (a < b)
		swap(a, b);
	if (b == 0)
		return a;
	if (a % b == 0)
		return b;
	return GCD(b, a % b);
}
int LCM(int a, int b)
{
	return  a * b / GCD(a, b);
}
int NUMOFDIV(int n) {
	//約数の数（だっけ？）
	int ans = 0;
	REP(i, n) {
		if (n % i == 0)
			ans++;
	}
	return ans;
}
int CEIL1(int n) {
	//1桁目切り上げ
	return (n + 9) / 10 * 10;
}
int DIGIT(int n, int k) {
	//nのk桁目
	rep(i, k - 1)
		n /= 10;
	return n % 10;
}
int DIGITSUM(int n) {
	int sum = 0, dig;
	while (n) {
		dig = n % 10;
		sum += dig;
		n /= 10;
	}
	return sum;
}
int DIVTIME(int n, int k) {
	//nをkで何回割れるか的な
	int div = 0;
	while (n % k == 0) {
		div++;
		n /= k;
	}
	return div;
}
int binary(int n) {
	//10進数→2進数
	int ans = 0;
	for (int i = 0; n > 0; i++) {
		ans += n % 2 * intpow(10, i);
		n /= 2;
	}
	return ans;
}
double LOG(int a, int b) {
	return log(b) / log(a);
}
inline bool BETWEEN(int x, int min, int max) {
	if (min <= x && x <= max)
		return true;
	else
		return false;
}
inline bool between(int x, int min, int max) {
	if (min < x && x < max)
		return true;
	else
		return false;
}
inline bool PRIMEOR(int x) {
	if (x == 1)
		return false;
	if (x == 2)
		return true;
	if (x % 2 == 0)
		return false;
	double sqrtx = sqrt(x);
	for (int i = 3; i <= sqrtx; i += 2) {
		if (x % i == 0)
			return false;
	}
	return true;
}
bool SQRTOR(int n) {
	if (sqrt(n) == (int)sqrt(n))
		return true;
	else
		return false;
}
// 順位付け
using namespace std;
#pragma endregion

signed main() {
	int X,Y,Z;
	cin >> X >> Y >> Z;
	cout << Z << ' ' << X << ' ' << Y;
}

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

const int MXN = 1e5 + 20;

int n, dp[MXN][3], tbl[MXN][3];

void npt();
void slv();
void tpt();

int main() {
	npt();
	slv();
	tpt();
	return 0;
}

void npt() {
	cin >> n;
	for (int i = 0; i < n; i++) {
		int a, b, c;
		cin >> a >> b >> c;
		tbl[i][0] = a;
		tbl[i][1] = b;
		tbl[i][2] = c;
	}
}

void slv() {
	dp[0][0] = tbl[0][0];
	dp[0][1] = tbl[0][1];
	dp[0][2] = tbl[0][2];
	for (int i = 1; i < n; i++)
		for (int j = 0; j < 3; j++)
			dp[i][j] = max(dp[i - 1][(j + 1) % 3], dp[i - 1][(j + 2) % 3]) + tbl[i][j];
}

void tpt() {
	cout << max(dp[n - 1][0], max(dp[n - 1][1], dp[n - 1][2])) << endl;
}


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

long long int solve(long long int n) {
    long long int div = 10;
    long long int ans = 0;
    while( n / div != 0) {
        ans += n/div;
        div *= 5;
    }
    return ans;
}
int main(){
    long long int n;
    cin >> n;
    if (n % 2) {
        cout << 0 << endl;
    }else {
        cout << solve(n) << endl;
    }
}

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

using namespace std;

long double BtoY = 380000.0;

int main(){
  int N;
  cin >> N;
  string CUR[N];
  long double AMT[N];
  
  long double ans = 0.0;
  
  for(int i =0; i < N; i++){
  cin >> AMT[i] >> CUR[i];
  }
  for(int i = 0; i < N; i++){
    if(CUR[i] == "JPY") ans += AMT[i];
    else if(CUR[i] == "BTC") ans += (AMT[i] * BtoY);
  }
  cout << ans;
}

Measured memory_bytes: 256
/*input
3
SRSRRSRRRSRRRR
*/
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
#define IOS ios_base::sync_with_stdio(0); cin.tie(0)
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define F first
#define S second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define eb emplace_back
#define pb push_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (int)(lower_bound(c.begin(),c.end(),x)-c.begin())
#define EL cout<<'\n'
#define BS(a,x) binary_search(ALL(a),x)
template<typename T1,typename T2>
ostream& operator<<(ostream& out,pair<T1,T2> P){
	out<<'('<<P.F<<','<<P.S<<')';
	return out;
}
template<typename T>
ostream& operator<<(ostream& out,vector<T> V){
	REP(i,SZ(V)) out<<V[i]<<((i!=SZ(V)-1)?" ":"");
	return out;
}
//}}}
const ll maxn=300005;
const ll maxlg=20;
const ll INF64=1e18;
const int INF=0x3f3f3f3f;
const ll MOD=ll(1e9+7);
const ld PI=acos(-1);
const ld eps=1e-9;
//const ll p=880301;
//const ll P=31;

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

const int N = 531441;

int n;
string s;
vector<int> a;

string op[13][N+5];

int res[13][N+5];

int main(){
	IOS;
	cin>>n>>s;
	string tmp;
	REP(i,SZ(s)){
		if(s[i]=='R') tmp.pb(s[i]);
		else{
			if(SZ(tmp)&&tmp.back()=='S') tmp.pop_back();
			else tmp.pb(s[i]);
		}
	}

	op[0][0] = tmp;
	res[0][0] = 0;

	int mx = 1;
	for(int len = 1; len <= n; len++){
		for(int i=0;i<3;i++) for(int j=0;j<mx;j++){
			int msb = i;
			op[len][i*mx+j].clear();
			for(char ch:op[len-1][j]){
				if(ch=='S'){
					if(msb) msb = 3-msb;
					if(SZ(op[len][i*mx+j])&&op[len][i*mx+j].back()=='S'){
						op[len][i*mx+j].pop_back();
					}
					else{
						op[len][i*mx+j].pb('S');
					}
				}
				else{
					msb++;
					if(msb == 3){
						msb = 0;
						op[len][i*mx+j].pb('R');
					}
				}
			}
			res[len][i*mx+j] = msb*mx+res[len-1][j];
		}
		mx*=3;
	}
	REP(i,mx){
		cout<<res[n][i]<<" \n"[i==mx-1];
	}
	return 0;
}


Measured memory_bytes: 227436
# http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ITP2_4_D&lang=jp
# Unique

from collections import deque
import sys
input = sys.stdin.readline

def main():
    n1 = int(input())
    l1 = list(map(int,input().split()))
    print(*sorted(list(set(l1))))
if __name__ == '__main__':
    main()


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

int main() {
    int n, c = 0;
    cin >> n;
    for(int i = 0; i < n; i++) {
        int a;
        cin >> a;
        if(i + 1 & a & 1)
            c++;
    }
    cout << c << endl;
    return 0;
}


Measured memory_bytes: 3592
#include <bits/stdc++.h>
#define ll long long
#define pll pair<ll, ll>
#define str string
#define fi first
#define se second
#define pb push_back
#define SET(a, b) memset(a, b, sizeof(a))
#define eps 1e-6
#define pi atan(1) * 4
#define mod 1000000007
#define inf 1000000000000000000
using namespace std;
int main () {
	int a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q;
	scanf("%d %d %d", &a, &b, &c);
	for (i = 0; i <= a; i++) {
		for (j = 0; j <= b; j++) {
			d = i * b + j * a - i * j * 2;
			if (d == c) {
				printf("Yes\n");
				return 0;
			}
		}
	}
	printf("No\n");
	return 0;
}

Measured memory_bytes: 256
//inlclude前用define 
#define _USE_MATH_DEFINES

//include
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<type_traits>
#include<numeric>
//#include<deque>
#include<iomanip>
#include<set>
#include<tuple>
#include<map>

using namespace std;

//typedef
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<char> VC;
typedef long long int ll;

//define
#define INF 1e9 
#define NUM 1000000007
#define all(x) begin(x), end(x)
#define rep(i,n) for(int i=0;i<(int)(n);i++)

int main() {
    string s;
    cin>>s;
    bool flag=true;
    for(int i=0;i<(int)s.length();i++){
        if((i+1)%2==0){
            if(s[i]=='R') flag=false;
        }else{
            if(s[i]=='L') flag=false;
        }
    }
    if(flag) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
 }



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

const int mod=1e9+7;

ll Big_Mod(ll value, ll power)
{
    if(power==0) return 1;

    ll ans = Big_Mod(value, power/2);

    ans = (ans * ans) % mod;

    if(power % 2) ans = (ans * value) % mod;

    return ans;
}

void solve()
{
   ll n,fact[10],i,sum=0,X,Y,Z;
   cin>>n;
   if(n==1)
   {
       cout<<0<<endl;
   }
   else
   {
       X=Big_Mod(10LL, n);
       Y=2LL*Big_Mod(9LL, n);
       Z=Big_Mod(8LL ,n);
       sum=X+Z-Y;
       sum%=mod;
       sum+=mod;
       sum%=mod;
       cout<<sum<<endl;
   }
}

int32_t main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);

    int t=1;
   // cin>>t;
    while(t--)
    {
        solve();
    }
}


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


int main()
{
	int N;
	cin>>N;
	int is_reverse=0;
	deque<int> deq;
	rep(i,N)
	{
		int a;
		cin>>a;
		if(is_reverse)
		{
			deq.push_front(a);
		}
		else
		{
			deq.push_back(a);
		}
		(is_reverse+=1)%=2;
	}
	rep(i,N)
	{
		if(is_reverse) cout<<deq.back();
		else cout<<deq.front();
		if(i!=N) cout<<" ";
		if(is_reverse) deq.pop_back();
		else deq.pop_front();
	}
	cout<<endl;
	return 0;
}


Measured memory_bytes: 4436
macro_rules! scan_sub {
    ( $itr:ident, $t:ty ) => {
        let mut buf = String::new();
        let $itr = {
            while buf.trim().len() == 0 {
                buf = String::new();
                std::io::stdin().read_line(&mut buf).unwrap();
            }
            buf.split_whitespace().map(|n| n.parse::<$t>().unwrap())
        };
    };
}

macro_rules! scan {
    ( $x:ident; Vec<$t:ty> ) => {
        scan_sub!(itr, $t);
        let $x = itr.collect::<Vec<_>>();
    };
    ( $( $x:ident ),*; $t:ty ) => {
        scan_sub!(itr, $t);
        let mut itr = itr;
        $(
            let $x = itr.next().unwrap();
        )*
    };
}

fn eval_schedule(
    d: usize,
    crray: &Vec<i64>,
    data: &Vec<Vec<i64>>,
    schedule: &Vec<usize>
) -> Result<Vec<i64>, String> {
    if d == 0 ||
        crray.len() != 26 ||
        data.len() != d ||
        data[0].len() != 26 ||
        schedule.len() != d
    {
        return Err("Invalid format.".to_string());
    }

    let mut sats = Vec::with_capacity(d);
    let mut sat = 0;
    let mut lasts = vec![0; 26];
    for i in 0..d {
        let s = schedule[i];
        sat += data[i][s];
        lasts[s] = i+1;
        for j in 0..26 {
            sat -= crray[j] * ((i+1 - lasts[j]) as i64);
        }
        sats.push(sat);
    }

    Ok(sats)
}

fn main() {
    scan!(d; usize);
    scan!(crray; Vec<i64>);
    let mut data = vec![vec![]; d];
    for i in 0..d {
        scan!(srray; Vec<i64>);
        data[i] = srray;
    }

    let mut trray = Vec::with_capacity(d);
    for _ in 0..d {
        scan!(t; usize);
        trray.push(t-1);
    }

    let res = eval_schedule(d, &crray, &data, &trray);

    match res {
        Ok(vec) => {
            for v in vec.into_iter() {
                println!("{}", v);
            }
        },
        Err(s) => {
            println!("{}", s);
        }
    }
}


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

int main() {
  int n;
  cin >> n;
  int a;
  cin >> a;
  int b;
  cin >> b;
  if (n == 1) {
    cout << "Hello World" << endl;
  } else {
    cout << a + b << endl;
  }
}
    

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

typedef long long ll;

#define F first 
#define S second 
#define PB push_back
#define MP make_pair 
#define rep(i,a,b) for (ll i=a;i<b;i++)

typedef vector<int> vi;
typedef pair<int,int> pi;


int main()
{
    int h,n;
    cin>>h>>n;
    vi a(n);
    rep(i,0,n) cin>>a[i];

    int sum =0;
    rep(i,0,n)  sum +=a[i];

    if(sum>=h) {
        cout<<"Yes"<<endl;
        return 0;
    } 


    cout<<"No"<<endl;
    return 0; 
}



Measured memory_bytes: 640
//#include "stdafx.h"
#include <stdio.h>
#include <iostream>
#include <set>
#include <queue>
#include <vector>
#include <algorithm>
#include <math.h>
#include <cmath>
#include <string>
#include <cstring>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
#include <stack>
#include <tuple>
#include <numeric>
#include <assert.h>
#include <functional>
#include <unordered_map>
#include <cstdint>

using namespace std;

/*-----------------------------------------------------------------------------
　定義
 -------------------------------------------------------------------------------*/
#define REP(i, n)				for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n)			for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define ALL(a)					(a).begin(),(a).end()
#define INF						2e9
#define MOD						(1000 * 1000 * 1000 + 7)
#define Ceil(x, n)				(((((x))+((n)-1))/n))		/* Nの倍数に切り上げ割り算 */
#define CeilN(x, n)				(((((x))+((n)-1))/n)*n)		/* Nの倍数に切り上げ */
#define FloorN(x, n)			((x)-(x)%(n))				/* Nの倍数に切り下げ */
#define IsOdd(x)				(((x)&0x01UL) == 0x01UL)			
#define IsEven(x)				(!IsOdd((x)))						
#define ArrayLength(x)			(sizeof( x ) / sizeof( x[ 0 ]))
#define	MAX_QWORD				((QWORD)0xFFFFFFFFFFFFFFFF)
#define M_PI					3.14159265358979323846
typedef long long				ll;
typedef unsigned long long int	QWORD;
typedef unsigned long long		SQWORD;
typedef pair<ll, ll>			P;

/*-----------------------------------------------------------------------------
　処理
 -------------------------------------------------------------------------------*/
int main()
{
	int N, K;
	cin >> N >> K;
	vector<int> A(N);
	REP(i, N) cin >> A[i];
	sort(ALL(A));

	int ans = 0;
	int totalCnt = 1;
	while (totalCnt < N) {
		totalCnt += (K - 1);
		ans++;
	}
	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 640
#include <bits/stdc++.h>
#define pii pair<int, int>
#define F first
#define S second
#define int int_fast64_t
using namespace std;
const int MX = 1e5 + 100;
const int mo = 1e9 + 7;
int a[MX], b[MX], cnt[MX];
main() {
    int n; cin >> n;
    priority_queue<pii> pq;
    multiset<pii> que;
    for(int i = 1; i <= n; i ++) {
        cin >> a[i] >> b[i];
        pq.push({-a[i], i});
        pq.push({-b[i], i});
    }
    int sum = 0, Yeee = 0;
    for(int i = 1; i <= n; i ++) {
        pii tmp = pq.top(); pq.pop();
        sum -= tmp.F;
        cnt[tmp.S] ++;
        if(cnt[tmp.S] == 2) Yeee ++;
        que.insert({-tmp.F, tmp.S});
    }
    if(Yeee) return cout << sum, 0;
    int ans = 1ll << 60;
    while(pq.size()) {
        pii tmp = pq.top(); pq.pop();
        auto a = *  --que.end();
        auto b = *----que.end();
        if(a.S == tmp.S) ans = min(ans, sum - b.F - tmp.F);
        else             ans = min(ans, sum - a.F - tmp.F); 
    }
    int sum1 = 0, sum2 = 0;
    for(int i = 1; i <= n; i ++) sum1 += a[i], sum2 += b[i];
    cout << min({ans, sum1, sum2});
}

Measured memory_bytes: 12908
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String c = sc.next();
        String s = "abcdefghijklmnopqrstuvwxyz";
        System.out.print(s.charAt(is(c.charAt(0)) + 1));
    }
    static int is(char c) {
        String s = "abcdefghijklmnopqrstuvwxyz";
        int re = -1;
        for (int i=0; i<26; i++) {
            if (s.charAt(i) == c) {
                re = i;
            }
        }
        return re;
    }
}


Measured memory_bytes: 35560
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a),i##formax=(b);i<i##formax;i++)
#define FORR(i,a,b) for(int i=(a),i##formax=(b);i>=i##formax;i--)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define pcnt __builtin_popcount
#define sz(x) (int)(x).size()
#define maxs(x,y) x=max(x,y)
#define mins(x,y) x=min(x,y)
#define show(x) cout<<#x<<" = "<<x<<endl;
#define all(a) (a.begin()),(a.end())
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define perm(c) sort(all(c));for(bool c##p=1;c##p;c##p=next_permutation(all(c)))
#define uniq(v) sort(all(v));v.erase(unique(all(v)), v.end());
#define bit(n) (1LL<<(n))
#define randInt(l,r) (uniform_int_distribution<ll>(l,r)(rnd))
#define randDouble(l,r) (uniform_real_distribution<double>(l,r)(rnd))

typedef long long ll;
typedef __int128_t lll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
template<class T>using V=vector<T>;
template<class T>using VV=V<V<T>>;
template<class T,class Y>ostream& operator<<(ostream& o,const pair<T,Y>& p){return o<<"("<<p.fi<<", "<<p.se<<")";}
template<typename A,size_t N,typename T>void Fill(A (&array)[N],const T&v){fill((T*)array,(T*)(array+N),v);}
lll gcd(lll a,lll b,lll &x,lll &y){if(!b){x=1;y=0;return a;}lll d=gcd(b,a%b,y,x);y-=a/b*x;return d;}
ll gcd(ll a,ll b){lll x=0,y=0;return gcd(a,b,x,y);}
ll modPow(lll a,lll n,ll m){if(!a)return a;lll p=1;for(;n>0;n>>=1,a=a*a%m)if(n&1)p=p*a%m;return(ll)p;}
bool isPrime(ll n){if(n<2||n%2==0)return n==2;lll t=n-1,d=t/(t&-t);for(lll a:{2,325,9375,28178,450775,9780504,1795265022})if(a%n){for(t=d,a=modPow(a,t,n);t!=n-1&&a!=1&&a!=n-1;a=a*a%n,t=t*2%n);if(a!=n-1&&t%2==0)return 0;}return 1;}
void dout(double d){printf("%.12f\n",d);}
const int IINF = 1e9+6;
const ll LINF = 1e18;
const int MOD = 1e9+7;
const double PI = acos(-1);
const double EPS = 1e-10;
static random_device rd;
static mt19937 rnd(rd());

const int N = 1e5;
double a, b;
main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> a >> b;
  dout(a/b);
}

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

int main() {
	string s;
   cin>>s;
  
  if(s=="Sunny"){
  	cout<<"Cloudy"<<endl;
  }
  
  else if(s=="Cloudy"){
  	cout<<"Rainy"<<endl;
  }
  
  else{
  	cout<<"Sunny"<<endl;
  }
}

Measured memory_bytes: 256
S = input()
res = "Yes"
for x in range(int(len(S)/2)+1):
  if 2*x < len(S):
    if S[2*x] not in ["R","U","D"]:
      res = "No"
  if 2*x + 1 < len(S):
    if S[2*x+1] not in ["L","U","D"]:
      res = "No"
print(res)

Measured memory_bytes: 3060
n = int(input())
a = [0,0] + list(map(int,input().split()))

anslist = [0] * (n+1)

for i in range(len(a)):
  if a[i] > 0:
    anslist[a[i]] += 1

for i in range(1,len(anslist)):
  print(anslist[i])

Measured memory_bytes: 92460
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
 
int main()
{
    ll N, T, Q;
    cin >> N >> T >> Q;
    vector<ll> A(N), D(N), left, right, rleft, rright;
    for (int i = 0; i < N; i++) {
        cin >> A[i] >> D[i];
        if (D[i] == 1) {      
            right.push_back(A[i]);
            rleft.push_back(-A[i]);
        } else {
            left.push_back(A[i]);
            rright.push_back(-A[i]);
        }
    } 

    sort(left.begin(), left.end());
    sort(right.begin(), right.end());
   
    sort(rleft.begin(), rleft.end());
    sort(rright.begin(), rright.end());
 
    ll q;
    for (int i = 0; i < Q; i++) {
        cin >> q; q--;    
        if (D[q] == 1) {
            ll l = lower_bound(left.begin(), left.end(), A[q]) - left.begin();
            if (l == (int)left.size()) {
                cout << A[q] + T << endl;
                continue;
            }
            
            ll ub = upper_bound(right.begin(), right.end(), left[l]) - right.begin()-1;
            ll now = (right[ub] != A[q] ? right[ub] : A[q]); 
            if (right[ub] != A[q]) {
                ll g;
                if (now + T >= left[l] - T) {
                    g = (now + left[l]) / 2;
                } else {
                    g = now + T;
                }
                cout << min(A[q] + T, g) << endl;
            } else {
                if (now + T >= left[l] - T) {
                    cout << (now + left[l]) / 2 << endl;
                } else {
                    cout << now + T << endl;
                }
            }   
        } else {  
            ll l = lower_bound(rleft.begin(), rleft.end(), -A[q]) - rleft.begin();
            if (l == (int)rleft.size()) {
                cout << A[q] - T << endl;
                continue;
            }

            ll ub = upper_bound(rright.begin(), rright.end(), rleft[l]) - rright.begin()-1;
            ll now = (-rright[ub] != A[q] ? -rright[ub] : A[q]);
            if (-rright[ub] != A[q]) {
                ll g;
                if (now - T <= -rleft[l] + T) {
                    g = (now - rleft[l]) / 2;
                } else {
                    g = now - T;
                }
                cout << max(A[q] - T, g) << endl;
            } else {
                if (now - T <= -rleft[l] + T) {
                    cout << (now - rleft[l]) / 2 << endl;
                } else {
                    cout << now - T << endl;
                }
            } 
        }
    }  
    return 0;
}

Measured memory_bytes: 6528
//g++ -std=gnu++14 a.cpp
//#include <bits/stdc++.h>

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <iostream>
#include <istream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <tuple>
#include <iomanip>
#include <random>
#include <math.h>

using namespace std;

#define ll long long
#define rep(i, n) for(ll i = 0; i < (n); i++)
ll MOD = 1e9 + 7;
int INF = 1 << 30;
ll INFL = 1LL << 60;

vector<int> sort(vector<int> &v){
  int l = v.size();
  int i = l-1;
  while(i != 0){
    for(int j = 0;j < i;j++){
      if(v[j] < v[j+1]){
        swap(v[j],v[j+1]);
      }
    }
    i--;
  }
  return v;
}

int main(){
   int N,K;
   cin >> N >> K;
   vector<int> p(N);
   rep(i,N)cin >> p[i];
   sort(p);
   int ans = 0;
   rep(i,K){
     ans += p[N-1-i];
   }
   cout << ans <<endl;

}


Measured memory_bytes: 3556
import math 
 
a,b,x=map(int, input().split())
if x>a*a*b/2:
  t=2*(a*a*b-x)/(a*a*a)
  print(math.degrees(math.atan(t)))
else:
  t=2*x/a/(b*b)
  print(math.degrees(math.atan(1/t)))

Measured memory_bytes: 3316
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>


using namespace std;

typedef long long LL;
typedef vector<LL> VL;
#define REPD(i,a,b) for (LL i=(a);i<(b);i++)
#define REP(i,n) REPD(i,0,n)

using namespace std;


LL inputValue(){
  LL a;
  cin >> a;
  return a;
};

vector<LL> inputVector(LL a){
  vector<LL> rv;
  REP(i, a){
    LL input;
    cin >> input;
    rv.push_back(input);
  }
  return rv;
}

vector<string> inputVectorString(LL a){
  vector<string> rv;
  REP(i, a){
    string input;
    cin >> input;
    rv.push_back(input);
  }
  return rv;
}
vector<vector<LL>> inputVector2D(LL a, LL b){
  vector<vector<LL>> rv;
  REP(i, a){
    rv.push_back(vector<LL>());
    REP(j, b) {
      LL input;
      cin >> input;
      rv.at(i).push_back(input);
    }
  }
  return rv;
}

#if 0
#define debug(d) debug1(__LINE__,#d, d)
void debug1(LL line, const char* name, vector<LL>& v) {
  cout << line << ":" << name << ":vector<LL>(" << v.size() << ") ";
  REP(i, (LL)v.size()) {
    cout << v.at(i) << " ";
  }
  cout << endl;
}
void debug1(LL line, const char* name, LL i) {
  cout << line << ":" << name << ":LL " << i << endl;;
}
void debug1(LL line, const char* name, vector<string>& v) {
  cout << line << ":" << name << ":vector<string>(" << v.size() << ") ";
  REP(i, (LL)v.size()) {
    cout << v.at(i) << " ";
  }
  cout << endl;
}
void debug1(LL line, const char* name, vector<vector<LL>>& v) {
  cout << line << ":" << name << ":vector<vector<LL>>(" << v.size() << ") ";
  REP(i, (LL)v.size()) {
    REP(j, (LL)v.at(i).size()) {
      cout << v.at(i).at(j) << " ";
    }
    cout << ", ";
  }
  cout << endl;
}
#else
#define debug(n)
#endif

int main(int argc, const char * argv[]) {
	cout.precision(16);
  // source code
  LL n = inputValue();
  VL vs = inputVector(n);

  sort(vs.begin(), vs.end());
  debug(vs);
  double r = vs.at(0);
  REPD(i, 1, n) {
    r = (r + vs.at(i)) / 2;
  }
  cout << r << endl;


  return 0;
}


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

using namespace std;


template <typename A, typename B>
string to_string(pair<A, B> p);

template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p);

template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p);

string to_string(const string& s)
{
    return '"' + s + '"';
}

string to_string(const char* s)
{
    return to_string((string) s);
}

string to_string(bool b)
{
    return (b ? "true" : "false");
}

string to_string(vector<bool> v)
{
    bool first = true;
    string res = "{";
    for (int i = 0; i < static_cast<int>(v.size()); i++)
    {
        if (!first)
        {
            res += ", ";
        }
        first = false;
        res += to_string(v[i]);
    }
    res += "}";
    return res;
}

template <size_t N>
string to_string(bitset<N> v)
{
    string res = "";
    for (size_t i = 0; i < N; i++)
    {
        res += static_cast<char>('0' + v[i]);
    }
    return res;
}

template <typename A>
string to_string(A v)
{
    bool first = true;
    string res = "{";
    for (const auto &x : v)
    {
        if (!first)
        {
            res += ", ";
        }
        first = false;
        res += to_string(x);
    }
    res += "}";
    return res;
}

template <typename A, typename B>
string to_string(pair<A, B> p)
{
    return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}

template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p)
{
    return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ")";
}

template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p)
{
    return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ", " + to_string(get<3>(p)) + ")";
}

void debug_out()
{
    cerr << endl;
}

template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T)
{
    cerr << " " << to_string(H);
    debug_out(T...);
}

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif



int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    string s;
    cin >> s;
    int w = 0;
    for (auto x : s)
    {
        w += (x - '0');
    }
    cout << (w % 9 == 0 ? "Yes" : "No") << '\n';
    return 0;
}



Measured memory_bytes: 3720
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <fstream>
#include <sstream>
#include <iomanip>
#define ll long long

using namespace std;

long long MOD = 1000000007;

long long gcd(long long N, long long M){
    while (true){
        if (min(N,M)==0){
            return max(N,M);
        }else if (N>M){
            N%=M;
        }else{
            M%=N;
        }
    }
}

long long lcm(long long N, long long M){
    return N*M/gcd(N,M);
}

int main(){
    ll X;
    cin >> X;

    ll l=lcm(X,360);
    cout << l/X << endl;
}

Measured memory_bytes: 3592
n = int(input())
D = list(map(int, input().split()))

if n == 1:
    print(D[0])
    exit()

C = [0]*13
C[0] = 1
for i in range(n):
    C[D[i]] += 1

D = []
E = []
for i in range(13):
    if i != 0:
        if C[i] >= 3:
            print(0)
            exit()
        elif C[i] == 2:
            D.append(i)
            D.append(-i)
        elif C[i] == 1:
            E.append(i)
        else:
            continue
    else:
        if C[i] >= 2:
            print(0)
            exit()
        elif C[i] == 1:
            D.append(i)
        else:
            continue

p = len(D)
q = len(E)
#print(E)
import copy
if q == 0:
    ans = 25
    for i in range(p-1):
        for j in range(i+1, p):
            ans = min(ans, min(abs(D[i]-D[j]), 24-abs(D[i]-D[j])))
    print(ans)
else:
    ans = []
    for i in range(2**q):
        D_ = copy.copy(D)
        for j in range(q):
            if (i >> j)&1:
                D_.append(E[j])
            else:
                D_.append(-E[j])
        p = len(D_)
        temp = 25
        #print(D)
        for i in range(p-1):
            for j in range(i+1, p):
                temp = min(temp, min(abs(D_[i]-D_[j]), 24-abs(D_[i]-D_[j])))
        ans.append(temp)
    print(max(ans))


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

int main(){
  ll n,m,ans=0,wa=0;
  cin >> n >> m;
  vector<ll> p(m);
  vector<string> s(m);
  for(ll i=0;i<m;i++){
    cin >> p.at(i) >> s.at(i);
  }
  vector<ll> a(n+1),w(n+1);
  for(ll i=0;i<m;i++){
    if(s.at(i) == "AC"){
      if(a.at(p.at(i)) == 0){
        a.at(p.at(i))++;
        ans++;
        wa += w.at(p.at(i));
      }
    }
    else w.at(p.at(i))++;
  }
  cout << ans <<' '<< wa << endl;
  
  return 0;
}


Measured memory_bytes: 8064
#include<bits/stdc++.h>
#define ll long long int
#define fast ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define pb push_back 
using namespace std;

int main()
{ 
  fast;
  ll n,x;
  cin>>n;

vector<ll> v;

for(ll i=0;i<n;i++)
{
  cin>>x;
  auto it=upper_bound(v.begin(),v.end(),-x);

  if(it==v.end())
    v.pb(-x);
  else *it=-x;
}
cout<<v.size()<<endl;
  }

Measured memory_bytes: 1400
#include<stdio.h>
int main()
{
   int n,a;scanf("%d%d",&n,&a);
   if(n>=500)
   {
       int d=n%500;
       if(d==0||d<=a)printf("Yes");
       else printf("No");
   }
   else if(n<500)
   {
       if(n<=a)printf("Yes");
       else printf("No");
   }
}


Measured memory_bytes: 1668
#pragma region template
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using vld = vector<ld>;
using vvld = vector<vld>;
using vvvld = vector<vvld>;
using vs = vector<string>;
using pll = pair<ll, ll>;
using vp = vector<pll>;
template <typename T>
using pqrev = priority_queue<T, vector<T>, greater<T>>;
#define rep(i, n) for (ll i = 0, i##_end = (n); i < i##_end; i++)
#define repb(i, n) for (ll i = (n)-1; i >= 0; i--)
#define repr(i, a, b) for (ll i = (a), i##_end = (b); i < i##_end; i++)
#define reprb(i, a, b) for (ll i = (b)-1, i##_end = (a); i >= i##_end; i--)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((ll)(x).size())
//*
constexpr ll MOD = 1e9 + 7;
/*/
constexpr ll MOD = 998244353;
//*/
constexpr ll INF = 1e+18;
constexpr ld EPS = 1e-12L;
constexpr ld PI = 3.14159265358979323846L;
constexpr ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }
constexpr ll LCM(ll a, ll b) { return a / GCD(a, b) * b; }
template <typename S, typename T>
constexpr bool chmax(S &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <typename S, typename T>
constexpr bool chmin(S &a, const T &b) {
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
#ifdef OJ_LOCAL
#include "dump.hpp"
#else
#define dump(...) ((void)0)
#endif
template <typename T>
bool print_(const T &a) {
  cout << a;
  return true;
}
template <typename T>
bool print_(const vector<T> &vec) {
  for (auto &a : vec) {
    cout << a;
    if (&a != &vec.back()) {
      cout << " ";
    }
  }
  return false;
}
template <typename T>
bool print_(const vector<vector<T>> &vv) {
  for (auto &v : vv) {
    for (auto &a : v) {
      cout << a;
      if (&a != &v.back()) {
        cout << " ";
      }
    }
    if (&v != &vv.back()) {
      cout << "\n";
    }
  }
  return false;
}
void print() { cout << "\n"; }
template <typename Head, typename... Tail>
void print(Head &&head, Tail &&... tail) {
  bool f = print_(head);
  if (sizeof...(tail) != 0) {
    cout << (f ? " " : "\n");
  }
  print(forward<Tail>(tail)...);
}
#pragma endregion

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(20);
  ll n;
  cin >> n;
  ll ans = 0;
  ans += n/500*1000;
  n %= 500;
  ans += n/5*5;
  print(ans);
}


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

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

    int n;
    cin >> n;
    int a[n][3], dp[n][3];

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

    for (int j = 0; j < 3; j++) {
        dp[0][j] = a[0][j];
    }

    for (int i = 1; i < n; i++) {
        for (int j = 0; j < 3; j++) {
            int mx = 0;
            for (int k = 0; k < 3; k++) {
                if (j != k) {
                    mx = max (dp[i-1][k], mx);

                }
            }
            dp[i][j] = mx + a[i][j];
        }
    }

    cout << max({dp[n-1][2], dp[n-1][1], dp[n-1][0]}) << "\n";
    return 0;
}


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

#define ll long long
#define rep(A,B,C) for(A=B;A<C;++A)
#define pii pair<int,int>
#define pll pair<ll,ll>

#define fi first
#define se second
#define all(A) A.begin(),A.end()

using namespace std;

/////////////////////////////////////////////////////

ll N;
char As[30];
ll A[202020];
pll B[202020];
ll i, j, k;

ll mk[40];



int main(){
    scanf("%lld", &N);
    rep(i,0,N){
        scanf("%s", As);
        for (j = 0;As[j]&& As[j] != '.';++j){
            A[i] *= 10;
            A[i] += As[j] - '0';
        }
        if(!As[j]){
            A[i] *= 1e9;
            continue;
        }
        ++j;
        for (k = 0; As[j+k];++k){
            A[i] *= 10;
            A[i] += As[j + k] - '0';
        }
        rep(k,k,9){
        A[i] *= 10;
        }
    }
    const ll r = 1e9;
    rep(i,0,N){
        ll a = A[i];
        ll b2 = 0, b5 = 0;
        while(a%2==0){
            a /= 2;
            ++b2;
        }
        while(a%5==0){
            a /= 5;
            ++b5;
        }
        B[i] = {b2, b5};
    }
    sort(B, B + N);
    j = N - 1;
    ll ans = 0;
    rep(i,0,N){
        //printf("%lld,%lld,%lld\n", i, B[i].fi, B[i].se);
        while(i<j&&B[i].fi+B[j].fi>=18){
            ++mk[B[j].se];
            --j;
        }
        if(i>j){
            --mk[B[i].se];
        }
        rep(k,18-B[i].se,30){
            ans += mk[k];
        }
        
    }
    printf("%lld\n", ans);
    return 0;
}

Measured memory_bytes: 8432