akhauriyash/Code-Regression huggingface dataset:
/// b.cpp
# include <stdio.h>
# include <bits/stdc++.h>
using namespace std;
const pair < int , int > DD[] = {{1,0},{1,1},{0,1},{-1,1},{-1,0},{-1,-1},{0,-1},{1,-1}};
# define fi cin
# define fo cout
# define x first
# define y second
# define ll long long
# define IOS ios_base :: sync_with_stdio(0);cin.tie(0)
# define p(v) cerr << #v << " = " << v << '\n'
# define p2(v) cerr << #v << " = " << (complex < decltype(v.x) > (v.x,v.y)) << '\n'
# define vi vector < int >
# define vl vector < ll >
# define pll pair < ll , ll >
# define pii pair < int , int >
# define mp make_pair
# define db long double
# define fail puts("-1")
# define yes puts("YES")
# define no puts("NO")
# define PP puts("Possible")
# define II puts("Impossible")
# define vii vector < pii >
# define vll vector < pll >
# define pb push_back
# define pdd pair < db , db >
# define all(s) s.begin(),s.end()
template < class T > T smin(T &a,T b) {if (a > b) a = b;return a;}
template < class T > T smax(T &a,T b) {if (a < b) a = b;return a;}
int main(void)
{
    #ifdef CF
    freopen("input","r",stdin);
    #endif // CF
    srand(time(0));
    fo << fixed << setprecision(7);
    cerr << fixed << setprecision(7);
    static int D1[1 << 20];
    static int D2[1 << 20];
    static int F[1 << 20];
    static vi g[1 << 20];
    int n;
    fi>>n;
    for (int i = 1;i < n;++i)
    {
        int a,b;
        fi>>a>>b;
        g[a].pb(b);
        g[b].pb(a);
    }
    queue < int > Q;
    Q.push(1);
    D1[1] = 1;
    while (!Q.empty())
    {
        int node = Q.front();
        Q.pop();
        for (auto it : g[node])
            if (!D1[it])
                D1[it] = D1[node] + 1,Q.push(it);
    }
    Q.push(n);
    D2[n] = 1;
    while (!Q.empty())
    {
        int node = Q.front();
        Q.pop();
        for (auto it : g[node])
            if (!D2[it])
                D2[it] = D2[node] + 1,Q.push(it);
    }
    int A = 0,B = 0;
    for (int i = 1;i <= n;++i)
    {
        A += D1[i] <= D2[i];
        B += D2[i] < D1[i];
    }
    if (A <= B)
        puts("Snuke");
    else
        puts("Fennec");
    cerr << "Time elapsed :" << clock() * 1000.0 / CLOCKS_PER_SEC << " ms" << '\n';
    return 0;
}


Measured memory_bytes: 30592
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i <= (n); i++)
#define ALL(x) (x).begin(), (x).end()
#define SIZE(x) ((int)(x).size())
#define MAX(x) *max_element(ALL(x))
#define INF 1000000000000 //10^12
#define MOD 10000007      //10^9+7
#define root sqrt
using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vs = vector<string>;
using ll = long long;
// vector入力
template <typename T>
istream &operator>>(istream &is, vector<T> &vec)
{
  for (T &x : vec)
    is >> x;
  return is;
}
// vector出力
template <typename T>
ostream &operator<<(ostream &os, vector<T> &vec)
{
  // os << '{';
  for (int i = 0; i < vec.size(); i++)
  {
    os << vec[i] << (i + 1 == vec.size() ? "" : ' ');
  }
  // os << '}';
  return os;
}

int main()
{
  int r;
  cin >> r;
  double ans = 3.141592648777698869248;
  printf("%.10lf\n", r * 2 * ans);
}

Measured memory_bytes: 3752
#include "bits/stdc++.h"
#pragma GCC optimize("Ofast")

// Begin {{{
using namespace std;
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define rep(i, n) for (i64 i = 0, i##_limit = (n); i < i##_limit; ++i)
#define reps(i, b, e) for (i64 i = (b), i##_limit = (e); i <= i##_limit; ++i)
#define repr(i, b, e) for (i64 i = (b), i##_limit = (e); i >= i##_limit; --i)
#define var(Type, ...) Type __VA_ARGS__; input(__VA_ARGS__)
using i64 = int_fast64_t;
using pii = pair<i64, i64>;
template <class T> using MaxHeap = priority_queue<T>;
template <class T> using MinHeap = priority_queue<T, vector<T>, greater<>>;
template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }
inline i64 sigma(i64 n) { return n * (1 + n) >> 1; }
inline i64 updiv(i64 n, i64 d) { return (n + d - 1) / d; }
constexpr int INF = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;

#ifndef DEBUG
#define dump(...)
#endif

inline void input() {}
template <class Head, class... Tail>
inline void input(Head&& head, Tail&&... tail) {
    cin >> head;
    input(forward<Tail>(tail)...);
}

inline void outs() { cout << "\n"; }
template <class Head, class... Tail>
inline void outs(Head&& head, Tail&&... tail) {
    cout << head << (sizeof...(tail) ? " " : "");
    outs(forward<Tail>(tail)...);
}

template <class T>
inline void outs(vector<T> &vec) { for (auto &e : vec) cout << e << " \n"[&e == &vec.back()]; }

template <class T>
inline void outs(vector<vector<T>> &df) { for (auto &vec : df) outs(vec); }

inline void outl() { cout << "\n"; }
template <class Head, class... Tail>
inline void outl(Head&& head, Tail&&... tail) {
    cout << head << (sizeof...(tail) ? "\n" : "");
    outl(forward<Tail>(tail)...);
}

template <class T>
inline void outl(vector<T> &vec) { for (auto &e : vec) cout << e << "\n"; }

inline void outn() {}
template <class Head, class... Tail>
inline void outn(Head&& head, Tail&&... tail) {
    cout << head;
    outn(forward<Tail>(tail)...);
}

template <class T>
inline void outn(vector<T> &vec) { for (auto &e : vec) cout << e; }

template <class T>
inline vector<T> make_v(const T &initvalue, size_t sz) {
    return vector<T>(sz, initvalue);
}

template <class T, class... Args>
inline auto make_v(const T &initvalue, size_t sz, Args... args) {
    return vector<decltype(make_v<T>(initvalue, args...))>(sz, make_v<T>(initvalue, args...));
}
// }}} End

vector<bool> isPrime;

