akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <fstream>
#include <stdio.h>
#include <math.h>
#include <time.h>
#include <string>
#include <tuple>
#include <vector>
#include <map>
#include <unordered_map>
#include <list>
#include <set>
#include <stack>
#include <queue>
#include <cstdlib>
#include <algorithm>
#include <random>
#include <cassert>
using namespace std;
#define LL long long
#define MP(a, b) make_pair(a, b)
#define MMP(a, b, c) make_pair(make_pair(a, b), c)
#define MAX 1000000000
#undef INT_MIN
#undef INT_MAX
#define INT_MIN -2147483647
#define INT_MAX 2147483647
#define LL_MIN (LL)-9223372036854775807
#define LL_MAX (LL)9223372036854775807
#define PI 3.14159265359

int main(){
    iostream::sync_with_stdio(false);
    
    int N;
    cin >> N;
    LL L[100];
    L[0] = 2; L[1] = 1;
    for(int i=2; i<=N; i++) L[i] = L[i-1] + L[i-2];
    cout << L[N] << endl;
    
    return 0;
}


/*

int main(){
    iostream::sync_with_stdio(false);
    
    
    
    return 0;
}
*/

/*

int main(){
    iostream::sync_with_stdio(false);
    
    
    
    return 0;
}
*/

Measured memory_bytes: 888
import sys
sys.setrecursionlimit(10 ** 9)

input = sys.stdin.readline

N = int(input())

G =[[] for _ in range(N + 1)] #iさんが勝った相手のリストを要素とするリスト
for i in range(2, N + 1):
    a = int(input())
    G[a].append(i)

# print (G)

def calc(x): #xからの移動先を検討
    tmp = 0
    lst = []
    for next_ in G[x]:
        y = calc(next_)
        lst.append(y)
    lst.sort()
    for i in lst:
        if tmp >= i:
            tmp += 1
        else: #tmp < i
            tmp = i
    return tmp + 1

ans = calc(1) - 1

print (ans)

Measured memory_bytes: 112636
from math import sqrt
xp0, yp0, xp1, yp1 = map(int, input().split())
a = [xp0, yp0]
b = [xp1, yp1]
q = int(input())

CCW = {1: 'COUNTER_CLOCKWISE',
       2: 'CLOCKWISE',
       3: 'ONLINE_BACK',
       4: 'ONLINE_FRONT',
       5: 'ON_SEGMENT',}

def dot(a, b):
    return sum([i * j for i,j in zip(a, b)])

def sub(a, b):
    return [a[0] - b[0],a[1] - b[1]]

def cross(a, b):
    return  a[0] * b[1] - a[1] * b[0]

def _abs(a):
    return sqrt(a[0] ** 2 + a[1] ** 2)

def ccw(a, b, c):
    x = sub(b, a)
    y = sub(c, a)
    if cross(x, y) > 0: return 1
    if cross(x, y) < 0: return 2
    if dot(x, y) < 0: return 3
    if _abs(x) < _abs(y): return 4
    return 5

for i in range(q):
    c = list(map(int, input().split()))
    print(CCW[ccw(a, b, c)])
    

Measured memory_bytes: 7972
#include <bits/stdc++.h>
using namespace std;
#define rep(i, a) for(int i=0; i<(a); i++)
typedef long long ll;
template<typename T>
struct edge {
  int src, to;
  T cost;
  edge(int to, T cost) : src(-1), to(to), cost(cost) {}
  edge(int src, int to, T cost) : src(src), to(to), cost(cost) {}
  edge &operator=(const int &x) {
    to = x;
    return *this;
  }
  operator int() const { return to; }
};
template<typename T>
using Edges = vector<edge<T>>;
template<typename T>
using WeightedGraph = vector<Edges<T>>;
using UnWeightedGraph = vector<vector<int>>;
template<typename T>
using Matrix = vector<vector<T>>;

/////////////////////////////////////////////////////////////////////
const ll inf = 1LL<<60;

int main()
{
  ll n; cin>>n;
  vector<ll> a(n);
  rep(i, n) cin>>a[i];

  sort(a.rbegin(),a.rend());

  vector<ll> x;
  rep(i, n) {
    if ((int)(x.size()) >= 2) break;
    if (a[i] == a[i+1]) {
      x.push_back(a[i]);
      i++;
    }
  }
  if ((int)(x.size()) < 2) {
    cout << 0 << endl;
    return 0;
  }
  cout << x[0]*x[1] << endl;

  return 0;
}


Measured memory_bytes: 3964
import qualified Data.ByteString.Char8 as BC
import Data.Maybe

readIntsLine :: IO [Int]
readIntsLine = map (fst . fromJust . BC.readInt) . BC.words <$> BC.getLine

solve :: [Int] -> Int -> Int -> Int
solve [a] _ _ = 0
solve [a1, a2] c m = if a1 >= a2 then max (c + 1) m else m
solve (a1:a2:as) c m = if a1 >= a2
                       then solve (a2:as) (c + 1) nextm
                       else solve (a2:as) 0 m
  where nextm = max (c + 1) m

main :: IO ()
main = do
  getLine
  hs <- readIntsLine
  print $ solve hs 0 0

Measured memory_bytes: 14844
#include <stdio.h>
#define HORIZONTAL 0
#define VERTICAL 1


int board[101][101], visited[101][101];	/* board[0][0]は使わない */
int queue[10000][2], head = 0, tail = 0;
int width, height, xgoal, ygoal;

int bfs(int x, int y);
void enqueue(int x, int y);
void dequeue(int *x, int *y);


int main()
{
	int xstart, ystart, n, color, direction, x, y, blockw, blockh;
	int i, j, k;
	while (1) {
		for(i = 0; i < 101; i++) {
			for(j = 0; j < 101; j++) {
				board[i][j] = 0;
				visited[i][j] = 0;
			}
		}
		for(i = 0; i < 10000; i++) {
			for(j = 0; j < 2; j++) {
				queue[i][j] = 0;
			}
		}
				
		scanf("%d %d", &width, &height);
		if(width == 0 && height == 0)
			break;
		scanf("%d %d", &xstart, &ystart);
		scanf("%d %d", &xgoal, &ygoal);
		scanf("%d", &n);

		for (i = 0; i < n; i++) {
			scanf("%d %d %d %d", &color, &direction, &x, &y);
			switch (direction) {
				case HORIZONTAL:
					blockw = 4, blockh = 2;
					break;
				case VERTICAL:
					blockw = 2, blockh = 4;
					break;
				default:
					break;
			}
			for (j = 0; j < blockw; j++) {
				for (k = 0; k < blockh; k++) {
					board[x + j][y + k] = color;
				}
			}
		}
		/* BFS開始 */
		if(!bfs(xstart, ystart)) puts("OK");
		else puts("NG");
	}
	return 0;
}

