akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <array>
#include <algorithm>
#include <utility>
#include <numeric>
#include <deque>
#include <stack>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cmath>
#include <limits>
#include <cassert>
#include <bitset>
#include <list>
#include <iomanip>
#include <cctype>

#define for0(i, N)    for (int i = 0  ; i <  (N); ++i)
#define for1n(i, N)   for (int i = 1  ; i <= (N); ++i)
#define for1(i, N)    for (int i = 1  ; i <  (N); ++i)
#define forn(i, N)    for (int i = 0  ; i <= (N); ++i)
#define forx(i, N, x) for (int i = (x); i <  (N); ++i)
#define forl(i, N, x, a) for (int i = (x), a = 0; a < (N);  \
                              i = (i + 1) % (N), ++a)

template<size_t i>
std::bitset<i> operator++(std::bitset<i> b, int){
    static_assert(i <= 64, "Cannot cast 64bit int.");
    return b = (unsigned long long)b + 1;
}

template<size_t i>
std::bitset<i> operator++(std::bitset<i> b){
    static_assert(i <= 64, "Cannot cast 64bit int.");
    auto temp = b;
    b++;
    return temp;
}

template<size_t i>
std::bitset<i> operator--(std::bitset<i> b, int){
    static_assert(i <= 64, "Cannot cast 64bit int.");
    return b = (unsigned long long)b - 1;
}

template<size_t i>
std::bitset<i> operator--(std::bitset<i> b){
    static_assert(i <= 64, "Cannot cast 64bit int.");
    auto temp = b;
    b--;
    return temp;
}

using namespace std;

typedef long long ll;
typedef long double ld;
typedef priority_queue<ll> pq;
typedef priority_queue<ll,vector<ll>, greater<ll>> pql;
typedef stack<ll> stk;
typedef queue<ll> qu;
typedef pair<ll, ll> pll;
typedef map<ll, ll> mll;
typedef unordered_map<ll, ll> umll;
typedef set<ll> sll;
typedef unordered_set<ll> usll;
typedef vector<ll> vll;
typedef vector<ld> vld;


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

    int a, b, c;

    cin >> a >> b >> c;

    cout << ((a == b && b != c) || (b == c && c != a) || (a == c && a != b)
                 ? "Yes"
                 : "No");

    return 0;
}


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

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  int b=1;
  for(int i=0;i<n;i++){
    cin >> a.at(i);
    if(a.at(i)==b)
      b++;
    }
  if(b==1)
  cout << -1 << endl;
  else
  cout << n-b+1 << endl;
}

Measured memory_bytes: 1152
Dic = {}

def adddic(n):
    if n in Dic:
        Dic[n] += 1
    else:
        Dic[n] = 1

N = int(input())
D = list(map(int,input().split()))
for n in range(N):
    adddic(D[n]-1)
    adddic(D[n])
    adddic(D[n]+1)
ans = 0
for key,value in Dic.items():
    ans = max(ans,value)
print(ans)

Measured memory_bytes: 18784
#include<stdio.h>

int search(int S[],int n,int T){
  
  int i=0;
  S[n]=T;
  while(S[i] != T)i++;
  return i != n;
  
}

int main(){
  
  int i,n,q,T,C=0,S[10000+1];
  scanf("%d",&n);
  for(i=0;i<n;i++)scanf("%d",&S[i]);
  
  scanf("%d",&q);
  for(i=0;i<q;i++){
    scanf("%d",&T);
    if(search(S,n,T))C++;
  }
  printf("%d\n",C);
  
  return 0;
}



Measured memory_bytes: 2108
def main
  h, n = gets.chomp.split.map(&:to_i)
  m = []
  n.times do |i|
  	m.push(gets.chomp.split.map(&:to_i))
  end
  
  #DPを使ってO(h * n) で解く
  dp = Array.new(h, 1000000000)
  
  h.times do |i|
    n.times do |j|
      #k = m[i][0]個前の最小値
      if i < m[j][0]
        k = m[j][1]
      else
        k = dp[i - m[j][0]] + m[j][1]
      end
      
      if dp[i] > k
        dp[i] = k
      end
    end
  end
  
  puts dp[-1]
end
 
main

Measured memory_bytes: 1916
/**
 *    author:  otera    
**/
#include<iostream>
#include<string>
#include<cstdio>
#include<cstring>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<deque>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;

//#define int long long
typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef long double ld;
const int inf=1e9+7;
const ll INF=1LL<<60 ;
const ll mod=1e9+7 ;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<int, int> P;
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
#define debug(x)  cerr << #x << " = " << (x) << endl;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

