akhauriyash/Code-Regression huggingface dataset:
import math

def C(m,n):
    if m>=n:
        return math.factorial(m)//math.factorial(n)//math.factorial(m-n)
    else:
        return 0

N,K = map(int,input().split())
for i in range(1,K+1):
        print(int(C(K-1,i-1)*C(N-K+1,i))%(10**9+7))


Measured memory_bytes: 3316
#include<bits/stdc++.h>
using namespace std;
long n,r,l=-1,m,c,s,i,N,a[1<<17];
main(){
	for(cin>>n;cin>>m;r=r<m?m:r)a[i++]=m;
	for(;r-l>1;(c>n*(n+1)/4?r:l)=m){
		int b[2*n+1]={};
		m=l+r>>1;
		b[n]=1;
		s=n,N=0,c=0;
		for(i=0;i<n;){
			if(a[i++]>m){
				s++;
				N-=s[b];
				b[s]++;
				c+=N;
			}
			else{
				N+=b[s];
				s--;
				c+=N;
				b[s]++;
			}
		}
	}
	cout<<r;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
 
int main(void){
    
     int a,b,c,d;
     cin>>a>>b>>c>>d;

    if(a+b>c+d)
    cout<<"Left"<<endl;

    else if(a+b<c+d)
    cout<<"Right"<<endl;

    else{
        cout<<"Balanced"<<endl;
    }
    
    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <climits>
#include <stack>
#include <queue>
#include <iomanip>
#include <limits>
#include <string>
#include <cmath>
#include <set>
#include <map>
#include <math.h>
#include <algorithm>
#include <vector>

using namespace std;
typedef long long ll;


typedef pair<ll,ll> P;
long long int INF = 1e18;
double Pi = 3.141592653589;
const int mod = 1000000007;
// memset(a,0,sizeof(a)); →全部０にする

vector<int> G[100005];
std::vector<P> tree[100010];

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

#define p(x) cout<<x<<endl;
#define e cout<<endl;
#define pe(x) cout<<x<<" ";
#define re(i,a,b) for(i=a;i<=b;i++)

ll i,j,k,l,ii,jj;
ll n,m,ans=0,sum,num=0;
ll a[100005],b[100005],dame[100005];
bool start=false;


int main(){
    cin>>n>>k;
    for(i=0;i<n;i++){
        cin>>a[i]>>b[i];
    }
    for(i=30;i>=-1;i--){
        /*if(!start && k & 1<<i){
            start=true;
        }
        if(!start)continue;*/
        if(k & 1<<i || i==-1){
            sum=0;
            for(j=0;j<n;j++){
                bool flag=false;
                for(ii=0;ii<num;ii++){
                    if(a[j] & 1<<(dame[ii]))flag=true;
                }
                if(i!=-1 && (a[j] & 1<<i))flag=true;
                if(!flag)sum+=b[j];
            }
            ans = max(sum,ans);
            sum=0;
        }else{
            dame[num]=i;
            num++;
        }
    }
    p(ans);
    return 0;
    
}


Measured memory_bytes: 6656
fn read_line() -> String {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim_right().to_owned()
}

fn main() {
    let nums: Vec<u64> = read_line().split_whitespace().map(|x| x.parse().unwrap()).collect();
    let (a, b) = (nums[0], nums[1]);
    let k_up = b + a;
    let k_down = 2;
    let k = k_up / k_down;

    if k_up % k_down == 0 {
        println!("{}", k);
    } else {
        println!("IMPOSSIBLE");
    }
}


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

#define ll long long int
#define Mod 1000000007


int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int a,b; cin>>a>>b;
    cout<<(3*a+b)/2;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long long ll;
const ll MOD = 1000000007;
#define SortAsc(c) std::sort(c.begin(), c.end())
#define SortDesc(c) std::sort(c.rbegin(), c.rend())
int dx[8] = {0, 1, 0, -1, 1, 1, -1, -1};
int dy[8] = {1, 0, -1, 0, 1, -1, 1, -1};

int main() {
  int N;
  cin >> N;
  set<string> p;

  for (int i = 0; i < N; i++) {
    string s;
    cin >> s;
    p.insert(s);
  }

  cout << p.size() << endl;
}

Measured memory_bytes: 19096
#include <bits/stdc++.h>
using namespace std;
#define debug(...) { printf("#  "); printf(__VA_ARGS__); puts(""); }
#define fi first
#define se second
#define endl "\n" 
using ll = long long;
using pII = pair <int, int>;
using pLL = pair <ll, ll>;
using VI = vector <int>;
using VL = vector <ll>;
constexpr int mod = 1e9 + 7;
template <class T1, class T2> inline void chadd(T1 &x, T2 y) { x += y; if (x >= mod) x -= mod; else if (x < 0) x += mod; } 
template <class T1, class T2> inline void chmax(T1 &x, T2 y) { if (x < y) x = y; }
template <class T1, class T2> inline void chmin(T1 &x, T2 y) { if (x > y) x = y; }
inline int rd() { int x; cin >> x; return x; }
template <class T> inline void rd(T &x) { cin >> x; }
template <class T> inline void rd(vector <T> &vec) { for (auto &it : vec) cin >> it; }
template <class T> inline void out(T s) { cout << s << "\n"; }
template <class T> inline void out(vector <T> &vec) { for (auto &it : vec) cout << it << " "; cout << endl; } 
inline ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
inline ll qpow(ll base, ll n) { ll res = 1; while (n) { if (n & 1) res = res * base % mod; base = base * base % mod; n >>= 1; } return res; }
constexpr int N = 1e5 + 10;
int A, B; 
void run() {
	int now = 1, res = 0;
	while (now < B) {
		now += A - 1;
		++res;
	}
	cout << res << endl;
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr); cout.tie(nullptr);
	cout << fixed << setprecision(20);
	while (cin >> A >> B) run();
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<vs> vvs;
typedef vector<vc> vvc;
typedef vector<vb> vvb;
using P = pair<ll,ll>;
#define REP(i, n) for (ll i = 0; i < (int)(n); i++)
#define RREP(i, n) for (ll i = (int)(n)-1; i > -1 ; i--)
#define IN(T, x) T x;cin >> x;
#define AIN(T, a, n) vector<T> a(n);REP(i, n){cin >> a[i];}
#define A2IN(T1, a, T2, b, n) vector<T1> a(n);vector<T2> b(n);REP(i, n){cin >> a[i] >> b[i];}
#define ALL(a) (a).begin(),(a).end()
#define SORT(a) sort(ALL(a))
#define RSORT(a) SORT(a);reverse(ALL(a))
#define pb push_back
#define mp make_pair
#define PF first
#define PS second
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;}
template<typename A, size_t N, typename T>void Fill(A (&array)[N], const T &val){fill( (T*)array, (T*)(array+N), val );}
#define OUT(x) cout << x << endl
#define BOUT(b) if(b){OUT("Yes");}else{OUT("No");}
const ll MOD = 100000007;
const ll INF = 10e9;
#define PI 3.14159265369;
ll dx[4] = {1,-1,0,0};
ll dy[4] = {0,0,1,-1};
ll ddx[8] = {1,1,1,-1,-1,-1,0,0};
ll ddy[8] = {0,1,-1,0,1,-1,1,-1};


int main() {
  IN(ll,N);
  IN(string,S);
  ll count = 0;
  for(ll i = 0; i < N - 2;i++){
    if(S.at(i) == 'A' && S.at(i+1) == 'B' && S.at(i+2) == 'C'){
      count++;
    }
  }
  OUT(count);
}



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

using namespace std;
using ll = long long;
using PAIR = pair<int, int>;
using PAIRLL = pair<ll, ll>;
using vi = vector<int>;
using vvi = vector<vi>;

#define rep(i,N) for(int i=0;i<(int)N;++i)

ll GCD(ll x, ll y) {
    if (y == 0) return x;
    else return GCD(y, x % y);
}

ll LCM(ll x, ll y) {
    return x / GCD(x, y) * y;
}

bool my_compare(pair<string, int> a, pair<string, int> b) {
    if (a.first != b.first) {
        return a.first < b.first;
    }

    if (a.second != b.second) {
        return a.second > b.second;
    }
    else {
        return true;
    }
}

int main()
{
    int H, W;
    cin >> H >> W;
    vector<string> S(H+1);
    for (int i = 1; i <= H;++i) cin >> S[i];

    vector<vector<char> > A(H+2, vector<char>(W+2));
    vector<vector<string> > B(H+2, vector<string>(W+2));

    for (int i = 1; i <= H; ++i) {
        for (int j = 1; j <= W; ++j) {
            A[i][j] = S[i][j-1];
        }
    }

    for (int i = 0; i <= H+1; ++i) {
        for (int j = 0; j <= W+1; ++j) {
            B[i][j] = A[i][j];
        }
    }

    int x;

    for (int i = 1; i <= H; ++i) {
        for (int j = 1; j <= W; ++j) {
            x = 0;
            if (A[i][j] == '.') {
                if (A[i - 1][j - 1] == '#') { ++x; }
                if (A[i - 1][j + 1] == '#') { ++x; }
                if (A[i + 1][j - 1] == '#') { ++x; }
                if (A[i + 1][j + 1] == '#') { ++x; }
                if (A[i][j - 1] == '#') { ++x; }
                if (A[i][j + 1] == '#') { ++x; }
                if (A[i - 1][j] == '#') { ++x; }
                if (A[i + 1][j] == '#') { ++x; }
                B[i][j] = to_string(x);
            }
        }
    }

    for (int i = 1; i < H+1; ++i) {
        for (int j = 1; j < W+1; ++j) {
            cout << B[i][j];
        }
        cout << endl;
    }

}

Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

int main() {
	int H, W, D;
	cin >> H >> W >> D;
	vector<pair<int, int>> A(H * W + 1, { 0,0 });
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			int a;
			cin >> a;
			A[a] = { i,j };
		}
	}
	int Q;
	cin >> Q;
	vector<int> L(Q, 0);
	vector<int> R(Q, 0);
	for (int i = 0; i < Q; i++) cin >> L[i] >> R[i];

	vector<int> memo(H * W + 1, 0);
	for (int i = D + 1; i <= H * W; i++) {
		memo[i] = memo[i - D] + abs(A[i].first - A[i - D].first)
			+ abs(A[i].second - A[i - D].second);
	}

	for (int i = 0; i < Q; i++) cout << memo[R[i]] - memo[L[i]] << endl;
}


