akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;
 
public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        String K = scan.next();
        int k = Integer.parseInt(K);
        String s = scan.next();

        int sLen = s.length();

        if (sLen <= k) {
          System.out.println(s);
        } else {
          System.out.println(s.substring(0, k) + "...");
        }
    }
}

Measured memory_bytes: 38580
n, m = map(int, input().split())
ac = [False for _ in range(n+1)]
wa = [0 for _ in range(n+1)]

acCount = 0
waCount = 0

for i in range(m):
    p, s = input().split()
    p = int(p)
    if(ac[p] == False):
        if (s == "AC"):
            ac[p] = True
        else:
            wa[p] += 1

for i in range(n+1):
    if(ac[i] == True):
        acCount += 1
        waCount += wa[i]

print(acCount, waCount)



Measured memory_bytes: 4760
#include<stdio.h>
int main()
{
	int temp;
	int i,j,n;
	int a[100];
	int count=0;

	scanf("%d",&n);
	a[n]=9999;

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

	for(i=0;i<n;i++)
	{
		for(j=0;j<n-1-i;j++)
		{
			if(a[j]>a[j+1])
			{
				temp=a[j];
				a[j]=a[j+1];
				a[j+1]=temp;
				count++;
			}
		}
	}

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

	printf("%d\n",count);
	return 0;
}

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

