akhauriyash/Code-Regression huggingface dataset:
use std::collections::*;
use std::cmp::*;

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!{
        n: usize,
        h: [i64; n],
    };

    let mut dp = vec![1 << 30; n];
    dp[0] = 0;

    for i in 1..n {
        dp[i] = min(dp[i], dp[i-1] +(h[i] - h[i-1]).abs());
        if i > 1 {
            dp[i] = min(dp[i], dp[i-2] + (h[i] - h[i-2]).abs());
        }
    }

    println!("{}", dp[n-1]);

}


Measured memory_bytes: 6396
// +build ignore
package main

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

func solve(sc *scanner, wr *bufio.Writer) int {
	N := sc.i()
	M := sc.i()
	X := sc.i()
	C := make([]int, N)
	A := make([][]int, N)
	for i := 0; i < N; i++ {
		C[i] = sc.i()
		A[i] = make([]int, M)
		for j := 0; j < M; j++ {
			A[i][j] = sc.i()
		}
	}

	ans := math.MaxInt64
	for s := 0; s < (1 << N); s++ {
		cost := 0
		LVs := make([]int, M)
		for i := 0; i < N; i++ {
			if (s>>i)&1 == 1 {
				cost += C[i]
				for j := 0; j < M; j++ {
					LVs[j] += A[i][j]
				}
			}
		}

		ok := true
		for j := 0; j < M; j++ {
			if LVs[j] < X {
				ok = false
				break
			}
		}

		if ok {
			if ans > cost {
				ans = cost
			}
		}
	}

	if ans == math.MaxInt64 {
		fmt.Println("-1")
	} else {
		fmt.Println(ans)
	}
	return 0
}

func main() {
	sc := newScanner(os.Stdin)
	wr := bufio.NewWriter(os.Stdout)
	ret := solve(sc, wr)
	wr.Flush()
	os.Exit(ret)
}

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

func newScanner(input io.Reader) *scanner {
	sc := bufio.NewScanner(input)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &scanner{sc}
}

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

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

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

func (s *scanner) bs() []byte {
	return []byte(s.s())
}

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

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


Measured memory_bytes: 2160
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;
	int m[1111];
	int used[111111]={};
	cin>>n;
	for(int i=0;i<n;i++)cin>>m[i];
	for(int i=0;i<n;i++){
		int t=0;
		for(int j=0;j<5;j++){
			if(j+i>=n)break;
			t+=m[i+j];
			used[t]=1;
			t*=10;
		}
	}
	for(int i=0;i<10001;i++){
		if(!used[i]){
			cout<<i<<endl;
			break;
		}
	}
	return 0;
}



Measured memory_bytes: 3540
# クエリが複数回与えられて、毎回のクエリに対する回答をする必要がある
# という時点で累積和を意識するべきだった……

# 競技中に一瞬思いついたが、10万の配列を作ったときにメモリが足りるかを懸念して避けてしまった
# 10万くらいなら余裕で足りるよ

# printしてみた配列の大きさ：
# 提出時の表示： URLを張る

N,Q =  map(int, input().split())
S = input()

cumsum = []
# cumsum[i] := (0-indexで)0文字目からi文字目までに含まれる部分列"AC"の個数
# (0-indexで)l文字目からr文字目までに含まれる部分列"AC"の個数は、cumsum[r] -cumsum[l]である
# l-1文字目とl文字目が"AC"になるケースも除外したいので、cumsum[l]を引くこと

cumsum.append(0)
summ = 0
for i in range(1,N):
	if S[i-1] == "A" and S[i] == "C":
		summ +=1
	cumsum.append(summ)

for _ in range(Q):
	left, right = map(int, input().split())
	left -= 1 # 1-indexから0-indexに変更する
	right -= 1
	print(cumsum[right] - cumsum[left])



