akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
namespace IO
{
	template <typename T> inline void read(T &x)
	{
		int f = 1; x = 0; char c = getchar();
		for (; !isdigit(c); c = getchar()) if (c == '-') f = -1;
		for (; isdigit(c); c = getchar()) x = (x << 3) + (x << 1) + (c ^ 48);
		x *= f;
	}

	template <typename T> inline void chkmax(T &x, T y) { x = x > y ? x : y; }
	template <typename T> inline void chkmin(T &x, T y) { x = x < y ? x : y; }

	template <typename T> inline void write(T x)
	{
		if (x < 0) putchar('-'), x = -x;
		if (x > 9) write(x / 10);
		putchar(x % 10 + '0');
	}
	template <typename T> inline void writesp(T x) { write(x); putchar(' '); }
	template <typename T> inline void writeln(T x) { write(x); putchar('\n'); }
}
using namespace IO;
const int N = 5e5 + 5;
const int mod = 1e9 + 7;
int n, m;
inline ll power(ll a, ll p) {
	ll ret = 1;
	for (; p; p >>= 1, a = a * a % mod) if (p & 1) ret = ret * a % mod;
	return ret;
}
ll fac[N], inv[N];
inline ll C(int n, int k) {
	return fac[n] * inv[n - k] % mod * inv[k] % mod;
}
inline ll P(int n, int k) {
	return fac[n] * inv[n - k] % mod;
}
int main(){
	read(n); read(m);
	if (n > m) {
		puts("0");
		return 0;
	}
	fac[0] = 1;
	for (int i = 1; i <= m; i++) fac[i] = fac[i - 1] * i % mod;
	for (int i = 0; i <= m; i++) inv[i] = power(fac[i], mod - 2);
	
	ll ans = 0;
	ll dep = 1;
	for (int k = 0; k <= n; k++)
	{
		ans = (ans + 1ll * dep * C(n, k) % mod * P(m, k) % mod * power(P(m - k, n - k), 2) % mod + mod) % mod; 
		dep = -dep; 
	}
	writeln(ans);
  return 0;
}

Measured memory_bytes: 11388
use proconio::{input, marker::Usize1};

fn main() {
    input!(n: usize, m: usize, lrd: [(Usize1, Usize1, i64); m]);
    let mut g = vec![vec![]; n];
    for &(l, r, d) in &lrd {
        g[l].push((r, d));
        g[r].push((l, -d));
    }
    let mut pos = vec![None; n];
    for i in 0..n {
        if pos[i].is_some() {
            continue;
        }
        pos[i] = Some(0);
        let mut queue = std::collections::VecDeque::from(vec![i]);
        while let Some(x) = queue.pop_front() {
            let px = pos[x].unwrap();
            for &(y, d) in &g[x] {
                if let Some(py) = pos[y] {
                    if px + d != py {
                        println!("No");
                        std::process::exit(0);
                    }
                } else {
                    pos[y] = Some(px + d);
                    queue.push_back(y);
                }
            }
        }
    }
    println!("Yes");
}


Measured memory_bytes: 24256
# -*- coding: utf-8 -*-

# AtCoder Beginner Contest
# Problem B

if __name__ == '__main__':
    a_cards = list(input())
    b_cards = list(input())
    c_cards = list(input())
    current_card = a_cards.pop(0)

    while True:
        if current_card == 'a':
            if len(a_cards) == 0:
                print(current_card.upper())
                exit()

            current_card = a_cards.pop(0)

        elif current_card == 'b':
            if len(b_cards) == 0:
                print(current_card.upper())
                exit()

            current_card = b_cards.pop(0)

        elif current_card == 'c':
            if len(c_cards) == 0:
                print(current_card.upper())
                exit()

            current_card = c_cards.pop(0)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a, b;  //二つの正の整数
  cin >> a >> b;  //入力
  
  int S = a * b;  //積
  
  if (S % 2 == 0){
  	cout << "Even" << endl;
  } else {
  	cout << "Odd" << endl;
  }
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<utility>
#include<cmath>
#include<string>
#include<cstring>
#include<map>
#include<queue>
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep1(i,n) for(ll i=1;i<=n;i++)
#define prin(arg) std::cout<<arg<<"\n"
#define prin2(arg1,arg2) std::cout<<arg1<<" "<<arg2<<"\n"
#define fill(arg,n) std::memset(arg,n,sizeof(arg))
#define mp(a,b) std::make_pair(a,b)
using std::cin;
typedef long long ll;
typedef std::pair<int,int> pi;
typedef std::vector<int> vi;
typedef std::string str;
const int INF=1e+9;
const ll INFLL=1e+17;
const ll MOD=1e+9+7;
const ll MAX=200010;
const ll MAX_P=200010;
ll N,M,K;
ll fact[MAX_P];
void make_fact(){
  fact[0]=fact[1]=1;
  for(ll i=2;i<MAX_P;i++){
    fact[i]=(fact[i-1]*i)%MOD;
  }
}
ll Extgcd(ll a,ll b,ll &x,ll &y){
  ll d=a;
  if(b!=0){
    Extgcd(b,a%b,y,x);
    y-=(a/b)*x;
  }
  else{
    x=1;y=0;
  }
  return d;
}

ll mod_inv(ll a,ll p){//mod pでのaの逆元を求める
  ll x,y;
  Extgcd(a,p,x,y);
  return (x%p+p)%p;
}
//n!=a*p^e (a,p互いに素,p素数) とした時のeとa mod p を求める
ll mod_fact(ll n,ll p,ll& e){
  e=0;
  if(n==0) return 1;
  
  ll res=mod_fact(n/p,p,e);
  e+=n/p;

  if(n/p%2!=0) return res*(p-fact[n%p])%p;
  return res*fact[n%p]%p;
}

