akhauriyash/Code-Regression huggingface dataset:
import java.util.*;

class Main{
    public static void main(String args[]){
        Scanner sc=new Scanner(System.in);
        int n=sc.nextInt();
        int a[]=new int[n+1];
        int b[]=new int[n+1];
        int x[]=new int[n+1];
        for(int i=0;i<n+1;i++){
            a[i]=1;
            b[i]=0;
            x[i]=0;
        }
        int an=sc.nextInt();
        for(int i=0;i<an;i++){
            int q=sc.nextInt();
            a[q]=0;
        }
        int bn=sc.nextInt();
        for(int i=0;i<bn;i++){
            int q=sc.nextInt();
            b[q]=1;
        }
        int xn=sc.nextInt();
        for(int i=0;i<xn;i++){
            int q=sc.nextInt();
            x[q]=1;
        }
        int cnt=0;
        for(int i=1;i<n+1;i++){
            if(a[i]==1||b[i]==1){
                if(x[i]==1){
                    cnt++;
                }
            }
        }
        System.out.println(cnt);
    }
}


Measured memory_bytes: 26384
import sys
from heapq import heappush, heappop
#input = sys.stdin.readline

def main():
    n=int(input())
    h=list(map(int,input().split()))
    ans=0
    for i in range(1,n):
        if h[n-1-i]-h[n-i]>=2:
            ans=1
            break
        elif h[n-1-i]-h[n-i]==1:
            h[n-i-1]-=1
    if ans==1:
        print('No')
    else:
        print('Yes')

if __name__ == '__main__':
    main()

Measured memory_bytes: 14152
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, K;
  int A = 1;
  cin >> N >> K;
 
  for (int i = 0; i < N; i++) {
    if (A * 2 <= A + K) {
      A = 2 * A;
    }
    else {
      A = A + K;
    }
  }
  cout << A << endl;
}

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

char ary[2][60][110],cpy[110],cpx[110];
int main(){
	int N;
	cin>>N;
	for(int i=1;i<=N;i++){
		cin>>ary[0][i]>>ary[1][i];
	}
	int len,men,nowl,nowm,up,res;
	for(int i=1;i<=N;i++){
		if(strlen(ary[0][i])<strlen(ary[1][i])){
			strcpy(cpy,ary[1][i]);
			strcpy(cpx,ary[0][i]);
		}
		else{
			strcpy(cpy,ary[0][i]);
			strcpy(cpx,ary[1][i]);
		}
		len=strlen(cpy);nowl=len-1;
		men=strlen(cpx);nowm=men-1;
		up=res=0;
		for(int j=0;j<len;j++){
			if(nowm>=0)up+=(int)(cpy[nowl]-'0')+(int)(cpx[nowm]-'0');
			else up+=(int)(cpy[nowl]-'0');
			cpy[nowl]=(char)('0'+up%10);
			up/=10;nowl--;nowm--;
		}
		if(up+len>80) cout<<"overflow"<<endl;
		else if(!up)cout<<cpy<<endl;
		else cout<<"1"<<cpy<<endl;
	}
	return 0;
}

Measured memory_bytes: 3120
#include<iostream>
#include<vector>

using namespace std;

const int Nmax=1001;
const long long MOD=1000000007;

vector<long long> No_ways[Nmax];

long long find_ways(vector< vector<char> > &path_array,int H,int W){
    No_ways[0] = vector<long long>(Nmax);
    for(int i=1;i<=H;i++){
        No_ways[i]=vector<long long>(Nmax);
        for(int j=1;j<=W;j++){
            
            if(i==1 && j==1) No_ways[i][j]=1;
            else if(path_array[i][j] == '.') No_ways[i][j] = (No_ways[i-1][j] + No_ways[i][j-1])%MOD;
            
        }
       
    }
    return No_ways[H][W];
}

int main(){
    int H=0,W=0;cin>>H>>W;
    vector< vector<char> > path_array(H+1);

    for(int i=1;i<=H;i++){
        path_array[i]=vector<char>(W+1);
        for(int j=1;j<=W;j++)
            cin>>path_array[i][j];
    }
    cout << find_ways(path_array,H,W);
  return 0;
}

Measured memory_bytes: 9088
from math import factorial

N = int(input())
x = list(map(int, input().split()))
mod = 10**9 + 7
x_dis = [x[i+1] - x[i] for i in range(N-1)]
ans = 0
m = N-1
fac = factorial(m) % mod
tmp = fac
for i in range(m):
    ans += x_dis[i] * tmp
    ans %= mod
    tmp += (fac*pow((i+2),(mod-2), mod))%mod
print(ans)


Measured memory_bytes: 15020
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<functional>
#include<math.h>
using namespace std;
#define N (1000000000+7)
#define INF 1e16
typedef long long ll;
typedef pair<ll,ll> P;
 
template <typename T>
struct SegmentTree{
    typedef function<T(T,T)> F;
    int n;
    F f;
    T unit;
    vector<T> dat;
    SegmentTree(){};
    SegmentTree(int newn,F f,T t):f(f),unit(t){
        init(newn);
    }
    SegmentTree(const vector<T> &v,F f,T t):f(f),unit(t){
        int n_ = v.size();
        init(n_);
        for(int i=0;i<n_;i++)dat[n+i]=v[i];
        for(int i=n-1;i;i--){
            dat[i]=f(dat[(i<<1)|0],dat[(i<<1)|1]);
        }
    }
 
    void init(int n_){
        n=1;
        while(n<n_)n<<=1;
        dat.assign(n<<1,unit);
    }
    
    void update(int k,T x){
        dat[k+=n]=x;
        while(k>>=1)
            dat[k]=f(dat[(k<<1)|0],dat[(k<<1)|1]);
    }
    T query(int a,int b){
        T vl=unit,vr=unit;
        for(int l=a+n,r=b+n;l<r;l>>=1,r>>=1){
            if(l&1)vl=f(vl,dat[l++]);
            if(r&1)vr=f(dat[--r],vr);
        }
        return f(vl,vr);
    }
 
};
 
ll n,q;
SegmentTree<bool>seg[26];
 
