akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <bitset>
#include <cmath>
#include <complex>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <vector>

const int MOD = 1e9 + 7;
const int iINF = 2147483647 / 2;
const long long int llINF = 9223372036854775807 / 2;

using namespace std;
using ll = long long int;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using vvvl = vector<vector<vector<ll>>>;

typedef pair<ll, ll> pll;
bool paircomp(const pll &a, const pll &b) {
  if (a.first == b.first)
    return a.second < b.second;
  return a.first < b.first;
}

#define REP(i, n) for (ll i = 0; i < (n); i++)
#define RREP(i, n) for (ll i = (n)-1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define AUTO(i, m) for (auto &i : m)
#define ALL(a) (a).begin(), (a).end()
#define MAX(vec) *std::max_element(vec.begin(), vec.end())
#define MIN(vec) *std::min_element(vec.begin(), vec.end())
#define ARGMAX(vec)                                                            \
  std::distance(vec.begin(), std::max_element(vec.begin(), vec.end()))
#define ARGMIN(vec)                                                            \
  std::distance(vec.begin(), std::min_element(vec.begin(), vec.end()))
#define REV(T) greater<T>()
#define PQ(T) priority_queue<T, vector<T>, greater<T>>
#define VVL(a, b, c) vector<vector<ll>>(a, vector<ll>(b, c))
#define VV(T, a, b, c) vector<vector<T>>(a, vector<T>(b, c))
#define VVVL(a, b, c, d)                                                       \
  vector<vector<vector<ll>>>(a, vector<vector<ll>>(b, vector<ll>(c, d)))
#define VVV(T, a, b, c, d)                                                     \
  vector<vector<vector<T>>>(a, vector<vector<T>>(b, vector<T>(c, d)))
#define SP(a) setprecision(a)
#define SQRT(a) sqrt((long double)(a))
#define DPOW(a, b) pow((long double)(a), (long double)(b))
#define UNIQUE(vec)                                                            \
  do {                                                                         \
    sort(ALL((vec)));                                                          \
    (vec).erase(std::unique(ALL((vec))), (vec).end());                         \
  } while (0)

ll POW(ll n, ll m) {
  if (m == 0) {
    return 1;
  } else if (m % 2 == 0) {
    ll tmp = POW(n, m / 2);
    return (tmp * tmp);
  } else {
    return (n * POW(n, m - 1));
  }
}

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

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ll N;
  cin >> N;
  bool ok = false;
  FOR(i, 1, 10) FOR(j, 1, 10) {
    if (i * j == N)
      ok = true;
  }
  if (ok)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
'use strict'

const main = (input) => {
    input = input.split('\n')
    const S = input[0] 
    const T = input[1]
    let words = S.split('')
    const Slen = words.length

    for(let i = 0; i < Slen; i++){
        let temp = words.pop()
        words.unshift(temp)
        if(words.join('') === T){
            console.log('Yes')
            return
        }
    }
    console.log('No')
}

main(require('fs').readFileSync('/dev/stdin', 'utf-8'))

Measured memory_bytes: 21064
def main():
    from math import ceil
    n, h, *ab = map(int, open(0).read().split())

    *c, = map(lambda x: -x, ab[::2])
    d = sorted(c + ab[1::2], key=abs, reverse=True)
    ans = 0
    for x in d:
        if x < 0:
            ans += ceil(h / abs(x))
            break

        h -= x
        ans += 1
        if h <= 0:
            break

    print(ans)


if __name__ == '__main__':
    main()


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

#define ll long long
#define mp make_pair
#define pb push_back

#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#define rep(i, n) for (int i = 0; i < (int)(n); ++ i)

const int mod = 924844033, g = 5;

inline int qp(int x, ll n) {
	int ans = 1;
	for (; n; n >>= 1, x = 1LL * x * x % mod)
		if (n & 1) ans = 1LL * ans * x % mod;
	return ans;
}

inline int inv(int n) {
	return qp(n, mod - 2);
}

inline void FFT(int *a, int n, bool f = 0) {
	static int r[1 << 19];
	int k = __builtin_ctz(n) - 1;
	for (int i = 1; i < n - 1; ++ i) {
		r[i] = r[i >> 1] >> 1 | (i & 1) << k;
		if (i < r[i]) swap(a[i], a[r[i]]);
	}
	for (int h = 2; h <= n; h <<= 1) {
		int w = qp(g, (mod - 1) / h);
		for (int i = 0; i < n; i += h) {
			int wn = 1;
			rep(j, h / 2) {
				int u = a[i + j], v = 1LL * a[i + j + h / 2] * wn % mod;
				a[i + j] = (u + v) % mod; a[i + j + h / 2] = (u + mod - v) % mod;
				wn = 1LL * w * wn % mod;
			}
		}
	}
	if (f) {
		reverse(a + 1, a + n);
		int r = inv(n);
		rep(i, n) a[i] = 1LL * a[i] * r % mod;
	}
}

struct poly : vector <int> {
	poly(int len = 0) { resize(len, 0); }
	poly(const initializer_list <int> &v) {
		resize(v.size());
		rep(i, v.size()) at(i) = *(v.begin() + i);
	}
	friend poly operator * (const poly &a, const poly &b) {
		static int A[1 << 19], B[1 << 19], C[1 << 19];
		int sz = 1;
		while (sz < (a.size() + b.size() - 1)) sz <<= 1;
		rep(i, sz) A[i] = i < (int)(a.size()) ? a[i] : 0;
		rep(i, sz) B[i] = i < (int)(b.size()) ? b[i] : 0;
		FFT(A, sz); FFT(B, sz);
		rep(i, sz) C[i] = 1LL * A[i] * B[i] % mod;
		FFT(C, sz, 1);
		poly c(a.size() + b.size() - 1);
		rep(i, c.size()) c[i] = C[i];
		return c;
	}
	friend ostream& operator << (ostream &out, const poly &a) {
		out << "{";
		rep(i, a.size()) out << a[i] << ",}"[i + 1 == (int)(a.size())];
		return out;
	}
};

int n;
vector <int> adj[1 << 19];
int sz[1 << 19];
int S[1 << 19];
int fac[1 << 19];

void dfs(int u, int p) {
	sz[u] = 1;
	rep(i, adj[u].size()) {
		int v = adj[u][i];
		if (v == p) continue;
		dfs(v, u);
		S[sz[v]] ++;
		sz[u] += sz[v];
	}
	S[n - sz[u]] ++;
}

