akhauriyash/Code-Regression huggingface dataset:
import java.util.*;
import static java.lang.System.*;
public class Main {
public static void main(String[] args){
Scanner sc = new Scanner(in);
int H = Integer.parseInt(sc.next());
int W = Integer.parseInt(sc.next());
char[][] a=new char[H][W];
    for (int i = 0; i < H; i++) {
        String p=sc.next();
        for (int j = 0; j < W; j++) {
            a[i][j]=p.charAt(j);
        }
    }
    for (int i = 0; i < H; i++) {
        int c=0;
        for (int j = 0; j <W ; j++) {
            if(a[i][j]=='.')c++;
        }
        if(c==W){
            for (int j = 0; j < W; j++) {
                a[i][j]='-';
            }
        }
    }
    for (int i = 0; i < W; i++) {
        int c=0;
        for (int j = 0; j < H; j++) {
            if(a[j][i]=='.'||a[j][i]=='-')c++;
        }
        if(c==H){
            for (int j = 0; j < H; j++) {
                a[j][i]='-';
            }
        }
    }
    String[] s=new String[H];
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            s[i]+=Character.toString(a[i][j]);
        }
    }
    for (int i = 0; i <H; i++) {
        s[i]=s[i].replaceAll("-","");
    s[i]=s[i].replaceAll("null","");
    }
    for (int i = 0; i < H; i++) {
        if(s[i].contains(".")||s[i].contains("#"))out.println(s[i]);
    }
    
}}

Measured memory_bytes: 30736
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define sz(x) (int)(x).size()
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define EPS (1e-10)
#define equals(a, b) (fabs((a)-(b)) < EPS)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;
  
int main() {
  int N;
  cin >> N;
  string s,t;
  cin >> s >> t;
  rep(i,N) {
    if(s[i]!=t[0]) continue;
    bool ok=true;
    srep(j,i,N) {
      ok &= s[j]==t[j-i];
    }
    if(!ok) continue;
    cout << N+i << endl;
    return 0;
  }
  cout << 2*N << endl;
  return 0;
}

Measured memory_bytes: 256
import java.io.*;
import java.util.*;
public class Main{
    public static void main(String[] args) throws IOException{
        MyReader r = new MyReader();  
        int N= r.i();
        int[] C = new int[N-1];
        int[] S = new int[N-1];
        int[] F = new int[N-1];
        for(int i = 0; i < N-1; i++){
            int[] a = r.ii();
            C[i] = a[0];
            S[i] = a[1];
            F[i] = a[2];
        }
        StringBuilder sb = new StringBuilder();
        for(int i = 0; i < N; i++){
            int t = 0;
            for(int j = i; j < N-1; j++){
                if(t < S[j])
                    t = S[j];
                else if(t%F[j] > 0)
                    t = t+F[j]-t%F[j];
                t += C[j];
            }
            sb.append(t);
            sb.append("\n");
        }              
        print(sb);
    }
    static void print(Object o){
        System.out.print(o.toString());
    }
    static void println(Object o){
        System.out.println(o.toString());
    }
    static int Int(String s){
        return Integer.parseInt(s);
    }
    static long Long(String s){
        return Long.parseLong(s);
    }
    static class MyReader extends BufferedReader{
        MyReader(){
            super(new InputStreamReader(System.in));
        }
        String s() throws IOException{
            return readLine();
        }
        String[] ss() throws IOException{
            return s().split(" ");
        }
        int i() throws IOException{
            return Int(s());
        }
        int[] ii() throws IOException{
            String[] ss = ss();
            int size = ss.length;
            int[] ii = new int[size];
            for(int j = 0; j < size; j++) ii[j] = Integer.parseInt(ss[j]);
            return ii;
        }
        long l() throws IOException{
            return Long(s());
        }
        long[] ll() throws IOException{
            String[] ss = ss();
            int size = ss.length;
            long[] ll = new long[size];
            for(int j = 0; j < size; j++) ll[j] = Long.parseLong(ss[j]);            
            return ll;
        }
    }
}

Measured memory_bytes: 22100
import heapq

S = input()
K = int(input())

q = []

for i in range(len(S)):
    for j in range(i, min(len(S), i + K) + 1):
        heapq.heappush(q, S[i:j])

last = ''
while K > 0:
    s = heapq.heappop(q)
    if s != last:
        K -= 1
        last = s

print(last)


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

int main(){
  int N,M;
  cin >> N >> M;
  int B[M];
  long long int C[M];
  vector<pair<long long int,int> > CB;
  vector<long long int> A;
  for(int i=0;i<N;i++){
    int a;
    cin >> a;
    A.push_back(a);
  }
  for (int i=0;i<M;i++){
    cin >> B[i] >> C[i];
    pair<long long int,int> cb;
    cb.first = C[i];
    cb.second = B[i];
    CB.push_back(cb);
  }
  sort(CB.begin(),CB.end(),greater<pair<long long int,int> >());
  int count=0;
  for(vector<pair<long long int,int> >::iterator e=CB.begin();e!=CB.end();e++){
    for(int i=0;i<e->second;i++){
      A.push_back(e->first);
      count++;
      if (count>N)break;
    }
    if (count>N)break;
  }
  sort(A.begin(),A.end(),greater<long long int>());
  long long int ans=0;
  int i=0;
  for(vector<long long int>::iterator e=A.begin();e!=A.end();e++){
    if (i>=N) break;
    ans+=*e;
//    cout << *e << " ";
    i++;
  }
//  cout << endl;
  cout << ans << endl;
}


Measured memory_bytes: 5104
#include <iostream>
using namespace std;
int main(void){
    long long N,L,ans;
    cin>>N>>L;
    if(L>0){
        ans=(N-1)*(L+1+L+N-1);
    }else if(L+N-1<0){
        ans=(N-1)*(L+L+N-2);
    }else{
        ans=N*(L+L+N-1);
    }
    ans/=2;
    cout<<ans<<endl;
}


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

typedef long long ll;
typedef long double ld;
#define L(ID) ((ID*2)+1)
#define R(ID) ((ID*2)+2)
#define M(L,R) ((L+R)/2)
#define forr(start,end) for(int i = start; i < end; i++)
#define gap ' '
 
const int MAXN = 1e6 + 5;
int n = 0, m = 0;
int a[MAXN];
int b[MAXN];


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

Measured memory_bytes: 640
using System;
using System.Collections.Generic;
using System.Text;

namespace codeTester.contest190804
{
    class ProblemA
    {
        static List<long> abc = new List<long>();
        static string answer = "";

