akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
int dp[(1<<13)+1];
int main(){
    int n, m, ch, tar, cur;
    cin>>n>>m;
    int price[m], arr[m];
    for (int i=0; i<m; i++){
        cin>>price[i]>>ch;
        cur=0;
        for (int j=0; j<ch; j++){
            cin>>tar;
            cur|=(1<<(tar-1));
        }
        arr[i]=cur;
        if (dp[cur]==0) dp[cur]=price[i];
        else dp[cur]=min(dp[cur], price[i]);
    }
    for (int i=0; i<=(1<<n)-1; i++){
        if (dp[i]==0) continue;
        for (int j=0; j<m; j++){
            cur=(i|arr[j]);
            if (dp[cur]==0) dp[cur]=dp[i]+price[j];
            else dp[cur]=min(dp[cur], dp[i]+price[j]);
        }
    }
    if (dp[(1<<n)-1]==0) cout<<"-1\n";
    else cout<<dp[(1<<n)-1]<<endl;
}

Measured memory_bytes: 256
#include <assert.h>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <algorithm>
#include <numeric>
#include <functional>
#include <iostream>
#include <string>
#include <array>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <complex>
#include <bitset>
typedef long long ll;
typedef unsigned long long ull;

#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define DEBUG(vec) for (auto v : vec) { cout << v << " "; } cout << endl;

using namespace std;

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

  ll a, b;
  cin >> a >> b;
  if (a > 0 && b > 0) {
    cout << "Positive" << endl;
  } else if (a <= 0 && 0 <= b) {
    cout << "Zero" << endl;
  } else {
    if ((b - a) % 2 == 0) {
      cout << "Negative" << endl;
    } else {
      cout << "Positive" << endl;
    }
  }
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<string>
#include<math.h>
#include<vector>
#include<iomanip>
using namespace std;

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

Measured memory_bytes: 888
#include <bits/stdc++.h>
using namespace std;
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long

const int N=1e5+5;

int n, k, ans=1e18;
int a[N];
vector<int> pos, neg;

int32_t main()
{
	IOS;
	cin>>n>>k;
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
		if(a[i]>=0)
			pos.push_back(a[i]);
		else
			neg.push_back(a[i]);
	}
	if(neg.size())
	reverse(neg.begin(), neg.end());
	for(int i=1;i<k;i++)
	{
		if(pos.size()<i)
			continue;
		if((int)neg.size()<k-i)
			continue;
		int cur=pos[i-1] + abs(neg[k-i-1]) + min(pos[i-1], abs(neg[k-i-1]));
		ans=min(ans, cur);
	}
	if(pos.size()>=k)
		ans=min(ans, pos[k-1]);
	if(neg.size()>=k)
		ans=min(ans, abs(neg[k-1]));
	cout<<ans;
	return 0;
}

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

int sosu(int n){
    int y = 0, A[10000];
    for(int i = 0; i < n; i++)cin >> A[i];
    for(int i = 0; i < n; i++){
        int s = 1;
        for(int j = 2; j <= sqrt(A[i]); j++){
            if(A[i] % j == 0){
                s = 0;
                break;
            }
        }
        if(s != 0 ){
            y = y + 1;         
        } 
    }
    return y;
           
}

int main(){
    int n;
    cin >> n ;
    
    cout << sosu(n) << endl;
    return 0;
}


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

namespace AtCoder
{
    class Program
    {
        static long[] Sarray() { return ReadLine().Trim().Split().Select(long.Parse).ToArray(); }
        static List<long> Slist() { return ReadLine().Trim().Split().Select(long.Parse).ToList(); }

        static void Main(string[] args)
        {
            var N = Sarray()[0];
            WriteLine(N * N * N);
        }
    }
}


Measured memory_bytes: 11348
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <functional>

#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define repi(i,a,b) for(int i = (a); i < (b); i++)

using namespace std;

typedef    long long          ll;
typedef    unsigned long long ull;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      pii;

const int INF=1<<29;
const double EPS=1e-9;

const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};
int vote[1010];
int cost[1010];

int main(){
	int n,m;
	cin>>n>>m;
	memset(vote, 0, sizeof(vote));
	memset(cost, 0, sizeof(cost));
	rep(i, n){
		cin>>cost[i];
	}
	rep(i, m){
		int x;
		cin>>x;
		rep(j, n){
			if(cost[j]<=x){
				vote[j]++;
				break;
			}
		}
	}
	int cnt = 0;
	int ans = 0;
	rep(i, n){
		if(vote[i]>=cnt){
			cnt =vote[i];
			ans=i;
		}
	}
	cout <<ans+1<<endl;
	return 0;
}

Measured memory_bytes: 1172
#include <iostream> 
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mk make_pair
#define MAX 1000001
ll prime[MAX];
#define FAST           ios_base::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL);
#define mod 1000000007
#define gcd __gcd
// ll rec(vector<vector<ll> >& dp,vector<ll>& arr,int n,int i,int k,int w)
// {
//   ll ans=0;
//   if(i>=n)
//     return 0;

//   if(dp[i][k]!=-1)
//     return dp[i][k];


//   if(k!=0)
//   ans=max(rec(dp,arr,n,i+1,w,w),arr[i]+rec(dp,arr,n,i+1,k-1,w));
//   else
//   ans=max(rec(dp,arr,n,i+1,k,w),rec(dp,arr,n,i+1,w,w));

//   return dp[i][k]=ans;

// }

//ll t[400008];
// void build(vector<ll>& a, int v, int tl, int tr) {
//     if (tl == tr) {
//         t[v] = a[tl];
//     } else {
//         int tm = (tl + tr) / 2;
//         build(a, v*2, tl, tm);
//         build(a, v*2+1, tm+1, tr);
//         t[v] = max(t[v*2] ,t[v*2+1]);
//     }
// }

// ll maxi(int v, int tl, int tr, int l, int r) {
//     if (l > r) 
//         return 0;
//     if (l == tl && r == tr) {
//         return t[v];
//     }
//     int tm = (tl + tr) / 2;
//     return max(maxi(v*2, tl, tm, l, min(r, tm)) ,maxi(v*2+1, tm+1, tr, max(l, tm+1), r));
// }



