akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) for(int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define show(x)  cerr << #x << " = " << (x) << endl;
#define int long long
using namespace std;

template <typename X, typename T>
auto vectors(X x, T a) {
	return vector<T>(x, a);
}

template <typename X, typename Y, typename Z, typename... Zs>
auto vectors(X x, Y y, Z z, Zs... zs) {
	auto cont = vectors(y, z, zs...);
	return vector<decltype(cont)>(x, cont);
}

template<typename T>
ostream& operator << (ostream& os, vector<T>& v){
	rep(i,v.size()){ os << v[i] << (i == v.size() - 1 ? "" : " "); } return os;
}
template<typename T>
istream& operator >> (istream& is, vector<T>& v){
	for(T& x: v){ is >> x; } return is;
}

signed main(){
	int n;
	cin >> n;

	vector<pair<int, int>> p(n);
	map<pair<int, int>,int> m;
	rep(i,n){
		int a, b;
		cin >> a >> b;
		p[i] = make_pair(a,b);
		m[p[i]] = i;
	}
	//sort(all(p));

	if(n == 1){
		cout << 1 << endl;
		return 0;
	}

	vector<pair<int, int>> d;
	rep(i,n){
		rep(j,n){
			if(i == j) continue;
			d.emplace_back(p[j].first - p[i].first, p[j].second - p[i].second);
		}
	}

	int ans = n - 1;
	for(auto pq : d){
		//cout << pq.first << ' ' << pq.second << endl;
		vector<bool> used(n, false);
		int cost = 0;
		rep(i,n){
			if(used[i]) continue;

			cost++;
			used[i] = true;

			int y, x;
			tie(y,x) = p[i];
			while(true){
				int ny = y + pq.first;
				int nx = x + pq.second;
				if(m.count(make_pair(ny,nx))){
					used[m[make_pair(ny,nx)]] = true;
					y = ny;
					x = nx;
					continue;
				}
				break;
			}
			tie(y,x) = p[i];
			while(true){
				int ny = y - pq.first;
				int nx = x - pq.second;
				if(m.count(make_pair(ny,nx))){
					used[m[make_pair(ny,nx)]] = true;
					y = ny;
					x = nx;
					continue;
				}
				break;
			}
		}
		ans = min(ans, cost);
	}
	cout << ans << endl;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
int main() {
  int a, b, c, mx, count = 0;
  cin >> a >> b >> c;
  mx = max(a, max(b, c));
  while(mx - a >= 2) {
    a += 2;
    count++;
  }
  while(mx - b >= 2) {
    b += 2;
    count++;
  }
  while(mx - c >= 2) {
    c += 2;
    count++;
  }
  int k = 0;
  if (mx - a == 1) k++;
  if (mx - b == 1) k++;
  if (mx - c == 1) k++;
  if (k == 1) count += 2;
  if (k == 2) count++;
  cout << count << endl;
}

Measured memory_bytes: 256
N = int(input())
S = list(input())

s = [0]*(N+1)

for i in range(1, N+1):
    k = 0
    if S[i-1] == "W":
        k = 1
    s[i] = s[i-1] + k

ans = N
for i in range(1, N+1):
    k = (N - i) - (s[N] - s[i])
    ans = min(ans, k + s[i-1])


print(ans)


Measured memory_bytes: 17484
#include <stdio.h>

char s[101],i,c,f;
int main() {
	scanf("%s",s);
	for(i=0;s[i]!='\0';i++)
		if(s[i]=='C') {
			c=i+1;
			break;	
		}
	for(i=c;s[i]!='\0';i++)
		if(s[i]=='F') {
			f=i;
			break;	
		}
	if(c&&f)
		printf("Yes\n");
	else
		printf("No\n");
	return 0;
}

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

int N, M;
std::vector<int> p;


int calc_sum(std::vector<int> status) {
    for (int i = 0; i < M; i++) {
        if (status[i] % 2 != p[i]) {
            return 0;
        }
    }
    return 1;
}

std::vector<int> update_status(std::vector<int> status, std::vector<int> swit) {
    for (int i = 0; i < M; i++) {
        status[i] += swit[i];
    }
    return status;
}


int search(int idx, std::vector<int> status, std::vector<std::vector<int>> &switches) {
    if (idx == N) {
        return calc_sum(status);
    }

    int sum = search(idx + 1, status, switches);
    std::vector<int> switch_on = update_status(status, switches[idx]);
    sum += search(idx + 1, switch_on, switches);
    return sum;
}


int main() {
    std::cin >> N >> M;

    std::vector<std::vector<int>> switches(N, std::vector<int>(M, 0));
    for (int i = 0; i < M; i++) {
        int k;
        std::cin >> k;
        for (int j = 0; j < k; j++) {
            int s;
            std::cin >> s;
            switches[s - 1][i] = 1;
        }
    }
    p = std::vector<int>(M);
    for (int i = 0; i < M; i++) {
        std::cin >> p[i];
    }

    std::vector<int> status(M, 0);
    int sum = search(0, status, switches);
    std::cout << sum << std::endl;
}


Measured memory_bytes: 3580
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ii = pair<int,int>;

const int mx = 2e5+5;

int dist[mx];
int n, m, vis[mx];
vector<int> g[mx], tp;

void dfs(int u){
    vis[u] = 1;
    for(int v : g[u])
        if(!vis[v])
            dfs(v);
    tp.push_back(u);
}

int main(){
    cin.tie(nullptr);
    ios_base::sync_with_stdio(0);

    cin >> n >> m;
    while(m--){
        int u, v; cin >> u >> v;
        g[u].push_back(v);
    }

    for(int i=1; i<=n; i++){
        dist[i] = 1;
        if(!vis[i]) dfs(i);
    }

    reverse(tp.begin(), tp.end());
    for(int u : tp)
        for(int v : g[u])
            dist[v] = max(dist[v], 1+dist[u]);
    cout << *max_element(dist, dist+n+1)-1 << "\n";

    return 0;
}



Measured memory_bytes: 14396
#include <bits/stdc++.h>
using ll = long long;
#define FOR(i, k, n) for(ll i = (k); i < (n); i++)
#define FORe(i, k, n) for(ll i = (k); i <= (n); i++)
#define FORr(i, k, n) for(ll i = (k)-1; i > (n); i--)
#define FORre(i, k, n) for(ll i = (k)-1; i >= (n); i--)
#define REP(i, n) FOR(i, 0, n)
#define REPr(i, n) FORre(i, n, 0)
#define ALL(x) (x).begin(), (x).end()
#define ALLr(x) (x).rbegin(), (x).rend()
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
using namespace std;

const int INF = 1001001001;

int main(void){
  int a, b;
  cin >> a >> b;
  cout << a*b << endl;
  return 0;
}

Measured memory_bytes: 3636
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;

int main() {
    int N, M, X;
    int in[110] = {};
    cin >> N >> M >> X;
    for (int i = 0; i <M; i++) {
        cin >> in[i];
    }
    int masu[110] = {};
    for (int i = 0; i < M; i++) {
        masu[in[i]]++;
    }
    int acost =0;
    for (int i = X - 1; i > 0; i--) {
        acost += masu[i];
    }
    int bcost = 0;
    for (int i = X; i < N; i++) {
        bcost += masu[i];
    }
    if (acost <= bcost) {
        cout << acost << endl;
    }
    else cout << bcost << endl;
}

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

using namespace std;

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


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

typedef long long ll;
typedef pair<int,int> P;
int dx[] = {-1, 1, 0,  0};
int dy[] = { 0, 0, 1, -1};
 
int main(){
  int n;
  cin >> n;
  string ans;
  if(n<1200) ans = "ABC";
  else if(n<2800) ans = "ARC";
  else ans = "AGC";
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
def main():
    h, w = [int(e) for e in input().split()]
    S = [input() for i in range(h)]

    L = [[0] * (w + 2) for i in range(h + 2)]
    R = [[0] * (w + 2) for i in range(h + 2)]
    T = [[0] * (w + 2) for i in range(h + 2)]
    B = [[0] * (w + 2) for i in range(h + 2)]
    for hi in range(1, h + 1):
        for wi in range(1, w + 1):
            if S[hi - 1][wi - 1] == '.':
                L[hi][wi] = L[hi][wi - 1] + 1
                T[hi][wi] = T[hi - 1][wi] + 1

            if S[hi - 1][-wi] == '.':
                R[hi][-wi - 1] = R[hi][-wi] + 1

            if S[-hi][wi - 1] == '.':
                B[-hi - 1][wi] = B[-hi][wi] + 1

    ans = 0
    for hi in range(1, h + 1):
        for wi in range(1, w + 1):
            ans = max(L[hi][wi] + R[hi][wi] + T[hi][wi] + B[hi][wi] - 3, ans)

    print(ans)


if __name__ == '__main__':
    main()


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

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

    static class A {
        public void solve(int testNumber, MyScanner in, PrintWriter out) {
            int A = in.Int();
            int B = in.Int();
            out.println(A <= 8 && B <= 8 ? "Yay!" : ":(");
        }

    }

    static class MyScanner {
        private BufferedReader in;
        private StringTokenizer st;

        public MyScanner(InputStream stream) {
            in = new BufferedReader(new InputStreamReader(stream));
        }

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

        public int Int() {
            return Integer.parseInt(next());
        }

    }
}



Measured memory_bytes: 23380
import java.util.*;
import java.io.*;
import java.lang.*;
public class Main {
	
	public static void main(String[] args) throws Exception{
		// TODO Auto-generated method stub
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		int N=Integer.parseInt(br.readLine());
		LinkedHashMap<String,Integer> hm=new LinkedHashMap<String,Integer>();
		hm.put("AC",0);
		hm.put("WA",0);
		hm.put("TLE",0);
		hm.put("RE",0);
		for(int i=0;i<N;i++)
		{
			String s=br.readLine().trim();
			hm.put(s,hm.get(s)+1);
		}
		for(String s:hm.keySet())
			System.out.println(s+" x "+hm.get(s));
	}
}


Measured memory_bytes: 44944
#include<iostream>
#include<iomanip>
#include<math.h>
#include<algorithm>
#include<utility>
#include<queue>
#include<string.h>
#include<string>
#include<set>
#include<map>
#include<unordered_map>
#include<functional>
#include<vector>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
const ll INF=2e18;
const ll MOD=1e9+7;

ll A,B;
char c[101][101];
int main(){
    cin>>A>>B;
    for(ll i=0;i<50;i++){
        for(ll j=0;j<100;j++){
            c[i][j]='.';
        }
    }
    for(ll i=50;i<100;i++){
        for(ll j=0;j<100;j++){
            c[i][j]='#';
        }
    }
    P now=P(1,1);
    for(ll i=0;i<B-1;i++){
        c[now.first][now.second]='#';
        now.second+=2;
        if(now.second>100){
            now.first+=2;
            now.second=1;
        }
    }
    now=P(51,1);
    for(ll i=0;i<A-1;i++){
        c[now.first][now.second]='.';
        now.second+=2;
        if(now.second>100){
            now.first+=2;
            now.second=1;
        }
    }
    cout<<"100 100"<<endl;
    for(ll i=0;i<100;i++){
        for(ll j=0;j<100;j++){
            cout<<c[i][j];
        }cout<<endl;
    }
    return 0;
}

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

using namespace std;

int W, N;
int *v, *w;
int dp[1001][1001];

int main() {
	int no = 1;
	while (1) {
		scanf("%d", &W);
		if (W == 0)
			break;
		scanf("%d", &N);
		v = new int[N];
		w = new int[N];
		for (int i = 0; i < N; i++)
			scanf("%d,%d", &v[i], &w[i]);

		memset(dp, 0, sizeof(dp));
		for (int i = N - 1; i >= 0; i--) {
			for (int j = 0; j <= W; j++) {
				if (j < w[i])
					dp[i][j] = dp[i+1][j];
				else
					dp[i][j] = max(dp[i+1][j], dp[i+1][j-w[i]] + v[i]);
			}
		}
		printf("Case %d:\n", no++);
		printf("%d\n", dp[0][W]);
		for (int j = 0; j <= W; j++) {
			if (dp[0][j] == dp[0][W]) {
				printf("%d\n", j);
				break;
			}
		}

		delete[] v;
		delete[] w;
	}
	return 0;
}

Measured memory_bytes: 5112
import sys
# import re
import math
import collections
# import decimal
import bisect
import itertools
import fractions
# import functools
import copy
# import heapq
import decimal
# import statistics
import queue

# import numpy as np

sys.setrecursionlimit(10000001)
INF = 10 ** 16
MOD = 10 ** 9 + 7
# MOD = 998244353

ni = lambda: int(sys.stdin.readline())
ns = lambda: map(int, sys.stdin.readline().split())
na = lambda: list(map(int, sys.stdin.readline().split()))


# ===CODE===

def largestRectangInHistgram(heights):
    stack = [-1]
    maxArea = 0

    for i in range(len(heights)):
        # we are saving indexes in stack that is why we comparing last element in stack
        # with current height to check if last element in stack not bigger then
        # current element
        while stack[-1] != -1 and heights[stack[-1]] > heights[i]:
            lastElementIndex = stack.pop()
            maxArea = max(maxArea, heights[lastElementIndex] * (i - stack[-1] - 1))
        stack.append(i)

    # we went through all elements of heights array
    # let's check if we have something left in stack
    while stack[-1] != -1:
        lastElementIndex = stack.pop()
        maxArea = max(maxArea, heights[lastElementIndex] * (len(heights) - stack[-1] - 1))

    return maxArea


def main():
    h, w = ns()
    mat = [na() for _ in range(h)]

    current = [0 for _ in range(w + 1)]

    ans = 0
    for i in range(h):
        for j in range(w):
            current[j] = current[j] + (mat[i][j] ^ 1) if mat[i][j]==0 else 0
        # current = [0] + current + [0]
        ans = max(ans, largestRectangInHistgram(current))

    print(ans)


if __name__ == '__main__':
    main()



Measured memory_bytes: 24312
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << x << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
typedef long long ll;
int main(){
	while(true){
		ll z=1000000,w=1000000;
		int a,b,d;
		cin>>a>>b>>d;
		if(d==0) break;
		for(ll x=0;x<=100000;x++){
			if((d-a*x)%b==0){
				ll y=abs(a*x-d)/b;
				if(x+y<z+w){
					z=x,w=y;
				}else if(x+y==z+w&&x*a+y*b<z*a+w*b){
					z=x,w=y;
				}
			}
			if((d+a*x)%b==0){
				ll y=abs(a*x+d)/b;
				if(x+y<z+w){
					z=x,w=y;
				}else if(x+y==z+w&&x*a+y*b<z*a+w*b){
					z=x,w=y;
				}
			}
		}
		cout<<z<<" "<<w<<endl;
	}
}

Measured memory_bytes: 1156
#include <bits/stdc++.h>
using namespace std;
#define int long long

signed main() {
    int N;
    cin >> N;
    int ans = N;
    for (int i = 1; i*i <= N; i++) {
        if (N%i == 0) {
            int B = N/i;
            int A = i;
            int X = 0;
            int Y = 0;
            while (A != 0) {
                X++;
                A/=10;
            }
            while (B != 0) {
                Y++;
                B/=10;
            }
            ans = min(ans,max(X,Y));
        }
    }
    cout << ans << endl;
}



Measured memory_bytes: 256
let factorize n =
  let rec f c d x =
    if x = 1 then if c > 0 then [(c, d)] else []
    else if c = 0 && d * d > x then [(1, x)]
    else if x mod d = 0 then f (c+1) d (x/d)
    else if c > 0 then (c, d) :: f 0 (d+1) x else f 0 (d+1) x
  in
  f 0 2 n

let rec pow_int a n =
  if n = 0 then 1
  else if n mod 2 = 1 then a * pow_int a (n-1)
  else let h = pow_int a (n/2) in h * h

let () =
  Scanf.scanf "%d %d" @@ fun n p ->
  factorize p
  |> List.fold_left (fun ac (c, d) -> ac * pow_int d (c/n)) 1
  |> Printf.printf "%d\n"


Measured memory_bytes: 384
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <tuple>

using namespace std;
using ll = long long;
using ull = unsigned long long;
#define out(S) cout<<(S)<<endl;
#define REP(i,b) for(size_t i=0;i<(b);i++)
#define rREP(i,b) for(size_t i=(b)-1;i>=0;i--)
#define FOR(i,a,b) for(size_t i=(a);i<(b);i++)
#define rFOR(i,a,b) for(size_t i=(b)-1;i>=0;i--)
#define Foreach(item,collection) for(auto item:collection)
#define mod(i) ((i) % (ll)(1e9 + 7))
ll modpow(ll i, ll j) { ll tmp = 1; while (j) { if (j % 2)tmp = mod(tmp*i); i = mod(i*i); j /= 2; }return tmp; }
#define divmod(a,b) (mod(a * modpow((ll)b,(ll)(1e9 + 5))))
#define Yes out("Yes")
#define No out("No")
#define NO out("NO")
#define YES out("YES")
#define INF INT_MAX/2
#define ShowAll(collection) for(auto i:collection){out(i);}
#define IfOut(condition,text) if((condition)){out(text);return 0;}
#define Select(collection,condition,result) Foreach(i,collection){result+=condition;}
template<typename T> pair<vector<T>,int> getAuto() {int N; cin >> N; pair<vector<T>, int> rt;rt.first.resize(N);rt.second = N;REP(i, N) cin >> rt.first[i];return rt;}
void removeAt(string& s, int index) { s.erase(index, 1); }
template<typename T> void removeAt(vector<T>& v, int index) { v.erase(v.begin() + index); }

int main() {
	char a, b;
	cin >> a >> b;
	out(a == b ? "H" : "D");
}



Measured memory_bytes: 256
N, X = map(int,input().split())
m = []
for i in range(N):
    m.append(int(input()))
m.sort()
ans = N
ing = sum(m)
for i in range(X):
    if ing < X:
        ing += m[0]
        if ing <= X:
            ans += 1

print(ans)

Measured memory_bytes: 3060
#include <cstdlib>
#include <cstring>
#include <limits>
#include <iostream>
#include <queue>
#include <unordered_map>
#include <vector>
using namespace std;

constexpr int MAX_SIZE = 20;
constexpr int MAX_LENGTH = 10;
constexpr int MAX_DEPTH = 2000;

constexpr int dx[5] = {1, -1, 0, 0, 0};
constexpr int dy[5] = {0, 0, 1, -1, 0};
const unordered_map<char, int> conv{{'6', 0}, {'4', 1}, {'2', 2}, {'8', 3}, {'5', 4}};

int h, w;
string field[MAX_SIZE];
string pattern;

int t, ax, ay;
int label[MAX_SIZE][MAX_SIZE];

inline bool out(int x, int y) {
	return x < 0 || y < 0 || x >= w || y >= h;
}

void bfs(int sx, int sy) {
	memset(label, -1, sizeof(label));
	label[sy][sx] = 0;
	queue<pair<int, int>> que;
	que.push({sx, sy});

	while(!que.empty()) {
		const int x = que.front().first;
		const int y = que.front().second;
		que.pop();

		for(int d = 0; d < 4; ++d) {
			const int nx = x + dx[d];
			const int ny = y + dy[d];

			if(out(nx, ny) || field[ny][nx] == '#') continue;
			if(label[ny][nx] == -1) {
				label[ny][nx] = label[y][x] + 1;
				que.push({nx, ny});
			}
		}
	}
}

void search(int x, int y, int tc) {
	if(label[y][x] != -1 && label[y][x] <= tc) {
		t = tc;
		ax = x;
		ay = y;
		return;
	}

	if(tc == MAX_DEPTH) return;

	const int idx = tc % pattern.size();
	int nx = x + dx[conv.at(pattern[idx])];
	int ny = y + dy[conv.at(pattern[idx])];
	if(out(nx, ny)) {
		nx = x;
		ny = y;
	}
	search(nx, ny, tc + 1);
}

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

	while(cin >> h >> w && h) {
		for(int i = 0; i < h; ++i) {
			cin >> field[i];
		}
		cin >> pattern;

		int sx, sy, gx, gy;
		for(int i = 0; i < h; ++i) {
			for(int j = 0; j < w; ++j) {
				if(field[i][j] == 'A') {
					sx = j;
					sy = i;
					field[i][j] = '.';
				}
				else if(field[i][j] == 'B') {
					gx = j;
					gy = i;
					field[i][j] = '.';
				}
			}
		}

		bfs(sx, sy);
		t = numeric_limits<int>::max();
		search(gx, gy, 0);
		if(t == numeric_limits<int>::max()) {
			cout << "impossible" << endl;
		}
		else {
			cout << t << " " << ay << " "<< ax << endl;
		}
	}

	return EXIT_SUCCESS;
}

Measured memory_bytes: 1240
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <climits>

#define rep(i, m, n) for(int i=int(m);i<int(n);i++)
#define EACH(i, c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s, e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

//#define LOCAL 0
//#ifdef LOCAL
//#define DEBUG(s) cout << (s) << endl
//#define dump(x)  cerr << #x << " = " << (x) << endl
//#define BR cout << endl;
//#else
//#define DEBUG(s) do{}while(0)
//#define dump(x) do{}while(0)
//#define BR
//#endif


//改造
typedef long long int ll;
using namespace std;
#define INF (1 << 20)
#define INFl (ll)5e15
#define DEBUG 0 //デバッグする時1にしてね
#define dump(x)  cerr << #x << " = " << (x) << endl
#define MOD 1000000007
//ここから編集する
string s;

bool check(int k){
    vector<int> f(s.size(),0);
//    printf("k = %dの時\n",k);
    int sum = 0;
    char c = s[0];
    for(int i = 0; i + k <= s.size(); ++i){
        if((s[i] != c && sum % 2 == 0) || (s[i] == c && sum % 2 == 1)){
            f[i] = 1;
        }
        sum += f[i];
        if(i - k + 1 >= 0){
            sum -= f[i - k + 1];
        }
    }
    int sq = s.size() - k;
//    for(int i = 0; i < s.size(); i++){
//        if(!((s[i] == c && f[i] == 0) || (s[i] != c && f[i] == 1))){
//            sq = i;
//            break;
//        }
//    }

    for(int i = s.size() - k + 1; i < s.size(); i++){
        if( (s[i] - '0' + sum) % 2 != (s[0] - '0') ){
            break;
        }
        sq++;
        if(i - k + 1 >= 0){
            sum -= f[i-k+1];
        }
    }
    sq++;
//    rep(i,0,s.size()){
//        cout << (s[i] - '0') + f[i];
//    }
//    cout << endl;
    return sq >= k;

}

int main() {

    cin >> s;
    if(check(s.size())){
        cout << s.size() << endl;
        return 0;
    }
    int ng = s.size();
    int ok = 1;
    while(ng - ok > 1){
        int mid = (ok + ng) / 2;
        if(check(mid)){
            ok = mid;
        }else{
            ng = mid;
        }
    }
    cout << ok <<endl;
    return 0;
}


Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
long long n, ans;

bool check(int x){
    if(x % 3 == 0 || x % 5 == 0) return false;
    return true;
}

int main(){
    cin >> n;
    for(int i = 1; i <= n; i++){
        if(check(i)) ans += i;
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3636
# from math import 

s = input()
t = input()

def distance(s, t):
    assert(len(s) == len(t))
    return len(s) - sum([c1 == c2 for c1, c2 in zip(s, t)])


min_d = len(s)

for i in range(len(s) - len(t) + 1):
    min_d = min(min_d, distance(s[i:i+len(t)], t))

print(min_d)

Measured memory_bytes: 9060
using System;
using System.IO;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;
using System.Diagnostics;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using System.Runtime.CompilerServices;
using static System.Math;


class P
{
    static void Main()
    {
        Console.WriteLine(700 + Console.ReadLine().Count(x => x =='o') * 100);
    }
}


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

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

using namespace std;
using ll = long long;

int calc(int x, int y, int z) {
  return x * x + y * y + z * z + x * y + y * z + z * x; 
}


int main(void)
{
  int n;
  cin >> n;
  for (int i = 1; i <= n; ++i) {
    int res = 0;
    for (int x = 1; x*x <= n; ++x) {
      for (int y = 1; y*y <= n; ++y) {
        for (int z = 1; z*z <= n; ++z) {
          if (calc(x,y,z) < i)
            continue;
          if (calc(x,y,z) == i)
            ++res;

          break;
        }
      }
    }
    cout << res << endl;
  }
}

Measured memory_bytes: 3592
//2020年4月17日現在

#include<stdio.h>
#include<cmath>
#include<math.h>
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<complex>
#include<queue>
#include<set>
#include<utility>
#include<iomanip>
#include<limits>
#include<thread>
#include<map>
#include<stack>
#include<numeric>
#include<cassert>
#include<random>
#include<chrono>
#include<unordered_set>
#include<unordered_map>
#include<fstream>
#include<list>
#include<functional>
#include<bitset>
#include<tuple>
#include <cstdio>

using namespace std;


template <class... A>
void prints() { cout << "\n"; }
template <class... A>
void prints_rest() { cout << "\n"; }
template <class T, class... A>
void prints_rest(const T &first, const A &... rest) { cout << " " << first; prints_rest(rest...); }
template <class T, class... A>
void prints(const T &first, const A &... rest) { cout << first; prints_rest(rest...); }
template <class T, class... A>
void printd(const T &first, const A &... rest) { cout << fixed << setprecision(15) << first; prints_rest(rest...); }


namespace {
	// printElems(&a[0], &a[n]);　みたいな感じで使う。
	void printElems(const int* begin, const int* end)
	{
		for (const int* p = begin; p != end; ++p) {
			cout << *p << ' ';
		}
		cout << endl;
	}
}

#define rep(i,n) for(ll i=0; i<n; i++)
#define rep1(i,n) for(ll i=1; i<n+1; i++)
#define repr(i,n) for(ll i=n-1; i>=0; i--)
#define repr1(i,n) for(ll i=n; i>0; i--)
#define FOR(i,j,n) for(ll i=j; i < n; i++)
#define souatari(i,j,n) rep1(i,n-1)rep(j,i)
#define souatari1(i,j,n) for(ll i=2; i<n+1; i++)rep1(j,i-1)
#define mp make_pair
#define F first
#define S second
#define elif else if

typedef long long ll;
typedef vector<int>  vi;
typedef vector<vi>  vvi;
typedef vector<ll> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<pii> vpii;
typedef array<ll,3> arr3;
typedef long double D;


const ll llinf =  numeric_limits<ll>::max();
const ll _llinf = numeric_limits<ll>::lowest();
const int inf = numeric_limits<int>::max();
const int _inf = numeric_limits<int>::lowest();
const double dinf = numeric_limits<double>::infinity();
const ll MOD = 1000000007;
//const ll MOD = 998244353;
const ll BIG = 1LL<<60;
const string yes = "Yes";
const string no = "No";

//----------------------------------------------

ll dp[3005][3005][10];
ll takara[3005][3005];



int main(){
	int r,c,k;
	cin >> r >> c >> k;
	rep(i,k){
		ll rtmp,ctmp,vtmp;
		cin >> rtmp >> ctmp >> vtmp;
		takara[rtmp][ctmp] = vtmp;
	}
	rep1(i,r){
		rep1(j,c){
			dp[i][j][0] = dp[i][j-1][0];
			rep(l,4) dp[i][j][0] = max(dp[i][j][0],dp[i-1][j][l]);
			rep(l,3){
				dp[i][j][l+1] = max(dp[i][j-1][l+1],dp[i][j-1][l]+takara[i][j]);
			}
			dp[i][j][1] = max(dp[i][j][1],dp[i][j][0]+takara[i][j]);
		}
	}
	ll ans = 0;
	rep(l,4) ans = max(ans,dp[r][c][l]);
	prints(ans);



	return 0;
}




Measured memory_bytes: 778152
#include "bits/stdc++.h"

#pragma warning(disable:4996)
using namespace std;
using ld = long double;



int main() {
	long long int amin=0;
	long long int amax=1e18;
	int N;cin>>N;
	vector<multiset<long long int>>passengers(N);
	for (int i = 0; i < N; ++i) {
		int a;cin>>a;
		for (int j = 0; j < a; ++j) {
			int b;cin>>b;
			passengers[i].insert(b);
		}
	}
	multiset<long long int>aset;
	long long int answer=0;
	for (int i = N-1; i >=0;--i) {

		for (auto p : passengers[i]) {
			aset.insert(p);
		}
		auto it=prev(aset.end());
		answer+=*it;
		aset.erase(it);
	}
	cout<<answer<<endl;
	return 0;
}


Measured memory_bytes: 31040
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <vector>
#include <random>
#include <cmath>
#include <chrono>
#include <cstring>
#include <algorithm>
#include <string>
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cassert>
using namespace std;
using LL = long long;
#define eps 1e-8
#define fi first
#define se second
#define eb emplace_back
#define close std::ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr)
#define FOR(i, x, y) for (LL i = (x), _##i = (y); i < _##i; ++i)
#define FORD(i, x, y) for (LL i = (x), _##i = (y); i > _##i; --i)
#define SORT_UNIQUE(c) (sort(c.begin(), c.end()), c.resize(distance(c.begin(), unique(c.begin(), c.end()))))
#define CASET           \
    int ___T;           \
    scanf("%d", &___T); \
    for (int __CS = 1; __CS <= ___T; __CS++)
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;
mt19937 dlsrand(random_device{}());
mt19937 mrand(std::chrono::system_clock::now().time_since_epoch().count());
int rnd(int x) { return mrand() % x; }
LL bin(LL x, LL n, LL MOD)
{
    LL ret = MOD != 1;
    for (x %= MOD; n; n >>= 1, x = x * x % MOD)
        if (n & 1)
            ret = ret * x % MOD;
    return ret;
}
inline LL get_inv(LL x, LL p) { return bin(x, p - 2, p); }
const double PI = acos(-1.0);
constexpr int maxn = 1e6 + 10;
constexpr int INF = 0x3f3f3f3f;
constexpr ll linf = 0x3f3f3f3f3f3f3f3f;
constexpr int mod = 1e9 + 7;
int a[maxn], b[maxn], n, k, q;
int solve(int x)
{
    vector<int> v, res;
    for (int i = 1; i <= n; i++)
    {
        if (a[i] >= x)
            v.eb(a[i]);
        else
        {
            sort(v.begin(), v.end());
            for (int i = 0; i + k <= v.size(); i++)
            {
                res.eb(v[i]);
            }
            v.clear();
        }
    }
    sort(v.begin(), v.end());
    for (int i = 0; i + k <= v.size(); i++)
        res.push_back(v[i]);
    v.clear();
    sort(res.begin(), res.end());
    if (res.size() < q)
        return INF;
    return res[q - 1] - res[0];
}
int main()
{
    close;
    cin >> n >> k >> q;
    for (int i = 1; i <= n; i++)
    {
        cin >> a[i];
        b[i] = a[i];
    }
    sort(b + 1, b + 1 + n);
    int tot = unique(b + 1, b + n + 1) - (b + 1);
    int ans = INF;
    for (int i = 1; i <= tot; i++)
    {
        ans = min(ans, solve(b[i]));
    }
    cout << ans << endl;
}

Measured memory_bytes: 2304
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/integer/common_factor.hpp>
#include <boost/integer/common_factor_rt.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>

using std::string;
using std::vector;
using std::set;
using std::multiset;
using std::unordered_set;
using std::map;
using std::multimap;
using std::unordered_map;
using std::pair;
using std::cin;
using std::cout;

typedef uintmax_t    ull;
typedef intmax_t     ll;
typedef uint64_t     ul;
typedef uint32_t     ui;
typedef uint8_t      uc;

typedef boost::multiprecision::number<boost::multiprecision::cpp_dec_float<1000>> cpp_dec_float_1000;

constexpr char CRLF  = '\n';
constexpr char SPACE = ' ';
constexpr char VECTOR_COUT_SEPARATOR = SPACE;
constexpr ll INF = 1000'000'007;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> std::ostream& operator<< (std::ostream& os, const std::vector<T>& vc) { for(auto it = vc.begin(); it != vc.end(); ++it) { if (std::next(it) == vc.end()) os << *it; else os << *it << VECTOR_COUT_SEPARATOR; } return os; }
template<class T1, class T2> inline std::ostream & operator<< (std::ostream & os, const std::pair<T1, T2> & p) { return os << p.first << ' ' << p.second; }

void solve(void)
{
  set<int> s = {1, 2, 3};
  int a, b; cin >> a >> b;
  s.erase(a);
  s.erase(b);
  cout << *s.begin() << CRLF;
  return;
}

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

  solve();

  return 0;
}


Measured memory_bytes: 256
#coding:utf-8
N = int(input())
cnt = 1

datalist =[ list(map(str, input().split())) for i in range(N) ]

for i in range(0,N):
    datalist[i].append(cnt)
    cnt += 1

datalist2 = sorted(datalist, key=lambda x:(x[0], -int(x[1])))

for i in range(0,N):
    print(datalist2[i][2])

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

using namespace std;
/**
********************************************************************
******************* Author:Bisnu sarkar ****************************
********************************************************************
**/

#define ull            unsigned long long
#define ll             long long
#define vi             vector<int>
#define pb             push_back
#define mp             make_pair
#define pii            pair<int,int>
#define vit            vector<int> :: iterator
#define sit            set<int> :: iterator
#define vrit           vector<int> :: reverse iterator
#define ff             first
#define ss             second

#define what_is(x)     cerr << #x << " is " << x << endl;

///*....Debugger....*/

#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it)
{
    cout << endl ;
}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args)
{
    cerr << *it << " = " << a << ' ' ;
    err(++it, args...);
}

int dx[8]= {1,0,-1,0,-1,-1,1,1};
int dy[8]= {0,1,0,-1,-1,1,-1,1};
int ini()
{
    int x;
    scanf("%d",&x);
    return x;
}
long long inl()
{
    long long x;
    scanf("%lld",&x);
    return x;
}

const int N = (int) 1e6 + 5;
const int M = (int) 1e9 + 7;
const double pi=2* acos(0.0);
std::vector<pair<int,ll>> adj[N];
bool vis[N];
ll dis[N];
int colour[N];

void bfs(int u){
    queue<int>q;
    q.push(u);
    vis[u]=true;
    colour[u]=0;
    dis[u]=0;
    while(!q.empty()){
      u=q.front();
      q.pop();

      for(int i=0;i<adj[u].size();i++){
        int v=adj[u][i].ff;
        ll w=adj[u][i].ss;
        if(!vis[v]){
            dis[v]=dis[u]+w;
            if(w%2 ==0){
                colour[v]=colour[u];
            }
            else{
                colour[v]=!colour[u];
            }
            vis[v]=true;
            q.push(v);
            vis[v]=true;
        }
      }
    }
}
int main()
{
    int n=ini();

    for(int i=1;i<n;i++){
        int u,v;
        ll w;
        u=ini(),v=ini(),w=inl();
        if(w%2==0){
            colour[u]=colour[v]=1;
        }

        adj[u].push_back({v,w});
        adj[v].push_back({u,w});
    }
    bfs(1);
    for(int i=1;i<=n;i++){
        cout<<colour[i]<<endl;
        
    }

    return 0;
}


Measured memory_bytes: 35968
#include <bits/stdc++.h>
#ifdef __DEBUG__
    #define DBG(X) cout << #X << " = " << (X) << endl;
    #define SAY(X) cout << (X) << endl;
#else
    #define DBG(X)
    #define SAY(X)
#endif

using namespace std;

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

int dx[]={1, 0, -1, 0, 1,-1, 1,-1};
int dy[]={0, 1, 0, -1, 1, 1,-1,-1};
const int INT_INF = (int)(2e9);
const ll  LL_INF = (ll)(2e18);

inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const map<T, S> p) { for (auto el : p) cout << "[" << el.first << ";" << el.second << "]"; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const deque<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const set<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline vector<T> fetch_vec(int sz) { vector<T> ret(sz); for (auto& elem : ret) cin >> elem; return ret; }

string s,t;
void input(){
    fast_io();
    cin >> s >> t;
}

int solve(){
    int ans = 1e6;
    for (int i = 0; i <= (s.length()-t.length()); i++)
    {
        int tmp = 0;
        for (int j = 0; j < t.length(); j++)
        {
            if(((i+j)<s.length()) && s[i+j]!=t[j]){
                tmp++;
            }
        }
        ans = min(ans, tmp);
    }
    cout << ans << endl;
    return 0;
}   

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

Measured memory_bytes: 3640
N = int(input())
T,A = map(int, input().split())
H = list(map(int, input().split()))

x = 0
temp = float('inf')
ans = 0
tmp = 0
for i in range(N):
    x = T - H[i]*0.006
    tmp = abs(x-A)
    if tmp < temp:
        temp = tmp
        ans = i+1

print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
using namespace std;
#define loop(i,N) for(ll (i)=0; (i)<(N);++(i))
struct _OMAZINAI_ { _OMAZINAI_() { std::ios::sync_with_stdio(false); std::cin.tie(0); } } __omazinai_instance__;
#define INF (1LL<<61 + 1<<29)
#define YesNo(x) {std::cout << ((x)?"Yes":"No") << std::endl;}
#define YESNO(x) {std::cout << ((x)?"YES":"NO") << std::endl;}
#define OddEven(x) {std::cout << ((x)%2?"Odd":"Even") << std::endl;}
#define ODDEVEN(x) {std::cout << ((x)%2?"ODD":"EVEN") << std::endl;}
typedef long long int ll;
void _INPUT_IMPL_() {};
template <class T, class... Args> void _INPUT_IMPL_(T& dest, Args&... args) { cin >> dest; _INPUT_IMPL_(args...); }
void _OUTPUT_IMPL_() {};
template <class T, class... Args> void _OUTPUT_IMPL_(T dest, Args... args) { cout<< dest << (sizeof...(Args)?" ":""); _OUTPUT_IMPL_(args...); }
#define in(type, ...) type __VA_ARGS__; _INPUT_IMPL_(__VA_ARGS__)
#define in_v(type, name, cnt) vector<type> name(cnt); loop(i, cnt) cin >> name[i];
#define sort_v(v) std::sort(v.begin(), v.end())
#define out(...) _OUTPUT_IMPL_(__VA_ARGS__)

int main() {
	in(int, a, b, c);
	YESNO(b - a == c - b);
}

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

using std::cin;
using std::cout;



int main(int argc, char* argv[])
{
  std::ios::sync_with_stdio(false);
  cin.tie(nullptr);

  int K, A, B;
  cin >> K >> A >> B;

  long long res = K + 1;
  if (A < B)
  {
    K = std::max(0, K+1-A);
    if (K)
    {
      res = std::max(res, A + 1LL * K/2 * (B-A) + (K&1));
    }
  }
  cout << res << "\n";

  return 0;
}



Measured memory_bytes: 256
import std.stdio, std.conv, std.functional, std.string;
import std.algorithm, std.array, std.container, std.range, std.typecons;
import std.bigint, std.numeric, std.math, std.random;
import core.bitop;

string FMT_F = "%.10f";

static File _f;
void file_io(string fn) { _f = File(fn, "r"); }
static string[] s_rd;
T _RD(T = long)() { while(!s_rd.length) s_rd = readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
T _RD(T = long)(File f) { while(!s_rd.length) s_rd = f.readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
T[] _RDA(T = long)(T fix = 0) { auto r = readln.chomp.split.to!(T[]); r[] += fix; return r; }
T[] _RDA(T = long)(File f, T fix = 0) { auto r = f.readln.chomp.split.to!(T[]); r[] += fix; return r; }
T RD(T = long)() { if (_f.isOpen) return _RD!T(_f); else return _RD!T; }
T[] RDA(T = long)(T fix = 0) { if (_f.isOpen)  return _RDA!T(_f, fix); else return _RDA!T(fix); }

size_t[] MAKE_IDX(alias less = "a < b", Range)(Range range) { auto idx = new size_t[](range.length); makeIndex!(less)(range, idx); return idx;}
size_t MIN_POS(alias less = "a < b", Range)(Range range) { auto r = minPos!(less)(range); return range.length - r.length; }

void chmin(T)(ref T x, T y) { x = min(x, y); } void chmax(T)(ref T x, T y) { x = max(x, y); }
bool inside(T)(T x, T b, T e) { return x >= b && x < e; }
T lcm(T)(T x, T y) { return x * (y / gcd(x, y)); }

long mod = 10^^9 + 7;
//long mod = 998_244_353;
//long mod = 1_000_003;
void moda(T)(ref T x, T y) { x = (x + y) % mod; }
void mods(T)(ref T x, T y) { x = ((x + mod) - (y % mod)) % mod; }
void modm(T)(ref T x, T y) { x = (x * y) % mod; }
void modpow(T)(ref T x, T y) { if (!y) { x = 1; return; } auto t = x; x.modpow(y>>1); x.modm(x); if (y&1) x.modm(t); }
void modd(T)(ref T x, T y) { y.modpow(mod - 2); x.modm(y); }

void main()
{
	auto S = RD;

	auto len = S / 3;
	auto dp = new long[][](len+1, S+1);
	dp[0][0] = 1;
	foreach (i; 0..len)
	{
		long tot;
		foreach (j; 0..S-2)
		{
			tot.moda(dp[i][j]);
			dp[i+1][j+3].moda(tot);
		}
	}
	//debug writeln(dp);

	long ans;
	foreach (i; 0..len)
	{
		ans.moda(dp[i+1][S]);
	}

	writeln(ans);
	stdout.flush;
	debug readln;
}


Measured memory_bytes: 13428
#include <iostream>
#include <limits.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <cassert>

#define REP(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
#define mp make_pair
#define pb push_back
#define eb emplace_back

typedef long long ll;
using namespace std;
int maze[3][3];
int ok[3][3];
int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    // cout << fixed << setprecision(20);
    REP(i,3)REP(j,3)cin >> maze[i][j];

    int n;cin >> n;
    REP(i,n){
        int a;cin >> a;
        REP(j,3)REP(k,3){
            if(maze[j][k] == a)ok[j][k] = 1;
        }
    }
    REP(i,3){
        bool judge = true;
        REP(j,3)if(ok[i][j] == 0)judge = false;
        if(judge){
            cout << "Yes" << '\n';
            return 0;
        }
    }

    REP(i,3){
        bool judge = true;
        REP(j,3)if(ok[j][i] == 0)judge = false;
        if(judge){
            cout << "Yes" << '\n';
            return 0;
        }
    }

    bool judge = true;
    REP(i,3){
        if(ok[i][i] == 0)judge = false;
    }
    if(judge){
        cout << "Yes" << '\n';
        return 0;
    }
    judge = true;
    REP(i,3){
        if(ok[i][2-i] == 0)judge = false;
    }
    if(judge){
        cout << "Yes" << '\n';
        return 0;
    }
    cout << "No" << '\n';
    return 0;

}


Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;

using E = System.Linq.Enumerable;

public class Program
{
    public static void Main()
    {
        var lrd = Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray();
        var (l, r, d) = (lrd[0], lrd[1], lrd[2]);

        var k = 0;
        for (int i = 1; i * d <= r; ++i)
        {
            if (i * d < l)
            {
                continue;
            }

            ++k;
        }

        Console.WriteLine(k);
    }
}


Measured memory_bytes: 28248
#include<iostream>
#include<string>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<vector>
#include<functional>
#include<iomanip>
#include<queue>
#include<cassert>
#include<tuple>
#include<set>
#include<map>
#include<list>
#include<bitset>
#include<utility>
#include<numeric>

#define PB push_back
#define all(a)  (a).begin(),(a).end()
#define ALL(v) begin(v), end(v)
#define DWN(a)  (a).begin(),(a).end(), greater<int>()
#define rep(i, m) for (int i = 0; i < m; i++)
#define REP(i, n, m) for (int i = n; i < m; i++)
#define V vector<int>
#define VV vector<V>
#define VVV vector<VV>

using namespace std;

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

const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };
const int inf = (int)1e9;
const ll INF = (ll)1e18;
const ll MOD{ (ll)1e9 + 7 };
const long double EPS = 1e-10;

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

	int cnt = 0, ans = 0;

	rep(i, s.size()) {
		if (s[i] == 'S') {
			cnt++;
		}
		else {
			if (cnt) {
				cnt--;
				ans += 2;
			}
		}
	}

	cout << s.size() - ans << endl;
	return 0;
}