int bfs(int xstart, int ystart)
{
	int x, y;
	int expectedcolor = board[xstart][ystart];
	enqueue(xstart, ystart);
	do {
		dequeue(&x, &y);
		if(x == xgoal && y == ygoal) return 0;
		if(x < width && !visited[x + 1][y] && board[x + 1][y] == expectedcolor) enqueue(x + 1, y);
		if(y < height && !visited[x][y + 1] && board[x][y + 1] == expectedcolor) enqueue(x, y + 1);
		if(x > 1 && !visited[x - 1][y] && board[x - 1][y] == expectedcolor) enqueue(x - 1, y);
		if(y > 1 && !visited[x][y - 1] && board[x][y - 1] == expectedcolor) enqueue(x, y - 1);

	} while(head != tail);
	return -1;

}

void enqueue(int x, int y)
{
	visited[x][y] = 1;
	queue[tail][0] = x, queue[tail][1] = y;
	tail++;
}

void dequeue(int *x, int *y)
{
	*x = queue[head][0];
	*y = queue[head][1];
	head++;
}

Measured memory_bytes: 0
import java.io.*;
import java.util.*;
import java.util.function.*;

final class Solver {
	static final Solver INSTANCE = new Solver();

	void solve(Supplier<String> sc) {
		int R = Integer.parseInt(sc.get());
		System.out.println(2 * Math.PI * R);
	}
}

