akhauriyash/Code-Regression huggingface dataset:
# 単調非減少にできるか。
# 前の方からやる場合、前の方は小さい方がいいので減らせるときは減らす。
# 後ろから約場合は、そのままにできるならそのままにする。

def build_stairs
  n   = gets.to_i
  a   = gets.split.map(&:to_i)
  pre = -99999999
  a.each do |i|
    if pre <= i - 1
      pre = i - 1
    elsif pre <= i
      pre = i
    else
      puts "No"
      return
    end
  end
  puts "Yes"
  return
end
build_stairs

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

typedef long long ll;

int main()
{
  ll K, A, B;
  cin >> K >> A >> B;
  if ( B - A <= 2 ) { cout << K+1 << endl; return 0; }
  ll zan = K-A+1;
  if ( zan <= 0 ) { cout << K+1 << endl; return 0; }
  ll ans = (zan/2) * (B-A);
  ans += A;
  if ( zan % 2 ) ans++;
  cout << ans << endl;
}

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

using namespace std;

const int MAX_N = 200000;
int n;
int a[MAX_N+1];

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

  if (a[0] != 0) {
    cout << -1 << endl;
    return 0;
  }

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

    if (i - zi < a[i]) {
      cout << -1 << endl;
      return 0;
    }

    if (a[i] <= a[i-1]) count += a[i-1];
  }

  cout << count << endl;

  return 0;
}


Measured memory_bytes: 1024
n = gets.to_i

positions = gets.split.map(&:to_i).sort
l = positions[0]
r = positions[-1]

res = 1000000000000000000000000000000
l.upto(r) do |pos|
  current = 0
  positions.each { |c| current += (pos - c)**2 }
  res = [current, res].min
end

puts res

Measured memory_bytes: 1788
#C問題
mod = 10**9+7
N,M = map(int,input().split())

step = []
for i in range(N+2):
    if i <= 1:
        step.append(1)
    elif i == 2:
        step.append(1)
    else:
        step.append(step[i-1]+step[i-2])
    
A = []
for j in range(M):
    A.append(int(input()))

stairs = []
flag = 0
old = -1
for a in A:
    if a-old == 1:
        flag = 1
        break
    else:
        stairs.append(a-old-1)
        old = a
stairs.append(N-old)

if flag == 1:
    print(0)
else:
    #print(stairs)
    ans = 1
    for s in stairs:
        ans*=step[s]
        
    print(ans%mod)

Measured memory_bytes: 464128
#include<bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long long ll;
typedef pair<ll, ll> PLL;
typedef vector<int> VI;
typedef vector<char> VC;
typedef vector<double> VD;
typedef vector<string> VS;
typedef vector<ll> VLL;
typedef vector<PLL> VP;
const static int INF = 1000000000;
const static int MOD = 1000000007;
#define rep(i,n) for (ll i=0; i<(ll)(n); i++)
#define repd(i,n) for (ll i=n-1; i>=0; i--)
#define rept(i,m,n) for(ll i=m; i<n; i++)
#define stl_rep(itr, x) for (auto itr = x.begin(); itr != x.end(); ++itr)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define PF push_front
#define PB push_back
#define SORT(V) sort((V).begin(), (V).end())
#define RVERSE(V) reverse((V).begin(), (V).end())
#define paired make_pair
#define PRINT(V) for(auto v : (V)) cout << v << " "
//charを整数に
int ctoi(char c) { if (c >= '0' && c <= '9') { return c - '0'; } return 0; }
// 累積和 for (int i = 0; i < N; ++i) s[i+1] = s[i] + a[i]; 
void cum_sum(int N,vector<double> a, vector<double> &s){ for(int i=0; i<N; i++){ s[i+1]=s[i]+a[i];}}
//ユークリッドの控除法
ll gcd(ll a,ll 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; // Be careful not to overflow
}
//素数判定
bool is_prime(long long n) {
    if (n <= 1) return false;
    for (long long p = 2; p * p <= n; ++p) {
        if (n % p == 0) return false;
    }
    return true;
}
int getdigit(ll num){
    unsigned digit=0;
    while(num!=0){
        num /= 10;
        digit++;
    }
    return digit;
}
//空白文字も入力 getline(cin, S);
//桁数指定 setprecision

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int N;
    cin >> N;
    string S;
    cin >> S;
    VLL left_W(S.size());
    ll count_W=0;
    VLL right_E(S.size());
    ll count_E=0;
    rep(i,S.size()){
        left_W[i]=count_W;
        if(S.at(i)=='W'){
            count_W++;
        }
    }
    repd(i,S.size()){
        right_E[i]=count_E;
        if(S.at(i)=='E'){
            count_E++;
        }
    }
    ll mini=INF;
    VLL ans(S.size());
    rep(i,S.size()){
        ans[i]=right_E[i]+left_W[i];
        mini=min(mini,ans[i]);
    }
    cout << mini << endl;
}


Measured memory_bytes: 7700
#include<iostream>
#include<cmath>
#include<algorithm>
#include<vector>
#include<string>

using namespace std;

int main(){

    int n;
    cin >> n;

    string s[n];
    for(int i=0;i<n;i++)cin >> s[i];

    sort(s,s+n);

    int c=1;

    for(int i=1;i<n;i++){
        if(s[i]==s[i-1])continue;
        else{
            c++;
        }
    }

    cout << c << endl;

}

Measured memory_bytes: 9880
import java.util.*;

public class Main {
	
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		int a = m / n;
		int mod = m % n;
		int value = Integer.MAX_VALUE;
		for (int i = 0; i < a; i++) {
			value = a - i;
			int b = a + mod + i * (n - 1);
			if (b % value == 0) {
				break;
			}
		}
		System.out.println(value);
	}
	
}

Measured memory_bytes: 23636
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <vector>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double LD;
using namespace std;
const int INF = 2147483647;
const int INF2 = 0x3f3f3f3f;
const ll INF64 = 3e18;
const double INFD = 1e30;
const double EPS = 1e-10;
const double PI = acos(-1);
const int MOD = 998244353;
template <typename T>
inline T read() {
    T X = 0, w = 0;
    char ch = 0;
    while (!isdigit(ch)) {
        w |= ch == '-';
        ch = getchar();
    }
    while (isdigit(ch)) X = (X << 3) + (X << 1) + (ch ^ 48), ch = getchar();
    return w ? -X : X;
}
const int MAXN = 1000005;
const int MAXV = 3;
int n, m, k;
int dr[4] = {1, 0, -1, 0};
int dc[4] = {0, 1, 0, -1};
int dr2[8] = {1, 1, 1, -1, -1, -1, 0, 0};
int dc2[8] = {1, 0, -1, 1, 0, -1, 1, -1};
int CASE = 1;