void solve() {
	int n; cin >> n;
    string s, t; cin >> s >> t;
    for(int i = n; i <= 2 * n; ++i) {
        string res = s + t.substr(2 * n - i, n);
        //cerr << res << endl;
        if(res.substr(i - n, i) == t) {
            cout << i << endl;
            return;
        }
    }
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(10);
	//int t; cin >> t; rep(i, t)solve();
	solve();
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<vector>
#include<map>
#include<string>
#include<sstream>
#include<cmath>
#include<climits>
#include<algorithm>
#include<bitset>
#include<set>
#include<stack>
#include<queue>
#include<iomanip>
#include<memory.h>
using namespace std;  
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
#define rep(i,n) for(ll i=0;i<(n);i++)  
#define pb push_back  
#define ALL(a) (a).begin(),(a).end()
#define FST first
#define SEC second  
const int INF = (INT_MAX/2);
const ll LLINF = (LLONG_MAX/2);
const double eps = 1e-5;
const double PI = M_PI;  
#define DEB cerr<<"!"<<endl
#define SHOW(a,b) cerr<<(a)<<" "<<(b)<<endl
#define SHOWARRAY(ar,i,j) REP(a,i)REP(b,j)cerr<<ar[a][b]<<((b==j-1)?((a==i-1)?("\n\n"):("\n")):(" "))
#define DIV int(1e9+7)
inline ll pow(ll x,ll n,ll m){ll r=1;while(n>0){if((n&1)==1)r=r*x%m;x=x*x%m;n>>=1;}return r%m;}
 
int main(){
  int n; cin >> n;
  vi a(n);
  rep(i,n) cin >> a[i];
  int ans = -100;
  int ans_v = INF;
  for(int t = -100;t <= 100; t++){
    int sum = 0;
    rep(i,n) sum += pow(t - a[i],2,INF);
    if(sum < ans_v){
      ans_v = sum;
      ans = t;
    }
  }
  cout << ans_v << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

#define MAX 20000
#define MYSCAN scanf

int main(void){
	int n, m;
	int i, j;
	int nowseg[7];
	int seg[10][7] = {
			{ 0, 1, 1, 1, 1, 1, 1 },
			{ 0, 0, 0, 0, 1, 1, 0 },
			{ 1, 0, 1, 1, 0, 1, 1 },
			{ 1, 0, 0, 1, 1, 1, 1 },
			{ 1, 1, 0, 0, 1, 1, 0 },
			{ 1, 1, 0, 1, 1, 0, 1 },
			{ 1, 1, 1, 1, 1, 0, 1 },
			{ 0, 1, 0, 0, 1, 1, 1 },
			{ 1, 1, 1, 1, 1, 1, 1 },
			{ 1, 1, 0, 1, 1, 1, 1 } };

	while (true){
		MYSCAN("%d", &n);
		if (n == -1){	break;	}
		for (i = 0; i < 7; i++){	nowseg[i] = 0;	}

		for (i = 0; i < n; i++){
			MYSCAN("%d", &m);
			for (j = 0; j < 7; j++){
				if (seg[m][j] == nowseg[j]){
					printf("0");					
				}
				else{
					printf("1");
				}
				nowseg[j] = seg[m][j];
			}
			printf("\n");
		}
	}

	return 0;

}

Measured memory_bytes: 1000
n, m = map(int, input().split())
a = [(1, int(x)) for x in input().split()]

for _ in range(m):
    b, c = map(int, input().split())
    a += [(b, c)]

from operator import itemgetter
a = sorted(a, key=itemgetter(1))

ans = 0
t = 0
while n-t > 0:
    (k, x) = a.pop()
    ans += x * min(k, n-t)
    t += k

print(ans)


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

int N;
int x[1000000];

void solve()
{
  int a, b;
  cin >> a >> b;
  cout << max(a+b, max(a-b, a*b)) << endl;
}

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


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
typedef long long ll;
typedef pair<int, int> pii;
const int INF = 1e9;
const int MOD = 1000000007;
const double PI = acos(-1);
int dx[4] = {0,1,0,-1};
int dy[4] = {1,0,-1,0};

void solve() {
  int n;
  cin >> n;
  vector<int> v(n);
  rep(i,n) cin >> v[i];
  map<int, int> mp;
  rep(i,n) {
    if (mp[v[i]]) mp[v[i]]--;
    else mp[v[i]]++;
  }
  int ans = 0;
  for(auto p: mp) {
    if (p.second) ans++;
  }
  cout << ans << endl;
}

int main() {
  solve();
  return 0;
}

Measured memory_bytes: 8156
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda:sys.stdin.readline().rstrip()
def resolve():
    a,b=map(int,input().split())
    now=1
    ans=0
    while(now<b):
        now+=a-1
        ans+=1
    print(ans)
resolve()

Measured memory_bytes: 38384
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define lvector vector<ll> 
#define P pair<ll,ll>
#define rep(i,n) for(ll (i)=0; (i)<(n); ++(i))
#define print(a) cout << (a) << endl

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll h,w,a,c,ans=0;cin>>h>>w;
  vector<lvector> A(h),C(10);
  rep(i,10) rep(j,10) {cin>>c; C[i].emplace_back(c);}
  rep(i,h) rep(j,w) {cin>>a; A[i].emplace_back(a);}
  rep(k,10) rep(i,10) rep (j,10) C[i][j]=min(C[i][j],C[i][k]+C[k][j]);
  rep(i,h)
  rep(j,w) {
    if(abs(A[i][j])==1) continue;
    else ans+=C[A[i][j]][1];
  }
  print(ans);
  return 0;
}

Measured memory_bytes: 640
#include<algorithm>
#include <iostream>
#include<cstdio>
#include<cmath>
#include<iomanip>
#include<string>
#include<cstdlib>
#include<ctime>
#include<vector>
using namespace std;

int main(){

   string s;
   cin>>s;

  int ans=1;

string ref="LRUD";
for(int i=0;i<s.length();i++){
  //  cout<<i<<endl;
    if(i%2==0){
      if(s[i]==ref[0]){
            ans=0;
            break;
        }
        }else{
            if(s[i]==ref[1]){
                ans=0;
                break;
            }
        
        
    }
}


if(ans==1){
    cout<<"Yes"<<endl;
}else{
    cout<<"No"<<endl;
}

    

return 0;
}

Measured memory_bytes: 256
macro_rules! get {
    ($t:ty) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t:ty),*) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            (
                $(iter.next().unwrap().parse::<$t>().unwrap(),)*
            )
        }
    };
    ($t:ty; $n:expr) => {
        (0..$n).map(|_|
            get!($t)
        ).collect::<Vec<_>>()
    };
    ($($t:ty),*; $n:expr) => {
        (0..$n).map(|_|
            get!($($t),*)
        ).collect::<Vec<_>>()
    };
    ($t:ty ;;) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.split_whitespace()
                .map(|t| t.parse::<$t>().unwrap())
                .collect::<Vec<_>>()
        }
    };
    ($t:ty ;; $n:expr) => {
        (0..$n).map(|_| get!($t ;;)).collect::<Vec<_>>()
    };
}

fn main() {
    let (n, k) = get!(usize, usize);
    let mut x = k;
    for _ in 0..n-1 {
        x *= k-1;
    }
    println!("{}", x);
}

Measured memory_bytes: 4352
#include<cstdio>
#include<algorithm>
#include<cctype>
#include<vector>
#define pb push_back
#define forall(x,i) for (int i=0;i<x.size();i++)
using namespace std;
#define G getchar()
int read()
{
	int x=0; char ch=G;
	for (;!isdigit(ch);ch=G);
	for (;isdigit(ch);ch=G) x=(x<<3)+(x<<1)+(ch^48);
	return x;
}
#undef G
typedef long long ll;

int n,m;
int A[100010],B[100010],C[100010];
int id[100010];
bool cmp(int x,int y){return C[x]<C[y];}
struct Edge{
	int to,nxt;
}edge[200010];
int cnt=1,last[100010];
inline void addedge(int x,int y){
	edge[++cnt]=(Edge){y,last[x]},last[x]=cnt;
	edge[++cnt]=(Edge){x,last[y]},last[y]=cnt;
}
ll S[100010],f[100010];
bool vis[100010];
int fat[100010];
int find(int x){return fat[x]?fat[x]=find(fat[x]):x;}
int main()
{
	n=read(),m=read();
	for (int i=1;i<=n;i++){
		A[i]=read(),B[i]=read();
		A[i]=max(A[i],B[i]);
		C[i]=A[i]-B[i];
		id[i]=i;
	}
	for (int i=1;i<=m;i++) addedge(read(),read());
	sort(id+1,id+n+1,cmp);
	for (int i=1;i<=n;i++){
		static int e[100010],top; top=0;
		int x=id[i]; vis[x]=1;
		S[x]=B[x];
		for (int j=last[x],y;j;j=edge[j].nxt){
			y=edge[j].to;
			if (!vis[y]||x==find(y)) continue;
			int k=find(y); S[x]+=S[k]; fat[k]=x;
			e[++top]=k;
		}
		f[x]=S[x]+C[x];
		for (int j=1;j<=top;j++){
			int k=e[j];
			f[x]=min(f[x],S[x]-S[k]+max(0LL+C[x],f[k]));
		}
	}
	printf("%lld\n",f[id[n]]);
	return 0;
}