void sieve(size_t MAX) {
    isPrime.resize(MAX + 1, true);
    isPrime[0] = isPrime[1] = false;
    for (intmax_t i = 2; i * i <= MAX; ++i) {
        if (isPrime[i]) {
            for (intmax_t j = 2; i * j <= MAX; ++j) isPrime[i * j] = false;
        }
    }
}

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    var(intmax_t, x);

    sieve(int(1e6));

    while (true) {
        if (isPrime[x]) {
            return cout << x << "\n", 0;
        }
        x++;
    }

    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
              
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define ll long long
#define int ll
#define forn(i, a, b) for(int i = (a); i <= (b); ++i)
#define forev(i, b, a) for(int i = (b); i >= (a); --i)
#define VAR(v, i) __typeof( i) v=(i)
#define forit(i, c) for(VAR(i, (c).begin()); i != (c).end(); ++i)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define file(s) freopen(s".in","r",stdin); freopen(s".out","w",stdout);

using namespace std;

const int maxn = (int)1e5 + 100;
const int mod = (int)1e9 + 7;
const int P = (int) 1e6 + 7; 

#define inf mod

typedef long double ld;                          
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;   
typedef vector<ll> Vll;               
typedef vector<pair<int, int> > vpii;
typedef vector<pair<ll, ll> > vpll;                        


int n, W, w[maxn], v[maxn], dp[111][maxn];
main () {
  cin >> n >> W;
  forn(i, 0, n - 1) cin >> w[i] >> v[i];
  forn(i, 0, n)
    forn(j, 0, maxn - 1)
      dp[i][j] = inf;
  dp[0][0] = 0;
  forn(i, 0, n - 1){
    forn(j, 0, maxn - 1){
      if(dp[i][j] != -inf){          
        dp[i + 1][j] = min(dp[i + 1][j], dp[i][j]);
        dp[i + 1][j + v[i]] = min(dp[i + 1][j + v[i]], dp[i][j] + w[i]);
      }
    }
  }        
  forev(i, maxn - 1, 0)
    if(dp[n][i] <= W){
      cout << i;
      return 0;
    }
}


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

#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for (int i = x; i < n; i++)
#define OP(m) cout << m << endl
typedef long long ll;
typedef unsigned long long ull;

struct uf_tree
{
    vector<int> par, rank;
    uf_tree(int n) : par(n), rank(n)
    {
        for (int i = 0; i < n; i++)
        {
            par[i] = i;
            rank[i] = 0;
        }
    }

    int find(int x)
    {
        if (x == par[x])
            return x;
        return par[x] = find(par[x]);
    }

    void unite(int x, int y)
    {
        x = find(x);
        y = find(y);

        if (x == y)
            return;

        if (rank[x] < rank[y])
            swap(x, y);
        par[y] = x;
        rank[x] += rank[y];
    }

    bool same(int x, int y)
    {
        return find(x) == find(y);
    }
};

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

    uf_tree uf(n);

    rep(i, q)
    {
        int com, x, y;
        cin >> com >> x >> y;
        if (com == 0)
            uf.unite(x, y);
        else
        {
            if (uf.same(x, y))
                OP(1);
            else
                OP(0);
        }
    }
    return 0;
}


Measured memory_bytes: 3176
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
#define prtd(var, i) cout << fixed << setprecision(i) << var << endl;
#define ll long long
using namespace std;
#define INF 1e18LL

const ll MAX = 1000000000000000000; //1e18

int main(){
    string a, b;
    ll x = 0;
    cin >> a >> b;
    if(a.size() > b.size()) {
        cout << "GREATER" << endl;
        return 0;
    }
    else if(a.size() < b.size()) {
        cout << "LESS" << endl;
        return 0;
    }
    else{
        rep(i, a.size()){
            if(a[i] > b[i]){
                cout << "GREATER" << endl;
                return 0;
            }else if(a[i] < b[i]){
                cout << "LESS" << endl;
                return 0;
            }
        }
        cout << "EQUAL" << endl;
    }

}


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

using namespace std;
typedef long long ll;
#define int ll

#define REP(i,n) for(ll i=0;i<n;++i)
#define SORT(name) sort(name.begin(), name.end())
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))
#if 1
#  define DBG(fmt, ...) printf(fmt, ##__VA_ARGS__)
#else
#  define DBG(fmt, ...)
#endif

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const double DINF = std::numeric_limits<double>::infinity();
const int MOD = 1000000007;
#define MAX_N 110

bool check(int num) {
    string s = to_string(num);
    if(s[0] == s[4] && s[1] == s[3]) { return true; }
    return false;
}

