akhauriyash/Code-Regression huggingface dataset:
def is_prime(x):
    if x == 1:
        return False
    l = x ** 0.5
    n = 2
    while n <= l:
        if x % n == 0:
            return False
        n += 1
    return True

import sys

def solve():
    file_input = sys.stdin
    N = file_input.readline()
    cnt = 0
    for l in file_input:
        x = int(l)
        if is_prime(x):
            cnt += 1
    print(cnt)

solve()

Measured memory_bytes: 7812
fun main(args: Array<String>) {
    val N = readInputLine().toInt()
    val ss = Array<String>(N) { readInputLine() }
    ss.sort()

    var maxCnt = 1
    var cntTmp = 1

    var ans = mutableListOf<String>()

    for (i in 1 until N) {
        if (ss[i] != ss[i - 1]) {
            if (cntTmp > maxCnt) {
                ans.clear()
                ans.add(ss[i - 1])
                maxCnt = cntTmp
            } else if (cntTmp == maxCnt) {
                ans.add(ss[i - 1])
            }
            cntTmp = 1
        } else {
            cntTmp++
        }
    }

    if (cntTmp > maxCnt) {
        ans.clear()
        ans.add(ss[N - 1])
    } else if (cntTmp == maxCnt) {
        ans.add(ss[N - 1])
    }

    for (s in ans.sorted()) {
        println(s)
    }
}

fun readInputLine(): String {
    return readLine()!!
}


Measured memory_bytes: 76712
#include<bits/stdc++.h>
using namespace std;
#define fo(i,a,n) for(i=a;i<n;i++)
#define ll long long
#define deb(x) cout << #x << "=" << x << endl
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define sortrev(x) sort(all(x),greater<int>())
#define pi 3.1415926535897932384626

typedef pair<int,int> pii;
typedef pair<ll, ll> pl;
typedef vector<int>	vi;
typedef vector<ll>	vl;
typedef vector<pii>	vpii;
typedef vector<pl>	vpl;
typedef vector<vi>	vvi;
typedef vector<vl>	vvl;
typedef vector<double> vd;


const int mod = 1000000007;
const int inf = 100000005;
const int N = 200005, M = N;
int i,j,n,m;

ll cnt , idx;
vi temp;

void solve() {
   ll x,y;
   cin>>x>>y;

    ll k = y - x*2;
    ll k1 = -1;
    if(k%2==0) k1 = k / 2;
    ll k2 = x - k1;
    if(k1>=0 && k2>=0) cout<<"Yes\n";
    else cout<<"No\n";
}

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

    int t = 1;
    //cin >> t;
    while(t--) {
      solve();
    }

    return 0;
}




Measured memory_bytes: 3620
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define dunk(a) cout << (a) << endl
using namespace std;
typedef long long ll;

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

	ll ans = 0;
	if (n <= m / 2) {
		ans += n;
		m -= 2 * n;
		ans += m / 4;
	}
	else {
		ans += m / 2;
	}

	dunk(ans);

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define inf 1000000000000000000
long long a,b,c,k,ans;
int main(){
	scanf("%lld%lld%lld%lld",&a,&b,&c,&k);
	if (!(k%2)) ans=a-b;
	else ans=b-a;
	if (abs(ans)>inf) printf("Unfair\n");
	else printf("%lld\n",ans);
	return 0;
}

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

using namespace std;
using lli = int_fast64_t;
using ulli = uint_fast64_t;
#define debug(x) cerr << #x << " : " << x << endl
#define debugv(x) cerr << #x << " : {";for(auto value_of_x:x){ cerr << value_of_x << ", ";}cerr << endl
#define debugst(x) auto xt = x;cerr << #x << " : {";for(int i=0;i<x.size();i++){ cerr << xt.top() << ", ";xt.pop();}cerr << endl
#define debugvp(x) cerr << #x << " : {";for(auto value_of_x:x){ cerr << value_of_x.first << " : " << value_of_x.second << ", ";}cerr << endl
#define HYPP(x) hypot(x.first,x.second)

const lli MOD = 1000000007;
const lli LIMIT = 1000000000000000000 * 5;
const int tenfive = 100000;



int main() {
	int H, W, h, w;
	cin >> H >> W >> h >> w;
	cout << H * W - (H * w + h * W - h * w) << endl;
	return 0;
}


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

using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
#define a first
#define b second
#define bg begin()
#define ed end()
#define all(x) (x).bg,(x).ed
#define sz(x) (ll)((x).size())
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep1(i,n) for(ll i=1;i<=n;i++)

int main(){
	ll N; cin>>N;
	vector<ll>A(N);
	rep(i,N) cin>>A[i];
	sort(all(A));
	ll W=0;
	rep(i,N) W+=A[i];
	//ギリOKな大きさ求める
	ll l=0,r=N-1;
	while(r-l>=1){
		ll i=(l+r)/2;
		ll sum=0;
		rep(k,i+1) sum+=A[k];
		ll k=i+1;
		while(k<N && A[k]<=sum*2){
			sum+=A[k++];
		}
		if(sum!=W) l=i+1;//ダメ
		else r=i;
	}
	cout<<N-r;
}

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

using namespace std;
using ll=long long;
using ull=unsigned long long;
using pii=pair<int,int>;

#define INF LONG_MAX
#define MOD 1000000007
#define rng(a) a.begin(),a.end()
#define rrng(a) a.end(),a.begin()

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

  int A,B;
  cin>>A>>B;
  int c=1;
  int ans=0;
  while(c<B)c+=A-1,ans++;
  cout<<ans<<endl;
  return 0;
}


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

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

    bool flag = (n % 10 == 7 || (n / 10) % 10 == 7 || n / 100 == 7 ? true : false);

    cout << (flag ? "Yes" : "No") << endl;
    return 0;
}

Measured memory_bytes: 3600
#include<bits/stdc++.h>
constexpr long long INFL = 1LL << 60;
constexpr int INF = 1 << 30;

using namespace std;

using ll = long long;
using P = tuple<int, int>;
using iarr = valarray<int>;

int main()
{
    string s;
    cin >> s;
    s.replace(5, 1, " ");
    s.replace(13, 1, " ");
    cout << s << endl;
    return 0;
}


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

int main () {
    int t, num;
    scanf("%d", &num);
    int *a = calloc(sizeof(int), num);

    scanf("%d", &t); //???????£???°???
    int i;
    for ( i = 0; i < num; ++i ) {
        a[i] = i + 1;
    }

    int from, to;
    while ( scanf("%d,%d", &from, &to) != EOF ) {
        t = a[to - 1];
        a[to - 1] = a[from -1];
        a[from - 1] = t;
    }

    for ( i = 0; i < num; ++i ) {
        printf("%d\n", a[i]);
    }
    return 0;
}