Measured memory_bytes: 7172
#include<stdio.h>
#include<cmath>

int main(){
    int q;
    scanf("%d",&q);
    double x[2][2][q];
    double y[2][2][q];
    double p;
    double v;
    for(int i = 0; i < q; i++){
        scanf("%lf %lf %lf %lf %lf %lf %lf %lf", &x[0][0][i], &y[0][0][i], &x[0][1][i], &y[0][1][i], &x[1][0][i], &y[1][0][i], &x[1][1][i], &y[1][1][i]);
        p = (x[0][1][i]-x[0][0][i])*(y[1][1][i]-y[1][0][i]) - (x[1][1][i]-x[1][0][i])*(y[0][1][i]-y[0][0][i]);
        v = (x[0][1][i]-x[0][0][i])*(x[1][1][i]-x[1][0][i]) + (y[1][1][i]-y[1][0][i])*(y[0][1][i]-y[0][0][i]);
        if (p < 0.000000001 && p > -0.000000001){
            printf("2\n");
        } else if (v < 0.000000001 && v > -0.000000001){
            printf("1\n");
        } else {
            printf("0\n");
        }
    }
}


Measured memory_bytes: 2808
#include <bits/stdc++.h>
#define l_ength size
const int inf = (1<<30);
const int mod = 1000000007; // 998244353
using ll = long long;
using namespace std;

int main(){
	double a, b, h, m; cin >> a >> b >> h >> m;
	cout << fixed << setprecision(15) << sqrt( a*a+b*b-2.0*a*b*cos( (30.0*h+0.5*m-6.0*m)*acos(-1)/180.0 ) ) << endl;
}

Measured memory_bytes: 4260
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll A,B,C,K;
int main(){
    cin>>A>>B>>C>>K;
    if(max(A,B) - min(A,B) > 1LL*1e18)return cout<<"Unfair"<<endl,0;
    if(K%2 == 0)return cout<<A-B<<endl,0;
    return cout<<B-A<<endl,0;


}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<map>
#include<stack>
#include<queue>
#include<iomanip>
using namespace std;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 2e9
#define MOD 1e9+7
#define LINF (long long)4e18



int main(){
  string S;
  cin >> S;
  int sum = 0;
  int k = S.size();
  rep(i,k){
    if(S[i] == 'o')sum++;
  }
  if(15-k >= 8-sum)cout << "YES" << endl;
  else cout << "NO" << endl;
}

Measured memory_bytes: 256
import sys,math

l=[list(map(float,i.split(","))) for i in sys.stdin]
S=0
for (i,j) in enumerate(l):
    xn,yn=j
    if i!=len(l)-1:
        xn_1,yn_1=l[i+1]
    else:
        xn_1,yn_1=l[0]
    a=math.sqrt(xn**2+yn**2)
    b=math.sqrt(xn_1**2+yn_1**2)
    c=math.sqrt((xn_1-xn)**2+(yn_1-yn)**2)
    z=(a+b+c)/2
    S+=math.sqrt(z*(z-a)*(z-b)*(z-c))
print(S)


Measured memory_bytes: 5656
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define pi pair<ll, ll>
#define mp make_pair
#define pb push_back
#define vi vector<ll>
#define pd pair<double, double>
#define vp vector<pi>
#define f(i, n) for(int i = 0; i < n; i++)
#define fo(i, a, n) for(int i = a; i < n; i++)
#define mod (1000*1000*1000+7)
#define sz(x) int((x).size())
#define all(x) x.begin(),x.end()
#define DBG(v) cerr << #v << " = " << (v) << endl;
ll INF = (1ll<<61);

using namespace std;

int main(int argc, char* argv[]){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    int n, k; cin >> k >> n;
    vi v(n);
    f(i, n){
      cin >> v[i];
    }
    sort(all(v));
    vi tmp = v;
    f(i, n-1) tmp[i] = tmp[i+1] - tmp[i];
    tmp.back() = (k - tmp[n-1]) + v[0];
    sort(all(tmp));
    v = tmp;
    // f(i, n) cout << v[i] << " ";
    int sum = 0;
    f(i, n-1) sum += v[i];
    cout << sum << endl;
    return 0;
}


Measured memory_bytes: 3456
#include<cstdio>
#include<iostream>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#include<cmath>
#include<vector>
using namespace std;
typedef long long LL;
const int _=1e2;
const int maxn=1e5+_;
const int maxm=1e5+_;

int A[maxn],B[maxn],id[maxn];
bool cmp(int n1,int n2){return A[n1]<A[n2];}
vector<int>vec[maxn];
struct node
{
	int x,y,next;
}a[maxm];int len,last[maxn];
void ins(int x,int y)
{
	len++;
	a[len].x=x;a[len].y=y;
	a[len].next=last[x];last[x]=len;
}
int F[maxn];
LL f[maxn],sum[maxn];//进入这棵树搞完最少要多少速度，这棵树里面的总消耗速度
void dfs(int x)
{
	if(last[x]==0){f[x]=A[x]+B[x];sum[x]=B[x];return ;}
	sum[x]=B[x];
	for(int k=last[x];k;k=a[k].next)
	{
		int y=a[k].y;
		dfs(y);
		sum[x]+=sum[y];
	}
	f[x]=(1LL<<62);
	for(int k=last[x];k;k=a[k].next)
	{
		int y=a[k].y;
		f[x]=min(f[x],max(f[y],(LL)A[x])+sum[x]-sum[y]);
	}
}

int fa[maxn];
int findfa(int x)
{
	if(x==fa[x])return x;
	fa[x]=findfa(fa[x]);return fa[x];
}
int main()
{
	int n,m,x,y;
	scanf("%d%d",&n,&m); len=1;
	for(int i=1;i<=n;i++)
	{
		scanf("%d%d",&A[i],&B[i]);
		A[i]=max(A[i]-B[i],0);
		id[i]=i;
	}
	for(int i=1;i<=m;i++)
	{
		scanf("%d%d",&x,&y);
		vec[x].push_back(y);
		vec[y].push_back(x);
	}
		
	sort(id+1,id+n+1,cmp);
	memset(F,-1,sizeof(F));
	for(int t=1;t<=n;t++)
	{
		int i=id[t]; fa[i]=i;
		for(int k=0;k<vec[i].size();k++)
		{
			int j=vec[i][k],fj=findfa(j);
			if(F[fj]==0)F[fj]=i,fa[fj]=i;
		}
		F[i]=0;
	}
	int rt;
	for(int i=1;i<=n;i++)
		if(F[i]==0)rt=i;
		else ins(F[i],i);
		
	dfs(rt);
	printf("%lld\n",f[rt]);
		
	return 0;
}