signed main()
{
    int A, B;
    cin >> A >> B;
    int ans = 0;
    for(int i = A; i <= B; ++i) {
        if(check(i)) { ans++; }
    }
    printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>
#include <iterator>
#include <utility>
#include <tuple>

int main(void) {
  int N;
  (void)scanf("%d", &N);
  std::tuple<int, int, bool> reds[N], bles[N];
  for (int i = 0; i < N; ++i) {
    int x, y;
    (void)scanf("%d %d", &x, &y);
    reds[i] = std::make_tuple(x, y, false);
  }
  for (int i = 0; i < N; ++i) {
    int x, y;
    (void)scanf("%d %d", &x, &y);
    bles[i] = std::make_tuple(x, y, false);
  }

  std::sort(bles, bles + N,
            [](const std::tuple<int, int, bool> &x, const std::tuple<int, int, bool> &y) {
              return std::get<0>(x) < std::get<0>(y);
            });
  std::sort(reds, reds + N,
            [](const std::tuple<int, int, bool> &x, const std::tuple<int, int, bool> &y) {
              return std::get<0>(x) < std::get<0>(y);
            });

  for (int b = 0; b < N; ++b) {
    int max = -1, i = -1;
    for (int r = 0; r < N && std::get<0>(reds[r]) < std::get<0>(bles[b]); ++r) {
      if (std::get<2>(reds[r]) == true) continue;
      int ry = std::get<1>(reds[r]);
      if (max < ry && ry < std::get<1>(bles[b])) {
        max = ry;
        i = r;
      }
    }
    if (i >= 0) std::get<2>(reds[i]) = std::get<2>(bles[b]) = true;
  }

  int cnt = 0;
  for (int i = 0; i < N; ++i) {
    if (std::get<2>(reds[i]) == true) cnt++;
  }
  printf("%d\n", cnt);

  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#include <complex>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define fi first
#define se second
#define mp make_pair
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,K,Q,A,B,C,L,R;
string S,T;
const ll MOD = (1e+9) + 7;
const ll INF = 1LL << 60;
typedef pair<ll,ll> P;

typedef vector<P> vp;
typedef vector<vp> matP;


int main() {
    cin>>N>>K;
    vec num(200010,0);
    rep(i,N){
        cin>>A;
        ++num[A];
    }
    sort(num.begin(), num.end());
    reverse(num.begin(), num.end());
    ll sum = 0;
    rep(i,K) sum += num[i];
    cout<<N - sum<<endl;
}

Measured memory_bytes: 1792
#include <stdio.h>

int main(){
    int n;
    scanf("%d",&n);
    int i;
    int pre,dir = 1,tmp,cn = 0;
    scanf("%d",&pre);
    for(i=1;i<n;i++){
        scanf("%d",&tmp);
        if((tmp -pre)*dir<0) dir *= -1;
        else if(i != 1) cn++;
        pre = tmp;
    }
    printf("%d",cn);
}

Measured memory_bytes: 128
A, B = gets.split.map(&:to_i)

size = 100
ret = Array.new(size) { Array.new(size) }

size.times do |i|
  size.times do |j|
    color = i < size / 2 ? '.' : '#'
    ret[i][j] = color
  end
end

i = 0
j = 0
(B - 1).times do
  ret[i][j] = '#'
  if j + 2 >= size
    j = 0
    i += 2
  else
    j += 2
  end
end
i = size / 2 + 1
j = 0
(A - 1).times do
  ret[i][j] = '.'
  if j + 2 >= size
    j = 0
    i += 2
  else
    j += 2
  end
end

puts "#{size} #{size}"
puts ret.map(&:join).join("\n")


Measured memory_bytes: 4092
while True:
  n = int(raw_input())
  if n == 0: break
  s = raw_input().split()
  state = [False, False]
  counter = 0
  stand = False
  for step in s:
    if step == "lu":
      state[0] = True
    elif step == "ru":
      state[1] = True
    elif step == "ld":
      state[0] = False
    elif step == "rd":
      state[1] = False

    if state[0] == state[1] and stand != state[0]:
      counter += 1
      stand = state[0]
  print counter

Measured memory_bytes: 6460
n,y = map(int,input().split())
for a in range(n+1):
  for b in range(n+1-a):
    c = n-a-b
    if 0<=c<=2000 and 1000*a+5000*b+10000*c == y:
      print(c,b,a)
      break
  else:
    continue
  break
else:
  print(-1,-1,-1)



  

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long int t,i,j,k,l,m,n,a[200005],b[200005];
    char s[200005],s1[200005];
    map<long long,long long>mp;
    pair<long long,long long>p[200005];
    long long matrix[500][500];
    cin>>n>>m>>k;
    for(i=0;i<m;i++)
    cin>>a[i];
    for(i=0;i<n;i++)
    {
        for(j=0;j<m;j++)
        cin>>matrix[i][j];
    }
    int count=0;
    for(i=0;i<n;i++)
    {
        long long sum=0;
        for(j=0;j<m;j++)
        {
            sum=sum+matrix[i][j]*a[j];
        }
        sum=sum+k;
        if(sum>0)
        count++;
    }
    cout<<count;
    return 0;
}

Measured memory_bytes: 2304
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools
from collections import deque

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

DR = [1, -1, 0, 0]
DC = [0, 0, 1, -1]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
     
def main():
    N = I()
    s1 = S()
    s2 = S()
    seq = ''
    i = 0
    while i < N:
        if s1[i] == s2[i]:
            seq += 'v'
            i += 1
        else:
            seq += 'h'
            i += 2
    if seq[0] == 'v':
        ans = 3
    else:
        ans = 6

    prev = seq[0]
    for i in range(1, len(seq)):
        cur = seq[i]
        if prev == 'v' and cur == 'h':
            ans *= 2
        if prev == 'v' and cur == 'v':
            ans *= 2
        if prev == 'h' and cur == 'h':
            ans *= 3
        if prev == 'h' and cur == 'v':
            ans *= 1
        prev = cur
        ans %= mod
    print(ans)






main()



Measured memory_bytes: 83656
#include <bits/stdc++.h>
using namespace std;
    
int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  a.at(0) = -1;
  for(int i = 1;i < n;i++)
    cin >> a.at(i);
  
  vector<vector<int>> children(n);
  for(int i = 1;i < n;i++){
    int parent = a.at(i) - 1;
    children.at(parent).push_back(i);
  }
  
  for(int i = 0;i < n;i++){
    cout << children.at(i).size() << endl;
  }  
  return 0;
}


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

const int MAXN = 80;
const int mod = 1000000007;
typedef long long LL;
void reduce(int & x) { x += x >> 31 & mod; }
int mul(int a, int b) { return (LL) a * b % mod; }
int fastpow(int a, int b, int res = 1) {
	for (; b; b >>= 1, a = mul(a, a)) if (b & 1) res = mul(res, a);
	return res;
}
int li[MAXN];
char buf[MAXN];
int n, K, ans;
const int MAXS = 300;
int tl[MAXN], C[MAXS][MAXS];
int fac[MAXN], inv[MAXN];
void dfs(int S, int rest, int can, int lst) {
	if (rest < 0) return ;
	memcpy(tl + 1, li + 1, S << 2);
	int cur1 = 1, cur2 = 1, cur3 = 1;
	for (int i = 1; i <= K; ++i) {
		bool ok = false;
		if (cur1 <= S && buf[i] == 'r') {
			++cur1; ok = true;
		}
		while (cur2 < cur1 && tl[cur2] == 0) ++cur2;
		if (!ok && cur2 + 1 <= cur1 && buf[i] == 'b') {
			--tl[cur2++]; ok = true;
		}
		while (cur2 < cur1 && tl[cur2] == 0) ++cur2;
		if (!ok && cur3 < cur2 && tl[cur3]) --tl[cur3];
		while (cur3 < cur2 && tl[cur3] == 0) ++cur3;
	}
	if (cur3 <= S) return ;
	int tx = mul(C[can + rest - 1][can - 1], fac[S]);
	static int hav[MAXN];
	memset(hav, 0, n + 1 << 2);
	for (int i = 1; i <= S; ++i) ++hav[li[i]];
	for (int i = 0; i <= n; ++i) if (hav[i]) tx = mul(tx, inv[hav[i]]);
	reduce(ans += tx - mod);
	for (int i = lst; ~i; --i) {
		li[S + 1] = i;
		dfs(S + 1, rest - std::max(i, 1) * 2 + (S == 0), can + (i + 1) * 2, i);
	}
}
int main() {
	std::ios_base::sync_with_stdio(false), std::cin.tie(0);
	for (int i = 0; i != MAXS; ++i) {
		C[i][0] = 1;
		for (int j = 1; j <= i; ++j)
			reduce(C[i][j] = C[i - 1][j] + C[i - 1][j - 1] - mod);
	}
	std::cin >> n >> K >> buf + 1;
	inv[0] = inv[1] = fac[0] = fac[1] = 1;
	for (int i = 2; i <= n; ++i) {
		inv[i] = mul(inv[mod % i], mod - mod / i);
		fac[i] = mul(fac[i - 1], i);
	}
	for (int i = 2; i <= n; ++i) inv[i] = mul(inv[i - 1], inv[i]);
	dfs(0, n, 1, n);
	std::cout << ans << std::endl;
	return 0;
}