int main(){
    int n, b;
    string a;
    cin >> n;
    tuple<string, int, int>p[n]; // name, rating, orig pos (op not for sorting)
    for (int i=0; i<n; i++){
        cin >> a >> b;
        p[i] = make_tuple(a,-b,i+1);
    }
    sort(p, p+n);
    for (int i=0; i<n; i++){
        cout << get<2>(p[i]) << "\n";
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int N;
  cin >> N;
  for(int i=1; i<10; i++){
    if(N%i==0){
      int a = N/i;
      if(a<10){
        cout << "Yes" << endl;
        return 0;
      }
    }
  }
  cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 256
import sys,collections as cl,bisect as bs
sys.setrecursionlimit(100000)
input = sys.stdin.readline
mod = 10**9+7
Max = sys.maxsize
def l(): #intのlist
    return list(map(int,input().split()))
def m(): #複数文字
    return map(int,input().split())
def onem(): #Nとかの取得
    return int(input())
def s(x): #圧縮
    a = []
    if len(x) == 0:
        return []
    aa = x[0]
    su = 1
    for i in range(len(x)-1):
        if aa != x[i+1]:
            a.append([aa,su])
            aa = x[i+1]
            su = 1
        else:
            su += 1
    a.append([aa,su])
    return a
def jo(x): #listをスペースごとに分ける
    return " ".join(map(str,x))
def max2(x): #他のときもどうように作成可能
    return max(map(max,x))
def In(x,a): #aがリスト(sorted)
    k = bs.bisect_left(a,x)
    if k != len(a) and a[k] ==  x:
        return True
    else:
        return False

def pow_k(x, n):
    ans = 1
    while n:
        if n % 2:
            ans *= x
        x *= x
        n >>= 1
    return ans

"""
def nibu(x,n,r):
    ll = 0
    rr = r
    while True:
        mid = (ll+rr)//2

    if rr == mid:
        return ll
    if (ここに評価入れる):
        rr = mid
    else:
        ll = mid+1
"""

n = onem()

a = l()

aa = [[a[i],i] for i in range(n)]

aa.sort(reverse = True)

dp = [[0 for i in range(n+1)] for j in range(n+1)]

for i in range(1,n+1):
    on = aa[i-1]
    for j in range(i+1):
        if j-1 >= 0:
            dp[i-j][j] = max(dp[i-j][j-1] + on[0] * abs(on[1] - (n-1 - (j - 1))),dp[i-j][j])
            """
            if i == 1:
                print(dp[i-j][j-1] + on[0] * abs(on[1] - j),dp[i-j][j])
            """
        if i-j-1 >= 0:
            #dp[i-j][j] = max(dp[i-j][j],dp[i-j-1][j] + on[0] * abs(on[1] - (n-1 - (i-j))))
            dp[i-j][j] = max(dp[i-j][j],dp[i-j-1][j] + on[0] * abs(on[1] - (i-j-1)))
            """
            if i == 1:
                print(on,(n-1 - (i-j)),n-1,i-j)
                print(dp[i-j-1][j],on[0] * abs(on[1] - (n-1 - (i-j))))
                print(dp[i-j][j],dp[i-j-1][j] + on[0] * abs(on[1] - (i-j-1)))
            """

ma = 0    
for i in range(n+1):
    ma = max(ma,dp[n-i][i])
print(ma)







Measured memory_bytes: 102288
// きりみんちゃんねるからきました 2020/02/02 22:16

package main

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

var sc = bufio.NewScanner(os.Stdin)
var out = bufio.NewWriter(os.Stdout)

func main() {
	sc.Split(bufio.ScanWords)
	defer out.Flush() // !!!!coution!!!! you must use Fprint(out, ) not Print()
	/* --- code ---*/
	// うしろからみていくかんじ 先頭は適当にaで埋めとけ
	s, t := next(), next()
	for i:=len(s)-len(t); i>=0; i--{
    	flag := true
    	ret := ""
		for j:=0; j<len(t); j++{
			if string([]rune(s)[i+j]) == string([]rune(t)[j]) || string([]rune(s)[i+j]) == "?"{
			    ret += string([]rune(t)[j])
			}else{
			    flag = false
			}
		}
		if flag{
		    // （eうしろからかぞえて）iまでの?を適当にaで埋める
		    pre := ""
		    for k:=0; k<i; k++{
		        if string([]rune(s)[k]) == "?"{
    		        pre += "a"
		        }else{
		            pre += string([]rune(s)[k])
		        }
		    }
		    // これはi+len(t)以降の?に対して適当にaで埋める
		    epi := ""
		    for k:=i+len(t); k<len(s); k++{
		        if string([]rune(s)[k]) == "?"{
    		        epi += "a"
		        }else{
		            epi += string([]rune(s)[k])
		        }
		    }
		    fmt.Println(pre + ret + epi)
		    return
		}
	}
	fmt.Println("UNRESTORABLE")
}

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	a, _ := strconv.Atoi(next())
	return a
}

func nextFloat64() float64 {
	a, _ := strconv.ParseFloat(next(), 64)
	return a
}

func nextInts(n int) []int {
	ret := make([]int, n)
	for i := 0; i < n; i++ {
		ret[i] = nextInt()
	}
	return ret
}
func nextFloats(n int) []float64 {
	ret := make([]float64, n)
	for i := 0; i < n; i++ {
		ret[i] = nextFloat64()
	}
	return ret
}
func nextStrings(n int) []string {
	ret := make([]string, n)
	for i := 0; i < n; i++ {
		ret[i] = next()
	}
	return ret
}

func PrintOut(src interface{}, joinner string) {
	switch reflect.TypeOf(src).Kind() {
	case reflect.Slice:
		s := reflect.ValueOf(src)
		for idx := 0; idx < s.Len(); idx++ {
			fmt.Fprintf(out, "%v", s.Index(idx))
			if idx < s.Len()-1 {
				fmt.Fprintf(out, "%s", joinner)
			} else {
				fmt.Fprintln(out)
			}
		}
	default:
		fmt.Fprintln(out, "fuck")
	}
}


Measured memory_bytes: 768
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
using namespace std;
int main(){
    int N;
    cin >> N;
    vector<int> vc(N);
    for(int i=0;i<N;i++)    cin >> vc[i];
    sort(vc.begin(),vc.end());
    cout << vc[N-1]-vc[0] << endl;
}

Measured memory_bytes: 256
#looked ans

n,k = map(int,input().split())
s = input()
#入力
cnt = 0
if s[0] == '0':
    cnt += 1
for i in range(1,n):
    if s[i-1] == '1' and s[i] == '0':
        cnt += 1
##切り替わるところで＋1
if cnt <= k:
    print(n)
    #切り替わるところが動かす回数より少ない場合n(自明)
else:
    one_left,one_right = [0],[]
    #
    for i in range(1,n):
        if s[i-1] == '0' and s[i] == '1':
            one_left.append(i)
        if s[i-1] == '1' and s[i] == '0':
            one_right.append(i)
    #01 の時右に加える10の時左に加える
    #切り替えの時の配列の番号を加える
    one_right.append(n)
    #nはとりあえず右
    if s[0] == '1':
        one_right.pop(0)
    if s[-1] == '1':
        one_left.pop(-1)
    #最初の人が逆立ちしているなら右の切り替えの最初はなし
    #最後の人が逆立ちしているなら左の切り替えの最後はなし
    #print(one_right,'r')
    #print(one_left,'l')

    ans = 0
    #ans 01,10の切り替えの少ないほうでloopを回す
    for i in range(min(len(one_left),len(one_right)-k+1)):
        ans = max(ans,one_right[i+k-1]-one_left[i])
        #ans は　ある点までの個数-フラグの開始点までの個数の最大値
    print(ans)



Measured memory_bytes: 7208
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(v) v.begin(), v.end()
typedef long long ll;

#include <bits/stdc++.h>
using namespace std;

int main() {
  ll a,b,q;
  cin>>a>>b>>q;
  
  vector<ll> A(a),B(b),X(q);
  rep(i,a) cin>>A[i];
  rep(i,b) cin>>B[i];
  rep(i,q) cin>>X[i];
  
  vector<ll> An(a),Bn(b);
  rep(i,a){
    auto itr=upper_bound(ALL(B),A[i]);
    if(itr==B.begin()) An[i]=B[0]-A[i];
    else if(itr==B.end()) An[i]=A[i]-B[b-1];
    else An[i]=min(*itr-A[i],A[i]-*(itr-1));
  }
  rep(i,b){
    auto itr=upper_bound(ALL(A),B[i]);
    if(itr==A.begin()) Bn[i]=A[0]-B[i];
    else if(itr==A.end()) Bn[i]=B[i]-A[a-1];
    else Bn[i]=min(*itr-B[i],B[i]-*(itr-1));
  }
  
  ll am,bm,n1,n2;
  rep(i,q){
    auto itr1=upper_bound(ALL(A),X[i]);
    if(itr1==A.begin()) am=A[0]+An[0]-X[i];
    else if(itr1==A.end()) am=X[i]-A[a-1]+An[a-1];
    else{
      n1=itr1-A.begin();
      am=min(A[n1]-X[i]+An[n1],X[i]-A[n1-1]+An[n1-1]);
    }
    
    auto itr2=upper_bound(ALL(B),X[i]);
    if(itr2==B.begin()) bm=B[0]+Bn[0]-X[i];
    else if(itr2==B.end()) bm=X[i]-B[b-1]+Bn[b-1];
    else{
      n2=itr2-B.begin();
      bm=min(B[n2]-X[i]+Bn[n2],X[i]-B[n2-1]+Bn[n2-1]);
    }
    
    cout<<min(am,bm)<<endl;
  }

  return 0;
}

Measured memory_bytes: 7176
#include <bits/stdc++.h>
using namespace std;
using LL = long long;
using PII = pair<int, int>;
#define ST first
#define ND second
#define EB emplace_back
#define FOR(i, l, r) for(int i = (l); i <= (r); ++i)
#define REP(i, n) FOR(i, 0, (n) - 1)
template<class T> int size(T &&x) {
	return int(x.size());
}
#ifdef DEBUG
template<class A, class B> ostream& operator<<(ostream &out, const pair<A, B> &p) {
	return out << '(' << p.first << ", " << p.second << ')';
}
template<class T> auto operator<<(ostream &out, T &&x) -> decltype(x.begin(), out) {
	out << '{';
	for(auto it = x.begin(); it != x.end(); ++it)
		out << *it << (it == --x.end() ? "" : ", ");
	return out << '}';
}
void dump() {}
template<class T, class... Args> void dump(T &&x, Args... args) {
	cerr << x << ";  ";
	dump(args...);
}
  const int seed = 1;
  struct Nl{~Nl(){cerr << '\n';}};
# define debug(x...) cerr << (#x != "" ? #x ":  " : ""), dump(x), Nl(), cerr
#else
  const int seed = chrono::system_clock::now().time_since_epoch().count();
# define debug(...) 0 && cerr
#endif
mt19937_64 rng(seed);
int rd(int l, int r) {
	return uniform_int_distribution<int>(l, r)(rng);
}

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

	int n, x;
	cin >> n >> x;
	int sum = 0;
	REP(i, n)
	{
		int l;
		cin >> l;
		sum += l;
		if(sum > x)
		{
			cout << i + 1 << "\n";
			return 0;
		}
	}

	cout << n + 1 << "\n";
}


Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))
flag = 1
swap_counter = 0

while flag:
    flag = 0
    for j in range(N-1, 0, -1):
        if A[j - 1] > A[j]:
            A[j - 1], A[j] = A[j], A[j - 1]
            swap_counter += 1
            flag = 1
A_str = [str(a) for a in A]
result = ' '.join(A_str)
print(result)
print(swap_counter)


Measured memory_bytes: 5604
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int K = sc.nextInt();
        int[] values = new int[N];
        for (int i = 0; i < N; i++) {
            values[i] = sc.nextInt();
        }
        sc.close();

        Arrays.sort(values);
        int allValues = 0;
        for (int i = 0; i < K; i++) {
            allValues += values[i];
        }
        System.out.println(allValues);

    }
}


Measured memory_bytes: 38424
if __name__ == '__main__':
	N = int(input())
	S = input()
	L = 0
	R = N-1
	count = 0
	if S.count('W') == 0 or S.count('R') == 0:
		R = -1
	while(L < R):
		while(S[L] == 'R'):
			L += 1
		while(S[R] == 'W'):
			R -= 1
		if L > R:
			break
		L += 1
		R -= 1
		count += 1

	print(count)

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

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

