akhauriyash/Code-Regression huggingface dataset:
#include <cstring>
#include <iostream>
using namespace std;
int n, sx, sy, tx, ty; bool ok[11][10][10];
int main() {
	while (cin >> sx >> sy, sx + sy) {
		cin >> n; memset(ok, false, sizeof(ok));
		ok[0][sy][sx] = true;
		for (int i = 1; i <= n; i++) {
			cin >> tx >> ty;
			for (int j = 0; j < 10; j++) {
				for (int k = 0; k < 10; k++) {
					if (!ok[i - 1][j][k]) continue;
					for (int l = -2; l <= 2; l++) {
						for (int m = -2; m <= 2; m++) {
							if (0 <= j + l && j + l < 10 && 0 <= k + m && k + m < 10) {
								if (abs(ty - j - l) <= 1 && abs(tx - k - m) <= 1) {
									if ((abs(l) == 2 || abs(m) == 2) && abs(l * m) != 4) {
										ok[i][j + l][k + m] = true;
									}
								}
							}
						}
					}
				}
			}
		}
		int ret = 0;
		for (int i = 0; i < 10; i++) {
			for (int j = 0; j < 10; j++) {
				if (ok[n][i][j]) ret = 1;
			}
		}
		cout << (ret ? "OK" : "NA") << endl;
	}
}

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

int main() {
    string s;
    cin >> s;
    lint sum = 0;
    for (int i = 0; i < s.length(); i++) {
        lint keta = s[i] - '0';
        sum += keta;
    }
    if (sum % 9 == 0) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 3716
import sys
def I(): return int(sys.stdin.readline().rstrip())
N = I()
dp = [float('INF')]*(N+1) #1_indexed
dp[0] = 0
for i in range(N+1):
    if i-1>=0:
        dp[i] = min(dp[i],dp[i-1]+1)
    num6,num9 = 6,9
    while i-num6>=0:
        dp[i] = min(dp[i],dp[i-num6]+1)
        num6 *= 6
    while i-num9>=0:
        dp[i] = min(dp[i],dp[i-num9]+1)
        num9 *= 9
print(dp[-1])


Measured memory_bytes: 3828
#include <iostream>
#include <math.h>
#include <algorithm>

using namespace std;

int main(){
  int n,m,k,cnt=0;
  int a[300000] = {0};
  int b[300000] = {0};

  cin >> n >> m >> k;
  for(int i = 0; i < n; i++){
    cin >> a[i];
    if ( i == 0 ) continue;
    if(2147483646-a[i] < a[i-1]) a[i] = 2147483646;
    else if(i!=0) a[i] += a[i-1];
  }

  for(int i = 0; i < m; i++){
    cin >> b[i];
    if ( i == 0) continue;
      if(2147483646-b[i] < b[i-1]) b[i] = 2147483646;
    else if(i!=0) b[i] += b[i-1];
  }
  int nn=n,mm=m;
  for(int i = 0; i < n; i++){
    if (a[i] > k) {nn = i;break;}
  }
  for(int i = 0; i < m; i++){
    if (b[i] > k) {mm = i;break;}
  }
  if(mm == 0) mm = 1;
  if (nn == 0) nn = 1;
  int jj = mm-1;
  for(int i = 0; i < nn; i++){
    for(int j = jj; j >= 0; j--){
      if(2147483646 - a[i] < b[j]) continue;
      if(a[i] + b[j] <= k) {jj = j;cnt = max(cnt,i+j+2);break;}
    }
  }

  for(int i = nn-1; i >= 0; i --){
    if(a[i] <= k) {cnt = max(cnt,i+1);break;}
  }
  for(int i = mm-1; i >= 0; i --){
    if(b[i] <= k) {cnt = max(cnt,i+1);break;}
  }


  cout << cnt;
}


Measured memory_bytes: 5980
#include <iostream>

using namespace std;
using ll = long long;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define IN(v) int v;cin>>v;
#define OUT(v) cout<<v<<"\n"
const ll INF = 1LL << 60;
const int MAX_N = 2e5;

ll sum[MAX_N + 1];
int main() {
  cin.tie(0); ios::sync_with_stdio(false);

  IN(N);

  REP(i, N) {
    IN(a);
    sum[i+1] = (ll)sum[i] + a;
  }
  ll ans = INF;
  FOR(i, 1, N) {
    ll x = sum[i];
    ll y = sum[N] - sum[i];
    ans = min(ans, abs(x - y));
  }
  OUT(ans);

  return 0;
}


Measured memory_bytes: 1792
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
using namespace std;
int fa[101010][17];
int x[101010];
int main()
{
	int n,l,r,L,q,ans;
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
		scanf("%d",&x[i]);
	scanf("%d",&L);
	l=r=1;
	while(l<n)
	{
		while(r<n&&x[r+1]-x[l]<=L)
			r++;
		fa[l][0]=r;
		l++;
	}
	for(int i=0;i<=16;i++)
		fa[n+1][i]=n+1;
	fa[n][0]=n+1;
	for(int i=n;i>=1;i--)
		for(int j=1;j<=16;j++)
			fa[i][j]=fa[fa[i][j-1]][j-1];
	scanf("%d",&q);
	for(int i=1;i<=q;i++)
	{
		scanf("%d%d",&l,&r);
		if(l>r)
			swap(l,r);
		ans=0;
		for(int j=16;j>=0;j--)
			if(fa[l][j]<=r)
			{
				l=fa[l][j];
				ans+=(1<<j);
			}
		if(l!=r)
			ans++;
		printf("%d\n",ans);
	}
	return 0;
}

Measured memory_bytes: 7808
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
typedef  long long ll;
ll gcd(ll x,ll y){
   if(y==0) return x;
   else return gcd(y,x%y);
}
ll lcm(ll x,ll y){
   return x/gcd(x,y)*y;
}
using namespace std;
int main(){
   deque<char> dq;
   string s;
   cin>>s;
   for(int i=0;i<s.size();i++){
       dq.push_back(s[i]);
   }
   int flag=0;
   int count=0;
   int q;
   cin>>q;
   rep(i,q){
       
       int k;
       cin>>k;
       if(k==1){
         if(flag==0) flag=1;
         else flag=0;
         count++;       
       }
       else{
           int f;
           char c;
           cin>>f>>c;
           if(f==1){
               if(flag==0){
               dq.push_front(c);
               }
               else{
                   dq.push_back(c);
               }
           }
           else{
               if(flag==0){
               dq.push_back(c);
               }
               else dq.push_front(c);
           } 
       }
   }
       if(count%2==1) reverse(dq.begin(),dq.end());
        rep(i,dq.size()){
           cout<<dq[i];
       }

   

   
return 0;
}


Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
#define REP(i,x,n) for(int i=x;i<(int)n;i++)
#define rep(i,n) REP(i,0,n)
#define sp(p) cout<<setprecision(16)<<fixed<<p<<endl;
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define SORT(a) sort(all(a))
#define RSORT(a) sort(rall(a))
#define UNIQ(a) unique(all(a))
#define vout(v) for(int i=0;i<(int)v.size()-1;i++){cout<<v[i]<<" ";}cout<<v[v.size()-1]<<"\n";
#define vmin(v) *min_element(all(v))
#define vmax(v) *max_element(all(v))
#define debg(a) cerr<<#a<<" "<<a<<endl;
#define show(a) for(cont &y:a){for(cont &x:y){cout<<x<<" ";}cout<<endl;}
template<class T>inline int out(const T &t){ print(t); putchar('\n'); return 0; }
template<class T>inline T gcd(T a,T b){if(b==0)return a; return(gcd(b,a%b));}
template<class T>inline T lcm(T a,T b){return a/gcd(a,b)*b;}
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef vector<ll> V;
// const long long MOD=1000000007;
const long long INF = 1e18;
#define EPS (1e-7)
#define PI (acos(-1))
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) { a = b; return true; }
    return false;
}
template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) { a = b; return true; }
    return false;
}


