akhauriyash/Code-Regression huggingface dataset:
N = int(input())
H_list = list(map(int, input().split()))
A_list = []
H_list.reverse()
k = 0
if N == 1:
    print(0)
else:
    for i in range(N-1):
        if H_list[i] <= H_list[i + 1]:
            k += 1
            A_list.append(k)
        else:
            k = 0
            A_list.append(k)
    if len(A_list) == 0:
        print(k)
    else:
        print(max(A_list))



Measured memory_bytes: 14224
n=int(input())
A=list(map(int,input().split()))
B=[0,0,0,0,0,0,0,0]
red=int(0)
for i in range(n):
    now=int(A[i]/400)
    if now<8:
        B[now]=1
    else:
        red+=1

ans=B.count(1)
if ans==0:
    ans=1
    red-=1
print("{} {}".format(ans,ans+red))

Measured memory_bytes: 3064
#include <iostream>
#include <vector>

using namespace std;

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

  int n;
  cin >> n;

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

  int sum = 0;
  int minNot10 = 1000;
  for (int i = 0; i < n; i++) {
    sum += ss[i];
    if (ss[i] % 10 != 0 && ss[i] < minNot10) minNot10 = ss[i];
  }

  int ans;
  if (sum % 10 == 0 && minNot10 % 10 == 0) {
    ans = 0;
  } else if (sum % 10 == 0) {
    ans = sum - minNot10;
  } else {
    ans = sum;
  }
  cout << ans << endl;
  return 0;
}

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

int main(){
  int n;
  cin>>n;
  
  vector<int> price(n);
  for(int i=0;i<n;i++){
    cin>>price.at(i);
  }
  sort(price.begin(),price.end());
  reverse(price.begin(),price.end());
  int sum=0;
  for(int i=0; i<n;i++){
    sum =sum+price.at(i);
  }
  
  cout<<sum-price.at(0)/2<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <climits>
#include <bitset>
#include <utility>
#include <cstring>
#include <numeric>
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<pair<int,int>> vpii;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvc;
typedef vector<vector<string>> vvs;
#define rep(i,n) for(int i=0;i<n;i++)
#define repll(i,n) for(long long int i=0;i<n;i++)
#define fin(ans) cout<<(ans)<<endl
#define P 1000000007
#define STI(s) atoi(s.c_str())//string to int
#define mp(p,q) make_pair(p,q)
#define Sort(a) sort(a.begin(),a.end())
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
const int INF = INT_MAX;
const long long LLINF = 1LL<<60;
template <typename T_char>
char ToUpper (char cX) { return toupper(cX); }
//g++ -std=c++1z temp.cpp
//./a.exe
ll digit(ll a){
    ll count = 0;
    for (ll i = 0; i < a; i++)
    {   if (a == 0)
        {
            break;
        }else
        {
            a = a/10;
            count++;
        }
    }
    return count;
}
//桁数のカウント
//pow(x,n) == x^n
//sum = accumulate(v.begin(),v.end(),0);
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a;}
ll lcm(ll a, ll b) { return a / gcd(a,   b) * b;}



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

ll a,b,subans,suba,subb;
cin >> a >> b;

subans = min(a/0.08,b/0.1);

for(int i = subans-20;i < subans+20;i++){
    int count = 0;
    suba = i*0.08;
    subb = i*0.1;
    if(suba == a && subb == b){
        cout << i << endl;
        return 0;
    }
}
cout << -1 << endl;



//////////////////////////////////////////////////////
return 0;}

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

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

	vector<double> p(N);
	for(uint32_t i=0; i<N; i++) cin >> p[i];
	
	vector<vector<double>> dp(2, vector<double>(N+1, 1));
	
	for(uint32_t i=1; i<=N; i++) {
		bool ic = i & 1;
		bool ip = !ic;
		
		dp[ic][0] = dp[ip][0] * (1 - p[i-1]);
		//cout << setprecision(3) << dp[ic][0] << " ";
		
		for(uint32_t j=1; j<i; j++) {
			dp[ic][j] = dp[ip][j-1] * p[i-1] + dp[ip][j] * (1 - p[i-1]);
			//cout << setprecision(3) << dp[ic][j] << " ";
		}

		dp[ic][i] = dp[ip][i-1] * p[i-1];
		//cout << setprecision(3) << dp[ic][i] << endl;
	}

	double ans = accumulate(dp[N&1].begin() + N/2 + 1, dp[N&1].end(), (double)0);
	cout << setprecision(10) << ans << endl;
	
	return 0;

}

Measured memory_bytes: 384
#include<iostream>
#include<cmath>
#include<iomanip>
#include<vector>

#define REP(i,s,n) for(int i=s;i<n;i++)
#define rep(i,n) REP(i,0,n)
#define inf (1<<29)
#define eps (1e-8)
#define equals(a,b) (fabs((a)-(b)) < eps)
#define MAX_N 60
#define MAX_M 5010
#define ADD 100000
using namespace std;
typedef long double ld;
typedef long long ll;

ld dp[MAX_N][MAX_M];

int X,Y,Z,N,E,A;
ld roulette[5];
/*
Event 1 : value + ADD
Event 2 : +value
Event 3 : -value
 */
int field[MAX_N];
ld prb;

int main()
{
  while(cin >> X >> Y >> Z,X|Y|Z)
    {
      prb = 1.0/X;
      rep(i,Y+1)field[i] = 0;
      rep(i,Y+1)rep(j,MAX_M)dp[i][j] = -inf;
      dp[0][0] = 1.0;
      rep(i,X)cin >> roulette[i];
    
      rep(i,Z)
	{
	  cin >> N >> E >> A;
	  if(E == 1) field[N] = A + ADD;
	  if(E == 2) field[N] = A;
	  if(E == 3) field[N] = -A; 
	}

      rep(i,Y)//マスの番号
	{
	  rep(j,5001)//所持金
	    {

	      if(equals(dp[i][j],-inf))continue;
	      rep(k,X)//ルーレットの目
		{
		  int next = i + roulette[k];
		  if(next > Y)next = Y;
		  ld cost = dp[i][j];

		  if(field[next] != 0)
		    {
		      if(field[next] >= ADD)
			{
			  next = min(next+field[next]-ADD,Y);
			  if(equals(dp[next][j],-inf))dp[next][j] = 0;
			  dp[next][j] += cost * prb;
			}
		      else if(field[next] < 0)
			{
			  if(equals(dp[next][max(0,j+field[next])],-inf))dp[next][max(0,j+field[next])] = 0;
			  dp[next][max(0,j+field[next])]+= cost*prb ; 
			}
		      else
			{	
			  if(equals(dp[next][j+field[next]],-inf))dp[next][j+field[next]] = 0;
			  dp[next][j+field[next]]+= cost*prb ;
			}
		    }
		  else
		    {
		      if(equals(dp[next][j],-inf))dp[next][j] = 0;
		      dp[next][j]+= cost*prb ;
		    }    
		}
	    }
	}

      ld ans = 0;
      REP(i,1,5001)if(!equals(dp[Y][i],-inf))
	  ans += i * dp[Y][i];

      cout << floor(ans) << endl;

    }
  return 0;
}

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

