akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<bits/stdc++.h>
#include<math.h>
#include<vector>
#include<string>
#include<cstring>
#include<ctype.h>
using namespace std;

typedef long long ll;
typedef long l;

#define EPS 1e-9
#define pb push_back
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007
#define mp make_pair
#define ff first
#define ss second
#define umpit unordered_map<ll,ll>::iterator
#define mpit map<ll,ll>::iterator
#define setit set<ll,ll>::iterator
#define all(v) v.begin(),v.end()


vector<ll>ans(100005,0);
void bfs(vector<ll>adj[],queue<ll>&qq,ll cur,bool visited[]){
	cur = qq.front();
  	visited[cur] = true;
  	qq.pop();
  	for(auto i: adj[cur])
    {
      if(!visited[i])
      {
      	visited[i] = true;
      	ans[i] = cur+1;
        qq.push(i);
      }
    }
}


int main()
{
  ll n,m;
  cin>>n>>m;
  vector<ll>adj[n];
  int u,v;
  for(int i=0;i<m;i++){
   cin>>u>>v;u--;v--;
    adj[u].pb(v);
    adj[v].pb(u);
  }
  bool visited[n];
  queue<ll>qq;
  memset(visited,false,n);
  qq.push(0);
  ans[0] = 1;
  while(!qq.empty())
  	bfs(adj,qq,0,visited);
  int flag = 1;
  for(int i=1;i<n;i++){
  	if(ans[i] == 0) flag =0;
  }
  if(flag == 0) cout<<"No\n";
  else{
    cout<<"Yes\n";
   FOR(i,1,n){
   	cout<<ans[i]<<endl;
   }
  }
  
  return 0; 
}


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

int ctoi(char c) {
  if (c =='0') {
    return 0; 
	} else if (c =='1') {
    return 1;} else {return 0;}
  }
    

int main() {
  string s;
  cin >> s;
  int s1, s2, s3;
  s1 = ctoi(s.at(0));
  s2 = ctoi(s.at(1));
  s3 = ctoi(s.at(2));
  cout << s1+s2+s3 << endl;
}


Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
using Console = System.Console;

namespace Atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            List<int> primes = new List<int>();
            int N = int.Parse(Console.ReadLine());
            for (int i = 2; i < int.MaxValue; i++)
            {
                bool isPrime = true;
                foreach (var prime in primes)
                {
                    if (i % prime == 0)
                    {
                        isPrime = false;
                        break;
                    }
                }

                if (isPrime)
                {
                    primes.Add(i);
                    if (i >= N)
                    {
                      break;  
                    }
                }
            }

            Console.WriteLine(primes.Last());
        }

    }
}

Measured memory_bytes: 13320
#define _USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <cmath>
using namespace std;

int main()
{
    double A[100], B[100];
    int n;
    double sum1 = 0, sum2 = 0, sum3 = 0, sum4 = 0;
    cin >> n;
    for (int i = 0; i != n; ++i)
    {
        cin >> A[i];
    }
    for (int i = 0; i != n; ++i)
    {
        cin >> B[i];
    }
    for (int i = 0; i != n; ++i)
    {
        sum1 += abs(A[i]-B[i]);
        sum2 += pow(abs(A[i]-B[i]), 2.0);
        sum3 += pow(abs(A[i]-B[i]), 3.0);
        sum4 = max(sum4, abs(A[i]-B[i]));
    }
    cout << fixed << setprecision(8);
    cout << sum1 << endl;
    cout << sqrt(sum2) << endl;
    cout << pow(sum3, 1.0/3.0) << endl;
    cout << sum4 << endl;
    return 0;
}


Measured memory_bytes: 3468
#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;
template <class T> using treap = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
#define int long long
#define REP(i, n) for (long long i = 0, max_i = (n); i < max_i; i++)
#define REPI(i, a, b) for (long long i = (a), max_i = (b); i < max_i; i++)
#define ALL(obj) begin(obj), end(obj)
#define RALL(obj) rbegin(obj), rend(obj)
#define fi first
#define se second
using ii = pair<int, int>;
vector<ii> dirs = {
  {1, 0}, {0, 1}, {-1, 0}, {0, -1},  // 4方向
  {1, 1}, {-1, 1}, {-1, -1}, {1, -1},  // 斜め
  {0, 0},  // 自身
};
template <class T> inline bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } return false; }
template <class T> inline bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; } return false; }
template <class T, class S> vector<T> make_vec(size_t n, S x) { return vector<T>(n, x); }
template <class T, class... Ts> auto make_vec(size_t n, Ts... ts) { return vector<decltype(make_vec<T>(ts...))>(n, make_vec<T>(ts...)); }

// debug
template <class T> ostream& operator<<(ostream& s, vector<T>& d) { REP (i, d.size()) s << d[i] << (i == d.size() - 1 ? "" : " "); return s; }
template <class T> ostream& operator<<(ostream& s, vector<vector<T>>& d) { REP (i, d.size()) s << d[i] << (i == d.size() - 1 ? "" : "\n"); return s; }
template <class T, class S> ostream& operator<<(ostream& s, pair<T, S>& p) { s << "{" << p.first << ", " << p.second << "}"; return s; }
template <class T, class S> ostream& operator<<(ostream& s, map<T, S> m) { for (auto it = m.begin(); it != m.end(); it++) { s << *it << (next(it) == m.end() ? "" : "\n"); } return s; }
template <class T, class S> ostream& operator<<(ostream& s, unordered_map<T, S> m) { for (auto it = m.begin(); it != m.end(); it++) { s << *it << (next(it) == m.end() ? "" : "\n"); } return s; }
#ifdef _MY_DEBUG
  #define dump(...) cerr << "/* " << #__VA_ARGS__ << " :[" << __LINE__ << ":" << __FUNCTION__ << "]" << endl, dump_func(__VA_ARGS__), cerr << "*/\n\n";
#else
  #define dump(...)
  #define endl "\n"
#endif
void dump_func() { cerr << endl; }
template <class Head, class... Tail> void dump_func(Head&& h, Tail&&... t) { cerr << h << (sizeof...(Tail) == 0 ? "" : ", "), dump_func(forward<Tail>(t)...); }

struct Fast { Fast() { cin.tie(0); ios::sync_with_stdio(false); } } fast;
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
constexpr int MOD = 1000000007;
// *************** TEMPLATE END *************** 

signed main() {
  int a, b; cin >> a >> b;
  int c = a + b;
  if (c % 2) {
    cout << "IMPOSSIBLE" << endl;
  } else {
    cout << c / 2 << endl;
  }
}


Measured memory_bytes: 256
s = int(input())
value = list()
value.append(s)