int main(void) {
    int n;
    bool flg = false;

    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n;
    REP(i, n / 4 + 1) {
        REP(j, n / 7 + 1) {
            if (4 * i + 7 * j == n) {
                flg = true;
            }
        }
    }

    cout << (flg? "Yes" : "No") << "\n";
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ok() puts(ok?"Yes":"No");
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<vi> vvi;
typedef vector<ii> vii;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef set<int> si;
typedef map<string, int> msi;
typedef greater<int> gt;
typedef priority_queue<int, vector<int>, gt> minq;
typedef long long ll;
typedef pair<ll,ll> pll;
const ll LINF = 1e18L + 1;
const int INF = 1e9 + 1;
//clang++ -std=c++11 -stdlib=libc++ 

int main() {
  string s, t; cin >> s >>t;
  int ans = 0;
  rep(i,3) {
    if (s[i] == t[i]) ans++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
from copy import deepcopy
from sys import exit,setrecursionlimit
import math
from collections import defaultdict,Counter,deque
from fractions import Fraction as frac
import fractions
from functools import reduce
from operator import mul
import bisect
import sys
import logging
import heapq
import itertools

logging.basicConfig(level=logging.ERROR)

input = sys.stdin.readline

setrecursionlimit(1000000)


def main():
	n = int(input())
	h = list(map(int,input().split()))
	mx = 0
	now = 0
	for i in range(1,n):
		if(h[i-1] >= h[i]):
			now+=1
		else:
			if(mx<now):
				mx=now
			now=0
	if(mx<now):
		mx  = now
	print(mx)

def factorization(n):
	if n<2:
		return []

	arr = []
	temp = n
	for i in range(2, int(-(-n**0.5//1))+1):
		if temp%i==0:
			cnt=0
			while temp%i==0:
				cnt+=1
				temp //= i
			arr.append([i, cnt])

	if temp!=1:
		arr.append([temp, 1])

	if arr==[]:
		arr.append([n, 1])

	return arr

def cmb(n,r):
    r = min(n-r,r)
    if r == 0: return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1,r + 1))
    return over // under

def zip(a):
	mae = a[0]
	ziparray = [mae]
	for i in range(1,len(a)):
		if(mae != a[i]):
			ziparray.append(a[i])
			mae = a[i]
	return ziparray

def is_prime(n):
	if n < 2: return False

	for k in range(2, int(math.sqrt(n)) + 1):
		if n % k == 0:
			return False

	return True

def list_replace(n,f,t):
	return [t if i==f else i for i in n]

def base_10_to_n(X, n):
	X_dumy = X
	out = ''
	while X_dumy>0:
		out = str(X_dumy%n)+out
		X_dumy = int(X_dumy/n)
	if(out == ''): return '0'
	return out

def gcd(numbers):
	return reduce(fractions.gcd, numbers)

def lcm(numbers):
    return reduce(lcm_base, numbers, 1)

def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)

class Queue():
	def __init__(self):
		self.q = deque([])
	def push(self,i):
		self.q.append(i)
	def pop(self):
		return self.q.popleft()
	def size(self):
		return len(self.q)
	def debug(self):
		return self.q

class Stack():
	def __init__(self):
		self.q = []
	def push(self,i):
		self.q.append(i)
	def pop(self):
		return self.q.pop()
	def size(self):
		return len(self.q)
	def debug(self):
		return self.q

class graph():
	def __init__(self):
		self.graph = defaultdict(list)
	def addnode(self,l):
		f,t = l[0],l[1]
		self.graph[f].append(t)
		self.graph[t].append(f)
	def rmnode(self,l):
		f,t = l[0],l[1]
		self.graph[f].remove(t)
		self.graph[t].remove(f)
	def linked(self,f):
		return self.graph[f]

class dgraph():
	def __init__(self):
		self.graph = defaultdict(set)
	def addnode(self,l):
		f,t = l[0],l[1]
		self.graph[f].append(t)
	def rmnode(self,l):
		f,t = l[0],l[1]
		self.graph[f].remove(t)
	def linked(self,f):
		return self.graph[f]

class PriorityQueue():
	def __init__(self):
		self.queue = []
	def push(self,i):
		heapq.heappush(self.queue,-i)
	def pop(self):
		return -1 * heapq.heappop(self.queue)
	def sum(self):
		return -sum(self.queue)

main()


Measured memory_bytes: 89196
#include<vector>
#include<iostream>
#include<stdio.h>
#include<stdlib.h>
#include <iostream>
#include <algorithm>
#include <map>
#include <cmath>
#include<queue>
#include <sstream>
#include <set>
#include<stack>

const long long MOD = 1000000007;
using namespace std;
typedef long long llong;

//int isalpha(char ch): ch がアルファベットなら true を返す
//int isdigit(char ch): ch が数字なら true を返す
//int islower(char ch): ch が小文字なら true を返す
//int isupper(char ch): ch が大文字なら true を返す
//int tolower(char ch): ch の小文字を返す
//int toupper(char ch): ch の大文字を返す

//string型
//size()	文字数を返す
//Insert()	（指定した場所に）文字・文字列を挿入する
//erase()	（指定した場所の）文字・文字列を削除する
//clear()	すべての文字を削除する
//substr()	文字列の（指定した）部分文字列を返す
//replace()	（指定した）部分文字列を新しい文字列に置換する
//c_str()変換
//文字列の比較は、<=や==などを使え
//replace関数を使い、簡単に文字列を置換
//リバース関数：reverse(str.begin(), str.end());
//map<type, type> dict;で宣言
//グラフ理論用変数
//vector<vector<llong> > graph(N);

//ソート
//降順sort(v.begin(), v.end(), std::greater<Type>());

//大文字から小文字へんかん
//w[i] = w[i]-'A'+'a';

//vector
//assignメソッド　引数：サイズ、値
//与えられたサイズと値でvectorを初期化する

//queueクラス
//find()次に取り出す値の表示をする。
//pop()値を取り出す。戻り値はなし
//push()キューに値をプッシュする

//priority_queueクラス

//切り上げ
//ceil
//floor

long long mod(long long val, long long m) {
  long long res = val % m;
  if (res < 0) res += m;
  return res;
}

int main(){
    llong N;
    cin >> N;
    vector<llong> A(N,0);
    vector<llong> S(N+1,0);
    llong ans=0;

    for(int i=0; i<N; i++){
        cin >> A[i];
    }
    for(int i=0; i<N; i++){
        S[i+1] = S[i]%MOD + A[i]%MOD;
    }
    for(int i=0; i<N; i++){
        ans = ans%MOD + ((mod((S[N]%MOD) - (S[i+1]%MOD), MOD)%MOD)*(A[i]%MOD))%MOD;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 6052
S = int(input())
mod = 10**9 + 7

if S < 3:
    print(0)
else:
    dp = [0] * (S+1)
    dp[0] = 1
    dp[1] = 0
    dp[2] = 0
    for i in range(3, S+1):
        dp[i] = (dp[i-1] + dp[i-3]) % mod
    print(dp[-1])

Measured memory_bytes: 9180
import sys
N = int(input())

upper = [int(_) for _ in input().split()]
lower = [int(_) for _ in input().split()]

if N == 1:
    print(upper[0] + lower[0])
    sys.exit()

lower_sum_sum = sum(lower)
upper_sum = [upper[0]] + [0] * (N - 1)
lower_sum = [lower_sum_sum] + [0] * (N - 1)
ans_list = [0] * N

for i in range(1, N):
    upper_sum[i] = upper_sum[i - 1] + upper[i]
    lower_sum[i] = lower_sum[i - 1] - lower[i - 1]
for i in range(N):
    ans_list[i] = upper_sum[i] + lower_sum[i]
print(max(ans_list))

Measured memory_bytes: 3064
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;

public class Main {

    public static void main(String[] args) {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        br.lines().forEach(s -> {
            List<Integer> list = Arrays.stream(s.split(" "))
                    .map(Integer::parseInt)
                    .collect(Collectors.toList());

            int h = list.get(0);
            int w = list.get(1);

            if (h == 0 && w == 0) {
                return;
            }

            for (int i = 0; i < h; i++) {
                if (i == 0 || i == h - 1) {
                    for (int j = 0; j < w; j++) {
                        System.out.print("#");
                    }
                    System.out.println();
                } else {
                    for (int j = 0; j < w; j++) {
                        if (j == 0 || j == w - 1) {
                            System.out.print("#");
                        } else {
                            System.out.print(".");
                        }
                    }
                    System.out.println();
                }
            }
            System.out.println();
        });
    }
}

Measured memory_bytes: 35008
#include <iostream>
#include <iomanip>
#include<math.h>
#include<list>
#include <algorithm>
#include<set>
#include<vector>
#include<math.h>
#include<map>
#include<string>
#include <numeric>
#include <queue>
#include <sstream>

using namespace std;
using ll = long long;
using vll = vector<long long>;
using sll = set<long long>;

template<typename T>
T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template<typename T>
T lcm(T a, T b) { return a / gcd(a, b) * b; }

template<typename T>
map<T, T> primeFactor(T n) {
	map<T, T> res;
	for (T i = 2; i * i <= n; ++i) {
		while (n % i == 0) {
			res[i] ++;
			n /= i;
		}
	}
	if (n != 1) res[n] = 1;
	return res;
}

template<typename T>
bool IsPrimeNumber(T num)
{
	if (num <= 2) return true;
	else if (num % 2 == 0) return false;

	double sqrtNum = sqrt(num);
	for (int i = 3; i <= sqrtNum; i += 2)
	{
		if (num % i == 0)
		{
			return false;
		}
	}

	return true;
}


#define in(x) cin >> x
#define out(x) cout << x
#define outn(x) cout << x << '\n'
#define outs(x) cout << x << ' '
#define rep(i,s,e) for(ll i=s;i<e;i++)
#define repeq(i,s,e) for(ll i=s;i<=e;i++)

int main() {
	ll n,ans=0,cntA=0,cntB=0,cntAB=0;
	in(n);
	vector<string> s(n);
	vector<char> tmp(2);
	rep(i, 0, n) {
		in(s[i]);
		rep(j, 0, s[i].size() - 1) {
			if (s[i][j + 1] == 'B') {
				if (s[i][j] == 'A') {
					ans++;
				}
				j++;
			}
			else if (s[i][j + 1] != 'A') {
				j++;
			}
		}
		tmp[0] = s[i][0];
		tmp[1] = s[i][s[i].size() - 1];
		if (tmp[1] == 'A') {
			cntA++;
			if (tmp[0] == 'B') {
				cntAB++;
			}
		}
		if (tmp[0] == 'B') {
			cntB++;
		}
	}
	ans += min(cntA, cntB);
	if (cntAB == cntA && cntAB== cntB && cntAB>0) {
		ans--;
	}
	outn(ans);

	return 0;

}


Measured memory_bytes: 768
#include<iostream>
using namespace std;
int main ()
{  char s[10];
    scanf("%s",s+1);
    int ans=0;
    if(s[1]=='R'||s[2]=='R'||s[3]=='R') ans++;
    if(s[1]=='R'&&s[2]=='R') ans++;
    if(s[2]=='R'&&s[3]=='R') ans++;
    cout<<ans<<endl;
}

Measured memory_bytes: 3684
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>

using flt = double;
const flt eps = 1e-12, inf = 1e18, PI = acos(-1.0);
template<typename T>
inline T sqr(T x) {return x * x;}
inline flt cmp(flt a, flt b, flt e = eps) {
  return fabs(a - b) >= e + fabs(a) * e ? a - b : 0;
}
inline int sgn(flt x, flt e = eps) {return x < -e ? -1 : (x > e);}
inline flt fix(flt x, flt e = eps) {return cmp(x, 0, e);}

struct point {
  flt x, y;
  point(flt x = 0, flt y = 0): x(x), y(y) {}
  bool operator < (const point &rhs) const {
    return cmp(x, rhs.x) < 0 || (cmp(x, rhs.x) == 0 && cmp(y, rhs.y) < 0);
  }
  bool operator == (const point &rhs) const {
    return cmp(x, rhs.x) == 0 && cmp(y, rhs.y) == 0;
  }
  point operator + (const point &rhs) const {
    return point(x + rhs.x, y + rhs.y);
  }
  point operator - (const point &rhs) const {
    return point(x - rhs.x, y - rhs.y);
  }
  point operator * (const flt k) const {
    return point(x * k, y * k);
  }
  point operator / (const flt k) const {
    return point(x / k, y / k);
  }
  point operator ~ () const {// counter clockwise rotate 90 degree
    return point(-y, x);
  }
  flt dot(const point &rhs) const {
    return x * rhs.x + y * rhs.y;
  }
  flt det(const point &rhs) const {
    return x * rhs.y - y * rhs.x;
  }
  flt norm2() const {
    return x * x + y * y;
  }
  flt norm() const {
    return hypot(x, y);
  }
  point rot(flt a) const {// counter clockwise rotate A rad
    return point(x * cos(a) - y * sin(a), x * sin(a) + y * cos(a));
  }
  point rot(flt cosa, flt sina) const {// counter clockwise rotate using cos/sin
    return point(x * cosa - y * sina, x * sina + y * cosa);
  }
  point trunc(flt a = 1.0) const {
    return (*this) * (a / this->norm());
  }
};

// check if point O is on segment AB
bool on_segment(const point &A, const point &B, const point &O) {
  return sgn((A - O).det(B - O)) == 0 && sgn((A - O).dot(B - O)) <= 0;
}

// check if AB is parallel to CD
bool is_parallel(const point &A, const point &B, const point &C, const point &D) {
  return sgn((B - A).det(D - C)) == 0;
}

// check intersection of segments AB and CD
bool segment_intersect(const point &A, const point &B, const point &C, const point &D, point &res) {
  if (on_segment(A, B, C)) {res = C; return true;}
  if (on_segment(A, B, D)) {res = D; return true;}
  if (on_segment(C, D, A)) {res = A; return true;}
  if (on_segment(C, D, B)) {res = B; return true;}
  point AB(B - A), CD(D - C);
  if (sgn(AB.det(CD)) == 0) return false; // parallel
  int d1 = sgn(AB.det(C - A)) * sgn(AB.det(D - A));
  int d2 = sgn(CD.det(A - C)) * sgn(CD.det(B - C));
  res = A + AB * (CD.det(C - A) / CD.det(AB));
  return d1 < 0 && d2 < 0;
}

int main() {
  int q;
  scanf("%d", &q);
  for (int i = 0; i < q; ++i) {
    point A, B, C, D, O;
    scanf("%lf%lf%lf%lf", &A.x, &A.y, &B.x, &B.y);
    scanf("%lf%lf%lf%lf", &C.x, &C.y, &D.x, &D.y);
    if (segment_intersect(A, B, C, D, O)) puts("1");
    else puts("0");
  }
  return 0;
}

Measured memory_bytes: 2680
#include<iostream>
#include<vector>
#include<climits>
using namespace std;
int main()
{
    int n;
    cin>>n;
    vector<int> costs(n);
    for(int i=0; i<n; ++i)
    cin>>costs[i];
    vector<long long> dp(n+1,LLONG_MAX);
    dp[0] = 0;
    for(int i=1;i<n;++i)
    {
        for(int j=1;j<=2;++j)
        {
            if((i-j)<0) continue;
            dp[i] = min(dp[i],dp[i-j]+abs(costs[i]-costs[i-j]));
            
        }
    }
    cout<<dp[n-1]<<'\n';
}

Measured memory_bytes: 1408
module Main where
import Control.Monad
import Control.Applicative
import Data.Maybe
import Data.List
import qualified Text.Printf
import qualified Data.ByteString.Char8 as BC
import qualified Data.ByteString as BC

import qualified Data.Set as Set

------------------------------------------

dir = zip [1, 1, 0, -1, -1, -1, 0, 1] [0, 1, 1, 1, 0, -1, -1, -1]

main :: IO ()
main = do
  [h, w] <- readInts
  raw <- zipWith (\a -> map (\(b, c) -> (a, b, c))) [0..] <$> replicateM h (getLine >>= return . zip [0..])
  let s = map (\(a,b,_) -> (a, b)) $ concat $ map (filter (\(_,_,c) -> c == '#')) raw
      m = Set.fromList s
      out x y
        | x >= h = return ()
        | y >= w = putStrLn "" >> out (x+1) 0
        | otherwise = do
          if Set.member (x, y) m then putStr "#"
          else do
            let np = zipWith (\(dx, dy) (x, y) -> (x+dx, y+dy)) dir (repeat (x, y))
                ans = length $ filter (flip Set.member m) np
            putStr $ show ans
          out x (y+1)
  out 0 0
  return ()


------------------------------------------

{- Int input -}

parseInt :: BC.ByteString -> Int
parseInt = fst . fromJust . BC.readInt

parseInts :: BC.ByteString -> [Int]
parseInts = map parseInt <$> BC.words

readInt :: IO Int
readInt = parseInt <$> BC.getLine

readInts :: IO [Int]
readInts = parseInts <$> BC.getLine

{- Double Formatting -}

doubleFmt :: Double -> String
doubleFmt = Text.Printf.printf "%.12f"


Measured memory_bytes: 1404
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>

using std::cin;
using std::cout;
using std::endl;

using std::string;
using std::pair;

using std::vector;
using std::sort;

int main(){
    int N;
    cin >> N;
    vector<string> s(N);
    for(int i=0;i<N;i++){
        cin >> s[i];
    }
    sort(s.begin(),s.end());

    int M;
    cin >> M;
    vector<string> t(M);
    for(int i=0;i<M;i++){
        cin >> t[i];
    }

    int x=0;
    for(int i=0;i<N;){
        int red=std::count(s.begin(),s.end(),s[i]);
        int blue=std::count(t.begin(),t.end(),s[i]);
        x=std::max(x,red-blue);
        i+=red;
    }

    cout << x << endl;
    return 0;
}



Measured memory_bytes: 256
import java.util.*;
import java.io.*;

public class Main{
	static PrintWriter out;
	static StringBuilder sb;
	static int mod = 998244353;
	static int inf = (int) 1e8;
	static int[] col;
	static int n, s, k;
	static ArrayList<Integer>[] ad;
	static long[][] memo;
	static ArrayList<Integer> h;
	static char[][] grid;
	static int[] a;
	static boolean f;

	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		out = new PrintWriter(System.out);
		n = sc.nextInt();
		s = sc.nextInt();
		a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = sc.nextInt();
		memo = new long[n + 1][s + 1];
		// for (long[] kk : memo)
		// Arrays.fill(kk, -1);
		memo[n][0] = 1;
		long x = modPow(2, mod - 2);
		for (int i = n - 1; i >= 0; i--) {
			for (int sum = 0; sum <= s; sum++) {
				long ans = memo[i + 1][sum];
				if (sum - a[i] >= 0)
					ans = (ans + memo[i + 1][sum - a[i]] * x % mod) % mod;
				memo[i][sum]=ans;
			}
		}
		System.out.println(modPow(2, n) * memo[0][s] % mod);
		out.flush();
	}

	static long modPow(long a, long e)

	{
		long res = 1;
		while (e > 0) {
			if ((e & 1) == 1)
				res = (res * a) % mod;
			a = (a * a) % mod;
			e >>= 1;
		}
		return res;
	}

	static long dp(int i, int sum) {
		if (sum < 0)
			return 0;
		if (i == n) {
			if (sum == 0)
				return 1;
			return 0;
		}
		if (memo[i][sum] != -1)
			return memo[i][sum];
		long ans = dp(i + 1, sum);
		ans = (ans + dp(i + 1, sum - a[i]) * modPow(2, mod - 2) % mod) % mod;
		return memo[i][sum] = ans;
	}

	static class Scanner {
		StringTokenizer st;
		BufferedReader br;

		public Scanner(InputStream system) {
			br = new BufferedReader(new InputStreamReader(system));
		}

		public Scanner(String file) throws Exception {
			br = new BufferedReader(new FileReader(file));
		}

		public String next() throws IOException {
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}

		public String nextLine() throws IOException {
			return br.readLine();
		}

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

		public double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}

		public char nextChar() throws IOException {
			return next().charAt(0);
		}

		public Long nextLong() throws IOException {
			return Long.parseLong(next());
		}

		public int[] nextArrInt(int n) throws IOException {
			int[] a = new int[n];
			for (int i = 0; i < n; i++)
				a[i] = nextInt();
			return a;
		}

		public long[] nextArrLong(int n) throws IOException {
			long[] a = new long[n];
			for (int i = 0; i < n; i++)
				a[i] = nextLong();
			return a;
		}

		public boolean ready() throws IOException {
			return br.ready();
		}

		public void waitForInput() throws InterruptedException {
			Thread.sleep(3000);
		}
	}
}

Measured memory_bytes: 96720
#include<bits/stdc++.h>
 
using namespace std ;
 
typedef double D ;
typedef long long ll ;
typedef long double ld ;
typedef unsigned int ui ;
typedef unsigned long long ull ;
 
# define F first
# define S second
# define R return
# define C continue 
# define pb push_back 
# define pf push_front
# define mp make_pair
 
# define all(v) (v).begin() , (v).end()
# define allrev(v) (v).rbegin() , (v).rend()
# define allcomp(v) v.begin() , v.end() , comp
# define allrevcomp(v) v.rbegin() , v.rend() , comp
 
# define vi vector <int>
# define vb vector <bool>
# define vll vector <ll>
# define vs vector <string>
 
# define vvi vector < vector < int > >
# define vvb vector < vector < bool > >
# define vvc vector < vector < char > >
# define vvll vector < vector < ll > >
# define vvd vector < vector < D > >
# define vvld vector < vector < ld > >
 
# define pii pair < int , int >
# define pll pair < ll , ll >
# define pld pair < ld , ld >
# define pDD pair < D , D >
 
# define vpld vector < pld >
# define vpii vector < pii >
# define vpll vector < pll >
# define vpDD vector < pDD >
# define vvpii vector < vector < pii > >
 
# define Fi(i,L,R) for (int i = L ; i <= R ; i++)
# define Fd(i,R,L) for (int i = R ; i >= L ; i--)
# define fast ios_base :: sync_with_stdio (false) ; cin.tie(0) ; cout.tie(0)
 
# define dist(a,b,p,q) sqrt((p-a)*(p-a) + (q-b)*(q-b))
 
#define inf INT_MAX
const ld PI = 3.1415926535897932384626 ;
const ll MOD = 1e9 + 7 ;
 
////////////////////////////////////////////////////////////////////////////////////////////////////////////////

void solve (int test_case)
{
	int x , y , z ;
	cin >> x >> y >> z ;
	cout << z << ' ' << x << ' ' << y ;
}
 
int main()
{
	//freopen ("input.txt","r",stdin) ;
	//freopen ("output.txt","w",stdout) ;
	fast ;
	int tc = 1 ;
//	cin >> tc ;
	for(int t = 1 ; t <= tc ; ++t)
	{
		solve(t) ;
	}
	return 0 ;
}

Measured memory_bytes: 256
import java.util.Scanner;

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

        if(k==1){
            System.out.println(x);
        }else {
            for (int i = x-(k-1); i<=x+(k-1);i++){
                System.out.println(i);

            }
        }
    }
}


Measured memory_bytes: 21844
#include<stdio.h>
#define N 45
int Fib[N];

int F(int n){
  if(n==0||n==1)return Fib[n]=1;
  if(Fib[n]!=0)return Fib[n];
  return Fib[n]=F(n-1)+F(n-2);
}

int main(){
  int n,i;
  for(i=0;i<N;i++)Fib[i]=0;
  scanf("%d",&n);
  printf("%d\n",F(n));
  return 0;
}




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

#define      ll     long long int

int main()
{
    int n, i, j, k, s = 0;
    cin >> n;
    map<int, int> mp;
    map<int, int>::iterator it;
    for (i = 1; i <= n; i++) {
        cin >> j;
        mp[j]++;
    }
    for (it = mp.begin(); it != mp.end(); it++) {
        j = (*it).first;
        k = (*it).second;
        if (j == k) continue;
        else if (j > k) {
            s += k;
        }
        else {
            s += (k - j);
        }
    }
    cout << s << '\n';
    return 0;
}


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

using PP = pair<int, int>;

int n, k;
long a[200000];
long p[200001];
int main() {
  cin >> n >> k;
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
    --a[i];
  }
  
  partial_sum(a, a + n, p + 1);
  for (int i = 0; i <= n; ++i) {
    p[i] %= k;
  }
  
  long sum = 0;
  map<int, vector<int>> mp;
  for (int i = 0; i <= n; ++i) {
    auto& v = mp[p[i]];
    auto it = lower_bound(v.begin(), v.end(), i - k + 1);
    sum += v.end() - it;
    v.push_back(i);
  }
  cout << sum << endl;
}

