akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
int main() {
	int a;	cin >> a;
  	if(a > 81){
    	cout << "No" << endl;
      	return 0;
    }
  	
  	int cnt = 0;
  	rep(i,9){
    	if(a%(i+1) == 0 && (0 <= a/(i+1) && a/(i+1) <= 9)) cnt++;
    }
  		
  	if(cnt > 0) cout << "Yes" << endl;
  	else cout << "No" << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<set>
#include<map>
#include<iostream>
using namespace std;
#define ll long long
#define REP(a,b,c) for(int a=b;a<=c;a++)
#define re register
#define file(a) freopen(a".in","r",stdin);freopen(a".out","w",stdout)
typedef pair<int,int> pii;
#define mp make_pair
inline int gi()
{
	int f=1,sum=0;char ch=getchar();
	while(ch>'9' || ch<'0'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0' && ch<='9'){sum=(sum<<3)+(sum<<1)+ch-'0';ch=getchar();}
	return f*sum;
}
const int N=100010;
int n;
struct node{int l,r;bool operator<(const node &b)const{return r<b.r;}}p[N];
int main()
{
	n=gi();
	for(int i=1;i<=n;i++)
	{
		int x=gi(),l=gi();
		p[i]=(node){x-l,x+l};
	}
	sort(p+1,p+n+1);int ans=0,r=-1e9-10;
	for(int i=1;i<=n;i++)
		if(p[i].l>=r)
		{
			r=p[i].r;ans++;
		}
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 1024
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<iostream>
using namespace std;

#define N_MAX 100

typedef struct _v {
    int k;
    struct _v *v;
} Vertex;
Vertex Adj[N_MAX];
int M[N_MAX][N_MAX];


int main() {
    int n;

    cin >> n;

    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            M[i][j] = 0;
        }
        int k;
        cin >> k;
        cin >> k;
        for (int j = 0; j < k; j++) {
            int l;
            cin >> l;
            M[i][l-1] = 1;
//            printf("M[%d][%d] = %d\n", i, l-1, M[i][l-1]);
        }
    }

    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            cout << M[i][j];
            if (j == n - 1) {
                cout << endl;
            }
            else {
                cout << " ";
            }
        }
    }


    return 0;
}



Measured memory_bytes: 3112
#include <iostream>
using namespace std;
inline bool isadd(int num, int leftb, int rightb){
    int iSum = 0;
    while (num){
        iSum += num % 10;
        num /= 10;
    }
    return (leftb <= iSum && iSum <= rightb);
}
int main(){
    ios::sync_with_stdio(false);
    int end, leftb, rightb;
    cin >> end >> leftb >> rightb;
    register int i;
    register long long iSum = 0;
    for (i = 1; i <= end; ++i){
        if (isadd(i, leftb, rightb))
            iSum += i;
    }
    cout << iSum << endl;
    return 0;
}

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

using namespace std;

const int MAXN = 3005;
const ll mod = 998244353;

ll dp[MAXN][MAXN][3];

int main() {
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	dp[a][b][0] = 1;
	for (int i = a + 1; i <= c; i++) {
		dp[i][b][0] = (dp[i - 1][b][0]) * b % mod;
		//dp[i][b][0] = (dp[i - 1][b][0] + dp[i - 1][b][1]) % mod;
	}

	for (int j = b + 1; j <= d; j++) {
		dp[a][j][0] = (dp[a][j - 1][0]) * a % mod;
		//dp[a][j][2] = (dp[a][j - 1][0] + dp[a][j - 1][2]) % mod;
	}
	for (int i = a + 1; i <= c; i++) {
		for (int j = b + 1; j <= d; j++) {
			dp[i][j][0] = (dp[i - 1][j][0] + dp[i - 1][j][1]) * (j - 1) % mod;

			dp[i][j][1] = (dp[i][j - 1][0] + dp[i][j - 1][1] * i + dp[i][j - 1][2]) % mod;

			dp[i][j][2] = (dp[i - 1][j][0] + dp[i - 1][j][2] * j + dp[i - 1][j][1]) % mod;



			//dp[i][j][0] = ((dp[i - 1][j][0] + dp[i - 1][j][1] + dp[i - 1][j][2]) * (j - 1) + (dp[i][j - 1][0] + dp[i][j - 1][1] + dp[i][j - 1][2]) * (i - 1)) % mod; 
			//dp[i][j][1] = (dp[i - 1][j][0] + dp[i - 1][j][1] + dp[i - 1][j][2]) % mod;
			//dp[i][j][2] = (dp[i][j - 1][0] + dp[i][j - 1][1] + dp[i][j - 1][2]) % mod;
		}
	}
	/*
	for (int i = a; i <= c; i++) {
		for (int j = b; j <= d; j++) {
			if (i == a && j == b)
				continue;
			if (i == a) {
				dp[i][j] = dp[i][j - 1] * i % mod;
				continue;
			}
			if (j == b) {
				dp[i][j] = dp[i - 1][j] * j % mod;
				continue;
			}
			dp[i][j] = ((dp[i - 1][j] * j + dp[i][j - 1] * i) % mod + mod) % mod;
		}
	}
	*/
	cout << (dp[c][d][0] + dp[c][d][1] + dp[c][d][2]) % mod << endl;
}

Measured memory_bytes: 214880
// 標準入力から一行を読み取り、指定の型に変換する
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

// 標準入力から一行を読み取り、空白文字で分割し、各要素を指定の型に変換する関数
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>().split_whitespace()
        .map(|e| e.parse().ok().unwrap()).collect()
}

fn main() {
    let hn: Vec<i64> = read_vec();
    let a: Vec<i64> = read_vec();

    let h = hn[0];

    let sum_a: i64 = a.iter().sum();
    if sum_a >= h { println!("Yes"); return; }

    println!("No");
}