const int N=19;
int n, m, x, res=1e9;
int c[N], a[N][N];
int sum[N];

bool _check(){
    for(int i=1; i<=m; ++i)
        if(sum[i]<x)
            return false;
    return true;
}

void _try(int i, int cost){
    if(i>n){
        if(_check())
            res=min(res, cost);
        return;
    }

    for(int j=i+1; j<=n+1; ++j){
        for(int u=1; u<=m; ++u)
            sum[u]+=a[j][u];
        _try(j, cost+c[j]);
        for(int u=1; u<=m; ++u)
            sum[u]-=a[j][u];
    }
}

void _input(){
    cin>>n>>m>>x;
    for(int i=1; i<=n; ++i){
        cin>>c[i];
        for(int j=1; j<=m; ++j)
            cin>>a[i][j];
    }
}

void _solve(){
    for(int i=1; i<=n; ++i){
        for(int u=1; u<=m; ++u)
            sum[u]+=a[i][u];
        _try(i, c[i]);
        for(int u=1; u<=m; ++u)
            sum[u]-=a[i][u];
    }
    if(res==1e9)
        res=-1;
}

void _output(){
    cout<<res;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

//    freopen("input.inp", "r", stdin);

    _input();
    _solve();
    _output();

    return 0;
}


Measured memory_bytes: 3652
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
)

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)

	var N int
	scanner.Scan()
	fmt.Sscanf(scanner.Text(), "%d", &N)

	xs := make([]int, N)
	for i := 0; i < N; i++ {
		scanner.Scan()
		fmt.Sscanf(scanner.Text(), "%d", &xs[i])
	}
	sxs := make([]int, N)
	copy(sxs, xs)
	sort.Sort(sort.IntSlice(sxs))
	med1 := sxs[(N-1)/2]
	med2 := sxs[(N-1)/2+1]

	for _, x := range xs {
		if x < med2 {
			fmt.Println(med2)
		} else {
			fmt.Println(med1)
		}
	}
}


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

using namespace std;
typedef long long ll;

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

    vector<int> b(1);
    b[0] = a[0];
    int mini = a[0];
    for (int i = 1; i < N; i++) {
        bool flag = false;
        if (a[i] <= mini) {
            b.push_back(a[i]);
            mini = a[i];
            continue;
        }
            

        for (int j = 0; j < b.size(); j++) {
            if (a[i] > b[j]) {
                b[j] = a[i];
                flag = false;
                break;
            }
            else {
                flag = true;
            }
        }
        if (flag){ 
            b.push_back(a[i]);
            if (mini >= a[i]) mini = a[i];
        }
    }
    
    cout << b.size() << endl;

}


Measured memory_bytes: 1276
N, M, Q = map(int, input().split())
LR = [list(map(int, input().split())) for _ in range(M)]
PQ = [list(map(int, input().split())) for _ in range(Q)]

table = [[0 for _ in range(N + 2)] for _ in range(N + 2)]

for l, r in LR:
	table[l][r] += 1

#for line in table:
#	print(*line)
#print()

for i in range(1, N + 1):
	for j in range(1, N + 1):
		table[i][j] += table[i][j - 1]
for i in range(1, N + 1):
	for j in range(1, N + 1):
		table[i][j] += table[i - 1][j]

#for line in table:
#	print(*line)
#print()

for p, q in PQ:
	#print(table[q][q], table[p - 1][q], table[q][p - 1], table[p - 1][p - 1])
	print(table[q][q] - table[p - 1][q] - table[q][p - 1] + table[p - 1][p - 1])


Measured memory_bytes: 77284
#include <stdio.h>
int main(void){
        int a,b,c,n;
        scanf("%d %d %d",&a,&b,&c);
        n=0;
        if(a>b){
                n=a;
                a=b;
                b=n;
}
        if(a>c){
                n=a;
                a=c;
                c=n;
}
        if(b>c){
                n=b;
                b=c;
                c=n;
}
        printf("%d %d %d\n",a,b,c);
        return 0;
}


Measured memory_bytes: 2108
# C - Average Length
from itertools import permutations


def main():
    temp = 0
    n = int(input())
    plot_list = [list(map(int,input().split())) for _ in range(n)]
    case = list(permutations(range(n)))

    for c in case:
        for i in range(n-1):
            temp += ((plot_list[c[i]][0] - plot_list[c[i+1]][0])**2 + (plot_list[c[i]][1] - plot_list[c[i+1]][1])**2)**0.5

    print(temp/len(case))


if __name__ == '__main__':
    main()

Measured memory_bytes: 8052
#include <bits/stdc++.h>
#define rep(i,n) for (int i = (0); i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(x) (x).begin(),(x).end()
#define rrng(x) (x).rbegin(),(x).rend()
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define show(x) cout << #x << " = " << (x) << endl
#define show2(x,y) cout << #x << " = " << (x) << ", " << #y << " = " << (y) << endl
#define show3(x,y,z) cout << #x << " = " << (x) << ", " << #y << " = " << (y) <<  ", " << #z << " = " << (z) << endl
#define showv(v) rep(i,v.size()) printf("%d%c", v[i], i==v.size()-1?'\n':' ')
#define showv2(v) rep(j,v.size()) showv(v[j])
#define showt(t,n) rep(i,n) printf("%d%c", t[i], i==n-1?'\n':' ')
#define showt2(t,r,c) rep(j,r) showt(t[j],c)
#define showvp(p) rep(i,p.size()) printf("%d %d\n", p[i].first, p[i].second);
#define printv(v) rep(i,v.size()) printf("%d\n", v[i])
#define printt(t,n) rep(i,n) printf("%d\n", t[i])
#define incl(v,x) find(rng(v),x)!=v.end()
#define incls(s,c) s.find(c)!=string::npos
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define bit(n,k) ((n>>k)&1) // nのk bit目
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define uni(x) x.erase(unique(rng(x)),x.end())
#define SP << " " <<
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vs = vector<string>;
using P = pair<int, int>;
using T = tuple<int, int, int>;
using vp = vector<P>;
using vt = vector<T>;
const int mod = 1000000007;
const double EPS = 1e-9;
//const long double EPS = 1e-14;
const int INF = (1<<30)-1;
//const ll INF = (1LL<<62)-1;
#define dame { puts("No"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
inline int in() { int x; scanf("%d",&x); return x;}
//template<class T = int> inline T in() { T x; cin >> x; return (x);}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
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; }