while len(value) == len(set(value)):
    if s % 2 == 0:
        s = int(s/2)
        value.append(s)
    elif s % 2 == 1:
        s = s*3 + 1
        value.append(s)
    
print(len(value))

Measured memory_bytes: 3060
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.BitSet;
import java.util.PriorityQueue;
import java.util.Queue;
import java.util.Scanner;

class Solve{
	final Scanner in = new Scanner(System.in);
	boolean solve(){
		int n = in.nextInt();
		int m = in.nextInt();
		if(n == 0) return false;
		Pos[] pos = new Pos[n];
		for(int i=0; i<n; i++){
			pos[i] = new Pos(in.nextInt(), in.nextDouble());
		}
		Arrays.sort(pos);
		int res = 0;
		for(int i=0; i<n; i++){
			if(m>0){
				m -= pos[i].dist;
				pos[i].dist = 0;
				if(m < 0) pos[i].dist += -m;
			}
			res += pos[i].dist*pos[i].p;
		}
		System.out.println(res);
		return true;
	}
}

class Pos implements Comparable<Pos>{
	int dist;
	double p;
	Pos(int d, double p){
		dist = d;
		this.p = p;
	}
	
	@Override
	public int compareTo(Pos o) {
		return Double.compare(o.p, p);
	}
}

public class Main{
	public static void main(String[] args) throws IOException{
		Solve solve = new Solve();
		while(solve.solve());
	}
}

Measured memory_bytes: 110860
#include<bits/stdc++.h>
const long long INF = INT_MAX / 2;
const long long MOD = 1000000007;
const long double PI = 3.1415926;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define REP(i,n) FOR(i,0,n)
#define REP1(i,n) FOR(i,1,n+1)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(x) x.begin(),x.end()
#define RALL(x) x.rbegin(),x.rend()
#define ll long long int
using namespace std;
ll ans = 0, sum = 0, n, k, cnt = 0, w, h;
string s;
vector<ll> v;
vector<ll> v1;
vector < pair<ll, ll > > vp;
vector<vector<ll> > vv(50, vector<ll>(50, INF));
vector<string> vs;
vector<char> vc;
set<ll> st;
map<char, ll> mp;

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

int main()
{
	cin >> n;
	k = sqrt(2 * n);
	h = 1;
	while(h!=0)
	{
		if(n<=k*(k+1)/2)
		{
			ans = k;
			h = 0;
		}
		k++;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
a=0
while a<=1000:
    a=int(input())
    if a==0:
        break
    else:
        x=1000-a
        b=x//500#500coin
        c=x%500
        d=c//100#100coin
        e=c%100
        f=e//50
        g=e%50
        h=g//10#
        i=g%10
        j=i//5#
        k=i%5#
    print(b+d+f+h+j+k)    


Measured memory_bytes: 5588
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <array>
#include <unordered_set>
#include <unordered_map>
#include <map>
#include <math.h>
#include <queue>
#include <stdio.h>
using namespace std;
using i64 = int64_t;
#define rep(i, n) for(int i=0;i<n;++i)
#define rep2(i, x, n) for(int i=x;i<n;++i)
#define INF 1<<29;

int main()
{
    int n;
    cin >> n;
    vector<string> w(n);
    rep(i,n) cin >> w[i];
    unordered_set<string> a;
    a.insert(w[0]);
    rep(i,n-1)
    {
        if(a.count(w[i+1])>0 || w[i].substr(w[i].size()-1,1) != w[i+1].substr(0,1))
        {
            cout << "No" << endl;
            return 0;
        }
        a.insert(w[i+1]);
    }
    cout << "Yes" << endl;
    return 0;
}

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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++)
#define RFOR(i,n,m) for(int i=(int)(n); i>=(int)(m); i--)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

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 (a>b) { a=b; return 1; } return 0; }

#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

/* Some Libraries */

//-------------------------------------------------

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin>>n;
    vi a(n),b(n);
    rep(i,n) cin>>a[i];
    rep(i,n) cin>>b[i];
    vi S(2*n-1), T(n);
    rep(i,2*n-1) S[i] = a[i%n]^a[(i+1)%n];
    rep(i,n) T[i] = b[i]^b[(i+1)%n];
    // MP Table
    vi A(n+1); A[0]=-1;
    int j=-1;
    rep(i,n){
        while(j>-1 && T[i]!=T[j]) j = A[j];
        A[i+1] = ++j;
    }
    T.pb(-1);
    // Matching
    j=0;
    rep(i,2*n-1){
        while(j>-1 && S[i]!=T[j]) j = A[j];
        if (++j == n){
            int k = i-j+1;
            cout<<k<<" "<<(b[0]^a[k])<<"\n";
        }
    }
    return 0;
}


Measured memory_bytes: 8176
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <sstream>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <cstring>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <algorithm>
#include <iterator>
#include <bitset>
#include <ctime>
#include<unordered_set>
#include<complex>
#include <cassert>

using namespace std;

#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define RFOR(i,b,a) for (int i = (b)-1; i >= (a); i--)
#define ITER(it,a) for (__typeof(a.begin()) it = a.begin(); it != a.end(); it++)
#define FILL(a,value) memset(a, value, sizeof(a))

#define SZ(a) (int)a.size()
#define ALL(a) a.begin(), a.end()
#define PB push_back
#define MP make_pair

typedef long long LL;
typedef vector<int> VI;
typedef pair<int, int> PII;

const double PI = acos(-1.0);
const int INF = 1000 * 1000 * 1000 + 7;
const LL LINF = INF * (LL)INF;

const int MAX = 3000 + 47;
const int MOD = 998244353;
LL A[MAX];
LL dp[MAX][MAX];
int n, s;
void add(LL& key, LL val) {
    key += val;
    if (key >= MOD) key -= MOD;
}

int solve() {
    dp[0][0] = 1;
    FOR(i, 0, n) {
        FOR(j, 0, s + 1) {
            if (dp[i][j] == 0) continue;

            if (j + A[i] <= s) {
                add(dp[i + 1][j + A[i]], dp[i][j]);
            }

            add(dp[i + 1][j], dp[i][j]);
            add(dp[i + 1][j], dp[i][j]);
        }
    }

    return dp[n][s];
}

int brute() {
    LL ans = 0;
    FOR(mask, 0, 1 << n) {
        int ss = 0;
        int cnt = 0;
        FOR(k, 0, 20) {
            if (mask & (1 << k)) {
                ss += A[k];
                cnt++;
            }
        }

        if (ss == s) {
            ans += 1 << (n - cnt);
            ans %= MOD;
        }
    }

    return ans;
}

void gen() {
    n = rand() % 10;
    s = rand() % 100 + 1;
    FOR(i, 0, n) {
        A[i] = rand() % s + 1;
    }
}