Measured memory_bytes: 640
import numpy as np

def main():
    #1. make master list
    N = int(input())
    A = list(map(int, input().split()))

    A.append(0)
    A.insert(0,0)

    A = np.array(A)
    
    cost = np.abs(A[1:] - A[:-1])    
    total = sum(cost)    
    #2. remove i-th componet
    for i in range(N):

        #3. output
        print(total - cost[i] - cost[i+1] + abs(A[i+2]-A[i]))

if __name__ == "__main__":
    main()

Measured memory_bytes: 22848
#import sys
#input = sys.stdin.readline
def main():
    N, K = map( int, input().split())
    A = list( map( int, input().split()))
    dp = [[None]*2 for _ in range(K+1)]
    for i in range(A[0]):
        dp[i][0] = False
        dp[i][1] = True
    for k in range(A[0], K+1):
        win = False
        for a in A:
            if a <= k:
                if dp[k-a][1]:
                    win = True
                    break
        dp[k][0] = win
        win = True
        for a in A:
            if a <= k:
                if not dp[k-a][0]:
                    win = False
                    break
        dp[k][1] = win
    if dp[K][0]:
        print("First")
    else:
        print("Second")

if __name__ == '__main__':
    main()

Measured memory_bytes: 13300
#include <iostream>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <new>
#include <utility>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <tuple>
#include <iomanip>

