akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <queue>
#include <array>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <cassert>
#include <utility>
#include <functional>

using namespace std;
using lli = long long int;
template<class T, class U> void init_n(vector<T>& v, size_t n, U x) {
  v = vector<T>(n, x);
}
template<class T> void init_n(vector<T>& v, size_t n) { init_n(v, n, T()); }
template<class T> void read_n(vector<T>& v, size_t n) {
  v = vector<T>(n); for (lli i=0; i<n; ++i) cin >> v[i];
}
template<class T> T gabs(const T& x) { return max(x, -x); }
#define abs gabs

lli n, k;
vector<lli> a, dp;
int main() {
  cin >> n >> k;
  read_n(a, n);
  init_n(dp, k+1, 0);
  for (lli i=0; i<=k; ++i) {
    lli win = -1;
    for (lli x : a) {
      if (x <= i && dp[i-x] == -1) win = 1;
    }
    dp[i] = win;
  }
  cout << (dp[k] > 0 ? "First" : "Second") << endl;
  return 0;
}


Measured memory_bytes: 1024
#include<iostream>
#include<string>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<list>
#include<cstdint>
#include<bits/stdc++.h>
#include<queue>
#include<set>

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep_r(i, n) for(int i = n-1; i >= 0; i--)
#define rep1(i, n) for(int i = 1; i <= (int)(n); i++)
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((ll)(x).size())
#define bit(n) (1LL<<(n))
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

#define INF bit(60)
#define pb push_back
#define mod 1000000007

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

using namespace std;
using uif=uint_fast64_t;
using ll=long long int;

int qp(int a,ll b){int ans=1;do{if(b&1)ans=1ll*ans*a%mod;a=1ll*a*a%mod;}while(b>>=1);return ans;}
int qp(int a,ll b,int mo){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}

int gcd(int a,int b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};


#define FACSIZE 2002

ll invfac[FACSIZE];
ll fac[FACSIZE];

ll mod_pow(ll ,ll );
ll mod_add(ll ,ll );
ll mod_mul(ll ,ll );
ll mod_div(ll ,ll );
void make_fact(ll );
void make_invfact(ll );



int main(void){

  ll n;
  cin>>n;
  vector<int> a(n);

  double ans=0.0;

  rep(i,n){
    cin>>a[i];

    ans+=1.0/a[i];

  }

  ans=1.0/ans;

  cout << ans << endl;

  return 0;

}

ll mod_pow(ll x,ll r){
  if(r==0) return 1;
  else if(r==1) return x%mod;
  else if(r%2==0){
    ll t=mod_pow(x,r/2)%mod;
    return t*t %mod;
  } 
  else{
    ll t=mod_pow(x,r/2)%mod;
    ll k= t*t %mod;
    return k*x%mod;
  } 
}
ll mod_add(ll a,ll b){
  return (a+b)%mod;
}

ll mod_mul(ll a,ll b){
  return (a*b)%mod;
}

ll mod_div(ll a,ll b){
  return mod_mul(a,mod_pow(b,mod-2));
}

void make_fact(ll n){
  fac[0]=1;
  rep(i,n){
    fac[i+1]=mod_mul(fac[i],i+1);
  }  
}

void make_invfact(ll n){
  invfac[n]= mod_pow( fac[n] ,mod-2);
  for(int i=n-1;i>=0;i--){
    invfac[i]=mod_mul(invfac[i+1],i+1);
  }

}

Measured memory_bytes: 256
/* Bismillahir Rahmanir Rahim */

#include <bits/stdc++.h>

using namespace std;

int main(){
	int n, t, x;
	long long ret = 0;
	scanf("%d %d", &n, &t);
	long long past = 0;
	while(n--){
		scanf("%d", &x);
		past = max(past, 1LL * x);
		ret += (x + t) - past;
		past = x + t;
	}
	cout << ret << endl;
	return 0;
}



Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

ans = 0
for i in range(N):
    #i人目の勇者の戦闘
    rem = B[i] #残りの倒せるモンスター
    
    if A[i] >= rem:
        ans += rem
        continue
    else:
        rem -= A[i]
        ans += A[i]

    if A[i+1] >= rem:
        ans += rem
        A[i+1] -= rem
    else:
        ans += A[i+1]
        A[i+1] = 0
print(ans)

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

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

  long long x;
  cin >> x;
  long long res = x / 11 * 2;
  int r = x % 11;
  if (r) {
    if (r <= 6) res++;
    else res += 2;
  }
  cout << res << '\n';
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,t,ans=0;
  while(1){
  ans = 0;
  cin >> t;
  if(t==0) break;
  for(int i=0; i<9; i++){
	cin >> n;
	ans += n;
  }
  if(t==0){
  } else {
  cout << t-ans << endl;
  }
  }
  return 0;
}


Measured memory_bytes: 3012
#include<bits/stdc++.h>
#define int long long
#define mod 1000000007
#define trace(x) cerr<<#x<<": "<<x<<" "<<endl
#define trace2(x, y) cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z) cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define sa(a,n) for(int i =0 ; i<n ; i++) cin>>a[i]
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define scan() int n; cin>>n ; int a[n]; for(int i = 0 ; i<n ; i++) cin>>a[i]
#define print(a,n) for(int i = 0 ; i < n ; i++) cout<<a[i]<<' '
using namespace std;

int32_t main(){
        ios_base::sync_with_stdio(false);
        cin.tie(NULL);
        cout.tie(NULL);
        int n,w;
        cin >> n >> w;
        int p=1e18;
        int i,j,weight[n+1],value[n+1];
        for(i=0; i<n; i++) cin >> weight[i] >> value[i];
        int v=0;
        for(i=0; i<n; i++){
            v+=value[i];
        }
        int dp[n+1][v+1];
        for(i=0; i<=n; i++){
            for(j=0; j<=v; j++){
                if(i==0 && j==0)dp[i][j]=0;
                else if(i==0){dp[i][j]=p;}
                else if(j==0) dp[i][j]=0;
                else if(value[i-1]<=j){
                    dp[i][j]=min(dp[i-1][j],dp[i-1][j-value[i-1]]+weight[i-1]);
                }
                else{
                    dp[i][j]=dp[i-1][j];
                }
            }
        }
        int ans=0;
        for(j=0; j<=v; j++){
            //trace(dp[n][j]);
            if(dp[n][j]<=w){
                ans=max(ans,j);
            }
        }
        cout << ans << '\n';

        

}

