akhauriyash/Code-Regression huggingface dataset:
import math

def func(n, a, b, v):
    v.sort()
    v.reverse()
    target = v[a - 1]
    count = 0
    innerCount = 0
    for i in range(n):
        if v[i] == target:
            if i < a:
                innerCount += 1
            count += 1
    # aつすべてがv[i] == targetの場合
    if v[0] == target:
        out = 0
        for i in range(a, min(count, b) + 1):
            out += math.factorial(count) \
                   // (math.factorial(count - i)
                       * math.factorial(i))
        print(sum(v[:a])/a)
        print(out)
    elif v[a-1] == v[a]:
        print(sum(v[:a])/a)
        print(math.factorial(count)
              // (math.factorial(count - innerCount)
                  * math.factorial(innerCount)))
    else:
        print(sum(v[:a])/a)
        print(1)
n, a, b = [int(i) for i in input().split()]
v = [int(i) for i in input().split()]
func(n, a, b, v)
"""
func(5, 2, 2, [5, 4, 3, 2, 1])
print()
func(4, 2, 3, [20, 10, 10, 10])
print()
func(5, 1, 5, [1000000000000000, 999999999999999, 999999999999998, 999999999999997, 999999999999996])
print()
func(50, 1, 50, [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1])
# print("func({}, {}, {}, {})".format(n, a, b, v))
"""


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

using namespace std;

typedef long long LL;

#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))
#define ALL(a)  (a).begin(),(a).end()
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

#define dump(x)  cerr << #x << " = " << (x) << endl;

map<int, int> get_primes(int num, map<int, int> init) {
  for (int i = 2; i*i <= num; ++i) {
    if (num % i == 0) {
      int count = 0;
      while (num % i == 0) {
        num /= i;
        count++;
      }
      init[i] += count;
    }
  }
  if (num > 1) init[num] += 1;
  return init;
}

int factorial(int n, int m) {
  if (n == m) return 1;
  return n * factorial(n-1, m);
}

int comb(int a, int b) {
  return factorial(a, a-b) / factorial(b, 1);
}


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

  map<int, int> primes;
  REP(i, N) {
    primes = get_primes(i+1, primes);
  }

  int over4 = 0, over2 = 0, over14 = 0, over24 = 0, over74 = 0;
  for (auto p:primes) {
    if (p.second >= 4) over4++;
    if (p.second >= 2) over2++;
    if (p.second >= 14) over14++;
    if (p.second >= 24) over24++;
    if (p.second >= 74) over74++;
  }

  int res = 0;
  if (over4 >= 2 && over2 >= 3)
    res += comb(over4, 2) * (over2-2);
  if (over14 >= 1 && over4 >= 2)
    res += over14 * (over4-1);
  if (over24 >= 1 && over2 >= 2)
    res += over24 * (over2-1);
  if (over74 >= 1)
    res += over74;

  cout << res << endl;

  return 0;
}

Measured memory_bytes: 384
import java.util.Scanner;

public class Main {
    public static void main(String args[]) {
        Scanner scanner = new Scanner(System.in);
        int N = scanner.nextInt();
        scanner.close();

        double ans = 1.000 / 2.000;
        if(N % 2 == 0) {
            System.out.println(ans);
        } else {
            ans += 1.000 / (N * 2);
            System.out.println(ans);
        }
    }
}

Measured memory_bytes: 24276
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <algorithm>

#define FOR(i,k,n) for (int i=(k); i<(int)(n); ++i)
#define REP(i,n) FOR(i,0,n)
#define FORIT(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define sz size()
#define pb push_back
#define mp make_pair
#define ALL(X) (X).begin(),(X).end()

using namespace std;

const int INF = 1000000000;
const double eps = 1e-8;

