akhauriyash/Code-Regression huggingface dataset:
#include <functional>
#include <algorithm>
#include <iostream>
#include <numeric>
#include <iomanip>
#include <utility>
#include <cstdlib>
#include <sstream>
#include <bitset>
#include <vector>
#include <cstdio>
#include <ctime>
#include <queue>
#include <deque>
#include <cmath>
#include <stack>
#include <list>
#include <map>
#include <set>

using namespace std;

typedef vector<int> vi;
typedef pair<int,int> pii;
typedef long long ll;

#define dump(x)  cerr << #x << " = " << (x) << endl
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(a)  (a).begin(),(a).end()
#define pb push_back


int main() {
    int n,m,i,j,s,l,c,r,t;
    int a[100]={0};
    int w[100]={0};
    scanf("%d %d",&n,&m);
    for(i=0;i<m;i++){
        scanf("%d %d",&s,&l);
        for(j=s;j<s+l;j++)w[j%n]=1;
    }
    

    
    
    for(i=c=r=0;i<n;i++){
        if(w[i])c++;
        else{
            a[r++]=c;
            c=0;
        }
    }
    a[0]+=c;
    for(i=0;i<n;i++){
        for(j=i;j;j--){
            if(a[j-1]<a[j]){
                t=a[j];
                a[j]=a[j-1];
                a[j-1]=t;
            }
        }
    }
    
    for(i=0;i<n;i++){
        if(a[i]==0)break;
        printf("%d ",a[i]);
        for(j=1;a[i]==a[i+j];j++);
        printf("%d\n",j);
        i+=j-1;
    }
        return 0;
}


Measured memory_bytes: 1192
n,k = list(map(int,input().split()))
s = input()
t = ''
for i in range(n):
  if i != k-1:
    t += s[i]
  else:
    if s[k-1] == 'A':
      t += 'a'
    elif s[k-1] == 'B':
      t += 'b'
    else:
      t += 'c'
print(t)
  

Measured memory_bytes: 3060
#include <algorithm>
#include <cassert>
#include <cfloat>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>
 
#define FOR(i,k,n) for (int (i)=(k); (i)<(n); ++(i))
#define rep(i,n) FOR(i,0,n)
#define all(v) begin(v), end(v)
#define debug(x) cerr<< #x <<": "<<x<<endl
#define debug2(x,y) cerr<< #x <<": "<< x <<", "<< #y <<": "<< y <<endl
 
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef vector<ll> vll;
typedef vector<vector<ll> > vvll;
typedef deque<bool> db;
template<class T> using vv=vector<vector< T > >;

int main() {
  int n, t;
  scanf("%d%d", &n, &t);
  vi time(n+1);
  rep (i, n) {
    scanf("%d", &time[i]);
  }
  time[n] = 2*1e9;
  int ans = 0;
  rep (i, n) {
    ans += min(t, time[i+1] - time[i]);
  }
  printf("%d\n", ans);

  return 0;
}


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

int calc(double x, int price);

int main()
{
    int x, y, s;
    while(1){
        cin >> x;
        cin >> y;
        cin >> s;
        if(x == 0 && y == 0 && s == 0){
            break;
        }
        int a = 0;
        int b = 0;
        int sum;
        int max = 0;
        for(int i = 1; i < s; i++){
            for(int j = 1; j < s; j++){
                a = (i * (100 + x)) / 100;
                b = (j * (100 + x)) / 100;
                if(a + b == s){
                    sum = ((i * (100 + y)) / 100) + ((j * (100 + y)) / 100);
                    if(max < sum) {
                        max = sum;
                    }
                }
            }
        }
        cout << max << endl;
    }
    return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <queue>

using namespace std;

using ll = long long int;

int main()
{
  int n, k;
  cin >> n >> k;
  vector<pair<ll, int>> sushi(n);
  for(int i = 0; i < n; i++)
  {
    int t;
    ll d;
    cin >> t >> d;
    sushi[i] = {d, t - 1};
  }
  sort(sushi.begin(), sushi.end());
  reverse(sushi.begin(), sushi.end());

  //結果を保持する配列
  vector<ll> memo_oishi(n + 1, 0);
  vector<int> memo_kind(n, 0);
  
  //k個の取り込み
  priority_queue<pair<ll, int>, vector<pair<ll, int>>, greater<pair<ll, int>>> pqsmall;
  ll total = 0;
  int kind = 0;
  for(int i = 0; i < k; i++)
  {
    pair<ll, int> current = sushi[i];
    if(memo_kind[current.second] == 0)
    {
      kind++;
    }
    memo_kind[current.second]++;
    total += current.first;
    pqsmall.push(current);
  }

  //残りをpriority_queueに追加
  priority_queue<pair<ll, int>, vector<pair<ll, int>>, less<pair<ll, int>>> pqlarge;
  for(int i = k; i < n; i++)
  {
    pqlarge.push(sushi[i]);
  }

  memo_oishi[kind] = total;


  //Nこまで再帰的に計算
  for(int i = kind; i < k; i++)
  {
    //pqsmallから種類を減らさない最小の美味しさを持つ寿司を取り出す
    ll temp = memo_oishi[i];
    ll minus = 0;
    while(true)
    {
      if(pqsmall.empty())
      {
        break;
      }
      pair<ll, int> current = pqsmall.top();
      pqsmall.pop();
      if(memo_kind[current.second] > 1)
      {
        minus = current.first;
        memo_kind[current.second]--;
        break;
      }
    }
    //pqlargeから種類を増やす最大の美味しさを持つ寿司を取り出す
    ll plus = 0;
    while(true)
    {
      if(pqlarge.empty())
      {
        break;
      }
      pair<ll, int> current = pqlarge.top();
      pqlarge.pop();
      if(memo_kind[current.second] == 0)
      {
        plus = current.first;
        memo_kind[current.second] = 1;
        break;
      }
    }
    if(minus == 0 || plus == 0) break;
    temp = temp - minus + plus;
    memo_oishi[i + 1] = temp;
  }
  ll max_oishi = 0;
  for(ll i = 0; i < n + 1; i++)
  {
    if(memo_oishi[i] == 0) continue;
    max_oishi = max(max_oishi, memo_oishi[i] + i * i);
  }
  cout << max_oishi << endl;
}


Measured memory_bytes: 5620
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
	ll n,m;
	cin>>n>>m;
	char arr[n][m];
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<m;j++)
		{
			cin>>arr[i][j];
		}
	}
	vector<vector<ll> > dp(n,vector<ll>(m,0));
	dp[0][0] = 1;
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<m;j++)
		{
			if(i==0 && j==0)
				continue;
			if(arr[i][j] == '#')
				continue;
			dp[i][j] =  (((i-1>=0)?dp[i-1][j]:0)%1000000007 + ((j-1>=0)?dp[i][j-1]:0)%1000000007)%1000000007;
		}
	}
	cout<<dp[n-1][m-1]%1000000007<<endl;
}