Measured memory_bytes: 608
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long N = sc.nextLong();
		long result=0;
		for (long i=1;i*i<=N;i++) {
			result =i*i;
		}
		System.out.println(result);
	}
}

Measured memory_bytes: 35808
N = int(input())

P = []

S = 0

for i in range(N):
    P.append(list(map(int,input().split())))

for i in range(N-1):
    for j in range(N-1-i):
        
        S += (((P[i][0] - P[i+j+1][0])**2 + (P[i][1] - P[i+j+1][1])**2)**0.5)*2
        
print(S/N)    

Measured memory_bytes: 38256
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <map>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <numeric>
using namespace std;

int main()
{
    vector<bool> isPos;
    int N, K;
    cin >> N >> K;

    isPos.resize(N);
    for (int i = 0; i < N;i++){
        isPos[i] = false;
    }

        for (int i = 0; i < K; i++)
        {
            int cnt;
            cin >> cnt;
            for (int j = 0; j < cnt;j++)
            {
                int nem;
                cin >> nem;
                isPos[nem - 1] = true;
            }
        }

        int count = 0;
        for (int i = 0; i < N;i++)
        {
            if( !isPos[i] ){
                count++;
            }
        }

        cout << count << endl;
        return 0;
}



Measured memory_bytes: 3632
n, a, b = [int(i) for i in input().split()]
x = [int(i) for i in input().split()]
ans = 0
for i in range(n - 1):
    if (x[i + 1] - x[i]) * a > b:
        ans += b
    else:
        ans += (x[i + 1] - x[i]) * a
print(ans)        