Measured memory_bytes: 25216
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vl = vector<ll>;
using vvl = vector<vl>;
using pl = pair<ll, ll>;
const ll INF = ll(1e18);
const ll mod = 998244353;
const double pi = acos(-1);
#define rep0(i,n) for(ll (i) = 0; (i) < (n); ++(i))
#define rrep0(i,n) for(ll (i) = (n) - 1; (i) >= 0; --(i))
#define rep1(i,n) for(ll (i) = 1; (i) <= (n); ++(i))
#define rrep1(i,n) for(ll (i) = (n); (i) >= 1; --(i))
#define nfor(i,a,b) for(ll (i) = (a); (i) < (b); ++(i))
#define rnfor(i,a,b) for(ll (i) = (b) - 1; (i) >= (a); --(i))
#define pf(x) cout << (x) << endl
#define all(x) (x).begin(),(x).end()
#define yes pf("Yes")
#define no pf("No")
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const int dx[8]={1,0,-1,0,1,1,-1,-1};
const int dy[8]={0,1,0,-1,1,-1,1,-1};

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

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

ll factorial(ll n){
    ll ans = 1;
    rep1(i, n){
        ans *= i;
        ans %= mod;
    }
    return ans;
}

ll power(ll a, ll b){
    ll ans = 1;
    a %= mod;
    while(b) {
        if(b & 1LL) ans = ans * a % mod;
        a = a * a % mod;
        b >>= 1;
    }
    return ans % mod;
}