int main(void){
    string s;
    cin>>n>>s>>q;
    auto f = [](bool l,bool r){return l|r;};
    for(int i=0;i<26;i++)seg[i] = SegmentTree<bool>(n,f,0);
    for(int i=0;i<s.length();i++){
        ll x = s[i]-'a';
        seg[x].update(i,1);
    }
    for(int i=0;i<q;i++){
        int t;
        cin>>t;
        if(t==1){
            ll index;
            char c;
            cin>>index>>c;
            ll x = c-'a';
            ll y = s[index-1]-'a';
            seg[y].update(index-1,0);
            seg[x].update(index-1,1);
            s[index-1]=c;
            //cout<<s<<endl;
        }
        else{
            ll l,r;
            cin>>l>>r;
            ll ans = 0;
            for(int i=0;i<26;i++){
                bool cnt = seg[i].query(l-1,r);
                if(cnt)ans++;
            }
            cout<<ans<<endl;
        }
    }
    return 0;
}

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

using ll = long long;
const int N = 53;
ll dp[N][2];

int main() {
	ios :: sync_with_stdio(0);
	int n, p; cin >> n >> p;
	dp[0][0] = 1;
	for(int i = 1; i <= n; i ++) {
		int x; cin >> x; x = x & 1;
		dp[i][0] = dp[i - 1][0] + dp[i - 1][x];
		dp[i][1] = dp[i - 1][1] + dp[i - 1][x ^ 1];
	}
	cout << dp[n][p] << '\n';
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
long long oll = 0;
#define ll long long
#define FIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define pb push_back
#define pii pair<int,int>
#define lcm(a,b) a*b/__gcd(a,b)
#define fl(i,a,b) for(ll i = a;i < b;i++)
#define lf(i,a,b) for(ll i = b;i >= a;i--)
#define MEM(x,y) memset(x,y,sizeof(x))
#define mp make_pair
#define bs(x,y) binary_search(x.begin(),x.end(),y)
#define nl "\n"
#define sp " ";
#define srt(x) sort(x.begin(),x.end())

void solve()
{
    ll x;
    cin>>x;
    fl(i,0,1000)fl(j,-1000,1000){
        if(pow(i,5)-pow(j,5) == x){
            cout<<i<<" "<<j<<nl;
            return;
        }
    }
}

int main()
{
    FIO;
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
    solve();
    return 0;
}


Measured memory_bytes: 4048
#include <bits/stdc++.h>
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) FOR(i, 0, n)
#define ll long long
using namespace std;

const ll P = 1000000007;
int gcd(int a, int b) { return b != 0 ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }

int main()
{
  cout << fixed << setprecision(10);
  int a,b,c,d;
  cin >> a >> b >> c >> d;
  if(abs(c-a)<=d)
  {
    cout << "Yes" << endl;
    return 0;
  }
  if(abs(c-b)<=d&&abs(b-a)<=d)
  {
    cout << "Yes" << endl;
    return 0;
  }
  cout << "No" << endl;
  return 0;
}


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

using namespace std;

#define pb push_back
#define mp make_pair
#define fst first
#define snd second
#define sz(X) (int)(X).size()
#define forn(i, n) for (int i = 0; i < int(n); i++)
#define fornr(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define forab(i, a, b) for(int i = int(a); i < int(b); i++)
#define forabr(i, a, b) for(int i = int(b)-1; i >= int(a); i--)
#define all(X) X.begin(), X.end()

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


int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    ll l, r;
    cin >> l >> r;
    if (r-l+1>=2019){
        cout << "0\n";
        return 0;
    }
    ll ans = 1e18;
    forab(i, l, r+1){
        forab(j, i+1, r+1){
            ans = min(ans, (i*1ll*j)%2019ll);
        }
    }
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 256
s=j=0
a=[];b=[];d=[]
for i,x in enumerate(input()):
    if x=='\\':a+=[i]
    elif x=='/' and a:
        j=a.pop()
        c=i-j;s+=c
        while b and b[-1]>j:c+=d.pop();b.pop()
        b+=[j];d+=[c]
print(s)
print(len(b),*(d))

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

using namespace std;

int a[1000];

int main(){
	int b;
	cin >> b;
	for (int i = 0;i < b;i++){
		cin >> a[i];
	}
	int min = 1000, max = -1000;
	for (int i = 0 ;i < b;i++){
		if(a[i] < min){
			min = a[i];
		}
		if(max < a[i]){
			max = a[i];
		}
	}
		cout << max - min;
	return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {

    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        char[] c = sc.next().toCharArray();

        int r = 0;
        for(int i=0; i<n; i++) {
            if(c[i] == 'R') {
                r++;
            }
        }
        int res = Math.min(r, n-r);
        int a = 0;
        for(int i=0; i<n; i++) {
            if(c[i] == 'R') {
                a++;
            }
            int w = (i+1) - a;
            int rr = r - a;
            if(rr >= w) {
                res = Math.min(res, rr);
            }
        }
        System.out.println(res);

    }




}

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

int main()
{
	int n, m;
	vector<int>	v1;
	cin >> n;
	for (int i = 0; i < n; i++)
	{
		cin >> m;
		v1.push_back(m);
	}
	int MIN=v1[0],ans=v1[1]-v1[0];
	for (int i = 2; v1.begin() + i != v1.end(); i++)	 
	{
		MIN = min(MIN, v1[i - 1]);
		ans=max(ans,v1[i] - MIN);
	}						  
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3848
N = int(input())
p = list(map(int,input().split()))
co_list = list(range(1,N+1))
cnt = 0

for i in range(N):
    if p[i] != co_list[i] :
        cnt += 1
if cnt > 2 :
    print('NO')
else :
    print('YES')

Measured memory_bytes: 3060
import numpy as np
MOD = 10**9+7
N = int(input())
A = list(map(int, input().split()))
A = np.array(A)

ans = 0
twopow = 1
for n in range(60):
    tmp = A & 1
    one = np.count_nonzero(tmp)
    zero = N - one
    ans = (ans + (one * zero) * twopow) % MOD
    A >>= 1
    twopow = twopow << 1 % MOD

print(ans)

Measured memory_bytes: 50024
#include<bits/stdc++.h>
#define ll long long int
#define ld long double
#define pi pair<int,int>
#define all(x) x.begin(), x.end()
#define allr(x) x.rbegin(), x.rend()
#define sz(x) ((int)x.size())
#define ln(x) ((int)x.length())
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define endl '\n'
#define dbg(x) cout<<#x<<" "<<x<<endl
#define clr(x,v) memset(x, v, sizeof(x))
#define FASTIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
const double eps = 1e-9;
const double PI = acos(-1.0);
const ll mod = 1e9 + 7;
const int MAXN = 5e5 + 5;
ll fact[MAXN];
void init()
{
    fact[0] = 1;
    for(int i = 1; i < MAXN; i++)
        fact[i] = (i % mod * fact[i - 1] % mod) % mod;
}

ll fpow(ll x, ll y)
{
    ll res = 1;
    while(y > 0)
    {
        if(y & 1)
            res = (res % mod * x % mod) % mod;
        x = (x % mod * x % mod) % mod;
        y = y / 2;
    }
    return res;
}

ll inv(ll a)
{
    return fpow(a, mod - 2) % mod;
}

ll ncr(ll n, ll r)
{
    ll ans = fact[n];
    ans = (ans * inv(fact[n - r])) % mod;
    ans = (ans * inv(fact[r])) % mod;
    return ans % mod;
}

void cp()
{
    ll n, m;
    cin >> n >> m;
    ll ans = 0;
    ll sg;
    for(int i = 0; i <= n; i++)
    {
        sg = (i % 2 ? -1 : 1);
        ll p = ncr(n, i);
        ll q = (fact[m] % mod * inv(fact[m - i]) % mod) % mod;
        ll r = ncr(m - i, n - i);
        ll s = fact[n - i];

        ll t = (r % mod * s % mod) % mod;
        t = fpow(t, 2) % mod;

        ll here = (p % mod * q % mod) % mod;
        here = (here % mod * t % mod) % mod;
        here *= sg;
        ans = (ans + here + mod) % mod;
    }
    cout << ans % mod;
}

int main()
{
    FASTIO;
    int t;
    t = 1;
    // cin >> t;
    init();
    while(t--)
    {
        cp();
    }
    return 0;
}

Measured memory_bytes: 7552
#include <bits/stdc++.h>
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
using namespace std;
using ll = long long;
using ld = long double;

const double PI=acos(-1);

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

  cout << 2*R*PI << endl;

  return 0;
}

