akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <string>
#include <iostream>
#include <map>
#include <algorithm>
using namespace std;

int main(void){
    string s;
    cin >> s;
    int flag=0;
    for(int i=0; i<s.size(); i++){
        if(flag==0)if(s[i]=='C')flag++;
        if(flag==1)if(s[i]=='F')flag++;
    }
    cout << (flag==2?"Yes":"No") << endl;
    return 0;
}

Measured memory_bytes: 256
def modpow(a,n,m):
    res = 1
    while n>0:
        if n%2==1:
            res = (res * a) % m
        a = (a*a) % m
        n = n//2
    return res


def comb(n,k,mod):
    MAX = k+1
    fac = [0]*MAX
    finv = [0]*MAX
    inv = [0]*MAX

    fac[0] = 1
    fac[1] = 1
    finv[0] = 1
    finv[1] = 1
    inv[1] = 1
    for i in range(2,MAX):
        fac[i] = (fac[i-1]*i)%mod
        inv[i] = mod - (inv[mod%i] * (mod//i))%mod
        finv[i] = (finv[i-1] * inv[i])%mod

    res = 1
    for i in range(n,n-k,-1):
        res *= i
        res %= mod
    res *= finv[k]
    return res%mod

MOD = 10**9 + 7
n,a,b = map(int, input().split())

res = modpow(2,n,MOD)
res = MOD + res - comb(n,a,MOD)
res = MOD + res - comb(n,b,MOD)
res = MOD + res - 1

print(res%MOD)

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

int main() {
  long long n;
  cin>>n;
  long long sum=1;
  bool ok=true;
  long long a[n];
  rep(i,n){
    cin>>a[i];
    }
  rep(i,n){
  if(a[i]==0)sum=0;
  }
  
  
  if(sum==1){
    rep(i,n){
      if(a[i]>(1000000000000000000/sum)){
        cout<<-1<<endl;
        ok=false;
        break;
      }
     sum*=a[i];
    }
  }
    
    if(ok)cout<<sum<<endl;
  
}


Measured memory_bytes: 4416
n,a,b,c,d = [int(i) for i in input().split()]
s = input()


flag1 = False
block = 0
for i in range(b, len(s)):
    if block == 2:
        flag1 = False
        break
    elif i == d-1:
        flag1 = True
        break
    elif s[i] == ".":
        block = 0
    elif s[i] == "#":
        block += 1

if flag1 == True:
    s2 = s[:d-1]+'#'+s[d:]
    flag1 = False
    block = 0
    for i in range(a, len(s)):
        if block == 2:
            flag1 = False
            break
        elif i == c-1:
            flag1 = True
            break
        elif s2[i] == ".":
            block = 0
        elif s2[i] == "#":
            block += 1


flag2 = False
flag3 = False
temp = 0
block = 0
for i in range(b-2,c-2):
    if temp == 3:
        flag2 = True
        temp = i-1
        break
    elif s[i] == "#":
        temp = 0
    elif s[i] == ".":
        temp += 1

if flag2 == True:
    flag3 = False
    block = 0
    s1 = s[:temp-1]+'#'+s[temp:]
    for i in range(a, len(s)):
        if block == 2:
            flag3 = False
            break
        elif i == c-1:
            flag3 = True
            break
        elif s1[i] == ".":
            block = 0
        elif s1[i] == "#":
            block += 1

    if flag3 == True:
        s3 = s1[:c - 1] + '#' + s1[c:]
        flag3 = False
        block = 0
        for i in range(temp, len(s)):
            if block == 2:
                flag3 = False
                break
            elif i == d-1:
                flag3 = True
                break
            elif s3[i] == ".":
                block = 0
            elif s3[i] == "#":
                block += 1

if flag1 or flag3:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3836
package main

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

// I/O
type Scanner struct {
	sc *bufio.Scanner
}

func NewScanner() *Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &Scanner{sc}
}

func (s *Scanner) nextStr() string {
	s.sc.Scan()
	return s.sc.Text()
}

func (s *Scanner) nextInt() int {
	i, e := strconv.Atoi(s.nextStr())
	if e != nil {
		panic(e)
	}
	return i
}

func (s *Scanner) nextFloat() float64 {
	f, e := strconv.ParseFloat(s.nextStr(), 64)
	if e != nil {
		panic(e)
	}
	return f
}

func (s *Scanner) nextRuneSlice() []rune {
	return []rune(s.nextStr())
}

func (s *Scanner) nextIntSlice(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextInt()
	}
	return res
}

func (s *Scanner) nextFloatSlice(n int) []float64 {
	res := make([]float64, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextFloat()
	}
	return res
}

// Arithmetic
func max(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m < i {
			m = i
		}
	}
	return m
}

func min(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m > i {
			m = i
		}
	}
	return m
}

func abs(x int) int {
	if x > 0 {
		return x
	}
	return -x
}

func pow(x, y int) int {
	res := 1
	for i := 0; i < y; i++ {
		res *= x
	}
	return res
}

// Sort
type Val struct {
	id, num int
}
type ByNum []Val

func (a ByNum) Len() int           { return len(a) }
func (a ByNum) Less(i, j int) bool { return a[i].num < a[j].num }
func (a ByNum) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }

type Sum struct {
	t     rune
	count int
}

func main() {
	sc := NewScanner()
	wtr := bufio.NewWriter(os.Stdout)
	S := sc.nextRuneSlice()
	K := []Sum{}
	before := S[0]
	count := 1
	for i := 1; i < len(S); i++ {
		if before != S[i] {
			K = append(K, Sum{before, count})
			count = 1
			before = S[i]
		} else {
			count++
		}
	}
	K = append(K, Sum{before, count})
	ans := 0
	for i, sum := range K {
		if sum.t == '>' {
			var s int
			if 0 < i {
				s = sum.count - 1
			} else {
				s = sum.count
			}
			ans += (s * (s + 1)) / 2
		} else {
			var s int
			if i < len(K)-1 {
				next := K[i+1]
				ma := max(sum.count, next.count)
				s = sum.count - 1
				ans += ma
			} else {
				s = sum.count
			}
			ans += (s * (s + 1)) / 2
		}
	}

	fmt.Fprintln(wtr, ans)
	wtr.Flush()
}


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

#define rep(i, n) for(int i = 0; i < n; ++i)

