akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <cmath>
#include <string>
#include <algorithm>
using namespace std;
#define mp  std::make_pair
#define ll long long int
#define abs(n) ((n>0)?(n):((n)*(-1)))
#define CEIL(a,b) (((a) + ((b)-1)) / (b))
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n) FOR(i,0,(n)-1)
#define VREP_ll(v) for(std::vector<ll>::iterator itr = (v).begin(); itr != (v).end();itr++)
#define VREP_int(v) for(std::vector<int>::iterator itr = (v).begin(); itr != (v).end();itr++)
#define VALL(v) ((v).begin(),(v).end())
#define errln(v) cerr << (v) << endl;
#define println(v) cout << (v) << endl;

int main(int argc, const char * argv[]) {
	int a, b, c;
	cin >> a >> b >> c;
	if(b/a > c){println(c);}
	else{println(b/a);}
	return 0;
}


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

int n;
double prob[3001];
double dp[3001][3001];
bool vis[3001][3001];

double f(int c, int h){
    if(c==0 and h<0) return 0;
    if(c==0 and h==0) return 1.0;
    if(c<0) return 0.0;
    
    if(vis[c][h]) return dp[c][h];
    
    dp[c][h] = (double)prob[c]*f(c-1,h-1)+(double)(1-prob[c])*f(c-1,h);
    vis[c][h] = true;
    
    return dp[c][h];
}


int main(){
    memset(dp,-1,sizeof(dp));
    cin>>n;
    prob[0]=0;
    for(int i=1;i<=n;i++){
        cin>>prob[i];
    }
    double ans = 0.0;
    for(int i=n/2+1;i<=n;i++){
        ans = ans + f(n,i); 
    }
    
    cout<< fixed <<setprecision(20)<<ans;
}


Measured memory_bytes: 79616
#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 TR ","
#define fi first
#define se second
#define rep(i,N) for(int i=0;i<(int)N;++i)
#define IO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)

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

ll lcm(ll x, ll y) {
    return x / gcd(x, y) * y;
}

ll waz = 76543217;

ll inv(ll x) {
    if (x == 1) { return 1; }
    if (x == 0) { return 0; }
    else {
        ll a = (waz - inv(waz % x) * (waz / x)) % waz;
        if (a >= 0) { return a; }
        else { return waz + a; }
    }
}

void printVector(const vector<int>& vec) {
    for (int value : vec) {
        cout << value << " ";
    }
    cout << endl;
}

vector<ll> p;

ll phi(ll x) {
    ll a = x;
    ll b = x;
    for (ll k = 0; k != p.size(); ++k) {
        if (a % p[k] == 0) {
            while (a % p[k] == 0) {
                a /= p[k];
            }
            b = b / p[k] * (p[k] - 1);
        }
        if (a == 1) { break; }
    }
    return b;
}

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()
{
    IO;

    int N, M; cin >> N >> M;
    vector<int> q(M);
    vector<string> S(M);
    vector<pair<int, int> > AW(N);

    rep(i, N) AW[i] = make_pair(0, 0);

    rep(i, M) {
        cin >> q[i] >> S[i];
        if (S[i] == "AC") { ++AW[q[i] - 1].first;}
        else if (AW[q[i]-1].first==0 && S[i]=="WA") { ++AW[q[i]-1].second; }
    }

    int y = 0, z = 0;

    rep(i, N) {
        if (AW[i].first > 0) {
            y += 1;
            z += AW[i].second;
        }
    }

    cout << y << " " << z << endl;

    

}

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

int main() {
  int N, NK, S=0;
  cin >> N;
  NK = N;
  while(N != 0) {
    S += N%10;
    N /= 10;
  }

  if(!(NK%S)) {
    cout << "Yes" << "\n";
  }
  else {
    cout << "No" << "\n";
  }

  return 0;
}


Measured memory_bytes: 256
import sys

n=int(input())
A=list(map(int,input().split()))
now=1
s=sum(A)
ans=1
if n==0:
    if A[0]!=1:
        print(-1)
    else:
        print(1)
    sys.exit()
if A[0]!=0:
    print(-1)
    sys.exit()
for i in range(1,n+1):  
    if A[i]>2*now:
        print(-1)
        sys.exit()
    if s>=2*now:
        ans+=2*now
        now=2*now-A[i]
        
    else:
        ans+=s
        now=s-A[i]
    s-=A[i]
print(ans)

Measured memory_bytes: 20076
#include <iostream>
#include <vector>
#include <algorithm>
#include <climits>
using namespace std;
using ll = long long;

ll N, num, A, B, C, res = LLONG_MAX;
vector<ll> vec;

#define REP(i, N) for(ll i = 0; i < N; ++i)

ll recursion(ll i, ll a, ll b, ll c, ll cost) {
    // 終端処理
    if (i == N) {
        // 一つでも 0 があったらMAXを出力．
        if (!a || !b || !c) return LLONG_MAX;
        else return abs(a - A) + abs(b - B) + abs(c - C) + cost;
    }
    
    // 現在の竹 vec[i] を使用しない場合
    // 竹を合成しないままインデックスを進める．当然合成コストは 0．
    ll ret0 = recursion(i+1, a, b, c, cost);
    
    // vec[i] を A, B, C どれに使うか割り当てる
    // 0 のときは合成コストは 0 を表す
    // それぞれの分岐で min が帰ってくる
    ll ret1 = recursion(i + 1, a + vec[i], b, c, cost + ((a == 0) ? 0 : 10));
    ll ret2 = recursion(i + 1, a, b + vec[i], c, cost + ((b == 0) ? 0 : 10));
    ll ret3 = recursion(i + 1, a, b, c + vec[i], cost + ((c == 0) ? 0 : 10));
    
    return min({ret0, ret1, ret2, ret3});
}

int main() {
    // input
    cin >> N >> A >> B >> C;
    // REP(i, N) {
    //     cin >> num;
    //     vec.push_back(num);
    // }
    // 以下の受け取り方の方がスマート
    vec.resize(N);
    for(ll  i = 0; i < N; i++) cin >> vec[i];
    
    // calculation
    cout << recursion(0, 0, 0, 0, 0) << "\n";
    
    return 0;
}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline

n = int(input())

task_list = []
ab = [tuple(map(int,input().split())) for i in range(n)]

ab = sorted(ab, key=lambda x: x[1])

time = 0
for a,b in ab:
    time += a
    if time > b:
        print('No')
        exit()

print('Yes')

Measured memory_bytes: 33392
//#include <bits/stdc++.h>
#include <vector>
#include <iostream>
using namespace std;
const int MAX=100;

