akhauriyash/Code-Regression huggingface dataset:
#<C>
import math
import itertools
n = int(input())
p = list(map(int,input().split()))
q = list(map(int,input().split()))
ans1=n
ans2=n
x = [i for i in range(1, n+1)]
for i in itertools.permutations(x,n):
    if p < list(i):
        ans1 -= 1
    if q < list(i):
        ans2 -= 1

print(abs(ans1-ans2))
    

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
#define pb push_back
#define gcd __gcd
bool compare(ll x, ll y){
    return x>y;
}
ll isprime(ll n){
    if(n==1) return 0;
    else if(n==2) return 1;
    else{
        for(ll i=2;i<=sqrt(n);i++){
            if(n%i==0) return 0;
        }
    return 1;   
    }
}
vector<ll> get_prime_less(ll n){
    ll array[n];
    vector<ll> factor;
    for(ll i=1;i<=n;i++) array[i]=i;
    ll prime[n];
    for(ll i=0;i<n;i++) prime[i]=1;
    for(ll i=2;i<=sqrt(n);i++){
        if(prime[i]==1){
            for(ll j=i*i;j<=n;j=j+i) prime[j]=0; 
            factor.push_back(i);
        }
    }
    return factor;
}
vector<ll> retain_index(ll arr[], ll n){ 
    vector<pair<ll, ll> > vp; 
    for (ll i = 0; i < n; ++i) { 
        vp.push_back(make_pair(arr[i], i)); 
    } 
    sort(vp.begin(), vp.end());
    vector<ll> retain;
    for (ll i = 0; i < vp.size(); i++) { 
        ll a = vp[i].second;
        retain.pb(a);
    }
    return retain;
}
int main(){
    ll a,b;
    cin>>a>>b;
    ll i;
    for(i=b*10;i<(b+1)*10;i++){
        if((i*8)/100 == a){
            cout<<i;
            break;
        }
    }   
    if(i==((b+1)*10)) cout<<"-1";
}


Measured memory_bytes: 256
def main():
    S = input()
    N = len(S)
    l, r = 0, N-1
    res = 0
    while l < r:
        lc = S[l]
        rc = S[r]
        if lc != rc:
            res += 1
        l += 1
        r -= 1

    print(res)

    

main()

Measured memory_bytes: 2940
#include <iostream>
#include <vector>
#include <string>
#include <map>
using namespace std;

int main() {
	int N;
	cin >> N;
	map<string, int> cards;
	for (int i = 0; i < N; i++) {
		string s;
		cin >> s;
		cards[s]++;
	}
	int M;
	cin >> M;
	for (int i = 0; i < M; i++) {
		string t;
		cin >> t;
		cards[t]--;
	}
	int max = 0;
	for (auto c : cards) {
		if (c.second > max) max = c.second;
	}
	cout << max;


}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string.h>
#define INF (1 << 30)
#define ll long long
#define MAX_N 16
using namespace std;

ll V, E;
ll G[MAX_N][MAX_N];
ll dp[1 << MAX_N][MAX_N];

ll rec(int S, int v) {
	if (dp[S][v] >= 0) {
		return dp[S][v];
	}

	if (S == (1 << V) - 1 && v == 0) {
		return dp[S][v] = 0;
	}

	ll res = INF;
	for (int u = 0; u < V; u++) {
		if (!(S >> u & 1)) {
			res = min(res, rec(S | 1 << u, u) + G[v][u]);
		}
	}
	return dp[S][v] = res;
}

int main() {
	cin.tie(0); ios::sync_with_stdio(false);
	cin >> V >> E;
	for (int i = 0; i < MAX_N;i++) {
		for (int j = 0; j < MAX_N;j++) {
			G[i][j] = INF;
		}
	}
	for (int i = 0; i < E; i++) {
		int s, t, d; cin >> s >> t >> d;
		G[s][t] = d;
	}
	memset(dp, -1, sizeof(dp));
	ll Ans = rec(0, 0);
	if (Ans == INF)cout << -1 << endl;
	else cout << Ans << endl;
}

Measured memory_bytes: 11316
import java.util.*;
public class Main{
	public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
      int n = sc.nextInt();
      int[] array = new int[n];
      int count = 0;
      int sum = 1;
      for(int i = 0;i < n;i++){
      	array[i] = sc.nextInt();
      }
      for(int i = 1;i < n;i++){
      	for(int j = 0;j < i;j++){
        	if(array[i] >= array[j]) count++;
        }
        if(count == i) sum++;
        count = 0;
      }
      System.out.println(sum);
    }
}

