akhauriyash/Code-Regression huggingface dataset:
import math
a, b, c, d = map(int, input().split())
lcm = c * d // math.gcd(c, d)
multi_c = b // c - (a-1) // c
multi_d = b // d - (a-1) // d
multi_lcm = b // lcm - (a-1) // lcm
print(b - a + 1 - multi_c - multi_d + multi_lcm)

Measured memory_bytes: 9196
#include<iostream>
#include<string>
#include<set>
#include<algorithm>
using namespace std;
int main(){
  string sya;
  int n;
  cin>>n;
  for(int i=0;i<n;i++){
    set<string> a;
    cin>>sya;
    a.insert(sya);
    for(int j=1;j<sya.size();j++){
      string b,c,a1,a2;
      for(int k=0;k<j;k++)b+=sya[k];
      for(int k=j;k<sya.size();k++)c+=sya[k];
      a.insert(c+b);
      reverse(b.begin(),b.end());
      a.insert(b+c);
      a.insert(c+b);
      reverse(c.begin(),c.end());
      a.insert(b+c);
      a.insert(c+b);
      reverse(b.begin(),b.end());
      a.insert(b+c);
      a.insert(c+b);
    }
    cout<<a.size()<<endl;
  }
  return 0;
}

Measured memory_bytes: 3260
#include <bits/stdc++.h>
using namespace std;
#define int         long long
#define ld          long double
#define endl        "\n"

const int mod = 1e9+7;

inline int add(int a, int b) { int res = a + b; if(res >= mod) res -= mod;  return res; }
inline int sub(int a, int b) { int res = a - b; if(res < 0) res += mod; return res;}
inline int mul(int a, int b) { return (a * b)%mod; }


void solve() {

    int n, m, k, x, y;
    cin >> x >> y >> n >> m >> k;
    int a[n], b[m], c[k];
    for(int i=0; i<n; i++) cin >> a[i];
    for(int i=0; i<m; i++) cin >> b[i];
    for(int i=0; i<k; i++) cin >> c[i];
    sort(a, a + n); reverse(a, a + n);
    sort(b, b + m); reverse(b, b + m);
    sort(c, c + k); reverse(c, c + k);
    priority_queue<int, vector<int>, greater<int>> q;
    for(int i=0; i<x; i++) q.push(a[i]);
    for(int i=0; i<y; i++) q.push(b[i]);
    int cur = 0;
    while(cur < k && !q.empty()) {
        int tp = q.top();
        if(tp < c[cur]) {
            q.pop();
            q.push(c[cur]);
            cur++;
        } else {
            break;
        }
    }
    int ans = 0;
    while(!q.empty()) {
        ans += q.top();
        q.pop();
    }
    cout << ans << endl;
}

signed main() {

    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    cout << fixed << setprecision(12);

    int T = 1;
    //cin >> T;
    for(int tt=1; tt<=T; tt++) {
    	solve();
    }
    return 0;
}

Measured memory_bytes: 4852
#include <bits/stdc++.h>
#define MOD 1000000007
using namespace std;

int main() {
  int a, b;
  cin >> a >> b;
  if (b%2) {
    cout << "No" << endl;
    return 0;
  }
  int low = a*2, h = a*4;
  if (low <= b && b <= h)
    cout << "Yes" << endl;
  else  cout << "No" << endl;
  return 0;
}


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

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

    int ans = 100100;
    {
        for(char ch = 'a'; ch <= 'z'; ch++){
            int costart = 0;
            int coans = 0;
            for(int i = 0; i < s.length(); i++){
                if(s[i] == ch){
                    int cocoans = i - costart;
                    if(cocoans > s.length()-costart) cocoans = s.length()-costart;
                    if(coans < cocoans) coans = cocoans;
                    costart = i+1;
                }
            }
            if(costart != s.length()){
                int cocoans = s.length()-costart;
                if(coans < cocoans) coans = cocoans;
            }

            if(coans < ans) ans = coans;
        }
    }

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

Measured memory_bytes: 256
S = "X" * chomp(readline())
function letter(S)
    if S[end-4:end] == "dream" || S[end-4:end] == "erase"
        return S = S[1:end-5]
    elseif S[end-5:end] == "eraser"
        return S = S[1:end-6]
    elseif S[end-6:end] == "dreamer"
        return S = S[1:end-7]
    end
end

for i in 1:25000
    try
        S = letter(S)
    except
        break
    end
end

if S == "X"
    println("YES")
else
    println("NO")
end

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

long aps(long a, long d, long n) {
  return n * (2 * a + (n - 1) * d) / 2;
}

int main() {
  int N;
  cin >> N;
  long ans = 0;
  for (int i = 1; i <= N; i++) {
    ans += aps(i, i, N / i);
  }
  cout << ans << "\n";
}

Measured memory_bytes: 3592
import java.util.Scanner;

public class Main {
    static int[][] map;
    static int h, w;

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while (true) {
            w = sc.nextInt();
            h = sc.nextInt();
            if ((h | w) == 0) { break; }
            map = new int[h][w];
            for (int i = 0; i < h; i++) {
                for (int j = 0; j < w; j++) {
                    map[i][j] = sc.nextInt();
                }
            }
            int c = 0;
            // arrayDump(map);
            for (int i = 0; i < h; i++) {
                for (int j = 0; j < w; j++) {
                    if (map[i][j] == 1) {
                        fill(i, j);
                        // arrayDump(map);
                        c++;
                    }
                }
            }
            System.out.println(c);
        }
    }

    private static void fill(int y, int x) {
        if (y < 0 || x < 0 || y >= h || x >= w || map[y][x] == 0) {
            return;
        }
        map[y][x] = 0;
        for (int dx = -1; dx < 2; dx++) {
            for (int dy = -1; dy < 2; dy++) {
                if ((dx | dy) == 0) {
                    continue;
                }
                fill(y + dy, x + dx);
            }
        }
    }
}

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

const long long INF = 1000000000;

typedef long long ll;

#define writeln(n) cout<<n<<"\n"
#define rep(i,n) for(int i=0; i<(n); ++i)

typedef pair<int, int> P;
typedef pair<string, int> Psi;

vector<int> X[200010];
bool dfs(int from, int pre, int cnt,int goal){
	if(from == goal && cnt ==2 ){
		return true;
	}
	if(cnt >3)return false;

	for(int i=0; i<X[from].size(); i++ ){
		int next = X[from][i];



		if(next != pre){

			if(dfs(next,from,cnt+1,goal))return true;
		}
	}
	return false;
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n,m; cin>>n>>m;



	rep(i,m){
		int from,to;cin>>from>>to;

		X[from].push_back(to);
		X[to].push_back(from);
	}

	if(dfs(1,0,0,n)){
		writeln("POSSIBLE");
	}else {
		writeln("IMPOSSIBLE");
	}





}