vector<ll> FactorialInv, Factorial;

void init_combination(ll MAX){
    Factorial.resize(MAX + 1);
    FactorialInv.resize(MAX + 1);
    Factorial[0] = 1;
    for(int i = 1; i <= MAX; i++){
        Factorial[i] = Factorial[i - 1] * i % mod;
    }
    FactorialInv[MAX] = power(Factorial[MAX], mod - 2);
    for(ll i = MAX - 1; i >= 0; i--) {
        FactorialInv[i] = FactorialInv[i+1] * (i+1) % mod;
    }
}

ll combination(ll a, ll b){
    if((a == b) || (b == 0)){
        return 1;
    }
    if(a < b) return 0;
    if(b < 0) return 0;
    ll ans = Factorial[a] * FactorialInv[b] % mod;
    ans = ans * FactorialInv[a - b] % mod;
    return ans;
}

//modの値の確認をすること
int main(){
    char a;
    cin >> a;
    pf(a <= 90? "A":"a");
    return 0;
}


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

int N;
int A[210];

int main(){
    cin >> N;
    for(int i=0;i<N;i++) cin >>A[i];

    int k=0;

    while(true){
        bool exist_odd = false;
        for(int i =0;i<N;i++){
            if(A[i]%2!=0) exist_odd =true;
        }

        if(exist_odd) break;

        for(int i=0;i<N;i++){
            A[i]/=2;
        }
        k++;
    }
    cout <<k<<endl;
}