Measured memory_bytes: 21716
#include <bits/stdc++.h>
using namespace std;
using lint     = long long;
const lint inf = 1LL << 60;
const lint mod = 1000000007;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    lint n, m;
    cin >> n >> m;
    vector<lint> x(m);
    for (int i = 0; i < m; ++i) {
        cin >> x[i];
    }
    sort(x.begin(), x.end());
    vector<lint> dist;
    for (int i = 1; i < m; ++i) {
        dist.push_back(x[i] - x[i - 1]);
    }
    sort(dist.begin(), dist.end());
    lint need = m - n;
    if (need <= 0) {
        cout << 0 << "\n";
        return 0;
    }
    lint ret = 0;
    for (int i = 0; i < need; ++i) {
        ret += dist[i];
    }
    cout << ret << "\n";
    return 0;
}

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


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

    int n;
    cin >> n;
    int ans=0;
    rep (i, n) {
        int l,r;
        cin >> l >> r;
        ans+=r-l+1;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3644
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//using namespace __gnu_pbds;


//      DEEP

using namespace std;
#define boost ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define all(v) v.begin(),v.end()
#define pb push_back
#define endl '\n'
#define mp make_pair

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef pair<int,int> pi;
typedef pair<long long,long long> pll;
typedef set<int> si;




/*
typedef tree<int,null_type,less<int>,rb_tree_tag,
tree_order_statistics_node_update> indexed_set;
*/
/*
typedef tree<
pair<int, int>,
null_type,
less<pair<int, int>>,
rb_tree_tag,
tree_order_statistics_node_update> ordered_set;
*/

const ll mod = 1e9 + 7;
const ll mod1=998244353;
const double pie=3.1415926535;
                                                    //power
ull power(ull x,ull y){
   if(y==0) return 1;
   else{
     if(y%2==0) return power(x*x,y/2);
     else return x*power(x*x,(y-1)/2);
   }
}

                        //                    Modular Exponentiation

ll mod_power(ll x, ll y, ll m)
{
    ll r = 1;     // Initialize result

    x = x % m; // Update x if it is more than or equal to m

    if (x == 0) return 0; // In case x is divisible by m;

    while (y > 0)
    {
        // If y is odd, multiply x with result
        if (y & 1)
            r = (r*x) % m;

        // y must be even now
        y = y/2;
        x = (x*x) % m;
    }
    return r;
}

                                                      //GCD
ll gcd(ll x,ll y){
   if(y==0)return x;
   return gcd(y,x%y);
}
                                              // SIEVE

/*
bool isPrime[1000001];
void sieve(int N) {

        for(int i = 0; i <= N;++i) {
            isPrime[i]=true;
        }
        isPrime[0]=false;
        isPrime[1]=false;

        for(int i = 2; i * i <= N; ++i) {
             if(isPrime[i] == true) {
                 for(int j = i * i; j <= N ;j += i)
                     isPrime[j] = false;
            }
        }
    }
*/
/*
const int N=100001;
ll fact_inverse[N];
ll num_inverse[N];
ll fact[N];
void number_inverse(int m){
   num_inverse[0]=1;
   num_inverse[1]=1;
   for(int i=2;i<=N;i++){
     num_inverse[i]=num_inverse[m%i]*(m - m/i)%m;
   }
}

void factorial_inverse(int m){
   fact_inverse[0]=1;
   fact_inverse[1]=1;
   for(int i=2;i<=N;i++){
      fact_inverse[i]=(num_inverse[i]*fact_inverse[i-1])%m;
   }
}

void factorial(int m){
  fact[0]=1;
  for(int i=1;i<=N;i++)fact[i]=(i*fact[i-1])%m;
}

int modular_nCr(int n,int r,int m){
   ll res=((fact[n]*fact_inverse[r])%m *  fact_inverse[n-r])%m;
   return res;
}
*/

int main(){
    boost;
    int TESTS=1;
    //cin>>TESTS;
    while(TESTS--){
       string s;
       cin>>s;
       if(s[s.size()-1]=='s')cout<<s<<"es"<<endl;
       else cout<<s<<"s"<<endl;
 }
}

Measured memory_bytes: 3664
import std.stdio, std.conv, std.math, std.string, std.range, std.array, std.algorithm, std.typecons;

void main(){
    int[4] m;

    foreach(immutable int i; 0 .. 3) {
        auto buf = readln().strip().split().map!(to!int)();
        m[buf[0]-1] ++;
        m[buf[1]-1] ++;
    }

    foreach(immutable i; m) {
        if(i >= 3) {
            writeln("NO");
            return;
        }
    }

    writeln("YES");
}


Measured memory_bytes: 256
N=input()
cnt=0
bit=0
bitflag=0
cur=0
inf=float("inf")

Nd="".join(("0",N))


dp=[[inf for _ in range(2)] for _ in range(1000005)]
dp[0][0]=0
#print(dp)
for i in range(0,len(Nd),1):
    for j in range(2):
        x=int(Nd[len(Nd)-1-i])
        #print(x)
        x=x+j
        for a in range(0,10,1):
            ni=i+1
            nj=0
            b=a-x
            if b<0:
                nj=1
                b=b+10
            dp[ni][nj]=min(dp[ni][nj],dp[i][j]+a+b)

print(dp[len(Nd)][0])






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

int main(){
	int n;
	cin >> n;
	
	int anko = 0;
	
	vector<int> a(n);
	
	for(int i = 0; i < n; ++i){
		cin >> a.at(i);
	}
		
	while(true){
		bool odd = false;
		for(int i = 0; i < n; ++i){
			if(a.at(i) % 2 != 0){
				odd = true;
			}
		}
		if(odd) break;
	
	for(int i = 0; i < n; ++i){
		a.at(i) /= 2;
	}
	++anko;
}
	cout << anko << endl;
	
	return 0;
}


Measured memory_bytes: 256
#include <set>
#include <cstdio>
#include <algorithm>

using namespace std;

int n,m;
int a[100];
int w[10];
set<int> all_poss;

void init(){
    for(int i=0;i<n;i++)
        scanf("%d",a+i);

    for(int j=0;j<m;j++)
        scanf("%d",w+j);
}

void calc(int c,int init){
    if (c>=m)
        return;

    int plus=init+w[c];
    int minus=abs(init-w[c]);

    all_poss.insert(plus);
    all_poss.insert(minus);

    calc(c+1,init);
    calc(c+1,plus);
    calc(c+1,minus);
}

void filter(){
    int i=0;
    for(int j=0;j<n;j++){
        if (all_poss.count(a[j])==0){
            // printf("%d\n",a[j]);
            swap(a[i++],a[j]);
        }
    }
    n=i;
}

void makeup(){
    set<int> candidate;
    for (auto i:all_poss){
        candidate.insert(i+a[0]);
        candidate.insert(abs(i-a[0]));
    }

    for (int i=1;i<n;i++){
        for (auto j:candidate){
            if (all_poss.count(a[i]+j)==0&&all_poss.count(abs(j-a[i]))==0)
                candidate.erase(j);
        }
    }

    if (candidate.empty())
        puts("-1");
    else 
        printf("%d\n",*candidate.begin());
}

int main(){

    while(scanf("%d%d",&n,&m)&&(n!=0||m!=0)){
        all_poss=set<int>({0});
        init();
        calc(0,0);
        // for(auto i:all_poss)
        //     printf("%d ",i);
        // putchar('\n');
        filter();
        if (n==0){
            puts("0");
            continue;
        }
        makeup();
        // printf("%d\n",n);
    }   


    return 0;
}


Measured memory_bytes: 6840
//Problem: ABC 171 D
//Progress: Working
#include <iostream>
#include <map>
typedef long long int ll;
using namespace std;

map<ll, ll> mpl;

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	ll t, k, ans = 0;
	cin >> t;
	for(ll i=0; i<t; i++){
		cin >> k;
		mpl[k] += 1;
		ans += k;
	}
	ll q, a, b;
	cin >> q;
	while(q--){
		cin >> a >> b;
		ans -= mpl[a]*a;
		ans += mpl[a]*b;
		mpl[b] += mpl[a];
		mpl[a] = 0;
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 9464
#include <assert.h>
#include <limits.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using ll = long long;
using P = std::pair<ll, ll>;

#define rep(i, a, b) for (ll(i) = (a); i < (b); i++)
#define all(i) i.begin(), i.end()
#define debug(i) std::cerr << "debug "<< i << std::endl

// const ll MOD = 998244353;
const ll MOD = 1e9 + 7;

int main() {
  std::cin.tie(0);
  std::ios::sync_with_stdio(false);
  //問題文中の添え字が0-indexか1-indexか確認!

  ll k;
  std::cin>>k;

  std::vector<ll> a(k);
  rep(i,0,k)std::cin>>a[i];

  ll min=2,max=2;

  for(ll i=k-1;i>=0;i--){
    ll temp=(min/a[i])*a[i]+((min%a[i]==0)?0:a[i]);
    if(temp>max){
      std::cout<<-1;
      return 0;
    }
    ll temp2=(max/a[i])*a[i];
    min=temp;
    max=temp2+a[i]-1;
  }

  std::cout<<min<<" "<<max;

  return 0;
}


Measured memory_bytes: 1024
n = int(input())
h_list = list(map(int, input().split()))

# 高さが小さいものの方が早く目標に到達する
# どの花も目標に到達していないときは全てをプラス1
# 到達した花がある場合はそれを基準に2つに分け、同様に作業をする
count = 0
while True:
    if (n == 0):
        break
    p = 0
    check = 0
    for i in range(n):
        if (i == 0 and h_list[i] == 0):
            h_list.pop(i)
            # 数えたくないbreakよりcheckを増やし、あとでcountをcheckで引く
            check += 1
            n -= 1
            break
        elif (h_list[i] != 0):
            if (h_list[i] > 0):
                h_list[i] -= 1

        elif (i != 0 and h_list[i] == 0):
            break

    p += 1
    count += p
    count -= check

print(count)


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

typedef long long ll;
#define fi first
#define se second
#define SORT(a) sort(a.begin(),a.end())
#define REP(i,n) for (int i = 0;i < (n) ; i++) 
#define MP(a,b) make_pair(a,b)
 
using namespace std;

int main(){

    ll n;
    cin >> n;

   
    ll ans = 0;
    ll a[n];
    ll s=0;
    REP(i,n) cin >> a[i];
    int right = 0;
    for(int left = 0;left<n;left++){
        
        while(right < n && (a[right]^s) == (a[right] + s)){
            s += a[right];
            right++;
        }
		ans += right -left;
      
        if(left == right)right++;
        else s -= a[left];
         
    }
    cout << ans;
    
}


Measured memory_bytes: 1920
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
//using P = pair<int,int>;
//pow(x,n)
//cout << fixed << setprecision(桁数);


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

    rep(i,n+1){
        rep(j,n+1-i){
            int k=n-i-j;
            if(y==10000*i+5000*j+k*1000 and k>=0){
                cout << i << " " << j << " " << k << endl;
                return 0;
            }

        }
    }
    cout << -1 << " " << -1 << " " << -1 << endl;
}





Measured memory_bytes: 256
import sys
from collections import defaultdict
import bisect
import itertools
readline = sys.stdin.buffer.readline
# sys.setrecursionlimit(10**5)


def geta(fn=lambda s: s.decode()):
    return map(fn, readline().split())


def gete(fn=lambda s: s.decode()):
    return fn(readline().rstrip())


def main():
    N, M = geta(int)
    A = list(geta(int))
    A.sort()

    def c(x):
        """
        @return  # of handshake where hapiness >= x
        """
        ret = 0
        for a in A:
            ret += bisect.bisect_left(A, x - a)
        return N * N - ret

    left, right = 0, 2 * A[-1] + 1

    while left + 1 < right:
        middle = (left + right) // 2
        if c(middle) >= M:
            left = middle
        else:
            right = middle

    ans = 0
    Acum = list(itertools.accumulate(A[::-1]))[::-1]
    for a in A:
        idx = bisect.bisect_left(A, right - a)
        if idx < N:
            ans += Acum[idx] + a * (N - idx)
    ans += left * (M - c(right))

    print(ans)


if __name__ == "__main__":
    main()

Measured memory_bytes: 57008
#include<bits/stdc++.h>
#define all(v) (v).begin(),(v).end()
#define pb push_back
#define ppb pop_back
#define mp make_pair
#define ri(x) scanf("%d",&(x))
#define ri2(x,y) scanf("%d %d",&(x),&(y))
#define ri3(x,y,z) scanf("%d %d %d",&(x),&(y),&(z))
#define rll(x) scanf("%lld",&(x))
#define rll2(x,y) scanf("%lld %lld",&(x),&(y))
#define rll3(x,y,z) scanf("%lld %lld %lld",&(x),&(y),&(z))
#define gc(x) ((x) = getchar())
using namespace::std;

const long double PI = acos(-1);
const long long MOD = 1000000000 +7;

typedef long long ll;
typedef pair<ll,ll> pll;
typedef pair<ll,pll> tll;
typedef pair<int,int> ii;
typedef pair<int,ii> iii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<iii> viii;
typedef vector<ll> vll;
typedef vector<pll> vpll;
typedef vector<tll> vtll;
typedef vector<string> vs;
typedef set<int> si;
typedef set<ii> sii;
typedef set<iii> siii;

ll gcd(ll a, ll b){ return b==0?a:gcd(b,a%b);}

ll add(ll a, ll b, ll m = MOD){
	if(a >= m) a %= m;
	if(b >= m) b %= m;
	if(a < 0) a += m;
	if(b < 0) b += m;
	ll res = a+b;
	if(res >= m or res <= -m) res %= m;
	if(res < 0) res += m;
	return res;
}

ll mul(ll a, ll b, ll m = MOD){
	if(a >= m) a %= m;
	if(b >= m) b %= m;
	if(a < 0) a += m;
	if(b < 0) b += m;
	ll res = a*b;
	if(res >= m or res <= -m) res %= m;
	if(res < 0) res += m;
	return res;
}

ll pow_mod(ll a, ll b, ll m = MOD){
	ll res = 1LL;
	a = a%m;
	while(b){
		if(b&1) res = mul(res,a,m);
		b >>= 1;
		a = mul(a,a,m);
	}
	return res;
}

ll fastexp(ll a, ll b){
	ll res = 1LL;
	while(b){
		if(b&1) res = res*a;
		b >>= 1;
		a *= a;
	}
	return res;
}

int gcdExtendido(int a, int b, int *x, int *y){
	if(a == 0){
		*x = 0;
		*y = 1;
		return b;
	}
	int x1, y1;
	int gcd = gcdExtendido(b%a,a,&x1,&y1);
	
	*x = y1-(b/a)*x1;
	*y = x1;
	return gcd;
}

int modInverso(int a, int m){
	int x, y;
	int g = gcdExtendido(a,m,&x,&y);
	if(g!=1) return -1;
	else return (x%m + m)%m;
}

/****************************************
*************P*L*A*N*T*I*L*L*A************
*****************************************/

const int N = 2000+5;

int n;
int x;
int y;
vi G[N];
int D[N];
int ans[N];

void solve(int src){
	for(int i=1; i<=n; i++) D[i] = 1<<29;
	D[src] = 0;
	priority_queue<ii> Q;
	Q.emplace(mp(0,src));
	while(!Q.empty()){
		int u = Q.top().second;
		int dis = -Q.top().first;
		Q.pop();
		if(D[u] < dis) continue;
		for(int v : G[u]){
			if(D[v] > D[u] + 1){
				D[v] = D[u] + 1;
				Q.emplace(mp(-D[v],v));
			}
		}
	}
	for(int i=src+1; i<=n; i++){
		if(D[i] >= n) continue;
		ans[D[i]] += 1;
	}
}

int main(){
	ri3(n,x,y);
	for(int i=1; i<n; i++){
		G[i].emplace_back(i+1);
		G[i+1].emplace_back(i);
	}
	G[x].emplace_back(y);
	G[y].emplace_back(x);
	for(int i=1; i<=n; i++){
		solve(i);
	}
	for(int i=1; i<n; i++){
		printf("%d\n",ans[i]);
	}
	return 0;
}


Measured memory_bytes: 512
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws Exception {
		String[] commandList = initCommand();
		doCommnand(commandList);
	}

	private static void doCommnand(String[] commandList) {
		int[] vectorList = new int[200000] ;
		int vectorIndex = -1;
		for (int i=0; i< commandList.length; i++) {
			String command = commandList[i];
			String[] commandDetail = command.split(" ", -1);
			if (commandDetail[0].equals("0")) {
				int value = Integer.parseInt(commandDetail[1]);
				if ( value < -1000000000 || value > 1000000000) {
					throw new IllegalArgumentException("command is illegal");
				}
				vectorIndex++;
				vectorList[vectorIndex] = value;
			} else if (commandDetail[0].equals("1")) {
				int index = Integer.parseInt(commandDetail[1]);
				if (0 <= index && index <= vectorIndex) {
					int value = vectorList[index];
					System.out.println(value);
				}
			} else if (commandDetail[0].equals("2")) {
				if (vectorIndex >= 0) {
					vectorIndex--;
				}
			}
		}
	}

	private static String[] initCommand() throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String numCommandStr = br.readLine();
		int commandNum = Integer.parseInt(numCommandStr);
		if (commandNum < 1 || commandNum > 200000) {
			throw new IllegalArgumentException("1 <= commandNum <= 200000");
		}

		String[] commandList = new String[commandNum];

		for (int i=0; i< commandNum; i++) {
			String command = br.readLine();
			if (command == null || command.isEmpty()) {
				throw new IllegalArgumentException("command is empty");
			}
			commandList[i] = command; 
		}
		return commandList;
	}
}