//nCk mod pを求める
ll mod_comb(ll n,ll k,ll p){
  if(n<0||k<0||n-k<0) return 0;
  ll e1,e2,e3;
  ll a1=mod_fact(n,p,e1),a2=mod_fact(k,p,e2),a3=mod_fact(n-k,p,e3);
  if(e1>e2+e3) return 0;
  return a1*mod_inv(a2*a3%p,p)%p;
}
void solve(){
  make_fact();
  ll res=0,res2=0;
  //全組み合わせの2点のマンハッタン距離の総和
  rep1(i,N){
    ll X=(((N+1-i)*(N-i)/2)%MOD+(i*(i-1)/2)%MOD)*(M*M%MOD)%MOD;
    res2=(res2+X)%MOD;
  }
  rep1(i,M){
    ll Y=(((M+1-i)*(M-i)/2)%MOD+(i*(i-1)/2)%MOD)*(N*N%MOD)%MOD;
    res2=(res2+Y)%MOD;
  }
  res2=(res2*mod_inv(2,MOD))%MOD;
  /*  ll m=M*M%MOD,n=N*N%MOD;
  rep(i,N){
    ll X=((((N-i)*m)%MOD)*i)%MOD;
    res=(res+X)%MOD;
  }
  rep(i,M){
    ll Y=((((M-i)*n)%MOD)*i)%MOD;
    res=(res+Y)%MOD;
  }
  prin2(res,res2);*/
  if(K!=2){
    ll com=mod_comb(N*M-2,K-2,MOD);
    res2=(res2*com)%MOD;
  }
  prin(res2);
  
}
int main(){
  cin>>N>>M>>K;
  solve();
  return 0;
}


Measured memory_bytes: 1792
s = gets.chomp

if s[0] != 'A'
  puts 'WA'
else
  chars = s.chars
  c = chars.find_index('C')
  if c && (1 < c && c < (chars.size - 1))
    chars.delete_at(c)
    chars.delete_at(0)
    if chars.join !~ /[A-Z]+/
      puts 'AC'
    else
      puts 'WA'
    end
  else
    puts 'WA'
  end
end

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

int main() {
  long N;
  cin>>N;
  for(long h=1;h<=3500;h++){
    for(long n=1;n<=3500;n++){
      long div=4*h*n-N*h-N*n;
      if(div>0){
        if(N*h*n%div==0){
          cout<<h<<" "<<n<<" "<<N*h*n/div<<endl;
          return 0;
        }
      }
    }
  }
}


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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N,M,X,Y;
int A[101],B[101];

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N>>M>>X>>Y;
	FOR(i,N) cin>>A[i];
	FOR(i,M) cin>>B[i];
	sort(A,A+N);
	sort(B,B+M);
	
	for(int Z=X+1;Z<=Y;Z++) {
		if(A[N-1]<Z && Z<=B[0]) {
			return _P("No War\n");
		}
	}
	_P("War\n");
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int a,b,c,d;

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

    while(1)
    {
        c=c-b;
        if(c<=0)
        {
            printf("Yes\n");
            break;
        }
        a=a-d;
        if(a<=0)
        {
            printf("No\n");
            break;
        }
    }
}


Measured memory_bytes: 1664
#include <bits/stdc++.h>
#include <unordered_map>
typedef long long ll;
#define rep(i,m,n) for(ll i = (m); i < (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define print2(x,y) cout << (x) << " " << (y) << endl;
#define printa(x,n) for(ll i = 0; i < n; i++){ cout << (x[i]) << " \n"[i == n-1];}
#define printp(x,n) for(ll i = 0; i < n; i++){ cout << "(" << x[i].first << ", " << x[i].second << ") "; } cout << endl;
#define INF (1e18)
using namespace std;
const ll MOD = 1e9 + 7;
typedef pair<ll, ll> lpair;
ll digit_sum(ll N, ll b){
    ll sum = 0;
    while(N > 0){
        sum += N % b;
        N /= b;
    }
    return sum;
}