Measured memory_bytes: 9088
import numpy as np
N,M = map(int,input().split())
S = np.array(input().split(), dtype = np.int32)
T = np.array(input().split(), dtype = np.int32)
dp = np.ones(M+1, dtype = np.int64)
for s in S:
  dp[1:] = ((dp[:-1] * (T == s)).cumsum() + dp[1:]) % (10**9 + 7)
print(dp[M])

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

#define REPZ(i, z, n) for (decltype(n) i = (z); i <= (n); i++)
#define REP(i, n) for (decltype(n) i = 0; i <= (n); i++)
#define ALL(v) v.begin(), v.end()
#define SIZE(v) ((ll)(v).size())
#define MAX(v) (*max_element(ALL(v)))
#define MIN(v) (*min_element(ALL(v)))
#define INF 1000000000000  // 1E+12

// 略
#define PB push_back
#define F first
#define S second
#define MP make_pair
#define READ cin >>
#define PRINT cout <<
#define PYES cout << "YES" << endl
#define pyes cout << "Yes" << endl
#define POK cout << "OK" << endl
#define PNO cout << "NO" << endl
#define pno cout << "No" << endl
#define PNG cout << "NG" << endl
#define ret return 0

using namespace std;

// デバッグ用
void debug_out() { cout << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cout << H << " ";
  debug_out(T...);
}

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

#ifdef _DEBUG
#define debug(...) debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif

// typedef
typedef long long ll;
typedef unsigned long long ul;
typedef long double ld;
typedef pair<ll, ll> pl;

// const
// 円周率
const ld pi = acos(-1);
// mod用
// 1E+9 +7
const ll mod = (int)1e+9 + 7;
// 1s間で可能なループ回数2E+8回
// int        最大値2147483647         〜2E+9
// long long  最大値9223372036854775807〜9E+18
// 総和accumulate
// 単純リストvector<type> push_back
// 連想配列map<key,value> insert,
// 集合set<type>
// pair キーとバリューを格納 firstとsecondでアクセス
// 小数点指定 cout << fixed << setprecision(15) << endl;
// to_string<->stoi
// stoll(longlong)
// stod(double)
// deep copy v1->v2 copy(v1.begin(), v1.end(), back_inserter(v2) );
// 大文字65-90(-32)
// 小文字97-122(+32)
//  priority_queue<pair<ll, ll>, vector<pair<ll, ll>>, greater<pair<ll, ll>>>
//  ba;
signed main() {
  // faster
  // C言語流の入出力は使用できない
  ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  string s, t;
  cin >> s >> t;
  int ssize = SIZE(s), tsize = SIZE(t);
  // if (ssize > tsize) {
  //   swap(s, t);
  //   swap(ssize, tsize);
  // }
  vector<vector<int>> dp(ssize + 1, vector<int>(tsize + 1, 0));
  repz(is, 1, ssize + 1) {
    repz(it, 1, tsize + 1) {
      if (s[is - 1] == t[it - 1]) chmax(dp[is][it], dp[is - 1][it - 1] + 1);
      chmax(dp[is][it], dp[is - 1][it]);
      chmax(dp[is][it], dp[is][it - 1]);
    }
  }
  int is = ssize, it = tsize;
  vector<char> res;
  while (is > 0 and it > 0) {
    if (dp[is][it] == dp[is - 1][it]) {
      is--;
    } else if (dp[is][it] == dp[is][it - 1]) {
      it--;
    } else {
      is--;
      it--;
      res.push_back(s[is]);
    }
  }
  reverse(ALL(res));
  for (char i : res) cout << i;
  cout << endl;
  ret;
}


Measured memory_bytes: 38508
H,W=map(int,input().split())
a=[[False for j in range(W+2)] for i in range(H+2)]

for i in range(1,H+1):
    si=input()
    for j in range(1,W+1):
        a[i][j]=si[j-1]=='#'

f=True
fEND=False
for i in range(1,H+1):
    if fEND:
        break
    for j in range(1,W+1):
        if a[i][j] and not (a[i-1][j] or a[i+1][j] or a[i][j-1] or a[i][j+1]):
            f=False
            fEND=True
            break

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

Measured memory_bytes: 39536
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=(a);i<(b);++i)
#define rrep(i,a,b) for(int i=(a);i>=(b);--i)
#define fore(i,a) for(auto& i:a)
#define all(a) (a).begin(),(a).end()
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
using ll = long long; constexpr int inf = INT_MAX / 2; constexpr ll infl = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }

vector<bool> solve(int N, int A, int B, string S) {
  int cnt_a = 0;
  int cnt_b = 0;
  vector<bool> ans(N);

  rep(i, 0, N) {
    if (S[i] == 'c') {
      ans[i] = false;
      continue;
    }
    if (A + B <= cnt_a + cnt_b) {
      ans[i] = false;
      continue;
    }
    if (S[i] == 'a') {
      ++cnt_a;
      ans[i] = true;
      continue;
    }
    if (cnt_b < B) {
      ++cnt_b;
      ans[i] = true;
    }
    else ans[i] = false;
  }

  return ans;
}

void _main() {
  int N, A, B;
  string S;
  cin >> N >> A >> B >> S;
  int a[N];
  rep(i, 0, N) cin >> a[i];

  vector<bool> ans = solve(N, A, B, S);
  rep(i, 0, N) {
    if (ans[i]) cout << "Yes" << endl;
    else cout << "No" << endl;
  }
}

Measured memory_bytes: 976
#include <bits/stdc++.h>  // g++ -std=c++14 -o a a.cpp

using namespace std;

typedef pair<int, int> P;
typedef long long ll;

#define rep(i, n) for(int i = 0; i < (n); i++)
#define repto(i, n) for(int i = 0; i <= (n); i++)
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end())
#define _1 first
#define _2 second
#define pb push_back
#define INF 1145141919
#define MOD 1000000007
#define DEBUG(x) cout << #x << ": " << x << endl;

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