        public static void Main(string[] args)
        {
            Input();
            Logic();
            Output();
        }

        static void Input()
        {
            abc = ReadSpaceSeparatedValues();
        }

        public static List<long> ReadSpaceSeparatedValues()
        {
            List<long> values = new List<long>();
            string[] inputs = Console.ReadLine().Split(' ');
            foreach (string input in inputs)
            {
                values.Add(long.Parse(input));
            }

            return values;
        }

        static void Logic()
        {
            long vessel1Size = abc[0];
            long vessel1Water = abc[1];
            long vessel2Water = abc[2];
            long vessel1RemainingCapacity = vessel1Size - vessel1Water;
            answer = Math.Max(vessel2Water - vessel1RemainingCapacity, 0).ToString();
        }

        static void Output()
        {
            Console.WriteLine(answer);
        }
    }
}


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

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

string s;
void input(){
    cin >> s;
}


void solve(){
    input();
    int ans = 0;
    int j = s.size() / 2;
    for(int i=0;i<j;i++){
        int k = s.size() - 1 - i;
        if(s[i] != s[k])
        {
            ans += 1;
        }
    }
    cout << ans << endl;
    return;
}
int main () {
    solve();
    return 0;
}





Measured memory_bytes: 256
n, k = map(int, input().split())

mod = 10**9+7
def _ans(_a):
    ret = _a[0]
    for _aa in _a[1:]:
        ret = (ret*_aa)%mod
    return ret


a = list(map(int, input().split()))
# マイナスでも全部かけるしかない
if len(a) == k:
    print(_ans(a))
    exit(0)

ap = [aa for aa in a if aa > 0]
an = [aa for aa in a if aa < 0]
apl, anl = len(ap), len(an)

# 0が入る
if apl + anl < k:
    print(0)
    exit(0)

ap.sort(reverse=True)
an.sort()

# プラスがない
if apl == 0:
    if k % 2 == 1:
        if apl + anl < n:
            print(0)
            exit(0)
        an = an[::-1]
    print(_ans(an[:k]))
    exit(0)

# マイナスは2の倍数個のみいれる
ans = 1
api, ani = 0, 0
if k % 2 == 1:
    ans = ap[0]
    api += 1
    k -= 1

while k > 0:
    if apl - api < 2:
        while k > 0:
            ans = (ans * an[ani] * an[ani+1]) % mod
            ani += 2
            k -= 2
        break
    if anl - ani < 2:
        while k > 0:
            ans = (ans * ap[api] * ap[api+1]) % mod
            api += 2
            k -= 2
        break

    app = ap[api] * ap[api+1]
    ann = an[ani] * an[ani+1]
    if app > ann:
        ans = (ans * app) % mod
        api += 2
    else:
        ans = (ans * ann) % mod
        ani += 2
    k -= 2

print(ans)


Measured memory_bytes: 31788
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
	"strings"
)

func main() {
	io, flush := NewIO()
	defer flush()
	n, m, x := io.ScanInt(), io.ScanInt(), io.ScanInt()

	var possibleCombinations [][]int
	for bit := 0; bit < (1 << uint(n)); bit++ {
		var comb []int
		for j := 0; j < n; j++ {
			if (bit>>uint(j))&1 == 1 {
				comb = append(comb, j+1)
			}
		}
		possibleCombinations = append(possibleCombinations, comb)
	}
	prices := []int{}
	bookScoreupMap := map[int][]int{}
	for i := 0; i < n; i++ {
		prices = append(prices, io.ScanInt())
		bookScoreupMap[i] = io.ScanInts(m)
	}
	minPrice := int(math.Pow10(7))
	for _, comb := range possibleCombinations {
		scores := make([]int, m)
		var price int
		for _, book := range comb {
			bookIndex := book - 1
			price += prices[bookIndex]
			for i, scoreup := range bookScoreupMap[bookIndex] {
				scores[i] += scoreup
			}
		}

		ok := true
		for _, score := range scores {
			if score < x {
				ok = false
			}
		}
		if ok && price < minPrice {
			minPrice = price
		}
	}
	if minPrice == int(math.Pow10(7)) {
		fmt.Println(-1)
	} else {
		fmt.Println(minPrice)
	}
}

type IO struct {
	scanner *bufio.Scanner
	writer  *bufio.Writer
}

func NewIO() (*IO, func()) {
	io := &IO{
		scanner: newScanner(),
		writer:  newWriter(),
	}
	return io, func() { io.writer.Flush() }
}

func newScanner() *bufio.Scanner {
	s := bufio.NewScanner(os.Stdin)
	s.Buffer(make([]byte, 10000000), 10000000)
	s.Split(bufio.ScanWords)
	return s
}

func newWriter() *bufio.Writer {
	return bufio.NewWriter(os.Stdout)
}

func (io *IO) ScanBytes() []byte {
	if !io.scanner.Scan() {
		panic("scan string failed")
	}
	return io.scanner.Bytes()
}

func (io *IO) ScanString() string {
	if !io.scanner.Scan() {
		panic("scan string failed")
	}
	return io.scanner.Text()
}

func (io *IO) ScanStrings(n int) []string {
	strs := make([]string, n)
	for i := 0; i < n; i++ {
		strs[i] = io.ScanString()
	}
	return strs
}

func (io *IO) Scan2DStrings(y, x int) [][]string {
	strings := make([][]string, y)
	for i := 0; i < y; i++ {
		strings[i] = io.ScanStrings(x)
	}
	return strings
}

func (io *IO) Scan2DGraph(y int) [][]string {
	strs := make([][]string, y)
	for i := 0; i < y; i++ {
		strs[i] = strings.Split(io.ScanString(), "")
	}
	return strs
}

func (io *IO) ScanInt() int {
	return int(io.ScanInt64())
}

func (io *IO) ScanInts(n int) []int {
	ints := make([]int, n)
	for i := 0; i < n; i++ {
		ints[i] = io.ScanInt()
	}
	return ints
}

func (io *IO) Scan2DInts(y, x int) [][]int {
	ints := make([][]int, y)
	for i := 0; i < y; i++ {
		ints[i] = io.ScanInts(x)
	}
	return ints
}

func (io *IO) ScanInt64() int64 {
	i, err := strconv.ParseInt(io.ScanString(), 10, 64)
	if err != nil {
		panic(err)
	}
	return i
}

func (io *IO) ScanFloat64() float64 {
	i, _ := strconv.ParseFloat(io.ScanString(), 64)
	return i
}