int main() {
	int h[2];
	int k[2];
	int a, b, c, d;

	cin >> h[0] >> h[1] >> k[0] >> k[1] >> a >> b >> c >> d;

	int hiroshi = h[0] * a + h[0] / 10 * c + h[1] * b + h[1] / 20 * d;
	int kenjiro = k[0] * a + k[0] / 10 * c + k[1] * b + k[1] / 20 * d;

	if (hiroshi == kenjiro) cout << "even" << endl;
	else (hiroshi > kenjiro) ? cout << "hiroshi" << endl : cout << "kenjiro" << endl;
}



Measured memory_bytes: 3120
import java.util.*;
 
public class Main {

    private static int MOD = 1_000_000_007;

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        PriorityQueue<Integer> pq = new PriorityQueue<>();
        Map<Integer, Integer> map = new HashMap<>();
        for (int i = 0; i < N; i++) {
            int X = sc.nextInt();
            int L = sc.nextInt();
            pq.offer(X);
            map.put(X, L);
        }

        int ans = 1;
        int prevX = pq.poll();
        int prevL = map.get(prevX);
        while (!pq.isEmpty()) {
            int X = pq.poll();
            int L = map.get(X);
            if (X+L <= prevX+prevL) {
                prevX = X;
                prevL = L;
            } else if (prevX+prevL <= X-L) {
                prevX = X;
                prevL = L;
                ans++;
            }
        }


        System.out.println(ans);
    }
}


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

int main() {
 int num1, num2, num3;


    cin >> num1 >> num2 >> num3;

    if (num1 < num2 && num1<num3)
    {
        if (num2 < num3)
            cout  <<abs(num3-num2)+abs(num2-num1);
        else cout << abs(num2-num3)+abs(num3-num1);
    }

    else

    if ( num2<num3)
    {
        if (num1 < num3)
            cout  <<abs(num3-num1)+abs(num1-num2);
        else cout << abs(num1-num3)+abs(num3-num2);
    }

    else
    {
        if(num2<num1)
            cout << abs(num1-num2)+abs(num2-num3);
        else cout << abs(num2-num1)+abs(num1-num3);
    }
  return 0;
}


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

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


Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))
counter = 0
for i in range(n):
  minj = i
  for j in range(i,n):
    if a[j] < a[minj]:
      minj = j
  if i != minj:
    counter += 1
    temp = a[i]
    a[i] = a[minj]
    a[minj] = temp
print(" ".join(map(str,a)))
print(counter)


Measured memory_bytes: 5596
#include <bits/stdc++.h>
 
//#include <unistd.h>
//#include <iostream>
 
using namespace std;
 
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl;
#define DEBUG_MAT(v) cerr<<#v<<endl;for(int i=0;i<v.size();i++){for(int j=0;j<v[i].size();j++) {cerr<<v[i][j]<<" ";}cerr<<endl;}
typedef long long ll;
#define int ll
 
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
template<class S, class T> pair<S, T> operator+(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first + t.first, s.second + t.second); }
template<class S, class T> pair<S, T> operator-(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first - t.first, s.second - t.second); }
template<class S, class T> ostream& operator<<(ostream& os, pair<S, T> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
#define X first
#define Y second
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define rrep1(i,n) for(int i=(n);i>0;i--)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define in(x, a, b) (a <= x && x < b)
#define all(c) c.begin(),c.end()
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a = b; return 1; } return 0; }
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
const ll inf = 1000000001;
const ll INF = (ll)1e18 + 1;
const long double pi = 3.1415926535897932384626433832795028841971L;
#define Sp(p) cout<<setprecision(25)<< fixed<<p<<endl;
//int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
//int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
vi dx = {1, 0, -1, 0}, dy = {0, 1, 0, -1};
vi dx2 = { 1,1,0,-1,-1,-1,0,1 }, dy2 = { 0,1,1,1,0,-1,-1,-1 };
#define fio() cin.tie(0); ios::sync_with_stdio(false);
//const ll MOD = 1000000007;
const ll MOD = 998244353;
// #define mp make_pair
//#define endl '\n'

signed main() {
  int n, k;
  cin >> n >> k;
  vi p(n);
  rep (i, n) cin >> p[i];
  vector<double> a(n);
  rep (i, n) {
    a[i] = (p[i] + 1) / 2.;
  }
  vector<double> sum(n + 1);
  rep (i, n) sum[i + 1] = sum[i] + a[i];
  double ans = 0;
  for (int i = 0; i + k <= n; i++) {
    chmax(ans, sum[i + k] - sum[i]);
  }
  Sp(ans);
}

Measured memory_bytes: 4992
#include <stdio.h>

int main(void)
{
  int a , b , c ,d;
  int max , min;
  
  scanf("%d %d %d %d",&a,&b,&c,&d);
  
  max = (b<d?b:d);
  min = (a>c?a:c);
  
  if((max-min)<=0)
   printf("0");
  else
    printf("%d",max-min);
  
  return 0;
}

Measured memory_bytes: 128
n, m = map(int, input().split())
h = list(map(int, input().split()))
l_n = [True] * n
for i in range(m):
    a, b = map(int, input().split())
    if h[a-1] == h[b-1]:
        l_n[b-1] = False
        l_n[a-1] = False
    elif h[a-1] <= h[b-1]:
        l_n[a-1] = False
    elif h[a-1] >= h[b-1]:
        l_n[b-1] = False
print(sum(l_n)) 

Measured memory_bytes: 19936
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,x) for(int i=0;i<x;i++)
#define put(ans)    cout << ans << endl;
#define reverse(s) reverse(s.begin(),s.end())


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

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

int main(){
    map<char,int> a;
    string s;   cin >> s;

    rep(i,s.size()){
        if(!a.count(s[i])){
            a[s[i]]++;
        }else{
            cout << "no" << endl;
            return 0;
        }
    }

    cout << "yes" << endl;

    return 0;
}