__attribute__((constructor)) void initial() {
    cin.tie(0);
    ios::sync_with_stdio(false);
}

const double PI = 3.141592;

int main() {
    double R;
    double two = 2;
    cin >> R;
    cout << (R * PI * two) << endl;
}


Measured memory_bytes: 3756
#include <iostream>

using namespace std;

int N;
int h[105];

int main(void) {
	cin >> N;

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

	int ans = 0;

	for (int j = 1; j <= 100; j++) {
		int flag = 0;
		for (int i = 1; i <= N + 1; i++) {
			if ((flag == 0) && (h[i] >= j) && (h[i] < j)) { flag = 1; }
			else if ((h[i] < j) && h[i - 1] >= j) { ans++; flag = 0; }
			else { flag++; }
		}
		//cout << "j= " << j << " ans= " << ans << endl;
	}

	cout << ans << endl;
	//system("pause");
	return 0;
}

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

int main() {
    
	int i,x,j,n,a,b,c;
	cin>>n;
	vector<int> dp;
	for(i=0;i<3;i++)
	{
	    cin>>x;
	    dp.push_back(x);
	}
	for(j=1;j<n;j++)
	{
	    vector<int> m(3,0);
	    cin>>a>>b>>c;
	    m[0]=max(a+dp[1],a+dp[2]);
	    m[1]=max(b+dp[0],b+dp[2]);
	    m[2]=max(c+dp[0],c+dp[1]);
	    dp=m;
	}
	int ans=*max_element(dp.begin(),dp.end());
	cout<<ans<<"\n";

	return 0;
}

Measured memory_bytes: 256
n=int(input())
A=list(map(int,input().split()))

mod=10**9+7
ans=1
cs=[0]*3
for a in A:
  c=cs.count(a)
  if c==0:
    print(0)
    exit()
  ans=(ans*c)%mod
  i=cs.index(a)
  cs[i]+=1
print(ans)

Measured memory_bytes: 13964
import java.util.Scanner;

class Main{
	public static void main(String[] args){
		Scanner scanner = new Scanner(System.in);
		for(int i = 1; i <= 3000; i ++){
			int x = scanner.nextInt();
			int y = scanner.nextInt();
			if(x == 0 && y == 0){
				break;
			}else if(x > y){
				System.out.println(y + " " + x);
			}else if(x <= y){
				System.out.println(x + " " + y);
			}
		}
		
	}
}

Measured memory_bytes: 35800
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Scanner;
import java.util.StringTokenizer;

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
/**
 *
 * @author Adly
 */
public class Main {

    static int t;
    static int[][] dp;
    static int[][] a;

    public static int re(int d, int i) {
        if (d > 0) {
            if (dp[d][i] != -1) {
                return dp[d][i];
            } else {
                int tmp = 0;
                for (int act = i; act < 3; act++) {
                    //System.out.println(d+"  "+act);
                    switch (act) {
                        case 0: tmp = Math.max(re(d - 1, 1), re(d - 1, 2)) + a[d][act];
                            break;
                        case 1: tmp = Math.max(re(d - 1, 0), re(d - 1, 2)) + a[d][act];
                            break;
                        case 2: tmp = Math.max(re(d - 1, 0), re(d - 1, 1)) + a[d][act];
                            break;
                        default: break;
                    }
                    dp[d][act] = Math.max(dp[d][act], tmp);
                }
                return dp[d][i];
            }
        }
        return a[d][i];//base case
    }

    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter out = new PrintWriter(System.out);
        StringTokenizer st = new StringTokenizer(br.readLine());
        t = Integer.parseInt(st.nextToken());
        a = new int[t][3];
        dp = new int[t][3];
        for (int i = 0; i < t; i++) {
            st = new StringTokenizer(br.readLine());
            for (int j = 0; j < 3; j++) {
                a[i][j] = Integer.parseInt(st.nextToken());
                dp[i][j] = -1;
            }
        }
        re(t - 1, 0);
        int max = -1;
        for (int i = 0; i < 3; i++) {
            max = Math.max(max, dp[t - 1][i]);
        }
        if (max==-1){
            for (int i = 0; i < 3; i++) {
                max=Math.max(a[t-1][i],max);
            }
        }
        out.println(max);
        //out.println(re(t - 1, 0));
        out.flush();
    }
}
/*
10
0 0 0 0 0 0 0 0 123 23
 */


Measured memory_bytes: 62924
#include <bits/stdc++.h>
#include <cassert>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
struct Edge
{
  int to;
  int weight;
  Edge(int t, int w) : to(t), weight(w) {}
};
using Graph = vector<vector<Edge>>;
// using Graph = vector<vector<int>>;

const long long INF = 1LL << 60;
const int INT_INF = 1000000000;

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

vector<pair<long long, int>> factorize(long long N)
{
  vector<pair<long long, int>> res;
  for (long long i = 2; i * i <= N; i++)
  {
    if (N % i != 0)
      continue;
    res.emplace_back(i, 0);
    while (N % i == 0)
    {
      N /= i;
      res.back().second++;
    }
  }
  if (N != 1)
    res.emplace_back(N, 1);
  return res;
}