func (io *IO) ScanFloat64s(n int) []float64 {
	floats := make([]float64, n)
	for i := 0; i < n; i++ {
		floats[i] = io.ScanFloat64()
	}
	return floats
}

func (io *IO) Println(a ...interface{}) {
	fmt.Fprintln(io.writer, a...)
}


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

using namespace std;

#define fore(i, s, e) for(int i = s; i < e; i++)

const int N = 1e5;

int n, k;
int a[N];
int dp[N];

int calc(int i) {
    if(i == n - 1) return dp[i] = 0;
    int r = 0;
    if(dp[i] != - 1) return dp[i];
    r = abs(a[i] - a[i+1]) + calc(i + 1);    
    fore(j, 2, k + 1) {
        if(i + j == n) break;
        r = min(r, abs(a[i] - a[i + j]) + calc(i + j));
    }
    return dp[i] = r;
}


int main() {
    cin >> n; cin >> k;
    fore(i, 0, n) cin >> a[i];
    memset(dp, -1, sizeof dp);
    cout << calc(0) << endl;
}

Measured memory_bytes: 5760
#include <iostream>
#include <math.h>
#define REP(i,n) for(int i=0;i<n;i++)
using namespace std;

int main() {
	int N;
	cin >> N;
	int ans[N];
	ans[0]=2;

	int now=1;
	for (int i=11; i<55555; i+=10) {
		bool prime=true;
		for (int j=2; j<=sqrt(i); j++) {
			if(i%j == 0){
				prime=false;
				break;
			}
		}
		if(prime) {
			ans[now]=i;
			now++;
		}
		if (now == N) {
      REP(i,N)
				cout << ans[i] << " ";
      cout << endl;
			return 0;
		}
	}
	return 0;
}

Measured memory_bytes: 256
use input::*;
use std::cmp::*;
use std::io::*;
use std::num::*;
use std::str::*;

mod input {
    use super::*;
    pub fn read<T: FromStr>() -> T {
        stdin()
            .bytes()
            .map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>()
            .parse::<T>()
            .ok()
            .unwrap()
    }
    pub fn string() -> String {
        read()
    }
    pub fn int() -> i64 {
        read()
    }
    pub fn char() -> char {
        read::<String>().pop().unwrap()
    }
    pub fn vecchar() -> Vec<char> {
        string().chars().collect()
    }
    pub fn vecint(n: i64) -> Vec<i64> {
        let mut vec = Vec::new();
        for i in 0..n {
            vec.push(int())
        }
        vec
    }
}
fn main() {
    let n = int();
    let a = vecint(n);
    let mut cur = vec![0i64, 0, 0];

    let MOD = 1_000_000_007;
    let mut ans = 1;
    for v in a {
        let count = cur.iter().filter(|x| **x == v).count();
        ans = ans * count % MOD;
        //dbg!(count, v, ans, &cur);
        for i in 0..3 {
            if cur[i] == v {
                cur[i] = v + 1;
                break;
            }
        }
    }
    println!("{}", ans)
}


Measured memory_bytes: 4352
s = input()
t = input()

dic_s = {}
for i in range(len(s)):
    if s[i] not in dic_s.keys():
        dic_s[s[i]] = [i]
    else:
        dic_s[s[i]].append(i)

dic_t = {}
for i in range(len(t)):
    if t[i] not in dic_t.keys():
        dic_t[t[i]] = [i]
    else:
        dic_t[t[i]].append(i)

if sorted(list(dic_s.values())) == sorted(list(dic_t.values())):
    print("Yes")
else:
    print("No")

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

#define ll long long
#define fw(p) for(int w=0;w<(p);w++)
#define fx(p) for(int x=0;x<(p);x++)
#define fy(p) for(int y=0;y<(p);y++)
#define fz(p) for(int z=0;z<(p);z++)
#define fyg(p,g) for(int y=(g);y<(p);y++)
#define fzg(p,g) for(int z=(g);z<(p);z++)
#define ce(d) cout<<d<<endl;
#define vecp(p) int aa;cin>>aa;(p).push_back(aa);
#define vecpl(p) long long aa;cin>>aa;(p).push_back(aa);
#define vecps(p) string aa;cin>>aa;(p).push_back(aa);
#define vecp2(p) cin>>aa;(p).push_back(aa);
#define vecpl2(p) long long a	b;cin>>ab;(p).push_back(ab);
#define vecps2(p) string ab;cin>>ab;(p).push_back(ab);
#define sorts(c) sort((c).begin(),(c).end());
#define reverses(c) reverse((c).begin(),(c).end());
#define vec(b) vector<int> (b);
#define vecl(b) vector<long long> (b);
#define vecs(b) vector<string> (b);
#define pb(b,a) (b).push_back((a));
#define doublece(a,b) cout<<(a)<<' '<<(b)<<endl;
#define pairs(s) vector<pair<int,int>> (s);
#define pairsp(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define MOD 1000000007
#define cey ce("Yes")
#define cen ce("No")
#define ceY ce("YES")
#define ceN ce("NO")

int main()
{
int N;
	cin >> N;
	vecs(S);
	int a = 0, b = 0,ab=0;
	int ans = 0;
	fx(N) {
		vecps(S);
		fy(S[x].size()-1) {
			if (S[x][y]=='A'&&S[x][y+1]=='B') {
				ans++;
			}
		}
		
		
		if (S[x][S[x].size() - 1] == 'A'&& S[x][0] == 'B') {
			ab++;
		}
		else if (S[x][S[x].size() - 1] == 'A') {
			a++;
		}else if (S[x][0] == 'B') {
			b++;
		}
	}
	if (ab>0) {
		if (a > 0) {
			a--;
			ans++;
		}
		if (b > 0) {
			b--;
			ans++;
		}
	}
	ce(ans+max(0,ab-1)+min(a,b))

    return 0;
}



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

#define rep(i,n) for(long long i=0; i<(long long)(n);i++)
#define rep2(i,s,n) for(long long i=(s); i<(long long)(n);i++)

#define mod 1e9+7;
#define inf 1e18+7;

typedef long long ll;

int main() {
    ll d,n;cin>>d>>n;

    if(n==100)n++;

    ll ans=pow(100,d)*n;

    cout<<ans<<endl;
}



Measured memory_bytes: 256
n, k = map(int, input().split())
a = list(map(int, input().split()))

s = a[:k]

