akhauriyash/Code-Regression huggingface dataset:
n, m, k = map(int, input().split())
mod = 998244353

N = 10 ** 6

#逆元テーブル
inv_t = [0]+[1]
for i in range(2, N):
  inv_t += [inv_t[mod % i] * (mod - int(mod / i)) % mod]

#階乗計算
kai = [1, 1]
rev_kai = [1, inv_t[1]]
for i in range(2, N):
	kai.append(kai[-1] * i % mod)
	rev_kai.append(rev_kai[-1] * inv_t[i] % mod)

# コンビネーション計算
def cmb(n, r):
	return kai[n] * rev_kai[r] * rev_kai[n-r] % mod

base = m
ans = 0

for i in range(n-1):
    base = base * (m-1) % mod

for i in range(0, k+1):
    ans += base * cmb(n-1, n-1-i)
    ans %= mod
    base = base * inv_t[m-1] % mod

if m == 1 and k == n-1:
    print(1)
else:
    print(ans)


Measured memory_bytes: 127648
#include"bits/stdc++.h"
using namespace std;
#define LL long long
#define PB push_back
#define MP make_pair
int N, A[100000];
vector<int> dp;
int main(){
	cin >> N;
	for(int i=0; i<N; i++) cin >> A[i];
	reverse(A, A+N);

	dp.resize(N);
	for(int i=0; i<N; i++) dp[i] = INT_MAX;
	for(int i=0; i<N; i++){
		*lower_bound(dp.begin(), dp.end(), A[i]+1) = A[i];
	}
	cout << lower_bound(dp.begin(), dp.end(), INT_MAX) - dp.begin() << endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define erep(i,a,b) for(int i=a;i<=(int)(b);++i)
#define per(i,a,b) for(int i=(b);i>(a);--i)
#define eper(i,a,b) for(int i=((int)(a));i>=b;--i)
#define pb push_back
#define mp make_pair
#define INF 2000000000
#define MOD 1000000007
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a/gcd(a, b)*b;}

int n, m;
ll ans; 
int main() {
 ios::sync_with_stdio ( false );
 cin.tie ( 0 );
    cin >> n >> m;
    ans = (int)pow(2, m)*(100*(n-m) + 1900*m);
    cout << ans << endl;
    return 0;
}


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

using ll = long long;
using pii  = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

const string YES = "Yes";
const string NO = "No";

int main(){
    int n;
    cin >> n;
    vector<vi> d(n, vi(2));
    rep(i, n) cin >> d[i][0] >> d[i][1];
    for (int i=0; i+2<n; ++i) {
        if (d[i][0]==d[i][1] && d[i+1][0]==d[i+1][1] && d[i+2][0]==d[i+2][1]) {
            cout << YES << endl;
            return 0;
        }
    }
    cout << NO << endl;
    return 0;
}


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

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

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

	int x1,x2,y1,y2; cin >> x1 >> y1 >> x2 >> y2;

	int dx = x2-x1, dy = y2-y1;

	swap(dx, dy);
	dx = -dx;

	int x,y; x = x2+dx; y = y2+dy;
	cout << x << " " << y << " ";

	swap(dx, dy);
	dx = -dx;

	x += dx; y += dy;
	cout << x << " " << y << endl;

	return 0;

}


Measured memory_bytes: 256
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <numeric>
#include <sstream>
#include <iostream>
#include <iomanip>
#define _USE_MATH_DEFINES
#include <cmath>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cfloat>
#include <cmath>
#include <ctime>
#include <cassert>
#include <cctype>
#include <cstdio>
#include <cassert>
using namespace std;

#define EPS 1e-12
#define ull unsigned long long
#define ll long long
#define VI vector<ll>
#define PII pair<ll, ll> 
#define VVI vector<vector<ll> >
#define VVVI vector<vector<vector<ll>>>
#define VVVVI vector<vector<vector<vector<ll>>>>
#define REP(i,n) for(ll i=0,_n=(n);(i)<(ll)_n;++i)
#define REPR(i,n) for(ll i=(ll)(n)-1;0<=(i);--i)
#define RANGE(i,a,b) for(ll i=(ll)a,_b=(ll)(b);(i)<_b;++i)
#define RANGER(i,a,b) for(ll i=(ll)(b)-1,_a=(ll)(a);(_a)<=i;--i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define ALLR(c) (c).rbegin(), (c).rend()
#define PB push_back
#define MP(a, b) make_pair(a, b)
#define POPCOUNT __builtin_popcount
#define POPCOUNTLL __builtin_popcountll
#define CLEAR(table, v) memset(table, v, sizeof(table));
#define UNIFORM_DOUBLE(a, b) (((b-a)*(double)rand()/RAND_MAX)+a) // [a, b) 
#define UNIFORM_LL(a, b) (ll)UNIFORM_DOUBLE(a, b) // [a, b) 
#define IN(v, lo, hi) ((lo)<=(v) && (v)<(hi))
#define DD(v) cout<<#v<<": "<<v<<endl
#define FI first
#define SE second
template <typename T0, typename T1> std::ostream& operator<<(std::ostream& os, const map<T0, T1>& v) { for( typename map<T0, T1>::const_iterator p = v.begin(); p!=v.end(); p++ ){os << p->first << ": " << p->second << " ";} return os; }
template <typename T0, typename T1> std::ostream& operator<<(std::ostream& os, const pair<T0, T1>& v) { os << v.first << ": " << v.second << " "; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const vector<T>& v) { for( int i = 0; i < (int)v.size(); i++ ) { os << v[i] << " "; } return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const set<T>& v) { vector<T> tmp(v.begin(), v.end()); os << tmp; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const deque<T>& v) { vector<T> tmp(v.begin(), v.end()); os << tmp; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const vector<vector<T> >& v) { for( int i = 0; i < (int)v.size(); i++ ) { os << v[i] << endl; } return os; }
template<typename T>void maxUpdate(T& a, T b) {a = max(a, b);}
template<typename T>void minUpdate(T& a, T b) {a = min(a, b);}

#define MOD 1000000007LL
#define INF (1LL<<60)

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll N,K;
	while(cin>>N>>K) {
		cout<<N-K+1<<endl;
	}
	
	return 0;
}