const int mod = 1000000007;
struct mint
{
  ll x; // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint &operator+=(const mint a)
  {
    if ((x += a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator-=(const mint a)
  {
    if ((x += mod - a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator*=(const mint a)
  {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const { return mint(*this) += a; }
  mint operator-(const mint a) const { return mint(*this) -= a; }
  mint operator*(const mint a) const { return mint(*this) *= a; }
  mint pow(ll t) const
  {
    if (!t)
      return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1)
      a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod - 2); }
  mint &operator/=(const mint a) { return *this *= a.inv(); }
  mint operator/(const mint a) const { return mint(*this) /= a; }
};
istream &operator>>(istream &is, const mint &a) { return is >> a.x; }
ostream &operator<<(ostream &os, const mint &a) { return os << a.x; }

struct combination
{
  vector<mint> fact, ifact;
  combination(int n) : fact(n + 1), ifact(n + 1)
  {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i)
      fact[i] = fact[i - 1] * i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i)
      ifact[i - 1] = ifact[i] * i;
  }
  mint operator()(int n, int k)
  {
    if (k < 0 || k > n)
      return 0;
    return fact[n] * ifact[k] * ifact[n - k];
  }
  mint p(int n, int k)
  {
    return fact[n] * ifact[n - k];
  }
} c(1000005);

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int N;
  ll M;
  cin >> N >> M;
  vector<pair<ll, int>> factor = factorize(M);
  mint ans = 1;
  for (int i = 0; i < factor.size(); i++)
  {
    ans *= c(factor[i].second + N - 1, factor[i].second);
  }
  cout << ans << endl;
  return 0;
}


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

int N;
int p[50];

int main() {
    cin >> N;
    rep(i, N) cin >> p[i];

    int p_sort[50];
    copy(p, p + N, p_sort);
    sort(p_sort, p_sort + N);

    // 2個以上違っていたらアウト
    int wrong = 0;
    rep(i, N) {
        if (p[i] != p_sort[i]) wrong++;
    }

    cout << (wrong == 2 || wrong == 0 ? "YES" : "NO") << endl;
}

Measured memory_bytes: 256
/*
ID: anonymo14
TASK: wormhole
LANG: C++                 
*/
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<pair<int,int>> vpii;

#define F first
#define S second
#define PU push
#define PUF push_front
#define PUB push_back
#define PO pop
#define POF pop_front
#define POB pop_back

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

#define MOD 1000000007

bool cmp(pair<int,int> &a,pair<int,int> &b){
	return a.F<b.F;
}

void solve(int test_case) {//234 Coloring Colorfully
	int a,b;
	cin>>a>>b;
	int cnt=0,now= 1;
	while(now<b) {
		now+=a-1;
		cnt++;
	}
	cout<<cnt;
}

int main() {
	
	////// FILE BASED IO////
	//freopen("wormhole.in", "r", stdin);
	//freopen("wormhole.out", "w", stdout);
	///////////////
	
	ios::sync_with_stdio(0);
	cin.tie(0);
	int t=1;
	//cin>>t;
	REP(i,1,t) {
		solve(i);
	}
	return 0;
}	


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

using namespace std;
#define mp make_pair
#define pb push_back
#define all(x) x.begin(), x.end()
#define fi first
#define se second
#define inf 1000000000
#define sz(x) (ll)x.size()
#define boost ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
typedef long long ll;
typedef unsigned long long ull;
typedef  double ld;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef pair< int , pii> piii;
typedef pair<int,bool> pib;
typedef vector<pii> vii;
typedef vector<pib> vib;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef pair<string,string> pss;
typedef vector<pss> vss;
typedef pair<ld , ld> pdd;
typedef vector<pdd> vdd;
typedef vector<ld> vd;
const int MOD = 1e9 + 7; //998244353;
int dp[100005];
int main() {
    boost;
    int n , k;
    cin >> n >> k;
    vi a(n);
    for(int &i : a)cin >> i;
    for(int i = 0;i<=n;i++)dp[i] = inf;
    dp[0] = 0;
    for(int i = 1;i<n;i++){
        for(int j = 1;j<=k;j++){
            if(i-j < 0)break;
            dp[i] = min(dp[i] , dp[i-j] + abs(a[i] - a[i-j]));
        }
    }
    cout << dp[n-1];
}


Measured memory_bytes: 3992
#include <iostream>
#include <unordered_map>
#include <vector>
#include <set>
#include <string.h>
#include <algorithm>
#define mod 1000000007
#define ll long long
#define pr pair<int,int>
#define all vec.begin(),vec.end()
#define REP(i,a,b) for (int i = a; i < b; i++)
#define fi first
#define se second
#define pushb push_back
#define makep make_pair

using namespace std;

int main(){
	string a,b,c;
	cin >> a >> b >> c;
	string out = (a[a.size() - 1] == b[0] && b[b.size() - 1] == c[0]) ? "YES" : "NO";
	cout << out; 
	return 0;
}



Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[]args) {
		try(Scanner scan = new Scanner(System.in)){
			long mod = 1000000000+7;

			long goukei = 0;


			int N = scan.nextInt();
			long[]A = new long[N];
			long[]S = new long [N+1];
			long[]p = new long[N+1];
			for(int i = 0;i<N;i++) {
				A[i] = scan.nextLong();
				S[i+1] = S[i]+A[i];
			}

			for(int i = N-1;i>0;i--) {
				p[i] = (p[i+1]+A[i])%mod;
			}


			for(int i = 0;i<N-1;i++) {
				goukei=(goukei+(A[i]*p[i+1])%mod)%mod;
			}

			System.out.println(goukei);


		}


	}


}


Measured memory_bytes: 63928
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;