int main(){
    int N,ans=0;
    int d[MAX];
    int num[MAX+1]={0};
    cin>>N;
    for(int i=0;i<N;i++){
        scanf("%d",&d[i]);
        num[d[i]]++;
    }
    for(int i=1;i<=MAX;i++){
        if(num[i]!=0){
            ans++;
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include<stdio.h>
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include <stack>
#include <queue>
#include <deque>     
#include<map>
#include <set>
#include<math.h>
using namespace std;
#define int long long
#define ll long long
#define ld long double
#define rep(i,n) for(ll i=0;i<n;++i)
#define Rep(i,n) for(ll i=1;i<=n;++i)
#define loop(i,m,n) for(ll i=m;i<n;++i)
#define rev(i,n) for(ll i=n-1;i>=0;--i)
#define ggr getchar(); getchar();return 0;
#define pie 3.141592653589793238462643383279
#define elif else if
#define P pair<ll,ll>
#define prique priority_queue<ll>
#define all(a)  (a).begin(),(a).end()
const int mod = 1000000007;
const int mod2 = 998244353;
int bin(int bina) {
	int ans = 0;
	for (int i = 0; bina > 0; i++)
	{
		ans = ans + (bina % 2) * pow(10, i);
		bina = bina / 2;
	}
	return ans;
}
bool prime(int n) {
	for (ll i = 2; i <= sqrt(n); i++) {
		if (n % i == 0)return false;
	}
	return n != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x * y / gcd(x, y);
}
int kai(int x, int y) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= i; res %= mod;
	}
	return res;
}
int mod_pow(int x, int y, int m) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x,y)* mod_pow(kai(y,y), mod - 2, mod) % mod;
}
int per(int n, int r) {
	r = n - r;
	int sum = 1;
	int i;
	for (i = n; i >= r + 1; i--)sum *= i;
	return sum;
}
struct UnionFind {
	vector<int> par;

	UnionFind(int n) : par(n, -1) { }

	int root(int x) {
		if (par[x] < 0) return x;
		else return par[x] = root(par[x]);
	}

	bool issame(int x, int y) {
		return root(x) == root(y);
	}

	bool merge(int x, int y) {
		x = root(x); y = root(y);
		if (x == y) return false;
		if (par[x] > par[y]) swap(x, y);
		par[x] += par[y];
		par[y] = x;
		return true;
	}

	int size(int x) {
		return -par[root(x)];
	}
};
//cout << fixed << setprecision(10) << num << endl;

signed main() {
	int n,k;
	cin >> n>>k;
	string s;
	cin >> s;
	int sum = 0;
	loop(i, 1, n) {
		if (s[i] == 'L' && s[i - 1] == 'R') {
			sum += 2;
		}
	}
	if (s[0] == 'L')sum++;
	if (s[n - 1] == 'R')sum++;
	if (sum <= k * 2) {
		cout << n - 1 << endl;
	}
	else {
		cout << n - (sum - 2 * k) << endl;
	}
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define FAST std::ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define endl '\n'
#define pb push_back
#define mod 1000000007
#define fr(i,n) for(int i=0;i<n;i++)
#define int long long int
signed main() 
{
    FAST
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    int n;
    cin>>n;
    std::vector<double> v(n);
    fr(i,n) cin>>v[i];
    std::vector<std::vector<double> > a;
    std::vector<double> row(n,0);
    fr(i,n+1) a.pb(row);

    a[0][0]=(1-v[0]);

    for(int i=1;i<n;i++)
    a[0][i]=(1-v[i])*a[0][i-1];


    for(int i=1;i<=n;i++)
    {
        double x=1;
        fr(j,i) x*=v[j];
        a[i][i-1]=x;

        for(int j=i;j<n;j++)
        {
            a[i][j]=a[i-1][j-1]*v[j]+a[i][j-1]*(1-v[j]);
        }
    }

    double answer=0;

    int level=n/2+1;
    for(int i=level;i<=n;i++)
    {
        answer+=a[i][n-1];
    }

    // fr(i,n+1)
    //     {fr(j,n)
    //         cout<<a[i][j]<<" ";
    //         cout<<endl;}

    cout<<setprecision(10)<<answer;

    // 0.58 0.5742 0.333036 0.00333036 0.00193161 
    // 0.42 0.4216 0.423126 0.422225   0.418036 
    // 0 0.0042    0.179508 0.281828   0.340795 
    // 0 0         0.001764 0.177731   0.280787 
    // 0 0         0        0.00174636 0.0756597 
    // 0 0 0 0                         0.000733471


    return 0;
}

Measured memory_bytes: 70784
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
  string s;cin >> s;
  ll n = s.size(),i,b = 0,ans = 0;
  for(i=0;i<n;i++){
    if(s[i]=='B') b++;
    else ans += b;
  }
  cout << ans << "\n";
}

Measured memory_bytes: 3704
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main(){
    int h,w,d;
    cin >> h >> w >> d;
    int a[h][w];
    vector<pair<int,int>> p(h*w); 
    rep(i,h)rep(j,w){
        cin >> a[i][j];
        a[i][j]--;
        p[a[i][j]] = make_pair(i,j);
    }
    vector<vector<int>> k(d);
    for(int i=0;i<d;i++){
        int j = i,cur=0;
        k[i].push_back(cur);
        while(j+d<h*w){
            cur += abs(p[j+d].first-p[j].first)+abs(p[j+d].second-p[j].second);
            k[i].push_back(cur);
            j += d;
        }
    }
    int q;
    cin >> q;
    rep(i,q){
        int b,c;
        cin >> b >> c;
        b--;c--;
        int t = b%d;
        cout << k[t][(c-t)/d]-k[t][(b-t)/d] << endl;
    }
}

Measured memory_bytes: 9340
import math

# 余弦定理

a, b, h, m = map(int, input().split())

# 12時方向に対して、分針が作る角度
b_degree = 6 * m

# 12時方向に対して、時針が作る角度
# 時針は1時間に30度動くことにも注意
# 10時40分の時、時針は10時の位置から+40/60*30度動いている
a_degree = 30 * h + m / 60 * 30

# 分針が時針を追い越しているか、追い越していないかで場合分け
# 分針が時針を追い越してない
# 分針が0の場合を考慮してminとる
if a_degree > b_degree:
    degree1 = a_degree - b_degree
    degree2 = 360 - degree1
    degree = min(degree1, degree2)
    length = math.sqrt(a**2 + b**2 - 2*a*b*math.cos(math.radians(degree)))
elif a_degree < b_degree:
    degree = b_degree - a_degree
    length = math.sqrt(a**2 + b**2 - 2*a*b*math.cos(math.radians(degree))) 
else:
    length = abs(b - a)

print(length)

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