Measured memory_bytes: 3612
#include <map>
#include <cmath>
#include <queue>
#include <cstdio>
#include <string>
#include <cassert>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <algorithm>
#define rg register
#define f(i,a,b) for(rg int i=a;i<=b;++i)
#define df(i,a,b) for(rg int i=a;i>=b;++i)
#define F(x) {freopen(#x".in","r",stdin);freopen(#x".out","w",stdout);}
using namespace std;
template <typename T> inline void cmax(T &a,T b) {a=a>b?a:b;}
template <typename T> inline void cmin(T &a,T b) {a=a<b?a:b;}
template <typename T> inline void read(T &n) {
	n=0;rg char ch;while(!isdigit(ch=getchar()));
	for(n=ch^48;isdigit(ch=getchar());n=n*10+(ch^48));
}
int n,m;
signed main() {
	cin>>n>>m;
	cout<<(n^m);
}


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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

struct Problem{
    int first,second,i;

    Problem(int _first, int _second, int _i){
        first = _first;
        second = _second;
        i = _i;
    }

    int getScore(){
        return first*i+second;
    }
};

int d,g;
//vl p,c;
vector<Problem> pc;
int ans = 1e9;

void dfs(int score, int i, vi useplob)
{
    //DEBUG(i);
    //DEBUG(score);
    //DEBUG_VEC(useplob);
    if (i==d && score < g) return;

    if(score >= g){
        
        //cout<<"hit!"<<endl;
        //DEBUG(g);
        //DEBUG(score);
        //DEBUG_VEC(useplob);
        int anstmp, tmp;
        anstmp = 0; tmp = 0;
        REP(j,useplob.size()) anstmp+=pc[useplob[j]].first;

        REP(j,useplob.size()){
            if(score - pc[useplob[j]].getScore() > g) continue;

            if(score - pc[useplob[j]].second > g){
                tmp = g-(score-pc[useplob[j]].getScore());
                if(tmp % pc[useplob[j]].i == 0)
                    tmp = tmp/pc[useplob[j]].i;
                else
                    tmp = tmp/pc[useplob[j]].i + 1;

                ans = min(ans, anstmp - pc[useplob[j]].first + tmp);
            }

            ans = min(ans, anstmp);
        }
        if(i==d) return;
        //return;
    }

    //使わない場合
    dfs(score, i+1, useplob);

    //使う場合
    useplob.emplace_back(i);
    dfs(score+pc[i].getScore(), i+1, useplob);
}



int main() {
    cin>>d>>g;
    g/=100;
    //p.resize(d);
    //c.resize(d);

    REP(i,d) {
        pc.emplace_back(Problem(0,0,0));
        cin>>pc[i].first>>pc[i].second;

        pc[i].i = i+1;
        pc[i].second /=100;
    }

    vi useplob;
    dfs(0, 0, useplob);

    cout <<ans<<endl;
}

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

#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 EPS (1e-7)

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

int vx[]={0,1,0,-1};
int vy[]={1,0,-1,0};

int dx[]={1,0,-1,1,-1,1,0,-1};
int dy[]={1,1,1,0,0,-1,-1,-1};

const ll mod=1e9+7;
const int INF=INT_MAX/2;
const int MAX=1e9;