void solve_ref(long long S){
    ll n = 3;
    for (ll bit = 0; bit < (1<<n); bit++) {
        V v;
        for (ll i = 0; i < n; i++) {
            if(bit & (1<<i)) {
                v.push_back(i);
            }
        }
        cout << bit << ": ";
        for (ll i = 0; i < v.size(); i++) {
            cout << v[i] << " ";
        }
        cout << endl;
    }
}

void solve(long long S){
    ll n = log10(S)+1;
    string str = to_string(S);
    V v;
    ll tmp = S;
    ll sum =0;
    for (ll i = 0; i < n; i++) {
        v.push_back(tmp%10);
        tmp/=10;
    }
    n--;
    // if(S<1000) vout(v);
    for (ll bit = 0; bit < (1<<n); bit++) {
        V va;
        tmp = S;
        for (ll i = 0; i <= n; i++) {
            if(bit & (1<<i)) {
                // va.push_back(v[i]);
                // va.insert(va.begin()+i, 10);
                ll p = pow(10,n-i);
                va.push_back(tmp/p);
                tmp = tmp % p;
            }
        }
        va.push_back(tmp);
        // if (S<1000){
        // cout << bit << ": ";
        // for (ll i = 0; i < va.size(); i++) {
        //     cout << va[i] << " ";
        // }
        // cout << endl;}
        sum+=accumulate(all(va), 0LL);
    }
    cout << sum << "\n";
}

int main(){
    long long S;
    scanf("%lld",&S);
    solve(S);
    return 0;
}


Measured memory_bytes: 512
import java.util.*

fun main(args:Array<String>){
    val s = readLine()!!
    var cnt1 = 0
    var cnt2 = 0
    for(i in 0 until s.length){
        if(i % 2 == 0){
            if(s[i] == '0') cnt2++
            else cnt1++
        }
        else{
            if(s[i] == '0') cnt1++
            else cnt2++
        }
    }
    println(Math.min(cnt1, cnt2))
}


Measured memory_bytes: 34068
#include<stdio.h>

int main(void) {
	int n,a,b,x=0,y;

	scanf("%d %d %d",&n,&a,&b);
	y = a;
	if (a > b)y = b;
	if (n < (a + b))x = a + b - n;
	printf("%d %d\n",y,x);
	return 0;
}

Measured memory_bytes: 128
#define STOPIT
#include <bits/stdc++.h>
#define loop(n) for (lint ngtkana_is_a_genius = 0; ngtkana_is_a_genius < lint(n); ngtkana_is_a_genius++)
#define rep(i, begin, end) for (lint i = lint(begin); (i) < lint(end); i++)
#define all(v) v.begin(), v.end()
#define rand(l, r) std::uniform_int_distribution<>(l, r)(mt)
using lint = long long;
auto mt = std::mt19937_64(std::random_device{}());
auto cmn = [](auto& a, auto b){ if (a > b) {a = b; return true;} return false; };
auto cmx = [](auto& a, auto b){ if (a < b) {a = b; return true;} return false; };
void debug_impl() { std::cerr << std::endl; }
template <typename Head, typename... Tail>
void debug_impl(Head head, Tail... tail) { std::cerr << " " << head; debug_impl(tail...); }
#ifndef STOPIT
#define debug(...)\
  do {\
    std::cerr << std::boolalpha << "[" << #__VA_ARGS__ << "]:";\
    debug_impl(__VA_ARGS__);\
    std::cerr << std::noboolalpha;\
  } while (false)
#else
#define debug(...) {}
#endif

template < typename Container, typename Value = typename Container::value_type, std::enable_if_t<!std::is_same< Container, std::string >::value, std::nullptr_t> = nullptr>
std::istream& operator>> (std::istream& is, Container& v)
  { for (auto & x : v) { is >> x; } return is; }

template < typename Container, typename Value = typename Container::value_type, std::enable_if_t<!std::is_same< Container, std::string >::value, std::nullptr_t> = nullptr >
std::ostream& operator<< (std::ostream& os, Container const& v) {
 os << "{";
  for (auto it = v.begin(); it != v.end(); it++)
    {os << (it != v.begin() ? "," : "") << *it;}
  return os << "}";
}

int main() {
  std::cin.tie(0); std::cin.sync_with_stdio(false);
  std::string s; std::cin >> s;
  int n = s.length();
  std::vector<int> a(n);
  std::transform(all(s), a.begin(), [](char c){ return c - '0'; });
  debug(a);

  int i = n / 2;
  if (a.at(i)) {
    for (int & x : a) x^=1;
  }
  while (true) {
    int j = n - 1 - i;
    if (i == n || a.at(i) || a.at(j)) {
      break;
    }
    debug(i,j);
    i++;
  }
  debug(i);
  int ans = i;
  std::cout << ans << std::endl;
  return 0;
}

Measured memory_bytes: 848
import math

N = int(input())


#試し割法
def trial_division(n):
    #素因数を格納するリスト
    factor = []
    #2から√n以下の数字で割っていく
    tmp = int(math.sqrt(n)) + 1
    for num in range(2,tmp):
        while n % num == 0:
            n //= num
            factor.append(num)
    #リストが空ならそれは素数
    if not factor:
        return 'prime number'
    else:
        factor.append(n)
        return factor

