akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <string>
#include <utility>
#include <algorithm>

int snuke(std::string s, char ch) {
  int res=0;
  while (s.length()) {
    if (size_t(std::count(s.begin(), s.end(), ch)) == s.length()) return res;

    std::string t;
    for (size_t i=1; i<s.length(); ++i) {
      if (s[i-1] == ch || s[i] == ch) {
        t += ch;
      } else {
        t += s[i-1];
      }
    }

    s = std::move(t);
    ++res;
  }
  return res;
}

int main() {
  char buf[128];
  scanf("%s", buf);

  std::string s=std::move(buf);

  int res=128;
  for (char ch='a'; ch<='z'; ++ch)
    res = std::min(res, snuke(s, ch));

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


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

int n;
vector<int> d;

int main() {
  int i, x;
  cin >> n;
  for(i = 0; i < n; ++i) {
    cin >> x;
    d.push_back(x);
  }
  sort(d.begin(), d.end());
  d.erase(unique(d.begin(), d.end()), d.end());
  cout << d.size() <<endl;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
	int A, B, C, D;
	
	scanf("%d", &A);
	scanf("%d", &B);
	scanf("%d", &C);
	scanf("%d", &D);

	for (int turns = 0; ; turns++){
		
		//Mr.Takahashi's Attack
		C -= B;
		
		if (C <= 0) {
			printf("Yes");
			break;
		}
		
		
		//Mr.Aoki's Attack
		A -= D;
		
		if (A <= 0) {
			printf("No");
			break;
		}
	}
	
	return 0;
}

Measured memory_bytes: 1724
def main():
    N, M = map(int, input().split())
    A = [0] * (N + 2)
    for _ in range(M):
        A[int(input())] = 1
    dp = [0] * (N + 2)
    dp[-2] = 1
    for i in range(N - 1, -1, -1):
        if A[i] == 1:
            continue
        dp[i] = dp[i + 1] + dp[i + 2]
    print(dp[0] % 1000000007)


main()


Measured memory_bytes: 460788
import java.util.Scanner;

 
public class Main {
 
	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		long N = sc.nextLong();
		long A = sc.nextLong();
		long B = sc.nextLong();
		
		long rest = N % (A + B);
		long divide = Math.floorDiv(N, A + B);
		
		if(rest < A) {
			System.out.print(A * divide + rest);
		}else {
			System.out.print(A * divide + A);
		}
		sc.close();
	}
	
}

Measured memory_bytes: 23764
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double

int main(void)
{
    ll n, dic_num = 1, dic_num_p, dic_num_q;
    cin >> n;
    vector<ll> p(n), q(n), dic(0);
    for(ll i = 0; i < n; i++) {
        cin >> p.at(i);
    }
    for(ll i = 0; i < n; i++) {
        cin >> q.at(i);
        dic.push_back(i + 1);
    }

    do {
        bool check_p = true, check_q = true;

        for(ll i = 0; i < n; i++) {
            if(dic.at(i) != p.at(i)) {
                check_p = false;    break;
            }
        }

        for(ll i = 0; i < n; i++){
            if(dic.at(i) != q.at(i)) {
                check_q = false;    break;
            }
        }

        if(check_p)
            dic_num_p = dic_num;
        if(check_q)
            dic_num_q = dic_num;

        dic_num++;

    } while ( next_permutation(dic.begin(), dic.end()) );

    cout << abs(dic_num_p - dic_num_q);
    
    return 0;
}

Measured memory_bytes: 3584
// DP
package main

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

func min(x, y int) int {
	if x < y {
		return x
	}
	return y
}

func fill(a []int, x int) {
	for i := 0; i < len(a); i++ {
		a[i] = x
	}
}

func main() {
	const maxW = 100000

	N := readInt()
	W := readInt()

	dp := make([]int, maxW+1)
	fill(dp, math.MaxInt64)
	dp[0] = 0

	for i := 0; i < N; i++ {
		w := readInt()
		v := readInt()
		for j := maxW - v; j >= 0; j-- {
			if dp[j] == math.MaxInt64 {
				continue
			}
			if dp[j]+w <= W {
				dp[j+v] = min(dp[j+v], dp[j]+w)
			}
		}
	}
	i := maxW
	for dp[i] == math.MaxInt64 {
		i--
	}
	fmt.Println(i)
}

const (
	ioBufferSize = 1 * 1024 * 1024 // 1 MB
)

var stdinScanner = func() *bufio.Scanner {
	result := bufio.NewScanner(os.Stdin)
	result.Buffer(make([]byte, ioBufferSize), ioBufferSize)
	result.Split(bufio.ScanWords)
	return result
}()

func readString() string {
	stdinScanner.Scan()
	return stdinScanner.Text()
}

func readInt() int {
	result, err := strconv.Atoi(readString())
	if err != nil {
		panic(err)
	}
	return result
}


Measured memory_bytes: 2632
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.StringTokenizer;

import static java.lang.Integer.parseInt;

/*
 * Problem B: Thanksgiving
 */
