akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <cassert>
#include <set>
using namespace std;
using ll = long long;
const int INF = 1<<30;
const int MOD = (int)1e9 + 7;
const int MAX_N = (int)1e5 + 5;
#define debug(x) cout << #x << ": " << x << endl
template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2>& p) { os << p.first << " " << p.second; return os; }
template<typename T>
ostream &operator<<(ostream &os, const vector<T> &v) { for(int i = 0; i < (int) v.size(); i++) os << v[i] << (i + 1 != v.size() ? " " : ""); return os; }

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

void dfs(string s, const int &digit, set<string> &ans)
{
    if((int)s.size() > digit) return;
    if(s != "") ans.insert(s);
    dfs(s + '3', digit, ans);
    dfs(s + '5', digit, ans);
    dfs(s + '7', digit, ans);
}

void solve()
{
    int n; cin >> n;
    int digit = get_digit(n);

    set<string> tmp_ans;
    dfs("", digit, tmp_ans);

    set<string> ans;
    for(auto &s : tmp_ans)
    {
        if((int)s.size() < 3 or stoi(s) > n) continue;
        int not_contain = s.find('3') == -1 or s.find('5') == -1 or s.find('7') == -1;
        if(!not_contain) ans.insert(s);
    }

    cout << ans.size() << endl;
}

signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    solve();
    return 0;
}

Measured memory_bytes: 4608
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <cmath>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <iostream>
#include <random>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include <fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
#include <cctype>
#include <bitset>
using namespace std;

using ll = long long;
using vll = vector<long long>;
using pll = pair<long long, long long>;
#define REP(i,n) for(long long i(0);(i)<(n);(i)++)

const long long MOD = 1000000007;


ll extgcd(ll a, ll b, ll &x, ll &y){
    if(b == 0){
        x = 1; y = 0;
        return a;
    }
    ll d = extgcd(b, a % b, y, x);
    y -= (a / b) * x;
    return d;
}

//* calculate a^-1 mod m
ll mod_inverse(ll a, ll m){
    ll x, y;
    extgcd(a, m, x, y);
    return(m + x%m) % m;
}

//* calculate n! % p in O(n)
ll mod_fact_simple(ll n, ll p){
    ll res = 1;
    if(n == 0) return res;
    for(ll i=1; i<= n; i++){
        res *= i;
        res = res % p;
    }
    return res;
}
//* calculate C(n, k)%p in O(n)
ll mod_comb(ll n, ll k, ll p){
    if(n < 0 || k < 0 || n < k) return 0;
    ll a1 = mod_fact_simple(n, p);
    ll a2 = mod_fact_simple(k, p);
    ll a3 = mod_fact_simple(n-k, p);
    return (a1 * mod_inverse(a2 * a3 % p, p)) % p;
}

void solve(long long X, long long Y){
    if((X+Y) % 3 !=0){
        cout << 0 << endl;
        return;
    }
    if(!(2*Y >= X && 2*X >= Y)){
        cout << 0 << endl;
        return;
    }
    ll n = (2*Y-X)/3, m = (2*X-Y)/3, s = (X+Y)/3;
    cout << mod_comb(s, n, MOD)<<endl;
}

int main(){
    long long X;
    scanf("%lld",&X);
    long long Y;
    scanf("%lld",&Y);
    solve(X, Y);
    return 0;
}


Measured memory_bytes: 256
N,A,B = map(int, input().split())

counter = 0
for num in range(1,N+1):
  num = str(num)
  sum = 0
  for j in range(len(num)):
    sum += int(num[j])
  if (sum>=A)&(sum<=B):
    counter += int(num)
print(counter)

Measured memory_bytes: 3060
///cREATED bY BERNARB.01
#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;
typedef tree<int,null_type,less<int>,rb_tree_tag, tree_order_statistics_node_update> indexed_set;
typedef priority_queue<int,vector<int>,greater<int>> pqil;
typedef priority_queue<int> pqig;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef pair<int, pii> piii;
typedef priority_queue<pii> pqiig;
typedef vector<pii> vii;
typedef vector<piii> viii;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
typedef map<int, int> mii;
#define mid ((l+r)/2)
#define PB push_back
#define PP pop_back
#define PF push_front
#define DF pop_front
#define F first
#define S second
#define MP make_pair
#define C continue
#define B break
#define R return
#define sz(v) (int)(v).size()
#define len(s) (int)(s).length()
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define clr(arr, x) memset((arr), (x), sizeof (arr))
#define loop(n) for(ll i=0; i<(n); i++)
#define jloop(n) for(ll j=0; j<(n); j++)
#define rloop(n) for(ll i=(n)-1; i>=0; i--)
#define sgm(y) (((y)*((y)+1))/2)
const ll INF = 2e17+423;
const ll mod = 1e9+7; //998244353;
const ld pi = acos(-1.0);
const ld cmpf = 1e-9;
//__int128_t
//      -ASCII-
//a -> z | A -> Z | 0 -> 9
//97 122 | 65  90 | 48  57
#define endl '\n'
ll po(ll,ll);



















int main() {
  /*#ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
  #endif // ONLINE_JUDGE*/
  ios::sync_with_stdio(0);
  cin.tie(0);
  ll h;
  cin >> h;
  ll hh=h;
  ll ans =0;
  ll c=2;
  while(h>1){
    ans+=c;
    c*=2;
    h/=2;
  }
  cout << ans+1<< endl;
  R 0;
}
/*

*/




























































ll po(ll x, ll n){
  if(n==0) R 1;
  ll y = po(x, n/2);
  y = ((y)*(y));
  if(n%2) y = (y*(x));
  R y;
}


Measured memory_bytes: 256
#include <iostream>
#include <map>
using namespace std;
#define pi 3.14159265