for i in range(n-k):
  b = s[0]
  if a[k+i] > b:
    print ('Yes')
  else:
    print ('No')
  s.append(a[k+i])
  s.pop(0)

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

int main() {
  int n;
  cin>>n;
  vector<int> vec(n);
  for(int i=0;i<n;i++){
    cin>>vec[i];
  }
  int ans=1e9;
  for(int i=1;i<n;i++){
    int l=0,r=0;
    for(int j=0;j<i;j++)l+=vec[j];
    for(int j=i;j<n;j++)r+=vec[j];
    ans=min(ans,abs(l-r));
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
class UF:
  def __init__(self,n):
    self.n = n
    self.p = [i for i in range(n)]
    self.r = [1]*n
    self.num = n
  
  def find(self,x):
    if x == self.p[x]:
      return x
    self.p[x] = UF.find(self,self.p[x])
    return self.p[x]
  
  def same(self,x,y):
    return UF.find(self,x) == UF.find(self,y)
  
  def unite(self,x,y):
    x = UF.find(self,x)
    y = UF.find(self,y)
    if x == y:
      return
    if self.r[x] < self.r[y]:
      x,y = y,x
    self.r[x] += self.r[y]
    self.p[y] = x
    self.num -= 1

  def size(self,x):
    return self.r[x]
  
  def count(self):
    return self.num

[n,q] = list(map(int,input().split()))
uf = UF(n)
for i in range(q):
  [com,x,y] = list(map(int,input().split()))
  x -= 1
  y -= 1
  if com == 0:
    uf.unite(x,y)
  else:
    if uf.same(x,y):
      print(1)
    else:
      print(0)



Measured memory_bytes: 6048
#include<bits/stdc++.h>
#define inf 0x3f3f3f3f
using namespace std;
const int N=55;
int n,x,d,v[N],w[N],m[N],fa[N],dp[N*N*N];
struct node
{
    int v,w,id;
    double k;
    node(int v=0,int w=0):v(v),w(w){k=1.0*v/w;}
    bool operator<(const node&o)const
    {
        return k>o.k;
    }
}a[N];
int main()
{
    scanf("%d%d%d",&n,&x,&d);
    scanf("%d",&m[1]);
    for(int i=2;i<=n;i++)
        scanf("%d%d",&m[i],&fa[i]);
    for(int i=n;i>=1;i--)
    {
        v[i]++;
        w[i]=min(w[i]+m[i],x+1);
        v[fa[i]]+=v[i];
        w[fa[i]]=min(w[fa[i]]+w[i],x+1);
    }
    for(int i=1;i<=n;i++)
        a[i]=node(v[i],w[i]),a[i].id=i;
    sort(a+1,a+1+n);
    int k=min(n,d);
    memset(dp,inf,sizeof(dp));
    dp[0]=0;
    for(int i=1;i<=n;i++)
        for(int j=1;j<=k;j++)
            for(int k=n*n*n;k>=v[i];k--)
            dp[k]=min(dp[k],dp[k-v[i]]+w[i]);
    int ans=0;
    for(int i=0;i<=n*n*n;i++)
    {
        if(dp[i]>x) break;
        int y=x-dp[i],res=i;
        for(int j=1;j<=n;j++)
        {
            int tot=min(a[j].id==1?y/a[j].w:d-k,y/a[j].w);
            res+=tot*a[j].v;
            y-=tot*a[j].w;
        }
        ans=max(ans,res);
    }
    printf("%d\n",ans);
}


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

using namespace std;

int main()
{
    char S[15], T[15];

    cin >> S >> T;

    T[strlen(T)-1]='\0';

    if(!strcmp(S, T))
    {
        cout << "Yes";
    }

    else
    {
        cout << "No";
    }
}


Measured memory_bytes: 3636
if __name__ == "__main__":
  str_N_K = input()
  
  list_N_K = str_N_K.split(' ')
  N = int(list_N_K[0])
  K = int(list_N_K[1])
  
  list_person = [0] * N
  
  for _ in range(K):
    d = int(input())
    str_persons = input()
    if (" " in str_persons):
      list_str_persons = str_persons.split(" ")
    else:
      list_str_persons = [str_persons]
      
    for str_person in list_str_persons:
      int_person = int(str_person)
      list_person[int_person-1] += 1
  
  output = 0
  for person in list_person:
    if person == 0:
      output += 1
      
  print(output)
    
  
  


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

int main() {
  ll N;
  cin >> N;
  ll mind = -1;
  for (ll i=1; i*i <= N; i++)
    if (N % i == 0)
      if (mind==-1||mind>max(to_string(i).size(), to_string(N/i).size()))
        mind = max(to_string(i).size(), to_string(N/i).size());
  cout << mind << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#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 pb(a) push_back(a)
#define mk(a,b) make_pair(a,b)
#define ll long long
#define INF 999999999
#define IOS cin.tie(0); ios::sync_with_stdio(false)
using namespace std;
typedef pair<int, int> P;
typedef pair<int, P> PP;
typedef pair<ll,ll> LP;
typedef pair<ll,LP> LPP;

int dy[] = {0, 0, 1, -1};
int dx[] = {1, -1, 0, 0};
int gcd(int a,int b){return b ? gcd(b,a%b) : a;}
int lcm(int a,int b){return a/gcd(a,b)*b;}

int main() {
    string S; cin >> S;
    int a=0,b=0,s,t;
    vector<int> A(S.size());
    rep(i,S.size()){
        if(S[i]=='R' && S[i+1]=='R' && i!=S.size()){
            if(i!=0 && S[i-1]=='L'){
                a=0; b=0;
            }
            if(i%2==1) a++;
            else b++;
        }
        else if(S[i]=='R' && S[i+1]=='L' && i!=S.size()){
            s=i; t=i+1;
            if(i%2==1) {A[i]+=a+1; A[i+1]+=b+1;}
            else {A[i]+=b+1; A[i+1]+=a+1;}
        }
        else if(i!=0 && S[i-1]!='R'){
            if((i-s)%2==1){
                A[t]++;
            }
            else A[s]++;
        }
        if(S[i]=='L' && S[i+1]=='R' && i!=S.size()){
            a=0; b=0;
        }
    }
    rep(i,S.size()){
        if(i!=S.size()-1)
        cout << A[i] << " " << flush;
        else cout << A[i] << endl;
    }

    return 0;
}

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

int gcd(int a, int b) {
    if (a < b) {
        int tmp = a;
        a = b;
        b = tmp;
    }
    int r = a % b;
    while (r != 0) {
        a = b;
        b = r;
        r = a % b;
    }
    return b;
}

int main() {
    int N, X; cin >> N >> X;
    vector<int> A(N);
    for (int i=0; i<N; i++) {
        int x; cin >> x;
        A[i] = abs(x - X);
    }
    int ans = A[0];
    for (int i=1; i<A.size(); i++) {
        ans = gcd(ans, A[i]);
    }
    cout << ans << endl;
}

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

int main() {

  int k,a,b,p,q,x;
	cin >> k >> a >> b;
	x=0;
	p=a/k;
	q=b/k;
	if(a%k==0){
	x=1;
	}
	if(b%k==0){
	x=1;
	}
	if(q-p>=1){
	x=1;
	}
	if(x==1){
	cout << "OK" << endl;
	}
	else{
	cout << "NG" << endl;
	}

}

Measured memory_bytes: 3632
#include <string>
#include <vector>
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<stack>
#include<queue>
#include<cmath>
#include<algorithm>
#include<functional>
#include<list>
#include<deque>
#include<bitset>
#include<set>
#include<map>
#include<unordered_map>
#include<unordered_set>
#include<cstring>
#include<sstream>
#include<complex>
#include<iomanip>
#include<numeric>
#include<cassert>
#define X first
#define Y second
#define pb push_back
#define rep(X,Y) for (int (X) = 0;(X) < (Y);++(X))
#define reps(X,S,Y) for (int (X) = S;(X) < (Y);++(X))
#define rrep(X,Y) for (int (X) = (Y)-1;(X) >=0;--(X))
#define rreps(X,S,Y) for (int (X) = (Y)-1;(X) >= (S);--(X))
#define repe(X,Y) for ((X) = 0;(X) < (Y);++(X))
#define peat(X,Y) for (;(X) < (Y);++(X))
#define all(X) (X).begin(),(X).end()
#define rall(X) (X).rbegin(),(X).rend()
#define eb emplace_back
#define UNIQUE(X) (X).erase(unique(all(X)),(X).end())
#define Endl endl

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
template<class T> using vv=vector<vector<T>>;
template<class T> ostream& operator<<(ostream &os, const vector<T> &t) {
os<<"{"; rep(i,t.size()) {os<<t[i]<<",";} os<<"}"<<endl; return os;}
template<class S, class T> ostream& operator<<(ostream &os, const pair<S,T> &t) { return os<<"("<<t.first<<","<<t.second<<")";}
template<class T> inline bool MX(T &l,const T &r){return l<r?l=r,1:0;}
template<class T> inline bool MN(T &l,const T &r){return l>r?l=r,1:0;}
#define out(args...){vector<string> a_r_g_s=s_p_l_i_t(#args, ','); e_r_r(a_r_g_s.begin(), args); }
vector<string> s_p_l_i_t(const string &s, char c){vector<string> v;int d=0,f=0;string t;for(char c:s){if(!d&&c==',')v.pb(t),t="";else t+=c;if(c=='\"'||c=='\'')f^=1;if(!f&&c=='(')++d;if(!f&&c==')')--d;}v.pb(t);return move(v);}
void e_r_r(vector<string>::iterator it) {}
template<typename T, typename... Args> void e_r_r(vector<string>::iterator it, T a, Args... args){ if(*it==" 1"||*it=="1") cerr<<endl; else cerr << it -> substr((*it)[0] == ' ', it -> length()) << " = " << a << ", "; e_r_r(++it, args...);}
const ll MOD=1e9+7;

int main(){
  ios_base::sync_with_stdio(false);
  cout<<fixed<<setprecision(0);
  int n,m;
  cin>>n>>m;
  vector<queue<int>> a(n);
  rep(i,n)rep(j,m){
    int x;
    cin>>x; --x;
    a[i].push(x);
  }
  int re=n;
  vector<int> ex(m,1);
  rep(_,m){
    vector<int> cnt(m);
    rep(i,n) ++cnt[a[i].front()];
    int mx=0,ind;
    rep(i,m)if(MX(mx,cnt[i])) ind=i;
    MN(re,mx);
    ex[ind]=0;
    rep(i,n)while(a[i].size() && ex[a[i].front()]==0) a[i].pop();
  }
  cout<<re<<endl;
  return 0;
}


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

int main(){
  int A,B,C,D;
  cin >> A>>B>>C>>D;
  int time=0;
  if(D<A||B<C){
    time=0;
  }else if(A<C){
    if(B>D){
      time=D-C;
    }else{
      time=B-C;
    }
  }else{
    if(B>D){
      time=D-A;
    }else{
      time=B-A;
    }
  }
  cout << time <<endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, l, r) for (register int i = l; i <= r; i++)
#define per(i, r, l) for (register int i = r; i >= l; i--)
#define srep(i, l, r) for (register int i = l; i < r; i++)
#define sper(i, r, l) for (register int i = r; i > l; i--)
#define erep(i, x) for (register int i = h[x]; i; i = e[i].next)
#define erep2(i, x) for (register int& i = cur[x]; i; i = e[i].next)
#define pii pair<int, int>
#define pll pair<ll, ll>
#define pdd pair<double, double>
#define fi first
#define se second
#define ui unsigned int
#define ld long double
#define ll long long int 
#define pb push_back
#define pc putchar
#define lowbit(x) (x & -x)
#define maxr 2000020
#define maxn
#define maxm
#define maxs
#define maxb
#define M 
#define gc() ((p1 == p2 && (p2 = (p1 = buffer) + fread(buffer, 1, maxr, stdin), p1 == p2)) ? EOF : *p1++)
using namespace std;

char buffer[maxr], *p1, *p2;
template <class T> void read(T& x){
	char ch = gc(); x = 0; bool f = 1;
	while (!('0' <= ch && ch <= '9') && ch != '-') ch = gc();
	if (ch == '-') f = 0, ch = gc();
	while ('0' <= ch && ch <= '9') x = (x << 1) + (x << 3) + ch - '0', ch = gc();
	x = (f) ? x : -x;
}
int _num[20];
template <class T> void write(T x){	
	if (!x) {putchar('0'), putchar('\n'); return;}
	if (x < 0) putchar('-'), x = -x;
	int c = 0;
	while (x) _num[++c] = x % 10, x /= 10;
	while (c) putchar('0' + _num[c--]); 
	putchar('\n');
}

int n;
int main(){
	int x, mx = 0, sum = 0;
	scanf("%d", &n); rep(i, 1, n) scanf("%d", &x), mx = max(mx, x), sum += x; 
	if (2 * mx >= sum) printf("No");
	else printf("Yes");
	return 0;
}


Measured memory_bytes: 3776
#include <cstdio>
#include <vector>
#include <algorithm>
#include <queue>
using namespace std;

int n,m,ru[100005],t,num[100005],f[100005],ans=0;
vector <int> dis[100005],x[100005];
queue <int> que;

int main(void){
	int t=n;
	scanf("%d %d",&n,&m);
	for(int i=1;i<=m;i++){
		int a,b;
		scanf("%d %d",&a,&b);
		ru[b]++;
		dis[a].push_back(b);
		x[b].push_back(a);
	}
	for(int i=1;i<=n;i++)
	if(ru[i]==0)que.push(i);
	while(!que.empty()){
		int u=que.front();
		num[++num[0]]=u;
		que.pop();
		int len=dis[u].size();
		for(int i=0;i<len;i++){
			ru[dis[u][i]]--;
			if(ru[dis[u][i]]==0)que.push(dis[u][i]);
		}
	}
	for(int i=1;i<=n;i++){
		int len=x[num[i]].size();
		for(int j=0;j<len;j++)
		f[num[i]]=max(f[num[i]],f[x[num[i]][j]]+1);
		ans=max(ans,f[num[i]]);
	}
	printf("%d\n",ans);
}

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

using namespace std;

int main () {
  int a, b;
  cin >> a >> b;
  
  if (a <=5) {
    cout << 0;
    return 0;
  }
  
  if (a >= 6 and a <= 12) {
    cout << b / 2;
    return 0;
  }
  
  cout << b;
  
  
  return 0;
  
}



Measured memory_bytes: 256
#include<iostream>
#include<stack>
using namespace std;
int ans[100];
int main(){
    long long N;
    while(~scanf("%lld",&N)){
        int temp = 0;
        while(N){
            ans[temp++]=(N-1)%26;
            N--;
            N/=26;
        }
        for(int i=temp-1;i>=0;i--){
            cout << (char)('a'+ans[i]);
        }
        cout << endl;
    }
}

Measured memory_bytes: 3712
n = int(input())
hap = []
for i in range(n):
    a,b,c = map(int,input().split())
    hap.append([a,b,c])

dp=[[0,0,0] for i in range(n)]

def f(list,step,choice):
    global dp
    if step == 0:
        dp[0][choice] = list[0][choice]
    else:
        temp = 0
        for i in range(3):
            if i == choice:
                continue
            spend = dp[step-1][i] + list[step][choice]
            if spend >= temp:
                temp = spend
        dp[step][choice] = temp

for i in range(n):
    for j in range(3):
        f(hap,i,j)

print(max(dp[n-1]))


Measured memory_bytes: 42592
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define all(x) (x).begin(), (x).end()
#define MOD 1000000007

int main() {
    ll n, t;
    cin >> n >> t;
    vector<ll> a(n), M(n + 1), m(n + 1);
    for(size_t i = 0; i < n; i++) {
        cin >> a[i];
    }
    m[0] = LLONG_MAX;
    for(int i = 0; i < n; i++) {
        m[i + 1] = min(m[i], a[i]);
    }
    M.back() = LLONG_MIN;
    for(int i = n - 1; i >= 0; i--) {
        M[i] = max(M[i + 1], a[i]);
    }
    ll ans = 0;
    for(size_t i = 0; i < n; i++) {
        ans = max(M[i] - m[i], ans);
    }
    unordered_map<ll, int> mp;
    int c = 0;
    for(int i = 0; i < n; i++) {
        c += mp[a[i] - ans];
        mp[a[i]]++;
    }
    cout << c << endl;
}


Measured memory_bytes: 10824
#include <iostream>
#include <cstdio>
using namespace std;
#define M_MAX 1001
int main(){
	while(true){
		int most = 0;
		int ans = 0;
		int N,Q;
		int days[M_MAX] = {0,};
		scanf("%d%d",&N,&Q);
		if(N==0&&Q==0)break;

		for(int i = 0; i < N; ++i){
			int M;scanf("%d",&M);
			for(int j =0; j <M; ++j){
				int t;scanf("%d",&t);++days[t];
				if( most < days[t] ){
					most = days[t];
					ans = t;
				}else if( most == days[t] && t < ans ){
					ans = t;
				}
			}
		}

		if( most < Q ){
			ans = 0;
		}
		
		printf("%d\n", ans);
	}
	return 0;
}

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

signed main() {
  string a, b; cin >> a >> b;

  if(a.size() > b.size()) cout << "GREATER" << endl;
  else if(b.size() > a.size()) cout << "LESS" << endl;
  else {  // 同じ文字数だった場合
    if(a == b) cout << "EQUAL" << endl;
    else       cout << (a>b ? "GREATER" : "LESS") << endl;  // a>b は辞書順比較
  }
  return 0;
}


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

int main()
{
	double a, b, c, d, e, f;
	while (cin >> a >> b >> c >> d >> e >> f) {
		double g = ((c*d) - (a*f)) / ((b*d) - (a*e));
		double h = (c - (b*g)) / a;
		cout << fixed << setprecision(3) << h << " " <<g << endl;
	}
	return 0;
}

Measured memory_bytes: 3184
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

template<class T> inline T sqr(T x) {return x*x;}

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

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

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

#define CLR(a) memset((a), 0 ,sizeof(a))

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

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

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

  long long ans;
  ans = 3*(N-gcd(N, X));
  printf("%lld\n", ans);

  return 0;
}


Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main(){

  int n,x,i,j,k;

  while(cin >> n >> x){
    if(n==0&&x==0)break;
    int cnt=0;
    for(i=1; i<=n; i++){
      for(j=i+1; j<=n; j++){
	for(k=j+1; k<=n; k++){
	  if(i+j+k==x) cnt++;
	}
      }
    }
    cout << cnt << endl;
  }
}

Measured memory_bytes: 1160
#include <stdio.h>

int n, cnt=0;

void merge(int A[], int left, int mid, int right){
  int n1 = mid -left;
  int n2 = right - mid;
  int L[n1], R[n2];
  int i, j, k;
  for(i = 0; i < n1; i++)L[i] = A[left+i];
  for(i = 0; i < n2; i++)R[i] = A[mid+i];
  L[n1] = 1000000000, R[n2] = 1000000000;
  i = 0, j = 0;
  for(k = left; k < right; k++){
    cnt++;
    if(L[i] <= R[j]){
      A[k] = L[i];
      i++;
    }
    else{
      A[k]= R[j];
      j++;
    }
  }
}

void mergesort(int A[], int left, int right){
  if(left+1 < right){
    int mid = (left+right)/2;
    mergesort(A, left, mid);
    mergesort(A, mid, right);
    merge(A, left, mid, right);
  }
}

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

  mergesort(a, 0, n);

  for(i = 0; i < n; i++){
    if(i+1 != n)printf("%d ", a[i]);
    else printf("%d", a[i]);
  }
  printf("\n");
  printf("%d\n", cnt);
  
  return 0;
}



Measured memory_bytes: 5576
#include<bits/stdc++.h>
using ll  = long long;
#define int ll
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define erep(e,v) for(auto && e :v)
#define all(in) in.begin(), in.end()
#define MP make_pair
#define INF (sizeof(int) == 4 ? (int)1e9:(int)1e18)
#define EPS 0.0000000001
using namespace std;
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
template<typename Head, typename Value> auto vectors(const Head &head, const Value &v) { return vector<Value>(head, v); }
template<typename Head, typename... Tail> auto vectors(Head x, Tail... tail) { auto inner = vectors(tail...); return vector<decltype(inner)>(x, inner); }
template<class T> void join(T a){for(auto itr :a){if(itr != *a.begin())cout << " "; cout << itr;} }
using ld  = long double;
using pii = pair<int,int>;
using piii = pair<int,pii>;
int W,H;
int dx[]={0,0,1,-1}, dy[]={1,-1,0,0};
bool valid(int x,int y){return (0<=x&&x<W)&&(0<=y&&y<H);}
auto f (pair<string,int> a,pair<string, int> b){
    if(a.first.size() < b.first.size())return true;
    else if(a.first.size() == b.first.size())return a.first < b.first;
    return false;
}
signed main(){
    int n; cin >> n;
    map<string,int>mp;
    vector<pair<string, int>>v;
    rep(_,n){
        string s;int num;
        cin >> s >> num;
        mp[s] += num;
    }
    for(auto itr : mp){
        v.push_back(make_pair(itr.first, itr.second));
    }
    sort(all(v),f);
    erep(e,v){
        cout << e.first << " " << e.second << endl;
    }
}





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

int N, M; 
vector<vector<bool>> edge(51, vector<bool>(51, false));

void dfs(int v, vector<bool> &visited){ //頂点vから探索
    visited[v] = true;

    rep(i,N){
        if(edge[v][i] && !visited[i]){
            //cout << v << " " << i << endl;
            dfs(i, visited);
        }
    }
}


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

    rep(i,M){
        int a, b; cin >> a >> b; a--; b--;
        edge[a][b] = true;
        edge[b][a] = true;
    }

    int ans = 0;
    rep(i,N){
        for(int j=i+1; j<N; j++){
            if(!edge[i][j]) continue;

            edge[i][j] = false; edge[j][i] = false;
            vector<bool> visited(N, false);
            dfs(0, visited);
            edge[i][j] = true; edge[j][i] = true;

            //rep(i,N) cout << visited[i];
            //cout << endl;

            bool flag = false;
            rep(i,N) {if(!visited[i]) flag = true;}
            if(flag) ans++;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<functional>
#include<string>
#include<cmath>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<cstdio>
using namespace std;
using ll = long long;
int main(){
  int a[32] = {1, 1, 1, 2, 1, 2, 1, 5,  2, 2, 1, 5, 1, 2, 1, 14,
               1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
  int k;
  cin >> k;
  k--;
  cout << a[k] << "\n";

  return 0;
}

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

using namespace std;

#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define MOD 1000000007

typedef long long ll;

ll dp[55][55][2555];
void mod_add(ll &a, ll b){
	a += b;
	a %= MOD;
}

int main(){
	cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);
	ll n, score;cin >> n >> score;
	dp[0][0][0] = 1;
	ll nj, x;
	REP(i, n){
		REP(j, i+1)REP(k, score + 1){
			nj = j;mod_add(dp[i + 1][nj][k + 2 * nj], dp[i][j][k]);
			nj = j + 1;mod_add(dp[i + 1][nj][k + 2 * nj], dp[i][j][k]);
			nj = j;x = 2 * j;mod_add(dp[i + 1][nj][k + 2 * nj], dp[i][j][k] * x);
			nj = j - 1;x = j * j;if(j)mod_add(dp[i + 1][nj][k + 2 * nj], dp[i][j][k] * x);
		}
	}
	cout << dp[n][0][score] << endl;
	return 0;
}


Measured memory_bytes: 55552
#include <cstdio>
#include <math.h>
#include <algorithm>
#include <vector>
#include <iostream>
#include <sstream>
#include <string>
#include <iomanip>
#include <set>
#include <map>

using namespace std;

#define EPS 1e-14
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define REP(i,n) FOR(i, 0, n)
#define PI 2*acos(0.0)
#define ALL(a) (a).begin(),(a).end()
#define DEBUG(x) cout<<#x <<": "<< x << "\n"
#define DEBUG_ARR(a) REP(i, size(a)){ cout << #a << "[" << i << "]: " << a[i] << "\n"; }
const int VX[] = { 0, 1, 0, -1 };
const int VY[] = { 1, 0, -1, 0 };
const long MOD = 1000000007;

typedef long long ll;

int main() {
	//	--- I/O 高速化 ---
	cin.tie(0);
	ios::sync_with_stdio(false);
	// --- ここまで ---

	int n, arr[26] = { 0 }, _arr[26] = { 0 };
	cin >> n;
	string str;

	cin >> str;
	REP(i, str.length()) {
		arr[str[i] - 'a']++;
	}

	REP(i, n - 1) {
		cin >> str;
		REP(j, 26) _arr[j] = 0;

		REP(j, str.length()) {
			_arr[str[j] - 'a']++;
		}
		REP(j, 26) {
			if (_arr[j] < arr[j]) {
				arr[j] = _arr[j];
			}
		}
	}

	REP(i, 26) {
		REP(j, arr[i]) {
			cout << (char)('a' + i);
		}
	}
	cout << endl;

	return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) (v).begin(),(v).end()
#define int long long
using namespace std;
typedef vector<int>   vint;
typedef pair<int,int> pint;

signed main()
{   
    string s; cin>>s;
    int ans=1e9;
    REP(i,s.size()-2){
        int t=(s[i]-'0')*100+(s[i+1]-'0')*10+(s[i+2]-'0');
        ans=min(ans,abs(t-753));
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
//#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <queue>

using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<n;++i)
#define mod (ll)(1e9+7)
#define FIX(a) ((a)%mod+mod)%mod
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define fi first
#define se second
#define pb push_back
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vint h(n);
    REP(i,n) cin >> h[i];
    int now = h[0]-1;
    bool f = true;
    for(int i=1;i<n;i++){
        if(h[i]==now){
            now=h[i];
        }else if(h[i]>now){
            now = h[i]-1;
        }else{
            f=false;
            break;
        }
    }
    if(f){
        cout << "Yes\n";
    }else{
        cout << "No\n";   
    }

    return 0;
}

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

int		main(void)
{
	vector<int> A(5);
	int		k;
	for (int i = 0; i < 5; i++)
		cin >> A.at(i);
	cin >> k;
	sort(A.begin(), A.end());
	cout << (A.at(4) - A.at(0) <= k ? "Yay!" : ":(") << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define llu unsigned long long int
#define sa(a,n,t) for(int ii=0;ii<n;ii++) scanf("%"#t"",&(a)[ii])
#define rep(i,n) for(int i=0;i<n;i++) 
#define reps(i,a,n) for(int i=a;i<n;i++) 
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define rreps(i,a,n) for(int i=n-1;i>=a;i--)
#define validl(i,a,b) ((i>=a)&&(i<=b))?1:0
#define validmat(x,y,a,b,c,d) (validl(x,a,b) && validl(y,a,b))?1:0
#define validmn(x,y,m,n) validmat(x,y,0,m,0,n)
#define valid(i,n) validl(i,0,n)
#define v(t) vector<t>
#define vv(t) vector<vector<t> >
#define mk make_pair
#define pb push_back
#define pa(a,n,t)  for(int i=0;i<n;i++) printf("%"#t"",a[i])
#define p2 pair<int,int>
#define p3 pair<p2,int>
#define fi first
#define se second
#define sd(a) scanf("%d",&a)
#define sl(a) scanf("%lld",&a)
#define pl(a) printf("%lld",a)
#define pd(a) printf("%d",a)
#define sf(a) scanf("%lf",&a)
#define pf(a) printf("%lf",a)
#define nline printf("\n")
#define ss(a) scanf("%s",a)
#define ps(a) printf("%s",a)
#define sc(a) scanf("%c",&a)
#define pc(a) printf("%c",&a)
#define mf(m,f) m.find(f)!=m.end()
#define pp3(m) cout<<m.fi.fi<<" "<<m.fi.se<<" "<<m.se<<" "
#define pp2(m) cout<<m.fi<<" "<<m.se<<" "
#define debug 0
/*v(int) adj[200001];
void dfs(int i,int p){
    rep(j,adj[i].size()){
        if(p!=adj[i][j])
            dfs(adj[i][j],i);
    }
}*/
int main()
{
  int t,n;
  int a[100];
  cin>>n;
  sa(a,n,d);
  int c=0;
  rep(i,n){
      if((i+1)%2 && a[i]%2) c++;
  }
  cout<<c<<endl;
  return 0;
}


Measured memory_bytes: 3756
#include <iostream>
#include <string>
#include <cstdlib>
#include <vector>
#include <array>
#include <map>
#include <algorithm>
#include <queue>
#include <stack>

using namespace std;
typedef long long int ll;

int main(int argc, char const *argv[])
{
    string s, t;
    cin >> s;
    cin >> t;

    ll cnt = s.size();

    for(ll i = 0; i < cnt; i++)
    {
        s = s.back() + s;
        s.erase(s.end() - 1);
        if(s == t) {
            cout <<"Yes" <<endl;
            return 0;
        }
    }

    cout << "No" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <stdlib.h>
#include <string.h>
using namespace std;
#define ll long long

int main(){

    int n,k; cin >> n >> k;
    if(n % k == 0) cout << 0 << endl;
    else cout << 1 << endl;

    return 0;
}

Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;

fn main() {
    let s: Vec<usize> = read::<String>()
        .chars()
        .map(|i| (i as usize - 'a' as usize) as usize)
        .collect();
    let t: Vec<usize> = read::<String>()
        .chars()
        .map(|i| (i as usize - 'a' as usize) as usize)
        .collect();
    let n = s.len();
    let mut st = [30; 26];
    let mut ts = [30; 26];
    for i in 0..n {
        st[s[i]] = t[i];
        ts[t[i]] = s[i];
    }
    let mut ok = true;
    for i in 0..n {
        if st[s[i]] != t[i] || ts[t[i]] != s[i] {
            ok = false;
            break;
        }
    }
    println!("{}", if ok { "Yes" } else { "No" });
}

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}


Measured memory_bytes: 8444
#include <stdio.h>

#define MAX 100000

int binarySearch(int S[], int T, int n)
{
	int left=0, right=n, mid;
	while(left<right){
		mid=(left+right)/2;
		if(S[mid]==T) {return 1;}
		else if(T<S[mid]){right=mid;}
		else {left=mid+1;}
	}
	return 0;
}

int main(void)
{
	int n,q,i,cnt=0;
	int S[MAX],T[MAX];
	scanf("%d", &n);
	for(i=0;i<n;i++){
		scanf("%d",&S[i]);
	}
	
	scanf("%d", &q);
	for(i=0;i<q;i++){
		scanf("%d",&T[i]);
	}
	
	for(i=0;i<q;i++){
		cnt+=binarySearch(S,T[i], n);
	}
	printf("%d\n",cnt);
	
	return 0;
}


Measured memory_bytes: 2316
//#include <bits/stdc++.h>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <iomanip>
#include <iostream>
#include <vector>    
#include <cstdlib>
#include <map>
#define fast_io()                \
    ios::sync_with_stdio(false); \
    std::cin.tie(0);
#define mod 998244353
typedef long long ll;
typedef long double ld;
using namespace std;
int main()
{
    //fast_io();
    ll n;
    cin >> n;
    ll a[n];
    map<ll, ll> num;
    for (ll i = 0; i < n; i++)
    {
        cin >> a[i];
        num[a[i]]++;
    }
    ll sum = 0;
    for(auto i:num)
        sum += i.second * (i.second - 1) / 2;
    for(ll i = 0; i < n; i++)
        cout << sum - (num[a[i]] * (num[a[i]] - 1) / 2) + ((num[a[i]] - 1) * (num[a[i]] - 2) / 2) << '\n';
    return 0;
}

Measured memory_bytes: 11008