Measured memory_bytes: 79104
#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 DBG_N(hoge) cerr<<" "<<(hoge)<<endl;
#define DBG cerr<<"!"<<endl;
#define BITLE(n) (1LL<<((ll)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;
ll cnt=0;
vi A(222222);
ll lis(int n){
  vi dp(222222,llINF);
  ll now=0;
  for(int i=0;i<n;i++){
    ll po=(upper_bound(ALL(dp),A[i])-dp.begin());
    dp[po]=A[i];
  }
  return lower_bound(ALL(dp),llINF)-dp.begin();
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n;cin>>n;
  //int hoge[n+10]={};
  A.resize(n);
  for(int i=0;i<n;i++){
    cin>>A[i];
  }
  reverse(ALL(A));
  cout<<lis(n)<<endl;
  return 0;
}


Measured memory_bytes: 3712
#include<bits/stdc++.h>
using namespace std;
int main (){
  int A,B,C,K;
  string ans = "No";
  cin >> A >> B >> C >> K;
  for(int i=0;i<K;i++){
    if(A>=B) B*=2;
    else if(B>=C) C*=2;
  }
  if(A<B && B<C)ans = "Yes";
  cout << ans << endl;
}


Measured memory_bytes: 3648
import java.io.*;

class Main {
	public static void main(String[] args){
		int W, H, x, y, r;
		try{
			BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
			
			String[] line = br.readLine().split(" ");
			W = Integer.parseInt(line[0]);
			H = Integer.parseInt(line[1]);
			x = Integer.parseInt(line[2]);
			y = Integer.parseInt(line[3]);
			r = Integer.parseInt(line[4]);
			
			if( W >= (x+r) && H >= (y+r) && (y-r) >= 0 && (x-r) >= 0){
				System.out.println("Yes");
			} else {
				System.out.println("No");
			}
		} catch(Exception e){
		}
	}
}
			

Measured memory_bytes: 24316
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;

int N, M;
vector <vector<int>> sparseTable;
vector <vector<int>> B;
vector<ll> dist;

void builldSparseTable(int ind, vector <int> &arr){
    int log_len_ceil = 32 - __builtin_clz(N);
    sparseTable[ind].resize(N*log_len_ceil+1);
    int potencias_2 = 2;
    for (int i = 0; i < log_len_ceil; i++) {
        potencias_2 *= 2;
        if (i == 0){
            potencias_2 = 0;
        } else if (i == 1){
            potencias_2 = 1;
        }
        for (int j = 0; j < N; ++j) {
            if (i == 0){
                sparseTable[ind][j] = arr[j];
            } else {
                sparseTable[ind][i*N+j] = max(sparseTable[ind][(i-1)*N + j], sparseTable[ind][(i-1)*N + j + potencias_2]);
            }
            if (j == N - potencias_2){
                break;
            }
        }
    }
}

int query(int b, int i, int j){ //inclusive
    if (i>j) swap(i,j);
    int log_query = 31 - __builtin_clz(j-i+1);
    int largo_query = 1 << log_query;
    return max(sparseTable[b][N*log_query + i], sparseTable[b][N*log_query + j-largo_query+1]);
}

ll total_dist(int i, int j){
    if (!j) return 0;
    j--;
    ll ans = dist[j];
    if (i) ans -= dist[i-1];
    return ans;
}

ll memo[5050];

void dp(int l, int r, int optl, int optr){
    if (l>r) return;
    int mid = (l+r)/2;
    ll val = -1e18, pos = 0;
    for (int i = optl; i <= min(mid, optr); ++i) {
        ll aux = -total_dist(i, mid);
        for (int j = 0; j < M; ++j) {
            aux += query(j, i, mid);
        }
        if (aux > val) val = aux, pos = i;
    }
    memo[mid] = val;
    dp(l, mid-1, optl, pos);
    dp(mid+1, r, pos, optr);
}


int main() {
    ios::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    cin >> N >> M;
    dist.resize(N-1);
    for (int i = 0; i < N-1; ++i) {
        cin >> dist[i];
        if (i) dist[i] += dist[i-1];
    }
    B.assign(M, vector<int>(N));
    for (int j = 0; j < N; ++j) for (int i = 0; i < M; ++i) cin >> B[i][j];
    sparseTable.assign(M, vector<int>());
    for (int k = 0; k < M; ++k) {
        builldSparseTable(k, B[k]);
    }
    ll ans = -1e18;
    dp(0, N-1, 0, N-1);
    for (int l = 0; l < N; ++l) {
        ans = max(ans, memo[l]);
    }
    cout << ans << "\n";
}



Measured memory_bytes: 58376
counter=0

def insert(lst,n,g):
    for i in range(g,n):
        v=lst[i]
        j=i-g
        global counter
        while j>=0 and lst[j]>v:
            lst[j+g]=lst[j]
            j=j-g
            counter+=1
        lst[j+g]=v

n=int(input())
lst=[int(input()) for _ in range(n)]
work=n//4
glst=[]
while work>=0:
    glst.append(work+1)
    if work==0 : break
    work//=4

m=len(glst)
for i in range(m):
    insert(lst,n,glst[i])

print(m)
print(" ".join(map(str,glst)))
print(counter)
for i in range(n): print(lst[i])



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

typedef long long int ll;
using namespace std;