int main()
{
	long long ans = 0, i = 0, j = 0, k = 0, a, b, x;
	cin >> a >> b >> x;

	ans = b / x - a / x;
	if (a%x == 0)ans++;

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<math.h>
using namespace std;
int main()
{
    long long int i,j,n;
    double  k,q,a,b,fc=1,sum=0,player;
    cin>>n;
    double x[n+2],y[n+2];
    for(i=0;i<n;i++)
    {
        cin>>x[i]>>y[i];
    }
    for(i=0;i<n-1;i++)
    {
        for(j=i;j<n;j++)
        {
            a=(x[i]-x[j]);
            b=(y[i]-y[j]);
            q=sqrt((a*a)+(b*b));
            sum+=q;
        }
    }
    sum=sum*2;
//    for(i=1;i<=n;i++)
//    {
//        fc=fc*i;
//    }
    cout<<fixed<<setprecision(10)<<sum/n<<endl;
    return 0;
}
















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

int main()
{
    int n, x;

    while (true) {
        cin >> n >> x;

        if (n == 0 && x == 0) {
            return 0;
        }

        int count = 0;

        for (int i = 1; i <= n; i++) {
            for (int j = i + 1; j <= n; j++) {
                for (int k = j + 1; k <= n; k++) {
                    if (i + j + k == x) {
                        count++;
                    }
                }
            }
        }

        cout << count << endl;
    }
}

Measured memory_bytes: 1164
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0;i < (n);i++)
#define rrep(i,n) for (int i = (n - 1);i >= 0;i--)
#define all(v) v.begin(),v.end()
using namespace std;
using ll = long long;
using P = pair<int,int>;
using vi = vector<int>;
using vvi = vector<vi>;

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

    pair<string,int> s,t;
    cin >> s.first >> t.first >> s.second >> t.second;
    string u;
    cin >> u;
    if(u == s.first) s.second--;
    if(u == t.first) t.second--;
    cout << s.second << " " << t.second << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

typedef long long ll;

#define rep(i, a, b) for (ll i = a; i < (ll)b; ++i)
#define INF 10e12
#define MAX 51000
#define all(x) (x).begin(), (x).end()
#define MX(x) *max_element(all(x))
#define MN(x) *min_element(all(x))

using namespace std;

const long long MOD = 1e9 + 7;

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

    vector<vector<int>> a(3, vector<int>(3));
    rep(i, 0, 3) rep(j, 0, 3) cin >> a[i][j];
    ll n;
    cin >> n;
    set<int> st;
    rep(i, 0, n)
    {
        int tmp;
        cin >> tmp;
        st.insert(tmp);
    }
    rep(i, 0, 3)
    {
        int count = 0;
        rep(j, 0, 3)
        {
            if (find(st.begin(), st.end(), a[i][j]) != st.end())
                count++;
        }
        if (count == 3)
        {
            cout << "Yes" << endl;
            return 0;
        }
        count = 0;
        rep(j, 0, 3)
        {
            if (find(st.begin(), st.end(), a[j][i]) != st.end())
                count++;
        }
        if (count == 3)
        {
            cout << "Yes" << endl;
            return 0;
        }
    }
    int count = 0;
    rep(i, 0, 3)
    {
        if (find(st.begin(), st.end(), a[i][i]) != st.end())
            count++;
    }
    if (count == 3)
    {
        cout << "Yes" << endl;
        return 0;
    }
    count = 0;
    rep(i, 0, 3)
    {
        if (find(st.begin(), st.end(), a[3 - 1 - i][i]) != st.end())
            count++;
    }
    if (count == 3)
    {
        cout << "Yes" << endl;
        return 0;
    }
    cout << "No" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(ll i = 0; i < (ll)n; i++)
#define FOR(i, a, b) for(ll i = (a); i < (ll)b; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF 1000000000000000
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;
typedef pair<ll, ll> p;
constexpr int MOD = 1000000007;
template <class T> inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

void print(const std::vector<int> &v) {
    std::for_each(v.begin(), v.end(), [](int x) { std::cout << x << " "; });
    std::cout << std::endl;
}