int main()
{
	int N, M;
	cin >> N >> M;

	int tmp;
	int cnt = 0;
	for (int i = 0; i < M; i++) {
		cin >> tmp;
		cnt += tmp;
	}
	if (cnt > N)
		cout << "-1" << endl;
	else
		cout << N - cnt << endl;

}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
int n,m,e,node[301],ans;
bool edge[301][301],used[301];
bool find(int x){
    for (int j=1;j<=n;j++){
    if (edge[x][j]&&!used[j]){
    used[j]=1;
    if (node[j]==0||find(node[j])){
    node[j]=x;return 1;}}}
    return 0;
}
int main() {
	ios::sync_with_stdio(false);
	cin>>n; 
    int ax[101],ay[101],bx[101],by[101];
	for (int i=1;i<=n;i++){
		cin>>ax[i]>>ay[i];
	}
	for (int j=1;j<=n;j++){
		cin>>bx[j]>>by[j];
	}
	for (int i=1;i<=n;i++){
		for (int j=1;j<=n;j++)
		if (ax[i]<bx[j]&&ay[i]<by[j])
		edge[i][j]=1;
	}
    for (int i=1;i<=n;i++){
        memset(used,0,sizeof(used));
        find(i);}
    for (int i=1;i<=n;i++)
    if (node[i]>0) ans++;
    cout<<ans;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<algorithm>
#define MaxN 200000+100
using namespace std;
typedef long long LL;
LL a[MaxN];
LL b[MaxN];

int main()
{
    int N;
    scanf("%d",&N);
    for(int i=1;i<=N;i++)
    {
        scanf("%lld",&a[i]);
        b[i]=a[i]-i;
    }
    sort(b+1,b+1+N);
    LL c=b[(N+1)/2];
    LL sum=0;
    for(int i=1;i<=N;i++)
        sum+=abs(a[i]-i-c);
    printf("%lld\n",sum);
    return 0;
}


Measured memory_bytes: 3328
#include<iostream>
#include<bits/stdc++.h>
#include<array>
using namespace std;
#define int long long
#define fast_cin ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define endl "\n"
#define endl "\n"
#define with_tests int t; cin >> t; while(t--){ solve(); cout << endl; }
#define without_tests solve(); cout << endl;
#define CEIL(x, y) (ll)ceil((long double)(x)/(long double)(y))
#define epsilon 1e-9 
typedef long long ll;
const int mod = 1e9+7;
const int N = 1e6+1;

int a[N], primes[N], pp[N];
int n, m, u, v;
vector<int> p;

bool pair1(){

    for(int i=0; i<n; i++){
        for(int pi: p){
            if(pi*pi > a[i]){
                break;
            }
            if(a[i]%pi == 0){
                int sec = a[i]/pi;
                if(pp[sec] == 0 && primes[sec] == 1){
                    return false;
                }
                if(primes[pi] == 1){
                    return false;
                }
                primes[pi] = 1;
                if(pp[sec] == 0){
                    primes[sec] = 1;
                }
            }
        }
        if(pp[a[i]] == 0 && primes[a[i]] == 1){
            return false;
        }
        if(pp[a[i]] == 0){
            primes[a[i]] = 1;
        }
    }
    return true;
}

bool set1(){

    vector<int> final;
    for(int i=0; i<n; i++){
        for(int pi: p){
            if(pi > a[i]){
                break;
            }
            if(a[i]%pi == 0){
                // int sec = a[i]/pi;
                // if(pi != sec && pp[sec] == 0){
                //     final.push_back(sec);
                // }
                final.push_back(pi);
            }
        }
        // if(pp[a[i]] == 0){
        //     final.push_back(a[i]);
        // }
        // for(int fi: final){
        //     cout << fi << " ";
        // }
        // cout << endl;
        if(final.size() == 0){
            return true;
        }
        p = final;
        // cout << p.size() << endl;
        final.clear();
    }
    return false;
}


void solve(){
    pp[1] = 1;
    for(int i=2; i<N; i++){
        if(pp[i] == 0){
            p.push_back(i);
            for(int j=i*2; j<N; j+=i){
                pp[j] = 1;
            }
        }
    }
    cin >> n;
    for(int i=0; i<n; i++){
        cin >> a[i];
    }
    if(pair1()){
        cout << "pairwise coprime";
    }
    else if(set1()){
        cout << "setwise coprime";
    }
    else{
        cout << "not coprime";
    }

}

int32_t main(){

    fast_cin;
    // with_tests;
    without_tests;

    return 0;
}


Measured memory_bytes: 20204
import java.util.*;

public class Main {
	
       public static void main(String[] args) {
    	  Scanner in=new Scanner( System.in)	;
          long n=in.nextLong(),m=in.nextLong(),k=in.nextLong();
          HashMap<pointt,Long> map=new HashMap<pointt,Long>();
          //TreeMap<pointt,Long> map=new TreeMap<pointt,Long>();
          for(int i=1;i<=k;i++)
          {
        	 int a=in.nextInt();
        	 int b=in.nextInt();
        	 for(int x=Math.max(1, a-2);x<=Math.min(n-2, a);x++)
        		 for(int y=Math.max(1, b-2);y<=Math.min(m-2, b);y++)
        		 {
        			 pointt p=new pointt(x, y);
                	 Long v=map.get(p);
                	// System.out.println(v);
                	 if(v==null)
                	 {
                		 v=(long) 1;
                	 }
                	 else v++;
                	 
                	
                	 map.put(p, v);
                	// System.out.println(x+"  "+y);
        		 }
          }
          long[] ans=new long[15];
          ans[0]=(n-2)*(m-2);
          
          for(long value:map.values())
          {
        	  ans[(int) value]++;
              ans[0]--;  
          }
          for(int i=0;i<=9;i++)
          {
        	  System.out.println(ans[i]);
          }
	}
}
class pointt {
    int x,y;

	public pointt(int x, int y) {
		super();
		this.x = x;
		this.y = y;
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + x;
		result = prime * result + y;
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		pointt other = (pointt) obj;
		if (x != other.x)
			return false;
		if (y != other.y)
			return false;
		return true;
	}
	 public int compareTo(pointt p) {
		    if (this.x != p.x) {
		      return this.x - p.x;
		    }
		    return this.y - p.y;
		  }
	
	
	
}


Measured memory_bytes: 165680
<?php

fscanf(STDIN, "%d", $n);
const C = 998244353;

$data = explode(" ", trim(fgets(STDIN)));

if($data[0] != 0){
    echo "0";
    exit;
}
$max = 0;
foreach($data as $no=>$value){
    if($value == 0 && $no != 0){
        echo "0";
        exit;
    }
    @$map[$value]++;
    $max = max($max,$value);
}
$ans = 1;
for($i=1;$i<=$max;$i++){
    if(!isset($map[$i])){
        echo "0";
        exit;
    }
    $ans = $ans * (mod($map[$i-1], $map[$i])) % C;

}
echo $ans;

function mod($a,$n){
    $k = 1;
    $ans = $a;
    while($k*2 < $n){
        $ans = ($ans * $ans) % C;
        $k = $k*2;
    }
    for($i=$k;$i<$n;$i++){
        $ans = ($ans*$a) % C;
    }
    return($ans);
}

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

typedef long lint;
typedef long long llint;
typedef pair<int, int> pint;
typedef pair<long long, long long> pllint;

// static const int MAX = 1e6;
// static const int NIL = -1;
// static const llint INF = 1<<21;
// static const llint MOD = 1e9 + 7;

bool compPair(const pint& arg1, const pint& arg2) { return arg1.first > arg2.first; }
template<class T> void chmax(T& a, T b) { if (a < b) { a = b; } }
template<class T> void chmin(T& a, T b) { if (a > b) { a = b; } }

int main(void) {
    int a, b;
    cin >> a >> b;

    cout << (a+b) % 24 << endl;
    return 0;
}


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

int max_score(int N, int K, int R, int S, int P, string &T) {
    int sum = 0;
    vector<bool> win(N, false);
    for (int i = 0; i < K; i++) {
        if (T.at(i) == 'r') {
            sum += P;
        } else if (T.at(i) == 's') {
            sum += R;
        } else {
            sum += S;
        }
        win[i] = true;
    }

    for (int i = K; i < N; i++) {
       if (T.at(i) == 'r') {
           if (T.at(i - K) == 'r' && win[i - K]) {
               continue;
           }
           sum += P;
           win[i] = true;
       }
       if (T.at(i) == 's') {
           if (T.at(i - K) == 's' && win[i - K]) {
               continue;
           }
           sum += R;
           win[i] = true;
       }
       if (T.at(i) == 'p') {
           if (T.at(i - K) == 'p' && win[i - K]) {
               continue;
           }
           sum += S;
           win[i] = true;
       }
    }

    return sum;
}

int main() {
    int N, K, R, S, P;
    string T;
    cin >> N >> K >> R >> S >> P >> T;

    int ans = max_score(N, K, R, S, P, T);

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(long long i=0;i<x;i++)
#define repn(i,x) for(long long i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
vector<pair<string,P> >vec;
// vector<vector<int>> data(3, vector<int>(4));

priority_queue<ll> que[100001];
vector<ll> dp(100001, -1);

ll solve(long long n){
	if (dp[n] != -1) return dp[n];
	if (que[n].empty()) return dp[n] = 0;
	// cout << que[n].top() << " ";
	priority_queue<ll> quel;
	while (!que[n].empty()) {
		quel.push(solve(que[n].top()));
		que[n].pop();
	}
	ll res = 0, c = 1;
	while (!quel.empty()) {
		// cout << quel.top() << " ";
		res = max(res, quel.top()+c);
		// cout << solve(quel.top()) << endl;
		quel.pop();
		c++;
	}
	// cout << endl;
	return dp[n] = res;
}

int main(){	
	long long N;
	scanf("%lld",&N);
	vector<long long> a(N-2+1);
	for(int i = 0 ; i <= N-2 ; i++){
		scanf("%lld",&a[i]);
		a[i]--;
		que[a[i]].push(i+1);
	}
	// rep(i, N) {
	// 	cout << i << ": ";
	// 	while(!que[i].empty()) {
	// 		cout << que[i].top() << " ";
	// 		que[i].pop();
	// 	}
	// 	cout << endl;
	// }
	cout << solve(0) << endl;
	return 0;
}



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

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

            if (ABC[0] <= ABC[2] && ABC[2] <= ABC[1])
            {
                Console.WriteLine("Yes");
            }
            else if(ABC[1] <= ABC[2] && ABC[2] <= ABC[0])
            {
                Console.WriteLine("Yes");
            }
            else Console.WriteLine("No");

            Console.ReadKey();
        }
    }
}


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