Measured memory_bytes: 13180
#include<bits/stdc++.h>
clock_t t=clock();
namespace IO
{
	using namespace std;
	char buf[1<<22],Out[1<<22],*p1=buf,*p2=buf;
	int p3=-1,f=0;
	inline void file()
	{
		#ifdef NTFOrz
		freopen("file.in","r",stdin);
		#endif
	}
	inline char getchar()
	{
		return (p1==p2)&&(p2=(p1=buf)+fread(buf,1,1<<21,stdin),p1==p2)?EOF:*p1++;
	}
	inline void flush(){fwrite(Out,1,p3+1,stdout),p3=-1;}
	inline void check(){if (p3>(1<<21)) flush();}
	inline void putchar(char a){Out[++p3]=a;check();}
	inline void putline(string s)
	{
		int tmp=p3;
		while (p3-tmp<s.size()) putchar(s[p3-tmp]);
		putchar('\n');
	}
	inline char gc()
	{
		char c=getchar();
		while (!c||c=='\n'||c==' ') c=getchar();
		return c;
	}
	inline void chktime()
	{
		#ifdef NTFOrz
		printf("%dms\n",clock()-t);
		#endif
	}
}
namespace my_std
{
	using namespace std;
//	#define getchar IO::getchar
//	#define putchar IO::putchar
    #define Re register
    #define rep(i,a,b) for (Re int i=(a);i<=(b);i++)
    #define drep(i,a,b) for (Re int i=(a);i>=(b);i--)
    #define repv(i,v) for (Re int i=0;i<v.size();i++)
    #define go(u) for (Re int i=head[(u)];i;i=e[i].nxt)
    #define writesp(x) write(x),putchar(' '),IO::check()
    #define writeln(x) write(x),putchar('\n'),IO::check()
    #define mem(x,v) memset(x,v,sizeof(x))
    #define pb push_back
    #define fir first
    #define sec second
    #define MP make_pair
    typedef long long ll;
    typedef unsigned long long ull;
    typedef pair<int,int> pii;
    const int INF=0x7fffffff;
    inline int read()
    {
        ll sum=0,f=0;char c=getchar();
        while (!isdigit(c)) f|=(c=='-'),c=getchar();
        while (isdigit(c)) sum=(sum<<1)+(sum<<3)+(c^48),c=getchar();
        return f?-sum:sum;
    }
    void write(int k)
    {
        if (k<0) putchar('-'),k=-k;
        if (k>=10) write(k/10);
        putchar(k%10+48);
    }
	#define templ template<typename T>
    templ inline void chkmax(T &x,T y){if (x<y) x=y;}
    templ inline void chkmin(T &x,T y){if (x>y) x=y;}
}
using namespace my_std;
char c[114514];
int ___[114514];
stack<int>s;
#define ask(x,y) printf("?%d %d\n",x,y),fflush(stdout)
#define query() (scanf("%s",c+1)&&(c[1]=='Y')) 
int main()
{
	IO::file();
	int a=read(),b=read(),n=a+b;
	if (a<=b) return printf("Impossible\n"),0;
	rep(i,0,n-1)
	{
		if (!s.size()) s.push(i);
		else
		{
			ask(s.top(),i);
			if (query()) s.push(i);
			else s.pop();
		}
	}
	rep(i,0,n-1) ask(s.top(),i),___[i]=query();
	printf("! ");
	rep(i,0,n-1) printf("%d",___[i]);
	IO::flush();
	IO::chktime();
	return 0;
}

Measured memory_bytes: 3856
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define fo(a,b) for(int a=0;a<b;a++)
#define Sort(a) sort(a.begin(),a.end())
#define rev(a) reverse(a.begin(),a.end())
 int wari(int a,int b) {
   if(a%b==0)
     return a/b;
   else
     return a/b+1;
 }
 int keta(int a){
  double b=a;
  b=log10(b);
  int c=b;
  return c+1;
 }
 int souwa(int a){
  return a*(a+1)/2;
 }
 int lcm(int a,int b){
  int d=a,e=b,f;
  if(a<b)
    swap(a,b);
  int c,m=1;
  while(m){
    c=a%b;
    if(c==0){
       f=b;
      m--;
    }
    else{
      a=b;
      b=c;
 }
  }
  return d*e/f;
    }
  int gcm(int a,int b){
      int d=a,e=b,f;
  if(a<b)
    swap(a,b);
  int c,m=1;
  while(m){
    c=a%b;
    if(c==0){
       f=b;
      m--;
    }
    else{
      a=b;
      b=c;
 }
  }
  return f;
  }
 bool prime(int a){
   if(a<2)
     return false;
   else if(a==2)
     return true;
   else if(a%2==0)
     return false;
   double b=sqrt(a);
    for(int i=3;i<=b;i+=2){
      if(a%i==0){
        return false;
      }
    }
   return true;
 }
signed main(){
  int a;
  cin>>a;
  vector<int> b(a),c;
  fo(i,a)
    cin>>b[i];
  c=b;
  Sort(c);
  int d,e;
  d=c[a/2-1];
  e=c[a/2];
  fo(i,a){
    if(b[i]<=d)
      cout<<e<<endl;
    else
      cout<<d<<endl;
  }
}


Measured memory_bytes: 5376
#include <stdio.h>
int main(void){
    // Your code here!
    int a,b,c;
    int tmp;
    scanf("%d %d %d",&a,&b,&c);
    
    tmp = a-b;
    tmp = c - tmp;
    
    if(tmp<0) tmp = 0;
    
    printf("%d\n",tmp);
    
    return 0;
}


Measured memory_bytes: 128
def GCD(x, y):
  # 最大公約数
    if x < y:
        x, y = y, x
    while True:
        r = x % y
        if r == 0:
            return y
        x, y = y, r


def calc_DCD_LCM(x, y):
  # 最大公約数
    gcd = GCD(x, y)
  # 最小公倍数
    lcm = int(x*y/gcd)
    return(gcd, lcm)


while True:
    try:
        x, y = list(map(int, input().split()))
        gcd, lcm = calc_DCD_LCM(x, y)
        print('{0} {1}'.format(gcd, lcm))
    except:
        exit(0)


Measured memory_bytes: 5596
#include<bits/stdc++.h>
using namespace std;
typedef pair<long long, long long> P;
int main(){
    long long N;
    cin >> N;
    vector<long long> A(N), sum(N);
    for(int i = 0; i < N; i++) {
        cin >> A[i];
        sum[i] = i - A[i];
    }
    sort(sum.begin(), sum.end());
    long long ans = 0;
    for(int i = 0; i < N; i++){
        long long a = i + A[i];
        long long t = upper_bound(sum.begin(),sum.end(), a) - lower_bound(sum.begin(),sum.end(), a);
         ans+=t;
    }
    cout << ans << endl;
}