int main(void) {
  while(1){
    int n;cin>>n;
    if(!n)break;
    int s = 0;
    int j=0;
    int c=0;
    REP(i,n){
      s += i;
      while(s>n){
        s-=j;
        j++;
      }
      if(s==n)
        c++;
    }
    cout<<c<<endl;
  }
  return 0;
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
#define FIO "C"
using namespace std;
typedef long long ll;
inline int read()
{
	int x=0,f=1;char c=getchar();
	while(!isdigit(c)){if(c=='-')f=-1;c=getchar();}
	while(isdigit(c)){x=x*10+c-'0';c=getchar();}
	return x*f;
}

const int maxn=2010;
int n,m,a[maxn][maxn];
int s[maxn][maxn],h[maxn][maxn],v[maxn][maxn]; 

inline int calc(int X1,int Y1,int X2,int Y2,int sum[maxn][maxn])
{
	if(X1>X2||Y1>Y2) return 0;
	return sum[X2][Y2]-sum[X1-1][Y2]-sum[X2][Y1-1]+sum[X1-1][Y1-1];
}

char buf[maxn];

int main()
{
#ifdef dxymaster
	freopen(FIO".in","r",stdin);
	freopen(FIO".out","w",stdout);
#endif

	n=read();m=read();int q=read();
	for(int i=1;i<=n;i++)
	{
		scanf("%s",buf+1);
		for(int j=1;j<=m;j++)
			if(buf[j]=='1') a[i][j]=1;
	}
	for(int i=1;i<=n;i++)
		for(int j=1;j<=m;j++)
			s[i][j]=s[i-1][j]+s[i][j-1]-s[i-1][j-1]+a[i][j];
	for(int i=1;i<=n;i++)
		for(int j=1;j<=m;j++)
			v[i][j]=v[i-1][j]+v[i][j-1]-v[i-1][j-1]+(a[i][j]&&a[i-1][j]);
	for(int i=1;i<=n;i++)
		for(int j=1;j<=m;j++)
			h[i][j]=h[i-1][j]+h[i][j-1]-h[i-1][j-1]+(a[i][j]&&a[i][j-1]);
	while(q--)
	{
		int sx=read(),sy=read(),tx=read(),ty=read();
		printf("%d\n",calc(sx,sy,tx,ty,s)-calc(sx+1,sy,tx,ty,v)-calc(sx,sy+1,tx,ty,h));
	}	

#ifdef dxymaster
	cerr<< " Time: " << (double) clock() / CLOCKS_PER_SEC << "s			It Runs So Fast!" << endl;
#endif

	return 0;
}


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

int main() {
  int n;
  cin>>n;
  vector<int> a(n+1);
  vector<int> b(n+1);
  vector<int> c(n);
  int cnt=0;
  for(int i=1;i<=n;i++){
    cin>>a[i];
  }
   for(int i=1;i<=n;i++){
    cin>>b[i];
  }
   for(int i=1;i<=n-1;i++){
    cin>>c[i];
  }
   for(int i=1;i<=n;i++){
    cnt+=b[a[i]];
     if(a[i]+1==a[i+1])cnt+=c[a[i]];
   }
  cout<<cnt<<endl;
}

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

typedef long long ll;
const ll INF = 1e15;

int main(int argc, char* argv[])
{
  ll N;
  std::cin >> N;
  std::vector< ll > vx(N, 0);
  std::vector< ll > vy(N, 0);
  std::vector< ll > vh(N, 0);

  ll tmpx = 0LL;
  ll tmpy = 0LL;
  ll tmph = 0LL;
  for (ll i = 0; i < N; i++) {
    std::cin >> vx[i] >> vy[i] >> vh[i];
    if (vh[i] >= 1) {
      tmpx = vx[i];
      tmpy = vy[i];
      tmph = vh[i];
    }
  }

  ll ansx = 0LL;
  ll ansy = 0LL;
  ll ansh = 0LL;
  for (ll cx = 0; cx <= 100; cx++) {
    for (ll cy = 0; cy <= 100; cy++) {
      bool is_ok = true;
      ll H = tmph + std::fabs(tmpx - cx) + std::fabs(tmpy - cy);
      for (ll i = 0; i < N; i++) {
	ll HH = std::max((ll)(H - std::fabs(vx[i] - cx) - std::fabs(vy[i] - cy)), 0LL);
	if (vh[i] != HH) {
	  is_ok = false;
	}
      }
      if (is_ok) {
	ansx = cx;
	ansy = cy;
	ansh = H;
      }
    }
  }

  std::cout << ansx << " " << ansy << " " << ansh << std::endl;
  
  return 0;
}



Measured memory_bytes: 256
#!/usr/bin/env python3
N, K = map(int, input().split())
sushi = [list(map(int, input().split())) for _ in range(N)]
sushi.sort(key=lambda x: x[1], reverse=True)

point = 0
stack = []
kind = set()

for t, d in sushi[:K]:
    point += d
    if t in kind:
        stack.append(d)
    else:
        kind.add(t)

point += len(kind) ** 2
ans = point

for t, d in sushi[K:]:
    if not stack:
        break
    if t not in kind:
        point += d - stack.pop() + 2 * len(kind) + 1
        kind.add(t)
        ans = max(ans, point)

print(ans)


Measured memory_bytes: 30876
#include <iostream>
#include <vector> 
#include <cmath>
#include <algorithm>
#include <set>
#include <map>
#include <cerrno>
#include <cfenv>
#include <math.h>
#include <iomanip>
#include <limits>
#define ll long long int

using namespace std;

int main(){

    int n;

    while(true){

        cin >> n;

        if(n==0){
            break;
        }

        vector<int> data(10000);
        int sum = 0;

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

        double ave = (sum/n);

        int cnt = 0;
        
        for(int i=0;i<n;i++){
            if(ave>=(double)data[i]){
                cnt++;
            }
        }

        cout << cnt << endl;

    }

    return 0;
}


Measured memory_bytes: 3140
#include<bits/stdc++.h>
#define cases long long test;cin>>test;while(test--)
#define f_io ios::sync_with_stdio(false); cin.tie(0)
#define foi(a,n) for(long long i=a;i<n;i++)
#define foj(a,n) for(long long j=a;j<n;j++)
#define fok(a,n) for(long long k=a;k<n;k++)
#define ll long long
#define MOD 1000000007
#define INF 1000000000
using namespace std;

int main()
{
    f_io;
    string s;
    cin >> s;
    if(s[(ll)s.length()-1]=='s')
        cout << s << "es";
    else
        cout << s << "s";
    return 0;
}

Measured memory_bytes: 3648
N = int(input())
#N=5
#A,B = [2,1,1,4,3],[4,9,8,9,12]
A,B = [],[]
for i in range(N):
    a,b = input().split()
    A.append(int(a))
    B.append(int(b))


import numpy as np
C = np.array([A,B])

C = C[:,C[1,:].argsort()]
A,B = C[0],C[1]
i=0
while(i<N):
    n=0
    #ind = i+n
    while((i+n<N) and (B[i]==B[i+n])):
        n += 1
    if(n>1):
        #print(n,i,A[i:i+n] )
        #pdb.set_trace()
        A[i:i+n] = A[i:i+n][::-1]
    i+=n
"""
print(A,B)
sum_ = 0
y=[]
b = []
for i in range(N):
    sum_ += A[i]
    y.append(sum_)
    b.append(B[i])
plt.plot(y)
plt.plot(b)
plt.show()
plt.close()"""
time = 0
hantei = 0
for i in range(N):
    time += A[i]
    if(time>B[i]):
        hantei = 1
        break
        
print("Yes") if hantei==0 else print("No")

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

int main(){
  int A, B, ans;
  cin >> A >> B;
  
  if(A >= 13)	ans = B;
  else if (6<=A && A<=12)	ans = B / 2;
  else if (A <= 5)	ans = 0;
  
  cout << ans << endl;

}

Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskB solver = new TaskB();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskB {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            char[] a = in.next().toCharArray();
            out.println("" + a[0] + (a.length - 2) + a[a.length - 1]);
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

    }
}



Measured memory_bytes: 21460
using System.Linq;
using System;

public class UnionFind
{
    private int[] data;
    public UnionFind(int size)
    {
        data = new int[size];
        for (int i = 0; i < size; i++) data[i] = -1;
    }
    public bool Unite(int x, int y)
    {
        x = Root(x);
        y = Root(y);
        if (x != y)
        {
            if (data[y] < data[x])
            {
                var tmp = y;
                y = x;
                x = tmp;
            }
            data[x] += data[y];
            data[y] = x;
        }
        return x != y;
    }
    public bool IsSameGroup(int x, int y) => Root(x) == Root(y);
    public int Root(int x) => data[x] < 0 ? x : data[x] = Root(data[x]);
}

public class P
{
    public int t { get; set; }
    public int s { get; set; }
    public int d { get; set; }
}