int main() {
#ifdef LOCALLL
    freopen("in", "r", stdin);
    freopen("out", "w", stdout);
#endif
    map<string, int> cnt;
    scanf("%d", &n);
    string str;
    for (int i = 0; i < n; i++) {
        cin >> str;
        cnt[str]++;
    }
    printf("%s x %d\n", "AC", cnt["AC"]);
    printf("%s x %d\n", "WA", cnt["WA"]);
    printf("%s x %d\n", "TLE", cnt["TLE"]);
    printf("%s x %d\n", "RE", cnt["RE"]);
    return 0;
}

Measured memory_bytes: 3788
module app;

import core.bitop;

import std.algorithm;
import std.array;
import std.bigint;
import std.conv;
import std.math;
import std.stdio;
import std.string;

struct Input
{
	int n;
	int[] p, q;
}

void parseInput(T)(out Input input, T file)
{
	with (file) with (input)
	{
		n = readln().strip().to!int;
		p = readln().strip().split().map!(to!int).array;
		q = readln().strip().split().map!(to!int).array;
	}
}

struct Output
{
}

auto main2(Input* input)
{
	return abs(orderOf(input.p) - orderOf(input.q));
}

int orderOf(int[] p)
{
    bool[] temp;
    temp.length = p.length;

    int order = 0;

    foreach (i, e; p)
    {
        auto value = factorial(p.length - i - 1);
        for (int j = 0; j < e; j++)
        {
            if (temp[j] == false)
                order += value;
        }
        temp[e-1] = true;
    }

    return order;
}

ulong factorial(ulong n)
{
    uint ret = 1;
    foreach (i; 1..n+1)
        ret *= i;
    return ret;
}

unittest { writeln("begin unittest"); }

unittest // example1
{
	string example =
`3
1 3 2
3 1 2`;
	Input input = void;
	parseExample(input, example);
	auto result = main2(&input);
	writeln(result);
	assert(result == 3);
}

unittest // example2
{
	string example =
`8
7 3 5 4 2 1 6 8
3 8 2 5 4 6 7 1`;
	Input input = void;
	parseExample(input, example);
	auto result = main2(&input);
	writeln(result);
	assert(result == 17517);
}

unittest // example3
{
	string example =
`3
1 2 3
1 2 3`;
	Input input = void;
	parseExample(input, example);
	auto result = main2(&input);
	writeln(result);
	assert(result == 0);
}

unittest { writeln("end unittest"); }

void parseExample(out Input input, string example)
{
	struct Adapter
	{
		string[] _lines;
		this(string input) { _lines = input.splitLines(); }
		string readln() { auto line = _lines[0]; _lines = _lines[1..$]; return line; }
	}
	parseInput(input, Adapter(example));
}

void main()
{
	Input input = void;
	parseInput(input, stdin);
	auto result = main2(&input);
	writeln(result);
}


Measured memory_bytes: 256
package main

import (
	"fmt"
)

type graph [][]int

func main() {
	var N int
	fmt.Scan(&N)

	graph1 := make(graph, N+1)

	for i := 2; i <= N; i++ {
		ai := 0
		fmt.Scan(&ai)
		graph1[ai] = append(graph1[ai], i)

	}
	// fmt.Println(graph1)
	for i := 1; i <= N; i++ {
		fmt.Println(len(graph1[i]))
	}
}


Measured memory_bytes: 15000
from collections import Counter
h,w,n = map(int,input().split())
need = []
append = need.append
for i in range(n):
    a,b = map(int,input().split())
    for x in range(-2,1):
        for y in range(-2,1):
            s = a + x
            t = b + y
            if 1 <= s <= h-2 and 1 <= t <= w-2:
                append(s*10**9 + t)

data = Counter(need).most_common()
ans = [0 for i in range(10)]
for x,y in data:
    ans[y] += 1

print((h-2)*(w-2)-sum(ans))
for i in ans[1:]:
    print(i)

Measured memory_bytes: 164284
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
const int INF = (1<<30)-1;
const long long LINF = (1LL<<62)-1;
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, 1, 0, -1};
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  map<int, int> mp;
  rep(i, n) {
    int a;
    cin >> a;
    mp[a-1]++;
    mp[a]++;
    mp[a+1]++;
  }
  int ans = 0;
  for (auto e : mp)
    chmax(ans, e.second);
  cout << ans << endl;
  return 0;
}

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

#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define mem(x,val) memset((x),(val),sizeof(x))
#define all(x) x.begin(),x.end()
#define pb push_back
#define mp make_pair
#define PI acos(-1.0) 
#define N 111111

const int INF = 1 << 30 ;
typedef long long ll ;
typedef pair < int , int > pii ;

int main() {
  string s1, s2 ;
  cin >> s1 >> s2 ;
  
  if(s1.length() > s2.length()) printf("GREATER") ;
  else if(s2.length() > s1.length())printf("LESS") ;
  else if (s1>s2)printf("GREATER") ;
  else if(s2>s1) printf("LESS") ;
  else printf("EQUAL") ;
	
  return 0 ;
}



Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
int main()
{
	string s;
	int arr[26] = {0};
	while (getline(cin, s))
	{
		for (int i = 0; i < s.length(); i++)
		{
			if(65 <= s[i] && s[i] <= 90)
				arr[s[i] - 65]++;
			else if(97 <= s[i] && s[i] <= 122)
				arr[s[i] - 97]++;
		}
	}

	for (int i = 0; i < 26; i++)
	{
		cout << (char)(i+97) << " : " << arr[i] << endl;
	}
	return 0;
}

Measured memory_bytes: 3164
#include<stdio.h>

int main() {
	int S, h, m, s;
	scanf("%d", &S);
	h = S / 3600;
	m = (S % 3600) / 60;
	s = (S % 3600) % 60;
	printf("%d:%d:%d\n", h, m, s);
	return 0;
}


Measured memory_bytes: 2728
#include <stdio.h>