Measured memory_bytes: 6348
import sys
import math
import itertools
import collections
import heapq
import re
import numpy as np

rr = lambda: sys.stdin.readline().rstrip()
rs = lambda: sys.stdin.readline().split()
ri = lambda: int(sys.stdin.readline())
rm = lambda: map(int, sys.stdin.readline().split())
rl = lambda: list(map(int, sys.stdin.readline().split()))
inf = float('inf')
mod = 10**9 + 7

s = rr()
min_ = inf
for i in range(len(s)-2):
  min_ = min(min_, abs(int(s[i:i+3])-753))
print(min_)
  
  
    










Measured memory_bytes: 27140
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda:sys.stdin.readline().rstrip()
def resolve():
    n=int(input())
    A=list(map(int,input().split()))
    xor=0
    for a in A:
        xor^=a # どう分けても確定しているbit

    A=[a&(~xor) for a in A] # 見るべき bit
    xor1=0
    for a in A:
        xor1^=a

    A.sort(reverse=1)
    now=0
    for d in range(60,-1,-1):
        for p in range(now,n):
            if((A[p]>>d)):
                for i in range(n):
                    if(i==p): continue
                    if((A[i]>>d)&1):
                        A[i]^=A[p]
                A[p],A[now]=A[now],A[p]
                now+=1
                break

    xor2=0
    for a in A:
        xor2^=a

    xor3=xor1^xor2
    print(xor+xor2+xor3)
resolve()

Measured memory_bytes: 76144
n=int(input())
a=list(map(int,input().split()))
ans=0
mod=10**9+7
for i in range(60):
    iti=0
    zero=0
    for j in range(n):
        if (a[j]>>i)&1:
            iti+=1
        else:
            zero+=1
    ans+=(2**i)*(iti*zero)
    ans%=mod
print(ans)


Measured memory_bytes: 122808
object Main {

  def main(args: Array[String]): Unit = {
    val sc = new java.util.Scanner(System.in)

    val _A, _B = sc.nextBigInteger()
    val _C, _D = sc.nextLong()

    val A = BigInt(_A)
    val B = BigInt(_B)

    def gcd(a: Long, b: Long): Long =
      if (b == 0) a
      else gcd(b, a % b)

    def lcm(a: Long, b: Long): Long =
      a * b / gcd(a, b)

    var C = null.asInstanceOf[BigInt]
    var D = null.asInstanceOf[BigInt]
    val lcmv = if (_D > _C) {
      C = BigInt(_C)
      D = BigInt(_D)
      lcm(_D, _C)
    } else {
      C = BigInt(_D)
      D = BigInt(_C)
      lcm(_C, _D)
    }


    // CでもDでも割り切れない
    // 全体から, CでもDでも割り切れる
    val v =
      (B / C) - ((A - 1) / C) + (B / D) - ((A - 1) / D) - ((B / lcmv) - ((A - 1) / lcmv))
    println(B - A + 1 - v)
  }

}

Measured memory_bytes: 25536
#include<stdio.h>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<utility>
#include<memory>
#include<cmath>

#define ALL(g) (g).begin(),(g).end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define pb push_back

using namespace std;
 
typedef long long ll;
typedef pair<int,int> P;
const int mod=1e9+7,INF=1<<30;
const double EPS=1e-12,PI=3.1415926535897932384626;
const int MAX_N=9;
const ll LINF=100000000000000000;

int main(){
  string S;
  cin >> S;
  map<char,int> mp;
  for(char c='a';c<='z';c++) mp[c]=0;
  bool res=true;
  rep(i,S.size()){
    mp[S[i]]++;
    if(mp[S[i]]>=2){
      res=false;
      break;
    }
  }
  cout << (res ? "yes" : "no" ) << endl;
  return 0;
}


Measured memory_bytes: 256
import sys
input=sys.stdin.readline
import collections

def main():
    N = int(input())
    A = list(map(int,input().split()))
    d = collections.defaultdict(int)
    for a in A:
        d[a] += 1
    for k,v in list(d.items()):
        if v < 2:
            d.pop(k)
    d = sorted(d.items(), key=lambda x: x[0], reverse=True)
    if len(d) >= 1 and d[0][1] >= 4:
        print(d[0][0]**2)
    elif len(d) >= 2:
        print(d[0][0]*d[1][0])
    else:
        print(0)

if __name__ == '__main__':
    main()


Measured memory_bytes: 21540
#coding=UTF-8

mozir=input()
hyo=mozir.split(' ')
X=int(hyo[0])
A=int(hyo[1])
B=int(hyo[2])

A_Dist=abs(X-A)
B_Dist=abs(X-B)

if A_Dist > B_Dist :
    print('B')
else:
    print('A')
    


Measured memory_bytes: 3060
/**
 *    author  : 𝒌𝒚𝒐𝒎𝒖𝒌𝒚𝒐𝒎𝒖𝒑𝒖𝒓𝒊𝒏
 *    created : 2020-01-18 20:36:18
**/

#include <iostream>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <complex>
#include <numeric>
#include <bitset>
#include <cassert>
#include <cctype>
#include <iomanip>
#include <random>
#include <utility>
#include <chrono>

using namespace std;

using int64 = long long;

template<class T> std::ostream& operator<<(std::ostream& os, const std::vector<T>& vec) { os << '{'; size_t n = vec.size(); for (size_t i = 0; i < n; ++i) { os << vec[i]; if (i != n - 1) os << ','; } os << '}'; return os; }
template<class T, class U> std::ostream& operator<<(std::ostream& os, const std::pair<T, U>& p) { return os << '{' << p.first << " " << p.second << '}'; }
template<class T> std::istream& operator>>(std::istream& is, std::vector<T>& vec) { size_t n = vec.size(); for (size_t i = 0; i < n; ++i) is >> vec[i]; return is; }

#ifdef LOCAL
#define debug(_) cerr << #_ << ": " << (_) << '\n'
#else
#define debug(_) 1728
#endif

template <class T>
class CumulativeSum {
 public:
  CumulativeSum(const std::vector<T>& vec) : vec_(vec) { Build(); }

  // return sum of [left, right]
  T Get(int left, int right) {
    return sum_[right + 1] - sum_[left];    
  }

 private:
  std::vector<T> vec_;
  std::vector<T> sum_;

  void Build() {
    sum_.assign(vec_.size() + 1, static_cast<T>(0));
    for (size_t i = 0; i < vec_.size(); ++i) {
      sum_[i + 1] = sum_[i] + vec_[i];
    }
  }
};