public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line;
		String[] words;

		while ((line = br.readLine()) != null && !line.isEmpty()) {

			int n, m;
			n = parseInt(line.substring(0, line.indexOf(' ')));
			m = parseInt(line.substring(line.indexOf(' ') + 1));
			if ((n | m) == 0) break;

			int[] p = new int[n];

			StringTokenizer st = new StringTokenizer(br.readLine());
			for (int i = 0; i < n; i++) p[i] = parseInt(st.nextToken());
			Arrays.sort(p);

			//
			int ans = 0;

			if (n >= m) {
				int r = n % m;
				for (int i = 0; i < r; i++) {
					ans += p[i];
				}
				for (int i = r; i < n; i++) {
					if (((i - r) % m) != 0) ans += p[i];
				}
			} else {
				for (int i = 0; i < n; i++) {
					ans += p[i];
				}
			}

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

Measured memory_bytes: 32548
#include<bits/stdc++.h>
using namespace std;
struct Unionfind{
  vector<int> par,sizes;
  Unionfind(int n) : par(n),sizes(n,1){
    for(int i=0;i<n;i++){
      par[i] = i;
    }
  }
  int find(int x){
    if(par[x] == x)return x;
    else{
      return par[x] = find(par[x]);
    }
  }
  void unite(int x,int y){
    x = find(x);
    y = find(y);
    
    if(x == y)return ;
    
    if(sizes[x] < sizes[y])swap(x,y);
    par[y] = x;
    sizes[x] += sizes[y];
  }
  int same(int x, int y){
    return find(x) == find(y);
  }
			 
};
int main(){
  int n,q,com,x,y;
  cin >> n >> q;
  Unionfind uni(n);
  for(int i=0;i<q;i++){
    cin >> com >> x >> y;
    if(com == 1){
      cout << uni.same(x,y) << endl;
    }else{
      uni.unite(x,y);
    }
  }
}

Measured memory_bytes: 1276
import sys
F = sys.stdin
N, Q = map(int, F.readline().strip("\n").split())
s = F.readline().strip("\n")
O = [None] * Q
for i in range(Q):
    O[i] = list(map(str, F.readline().strip("\n").split()))

leftlow, lefthigh = 0, N
while lefthigh - leftlow > 1:
    mid = (lefthigh + leftlow)//2
    now = mid
    for place, move in O:
        if place == s[now]:
            if move == "L": now -= 1
            else: now += 1
            if now == -1 or now == N: break
    if now == -1:leftlow = mid
    else: lefthigh = mid

rightlow, righthigh = 0, N
while righthigh - rightlow > 1:
    mid = (righthigh + rightlow)//2
    now = mid
    for place, move in O:
        if place == s[now]:
            if move == "L":now -= 1
            else: now += 1
            if now == -1 or now == N: break
    if now == N:righthigh = mid
    else: rightlow = mid

print(righthigh - lefthigh)

Measured memory_bytes: 78796
#include<bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long
#define ld long double
#define pb push_back
const ll mod=1e9+7;
template<typename T> T pow(T a,T b, long long m){T ans=1; while(b>0){ if(b%2==1) ans=(ans*a)%m; b/=2; a=(a*a)%m; } return ans%m; }
const ll N=1e6+8;
const ll INF=1e18;
  string a,b;
 ll dp[3005][3005];
ll LCS(ll i,ll j){
    if(i==0||j==0)
    return 0;
    if(dp[i][j]!=-1)
    return dp[i][j];
    ll ans=0;
   if(a[i-1]==b[j-1]){
        ans=1+LCS(i-1,j-1);
   }
 ans=max(ans,LCS(i-1,j));
 ans=max(ans,LCS(i,j-1));
 return dp[i][j]=ans;
}
int main(){
    IOS;
    cin>>a>>b;
    string s="";
    memset(dp,-1,sizeof(dp));
    ll l=LCS(a.length(),b.length());
    ll n=a.length(),m=b.length();
  while(n>0&&m>0){
      if(a[n-1]==b[m-1]){
          s+=a[n-1];
        //cout<<a[n-1];
       n--;
       m--;
      }
      else 
        if(dp[n-1][m]>dp[n][m-1]){
          n--;
      }
      else 
      m--;
  }
  reverse(s.begin(),s.end());
  cout<<s<<endl;
}


Measured memory_bytes: 71168
# -*- coding: utf-8 -*-
N=int(input())
S=str(input())
if((N-1)%2 == 0):
    print('No')
else:
    K=int(N/2)
    T1=S[0:K]
    T2=S[K:]
    if(T1==T2):
        print("Yes")
    else:print("No")


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

int main(){
    long double x, ans;
    string u;
    int n;
    ans=0;

    cin>>n;
    for(int i=0;i<n;i++){
        cin>>x>>u;
        if(u=="JPY")ans+=x;
        else ans+=x*380000.0;
    }
    cout<<fixed<<setprecision(10)<<ans<<endl;

}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int m1 = sc.nextInt();
		int d1 = sc.nextInt();
		int m2 = sc.nextInt();
		int d2 = sc.nextInt();
		sc.close();

		if (d2 == 1) {
			System.out.println(1);
		} else {
			System.out.println(0);
		}

	}

}


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

///    ____ ____ ____ ____ ____
///   ||a |||t |||o |||d |||o ||
///   ||__|||__|||__|||__|||__||
///   |/__\|/__\|/__\|/__\|/__\|
///

using namespace std;

typedef long long ll;

const int N_MAX = 102;

const double PI = 3.14159265358979323846264338327950288;
const double EPS = 0.000001;

struct Point
{
    ll x, y;
};

ll dist (const Point &a, const Point &b)
{
    return (a.x - b.x) * (a.x - b.x) + (a.y - b.y) * (a.y - b.y);
}

ll area (const Point &a, const Point &b, const Point &c)
{
    return a.x * (b.y - c.y) + b.x * (c.y - a.y) + c.x * (a.y - b.y);
}

bool ok;

double ang (const Point &a, const Point &b, const Point &c)
{
    ll ab = dist(a, b);
    ll bc = dist(b, c);
    ll ac = dist(a, c);
    double angCos = (ab + ac - bc) / (2 * sqrt(ab) * sqrt(ac));
    if(1 - angCos <= EPS)
        return 0;
    ok = false;
    double ans = acos(angCos);
    if(area(b, a, c) > 0)
        ans = 2 * PI - ans;
    ans -= PI;
    ans /= 2 * PI;
    return ans;
}

int f (const Point &a)
{
    if(a.x > 0 && a.y >= 0)
        return 1;
    if(a.x <= 0 && a.y > 0)
        return 2;
    if(a.x < 0 && a.y <= 0)
        return 3;
    if(a.x >= 0 && a.y < 0)
        return 4;
}

Point O = {0, 0};

bool operator < (const Point &a, const Point &b)
{
    int fa = f(a), fb = f(b);
    if(fa != fb)
        return fa < fb;
    if(fa == 1 || fa == 3)
        return abs(a.y) * abs(b.x) < abs(b.y) * abs(a.x);
    return abs(a.y) * abs(b.x) > abs(b.y) * abs(a.x);
}

int n;

Point p[N_MAX];

vector <Point> v;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin >> n;
    for(int i = 1; i <= n; i++)
        cin >> p[i].x >> p[i].y;
    cout << fixed << setprecision(20);
    if(n == 2)
    {
        cout << 0.5 << "\n" << 0.5 << "\n";
        return 0;
    }
    for(int i = 1; i <= n; i++)
    {
        v.clear();
        for(int j = 1; j <= n; j++)
            if(j != i)
                v.push_back(Point{p[j].x - p[i].x, p[j].y - p[i].y});
        sort(v.begin(), v.end());
        double mx = 0;
        ok = true;
        for(int j = 0; j < (int)v.size(); j++)
        {
            int j1 = j + 1;
            if(j1 == (int)v.size())
                j1 = 0;
            mx = max(mx, ang(O, v[j], v[j1]));
        }
        if(ok == true)
            mx = 0.5;
        cout << mx << "\n";
    }
    return 0;
}


Measured memory_bytes: 4224
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); i++)
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define MOD 1000000007
using namespace std;
typedef long long ll;