#define times(n, i)      uptil(0, n, i)
#define upto(f, t, i)    for(decltype(t) _##i = (t), i = (f); i <= _##i; i++)
#define uptil(f, t, i)   for(decltype(t) _##i = (t), i = (f); i < _##i; i++)
#define downto(f, t, i)  for(decltype(t) _##i = (t), i = (f); i >= _##i; i--)
#define downtil(f, t, i) for(decltype(t) _##i = (t), i = (f); i > _##i; i--)
#define unless(c) if(!(c))
#define until(c) while(!(c))
#define loop while(true)

#define all(v) v.begin(), v.end()
#define ln << "\n"

struct line{};

template<class T> istream& operator>>(istream& in, vector<T>& v) {
    times(v.capacity(), i) in >> v[i];
    return in;
}

template<class T> const ostream& operator<<(ostream& out, const vector<T>& v) {
    times(v.size(), i) out << (i ? " " : "") << v[i];
    return out;
}

template<class T, class...U> typename enable_if<is_same<T, line>::value, string>::type next(istream& in, const U&... args) {
    string s;
    getline(in, s, args...);
    return move(s);
}

template<class T, class...U> typename enable_if<!is_same<T, line>::value, T>::type next(istream& in, const U&... args) {
    T t(args...);
    in >> t;
    return move(t);
}
template<class T, class...U> auto next(const U&... args) -> decltype(next<T>(cin)) {
    return next<T>(cin, args...);
}

template<class T> T sum(const vector<T>& v) {
    T ans = T();
    for(const T& t : v) ans += t;
    return ans;
}

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

    int L = next<int>(), A = next<int>(), B = next<int>(), C = next<int>(), D = next<int>();
    cout << L - max((A - 1) / C + 1, (B - 1) / D + 1) ln;

    return 0;
}

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

using namespace std;

int main() {
	string a,b,huk;
	cin >> a;
  cin >> b;

  huk=a.at(2);
  huk=huk+a.at(1);
  huk=huk+a.at(0);

  if(huk==b) cout << "YES" << endl;
  else cout << "NO" << endl;
  
	return 0;
}


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

int main(){ 
  int64_t N, M; cin >> N >> M;

  int64_t ans;
  if(N == 1 && M == 1){
    ans = 1;
  } else if(N == 1 || M == 1){
    ans = max((int64_t)0, max(N, M)-2);
  } else if (N == 2 || M == 2){
    ans = 0;
  } else {
    ans = (N-2)*(M-2);
  }

  cout << ans << endl;
}


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

#define REP(i, n) for(int (i) = 0; (i) < (n); ++(i))
#define REPR(i, n) for(int (i) = (n); (i) >= 0; --(i))
#define FOR(i, n, m) for(int (i) = (n); (i) < (m); ++(i))

constexpr int INF = 1e9;
//constexpr ll INF = 1LL<<61;
constexpr ll mod = 1e9+7;

int main(){
  int N;
  ll K;
  cin >> N >> K;
  vector<ll> A(N);
  REP(i, N){
    cin >> A[i];
  }
  ll beki = 1LL<<60;
  ll ans = 0, ans2 = 0;
  bool under = false;
  REPR(i, 60){
    int cnt = 0;
    REP(j, N){
      if(A[j] >> i & 1){
        cnt++;
      }
    }
    if(under){
      ans2 += beki * max(cnt, N-cnt);
    }
    if(K >> i & 1){
      ans2 = max(ans2, ans+cnt*beki);
    }
    if(K>>i & 1) under = true;

    if(K>>i & 1){
      ans += (N-cnt) * beki;
    }
    else{
      ans += cnt * beki;
    }
    beki = beki >> 1;
  }
  cout << max(ans, ans2) << endl;
  return 0;
}


Measured memory_bytes: 1024
import sys


def main():
    n, k, q = [int(s) for s in sys.stdin.readline().strip().split()]
    a = [0] * q
    for i in range(q):
        a[i] = int(sys.stdin.readline().strip()) - 1

    scores = [0] * n
    for ai in a:
        scores[ai] += 1

    for i in range(n):
        score = scores[i]
        lose = q - score
        if lose >= k:
            print('No')
        else:
            print('Yes')


main()


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


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

    string s;
    cin >> s;

    int a,z;
    rep(i,s.size()){
        if(s.at(i)=='A') {
            a=i;
            break;
        }
    }
    rep(i,s.size()){
        if(s.at(i)=='Z') z=i;
    }
    cout << z-a+1 << endl;


}

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

int main() {
  int N, M;
  cin >> N >> M;
  string S;
  cin >> S;
  if (S.at(M - 1) == 'A') {
    S.at(M - 1) = 'a';
  }
  else if (S.at(M - 1) == 'B') {
    S.at(M - 1) = 'b';
  }
  else {
    S.at(M - 1) = 'c';
  }
  cout << S <<endl;
}

Measured memory_bytes: 256
n=int(input())
T, A = map(int,input().split())
H=list(map(int,input().split()))
ans=A-(T - H[0]* 0.006)
place=1
for i in range(1,n):
    if abs(ans)>abs(A-(T - H[i]* 0.006)):
        ans=A-(T - H[i]* 0.006)
        place=i+1
print(place)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define N 101000
const ll mod=1e9+7;

int n;
ll a[N],fac[N],inv[N],sum[N],ans;

ll power(ll x,ll y) {
	ll ret=1;
	for (;y;y>>=1,x=x*x%mod)
		if (y&1) ret=ret*x%mod;
	return ret;
}

int main()
{
	scanf("%d",&n);
	for (int i=1;i<=n;i++) scanf("%lld",&a[i]);
	fac[0]=1; for (int i=1;i<=n;i++) fac[i]=fac[i-1]*i%mod;
	inv[0]=inv[1]=1; for (int i=2;i<=n;i++) inv[i]=inv[mod%i]*(mod-mod/i)%mod;
	
	for (int i=2;i<=n;i++) sum[i]=(sum[i-1]+fac[n]*inv[i]%mod)%mod;
	for (int i=1;i<=n;i++) (ans+=a[i]*(fac[n]+sum[i]+sum[n-i+1])%mod)%=mod;
	printf("%lld\n",ans);
	return 0;
}

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

int main() {
  int n, k;
  cin >> n >> k;
  vector<int> x(n);
  for (int i = 0; i < n; i++)
    cin >> x[i];

  int sum = 0;
  for (int i = 0; i < n; i++) {
    sum += min(abs(x[i] * 2), abs((k - x[i]) * 2));
  }
  cout << sum << endl;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void){

  int N,K,d[101],A[101][101],i,j,sweets[101] = {0},ans = 0;

  scanf("%d %d",&N,&K);
  for(i = 1;i <= K;i++){
    scanf("%d",&d[i]);
    for(j = 1;j <= d[i];j++){
      scanf("%d",&A[i][j]);
    }
  }

  for(i = 1;i <= K;i++){
    for(j = 1;j <= d[i];j++){
      sweets[A[i][j]]++;
      //printf("addSunuke:%d\n",A[i][j]);
    }
  }

  for(i = 1;i <= N;i++){
    if(sweets[i] == 0) ans++;
  }

  printf("%d\n",ans);
  return 0;
}