Measured memory_bytes: 3800
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
const long long INF = 1001001001;
const long long MOD = 1000000007;
const double EPS = 1e-10;

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

    int h,w,m;
    cin>>h>>w>>m;
    map<P,int> mp;
    P r[h],c[w];
    for(int i=0;i<h;i++)r[i]=P(0,i);
    for(int j=0;j<w;j++)c[j]=P(0,j);
    for(int i=0,a,b;i<m;i++){
        cin>>a>>b;
        a--,b--;
        mp[P(a,b)]++;
        r[a].first++;
        c[b].first++;
    }
    sort(c,c+w,greater<P>());
    int ans=0;
    for(int i=0;i<h;i++){
        int res=r[i].first;
        int t=0;
        for(int j=0;j<w;j++){
            if(mp[P(i,c[j].second)]){
                t=max(t,c[j].first-1);
            }else{
                t=max(t,c[j].first);
                break;
            }
            if(c[j].first<t)break;
        }
        ans=max(ans,res+t);
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 45812
#include <algorithm>
#include <climits>
#include <iostream>
#include <string>
#include <utility>
#include<vector>
#include<iomanip>
#include<map>
#include <queue>
#include<cmath>
#include<cstdio>
#include<iomanip>
#include<set>
#include <bits/stdc++.h>
 
using namespace std;
using ll = long long int;
 
#define REP(i,n) for(ll i=0;i<(ll)(n);i++) //REP(i, 5) cout<<i;
#define REPD(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define MOD 1000000007 //10^9+7
//#define MOD 1
 
ll gcd(ll a, ll b) {
  ll tmp;
  if ( b > a) {
    tmp = a;
    a = b;
    b = tmp;
  }
  while (a % b !=0) {
    tmp = b;
    b = a % b;
    a = tmp;
  }
  return b;
}
 
const int MAX = 2000;

long long fac[MAX], finv[MAX], inv[MAX];
 
// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}


void sosuu(ll n, vector<ll> &v){

  vector<ll> num(n, 0);

  FOR(i, 1, sqrt(n)){
    if(num[i]==0){
      FOR(j, 0, n/i){
        num[i+(j*i)] = 1;
      }
    }
  }
  REP(i, n){
    if(num[i]==0) v.push_back(i+1);
  }
}

ll GetDigit(ll num){
    ll digit=0;
    while(num!=0){
        num /= 10;
        digit++;
    }
    return digit;
}


int main(void){

  ll h, w;
  cin>>h>>w;

  ll s_x, s_y;
  ll g_x, g_y;

  s_x = 0;
  s_y = 0;
  g_x = h-1;
  g_y = w-1;

  ll count = 0;

  ll v[h][w];

  REP(i, h){
    REP(j, w){
      char x;
      cin>>x;
      if(x == '.') v[i][j] = 0;
      else{
         v[i][j] = 1;
         count++;
      }
    }
  }

  queue<pair<ll, ll>> q;
  q.push(make_pair(0, 0));
  ll d[4][2] = {{0, 1}, {0, -1}, {1, 0}, {-1, 0}};

  ll visit[h][w];
  REP(i, h){
    REP(j, w){
      visit[i][j] = 0;
    }
  }
  v[s_x][s_y] = 1;

  while(q.size() != 0){
    pair<ll, ll> now = q.front();
    q.pop();
    s_x = now.first;
    s_y = now.second;

    //cout<<s_x<<", "<<s_y<<endl;

    if(s_x == g_x && s_y ==g_y){
      cout<<h*w-count-visit[s_x][s_y]-1<<endl;
      return 0;
    }

    for(int i=0;i<4;i++){
      ll nx = s_x + d[i][0];
      ll ny = s_y + d[i][1];
      if(0<=nx && 0<=ny && nx<h && ny<w && v[nx][ny] == 0 && visit[nx][ny]==0){
        q.push(make_pair(nx, ny));
        visit[nx][ny] = visit[s_x][s_y] + 1;
      }
    }
  }

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

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



using namespace std;

int main(){
  
  string s;
  cin >> s;
  if ( s.at(0) == 'R' && s.at(1) == 'R' && s.at(2) == 'R'){
    cout << "3" << endl;
  }else if( s.at(0) == 'R' && s.at(1) == 'R'){
    cout << "2" << endl;
  }else if(s.at(1) == 'R' && s.at(2) == 'R'){
    cout << "2" << endl;
  }else if(s.at(0) == 'R' || s.at(1) == 'R' || s.at(2) == 'R'){
    cout << "1" << endl;
  }else{
    cout << "0" << endl;
  }
 
}



Measured memory_bytes: 3624
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include<iostream>
#include<fstream>
#include<iomanip>
#include<cstdio>
#include<string>
#include<cstring>
#include<climits>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<deque>
#include<tuple>
#include<list>
#include<unordered_map>
#include<unordered_set>
#include<random>
#include<functional>
#define ll long long
#define ull unsigned long long
#define pii pair<int,int>
#define pp pair<pair<ll, ll>,pair<ll, ll>>
#define pll pair<ll,ll>
#define pdd pair<double,double>
#define vii vector<int>
#define vll vector<ll>
#define mat vector<vector<ll>>
#define lb lower_bound
#define pb push_back
#define mp make_pair
#define fi first
#define sc second
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=a;i<b;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define LB(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define UB(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
#define ERASE(v) v.erase(unique(v.begin(),v.end()),v.end())
// #define int ll
using namespace std;
const ll INF = (1 << 30 ) - 1;
const ll LLINF = (1LL << 60LL);
const ll MOD = 1000000007;
const ll mod = 998244353;
const ll MAX = 1100000;
const double pi = acos(-1);
const double eps = 1e-10;
ll dx[4] ={1,0,-1,0} , dy[4] ={0,1,0,-1};


signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    ll a[10];
    cin>>a[0]>>a[1]>>a[2];
    sort(a,a+3);
    if(a[0]==5&&a[1]==5&&a[2]==7) cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
    return 0;
}

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

using namespace std;
#define int long long
int MOD = 1000000007;

signed main(){
    int N;
    cin >> N;
    int a[111];
    map<int,int> mp;
    for(int i=0;i<N;i++){
        cin >> a[i];
        mp[a[i]]++;
    }
    
    int change = 0;
    for(int i=0;i<N;i++){
        if(mp[a[i]]==0){
            change = a[i];
            break;
        }
    }
    
    int cnt = 0;
    for(int i=1;i<N;i++){
        if(a[i-1]==a[i]){
            a[i] = change;
            cnt++;
        }
    }
    
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;
typedef long long ll;

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

    if(n % 2 == 0){
        printf("%.10f\n", (n/2.0)/n);
    }else{
        printf("%.10f\n", ((n-1)/2.0 +1.0)/n);
    }

}

Measured memory_bytes: 256
from collections import defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue,copy,time
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())

N,K = inpl()
print(sum([1 if h >= K else 0 for h in inpl()]))


Measured memory_bytes: 12904
# -*- coding: utf-8 -*-
n = int(input())
d = {}
for x in input().split(" "):
    x = int(x)
    if x not in d:
        d[x] = 0
    d[x] += 1
# print(d)

if n%2==0 and 0 in d:
    print(0)
    exit()
if n%2==1 and d[0]!=1:
    print(0)
    exit()

for k,v in d.items():
    if k==0:
        continue
    if v!=2:
        print(0)
        exit()

if 0 in d:
    del d[0]
m = len(d)
MOD = 10**9 + 7

ret = 1
for _ in range(m):
    ret = (ret*2)%MOD
print(ret)


Measured memory_bytes: 16228
while True:
    a,op,b = input().split()
    a = int(a)
    b = int(b)
    if op == "+":
        print(a+b)
    elif op == "-":
        print(a-b)
    elif op == "*":
        print(a*b)
    elif op == "/":
        print(int(a/b))
    else:
        break


Measured memory_bytes: 5596
import java.util.Arrays;
import java.util.Scanner;

public class Main {

    public static void main(String args[]) {

        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        Integer[] d = new Integer[n];
        for (int i = 0; i < n; i++) {
            d[i] = sc.nextInt();
        }

        Arrays.sort(d);
        int start = d[d.length / 2 - 1];
        int end = d[d.length / 2];
        int result = 0;
        if (start != end) {
            result = end - start;
        }

        System.out.println(result);
    }
}


Measured memory_bytes: 61500
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while(sc.hasNext()) {
			double a = sc.nextDouble(), sum = a;
			for(int i=1;i<10;i++) { a = (i%2==1? a*2: a/3 ); sum += a; }
			System.out.println(sum);
		}
	}
}

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