Measured memory_bytes: 12016
#include<iostream>
using namespace std;
int main(){
  int a,b;
  char op;
  while(1){
    cin>>a>>op>>b;
    if(op=='+'){
      cout <<a+b<<endl;
    }
    else if(op=='-'){
      cout <<a-b<<endl;
    }
    else if(op=='*'){
      cout <<a*b<<endl;
    }
    else if(op=='/'){
      cout <<a/b<<endl;
    } 
    else if(op=='?'){
      break;
    } 
  }
}



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

const int maxn=5e5+10;

int n,L,H,T;

struct Point{
	LL x;
	double y;
	Point() {}
	Point(LL x,double y):x(x),y(y) {}
	Point operator + (const Point &p) const {return Point(x+p.x,y+p.y);}
	Point operator - (const Point &p) const {return Point(x-p.x,y-p.y);}
};

double Cross(Point A,Point B) {return A.x*B.y-A.y*B.x;}

Point P[maxn];

Point GetPoint(Point A,Point B,LL x)
{
	double t=((double)x-A.x)/(B.x-A.x);
	return Point(x,A.y+t*(B.y-A.y));
}

void print()
{
	for (int i=H;i<=T;i++)
		printf("(%lld, %lf) (%lld, %lf)\n",P[i].x,P[i].y,P[i].x-P[T].x,P[i].y-P[T].y);
	puts("");
}

int main()
{
	scanf("%d%d",&n,&L);
	H=T=1;
	P[1]=Point(0,0);
	while (n--)
	{
		Point p;
		scanf("%lf%lld",&p.y,&p.x);
		p.y*=p.x;
		T++;
		P[T]=P[T-1]-p;

//		puts("print1"); print();

		while (H!=T&&P[H+1].x-P[T].x>=L) H++;

//		puts("print2"); print();

		if (P[H].x-P[T].x>L)
			P[H]=GetPoint(P[H],P[H+1],P[T].x+L);

//		puts("print3"); print();

		while (H+1<T&&Cross(P[T-1]-P[T],P[T-2]-P[T])>=0) P[T-1]=P[T],T--;

//		puts("print4"); print();


		printf("%.10lf\n",((double)P[H].y-P[T].y)/L);
//		puts("");
//		puts("---------------------");
//		puts("");
	}
}


Measured memory_bytes: 18304
import Data.List
import Control.Monad

main :: IO()
main = do
  (n:k:_) <- fmap (map read . words) getLine :: IO [Int]
  as <- fmap (map read . words) getLine :: IO [Int]
  let
    Just ind = elemIndex 1 as
  print $ (div (n - k) (k - 1)) + 1 + if mod (n - k) (k - 1) == 0 then 0 else 1


Measured memory_bytes: 18812
#include<bits/stdc++.h>
#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define ull unsigned long long
#define vi vector<ll>
#define vvi vector<vi>
#define BITLE(n) (1LL<<(n))
#define BITCNT(n) (__builtin_popcountll(n))
#define SUBS(s,f,t) ((s).substr((f)-1,(t)-(f)+1))
#define ALL(a) (a).begin(),(a).end()
using namespace std;
struct Grid{ll x,y,t;};
struct Edge{ll to,cost;};
struct Graph{vector<vector<Edge>>E;int V;
  const ll Inf = llINF;const int MAX_V=201010;vector<ll>d;
  Graph(int n):E(n){d.resize(MAX_V);E.resize(n);V=n;}
  void init(){for(int i=0;i<MAX_V;i++)d[i]=Inf;}
  void add_edge(ll from,ll to,ll cost){E[from].pb({to,cost});}
};
bool field[1000][1000];
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll a,b;cin>>a>>b;
  ll h,w;cin>>h>>w;
  for(int i=0;i<a;i++){
    for(int j=0;j<b;j++){
      if(field[i][j]==false&&i+h-1<a&&j+w-1<b)
	for(int k=0;k<h;k++)
	  for(int kk=0;kk<w;kk++)
	    field[i+k][j+kk]=true;
    }
  }
  ll ans=0;
  for(int i=0;i<a;i++){
    for(int j=0;j<b;j++){
      ans+=(!field[i][j]);
      // cout<<(field[i][j]?'o':'.');
    }
    //cout<<endl;
  }
  cout<<ans<<endl;
  return 0;
}



Measured memory_bytes: 3260
#include<bits/stdc++.h>
#define int long long int
using namespace std;
int32_t main(){
	ios_base::sync_with_stdio(false);
    cin.tie(NULL); 
    cout.tie(NULL);
	string s;
	cin>>s;
	deque<char> d; 
	for(auto &it:s)
		d.push_back(it); 
	int q;
	cin>>q;
	int state = 0; 
	while(q--){
		int t;
		cin>>t; 
		if(t==1){
			state ^= 1;
		}else{
			int f;
			char ch;
			cin>>f>>ch;
			if(f==1){
				if(state){
					d.push_back(ch);
				}else{
					d.push_front(ch);
				}
			}else{
				if(state){
					d.push_front(ch);
				}else{
					d.push_back(ch);
				}
			}
		}
	} 
	if(!state){
		while(!d.empty()){
			cout<<d.front();
			d.pop_front();
		} 
	}else{
		while(!d.empty()){
			cout<<d.back();
			d.pop_back();
		} 
	}
}

Measured memory_bytes: 976
N, M = map(int,input().split())
A = [list(input()) for n in range(N)]
B = [list(input()) for m in range(M)]

ans = "No"

for up in range(N-M+1):
  for left in range(N-M+1):
    flag = True
    for m1 in range(M):
      for m2 in range(M):
        if A[up+m1][left+m2] != B[m1][m2]:
          flag = False
    if flag == True:
      ans = "Yes"
      break
print(ans)
        

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


 int main(){
  int a,b,k,v=0,i;
  cin >> a >> b >> k;
  for(i=1;i<1000;i++){
    if(a%i==0 && b%i==0){
      v++;
    }
  }
  int y=v;
  v=0;
  for(i=1;i<1000;i++){
    if(a%i==0 && b%i==0){
      v++;
    }
    if(v==y-k+1){
      break;
    }
  }
  cout << i << endl;
  
 }

Measured memory_bytes: 256
N = int(input())
lis = list(map(int, input().split()))
c = 1
j_min = lis[0]
if N == 1:
  print(c)
else:
  for i in range(1,N):
    if j_min > lis[i]:
        c += 1
        j_min = lis[i]
  print(c)

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

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

  string x; cin >> x;
  int s = 0,st = 0;
  for(int i = 0; i < x.size(); i++){
    if(x[i] == 'S') s++;
    else {
      if(s == 0) continue;
      else {
        s--;
        st += 2;
      }
    }
  }
  cout << x.size() - st << endl;

  return 0;
}


Measured memory_bytes: 720
import bisect

N, M = map(int, input().split())
P = [0 for _ in range(M)]
Y = [0 for _ in range(M)]
y_p = [[] for _ in range(N+1)]
for i in range(M):
    P[i], Y[i] = map(int, input().split())
    y_p[P[i]].append(Y[i])

for p in set(P):
    y_p[p].sort()

for p, y in zip(P, Y):
    order = bisect.bisect_left(y_p[p], y) + 1
    ans = str(p).zfill(6) + str(order).zfill(6)
    print(ans)