Measured memory_bytes: 2944
#include <iostream>
#include <cstdio>
#include <cmath>
#include <string>
#include <algorithm>
using namespace std;
int main() {
    bool ac = false;
	string s;
	std::cin >> s;
	for (int i = 0; i < s.size(); i++) {
	    if(s[i] == 'A' and s[i + 1] == 'C'){
	        std::cout << "Yes" << std::endl;
	        ac = true;
	        break;
	    }
	}
	if(ac == false){
	    std::cout << "No" << std::endl;
	}
	return 0;
}

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

const int MAX_N = 1e5;

int N;
int M;
int f[MAX_N+1];
bool is_f[MAX_N+1];
int ans;

int find(int x){return f[x]?f[x]=find(f[x]):x;}

void merge(int x,int y)
{
	int fx = find(x);
	int fy = find(y);
	if ( fx != fy )
		f[fx] = fy;
	return;
}

int main()
{
	scanf("%d%d",&N,&M);
	for ( int i = 0 ; i < M ; i++ )
	{
		int X,Y,Z;
		scanf("%d%d%d",&X,&Y,&Z);
		merge(X,Y);
	}
	for ( int i = 1 ; i <= N ; i++ )
		is_f[find(i)] = true;
	for ( int i = 1 ; i <= N ; i++ )
		ans += is_f[i];
	printf("%d",ans);
	printf("\n");
	return 0;
}

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

public class Main{
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String str;
		int num[] = new int[101];
		int value=0;

		while((str=br.readLine()) != null){
			num[Integer.parseInt(str)]++;
		}

		for(int i=1; i<=100; i++){
			if(num[i]>value){
				value = num[i];
			}
		}

		for(int i=1; i<=100; i++){
			if(num[i]==value){
				System.out.println(i);
			}
		}

	}
}

Measured memory_bytes: 17004
#include<iostream>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<climits>

#define REP(i,s,n) for(int i=s;i<n;i++)
#define rep(i,n) REP(i,0,n)
#define IINF (INT_MAX)
#define MAX 2010

using namespace std;

struct Data{
  string word;
  int value;
  Data(string word="X",int value=IINF):word(word),value(value){}
};

int dp[2][MAX];
Data input[MAX];
string line;

int main(){
  int N,CNT = 1;
  while(cin >> N,N){
    rep(i,N) cin >> input[i].word >> input[i].value;
    cin >> line;
    rep(i,2)rep(j,MAX)dp[i][j] = (i?IINF:-IINF);
    dp[0][0] = 0, dp[1][0] = 0;
    rep(i,(int)line.size())rep(j,N)if(dp[0][i] != -IINF && i+(int)input[j].word.size()<=(int)line.size() && input[j].word == line.substr(i,input[j].word.size()) ) dp[0][i+(int)input[j].word.size()] = max(dp[0][i+(int)input[j].word.size()],dp[0][i]+input[j].value);
    int max_cost = dp[0][line.size()];
    rep(i,max_cost+1)rep(j,N)if(dp[1][i] != IINF && i+input[j].value <= max_cost )dp[1][i+input[j].value] = min(dp[1][i+input[j].value],dp[1][i]+(int)input[j].word.size());
    cout << "Case " << CNT++ << ": " << dp[1][max_cost] << endl;
  }
  return 0;
}