int main() {
	ll N, K;
	cin >> N >> K;

	ll a = N % K;
	ll min;

	if (K > 2 * a) {
		min = a;
	}
	else {
		min = K - a;
	}

	cout << min << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define dot cout<< setprecision(20)<<endl;
#define vsor(x) sort(x.begin(),x.end());
#define vrev(x) reverse(x.begin(),x.end());
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define move(i) for(int i=0;i<4;i++)
#define bit(b,n) for(int b=0;b<(1<<(ll)(n));b++)

using namespace std;

int main(){
    ll k;
    cin>>k;
    ll ans=0;
    if(k%5==0||k%2==0)cout<<-1<<endl;
    else{
        int n=0;
        while(true){
            n=(n*10+7)%k;
            ans++;
            if(n==0){
                break;
            }
        }
            cout<<ans<<endl;
    }
    }

Measured memory_bytes: 3592
#include <iostream>

using namespace std;

int main()
{
 int n,i,k;
 cin>>n>>k;
 char a[n];
 cin>>a;
 for (i=0;i<n;i++){
  if (i+1==k){
   cout<<(char)((int)a[i]+32);
  }
  else {
   cout<<a[i];
  }
 }
 return 0;
}

Measured memory_bytes: 256
/************************************
/ AUTHOR : YATHARTH GOSWAMI         /  
/ ALIAS : hacker_yg                 /
/ INSTITUTE : IIT Kanpur            /
************************************/
//          TEMPLATE                //

#include <bits/stdc++.h>

#define ll long long
#define MOD 1000000007
#define pb push_back
#define mp make_pair
#define F first
#define S second

using namespace std;

int main(){
    ll x;
    cin >> x;
    ll c = 100;
    ll d = 0;
    while (c + c/100 < x) {
        d++;
        c = c + c/100;
    }
    cout << d+1;
    return 0;
}




Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
int main(){
  long N,Y;cin>>N>>Y;
  for(long i=0;i<=N;i++){
    for(long j=0;i+j<=N;j++){
      long k=N-(i+j);
      if(10000*i+5000*j+1000*k==Y){
        cout<<i<<" "<<j<<" "<<k;
        return 0;
      }
    }
  }
  cout<<"-1 -1 -1";
}

Measured memory_bytes: 256
#include <stdio.h>

int main()
{
    int n;
    scanf("%d",&n);
    
    int arr[n][3];
    for (int i = 0; i<n; i++){
        scanf("%d", &arr[i][0]);
        scanf("%d", &arr[i][1]);
        scanf("%d", &arr[i][2]);
    }
    
    int arr2[n][2];
    arr2[0][0] = arr[0][0];
    arr2[0][1] = arr[0][1] + arr[0][2];
    for (int k = 1; k<n; k++){
        arr2[k][0] = arr[k][0] - arr[k-1][0];
        arr2[k][1] = arr[k][1] - arr[k-1][1] + arr[k][2] - arr[k-1][2];
    }
    
    int c = 0;
    
    for (int j = 0; j<n; j++){
        if (arr2[j][1] <= arr2[j][0]){
            if (arr2[j][1]%2 == 0 && arr2[j][0]%2 == 0){
                c++;
            }
            else if (arr2[j][1]%2 != 0 && arr2[j][0]%2 != 0){
                c++;
            }
        }
    }
    
    if (c == n){
        printf("Yes\n");
    }
    else {
        printf("No\n");
    }

    return 0;
}

Measured memory_bytes: 2176
#include <stdio.h>

int main(void) {
	unsigned long long n, i, d;
	
	scanf("%llu", &n);
	d=n-1;
	for(i=1; i*i<=n; ++i){
		if(n%i==0){
			unsigned long long d0 = (i-1)+(n/i-1);
			if(d0 < d) d = d0;
		}
	}
	printf("%llu\n", d);
	return 0;
}


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

int main(){
  int X,Y;
  cin>>X>>Y;
  int a,b,c,d,ans=2147483647;
  a=Y-X;
  if(a>=0)
    ans=a;
  b=-Y-X;
  if(b>=0&&b+1<ans)
    ans=b+1;
  c=Y+X;
  if(c>=0&&c+1<ans)
    ans=c+1;
  d=-Y+X;
  if(d>=0&&d+2<ans)
    ans=d+2;
  cout<<ans<<endl;
}

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

using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define erep(i, n) for (ll i = 0; i <= (ll)(n); ++i)
#define FOR(i,a,b) for (ll i = (a); i < (ll)(b); ++i)
#define EFOR(i,a,b) for (ll i = (a); i <= (ll)(b); ++i)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } }


int main() {
    int n; cin >> n;
    vector<ll> a(n);
    vector<ll> b(n);
    vector<ll> c(n);
    rep(i, n) cin >> a[i];
    rep(i, n) cin >> b[i];
    rep(i, n) cin >> c[i];
    sort(a.begin(), a.end());
    sort(b.begin(), b.end());
    sort(c.begin(), c.end());

    // 全てのbに対して、それより小さいaの個数と大きいcの個数を求める
    ll ans = 0;
    rep(i, n) {
        auto itr = upper_bound(c.begin(), c.end(), b[i]);
        ll bc = c.size() - (itr - c.begin());
        itr = lower_bound(a.begin(), a.end(), b[i]);
        ll a_itr = itr - a.begin();
//        cout << b[i] << endl;
//        cout << a_itr << endl;
//        cout << bc << endl;
        ans += bc * a_itr;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 2560
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx")
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin >> N;
  vector<double> xt(N + 1), yt(N + 1);
  for (int i = 0; i < N; i++){
    int x, y;
    cin >> x >> y;
    xt[i] = x * (double) 1000000 / (1000000 - 100);
    yt[i] = y * (double) 1000000 / (1000000 - 100);
  }
  xt[N] = xt[0];
  yt[N] = yt[0];
  vector<double> dx1(N), dy1(N);
  for (int i = 0; i < N; i++){
    dx1[i] = xt[i + 1] - xt[i];
    dy1[i] = yt[i + 1] - yt[i];
  }
  int Q;
  cin >> Q;
  for (int i = 0; i < Q; i++){
    double x, y;
    cin >> x >> y;
    bool ok = true;
    for (int j = 0; j < N; j++){
      if (dx1[j] * (y - yt[j]) - dy1[j] * (x - xt[j]) < 0){
        ok = false;
        break;
      }
    }
    if (ok){
      cout << 1 << endl;
    } else{
      cout << 0 << endl;
    }
  }
}


Measured memory_bytes: 3672
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long a = sc.nextLong()-1;
		long b = sc.nextLong();
		long c = sc.nextLong();
		long d = sc.nextLong();
		
		long l = lcm(c,d);

		long countA = a - (a/c + a/d - a/l);
		long countB = b - (b/c + b/d - b/l);
		
		long ans = countB - countA;
		System.out.println(ans);
		
		
		sc.close();
	}
	
	public static long lcm(long a, long b)  {
		long c = a * b;
		long temp;
		while ((temp = a % b) != 0) {
			a = b;
			b = temp;
		}
		
		return c/b;
	}
	
}


Measured memory_bytes: 23764
#include<stdio.h>
int main(void){
    int a,b;
    while(scanf("%d%d",&a,&b)!=EOF){
        a+=b;
        b=1;
        while(a>=10){
            a/=10;
            b++;
        }
        printf("%d\n",b);
    }
    return 0;
}

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

int64_t solve(int64_t n, int64_t k) {
  while (n % k == 0) {
    n /= k;
  }
  return n % k == 1;
}

int main() {
  int64_t n, result = 0;
  cin >> n;
  for (int64_t d = 1; d * d <= n; ++d) {
    if (n % d == 0) {
      if (d > 1) {
        result += solve(n, d);
      }
      if (n / d != d) {
        result += solve(n, n / d);
      }
    }
  }
  --n;
  for (int64_t d = 1; d * d <= n; ++d) {
    if (n % d == 0) {
      if (d > 1) {
        ++result;
      }
      if (d != n / d) {
        ++result;
      }
    }
  }
  cout << result;
  return 0;
}