int main () {
  int a, b, c;
  cin >> a >> b >> c;
  int m = max({a,b,c});
  int x;
  if (3*m%2 == (a+b+c)%2) {
    x = m;
  }
  else {
    x = m+1;
  }
  int ans = (3*x - (a+b+c))/2;
  cout << ans << endl;
  return 0;
}

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

using namespace std;
typedef long long int ll;
int a[30];
int main()
{
int n=0;
string s;
cin>>s;
for(int i=0;i<s.size();i++)
{
    if(s[i]=='+') n++;
    else n--;
}
cout<<n;
    return 0;
}


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

int a, b, c;

int main() {
	cin >> a >> b >> c;
	for (int k = 0; k != b; ++k)
		if (k * a % b == c) {
			cout << "YES\n";
			return 0;
		}
	cout << "NO\n";
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
const int N = 100001;
int n,k,a[N],f[N];

int main()
{
    cin >> n >> k;
    for (int i=1; i<=n; i++)
        cin >> a[i];
    //f[0] = 1;
    for (int i=0; i<k; i++)
    {
        for (int j=1; j<=n; j++)
        {
            int x = i + a[j];
            if (x <= k)
            {
                f[x] = max(f[x], 1 - f[i]);
            }
        }
    }
    cout << ((f[k] == 0) ? "Second" : "First");
    return 0;
}


Measured memory_bytes: 640
/*
我的心脏怦怦跳，监管者就在附近
*/
#pragma GCC optimize(3,"Ofast","inline")
#include<bits/stdc++.h>
#include<string>
#include<iostream>
#include<cmath>
#include<set>
#include<stack>
#include<queue>
#include<unistd.h>
#include<stdio.h>
#include<cstring>
#define random(a,b) (rand()%(b-a+1)+a)
using namespace std;
bool prime(int x){
	 int i;
	 if(x<2) return 0;
	 for(i=2;i*i<=x;i++){
		if(x%i==0){return 0;}
	 }
	 return 1;
}
int s,n,a[1001];
void dfs(int b,int e,int p){
	int i;
	if(p>3){
		s++;
		
	}
	else{
		for(i=1;i<=n;i++){
			a[p]=i;
			dfs(1,3,p+1);
		}
	}
}
int main()
{
	cin>>n;
	dfs(1,3,1);
	cout<<s;
	return 0;
}


Measured memory_bytes: 256
while True:
    n = int(input())
    if n == 0:
        break
    a = list(map(float, input().split()))
    ave = sum(a)/n
    sa2 = 0
    for i in range(n):
        sa2 += (a[i]-ave)**2
    ans = (sa2/n)**0.5
    print (ans)
        


Measured memory_bytes: 5724
n=int(input())
w=list(map(int,input().split()))
ans=abs((sum(w[0:1]))-sum(w[1:n]))
for t in range(2,n):
    if abs((sum(w[0:t]))-sum(w[t:n])) < ans:
        ans = abs((sum(w[0:t]))-sum(w[t:n]))
print(ans)


Measured memory_bytes: 3060
#include<stdio.h>

int main(){
//    printf(" ");
    int a,b,c,d;
    scanf("%d %d %d %d",&a,&b,&c,&d);
    if(a*b>=c*d){
        printf("%d\n",a*b);
    }else{
        printf("%d\n",c*d);
    }
}


Measured memory_bytes: 128
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    long k = sc.nextLong();
    List<Integer> list = new ArrayList<>();
    Map<Integer, Long> map = new HashMap<>();
    for(int i = 0; i < n; i++){
      int a = sc.nextInt();
      int b = sc.nextInt();
      if(!map.containsKey(a)){
        map.put(a, 0L);
        list.add(a);
      }
      map.put(a, map.get(a) + b);
    }
    long sum = 0;
    Collections.sort(list);
    for(int i : list){
      sum += map.get(i);
      if(sum >= k){
        System.out.println(i);
        System.exit(0);
      }
    }
  }
}


Measured memory_bytes: 96048
#include <cmath>
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <iomanip>
#include <map>
#include <stack>
#include <queue>

using namespace std;

typedef long long ll;



int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a[3],n;
    cin>>a[0]>>a[1]>>a[2]>>n;
    
    int ans=0;
    for(int i=0;i<=n/a[0];i++){
        for(int j=0;j<=(n-i*a[0])/a[1];j++){
            if ((n-a[0]*i-a[1]*j)%a[2]==0) ans++;
        }
    }
    
    cout<<ans<<endl;
}

Measured memory_bytes: 256
using System;

public class Hello
{
    public static void Main()
    {
        string[] line = Console.ReadLine().Trim().Split(' ');
        var h = int.Parse(line[0]);
        var w = int.Parse(line[1]);
        var buf = new string[h];
        var ss = new string('.', w);
        var a = new bool[w];
        var p = 0;
        for (int i = 0; i < h; i++)
        {
            var s = Console.ReadLine().Trim();
            if (s != ss) buf[p++] = s;
            for (int j = 0; j < w; j++)
                if (s[j] == '#') a[j] = true;
        }
        for (int i = 0; i < p; i++)
            for (int j = 0; j < w; j++)
                if (a[j])
                    if (j != w - 1) Console.Write(buf[i][j]);
                    else Console.WriteLine(buf[i][j]);
                else if (j == w - 1) Console.WriteLine();
    }
}


Measured memory_bytes: 13140
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef vector<int> VI;

template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()