inline vector<ll> divisor(ll M){ //約数の全列挙
    vector<ll> dd;
    for(ll i = 1; i*i <= M; i++){
        if(M % i == 0){
            dd.push_back(i);
            if(i * i != M){
                dd.push_back(M/i);
            }
        }
    }
    sort(dd.begin(), dd.end());
    return dd;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N,S;
    cin >> N >> S;
    if(N == S){
        print(N+1);
        return 0;
    }
    ll v = sqrt(N);
    rep(b,2,v+1){
        ll ss = digit_sum(N, b);
        if(S == ss){
            print(b);
            return 0;
        }
    }
    if(N - S < 0){
        print(-1);
        return 0;
    }
    vector<ll> dd = divisor(N-S);
    ll dn = dd.size();
    rep(i,0,dn){
        ll bb = dd[i] + 1;
        ll xx = (N-S) / dd[i];
        if(S - xx >= 0 && S - xx <= bb-1){
            if(N - xx*bb >= 0 && N - xx * bb <= bb-1){
                if(xx <= bb && bb > sqrt(N)){
                    print(bb);
                    return 0;
                }
            }
        }
    }
    print(-1);
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD=1e9+7;
const int INF=1e9;
const ll LINF=1e18;

struct BIT{
private:
    vector<ll> a;
    int n;
public:
    BIT(int sz){
        n=sz;
        a.resize(sz+1);
    }
    ll sum(int i){
        ll res=0;
        while(i>0){
            res+=a[i];
            i-=i&-i;
        }
        return res;
    }
    ll sum(int i,int j){
        return sum(j)-sum(i-1);
    }
    void add(int i,ll x){
        while(i<=n){
            a[i]+=x;
            i+=i&-i;
        }
    }
};

int main(){
    int n,k;
    cin>>n>>k;
    ll a[n+1];
    a[0]=0;
    for(int i=1;i<n+1;i++){
        cin>>a[i];
        a[i]-=k;
        a[i]+=a[i-1];
    }
    pair<ll,int> p[n+1];
    for(int i=0;i<n+1;i++){
        p[i]={a[i],i};
    }
    sort(p,p+n+1);
    for(int i=0;i<n+1;i++){
        a[p[i].second]=i+1;
    }
    ll ans=0;
    BIT bit(n+1);
    for(int i=0;i<n+1;i++){
        ans+=bit.sum(a[i]);
        bit.add(a[i],1);
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 6528
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPR(i, n) for (int i = n - 1; i >= 0; --i)
#define FOR(i, m, n) for (ll i = m; i < n; ++i)
#define FORR(i, m, n) for (ll i = m; i >= n; --i)
#define ALL(v) (v).begin(),(v).end()
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll INF=1LL<<60;
const int inf=(1<<30)-1;
const int mod=1e9+7;
int dx[8]={1,0,-1,0,-1,-1,1,1};
int dy[8]={0,1,0,-1,-1,1,-1,1};
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;cin >> n;
    vector<pair<int,int>> p(n);
    REP(i,n){
        int a,b;cin >> a >> b;
        p[i]={b,a};
    }
    sort(ALL(p));
    ll sum=0;
    REP(i,n){
        if(sum+p[i].second>p[i].first){
            cout << "No" << endl;
            return 0;
        }
        sum+=p[i].second;
    }
    cout << "Yes" << endl;
}

Measured memory_bytes: 4768
#include <stdio.h>

void write(int A[],int N){
	int i;
	for(i=0;i< N;i++){
		if(i>0){
			printf(" ");
		}
		printf("%d",A[i]);
	}
	printf("\n");
}

void insertionSort(int A[],int N){
	int i,j,v;
	for(i=0;i< N;i++){
		v=A[i];
		j=i-1;
		while(j>=0 && A[j]>v){
			A[j+1]=A[j];
			j--;
		}
		A[j+1]=v;
		write(A,N);
	}
}

int main(void){
	int N,i;
	int A[1000];
	
	scanf("%d",&N);
	for(i=0;i< N;i++){
		scanf("%d",&A[i]);
	}
	
	insertionSort(A, N);
}


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

using namespace std;
#define DBG(x)                         \
    (void)(cout << "L" << __LINE__     \
                << ": " << #x << " = " \
                << (x) << '\n')
typedef long long ll;
const int INF = 0x3f3f3f3f;
const int maxn = 110000;
int main()
{
    //检查有没有特判0,有没有越界限.
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << setiosflags(ios::fixed) << setprecision(12);
    string s, t;
    cin >> s >> t;
    int a, b;
    cin >> a >> b;
    string u;
    cin >> u;
    if (u == s)
        a--;
    else if (u == t)
        b--;
    cout << a << " " << b << "\n";
    return 0;
}

Measured memory_bytes: 256
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <set>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cstring>
#include <iterator>
#include <bitset>
#include <unordered_set>
#include <unordered_map>
#include <fstream>
#include <iomanip>
#include <cassert>
//#include <utility>
//#include <memory>
//#include <functional>
//#include <deque>
//#include <cctype>
//#include <ctime>
//#include <numeric>
//#include <list>
//#include <iomanip>

//#if __cplusplus >= 201103L
//#include <array>
//#include <tuple>
//#include <initializer_list>
//#include <forward_list>
//
//#define cauto const auto&
//#else

//#endif

using namespace std;


typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;

#define VV(T) vector<vector< T > >

template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
    v.assign(a, vector<T>(b, t));
}

template <class F, class T>
void convert(const F &f, T &t){
    stringstream ss;
    ss << f;
    ss >> t;
}

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define reep(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) reep((i),0,(n))
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define F first
#define S second
#define mkp make_pair
#define RALL(v) (v).rbegin(),(v).rend()
#define DEBUG
#ifdef DEBUG
#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#else
#define dump(x) 
#define debug(x) 
#endif

#define MOD 1000000007LL
#define EPS 1e-8
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL
#define maxs(x,y) x=max(x,y)
#define mins(x,y) x=min(x,y)

void mainmain(){
	string s;
	cin>>s;
	int n;
	cin>>n;
	rep(i,s.size()){
		if(s[i] == 'a') continue;
		if('z'-s[i]+1 <= n){
			n -= 'z'-s[i]+1;
			s[i] = 'a';
		}
	}
	s.back() = (s.back()-'a'+n%26) %26+'a';
	cout << s <<endl;
}


signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(20);
    mainmain();
}

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

int NumOfDigits(int n) {
  int res = 0;
  while (n) {
    n /= 10;
    res++;
  }
  return res;
}

bool Is753Number(ll num) {
  bool has_3 = false;
  bool has_5 = false;
  bool has_7 = false;
  while (num) {
    switch (num % 10) {
      case 3: has_3 = true; break; 
      case 5: has_5 = true; break; 
      case 7: has_7 = true; break; 
      default: break;
    }
    num /= 10;
  }
  return has_3 && has_5 && has_7;
}

ll dfs(int num, ll cur, ll n) {
  if (num == 0) {
    if (!Is753Number(cur)) return 0;
    return (cur <= n) ? 1 : 0;
  }
  int res = 0;
  res += dfs(num - 1, cur * 10 + 3, n);
  res += dfs(num - 1, cur * 10 + 5, n);
  res += dfs(num - 1, cur * 10 + 7, n);
  return res;
}

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  cout << setprecision(20);

  ll n;
  cin >> n;
  int num = NumOfDigits(n);
  ll ans = 0;
  for (int i = 3; i <= num; ++i) {
    ans += dfs(i, 0, n);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include <algorithm>

using ll = long long int;
const int INF = (1<<30);
const ll INFLL = (1ll<<60);
const ll MOD = 998244353ll;

#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	a = (a<MOD)?a:(a-MOD);
	b = (b<MOD)?b:(b-MOD);
	a += b;
	a = (a<MOD)?a:(a-MOD);
}

int main(void){
	int a,b,l,r;
	std::cin >> a >> b;
	l = std::max((100*a+7)/8,10*b);
	r = std::min((100*a+99)/8,10*b+9);
	if(r<l){
		std::cout << -1 << std::endl;
	}else{
		std::cout << l << std::endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)n; ++i)
#define repi(i, a, b) for (int i = int(a); i < int(b); ++i)
#define repr(i, n) for (int i = (int)n - 1; i >= 0; --i)
#define ALL(a) (a).begin(), (a).end()
using ll = long long;
using Graph = vector<vector<int>>;
const ll mod = 1e9 + 7;
const ll INF = 1e9;

