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

using namespace std;

const int big_month = 20;
const int small_month = 19;
const int ordinal_year = big_month * 5 + small_month * 5;
const int special_year = big_month * 10;
const int three_years = ordinal_year * 2 + special_year;
const int millennium = three_years * 333 + 1;

int count_day_from_first(int y, int m, int d) {
	int day = 0;
	if (y % 3 == 0) {
		day += three_years * ((y-1) / 3);
		day += ordinal_year * ((y-1) % 3);
		day += big_month * (m-1);
		day += d;
	} else {
		day += three_years * ((y-1) / 3);
		day += ordinal_year * ((y-1) % 3);
		day += (big_month + small_month) * ((m-1) / 2);
		if ((m-1) % 2 == 1) {
			day += big_month;
		} 
		day += d;
	}
	return day;
}

int main() {
	int n; cin >> n;
//	cout << millennium << endl;
//	cout << three_years << endl;
	for (int i = 0; i < n; i++) {
		int y, m, d; cin >> y >> m >> d;
//		cout << count_day_from_first(y, m, d) << endl;
		cout << millennium - count_day_from_first(y, m, d) << endl;
	}
	return 0;
}

	

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

using namespace std;

struct Initializer {
  Initializer() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(15);
  }
} initializer;

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

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

int tax(int x, int p) {
  return x * (100 + p) / 100;
}

int main() {
  while (true) {
    int x, y, s;
    cin >> x >> y >> s;
    if (x == 0 && y == 0 && s == 0) break;
    int res = -1;
    for (int i = 1; i < s; ++i) {
      for (int j = i; j < s; ++j) {
        if (tax(i, x) + tax(j, x) != s) continue;
        chmax(res, tax(i, y) + tax(j, y));
      }
    }
    cout << res << endl;
  }
}

Measured memory_bytes: 3124
H, W = map(int, input().split())
S = [input() for i in range(H)]

def singleB(i, j):
    search = [(-1, 0), (1, 0), (0, -1), (0, 1)]
    single = True
    for s in search:
        if 0 <= i+s[0] <= H-1 and 0 <= j+s[1] <= W-1:
                if S[i+s[0]][j+s[1]] == "#":
                        single = False
    return single

Success = True
for i in range(H):
    for j in range(W):
        if S[i][j] == "#":
            if singleB(i, j):
                Success = False
print("Yes" if Success else "No")

Measured memory_bytes: 3064
#include <algorithm>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>

using namespace std;

#define reps(i,f,n) for(int i=f; i<int(n); ++i)
#define rep(i,n) reps(i,0,n)

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;

const int INF = 1001001001;

int main()
{
	int n;
	while(scanf("%d", &n), n){
		int Bp, Bd = -1;
		rep(i, n){
			int p, d1, d2;
			scanf("%d%d%d", &p, &d1, &d2);
			d1 += d2;
			if(d1 > Bd){
				Bd = d1;
				Bp = p;
			}
		}
		printf("%d %d\n", Bp, Bd);
	}
	return 0;
}

Measured memory_bytes: 1028
#include <iostream>
#include <cmath>
#include <cstdio>
using namespace std;

int main()
{
  double x1, x2, y1, y2;

  cin >> x1 >> y1 >> x2 >> y2;
  printf("%f\n", sqrt((x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1)));
  return (0);
}


Measured memory_bytes: 3220
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define MOD 1000000007
#define rep(i,n) for(i=0;i<n;i++)
#define loop(i,a,n) for(i=a;i<n;i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

typedef vector<int> vi;
typedef pair<int,int> pii;

int main(void) {
  int i,j;
  string s,t;
  cin>>s;
  t="CODEFESTIVAL2016";
  int ans=0;
  rep(i,16)if(s[i]!=t[i])ans++;
  cout<<ans<<endl;



}


Measured memory_bytes: 256
#include <set>
#include <map>
#include <queue>
#include <ctime>
#include <cmath>
#include <cstdio>
#include <vector>
#include <string>
#include <cctype>
#include <bitset>
#include <cstring>
#include <cstdlib>
#include <utility>
#include <iostream>
#include <algorithm>
#define REP(i,a,b) for(int i=(a);i<=(b);i++)
#define PER(i,a,b) for(int i=(a);i>=(b);i--)
#define RVC(i,S) for(int i=0;i<(S).size();i++)
#define RAL(i,u) for(int i=fr[u];i!=-1;i=e[i].next)
using namespace std;
typedef long long LL;
typedef pair<int,int> pii;
     
template<class T> inline
void read(T& num) {
    bool start=false,neg=false;
    char c;
    num=0;
    while((c=getchar())!=EOF) {
        if(c=='-') start=neg=true;
        else if(c>='0' && c<='9') {
            start=true;
            num=num*10+c-'0';
        } else if(start) break;
    }
    if(neg) num=-num;
}
/*============ Header Template ============*/

const int maxn=(int)(2e5)+5;
char s[maxn];

int main() {
    scanf("%s",s+1);
    int n=strlen(s+1);
    int lst=n+1,res=0;
    REP(i,1,n) if(s[i]=='A') lst=min(lst,i); else if(s[i]=='Z') res=max(res,i-lst+1);
    printf("%d\n",res);
    return 0;
}

Measured memory_bytes: 384
A,B=map(int,input().split())
H=[0]*1000

i=1
while i<=999:
    H[i]=i+H[i-1]
    i+=1

ans=0
while True:
    if (A+ans in H)and(B+ans==H[H.index(A+ans)+1] in H):
        break
    else:
        ans+=1
    
print(ans)