int main() {
    string s;
    cin >> s;
    //真ん中の2K-N個数部分はすべて0かすべて1とならないといけない
    int len = s.size();
    if(len % 2 == 1) {
        //奇数個
        // cout << "奇数個" << endl;
        int middle = len / 2;
        int i = 1;
        int cnt = 0;
        while(s[middle] == s[middle - i] and s[middle] == s[middle + i]) {
            i++;
            cnt++;
        }
        cout << (2 * cnt + 1 + len) / 2 << endl;
        return 0;
    } else {
        // cout << "偶数個" << endl;
        if(s[len / 2] != s[len / 2 - 1]) {
            cout << len / 2 << endl;
            return 0;
        } else {
            int i = 1;
            int cnt = 0;
            while(s[len / 2] == s[len / 2 + i] and
                  s[len / 2 - 1] == s[len / 2 - 1 - i]) {
                i++;
                cnt++;
            }
            cout << (2 * cnt + 2 + len) / 2 << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 512
#include <algorithm>
#include <iostream>
#include <stack>
#include <vector>

using namespace std;

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

#define MOD 1000000007
#define REP(i, N) for (int i = 0; i < N; ++i)
#define REP1(i, N) for (int i = 1; i <= N; ++i)
#define RREP(i, N) for (int i = N - 1; i >= 0; --i)
#define ALL(a) a.begin(), a.end()

int main() {
  int n, q;
  cin >> n >> q;
  stack<int> st[n];
  REP(i, q) {
    int num, t;
    cin >> num >> t;
    if (num == 0) {
      int x;
      cin >> x;
      st[t].push(x);
    } else if (num == 1) {
      if (st[t].size()) {
        cout << st[t].top() << endl;
      }
    } else {
      if (st[t].size()) {
        st[t].pop();
      }
    }
  }
  return 0;
}


Measured memory_bytes: 4348
import java.util.*;

class Main {
	public static void main (String[] args){
        Scanner sc = new Scanner(System.in);
        
        int num1 = sc.nextInt();
        
        for(int i = 1;i <= num1;i++){
            if(i % 3 == 0)  System.out.print(" "+i);
            else{
                String s = String.valueOf(i);
                if(s.contains("3")) System.out.print(" "+i);
            }
        }
        System.out.print("\n");
    }
}



Measured memory_bytes: 29476
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n,x;
  cin >> n >> x;
  int k = 10000;
  for (int i = 0; i < n; i++) {
    int m;
    cin >> m;
    x -= m;
    k = min(k,m);
  }
  int ans = n + x/k;
  cout << ans << endl;
  return 0;
}

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

int main(void){

  int n=0, m=0;
  char s[100][11]={0};
  char t[100][11]={0};
  int i=0, j=0, k=0;
  int cnt1=0, cnt2=0;
  int max=0;

  scanf("%d", &n);
  for(i=0; i<n; i++){
    scanf("%s", s+i);
  }
  scanf("%d", &m);
  for(i=0; i<m; i++){
    scanf("%s", t+i);
  }
  //ここまでok

  max=0;
  for(i=0; i<n; i++){
    k=0;
    while(k<n){
      if(strcmp(&s[i], &s[k])==0)
	cnt1++;
      k++;
    }

    for(j=0; j<m; j++){
      if(strcmp(&s[i], &t[j])==0)
	cnt2++;
    }
    if(cnt1-cnt2 > 0 && max < cnt1-cnt2)
      max=cnt1-cnt2;
    cnt1=0, cnt2=0;
  }

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

  return 0;
}


Measured memory_bytes: 128
#include <iostream>

using namespace std;

int main() {
    string s;
    cin >> s;
    int n=stoi(s);
    int res=0;
    for(char c : s){
        res+=c-'0';
    }
    cout << (n%res==0 ? "Yes" : "No") << "\n";
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for (int i=0;i<(n);i++)
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define FORR(i, a, b) for(int i=(b)-1; i>=(a); --i)
typedef long long ll;
using namespace std;
const ll MOD=1000000007ll;
const int MAX=5100000;

ll fact[MAX], fact_inv[MAX];

// 繰り返し二乗法
ll power(ll a, ll b){
	ll res=1;
	while(b>0){
		if(b&1) res=res*a%MOD;
		a=a*a%MOD;
		b>>=1;
	}
	return res;
}

ll comb(ll n, ll r){
	return (fact[n]*fact_inv[r])%MOD*fact_inv[n-r]%MOD;
}

int main() {
    ll x,y;cin>>x>>y;
    ll a,b,c;
    if(2*x<y || 2*y<x)cout<<0<<endl;
    else{
        if((2*x-y)%3==0 && (2*y-x)%3==0){
            a = (2*x-y)/3;
            b = (2*y-x)/3;

            fact[0]=1;
            // 階乗の計算
            rep(i, a+b) fact[i+1]=fact[i]*(i+1)%MOD;
            fact_inv[a+b]=power(fact[a+b], MOD-2);
            // 逆元の計算
            FORR(i, 0, a+b) fact_inv[i]=fact_inv[i+1]*(i+1)%MOD;

            c = comb(a+b,a);
            cout<<c%MOD<<endl;
        }
        else{
            cout<<0<<endl;
        }
    }
}

Measured memory_bytes: 14592
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <ctime>
#include <map>

#define inf 0x3f3f3f3f
#define Inf 0x3FFFFFFFFFFFFFFFLL
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define Rep(i, n) for (int i = 1; i <= (n); ++i)
#define clr(x, a) memset(x, (a), sizeof x)
using namespace std;
typedef long long ll;

int main() {
  int a,b;cin>>a>>b;
  if(a*b%2==0)cout<<"No\n";
  else cout<<"Yes\n";
  return 0;
}



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

void solve(long long N, std::vector<long long> A)
{
    vector<long long> sort_a(N);
    for (int i = 0; i < N; i++)
    {
        long long index = A[i];
        sort_a[index - 1] = i + 1;
    }

    for (int i = 0; i < N; i++) //auto dame
    {
        cout << sort_a[i] << ' ';
    }
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main()
{
    long long N;
    scanf("%lld", &N);
    std::vector<long long> A(N);
    for (int i = 0; i < N; i++)
    {
        scanf("%lld", &A[i]);
    }
    solve(N, std::move(A));
    return 0;
}


Measured memory_bytes: 2432
#include <iostream>
#include <stdlib.h>
using namespace std;

int main()
{
	int n;
	cin>>n;
	int a[3];
	for(int i=0;i<n;i++)
	{
		cin>>a[0]>>a[1]>>a[2];
		if(abs(a[1]) + abs(a[2]) > a[0])
		{
			cout<<"No"<<endl;
			return 0;
		}
		if((abs(a[1]) + abs(a[2])) % 2 == 0 && a[0] % 2 == 1)
		{
			cout<<"No"<<endl;
			return 0;
		}
		if((abs(a[1]) + abs(a[2])) % 2 == 1 && a[0] % 2 == 0)
		{
			cout<<"No"<<endl;
			return 0;
		}
	} 
	cout<<"Yes"<<endl;
	return 0;
}

Measured memory_bytes: 256
# ABC085D - Katana Thrower
import sys
input = sys.stdin.readline

def main():
    N, H = tuple(map(int, input().split()))
    AB = tuple(tuple(map(int, input().split())) for _ in range(N))
    A, B = zip(*AB)
    x = max(A)
    B = sorted([i for i in B if i > x], reverse=1)
    ans = 0
    for i in B:
        ans += 1
        H -= i
        if H <= 0:
            break
    else:
        ans += (H + x - 1) // x
    print(ans)


if __name__ == "__main__":
    main()

Measured memory_bytes: 25176
#include <iostream>
#include <stdio.h>
#include <cstring>
#include <algorithm>
#define ll long long
#define rep(i, a, b) for(int i = (a); i <= (b); i++)
using namespace std;
const int N = 1e5 + 9, M = 2e5 + 9;
const int inf = 0x3f3f3f3f;
int a[N], s[N], tr[M], n;
int lowbit(int x) { return x & (-x); }
void add(int x){ while(x < M) tr[x]++, x += lowbit(x); }
ll query(int x){
    ll res = 0;
    while(x > 0) res += tr[x], x -= lowbit(x);
    return res;
}
bool check(int x){
    ll res = 0;
    rep(i, 1, n) s[i] = s[i-1] + (a[i] >= x ? 1 : -1);
    memset(tr, 0, sizeof tr);
    rep(i, 0, n) res += query(s[i] + N), add(s[i] + N);
    return 2 * res >= 1ll * n * (n+1) / 2; 
}
int erfen(int l, int r){
    int res = 0;
    while(l <= r){
        int mid = (l + r) / 2;
        if(check(mid)) res = mid, l = mid+1;
        else r = mid-1;
    }
    return res;
}
int main(){

    int minn = inf, maxx = 0;
    scanf("%d", &n);
    rep(i, 1, n) {
        scanf("%d", &a[i]);
        maxx = max(maxx, a[i]), minn = min(minn, a[i]);
    }
    printf("%d", erfen(minn, maxx));
    return 0;
}

Measured memory_bytes: 1792
import java.io.*;
class Main {
	public static void main(String[] args) throws IOException {
        	BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        	while(true){
			String str = br.readLine();
            		String[] str2 = str.split(" ");
		        int a = Integer.parseInt(str2[0]);
		        int b = Integer.parseInt(str2[1]);
		        int c = Integer.parseInt(str2[2]);
		        int x = a + b;
		        if(a == -1 && b == -1 && c == -1){
				break;
            		}
            		if(a == -1 || b == -1){
                		System.out.println("F");
            		}
            		else if(x >= 80){
                		System.out.println("A");
            		}
            		else if(x >= 65 && x < 80){
                		System.out.println("B");
           		}
            		else if(x >= 50 && x < 65){
                		System.out.println("C");
            		}
            		else if(x >= 30 && x < 50){
                		if(c >= 50){
                    			System.out.println("C");
                		}else{
                    			System.out.println("D");
                		}
            		}else if(x < 30){
                		System.out.println("F");
            		}
        	}
    	}
}

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

#define PI 3.14159265358979323846264338327950L

int main() {
  long double A, B, H, M;
  cin >> A >> B >> H >> M;
  
  /* long double PI=3.14159265358; */
  long double cos = cosl(((H + M / 60.0) / 6.0 - M / 30.0) * PI);
  cout << fixed << setprecision(10) << sqrt(A * A + B * B - 2.0 * A * B * cos);
  
}


Measured memory_bytes: 4164
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <complex>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
using namespace std;
#define REP(i,n) for(int i = 0; i < (int)n; i++)
#define FOR(i,a,b) for(int i = a; i < (int)b; i++)
#define pb push_back
#define mp make_pair
typedef vector<int> vi;
typedef pair<int, int> pi;
typedef long long ll;
const int INF = 1<<28;
const ll MOD = 1000000007;
const int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};

int t;
string s;
vector<vi> vvi;

void dfs(int pnt, vi v) {
	if(pnt == s.size()) {
		vvi.pb(v);
		return;
	}
	else {
		string s2 = "";
		FOR(i, pnt, s.size()) {
			vi v2 = v;
			if(i > s.size())
				break;
			s2 += s[i];
			v2.pb(stoi(s2));
			dfs(i + 1, v2);
		}
	}
}

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

	while(cin >> t, t) {
		vvi.clear();
		cin >> s;
		dfs(0, vi());
		int max = 0, pnt = -1;
		bool flg = false;
		REP(i, vvi.size()) {
			int sum = 0;
			REP(j, vvi[i].size())
				sum += vvi[i][j];
			if(sum <= t && sum > max) {
				max = sum; pnt = i;
				flg = false;
			}
			else if(sum == max)
				flg = true;
		}
		if(flg)
			cout << "rejected" << endl;
		else if(pnt == -1)
			cout << "error" << endl;
		else {
			cout << max << ' ';
			REP(i, vvi[pnt].size()) {
				if(i)
					cout << ' ';
				cout << vvi[pnt][i];
			}
			cout << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 3244
H,W=map(int,input().split())
A=[[]]
for _ in range(H):
    A.append([0]+list(map(int,input().split())))

ans=[]

#左上から右に見ていく
for i in range(1,H+1):
    row = A[i]
    for j in range(1,W+1):
        odd=row[j]&1
        odd_down=A[i+1][j]&1 if i<H else 0
        odd_right=row[j+1]&1 if j<W else 0
        if odd:
            if odd_down or (j==W and i<H):
                row[j]-=1
                A[i+1][j]+=1
                ans.append((i,j,i+1,j))
            elif j<W:
                row[j]-=1
                row[j+1]+=1
                ans.append((i,j,i,j+1))

print(len(ans))
for a in ans:
    print(' '.join(map(str,a)))


Measured memory_bytes: 21900
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		int[] p = new int[5];
		for(int i = 0; i < 5; i++) {
			p[i] = stdIn.nextInt();
			if(p[i] < 40) {
				p[i] = 40;
			}
		}
		int sum = 0;
		for(int i = 0; i < 5; i++) {
			sum += p[i];
		}
		System.out.println(sum/5);
		
	}

}

Measured memory_bytes: 17228
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,m,k;
	cin>>n>>m>>k;
	for(int i=0;i<=n;i++)
		for(int j=0;j<=m;j++)
			if((n-i)*j+(m-j)*i==k)
				cout<<"Yes"<<endl,exit(0);
	cout<<"No"<<endl;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
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(int i=0;i<x;i++)
#define repn(i,x) for(int 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())
int m;
ll d[200005],c[200005],ans,ans2;
int main(){
	cin >> m;
	rep(i,m){
		cin >> d[i] >> c[i];
		ans += d[i] * c[i];
		ans2 += c[i];
	}
	if(ans%9 == 0) ans = ans/9-1;
	else ans = ans/9;
	cout << ans2-1+ans << endl;
}

Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
int main() {
    // freopen("stone.in", "r", stdin);
    // freopen("stone.out", "w", stdout);
    int a, b;
    cin >> a >> b;
    for (int i = b - a + 1; i <= b + a - 1; i++)
        cout << i << (i == b + a - 1 ? '\n' : ' ');
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	int d,n,x;
	scanf("%d %d",&d,&n);
	x=(100*((n-1)/99)+n-99*((n-1)/99))*100;
  	if(d==0) x=(100*((n-1)/99)+n-99*((n-1)/99))*1;
  	if(d==2) x=x*100;
	printf("%d\n",x);
	return 0;
}




Measured memory_bytes: 1708
n, w = map(int, input().split())
t = [tuple(map(int, input().split())) for _ in range(n)]

dp = [[0]*(w+1) for _ in range(n+1)]

for i in range(n):
    for j in range(w+1):
        if j >= t[i][0]:
            dp[i+1][j] = max(dp[i][j-t[i][0]] + t[i][1], dp[i][j])
        else:
            dp[i+1][j] = dp[i][j]

print(dp[n][w])


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

class TEST{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	public void Solve(){
		
		for(int i=0;i<=999;i++){
			var s = i.ToString();
			if(s.Length != N) continue;
			bool chk = true;
			for(int j=0;j<M;j++){
				chk &= s[S[j] - 1] == C[j];
			}
			if(chk){
				Console.WriteLine(i);
				return;
			}
		}
		Console.WriteLine(-1);
		
		
	}
	int N, M;
	int[] S;
	char[] C;
	public Sol(){
		var d = ria();
		N = d[0]; M = d[1];
		S = new int[M];
		C = new char[M];
		for(int i=0;i<M;i++){
			d = ria();
			S[i] = d[0];
			C[i] = (char)(d[1] + '0');
		}
	}

	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}
	static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}
	static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}
	static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}
}


