akhauriyash/Code-Regression huggingface dataset:
#include<iostream>

using namespace std;
   
void Simultaneous()
{
    double a, b, c, d, e, f;
    double x, y;
      
    while(cin>>a>>b>>c>>d>>e>>f)  
    {
        x = ( c * e - b * f ) / ( a * e - b * d );
        y = ( a * f - c * d ) / ( a * e - b * d );
        
        cout.setf(ios::fixed); //"setf" is used for “half-adjusting”
        cout.precision(3); //precision is used for rould off three places of decimals
        
        //if value is 0, and there is half-adjusting function below, then the output would be "-0", needs to change it to "0"
        if(x == 0)
        {
            x = 0;
        }
        
        if(y == 0)
        {
            y = 0;
        }
        
        cout<<x<<" "<<y<<endl;
    }
            
    return;
}
     
int main()
{     
    Simultaneous();
    return 0;
}

Measured memory_bytes: 1284
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#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 fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()

int main(void){
    ll n, k;
    string s;

    cin >> n >> k;
    cin >> s;

    ll a = 0, b = 0, c = 0;
    rep(i, 0, n-1){
        if(s[i] == s[i+1]){
            a++;
        }else if(s[i] == 'R' && s[i+1] == 'L'){
            b++;
        }else{
            c++;
        }
    }

    if(k <= min(b, c)){
        a += k * 2;
    }else{
        a += min(b, c) * 2;
        if(b != c)
            a += 1;
    }
    cout << a << endl;
    return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;   
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
                       
#define pb push_back   
#define PII pair<int,int>    
                       
#define VS vector<string>    
#define VI vector<int> 
#define ll long long int
#define debug(x) cout << x << " :" <<#x << endl  
int main(void) {       
    int a,b,c,d;       
    cin >> a >> b >> c >> d; 
    if(a + b > c + d) {
      cout << "Left" << endl;
    } else if (a + b == c + d) {
      cout << "Balanced" <<endl;                                                                                             
    } else {           
      cout << "Right" << endl;
    }                  
}

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

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    
    int a,b,c;
    cin>>a>>b>>c;
    if(a+b>=c)
    {
    	cout<<"Yes\n";
    }
    else
    {
    	cout<<"No\n";
    }
    
    return 0;
}



Measured memory_bytes: 3648
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int x = sc.nextInt();
    
    long ans = 0;
    /*
    int prev = sc.nextInt();
    if (prev > x) {
      int diff = prev - x;
      ans += diff;
      prev -= diff;
    }
    */
    int prev = 0;
    for (int i = 1; i <= N; i++) {
      int a = sc.nextInt();
      if (prev+a >= x) {
        int diff = prev+a - x;
        ans += diff;
        prev = a - diff;
      } else {
        prev = a;
      }
    }
    
    System.out.println(ans);
  }
}

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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef vector<ll> Vector;
typedef vector<vector<ll>> DVector;

#define fi          first
#define se          second
#define pb          push_back
#define INF         INT_MAX/3
#define bcnt        __builtin_popcount
#define all(x)      (x).begin(),(x).end()
#define dbg(x)      cout<<#x"="<<x<<endl
#define ub(x,y)     upper_bound(all(x),y)-x.begin()
#define lb(x,y)     lower_bound(all(x),y)-x.begin()
#define uni(x)      x.erase(unique(all(x)),x.end())
#define rep(i,n)    repl(i,0,n-1)
#define repl(i,a,b) for(ll i=(ll)(a);i<=(ll)(b);i++)
#define mmax(x,y)   (x>y?x:y)
#define mmin(x,y)   (x<y?x:y)
#define maxch(x,y)  x=mmax(x,y)
#define minch(x,y)  x=mmin(x,y)
#define exist(x,y)  (find(all(x),y)!=x.end())
#define each(itr,v) for(auto itr:v)
#define usort(x)    sort(all(x))
#define dsort(x)    sort(all(x),greater<int>())
#define mkp(x,y)    make_pair(x,y)
int n;
Vector a,b,c;
int main(){
  cin.sync_with_stdio(false);
  cin >> n;
  a.resize(n);
  b.resize(n);
  c.resize(n);
  rep(i,n)cin>>a[i];
  rep(i,n)cin>>b[i];
  rep(i,n)cin>>c[i];
  usort(a);
  usort(b);
  usort(c);
  ll ans = 0;
  Vector dp(n);
  for(int i=n-1;i>=0;i--){
    auto itc = ub(c, b[i]);
    if(itc >= n)dp[i]=0;
    else if(i == n-1)dp[i] = n-itc;
    else dp[i] = (n-itc)+dp[i+1];
  }

  each(ita, a) {
    auto itb = ub(b,ita);
    if(itb >= n)break;
    ans += dp[itb];
  }

  cout << ans << endl;
}


Measured memory_bytes: 3456
import java.io.*;
import java.util.Arrays;
class Main{
    public static void main(String[] args) throws IOException {
        int i;
        int[] n = new int[990];
        String str;
        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        str = in.readLine();
        char[] c = str.toCharArray();
        for(i=0;i<c.length;i++){
            if(Character.isUpperCase(c[i])){
                c[i] = Character.toLowerCase(c[i]);
            }
            else if(Character.isLowerCase(c[i])){
                c[i] = Character.toUpperCase(c[i]);
            }
        }
        System.out.println(c);   
        System.out.flush();
    }
}

Measured memory_bytes: 24160
#include <stdio.h>

int main(void)
{
	int k;
	int x;
	int min;
	int max;
	int i;
	
	scanf("%d",&k);
	scanf("%d",&x);
	
	min = x - k + 1;
	max = k + x - 1;
	
	for (i = min;i <= max;i++){
		printf("%d ",i);
	}
	
	return(0);
}

Measured memory_bytes: 128
# E - Flatten

n = int(input())
a = list(map(int, input().split()))
assert len(a) == n

modulus = 10 ** 9 + 7
binmod = (bin(modulus - 2))[2:]  # modulus - 2 in binary

MAX = 10 ** 6

primefact = [0 for i in range(MAX + 1)]

def sieve():
    # cf. https://www.geeksforgeeks.org/lcm-of-n-numbers-modulo-m/
    for i in range(2, MAX + 1):
        if primefact[i] == 0:
            for j in range(i, MAX + 1, i):
                if primefact[j] == 0:
                    primefact[j] = i