Measured memory_bytes: 38768
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
using ll = long long;
using ull = unsigned long long; 
using pii =  pair<int, int>;
using pll =  pair<long long, long long>;
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
//constexpr long long MOD = 998244353LL;
template<class T, class U> inline bool chmax(T &a, U b) { if (a < b) { a = b; return true;} return false; }
template<class T, class U> inline bool chmin(T &a, U b) { if (a > b) { a = b; return true;} return false; }
////////////////////////////////////////////////////////////////////////////////////////////////////////////

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

    auto NO=[]() {
        cout << "No" << ln;
        exit(0);
    };
    int N; cin >> N;
    vector<string> S(N);
    rep(i,N) cin >> S[i];

    vector<pii> A,B;
    int ALL = 0;
    int val = 0;
    int val2 = 0;
    rep(i,N) {
        int L = S[i].size();
        int cnt = 0;
        int mi = 0;
        rep(j,L) {
            if (S[i][j]=='(') cnt++;
            else cnt--;
            chmin(mi,cnt);
        }
        int cnt2 = 0;
        int mi2 = 0;
        for (int j = L-1; j >= 0; j--) {
            if (S[i][j]==')') cnt2++;
            else cnt2--;
            chmin(mi2,cnt2);
        } 
        if (cnt >= 0 and mi >= 0) val += cnt;
        else if (cnt >= 0 and mi < 0) {
            A.emplace_back(mi,cnt);
        } else if (cnt2 >= 0 and mi2 >= 0) val2 += cnt2;
        else B.emplace_back(mi2,cnt2);
        ALL += cnt;
    }
    if (ALL != 0) NO();
    sort(all(A)); reverse(all(A));
    for (auto i : A) {
        if (val+i.first < 0) NO();
        val += i.second;
    }
    sort(all(B)); reverse(all(B));
    for (auto i : B) {
        if (val2+i.first < 0) NO();
        val2 += i.second;
    }

    cout << "Yes" << ln;
}

Measured memory_bytes: 34820
#include<string>
#include<vector>
#include<cstdio>
#include<sstream>
#include<algorithm>
#include<iostream>
#include<cmath>
#include<map>
#include<list>
using namespace std;
int stoi(string x){stringstream ss;ss<<x;int tmp;ss>>tmp;return tmp;}
string itos(int x){stringstream ss;ss<<x;return ss.str();}
int main(){
	vector<int>ta;
	int n,m,k;
	while(true){
	cin>>n>>k>>m;
	if(n==0&&m==0&&k==0)break;
	for(int i=0;i<n;i++)ta.push_back(i+1);
	//list<int>::iterator it=ta.begin();
	int i;
	int now=0;
	while(ta.size()!=1){
		//if(ta.size()>=n-5)for(int i=0;i<ta.size();i++)cout<<ta[i]<<" ";cout<<endl;
		if(ta.size()==n){
		now=(m-1)%ta.size();
		ta.erase(ta.begin()+now);
		}
		else{
		now=(now+k-1)%ta.size();
		ta.erase(ta.begin()+now);
		}
	}//endwhile
	cout<<ta[0]<<endl;
	ta.clear();
	}
	return 0;
}

Measured memory_bytes: 1332
while gets
  z = $_.split(',').map(&:to_i)
  v1 = z[10].to_f
  v2 = z[11].to_f
  t = 0
  10.times do |i|
    t += z[i]
  end
  s = v1*t / (v1+v2)
  k = 0
  while s > 0
    s -= z[k]
    k += 1
  end
  puts k
end

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

int main() {
  int N;
  cin >> N;
  vector<int> a(N);
  for (int i = 0; i < N; i++) {
    cin >>a.at(i);
  }
  int M;
  int S;
  M = max(a.at(0), a.at(1));
  S = min(a.at(0), a.at(1));
  if (N == 2) {
    cout << a.at(1) <<endl;
    cout << a.at(0) <<endl;
  }
  else {
    for (int i = 2; i < N; i++) {
      int m = M;
      M = max(M, a.at(i));
      if (M == m) {
        S = max(S, a.at(i));
      }
      else {
        S = m;
      }
    }
    for (int i = 0; i < N; i++) {
      if (a.at(i) == M) {
        cout << S << endl;
      }
      else {
        cout << M <<endl;
      }
    }
  }
}

Measured memory_bytes: 2432
c,t,d[4010][4010];char s[4010];i,j;main(){for(**d=scanf("%s",s);s[i/2];i++)for(j=c+=s[i]?t++,s[i]-48:0;j>i+c-2*t&&~j;j--)d[i+1][j]=(d[i][j]+d[i][j-1])%998244353;printf("%d",d[i][c]);}

Measured memory_bytes: 60416
function Main(input) {
  input = input.split(" ").map(Number);
  if((input[1]+input[0])%2==1){
  console.log("IMPOSSIBLE")
  }else{
  console.log((input[0]+input[1])/2)
  }
}Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
//Created by Kira

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

#define IOS cin.sync_with_stdio(0);cin.tie(0); cout.tie(0);
#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()
#define pii pair<int,int> 
#define pb push_back
#define vi vector<int> 
using ll = long long;

const int mod = 1e9 + 7;

ll pwr(ll a, ll b);
    

const int nax = 3005;
ll dp[nax][nax];

int main(){
   IOS


   int n; cin>>n;

   vi a(n);
   for(int & x : a)cin>>x;


    for(int i = 0; i < n; i++) 
        dp[i][i] = a[i];

    for(int l = 2; l <= n; l++){
        for(int i = 0; i < n-l + 1; i++){
            int j = i + l-1;
            dp[i][j] = max(a[i]-dp[i+1][j], a[j]-dp[i][j-1]);
        }
    }

    cout<<dp[0][n-1]<<"\n";















}

ll pwr(ll a, ll b){
   a %= mod;	//Remove mod if not required
   ll res = 1;
   while(b > 0){
    if(b&1)
        res = res * a % mod;
        a = a * a % mod;
    b >>= 1;
    }

    return res;
}



Measured memory_bytes: 70016
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define st first
#define N 1000005
using namespace std;
typedef long long int lo;
const int mod=1000000007;
lo a,b,c,d,e,f,g,h[100005],arr[100005];
string s;
vector<lo>v;
char ch;