// void update(int v, int tl, int tr, int pos, ll new_val) {
//     if (tl == tr) {
//         t[v] = new_val;
//     } else {
//         int tm = (tl + tr) / 2;
//         if (pos <= tm)
//             update(v*2, tl, tm, pos, new_val);
//         else
//             update(v*2+1, tm+1, tr, pos, new_val);
//         t[v] = max(t[v*2] ,t[v*2+1]);
//     }
// }


struct hash_pair {
   template <class T1, class T2>
   size_t operator()(const pair<T1, T2>& p) const{
      auto hash1 = hash<T1>{}(p.first);
      auto hash2 = hash<T2>{}(p.second);
      return hash1 ^ hash2;
   }
};


int temp[1000002]={0};

void sieve()
{
  temp[1]=1;
  for(int i=2;i<1000002;i++)
  {
    if(temp[i]==0)
    { temp[i]=i;
      for(int j=i*2;j<1000002;j+=i)
      { 
        if(temp[j]==0)
        temp[j]=i;
      }
    }
  }

}

int dfs(int i,vector<vector<int> > &g,vector<int>& p,vector<int>& c)
{
  int sub=1;
  for(auto x:g[i])
  {
    if(p[i]!=x)
    {
      p[x]=i;
      sub+=dfs(x,g,p,c);
    }
  }

  return c[i]=sub;
}


int main() { 

int n;
cin>>n;
ll a[n][2];

ll m1=INT_MAX,m2=INT_MIN,m3=INT_MAX,m4=INT_MIN;
for(int i=0;i<n;i++)
{
  cin>>a[i][0]>>a[i][1];
  m2=max(m2,a[i][0]+a[i][1]);
  m1=min(m1,a[i][0]+a[i][1]);
  
  m4=max(m4,a[i][0]-a[i][1]);
  m3=min(m3,a[i][0]-a[i][1]);
}

cout<<max(abs(m2-m1),abs(m3-m4));

return 0;
}
/*
1
4
1 2
2 3
3 4
*/


Measured memory_bytes: 6744
#include <bits/stdc++.h>
#include <iomanip>
#include <math.h>
#include <unistd.h>
#include <stdio.h>
#define rep(i,x) for(ll i = 0;i<x;i++)
#define all(a) (a).begin(),(a).end()
#define vecin(a) rep(i,a.size())cin >> a[i]
#define vecout(a) rep(i,a.size())cout << a[i] << " ";cout << "\n"
#define vecvec(a) vector<vector<(a)>>
using ll = long long;
using ld = long double;
using namespace std;
using dou = double;
const ll inf = 2147483647;
const ll INF = 1LL << 60;
const ld pi = 3.14159265358;
const ll mod = 1000000007;
typedef pair<ll,ll> P;
using graph = vector<vector<ll>>;
template<class T> inline bool chmax(T& a, T b){if(a < b){a = b; return true;}return false;}
template<class T> inline bool chmin(T& a, T b){if(a > b){a = b; return true;}return false;}
template<class T> inline bool change(T a,T b){if(a > b){swap(a,b);return true;}return false;}
ll gcd(ll a,ll b){
    if(a < b)swap(a,b);
    if(a % b == 0)return b;
    else return gcd(b,a%b);
}
//素数判定O(sqrt(N))
bool isp(ll n){
    bool res = true;
    if(n == 1)return false;
    else{
        for(ll i = 2;i * i <= n;i++){
            if(n % i == 0){
                res = false;
                break;
            }
        }
        return res;
    }
}
const ll cmax = 1000000;
ll fac[cmax], finv[cmax], inv[cmax];

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

// 二項係数計算
ll nCk(ll n, ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
}
//nのm乗をMODで割ったあまりO(logN)
ll modpow(ll n,ll m,ll MOD){
    ll res = 1;
    while(m){
        if(m & 1)res = (res * n) % MOD;
        m >>= 1;
        n *= n;
        n %= MOD;
    }
    return res;
}

//printf("%.10f\n", N);
/*  vector<ll> vec = {1,2,5,6,8,9,10};
    cout << binary_search(all(vec),5) << endl; -> true*/
/*
    vector<ll> vec = {1,2,5,6,8,9,10};
    auto n = upper_bound(all(vec),4);
    cout << *n << endl; -> 5*/

//    cout << fixed << setprecision(15);
struct edge{ll to,cost;};
ll N;const ll NMAX = 100005LL;
vector<edge> G[NMAX];
vector<ll> dist(NMAX,INF);
void dfs(ll from,ll par,ll d){
    dist[from] = d;
    for(auto x : G[from]){
        if(x.to != par){
            dfs(x.to,from,d + x.cost);
        }
    }
}
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll A,B,C,D;
    cin >> A >> B >> C >> D;
    if(min(B,D) - max(A,C) >= 0)
    cout << min(B,D) - max(A,C) << endl;
    else cout << 0 << endl;
}

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

template <int MOD>
struct ModInt {
    using lint = long long;
    int val;

    // constructor
    ModInt(lint v = 0) : val(v % MOD) {
        if (val < 0) val += MOD;
    };

    // unary operator
    ModInt operator+() const { return ModInt(val); }
    ModInt operator-() const { return ModInt(MOD - val); }
    ModInt inv() const { return this->pow(MOD - 2); }

    // arithmetic
    ModInt operator+(const ModInt& x) const { return ModInt(*this) += x; }
    ModInt operator-(const ModInt& x) const { return ModInt(*this) -= x; }
    ModInt operator*(const ModInt& x) const { return ModInt(*this) *= x; }
    ModInt operator/(const ModInt& x) const { return ModInt(*this) /= x; }
    ModInt pow(lint n) const {
        auto x = ModInt(1);
        auto b = *this;
        while (n > 0) {
            if (n & 1) x *= b;
            n >>= 1;
            b *= b;
        }
        return x;
    }