int main(void){

  int a,b;
  scanf("%d %d", &a, &b);
  if (a == 1) {
    if (b == 1) {
      printf("Draw\n");
    } else {
      printf("Alice\n");
    }
  } else {
    if (b == 1) {
      printf("Bob\n");
    } else {
      if (a > b) {
        printf("Alice\n");
      } else if (b > a) {
        printf("Bob\n");
      } else {
        printf("Draw\n");
      }
    }
  }

  return 0;
}

Measured memory_bytes: 128
a = 3.times.map do
  gets.split.map &:to_i
end
b = 3.times.map{[false]*3}
gets.to_i.times do
  c = gets.to_i
  (0...3).each do |i|
    (0...3).each do |j|
      b[i][j] = true if a[i][j]==c
    end
  end
end
def ok
  puts :Yes
  exit
end
a = b
ok() if a[0][0]&&a[0][1]&&a[0][2]
ok() if a[1][0]&&a[1][1]&&a[1][2]
ok() if a[2][0]&&a[2][1]&&a[2][2]
ok() if a[0][0]&&a[1][0]&&a[2][0]
ok() if a[0][1]&&a[1][1]&&a[2][1]
ok() if a[0][2]&&a[1][2]&&a[2][2]
ok() if a[0][0]&&a[1][1]&&a[2][2]
ok() if a[0][2]&&a[1][1]&&a[2][0]

puts :No


Measured memory_bytes: 14268
#include<iostream>
#include<vector>
#include<algorithm>
#include <cmath>
#include <cctype>
using namespace std;

#define N 8

int main()
{
	vector<int> nums(N);
	int n, i;
	int j;
	int difference;
	char c;

	cin>>n;
	for (i = 0; i < n; i++) {
		j = 0;
		while (j < N) {
			cin.get(c);
 			if ( isdigit(c) ) nums[j++] = c-'0';
		}

		difference = 0;
		sort(nums.begin(), nums.end());
		for (j = 0; j < N; j++)
			difference += nums[j] * (int)pow(10.0, j);
		sort(nums.begin(), nums.end(), greater<int>());
		for (j = 0; j < N; j++)
			difference -= nums[j] * (int)pow(10.0, j);

		cout<<difference<<endl;
	}

	return 0;
}

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

#define lli long long int
#define st first
#define nd second
#define mp make_pair
#define pb push_back
#define INF 1000000007
#define endl "\n"

lli n,m;

int main(){
	// #ifndef ONLINE_JUDGE
	// freopen("zgir.gir","r",stdin);
	// freopen("zcik.cik","w",stdout);
	// #endif
	cin>>n>>m;
	cout<<n*(n-1)/2+m*(m-1)/2;
}

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

map<vector<int>,int> mem;
int dfs(vector<int> &A){
  int n = A.size();  
  if(n<=1) return 0;
  if(n==2) return 1;
  if(n==3) return 2;
  if(mem.count(A)) return mem[A];
  
  int res = A.size()-1;
  for(int i=0;i<w;i++){
    vector<int> T,F;
    for(int j=0;j<n;j++) (A[j]>>i&1)? T.push_back(A[j]) : F.push_back(A[j]);
    if(T.empty() || F.empty()) continue;
    if(T.size()==1 || F.size()==1)continue;
    res = min(res,max(dfs(T),dfs(F))+1);
  } 
  return mem[A] = res;
}

int BtoI(string a){
  int res = 0;
  for(int i=0;i<(int)a.size();i++) res = res*2+a[i]-'0';
  return res;
}

int main(){

  while(1){
    int n;
    cin>>w>>n;
    if(w==0&&n==0)break;
    vector<int> A;
    A.resize(n);
    for(int i=0;i<n;i++){
      string s;
      cin>>s;
      A[i] = BtoI(s);
    }
    mem.clear();
    cout<<dfs(A)<<endl;
  }
  return 0;
}

Measured memory_bytes: 4800
import math
import itertools

N = int(input())
Nlist = [0 for i in range(N)]
for i in range(N):
    Nlist[i] = i+1

Plist =list(itertools.permutations(Nlist))

Pn = input().split()
Pn = [int(i) for i in Pn]
Qn = input().split()
Qn = [int(i) for i in Qn]

def Order(A, Plist):
    #print(list(A), list(Plist[2]))
    num = -1
    for i in range(len(Plist)):
        if(list(A) == list(Plist[i])):
            num = i+1
            break
    return num

print(int(math.fabs(Order(Pn, Plist)-Order(Qn, Plist))))







Measured memory_bytes: 8052
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
#define rep(i, n) for(ll i = 0;i < n;i++)
#define all(i) i.begin(), i.end()
template<class T, class U> bool cmax(T& a, U b) { if (a<b) {a = b; return true;} else return false; }
template<class T, class U> bool cmin(T& a, U b) { if (a>b) {a = b; return true;} else return false; }

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

ll f(ll x, ll y, ll z) {
  return x - (x/y + x/z - x/lcm(y, z));
}

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

  ll a, b, c, d;
  cin >> a >> b >> c >> d;
  cout << f(b, c, d) - f(a-1, c, d) << endl;
}


Measured memory_bytes: 256
import java.util.*

fun main(args: Array<String>) {
  val sc = Scanner(System.`in`)
  val n = sc.nextInt()
  val m = sc.nextInt()
  val a = (1..n).map {
    sc.nextLong()
  }

  println(abc161b(m, a))
}

private fun abc161b(m: Int, a: List<Long>): String {
  val total = a.sum()
  var minM = total / (4 * m)

  if (total % (4 * m) != 0L) {
    minM++
  }

  val okSize = a.filter { !(it < minM) }.size
  if (okSize >= m) {
    return "Yes"
  }

  return "No"
}


Measured memory_bytes: 31400
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int n,a[1005];
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
	}
	int k=0,l=0;
	for(int i=1;i<=n;i++)
	{
		for(int j=i+1;j<=n;j++)
		{
			if(a[j]>a[i])
			{
				int o;
				o=a[i];
				a[i]=a[j];
				a[j]=o;
			}
		}
	}
	for(int i=1;i<=n;i++)
	{
		if(i%2==1)
		{
			k+=a[i];
		}
		else
		{
			l+=a[i];
		}
	}
	cout<<k-l<<endl;
	return 0;
}

Measured memory_bytes: 256
import math
N,D = map(int, input().split())

X = [0]*N
for i in range(N):
    X[i] = list(map(int, input().split()))
count=0

for i in range(0, N):
    for j in range(i+1,N):
        x = 0
        for a,b in zip(X[i],X[j]):
            x += (a-b)**2
        x = math.sqrt(x)
        if x.is_integer():
            count += 1