int main(){
	// freopen("in.txt","r",stdin);
 //    freopen("out.txt","w",stdout);
    cin >>a;
    double x;
    for(lo i=1;i<=a;i++){
    	cin >> arr[i];
    	x+=(double)1/arr[i];
    }
    printf("%.6f",(double)1/x);
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
from sys import stdin

in_strings = lambda: stdin.readline()[:-1] # s = in_strings()
in_int = lambda: int(stdin.readline()) # N = in_int()
in_intlist = lambda: list(map(int, stdin.readline().split())) # List = in_intlist()

N = in_int()
L_list = []
R_list = []
for _ in range(N):
    temp = in_intlist()
    L_list.append(temp[0])
    R_list.append(temp[1])

L_list.sort(reverse=True)
R_list.sort()


ans = 0
for i in range(N):
    if (L_list[i] - R_list[i]) > 0:
        ans += 2*(L_list[i] - R_list[i])
    else:
        if (L_list[i] <= 0) and (R_list[i] >= 0):
            pass
        elif L_list[i] > 0:
            if (i>0) and (L_list[i] < R_list[i-1]):
                ans += 2 * R_list[i-1]
            else:
                ans += 2 * L_list[i]
        else:
            if (i>0) and (R_list[i] > L_list[i-1]):
                ans -= 2 * L_list[i-1]
            else:
                ans -= 2 * R_list[i]
        break

print(ans)


Measured memory_bytes: 11524
#include<bits/stdc++.h>
#define ll long long
using namespace std;
#define ll long long
#define dd double
#define fio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define mod (ll)(998244353)
#define sz(a) (ll)a.size()
#define all(a) a.begin(),a.end()
#define fr(i,a,b) for(ll i=a;i<b;i++)
#define frr(i,a,b) for(ll i=a-1;i>=b;i--)
#define tc(t) ll t;cin >>t;while(t--)
#define pb emplace_back
#define ee emplace
#define rr return 0
#define mp make_pair
#define pr  pair <ll,ll>
#define ff first
#define ss second
#define pie 3.1415926535
#define inf LLONG_MAX
ll mult(ll a, ll b, ll p = mod) {return ((a % p) * (b % p)) % p;}
ll add(ll a, ll b, ll p = mod) {return (a % p + b % p) % p;}
ll fpow(ll x, ll y)
{
	ll res = 1;
	x = x % mod;
	if (x == 0) return 0;
	while (y > 0)
	{
		if (y & 1LL)
			res = (res * x) % mod;
		y = y >> 1LL;
		x = (x * x) % mod;
	}
	return res;
}
ll inv(ll a, ll p = mod) {return fpow(a, p - 2);}
bool sa(const pair<ll, ll> &a, const pair<ll, ll> &b) {return (a.second < b.second);}
bool fd(const pair<ll, ll> &a, const pair<ll, ll> &b) {return (a.first > b.first);}
bool sd(const pair<ll, ll> &a, const pair<ll, ll> &b) {return (a.second > b.second);}
ll dx[4] = {0, 0, 1, -1};
ll dy[4] = {1, -1, 0, 0};
bool valid(ll x, ll y, ll n, ll m) {
	if (x < 0 || y < 0) {
		return false;
	}
	else if (x >= n || y >= m) {
		return false;
	}
	else
		return true;
}
#define MAXN 1000001
ll spf[MAXN];
void sieve()
{
	spf[1] = 1;
	for (ll i = 2; i < MAXN; i++)

		// marking smallest prime factor for every
		// number to be itself.
		spf[i] = i;

	// separately marking spf for every even
	// number as 2
	for (ll i = 4; i < MAXN; i += 2)
		spf[i] = 2;

	for (ll i = 3; i * i < MAXN; i++)
	{
		// checking if i is prime
		if (spf[i] == i)
		{
			// marking SPF for all numbers divisible by i
			for (ll j = i * i; j < MAXN; j += i)

				// marking spf[j] if it is not
				// previously marked
				if (spf[j] == j)
					spf[j] = i;
		}
	}
}

int main() {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	ll n, k;
	cin >> n >> k;
	map<ll, ll> mp;
	for (ll i = 1; i <= n; i++) {
		ll x;
		cin >> x;
		mp[i] = x;
	}
	ll new_city = 1;
	vector<ll> loop_cities;
	bool tt = true;
	map<int, int> val;
	loop_cities.push_back(1);
	val[1]++;
	while (k--) {
		new_city = mp[new_city];
		val[new_city]++;
		if (val[new_city] == 2) {
			int tt = true;
			break;
		} else {
			loop_cities.push_back(new_city);
		}
	}

	ll i = std::find (loop_cities.begin(), loop_cities.end(), new_city) - loop_cities.begin();
	if (tt) {
		ll x = loop_cities[ i + (k % (loop_cities.size() - i) ) ];
		cout << x;
	} else
		cout << new_city;
	return 0;
}


Measured memory_bytes: 24416
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h>
#include <iomanip>
using namespace std;
#define int long long

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

    int n,k; cin >> n >> k;
    vector<int> l(k),r(k);
    for(int i = 0;i < k;i ++){
        cin >> l.at(i) >> r.at(i);
    }

    vector<int> s(n+1);
    for(int i = 0;i < k;i ++){
        for(int j = l.at(i);j < r.at(i) + 1;j ++){
            s.at(j) = 1;
        }
    }

    vector<int> ans(n+1);
    vector<int> ansruiseki(n+1);

    ans.at(1) = 1;
    ansruiseki.at(1) = 1;

    for(int i = 2;i < n+1;i ++){
        int tmpruiseki = 0;
        for(int j = 0;j < k;j ++){
            if(l.at(j) >= i) continue;
            int tmpmax = min(r.at(j),i-1);
            tmpruiseki += ansruiseki.at(i-l.at(j)) - ansruiseki.at(i-tmpmax-1);
//            tmpruiseki %= 998244353;
//            cout << i << " " << j << " " << tmpmax << " " << l.at(j)-1 << endl;
//            cout << ansruiseki.at(i-l.at(j)) << " " << ansruiseki.at(i-tmpmax-1) << endl;
        }
        ans.at(i) = tmpruiseki;
        ans.at(i) %= 998244353;
        ansruiseki.at(i) = ansruiseki.at(i-1) + ans.at(i);
//        ansruiseki.at(i) %= 998244353;
//        cout << ans.at(i) << " " << ansruiseki.at(i) << endl;
    }


/*    for(int i = 0;i < n;i ++){
        cout << ans.at(i) << endl;
    }
*/
    cout << ans.at(n) % 998244353<< endl;
}

Measured memory_bytes: 7964
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>

using namespace std;