Measured memory_bytes: 13140
#include <bits/stdc++.h>
#define RI register int
typedef long long LL;

#define FILEIO(name) freopen(name".in", "r", stdin), freopen(name".out", "w", stdout);

using namespace std;

char buf[1000000], *p1 = buf, *p2 = buf;
inline char gc() {
  if (p1 == p2) p2 = (p1 = buf) + fread(buf, 1, 1000000, stdin);
  return p1 == p2 ? EOF : *(p1++);
}
template <class T> inline void read(T &n) {
  n = 0; RI ch = gc(), f;
  while ((ch < '0' || ch > '9') && (ch != '-')) ch = gc();
  f = (ch == '-' ? ch = gc(), -1 : 1);
  while (ch >= '0' && ch <= '9') n = n * 10 + (ch ^ 48), ch = gc();
  n *= f;
}

int const MAXN = 1e5 + 5;
int dis[MAXN];
struct Edges { int to, next; } e[MAXN * 2];
int head[MAXN], tot;
queue <int> q;
int Ans[MAXN];

inline void addedge(int from, int to) {
  e[++tot] = (Edges){to, head[from]};
  head[from] = tot;
  e[++tot] = (Edges){from, head[to]};
  head[to] = tot;
}

int main() {

#ifdef LOCAL
  FILEIO("a");
#endif

  int n, x, y;
  cin >> n >> x >> y;
  for (RI i = 1; i < n; ++i)
    addedge(i, i + 1);
  addedge(x, y);
  for (RI i = 1; i <= n; ++i) {
    memset(dis, 0, sizeof(dis));
    dis[i] = 1;
    q.push(i);
    while (!q.empty()) {
      int t = q.front(); q.pop();
      for (RI i = head[t]; i; i = e[i].next)
        if (!dis[e[i].to]) dis[e[i].to] = dis[t] + 1, q.push(e[i].to);
    }
    for (RI j = 1; j <= n; ++j)
      ++Ans[dis[j] - 1];
  }
  for (RI i = 1; i < n; ++i)
    cout << Ans[i] / 2 << endl;

  cerr << (double)(clock()) / CLOCKS_PER_SEC * 1000 << "ms" << endl;

  return 0;
}