    // compound assignment
    ModInt& operator+=(const ModInt& x) {
        if ((val += x.val) >= MOD) val -= MOD;
        return *this;
    }
    ModInt& operator-=(const ModInt& x) {
        if ((val -= x.val) < 0) val += MOD;
        return *this;
    }
    ModInt& operator*=(const ModInt& x) {
        val = lint(val) * x.val % MOD;
        return *this;
    }
    ModInt& operator/=(const ModInt& x) { return *this *= x.inv(); }

    // compare
    bool operator==(const ModInt& b) const { return val == b.val; }
    bool operator!=(const ModInt& b) const { return val != b.val; }

    // I/O
    friend std::istream& operator>>(std::istream& is, ModInt& x) noexcept { return is >> x.val; }
    friend std::ostream& operator<<(std::ostream& os, const ModInt& x) noexcept { return os << x.val; }
};

template <class T>
struct Combination {
    int max_n;
    std::vector<T> f, invf;

    explicit Combination(int n)
        : max_n(n), f(n + 1), invf(n + 1) {
        f[0] = 1;
        for (int i = 1; i <= n; ++i) {
            f[i] = f[i - 1] * i;
        }

        invf[max_n] = f[max_n].inv();
        for (int i = max_n - 1; i >= 0; --i) {
            invf[i] = invf[i + 1] * (i + 1);
        }
    }

    T fact(int n) const { return f[n]; }
    T invfact(int n) const { return invf[n]; }
    T perm(int a, int b) const {
        return a < b || b < 0 ? T(0) : f[a] * invf[a - b];
    }
    T comb(int a, int b) const {
        return a < b || b < 0 ? T(0) : f[a] * invf[a - b] * invf[b];
    }
};

constexpr int MOD = 1e9 + 7;
using mint = ModInt<MOD>;

const Combination<mint> C(200000);

void solve() {
    int n;
    mint a, b, c;
    std::cin >> n >> a >> b >> c;
    a /= 100, b /= 100, c /= 100;
    a /= mint(1) - c, b /= mint(1) - c;

    mint ans = 0;
    for (int k = 0; k < n; ++k) {
        ans += C.comb(n + k - 1, k) *
               (a.pow(n) * b.pow(k) + a.pow(k) * b.pow(n)) *
               (n + k);
    }

    ans /= mint(1) - c;
    std::cout << ans << std::endl;
}

int main() {
    std::cin.tie(nullptr);
    std::cout.tie(nullptr);
    std::ios::sync_with_stdio(false);

    solve();

    return 0;
}


Measured memory_bytes: 1792
//SAIKH SERAJ FAHIM, CSE-HSTU, DINAJPUR, BANGLADESH.

#include<bits/stdc++.h>
using namespace std;
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int a,d;
    cin>>a;
    string s=to_string(a);
    d=s.size()-1;
    if(s[d]=='0' || s[d]=='1' || s[d]=='6' || s[d]=='8')
        cout<<"pon"<<"\n";
    else if(s[d]=='2' || s[d]=='4' || s[d]=='5' || s[d]=='7' || s[d]=='9')
        cout<<"hon"<<"\n";
    else
        cout<<"bon"<<"\n";
    return 0;
}


Measured memory_bytes: 3716
import java.util.Scanner;

public class Main {
    static final int N = 1000;

    public static void main(String... args) {
        double[] x = new double[N + 1];
        double[] y = new double[N + 1];
        x[0] = 1.0;
        y[0] = 0.0;
        for (int i = 1; i <= N; i++) {
            double r = Math.sqrt((double) i);
            x[i] = x[i - 1] - (y[i - 1] / r);
            y[i] = y[i - 1] + (x[i - 1] / r);
        }
        Scanner sc = new Scanner(System.in);
        while (true) {
            int k = sc.nextInt();
            if (k <= 0) break;
            System.out.println(String.format("%.2f\n%.2f", x[k - 1], y[k - 1]));
        }
    }
}

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

int main() {
    long long N;
    cin >> N;
    queue<pair<long long, long long>> P;
    for (long long i = 2; i * i <= N; i++) {
        if (N % i != 0) {
            continue;
        }
        long long count = 0;
        while (N % i == 0) {
            count++;
            N /= i;
        }
        P.push(make_pair(i, count));
    }
    if (N != 1) {
        P.push(make_pair(N, 1));
    }
    long long ans = 0;
    while (!P.empty()) {
        long long A = P.front().second, B = 1, count = 0;
        P.pop();
        while (B <= A) {
            A -= B;
            B++;
            count++;
        }
        ans += count;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3648
#include <stdio.h>
int main(void) {
    int num,floor[100][100][3],i,j,k,jump[2],count;
    while (1) {
        scanf("%d",&num);
        if (num==0) break;
        for (i=0; i<num; i++) {
            for (j=0; j<num; j++) {
                scanf("%d %d",&floor[j][i][0],&floor[j][i][1]);
                floor[j][i][2]=0;
            }
        }
        int check[num*num][2],sp;
        count=0;
        for (i=0; i<num; i++) {
            for (j=0; j<num; j++) {
                jump[0]=j,jump[1]=i,sp=0;
                if (floor[jump[0]][jump[1]][2]==0) {
                    while (floor[jump[0]][jump[1]][2]==0) {
                        floor[jump[0]][jump[1]][2]=1;
                        check[sp][0]=jump[0];
                        check[sp][1]=jump[1];
                        sp++;
                        jump[0] = floor[check[sp-1][0]][check[sp-1][1]][0];
                        jump[1] = floor[check[sp-1][0]][check[sp-1][1]][1];
                    }
                    for (k=0; k<sp; k++) {
                        if (check[k][0]==jump[0]&&check[k][1]==jump[1]) {
                            count++;
                            break;
                        }
                    }
                }
            }
        }
        printf("%d\n",count);
    }
    return 0;
}

Measured memory_bytes: 728
import java.util.*;


class Main {
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);

        while (true){

        int n=sc.nextInt();
        int x=sc.nextInt();
        if (n==0&&x==0){break;}

        int s=0;
            for(int y=1;y<=n;y++) {
            for (int w = 1+y; w <= n; w++) {
                for (int v = 1+w; v <= n; v++) {
                    if(y+w+v==x){s++;}
                       }
                   }
               }

               System.out.println(s); }
        }
    }
    
    
    