prime_cnt = {}
for i in range(1, N + 1):
  ps = trial_division(i)
  if ps == "prime number":
    ps = [i]
  for d in ps:
    if d == 1:
      continue
    if d in prime_cnt:
      prime_cnt[d] += 1
    else:
      prime_cnt[d] = 1
      
#print(prime_cnt)
  
ans = 1
for d in prime_cnt:
  ans *= prime_cnt[d] + 1
  ans %= 1000000007
  
print(ans)

Measured memory_bytes: 3064
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
int n;
cin >> n;
int a[3];
while(cin >>a[0]>>a[1]>>a[2]){
sort(a,a+3);
if((a[0] * a[0]) + (a[1] * a[1] ) == (a[2] * a[2])) cout << "YES" << endl;
else cout << "NO"<<endl;
}
return 0;
}

Measured memory_bytes: 3148
#include <iostream>
#include <vector>
#include <chrono>
#include <random>
#include <cassert>

std::mt19937 rng((int) std::chrono::steady_clock::now().time_since_epoch().count());

int main() {
	std::ios_base::sync_with_stdio(false); std::cin.tie(NULL);
	int a, b, c, d, e;
	std::cin >> a >> b >> c >> d >> e;
	std::cout << std::max(0, (c - a) * 60 + (d - b) - e) << '\n';
}

Measured memory_bytes: 3656
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        mut x: u64,
        y: u64,
    }

    let mut ans = 0;
    while x <= y {
        x *= 2;
        ans += 1;
    }

    println!("{}", ans);
}


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

using namespace std;

int dirs[4][2]={{-1, 0}, {0, 1}, {1, 0}, {0, -1}};

int main()
{
    //freopen("inp.in", "r", stdin);
    //ios::sync_with_stdio(false);
    vector<long long> v(3);
    for(int i=0; i<3; i++) scanf("%lld", &v[i]);
    sort(v.begin(), v.end());
    long long k;
    scanf("%lld", &k);
    for(int i=0; i<k; i++) v[2]*=2;
    long long ans=v[0]+v[1]+v[2];
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
var arr=readLine()!.characters.split{$0==" "}.map{Int(String($0))!}

var n = arr[0]
var k = arr[1]
var q = arr[2]

var p = Array(count: n, repeatedValue: 0 )

var i = 0
var a = 0
for i in 0..<q {
  a=Int(readLine()!)!
  p[a-1] += 1
}

i = 0
for i in 0..<n {
  if( ( k - q + p[i] ) > 0) {
    print( "Yes" )
  } else {
    print( "No" )
  }
}

Measured memory_bytes: 4080
#include<bits/stdc++.h>
#define F first
#define S second
#define int long long
#define double long double
using namespace std;
typedef pair<int,int> P;
typedef pair<int,P> iP;
typedef pair<P,int> Pi;
typedef pair<P,P> PP;
double eps=1e-8;
int mod=1e9+7;
int inf=1LL<<60;

priority_queue<P,vector<P>,greater<P> > pq;

signed main(){
  int n,x,a[100];
  cin>>n>>x;
  for(int i=0;i<n;i++)cin>>a[i];
  sort(a,a+n);
  int c=0;
  while(1){
    if(c>=n||x-a[c]<0)break;
    x-=a[c];
    c++;
  }
  if(c==n&&x)c--;
  cout<<c<<endl;
  return 0;
}


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

int main(){
  string s,a="CODEFESTIVAL2016";cin>>s;
  int ans=0;
  REP(i,16){if(s[i]^a[i])++ans;}
  cout<<ans<<"\n";
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
	int n;
	int min = 1000001;
	int max = -1000001;
	long long int y=0;
	cin >> n;
	for (int i = 0; i < n; i++)
	{
		int a;
		cin >> a;
		if (min > a) min = a;
		if (max < a) max = a;
		y = y + a;

	}
	cout << min <<" "<< max <<" "<< y<<endl;

	return 0;
}

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

double n,m,a[999999],sum;
int main(){
	cin>>n>>m;
	for(int i=0;i<m;i++){
		cin>>a[i];
		sum+=a[i];
	}
	if(sum>n)cout<<-1;
	else cout<<n-sum;
	return 0;
}

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

int main(){
    int N=0, W=0, S=0, E=0;
    char s[1100];
    int len;
    int sum;

    scanf("%s", &s);
    len = strlen(s);
    for(int i=0; i<len; i++){
        if(s[i]=='N'){
            N=1;
        }else if(s[i]=='W'){
            W=1;
        }else if(s[i]=='S'){
            S=1;
        }else if(s[i]=='E'){
            E=1;
        }
    }
    sum = N+W+S+E;
    if(sum==1 || sum==3){
        printf("No");
    }else if(N==1 && S==0){
        printf("No");
    }else if(W==1 && E==0){
        printf("No");
    }else if(S==1 && N==0){
        printf("No");
    }else if(E==1 && W==0){
        printf("No");
    }else{
        printf("Yes");
    }

    return 0;
}

Measured memory_bytes: 128
N = int(input())
alp = "abcdefghijklmnopqrstuvwxyz"
L = ""

for i in range(1,99):
    if N<=26**i:
        N -= 1
        for j in range(i):
            ind = int(N%26)
            L = alp[ind]+L
            N = (N-ind)/26
        break
    else:
        N -= 26**i
print(L)

Measured memory_bytes: 9184
#include<iostream>
#include<string>
#include<vector>
#include<numeric>
#include<math.h>
#include<algorithm>
#include<iomanip>
#include<list>
using namespace std;

int main() {

	long N;
	cin >> N;

	string S;
	cin >> S;

	long cnt = 1;
	string t;

	for (long j = 0; j < N - 1; j++) {
		if (S.substr(j, 1) != S.substr(j + 1, 1)) {
			cnt += 1;
		}
	}

	cout << cnt << endl;

	return 0;
}



Measured memory_bytes: 512
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORR(i, m, n) for (int i = m; i >= n; i--)
#define INF 1e9;
using namespace std;
typedef long long ll;
int main() {
  ll L, R;
  cin >> L >> R;
  ll a = L % 2019;
  ll b = R - L + 1;
  bool c = false, d = false;
  int ans = a * (a + 1);
  if (a + b > 2019) {
    cout << 0;
    return 0;
  }
  FOR(i, a, a + b) {
    FOR(j, i + 1, a + b) { ans = min(ans, (i * j) % 2019); }
  }

  cout << ans;
  return 0;
}

Measured memory_bytes: 256
/*
	http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0005
	GCD and LCM
*/

#include <stdio.h>
int main(void)
{
	int a,b,temp,a_orig,b_orig;
	long int gcd = 0, lcm = 0;
	while(scanf("%ld %ld", &a_orig, &b_orig)!=EOF)
	{
		if (a_orig < b_orig)
		{
			long x;
			x		= b_orig;
			b_orig	= a_orig;
			a_orig	= x;
		}

		a = a_orig;
		b = b_orig;

		while (b != 0){
			long temp;
			temp = b;
			b = a % b;
			a = temp;
		}

		gcd = a;

		/* lcm = a * b_orig / gcd ???????????§????????¨????????????
		20???*20?????¨???????????¨long??§??????????????????????????§???????????????
		*/

		lcm = (a_orig / gcd) * b_orig;

		printf("%d %ld\n", gcd, lcm);

	}
	return 0;
}

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

#define REP(i,num) for(int i=0;i<(num);++i)
#define LOOP(i) while(i--)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto pitr=c.begin();pitr!=c.end();++pitr){cout<<*pitr;if(next(pitr,1)!=c.end())cout<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

using namespace std;
using ll = long long;

constexpr ll atcoder_mod = 1e9+7;

template<typename T=int>
T in(){T x; cin >> x; return (x);}
template<typename T=int,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in<T>();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

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

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);

	int K=in(),X=in();
	out(500*K>=X?"Yes":"No");
	return 0;
}

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