Measured memory_bytes: 28932
#include <iostream>
#include <vector>
#include <numeric>
#include <algorithm>
#include <queue>
#include <utility>
#include <tuple>
using namespace std;
using Int = long long;

int main()
{
    int N;
    cin >> N;
    vector<int> A(N+1), B(N+1);
    for (int i = 1; i <= N; i++) {
        int k;
        cin >> k;
        A[i] = A[i-1] + k;
    }
    for (int i = 1; i <= N; i++) {
        int k;
        cin >> k;
        B[i] = B[i-1] + k;
    }
    int M = 0;
    for (int i = 1; i <= N; i++) {
        M = max(M, A[i] - A[0] + B[N] - B[i-1]);
    }
    cout << M << endl;
    return 0;
}

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

int main(){
	string s1,s2;
	while(cin>>s1>>s2){
		int l1=s1.size(),l2=s2.size();
		if (l1>l2){
			cout<<"GREATER"<<endl;
		}
		else if (l1<l2){
			cout<<"LESS"<<endl;
		}
		else{
			int flag=0;
			for(int i=0;i<l1;i++){
				if (s1[i]>s2[i]){
					flag=1;
					break;
				}
				else if (s1[i]<s2[i]){
					flag=-1;
					break;
				}
			}
			if (!flag) cout<<"EQUAL"<<endl;
			else if (flag==1){
				cout<<"GREATER"<<endl;
			}
			else cout<<"LESS"<<endl;
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin >> n;
    vector<int> a(n);
    for(int i = 0; i < n; i++) {
        cin >> a[i];
        a[i]--;
    }
    
    int ans = 0;
    for(int i = 0; i < n; i++)
        if (a[a[i]] == i)
            ans++;
    ans /= 2;
    cout << ans << '\n';
  
    return 0;
}

Measured memory_bytes: 640
# -*- coding: utf-8 -*-
import sys
import math
import os
import itertools
import string
import heapq
import _collections
from collections import Counter
from collections import defaultdict
from collections import deque
from functools import lru_cache
import bisect
import re
import queue
import decimal


class Scanner():
    @staticmethod
    def int():
        return int(sys.stdin.readline().rstrip())

    @staticmethod
    def string():
        return sys.stdin.readline().rstrip()

    @staticmethod
    def map_int():
        return [int(x) for x in Scanner.string().split()]

    @staticmethod
    def string_list(n):
        return [Scanner.string() for i in range(n)]

    @staticmethod
    def int_list_list(n):
        return [Scanner.map_int() for i in range(n)]

    @staticmethod
    def int_cols_list(n):
        return [Scanner.int() for i in range(n)]


class Math():
    @staticmethod
    def gcd(a, b):
        if b == 0:
            return a
        return Math.gcd(b, a % b)

    @staticmethod
    def lcm(a, b):
        return (a * b) // Math.gcd(a, b)

    @staticmethod
    def divisor(n):
        lower, upper = [], []
        i = 1
        while i * i <= n:
            if n % i == 0:
                lower.append(i)
                if i != n // i:
                    upper.append(n // i)
            i += 1
        return lower + upper[::-1]

    @staticmethod
    def round_up(a, b):
        return -(-a // b)

    @staticmethod
    def is_prime(n):
        if n < 2:
            return False
        if n == 2:
            return True
        if n % 2 == 0:
            return False
        d = int(n ** 0.5) + 1
        for i in range(3, d + 1, 2):
            if n % i == 0:
                return False
        return True

    @staticmethod
    def fact(N):
        res = {}
        tmp = N
        for i in range(2, int(N ** 0.5 + 1) + 1):
            cnt = 0
            while tmp % i == 0:
                cnt += 1
                tmp //= i
            if cnt > 0:
                res[i] = cnt
        if tmp != 1:
            res[tmp] = 1
        if res == {}:
            res[N] = 1
        return res


def pop_count(x):
    x = x - ((x >> 1) & 0x5555555555555555)
    x = (x & 0x3333333333333333) + ((x >> 2) & 0x3333333333333333)
    x = (x + (x >> 4)) & 0x0f0f0f0f0f0f0f0f
    x = x + (x >> 8)
    x = x + (x >> 16)
    x = x + (x >> 32)
    return x & 0x0000007f


def solve():
    N = Scanner.int()
    if N % 1000 == 0:
        print(0)
    else:
        print(1000 - N % 1000)


def main():
    # sys.setrecursionlimit(1000000)
    # sys.stdin = open("sample.txt")
    # T = Scanner.int()
    # for _ in range(T):
    #     solve()
    # print('YNeos'[not solve()::2])
    solve()


if __name__ == "__main__":
    main()


Measured memory_bytes: 10708
/*  -*- coding: utf-8 -*-
 *
 * 1577.cc: Courage Test
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int MAX_N = 100000;

/* typedef */

typedef vector<int> vi;

/* global variables */

vi nbrs[MAX_N];
int lvs[MAX_N], crs[MAX_N], ps[MAX_N];

/* subroutines */

inline int nextp(int u, int up) {
  vi &nbru = nbrs[u];
  int v0 = nbru[0];
  if (v0 != up) return v0;
  return (nbru.size() > 1) ? nbru[1] : -1;
}

inline int findbr(int u, int &l, int &up) {
  l = 0, up = -1;
  while (nbrs[u].size() <= 2) {
    int v = nextp(u, up);
    up = u, u = v;
    l++;
  }
  return u;
}

inline bool matchp(int p0, int p1, int p2, int p3, int u, int v) {
  return
    ((p0 == u || p1 == u) && (p2 == v || p3 == v)) ||
    ((p0 == v || p1 == v) && (p2 == u || p3 == u));
}

/* main */

int main() {
  int n, u, v;
  scanf("%d%d%d", &n, &u, &v);
  u--, v--;

  if (n & 1) { puts("No"); return 0; }
  int hn = n / 2;
  
  for (int i = 1; i < n; i++) {
    int a, b;
    scanf("%d%d", &a, &b);
    a--, b--;
    nbrs[a].push_back(b);
    nbrs[b].push_back(a);
  }

  int lvn = 0, crn = 0;
  for (int i = 0; i < n; i++) {
    int sz = nbrs[i].size();
    if (sz == 1) lvs[lvn++] = i;
    else if (sz == 3) crs[crn++] = i;

    if (sz > 3 || lvn > 4 || crn > 2) { puts("No"); return 0; }
  }
  //printf("lvn=%d, crn=%d\n", lvn, crn);

  if (lvn == 2) {
    ps[0] = lvs[0];
    for (int i = 1, up = -1; i < n; i++) {
      ps[i] = nextp(ps[i - 1], up);
      up = ps[i - 1];
    }
    //for (int i = 0; i < n; i++) printf("%d ", ps[i]); putchar('\n');

    if (matchp(ps[0], ps[hn - 1], ps[hn], ps[n - 1], u, v)) {
      puts("Yes");
      return 0;
    }
  }
  else if (lvn == 3) {
    int ls[3], brs[3], bps[3];
    for (int i = 0; i < 3; i++) {
      brs[i] = findbr(lvs[i], ls[i], bps[i]);
      //printf("%d: lv=%d, l=%d, br=%d, bp=%d\n",
      //i, lvs[i], ls[i], brs[i], bps[i]);
    }

    for (int i = 0; i < 3; i++)
      if (ls[i] == hn) {
	int i1 = (i + 1) % 3, i2 = (i + 2) % 3;
	if (matchp(lvs[i], bps[i], lvs[i1], lvs[i2], u, v)) {
	  puts("Yes");
	  return 0;
	}
      }
  }
  else { // lvn == 4
    int ls[4], brs[4], bps[4];
    for (int i = 0; i < 4; i++) {
      brs[i] = findbr(lvs[i], ls[i], bps[i]);
      //printf("%d: lv=%d, l=%d, br=%d, bp=%d\n",
      //i, lvs[i], ls[i], brs[i], bps[i]);
    }

    if (brs[0] != brs[1])
      for (int i = 2; i < 4; i++)
	if (brs[0] == brs[i]) {
	  swap(lvs[1], lvs[i]);
	  swap(ls[1], ls[i]);
	  swap(brs[1], brs[i]);
	  swap(bps[1], bps[i]);
	  break;
	}
    if (ls[0] + ls[1] == hn - 1 && ls[2] + ls[3] == hn - 1 &&
	matchp(lvs[0], lvs[1], lvs[2], lvs[3], u, v)) {
      puts("Yes");
      return 0;
    }
  }

  puts("No");
  return 0;
}



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

using namespace std;
using ll = long long;
using ull = unsigned long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
#define rep(i,n) for(ll i = 0;i < (ll)n;i++)
#define ALL(x) (x).begin(),(x).end()
#define FILLl(n,first_dimension_size,value) fill((ll*)n,(ll*)(n+first_dimension_size),value)
#define FILL(n,first_dimension_size,value) fill((int*)n,(int*)(n+first_dimension_size),value)
#define INF (1 << 30)
#define MOD 1000000007
//int dy[4] = {-1,0,0,1};
//int dx[4] = {0,1,-1,0};



int main(){
  
  int n,m;
  cin >> n >> m;
  vector<ll> h(n);
  rep(i,n)cin >> h[i];
  vector<vector<int>> v(n);
  rep(i,m){
    int a,b;cin >> a >> b;
    a--,b--;
    v[a].push_back(b);
    v[b].push_back(a);
  }
  ll res = 0;
  rep(i,n){
    bool is = true;
    for(auto nv : v[i]){
      if(h[nv] >= h[i])is  = false;
    }
    if(is)res++;
  }
  cout << res << endl;
  


  

  return 0;
}

Measured memory_bytes: 9068
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);
		while (true) {
			int H = scan.nextInt();
			int W = scan.nextInt();

			if ((H == 0) && (W == 0)) {
				break;
			}
			else {

				for (int i = 0; i < H; i++) {
					for (int j = 0; j < W; j++) {

						if ((i+j)%2==1) {
							System.out.print(".");
						}
						else if ((i+j)%2==0) {
							System.out.print("#");
						}
					}
					System.out.println();
				}
			}
			System.out.println();
		}

	}

}

Measured memory_bytes: 34956
n,m = map(int, input().split())
h = list(map(int, input().split()))
ans = [True for _ in range(n)]
for i in range(m):
    a,b = map(lambda z:int(z)-1,input().split())
    if h[a] >= h[b]:
        ans[b] = False
    if h[b]>=h[a]:
        ans[a] = False

print(sum(ans))

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

int main()
{
	int N{};
	cin >> N;
	
	vector<int> num(N);
	for (size_t i = 0;i < N;++i) {
		cin >> num.at(i);
	}
	bool flg = true;

	for (size_t i = 0;i < N;++i) {
		if (num.at(i) % 2 == 0) {
			if (num.at(i) % 3 != 0 && num.at(i) % 5 != 0) {
				flg = false;
			}
		}
	}
	if (flg) {
		cout << "APPROVED";
	}
	else {
		cout << "DENIED";
	}


}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;
#define NIL NULL

Node root;
int flag;

void search(Node u, int k){
  if(k == u->key){
    printf("yes\n");
    flag++;
  }
  if(k < u->key){
    if(u->left != NIL) search(u->left, k);
  }
  if(k > u->key){
    if(u->right != NIL)search(u->right, k);
  }
}

void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;

  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

  while(x != NIL){
    y = x;
    if(z->key < x->key) x = x->left;
    else x = x->right;
  }
  z->parent = y;
  if(y == NIL) root = z;
  else if(z->key < y->key) y->left = z;
  else y->right = z;
}