Measured memory_bytes: 26788
using System;
using System.Collections.Generic;
using System.Collections;
using System.Collections.Specialized;
using System.Linq;
using System.Text;
using System.IO;
using System.Reflection;
using static System.Math;
using System.Numerics;
static class Program{
	const int mod=(int)1e9+7;
	const double eps=1e-11;
	static void Main(){
		Sc sc=new Sc();
		var s=sc.Ia;
		var h=new int[s[0]+1];
		var w=new int[s[1]+1];
		var a=new int[s[2]][];
		var hs=new HashSet<int>[s[0]+1];
		for(int i = 1;i<=s[0];i++) {
			hs[i]=new HashSet<int>();
		}
		int p=0,u=0;
		for(int i = 0;i<s[2];i++) {
			a[i]=sc.Ia;
			h[a[i][0]]++;
			w[a[i][1]]++;
			p=Max(p,h[a[i][0]]);
			u=Max(u,w[a[i][1]]);
			hs[a[i][0]].Add(a[i][1]);
		}
		int z=0;
		for(int i = 1;i<=s[1];i++) {
			if(w[i]==u){
				z++;
			}
		}
		var g=new int[s[1]+1];
		for(int i = 1;i<=s[0];i++) {
			if(h[i]==p){
				int d=0;
				foreach(var e in hs[i]){
					if(w[e]==u){
						d++;
					}
				}
				if(d<z){
					Console.WriteLine(p+u);
					return;
				}
			}
		}
		Console.WriteLine(p+u-1);
	}
}
public class Sc{
	public int I{get{return int.Parse(Console.ReadLine());}}
	public long L{get{return long.Parse(Console.ReadLine());}}
	public double D{get{return double.Parse(Console.ReadLine());}}
	public string S{get{return Console.ReadLine();}}
	public int[] Ia{get{return Array.ConvertAll(Console.ReadLine().Split(),int.Parse);}}
	public long[] La{get{return Array.ConvertAll(Console.ReadLine().Split(),long.Parse);}}
	public double[] Da{get{return Array.ConvertAll(Console.ReadLine().Split(),double.Parse);}}
	public string[] Sa{get{return Console.ReadLine().Split();}}
	public object[] Oa{get{return Console.ReadLine().Split();}}
	public int[] Ia2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),int.Parse);}}
	public int[] Ia3(string a,string b){return Array.ConvertAll((a+Console.ReadLine()+b).Split(),int.Parse);}
	public int[] Ia3(int a){return Array.ConvertAll((Console.ReadLine()+" "+a.ToString()).Split(),int.Parse);}
	public long[] La2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),long.Parse);}}
	public long[] La3(string a,string b){return Array.ConvertAll((a+Console.ReadLine()+b).Split(),long.Parse);}
	public long[] La3(int a){return Array.ConvertAll((Console.ReadLine()+" "+a.ToString()).Split(),long.Parse);}
	public double[] Da2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),double.Parse);}}
	public double[] Da3(string a,string b){return Array.ConvertAll((a+Console.ReadLine()+b).Split(),double.Parse);}
	public T[] Arr<T>(int n,Func<T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f();}return a;}
	public T[] Arr<T>(int n,Func<int,T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(i);}return a;}
	public T[] Arr<T>(int n,Func<string[],T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(Console.ReadLine().Split());}return a;}
	public T[] Arr<T>(int n,Func<int,string[],T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(i,Console.ReadLine().Split());}return a;}
}

Measured memory_bytes: 112312
nk  = list(map(int,input().split()))
p = list(map(int,input().split()))
s = [0] * (nk[0])
for j in range(nk[1]):
    s[0] += p[j]

for i in range(nk[0]-nk[1]):
    s[i+1] = s[i] - p[i] + p[i+nk[1]]

print((max(s)+nk[1])/2)



Measured memory_bytes: 25060
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <list>
#include <algorithm>
#include <queue>
#include <cmath>
#include <iomanip>
#include <cstdlib>
// #include <fstream>
// #include <iomanip>
// std::cout << std::fixed << std::setprecision(5);
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

const long long mod = 1e9 + 7;
const int INF32 = INT32_MAX;

int main()
{
    std::cout << std::fixed << std::setprecision(12);
    int L; std::cin >> L;
    std::cout << pow(L, 3) / 27.0 << std::endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
    using namespace std;
     
    bool myfunction( char i, char j ){
    	return (i>j); 
    }
     
    int main(){
    	string s, t;
    	cin >> s >> t;
     
    	sort(s.begin(), s.end());
    	sort(t.begin(), t.end(), myfunction);
    	
    	if( s < t )
    		cout << "Yes" << endl;
    	else
    		cout << "No" << endl;
    	return 0;
    }

Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Tarek
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        DSumOfLargeNumbers solver = new DSumOfLargeNumbers();
        solver.solve(1, in, out);
        out.close();
    }

    static class DSumOfLargeNumbers {
        final static int MOD = 1000000007;

        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            int m = in.nextInt();
            long ans = 0, pre = 0, suf = 0;
            for (int i = 1; i <= n + 1; i++) {
                pre += i - 1;
                suf += n + 1 - i;
                pre %= MOD;
                suf %= MOD;
                if (i >= m) {
                    ans += suf - pre + 1 + MOD;
                    ans %= MOD;
                }
            }
            out.println(ans);
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}



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

//階乗,二項係数
//*
ll fact[2000010];
ll invfact[2000010];
void makefact(int n,ll m){
	n=min(n,m-1);
	fact[0]=1;
	rep(i,0,n)fact[i+1]=fact[i]*(i+1)%m;
	invfact[n]=invp(fact[n],m);
	for(int i=n;i>0;i--)invfact[i-1]=invfact[i]*i%m;
}
ll choose(int n,int r,int m){return n<0||r<0||n-r<0?0:fact[n]*invfact[r]%m*invfact[n-r]%m;}
//*/