// created by Daniel yuan

Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
  ll n,k;
  ll arr[n];
  cin >> n >> k;
  for(int i=0;i<n;i++) cin >> arr[i];
  
  sort(arr,arr+n,greater<int>());
  
  if(n<=k) puts("0");
  else {
  ll sum = 0;
  for(int i=k;i<n;i++) sum += arr[i];
  cout << sum << endl;
  }
}


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

void solve(long long N){
    int count = N % 2 == 0 ? N/2 : N/2 + 1;
    cout << fixed << setprecision(10) << (double) count/N << endl;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
    scanf("%lld",&N);
    solve(N);
    return 0;
}


Measured memory_bytes: 256
/* AUTHOR :  SHIVANK JAIN */

#include<bits/stdc++.h>
#define fast ios_base::sync_with_stdio(false)
#define itt cin.tie(0)
#define now cout.tie(0)

using namespace std;

#define ll long long
#define li long int

#define pb push_back
#define rep(i,a,n) for(int i=a;i<n;i++)
#define reprev(i,n,a) for(int i=n;i>=a;i--)
#define endl "\n"

#define vi vector<int>
#define vll vector<ll>
#define vpi vector< pair<int , int> >
#define mapi map<int , int>
#define mapll map<ll ,ll >
#define seti set<int> 

#define fr first
#define se second
#define lb lower_bound
#define ub upper_bound
#define pb push_back
#define mp make_pair
#define sort(v) sort(v.begin() , v.end())

#define BIG 1000000007
int gcd(int a, int b) 
{ // builtin function __gcd(a,b)
    if (a == 0) 
        return b; 
    return gcd(b % a, a); 
} 
int main(){

     fast;itt;now;
 
//    #ifndef ONLINE_JUDGE
//    // for getting input from input.txt
//    freopen("input.txt", "r", stdin);
//    // for writing output to output.txt
//     freopen("output.txt", "w", stdout);
//    #endif
    
     string s;  cin>>s;
     
     if(s == "ABC")
      cout<<"ARC"<<endl;
     else
	  cout<<"ABC"<<endl; 
}

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

#define rapid_io() ios::sync_with_stdio(false);cin.tie(0);
#define endl '\n'
#define pb push_back
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()

int main()
{
    rapid_io();
    int x,y;
    cin>>x>>y;
    int n1=0,ans=0;
    if(y/2==x && y%2==0)
        cout<<"Yes"<<endl;
    else if(y/4==x && y%4==0)
        cout<<"Yes"<<endl;
    else{
    for(int i=1;i<=x;i++)
    {
        n1=i*2;

        int ck=y-n1;
        if(ck>=4 && ((ck%4)==0 && (ck/4==x-i)))
        {
            ans=1;
            break;
        }

    }
    if(ans)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
    }


    return 0;
}