using namespace std;

#define MX 35
#define MOD 1'000'000'007
#define F first
#define S second
#define br '\n'

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;

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

	int n;
	cin >> n;
	vi cnt(n+1);
	int a;
	for(int i=1; i<n; i++)
	{
		cin >> a;
		cnt[a]++;
	}
	for(int i=1; i<=n; i++)
	{
		cout << cnt[i] << '\n';
	}

	return 0;
}


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

int main()
{
  int a , b ,c ;
  cin>>a>>b>>c;
  if(c>a && c>b)
  {
    cout<<"No"<<endl;}
     else if (c<a && c<b)
     {
       
       cout<<"No"<<endl;}
    else
    {
      cout<<"Yes"<<endl;}
    return 0;
  }
  

Measured memory_bytes: 256
import java.util.*;

public class Main {

	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt(), b = sc.nextInt();
		sc.close();
		int ans = 0;
		int tmpa = ((a + 1) * 100) / 8;
		if(((a + 1) * 100) % 8 == 0)tmpa--;
		int tmpb = ((b + 1) * 100) / 10;
		tmpb--;
		int tmpbb = (b * 100) / 10;
		int tmpaa = (a * 100) / 8;
		if((a * 100) % 8 != 0)tmpaa++;
		ans = Math.max(tmpbb, tmpaa);
		if(tmpbb > tmpa || tmpaa > tmpb)ans = -1;
		// System.out.println(tmpaa + " <= x < "  + tmpa + " and " + tmpbb + " <= x < " + tmpb);
		System.out.println(ans);
	}
}


Measured memory_bytes: 25044
#include <stdio.h>

int main(void){
    int h = 0;
    int n = 0;

    scanf("%d %d",&h, &n);

    for(int i = 0; i < n; i++){
        int a;
        scanf("%d", &a);
        h = h - a;
    }

    if(h <= 0){
        puts("Yes");    
    }else {
        puts("No");
    }
    return 0;
}

Measured memory_bytes: 128
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (n); i++)
#define REPS(i, a, b) for (int i = (a); i < (b); i++)
using namespace std;
using ll = long long int;

int main() {
  int n,W;
  cin >> n >> W;
  int v[n+100],w[n+100];
  REP(i,n) cin >> w[i] >> v[i];
  
  ll dp[n+1][W+1];
  REP(i,n+1){
    REP(j,W+1){
      dp[i][j] = 0;
    }
  }
  
  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;
 
  
}


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

using namespace std;
using ll = long long;

const int MAX = 1e6;
const int MOD = 1e9 + 7;

int mult(int a, int b) {
    return (a * 1ll * b) % MOD; 
}          

int binpow(int a) {
    int res = 1;
    int b = MOD - 2;
    while (b) {
        if (b & 1)
            res = mult(res, a);
        a = mult(a, a);
        b >>= 1;
    }
    return res;
}

int f[MAX * 3];

int calc() {
    f[0] = 1;
    for (int i = 1; i <= MAX*2; ++i) 
        f[i] = mult(f[i-1], i);
}

int c(int n, int k) {
    return mult(f[n], binpow(mult(f[k], f[n-k])));
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int x, y;
    cin >> x >> y;
    if ((x + y) % 3)
        cout << 0, exit(0);
    int m = -1, n = -1;
    for (int i = 0; i <= MAX; ++i) {
        m = x - 2 * i; 
        if (2 * m + i == y) {
            n = i;
            break;
        }            
    }                
    if (m < 0 || n < 0)
        cout << 0, exit(0);
    calc();
    cout << c(n+m, m);
    return 0;
}                                                               
    
                

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

#define mp make_pair
#define pb push_back


typedef long long ll;
typedef long long llong;
typedef long double ld;
typedef unsigned long long ull;

using namespace std;

template <typename T> void dprint(T begin, T end) {
    for (auto i = begin; i != end; i++) {
        cerr << (*i) << " ";
    }
    cerr << "\n";
}
const int MAXN = 120000;