void inorder(Node u){
  if(u->left != NIL) inorder(u->left);
  printf(" %d", u->key);
  if(u->right != NIL) inorder(u->right);
}

void preorder(Node u){
  printf(" %d", u->key);
  if(u->left != NIL) preorder(u->left);
  if(u->right != NIL) preorder(u->right);
}


int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);
  root = NIL;

  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if ( com[0] == 'f' ){
      scanf("%d", &x);
      flag = 0;
      search(root, x);
      if(flag == 0) printf("no\n");
    } else if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    } else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }
  }
  return 0;
}

Measured memory_bytes: 19364
#include<bits/stdc++.h>
using namespace std;
 
int main(void){
    int stoneNum = 2000001;
    int k, x;cin >> k >> x;
    if (k == 1){
        cout << x << endl;
        return 0;
    }

    int start = x - (k - 1);
    int end = x + (k-1);

    while (start <= -1000000){
        start++;
    }

    while(end >= 1000000){
        end--;
    }

    for (int i=start;i<=end;i++){
        cout << i;
        
        if (i != end){
            cout << " ";
        }
    }

    return 0;
}

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

int main(){
  int a,b,c;
  cin >> a >> b >> c;
  if(a==b){
    cout << c << endl;
  }
  else if(b==c){
    cout << a << endl;
  }
  else{
    cout  << b << endl;
  }
}

Measured memory_bytes: 256
def solve(S, T):
    from bisect import bisect_right, bisect_left
    N = len(S)
    a = ord('a')
    S_ = S
    S = [ord(c)-a for c in S]
    T_ = T
    T = [ord(c)-a for c in T]
    index = [[] for i in range((ord('z')-ord('a')+1))]
    for i, c in enumerate(S):
        index[c].append(i)

    for t in T:
        if len(index[t]) == 0:
            return -1

    prev = T[0]
    prevIndex = index[prev][0]
    find = bisect_left
    offset = 0
    for i in range(1, len(T)):
        t = T[i]
        indexT = index[t]
        found = find(indexT, prevIndex+1)
        #print(offset, "%d:'%c'"%(i,T_[i]), "prevIndex=%d:'%c'"%(prevIndex, S_[prevIndex]), "found=%d/%d"%(found,len(indexT)), indexT)
        if found== len(indexT):
            prevIndex = indexT[0]
            offset += 1
        else:
            prevIndex = indexT[found]
        #print("%d:%c"%(i, T_[i]), offset, prevIndex)

    #print(offset, prevIndex, N, offset*N+prevIndex+1)
    return offset*N+prevIndex+1