Measured memory_bytes: 14252
#include <bits/stdc++.h>
using namespace std;
struct Edge {
    int to;     // 辺の行き先
    int weight; // 辺の重み
    Edge(int t, int w) : to(t), weight(w) { }
};
using Graph = vector<vector<int> >;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define reprep(i,j,h,w) rep(i,h)rep(j,w)
#define rrep(i,m, n) for(int i = m; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define aall(x,n) (x).begin(),(x).begin()+(n)
#define VEC(type,name,n) std::vector<type> name(n);rep(i,n)std::cin >> name[i];
#define pb push_back
#define pf push_front
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define mk make_pair
#define sum accumulate
#define keta fixed<<setprecision
#define vvector(name,typ,m,n,a)vector<vector<typ> > name(m,vector<typ> (n,a))
#define vvvector(name,t,l,m,n,a) vector<vector<vector<t> > > name(l, vector<vector<t> >(m, vector<int>(n,a)));
typedef long long ll;
const int INF = 2000000000;
const long INF64 = 1000000000000000ll;
const ll MOD = 1000000007LL;
typedef unsigned int uint;
int main(){
    int n;
    std::cin >> n;
    std::vector<int> dp(100001,INF);
    dp[0]=0;
    std::vector<int> a;
    a.pb(1);
    for (int i = 1; pow(6,i)<=100000; i++) {
        /* code */
        a.pb(pow(6,i));
    }
    for (int i = 1; pow(9,i)<=100000; i++) {
        /* code */
        a.pb(pow(9,i));
    }
    sort(all(a));
    for (auto i : a) {
        /* code */
       // std::cout << i << std::endl;
    }
    rep(i,100000){
        for (int j = 0; i+a[j] <= 100000 ; j++) {
            /* code */
            dp[i+a[j]]=min(dp[i+a[j]],dp[i]+1);
            //std::cout << dp[i+a[j]] << std::endl;
        }
    }
    std::cout << dp[n] << std::endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define itn int
#define INF (1<<29)
#define rep(i,n) for(int i=0;i<(n);i++)
int gcd(int a,int b){
	if(b==0)return a;
	return gcd(b,a%b);
}
int lcm(int a,int b){
	return a/gcd(a,b)*b;
}
bool prime(int p){
	for(int i=2;i<=sqrt(p);i++){
		if(!p%i)return false;
	}
	return true;
}
int n,m,a[100000],x,ans=0;
map<int,int>mp;
signed main(){
	cin>>n>>m>>x;
	a[0]=x%m;
	mp[0]=1;
	for(int i=1;i<n;i++){
		cin>>x;
		a[i]=(a[i-1]+x)%m;
	}
	sort(a,a+n);
	rep(i,n){
		ans+=mp[a[i]];
		mp[a[i]]++;
	}
	cout<<ans<<endl;
	return 0;
}

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

const int maxn = 3005;
typedef  long long  ll;
int N,a[maxn];
ll dp[maxn][maxn];

int main(){
#ifdef LOCAL
    freopen("./input.txt", "r", stdin);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    

    cin>>N;
    for(int i = 0; i<N; i++){
        cin>>a[i];
        dp[i][i] = a[i];
    }
    
    for(int i = 2; i<=N; i++ ){
        for(int j = 0; j<= N-i;j++){
            dp[j][j+i-1] = max(a[j]-dp[j+1][j+i-1], a[j+i-1] - dp[j][j+i-2]);
        }
    }
    cout<<dp[0][N-1]<<endl;
    return 0;
}






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

int main() {
  int n;
  cin >> n;
  rep(i,n+1) {
    int x = i*108/100;
    if (x == n) {
      cout<<i<<endl;
      return 0;
    }
  }
  cout<<":("<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <cmath>
#include <iomanip>
using namespace std;
typedef long long ll;


int main(){
    int N; cin >> N;
    if(N <= 999) cout << "ABC" << endl;
    else cout << "ABD" << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <stack>
#include <map>
#define ll long long
using namespace std;

int main(void){

    string even, odd, ret;
    cin >> odd;
    cin >> even;

    auto even_itr = even.begin();
    auto odd_itr = odd.begin();
    for(int i=1; i < odd.length() + even.length() + 1; i++){
        if(i%2 == 0){
            ret += *even_itr;
            even_itr++;
        } else {
            ret += *odd_itr;
            odd_itr++;
        }
    }

    cout << ret << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <queue>
#include <map>
#include <numeric>
#include <unordered_map>
#include <iomanip>
#include <functional>
#include <bitset>
#include <complex>

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define all(x) (x).begin(),(x).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 (b<a) { a=b; return 1; } return 0; }

typedef long long ll;

using namespace std;

int geta=2525;
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  vector<ll>dp(geta*2,0);
  int n,a;
  cin>>n>>a;
  dp[geta]=1;
  rep(i,n)
  {
    int x;
    cin>>x;
    x-=a;
    if(x<0)
    {
      repi(j,-x,geta*2)
      {
        dp[j+x]+=dp[j];
      }
    }
    else
    {
      for(int j=geta*2-x-1;j>=0;j--)dp[j+x]+=dp[j];
    }
  }
  cout<<dp[geta]-1<<endl;



  return 0;

}


Measured memory_bytes: 384
#include<stdio.h>

static const int N = 100;

int main(){
  int n,i,j,flag;
  int A[N];
  int swap,sort=0;

  scanf("%d",&n); /*Input an integer n, the number of elements in sequence*/

  for(i=0;i<n;i++){
    scanf("%d",&A[i]);/* Input N elements of the sequence*/
  }

  flag=1;
  i=0;
  while(flag){
  flag=0;
    for(j=n-1;j>=i+1;j--){
      if(A[j]<A[j-1]){
	swap=A[j];    
        A[j]=A[j-1];
        A[j-1]=swap;
        flag=1;
        sort++;
      }
     }
    i++;
   }
    for(i=0;i<n;i++){
      if(i<n-1) printf("%d ",A[i]);/*Output the sorted sequence*/
      else printf("%d\n",A[i]);
    }
    printf("%d\n",sort);  /*Output the number of swap operations.*/

    return 0;
   } 

Measured memory_bytes: 600
#include <cstdio>
#include <cctype>
#include <algorithm>
#define repu(i,x,y) for (int i=x; i<=y; ++i)
using namespace std;

int n,a[100100],w,cnt;

int getint()
{
    char ch;
    while (!isdigit(ch=getchar()));
    int x=ch-'0';
    for (; isdigit(ch=getchar()); x=x*10+ch-'0');
    return x;
}

bool check()
{
    repu(i,1,n)
    {
        cnt+=a[i]!=w;
        if (a[i]<w-1)
            return 0;
    }
    if (!cnt && w==n-1)
        return 1;
    return w>cnt && n-cnt>=(w-cnt)*2;
}

int main()
{
    n=getint();
    repu(i,1,n)
        a[i]=getint(),w=max(w,a[i]);
    puts(check()?"Yes":"No");
    return 0;
}

Measured memory_bytes: 512
#include <cstdio>
#include <regex>
#include <list>
#include <iomanip>
#include <iterator>
#include <iostream>
#include <sstream>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <climits>
#include <string>
#include <set>
#include <numeric>
#include <bitset>
#include <cmath>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <stack>
#include <numeric>
#include <vector>
#include <cassert>
#include <ctime>

using namespace std;

#define dump(...) do{print_vars(cout<<"# "<<#__VA_ARGS__<<'=',__VA_ARGS__);cout<<endl;}while(0)
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define peri(i,a,b) for(int i=int(b);i-->int(a);)
#define FORi(i,a,b) for(int i=int(a);i<=int(b);i++)
#define FOR(i,n) FORi(i,1,n)
#define rep(i,n) repi(i,0,n)
#define per(i,n) peri(i,0,n)
#define all(c) begin(c),end(c)
#define mt make_tuple
#define pb push_back
#define sz size()
#define SET(__set, val) memset(__set, val, sizeof(__set))

using uint=unsigned;
using ll=long long;
using ull=unsigned long long;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using vd=vector<double>;
using vvd=vector<vd>;
using vs=vector<string>;
using pii=pair<int, int>;
using pdd=pair<double, double>;
template<typename T1,typename T2>
ostream& operator<<(ostream& os,const pair<T1,T2>& p){
	return os<<'('<<p.first<<','<<p.second<<')';
}

template<typename Ch,typename Tr,typename C>
basic_ostream<Ch,Tr>& operator<<(basic_ostream<Ch,Tr>& os,const C& c){
	os<<'[';
	for(auto& p: c) os << p << " ";
	return os<<']';
}

void print_vars(ostream&){}
template<typename Car,typename... Cdr>
void print_vars(ostream& os,const Car& car,const Cdr&... cdr){
	print_vars(os<<car<<(sizeof...(cdr)?",":""),cdr...);
}


template<int I,typename Tuple>
void print_tuple(ostream&,const Tuple&){}
template<int I,typename Car,typename... Cdr,typename Tuple>
void print_tuple(ostream& os,const Tuple& t){
	os<<get<I>(t)<<(sizeof...(Cdr)?",":"");
	print_tuple<I+1,Cdr...>(os,t);
}
template<typename... Args>
ostream& operator<<(ostream& os,const tuple<Args...>& t){
	print_tuple<0,Args...>(os<<'(',t);
	return os<<')';
}


constexpr int INF=1e9;
constexpr int MOD=1000000007;
constexpr double EPS=1e-9;
constexpr int maxw=31;
constexpr int maxn=1000000000;

int readint() {
	char c;
	while(!isdigit(c=getchar()));
	int now = c-'0';
	while(isdigit(c=getchar())) (now*=10) += c-'0';
	return now;
}
int nums[200001];
int cnt[200001];

bool solve(){
	int n, m, cntn=0;
	n = readint();
	SET(cnt, 0);
	rep(i, n) 
		nums[i] = readint();
	sort(nums, nums+n);
	int now=-1, cts = -1;
	rep(i, n) {
		if(now != nums[i]) {
			now = nums[i];
			cts ++;
		}
		cnt[cts]++;
	}
	
	cntn = unique(nums, nums+n)-nums;

	m = readint();
	if(n<m) return false;
	rep(i, m) {
		int tmp = readint();
		int p = lower_bound(nums,nums+cntn, tmp) - nums;
		if(p == cntn || nums[p] != tmp || cnt[p] == 0){
			return false;
		}
		cnt[p]--;
	}
	return true;
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout << (solve()? "YES":"NO") << endl;
	return 0;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
	ll n,i,j,k,p=0,q=0;
	string s;
	cin>>n>>s;
	for(i=0;i<n-2;i++)
	{
		if(s[i]=='A' && s[i+1]=='B' && s[i+2]=='C') p=p+1;
	}
	cout<<p;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define IFOR(i,a,b) for(int i = 0; i < b; i++)cin>>a[i];
#define OFOR(i,a,b) for(int i = 0; i < b; i++)cout<<a[i]<<" ";
#define ll  long long 

void solve()
{
    int n;
    cin>>n; 
    int a[n][3];
    for(int i = 0; i < n; i++)
    {
        for(int j = 0; j < 3 ;j++)
        {
            cin>>a[i][j];
        }
    }

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

    }
b[n-1][0] += a[n-1][0];
b[n-1][1] += a[n-1][1];
b[n-1][2] += a[n-1][2];
cout<<max(b[n-1][0], max(b[n-1][1],b[n-1][2]));

}

int main()
{
    int t = 1;
    while(t--)
    {
        solve();
    }

}

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





int main() {

ios_base::sync_with_stdio(false);
cin.tie(NULL);
string s;
string t;
cin>>s>>t;

int cnt=0;

for(int i=0;i<s.size();i++){
    if(s[i]!=t[i]){
        cnt++;
    }
}
cout<<cnt<<"\n";
return 0;
}


Measured memory_bytes: 3780
#import sys
#input = sys.stdin.readline
#input = sys.stdin.buffer.readline


#sys.setrecursionlimit(10**9)
#from functools import lru_cache

def RD(): return sys.stdin.read()
def II(): return int(input())
def MI(): return map(int,input().split())
def MF(): return map(float,input().split())
def LI(): return list(map(int,input().split()))
def LF(): return list(map(float,input().split()))
def TI(): return tuple(map(int,input().split()))
# rstrip().decode()

#import numpy as np


def main():
	s=input()
	t=input()

	ans="No"


	if s==t[:-1]:
		ans="Yes"

	print(ans)












if __name__ == "__main__":
	main()


Measured memory_bytes: 9064
n = int(input())
w = [0 for i in range(n)]

for i in range(n):
    w[i] = input()
    if i > 0 and w[i-1][-1] != w[i][0]:
        print("No")
        exit()
    else:
        for j in range(i):
            if w[j] == w[i]:
                print("No")
                exit()
print("Yes")



Measured memory_bytes: 3060
#include <stdio.h>

int main() {
  int n, ans = 0;
  scanf("%d", &n);
  int p[n];
  for (size_t i = 0; i < n; i++) {
    scanf("%d", p+i);
  }
  for (size_t i = 1; i < n-1; i++) {
    if ((p[i-1] < p[i] && p[i] < p[i+1]) ||
        (p[i-1] > p[i] && p[i] > p[i+1])) {
      ans++;
    }
  }
  printf("%d\n", ans);
  return 0;
}


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

int main(){
  int N;
  cin>>N;
  std::vector<int> v(N),w(N);
  for(int i=0;i<N;i++){
    cin>>v[i];
    w[i]=v[i];
  }
  int ans=0;
  for(int i=0;i<N-2;i++){
    if(i%2){//i is odd so v[i] is already bigger than v[i-1] & i wish v[i] is bigger than v[i+1]
      if(v[i]<v[i+1]){
        if(v[i+1]<v[i+2])swap(v[i],v[i+1]);
        else{
          if(v[i+2]>v[i])swap(v[i],v[i+1]);
          else swap(v[i+1],v[i+2]);
        }
        ans++;
      }
    }
    else{
      if(v[i]>v[i+1]){
        if(v[i+1]>v[i+2])swap(v[i],v[i+1]);
        else{
          if(v[i+2]<v[i])swap(v[i],v[i+1]);
          else swap(v[i+1],v[i+2]);
        }
        ans++;
      }
    }
  }
  //cout<<ans<<endl;
  if(N%2&&v[N-2]<v[N-1])ans++;
  if(N%2==0&&v[N-2]>v[N-1])ans++;
  int fans=ans;
  ans=0;
  for(int i=0;i<N-2;i++){
    if(i%2==0){//i is odd so v[i] is already bigger than v[i-1] & i wish v[i] is bigger than v[i+1]
      if(w[i]<w[i+1]){
        if(w[i+1]<w[i+2])swap(w[i],w[i+1]);
        else{
          if(w[i+2]>w[i])swap(w[i],w[i+1]);
          else swap(w[i+1],w[i+2]);
        }
        ans++;
      }
    }
    else{
      if(w[i]>w[i+1]){
        if(w[i+1]>w[i+2])swap(w[i],w[i+1]);
        else{
          if(w[i+2]<w[i])swap(w[i],w[i+1]);
          else swap(w[i+1],w[i+2]);
        }
        ans++;
      }
    }
  }
  //cout<<ans<<endl;
  if(N%2==0&&w[N-2]<w[N-1])ans++;
  if(N%2&&w[N-2]>w[N-1])ans++;
  //cout<<fans<<" "<<ans<<endl;
  fans=min(ans,fans);
  cout<<fans<<endl;
}



Measured memory_bytes: 3648
#include <iostream>
#include <cctype>

int num;

const char *solve(const char *p, int idx)
{
    while (*p != '\0' && *p != ')') {
        int n = 1;
        if (isdigit(*p)) {        
            n = 0;
            while (isdigit(*p)) {
                n *= 10;                
                n += *p - '0';
                ++p;
            }
        }
        if (isalpha(*p)) {
            for (int i = 0; i < n; i++) {
                if (num++ == idx) {
                    throw *p;
                }
            }
            ++p;            
        } else if (*p == '(') {
            ++p;
            const char *q = p;
            for (int i = 0; i < n; i++) {
                p = solve(q, idx);
            }
            ++p;
        }        
    }       
    return p;
}

char find_char(const std::string &s, int idx)
{
    try {
        num = 0;
        solve(s.c_str(), idx);
    } catch (char ch) {
        return ch;
    }
    return '0';
}

int main()
{
    std::string s;
    int idx;
    while (1) {
        std::cin >> s >> idx;
        if (s == "0" && idx == 0) {
            break;
        }
        
        std::cout << find_char(s, idx) << std::endl;
    }
    return 0;
}

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

using namespace std;

int s[2];
int data[2][1501];
int cnt[2][1500001];

main(){
  while(cin >> s[0] >> s[1] && (s[0]|s[1])){
    data[0][0] = data[1][0] = 0;
    for(int j=0;j<2;j++){
      for(int i=1;i<=s[j];i++){
        int in;
        cin >> in;
        data[j][i] = data[j][i-1] + in;
      }
    }
    fill(cnt[0], cnt[2], 0);
    for(int k=0;k<2;k++){
      for(int i=0;i<=s[k];i++){
        for(int j=i+1;j<=s[k];j++){
          cnt[k][data[k][j]-data[k][i]]++;
        }
      }
    }
    int ans = 0;
    for(int i=1;i<=1500000;i++){
      ans += cnt[0][i] * cnt[1][i];
    }
    cout << ans << endl;
  }
  return 0;
}

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

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

    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> a >> b >> c;
    cout << (a[a.length() -1] == b[0] && b[b.length() - 1] == c[0]? "YES" : "NO") << "\n";
    return 0;
}

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

long long A[200010];
int main(){
    int i,n,k;
    cin>>n>>k;
    for(i=1;i<=n;i++) cin>>A[i];
    for(i=k+1;i<=n;i++){
        if(A[i]>A[i-k]) printf("Yes\n");
        else printf("No\n");

    }

}


Measured memory_bytes: 5176
#include <iostream>
using namespace std;
int main(){
  while(true){
    string s;
    int a,b,c;cin>>a>>b>>c;
    if(a+b+c == -3){
      break;
    }
    if(a == -1 || b == -1)s = "F";
    else if(a+b > 79)s = "A";
    else if(a+b > 64)s = "B";
    else if(a+b > 49)s = "C";
    else if(a+b > 29 && c > 49)s = "C";
    else if(a+b > 29)s = "D";
    else s = "F";
    cout << s << endl;
  }
}


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

using namespace std;

using ll = long long;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int K, Q;
    cin >> K >> Q;
    vector<ll> d_ori(K);
    for (int i = 0; i < K; ++i) {
        cin >> d_ori[i];
    }

    for (int i = 0; i < Q; ++i) {
        ll n, x, m;
        cin >> n >> x >> m;

        vector<ll> d(K, 0);
        vector<ll> dsum(K + 1, 0);
        vector<ll> cnt0(K + 1, 0);
        for (int j = 0; j < K; ++j) {
            d[j] = d_ori[j] % m;
            dsum[j + 1] = dsum[j] + d[j]; 
            cnt0[j + 1] = cnt0[j] + (d[j] == 0);
        }

        ll ans = n - 1;
        ans -= (n - 1) / K * cnt0[K] + cnt0[(n - 1) % K] - cnt0[0];
        ans -= ((n - 1) / K * dsum[K] - dsum[0] + dsum[(n - 1) % K] + x) / m - x / m;
        cout << ans << "\n";
    }
    return 0;
}

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

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

	int cnt = 0;
	for(int i=0; i<n; i++){
		int f = 0;
		for(int j=2; j<(int)sqrt(a[i])+1; j++){
			if(a[i]%j==0){
				f=1;
				break;
			}
		}
		if(f==0){
			cnt++;
		}
	}
	cout << cnt << endl;

	return 0;
}