print(count)

Measured memory_bytes: 3064
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <utility>
#include <stack>
#include <vector>
#include <queue>
#include <algorithm>
#include <map>
#include <climits>
#include <set>
#include <cmath>
#include <numeric>
#include <iomanip>

using namespace std;
int dp[1000000][2];
int A[1000000];
int main(){
    string N_str;
    cin >> N_str;
    for(int i = 0; i < N_str.size(); i++){
        A[i] = (int) (N_str[i] - '0');
    }
    int N = N_str.size();
    dp[N - 1][0] = 10 - A[N - 1];
    dp[N - 1][1] = A[N - 1];
    for(int i = N - 2; i >= 0; i--){
        dp[i][0] = min(9 - A[i] + dp[i + 1][0], 10 - A[i] + dp[i + 1][1]);
        dp[i][1] = min(A[i] + 1 + dp[i + 1][0], A[i] + dp[i + 1][1]);
    }
    int ans = INT_MAX;
    //cout << "hello: " << 1 + right_cumsum[0] << endl;
    ans = min(ans, 1 + min(dp[0][0], dp[0][1]));
    int cum_sum = 0;
    for(int i = 0; i < N - 1; i++){
        //cout << cum_sum + A[i] + 1 + min(dp[i + 1][0], dp[i + 1][1]) << endl;
        if(A[i] < 9){
            ans = min(ans, cum_sum + A[i] + 1 + min(dp[i + 1][0], dp[i + 1][1]));
        }
        cum_sum += A[i];
    }
    cum_sum += A[N - 1];
    ans = min(ans, cum_sum);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 13060
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<string>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
const ll inf=0xfffffffffffffff;
vector<ll> node[100005],rev_node[100005],topo_v;
vector<P> idx;
ll inode[100005]={0},topo[100005]={0};
int ans[100005]={0};
bool top_sort(const int &a,const int &b){
  return topo[a]>topo[b];
}
int main(){
  int n,m;
  cin>>n>>m;
  for(int i=0;i<(n+m-1);i++){
    ll a,b;
    cin>>a>>b;
    node[a].push_back(b);
    rev_node[b].push_back(a);
    idx.push_back(P(a,b));
  }
  int st;
  for(int i=1;i<=n;i++){
    inode[i]=rev_node[i].size();
    if(inode[i]==0) st=i;
  }
  queue<int> que;
  que.push(st);
  int cnt=0;
  while(!que.empty()){
    int pos=que.front();
    que.pop();
    topo[pos]=cnt++;
    topo_v.push_back(pos);
    for(int i=0;i<node[pos].size();i++){
      inode[node[pos][i]]--;
      if(inode[node[pos][i]]==0) que.push(node[pos][i]);
    }
  }
  for(int i=1;i<=n;i++){
    if(rev_node[i].size()==0) cout<<0<<endl;
    else {
      sort(rev_node[i].begin(),rev_node[i].end(),top_sort);
      cout<<rev_node[i][0]<<endl;
    }
  }
}


Measured memory_bytes: 16752
#include <iostream>

using namespace std;
typedef long long ll;

constexpr ll INF = 1000000000000000005;

int n;
ll t[405];
ll sum[405];

ll dp[405][405];

ll gsum(int l, int r) {
	return sum[r]-sum[l-1];
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cin >> n;
	for (int i = 1; i <= n; ++i) {
		cin >> t[i];
		sum[i] = sum[i-1]+t[i];
	}
	for (int i = 0; i <= n; ++i) {
		for (int j = 0; j <= n; ++j) {
			dp[i][j] = INF;
		}
	}
	for (int i = 0; i <= n; ++i) {
		dp[i][i] = 0;
	}
	for (int len = 2; len <= n; ++len) {
		for (int l = 1; l+len-1 <= n; ++l) {
			int r = l+len-1;

			// merge such that p is the first element
			// of the second part
			for (int p = l+1; p <= r; ++p) {
				dp[l][r] = min(dp[l][r], dp[l][p-1]+dp[p][r]+gsum(l, p-1)+gsum(p, r));
			}
		}
	}
	cout << dp[1][n] << "\n";
	return 0;
}

/*
	each slime can be merged either left or right
	solve for subsegments? and merge + cost

	dp[l][r] = min cost for merging l..r into one
	res = dp[1][n]

	dp[x][x] = 0
	dp[x][x+1] = t[x]+t[x+1]

	iterate over subsegment length 1..n and slide over the array?
	how to merge?
	
	try all merge points p in [l, r] and since we know the solution for shorter arrays,
	we can find the minimum merge cost
*/


Measured memory_bytes: 1536
use std::io;


fn main() {
    let (a, b) = {
        let i = read::<usize>();
        (i[0], i[1])
    };

    if a * b % 2 == 0 { println!("No"); }
    else { println!("Yes"); }
}

#[allow(dead_code)]
fn read<T>() -> Vec<T>
where T:
    std::str::FromStr,
    T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.split_whitespace()
        .map(|s| s.trim().parse().unwrap())
        .collect()
}

#[allow(dead_code)]
fn read_one<T>() -> T
where T:
    std::str::FromStr,
    T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.trim().parse().unwrap()
}

Measured memory_bytes: 4352
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<stdlib.h>
#include<cassert>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=500000004;
const double EPS=1e-6;
const double PI=acos(-1.0);
int ABS(int a){return max(a,-a);}
long long ABS(long long a){return max(a,-a);}
int b[510];
pair<int,int>p[510];
int ret[300000];
int main(){
	int a;scanf("%d",&a);
	for(int i=0;i<a;i++){scanf("%d",b+i);b[i]--;}
	for(int i=0;i<a;i++)p[i]=make_pair(b[i],i);
	std::sort(p,p+a);
	int at=0;
	for(int i=0;i<a;i++){
		int s=p[i].first;
		int t=p[i].second;
		int rem=t;
		while(at<s&&rem){
			if(!ret[at]){
				rem--;
				ret[at]=t+1;
			}
			at++;
		}
		if(rem){
			printf("No\n");return 0;
		}
		ret[s]=t+1;
	}
//	printf("A\n");
	at=a*a-1;
	for(int i=a-1;i>=0;i--){
		int s=p[i].first;
		int t=p[i].second;
		int rem=a-1-t;
		while(at>s&&rem){
			if(!ret[at]){
				rem--;
				ret[at]=t+1;
			}
			at--;
		}
		if(rem){
			printf("No\n");return 0;
		}
	}
	printf("Yes\n");
	for(int i=0;i<a*a;i++){
		if(i)printf(" ");
		printf("%d",ret[i]);
	}
	printf("\n");
}