int main() {
	rep(i, 1 << 19) fac[i] = i ? 1LL * i * fac[i - 1] % mod : 1;
	scanf("%d", &n);
	rep(i, n - 1) {
		int u, v; scanf("%d %d", &u, &v);
		-- u; -- v; adj[u].pb(v); adj[v].pb(u);
	}
	dfs(0, -1);
	poly a(n + 1); rep(i, n + 1) a[i] = 1LL * S[i] * fac[i] % mod;
	poly b(n + 1); rep(i, n + 1) b[n - i] = inv(fac[i]);
	poly c = a * b;
	rep(k, n + 1) if (k) {
		int ans = 1LL * n * fac[n] % mod * inv(fac[k]) % mod * inv(fac[n - k]) % mod;
		ans = (ans + mod - (1LL * c[n + k] * inv(fac[k]) % mod)) % mod;
		printf("%d\n", ans);
	}
	return 0;
}

Measured memory_bytes: 51456
N,M,X,Y=map(int,input().split())

xlist=list(map(int,input().split()))
ylist=list(map(int,input().split()))

xlist.append(X)
ylist.append(Y)

xlist=sorted(xlist)
ylist=sorted(ylist)

if xlist[-1]<ylist[0]:
    print("No War")
else:
    print("War")

Measured memory_bytes: 3064
x1,y1,x2,y2 = map(int, input().split())

x1 -= x2
y1 -= y2

c1 = complex(x1, y1)
c2 = c1 * (-1j)

print(int(c2.real+x2), int(c2.imag+y2), end = ' ')

c3 = c1 + c2
print(int(c3.real+x2), int(c3.imag+y2))

Measured memory_bytes: 3060
//https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8 より
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

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

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

//

fn run() {
    input! {
        n: usize,
        a: [u32; n],
    }
    let mut b: Vec<(usize, u32)> = a.into_iter().enumerate().collect();
    b.sort_by_key(|b| b.1);
    let mut ans = 0;
    for i in 0..n {
        if i % 2 != b[i].0 % 2 {
            ans += 1;
        }
    }
    ans /= 2;
    println!("{}", ans);
}

fn main() {
    run();
}


Measured memory_bytes: 8444
#include<iostream>
#include<cstdio>
#include<string>
#include<cstring>
#include<climits>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<tuple>
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vii vector<int>
#define vll vector<ll>
#define lb lower_bound
#define pb push_back
#define mp make_pair
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=a;i<b;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define INF (ll)1e9+7
#define LLINF (ll)1e30
// #define int ll
using namespace std;
const int MOD = 1e9 +7;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N,W;
    ll w[110],v[110],dp[110][101010]={};
    cin>>N>>W;
    rep(i,N){
        cin>>w[i]>>v[i];
    }
    rep(i,N){
        rep(j,W+1){
            if(j<w[i]){
                dp[i+1][j]=dp[i][j];
            }else{
                dp[i+1][j]=max(dp[i][j],dp[i][j-w[i]]+v[i]);
            }
        }
    }
    cout<<dp[N][W]<<endl;
    return 0;
}

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

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

using namespace std;

using ll = long long;

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

    int N, K;
    cin >> N >> K;
    K = min(K, 50);
    vector<int> A(N);
    REP(i, N) cin >> A[i];

    while (K-- > 0) {
        vector<int> B(N + 1);
        REP(i, N) {
            B[max(i - A[i], 0)] += 1;
            B[min(i + A[i] + 1, N)] -= 1;
        }
        REP(i, N) {
            B[i + 1] += B[i];
        }
        A = B;
    }

    REP(i, N) {
        cout << A[i] << " ";
    }
    cout << endl;

    return 0;
}


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

using namespace std;

int N;
int nobi[300000 + 10];

struct LazySegmentTree {
private:
	int n;
	vector<int> node, lazy;

public:
	LazySegmentTree(vector<int> v) {
		int sz = (int)v.size();
		n = 1; while (n < sz) n *= 2;
		node.resize(2 * n - 1);
		lazy.resize(2 * n - 1, 0);

		for (int i = 0; i<sz; i++) node[i + n - 1] = v[i];
		for (int i = n - 2; i >= 0; i--) node[i] = node[i * 2 + 1] + node[i * 2 + 2];
	}
	// k 番目のノードについて遅延評価を行う
	void eval(int k, int l, int r) {

		// 遅延配列が空でない場合、自ノード及び子ノードへの
		// 値の伝播が起こる
		if (lazy[k] != 0) {
			node[k] += lazy[k];

			// 最下段かどうかのチェックをしよう
			// 子ノードは親ノードの 1/2 の範囲であるため、
			// 伝播させるときは半分にする
			if (r - l > 1) {
				lazy[2 * k + 1] += lazy[k] / 2;
				lazy[2 * k + 2] += lazy[k] / 2;
			}

			// 伝播が終わったので、自ノードの遅延配列を空にする
			lazy[k] = 0;
		}
	}
	void add(int a, int b, int x, int k = 0, int l = 0, int r = -1) {
		if (r < 0) r = n;

		// k 番目のノードに対して遅延評価を行う
		eval(k, l, r);

		// 範囲外なら何もしない
		if (b <= l || r <= a) return;

		// 完全に被覆しているならば、遅延配列に値を入れた後に評価
		if (a <= l && r <= b) {
			lazy[k] += (r - l) * x;
			eval(k, l, r);
		}

		// そうでないならば、子ノードの値を再帰的に計算して、
		// 計算済みの値をもらってくる
		else {
			add(a, b, x, 2 * k + 1, l, (l + r) / 2);
			add(a, b, x, 2 * k + 2, (l + r) / 2, r);
			node[k] = node[2 * k + 1] + node[2 * k + 2];
		}
	}
	int getsum(int a, int b, int k = 0, int l = 0, int r = -1) {
		if (r < 0) r = n;
		if (b <= l || r <= a) return 0;

		// 関数が呼び出されたら評価！
		eval(k, l, r);
		if (a <= l && r <= b) return node[k];
		int vl = getsum(a, b, 2 * k + 1, l, (l + r) / 2);
		int vr = getsum(a, b, 2 * k + 2, (l + r) / 2, r);
		return vl + vr;
	}

};

LazySegmentTree dp(vector<int>(300000 + 10)), dp2(vector<int>(300000 + 10));

int main() {
	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> nobi[i];
		nobi[i] /= 10;
	}

	dp.add(0, 1, 1);
	for (int i = 0; i < N - 1; i++) {
		if (dp.getsum(i, i + 1) && nobi[i] > 0) {
			dp.add(i + 1, i + nobi[i] + 1, 1);
		}
	}
	if (!dp.getsum(N - 1, N)) {
		cout << "no" << endl;
		return 0;
	}
	dp2.add(N - 1, N, 1);
	for (int i = N - 1; i >= 0; i--) {
		if (dp2.getsum(i, i + 1) && nobi[i] > 0) {
			dp2.add(i - nobi[i], i, 1);
		}
	}
	if (!dp2.getsum(0, 1)) {
		cout << "no" << endl;
	}
	else {
		cout << "yes" << endl;
	}
	return 0;
}