int main(){
    string a, b, c;
    cin >> a >> b >> c;
    if(a[a.size()-1] == b[0] && b[b.size()-1] == c[0]) cout << "YES" << endl;
    else cout << "NO" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
	// your code goes here
	int X; cin>>X;
	int mx = 1,p,b;
	for(b = 2; b<=X;b++){
		p = b*b;
		while(p<=X){
			mx = max(mx,p);
			p*=b;
		}
	}
	
	if(p<=X) mx = max(mx,p);
	printf("%d\n",mx);
	return 0;
}

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

using namespace std;

typedef long long int ll;
typedef long double ld;
typedef string str;
typedef vector<char> vc;
typedef vector<ld> vd;
typedef vector<str> vs;
typedef vector<ll> vll;

const ld PI = acos(-1.0);
const ll MAX = 9000000000000000000;
const ll MIN = -9000000000000000000;

#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define fin(ans) cout << (ans) << endl;
#define all(a) a.begin(), a.end()

template <typename T>
T Sum(vector<T> n, ll a = 0, ll b = 0)
{
  if (b == 0)
  {
    return (accumulate(n.begin() + a, n.end(), 0));
  }
  else
  {
    return (accumulate(n.begin() + a, n.begin() + b, 0));
  }
}
template <>
ld Sum(vector<ld> n, ll a, ll b)
{
  if (b == 0)
  {
    return (accumulate(n.begin() + a, n.end(), 0));
  }
  else
  {
    return (accumulate(n.begin() + a, n.begin() + b, 0));
  }
}

template <typename T>
void Sort(T &n, ll a = 0, ll b = 0)
{
  if (b == 0)
  {
    return (sort(n.begin() + a, n.end()));
  }
  else
  {
    return (sort(n.begin() + a, n.begin() + b));
  }
}

template <typename T>
void Reve(T &n, ll a = 0, ll b = 0)
{
  if (b == 0)
  {
    return (reverse(n.begin() + a, n.end()));
  }
  else
  {
    return (reverse(n.begin() + a, n.begin() + b));
  }
}

template <typename T>
void V(T &n)
{
  for (ll i = 0; i < n.size(); i++)
  {
    cin >> n[i];
  }
}

template <typename T, typename U>
void V2(T &n, U &m)
{
  for (ll i = 0; i < n.size(); i++)
  {
    cin >> n[i] >> m[i];
  }
}

template <typename T, typename U, typename W>
void V3(T &n, U &m, W &p)
{
  for (ll i = 0; i < n.size(); i++)
  {
    cin >> n[i] >> m[i] >> p[i];
  }
}

void fYn(bool a)
{
  if (a)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  exit(0);
}
//最大公約数
ll gcd(ll a, ll b)
{
  return b ? gcd(b, a % b) : a;
}
//最小公倍数
ll lcm(ll a, ll b)
{
  return a * b / gcd(a, b);
}
//複数個の最小公倍数
ll nlcm(vector<ll> numbers)
{
  ll res;
  res = numbers[0];
  for (ll i = 1; i < numbers.size(); i++)
  {
    res = lcm(res, numbers[i]);
  }
  return res;
}
//累乗(xのn乗%mod)
ll mod_pow(ll x, ll n, ll mod = MAX)
{
  ll res = 1;
  while (n > 0)
  {
    if (n & 1)
      res = res * x % mod;
    x = x * x % mod;
    n >>= 1;
  }
  return res;
}

//大文字->小文字(+32)
//少数はなるべく整数に

void Main()
{
  ll n; cin >> n;
  vs s(n); V(s);
  Sort(s);
  ll flag = 1;
  map<str, ll> ans;
  for(ll i = 0;i < n;i++)
  {
    if(ans.count(s[i]))
    {
      ans[s[i]]++;
      flag = max(flag, ans[s[i]]);
    }
    else
    {
      ans[s[i]] = 1;
    }
  }
  for(ll i = 0;i < n;i++)
  {
    if(ans.count(s[i]))
    {
      if(flag == ans[s[i]])
      fin(s[i])
      ans.erase(s[i]);
    }
  }
}

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << fixed << setprecision(20);
  Main();
  return 0;
}

Measured memory_bytes: 25472
num = [[0 for i in range(101)] for j in range(101)]
r, c = map(int, input().split())
for i in range(r):
    num[i][:c] = list(map(int, input().split()))
    for j in range(c):
        num[i][c] += num[i][j]
for j in range(c+1):
    for i in range(r):
        num[r][j] += num[i][j]
for i in range(r+1):
    for j in range(c):
        print(num[i][j], end=' ')
    print(num[i][c])

Measured memory_bytes: 8336
#include <bits/stdc++.h>
using namespace std;
int gcd(int a, int b)
{
    if (a < b)
        return gcd(b, a);
    else if (a % b)
        return gcd(b, a % b);
    else
        return b;
}
int main()
{
  int n;
  cin>>n;
  long A[n];
  int cnt=0;
  for(int i=0; i<n; i++){
    cin>>A[i];
    if(A[i]<0)cnt++;
  }
  long long sum=0;
  if(cnt%2==0){
    for(int i=0; i<n; i++){
      sum+=abs(A[i]);
    }
    cout<<sum<<endl;
  }
  else{
    vector<long long>v;
    for(int i=0; i<n; i++){
      v.push_back(abs(A[i]));
      sum+=abs(A[i]);
    }
    sort(v.begin(),v.end());
    cout<<sum-2*v[0]<<endl;
  }

    
}

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

typedef struct _data
{
	long Q;
	long q;
	double l;
} data;

// struct _data data;

int q_cmp(const void *a, const void *b)
{
	return ((struct _data*)a)->q - ((struct _data*)b)->q;
}