void stress() {
    while (1) {
        cout << "*" << endl;
        FILL(dp, 0);
        gen();
        int br = brute();
        int sol = solve();
        if (br != sol) {
            cout << n << " " << s << endl;
            FOR(i, 0, n) cout << A[i] << " ";
            cout << endl;
            cout << "brute=" << br << " solution=" << sol << endl;
            exit(0);
        }
    }
}

int main()
{
    //freopen("in.txt", "r", stdin);
    //freopen("out.txt", "w", stdout);
    ios::sync_with_stdio(false); cin.tie(0);
    
    //stress();
    cin >> n >> s;
    FOR(i, 0, n) {
        cin >> A[i] ;
    }

    cout << solve() << endl;
}

Measured memory_bytes: 75020
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
int main(){
  int a,b,ans=0;
  cin >> a >> b;
  vector<int> ai(a);
  for(int i = 0;i<a;i++)cin >> ai.at(i);
  sort(ai.begin(),ai.end());
  reverse(ai.begin(),ai.end());
  for(int i = 0;i<b;i++) ans += ai.at(i);
  cout << ans;
}

Measured memory_bytes: 3524
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line = "";

		while ((line = br.readLine()) != null && !line.isEmpty()) {
			int a, b, c, i, j, k;
			a = Integer.parseInt(line.substring(0, line.indexOf(' ')));
			b = Integer.parseInt(line.substring(line.indexOf(' ') + 1));
			if ((a | b) == 0) {
				break;
			}
			c = (b - a) / 100;

			i = j = k = 0;
			i = c / 10;
			if ((c %= 10) != 0) {
				j = c / 5;
			}
			if ((c %= 5) != 0) {
				k = c;
			}
			System.out.println(k + " " + j + " " + i);
		}
	}
}

Measured memory_bytes: 22012
#include<cstdio>
#include<cstring>
#include<map>
#include<set>
#include<queue>
#include<vector>
#include<iostream>
#include<algorithm>
using namespace std;
#define mp make_pair
#define pb push_back
#define sz(x) ((int)(x).size())
#define rep(i,l,r) for(int i=(l);i<(r);++i)
typedef long long ll;
typedef pair<int,int> pii;
const int N = 9e5 + 7;
const int MOD = 1e9 + 7;
//--------head---------
int n, m, k, f[N], rf[N], x2[N], x3[N];
ll kpow(ll a, ll b) {
	ll r = 1;
	while (b > 0) {
		if (b & 1)
			r = r * a % MOD;
		a = a * a % MOD, b >>= 1;
	}
	return r;
}
void inc(int &x, int y) {
	x += y;
	if (x >= MOD)
		x -= MOD;
}
void init() {
	f[0] = 1;
	rep(i, 1, N)
		f[i] = 1ll * i * f[i - 1] % MOD;
	rf[N - 1] = kpow(f[N - 1], MOD - 2);
	for (int i = N - 2; i >= 0; --i)
		rf[i] = 1ll * (i + 1) * rf[i + 1] % MOD;
	x2[0] = 1;
	rep(i, 1, N)
		x2[i] = 1ll * 2 * x2[i - 1] % MOD;
	x3[0] = 1;
	rep(i, 1, N)
		x3[i] = 1ll * 3 * x3[i - 1] % MOD;
}
ll C(int n, int m) {
	if (n < m)
		return 0;
	return 1ll * f[n] * rf[m] % MOD * rf[n - m] % MOD;
}
int main() {
	init();
	cin >> n >> m >> k;
	++m, ++k;
	int tot = n + m + k, ans = 0;
	int fb = 0, fc = 0;
	rep(i, n, tot - 2 + 1) {
		int cnt = C(i - 1, n - 1), ill = x2[i - n];
		if (m == i - n)
			fb = 1;
		else if (m < i - n) {
			fb = 1ll * 2 * fb % MOD;
			inc(fb, C(i - n - 1, i - n - m));
		}
		if (k == i - n)
			fc = 1;
		else if (k < i - n) {
			fc = 1ll * 2 * fc % MOD;
			inc(fc, C(i - n - 1, i - n - k));
		}
		inc(ill, MOD - fb), inc(ill, MOD - fc);
		inc(ans, 1ll * cnt * ill % MOD * x3[tot - 2 - i] % MOD);
	}
	cout << ans << endl;
	return 0;
}


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

//定数
const long long MOD1=1000000007;
const long long MOD2=998244353;
const long long INF=1LL<<60;
const long double PI=3.1415926535897932;

//型名省略
#define ll long long
#define ull unsigned long long
#define ld long double
#define pll pair<long long,long long>
#define vl vector<long long>
#define vvl vector<vector<long long>>
#define vc vector<char>
#define vvc vector<vector<char>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define mp make_pair
#define mt make_tuple
#define eb emplace_back
#define umap unordered_map
#define Lqueue priority_queue<long long>
#define Squeue priority_queue<long long,vector<long long>,greater<long long>>
#define Fi first
#define Se second

//マクロ
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define rbf(a, x) for (auto& a : x)
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
#define drep(i, x) for (ll i = ((ll)(x)-1); i >= 0; i--)
#define Maxe(x) *max_element(all(x))
#define Mine(x) *min_element(all(x))
#define Size(x) ((ll)(x).size())


//pow
template<typename Num>
constexpr Num mypow(Num a, long long b) {
    if(b==0)return 1;
    if (a==0)return 0;
    Num x = 1;
    while (b > 0) {
        if(b & 1)x*=a;
        a*=a;
        b >>= 1;
        }
    return x;
}

    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;
    }

    signed main(){
        ios::sync_with_stdio(false);
        cin.tie(nullptr);
        ll n,q;
        cin>>n>>q;
        vvl G(n,vl(0));
        umap<ll,ll> visited;
        rep(i,n-1){
            ll a,b;
            cin>>a>>b;
            a--;b--;
            G[a].eb(b);
            G[b].eb(a);
        }
        vl point(n,0);
        rep(i,q){
            ll p,x;
            cin>>p>>x;
            p--;
            point[p]+=x;
        }
        queue<ll> Q;
        Q.push(0);
        visited[0]++;
        while(!Q.empty()){
            ll f=Q.front();
            Q.pop();
            rbf(a,G[f]){
                if(!visited[a]){
                    visited[a]++;
                    point[a]+=point[f];
                    Q.push(a);
                }
            }
        }
        rep(i,n)cout<<point[i]<<" ";
        cout<<endl;
    }

Measured memory_bytes: 27016
#include <bits/stdc++.h>
#define IO_OP std::ios::sync_with_stdio(0); std::cin.tie(0);
#define F first
#define S second
#define V vector
#define PB push_back
#define MP make_pair
#define EB emplace_back
#define ALL(v) (v).begin(), (v).end()
#define debug(x) cerr << #x << " is " << x << endl