S = input().strip()
T = input().strip()

print(solve(S, T))


Measured memory_bytes: 9196
#define _CRT_SECURE_NO_WARNINGS
//#define DEBUG
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>

int main(void) {
#ifdef DEBUG
	printf("");
#endif

	int N;
	int a[100];
	int tmp;
	int sum=0,sum2=0;
	int ans=-1;
	int i=0,j=0;

	scanf("%d", &N);
	for (i = 0; i < N; i++) {
		scanf("%d", &a[i]);
		sum += a[i];
		sum2 += a[i] * a[i];
	}

	for (i = 0; i < N-1; i++) {
		if (a[i] != a[i + 1]) {
			break;
		}
		if (i == N - 2) {
			printf("0\n");
			return 0;
		}
	}

	for (i = -100; i <= 100; i++) {
		tmp = i*(N*i - 2 * sum)+sum2;
		if (ans == -1) {
			ans = tmp;
		}
		else {
			if (ans > tmp) {
				ans = tmp;
			}
		}
	}
	printf("%d\n",ans);

	return 0;
}

Measured memory_bytes: 128
import java.util.*;
import java.io.*;

public class Main{
	public static int[] solve(int n){
		int[] ans = new int[2];
		ans[0] = n; ans[1] = n;
		if( n%2 == 0 ){
			ans[0] = n-1;
			ans[1] = n+1;
		} else if( n == 3 ){
			ans[0] = 2;
			ans[1] = 5;
			return ans;
		} else {
			ans[0] = n-2;
			ans[1] = n+2;
		}
		for(int i = 3; i <= Math.sqrt(ans[0]); i += 2){
			if( ans[0]%i == 0 ){
				ans[0] -= 2;
				i = 1;
			}
		}
		for(int i = 3; i <= Math.sqrt(ans[1]); i += 2){
			if( ans[1]%i == 0 ){
				ans[1] += 2;
				i = 1;
			}
		}
		return ans;
	}
		
	public static void main(String[] args) throws IOException{
		Scanner stdIn = null;
		List<int[]> result = new ArrayList<int[]>();
		
		try{
			stdIn = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
			
			while( stdIn.hasNext() ){
				int n = stdIn.nextInt();
				int[] ans = solve(n);
				result.add(ans);
			}
			for(int[] list : result){
				System.out.println(list[0] + " " + list[1]);
			}
		} finally {
			if( stdIn != null ){
				stdIn.close();
			}
		}
	}
}

Measured memory_bytes: 12000
#include<bits/stdc++.h>
using namespace std;
#define gc getchar
#define gcu getchar_unlocked
#define pc(x) putchar(x);
#define pcu(x) putchar_unlocked(x);
#define ll long long int
#define SPEED ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

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

void readint(ll &x)
    {
        bool neg=false;
        ll c;
        x =0;
        c=gc();
        if(c=='-')
        {
            neg = true;
            c=gc();
        }
        for(;(c>47 && c<58);c=gc())
            x = (x<<1) + (x<<3) +c -48;
        if(neg)
            x *=-1;
    }

inline void writeInt (ll n)
{
    ll N = n, rev, count = 0;
    rev = N;
    if (N == 0) { pc('0'); pc('\n'); return ;}
    if (N*(-1)>0){pc('-');rev=rev*(-1);N=N*(-1);}
    while ((rev % 10) == 0) { count++; rev /= 10;}
    rev = 0;
    while (N != 0) { rev = (rev<<3) + (rev<<1) + N % 10; N /= 10;}
    while (rev != 0) { pc(rev % 10 + '0'); rev /= 10;}
    while (count--) pc('0');
}
int main()
{
  SPEED;
  int n,k,i,s=0;
  cin>>n>>k;
  for(i=n;i>n-k;i--)
  {
      s=s+(i/k);
  }
  cout<<s<<"\n";
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

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

		while(true) {
			int m=sc.nextInt(),f=sc.nextInt(),r=sc.nextInt();
			if(m==-1 && f==-1 && r==-1) {
				break;
			}
			int sum=m+f;
			if((m==-1 || f==-1)  || sum<30) {
				System.out.println("F");
			}else if(sum>=80) {
				System.out.println("A");
			}else if(sum>= 65 && sum<80){
				System.out.println("B");
			}else if(sum>=50 && sum<65 || r>=50) {
				System.out.println("C");
			}else  {
				System.out.println("D");
			}
		}
	}
}


Measured memory_bytes: 26380
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
typedef long long ll;
namespace mp = boost::multiprecision;
using Mint = mp::cpp_int;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i = int(a); i < int(b); i++)
#define all(v) v.begin(), v.end()
#define uni(v) v.erase(unique(all(v)), v.end())
#define sort_g(v) sort(all(v), greater<int>())
#define dump(x) cerr << #x << ' ' << '=' << ' ' << x << endl

int main() {
    int X, A;
    cin >> X >> A;
    cout << (X < A ? 0 : 10) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, b) for (int i = a; i < (b); i++)
#define rrep(i, a, b) for (int i = a; i >= b; i--)
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
template <class T>
inline bool chmin(T& a, T b) {
   if (a > b) {
      a = b;
      return true;
   }
   return false;
}
template <class T>
inline bool chmax(T& a, T b) {
   if (a < b) {
      a = b;
      return true;
   }
   return false;
}

const int INF = 1 << 20;
const int MOD = 1e9 + 7;