def factorize(x):
    if primefact[2] == 0:
        sieve()

    vec = {}
    while x >= 2:
        d = primefact[x]
        if d not in vec:
            vec[d] = 0
        vec[d] += 1
        x //= d
    return vec

def value(x):
    p = 1
    for i in x:
        p = (p * (i ** x[i])) % modulus
    return p

def inverse(x):
    p = 1
    for b in binmod:
        p = p * p % modulus
        if b == '1':
            p = p * x % modulus
    return p

def div(n, d):
    return n * inverse(d) % modulus

fact = [factorize(x) for x in a]

fset = set()
for f in fact:
    fset.update(f.keys())

l = {k: 0 for k in fset}
for f in fact:
    for k in f:
        l[k] = max(l[k], f[k])
lcm = value(l)

s = sum(div(lcm, x) for x in a) % modulus
print(s)


Measured memory_bytes: 114800
import sys
import math
import itertools
import bisect
from copy import copy,deepcopy
from collections import deque,Counter
from decimal import Decimal
def s(): return input()
def i(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def L(): return list(map(int,input().split()))
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 9)
INF = 10**9
mod = 10**9+7

N = i()
S = [i() for _ in range(N)]
S.sort()
ans = sum(S)
num = 0
for i in range(N):
    if S[i]%10 != 0:
        num = S[i]
        break
if ans%10 == 0:
    ans = ans-num
if ans%10 == 0:
    ans = 0
print(ans)

Measured memory_bytes: 77424
#include <iostream>
#include <string>
#include <cmath>
#include <queue>
#include <map>
#include <set>
#include <list>
#include <iomanip>
#include <vector>
#include <functional>
#include <algorithm>
#include <cstdio>
#include <random>
#include <ctime>
#include <cstdlib>
#include <unordered_map>
#include <string.h>
#include <iostream>

using namespace std;
typedef long long ll;
typedef pair<int, int> Pint;
typedef pair<ll, ll> Pll;
#define rep(begin, i, end) for (int i = begin; i < (int)(end); i++)
#define all(v) v.begin(), v.end()
const int MOD = 1000000007;

int main()
{
    int N, A, B;
    cin >> N >> A >> B;
    int ans = 0;
    for (int i = 1; i <= N; i++)
    {
        int a = i;
        int sum = 0;
        while (a != 0)
        {
            sum += a % 10;
            a /= 10;
        }
        if (A <= sum && sum <= B)
        {
            ans += i;
        }
    }
    cout << ans << endl;
}

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

int main(){
  int n,m;
  cin >> n >> m;
  int sum=0;
  for(int i=0; i < m; i++){
    int temp;
    cin >> temp;
    sum+=temp;
  }
  if(sum>n){
    cout << -1;
  }
  else{
    cout << n-sum;
  }
}

Measured memory_bytes: 3592
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define MOD 1000000007
#define all(ppp) ppp.begin(),ppp.end()
#define out(ppp) cout<<(ppp)<<endl
#define out1(ppp) cout<<(ppp) 
#define MAX_CHAR 256

#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
#define pb push_back

typedef long double ld;
typedef complex<ld> cd;
 
typedef pair<int, int> pi;
typedef pair<double, double> pd;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pld;
 
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<vi> vvi;
typedef vector<bool> vb;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pd> vpd;
typedef vector<pl> vpl;
typedef vector<cd> vcd;
typedef vector<vpi> vvpi;

typedef set<pi> spi;

const int INF=INT_MAX;
ll x,y;
ll inv[10000100];
ll FactorialInv[10000100];
ll Factorial[10000100];

ll mymod(ll a,ll b){
    a%=MOD;
    ll result=1;
    while(b>0){
        if(b&1){
            result=(result*a)%MOD;
        }
        a=(a*a)%MOD;
        b>>=1;
    }
    return result;
    
}
ll modInverse(ll n){
    return mymod(n,MOD-2);
}

void init_combination(){
    const int MAX = 10000002;   //1e6+2
    Factorial[0]=1;
    inv[0]=1;
    for(int i=1;i<=MAX;i++){
        Factorial[i]=(Factorial[i-1]*i)%MOD;
    }
    FactorialInv[MAX]=modInverse(Factorial[MAX]);
    for(int i=MAX-1;i>=0;i--){
        FactorialInv[i]=FactorialInv[i+1]*(i+1)%MOD;
    }
    for(int i=1;i<=MAX;i++){
        inv[i]=(FactorialInv[i]*FactorialInv[i-1])%MOD;
    }
}

ll combination(ll n,ll k){
    if(n==k||k==0){
        return 1;
    }
    if(n<k){
        return 0;
    }
    ll ans=(Factorial[n]*FactorialInv[k])%MOD;
    ans=(ans*FactorialInv[n-k])%MOD;
    return ans;
}


int main(){
    int N,K;
    cin>>N>>K;
    N++;
    ll H[N];
    F0R(i,N-1){
        cin>>H[i];
    }
    H[N-1]=0;
    ll dp[N+1][K+1];
    F0R(i, N+1) F0R(j, K+1) {
        dp[i][j] = 1000000000000;
    }
    dp[0][0]=0;
    FOR(i,1,N+1){
        F0R(j,K+1){
            F0R(k,j+1){
                int pos=i-1-k;
                if(pos<0){
                    break;
                }
                int dif=0;
                int lst=0;
                if(pos!=0){
                    lst=H[pos-1];
                }
                dp[i][j]=min(dp[i][j],dp[pos][j-k]+max(0ll,H[i-1]-lst));
            }
        }
    }
    ll ans = 1000000000000;
        F0R(j,K+1){
            ans=min(ans,dp[N][j]);
        }
        out(ans);
}


Measured memory_bytes: 896
import java.util.*;

import java.io.*;

public class Main {

	static Scanner in = new Scanner(System.in) ;
	
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		
		int len = in.nextInt() ;
		int K = in.nextInt() ;
		String str = in.next() ;
		String output = ""+str.charAt(K-1) ;
		output = output.toLowerCase() ;
		for(int i=0;i<len;i++){
			if((K-1)!=i){
				System.out.print(str.charAt(i));
			}else{
				System.out.print(output);
			}			
		}
	}

}


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