int main()
{
	long long int N,v[7],min=1000000000000000;
	long long int ans;
	
	cin >> N;
	
	for(int i=0;i<5;i++){
		cin >> v[i];
		if(min > v[i]) min = v[i];
	}
	
	ans = (N+min-1)/min + 4;
	
	cout << ans << endl;
	
	
	
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

class Main {
    private static void solve() {
        Scanner scanner = new Scanner(System.in);
        int[] map = {0, 1, 2, 3, 5, 7, 8, 9};

        while (true) {
            int n = scanner.nextInt();
            if (n == 0) {
                break;
            }
            StringBuilder result = new StringBuilder();
            do {
                result.append(map[n % 8]);
                n /= 8;
            } while (n != 0);
            System.out.println(result.reverse());
        }
    }

    public static void main(String... args) {
        solve();
    }
}

Measured memory_bytes: 12000
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <cstring>
#include <set>
#include <utility>
#include <cstdlib>
#include <cmath>
#include <queue>
#include <stack>
#include <string>
#include <map>
#include <cmath>
#include <deque>
#include <bitset>
#define ll long long
#define PI 3.1415926535897932384626433832795
#define read(x) scanf("%d",&x);
#define readll(x) cin>>x;
#define FOR(x,a,b) for(int x=a;x<b;x++)
#define MP make_pair
#define PB push_back
#define pii pair<int,int>
#define readN(N,X) for(int i=0;i<N;i++) cin>>X[i];
#define pff pair<double,double>
#define MOD 1000000007
using namespace std;
int cnt[333];
string S;
int N;
int main(){
   std::ios::sync_with_stdio(false); 
   cin>>N;
   cin>>S;
   long long res = 0;
   for (int i=0;i<N;i++)
      cnt[S[i]]++;

   res = 1;
   for (int i=0;i<=300;i++){
     res = (res * (cnt[i] + 1)) % MOD;
   }

   res = (res - 1 + MOD) % MOD;
   cout<<res<<endl;

}




Measured memory_bytes: 512
import itertools
data = []
data_1 = []
while True:
    s = list(map(int, input().split()))
    if s[0] == 0 and s[1] == 0:
        break
    data.append(s)
# for n, x in data:
#     a = [i for i in range(1, n + 1)]
#     b = list(itertools.combinations(a, 3))
#     for c in b:
#         d = sum(c)
#         if d == x:
#             data_1.append(c)
#     print(len(data_1), end=" ")

for i in range(len(data)):
    data_1 = []
    n = data[i][0]
    x = data[i][1]
    
    a = [j for j in range(1, n + 1)]
    b = list(itertools.combinations(a, 3))
    
    for c in b:
        d = sum(c)
        if d == x:
            data_1.append(c)
    
    print(len(data_1), end="\n")


Measured memory_bytes: 31440
open Batteries

let read_two () = Scanf.sscanf (read_line ()) "%d %d" (fun a b -> (a, b))

let read_three () =
  Scanf.sscanf (read_line ()) "%d %d %d" (fun a b c -> (a, b, c))

let read_four () =
  Scanf.sscanf (read_line ()) "%d %d %d" (fun a b c d -> (a, b, c, d))

let read_list () =
  read_line () |> String.split_on_char ' '
  |> List.map (fun s -> int_of_string s)

(* a**x *)
let pow a x =
  let rec aux acc = function 0 -> acc | n -> aux (acc * a) (n - 1) in
  aux 1 x

let rec pow2 n = if n mod 2 = 0 then 1 + pow2 (n / 2) else 0

let rec f n ar = (ar.(n - 1), ar.(n))

let () =
  let n = read_int () in
  let ls = read_list () |> List.sort compare in
  let d = Array.of_list ls in
  let a, b = f (n / 2) d in
  print_int (b - a);
  print_newline ()


Measured memory_bytes: 11708
N = int(input())
num=0
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr
for i in range(1,N+1):
    ans=1
    if i%2==1:
        a=factorization(i)
        #print(a)
        for u in a:
            ans*=u[1]+1
        if ans==8:
            num+=1
print(num)

Measured memory_bytes: 62744
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws Exception{

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		String s = br.readLine();
		long n = s.length();
		long sum = 0;
		
		for(int i=0;i<(1<<n-1);i++)
		{
			int p = 0;
			for(int j=0;j<n-1;j++)
			{
				if((i&(1<<j)) > 0)
				{
					String str = s.substring(p, j+1);
					p = j+1;
					sum += Long.parseLong(str);
				}
			}
			String str = s.substring(p);
			sum += Long.parseLong(str);
		}
		System.out.println(sum);
	}
}


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

using namespace std;

int N ;

inline int abs(int a){
    return (a < 0) ? -1 * a : a;
}

int dp(int i, int* h, int* memo) {
    if(i == N - 1) return 0;
    if( memo[i] != -1) return memo[i];
    int b = abs(h[i] - h[i + 1]) + dp(i + 1, h, memo);
    int a = (i < N - 2)? abs(h[i] - h[i + 2]) + dp(i + 2, h, memo) : INT_MAX;
    return  memo[i] = min(a, b);
}

int main() {
    cin >> N;
    int memo[N];
    memset(memo, -1, sizeof memo);
    int h[N];
    for(int i = 0; i < N; i++){
        cin >> h[i]; 
    }
    cout << dp(0, h, memo) << endl;
    return 0;
}

Measured memory_bytes: 8832
n,m=map(int,input().split())
if abs(n-m)>1:print(0)
else:
	mod=10**9+7
	x=1 if abs(n-m)==1 else 2
	p=[1]
	for i in range(1,max(n,m)+1):
		p.append(p[ i-1]*i%mod)
	print(x*p[n]*p[m]%mod)

Measured memory_bytes: 7060
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<map>
using namespace std;
#define REP(i, limit) for(int i=0; i< limit; ++i)
#define LL long long

int main(){
  int n, a;
  cin>>n>>a;
  int x[n];
  REP(i, n){
    cin>>x[i];
    x[i]-=a;
  }
  int p = 2500;
  LL dp[n+1][5000];
  REP(i, n+1) REP(j, 5000) dp[i][j]=0;
  dp[0][p]=1; //pでsum=0
  REP(i, n) REP(j, 5000){
    dp[i+1][j] = dp[i][j];
    if(j+x[i]>-1 && j+x[i]<5000) dp[i+1][j] += dp[i][j-x[i]];
  }
  cout<<dp[n][p]-1<<endl;

  return 0;
}