int main() {
   string s;
   cin >> s;
   int ans = 1000;
   rep(i, 0, s.size() - 2) {
      int num = (s[i] - '0') * 100 + (s[i + 1] - '0') * 10 + (s[i + 2] - '0');
      ans = min(ans, abs(num - 753));
   }
   cout << ans << endl;
   return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
using namespace std;
//typedef __int64 LL;
typedef long long int LL;
typedef vector<int> ivec;
typedef vector<string> svec;

const int MOD=1000000007;

LL gcd(LL x,LL y)
{
	if(x==0)return y;
	else if(y==0)return x;
	else if(x>y)return gcd(x%y,y);
	return gcd(x,y%x);
}
int main(){
	LL a,b;cin>>a>>b;
	LL g=gcd(a,b);
	
	int ans=0;
	for(LL i=2;i*i<=g;i++)
	{
		if(g%i!=0)continue;
		while(g%i==0)
		{
			g/=i;
		}
		ans++;
	}
	if(g!=1)ans++;
	cout<<ans+1<<"\n";
	return 0;
}

Measured memory_bytes: 256
n = int(input())
h = list(map(int, input().split()))
cnt = 0
mx = 0
for i in range(n-1) :
    if h[i+1] <= h[i] :
        cnt += 1
    else :
        mx = max(mx, cnt)
        cnt = 0
mx = max(mx, cnt)
print(mx)


Measured memory_bytes: 20560
#include <iostream>

using namespace std;

int p[100+10][100+10];
int n,a,b,c;

int main(){
	cin >> n;
	for (int i=1; i<=n; i++){
		cin >> a >> b;
		for (int j=1; j<=b; j++){
			cin >> c;
			p[a][c] = 1;
		}
	}
	
	for (int i=1; i<=n; i++){
		for (int j=1; j<=n; j++){
			if (j>1) {cout << ' ';}
			cout << p[i][j];
		}
		cout << endl;
	}
}

Measured memory_bytes: 3120
#include <cstdio>

int main() {
  char n[4];
  scanf("%s", n);
  for (int i = 0; i < 3; ++i)
    if (n[i] == '1') {
      n[i] = '9';
    } else if (n[i] == '9') {
      n[i] = '1';
    }
  printf("%s\n", n);
}

Measured memory_bytes: 128
N,M,X = map(int,input().split())

CA = [list(map(int,input().split())) for i in range(0,N,1)]

minC = 10000000

for i in range(0,pow(2,N),1):
    C = 0
    A = [0 for i in range(0,M+1,1)]
    for j in range(N):
        if((i>>j)&1):
            for k in range(1,M+1,1):
                A[k]+= CA[j][k]
            C += CA[j][0]
    flag = False
    for k in range(1,M+1,1):
        if A[k] < X:
            flag = True
    if flag:
        continue

    if C < minC:
        minC = C

if minC != 10000000:
    print(minC)
else:
    print(-1)

Measured memory_bytes: 68660
#include<bits/stdc++.h>
#define X first
#define Y second
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pll;
const ll N = 5005, M = 205;

ll n, m, a[N], b[N][M], v[M], ans;

struct maxtree {
	ll v[4*N], lim;
	void init (ll P) {
		for(lim=1;lim<=n;lim<<=1);
		for(ll i=1;i<=n;i++) v[lim+i] = b[i][P];
		for(ll i=lim;--i;) v[i] = max(v[2*i], v[2*i+1]);
	}
	ll get (ll S, ll E) {
		ll R = 0; S += lim; E += lim;
		while(S<=E) {
			if(S%2==1) {R = max(R, v[S]); S++;}
			if(E%2==0) {R = max(R, v[E]); E--;}
			S >>= 1; E >>= 1;
		}
		return R;
	}
} seg[M];

void solve (ll S, ll E, ll L, ll R) {
	ll I = (S+E)/2, V = 0, T = max(L, I);
	for(ll i=1;i<=m;i++) {
		v[i] = seg[i].get(I, T);
		V += v[i];
	}
	pll O = pll(V-a[T]+a[I], T);
	for(ll i=T+1;i<=R;i++) {
		V = 0;
		for(ll j=1;j<=m;j++) {
			v[j] = max(v[j], b[i][j]);
			V += v[j];
		}
		O = max(O, pll(V-a[i]+a[I], i));
	}
	ans = max(ans, O.X);
	if(S == E) return;
	solve(S, I, L, O.Y);
	solve(I+1, E, O.Y, R);
}

int main()
{
	scanf("%lld%lld",&n,&m);
	for(ll i=2;i<=n;i++) {
		scanf("%lld",&a[i]); a[i] += a[i-1];
	}
	for(ll i=1;i<=n;i++) for(ll j=1;j<=m;j++) {
		scanf("%lld",&b[i][j]);
	}
	for(ll i=1;i<=m;i++) seg[i].init(i);
	solve(1, n, 1, n);
	printf("%lld\n",ans);
}


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

#define PI 3.14159265359

int main(){
  int N;
  cin >> N;
  int64_t ans = 0;
  for (int i = 1; i < N; i++){
    ans += (N - 1) / i;
  }
  cout << ans << endl;
}


Measured memory_bytes: 3632
#include <cstdio>
#include <cmath>
#include <cstring>
#include <algorithm>
using namespace std;

char s[55];

int main()
{
	scanf ("%s", s);
	int len = strlen(s);
	for (int i = 0; i <= len - 9; i++)	printf ("%c", s[i]);
	printf ("\n");
}

Measured memory_bytes: 128
//21, 07, 2018, 09:57:26 Rafaelcs cpp
#include <bits/stdc++.h>

using namespace std;
typedef pair<int, int> pii;
typedef long double ld;
typedef long long ll;

typedef unsigned long long ull;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    
    string s, t;

    cin >> s >> t;

    int n = s.length();

    for(int i = 0 ; i < n ; i++){
        bool ok = true;

        for(int j = 0 ; j < n ; j++){
            int p = (i + j) % n;

            if(s[p] != t[j]){
                ok = false;
                break;
            }
        }

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

    cout << "No" << endl;
    
    return 0;
}

Measured memory_bytes: 256
using System;
class Program
{
  static void Main(string[] args)
  {
    string[] line = Console.ReadLine().Split(' ');
    int a = int.Parse(line[0]);
    int b = int.Parse(line[1]);
    int c = b - a;
    for(int i = 1; i <= a + (a - 1); i++)
    {
    Console.WriteLine(c + i);
    }
  }
}


Measured memory_bytes: 13140
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define each(a,x) for(auto a : (x))
#define all(a) (a).begin(),(a).end()
#define chmin(a,b) ((a) = min((a),(b)))
#define chmax(a,b) ((a) = max((a),(b)))
#define in_range(x,l,r) ((l)<=(x) && (x)<(r))
#define printvec(a) rep(i,a) cout << a[i] << " \n"[i+1==(a).size()];
#define fs first
#define sc second
#define em emplace
#define eb emplace_back
#define sz size()
#define MP make_pair
using namespace std;
typedef long long ll;
typedef double D;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<string> vs;

const ll INF = 1e8;
const D EPS = 1e-8;
const ll MOD = 1e9+7;

int main(){
  int l=0, r, d=0, u, n;
  cin >> r >> u >> n;
  rep(i,n){
    int x,y,a;
    cin >> x >> y >> a;
    if(a==1) chmax(l,x);
    else if(a==2) chmin(r,x);
    else if(a==3) chmax(d,y);
    else chmin(u,y);
  }
  if(r-l < 0 or u-d < 0) cout << 0 << endl;
  else cout << (r-l) * (u-d) << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <functional>
#include <set>
#include <queue>
#include <cctype>
#include <climits>
#include <stack>
using namespace std;

//?§??????°??????????????°?????¶????????????????????°
int n,m,h,k;

//???????§???????????§????1day???????????°
int s,t,p;

typedef pair<int,int> P;
typedef pair<P,int> PP;
struct edge{
	int to,cost,time,corp;
	
	edge(int to_,int cost_,int time_,int corp_){
		to=to_; cost=cost_; time=time_; corp=corp_;
	}
	
};
vector<edge> G[100];

const int BIT=1<<8;

// i????????????????????????????????????
int pass_corps[BIT];

// pass_cost[bit] bit?????¨?????????????????????????????????
int pass_cost[BIT];

//corps_cost[bit] bit?????¨???corps??????????????????1day??????????????????
int corps_cost[BIT];

const int INF=1e8;

int solve(int use){
	
	// d[time][pos]
	int d[25][BIT];
	for(int i=0;i<25;i++){
		for(int j=0;j<BIT;j++) d[i][j]=INF;
	}
	
	d[0][s]=corps_cost[use];
	priority_queue<PP,vector<PP>,greater<PP> > q;
	
	// cost,time,pos
	q.push(PP(P(corps_cost[use],0),s));
	while(!q.empty()){
		
		PP pp=q.top(); q.pop();
		
		int cost=pp.first.first,time=pp.first.second,pos=pp.second;
		
		//printf("cost %d, time %d, pos %d\n",cost,time,pos);
		
		if(pos==t) return cost;
		
		if(d[time][pos]<cost) continue;
		
		for(int i=0;i<G[pos].size();i++){
			edge e=G[pos][i];
			int to=e.to,ncost=cost+e.cost,nt=time+e.time,ncorp=e.corp;
			
			//printf("to %d, ncost %d, nt %d ncorp %d\n",to,ncost,nt,ncorp);
			
			if(nt>h) continue;
			
			if(use&(1<<ncorp)) ncost=cost;
			if(ncost<d[nt][to]){
				d[nt][to]=ncost;
				q.push(PP(P(ncost,nt),to));
			}
			
		}
		
	}
	
	return INF;
	
}

int main(){
	
	while(scanf("%d %d %d %d",&n,&m,&h,&k),n){
		
		for(int i=0;i<100;i++) G[i].clear();
		for(int i=0;i<BIT;i++){
			pass_corps[i]=0;
			pass_cost[i]=corps_cost[i]=INF;
		}
		for(int i=0;i<m;i++){
			int a,b,c,h,r;
			scanf("%d %d %d %d %d",&a,&b,&c,&h,&r);
			a--; b--; r--;
			
			G[a].push_back(edge(b,c,h,r));
			G[b].push_back(edge(a,c,h,r));
		}
		
		scanf("%d %d %d",&s,&t,&p);
		s--; t--;
		
		for(int i=0;i<p;i++){
			int l,d,corp;
			scanf("%d %d",&l,&d);
			
			int corps=0;
			for(int j=0;j<l;j++){
				scanf("%d",&corp);
				corp--;
				corps|=(1<<corp);
			}
			
			pass_corps[i]=corps;
			pass_cost[corps]=d;
		}
				
		//corps_cost[bit] bit?????¨???corps??????????????????1day??????????????????
		corps_cost[0]=0;
		for(int i=0;i<(1<<k);i++){
			if(corps_cost[i]==INF) continue;
			for(int j=0;j<p;j++){
				corps_cost[i|pass_corps[j]]=min(corps_cost[i|pass_corps[j]],corps_cost[i]+pass_cost[pass_corps[j]]);
			}
		}
		
		int res=INF;
		for(int use=0;use<(1<<k);use++){
			if(corps_cost[use]==INF) continue;
			res=min(res,solve(use));
		}
		if(res==INF) res=-1;
		cout<<res<<endl;	
	}
}

Measured memory_bytes: 1412
N = 1000000007

def fac(n,r,N):
    ans=1
    for i in range(r):
        ans=ans*(n-i)%N
    return ans

def combi(n,r,N):
    r= min(r, n-r)
    ans = fac(n,r,N)*pow(fac(r,r,N),N-2,N)%N
    return ans

n,a,b = map(int, input().split())
ans = pow(2,n,N)-combi(n,a,N)-combi(n,b,N)-1
if ans<0:
    ans+=N
if ans<0:
    ans+=N
print(ans)


Measured memory_bytes: 3064
A,B = map(int, input().split())
count = 0
for i in range(4,A+1):
  for j in range(22,B+1):
    C = str(j)
    if i == int(C[0])*int(C[1]) and int(C[1]) > 1:
      count = count + 1
print(count)



Measured memory_bytes: 2940
#include<cstdio>
#include<cstring>
#include<cctype>
#include<cmath>
#include<algorithm>
#define ll long long
using namespace std;
int read()
{
    char c;int s=0,t=1;
    while(!isdigit(c=getchar()))if(c=='-')t=-1;
    do{s=s*10+c-'0';}while(isdigit(c=getchar()));
    return s*t;
}
/*------------------------------------------------------------*/
const int inf=0x3f3f3f3f;

int n;
char s[1000];
int main()
{
    scanf("%s",s+1);
    int n=strlen(s+1);
    int ans=inf;
    for(int i=0;i<=25;i++)
    {
    	char x='a'+i;
    	int tot=0,anss=0;
    	for(int j=1;j<=n;j++)
    	{
    		if(s[j]!=x)tot++;else tot=0;
    		anss=max(tot,anss);
    	}
    	ans=min(ans,anss);
    }
    printf("%d",ans);
    return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
vector<ll> node1[400005],node2[400005];
vector<P> son_node[400005];
ll count_[400005]={0},par[400005]={0},node_num[400005]={0},color[400005]={0};
bool used[400005]={0};
void set_root(ll pos){
  used[pos]=true;
  for(int i=0;i<node1[pos].size();i++){
    ll to=node1[pos][i];
    if(!used[to]){
      used[to]=true;
      node2[pos].push_back(to);
      set_root(to);
    }
  }
}
void get_color_graph(ll pos){
  ll col=color[pos];
  ll initial_par=par[col],initial_nnum=node_num[col];
  son_node[initial_par].push_back(P(initial_nnum,pos));
  par[col]=pos;
  for(int i=0;i<node2[pos].size();i++){
    ll to=node2[pos][i];
    node_num[col]=i;
    get_color_graph(to);
  }
  par[col]=initial_par;
  node_num[col]=initial_nnum;
}
ll count_dfs(ll pos){
  count_[pos]=1;
  for(int i=0;i<node2[pos].size();i++){
    ll to=node2[pos][i];
    count_[pos]+=count_dfs(to);
  }
  return count_[pos];
}
ll get_answer(ll pos){
  ll son_num=0;
  ll res=0;
  for(int i=0;i<node2[pos].size();i++){
    ll to=node2[pos][i];
    ll num=count_[to];
    while(son_num<son_node[pos].size()&&son_node[pos][son_num].first==i){
      ll son=son_node[pos][son_num].second;
      res+=get_answer(son);
      num-=count_[son];
      son_num++;
    }
    res+=num;
    res+=num*(num-1)/2;
  }
  return res;
}
int main(){
  ll n;
  cin>>n;
  for(int i=1;i<=n;i++) cin>>color[i];
  for(int i=1;i<n;i++){
    ll s,t;
    cin>>s>>t;
    node1[s].push_back(t);
    node1[t].push_back(s);
  }
  for(int i=1;i<=n;i++) used[i]=false;
  set_root(1);
  for(int i=n+1;i<=n*2;i++) par[i-n]=i;
  get_color_graph(1);
  count_dfs(1);


  for(int i=n+1;i<=n*2;i++){
    node2[i].push_back(1);
    ll first_ans=n*(n-1)/2;
    first_ans+=n;
    cout<<first_ans-get_answer(i)<<endl;
  }
}


Measured memory_bytes: 85032
n, m, x = map(int, input().split())
a = list(map(int, input().split()))
pr = 0 ; pl = 0
for i in range(x,n+1) :
    if i in a :
        pr += 1
for j in range(x,-1,-1) :
    if j in a :
        pl += 1
mn = min(pr, pl)
print(mn)


Measured memory_bytes: 9180
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <math.h>
#define MOD 1000000007
typedef long long ll;
using namespace std;

const int N=100010;

ll inv[N+30],fac[N+30],ifac[N+30];

int main(){
  int n;
  ll m;
  cin>>n>>m;

  inv[0]=1;inv[1]=1;fac[1]=1;ifac[1]=1;fac[0]=1;ifac[0]=1;
  for(int i=2;i<=n+30;i++){
    inv[i]=(-MOD/i)*inv[MOD%i]%MOD;
    fac[i]=fac[i-1]*i%MOD;
    ifac[i]=ifac[i-1]*inv[i]%MOD;
    //cout<<inv[i]<<" "<<fac[i]<<" "<<ifac[i]<<endl;
  }

  vector<pair<int,int>> prime;
  ll tmp=m;
  for(int i=2;i*i<=m;i++){
    if(i!=2&&i%2==0) continue;
    if(tmp%i==0){
      //prime.push_back(i);
      int p=0;
      while(tmp%i==0){
        tmp/=i;
        p++;
      }
      prime.push_back(make_pair(i,p));
    }
    if(tmp==1) break;
  }
  if(tmp!=1) prime.push_back(make_pair(tmp,1));

  ll ans=1;
  for(int i=0;i<prime.size();i++){
    int x=prime[i].second;
    ans=(ans*fac[x+n-1]%MOD*ifac[x]%MOD*ifac[n-1])%MOD;
  }
  cout<<(ans+MOD)%MOD<<endl;

  return 0;
}


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

int selectionSort (int A[], int N){
  int i,j,t,sw =0,minj;
  for (i = 0; i < N-1; i++){ //A[i]が未ソート部分の先頭
    minj =i;
    for( j= i; j < N; j++){
      if(A[j] < A[minj]){
        minj = j;
      }
    }
    swap(A[i], A[minj]);
    if(i != minj)sw++;
  }
  return sw;  
}

int main(){
  int N;
  cin >> N;
  int A[110];
  for(int i = 0; i <N; i++) cin >> A[i];
  
  int sw = 0;
  sw = selectionSort(A,N);
  
  for(int i = 0; i < N ; i++){
    cout << A[i];
    if(i != N-1) cout << " ";
  }
  cout << endl;
  cout << sw << endl;
}


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

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

	int q, com, x;
	string key, L, R;
	map<string, int> my_map;
	map<string, int>::iterator it1, it2, it;

	cin >> q;
	while (q--) {
		cin >> com >> key;
		switch (com) {
			case 0:
				cin >> x;
				if (my_map.end() != my_map.find(key)) {
					my_map.erase(key);
				}
				my_map.insert(make_pair(key, x));
				break;
			case 1:
				it = my_map.find(key);
				if (it != my_map.end()) {
					cout << it->second << endl;
				} else {
					cout << 0 << endl;
				}
				break;
			case 2:
				// it = my_map.find(key);
				my_map.erase(key);
				break;
			case 3:
				L = key;
				cin >> R;
				it1 = my_map.lower_bound(L);
				it2 = my_map.upper_bound(R);
				for (it = it1; it != it2; it++) {
					cout << it->first << " " << it->second << endl;
				}
				break;
		}
	}
}


Measured memory_bytes: 25860
import java.util.Scanner;

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

        System.out.println(
            Integer.parseInt(s.substring(0, 1))
                + Integer.parseInt(s.substring(1, 2))
                + Integer.parseInt(s.substring(2, 3))
        );

    }
}