int main()
{
	struct _data set[4];
	rep(i ,4)
		cin >> set[i].Q;
	long n;
	cin >> n;
	// long double n = N;
	set[0].q = 4 * set[0].Q;
	set[1].q = 2 * set[1].Q;
	set[2].q = set[2].Q;
	set[3].q = 0.5 * set[3].Q;

	set[0].l = 0.25;
	set[1].l = 0.5;
	set[2].l = 1.0;
	set[3].l = 2.0;
	int size = sizeof(set) / sizeof(_data);
	qsort(set, size, sizeof(_data), q_cmp);
	long ans = 0;
	rep(i,4)
	{
		// cout << (set[i].q * n % set[i].Q) << endl;
		// if (set[i].q * n % set[i].Q == 0 )
		// {
		// 	// cout << set[i].q * n % set[i].q << endl;
		// 	ans += set[i].q * n;
		// 	break;
		// }
		if (n >= set[i].l)
		{
			// cout << (long)(n / set[i].l)<< endl;
			ans += (long)(n / set[i].l) * set[i].Q;
			n -= (long)(n / set[i].l) * set[i].l;
			// cout << n << endl;
		}
		if (n == 0)
		{
			break;
		}
		// cout << set[i].Q << "|" << set[i].l << "|" << set[i].q<< endl;
	}
	// cout << set[0].q << (set[0].q * (long)n) % set[0].Q << endl;
	cout << ans << endl;
	return (0);
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<set>

using namespace std;

#define MAX(X,Y) ((X)>(Y) ? (X) : (Y))
#define MIN(X,Y) ((X)<(Y) ? (X) : (Y))

void dfs(set<char> graph[], char now, int &k, int dst[]) {
    if(dst[now] != -1) return;
    dst[now] = 100000;
    for(char cn : graph[now])
        dfs(graph, cn, k, dst);
    dst[now] = k++;
}

bool strong(set<char> graph[], set<char> rev[]) {
    int ord[256];
    memset(ord, 0xFF, sizeof(ord));
    int k=0;
    for(char c='A'; c<='Z'; c++)
        dfs(graph, c, k, ord);
    while(k >= 0) {
        for(char c='A'; c<='Z'; c++)
            if(ord[c] == k)
                for(char cb : rev[c])
                    if(ord[cb] < ord[c])
                        return false;
        k--;
    }
    return true;
}


int main(void) {
    int n;
    scanf("%d",&n);
    for(int i=0; i<n; i++) {
        char s[100][100];
        int minx[256], maxx[256], miny[256], maxy[256];
        set<char> cs[256], rev[256];

        memset(s, 0, sizeof(s));
        memset(maxx, 0xFF, sizeof(maxx));
        memset(maxy, 0xFF, sizeof(maxy));
        memset(minx, 0x7F, sizeof(minx));
        memset(miny, 0x7F, sizeof(miny));

        int h, w;
        scanf("%d%d",&h,&w);
        for(int j=0; j<h; j++)
            scanf("%s",s[j]);

        for(int ih=0; ih<h; ih++)
            for(int iw=0; iw<w; iw++) {
                minx[s[ih][iw]] = MIN(minx[s[ih][iw]] , iw);
                miny[s[ih][iw]] = MIN(miny[s[ih][iw]] , ih);
                maxx[s[ih][iw]] = MAX(maxx[s[ih][iw]] , iw);
                maxy[s[ih][iw]] = MAX(maxy[s[ih][iw]] , ih);
            }
        bool safe = true;
        for(char c='A'; c<='Z'; c++) {
            if(minx[c] == 0x7F7F7F7F) continue;

            for(int iw=minx[c]; iw<=maxx[c]; iw++)
                for(int ih=miny[c]; ih<=maxy[c]; ih++) {
                    if(s[ih][iw] == '.') { safe = false; continue; }
                    if(c != s[ih][iw])
                        cs[c].insert(s[ih][iw]), rev[s[ih][iw]].insert(c);
                }
        }

/*        for(char c='A'; c<='Z'; c++) {
            printf("%c: ", c);
            for(char cn : cs[c])
                printf("%c ", cn);
            puts("");
        }*/
        if(safe)
            safe = strong(cs, rev);

        puts(safe ? "SAFE" : "SUSPICIOUS");
    }
    return 0;
}

Measured memory_bytes: 2684
#include<iostream>
#include<map>
#include<string>
#include<algorithm>
using namespace std;
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n, m, sum = 0;
	cin >> n >> m;
	for (int i = 0; i < 12; i++) {
		if (n >= i + 1) {
			if (n == i + 1) {
				if (m >= i + 1) {
					sum++;
				}
			}
			else ++sum;
		}
	}
	cout << sum;
}

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

using namespace std;
using ll=long long;
using ull=unsigned long long;
using pii=pair<int,int>;

#define INF LONG_MAX
#define MOD 1000000007
#define rng(a) a.begin(),a.end()
#define rrng(a) a.end(),a.begin()
#define endl "\n"
#define int ll

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

  int N,K;
  cin>>N>>K;
  vector<int>P(N),C(N);
  for(int i=0;i<N;i++)cin>>P[i],P[i]--;
  for(int i=0;i<N;i++)cin>>C[i];

  ll ans=-LONG_MAX;
  for(int i=0;i<N;i++){
    int now=i;
    vector<int>dp(N,-LONG_MAX);
    int Max=-LONG_MAX;
    vector<int>p(N);
    for(int j=0;j<min(K,N+1);j++){
      p[now]=j;
      int next=P[now];
      if(j==0){
        dp[next]=C[next];
        Max=max(Max,dp[next]);
        now=next;
        continue;
      }

      if(dp[next]!=-LONG_MAX){
        int k=K-j-1;
        int DD=k/(p[now]-p[next]+1);
        int PP=k%(p[now]-p[next]+1);
        int memo=dp[next];
        dp[next]=dp[now]+C[next];
        Max=max(Max,dp[next]);
        now=next;
        j++;
        if(j>=K)break;
        int CC=dp[now]-memo;
        if(CC>0){
          dp[now]=CC*DD+dp[now];
        }
        Max=max(Max,dp[now]);
        for(int l=0;l<PP;l++){
          next=P[now];
          dp[next]=dp[now]+C[next];
          Max=max(Max,dp[next]);
          now=next;
        }
        break;
      }

      dp[next]=dp[now]+C[next];
      Max=max(Max,dp[next]);
      now=next;
    }
    ans=max(ans,Max);
  }
  cout<<ans<<endl;

  return 0;
}


Measured memory_bytes: 3780
import math
from collections import defaultdict
ml=lambda:map(int,input().split())
ll=lambda:list(map(int,input().split()))
ii=lambda:int(input())
ip=lambda:list(input())
ips=lambda:input().split()

"""========main code==============="""

a=ii()
lol=["AC","WA","TLE","RE"]
d=defaultdict(int)
for _ in range(a):
    p=input()
    d[p]+=1
for i in lol:
    print(i,"x",d[i])

Measured memory_bytes: 69968
#include <bits/stdc++.h> //C++の標準ライブラリを一行で一括でインクルードする
#include <math.h> //数学関数と数学定数を利用する
#define rep(i,n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
template<class T> void chmax(T &a,T b) { if (a<b) a=b;}
template<class T> void chmin(T &a,T b) { if (a>b) a=b;}

ll func(ll n,ll x){
  
  if(n == -1){
    return 0LL;
  }else{
    return n/x+1;
  }
}

int main(){
  ll a,b,x;
  cin >> a >> b >> x;
  ll l = func(b,x);
  ll r = func(a-1,x);
  cout << l - r;
  
  return 0;
}

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

int main()
{
int S, s, h, m;
cin >> S;
s = S % 60;
m = ((S - s) / 60) % 60;
h = ((S - s) / 60 - m)/60;
cout << h <<":"<< m << ":" << s << endl;
return 0;
}