Measured memory_bytes: 93732
/*  
     author : hursh29    
     g++ : 17.3.20 
*/        
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define forn(i,a,b)        for( i = a ; i < b  ; i++ )
#define debug(x)           cout << #x << " " << x << "\n"
#define speedup            ios::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define ll                 long long  
#define p(x) 			   cout << x << "\n" ; 
#define MOD                998244353
#define pi                 pair<ll,ll>
#define vi                 vector <ll>
#define pb                 push_back
#define vp                 vector <pair<ll,ll>>
#define endl               cout << "\n"
#define mi                 map <int,int> 
#define f1                 first 
#define s1                 second    
#define in                 insert
#define all(x)             x.begin(),x.end() 
using namespace std ; 
using namespace __gnu_pbds;
typedef tree<int,null_type,less<int>,rb_tree_tag,
tree_order_statistics_node_update> indexed_set; 
const int N = 2e5+7; 
/*   
    time : 17 : 28      
    date : 20.12.2019
*/    
vi v[N]; 
int x,last,i,f,n;  
int solve(){
    cin >> n ;   
    forn(i,0,n){
      cin >> x ; 
      v[x].pb(i+1) ; 
    }
    if(v[1].empty())
    	return cout<<-1,0;   
   
    last = v[1][0];
    forn(i,2,n+1){
    	f = 0 ; 
    	for(auto it : v[i])
        if(it > last){
        	last = it ; 
        	f++ ; 
        	break ;  
        }
        if(f == 0 )
        	break ; 
    }
    i-- ; 
    n -= i ; 
    cout << n  ;   
    return 0 ; 
}
int main() { 
	speedup ;  
    int test  = 1 ; 
	//cin >> test  ; 
	while(test--)
    	solve() ; 
	 
	return 0;
} 


