akhauriyash/Code-Regression huggingface dataset:
package main

import (
	"fmt"
	"math"
)

func main(){
	var n int
	var m, ans float64
	for{
		m, ans = 0, 0
		fmt.Scan(&n)
		if n == 0{
			break
		}
		s := make([]float64, n)
		for i:=0; i<n; i++{
			fmt.Scan(&s[i])
			m += s[i]
		}
		m /= float64(n)
		for i:=0; i<n; i++{
			ans += math.Pow(s[i] - m, 2)
		}
		fmt.Println(math.Sqrt(ans/float64(n)))
	}
}


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

using ll = long long;
using vll = vector<ll>;
using pll = pair<ll, ll>;
using qll = queue<ll>;
using vb = vector<bool>;
using mll = map<ll, ll>;
using sll = stack<ll>;
#define REP(i,n) for(ll i(0);(i)<(n);(i)++)
#define rep(i,n) for(ll i(0);(i)<(n);(i)++)
#define ALL(a) a.begin(), a.end()
#define enld endl //* missspell check
const ll INF = 1LL << 60;


void solve(std::string S, std::string T){
    cout << T+S<<endl;
}

int main(){
    std::string S;
    std::cin >> S;
    std::string T;
    std::cin >> T;
    solve(S, T);
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<math.h>
#include<vector>
#include<algorithm>
#include<string.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
long long int mod=1e9+7;
bool debug=false;
typedef long long ll;
int main(){
	int n,k,sum,l,r;
	cin>>n>>k;
	string s;
	cin>>s;
	vector<int>v(1,0);
	char mode=s[0];
	int head,max=-1e9;
	rep(i,n){
		if(mode==s[i]){
			v[v.size()-1]+=1;
		}else{
			mode=s[i];
			v.push_back(1);
		}
	}
	if(s[0]=='0'){
		if(k>=(v.size()+1)/2){
			cout<<n<<endl;
			return 0;
		}
		head=0;
		while(head+2*(k-1)<v.size()){
			sum=0;
			l=head-1;
			if(l<0)l=0;
			r=head+2*(k-1)+1;
			if(r>=v.size())r--;
			for(int i=l;i<=r;i++){
				sum+=v[i];
			}
			if(max<sum)max=sum;
			head+=2;
		}
	}else{
		if(k>=v.size()/2){
			cout<<n<<endl;
			return 0;
		}
		head=1;
		while(head+2*(k-1)<v.size()){
			sum=0;
			l=head-1;
			if(l<0)l=0;
			r=head+2*(k-1)+1;
			if(r>=v.size())r--;
			for(int i=l;i<=r;i++){
				sum+=v[i];
			}
			if(max<sum)max=sum;
			head+=2;
		}
	}
	cout<<max<<endl;




	return 0;
}

Measured memory_bytes: 1020
#ifdef _MSC_VER
#define _CRT_SECURE_NO_WARNINGS
#endif

#include <bits/stdc++.h>

using namespace std;

#define POW2(X) (1<<(X))
#define CKBIT(S,X) (((S)&POW2(X))!=0)

template<class T> inline void nlmin(T &a,T b){ a=min(a,b); }
template<class T> inline void nlmax(T &a,T b){ a=max(a,b); }
template<class T> inline T sqr(T x){ return x*x; }
#define SIZE(A) ((int)A.size())
#define LENGTH(A) ((int)A.length())

#define PB(X) push_back(X)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define RFOR(i,a,b) for(int i=(a);i>(b);--i)

#define REP(i,n) for(int i=0;i<(n);++i)
#define ALL(A) A.begin(),A.end()
template<class T> int CMP(T a[],const T b[],int n) { return memcmp(a,b,n*sizeof(T)); }
template<class T> void COPY(T a[],const T b[],int n) { memcpy(a,b,n*sizeof(T)); }
template<class T> void SET(T a[],int val,int n) { memset(a,val,n*sizeof(T)); }
//using uint=unsigned int;
typedef long long int64;
//using uint64=unsigned long long;
typedef pair<int,int> pii;
typedef vector<int> VI;
typedef vector<VI> VII;
// using VD=vector<double>;
const int kmod = 1000000007;
const int N = 100000 + 10;
VI g[N];
vector<bool> vis(N);
VI dp(N);
VI father(N);
int dfs(int u) {
	if (vis[u]) 
		return dp[u];
	else {
		dp[u] = 0;
		vis[u] = true;
		for (auto v : g[u]) {
			nlmax(dp[u], dfs(v) + 1);
		}
		return dp[u];
	}

}
int main() {
	int N, M;
	int x, y;
	while (cin >> N >> M) {
		
		FOR (i, 0, N + 1) {
			g[i].clear();
			father[i] = -1;
		}
		FOR (i, 0, M) {
			cin >> x >> y;
			g[x].PB(y);
			father[y] = x;
		}

		VI start;
		FOR (i, 0, N + 1) {
			vis[i] = false;
			if (father[i] == -1) 
				start.PB(i);
		}

		int ret = 0;
		for (int i : start)
			nlmax(ret, dfs(i));

		cout << ret <<endl;
	}
	return 0;
}

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


#define base 1000000007LL
#define ll long long
#define ld long double
#define X first
#define Y second
#define pb push_back
#define EPS 1e-15
#define all(a) (a).begin(), (a).end()
#define sz(a) int((a).size())

#define ms(s, n) memset(s, n, sizeof(s))

#define FOR(i,a,b) for (int i = (a); i <= (b); i++)
#define FORE(i,a,b) for (int i = (a); i >= (b); i--)
#define sqr(a) (a)*(a)

#define foru(i,a,b) for (ll i = (a); i <= (b); i++)
#define ford(i,a,b) for (ll i = (a); i >= (b); i--)
#define cbit(a) __builtin_popcount(a)
#define uni(a) (a).resize(unique(all(a)) - (a).begin())
#define cprint(n) printf("%.6lf + %.6lfi\n", (n).real(), (n).imag())

#define FORALL(it, a) for (__typeof((a).begin()) it = (a).begin(); it !=(a).end(); it++)


using namespace std;
typedef pair<ll, ll> II;
typedef pair<int, int> ii;



struct Edge{
    ll u,v,w;
    Edge(ll u=0, ll v=0, ll w=0): u(u),v(v),w(w) {}
    bool operator < (Edge a){return w<a.w;}
};

const int M=1e5+7;
const int MM=4*M;
const ll MOD=base;
const int MAX=1e9;


inline ll gcd(ll a, ll b) {ll r; while (b) {r = a % b; a = b; b = r;} return a;}
inline ll lcm(ll a, ll b) {return a / gcd(a, b) * b;}
inline ll power(ll n, ll k, ll p = MOD) {ll r = 1; for (; k; k >>= 1LL) {if (k & 1LL) r = r * n % p; n = n * n % p;} return r;}
inline ll inverse(ll n, ll p=MOD){return power(n,p-2);}
ll search(ll a[], ll N, ll x){ ll l = 0, r = N - 1; while (l <= r){ ll mid = (l + r) / 2; if (x == a[mid]){ return 1; } else if (x < a[mid]){ r = mid - 1; } else if (x > a[mid]){ l = mid + 1; } } return -1; }

int k;
int main(){
    ios::sync_with_stdio(0);
    cin >> k;
    int sum = 0;
    for (int i = 1; i <= k; i++){
    	for(int j = i+1;j <= k;j ++){
    		if(i % 2 == 0){
    			if(j % 2 == 1) sum++;
			}
			else {
				if(j % 2 == 0) sum++;
			}
		}
	}
	cout << sum;
    return 0;
}





















Measured memory_bytes: 256
# include <bits/stdc++.h>
# define rep(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
# define reps(i, n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
# define rrep(i, n) for(int i=((int)(n)-1); i>=0; --i)
# define rreps(i, n) for(int i=((int)(n)); i>0; --i)
# define ALL(x) (x).begin(), (x).end()
# define SZ(x) ((int)(x).size())
# define pb push_back
# define optimize_cin() cin.tie(0); ios::sync_with_stdio(false)
using namespace std;
using ll = long long;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int main() {
  string s, t; cin >> s >> t;
  int n = s.size(), m = t.size();

  
  int ans = 1000;
  rep(i, n){
    if(i + m > n) break;
    int count = 0;
    rep(j, m){
      if(s[i+j]!=t[j]) count++;
    }
    chmin(ans, count);
  }

  cout << ans << endl;
}


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

using namespace std;

using i64 = long long;

const i64 MOD = 1e9 + 7;
const i64 INF = i64(1e18) + 7;


template <typename T>
bool chmin(T& x, T y){
    if(x > y){
        x = y;
        return true;
    }
    return false;
}

template <typename T>
bool chmax(T& x, T y){
    if(x < y){
        x = y;
        return true;
    }
    return false;
}

int solve(string a, string b, string c){

    bitset<2001> ab, bc;
    bitset<4001> ac;
    ab.set(), ac.set(), bc.set();
    for(int i = 0; i < ab.size(); ++i){
        for(int j = i; j < a.size() && j - i < b.size(); ++j){
            if(a[j] != '?' && b[j - i] != '?' && a[j] != b[j - i])
                ab.reset(i);
        }
    }
    for(int i = 0; i < ac.size(); ++i){
        for(int j = i; j < a.size() && j - i < c.size(); ++j){
            if(a[j] != '?' && c[j - i] != '?' && a[j] != c[j - i])
                ac.reset(i);
        }
    }
    for(int i = 0; i < bc.size(); ++i){
        for(int j = i; j < b.size() && j - i < c.size(); ++j){
            if(b[j] != '?' && c[j - i] != '?' && b[j] != c[j - i])
                bc.reset(i);
        }
    }

    int ans = MOD;

    for(int i = 0; i <= a.size(); ++i){
        for(int j = i; j <= i + b.size() || j <= a.size(); ++j){
            if(ab[i] && ac[j] && bc[j - i])
                chmin(ans, int(max({a.size(), i + b.size(), j + c.size()})));
        }
    }

    return ans;
}

signed main(){
    string a, b, c;
    cin >> a >> b >> c;
    int ans = MOD;
    chmin(ans, solve(a, b, c));
    chmin(ans, solve(a, c, b));
    chmin(ans, solve(b, a, c));
    chmin(ans, solve(b, c, a));
    chmin(ans, solve(c, a, b));
    chmin(ans, solve(c, b, a));

    cout << ans << endl;
}


Measured memory_bytes: 384
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
int main()
{
  int five = 0, seven = 0;
  int data;
  for(int i = 0; i < 3; i++)
  {
    cin >> data;
    if(data==5)
    {
      five++;
    }
    else if(data==7)
    {
      seven++;
    }
  }

  if(five == 2 && seven == 1)
  {
    cout << "YES" << endl;
  }
  else
  {
    cout << "NO" << endl;
  }
}


Measured memory_bytes: 3532
#include <bits/stdc++.h>
#define ft first
#define sc second
#define pt(sth) cout << sth << "\n"
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;
template<class T>bool chmax(T &a, const T &b) {if(a<b) {a=b; return 1;} return 0;}
template<class T>bool chmin(T &a, const T &b) {if(b<a) {a=b; return 1;} return 0;}
static const ll INF=1e18;
static const ll MAX=101010;
static const ll MOD=998244353;

//for(i=0; i<N; i++) cin >> a[i];



ll N, S;
ll a[3333];
ll dp[3333][6666];

int main(void) {
  ll i, j, k;
  
  cin >> N >> S;
  for(i=0; i<N; i++) cin >> a[i];
  
  dp[0][0]=1;
  for(i=0; i<N; i++) {
    for(j=0; j<=S; j++) {
      (dp[i+1][j]+=dp[i][j]*2)%=MOD;
      (dp[i+1][j+a[i]]+=dp[i][j])%=MOD;
    }
  }
  
  pt(dp[N][S]);
  
  
  
}
 
 




Measured memory_bytes: 97648
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (n); i++)
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const ll mod = 1000000007;
int main(){
    string s;
    cin >> s;
    int n = s.size();
    vector<vector<ll>> dp(s.size()+2,vector<ll>(2));
    dp[0][0]=1;
    for(int i=0;i<n;i++){
        if(s[i]=='0'){
            dp[i+1][0]=dp[i][0];
            dp[i+1][0]%=mod;
            dp[i+1][1]=dp[i][1]*3;
            dp[i+1][1]%=mod;
        }else{
            dp[i+1][0]=dp[i][0]*2;
            dp[i+1][0]%=mod;
            dp[i+1][1]=dp[i][0]+dp[i][1]*3;
            dp[i+1][1]%=mod;
        }
    }
    ll ans = (dp[n][0] + dp[n][1])%mod;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 5888
from collections import deque,defaultdict,Counter
from itertools import accumulate
import bisect
from heapq import heappop,heappush
from fractions import gcd
from copy import deepcopy
import math
import queue
#import numpy as np
#import sympy as syp(素因数分解とか)
Mod = 1000000007
 
  
def sieve_of_eratosthenes(n):
    if not isinstance(n,int):
        raise TypeError("n is not int")
    if n<2:
        raise ValueError("n is not effective")
    prime = [1]*(n+1)
    for i in range(2,int(math.sqrt(n))+1):
        if prime[i] == 1:
            for j in range(2*i,n+1):
                if j%i == 0:
                    prime[j] = 0
    res = []
    for i in range(2,n+1):
        if prime[i] == 1:
            res.append(i)
    return res

def factorial(i):
    if i == 1:
        return 1
    else:
        return i*factorial(i-1)
 
class UnionFind:
    def __init__(self,n):
        self.parent = [i for i in range(n+1)]
        self.rank = [0 for i in range(n+1)]
    
    def findroot(self,x):
        if x == self.parent[x]:
            return x
        else:
            y = self.parent[x]
            y = self.findroot(self.parent[x])
            return y
    
    def union(self,x,y):
        px = self.findroot(x)
        py = self.findroot(y)
        if px < py:
            self.parent[py] = px
        else:
            self.parent[px] = py
 
    def same_group_or_no(self,x,y):
        return self.findroot(x) == self.findroot(y)




def main(): #startline-------------------------------------------
    N = int(input())
    print(N*(N+1)//2 - N)
if __name__ == "__main__":
    main() #endline===============================================

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

ll res = 0;
int N;
ll A[100101], S[100101]; // suffix sum

void DIE()
{
	printf("-1");
	exit(0);
}

void f(ll h, ll n)
{
	if (h == N+1) return;
	//printf("%lld, %lld\n", h, n);
	res += n; // 내부 노드 개수

	ll next = min(n*2-A[h+1], S[h+2]);
	if (next < 0) DIE();

	f(h+1, next);
}

int main()
{
	scanf("%d", &N);
	for(int i=0; i<=N; i++)
		scanf("%lld", &A[i]);
	for(int i=N; i>=0; i--)
		S[i] = S[i+1] + A[i];

	if (N == 0)
	{
		if (A[0] == 1) return !printf("1");
		else DIE();
	}

	if (A[0] != 0) DIE();
	f(0, 1);
	res += S[0];
	printf("%lld", res);
	return 0;
}

Measured memory_bytes: 5376
#include <cstdio>
#include <cmath>
#include <cstring>
#include <iostream>
#include <sstream>

#include <string>
#include <vector>
#include <queue>
#include <list>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <stack>
#include <deque>
#include <algorithm>
#include <random>
using namespace std;

int main(int argc, char *argv[]) {
	int n, m;
	cin >> n >> m;
	vector<int> s1(pow(2, n), -1);
	s1[0] = 0;
	for (int i = 0; i < m; i++) {
		vector<int> s2 = s1;
		int a, b;
		cin >> a >> b;
		int index = 0;
		for (int j = 0; j < b; j++) {
			int t;
			cin >> t;
			index += pow(2, t - 1);
		}
		for (int j = 0; j < s1.size(); j++) {
			if (s1[j] != -1) {
				s2[j | index] = min(s2[j | index], s1[j] + a);
				if (s2[j | index] == -1)
					s2[j | index] = s1[j] + a;
			}
		}
		s1 = s2;
	}
	cout << s1[pow(2, n) - 1] << endl;
}














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

int main() {
	int a,b;
	cin >> a >> b;
	string k = "Impossible";
	if(a % 3 == 0||b % 3 == 0||(a + b) % 3 == 0)
	{
		k = "Possible";
	}
    cout << k << endl;
	return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
	double EPS = 10.e-08;
	private void doit(){
		Scanner sc = new Scanner(System.in);
		while(sc.hasNext()){
			int a = sc.nextInt();
			int b = sc.nextInt();
			if(a > 9 || b > 9) {
				System.out.println(-1);
			}
			else {
				System.out.println(a * b);
			}
		}
	}

	private void debug(Object... o) {
		System.out.println("debug = " + Arrays.deepToString(o));
	}

	public static void main(String[] args) {
		new Main().doit();
	}

}


Measured memory_bytes: 21972
// g++ -std=c++11 a.cpp
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
//#define int ll
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
// #define mt make_tuple
//typedef tuple<pii,int,int> tp;
//typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
//template<class C>constexpr int size(const C &c){return (int)c.size();}
//template<class T,size_t N> constexpr int size(const T (&xs)[N])noexcept{return (int)N;}
const double PI=acos(-1);
const double EPS=1e-7;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
int main(){
	int a,b,c;
	cin>>a>>b>>c;
	cout<<min(c,a*b)<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <stdio.h>
#include <numeric>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define repone(i,n) for(int i=1;i<(int)(n);++i)
#define repo(i,o,n) for(int i=o;i<(int)(n);++i)
#define Rep(j,n) for(int j=0;j<(int)(n);++j)
#define Repo(j,o,n) for(int j=o;j<(int)(n);++j)
#define Repone(j,n) for(int j=1;j<(int)(n);++j)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define int long long
#define pb(a) push_back(a)
#define eraser(v,i) (v).erase(v.begin()+(i))
#define pbpair(a,b) push_back(make_pair(a,b))
#define MOD 1000000007
#define INF 9223372036854775807
#define pairint pair<int,int>
int num[12] = {31,28,31,30,31,30,31,31,30,31,30,31};
bool uru(int checkyear){if(checkyear%4==0){if(checkyear%100!=0||checkyear%400==0)return true;}return false;}
int gcd( int x, int y ){return y ? gcd(y, x%y) : x;}
bool pairCompare(const pairint& firstElof, const pairint& secondElof)
{
  if(firstElof.second!= secondElof.second)    return firstElof.second> secondElof.second;
  else return firstElof.first< secondElof.first;
}
signed main() {
int x=0,y=0,z=0,w=0,n=0,m=0;
std::cin >> x>>y>>z;
x-=y;
std::cout << x%z << '\n';
}


Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
	"strconv"
)

var (
	readString func() string
	stdout     *bufio.Writer
)

func init() {
	readString = newReadString(os.Stdin)
	stdout = bufio.NewWriter(os.Stdout)
}

func newReadString(ior io.Reader) func() string {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)

	return func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
}

func readInt() int {
	return int(readInt64())
}

func readInt64() int64 {
	i, err := strconv.ParseInt(readString(), 0, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func readIntSlice(n int) []int {
	b := make([]int, n)
	for i := 0; i < n; i++ {
		b[i] = readInt()
	}
	return b
}

func readLengthAndSlice() []int {
	n := readInt()
	return readIntSlice(n)
}

func printf(f string, args ...interface{}) (int, error) {
	return fmt.Fprintf(stdout, f, args...)
}

func println(args ...interface{}) (int, error) {
	return fmt.Fprintln(stdout, args...)
}

func vi(n int, args ...int) []int {
	res := make([]int, n)
	if len(args) == 0 {
		return res
	}
	v := args[0]
	if v == 0 {
		return res
	}
	for i := 0; i < n; i++ {
		res[i] = v
	}
	return res
}

func vvi(n int, args ...int) [][]int {
	res := make([][]int, n)
	m := n
	if len(args) > 0 {
		m = args[0]
	}
	v := 0
	if len(args) > 1 {
		v = args[1]
	}
	for i := 0; i < n; i++ {
		res[i] = vi(m, v)
	}
	return res
}

// readString() string
// readInt() int
// readIntSlice(n int) []int
// readLengthAndSlice() []int
func main() {
	defer stdout.Flush()
	s := readString()
	ans := 0
	for _, r := range s {
		if r == '+' {
			ans++
		} else {
			ans--
		}
	}
	println(ans)
}


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

int main(){
  int a,b;
  cin>>a>>b;
  
  
  int answer=0;
  
  for (int i=a;i<b+1;i++){
    
    int j=i;
    int x,y,z,v,w;
    x=j%10;
    j/=10;
    y=j%10;
    j/=10;
    z=j%10;
    j/=10;
    v=j%10;
    j/=10;
    w=j%10;
    
    if (x==w and y==v){
      answer+=1;
    }
  }
  
  cout<<answer<<endl;
  
    
  
  
}

  













Measured memory_bytes: 256
#include<bits/stdc++.h>
#define LL long long
#define Max 100005
const LL mod=1e9+7;
const LL LL_MAX=9223372036854775807;
using namespace std;
int main()
{
    int n,c;
    scanf("%d%d",&n,&c);
    if(n<=5)
        printf("0\n");
    else if(n<=12)
        printf("%d\n",c/2);
    else
        printf("%d\n",c);
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fast                                                                   \
ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define int long long
#define ll long long
#define f(i, n) for (int i = 0; i < n; i++)
#define ff(i, n) for (int i = 1; i <= n; i++)
#define F first
#define S second
#define vpii vector<pair<int,int> >
#define sz size()
#define all(v) v.begin(),v.end()
#define pb push_back   
#define PB pop_back
#define vl vector<int>
#define mp make_pair
#define mod 1000000007
typedef unsigned long long ull;
const int N = 200005;
const int MOD = 998244353 ;




void solve(){
    int n, k, cnt = 1, pre = 0;
    cin>>n>>k;
    int a[n+5];
    ff(i,n)cin>>a[i];
    for(int i = k + 1; i <= n; i++){
        if(a[i] > a[i-k])cout<<"Yes\n";
        else cout<<"No\n";
    }
}

int32_t main() {
    fast
    int t;
    t = 1;
    //cin >> t;
    while(t--)solve();
    return 0;
}


Measured memory_bytes: 5204
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = (s); i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) for(int i = (n); i >= 0; i--)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << '\n';
#define CFYN(n) cout << ( (n) ? "YES":"NO") << '\n';
#define OUT(n) cout << (n) << '\n';
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;

int main(void)
{
    IOS
    int a, b, c;
    cin >> a >> b >> c;
    int x, y;
    cin >> x >> y;
    int mxy = min(x,y);
    int nxy = max(x,y);
    int ab = x*a + y*b;
    int abm = c * mxy * 2 + (x > y ? a * (nxy-mxy) : b * (nxy-mxy));
    int abn = c * nxy * 2;
    int ans = min(min(ab,abm),abn);

    cout << ans << '\n';


    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <vector>
#include <algorithm>
#include <cstring>
const int maxn = 2e5 + 5;
const int INF = 0x3f3f3f3f;
using namespace std;
struct T{
	struct A{
		int l, r, Min;
	}a[maxn << 2];
	void build(int cur, int l, int r){
		a[cur].l = l, a[cur].r = r;
		a[cur].Min = INF;
		if (l == r) return;
		int mid = l + r >> 1;
		build(cur << 1, l, mid);
		build(cur << 1 | 1, mid + 1, r);
	}
	void upd(int cur, int p, int k){
		if (a[cur].l == a[cur].r){
			a[cur].Min = min(a[cur].Min, k);
			return;
		}
		int mid = a[cur].l + a[cur].r >> 1;
		if (p <= mid) upd(cur << 1, p, k);
		else upd(cur << 1 | 1, p, k);
		a[cur].Min = min(a[cur << 1].Min, a[cur << 1 | 1].Min);
	}
	int Query(int cur, int l, int r){
		if (a[cur].l > r || a[cur].r < l) return INF;
		if (a[cur].l >= l && a[cur].r <= r) return a[cur].Min;
		return min(Query(cur << 1, l, r), Query(cur << 1 | 1, l, r));
	}
}t;
vector <int> v[maxn];
int n, Q, b[maxn], f[maxn], S = 0;
int main(){
	scanf("%d", &n); for (int i = 1; i <= n; i++) scanf("%d", b + i), S += (1 - b[i]);
	scanf("%d", &Q);
	for (int l, r, i = 1; i <= Q; i++){
		scanf("%d%d", &l, &r);
		v[l].push_back(r);
	} t.build(1, 1, n);
	for (int i = 1; i <= n; i++) sort(v[i].begin(), v[i].end());
	memset(f, 0x3f, sizeof f); f[0] = 0;
	for (int i = 1; i <= n; i++){
		for (int j = 0; j < v[i].size(); j++){
			int r = v[i][j]; int tmp = min(f[i - 1], t.Query(1, max(1, i - 1), r));
			if (tmp < f[r]) t.upd(1, r, f[r] = tmp);
		}
		f[i] = min(f[i], f[i - 1] + ((b[i] == 1) ? 1 : -1));
	} printf("%d\n", S + f[n]);
	return 0;
}

Measured memory_bytes: 18560
//inlclude before define 
#define _USE_MATH_DEFINES

//include
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<type_traits>
#include<numeric>
#include<deque>
#include<iomanip>
#include<set>
#include<unordered_set>
#include<tuple>
#include<map>
#include<memory>

using namespace std;

//typedef
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<char> VC;
typedef vector<double> VD;
typedef pair<int, int> P1;
typedef long long int ll;

//number
#define INF 1e9
#define NUM 1000000007

//itr
#define all(x) begin(x),end(x)

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

//max,min
#define chmin(a,b) a=min((a),(b))
#define chmax(a,b) a=max((a),(b))

//function

/*ll gcd(ll a, ll b) {
	if (b == 0) return a;
	else return gcd(b, a%b);
}*/

/*ll lcm(ll a,ll b) {
	ll g = gcd(a, b);
	retur5n a * (b / g);
}*/

int dig(int a) {
	int sum = 0;
	while (a) {
		sum += a % 10;
		a /= 10;
	}
	return sum;
}

//grid template
int x[] = { -1, 0, 1, 0 };
int y[] = { 0,-1,0,1 };
int xx[] = { -1,-1,1,1 };
int yy[] = { 1,-1,1,-1 };

int main() {
	string s;
	cin >> s;
	int n = s.size();
	int cnt = 0;
	rep(i, n-1) {
		if (s[i] == s[i + 1]) {
			if (s[i] == '1') {
				s[i+1] = '0';
			} else {
				s[i+1] = '1';
			}
			cnt++;
		}
	}
	cout << cnt << endl;
}

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

int main() {
  int n;
  cin>>n;
  vector<int> v(n);
  vector<int> c(n);
  for(int i=0;i<n;i++){
    cin>>v[i];
  }
   for(int i=0;i<n;i++){
    cin>>c[i];
  }
  int ans=0;
  for(int i=0;i<n;i++){
    if(v[i]-c[i]<=0)continue;
    ans+=v[i]-c[i];
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<vector>
#include<cmath>
#include<string>
#include<cstring>
#include<algorithm>
#include<queue>
#include<map>
#include<set>
#define  endl '\n'
#define all(s) s.begin(),s.end()
#define lowbit(x) (x&-x)
#define rep(i,a,n) for (int i=a;i<=n;i++)
#define IOS ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define mem(a,b) memset(a,b,sizeof(a))
#define fi first
#define se second
#define pb push_back
#define PI acos(-1.0)
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int mod=1e9+7;
const double eps=1e-8;
const int inf=0x3f3f3f3f;
const int N=2e5+10;
int main()
{
	int n,m,q,k;
	int a,d,A,D;
	cin>>n;
	set<string>s;
	string S;
	for(int i=1;i<=n;i++){
		cin>>S;
		s.insert(S);
	}
	cout<<s.size();
}


Measured memory_bytes: 15564
#include<iostream>
#include<string>
#include<vector>
#include<stdio.h>
#include<algorithm>
#include<math.h>
#include<numeric>
#include<iomanip>
#include<deque>
#include<tuple>
#include<queue>
#include<stack>
#include<map>
#include<unordered_map>
#include<boost/multiprecision/cpp_int.hpp>


#define rep(i, n) for(int i = 0; i < ( int)(n); i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define vi vector<int>
#define vll vector<ll>
#define all(x) (x).begin(),(x).end()
#define F first
#define S second


namespace mp = boost::multiprecision;

using cpp_int = mp::cpp_int;
using ll = long long;
using namespace std;

int main() {
	int n;
    cin>>n;
    vector<double>a(n);
    rep(i,n)cin>>a[i];
    double ans=0;
    rep(i,n){
        ans+=pow(a[i],-1);
    }
    cout<<setprecision(13)<<pow(ans,-1)<<endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<utility>
#include<vector>
#define ll long long int

using namespace std;

int main()
{
  ll n,m;
  cin>>n>>m;
  
  vector<pair<ll,ll>>V;
  ll i;
  
  for(i=0;i!=n;i++)
  {
    ll a,b;
    cin>>a>>b;
    
    pair<ll,ll>p(a,b);
    V.push_back(p);
  }
  
  sort(V.begin(),V.end());
  ll c = 0,cn = 0;
  for(i=0;i!=n;i++)
  {
    if(cn+V[i].second<=m)
    {
      cn += V[i].second;
      c += (V[i].first) * (V[i].second);
    }
    else
      break;
  }
  
  if(cn!=m)
    c += (m-cn)*V[i].first;
  
  cout<<c;
  return 0;
}

Measured memory_bytes: 2420
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define ll long long
#define _GLIBCXX_DEBUG
const ll MOD = 1000000007;
const int MAX = 510000;

int main() {
  int n;
  cin >> n;
  vector<int> v(n);
  for (int i=0; i<n; i++) cin >> v[i];
  map<int, int> memo_odd, memo_even;
  // 奇数番目，偶数番目それぞれについて登場回数最多の数字を調べる
  for (int i=0; i<n; i++) {
    if (i%2==0) {
      if (memo_odd.count(v[i])) memo_odd[v[i]]++;
      else memo_odd[v[i]] = 1;
    }
    else {
      if (memo_even.count(v[i])) memo_even[v[i]]++;
      else memo_even[v[i]] = 1;
    }
  }
  // 最も登場回数が多い数字に合わせる
  vector<pair<int, int>> memo2_odd, memo2_even;
  for (auto p: memo_odd) {
    auto key = p.first;
    auto value = p.second;
    memo2_odd.push_back(make_pair(value, key));
  }
  for (auto p: memo_even) {
    auto key = p.first;
    auto value = p.second;
    memo2_even.push_back(make_pair(value, key));
  }
  sort(memo2_odd.begin(), memo2_odd.end());
  reverse(memo2_odd.begin(), memo2_odd.end());
  sort(memo2_even.begin(), memo2_even.end());
  reverse(memo2_even.begin(), memo2_even.end());
  int ans;
  if (memo2_odd[0].second!=memo2_even[0].second) ans = n-memo2_odd[0].first-memo2_even[0].first;
  else if (n>3) ans = min(n-memo2_odd[1].first-memo2_even[0].first, n-memo2_odd[0].first-memo2_even[1].first);
  else ans = 1;
  cout << ans << endl;
}

Measured memory_bytes: 6520
#include<stdio.h>

int main()
{
	char s[3];
	int count = 0;
	
	scanf("%s",s);
	
	if(s[0] == s[1]) count++;
	if(s[0] == s[2]) count++;
	if(s[1] == s[2]) count++;
	
	if(count != 0) printf("No\n");
	else printf("Yes\n");
	
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,m,c;
  cin >> n >> m >> c;
  int b[m];
  for(int i=0;i<m;i++){
    cin >> b[i];
  }
  int a[n][m];
  int s[m],t=0;
  for(int i=0;i<n;i++){
    s[i]=c;
    for(int j=0;j<m;j++){
      cin >> a[i][j];
      s[i]+=a[i][j]*b[j];
    }
    if(s[i]>0){
      t++;
    }
  }
  cout << t;
}


Measured memory_bytes: 256
#include <stdio.h>

int main()
{
  int a, b;
 scanf("%d%d\n", &a, &b);
  if (a == b){
   printf("a == b\n");
 }
  if (a > b){
   printf("a > b\n");
 }
  if (a < b){
   printf("a < b\n");
 }
   return 0;
}

Measured memory_bytes: 584
def check_path(dots_list,dot,golist):
	List = dots_list[:]
	List.remove(dot)

	c = 0

	if len(List) > 0:
		for i in golist[dot-1]:
			if List.count(i) > 0:
				c += check_path(List, i, golist)
			else:
				c += 0
	else:
		c = 1

	return c



if __name__ == '__main__':

	#入力
	N, M = map(int, input().split())
	ms = []
	for i in range(0,M):
		a, b = map(int, input().split())
		ms.append([a, b])

	golist = []
	dots_list = []

	#各頂点の隣接点をリストに
	for i in range(1,N+1):
		golist_each = []
		dots_list.append(i)
		for j in range(0,M):
			if ms[j][0] == i:
				golist_each.append(ms[j][1])
			elif ms[j][1] == i:
				golist_each.append(ms[j][0])

		golist.append(golist_each)

	ans = check_path(dots_list, 1, golist)
	print(ans)

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

#define int long long
#define fi first
#define se second
#define otp(n) cout << n;
#define ct(n) cout << n << endl;
#define cts(n) cout << n << " ";
#define cte cout << endl;
#define ctv(v) rep(i,(v).size()) ct(v[i])
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define repo(i,o,n) for(int i=o;i<n;i++)
#define repm(i,n) for(int i=n-1;i>=0;i--)
#define repv(i,v) for(int i=0;i<(v).size();i++)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define sperase(v,n) (v).erase(remove(all(v), n), (v).end());
#define vdelete(v) (v).erase(unique(all(v)), (v).end());
#define pb(n) push_back(n);

int N,W,S,E;
string s;

main() {
    cin >> s;
    rep(i,s.size()) {
        if (s[i] == 'N') N++;
        else if (s[i] == 'W') W++;
        else if (s[i] == 'S') S++;
        else E++;
    }
    if (N&&!S || !N&&S || E&&!W || !E&&W) ct("No")
    else ct("Yes")
}


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

int n;
int a[212345];
map<int, long long> cnt;

int main(){
    ios_base::sync_with_stdio(0);
    //freopen("input.txt","r",stdin);

    cin>>n;
    for(int i=0;i<n;i++){
        cin>>a[i];
        cnt[a[i]]++;
    }
    long long res = 0;
    for(auto const& x : cnt){
        res += x.second*(x.second-1)/2;
    }
    for(int i=0;i<n;i++){
        long long c = cnt[a[i]];
        cout << res - c*(c-1)/2 + (c-1)*(c-2)/2 << "\n";
    }
}


Measured memory_bytes: 10368
#include <bits/stdc++.h>
using namespace std;
// define
#define int long long
#define UNIQUE(v) v.erase(unique(all(v)), v.end());
#define ZIP(v) sort(all(v)),UNIQUE(v)
#define ADD(a, b) a = (a + b) % mod
#define SUB(a, b) a = (a+mod-b)%mod
#define MUL(a, b) a = (a * b) % mod
#define rollcall cout << "I'm Sucu." << endl;
#define repi(i,m,n) for(int i = m;i < n;i++)
#define drep(i,n,m) for(int i = n;i >= m;i--)
#define rep(i,n) repi(i,0,n)
#define rrep(i,n) repi(i,1,n+1)
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(), v.rend()
#define dmp(x,y) make_pair(x,y)
#define pb(x) push_back(x)
#define pf(x) push_front(x)
#define fi first
#define se second
// debug
template <typename T, typename U>
ostream &operator<<(ostream &os, const pair<T, U> &p){
  os << "(" << p.first << "," << p.second << ")";return os;
}
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v){
  for (auto it = v.begin();it != v.end();++it){
    if(it != v.begin())os << " ";os << *it;
      }return os;
}
template <typename T, typename U>
ostream &operator<<(ostream &os, const map<T, U> &mp){
  for(auto x: mp)os << "(" << x.first << "," << x.second << ")" << endl;
  return os;
}
template<typename T, int SIZE>
int array_length(const T (&)[SIZE]){return SIZE;}
template<typename T, int N>
void PRINTF(const T (&a)[N], int s = N, int t = -1, bool f = true){
	if(t == -1){rep(i,s){if(i)cout << " ";cout << a[i];}}
	else repi(i,s,t){if(i!=s)cout << " ";cout << a[i];}
	if(f)cout << "\n";
}
template<typename T, int N1, int N2>
void PRINTF(const T (&a)[N1][N2], int h = N1, int w = N2){
	rep(i,h){rep(j,w){cout << a[i][j] << " \n"[j==w-1];}}
}
string substr(const string &str, int S1, int S2 = -1){
  if(S2 == -1)return str.substr(S1);
  return str.substr(S1, S2-S1);
}
// typedef
typedef complex<double> Point;
typedef pair<int, int> P;
typedef pair<int, P> PP;
typedef pair<P, int> Pi;
typedef vector<int> vi;
typedef deque<int> dq;
const int inf = 1e9+7;
const int INF = 1e18+7;

signed main(){
  int n, a, b;
  scanf("%lld%lld%lld", &n, &a, &b);
  int tmp = a+b-n;
  if(tmp < 0)tmp = 0;
  printf("%lld %lld\n", min(a, b), tmp);
  return 0;
}






Measured memory_bytes: 256
#pragma GCC optimize ("O3")

#include <bits/stdc++.h>

using namespace std;

#ifdef LOCAL
#include <prettyprint.hpp>
#define debug(...)  cerr << "[" << #__VA_ARGS__ << "]: ", d_err(__VA_ARGS__);
#else
#define debug(...) 83;
#endif

void d_err() {
    cerr << endl;
}

template <typename H, typename... T>
void d_err(H h, T... t) {
    cerr << h << " ";
    d_err(t...);
}

#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define bcnt __builtin_popcountll

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<ll,ll> Pll;
typedef pair<int,int> Pin;

ll INF = 1e16;
int inf = 1e9;
ll MOD = 1e9+7;

struct UnionFind {
    vector<int> par;

    UnionFind(int n): par(n, -1) {}
    void init(int n) { par.assign(n, -1); }

    int root(int x) {
        if (par[x] < 0) return x;
        return par[x] = root(par[x]);
    }

    int issame(int x, int y) {
        return root(x) == root(y);
    }

    bool merge(int x, int y) {
        x = root(x); y = root(y);

        if (x == y) return false;

        // merge by size
        // force size of x to be bigger than that of y
        if (par[x] > par[y]) swap(x, y);
        par[x] += par[y];
        par[y] = x;
    }

    int size(int x) {
        return -par[root(x)];
    }
};

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    
    int N, M, K;
    cin >> N >> M >> K;

    UnionFind F(N);

    map<int, int> cnt;
    REP(i, M) {
        int a, b;
        cin >> a >> b;
        --a; --b;
        F.merge(a, b);
        cnt[a] += 1;
        cnt[b] += 1;
    }

    REP(i, K) {
        int c, d;
        cin >> c >> d;
        --c; --d;
        if (F.issame(c, d)) {
            cnt[c] += 1;
            cnt[d] += 1;
        }
    }

    REP(i, N) {
        if (i > 0) cout << " ";
        cout << F.size(i) - cnt[i] - 1;
    }
    cout << endl;
    
}


Measured memory_bytes: 5888
#include<stdio.h>

int main(void)
{
    double W, H, x, y;
    double a, b;
    double temp, ans;

    scanf("%lf %lf %lf %lf", &W, &H, &x, &y);

    printf("%lf", (W * H / 2));

    if ((W / 2) == x && (H / 2) == y)
    {
        printf(" 1");
    } else
    {
        printf(" 0");
    }
    
    return 0;
}

Measured memory_bytes: 128
// kid_kb //

#include<bits/stdc++.h>
using namespace std;
#define endl '\n'
#define ll long long
#define ull unsigned long long int
#define lower(str) transform(str.begin(),str.end(),str.begin(),::tolower);
#define upper(str) transform(str.begin(),str.end(),str.begin(),::toupper);
#define mod 1000000007
#define SORT(vec) sort(vec.begin(),vec.end());
#define pb push_back
#define csb __builtin_popcount
#define msb(n) (ll)(log2(n))
#define DIG(n) floor(log10(n))+1
#define kb ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define ptr(arr) for(auto i:arr)cout<<i<<" ";
#define ptr2(vec) for(auto i:vec){for(auto j: i){cout<<j<<" ";}cout<<endl;}
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,n,a) for (int i=n-1;i>=a;i--)
#define mem(a,val) memset(a,val,sizeof(a))
#define INF INT_MAX
#define inf INT_MIN

// cout<<fixed<<setprecision(8)<<endl;

ll gcd(ll a,ll b)
{    if (a == 0)    return b;     return gcd(b % a, a); }

ll lcm(ll a,ll b)
{    ll g=gcd(a,b); ll ans=(a*b)/g; return ans;    }

ll fastpower(ll a,ll b,ll m){ if(b==0) return 1; if(b==1) return a%m; ll t=fastpower(a,b/2,m); t=(t*t)%m; if(b&1)t=(t*a)%m; return t;}

ll modInverse(ll a, ll m) { return fastpower(a, m-2, m); }

//----------------------------------------Let's Fight-----------------------------------------------------------------

void solve(){
    string s;
    cin>>s;
    if(s[s.length()-1]=='s'){
        cout<<s<<"es"<<endl;
    }
    else cout<<s<<"s"<<endl;
}

int main()
{
    kb
//  clock_t tStart = clock();
    ll t;
     t=1;
//    cin>>t;
    while(t--){
        solve();
    }
//  printf("%.2fs time lga\n", (double)(clock() - tStart)/CLOCKS_PER_SEC);
    return 0;
}


Measured memory_bytes: 3648
# D
N = int(input())
edge = [[] for _ in range(N)]
for _ in range(N-1):
    ai,bi,ci = map(int, input().split())
    edge[ai-1].append((bi-1, ci))
    edge[bi-1].append((ai-1, ci))
Q,K = map(int, input().split())
K = K-1
x,y = [],[]
for _ in range(Q):
    xi,yi = map(int, input().split())
    x.append(xi-1)
    y.append(yi-1)


dist = [float('inf')]*N # from K
visited = [False]*N
q = [K]
dist[K] = 0
visited[K] = True
while q:
    cur = q.pop()
    visited[cur] = True
    for nex,cost in edge[cur]:
        if not visited[nex]:
            q.append(nex)
            dist[nex] = dist[cur]+cost
#print(dist)
for xi,yi in zip(x,y):
    print(dist[xi] + dist[yi])

Measured memory_bytes: 52244
import sys
import collections

sys.setrecursionlimit(10 ** 8)
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

N, W = map(int, readline().split())
items = []
for i in range(N):
    w, v = map(int, readline().split())
    items.append((w, v))


def solve():
    dp = collections.defaultdict(lambda: -1)
    dp[0] = 0
    for i in range(N):
        wi, vi = items[i]
        ndp = collections.defaultdict(lambda: -1)
        for ws, vs in dp.items():
            if ws + wi <= W:
                ndp[ws + wi] = max(ndp[ws + wi], vs + vi)
        for wt, vt in ndp.items():
            dp[wt] = max(dp[wt], vt)
    return max(dp.values())


if __name__ == "__main__":
    print(solve())


Measured memory_bytes: 3956
#include<bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>

// using namespace __gnu_pbds;
using namespace std;

#define fbo find_by_order
#define ook order_of_key
#define fi first
#define se second
#define long long long
typedef pair<int,int> ii;
typedef pair<int,ii> iii;
typedef vector<int> vi;
typedef vector<ii> vii;
// typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
// mt19937_64 rng(std::chrono::system_clock::now().time_since_epoch().count());

// /mnt/c/Users/vince/Desktop/POST-IOI/  

int par[100003];
int parent(int u) {return par[u] = (u == par[u])? u : parent(par[u]); }
void gab(int u, int v)
{
	par[parent(u)] = parent(v);
}

int main()
{
	// ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	// freopen("input.in", "r", stdin);

	int n, m;
	scanf("%d %d", &n, &m);
	for(int i = 1; i <= n; i++)
		par[i] = i;
	
	while(m--)
	{
		int u, v;
		scanf("%d %d", &u, &v);
		if(parent(u) == parent(v)) continue;
		gab(u, v);
	}
	set<int> st;
	for(int i = 1; i <= n; i++)
		st.insert(parent(i));
	printf("%lu\n", st.size()-1);
}

Measured memory_bytes: 8068
n = gets.to_i
a = gets.split.each_with_index.map{|k,i| [k.to_i,i]}.sort_by{|t| [-t[0],t[1]]}
ans = [0]*n
mindex = a[0][1]
(n-1).times do |i|
  mindex = [a[i][1],mindex].min
  k = a[i][0]-a[i+1][0]
  ans[mindex] += k * (i+1)
end
ans[0] += n*a[n-1][0]
puts ans.join("\n")

Measured memory_bytes: 29768
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
  int n, m;
  cin >> n >> m;
  int r=n, l=1, a, b;
  for(int i=0;i<m;i++){
    cin >> a >> b;
    l=l>a?l:a;
    r=r>b?b:r;
  }
  cout << max(r-l+1,0) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = s; i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << endl;
#define CFYN(n) cout << ( (n) ? "YES":"NO") << endl;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;

int main(void)
{
    IOS
    int n; cin >> n;
    string s; cin >> s;

    int ans = 0;
    REP(i,10) {
        REP(j,10) {
            REP(k,10) {
                char c1 = '0'+i;
                auto p1 = s.find(c1);
                if (p1 == string::npos) continue;
                char c2 = '0' + j;
                auto p2 = s.find(c2,p1+1);
                if (p2 == string::npos) continue;

                char c3 = '0' + k;
                auto p3 = s.find(c3,p2+1);
                if (p3 != string::npos) ans++;
            }
        }
    }


    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define mset(a, b) memset(a, b, sizeof(a))
#define mcpy(a, b) memcpy(a, b, sizeof(a))
using namespace std;
typedef long long LL;
const int N = 105;

template <typename T> inline void read(T &AKNOI) {
	T x = 0, flag = 1;
	char ch = getchar();
	while (!isdigit(ch)) {
		if (ch == '-') flag = -1;
		ch = getchar();
	}
	while (isdigit(ch)) {
		x = x * 10 + ch - '0';
		ch = getchar();
	}
	AKNOI = flag * x;
}

template <typename T> inline void cmin(T &x, T y) {
	if (x > y) x = y;
}

template <typename T> inline void cmax(T &x, T y) {
	if (x < y) x = y;
}

char g[N][N];
int n, m, dp[N][N];

void init() {
	read(n); read(m);
	for (int i = 1; i <= n; ++i) {
		scanf("%s", g[i] + 1);
	}
}

void solve() {
	mset(dp, 0x3f);
	dp[1][1] = (g[1][1] == '#');
	for (int i = 1; i <= n; ++i) {
		for (int j = 1; j <= m; ++j) {
			if (g[i][j] == '#') {
				if (i > 1) cmin(dp[i][j], dp[i - 1][j] + (g[i - 1][j] != '#'));
				if (j > 1) cmin(dp[i][j], dp[i][j - 1] + (g[i][j - 1] != '#'));
			} else {
				if (i > 1) cmin(dp[i][j], dp[i - 1][j]);
				if (j > 1) cmin(dp[i][j], dp[i][j - 1]);
			}
		}
	}
	printf("%d\n", dp[n][m]);
}

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


Measured memory_bytes: 256
#include <iostream>
#include <numeric>
#include <math.h>
#include <algorithm>
#include <float.h>
#include <limits>
#include <vector> 
#include <string.h>
#include <iomanip>

#define rep(i,a,n) for(ll int (i) = (a);(i) < (n);(i)++)
#define urep(i,a,n) for(ll int (i) = (a);(i) > (n);(i)--)
#define MOD 1000000007
#define INF 2147483647
#define ll long long
#define asort(a) sort(a.begin(),a.end());

using namespace::std;

int jo(ll int jxo, ll int jyo){//累乗
    ll int jhogeo = 1;
    rep(jinto,0,jyo) jhogeo=jhogeo*jxo;
    return jhogeo;
}
char tobig(char toxbig){//char大文字化
  return (toxbig-0x20);
}
char tolow(char toxlow){//char小文字化
  return (toxlow+0x20);
}
int ctoi(char cctoi){//char->int
  if('0' <= cctoi && cctoi <= '9') return (cctoi-'0');
  return -1;
}

int gcd(int gcad, int gcbd) {//最大公約数
  if(gcad < gcbd) return gcd(gcbd, gcad);
  int gcrd;
  while ((gcrd=gcad%gcbd)) {
    gcad = gcbd;
    gcbd = gcrd;
  }
  return gcbd;
}
int lcm(int lcam, int lcbm){//最小公倍数
 return (lcam*lcbm)/gcd(lcam,lcbm);
}


int main(){
  double N;
  cin>>N;
  double price1 = (N+1)/1.08;
  double price2 = (N)/1.08;
  int check=0;
// cout<<price1<<" "<<price2;
  rep(i,1,50000){
    if(price2<=double(i)&&double(i)<price1){
      check++;
      cout<<i;
      break;
    }
  }
  if(!check) cout<<":(";
  

}
// int *p = new int[N];

//  vector<int> 変数名(要素数);
//  sort(変数名.begin(),変数名.end());//昇順ソート

// vector<vector<int>> 変数名(左の個数, vector<int>(右の個数));

//cout<<fixed<<setprecision(n);  //小数点n桁まで表示

//  vector<pair<int,int>> data(N);  //2つのデータを格納、.first/.secondで参照
// pairのソートはfirst優先の昇順


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <queue>
using namespace std;
#define INF 1000000007
#define ll long long
#define rep(i, start, end) for(ll i=(ll)start; i<(ll)end; i++)
#define print(a) cout << a << endl;
#define printarray(a, len) rep(i,0,len) cout << a[i] << " ";

int main(){
  ll l, r, ans = 2019;
  cin >> l >> r;
  r = min(r, l+2019);
  rep(i, l, r){
    rep(j, i+1, r+1){
      ans = min(ans, i*j % 2019);
    }
  }
  print(ans);
  
  return 0;
}

Measured memory_bytes: 256
A, B, C, D = list(input())
ops = ['+', '-']
for op1 in ops:
    for op2 in ops:
        for op3 in ops:
            s = '{}{}{}{}{}{}{}'.format(A, op1, B, op2, C, op3, D)
            if eval(s) == 7:
                print('{}=7'.format(s))
                exit()

Measured memory_bytes: 3060
#include<iostream>
using namespace std;
int main(){
    int a,b,c;
    cin>>a>>b>>c;
    int max;
    max=b/a;
    if(max>=c){
        cout<<c<<endl;
        return 0;
    }else{
        cout<<max<<endl;
        return 0;
    }
}

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

/* using */
using namespace std;

/* main constructor */
struct Fast
{
    Fast()
    {
        std::cin.tie(0);
        ios::sync_with_stdio(0);
        //cout << fixed << setprecision(12);
    }
} fast;

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

/* define */
#define REP(i, x, n) for (int i = x; i < (int)(n); ++i)
#define RREP(i, x, n) for (int i = x - 1; i >= (int)(n); --i)
#define rep(i, n) REP(i, 0, n)
#define reps(i, n) REP(i, 1, n + 1)
#define rrep(i, n) RREP(i, n, 0)
#define each(i, n) for (auto &i : n)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define eunique(x) (x).erase(unique(all(x)), (x).end())
#define int long long

/* function */
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a * b / gcd(a, b); }

/* const */
const int inf = 1e9 + 7;

/* main */
signed main(void)
{
    string a, b;
    cin >> a >> b;
    if (a.size() > b.size())
    {
        cout << "GREATER" << endl;
    }
    else if (a.size() < b.size())
    {
        cout << "LESS" << endl;
    }
    else
    {
        bool flag = false;
        for (int i = 0; i < a.size(); i++)
        {
            if (a[i] > b[i])
            {
                cout << "GREATER" << endl;
                flag = true;
                break;
            }
            else if (a[i] < b[i])
            {
                cout << "LESS" << endl;
                flag = true;
                break;
            }
        }
        if (flag == false)
        {
            cout << "EQUAL" << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 256