Measured memory_bytes: 6396
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 minInt(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func minUint(a, b uint) uint {
	if a < b {
		return a
	}
	return b
}

func minInt64(a, b int64) int64 {
	if a < b {
		return a
	}
	return b
}

func minUint64(a, b uint64) uint64 {
	if a < b {
		return a
	}
	return b
}

func maxInt(a, b int) int {
	if a < b {
		return b
	}
	return a
}

func maxUint(a, b uint) uint {
	if a < b {
		return b
	}
	return a
}
func maxInt64(a, b int64) int64 {
	if a < b {
		return b
	}
	return a
}

func maxUint64(a, b uint64) uint64 {
	if a < b {
		return b
	}
	return a
}

func absInt(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

func absInt64(a int64) int64 {
	if a < 0 {
		return -a
	}
	return a
}

// readString() string
// readInt() int
// readIntSlice(n int) []int
// readLengthAndSlice() []int
func main() {
	defer stdout.Flush()
	n := readInt()
	var ans int64
	for i := 0; i < n; i++ {
		a := readInt64()
		ans += a - 1
	}
	println(ans)
}


Measured memory_bytes: 640
#include <iostream>
#include <iomanip>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cctype>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <cstdio>
#include <functional>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
using namespace std;
// #define int long long
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define FORD(i,a,b) for(int i=(a);i>=(b);i--)
inline bool EQ(double a, double b) { return fabs(a-b) < 1e-9; }
const int INF = (((1<<30)-1)<<1)+1;
const int nINF = 1<<31;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<char, int> pci;

/////////////////////////////////////////////////////////////////////

const int N = 1e5+10;
int n, m, d[N], dp[N];
vector<int> g[N];

signed main() {
    ios::sync_with_stdio(false);
    //cout << fixed << setprecision(7);
    cin >> n >> m;
    REP(i, m) {
    	int a, b;
    	cin >> a >> b;
    	++d[b];
    	g[a].push_back(b);
    }
    queue<int> nxt;
    FOR(i, 1, n) if(d[i] == 0) nxt.push(i);
    while(!nxt.empty()) {
    	int cur = nxt.front();
    	nxt.pop();
    	for(int v : g[cur]) {
    		dp[v] = max(dp[v], dp[cur]+1);
    		--d[v];
    		if(d[v] == 0) nxt.push(v);
    	}
    }
	int ans = 0;
	FOR(i, 1, n) ans = max(ans, dp[i]);
	cout << ans << endl;

    return 0;
}

// Easy things to check:
// - LONG LONGS (WA)
// - const int N is correct (WA, RTE)
// - .size()-k underflow (WA, RTE, TLE)
// - small n edge cases (WA)

// Rare mistakes made in the past:
// - division by 0 (WA)
// - integer division (WA)
// - setprecision (WA)
// - INF not big enough using ll (WA)
// - setting min to 0 instead of -INF (WA)
// - outputting debug (WA)
// - allocating too much memory (locRTE, MLE)
// - stack size (locRTE)


Measured memory_bytes: 6528
#include <bits/stdc++.h>
#include<string.h>
using namespace std;
#define li long long int
#define mod 1000000000+7
li n,k;
li a[3005];
li dp[3005][3005];
li f(li i,li j)
{
   if(i==j)
   {
       return a[i];
   }
   if(i==j-1)
   {
       return max(a[i],a[j]);
   }
   if(dp[i][j]!=-1)
   {
       return dp[i][j];
   }
   li op1=a[i]+min(f(i+2,j),f(i+1,j-1));
   li op2=a[j]+min(f(i+1,j-1),f(i,j-2));
   li ans=max(op1,op2);
   return dp[i][j]=ans;
}

int main()
{
    cin>>n;

    memset(dp,-1,sizeof(dp));
    li i,s=0;
    for(i=0;i<n;i++)
    {
        cin>>a[i];
        s+=a[i];
    }

    cout<<2*f(0,n-1)-s;


    return 0;
}


Measured memory_bytes: 70912
#include<bits/stdc++.h>
using namespace std;
#define int long
using pi=pair<int,int>;
signed main(){
    int k;
    cin >> k;
    int r = 0;
    for (int a = 1; a <= k; ++a)
        for (int b = 1; b <= k;++b)
            for (int c = 1; c <= k;++c)
                r += gcd(gcd(a, b), c);
    cout<<r;
}

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

namespace abc061_a
{
    class Program
    {
        static void Main()
        {
            int[] s = Console.ReadLine().Split().Select(int.Parse).ToArray();
            Console.WriteLine(s[0] <= s[2] && s[2] <= s[1] ? "Yes" : "No");
            Console.Read();
        }
    }
}


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

// 総数を1000000007（素数）で割った余り
const long long mod = 1e9 + 7;

using ll = long long;
using pii  = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

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

string name(ll n) {
    if (n == 0) return "";
    --n;
    return name(n/26) + (char)(n%26+'a');
}

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


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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N;
  cin >> N;
  vector<int> A(N);
  for (int i = 0; i < N; i++) {
    cin >> A[i];
  }
  int res = 0;
  for (int i = 0; i < N; i++) {
    while (i + 1 < N && A[i] == A[i + 1]) {
      i++;
    }
    if (i + 1 < N && A[i] < A[i + 1]) {
      while (i + 1 < N && A[i] <= A[i + 1]) {
        i++;
      }
    } else if (i + 1 < N && A[i] > A[i + 1]) {
      while (i + 1 < N && A[i] >= A[i + 1]) {
        i++;
      }
    }
    res++;
  }
  cout << res << '\n';
  return 0;
}


Measured memory_bytes: 640
def main():
  N = int(input())
  ab = [list(map(int,input().split())) for _ in range(N)]
  cd = [list(map(int,input().split())) for _ in range(N)]
  ab = sorted(ab)
  cd = sorted(cd)
  cnt = 0
  i = 0
  while i < len(cd):
    x = cd[i][0]
    std = -1
    y = -1
    for j in range(len(ab)):
      if ab[j][0] < x and ab[j][1] > y and ab[j][1] < cd[i][1]:
        std = j
        y = ab[j][1]
    if std == -1:
      i += 1
      continue
    cd.pop(i)
    ab.pop(std)
    cnt += 1
  #print(ab)
  #print(cd)
  print(cnt)
  
main()

      
    
  



Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
       
        Scanner sc = new Scanner(System.in);
        int hoge = sc.nextInt();
        int[] array1 = new int[hoge];
        int[] array2 = new int[hoge];
        double sum = 0;
        for(int i = 0; i < hoge; i++){
            array1[i] = sc.nextInt();
            array2[i] = sc.nextInt(); 
        }
        for(int i = 0; i < hoge; i++){
            for(int j = 0; j < hoge; j++){
                if(i == j){
                    continue;
                }
                sum += Math.sqrt(Math.pow(array1[i] - array1[j], 2) + Math.pow(array2[i] - array2[j], 2));
            }
        }
        System.out.println(sum/hoge);
    }     
}