int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    vector<int> num(1e6+1, 0);
    rep (i, n) {
        scanf("%d", &a[i]);
        num[a[i]]++;
    }
    sort(all(a));
    int ans = 0;
    vector<vector<int>> each_divs;
    rep (i, n) {
        vector<int> tmp_div;
        for (int j = 1; j * j <= a[i]; ++j) {
            if (a[i] % j == 0) {
                tmp_div.push_back(j);
                if (j * j != a[i]) {
                    tmp_div.push_back(a[i] / j);
                }
            }
        }
        if (num[a[i]] >= 2) {
            continue;
        }
        bool flag = true;
        for (auto e: tmp_div) {
            if(e == a[i]) {
                continue;
            }
            if (num[e]) {
                flag = false;
                break;
            }
        }
        if (flag) {
            ans++;
        }
    }
    cout << ans << endl;
}




Measured memory_bytes: 8008
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#define rep(i,n) for(int i=0;i<n;i++)
const long long MOD = 1000000007;
typedef pair<int,int> P;
typedef long long ll;
ll n,m,k,ans;
string s;


int main(){
  cin >> n >> s;
  rep(i,s.size()){
    int num = s.at(i)-'A';
    s.at(i) = ((num+n)%26)+'A';
  }
  cout << s << "\n";
}

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


using namespace std;

int main(){
  int A,B;
  cin >> A;
  cin >> B;

  int a=A+B;
  int b=A-B;
  int c=A*B;
  vector<int> l;
  l.push_back(a);
  l.push_back(b);
  l.push_back(c);

  int max = *max_element(l.begin(), l.end());


	
	cout << max << endl;

}

Measured memory_bytes: 256
import numpy as np
import math
import sys
n, h = map(int, input().split())
A = []
B = []
for _ in range(n):
    a, b = map(int, input().split())
    A.append(a)
    B.append(b)

max_a = max(A)
  
C = list(np.array(B)[max_a <= np.array(B)][::-1])
C.sort(reverse=True)

cnt = 0
for c in C:
    if h <= 0:
        break
    cnt += 1
    h -= c

if h > 0:
    cnt += math.ceil(h / max_a)

print(cnt)

Measured memory_bytes: 24508
import java.util.*;
class Main {
    public static void main(String[] args) {
	Scanner sc = new Scanner(System.in);
	int N = Integer.parseInt(sc.next());
	int M = Integer.parseInt(sc.next());
	int[] cost = {0, 2, 5, 5, 4, 5, 6, 3, 7, 6};
	int[] a = new int[M];
	int[] zantei = new int[N+1];
	for(int i = 0; i<N; i++) {
	    zantei[i] = Integer.MIN_VALUE;
	}
	for(int i = 0; i<M; i++) {
	    a[i] = Integer.parseInt(sc.next());
	}
	zantei[0] = 0;
	for(int i = 0; i<N+1; i++) {
	    for(int j = 0; j<M; j++) {
		if(i>=cost[a[j]]) {
		    zantei[i] = Math.max(zantei[i-cost[a[j]]]+1, zantei[i]);
		}
	    }
	}
	//	System.out.println(zantei[N]);
	StringBuilder sb = new StringBuilder();
	int cnt = N;
	for(int i = zantei[N]; i>0; i--) {
	    int x = 0;
	    for(int j = 0; j<M; j++) {
		if(cnt>=cost[a[j]]) {
		    if( zantei[cnt-cost[a[j]]] == i-1) {
			x = Math.max(a[j],x);
		    }
		}
            }
	    sb.append(x);
	    cnt = cnt - cost[x];
	    //  System.out.println("cnt: "+ cnt + " " + x + " " + cost[x]);
	}
	System.out.println(sb.toString());

    }
}

Measured memory_bytes: 23636
import sys
sys.setrecursionlimit(10**7)
N = int(input())
L = [-1 for i in range(N)]
flg = [0 for i in range(N)]
M = [[] for i in range(N)]
for i in range(N-1):
  u, v, w = map(int, input().split())
  M[u-1].append([v-1, w%2])
  M[v-1].append([u-1, w%2])
L[0] = 0
def dist(m, d):
  L[m] = d % 2
  for i in M[m]:
    if L[i[0]] == -1:
      dist(i[0], i[1] + d)
dist(0, 0)
for i in range(N):
  print(L[i])

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

typedef long long ll;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<vector<vector<ll>>> vvvll;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<vector<vector<bool>>> vvvb;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef vector<vpll> vvpll;
typedef vector<double> vd;
typedef vector<vd> vdd;

#define FOR(i,x,y) for(ll i=(ll)x; i<(ll)y; ++i)
#define REP(i,y) FOR(i, 0, y)
#define RFOR(i,x,y) for(ll i=(ll)x; i>=(ll)y; --i)
#define RREP(i,x) RFOR(i, x, 0)
#define ALL(a) a.begin(), a.end()
#define pb push_back
#define debug_print(x...) cerr << "line " << __LINE__ << " : "; debug_print_in(x);

template <typename First>
void debug_print_in(First first){
  cerr << first << endl;
  return;
}

template <typename First, typename... Rest>
void debug_print_in(First first, Rest... rest){
  cerr << first << " ";
  debug_print_in(rest...);
  return;
}

void IN(void){
  return;
}

template <typename First, typename... Rest>
void IN(First& first, Rest&... rest){
  cin >> first;
  IN(rest...);
  return;
}

template <typename First>
void OUT(First first){
  cout << first << endl;
  return;
}

template <typename First, typename... Rest>
void OUT(First first, Rest... rest){
  cout << first << " ";
  OUT(rest...);
  return;
}

template<class t, class u> void chmax(t&a,u b){if(a<b)a=b;};
template<class t, class u> void chmin(t&a,u b){if(a>b)a=b;};
int popcount(int t){return __builtin_popcount(t);} //GCC
int popcount(ll t){return __builtin_popcountll(t);} //GCC

template <typename T>
void vec_print(vector<T> VEC){
  REP(i, VEC.size()){
    cerr << VEC[i] << " ";
  }
  cerr << endl;
};

template <typename T>
void mat_print(vector<vector<T> > MAT){
  REP(i,MAT.size()){
    REP(j,MAT[i].size()){
      cerr << MAT[i][j] << " ";
    }
    cerr << endl;
  }
};

constexpr int INF = (1<<30);
constexpr ll INFLL = 1LL<<62;
constexpr long double EPS = 1e-12;
constexpr ll MOD = (ll)((1E+9)+7);