using namespace std;

int main()
{
	string tc, hc;
	int n, ts = 0, hs = 0;

	cin >> n;

	for (int i = 0; i < n; i++) {
		cin >> tc >> hc;
		if (tc > hc) ts += 3;
		else if (tc < hc) hs += 3;
		else{
			ts++;
			hs++;
		}
	}

	cout << ts << " " << hs << endl;

	return 0;
}

Measured memory_bytes: 1208
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(int (i) = (s);(i) <= (e);(i)++)
#define all(x) x.begin(),x.end()

int main(){
  int N;
  cin >> N;
  int now = 0;
  int X = 0;
  int Y = 0;
  rep(i,0,N - 1){
    int t,x,y;
    cin >> t >> x >> y;
    int need = abs(X - x) + abs(Y - y);
    if(t - now >= need && (t - now - need) % 2 == 0){

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

  cout << "Yes" << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <numeric>
#include <queue>
#include <unordered_map>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <sstream>
#include <stack>
#include <map>
#include <set>

#define STARTUP {(cin.tie(0));\
 (ios::sync_with_stdio(false));}

#define REP(i,a) for(int i = 0;i < (a);++i)
#define FOR(i,a,b) for(int i = (a);i < (b); ++i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SIZE(obj) (int)(obj).size()
#define MAX(list) std::max(list)
#define MIN(list) std::min(list)
#define YESNO(cond,yes,no){cout <<((cond)?(yes):(no))<<endl; }
#define SORT(list) sort(ALL((list)));
#define RSORT(list) sort((list).rbegin(),(list).rend())
#define CINVEC(vec) REP(i,(vec).size()) cin>>(vec)[i];

template<typename T>
T round_up(const T& a, const T& b) {
    return (a + (b - 1)) / b;
}

template <typename T1, typename T2>
std::istream& operator>>(std::istream& is, std::pair<T1, T2>& p) {
    is >> p.first >> p.second;
    return is;
}

template <typename T1, typename T2>
std::ostream& operator<<(std::ostream& os, std::pair<T1, T2>& p) {
    os << p.first << p.second;
    return os;
}

using ll = long long;
using namespace std;
ll mod = 1'000'000'007;

const int INF = 1'050'000'000;

int main() {
    STARTUP;

    int N, K;
    cin >> N >> K;
    ll ans = K;
    REP(i, N - 1) {
        ans *= (K - 1);
    }

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

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

#define ul unsigned long long
#define ll long long

ul perm(ul n)
{
  if (n == 1)
    return 1;
  else
    return n * perm(n - 1);
}
bool ident(ul *x,ul *y,ul n) 
{
  for (size_t i = 0; i < n; i++)
  {
    if (x[i]!=y[i])return false;
  }
  return true;
}

int main()
{
  size_t n;
  ul x[8],y[8];
  cin>>n;
  for (size_t i = 0; i < n; i++)
  {
    cin >> x[i];
  }
  for (size_t i = 0; i < n; i++)
  {
    cin >> y[i];
  }

  ul prm[8]={1,2,3,4,5,6,7,8};

  ll px,py,counter=1;
  do {
    if (ident(prm, x, n))
      px = counter;
    if (ident(prm, y, n))
      py = counter;
    counter++;
  } while (next_permutation(prm,prm+n));

  //cout << fixed<<setprecision(16);
  cout<<abs(px-py)<<endl;

  return 0;
}


Measured memory_bytes: 256
import numpy as np

N = int(input())
tasks = np.empty(shape=(N,2), dtype=np.int64)
for i in range(N):
    a, b = map(int, input().split())
    tasks[i,0] = a
    tasks[i,1] = b
tasks = tasks[np.argsort(tasks[:,1])]

progress = 0
deadline = False
for i in range(N):
    progress += tasks[i,0]
    if progress > tasks[i,1]:
        deadline = True
        break

print('No' if deadline else 'Yes')

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

int main()
{
  int n,k;
  cin>>n>>k;
  int arr[n];
  for(int i=0;i<n;i++)
    cin>>arr[i];
    int dp[n+1];
    dp[0]=0;
    dp[2]=abs(arr[1]-arr[0]);
    for(int i=3;i<n+1;i++)
    {
    	int sum=INT_MAX;
    	int t=i;
    	for(int j=1;j<=k;j++)
    	{
    		if(i-j>=1)
				sum=min(sum,dp[i-j]+abs(arr[i-1]-arr[i-j-1]));
		}
		dp[i]=sum;
	}
  cout<<dp[n];
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <map>
using namespace std;
int MOD = 2019;
int D[200005];
typedef long long ll;
int main() {
  ios::sync_with_stdio(false);
  int N;
  string S;
  cin >> S;
  map<int, int> m;
  m[0]++;
  int r = 1;
  for (int i=S.size()-1; i>=0; i--) {
    D[i] = (D[i+1] + (S[i] - '0') * r) % MOD;
    m[D[i]]++;
    r = (r * 10) % MOD;
  }
  ll ret = 0;
  for (auto it: m) {
    ll d = it.second;
    ret += d * (d-1) / 2;
  }
  cout << ret << endl;
}

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

using namespace std;

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

	int n;
	cin >> n;

	vector<pair<int, int> > a;
	a.resize(n);

	for(int i = 0; i < n; ++i) {
		cin >> a[i].first;
		a[i].second = i;
	}

	sort(a.begin(), a.end(), greater<pair<int, int> > ());

	vector<vector<long long> > dp;
	dp.resize(n + 1);

	for(int i = 0; i < n + 1; ++i) {
		dp[i].resize(n + 1);
	}

	for(int i = 0; i <= n; ++i) {
		for(int j = 0; j + i < n; ++j) {
			dp[i + 1][j] = max(dp[i + 1][j], dp[i][j] + 1LL * a[i + j].first * abs(a[i + j].second - i));
			dp[i][j + 1] = max(dp[i][j + 1], dp[i][j] + 1LL * a[i + j].first * abs(n - 1 - j - a[i + j].second));
		}
	}

	long long ans = 0;

	for(int i = 0; i < n + 1; ++i) {
		ans = max(ans, dp[i][n - i]);
	}

	cout << ans << '\n';

	return 0;
}


Measured memory_bytes: 34628
#include<stdio.h>

int main(){
    int N, K, ans = 1;
    scanf("%d", &N);
    scanf("%d", &K);
    for(int i = 0; i < N; i++){
        if(ans * 2 < ans + K){
            ans *= 2;
        }else{
            ans += K;
        }
    }
    printf("%d", ans);
}

Measured memory_bytes: 128
s=input()
t=input()
ans=1000
if(len(s)==len(t)):
  tmp=0
  for i in range(len(s)):
    if(s[i]!=t[i]):
      tmp+=1
  ans=min(tmp,ans)
for i in range(len(s)-len(t)):
    tmp=0
    for j in range(len(t)):
        if(s[i+j]!=t[j]):
            tmp+=1
    ans=min(ans,tmp)
print(ans)

Measured memory_bytes: 72564
import java.util.Scanner;

public class Main {
	public static final int[] coin = {500,100,50,10,5,1};
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while(true) {
			int n = 1000 - sc.nextInt();
			if (n==1000) {
				break;
			}
			int ans = 0;
			for(int i=0;i<coin.length;i++) {
				if (n>=coin[i]) {
					ans += n / coin[i];
					n -= coin[i] * (n/coin[i]);
				}
			}
			System.out.println(ans);
		}
	}
}

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

int main() {
    string s;
    cin>>s;
    int ans=0;
    if(s=="RRR"){
        ans=3;
    }else if(s=="RRS" || s=="SRR"){
        ans=2;
    }else if(s=="RSS" || s=="SRS" || s=="SSR" || s=="RSR"){
        ans=1;
    }else ans=0;
       
    
    cout<<ans<<endl;
    
    return 0;
    
    
}


Measured memory_bytes: 3604
using System;
using System.Linq;
using System.Collections.Generic;
using System.IO;

namespace AOJV0
{
    class P0004
    {
        static void Main()
        {
            foreach(var s in EnumerateInputs()
                            .Select(x => x.Split(' '))
                            .Select(x => x.Select(double.Parse)))
            {
                var abc = s.Take(3).ToArray();
                var def = s.Skip(3).ToArray();
                var r1 = abc.Select(d => d * def[0]).ToArray();
                var r2 = def.Select(d => d * abc[0]).ToArray();
                var y = Math.Round((r1[2] - r2[2]) / (r1[1] - r2[1]) * 1000, MidpointRounding.AwayFromZero) / 1000;
                var x = Math.Round((abc[2] - abc[1] * y) / abc[0] * 1000, MidpointRounding.AwayFromZero) / 1000;
                Console.WriteLine(string.Format("{0} {1}", x.ToString("F3"), y.ToString("F3")));
            }
        }

        static IEnumerable<string> EnumerateInputs()
        {
            while(true)
            {
                var s = Console.In.ReadLine();
                if(s == null)
                    break;
                yield return s;
            }
        }
    }
}

Measured memory_bytes: 6208
#pragma GCC optimize("Ofast")
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<iostream>
#include<queue>
#include<vector>
#include <bitset>
#include <cmath>
#include <limits>
#include <iostream>
#include <map>
#include<tuple>
using namespace std;
#define INF 1LL<<62
#define MAX 100000
#define MOD 1000000007
typedef long long ll;
typedef pair<int,int> P;
//typedef pair<pair<int,int>,int> p;
#define bit(n,k) ((n>>k)&1) /*nのk bit目*/
#define rad_to_deg(rad) (((rad)/2/M_PI)*360)
struct edge{ll to,cost,val;};
template<class T,class U>bool chmin(T&a,const U&b){if(a<=b)return false;a=b;return true;}
template<class T,class U>bool chmax(T&a,const U&b){if(a>=b)return false;a=b;return true;}
//__builtin_popcount(S);
//C.erase(unique(C.begin(),C.end()),C.end());

int dp[110000];
vector<int> V[110000];

int dfs(int x){
    //cout<<x<<endl;
    if(dp[x]!=-1) return dp[x];
    int temp=-1;
    for(auto next:V[x]){
        chmax(temp,dfs(next));
    } 
    return dp[x]=temp+1;
}

int main(){
    int N,M;
    cin>>N>>M;
    for(int i=0;i<M;i++){
        int x,y;
        cin>>x>>y;
        x--; y--;
        V[x].push_back(y);
    }
    for(int i=0;i<110000;i++) dp[i]=-1;
    int ans=0;
    for(int i=0;i<N;i++){
        //cout<<i<<endl;
        ans=max(dfs(i),ans);
    }
    cout<<ans<<endl;

}


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

int main(){
    int N, K;
    cin >> N >> K;
    vector<ll> a(N), sum(N+1, 0);
    vector<ll> b;
    for (int i = 0; i < N; i++) cin >> a[i];
    for (int i = 0; i < N; i++) sum[i+1] = sum[i] + a[i];
    for (int i = 1; i <= N; i++) {
        for (int j = 0; j < i; j++) {
            b.push_back(sum[i]-sum[j]);
        }
    }
    sort(b.begin(), b.end());
    ll ans = 0;
    for (int i = 50; i >= 0; i--) {
        ll cand = ans + ((ll)1 << i);
        int cnt = 0;
        for (ll x : b) {
            if ((cand&x)==cand) cnt++;
        }
        if (cnt >= K) ans = cand;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 6516
#include <stdlib.h>
#include <stdio.h>
#include <stdbool.h>
#include <time.h>
#include <string.h>

typedef struct{
    int other;
    int parent;
    int depth;
    char *type;
    int* c;
    bool done_f;
}Node;

void input(Node*,int);
void allprint(Node*,int);
void depthjud(Node*,int);

const char* root="root";
const char* internal="internal node";
const char* leaf="leaf";

int main(){
    Node* np;
    int n;

    scanf("%d",&n);
    np=malloc(sizeof(Node)*n);
    for(int i=0;i<n;i++){
        (np+i)->parent=-1;
    }
    input(np,n);
    depthjud(np,n);
    allprint(np,n);

    return 0;
}

void input(Node* np,int max){
    int node_num;
    int other;
    int buff;

    for(int i=0;i<max;i++){
        scanf("%d%d",&node_num,&other);
        //scanf("%d",&other);
        (np+node_num)->other=other;
        (np+node_num)->c=malloc(sizeof(int)*other);
        for(int j=0;j<other;j++){
            scanf("%d",&buff);
            (np+buff)->parent=node_num;
            (np+node_num)->c[j]=buff;
        }
    }
    for(int i=0;i<max;i++){
        if((np+i)->parent==-1){
            (np+i)->type=root;
            (np+i)->done_f=true;
            continue;
        }
        if((np+i)->other==0){
            (np+i)->type=leaf;
            continue;
        }
        (np+i)->type=internal;
    }
}

void allprint(Node* np,int max){
    Node* np_for_print;
    for(int i=0;i<max;i++){
        np_for_print=np+i;
        //printf("other %d\n",np_for_print->other);
        printf("node %d: parent = %d, depth = %d, %s, [",i,np_for_print->parent,np_for_print->depth,np_for_print->type);
        for(int j=0;j<np_for_print->other;j++){
            if(j!=np_for_print->other-1)
                printf("%d, ",np_for_print->c[j]);
            else{
                printf("%d",np_for_print->c[j]);
            }
        }
        printf("]\n");
    }
}

void depthjud(Node* np,int max){
    //printf("in depthjud root node_num %d parent %d\n",np[0].node_num,np[0].parent);
    for(int i=0;i<max;i++){
        //printf("in depthjud i %d node_num %d parent %d\n",i,(np+i)->node_num,(np+i)->parent);
        if(strcmp((np+i)->type,"root")==0){
            continue;
        }
        if(!(np+(np+i)->parent)->done_f){
            continue;
        }
        if((np+i)->other==0){
            (np+i)->depth=(np+(np+i)->parent)->depth+1;
            (np+i)->done_f=true;
        }
        else{
            (np+i)->depth=(np+(np+i)->parent)->depth+1;
            (np+i)->done_f=true;
        }
    }
    for(int i=0;i<max;i++){
        //printf("in depthjud i %d node_num %d parent %d depth %d\n",i,(np+i)->node_num,(np+i)->parent,(np+i)->depth);
        if((np+i)->type==root){
            continue;
        }
        if((np+i)->done_f){
            continue;
        }
        if((np+i)->other==0){
            (np+i)->depth=(np+(np+i)->parent)->depth+1;
        }
        else{
            (np+i)->depth=(np+(np+i)->parent)->depth+1;
        }
    }
    
    //printf("in depthjud root node_num %d parent %d\n",np[0].node_num,np[0].parent);
}


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

using namespace std;

void solve(void)
{
	int n;
	cin >> n;
	vector<pair<int, int>> g[n];
	for (int i = 0; i < n - 1; i++)
	{
		int u, v, w;
		cin >> u >> v >> w;
		u--, v--;
		g[u].push_back({v, w});
		g[v].push_back({u, w});
	}
	vector<int> ans(n, -1);
	ans[0] = 0;
	queue<int> q;
	q.push(0);
	while(!q.empty())
	{
		int v = q.front();
		q.pop();
		for(auto np : g[v])
		{
			int nv = np.first, w = np.second;
			if (ans[nv] != -1)
			{
				continue;
			}
			ans[nv] = ans[v] ^ (w & 1);
			q.push(nv);
		}
	}
	for (int a :ans)
	{
		cout << a << endl;
	}
}

int main()
{
	solve();
	//cout << "yui(*-v・)yui" << endl;
	return 0;
}


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

class TEST{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	public void Solve(){
		
		var ST = new SegTreeMax(N);
		for(int i=0;i<N;i++){
			ST.Update(i, A[i]);
		}
		int cnt = 0;
		for(int i=0;i<N;i++){
			if(ST.At(i) == -1) continue;
			int now = i;
			while(true){
//Console.WriteLine("now:{0}, i:{1}",now, i);
				if(ST.QueryMax(now, N) == A[now]){
					cnt++;
					ST.Update(now, -1);
					break;
				}
				int l = now + 1, r = N;
				while(r - l > 1){
					int c = (r + l) / 2;
					if(ST.QueryMax(l, c) > A[now]){
						r = c;
					} else {
						l = c;
					}
				}
				ST.Update(now, -1);
				now = l;
			}
		}
		Console.WriteLine(cnt);
		
		
	}
	int N;
	int[] A;
	public Sol(){
		N = ri();
		A = new int[N];
		for(int i=0;i<N;i++) A[i] = ri();
	}

	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}
	static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}
	static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}
	static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}
}