Measured memory_bytes: 21716
//g++ -std=c++17 -Wshadow -Wall -fsanitize=address -fsanitize=undefined -D_GLIBCXX_DEBUG -g PROGRAM -o OUTPUT -DLOCAL -lasan -lubsan
#include <bits/stdc++.h>
#include <ext/pb_ds/detail/standard_policies.hpp>

#define ll long long
#define ull unsigned long long
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define alli(a, n, k) (a + k), (a + n + k)
#define FP(i, a, b, k) for (__typeof(a) i = a; i < b; i += k)
#define FS(i, a, b, k) for (__typeof(a) i = a; i > b; i -= k)
#define IT(it, a) for (__typeof(a.begin()) it = a.begin(); it != a.end(); ++it)
#define eps 1e-6
#define pi 3.141592653589793
using namespace std;
using namespace __gnu_pbds;

template <class T>
inline T gcd(T x, T y)
{
    if (!y)
        return x;
    return gcd(y, x % y);
}
typedef vector<int> VII;
typedef vector<ll> VLL;
typedef pair<int, int> PII;
typedef vector<pair<int, int>> VPII;
typedef vector<pair<int, PII>> VPPI;
const int MOD = 1e9 + 7;
const int INF = 1e9;


inline ll modulo(ll a, ll m)
{
    return (a % m + m) % m;
}

inline ll modInverse(ll a, ll m)
{
    assert(__gcd(a, m) == 1);
    ll m0 = m;
    ll y = 0, x = 1;

    if (m == 1)
        return 0;

    while (a > 1)
    {
        ll q = a / m;
        ll t = m;

        m = a % m, a = t;
        t = y;

        y = x - q * y;
        x = t;
    }

    if (x < 0)
        x += m0;

    return x;
}

inline ll modPow(ll x, ll y, ll m)
{ //x^y % m
    if (y == 0)
        return 1LL;
    else if (y == 1)
        return x;
    else
    {
        ll ans = modPow(x, y / 2, m) % m;
        if (y & 1)
        {
            return (((ans * ans) % m) * x) % m;
        }
        else
        {
            return (ans * ans) % m;
        }
    }
}

vector<string> split(char d,string s)
{
    stringstream ss(s);
    string t;
    vector<string> words;
    while(getline(ss,t,d))
    {
        words.pb(t);
    }

    return words;
}

int main(int argc, char *argv[])
{
#ifdef LOCAL
    auto start = chrono::high_resolution_clock::now();
#endif
    
    ios::sync_with_stdio(false);
    cin.tie(NULL);

    int n;
    cin >> n;
    VLL arr(n);

    int ans = 0;
    for(auto &x:arr)
        cin >> x;

    for (int i = 0; i < n;++i)
    {
        for (int j = i + 1; j < n;++j)
        {
            for (int k = j + 1; k < n;++k)
            {
                VLL a = {arr[i], arr[j], arr[k]};
                if(a[0]==a[1] || a[1]==a[2] || a[0]==a[2])
                    continue;
                if((a[0]+a[1]>a[2]) && (a[1]+a[2]>a[0]) && (a[0]+a[2]>a[1]))
                    ans++;
            }
        }
    }

    cout << ans;
    exit(0);

#ifdef LOCAL
    auto end = chrono::high_resolution_clock::now();
    double time_taken =
        chrono::duration_cast<chrono::nanoseconds>(end - start).count();

    time_taken *= 1e-9;

    cerr << "\nTime taken by program is : " << fixed
         << time_taken << setprecision(9);
    cerr << " sec" << endl;
#endif
    return 0;
}