int main(){
    float n; cin >>n;
    vector<int> x(n); vector<int> y(n); 
    rep(i,n) cin >> x[i] >> y[i];
    float l=1;
    for(int i=n-1;i>0;i--){
        l*=i;
    }
    int N;
    N=n*(n-1)/2;
    vector<float> d(N); int k=0;
    for(int i=0; i<n-1; i++){
        for(int j=i+1;j<n;j++){
            float a = pow(x[i]-x[j],2);
            float b = pow(y[i]-y[j],2);
            float c = pow(a+b,0.5);
            d[k] = c;
            k++;
        }
    }float sum =0;
    for(int i=0; i<N; i++){
        sum +=d[i];
    }
    cout << setprecision(12)<<sum*(n-1)/N << endl;
}

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

const ll MAXN = 200000;
const ll INF = 1001001001;

ll N, M, ans=0, tmp=0;
vector<ll> cl, Ls, Rs, Ds;
vector<vector<pair<ll,ll>>> G;

void bfs(ll id) {
    queue<ll> Q;
    Q.push(id);
    cl[id] = 0;
    while(!Q.empty()) {
        ll u = Q.front();
        Q.pop();
        for(int i=0;i<G[u].size();i++) {
            if(cl[G[u][i].first]!=-INF) continue;
            else {
                Q.push(G[u][i].first);
                cl[G[u][i].first] = cl[u] + G[u][i].second;
            }
        }
    }
}

signed main(){
    cin >> N >> M;
    G.resize(N);
    cl.resize(N,-INF);
    for(int i=0;i<M;i++) {
        ll l, r, d;
        cin >> l >> r >> d;
        l--;
        r--;
        Ls.push_back(l);
        Rs.push_back(r);
        Ds.push_back(d);
        G[l].push_back(make_pair(r,d));
        G[r].push_back(make_pair(l,-d));
    }
    for(int i=0;i<N;i++) {
        if(cl[i]!=-INF) continue;
        else {
            bfs(i);
        }
    }
    for(int i=0;i<M;i++) {
        if(cl[Rs[i]]!=cl[Ls[i]]+Ds[i]) {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 21660
#include<bits/stdc++.h>
#define for(i,a,b) for(int i=a;i<=b;i++)
#define _inline __inline__ __attribute__((always_inline))
using namespace std;
_inline void read(int &x){
	int res=0,f=1;
	char c=getchar();
	if(c=='-') f=-1;
	while(c>'9'||c<'0') c=getchar();
	while(c>='0'&&c<='9'){
		res=res*10+c-'0';
		c=getchar();
	}
	x=res*f;
}
inline void print(int x){
    if(x<0) putchar('-'),x=-x;
    if(x>9) print(x/10);
    putchar(x%10+'0');
}
int ans=1,n,k;
int main(){
	read(n),read(k);
	while(n--) ans+=min(ans,k);
	print(ans),puts("");
	exit(0); 
}

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

int main() {
    string s;cin >> s;
    int lo;lo = s.size();
    int cnt;cnt = 0;
    for(int i=0;i<lo;i++){
        if(s[i] == 'o'){
            cnt++;
        }
    }

    cnt += 15 - lo;
    if(cnt>7){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }
}


Measured memory_bytes: 256
#include <cstdio>
#include <string>
typedef long long LL;
int main() {
    LL a, b, c;
    scanf("%lld%lld%lld",&a,&b,&c);
    if (a%2==0||b%2==0||c%2==0) 
    {
        printf("0");
        return 0;
    }
    LL AB=a*b;
    LL BC=b*c;
    LL AC=a*c;
    LL m=std::min(AB,BC);
    m=std::min(m,AC);
    printf("%lld",m);
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int main() {
    int K;
    cin >> K;
    int k[] = {K ,K ,K};
 
    long long tmp = 0;
    for (int a = 1; a <= K; a++) {
        for (int b = 1; b <= K; b++) {
            for (int c = 1; c <= K; c++) {
                tmp += __gcd(__gcd(a, b), c);
            }
        }
    }
    cout << tmp << endl;
    return 0;
}

Measured memory_bytes: 3636
k, n = list(map(int, input().split()))

a = [i for i in list(map(int, input().split()))]

gap_max=0
for i in range(n-1):
  gap = a[i+1]-a[i]
  if gap>gap_max:
    gap_max=gap

if k-a[n-1]+a[0]>gap_max:
  gap_max=k-a[n-1]+a[0]
print(k-gap_max)

Measured memory_bytes: 26420
import java.util.Scanner;
public class Main {

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

int a=scan.nextInt();
        int b=scan.nextInt();
        int c=scan.nextInt();
        if(b-a==c-b){
            System.out.println("YES");
        }
        else{
            System.out.println("NO");
        }

    }
}

Measured memory_bytes: 22100
#include<cstdio>
#include<algorithm>
using namespace std;
int a[200100];
int main(){
//	freopen("A.in","r"zs,stdin);
	int n;
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
		scanf("%d",&a[i]);
	sort(a+1,a+n+1);
	long long l1=0,l2=0;
	for(int i=n;i>=2;i--)
	{
		if(a[i]==a[i-1]){
			if(a[i]>l1) l2=l1,l1=a[i];
			else if(a[i]>l2) l2=a[i];
			i--;
		}
	}
	printf("%lld\n",l1*l2);
	return 0;
}


Measured memory_bytes: 512
name1 = input()
name2 = input()

x = False
d = len(name2)-1


if(name1[0:] == name2[0:d]):
    x = True
else:
    x = False

if(x == True):
    d = d+1
    f = len(name1)
    if(d > f):
        print("Yes")
else:
    print("No")


Measured memory_bytes: 9124
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdbool.h>
#include <math.h>
#include <limits.h>

int max(int a,int b){return a>b?a:b;}
int min(int a,int b){return a<b?a:b;}
void swap(int *a,int *b){int tmp;tmp=*a;*a=*b;*b=tmp;}

int main(void){
    int x;
    scanf("%d",&x);
    if (x==3||x==5||x==7){
        printf("YES\n");
    } else {
        printf("NO\n");
    }
    
    
    
    return 0;
}

Measured memory_bytes: 128
<?php
  
$alph = range('a', 'z');
  
$s = trim(fgets(STDIN));
$sa = [];
for($i=0; $i<strlen($s); $i++){
  $sa[$i] = $s[$i];
}
$sa = array_unique($sa);

$diff = array_diff($alph,$sa);
sort($diff);

echo count($diff) > 0 ? $diff[0] : 'None';

?>

Measured memory_bytes: 18804
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s;
  int i;
  cin>>s;
  for(i=0;i<s.length();i++){
   if(i%2==0) if(s[i]!='R'&&s[i]!='U'&&s[i]!='D') {cout<<"No"; return 0;}
   if(i%2==1) if(s[i]!='L'&&s[i]!='U'&&s[i]!='D') {cout<<"No"; return 0;}
}
  cout<<"Yes";
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i=0; i<(int)(n); i++)
#define REP1(i,a,b) for(int i=a; i<=(int)(b); i++)
#define ALL(x) begin(x),end(x)
#define PB push_back
using namespace std;
typedef int64_t LL;
typedef vector<int> VI;
typedef pair<int,int> PII;

template<class T> inline bool chmax( T &a, const T &b ) { return b>a ? a=b,true : false; }
template<class T> inline bool chmin( T &a, const T &b ) { return b<a ? a=b,true : false; }
template<class T> using MaxHeap = priority_queue<T>;
template<class T> using MinHeap = priority_queue<T, vector<T>, greater<T>>;
template<class T, class F=less<T>> void sort_uniq( vector<T> &v, F f=F() ) {
    sort(begin(v),end(v),f);
    v.resize(unique(begin(v),end(v))-begin(v));
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    LL x,y;
    cin >> x >> y;
    LL ans=0;
   	LL a=x;
   	while ( a<=y ) {
   		++ans;
   		a*=2;
   	}
   	cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		final String lb = System.getProperty("line.separator");
		StringBuilder sb = new StringBuilder();

		while(true){
			final String[] scores = sc.nextLine().split(" ");
			final int mid = Integer.parseInt(scores[0]);
			final int fin = Integer.parseInt(scores[1]);
			final int ret = Integer.parseInt(scores[2]);
			final int sum = mid + fin;

			if(mid == -1 && fin == -1 && ret == -1) break;

			if(mid == -1 || fin == -1){
				sb.append("F").append(lb);
			} else if(sum >= 80){
				sb.append("A").append(lb);
			} else if(sum >= 65){
				sb.append("B").append(lb);
			} else if(sum >= 50){
				sb.append("C").append(lb);
			} else if(sum >= 30){
				if(ret >= 50){
					sb.append("C").append(lb);
				} else {
					sb.append("D").append(lb);
				}
			} else {
				sb.append("F").append(lb);
			}
		}
		System.out.print(sb.toString());
	}
}

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

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner();
		int n = sc.nextInt();
		String s = "." + sc.next();
		int sum = 0;
		for(int i = 1; i < s.length(); i++) 
			if(s.charAt(i) == '.')
				sum++;
		
		long min = sum;
		for(int i = 1; i < s.length(); i++) {
			int val = sum;
			if(s.charAt(i) == '#')
				val++;
			else
				val--;
			if(min > val)
				min = val;
			sum = val;
		}
		
		System.out.println(min);
		
	}
}