Measured memory_bytes: 1772
n=int(input())
a=list(map(int, input().split()))

import fractions
def LCM(a,b):
  G=fractions.gcd(a,b) #最大公約数
  L=(a//G)*b           #最小公倍数
  return L

lcm = a[0]
for b in a[1:]:
  lcm = LCM(lcm,b)
ans = 0
print(sum([(lcm-1)%ai for ai in a]))

Measured memory_bytes: 5284
/* Coached by rainboy */
#include <stdio.h>
#include <string.h>

#define N 100000

int main() {
	static char s[N + 1];
	static int aa[N];
	int n, i, j, k;

	scanf("%s", s);
	n = strlen(s);
	for (i = 0; i < n; i = k) {
		int x, y;

		j = i + 1;
		while (j < n && s[j] == 'R')
			j++;
		k = j + 1;
		while (k < n && s[k] == 'L')
			k++;
		x = j - i;
		y = k - j;
		aa[j - 1] = (x + 1) / 2 + y / 2;
		aa[j] = x / 2 + (y + 1) / 2;
	}
	for (i = 0; i < n; i++)
		printf("%d ", aa[i]);
	printf("\n");
	return 0;
}


Measured memory_bytes: 896
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE LambdaCase #-}

module Main where

import qualified Data.ByteString.Char8 as B8
import Data.Maybe (fromJust)
import Data.Char (toUpper,isDigit)
import Data.List
import qualified Data.Map as M
import Data.Array.IO
import Data.IORef
import Data.Ix (range)
import Control.Monad
import Control.Applicative
import Text.Printf
import Data.Time.Calendar
import Debug.Trace

readDigits = map read <$> words <$> getLine :: IO [Int]
readDigits' = map read <$> lines <$> getContents :: IO [Int]

--
main :: IO ()
main = do
    sort <$> readDigits
    >>= putStrLn . unwords . map show 

Measured memory_bytes: 3632
#include <iostream>
#include <string>
#include <algorithm>
#include <utility>
#include <iomanip>
#include <functional>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <vector>
#include <cmath>
#include <cctype>
#include <cstdio>
#include <bitset>
#include <complex>
#define ll long long
#define INF 1000000000000000001
#define MOD 1000000007
using namespace std;


int main(){
    char temp='(';
    int n;
    cin >> n;
    string s;
    cin >> s;
    int ans=0;
    for(int i=0; i<n; i++){
        if(s[i]!=temp){
            ans++;
            temp=s[i];
        }
    }
    cout<<ans<<endl;
    return 0;
    
}


Measured memory_bytes: 512
from itertools import *
N = int(input())
L = list(map(int,input().split()))
csum = list(0 for _ in range(2000+1))
for i in range(N): csum[L[i]] += 1
csum = list(accumulate(csum))
ans = 0
for ib in range(N):
    for ia in range(ib):
        a, b = L[ia], L[ib]
        minL, maxL = abs(a-b), a+b
        ans += csum[maxL-1] - csum[minL]
        if minL < a and a < maxL: ans -= 1
        if minL < b and b < maxL: ans -= 1
print(ans//3)

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

struct Edge{
    int parent;
    int depth;
};

int main() {

    int n;
    cin >> n;
    vector<vector<int> > v(n);
    vector<Edge> info(n);
    rep(i, n){
        int id, m;
        cin >> id >> m;
        rep(j, m){
            int x;
            cin >> x;
            v[id].push_back(x);
            info[x] = (Edge){id, info[id].depth + 1};
            rep(k, v[x].size()){
                info[v[x][k]].depth = info[x].depth + 1;
            }
        }
    }

    rep(i, n){
        string s;
        if(info[i].parent == 0 && info[i].depth == 0){
            s = "root, [";
            info[i].parent = -1;
        }
        else if(v[i].size() == 0){
            s = "leaf, [";
        }
        else{
            s = "internal node, [";
        }

        cout << "node " << i << ": parent = " << info[i].parent 
            << ", depth = " << info[i].depth << ", " << s;

        if(v[i].size() == 0){
            cout << "]\n";
        }
        rep(j, v[i].size()){
            if(j != v[i].size()-1){
                cout << v[i][j] << ", ";
            }
            else{
                cout << v[i][j] << "]" << endl;
            }
        }
    }

    return 0;
}



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


def solve(K: int, A: int, B: int):
    if B-A < 2:
        print(K+1)
    else:
        remain_c = K + 1 - A
        ans = A + (remain_c//2) * (B-A) + remain_c%2
        print(ans)
    return


# Generated by 1.1.5 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()
    K = int(next(tokens))  # type: int
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    solve(K, A, B)

if __name__ == '__main__':
    main()


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

using namespace std;

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

    vector<double> ps(n);
    for (double& p : ps) cin >> p;

    vector<vector<double>> dp(n + 1, vector<double>(n + 1, 0));
    dp[0][0] = 1;
    for (int i = 1; i <= n; i++) {
        for (int h = 0; h <= n; h++) {
            if (0 < h) {
                dp[i][h] = dp[i - 1][h] * (1 - ps[i - 1]) + dp[i - 1][h - 1] * ps[i - 1];
            } else {
                dp[i][h] = dp[i - 1][h] * (1 - ps[i - 1]);
            }
        }
    } 

    double p = 0;
    for (int h = 0; h <= n; h++) {
        if (n - h < h) {
            p += dp[n][h];
        }
    }

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

    return 0;
}



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

#ifdef LOCAL
#include "dump.hpp"
#else
#define dump(...)
#define dumpv(...)
#endif

#define rep(i, n) for (int i = 0; i < (n); i++)
#define mins(x, y) (x = min(x, y))
#define maxs(x, y) (x = max(x, y))
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vvl = vector<vl>;
using P = pair<int, int>;
const int MOD = 1e9 + 7;
const int INF = 1001001001;
const ll LINF = 1001002003004005006ll;

void solve() {
  int n;
  cin >> n;
  vl a(n);
  rep(i, n) cin >> a[i];
  vl b(n);
  rep(j, 31) {
    ll one = (1 << j);
    int cnt = 0;
    rep(i, n) {
      if (a[i] & one) cnt++;
    }
    if (cnt % 2 == 0) {
      rep(i, n) {
        if (a[i] & one) b[i] = b[i] | one;
      }
    } else {
      rep(i, n) {
        if (!(a[i] & one)) b[i] = b[i] | one;
      }
    }
  }
  rep(i, n) cout << b[i] << " ";
  cout << endl;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  // freopen("temp.1", "r", stdin);
  solve();
  return 0;
}

Measured memory_bytes: 6372
#include <bits/stdc++.h>
#define F(i, l, r) for(int i = (l), _end_ = (int)(r); i <= _end_; ++i)
#define f(i, r, l) for(int i = (r), _end_ = (int)(l); i >= _end_; --i)
#define Set(a, v) memset(a, v, sizeof(a))
#define file(a) freopen(a".in","r",stdin),freopen(a".out","w",stdout)
using namespace std;

bool chkmin(int &a, int b) {return b < a ? a = b, 1 : 0;}
bool chkmax(int &a, int b) {return b > a ? a = b, 1 : 0;}

inline long long  read() {
 long long x = 0, fh = 1; char ch = getchar();
    for (; !isdigit(ch); ch = getchar() ) if (ch == '-') fh = -1;
    for (; isdigit(ch); ch = getchar() ) x = (x<<1) + (x<<3) + (ch ^ '0');
    return x * fh;
}
#define PII pair<long long,long long>
#define x first
#define y second
int n,m,totn;
long long ans[100005],cnt[100005],c[100005],top;
queue<PII>q;
int main () {
#ifndef ONLINE_JUDGE
//file("l");
#endif
    n=read();
	m=read();
	totn=n;
	c[top=1]=n;
	while(m--){
	   long long x=read();
	   while(top&&x<=c[top])top--;
	   c[++top]=x;
	}
	m=top;
	n=c[1];
	cnt[m]=1;
	f(i,m,1){
	  if(cnt[i])q.push(make_pair(c[i],cnt[i]));
	  while(!q.empty()){
	      PII p=q.front();
		  q.pop();
		  if(p.x<=n){
		      ans[p.x]+=p.y;
			  continue;
		  }
		  int pos=lower_bound(c+1,c+m+1,p.x)-c-1;
		  cnt[pos]+=(p.x/c[pos])*p.y;
		  if(p.x%c[pos])q.push(make_pair(p.x%c[pos],p.y));
	  }
	}
	f(i,n,1)ans[i-1]+=ans[i];
	F(i,1,totn)printf("%lld\n",ans[i]);
    return 0;
}

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

#define EPS (1e-7)
#define INF 1e18
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
#define PI (acos(-1))

#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define rep(i, init, n) for(int i = init; i <(int)(n); i++)

int main() {
    ll N;
    cin >> N;
    ll tmp;
    map<ll, ll> m;
    REP(i, N){
        cin >> tmp;
        m[tmp]++;

    }
    ll a = 0, b = 0;
    for(auto iter = m.begin(); iter != m.end(); iter++){
        if (iter->second < 2) continue;
        if (iter->first > a) {
            if (iter->second >= 4) b = iter->first;
            else b = a;
            a = iter->first;
        }
        else if (iter->first > b) b = iter->first;
    }
    cout << (a * b) << endl;

    return 0;
}

Measured memory_bytes: 6528
#include <stdio.h>

int main() {

    int n,rj,ri,max,tmp,minv;
    int t[200001]={};
    int i,j;

    scanf("%d",&n);

    for(i = 0; i < n; i++){
        scanf("%d",&t[i]);
    }

    max = t[1] - t[0];

    // for(j = 1; j < n; j++){
    //     for(i = 0; i < j; i++){
    //         tmp = t[j] - t[i];
    //         if(tmp > max){
    //             max = tmp;
    //         }
    //     }
    // }

    minv = t[0];

    for(j = 1; j < n; j++){
        tmp = t[j] - minv;
        if (tmp > max) {
            max = tmp;
        }
        if (minv > t[j]) {
            minv = t[j];
        }

    }

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

    return 0;
}



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

using namespace std;
typedef long long ll;

#define MOD 1000000007
#define INF 1000000000
#define PI 3.14159265359

stack<char> s;

int main(void) {
  string str;
  cin >> str;
  for (int i = 0; i < str.size(); i++) {
    if (str[i] == 'S') {
      s.push(str[i]);
    } else if (str[i] == 'T') {
      if (!s.empty() && s.top() == 'S')
        s.pop();
      else
        s.push('T');
    }
  }

  cout << s.size() << endl;

  return 0;
}

Measured memory_bytes: 644
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Scanner;

public class Main {
	static Scanner sc = new Scanner(System.in);

	public static void main (String [] args){
		List <Integer> list = new ArrayList<Integer>();
		HashMap <Integer, Integer>hm = new HashMap<Integer, Integer>();
		int v1 = Integer.parseInt(sc.next());
		int v2 = Integer.parseInt(sc.next());		
		int v3 = Integer.parseInt(sc.next());
		int v4 = Integer.parseInt(sc.next());
		String ans_str = "";
		int ans_int = 0;
		if(v1+v2>v3+v4){
			ans_str = "Left";
		}else if(v1+v2<v3+v4){
			ans_str = "Right";
		}else{
			ans_str = "Balanced";
		}
		System.out.println(ans_str);
		System.out.flush();
		sc.close();
	}
}

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

int main()
{
  int n,m;
  cin>>n>>m;
  vector<int> b(n);
  for(int i = 0; i<m;i++){
    vector<int> a(2);
    cin>>a.at(0)>>a.at(1);
    for(int j =0;j<n;j++){
      if(j+1 == a.at(0)){
        b.at(j)++;
      }
      if(j+1 == a.at(1)){
        b.at(j)++;
      }
    }
  }
  for (int k =0;k<n;k++){
    cout << b.at(k) <<endl;
  }
}
  


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(ll i = 0;i<((ll)(n));i++)
#define reg(i,a,b) for(ll i = ((ll)(a));i<=((ll)(b));i++)
#define irep(i,n) for(ll i = ((ll)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(ll i = ((ll)(b));i>=((ll)(a));i--)
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;

/*
*/

string s,t;


void init(){
	cin>>s>>t;
}

int main(void){
	init();
	int ans=0;
	rep(i,3)if(s[i]==t[i])ans++;
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
//
// Created on 2020/02/09.
//

//#include <bits/stdc++.h>
#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 <math.h>
#include <ios>
#include <iomanip>
#include <numeric>

#define all(x) (x).begin(),(x).end()
typedef long long ll;
using namespace std;
const long long LINF =1e18;
const int INF = 1e9;
using gragh = vector<vector<int>>;

int main() {
    double ans = 0;
    int n;
    int k;
    cin>>n>>k;
    vector<int>p(n);
    for (int i = 0; i < n; ++i) {
        cin>>p[i];
    }
    vector<double >table(1000+10);
    table[1] = 1;
    for (int j = 2; j <= 1000; ++j) {
        table[j] = (table[j-1]*(j-1)+j)/j;
    }

    for (int l = 0; l < k; ++l) {
        ans += table[p[l]];
    }

    double temp = ans;
    for (int m = 0; m + k < n; ++m) {
        temp -= table[p[m]];
        temp += table[p[k+m]];
        ans = max(temp,ans);
    }

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


Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define pb push_back
#define mod int(1e9+7)
#define N int(2e5+100)
#define ll long long int
#define pii pair<int,int>
#define pll pair<ll,ll>
#define fi first
#define si second
using namespace std;
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
   int k;
   cin>>k;
   ll sum=0*1ll;
   for(int a=1;a<=k;a++){
      for(int b=1;b<=k;b++){
         for(int c=1;c<=k;c++){
            sum+=1ll*__gcd(a,__gcd(b,c));
         }
      }
   }
   cout<<sum<<'\n';
   return 0;
}


Measured memory_bytes: 3652
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<cstring>
#include<algorithm>
#include<iostream>

using namespace std;
const int MaxN = 1e5 + 5;

int main(){
	int n, w, i, j;
	int dp[MaxN], a[MaxN];
	cin >> n >> w;
	for(i = 1;i <= n;i++)  scanf("%d", &a[i]);
	memset(dp, 0x3f, (n + 1) * sizeof(dp[0]));
	dp[1] = 0;
	for(i = 1;i <= n;i++){
		for(j = 1;j <= w;j++){
			if(dp[i + j] >= dp[i] + abs(a[i] - a[i + j]))   dp[i + j] = dp[i] + abs(a[i] - a[i + j]);
		}
	}
	cout << dp[n] << endl;
	return 0;
}

Measured memory_bytes: 1024
#include <stdio.h>
int main()
{
  int i, j, minj, tmp, n, count, check;
  int A[100];

  scanf("%d", &n);
  for(i=0; i<n; i++) {
    scanf("%d", &A[i]);
  }

  count = 0;
  check = 0;

  for(i=0; i<n; i++) {
    minj = i;
    for(j=i; j<n; j++) {
      if(A[j] < A[minj]) {
	minj = j;
	check = 1;
      }
    }
    tmp = A[i];
    A[i] = A[minj];
    A[minj] = tmp;
    if(check == 1) {
      count++;
      check = 0;
    }
  }

  for(i=0 ; ; i++) {
    printf("%d", A[i]);
    if(i == n-1) break;
    printf(" ");
  }
  printf("\n%d\n", count);

  return 0;
}

Measured memory_bytes: 604
while data = gets
  a, b, c, d, e, f = data.chomp.split(" ").map(&:to_f)
  x = (c * e - b * f) / (a * e - b * d)
  y = (c * d - a * f) / (b * d - a * e)
  x = 0.to_f if x.zero?
  y = 0.to_f if y.zero?
  puts sprintf("%.3f %.3f", x, y)
end

Measured memory_bytes: 8648
#include<bits/stdc++.h>
using namespace std;
const int N=2e6+10;
typedef long long ll;
const ll Inf=1e18;

int gi() {
	int x=0,o=1;char ch=getchar();
	while((ch<'0'||ch>'9')&&ch!='-') ch=getchar();
	if(ch=='-') o=-1,ch=getchar();
	while(ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();
	return x*o;
}

int to[N],ww[N],nxt[N],tt=1,h[N],cur[N],dep[N],n,p[N],q[N],s,t,belp[N],belq[N],val[N];
bool vis[N];

void adde(int u,int v,int w) {
	to[++tt]=v,ww[tt]=w,nxt[tt]=h[u],h[u]=tt;
	to[++tt]=u,nxt[tt]=h[v],h[v]=tt;
}

bool bfs() {
	memset(dep,0,4*(t+1));
	queue<int> q;q.push(s);dep[s]=1;
	while(!q.empty()) {
		int u=q.front();q.pop();
		for(int i=h[u],v;v=to[i],i;i=nxt[i])
			if(!dep[v]&&ww[i]) {
				dep[v]=dep[u]+1,q.push(v);
				if(v==t) return 1;
			}
	}
	return 0;
}

ll dfs(int u,ll flow) {
	if(u==t) return flow;
	ll ret=0;
	for(int &i=cur[u],v;v=to[i],i;i=nxt[i])
		if(dep[v]==dep[u]+1&&ww[i]) {
			ll d=dfs(v,min(flow,(ll)ww[i]));
			ww[i]-=d,ww[i^1]+=d,ret+=d,flow-=d;
			if(!flow) return ret;
		}
	dep[u]=0;return ret;
}

ll dinic() {
	ll ret=0;
	while(bfs()) {
		memcpy(cur,h,4*(t+1));
		ret+=dfs(s,Inf);
	}
	return ret;
}

int main() {
	cin>>n;
	for(int i=1;i<=n;i++) p[i]=gi()+1;
	for(int i=1;i<=n;i++) q[i]=gi()+1;
	for(int i=1;i<=n;i++)
		if(!vis[i]) {
			++t;
			for(int j=i;!vis[j];j=p[j]) vis[j]=1,belp[j]=t;
		}
	memset(vis,0,sizeof(vis));
	int lst=t;
	for(int i=1;i<=n;i++)
		if(!vis[i]) {
			++t;
			for(int j=i;!vis[j];j=q[j]) vis[j]=1,belq[j]=t;
		}
	++t;
	int ans=n;
	for(int i=1;i<=n;i++) {
		if(p[i]!=i&&q[i]!=i) {
			adde(belq[i],belp[i],1);
			if(p[i]==q[i]) adde(belp[i],belq[i],1);
		}
		else if(p[i]==i&&q[i]==i) --ans;
		else if(p[i]==i) ++val[belq[i]];
		else ++val[belp[i]];
	}
	for(int i=1;i<=lst;i++) {
		adde(s,i,val[i]+n);
		adde(i,t,n);
	}
	for(int i=lst+1;i<t;i++) {
		adde(s,i,n);
		adde(i,t,val[i]+n);
	}
	ans-=dinic()-1ll*n*(t-1);
	cout<<ans;
	return 0;
}


Measured memory_bytes: 33128
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <map>
#include <vector>
using namespace std;
typedef long long int ll;

int main(int argc, char const *argv[]) {
  int N;
  cin >> N;
  string s;
  cin >> s;
  int b = 0;
  int r = 0;
  for (size_t i = 0; i < s.size(); i++) {
    if (s[i] == 'R') {
      r++;
    } else {
      b++;
    }
  }
  if (r > b) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define N 100010
using namespace std;
typedef vector<vector<int>> graph;
int dfs(const graph &G, int v, int h[])
{
    int x(1);
    for (auto next_v : G[v])
    {
        if (h[v] <= h[next_v])
        {
            x = 0;
            break;
        }
    }
    return x;
}
int main()
{
    int n, m, h[N];
    cin >> n >> m;
    graph g(N);
    for (int i = 1; i <= n; ++i)
    {
        cin >> h[i];
    }
    for (int i = 0; i < m; ++i)
    {
        int a, b;
        cin >> a >> b;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    int ans(0);
    for (int i = 1; i <= n; ++i)
        ans += dfs(g, i, h);
    cout << ans << endl;
}

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

int main(){
  string s;
  cin >> s;
  string ans = "No";
  if(s.size() %2 == 1){
    cout << ans << endl;
    return 0;
  }
  for(int i=0; i<s.size()-1;){
    if(s.at(i) != 'h' || s.at(i+1) != 'i'){
      cout << ans << endl;
      return 0;
    }
    i += 2;
  }
  cout << "Yes" << endl;
  return 0;
}

Measured memory_bytes: 256
from collections import Counter


def solve(N, As):
    c = Counter(As)
    n = 10 ** 9 + 7
    if c['0'] == N % 2 and \
            all([v == 2 and int(i) % 2 == (N + 1) % 2 for i, v in c.items() if i != '0']):
        return pow(2, N // 2, n)

    return 0


if __name__ == "__main__":
    N = int(input())
    As = input().split(" ")
    print(solve(N, As))


Measured memory_bytes: 15216
#include<stdio.h>

int main (void)
{
  int x[3000], y[3000], i = 0, temp;
  do
  {
    scanf("%d %d", &x[i], &y[i]);
    if (x[i] > y[i])
    {
      temp = x[i];
      x[i] = y[i];
      y[i] = temp;
    }
    i++;
  } while (x[i-1] != 0 || y[i-1] != 0);
  
  i = 0;
  
  while (x[i] != 0 || y[i] != 0)
  {
    printf("%d %d\n", x[i], y[i]);
    i++;
  }
  
  return 0;
}

Measured memory_bytes: 2712
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> pll;
const ll mod=1e9+7;
//const ll mod=998244353;
const ll inf=5e18;

int main() {
  ll n;
  cin >> n;
  vector<double> x(n);
  vector<string> u(n);
  double ans=0;
  for(ll i=0;i<n;i++) {
    cin >> x[i] >> u[i];
    if(u[i]=="JPY") {
      ans+=x[i];
    }
    else {
      ans+=x[i]*380000;
    }
  }
  cout << fixed << setprecision(10) << ans << endl;
}

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

int main(){
    map<char, int> mp;

    string s;
    cin >> s;
    for(int i = 0;i < s.size();i++){
        mp[s[i]]++;
    }

    for(char i = 'a';i <= 'z';i++){
        if(mp[i] == 0){
            cout << i << endl;
            return 0;
        }
    }

    cout << "None" << endl;
    return 0;
}



Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
#define rep(i,a,b) for(ll (i)=a;(i)<(ll)(b);(i)++)
#define INF 100000000

int main(){
    string S;
    cin >> S;
    if(S=="ABC") cout << "ARC" <<endl;
    else cout << "ABC" << endl;

}


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

using namespace std;

#define sz(x) ((int) ((x).size()))
typedef long long ll;
typedef long double ld;

// return a % b (positive value)
ll mod(ll a, ll b) {
	return ((a % b) + b) % b;
}

// return a^b mod m
ll powmod(ll a, ll b, ll m) {
	ll res = 1;
	while(b > 0)
		if(b & 1) res = (res * a) % m, --b;
		else a = (a * a) % m, b >>= 1;
	return res % m;
}

// returns d = gcd(a,b); finds x,y such that d = ax + by
ll extended_euclid(ll a, ll b, ll &x, ll &y) {
	ll xx = y = 0; ll yy = x = 1;
	while(b) {
		ll q = a / b; ll t = b; b = a % b;
		a = t; t = xx; xx = x - q * xx; x = t;
		t = yy; yy = y - q * yy; y = t;
	}
	return a;
}

// computes b such that ab = 1 (mod n), returns -1 on failure
ll mod_inverse(ll a, ll n) {
	ll x, y;
	ll d = extended_euclid(a, n, x, y);
	if(d > 1) return -1;
	return mod(x, n);
}

const ll m = 1000000000 + 7;
ll b, ci, co;

ll f(ll k) {
  if (k == 1)
    return 1;
  ll r = powmod(b, k - 1, m);
  ci = mod(ci * powmod(b, k - 2, m), m);
  ll binv = mod_inverse(b, m);
  co = mod(co * binv, m);
  if (co == 1)
    r = mod(r - ci * (k - 1), m);
  else
    r = mod(r - ci * mod((powmod(co, k - 1, m) - 1) * mod_inverse(co - 1, m), m), m);
  return r;
}

// ll f(ll k) {
//   if (k == 1)
//     return 1;
//   return mod(b * f(k - 1) - ci * powmod(co, k - 2, m), m);
// }

// f(1) = 1
// f(k + 1) = #b * f(k) - #ci * #co^(k - 1)
// -> f(k) = #b^(k - 1) - #ci * sum_(i = 0)^(k - 2) #co^i * #b^(k - 2 - i)
// sum_(i = 0)^(k - 2) #co^i * #b^(k - 2 - i) = #b^(k - 2) sum_(i = 0)^(k - 2) (#co * #b^(-1))^i
// {#co = 1: k - 1}, {#co > 1: (#co^(k - 1) - 1) / (#co - 1)}}

ll k;
int h, w, ca[2], cb[2];
bool g[2000][2000];

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout << fixed << setprecision(10);
  cin >> h >> w >> k;
  char c;
  for (int i = 0; i < h; i++)
    for (int j = 0; j < w; j++) {
      cin >> c;
      g[i][j] = c == '#';
      b += g[i][j];
    }
  for (int i = 0; i < h - 1; i++)
    for (int j = 0; j < w; j++)
      ca[0] += g[i][j] && g[i + 1][j];
  for (int i = 0; i < h; i++)
    for (int j = 0; j < w - 1; j++)
      ca[1] += g[i][j] && g[i][j + 1];
  for (int i = 0; i < w; i++)
    cb[0] += g[0][i] && g[h - 1][i];
  for (int i = 0; i < h; i++)
    cb[1] += g[i][0] && g[i][w - 1];
  // cerr << ca[0] << " " << ca[1] << " " << cb[0] << " " << cb[1] << "\n";
  if (cb[0] && cb[1])
    cout << "1\n";
  else if (!cb[0] && !cb[1])
    cout << powmod(b, k - 1, m) << "\n";
  else {
    if (cb[0])
      ci = ca[0], co = cb[0];
    else
      ci = ca[1], co = cb[1];
    // cerr << ci << " " << co << "\n";
    cout << f(k) << "\n";
  }
}


Measured memory_bytes: 2176
W,H = map(int,input().split())
while W != 0:
    for i in range(W):
        for j in range(H):
            if ((i+1)%2 != 0 and (j+1)%2 != 0) or ((i+1)%2 == 0 and (j+1)%2 == 0):
                print('#',end='')
            else:
                print('.',end='')
            
        print()
    print()
    W,H = map(int,input().split())


Measured memory_bytes: 7000
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <iterator>
#include <assert.h>
#pragma warning(disable:4996) 

typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223300000000000000
#define INF 2140000000
const long long MOD = 1000000007;
//const long long MOD = 998244353;

using namespace std;



void solve()
{
    int n,m;
    scanf("%d%d", &n, &m);

    vector<int> a(n);
    vector<vector<int> > z(m);
    int i;
    ll sum=0;
    int cnt=0;
    for(i=0; i<n; i++) {
        scanf("%d", &a[i]); a[i]--;
        if(i>0) {
            if(a[i-1]>a[i]) {
                sum+=1+a[i];
                cnt++;
            }
            else {
                sum+=a[i]-a[i-1];
            }
        }
        z[a[i]].push_back(i);
    }

    ll ans=sum;
#ifdef _DEBUG
    printf("%lld, %d\n", sum, cnt);
#endif
    int j;
    for(i=0; i<m-1; i++) {
        ll diff=0;
        for(j=0; j<(int)z[i].size(); j++) {
            int k=z[i][j];
            if(k>0) {
                int tmp=(a[k]-a[k-1]+m)%m;
                diff+=(tmp-1);
            }
            else {
                cnt++;
            }
            if(k==n-1) {
                cnt--;
            }
            else {
                diff++;
            }
        }
        diff-=cnt;
        sum+=diff;
#ifdef _DEBUG
        printf("%lld\n", sum);
#endif
        ans=MIN(ans,sum);
    }
    printf("%lld\n", ans);
    

    return;
}


int main(int argc, char* argv[])
{
#if 1
	solve();
#else
	int T; scanf("%d", &T);
	while (T--) {
		solve();
	}
#endif
	return 0;
}


Measured memory_bytes: 5376
#include <algorithm>
#include <bits/stdc++.h>
#include <cstdint>
#include <iostream>
#include <iterator>
#include <vector>

// lib/detail/ceil_and_floor.hpp
#ifndef DETAIL_CEIL_AND_FLOOR_HPP
#define DETAIL_CEIL_AND_FLOOR_HPP

namespace tools {
  template <typename T>
  constexpr T floor(T lhs, T rhs);

  template <typename T>
  constexpr T ceil(T lhs, T rhs);

  template <typename T>
  constexpr T floor(const T lhs, const T rhs) {
    return
      lhs >= 0 && rhs >= 0 ?
        lhs / rhs :
      lhs < 0 && rhs >= 0 ?
        -ceil<T>(-lhs, rhs) :
      lhs >= 0 && rhs < 0 ?
        -ceil<T>(lhs, -rhs) :
        floor<T>(-lhs, -rhs);
  }

  template <typename T>
  constexpr T ceil(const T lhs, const T rhs) {
    return
      lhs >= 0 && rhs >= 0 ?
        (lhs - 1 + rhs) / rhs :
      lhs < 0 && rhs >= 0 ?
        -floor<T>(-lhs, rhs) :
      lhs >= 0 && rhs < 0 ?
        -floor<T>(lhs, -rhs) :
        ceil<T>(-lhs, -rhs);
  }
}

#endif

// lib/util.hpp
#ifndef UTIL_HPP
#define UTIL_HPP


using i64 = ::std::int_fast64_t;
using u64 = ::std::uint_fast64_t;
using i32 = ::std::int_fast32_t;
using u32 = ::std::uint_fast32_t;

namespace tools {
  template <typename T>
  void read(::std::istream& is, ::std::vector<T>& vector, const typename ::std::vector<T>::size_type size) {
    vector.reserve(size);
    ::std::copy_n(::std::istream_iterator<T>(is), size, ::std::back_inserter(vector));
  }
  template <typename T>
  void read(::std::vector<T>& vector, const typename ::std::vector<T>::size_type size) {
    ::tools::read(::std::cin, vector, size);
  }

  template <typename T, ::std::size_t N>
  void read(::std::istream& is, ::std::array<T, N>& array) {
    ::std::copy_n(std::istream_iterator<T>(is), N, array.begin());
  }
  template <typename T, ::std::size_t N>
  void read(::std::array<T, N>& array) {
    ::tools::read(::std::cin, array);
  }
}

#endif

// lib/ceil.hpp
#ifndef CEIL_HPP
#define CEIL_HPP


/*
usage:

tools::ceil(5, 3) // => 2 (i.e., ceil(5 / 3))
*/

#endif

// main.cpp

int main() {
  i64 X;
  std::cin >> X;
  std::cout << tools::ceil<i64>(2000 - X, 200) << std::endl;
  return 0;
}

Measured memory_bytes: 3568
N, M = map(int, input().split())
AB = [list(map(int, input().split())) for _ in range(N)]

AB.sort()
#print(AB)

cost = 0
for i in range(N):
    cost += AB[i][0] * min(AB[i][1], M)
    M = M - min(AB[i][1], M)
    if M == 0:
        break

print(cost)

Measured memory_bytes: 27760
use std::io::*;
use std::str::FromStr;

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}

fn main() {
    let N: usize = read();
    let b: Vec<isize> = read_vec();
    let mut a: Vec<isize> = vec![0; N];
    let mut sum = 0;

    a[0] = b[0];
    a[1] = b[0];
    for i in 1..b.len() {
        if b[i] < b[i - 1] {
            a[i] = b[i];
            a[i + 1] = b[i];
        } else {
            a[i] = b[i - 1];
            a[i + 1] = b[i];
        }
    }

    for i in a {
        sum += i;
    }

    println!("{}", sum);
}


Measured memory_bytes: 4352
#include <iostream>
#include <stdlib.h>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;

int n;
vector<int> a;

void solve(){
  long sum = 0L;
  if(n%2 == 0){
    int k = n/2;
    for(int i = 0; i < k-1; i++){
      sum += 2 * (a[n-1-i] - a[i]);
    }
    sum += a[k] - a[k-1];
  }else{
    int k = (n-1)/2;
    for(int i = 0; i < k-1; i++){
      sum += 2 * (a[n-1-i] - a[i]);
    }
    long tmp1 = a[k+1] + a[k] - 2*a[k-1];
    long tmp2 = 2*a[k+1] - a[k] - a[k-1];
    sum += (tmp1 > tmp2) ? tmp1 : tmp2;
  }
  cout << sum << endl;
}

int main(int argc,char** argv){
  cin >> n;
  for(int i = 0;i < n;i++){
    int tmp;
    cin >> tmp;
    a.push_back(tmp);
  }
  sort(a.begin(),a.end());
  solve();
  return 0;
}



Measured memory_bytes: 892