Measured memory_bytes: 3152
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 1e5 + 5;
int n, k;
string s;
int sum[maxn];
int main() {
//    freopen("in.txt", "r", stdin);
//    freopen("out.txt", "w", stdout);
    while(cin >> s) {
        int cnt1 = 0, cnt2 = 0;
        for(int i = 0; i < s.size(); ++i) {
            if(i & 1) {
                if(s[i] == '0') ++cnt1;
                else ++cnt2;
            }
            else {
                if(s[i] == '1') ++cnt1;
                else ++cnt2;
            }
        }
        cout << min(cnt1, cnt2) << endl;
    }
    return 0;
}


Measured memory_bytes: 512
#include<stdio.h>

int main(void){
  int N,cnt=0;
  scanf("%d",&N);
  int p[N];
  for(int i=0;i<N;i++){
    scanf("%d",&p[i]);
  }
  
  for(int i=0;i<N-2;i++){
    if( (p[i]<p[i+1] && p[i+1] < p[i+2])|| (p[i]>p[i+1] && p[i+1] > p[i+2])) cnt++;
  }
  printf("%d",cnt);
  return 0; 
}

Measured memory_bytes: 128
#include <stdio.h>

int remain(int n)
{

  int x,sco[n],ave,max,min,i,j,maxcou,mincou;

  for(i=0;i<n;i++)sco[i]=0;
  ave=0;max=0;min=1000;
  
  for(i=0;i<n;i++)
    scanf("%d", &sco[i]);
  for(i=0;i<n;i++){
    if(max<=sco[i]){
      max=sco[i];
      maxcou=i;
    }
    if(min>=sco[i]){
      min=sco[i];
      mincou=i;
    }
  }
  sco[maxcou]=0;
  sco[mincou]=0;

  for(i=0;i<n;i++)
    ave=ave+sco[i];
  ave=ave/(n-2);

  return (ave);
}
  

int main(void)
{

  int n,ans;

  while(1){
    scanf("%d", &n);
    if(n==0)break;
    ans=remain(n);
    printf("%d\n", ans);
  }

  return 0;
}

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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#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 uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcount

#define INF INT_MAX/3

struct UnionFind{
  vector<int> v;
  UnionFind(int n) : v(n, -1) {}
  void init(){ for(int i = 0;i < v.size();i++)v[i]=-1; }
  int find(int x) { return v[x] < 0 ? x : v[x] = find(v[x]); }
  bool unite(int x, int y) {
    x = find(x); y = find(y);
    if (x == y) return false;
    if (-v[x] < -v[y]) swap(x, y);
    v[x] += v[y]; v[y] = x;
    return true;
  }
  bool root(int x) { return v[x] < 0; }
  bool same(int x, int y) { return find(x) == find(y); }
  int size(int x) { return -v[find(x)]; }
};

ll n,m;
ll cnt[3];
bool used[202020];
ll c[202020];
vector<ll> g[202020];

bool dfs(ll v,ll nc){
  c[v]=nc;
  for(ll nv : g[v]){
    if(c[nv]==-1&&!dfs(nv,1-nc))return false;
    else{
      if(c[nv]==nc)return false;
    }
  }
  return true;
}

int main(){
	cin>>n>>m;
  UnionFind uf(n);
  rep(i,m){
    ll a,b;
    cin>>a>>b;
    a--; b--;
    uf.unite(a,b);
    g[a].push_back(b);
    g[b].push_back(a);
  }
  memset(c,-1,sizeof(c));
  rep(i,n){
    if(used[uf.find(i)])continue;
    used[uf.find(i)]=true;
    if(uf.size(i)==1)cnt[2]++;
    else{
      bool nibu=dfs(i,0);
      cnt[nibu]++;
    }
  }
  ll res=cnt[2]*n*2-cnt[2]*cnt[2];
  res+=(cnt[0]+cnt[1])*(cnt[0]+cnt[1]);
  res+=cnt[1]*cnt[1];
  cout<<res<<endl;
	return 0;
}


Measured memory_bytes: 13312
#include <iostream>
#include <algorithm>

using namespace std;
static const int MAX = 200000;



int selectionsort(int A[],int n){
  int count = 0;
  int i,j,t;
  int minj;

  for(i=0;i<n-1;i++){
    minj = i;
    for(j=i;j<n;j++){
        if(A[j]<A[minj]){
          minj = j;
        }
    }
    t = A[i];
    A[i]=A[minj];
    A[minj]= t;

    if(i != minj) count++;

  }
  return count;
}



int main(){
  int A[MAX],n;
  int count;

  cin >> n;

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

   count = selectionsort(A,n);

  for (int i=0;i<n;i++){
    if(i) cout <<" ";
    cout << A[i];
  }
  cout << endl;

  cout << count << endl;

  return 0;
}

Measured memory_bytes: 3108
#include <iostream>

int main()
{
	int n;
	std::string s;
	std::cin >> n >> s;
	
	int max = 0;
	int x = 0;
	for (char c : s) {
		if (c == 'I') x++; else x--;
		if (x > max) max = x;
	}
	
	std::cout << max << std::endl;
	
	return 0;
}


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

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n; cin>>n;
  string s; cin>>s;
  bool j=true;
  int m=s.size();
  if(m%2==1) j=false;
  else rep(i,m/2) if(s.at(i)!=s.at(m/2+i)) j=false;
  (j)?cout<<"Yes"<<endl:cout<<"No"<<endl;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
from itertools import *
from functools import *
from collections import *
from heapq import heapify, heappop, heappush, heappushpop

from math import gcd

INF = float('inf')
NIL = - 1

n = int(input())
ans = 0
for i in range(1, n + 1):
    for j in range(1, n + 1):
        for k in range(1, n + 1):
            ans += gcd(gcd(i, j), k)
print(ans)




Measured memory_bytes: 74300
N = int(input())
H = list(map(int,input().split()))
cmax = 0
cnt = 0
for i in range(1,N):
    if H[i]<=H[i-1]:
        cnt += 1
    else:
        cmax = max(cmax,cnt)
        cnt = 0
cmax = max(cmax,cnt)
print(cmax)

Measured memory_bytes: 85488
from sys import exit, setrecursionlimit
from functools import reduce
from itertools import *
from collections import defaultdict
from bisect import bisect

def read():
  return int(input())

def reads():
  return [int(x) for x in input().split()]

setrecursionlimit(1000000)

(a, b) = reads()

if a == 1:
  a = 14
if b == 1:
  b = 14

if a > b:
  print("Alice")
elif a < b:
  print("Bob")
else:
  print("Draw")