public class Hello
{
    public static void Main()
    {
        while (true)
        {
            string[] line = Console.ReadLine().Trim().Split(' ');
            var n = int.Parse(line[0]);
            var m = int.Parse(line[1]);
            if (n == 0 && m == 0) break;
            var uf = new UnionFind(n + 1);
            var ps = new P[m];
            for (int i = 0; i < m; i++)
            {
                line = Console.ReadLine().Trim().Split(' ');
                var t = int.Parse(line[0]);
                var s = int.Parse(line[1]);
                var d = int.Parse(line[2]);
                ps[i] = new P { t = t, s = s, d = d };
            }
            foreach (var x in ps.OrderBy(y => y.t))
                if (uf.IsSameGroup(x.s, 1)) uf.Unite(x.d, 1);
            var count = 1;
            for (int i = 2; i <= n; i++)
                if (uf.IsSameGroup(i, 1)) count++;
            Console.WriteLine(count);
        }
    }
}



Measured memory_bytes: 32776
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;

public class Main {

  static int a, b, c, k, ans;

  public static void main(String[] args) throws Exception {

    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    PrintWriter out = new PrintWriter(System.out);

    String[] in = br.readLine().split(" ");
    a = Integer.parseInt(in[0]);
    b = Integer.parseInt(in[1]);
    c = Integer.parseInt(in[2]);
    k = Integer.parseInt(in[3]);

    /*
    =====templates=====
    ===inputs===
    static int n;
    in = br.readLine().split(" ");
    int[] a = Stream.of(in).mapToInt(Integer::parseInt).toArray();

    int n = Integer.parseInt(in[0]);
    long n = Long.parseLong(in[0]);
    int[] a = Stream.of(in).mapToInt(Integer::parseInt).toArray();

    ===outputs===
    PrintWriter out = new PrintWriter(System.out);
    out.println(ans);
    out.flush();
    */

    br.close();

    ans = Math.min(a, k);
    k -= a + b;
    if(k > 0) ans -= k;

    out.println(ans);

    out.flush();

  }
}

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