constexpr int64 INF = 1e9;

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

  int64 n, k, s; cin >> n >> k >> s;
  vector<int64> ans;

  for (int i = 0; i < k; ++i) {
    ans.emplace_back(s);
  }

  if (n - k > s) {
    for (int i = 0; i < n - k; ++i) {
      if (s == 1LL) {
        ans.emplace_back(INF);
      } else {
        ans.emplace_back(s - 1LL);
      }
    }
  } else {
    for (int i = 0; i < n - k; ++i) {
      if (s == INF) {
        ans.emplace_back(1LL);
      } else {
        ans.emplace_back(INF);
      }
    }
  }

  for (int i = 0; i < n; ++i) {
    cout << ans[i] << " ";
  }
  cout << '\n';

  return 0;
}

Measured memory_bytes: 2292
# revie series
from collections import Counter
N = int(input())
A = list(map(int, input().split()))
A.sort()
divisible = [False for i in range(10**6+1)]
visited = [False for i in range(10**6+1)]
for x in A:
    if visited[x] == False:
        visited[x] = True
        cnt = 2*x
        while cnt <= 10**6:
            divisible[cnt] = True
            cnt += x
    elif visited[x] == True:
        divisible[x] = True

ans = 0
for x in A:
    if divisible[x] == False:
        ans += 1
print(ans)

Measured memory_bytes: 217892
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        MyScanner in = new MyScanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        A solver = new A();
        solver.solve(1, in, out);
        out.close();
    }

    static class A {
        public void solve(int testNumber, MyScanner in, PrintWriter out) {
            int A = in.nextInt();
            int B = in.nextInt();
            out.println(Math.max(A + B, Math.max(A - B, A * B)));
        }

    }

    static class MyScanner {
        private BufferedReader in;
        private StringTokenizer st;

        public MyScanner(InputStream stream) {
            in = new BufferedReader(new InputStreamReader(stream));
        }

        public String next() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    String rl = in.readLine();
                    if (rl == null) {
                        return null;
                    }
                    st = new StringTokenizer(rl);
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return st.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}



Measured memory_bytes: 21460
/***********************
*  Author: xuziyuan    * 
***********************/

#include <bits/stdc++.h>

#define rt0 return 0
#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
#define replet(c) for(char c='a';c<='z';c++)
#define LL long long
#define pii pair <int,int>
#define pb push_back
#define fi first
#define se second
#define mpr make_pair
#define sqr(a) ((a)*(a))

using namespace std;

const LL MOD=1e9+7;

int n,m,x,y,in[100010],dist[100010],ans[100010];
vector <int> g[100010];

int dfs_init(int pos)
{
	//cout<<pos<<endl;
	if(dist[pos]!=-1) return dist[pos];//作为vis数组 
	rep(i,g[pos].size()) dist[pos]=max(dist[pos],dfs_init(g[pos][i])+1);
	if(dist[pos]==-1) dist[pos]=0;
	return dist[pos];
}

bool cmp(pii a,pii b)
{
	return a.fi>b.fi;
}

void dfs(int pos,int lst)
{
	if(ans[pos]!=-1) return;
	ans[pos]=lst;
	vector <pii> v;
	rep(i,g[pos].size()) v.pb({dist[g[pos][i]],g[pos][i]});
	sort(v.begin(),v.end(),cmp);
	rep(i,v.size()) dfs(v[i].se,pos);
}

int main()
{
	memset(dist,-1,sizeof(dist));
	memset(ans,-1,sizeof(ans));
	cin>>n>>m;
	rep(i,n+m-1)
	{
		scanf("%d%d",&x,&y);
		g[x].pb(y);
		in[y]++;
	}
	repn(i,n)
	{
		if(in[i]==0)
		{
			dfs_init(i);
			dfs(i,0);
			repn(j,n) cout<<ans[j]<<endl;
			rt0;
		}
	}
	rt0;
}

Measured memory_bytes: 19968
n,k=map(int,input().split())
list_a=[]
for d in range(k):
  d=int(input())
  a=list(map(int,input().split()))
  list_a.extend(a)
ans=0
for i in range(1,n+1): 
 if list_a.count(i)==0:
      ans+=1
print(ans)
       

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

// definition {{{ 1

// scaning {{{ 2
#define Scd(x) scanf("%d", &x)
#define Scd2(x,y) scanf("%d%d", &x, &y)
#define Scd3(x,y,z) scanf("%d%d%d", &x, &y, &z)

#define Scll(x) scanf("%llu", &x)
#define Scll2(x,y) scanf("%llu%llu", &x, &y)
#define Scll3(x,y,z) scanf("%llu%llu%llu", &x, &y, &z)

#define Scc(c) scanf("%c", &c);
#define Scs(s) scanf("%s", s);
#define Scstr(s) scanf("%s", &s);
// }}} 2

// constants {{{ 2
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
// }}} 2

// systems {{{ 2
#define Rep(x,y) for(int x = 0; x < y; x++)
#define Repe(x,y,z) for(int x = z; x < y; x++)
// }}} 2

// output {{{ 2
#define YesNo(a) (a)?printf("Yes\n"):printf("No\n");
// }}} 2

// }}} 1

int main() {

    int N,M;
    Scd2(N,M);

    int a,b;
    vector<int> imo(N,0);
    Rep(i,M){
        Scd2(a,b);
        a--,b--;
        imo[a]++;
        imo[b]--;
    }

    bool ans = true;
    Rep(i,N){
        imo[i+1] += imo[i];
        if( imo[i] & 1 ) ans = false;
    }

    printf ("%s\n", ans ? "YES" : "NO" );

    return 0;
}