Measured memory_bytes: 3104
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (int i = a; i < (int)b; i++)
#define all(v) v.begin(), v.end()
const int MOD = 1e9 + 7;
const int INF = 1e9;
//'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122

int main() {
    int n;
    string s;
    cin >> n;
    cin >> s;
    int ans = 0;
    rep(i, 0, 1000) {
        int d[3] = {i / 100, (i / 10) % 10, i % 10};
        int tmp = 0;
        rep(j, 0, n) {
            if (s[j] == '0' + d[tmp]) tmp++;
            if (tmp == 3) break;
        }
        if (tmp == 3) ans++;
    }
    cout << ans << endl;
    return 0;
}


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

using namespace std;

int get_GCD(int a, int b) {
	int r;
	if (a < b) {
		swap(a, b);
	}
	while ((r = a % b) != 0) {
		a = b;
		b = r;
	}
	return b;
}

int get_LCM(int a, int b, int gcd) {
	return (a * b) / gcd;
}

int main(int argc, char *argv[]) {
	int n;
	cin >> n;
	int a[n];
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	
	if (n >= 2) {
		int all_lcm = a[0];
		for (int i = 0; i < n - 1; i++) {
			int lcm = get_LCM(a[i], a[i+1], get_GCD(a[i], a[i+1]));
			all_lcm = get_LCM(all_lcm, lcm, get_GCD(all_lcm, lcm));
		}
		int sum = 0;
		for (int i = 0; i < n; i++) {
			sum += all_lcm / a[i];
		}
		float ans = (float)all_lcm / (float)sum;
		
		cout << ans << endl;
	} else {
		cout << a[0] << endl;
	}
}

Measured memory_bytes: 384
import itertools

def primes(n):
    is_prime = [True] * (n + 1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n ** 0.5) + 1):
        if not is_prime[i]:
            continue
        for j in range(i * 2, n + 1, i):
            is_prime[j] = False
    # return [i for i in range(n + 1) if is_prime[i]]
    return is_prime

p_list = primes(101010)
cnt_list = [0] * 101010