int main(){
	int x,y,z;
	cin>>x>>y>>z;
	int ans=(x-z)/(y+z);
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
function Main(input) {

    let output = "";

    for(i = 0; i < input[0]; i++){
        output = output + "ACL";
    }

    console.log(output);
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

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

using namespace std;
#define rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define pb push_back
#define int long long

signed main(){

	string s;
	cin>>s;

	for(int i=0;i<s.size();i+=2){
		cout<<s[i];
	}

	// if(s.size()%2==1){
	// 	cout<<s[s.size()-1];
	// }
	cout<<endl;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
int main(){
    int A, B , C, X;
    cin >> A >> B >> C >> X;
    int ans = 0;
    for(int i = 0; i <= A; i++){
        for(int j = 0; j <= B; j++){
            for(int k = 0; k <= C; k++){
                if(i * 500 + j * 100 + k * 50 == X){
                    ans++;
                }
            }
        }
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;

const int N = 100005;

int main() {
    
    long long A, B, C, K;
    
    scanf("%lld %lld %lld %lld", &A, &B, &C, &K);
    
    if (K % 2 == 0) {
        printf("%lld\n", A - B);
    } else {
        printf("%lld\n", B - A);
    }
    
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<math.h>
#include<queue>
#include<vector>
#include<climits>
#include<map>
#include<string>
#include<functional>
#include<iomanip>
#include <deque>

using namespace std;
typedef long long ll;

ll n, Y, M, D, ans[101] = {};

int main() {
	cin >> n;
	for (int i = 1; i <= n; i++) {
		cin >> Y >> M >> D;
		ans[i] = (1000 - Y - 1) * 195;
		if (Y % 3 != 0) {
			if (M % 2 == 0) {
				ans[i] += (10 - M) / 2 * 39;
			}
			else {
				ans[i] += ((10 - M) / 2 + 1) * 19 + (10 - M) / 2 * 20;
			}
		}
		else {
			ans[i] += (10 - M) * 20;
		}
		if (Y % 3 != 0 && M % 2 == 0) {
			ans[i] += 20 - D;
		}
		else {
			ans[i] += 21 - D;
		}
		ans[i] += (333 - Y / 3) * 5;
	}
	for (int i = 1; i <= n; i++)cout << ans[i] << endl;
	return 0;
}


Measured memory_bytes: 3068
#include <iostream>
#include <string>
#include <sstream>
#include <stack>
#include <cstdlib>
#include <cstdio>

using namespace std;

int main(){
	int t = 0;
	while(cin >> t){
		if(t == 0) break;
		int score1 = 0;
		int score2 = 0;
		while(t > 0){
			t --;
			int card1;
			int card2;
			cin >> card1;
			cin >> card2;
			if(card1 > card2)
				score1 += card1 + card2;
			else if (card1 < card2)
				score2 += card1 + card2;
			else{
				score1 += card1;
				score2 += card2;
			}
			
		}
		cout << score1 << " " << score2 << endl;
	}
}

Measured memory_bytes: 1160
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 998244353 
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
int n,x;
ll a[305];
ll dp[305][305];

int main(){
	cin >> n >> x;
	repn(i,n) cin >> a[i];
	rep(i,305)rep(j,305) dp[i][j] = 1e18;
	dp[0][0] = 0;
	repn(i,n+1){
		rep(j,i){
			rep(k,305){
				if(dp[j][k] > 5e17) continue;
				if(k+(i-j-1) > x) continue;
				dp[i][k+(i-j-1)] = min(dp[i][k+(i-j-1)],dp[j][k]+max(0LL,a[j]-a[i]));
			}
		}
	}
	ll ans = 1e18;
	rep(i,x+1) ans = min(ans,dp[n+1][i]);
	cout << ans << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int main() {
    string d[4] = {"dream", "erase", "eraser", "dreamer"};
    string s;
    cin >> s;
    int len = s.size();

    while(len != 0){
        for(int i=0;i<4;i++){
            string tmp = "";
            if(len < d[i].size()){
                continue;
            }
            tmp = s.substr(len - d[i].size(),d[i].size());
            if (tmp.compare(d[i])==0){
                s = s.substr(0,len-d[i].size());
                len = s.size();
                goto loop;
            }
        }
        printf("NO\n");
        return 0;
        loop:;
    }
    printf("YES\n");
}


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

using namespace std;
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)

typedef long long ll;
typedef pair<ll, ll> P;
const ll INF = 1LL<<60;

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

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

ll modpow(ll a, ll n, ll mod) {
  ll res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}

bool dp[100100];

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

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

  vector<int> a(N);

  rep(i, N) cin >> a[i];

  rep(i, 100100){
    dp[i] = false;
  }

  rep(i, N){
    dp[a[i]] = true;
  }

  for(int i = 0; i <= K; i++){

    bool win = false;

    for(int j = 0; j < N; j++){

      if(i - a[j] < 0) continue;

      if(dp[i - a[j]] == false){
        win = true;
        break;
      }

    }
    dp[i] = win;
  }

  if(dp[K]){
    cout << "First" << endl;
  }else{
    cout << "Second" << endl;
  }


  

  

  return 0;
}


Measured memory_bytes: 384
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<stack>
#include<set>
#include<climits>
#include<cstdlib>
#include<cmath>
#include<string>

using namespace std;

#define INF 1 << 29
#define LL long long int

LL const MOD = 1000000007;

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

    LL n;
    cin >> n;

    string str;
    cin >> str;

    auto tr = [&](LL k)->LL{
        return k < 0? k+n:k;
    };

    vector<bool> vec(n);

    for(int i = 0; i < 2; i++){
        for(int j = 0; j < 2; j++){
            vec[0] = i==0?false:true;
            vec[1] = j==0?false:true;
            for(int k = 0; k < n-2; k++){
                vec[k+2] = (str[k+1]=='o'?vec[k]:!vec[k]);
                vec[k+2] = vec[k+1]?vec[k+2]:!vec[k+2];
            }
            bool ans = true;
            bool t = (str[0]=='o'?vec[n-1]==vec[1]:vec[n-1]!=vec[1]);
            t = vec[0]?t:!t;
            if(!t){
                ans = false;
            }
            t = (str[n-1]=='o'?vec[n-2]==vec[0]:vec[n-2]!=vec[0]);
            t = vec[n-1]?t:!t;
            if(!t){
                ans = false;
            }

            for(int k = n-1; k >= 0 && ans; k--){
                t = (str[tr(k-1)]=='o'?vec[tr(k)]==vec[tr(k-2)]:vec[tr(k)]!=vec[tr(k-2)]);
                t = vec[tr(k-1)]?t:!t;
                if(!t){
                    ans = false;
                }   
            }
            if(ans){
                for(int k = 0; k < n; k++){
                    if(vec[k]){
                        cout << "S";
                    }else{
                        cout << "W";
                    }
                }
                cout << endl;
                return 0;
            }
        }
    }

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

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

int main() {
  int n;
  cin >> n;
  double a = floor(n/1.08);
  double b = ceil(n/1.08);
  if (n == (int)floor(a*1.08)) {
    cout << a << endl;
  } else if (n == (int)floor(b*1.08)) {
    cout << b << endl;
  } else {
    cout << ":(" << endl;
  }
}


Measured memory_bytes: 3784
#include <iostream>
using namespace std;
int main() {
	int S,F,A;
	int Y,M;

	cin >> S;
	F = (int)S / 100;
	A = S - F * 100;
		if (F <= 12 && F >= 1) {
			M = 1; //月かも
		}
		else {
			M= 3; //年確定
		}
		if (A <= 12 && A >= 1) {
			Y = 2; //月かも
		}
		else {
			Y = 5; //年確定
		}
		switch (M + Y){
			case 3:
				cout << "AMBIGUOUS" << endl;
			break;
			case 6:
				cout << "MMYY" << endl;
				break;
			case 5:
				cout << "YYMM" << endl;
			break;

			case 8:
				cout << "NA" << endl;
			break;
		}
		return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <climits>
using int64 = long long;
using namespace std;

int main()
{
  int n;
  cin >> n;
  int64 absSum = 0;
  int negativeCount = 0;
  int absMin = INT_MAX;
  for (int i = 0; i < n; ++i)
  {
    int tmp;
    cin >> tmp;
    if (tmp < 0)
    {
      ++negativeCount;
      tmp = -tmp;
    }
    absMin = tmp < absMin ? tmp : absMin;
    absSum += tmp;
  }
  
  if ((negativeCount & 1) == 0)
  {
    cout << absSum << endl;
  }
  else
  {
    cout << (absSum - 2 * absMin) << endl;
  }
  
  return 0;
}

Measured memory_bytes: 256
/*
これを入れて実行
g++ code.cpp
./a.out
 */

#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <cmath>
#include <tuple>
#include <iomanip>

using namespace std;
typedef long long ll;
typedef long double ld;

int dy[4] = {-1, 0, +1, 0};
int dx[4] = {0, +1, 0, -1};

const long long INF = 1LL << 60;
const ll MOD = 1e9 + 7;

bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}

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

//-----------------------ここから-----------


int main(void){
    int a, b, c;

    cin >> a >> b >> c;

    int ans1 = a * 10 + b + c;
    int ans2 = a + b * 10 + c;
    int ans3 = a + b + 10 * c;

    cout << max({ans1, ans2, ans3}) << endl;



}



Measured memory_bytes: 256
n = int(input())
sum = 0
tmp_2 = 101
for i in range(n):
  tmp = int(input())
  sum += tmp
  if tmp % 10 != 0:
    tmp_2 = min(tmp_2,tmp)
if sum % 10 != 0:
  print(sum)
elif tmp_2 == 101:
  print(0)
else:
  print(sum - tmp_2)

Measured memory_bytes: 3060
#include <iostream>
#include <string>
using namespace std;
typedef long long LL;
int main(int argc, char* argv[])
{
	int N,i;
	cin>>N;
	double x;
	string u;
	double ans=0.0;
	for (i=0;i<N;i++){
		cin>>x>>u;
		if (!u.compare("JPY")){
			ans+=x;
		}else{
			ans+=x*380000.0;
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define rep(i,n)for(int i=0;i<(int)(n);i++)
#define PI 3.141592653589793
//vector < vector<int>>a(0, vector<int>(0));二次元配列宣言


int main()
{
	int n;
	cin >> n;
	bool f = false;
	int i;
	vector<int>a(n);
	for (i = 0; i < n; i++)
	{
		cin >> a.at(i);
	}
	for (i = 0; i < n; i++)
	{
		if (a.at(i) % 2 == 0)
		{
			if (a.at(i) % 3 != 0 && a.at(i) % 5 != 0)
			{
				f = true;
				break;
			}
		}
	}
	if (f)
		cout << "DENIED" << endl;
	else
		cout << "APPROVED" << endl;
}

Measured memory_bytes: 3600
#include<stdio.h>
#define MAX 100000
int main()
{	int n,num=0;
	int a[MAX];
	int i;
	scanf("%d",&n);
	for(i=1;i<=n;i++)
		scanf("%d",&a[i]);
	i=1;
	while(1)
	{	num++;
		if(a[i]==2)
		{	printf("%d\n",num);
			break;
		}
		i=a[i];
		if(num>n)
		{	printf("-1\n");
			break;
		}
	} 
	return 0;
 } 

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

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


Measured memory_bytes: 3076
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
import java.util.stream.Collectors;

public class Main {
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int A = sc.nextInt();
		int B = sc.nextInt();
		int K = sc.nextInt();
		
		List<Integer> list = new ArrayList<>();
		for (int i = 1; i <= Math.min(A, B); i++) {
			if (A % i == 0 && B % i == 0) {
				list.add(i);
			}
		}
		
		list = list.stream().sorted().collect(Collectors.toList());
		
		System.out.println(list.get(list.size()-K));
		
		
	}
}


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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
vector<ll> pos;
vector<ll> neg;

template<typename T>
void remove(std::vector<T>& vector, unsigned int index)
{
    vector.erase(vector.begin() + index);
}


int main () {

    int n; cin >> n;
    ll a;

    if (n == 2) {
        int a, b;
        cin >> a >> b;
        
        cout << max(a, b) - min(a, b) << '\n';

        cout << max(a, b) << ' ' <<  min(a, b) << '\n';

    return 0;


    }


    for (int i = 0; i < n ;i++) {
        cin >> a;
        if (a >= 0) pos.push_back(a);
        else neg.push_back(a);
    }
    
    int len_pos = pos.size();
    int len_neg = neg.size();
    if (len_pos != 0) sort(pos.begin(), pos.end(), greater<int>());
    if (len_neg != 0) sort(neg.begin(), neg.end());

    vector<P> V1;
    if (len_neg == 0) {
        neg.push_back(pos[len_pos-2] - pos[len_pos-1]);
        V1.push_back(P(pos[len_pos-2], pos[len_pos-1]));
        len_pos--;
        remove(pos, len_pos);
        len_pos--;
        remove(pos, len_pos);
        len_neg++;
    }
    if (len_pos == 0) {
        pos.push_back(neg[len_neg-1] - neg[len_neg-2]);
        V1.push_back(P(neg[len_neg-1], neg[len_neg-1]));
        len_neg--;
        remove(neg, len_neg);
        len_neg--;
        remove(neg, len_neg);
        len_pos++;
    }
/*
    cout << len_pos << ' ' << len_neg << '\n';
    for (int i = 0; i < pos.size(); i++) {
        cout << pos[i] << '\n';
    }

    cout << 'a' << '\n';
    for (int i = 0; i < neg.size(); i++) {
        cout << neg[i] << '\n';
    }
*/


    while (len_pos > 1) {
        len_neg--;
        len_pos--;
        neg.push_back(neg[len_neg] - pos[len_pos]);
        V1.push_back(P(neg[len_neg], pos[len_pos]));
        remove(neg, len_neg);
        remove(pos, len_pos);
        len_neg++;
    }
    while (len_neg > 0) {
        len_neg--;
        len_pos--;
        pos.push_back(pos[len_pos] - neg[len_neg]);
        V1.push_back(P(pos[len_pos], neg[len_neg]));
        remove(neg, len_neg);
        remove(pos, len_pos);
        len_pos++;
    }

    cout << pos[len_pos] << '\n';

    for (int i = 0; i < V1.size(); i++) {
        cout << V1[i].first << ' ' << V1[i].second << '\n';
    }


}




Measured memory_bytes: 5104
/**
 *    author:  tourist
 *    created: 14.07.2018 15:20:06       
**/
#include <bits/stdc++.h>

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int half;
  cin >> half;
  string s;
  cin >> s;
  map<string,int> mp;
  for (int t = 0; t < (1 << half); t++) {
    string a = "", b = "";
    for (int i = 0; i < half; i++) {
      if (t & (1 << i)) {
        a += s[i];
      } else {
        b += s[i];
      }
    }
    string c = a + "." + string(b.rbegin(), b.rend());
    mp[c]++;
  }
  long long ans = 0;
  for (int t = 0; t < (1 << half); t++) {
    string a = "", b = "";
    for (int i = 0; i < half; i++) {
      if (t & (1 << i)) {
        a += s[i + half];
      } else {
        b += s[i + half];
      }
    }
    string c = string(a.rbegin(), a.rend()) + "." + b;
    ans += mp[c];
  }
  cout << ans << '\n';
  return 0;
}


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

int main() {
	string s;
	cin >> s;
	int A = -1, Z = -1, len = s.size();
	for (int i = 0; i < len; i++) {
		if (A != -1 && Z != -1) break;
		if (A == -1 && s.at(i) == 'A') {
			A = i;
		}
		if (Z == -1 && s.at(len - 1 - i) == 'Z') {
			Z = len - 1 - i;
		}
	}

	cout << Z - A + 1 << endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef int64_t Int;
#define dump(x) cout << (x) << '\n'
Int mod = 1e9+7;
//Int mod = 998244353; 
Int INF = 1e9+7;

int main() {    
    Int r, g, b, n;
    cin >> r >> g >> b >> n;
    Int res = 0;
    for (Int i = 0; i * r <= n; i++) {
        for (Int j = 0; i * r + j * g <= n; j++) {
            if ((n - i * r - j * g) % b == 0) res++;
        }
    }
    dump(res);
    return 0;  
}

Measured memory_bytes: 256
import java.util.Scanner;
import java.lang.*;

public class Main{

	public static String reverse(String str){
		
			if(str.length() == 1){
				return str;
			}else{
				
				return  reverse(str.substring(1)) + str.substring(0,1);
				
			}
		
		}

	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		
		String str = scan.next();
		
		str = reverse(str);
		
		System.out.println(str);
		
		
		
	}

}

Measured memory_bytes: 25788
import Control.Applicative ((<$>), (<*>))
import Control.Monad
import Data.List
import Data.Array.Unboxed

main :: IO ()
main = do
  n <- getl toInt
  unless (n == 0) $ do
    solve <$> replicateM n (getl toInt) >>= mapM_ putStrLn
    main

solve :: [Int] -> [String]
solve = map f . elems . accum (+) iar . map g
  where
    iar = listArray (0,9) (repeat 0) :: UArray Int Int
    f x = if x == 0 then "-" else replicate x '*'
    g x = (x,1)
      
toInt :: String -> Int
toInt = read

wrds :: (String -> a) -> String -> [a]
wrds f = map f . words

getl :: (String -> a) -> IO a
getl f = f <$> getLine

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

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define rep2(i, a, b) for (ll i = (a); i < (b); i++)
typedef uint64_t ull;
typedef int64_t ll;
typedef std::pair<ll, ll> PLL;

using namespace std;

signed main() {
  ll N;
  cin >> N;
  vector<ll> d(N);
  rep(i,N) {
    cin >> d[i];
  }
  sort(begin(d), end(d));

  // 上から順に左右に振り分けていく
  vector<ll> v;
  rep(i,d.size()) {
    if (i%2==0) {
      v.push_back(d[i]);
    } else {
      v.push_back(24-d[i]);
    }
  }
  v.push_back(0);
  v.push_back(24);

  sort(begin(v), end(v));
  //cout << "v: ";
  //rep(i,v.size()) {
  //  cout << v[i] << " ";
  //}
  //cout << endl;

  ll ans = 3333;
  rep(i, N+1) {
    ans = min(ans, v[i+1]-v[i]);
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
X,Y,Z,K = gets.split.map(&:to_i)
A = gets.split.map(&:to_i).sort.reverse
B = gets.split.map(&:to_i).sort.reverse
C = gets.split.map(&:to_i).sort.reverse
ans = []
for i in 1..[K,X].min do
    for j in 1..[K/i,Y].min do
        for k in 1..[K/(i*j),Z].min do
            ans.push(A[i-1]+B[j-1]+C[k-1])
        end
    end
end
ans.sort!.reverse!
for i in 0..K-1 do
    p ans[i]
end

Measured memory_bytes: 3832
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
#define show(x) {for(auto i: x){cout << i << " ";} cout << endl;}
using namespace std;
using ll = long long;
using P = pair<int, int>;

struct Edge {
    int to, id;
    Edge(int to, int id): to(to), id(id) {}
};

vector<Edge> g[55];
vector<int> es;

bool dfs(int cur, int goal, int pa = -1) {
    if (cur == goal) return true;
    for (Edge p : g[cur]) {
        int next = p.to;
        if (next == pa) continue;
        if (dfs(next, goal, cur)) {
            es.push_back(p.id);
            return true;
        }
    }
    return false;
}

int main() {
    // 包除原理、m個の制約で辺のidの集合をbitで持つ
    int n;
    cin >> n;
    rep(i, n-1) {
        int a, b;
        cin >> a >> b;
        --a; --b;
        g[a].emplace_back(b, i);
        g[b].emplace_back(a, i);
    }
    int m;
    cin >> m;
    vector<ll> eset(m);
    rep(i, m) {
        int u, v;
        cin >> u >> v;
        --u; --v;
        es = vector<int>();
        dfs(u, v);
        for (int a : es) {
            eset[i] |= 1ll << a;
        }
    }
  ll ans = 0;
  rep(i,1<<m) {
    ll mask = 0;
    rep(j,m) {
      if (i>>j&1) mask |= eset[j];
    }
    int white = __builtin_popcountll(mask);
    ll now = 1ll<<(n-1-white); // 2^(n-1-white)
    if (__builtin_popcountll(i)%2 == 0) ans += now;
    else ans -= now;
  }
    cout << ans << '\n';
    return 0;
}


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

int main(){
    ll n, k;
    cin >> n >> k;
    ve<P> dt(n);
    ve<ll> fl(n,0);
    rep(i,n) {
        cin >> dt[i].second >> dt[i].first;
        dt[i].second--;
    }
    sort(dt.rbegin(), dt.rend());
    ll ans = 0;
    ll cnt = 0;
    priority_queue<P> kouho;
    rep(i,k){
        ans += dt[i].first;
        if(fl[dt[i].second] == 0) cnt++;
        else kouho.push(P(-dt[i].first,dt[i].second));
        fl[dt[i].second] += 1;
    }
    ans += cnt*cnt;
    ve<ll> x;
    x.push_back(ans);
    ll i = k;
    while(i<n && !kouho.empty()){
        if(fl[dt[i].second] != 0){
            i++;
            continue;
        }
        ans -= cnt*cnt;
        ans += kouho.top().first;
        kouho.pop();
        cnt++;
        ans += cnt*cnt;
        ans += dt[i].first;
        fl[dt[i].second] = 1;
        x.push_back(ans);
        i++;
    }
    sort(x.rbegin(), x.rend());
    cout << x[0] << endl;
    return 0;
}


Measured memory_bytes: 6520
#include <bits/stdc++.h>
#define fi first
#define se second
using ll = long long;
using namespace std;

constexpr int B = 33, M = 1000000000 + 3337, B2 = 29, M2 = 1000000000 + 9;

int mpow(int a, int b, int m) {
  int res = 1;
  do {
    if(b & 1) res = 1ll * res * a % m;
    a = 1ll * a * a % m;
  } while(b >>= 1);
  return res;
}
 
class Hash {
  string & s;
  int n, B, M;
  vector<int> bi, h;
public:
  Hash(string & _s, int _B, int _M) : s(_s), B(_B), M(_M) {
    n = (int) s.size();
    bi.resize(n);
    int b = mpow(B, M - 2, M);
    bi[0] = 1;
    for(int i = 1; i < n; ++i) {
      bi[i] = 1ll * bi[i - 1] * b % M;
    }
    h.assign(n, 0);
    for(int i = 0, p = 1; i < n; ++i, p = 1ll * p * B % M) {
      if(i) h[i] = h[i - 1];
      h[i] += 1ll * (s[i] - 'a') * p % M;
      if(h[i] >= M) h[i] -= M;
    }
  }
 
  int hash(int i, int j) {
    int ans = h[j];
    if(i) {
      ans -= h[i - 1];
      if(ans < 0) ans += M;
    }
    ans = 1ll * ans * bi[i] % M;
    return ans;
  }
};

class DoubleHash {
  Hash h1, h2;
public:
  DoubleHash(string s, int b1, int m1, int b2, int m2) :
    h1(s, b1, m1), h2(s, b2, m2)
  {
  }
 
  pair<int, int> hash(int i, int j) {
    return {h1.hash(i, j), h2.hash(i, j)};
  }
};

int n;

bool ok(int m, DoubleHash& H) {
    map<pair<int, int>, int> mn, mx;
    for(int i = 0; i + m - 1 < n; ++i) {
        pair<int, int> hash = H.hash(i, i + m - 1);
        if(mn.find(hash) == mn.end()) mn[hash] = i;
        mx[hash] = i;
    }
    for(auto e : mn) {
        int i = e.se;
        int j = mx[e.fi];
        if(j - i >= m) return true;
    }
    return false;
}

int32_t main() {
    ios::sync_with_stdio(0); cin.tie(0);
    string s;
    cin >> n >> s;
    DoubleHash H(s, B, M, B2, M2);
    int l = 0, r = n / 2;
    while(r - l > 1) {
        int m = (l + r) >> 1;
        if(ok(m, H)) l = m;
        else r = m - 1;
    }
    if(ok(r, H)) l = r;
    cout << l << '\n';
}


Measured memory_bytes: 1024
# coding:utf-8

import sys
import math
import time
#import numpy as np
import collections
from collections import deque
from collections import Counter
import queue
import copy
import bisect
import heapq
import itertools


sys.setrecursionlimit(10**7)
#N, Q = map(int, input().split())
#G = [list(input()) for i in range(H)]
#INF = V * 10001
#A = [int(i) for i in input().split()]
#AB = [list(map(int, input().split())) for _ in range(K)]

S = str(input())
T = str(input())
ans = 0

for i in range(3):
    if(S[i]==T[i]):
        ans+=1


print(ans)


Measured memory_bytes: 68704
N = int(input())
s = [input() for _ in [0]*N]
M = int(input())
t = [input() for _ in [0]*M]
ans = {}
for c in s:
    ans[c] = ans.get(c,0) + 1
for c in t:
    ans[c] = ans.get(c,0) - 1
print(max(0,max(ans.values())))

Measured memory_bytes: 3060
import sys

def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())

A,B = LI()

if A <= 5:
    print(0)
elif A <= 12:
    print(B//2)
else:
    print(B)

Measured memory_bytes: 9032
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second

const int mx=1000010;
const ll mod=1e9+7;

struct UnionFind {  
  vector<int> par,sizes;                     // par[i]:iの親の番号(ex)par[3]=2 : 3の親が2
  UnionFind(int n) : par(n),sizes(n,1)  {    //最初は全てが根であるとして初期化
    for(int i=0; i<n; i++){ par[i]=i; }  
  }
  int root(int x) {                       //xが属する木の根を再帰で得る:root(x)={xの木の根}
    if(par[x]==x){ return x; }
    return par[x] = root(par[x]);
  }
  void unite(int x, int y) {                 // xとyの木を併合
    int rx = root(x);                        //xの根をrx
    int ry = root(y);                        //yの根をry
    if(rx == ry){ return; }                  //xとyの根が同じ(=同じ木にある)時はそのまま
    if(sizes[rx]<sizes[ry]){ swap(rx, ry); } //xの木をおおきくする
    par[ry] = rx; 
    sizes[rx] += sizes[ry];                  //sizes[ry]はもう使わない
  }
  bool check(int x, int y) {                 // x,yが属する木が同じならtrueを返す
    return root(x) == root(y);
  }
  int size(int x){                           //xが含まれる木の大きさを返す
    return sizes[root(x)];
  }
};

int main(){
  int n,m;
  cin >> n >> m;
  vector<int> v[n];
  rep(i,m){
    int a,b;
    cin >> a >> b;
    a--; b--;
    v[a].emplace_back(b);
    v[b].emplace_back(a);
  }

  vector<int> si(n,inf);
  queue<int> q;
  q.push(0);
  si[0]=0;
  while(!q.empty()){
    int p = q.front(); q.pop();
    for(auto it:v[p]){
      if(si[it]!=inf) continue;
      q.push(it);
      si[it] = p;
    }
  }

  rep(i,n)if(si[i]==inf){
    cout << "No" << endl; return 0;
  }
  cout << "Yes" << endl;
  REP(i,1,n){
    cout << si[i]+1 << endl;
  }

  return 0;
}

Measured memory_bytes: 10232
import java.awt.geom.*;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.*;

public class Main {
	
	//1040 start
	
	//SHAKYO
	private void doit(){
		InStream sc = new InStream();
		while(sc.hasNext()){
			int n = sc.nextInt();
			int m = sc.nextInt();
			char [] s = sc.next().toCharArray();
			
			long B = 1000000007L;
			long [] bb = new long[n];
			bb[0] = 1L;
			for(int i = 0 ; i < n-1; i++){
				bb[i+1] = bb[i] * B;
			}
			long B1 = 1L;
			long tmp = B;
			for(int i =0; i < 63; i++){
				B1 *= tmp;
				tmp *= tmp;
			}
			int right = 0, left = 0;
			long now = s[0];
			HashSet<Long> set = new HashSet<Long>();
			for(int i = 0; i < m; i++){
				String op = sc.next();
				if(op.charAt(0) == 'R'){
					if(op.charAt(1) == '+'){
						right++;
						long temp = now * B;
						now = temp + s[right];
					}
					else{
						now = now - s[right];
						now = now * B1;
						right--;
					}
				}
				else{
					if(op.charAt(1) == '+'){
						long temp = (long)s[left] * bb[right - left];
						now = now - temp;
						left++;
					}
					else{
						left--;
						long temp = (long)s[left] * bb[right - left];
						now = now + temp;
					}
				}
				set.add(now);
			}
			System.out.println(set.size());
		}
	}
	
	class InStream{
		BufferedReader in;StringTokenizer st;
		public InStream() {
			this.in = new BufferedReader(new InputStreamReader(System.in));
			this.st = null;
		}
		String next() {
			while (st==null || !st.hasMoreTokens()) {
				try {
					st = new StringTokenizer(in.readLine());
				} catch (Exception e) {}
			}
			return st.nextToken(); 
		}
		boolean hasNext(){
			try {
				st = new StringTokenizer(in.readLine());
				return true;
			} catch (Exception e) {return false;}
		}
		int nextInt() {	return Integer.parseInt(next()); }
		long nextLong() {return Long.parseLong(next());	}
		double nextDouble() {return Double.parseDouble(next());	}
	}
	
	public static void main(String [] args){
		new Main().doit();
	}
}

Measured memory_bytes: 30000
#include <bits/stdc++.h>
using namespace std;
int main(){
    int N;
    cin >> N;
    vector<int> a(N),b(N);
    for(int i(0);i<N;++i) cin >> b[i];
    for(int i(0);i<N;++i){
        int max_idx(-1);
        for(int j(0);j<N-i;++j){
            if(b[j] == j+1) max_idx = j;
        }
        if(max_idx == -1){
            cout << -1 << endl;
            return 0;
        }
        a[N-1-i] = b[max_idx];
        if(i < N-1) b.erase(b.begin() + max_idx);
    }
    for(int i(0);i<N;++i){
        cout << a[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
//#define int ll
//#define endl "\n"
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;
#define all(c) (c).begin(), (c).end()
#define loop(i,a,b) for(ll i=a; i<ll(b); i++)
#define rep(i,b) loop(i,0,b)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
template<class T> ostream & operator<<(ostream & os, vector<T> const &);
template<int n, class...T> typename enable_if<(n>=sizeof...(T))>::type _ot(ostream &, tuple<T...> const &){}
template<int n, class...T> typename enable_if<(n< sizeof...(T))>::type _ot(ostream & os, tuple<T...> const & t){ os << (n==0?"":" ") << get<n>(t); _ot<n+1>(os, t); }
template<class...T> ostream & operator<<(ostream & os, tuple<T...> const & t){ _ot<0>(os, t); return os; }
template<class T, class U> ostream & operator<<(ostream & os, pair<T,U> const & p){ return os << "(" << p.first << ", " << p.second << ") "; }
template<class T> ostream & operator<<(ostream & os, vector<T> const & v){ rep(i,v.size()) os << v[i] << (i+1==(int)v.size()?"":" "); return os; }
template<class T> inline bool chmax(T & x, T const & y){ return x<y ? x=y,true : false; }
template<class T> inline bool chmin(T & x, T const & y){ return x>y ? x=y,true : false; }
#ifdef DEBUG
#define dump(...) (cerr<<#__VA_ARGS__<<" = "<<mt(__VA_ARGS__)<<" ["<<__LINE__<<"]"<<endl)
#else
#define dump(...)
#endif
// ll const mod = 1000000007;
// ll const inf = 1LL<<60;

bool dp[6000][1<<13];

ll const B = 3;
ull p[6000], thash[6000];
ull shash[13];

int n,m;
int len;
char t[6000];
char ss[13][22];
int sslen[13];

int solve(){
    rep(i,n){
        ull x = 0;
        for(int j=0;ss[i][j];j++){
            x = x*B + ss[i][j];
        }
        shash[i] = x;
    }
    p[0] = 1;
    thash[0] = 0;
    rep(i,len){
        p[i+1] = p[i]*B;
        thash[i+1] = thash[i]*B + t[i];
    }

    rep(i,len+1)rep(j,1<<n) dp[i][j] = false;
    rep(i,len+1) dp[i][0] = true;
    rep(pos,len){
        rep(mask,1<<n){
            if(!dp[pos][mask]) continue;
            rep(i,n){
                if(mask>>i&1) continue;
                if(pos+sslen[i] > len) continue;
                ull h1 = shash[i];
                ull h2 = thash[pos+sslen[i]] - thash[pos] * p[sslen[i]];
                // if(h1 != h2) continue;
                dp[pos+sslen[i]][mask|1<<i] |= h1 == h2; // t.substr(pos,ss[i].size()) == ss[i];
            }
        }
    }

    int ans = 0;
    rep(i,len+1){
        if(dp[i][(1<<n)-1]){
            ++ans;
        }
    }
    return ans;
}

signed main(){
    while(scanf("%d%d",&n,&m), n){
        len = 0;
        rep(i,n){
            scanf("%s",ss[i]);
            sslen[i] = strlen(ss[i]);
        }
        rep(i,m){
            static char buf[22];
            scanf("%s",buf);
            int l = strlen(buf);
            rep(i,l) t[i+len] = buf[i];
            len += l;
        }
        cout << solve() << endl;
    }
}

Measured memory_bytes: 42160
#include <cstdio>
#include <cstring>
#include <cmath>
#include <utility>
#include <iostream>
#include <functional>
#include <bitset>
#include <algorithm>
#include <vector>
#include <forward_list>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <tuple>
#include <numeric>
#define rep(i, s, g) for ((i) = (s); (i) < (g); ++(i))
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const ll MOD = 1e9 + 7;
const ll INF = (1ll << 60);

int main(void)
{
    int n;
    cin >> n;

    ll ans = 0;

    for (int i = 1; i <= n; i++)
    {
        ans += ((n - 1) / i);
    }

    cout << ans << endl;
}


Measured memory_bytes: 3620