Measured memory_bytes: 640
#include<iostream>
#include<climits>
#include<math.h>
#include<vector>
#include<algorithm>
#include<cstdio>
#include <string>
#include <complex>
#include <functional>
using namespace std;
typedef pair<int,int> P;
double dat[100][100];
int dp[6][1010];//動的計画法
int prime[10000001];
char str[1010][1010];
vector<pair<int,int> > pc[100001];
int ABS(int a){return max(a,-a);}
int main(){
  int n,cnt,ans;
  for(int i=1;i<201;i++) prime[i]=0;
  for(int i=105;i<201;i+=2){
      cnt=0;
      for(int j=1;j*j<=i;j++){
          if(i%j==0){
              if(j!=i/j) cnt+=2;
              else cnt++;
          }
      }
      if(cnt==8) prime[i]=1;
  }
  cin>>n;
  ans=0;
  for(int i=1;i<=n;i+=2){
      if(prime[i]==1) ans++;
  }
  cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 4352
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using LL = long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VVLL = vector<VLL>;
using VS = vector<string>;
using PII = pair<int,int>;
using VP = vector<PII>;
using VB = vector<bool>;
using VVB = vector<VB>;
#define REP(i,m,n) for(int i=(m);i<(n);i++)
	//i=m -> n-1(昇順)
#define RREP(i,m,n) for(int i=(m);i>=(n);i--)
	//i=m -> n(降順)

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

int main(){
  LL h,w,ch,cw,dh,dw,cost=0;
  cin >> h >> w >> ch >> cw >> dh >> dw;
  ch--; cw--; dh--; dw--;
  VS s(h);
  REP(i,0,h){
    cin >> s[i];
  }
  
  bool finished = false;
  VVLL cost_info(h,VLL(w,-1));
  queue<PII> que;
  queue<PII> warp;
  
  cost_info[ch][cw] = 0;
  que.push(make_pair(ch,cw));

  
  while(!que.empty()){
    while(!que.empty()){
      int x = que.front().first;
      int y = que.front().second;
      que.pop();
      warp.push(make_pair(x,y));
    
      REP(dir,0,4){
        int nx = x + dx[dir];
        int ny = y + dy[dir];
        if(nx < 0 || nx >= h || ny < 0 || ny >= w){continue;}
        if(s[nx][ny] == '#'){continue;}
      
        if(cost_info[nx][ny] == -1) {
          que.push(make_pair(nx, ny));
          cost_info[nx][ny] = cost;
        }
      }
    }
    
    while(!warp.empty()){
      int x = warp.front().first;
      int y = warp.front().second;
      warp.pop();
      
      REP(i,-2,3){
        REP(j,-2,3){
          int nx = x + i;
          int ny = y + j;
          if(nx<0 || nx>=h || ny<0 || ny>=w){continue;}
          if(s[nx][ny] == '#'){continue;}
          
          if(cost_info[nx][ny] == -1){
            que.push(make_pair(nx,ny));
            cost_info[nx][ny] = cost+1;
          }
        }
      }
    }
    cost++;
  }
  
  cout << cost_info[dh][dw] << endl;
  /*REP(i,0,h){
    REP(j,0,w){
      cout << cost_info[i][j] << " ";
    }
    cout << endl;
  }*/
  
  return 0;
}


Measured memory_bytes: 13484
A, B, C, D = [int(s) for s in input().split()]
turn = 0
while A > 0 and C > 0:
  if turn == 0:
    C -= B
    turn = 1
  else:
    A -= D
    turn = 0
if A > 0:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 9124
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int y = sc.nextInt();
        int a = -1;
        int b = -1;
        int c = -1;
        boolean breakFlag = false;
        for(int i = 0; i <= n; i++){
            for(int j = 0; j <= n-i; j++){
                int sum = 10000*i + 5000*j + 1000*(n-i-j);
                if(sum == y){
                    a = i;
                    b = j;
                    c = n - i - j;
                    breakFlag = true;
                }
            }
            if(breakFlag){
                break;
            }
        }
        System.out.println(String.valueOf(a) + " " + String.valueOf(b) + " " + String.valueOf(c));
        sc.close();
    }

}


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

using namespace std;

#define MOD 1000000007
#define N 100005
#define M 30
#define ll long long 
#define ld long double
#define pb push_back
#define ff first
#define ss second

int main(){
	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	string s, t;
	cin>>s>>t;
	int ans = 0, i;
	for(i=0; i<3; i++){
		if(s[i] == t[i]) ans++;
	}
	cout<<ans;
	return 0;
}

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

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

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

n = read()
a = sorted(reads())

x = a.pop()
y = sorted((abs(x-2*p), p) for p in a)[0][1]
print(x, y)


Measured memory_bytes: 64748
#include <iostream>
#include <map>
#include <vector>
#include <algorithm>

using namespace std;