Measured memory_bytes: 11264
S = list(map(int, list(input())))
n = len(S)

num_0_even = 0
num_0_odd = 0

for i in range(n // 2):
    if S[2 * i] == 0:
        num_0_even += 1
    if S[2 * i + 1] == 0:
        num_0_odd += 1
if n % 2:
    if S[n - 1] == 0:
        num_0_even += 1

a = n // 2 + n % 2 - num_0_even + num_0_odd
b = num_0_even + n // 2 - num_0_odd

if a > b:
    print(b)
else:
    print(a)

Measured memory_bytes: 4652
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
#define pb push_back
#define fastio ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
#define ll long long
#define REP(i,a,b) for(int i=a;i<b;i++)
using namespace std;
int main()
{
    fastio
    ll n,k;
    cin>>n>>k;
    vector<ll> v(n);
    REP(i,0,n)
        cin>>v[i];
    sort(v.begin(),v.end(),greater<ll>());
    ll result=0;
    REP(i,k,n)
    {
        result+=v[i];
    }
    cout<<result<<"\n";
}

Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <random>
#include <chrono>
#include <queue>
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
#define INF 1000000000
#define MOD 1000000007
#define EPS 0.00000001



int main(){
    int N, K; cin >> N >> K;
    vector<PII> V(N);
    for(int i=0; i<N; i++){
        int t, d; cin >> t >> d;
        V[i] = PII(d, t);
    }
    
    sort(V.begin(), V.end(), greater<PII>());
    map<int, int> M;
    priority_queue<int, vector<int>, greater<int>> A;
    vector<PII> V2;
    ll init = 0;
    for(int i=0; i<N; i++){
        if(i<K){
            if(M[V[i].second]!=0) A.push(V[i].first);
            M[V[i].second]++;
            init += V[i].first;
        } else {
            V2.push_back(PII(V[i].second, V[i].first));
        }
    }
    ll div = M.size();

    sort(V2.begin(), V2.end());
    V2.push_back(PII(INF, INF));
    priority_queue<int> B;
    for(int i=0; i<V2.size()-1; i++){
        if(V2[i].first!=V2[i+1].first && M[V2[i].first]==0) B.push(V2[i].second);
    }
    

    ll ans = init + div*div;
    ll now = init;
    
    while(A.size() && B.size()){
        
        div++;
        now = now - A.top() + B.top();
        ans = max(ans, now + div*div);
        A.pop();
        B.pop();
    }
    
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 6264
#include <bits/stdc++.h>
#define int long long 
#define float long double 
#define el '\n'
#define IOS ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)

using namespace std;

#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__) << "] "

const int inf = 1e10;

signed main(){
        IOS;
        int n ;
        cin >> n;
        vector<int>arr(n),dp(n,inf);
        dp[0] = 0;
        for(int& i : arr) cin >> i ;
        for(int i=0;i<n;i++){
                for(int j=1;j<=2;j++){
                        if(i+j<n){
                                dp[i+j] = min(dp[i]+abs(arr[i+j]-arr[i]),dp[i+j]);
                        }
                }
        }
        cout << dp[n-1] << endl; 
        return 0;
}

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

int N,i,j,a;
int64_t ans=0,cnt=0;
map<int,int> mp;
int main(){
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  // ifstream in("input.txt");
  // cin.rdbuf(in.rdbuf());

  cin>>N;
  for(i = 0;i < N;i++){
    cin >> a;
    mp[a]++;
  }
  for(auto itr = mp.begin(); itr != mp.end();++itr) {
    j = (itr->second);
    if(j%2 == 0){
      ans += (j-2)/2;
      cnt++;
    }else{
      ans += (j-1)/2;
    }
  }
  ans += (cnt+1)/2;
  cout << N - 2*ans << endl;
  return 0;
}

Measured memory_bytes: 4992
l, r = map(int, input().split())
lr_ans = []
if r - l  >= 2019:
    print(0)
    exit()
for i in range(l, r+1):
    for j in range(i+1, r+1):
        lr_ans.append((i*j)%2019)
print(min(lr_ans))

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

using namespace std;
using ll = long long;
// #define int ll
using PII = pair<ll, ll>;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()

template<typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template<typename T> bool IN(T a, T b, T x) { return a<=x&&x<b; }
template<typename T> T ceil(T a, T b) { return a/b + !!(a%b); }

template<typename T> vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts) {
    return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}
template<typename T,typename V> typename enable_if<is_class<T>::value==0>::type
fill_v(T &t, const V &v) { t=v; }
template<typename T,typename V> typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t, const V &v ) { for(auto &e:t) fill_v(e,v); }