Measured memory_bytes: 256
import java.util.*;

import static java.lang.String.format;

/**
 * Created by Seiya on 2016/10/16.
 */
public class Main {


    public static void main(String[] args){
        Scanner scanner = new Scanner(System.in);
        int H, W;
        String[][] map = new String[26][26];

        H = scanner.nextInt();
        W = scanner.nextInt();

        for (int i = 0; i < H; i++) {
            for (int j = 0; j < W; j++) {
                map[i][j] = scanner.next();
            }
        }

        for (int i = 0; i < H; i++) {
            for (int j = 0; j < W; j++) {
                if("snuke".equals(map[i][j])){
                    System.out.println((char)('A' + j) + "" + (i+1) );
                };
            }
            //System.out.println();
        }

    }


}




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

int main(){
    int a,b,c,x,y;
    cin >> a >> b >> c >> x >> y;
    int ans = 0;

    if((a+b)>=2*c) ans += 2*c*min(x,y);
    else ans += (a+b)*min(x,y);

    if(y-x>0) ans += (y-x)*min(2*c,b);
    else if(x-y>0) ans += (x-y)*min(2*c,a);

    cout << ans << endl; 
}


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

int main(){
  int N;
  cin >> N;
  string S,T;
  cin >> S >> T;
  for(int i = 0; i < N; i++){
    cout << S[i] << T[i];
  }
  cout << endl;
}