Measured memory_bytes: 2176
from collections import Counter
N = int(input())
S = input()

east = []
west = []
tmp_e = 0
tmp_w = 0
for i in range(N):
    if S[i] == 'W':
        tmp_e += 1
    east.append(tmp_e)
    if S[N-1-i] == 'E':
        tmp_w += 1
    west.append(tmp_w)

mn = N
for i in range(N):
    e = east[i-1] if i else 0
    w = west[N-1-i] if i != N-1 else 0
    if e + w < mn:
        mn = e + w
print(mn)


Measured memory_bytes: 86108
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#define ll long long
#define rep(i,l,r) for(ll i=(l);i<(r);i++)
#define max(p,q) ((p)>(q)?(p):(q))
#define min(p,q) ((p)<(q)?(p):(q))
#define chmax(a,b) ((a)=(a)>(b)?(a):(b))
#define chmin(a,b) ((a)=(a)<(b)?(a):(b))
#define abs(p) ((p)>=(0)?(p):(-(p)))
int cmp(const void *a, const void *b);
//your code here!

int main(void){
    ll a, b, c;
    scanf("%lld %lld %lld", &a, &b, &c);
    if(a==b && b==c)printf("1\n");
    else if(a==b || b==c || c==a) printf("2\n");
    else printf("3\n");
    return 0;
}

int cmp(const void *a, const void *b){
    ll A=*(ll *)a, B=*(ll *)b;
    if(A==B)return 0;
    else return A>B ? 1:-1;//昇順ソート
}


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

using namespace std;

#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl

typedef long long ll;
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
template<class S, class T> pair<S, T> operator+(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first + t.first, s.second + t.second); }
template<class S, class T> pair<S, T> operator-(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first - t.first, s.second - t.second); }
template<class S, class T> ostream& operator<<(ostream& os, pair<S, T> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
#define X first
#define Y second
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define rrep1(i,n) for(int i=(n);i>0;i--)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define in(x, a, b) (a <= x && x < b)
#define all(c) c.begin(),c.end()
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 (a>b) { a = b; return 1; } return 0; }
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
const ll inf = 1000000001;
const ll INF = 1e18;
const ll MOD = 1000000007;
//const ll MOD = 998244353;
const double pi = 3.14159265358979323846;
#define Sp(p) cout<<setprecision(15)<< fixed<<p<<endl;
int dx[4] = { 1,0, -1,0 }, dy[4] = { 0,1,0,-1 };
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
#define fio() cin.tie(0); ios::sync_with_stdio(false);
//#define mp make_pair

#define vlll vector<vll>


int main() {
  string s;
  cin >> s;
  int d;
  cin >> d;
  int n = s.size();
  vlll dp(n + 1, vll(d, vl(2)));
  dp[0][0][1] = 1;
  rep (keta, n) {
    rep (mo, d) {
      rep (giri, 2) {
        int nketa = keta + 1;
        int nmo, ngiri;
        rep (add, 10) {
          if (giri) {
            if (add > s[keta] - '0') break;
            else if (add == s[keta] - '0') {
              ngiri = 1;
            }
            else {
              ngiri = 0;
            }
          }
          else {
            ngiri = 0;
          }
          nmo = (mo + add) % d;
          (dp[nketa][nmo][ngiri] += dp[keta][mo][giri]) %= MOD;
        }
      }
    }
  }
  cout << (dp[n][0][0] + dp[n][0][1] - 1 + MOD) % MOD << endl;
}


Measured memory_bytes: 55296
//~ while (clock()<=69*CLOCKS_PER_SEC)
//~ #pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
//~ #pragma GCC target ("avx2")
//~ #pragma GCC optimize("Ofast")
//~ #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//~ #pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;

template <typename T>
using ordered_set =
    tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

#define shandom_ruffle random_shuffle

using ll=long long;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
using vi=vector<int>;
using vll=vector<ll>;
const int nax=3007;

int n;

ll tab[nax];
ll dp[nax][nax];

int main()
{
	scanf("%d", &n);
	for (int i=1; i<=n; i++)
		scanf("%lld", &tab[i]);
	for (int i=1; i<=n; i++)
	{
		for (int j=i; j; j--)
		{
			if (j==i)
			{
				dp[j][i]=tab[i];
			}
			else
			{
				dp[j][i]=max(-dp[j+1][i]+tab[j], -dp[j][i-1]+tab[i]);
			}
		}
	}
	printf("%lld\n", dp[1][n]);
	return 0;
}


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

using namespace std;

class Work {
public:
	int cost;
	int deadline;

	Work(int cost, int deadline) :cost(cost), deadline(deadline) {};
};

bool priority(Work work1, Work work2) {
	return work1.deadline < work2.deadline;
}

int main()
{
	int n,cost,deadline;
	cin >> n;
	vector<Work> works;
	works.reserve(n);

	for (int i = 0; i < n; i++) {
		cin >> cost >> deadline;
		works.push_back(Work(cost, deadline));
	}
	
	sort(works.begin(), works.end(), priority);

	int totaltime = 0;

	for (int i = 0; i < n; i++) {
		totaltime += works[i].cost;
		if (totaltime > works[i].deadline) {
			cout << "No";
			return 0;
		}
	}

	cout << "Yes";
}

Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <vector>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <cstring>

using namespace std;
// ascending order
#define vsort(v) sort(v.begin(), v.end())
// descending order
#define vsort_r(v) sort(v.begin(), v.end(), greater<int>())
#define vunique(v) unique(v.begin(), v.end())
#define mp make_pair
#define ts(x) to_string(x)
#define rep(i, a, b) for(int i = (int)a; i < (int)b; i++)
#define repm(i, a, b) for(int i = (int)a; i > (int)b; i--)
#define bit(a) bitset<8>(a)
#define des_priority_queue priority_queue<int, vector<int>, greater<int> >
#define all(v) (v).begin(), (v).end()
typedef long long ll;
typedef pair<int, int> P;
const ll INF = 1e18;

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

	int N, K;
	cin >> N >> K;
	ll a[N + 2], b[N + 2];
	a[0] = a[N + 1] = b[0] = b[N + 1] = 0ll;
	rep(i, 1, N + 1) {
		cin >> a[i];
		b[i] = max(a[i], 0ll);
	}

	rep(i, 1, N) {
		a[i + 1] += a[i];
		b[i + 1] += b[i];
	}

	ll rsl = 0ll;
	for(int i = 0; i + K <= N; i++) {
		ll tmp = b[i] + b[N] - b[i + K];
		ll tmp2 = a[i + K] - a[i];
		tmp = max(tmp, tmp + tmp2);

		rsl = max(rsl, tmp);
	}

	cout << rsl << endl;

}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0;i<(n);++i)
#define fi first
#define se second
#define INF 1000000009
#define lINF 1000000000000000009
typedef long long ll;
int d[100009];