Measured memory_bytes: 3828
#include<cstdio>
#include<cstring>
#define MAXN 100005
#define M 1000000007
char s[2*MAXN+5];
long long k[2*MAXN+5];
long long Na[MAXN+5],Nc[MAXN+5],Fl[MAXN+5],Fr[MAXN+5];
long long ansl[MAXN+5];
int init()
{
	long long x=MAXN;
	long long l=1;
	long long cnt=0;
	k[cnt]=l;
	while(x--)
	{
		l=(l*3)%M;
		k[++cnt]=l;
	}
}
int CMP(int x)
{
	long long ans=0;
	ans=((((Na[x-1]*Nc[x+1])%M)*k[Fl[x-1]+Fr[x+1]])%M+(((Na[x-1]*Fr[x+1])%M)*k[Fl[x-1]+Fr[x+1]-1])%M+(((Fl[x-1]*Nc[x+1])%M)*k[Fl[x-1]+Fr[x+1]-1])%M+(((Fl[x-1]*Fr[x+1])%M)*k[Fl[x-1]+Fr[x+1]-2])%M);
	return ansl[x]=ans%M;
}
int main()
{
	init();
	scanf("%s",s+1);
	int lens=strlen(s+1);
	for(int i=1;i<=lens;i++)
	{
		Na[i]=Na[i-1];
		Fl[i]=Fl[i-1];
		if(s[i]=='A') Na[i]+=1;
		if(s[i]=='?') Fl[i]+=1;
		//printf("%d:%d\n",Na[i],Fl[i]);
	}
	for(int i=lens;i>=1;i--)
	{
		Nc[i]=Nc[i+1];
		Fr[i]=Fr[i+1];
		if(s[i]=='C') Nc[i]+=1;
		if(s[i]=='?') Fr[i]+=1;
	}
	for(int i=1;i<=lens;i++)
	{
		if(s[i]=='B'||s[i]=='?')
			CMP(i);
	}
	long long cnt=0;
	for(int i=1;i<=lens;i++)
	{
		cnt=(cnt+ansl[i])%M;
	}
	printf("%lld",cnt%M);
}


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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  string s;
  cin >> s;
  
  if (s == "RRR") cout << 3 << '\n';
  else if (s == "SSS") cout << 0 << '\n';
  else if (s == "RRS" || s == "SRR") cout << 2 << '\n';
  else cout << 1 << '\n';
}

Measured memory_bytes: 3640
N, M, Q = gets.split.map(&:to_i)
A, B, C, D = Q.times.map { gets.split.map(&:to_i) }.transpose
puts (0...M).to_a.repeated_combination(N).map { |arr| Q.times.map { |i| arr[B[i] - 1] - arr[A[i] - 1] == C[i] ? D[i] : 0 }.sum }.max

Measured memory_bytes: 16660
import numpy as np
n = input()
ans = 100000000
arr = list(map(int,input().split()))
for a in arr:
    ind = 1
    while (True):
        if a%(2**ind) == 0:
            ind += 1
        else:
            break
    ind -= 1
    if ind < ans:
        ans = ind

print(ans)



Measured memory_bytes: 12396
#include<deque>
#include<iostream>
#include<string>

int main()
{
	std::string str;
	std::cin >> str;

	int heightRight = 0;
	for (char c : str)
	{
		if ('\\' == c)
		{
			heightRight -= 1;
		}
		else if ('/' == c)
		{
			heightRight += 1;
		}
	}
	int heightLeft = 0;

	auto searchDown = [&str, &heightLeft, &heightRight](int& targetPosition, int& targetHeight)
	{
		const char characterDown = &heightLeft == &targetHeight ? '\\' : '/';
		const char characterUp = &heightLeft == &targetHeight ? '/' : '\\';
		const int direction = &targetHeight == &heightLeft ? 1 : -1;
		for (; 0 <= targetPosition && str.size() > targetPosition && characterDown != str[targetPosition]; targetPosition += direction)
		{
			if (characterUp == str[targetPosition])
			{
				targetHeight += 1;
			}
		}
	};
	auto researchFlood = [&str, &heightLeft, &heightRight](int& targetPosition, int& targetHeight)
	{
		const char characterDown = &heightLeft == &targetHeight ? '\\' : '/';
		const char characterUp = &heightLeft == &targetHeight ? '/' : '\\';
		const int direction = &targetHeight == &heightLeft ? 1 : -1;
		const int startHeight = targetHeight;
		int area = 0;
		targetPosition += direction;
		targetHeight -= 1;
		while (startHeight > targetHeight)
		{
			area += startHeight - targetHeight;
			if (characterDown == str[targetPosition])
			{
				targetHeight -= 1;
			}
			else if (characterUp == str[targetPosition])
			{
				targetHeight += 1;
			}
			targetPosition += direction;
		}
		return area;
	};

	int positionLeft = 0;
	int positionRight = static_cast<int>(str.size()) - 1;
	std::deque<int> areaLeft;
	std::deque<int> areaRight;
	int areaSum = 0;
	searchDown(positionLeft, heightLeft);
	searchDown(positionRight, heightRight);
	while (positionLeft < positionRight)
	{
		if (heightLeft < heightRight)
		{
			areaLeft.emplace_back(researchFlood(positionLeft, heightLeft));
			areaSum += areaLeft.back();
			if (positionLeft >= positionRight)
			{
				break;
			}
			searchDown(positionLeft, heightLeft);
		}
		else
		{
			areaRight.emplace_front(researchFlood(positionRight, heightRight));
			areaSum += areaRight.front();
			if (positionLeft >= positionRight)
			{
				break;
			}
			searchDown(positionRight, heightRight);
		}
	}

	std::cout << areaSum << std::endl;
	std::cout << (areaLeft.size() + areaRight.size());
	if (!areaLeft.empty())
	{
		std::cout << ' ';
	}
	for (int index = 0; static_cast<int>(areaLeft.size()) - 1 > index; ++index)
	{
		std::cout << areaLeft[index] << ' ';
	}
	if (!areaLeft.empty())
	{
		std::cout << areaLeft.back();
	}
	if (!areaRight.empty())
	{
		std::cout << ' ';
	}
	for (int index = 0; static_cast<int>(areaRight.size()) - 1 > index; ++index)
	{
		std::cout << areaRight[index] << ' ';
	}
	if (!areaRight.empty())
	{
		std::cout << areaRight.back();
	}
	std::cout << std::endl;
}