char s[1000010];
int main(){
	makefact(2000005,MOD);
	int k;
	scanf("%d %s",&k,s);
	int n=strlen(s);
	
	ll ans=0;
	rep(i,0,k+1){
		//末尾にi個
		ans+=choose(k-i+n-1,n-1,MOD)*pom(25,k-i,MOD)%MOD*pom(26,i,MOD)%MOD;
	}
	printf("%lld",ans%MOD);
}

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

int main()
{
	int N,ans=0;
	cin >> N;
	vector<int> a(N+1, 0);
	for (int i=1; i <= N; ++i){
		cin >> a[i];
	}
	for (int i = 1; i <= N; ++i){
		if (a[i]>i){
			if (a[a[i]] == i){
				++ans;
			}
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 640
#include <stdio.h>
#include <stdlib.h>

int main(void)
{
    long long int sum,min=9223372036854775807;
    int N,X[200],i,j,min_i;

    scanf("%d",&N);
    for(i=0; i<N; i++){
        scanf("%d",&X[i]);
    }

    for(i=1; i<=100; i++){
        sum = 0;
        for(j=0; j<N; j++){
            sum += (i-X[j])*(i-X[j]);
            //printf("i=%d,  j=%d, abs(i-X[%d])=%d\n",i,j,j,abs(i-X[j]));
        }

        if(min > sum){
            min = sum;
            min_i = i;
        }
    }

    //printf("%d\n",min_i);

    sum = 0;
    for(i=0; i<N; i++){
        sum += (min_i-X[i])*(min_i-X[i]);
    }
    
    printf("%lld\n",sum);

    return 0;
}

Measured memory_bytes: 128
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <chrono>
#define _USE_MATH_DEFINES
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iostream>
#include <iterator>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;

#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()

const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-8;
const int MOD = 1000000007; // 998244353;
const int dy[] = {1, 0, -1, 0}, dx[] = {0, -1, 0, 1};
/*-------------------------------------------------*/
int main() {
  cin.tie(0); ios::sync_with_stdio(false);
  // freopen("input.txt", "r", stdin);

  int h, w; cin >> h >> w;
  vector<vector<char> > s(h, vector<char>(w)); REP(i, h) REP(j, w) cin >> s[i][j];
  int ans = 0;
  vector<int> tate(w, 0);
  REP(j, w) {
    REP(i, h) {
      if (s[i][j] == '#') break;
      else ++tate[j];
    }
  }
  REP(i, h) {
    int yoko = 0;
    REP(j, w) {
      if (s[i][j] == '#') break;
      else ++yoko;
    }
    REP(j, w) {
      if (s[i][j] == '#') {
        yoko = 0;
        FOR(k, j + 1, w) {
          if (s[i][k] == '#') break;
          else ++yoko;
        }
        tate[j] = 0;
        FOR(k, i + 1, h) {
          if (s[k][j] == '#') break;
          else ++tate[j];
        }
        // cout << "# ";
      } else {
        ans = max(ans, tate[j] + yoko - 1);
        // cout << tate[j] + yoko << ' ';
      }
    }
    // cout << '\n';
  }
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 4224
#include<algorithm>
#include<cstring>
#include<cmath>
#include<queue>
#include<vector>
#include<cstdio>
#include<iomanip>
#include<map>
#include<iostream>
using namespace std;
int a,b,k;
int main(){
	cin>>a>>b>>k;
	for(int i=1;i<=k;i++){
		if(i%2==1){
			if(a%2==1)a--;
			b+=a/2;
			a/=2;
	    }
	    else {
	    	if(b%2==1)b--;
	    	a+=b/2;
	    	b/=2;
		}
	}
	cout<<a<<" "<<b;
    return 0;
}



Measured memory_bytes: 256
N = int(input())
S = str(input())
S = list(S)

if N % 2 == 1:
    print('No')
else:
    M = N // 2
    A = []
    for i in range(M):
        A.append(S[i])
    B = []
    for i in range(M,N):
        B.append(S[i])
        
    if A == B:
        print('Yes')
    else:
        print('No')
        
        

Measured memory_bytes: 3060
N = int(input())
arms = []
ans = 1
for i in range(N):
    X,L = (int(x) for x in input().split())
    arms.append((X-L,X+L))
arms.sort(key=lambda x:x[1])
limit = arms[0][1]
for x in arms[1:]:
    if x[0] < limit:
        continue
    else:
        limit = x[1]
        ans += 1
print(ans)

Measured memory_bytes: 18296
using System;

namespace atCodeTest
{
    class Program
    {
        static void Main(string[] args)
        {
            string a = Console.ReadLine();
            string b = Console.ReadLine();

            int c = 6 - (Convert.ToInt32(a) + Convert.ToInt32(b));
            Console.WriteLine(c);
        }
    }
}


Measured memory_bytes: 11220
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <cmath>
#include <iomanip>
#include <algorithm>
using namespace std;
using ll = long long;

int main(){
    string s1, s2, s3;
    cin >> s1 >> s2 >> s3;
    transform(s1.cbegin(), s1.cend(), s1.begin(), towupper);
    transform(s2.cbegin(), s2.cend(), s2.begin(), towupper);
    transform(s3.cbegin(), s3.cend(), s3.begin(), towupper);
    cout << s1[0] << s2[0] << s3[0] << endl;
    return 0;
}


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

#define REP(i, n)    for (int i = 0;   i <  (int)n; i++)
#define REV(i, n)    for (int i = n-1; i >= (int)0; i--)
#define INF 1000000000

int H, W;
int dp[301][301];
int co[301][301];
char c[301][301];

int calc_dp(int w1, int w2)
{
  memset(co, 0, sizeof(co));
  REV(x, H)   REV(y, H)   co[x][y] = co[x+1][y+1] + (c[H-x-1][w1] == c[H-y-1][w2]);
  REP(x, H+1) REP(y, H+1) dp[x][y] = INF; dp[0][0] = 0;
  REP(x, H+1) REP(y, H+1) {
    if (x > 0) dp[x][y] = min(dp[x][y], dp[x-1][y] + co[x-1][y]);
    if (y > 0) dp[x][y] = min(dp[x][y], dp[x][y-1] + co[x][y-1]);
  }
  return dp[H][H];
}

int main()
{
  cin >> H >> W;
  REP(i, H) REP(j, W) cin >> c[i][j];

  int cost = 0;
  REP(w, W-1) cost += calc_dp(w, w+1);
  cout << cost << endl;

  return 0;
}

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

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

    if (N == 0) {
        cout << X << endl;
        return 0;
    }

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

    int min = 0;
    for (int i = 0; i < 100; i++ )
    {
        min = X - i;
        if ( p.end() == find(p.begin(), p.end(), min )) {
            break;
        }
        min = X + i;
        if ( p.end() == find(p.begin(), p.end(), min )) {
            break;
        }
    }
    cout << min << endl;

    return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

const ll mod = 1e9+7;

ll mod_pow(ll x, ll n){
    ll ret = 1;
    while(n){
        if(n&1) (ret*=x)%=mod;
        (x*=x)%=mod;
        n>>=1;
    }
    return ret;
}

ll mod_inv(ll x){
    return mod_pow(x,mod-2);
}

const int F = 300010;
ll f[F], invf[F];

ll C(ll n, ll r){
    if(r<0 || n-r<0) return 0;
    ll ret = f[n];
    (ret *= invf[r]) %= mod;
    (ret *= invf[n-r]) %= mod;
    return ret;
}

ll calc(ll m, ll p){
    ll ret = C(p+m,m);
    (ret *= (p+1-m))%=mod;
    (ret *= mod_inv(p+1))%=mod;
    return ret;
}

int main(){
    f[0] = 1;
    for(int i=1; i<F; ++i) f[i] = (f[i-1]*i)%mod;
    invf[F-1] = mod_inv(f[F-1]);
    for(int i=F-2; i>=0; --i) invf[i] = (invf[i+1]*(i+1))%mod;

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

    ll ans = 0;
    rep(i,k+1){
        int mx = i, px = n+mx;
        int my = k-i, py = m+my;
        int X = mx+px, Y = my+py;
        // printf(" %d:: %d %d\n",i,X,Y);
        ll add = C(X+Y,Y);
        (add *= calc(mx,px)) %= mod;
        (add *= calc(my,py)) %= mod;

        (ans += add) %= mod;
        // dbg(add);
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 7784
#include <iostream>
#include <cmath>
#include <vector>
using namespace std;

double p, T;
int N;

double dfs1(int node, double pp, int prev, vector<vector<pair<int, int>>> &Cost) {
  double e = 0;
  for (auto nn : Cost[node]) {
    if (nn.first == prev)
      continue;
    e += nn.second * pp;
    e += dfs1(nn.first, pp * p, node, Cost);
  }
  return e;
}

double dfs2(int node, double pp, int prev, vector<vector<pair<int, int>>> &Cost) {
  double e = 0;
  for (auto nn : Cost[node]) {
    if (nn.first == prev)
      continue;
    e += (nn.second + T) * pp;
    e += dfs2(nn.first, pp * p, node, Cost);
  }
  return e;
}

int main(void) {
  cin >> p >> N;

  vector<vector<pair<int, int>>> Cost(N);

  for (int i = 0; i < N - 1; i++) {
    int x, y, c;
    cin >> x >> y >> c;
    x--;
    y--;
    Cost[x].push_back(pair<int, int>(y, c));
    Cost[y].push_back(pair<int, int>(x, c));
  }

  T = dfs1(0, p, -1, Cost);

  double res = dfs2(0, p, -1, Cost) + T;
  printf("%.10f\n", res);

  return 0;
}

Measured memory_bytes: 16052
import java.util.Scanner;
public class Main{
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		while(scan.hasNext()){
			int m = scan.nextInt();
			int n = scan.nextInt();
			if(m == 0 && n == 0){
				break;
			}
			int max = 0;
			int t = 0;
			for(int i = 0;i < m;i++){
				t = 0;
				for(int j = 0;j < n;j++){
					t += (scan.nextInt() == 1)?1:0;
				}
				if(max < t){
					max = t;
				}
			}
			System.out.println(max);
		}
	}
}

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

#ifdef _DEBUG
#define debug(x) cerr << "line: " << __LINE__ << ", func: " << __func__ << " ->  " << #x << " = " << x << endl
#else
#define debug(x)
#endif

#define all(s) begin(s), end(s)
#define rall(s) rbegin(s), rend(s)
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define rrep(i, a, b) for (int i = ((a)-1); i >= (b); i--)
#define pb push_back
#define sz(a) int((a).size())
#define put(a) ((cout) << (a) << (endl))
#define putf(a, n) ((cout) << (fixed) << (setprecision(n)) << (a) << (endl))

using namespace std;

using ll = long long;
using ull = unsigned long long;
using i_i = pair<int, int>;
using ll_ll = pair<ll, ll>;
using d_ll = pair<double, ll>;
using ll_d = pair<ll, double>;
using d_d = pair<double, double>;

static constexpr ll LL_INF = 1LL << 60;
static constexpr int I_INF = 1 << 28;
static constexpr double PI = static_cast<double>(3.14159265358979323846264338327950288);
static constexpr double EPS = numeric_limits<double>::epsilon();

static map<type_index, const char* const> scanType = {
    {typeid(int), "%d"}, {typeid(ll), "%lld"}, {typeid(double), "%lf"}, {typeid(char), "%c"}};

template <class T> static void scan(vector<T>& v);
[[maybe_unused]] static void scan(vector<string>& v, bool isWord = true);
template <class T> static inline bool chmax(T& a, T b);
template <class T> static inline bool chmin(T& a, T b);
template <class T> static inline T gcd(T a, T b);
template <class T> static inline T lcm(T a, T b);
template <class A, size_t N, class T> static void Fill(A (&arr)[N], const T& val);

ll dp[1005][1 << 12];

int main(int argc, char* argv[]) {
  ll n, m;
  cin >> n >> m;

  vector<pair<ll, int>> keys(m);
  vector<int> box_bits(m);
  rep(i, 0, m) {
    int c;
    cin >> keys[i].first >> c;
    vector<ll> tmp(c);
    scan(tmp);
    for (ll k : tmp) {
      keys[i].second |= (1 << (k - 1));
    }
  }

  Fill(dp, ll(LL_INF));
  dp[0][0] = 0;

  rep(i, 0, m) {
    rep(j, 0, 1 << n) {
      if (dp[i][j] >= LL_INF) continue;

      chmin(dp[i + 1][j], dp[i][j]);
      chmin(dp[i + 1][j | keys[i].second], dp[i][j] + keys[i].first);
    }
  }

  ll ans = dp[m][(1 << n) - 1] >= LL_INF ? -1 : dp[m][(1 << n) - 1];
  put(ans);

  return 0;
}

template <class T> static void scan(vector<T>& v) {
  auto tFormat = scanType[typeid(T)];
  for (T& n : v) {
    scanf(tFormat, &n);
  }
}

static void scan(vector<string>& v, bool isWord) {
  if (isWord) {
    for (auto& n : v) {
      cin >> n;
    }
    return;
  }

  int i = 0, size = v.size();
  string s;
  getline(cin, s);

  if (s.size() != 0) {
    i++;
    v[0] = s;
  }

  for (; i < size; ++i) {
    getline(cin, v[i]);
  }
}

template <class T> inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}

template <class T> inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}

template <class T> inline T gcd(T a, T b) { return __gcd(a, b); }

template <class T> inline T lcm(T a, T b) { return (a * b) / gcd(a, b); }

template <class A, size_t N, class T> void Fill(A (&arr)[N], const T& val) {
  std::fill((T*)arr, (T*)(arr + N), val);
}


Measured memory_bytes: 32384
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vi2 = vector<vector<int>>;
using vb = vector<bool>;
using vb2 = vector<vector<bool>>;
using vc = vector<char>;
using vc2 = vector<vector<char>>;
using vs = vector<string>;
using si = set<int>;
using vs2 = vector<vector<string>>;
using pii = pair<int, int>;
using mii = map<int, int>;
const int INF = 1e9;
const ll LINF = 1e18;
const long double PI = acos(-1.0);
#define MP(a,b) make_pair((a),(b))
#define MT(...) make_tuple(__VA_ARGS__)
#define sz(x) (int)(x).size()
 
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define REPS(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREPS(i,x) for(int i=((int)(x));i>0;i--)
 
#define ALL(x) (x).begin(),(x).end()
#define SORT(v) sort(ALL(v));
#define IN(type,a) type a;cin >> a;
#define VIN(type,a,n) vector<type> a(n);cin >> a;
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl;
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl;
#define COUT(x) cout << (x) << endl;
#define DCOUT(x,n) cout << fixed << setprecision(n) << (x) << endl;
#define ENDL cout << endl;
#define DB(s,x) cout << (s) << " : " << x << endl;

#define HOGE COUT("HOGE")

template<typename T>inline istream& operator>>(istream&i,vector<T>&v)
{REP(j,sz(v))i>>v[j];return i;}

template<typename T> bool chmax(T& a, const T& b){if(a<b){a=b;return true;}return false;}
template<typename T> bool chmin(T& a, const T& b){if(a>b){a=b;return true;}return false;}
int main() {
    int a;
    cin >> a ;
    if (a >= 65 && a <= 90) {
        COUT(1);
    }else if (a >= 97 && a <= 122) {
        COUT(2);
    }else{
        COUT(0);
    }
}



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

#define rep(i, n) for(int i = 0; i<(n); i++)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;

const int MOD = 1000000007;

bool rec(int n) {
    if (n == 0) return true;
    if (n < 0) return false;

    if (rec(n - 4)) return true;
    if (rec(n - 7)) return true;
    return false;
}

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

    if(rec(N)) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int x = sc.nextInt();
		long[] a = new long[n];
		for (int i = 0; i < n; i++) {
			a[i] = sc.nextLong();
		}
		sc.close();

		long ans = 0;
		if (a[0] > x) {
			ans += a[0] - x;
			a[0] -= ans;
		}
		for (int i = 1; i < n; i++) {
			long y = x - a[i - 1];
			if (a[i] > y) {
				long z = a[i] - y;
				ans += z;
				a[i] -= z;
			}
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 58628
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
//vector<vector<int> > dp;
//vector<vector<vector<int> > > vvvi;
//dp=vector<vector<int> >(N, vector<int>(M,0));
//vector<pair<int,int> > v;
//v.push_back(make_pair(x,y));

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

	char sw[55][55];
	bool s[55][55]={false};
	int H,W;
	cin>>H>>W;
	eFOR(i,1,H){
		eFOR(j,1,W)cin>>sw[i][j];
	}
	eFOR(i,1,H){
		eFOR(j,1,W){
			if(sw[i][j]=='.')s[i][j]=true;
			else if(sw[i-1][j]=='#' || sw[i+1][j]=='#' || sw[i][j-1]=='#' || sw[i][j+1]=='#')
				s[i][j]=true;
		}
	}
	bool F=true;
	eFOR(i,1,H){
		eFOR(j,1,W){
			if(!s[i][j])F=false;
		}
	}
	if(F)cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	
	return 0;
}

Measured memory_bytes: 256
package main
import (
  "fmt"
  "sort"
  //"regexp"
)
 
func main(){
  var n, k, a, ans int
  fmt.Scan(&n)
  fmt.Scan(&k)
  s := make([]int, 0)
  for i := 0; i < n; i++ {
    fmt.Scan(&a)
    s = append(s, a)
  }
  sort.Slice(s, func(i, j int) bool { return s[i] < s[j] })
  for i :=0; i < k; i++ {
    ans += s[i]
  }
  fmt.Printf("%d\n", ans)
}

Measured memory_bytes: 1916
#include <bits/stdc++.h>
#include <cmath>
#include <set>
#include <cstdio>
#include <vector>
#include <iostream>
#include <utility>

#define fir first
#define sec second
#define get(n) scanf("%d",&n);
#define gets(s) string s;cin >> (s);
#define All(s) (c).begin(), (c).end()
#define chmin(x, y) x = min(x, y);
#define chmax(x, y) x = max(x, y);
#define rep(i, j) for (int (i)=0;(i)<(j);(i)++)
#define repk(i, j, k) for(int (i)=(j);(i)<(k);(i)++)
#define dump(x)  std::cout << #x << " = " << (x) << std::endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
using namespace std;
typedef long long int ll;
const int max_n = 2 * 1e5 + 1;
const ll INF = 10241024;
long double INFD = 100100100;

int N;
vector<vector<int> > v(15, vector<int>(15, -1));
void input(){
    cin >> N;
    rep(i, N){
        int a; cin >> a;
        rep(j, a){
            int b , c; cin >> b >> c;
          	b--;
            v[i][b] = c;
            //dump(v[i][b]);
        }  
    }
}



void solve(){
    input();
    int ans = 0;
    bool ok = true;
  	
    for(int i=0;i< (1<<N) ;i++){
      	//dump(i);
        vector<int> w(15, 0);
        int ansa = 0;
      	
        for(int j = 0;j<N;j++){//serch which bit stand
            int k = 1 << j;
            int l = k & i;
            if( l == k){
                w[j] = 1;
                ansa += 1;
                //dump(j);
                //dump(w[j]);
                //dump(ansa);
            }
        }

        for(int j=0;j<N;j++){
            if(w[j] != 1) continue;
          	//cout << "a" << endl;
          	//dump(j);
            for(int k=0;k<N;k++){
              	//dump(k);
              	//dump(v[j][k]);
                if(v[j][k] == -1)continue;
                if(v[j][k] != w[k])
                {
                    ok = false;
                    break;
                }
            }
            if(!ok)break;
        }
        if(!ok)
        {
          ok = true;
          continue;
        }
        chmax(ans, ansa);
        //dump(ans);
    }

  	cout << ans << endl;
}

int main () {
    solve();
    return 0;
}





Measured memory_bytes: 256
import java.util.*;

public class Main{
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);

		int n = scan.nextInt();
		long[] f = new long[n+1];

		System.out.println(Fib(n, f));

		scan.close();
		System.exit(0);
	}

	private static long Fib(int n, long[] f){
		if(n <= 1)
			return 1;
		if(f[n] != 0)
			return f[n];
		f[n] = Fib(n-2, f) + Fib(n-1, f);
		return f[n];
	}
}

Measured memory_bytes: 26360
#ifdef __unix__
#include <bits/stdc++.h>
#else
#include <iostream>
#include <algorithm>
#include <math.h>
#include <functional>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <unordered_set>
#include <stack>
#include <bitset>
#endif

#define fastIO ios_base::sync_with_stdio(0), cin.tie(NULL)
#define pb push_back
#define all(x) x.begin(), x.end()
#define endl '\n'
#define mkp make_pair
/*#define NUMTOSTR(x)  (unsigned char)((x) + 48);*/
typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long  ull;
using namespace std;

int main(){
	fastIO;
	int a, b, c;
	cin >> a >> b >> c;
	unordered_multiset<int> ms;
	ms.insert(a), ms.insert(b), ms.insert(c);
	if (ms.count(a) == 2) {
		cout << "Yes";
		return 0;
	}
	else if (ms.count(b) == 2) {
		cout << "Yes";
		return 0;
	}
	else if (ms.count(c) == 2) {
		cout << "Yes";
		return 0;
	}
	cout << "No";
	return 0;
}



Measured memory_bytes: 3620
#include <algorithm>
#include <iostream>
#include <stack>
#include <queue>
#include <cmath>
#include <string>
#include <iterator>
#include <map>
#include <set>
#include <iomanip>
#include <vector>
#include <cstdint>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll, ll>;
using Graph = vector<vector<int>>;
int dx[] = {0, 1, 0, -1};
int dy[] = {1, 0, -1, 0};
#define rep(i, N) for(int i = 0; i < N; i++)
#define rep2(i, l, r) for (ll i = (ll)l; i < (ll)(r); i++)
#define INF 1000000000000000
#define MAX 200001

#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
const ll MOD = 1000000007;

template <typename T > inline string toString(const T &a) {ostringstream oss; oss << a; return oss.str();};
int par[1000000];

void init(int N){
    rep(i,N) par[i] = -1;
}

int find(int a){
    if(par[a] < 0) return a;
    else{
        return par[a] = find(par[a]);
    }
}

void unite(int a, int b){
    a = find(a);
    b = find(b);
    if(a == b) return;
    else{
        if(par[a] > par[b]) swap(a,b);
        par[a] += par[b];
        par[b] = a;
    }
}

int size(int A) {
     return -par[find(A)];
}

bool same(int a, int b){
    return find(a) == find(b);
}

int main(){
    int N;
    cin >> N;
    string s;
    cin >> s;
    map<pair<string, string>,ll> zen;
    map<pair<string, string>,ll> kou;
    rep(i,1<<N){
        string r = "";
        string b = "";
        rep(j,N){
            if(i>>j & 1) r += s[j];
            else b += s[j];
        }
        zen[{r,b}] += 1;
    }
    rep(i,1<<N){
        string r = "";
        string b = "";
        rep(j,N){
            if(i>>j & 1) r += s[N+j];
            else b += s[N+j];
        }
        reverse(r.begin(), r.end());
        reverse(b.begin(), b.end());
        kou[{r,b}] += 1;
    }
    ll ans = 0;
    for(auto z:zen){
        auto a = z.first;
        ans += z.second * kou[a];
    }
    cout << ans << endl;
}

Measured memory_bytes: 89668
# from sys import exit
N, K = [int(n) for n in input().split()]
# a = [int(input()) for _ in range(N)]
# S = str(input())
# L = len(S)
# T = str(input())
# exit()
ans = 0
for i in range(0, N-K+1):
    ans += 1
print(ans)


Measured memory_bytes: 38384