Measured memory_bytes: 21588
# AOJ 0104 Magical Tiles
# Python3 2018.6.17 bal4u

while True:
	h, w = list(map(int, input().split()))
	if h == 0: break

	a = [0]*h
	for r in range(h): a[r] = list(input())
	r = c = 0
	while True:
		k = a[r][c]
		a[r][c] = '#'
		if k == '#':
			print('LOOP')
			break
		elif k == '>': c += 1
		elif k == '<': c -= 1
		elif k == '^': r -= 1
		elif k == 'v': r += 1
		elif k == '.':
			print(c, r)
			break


Measured memory_bytes: 5684
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#ifdef ENABLE_DEBUG
#define dump(a) cerr<<#a<<"="<<a<<endl
#define dumparr(a,n) cerr<<#a<<"["<<n<<"]="<<a[n]<<endl
#else
#define dump(a) 
#define dumparr(a,n) 
#endif
#define FOR(i, a, b) for(ll i = (ll)a;i < (ll)b;i++)
#define For(i, a) FOR(i, 0, a)
#define REV(i, a, b) for(ll i = (ll)b-1LL;i >= (ll)a;i--)
#define Rev(i, a) REV(i, 0, a)
#define REP(a) For(i, a)
#define SIGN(a) (a==0?0:(a>0?1:-1))