Measured memory_bytes: 3268
#pragma region header
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <math.h>
using namespace std;
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
#define rev(i, n) for(int i = (int)(n - 1); i >= 0; i--)
#define rev1(i, n) for(int i = (int)(n); i > 0; i--)
#define pb push_back
#define ts to_string
#define all(v) (v).begin(), (v).end()
#define vi vector<int>
#define vvi vector<vector<int>>
#define vc vector<char>
#define vvc vector<vector<char>>
#define vs vector <string>
#define vvs vector <vector<string>>
#define pq  priority_queue<int>
using ll = long long;
/* ----------------よく使う数字や配列----------------- */
int dx[] = { 1,0,-1,0 };
int dy[] = { 0,1,0,-1 };
constexpr ll mod = 1e9 + 7;
constexpr long double pi = 3.141592653589793238462643383279;
/* ----------------------end----------------------- */
/* --------------------ライブラリ-------------------- */
ll fact(int i) {       //階乗
    if (i == 0) return 1;
    return (fact(i - 1)) * i % mod;
}
ll gcd(ll a, ll b) {        //最大公約数
    if (b == 0) return a;
    return gcd(b, a % b);
}
ll lcm(ll a, ll b) {      //最小公倍数
    return a * b / gcd(a, b);
}
bool isprime(ll a)//素数判定、primeならtrue,違うならfalse
{
    if (a < 2) return false;
    else if (a == 2) return true;
    else if (a % 2 == 0) return false;
    double m = sqrt(a);
    for (int i = 3; i <= m; i += 2)
    {
        if (a % i == 0)
        {
            return false;
        }
    }
    // 素数である
    return true;
}
ll ketasum(ll n) {    //各桁の和
    ll sum = 0;
    while (n != 0) {
        sum += n % 10;
        n /= 10;
    }
    return sum;
}
ll kind(vi SYURUI) {//vector<int>型の配列の要素の種類数
    int size = SYURUI.size();
    sort(all(SYURUI));
    int cnt = 1;
    rep(i, size-1) {
        if (SYURUI[i] != SYURUI[i + 1])cnt++;
    }
    return cnt;
}
/* ----------------------end----------------------- */
#pragma endregion
signed main() {
    int N, A, B; cin >> N >> A >> B;
    vi P(N); rep(i, N)cin >> P[i];
    int _1 = 0;
    int _2 = 0;
    int _3 = 0;
    rep(i, N) {
        if (P[i] <= A)_1++;
        else if (P[i] <= B)_2++;
        else _3++;
    }
    cout << min({ _1,_2,_3 }) << endl;
}





Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<n; ++i)
#define rep1(i, n) for (int i=1; i<=n; ++i)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
constexpr ll  MOD = (1e9+7);
constexpr int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
constexpr int lcm(int a, int b) { return a / gcd(a, b) * b; }

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;
}
ll factorial(ll n, ll m=2) {
    // calculate n!
    m = max(2LL, m);
    ll rtn = 1;
    for (ll i=m; i<=n; i++) {
        rtn = (rtn * i) % MOD;
    }
    return rtn;
}
ll modinv(ll a, ll m) {
    ll b = m, u = 1, v = 0;
    while (b) {
        ll t = a / b;
        a -= t * b;
        swap(a, b);
        u -= t * v;
        swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}
ll modpow(ll a, ll n) {
    ll res = 1;
    while (n > 0) {
        if (n & 1)
            res = res * a % MOD;
        a = a * a % MOD;
        n >>= 1;
    }
    return res;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    int n; cin >> n;
    vector<vector<int>> mozi(n, vector<int>('z'-'a'+1, 0));
    rep(i, n) {
        string s; cin >> s;
        rep(j, s.size()) {
            mozi[i][s[j] - 'a']++;
        }
    }
    string ans = "";
    rep(j, 'z'-'a'+1) {
        ll tmp = INF;
        rep(i, n) {
            chmin(tmp, (ll)mozi[i][j]);
        }
        rep(i, tmp) ans += 'a' + j;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<queue>
#include<cmath>
#include<map>
using namespace std;
typedef long long ll;
ll inf = 100000000;
ll w[205];
ll v[205];
ll c[200005];
ll h[200005];
ll dp[105][100005];
typedef pair<int, int> P;

int main() {
	ll n, k;
	cin >> n >> k;
	ll sum = 0;
	for (int i = 0; i < n; i++) {
		cin >> h[i];
	}
	sort(h, h + n);
	for (int i = 0; i < n - k; i++) {
		sum += h[i];
	}
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 2432
# encoding:utf-8
import copy
import numpy as np
import random

c = []
for i in range(3):
    tem = [int(i) for i in input().split()]
    c.append(tem)

a = [0 for i in range(3)]
b = [0 for i in range(3)]
for i in range(3):
    min_line =  min(c[i])
    for j in range(3):
        c[i][j] -= min_line
    # a[i] += min_line

# print(c)

c = np.array(c)

for i in range(3):
    min_row = min(c[:,i])
    for j in range(3):
        c[j,i] -= min_row

if np.all(c==0):
    ans = True
else:
    ans = False
    
if ans:
    print("Yes")
else:
    print("No")


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

int main(){
  int A,B,M;
  cin >> A >> B >> M;
  vector<int> a(A);
  for(int i=0;i<A;i++)  cin >> a.at(i);
  vector<int> b(B);
  for(int i=0;i<B;i++)  cin >> b.at(i);
  vector<int> x(M),y(M),c(M);
  for(int i=0;i<M;i++){
    cin >> x.at(i) >> y.at(i) >> c.at(i);
    x.at(i)--;
    y.at(i)--;
  }

  int ans=1e9;
  int mi_a=1e9;
  int mi_b=1e9;
  for(int i=0;i<A;i++)  mi_a=min(mi_a,a.at(i));
  for(int i=0;i<B;i++)  mi_b=min(mi_b,b.at(i));
  ans=mi_a+mi_b;

  for(int i=0;i<M;i++){
    ans=min(ans,a.at(x.at(i))+b.at(y.at(i))-c.at(i));
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 2176
#include <bits/stdc++.h>
#include <fstream>
using namespace std;
 
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define Eunique(v) v.erase(unique(all(v)),v.end())
#define pvec(v) rep(i,v.size()){cout << v[i] << " ";};cout<<endl;
#define pb push_back
#define pf push_front
#define mod 1e9+7
#define m_p make_pair
 
typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;
typedef pair<int,int> pii;
typedef vector<pii> vpii;
typedef pair<ll,ll> pll;
typedef vector<pll> vpll;
typedef vector<vector<int>> vvi;
const double pi = acos(-1.0);
 
ll gcd(ll x, ll y) { return (y == 0) ? x : gcd(y, x % y); }
ll lcm(ll x, ll y) { return x * y / gcd(x, y); }

bool IsPrime(int num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false;

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            return false;
        }
    }
    return true;
}

int main()
{
    ll a,b,c,d;
    cin >> a >> b >> c >> d;
    cout << min(a,b)+min(c,d) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define eps 1e-9

using namespace std;
typedef double db;
struct P{
    db x, y;
    P(){}
    P(db x, db y) : x(x) , y(y) {}
    P operator - (P a){ return P(x-a.x, y-a.y); }
    db times(P a){ return x*a.y-y*a.x; }
};
typedef P V;
struct L{ P p, q; };

int sign(db x){ return x<-eps ? -1 : x>eps; }

bool intersection(P p1, P q1, P p2, P q2){
    if(max(p1.x,q1.x)+eps < min(p2.x,q2.x)) return false;
    if(max(p1.y,q1.y)+eps < min(p2.y,q2.y)) return false;
    if(max(p2.x,q2.x)+eps < min(p1.x,q1.x)) return false;
    if(max(p2.y,q2.y)+eps < min(p1.y,q1.y)) return false;
    int t1=sign( (p2-p1).times(q1-p1) )*sign( (q1-p1).times(q2-p1) ), 
    t2=sign( (p1-p2).times(q2-p2) )*sign( (q2-p2).times(q1-p2) );
    return (t1>=0) && (t2>=0);
}

int main(){
    //freopen("owo.in","r",stdin);
    L s1, s2;
    int n;
    cin >> n;
    while(n--){
        scanf("%lf%lf%lf%lf%lf%lf%lf%lf", &s1.p.x, &s1.p.y, &s1.q.x, &s1.q.y, &s2.p.x, &s2.p.y, &s2.q.x, &s2.q.y);
        printf("%d\n", intersection(s1.p, s1.q, s2.p, s2.q));
    }
    return 0;
}


Measured memory_bytes: 3224
#include<bits/stdc++.h>
#define int long long int
using namespace std;
int n,i,j,tree[200001*4],h[200001],w[200001],num=1,res;
int getmax(int l,int r){
	l+=num-1;r+=num-1;
	res=0;
	while(l<=r){
		if(l%2==1)res=max(res,tree[l]),l++;
		if(r%2==0)res=max(res,tree[r]),r--;
		l/=2;r/=2;
	}
	return res;
}
void update(int pos,int val){
	pos+=num-1;
	if(tree[pos]>=val)return;
	tree[pos]=val;
	pos/=2;
	while(pos>0)
		tree[pos]=max(tree[pos*2+1],tree[pos*2]),pos/=2;
}
main(){
	cin>>n;
	vector<int>a(n);
	for(i=0;i<n;i++)scanf("%d",&h[i]),a[i]=h[i];
	for(i=0;i<n;i++)scanf("%d",&w[i]);
	sort(a.begin(),a.end());
	while(num<n)num*=2;
	for(i=0;i<n;i++){
		j=lower_bound(a.begin(),a.end(),h[i])-a.begin();
		update(j+1,getmax(1,j)+w[i]);
	}
	cout<<tree[1];
}

Measured memory_bytes: 9984
N, K = map(int, input().split())
S = list(input())

if S[K-1] == "A":
  S[K-1] = "a"
elif S[K-1] == "B":
  S[K-1] = "b"
elif S[K-1] == "C":
  S[K-1] = "c"

print("".join(S))

Measured memory_bytes: 38384
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        int m = Integer.parseInt(sc.next());
        boolean[] isBroken = new boolean[n+1];
        for(int i=0;i<m;i++){
            isBroken[Integer.parseInt(sc.next())] = true;
        }
        long dp[] = new long[n+1];
        dp[0] = 1;
        if(!isBroken[1]){
            dp[1] = 1;
        }
        for(int i=2;i<=n;i++){
            if(!isBroken[i]){
                dp[i] = (dp[i-1]+dp[i-2])%1000000007;
            }
        }
        System.out.println(dp[n]);
    }
}

Measured memory_bytes: 42804
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
// memo  fixed  setprecision(20);
using vvll = vector<vector<ll>>;
ll mod =1e9+7;
/*"itob" int to "N"base */           template<typename TypeInt> string itob(const TypeInt v, int base){static const char table[] = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";string ret;static numeric_limits<TypeInt> t;TypeInt n = v;if (t.is_signed) {if (v < 0) n *= -1;}while (n >= base) {ret += table[n%base];n /= base;}ret += table[n];if (t.is_signed) {if (v < 0 && base == 10) ret += '-';}reverse(ret.begin(), ret.end());return ret;}
/*"chmin" a = MAX*/                  template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
/*"chmax" a = MIN*/                  template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
/*"ctoi"  char to int*/              int ctoi(char c) {return c-'0';}
/*"gcd"   MAX Euclidean */           ll gcd(ll a,ll b){if(b==0)return a; return gcd(b,a%b);}
    /*"lcm"   MIN*/                      ll lcm(ll a,ll b){ll g = gcd(a,b);return a/g*b;}
/*"primecheck"If prime,return true.*/bool primecheck(ll n){if(n < 2) return false;else{for(int i = 2; i * i <= n; i++){if(n % i == 0) return false;}return true;}}
string  reverserange(string s,ll a,ll b){reverse(s.begin()+a-1,s.begin()+b); return s;}
ll modpow(ll a,ll n, ll mod){ll res = 1;while(n>0){if (n%2==1){res = res * a % mod;}a = a * a % mod;n/=2;}return res;}
int main() {
    int n;
    cin >>n;
    vector<pair<int,int>>a(n);
    for(int i=0;i<n;i++){
        int z,zz;
        cin >>z >>zz;
        a.at(i)=make_pair(z,zz);
    }
    ll che=0;
    for(int i=0;i<n;i++){
        if(a.at(i).first==a.at(i).second)che++;
        else che=0;
        if(che==3){
            cout<<"Yes"<<endl;
            return 0;
        }
    }
    cout<<"No"<<endl;
}
    
 

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

int n,k,h,sum;

int main()
{
	cin>>n>>k;
	
	for(int i=1; i<=n; i++)
		{
			cin>>h;
			if(h>=k)sum++;
		}
	
	cout<<sum<<endl;
	
	return 0;
}

Measured memory_bytes: 256
import java.util.*;
      class Main{
          public static void main(String[]args){
              Scanner cin=new Scanner(System.in);
              int numS;
              int numC;
              int count;
              int kx;
              int ky;
              int result;
              int temp;
             
              numS = cin.nextInt();
              numC = cin.nextInt();
              int student[] = new int[2*numS];
              int checkp[] = new int[2*numC];
              count = 0;
              for(int i=0;i<numS;i++ ){
                  student[count]=cin.nextInt();
                  count++;
                 student[count]=cin.nextInt();
                  count++;
             }
              count = 0;
              for(int j=0;j<numC;j++ ){
                  checkp[count]=cin.nextInt();
                  count++;
                  checkp[count]=cin.nextInt();
                  count++;
              }
              for(int k=0;k<numS;k++){
                  kx = student[2*k];
                  ky = student[2*k+1];
                  result = 0;
                  temp = 900000000;
                  for(int m=0;m<numC;m++){
                      if(temp > Math.abs(kx-checkp[2*m])+Math.abs(ky-checkp[2*m+1])){
                          temp = Math.abs(kx-checkp[2*m])+Math.abs(ky-checkp[2*m+1]);
                          result = m+1;
                       }
                  }    
                  System.out.println(result);
              }
          }
      }


Measured memory_bytes: 21844
#include "bits/stdc++.h"
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a),i##_len=(b);i<i##_len;++i)
#define MSVC_UNKO(x) x
#define rep(...) MSVC_UNKO(_overload3(__VA_ARGS__,repi,_rep,_rep)(__VA_ARGS__))
#define all(c) c.begin(),c.end()
#define mp make_pair
#define write(x) cout<<(x)<<"\n"
using namespace std; typedef long long ll;
typedef vector<int> vi; typedef vector<ll> vll; template<class T>using vv = vector<vector<T>>;
template<class T>vv<T> vvec(size_t n, size_t m, T v) { return vv<T>(n, vector<T>(m, v)); }
template<class T>bool chmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }
template<class T>bool chmin(T& a, const T& b) { return b < a ? a = b, 1 : 0; }
constexpr int INF = 1 << 28, MOD = 1e9 + 7; constexpr ll LINF = 1ll << 60;
struct aaa { aaa() { cin.tie(0); ios::sync_with_stdio(0); }; }aaaa;

int main() {
    int A, B;
    cin >> A >> B;

    if (A >= 13) write(B);
    else if (A >= 6) write(B / 2);
    else write(0);
}

Measured memory_bytes: 256
// 2011/05/31 Tazoe

#include <iostream>
using namespace std;

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

	int dbt = 100000;
	for(int i=0; i<n; i++){
		dbt = dbt/100*105;
		dbt = (dbt+999)/1000*1000;
	}

	cout << dbt << endl;

	return 0;
}

Measured memory_bytes: 0
m,a=gets.chomp.split(" ").map(&:to_i);
hl=gets.chomp.split(" ").map(&:to_i);
hl.sort!
if a >= hl.size
  print 0
  exit
end
a.times do
  hl.pop
end
sum = 0
hl.each do |i|
sum += i
end
p sum

Measured memory_bytes: 19824
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#define endl "\n"
#include <map>
#include <numeric>
#include <stack>
#define ll long long int
using namespace std;

int main()
{
    ios_base::sync_with_stdio(false); cin.tie(0);
    int n;
    cin >> n;
    map<string,int>m;
    for(int i=0; i<n; ++i)
    {
        string s;
        cin >> s;
        ++m[s];
    }cout << "AC x " << m["AC"] << endl;
    cout << "WA x " << m["WA"] << endl;
    cout << "TLE x " << m["TLE"] << endl;
    cout << "RE x " << m["RE"] << endl;

    //1 3 1 5 3 6
    //2 6 5 4 2 4//

	return 0;
}


Measured memory_bytes: 3640
# -*- coding: utf-8 -*-
# 整数の入力
# N = int(input())
N, K, Q = map(int, input().split())
aList = [int(input()) for i in range(Q)]
# スペース区切りの整数の入力
# b, c = map(int, input().split())
# 文字列の入力
#s = input()
# sList=[input() for i in range(N)]
scoreList = [0] * N;
for i in range(len(aList)):
  seikaisya = aList[i];
  scoreList[seikaisya - 1] = scoreList[seikaisya - 1] + 1;

# 出力
for i in range(len(scoreList)):
  if K - Q + scoreList[i] > 0:
    print('Yes');
  else:
    print('No');


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

using namespace std;

const double PI = 3.14159265358979323846;
typedef long long ll;
const double EPS = 1e-9;
#define rep(i, n) for (int i = 0; i < (n); ++i)
//#define rep(i, n) for (ll i = 0; i < (n); ++i)
//typedef pair<ll, ll> P;
typedef pair<double, double> P;
const ll INF = 10e17;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
#define ret() return 0;

double equal(double a, double b) {
    return fabs(a - b) < DBL_EPSILON;
}

std::istream &operator>>(std::istream &in, set<string> &o) {
    string a;
    in >> a;
    o.insert(a);
    return in;
}

std::istream &operator>>(std::istream &in, queue<int> &o) {
    ll a;
    in >> a;
    o.push(a);
    return in;
}

bool contain(set<int> &s, int a) { return s.find(a) != s.end(); }

//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);
//const ll mod = 1e10;

typedef priority_queue<ll, vector<ll>, greater<ll> > PQ_ASK;

map<pair<string, string>, ll> f(string &u, int n) {
    map<pair<string, string>, ll> m;
    rep(i, 1 << n) {
        string x = "", y = "";
        rep(j, n) {
            bool b = (i >> j) & 1;
            if (b) x.push_back(u[j]);
            else y.push_back(u[j]);
        }
        m[pair<string, string>(x, y)]++;
    }
    return m;
}

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

    string u = s.substr(0, n);
    string v = s.substr(n);
    reverse(v.begin(), v.end());

    map<pair<string, string>, ll> a = f(u, n), b = f(v, n);


    ll ans = 0;
    for (auto &e : a) {
        pair<string, string> k = e.first;
        ll ai = e.second, bi = b[k];
        ll now = ai * bi;
        ans += now;
    }
    cout << ans << endl;

}