Measured memory_bytes: 256
# include <bits/stdc++.h>
using namespace std;
# define MOD 1000000007
typedef long long ll;
ll dp1[100001], dp2[100001];
void solve2(vector<int> adj[], int n, int m, int u, int parent, ll pval){
    dp2[u] = ((1 + pval)*dp1[u])%m;
    
    vector<ll> prefix, suffix;
    for(int v : adj[u]){
        if(v != parent){
            prefix.push_back(1 + dp1[v]);
            suffix.push_back(1 + dp1[v]);
        }
    }
    for(int i=1;i<prefix.size();i++){
        prefix[i] = (prefix[i-1]*prefix[i])%m;
    }
    for(int i=suffix.size()-2;i>=0;i--){
        suffix[i] = (suffix[i+1]*suffix[i])%m;
    }
    
    int cn = 0;
    for(int v : adj[u]){
        if(v != parent){
            ll cval = (1 + pval);
            if(cn > 0) cval = (cval*(prefix[cn-1]))%m;
            if(cn < suffix.size() - 1) cval = (cval*(suffix[cn+1]))%m;
            solve2(adj, n, m, v, u, cval);
            cn++;
        }
    }
}
void solve1(vector<int> adj[], int n, int m, int u, int parent){
    dp1[u] = 1;
    for(int v : adj[u]){
        if(v != parent){
            solve1(adj, n, m, v, u);
            dp1[u] = (dp1[u]*(1 + dp1[v]))%m;
        }
    }
}
int main(){
    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
	int n, m;
	cin>>n>>m;
	vector<int> adj[n];
	for(int i=0;i<n-1;i++){
	    int u,v;
	    cin>>u>>v;
	    adj[u-1].push_back(v-1);
	    adj[v-1].push_back(u-1);
	}
	memset(dp1, 0, sizeof(dp1));
	memset(dp2, 0, sizeof(dp2));
	solve1(adj, n, m, 0, -1);
	solve2(adj, n, m, 0, -1, 0);
	for(int i=0;i<n;i++){
	    cout<<dp2[i]<<"\n";
	}
}

Measured memory_bytes: 26368
N = int(input())
C = list(input())

r_cnt = C.count("R")
w_cnt = C.count("W")

ref_c = ["R"]*r_cnt + ["W"]*w_cnt

cnt = 0
for i in range(N):
    if C[i] != ref_c[i]:
        cnt += 1

ans = min(r_cnt, w_cnt, int(cnt/2))
print(ans)

Measured memory_bytes: 13492
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define pii pair<int,int>
#define ld long double
const int mod=1e9 +7;







int32_t main()
{
     ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
 
  
  int n;
  cin>>n;
  
  set<int>v;
  for(int i=1;i<=9;i++)
  {
     for(int j=1;j<=9;j++)
     {
        v.insert(j*i);
     }
  }


  if(v.find(n)!=v.end())
  {
     cout<<"Yes";
  }
  else
  {
     cout<<"No";
  }
  
  

   
}

 

 
 
 
 
 

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)
 
#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=(int)(a)-1;i>=(int)(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)
 
#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define bit(n) (1LL<<(n))
 
// #define DEBUG
 
#ifdef DEBUG
    #define dump(...) fprintf(stderr, __VA_ARGS__)
#else
    #define dump(...)
#endif
 
template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}
 
using namespace std;
using ll=long long;
using vi=vector<int>;
using vll=vector<ll>;
 
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int inf = INT_MAX;
const ll INF = LLONG_MAX;
const ll MOD = 1000000007LL;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
 
ll extgcd(ll a,ll b,ll& x,ll& y){x=1,y=0;ll g=a;if(b!=0) g=extgcd(b,a%b,y,x),y-=a/b*x;return g;}
ll ADD(const ll &a, const ll &b, const ll mod=MOD) { return (a+b)%mod;}
ll SUB(const ll &a, const ll &b, const ll mod=MOD) { return (a-b+mod)%mod;}
ll MUL(const ll &a, const ll &b, const ll mod=MOD) { return (1LL*a*b)%mod;}
ll DIV(const ll &a, const ll &b, const ll mod=MOD) {ll x,y; extgcd(b,mod,x,y);return MUL(a,(x+mod)%mod,mod);}
 
int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);

    string a, b; cin >> a >> b;
    string c = a + b;

    stringstream ss; ss << c;
    int n; ss >> n;

    int sq = sqrt(n);
    cout << (sq * sq == n ? "Yes":"No") << endl;

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#define MAX 1005
  
int main()
{ 
  int tum, mum, num;
  int i, j, c[MAX][MAX];
  char a[MAX], b[MAX];
  
  scanf("%d", &tum);
  
  while(tum--){
    scanf("%s", a);
    scanf("%s", b);
    mum = strlen(a);
    num = strlen(b);
    for(i=1; i<=mum; i++){
      c[i][0] = 0;
    }
    for(j=0; j<=num; j++){
      c[0][j] = 0;
    }
    for(i=1; i<=mum; i++){
      for(j=1; j<=num; j++){
        if(a[i-1] == b[j-1]){
          c[i][j] = c[i-1][j-1] + 1;
        }
        else{
          if(c[i-1][j] >= c[i][j-1]) c[i][j] = c[i-1][j];
          else c[i][j] = c[i][j-1];
        }
      }
    }
    printf("%d", c[mum][num]);
    printf("\n");
  }
 
  return 0;
}


Measured memory_bytes: 5656
import java.util.*;
import java.io.BufferedInputStream;
 
public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner (new BufferedInputStream(System.in));
    int n = sc.nextInt();
    int x = sc.nextInt();
    int y = sc.nextInt();
    new Solution(n, x, y);
  }
}

class Solution {
    private int[] count;
    public Solution(int n, int x, int y) {
        int[] res = new int[n];
        for(int i = 1; i <= n; ++i) {
            count = new int[n + 1];
            Arrays.fill(count, Integer.MAX_VALUE);
            LinkedList<Integer> que = new LinkedList<>();
            que.offer(i);
            count[i] = 0;
            int d = 0;
            while(!que.isEmpty()) {
            int now = que.poll();
            if(now > 1 && count[now - 1] == Integer.MAX_VALUE) {
                que.offer(now - 1);
                count[now - 1] = count[now] + 1;
            }
            if(now < n && count[now + 1] == Integer.MAX_VALUE) {
                que.offer(now + 1);
                count[now + 1] = count[now] + 1;
            }
            if(now == x && count[y] == Integer.MAX_VALUE) {
                que.offer(y);
                count[y] = count[x] + 1;
            }
            if(now == y && count[x] == Integer.MAX_VALUE) {
                que.offer(x);
                count[x] = count[y] + 1;
            }
            }
            for(int j = 1; j <=n; ++j) {
            res[count[j]]++;
            }
        }
        for(int i = 1; i < n; ++i) {
            System.out.println(res[i] / 2);
        }
    }
}

Measured memory_bytes: 91908
#include <iostream>
#include <cstdio>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstring>
#define inf 2147483647
#define N 1000010
#define p(a) putchar(a)
#define For(i,a,b) for(int i=a;i<=b;++i)