template<class S,class T>
ostream &operator <<(ostream& out,const pair<S,T>& a) {
    out<<'('<<a.first<<','<<a.second<<')'; return out;
}
template<class T>
ostream &operator <<(ostream& out,const vector<T>& a){
    out<<'[';
    for(const T &i: a) out<<i<<',';
    out<<']';
    return out;
}
template<class T>
ostream &operator <<(ostream& out, const set<T>& a) {
    out<<'{';
    for(const T &i: a) out<<i<<',';
    out<<'}';
    return out;
}
template<class T, class S>
ostream &operator <<(ostream& out, const map<T,S>& a) {
    out<<'{';
    for(auto &i: a) out<<i<<',';
    out<<'}';
    return out;
}

int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0}; // DRUL
const int INF = 1<<30;
const ll LLINF = 1LL<<60;
const ll MOD = 1000000007;

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

    ll n;
    cin >> n;

    ll nn = n;
    bool flag = true;
    while(nn>1) {
        if(nn%2==1) flag = false;
        nn /= 2;
    }
    if(flag) {
        cout << "No" << endl;
        return 0;
    }

    vector<PII> ans;
    ans.push_back({0, 1});
    ans.push_back({1, 2});
    ans.push_back({2, n});
    ans.push_back({n, n+1});
    ans.push_back({n+1, n+2});
    for(ll i=3; i+1<n; i+=2) {
        ans.push_back({i, n});
        ans.push_back({i+1, n});
        ans.push_back({i, i+n+1});
        ans.push_back({i+1, i+n});
    }
    if(n%2 == 0) {
        // n = 1 xor x xor y;
        ll x = 1;
        FOR(i, 1, 20) {
            if((n+1)&1<<i) {
                x |= 1<<i;
                break;
            }
        }
        ll y = n ^ 1 ^ x;
        if(x == 2) x += n;
        if(y == 2) y += n;
        ans.push_back({x-1, n-1});
        ans.push_back({y-1, n*2-1});
    }

    cout << "Yes" << endl;
    for(auto p: ans)  cout << p.first+1 << " " << p.second+1 << endl;

    return 0;
}


Measured memory_bytes: 6380
#include <iostream>

using namespace std;

int main() {
	int A, B, C, D;
	cin >> A >> B >> C >> D;
	int takahashibeat, aokibeat;
	takahashibeat = (C+B-1) / B;
	aokibeat = (A+D-1) / D;
	if (takahashibeat > aokibeat) {
		cout << "No" << endl;
	}
	else {
		cout << "Yes" << endl;
	}
}

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

using namespace std;

int main() {
  int N;
  cin >> N;
  map<int, int> m;
  vector<int> v;
  for (int i = 0; i < N; i++) {
    int a;
    cin >> a;
    m[a]++;
    if (m[a] % 2 == 0) v.push_back(a);
  }
  if (v.size() < 2) {
    cout << 0 << endl;
    return 0;
  }
  sort(v.rbegin(), v.rend());
  long long ans = (long long)v[0] * v[1];
  cout << ans << endl;

  return 0;
}
/* vim:set fdm=marker: */


Measured memory_bytes: 4992
from sys import stdin
il = lambda func=int: list(map(func, stdin.readline().rstrip().split()))
ils = lambda n, s="int(input())": [eval(s) for _ in range(n)]
def gcd(a, b):
    if a < b: return gcd(b, a)
    if b == 0: return a
    return gcd(b, a%b)

n = int(input())
t = ils(n)
ans = t[0]
for i in t[1:]:
    ans = ans * i // gcd(ans, i)
print(ans)

Measured memory_bytes: 3064
#ABC122B
S = input()
count_max = 0
count = 0
for i in range(len(S)):
    if "A" in S[i] or "C" in S[i] or"G" in S[i] or"T" in S[i]:
        count += 1
    #最長のACGT文字列が、文字列の末尾にあるときに対応する
        if i+1 == len(S) and count>count_max:
            count_max = count
    #まだ列が途中であって、文字が途切れた時、maxを更新する
    elif count > count_max:
            count_max = count
            count = 0
print(count_max)