const int64_t MOD = 1e9+7;
vector<int64_t> f(100010, 1);
vector<int64_t> invf(100010, 1);

//---------- べき乗 ----------
int64_t power(int64_t a, int64_t n){
    if(n == 0) return 1;
    
    int64_t res = 1;
    while(n > 0){
        if(n % 2 == 1) res = res * a % MOD;
        a = a * a % MOD;
        n /= 2;
    }

    return res;
}

//---------- 逆元 ----------
int64_t inv(int64_t a){
    return power(a, MOD-2);
}

//---------- 階乗 ----------
vector<int64_t> factorial(int64_t n){
    vector<int64_t> res(n+1);

    res[0] = 1; 
    for(int i=1; i<=n; i++) res[i] = i * res[i-1] % MOD;

    return res; // nまでの階乗の配列を返す
}


//--------- 組み合わせ ---------
int64_t comb(int64_t n, int64_t r){
    return (f[n] * invf[r] % MOD) * invf[n-r] % MOD;
}

 
int main(){
  int N,  K;
  vector<int64_t> A(100010, 1);

  cin >> N >> K;
  for(int i=0; i<N; i++) cin >> A[i];
  sort(A.begin(), A.begin()+N, greater<int64_t>());

  
  f = factorial(N);
  for(int i=0; i<=N; i++) invf[i] = inv(f[i]);

  int64_t ans1 = 0, ans2 = 0;
  for(int i=0; i<=N-K; i++){
    int64_t M = (MOD+A[i]) % MOD;
    int64_t m = (MOD+A[N-i-1]) % MOD;
    int64_t C = comb(N-1-i, K-1);
    ans1 = ((M * C) % MOD + ans1) % MOD;
    ans2 = ((m * C) % MOD + ans2) % MOD; 
  }

  cout << (ans1 - ans2 + MOD) % MOD << endl;
}

Measured memory_bytes: 3328
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<long long> vll;
typedef pair<int,int> pint;
typedef pair<long long, long long> pll;

#define MP make_pair
#define PB push_back
#define ALL(s) (s).begin(),(s).end()
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << 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; }
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 << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P) 
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }



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



int T;
int ix, iy;
string fi[8];

void dfs(int x, int y) {
    fi[x][y] = '0';
    for (int i = 0; i < 4; ++i) {
        for (int j = 1; j <= 3; ++j) {
            int nx = x + dx[i] * j;
            int ny = y + dy[i] * j;
            if (nx < 0 || nx >= 8 || ny < 0 || ny >= 8) continue;
            if (fi[nx][ny] == '0') continue;
            dfs(nx, ny);
        }
    }
}