using namespace std;
int n,cnt,ans;
int a[N];
char c[N];
void in(int &x){
    int y=1;char c=getchar();x=0;
    while(c<'0'||c>'9'){if(c=='-')y=-1;c=getchar();}
    while(c<='9'&&c>='0'){ x=(x<<1)+(x<<3)+c-'0';c=getchar();}
    x*=y;
}
void o(int x){
    if(x<0){p('-');x=-x;}
    if(x>9)o(x/10);
    p(x%10+'0');
}

signed main(){
    cin>>(c+1);
    n=(int)strlen(c+1);
    For(i,2,n){
    	if(c[i]!=c[i-1]) a[++cnt]=max(i-1,n-(i-1));
    }
    ans=n;
    For(i,1,cnt) ans=min(ans,a[i]);
    o(ans);
    return 0;
}

Measured memory_bytes: 2560
#include<iostream>
#include<iomanip>
#include<cassert>
#include<stdexcept>
#include<utility>
#include<functional>
#include<numeric>
#include<cmath>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<array>
#include<stack>
#include<queue>
#include<deque>
#include<vector>
#include<complex>
#include<set>
#include<map>
#include<unordered_map>
#include<unordered_set>
#include<string>
#include<bitset>
#include<memory>
using namespace std;
using ll=long long;

int main(){
    int n,k;
    cin>>n>>k;
    vector<int> sum(n);
    for(int i=0;i<n;i++){
        int d;
        cin>>d;
        for(int j=0;j<d;j++){
            int a;
            cin>>a;
            a--;
            sum[a]++;
        }
    }
    int res=0;
    for(int i=0;i<n;i++){
        if(!sum[i])  res++;
    }
    cout<<res<<endl;
    
    return 0;
}


Measured memory_bytes: 3612
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#endif
//#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
typedef long double ld;
typedef long long ll;
int n;
const int maxN = 205;
int x[maxN];
const int maxP = 1e7 + 10;
int f[maxP];
vector < int > g[maxN];
vector < int > by[2];
bool used[maxN];
int mt[maxN];
bool dfs(int v) {
    if (used[v]) return false;
    used[v] = true;
    for (int to : g[v]) {
        if (mt[to] == -1 || dfs(mt[to])) {
            mt[to] = v;
            return true;
        }
    }
    return false;
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
//    freopen("input.txt", "r", stdin);
    for (int i = 2; i < maxP; i++) {
        if (f[i] == 0) {
            f[i] = i;
            for (int j = 2 * i; j < maxP; j += i) f[j] = i;
        }
    }
    cin >> n;
    for (int i = 1; i <= n; i++) {
        cin >> x[i];
    }
    sort(x + 1, x + n + 1);
    vector < int > f;
    for (int i = 1; i <= n; i++) {
        if (x[i] + 1 != x[i + 1]) f.emplace_back(x[i] + 1);
        if (i == 1 || x[i] != x[i - 1] + 1) f.emplace_back(x[i]);
    }
    sort(f.begin(), f.end());
    f.erase(unique(f.begin(), f.end()), f.end());
    assert(f.size() % 2 == 0);
    for (int j = 0; j < f.size(); j++) {
        by[f[j] % 2].emplace_back(f[j]);
    }


    for (int i = 0; i < by[0].size(); i++) {
        for (int j = 0; j < by[1].size(); j++) {
            if (::f[abs(by[0][i] - by[1][j])] == abs(by[0][i] - by[1][j])) {
                g[i].emplace_back(j);
            }
        }
    }

    int tot = f.size();
    memset(mt, -1, sizeof mt);
    for (int i = 0; i < by[0].size(); i++) {
        memset(used, 0, sizeof used);
        dfs(i);
    }
    int c = 0;
    for (int j = 0; j < by[1].size(); j++) {
        if (mt[j] != -1) c++;
    }
    int lft1 = by[0].size() - c;
    cout << c + (tot - 2 * c) + (lft1 % 2 == 1)  << '\n';
    return 0;
}

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

int main() {
  int N,M;
  cin >> N >> M;
  vector<int>order(N-1);
  for(int i=0;i<N-1;i++){
    order.at(i)=i+2;
  }
  vector<set<int>>data(N+1);
  for(int i=0;i<M;i++){
    int a,b;
    cin >> a >> b;
    data.at(a).insert(b);
    data.at(b).insert(a);
  }
  int count=0;
  do{
    bool res=true;
    if(!data.at(1).count(order.at(0))) res=false;
    for(int i=0;i<N-2;i++){
      if(!data.at(order.at(i)).count(order.at(i+1))) res=false;
    }
    if(res) count++;
  }while(next_permutation(order.begin(),order.end()));
  cout << count;
}


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

#if defined(DEBUG)

#include <unistd.h>
#include <sys/fcntl.h>
#define DLOG(...)        cerr << dbgFormat(__VA_ARGS__) << endl
#define DCALL(func, ...) func(__VA_ARGS__)

template <class... Args>
string dbgFormat(const char* fmt, Args... args) {
  size_t len = snprintf(nullptr, 0, fmt, args...);
  char buf[len + 1];
  snprintf(buf, len + 1, fmt, args...);
  return string(buf);
}

#else  // defined(DEBUG)

#define DLOG(...)
#define DCALL(func, ...)

#endif // defined(DEBUG)
// ----------------------------------------------------------------------