int main() {
    int N, K;
    cin >> N >> K;
    
    map<int, int> num;
    for (int i = 0; i < N; i++) {
        int A; cin >> A; A--;
        num[A]++;
    }

    int kind = 0;
    vector<int> snum;
    for (auto i = num.begin(); i != num.end(); i++) {
        kind++;
        snum.push_back(i->second);
    }

    sort(snum.begin(), snum.end());

    int ans = 0;
    if (kind > K) {
        for (int i = 0; i < kind - K; i++) ans += snum[i];
    }
    

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 10748
// C.

#include <iostream>
#include <sstream>
#include <vector>
#include <algorithm>
#include <numeric>

using namespace std;

int n;
int target[3];
int fragment[8];

int dfs(int i, int used) {
	if (i >= 3) return 0;
	int min_cost = 1 << 30;
	int bm = 1 << n;
	for (int t = 1; t < bm; ++t) {
		if (used & t) continue;
		int len = 0, cost = 0;
		for (int i = 0; i < n; ++i) {
			if ((1 << i) & t) {
				if (len) {
					cost += 10;
				}
				len += fragment[i];
			}
		}
		cost += abs(target[i] - len);
		cost += dfs(i + 1, used | t);
		min_cost = min(min_cost, cost);
	}
	return min_cost;
}

int main(int argc, char *argv[]) {
	cin >> n;
	for (int i = 0; i < 3; ++i) {
		cin >> target[i];
	}
	for (int i = 0; i < n; ++i) {
		cin >> fragment[i];
	}
	int ans = dfs(0, 0);
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#define ll long long
#define fi first
#define se second
#define pb push_back
#define me memset
const int N = 1e6 + 10;
const int mod = 1e9 + 7;
using namespace std;
typedef pair<int,int> PII;
typedef pair<long,long> PLL;

string s,t;

int main() {
    ios::sync_with_stdio(false);
    cin >> s >> t;
    if (s.size() != t.size() - 1) puts("No");
    else{
        for (int i = 0; i < s.size(); ++i) {
            if (s[i] != t[i]){
                puts("No");
                return 0;
            }
        }
        puts("Yes");
}
    return 0;
}

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

using namespace std;

typedef long long ll;

const double pi = 3.14159265358979323846;

#define REP(i, n) for (ll i = 0; i < n; i++)
#define MOD 1000000007LL
#define PS(p) cout << setprecision(15) << fixed << p << endl;
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
#define ALL(c) c.begin(), c.end()
#define CIN(v) cin >> v;
#define COUT(v) cout << v << "\n";

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

  int N;
  CIN(N);

  int count = 1;
  char S, last;
  CIN(last);
  for (int i = 1; i < N; i++) {
    CIN(S);

    if (S != last) {
      count++;
    }

    last = S;
  }

  COUT(count);

  return 0;
}


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

class State{
public:
  int p[2][4];
  int cost;
  int sx, sy;
  bool operator < (const State &s) const {
    for(int i = 0; i < 2; i++) {
      for(int j = 0; j < 4; j++) {
	if(p[i][j] != s.p[i][j]) return p[i][j] < s.p[i][j];
      }
    }
    return false;
  }
};

int main() {
  set<State> data;
  State s;
  for(int i = 0; i < 2; i++) {
    for(int j = 0; j < 4; j++) {
      s.p[i][j] = i*4+j;
    }
  }
  s.sx = 0;
  s.sy = 0;
  s.cost = 0;
  data.insert(s);
  queue<State> Q;
  Q.push(s);
  while(!Q.empty()) {
    s = Q.front();
    Q.pop();
    int d[4][2] = {{1,0},{0,1},{-1,0},{0,-1}};
    for(int i = 0; i < 4; i++) {
      State ts = s;
      ts.sx += d[i][0];
      ts.sy += d[i][1];
      ts.cost++;
      if(ts.sx < 0 || ts.sx >= 4) continue;
      if(ts.sy < 0 || ts.sy >= 2) continue;
      int temp = ts.p[ts.sy][ts.sx];
      ts.p[ts.sy][ts.sx] = ts.p[s.sy][s.sx];
      ts.p[s.sy][s.sx] = temp;
      if(data.find(ts) != data.end()) continue;
      data.insert(ts);
      Q.push(ts);
    }
  }

  State input;
  while(cin >> input.p[0][0]) {
    for(int i = 1; i < 8; i++) {
      cin >> input.p[i/4][i%4];
    }

    cout << data.find(input)->cost << endl;
  }
}

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

int N, X, L[100009], S, T;

int main() {
	cin >> N >> X; S = 1;
	for (int i = 1; i <= N; i++) {
		cin >> L[i]; T += L[i];
		if (T <= X) S++;
	}
	cout << S << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <map>
#include <set>
#include <numeric>

using namespace std;

typedef long long ll;
typedef long double ld;

#define sz(a) int((a).size())
#define forn(i, n) for (int i = 0; i < int(n); ++i)
#define fore(i, l, r) for (int i = int(l); i < int(r); ++i)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define file_name(a) (freopen(((string)(a) + ".in").c_str(),"r",stdin), freopen(((string)(a) + ".out").c_str(),"w",stdout))


int nxt() {
	int x;
	cin >> x;
	return x;
}


struct req {
	int a, b, c, d;
};

int n, m, q;
vector <int> a;
vector <req> r;
ll ans = 0;

void rec(int ind, int p) {
	if (ind == n + 1) {
		ll sum = 0;
		for (int i = 1; i <= q; i++) {
			if (a[r[i].b] - a[r[i].a] == r[i].c) {
				sum += r[i].d;
			}
		}
		ans = max(ans, sum);
	}
	else {
		for (int i = p; i <= m; i++) {
			a[ind] = i;
			rec(ind + 1, i);
		}
	}
}

int main() {
	cin >> n >> m >> q;
	a.resize(n + 1);
	r.resize(q + 1);
	for (int i = 1; i <= q; i++) {
		cin >> r[i].a >> r[i].b >> r[i].c >> r[i].d;
	}
	rec(1, 1);
	cout << ans << '\n';
	return 0;
}

Measured memory_bytes: 3644
import bisect
N=int(input())
A=sorted(list(map(int, input().split())))
B=sorted(list(map(int, input().split())))
C=sorted(list(map(int, input().split())))

ans=0
for b in B:
    a=bisect.bisect_left(A,b)
    c=bisect.bisect_right(C,b)
    ans+=a*(N-c)
print(ans)

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

using namespace std;
typedef long long ll;

#define INF (long long)(1e9+7)
#define REP(i,n) for(ll i = 0; i < n; i++)
#define REP1(i,n) for(ll i = 1; i <= n; i++)

ll t[100100], x[100100], y[100100];

int main(void)
{
    ll n;
    ll dt, dx,dy;
    cin >> n;
    REP1(i, n) cin >> t[i] >> x[i] >> y[i];
    t[0] = x[0] = y[0] = 0;
    bool ok = true;
    REP1(i, n) {
        dt = t[i] - t[i -1];
        dx = abs(x[i] - x[i -1]);
        dy = abs(y[i] - y[i -1]);
        if((dx+dy<=dt) && (dx + dy)%2 == dt%2) {
        } else {
            ok = false;
        }
    }
    cout << (ok?"Yes":"No") << endl; 
                 



}


Measured memory_bytes: 2560
let () = Scanf.scanf "%d %d %d\n" @@ fun n m x ->
  let icass = List.init n @@ fun i ->
    Scanf.scanf "%d " @@ fun c ->
      (i, c, List.init m @@ fun _ -> Scanf.scanf "%d " Fun.id) in
  let ans =
    List.fold_left min max_int @@
    List.init (1 lsl n) @@ fun bits ->
      let skill = Array.make m 0 in
      let cost =
        List.fold_left (fun cost (i, c, as_) ->
          if bits land (1 lsl i) = 0
          then cost
          else begin
            List.iteri (fun j a ->
              skill.(j) <- a + skill.(j)) as_;
            c + cost
          end) 0 icass in
      if
        List.for_all (( <= ) x) @@
        Array.to_list skill
      then cost
      else max_int in
  Printf.printf "%d\n" @@
  if ans = max_int then -1 else ans



Measured memory_bytes: 6056
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int[] s = new int[n];
        for (int i = 0; i < n; i++) {
            s[i] = in.nextInt();
        }
        int q = in.nextInt();
        int[] t = new int[q];
        for (int i = 0; i < q; i++) {
            t[i] = in.nextInt();
        }

        int c = 0;
        for (int i : t) {
            if (binarySearch(s, i)) {
                c++;
            }
        }
        System.out.println(c);
    }

    private static boolean binarySearch(int[] s, int val) {
        int left = 0;
        int right = s.length - 1;
        int mid = (right + left) / 2;

        while (left <= right) {
            if (s[mid] == val) {
                return true;
            } else if (s[mid] > val) {
                right = mid - 1;
                mid = (right + left) / 2;
            } else {
                left = mid + 1;
                mid = (right + left) / 2;
            }
        }
        return false;
    }
}



Measured memory_bytes: 68256
#include <iostream>
using namespace std;
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
long long A,B,C,x,y,z;
int main(int argc, char** argv) 
{
	cin>>A>>B>>C;
	if(A%2==0||B%2==0||C%2==0) cout<<0<<endl;
	else
	{
		x=A*B,y=B*C,z=C*A;
		if(x>y) x=y;
		if(x>z) x=z; 
		cout<<x<<endl;
	}
	return 0;
}

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

int main()
{
    int h,w;
    cin>>h>>w;
    for(int i=0;i<w+2;i++){
        cout<<'#';
    }
    cout<<endl;
    char x;
    for(int i=0;i<h;i++){
        cout<<'#';
        for(int j=0;j<w;j++){
        cin>>x;
        cout<<x;
        }
        cout<<'#'<<endl;
    }
    for(int i=0;i<w+2;i++){
        cout<<'#';
    }
    cout<<endl;
}

Measured memory_bytes: 256