int main() {
    cin >> T;
    for (int id = 0; id < T; ++id) {
        for (int i = 0; i < 8; ++i) cin >> fi[i];
        cin >> iy >> ix;
        --ix; --iy;
        dfs(ix, iy);
        
        cout << "Data " << id+1 << ":" << endl;
        for (int i = 0; i < 8; ++i) cout << fi[i] << endl;
    }
    
    return 0;
}


Measured memory_bytes: 1208
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
struct Edge
{
	int to;
	int nxt;
}e[200005];
int n,m,edgenum,head[100005],c[100005],ans[100005],pa[100005];
void add(int u,int v)
{
	e[++edgenum].to=v;
	e[edgenum].nxt=head[u];
	head[u]=edgenum;
}
int ind=0;
void dfs(int node)
{
	ans[node]=c[++ind];
	for(int hd=head[node];hd;hd=e[hd].nxt)
	{
		int to=e[hd].to;
		if(to==pa[node])continue;
		pa[to]=node;
		dfs(to);
	}
}
bool cmp(int a,int b)
{
	return a>b;
}
int main()
{
	scanf("%d",&n);
	for(int i=1;i<n;i++)
	{
		int u,v;
		scanf("%d%d",&u,&v);
		add(u,v);
		add(v,u);
	}
	for(int i=1;i<=n;i++)scanf("%d",&c[i]);
	sort(c+1,c+n+1,cmp);
	int sum=0;
	for(int i=2;i<=n;i++)sum+=c[i];
	printf("%d\n",sum);
	dfs(1);
	for(int i=1;i<=n;i++)printf("%d ",ans[i]);
	printf("\n");
	return 0;
}

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

typedef long long int ll;
ll powk(ll a, ll n = 2){
    ll r = 1;
    for(ll i = 0;i < n;i++){
        r *= a;
    }

    return r;
}

int main()
{
    string s;
    cin >> s;
    vector<ll> r(s.size()), l(s.size());

    ll cnt;
    cnt = 0;
    for(ll i = 0;i < s.size();i++){
        if(s[i] == 'R'){
            cnt++;
        }
        else{
            if(cnt != 0){
                if(cnt % 2 == 0){
                    r[i] = r[i - 1] = cnt / 2;
                }
                else{
                    r[i] = cnt / 2;
                    r[i - 1] = cnt / 2 + 1;
                }
            }
            cnt = 0;
        }
    }
    cnt = 0;
    for(ll i = s.size() - 1;i >= 0;i--){
        if(s[i] == 'L'){
            cnt++;
        }
        else{
            if(cnt != 0){
                if(cnt % 2 == 0){
                    l[i] = l[i + 1] = cnt / 2;
                }
                else{
                    l[i] = cnt / 2;
                    l[i + 1] = cnt / 2 + 1;
                }
            }
            cnt = 0;
        }
    }

    for(ll i = 0;i < s.size();i++){
        cout << r[i] + l[i] << " ";
    }
    
    return 0;
}

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

#define rep(i, n) for(int i = 0; i < (n); i++)
#define repp(i, l, r) for(int i = (l); i < (r); i++)
#define per(i, n) for(int i = ((n)-1); i >= 0; i--)
#define perr(i, l, r) for(int i = ((r)-1); i >= (l); i--)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007
#define IINF 1000000000
#define LINF 1000000000000000000
#define SP <<" "<<
#define CYES cout<<"Yes"<<endl
#define CNO cout<<"No"<<endl
#define CCYES cout<<"Yay!"<<endl
#define CCNO cout<<":("<<endl
#define CFS cin.tie(0);ios::sync_with_stdio(false)

typedef long long LL;
typedef long double LD;