Measured memory_bytes: 21688
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(ll i=0;i<n;i++)
#define all(n) n.begin(),n.end()
#define yn(x) cout << (x ? "Yes":"No") << endl;

double len(double x1,double x2,double y1,double y2){
  return sqrt( (x1-x2)*(x1-x2) + (y1-y2)*(y1-y2) );
}

int main() {
  double n;
  cin >> n;
  vector<double>x(n),y(n),a(n);
  rep(i,n) cin >> x[i] >> y[i];
  rep(i,n) a[i] = i;
  double sum = 0;
  do{
    rep(i,n-1) sum += len(x[a[i]],x[a[i+1]],y[a[i]],y[a[i+1]]);
  }while(next_permutation(all(a)));
  double kai = 1;
  for(int i=1;i<=n;i++) kai *= i;
   cout << std::fixed << std::setprecision(6) << sum/kai <<  endl;
         
}


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


void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i : x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}

#define fo(i, n) for(int i=0; i<n; i++)
#define Fo(i, k, n) for(int i=k; i<n; i++)
#define w(x)  int x; cin>>x; while(x--)
#define watch(x) cout << (#x) << " is " << (x) << "\n"
#define watch2(x,y) cout <<(#x)<<" is "<<(x)<<" and "<<(#y)<<" is "<<(y)<<"\n"
#define watch3(x,y,z) cout <<(#x)<<" is "<<(x)<<" and "<<(#y)<<" is "<<(y)<<" and "<<(#z)<<" is "<<(z)<<"\n"
#define watch4(x,y,z,q) cout <<(#x)<<" is "<<(x)<<" and "<<(#y)<<" is "<<(y)<<" and "<<(#z)<<" is "<<(z)<<" and "<<(#q)<<" is "<<(q)<<"\n"
#define MOD 1000000007
#define INF 1000000007;
#define F first
#define S second
#define pb(x) push_back(x);


#define ll  long long
#define all(c) (c).begin(),(c).end()
#define endl "\n"

typedef vector<int> vl;
typedef vector< vl > vvl;
typedef pair< int, int> pll;
typedef map< int, int> mll;


#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif





void c_p_c()
{
#ifndef ONLINE_JUDGE
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
}
void parray(int a[], int n) {
	for (int i = 0; i < n; i++) {
		cout << a[i] << " ";
	}
	cout << endl;
}

int main() {
	ll i, n, m, k, c = 0, sum = 0;
	c_p_c();
	ll no;

	cin >> n;
	int pre;
	int a[n];
	fo(i, n) cin >> a[i];
	ll sum1=0,sum2=0,ans=0,ans2=0;;




	for (int i = 0; i < n; ++i)
	{
		sum1+=a[i];
		if(i%2==0 and sum1<=0){
			ans+=-sum1+1;
			sum1=1;
		}else if(i%2==1 and sum1>=0){
			ans+=sum1+1;
			sum1=-1;
		}
	}


	for (int i = 0; i < n; ++i)
	{
		/* code */
		sum2+=a[i];
		if(i%2==0 and sum2>=0){
			ans2+=sum2+1;
			sum2=-1;
		}else if(i%2==1 and sum2<=0){
			ans2+=-sum2+1;
			sum2=1;
		}
	}




	cout<<min(ans2,ans)<<endl;
	return 0;
}



Measured memory_bytes: 3944
#include <iostream>
#include <stdio.h>
#include <fstream>
#include <algorithm>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <vector>
#include <limits.h>
#include <math.h>

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

using namespace std;

typedef long long ll;
typedef pair<int,int> Pii;
typedef vector<int> vint;

const ll INF = LONG_LONG_MAX;

template<typename T>
inline int compress(vector<T> &x) {
    sort(x.begin(), x.end());
    x.erase(unique(x.begin(), x.end()), x.end());
    return (int) x.size();
}

template<typename T>
inline int idx(vector<T> &x, T a) {
    return lower_bound(x.begin(), x.end(), a) - x.begin();
}


int main() {
    // insert code here...    return 0;
    //////
    // input from txt
    /*
     std::ifstream in("input.txt");
     std::cin.rdbuf(in.rdbuf());
     std::ofstream out("output.txt");
     std::cout.rdbuf(out.rdbuf());
     ////
     */
    int N,K;
    cin >> N >>K;
    vector<ll> x(N),y(N);
    repeat(i, N){
        cin >> x[i] >> y[i];
    }
    vector<ll> xs(x),ys(y);
    xs.push_back(-INF);
    xs.push_back(INF);
    ys.push_back(-INF);
    ys.push_back(INF);
    /*
    sort(xs.begin(),xs.end());
    sort(ys.begin(),ys.end());
    xs.erase(unique(xs.begin(), xs.end()),xs.end());
    ys.erase(unique(ys.begin(), ys.end()),ys.end());
    int w = (int)xs.size(),h = (int)ys.size();
     */
    int w = compress(xs);
    int h = compress(ys);
    /*
    vint cx(N),cy(N);
    repeat(i, N){
        cx[i] = (int)(lower_bound(xs.begin(), xs.end(), x[i]) - xs.begin());
        cy[i] = (int)(lower_bound(ys.begin(), ys.end(), y[i]) - ys.begin());
        cx[i]++;
        cy[i]++;
    }
     */
    vector<vint> fld(w,vint(h,0));
    repeat(i, N){
        fld[idx(xs,x[i])][idx(ys,y[i])] = 1;
    }
    repeat(i, w-1){
        repeat(j, h-1){
            fld[i+1][j+1] += fld[i+1][j];
        }
    }
    repeat(j, h-1){
        repeat(i,w-1){
            fld[i+1][j+1] += fld[i][j+1];
        }
    }
    ll ans = INF;
    repeat(rx, w-2){
        repeat(lx, rx){
            repeat(by, h-2){
                repeat(ty, by){
                    int num = fld[rx+1][by+1]-fld[rx+1][ty]-fld[lx][by+1]+fld[lx][ty];
                    //cout << num << endl;
                    if(num < K) continue;
                    ll area = (xs[rx+1]-xs[lx+1])*(ys[by+1]-ys[ty+1]);
                    ans = min(ans,area);
                }
            }
        }
    }
    cout << ans <<endl;
    return 0;
}



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