Measured memory_bytes: 89492
from collections import deque
h,w=map(int,input().split())
field=[["#" for i in range(w+2)]]+[["#"]+list(input())+["#"] for i in range(h)]+[["#" for i in range(w+2)]]
queue=deque([[1,1]])
cost=[[50000 for i in range(w)]for j in range(h)]
cost[0][0]=0
while queue:
  now=queue.popleft()
  for i in [(-1,0),(1,0),(0,1),(0,-1)]:
    if field[now[0]+i[0]][now[1]+i[1]]=="#":continue
    if cost[now[0]+i[0]-1][now[1]+i[1]-1]!=50000:continue
    queue.append((now[0]+i[0],now[1]+i[1]))
    cost[now[0]+i[0]-1][now[1]+i[1]-1]=cost[now[0]-1][now[1]-1]+1
cnt=0
for i in range(h+2):
  for j in range(w+2):
    if field[i][j]=="#":cnt+=1
cnt-=(h+w)*2+4
blackable=h*w-cnt
if cost[-1][-1]==50000:print(-1)
else:
  print(blackable-cost[-1][-1]-1)

Measured memory_bytes: 40560
n = int(input())
lst = []
dlst = []
ans = "Yes"
for i in range(n):
    lst.append(input())
st = set(lst)
for i in st:
    if lst.count(i) != 1:
        ans = "No"
for i in range(1, n):
    if lst[i-1][-1] != lst[i][0]:
        ans = "No"
print(ans)

Measured memory_bytes: 3064