class SegTreeMax{
	//segment Tree 
	// 0-origin
	protected long[] Data;	
	protected long Inf;	
	protected int N;		 
	protected int n;		
	
	public SegTreeMax(int n_){
		N = n_; Inf = -(long)1e18;
		n = 1;
		while(n < n_) n *= 2;
		Data = new long[2 * n - 1];
		for(int i=0; i < 2 * n - 1; i++) Data[i] = Inf;
	}
	
	//	   0
	//	 1   2
	//	3 4 5 6
	public void Update(int k,long a){
		k += n - 1;	
		Data[k] = a;
		while(k > 0){
			k = (k - 1) / 2;
			Data[k] = Math.Max(Data[k * 2 + 1], Data[k * 2 + 2]);
		}
	}
	
	
	public long QueryMax(int a, int b){
		return Query(a, b, 0, 0, n);
	}
	//RMQ; [a,b)
	public long Query(int a,int b,int k,int l,int r){
		if(r <= a || b <= l) return Inf;
		if(a <= l && r <= b) return Data[k];
		
		var vl = Query(a, b, k * 2 + 1, l, (l + r) / 2);
		var vr = Query(a ,b, k * 2 + 2, (l + r) / 2, r);
		return Math.Max(vl, vr);
	}
	
	public long At(int idx){
		return Data[idx + n - 1];
	}
	