Measured memory_bytes: 2176
#include<stdio.h>
int main(){
int i,a,b,c,d,n,e;
	scanf("%d",&n);
	for(i=0;i<n;i++){
	scanf("%d %d %d %d",&a,&b,&c,&d);
	e=a*c+b*d;
	if(d<2&&c<5){
		if((a*5+b*2)*0.8<e) e=(a*5+b*2)*0.8; 
	}
	else if(c<5){
		if((a*5+b*d)*0.8<e) e=(a*5+b*d)*0.8; 
	}
	else if(d<2){
		if((a*c+b*2)*0.8<e) e=(a*c+b*2)*0.8; 
	}
	else{
		e=(a*c+b*d)*0.8; 
	}
	printf("%d\n",e);
	}
	return 0;
}

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

using namespace std;

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

	bool is_ok(false);

	vector<char> v_s;
	vector<char> v_t;
	for (int j = 0; j < s.size(); j++) {
		v_s.push_back(s[j]);
	}
	for (int k = 0; k < t.size(); k++) {
		v_t.push_back(t[k]);
	}
	sort(v_s.begin(), v_s.end());
	sort(v_t.begin(), v_t.end(), greater<char>());

	bool equal(true);
	for (int m = 0; m < s.size(); m++) {
		if (v_s[m] != v_t[m]) {
			equal = false;
		}
	}

	if (s.size() < t.size() && equal) {
		is_ok = true;
	} else {
		for (int l = 0; l < t.size(); l++) {
			if (l <= s.size() - 1 && v_s[l] < v_t[l]) {
				is_ok = true;
			}	
		}
	}
	
	cout << ((is_ok) ? "Yes" : "No") << endl;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>

int satr(int n,int A[],int m){
	
  if(n==0){
    if(m-A[n]==0){
      return 0;
    }else{
      return m;
    }
  }
  if(satr(n-1,A,m-A[n])==0){
    return 0;
  }else if(satr(n-1,A,m)==0){
    return 0;
  }
	
  return 1;
}

int main(){

  int n;
  std::cin>>n;
  int A[n];
  for(int i=0;i<n;i++){
    std::cin>>A[i];
  }
  int q;
  std::cin>>q;
  int m[q];
  for(int i=0;i<q;i++){
    std::cin>>m[i];
  }

  for(int x=0;x<q;x++){
    if(satr(n,A,m[x])==0){
      std::cout<<"yes\n";
    }else{
      std::cout<<"no\n";
    }

  }

  return 0;
}



Measured memory_bytes: 3080
program great_ocean_view
  implicit none
  integer :: n, h(0:20), i, m
  h = 0
  read(*,*) n
  read(*,*) h(1:n)
  m = 0
  do i = 1, n
    if (h(i).ge.maxval(h(0:i-1))) m = m + 1
  end do
  write(*,'(i0)') m
  stop
end program great_ocean_view

Measured memory_bytes: 768
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <list>
#include <map>

using namespace std;
typedef long long ll;

int main() {
    string S;
    cin >> S;
    string p="",l="";
    p+=char(S[0]);
    p+=char(S[1]);
    l+=char(S[2]);
    l+=+char(S[3]);
    vector<string> jg={"01","02","03","04","05","06","07","08","09","10","11","12"};
    bool jg1=false,jg2=false;
    for(int i=0;i<jg.size();i++){
        if(p==jg[i]) {
            jg1=true;
        }
        if(l==jg[i]) {
            jg2=true;
        }
    }
    //cout << p << l << endl;
    if(jg1 && jg2) cout << "AMBIGUOUS" << endl;
    else if(jg1) cout << "MMYY" << endl;
    else if(jg2) cout << "YYMM" << endl;
    else cout << "NA" << endl;

}

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


int solve(int H, int W) {
    vector<vector<int>> field(H, vector<int>(W));
    for (int h = 0; h < H; h++) {
        for (int w = 0; w < W; w++) {
            cin >> field[h][w];
        }
    }
    

    int ret = 0;
    
    for (int sh = 0; sh < H; sh++) {
        for (int sw = 0; sw < W; sw++) {
            for (int eh = sh+2; eh < H; eh++) {
                for (int ew = sw+2; ew < W; ew++) {
                    int outer = 100;
                    int inner = -1;
                    int sum = 0;
                    for (int h = 0; h < H; h++) {
                        for (int w = 0; w < W; w++) {
                            if (sh <= h && h <= eh && sw <= w && w <= ew) {
                                if (h == sh || h == eh || w == sw || w == ew) {
                                    outer = min(outer, field[h][w]);
                                } else {
                                    sum -= field[h][w];
                                    inner = max(inner, field[h][w]);
                                }
                            }
                            if (h == H-1 && w == W-1 && outer > inner) {
                                sum += outer * (eh - sh - 1) * (ew - sw - 1);
                                ret = max(sum, ret);
                            } 
                        }
                    }
                }
            }
        }
    }
    return ret;
}

int main(void){
    int h, w;
    vector<int> ans;
    while (1) {
        cin >> h >> w;
        if (!h && !w) break;
        ans.push_back(solve(h, w));
    }
    for (auto &i : ans) {
        cout << i << endl;
    }
    
}



Measured memory_bytes: 3100
import fractions as math
from functools import reduce
def lcm_base(x, y):
    return (x * y) // math.gcd(x, y)
def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)
a = input()
b = list(map(int,input().split()))
c = lcm_list(b)
ans = 0
for d in b:
  ans += c//d
print(ans%1000000007)

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

ll MOD = 1e9 + 7;

ll modPow(ll a, ll x) {
  if (x == 0) return 1;
  if (x == 1) return a;
  ll temp = modPow(a, x / 2);
  ll ans = (temp * temp) % MOD;
  if (x % 2 == 1) ans = (ans * a) % MOD;
  return ans;
}