for i in range(1, 101011, 2):
    if p_list[i] and p_list[(i + 1) // 2]:
        cnt_list[i] = 1

cnt_list = list(itertools.accumulate(cnt_list))

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

Measured memory_bytes: 7716
#include <vector>
#include <iostream>
#include <numeric>
#include <list>
#include <limits>
#include <algorithm>
#include <cmath>
#include <unordered_map>
#include <unordered_set>
#include <set>
#include <map>

#define pi 3.141592653589793
#define mp make_pair
#define ll long long
#define ull unsigned long long
#define pb push_back
#define FP(i, a, b, k) for (__typeof(a) i = a; i < b; i += k)
#define FS(i, a, b, k) for (__typeof(a) i = a; i > b; i -= k)
#define IT(it, a) for (__typeof(a.begin()) it = a.begin(); it != a.end(); ++it)

using namespace std;
typedef vector<int> VII;
typedef vector<ll> VLL;
typedef pair<int, int> PII;
typedef vector<pair<int, int>> VPII;
typedef vector<pair<int, PII>> VPPI;

const long long MOD = 1e9 + 7;
const long long INF = 1e9;

template <typename T>
std::ostream &operator<<(ostream &os,
                         const vector<T> &v)
{
    for (T const &i : v)
    {
        os << i << " ";
    }
    os << endl;
    return os;
}
template <typename T>
std::ostream &operator<<(ostream &os,
                         const vector<vector<T>> &v)
{
    for(auto i: v){
        for(auto j: i)
            cout<<j<<" ";
        os << endl;
    }
    os << endl;
    return os;
}

template <class T>
inline T gcd(T x, T y)
{
    if (!y)
        return x;
    return gcd(y, x % y);
}
vector<int> sieve(int n)
{
    vector<bool> s(n, true);
    for (int i = 2; i * i <= n; i++)
        if (s[i])
            for (int j = 2 * i; j < n; j += i)
                s[j] = false;

    vector<int> primes;
    for (int i = 0; i < n; i++)
        if (s[i])
            primes.push_back(s[i]);

    return primes;
}


int main()
{
   
    int n,x;
    cin>>n;
    vector<int> ar(n);
    int acc = 0;
    for(auto &i: ar) cin>>i, acc ^= i;
    for(auto i: ar) {
        int temp = i ^ acc;
        cout<< temp<<" ";

    }

    return 0;
}

Measured memory_bytes: 3684
#include <iostream>
#include <string>
#include <queue>
using namespace std;

int main() {
    int N, A, B, C, X, Y;
    while (cin >> N >> A >> B >> C >> X && (N || A || B || C || X)) {
        queue<int> q;
        for (int i=0; i<N; ++i) {
            cin >> Y;
            q.push(Y);
        }
        int time = 0;
        while (time <= 10000) {
            if (q.front() == X) q.pop();
            if (q.empty()) break;
            X = (A * X + B) % C;
            time ++;
        }
        if (10000 < time) {
            cout << "-1" << endl;
        } else {
            cout << time << endl;
        }
    }
    return 0;
}

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

a=[""]*n

for i in range(n):
  a[i] = int(input())

light = a[0]
counter = 1
result = -1
if light == 2:
  print(1)
  exit()
for i in range(n):
  light = a[light-1]
  counter += 1
  if light == 2:
    result = counter
    break
print(result)

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

int main() {
  int P, Q, R; // AB, BC, CA
  cin >> P >> Q >> R;

  int time = 400;

  time = min(time, P+Q);
  time = min(time, P+R);
  time = min(time, Q+R);

  cout << time << endl;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>

using namespace std;

typedef long long int64;
typedef pair<int, int> ii;
const int INF = 1 << 30;

const int N = 200;
int main() {
  int n;
  string s, t;
  cin >> n >> s >> t;
  int ret = 0;
  for (int i = n; i > 0; --i) {
    if (s.substr(n - i, i) == t.substr(0, i)) {
      ret = i;
      break;
    }
  }
  cout << 2 * n - ret << endl;
  return 0;
}


Measured memory_bytes: 256
fn main() {
    proconio::input! {
        mut s: proconio::marker::Chars,
    }
    let alphas = "abcdefghijklmnopqrstuvwxyz".chars().collect::<Vec<_>>();
    let mut set = std::collections::BTreeSet::new();
    for c in &s {
        set.insert(*c);
    }
    if set.len() != 26 {
        let tail = alphas.iter().find(|x| !set.contains(x)).unwrap();
        println!("{}{}", s.iter().collect::<String>(), tail);
    } else if {
        let mut cond = true;
        let revalpha = alphas.iter().cloned().rev().collect::<Vec<_>>();
        for i in 0..s.len() {
            if s[i] != revalpha[i] {
                cond = false;
            }
        }
        cond
    } {
        println!("-1");
    } else {
        let mut candidates = alphas
            .iter()
            .cloned()
            .filter(|x| !set.contains(x))
            .collect::<std::collections::BTreeSet<_>>();
        for i in (0..s.len()).rev() {
            if let Some(change) = candidates.iter().find(|x| **x > s[i]) {
                s[i] = *change;
                break;
            } else {
                candidates.insert(s[i]);
                s[i] = ' ';
            }
        }
        println!("{}", s.iter().collect::<String>().trim_end());
    }
}


Measured memory_bytes: 2128
#include <iostream>
#include <algorithm>
#include <functional>
using namespace std;
 
int main() {
    int a, b;
    cin >> a >> b;

    int ans1 = a + b;
    int ans2 = a - b;
    int ans3 = a * b;

    int ans= std::max({ans1, ans2, ans3});

    cout << ans << endl;


    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
    int length;
    int questions;
    char str[100001];
    int s[100000];
    int e[100000];
    int results[100000] = {0};

    scanf("%d %d", &length, &questions);
    scanf("%s", &str);
    
    for(int i = 0 ; i < questions ; i++)
    {
        scanf("%d %d", &s[i], &e[i]);
    }
    for(int i = 1; i < length ; i++)
    {
        if( str[i - 1] == 'A' && str[i] == 'C')
        {
            results[i]++;
        }
        results[i] = results[i] + results[i - 1];
    }
    for(int i = 0 ; i < questions ; i++)
    {
        printf("%d\n", results[e[i] - 1] - results[s[i] - 1]);
    }

    return 0;
}

Measured memory_bytes: 2048
#include<iostream>
using namespace std;
int main() {
	int N, M, A[25] = {}, B[25] = {}, C, i, j, Ccheck = 0, count = 0;
	cin >> N >> M >> C;
	for (i = 0;i<M;i++) {
		cin >> B[i];
	}
	for (j = 0;j < N;j++) {
		for (i = 0;i < M;i++) {
			cin >> A[i];
			Ccheck += A[i] * B[i];
		}
		if (Ccheck + C > 0) {
			count++;
		}
      Ccheck = 0;
	}
	cout << count << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rrep(i, n) for (int i = (n); i >= 0; i--)
#define loop(i, r, n) for (int i = (r); i < (n); i++)
#define pb push_back
#define all(in) in.begin(),in.end()

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

using ll = long long;
using ull = unsigned long long;
using namespace std;

int main(){
    ll n, d; cin >> n >> d;
    ll ans = 0;
    rep(i,n){
        ll x, y; cin >> x >> y;
        if(x*x+y*y <= d*d) ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3632
#include <stdio.h>

int main(){
	
	char A, B, C;
	
	scanf ("%c %c %c", &A, &B, &C);
	
	if ((A==B & A==C && B==C) || (A != B && A != C && B != C))
	{
		printf("No");
	}
	else{
		printf("Yes");
	}
	
	return 0;
}

Measured memory_bytes: 1672
#define _CRT_SECURE_NO_WARNINGS
#include <cstdio>
#include <cstring>
#include<string>
#include <iostream>
#include<vector>
#include<map>
#include<stack>
#include<queue>
#include<algorithm>
#include<iomanip>
#include<cstdlib>
#include<cmath>
#include<sstream>
using namespace std;
#define ll long long
#define INF 0x7fffffff
inline int read() {
    char ch = getchar();
    int x = 0, f = 1;
    while (ch < '0' || ch>'9') { if (ch == '-') f = -1; ch = getchar(); }
    while (ch >= '0' && ch <= '9') x = x * 10 + (ch - '0'), ch = getchar();
    return x * f;
}
int main()
{
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);
    string a, b,c;
    stringstream s;
    cin >> a >> b;
    c = a + b;
    s << c;
    int x;
    s >> x;
    s.str("");
    s.clear();
    double m = sqrt(x);
    int n= sqrt(x);
    double q = m - n;
    if (fabs(q) < 1e-9)
        cout << "Yes";
    else
        cout << "No";
    return 0;
}

Measured memory_bytes: 384
// abc133b: Good Distance
#include <bits/stdc++.h>
using namespace std;

#define upto(i,s,e,d) for(int i=(s);i<(e);i+=(d))

using vi = vector<int>;
using vvi = vector<vi>;

bool is_z(int x){
  int a=(int)sqrt(x);
  return a*a==x;
}

int len2(vi &x, vi &y, int d){
  int s=0;
  upto(i,0,d,1) s+=pow(x[i]-y[i], 2);
  return s;
}

int main(){
  int n,d; cin>>n>>d;
  vvi x(n, vi(d));
  upto(i,0,n,1)upto(j,0,d,1)cin>>x[i][j];
  int c=0;
  upto(i,0,n-1,1){
    vi &a=x[i];
    upto(j,i+1,n,1){
      vi &b=x[j];
      if(is_z(len2(a,b,d))) c++;
    }
  }
  cout<<c<<endl;
}

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

#define ll long long
#define ull unsigned long long
#define N 100005
#define mod 998244353 
#define boost ios_base::sync_with_stdio(false);cin.tie(0)
#define prec(n) fixed<<setprecision(n)

#define mii unordered_map<int,int>
#define mll unordered_map<ll,ll>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define fi  first

#define se second
#define pb push_backP
#define mp make_pair
#define pp pop_back
#define vii vector<int>
#define vll vector<ll>
#define vpp vector<pii>
#define all(c) c.begin(),c.end()
#define tr(it,c) for(it = c.begin() ; it!=c.end() ; it++)
int inf = INT_MAX ;
ll modulo(ll num,ll MOD=mod){ return ((num%MOD)+MOD)%MOD;} // for negative integer
ll power(ll b,ll e,ll MOD=mod){ll ans=1; while(e){if(e%2) ans=(ans*b)%MOD; b=(b*b)%MOD; e/=2;} return ans;}
ll inv(ll num,ll MOD=mod){ return power(modulo(num),MOD-2,MOD); }
ll gcd(ll a,ll b){ return ((b==0) ? a:gcd(b,a%b));}

int main(){
	boost;

	ll n;
    cin>>n;

    ll k = 1,ans = 1;
    while(k<=n){
        ans = 2*ans + 1;
        k = k*2;
    }

    cout<<(ans-1)/2;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define sz(c)      int(c.size())
#define rep(i,a,b) for (int i=a; i<(b); ++i)
#define per(i,a,b) for (int i=(b)-1; i>=(a); --i)
using namespace std;
using ll = long long;

int const MD=int(1e9)+7;
int const MAXNM=220000;

inline int madd(int x,int y) {
	if (x+y<MD) return x+y; else return x+y-MD;
}
inline int msub(int x,int y) {
	if (x-y>=0) return x-y; else return x-y+MD;
}
inline int mmul(int x,int y) {
	return int(ll(x)*y % MD);
}
int mpow(int x,int y) {
	int res=1;
	while (y>0) {
		if (y%2) res=mmul(res,x);
		x=mmul(x,x);
		y/=2;
	}
	return res;
}
inline int minv(int x) {
	return mpow(x,MD-2);
}

int fact[MAXNM];
int invfact[MAXNM];
void mfact_init() {
	fact[0]=invfact[0]=1;
	rep(i,1,MAXNM) {
		fact[i]=mmul(fact[i-1],i);
		invfact[i]=minv(fact[i]);
	}
}
inline int mcomb(int x,int y) {
	if (x<y) return 0;
	return mmul(fact[x],mmul(invfact[x-y],invfact[y]));
}

int main() {
	cin.tie(0);
	ios_base::sync_with_stdio(0);
	cout<<fixed<<setprecision(10);

	mfact_init();

	int N,M,K;
	cin>>N>>M>>K;
	
	int res=0;
	
	int c=mcomb(N*M-2,K-2);
	rep(dx,1,N) res=madd(res,mmul(c,mmul(dx,mmul(N-dx,mmul(M,M)))));
	rep(dy,1,M) res=madd(res,mmul(c,mmul(dy,mmul(M-dy,mmul(N,N)))));
	
	cout<<res<<"\n";
}


Measured memory_bytes: 1920
package main

import "fmt"

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

	var str string
	switch day {
	case 22:
		str = "Christmas Eve Eve Eve"
	case 23:
		str = "Christmas Eve Eve"
	case 24:
		str = "Christmas Eve"
	case 25:
		str = "Christmas"
	}
	fmt.Println(str)
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll n, x[110000], l, numq, a, b, nexth[110000], table[30][110000];

void build_sparse()
{
	for (int i = 0; i < 20; i++)
	{
		if ((1 << i) >= n)
			break;
		for (int j = 0; j < n; j++)
		{
			if (i == 0)
			{
				table[i][j] = nexth[j];
			}
			else if (table[i - 1][j] == -1)
			{
				table[i][j] = -1;
			}
			else
			{
				if (table[i - 1][table[i - 1][j]] == -1)
					table[i][j] = -1;
				else
					table[i][j] = table[i - 1][table[i - 1][j]];
			}
		}
	}
}

int solve(int x1, int y1)
{
	if (x1 >= y1)
		return 0;
	int j;
	for (j = 0; j < 20; j++)
	{
		if (table[j][x1] > y1 || table[j][x1] == -1)
			break;
	}
	j--;
	if (j == -1)
		return 1;
	return (solve(table[j][x1], y1) + (1<<j));
}

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

	queue<int> q;
	q.push(0);

	for (int i = 1; i < n; i++)
	{
		int temp = x[q.front()];
		while (x[i]-temp > l)
		{
			nexth[q.front()] = i - 1;
			q.pop();
			temp = x[q.front()];
		}
		q.push(i);
	}

	while (!q.empty())
	{
		nexth[q.front()] = n - 1;
		q.pop();
	}

	nexth[n - 1] = -1;

	memset(table, -1, sizeof(table));
	build_sparse();

	cin >> numq;

	for (int i = 0; i < numq; i++)
	{
		cin >> a >> b;
		if (a > b)
		{
			int temp = a;
			a = b;
			b = temp;
		}
		a--; b--;

		int ans = solve(a, b);
		cout << ans << endl;
	}
}

Measured memory_bytes: 28288
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pll = pair<ll, ll>;
using vl = vector<ll>;

/* short */
#define pb push_back
#define mp make_pair
#define Fi first
#define Se second
#define ALL(v) begin(v), end(v)
#define RALL(v) rbegin(v), rend(v)

/* REPmacro */
#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 REP(i, n) for(int i = 0; i < (n); i++)
#define FOREACH(x, a) for(auto x : a)

/* exchange */
#define CHMIN(a, b) (a) = min((ll)(a), (ll)(b))
#define CHMAX(a, b) (a) = max((ll)(a), (ll)(b))

/* function */
#define IN(x) cin >> x
#define DEBUG(x) cerr << (x) << " "
#define LN() cerr << "\n"
#define PRINT(x) cout << (x) << endl
#define BR cout << endl

/* const */
const int ARRAY = 100005;
const int INF = 1001001001; // 10^9
const ll LINF = 1001001001001001001; // 10^18
const int MOD = 1e9 + 7;

ll N = 0;
ll ret = 0;
string s;

struct Node {
  vl adj;
};

void dfs(ll init, vl& dist, vector<bool>& checked, vector<Node>& nodes) {
  stack<ll> s;
  s.push(init);
  dist[init] = 0;
  checked[init] = true;
  while(!s.empty()) {
    ll t = s.top();
    s.pop();
    FOREACH(k, nodes[t].adj) {
      if (!checked[k]) {
        dist[k] = dist[t] + 1;
        checked[k] = true;
        s.push(k);
      }
    }
  }
}

// bool compare(pair<ll, ll> a, pair<ll, ll> b) {
//   if (a.first != b.first) {
//     return a.first > b.first;
//   } else {
//     return a.second < b.second;
//   }
// }

int main(void){
  ll u, v;
  IN(N);
  IN(u);
  IN(v);
  
  vector<Node> nodes(N+1);
  REP(i, N) {
    ll a, b;
    IN(a);
    IN(b);
    nodes[a].adj.pb(b);
    nodes[b].adj.pb(a);
  }
  vector<bool> checkedT(N+1, false);
  vector<bool> checkedA(N+1, false);
  vl distT(N+1);
  vl distA(N+1);
  dfs(u, distT, checkedT, nodes);
  dfs(v, distA, checkedA, nodes);

  // FOR(i, 1, N+1) DEBUG(distT[i]);
  // LN();
  // FOR(i, 1, N+1) DEBUG(distA[i]);
  // LN();

  // vector<pair<ll, ll>> A;
  vl A;
  FOR(i, 1, N+1) {
    if (distT[i] <= distA[i]) {
      A.pb(distA[i] - 1);
    }
  }
  sort(ALL(A));
  reverse(ALL(A));
  PRINT(A[0]);
}


Measured memory_bytes: 9084
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <unordered_map>
#include <vector>

#define MOD 1000000007
//#define PI 3.14159265358979

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

using namespace std;

template < typename T >
ostream &operator<<(ostream &os, const vector< T > &A) {
	for (int i = 0; i < A.size(); i++)
		os << A[i] << " ";
	os << endl;
	return os;
}
template <>
ostream &operator<<(ostream &os, const vector< vector< int > > &A) {
	int N = A.size();
	int M;
	if (N > 0)
		M = A[0].size();
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < M; j++)
			os << A[i][j] << " ";
		os << endl;
	}
	return os;
}

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

struct edge {
	int from, to, d, c;
	edge(int _from = 0, int _to = 0, int _d = 0, int _c = 0) {
		from = _from;
		to = _to;
		d = _d;
		c = _c;
	}
	bool operator<(const edge &rhs) const {
		return (d == rhs.d) ? (c < rhs.c) : (d < rhs.d);
	}
};

typedef vector< edge > edges;
typedef vector< edges > graph;
struct flow {
	int to, cap, rev, cost;
	flow(int to = 0, int cap = 0, int rev = 0, int cost = 0) : to(to), cap(cap), rev(rev), cost(cost) {}
};
typedef vector< vector< flow > > flows;

const int di[4] = {0, -1, 0, 1};
const int dj[4] = {-1, 0, 1, 0};
const int ci[5] = {0, 0, -1, 0, 1};
const int cj[5] = {0, -1, 0, 1, 0};
const ll LINF = LLONG_MAX / 2;
const int INF = INT_MAX / 2;
const double PI = acos(-1);

template < typename T, typename U >
bool chmin(T &x, const U &y) {
	if (x > y) {
		x = y;
		return true;
	}
	return false;
}
template < typename T, typename U >
bool chmax(T &x, const U &y) {
	if (x < y) {
		x = y;
		return true;
	}
	return false;
}

struct initializer {
	initializer() {
		cout << fixed << setprecision(11);
	}
};
initializer _____;

int N, M, K, T, Q;
int main() {
	cin >> N >> K;
	vector< int > A(N);
	ll psum = 0;
	rep(i, N) {
		cin >> A[i];
		if (A[i] > 0)
			psum += A[i];
	}
	ll w = 0;
	rep(i, K - 1) {
		w += A[i];
		if (A[i] > 0)
			psum -= A[i];
	}
	ll ans = 0;
	for (int i = K - 1; i < N; i++) {
		w += A[i];
		if (A[i] > 0)
			psum -= A[i];
		ll tmp = psum + (w > 0 ? w : 0);
		chmax(ans, tmp);
		w -= A[i - K + 1];
		if (A[i - K + 1] > 0)
			psum += A[i - K + 1];
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
 
int main(){
    int N;
    cin >> N;
    string S;
    cin >> S;

    int r[N], g[N], b[N];
    r[0] = 0;
    g[0] = 0;
    b[0] = 0;
    for(int i=0;i<N;i++){
        if(S[i] == 'R')
            r[0]++;
        else if(S[i] == 'G')
            g[0]++;
        else
            b[0]++;
    }
    if(S[0] == 'R')
        r[0]--;
    else if(S[0] == 'G')
        g[0]--;
    else
        b[0]--;
    for(int i=1;i<N;i++){
        r[i] = r[i-1];
        g[i] = g[i-1];
        b[i] = b[i-1];
        if(S[i] == 'R'){
            r[i]--;
        }else if(S[i] == 'G'){
            g[i]--;
        }else{
            b[i]--;
        }
    }
    /*
    for(int i=0;i<N;i++){
        cout << r[i] << ' ' << g[i] << ' ' << b[i] << endl;
    }
    */

    ll ans = 0;
    for(int i=0;i<N-2;i++){
        for(int j=i+1;j<N-1;j++){
            if(S[i] == 'R'){
                if(S[j] == 'G')
                    ans += b[j];
                if(S[j] == 'B')
                    ans += g[j];
            }else if(S[i] == 'G'){
                if(S[j] == 'R')
                    ans += b[j];
                if(S[j] == 'B')
                    ans += r[j];
            }else{  // B
                if(S[j] == 'R')
                    ans += g[j];
                if(S[j] == 'G')
                    ans += r[j];
            }
        }
    }

    for(int i=1;2*i<N;i++){
        for(int j=0;j+2*i<N;j++){
            string s;
            s += S[j];
            s += S[j+i];
            s += S[j+2*i];
            //cout << s << endl;
            if(s == "RGB" || s == "RBG" ||
               s == "GRB" || s == "GBR" ||
               s == "BRG" || s == "BGR"){
                if(ans > 0)
                    ans--;
            }
        }
    }

    cout << ans << endl;




}

Measured memory_bytes: 3688
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<ll, P> P3;
typedef pair<P ,P> PP;
constexpr ll MOD = ll(1e9) + 7;
constexpr int IINF = INT_MAX;
constexpr ll LLINF = LLONG_MAX;
constexpr int MAX_N = int(2e5) + 5;
constexpr double EPS = 1e-9;
constexpr int di[] = {0, 1, 0, -1}, dj[] = {1, 0, -1, 0};
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i > 0; i--)
#define SORT(v) sort((v).begin(), (v).end())
#define SORTR(v) sort((v).rbegin(), (v).rend())
#define ALL(v) (v).begin(), (v).end()

int h, w, field[25][25], si, sj, gi, gj, ans = 99;

bool isIn(int i, int j){
    return i>=0 && i<h && j>=0 && j<w;
}

void dfs(int i, int j, int cnt = 1){
    if(cnt > 10) return;
    for(int k=0;k<4;k++){
        int ni = i, nj = j;
        while(isIn(ni+di[k], nj+dj[k]) && field[ni+di[k]][nj+dj[k]]!=1){
            ni += di[k];
            nj += dj[k];
            if(ni==gi && nj==gj){
                ans = min(ans, cnt);
                return;
            }
        }
        if(!isIn(ni+di[k], nj+dj[k])) continue;
        if(ni==i && nj==j) continue;
        field[ni+di[k]][nj+dj[k]] = 0;
        dfs(ni, nj, cnt + 1);
        field[ni+di[k]][nj+dj[k]] = 1;
    }
    return;
}

int main() {
    while(cin >> w >> h, w){
        for(int i=0;i<h;i++){
            for(int j=0;j<w;j++){
                cin >> field[i][j];
                if(field[i][j] == 2){
                    si = i;
                    sj = j;
                }
                if(field[i][j] == 3){
                    gi = i;
                    gj = j;
                }
            }
        }
        ans = 99;
        dfs(si, sj);
        cout << (ans <= 10 ? ans : -1) << endl;
    }
    return 0;
}





Measured memory_bytes: 3008