typedef long long int ll;
typedef unsigned long long ull;
typedef unsigned int uint;
typedef pair<ll, ll> pll;
typedef pair<ll,pll> ppll;
typedef vector<ll> vll;
typedef long double ld;
typedef pair<ld,ld> pdd;

const ll INF=(1LL<<60);
#if __cplusplus<201700L
ll gcd(ll a, ll b) {
  a=abs(a);
  b=abs(b);
  if(a==0)return b;
  if(b==0)return a;
  if(a < b) return gcd(b, a);
  ll r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}
#endif
template<class T>
bool chmax(T& a,const T& b){
  if(a<b){
    a=b;
    return true;
  }
  return false;
}
template<class T>
bool chmin(T& a,const T& b){
  if(a>b){
    a=b;
    return true;
  }
  return false;
}
template<class S,class T>
std::ostream& operator<<(std::ostream& os,pair<S,T> a){
  os << "(" << a.first << "," << a.second << ")";
  return os;
}
template<class T>
std::ostream& operator<<(std::ostream& os,vector<T> a){
  os << "[ ";
  REP(a.size()){
    os<< a[i] << " ";
  }
  os<< " ]";
  return os;
}


void solve(std::vector<long long> H, std::vector<long long> M, long long K){
  cout<<(H[1]-H[0])*60+M[1]-M[0]-K<<endl;
}

int main(){
  cout<<setprecision(1000);
    std::vector<long long> H(2);
    std::vector<long long> M(2);
    for(int i = 0 ; i < 2 ; i++){
        scanf("%lld",&H[i]);
        scanf("%lld",&M[i]);
    }
    long long K;
    scanf("%lld",&K);
    solve(std::move(H), std::move(M), K);
    return 0;
}


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

int main(){
    int N, K;
    cin >> N >> K;
    
    int ans = 0;
    for(int i = 0; i < N; i++){
        int t;
        cin >> t;
        if(t >= K){
            ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256