	public long Max{
		get{ return Data[0];}
	}
	
	
	public void Dump(){
		Console.WriteLine();
		int h = 0;
		int cnt = 0;
		for(int i=0;i<Data.Length;i++){
			Console.Write("{0} ", Data[i]);
			cnt++;
			if(cnt == 1 << h){
				cnt = 0;
				h++;
				Console.WriteLine();
			}
		}
	}
	
}



Measured memory_bytes: 17500
N, X = gets.split(" ").map(&:to_i)
l = gets.split(" ").map(&:to_i)

d = []

d[0] = 0

count = 0

(1..N).map{ |i|
  d[i] = d[i-1] + l[i-1]
}

d.map{|di|
  if di <= X then
    count += 1
  end
}

p count


Measured memory_bytes: 1788
#include <iostream>
#include <stdio.h>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <cstring>
#include <algorithm>
#include <math.h>

using namespace std;

typedef long long ll;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;

#define FOR(i,n,m) for(int i=n; i<(int)m; i++)
#define ROF(i,n,m) for(int i=n; i>(int)m; i--)
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define F first
#define S second
#define ri(a) scanf("%d",&a)
#define rii(a,b) ri(a),ri(b)
#define riii(a,b,c) rii(a,b),ri(c)
#define lri(a) scanf("%lld",&a)
#define lrii(a,b) lri(a),lri(b)
#define ms(obj,val) memset(obj,val,sizeof(obj))
#define all(x) x.begin(),x.end()
#define debug true
#define dprintf debug && printf