Measured memory_bytes: 6104
#include<iostream>
#include <string>
using namespace std;
int main(){
  string a;
  cin >> a;
  if (a == "A"){
    cout << "T" << endl;
  } else if (a == "T"){
    cout << "A" << endl;
  } else if (a == "C"){
    cout << "G" << endl;
  } else if (a == "G"){
    cout << "C" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
###template###
import sys
def input(): return sys.stdin.readline().rstrip()
def mi(): return map(int, input().split())
###template###

N, A, B, C, D = mi()
#S[0~N-1]でアクセス
cells = input()

#全部0~N-1ベースにする
A -= 1
B -= 1
C -= 1
D -= 1

ans = '?'

goal = max(C,D)


rockcheck = 0 #直前が岩なら1
for i, cell in enumerate(cells):
  if i < A or goal < i: continue
  if rockcheck == 1 and cell == '#':
    ans = 'No'
    break
  elif cell == '#': rockcheck = 1
  else: rockcheck = 0

#C<Dならflag=0, D<Cならflag=1
if C < D: flag = 0
else: flag = 1

if ans == 'No':
  print('No')
  exit()
elif flag == 0: #C<Dならこの時点で勝ち確
  print('Yes')
  exit()
#そうでなければ戦いは続く

ans = 'No'
#C<Dの場合決着がついているので、ここからは必ずD<C
#かつ、##は無いことが保証されている
blankcheck = 0 #直前が.なら1, 直前が..なら2
for i, cell in enumerate(cells):
  if i < (B-1) or (D+1) < i: continue
  if cell == '.': blankcheck += 1
  else: blankcheck = 0
  if blankcheck == 3:
    ans = 'Yes'
    break

print(ans)


Measured memory_bytes: 41828
#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define dunk(a) cout << (a) << endl
const int INF = 2e9;
using namespace std;
using Graph = vector<vector<int>>;
typedef pair<int,int> P;
typedef long long ll;

int main(){
    ll n, k; cin >> n >> k;
    ll ans = k;

    rep(i,n-1) ans *= k-1;

    cout << ans << endl;
    
}



Measured memory_bytes: 384
import java.util.*; import java.io.*; import java.math.*;
public class Main{
	//Don't have to see. start------------------------------------------
	static class InputIterator{
		ArrayList<String> inputLine = new ArrayList<String>(1024);
		int index = 0; int max; String read;
		InputIterator(){
			BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
			try{
				while((read = br.readLine()) != null){
					inputLine.add(read);
				}
			}catch(IOException e){}
			max = inputLine.size();
		}
		boolean hasNext(){return (index < max);}
		String next(){
			if(hasNext()){
				return inputLine.get(index++);
			}else{
				throw new IndexOutOfBoundsException("There is no more input");
			}
		}
	}
	static HashMap<Integer, String> CONVSTR = new HashMap<Integer, String>();
	static InputIterator ii = new InputIterator();//This class cannot be used in reactive problem.
	static PrintWriter out = new PrintWriter(System.out);
	static void flush(){out.flush();}
	static void myout(Object t){out.println(t);}
	static void myerr(Object t){System.err.print("debug:");System.err.println(t);}
	static String next(){return ii.next();}
	static boolean hasNext(){return ii.hasNext();}
	static int nextInt(){return Integer.parseInt(next());}
	static long nextLong(){return Long.parseLong(next());}
	static double nextDouble(){return Double.parseDouble(next());}
	static ArrayList<String> nextStrArray(){return myconv(next(), 8);}
	static ArrayList<String> nextCharArray(){return myconv(next(), 0);}
	static ArrayList<Integer> nextIntArray(){
		ArrayList<String> input = nextStrArray(); ArrayList<Integer> ret = new ArrayList<Integer>(input.size());
		for(int i = 0; i < input.size(); i++){
			ret.add(Integer.parseInt(input.get(i)));
		}
		return ret;
	}
	static ArrayList<Long> nextLongArray(){
		ArrayList<String> input = nextStrArray(); ArrayList<Long> ret = new ArrayList<Long>(input.size());
		for(int i = 0; i < input.size(); i++){
			ret.add(Long.parseLong(input.get(i)));
		}
		return ret;
	}
	static String myconv(Object list, int no){//only join
		String joinString = CONVSTR.get(no);
		if(list instanceof String[]){
			return String.join(joinString, (String[])list);
		}else if(list instanceof ArrayList){
			return String.join(joinString, (ArrayList)list);
		}else{
			throw new ClassCastException("Don't join");
		}
	}
	static ArrayList<String> myconv(String str, int no){//only split
		String splitString = CONVSTR.get(no);
		return new ArrayList<String>(Arrays.asList(str.split(splitString)));
	}
	public static void main(String[] args){
		CONVSTR.put(8, " "); CONVSTR.put(9, "\n"); CONVSTR.put(0, "");
		solve();flush();
	}
	//Don't have to see. end------------------------------------------
	static void solve(){//Here is the main function
      int N = nextInt();
      ArrayList<String> s = nextCharArray();
      int now = 0;
      int max = 0;
      for(int i = 0; i < N; i++){
        now += (s.get(i).equals("I")) ? 1 : -1;
        max = Math.max(max, now);
      }
      myout(max);
	}
	//Method addition frame start


  
	//Method addition frame end
}


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

int main() {
  int N, K;
  cin >> N >> K;
  int grade = 0;
  int &n = N;
  
  while (true){
    n = N/K;
    grade ++;
    if(N == 0) break;
  }
  cout << grade << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
using namespace std;
#define REP(i, n) for(int i=0; i<(n); i++)
#define FOR(i, a, n) for(int i=0; i<(n); i++)

int main(){
  	char s;cin >> s;
  	string ans = s == 'a' || s == 'i' || s == 'u' || s == 'e' || s == 'o' ? "vowel" : "consonant";
  	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <utility>
#include <algorithm>
#include <cstdio>
#include <iomanip>
#include <queue>
#include <deque>
#include <stack>
#include <fstream>
#include <cmath>
#include <random>
#include <complex>
#include <functional>
#include <bitset>
#include <sstream>
#include <cassert>
#include <time.h>

#define ll int64_t
#define Rep(i, n) for (ll i = 0; i < n; i++)
using namespace std;
typedef vector<ll> vec;
typedef vector<vec> mat;

const ll inf = 1LL << 60;

template<class T> inline void chmin(T& a, T b) {
    if (a > b) {
        a = b;
    }
}
template<class T> inline void chmax(T& a, T b) {
    if (a < b) {
        a = b;
    }
}
void printvec (vec &v) {
    Rep (i, (ll)v.size()) {
        cout << v[i] << " \n"[i+1 == (ll)v.size()];
    }
}

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

    ll N;
    cin >> N;
    vec a(N);
    ll ans = 0;
    Rep (i, N) {
        cin >> a[i];
        if (i % 2 == 0 and a[i] % 2 == 1) ans++;
    }

    cout << ans << endl;
}

Measured memory_bytes: 3652
#include <stdio.h>
#include <stdlib.h>

int main(void) {

	int K, N;
	int* p;
	int* cum_sum;
	int emax = 0;
	scanf("%d %d\n", &N, &K);
	p = (int*)calloc(sizeof(int),N);
	cum_sum = (int*)calloc(sizeof(int),N);
	for (int i = 0; i < N; ++i) {
		scanf("%d", &p[i]);
	}

	cum_sum[0] = p[0];
	for (int i = 1; i < N; ++i) {
		cum_sum[i] += cum_sum[i-1] + p[i];
	}

	emax = cum_sum[K-1];
	for (int i = K; i < N; ++i){
		if (emax < cum_sum[i] - cum_sum[i-K]) emax = cum_sum[i] - cum_sum[i-K];
	}

	printf("%.12f\n",(emax+K)*0.5);
	free(p);
	free(cum_sum);
	return 0;
}

Measured memory_bytes: 1664
n = int(input())
li1 = list(map(int,input().split()))
li2 = list(map(int,input().split()))

ans = li1[0] + sum(li2)
tmp = li1[0] + sum(li2)
for i in range(n-1):
  tmp = tmp + li1[i+1] - li2[i]
  ans = max(tmp,ans)
print(ans)

Measured memory_bytes: 3064
def main():
    N = int(input())
    l = list(map(int, input().split()))
    ans = []
    sunuke = 0
    arai = sum(l)
    for i in range(N-1):
        sunuke += l[i]
        arai   -= l[i]
        ans.append(abs(sunuke-arai))
    print(min(ans))
if __name__ == '__main__':
    main()


Measured memory_bytes: 23800
/*ex2_3
    ueki takafumi*/
#include <stdio.h>
int main(void){
    //変数の定義(N:マス目の数、A:白色のマスの数)
    int N,A;
    //入力受け取り
    scanf("%d",&N);
    scanf("%d",&A);
    //黒色のマス目の数を計算する
    printf("%d\n",N*N-A);
    
    return 0;
}

Measured memory_bytes: 128
#include<stdio.h>
#include<algorithm>
using namespace std;
char in[110][110];
int dp[5100][5100];
int sum[110][110];
inline int rec(int r1,int r2,int c1,int c2){
	return sum[r2][c2]-sum[r1][c2]-sum[r2][c1]+sum[r1][c1];
}
int main(){
	int a,b;scanf("%d%d",&a,&b);
	for(int i=0;i<a;i++)scanf("%s",in[i]);
	for(int i=0;i<a;i++)for(int j=0;j<b;j++){
		if(in[i][j]=='o')sum[i+1][j+1]=1;
	}
	int r,c;
	for(int i=0;i<a;i++)for(int j=0;j<b;j++)if(in[i][j]=='E'){r=i;c=j;}
	for(int i=0;i<=a;i++){
		for(int j=0;j<b;j++)sum[i][j+1]+=sum[i][j];
	}
	for(int i=0;i<=b;i++){
		for(int j=0;j<a;j++)sum[j+1][i]+=sum[j][i];
	}
	int R=r+1;
	int C=c+1;
	for(int i=0;i<5100;i++)for(int j=0;j<5100;j++)dp[i][j]=-99999999;
	dp[0][0]=0;
	int ret=0;
	for(int i=0;i<R*(a-r);i++){
		for(int j=0;j<C*(b-c);j++){
			if(dp[i][j]<0)continue;
			ret=max(ret,dp[i][j]);
			int h1=r-i%R;
			int h2=r+i/R;
			h1=max(h1,i/R);
			h2=min(h2,a-1-i%R);
			int w1=c-j%C;
			int w2=c+j/C;
			w1=max(w1,j/C);
			w2=min(w2,b-1-j%C);
		//	printf("%d %d %d %d: %d %d %d %d %d\n",i/R,i%R,j/C,j%C,dp[i][j],h1,h2,w1,w2);
			if(i%R<R-1-i/R){
				dp[i+1][j]=max(dp[i+1][j],dp[i][j]+rec(r-i%R-1,r-i%R,w1,w2+1));
			}
			if(i/R<a-r-1-i%R){
				dp[i+R][j]=max(dp[i+R][j],dp[i][j]+rec(r+i/R+1,r+i/R+2,w1,w2+1));
			}
			if(j%C<C-1-j/C){
				dp[i][j+1]=max(dp[i][j+1],dp[i][j]+rec(h1,h2+1,c-j%C-1,c-j%C));
			}
			if(j/C<b-c-1-j%C){
				dp[i][j+C]=max(dp[i][j+C],dp[i][j]+rec(h1,h2+1,c+j/C+1,c+j/C+2));
			}
		}
	}
	printf("%d\n",ret);
}

Measured memory_bytes: 101888
#include <iostream>
#define MAXN 105
using namespace std;

int n, k, a[MAXN], dp[100005];
// dp[i] = 1 means the first player will win with optimal play, 0 otherwise

int main() {
	cin >> n >> k;
	for (int i=0; i<n; i++) {
		cin >> a[i];
	}

	for (int i=0; i<=k; i++) {
		bool canwin = false;
		for (int j=0; j<n; j++) {
			if (i - a[j] < 0) continue;
			if (dp[i - a[j]] == 0) {
				canwin = true;
				break;
			}
		}
		if (canwin) dp[i] = 1;
		else dp[i] = 0;
	}
	if (dp[k]) cout << "First\n";
	else cout << "Second\n";
}

Measured memory_bytes: 640
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<stack>
#include<queue>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<utility>
#include<set>
#include<unordered_set>
typedef long long int ll;
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<signed(n);i++)
#define EREP(i,n) for(int i=1;i<=signed(n);i++)
#define ALL(a) (a).begin(),(a).end()
using std::cout;
using std::vector;
using std::endl;
using std::cin;
using std::string;
using std::min;
using std::max;
//#define EVEL 1
#ifdef EVEL
#define DEB(X) cout << #X <<":" <<X<<" " ;
#define TF(f) f ? cout<<"true  " : cout<<"false ";
#define END cout<<"\n";
#else
#define DEB(X) {}
#define TF(f) {}
#define END {}
#endif
const ll MOD = 1000000007;
const ll INF = 9e9;
typedef std::pair<int,int> P;
struct edge {int to,cost;};
#define VMAX 100000
bool cmp(P a,P b){ return a.second < b.second;}
ll N,M,ans=0;
vector<P> S;
int main(){
    std::ios_base::sync_with_stdio(false);
    cin>>N>>M;
    S.resize(M);
    REP(i,M){
        cin>>S[i].first>>S[i].second;
    }
    sort(ALL(S),cmp);
    int t=0;
    REP(i,M){
        if(S[i].first>=t){
            t=S[i].second;
            ans++;
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 1024
n = int(input())
a = []
minArray = []

m = int(1e10)
for _ in range(n):
	x = int(input())
	minArray.append(m)
	m = min([m,x])
	a.append(x)
	
t = 0
ans = -int(1e10)
for i in reversed(range(1,n)):
	t = max([t,a[i]])
	ans = max(ans, t-minArray[i])

print(ans)



Measured memory_bytes: 15164
#include <bits/stdc++.h>
using namespace std;
#define int long long

const int MAX = 1000000;
const int MOD = 1000000007;

signed main() {
 int n;
 cin>>n;
    int a[n];
    for(int i=0;i<n;i++)cin>>a[i];
    for(int i=1;i<n;i++){
        if(a[i-1]>=a[i])break;
        if(i==n-1){
            cout<<1;
            return 0;
        }
    }
    if(n==1){
        cout<<1;
        return 0;
    }
    int ok=n,ng=1,mid,j;
    map<int,int> mp;
    while(abs(ok-ng)>1){
        mp.clear();
        mid=(ok+ng)/2;
        for(int i=1;i<n;i++){
            if(a[i-1]<a[i])continue;
            while(mp.size()>0&&mp.rbegin()->first>=a[i])mp.erase((next(mp.rbegin())).base());
            //mp.erase(mp.lower_bound(a[i]),mp.end());
            j=a[i]-1;
            mp[j]++;
            while(j>0&&mp[j]==mid){
                mp[j]=0;
                j--;
                mp[j]++;
            }
            if(mp[0]>=mid)break;
        }
        if(mp[0]>=mid)ng=mid;
        else ok=mid;
    }
    cout<<ok;
return 0;
}


Measured memory_bytes: 1792
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int bb = b;
		int count = 0;
		int c  = 0;
		while(bb > 0) {
			bb /= 10;
			count++;
		}
		for(int i = 0; i < count; i++) {
			a = a * 10;
		}
		c = a + b;
		if(Math.sqrt(c) % 1 == 0) {
			System.out.println("Yes");
			return;
		}
		else System.out.println("No");
		sc.close();
	}

}


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

int main(){
    int n;
    cin>>n;
    string s;
    set<string> a;
    rep(i,n)cin>>s,a.insert(s);
    cout<<a.size()<<endl;    
}


Measured memory_bytes: 19232
#include<bits/stdc++.h>
#include<iomanip>
#include<numeric>

using namespace std;
using ll = long long;
constexpr int mo = 1e9+7;
constexpr int  mod = mo;
constexpr ll inf = 1ll<<60;
vector<tuple<double,double,char>> v;
double area(double t){
    double xmi =inf, ymi = inf,xma = -inf,yma = -inf;
    for(auto a : v){
        double curx = get<0>(a),cury=get<1>(a);
        char c = get<2>(a);
        switch(c){
            case 'L':
                curx -= t;break;
            case 'R':
                curx += t;break;
            case 'U':
                cury += t;break;
            case 'D':
                cury -= t;break;
        }
        xmi = min(xmi,curx);
        xma = max(xma,curx);
        ymi = min(ymi,cury);
        yma = max(yma,cury);
    }
    return (xma - xmi)*(yma - ymi);
}
int main(){
    int n;
    cin>>n;
    for(int i=0;i<n;++i){
        double x,y;
        char c;
        cin>>x>>y>>c;
        v.emplace_back(x,y,c);
    }
    
    vector<double> turn;
    turn.emplace_back(0);
    double lmi,rmi,udmi;
    lmi = rmi = udmi = inf;
    for(int i=0;i<n;++i){
        if(get<2>(v[i]) == 'L') lmi = min(lmi,get<0>(v[i]));
        else if(get<2>(v[i]) == 'R') rmi = min(rmi,get<0>(v[i]));
        else udmi = min(udmi,get<0>(v[i]));
    }
    if(lmi < inf && rmi < inf)turn.push_back(abs(lmi - rmi)/2);
    if(lmi < inf && udmi < inf) turn.push_back(abs(lmi - udmi));
    if(rmi < inf && udmi < inf) turn.push_back(abs(rmi - udmi));
    
   double lma,rma,udma;
   lma= rma = udma = -inf;
   for(int i=0;i<n;++i){
        if(get<2>(v[i]) == 'L') lma = max(lma,get<0>(v[i]));
        else if(get<2>(v[i]) == 'R') rma = max(rma,get<0>(v[i]));
        else udma = max(udma,get<0>(v[i]));
    }
    if(lma >-inf && rma > -inf)turn.push_back(abs(lma - rma)/2);
    if(lma >- inf && udma > -inf) turn.push_back(abs(lma - udma));
    if(rma >-inf && udma > -inf) turn.push_back(abs(rma - udma));
    
    lmi = rmi = udmi = inf;
    for(int i=0;i<n;++i){
        if(get<2>(v[i]) == 'U') lmi = min(lmi,get<1>(v[i]));
        else if(get<2>(v[i]) == 'D') rmi = min(rmi,get<1>(v[i]));
        else udmi = min(udmi,get<1>(v[i]));
    }
    if(lmi < inf && rmi < inf)turn.push_back(abs(lmi - rmi)/2);
    if(lmi < inf && udmi < inf) turn.push_back(abs(lmi - udmi));
    if(rmi < inf && udmi < inf) turn.push_back(abs(rmi - udmi));
    
   lma= rma = udma = -inf;
   for(int i=0;i<n;++i){
        if(get<2>(v[i]) == 'U') lma = max(lma,get<1>(v[i]));
        else if(get<2>(v[i]) == 'D') rma = max(rma,get<1>(v[i]));
        else udma = max(udma,get<1>(v[i]));
    }
    if(lma >-inf && rma > -inf)turn.push_back(abs(lma - rma)/2);
    if(lma >- inf && udma > -inf) turn.push_back(abs(lma - udma));
    if(rma >-inf && udma > -inf) turn.push_back(abs(rma - udma));
       
    double ret = inf;
    sort(turn.begin(),turn.end());
    turn.erase(unique(turn.begin(),turn.end()),turn.end());
    for(auto t : turn){
        ret = min(ret,area(t));
    }
    cout <<fixed << setprecision(10) << ret << endl;
    return 0;
}



Measured memory_bytes: 4980
package main

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

var sc = bufio.NewScanner(os.Stdin)

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

func main() {
	line := nextLine()
	l := strings.Split(line, " ")
	N, _ := strconv.Atoi(l[0])
	Q, _ := strconv.Atoi(l[1])
	g := map[int][]int{}
	for i := 0; i < N-1; i++ {
		line = nextLine()
		l = strings.Split(line, " ")
		a, _ := strconv.Atoi(l[0])
		b, _ := strconv.Atoi(l[1])
		g[a] = append(g[a], b)
		g[b] = append(g[b], a)
	}
	w := map[int]uint64{}
	for i := 0; i < Q; i++ {
		line = nextLine()
		l = strings.Split(line, " ")
		p, _ := strconv.Atoi(l[0])
		x, _ := strconv.ParseInt(l[1], 10, 64)
		w[p] += uint64(x)
	}

	visited := map[int]bool{}
	ans := make([]uint64, N+1)
	stack := []int{}
	visited[1] = true
	stack = append(stack, 1)
	for len(stack) != 0 {
		v := stack[len(stack)-1]
		stack = stack[:len(stack)-1]
		ans[v] += w[v]
		for _, c := range g[v] {
			if !visited[c] {
				visited[c] = true
				stack = append(stack, c)
				ans[c] += ans[v]
			}
		}
	}
	for i, v := range ans {
		if i == 0 {
			continue
		}
		fmt.Print(v)
		if i != N {
			fmt.Print(" ")
		}
	}
	fmt.Println()
}


Measured memory_bytes: 48000
C = input()
alphabet = ["A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"]

count = 0
for i in alphabet:
    count += 1
    if (i.lower() == C):
        break

print(alphabet[count].lower())


Measured memory_bytes: 3060
package main

import (
  "fmt"
  "sort"
)

func main(){
  var N int
  fmt.Scan(&N)
  X := make([]int, N)
  for i:=0;i<N;i++{
    fmt.Scan(&X[i])
  }
  Y := make([]int,N)
  copy(Y,X)
  sort.Ints(X)
  // fmt.Println(X)
  // fmt.Println(Y)
  low := X[(N-1)/2]
  high := X[N/2]
  // fmt.Println(low,high)
  for i:=0;i<N;i++{
    if Y[i] <= low{
      fmt.Println(high)
    }else{
      fmt.Println(low)
    }
  }
}


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

    class Program
    {
        static void Main(string[] args)
        {
            int num = int.Parse(Console.ReadLine());
            string strInput = "";
            string[] strInputArray = null;
            string str = "";
            List<string> slist = new List<string>();
            List<string> hlist = new List<string>();
            List<string> clist = new List<string>();
            List<string> dlist = new List<string>();
            for (int i = 1; i <= num; i++)
            {
                strInput = Console.ReadLine();
                strInputArray = strInput.Split(' ');
                if (strInputArray[0].Equals("S"))
                {
                    slist.Add(strInputArray[1]);
                }
                else if (strInputArray[0].Equals("H"))
                {
                    hlist.Add(strInputArray[1]);
                }
                else if (strInputArray[0].Equals("C"))
                {
                    clist.Add(strInputArray[1]);
                }
                else if (strInputArray[0].Equals("D"))
                {
                    dlist.Add(strInputArray[1]);
                }
            }
            for (int s = 1; s <= 13; s++)
            {
                str = s.ToString();
                if (!slist.Contains(str))
                {
                    Console.WriteLine("S" + " " + str);
                }
            }
            for (int h = 1; h <= 13; h++)
            {
                str = h.ToString();
                if (!hlist.Contains(str))
                {
                    Console.WriteLine("H" + " " + str);
                }
            }
            for (int c = 1; c <= 13; c++)
            {
                str = c.ToString();
                if (!clist.Contains(str))
                {
                    Console.WriteLine("C" + " " + str);
                }
            }
            for (int d = 1; d <= 13; d++)
            {
                str = d.ToString();
                if (!dlist.Contains(str))
                {
                    Console.WriteLine("D" + " " + str);
                }
            }
            Console.ReadLine();
        }
    }


Measured memory_bytes: 19836
def abc156_d():
    N, A, B = map(int, input().split())
    MOD = 10**9 + 7

    def combi(n, k, p):
        a = 1
        b = 1
        for i in range(k):
            a = a * (n-i) % p
            b = b * (i+1) % p
        return a * pow(b, p-2, p) % p

    ans = pow(2, N, MOD) - 1
    ans -= combi(N, A, MOD)
    ans -= combi(N, B, MOD)
    ans %= MOD
    print(ans)

abc156_d()

Measured memory_bytes: 3064
#define _CRT_SECURE_NO_WARNINGS
#pragma comment(linker, "/stack:256000000")
#include<utility>
#include<iostream>
#include<vector>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<ctime>
#include<functional>
#include<random>
#include<climits>
#include<queue>
#include<stack>
#include<deque>
#include<bitset>
#include<map>
#include<set>
#include<unordered_map>
#include<unordered_set>
#include<cassert>
#include<ccomplex>

//4Head
#define all(x) x.begin(), x.end()
#define mp make_pair
#define X first
#define Y second

using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
mt19937_64 gen(time(NULL));

// belik's shit
ll const mod = 1e9 + 7;
namespace {
	ll mult(ll a, ll b) {
		ll val = a * b - (ll)((ld)a * b / mod) * mod;
		if (val < 0) {
			val += mod;
		}
		if (val >= mod) {
			val -= mod;
		}
		return val;
	}
	ll poww(ll a, ll b)
	{
		ll val = 1;
		a %= mod;
		while (b > 0){
			if (b % 2) val = mult(a, val);
			a = mult(a, a);
			b >>= 1;
		}
		return val % mod;
	}
	ll inv(ll a) {
		return poww(a, mod - 2);
	}
}

ll const maxn = 2e5 + 5;

signed main() {
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	ll n; cin >> n; ll ans = 0;
	vector<ll>a(n);
	for (ll i = 0; i < n; i++) cin >> a[i];
	for (ll i = n - 2; i >= 0; i--) {
		if (a[i] - a[i + 1] > 1) {
			cout << "No\n";
			return 0;
		}
		else {
			a[i] = min(a[i], a[i + 1]);
		}
	}
	cout << "Yes";
	return 0;

}
/*

*/

Measured memory_bytes: 1024
N, Q = map(int, input().split())
S = input().rstrip('\n')
count = [0]*(N+2)

for i in range(N-1):
    if S[i] == 'A' and S[i+1] == 'C':
        count[i+1] = 1

#累積和
for i in range(1, N+1):
    count[i] += count[i-1]

for _ in range(Q):
    l, r = map(int, input().split())
    print(count[r-1] - count[l-1])




Measured memory_bytes: 13168
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <cmath>
#include <iomanip>
#include <cassert>
#include <bitset>
#include <stack>
using namespace std;

typedef pair<int, int> P;
typedef pair<int, P> P2;
#define rep(i, n) for (int i=0; i<(n); i++)
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end())
#define index(xs, x) (int)(lower_bound(all(xs), x) - xs.begin())
#define _1 first
#define _2 second
#define pb push_back
#define INF 1145141919
#define MOD 1000000007

int N, M;
int A[5000];
int B[200][5000];
stack<P2> S[200];
long long X[5000];
long long T[5000];
// [l, r] += v
void add(int l, int r, int v) {
  T[l] += v;
  if (r+1 < N) T[r+1] -= v;
}

signed main() {
  ios::sync_with_stdio(false); cin.tie(0);
  cin >> N >> M;
  rep(i, N-1) cin >> A[i];
  rep(i, N) rep(j, M) cin >> B[j][i];
  long long m = 0;
  for (int i=N-1; i>=0; i--) {
    rep(i, N) T[i] = 0;
    if (i+1 < N) add(i+1, N-1, -A[i]);
    rep(x, M) {
      int r = i;
      while (!S[x].empty() && S[x].top()._1 <= B[x][i]) {
        P2 p = S[x].top();
        add(p._2._1, p._2._2, -p._1);
        r = p._2._2;
        S[x].pop();
      }
      add(i, r, B[x][i]);
      S[x].push(P2(B[x][i], P(i, r)));
    }
    rep(i, N-1) T[i+1] += T[i];
    rep(i, N) X[i] += T[i];
    rep(i, N) m = max(m, X[i]);
  }
  cout << m << "\n";
  return 0;
}


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

int main(){
  int N,q,ans = 0;
  cin >> N;
  int a[100001];
  for(int i = 1;i <= 100001;i++)a[i] = 0;
  for(int i = 0;i < N;i++){
    cin >> q;
    if(q <= 100000)a[q]++;
    else ans++;
  }
  for(int i = 1;i <= 100001;i++){
    if(a[i] < i)ans += a[i];
    else ans += a[i] - i;
  }
  cout << ans << endl;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define F first
#define S second
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int,int>;
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; }
ll gcd(ll a, ll b) { return b?gcd(b, a%b):a;}
ll lcm(ll a, ll b) { return a*b/gcd(a,b);}
ll MOD=1000000007;

int main(){
  string s;cin>>s;
  bool b=true;
  for(int i=1;i<4;i++){
    if(s.at(i)==s.at(i-1)) b=false;
  }
  if(!b){
    cout<<"Bad"<<endl;
  }else{
    cout<<"Good"<<endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <bits/stdc++.h>
#define ll long long int

using namespace std;

int main() {

    string s, t;
    cin>>s>>t;
    int ans = 0;
    for(int i = 0; i < s.length(); i++)
        if(s[i] == t[i]) ans++;
    cout<<ans<<endl;

	return 0;
}


Measured memory_bytes: 256
n=int(input())

ans=0
if n==1:
    ans=1
else:

    yakusuu=[1]*(n+1)

    for i in range(2,n+1):
        num=i

        while(num<=n):
            yakusuu[num]+=1
            num=num+i
    
    for i in range(1,n+1):
        ans+=yakusuu[i]*i

print(ans)

Measured memory_bytes: 151376
#!/usr/bin/env python3
import sys
import math

def solve(D: int, G: int, p: "List[int]", c: "List[int]"):
    ans = 1e9
    for bit in range(2 ** D):
        sum = 0
        rest_max = -1
        num = 0

        for i in range(D):
            if bit & 1 << i:
                sum += (i + 1) * 100 * p[i] + c[i]
                num += p[i]
            else:
                rest_max = i
        
        if sum < G:
            remain = G - sum
            s1 = 100 * (rest_max + 1)
            need = math.ceil(remain / s1)
            if need >= p[rest_max]:
                continue
            num += need
        ans = min(ans, num)

    print(ans)
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    D = int(next(tokens))  # type: int
    G = int(next(tokens))  # type: int
    p = [int()] * (D)  # type: "List[int]"
    c = [int()] * (D)  # type: "List[int]"
    for i in range(D):
        p[i] = int(next(tokens))
        c[i] = int(next(tokens))
    solve(D, G, p, c)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using db = double;
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define all(v) (v).begin(), (v).end()
#define siz(v) (ll)(v).size()
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define repi(i, x, n) for (ll i = x; i < (ll)(n); i++)
#define lb lower_bound
#define ub upper_bound
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
const ll mod = 1000000007;
const ll INF = 1000000099;
vector<ll> dx = {-1, 1, 0, 0}, dy = {0, 0, -1, 1};
//cin.tie(0);ios::sync_with_stdio(false);



signed main()
{
    chrono::system_clock::time_point start, end;
    start = chrono::system_clock::now();

    ll n,ans=0;
    cin >> n;
    vector<vector<ll>> v(n + 1, vector<ll>(n-1));
    rep(i, n) rep(j, n - 1)
    {
        cin >> v[i+1][j];

        if (j == n - 2){
            reverse(all(v[i + 1]));

        }
    }

    while (1)
    {

        set<ll> se;
        bool f=true;
        ll cnt=0;

        for (int i = 1; i <= n; i++)
        {
            if(siz(v[i])==0){
                cnt++;
                continue;
            }

            if (v[v[i].back()].back() == i && !se.count(i) && !se.count(v[i].back()))
            {
                f=false;
                //cout<<"DE"<<endl;
                se.insert(i);
                se.insert(v[i].back());
                v[v[i].back()].pop_back();
                v[i].pop_back();
            }
        }

        if(cnt==n){
            break;
        }
        if(f){
            cout<<-1<<endl;
            return 0;
        }
        se.clear();
        ans++;
    }

    
    cout<<ans<<endl;
    end = chrono::system_clock::now();

    double time = static_cast<double>(chrono::duration_cast<chrono::microseconds>(end - start).count() / 1000.0);
    //printf("time %lf[ms]\n", time);
}

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


int main(){
    string str; cin >> str;
    int n = str.size(), cnt = 0;

    if(str[0] != 'A')
    {
        cout << "WA\n";
        return 0;
    }

    for(int i = 1; i < n; i++)
    {
        if(1 < i && i < n-1 && str[i] == 'C')
        {
            cnt++;
        }
        else if(str[i] < 'a' || 'z' < str[i])
        {
            cout << "WA\n";
            return 0;
        }
    }

    if(cnt != 1) cout << "WA\n";
    else cout << "AC\n";
}


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

typedef long long ll;
typedef unsigned long long ull;

using namespace std;

const int MAXN=3010;
const int P=1E9+7;

template<typename T1,typename T2>
	void Inc(T1 &a,T2 b){a+=b;if(a>=P) a-=P;}

template<typename T1,typename T2>
	void Dec(T1 &a,T2 b){a-=b;if(a<0) a+=P;}

template<typename T1,typename T2>
	T1 Add(T1 a,T2 b){a+=b;return a>=P?a-P:a;}

template<typename T1,typename T2>
	T1 Sub(T1 a,T2 b){a-=b;return a<0?a+P:a;}

int n,m;
int f[MAXN][MAXN][2];

int main()
{
	scanf("%d%d",&n,&m);
	f[0][0][1]=1;
	for(int i=1;i<=n;i++)
		f[0][i][0]=1;
	for(int i=0;i<m;i++)
		for(int j=0;j<=n;j++)
		{
			if(!j)
				Inc(f[i][j][1],f[i][j][0]),
				f[i][j][0]=0;
			//WB
			if(j)
				Inc(f[i+1][j][j==1],f[i][j][0]),
				Inc(f[i+1][j][1],f[i][j][1]);
			//BW
			if(n-j)
				Inc(f[i+1][j][0],f[i][j][0]),
				Inc(f[i+1][j][1],f[i][j][1]);
			//WW
			if(j)
				Inc(f[i+1][j-1][j==1],f[i][j][0]),
				Inc(f[i+1][j-1][1],f[i][j][1]);
			//BB
			if(n-j)
				Inc(f[i+1][j+1][0],f[i][j][0]),
				Inc(f[i+1][j+1][1],f[i][j][1]);
		}
	ll Ans=0;
	for(int i=0;i<=n;i++)
		Inc(Ans,f[m][i][1]);
	printf("%lld\n",Ans);
}


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

int main(){
    using namespace std;
    unsigned long N, Q;
    cin >> N >> Q;
    vector<unsigned long> c(N);
    for(auto&& i : c){
        cin >> i;
        --i;
    }
    vector<tuple<unsigned long, unsigned long, unsigned long>> queries(Q);
    {
        unsigned long cnt{0};
        for(auto&& [i, l, r] : queries){
            cin >> l >> r;
            --l;
            i = cnt++;
        }
    }
    constexpr unsigned long B{1500};
    sort(begin(queries), end(queries), [&B](const auto& lhs, const auto& rhs){
        const auto& [i, li, ri] = lhs;
        const auto& [j, lj, rj] = rhs;
        return li / B == lj / B ? (li / B) & 1 ? ri > rj : ri < rj : li < lj;
    });
    unsigned long nl{0}, nr{0}, now{0};
    vector<unsigned long> cnt(N), ans(Q);
    for(const auto& [i, l, r] : queries){
        while(nr < r)now += !cnt[c[nr++]]++;
        while(nr > r)now -= !--cnt[c[--nr]];
        while(nl < l)now -= !--cnt[c[nl++]];
        while(nl > l)now += !cnt[c[--nl]]++;
        ans[i] = now;
    }
    for(const auto& i : ans)cout << i << endl;
    return 0;
}

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

using namespace std;

typedef long long ll;
typedef pair<int,int> pi;

int N, M, Q, A[5005], B, C, X, Y, Z;
string s, t;

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cin >> N >> M;
	for (int i = 1; i <= N; ++i) cin >> A[i];
	for (int i = 1; i <= N; ++i) B += A[i];
	for (int i = 1; i <= N; ++i){
		if (A[i] * 4 * M >= B) X++;
	}
	if (X >= M){
		cout << "Yes\n";
	}
	else cout << "No\n";
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>

using namespace std;

int n,m,maxx,c,vaz1[310],vaz[310],v[310][310];

void solve()
{
    for(int i=1;i<=m;i++) vaz1[i]=0;
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=m;j++)
            if(vaz[v[i][j]]==1) {vaz1[v[i][j]]++;break;}
    }
    for(int i=1;i<=m;i++)
        if(vaz1[i]>maxx) {maxx=vaz1[i];c=i;}
}

int main()
{
    //freopen("file.in","r",stdin);
    //freopen("file.out","w",stdout);
    int sol=1e9;
    scanf("%d%d",&n,&m);
    for(int i=1;i<=n;i++)
        for(int j=1;j<=m;j++)
            scanf("%d",&v[i][j]);
    for(int i=1;i<=m;i++)
        vaz[i]=1;
    for(int i=1;i<=m;i++)
    {
        maxx=0;c=0;
        solve();
        sol=min(sol,maxx);
        vaz[c]=0;
    }
    printf("%d",sol);
    return 0;
}


Measured memory_bytes: 512
#include<iostream>
#include<algorithm>
#include<vector>
#include<set>
#include<string>

int main() {
	int a, b, c;
	std::cin >> a >> b >> c;
	if (b - a == c - b) {
		std::cout << "YES" << std::endl;
	}
	else {
		std::cout << "NO" << std::endl;
	}
}

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

int dp[50010];

int main(){
    int n, m; cin >> n >> m;
    vector<int> c(m);
    rep(i,m) cin >> c[i];
    rep(i,50010) dp[i] = 100000;
    dp[0] = 0;
    for(int i = 0; i <= 50000; i++){
        for(int j = 0; j < m; j++){
            if(i + c[j] <= n){
                dp[i + c[j]] = min(dp[i + c[j]], dp[i] + 1);
            }
        }
    }
    cout << dp[n] << endl;
    return 0;
}


Measured memory_bytes: 3316
from numpy import zeros, maximum, array

def main():
    N, T, *AB = array(open(0).read().split(), int)

    dp = zeros(6010, int)
    for w, v in sorted(zip(*[iter(AB)] * 2)):
        dp[w:T + w] = maximum(dp[w:T + w], dp[:T] + v)

    print(dp.max())

main()

Measured memory_bytes: 12716
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin >> n;
    int ans = 0;
    for(int i = 1; i <= n; i++){
        int k = i;
        if(i == 1){
            ans = 1;
        }else{
            int v = k * k;
            while(v <= n){
                ans = max(v,ans);
                v *= k;
            }
        }
    }
    cout << ans;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define pi acos(-1)
#define IOS ios_base::sync_with_stdio(0); cin.tie(); cout.tie();
#define ff first
#define ss second
#define pb push_back
#define debug(val) cerr << "The value of " << #val << " is = " << val << '\n';
typedef long long ll;
typedef unsigned long long ull;
const ll mod = 1e9 + 7;
const ll inf = 0x3f3f3f3f;
const ll mininf = -922337203685477;
const ll nax = 1e5+5;
ll n, m;
vector<ll>dp(nax, 0);
unordered_map<ll, bool>rusak;	
		
int main(){
	IOS
	cin >> n >> m;
	while(m--){
		ll a;
		cin >> a;
		rusak[a]=1;
	}
	dp[0]=1;	
	for(int i=1;i<=n;i++){
		if(rusak[i]){ 
			continue;
		}
		else if(i==1){
			dp[i]=dp[0];
		}
		else{
			dp[i]=(dp[i-1]+dp[i-2])%mod;
		}
	}
	cout << dp[n] << '\n';
}


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



int main(){
 	string s;
  	cin >> s;
 	int m = 0;
  	int cnt = 0;
  	bool flag = false;
  	char ans[4] = {'A','T','G','C'};
  	for(int i=0; i<s.length(); ++i){
      flag = false;
      for(int j=0; j<4; ++j){
       	 if(s[i] == ans[j]){
         	flag = true;
            break;
         }
      }
	  if(flag == true){
      	cnt ++ ;
        m = max(m,cnt);
      }else{
        m = max(m,cnt);
        cnt = 0;
      }
      
    }
  	cout << m << endl;
}

Measured memory_bytes: 256
//
//  respect the past, embrace the future
//

#include  <bits/stdc++.h>
#include  <algorithm>
#include  <iostream>
#include  <climits>
#include  <cstdlib>
#include  <cstring>
#include  <cmath>
#include  <cstdio>
#include  <unordered_map>
#include  <map>
#include  <set>
#include  <stack>
#include  <string>
#include  <vector>
#include  <queue>

using namespace :: std;

using vpll = vector <pair <long long, long long> >;
using pll = pair <long long, long long>;
using vll = vector <long long>;
using ll = long long;

#define N (long long) (2e6 + 7)
#define M (long long) (1e9 + 7)
#define INF (long long) (2e18)
#define F first
#define S second

inline void fastInputOutput () {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL); cout.tie(NULL);
}

inline void ReadWriteFromFile () {
  freopen("../in.txt", "r", stdin);
  freopen("../out.txt", "w", stdout);
}

ll n, k, ans, a, b, check[N];
pll p[N];

int32_t main (int argc, char *argv[]) {
  fastInputOutput();
  // ReadWriteFromFile();
  
  string str;
  cin >> str;
  for (int i = 0; i < 3; i++)
    if (str[i] == str[i + 1])
      ans = 1;
  cout << (!ans ? "Good" : "Bad");
}

Measured memory_bytes: 256
# coding:utf-8

import sys

INF = 10 ** 5
MOD = 10 ** 9 + 7

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return input()


h, w = LI()
B = [SI() for _ in range(h)]

dp = [[0] * (w + 1) for _ in range(h + 1)]
dp[0][1] = 1

for i in range(h):
    for j in range(w):
        if B[i][j] == '#':
            continue
        dp[i + 1][j + 1] = (dp[i][j + 1] + dp[i + 1][j]) % MOD

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


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

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


// std::vector Declaration
template<typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts) {
   return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

// std::vector Initialization
template<typename T>
void fill_all(T& arr, const T& v) { arr = v; }
template<typename T, typename U>
void fill_all(T& arr, const U& v) { for (auto& i : arr) fill_all(i, v); }

// std::vector Debug
template<typename T>
ostream& operator<<(ostream& os, const vector<T>& v) {
   os << "[";
   bool a = 1;
   for (auto e : v ) {
      os << (a ? "" : " "); 
      os << e;
      a = 0;
   }
   os << "]";
   return os;
}

// std::pair Debug
template<typename T, typename U>
ostream& operator<<(ostream& os, const pair<T, U>& p) {
   os << "(" << p.first << " " << p.second << ")";
   return os;
}

// std::set Debug
template<typename T>
ostream& operator<<(ostream& os, const set<T>& st) {
   os << "{";
   bool a = 1;
   for (auto e : st) {
      os << (a ? "" : " ");
      os << e;
      a = 0;
   }
   os << "}";
   return os;
}

// std::multiset Debug
template<typename T>
ostream& operator<<(ostream& os, const multiset<T>& st) {
   os << "{";
   bool a = 1;
   for (auto e : st) {
      os << (a ? "" : " ");
      os << e;
      a = 0;
   }
   os << "}";
   return os;
}

// std::map Debug
template<typename T, typename U>
ostream& operator<<(ostream& os, const map<T, U>& mp) {
   os << "{";
   bool a = 1;
   for (auto e : mp) {
      os << (a ? "" : " ");
      os << e.first << ":" << e.second;
      a = 0;
   }
   os << "}";
   return os;
}

// std::tuple Debug
template<int N,class Tuple>
void out(ostream& os,const Tuple& t){}
template<int N,class Tuple,class H,class ...Ts>
void out(ostream& os,const Tuple& t){
   if(N)os<<" ";
   os<<get<N>(t);
   out<N+1,Tuple,Ts...>(os,t);
}
template<class ...Ts>
ostream& operator<<(ostream& os, const tuple<Ts...>& t){
   os<<"(";
   out<0,tuple<Ts...>,Ts...>(os,t);
   os<<")";
   return os;
}

// Debug
#define DUMP(x) cout<<#x<<" = "<<(x)<<endl


struct edge { int to, cost; };
ostream& operator<<(ostream& os, const edge& e) {
   os << "(" << e.to << ", " << e.cost << ")";
   return os;
}

const LL LINF = 1LL<<60;
const int IINF = 1<<30;
const LL MOD = 1e9+7;

int main()
{
   int a, b, c; cin >> a >> b >> c;

   cout << (a+b+c) - max({a,b,c}) << endl;

   return 0;
}


Measured memory_bytes: 256
import copy

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

def count(L):
    cnt = 0
    for i in range(len(L)-1):
        if L[i] == L[i+1]:
            L[i+1] = "1"
            cnt += 1
    return cnt

T = copy.copy(S)
T.insert(0, T[len(T)-1])
cnt_T = count(T)

if T[-1] != "1":
    ans = count(S) + (cnt_T * (K-1))
else:
    TT = S * 2
    cnt_TT = count(TT)
    if K % 2 == 0:
        ans = cnt_TT * (K // 2)
    else:
        ans = (cnt_TT * (K // 2)) + count(S)

print(ans)

Measured memory_bytes: 3444
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
		int[][][] count=new int[4][3][10];
		Scanner scan = null;
		try{
			scan =new Scanner(System.in);
			int n = scan.nextInt();
			int b,f,r,v;
			for(int i = 0 ; i < n;i++){
				b = scan.nextInt();
				f = scan.nextInt();
				r = scan.nextInt();
				v = scan.nextInt();
				count[b - 1][f - 1][r - 1] += v;
			}
		}finally{
			if(scan !=null)scan.close();
		}
		for(int i = 0; i < count.length;i++){
			if(i !=0 ){
				for(int j = 0 ; j < 20;j++){
					System.out.print("#");
				}
				System.out.println();
			}
			for(int j = 0 ; j < count[i].length;j++){
				for(int k = 0 ; k < count[i][j].length;k++){
					System.out.printf(" %d",count[i][j][k]);
				}
				System.out.println();
			}
		}
	}
}

Measured memory_bytes: 23204
#include <bits/stdc++.h>
#define lol long long
using namespace std;
signed main(){
  int n;
  cin>>n;
  if(n%10==3){
    cout<<"bon\n";
  }else if(n%10==0 ||n%10==1 ||n%10==6||n%10==8){
    cout<<"pon\n";
  }else{
    cout<<"hon\n";
  }
  return(0);
}


Measured memory_bytes: 3584
#include<iostream>
#include<string>
#include<deque>
#include<algorithm>
using namespace std;

int main(){
    string s;
    cin>>s;
    deque<char> q;
    for(int i=0;s[i]!='\0';i++){
        q.push_back(s[i]);
    }
    bool flip=false;
    int n,t,f;
    char c;
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>t;
        if(t==1){
            flip=!flip;
        }
        else{
            cin>>f>>c;
            if(f==1){
                if(flip)q.push_back(c);
                else q.push_front(c);
            }
            else{
                if(flip)q.push_front(c);
                else q.push_back(c);
            }
        }
    }

    if(flip)reverse(q.begin(),q.end());
    for(int i=0;q[i]!='\0';i++){
        cout<<q[i];
    }cout<<"\n";

    return 0;
}

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

int w, h, n;

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cin >> h >> w >> n;
  cout << (n / max(h, w)) + (n % max(h, w) ? 1 : 0) << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int inf = 1e9 + 7;
const ll longinf = 1LL << 60;
const ll mod = 1e9 + 7;

int main() {
    string S;
    cin >> S;
    int ans = 0;
    int tmp = 0;
    for(int i = 0; i < S.size(); i++) {
        if(S[i] == 'A' || S[i] == 'C' || S[i] == 'G' || S[i] == 'T') {
            tmp++;
            ans = max(ans, tmp);
        } else
            tmp = 0;
    }
    cout << ans;
    return 0;
}


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

int main() {
	int n,k;
	cin>>n>>k;
	vector<int> a(k);
	for(int i=0;i<n;i++){
		a[i%k]++;
	}
	//https://qiita.com/shirakawa4756/items/f4cc65c6b2b412b10c0c
	int min = *min_element(a.begin(), a.end());
	int max = *max_element(a.begin(), a.end());
	cout<<max-min<<endl;
	return 0;
}

Measured memory_bytes: 256