Measured memory_bytes: 1196
n,m = gets.chomp.split(" ").map{|e|e.to_i}
h = gets.chomp.split(" ").map{|e|e.to_i}
good = Array.new(n, true)

m.times do
	a, b = gets.chomp.split(" ").map{|e|e.to_i}
	a -= 1
	b -= 1
	if h[a]>h[b] then
		good[b] = false
	elsif h[a]<h[b] then
		good[a] = false
	else
		good[a] = false
		good[b] = false
	end
end

sum = 0
for i in good do i&&sum+=1 end

print(sum)

Measured memory_bytes: 23440
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main()
{
    //#ifndef ONLINE_JUDGE
    //freopen("F:/cpp/input.txt", "r", stdin);
    //freopen("F:/cpp/output.txt", "w", stdout);
    //#endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string s1, s2;
    cin >> s1 >> s2;
    ll i, ans = 1;
    for (i=0;i<s1.length();i++)
    {
        if (s1[i] != s2[i])
        {
            ans = 0;
            break;
        }
    }
    if (ans)
    cout << "Yes\n";
    else
    cout << "No\n";
    return 0;
}

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

#define ASC(vec) vec.begin(), vec.end()		// 昇順ソート 例：sort(ASC(vec));
#define DESC(vec) vec.rbegin(), vec.rend()	// 降順ソート 例:sort(DESC(vec));
#define rep(i, n) for(i = 0; i < n; i++)
#define Rep(i, n) for(i = 1; i < n; i++)
#define Ans(s) cout << s << endl;