const int INF = 0x3f3f3f3f;
const ll INFLL = 1e18;
const int MOD = 1e9+7;
const int MAXN = 1<<19;

int A[MAXN];
int n;

void mxze(int &a, int b){
    a = max(a,b);
}
void mnze(int &a, int b){
    a = min(a,b);
}

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

    ri(n);
    FOR(i,0,1<<n) ri(A[i]);

    int ans = 0;
    FOR(mask,1,1<<n){
        int mxi = A[0], mxi2 = -1;
        for(int s = 0 ; s = (s - mask) & mask ;) {
            if(mxi < A[s]) mxi2 = mxi, mxi = A[s];
            else if(mxi2 == -1 || mxi2 < A[s]) mxi2 = A[s];
        }
        mxze(ans, mxi + mxi2);
        printf("%d\n", ans);
    }

    return 0;
}


Measured memory_bytes: 4224
#include<cstdio>
using namespace std;
int main(){
  int n,a[100000],ans=1,x,p;
  scanf("%d",&n);
  for(int i=0;i<n;i++)
    scanf("%d",&a[i]);
  p=1;
  while(a[p]==a[0]&&p<n)
    p++;
  if(p!=n&&a[0]>a[p])
    x=0;
  else
    x=1;
  for(int i=p+1;i<n;i++){
    if(x==0&&a[i-1]<a[i]){
      ans++;
      p=i+1;
      while(a[i]==a[p]&&p<n){
        p++;
      }
      if(p!=n&&a[i]>a[p])
        x=0;
      else
        x=1;
      i=p;
    }
    else if(x==1&&a[i-1]>a[i]){
      ans++;
      p=i+1;
      while(a[i]==a[p]&&p<n){
        p++;
      }
      if(p!=n&&a[i]>a[p])
        x=0;
      else
        x=1;
      i=p;
    }
  }
  printf("%d\n",ans);
}

Measured memory_bytes: 512
n, m = map(int, input().split())
from1 = set()
fromn = set()
a =[]
for _ in range(m):
    a, b = map(int, input().split())
    if a == 1:
        fromn.add(b)
    if b == n:
        from1.add(a)
if len(from1 & fromn)>0 :
    print('POSSIBLE')
else:
    print('IMPOSSIBLE')

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




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

int main() {
    int n, k;
    cin >> n >> k;
    ll ans1 = 0, ans2 = 0;
    rep(i, 1, n+1) {
        if (i % k == 0) ans2++;
        else if (2 * i % k == 0) ans1++;
    }
    ans1 = pow(ans1, 3);
    ans2 = pow(ans2, 3);
    cout << ans1 + ans2 << endl;
    return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python
# -*- coding: utf-8 -*-

while True:
    direction = ''.join(reversed(input()))
    if direction == '#':
        break
    count = 0
    ans = 0
    while direction != '':
        if direction[0] == 'h':
            if count == 0:
                ans =  0
            else:
                ans = ans * 2 - 90
            direction = direction[len('north'):]
        else:
            if count == 0:
                ans = 90
            else:
                ans = ans * 2 + 90
            direction = direction[len('west'):]
        count += 1

    while ans % 2 == 0 and count > 1:
        ans //= 2
        count -= 1
    if count <= 1:
        print(ans)
    else:
        print(str(ans)+'/'+str(2**(count-1)))

Measured memory_bytes: 6716
def main():
  n = int(input())
  xy = [map(str, input().split()) for _ in range(n)]
  x, u = [list(i) for i in zip(*xy)]
  sum=0
  for i in range(0,n):
    if u[i]=='JPY':
      sum+=float(x[i])
    else:
      sum+=float(x[i])*380000
  print(sum)
  
main()

Measured memory_bytes: 8924
#include <iostream>

using std::cin;
using std::cout;
using std::endl;

int
main()
{
  int N, M, X;
  cin >> N >> M >> X;
  int v[12][13];
  int lowest_cost = 0;
  for (int n = 0; n < N; n++)
  {
    for (int m = 0; m <= M; m++)
    {
      cin >> v[n][m];
    }
  }
  lowest_cost = -1;
  for (int mask = 1; mask < (1 << N); mask++)
  {
    int sum[13] = {0};
    for (int n = 0; n < N; n++)
    {
      if (mask & (1 << n))
      {
        for (int m = 0; m <= M; m++)
        {
          sum[m] += v[n][m];
        }
      }
    }
    bool ok = true;
    for (int m = 1; m <= M; m++)
    {
      if (sum[m] < X)
      {
        ok = false;
        break;
      }
    }
    if (ok && (lowest_cost == -1 || sum[0] < lowest_cost))
    {
      lowest_cost = sum[0];
    }
  }
  cout << lowest_cost << endl;
  return 0;
}


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

bool comp(pair<int,int> lef,pair<int,int> rig){
	return lef.first*lef.second<rig.first*rig.second;
}
int main(){
	int n,w,d;
	while(cin>>n>>w>>d,n!=0 || w!=0 || d!=0){
		vector<int> p(n),s(n);
		for(int i=0;i<n;i++) cin>>p[i]>>s[i];
		vector<pair<int,int>> stack;
		stack.emplace_back(w,d);	
		for(int i=0;i<n;i++){
			int index=p[i]-1;
			auto cake=stack[index];
			stack.erase(stack.begin()+index);
			int w0=cake.first;
			int d0=cake.second;
			int cutin=(s[i]%((w0+d0)*2));
			int w1=cake.first;
			int w2=cake.first;
			int d1=cake.second;
			int d2=cake.second;
			if(cutin<w0){
				w1=cutin;
				w2=w0-cutin;
			}
			else if(cutin<w0+d0){
				cutin-=w0;
				d1=cutin;
				d2=d0-cutin;
			}
			else if(cutin<w0+d0+w0){ 
				cutin-=w0+d0;
				w1=cutin;
				w2=w0-cutin;
			}
			else{
				cutin-=w0+d0+w0;
				d1=cutin;
				d2=d0-cutin;
			}
			if(w1*d1<w2*d2){
				stack.emplace_back(w1,d1);
				stack.emplace_back(w2,d2);
			}
			else{
				stack.emplace_back(w2,d2);
				stack.emplace_back(w1,d1);
			}
		}
		sort(stack.begin(),stack.end(),comp);
		for(int i=0;i<stack.size();i++){
			cout<<stack[i].first*stack[i].second;
			if(i+1<stack.size()) cout<<" ";
			else cout<<endl;
		}
	}
	return 0;
}

Measured memory_bytes: 3112
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String a, b;
		a = sc.next();
		b = sc.next();

		String ans = "";
		int len = Math.max(a.length(), b.length());
		for (int i = 0; i < len; i++) {
			if(i <= a.length() - 1) ans += a.charAt(i);
			if(i <= b.length() - 1) ans += b.charAt(i);
		}

		System.out.print(ans);
	}
}

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