vector<int> ea[MAXN];
vector<int> eb[MAXN];
vector<int> eds[MAXN];
int cl[MAXN];
int was[MAXN];

void add_edge(int a, int b) {
    eds[a].push_back(b);
    eds[b].push_back(a);
}

int dfs1(int v) {
    for (int i = 0; i + 1 < ea[v].size(); i += 2)
        add_edge(dfs1(ea[v][i]), dfs1(ea[v][i + 1]));
    if (ea[v].size() % 2 == 0)
        return v;
    else
        return dfs1(ea[v].back());
}

int dfs2(int v) {
    for (int i = 0; i + 1 < eb[v].size(); i += 2)
        add_edge(dfs2(eb[v][i]), dfs2(eb[v][i + 1]));
    if (eb[v].size() % 2 == 0)
        return v;
    else
        return dfs2(eb[v].back());
}

void dfs3(int v, int c) {
    was[v] = 1;
    cl[v] = c;
    for (int u: eds[v]) {
        if (was[u])
            continue;
        dfs3(u, c ^ 1);
    }
}

int n;

int main() {
    scanf("%d", &n);
    int ra = -1, rb = -1;
    for (int i = 0; i < n; ++i) {
        int p;
        scanf("%d", &p);
        --p;
        if (p == -2)
            ra = i;
        else
            ea[p].push_back(i);
    }
    for (int i = 0; i < n; ++i) {
        int p;
        scanf("%d", &p);
        --p;
        if (p == -2)
            rb = i;
        else
            eb[p].push_back(i);
    }
    for (int i = 0; i < n; ++i) {
        if (ea[i].size() % 2 != eb[i].size() % 2) {
            cout << "IMPOSSIBLE\n";
            return 0;
        }
    }
    dfs1(ra);
    dfs2(rb);
    printf("POSSIBLE\n");
    for (int i = 0; i < n; ++i) {
        if (!was[i]) {
            dfs3(i, 0);
        }
    }
    for (int i = 0; i < n; ++i) {
        if (ea[i].size() % 2 == 1) {
            printf("0 ");
        }
        else {
            if (cl[i] == 0)
                printf("-1 ");
            else
                printf("1 ");
        }
    }
    printf("\n");
    return 0;
}




Measured memory_bytes: 18304
import java.util.*;
import java.io.*;
import java.math.*;
public class Main
{
    public static void main(String args[])throws Exception
    {
        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
        PrintWriter pw=new PrintWriter(System.out);
        int n=Integer.parseInt(br.readLine());
        String str[]=br.readLine().split(" ");
        //int n=Integer.parseInt(str[0]);
        //int k=Integer.parseInt(str[1]);
        int arr[]=new int[n];
        for(int i=0;i<n;i++)
        arr[i]=Integer.parseInt(str[i]);
        //str=br.readLine().split(" ");
        long money=1000;
        for(int i=0;i<n-1;i++)
        {
            if(arr[i+1]>arr[i])
            {
                long numofstock=money/arr[i];
                money=money%arr[i];
                money+=numofstock*arr[i+1];
            }
        }
        pw.println(money);
        pw.flush();
        pw.close();
    }
}

Measured memory_bytes: 32740
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<string>
#include<sstream>
#include<cmath>
#include<numeric>
#include<map>
using namespace std;

void show(vector<int> a){
  for(int i=0; i<a.size()-1; i++){
    cout << a[i] << " ";
  }
  cout << a[a.size()-1] << endl;
}

vector<int> isort(vector<int> a, int n){
  int v = 0;
  int j;
  show(a);
  for(int i=1; i<n; i++){
    v = a[i];
    j = i-1;
    while(j >= 0 && a[j] > v){
      a[j+1] = a[j];
      j--;
    }
    a[j+1] = v;
    show(a);
  }
  return a;
}

int main(void) {
  int n;
  cin >> n;
  vector<int> a(n);
  for(int i=0; i<n; i++) cin >> a[i];
  isort(a, n);

  return 0;
}

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

#define ff first
#define ss second
#define mp make_pair

using namespace std;

typedef long long ll;

int main() {
    int n, k;
    int ans = 0;
    int a;

    scanf("%d%d", &n, &k);

    while(n--) {
    	scanf("%d", &a);
    	if(a >= k) ans++;
    }

    printf("%d\n", ans);
    return 0;
}


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

int n, k;
double ans;

double expo(double b, int e){
	if(e == 0)
		return 1.0;
	double tmp = expo(b, e/2);
	if(e%2 == 0)
		return tmp*tmp;
	return tmp*tmp*b;
}

double getChance(int init){
	int minHead = 0;
	while(init < k){
		minHead++;
		init <<= 1;
	}
	return expo(0.5, minHead);
}

int main(){
	scanf("%d %d", &n, &k);
	for(int i = 1; i <= n; ++i){
		ans += getChance(i);
	}
	ans = ans/((double)n);
	printf("%.15lf", ans);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
  long long int n;
  cin>>n;
  int a[n];
  long long int res=0;
  unordered_map<long long int,long long int>m;
  for(int i=0;i<n;i++)
  {
    cin>>a[i];
    res+=a[i];
    m[a[i]]++;
  }
  long long int q;
  cin>>q;
  long long int temp=res;
  for(int i=0;i<q;i++)
  {
    long long int b,c;
    cin>>b;
    cin>>c;
    if(m[b]!=0)
    {
        temp=temp-(m[b]*b);
        temp=temp+(c*m[b]);
        m[c]+=m[b];
        m[b]=0;
    }
    cout<<temp<<endl;
  }
}

Measured memory_bytes: 7284
#include <algorithm>
#include <iterator>
#include <iostream>
#include <sstream>
#include <bitset>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <list>
#include <map>
#include <set>
#include <time.h>
#include <limits>
#include <math.h>
#include <climits>
#include <numeric>
#include <utility>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>
#include <functional>
#include<unordered_map>

using namespace std;
const double pi=acos(-1.0);
//memset ( a , 0 , n * sizeof(ll) ) ;