class Main {
	public static void main(String... args) {
		var reader = new BufferedReader(new InputStreamReader(System.in));
		Solver.INSTANCE.solve(new Supplier<>() {
			StringTokenizer line;

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

Measured memory_bytes: 33044
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define fastIO cout << fixed << setprecision(12), ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr)
double const EPS = 1e-10, PI = acos(-1);
const int N = 5e5 + 9, M = 1e5 + 9, OO = 1e9 + 7, MOD = 1e9 + 7;

ll add(ll x, ll y) {
  x += y;
  while(x >= MOD)
    x -= MOD;
  while(x < 0)
    x += MOD;
  return x;
}

ll mul(ll x, ll y) {
  return (x * y) % MOD;
}

ll Left[N], Right[N], cnt[N], dp[102][N], pre[102][N];

int main() {
  fastIO;
#ifdef LOCAL
  freopen("input.in", "rt", stdin);
#endif
  int len, n;
  cin >> n >> len;
  int x = 1, idx = 0;
  while(x <= n) {
    int a = n / x;
    int b = n / a;
    ++idx;
    Left[idx] = x, Right[idx] = b;
    x = b + 1;
  }
  for (ll i = 1; i <= idx; ++i) {
    cnt[i] = Right[i] - Left[i] + 1;
    dp[1][i] = cnt[i];
  }
  for (int i = 2; i <= len; ++i) {
    for (int last = 1; last <= idx; ++last) {
      int L = 1, R = idx - last + 1;
      pre[i][L] = add(pre[i][L], dp[i-1][last]);
      pre[i][R + 1] = add(pre[i][R+1], -dp[i-1][last]);
    }
    for (ll last = 1; last <= idx; ++last) {
      pre[i][last] = add(pre[i][last], pre[i][last - 1]);
      dp[i][last] = add(dp[i][last], mul(cnt[last], pre[i][last]));
    }
  }
  ll answer = 0;
  for (int i = 1; i <= idx; ++i) {
    answer = add(answer, dp[len][i]);
  }
  cout << answer;
  return 0;
}


Measured memory_bytes: 514304
import java.awt.*;
import java.io.DataInputStream;
import java.io.FileInputStream;
import java.io.IOException;
import java.math.BigInteger;
import java.util.*;

public class Main {
    public static void main(String[] args)throws IOException {
        Scanner sc = new Scanner(System.in);
        int n=sc.nextInt();
        int[] a=new int[n];
        for(int i=0;i<n;i++)a[i]=sc.nextInt();

        for(int i=0;i<n-1;i++){
            if(a[i]<a[i+1])a[i+1]--;
            else if(a[i]==a[i+1]);
            else {
                System.out.println("No");
                System.exit(0);
            }
        }
        System.out.println("Yes");
    }
}

Measured memory_bytes: 49800
/*
	@・ω・@ <れれですよ
*/

/*****/

# include <iostream>
# include <vector>
# include <algorithm>
# include <string>
# include <cmath>
# include <queue>
# include <stack>
# include <map>
# include <iomanip>	//cout << fixed << setprecision(桁数);
# include <stdexcept>
# include <functional>

//#define int long long

using namespace std;
using ll = long long;
using ld = long double;
using pll = pair<long long, long long>;
template<class T> using vec = vector<T>;

#define debug(x) (std::cerr << x)
#define debugln(x) (std::cerr << x << "\n")
#define debug_tab(n, x) (std::cerr << strMulti("\t",n) << (x) << "\n")
#define debug_cout(x) (std::cerr << #x << " : " <<  (x) << "\n")
#define debug_coutVec(x) std::cerr << #x << " : "; _debug_coutVec(x)
#define debug_tabcout(n, x) (std::cerr << strMulti("\t",n) << #x << " : " <<  (x) << "\n")
#define debug_headcout(h, x) (std::cerr << h << " : " <<  (x) << "\n")
#define debug_tabheadcout(n, h, x) (std::cerr << strMulti("\t",n) << h << " : " <<  (x) << "\n")

#define rep(i, n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define rep1(i, n) for(ll i=1, i##_len=(n); i<=i##_len; ++i)
#define rrep(i, n) for(ll i=(n)-1; i >= 0; --i)
#define rrep1(i, n) for(ll i=(n); i > 0; --i)
#define step(i, a, n) for(ll i=(a), i##_len=(a)+(n); i<i##_len; ++i)
#define rstep(i, a, n) for(ll i=(a)+(n)-1, i##_len=(a); i>=i##_len; --i)
#define range(i, a, b) for(ll i=(a), i##_len=(b); i<i##_len; ++i)
#define rrange(i, a, b) for(ll i=(b)-1, i##_len=(a); i>=i##_len; --i)
#define all(x) (x).begin(), (x).end()
#define pair(a, b) make_pair(a, b)
constexpr int INF = 2147483647;
template<class T> bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> T divup(T a, T b) { if (a % b == 0) { return a / b; } return a / b + 1; }
std::string strMulti(std::string t, int n) { std::string out = ""; for (int i = 0; i < n; i++) { out += t; } return out; }
template<class T> T math_P(T m, T n) { T ret = 1; for (T i = m; i > m - n; i--) { ret *= i; } return ret; }
template<class T> T math_C(T m, T n) { T ret = math_P(m, n); for (T i = 2; i <= n; i++) { ret /= i; } return ret; }
template<class T> bool cmp_2nd(pair<T, T> a, pair<T, T> b) { if (a.second != b.second) { return a.second < b.second; } return a.first < b.first; }
template<class T> T mod_pow(T x, T n, const T& p) { T ret = 1; while (n > 0) { if (n & 1) { (ret *= x) %= p; } (x *= x) %= p; n >>= 1; } return ret; }
template<class T> T math_gcd(T a, T b) { if (b == 0) { return a; } else { return math_gcd(b, a % b); } }

template<class T> void _debug_coutVec(vector<T> ar, string space = " ") { rep(i, ar.size()) { debug(ar[i] << space); } debugln(""); }

constexpr ll MOD = 1000000007;	// 10e9+7

/*****/

void Main()
{
	int A, B;
	cin >> A >> B;

	cout << divup(B - 1, A - 1);
}

/*****/

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

	//std::cout << std::fixed << std::setprecision(10);

	/**
	while (true)
	{
		Main();
		std::cerr << flush;
		cout << endl;
	}
	/*/
	Main();
	std::cerr << flush;
	cout << endl;
	/**/

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <vector>
#include <algorithm>
#include <map>
using namespace std;
const int N=100000+10;
int n,a[N];
vector< pair<int,int> > v[2];
map<int,int> mp;
int main(){
    scanf("%d",&n);
    for(int i=1;i<=n;i++)scanf("%d",&a[i]);
    for(int i=1;i<=n;i+=2) mp[a[i]]++;
    for(auto p: mp) v[0].push_back(make_pair(n/2-p.second,p.first));
    mp.clear();
    for(int i=2;i<=n;i+=2) mp[a[i]]++;
    for(auto p: mp) v[1].push_back(make_pair(n/2-p.second,p.first));
    sort(v[0].begin(),v[0].end());
    sort(v[1].begin(),v[1].end());
    if(v[0][0].second != v[1][0].second) {
        printf("%d\n", v[0][0].first + v[1][0].first);
    } else {
        int ans=1e9;
        if(v[1].size()>=2) ans=min(ans, v[0][0].first+v[1][1].first);
        else ans=min(ans, v[0][0].first + n/2);

        if(v[0].size()>=2) ans=min(ans, v[0][1].first+v[1][0].first);
        else ans=min(ans, v[1][0].first + n/2);
        printf("%d\n", ans);
    }
}

Measured memory_bytes: 4088
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <numeric>
#include <functional>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <memory>
#include <thread>
#include <tuple>
#include <limits>

using namespace std;

char buffer[30004];
int dp[3][1000]; // num digits - 1
int main() {
  int n;
  scanf("%d", &n);
  scanf("%s", buffer);
  for (int i = 0; i < n; i++) {
    int digit = buffer[i] - '0';
    int p10 = 100;
    for (int j = 1; j >= 0; j--) {
      for (int k = 0; k < p10; k++) {
        if (dp[j][k] == 0) continue;
        dp[j + 1][k * 10 + digit] = 1;
      }
      p10 /= 10;
    }
    dp[0][digit] = 1;
  }
  int ans = 0;
  for (int i = 0; i < 1000; i++) {
    ans += dp[2][i];
  }
  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 256
N = int(input())
sum_N = N*(N+1)//2
sum_3 = 3*(N//3)*(N//3+1)//2
sum_5 = 5*(N//5)*(N//5+1)//2
sum_15 = 15*(N//15)*(N//15+1)//2
print(sum_N-sum_3-sum_5+sum_15)

Measured memory_bytes: 61788
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <string>
using namespace std;
typedef long long int ll;
typedef vector<int> vi;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define Sort(a) sort(a.begin(), a.end())
const int INF = 1<<30;
const ll MOD = 1000000007;

int main(void) {

    int n, m , k; cin >> n >> m >> k;
    vi a(n), b(m);
    rep(i, n) cin >> a[i];
    rep(i, m) cin >> b[i];
    ll t = 0;
    rep(i, m) t += b[i];
    int j = m;
    int ans = 0;
    rep(i, n+1) {
        while (j > 0 && t > k) {
            --j;
            t -= b[j];
        }
        if (t > k) break;
        ans = max(ans, i+j);
        if (i == n) break;
        t += a[i];
    }
    cout << ans << endl;


    return 0;
}

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

int main() {
  int n, m, k;
  cin >> n >> m >> k;
  bool flag = false;
  for (int i = 0; i <= n; i++) {
    for (int j = 0; j <= m; j++) {
      int tmp = m*i + n*j - 2*i*j;
      if (tmp == k) {
        flag = true;
      }
    }
  }
  if (flag) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
    int x, y, t;

    for(int i = 0; i < 3000; i++)
    {
        cin >> x;
        cin >> y;
    
        if(x == 0 && y == 0) {break;}

        if(x > y)
            {
                 t = x;
                 x = y;
                 y = t;
             }

        cout << x << " " << y << endl;
    }

}



Measured memory_bytes: 3000
from collections import deque

def solve(n, a, b):
    E = {(i+1): [] for i in range(n)}
    G = {}
    for i in range(n-1):
        u, v = a[i], b[i]
        E[u].append(v)
        E[v].append(u)
        G[u, v] = 0
        G[v, u] = 0
    k = max(map(len, E.values()))
    V = {v: set() for v in E.keys()}
    que = deque(range(1,k+1))
    for u, vs in E.items():
        for v in vs:
            if G[u, v] != 0:
                continue
            while que:
                c = que.popleft()
                que.append(c)
                if (not c in V[u]) and (not c in V[v]):
                    V[u].add(c)
                    V[v].add(c)
                    G[u, v] = c
                    G[v, u] = c
                    break
    res = [k]
    for i in range(n-1):
        res.append(G[a[i], b[i]])
    return "\n".join(map(str, res))

n = int(input())
a = [0] * n
b = [0] * n
for i in range(n-1):
    a[i], b[i] = map(int, input().split())
print(solve(n, a, b))

Measured memory_bytes: 96728
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <unordered_map>
#include <climits>
#include <set>
#include <unordered_set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <queue>
#include <random>
#include <complex>
#include <regex>

using namespace std;

#define SHOW_VECTOR(v) {std::cerr << #v << "\t:";for(const auto& xxx : v){std::cerr << xxx << " ";}std::cerr << "\n";}
#define SHOW_MAP(v){std::cerr << #v << endl; for(const auto& xxx: v){std::cerr << xxx.first << " " << xxx.second << "\n";}}

vector <pair<int, int>> get_primes(int x) {
    vector <pair<int, int>> ret;
    for (int i = 2; i * i <= x; i++) {
        if (x % i == 0) {
            int cnt = 0;
            while (x % i == 0) cnt++, x /= i;
            ret.push_back(make_pair(i, cnt));
        }
    }
    if (x != 1) ret.push_back(make_pair(x, 1));
    return ret;
}

long long mod = 1e9 + 7;

int main() {

    int N;
    cin >> N;

    map<int, long long> m;
    for (int i = 1; i <= N; i++) {
        auto ret = get_primes(i);
        for (auto x:ret) m[x.first] += x.second;
    }

    long long ans = 1;
    for (auto x: m)ans = (ans * (x.second + 1)) % mod;

    cout << ans << endl;

}















































Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
#define show(x) {for(auto i: x){cout << i << " ";} cout << endl;}
using namespace std;
using ll = long long;
using P = pair<int, int>;

struct UnionFind {
    vector<int> d;
    UnionFind(int n): d(n,-1) {}
    int root(int x) {
        if (d[x] < 0) return x;
        return d[x] = root(d[x]);
    }
    bool unite(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (d[x] > d[y]) swap(x,y);
        d[x] += d[y];
        d[y] = x;
        return true;
    }
    bool same(int x, int y) { return root(x) == root(y);}
    int size(int x) { return -d[root(x)];}
};  // UnionFind uf(N+1);  // 1-indexed

int deg[200005];
vector<int> graph[200005];

int main() {
    int N, Q;
    cin >> N >> Q;
    UnionFind uf(N+1);
    rep(i, Q) {
        int t, u, v;
        cin >> t >> u >> v;
        if (t == 0) {
            uf.unite(u, v);
        } else {
            if (uf.same(u, v)) cout << '1' << '\n';
            else cout << '0' << '\n';
        }
    }
    return 0;
    // ll, 0, -, 1i, for s&g, debug
}

Measured memory_bytes: 8548
/*____________________________Definitions__________________________*/
#include <bits/stdc++.h>
using namespace std;
#define fastIO ios_base::sync_with_stdio(0); cin.tie(0);
typedef long long ll;
typedef vector<int> vi;
#define Rep(i, a, b) for (int i=a; i<(b); i++)
#define trav(a,x) for(auto& a : x)
#define nl '\n'
#define ri(n) int n; scanf("%d", &n);
#define rll(n) ll n; scanf("%lld", &n);
/*__________________________________________________________________*/


int main() {

	fastIO
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	int T = 1;
	while (T--) {
		/*_____________________Code Here____________________________*/

		int n ; cin >> n;
		vi v;
		for (int i = 0 ; i < n ; i++) {
			int t ; cin >> t ;
			v.push_back(t);
		}
		ll sum = 0;

		for (int i = 1 ; i < n ; i++) {
			if (v[i] <= v[i - 1]) {
				sum += v[i - 1] - v[i] ;
				v[i] += v[i - 1] - v[i] ;

			}
		}
		cout << sum << nl;



		/*_____________________End Here____________________________*/
	}
	return 0;
}



Measured memory_bytes: 4192
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef pair<int, int> P;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define all(x) (x).begin(),(x).end()

constexpr auto INF = INT_MAX/2;
constexpr auto MOD = 1000000007;

vvi prg;

int main() {
	int n, cc;
	cin >> n >> cc;

	prg.assign(cc, vi(100000, 0));

	rep(i, n) {
		int s, t, c;
		cin >> s >> t >> c;
		s--;t--;c--;

		prg[c][s]++;
		if (t < 99999)prg[c][t+1]--;
	}

	vi s(cc, 0);
	int ans = 0;

	rep(i, 100000) {

		int k = 0;

		rep(j, cc) {
			s[j] += prg[j][i];
			if (s[j] >= 1)k++;
		}

		ans = max(ans, k);

	}

	cout << ans << endl;

}

Measured memory_bytes: 14072
#include <iostream>
#include <stdio.h>
#include <fstream>
#include <algorithm>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <limits.h>
#include <math.h>
#include <functional>
#include <bitset>
#include <iomanip>

#define repeat(i,n) for (long long i = 0; (i) < (n); ++ (i))
#define debug(x) cerr << #x << ": " << x << '\n'
#define debugArray(x,n) for(long long i = 0; (i) < (n); ++ (i)) cerr << #x << "[" << i << "]: " << x[i] << '\n'
#define debugArrayP(x,n) for(long long i = 0; (i) < (n); ++ (i)) cerr << #x << "[" << i << "]: " << x[i].first<< " " << x[i].second << '\n'

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> Pii;
typedef vector<int> vint;
typedef vector<ll> vll;
const ll INF = INT_MAX;
const ll MOD = 1e9+7;


int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N;cin>>N;
  cout << N/3<<endl;
  return 0;
}


Measured memory_bytes: 256
H, W, A, B = map(int, input().split())

if H == 1:
    ans = "1"*A + "0"*(W-A)
    print(ans)
    exit()

if W == 1:
    for _ in range(B):
        print(1)
    for _ in range(H-B):
        print(0)
    exit()

ans = [[0]*W for _ in range(H)]

for i in range(B):
    for j in range(A):
        ans[i][j] = 1

for i in range(B, H):
    for j in range(A, W):
        ans[i][j] = 1

for a in ans:
    t = list(map(str, a))
    print("".join(t))

Measured memory_bytes: 12020
#include<iostream>
#include<math.h>
using namespace std;

int main(){
  string s,t;
  int i;
  cin >>s >> t;
  for( i=0;i<s.size();i++){
    if(s[i]!=t[i]){
      cout << "No";
      break;
    }
  }
  if(i==s.size()){
    cout << "Yes";
  }
  return 0;
}
  

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

public class Program
{
    #region Standard I/O
    readonly TextReader input;
    readonly TextWriter output;

    X[] ReadLine<X>(Func<string, X> func)
    {
        return input.ReadLine().Split(' ').Select(func).ToArray();
    }

    void WriteLineOne(object obj)
    {
        output.WriteLine("{0}", obj);
    }

    void WriteLineMany(params object[] objects)
    {
        output.WriteLine(string.Join(" ", objects.Select(obj => obj.ToString())));
    }
    #endregion

    int n;
    int[] xs;

    public void Run()
    {
        {
            n = ReadLine(int.Parse)[0];
            xs = ReadLine(int.Parse);
        }

        var count1 = 0;
        var count2 = 0;
        var count4 = 0;

        foreach (var x in xs)
        {
            if (x % 4 == 0)
            {
                count4++;
            }
            else if (x % 2 == 0)
            {
                count2++;
            }
            else
            {
                count1++;
            }
        }

        if (count2 > 0)
        {
            count1++;
        }

        WriteLineOne(count1 <= count4 + 1 ? "Yes" : "No");
    }

    public Program(TextReader input, TextWriter output)
    {
        this.input = input;
        this.output = output;
    }

    public static void Main(string[] args)
    {
        new Program(Console.In, Console.Out).Run();
    }
}


Measured memory_bytes: 21728
import java.lang.Math;
import java.util.Scanner;

class Main {
    public static void main(String[] args) {
        int A, B, C, D;
        Scanner sc = new Scanner(System.in);
        A = sc.nextInt();
        B = sc.nextInt();
        C = sc.nextInt();
        D = sc.nextInt();
        System.out.println(Math.min(A, B) + Math.min(C, D));
    }
}


Measured memory_bytes: 22996
import java.io.IOException
import java.lang.NumberFormatException
import java.lang.StringBuilder
import kotlin.math.max
import kotlin.math.pow

object AMain{
    fun solve(){
        val a = next()
        if(a[0].toByte() in 'a'.toByte()..'z'.toByte()){
            println("a")
        }else{
            println("A")
        }
    }

    fun count(x: Long, n: Int): Int{
        var ret = 0
        var mx = x
        while(mx % n.toLong() == 0L){
            mx /= n.toLong()
            ret++
        }
        return if(ret > 20) 20 else ret
    }





    // Scanner based on uwi-san's Java code
    val stream = System.`in`
    val buffer = ByteArray(1024)
    var ptr = 0
    var buflen = 0

    fun hasNextByte(): Boolean{
        if(ptr < buflen){
            return true
        }else{
            ptr = 0
            try{
                buflen = stream.read(buffer)
            }catch (e: IOException){
                e.printStackTrace()
            }
            if(buflen <= 0){
                return false
            }
        }
        return true
    }

    fun readByte() =
        if(hasNextByte()) buffer[ptr++]
        else -1

    fun isPrintableChar(c: Byte) = c in 33..126

    fun hasNext(): Boolean{
        while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++
        return hasNextByte()
    }

    fun next(): String{
        if(!hasNext()) throw NoSuchElementException()
        val sb = StringBuilder()
        var b = readByte()
        while(isPrintableChar(b)){
            sb.appendCodePoint(b.toInt())
            b = readByte()
        }
        return sb.toString()
    }

    fun nextLong(): Long{
        if(!hasNext()) throw NoSuchElementException()
        var n = 0L
        var minus = false
        var b = readByte()
        if(b == '-'.toByte()){
            minus = true
            b = readByte()
        }
        if(b !in '0'.toByte()..'9'.toByte())
            throw NumberFormatException()
        while(true){
            if(b in '0'.toByte()..'9'.toByte()){
                n *= 10
                n += b - '0'.toByte()
            }else if(!isPrintableChar(b)){
                return if(minus) -n else n
            }else{
                throw NumberFormatException()
            }
            b = readByte()
        }
    }

    fun nextInt(): Int{
        val n1 = nextLong()
        if(n1 !in Int.MIN_VALUE..Int.MAX_VALUE)
            throw NumberFormatException()
        return n1.toInt()
    }

    fun NextDouble() = next().toDouble()
}

fun main(){
    AMain.solve()
}



Measured memory_bytes: 34144
N, K = map(int, input().split())
h = list(map(int, input().split()))

# DP
INF = int(1e10)
dp = [INF] * N
dp[0] = 0


for i in range(1, N):
    for j in range(1, K+1):
        if i-j >= 0:
            dp[i] = min(dp[i], dp[i-j] + abs(h[i] - h[i-j]))
        else:
            break
print(dp[N-1])


Measured memory_bytes: 52448
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <iomanip>

#define REP(i,n) for(int i=0;i<n;++i)
#define RREP(i,n) for(int i=n-1;i>=0;--i)
#define FOR(i,m,n) for(int i=m;i<n;++i)
#define RFOR(i,m,n) for(int i=m-1;i>=n;--i)
#define ALL(v) v.begin(),v.end()
#define PB(a) push_back(a)
#define INF 1000000001
#define MOD 1000000007

using namespace std;


int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	while (1){
		cin >> n;
		if (!n) break;
		bool ud = 0, r = 0, l = 0;
		int cnt = 0;
		REP(i,n) {
			string s;
			cin >> s;
			if (s == "ru") {
				r = 1;
				if (l & !ud) {
					cnt++;
					ud = 1;
				}
			}
			else if (s == "rd") {
				if (!l&ud) {
					cnt++;
					ud = 0;
				}
				r = 0;
			}
			else if (s == "lu") {
				if (r & !ud) {
					cnt++;
					ud = 1;
				}
				l = 1;
			}
			else {
				if (!r&ud) {
					cnt++;
					ud = 0;
				}
				l = 0;
			}
		}
		cout << cnt << endl;
	}
	return 0;
}

Measured memory_bytes: 3080
#include <set>
#include <vector>
#include <cstdio>
#include <iostream>
#include <algorithm>

using namespace std;

int n;
multiset<int> s;

void solve() {
    cin >> n;
    int x;
    for (int i = 0; i < n; i++) {
        scanf("%d", &x);
        s.insert(x);
    }

    int ans = 0;
    while (s.size() >= 2) {
        auto ptr = s.end();
        ptr--;
        int x = *ptr;
        s.erase(ptr);

        long long sum = 1;
        for (int i = 0; i < 32; i++) {
            int y = sum - x;
            auto ptr = s.find(y);
            if (ptr != s.end()) {
                s.erase(ptr);
                ans++;
                break;
            }
            sum *= 2;
        }
    }

    cout << ans << endl;
}

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


Measured memory_bytes: 9600
import Control.Applicative ((<$>), (<*>))
import Control.Monad
import Data.List

main :: IO ()
main = do
  solve <$> getl (wrds toInt) >>= print

solve :: [Int] -> Int
solve [a,b,c]
  | even a || even b || even c = 0
  | otherwise = let (x:y:_) = sort [a,b,c] in x * y
                
toInt :: String -> Int
toInt = read

wrds :: (String -> a) -> String -> [a]
wrds f = map f . words

getl :: (String -> a) -> IO a
getl f = f <$> getLine


Measured memory_bytes: 508
#include <bits/stdc++.h>
#define ll long long
#define INF 0x3f3f3f3f
#define mem( f, x ) memset( f, x, sizeof( f ) )
#define pii pair<int, int>
#define fi first
#define se second
#define mk(x, y) make_pair( x, y )
#define pk push_back
using namespace std;
const int M = 1e5 + 5;
const int N = 1e5 + 5;
const double PI = acos(-1.0);
int m, n;

int main( ){
    string s;
    while( scanf( "%d", &n ) != EOF ){
        map<string,bool> mp;
        int ans = 0;
        for( int i = 0; i < n; i++ ){
            cin >> s;
            if( !mp.count(s) ){
                mp[s] = 1;
                ans++;
            }
        }
        printf( "%d\n", ans );
    }
    return 0;
}


Measured memory_bytes: 19356
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a)  (a).begin(),(a).end()
#define pb push_back
#define INF (1e9+1)
//#define INF (1LL<<59)

struct edge{
    int a,b,cost;
    bool operator<( const edge &right ) const {
        if (cost == right.cost){
            if(a == right.a){
                return b<right.b;
            }
            else return a<right.a;
        }
        return cost<right.cost;
    }
};


class UF{
private:
    vector<int> par,rank,elm;
public:
    int groups;

    UF(int __size):par(__size) , rank(__size,0) , elm(__size,1) , groups(__size){
        for(int i=0;i<__size;i++)par[i]=i;
    }

    int elements(int n){
        return elm[find(n)];
    }

    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;

        groups--;
        if(rank[x]<rank[y]){
            par[x]=y;
            elm[y]+=elm[x];
        }else{
            par[y]=x;
            elm[x]+=elm[y];
            if(rank[x]==rank[y])rank[x]++;
        }
    }

    bool isSame(int x,int y){
        return find(x)==find(y);
    }
};


int main(){
    int v,e;
    while(cin>>v>>e&&(v||e)){
        vector<edge> st;
        rep(i,e){
            int a,b,c;
            cin>>a>>b>>c;
            a--,b--;
            st.pb(edge{a,b,c});
        }
        sort(all(st));

        int ans=INF;
        for(int i=1;i<=10000;i++){
            UF uf(v);
            int pos=0;
            int j;
            for(j=i;j<=10000;j++){
                if(pos>=e)break;
                if( st[pos].cost>j )continue;
                while( st[pos].cost<j && pos<e)pos++;
                
                while( st[pos].cost==j && pos<e ){
                    uf.unite(st[pos].a,st[pos].b);
                    pos++;
                }
                if(uf.groups==1) break;
            }
            if(uf.groups==1){
                ans = min(j-i,ans);
            }
        }
        if(ans==INF)cout<<-1<<endl;
        else cout<<ans<<endl;
    }
}

Measured memory_bytes: 3288
n = int(input())
s = input()
memo = []
for i in range(10):
  for j in range(10):
    for k in range(10):
      memo.append(str(i) + str(j) + str(k))
ans = 0
for i in memo:
  x = 0
  for j in range(n):
    if i[x] == s[j]:
      x += 1
      if x == 3:
        ans += 1
        break

print(ans)

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

#define MOD 1000000007LL
#define MAX_H 100
#define MAX_W 8
typedef long long int ll;

ll dp[MAX_H + 1][MAX_W + 2];

bool check(int b) {
  bool ret = true;
  while(b > 0) {
    ret &= (b & 3) < 3;
    b >>= 1;
  }

  return ret;
}

int main() {
  int h, w, k;

  std::cin >> h >> w >> k;

  dp[0][1] = 1;
  for(int i = 1; i <= h; ++i) {
    for(int j = 1; j <= w; ++j) {
      int cnt1 = 0, cnt2 = 0, cnt3 = 0;
      for(int b = 0; b < 1 << (w - 1); ++b) {
        if(!check(b)) continue;
        if((b >> (j - 2) & 1) == 1) ++cnt1;
        if((b >> (j - 2) & 1) == 0 && (b >> (j - 1) & 1) == 0) ++cnt2;
        if((b >> (j - 1) & 1) == 1) ++cnt3;
      }

      dp[i][j] = (cnt1 * dp[i - 1][j - 1] % MOD + cnt2 * dp[i - 1][j] % MOD + cnt3 * dp[i - 1][j + 1] % MOD ) % MOD;
    }
  }

  std::cout << dp[h][k] << std::endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long LL;
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

using namespace std;
LL p = 1000000007ll;

int main(void)
{
  LL n;
  cin >> n;
  vector<LL> p(n);
  for(LL &x:p) cin >> x;
  LL answer = 0;
  REP(i,n-2) {
    LL a=p[i],b=p[i+1],c=p[i+2];
    if(max(max(a,b),c) == b) continue;
    if(min(min(a,b),c) == b) continue;
    ++answer;
  }
  cout << answer << endl;
  return 0;
}


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

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

using ll = long long;
const ll INF = 1LL << 60;

int main()
{
  int n;
  ll d[100100][3];
  ll v[100100][3];

  cin >> n;
  for (int i = 1; i <= n; ++i)
  {
    cin >> v[i][0] >> v[i][1] >> v[i][2];
  }

  for (int i = 0; i < 3; ++i)
  {
    d[0][i] = 0;
  }
  for (int i = 1; i <= n; ++i)
  {
    for (int j = 0; j < 3; ++j)
    {
      d[i][j] = -INF;
    }
  }

  for (int i = 1; i <= n; ++i)
  {
    for (int j = 0; j < 3; ++j)
    {
      for (int k = 0; k < 3; ++k)
      {
        if (j == k)
          continue;
        chmax(d[i][k], d[i - 1][j] + v[i][k]);
      }
    }
  }
  ll ans = 0;
  for (int i = 0; i < 3; ++i)
  {
    chmax(ans, d[n][i]);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 4992
# ABC086-C

declare -r PREPROCESS='
BEGIN {
    t = 0; x = 0; y = 0;
}
{
    print ($1 - t) " " ($2 > x ? $2 - x : x - $2) " " ($3 > y ? $3 - y : y - $3)
    t = $1; x = $2; y = $3;
}'

read # N
while read dt dx dy; do
    if (( dx + dy > dt || (dx + dy) % 2 != dt % 2 )); then
        echo No
        exit
    fi
done < <(awk "${PREPROCESS}")

echo Yes    


Measured memory_bytes: 1068
#include <stdio.h>

int main(void)
{

    int A[3];
    int max;
    int min;
    for (int i = 0; i < 3; i++)
    {
        scanf("%d", &A[i]);
    }

    max = min = A[0];
    for (int i = 1; i < 3; i++)
    {
        if (max < A[i])
        {
            max = A[i];
        }
        else if (min > A[i])
        {
            min = A[i];
        }
    }
    printf("%d\n", max - min);
    return 0;
}


Measured memory_bytes: 128
#HarshadNumber
n = int(input())
def hrsh(x):
  s = 0
  while x > 10:
    s += x % 10
    x = x//10
  s += x
  return s
f = hrsh(n)
#print(f)
if n % f == 0:
  print('Yes')
else:
  print('No')

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

int main(){
  using idx= tuple<int, int, int>;
  using state= pair<int64_t, idx>;
  int N1,N2,N3,K;
  cin >> N1 >> N2 >> N3 >> K;

  vector<int64_t> cake1(N1);
  vector<int64_t> cake2(N2);
  vector<int64_t> cake3(N3);

  for(int i=0; i<N1; i++){
    cin >> cake1.at(i);
  }
  for(int i=0; i<N2; i++){
    cin >> cake2.at(i);
  }
  for(int i=0; i<N3; i++){
    cin >> cake3.at(i);
  }
  
  sort(cake1.begin(), cake1.end(), greater<int64_t>());
  sort(cake2.begin(), cake2.end(), greater<int64_t>());
  sort(cake3.begin(), cake3.end(), greater<int64_t>());

  priority_queue<state> outputs;
  set<idx> pushed_idx;
  outputs.push(make_pair(cake1.at(0)+ cake2.at(0)+ cake3.at(0), make_tuple(0,0,0)));
  pushed_idx.insert(make_tuple(0,0,0));

  int cnt= 0;
  int64_t val; idx idx_this; int id1,id2,id3;
  while(cnt < K){
    state output= outputs.top();
    outputs.pop();

    tie(val, idx_this)= output;
    tie(id1, id2, id3)= idx_this;
    cout << val << endl;

    idx next1= make_tuple(id1+1, id2  , id3);
    idx next2= make_tuple(id1  , id2+1, id3);
    idx next3= make_tuple(id1  , id2  , id3+1);

    if(get<0>(next1) < N1 && !pushed_idx.count(next1)){
      outputs.push(make_pair(cake1.at(get<0>(next1))+ cake2.at(get<1>(next1))+ cake3.at(get<2>(next1)), next1));
      pushed_idx.insert(next1);
    }
    if(get<1>(next2) < N2 && !pushed_idx.count(next2)){
      outputs.push(make_pair(cake1.at(get<0>(next2))+ cake2.at(get<1>(next2))+ cake3.at(get<2>(next2)), next2));
      pushed_idx.insert(next2); }
    if(get<2>(next3) < N3 && !pushed_idx.count(next3)){
      outputs.push(make_pair(cake1.at(get<0>(next3))+ cake2.at(get<1>(next3))+ cake3.at(get<2>(next3)), next3));
      pushed_idx.insert(next3);
    }

    cnt++;
  }
}

Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,o,n) for(long long i = o;i<n;i++)
#define oneforall ios::sync_with_stdio(false);cin.tie(0);
#define all(v) (v).begin(),(v).end()
#define ini(...) int __VA_ARGS__; in(__VA_ARGS__)
#define inl(...) long long __VA_ARGS__; in(__VA_ARGS__)
#define ins(...) string __VA_ARGS__; in(__VA_ARGS__)
#define int long long 
const long long inf=1e18;
void in(){} template <typename T,class... U> void in(T &t,U &...u){ cin >> t; in(u...);}
void out(){cout << "\n";} template <typename T,class... U> void out(const T &t,const U &...u){ cout << t; if(sizeof...(u)) cout << " "; out(u...);}
typedef vector<int> vi;
typedef vector<long long> vl;
typedef long long ll;
typedef vector<pair<long, long > > vpll;
typedef vector<pair<int, int > > vpii;
#define FORR(x,arr) for(auto& x:arr)
#define ZERO(a) memset(a,0,sizeof(a))





//3111111111111111111111111111111

	int n;
	vi adj[310];
	bool visit[310];
	int dep[310];
	void bfs(){

		visit[1] = 1;
		queue<int> queue1;
		queue1.push(1);
		while(!queue1.empty()){
			int tmp = queue1.front();
			queue1.pop();
			FORR(x1,adj[tmp])if(!visit[x1]){
				visit[x1] = 1;
				queue1.push(x1);
				dep[x1] = dep[tmp]+1;
			}
		}
	}

	void solve(){
		
		in(n);
		memset(dep,-1,sizeof(dep));
		dep[1] = 0;
		FOR(i,0,n){
			ini(x,x1);
			FOR(i1,0,x1){
				ini(tmp);
				adj[x].push_back(tmp);
			}
		}
		bfs();
		FOR(i,1,n+1){
			out(i,dep[i]);
		}







		
		
	}























int32_t main() {
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall 
	oneforall

	solve();
	


	return 0;
}



Measured memory_bytes: 3148
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
#[allow(unused_imports)]
use std::io::{BufWriter, Write};

// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

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

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

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

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

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

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

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

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

fn solve() {
    input!(
        n: usize,
        k: usize,
        s: chars,
    );
    let mut s = s as Vec<char>;
    let mut c = s[0].clone();
    let mut tmp = 0;
    let mut v = Vec::new();
    for i in &s {
        if i != &c {
            v.push(tmp.clone());
            tmp = 0;
            c = i.clone();
        }
        tmp += 1;
    }
    v.push(tmp);

//    println!("{:?}", v);
    let mut c = if s[0] == '0' { 0 } else { 1 };
    let mut l = 0;
    let mut ans = 0;
    let mut tmp = 0;
    let mut mn = 0;
    for i in 0..v.len() {
        tmp += v[i];
        if i % 2 == c {
            l += 1;
        }
        if l > k {
            while i - 2 * k >= mn {
                tmp -= v[mn];
                mn += 1;
            }
            l = k;
        }
//        println!("{}, {}", tmp, l);
        ans = max(ans, tmp);
    }
    println!("{}", ans);
}

fn main() {
    let stack_size = 1 << 28;
    let thd = std::thread::Builder::new().stack_size(stack_size);
    thd.spawn(|| solve()).unwrap().join().unwrap();
}


Measured memory_bytes: 8572
//----------------------------------------------------------------------
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
//----------------------------------------------------------------------

using namespace std;
using ll = long long;
using P = pair<int,int>;
using Graph = vector<vector<int>>;

int main(void) {
    int n;
    cin >> n;
    vector<int> h(n);
    REP(i,n) cin >> h[i];

    ll step = 0;
    ll ans = 0;
    for(int i = 0; i <n-1; i++) {
        if(h[i+1]<= h[i]) {
            step++;
            ans = max(ans,step);
        }else {
            step = 0;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(a) (a).begin(),(a).end()
#define ll long long
int main(){
  int N;
  cin>>N;
  vector<int> A(N);
  rep(i,N) cin>>A[i];
  ll mod=998244353;
  ll dp[90010]={};
  dp[0]=2;
  dp[A[0]]=1;
  ll dp10[90010];
  rep(i,N-1){
    rep(j,90010) dp10[j]=dp[j];
    rep(j,90010) dp[j]=(dp10[j]*2+(j>=A[i+1])*dp10[j-A[i+1]])%mod;
  }
  ll S=0;
  rep(i,N) S+=A[i];
  ll dp2[90010]={};
  if(S%2==0){
    dp2[0]=1;
    dp2[A[0]]=1;
    ll dp20[90010];
    rep(i,N-1){
      rep(j,90010) dp20[j]=dp2[j];
      rep(j,90010) dp2[j]=(dp20[j]+(j>=A[i+1])*dp20[j-A[i+1]])%mod;
    }
  }
  ll R=0;
  rep(i,90010) if(i>=(S+1)/2) R=(R+dp[i])%mod;
  ll P=1;
  rep(i,N) P=P*3%mod;
  ll ans=(P-R*3+dp2[S/2]*3)%mod;
  if(ans<0) ans+=mod;
  cout<<ans<<endl;
}

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

typedef long long ll;
typedef long double ld;
#define endl "\n"
#define deb(x) cerr << #x << ":" << x << "\n"

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    string s;
    cin>>s;
    if(s[2]==s[3] && s[4]==s[5])cout<<"Yes";
    else cout<<"No";
    return 0;
}

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



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

	int A, B, C;

	cin >> A >> B >> C;

	if (C > A && C < B || C < A && C > B)
	{
		cout << "Yes";
	}else{
		cout << "No";
	}
	cout << endl;

	return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    String S = sc.next();
    int cnt = 0;
    for(int i=0; i<N-1; i++){
      if(S.charAt(i)==S.charAt(i+1)){
        cnt++;
      }
    }
    System.out.println(N-cnt);
  }
}

Measured memory_bytes: 39536
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <cmath>
#include <cassert>
using namespace std;

bool prime[10001];
vector<int> primes;

int main()
{
  memset(prime, true, sizeof(prime));
  prime[0] = prime[1] = false;
  for (int i = 2; i <= 10000; ++i) {
    if (prime[i]) {
      for (int j = i+i; j <= 10000; j += i) {
        prime[j] = false;
      }
    }
  }

  for (int i = 0; i <= 10000; ++i) {
    if (prime[i]) {
      primes.push_back(i);
    }
  }
  primes.push_back(100000);

  int N;
  while (cin >> N) {
    int count = 0;
    for (int i = 0; primes[i] <= N; ++i) {
      if (prime[N - primes[i] + 1]) { ++count; }
    }
    cout << count << endl;
  }
}

Measured memory_bytes: 0
#include<iostream>/*入出力関連ヘッダファイル*/
using namespace std;/*標準名前空間を利用する。cinやcoutはこれによって利用可能になる*/

int A;
int B;
int S;

int main(void) {
  cin >> A >> B;
  cout << max(2*A-1, max(A+B,2*B-1)) << endl;
  return 0;
}


Measured memory_bytes: 256
#宝石の数
N = int(input())
#宝石の価値
V = [int(i) for i in input().split()] 
#コスト
C = [int(i) for i in input().split()] 

X = 0
Y = 0

for i in range(N):
     if V[i] > C[i]:
         X += V[i]
         Y += C[i]
         
print(X-Y)

Measured memory_bytes: 3060
#include<stdio.h>
#include<math.h>
#include <limits.h>
#include<stdlib.h>





int main() {
	int n,k;
	scanf("%d", &n);
	scanf("%d", &k);
	long long int* a = (long long int*)malloc(sizeof(long long int) * n);
	for (int i = 0; i < n; i++) {
		scanf("%lld", a + i);
	}
	

	for (int i = 1; i < n - k + 1; i++) {
		if (*(a - 1 + i) < *(a + k - 1 + i)) {
			printf("Yes\n");
		}
		else {
			printf("No\n");
		}
		
	}

	return 0;
}

Measured memory_bytes: 3208
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a)  (a).begin(),(a).end()
#define pb emplace_back
#define INF (1e9+1)
//#define INF (1LL<<59)

double f(pii a,pii b){
    return fabs(a.first-b.first)+fabs(a.second-b.second);
}

int main(){
    int n,m;
    cin>>n>>m;
    vector<pii> a,b;
    rep(i,n){
        int x,y;
        cin>>x>>y;
        a.pb(pii(x,y));
    }

    rep(i,m){
        int x,y;
        cin>>x>>y;
        b.pb(pii(x,y));
    }
    
    rep(i,a.size()){
        int id = -1;
        double val = INF;
        rep(j,b.size()){
            double res = f(a[i],b[j]);
            if(res<val){
                id = j;
                val =res;
            }
        }cout<<id+1<<endl;
    }

}

Measured memory_bytes: 256