Measured memory_bytes: 3060
/**
SXR0aXAkI0JwbXptI3FhI3Z3I293bCNqY2IjUG0jMCNicG0jVHFkcXZvLyNCcG0jQW10bjBhY2phcWFicXZvLyNNYm16dml0MSNWdyNhdGN1am16I2tpdiNhbXF9bSNQcXUjVnd6I0F0bW14MSNQcWEjaXptI2l0dCNicHF2b2EjUXYjYnBtI3BtaWRtdmEjaXZsI3d2I21pemJwMSNFcHcjcWEjYnBtem0ja2l2I3F2Ym16a21sbSNRdiNQcWEjeHptYW12a20jbXtrbXhiI0lhI3BtI3htenVxYmJtYnBHI1BtI3N2d2VtYnAjRXBpYiMraXh4bWl6bWJwI2J3I1BxYSNrem1pYmN6bWEjSWEsI0ptbnd6bSN3eiNJbmJteiN3eiNKbXBxdmwjYnBtdTEjVnd6I2FwaXR0I2JwbXwja3d1eGlhYSNJY29wYiN3biNwcWEjc3Z3ZXRtbG9tI017a214YiNpYSNQbSNlcXR0bWJwMSNQcWEjYnB6d3ZtI2x3YnAjbXtibXZsI1dkbXojYnBtI3BtaWRtdmEjSXZsI3d2I21pemJwLyNpdmwjUG0jbm1tdG1icCNWdyNuaWJxb2NtI3F2I29jaXpscXZvI0l2bCN4em1hbXpkcXZvI2JwbXUvI053eiNQbSNxYSNicG0jVXdhYiNQcW9wMSNCcG0jQWN4em11bSMrcXYjb3R3enwsMQ==
*/
#include <cstring>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <queue>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cassert>

#define F first
#define S second
#define endl '\n'
#define deb(x) cout<<#x<<' '<<x<<endl;
#define pb push_back

/*
#ifdef IZI_KATKA
#define int __int64_t
#else
#define int __int64
#endif
*/

const long long MOD = 1e9 + 7;
const long long MAXN = 1e6 + 1;
using namespace std;

typedef long long ll;

long long readInt() {
    bool minus1 = false;
    long long result = 0;
    char ch;
    ch = getchar();
    while (true) {
        if (ch == '-') break;
        if (ch >= '0' && ch <= '9') break;
        ch = getchar();
    }
    if (ch == '-') minus1 = true; else result = ch-'0';
    while (true) {
        ch = getchar();
        if (ch < '0' || ch > '9') break;
        result = result*10 + (ch - '0');
    }
    if (minus1)
        return -result;
    else
        return result;
}

int ans[MAXN];

int main() {
	#ifdef IZI_KATKA
	assert(freopen("input", "r", stdin));
    assert(freopen("output", "w", stdout));
    #endif
    int n = readInt(), x = readInt();
    if (x == 1 || x == 2 * n - 1) {
    	cout << "No";
    	return 0;
    } 
	if (x == 2) {
		///3 2 1 4
		set< int > s;
		for (int i = 1; i <= 2 * n - 1; i ++) {
			s.insert(i);
		}
		s.erase(1);
		s.erase(2);
		s.erase(3);
		s.erase(4);
		ans[n - 1] = 3;
		ans[n] = 2;
		ans[n + 1] = 1;
		ans[n + 2] = 4;
		for (int i = 1; i <= 2 * n - 1; i++) {
			if (!ans[i]) {
				ans[i] = *s.begin();
				s.erase(s.begin());
			}
		}
		cout << "Yes\n";
		for (int i = 1; i <= 2 * n - 1; i ++) {
			cout << ans[i] << endl;
		}
	} else {
		/// x - 1, x, x + 1, x - 2
		set< int > s;
		for (int i = 1; i <= 2 * n - 1; i ++) {
			s.insert(i);
		}
		s.erase(x);
		s.erase(x + 1);
		s.erase(x - 1);
		s.erase(x - 2);
		ans[n - 1] = x - 1;
		ans[n] = x;
		ans[n + 1] = x + 1;
		ans[n + 2] = x - 2;
		for (int i = 1; i <= 2 * n - 1; i++) {
			if (!ans[i]) {
				ans[i] = *s.begin();
				s.erase(s.begin());
			}
		}
		cout << "Yes\n";
		for (int i = 1; i <= 2 * n - 1; i ++) {
			cout << ans[i] << endl;
		}
	}
    return 0;
}       

Measured memory_bytes: 11648
// at_abc138c.cpp : This file contains the 'main' function. Program execution begins and ends there.
//

#include <iostream>
#include<vector>
#include<iomanip>
#include<algorithm>
using namespace std;
int main()
{
    int num;cin >> num;
    vector<int>v(num, 0);
    for (int i = 0;i < num;i++) {
        cin >> v[i];
    }
    sort(v.begin(), v.end());
    double pot = v[0];
    for (int i = 1;i < num;i++) {
        pot += v[i];
        pot /= 2;;
    }
    cout << fixed << setprecision(8) << pot << "\n";
}

// Run program: Ctrl + F5 or Debug > Start Without Debugging menu
// Debug program: F5 or Debug > Start Debugging menu

// Tips for Getting Started: 
//   1. Use the Solution Explorer window to add/manage files
//   2. Use the Team Explorer window to connect to source control
//   3. Use the Output window to see build output and other messages
//   4. Use the Error List window to view errors
//   5. Go to Project > Add New Item to create new code files, or Project > Add Existing Item to add existing code files to the project
//   6. In the future, to open this project again, go to File > Open > Project and select the .sln file


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

int main()
{
  int n, m, c;
  scanf("%d%d%d", &n, &m, &c);
  int b[m];
  for(int i = 0; i < m; i++)
    scanf("%d", &b[i]);
  int ans = 0;
  for(int i = 0; i < n; i++)
  {
    int sum = 0;
    for(int j = 0; j < m; j++)
    {
      int a;
      scanf("%d", &a);
      sum += a * b[j];
    }
    ans += (sum + c > 0);
  }
  printf("%d\n", ans);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define sz(c)      int(c.size())
#define rep(i,a,b) for (int i=a; i<(b); ++i)
#define per(i,a,b) for (int i=(b)-1; i>=(a); --i)
using namespace std;
using i64 = long long;

int const MAXD=11;
int const MAXG=110000;
int D,G;
int p[MAXD], c[MAXD];
int f[2][MAXG];


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

  cin>>D>>G;
  G/=100;
  rep(i,0,D) {
    cin>>p[i]>>c[i];
    c[i]/=100;
  }

  f[0][0]=0;
  rep(i,1,G+1) f[0][i]=1001;

  rep(i,0,D) {
    int curr=i%2;
    int next=!curr;
    rep(j,0,G+1) f[next][j]=f[curr][j];

    rep(j,1,p[i]+1) {
      per(k,0,G+1) if (f[curr][k]!=-1) {
        int nk=k+(i+1)*j;
        if (j==p[i]) nk+=c[i];
        nk=min(nk,G);
        f[next][nk]=min(f[next][nk],f[curr][k]+j);
      }
    }
  }

  cout<<f[D%2][G]<<"\n";
}


Measured memory_bytes: 1152
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<ll, P> PP;
 
static const double EPS = 1e-8;
static const double PI = 4.0 * atan(1.0);
static const ll INF = 1023456789;
 