typedef long long ll;

bool judge(ll x)
{
    printf("? %lld\n",x);
    fflush(stdout);
    char C;
    scanf(" %c",&C);
    return C == 'Y';
}

int main()
{
    ll ans = 1000000000;
    if(judge(ans))
    {
        ans = 10;
        while(!judge(ans - 1))ans *= 10;
        printf("! %lld\n",ans / 10);
        fflush(stdout);
        return 0;
    }
    else
    {
        while(!judge(ans /= 10));
        ll l = ans,r = ans * 10;
        while(r - l > 1)
        {
            ll mid = (l + r) / 2;
            if(judge(mid * 10))r = mid;
            else l = mid;
        }
        printf("! %lld\n",r);
        fflush(stdout);
        return 0;
    }
}


Measured memory_bytes: 596
#include<bits/stdc++.h>
#define ffr(i,a,b) for(i=a;i<b;i++)
#define ffrr(i,a,b) for(i=a;i<=b;i++)
#define ll long long int
#define pf printf
#define mm(a,b) memset(a,b,sizeof(a))
#define pb push_back
#define pii pair<int,int>
#define mp(a,b) make_pair(a,b)
#define mmxx 1e18

using namespace std;
ll a[200005];

int main()
{
    ll n, i, x;
    map<ll,ll> mp;
    while(cin >> n)
    {
        ll ans=0;

        mp.clear();
        ffr(i,0,n)
        {
            cin>> x;
            a[i]=x;
            mp[x]++;
        }
        sort(a,a+n);
        for(i=n-1;i>=0;i--)
        {
            ll cur=a[i];
            if(mp[cur]==0)
            {
                continue;
            }
            ll p2=1;
            while(p2<=cur) p2+=p2;
            ll req=p2-cur;
            if(req==cur)
            {
                if(mp[cur]>1)
                {
                    mp[cur]-=2;
                    ans++;
                }
            }
            else if(mp.find(req)!=mp.end() && mp[req]>0)
            {
                mp[cur]--;
                mp[req]--;
                ans++;
            }


        }
        cout << ans << endl;

    }
}


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

#define EB emplace_back
#define int long long
#define F first
#define S second
#define N 500005
#define all(x) x.begin(),x.end()
#define endl '\n'
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)

using namespace std;

#define rt return

void test_case(){
  
  string s; cin >> s;
  int cnt = 0, ans = 0;
  for(int i = 0; i < 3; i++){
    if(s[i] == 'R') cnt++;
    else{
      ans = max(ans, cnt);
      cnt = 0;
    }
  }
  ans = max(ans, cnt);
  cout << ans;
}

int32_t main(){
	IOS;
	int tt = 1; 
	//cin >> tt;
	while(tt--){
    test_case();
    cout << endl;
	}
	return 0;
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;
#define fast_io(); std::ios_base::sync_with_stdio(0); std::cin.tie(0); std::cout.tie(0);
#define rad2deg(a) ((a)/M_PI * 180.0)
#define deg2rad(a) ((a)/180.0 * M_PI)
const std::string yes = "Yes";
const std::string no  = "No";

int main(){
    int n;
    std::cin >> n;
    std::vector<int> a(n+1),b(n);
    rep(i,n+1) std::cin >> a[i];
    rep(i,n) std::cin >> b[i];

    ll ans = 0;
    rep(i,n+1){
        ll mi;
        if(a[i]>b[i]){
            ans += b[i];
        }else{
            if(a[i+1]>b[i]-a[i]){
                ans += a[i] + b[i]-a[i];
                a[i+1] -= b[i]-a[i];
            }else{
                ans += a[i] + a[i+1];
                a[i+1] = 0;
            }
        }
    }
    std::cout << ans << "\n";
    return 0;
}

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

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

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;
}

int main() {
  int n;
  cin >> n;
  ll total = 0;

  map<int, int> m;
  rep(i, n) {
    int num;
    cin >> num;
    total += num;
    m[num]++;
  }

  int q;
  cin >> q;
  rep(i, q) {
    int b, c;
    cin >> b >> c;
    if (m[b] != 0) {
      ll diff = (c - b) * m[b];
      total += diff;
      m[c] += m[b];
      m[b] = 0;
    }
    cout << total << endl;
  }
  return 0;
}

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

int main()
{
    long long N, A, B;
    cin>>N>>A>>B;
    if(A == B) cout<< 0 <<endl;
    if(abs(A - B) % 2 == 1) 
    {
        long long dis = min(N - max(A, B), min(A, B) - 1);
        cout << dis + 1 + (abs(A - B) - 1)/2<<endl;
    }
    else
    {
        cout<< abs(A - B)/2<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){

	int i, j,g;
	for (i = 1; i <= 9; i++){

		for (j = 1; j <= 9; j++){
			g = i*j;
			printf("%dx%d=%d\n", i, j,g);

		}
	}
	







	return 0;


}

Measured memory_bytes: 924