int main(){
  int n;
  cin >> n;
  int xa,ya,za;
  cin >> xa >> ya >> za;
  int xb,yb,zb;
  cin >> xb >> yb >> zb;
  LL m=5100*5100;
  vector<LL> v(m);
  rep(i,m){
    v[i]=i;
    if(xa>xb&&xb<=i){
      v[i]=max(v[i],v[i-xb]+xa);
    }
    if(ya>yb&&yb<=i){
      v[i]=max(v[i],v[i-yb]+ya);
    }
    if(za>zb&&zb<=i){
      v[i]=max(v[i],v[i-zb]+za);
    }
  }
  LL ans=0;
  vector<LL> w(n+1);
  rep(i,n+1){
    w[i]=i;
    if(xb>xa&&xa<=i){
      w[i]=max(w[i],w[i-xa]+xb);
    }
    if(yb>ya&&ya<=i){
      w[i]=max(w[i],w[i-ya]+yb);
    }
    if(zb>za&&za<=i){
      w[i]=max(w[i],w[i-za]+zb);
    }
    ans=max(ans,v[w[i]+n-i]);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 203520
import Control.Applicative

solver :: (Ord a) => a -> a -> String
solver a b
  | a < b    = "a < b"
  | a > b    = "a > b"
  |otherwise = "a == b"


main :: IO()
main = do
  (a:b:_) <- map (read :: String -> Int) . words <$> getLine
  putStrLn $ solver a b

Measured memory_bytes: 3572
//Author - Rahil Malhotra
#include <bits/stdc++.h>
using namespace std;
 
template <typename T> void print(T t) { cout<<t<<endl; }
template<typename T, typename... Args> void print(T t, Args... args) { cout<<t<<" "; print(args...); }
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl '\n'
#define int long long
#define double long double
 
int n,k;
int mod=1000000007;
struct Matrix 
{
    int arr[101][101]={};
    void iden() {
        for(int i=0;i<101;i++)
            arr[i][i]=1;
    }
};
 
Matrix mp;
Matrix multiply(Matrix res1,Matrix res2) {
    Matrix final;
    for(int i=0;i<n;i++)
        for(int j=0;j<n;j++)
            for(int k=0;k<n;k++) {
                final.arr[i][j]+=(res1.arr[i][k]*res2.arr[k][j])%mod;
                final.arr[i][j]%=mod;
            }
    return final;
}
Matrix power(int y) { 
    Matrix res;
    res.iden();
    while (y > 0) { 
        if((y & 1)==1)
            res=multiply(res,mp);
        y = y >> 1;  
        mp=multiply(mp,mp);
    } 
    return res; 
} 
int32_t main() {
    IOS;
    cin>>n>>k;
    for(int i=0;i<n;i++) {
        for(int j=0;j<n;j++) {
            cin>>mp.arr[i][j];
        }
    }
    Matrix fin = power(k);
    int sum=0;
    for(int i=0;i<n;i++) {
        for(int j=0;j<n;j++) {
            sum+=fin.arr[i][j];
        }
    }
    cout<<sum%mod;
}   

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

using namespace std;

class Vector {
    public:
        double x, y;

        Vector(double x = 0.0, double y = 0.0) : x(x), y(y) {}

        Vector operator -(Vector v) { return Vector(x - v.x, y - v.y); }

        double abs() { return sqrt(x * x + y * y); }
};

double heron(double a, double b, double c) {
    double s = (a + b + c) / 2;
    return sqrt(s * (s - a) * (s - b) * (s - c));
}

int main() {
    vector<Vector> v(20);
    int n;
    double x, y;
    for (n = 0; scanf("%lf,%lf", &x, &y) != EOF; n++)
        v[n] = Vector(x, y);
    
    double ans = 0;
    for (int i = 1; i + 1 < n; i++) {
        double a = (v[i] - v[0]).abs(),
               b = (v[i + 1] - v[0]).abs(),
               c = (v[i + 1] - v[i]).abs();
        ans += heron(a, b, c);
    }

    printf("%.10f\n", ans);

    return 0;
}


Measured memory_bytes: 3136
#include <numeric>
#include<iostream>
#include<set>
#include<queue>
#include<vector>
#include<map>
#include<stack>
#include<algorithm>
#include <sstream>
#include<string.h>
#include <cmath>
#include <iomanip>
using namespace std;
#define inf 1000000007
#define int long long
#define rep(i,j,n) for(int i=j;i<n;++i)
typedef pair<int,int>  P;
struct edge{int from,to,cost;};
double pi = 3.141592653589793;
//使うやつはここから下に置こうな
signed main(){
    int n,m;
    cin>>n>>m;
    if(n==1&&m==1)cout<<1<<endl;
    else if(n==1)cout<<m-2<<endl;
    else if(m==1)cout<<n-2<<endl;
    else if(n>=3&&m>=3){
        cout<<(n-2)*(m-2)<<endl;
    }else cout<<0<<endl;
    return 0;
}


Measured memory_bytes: 256
//周期性で殴る
#include <iostream>
#include <algorithm>
#include <functional>
#define int long long
using namespace std;

int n;
int a[50];

signed main() {
	int i, j;
	
	cin >> n;
	for (i = 0; i < n; i++) cin >> a[i];
	sort(a, a + n, greater<int>());
	
	//for (int k = 0; k < n; k++) cout << a[k] << " "; cout << endl;
	
	int ans = 0;
	for (i = 0; i < n - 1; i++) {
		int cnt = min(a[i] / (n - i), (a[i] - a[i + 1]) / (n + 1));
		for (j = 0; j <= i; j++) {
			a[j] -= (n - i) * cnt;
			ans += cnt;
		}
		for (j = i + 1; j < n; j++) {
			a[j] += (i + 1) * cnt;
		}
	}
	sort(a, a + n, greater<int>());
	
	//cout << ans << endl;
	//for (int k = 0; k < n; k++) cout << a[k] << " "; cout << endl;
	
	
	int cnt = max(0LL, a[n - 1] - (n - 1));
	for (i = 0; i < n; i++) {
		a[i] -= cnt;
		ans += cnt;
	}
	
	//cout << ans << endl;
	//for (int k = 0; k < n; k++) cout << a[k] << " "; cout << endl;
	
	
	//最後にシミュレーション
	while (true) {
		sort(a, a + n, greater<int>());
		if (a[0] <= n - 1) { break; }
		ans++;
		a[0] -= n;
		for (i = 1; i < n; i++) a[i]++;
	}
	
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
N,A,B = map(int,input().split())
ans = 0

for i in range(1, N+1):
    r = (i - i % 10000)
    s = (i - i % 1000)
    t = (i - i % 100)
    u = (i - i % 10)
    v = i % 10

    u = (u - t) / 10    
    t = (t - s) / 100
    s = (s - r) / 1000
    r = r / 10000
    
    if A <= s+t+u+v+r and r+s+t+u+v <= B:
        ans += i
    
print(ans)


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

// Template Headers {{{
using pii = pair<int, int>; using vpii = vector<pii>;
using vi = vector<int>; using vvi = vector<vi>;
using ll = long long; using vll = vector<long long>;
template <class T> using min_queue = priority_queue<T, vector<T>, greater<T>>;
template <class T> istream &operator>>(istream &, vector<T> &);
template <class T> ostream &operator<<(ostream &, const vector<T> &);
template <class T, class U> istream &operator>>(istream &, pair<T, U> &);
template <class T, class U> ostream &operator<<(ostream &, const pair<T, U> &);
template <class T> struct Inf { static constexpr T inf() { return std::numeric_limits<T>::has_infinity ? std::numeric_limits<T>::infinity() : std::numeric_limits<T>::max(); } };
template <> struct Inf<int> { static constexpr int inf() { return 0x3f3f3f3f; } };
template <> struct Inf<long long> { static constexpr long long inf() { return 0x3f3f3f3f3f3f3f3fLL; } };
constexpr int INF = Inf<int>::inf(); constexpr ll BINF = Inf<ll>::inf();
// mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
// }}}

int solve() {
	int n, k; cin >> n >> k;
	vi hasSnack(n);
	for (int i = 0; i < k; i++) {
		int d; cin >> d;
		for (int j = 0; j < d; j++) {
			int u; cin >> u; u--;
			hasSnack[u] = 1;
		}
	}
	cout << n - accumulate(hasSnack.begin(), hasSnack.end(), 0) << endl;
	return 0;
}

// Template Main {{{
int main() {
	ios::sync_with_stdio(0); cin.tie(0);
	// precompute();
	// int t; cin >> t; for (int i=1;i<=t;i++)
	solve();
	// cout << "Case #" << i << ": ", solve();
	return 0;
}

template <class T> istream &operator>>(istream &is, vector<T> &v) {
	for (auto it=v.begin();it!=v.end();++it) is >> *it;
	return is;
}

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
	for (auto it=v.begin();it!=v.end();) os << *it, os << " \n"[++it==v.end()];
	return os;
}

template <class T, class U> istream &operator>>(istream &is, pair<T, U> &p) {
	return is >> p.first >> p.second;
}

template <class T, class U> ostream &operator<<(ostream &os, const pair<T, U> &p) {
	return os << p.first << ' ' << p.second;
}
// }}}

// vim: fdm=marker


Measured memory_bytes: 3656
#include<bits/stdc++.h>
using namespace std;
bool month(int n){
    if(1<=n&&n<=12){return true;}
    else{return false;}
}
int main(){
  int n,a,b;
  cin>>n;
  a=n/100;
  b=n%100;
  if(month(a)&&month(b)){cout<<"AMBIGUOUS";}
  else if(month(a)&&!month(b)){cout<<"MMYY";}
  else if(month(a)&&b==0){cout<<"MMYY";}
  else if(!month(a)&&month(b)){cout<<"YYMM";}
  else if(month(b)&&a==0){cout<<"YYMM";}
  else{cout<<"NA";}
}


Measured memory_bytes: 256
#include<cstdio>
#include<cmath>
#include<vector>
#include<string>
#include<algorithm>

using namespace std;

int main()
{
	int lmax = 0;
	int n;
	int len = -1, cur = -1;
	int i;
	int input;

	scanf("%d", &n);

	for (i = 0; i < n; i++)
	{
		scanf("%d", &input);

		if (input > cur)
		{
			len = 0;
		}

		else
		{
			len++;
		}

		cur = input;

		if (len > lmax)
		{
			lmax = len;
		}
	}

	printf("%d\n", lmax);

	return 0;
}

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

int main() {
	string s;
	cin >> s;
	int cnt = 0;
	if (s[0] == 'o') cnt++;
	if (s[1] == 'o') cnt++;
	if (s[2] == 'o') cnt++;
	cout << 700 + cnt * 100 << endl;
	return 0;
}

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

typedef long long ll;
typedef long double ld;

#define X first
#define Y second
#define all(x) x.begin(), x.end()

using namespace std;

inline int tmin(int a, int b, int c){
    b = min(a, b);
    c = min(b, c);
    return c;
}

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

    ll k, n;
    cin >> k >> n;
    k * 500 >= n ? cout << "Yes" : cout << "No";
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <regex>
#include <numeric>
using namespace std;

/*--- Macro ---*/
#define rep(i, n) for(int i=0; i<(int)n; i++)
#define rep1(i, n) for(int i=1; i<(int)n; i++)
#define mp make_pair
#define pb push_back
#define all(a) a.begin(), a.end()

/*---  Type ---*/
typedef long long ll;

/*--- Constants ---*/
template <typename T> const T INF = numeric_limits<T>::max() / 10;
const int MOD = (int)1e9 + 7;

// Floating
const double EPS = 1e-11;
#define EQ0(x) (abs(x) < EPS)
#define EQ(x, y) (abs(a-b) < EPS)

// Util
int max(int a, int b, int c) {return max(a, max(b, c));}
int min(int a, int b, int c) {return min(a, min(b, c));}
ll max(ll x, ll y) {return x > y ? x : y;}
ll min(ll x, ll y) {return x < y ? x : y;}
ll max(ll a, ll b, ll c) {return max(a, max(b, c));}
ll min(ll a, ll b, ll c) {return min(a, min(b, c));}

// -------------------------------------------------------------------------------------



int main() {
  int n;
  cin >> n;
  vector<int> a1(n), a2(n);
  int _sum = 0;
  rep(i, n) {
    int ai;
    cin >> ai;
    _sum += ai;
    a1[i] = _sum;
  }
  _sum = 0;
  rep(i, n) {
    int ai;
    cin >> ai;
    _sum += ai;
    a2[i] = _sum;
  }

  int ans = a1[0] + a2[n-1];
  rep1(i, n) {
    ans = max(ans, a1[i] + a2[n-1] - a2[i-1]);
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;
using System.Text;

namespace Program
{
    public class ABC126A
    {
        static public void Main(string[] args)
        {
            var N = NextInt;
            var K = NextInt;
            var S = NextString.ToArray();

            S[K - 1] = (char)((int)S[K - 1] - ((int)'A' - (int)'a'));

            Console.WriteLine(new string(S));
        }

        static class Console_
        {
            private static Queue<string> param = new Queue<string>();
            public static string NextString()
            {
                if (param.Count == 0) foreach (var item in Console.ReadLine().Split(' ')) param.Enqueue(item);
                return param.Dequeue();
            }
        }
        static int NextInt => int.Parse(Console_.NextString());
        static long NextLong => long.Parse(Console_.NextString());
        static string NextString => Console_.NextString();

        static IEnumerable<long> Prime(long x)
        {
            if (x < 2) yield break;
            yield return 2;
            var halfx = x / 2;
            var table = new bool[halfx + 1];
            var max = (long)(Math.Sqrt(x) / 2);
            for (long i = 1; i <= max; ++i)
            {
                if (table[i]) continue;
                var add = 2 * i + 1;
                yield return add;
                for (long j = 2 * i * (i + 1); j <= halfx; j += add) table[j] = true;
            }
            for (long i = max + 1; i <= halfx; ++i) if (!table[i]) yield return 2 * i + 1;
        }
        static IEnumerable<long> Divisor(long x)
        {
            if (x < 1) yield break;
            var max = (long)Math.Sqrt(x);
            for (long i = 1; i < max; ++i)
            {
                if (x % i != 0) continue;
                yield return i;
                if (i != x / i) yield return x / i;
            }
        }
        static long GCD(long a, long b)
        {
            long tmpa = a, tmpb = b;
            while (tmpb > 0) { var tmp = tmpb; tmpb = tmpa % tmpb; tmpa = tmp; }
            return tmpa;
        }
    }
}


Measured memory_bytes: 13396
from collections import deque

h, w = map(int, input().split())
cm = [[0 for j in range(w + 2)] for i in range(h + 2)]
que = deque([])
for i in range(1, h + 1):
    s = input()
    for j in range(1, w + 1):
        if s[j - 1] == ".":
            cm[i][j] = -1
        else:
            que.append(i)
            que.append(j)
ans = 0
while len(que) > 0:
    y = que.popleft()
    x = que.popleft()
    ans = cm[y][x] + 1
    if cm[y + 1][x] == -1:
        cm[y + 1][x] = ans
        que.append(y + 1)
        que.append(x)
    if cm[y - 1][x] == -1:
        cm[y - 1][x] = ans
        que.append(y - 1)
        que.append(x)
    if cm[y][x + 1] == -1:
        cm[y][x + 1] = ans
        que.append(y)
        que.append(x + 1)
    if cm[y][x - 1] == -1:
        cm[y][x - 1] = ans
        que.append(y)
        que.append(x - 1)
print(ans - 1)

Measured memory_bytes: 102108
import collections
n = int(input())
P = list(map(int,input().split()))
P.sort()
c = collections.Counter(P)
p = 0
ans = 0
for i in c:
    r = c[i]
    if r % 2 == 0:
        p += 1
    else:
        ans += 1
p = (p // 2) * 2
print(p + ans)

Measured memory_bytes: 18656
#include <bits/stdc++.h>
 
using namespace std;
 
#define rep(i, n) for(int i = 0; i < (int)(n); ++i)
#define repr(i, n) for(int i = n;i >= 0; --i)
#define all(x) (x).begin(),(x).end()
#define PI 3.141592653589793
#define MOD 1000000007
 
typedef long long ll;
 

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

    int w,a,b,tmp;
    cin >> w >> a >> b;
    tmp = min(a,b);
    if(a == tmp){
        if(a <= b && b <= a+w){
            cout << 0 << endl;
        }
        else{
            cout << b - (a + w) << endl;
        }
    }
    else{
        if(b <= a && a <= b+w){
            cout << 0 << endl;
        }
        else{
            cout << a - (b + w) << endl;
        }
    }

	return 0;
}

Measured memory_bytes: 256
from collections import Counter
n=int(input())
s=[sorted([_ for _ in input()]) for i in range(n)]
alpha=[100000000]*26
a="abcdefghijklmnopqrstuvwxyz"
for i in range(n):
    for j in range(26):
        alpha[j]=min(s[i].count(a[j]),alpha[j])
ans=""
for i in range(26):
    ans+=a[i]*alpha[i]
print(ans)

Measured memory_bytes: 39536
//ABC154_B.I miss you...
//与えられた文字列Sの全ての文字をxで置き換えて出力するプログラム
//Sは英小文字のみからなる１以上100以下の文字列

//入力
//*S

#include <stdio.h>
#include <string.h>

int main(){
    
    char S[110];
    //SとSの長さを取得
    scanf("%s",S);
    int len;
    len = strlen( S );
    
    //printf("%s\n",S);
    
    for( int i=0; i<len; i++ ){
        S[i] = 'x';
    }
    
    printf("%s\n",S);
    return 0;
    
}


Measured memory_bytes: 128
#include<stdio.h>
#include<algorithm>
using namespace std;
char map[15][15],moji[15];
void func(int ,int);
int main(void){
	int i,j;
	while(1){
		for(i=0;i<12;i++){
			if(scanf("%s",map[i])==EOF){
				return 0;
			}
		}
		/*for(i=0;i<=12;i++){
			printf("%s",map[i]);
		}
		printf("\n");*/
		int cnt=0;
		for(i=0;i<12;i++){
			for(j=0;j<12;j++){
				if(map[i][j]=='1'){
					map[i][j]=0;
					func(i,j);
					cnt++;
				}
			}
		}
		printf("%d\n",cnt);
	}
}
void func(int y,int x){
	int i,j;
	int xx,yy;
	int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
	for(i=0;i<4;i++){
		xx=x+dx[i]; 
		yy=y+dy[i];
		if(map[yy][xx]=='1' && xx<=12 && xx>=0 && yy<=12 && yy>=0){
			map[yy][xx]=0;
			func(yy,xx);
		}
	}
}

Measured memory_bytes: 976
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		solver();

	}

	static void solver() {
		Scanner sc = new Scanner(System.in);
		while (sc.hasNext()) {
			char[] c = sc.next().toCharArray();
			int n = c.length;
			if (n == 1 && c[0] == '0')
				return;
			int[] sum = new int[n + 1];
			int[] cnt = new int[11];
			sum[0] = 0;
			cnt[0]++;
			for (int i = 0; i < n; i++) {
				if (i % 2 == 0) {
					sum[i + 1] = sum[i] - (c[i] - '0');
					sum[i + 1] = (sum[i + 1] + 11) % 11;
				} else {
					sum[i + 1] = sum[i] + (c[i] - '0');
					sum[i + 1] = (sum[i + 1] + 11) % 11;
				}
				cnt[sum[i + 1]]++;
			}
			int ans = 0;
			for (int i = 0; i < n; i++) {
				cnt[sum[i]]--;
				if (c[i] - '0' != 0) {
					ans += cnt[sum[i]];
				}
			}
			System.out.println(ans);
		}
	}
	static void tr(Object...o){System.out.println(Arrays.deepToString(o));}
}

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

bool isin[2030] = {0};

int main() {
    int N; cin >> N;
    vector<int> X(N);
    for (int i = 0; i < N; ++i) {
        cin >> X[i];
        isin[X[i]] = true;
    }
    int M; cin >> M;
    for (int i = 0; i < M; ++i) {
        int a; cin >> a; --a;
        if (isin[X[a]+1] || X[a]+1 > 2019) continue;
        int p = X[a];
        X[a]++;
        isin[p] = false;
        isin[p+1] = true;
    }
    for (int i = 0; i < N; ++i) cout << X[i] << endl;
}



Measured memory_bytes: 3116
printn = lambda x: print(x,end='')
inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      map(int, input().split())
ins = lambda : input().strip()
DBG = True # and False
BIG = 10**18
R = 10**9 + 7

def ddprint(x):
  if DBG:
    print(x)

n = inn()
a = inl()
h = {}
for x in a:
    if x not in h:
        h[x] = 0
    h[x] += 1
tot = 0
for x in h:
    tot += h[x]*(h[x]-1)//2
for i in range(n):
    y = h[a[i]]
    print(tot-y*(y-1)//2+(y-1)*(y-2)//2)


Measured memory_bytes: 87756
/*
    *   |.-|-..|..|-.--|---|--.|..|...|....|..|...-|.-| 
    */
#include<bits/stdc++.h>
 
using namespace std;
 
int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(NULL);
    
  	int m,d,count = 0,d1,d2;
  	cin >> m >> d;
  	if(d >= 22){
  		for(int i = 22;i <= d;i++){
          	d1 = i%10;
          	d2 = i/10;
        	if(d1 >= 2 && (d1*d2) <= m && (d1*d2) > 0){
            	count++;
            }
        }	
      	cout << count << "\n";
    }else{
    	cout << "0\n";
    }
	return 0;
}

Measured memory_bytes: 256