#define REP(i,n)	for(int i=0;i<n;++i)
#define REPR(i,n)	for(int i=n-1;i>=0;--i)
#define FOR(i,s,n)	for(int i=s;i<n;++i)
#define FORR(i,s,n)	for(int i=n-1;i>=s;--i)
#define ALL(c)		(c).begin(),(c).end()
#define CLEAR(v)	memset(v,0,sizeof(v))
#define MP(a,b)		make_pair((a),(b))
#define ABS(a)		((a)>0?(a):-(a))
#define F			first
#define S			second
 
int main(int argc, char **argv) {
	int n, a;
	cin >> n >> a;
	cout << (n % 500 <= a ? "Yes" : "No") << endl;
	return 0;
}
 

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

int K, A, B;

int main()
{
	scanf("%d", &K);
	scanf("%d%d", &A, &B);
	for (int i=A; i<=B; i++) if (i%K == 0) { puts("OK"); return 0; }
	puts("NG");
}

Measured memory_bytes: 3764
#include <atcoder/all>
#include <bits/stdc++.h>
using namespace std;
using namespace atcoder;
#define int long long
   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; }
    const int MAX =200005;
const int MOD =1000000007;

signed main(){
  int n,m;
  cin>>n>>m;
  string s[n];
  for(int i=0;i<n;i++)cin>>s[i];
  bool used[n][m];
    mcf_graph<int,int> g(n*m+110);
    int t=1;
  for(int i=0;i<n;i++)for(int j=0;j<m;j++){
    if(s[i][j]!='o')continue;
    g.add_edge(n*m,n*m+t,1,0);
    t++;
    for(int i0=0;i0<n;i0++)fill(used[i0],used[i0]+m,false);
    queue<pair<int,int>> que;
    que.push({i,j});
    used[i][j]=true;
  g.add_edge(n*m+t-1,i*m+j,1,MOD-(i-i+j-j));
    while(!que.empty()){
      int i0=que.front().first,j0=que.front().second;
      que.pop();
     
      if(i0+1<n&&!used[i0+1][j0]&&s[i0+1][j0]!='#'){
        que.push({i0+1,j0});
        used[i0+1][j0]=true;
        g.add_edge(n*m+t-1,(i0+1)*m+j0,1,MOD-(i0+1-i+j0-j));
      }
      if(j0+1<m&&!used[i0][j0+1]&&s[i0][j0+1]!='#'){
        que.push({i0,j0+1});
        used[i0][j0+1]=true;
        g.add_edge(n*m+t-1,i0*m+j0+1,1,MOD-(i0-i+j0+1-j));
      }

    }
  }
  for(int i=0;i<n;i++)for(int j=0;j<m;j++)g.add_edge(i*m+j,n*m+t,1,0);
pair<int,int>ans=g.flow(n*m,n*m+t);
  cout<<MOD*ans.first-ans.second<<endl;


}


Measured memory_bytes: 8756
n=int(input())
a=list(map(lambda x: int(x), input().split()))

ans_plus=0
tmp=0
if a[0]<=0:
    ans_plus=1-a[0]
    tmp=1
else:
    tmp=a[0]
plus_flag=False
for i in a[1:]:
    tmp+=i
    if plus_flag==True and tmp>0:
        pass
    elif plus_flag==True and tmp<=0:
        ans_plus+=1-tmp
        tmp=1
    elif plus_flag==False and tmp<0:
        pass
    elif plus_flag==False and tmp>=0:
        ans_plus+=1+tmp
        tmp=-1
    plus_flag=not plus_flag
#print(ans_plus)

ans_minus=0
tmp=0
if a[0]>=0:
    ans_minus=1+a[0]
    tmp=-1
else:
    tmp=a[0]
plus_flag=True
for i in a[1:]:
    tmp+=i
    if plus_flag==True and tmp>0:
        pass
    elif plus_flag==True and tmp<=0:
        ans_minus+=1-tmp
        tmp=1
    elif plus_flag==False and tmp<0:
        pass
    elif plus_flag==False and tmp>=0:
        ans_minus+=1+tmp
        tmp=-1
    plus_flag=not plus_flag
#print(ans_minus)
print(min(ans_plus, ans_minus))