Measured memory_bytes: 3664
#define _CRT_SECURE_NO_DEPRECATE
#pragma GCC optimize("O3")
#pragma GCC target("sse4")
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds; 
using namespace std;
#define int long long int
#define SYNC std::ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
#define FRE freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
typedef long double ld;
typedef pair<int,int> ii;
typedef pair<int,ii> iii;
typedef vector<int> vi;
typedef vector<ii>   vii;
//typedef tree<int, null_type, less<int>, rb_tree_tag, 
//             tree_order_statistics_node_update> 
//    data_set;
#define rep(i,l,r)   for(int i=(l);i<(r);i++)
#define deb(x)     cout << (#x) << " is " << (x) << endl
#define dbg(x)     cout << x << ' '
#define here cout << " Hey baitch!!\n";
#define  pb push_back
#define  F  first
#define  S  second
#define all(v) (v).begin(),(v).end()
#define sz(a) (int)((a).size())
#define sq(x) ((x)*(x))
const int MOD = 1e9+7;
const int MOD1 = 998244353;
const int N = 2e5+5;
const int INF = 1000111000111000111LL;
const ld PI = 3.1415926535898;

int32_t main()
{
	SYNC
	int n,m,x;
	cin >> n >> m >> x;
	int c[n],a[n][m];
	for(int i = 0; i < n; i++) {
		cin >> c[i];
		for(int j = 0; j < m; j++) {
			cin >> a[i][j];
		}
	}
	int ans = INF;
	for(int mask = 0; mask < (1ll<<n); mask++)
	{
		vi v(m,0);
		int cost = 0;
		for(int i = 0; i < n; i++) {
			if((1ll<<i)&mask) {
				cost += c[i];
				for(int j = 0; j < m; j++) {
					v[j] += a[i][j];
				}
			}
		}
		sort(all(v));
		if(v[0] >= x) {
			ans = min(ans,cost);
		}
	}
	if(ans==INF)	return cout << -1,0;
	cout << ans;
    return 0;
}

Measured memory_bytes: 3672
import math

N, A, B = map(int, input().split())
H = [int(input()) for i in range(N)]

add_damage = A-B
left = 1
right = 10**9
ans = float('inf')

for i in range(int(math.log(10**9, 2)+1)):
    T = (left+right) // 2
    h = H.copy()
    h = list(map(lambda x: math.ceil(max(0, x-T*B) / add_damage), h))
    need = sum(h)
    
    if need <= T:
        right = T
        ans = min(ans, T)
    else:
        left = T

print(ans)

Measured memory_bytes: 11832
N, K = map(int, input().split())
P = list(map(int, input().split()))
C = list(map(int, input().split()))

lim = 60
nex = [[0] * N for _ in range(lim)]
val = [[0] * N for _ in range(lim)]
cnd = [[0] * N for _ in range(lim)]

for i in range(N):
    nex[0][i] = P[i] - 1
    val[0][i] = C[i]
    cnd[0][i] = C[i]

for d in range(lim - 1):
    for i in range(N):
        nex[d + 1][i] = nex[d][nex[d][i]]
        val[d + 1][i] = val[d][i] + val[d][nex[d][i]]
        cnd[d + 1][i] = max(cnd[d][i], val[d][i] + cnd[d][nex[d][i]])

res = -10 ** 9
for i in range(N):
    sum_ = 0
    offset = i
    for d in reversed(range(lim)):
        if K & 1 << d:
            res = max(res, sum_ + cnd[d][offset])
            sum_ += val[d][offset]
            offset = nex[d][offset]

print(res)


Measured memory_bytes: 117828
#include <bits/stdc++.h>
using namespace std;
#define M 100010
#define LL long long
int a[M], b[M];
inline bool cmp(int x, int y) {
	return x > y;
}
int main() {
	LL Ans = 0;
	int n; scanf("%d", &n);
	for(int i = 1; i <= n; ++ i) {
		scanf("%d%d", &a[i], &b[i]);
	}
	sort(a, a + n + 1, cmp);
	sort(b, b + n + 1);
	for(int i = 0; i <= n; ++ i) {
		if(a[i] >= b[i]) {
			Ans += 2 * (a[i] - b[i]);
		}
	}
	printf("%lld\n", Ans);
}

Measured memory_bytes: 1024
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;

typedef long long ll;

#define MOD 1000000007

vector<int> g[100000];