Measured memory_bytes: 256
#https://atcoder.jp/contests/dp/tasks/dp_e
import copy
N,W = map(int,input().split())
Goods_List=[]
for i in range(N):
    Goods_List.append(list(map(int,input().split())))
 
Sum_Value = sum(map(lambda x:x[1],Goods_List))
dp = [[0] * (Sum_Value + 1) for i in range(N)]

for i in range(N):
    if i == 0:
        dp[i][Goods_List[i][1]] = Goods_List[i][0]
    else:
        dp[i] = copy.copy(dp[i-1])
        Valid_List = [k for k, x in enumerate(dp[i]) if x != 0]
        Valid_List.append(0)
        for j in Valid_List:
            if dp[i][j + Goods_List[i][1]] == 0:
                dp[i][j + Goods_List[i][1]] = dp[i-1][j] + Goods_List[i][0]
            else:
                dp[i][j + Goods_List[i][1]] = min(dp[i-1][j] + Goods_List[i][0],dp[i][j + Goods_List[i][1]])
        

for k in range(len(dp[-1])-1,0,-1):
    if (dp[-1][k] != 0) & (dp[-1][k] <= W):
        print(k)
        break
            


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

using namespace std;

int main(){
	int x;cin>>x;
	for(int a=-121;a<=121;a++)
		for(int b=-122;b<=a;b++)
			if(a*a*a*a*a-b*b*b*b*b==x){
				cout<<a<<' '<<b;
				return 0;
			}
	return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a,b;
  cin >> a >> b;
  if(b<10) a*=10;
  else if(b<100) a*=100;
  else a*=1000;
  int rab= sqrt(a+b);
  if(rab*rab==a+b) cout << "Yes" << endl;
  else cout << "No" << endl;
  
}

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

#define INF 1e18
#define int long long

signed main() {
    double w, h, x, y; cin >> w >> h >> x >> y;

    cout << setprecision(18) << (double)(w * h / 2.0) << endl;
    if(x == (w / 2) && y == (h / 2)) {
        cout << 1 << endl;
        return 0;
    }
    cout << 0 << endl;
    return 0;
}


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

using namespace std;

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

Measured memory_bytes: 256
#include<stdio.h>
int dp[1001][1001];
int main(void)
{
	int i,j,k,l;
	int w,n;
	int max;
	int a[1001],b[1001];
	
	scanf("%d",&w);
	l=1;
	while(w!=0){
		max=0;
	scanf("%d",&n);
		for(i=0;i<=n;i++){
			for(j=0;j<=w;j++){
				dp[i][j]=-1;
			}
		}
		for(i=0;i<n;i++){
			scanf("%d,%d",&a[i],&b[i]);
		}
		for(i=0;i<n;i++){
			dp[i][0]=0;	
			for(j=0;j<=w;j++){
				if(dp[i][j]!=-1){
					if(j+b[i]<=w && dp[i][j]+a[i]>=dp[i+1][j+b[i]]){
						dp[i+1][j+b[i]]=dp[i][j]+a[i];
					}
					if(dp[i+1][j]<dp[i][j]){
						dp[i+1][j]=dp[i][j];
					}
				}
			}
		}
		for(j=0;j<=w;j++){
			if(dp[n][j]>max){
				max=dp[n][j];
				k=j;
			}
		}
		printf("Case %d:\n",l);
		printf("%d\n%d\n",max,k);
		scanf("%d",&w);
		l++;
	}
	return 0;
}

Measured memory_bytes: 4948
import sys
import math
import itertools
import collections
import heapq
import re
import numpy as np
from functools import reduce

rr = lambda: sys.stdin.readline().rstrip()
rs = lambda: sys.stdin.readline().split()
ri = lambda: int(sys.stdin.readline())
rm = lambda: map(int, sys.stdin.readline().split())
rl = lambda: list(map(int, sys.stdin.readline().split()))
inf = float('inf')
mod = 10**9 + 7

s = rr()
if len(s) == len(set(s)):
  print('yes')
else:
  print('no')











Measured memory_bytes: 27140
// I'm a f*cking looser
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define fasino ios_base::sync_with_stdio(false); cin.tie(0);
#define asc(A) sort(A.begin(),A.end())
#define dsc(A) sort(A.begin(),A.end(),greater<ll>())
#define input(A,N) for(ll i=0;i<N;i++) cin>>A[i];
int main()
{
    fasino
    #ifndef ONLINE_JUDGE
    //freopen("input.txt", "r", stdin); 
    #endif
    ll a,b,n;
    cin>>a>>b>>n;
    ll maxi = INT32_MIN;
    // for(int i=;i<min(b,n);i++){
        // ll i=b;
        maxi = floor(double(a*(min(b,n)-1))/b)-(a*floor(double(min(b,n)-1)/b));
        ll k = floor(double(a*(min(b,n)))/b)-(a*floor(double(min(b,n))/b));
        maxi = max(maxi,k);
        // if(b==1){
        //     maxi = floor(double(a*n)/b)-(a*floor(double(n))/b);
        // }
        // maxi = max(maxi,m);
// 
    // }
    cout<<maxi;
    return 0;
}

Measured memory_bytes: 3652
/*
─────────────────────
───────────████████──
──────────███▄███████
──────────███████████
──────────███████████
──────────██████─────
──────────█████████──
█───────███████──────
██────████████████───
███──██████████──█───
███████████████──────
███████████████──────
─█████████████───────
──███████████────────
────████████─────────
─────███──██─────────
─────██────█─────────
─────█─────█─────────
─────██────██────────
─────────────────────
*/
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>