Measured memory_bytes: 640
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp63 {
    class Program {
        static void Main(string[] args) {
            var st = Console.ReadLine().Split().Select(int.Parse).ToArray();

            int a = st[0];
            int b = st[1];

            int lastHeight = b - a;

            int secondHeight = lastHeight * (lastHeight + 1) / 2;

            Console.WriteLine(secondHeight - b);
        }
    }
}


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


namespace std
{
    class Test {
        static void Main(string[] args) {
            var stack = new Stack<int>();

            foreach(var s  in Console.ReadLine().Split(' '))
            {

                switch(s) {
                    case "+":
                        stack.Push(stack.Pop() + stack.Pop());
                        break;
               
                    case "-":
                        stack.Push(-1 *(stack.Pop() - stack.Pop()));
                        break;
               
                    case "*":
                        stack.Push(stack.Pop() * stack.Pop());
                        break;
                
                    default:
                        stack.Push(int.Parse(s));
                        break;
                }
      
            }
            Console.WriteLine(stack.Pop());
        }
    }
}

      
      
      



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

void pr(void);
void rev(void);
void rep(void);

char str[1001];

int main(){
  int count, i;
  char com[8];

  scanf("%s %d",str,&count);

  for(i=0;i<count;i++){
    scanf("%s",com);

    if(strcmp(com,"print")==0) pr();
    else if(strcmp(com,"reverse")==0) rev();
    else if(strcmp(com,"replace")==0) rep();
  }
  
  return 0;
}


void pr(void){
  int a, b;
  
  scanf("%d %d",&a,&b);
  for(;a<=b;a++) printf("%c",str[a]);
  printf("\n");  
}

void rev(void){
  int a, b, i;
  char sub;

  scanf("%d %d",&a,&b);
  for(i=0;i<=(b-a)/2;i++){
    sub=str[a+i];
    str[a+i]=str[b-i];
    str[b-i]=sub;
  }
}

void rep(void){
  int a, b, i;
  char change[1001];

  scanf("%d %d %s",&a,&b,change);
  for(i=0;i+a<=b;i++) str[a+i]=change[i];
}



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


int main(void){
  int n,m,i,x;
  string s,t="";
  vector<int> wx;
  
  cin >> s;
  n=s.size();
  
  i=0;
  while (i<n){
    x=0;
    while (i<n && s[i]=='x'){
      i++;
      x++;
    }
    wx.push_back(x);
    if (i<n) t+=s[i];
    i++;
  }
  if (s[i]!='x') wx.push_back(0);
  
  m=t.size();
  for (i=0;i<m;i++){
    if (t[i]!=t[m-i-1]){
      cout << -1 << endl;
      return 0;
    }
  }
  
  int ans=0;
  for (i=0;i<m+1;i++){
    ans+=abs(wx[i]-wx[m-i]);
    wx[i]=max(wx[i],wx[m-i]);
    wx[m-i]=max(wx[i],wx[m-i]);
  }
  
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 1148
a, b, c, x = 4.times.map { gets.to_i }

cnt = 0
(0..a).each do |i|
  (0..b).each do |j|
    (0..c).each do |k|
      cnt += 1 if i*500+j*100+k*50==x
    end
  end
end

p cnt


Measured memory_bytes: 1788
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "ctime"

using namespace std;

const long long int MOD = 1000000007;
const long double EPS = 1e-8;

long long int N, M, K, H, W, L, R;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	cin >> N >> M;
	if (N % 2 && M % 2)cout << "Yes\n";
	else cout << "No\n";

	return 0;
}

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

int main()
{
  ll n,w;
    cin>>n>>w;
    ll arr[n+1][2];
    for(ll i=1;i<=n;i++)cin>>arr[i][0]>>arr[i][1];
    vector<ll> dp(100001,(ll)1e18);
    dp[(ll)0]=(ll)0;
    for(ll i=1;i<=n;i++)
    {
      for(ll j=100000-arr[i][1];j>=0;j--)dp[j+arr[i][1]]=min(dp[j+arr[i][1]],dp[j]+arr[i][0]);
    }
    ll ans=0;
   for(ll i=0;i<=100000;i++)
  {
     if(dp[i]<=w)ans=max(ans,i);
  }
    cout<<ans<<endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include<vector>
using namespace std;
#define rep(i, n)        for(int i=0; i<(int)(n); ++i)
int main() {
  int a,b,c;cin>>a>>b>>c;
  for(int i=min(a,b);i>0;i--){
    if(a%i==0&&b%i==0)c--;
    if(c==0){
      cout<<i;
      break;
    }
  }
}

Measured memory_bytes: 256
n=int(input())
ns=list(map(int,input().split()))
ans=0
for i in range(n):
    minj=i
    for j in range(i,n):
        if(ns[j]<ns[minj]):
            minj=j
    if i!=minj:
        ans+=1
        k=ns[i]
        ns[i]=ns[minj]
        ns[minj]=k
 
for i in range(n):
    if(i!=n-1):
        print(ns[i],end=' ')
print(ns[n-1])
print(ans)


Measured memory_bytes: 5604
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
ll n,m;
cin>>n>>m;
ll i,a,sum=0;
for(i=0;i<m;i++)
{
    cin>>a;
    sum+=a;
}
if((n-sum)>=0) cout<<n-sum<<endl;
else cout<<-1<<endl;
    return 0;
}



Measured memory_bytes: 3636
//program luogu.AT2281
#include<iostream>
#include<cstdio>
using namespace std;
int k,s,ans;

void DFS(int sum,int cnt){
	if( cnt==2 ){
		if( s-sum>=0 && s-sum<=k )
			ans++;
		return;
	}
	
	for(int i=0;i<=k;i++)
		DFS(sum+i,cnt+1);
}