// ----------------------------------------------------------------------
int main(int argc, char *argv[]) {
#if defined(DEBUG)
  // GDB on Cygwin ignores redirection at run command.
  if (argc == 2) dup2(open(argv[1], 0), 0);
#else
  // For performance.  We should not use C-style stdio functions
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
#endif
  cout << setprecision(20);

  int N, K, Q; cin >> N >> K >> Q;
  vector<int> nCor(N);
  for (int i = 0; i < Q; i++) {
    int a; cin >> a; a--;
    nCor.at(a)++;
  }
  for (int i = 0; i < N; i++) {
    if (Q - nCor.at(i) >= K) {
      cout << "No\n";
    }else {
      cout << "Yes\n";
    }
  }

  return 0;
}



Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
// https://atcoder.jp/contests/abc051/tasks/abc051_b
int main()
{
    int k,s,count=0;
    cin >> k >> s;

    for(int x=0; x<=k; x++)
    for(int y=0; y<=k; y++)
    {
        int z=s-x-y;
        if(0<=z&&z<=k) count++;
    }
     
    cout << count << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define rrep(i,n) for(int i=1;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin,(a).rend()
#define dunk(a) cout << (a) << endl
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int inf = 1001001001;
const int mod = 1000000007;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int sx, sy, tx, ty;
	cin >> sx >> sy >> tx >> ty;

	int a = tx - sx, b = ty - sy;
	int c = a + 1 , d = b + 1;
	string ans = "";
	while (b > 0) {
		ans += 'U';
		b--;
	}
	while (a > 0) {
		ans += 'R';
		a--;
	}
	int n = ans.size();
	rep(i, n) ans += ans[i] == 'R' ? 'L' : 'D';
	n = ans.size();
	ans += 'L';
	while (d > 0) {
		ans += 'U';
		d--;
	}
	while (c > 0) {
		ans += 'R';
		c--;
	}
	ans += 'D';
	int k = ans.size();
	for (int i = n; i < k; ++i) {
		if (ans[i] == 'L') ans += 'R';
		if (ans[i] == 'R') ans += 'L';
		if (ans[i] == 'U') ans += 'D';
		if (ans[i] == 'D') ans += 'U';
	}

	dunk(ans);

	return 0;
}

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

const int MAX_N = 1 << 19;
const int INF = 1 << 28;
const int def = -INF;

struct MaxSegTree2{
	int n;
	ll segMax[2 * MAX_N - 1], segAdd[2 * MAX_N - 1];
	void init(int n_){
		n = 1;
		while(n < n_) n *= 2;
		for(int i = 0; i < 2 * n - 1; i++) segMax[i] = 0, segAdd[i] = 0;
	}

	void add(int a, int b, ll x){ add(a, b, x, 0, 0, n); }

	void add(int a, int b, ll x, int k, int l, int r){
		if(r <= a || b <= l) return;
		if(a <= l && r <= b){
			segAdd[k] += x;
			return;
		}
		add(a, b, x, k * 2 + 1, l, (l + r) / 2);
		add(a, b, x, k * 2 + 2, (l + r) / 2, r);
		segMax[k] = max(segMax[k * 2 + 1] + segAdd[k * 2 + 1], segMax[k * 2 + 2] + segAdd[k * 2 + 2]);
	}

	ll query(int a, int b){ return query(a, b, 0, 0, n); }

	ll query(int a, int b, int k, int l, int r){
		if(r <= a || b <= l) return def;
		if(a <= l && r <= b) return segMax[k] + segAdd[k];
		ll vl = query(a, b, k * 2 + 1, l, (l + r) / 2);
		ll vr = query(a, b, k * 2 + 2, (l + r) / 2, r);
		return max(vl, vr) + segAdd[k];
	}
} st;

typedef pair<int, int> P;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
#ifdef LOCAL
	std::ifstream in("in");
	std::cin.rdbuf(in.rdbuf());
#endif

	int N, M;
	cin >> N >> M;

	vector<P> p(N);
	for(int i = 0; i < N; i++){
		cin >> p[i].first >> p[i].second;
	}
	sort(p.begin(), p.end());

	st.init(M + 10);
	for(int i = M + 1; i >= 1; i--){
		st.add(i, i + 1, i);
	}

	auto f = [&]{
		for(int i = 0; i < M + 1; i++){
			cout << st.query(i, i + 1) << " ";
		}
		cout << endl;
	};

	//f();
	int ans = max(0, N - M);
	for(int i = 0; i < N; i++){
		int L = p[i].first, R = p[i].second;
		st.add(0, R + 1, 1);
		int sum = -(L + M + 1);
		sum += st.query(0, M + 2);
		//f();
		ans = max(ans, sum);
	}
	cout << ans << endl;
}


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

using namespace std;

typedef long long ll;

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

	int N;
	cin >> N;

	vector<int> V(N);
	rep(i, N) cin >> V[i];

	vector<int> C(N);
	rep(i, N) cin >> C[i];

	int ans = 0;
	rep(i, N){
		ans += max(V[i] - C[i], 0);
	}

	cout << ans << endl;
}


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

int gcd(int a, int b);
int gcd(const std::vector<int>& arr);

int main() {

        std::string s;
        std::cin >> s;
        for (std::size_t i = 0; i < s.length() - 1; ++i) {
                if (s[i] == s[i + 1]) {
                        std::cout << "Bad" << std::endl;
                        return 0;
                }
        }
        std::cout << "Good" << std::endl;
        return 0;
}

int gcd(int a, int b) {
        if (a > b) {
                std::swap(a, b);
        }

        for (int r = b % a; r != 0; b = a, a = r, r = b % a)
                ;

        return a;
}