ll modInv(ll a) {
  return modPow(a, MOD - 2);
}

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

  ll N, M; cin >> N >> M;
  vector<ll> P(M + 1, 1);
  vector<ll> INV(M + 1, 1);
  
  P[0] = 1;
  for (ll i = 1; i <= M; i++) {
    P[i] = (P[i - 1] * i) % MOD;
  }
  INV[0] = 1;
  for (ll i = 1; i <= M; i++) {
    INV[i] = (INV[i - 1] * modInv(i)) % MOD;
  }

  ll ans = 0;
  ll f = 1;
  for (ll i = 0; i <= N; i++) {
    ll mCk = P[N];
    mCk = (mCk * INV[i]) % MOD;
    mCk = (mCk * INV[N - i]) % MOD;

    ll mPi = P[M];
    mPi = (mPi * INV[M - i]) % MOD;

    ll mPn = P[M - i];
    mPn = (mPn * INV[M - N]) % MOD;

    ll temp = mCk;
    temp = (temp * mPi) % MOD;
    temp = (temp * mPn) % MOD;
    temp = (temp * mPn) % MOD;
    temp = (f * temp + MOD) % MOD;
    ans = (ans  + temp) % MOD;
    f = -f;
  }

  cout << ans << '\n';
  return 0;
}

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

#define REP(i, n) for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n) for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define REP_REV(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (int (i) = (int)(n) - 1 ; (i) >= m ; --(i))

#define INF 2e9
#define INF_LL 1LL<<60
#define ll long long
#define ALL(v) (v).begin(), (v).end()

typedef pair<ll, ll> P;


int main(){
    string s, t;
    cin >> s >> t;

    bool seikou = false;

    REP_REV(i, s.size()-t.size()+1) {
        bool bamen = true;
        REP(j, t.size()) {
            if(!(s[i+j] == t[j] || s[i+j] == '?')) {
                bamen = false;
                break;
            }
        }
        if(bamen) {
            REP(j, t.size()) {
                s[i+j] = t[j];
            }
            seikou = true;
            break;
        }
    }

    if(!seikou) {
        cout << "UNRESTORABLE" << endl;
        return 0;
    }

    REP(i, s.size()) if(s[i] == '?') s[i] = 'a';

    cout << s << endl;




    return 0;
}


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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int H,W;
string S[2020];
int len[2020][2020];

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>H>>W;
	FOR(y,H) cin>>S[y];
	
	FOR(y,H-1) {
		int same=W,ns=W;
		for(x=W-1;x>=0;x--) {
			if(S[y][x]==S[y+1][x]) {
				len[y][x]=ns-x;
				same=x;
			}
			else {
				len[y][x]=same-x;
				ns=x;
			}
		}
	}
	
	int ma=max(H,W);
	int step=0;
	FOR(i,W) {
		vector<pair<int,int>> V;
		V.push_back({-1,-1});
		for(y=1;y<=H;y++) {
			
			x=len[y-1][i];
			int f=y;
			while(V.back().second>=x) {
				f=V.back().first;
				ma=max(ma,V.back().second*(y-f+1));
				V.pop_back();
			}
			V.push_back({f,x});
		}
	}
	cout<<ma<<endl;
	
	
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


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

int main() {
  string s;
  cin>>s;

  int ans=1e9;
  int cnt1,cnt2;
  for (int i=0; i<26; i++) {
    cnt1=0;
    cnt2=0;
    for (int j=0; j<s.size(); j++) {
      cnt1++;
      if (s[j]-'a'==i) {
	cnt1--;
	cnt2=max(cnt2,cnt1);
	cnt1=0;
      }
      else if (j==s.size()-1)
	cnt2=max(cnt2,cnt1);
    }
    ans=min(ans,cnt2);
  }

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

Measured memory_bytes: 256
import collections

N = int(input())
S = [input() for _ in range(N)]
M = int(input())
T = [input() for _ in range(M)]
c1 = collections.Counter(S)
c2 = collections.Counter(T)
answer = 0
for word in c1:
    if word in c2:
        count = c1[word] - c2[word]
    else:
        count = c1[word]
    answer = max(answer, count)
print(answer)    


Measured memory_bytes: 3316
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<map>
using namespace std;

typedef long long ll;
int main(){
    ll n,i,j,tt;
    vector<ll>vec,s,p;
    map<ll,ll>m;
    scanf("%lld",&n);
    while(n--){
        scanf("%lld",&i);
        vec.push_back(i);
    }
    sort(vec.begin(),vec.end());
    ll lasts=0;
    for(int i=0;i<vec.size();i++){
        lasts+=vec[i];
        m[vec[i]]=lasts;
    }
    scanf("%lld",&n);
    for(int i=0;i<n;i++){
        scanf("%lld",&j);
        s.push_back(j);
    }
    for(int i=0;i<n;i++){
        scanf("%lld",&j);
        for(tt=s[i];tt>=0&&m[tt]==0;tt--);
        if(m[tt]<j)
            printf("No\n");
        else printf("Yes\n");
    }
}

Measured memory_bytes: 62444
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

#define endl            "\n"
#define forn(i,n)       for(int i=0; i<n; i++)
#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;


void zeus()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
}