int main() {
    int arr[3];
    cin >> arr[0] >> arr[1] >> arr[2];
    sort(arr, arr+3);
    int ans = 0;
    ans += arr[2] - arr[1];
    int val = arr[1] - arr[0];
    if (val&1 == 1) {
        ans += int(val/2) + 2;
    }
    else {
        ans += val/2;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
var
  n,a,b:int64;
  i:longint;
  s:string;
begin
  read(n);
  a:=round(sqrt(n));
  for i:= a+1 downto 1 do
    if n mod i= 0 then
                    begin
                      b:=n div i;
                      str(b,s);
                      write(length(s));
                      break;
                    end;
end.

Measured memory_bytes: 128
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
using namespace std;

#define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++)
#define repq(i,a,n) for(int (i)=(a); (i)<=(n); (i)++)
#define repr(i,a,n) for(int (i)=(a); (i)>=(n); (i)--)
#define all(v) begin(v), end(v)
#define pb(a) push_back(a)
#define fr first
#define sc second
#define INF 2000000000
#define int long long int

#define X real()
#define Y imag()
#define EPS (1e-10)
#define EQ(a,b) (abs((a) - (b)) < EPS)
#define EQV(a,b) ( EQ((a).X, (b).X) && EQ((a).Y, (b).Y) )
#define LE(n, m) ((n) < (m) + EPS)
#define LEQ(n, m) ((n) <= (m) + EPS)
#define GE(n, m) ((n) + EPS > (m))
#define GEQ(n, m) ((n) + EPS >= (m))

typedef vector<int> VI;
typedef vector<VI> MAT;
typedef pair<int, int> pii;
typedef long long ll;

typedef complex<double> P;
typedef pair<P, P> L;
typedef pair<P, double> C;

int dx[]={1, -1, 0, 0};
int dy[]={0, 0, 1, -1};
int const MOD = 1000000007;
ll mod_pow(ll x, ll n) {return (!n)?1:(mod_pow((x*x)%MOD,n/2)*((n&1)?x:1))%MOD;}
int madd(int a, int b) {return (a + b) % MOD;}
int msub(int a, int b) {return (a - b + MOD) % MOD;}
int mmul(int a, int b) {return (a * b) % MOD;}
int minv(int a) {return mod_pow(a, MOD-2);}
int mdiv(int a, int b) {return mmul(a, minv(b));}

namespace std {
    bool operator<(const P& a, const P& b) {
        return a.X != b.X ? a.X < b.X : a.Y < b.Y;
    }
}

string s, t;

signed main() {
    cin >> s >> t;
    int n = (int)s.length(), m = (int)t.length();
    int x = 0, y = 0, cur = 0;
    bool ok = false;
    while(x < n && y < m && cur < n) {
        if(cur % 2) {
            if(s[x] == s[cur]) cur++;
            x++;
        }
        else {
            if(t[y] == s[cur]) cur++;
            y++;
        }
    }
    if(cur == n) ok = true;

    x = 0, y = 0, cur = 0;
    while(x < n && y < m && cur < n) {
        if(cur % 2) {
            if(t[y] == s[cur]) cur++;
            y++;
        }
        else {
            if(s[x] == s[cur]) cur++;
            x++;
        }
    }
    if(cur == n) ok = true;

    if(ok) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3228
import math

foo = []
while True:
    n = int(input())
    if n == 0:
        break

    a = [int(x) for x in input().split()]
    
    ave = sum(a)/len(a)

    hoge = 0
    for i in a:
        hoge += (i - ave) ** 2
    hoge /= len(a)
    foo += [math.sqrt(hoge)]
for i in foo:
    print(i)

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

#define REP(i, e) for(int (i) = 0; (i) < (e); ++(i))
#define FOR(i, b, e) for(int (i) = (b); (i) < (e); ++(i))
#define ALL(c) (c).begin(), (c).end()
#define ACC(c) (accumulate(ALL(c), 0LL))
#define PRINT(x) cout << (x) << "\n"

using namespace std;
using ll = long long;
using pint = pair<int, int>;
using pll = pair<ll, ll>;

inline int in(int& a) {return scanf("%d", &a);}
auto pint_compare = [](pint x, pint y) -> bool{return (x.first < y.first);};


signed main(){
    int K, X;
    cin >> K >> X;
    FOR(i, X - K + 1, X + K){
        cout << i;
        if(i == X + K) cout << endl;
        else cout << " ";
    }
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>    
#include<cmath>
#include<map>
#include<vector>
#include<math.h>
#include<stdio.h>
#include<stack>
#include<queue>
#include<tuple>
#include<cassert>
#include<set>
#include<functional>
//#include<bits/stdc++.h>
#define int long long
using namespace std;
const int INF = 1000000000000;
const int mod = 1000000007;
int dx[4] = { 1, 0, -1, 0 }, dy[4] = { 0, 1, 0, -1 };
int aa[12345678], bb[1234][1234], cc[123][123][123];
int res[123456], uio[1234][1234];
signed main() {
	int n, m, a, b, x = 0, y = 0, ans = 0; cin >> n >> a >> b;
	if (a != b) { x = n / (a - b); }
	x *= 2; x = max(x - 20, (long long)0);
	y = (a - b) * x / 2;
	if (a <= b && n > a) { cout << -1 << endl; return 0; }
	while (true) {
		y += a; x++; if (y >= n) { cout << x << endl; return 0; }
		y -= b; x++;
	}
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void){

  int a, b, c, x;

  scanf("%d %d %d",&a,&b,&c);
 
  if ( b < a){
    x = a;
    a = b;
    b = x;
  }
 
  if ( a < c && b < c){
    printf("%d %d %d\n",a,b,c);
  }else if (a < c && c < b) {
    printf("%d %d %d\n",a,c,b);
  }else {
    printf("%d %d %d\n",c,a,b);
  }

  return 0;
}

Measured memory_bytes: 1752
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod=1e9+7;
ll a[20005];
int main()
{
    ll s;
    cin>>s;
    a[0]=a[1]=a[2]=0;
    a[3]=1;
    for(int i=4; i<=s; i++)
    {
        a[i]=(a[i-1]+a[i-3])%mod;
    }
    cout<<a[s]<<endl;
    return 0;
}


Measured memory_bytes: 3608
def resolve():
    N = int(input())
    
    K = 0
    for i in range(1, 1000):
        if (i*(i-1)//2 == N):
            K = i
            break

    if K == 0:
        print("No")
        return
    else:
        S = [[] for _ in range(K)]
        cnt = 1
        for i in range(K):
            for j in range(i+1, K):
                S[i].append(cnt)
                S[j].append(cnt)
                cnt += 1

    print("Yes")
    print(K)
    for s in S:
        print(len(s), *s)

if __name__ == "__main__":
    resolve()

Measured memory_bytes: 9424
import itertools
n, m, q = map(int, input().split())
ls = []
for _ in range(q):
    a, b, c, d = map(int, input().split())
    ls.append((a, b, c, d))

def calc(x, ls):
    s = sum([d for a, b, c, d in ls if x[b - 1] - x[a - 1] == c])
    return s

ans = 0
cands = range(1, m+1)
c = itertools.combinations_with_replacement(cands, n)
for x in c:
    ans = max(ans, calc(x, ls))
print(ans)

Measured memory_bytes: 68556
#include "bits/stdc++.h"
using namespace std;
using Graph = vector<vector<int>>;
typedef long long ll;
typedef pair<ll, ll> P;
#define rep(i,n) for (ll i = 0; i < (n); ++i)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const long long mod = 1e9 + 7;

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;
}

ll powMod(ll n, ll k, ll m) {
	if (k == 0) {
		return 1;
	} else if (k % 2 == 1) {
		return powMod(n, k - 1, m) * n % m;
	} else {
		ll t = powMod(n, k / 2, m);
		return t * t % m;
	}
}

int main() {
	ll n;
	cin >> n;
	
	bool flg=true;

	rep(i, n) {
		int a;
		cin >> a;
		if (a % 2 == 0 && a % 3 != 0 && a % 5 != 0) {
			flg = false;
			break;
		}
	}

	if (flg) {
		cout << "APPROVED" << endl;
	} else {
		cout << "DENIED" << endl;
	}
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    
    public static void main(String[] args) {
        
        var sc = new Scanner(System.in);
    
        String s = sc.next();
        String t = sc.next();
        
        int count = 0;
        for(int i = 0; i < s.length(); i++){
            if(s.charAt(i) != t.charAt(i)){
                count++;
            }
        }
        System.out.println(count);
    }
}

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

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

#define SQR(x) ((x)*(x))

int main() {
    //freopen("hi.txt","r",stdin);
    int n;
    scanf("%d",&n);
    ll sum[n];
    for(int i=0;i<n;i++){
        scanf("%lld",&sum[i]);
        if(i>0)sum[i]+=sum[i-1];
    }
    ll ans=1LL<<60;
    for(int i=0;i<n-1;i++){
        ans=min(ans,abs(sum[i]*2-sum[n-1]));
    }
    printf("%lld\n",ans);
}


Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <bits/stdc++.h>

using namespace std;
using ll = long long ;
const int INF = 1001001001;

int main() {

    ll a ;
    double b ;
    cin >> a >> b ;
    //a = 100 ;
    //b = 0.53 ;
    double eps = 0.00001 ;
    ll llb = 100*b + eps ;

    //cout << (ll) (a*b) << endl ;

    cout << (a*llb/100) << endl ;




        return 0; 
}

Measured memory_bytes: 3728
//Date and time of submission: 
 
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const ll N=1e5+5;
ll x,a,b;
int main() {
	ios_base::sync_with_stdio(false); 
	cin.tie(NULL);
	cin>>x>>a>>b;
	if(b-a<=0)
	cout<<"delicious";
	else if(b-a<=x)
	cout<<"safe";
	else
	cout<<"dangerous";
	return 0;
}


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

#include <math.h>
#include <stdlib.h>


#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;

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

//INT_MAX	2,147,483,647 = 2*1.0e9

int main(){
    ll H, W;
    cin >> H >> W;
    
    if(H%3 == 0 || W%3 == 0){
        cout << 0 << endl;
        return 0;
    }

    ll ans = 1e9;
    for(ll j = 0; j < 2; j++){
        for(ll i = 0; i < 2; i++){
            vector<ll> s(3);
            ll s1h = H/3+ i;
            s[0] = s1h * W;
            ll restH = H - s1h;
            if(restH %2 == 0 || W%2 == 0) s[1] = (restH * W) / 2;
            else s[1] = min(restH, W) * (max(restH, W)/2);
            s[2] = H*W - s[0] - s[1];
            sort(s.begin(), s.end());
            ans = min(ans, abs (s[2]-s[0]));
        }
        swap(H,W);
    } 

    cout << ans << endl;

    return 0;
}


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

const int N = 2e5 + 5, mod = 1e9 + 7;
int n, a[N], b[N];

int main()
{
    //ios::sync_with_stdio(false);cin.tie(nullptr);ios_base::sync_with_stdio(false);
    cin >> n;
    vector<int> v;
    for (int i = 1; i <= n; i++)
        cin >> a[i];
    for (int i = n; i > 0; i--)
    {
        int c = 0;
        for (int j = i + i; j <= n; j += i)
            c += b[j];
        if (c % 2 != a[i] % 2)
            v.push_back(i),
            b[i] = 1;
    }
    cout << v.size() << endl;
    sort(v.begin(), v.end());
    for (auto it: v)
        cout << it << ' ';
    return 0;
}

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

int main(){
	int n;
	cin >> n;
	string s;
	cin >> s;
	
	int ans = 0;
	for(int i=0; i<s.size()-2; i++){
		if(s[i]=='A' && s[i+1]=='B' && s[i+2]=='C') ans++;
	}
	cout << ans << endl;
}

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

using namespace std;

#define ll long long
#define ld long double

int main()
{
    ll n;
    cin >> n;
    ll res = 0;
    vector<ll> nums;
    vector<ll> isGreaterFound(n+1,0);
    ll minTillNow = LONG_LONG_MAX;
    while(n--)
    {
        ll a;
        cin >> a;
        if(a < minTillNow)
        {
            minTillNow = a;
            res++;
        }
    }

    cout << res << endl;

    return 0;
}



Measured memory_bytes: 1792
#include <bits/stdc++.h>
#include <string>
#include <cstring>
#include <algorithm>
#include <math.h>
#include <map>
#include <bitset>
#include <cmath>
#include <set>
#include <utility>

#define INF 1000000000000
#define MOD 1000000007 //10^9+7:合同式の法

using namespace std;
typedef long long ll;

//マクロ
#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 FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)

ll digitnum(ll N){
    ll count = 0,x,hako;
    for(ll i = 1;i <= N;i++){
        x = 0;
        hako = i;
        while(hako > 0){
            hako /= 10;
            x++;
        }
        if(x % 2 != 0)
            count++;
    }

    return count;

}

int main(){
    ll N,ans=0;
    cin >> N;

    ans = digitnum(N);

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

Measured memory_bytes: 3596
#include<bits/stdc++.h>
using namespace std;
#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define READ freopen("in.txt","r",stdin)
#define WRITE freopen("out.txt","w",stdout);
#define pb push_back
#define mem(arr,val) memset(arr,val,sizeof(arr))
#define sf(x) scanf("%d",&x)
#define sf2(x,y) scanf("%d %d",&x,&y)
#define sf3(x,y,z) scanf("%d %d %d",&x,&y,&z)
#define sl(x) scanf("%lld",&x)
#define sl2(x,y) scanf("%lld %lld",&x,&y)
#define sl3(x,y,z) scanf("%lld %lld %lld",&x,&y,&z)
#define sd(x) scanf("%lf",&x);
#define pii pair<int,int>
#define pLL pair<long long,long long>
#define ff first
#define sn second
#define PRINT_CASE  printf("Case %d: ",tc++)
#define PRINT_CASENL  printf("Case %d:\n",tc++)
#define mx 100005
#define lnd tree[ind<<1]
#define rnd tree[(ind<<1)+1]
#define cnd tree[ind]
#define lndp b,(b+e)>>1,(ind<<1)
#define rndp ((b+e)>>1)+1,e,(ind<<1)+1
#define IN(a,x,y) (a>=x && a<=y)
typedef long long ll;
typedef long long int lln;
ll INF=1<<28;
//typedef long long lld;
const double pi=acos(-1.0);
int fx[]={1,-1,0,0}; //direction array
int fy[]={0,0,1,-1};
int dir[4][2]={1,0,-1,0,0,-1,0,1};
const long double EPS=1e-7;
//#define INF 10000
ll gcd(ll a,ll b)
{
    if(b==0)
        return a;
    else
        return gcd(b,a%b);
}
ll lcm(ll a,ll b)
{
    return a/gcd(a,b)*b;
}

bool cmp(int a, int b)
{
    return a<b;
}

int vis[200000];
struct compare
{
  bool operator()(const int& l, const int& r)
  {
      return vis[l]>vis[r];
  }
};
ll inf=1e18;
int mod=1e9+7;
const int sz=300005;
struct node{
    int w,s,v;
}arr[sz];
bool cmpN(node a,node b)
{
    return a.w+a.s>b.w+b.s;
}
ll dp[1005][10005];
int n;
ll fun(int pos,int bakiw)
{
//    cout<<pos<<" "<<bakiw<<endl;
    if(bakiw<0)
        return -inf;
    if(pos==n)
        return 0;
    if(dp[pos][bakiw]!=-1)
        return dp[pos][bakiw];
    ll ans=0;
    if(pos+1!=n)
    ans=max(ans,arr[pos].v+fun(pos+1,min(arr[pos].s,bakiw-arr[pos].w)));
    else
    ans=max(ans,arr[pos].v+fun(pos+1,bakiw-arr[pos].w));
    ans=max(ans,fun(pos+1,bakiw));
    return dp[pos][bakiw]=ans;
}
int main()
{
//    READ;
    int x,y,z;
    sf(n);
    for(int i=0;i<n;i++)
    {
        sf3(x,y,z);
        arr[i].w=x;
        arr[i].s=y;
        arr[i].v=z;
    }
    mem(dp,-1);
    sort(arr,arr+n,cmpN);
    ll ans=0;
    for(int i=0;i<n;i++)
    {
        ans=max(ans,arr[i].v+fun(i+1,arr[i].s));
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 80128
#include<cmath>
#include<cstdio>
#include<cstring>
#include<algorithm>
#define gt getchar()
#define ll long long
#define File(s) freopen(s".in","r",stdin),freopen(s".out","w",stdout)
typedef std::pair<int,int> P;
#define mk std::make_pair
#define fr first
#define sc second
inline int in()
{
	int k=0;char ch=gt;bool p=1;
	while(ch<'-')ch=gt;if(ch=='-')ch=gt,p=0;
	while(ch>'-')k=k*10+ch-'0',ch=gt;
	return p?k:-k;
}
const int N=606,YL=1e9+7;
int a[N],dp[N][N>>1][N>>1],o[N],fz[N],mp[N];
inline void add(int &x,int y){if((x+=y)>=YL)x-=YL;}
inline int ksm(int a,int k){int r=1;while(k){if(k&1)r=1ll*r*a%YL;a=1ll*a*a%YL,k>>=1;}return r;}
int main()
{
	int n=in(),tot=0,sum1=0,sum2=0;
	for(int i=1;i<=n;++i)
	{
		a[i*2-1]=in(),a[i*2]=in();
		if(a[i*2-1]!=-1&&a[i*2]!=-1)
			o[a[i*2-1]]=o[a[i*2]]=1;
		else
		{
			if(a[i*2-1]!=-1)mp[a[i*2-1]]=i*2-1;
			else if(a[i*2]!=-1)mp[a[i*2]]= i*2;
			else ++sum2;
		}
	}
	for(int i=n<<1;i;--i)if(!o[i])fz[++tot]=i;
	dp[0][0][0]=1;
	for(int i=1;i<=tot;++i)
		for(int j=0;j<=n;++j)
			for(int k=0;k<=n;++k)
				if(dp[i-1][j][k])
				{
					int res=dp[i-1][j][k];
					if(mp[fz[i]])
					{
						if(k)add(dp[i][j][k-1],res);
						add(dp[i][j+1][k],res);
					}
					else
					{
						if(j)add(dp[i][j-1][k],1ll*res*j%YL);
						if(k)add(dp[i][j][k-1],res);
						add(dp[i][j][k+1],res);
					}
				}
	int ans=dp[tot][0][0];
	for(int i=1;i<=sum2;++i)ans=1ll*ans*i%YL;
	printf("%d\n",ans);
	return 0;
}


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

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; }

#define rep(i,cc,n) for(int i=cc;i<n;++i)
#define lrep(i,cc,n) for(long long i=cc;i<n;++i)
#define sqrep(i,cc,n) for(long long i=cc;i*i<=n;++i)
#define rrep(i,cc,n) for(long i=cc;i>n;--i)
#define pii pair<int, int>
#define pll pair<long long, long long>
 
using ll = long long;

const vector<int> dx = {1, 0, -1, 0};
const vector<int> dy = {0, 1, 0, -1};
const ll inf = 1001001001;
const ll e9  = 1000000000;
const ll mod = 1000000007;


int main() {
    string s;
    cin >> s;
    if(s.size()==3)cout << s << endl;
    else cout << s.erase(3)<< endl;
}

Measured memory_bytes: 3632
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<map>
#include<set>
#include<queue>
#include<cstdio>
#include<climits>
#include<cmath>
#include<cstring>
#include<string>
#include<sstream>
#include<numeric>
#include<cassert>

#define f first
#define s second
#define mp make_pair

#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define rep(i,s,n) for(int i=(s); i<(int)(n); i++)
#define FOR(i,c) for(__typeof((c).begin()) i=(c).begin(); i!=(c).end(); i++)
#define ALL(c) (c).begin(), (c).end()
#define IN(x,s,g) ((x) >= (s) && (x) < (g))
#define ISIN(x,y,w,h) (IN((x),0,(w)) && IN((y),0,(h)))
#define print(x) printf("%d\n",x)

using namespace std;

typedef unsigned int uint;
typedef long long ll;

const int _dx[] = {0,1,0,-1};
const int _dy[] = {-1,0,1,0};

int getInt(){
  int ret = 0,c;
  c = getchar();
  while(!isdigit(c)) c = getchar();
  while(isdigit(c)){
    ret *= 10;
    ret += c - '0';
    c = getchar();
  }
  return ret;
}

int p[10];

bool valid(){
  int m = p[9];
  int ok;
  int sum;
  sum = p[0] + p[4] + p[8];
  if(sum % m == (p[2] + p[4] + p[6]) % m){
    ok = sum % m;
  }else{
    return false;
  }

  int sumT[3] = {0};
  int sumY[3] = {0};
  REP(i,3){
    REP(j,3){
      sumY[i] += p[3*i + j];
      sumT[i] += p[3*j + i];
    }
  }
  REP(i,3){
    if(sumT[i] % m != ok) return false;
    if(sumY[i] % m != ok) return false;
  }

  return true;
}

int solve(int now, int f){
  if(now == 10){
    //REP(i,10) printf("%d ",p[i]); puts("");
    return valid() ? 1 : 0;
  }
  if(p[now] == 0){
    int ret = 0;
    REP(i,10) if(f & (1<<i)){
      p[now] = i+1;
      ret += solve(now+1, f^(1<<i));
      p[now] = 0;
    }
    return ret;
  }else{
    int tmp = p[now]-1;
    if(!(f & (1 << tmp))) return 0;
    return solve(now+1, f^(1<<tmp));
  }
}

int main(){
  while(true){
    REP(i,10) scanf("%d",p+i);
    if(p[0] == -1) break;
    print(solve(0, (1<<10)-1));
  }
  return 0;
}

Measured memory_bytes: 876
#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include <random>
#include<map>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include<fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
using namespace std;
#define Ma_PI 3.141592653589793
#define eps 0.00000001
#define LONG_INF 3000000000000000000
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007
#define MOD 998244353
#define REP(i,n) for(long long i = 0;i < n;++i)    
#define seg_size 524288
double dot(complex<double> a, complex<double> b) {
	return a.real() * b.real() + a.imag() * b.imag();
}
double gyaku_dot(complex<double> a, complex<double> b) {
	return a.real() * b.imag() - a.imag() * b.real();
}
double leng(complex<double> a) {
	return sqrt(a.real()*a.real() + a.imag()*a.imag());
}
double angles(complex<double> a, complex<double> b) {
	double cosine = dot(a, b) / (leng(a) * leng(b));
	double sine = gyaku_dot(a, b) / (leng(a) * leng(b));
	double kaku = acos(cosine);
	if (sine <= 0) {
		kaku = 2 * Ma_PI - kaku;
	}
	return kaku;
}
vector<int> convex_hull(vector<complex<double>> a) {
	vector<int> ans;
	double now_minnest = a[0].real();
	int now_itr = 0;
	REP(i, a.size()) {
		if (now_minnest > a[i].real()) {
			now_minnest = a[i].real();
			now_itr = i;
		}
	}
	ans.push_back(now_itr);
	complex<double> ba(0, 1);
	while (true) {
		int now_go = 0;
		double now_min = 0;
		int starter = ans[ans.size() - 1];
		for (int i = 0; i < a.size(); ++i) {
			if (i != starter) {
				double goa = angles(ba, a[i] - a[starter]);
				if (goa > now_min) {
					now_min = goa;
					now_go = i;
				}
			}
		}
		if (now_go == ans[0]) break;
		ans.push_back(now_go);
		ba = complex<double>(a[now_go] - a[starter]);
	}
	return ans;
}
long long size_of_beaf[2000] = {};
long long size_of_all[2000] = {};
long long calc(long long a, long long b) {
	if (b == 0) return 0;
	if (a == 0) {
		assert(b == 0 || b == 1);
		if (b == 0) return 0;
		return 1;
	}
	if (b <= 1) return 0;
	b--;
	if (b <= size_of_all[a - 1]) {
		return calc(a - 1, b);
	}
	long long ans = size_of_beaf[a - 1];
	b -= size_of_all[a - 1];
	b--;
	ans++;
	if (b <= size_of_all[a - 1]) {
		return calc(a - 1, b) + size_of_beaf[a-1] + 1LL;
	}
	ans += size_of_beaf[a - 1];
	b -= size_of_all[a - 1];
	b--;
	assert(b == 0);
	return ans;
}
int main(){
#define int long long
	long long n, x;
	cin >> n >> x;
	size_of_beaf[0] = 1;
	size_of_all[0] = 1;
	for (int i = 0; i < n+1; ++i) {
		size_of_beaf[i + 1] = size_of_beaf[i] * 2LL + 1LL;
		size_of_all[i + 1] = size_of_all[i] * 2LL + 3LL;
	}
	cout << calc(n, x) << endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
int main(){
	int a, b, x;
	long double z, d, tan;
	scanf("%d%d%d", &a, &b, &x);
	if(a*a*b/2 <= x){
		d = b - x/ ((long double) a*a);
		tan = 2*d/a;
	}else{
		z = 2*x/ ((long double)a*b);
		tan = b/z;
	}
	//printf("%.12Lf %Lf %Lf %Lf\n", atanl(tan) * 180.0 / 3.14159265, d, z, tan);
	printf("%.12Lf\n", atanl(tan) * 180.0 / 3.14159265);
}


Measured memory_bytes: 128
#include <iostream>
#include <iomanip>
#include <vector>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <cstring>
#define rep(i, N) for (int i = 0; i < (int)N; i++)
using namespace std;
typedef long long ll;
const ll LLINF = 9223372036854775807;
const int MOD = 1000000007;

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

  string result = "";
  int i = 0;
  if (N==0) result = "0";
  else while(abs(N)!=0) {
    if (abs(N)%2==1) {
      result += "1";
      N += pow(-1,i+1);
    }
    else result += "0";
    N /= 2;
    i++;
    // cout << i << " " << N << endl;
  }

  reverse(result.begin(), result.end());
  cout << result << endl;
  return 0;
}

Measured memory_bytes: 256
N = int(input())
DIV = pow(10,9)+7
sum = 1
prime = []
for i in range(2,N+1):
  flg = True
  for j in range(2,i+1):
    if i != j and i%j == 0:
      flg = False
      break
  if flg:    
  	prime.append(i)
stock = [0]*len(prime)
ind = 0
for x in prime:
  work = 0
  for y in range(2,N+1):
    if y%x == 0:
      cnt = 1
      while y%pow(x,cnt)==0:
        cnt += 1
      work += (cnt-1)
  stock[ind] = work
  ind += 1
for z in stock:
  sum *= (z+1)
print(sum%DIV)

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

using namespace std;
int degit_sum(int);

int main(void){
  int N, A, B;
  int ans = 0;
  cin >> N >> A >> B;

  for(int i = 1; i <= N; ++i){
    if(A <= degit_sum(i) && degit_sum(i) <= B){
      ans += i;
    }
  }

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

int degit_sum(int i){
  int sum = 0;
  for(int j = 1; j < 6; j++){
    sum += i % 10;
    i = i/10;
  }
  return sum;
}

Measured memory_bytes: 256
import itertools


n, a, b, c = map(int, input().split())
ls = [int(input()) for _ in range(n)]

mint = 1e9
for comb in itertools.product((0, 1, 2, 3), repeat=len(ls)):
    fa = [ls[i] for i in range(len(ls)) if comb[i] == 1]
    fb = [ls[i] for i in range(len(ls)) if comb[i] == 2]
    fc = [ls[i] for i in range(len(ls)) if comb[i] == 3]

    if len(fa) == 0 or len(fb) == 0 or len(fc) == 0:
        continue

    mint = min(mint, (len(fa) + len(fb) + len(fc) - 3) * 10 +
               abs(sum(fa) - a) + abs(sum(fb) - b) + abs(sum(fc) - c))


print(mint)

Measured memory_bytes: 3064
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>

using namespace std;
typedef long long int ll;

ll solve(ll N,ll X)
{
	if(N%X==0) return 3LL*(N-X);
	else
	{
		if(2*X<N) return 3LL*X*(N/X-1)+3LL*(N%X)+solve(X,X-N%X);
		ll g=N%X;
		if(X%g==0) return 3LL*X;
		return 3LL*g*(X/g)+solve(g+X%g,X%g);
	}
}
int main()
{
	ll N,X;
	scanf("%lld %lld",&N,&X);
	printf("%lld\n",solve(N,X));
	return 0;
}


Measured memory_bytes: 128
import java.util.Scanner;

class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();
		int[] h = new int[n];

		for (int i = 0; i < n; i++) {
			h[i] = sc.nextInt();
		}

		int ans = 1;
		outer:
		for (int i = 1; i < n; i++) {
			for (int j = 0; j < i; j++) {
				if (h[j] > h[i]) {
					continue outer;
				}
			}
			ans++;
		}

		System.out.println(ans);
		sc.close();
	}
}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
#define mod 1000000007
 
int gcd(int a, int b) { return b ? gcd(b, a%b) : a; }
 
int lcm(int a, int b) { return a * b / gcd(a, b); }

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

    int ans = 0;
    while(1){
        int l = 101;
        int r = 101;

        for (int i = 0; i < n; i++){
            if(l == 101 && h[i] > 0){
                l = i;
                continue;
            }
            if(l != 101 && h[i] <= 0){
                r = i;
                break;
            }
        }
        // cout << l << " " << r << endl;

        if(r == 101) r = n;
        if(l == 101) break;

        for(int i = l; i < r; i++){
            h[i]--;
        }
        ans++;
    }
    cout << ans << endl;
    return 0;
}

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

using I = long long;
using U = unsigned long long;

using F = long double;

template <typename T> using Vec = vector<T>;
template <typename K, typename V> using HashMap = unordered_map<K, V>;
template <typename T> using HashSet = unordered_set<T>;
template <typename T> using PQueue = priority_queue<T>;
template <typename T> using Uq = unique_ptr<T>;

using StrView = string_view;

auto solve(StrView T) -> void {
  for (char c : T) {
    if (c == '?') {
      cout << "D";
    } else {
      cout << c;
    }
  }
  cout << '\n';
}

auto main() -> int {
  string T;
  cin >> T;
  solve(T);
  return 0;
}


Measured memory_bytes: 3752
n=int(input())
a=list(map(int,input().split()))
x=0
ans=0
while sum(a)>0:
    while x<=n-1 and a[x]==0:
        x+=1
    while x<=n-1 and a[x]!=0:
        a[x]-=1
        x+=1
    ans+=1
    x=0
print(ans)

Measured memory_bytes: 3060
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
/*16行目以降の実装ができなかった*/
int compare_int(const void *a, const void *b){return *(int*)a - *(int*)b;}

int main(void){
	int N,i,ans=0,j;
	scanf("%d",&N);
	int A[N];
	for(i=0;i<N;i++){
		scanf("%d",&A[i]);
	}
	qsort(A, N, sizeof(int), compare_int);
	int c = 1;
	for(i=0;i<N;i++){
		for(j=i+1;j<N;j++){
			if(A[i] == A[j]) c++;
			else break;
		}
		ans += c%2;
		c = 1;
		i = j-1;
	}
	
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 892
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
#define chmin(a, b) ((a) = min((a), (b)))
#define chmax(a, b) ((a) = max((a), (b)))
#define fs first
#define sc second
#define eb emplace_back
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;

const ll MOD = 1e9 + 7;
const ll INF = 1e18;
const double pi = acos(-1);
const double eps = 1e-10;

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

int main(){
    int x, a; cin>>x>>a;
    if(x < a) cout << 0 << endl;
    else cout << 10 << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define MOD 1000000007
#define INF 1000000000000000
#define fi first
#define se second
#define all(v) v.begin(),v.end()
int dx[]={0,1,0,-1},dy[]={1,0,-1,0};
#define pb push_back
struct edge{int to,cost;};
typedef pair<int,int> P;
int c[20];
int dp[50001];
signed main(){
	int n,m;
	cin>>n>>m;
	rep(i,m)cin>>c[i];
	fill(dp+1,dp+50001,INF);
	for(int i=0;i<=50000;i++){
		rep(j,m){
			if(i+c[j]<=n)dp[i+c[j]]=min(dp[i+c[j]],dp[i]+1);
		}
	}
	cout<<dp[n]<<endl;
	return 0;
}



Measured memory_bytes: 3468
#include <bits/stdc++.h>
using namespace std;
int main(){
	int a,b,k,l;
    cin>>a>>b;
    k=max(a,b);
    l=min(a,b);
    string c;
    c= std::to_string(l);
    for(int i=0;i<k;i++){
    	cout<<c;
    }
    

}

Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<numeric>
#include<functional>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<n;i++)
#define ll long long
#define modbig (10*10*10*10*10*10*10*10*10+7)
using namespace std;

int main(){
  int n; cin>>n; int h[n];
  rep(i,n){
    cin>>h[i];
  }
  int maxi=0,d=0;
  rep1(i,n){
    if(h[i-1]>=h[i]){
      d++;
    }else{
      d=0;
    }
    maxi=max(maxi,d);
  }
  cout<<maxi;
}

Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <math.h>
#include <cassert>
#define rep(i,n) for(int i = 0; i < n; ++i )
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
  int n;
  cin>>n;
  double ans = (n+1)/2;
  ans /= n;
  cout << ans << endl;
}


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

#define ll long long

const int N = 4e3+15;

int dp[N][N];

int a[N],b[N];

const int mod = 998244353;

int add(int x,int y){
	return (x+y)%mod;
}
int solveDp(int x,int y,int apos,int bpos){
	if(x==apos && y==bpos){
		return 1;
	}
	int &ret = dp[x][y];
	if(ret!=-1){
		return ret;
	}
	int ind = x+ y;
	ret = 0;
	if(x<apos && a[x]<=ind){
		ret = add(ret, solveDp(x+1,y,apos,bpos));
	}
	if(y<bpos && b[y]<=ind){
		ret = add(ret, solveDp(x,y+1,apos,bpos));
	}
	return ret;
}
void solve(){
	int n;
	string s;
	cin>>s;
	n = s.size();
	int apos = 0,bpos = 0;
	memset(dp,-1,sizeof(dp));
	for(int i=0;i<n;++i){
		if(s[i]=='1'){
			a[apos++] = i;
			b[bpos++] = i;
		} else if(s[i]=='0'){
			a[apos++] = i;
			a[apos++] = i;
		} else {
			b[bpos++] = i;
			b[bpos++] = i;
		}
	}
	printf("%d\n", solveDp(0,0,apos,bpos));
}
int main(){
	//freopen("input.txt","r",stdin);
	solve();
}

Measured memory_bytes: 63616
import java.util.Scanner;

class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int input = sc.nextInt();
        int first = input / 100;
        int latter = input % 100;

        boolean firstMonth = first > 0 && first <= 12;
        boolean latterMonth = latter > 0 && latter <= 12;
        if(firstMonth && latterMonth)System.out.println("AMBIGUOUS");
        else if(firstMonth)System.out.println("MMYY");
        else if(latterMonth)System.out.println("YYMM");
        else System.out.println("NA");
    }
}

Measured memory_bytes: 21844
n = int(input())
csf = [list(map(int,input().split())) for _ in range(n-1)]

for i in range(n):
    time = 0
    while True:
        if i == n-1:
            print(time)
            break
        if csf[i][1] <= time and time%csf[i][2] == 0:
            time += csf[i][0]
        elif csf[i][1] > time:
            time = csf[i][1] + csf[i][0]
        else:
            time += csf[i][2] - time%csf[i][2] + csf[i][0]
        i += 1

Measured memory_bytes: 9116