class Scanner {
	private static final int SPACE = (int)' ';
	private static final int LINE_END_0 = 13;
	private static final int LINE_END_1 = 10;
	private static final int BEFORE = -1;
	private BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	
	public String next(){
		StringBuilder sb = new StringBuilder();
		
		int length = BEFORE;
		readLoop: while(true) {
			try {
				int value = br.read();
				switch(value) {
				case LINE_END_1:
					if(length == BEFORE)
						break;
					
					if((int)sb.charAt(length) == LINE_END_0)
						sb.deleteCharAt(length);
				case SPACE:
					break readLoop;
				}
				sb.append((char)value);
				length++;

			} catch (IOException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}
		return sb.toString();
	}
	
	public String[] nextArray(int length) {
		String[] array = new String[length];
		for(int i = 0; i < length; i++)
			array[i] = next();
		return array;
	}
	
	public double nextDouble() {
		return Double.parseDouble(next());
	}
	
	public double[] nextDoubleArray(int length) {
		double[] array = new double[length];
		for(int i = 0; i < length; i++)
			array[i] = nextDouble();
		return array;
	}
	
	public int nextInt() {
		return Integer.parseInt(next());
	}
	
	public int[] nextIntArray(int length) {
		int[] array = new int[length];
		for(int i = 0; i < length; i++)
			array[i] = nextInt();
		return array;
	}
	
	public long nextLong() {
		return Long.parseLong(next());
	}
	
	public long[] nextLongArray(int length) {
		long[] array = new long[length];
		for(int i = 0; i < length; i++)
			array[i] = nextLong();
		return array;
	}
	
	public boolean ready() {
		try {
			return br.ready();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return false;
	}
}


Measured memory_bytes: 25556
#include <bits/stdc++.h>
using namespace std;
int main()
{
    string s;
    cin>>s;
    for(int i=0;i<s.size();i++)
    {
        if(s[i]=='C')
        {
            for(int j=i+1;j<s.size();j++)
            {
                if(s[j]=='F')
                {
                    cout<<"Yes"<<endl;
                    return 0;
                }
            }
        }
    }
    cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 256
A, B, C, D = gets.chomp.chars.map(&:to_i)
op = %w(+ -)
op.each do |op1|
  op.each do |op2|
    op.each do |op3|
      s = "#{A}#{op1}#{B}#{op2}#{C}#{op3}#{D}"
      if eval(s) == 7
        puts "#{s}=7"
        exit
      end
    end
  end
end


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

#define F first
#define S second
#define MP make_pair
#define pb push_back
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define LCM(a, b) (a) / __gcd((a), (b)) * (b)
#define CEIL(a, b) (a)/(b)+(((a)%(b))?1:0)
#define ln '\n'

using namespace std;
using LL = long long;
using ldouble = long double;
using P = pair<int, int>;
using LP = pair<LL, LL>;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1e9 + 7;
static const int SIZE = 200005;

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

vector<LL> Div(LL n) {
    vector<LL> ret;
    for(LL i = 1; i * i <= n; ++i) {
        if(n % i == 0) {
            ret.pb(i);
            if(i * i != n) ret.pb(n / i);
        }
    }
    sort(all(ret));
    return ret;
}

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

    int N;
    cin >> N;

    int c = 0;
    int bc = 0;
    for(int i = 0; i < N; ++i) {
        int a;
        cin >> a;
        if(a % 4 == 0) ++c;
        else if(a % 2 == 0) ++bc;
    }

    N--;
    if(N / 2 + N % 2 <= c + (bc / 2)) cout << "Yes";
    else cout << "No";
    cout << endl;

    return 0;
}



Measured memory_bytes: 256
import java.util.*;
 
public class Main{
    public static void main(String args[] ) throws Exception {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] m = {0, 0, 0, 0, 0, 0, 0, 0, 0};
        int c = 0;
        for (int i = 0; i < n; i++) {
            int rate = sc.nextInt();
            for (int j = 0; j < 8; j++) {
                if (3200 <= rate) {
                    m[8]++;
                    break;
                } else if (j * 400 <= rate && rate < (j + 1) * 400) {
                    m[j]++;
                }
            }
        }
        int count = 0;
        for (int i = 0; i < 8; i++) {
            if (!(m[i] == 0)) {
                count++;
            }
        }
        if (m[8] == 0) {
             System.out.println(count + " " + count);
        } else {
            if (count == 0) {
                System.out.println("1 " + (count + m[8]));
            } else {
                System.out.println(count + " " + (count + m[8]));
            }
        }
    }    
}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
    using namespace std;
    const int N = 1e5 + 5;
    bool gg = 0;
    int c[N], cnt[3];
    vector<int> G[N];
    void dfs(int x, int col = 1) {
    	if (c[x]) {
    		gg |= col != c[x];
    		return;
    	}
    	c[x] = col;
    	cnt[col] ++;
    	for (int u : G[x]) dfs(u, 3 - col);
    }
    int main() {
    	int n, m;
    	scanf("%d%d", &n, &m);
    	for (int i = 0; i < m; ++ i) {
    		int u, v;
    		scanf("%d%d", &u, &v);
    		G[u].push_back(v);
    		G[v].push_back(u);
    	}
    	dfs(1);
    	if (gg) printf("%lld\n", 1LL * n * (n - 1) / 2 - m); else printf("%lld\n", 1LL * cnt[1] * cnt[2] - m);
    }

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

using namespace std;

#define int long long

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

int calc(int a, int b)
{
    if (b % a == 0) return 2 * b - a;

    return 2 * (a / b) * b + calc(b, a % b);
}

signed main()
{
    int N, X; cin >> N >> X;

    int a = X, b = N - X;

    if (a < b) swap(a, b);

    cout << N + calc(X, N - X) << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <queue>
#include <set>
#include <map>
#include <iomanip>
#include <fstream>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int mod = 1000000007;

ll gcd(ll a, ll b) {
    while (b) {
        ll c = a % b;
        a = b;
        b = c;
    }
    return a;
}

int main() {
    ios::sync_with_stdio(false);
    int n, m;
    ll a[100005] = {}, g = 0, c[100005] = {};
    cin >> n >> m;
    for (int i = 0; i < n; i++) cin >> a[i];
    for (int i = 0; i < n; i++) {
        a[i] /= 2;
        ll b = gcd(g, a[i]);
        if (!g) g = a[i];
        else g = g * a[i] / b;
        if (g > mod) g = mod;
    }
    for (int i = 0; i < n; i++) {
        while (a[i] % 2 == 0) a[i] /= 2, c[i]++;
    }
    for (int i = 1; i < n; i++) if (c[i] != c[i - 1]) {
        cout << 0;
        return 0;
    }
    ll z = m / g;
    if (z % 2) cout << z / 2 + 1;
    else cout << z / 2;
}


Measured memory_bytes: 5204
# coding: utf-8
# Your code here!

line = input().split( )
line = [int(s) for s in line]
a = []
a.append(line[0]* 10 + line[1] + line[2])
a.append(line[1]* 10 + line[0] + line[2])
a.append(line[2]* 10 + line[0] + line[1])
print(max(a))

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

int main() {
  int N;
  cin >> N;
  int r[9] = {0,0,0,0,0,0,0,0,0};
  for (int i = 0; i < N; i++) {
    int rate;
    cin >> rate;
    if (rate / 400 <= 7) {
      int n = rate / 400;
      r[n] =1;
    }
    else {
      r[8]++;
    }
  }
  int m = 0;
  for (int i = 0; i < 8; i++) {
    m += r[i];
  }
  int M = m + r[8];
  if (m == 0) m = 1;
  cout << m << " " << M << endl;
}

Measured memory_bytes: 256
///#pragma GCC optimize("Ofast")
///#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,fma")
///#pragma GCC optimize("unroll-loops")

#include<bits/stdc++.h>
using namespace std;

///#include<ext/pb_ds/assoc_container.hpp>
///#include<ext/pb_ds/tree_policy.hpp>
///using namespace __gnu_pbds;
///template<typename T> using orderset = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;
///(X).order_of_key(value) /// return lower_bound(value)
///(*X).find_by_order(index) /// return value (0 index)

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); /// mt19937_64 (long long)

typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef vector<int> vii;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<vii> vvii;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<bool> vbb;

const int N = 1000001;
const int MOD = 1000000007;
const ll INF = LLONG_MAX;

#define fast() ios_base::sync_with_stdio(false),cin.tie(NULL)
#define next(x) next_permutation(all(x))
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rev(a) reverse(all(a))
#define eb emplace_back
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define yes cout<<"YES"<<nl
#define no cout<<"NO"<<nl
#define space ' '
#define nl '\n'
#define PI acos(-1)
#define Case(x) cout<<"Case "<<x<<": "
#define strtoint(a) atoi(a.c_str())
#define dbg(x) cerr<<#x<<" is "<<x<<'\n';
#define fix(x) cout<<fixed<<setprecision(x)
#define leastonepos(x) __builtin_ffs(x)
#define leadingoff(x) __builtin_clz(x)
#define trailingoff(x) __builtin_ctz(x)
#define numofone(x) __builtin_popcount(x)
#define time() cerr<<"Time elapsed : "<<clock()*1000.0/CLOCKS_PER_SEC<<"ms"<<'\n'

#define coutv(v) for(auto it:v)cout<<it<<space;cout<<nl;
#define cinv(v) for(auto &it:v)cin>>it;

///................Graph's Move.................
///const int dx[] = {+1,-1,+0,+0}; ///Rock's Move
///const int dy[] = {+0,+0,+1,-1}; ///Rock's Move
///const int dx[] = {+0,+0,+1,-1,-1,+1,-1,+1}; ///King's Move
///const int dy[] = {-1,+1,+0,+0,+1,+1,-1,-1}; ///king's Move
///const int dx[] = {-2,-2,-1,-1,+1,+1,+2,+2}; ///knight's Move
///const int dy[] = {-1,+1,-2,+2,-2,+2,-1,+1}; ///knight's Move
///*.....................-_-........................*///



int main()
{
    fast();
    int tc=1,cs=0;
    //cin>>tc;
    while(tc--)
    {
        int n,i;
        cin>>n;
        vii h(n),dp(n);
        cinv(h);
        for(i=1; i<n; i++)
        {
            dp[i]=(dp[i-1]+abs(h[i]-h[i-1]));
            if(i>1)
                dp[i]=min(dp[i],(dp[i-2]+abs(h[i]-h[i-2])));
        }
        cout<<dp[n-1]<<nl;
    }
}

Measured memory_bytes: 3936
/* Dynamic Programming implementation of LCS problem */ 
#include<bits/stdc++.h>
using namespace std; 

/* Returns length of LCS for X[0..m-1], Y[0..n-1] */
void lcs( string X, string Y, int m, int n ) 
{ 
int L[m+1][n+1]; 

/* Following steps build L[m+1][n+1] in bottom up fashion. Note 
	that L[i][j] contains length of LCS of X[0..i-1] and Y[0..j-1] */
for (int i=0; i<=m; i++) 
{ 
	for (int j=0; j<=n; j++) 
	{ 
	if (i == 0 || j == 0) 
		L[i][j] = 0; 
	else if (X[i-1] == Y[j-1]) 
		L[i][j] = L[i-1][j-1] + 1; 
	else
		L[i][j] = max(L[i-1][j], L[i][j-1]); 
	} 
} 

// Following code is used to print LCS 
int index = L[m][n]; 

// Create a character array to store the lcs string 
char lcs[index+1]; 
lcs[index] = '\0'; // Set the terminating character 

// Start from the right-most-bottom-most corner and 
// one by one store characters in lcs[] 
int i = m, j = n; 
while (i > 0 && j > 0) 
{ 
	// If current character in X[] and Y are same, then 
	// current character is part of LCS 
	if (X[i-1] == Y[j-1]) 
	{ 
		lcs[index-1] = X[i-1]; // Put current character in result 
		i--; j--; index--;	 // reduce values of i, j and index 
	} 

	// If not same, then find the larger of two and 
	// go in the direction of larger value 
	else if (L[i-1][j] > L[i][j-1]) 
		i--; 
	else
		j--; 
} 

// Print the lcs 
cout << lcs; 
} 

/* Driver program to test above function */
int main() 
{ 
string X, Y; cin >> X >> Y; 
int m = X.length(); 
int n = Y.length(); 
lcs(X, Y, m, n); 
return 0; 
} 


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

typedef long long ll;

int main()
{
    int a,b,m;
    cin >> a >> b >> m;
    vector<int> d(a);
    vector<int> e(b);
    int i;
    for(i = 0;i < a;++i){
        cin >> d.at(i);
    }
    for(i = 0;i < b;++i){
        cin >> e.at(i);
    }
    int x,y,c;
    vector<int> ans;
    for(i = 0;i < m;++i){
        cin >> x >> y >> c;
        int temp = 0;
        temp += d.at(x-1) + e.at(y-1) - c;
        ans.push_back(temp);
    }
    sort(d.begin(), d.end());
    sort(e.begin(), e.end());
    int temp = d.at(0) + e.at(0);
    ans.push_back(temp);
    sort(ans.begin(), ans.end());
    cout << ans.at(0) << endl;

    return 0;
}

Measured memory_bytes: 1660
/**
   <Linear Search>
   
   http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_4_A
   
   Shunji Lin
   06/01/2016
**/

#include <cstdio>
#include <set>

int main()
{
  int s, t; //number of integers for S and T

  int count = 0; // number of integers of T in S
  
  std::set<int> S; // set S to be checked against

  scanf("%d", &s);
  
  for (int i = 0; i < s; ++i) {
    int input;
    scanf("%d", &input);
    S.insert(input);
  }

  scanf("%d", &t);

  for (int i = 0; i < t; ++i) {
    int input;
    scanf("%d", &input);
    if ( S.count(input) ) ++count; // increment count if found in S
  }

  printf("%d\n", count);
}
    

Measured memory_bytes: 2856
import java.util.*;
public class Main {
	static int inf = (int) Math.pow(10, 9);
	static int num, A, B, C;
	static int[] l = new int[1000];
	public static int dfs(int cur, int a, int b, int c) {
		if(cur == num) {
			if(a > 0 && b > 0 && c > 0) {
				return Math.abs(a - A) + Math.abs(b - B) + Math.abs(c - C) - 30;
			}
			else return inf;
		}
		int ret0 = dfs(cur+1, a, b, c);
		int ret1 = dfs(cur+1, a + l[cur], b, c) + 10;
		int ret2 = dfs(cur+1, a, b + l[cur], c) + 10;
		int ret3 = dfs(cur+1, a, b, c + l[cur]) + 10;
		return Math.min(ret0, Math.min(ret1, Math.min(ret2, ret3)));
	}
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		num = sc.nextInt();
		A = sc.nextInt();
		B = sc.nextInt();
		C = sc.nextInt();
		for(int i = 0; i < num; i++) l[i] = sc.nextInt();
		System.out.println(dfs(0, 0, 0, 0));
	}

}


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