Measured memory_bytes: 1384
#!/usr/bin/env python3
import sys
from collections import Counter
readline = sys.stdin.buffer.readline

N = int(readline())
A = list(map(int, readline().split()))
Q = int(readline())
d = Counter(A)

total = sum(A)

for _ in range(Q):
    B, C = map(int, readline().split())

    total -= B * d[B]
    total += C * d[B]

    d[C] += d[B]
    d[B] = 0

    print(total)


Measured memory_bytes: 24384
#include <stdio.h>
int main (void){
  int a = 0,b = 0;
  
  scanf("%d %d", &a, &b);
  
  if(a+b == 15){
    printf("+\n");
  }else if(a*b == 15){
    printf("*\n");
  }else{
    printf("x\n");
  }
  
  return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define MAX_N 1111
#define pb push_back
#define fi first
#define sc second
typedef pair<double,int> P;
int N;
double Xs,Ys,Xt,Yt;
double X[MAX_N],Y[MAX_N],R[MAX_N];
double cost[MAX_N][MAX_N];
double s[MAX_N];
double dis(int i,int j);
int main()
{
	cout.precision(22);cin.precision(22);
	//printf("long double : %d\n", sizeof(long double));
	cin >> Xs >> Ys >> Xt >> Yt;
	cin >> N;
	for(int i=0;i<N;i++){
		cin >> X[i] >> Y[i] >> R[i];
	}
	X[N]=Xs;Y[N]=Ys;R[N]=0;
	X[N+1]=Xt;Y[N+1]=Yt;R[N+1]=0;N+=2;
	for(int i=0;i<N;i++){
		for(int j=i+1;j<N;j++){
			cost[i][j]=dis(i,j);
			//cout << i << " " << j << " " << cost[i][j] << "\n";
			cost[j][i]=cost[i][j];
		}
	}
	for(int i=0;i<N;i++){
		s[i]=3000000000;
	}
	priority_queue<P,vector<P>,greater<P> >que;
	que.push(P(0,N-2));
	while(!que.empty()){
		P p=que.top();que.pop();
		if(s[p.sc]<=p.fi)continue;
		s[p.sc]=p.fi;
		for(int i=0;i<N;i++){
			if(p.fi+cost[p.sc][i]<s[i]){
				que.push(P(p.fi+cost[p.sc][i],i));
			}
		}
	}
	
	cout << s[N-1] << "\n";
	return 0;
}
double dis(int i,int j){
	double l=sqrt((Y[j]-Y[i])*(Y[j]-Y[i])+(X[j]-X[i])*(X[j]-X[i]));
	l-=(R[i]+R[j]);
	if(l<0)return 0;
	return l;
}

Measured memory_bytes: 17260
#!/usr/bin/env python3
import sys

YES = "Yes"  # type: str
NO = "No"  # type: str


def solve(S: str):
    for i in range(len(S)):
        if S[i] != S[len(S) - i-1]:
            print(NO)
            exit()

    for i in range(len(S)//2):
        if S[i] != S[len(S)//2 - i-1]:
            print(NO)
            exit()

    print(YES)
        
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    S = next(tokens)  # type: str
    solve(S)

if __name__ == '__main__':
    main()


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

using namespace std;


int main(){
	int a,b;
	cin>>a>>b;
	if(b>a){
	cout<<2*b-1;
	}
	else if(a==b){
		cout<<2*a;
	}
	else if(a>b){
		cout<<2*a-1;
	}
}

Measured memory_bytes: 3584
import numpy as np
N,W = map(int, input().split())

dp = np.full(N*1000+1, W+1, dtype=int)
dp[0] = 0

for _ in range(N):
  w,v = map(int, input().split())
  dp[v:] = np.minimum(dp[v:], dp[:-v]+w)
  
print(np.max(np.where(dp<=W)))

Measured memory_bytes: 14904
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
int n,cnt[15],x[15][15],y[15][15],ans;
void check(int w) {
	int num=0;
	for (int i=0; i<n; ++i)
		if (w>>i&1) {
			++num;
			for (int j=0;j<cnt[i];++j)
				if ((w>>x[i][j]&1)!=y[i][j]) return;
		}
	ans = max(ans,num);
}

int main() {
	scanf("%d",&n);
	for (int i=0; i<n; ++i) {
		scanf("%d",&cnt[i]);
		for (int j=0;j<cnt[i];++j)
            scanf("%d %d",&x[i][j],&y[i][j]),--x[i][j];
	}
	for (int i=1; i<1<<n; ++i) check(i);
	printf("%d", ans);
	return 0;
}

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

int main() {
  long long N;
  int M;
  vector<int> vec(M,0);
  cin >> N >> M;
  for (int i = 1;i < M+1; i++){
    cin >> vec.at(i);
  }
  int L = 0;
  for (int i = 1;i < M+1; i++){
    L += vec.at(i);
  }
  if (N > L-1){
    cout << N-L;
  }
  else{
    cout << -1;
  }
    
return 0;
}

Measured memory_bytes: 3720
K = int(input())
X, Y = map(int, input().split())

swap = False
if abs(X) < abs(Y) :
    swap = True
    X, Y = Y, X
    
signX, signY = 1, 1
if X < 0 : 
    signX = -1
    X = -X
if Y < 0 :
    signY = -1
    Y = -Y

def output(x, y) :
    if swap :
        print(y*signY, x*signX)
    else :
        print(x*signX, y*signY)

if K % 2 == 0 and (X + Y) % 2 == 1 :
    print(-1)
else :
    if K > X + Y and (X + Y) % 2 == 1 :
        print(3)
        output(X, -(K - X))
        output(X + (K + X - Y) // 2, -(K - X) + (K - X + Y) // 2)
        output(X, Y)
    else :
        if K > X + Y and (X + Y) % 2 == 0 :
            n = 2
        else :
            n = (X + Y + K - 1) // K
            if (X + Y) % 2 != n * K % 2 :
                n += 1
        print(n)
        a = (K*n-X-Y)//2//K
        b = (K*n+X-Y)//2//K
        x0 = K*(a+1)-(K*n-X-Y)//2
        y0 = K*(b+1)-X-(K*n-X-Y)
        for i in range(a) :
            output(0, -(i+1)*K)
        for i in range(b-a) :
            output(x0+i*K, -(K*n-X-Y)//2)
        for i in range(n-b) :
            output(X, y0 + i*K)

Measured memory_bytes: 53848
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;
  int ans=0;
  for(int i=2;i<32;i++){
    int t=i;
      while(i*t<=n){
        t*=i;
      }
    if(t>i){ans=max(ans,t);}
  }
  if(n==1){cout<<1;}
  else{cout<<ans;}
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll          long long int
#define pb          push_back
#define pll         pair<ll,ll>
#define pq          priority_queue
#define speed_up    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define mod         1000000007
#define inf         1000000000000000000LL
#define vl          vector<ll>
#define vll         vector<pll>
#define f           first
#define s           second
#define db          long double
#define sz(x)       (ll)x.size()
#define fix(n)      cout<<fixed<<setprecision(n)
#define rep(i,a,b)  for(ll i=a;i<b;i++)
#define all(x)      x.begin(),x.end()
#define mset(x)     memset(x,0,sizeof x)
#define pi          3.14159265358979323
ll v[100005],k,n;
//ll dp[100005];
ll c1(ll a, ll b)
{
    if(a%b==0) return (a/b)-1;
    else return (a/b);
}
bool check(ll m)
{   ll s=0;
    for(int i=1;i<n;i++)
        s+=c1(v[i]-v[i-1],m);
    return s<=k;
}
void solve()
{
 ll t,b,m;
 cin>>n>>m;
 cout<<(n*(n-1))/2 + (m*(m-1))/2;
 
}   

int main()
{
    speed_up
    ll T=1;
    //cin>>T;
    while(T--)
        solve();
    return 0;
}



Measured memory_bytes: 256
#include <algorithm>
#include <array>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#define REP(X, Y, Z) for (ll(X) = (Y); (X) < (Z); (X)++)
#define REV(X, Y, Z) for (ll(X) = (Y); (X) > (Z); (X)--)

using namespace std;
using ld = long double;
using ll = long long;
using dll = deque<ll>;
using pll = pair<ll, ll>;
using qll = queue<ll>;
using usll = unordered_set<ll>;
using umll = unordered_map<ll, ll>;
using sll = stack<int>;
using vll = vector<ll>;
using vvll = vector<vll>;

constexpr ll kMax = 1e12 + 1;
constexpr ll kMod = 1e9 + 7;
constexpr long double kPI = 3.14159265358979323846;

ll gcd(ll a, ll b) {
  if (a < b) {
    return gcd(b, a);
  }
  ll c = a % b;
  while (c != 0) {
    a = b;
    b = c;
    c = a % b;
  }
  return b;
}

ll lcm(ll a, ll b) {
  return a / gcd(a, b) * b;
}

void init() {
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
}

int main() {
  init();

  string S, T;
  cin >> S >> T;

  ll ans = 0;
  REP(i, 0, S.size()) {
    if (S[i] != T[i]) {
      ans++;
    }
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3800
#include<bits/stdc++.h>
using namespace std;
const int mod=1000000007;

int quickpow(int x,int y)
{
	long long res=1,base=x;
	while(y)
	{
		if(y&1) res*=base,res%=mod;
		y>>=1; base*=base,base%=mod;
	}
	return res;
}
int inv(int x){return quickpow(x,mod-2);}

int prod[1000001];
int iprod[1000001];
int c(int n,int m){return 1ll*prod[n]*iprod[n-m]%mod*iprod[m]%mod;}

int solve2(int n,int m,int s,int l,int r)
{
	if(s-1ll*m*r<0) return 0;
	s-=m*r;
	int ans=0;
	for(int i=0;i<=n-m&&s-i*l>=0;i++)
	{
		ans=ans+1ll*((i%2==0)?1:-1)*c(s-i*l+n,n)*c(n-m,i)%mod;
		ans%=mod;
	}
	return 1ll*(ans+mod)*c(n,m)%mod;
}

int solve(int n,int m,int s)
{
	int ans=c(s+n,n);
	for(int i=0;i<=s;i++)
		ans=(ans-solve2(n,m,s,i,i)+solve2(n,m,s,i,i+1))%mod;
	return 1ll*(ans+mod)%mod;
}
signed main()
{
	int n,m,l,r;
	scanf("%d%d%d%d",&n,&m,&l,&r);
	
	prod[0]=1,iprod[0]=1;
	for(int i=1;i<=1000000;i++)
	{
		prod[i]=1ll*prod[i-1]*i%mod;
		iprod[i]=inv(prod[i]);
	}
	printf("%d",(solve(n,m,r)-solve(n,m,l-1)+mod)%mod);
	return 0;
}


Measured memory_bytes: 8064
cards={}
%w[S H C D].each{|k| cards[k]=(1..13).to_a}
readlines[1..-1].each do |l|
  k,v=l.split(' ')
  cards[k]=cards[k]-[v.to_i]
end
%w[S H C D].each{|k| cards[k].each{|i| puts [k,i]*' '}}

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

int main(){
    while(true){
        string s;
        cin >> s;
        
        if(s == "-") break;
        
        int n;
        cin >> n;
        
        rep(i,n){
            int a;
            cin >> a;
            
            string w = s.substr(0,a);
            s += w;
            s.erase(0,a);
        }
        
        cout << s << endl;
    }
    
    
}


Measured memory_bytes: 3172
#include <bits/stdc++.h>
  
using namespace std;
  
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define repr(i, n) REPR(i, n, 0)
#define REPR(i, s, e) for(int i=(int)(s-1); i>=(int)(e); i--)
#define pb push_back
#define all(r) (r).begin(),(r).end()
#define rall(r) (r).rbegin(),(r).rend()
#define fi first
#define se second
  
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
 
const int INF = 1e9;
const ll MOD = 1e9 + 7;
double EPS = 1e-8;

template <typename T>
struct SegTree{
    vector<T> dat;
    int n;
    const T Default;
    SegTree(int n_, const T& def) : Default(def){init(n_);}
    void init(int n_){
        n = 1;
        while(n < n_) n *= 2;
        dat = vector<T>(2*n-1, Default);
    }
    T f(const T& a, const T& b) {
    	return min(a, b);
    }
    void update(int k, const T& a){
        k += n-1;
        dat[k] = a;
        while(k > 0){
            k = (k - 1) / 2;
            dat[k] = f(dat[k * 2 + 1], dat[k * 2 + 2]);
        }
    }
    T query(int a, int b, int k, int l, int r ){
        if(r <= a || b <= l) return Default;
        if(a <= l && r <= b) return dat[k];
        T vl = query(a, b, k * 2 + 1, l, (l + r) / 2);
        T vr = query(a, b, k * 2 + 2, (l + r) / 2, r);
        return f(vl, vr);
    }
    T query(int a, int b) {
    	return query(a, b, 0, 0, n);
    }
};

int main(){
#ifdef LOCAL_TEST
	freopen("in", "r", stdin);
	freopen("out", "w", stdout);
#endif
	ll n, x;
	cin >> n >> x;
	vl a(n);
	rep(i, n) cin >> a[i];
	SegTree<ll> st(n, 1e10);
	rep(i, n) st.update(i, a[i]);
	ll ans = 1e18;
	rep(k, n+1) {
		ll tmp = 0;
		rep(i, n) {
			if(i >= k){
				tmp += st.query(i - k, i+1);	
			}
			else {
				int dif = k - i;
				tmp += min(st.query(0, i+1), st.query(n-dif, n));
			}
		}
		ans = min(ans, tmp + x*k);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int solve(int, int);

int a[20];
int n;

int main()
{
  int i, q;
  int m[200];
  
  scanf("%d",&n);
  for( i=0 ; i<n ; i++ )
    scanf("%d",&a[i]);
  scanf("%d",&q);
  for( i=0 ; i<q ; i++ )
    scanf("%d",&m[i]);

  for( i=0 ; i<q ; i++ ){
    if(solve(0,m[i])) printf("yes\n");
    else printf("no\n");
  }

  return 0;
}

int solve(int i, int m)
{
  int res;
  if(m==0) return 1;
  if(i>=n) return 0;
  res = solve(i+1,m) || solve(i+1,m-a[i]);
  if(res) return 1;
  else return 0;
}

Measured memory_bytes: 580
from collections import defaultdict
N, = map(int, input().split())
X = list(map(int, input().split()))
d = defaultdict(int)
for x in X:
    d[x] += 1

r = 0
for i in range(10**6):
    r = max(r, d[i] + d[i-1] + d[i+1])
print(r)


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
using P = pair<ll, ll>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
#define ALL(obj) (obj).begin(), (obj).end()
#define MOD 1000000007
#define INF 100000000000

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

	ll A, B, Q;
	cin >> A >> B >> Q;

	vector<ll> s(A);
	vector<ll> t(B);
	vector<ll> x(Q);
	ll tmp;

	rep(i, A) {
		cin >> tmp;
		s[i] = tmp;
	}

	rep(i, B) {
		cin >> tmp;
		t[i] = tmp;
	}

	rep(i, Q) {
		cin >> tmp;
		x[i] = tmp;
	}

	ll vsu, vsd, vtu, vtd;
	ll ans;
	rep(i, Q) {
		auto su = upper_bound(s.begin(), s.end(), x[i]);
		if (su == s.end()) {
			vsu = INF;
			vsd = *s.rbegin();
		}
		else {
			vsu = *su;
			if (*su == *s.begin()) {
				vsd = -INF;
			}
			else {
				vsd = *(--su);
			}
		}

		auto tu = upper_bound(t.begin(), t.end(), x[i]);
		if (tu == t.end()) {
			vtu = INF;
			vtd = *t.rbegin();
		}
		else {
			vtu = *tu;
			if (*tu == *t.begin()) {
				vtd = -INF;
			}
			else {
				vtd = *(--tu);
			}
		}

		ans = min(abs(x[i] - vsu) + abs(vsu - vtu), abs(x[i] - vsu) + abs(vsu - vtd));
		ans = min(ans, abs(x[i] - vsd) + abs(vsd - vtu));
		ans = min(ans, abs(x[i] - vsd) + abs(vsd - vtd));
		ans = min(ans, abs(x[i] - vtu) + abs(vtu - vsu));
		ans = min(ans, abs(x[i] - vtu) + abs(vtu - vsd));
		ans = min(ans, abs(x[i] - vtd) + abs(vtd - vsu));
		ans = min(ans, abs(x[i] - vtd) + abs(vtd - vsd));

		cout << ans << "\n";
	}

	return 0;
}

Measured memory_bytes: 3712
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        String S;
        Scanner sc = new Scanner(System.in);
        S = sc.nextLine();
        int count = 0;
        for(int i  = 1 ; i < S.length() ; i++)
        {
            if(S.charAt(0) == S.charAt(i))
            {
                count++;
            }
        }
        System.out.println(count == 2 ? "No" : "Yes");
    }
}


Measured memory_bytes: 35564
N = int(input())
A = [int(i) for i in input().split()]

count = 0
all_even = True
while all_even:
    for i in range(N):
        if A[i] % 2 == 1:
            all_even = False
    if all_even == True:
        for i in range(N):
            A[i] = A[i] / 2
        count += 1

print(count)

Measured memory_bytes: 3060
N,M,C=map(int,input().split())
B=list(map(int,input().split()))
count=0
for i in range(N):
    A=list(map(int,input().split()))
    p=C
    for j in range(M):p+=A[j]*B[j]
    if p>0:count+=1
print(count)

Measured memory_bytes: 3060
#include <cstring>
#include <cassert>
#include <utility>
#include <iostream>
#include <cstdio>
#include <iomanip>
#include <bitset>
#include <chrono>
#include <cstdlib>
#include <functional>
#include <tuple>
#include <climits>
#include <limits>
#include <deque>
#include <list>
#include <array>
#include <stack>
#include <queue>
#include <random>
#include <complex>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define ll              long long
#define pi              pair<int,int>
#define pll             pair<ll,ll>
#define pb              push_back
#define F               first
#define S               second
#define vi              vector<int>
#define vll             vector<ll>
#define endl            '\n'
#define all(v)          (v).begin(),(v).end()
#define FOR(i,a,b)      for(int i=a;i<b;i++)
#define MP(a,b)         make_pair(a,b)
#define debug(x)        cerr<< #x << " : " << x << endl;
#define debugp(p)       cerr<< #p << " : " << "(" << (p).first << "," << (p).second << ")\n";
#define debugv(v)       cerr<< #v << " : " << "["; for(int i = 0; i < (v).size(); i++) cerr << v[i] << " "; cerr<<"]\n";
#define debugs(m)       cerr<< #m << " : [ "; for(auto itr = m.begin(); itr != m.end(); itr++) cerr <<*itr << " "; cerr << "]\n";
#define debugm(m)       cerr<< #m << " : [ "; for(auto itr = m.begin(); itr != m.end(); itr++) cerr <<"(" << itr->first << "," << itr->second << ") "; cerr << "]\n";

/* ordered set: 
tree<T, null_type,less<T>, rb_tree_tag,tree_order_statistics_node_update>
member functions :
1. order_of_key(k) : number of elements strictly lesser than k
2. find_by_order(k) : k-th element in the set
*/

inline ll modexp(ll x, ll ex , ll md) {
    ll ans = 1ll;
    while (ex > 0) {
        if (ex & 1ll) ans = (ans * x) % md;
        ex >>= 1ll;
        x = (x * x) % md;
    }
    return ans;
}

const int inf = 1e9 + 7;

void solve(){
    ll n , x , t; cin >> n >> x >> t;
    cout << ((n + x - 1) / x)  * t << endl;
}
int main(){
    ios :: sync_with_stdio(false); 
    cin.tie(nullptr); 
    cout.tie(nullptr);
    
    int T = 1;
    // cin >> T;
    for(int tc = 1; tc <= T; tc++){
        // cout << "Case #" << tc << ": ";
        solve();
    }
    #ifdef LOCAL
    cerr << "Time elapsed\t: " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";       
    #endif
}



Measured memory_bytes: 3644
#include<stdio.h>
#include<iostream>
using namespace std;
int bubbleSort(int A[],int N)
{
	int i,j,k,t;
	int num=0;
	for(i=0;i<N-1;i++)
	{
		for(j=N-1;j>=i+1;j--)
		{
			if(A[j]<A[j-1])
			{
				t=A[j];
				A[j]=A[j-1];
				A[j-1]=t;
				num++;
			}
		}
	}
	return num;
}
int main()
{
	int n;
	int a[102]={0};
	scanf("%d",&n);
	
	for(int i=0;i<n;i++) scanf("%d",&a[i]);
	
	int sum=bubbleSort(a,n);
	for(int i=0;i<n;i++) 
	{
		if(i) cout<<" ";
		cout<<a[i];
	}
	cout<<endl;
	cout<<sum<<endl;
	return 0;
} 


Measured memory_bytes: 3168
#include"bits/stdc++.h"
using namespace std;
#define REP(k,m,n) for(ll (k)=(m);(k)<(n);(k)++)
#define rep(i,n) REP((i),0,(n))
using ll=long long;

struct ModInt {
	static const ll MOD = 1000000007;

	// constructors etc
	ModInt() :num(1ll) {}
	ModInt(ll num_) :num(num_%MOD) {}
	ModInt(const ModInt& modint) :num(modint.num%MOD) {}
	ll get()const { return num; }

	// operator etc
	// operator ll() const { return num; }
	// ll operator*() { return num; }
	ModInt& operator+=(const ModInt& r) { (num += r.num) %= MOD; return *this; }
	ModInt& operator-=(const ModInt& r) { (num += -r.num + MOD) %= MOD; return *this; }
	ModInt& operator*=(const ModInt& r) { (num *= r.num) %= MOD; return *this; }
	ModInt& operator/=(const ModInt& r) { (num *= r.inv().num) %= MOD; return *this; }
	ModInt pow(const ModInt& r)const {
		ll res = 1;
		ll x = num;
		ll n = r.num;
		while (n > 0) {
			if (n & 1)res = (res*x) % MOD;
			x = (x*x) % MOD;
			n >>= 1;
		}
		return res;
	}
	ModInt inv()const { return this->pow(MOD - 2); }

	ModInt operator+(const ModInt& r)const { return ModInt(*this) += r; }
	ModInt operator-(const ModInt& r)const { return ModInt(*this) -= r; }
	ModInt operator*(const ModInt& r)const { return ModInt(*this) *= r; }
	ModInt operator/(const ModInt& r)const { return ModInt(*this) /= r; }
	ModInt operator+(const ll& r)const { return *this + ModInt(r); }
	ModInt operator-(const ll& r)const { return *this - ModInt(r); }
	ModInt operator*(const ll& r)const { return *this * ModInt(r); }
	ModInt operator/(const ll& r)const { return *this / ModInt(r); }

private:
	ll num;
};
ostream& operator<<(ostream& stream, const ModInt& val) { stream << val.get(); return stream; }


ll N;
vector<vector<int>> edges;
vector<int> childs,parents;
int count_childs(int now, int bef){
	for(auto next: edges[now])if(next!=bef){
		parents[next] = now;
		childs[now] += count_childs(next,now);
	}
	return childs[now]+=1;
}

int main()
{
	cin>>N;
	edges.resize(N);
	childs.resize(N,0);
	parents.resize(N,-1);
	rep(i,N-1){
		int a,b;
		cin>>a>>b;
		a--;b--;
		edges[a].push_back(b);
		edges[b].push_back(a);
	}
	count_childs(0, -1);
	/*
	for(auto num:childs)cout<<num<<" ";
	cout<<endl;
	for(auto num:parents)cout<<num<<" ";
	cout<<endl;
	*/

	ModInt res(0);
	rep(i, N){
		ModInt beta = ModInt(2).inv().pow(N-1);
		ModInt gamma(0);
		ll pars = N-1;
		for(auto next: edges[i])if(next!=parents[i]){
			ll z = childs[next];
			pars-=z;
			gamma += ModInt(2).inv().pow(N-1-z) * (ModInt(1) - ModInt(2).inv().pow(z));
		}
		if(pars!=0){
			gamma += ModInt(2).inv().pow(N-1-pars) * (ModInt(1)-ModInt(2).inv().pow(pars));
		}
		ModInt alpha = beta + gamma;
		res += ModInt(1) - alpha;
	}

	cout<<res/2<<endl;
	return 0;
}


Measured memory_bytes: 19456
#include <stdio.h>
#include <math.h>
#include <string.h>
int main() {
    char str[100];int n;scanf("%d\n",&n);scanf("%s",str);
    int i;
    if(strlen(str)<=n){
        printf("%s",str);return 0;
    }
    for(int i=0;i<n;i++)printf("%c",str[i]);
    printf("...");
    
}

Measured memory_bytes: 1728
#include <iostream>
#include <math.h>
#include <string>
#include <algorithm>
#include <set>
using namespace std;

int n,x;

int main(){
    while(true){
        cin>>n>>x;
        if(n==0&&x==0)break;
        int ans=0;
        for(int i=1;i<=n;i++){
            for(int j=i+1;j<=n;j++){
                for(int k=j+1;k<=n;k++){
                    if(i+j+k==x)ans++;
                }
            }
        }
        cout<<ans<<endl;
    }
    return 0;
}


Measured memory_bytes: 3080
#include <bits/stdc++.h>
using namespace std;
int main() {
     int N,M,X;
     cin >> N >> M >> X;
     int l = 0,r = 0;
     vector<int> A(M);
     for(int i = 0; i < M; i++){
          cin >> A[i];
          if(A[i] < X) l++;
          else r++;
     }
     cout << min(l,r) << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define z 500000000000000000
#define sh 500000

int main()
{

	
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	int n,i;
	cin>>n;
	int ar[n+1];
	for(i=1;i<=n;i++)
		cin>>ar[i];
	int dp[n+1];
	dp[1]=0;
	dp[2]=abs(ar[2]-ar[1]);
	for(i=3;i<=n;i++)
	{
		dp[i]=min(dp[i-1]+abs(ar[i]-ar[i-1]),dp[i-2]+abs(ar[i]-ar[i-2]));
	}
	cout<<dp[n];

}

Measured memory_bytes: 1024
#include<iostream>
#include<string>
using namespace std;
int main(){
	int ans=0;
	string T,W;
	cin>>W;
	for(;;){
		cin>>T;
		if(T=="END_OF_TEXT"){
			break;
		}
		for(int i=0;i<T.size();i++){
			if(isupper(T[i])){
				T[i]=tolower(T[i]);
			}
		}
		if(T==W){
			ans++;
		}

	}
	cout<<ans<<endl;

	return 0;
}


Measured memory_bytes: 3188
#include <stdio.h>

int solve() {
    int N, a[50], x[100], y[100], max_i=0;
    scanf("%d", &N);
    for (int i=0; i < N; i++) {
        scanf("%d", a+i);
        if (abs(a[i]) > abs(a[max_i])) max_i = i;
    }
    printf("%d\n", 2*N-2);
    for (int i=0; i < N; i++) {
        if (i == max_i) continue;
        printf("%d %d\n", max_i+1, i+1);
    }
    int diff = a[max_i] < 0 ? -1:1;
    int init = a[max_i] < 0 ? N:1;
    for (int i=0; i < N-1; i++){
        int x = init + diff*i, y = x + diff;
        printf("%d %d\n", x, y);
    }
}

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


Measured memory_bytes: 256
n = int(input())
t = list(map(int,input().split()))
s = sum(t)
m = int(input())
p = []
x = []
for i in range(m):
    pi,xi = map(int,input().split())
    p.append(pi)
    x.append(xi)

for i in range(m):
    print(s - t[p[i]-1] + x[i])

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

int main() {
    int A, B, C;
    cin >> A >> B >> C;
    map<int, int> m;
    m[A]++;
    m[B]++;
    m[C]++;
    bool flg = false;
    for (auto i = m.begin(); i != m.end(); i++) {
        if (i->second == 2) flg = true;
    }
    if (flg) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

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


int main(){
    string S;
    cin>>S;
    ll Keta=S.size();
    vector<ll> Alist(1, 0);
    vector<char> BC(0);
    ll BClength=0;
    for(ll i=0; i<Keta; i++){
        if(S.at(i)=='A'){
            Alist.at(BClength) ++;
            continue;
        }
        BC.push_back(S.at(i));
      	Alist.push_back(0);
        BClength ++;
    }
    BC.push_back('Z');
    vector<ll> Score(BClength+2, 0);
    for(ll i=BClength-1; i>=0; i--){
        if(BC.at(i)=='C'){
            Score.at(i)=0;
        }
        else{
            if(BC.at(i+1)=='C'){
              	if(Score.at(i+1)>0||Alist.at(i+1)==0){
                Score.at(i)=Score.at(i+2)+1;
                }
            }
        }
    }
    ll ASz=Alist.size();
    ll Ans=0;
    for(ll i=0; i<ASz; i++){
        Ans+=Score.at(i)*Alist.at(i);
    }
    cout<<Ans<<endl;
    return 0;
}

Measured memory_bytes: 4084
N = int(input())
As = list(map(int, input().split()))
 
sum_humidai = 0
max_front_person = 0
  
for person_idx, person_height in enumerate(As):
  
  if person_idx == 0:
    continue
    
  max_front_person = max(max_front_person, As[person_idx - 1])
  if max_front_person > person_height:
    humidai = max_front_person - person_height
    sum_humidai += humidai
 
print(sum_humidai)

Measured memory_bytes: 32088
import java.math.BigDecimal;
import java.util.Scanner;
class Main{
    public static void main(String args[]){
        Scanner scan = new Scanner(System.in);
        double a = scan.nextDouble();
        double b = scan.nextDouble();
        BigDecimal aa = BigDecimal.valueOf(a);
        BigDecimal bb = BigDecimal.valueOf(b);
        BigDecimal cc = aa.multiply(bb);
        BigDecimal sum = cc.setScale(0, BigDecimal.ROUND_DOWN);

        System.out.println(sum);
    }
}

Measured memory_bytes: 37628
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define FORR(i,a,b) for (int i=(a);i>=(b);i--)
#define pb push_back
#define pcnt __builtin_popcount
#define show(x) cout<<#x<<" = "<<x<<endl;
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define fi first
#define se second
#define rng(a) (a.begin()),(a.end())
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define sz(x) (int)(x).size()
#define mp make_pair

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
typedef set<int> si;
typedef pair<ll,ll> pll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<pll> vpll;
typedef set<ll> sl;
typedef __int128_t lll;
typedef pair<lll,lll> plll;
typedef vector<lll> vlll;
template<typename T>string join(vector<T>&v)
{stringstream s;FOR(i,0,sz(v))s<<' '<<v[i];return s.str().substr(1);}
ll gcd(ll a,ll b){if(a>b)swap(a,b);for(;a>0;b%=a,swap(a,b));return b;}
int modpow(ll a,ll n,int m){if(a==0)return a;ll p=1;for(;n>0;n/=2,a=a*a%m)if(n&1)p=p*a%m;return(int)p;}
void dout(double d){printf("%.12f\n",d);}

const int iinf = 1e9;
const ll linf = 1e18;
const int mod = 1e9+7;
const double pi = acos(-1);
const double eps = 1e-10;
int n, a, c[2];
map<int, int> m;

main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> n;
  FOR(i, 0, n){
    cin >> a;
    if(m.find(a) == m.end()) m[a] = 0;
    m[a]++;
  }
  each(itr, m) c[itr->se%2]++;
  if(c[0]%2) c[1]--;
  cout << c[0]+c[1] << endl;
  return 0;
}

Measured memory_bytes: 4992
import java.util.Scanner;
import java.util.Set;
import java.util.HashSet;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);

    int n = sc.nextInt();
    Set<String> keihin = new HashSet<String>();

    for (int i = 0; i < n; i++) {
      keihin.add(sc.next());
    }

    System.out.println(keihin.size());
  }
}


Measured memory_bytes: 66180
package main

import "fmt"

func main() {
	var s string
	fmt.Scan(&s)
	l := 0
	r := len(s) - 1
	ans := 0

	for r-l > 0 {
		if s[l] == s[r] {
			l++
			r--
		} else if s[l] == 'x' {
			ans++
			l++
		} else if s[r] == 'x' {
			ans++
			r--
		} else {
			ans = -1
			break
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 1280
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <queue>
#include <set>
#include <map>

using namespace std;
typedef long long ll;
int N, u, v;
const int N_MAX = 100000;
int A[100000], B[100000];
vector<int> G[100000];
bool used[100000];
bool leaf[100000];

int root;
const int N_LOG_MAX = 25;

int parent[N_LOG_MAX][N_MAX];
int depth[N_MAX];

void dfs(int v, int p, int d){
    parent[0][v] = p;
    depth[v] = d;
    for(int i = 0; i < G[v].size(); i++){
        if(G[v][i] != p) dfs(G[v][i], v, d+1); 
    }
}

void init(int V){
    dfs(root, -1, 0);
    for(int i = 0; i < N_LOG_MAX-1; i++){
        for(int v = 0; v < V; v++){
            if(parent[i][v] < 0) parent[i+1][v] = -1;
            else parent[i+1][v] = parent[i][parent[i][v]];
        }
    }
}

int lca(int u, int v){
    if(depth[u] > depth[v]) swap(u, v);
    for(int i = 0; i < N_LOG_MAX; i++){
        if((depth[v] - depth[u]) >> i & 1){
            v = parent[i][v];
        }
    }
    if(u == v) return u;
    for(int i = N_LOG_MAX-1; i >= 0; i--){
        if(parent[i][u] != parent[i][v]) {
            u = parent[i][u];
            v = parent[i][v];
        }
    }
    return parent[0][u];
}

void dfs(int v, int d){
    used[v] = true;
    depth[v] = d;
    for(int i = 0; i < G[v].size(); i++){
        if(!used[G[v][i]]){
            dfs(G[v][i], d+1);
        }
    }
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << setprecision(10) << fixed;
    cin >> N >> u >> v;
    u--; v--;
    for(int i = 0; i < N-1; i++){
        cin >> A[i] >> B[i];
        A[i]--; B[i]--;
        G[A[i]].push_back(B[i]);
        G[B[i]].push_back(A[i]);
    }
    for(int i = 0; i < N; i++){
        if(G[i].size() == 1) leaf[i] = true;
    }
    root = v;
    // dfs(v, 0);
    init(N);
    int ans;
    int cur = -1;
    for(int i = 0; i < N; i++){
        if(leaf[i]){
            int la = lca(u, i);
            if(depth[la] < depth[u]-depth[la]) continue;
            if(depth[la] == depth[u]-depth[la]) {
                // cout << i << endl;
                if(cur < depth[la]){
                    cur = depth[la];
                }
                continue;
            }
            if(i == u){
                int len;
                if(depth[i]%2 == 0){
                    len = depth[i]-1;
                }else{
                    len = depth[i]-1;
                }
                if(cur < len) cur = len;
                continue;
            }
            int len = depth[u]+depth[i]-2*depth[la];
            if(len%2 != depth[i]%2){
                if(cur < depth[i]-1){
                    cur = depth[i]-1;
                }
            }else{
                if(cur < depth[i]){
                    cur = depth[i]-1;
                }
            }
        }
    }
    cout << cur << endl;
}

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

const int MOD = 1000000007; 

// mod. m での a の逆元 a^{-1} を計算する
long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}


    // a を 10000000007 で割ってから b の逆元をかけて計算
   // a %= MOD;
 //   cout << a * modinv(b, MOD) % MOD << endl;

// a^n mod を計算する
long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

long long COM(long long n,long long k){
    long long C=1;
    for(int i=1; i<=k; i++){
      C=C*((n-i+1)*modinv(i, MOD) % MOD);
      C=C%MOD;
    }
    return C%MOD;
}

int main() {
  int n,a,b;cin>>n>>a>>b;
  int ans=modpow(2,n,MOD)-COM(n,a)-COM(n,b)-1;
  ans=ans%MOD;
  if(ans<0)ans+=MOD;
  cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    int a[200000];
    cin>>n;
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
    }
    sort(a,a+n);
    int x=unique(a,a+n)-a;
    if(x%2)
    {
        cout<<x;
    }
    else
    {
        cout<<x-1;
    }
    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
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; }

#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ for(auto it : P) { s << "<" << it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ for(auto it : P) { s << "<" << it.first << "->" << it.second << "> "; } return s << endl; }


template<class Monoid> struct SegTree {
    using Func = function<Monoid(Monoid, Monoid)>;
    const Func F;
    const Monoid UNITY;
    int SIZE_R;
    vector<Monoid> dat;
    
    SegTree(int n, const Func f, const Monoid &unity): F(f), UNITY(unity) { init(n); }
    void init(int n) {
        SIZE_R = 1;
        while (SIZE_R < n) SIZE_R *= 2;
        dat.assign(SIZE_R * 2, UNITY);
    }
    
    /* set, a is 0-indexed */
    void set(int a, const Monoid &v) { dat[a + SIZE_R] = v; }
    void build() {
        for (int k = SIZE_R - 1; k > 0; --k)
            dat[k] = F(dat[k*2], dat[k*2+1]);
    }
    
    /* update a, a is 0-indexed */
    void update(int a, const Monoid &v) {
        int k = a + SIZE_R;
        dat[k] = v;
        while (k >>= 1) dat[k] = F(dat[k*2], dat[k*2+1]);
    }
    
    /* get [a, b), a and b are 0-indexed */
    Monoid get(int a, int b) {
        Monoid vleft = UNITY, vright = UNITY;
        for (int left = a + SIZE_R, right = b + SIZE_R; left < right; left >>= 1, right >>= 1) {
            if (left & 1) vleft = F(vleft, dat[left++]);
            if (right & 1) vright = F(dat[--right], vright);
        }                                                                                                              
        return F(vleft, vright);
    }
    inline Monoid operator [] (int a) { return dat[a + SIZE_R]; }
    
    /* debug */
    void print() {
        for (int i = 0; i < SIZE_R; ++i) {
            cout << (*this)[i];
            if (i != SIZE_R-1) cout << ",";
        }
        cout << endl;
    }
};

int solve(int N, int K) {
    const int MAX = 510000;
    auto func = [&](int a, int b) { return max(a, b); };
    SegTree<int> seg(MAX, func, 0);
    for (int i = 0; i < N; ++i) {
        int a;
        cin >> a;
        int left = max(0, a - K);
        int right = min(MAX, a + K + 1);
        int val = seg.get(left, right);
        seg.update(a, val + 1);

        //seg.print(); COUT(val);
    }
    return seg.get(0, MAX);
}

int main() {
    int N, K;
    while (cin >> N >> K) cout << solve(N, K) << endl;
}

















Measured memory_bytes: 7484