int32_t main()
{
    //zeus();

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

    if (t.length() != s.length() + 1) {
        cout << "No" << endl;
        return 0;
    }

    forn(i, s.length()) {
        if (s[i] != t[i]) {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;


}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pli = pair<ll, int>;
using pil = pair<int, ll>;
using uint = unsigned int;
template <typename T>
using Graph = vector<vector<T>>;
const int MOD = 1e9 + 7;
const ld PI = acosl(-1);

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

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

    vector<int> num;
    for (int i = 1; i * i <= N; ++i) {
        int tmp = N / i;
        num.push_back(i);
        if (i != tmp)
            num.push_back(tmp);
    }
    sort(num.begin(), num.end());

    int siz = num.size();
    vector<ll> dp(siz);
    dp[0] = 1;
    for (int i = 0; i < K; ++i) {
        reverse(dp.begin(), dp.end());
        for (int j = siz - 1; j >= 1; --j) {
            (dp[j - 1] += dp[j]) %= MOD;
            (dp[j] *= num[j] - num[j - 1]) %= MOD;
        }
    }

    ll ans = 0;
    for (int i = 0; i < siz; ++i)
        ans += dp[i];
    cout << ans % MOD << endl;

    return 0;
}


Measured memory_bytes: 4084
#include <iostream>
#include<sstream>
#include<string>
#include<vector>
#include <cmath>
#include <limits>
#include <queue>
#include<algorithm>
 
using namespace std;
 
#define rep(i,n) for (int (i)=0;(i)<(n);i++)
 
int main(){
    int a, b;
    cin >> a >> b;
    int s;
    if (a > b) {
        rep(i,a) cout << b;
    }
    else {
        rep(i,b) cout << a;
    }
 
    return 0;
}

Measured memory_bytes: 256
if __name__ == '__main__':
    [n, m] = list(map(int, input().split()))
    a = list(map(int, input().split()))
    bc = [list(map(int, input().split())) for _ in range(m)]

    a.sort()
    bc.sort(key=lambda x: x[1], reverse=True)

    index = 0
    for b, c in bc:
        if index >= len(a) or c <= a[index]:
            break
        for _ in range(b):
            if index < len(a) and c > a[index]:
                a[index] = c
                index = index + 1
            else:
                break

    # print(a)
    print(sum(a))


Measured memory_bytes: 32956
import math

ans = []
while True:
	data = input().split()
	a = int(data[0])
	b = data[1]
	c = int(data[2])

	if b == '+':
		ans += [a+c]
	elif b == '-':
		ans += [a-c]
	elif b == '*':
		ans += [a*c]
	elif b == '/':
		ans += [math.floor(a/c)]
	elif b == '?':
		break
	else:
		break

for output in ans:
	print(output)


Measured memory_bytes: 5664
#include <iostream>
#include <string>
#include <cstring>
#include <fstream>
#include <random>
#include <cmath>
#include <iomanip>
#include <climits>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <map>
#include <deque>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <list>
#include <unordered_map>
#include <bitset>
#include <sstream>
#include <new>
#include <typeinfo>

typedef  long long ll;
#define mop 1000000007
#define mop2 998244353

using namespace std;

int main() {
	ll a, b, c, k;
	cin >> a >> b >> c >> k;
	ll ans = 0;
	
	ans += max(0ll, min(a, k));
	k -= a;
	
	k -= b;
	
	ans -= max(0ll, min(c, k));
	k -= c;

	cout << ans << endl;
}

Measured memory_bytes: 3632
N=int(input())
A=list(map(int,input().split()))
i=0
for i in range(N):
  if A[i]%2==1 or (A[i]%2==0 and A[i]%3==0) or (A[i]%2==0 and A[i]%5==0):
    i+=1
    if i==N:
      print("APPROVED")
  else:
    print("DENIED")
    break


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

using namespace std;
using boost::multiprecision::cpp_int;

typedef long long ll;
typedef pair<ll, ll> pll;

const ll INF = 1e17;
const ll MOD = 1e9+7;

int main() {
    // input, ready
    ll N,K;
    cin >> N >> K;

    ll kurai = 1;
    int ans = 1;
    while (kurai < N) {
        kurai *= K;
        ans++;
    } 
    if (kurai == N) cout << ans << endl;
    else cout << ans -1 << endl;

    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int M = sc.nextInt();
		int[] a = new int[N];
		int[] b = new int[N];
		int[] c = new int[M];
		int[] d = new int[M];
		for(int i = 0 ; i < N ; i++) {
			a[i] = sc.nextInt();
			b[i] = sc.nextInt();
		}
		for(int i = 0 ; i < M ; i++) {
			c[i] = sc.nextInt();
			d[i] = sc.nextInt();
		}
		for(int i = 0 ; i < N ; i++) {
			int point = 0;
			int min = 1000000000;
			for(int j = 0 ; j < M ; j++) {
				if(Math.abs(a[i] - c[j]) + Math.abs(b[i] - d[j]) < min) {
					point = j + 1;
					min = Math.abs(a[i] - c[j]) + Math.abs(b[i] - d[j]);
				}
			}
			System.out.println(point);
		}
	}
}


Measured memory_bytes: 21972
#include<iostream>
#include<stdio.h>
#include<string.h>
#include<algorithm>
#define maxn 100005
using namespace std;
typedef long long ll;
ll n,m;
int main()
{
	scanf("%lld%lld",&n,&m);
	ll temp=m*1900+(n-m)*100;
	printf("%lld\n",(1<<m)*temp);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define REP(i,a,b) for(int i=a; i<=b; i++)
using namespace std;

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

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int a;
    for(int i=1; i<=5; i++){
        cin >> a;
        if(a==0){
            cout << i;
            break;
        }
    }
    return 0;
}


Measured memory_bytes: 3564
#include <iostream>
#include <string>
using namespace std;
 
int main() 
{
    string S;
    cin >> S;
    int length = 0;
    int cnt = 0;
    for(int i = 0; i < S.length(); i++) 
    {
        if(S[i] == 'A' || S[i] == 'T' || S[i] == 'G' || S[i] == 'C') 
        {
            ++cnt;
            length = max(length, cnt);
        } else cnt = 0;
    }
    cout << length << endl;
}

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

sArray = [input() for i in range(n)]

#文字列比較は辞書順となる
sASorted = sorted(sArray)
#''.joinはリスト要素に格納された文字列の結合をすっきり書くことができる
result = ''.join(sASorted)

print(result)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
// ll mod=1000000007;
// ld pi = 3.14159;

int main(){
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);
    cout.tie(NULL);
    ll t,t1,i,j,k,temp,temp2,n,m,x,y,z,sum=0,o;
    // cin >> t;
    // while(t--){
    ld a,b;
    cin >> a >> b;
    cout << ll(a*b);
}

Measured memory_bytes: 3808
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        String a = sc.next();
        String b = sc.next();
        String c = sc.next();
        sc.close();
        int ans = 0;
        for (int i = 0; i < n; i++) {
            switch (que(a.charAt(i), b.charAt(i), c.charAt(i))) {
            case 0:
                ans += 2;
                break;
            case 1:
                ans += 1;
                break;
            }
        }
        System.out.println(ans);
    }

    public static int que(char a, char b, char c) {
        int ans = 0;
        if (a == b) ans++;
        if (c == b) ans++;
        if (a == c) ans++;
        return ans;
    }
}


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

using namespace std;

using ll = long long;

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

    int n;
    cin >> n;

    int p = 1;
    while (2 * p <= n) p *= 2;

    cout << p << endl;

    return 0;
}


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

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define INF 999999999
#define M_PI 3.14159265358979323846
#define ALL(X) (X).begin(),(X).end()

#ifdef __LOCAL
    #define DBG(X) cout << #X << " = " << (X) << endl;
    #define SAY(X) cout << (X) << endl;
#else
    #define DBG(X)
    #define SAY(X)
#endif

#ifdef __LOCAL
    #include <filesystem>
    namespace fs = std::filesystem;
#endif

using namespace std;

using ll = long long int;
using ull = unsigned long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