int main(){
  int n,m;
  string s;
  vector<int>x;
  
  cin>>n>>m>>s;
  n++;
  reverse(s.begin(),s.end());

  rep(i,n){
    if(s[i]=='0'){
      x.push_back(i);
    }
    d[i]=INF;
  }
  d[0]=0;
  for(int i=1;i<n;i++){
    if(s[i]=='1')continue;
    int idx=upper_bound(x.begin(),x.end(),i-m-1)-x.begin();
    int nx=x[idx];
    if(nx<i&&d[nx]<INF){
      d[i]=d[nx]+1;
    }
  }

  /*rep(i,n){
    cout<<d[i]<<' ';
  }
  cout<<endl;*/

  vector<int>ans;
  int now=d[n-1],xnow=n-1;
  for(int i=n-1;i>=0;i--){
    if(d[i]+1==now){
      ans.push_back(xnow-i);
      now--;
      xnow=i;
    }
  }

  if(d[n-1]==INF){
    cout<<-1<<endl;
    return(0);
  }
  rep(i,ans.size()){
    cout<<ans[i];
    if(i+1==ans.size())cout<<endl;
    else cout<<' ';
  }

  return(0);
}


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

int main()
{
  long long int A, B, C, D;
  cin >> A >> B >> C >> D;
  long long int numC = B / C - (A - 1) / C;
  long long int numD = B / D - (A - 1) / D;
  long long int CDGCD = __gcd(C, D);
  long long int CDLCM = C * D / CDGCD;
  long long int numCD = B / CDLCM - (A - 1) / CDLCM;
  long long int ans = (B - (A - 1)) - (numC + numD - numCD);
  cout << ans << endl;
}


Measured memory_bytes: 256
// #define _GLIBCXX_DEBUG // for STL debug (optional)
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;
using ll = long long int;
using int64 = long long int;
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const int INF = 1LL << 29;
const ll LONGINF = 1LL << 60;
const ll MOD = 1000000007LL;
 