vector<int> G[100000];
int color[100000];
int white = 0;

bool dfs(int v, int c) {
    color[v] = c;
    if (c == 1) white++;
    for (int i = 0; i < G[v].size(); i++) {
        if (color[G[v][i]] == c) return false;
        if (color[G[v][i]] == 0 && !dfs(G[v][i], -c)) return false;
    }
    return true;
}

int main()
{   
    memset(color, 0, 100000);
    ll N, M;
    cin >> N >> M;
    for (ll i = 0; i < M; i++) {
        int a, b;
        cin >> a >> b;
        a--; 
        b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    if (dfs(0,1)) {cout << white*(N-white) - M << endl;} 
    else {cout << N*(N-1)/2 - M << endl;}
    return 0;
}

Measured memory_bytes: 6528
#include <iostream>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <functional>
using namespace std;

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

    int cmax = 0;
    int count = 0;
    for(auto c: s){
        if(c == 'A' || c == 'C' || c == 'G' || c == 'T'){
            count++;
        }else{
            cmax = max(cmax, count);
            count = 0;
        }
    }
    cmax = max(cmax, count);
    cout << cmax << endl;
    return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
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; }

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	vector<ll> a(n+1, 0);
	rep(i,n) cin >> a[i];
	ll ans = 0;
	rep(i,n){
		ans += a[i] / 2;
		if(a[i]%2 == 1 && a[i+1] > 0){
			++ans;
			--a[i+1];
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3988
from itertools import product

H, W, K = map(int, input().split())
grid = [input() for _ in range(H)]

ans = 0
for a in product([0, 1], repeat=H):
    for b in product([0, 1], repeat=W):
        cnt = 0
        for i in range(H):
            if a[i] == 1:
                continue
            for j in range(W):
                if b[j] == 1:
                    continue
                if grid[i][j] == '#':
                    cnt += 1
        if cnt == K:
            ans += 1

print(ans)


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

using namespace std;

#define rep(i,x) for(int i=0;i<x;++i)
#define all(a) begin(a),end(a)
#define PB push_back

const int inf = 1e9;

struct edge {int to,id;};

vector<edge> G0[100010], G[100010];
vector<pair<int, int>> edges;
bool used[200010];
int d[100010];
int indeg[100010];

int N, M, Q;

void build_G()
{
    queue<int> q;
    q.push(0);

    fill_n(d, N, inf);
    d[0] = 0;

    while (q.size()) {
        int v = q.front(); q.pop();

        for (edge &e : G0[v]) {
            if (d[e.to] >= d[v] + 1) {
                used[e.id] = true;

                G[v].PB(edge{e.to, e.id});
                indeg[e.to]++;

                if (d[e.to] > d[v] + 1) {
                    d[e.to] = d[v] + 1;
                    q.push(e.to);
                }
            }
        }
    }
}

signed main()
{
    cin >> N >> M >> Q;

    rep(i, M) {
        int U, V; cin >> U >> V;
        --U, --V;
        G0[U].PB(edge{V, i});
        G0[V].PB(edge{U, i});
        edges.PB(pair<int, int>(U, V));
    }

    build_G();

    int ans = 0;

    rep(i, Q) {
        int r; cin >> r;
        --r;

        if (!used[r]) {
            cout << ans << endl;
            continue;
        }

        used[r] = false;

        int u = edges[r].first, v = edges[r].second;

        if (d[u] > d[v]) swap(u, v);

        // d[u] < d[v]
        indeg[v]--;

        if (indeg[v] == 0) {
            ans++;

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

            while (q.size()) {
                int v = q.front(); q.pop();

                for (edge &e : G[v]) {
                    int u = e.to, id = e.id;

                    if (!used[id]) continue;
                    used[id] = false;
                    indeg[u]--;

                    if (indeg[u] == 0) {
                        ans++;
                        q.push(u);
                    }
                }
            }
        }

        cout << ans << endl;
    }
}

Measured memory_bytes: 18776
import sys
def input(): return sys.stdin.readline().strip()

def resolve():
    n=int(input())
    edge = [[] * n for i in range(n)] # rangeに頂点の数。繋がっている頂点を投入するリスト
    for i in range(n): # rangeに辺の数
        x, y = i,int(input())
        y = y - 1
        edge[x].append(y)
    sagasu=0
    cnt=0
    while True:
        a=edge[sagasu]
        if a==[1]:
            print(cnt+1)
            break
        else:
            if cnt>n:
                print(-1)
                break
            else:
                cnt+=1
                sagasu=a[0]
resolve()

Measured memory_bytes: 51760
c=[0,2,5,5,4,5,6,3,7,6]
eval'N,M,*A='+`dd`.split*?,
d=[0]
0.upto(N){|i|
	A.map{|a|
		if d[i]
			d[i+c[a]]=[d[i+c[a]]||0,d[i]*10+a].max
		end
	}
}
p d[N]


Measured memory_bytes: 29192
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <utility>
#include <numeric>

#define faster ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define pb push_back
#define mp make_pair

typedef long long  ll;
using namespace std;
int inf = 1e9;
const int N = 300005;
int n, k;
int a[N];
int pos[N];

struct segtree {
    
    int size;
    vector<int> t;
    
    segtree(int n) {
        size = (int) n;
        t.assign(4 * n, 0);
    }
    
    void build(int v, int tl, int tr) {
        if(tl == tr) {
            t[v] = pos[tl];
        } else {
            int tm = (tl + tr) >> 1;
            build(2 * v, tl, tm);
            build(2 * v + 1, tm + 1, tr);
            t[v] = max(t[2 * v], t[2 * v + 1]);
        }
    }
    
    int get_max(int v, int tl, int tr, int l, int r) {
        if(l > r) return -inf;
        if(l == tl && r == tr)
            return t[v];
        int tm = (tl + tr) >> 1;
        return max(get_max(2 * v, tl, tm, l, min(tm, r)),
                   get_max(2 * v + 1, tm + 1, tr, max(tm + 1, l), r));
    }
    
    void update(int v, int tl, int tr, int pos, int val) {
        if(tl == tr) {
            t[v] = val;
        } else {
            int tm = (tl + tr) >> 1;
            if(pos <= tm)
                update(2 * v, tl, tm, pos, val);
            else update(2 * v + 1, tm + 1, tr, pos, val);
            t[v] = max(t[2 * v], t[2 * v + 1]);
        }
    }
    
    void build() {
        build(1, 0, size - 1);
    }
    
    int get_max(int l, int r) {
        return get_max(1, 0, size - 1, l, r);
    }
    
    void update(int pos, int val) {
        update(1, 0, size - 1, pos, val);
    }
};

int main(){
    faster
    cin >> n >> k;
    for(int i = 0;i < n;i++)
        cin >> a[i];
    
    segtree tree(N);
    tree.build();
    
    for(int i = 0;i < n;i++){
        int l = max(0, a[i] - k);
        int r = min(300000, a[i] + k);
        int temp = tree.get_max(l, r);
        tree.update(a[i], temp + 1);
    }
    cout <<  tree.get_max(0, 300001) << endl;
    return 0;
}


Measured memory_bytes: 8796
#include <bits/stdc++.h>
using namespace std;
 
int main() {
 string s;
 cin >> s;
 int n;
 n = s.size();
 vector<vector<int>> dp(n,vector<int>(13,0));
 int ciconv; //char->int convert
 
 // dp[0][j]を初期化する
 if(s.at(0)=='?'){ //先頭の文字が?の場合
   for(int i=0; i<10;i++){
   dp.at(0).at(i) = 1; 
   }
 }else{ //先頭の文字が数字の場合
   ciconv = s.at(0) - '0';
   dp.at(0).at(ciconv) = 1;
 }

 for(int i=1;i<n;i++){
   ciconv = s.at(i) - '0';
   for(int j=0 ; j!=13;j++){
      for(int k=0 ; k!=10 ; k++){
        if(s.at(i)!='?' && k!=ciconv) continue;
        dp.at(i).at((j*10+k)%13) += dp.at(i-1).at(j);
        dp.at(i).at((j*10+k)%13) %= 1000000007;
      }
    }
  }
  cout << dp.at(n-1).at(5);  
// system("pause");
 return 0;
}


Measured memory_bytes: 8960
import java.util.ArrayList;
import java.util.Comparator;
import java.util.PriorityQueue;
import java.util.Scanner;

public class Main{
	public static void main(String args[]) {

		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		ArrayList<PriorityQueue<Integer>> pque = new ArrayList<>();
		for(int i = 0; i < n; i++) {
			pque.add(new PriorityQueue<Integer>(Comparator.reverseOrder()));
		}

		int q = sc.nextInt();

		for(int i = 0; i < q; i++) {
			int command = sc.nextInt();
			int t = sc.nextInt();

			switch(command) {

			case 0:
				int x = sc.nextInt();
				pque.get(t).offer(x);
				break;

			case 1:
				if(!pque.get(t).isEmpty()) {
					System.out.println(pque.get(t).peek());
				}
				break;

			case 2:
				if(!pque.get(t).isEmpty()) {
					pque.get(t).poll();
				}
				break;
			}
		}
	}
}


Measured memory_bytes: 170736
#124_C

S=input()

a=''
b=''

lenS=len(S)

for i in range(lenS):
    if i%2==0:
        a+='1'
        b+='0'
    else:
        a+='0'
        b+='1'
        
ca=0
cb=0
for i in range(lenS):
    if a[i]!=S[i]:
        ca+=1
    if b[i]!=S[i]:
        cb+=1
print(min(ca,cb))
        



Measured memory_bytes: 3444
#include<stdio.h>

void selectionSort(int a[], int N);
void swap(int *a, int *b){
    int c;
    c=*a;
    *a=*b;
    *b=c;
}

int main(void){
    int a[100],N,i,j;
    scanf("%d",&N);
    
    for(i=0;i<N;i++){
        scanf("%d ",&a[i]);
    }

    selectionSort(a,N);
}

void selectionSort(int a[], int N){
    int i,j,minj,count;
    count = 0;


    for(i=0;i<N-1;i++){
        minj = i;
        for(j=i;j<N;j++){
            if(a[j]<a[minj])
                minj=j;
        }

        swap(&a[i],&a[minj]);
        if(i!=minj){
            count++;
        }  
        
    }

    printf("%d",a[0]);
    for(i=1;i<N;i++)
        printf(" %d",a[i]);
    
    printf("\n%d\n",count); 
}


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

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REP1(i,n) for(int i=1, i##_len=(n); i<i##_len; ++i)
#define ll long long
static const ll MAX = 10000;
static const ll INFTY = 1e12;

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 int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
using P = pair<ll, ll>;
// 入力
// 入力
ll h, w;
ll startX, startY, endX, endY;
vector<vector<char>> s;
vector<vector<ll>> cnts; // 魔法使った回数


int main() {

  int a, b;
  cin >> a >> b;

  if(a%2==1 && b%2==1){
    cout << "Odd" << endl;
  }else{
    cout << "Even" << endl;
  }



   
}
/*
                   _ooOoo_
                  o8888888o
                  88" . "88
                  (| -_- |)
                  O\  =  /O
               ____/`---'\____
             .'  \\|     |//  `.
            /  \\|||  :  |||//  \
           /  _||||| -:- |||||-  \
           |   | \\\  -  /// |   |
           | \_|  ''\---/''  |   |
           \  .-\__  `-`  ___/-. /
         ___`. .'  /--.--\  `. . __
      ."" '<  `.___\_<|>_/___.'  >'"".
     | | :  `- \`.;`\ _ /`;.`/ - ` : | |
     \  \ `-.   \_ __\ /__ _/   .-` /  /
======`-.____`-.___\_____/___.-`____.-'======
                   `=---='
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
         pass System Test!
*/

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

#define REP(i,num) for(ll i=0;i<(num);++i)
#define FOR(i,c,num) for(ll (i)=(c);(i)<(num);++(i))
#define LOOP(i) while(i--)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto pitr=c.begin();pitr!=c.end();++pitr){cout<<*pitr;if(next(pitr,1)!=c.end())cout<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;

constexpr ll atcoder_mod = 1e9+7;

template<typename T=ll>
T in(){T x; cin >> x; return (x);}
template<typename T=ll,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in<T>();}return x;}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

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

vector<ll> enum_div(ll n){
	vector<ll> ret;
	for(ll i=1;i*i<=n;++i){
		if(n%i==0){
			ret.push_back(i);
			if(i*i!=n){
				ret.push_back(n/i);
			}
		}
	}
	return ret;
}

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

	auto N=in();
	auto A=vecin(N);
	map<ll,ll> M;
	sort(ALL(A));
	REP(i,N){
		M[A[i]]++;
	}
	set<ll> S;
	for(auto& x:M){
		if(x.second>1) S.emplace(x.first);
	}

	set<ll> H;
	REP(i,N){
		if(S.find(A[i])!=S.end()){
			H.emplace(A[i]);
			continue;
		}

		if(H.empty()){
			H.emplace(A[i]);
		}
		else{
			auto D = enum_div(A[i]);
			bool exist = false;
			for(auto& x:D){
				if(H.find(x)!=H.end()){
					exist = true;
					break;
				}
			}
			if(!exist){
				H.emplace(A[i]);
			}
		}
	}

	out(H.size()-S.size());
	return 0;
}


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

int main()
{
    int a, b, c;

    cin >> a >> b >> c;

    if ((a >= 0 && a <= 100) && (b >= 0 && b <= 100) && (c >= 0 && c <= 100)) {
        if (a < b && b < c) {
            cout << "Yes" << endl;
        } else {
            cout << "No" << endl;
        }
    }

    return 0;
}


Measured memory_bytes: 3104