Measured memory_bytes: 14332
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MAX_V = 200;
const ll inf = 100100100100100100;
ll V,D[MAX_V][MAX_V];
void WarshallFloyd(){
  ll i,j,k;
  for(i=0;i<V;i++) D[i][i] = 0;
  for(k=0;k<V;k++){
    for(i=0;i<V;i++){
      for(j=0;j<V;j++) D[i][j] = min(D[i][j],D[i][k]+D[k][j]);
    }
  }
}
int main(){
  ll E,R,i,a,b,c,ans = inf,now;scanf("%lld%lld%lld",&V,&E,&R);
  ll r[R];
  for(i=0;i<V;i++) fill(D[i],D[i]+V,inf);
  for(i=0;i<R;i++){
    scanf("%lld",&r[i]);r[i]--;
  }
  sort(r,r+R);
  for(i=0;i<E;i++){
    scanf("%lld%lld%lld",&a,&b,&c);a--;b--;
    D[a][b] = D[b][a] = c;
  }
  WarshallFloyd();
  do{
    now = 0;
    for(i=0;i<R-1;i++) now += D[r[i]][r[i+1]];
    ans = min(ans,now);
  }while(next_permutation(r,r+R));
  printf("%lld\n",ans);
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
#define yes cout<<"Yes"<<endl;
#define no cout<<"No"<<endl;
#define ll long long int
using namespace std;
int main()
{
    ll tc;
    ll a,b,c,n,x,y,z,cnt=0,sum=0;
    string str;
    cin>>n;
    if(n/10==9||n%10==9)
    {
        yes

    }
    else no

}


Measured memory_bytes: 3588
#include "bits/stdc++.h"
using namespace std;

#define _ ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define forn(i, n) for (int i = 0; i < n; i++)
#define fin(ds) for (auto &v : ds) cin >> v;
#define all(a) (a).begin(), (a).end()
#define pii pair<int, int>
#define pll pair<ll, ll>
#define nl '\n'

typedef long long ll;

vector<vector<char>> subsets(vector<char>& v) {
    size_t n = v.size();
    vector<vector<char>> subsets;
    for (int b = 0; b < (1<<n); b++) {
        vector<char> ss;
        for (int i = 0; i < b; i++) {
            if (b&(1<<i)) ss.push_back(v[i]);
        }
        if (ss.size() <= 3) {
            subsets.push_back(ss);
        }
    }
    return subsets;
}

signed main() { _
    int n; cin >> n;
    
    ll people = 0;
    map<char, int> counts;
    vector<char> pep;
    forn(i, n) {
        string s; cin >> s;
        if (s[0] == 'M' || s[0] == 'A' || s[0] == 'R' || s[0] == 'C' || s[0] == 'H') {
            if (!counts.count(s[0])) {
                counts[s[0]] = 1;
                pep.push_back(s[0]);
            } else {
                counts[s[0]]++;
            }
        }
    }
    
    vector<vector<char>> comb = subsets(pep);
    for (vector<char> ss : comb) {
        if (ss.size() == 3) {
            ll cur = 1;
            for (char c : ss) {
                cur *= counts[c];
            }
            people += cur;
        }
    }
    
    cout << people << nl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define RANGE(i,n) for(int i=0;i<n;i++)
typedef long long ll;

using namespace std;

signed main() {
    int a,b,c,d,e,k;
    cin >>a>>b>>c>>d>>e>>k;
    if(e - a > k){
        cout << ":(" << endl;
    }else{
        cout << "Yay!"  << endl;
    }
}


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

typedef long long ll;

ll n, k, c[30];
set<string> wow;

bool cmp(int a, int b) {
	return a > b;
}

int main() {

	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	memset(c, 0, sizeof(c));

	cin>>n>>k;

  	string a;
	for(ll i=0;i<n;i++) {
		cin>>a;
		if(wow.count(a) == 0) {
			wow.insert(a);
			c[a[0] - 'A']++;
		}
	}

	ll ans = 0;

	while(1) {
		sort(c, c+26, cmp);
		ll used = 0;
		for(ll i=0;i<26;i++) {
			if(c[i] > 0) {
				c[i]--;
				used++;
				if(used == k) break;
			}
		}
		if(used < k) break;
		else ans++;
	}

	cout<<ans<<endl;
}

Measured memory_bytes: 1152
M=10**9+7
o=->a,n{n<1?1:a**n[0]*o[a,n/2]**2%M}
eval'N,A,B,C='+gets.split*?,
f=f=1,*(1..2*N).map{|i|f=f*i%M}
a=o[A*=t=o[A+B,M-2],N]
b=o[B*=t,N]
z=0
N.times{|i|z+=(N+i)*f[N+i-1]*o[f[N-1]*f[i],M-2]*(a+b)
z%=M
a=a*B%M
b=b*A%M}
p z*100*o[100-C,M-2]%M

Measured memory_bytes: 4988
// c++include
#include <iostream>
// cinclude
#include <stdio.h>
#include<string.h>
#include<math.h>
//c++標準ライブラリ
#include<vector>
#include<string>
//std使用<-namespace
using namespace std;

// define, typedef
#define rpt(i, n) for(i = 0; i < (n); i++)
typedef long long ll;

// main関数
int main(void) {
	int n, i;
	cin >> n;
	vector<ll> b;
	ll tmp;
	rpt(i, n - 1) {
		cin >> tmp;
		b.push_back(tmp);
	}
	ll sum = 0;
	rpt(i, n - 1) {
		if (i == 0) {
			sum += b[i];
		}
		else {
			if (b[i] <= b[i - 1]) {
				sum += b[i];
			}
			else {
				sum += b[i - 1];
			}
		}
		if (i == n - 2) {
			sum += b[i];
		}

	}
	cout << sum;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end())
#define VRSORT(v) sort(v.rbegin(), v.rend())//vectorの降順ソート
#define ll long long
#define pb(a) push_back(a)
#define INF 1000000000
#define MOD 1000000007
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

typedef vector<unsigned int>vec;
typedef vector<vec> mat;

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


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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,a,b,c,d;
    string s;
    cin>>n>>a>>b>>c>>d;
    cin>>s;
    --a,--b,--c,--d;
    bool block=false;
    int tmp=0;
    bool ok=false;


    if(d<c){
        for(int i=b;i<=d;i++){
            if(s[i-1]=='.'&&s[i]=='.'&s[i+1]=='.') ok=true;
        }
    }

    for(int i=a;i<=c;i++){
        if(s[i]=='#'&&s[i+1]=='#') block=true;
    }
    for(int i=b;i<=d;i++){
        if(s[i]=='#'&&s[i+1]=='#') block=true;
    }
    
    if(block){
        cout<<"No"<<endl;
        return 0;
    }
    if(c<d){
        cout<<"Yes"<<endl;
        return 0;
    }
    else{
        if(ok){
            cout<<"Yes"<<endl;
            return 0;
        }
        else{
            cout<<"No"<<endl;
            return 0;
        }
    }
    assert(0);
    //cout<<"No"<<endl;
}

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

int main(){
  int N;
  cin >>N;
  string S;
  cin >>S;
  char b=S[0];
  int ans=N;
  for(int i=1;i<N;i++){
    if(S[i]==b){
      ans--;
    }
    else{
      b=S[i];
    }
  }
  cout << ans <<endl;
}

    
        

Measured memory_bytes: 3760
N=int(input())
Array = list(map(int, input().strip().split()))
array=list(set(Array))
array.sort()
n=len(array)
f=0
for i in range(0,n-2):
    for j in range(i+1,n-1):
        for w in range(j+1,n):
            if array[i]+array[j]>array[w]:
                f+=Array.count(array[i])*Array.count(array[j])*Array.count(array[w])
print(f)
            

Measured memory_bytes: 9204
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n, s=0;
  cin >> n;
  for (int i=0; i<n; i++) {
    int l, r;
    cin >> l >> r;
    s += r-l+1;
  }
  cout << s << endl;
}

Measured memory_bytes: 3560
# -*- coding: utf-8 -*-

import sys
import math


sys.setrecursionlimit(10 ** 6)

input_line = input()
inputs = input_line.split(' ')
N, = list(map(int, inputs))
input_line = input()
inputs = input_line.split(' ')
A = list(map(int, inputs))

ans = [0] * N
for a in A:
    ans[a-1] += 1

for a in ans:
    print(a)



Measured memory_bytes: 35356
import java.io.*
import java.util.*

var pw = PrintWriter(System.out)
const val MOD = 2019
fun solve(L: Int, R: Int){
    var ans = 2019*2019
    val range = when{
        R - L >= 2019 -> IntArray(2019){ it }.toList()
        else -> (L..R).toList().map{ it % 2019 }
    }
    // println(range.toString())
    for (i in 0 until range.size){
        for (j in i+1 until range.size){
            ans = Math.min(ans, (range[i] * range[j]) % 2019)
        }
    }
    println(ans)
    return
}


fun main(args: Array<String>) {
    fun StringArray(size: Int, init: (Int) -> String = { "\u0000" }): Array<String> {
        return Array<String>(size, init)
    }
    class Scanner(stream: InputStream) {
        private val reader = BufferedInputStream(stream).bufferedReader()
        private var st: StringTokenizer? = null
        fun next(): String {
            while (!(st?.hasMoreTokens() ?: false)) st = StringTokenizer(reader.readLine())
            return st!!.nextToken()
        }
    }
    val sc = Scanner(System.`in`)
    val L = sc.next().toInt()
    val R = sc.next().toInt()
    solve(L, R)
}



Measured memory_bytes: 31920