int main(){
	scanf("%d%d",&k,&s);
	DFS(0,0);
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 256
lines = readlines.map(&:split)
max, left, right = lines[0].map(&:to_i).sort.reverse

left_diff = max-left
right_diff = max-right

result = 
  if(left_diff%2==0 && right_diff%2==0)
    (left_diff + right_diff)/2
  elsif(left_diff%2==1 && right_diff%2==1)
    (left_diff + right_diff - 1)/2 + 1
  elsif(left_diff%2==1 || right_diff%2==1)
    (left_diff + right_diff + 1)/2 + 1
  end
#puts [max,left,right,left_diff,right_diff]
puts result


Measured memory_bytes: 1788
import sys
sys.setrecursionlimit(10**7) #再帰関数の上限,10**5以上の場合python
import math
from copy import copy, deepcopy
from copy import deepcopy as dcp
from operator import itemgetter
from bisect import bisect_left, bisect, bisect_right#2分探索
#bisect_left(l,x), bisect(l,x)#aはソート済みである必要あり。aの中からx未満の要素数を返す。rightだと以下
from collections import deque, defaultdict
#deque(l), pop(), append(x), popleft(), appendleft(x)
#q.rotate(n)で → にn回ローテート
from collections import Counter#文字列を個数カウント辞書に、
#S=Counter(l),S.most_common(x),S.keys(),S.values(),S.items()
from itertools import accumulate,combinations,permutations,product#累積和
#list(accumulate(l))
from heapq import heapify,heappop,heappush
#heapify(q),heappush(q,a),heappop(q) #q=heapify(q)としないこと、返り値はNone
from functools import reduce,lru_cache#pypyでもうごく
#@lru_cache(maxsize = None)#maxsizeは保存するデータ数の最大値、2**nが最も高効率
from decimal import Decimal

def input(): 
    x=sys.stdin.readline()
    return x[:-1] if x[-1]=="\n" else x
def printe(*x):print("## ",*x,file=sys.stderr)
def printl(li): _=print(*li, sep="\n") if li else None
def argsort(s, return_sorted=False): 
    inds=sorted(range(len(s)), key=lambda k: s[k])
    if return_sorted: return inds, [s[i] for i in inds]
    return inds
def alp2num(c,cap=False): return ord(c)-97 if not cap else ord(c)-65
def num2alp(i,cap=False): return chr(i+97) if not cap else chr(i+65)
def matmat(A,B):
    K,N,M=len(B),len(A),len(B[0])
    return [[sum([(A[i][k]*B[k][j]) for k in range(K)]) for j in range(M)] for i in range(N)]
def matvec(M,v):
    N,size=len(v),len(M)
    return [sum([M[i][j]*v[j] for j in range(N)]) for i in range(size)]
def T(M):
    n,m=len(M),len(M[0])
    return [[M[j][i] for j in range(n)] for i in range(m)]
def binr(x): return bin(x)[2:]
def bitcount(x): #xは64bit整数
    x= x - ((x >> 1) & 0x5555555555555555)
    x= (x & 0x3333333333333333) + ((x >> 2) & 0x3333333333333333)
    x= (x + (x >> 4)) & 0x0f0f0f0f0f0f0f0f 
    x+= (x >> 8); x+= (x >> 16); x+= (x >> 32) 
    return x & 0x7f

def main():
    mod = 1000000007
    #w.sort(key=itemgetter(1),reverse=True)  #二個目の要素で降順並び替え

    #N = int(input())
    N, K = map(int, input().split())
    P = tuple(map(int, input().split())) #1行ベクトル
    C = tuple(map(int, input().split()))
    #L = tuple(int(input()) for i in range(N)) #改行ベクトル
    #S = tuple(tuple(map(int, input().split())) for i in range(N)) #改行行列

    
    tans=-float('inf')
    for i in range(N):
        start=i
        cur=P[i]-1
        score=C[cur]
        time=1
        ans=-float('inf')

        f2=0
        while True:
            
            if cur==start and f2==0:
                f2=1

                d=(K//time)
                if d>=2:
                    time=(d-1)*time
                    score=(d-1)*score

            ans=max(ans,score)


            cur=P[cur]-1
            score=score+C[cur]
            time=time+1
            if time>K:
                break
        tans=max(ans,tans)
    print(tans)





if __name__ == "__main__":
    main()

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

using db = long double;
using ll = long long;
using vi = vector <int>;
#define op operator
#define pb push_back

struct poi {
	db x, y;
	void r() { cin >> x >> y; }
	poi op -(poi p) {
		return {x - p.x, y - p.y};
	}
	db cross(poi p) {
		return x * p.y - y * p.x;
	}
};
db xmul(poi a, poi b, poi c) {
	return (b - a).cross(c - a);
}
db li(poi a, poi b, poi c, poi d) {
	if(xmul(a, b, c) * xmul(a, b, d) > 0) return 2;
	return (c - a).cross(d - c) / (b - a).cross(d - c);
}

int main() {
	cout << fixed << setprecision(9);
	ios :: sync_with_stdio(0);

	int t; cin >> t;
	while(t --) {
		poi a, b; a.r(); b.r();
		int n; cin >> n;
		vector <pair <db, int>> v;
		while(n --) {
			poi p, q; p.r(); q.r();
			int o, l; cin >> o >> l;
			db t = li(a, b, p, q);
			if(t > 0 && t < 1)
				v.pb({t, o ^ l});
		}

		sort(v.begin(), v.end());
		int ans = 0;
		for(int i = 1; i < v.size(); i ++)
			if(v[i].second != v[i - 1].second)
				ans ++;
		cout << ans << '\n';
	}

	return 0;
}

Measured memory_bytes: 3272
#include <iostream>
#include <string>
 
using std::cout;
using std::cin;
using std::endl;
using std::string;
 
 
int main()
{
    string s;
    cin >> s;
    
    int num_hug = 0;
    int s_len = s.size();
    for (int i = 0; i < s_len/2; ++i) {
        if (s[i] != s[s_len - 1 - i]) ++num_hug;
    }
    cout << num_hug;
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;

class Program
{
	static void Main(string[] args)
	{
		string[] input = Console.ReadLine().Split(' ');
		int x = int.Parse(input[0]);
		int n = int.Parse(input[1]);
		if(n==0)
		{
			Console.WriteLine(x);
			return;
		}
		List<int> p = new List<int>();
		input = Console.ReadLine().Split(' ');
		for(int i=0; i<n; i++) p.Add(int.Parse(input[i]));
		p.Sort();
		int index = p.BinarySearch(x);
		if(index<0)
		{
			Console.WriteLine(x);
			return;
		}
		int diff = 1;
		while(true)
		{
			int indMin = index - diff;
			if(indMin<0 || p[indMin] != x - diff)
			{
				Console.WriteLine(x-diff);
				return;
			}
			int indMax = index + diff;
			if(indMax>=n || p[indMax] != x + diff)
			{
				Console.WriteLine(x+diff);
				return;
			}
			diff++;
		}

	}
}



Measured memory_bytes: 27848
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <stdlib.h>
using namespace std;

int main()
{
    long long int n;
    cin >> n;
    std::vector<int> v;
    for(int i=0; i<n; i++){
        int tmp;
        cin >> tmp;
        v.push_back(tmp);
    }
    long long int cnt = 0;
    std::map<long long int, int> m;
    for(int i=0; i<n; i++){
        int a = v[i];
        int index = i + a;
        m[index]++;
    }
    
    for(int i=0; i<n; i++){
        int a = v[i];
        int index = i - a;
        if(index >= 0){
            cnt += m[index];
        }
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 17500
#include <stdio.h>

int main()
{
	int m, f, r, MAX;
	int i=0;
	char result[50];

	for(;;){
		//成績を読み込む
		scanf("%d %d %d", &m, &f, &r);

		//全て-1なら終了する
		if(m==-1 && f==-1 && r==-1){
			break;
		}

		//中間・期末をどちらも欠席していないか
		if(m==-1 || f==-1){
			result[i] = 'F';
		}else{
			if(m+f > 79){
				result[i] = 'A';
			}else if(m+f > 64 && m+f < 80){
				result[i] = 'B';
			}else if(m+f > 49 && m+f < 65){
				result[i] = 'C';
			}else if(m+f > 29 && m+f < 50){
				if(r > 49){
					result[i] = 'C';
				}else{
					result[i] = 'D';
				}
			}else{
				result[i] = 'F';
			}
		}

		i++;
	}

	MAX = i;

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

	return 0;
}


Measured memory_bytes: 2120
//
//  main.c
//  Number of Multiples
//
//  Created by k19031kk on 2020/07/11.
//  Copyright © 2020 AIT. All rights reserved.
//

#include <stdio.h>

int main(int argc, const char * argv[]) {
    int minnum,maxnum,num;
    int count = 0 ,sum = 0;
    scanf("%d",&minnum);
    scanf("%d",&maxnum);
    scanf("%d",&num);
    
    
    
    
    while(sum <= maxnum){
        if(maxnum >= sum && minnum <= sum){
            count += 1;
        }
        sum += num;
    }
    printf("%d\n",count);
    return 0;
}


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

int main() {
  int64_t x;
  cin >> x;
  
  int64_t h = 100;
  int64_t ans = 0;
  while (h < x) {
    h *= 1.01;
    ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 3596
#include<bits/stdc++.h>
using namespace std;
const int N = 1e5+10;
int tree[N << 2];
inline void pushup(int rt){
	tree[rt] = max(tree[rt << 1], tree[rt << 1 | 1]);
}
inline void update(int p, int l, int r, int rt, int x){
	if(l == r){
		tree[rt] = x;
		return;
	}
	int mid = (l + r) >> 1;
	if(mid >= p)update(p, l, mid, rt << 1, x);
	else update(p, mid + 1, r, rt << 1 | 1, x);
	pushup(rt);
}
inline int query(int x, int y, int l, int r, int rt){
	if(x <= l && r <= y)return tree[rt];
	int mid = (l + r) >> 1, ans = 0;
	if(mid >= x)ans = max(ans, query(x, y, l, mid, rt << 1));
	if(mid < y)ans = max(ans, query(x, y, mid + 1, r, rt << 1 | 1));
	return ans;
}
int x[N], a[N], hsh[N];
inline bool cmp(int x, int y){
	return a[x] < a[y];
}
int tot = 0;
int main(){
	int n; scanf("%d", &n);
	for(int i = 1; i <= n; ++ i)scanf("%d", &a[i]), x[i] = i;
	sort(x + 1, x + n + 1, cmp); a[0] = -1;
	for(int i = 1; i <= n; ++ i){
		if(a[x[i]] != a[x[i - 1]])
			++ tot;
		hsh[x[i]] = tot;
	}
	int mx = 1;
	update(hsh[1], 1, tot, 1, 1);
	for(int i = 2; i <= n; ++ i){
		int t = query(hsh[i], tot, 1, tot, 1);
		mx = max(mx, t + 1);
		update(hsh[i], 1, tot, 1, t + 1);
	}
	printf("%d", mx);
	return 0;
}

Measured memory_bytes: 2432
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations, product
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor
from operator import mul
from functools import reduce


INF = float('inf')
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return sys.stdin.readline().strip()
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 1000000007


def find_cycle(graph, vst):
    que = deque([vst])
    dist = [-1] * n
    pre = [-1] * n
    dist[vst] = 0
    flag = False
    while que:
        cur = que.popleft()
        for nxt in graph[cur]:
        # 無向グラフでは祖父の所にいかない工夫が必要。
            if nxt == vst:
                flag = True
                break
            if dist[nxt] != -1:
                continue
            pre[nxt] = cur
            dist[nxt] = dist[cur] + 1
            que += [nxt]
        if flag:
            v = cur
            cycle = []
            while v != -1:
                cycle += [v]
                v = pre[v]
            return cycle


ret_len = INF
n, m = LI()
graph = [[] for _ in range(n)]
for _ in range(m):
    a, b = LI()
    graph[a - 1] += [b - 1]


min_cycle = 0
for vst in range(n):
    cycle = find_cycle(graph, vst)
    if cycle and len(cycle) < ret_len:
        min_cycle = cycle
        ret_len = len(cycle)


if min_cycle:
    print(ret_len)
    for i in min_cycle:
        print(i + 1)
else:
    print(-1)

Measured memory_bytes: 44636
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        Integer n = sc.nextInt();
        int maxHeight = 0;
        int ans = 0;
        for (int i=0; i<n; i++) {
            int h = sc.nextInt();
            if (h >= maxHeight) ans++;
            maxHeight = Math.max(maxHeight, h);
        }
        System.out.println(ans);
    }
}


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

int main() {
  int N, W;
  cin>>N>>W;
  int w[N], v[N];
  for (int i=0; i<N; i++) cin>>w[i]>>v[i];

  long long dp[N][100001];

  dp[0][0] = 0;
  for (int i=1; i<100001; i++) {
    if (i <= v[0]) {
      dp[0][i] = w[0];
    } else {
      dp[0][i] = 1e11;
    }
  }
  for (int i=1; i<N; i++) {
    for (int j=0; j<100001; j++) {
      if (j >= v[i]) {
        dp[i][j] = min(dp[i-1][j], dp[i-1][j-v[i]] + w[i]);
      } else {
        dp[i][j] = dp[i-1][j];
      }
    }
  }
  int ans = 0;

  for (int i=0; i<100001; i++) {
    if (dp[N-1][i] <= W) {
      ans = i;
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 78336
#if 1
#include <iostream>
#include <cmath>
#include <string>
#include <vector>
#include <climits>
#include <algorithm>
#include <unordered_set>
#include <unordered_map>
#include <functional>
#include <set>
#include <map>
#include <numeric>
#include <cassert>
#include <iomanip>

using namespace std;
#define int long long
#define uint unsigned long long
constexpr int MOD = 1000000007;
constexpr int INF = 1145141919810893;

#define LOADVEC(type,name,N) std::vector<type>name(N); \
for (int nnn = 0; nnn < N; ++nnn) { \
	cin >> name[nnn]; \
}

#define LOADVEC2(type,name0,name1,N) std::vector<type>name0(N),name1(N); \
for (int nnn = 0; nnn < N; ++nnn) { \
	cin >> name0[nnn];cin >> name1[nnn]; \
}

#define LOADVEC3(type,name0,name1,name2,N) std::vector<type>name0(N),name1(N),name2(N); \
for (int nnn = 0; nnn < N; ++nnn) { \
	cin >> name0[nnn];cin >> name1[nnn];cin >> name2[nnn]; \
}

#define LOAD(type,name) type name; \
cin >> name;


void proc();

signed main() {
	ios::sync_with_stdio(false);
	proc();
	return 0;
}

/*
--------------------------------------------------------
--------------------------------------------------------
---------------    template      ----------------------
--------------------------------------------------------
--------------------------------------------------------
*/


void proc() {
	LOAD(int, N);
	LOAD(int, K);
	double res;
	for (int i = 1; i <= N; ++i) {
		int n = i;
		int j = 0;
		for (j = 0;; ++j) {
			if (n >= K)break;
			n *= 2;
		}
		res += 1 / std::pow(2, j);
	}
	cout << std::setprecision(13)<<res / N << endl;
}


#endif


Measured memory_bytes: 384
#include<iostream>
#include <math.h>
#include<cstdio>
using namespace std;

//???????????????
struct Vertex2D{
	double x;
	double y;
};
//?????????????????????(????????¨??????)
#define Vector2D Vertex2D

//???????????¢
double distance_vertex(Vertex2D p1, Vertex2D p2) {
	return pow( ( p2.x - p1.x ) * ( p2.x - p1.x ) + ( p2.y - p1.y ) * ( p2.y - p1.y ), 0.5 );
}

//??????????????????
double cross_vector(Vector2D vl, Vector2D vr) {
	return vl.x * vr.y - vl.y * vr.x;
}

//???P??¨???(AB)????????¢
double Distance_DotAndLine(Vertex2D P, Vertex2D A, Vertex2D B )
{
	Vector2D AB,AP;

	AB.x = B.x - A.x;
	AB.y = B.y - A.y;
	AP.x = P.x - A.x;
	AP.y = P.y - A.y;

	//????????????AB???AP??????????????¶???????????????????????¢D?????¢????????????
	double D =  cross_vector( AB, AP );

	double L = distance_vertex( A, B );	//AB???????????¢

	double H = D / L;
	return H;

}


int main(){

	struct  Vertex2D point[4];

	while(	scanf("%lf %lf %lf %lf %lf %lf %lf %lf ",&point[0].x , &point[0].y,
													 &point[1].x , &point[1].y,
													 &point[2].x , &point[2].y,
													 &point[3].x , &point[3].y) != EOF){
	int check = 0;
	for(int i=0;i<3;i++){
		double tmp =  Distance_DotAndLine(point[i%3],point[(i+1)%3],point[3]);
		if(tmp < 0){
			check--;
		}else{
			check++;
		}
	}
	if(check == 3 or check == -3){
		cout << "YES" << endl;

	}else{
		cout << "NO" << endl;

	}
	}
	return 0;
}

Measured memory_bytes: 1296
n= int(input())
for _ in range(n):
    a= input()
    ans=set()
    ans.add(a)
    for i in range(len(a)):
        s=a[:i]
        t=a[i:]
        ans.add(s[::-1]+t[::-1])
        ans.add(t[::-1]+s[::-1])
        ans.add(s[::-1]+t)
        ans.add(t[::-1]+s)
        ans.add(s+t[::-1])
        ans.add(t+s[::-1])
        ans.add(t+s)
        
    print(len(ans))
        


Measured memory_bytes: 5632
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
using namespace std;
using namespace __gnu_pbds;
 
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key
 
typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<int> vi;
typedef long double ld; 
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
typedef set<int>::iterator sit;
typedef map<int,int>::iterator mit;
typedef vector<int>::iterator vit;

const int MOD = 1e9+7;

int add(int a, int b)
{
	a+=b;
	while(a>=MOD) a-=MOD;
	return a;
}
int mult(int a, int b)
{
	return (a*1LL*b)%MOD;
}

int pow2[2111];
int dp[2111][2111];
int sum[2111][2111];

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	pow2[0]=1; for(int i=1;i<=2011;i++){pow2[i]=add(pow2[i-1],pow2[i-1]);}
	int n,k; cin>>n>>k;
	if(n==1)
	{
		cout<<1<<'\n';
		return 0;
	}
	int coeff=(k<n?pow2[n-k-1]:1);
	for(int i=1;i<=n-1;i++) dp[0][i]=1;
	for(int i=1;i<k;i++)
	{
		for(int j=n-i-1;j>=(i==n-1?0:1);j--)
		{
			if(j==n-i-1) dp[i][j]=dp[i-1][j+1];
			else dp[i][j]=dp[i][j+1];
			dp[i][j]=add(dp[i][j],dp[i-1][j]);
		}
	}
	int ans=dp[k-1][(k==n?0:1)];
	ans=mult(ans,coeff);
	cout<<ans<<'\n';
}


Measured memory_bytes: 18688
#include <stdio.h>
#include <math.h>
int main()
{
	int n, i;
	double x[100], y[100], z[100], max = 0, a = 0, b = 0, c = 0;
	scanf("%d", &n);
	for (i = 0; i < n; i++)
	{
		scanf("%lf", &x[i]);
	}	
	for (i = 0; i < n; i++)
	{
		scanf("%lf", &y[i]);
	}
	for (i = 0; i < n; i++)
	{
		z[i] = fabs(x[i] - y[i]);
		a += z[i];
		b += pow(z[i], 2);
		c += pow(z[i], 3);
		if (max < z[i])
		{
			max = z[i];
		}
	}
	printf("%f\n%f\n%f\n%f\n", a, sqrt(b), cbrt(c), max);

	return 0;
}


Measured memory_bytes: 2108
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <set>
#include <string>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <utility>
using namespace std;

typedef unsigned int uint;
typedef long long int64;
typedef unsigned long long uint64;
typedef pair<int, int> ii;
typedef pair<int64, int64> int64int64;
typedef vector<int> vint;
typedef vector<int64> vint64;
typedef vector<uint64> vuint64;
typedef vector<vint> vvint;
typedef vector<vint64> vvint64;
typedef vector<vuint64> vvuint64;
typedef vector<ii> vii;
typedef vector<vector<ii>> vvii;

#define mp make_pair
#define pb push_back
#define ALL(a) a.begin(), a.end()
#define fi first
#define se second
#define fori(n) for(int i = 0; i < n; ++i)
#define forj(n) for(int j = 0; j < n; ++j)
#define fork(n) for(int k = 0; k < n; ++k)
#define INF9 (int64)(1e9)
#define INF18 (int64)(1e18)

template<typename T>
struct compF{
	bool operator()(const pair<T, T> &a, const pair<T, T> &b){
		return a.first < b.first;
	}
};

template<typename T>
struct compS{
	bool operator()(const pair<T, T> &a, const pair<T, T> &b){
		return a.second < b.second;
	}
};

template<typename T>
void printMatrix(const string &txt, vector<vector<T>> &a){
	cout << txt;
	fori(a.size()){
		forj(a[i].size())
			cout << a[i][j] << ' ';

		cout << endl;
	}
}

template<typename T>
void printVector(const string &txt, vector<T> &a){
	cout << txt;
	for (int i = 0; i < a.size(); ++i)
		cout << a[i] << ' ';
	cout << endl;
}

template<typename T>
void readVector(int n, vector<T> &a){
	if (a.size() < n)
		a.resize(n);

	fori(n) cin >> a[i];
}

template<typename T1, typename T2>
bool exist(map<T1, T2> &m, T1 x){
	if (m.find(x) == m.end())
		return false;

	return true;
}

int64 gcd(int64 a, int64 b){
	while (a != 0 && b != 0){
		if (b > a)
			b %= a;
		else
			a %= b;
	}

	return a + b;
}

int64 minFactor(int64 x){
	for (int64 i = 2; i * i <= x; ++i)
		if (x % i == 0)
			return i;

	return x;
}

int64 allFactors(int64 x, vint64 &prms, vint64 &prm_cnt){
	prms.clear();
	prm_cnt.clear();
	while (x > 1){
		int64 t = minFactor(x);
		prms.push_back(t);
		int s = prms.size() - 1;
		prm_cnt.push_back(0);
		while (x % t == 0){
			x /= t;
			++prm_cnt[s];
		}
	}

	return 0;
}

int main(){

	ios_base::sync_with_stdio(0);
	cin.tie();
	
	int n, q;
	cin >> n;
	vint a(n);
	readVector(n, a);

	int64 sum = 0;
	vint occ(100001, 0);
	fori(n){
		sum += a[i];
		++occ[a[i]];
	}

	cin >> q;
	fori(q){
		int b, c;
		cin >> b >> c;

		sum -= b * occ[b];
		sum += c * occ[b];
		occ[c] += occ[b];
		occ[b] = 0;

		cout << sum << endl;
	}

	return 0;
}


Measured memory_bytes: 3576
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define repp(i,l,r,k)for(ll i=(l);i<(r);i+=(k))
#define INF ((1LL<<62)-(1LL<<31))
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
#define bit(n,m)(((n)>>(m))&1)
int upll(const void*a, const void*b){return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;}
int downll(const void*a, const void*b){return*(ll*)a<*(ll*)b?1:*(ll*)a>*(ll*)b?-1:0;}
void sortup(ll*a,int n){qsort(a,n,sizeof(ll),upll);}
void sortdown(ll*a,int n){qsort(a,n,sizeof(ll),downll);}
ll pom(ll a,ll n,int m){ll x=1;for(a%=m;n;n/=2)n&1?x=x*a%m:0,a=a*a%m;return x;}
//#define MOD 998244353
#define MOD 1000000007
#define invp(a,p)pom(a,p-2,p)

ll a[5],ans;
int main(){
	ll n;
	scanf("%lld",&n);
	rep(i,0,5)scanf("%lld",a+i);
	ll m=INF,mi;
	rep(i,0,5){
		if(m>a[i]){
			m=min(m,a[i]);
			mi=i;
		}
	}
	ll ans=4+(n+a[mi]-1)/a[mi];
	printf("%lld",ans);
}

Measured memory_bytes: 128
#define ll long long
#define MOD 1000000007
#define MOD2 998244353
#define INF 1e12
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define set2d(array, val, m, n) memset(array, val, sizeof(array[0][0]) * m * n);
#define FOR(i, n) for (int i = 0; i < n; i++)
#define FORE(i, a, b) for (int i = a; i <= b; i++)
#define pii pair<int, int>
#define pll pair<ll, ll>
#include <bits/stdc++.h>
using namespace std;
ll power(ll x, ll y, ll p)
{
    ll res = 1;
    x %= p;
    while (y > 0)
    {
        if (y & 1)
            res = (res * x) % p;
        y = y >> 1;
        x = (x * x) % p;
    }
    return res;
}
ll po(ll base, ll powerRaised)
{
    if (powerRaised != 0)
        return (base * po(base, powerRaised - 1));
    else
        return 1;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    // #ifndef ONLINE_JUDGE
    //     freopen("input.txt", "r", stdin);
    //     freopen("output.txt", "w", stdout);
    // #endif //*/
    ll n, s;
    cin >> n;
    set<string> st;
    for (int i = 0; i < n; i++)
    {
        string s;
        cin >> s;
        st.insert(s);
    }
    cout << st.size();
}

Measured memory_bytes: 19244
#include<iostream>
#include<iomanip>
#include<algorithm>

using namespace std;

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

int main(){
    int A,B;
    cin >> A >> B;

    int i1,i2,i4,i5;
    int sum = 0;
    FOR(i,A,B+1){
        i1 = i/10000;
        i2 = i/1000;
        i4 = i%100;
        i5 = i%10;
        if(i1==i5 && (i2-10*i1)==(i%100-i%10)/10){
            sum += 1;
        }
    }

    cout << sum;
}


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

using namespace std;
#define ll long long int
#define pb push_back
#define rep(i, a, v) for(int i = a; i <= v; ++i)
#define vi vector<int>
#define vll vector<ll>
#define maxi 1000000007
#define pi 3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679
const double pie = 3.1415926535;
const string spaces = "    ";

const int MAX = 3002;
double ps[MAX], dp[MAX][MAX];
int N;

double FindAns(int start, int heads){
    if(start == 0)
        return (heads == 0);
    if(dp[start][heads] != -1)
        return dp[start][heads];
    double ans = ps[start] * FindAns(start - 1, heads - 1) + (1 - ps[start]) * FindAns(start - 1, heads);
    dp[start][heads] = ans;
    return ans;
}

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

    for(int i = 0; i <= N; ++i)
        for(int j = 0; j <= N; ++j)
            dp[i][j] = -1;

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

    double ans = 0;
    for(int i = N; i > N / 2; --i){
        ans += FindAns(N, i);

    }

    cout << std::fixed << std::setprecision(20) << ans << "\n";
    return 0;
}


Measured memory_bytes: 70784