int gcd(const std::vector<int>& arr) {
        const int size = arr.size();
        if (size == 0) {
                return 0;
        }
        else if (size == 1) {
                return arr[0];
        }

        int ret = gcd(arr[0], arr[1]);

        for (std::size_t i = 2; i < size && ret != 1; ++i) {
                ret = gcd(arr[i], ret);
        }

        return ret;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <math.h>
#include <vector>
#include <string>
#include <queue>
#include <numeric>

using namespace std;

typedef long long int ll;
typedef long int li;

bool compare_by_b(pair<int, int> a, pair<int, int> b) {
    if(a.second != b.second){
        return a.second < b.second;
    }else{
        return a.first < b.first;
    }
}

int main(){
    ll ans=0;
    int n;
    int x=0;
    cin >> n;
    int v[n],c[n],j[n];
    for(int i=0;i<n;i++)cin >> v[i];
    for(int i=0;i<n;i++)cin >> c[i];
    for(int i=0;i<n;i++)if(v[i]>c[i])ans+=(v[i]-c[i]);
    
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 256
# C - Walk on Multiplication Table

N = int(input())
start = [1, 1]
end = [0, 0]
for i in range(1, int(N ** (1 / 2)) + 1):
    if N % i == 0:
        end[0] = i
        end[1] = N // i

print((end[0] - start[0]) + (end[1] - start[1]))


Measured memory_bytes: 3188
#include <iostream>
#include <bitset>

using namespace std;

int main(){
    int N, K;
    long ans = 0;
    int A[100000];
    int B[100000];
    cin >> N >> K;
    for(int i = 0; i < N; i++){
        cin >> A[i] >> B[i];
    }
    for(int i = 0; i < N; i++){
        if((K|A[i]) <= K) ans += B[i];
    }
    int n = 1;
    for(int i = 0; i <= 30; i++){
        if(K & n){
            int m = n-1;
            int K_ = K^n;
            K_ = K_ | m;
            //std::cout << std::bitset<8>(n) << endl;
            //std::cout << std::bitset<8>(K_) << endl;
            long tmp = 0;
            for(int i = 0; i < N; i++){
                if((K_|A[i]) <= K_) tmp += B[i];
            }
            ans = max(ans, tmp);
        }
        n = n << 1;
    }
    cout << ans << endl;
}

Measured memory_bytes: 1656
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>
#include <iomanip>
#include <map>
using namespace std;

int main() {
    double t, x;
    cin >> t >> x;
    double ans = t / x;
    cout << fixed << setprecision(10) << ans << endl;
}

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

int main() {

  int m;
  cin >> m;
  int x, y, w, h;
  int n;
  int cnt = 0;

  while( m-- ) {
    cnt = 0;
    cin >> x >> y >> w >> h;
    cin >> n;
    
    int xx = x + w;
    int yy = y + h;
    
    for(int i=0; i<n; i++) {
      int a, b;
      cin >> a >> b;
      if( x <= a && a <= xx && y <= b && b <= yy ) cnt++;
    }
    
    cout << cnt << endl;
  }
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
using namespace std;
//Optimisations
#pragma GCC target ("avx2")
#pragma GCC optimization ("unroll-loops")
#pragma GCC optimize("O2")
//shortcuts for functions
#define pb push_back
#define mp make_pair
#define ff first 
#define ss second
#define all(v) v.begin(),v.end()
#define prec(n) fixed<<setprecision(n)
#define n_l '\n'
// make it python 
#define gcd __gcd
#define append push_back
#define str to_string
// utility functions shortcuts
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define sswap(a,b) {a=a^b;b=a^b;a=a^b;}
#define swap(a,b) {auto temp=a; a=b; b=temp;}
#define init(dp) memset(dp,-1,sizeof(dp));
#define set0(dp) memset(dp,0,sizeof(dp));
#define bits(x) __builtin_popcount(x)
#define SORT(v) sort(all(v))
#define endl "\n"
#define forr(i,n) for(ll i=0;i<n;i++)
// declaration shortcuts
typedef long long int ll;
#define int ll
// Constants
constexpr int dx[] = {-1, 0, 1, 0, 1, 1, -1, -1};
constexpr int dy[] = {0, -1, 0, 1, 1, -1, 1, -1};
constexpr ll INF = 1999999999999999997; 
constexpr int inf= INT_MAX;
constexpr int MAXSIZE = int(1e6)+5;
constexpr auto PI  = 3.14159265358979323846L;
constexpr auto oo  = numeric_limits<int>::max() / 2 - 2;
constexpr auto eps = 1e-6;
constexpr auto mod = 1000000007;
constexpr auto MOD = 1000000007;
constexpr auto MOD9 = 1000000009;
constexpr auto maxn = 100006;
//void IOfile(){
//freopen(file_name, reade_mode, stdin);
//freopen(file_name, write_mode, stdout);
//}
void fastio(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
}
int32_t main(){
	fastio();
	int sum = 0;
	int ans = 0;
	int n;
	cin >> n;
	int a[n];
	for(int i = 0; i < n; i++) cin >> a[i], sum += a[i];
	sum %= mod;
	for(int i = 0; i < n; i++){
		sum -= a[i];
		sum = (sum + mod) % mod;
		ans += (a[i] % mod * sum % mod) % mod;
		ans %= mod;
	}
	cout << ans;
}

Measured memory_bytes: 5204
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b;
  cin >> a >> b;
  if(b == 100){
    b += 1;
    for(int i = 0;i<a;i++){
    b *= 100;
    }
    cout << b << endl;
  }
  else{
    for(int i = 0;i<a;i++){
      b *= 100;
    }
    cout << b << endl;
  }
}


Measured memory_bytes: 256
#include<string.h>
    #include<stdio.h>
    
    
    int main(){
    	char s[1000], t[1000];
    	int i,k,l;
    	scanf("%s%s",s,t);
    	l=strlen(s);
    	for(k=0;k<l;k++){
    		char rot=s[l-1];	
    		for(i=l-2;i>=0;i--){
    			
    			s[i+1]= s[i];
    		}
    		s[0]=rot;
    	
    	if(strcmp(s,t)==0){
    			printf("Yes\n");
    			return 0;
    		}
    }
    printf("No\n");
    		
    		
    return 0;	
    }

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

def solve():
    S = input()

    ans = 0
    tmp = 0
    for s in S:
        if s=="A" or s=="C" or s=="G" or s=="T":
            tmp += 1
        else:
            ans = max(ans, tmp)
            tmp = 0
    ans = max(ans, tmp)
    print(ans)


if __name__ == "__main__":
    solve()


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

int main() {
  const int Nbit= 100;
  bitset<Nbit> bs;

  int N,K;
  cin >> N >> K;

  int buf,idx;
  for(int i=0; i<K; i++){
    cin >> buf;
    for(int j=0; j<buf; j++){
      cin >> idx;
      idx--; // 1-indexed -> 0-indexed
      bs.set(idx);
    }
  }

  cout << N- bs.count() << endl;
}

Measured memory_bytes: 3620
#include<iostream>
#include<cstring>
#include<string>
#include<cmath>
#include<algorithm>
#include<vector>
#include<map>
#include<stack>
#include<queue>
#include<iomanip>
using namespace std;

int main(){
	int M,N;
	cin>>M>>N;
	vector<bool> hasRed(M+1,false);
	hasRed[1]=true;
	vector<int> nums(M+1,1);
	int x,y;
	int res=0;
	for(int i=0;i<N;++i){
		cin>>x>>y;
		if(hasRed[x]){
			hasRed[y]=true;
		}
		nums[x]-=1;
		nums[y]+=1;
		if(nums[x]==0)
			hasRed[x]=false;
	}
	for(int j=1;j<=M;j++){
		if(hasRed[j])
			res++;
	}
	cout<<res;
	return 0;
} 

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

int main() {
  int n; cin>>n;
  map<string, int> P;
  rep(i, n) {
    string S; cin>>S;
    P[S]++;
  }
  int tmp=0;
  auto begin=P.begin(), end=P.end();
  for (auto iter=begin; iter!=end; iter++) {
    int t=iter->second;
    tmp=max(tmp, t);
  }

  begin=P.begin();
  end=P.end();
  for (auto iter=begin; iter!=end; iter++) {
    int t=iter->second;
    if (t==tmp) cout<<iter->first<<endl;
  }
}

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

/*ll binpow(ll a, ll n, ll mod){
    if(n==0){
        return 1;
    }
    ll res = binpow(a, n/2, mod);
    if(n%2!=0){
        return (res*res*a) % mod;
    }else{
        return (res*res) % mod;
    }
    return res;
}*/
int main() {
    // int t; cin>>t;
    // while(t--){
        ll n;
        cin>>n;
        if(n==1){
            cout<<"0";
            return 0;
        }
        ll mod=1000000007;
        // ll a = binpow(10,n,mod) % mod;
        // ll b = binpow(9,n,mod) % mod;
        // ll c = binpow(8,n,mod) % mod;
        // ll ans = a - 2*b + c;
        ll a=1,b=1,c=1,ans=0;
        for(int i=0;i<n;i++){
            a*= 10;
            b*= 9;
            c*= 8;
            a%=mod;
            b%=mod;
            c%=mod;
        }
        ans = (a+c)%mod - (2*b)%mod;
        if(ans<0) ans+=mod;
        ans %= mod;
        cout<<ans;
        
    // }
}

Measured memory_bytes: 3592
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define lvector vector<ll>
#define cvector vector<char>
#define svector vector<string>
#define lque queue<ll>
#define lpque priority_queue<ll>
#define dlpque priority_queue<ll,lvector,greater<ll>>
#define P pair<ll,ll>
#define ALL(a) a.begin(),a.end()
#define RALL(a) a.rbegin(),a.rend()
#define rep(i,n) for(ll i=0; i<n; ++i)
#define print(a) cout << (a) << endl

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n,inf=1e9+10;cin>>n;
  lvector A(n);rep(i,n) cin>>A[i];
  reverse(ALL(A));
  lvector dp(100000,inf);
  rep(i,n) {
    auto it=upper_bound(ALL(dp),A[i]);
    *it=A[i]; 
  }
  print(lower_bound(ALL(dp),inf)-dp.begin());
  return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
long long x[100001],ans,n,a,b,i;
int main()
{
    cin>>n>>a>>b;
    for(i=1;i<=n;i++) cin>>x[i];
    for(i=2;i<=n;i++) ans+=min((x[i]-x[i-1])*a,b);
    cout<<ans<<endl;
}

Measured memory_bytes: 1024
N, D, A = map(int, input().split())
XH = [list(map(int, input().split())) for _ in range(N)]

XH.sort()
q = []
t = 0
result = 0
for x, h in XH:
    while True:
        if len(q) == 0:
            break
        if x <= q[0][0]:
            break
        t -= q[0][1]
        q.pop(0)
    h -= t
    if h < 0:
        continue
    c = (h + A - 1) // A
    result += c
    t += c * A
    q.append((x + 2 * D, c * A))
print(result)


Measured memory_bytes: 66112
import java.util.Scanner;

public class Main {

	static Scanner sc = new Scanner(System.in);

	public static void main(String[] args) throws Exception {
		String s = sc.next();
		int[] count = new int[4];
		for (int i = 0; i < s.length(); ++i) {
			if (s.charAt(i) == 'K') {
				count[0]++;
			} else if (s.charAt(i) == 'U') {
				count[1]++;
			} else if (s.charAt(i) == 'P') {
				count[2]++;
			} else if (s.charAt(i) == 'C') {
				count[3]++;
			}
		}
		int ans = Integer.MAX_VALUE;
		for (int i = 0; i < 4; ++i) {
			ans = Math.min(ans, count[i]);
		}
		System.out.println(ans);
	}

}

Measured memory_bytes: 12000
#include<iostream>
using namespace std;
int main(){
	int a,b,max=0,min=0;
	long long int sum=0;
	cin>>a;
	for (int i=0;i<a;i++){
		cin>>b;
		sum=sum+b;
		if(max<b||i==0){
			max=b;
		}
		if(min>b||i==0){
			min=b;
		}
	}
	cout<<min<<" "<<max<<" "<<sum<<endl;
}


Measured memory_bytes: 3116
#include <iostream>
#include <cstring>
using namespace std;
int N, M;
int crystal[21][21];
char ord[31];
int dist[31];

void solve() {
  memset(crystal, 0, sizeof crystal);
  
  for(int i=0;i<N;i++) {
    int x, y;
    cin>>x>>y;
    crystal[y][x] = 1;
  }
  
  cin>>M;
  for (int i = 0; i < M; i += 1) {
    cin>>ord[i]>>dist[i];
  }
  
  // explore
  int x = 10, y = 10, cnt = 0;
  // ツスツタツーツトツ地ツ点ツづ個陛ウツ静篠確ツ認
  if (crystal[y][x] == 1) {
    cnt++; crystal[y][x] = 0;
  }
  for (int i = 0; i < M; i += 1) {
    // ツ陛サツ古シツづ可督ョツつュ
    for (int j = 0; j < dist[i]; j += 1) {
      //cout<<x<<","<<y<<endl;
      if (ord[i] == 'N') {
        y++;
      } else if (ord[i] == 'S') {
        y--;
      } else if (ord[i] == 'E') {
        x++;
      } else {
        x--;
      }  
      // ツ陛ウツ静篠確ツ認
      if (crystal[y][x] == 1) {
        cnt++; crystal[y][x] = 0;
      }
    }
  }
  //cout<<cnt<<endl;
  if (cnt == N) {
    cout<<"Yes"<<endl;
  } else {
    cout<<"No"<<endl;
  }
}


int main (int argc, char const* argv[]) {
  while (cin>>N, N) {
    solve();
  }
  return 0;
}

Measured memory_bytes: 0
// template version 1.12
using namespace std;
#include <iostream>
#include <bits/stdc++.h>

// varibable settings
#define infile "../test/sample-1.in"
#define int long long //{{{
const int INF=1e18;
const int MOD=1e9+7; //}}}

// define basic macro {{{
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define _rrep(i,n) rrepi(i,0,n)
#define rrepi(i,a,b) for(int i=(int)((b)-1);i>=(int)(a);--i)
#define rrep(...) _overload3(__VA_ARGS__,rrepi,_rrep,)(__VA_ARGS__)
#define each(i,a) for (auto&& i : a)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define pb(a) push_back(a)
#define mp(a, b) make_pair(a, b)
#define ceil(a,b) ((a)+(b)-1)/(b)
#define uni(x) sort(all(x));x.erase(unique(all(x)),x.end())
#define ub upper_bound
#define lb lower_bound
#define posl(A, x) (lower_bound(all(A), x)-A.begin())
#define posu(A, x) (upper_bound(all(A),x)-A.begin())
template<class T> inline void chmax(T &a, const T &b) { if((a) < (b)) (a) = (b); }
template<class T> inline void chmin(T &a, const T &b) { if((a) > (b)) (a) = (b); }

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

template<typename T> using PQ = priority_queue<T, vector<T>, greater<T>>;
struct Fast { Fast(){ std::cin.tie(0); ios::sync_with_stdio(false); } } fast;

#if defined(PCM) || defined(LOCAL)
  #include "lib/dump.hpp"
#else
  #define dump(...) 42
  #define dump_1d(...) 42
  #define dump_2d(...) 42
#endif
//}}}

int solve(){
  string s;cin>>s;
  if (s=="Sunny"){
    cout << "Cloudy" << endl;
  }
  if (s=="Cloudy"){
    cout << "Rainy" << endl;
  }
  if (s=="Rainy"){
    cout << "Sunny" << endl;
  }
  return 0;
}

signed main() { //{{{
#ifdef INPUT_FROM_FILE
  std::ifstream in(infile);
  std::cin.rdbuf(in.rdbuf());
#endif
  solve();
  return 0;
} //}}}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <utility>

#define REP(i, a, b) for (int i = int(a); i < int(b); i++)
#define dump(val) cerr << __LINE__ << ":\t" << #val << " = " << (val) << endl

using namespace std;

typedef long long int lli;
typedef pair<string, string> pss;

template<typename T>
vector<T> make_v(size_t a, T b) {
    return vector<T>(a, b);
}

template<typename... Ts>
auto make_v(size_t a, Ts... ts) {
    return vector<decltype(make_v(ts...))>(a, make_v(ts...));
}

int main() {
    int n;
    cin >> n;
    string str;
    cin >> str;
    map<pss, lli> m1, m2;
    REP(i, 0, 1 << n) {
        string red = "", blue = "";
        REP(j, 0, n) {
            if ((i >> j) & 1) {
                red += str[j];
            } else {
                blue += str[j];
            }
        }
        m1[make_pair(red, blue)]++;
    }
    REP(i, 0, 1 << n) {
        string red = "", blue = "";
        REP(j, 0, n) {
            if ((i >> j) & 1) {
                red += str[j + n];
            } else {
                blue += str[j + n];
            }
        }
        reverse(begin(red), end(red));
        reverse(begin(blue), end(blue));
        m2[make_pair(red, blue)]++;
    }
    lli ans = 0;
    for (auto &mp : m1) {
        ans += mp.second * m2[mp.first];
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 103424
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

#include <complex>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#define debug(x) cerr << #x << " = " << (x) << endl;


#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 100010

int d,n,b;
int p[SIZE],h[SIZE];

double calc(int sp){
  double g = 1.0;
  
  double w = (double)d / sp;

  double l = sqrt(sqrt(w*w/4)), r = 1e10;
  
  while(r - l > 1e-9){    
    double vy = (l+r)/2;
    double t = vy / g;
    double vx = w / (t * 2);

    bool flag = true;
    
    for(int i=0;i<n;i++){
      double spp = p[i] - floor(p[i]/w) * w;
      
      if(spp > w/2){
        spp = w - spp;
      }

      if(spp < 1e-11){
        flag = false;
        break;
      }
      
      if(h[i] > vy * spp/vx - g * (spp*spp) / (vx*vx) / 2){
        flag = false;
        break;
      }
    }

    if(flag){
      r = vy;
    }else{
      l = vy;
    }
  }

  double vy = l;
  double t = vy / g;
  double vx = w / (t * 2);

  return sqrt(vx*vx + vy*vy);
}

int main(){

  scanf("%d%d%d",&d,&n,&b);
  
  for(int i=0;i<n;i++)
    scanf("%d%d",p+i,h+i);

  double ans = 1e15;
  
  for(int i=0;i<=b;i++){
    ans = min(ans, calc(i+1));
  }

  printf("%.10lf\n",ans);
  
  return 0;
}

Measured memory_bytes: 3228
#include <iostream>
#include <utility>
#include <string>
#include <vector>
#include <math.h>
#include <algorithm>
using namespace std;
#define fastIO                        \
	ios_base::sync_with_stdio(false); \
	cin.tie(NULL);                    \
	cout.tie(NULL);
// g++ -std=c++11 -O2 -Wall *.cpp -o *
#define eps 1e-9
#define MAX 1000000001
#define MOD 998244353
#define Fi first
#define Se second
#define PB push_back
#define MP make_pair
typedef long long ll;
typedef pair<int, int> pr_int;



int main()
{
	//freopen("input.txt", "r", stdin);
	int a, b;
	scanf("%d %d", &a, &b);
  	for(int i = max(-1000000, b-a+1); i <= min(1000000, b+a-1); ++i)
		printf("%d ", i);

	return 0;
}


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

#define int long long

using namespace std;



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

    int N;
    cin >> N;

    bool flag = false;

    bool fff = true;

    int mult = 1;

    for(int i = 0 ; i < N ; i++)
    {
    	int n;
    	cin >> n;
 
    	if(n == 0)
      {
          flag = true;
          break;
      }

    	if(mult > 1000000000000000000/n)
    	{
    		fff = false;
    		mult = 0;
    	}

      mult *= n;

    }

    if(flag)
    {
    	cout << 0 << '\n';
    }
    else
   	{
   		if(fff)
   		{
   			cout << mult << '\n';
   		}
   		else
   		{
   			cout << -1 << '\n';
   		}
   	}

    return 0;
}

Measured memory_bytes: 3644
#include<bits/stdc++.h>
using namespace std;
#define ioS            ios::sync_with_stdio(false);cin.tie(0);
#define li             long int
#define lli            long li
#define ull            unsigned lli
#define pi             pair<int,int>
#define vi             vector<int>
#define vli            vector<li>
#define vlli           vector<lli>
#define vvi            vector<vector<int>>
#define pb             push_back
#define mp             make_pair
#define forn(i,s,n)    for(auto i=s;i<n;i++)               
#define forr(i,s,n)    for(auto i=s;i>=n;i--) 
const lli MOD = 1e9+7;
const lli mx = 1e7; 

void solve()
{
    char c;
    cin>>c;
    if(c>='a' && c<='z')  
    cout<<"a"<<endl;
    else
    cout<<"A"<<endl;  
}


int32_t main()
{
    ioS
    // int t;
    // cin>>t;
    // while(t--)
        solve();
}

Measured memory_bytes: 3608
#include <iostream>
#include <string>
#include <vector>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <cstring>
#include <ios>
#include <iomanip>

using namespace std;
// ascending order
#define vsort(v) sort(v.begin(), v.end())
// descending order
#define vsort_r(v) sort(v.begin(), v.end(), greater<int>())
#define vunique(v) unique(v.begin(), v.end())
#define mp make_pair
#define ts(x) to_string(x)
#define rep(i, a, b) for(int i = (int)a; i < (int)b; i++)
#define repm(i, a, b) for(int i = (int)a; i > (int)b; i--)
#define bit(a) bitset<8>(a)
#define des_priority_queue priority_queue<int, vector<int>, greater<int> >
#define all(v) (v).begin(), (v).end()
typedef long long ll;
typedef pair<int, int> P;
const ll INF = 1e18;

vector<pair<int, int> > v;
vector<int> year[100005];
int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);

	int N, M;
	cin >> N >> M;
	rep(i, 0, M) {
		int p, y;
		cin >> p >> y;
		v.push_back(make_pair(y, p));
		p--;
		year[p].push_back(y);
	}

	rep(i, 0, N) vsort(year[i]);

	rep(i, 0, M) {
		int city = v[i].second - 1;

		auto it = lower_bound(year[city].begin(), year[city].end(), v[i].first);
		cout << setfill('0') << right << setw(6) << city + 1;
		cout << setfill('0') << right << setw(6) << it - year[city].begin() + 1 << endl;
	}

}


Measured memory_bytes: 7796
#include<stdio.h>
int main(void){
        int h,w,hc,wc;
        while(1){
	 scanf("%d %d",&h,&w);
         if(h==0 && w==0){
          break;
         }
	 for(hc=1;hc<=h;hc++){
 	        for(wc=1;wc<=w;wc++){
	 	        if(wc==1 || wc==w || hc==1 || hc==h){
                                printf("#");
                        }else{
                                printf(".");
                        }
                 }
                 printf("\n");
	 }
        printf("\n");
        }
	return 0;
}


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

int main(void) {
	string A;
	cin >> A;
	int N = 1;
	for (int i = 0; i < N; i++)
	{
		if (A.at(i) == 'a' || A.at(i) == 'i' || A.at(i) == 'u' || A.at(i) == 'e' || A.at(i) == 'o')
			cout << "vowel" << endl;
		else
			cout << "consonant" << endl;
	}
}

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

using namespace std;

int main() {
	int a, b;
	while (cin >> a >> b, a || b) {
		if (a < b) cout << a << " " << b << endl;
		else cout << b << " " << a << endl;
	}
}

Measured memory_bytes: 1160
#include <cstdio>
#include <iostream>
#include <cstring>
#include <algorithm>
using namespace std;

int main() {
	int digit, n, x;
	string s;
	scanf("%d", &n);
	digit = n/100;
	for (int i = 0; i < 3; i++) s+= digit +'0';
	x = stoi(s);
	if (n <= x) printf("%d", x);
	else printf("%d", x + 111);
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;

vector<ll> divisor(ll n){
  vector<ll> ret;
  for(ll i=1; i*i<=n; i++){
    if(n%i==0){
      ret.push_back(i);
      if(i!=n/i) ret.push_back(n/i);
    }
  }
  //sort(ret.begin(), ret.end());
  return ret;
}

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

  vector<ll> res = divisor(N);

  ll ret = 0;
  rep(i,res.size()){
    ll x = (N-res[i])/res[i];
    if(x > 0 && N/x == N%x){
      ret += x;
    }
  }

  cout << ret << endl;
  
  return 0;
}



Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
string s;
int main()
{
	cin>>s;
	long long ans=0;
	for(int i=(int)s.size()-1,cur=i;i>=0;i--)
		if(s[i]=='B')ans+=cur-- -i;
	cout<<ans<<'\n';
}


Measured memory_bytes: 640
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#define N 200010
#define ll long long
using namespace std;
int n;
ll num[N],m;
int main()
{
	scanf("%d%lld",&n,&m);
	for(int i=1;i<=n<<1;i++) scanf("%lld",&num[i]);
	sort(num+1,num+n*2+1);
	int l=0,r=n;
	while(l<r)
	{
		int mid=(l+r)>>1;
		bool can=true;
		for(int i=mid*2+1;can && i<=n*2;i++)
        if(num[i]+num[n*2-i+mid*2+1]<m) can=false;
        if(can) r=mid;
        else l=mid+1;
	}
	int u=r<<1;
	ll ans=0;
	for(int i=1;i<=u>>1;i++) ans=max(ans,num[i]+num[u-i+1]);
	for(int i=u+1;i<=(n*2+u)>>1;i++) ans=max(ans,num[i]+num[n*2-i+u+1]-m);
	printf("%lld",ans);
	return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#include <vector>
#include <queue>
#include <set>
#include <iostream>
#include <iomanip>
using namespace std;
typedef long long LL;
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)

int main(){
    int N;
    LL C, K;
    cin >> N >> C >> K;
    vector<LL> T(N);
    REP(i,N)cin>>T[i];

    sort(T.begin(), T.end());
    int count = 0;
    LL time = T[0];
    LL man = 0;
    REP(i,N){
        man++;

        if(man>C || T[i]>time+K){
            count++;
            time = T[i];
            man = 1;
        }        
        
    }

    if(man!=0){count++;}

    cout << count << endl;
    return 0;

}

Measured memory_bytes: 4032
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main(){

int num;
vector<int> a;

cin >> num;

for(int i = 0; i < num;i++){
int b = 0;
cin >> b;
a.push_back(b);

}

reverse(a.begin(), a.end());

for(int i = 0; i < num;i++){

cout << a[i];

if(i != (num-1)){

cout << " ";

}else{

cout << endl;

}

}
return 0;

}


Measured memory_bytes: 3104
import numpy as np
import math
n,d=[int(i) for i in input().split()]
x=[]
for _ in range(n):
  x.append(np.array([int(i) for i in input().split()]))
def dis(x,y):
  return int(np.sum((x-y)**2))
def iss(x):
  a=round(math.sqrt(x))
  return a**2==x
k=0
for i in range(n):
  for j in range(i+1,n):
    if iss(dis(x[i],x[j])):
      k+=1
print(k)


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

int main(){
	int n;
	int m;
	char before, after;
	char ch;
	while(cin >> n){
		if(n == 0) break;
		map<char , char> mp;
		vector<char> vc;
		for(int i = 0; i < n; i++){
			cin >> before >> after;
			mp[before] = after;
			vc.push_back(before);
		}
		cin >> m;
		for(int i = 0; i < m; i++){
			cin >> ch;
			bool f = true;
			for(vector<char>::const_iterator iter = vc.begin();
				iter != vc.end(); iter++)
			{
				if(*iter == ch){
					cout << mp[ch];
					f = false;
					break;
				}
			}
			if(f) cout << ch;
		}
		cout << endl;
	}
	return 0;
}

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

int main()
{
	int N,i,x = 0,y = 0;
	int V[25],C[25];
	cin >> N;
	for( i = 0; i < N; i++ )
	{
		cin >> V[i];
	}
	for( i = 0; i < N; i++ )
	{
		cin >> C[i];
	}

	for( i = 0; i < N; i++ )
  {
		if( V[i] > C[i] )
		{
			x = x + V[i];
			y = y + C[i];
		}
	}
	cout << x - y << endl;
	return 0;
}


Measured memory_bytes: 256