Measured memory_bytes: 3668
#include <iostream>
using namespace std;
int main(){
    int N; cin >> N;
    string S; cin >> S;
    int ans = 0;
    for(int i = 0; i < N-2; i++){
        if(S[i] == 'A'){
            if(S[i+1] == 'B'){
                if(S[i+2] == 'C') ans++; 
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define si size()
#define bk back()
#define popb pop_back()
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define endl "\n"
#define lb lower_bound
#define ub upper_bound
#define emp empty()
#define beg begin()
#define en end()
#define ump unordered_map
#define forl(i,a,n) for(int i=a;i<n;i++)
#define rfor(i,n,a) for(int i=n;i>=a;i--)
#define fore(i,a,n) for(int i=a;i<=n;i++)
#define len length()
double doINF = 1.0/0.0 ;
ostream_iterator <int> outp(cout," ");
inline ll modadd(ll n,ll m,ll mod){
    ll sum = ((n+m)%mod+mod)%mod;
    return sum;
} 
inline ll modsub(ll n,ll m, ll mod){
    ll diff = ((n-m+mod)%mod+mod)%mod;
    return diff;
}
inline ll modpro(ll n,ll m,ll mod){
    ll pro = ((n*m)%mod+mod)%mod;
    return pro;
}
inline ll pow(int x,int y){
    ll res = 1;
    while (y > 0) {
        if (y & 1)
            res = res * x;
        y = y >> 1;
        x = x * x;
    }
    return res;
}
inline ll powmod(ll x,ll y,ll mod){
    ll res = 1;
    while (y > 0) {
        if (y & 1)
            res = modpro(res , x,mod);
        y = y >> 1;
        x = modpro(x , x,mod);
    }
    return res;
}
//ll min(ll a, ll b){
//    if(a>b){
//        return b;
//    }
//    return a;
//}
// 
//ll max(ll a, ll b){
//    if(a>b){
//        return a;
//    }
//    return b;
//}
bool pairdec(const pair<int,int> &a,  
               const pair<int,int> &b) 
{ 		if(a.fi!=b.fi)
       	return (a.fi> b.fi);
		else return a.se>b.se;  
} 

ll power(ll x, ll y, ll mod) 
{ 
    ll res = 1; 
    x = x%mod; 
    while (y > 0) { 
        if (y & 1) 
            res = (res * x) % mod; 
  
        y = y >> 1;
        x = (x * x) % mod; 
    } 
    return res; 
} 
ll modInverse(ll a, ll mod) 
{ 
    return  powmod(a, mod - 2, mod); 
} 
ll modFact(ll n, ll mod) 
{ 
    if (n >=mod) 
        return 0; 
  
    ll result = 1; 
    for (ll i = 1; i <= n; i++) 
        result = (result * i) %mod; 
  
    return result; 
} 
//cout<<setprecision(9)<<fixed<<sum<<endl; --- precision for double numbers
//copy(v.beg,v.en,outp);

int main()
{
	int a,b;
	cin>>a>>b;
	if(a==1 && b==2)cout<<3<<endl;
	if(a==1 && b==3)cout<<2<<endl;
	if(a==3 && b==2)cout<<1<<endl;
	if(a==2 && b==3)cout<<1<<endl;
	if(a==3 && b==1)cout<<2<<endl;
	if(a==2 && b==1)cout<<3<<endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long int;
using ld=long double;
using VI=vector<ll>;
using VD=vector<ld>;
using VVI=vector<VI>;
using VC=vector<char>;
using VVC=vector<VC>;
using VS=vector<string>;
using PLL =pair<ll,ll>;
using PLD=pair<ld,ld>;
using VPLL=vector<PLL>;
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define FORD(i,a,b) for(ll i=(a);i>=(b);i--)
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element((x).begin(),(x).end())
#define MIN(x) *min_element((x).begin(),(x).end())
#define SORTR(x) sort((x).rbegin(),(x).rend())
#define SORT(x) sort((x).begin(),(x).end())
#define SUM(x) accumulate((x).begin(),(x).end(), 0)
#define FILL(x,a) fill(x.begin(),x.end(),a)
#define EACH(i,x) for(typeof((x).begin()) i=(x).begin(); i!=(x).end(); ++i)

const int INF  = 1<<30;
const ld EPS   = 1e-10;
const int MOD  = int(1e9)+7;
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; }
template <class BidirectionalIterator>
bool next_partial_permutation(BidirectionalIterator first, BidirectionalIterator middle,BidirectionalIterator last){reverse(middle, last); return next_permutation(first , last);}
#define COUT(x) cout<<x<<"\n"

void Main()
{
	ll result=0;
	map<string,ll> day={
			{"SUN",7},
			{"MON",6},
			{"TUE",5},
			{"WED",4},
			{"THU",3},
			{"FRI",2},
			{"SAT",1},
	};
	string S;
	cin>>S;
	result=day[S];
	cout << result << "\n";
	return;
}

int main()
{
	std::cin.tie(0);
	std::ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	Main();
}


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

int main()
{
    int n;
    bool isblue[4000] = {};
    long r = 0, g = 0, b = 0;
    vector<int> rs = {};
    vector<int> gs = {};
    cin >> n;

    for (int i = 0; i < n; i++) {
        char c;
        cin >> c;
        if (c == 'R') {
            isblue[i] = false;
            r++;
            rs.push_back(i);
        } else if (c == 'G') {
            isblue[i] = false;
            g++;
            gs.push_back(i);
        } else if (c == 'B') {
            isblue[i] = true;
            b++;
        }
    }

    long ans = r * g * b;
    for (auto r : rs) {
        for (auto g : gs) {
            int i = 2 * r - g;
            if (i >= 0 && i < n && isblue[i])
                ans--;

            i = 2 * g - r;
            if (i >= 0 && i < n && isblue[i])
                ans--;

            if ((r + g) % 2 == 0) {
                int i = (r + g) / 2;
                if (isblue[i])
                    ans--;
            }
        }
    }

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3652
def solve(brd, list)
  if list.all?{|v| !v}
    brd.map{ |bs| puts bs.map{ |b| b ? '.' : 'Q' }.join }
    return
  end
  y = list.index{|v| v}
  (0..7).each do |x|
    if brd[y][x] && check(y, x, brd)
      brd[y][x] = false
      list[y] = false
      solve(brd, list)
      list[y] = true
      brd[y][x] = true
    end
  end
end

def check(y, x, brd)
  (1..7).each do |i|
    [-1, 1].each do |dy|
      (-1..1).each do |dx|
        ny = y + dy * i
        nx = x + dx * i
        if 0 <= ny && ny < 8 && 0 <= nx && nx < 8
          return false unless brd[ny][nx]
        end
      end
    end
  end
  true
end

brd = 8.times.map{ [true] * 8 }
list = [true] * 8
gets.to_i.times do
  r, c = gets.split.map(&:to_i)
  list[r] = false
  brd[r][c] = false
end

solve(brd, list)

Measured memory_bytes: 8784
# 参考：
# https://qiita.com/drken/items/dc53c683d6de8aeacf5a

# ver 2,振り返る DP

n=int(input())
a=list(map(int,input().split()))

# dp には 足場(i)へ至る最小コストが入る。
dp=[float("inf")]*(n)

# 振り返り起点(i==2)までのdp値は埋めておく。
dp[0]=0
dp[1]=abs(a[1]-a[0])
for i in range(2,n):
  dp[i]=min(dp[i-1]+abs(a[i]-a[i-1]), dp[i-2]+abs(a[i]-a[i-2]))
print(dp[-1])


Measured memory_bytes: 20576
#include <bits/stdc++.h>
#define rep(i,n)for(long long i=0;i<(long long)(n);i++)
#define all(a) a.begin(), a.end()
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
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 ll MOD=1e9+7;
const ll INF=1e18;
const int MAX=510000;
const double pi=acos(-1);
int dx[8] = {1,0,-1,0,1,1,-1,-1};
int dy[8] = {0,1,0,-1,-1,1,1,-1};
// int d[13]={0,31,28,31,30,31,30,31,31,30,31,30,31};


int main(){
  cin.tie(0);
  ios::sync_with_stdio(false); 
  ll n,k;
  cin >> n >> k;
  vector<ll> a(n);
  rep(i,n) cin >> a[i];
  
  
  while(k--){
    vector<ll>b(n+1,0);
    rep(i,n){
      ll left=max(0ll,i-a[i]);
      ll right=min(n,i+a[i]+1);
      b[left]++;
      b[right]--;
    }
    rep(i,n){
      a[i]=b[i];
      b[i+1]+=b[i];
    }
    bool ok = true;
    rep(i,n)if(a[i]!=n)ok=false;
    if(ok)break;
  }
  rep(i,n) cout << a[i]<< " ";
  cout << endl;
  return 0;
}


Measured memory_bytes: 6368
/*  ex5_3
    L40S38  */
#include<stdio.h>
#define LIMIT 100
int main(void){
    int high,wide,i,j,black_exist_high[LIMIT],black_exist_wide[LIMIT];
    //high,wide:マス目の縦,横の長さ
    //black_exist_high:黒いマスがあった行番号を格納
    //black_exist_wide:黒いマスがあった列番号を格納
    char cells[LIMIT][LIMIT];
    scanf("%d %d",&high,&wide);
    
    for(i=0;i<LIMIT;i++){
        black_exist_high[i]=0;
    }//black_exist_highの初期化
    for(j=0;j<LIMIT;j++){
        black_exist_wide[j]=0;
    }//black_exist_wideの初期化
    
    for(i=0;i<high;i++){
        for(j=0;j<wide;j++){
            scanf(" %c",&cells[i][j]);
            if(cells[i][j]=='#'){
                black_exist_high[i]=1;
                black_exist_wide[j]=1;
                //黒いマスがあったらその行、列に印（1）をつける
            }
        }
    }
    
    for(i=0;i<high;i++){
        if(black_exist_high[i]==1){
            for(j=0;j<wide;j++){
                if(black_exist_wide[j]==1){
                    printf("%c",cells[i][j]);
                    //行・列の両方に印があった要素だけ出力
                }
            }
            printf("\n");
        }
    }
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i = 0; i < (N); i++)
#define repo(i,N) for(int i = 1; i < (N); i++)
//#define int long long
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
//#define num 1000000007
#define pi acos(-1.0)
//cout << fixed << setprecision (10);   小数点以下１０桁まで
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//'大文字'+=32;    で小文字に
//string s = to_string(int数);
//int n = stoi(string文字列);

int main() {
  int a,b,c;
  cin >>a>>b>>c;
  
  cout << (a+b+c>=22?"bust":"win") << endl; 
  
}


Measured memory_bytes: 256
from sys import stdin

n = int(stdin.readline().rstrip())

def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    divisors.sort()
    return divisors

li = make_divisors(n)
mi = len(str(n))

for i in li:
    a = i
    b = n//a
    keta = max(len(str(a)),len(str(b)))
    mi = min(mi,keta)

print(mi)

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

int main(){
	int N;
	cin >> N;
	int rate[9];
	rep(i,9) rate[i] = 0;
	rep(i,N) {
		int a;
		cin >> a;
		a /= 400;
		if (a >= 8) rate[8]++;
		else  rate[a] = 1;
	}

	int ans_min = 0, ans_max;
	rep(i,8) ans_min += rate[i];
	ans_max = ans_min + rate[8];

	if (ans_min == 0) {
		ans_min = 1;
		ans_max = rate[8]--;
	}
	cout << ans_min << " " << ans_max << endl;

	return 0;
}


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

vector<string> divide = {"dream", "dreamer", "erase", "eraser"};
 
int main() {
  string s;
  cin >> s;
  
  reverse(s.begin(), s.end());
  rep(i, divide.size()) reverse(divide[i].begin(), divide[i].end());
  
  bool can = true;
  
  for (int i = 0; i < s.size();) {
    bool can2 = false;
    
    rep(j, divide.size()) {
      string d = divide[j];
      if (s.substr(i, d.size()) == d) {
        can2 = true;
        i += d.size();
      }
    }
    if (!can2) {
      can = false;
      break;
    }
  }
  
  if (can) cout << "YES" << endl;
  else cout << "NO" << endl;
}


Measured memory_bytes: 512
use std::io::{self, BufRead};

fn main() {
    let stdin = io::stdin();
    let mut lines = stdin.lock().lines();
    lines.next();
    let mut a: Vec<i32> = lines
        .next()
        .unwrap()
        .unwrap()
        .split_whitespace()
        .map(|s| s.parse().unwrap())
        .collect();

    let n = a.len();
    a.sort();
    a.dedup();
    if n == a.len() {
        println!("YES");
    } else {
        println!("NO");
    }
}


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

namespace _0059
{
    public class Program

    {
        public static void Main(string[] args)
        {
            while (true)
            {
                string line = Console.ReadLine();
                if (string.IsNullOrEmpty(line)) return;

                double[] items = Array.ConvertAll(line.Trim().Split(' '), e => double.Parse(e));

                double xa1 = items[0]; double ya1 = items[1]; double xa2 = items[2]; double ya2 = items[3];
                double xb1 = items[4]; double yb1 = items[5]; double xb2 = items[6]; double yb2 = items[7];

                bool xCross = xa1 <= xb2 && xb1 <= xa2;
                bool yCross = ya1 <= yb2 && yb1 <= ya2;

                string res = (xCross && yCross) ? "YES" : "NO";

                Console.WriteLine(res);
            }
        }
    }
}



Measured memory_bytes: 13736
#include<bits/stdc++.h>
#include <cstdio>
using namespace std;
#define ll  long long
#define PB push_back
#define ld long double
#define ff first
#define ss second
# define st(v) (v).begin(),(v).end()
#define   pr pair<int,int>
const int dx[4] = {1,0,0,-1};
const int dy[4] = {0,-1,1,0};
void solve(){
	int n , m ;
	cin >> n >> m ;
	vector < vector < int > > v(m,vector<int>()); 
	for( int i = 0 ; i < m ; i++){
		int k , s ;
		cin >> k ;
		for( int j = 0 ; j < k ; j++){
			cin >> s ;
			s--;
			v[i].PB(s);
		}
	}
	vector < int > p(m);
	for( int i = 0 ; i < m ; i++) cin >> p[i] ;
	int ans = 0 ;
	for( int i = 0 ; i < (1<<n) ; i++ ){
		bool flag = true ;
		for( int j = 0 ; j < m ; j++){
			int cnt = 0 ;
			for( int k = 0 ; k < (int)v[j].size() ; k++){
				int s = v[j][k] ;
				if((i&(1<<s))){
					cnt++;
				}
			}
			if( (cnt%2) != p[j]){
				flag = false ;
				break ;
			}
		}
		if(flag){
			ans++;
		}
	}
	cout << ans ;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int q=1;
    //cin >> q;
    while(q--)
        solve();
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
 
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <vector>
#include <math.h>

using namespace std;

int main(){
	int n;

	while(cin >> n){
		int max = 0;
		int soremade = 0;
		int mae = 0;
		int ima = 0;

		if(n==0) break;
		
		cin >> mae;
		max = mae;

		for(int i=1;i<n;i++){
			if(mae > soremade+mae){
				soremade = mae;
			}else{
				soremade += mae;
			}
			
			cin >> ima;
			
			if(max < ima){
				max = ima;
			}
			if(max < ima+soremade){
				max = ima+soremade;
			}
			mae = ima;
		}

		cout << max << endl;
	}

	return 0;
}

Measured memory_bytes: 1160
#include <iostream>
using namespace std;
int main() {
    string S, T;
    cin >> S;
    cin >> T;
    int cnt = 0;
    for (int i = 0; i < S.size(); ++i) {
        char s = S[i];
        char t = T[i];
        if (s != t) { cnt++;}
    }
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 3468
use std::io;
use std::str::FromStr;

fn input<T:FromStr>() -> T {
    let mut line: String = String::new();
    io::stdin().read_line(&mut line);
    line.trim().parse().ok().unwrap()
}

fn input_i32_vec() -> Vec<i32> {
    let mut line: String = String::new();
    io::stdin().read_line(&mut line);
    line.split_whitespace().map(|s| s.parse().unwrap()).collect()
}

fn main() {
    let n: i32 = input();
    let p_vec: Vec<i32> = input_i32_vec();
    let mut sum = 0;
    for i in 0..(n-2) as usize {
        if p_vec[i] < p_vec[i+1] && p_vec[i+1] < p_vec[i+2] {
            sum += 1;
        }
        if p_vec[i] > p_vec[i+1] && p_vec[i+1] > p_vec[i+2] {
            sum += 1;
        }
    }
    println!("{}", sum);
}


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

int main() {
    int X;
    cin >> X;
    vector<int> nums;
    nums.push_back(1);
    for(int i=2; i<50; i++) {
        int t = i;
        while(t*i <= 1000) {
            t *= i;
            nums.push_back(t);
        }
    }
    sort(nums.begin(), nums.end());

    cout << *(upper_bound(nums.begin(), nums.end(), X)-1) << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
using namespace std;
int main(void){
	int n;
	while(1){
cin>>n;
if(n==0)break;
int t=0;
int sum=0;
int i=0,j=1;
while(i<n){
	i++;
sum+=i;
while(sum>=n){
	if(sum==n)t++;
sum-=j;
j++;
}

}
cout<<t-1<<endl;
	}
	return 0;
}

Measured memory_bytes: 3084
#include <iostream> // cout, endl, cin
#include <cmath> //sqrt pow
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
 
#define rep(i,n) for(int i = 0; i < n; i++)
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int, int>
#define mod 1000000007
using ll = long long;
using namespace std;
int main(){
  int n;
  cin >> n;
  vvi tru(n), fal(n);
  rep(i, n){
    int a;
    cin >> a;
    rep(j, a){
      int x,y;
      cin >> x >> y;
      x--;
      if(y) tru[i].push_back(x);
      else fal[i].push_back(x);
    }
  }
  int ans = 0;
  for(int i = 1; i < (1 << n); i++){
    bool ok = true;
    int cnt = 0;
    rep(j, n){
      ok = true;
      if((i >> j) & 1){
        cnt++;
        for(int a : tru[j]){
          if(!((i >> a) & 1)){
            ok = false;
            break;
          }
        }
        for(int a : fal[j]){
          if((i >> a) & 1){
            ok = false;
            break;
          }
        }
      }
      if(!ok) break;
    }
    if(ok){
      ans = ans < cnt ? cnt : ans;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<cstring>
using namespace std;
int main(void)
{
	int a,b,n,s,f,i,j,flg;
	cin>>a>>b>>n;
	flg=0;
	for(i=0;i<n;i++){
		cin>>s>>f;
		if(b>s && a<f){
			flg=1;
		}
	}
	cout<<flg<<endl;
	return 0;
}



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

using namespace std;

#define int long long
#define double long double
#define pb push_back
#define sz(el) (int)el.size()

int max(int &a, int b) {
    if (b > a) {
        a = b;
        return 1;
    }
    return 0;
}

const int inf = 1e18;
const int maxN = 3100;

double dp[maxN][maxN];
double a[maxN];

signed main() {
    
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    
    int n;
    cin >> n;
    for (int i = 1; i <= n; i++) {
        cin >> a[i];
    }
    dp[0][0] = 1;
    for (int i = 1; i <= n; i++) {
        dp[i][0] = dp[i - 1][0] * a[i];
        for (int j = 1; j <= n / 2; j++) {
            dp[i][j] += dp[i - 1][j] * a[i];
            dp[i][j] += dp[i - 1][j - 1] * (1 - a[i]);
        }
    }
    
    double ans = 0;
    for (int i = 0; i <= n / 2; i++) {
        ans += dp[n][i];
    }
    cout << fixed << setprecision(20) << ans;
    return 0;
    
}


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

int main() {
    int n, k;
    while (cin >> n >> k) {
        int min = 0;
        int max = (n - 1) * (n - 2) / 2;
        if (k < min || k > max) {
            printf("-1\n");
            continue;
        }
        int m = n * (n - 1) / 2 - k;
        int current = k;
        int last = 1;
        int size = 1;
        for (int i = n - 2; i > 0; --i) {
            if (current <= i) {
                last = current;
                break;
            }
            ++size;
            current -= i;
        }
        printf("%d\n", m);
        for (int i = 1; i < n; ++i) {
            if (i > size) {
                for (int j = n; j > i; --j) {
                    printf("%d %d\n", i, j);
                }
            }
            else if (i < size){
                printf("%d %d\n", i, n);
            }
            else {
                for (int j = n, end_j = i + current; j > end_j; --j) {
                    printf("%d %d\n", i, j);
                }
            }
        }
    }
}


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

using namespace std;

#define ok1 printf("ok1\n");
#define ok2 printf("ok2\n");
#define M 1000000000000000000LL
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define pb push_back
#define pf push_front
#define MIN(a,b) a=min((a),(b))
#define MAX(a,b) a=max((a),(b))
#define SIZE(v) (int)v.size()
#define Eunique(v) v.erace(unique(all(v)),v.end())
#define pvec(v)　rep(i,v.size()){cout << v[i] << " ";}
#define INF 0x3f3f3f3f
#define mset(m,v) memset(m,v,sezeof(m))
#define mod (ll)(1e9 +7);

const double pi = acos(-1.0);

typedef vector<int> vi;
typedef string ss;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef deque<ll> dll;
typedef pair<ll, ll> P;
ll dx[4] = {1,0,-1,0},dy[4] = {0,1,0,-1};

ll gcd(ll x,ll y)
{
    ll r;
    while((r = x % y) != 0)
    {
        x = y;
        y = r;
    }
    return y;
}

ll lcm(ll a,ll b){
    ll g = gcd(a,b);
    return a / g * b; // Be careful not to overflow
}

ll digsum(ll n){
    ll sum = 0;
    while(n > 0){
        sum += n % 10;
        n /= 10;
    }

    return sum;
}

string to_binString(int val)
{
    if( !val )
        return std::string("0");
    string str;
    while( val != 0 ) {
        if( (val & 1) == 0 )  // val は偶数か？
            str.insert(str.begin(), '0');  //  偶数の場合
        else
            str.insert(str.begin(), '1');  //  奇数の場合
        val >>= 1;
    }
    return str;
}

int main()
{
    ll a,b;
    cin >> a >> b;
    if(0 <= a && a <= 9 && 0 <= b && b <= 9)cout << a * b << endl;
    else cout << -1 << endl;
    return 0;
}

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

int main()
{
    long double A,B,C;
    cin >> A >> B >> C;
    long double eps=1.0E-14;
    if(sqrt(A)+sqrt(B)+eps<sqrt(C)){
        cout<<"Yes"<<endl;
    }else {
        cout<<"No"<<endl;
    }
    return 0;
}

Measured memory_bytes: 3668
a,b,c,d=input().split()
a=int(a)
b=int(b)
c=int(c)
d=int(d)
if a==b and c==d:
    print("yes")
elif a==c and b==d:
    print("yes")
elif a==d and b==c:
    print("yes")
else:
    print("no")


Measured memory_bytes: 5596
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>

using namespace std;

#define fori(x) for(int i=0;i<x;++i)
#define forj(x) for(int j=0;j<x;++j)

constexpr int maximum = 100100;


int main() {
	string s, t,u;
	int a, b;
	cin >> s >> t >> a >> b >> u;
	if (u == s) {
		cout << a - 1 <<" "<< b;
	}
	else {
		cout << a <<" "<< b - 1;
	}
	return 0;
}

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

#define FASTIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define MOD 1000000007

int main()
{
    FASTIO
    int n, w;
    cin >> n >> w;
    int weight[n], value[n];
    for(int i=0; i<n; i++)
    {
        cin >> weight[i] >> value[i];
    }
    long long dp[n+1][w+1];
    memset(dp, 0, sizeof(dp));
    for(int i = 1; i<n+1; i++)
    {
        for(int j=1; j<w+1; j++)
        {
            if(weight[i-1] > j)
                dp[i][j] = dp[i-1][j];
            else
            {
                dp[i][j] = max(dp[i-1][j], value[i-1] + dp[i-1][j-weight[i-1]]);
            }
        }
    }
    cout << dp[n][w] << "\n";

    return 0;
}

Measured memory_bytes: 79232
n=int(input())
s=[input()for i in range(n)]
count_m=count_a=count_r=count_c=count_h=0
for i in s:
    if i[0]=="M":
        count_m+=1
    if i[0]=="A":
        count_a+=1
    if i[0]=="R":
        count_r+=1
    if i[0]=="C":
        count_c+=1
    if i[0]=="H":
        count_h+=1
ans_1=count_m*count_a*count_r
ans_2=count_m*count_a*count_c
ans_3=count_m*count_a*count_h
ans_4=count_m*count_r*count_c
ans_5=count_m*count_r*count_h
ans_6=count_m*count_c*count_h
ans_7=count_a*count_r*count_c
ans_8=count_a*count_r*count_h
ans_9=count_a*count_c*count_h
ans_10=count_r*count_c*count_h
print(ans_1+ans_2+ans_3+ans_4+ans_5+ans_6+ans_7+ans_8+ans_9+ans_10)

Measured memory_bytes: 9772
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        while(true) {
            int n = s.nextInt();
            if (n==0) break;
            int[] a=new int[n];
            for (int i=0;i<a.length;i++) {
                a[i]=s.nextInt();
            }
            Arrays.sort(a);
            int sum=0;
            for (int i=1;i<a.length-1;i++) {
                sum+=a[i];
            }
            System.out.println(sum/(a.length-2));
        }
    }
}

Measured memory_bytes: 29584
#include <bits/stdc++.h>
using namespace std;;
#define ll long long
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define INF 1<<30
#define LINF 1LL<<62
#define all(x) (x).begin(), (x).end()
#define mp make_pair
#define pb push_back
const int MOD = 1000000007;
 
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;
ll pa[55], br[55], lg[55];
ll dfs(ll x, ll level){
    if(x==1){
        return 0;
    }else if(x>1 && x< lg[level-1]+1){
        return dfs(x-1, level-1);
    }else if(x==lg[level-1]+1){
        return pa[level-1];
    }else if(x==lg[level-1]+2){
        return (pa[level-1]+1);
    }else if(x<lg[level-1]*2+2){
        return (dfs(x-2-lg[level-1], level-1) + pa[level-1] + 1);
    }else if(x==lg[level-1] * 2 + 2){
        return pa[level] ;
    }else {
        return pa[level];;
    }
}
int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n,x; cin >> n >> x;
  pa[0] =1;
  br[0] = 0;
  lg[0] = 1;
  FOR(i,1,51){
      pa[i] = pa[i-1] * 2 +1;
      br[i] = pa[i]-1;
      lg[i] = pa[i] + br[i] ;
  }
  ll ans = dfs(x, n);
  cout << ans << endl;

}

Measured memory_bytes: 256
h,w=map(int,input().split())
M=[]


M=[input() for _ in range(h)]

def bfs(x,y):
    dist=[[-1]*w  for _ in range(h)]
    seen=[[False]*w for _ in range(h)]
    stk=[(x,y,0)]
    while stk:
        px,py,dst=stk.pop()
        if seen[px][py]:
            continue
        seen[px][py]=True
        
        if M[px][py]=='#':
            dist[px][py]=0
            continue
        
        for x,y in [(-1,0),(1,0),(0,-1),(0,1)]:
            if px+x<0 or px+x>=h or py+y<0 or py+y>=w:
                continue
            else:
                stk.insert(0,(px+x,py+y,dst+1))
        dist[px][py]=dst
    ans=0

    for i in range(h):
        ans=max(max(dist[i]),ans)
    return ans

ans=0
for i in range(h):
    for j in range(w):
        if M[i][j]=='#':
            continue
        ans=max(bfs(i,j),ans)

print(ans)
        

Measured memory_bytes: 3188
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<vector>
#include<string.h>
#include<math.h>
#include<map>
#include<iomanip>

#define MOD 1e9+7;
#define INF 1e17+9;
#define PI acos(-1);

using namespace std;

int main(){
	long long n;
	cin >> n;
	vector<long long> a(n);
	long long sum=0;
	for(long long i=0;i<n;i++){
		cin >> a[i];
		sum+=a[i];
	}
	long long cent=sum/2;
	long long left,right;
	left=right=0;
	long long cost=INF;
	for(long long i=0;i<n;i++){
		left+=a[i];
		right=sum-left;
		cost=min(cost,abs(right-left));
	}
	cout << cost << endl;
	return 0;
}


Measured memory_bytes: 1792
N = int(input())
D = [list(map(int,input().split())) for i in range(N)]  

ans = "No"

for i in range(N-2):
    if D[i][0] == D[i][1]:
        if D[i+1][0] == D[i+1][1]:
            if D[i+2][0] == D[i+2][1]:
                ans = "Yes"
                break
print(ans)

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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef vector<ld> vd;
typedef vector<ll> vll;
typedef vector<string> vstr;
typedef vector<vector<ll>> vvll;
typedef vector<pair<ll, ll>> vpll;
typedef priority_queue<ll, vector<ll>, greater<ll>> spqll;  // 小さい順に取り出し
typedef priority_queue<ll, vector<ll>, less<ll>> bpqll;     // 大きい順に取り出し

#define REP(i, n) for (ll i = 0; i < (ll)(n); i++)
#define FOR(i, a, b) for (ll i = (ll)a; i < (ll)b; i++)
#define IREP(i, v) for (auto i = (v).begin(); i != (v).end(); i++)
#define FI first
#define SE second
#define MP make_pair
#define MT make_tuple
#define PB push_back
#define TS to_string
#define NP next_permutation
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) (ll) x.size()
#define SP(x) setprecision((ll)x)


ll INF = 1e9;
ll NIL = -1;
ll MOD = 1000000007;
ll LINF = 1e18;
ld EPS = 1e-9;
ld PI = M_PI;
vll dx = {1, 0, -1, 0, 1, -1, -1, 1};
vll dy = {0, 1, 0, -1, 1, 1, -1, -1};
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a;} //最大公約数
ll lcm(ll a, ll b) { return a / gcd(a, b) * b;}     //最小公倍数

void yes(){ cout << "Yes" << endl;}
void no(){ cout << "No" << endl;}

//-----------------------------------------
template<class T>
class List{
  private:
    struct Node{
      T key;
      Node *prev, *next;
    };
    Node *nil;
    int size;
  public:
    List(){
      nil = (Node *)malloc(sizeof(Node));
      nil->next = nil;
      nil->prev = nil;
      size = 0;
    }
    void insert(T key){
      Node *x = (Node *)malloc(sizeof(Node));
      x->key = key;
      x->next = nil->next;
      x->prev = nil;
      nil->next->prev = x;
      nil->next = x;
      size++;
    }
    void deleteNode(Node *t){
      if(t == nil) return;
      t->prev->next = t->next;
      t->next->prev = t->prev;
      free(t);
      size--;
    }
    void deleteFirst(){
      deleteNode(nil->next);
    }
    void deleteLast(){
      deleteNode(nil->prev);
    }
    Node* listSearch(T key){
      Node *tmp = nil->next;
      while(tmp != nil && tmp->key != key){
        tmp = tmp->next;
      }
      return tmp;
    }
    void deleteKey(T key){
      deleteNode(listSearch(key));
    }
    void printList(){
      Node *tmp = nil->next;
      if(tmp != nil){
        cout << tmp->key;
        tmp = tmp->next;
      }
      while(tmp != nil){
        cout << " " << tmp->key;
        tmp = tmp->next;
      }
      cout << endl;
    }
};
//-----------------------------------------
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);

  int n;
  cin >> n;
  List<int> lis;
  for(int i=0;i<n;i++){
    string s;
    int a;
    cin >> s;
    if(s=="insert"){
      cin >> a;
      lis.insert(a);
    }
    else if(s=="delete"){
      cin >> a;
      lis.deleteKey(a);
    }
    else if(s=="deleteFirst"){
      lis.deleteFirst();
    }
    else{
      lis.deleteLast();
    }
  }
  lis.printList();
    
  return 0;
}




Measured memory_bytes: 34484
#include"bits/stdc++.h"
using namespace std;

int main() {
    int A, B, C, D;
    cin >> A >> B >> C >> D;
    if (A + B > C + D) {
        cout << "Left" << endl;
    } else if (A + B < C + D) {
        cout << "Right" << endl;
    } else {
        cout << "Balanced" << endl;
    }
}

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

int main() {
  int N;
  int A;
  string answer;
  
  cin >> N >> A;
  
  if (N % 500 <= A)
    answer = "Yes";
  
  else answer = "No";
  
  cout << answer << endl;
  
}
  
  
  

Measured memory_bytes: 256