int main(){
  cin.tie(0); // cut the cin and cout (default, std::flush is performed after std::cin)
  ios::sync_with_stdio(false); // cut the iostream and stdio (DON'T endl; BUT "\n";)

  ll a, b, h;
  IN(a);
  IN(b);
  IN(h);
  OUT(((a+b)*h)/2);

  return 0;
}

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

using namespace std;
typedef long long ll;

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin >> n;
    vector<int> a(n);
    int x=0;
    for(int i=0;i<n;i++)
    {
        cin >> a[i];
        x^=a[i];
    }
    for(int i=0;i<n;i++) cout << (x^a[i]) << " \n"[i==n-1];
    return 0;
}


Measured memory_bytes: 3988
// 新規マクロ確認用の提出
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define bit(n) (1<<(n))
#define fi first
#define se second
#define ii(x) int x; cin >> (x)
#define ii2(x, y) int x, y; cin >> (x) >> (y)
#define ii3(x, y, z) int x, y, z; cin >> (x) >> (y) >> (z)
#define yn(x, ok, ng) cout << ((x)?(ok):(ng)) << endl
using namespace std;

int main()
{
ii2(S,W);
yn(S <= W, "unsafe", "safe");
return 0;
}

Measured memory_bytes: 3620
/*
    Author : zzugzx
    Lang : C++
    Blog : blog.csdn.net/qq_43756519
*/
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define endl '\n'
#define SZ(x) (int)x.size()
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int mod = 1e9+7;
//const int mod = 998244353;
const double eps = 1e-10;
const double pi = acos(-1.0);
const int maxn = 1e6+10;
const ll inf = 0x3f3f3f3f;
const int dir[][2]={{0, 1}, {1, 0}, {0, -1}, {-1, 0}, {1, 1}, {1, -1}, {-1, 1}, {-1, -1}};


char g[10][10];
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
//  freopen("in.txt", "r", stdin);
//  freopen("out.txt", "w", stdout);
    int n, m, k;
    cin >> n >> m >> k;
    for (int i = 0; i < n; i++)
        for (int j = 0; j < m; j++)
            cin >> g[i][j];
    int ans = 0;
    for (int st1 = 0; st1 < (1 << n); st1++)
        for (int st2 = 0; st2 < (1 << m); st2++){
            int tmp = 0;
            for (int i = 0; i < n; i++)
                for (int j = 0; j < m; j++)
                    if (g[i][j] == '#' && !((st1 >> i) & 1) && !((st2 >> j) & 1))tmp++;
            if (tmp == k) ans++;
        }
    cout << ans;

    return 0;
}


Measured memory_bytes: 3648
#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <map>
#include <cmath>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>