int dx[]={1, 0, -1, 0, 0};
int dy[]={0, 1, 0, -1, 0};
const int INT_INF = (int)(2e9);
const ll  LL_INF = (ll)(2e18);
const int NIL = -1;
static mt19937 _g(time(nullptr));
 
std::string pad(int num){ char buffer[4]; std::snprintf(buffer, sizeof(buffer), "%03d", num); return buffer;}
inline ll randint(ll a, ll b) { ll w = (_g() << 31LL) ^ _g(); return a + w % (b - a + 1); }
inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T> inline T sign(T x) { return T(x > 0) - T(x < 0); }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline T fetch() { T ret; cin >> ret; return ret; }
template<typename T> inline vector<T> fetch_vec(int sz) { vector<T> ret(sz); for (auto& elem : ret) cin >> elem; return ret; }

int N;
vector<int> A;

void input(){
    fast_io();
    #ifdef __LOCAL
        fs::path p = __FILE__;
        fs::path input,output;
        input = output = p.parent_path();
        input += string("/input/") + string(p.stem()) + string(".txt");
        output += string("/output/") + string(p.stem()) + string(".txt");
        freopen(input.c_str(), "r", stdin);
        freopen(output.c_str(), "w", stdout);
    #endif
    cin >> N;
    A = fetch_vec<int>(N);

}

void solve(){
    input();
    bool flag=true;
    for(int i=0;i<N;i++){
        if(A[i]%2==0) flag &= (A[i]%3==0)||(A[i]%5==0);
    }
    if(flag) cout << "APPROVED" << endl;
    else cout << "DENIED" << endl;
    
}

int main()
{
    solve();
    return 0;
}


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

#define rep(i, a, b) for(int i = (a); i < (b); ++i)
#define per(i, a, b) for(int i = (b)-1; i >= (a); --i)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fst first
#define snd second

template<class T> bool ckmin(T& a, const T& b) { return b < a ? a = b, 1 : 0; }
template<class T> bool ckmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<pii> vii;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int main() {
  cin.tie(0)->sync_with_stdio(0);
  cin.exceptions(cin.failbit);

  int n;
  cin >> n;

  ll ans = 0;
  rep(a,1,n) {
    int cnt = n/a;
    if (n%a==0) --cnt;
    ans += cnt;
  }

  cout << ans << '\n';
}

Measured memory_bytes: 3648
#include <iostream>
#include <cmath>
using namespace std;
const int Max_N=1e5+10;
int n;
int a[Max_N];
int dp[Max_N];
int main(){
	cin >> n;
	
	for(int i = 0 ; i < n ; i++){
		cin >>a[i];
	}
	dp[0]=0;
	dp[1]=abs(a[0]-a[1]);
	
	for(int i = 2; i < n ; i++){
		dp[i] = min(dp[i-1]+abs(a[i]-a[i-1]),dp[i-2]+abs(a[i-2]-a[i]));
	}
	cout << dp[n-1];

    return 0;
}




Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define ALL(A) (A).begin(),(A).end()
#define ll long long
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)

const ll mod = 1e9+7;
const ll INF = -1*((1LL<<63)+1);
const int inf = -1*((1<<31)+1);

using namespace std;

bool v[100005];

void dfs(int now,vector<vector<int>> &to,vector<vector<int>> &cost,vector<int> &d){
	if(v[now] == 0 ){
		v[now] = 1;
		d[now] = 0;
	}
	for(int i=0;i<to[now].size();i++){
		int next = to[now][i];
		if(v[next]==1)continue;
		d[next] = d[now] + cost[now][i];
		v[next] = 1;
		dfs(next,to,cost,d);
	}
}
int main(void){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N,M;
	cin >> N >> M;
	vector<vector<int>> to(N),cost(N);
	vector<int> d(N),L(M),R(M),D(M);
	rep(i,M){
		int a,b,c;
		cin >> a >> b >> c;
		a--;
		b--;
		L[i] = a;
		R[i] = b;
		D[i] = c;
		to[a].push_back(b);
		cost[a].push_back(c);
		to[b].push_back(a);
		cost[b].push_back(-c);
	}
	rep(i,N){
		dfs(i,to,cost,d);
	}
	rep(i,M){
		if(d[R[i]] - d[L[i]] != D[i]){
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
}

Measured memory_bytes: 19840
def main():
    S = input()
    T = input()
    cnt = 0
    tmp = 0
    for i in range(len(S)-len(T)+1):
        for j in range(len(T)):
            if S[i+j] == T[j]:
                tmp += 1
        cnt = max(cnt,tmp)
        tmp = 0

    return(len(T)-cnt)


print(main())


Measured memory_bytes: 9008
import sys
mod = pow(10, 9) + 7
def mul(a, b):
    return ((a % mod) * (b % mod)) % mod

def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

NNN = (10**2)
g1 = [1, 1]
g2 = [1, 1]
inverse = [0, 1]

for i in range( 2, NNN + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )


def erabu(aW):
    r = 0
    for i in range(aW // 2 + 1 + 1):
        sp = aW - (2*i -1)
        r += cmb(sp+i+1-1, sp, mod)
    return r

N, W, K = [int(x) for x in input().strip().split(" ")]
hasi = 0
cc = []
if W == 1:
    if K == 1:
        print(1)
    else:
        print(0)
    sys.exit()
elif W == 2:
    cccl = [1, 1]
    cc = [1, 1]
elif W == 3:
    cccl = [1, 1, 1]
    cc = [2, 1, 2]
elif W >= 4:
    aW = W - 1
    hW = aW - 2
    nhW = aW - 3
    cc = []
    cccl = []
    for w in range(W):
        nn = max(W - 1 - w - 1, 0)
        nnn = max((W - 1) - nn - 2, 0)
        if w == W -1:
            nnn += 1
        cc.append(erabu(nn) * erabu(nnn))
        cccl.append(erabu(nn) * erabu(nnn-1))

cccl[0] = 0
cccr = cccl[::-1]
d = [[1] + [0 for x in range(W-1)]] + [[0] * W for _ in range(N)]
for i in range(N):
    i += 1
    for j in range(W):
        d[i][j] = (d[i-1][j] * cc[j]) % mod
        if j != 0:
            d[i][j] = (d[i][j] + (d[i-1][j-1] * cccl[j]) )% mod
        if j != W-1:
            d[i][j] = (d[i][j] + (d[i-1][j+1] * cccr[j])) % mod

print(d[N][K-1])


Measured memory_bytes: 3192