using namespace std;

typedef long long ll;
typedef pair<int, int> pi;
typedef V<int> vi;

const int INF = 1e9 + 7;

int dp[2][2020];

signed main()
{
	IO_OP;
	
	string s;
	cin >> s;
	ll ans = 0;
	for(int i = 1; i <= s.size(); i++) {
		for(int j = 0; j < 2019; j++) dp[i&1][j] = 0;
		for(int j = 0; j < 2019; j++) {
			dp[i&1][((j*10)+s[i-1]-'0')%2019] += dp[(i-1)&1][j];
		}
		dp[i&1][s[i-1]-'0']++;
		ans += dp[i&1][0];
	}
	cout << ans << endl;
	
}





Measured memory_bytes: 3756
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int a,b,c,k,sum=0;
  
  cin>>a>>b>>c>>k;
  if(k<=a){
    cout<<k<<'\n';
  }else if(k<=a+b){
    cout<<a<<'\n';
  }else{
    cout<<a-(k-(a+b))<<'\n';
  }
  return 0;
}


Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define pii pair<int,int>
#define fi first
#define se second
#define mp make_pair
#define poly vector<ll>
#define For(i,l,r) for(int i=(int)(l);i<=(int)(r);i++)
#define Rep(i,r,l) for(int i=(int)(r);i>=(int)(l);i--)
#define pb push_back
inline char gc(){
	static char buf[100000],*p1=buf,*p2=buf;
	return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
}
#define gc getchar
inline ll read(){
	ll x=0;char ch=gc();bool positive=1;
	for(;!isdigit(ch);ch=gc()) if(ch=='-') positive=0;
	for(;isdigit(ch);ch=gc()) x=x*10+ch-'0';
	return positive?x:-x;
}
inline void write(ll x){
	if(x<0){
		x=-x;putchar('-');
	}
	if(x>=10) write(x/10);
	putchar('0'+x%10);
}
inline void writeln(ll x){write(x);puts("");}
inline void writep(ll x){write(x);putchar(' ');}
inline ull rnd(){
	return ((ull)rand()<<30^rand())<<4|rand()%4;
}
const int N=505;
char r[N][N],a[N][N],b[N][N];
int main(){
	int n=read(),m=read();
	for(int i=1;i<=n;i+=2){
		For(j,1,m) r[i][j]='#';
	}
	for(int i=2;i<=n;i+=2){
		For(j,1,m) r[i][j]='.';
	}
	for(int i=2;i<=n;i+=2){
		For(j,1,m) b[i][j]='#';
	}
	for(int i=1;i<=n;i+=2){
		For(j,1,m) b[i][j]='.';
	}
	For(i,1,n) For(j,1,m){
		char ch;cin>>ch;
		if(ch=='#') r[i][j]=b[i][j]='#';
	}
	For(i,1,n) r[i][1]='#',b[i][1]='.';
	For(i,1,n) r[i][m]='.',b[i][m]='#';
	For(i,1,n){
		For(j,1,m) putchar(r[i][j]);
		puts("");
	}
	puts("");
	For(i,1,n){
		For(j,1,m) putchar(b[i][j]);
		puts("");
	}
}

Measured memory_bytes: 4076
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
using namespace std;
using ll = long long;
using P  = pair<int,int>;
using v  = vector<int>;
using vv = vector<v>;
const int MOD = 1000000007;

const ll INF = 1001001001001;