int main(){
    int n,a=0,b=0;
    cin >> n;
    vector<int> vec(n);

    for(int i = 0; i < n; i++){
        cin >> vec.at(i);
    }

    sort(vec.begin(), vec.end());
    reverse(vec.begin(), vec.end());

    bool c = true;

    for(int i = 0; i < n; i++){
        if(c) {
            a += vec.at(i);
            c = false;
        }else{
            b += vec.at(i);
            c = true;
        }
    }
    cout << a - b;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
#include<string.h>
#include<string>
#include<stack>
#include<map>
#include<set>
#include<queue>
#include<iostream>
#include<algorithm>
#include<unordered_map>
#include<unordered_set>
#define PI acos(-1)
#define pb push_back
#define all(x) x.begin(),x.end()
#define INF 0x3f3f3f3f
#define dd(x) cout<<#x<<" = "<<x<<","
#define de(x) cout<<#x<<" = "<<x<<"\n"
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int N=2e5+5;
char c[N];
int main()
{
	scanf("%s",c+1);
	int len=strlen(c+1);
	for(int i=1;i<=len;i++){
		if(c[i]=='?'){
			printf("D");
		}
		else{
			printf("%c",c[i]);
		}
	}
}


Measured memory_bytes: 3844
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
 
int main(void){
  int i, j, N;
  j = 0;
  scanf("%d", &N);
  int t[N], x[N], y[N];
  t[0]=x[0]=y[0]=0;
  for(i = 1; i <= N; i++){
    scanf("%d", &t[i]);
    scanf("%d", &x[i]);
    scanf("%d", &y[i]);
  }
  for(i = 1; i <= N; i++){
    int T = abs(t[i] - t[i - 1]);
    int xt = abs(x[i] - x[i - 1]);
    int yt = abs(y[i] - y[i - 1]);
    if((T >= (xt + yt)) && ((T - xt - yt) % 2 == 0))
      j++;
  }
  if(N == j)
    printf("Yes");
  else
    printf("No");
}


Measured memory_bytes: 1280
#include "bits/stdc++.h"
using namespace std;
const int MAX = 700000;
const int MOD = 1000000007;

long long  fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 二項係数計算
long long COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
/*第二引数で第一引数を割ったときの切り上げの計算*/
long long int maxtime(long long int x, long long int y){
	return(x + y - 1) / y;

}
/*最大公約数*/
long long int lcm(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;

	if (number2 > number1) {
		m = number2;
		n = number1;
	}
	long long int s = -1;
	while (s != 0) {
		s = m % n;
		m = n;
		n = s;
	}
	return m;
}
/*最大公倍数*/
long long int gcd(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;
	return m / lcm(m, n) * n;
}
/*逆元計算*/
long long int  modinv(long long a, long long m) {
	long long int b = m, u = 1, v = 0;
	while (b) {
		long long int t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
// index が条件を満たすかどうか
vector<long long int >meguru;
bool isOK(int index, int key) {
	if (meguru[index] >= key) return true;
	else return false;
}
// 汎用的な二分探索のテンプレ
int binary_search(int key) {
	int left = -1; //「index = 0」が条件を満たすこともあるので、初期値は -1
	int right = (int)meguru.size(); // 「index = a.size()-1」が条件を満たさないこともあるので、初期値は a.size()
	/* どんな二分探索でもここの書き方を変えずにできる！ */
	while (right - left > 1) {
		int mid = left + (right - left) / 2;

		if (isOK(mid, key)) right = mid;
		else left = mid;
	}
	/* left は条件を満たさない最大の値、right は条件を満たす最小の値になっている */
	return right;
}
int main() {
	long long int h;
	long long int n;
	cin >> h >> n;
	vector<long long int>a;
	vector<long long int >b;
	for (int i = 0; i < n; i++) {
		long double k, c;
		cin >> k >> c;
		a.push_back(k);
		b.push_back(c);
	}
	long long int dp[10020] = {};
	for (int i = 0; i < 10020; i++) {
		dp[i] = 1000000000000;
	}
	dp[0] = 0;
	for (int i = 0; i < a.size(); i++) {
		for (int j = 0; j < 10010; j++) {
			long long int k = j - a[i];
			if (k >= 0) {
				dp[j] = min(dp[k] + b[i], dp[j]);
			}
		}
	}
	long long int ans = 10000000000000;
	for (int i = h; i < 10020; i++) {
		ans = min(ans, dp[i]);
	}
	cout << ans;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))


int main() {
	int sx; int sy; int tx; int ty;
	cin >>sx>>sy>>tx>>ty;
		int x = tx - sx, y = ty - sy;
		string ans;
		rep(i, x)
			ans += 'R';
		rep(i, y)
			ans += 'U';
		rep(i, x)
			ans += 'L';
		rep(i, y)
			ans += 'D';
		ans += 'L';
		rep(i, y + 1)
			ans += 'U';
		rep(i, x + 1)
			ans += 'R';
		ans += 'D';
		ans += 'R';
		rep(i, y + 1)
			ans += 'D';
		rep(i, x + 1)
			ans += 'L';
		ans += 'U';
		cout <<ans;
	
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
long long LUNLUN(long long K){
  queue<long long> Q;
  for(int i=0;i<9;i++)
    Q.push(i+1);
  long long count=0;
  while(count<K){
  long long x;
  x=Q.front();
  if((x%10)!=0)
    Q.push(10*x+x%10-1);
  Q.push(10*x+x%10);
  if((x%10)!=9)
    Q.push(10*x+x%10+1);
  count++;
  if(count==K)
    cout << Q.front() << endl;
  Q.pop();
}
}

int main(){
  long long K;
  cin >> K;
  LUNLUN (K);
}

Measured memory_bytes: 1792
import java.util.Scanner;

public class Main {

	static int N;
	
	public static void main(String[] args) {
		Scanner cin=new Scanner(System.in);
		N=cin.nextInt();
		while(N--!=0){
			String s = cin.next();
			if(s.length()==1){
				System.out.println(0);
				continue;
			}
			int ans=0;
			while(true){
				ans++;
				int max=-1;
				for(int i=1;i<s.length();i++){
					int a=Integer.parseInt(s.substring(0,i));
					int b=Integer.parseInt(s.substring(i));
//					System.out.println(a+" "+b);
					max=Math.max(a*b,max);
				}
				if(max<10){
					System.out.println(ans);
					break;
				}
				else{
					s=max+"";
				}
			}

			
		}
	}

}

Measured memory_bytes: 23040
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <deque>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <iomanip>
#include <bitset>
#include <set>
#include <map>
#include <stdio.h>
#include <numeric>

#define rep(i,n) for (long long int i = 0; i < (n); i++)
#define rep1(i,n) for (long long int i = 1; i < (n); i++)
#define FOR(i,a,b) for (int i=(a); i < (b); i++)
#define INF 100000000000
#define MOD 1000000007 //10^9+7
using namespace std;
using ll = long long;
using P = pair<int, int>;

// 負の数にも対応した % 演算
long long mod(long long val, long long m) {
    long long res = val % m;
    if (res < 0) res += m;
    return res;
}

long long gcd(ll a, ll b) 
{
    if (a % b == 0) {
        return b;
    } else {
        return gcd(b, a % b);
    }
}

long long lcm(ll a, ll b)
{
    return a / gcd(a, b) * b ;
}

int main()
{
    int n, d;
    cin >> n >> d;
    vector<vector<int>> v(n, vector<int>(d));
    rep(i,n) {
        rep(j,d) {
            cin >> v[i][j];
        }
    }

    int ans = 0;
    rep(i,n) {
        for(int j = i + 1; j < n; j++) {
            int root = 0;
            rep(k,d) {
                root += pow(v[i][k]-v[j][k],2);
            }
            if (sqrt(root) == floor(sqrt(root)))
                ans++;
        }
    }

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


Measured memory_bytes: 256
#ifdef _DEBUG
#include "MyLib.h"
#else
#define main_E main
#include "bits/stdc++.h" 
#include <regex>
#define _USE_MATH_DEFINES
#include <math.h>
#define FOR(i,s,e) for (int i = int(s); i < int(e); ++i)
#define REP(i,e) FOR(i,0,e)
#define INF (INT_MAX/2)
#define EPS (1.0e-8)
#define LINF (LONG_MAX/2)
const int MGN = 8;
const int ARY_SZ_MAX = 10000000;
using namespace std;
using ll = long long; using ull = unsigned long long;
using vi = vector<int>; using vvi = vector<vi>; using vvvi = vector<vvi>;
using vb = vector<bool>; using vvb = vector<vb>; using vvvb = vector<vvb>;
using vl = vector<ll>; using vvl = vector<vl>;
using vd = vector<double>; using vs = vector<string>;
using pii = pair<int, int>; using pll = pair<ll, ll>;
// functions
struct DSU {
    int N;
    vi dt;
    DSU(int n) : N(n), dt(n, -1) {}

    int root(int v){
        if (dt[v] < 0) return v;
        return dt[v] = root(dt[v]);
    }

    bool unite(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (size(x) < size(y)) swap(x,y);
        dt[x] += dt[y];
        dt[y] = x;
        return true;
    }

    int size(int v) {return -dt[root(v)];}
};
#endif


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

    int N, M;  cin >> N >> M;
    vi X(M), Y(M), Z(M);
    REP(i, M) {
        cin >> X[i] >> Y[i] >> Z[i];
        X[i]--; Y[i]--;
    }

    DSU un(N + MGN);
    REP(i, M) {
        un.unite(X[i], Y[i]);
    }

    set<int> st;
    REP(i,N) {
        st.insert(un.root(i));
    }

    int ans = st.size();

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 6528
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Scanner;
import java.util.stream.Collectors;

public class Main {
	private static Map<Integer, Integer> vMap_odd = new HashMap<Integer, Integer>();
	private static Map<Integer, Integer> vMap_evn = new HashMap<Integer, Integer>();

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n = Integer.parseInt(scan.next());
		int[] v_evn = new int[n / 2];
		int[] v_odd = new int[n / 2];
		for (int i = 0; i < n / 2; i++) {
			v_odd[i] = Integer.parseInt(scan.next());
			v_evn[i] = Integer.parseInt(scan.next());
		}
		createModeMap(v_odd, "odd");
		createModeMap(v_evn, "evn");
		int mode_odd = (int) vMap_odd.keySet().toArray()[0];
		int mode_evn = (int) vMap_evn.keySet().toArray()[0];
		int freq_odd = (int) vMap_odd.values().toArray()[0];
		int freq_evn = (int) vMap_evn.values().toArray()[0];
		//最頻値が異なる場合
		if (mode_odd != mode_evn) {
			System.out.println(n - (freq_odd + freq_evn));
			return;
		}
		//すべて同じ値の場合
		if (freq_odd == freq_evn && freq_odd == n / 2) {
			System.out.println(n / 2);
			return;
		}
		//最頻値が同じで、出現回数が異なる場合
		int count_odd; // 奇数列の2番目の最頻値を用いた場合
		int count_evn; // 偶数列の2番目の最頻値を用いた場合
		int freq_odd_second;
		int freq_evn_second;
		if (freq_odd != n / 2) {
			freq_odd_second = (int) vMap_odd.values().toArray()[1];
			count_odd = n - (freq_odd_second + freq_evn);
		} else { //奇数列の最頻値が１種類であった場合
			count_odd = n - (int) vMap_evn.values().toArray()[1];
		}
		if (freq_evn != n / 2) {
			freq_evn_second = (int) vMap_evn.values().toArray()[1];
			count_evn = n - (freq_odd + freq_evn_second);
		} else { //偶数列の最頻値が１種類であった場合
			count_evn = n - (int) vMap_odd.values().toArray()[1];
		}
		System.out.println(Math.min(count_odd, count_evn));
	}

	private static void createModeMap(int[] vArray, String str) {
		Map<Integer, Integer> vMap;
		if (str.equals("odd")) {
			vMap = vMap_odd;
		} else {
			vMap = vMap_evn;
		}
		Integer count = null;
		for (Integer v : vArray) {
			count = vMap.get(v);
			if (count == null) {
				vMap.put(v, new Integer(1));
			} else {
				vMap.put(v, ++count);
			}
		}
		if (str.equals("odd")) {
			vMap_odd = vMap.entrySet().stream()
					.sorted(Entry.<Integer, Integer> comparingByValue().reversed())
					.collect(Collectors.toMap(Entry::getKey, Entry::getValue, (e1, e2) -> e1, LinkedHashMap::new));
		} else {
			vMap_evn = vMap.entrySet().stream()
					.sorted(Entry.<Integer, Integer> comparingByValue().reversed())
					.collect(Collectors.toMap(Entry::getKey, Entry::getValue, (e1, e2) -> e1, LinkedHashMap::new));
		}
	}
}


Measured memory_bytes: 53832
from bisect import bisect_left, bisect_right

INF = float("inf")
n, *s = map(int, input().split())
toidx = {"AB": (0, 1), "BC": (1, 2), "AC": (0, 2)}
toalp = lambda x: chr(ord("A") + x)
m = sum(s)
q = [toidx[input()] for _ in range(n)]

def solve():
    res = []
    if m == 0 or (not s[q[0][0]] and not s[q[0][1]]):
        print("No")
        return
    elif m == 1:
        for i, j in q:
            if not s[i] and not s[j]:
                print("No")
                return
            elif s[i]:
                s[j] += 1; s[i] -= 1
                res.append(toalp(j))
            elif s[j]:
                s[i] += 1; s[j] -= 1
                res.append(toalp(i))
    elif m == 2:
        d = {(0, 1): [], (0, 2): [], (1, 2): []}
        for i in range(n): d[q[i]].append(i)
        for key in d.keys(): d[key].append(INF)
        for idx, (i, j) in enumerate(q):
            if s[i] and s[j]:
                k = [x for x in range(3) if i != x and j != x][0]
                key1 = tuple(sorted([i, k]))
                key2 = tuple(sorted([j, k]))
                nik = d[key1][bisect_left(d[key1], idx)]
                njk = d[key2][bisect_left(d[key2], idx)]
                if nik <= njk:
                    s[i] += 1; s[j] -= 1
                    res.append(toalp(i))
                else: 
                    s[j] += 1; s[i] -= 1
                    res.append(toalp(j))
            elif s[i]:
                s[j] += 1; s[i] -= 1
                res.append(toalp(j))
            elif s[j]:
                s[i] += 1; s[j] -= 1
                res.append(toalp(i))
    else:
        for i, j in q:
            if s[i] >= s[j]:
                s[j] += 1; s[i] -= 1
                res.append(toalp(j))
            else:
                s[i] += 1; s[j] -= 1
                res.append(toalp(i))
    print("Yes")
    print(*res, sep="\n")

solve()


Measured memory_bytes: 16524
#include<iostream>
#include<bits/stdc++.h>
#include<stdio.h>
using namespace std;
int main(){
	unsigned int x,y,n;
	scanf("%d",&n);
	x=n*800;
	if(n>=15)
	printf("%d",x-(n/15*200));
	else
	printf("%d",x);
	return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
import sys


def solve(N: int, S: str):
    ans = 0
    t  = 0
    for i in S:
        if i == "I":
            t += 1
        if i == "D":
            t -= 1
        if t > ans:
            ans = t
    print(ans)
    return


# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    S = next(tokens)  # type: str
    solve(N, S)

if __name__ == '__main__':
    main()


Measured memory_bytes: 61900
use proconio::{fastout, input};

#[fastout]
fn main() {
    input! {
        n: usize,
        s: proconio::marker::Chars
    }

    let mut a = vec![0; n+1];
    for (i, c) in s.iter().copied().enumerate() {
        a[i+1] = match c {
            'W' => a[i] + 1,
            'R' => a[i],
            _ => panic!(),
        }
    }

    println!(
        "{}",
        (0..=n)
            .map(|i| a[i].max(n - i - (a[n] - a[i])))
            .min()
            .unwrap()
    );
}


Measured memory_bytes: 4692
#include <iostream>
#include <vector>
#include <algorithm>
#include <deque>
#include <set>
#include <numeric>
#include <map>
#include <iomanip>
#include <climits>
#include <string>

using namespace std;

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

	string s, t;
	cin >> s >> t;
	set<char> a, b;
	for (auto c : s)
		a.insert(c);
	for (auto c : t)
		b.insert(c);

	for (auto x : b)
	{
		if (a.find(x) == a.end())
		{
			cout << -1;
			return 0;
		}
	}

	long long ans = 0;
	map<char, vector<int> > pos;
	for (int i = 0; i < s.size(); i++)
		pos[s[i]].push_back(i);
	int lst = -1;
	for (int i = 0; i < t.size(); i++)
	{
		auto ut = upper_bound(pos[t[i]].begin(), pos[t[i]].end(), lst);
		if (ut == pos[t[i]].end())
		{
			ans += (int)s.size() - lst - 1;
			lst = pos[t[i]].front();
			ans += lst + 1;
		}
		else
		{
			ans += *ut - lst;
			lst = *ut;
		}
	}
	cout << ans;
}

Measured memory_bytes: 1228
package main 
import (
    "bufio"
    "fmt"
    "os")
    
    var r =bufio.NewReader(os.Stdin)
    
    func main() {
        var a int
        var b int
        
        fmt.Fscan(r, &a, &b)
        
        if( a > b ) {
            fmt.Println("a > b")
        } else if (a < b ) {
            fmt.Println("a < b")
        } else {
            fmt.Println("a == b")
        }
    }


Measured memory_bytes: 1172
import java.util.Scanner;

class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int N = Integer.parseInt(scanner.next());
        int[] h = new int[N];
        for (int i=0; i<N; i++) {
            h[i] = Integer.parseInt(scanner.next());
        }
        scanner.close();
        int[] dp = new int[N];
        dp[0] = 0;
        dp[1] = Math.abs(h[1]-h[0]);
        for (int i=2; i<N; i++) {
            dp[i] = Math.min(dp[i-2] + Math.abs(h[i]-h[i-2]), dp[i-1] + Math.abs(h[i]-h[i-1]));
        }
        System.out.println(dp[N-1]);
    } 
}

Measured memory_bytes: 52348
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <string.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define forn(i,a,b) for(int i=a;i<=b;i++)
#define INF 2147483647
#define LLINF 9223372036854775807
using namespace std;
int n,x;
int a[110];
map<int,bool> mp;
int main(){
	cin>>x>>n;
	for(int i=0;i<n;i++){
		cin>>a[i];
		mp[a[i]]=1;
	}
	for(int i=0;;i++){
		if(!mp[x-i]){
			cout<<x-i<<endl;
			return 0;
		}
		if(!mp[x+i]){
			cout<<x+i<<endl;
			return 0;
		}
	}
	return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
int main() {
    int N;
    cin >> N;

    if (N == 1) {
        cout << "Hello"
             << " "
             << "World" << endl;
    } else if (N == 2) {
        int A, B;
        cin >> A >> B;

        cout << A + B << endl;
    }
}

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

int main() {
    int n, max, k=0;
    int arr[110000];
    cin >> n;
    for(int i=0; i<n; i++) cin >> arr[i];
    sort(arr, arr+n);
    max = arr[n-1];
    int half_max = max / 2;
    for(int i=1; i<n-1; i++){
        if(arr[i] > half_max) {
            if(abs(arr[i]-half_max) <= abs(arr[i-1]-half_max)) k = arr[i];
            else k = arr[i-1];
            break;
        }
    }
    cout << max << " " << k << endl;
}

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

#define EPS 1e-6
#define MOD 1000000007
#define inf 0x3f3f3f3f
#define llinf 0x3f3f3f3f3f3f3f3f

#define fi first
#define se second
#define pb push_back
#define ende '\n'

#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define mset(x, y) memset(&x, (y), sizeof(x))

using namespace std; 

using ll = long long;
using ii = pair<int,int>;

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

  int n; cin >> n;
  vector<int> v(n + 1);
  for (int i = 1; i <= n; ++i)
    cin >> v[i];

  vector<int> ans(n + 1);
  for (int i = n / 2 + 1; i <= n; ++i)
    ans[i] = v[i];

  for (int i = n / 2; i >= 1; --i) {
    for (int j = i; j <= n; j += i)
      ans[i] += ans[j];
    if (ans[i] % 2) ans[i] = !v[i];
    else ans[i] = v[i];
  }

  vector<int> res;
  for (int i = 1; i <= n; ++i)
    if (ans[i]) res.pb(i);
  cout << res.size() << ende;
  if (res.size()) {
    for (auto i : res)
      cout << i << " ";
    cout << ende;
  }
  return 0;
}


Measured memory_bytes: 3192
n, q = map(int, input().split())
s = input()
count_ac = [0]
for i in range(1, n):
    count_ac.append(count_ac[i-1])
    if s[i-1:i+1] == "AC":
        count_ac[i] += 1
for query in range(q):
    l, r = map(int, input().split())
    print(count_ac[r-1]-count_ac[l-1])


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

const int MAX_N = 200000;
int a[MAX_N], b[MAX_N];

int n;
bool good(int i) {
    return (b[i] > b[(i + 1) % n] + b[(i + n - 1) % n] && b[i] > a[i]);
}

int main() {
    cin >> n;
    for (int i = 0; i < n; i++)
        cin >> a[i];
    for (int i = 0; i < n; i++)
        cin >> b[i];

    vector<int> V;
    for (int i = 0; i < n; i++)
        if (good(i))
            V.push_back(i);
    long long int ans = 0;
    for (int p = 0; p < V.size(); p++) {
        int i = V[p];
        int t = b[(i + 1) % n] + b[(i + n - 1) % n];
        int k = (b[i] - a[i]) / t;
        ans += k;
        b[i] -= t * k;
        if (good((i + 1) % n))
            V.push_back((i + 1) % n);
        if (good((i + n - 1) % n))
            V.push_back((i + n - 1) % n);
    }
    for (int i = 0; i < n; i++)
        if (a[i] != b[i]) {
            ans = -1;
            break;
        }
    cout << ans << "\n";
}


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

using namespace std;

#define int long long

int N, M;

signed main()
{
  cin >> N >> M;
  int rest = (N - M) * 100;

  int cur = 1;
  for(int i = 0; i < M; i++) cur *= 2;
  cout << (M * 1900 + rest) * cur << endl;
}

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

using namespace std;

int t[100];
int v[100];
int endV[100];
int startV[100];
int tStart[100];
int tEnd[100];

vector<pair<double, double>> solutions;

double solve(double a0, double b0, double a1, double b1)
{
    int da = a0 - a1;
    int db = b0 - b1;
    return -(double)db / da;
}

void divide(double st, double et, double a0, double b0, double a1, double b1)
{
    if (a0 == a1)
    {
        throw runtime_error("a0 and a1 must be different.");
    }
    if (a0 < a1)
    {
        divide(st, et, a1, b1, a0, b0);
        return;
    }

    double t = et - st;
    double solution = solve(a0, b0, a1, b1);
    if (solution <= 0)
    {
        solutions.push_back(make_pair(et, b1 + a1 * t));
    }
    else if (solution >= t)
    {
        solutions.push_back(make_pair(et, b0 + a0 * t));
    }
    else
    {
        solutions.push_back(make_pair(st + solution, b0 + a0 * solution));
        solutions.push_back(make_pair(et, b1 + a1 * t));
    }
}

int main()
{
    int N;

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

    for (int i = N - 1; i >= 0; i--)
    {
        if (i == N - 1)
        {
            endV[i] = 0;
        }
        endV[i] = min(v[i + 1], endV[i + 1] + t[i + 1]);
    }

    for (int i = 0; i < N; i++)
    {
        if (i == 0)
        {
            startV[i] = 0;
        }
        startV[i] = min(v[i - 1], startV[i - 1] + t[i - 1]);
    }

    for (int i = 0; i < N; i++)
    {
        if (i == 0)
        {
            tStart[i] = 0;
            tEnd[i] = t[i];
            continue;
        }
        tStart[i] = tEnd[i - 1];
        tEnd[i] = tStart[i] + t[i];
    }

    solutions.push_back(make_pair(0, 0));

    for (int i = 0; i < N; i++)
    {
        double solution = solve(0, v[i], 1, startV[i]);

        if (solution <= 0)
        {
            divide(tStart[i], tEnd[i], 0, v[i], -1, endV[i] + t[i]);
        }
        else if (solution >= t[i])
        {
            divide(tStart[i], tEnd[i], 1, startV[i], -1, endV[i] + t[i]);
        }
        else
        {
            divide(tStart[i], tStart[i] + solution, 1, startV[i], -1, endV[i] + t[i]);
            divide(tStart[i] + solution, tEnd[i], 0, v[i], -1, endV[i] + t[i] - solution);
        }
    }

    double result = 0;
    for (int i = 0; i < solutions.size() - 1; i++)
    {
        double h = solutions[i + 1].second + solutions[i].second;
        double w = solutions[i + 1].first - solutions[i].first;
        double area = h * w / 2;
        result += area;
    }

    cout << fixed << result << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
using namespace std;

long long n, k, cnt = 0;
vector<pair<long long, long long>> s;
long long num[100005] = {0};

long long solve();

int main() {
  cin >> n >> k;
  for(long long i = 0; i < n; ++i) {
    long long t, d;
    cin >> t >> d;
    --t;
    s.push_back(make_pair(d, t));
  }
  sort(s.begin(), s.end(),
       greater<pair<long long, long long>>());
  cout << solve() << endl;
  return 0;
}

long long solve() {
  long long now = 0, ans = 0, r = k - 1;
  for(long long i = 0; i < k; ++i) {
    now += s[i].fi;
    if(++num[s[i].se] == 1) ++cnt;
  }
  ans = now + cnt * cnt;
  for(long long i = k; i < n; ++i)
    if(num[s[i].se] == 0) {
      while(r >= 0 && num[s[r].se] == 1) --r;
      if(r < 0) break;
      now += s[i].fi - s[r].fi;
      ++cnt;
      ++num[s[i].se];
      --num[s[r].se];
      --r;
      ans = max(ans, now + cnt * cnt);
    }
  return ans;
}

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

string b = "bdpq";
string c = "dbqp";

int main() {
  string s, t;
  cin >> s;
  for (int i = 0; i < s.size(); i++)
    for (int j = 0; j < 4; j++)
      if (s[i] == b[j])
        t.push_back(c[j]);
  reverse(t.begin(), t.end());
  if (s == t)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
//clock_t t=clock();
namespace my_std{
	using namespace std;
	#define pii pair<int,int>
	#define fir first
	#define sec second
	#define MP make_pair
	#define rep(i,x,y) for (int i=(x);i<=(y);i++)
	#define drep(i,x,y) for (int i=(x);i>=(y);i--)
	#define go(x) for (int i=head[x];i;i=edge[i].nxt)
	#define templ template<typename T>
	#define sz 202200
	#define mod 1000000007ll
	typedef long long ll;
	typedef double db;
//	mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
//	templ inline T rnd(T l,T r) {return uniform_int_distribution<T>(l,r)(rng);}
	templ inline bool chkmax(T &x,T y){return x<y?x=y,1:0;}
	templ inline bool chkmin(T &x,T y){return x>y?x=y,1:0;}
	templ inline void read(T& t)
	{
		t=0;char f=0,ch=getchar();double d=0.1;
		while(ch>'9'||ch<'0') f|=(ch=='-'),ch=getchar();
		while(ch<='9'&&ch>='0') t=t*10+ch-48,ch=getchar();
		if(ch=='.'){ch=getchar();while(ch<='9'&&ch>='0') t+=d*(ch^48),d*=0.1,ch=getchar();}
		t=(f?-t:t);
	}
	template<typename T,typename... Args>inline void read(T& t,Args&... args){read(t); read(args...);}
	char __sr[1<<21],__z[20];int __C=-1,__zz=0;
	inline void Ot(){fwrite(__sr,1,__C+1,stdout),__C=-1;}
	inline void print(register int x)
	{
		if(__C>1<<20)Ot();if(x<0)__sr[++__C]='-',x=-x;
		while(__z[++__zz]=x%10+48,x/=10);
		while(__sr[++__C]=__z[__zz],--__zz);__sr[++__C]='\n';
	}
//	void file()
//	{
//		#ifndef ONLINE_JUDGE
//		freopen("a.in","r",stdin);
//		#endif
//	}
//	inline void chktime()
//	{
//		#ifndef ONLINE_JUDGE
//		cout<<(clock()-t)/1000.0<<'\n';
//		#endif
//	}
//	#ifdef mod
//	ll ksm(ll x,int y){ll ret=1;for (;y;y>>=1,x=x*x%mod) if (y&1) ret=ret*x%mod;return ret;}
//	ll inv(ll x){return ksm(x,mod-2);}
//	#else
//	ll ksm(ll x,int y){ll ret=1;for (;y;y>>=1,x=x*x) if (y&1) ret=ret*x;return ret;}
//	#endif
//	inline ll mul(ll a,ll b){ll d=(ll)(a*(double)b/mod+0.5);ll ret=a*b-d*mod;if (ret<0) ret+=mod;return ret;}
}
using namespace my_std;

int n;
int lst[sz];
ll dp[sz];

int main()
{
//	file();
	read(n);
	dp[0]=1;
	rep(i,1,n)
	{
		int x;read(x);
		int y=lst[x];
		dp[i]=dp[i-1];
		if (y&&y!=i-1) (dp[i]+=dp[y])%=mod;
		lst[x]=i;
	}
	cout<<dp[n];
	return 0;
}

Measured memory_bytes: 4352
#include <iostream>
#include <iomanip>
#include <fstream>
#include <vector>
#include <algorithm>
#include <math.h>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>

#define _GLIBCXX_DEBUG
#define rep(i, n) for (int64_t i = 0; i < (int64_t)(n); i++)
using namespace std;
using vi = vector<int64_t>;
using vvi = vector<vi>;

int main(int argc, const char * argv[]) {
    // fasten cin
    cin.tie(0);
    ios::sync_with_stdio(false);
    // implement
    vi x(3);
    rep(i,3) cin >> x.at(i);
    sort(x.begin(), x.end());
    cout << x.at(0) + x.at(1) + x.at(2) * 10 << endl;
}


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

struct Card{
    char suit;
    int value;
};

int main(void){
    int n;
    cin>>n;
    vector<Card> a(n),a2(n);
    for (int i = 0; i < n; ++i) {
        cin>>a[i].suit>>a[i].value;
        a2[i]=a[i];
    }
    for (int i = 0; i < n; ++i) {
        for (int j = n-1; j > i; --j) {
            if(a[j].value<a[j-1].value){
                Card t=a[j];
                a[j]=a[j-1];
                a[j-1]=t;
            }
        }
    }
    for (int i = 0; i < n-1; ++i) {
        cout<<a[i].suit<<a[i].value<<" ";
    }
    cout<<a[n-1].suit<<a[n-1].value<<endl;

    cout<<"Stable"<<endl;

    for (int i = 0; i < n; ++i) {
        int minj=i;
        for (int j = i+1; j < n; ++j) {
            if(a2[minj].value>a2[j].value)minj=j;
        }
        if(i!=minj){
            Card t=a2[i];
            a2[i]=a2[minj];
            a2[minj]=t;
        }

    }
    for (int i = 0; i < n-1; ++i) {
        cout<<a2[i].suit<<a2[i].value<<" ";
    }
    cout<<a2[n-1].suit<<a2[n-1].value<<endl;

    bool isisstable=true;
    for (int i = 0; i < n; ++i) {
        if(a[i].suit!=a2[i].suit){isisstable=false;break;}
    }
    if(isisstable)cout<<"Stable"<<endl;
    else cout<<"Not stable"<<endl;
    return 0;
}


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

string HOSHINOtoHOSHINA(string str) {
  string str2(str);
  int idx = 0;
  int len = 7; // "Hoshina" has 7 character
  while( (idx = str2.find("Hoshino", idx)) >= 0) {
	str2.replace(idx, len, "Hoshina");
  }
  return str2;
}

int main() {
  int n;
  string buf;

  cin >> n;
  cin.ignore();
  
  for(int i = 0; i < n; ++i) {
	getline(cin, buf);
	cout << HOSHINOtoHOSHINA(buf) << endl;
  }

  return 0;
}

Measured memory_bytes: 3012