int main() {
  ll n;
  cin >> n;
  queue<ll> que;  //約数を入れる
  que.push(n);
  for (ll i = 2; i * i <= n; ++i) {
    if (n % i == 0) {
      que.push(i);
      if (n / i != i) que.push(n / i);
    }
  }
  ll ans = 0;
  // cout << que.size() << endl;
  while (!que.empty()) {
    ll x = que.front();
    que.pop();
    ll y = n;
    while (y % x == 0) {
      y /= x;
    }
    if (y % x == 1) ans++;
  }
  ll count = 1;
  for (ll i = 2; i * i <= n - 1; ++i) {
    if ((n - 1) % i == 0) {
      count++;
      if ((n - 1) / i != i) count++;
    }
  }
  if (n <= 2) count = 0;
  ans += count;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
n = int(input())
a = []
for i,x in enumerate(input().split()):
    x = int(x)
    a.append(x-(i+1))
a = sorted(a)

if n%2==0:
    b = a[n//2-1]
else:
    b = a[n//2+1-1]

ret = 0
for x in a:
    ret += abs(x-b)
print(ret)


Measured memory_bytes: 25836
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000
#define int long long int

signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, Z, W;
    cin >> N >> Z >> W;
    int a[N];
    rep(i, N) cin >> a[i];
    int ans = 0;
    int A[N] = {};
    if ( N > 1 ) {
        ans = max(ans, abs(a[N-1]-a[N-2]));
        ans = max(ans, abs(a[N-1]-W));
        cout << ans << endl;
    } else {
        cout << abs(a[0] - W) << endl;
    }


    return 0;
}


Measured memory_bytes: 256
n=int(input())
w=list(list(input()) for i in range(n))
f=True
c=0
for i in range(n):
    for j in range(n):
        if w[i]==w[j]:
            c+=1
    if (i!=n-1 and w[i+1][0]!=w[i][-1]) or c>n:
        f=False
if f:
    print("Yes")
else:
    print("No")



Measured memory_bytes: 38768
/*author: hyperion_1724
  date: 
*/

//Required Libraries

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>

//Required namespaces

using namespace std;
using namespace __gnu_pbds;

//Required defines

#define endl '\n'

#define READ(X) cin>>X;
#define READV(X) long long X; cin>>X;
#define READAR(A,N) long long A[N]; for(long long i=0;i<N;i++) {cin>>A[i];}
#define rz(A,N) A.resize(N);
#define sz(X) (long long)(X.size())
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define trav(x,A) for(auto &x:A)
#define FORI(a,b,c) for(long long a=b;a<c;a++)
#define FORD(a,b,c) for(long long a=b;a>c;a--)

//Required typedefs

typedef tree<long long,null_type,less<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
typedef tree<long long,null_type,greater<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set1;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<long long,long long> pll;
typedef vector<int> veci;
typedef vector<long long> vecl;

//Required Constants

const long long inf=(long long)1e18;
const long long MOD=(long long)(1e9+7);
const long long INIT=(long long)(1e6+1);

//Required Functions

ll power(ll x,ll y) 
{ 
    if (y == 0) 
        return 1; 
    ll p = power(x, y/2) % MOD; 
    p = (p * p) % MOD; 
  
    return (y%2 == 0)? p : (x * p) % MOD; 
}
ll modInverse(ll a) 
{ 
   return power(a,MOD-2); 
   
}

//Work

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

    READV(N);
    READV(K);
    READV(Q);
    ll A[N+1]={0};
    FORI(i,0,Q)
    {
        READV(x);
        A[x]++;
    }
    FORI(i,1,N+1)
    {
        A[i]+=(K-Q);
    }
    FORI(i,1,N+1)
    {
        if(A[i]>0)
        {
            cout<<"Yes"<<endl;
        }
        else 
        {
            cout<<"No"<<endl;
        }
    }


    return 0;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define whole(x) (x).begin(),(x).end()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
using ll = long long;
using P = pair<int, int>;
const int mod = 1000000007;
const double eps = 1E-9;


int main(){
    ll a, b, c;
    cin >> a >> b >> c;
    string ans = "No";
    
    if (c-a-b<=0) {;}
    else if (4*a*b<(c-a-b)*(c-a-b)) ans = "Yes";
    
    
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;

void main()
{
    auto abn = readln.split.to!(long[]);
    auto A = abn[0];
    auto B = abn[1];
    auto N = abn[2];

    auto x = min(N, B-1);
    writeln((A*x)/B - A*(x/B));
}

Measured memory_bytes: 2668
#include<stdio.h>

int keta(int);

int main(){
    int a,b;//aとbの入力用
    
    while(scanf("%d %d",&a,&b)!=EOF){
        printf("%d\n",keta(a+b));
    }
    
    return 0;
}

int keta(int n){
    if(n<10){
        return 1;
    }else{
        return keta(n/10)+1;
    }
}

Measured memory_bytes: 596
n, m, k = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = [0]
d = [0]
for i in range(n):
    c.append(a[i]+c[i])
for i in range(m):
    d.append(b[i]+d[i])
e = 0
for i in range(n+1):
    if c[i] > k:
        break;
    while c[i]+d[m] > k:
        m -= 1
    e = max(e, i+m)
print(e)

Measured memory_bytes: 47340
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long ll;

const ll MAXN= 2e5+5;
const ll MOD= 1e9+7; 
ll a[MAXN];
ll s[MAXN];
int main()
{
	int n;
	ll sum=0;
	cin >> n;
	ll t=0;
	for(int i=0;i<n;i++){
		cin >> a[i];
		s[i]=a[i]+t;
		t=s[i];
	}
	for(int i=0;i<n-1;i++){
		sum=((s[i]%MOD*a[i+1]%MOD)%MOD+sum)%MOD;
	}
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 6248
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.util.NoSuchElementException;

public class Main {

	static PrintWriter out;
	static InputReader ir;

	static void solve() {
		int h=ir.nextInt();
		int w=ir.nextInt();
		while(h-->0){
			String s=ir.next();
			out.println(s);
			out.println(s);
		}
	}

	public static void main(String[] args) throws Exception {
		ir = new InputReader(System.in);
		out = new PrintWriter(System.out);
		solve();
		out.flush();
	}

	static class InputReader {

		private InputStream in;
		private byte[] buffer = new byte[1024];
		private int curbuf;
		private int lenbuf;

		public InputReader(InputStream in) {
			this.in = in;
			this.curbuf = this.lenbuf = 0;
		}

		public boolean hasNextByte() {
			if (curbuf >= lenbuf) {
				curbuf = 0;
				try {
					lenbuf = in.read(buffer);
				} catch (IOException e) {
					throw new InputMismatchException();
				}
				if (lenbuf <= 0)
					return false;
			}
			return true;
		}

		private int readByte() {
			if (hasNextByte())
				return buffer[curbuf++];
			else
				return -1;
		}

		private boolean isSpaceChar(int c) {
			return !(c >= 33 && c <= 126);
		}

		private void skip() {
			while (hasNextByte() && isSpaceChar(buffer[curbuf]))
				curbuf++;
		}

		public boolean hasNext() {
			skip();
			return hasNextByte();
		}

		public String next() {
			if (!hasNext())
				throw new NoSuchElementException();
			StringBuilder sb = new StringBuilder();
			int b = readByte();
			while (!isSpaceChar(b)) {
				sb.appendCodePoint(b);
				b = readByte();
			}
			return sb.toString();
		}

		public int nextInt() {
			if (!hasNext())
				throw new NoSuchElementException();
			int c = readByte();
			while (isSpaceChar(c))
				c = readByte();
			boolean minus = false;
			if (c == '-') {
				minus = true;
				c = readByte();
			}
			int res = 0;
			do {
				if (c < '0' || c > '9')
					throw new InputMismatchException();
				res = res * 10 + c - '0';
				c = readByte();
			} while (!isSpaceChar(c));
			return (minus) ? -res : res;
		}

		public long nextLong() {
			if (!hasNext())
				throw new NoSuchElementException();
			int c = readByte();
			while (isSpaceChar(c))
				c = readByte();
			boolean minus = false;
			if (c == '-') {
				minus = true;
				c = readByte();
			}
			long res = 0;
			do {
				if (c < '0' || c > '9')
					throw new InputMismatchException();
				res = res * 10 + c - '0';
				c = readByte();
			} while (!isSpaceChar(c));
			return (minus) ? -res : res;
		}

		public double nextDouble() {
			return Double.parseDouble(next());
		}

		public int[] nextIntArray(int n) {
			int[] a = new int[n];
			for (int i = 0; i < n; i++)
				a[i] = nextInt();
			return a;
		}

		public long[] nextLongArray(int n) {
			long[] a = new long[n];
			for (int i = 0; i < n; i++)
				a[i] = nextLong();
			return a;
		}

		public char[][] nextCharMap(int n, int m) {
			char[][] map = new char[n][m];
			for (int i = 0; i < n; i++)
				map[i] = next().toCharArray();
			return map;
		}
	}
}

Measured memory_bytes: 21460
# -*- coding: utf-8 -*-
import sys
import math
from bisect import bisect_left
from bisect import bisect_right
from collections import defaultdict
from heapq import heappop, heappush
import itertools
import random
from collections import deque
from decimal import *
import queue

input = sys.stdin.readline

def inputInt(): return int(input())
def inputMap(): return map(int, input().split())
def inputList(): return list(map(int, input().split()))
def inputStr(): return input()[:-1]

inf = float('inf')
mod = 1000000007

#-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
#-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-

def main():
	N = inputInt()

	if N >= 1800:
		print("1")
	elif N >= 1600:
		print("2")
	elif N >= 1400:
		print(3)
	elif N >= 1200:
		print(4)
	elif N >= 1000:
		print("5")
	elif N >= 800:
		print(6)
	elif N >= 600:
		print(7)
	else:
		print(8)

	#print(N)

#-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
#-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
if __name__ == "__main__":
	main()


Measured memory_bytes: 76916
A, B = map(int, input().split())
S = input()
a = ''
b = ''
cnt = 0
for i in range(0, len(S)):
	if S[i] == '-':
		cnt += 1
	elif cnt == 0:
		a = a + S[i]
	else: b = b + S[i]
if cnt == 1 and len(a) == A and len(b) == B:
	print('Yes')
else: print('No')

Measured memory_bytes: 38384
#include <cstdio>
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main(){

	int n,m;
	while(cin>>n>>m&&!(n==0&&m==0)){
		double table[101][101];
		for(int i = 0; i < n; i++){
			for(int j = 0; j < n; j++)
				cin>>table[i][j];
		}
		double dp[2][101];
		fill(dp[0],dp[0]+101,1);
		fill(dp[1],dp[1]+101,0);

		double *prv=dp[0];
		double *nxt=dp[1];
		for(int k = 0; k < m-1; k++){
			for(int i = 0; i < n; i++){
				for(int j = 0; j < n; j++){
					nxt[i]=max(nxt[i],prv[j]*table[j][i]);
				}
			}
			swap(prv,nxt);
			fill(nxt,nxt+101,0);
		}

		double maxNum=0;
		for(int i = 0; i < n; i++){
			maxNum=max(maxNum,prv[i]);
		}
//		double ret = ((double)((int)(maxNum*100+0.5)))/100;
		double ret=maxNum;
		printf("%.2f\n",ret);
	}

	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>

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

using namespace std;

int main()
{
	int n;
	while(cin >> n && n)
	{
		int num,ans_num;
		double h,w,ans;
		
		rep(i,n)
		{
			cin >> num >> h >> w;
			
			h /= 100;
			double bmi = w / (h*h);

			if(i == 0)
			{
				ans_num = num;
				ans = fabs(22 - bmi);
			}
			else
			{
				if(fabs(22 - bmi) == ans)
				{
					ans_num = min(ans_num,num);
				}

				if(fabs(22 - bmi) < ans)
				{
					ans_num = num;
					ans = fabs(22 - bmi);
				}
			}
		}

		cout << ans_num << endl;
	}
	return 0;
}

Measured memory_bytes: 1228
#include<bits/stdc++.h>
#include <iostream>
#include <numeric>
#include <math.h>
#define ll  long long
#define ull unsigned long
#define mpa make_pair
#define pb push_back
#define ff first
#define pii pair<ll,ll>
#define dd double
#define trace(x) cerr << #x << " : " << x << endl
#define ss second
#define boost ios_base::sync_with_stdio(0)
#define forp(i,a,b) for(ll i=a;i<=b;i++)
#define rep(i,n)    for(ll i=0;i<n;++i)
#define ren(i,n)    for(ll i=n-1;i>=0;i--)
#define forn(i,a,b) for(ll i=a;i>=b;i--)
#define all(c) (c).begin(),(c).end()
#define tr(c,i) for(typeof((c).begin()) i = (c).begin(); i != (c).end();
#define sc(x) scanf("%lld",&x)
#define clr(x,val) memset(x,val,sizeof(x))
#define pr(x) printf("%lld\n",x) 
#define gc getchar
#define pdd pair<dd,dd>
#define prec(x) cout<<fixed<<setprecision(x)
using namespace std;
ll a[200005];
ll b[200005];

int main(){
	boost;
    ll l,r,d;
    cin>>l>>r>>d;
    ll ans=0;
    for(ll i=l;i<=r;i++){
    	if(i%d==0)ans++;
	}
	cout<<ans;

}
			
			


Measured memory_bytes: 3604
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <queue>
#include <stack>
#include <tuple>
#include <cmath>
#include <iomanip>
#include <map>
#include <cstring> //memset(dp,0,sizeof(dp))
#include <functional>
#include <cctype>
#include <locale>
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define fi first
#define se second
#define pb push_back
#define ALL(a) (a).begin(),(a).end()

using namespace std;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
typedef pair<int,int> P;
typedef pair<long long,long long> Pll;
#define fout(num) cout << fixed << setprecision(20) << (num) << endl
//s[i]=tolower(s[i]); islower(s[i]); cout << tolower(s[i])はバグ
//vector<vector<ll>> dp(n,vector<ll>(n))
//exist x map o setconst ll MOD = 1e9+7;return fac[n]*(finv[k]*finv[n-k] % MOD) % MOD;

signed main(){
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    ll n; cin >> n;
    vector<ll> a(n);
    ll t=0;
    rep(i,n){
        cin >> a[i];
        t+=a[i];
    }
    t-=(n*(n-1));
    chmax(t,0);
    while(1){ //t kai
        vector<ll> v(n);
        rep(i,n) v[i]=a[i]+t;
        ll cnt=0;
        rep(i,n){
            if(v[i]>n-1LL){
                cnt+=((v[i]+1LL)/(n+1));
            }
        }
        if(cnt<=t){
            cout << t << endl;
            return 0;
        }
        t++;
    }
    return 0;
}


Measured memory_bytes: 3664
#include<stdio.h>

void print_map(char map[8][8]){
  int i,j;

  for(i=0;i<8;i++){
    for(j=0;j<8;j++){
      printf("%c",map[i][j]);
    }
    printf("\n");
  }
}

void rotate_map(char map[8][8]){
  int i,j,jj;
  char pmap[8][8];

  for(i=0;i<8;i++){
    for(j=0;j<8;j++){
      pmap[i][j]=map[i][j];
    }
  }
  for(i=0;i<8;i++){
    for(j=0,jj=7;j<8;j++,jj--){
      map[i][j]=pmap[jj][i];
    }
  }
}

int main(void){
  int i,num,j;
  char map[8][8];
  char hoge;

  for(i=0;i<8;i++){
    for(j=0;j<8;j++){
      scanf("%c",&map[i][j]);
    }
    scanf("%c",&hoge);
  }
  rotate_map(map);
  printf("90\n");
  print_map(map);
  rotate_map(map);
  printf("180\n");
  print_map(map);
  rotate_map(map);
  printf("270\n");
  print_map(map);
  return 0;
}

Measured memory_bytes: 0
import sys
def s():
 W=int(input().split()[1])
 C=[0]*-~W
 for e in sys.stdin:
  v,w=map(int,e.split())
  for i in range(W,w-1,-1):
   t=v+C[i-w]
   if t>C[i]:C[i]=t
 print(C[W])
if'__main__'==__name__:s()


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

using namespace std;

string str;

int main() {
    cin >> str;
    int N = str.size(), num = 0;
    bool check = true;

    while(num < N) {
        if(str.substr(num, 6) == "eraser")
            num += 6;
        else if(str.substr(num, 5) == "erase")
            num += 5;
        else if(str.substr(num, 7) == "dreamer" && str.substr(num+5, 5) != "erase")
            num += 7;
        else if(str.substr(num, 5) == "dream")
            num += 5;
        else {
            check = false;
            break;
        }
    }
    if(check)
        cout << "YES" << endl;
    else
        cout << "NO" << endl;
    return 0;
}

Measured memory_bytes: 3756
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
#include <cstring>
#include <deque>
#include <iomanip>
#include <limits>
#include <fstream>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define CLR(mat) memset(mat, 0, sizeof(mat))
typedef long long ll;

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  string s;
  cin >> s;
  int ans = 0;
  FOR(i,0,4){
if(s[i]=='+') ans++;
    else ans--;
  }
  cout << ans <<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
using namespace std;
int n;
int p[100001];

void print(){
    for(int i = 1; i <= n; i++){
        printf("%d", p[i]);
    }
    printf("\n");
}

int main(){
    cin >> n;


    for(int i = 1; i <= n; i++){
        cin >> p[i];
    }

    int count = 0;

    for(int i = 1; i <= n; i++){
        if(p[i] == i){
            int tmp = p[i];
            p[i] = p[i+1];
            p[i+1] = tmp;
            //print();
            count++;
        }
    }

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

    return 0;

}

Measured memory_bytes: 640
mum = input()
a = int(mum[0])
b = int(mum[1])
c = int(mum[2])
d = int(mum[3])
ans = []
ans.append(a+b+c+d)
ans.append(a-b+c+d)
ans.append(a+b-c+d)
ans.append(a-b-c+d)
ans.append(a+b+c-d)
ans.append(a-b+c-d)
ans.append(a+b-c-d)
ans.append(a-b-c-d)

if ans[0] == 7:
	print('{}+{}+{}+{}=7'.format(a,b,c,d))
elif ans[1] == 7:
	print('{}-{}+{}+{}=7'.format(a,b,c,d))
elif ans[2] == 7:
	print('{}+{}-{}+{}=7'.format(a,b,c,d))
elif ans[3] == 7:
	print('{}-{}-{}+{}=7'.format(a,b,c,d))
elif ans[4] == 7:
	print('{}+{}+{}-{}=7'.format(a,b,c,d))
elif ans[5] == 7:
	print('{}-{}+{}-{}=7'.format(a,b,c,d))
elif ans[6] == 7:
	print('{}+{}-{}-{}=7'.format(a,b,c,d))
elif ans[7] == 7:
	print('{}-{}-{}-{}=7'.format(a,b,c,d))
	

Measured memory_bytes: 3064
#include <iostream>

using namespace std;

int N, T;
int t[200000];
int diff[200000];

int main(){

    cin >> N >> T;

    for(int i = 0; i < N; i++)
        cin >> t[i];

    for(int i = 0; i < N - 1; i++){
        diff[i] = t[i + 1] - t[i];
    }
    
    int ans = T;

    for (int i = 0; i < N - 1; i++){
        if (diff[i] < T)
            ans += diff[i];
        else
            ans += T;
    }
    
    cout << ans << '\n';

}







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

#define rep(i, N) for (int i = 0; i < (int)N; i++)
using namespace std;
typedef long long ll;
const ll LLINF = 9223372036854775807;
const int INF = pow(2,29);
const int MOD = 1000000007;

int main() {
  int H, W; cin >> H >> W;
  string S[H]; rep(i,H) cin >> S[i];
  int r[H][W] = {};
  rep(i,H) {
    int pos = 0;
    rep(j,W) {
      if (S[i][j]=='#') {
        for (int k=pos; k<j; k++) r[i][k]+= j-pos;
        pos = j+1;
      }
    }
    for (int k=pos; k<W; k++) r[i][k]+= W-pos;
  }
  rep(j,W) {
    int pos = 0;
    rep(i,H) {
      if (S[i][j]=='#') {
        for (int k=pos; k<i; k++) r[k][j]+= i-pos;
        pos = i+1;
      }
    }
    for (int k=pos; k<H; k++) r[k][j]+= H-pos;
  }

  // rep(i,H) { rep(j,W) cout << r[i][j] << " "; cout << endl; }
  int result = 0;
  rep(i,H) result = max(result, *max_element(r[i], r[i]+W));
  result--;
  cout << result << endl;
  return 0;
}

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

void judge(int r, vector<int>& c){
    if(r <= 399){
        c[0]++;
    }
    else if(400 <= r && r <= 799){
        c[1]++;
    }
    else if(800 <= r && r <= 1199){
        c[2]++;
    }
    else if(1200 <= r && r <= 1599){
        c[3]++;
    }
    else if(1600 <= r && r <= 1999){
        c[4]++;
    }
    else if(2000 <= r && r <= 2399){
        c[5]++;
    }
    else if(2400 <= r && r <= 2799){
        c[6]++;
    }
    else if(2800 <= r && r <= 3199){
        c[7]++;
    }
    else{
        c[8]++;
    }
}

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

    //int top = 0;
    vector<int> color(9, 0);
    for(int i = 0; i < n; i++){
        int rate;
        cin >> rate;
        judge(rate, color);
        //cout << "color2:" << color[2] << endl;
    }

    int min = 0, max = 0;
    for(int i = 0; i < 8; i++){
        if(color[i]){
            min++;
            max++;
        }
    }
    if(min == 0){
        min++;
    }
    if(color[8]){
        max += color[8];
        /*
        if(max > 8){
            max = 8;
        }*/
    }

    cout << min << " " << max << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <algorithm>
#include <iomanip>
#include <string.h>

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()

typedef long long lint;

using namespace std;

int main(){
  int A,B,X;
  cin>>A>>B>>X;
  cout<<((A+B>=X and A<=X)? "YES":"NO")<<endl;
  return 0;
}


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

int main()
{
    int N, K;
    string S;
    cin >> N >> S >> K;
    for (int i = 0; i < N; ++i)
    {
        if (S[i] != S[K - 1])
        {
            S[i] = '*';
        }
    }
    cout << S << endl;
    return 0;
}


Measured memory_bytes: 256
mod = 10**9+7
S = input()
N = len(S)
dp = [[0]*13 for _ in range(N+1)]
dp[0][0] = 1
S = S[::-1]
for i in range(N):
    if S[i] != '?':
        m = int(S[i])
        rm = (m*pow(10,i,13))%13
        for r in range(13):
            dp[i+1][(r+rm)%13] = dp[i][r]
            dp[i+1][(r+rm)%13] %= mod
    else:
        for m in range(10):
            rm = (m*pow(10,i,13))%13
            for r in range(13):
                dp[i+1][(r+rm)%13] += dp[i][r]
                dp[i+1][(r+rm)%13] %= mod

print(dp[N][5])

Measured memory_bytes: 64280
#include <stdio.h>

int main(void){
  int i, x1, x2, x3, n;
  scanf("%d", &n);
  for(i = 1; i <= n; i++){
      x1 = i / 10;
      x2 = i / 100;
      x3 = i / 1000;

    if(i % 3 == 0 || i % 10 == 3 ||
       x1 % 10 == 3 || x2 % 10 == 3 || x3 % 10 == 3)
      printf(" %d", i);
  }
  printf("\n");
  return 0;
}

Measured memory_bytes: 600
import java.util.*;

import static java.lang.Math.*;
import static java.util.Arrays.*;

public class Main {

	int INF = 1 << 28;
	int MAX = 1000000000;
	void run() {
		Scanner sc = new Scanner(System.in);
		for(;;) {
			int n = sc.nextInt();
			if( n == 0 ) break;
			
			LinkedList<Seg> list = new LinkedList<Seg>();
			for(int i=0;i<n;i++) {
//				for(Seg seg: list) debug(seg.id, seg.s, seg.e);
//				debug(" ");
				switch ( sc.next().charAt(0) ) {
				case 'W':
					int l = sc.nextInt();
					int mem = sc.nextInt();
					LinkedList<Seg> tmp = new LinkedList<Seg>();
				
					long s = 0; long e = mem;
					for(;!list.isEmpty();) {
						Seg seg = list.removeFirst();
						if(mem == 0) {
							tmp.add(seg);
							for(;!list.isEmpty();)
								tmp.addLast(list.removeFirst());
							break;
						}
						if( seg.s > s ) {
							e = min(s + mem, seg.s);
							mem -= (e-s);
							tmp.addLast(new Seg(l, s, e));
							tmp.addLast(seg);
						}
						else {
							tmp.addLast(seg);
						}
						s = seg.e;
					}
					if(mem != 0) tmp.addLast(new Seg(l, s, s+mem));
					list.clear();
					list.addAll(tmp);
					break;
				
				case 'D':
					l = sc.nextInt();
					tmp = new LinkedList<Seg>();
					for(;!list.isEmpty();) {
						Seg seg = list.removeFirst();
						if(seg.id == l);
						else tmp.addLast(seg);
					}
					
					list.clear();
					list.addAll(tmp);
					break;
				
				case 'R':
					int p = sc.nextInt();
					boolean flg = false;
					for(Seg seg: list) {
						if( seg.s <= p && p < seg.e ) {
							flg = true;
							System.out.println(seg.id);
						}
					}
					if(!flg) System.out.println(-1);
				}
			}
			System.out.println();
		}
	}
	
	class Seg {
		long id, s, e;
		Seg(long id, long s, long e) {
			this.s = s;
			this.id = id;
			this.e = e;
		}
	}

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

	void debug(Object... os) {
		System.err.println(Arrays.deepToString(os));
	}
}

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

using namespace std;

string S(string str,int h){
    string str1,str2;
    str1 = str.substr(0,h);
    str2 = str.substr(h,str.size()-h);

    string Nstr = str2 + str1;

    return Nstr;

}

int main(){
    string card;
    int h,m;

    while(1){

        cin >> card;
        if(card == "-")break;

        cin >> m;
        for(int i=0;i<m;i++){
            cin >> h;
            card = S(card,h);

        }
        
        cout << card << endl;


    }

    return 0;


}


Measured memory_bytes: 3180
function main(input) {
  var temp = input.split(' ');
  var x = parseInt(temp[0]);
  var y = parseInt(temp[1]);
  var z = parseInt(temp[2]);

  if (x <= y){
    if (y <= z) {
      console.log(x+' '+y+' '+z);
    } else if (x <= z) {
      console.log(x+' '+z+' '+y);
    } else {
      console.log(z+' '+x+' '+z);
    }
  } else {
    if (x <= z) {
      console.log(y+' '+x+' '+z);
    } else  if(y <= z) {
      console.log(y+' '+z+' '+x);
    } else {
      console.log(z+' '+y+' '+x);
    }
  }
}

var x = require('fs').readFileSync('/dev/stdin', 'utf-8');
main(x);


Measured memory_bytes: 15124
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Convert;
using static System.Math;
//using static System.Globalization.CultureInfo;

class Program
{
    static void Main(string[] args)
    {
        var num = Input.num;
        var rc = Input.twodim(num);
        var dp = new long[num, num];
        for (var i = 0; i < num; i++)
            for (var j = 0; j < num; j++)
                if(i!=j)
                dp[i, j] = int.MaxValue;
        for(var k=1;k<num;k++)
            for(var i = 0; i < num-k; i++)
                for (var j = i; j < i + k; j++)
                    dp[i, i + k] = Min(dp[i, i + k], dp[i, j] + dp[j + 1, i + k] + rc[i][0] * rc[j][1] * rc[i + k][1]);
        WriteLine(dp[0, num - 1]);
    }
}

public class Input
{
    public static string read => ReadLine();
    public  static int[] ar => Array.ConvertAll(read.Split(' '), int.Parse);
    public  static int num => ToInt32(read);
    public  
static long[] arL => Array.ConvertAll(read.Split(' '), long.Parse);
    public  static long numL => ToInt64(read);
    public static int[][] twodim(int num)
        => Enumerable.Repeat(0, num).Select(v => ar).ToArray();
    public static long[][] twodimL(int num)
        => Enumerable.Repeat(0, num).Select(v => arL).ToArray();
    public  const string Alfa = "abcdefghijklmnopqrstuvwxyz";
    public  const int MOD = 1000000007;
}



Measured memory_bytes: 18448
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
#include <functional>
using namespace std;

const int INF = INT_MAX / 4;

int n, l, k;

class Edge
{
public:
    int to, cost;
    Edge(int to0, int cost0){
        to = to0;
        cost = cost0;
    }
};

class Data
{
public:
    int pos, ball, rank;
    Data(int pos0, int ball0, int rank0){
        pos = pos0;
        ball = ball0;
        rank = rank0;
    }
    int toInt(){
        return pos + n * (ball + (1<<l) * rank);
    }
};

int main()
{
    for(;;){
        int m;
        cin >> n >> m >> l >> k;
        if(n == 0)
            return 0;

        vector<vector<Edge> > edges(n);
        for(int i=0; i<m; ++i){
            int u, v, c;
            cin >> u >> v >> c;
            -- u;
            -- v;
            edges[u].push_back(Edge(v, c));
            edges[v].push_back(Edge(u, c));
        }

        int start, goal;
        cin >> start >> goal;
        -- start;
        -- goal;

        vector<int> ball(n);
        for(int i=0; i<l; ++i){
            int b;
            cin >> b;
            -- b;
            ball[b] = 1 << i;
        }

        multimap<int, Data> mm;
        vector<int> dp(n*(1<<l)*k, INF);
        mm.insert(make_pair(0, Data(start, ball[start], 0)));
        dp[Data(start, ball[start], 0).toInt()] = 0;

        while(!mm.empty()){
            int cost = mm.begin()->first;
            Data d = mm.begin()->second;
            mm.erase(mm.begin());

            if(cost > dp[d.toInt()])
                continue;

            for(unsigned i=0; i<edges[d.pos].size(); ++i){
                int cost2 = cost + edges[d.pos][i].cost;
                Data d2 = d;
                d2.pos = edges[d.pos][i].to;
                d2.ball |= ball[d2.pos];

                for(int j=0; j<k; ++j){
                    d2.rank = j;
                    if(cost2 < dp[d2.toInt()]){
                        mm.insert(make_pair(cost2, d2));
                        swap(cost2, dp[d2.toInt()]);
                    }
                }
            }
        }

        int ret = dp[Data(goal, (1<<l)-1, k-1).toInt()];
        if(ret == INF)
            cout << "NA" << endl;
        else
            cout << ret << endl;

    }
}

Measured memory_bytes: 31712
#include <bits/stdc++.h>
#define ALL(A) (A).begin(), (A).end()
#define ll long long
#define rep(i, n) for (int i = 0; i < (n); i++)

const ll mod = 1e9 + 7;
const ll INF = -1 * ((1LL << 63) + 1);
const int inf = -1 * ((1 << 31) + 1);

using namespace std;

int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    string S;
    cin >> S;
    int A[4];
    rep(i,4){
        A[i] = S[i] - '0';
    }
    for(int i=0;i< 1<<3;i++){
        int sum = A[0];
        for(int j=0;j<3;j++){
            if( i>>j & 1){
                sum -= A[j+1];
            }else{
                sum += A[j+1];
            }
        }
        if( sum == 7){
            string t;
            for(int j=0;j<3;j++){
                if( i>>j & 1)t.push_back('-');
                else t.push_back('+');
            }
            rep(i,3)cout << A[i] << t[i];
            cout << A[3] << "=7" << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 256