int main(){
    int n;cin>>n;
    vector<ll> a(n);
    
    double loga=0;
    bool ok=true;
    
    rep(i,n){
        cin>>a[i];
        if(a[i]==0){
            ok = false;
        }
        else loga += (double)log10((double)a[i]);
    }
    //cout << loga<<endl;
    
    if(!ok){
        cout << 0 << endl;
        return 0;
    }
    
    if(loga>18.1){
        cout << -1 << endl;
        return 0;
    }
    
    ll ans = 1;
    
    rep(i,n)ans *= a[i];
    
    if(ans>=1000000000000000001){
        cout << -1 << endl;
        return 0;
    }
    
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4056
#include <cstdio>
using namespace std;
int a,b,c,n;
int main(){
	scanf("%d%d%d%d",&a,&b,&c,&n);
	if(n<=a)printf("%d\n",n);
	else if(n-a<=b)printf("%d\n",a);
	else printf("%d\n",a-(n-a-b));
	return 0;
}


Measured memory_bytes: 1732
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define mod 1000000007
using namespace std;
ll binpow(ll x,ll y)/* (x^y)%p in O(log y) */{ll res=1;while (y > 0){if(y&1)res=(res*x);y = y>>1;x=(x*x);}return res;}
ll binpowmod(ll x,ll y,ll p)/* (x^y)%p in O(log y) */{ull res=1;x=x%p;while (y > 0){if(y&1)res=(res*x)%p;y = y>>1;x=(x*x)%p;}return res;}
ll mod_inverse(ll n,ll p)/* Returns n^(-1) mod p */{return binpowmod(n,p-2,p);}
ll gcd(ll x,ll y)
{
    if(y==0)
        return x;
    return gcd(y,x%y);
}
bool comp(pair<int,int> x,pair<int,int> y)
{
    return x.first<y.first;
}
bool comp_pairs_by_s(pair<ll,ll> &x ,pair<ll,ll> &y)
{
    return x.second<y.second;
}
bool isPowerOfTwo (ll x)  
{  
    /* First x in the below expression is for the case when x is 0 */
    return x && (!(x&(x-1)));  
}

class cmp      //comparator for priority_queue 
{               //declaration: priority_queue<int,vector<int>,cmp>
public:         
    bool operator()(pair<int,int> A,pair<int,int> B)
    {
        if(abs(A.first-A.second)==abs(B.first-B.second))
            return A.first>B.first;
        return abs(A.first-A.second)<abs(B.first-B.second);
    }
};
// int prime[10000007]={0};
// void sieve(void)
// {
//  int i,j;
//  for(i=0;i<10000007;i++)
//         prime[i]=1;
//  prime[0]=0,prime[1]=0;
//  for(i=2;i<=sqrt(10000007);i++){
//      if(prime[i]==i){
//          for(j=i*i;j<10000007;j+=i){
//             if(!prime[j])
//                 prime[j]=0;
//          }
//      }
//  }
    
// }
void swap(ll &x,ll &y){
    int temp=x;
    x=y;
    y=temp;
}
  
unsigned int onesComplement(unsigned int n) 
{ 
   // Find number of bits in the given integer 
   int number_of_bits = floor(log2(n))+1; 
  
   // XOR the given integer with poe(2,  
   // number_of_bits-1 and print the result  
   return ((1 << number_of_bits) - 1) ^ n; 
}
vector<ll> ar[10];
void solve()
{   
    int n;
    cin>>n;
    if(n<=9)
        cout<<n;
    else
    {
        vector<pair<int,int>> index(10,{0,1});
        for(int i=1;i<=9;++i)
            ar[i].push_back(i);
        n-=9;
        while(1){
            for(int i=1;i<=9;++i){
                int j=index[i].first;
                int end=index[i].second;
                for(;j<end;++j){
                    for(int digit=max(ar[i][j]%10-1,0LL);digit<=min(9LL,ar[i][j]%10+1);++digit){
                        ar[i].push_back(ar[i][j]*10+digit);
                        //cout<<ar[i][j]*10+digit<<'\n';
                        --n;
                        if(n==0){
                            cout<<ar[i].back();
                            return;
                        }
                    }
                }
                index[i].first=end;
                index[i].second=ar[i].size();

            }
        }
    }
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
}   


Measured memory_bytes: 4232
#!/usr/bin/env python3

L = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
K = int(input())
print(L[K-1])

Measured memory_bytes: 38384
#include <iostream>
#include <vector>
#include<algorithm>
#include<iomanip>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define REP(i,m,n) for(int i=m;i<(int)(n);i++)
typedef pair<int,int> pint;
typedef long long ll;
const int inf   = 1<<30;
const ll  longinf = 1LL<<60;
int dx[4]={1,0,-1,0}, dy[4]={0,1,0,-1};
 
int main(){
	int n,k,l;
	scanf("%d %d",&n,&k);
	l=2*k;
	int x[n],y[n],table[k+1][k+1];
	bool black[n];
	char c[n];
	rep(i,k+1)rep(j,k+1)table[i][j]=0;
	rep(i,n){
		scanf("%d %d %c",&x[i],&y[i],&c[i]);
		x[i]%=l;
		y[i]%=l;
		black[i]=(c[i]=='B');
		if(x[i]>=k){
			x[i]-=k;
			black[i]=!black[i];
		}
		if(y[i]>=k){
					y[i]-=k;
					black[i]=!black[i];
		}
		if(black[i]){
			table[0][0]++;
			table[0][y[i]+1]--;
			table[x[i]+1][0]--;
			table[x[i]+1][y[i]+1]+=2;
		}
		else{
			table[0][y[i]+1]++;
			table[x[i]+1][0]++;
			table[x[i]+1][y[i]+1]-=2;
		}
	}
	rep(i,k)REP(j,1,k)table[i][j]+=table[i][j-1];
	rep(i,k)REP(j,1,k)table[j][i]+=table[j-1][i];
	int ans=0;
	rep(i,k)rep(j,k){
		table[i][j]=max(table[i][j],n-table[i][j]);
		ans=max(ans,table[i][j]);
	}
	cout<<ans<<endl;
  return 0;
  }

Measured memory_bytes: 5120
#include <string.h>
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <cmath>
#define pi acos(-1.0)
#define eps 1e-8
const int maxn=100+10;
using namespace std;
struct Point{
    double x,y,z;
    //Point(){}
    Point(double x=0,double y=0,double z=0){
        this->x=x;
        this->y=y;
        this->z=z;
    }
}p[maxn],ran[maxn];
//两点距离
double get_dis(Point a,Point b){
    return sqrt((a.x-b.x)*(a.x-b.x)+(a.y-b.y)*(a.y-b.y)+(a.z-b.z)*(a.z-b.z));
}
//在l~r范围内的随机数
double random(double l,double r){
    return (rand()%10000+1)/10000.0*(r-l)+l;
}
int x=100,y=100,n;//范围
double dis[maxn];//记录随机点到给定点的最短距离
int key;//记录最后找到的点下标
//求该点到所有给定点的最短距离
double get_max(Point a){
    double ans=0;
    for(int i=1;i<=n;i++){
        if(get_dis(a,p[i])>ans){
            key=i;
            ans=get_dis(a,p[i]);
        }
       // ans=max(ans,get_dis(a,p[i]));
    }
    return ans;
}
//生成随机数组
void get_rand(){
    for(int i=1;i<=50;i++){
        ran[i].x=random(0,x*1.0);
        ran[i].y=random(0,y*1.0);
        dis[i]=get_max(ran[i]);//对每个随机点找到它与给定点的最短距离
    }
}
//随机的步是否在范围内
bool in(Point a){
    if(a.x<=x&&a.x>=0&&a.y>=0&&a.y<=y)return 1;
    return 0;
}
//模拟退火
double res;
void simulated_annealing(){
    //get_rand();
    //double T=max(x,y);//T初始温度，高温
    //double T=sqrt((double)x*x+y*y)+10;
    double T=100.0;
    Point temp=p[1];
    while(T>eps){//温度降温0-
        double d=get_max(temp);
        res=min(res,d);
        temp.x+=(p[key].x-temp.x)/d*T;
        temp.y+=(p[key].y-temp.y)/d*T;
        temp.z+=(p[key].z-temp.z)/d*T;
        T*=0.99;//退火速度
    }
}

int main()
{
    while(~scanf("%d",&n),n){
        for(int i=1;i<=n;i++){
            scanf("%lf%lf%lf",&p[i].x,&p[i].y,&p[i].z);
        }
        res=0x3f3f3f;
        simulated_annealing();
        printf("%.5f\n",res);
    }
    return 0;
}



Measured memory_bytes: 3160
#include <iostream>
using namespace std;
int main() {
    int n;
    string s, t;
    cin >> n >> s >> t;
    int cnt = 0;
    string subs;
    for(int i=0; i<n; i++) {
        subs = t.substr(0, n-i);
        if (s.find(subs) == i) {
            cnt = n-i;
            break;
        }
    }
    cout << 2*n - cnt << endl;
}


Measured memory_bytes: 3580
#include <bits/stdc++.h>
using namespace std;
int main(){
  long long n,m,i;
  cin >> n >> m;
  vector<long long> a(n),b(n);
  vector<pair<long long,long long>> c(n);
  for(i=0;i<n;i++){
    cin >> a[i] >> b[i];
    c[i]=make_pair(a[i],b[i]);
  }
  sort(c.begin(),c.end());
  long long cnt=0,sum=0;
  for(i=0;i<n;i++){
    if(cnt+c[i].second<=m){
      cnt+=c[i].second;
      sum+=c[i].first*c[i].second;
    }
    else{
      sum+=(m-cnt)*c[i].first;
      cnt=m;
    }
    if(cnt==m){
      break;
    }
  }
  cout << sum << endl;
}

Measured memory_bytes: 3456
N = input().split()

a = int(N[0])
b = int(N[1])
c = int(N[2])
d = int(N[3])
q = a * c 

if a * d > q:
  q = a * d
if b * c > q:
  q = b * c
if b * d > q:
  q = b * d

print(q)

Measured memory_bytes: 9176
use std::str::FromStr;
use std::fmt::Debug;
use std::cmp;

#[allow(dead_code)]
fn read_as_vec<T>() -> Vec<T>
where T: FromStr, <T as FromStr>::Err : Debug{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().split_whitespace().map(|c| T::from_str(c).unwrap()).collect()

}

#[allow(dead_code)]
fn read_as_string() -> String{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

fn dfs(v: usize, graph: &Vec<Vec<(usize, u64)>>, colors: &mut Vec<i32>){
    for next_v in &graph[v]{
        let (u, w) = (next_v.0, next_v.1);
        if colors[u] != 2{
            continue;
        }

        if w%2 == 0{
            colors[u] = colors[v];
        }else{
            colors[u] = (colors[v]+1)%2;
        }
        dfs(u, graph, colors);
    }
}

fn main(){
    let n: usize = read_as_vec()[0];


    
    let mut graph: Vec<Vec<(usize, u64)>> = vec![vec![];n];
    for _ in 1..n{
        let line: Vec<usize> = read_as_vec();
        let (u, v) = (line[0]-1, line[1]-1);
        let w = line[2] as u64;
        graph[u].push((v, w));
        graph[v].push((u, w));
    }

    let mut colors: Vec<i32> = vec![2;n];
    colors[0] = 0;

    dfs(0, &graph, &mut colors);

    for c in &colors{
        println!("{}", *c);
    }
    
}


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

bool Free[10];
int n,Count=0;

int main()
{
    cin>>n;
    int x;
    for(int i=1;i<=n;i++)
    {
        cin>>x;
        if(1<=x&&x<=399)
            Free[1]=true;
        if(400<=x&&x<=799)
            Free[2]=true;
        if(800<=x&&x<=1199)
            Free[3]=true;
        if(1200<=x&&x<=1599)
            Free[4]=true;
        if(1600<=x&&x<=1999)
            Free[5]=true;
        if(2000<=x&&x<=2399)
            Free[6]=true;
        if(2400<=x&&x<=2799)
            Free[7]=true;
        if(2800<=x&&x<=3199)
            Free[8]=true;
        if(x>=3200)
            Count++;
    }
    int minn=0,maxn=0;
    for(int i=1;i<=8;i++)
        if(Free[i]==true)
        {
            minn++;
            maxn++;
        }
    cout<<max(minn,1)<<' '<<maxn+Count;
}


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

int main() {

	int n, k;
	cin >> n >> k;

	vector<int> v(n);

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

	sort(v.begin(), v.end());
    
    int a = 0;
	for (int i = 0; i < k; i++) {
  
		a += v[n - 1 - i];

}
	cout << a << endl;

}

Measured memory_bytes: 256
def ii(): return int(input())


def mi(): return map(int, input().split())


def li(): return list(map(int, input().split()))


MOD = 10**9 + 7


class ModInt:

    def __init__(self, x):
        self.x = x.x if isinstance(x, ModInt) else x % MOD

    def __str__(self): return str(self.x)
    __repr__ = __str__
    def __int__(self): return self.x
    __index__ = __int__

    def __add__(self, other): return ModInt(self.x + ModInt(other).x)
    def __sub__(self, other): return ModInt(self.x - ModInt(other).x)
    def __mul__(self, other): return ModInt(self.x * ModInt(other).x)
    def __pow__(self, other): return ModInt(pow(self.x, ModInt(other).x, MOD))
    def __truediv__(self, other): return ModInt(
        self.x * pow(ModInt(other).x, MOD - 2, MOD))

    def __floordiv__(self, other): return ModInt(self.x // ModInt(other).x)
    def __radd__(self, other): return ModInt(other + self.x)
    def __rsub__(self, other): return ModInt(other - self.x)
    def __rpow__(self, other): return ModInt(pow(other, self.x, MOD))
    def __rmul__(self, other): return ModInt(other * self.x)
    def __rtruediv__(self, other): return ModInt(
        other * pow(self.x, MOD - 2, MOD))

    def __rfloordiv__(self, other): return ModInt(other // self.x)

    def __lt__(self, other): return self.x < ModInt(other).x
    def __gt__(self, other): return self.x > ModInt(other).x
    def __le__(self, other): return self.x <= ModInt(other).x
    def __ge__(self, other): return self.x >= ModInt(other).x
    def __eq__(self, other): return self.x == ModInt(other).x
    def __ne__(self, other): return self.x != ModInt(other).x


def cmb(n, r):  # nCr = n!/(n-r)!r!
    retVal = 1
    for i in range(n-r+1, n+1):
        retVal *= i
    for i in range(2, r+1):
        retVal //= i
    return retVal


n = ii()

print(pow(ModInt(10), n) - pow(ModInt(9), n) * 2 + pow(ModInt(8), n))


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

using namespace std;

#define INPUT_OUTPUT { \
    freopen("input.txt", "r", stdin); \
    freopen("output.txt", "w", stdout); \
}

int main()
{
    //INPUT_OUTPUT;
    int a, b;
    scanf("%d %d", &a, &b);
    if(a >= 13) printf("%d\n", b);
    else if(a >= 6 && a <= 12) printf("%d\n", (b/2));
    else printf("0\n");
    return 0;
}


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

using namespace std;


bool isNotPresent(int d,vector<int> v){
    for(auto x:v){
        if (x==d){
                return false;
        }
    }
    return true;
}

int main(){

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

    vector<int> hatred;
    int data;
    for(int i=0;i<K;i++){
        cin>>data;
        hatred.push_back(data);
    }
    int flag=1;
    for(int n=N;n<100000;n++){
        int a=n;
        flag=1;
        while(a>0){
            int d=a%10;
            a=a/10;
            if(isNotPresent(d,hatred)==false){

                    flag=0;
                    break;
            }
        }
        if(flag==1){
                cout<<n<<endl;
                break;
        }
        }


    return 0;

}


Measured memory_bytes: 256
n, m, x = map(int, input().split())
a = list(map(int, input().split()))
sum_list = []
count = 0

for i in range(n+1):
    if i in a:
        count += 1
    sum_list.append(count)

sum_front = sum_list[x] - sum_list[0]
sum_rear = sum_list[n] - sum_list[x]

print(min(sum_front, sum_rear))

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

int main(){
  int h,n;cin>>h>>n;
  int arr[n];
  for(int i=0; i<n; i++)cin>>arr[i];
  sort(arr,arr+n);
  for(int i=n-1; i>=0; i--){
    h-=arr[i];
    if(h<=0){
    	cout<<"Yes"<<endl;
      	return 0;
    }
  }
  cout<<"No"<<endl;
  return 0;
}

Measured memory_bytes: 640
//半价优惠卷 2020.3.19 
#include<iostream>
using namespace std;
int main ()
{ 
	int n,p[10],ma=0,ba=0;
	cin>>n;
	for(int t=0;t<n;t++)
	{ 
		cin>>p[t];
		ba=ba+p[t];
		if(p[t]>ma)
			ma=p[t];
	} 
	cout<<ba-ma/2;
	return 0;
} 

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

int main() {
    int N, W;
    std::cin >> N >> W;

    std::vector<int> dp(W + 1, 0);
    for (int i = 0; i < N; ++i) {
        int v, w, m;
        std::cin >> v >> w >> m;

        for (int k = 0; m > 0; ++k) {
            int c = std::min(m, 1 << k);
            for (int j = W; j - w * c >= 0; --j) {
                dp[j] = std::max(dp[j], dp[j - w * c] + v * c);
            }
            m -= c;
        }
    }

    std::cout << *std::max_element(dp.begin(), dp.end()) << std::endl;
    return 0;
}



Measured memory_bytes: 3124
import sys
n=int(input())
a=list(map(int,input().split()))

if 0 in a:
    print('0')
    sys.exit()

c=1

for i in range(n):
    c*=a[i]
    if c>10**18:
        print('-1')
        sys.exit()
    else:
        continue

print(c)

Measured memory_bytes: 21692
#include<cstdio>
#include<iostream>
#include<string>
#include<algorithm>
#include<stdio.h>
#include<locale.h>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long int ll;
const ll cs=1000000000;
//15
bool z[1000]={};

int main()
{
 int N;
 string s;
 scanf("%d",&N); cin>>s;
 bool dig1[10]={};
 for(int i=0;i<(N-2);i++)
 {
	int d1=s[i]-'0';
	if(!dig1[d1])
	{
		dig1[d1]=true;
		bool dig2[10]={};
		for(int j=i+1;j<(N-1);j++)
		{
			int d2=s[j]-'0';
			if(!dig2[d2])
			{
				dig2[d2]=true;
				for(int k=j+1;k<N;k++)
				{
					int d3=s[k]-'0';
					int d=d1*100+d2*10+d3;
					z[d]=true;
				}
			}
		}
	}
 }
 int ans=0;
 for(int i=0;i<1000;i++)
 {
	if(z[i]){ans++;}
 }
 printf("%d",ans);
}

Measured memory_bytes: 3800
#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused_imports)]
use std::collections::{HashMap, HashSet};

mod util {
    use std::io::stdin;
    use std::str::FromStr;
    use std::fmt::Debug;

    #[allow(dead_code)]
    pub fn line() -> String {
        let mut line: String = String::new();
        stdin().read_line(&mut line).unwrap();
        line.trim().to_string()
    }

    #[allow(dead_code)]
    pub fn get<T: FromStr>() -> T
    where
        <T as FromStr>::Err: Debug,
    {
        let mut line: String = String::new();
        stdin().read_line(&mut line).unwrap();
        line.trim().parse().unwrap()
    }

    #[allow(dead_code)]
    pub fn gets<T: FromStr>() -> Vec<T>
    where
        <T as FromStr>::Err: Debug,
    {
        let mut line: String = String::new();
        stdin().read_line(&mut line).unwrap();
        line.split_whitespace()
            .map(|t| t.parse().unwrap())
            .collect()
    }
}

fn main() {
    let nm: Vec<usize> = util::gets();
    let ab: Vec<(usize, usize)> = (0..nm[1])
        .map(|_| {
            let ab: Vec<usize> = util::gets();
            (ab[0] - 1, ab[1] - 1)
        })
        .collect();

    let mut from_1 = vec![false; nm[0]];
    let mut to_n = vec![false; nm[0]];

    for &(a, b) in &ab {
        if a == 0 {
            from_1[b] = true;
        }
        if b == nm[0] - 1 {
            to_n[a] = true;
        }
    }

    if (0..nm[0]).any(|i| from_1[i] && to_n[i]) {
        println!("POSSIBLE");
    } else {
        println!("IMPOSSIBLE");
    }
}


Measured memory_bytes: 8444
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,a[32]={1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51};
    cin>>n;
    cout<<a[n-1]<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main() {
  int n, k;
  scanf("%d%d", &n, &k);
  int p[n];
  for (int i = 0; i < n; i++) {
    scanf("%d", &p[i]);
  }

  int sum = 0;
  for (int i = 0; i < k; i++) {
    sum += p[i];
  }
  int max = sum;
  if (n > k) {
    for (int i = 0; i < n - k; i++) {
      sum = sum - p[i] + p[i + k];
      if (sum > max) {
        max = sum;
      }
    }
  }
  double d = (max + k) / 2.0;
  printf("%f\n", d);
  return 0;
}

Measured memory_bytes: 896
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n,k;
  cin>>n>>k;
  int a[n];
  int c=0;
  for(int i=0;i<n;++i)
   cin>>a[i];
  long long ans=9999999999;
  for(int i=0;i<n-k+1;++i)
  { 
    long long x=min(abs(a[i])+abs(a[i+k-1]-a[i]),abs(a[i+k-1])+abs(a[i+k-1]-a[i]));
    ans=min(ans,x);
  }
 cout<<ans<<endl;
            return 0;
  
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define ll long long
#define INF 1000000005
#define MOD 1000000007
#define EPS 1e-10
#define rep(i,n) for(int i=0;i<n;++i)

using namespace std;

typedef pair<int,int>P;

const int MAX_N = 102;
const int MAX_D = 100005;

int a[MAX_N];
int n,k,t,u,v,l;
int flag[MAX_D];

int main()
{
	scanf("%d%d%d%d%d%d",&n,&k,&t,&u,&v,&l);
	rep(i,n){
		scanf("%d",&a[i]);
        flag[a[i]] = 1;
	}
    double res = 0;
    double rem_t = 0;
    int cnt = 0;
    rep(i,l){
        if(flag[i] == 1){
            if(rem_t < EPS){
                rem_t = t - 1.0 / v;
                res += 1.0 / v;
            }else{
                if(cnt == k){
                    rem_t = t - 1.0 / v;
                    res += 1.0 / v;
                }else{
                    cnt++;
                    rem_t -= 1.0 / v;
                    res += 1.0 / v;
                }
            }
        }else{
            if(rem_t > EPS){
                res += 1.0 / v;
                rem_t -= 1.0 / v;
            }else{
                if(cnt > 0){
                    rem_t = t - 1.0 / v;
                    res += 1.0 / v;
                    cnt--;
                }else{
                    res += 1.0 / u;
                }
            }
        }
    }
    printf("%.10f\n",res);
	return 0;
}

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

int main()
{
    string s1, s2, s3;
    cin >> s1 >> s2 >> s3;
    s1[0] = s1[0] - 'a' + 'A';
    s2[0] = s2[0] - 'a' + 'A';
    s3[0] = s3[0] - 'a' + 'A';
    cout << s1[0] << s2[0] << s3[0] << endl;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline

n, q = map(int, input().split())
C = [0] + list(map(int, input().split()))
D = [-1]*(n+1)
A = [0]*q
U = 10**6
LR = tuple(tuple(map(int, input().split())) for _ in range(q))
W = sorted(r*U+i for i, (l, r) in enumerate(LR))
B = [0]*(1<<n.bit_length())
def add(i, a):
  while i <= n:
    B[i] += a
    i += i & -i
def acc(i):
  res = 0
  while i:
    res += B[i]
    i -= i & -i
  return res
temp = 1
for w in W:
  r, i = divmod(w, U)
  while temp <= r:
    c = C[temp]
    add(temp, 1)
    if D[c] != -1:
      add(D[c], -1)
    D[c] = temp
    temp += 1
  l = LR[i][0]
  A[i] = acc(r) - acc(l-1)
print(*A, sep="\n")

Measured memory_bytes: 227128
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;

namespace AtCoder
{
    class Program
    {
        static public int[] Sarray() { return ReadLine().Split().Select(int.Parse).ToArray(); }
        static public List<int> Slist() { return ReadLine().Split().Select(int.Parse).ToList(); }
 
        static void Main(string[] args)
        {
            var N = Slist()[0];
            var D = Slist();
            D.Insert(0, 0);
            D.Sort();
            if (23 < N)
            {
                WriteLine(0);
                return;
            }
            var pos = new int[13];
            for (var i = 0; i < D.Count; ++i)
                ++pos[D[i]];
            if (2 <= pos[0] || 2 <= pos[12])
            {
                WriteLine(0);
                return;
            }
            for (var i = 1; i < 12; ++i)
                if (3 <= pos[i])
                {
                    WriteLine(0);
                    return;
                }

            var org = new int[24];
            for (var i = 0; i <= 12; ++i)
            {
                if (pos[i] == 1)
                    org[i] = 1;
                else if (pos[i] == 2)
                {
                    org[i] = 1;
                    org[24 - i] = 1;
                }
            }
            var maxs = 0;
            for (var k = 0; k < Math.Pow(2, 12); ++k)
            {
                var mins = int.MaxValue;
                var cpy = new int[24];
                org.CopyTo(cpy, 0);
                var f = false;
                for (var i = 1; i < 12; ++i)
                    if (((k >> i) & 1) == 1)
                    {
                        if (pos[i] == 1)
                        {
                            cpy[i] = 0;
                            cpy[24 - i] = 1;
                        }
                    }

                for (var i = 0; i < 23; ++i)
                    for (var j = i + 1; j < 24; ++j)
                    {
                        if (cpy[i] != 0 && cpy[j] != 0)
                        {
                            var t = j - i;
                            if (12 < t) t = 24 - t;
                            mins = Math.Min(mins, t);
                        }
                    }
                maxs = Math.Max(maxs, mins);
            }
            WriteLine(maxs);
        }
    }
}


Measured memory_bytes: 13396
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <cmath>
#include <climits>

#include <sstream>
#include <iostream>
#include <iomanip>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <queue>
#include <stack>
#include <utility>
#include <vector>
#include <functional>
#include <algorithm>

using namespace std;

#define fast_cin() ios_base::sync_with_stdio(false)

typedef long double ld;
typedef long long ll;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;

int isPrime(int x);
int powerOf(int p, int N);

const ll mod = 1e9 + 7;

int main()
{
	int N;
	cin >> N;
	ll ans = 1;
	for (int i = 2; i <= N; ++i) {
		if (isPrime(i)) {
			ans *= (powerOf(i, N) + 1);
			ans %= mod;
		}
	}
	cout << ans << endl;
}

int isPrime(int x)
{
	int R = sqrt(x);
	for (int i = 2; i <= R; ++i) {
		if (x % i == 0) {
			return 0;
		}
	}
	return 1;
}

int powerOf(int p, int N)
{
	int ans = 0, res = p;
	while(res <= N) {
		ans += N / res;
		res *= p;
	}
	return ans;
}


Measured memory_bytes: 256
// 2011/09/21 Tazoe

#include <iostream>
#include <string>
using namespace std;

int main()
{
	string S;
	cin >> S;

	for(int i=0; i<S.size(); i++)
		if(S[i]>='D'&&S[i]<='Z')
			S[i] -= 3;
		else if(S[i]>='A'&&S[i]<='C')
			S[i] += 23;

	cout << S << endl;

	return 0;
}

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

typedef long long ll;

int main(){
  int N;
  cin >> N;
  map<char, bool> m;
  for(int i = 0; i < N; i++){
    char tmp;
    cin >> tmp;
    if(m.count(tmp) == 0){
      m[tmp] = true;
    }
  }
  
  if(m.size() == 4){
    cout << "Four" << endl;
  } else { 
    cout << "Three" << endl;
  }
}

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

namespace AtCoder2 {
	class Program {
		static void Main(string[] args) {

	
			var inputArray = retreiveLongArray();
			var inputCount = 1;

			// 不正な入力は処理しない
			if (inputArray.Length != inputCount) {
				Console.WriteLine("invalid input");
				return;
			}
			long N = inputArray[0];
			var numArray = retreiveLongArray();

			//0を含む場合は0を返す
			if (numArray.Contains(0)) {
				Console.WriteLine(0);
				return;
			}


			long ans = 1;
			var log10Ans = Math.Log10(ans);
			for (int i = 0; i < N; i++) {
				var log10I = Math.Log10(numArray[i]);

				if(log10Ans + log10I > 18) {
					Console.WriteLine(-1);
					return;
				}
				ans = ans * numArray[i];
				if (ans > 1000000000000000000) {
					Console.WriteLine(-1);
					return;
				}
				log10Ans = Math.Log10(ans);
			}

			//答えの出力
			Console.WriteLine(ans);

		}

		/// <summary>
		/// スペースで区切られた文字列配列の入力を受け取る
		/// </summary>
		/// <returns></returns>
		private static string[] retreiveStringArray() {
			var inputArray = Console.ReadLine().Split(' ');
			return inputArray;
		}

		/// <summary>
		/// スペースで区切られた整数配列の入力を受け取る
		/// </summary>
		/// <returns></returns>
		private static long[] retreiveLongArray() {
			var inputArray = Console.ReadLine().Split(' ');
			var longArray = inputArray.Select(s => long.Parse(s));
			return longArray.ToArray();
		}
	}
}

Measured memory_bytes: 41460