int main(int argc, char *argv[]){
    std::string S;
    std::cin >> S;
    int len = S.size();
    int count = 0;
    for(int i=0; i<len/2; ++i){
        if(S[i] != S[len-1-i]){
            ++count;
        }
    }
    std::cout << count << std::endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>

#define MOD 1000000007

using namespace std;

typedef long long ll;

int main() {
    ll h, w;
    scanf("%lld%lld", &h, &w);
    vector< vector<char> > a(h + 1, vector<char>(w + 1, '#'));
    vector< vector<ll> > dp(h + 1, vector<ll>(w + 1, 0));
    dp.at(1).at(1) = 1;
    for (ll i = 1; i <= h; ++i) scanf("%s", a.at(i).begin() + 1);
    for (ll i = 1; i <= h; ++i) for (ll j = (i == 1 ? 2 : 1); j <= w; ++j) if (a.at(i).at(j) == '.') dp.at(i).at(j) = (dp.at(i - 1).at(j) + dp.at(i).at(j - 1)) % MOD;
    printf("%lld\n", dp.back().back());
    return 0;
}


Measured memory_bytes: 9088
#include<stdio.h>

int main(){
  char moji[12];
  int i,j;
  for(i=0;i<12;i++){
      scanf("%c",&moji[i]);
  }

  printf("%c",moji[0]);
  printf("%c",moji[5]);
  printf("%c",moji[10]);
  return 0;
}


Measured memory_bytes: 128
import sys,re,copy
input = sys.stdin.readline

N,K=[int(x) for x in input().strip().split()]

f=1
cnt=0
S=[]
r=0
for s in input().strip():
    s=int(s)
    if s==f:
        cnt+=1
    else:
        r+=cnt
        S.append(r)
        cnt=1
        f=1-f
else:
    r+=cnt
    S.append(r)
if len(S)%2==0:
    S.append(r)

Max=0
i=0
if len(S)==1:
    Max=S[0]
else:
    while True:
        if i >=len(S):
            break
        r=i+2*K
        cnt=S[min(r,len(S)-1)]-S[max(i-1,0)]
        if cnt > Max:
            Max = cnt
        i+=2

print(Max)

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

using namespace std;

int main()
{
    ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int k,x;
    cin>>k>>x;
    if (k*500>=x)
        cout<<"Yes";
    else
        cout<<"No";

    return 0;
}


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

#define lint long long
#define P pair<int, lint>

const lint INF = 1E15;

int main() {
    int A, B;
    cin >> A >> B;

    string S;
    cin >> S;

    for(int i = 0; i < A + B + 1; ++i){
        if(i == A){
            if(S[i] != '-'){
                cout << "No" << endl;
                return 0;
            }
        } else {
            if(S[i] == '-'){
                cout << "No" << endl;
                return 0;
            }
        }
    }
    cout << "Yes" << endl;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = Integer.parseInt(sc.next());

		int ans = 0;
		for (int i=0; i<n; i++){
			int a = Integer.parseInt(sc.next());
			while (a%2 == 0 && a != 0){
				a /= 2;
				ans += 1;
			}
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 32128
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
using namespace std;

#define rep(i,x) for(ll i=0;i<x;i++)
#define repn(i,x) for(ll i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 1000000007;
const ll MAX = 1000001;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

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

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

struct edge {
	ll ind;
	ll fr;
	ll to;
	ll d;
};


///////////////////////////

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

	ll N = S.size();

	ll ans = 0;
	ll w = 0;

	rep(i, N) {
		if (S[i] == 'B') { w++; }
		else { ans += w; }
	}

	cout << ans;

	system("PAUSE");

}





Measured memory_bytes: 764
package main

import "fmt"

func main() {
	var n, T int
	fmt.Scan(&n, &T)

	cost := 1001
	for i := 0; i < n; i++ {
		var c, t int
		fmt.Scan(&c, &t)
		if T >= t && cost > c {
			cost = c
		}
	}
	if cost == 1001 {
		fmt.Println("TLE")
		return
	}
	fmt.Println(cost)
}


Measured memory_bytes: 512
/// Author: Sarfaraz Alam
# include <bits/stdc++.h>
# define pb push_back
# define ll long long

# define fi first
# define se second
# define all(vc) vc.begin(),vc.end()
# define speed ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
# define DEBUG
typedef unsigned long long int ull;
using namespace std;

const int N = 1e5 + 7;
const int mod = 1e9 + 7;

int n, a[N], ans = 1, x;
#include<cmath>


int main()
{
    speed;
    #ifdef DEBUGfd
        freopen("in.txt", "r", stdin);
        freopen("out.txt", "w", stdout);
    #endif // DEBUG

    //Code begins
    ull n;
    cin>>n;
    if(n!= 1)
    {
    ull t;
    ull min = ceil(log10(n));
     if(min % 10 == 0)
    min += 1;

    for(ull i = 1; i*i<=n; i++)
    {
    //  cout<<"stuck insiet the loop\n";
      if(n%i == 0)
      {
        int ta = ceil(log10(i));
        if(i% 10 == 0) ta += 1;
        int tb = ceil(log10(n/i));
        if((n/i) % 10 == 0) tb += 1;
        t =  max(ta, tb);

        if(t<min)
        min = t;
      }
    }

    cout<<min<<endl;
  }
  else
  cout<<1<<endl;







    return 0;
}


Measured memory_bytes: 256
import itertools, math

N = int(input())
K = int(input())

def cmb(n, r):
    if r < 0 or r > n:
        return 0
    return (math.factorial(n) // math.factorial(r)) // math.factorial(n-r)

def ans_when_K1(N):
    max_digit = len(str(N))
    return 9 * (max_digit-1) + int(str(N)[0])

def ans_when_K2(N):
    max_digit = len(str(N))
    if max_digit < 2:
        return 0

    digit = 2
    ans = 0
    while digit < max_digit:
        ans += 9 * (digit-1) * 9
        digit += 1

    second_non_zero_idx = -1
    for i in range(1, max_digit):
        if str(N)[i] != "0":
            second_non_zero_idx = i
            break

    ans += (int(str(N)[0]) -1) * (digit-1) * 9
    if second_non_zero_idx != -1:
        ans += ans_when_K1(int(str(N)[second_non_zero_idx:]))
    return ans

def ans_when_K3(N):
    max_digit = len(str(N))
    if max_digit < 3:
        return 0

    digit = 3
    ans = 0
    while digit < max_digit:
        ans += 9 * cmb(digit-1, 2) * 9 * 9
        digit += 1

    second_non_zero_idx = -1
    for i in range(1, max_digit):
        if str(N)[i] != "0":
            second_non_zero_idx = i
            break

    ans += (int(str(N)[0]) -1) * cmb(digit-1, 2) * 9 * 9
    if second_non_zero_idx != -1:
        ans += ans_when_K2(int(str(N)[second_non_zero_idx:]))
    return ans

if K == 1:
    print(ans_when_K1(N))
elif K == 2:
    print(ans_when_K2(N))
else:
    print(ans_when_K3(N))

Measured memory_bytes: 3188
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
int main(){
	string a;
	cin >> a;
	int sum,l=a.size();
	for(int n=0;n<l;n++)
		sum=(sum+a[n]-'0')%9;
	if(sum==0)cout<< "Yes";
	else cout<<"No";
	return 0;
}

Measured memory_bytes: 3748
#include <iostream>
#include <stdio.h>
#include <cstring>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string>
#include <stdlib.h>
#include <queue>
#include <utility>
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ll long long
#define LL long long
#define INF 100000000
#define mod 1000000007
using namespace std;
int keta(int n,int k){return (n/int(pow(10,double(k-1)))) % 10;} //nの下からk桁目
ll gcd(ll n,ll m){
	if(n<m){ll a=m;m=n;n=a;}
	ll r=n%m;
	while(r!=0){
		n=m;
		m=r;
		r=n%m;
	}
	return m;
}
ll lcm(ll n,ll m){
	return n*m/gcd(n,m);
}

int main(){
	int n;
	cin>>n;
	//vector<char> a(n),b(n);
	char a[53],b[53];
	cin>>a>>b;
	ll ans=1;
	int i=0;
	int t=0;
	if(a[i]==b[i]){
		ans*=3;
		i++;
		t=1;
	}else{
		ans*=6;
		i+=2;
		t=2;
	}
	while(a[i]!='\0'){
		if(a[i]==b[i]){
			if(t==1){
				ans*=2;
			}
			if(t==2){
				ans*=1;
			}
			t=1;
			i++;
		}else{
			if(t==1){
				ans*=2;
			}
			if(t==2){
				ans*=3;
			}
			t=2;
			i+=2;
		}
		ans%=mod;
	}
	cout<<ans<<endl;

}



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

int main(void) {
    int n, k;
    cin >> n >> k;
    int array[n];
    for(int i = 0; i < n; i ++){
        cin >> array[i];
    }
   
    
    sort(array, array + n);
    
    
    int array_2[n - k + 1];
    for(int i = 0; i < n - k + 1; i ++){
        array_2[i] = array[k - 1 + i] - array[i];
        
    }
    int min = array_2[0];
    for(int i = 1; i < n - k + 1; i ++){
        if(min > array_2[i]){
            min = array_2[i];
        }
    }
    cout << min << endl;
}


Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

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

using std::cin;
using std::cout;
using std::endl;
using std::string;
using std::vector;

int main() {
  int N, K;
  cin >> N >> K;

  vector<int> l(N);
  rep(i, N) {
    cin >> l[i];
  }

  std::sort(l.begin(), l.end(), std::greater<int>());

  int sum = 0;
  rep(i, K) {
    sum += l[i];
  }

  cout << sum << endl;
  
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (ll i = 0; i < n; ++i)
#define sz(x) int(x.size())
#define ALL(c) (c).begin(), (c).end()
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v, x) (std::find(v.begin(), v.end(), x) != v.end())
#define FORV(i, v) for (auto i = v.begin(); i != v.end(); i++)
using namespace std;

using ll = int64_t;

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; }
const int INF = 1'001'001'001;
const ll INFL = (1LL<<60);
const double eps = (1e-9);

const ll mod = 1e9 + 7;

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

  ll N, K;
  cin >> N >> K;

  if (K == 0) {
    cout << N * N << endl;
    return 0;
  }

  ll ans = 0;
  for (ll b = K; b <= N; b++) {
    ans += (b - K) * (N / b) + max(ll(0), N % b - K + 1);
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
A = int(input())
B = int(input())
C = int(input())
X = int(input())

cnt = 0

for i in range(A+1):
    for j in range(B+1):
        for k in range(C+1):
            tot = 500*i + 100*j + 50*k
            if tot-X == 0:
                cnt += 1
print(cnt)

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

#define int long long
#define pb push_back
#define all(a) begin(a), end(a)
#define deb(x) cout << #x << " = " << x << endl
#define debu(x, y) cout << "( " << #x << ", " << #y << " ) = ( " << x << ", " << y << " )" << endl

typedef long long ll;
ll mod=1000000007;

template <typename T> vector<T> readVector(int n) { vector<T> res(n); for (int i = 0 ; i < n ; i++) cin >> res[i]; return res; }

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    string s;
    cin >> s;
    int sum = 0;
    for(int i=0; i<s.length(); i++) {
        sum += (s[i] - '0');
    }
    if(sum%9 == 0) cout << "Yes";
    else cout << "No";
    return 0;
}


Measured memory_bytes: 3736
#include<bits/stdc++.h>
#define rep(i,m) for(long long i=0; i<m; i++)
#define per(i,m) for(long long i=m-1; i>=0; i--)
#define FOR(i,n,m) for(long long i=n; i<m; i++)
#define ROF(i,n,m) for(long long i=m-1; i>=n; i--)
#define SORT(v,n) do{sort(v,v+n);reverse(v,v+n);}while(0)
#define all(x) (x).begin(),(x).end()
#define EPS (1e-7)
#define INF (1e18)
#define PI (acos(-1))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
using namespace std;
typedef long long ll;
const ll MOD = 1000000007;
typedef pair<ll, ll> LP;

ll POW(ll x,ll n){
  if(n==0)return 1;
  if(n%2==0)return POW(x*x,n/2)%MOD;
  return x%MOD*POW(x,n-1)%MOD;
}

ll POW2(ll x,ll n){
  if(n==0)return 1;
  if(n%2==0)return POW2(x*x,n/2);
  return x*POW2(x,n-1);
}

ll gcd(ll u, ll v) {
  ll r;
  while (0 != v) {
    r = u % v; u = v; v = r;
  }
  return u;
}
 
ll KAI(ll m)
{
  if(m<0) return 0;
  if(m==0) return 1;
  return m*KAI(m-1)%MOD;
}
 
ll KAI2(ll m)
{
  if(m<0) return 0;
  if(m==0) return 1;
  return m*KAI2(m-1);
}

ll extGCD(ll a, ll b, ll &x, ll &y) {
    if (b == 0) {
        x = 1;
        y = 0;
        return a;
    }
    ll d = extGCD(b, a%b, y, x);
    y -= a / b * x;
    return d;
}
 
inline ll mod(ll a, ll m) {
    return (a % m + m) % m;
}
 
ll modinv(ll a) {
    ll x, y;
    extGCD(a, MOD, x, y);
    return mod(x, MOD);
}
 
ll COM(ll m,ll n)
{
  if(m<n) return 0;
  if(n<0) return 0;
  if(n==0) return 1;
  if(m==n) return 1;
  return KAI(m)%MOD*modinv(KAI(n)%MOD*KAI(m-n)%MOD)%MOD;
}

ll COM2(ll m,ll n)
{
  if(m<n) return 0;
  if(n<0) return 0;
  if(n==0) return 1;
  if(m==n) return 1;
  return KAI2(m)/KAI2(n)/KAI2(m-n);
}

ll DEC(ll x,ll m,ll n)
{
  return x%POW(m,n+1)/POW(m,n);
}

ll keta(ll x,ll n)
{
  if(x==0)return 0;
  return keta(x/n,n)+1;
}

ll DIV(ll x,ll n)
{
  if(x==0)return 0;
  return x/n+DIV(x/n,n);
}

ll ORD(ll x,ll n)
{
  if(x==0)return INF;
  if(x%n!=0)return 0;
  return 1+ORD(x/n,n);
}

int main()
{
  ll n;
  string s,t;
  cin >> n >> s >> t;
  rep(i,n){
    FOR(j,i,n){
      if(s[j]!=t[j-i])goto A;
    }
    printf("%lld",n+i);
    return 0;
    A:;
  }
  printf("%lld",2*n);
}

Measured memory_bytes: 256
package main

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

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

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

// min, max, asub, absなど基本関数
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func asub(a, b int) int {
	if a > b {
		return a - b
	}
	return b - a
}

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

func main() {
	sc.Split(bufio.ScanWords)
	K, A, B := getInt(), getInt(), getInt()

	if A+1 >= B {
		out(K + 1)
		return
	}

	k := K - (A - 1)
	if k < 0 {
		out(K + 1)
		return
	}
	// out(k, B, A, k/2, k%2)

	// out(A, (B-A)*(k/2), k%2)
	ans := A + (B-A)*(k/2) + k%2

	out(ans)
}


Measured memory_bytes: 640
#include <iostream>
#include <numeric>
#include <vector>
#include <cmath>
#include <string>
#include <algorithm>
#include <set>
#include <map>
using namespace std;
using ll=long long;
#define rep(i,a,b) for(ll i=a;i<b;i++)
inline constexpr int intpow(ll a,ll b){
    if(b==0) return 1;
    ll ans=intpow(a,b/2);
    return ans*ans*(b&1?a:1);
}
int main(){
    string n;
    cin>>n;
    int s=0,l=n.size();
    int t=stoi(n.substr(0,l));
    int c=t;
    rep(i,0,l){
        s+=c/intpow(10,l-1-i);
        c-=(c/intpow(10,l-1-i))*intpow(10,l-1-i);
    }
    if(t%s==0) cout<<"Yes";
    else cout<<"No";
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n;
  cin >> n;
  long long start,nowstep,nowscore=0,ans=0;
  cin >> start;
 for(int i=1;i<n;i++){
    cin >> nowstep;
   if(nowstep > start){
     if(nowscore > ans){
       ans = nowscore;
     }
     nowscore = 0;
   }else{
     nowscore++;
   }
   start = nowstep;
 }
  if(nowscore > ans){
       ans = nowscore;
   }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<set>
#include<map>
#include<queue>
#include<cmath>
#define REP(i,a) for (int i = 0;i < (a);++i)
#define FOR(i,a,b) for (int i = (a);i < (b); ++i)
#define FORR(i,a,b) for (int i = (a);i >= (b); --i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SORT(list) sort(ALL((list)));
#define MOD 1000000007
using namespace std;
using ll = long long;
int main(){
    int n,k;
    cin >> n >> k;
    vector<int>p(n);
    REP(i,n)cin >> p[i];
    int answer = 0;
    SORT(p);
    REP(i,k)answer+=p[i];
    cout << answer << endl;
    
    return 0;
}

Measured memory_bytes: 3616
import Control.Monad
import Data.List
import Data.Maybe

earliest :: Int -> Int -> Int -> String -> Maybe [Int]
earliest i k c [] = Just []
earliest i k c (s:ss)
  | k > 0 =
    case s of 
      'o' -> if failure 
          then Nothing 
          else  do
             z <- earliest (i + c + 1) (k - 1) c nextStr
             return $ i : z
      'x' -> earliest (i + 1) k c ss
  | otherwise =
    Just []
  where 
    nextStr = drop c ss
    failure = nextStr == [] && k > 1

latest :: Int -> Int -> Int -> String -> Maybe [Int]
latest i k c s = getLatest (earliest i k c $ reverse s)
  where 
    getLatest :: Maybe [Int] -> Maybe [Int]
    getLatest (Just ear) = Just $ reverse $ map (length s  + 1 -) ear
    getLatest Nothing = Nothing

solve :: Int -> Int -> Int -> String -> Maybe [Int]
solve n k c s = do
      ear <- earliest 1 k c s
      lat <- latest 1 k c s
      return $ getWorkingDays ear lat
  where 
    getWorkingDays [] _ = []
    getWorkingDays  _ [] = []
    getWorkingDays (e:es) (l:ls) = if (e == l) then e : getWorkingDays es ls else getWorkingDays es ls

main = do
  (n:k:c:_) <- (map read . words) <$> getLine
  s <- getLine
  maybe (putStr "") (putStr . intercalate "\n" . map show) (solve n k c s)


Measured memory_bytes: 58864
import java.util.Arrays;
import java.util.Scanner;
 
public class Main {

	public static final MyScanner in = new MyScanner();

	public static void main(String[] args) {

		int N = in.nextInt();
		int[] A = new int[N];
		for(int i=1;i<N+1;i++) {
			int p = in.nextInt();
			A[p-1] = i;
		}

		StringBuffer s = new StringBuffer();
		s.append(A[0]);
		for(int i=1;i<N;i++) {
			s.append(" ");
			s.append(A[i]);
		}
		System.out.println(s.toString());
	}

	public static class MyScanner{
		Scanner sc = new Scanner(System.in);
		String nextLine() {return sc.nextLine();}
		String next() {return sc.next();}
		int nextInt() {return Integer.valueOf(sc.next());}
		long nextLong() { return Long.valueOf(sc.next());}
	}
}

Measured memory_bytes: 48016
import java.util.Scanner;

class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        while(true){
            int h = sc.nextInt();
            int w = sc.nextInt();
            String pushs = "";
            
            if(h == 0 && w == 0){
                break;
            } else{
                for(int i = 0; i < h; i++){
                    pushs = "";
                    for(int j = 0; j < w; j++){
                        if((i+j)%2 == 0){
                            pushs += "#";
                        } else {
                            pushs +=".";
                        }
                    }
                    System.out.println(pushs);
                }
                System.out.println("");
            }
        }
    }
}



Measured memory_bytes: 55520
#include <algorithm>
#include <complex>
#include <cstdlib>
#include <ctime>
#include <time.h>
#include <iomanip>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <numeric>
#include <limits>
#include <type_traits>


using namespace std;
#define SAY_YES cout << "YES" << endl;
#define SAY_Yes cout << "Yes" << endl;
#define SAY_NO cout << "NO" << endl;
#define SAY_No cout << "No" << endl;
#define IFYES(TRUE_OR_FALSE)   \
    if (TRUE_OR_FALSE)         \
    {                          \
        cout << "YES" << endl; \
    }                          \
    else                       \
    {                          \
        cout << "NO" << endl;  \
    }
#define IFYes(TRUE_OR_FALSE)   \
    if (TRUE_OR_FALSE)         \
    {                          \
        cout << "Yes" << endl; \
    }                          \
    else                       \
    {                          \
        cout << "No" << endl;  \
    }
#define IFyes(TRUE_OR_FALSE)   \
    if (TRUE_OR_FALSE)         \
    {                          \
        cout << "yes" << endl; \
    }                          \
    else                       \
    {                          \
        cout << "no" << endl;  \
    }
#define DEBUG_OUTPUT_ARRAY(XXX, ONE)                            \
    for (int i = 0; i < (ONE); i++)                             \
    {                                                           \
        cout << "DEBUG: i = " << i << " -> " << XXX[i] << endl; \
    }
#define DEBUG_OUTPUT_ARRAY2(XXX, ONE, TWO)                             \
    for (int i = 0; i < (ONE); i++)                                    \
    {                                                                  \
        cout << "<<< i = " << i << " >>>" << endl;                     \
        for (int j = 0; j < (TWO); j++)                                \
        {                                                              \
            cout << "DEBUG: j = " << j << " -> " << XXX[i][j] << endl; \
        }                                                              \
    }
#define DEBUG_OUTPUT_ARRAY2_BOX(XXX, ONE, TWO) \
    for (int i = 0; i < (ONE); i++)            \
    {                                          \
        cout << i << "  ";                     \
        for (int j = 0; j < (TWO); j++)        \
        {                                      \
            cout << XXX[i][j] << " ";          \
        }                                      \
        cout << endl;                          \
    }

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


const long long int mod = 1000000007;
const long long int INF = 1e18;
const long double PI=3.14159265358979323; 

long long int N,M,K,A,C,B,res=0,L[2005]={},Lsum[4005]={};


int main()
{
    cout << fixed << setprecision(18);
    cin>>A>>B>>C;
    for(long long int i = 1; i <= B; i++){
        if((A*i)%B==C){cout<<"YES"<<endl;return 0;}
    }
    cout<<"NO"<<endl;
}    


Measured memory_bytes: 256