int main() {
    int N; cin >> N;
    vector<int> D(N);
    for(int i=0; i<N; i++) cin >> D[i];

    ll ans = 0;
    for(int i=0; i<N; i++) {
        for(int j=i+1; j<N; j++) {
            ans += D[i] * D[j];
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#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 = int(1e9) + 7; constexpr ll LINF = 1ll << 60;
struct aaa { aaa() { cin.tie(0); ios::sync_with_stdio(0); }; }aaaa;

const int exp6max = 6, exp9max = 5;

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

    vi dp(500000, INF);
    dp[0] = 0;
    rep(i, N) {
        chmin(dp[i + 1], dp[i] + 1);
        int a = 1;
        rep(j, exp6max) {
            a *= 6;
            chmin(dp[i + a], dp[i] + 1);
        }
        int b = 1;
        rep(j, exp9max) {
            b *= 9;
            chmin(dp[i + b], dp[i] + 1);
        }
    }

    write(dp[N]);
}

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

long long N = 0;
long long M = 0;
long long ans = 0;
long long penalty = 0;

int main()
{
  cin >> N >> M;
  vector<long long> p(M);
  vector<string> S(M);
  vector<long long> AC(N + 1);
  vector<long long> WA(N + 1);
  long long count = 1;
  for (int i = 0; i < M; i++)
  {
    cin >> p.at(i) >> S.at(i);
    p.at(i)--;
    if (AC.at(p.at(i)) == 0 && S.at(i) == "AC")
    {
      AC.at(p.at(i))++;
      count = 1;
    }
    if (AC.at(p.at(i)) == 0 && S.at(i) == "WA")
    {
      WA.at(p.at(i))++;
      count++;
    }
  }

  for (int i = 0; i < N; i++)
  {
    if (AC.at(i) > 0)
    {
      ans++;
      penalty += WA.at(i);
    }

    // cout << "AC(" << i << ") = " << AC.at(i) << " WA = " << WA.at(i) << endl;
  }
  cout << ans << " " << penalty << endl;
  return 0;
}


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

#define INF 0x3f3f3f3f

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

ll x;
ll t;

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

	cin >> x >> t;
	ll ans = x - t;
	if (ans < 0) cout << 0 << endl;
	else cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
import sys


def next_str() -> str:
    result = ""
    while True:
        tmp = sys.stdin.read(1)
        if tmp.strip() != "":
            result += tmp
        elif tmp != '\r':
            break
    return result


def next_int() -> int:
    return int(next_str())


def main() -> None:
    n = next_int()
    flg = False
        
    for i, v in enumerate(str(n)):
        if i != 0 and v != '9':
            flg = True

    print(int(str(n)[0]) + 9 * (len(str(n)) - 1) - flg)


if __name__ == '__main__':
    main()

Measured memory_bytes: 3064
import sys
input = sys.stdin.readline


n = int(input())
edges = [[] for _ in range(n)]

for _ in range(n-1):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    edges[a].append(b)
    edges[b].append(a)

seen = [-1] * n
todo = [(0, 0)]

while todo:
    node, prev = todo.pop()
    if seen[node] != -1:
        continue

    seen[node] = prev
    for to in edges[node]:
        if seen[to] != -1:
            continue
        todo.append((to, node))


colors = [0] * n

node = n-1
goal_to_start = [n-1]
while node:
    node = seen[node]
    goal_to_start.append(node)

length = len(goal_to_start)
limit = (length) // 2

colors = [0] * n
for node in goal_to_start[:limit]:
    colors[node] = 2

for node in goal_to_start[limit:]:
    colors[node] = 1

fennec_todo = [node for node in range(n) if colors[node] == 1]
snuke_todo = [node for node in range(n) if colors[node] == 2]


def paint(todo, my_color):
    while todo:
        node = todo.pop()
        for to in edges[node]:
            if colors[to]:
                continue

            colors[to] = my_color
            todo.append(to)


paint(fennec_todo, 1)
paint(snuke_todo, 2)

feccec_count = len([color for color in colors if color == 1])
snuke_count = len([color for color in colors if color == 2])

if feccec_count > snuke_count:
    print('Fennec ')

else:
    print('Snuke ')


Measured memory_bytes: 27704
import numpy as np

n = int(input())

div=1000000007

loop=(n)//10
amari=(n)%10

mod1=1
mod2=1
mod3=1
for i in range(0,loop):
  mod1=(mod1*(10**10 % div) ) % div
  mod2=(mod2*(9**10 % div) ) % div
  mod3=(mod3*(8**10 % div) ) % div
mod1=mod1*(10**amari % div)
mod2=mod2*(9**amari % div)
mod3=mod3*(8**amari % div)

#print (loop, amari)
#print (mod1, mod2, mod3)
print((((mod1-mod2*2))+mod3) % div)


Measured memory_bytes: 26856
/*
このコード、と～おれ!
Be accepted!
∧＿∧　
（｡･ω･｡)つ━☆・*。
⊂　　 ノ 　　　・゜+.
　しーＪ　　　°。+ *´¨)
 　　　　　　　　　.· ´¸.·*´¨) ¸.·*¨)
		  　　　　　　　　　　(¸.·´ (¸.·'* ☆
					*/

#include <stdio.h>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstring>
#include <vector>
#include <numeric>
#include <iostream>
#include <random>
#include <map>
#include <unordered_map>
#include <queue>
#include <regex>

#pragma GCC optimize("Ofast")
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define rep1(i, n) for(int i = 1; i <= (n); ++i)
#define rep2(i, n) for(int i = 2; i < (n); ++i)
#define repr(i, n) for(int i = n; i >= 0; --i)
#define reprm(i, n) for(int i = n - 1; i >= 0; --i)
#define printynl(a) printf(a ? "yes\n" : "no\n")
#define printyn(a) printf(a ? "Yes\n" : "No\n")
#define printYN(a) printf(a ? "YES\n" : "NO\n")
#define printin(a) printf(a ? "possible\n" : "inposible\n")
#define printdb(a) printf("%.50lf\n", a)//少数出力
#define printdbd(a) printf("%.16lf\n", a)//少数出力(桁少なめ)
#define prints(s) printf("%s\n", s.c_str())//string出力
#define all(x) (x).begin(), (x).end()
#define allsum(a, b, c) ((a + b) * c / 2)//等差数列の和、初項,末項,項数
#define pb push_back
#define priq priority_queue
#define rpriq priq<int, vector<int>, greater<int>>
#define deg_to_rad(deg) (((deg)/360.0)*2.0*PI)
#define rad_to_deg(rad) (((rad)/2.0/PI)*360.0)
#define Please return
#define AC 0

using ll = long long;

constexpr int INF = 1073741823;
constexpr int MINF = -1073741823;
constexpr ll LINF = ll(4661686018427387903);
constexpr ll MOD = 1000000007;
const double PI = acos(-1);

using namespace std;

void scans(string& str) {
	char c;
	str = "";
	scanf("%c", &c);
	if (c == '\n')scanf("%c", &c);//最初の改行対策
	while (c != '\n' && c != -1) {
		str += c;
		scanf("%c", &c);
	}
}

void scanc(char& str) {
	char c;
	scanf("%c", &c);
	if (c == -1)return;
	while (c == '\n') {
		scanf("%c", &c);
	}	str = c;
}

double acot(double x) {
	return PI / 2 - atan(x);
}

/*-----------------------------------------ここからコード-----------------------------------------*/


int main() {
	
	int n;
	scanf("%d", &n);
	vector<int> a(n);
	int count = 1;
	rep(i, n)scanf("%d", &a[i]);
	
	rep(i, n){
	  if(count == a[i]){
	    ++count;
		}
	}
	printf("%d\n", n - count + 1 == n ? -1 : n - count + 1);
	
	Please AC;
}


Measured memory_bytes: 1024
N = int(input())
d = list(map(int, input().split()))
d.sort()

abc = 0
arc = N

ans = 0
for k in range(1, 10 ** 5 + 1):
    while True:
        if abc >= N:
            break
        elif d[abc] < k:
            abc += 1
            arc -= 1
        else:
            break
    if abc == arc:
        ans += 1
    elif abc > arc:
        break

print(ans)


Measured memory_bytes: 14008
N, K = gets.chomp.split(" ").map(&:to_i);
A = gets.chomp.split(" ").map(&:to_i);
F = gets.chomp.split(" ").map(&:to_i);

aw = A.sort
fw = F.sort.reverse
R = []
(0...N).each{|i| R << [aw[i], fw[i], aw[i] * fw[i]]}

def sum_training_count(r, gool)
  r.select{|r| r[2] >= gool}.inject(0){|rst, r| rst + r[0] - gool / r[1]}
end

def binsearch(l, lc, h, hc, training, r)
  return h if h - l == 1
  lc = sum_training_count(r, l) if lc == -1
  hc = sum_training_count(r, h) if hc == -1
  m = (h - l)/2 + l
  mc = sum_training_count(r, m)
  if mc > training then
    return binsearch(m, mc, h, hc, training, r)
  else
    return binsearch(l, lc, m, mc, training, r)
  end
end

rmax = R.max_by{|r| r[2]}[2]
a_all = A.inject(:+)

if a_all <= K then
  puts 0
  exit
end

target = binsearch(0, a_all, rmax, -1, K, R)

puts target


Measured memory_bytes: 67348
use proconio::input;

fn main() {
    input! {
        s:String,t:String
    }

    let s = s.chars().collect::<Vec<char>>();
    let t = t.chars().collect::<Vec<char>>();
    let ma = s.len() - t.len() + 1;
    let mut ans = t.len();
    for start in 0..ma {
        let mut cnt = 0;
        for i in 0..t.len() {
            if t[i] != s[i + start] {
                cnt += 1;
            }
        }
        ans = if ans > cnt { cnt } else { ans };
    }
    println!("{}", ans)
}


Measured memory_bytes: 2172
//ProblemE

#ifdef _MYPC
#include "mypc.h"
#endif // _MYPC

#include <iostream>
#include <string>
#include <vector>
#include <bitset>
#include <list>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <algorithm>
#include <numeric>
#include <functional>
#include <memory>
#include <complex>
#include <cstdio>
#include <cstring>
#include <cmath>

using namespace std;

//ProblemE

class Solve {
private:
	auto get_cost(const vector<pair<int, char>>& p, const vector<int>& ib) {
		const int n = (int)ib.size();
		vector<vector<int>> rst(n, vector<int>(n + 1, 0));

		const char c = p[ib.front()].second;
		for (int i = 0; i < n; i++) {
			auto& b = rst[i];
			int cntb = 0;

			int cntw = 0;
			vector<bool> w(n + 1, false);
			for (int j = 0; j < ib[i]; j++) {
				if (p[j].second != c) {
					cntw++;
					w[p[j].first] = true;
				}
				else if (p[j].first > i) {
					cntb++;
				}
			}

			for (int j = 0; j <= n; j++) {
				b[j] = cntb + cntw;
				if (w[j]) cntw--;
			}
		}
		return rst;
	}

	void solve() {
		int n;
		cin >> n;

		vector<pair<int, char>> p(2 * n);
		vector<int> ib(n);
		vector<int> iw(n);
		
		for (int i = 0; i < n * 2; i++) {
			cin >> p[i].second >> p[i].first;
			p[i].first--;
			if (p[i].second == 'W') iw[p[i].first] = i;
			else ib[p[i].first] = i;
		}

		auto cb = get_cost(p, ib);
		auto cw = get_cost(p, iw);

		//dp[i][j]: i bs and j ws
		vector<vector<int>> dp(n + 1, vector<int>(n + 1, 0));
		
		dp[0][0] = 0;
		for (int j = 1; j <= n; j++) dp[0][j] = dp[0][j - 1] + cw[j - 1][0];
		for (int i = 1; i <= n; i++) {
			dp[i][0] = dp[i - 1][0] + cb[i - 1][0];
			for (int j = 1; j <= n; j++) {
				dp[i][j] = min(dp[i][j - 1] + cw[j - 1][i], dp[i - 1][j] + cb[i - 1][j]);
			}
		}

		int cnt = dp[n][n];

		cout << cnt << endl;
	}

public:
	Solve() { solve(); }
};

int main(int argc, char* argv[]) {
	unique_ptr<Solve> solve = make_unique<Solve>();
	return 0;
}


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


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

	int n,m,sum=0;
	cin>>n>>m;

	vector<int> v(n);

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

	int count=0;

	for(int i=0;i<n;i++){
		
		if((float)v[i]>=((float)sum/(float)(4*m)))
			count++;
	
	}

	if(count>=m)
		cout<<"Yes";
	else
		cout<<"No";

	return 0;
	}

		

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define int ll
#define double long double
#define YES {cout<<"YES"<<'\n';}
#define NO {cout<<"NO"<<'\n';}
#define Yes {cout<<"Yes"<<'\n';}
#define No {cout<<"No"<<'\n';}
#define yes {cout<<"yes"<<'\n';}
#define no {cout<<"no"<<'\n';}
void YN(bool flg){cout<<(flg?"YES":"NO")<<'\n';}
void Yn(bool flg){cout<<(flg?"Yes":"No")<<'\n';}
void yn(bool flg){cout<<(flg?"yes":"no")<<'\n';}
#define SORT(a) sort(a.begin(),a.end())
#define REVERSE(a) reverse(a.begin(),a.end())
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define out(n) {cout << n << '\n';}
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef vector<VI> VVI;
const int MOD = 1000000007;
const long long INF = 10e10;
const double PI = acos(-1.0);
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; }
template<class T>auto MAX(const T& a) { return *max_element(a.begin(),a.end()); }
template<class T>auto MIN(const T& a) { return *min_element(a.begin(),a.end()); }
int ABS(int a) {if(a<0) a = -a; return a;}
template<class T, class U>U SUM(const T& a, const U& v) { return accumulate(a.begin(),a.end(), v); }
template<class T, class U>U COUNT(const T& a, const U& v) { return count(a.begin(),a.end(), v); }
template<class T, class U>int LOWER(const T& a, const U& v) { return lower_bound(a.begin(),a.end(), v) - a.begin(); }
template<class T, class U>int UPPER(const T& a, const U& v) { return upper_bound(a.begin(),a.end(), v) - a.begin(); }
int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
int LCM(int a, int b) { int g = GCD(a, b); return a / g * b; }
int POW(int a, int n) { int r = 1; while (n > 0) { if (n & 1)r *= a; a *= a; n /= 2; }return r; }
int isPrime(int n){if(n<2){return 0;}for(int i=2; i*i<=n; i++){if(n%i==0){return 0;}}return 1;}
/*素因数分解*/map< int, int >prime_factor(int n){map< int, int > ret;for(int i = 2; i * i <= n; i++) {while(n % i == 0) {ret[i]++;n /= i;}}if(n != 1) ret[n] = 1;return ret;}
/*約数の個数*/int divisor_number(int n){auto p = prime_factor(n); int res = 1; for(auto x:p)res*=(x.second+1); return res;}
/*約数列挙*/vector<int> divisor(int n){vector<int> v; for(int i=1; i*i<=n; i++){if(n%i==0){v.push_back(i);if(i!=n/i){v.push_back(n/i);}}}sort(v.begin(),v.end()); return v;}
//----------------ライブラリとか----------------

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout<<fixed<<setprecision(15);

    int a,b,c,d; cin >> a >> b >> c >> d;
    if(a+b>c+d){out("Left");}
    else if(a+b==c+d){out("Balanced");}
    else out("Right")

    return 0;
}

Measured memory_bytes: 256
ma = lambda :map(int,input().split())
ni = lambda:int(input())
import collections
import math
import itertools
gcd = math.gcd
s = input()
t = input()
n = len(s)
c = 0
for i in range(n):
    if s[i] != t[i]:
        c+=1
print(c)


Measured memory_bytes: 9676