const int inf = (int)1e9 + 7;
const long long INF = 1LL << 60;

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

int GCD(int a, int b) { return b ? GCD(b, a % b) : a; }

typedef long long ll;

// 4,8方向に探索する際に用いる配列
//int dx[4] = { 0,  0, 1, -1 };
//int dy[4] = { 1, -1, 0,  0 };
//int dx[8] = { 1, 0, -1,  0, 1, -1, -1,  1 };
//int dy[8] = { 0, 1,  0, -1, 1,  1, -1, -1 };

constexpr auto MAX = 100010;

int mod = 1000000007;

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

	vector<bool> isBroken(n + 1, false);

	for (int i = 0; i < m; i++)
	{
		int val;
		cin >> val;
		isBroken[val] = true;
	}

	vector<ll> dp(n + 1);

	dp[0] = 1;
	if (!isBroken[1]) dp[1] = 1;

	for (int i = 2; i <= n; i++)
	{
		if (!isBroken[i - 1]) dp[i] += dp[i - 1];
		if (!isBroken[i - 2]) dp[i] += dp[i - 2];
		dp[i] %= mod;
	}
	cout << dp[n] << endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define SZ(x) ((int)(x).size())
#define m0(x) memset(x,0,sizeof(x))
#define fill(x,y) memset(x,y,sizeof(x))
#define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0]))

map<ll, ll> primeFactors(ll n)
{
    map<ll, ll> ret;
    while (n % 2 == 0)
    {
        if( ret.find(2) != ret.end() ) {
            ret[2]++;
        }
        else
        {
            ret[2] = 1;
        }
        n = n / 2;
    }
    for (ll i = 3; i <= sqrt(n); i = i+2)
    {
        while (n%i == 0)
        {
            if( ret.find(i) != ret.end() ) {
            ret[i]++;
        }
        else
        {
            ret[i] = 1;
        }
            n = n / i;
        }
    }
    if (n > 2)
        {
            if( ret.find(n) != ret.end() ) {
            ret[n]++;
        }
        else
        {
            ret[n] = 1;
        }
        }
    return ret;
}

void print_map(map<ll, ll> mp){
    for(auto itr = mp.begin(); itr != mp.end(); ++itr) {
        std::cout << "key = " << itr->first           // キーを表示
                        << ", val = " << itr->second << "\n";    // 値を表示
    }
}

int main()
{
    int N, K;
    cin >> N >> K;
    vector<string> str(K);
    rep(i, K)
    {
        cin >> str.at(i);
    }
    for (int i = N; i < 100000; i++){
        string s = to_string(i);
        bool flag = true;
        for (string &i : str)
        {
            if (s.find(i) != -1){
                flag = false;
                break;
            }
        }
        if (flag) {
            cout << s << endl;
            return 0;
        }
    }
    return 0;
}


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

int comp (const void *a, const void *b) {
	return *(int*)a - *(int*)b;
}

int main () {
	char buff[1024];
	int e[3];
	int a, b, c;

	fgets (buff, 1024, stdin);
	while (fgets (buff, 1024, stdin) != NULL) {
		sscanf (buff, "%d %d %d", &e[0], &e[1], &e[2]);

		qsort (e, 3, sizeof(e[0]), comp);
		a = e[0];
		b = e[1];
		c = e[2];

		if ((a * a + b * b) == (c * c)) {
			printf ("YES\n");
		}
		else {
			printf ("NO\n");
		}
	}
	
	return 0;
}