int main() {
  int n, m;
  cin >> n >> m;
  vector<int> h(n);
  for (int i = 0; i < n; ++i) {
    cin >> h[i];
  }
  for (int i = 0; i < m; ++i) {
    int a, b;
    cin >> a >> b;
    a--, b--;
    g[a].push_back(b);
    g[b].push_back(a);
  }
  int ans = 0;
  for (int i = 0; i < n; ++i) {
    bool ok = true;
    for (auto u : g[i]) {
      if (h[i] <= h[u]) ok = false;
    }
    if (ok) ans++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 8808
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cstring>
#include <cctype>
#include <complex>
#include <stack>
#include <queue>
#include <unordered_map>
#include <set>
#include <deque>
#include <map>
#include <bitset>
#include <functional>
#include <cmath>

#define INF 1000000000
using namespace std;

int keta(long long n){
	long long ans = 0;
	while(n/10 != 0){
		ans ++;
		n /= 10;
	}

	return ans;
}

int main() {
    long long n;
	cin >> n;
	vector<long long> a;
	for(long long i = 0; i < n; i++){
		long long t;
		cin >> t;
		a.push_back(t);
		if(t == 0){
			cout << 0 << endl;
			return 0;
		}
	}

	sort(a.begin(), a.end());
	long long res = 1;
	for(int i = a.size()-1; i >= 0; i--){
		long long tmp;
		tmp = res;
		res *= a[i];
		if(tmp > res){
			cout << -1 << endl;
			return 0;
		}
	}

	if(res > 1000000000000000000){
		cout << -1 << endl;
	}else{
		cout << res << endl;
	}
}

Measured memory_bytes: 4316
n=gets.chomp.to_i
a=gets.chomp.split.map(&:to_i)

a.unshift(0)
ans=1000
(1...n).each do|i|
    stk=0

    stk=ans/a[i] if a[i] < a[i+1]
    ans+=(a[i+1]-a[i])*stk
end

puts ans

Measured memory_bytes: 14280
import qualified Data.ByteString.Lazy.Char8 as B
import Data.List
import Data.Maybe

bsReadInts :: B.ByteString -> [Int]
bsReadInts = map (fst . fromJust . B.readInt) . B.words

main :: IO ()
main = do
  conts <- B.getContents
  let n : ds = bsReadInts conts
      x = length (nub ds)
  putStrLn $ show x


Measured memory_bytes: 508
#
import sys
import math
import numpy as np
import itertools

# 文字列を一文字ずつのリストに代入 test は['t', 'e', 's', 't']
s = list(input())
t = [0]
now = 0
if s[0]=='<':
    now = 1
else:
    now = -1

for i in range(1,len(s)):
    if s[i]=='<' and now > 0:
        now += 1
    elif s[i]=='<' and now < 0:
        t.append(now)
        now = 1
    elif s[i]=='>' and now < 0:
        now -= 1
    elif s[i]=='>' and now > 0:
        t.append(now)
        now = -1
t.append(now)

answer=0
for i in range(1,len(t)):
    if t[i-1] > 0 and t[i] < 0:
        if t[i-1] < -t[i]:
            t[i-1] -= 1
        else:
            t[i] += 1
for i in range(len(t)):
    answer += abs(t[i]) * (abs(t[i]) + 1) // 2
#print(t)
print(answer)



Measured memory_bytes: 21272
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <climits>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <queue>
#include <random>
#include <complex>
#include <regex>

using namespace std;

#define SHOW_VECTOR(v) {std::cerr << #v << "\t:";for(const auto& xxx : v){std::cerr << xxx << " ";}std::cerr << "\n";}
#define SHOW_MAP(v){std::cerr << #v << endl; for(const auto& xxx: v){std::cerr << xxx.first << " " << xxx.second << "\n";}}

int main() {

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

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

    sort(h.begin(), h.end());

    int ans = INT_MAX;
    for (int i = 0; i < N - K + 1; i++) ans = min(ans, h[i + K -1] - h[i]);
    cout << ans << endl;

    return 0;
}


























































Measured memory_bytes: 640
fun main(args:Array<String>):Unit{
    val (n, m) = readLine()!!.split(' ').map(String::toInt)
    f(n, m)
}
tailrec fun f(n:Int, m:Int):Unit{
    if (n != 0 && m != 0){
        val difficulty = Array(m){0}
        for (void in 0 until n){
            val (d, v) = readLine()!!.split(' ').map(String::toInt)
            if (difficulty[d - 1] < v){
                difficulty[d - 1] = v
            }
        }
        println(difficulty.sum())
        val (nn, nm) = readLine()!!.split(' ').map(String::toInt)
        f(nn, nm)
    }
}


Measured memory_bytes: 33348
#include <bits/stdc++.h>
#define pb push_back
#define fst first
#define snd second
#define ios ios_base::sync_with_stdio(0); cin.tie(0);
#define open freopen("input.in", "r", stdin); freopen("output.out", "w", stdout);
using namespace std; typedef long long ll; typedef long double ld; mt19937 rnd(time(0));

#define int ll

void solve(){
    int n, m;
    cin >> n >> m;
    int sum = 0;
    int a[n];
    for (int i = 0; i < n; i++){
        cin >> a[i];
        sum += a[i];
    }
    sort(a, a + n);
    reverse(a, a + n);
    if (a[m - 1] * 4 * m >= sum)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}

signed main(){
    ios;
    // open;
    ll t = 1;
    // cin >> t;
    cout.precision(16);
    while(t--){
        solve();
    }
    return 0;
}

Measured memory_bytes: 256
import java.io.*;
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        try (BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {
            br.lines()
                .map(line -> Arrays.stream(line.split(" "))
                        .mapToInt(Integer::parseInt)
                        .toArray())
                .forEach(tokens -> {
                    int a = tokens[0];
                    int b = tokens[1];
                	if(((a%3==0)||(b%3==0))||((a+b)%3==0))System.out.println("Possible");
                	else System.out.println("Impossible");
                });
        }
    }
}

Measured memory_bytes: 26836
#include "bits/stdc++.h"
typedef long long ll;
using namespace std;

int main() {
    int n, m, maxL, minR;
    cin >> n >> m;
    maxL = 0;
    minR = 100000;
    for (int i = 0; i < m; ++i) {
        int l, r; cin >> l >> r;
        maxL = max(l, maxL);
        minR = min(r, minR);
    }
    int ans = max(0, minR - maxL + 1);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define show(x) cout<<#x" = "<<x<<endl;
#define show2(x,y) cout<<#x" = "<<x<<" "<<#y<<" = "<<y<<endl;
#define all(x) x.begin(),x.end()
#define INF 0x3f3f3f3f
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int,int> iipair;
typedef pair<unsigned,unsigned> uupair;
typedef vector<int> vec;
typedef vector<unsigned> uvec;

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    unsigned n,k;
    vector<ld> p;
    cin>>n>>k;
    p.resize(n);
    for(unsigned i=0;i<n;cin>>p[i++]);
    for(auto &x : p) x=(x+1)/2;
    ld res=0;
    for(unsigned i=0;i<k;++i)
        res+=p[i];
    // show(res);
    ld temp=res;
    for(unsigned i=1;i<=(n-k);++i)
    {
        temp-=p[i-1];
        temp+=p[i+k-1];
        res=max(res,temp);
    }
    cout<<fixed<<setprecision(12)<<res;
}

Measured memory_bytes: 3456
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <cfloat>
#include <complex>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

int main() {
  ll N;

  cin >> N;

  vector<ll> acc(N+1);
  for (int i = 1; i <= N; i++) {
    ll tmp;
    cin >> tmp;
    acc[i] = acc[i - 1] + tmp;
  }

  ll ans = LONG_LONG_MAX;
  ll sum = acc[N];
  for (int i = 1; i <= N - 1; i++) {
    ll tmp = abs(sum - acc[i] - acc[i]);
    ans = min(tmp, ans);
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 1792
#include <cstdio> 
#include <cstdlib> 
#include <cmath> 
#include <cstring> 
#include <climits> 
#include <cfloat> 
#include <map> 
#include <utility> 
#include <set> 
#include <iostream> 
#include <memory> 
#include <string> 
#include <vector> 
#include <algorithm> 
#include <functional> 
#include <sstream> 
#include <complex> 
#include <stack> 
#include <queue> 
#include <numeric>
#include <cassert>

#define FOR(i, min, max) for (int i = (min); i < (max); ++i) 
#define FORE(i, min, max) for (int i = (min); i <= (max); ++i) 
#define REP(i, n) for (int i = 0; i < (n); ++i) 
#define REPV(vec, i) for (int i = 0; i < (int)(vec.size()); ++i) 
#define FOR_EACH(vec, it) for (typeof((vec).begin()) it = (vec).begin(); it != (vec).end(); ++it)

using namespace std; 
static const double EPS = 1e-12; 
typedef long long ll; 

template<typename T>
vector<T> getVector(int N) {
    vector<T> v(N);
    REP(i, N) cin >> v[i];
    return v;
}

ll MOD=998244353;
inline ll add_m(ll a, ll b) { return (a + b) % MOD; }
inline ll sub_m(ll a, ll b) { return (a - b + MOD) % MOD; }
inline ll mul_m(ll a, ll b) { return (a * b) % MOD; }
ll pow_m(ll a, ll b) {
    ll r = 1LL;
    while(b) {
        if(b & 1LL)
            r = mul_m(r, a);
        a = mul_m(a, a);
        b >>= 1;
    }
    return r;
}
inline ll div_m(ll a, ll b) { return mul_m(a, pow_m(b, MOD-2LL)); }

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


    ll ret = 0LL;
    ll c = 1LL;
    FORE(k, 0, K) {
        ll a = mul_m(M, pow_m(M-1, N-k-1));
        ret = add_m(mul_m(a, c), ret);
        c = div_m(mul_m(c, N-1-k), k+1);
    }
    cout << ret << endl;

    return 0;
}


Measured memory_bytes: 3636
#include <stdio.h>
#include <algorithm>

using namespace std;
using ll = long long;

int n, a[30], b[30], c[30] = { 0 };
int main() {
	scanf("%d", &n);
	for (int i = 1; i <= n; i++)
		scanf("%d", a + i);
	for (int i = 1; i <= n; i++)
		scanf("%d", b + i);
	for (int i = 1; i + 1 <= n; i++)
		scanf("%d", c + i);

	int s = 0;
	for (int i = 1; i <= n; i++) {
		s += b[a[i]];
		if (a[i] + 1 == a[i + 1])
			s += c[a[i]];
	}
	printf("%d\n", s);
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <cmath>
#include <numeric>
#include <fstream>
#include <queue>
#include <cstdio>
#include <deque>
#include <map>
#define fol(i,n) for(int i=0;i<n;i++)
#define db(a) cout << a<< endl;
using namespace std;

int main(){
    string a;
    cin >> a;
    cout << a.substr(0,4)<<" "<<a.substr(4,8)<<endl;
    return 0;
}


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

#ifdef LOCAL
#include <debug.hpp>
#else
#define debug(...) void()
#endif

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, m;
  cin >> n >> m;
  const int mx = 40;
  vector<vector<int>> ex(mx);
  for (int i = 0, a, a_; i < n; i++) {
    cin >> a;
    a_ = a;
    int cnt = 0;
    while (a > 0) {
      a /= 2;
      cnt++;
    }
    ex[cnt].emplace_back(a_);
  }
  debug(ex);
  for (int i = mx - 1; i > 0 && m > 0; i--) {
    if ((int)ex[i].size() <= m) {
      for (auto&& e : ex[i]) {
        e /= 2;
        ex[i - 1].emplace_back(e);
        e = 0;
      }
      m -= (int)ex[i].size();
    } else {
      sort(ex[i].begin(), ex[i].end(), greater<int>());
      for (int j = 0; j < m; j++) {
        ex[i][j] /= 2;
      }
      m = 0;
    }
    debug(i, m);
    debug(ex);
  }
  long long ans = 0;
  for (int i = 0; i < mx; i++) {
    for (auto&& e : ex[i]) {
      ans += e;
    }
  }
  cout << ans << '\n';
  return 0;
}

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

int main(){
    int dH[]={1,-1,0,0};
    int dW[]={0,0,1,-1};   
    
    int H,W;
    cin>>H>>W;
    
    string S[H];
    for(int i=0;i<H;i++) cin>>S[i];
    
    int i,j,k;
    bool check;
    
    for(i=0;i<H;i++){
        for(j=0;j<W;j++){
            
            if(S[i][j]=='#'){
                check = false;
                
                for(k=0;k<4;k++){
                    int x=i+dH[k];
                    int y=j+dW[k];
                    
                    if(y<0 || W<=y) continue;
                    if(x<0 || H<=x) continue;
                    
                    if(S[x][y]=='#'){
                        check = true;
                    }
                }
                
                if(!check){
                    cout<<"No"<<endl;
                    return 0;
                }
            }
            
        }
    }
    
    cout<<"Yes"<<endl;
    
    
}

Measured memory_bytes: 256
// You can win if you want
#include <bits/stdc++.h>
using namespace std;
# define ll long long
# define endl "\n"
# define pi 3.14159265359
# define str string
# define vll vector<ll>
# define pb push_back
# define mll map<ll,ll>
# define vp vector< pair<ll,ll> >
# define mp make_pair
# define ff first
# define ss second
# define pll pair<ll,ll>
# define f(x,y) for(int x=0;x<y;x++)
int main(){
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    ll x,y;
    cin>>x>>y;
    ll k=y*y;
    ll ans=0;
    while(x--){
        ll a,b;
        cin>>a>>b;
        ll m=a*a;
        ll m1=b*b;
        ll m2=m+m1;
        if(m2<=k){
            ans++;
        }
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 3652
N ,K ,S= map(int, input().split())

if S == 1:
    ans = [100]*N
    for i in range(K):
        ans[i] = 1
    print(*ans)
    exit()

# Sが偶数の時
if S % 2 == 0:
    m = S // 2
    if N - K == 0:
        ans = [S]*N
    elif N - K == 1:
        ans = [m]*N
    else:
        wrong = N-K-1
        ans = [m-1]*wrong
        for _ in range(N-wrong):
            ans.append(m)

# Sが奇数の時
else:
    num_down = S // 2
    num_up = -(-S // 2)
    if N - K ==0:
        ans = [S] * N
    elif N -K == 1:
        ans = []
        for i in range(N):
            if i % 2 == 0:
                ans.append(num_down)
            else:
                ans.append(num_up)
    else:
        wrong = N-K-1
        ans = [num_up+2]*wrong
        for i in range(N-wrong):
            if i % 2 == 0:
                ans.append(num_down)
            else:
                ans.append(num_up)
        
print(*ans)

Measured memory_bytes: 6628