typedef long long ll;
typedef long double ld;

using namespace std;
using Graph = vector<vector<ll>>;

#define rep(i, N) for (ll i = 0; i < (ll)(N); ++i)
#define ALL(a) (a).begin(),(a).end()

const ll inf = 1e18+7;
const ll mod = 1e9+7;

ll GetDigit(ll num){
    unsigned digit=0;
    while(num!=0){
        num /= 10;
        digit++;
    }
    return digit;
}

int main(){
    ll N,sum=0;
    cin >> N;
    vector<ll> V(N,0);
    vector<ll> C(N,0);
    vector<ll> S(N,0);
    rep(i,N) cin >> V[i];
    rep(i,N) cin >> C[i];
    rep(i,N){
        S[i]=V[i]-C[i];
        if(S[i]>0){
            sum+=S[i];
        }
    }
    cout << sum << endl;
    return 0;
}


Measured memory_bytes: 256
a,b,c,d=list(map(int,input().split()))
e=[a,b,c]
w,r,t=e[0],e[1],e[2]
u=0
for i in range(d//a+1):
    y=d-(a*i)
    for o in range(y+1):
        x=y-(b*o)
        if x%c==0 and x>=0:
            u+=1
print(u)

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

using namespace std;

typedef long long ll;

const double pi = 3.14159265358979323846;

#define rep(i, n) for (ll i = 0; i < n; i++)
#define mod 1000000007LL
#define PS(p) cout << setprecision(15) << fixed << p << endl;
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
#define ALL(c) c.begin(), c.end()

int main() {
  int AB, BC, CA;

  cin >> AB >> BC >> CA;

  cout << (AB * BC) / 2 << endl;

  return 0;
}

Measured memory_bytes: 256
#!/usr/bin/python3

n = int(input())
a = [int(_) for _ in input().split()]

d = []
for i in range(n):
    d.append(a[i] - (i + 1))

d.sort()
m = d[int(n/2)]

s = 0
for i in range(n):
    s += abs((a[i] - (i + 1 + m)))

print(s)


Measured memory_bytes: 26128
#include <bits/stdc++.h>
#define rep(i,n) for (ll i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<vector<ll> > Graph;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const ll INF = 1e16;

int n;
Graph G;
ll ans[200010];
vector<ll>a;
ll dp[200010];

void dfs(int v,int p){
    ll now = a[v];
    int itr = lower_bound(dp,dp+200010,now)-dp;
    ll old = dp[itr];
    dp[itr]=now;
    ans[v]=lower_bound(dp,dp+200010,INF)-dp-1;
    for(ll x : G[v]){
        if(x==p)continue;
        dfs(x,v);
    }
    dp[itr]=old;
}

int main(){
    cin >> n;
    a.resize(n);
    rep(i,n)cin>>a[i];
    G.resize(n);
    rep(i,n-1){
        int a,b;
        cin >> a >> b;
        a--;b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    rep(i,200010){
        dp[i]=INF;
    }
    dp[0]=-INF;
    dfs(0,-1);
    rep(i,n){
        cout << ans[i] << endl;
    }
    return 0;
}


Measured memory_bytes: 33256
'use strict'

const main = input => {
	const args = input.split('\n').map(arg => arg.split(' '))
	const N = parseInt(args[0][0], 10)
	let v	= args[1].map(arg => parseInt(arg, 10)).sort((a, b) => a - b)

	while (v.length > 1) {
		const t1 = v.shift()
		const t2 = v.shift()
		v.push((t1 + t2) / 2)
		v = v.sort((a, b) => a - b)
	}

	console.log(v[0])
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'))


Measured memory_bytes: 7500