Measured memory_bytes: 1968
#include<bits/stdc++.h>
using namespace std;
int main(){
	int x,n,temp,arr[101]={0,};
	cin>>x>>n;
	
	
	for(int i=0;i<n;i++){
		cin>>temp;
		arr[temp]=1;	
	}
	
	int r=x;
	int l=x;
	while(1){
		if(1<=l && l<=100)
			if(arr[l]) l-=1;	
			else{
				cout<<l<<endl;
				return 0;
			}
		else{
			cout<<l<<endl;
			return 0;
		}
		
		if(1<=r && r<=100)
			if(arr[r]) r+=1;
			else{
				cout<<r<<endl;
				return 0;
			}
		else{
			cout<<r<<endl;
			return 0;
		}
	}
}

Measured memory_bytes: 3620
#include <algorithm>
#include <iostream> //入出力
#include <stdio.h>
#include <map>
#include <set>
#include <string>
#include <math.h> //算術演算子
#include <vector>
#include <cstdlib>
#include <queue>
#include <stack>
#include <list>
#include <iomanip> //小数点以下を表示させる(setprecision())
//#include <bits/stdc++.h>
using namespace std;
typedef long long ll; //64bit型

#define debug(x) cerr << x << " " \
                      << "(L:" << __LINE__ << ")" << '\n'
#define PRINT(V)                                   \
        {                                          \
                for (int i = 0; i < V.size(); i++) \
                {                                  \
                        cout << V[i] << " ";       \
                }                                  \
                cout << endl;                      \
        }

int gcd(int a, int b)
{
        return b ? gcd(b, a % b) : a;
}

int main()
{
        //input->compute->output//

        char A, B;
        cin >> A >> B;
        if (A=='H')
        {
                if (B=='H')
                {
                        cout <<'H' << endl;
                } else{
                        cout << 'D' << endl;
                }
                
        }
        else
        {
                if (B == 'H')
                {
                        cout << 'D' << endl;
                }
                else
                {
                        cout << 'H' << endl;
                }
        }

        return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

ll fat[100009];

template <typename T>
T extGcd(T a, T b, T& x, T& y) {
    if (b == 0) {
        x = 1; y = 0; return a;
    }
    else {
        T g = extGcd(b, a % b, y, x);
        y -= a / b * x; return g;
    }
}
 
template <typename T>
T modInv(T a, T m) {
    T x, y;
    extGcd(a, m, x, y);
    return (x % m + m) % m;
}
 
template <typename T>
T modDiv(T a, T b, T m) {
    return ((a % m) * modInv(b, m)) % m;
}

template<typename T>
T modMul(T a, T b, T m) {
	T x = 0, y = a % m;
	while (b > 0) {
		if (b % 2 == 1) x = (x + y) % m;
		y = (y * 2) % m; b /= 2;
	}
	return x % m;
}
main(){
    cin.sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cin.exceptions(cin.failbit);
    fat[0] = 1;
    
    int n, k;
    ll ans = 0;
    ll mod = 1e9+7;
    cin >> n >> k;
    rep(i,1,n + 1){
        fat[i] = (fat[i-1]*i) % mod;
    }
    vector<ll> a(n);
    rep(i, 0, n) cin >> a[i];
    sort(all(a));
    rep(i, 0, n){
        ll cik1 = (i - k + 1 >= 0) ? modDiv(fat[i], modMul(fat[k-1],fat[i-k+1], mod), mod) : 0;
        ll cni1k1 = (n - i - k >= 0 )? modDiv(fat[n-i-1], modMul(fat[k-1],fat[n-i-k], mod), mod) : 0;
        ans += modMul(a[i], (cik1 - cni1k1 + mod) % mod, mod);
        ans %= mod;
    }
    cout << (ans + mod) % mod << '\n';
}

Measured memory_bytes: 1792
/*
If you want to shine like a sun, first burn like a sun.
*/

#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;
#define mod 1000000007
#define pb push_back
#define mp make_pair
#define ll long long int
#define ld long double
#define vi vector<int>
#define vl vector<ll>
#define v2i vector<vector<int>>
#define v2l vector<vector<ll>>
#define ppi pair<int,int>
#define ppl pair<ll,ll>
#define vpi vector<ppi>
#define vpl vector<ppl>
#define all(x) x.begin(),x.end()
#define ii int,int 
#define ff first    
#define ss second
#define forn(i,a,b) for(int i=a;i<b;i++)
#define forr(i,a,b) for(int i=a;i>=b;i--)
#define forv(i,m) for(auto i : m)
#define imx INT_MAX
#define imn INT_MIN
#define inf LONG_MAX
#define minf LONG_MIN
#define endl "\n"
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);
#define sze size()
#define rvs reverse 
#define itr iterator 
#define pre cout<<fixed<<setprecision(10);
#define umap unordered_map
#define uset unordered_set
#define pi 3.141592653589793
#define MAXN 100005
#define test1(x) cout << #x " = " << x << endl;
#define test2(x,y) cout << #x " = " << x << " " << #y " = " << y << endl;
const ll infinity = 9e18;

/*
#define oset tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define MODM(a,b,md) ((a%md)*(b%md))%md
#define MODA(a,b,md) ((a%md)+(b%md))%md
#define ull unsigned long long int
*/

/*
bool compare(int a,int b) {return a > b;}
bool compare1(ppi a,ppi b) {return a.ff > b.ff;}
bool compare2(ppi a,ppi b) {return a.ss < b.ss;}
ll Npower(ll a,ll b) {ll product = 1; while(b){if(b&1){product = product*a;}a = a*a;b = b>>1;} return product;}
ll power(ll a,ll b,ll md) {ll product = 1; while(b){if(b&1){product = MODM(product,a,md);}a = MODM(a,a,md);b = b>>1;} return product%md;}
bool isprime(ll n){if(n < 2) return 0; ll i = 2; while(i*i <= n){if(n%i == 0) return 0; i++;} return 1;}
ll GCD(ll a,ll b) {return b==0 ? a:GCD(b,a%b);}
ll LCM(ll a,ll b) {return (a/GCD(a,b))*b; }
*/