#define int long long
#define read(a) int a; cin >> a;
#define readb(a, b) int a, b; cin >> a >> b;
#define readc(a, b, c) int a, b, c; cin >> a >> b >> c;
#define reads(s) string s; cin >> s;
#define readarr(a, n) int a[(n) + 1] = {}; fori (i, 1, (n)) {cin >> a[i];}
#define readmat(a, n, m) int a[n + 1][m + 1] = {}; fori (i, 1, n) {fori (j, 1, m) cin >> a[i][j];}

#define print(a) cout << a << endl;
#define printarr(a, n) fori (i, 1, n) cout << a[i] << " "; cout << endl;
#define printv(v) for (int i: v) cout << i << " "; cout << endl;
#define printmat(a, n, m) fori (i, 1, n) {fori (j, 1, m) cout << a[i][j] << " "; cout << endl;} cout << endl;
#define all(v) v.begin(), v.end()
#define sz(s) (int)(s.size())
#define pb push_back
#define fi first
#define se second
#define rz resize
#define fori(i, a, b) for (int i = (a); i <= (b); i++)
#define ford(i, a, b) for (int i = (a); i >= (b); i--)
#define endl '\n'
#define setprec(x) cout << fixed << setprecision(x)
 
using namespace std;
using namespace __gnu_pbds; 
 
typedef tree<long long,null_type,less<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef vector<pair <int, int>> vpi;
typedef vector < vector <int> > vvi;
 
const int INF = 4e18;
const int mod = 1e9+7; 

     
signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    //start from here

    string s, t;
    cin >> s >> t;

    int n = sz(s);

    bool flag = true;

    fori (i, 0, n-1) if(s[i] != t[i]) flag = false;

    if(flag) cout << "Yes";
    else cout << "No";

    return 0;
}


Measured memory_bytes: 3648
#include<stdio.h>
#include<string.h>
#define fo(i,a,b) for(int i=a;i<=b;i++)
#define fd(i,a,b) for(int i=a;i>=b;i--)
int ans,n,l,r,q,a[110000];
char s[110000]; 
int main(){
	scanf("%d%d%s",&n,&q,s+1);
	fo(i,1,n-1) if (s[i]=='A'&&s[i+1]=='C') a[i]=1;
	fo(i,2,n-1) a[i]+=a[i-1];
	while (q--){
		scanf("%d%d",&l,&r);
		printf("%d\n",a[r-1]-a[l-1]);
	}
	return 0;
}

Measured memory_bytes: 1280
#include<bits/stdc++.h>
using namespace std;
int main(){
    string a,b;
    cin >> a >> b;
    
    string c;
    for(int i=0;i<a.size();i++){
        c.push_back(a.at(i));
    }
    for(int i=0;i<b.size();i++){
        c.push_back(b.at(i));
    }
    int d=0;
    int e=1;
    for(int i=c.size()-1;i>=0;i--){
        d += (c.at(i)-'0')*e;
        e *= 10;
    }
    for(int i=2;i<d;i++){
        if(i*i==d){
            cout << "Yes" << endl;
            goto Exit;
        }
    }
    cout << "No" << endl;
Exit:
    ;
}


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

int main(){
	LL H,W;cin >> H >> W;
	LL ans = 0;
	LL tmp;
	if(H == 1||W == 1){
		cout << 1 << endl;
		return 0;
	}
	tmp = H/2;
	ans += tmp * W;
	if(H%2==1){
	tmp = (W+1)/2;
	ans += tmp;
	}
	cout << ans << endl;
}










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

#define ll long long 
#define ull unsigned long long
#define all(c) c.begin(),c.end()
#define pb push_back

const ll INF = 1e9+5;

using namespace std;

int main(){
	int n;
	cin >> n;
	vector<int>a(n+1),b(n+1),c(n+1);
	for(int i = 1 ; i <= n ;++i ){
		cin >> a[i] >> b[i] >> c[i];
	}
	ll dp[n+1][3];
	a[0]=b[0]=c[0]=0;
	dp[0][0]=dp[0][1]=dp[0][2]=0;
	for(int i = 1 ; i <= n ; ++i){
		dp[i][0]=a[i]+max(dp[i-1][1],dp[i-1][2]);
		dp[i][1]=b[i]+max(dp[i-1][0],dp[i-1][2]);
		dp[i][2]=c[i]+max(dp[i-1][1],dp[i-1][0]);
	}

	cout << max(dp[n][1],max(dp[n][0],dp[n][2])) << endl;
	return 0;
}

Measured memory_bytes: 3712
/**
 * Author : RDP
 * There are no two words in the English language more harmful than "good job".
 * 1729 ;)
**/
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cctype>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <queue>
#include <stack>
#include <algorithm>
#include <functional>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <numeric>
using namespace std;
using ll = long long;
#define endl '\n'
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) 
{
  cerr << " " << to_string(H);
  debug_out(T...);
}
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#define FAST_IO ios::sync_with_stdio(0); std::cin.tie(0); std::cout.tie(0);
#define bp(x) __builtin_popcount(x)
#define zf(x) __builtin_clz(x)
#define zl(x) __builtin_ctz(x)
#define par(x) __bultin_parity(x)
#define all(x) (x).begin(), (x).end()
/* **************************************************************************************** */
const ll MOD= 1e9 + 7;
ll power_modm(ll x, ll y)  
{  
    ll res = 1;
    x = x % MOD; 
    if (x == 0) 
        return 0;
    while (y > 0)  
    {  
        if (y & 1)  
            res = (res * x) % MOD; 
        y = y >> 1;
        x = (x * x) % MOD;  
    }  
    return res;  
}
int fact_modm(ll n) 
{ 
    if(n == 0)
        return 1;
    if(n == 1)
        return 1;
    if (n >= MOD) 
        return 0; 
  
    ll result = 1; 
    for (ll i = 1; i <= n; i++) 
        result = (result * i) % MOD; 
  
    return result; 
} 
void test_case()
{
    ll n, ans;
    cin >> n;
    ans = power_modm(10, n) - (2 * power_modm(9, n) )% MOD + power_modm(8, n) + MOD;
    cout <<ans%MOD;
    return ;
}
int main()
{
	FAST_IO
    test_case();
	return 0;
}



Measured memory_bytes: 3648
import math
a,b,c = map(float,input().split())
S = a * b * math.sin(2*math.pi*c/360) /2
L = a+b+ math.sqrt(a*a + b*b - 2*a*b*math.cos(2*math.pi*c/360))
h = b * math.sin(2*math.pi*c/360)
print(S)
print(L)
print(h)


Measured memory_bytes: 5692
stdin = open(0).read().rstrip().split('\n')
N, K, Q = list(map(int,stdin[0].split()))
A = list(map(int,stdin[1:]))
ans = [K-Q]*N
for i in range(Q):
    ans[A[i]-1]+=1
for j in range(N):
    if ans[j]>0:print('Yes')
    else:print('No')

Measured memory_bytes: 16896