#define 	boost  		ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0); // don't use if small inpts
#define 	endl 		'\n'
#define 	sl(n) 		scanf("%lld",&n)
#define		mp 			make_pair
#define 	pb 			push_back
#define 	ppb 		pop_back
#define 	fi 			first
#define 	se 			second
#define 	ll 			long long
#define 	ull 		unsigned long long
#define 	pii 		pair<int, int>
#define 	f(i,a,b) 	for(ll i = (ll)(a); i < (ll)(b); i++)
#define 	rf(i,a,b) 	for(ll i = (ll)(a); i > (ll)(b); i--)
#define 	ms(a,b) 	memset((a),(b),sizeof(a))
#define 	max(a,b) 	((a>b)?(a):(b))
#define 	min(a,b) 	((a<b)?(a):(b))
#define 	vec(g1) 	int temp;cin>>temp;g1,push_back(temp);
#define 	abs(x) 		((x<0)?(-(x)):(x))
#define 	MAX 		1000005
#define 	inf 		LLONG_MAX
#define 	MIN 		INT_MIN

//typedef
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<PII> VII;
typedef vector<VI> VVI;
typedef map<int,int> MPII;
typedef set<int> SETI;
typedef multiset<int> MSETI;
typedef long int int32;
typedef unsigned long int uint32;
typedef long long int int64;
typedef unsigned long long int  uint64;


int mod = 1e9 + 7 ;
ll gcd(ll a , ll b){return b==0?a:gcd(b,a%b);}
ll powmod(ll a,ll b) {ll res=1;if(a>=mod)a%=mod;for(;b;b>>=1){if(b&1)res=res*a;if(res>=mod)res%=mod;a=a*a;if(a>=mod)a%=mod;}return res;}
// ll fac[200005];
// ll inverse(ll n){return powmod(n, mod-2);}
// ll nCr(ll n, ll r){return (fac[n] * inverse(fac[r]) % mod * inverse(fac[n-r]) % mod) % mod;}
////****************************************************************************************************************************************************************************************************************////

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

}

Measured memory_bytes: 256
#include <string>
#include <iostream>
using namespace std;
int n; string s;
int main() {
	cin >> n;
	for(int i = 0; i < n; i++) {
		cin >> s;
		string t = s.substr(0, 1); int pos = 0;
		for(int i = 3; i < s.size(); i += 3) {
			if(s[i - 1] == '>') {
				if(pos + 1 == t.size()) t += s[i];
				pos++;
			}
			else {
				if(pos == 0) t = s[i] + t;
				else pos--;
			}
		}
		cout << t << endl;
	}
}

Measured memory_bytes: 3072
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(v) v.begin(),v.end()
#define len(x) (ll)(x).length()
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const int INF=1e9;
const ll INFS=1e18;
const int MOD=INF+7;
const int di[] = {-1,0,1,0};
const int dj[] = {0,-1,0,1};
 
int main() {
  vector<vector<int>> a(3,vector<int>(3));
  rep(i,3)rep(j,3) cin>>a[i][j];
  vector<int> x(3);
  vector<int> y(3);
  x[0]=0;
  rep(i,3) y[i]=a[0][i]-x[0];
  rep(i,3) x[i]=a[i][0]-y[0];
  bool good=true;
  rep(i,3)rep(j,3){
    if(x[i]+y[j]!=a[i][j]){
      good=false;
    }
  }
  if(good){
    cout<<"Yes"<<endl;
    return 0;
  }
  cout<<"No"<<endl;
}

Measured memory_bytes: 3616
#include<bits/stdc++.h>
#define ll long long
//#define pw (ll)pow 
#define MAX 1000005
#define MOD (ll)1e9+7
using namespace std;

int main()	
{
	int n;
	cin >> n;
	int a[4]={0,0,0,0};
	for(int i=0; i<n; i++)	{
		string s;
		cin >> s;
		if(s[0]=='A')	a[0]++;
		if(s[0]=='W')	a[1]++;
		if(s[0]=='T')	a[2]++;
		if(s[0]=='R')	a[3]++;
	}
	printf("AC x %d\n",a[0]);
	printf("WA x %d\n",a[1]);
	printf("TLE x %d\n",a[2]);
	printf("RE x %d\n",a[3]);
	return 0;
}

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

vector<int> to[200005];
vector<int> ans;

void dfs(int v,int p=-1){
    for(int u : to[v]){
        if(u == p) continue;
        ans[u] += ans[v];
        dfs(u,v);
    }
}

int main(){
    int n,q;
    cin >> n >> q;
    rep(i,n-1){
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        to[a].push_back(b);
        to[b].push_back(a);
    }
    ans.resize(n);
    rep(i,q){
        int p,x;
        cin >> p >> x;
        p--;
        ans[p] += x;
    }
    dfs(0);
    rep(i,n){
        cout << ans[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 23552
#include <stdio.h>

int main(void)
{
    int n, max, sum;
    int L[10];


    scanf("%d", &n);

    max = sum = 0;
    for (int i=0; i<n; i++) {
        scanf("%d", &L[i]);

        if (L[i]>max)   max = L[i];
        sum += L[i];
    }

    if (max < sum-max)
        printf("Yes\n");

    else
        printf("No\n");

    return 0;

}

Measured memory_bytes: 128
#include<iostream>
using namespace std;
int main(){
    int n,b,f,r,v;

    int number[4][3][10];
    //初期化
    for(int i=0;i<4;i++){
        for(int j=0;j<3;j++){
            for(int k=0;k<10;k++)
                number[i][j][k]=0;
        }
    }
    //人数処理
    cin>>n;
    while(n){
        cin>>b>>f>>r>>v;
        number[b-1][f-1][r-1]+=v;
        n--;
        
    }

    //出力
    for(int i=0;i<4;i++){
        for(int j=0;j<3;j++){
            for(int k=0;k<10;k++)cout<<" "<<number[i][j][k];
            cout<<"\n";
        }
        if(i<3){
            for(int l=0;l<20;l++)cout<<"#";
        }    
        if(i<3)cout<<"\n";                                     
    }       
    return 0;
}


Measured memory_bytes: 3100
#include<bits/stdc++.h>
using namespace std;
int Grundy(int N, int K) {
  if(N%K==0) return N/K;
  auto d = (N+K-1)/K;
  auto r = N%K;
  auto n = r/d;
  return Grundy(N-max(1,n)*d, K);
}
int main() {
  int N;
  cin >> N;
  int g = 0;
  for(auto i=0; i<N; ++i) {
    int A, K;
    cin >> A >> K;
    g ^= Grundy(A, K);
  }
  cout << (g ? "Takahashi" : "Aoki") << endl;
}


Measured memory_bytes: 256