int main()
{
    fast

/*
    #ifndef ONLINE_JUDGE
        freopen("input.txt",  "r",  stdin);
        freopen("output.txt", "w", stdout);
    #endif
//*/

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

	int sum = a+b+c;

	if(sum >= 22)
	{
		cout<<"bust";
	}
	else
	{
		cout<<"win";
	}
        
        












    return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {


	public static void main(String[] args) {
		FastScanner fsc = new FastScanner();

		int SV = fsc.nextInt();
		int HW = fsc.nextInt();
		int[] HW_count = new int[HW];
		int Total = 0;
		for(int i = 0; HW > i; i++) {
			HW_count[i] = fsc.nextInt();
		}
		//遊べる残日数計算
		for(int num = 0; HW > num; num++ ) {
			Total = HW_count[num];
			SV = SV - Total;
		}

		//宿題が間に合わない
		if(SV < 0) {
			System.out.println(-1);
		}
		//遊べる日数を出力
		else if(SV >= 0) {
			System.out.println(SV);
		}
	}
}




class FastScanner {

	BufferedReader br;

	StringTokenizer st;



	public FastScanner() {

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

	}



	String next() {

		while (st == null || !st.hasMoreElements()) {

			try {

				st = new StringTokenizer(br.readLine());

			} catch (IOException e) {

				e.printStackTrace();

			}

		}

		return st.nextToken();

	}



	int nextInt() {

		return Integer.parseInt(next());

	}



	long nextLong() {

		return Long.parseLong(next());

	}

}


Measured memory_bytes: 34076
import heapq

Q = int(input())
Query = [input() for _ in range(Q)]

ans = 0

lq = []
rq = []

for q in Query :
    if q[0] == '1' :
        a, b = map(int, q[2:].split())
        
        heapq.heappush(lq, -a)
        heapq.heappush(rq, a)

        lmax, rmin = -lq[0], rq[0]
        if lmax > rmin :
            lmax, rmin = rmin, lmax
            ans += rmin - lmax

            heapq.heappop(lq)
            heapq.heappop(rq)
            heapq.heappush(lq, -lmax)
            heapq.heappush(rq, rmin)

        ans += b

    else :
        print(-lq[0], ans)


Measured memory_bytes: 121624
int main(void){int i,j,n;char s[200001];scanf("%s",s);
for(n=0;s[n]!='\0';n++);
for(i=0;s[i]!='A';i++);
for(j=1;s[n-j]!='Z';j++);
printf("%d\n",n-i-j+1);
return 0;}

Measured memory_bytes: 384
#include <iostream>
#include <cmath>
using namespace std;
int main()
{
	int x,a,b,c,d;
	cin>>x>>a>>b;
	c=x-a;d=x-b;
	if(abs(c)>abs(d)) cout<<"B"<<endl;
	else cout<<"A"<<endl;
	return 0;
}

Measured memory_bytes: 256
def distance(a, b):
	cont = 0
	for k in xrange(len(a)):
		cont += (a[k] - b[k]) * (a[k] - b[k])
	return cont ** 0.5
n, t = map(int, raw_input().split())

ar = []

for i in xrange(n):
	ar.append(map(int, raw_input().split()))
	
cont = 0
for k in xrange(n):
	for l in xrange(k + 1, n):
		if distance(ar[k], ar[l]) == int(distance(ar[k], ar[l])):
			cont += 1
			
print cont


Measured memory_bytes: 28396
#![allow(unused_imports)]
#![allow(clippy::many_single_char_names)]
#![allow(clippy::suspicious_arithmetic_impl)]

// using Rust(1.42.0)
// My Library Repo is at "https://github.com/Loptall/prcn_lib"
// check available crates on AtCoder at "https://atcoder.jp/contests/language-test-202001"

/*
    AtCoder Language Update 2020204 お疲れ様でした! 有難いです
*/

// Dep crates are...
use std::cmp::{max, min, Ordering};
use std::collections::{BTreeMap, BTreeSet, HashMap, HashSet, VecDeque};
use std::mem::swap;
use std::ops::*;
use std::{i128, i16, i32, i64, i8, isize, u128, u16, u32, u64, u8, usize};

use itertools::*;
use itertools_num::*;
use lazy_static::lazy_static;
use maplit::{btreemap, btreeset, hashmap, hashset};
use num_bigint::{BigInt, BigUint};
use num_integer::{binomial, gcd, lcm, Integer};
use permutohedron::Heap;
use proconio::{fastout, input, is_stdin_empty, marker::*};
use rand::random;


use std::io::stdin;
use std::str::FromStr;

fn input<T: FromStr>() -> Result<T, T::Err> {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();
    buf.trim().parse()
}

fn input_vec<T: FromStr>() -> Result<Vec<T>, T::Err> {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();
    buf.trim().split_whitespace().map(|x| x.parse()).collect()
}

// code...
fn main() {
    input! {
        n: usize, k: usize,
        v: [[usize]; k]
    }

    let mut f = vec![true; n];
    for i in v {
        for j in i {
            f[j-1] = false;
        }
    }

    println!("{}", f.iter().filter(|x| **x).count());
}


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



int main() {
    double L;
    cin>>L;
    double ans=L*L*L/27;
    cout << fixed << setprecision(10);
    cout<<ans<<endl;
}

Measured memory_bytes: 256
a,b=map(int,input().split())

m=[]    
for i in range(a):
    k=list(map(int,input().split()))
    k.append(sum(k))
    m.append(k)
    print(' '.join(map(str,k)))

n=0
o=[]
for i in range(b):
    for j in range(a):
        n+=m[j][i]
    o.append(n)
    n=0
o.append(sum(o))
print(' '.join(map(str,o)))
    
    
    
 


Measured memory_bytes: 5676
#include <bits/stdc++.h>
#include <unordered_map>
#include <queue>
#define MOD 1000000007

using namespace std;

int main() {
    int H, W, K, i, j, k, l;
    long long d[101][8]={0,};
    cin>>H>>W>>K;
    d[0][0]=1;
    // cout<<(1<<W)-1<<endl;
    for(i=0;i<H;i++){
        for(j=0;j<W;j++){
            for(k=0;k<(1<<(W-1));k++){
                bool isOkay=true;
                for(l=0;l<(W-2);l++){
                    if(((k>>l)&1)&&((k>>(l+1))&1)){
                        isOkay=false;
                        break;
                    }
                }
                if(!isOkay)continue;
                if(j>0&&((k>>(j-1))&1)){
                    d[i+1][j-1]=(d[i+1][j-1]+d[i][j])%MOD;
                }else if(j<W-1&&((k>>j)&1)){
                    d[i+1][j+1]=(d[i+1][j+1]+d[i][j])%MOD;
                }else d[i+1][j]=(d[i+1][j]+d[i][j])%MOD;
            }
        }
    }
    cout<<d[H][K-1];
    return 0;
}

Measured memory_bytes: 256
n,m,l=map(int,input().split())
a=[]
b=[]
for i in range(n):
    a+=[list(map(int,input().split()))]

for i in range(m):
    b+=[list(map(int,input().split()))]
  
c=[]
c=[[sum(a[i][k]*b[k][j] for k in range(m))for j in range(l)] for i in range(n)]
[print(" ".join(list(map(str,c[i])))) for i in range(n)]

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

#define DIV 1000000007

long long N, M;
long long S[20005];
long long T[20005];
long long dp[2005][2005];

int main(){
	cin >> N >> M;
	for(long long i = 1; i <= N; i++){
		cin >> S[i];
	}
	for(long long j = 1; j <= M; j++){
		cin >> T[j];
	}

	for(long long i = 0; i <= N; i++){
		dp[i][0] = 0;
	}
	for(long long i = 0; i <= M; i++){
		dp[0][i] = 0;
	}
	for(long long i = 1; i <= N; i++){
		for(long long j = 1; j <= M; j++){
			dp[i][j] = dp[i-1][j] + dp[i][j-1];
			if(S[i] == T[j]){
				dp[i][j]++;
			}else{
				dp[i][j] -= dp[i-1][j-1];
			}
			dp[i][j] = (dp[i][j]+ DIV) % DIV;
		}
	}

	cout << (dp[N][M] + 1)%DIV << endl;
}

Measured memory_bytes: 31616
#include<bits/stdc++.h>
#define EPS 1e-10
#define equals(a,b) (fabs((a)-(b)) < EPS)
#define rep(i,n) for(int i=0;i<n;++i)
typedef long long ll;
using namespace std;

struct Point {
    double x,y;
    Point(){}
    Point(double x, double y): x(x),y(y){}
    Point operator+(Point p) {return Point(x+p.x, y+p.y);}
    Point operator-(Point p) {return Point(x-p.x, y-p.y);}
    Point operator*(double k) {return Point(x*k,y*k);}
    double norm(){return x*x+y*y;}
    double abs(){sqrt(norm());}
    bool operator == (const Point &p) const {return equals(x,p.x)&&equals(y,p.y);} 
};
typedef Point P;

struct Segment {
    Point p1,p2;
    Segment(){}
    Segment(Point p1, Point p2):p1(p1),p2(p2){}
};

double dot(Point a, Point b) {return a.x*b.x+a.y*b.y;}

Point project(Segment s, Point p) {
    Point base = s.p2-s.p1;
    double r = dot(p-s.p1,base)/base.norm();
    return s.p1+(base*r);
}

int main() {
    double x1,y1,x2,y2;
    cin >>x1>>y1>>x2>>y2;
    Point p1(x1,y1); Point p2(x2,y2);
    Segment s(p1,p2);
    int q; cin >> q;
    rep(i,q) {
        double x0,y0;
        cin >>x0>>y0;
        Point ans = project(s,Point(x0,y0));
        cout << fixed << setprecision(8);
        cout << ans.x << " " << ans.y << endl;
    }
    return 0;
}


Measured memory_bytes: 3296
#!/usr/bin/env python3

import sys, math
sys.setrecursionlimit(300000)

MOD = 1000000007  # type: int
def calc_fraction_mod(numerator, denominator):
    '''
        returns numerator / denominator (mod MOD)
    '''
    inv = pow(denominator, MOD - 2, MOD)
    return numerator * inv % MOD

def make_facts(n):
    '''
        make factorials
        0!(=1), 1!, 2!, 3! .... n!
    '''
    fact = [1]
    for i in range(n):
        fact.append((fact[i] * (i + 1)) % MOD)
    return fact


def make_combs(n, k):
    '''
        make [C(n - k, 0), C(n - k + 1, 1), C(n, 2) ..... C(n, k)]
    '''
    facts = make_facts(n)
    invs = [] # inverted for fraction
    for fact in facts:
        invs.append(pow(fact, MOD - 2, MOD))

    ret = []
    for i in range(0, k + 1):
        x = n - k + i
        a = facts[x]
        #b = facts[i]
        #c = facts[n - i]
        #ret.append(calc_fraction_mod(a, b))
        ret.append(a * invs[i] * invs[x - i] % MOD)
    return ret

def solve(K: int, S: str):
    n = len(S)
    N = K + n
    ret = 0
    p26 = [1]
    p25 = [1]
    for i in range(1, K + 1):
        #p26.append(pow(26, i, MOD))
        #p25.append(pow(25, i, MOD))
        p26.append(p26[-1] * 26 % MOD)
        p25.append(p25[-1] * 25 % MOD)
    coms = make_combs(N - 1, K)
    #print('a')
    #print('b')
    for i in range(K + 1):
        #tmp = p26[i] * p25[K - i] * c(N - i - 1, K - i)
        tmp = p26[i] * p25[K - i] * coms[K - i]
        #print(i, p26[i], p25[K - i], coms[K - i], tmp)
        ret += tmp
        ret %= MOD
    print(ret)
    return


def solve_(K: int, S: str):
    n = len(S)
    N = K + n
    coms = make_combs(N, n)
    ret = pow(26, N, MOD)
    tmp = pow(25, coms[n], MOD)
    print(coms[n], ret, tmp)
    ret -= tmp
    #ret *= coms[n]
    ret %= MOD
    print(ret)
    return

def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    K = int(next(tokens))  # type: int
    S = next(tokens)  # type: str
    solve(K, S)

if __name__ == '__main__':
    main()


Measured memory_bytes: 245008
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.math.BigDecimal;
import java.math.RoundingMode;

public class Main {
	public static void main(String[] args) {
		try {
			String[] input = new BufferedReader(new InputStreamReader(System.in)).readLine().split(" ");
			int faces = Integer.parseInt(input[0]);
			int target = Integer.parseInt(input[1]);
			BigDecimal rate = BigDecimal.ZERO;
			for (int i = 1; i <= faces; i++) {
				int cnt = 0;
				int sum = i;
				while(sum < target) {
					sum += sum;
					cnt++;
				}
				rate = rate.add(BigDecimal.valueOf(Math.pow(0.5, cnt) / faces));
			}
			System.out.println(rate.setScale(10, RoundingMode.HALF_UP));
		} catch (IOException e1) {
		}
	}
}

Measured memory_bytes: 91312
#include <iostream>

using namespace std;
using LL = long long;

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

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

    LL dp[N];
    fill(dp, dp + N, 1L << 61);
    dp[0] = 0L;

    for (int i = 1; i < N; i++) {
        for (int j = 1; j <= K; j++) {
            if (i - j >= 0) {
                dp[i] = min(dp[i], dp[i - j] + abs(H[i] - H[i - j]));
            }
        }
    }

    cout << dp[N - 1] << endl;
}

Measured memory_bytes: 1408
f=lambda:[*map(int,input().split())]
f()
s,*l=[0]*100002
for i in f(): s+=i; l[i]+=1
q=f()[0]
for _ in range(q): b,c=f(); s+=(c-b)*l[b]; l[c]+=l[b]; l[b]=0; print(s)

Measured memory_bytes: 21640