akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>

typedef struct{
	char suit;
	int num;
}card_t;



void BubbleSort(card_t c[],int N){
	int j,flag=1;
	card_t x;
	
	while(flag==1){
		flag=0;
		for(j=N-1;j>=1;j--){
			if(c[j].num<c[j-1].num){
				x=c[j];
				c[j]=c[j-1];
				c[j-1]=x;
			
				flag=1;
			}
		}
	}
}

void SelectionSort(card_t a[], int N){
	int i, j,min, flag=1;
	card_t x;
	
	while(flag==1){
		flag=0;
		for(i=0;i<N;i++){
			min=i;
			for(j=i; j<N; j++){
				if(a[j].num<a[min].num){
					min=j;
					flag=1;
				}
			}
			x=a[i];
			a[i]=a[min];
			a[min]=x;
			
		}
	}
}

int isStable(card_t in[], card_t out[], int N){
	int i, j, a, b;
	
	for(i=0; i<N; i++){
		for(j=i+1; j<N; j++){
			for(a=0; a<N; a++){
				for(b=a+1; b<N;b++){
					if((in[i].num==in[j].num)&&(in[j].num==out[a].num)&& (in[i].num==out[b].num) && (in[i].suit==out[b].suit) && (in[j].suit==out[a].suit)){return 1;}
				}
			}
		}
	}
	return 0;
}

int main(void)
{
	int N;
	int i, judge;
	scanf("%d", &N);
		
	card_t c[N];
	card_t a[N];
	card_t r[N];
	for(i=0; i<N; i++){
		scanf("%*c%c", &c[i].suit);
		scanf("%d", &c[i].num);
		a[i]=c[i];
		r[i]=c[i];
	}
	
	BubbleSort(c, N);
	SelectionSort(a,N);
	
	
	for(i=0; i<N-1; i++){
		printf("%c", c[i].suit);
		printf("%d ", c[i].num);
		}
	printf("%c", c[N-1].suit);
	printf("%d\n", c[N-1].num);
	judge=isStable(c, r, N);
	if(judge==0){printf("Stable\n");}
	else {printf("Not stable\n");}
	
	for(i=0; i<N-1; i++){
		printf("%c", a[i].suit);
		printf("%d ", a[i].num);
		}
	printf("%c", a[N-1].suit);
	printf("%d\n", a[N-1].num);
	judge=isStable(a, r, N);
	if(judge==0){printf("Stable\n");}
	else {printf("Not stable\n");}
	return 0;
}


Measured memory_bytes: 2032
n,m=map(int,input().split())

if n%2 == 1:
  for i in range(1,m+1):
    a,b=i,n-i
    print(a,b)
else:
  for i in range(1,m+1):
    a,b = i,n-i
    if b-a <= n//2:
      a+=1
    print(a,b)
  

Measured memory_bytes: 9120
#include <stdio.h>
int main(void){
int x = 1;
int k,n;
scanf ("%d",&n);
scanf ("%d",&k);
for(int i = 0; i < n; i++){
if(x < k){
x = 2*x;
}else{
x = x + k;
}
}
printf("%d\n",x);
return 0;
}


Measured memory_bytes: 128
S = input()
T = input()
li_S = [-1]*26
li_T = [-1]*26


for i in range(len(S)):
    li_S[ord(S[i])-97]=i if li_S[ord(S[i])-97]==-1 else li_S[ord(S[i])-97]
    li_T[ord(T[i])-97]=i if li_T[ord(T[i])-97]==-1 else li_T[ord(T[i])-97]


flag = True
for i in range(len(S)):
    if(li_S[ord(S[i])-97]!=li_T[ord(T[i])-97]):
        flag = False

if(flag):
    print('Yes')
else:
    print('No')


Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
const int inf = 1e9 + 7;
const ll INF = 1e18;
const int mod = 1000000007;
#define abs(x) (x >= 0 ? x : -(x))
#define lb(v, x) (int)(lower_bound(all(v), x) - v.begin())
#define ub(v, x) (int)(upper_bound(all(v), x) - v.begin())
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
template<typename T> T pow(T a, int b) { return b ? pow(a * a, b / 2) * (b % 2 ? a : 1) : 1; }
ll modpow(ll a, ll b, ll _mod) { return b ? modpow(a * a % _mod, b / 2, _mod) * (b % 2 ? a : 1) % _mod : 1; }
template<class T> ostream& operator << (ostream& os, const vector<T>& vec) { for (auto &vi: vec) os << vi << " "; return os; }
template<class T, class U> ostream& operator << (ostream& os, const pair<T, U>& p) { os << p.F << " " << p.S; return os; }
template<typename T >inline istream& operator >> (istream& is, vector<T>& v) { rep(j, sz(v)) is >> v[j]; return is; }
template<class T> inline void add(T &a, int b) { a += b; if (a >= mod) a -= mod; }


void solve();

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

    int T;
    // cin >> T;
    T = 1;

    while (T--) {
        solve();
    }
}

struct Edge {
  int to, cap, rev;
  Edge(int to, int cap, int rev) : to(to), cap(cap), rev(rev) {}
};

const int maxv = 205;
vector<Edge> G[maxv];
bool used[maxv];

void add_edge(int from, int to, int cap) {
    G[from].eb((Edge){ to, cap, sz(G[to])});
    G[to].eb((Edge){ from, 0, sz(G[from]) - 1});
}

int dfs(int v, int t, int f) {
    if (v == t) return f;
    used[v] = 1;
    for (Edge &e : G[v]) {
        if (!used[e.to] && e.cap != 0) {
            int d = dfs(e.to, t, min(f, e.cap));
            if (d != 0) {
                e.cap -= d;
                G[e.to][e.rev].cap += d;
                return d;
            }
        }
    }
    return 0;
}

int max_flow(int s, int t) {
    int flow = 0;
    while (1) {
        memset(used, 0, sizeof(used));
        int f = dfs(s, t, inf);
        if (f == 0) return flow;
        flow += f;
    }
}

void solve() {
  int n;
  cin >> n;
  vector<pii> a(n);
  rep(i, n) cin >> a[i].F >> a[i].S;
  vector<pii> b(n);
  rep(i, n) cin >> b[i].F >> b[i].S;

  rep(i, n) rep(j, n) {
    if (a[i].F < b[j].F && a[i].S < b[j].S) {
      add_edge(i, n + j, 1);
    }
  }
  // source
  rep(i, n) {
    add_edge(2 * n, i, 1);
  }
  // sink
  rep(i, n) {
    add_edge(n + i, 2 * n + 1, 1);
  }
  cout << max_flow(2 * n, 2 * n + 1) << endl;
}


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

const int MAX_N = 2e5+5;

int n, Q;
vector<int> G[MAX_N];
int arr[MAX_N];

void dfs(int node, int parent) {
    if (parent != -1) {
        arr[node] += arr[parent];
    }
    for (auto adj: G[node]) {
        if (adj == parent) continue;
        dfs(adj, node);
    }
}

int main() {
    cin >> n >> Q;
    for (int i=0; i<n-1; i++) {
        int u, v;
        cin >> u >> v;
        G[u].push_back(v);
        G[v].push_back(u);
    }
    while (Q--) {
        int x, p;
        cin >> p >> x;
        arr[p] += x;
    }

    dfs(1, -1);

    for (int i=1; i<=n; i++) {
        cout << arr[i] << " ";
    }
    return 0;
}


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

int main(){
    int k;
    int a[5];
    for(int i = 0; i < 5; i++){
        cin >> a[i];
    }
    cin >> k;
    int frag = 0;

    for(int i = 0; i < 4; i++){
        for(int j = i; j < 4; j++){
            if(a[j + 1] - a[i] > k){
                frag = 1;
                break;
            }
        }
    }

    if(frag == 1){
        cout << ":(" << endl;
    }else{
        cout << "Yay!" << endl;
    }
}

Measured memory_bytes: 256
n, m = map(int, input().split())
account, wacount = 0, 0
acdic = [0] * (n + 10)
for _ in range(m):
    p, s = input().split()
    p = int(p)
    if s == "AC" and acdic[p] <= 0:
        account += 1
        wacount += abs(acdic[p])
        acdic[p] = 1
    elif s == "WA" and acdic[p] <= 0:
        acdic[p] -= 1
print(account, wacount)

Measured memory_bytes: 9608
#include <iostream>
using namespace std;
int v[101][101];
int node[101][2];
int t=1;
int n;
int w[101];
int s,k;
int h[101][101];
int q[101];
void dfs(int i){
    for(int i=0;i<n;i++){
        v[i][0]=0;
    }
    for(int j=0;j<n;j++){
        
        if(v[i][j]!=0){
            if(w[j]==0){
                w[j]=w[i]+v[i][j];
                s=s+v[i][j];
                h[i][j]=v[i][j];
                v[i][j]=0;
                
                q[j]=i;
                dfs(j);
                v[i][j]=h[i][j];
                
            }else if(w[j]<=w[i]+v[i][j]){
                
            }else{
                s=s-v[q[j]][j]+v[i][j];
                w[j]=w[i]+v[i][j];
                h[i][j]=v[i][j];
                v[i][j]=0;
               
                q[j]=i;
                dfs(j);
                v[i][j]=h[i][j];
               
            }
            
            
        }
    }
}
int main(void){
    
    cin >> n;
    for(int i=0;i<n;i++){
        int x,y,z;
        cin>>x>>k;
        for(int j=0;j<k;j++){
            cin>>y>>z;
            v[x][y]=z;
        }
    }
        
    dfs(0);
    
   /*for(int i=1;i<=n;i++){
        for(int j=1;j<=n;j++){
            if(v[i][j]==1){
                dfs(i);
            }
        }
    }*/
    
    for(int i=0;i<n;i++){
        cout <<i << " " << w[i]<<endl;
    }
    

}



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

int main() {
    int N, M;
    cin >> N >> M;
    vector<int> H(N);
    for (int i = 0; i < N; i++) cin >> H[i];
    vector<vector<int>> next(N, vector<int>(0));
    for (int i = 0; i < M; i++) {
        int A, B;
        cin >> A >> B;
        A--;
        B--;
        next[A].push_back(B);
        next[B].push_back(A);
    }
    int ans = 0;
    for (int i = 0; i < N; i++) {
        int cnt = 0;
        for (auto j: next[i]) {
            if (H[j] < H[i]) cnt++;
        }
        if (cnt == next[i].size()) ans++;
    }
    cout << ans << endl;
    return 0;
}

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

#define Min(a,b) ((a)<(b)?(a):(b))

#define Max(a,b) ((a)>(b)?(a):(b))

#define ABS(a) ((a)>(0)?(a):-(a))

#define Rep(i,n) for(int (i)=0;(i)<(n);(i)++)

#define Rep2(i,bottom,ceiling) for(int (i)=(bottom);(i)<=(ceiling);(i)++)

void SwapInt(int* v1,int* v2){
	char sw = *v1;
    *v1=*v2;
    *v2=sw;
}

void SwapChar(char* v1,char* v2){
    char sw = *v1;
    *v1=*v2;
    *v2=sw;
}

int main(){ 
	int n,max=1;
	scanf("%d",&n);
	for(int i=2;pow(2,i)<=n;i++){ 
		int num=2;
		while(pow(num,i)<=n){ num++; }
		max=Max(max,pow(num-1,i));
	}
	printf("%d",max);
	return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <cmath>
#include <functional>
#include <iomanip>

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

// #define rep(i,n) for(int i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) for(int i=0;i<(n);++i)
#define repi(i,a,b) for(int i=(a);i<(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define _fromto2(i,n) for(int i=0;i<=(n);++i)
#define _fromto3(i,a,b) for(int i=(a);i<=(b);++i)
#define fromto(...) _overload3(__VA_ARGS__,_fromto3,_fromto2,)(__VA_ARGS__)

#define rrep(i,n) for(int i=(n);i>=0;--i)
#define iter(it,v) for(auto it=v.begin();it!=v.end();++it)
const int MOD = 1e9+7;
const int INF = 1e9;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

// debug
template<class T>ostream& operator<<(ostream& os, vector<T>& vec){os<<"{";for(int i=0;i<vec.size();++i)os<<(i?", ":"")<<vec[i];os<<"}";return os;}
template<class T1,class T2>ostream& operator<<(ostream& out,const pair<T1,T2>& rhs){out<<"("<<rhs.first<<", "<<rhs.second<<")";return out;}
#include<type_traits>
template<typename T,size_t SIZE,enable_if_t<!is_same<remove_cv_t<T>,char>::value,nullptr_t> = nullptr>ostream& operator<<(ostream& os,T(&arr)[SIZE]){os<<"{";for(size_t i=0;i<SIZE;++i)os<<(i?", ":"")<<arr[i];os<<"}";return os;}
#ifdef LOCAL
#define debug(v) cerr<<v<<"\n"
#else
#define debug(...) 42
#endif


const int MAX = 2e5+1;
long long fac[MAX], finv[MAX], inv[MAX];

void comb_init() {
  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 comb(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;
}


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

  vector<ll> A(N);
  rep(i, N) cin >> A[i];
  sort(A.begin(), A.end());

  ll sum[N+1];
  sum[0] = 0;
  rep(i, N)
    sum[i+1] = (sum[i] + A[i]) % MOD;

  ll ans = 0;
  if (K == 1) {
    cout << 0 << endl;
    return 0;
  }
  rep(l, K, N+1) {
    ans = (ans + (((sum[N] - sum[l-1]) - sum[N - l + 1]) * comb(l-2, K-2)) % MOD + MOD) % MOD;
  }
  cout << ans << endl;

  return 0;
}



Measured memory_bytes: 6528
def check(l, r, s, len)
  loop do
    if l - 1 >= 0 && r + 1 < len && s[l-1] == s[r+1]
      $rec << s[l..r] if r - l >= 2
    else break
    end
    l -= 1; r += 1
  end
  t = s[l..r]
  $ret << t if r - l >= 2 && !$rec.include?(t) && !$ret.include?(t)
end

while l = gets
  s = ''
  l.split('').each{|c| s += c.capitalize if c =~ /[a-zA-Z]/ }
  $ret = []
  len = s.size
  $rec = []
  (1..len-2).each do |c|
    check(c, c, s, len)
    check(c, c + 1, s, len) if s[c] == s[c+1]
  end
  $ret.each{ |s| $ret.delete(s) if $rec.include?(s) }
  puts $ret.join(' ')
end

Measured memory_bytes: 8824
import java.util.Scanner;
public class Main{
   public static  void main(String [] args){
       Scanner sc = new Scanner(System.in);
       double r=sc.nextDouble();
       double pi= Math.PI;
       double area = r*r*pi;
       double length = 2*r*pi;
       System.out.printf("%f %f",area,length);
   }
}


Measured memory_bytes: 28268
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<functional>
#include<map>
using namespace std;
#define inf 1000000009
#define int long long

signed main() {
	int a, b, c;
	cin >> a >> b >> c;
	if (a == b)cout << c << endl;
	else if (b == c)cout << a << endl;
	else cout << b << endl;
}

Measured memory_bytes: 764
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
#define int long long
constexpr long long INF = numeric_limits<long long>::max() / 2;
constexpr int MOD = 1000000007;
using Graph = vector<vector<int>>;



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

    int N;
    cin>>N;

    string S[N];
    map<string,int> m;
    rep(i,N){
        cin>>S[i];
        m[S[i]]++;
    }
    cout << "AC x " << m["AC"]<<endl;
    cout << "WA x " << m["WA"]<<endl;
    cout << "TLE x " << m["TLE"]<<endl;
    cout << "RE x " << m["RE"]<<endl;

    



}


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

main()
{
    int n,m;
    cin>>n>>m;
    vector<vector<int>> g(n);
    for(int i=0; i<m; ++i)
    {
        int a,b; cin>>a>>b; --a,--b;
        g[a].emplace_back(b);
        g[b].emplace_back(a);
    }
    queue<int> qu;
    qu.emplace(0);
    cout << "Yes" << "\n";
    vector<int> ans(n-1);
    vector<bool> flag(n);
    flag[0]=1;
    while(!qu.empty())
    {
        int f=qu.front(); qu.pop();
        for(int v : g[f])
        {
            if(flag[v]) continue;
            qu.push(v);
            flag[v]=1;
            ans[v-1]=f+1;
        }
    }
    for(int e:ans) cout<<e<<endl;
}

Measured memory_bytes: 10216
#include <bits/stdc++.h>
using namespace std;
#define fo(i,a,b) for (int i = (a); i < (b); i++)
#define FO(i,a,b) for (int i = (a); i < (b); i++)
#define fo2(i,a,b) for (i = (a); i < (b); i++)
#define pb push_back
#define eb emplace_back
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;

ll dx[] = {0,1,0,-1};
ll dy[] = {-1,0,1,0};
int n, ut[4], ov[4], v[4];
ll d, s, t, x, y, o[4][40], cum[4][40];
ll xx[40], yy[40];
int main() {
    scanf("%d %lld %lld %lld", &n, &d, &s, &t);
    fo(i,0,n) {
        scanf("%lld %lld", &x, &y);
        xx[i] = x; yy[i] = y;
        if (x == -d) o[0][ut[0]++] = -y;
        else if (y == -d) o[1][ut[1]++] = x;
        else if (x == d) o[2][ut[2]++] = y;
        else o[3][ut[3]++] = -x;
    }
    fo(i,0,4) {
        sort(o[i], o[i]+ut[i]);
        fo(j,0,ut[i]) {
            cum[i][j] = o[i][j];
            if (j) cum[i][j] += cum[i][j-1];
        }
    }

    ll ans = 1e18;
    fo2(ov[0],0,n+1) fo2(ov[1],0,n+1) fo2(ov[2],0,n+1) fo2(ov[3],0,n+1) {
        fo(i,0,4) v[i] = ov[i];

        int cnt[4];
        fo(i,0,4) cnt[i] = ut[i];
        fo(i,0,8) {
            int ii = i%4;
            int mv = min(v[ii], cnt[ii]);
            v[ii] -= mv;
            cnt[ii] -= mv;
            cnt[(ii+1)%4] += mv;
        }
        int g = 1;
        fo(i,0,4) if (v[i]) g = 0;
        if (!g) continue;

        ll tans = n;
        ll ts = s, tt = t;
        fo(i,0,n) {
            ts -= xx[i];
            tt -= yy[i];
        }

      /*  fo(i,0,8) {
            int ii = i%4;
            while (v[ii] && !ss[ii].empty()) {
                v[ii]--;
                ll num = *ss[ii].rbegin();
                ss[ii].erase(ss[ii].find(num));
                tans += d - num;
                ts -= dx[ii] * (d - num);
                tt -= dy[ii] * (d - num);
                ss[(ii+1)%4].insert(-d);
            }
        }
        int g = 1;
        fo(j,0,4) if (v[j]) g = 0;
        if (!g) continue;
       */
//        printf("%d %d %d %d\n", ov[0], ov[1], ov[2], ov[3]);

        ll sum[4] = {0,0,0,0};
        fo(i,0,4) {
            int ovout = ov[i], ovin = ov[(i+3)%4];
            int bal = ut[i] + ovin - ovout;
            int keep = max(0, ut[i] - ovout);
            if (keep) {
                sum[i] += d*keep - cum[i][keep-1];
            }
            sum[i] += 2*d* min(bal, ovin);

            int origout = min(ovout, ut[i]);
            ll mv = 0;
            if (origout) {
                mv += d*origout - (cum[i][ut[i] - 1] - (origout==ut[i] ? 0 : cum[i][ut[i] - 1 - origout]));
            }
            mv += 2*d * max(0, ovout - ut[i]);
            tans += mv;

            ts -= dx[i] * mv;
            tt -= dy[i] * mv;

            assert(keep + origout == ut[i]);
        }

  //      fo(i,0,4) printf("%lld\n", sum[i]);

        if (tt < 0 && abs(tt) > sum[0]) continue;
        if (tt > 0 && tt > sum[2]) continue;
        if (ts < 0 && abs(ts) > sum[3]) continue;
        if (ts > 0 && ts > sum[1]) continue;

        tans += abs(ts) + abs(tt);

        ans = min(ans, tans);
    }
    printf("%lld\n", ans);

    return 0;
}

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

bool isValid(string str, int len) 
{ 
    for (int i = 1; i < len; i++) { 
        if (str[i] == str[i - 1]) 
            return false; 
    } 
  
 
    return true; 
} 

int main() 
{ 
    string str;
    cin>>str;
    int len = str.length(); 
  
    if (isValid(str, len)) 
        cout << "Good"; 
    else
        cout << "Bad"; 
  
    return 0; 
} 

Measured memory_bytes: 256
import sys,queue,math,copy,itertools,bisect,collections,heapq
sys.setrecursionlimit(10**7)
INF = 10**18
MOD = 10**9 + 7
LI = lambda : [int(x) for x in sys.stdin.readline().split()]
NI = lambda : int(sys.stdin.readline())

N,M = LI()
island = [0 for _ in range(N)]
req = [[] for _ in range(N)]
for _ in range(M):
    a,b = LI()
    req[a-1].append(b-1)

p = 1
ans = 0
for i in range(N):
    if island[i] > p:
        ans += 1
        p = island[i]
    for b in req[i]:
        island[b] = p+1
print (ans)




Measured memory_bytes: 55596
N = int(input())
A = list(map(int,input().split()))
# print('A:',A)
money=1000
kabu=0

for i in range(N-1):
    if A[i] < A[i+1]:
        kabu+=money // A[i]
        money=money % A[i]
    elif A[i] > A[i+1]:
        money+=kabu*A[i]
        kabu=0
money+=kabu*A[N-1]  #last

print(money)            


Measured memory_bytes: 61764
#include<cstdio>
#include<cctype>

int main(){
	int counter[26];
	char ch;

	for (int i = 0; i < 26; i++)
		counter[i] = 0;

	while (scanf("%c", &ch) != EOF){
		ch = tolower(ch);
		if (isalpha(ch))
			counter[ch - 'a']++;
	}

	for (int i = 0; i < 26; i++)
		printf("%c : %d\n", i + 'a', counter[i]);
	
	return 0;
}

Measured memory_bytes: 984
//#include <bits/stdc++.h>
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <queue>
#include <deque>
#include <set>
#include <stack>
#include <time.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;

const ll nmax = 1e9 + 7;
const ll Mod = 998244353;
const double PI = 2 * asin(1);

ll Pow(ll A, ll B, ll mod){
  if (B == 0) return 1;
  else{
    if (B % 2 == 0){
      return Pow(A * A % mod, B / 2, mod) % mod;
    }else{
      return A * Pow(A * A % mod, B / 2, mod) % mod;
    }
  }
}

ll nCr(ll N, ll C, ll mod){
  ll ans = 1; C = min(C, N - C);
  for (ll i = 1; i <= C; i++){
    ans *= N - i + 1; ans %= mod;
    ans *= Pow(i, mod - 2, mod); ans %= mod;
  }
  return ans;
}

bool compare(string A, string B){
  if (A.length() < B.length()){
    return false;
  }else{
    bool ans = true;
    for (ll i = 0; i < B.length(); i++){
      if (A[i] != B[i]) ans = false;
    }
    return ans;
  }
}

int main(){

  string S; cin >> S;
  string T = "";
  for (int i = S.length() - 1; i >= 0; i--){
    T = T + S[i];
  }

  string cand[4] = {"maerd", "remaerd", "esare", "resare"};

  string ans = "YES";
  while (T.length() > 0){
    bool flag = false;
    for (int i = 0; i < 4; i++){
      if (compare(T, cand[i])){
        flag = true;
        T = T.substr(cand[i].length());
        break;
      }
    }

    if (flag == false){
      ans = "NO";
      break;
    }
  }
  cout << ans << endl;
  

  return 0;
}


Measured memory_bytes: 696
n = gets.to_i
n.times do
    r, t = gets.split.map(&:to_i)
    if r % 100 == 0 and t % 30 == 0
        puts (t / 30) * 5 + (r / 100)
    elsif r % 100 > 0 and t % 30 == 0
        puts [(t / 30) * 5 + (r / 100), (t / 30) * 5 + (r / 100) + 1] * ' '
    elsif r % 100 == 0 and t % 30 > 0
        puts [(t / 30) * 5 + (r / 100), (t / 30 + 1) * 5 + (r / 100)] * ' '
    else
        puts [(t / 30) * 5 + (r / 100), (t / 30) * 5 + (r / 100) + 1, (t / 30 + 1) * 5 + (r / 100), (t / 30 + 1) * 5 + (r / 100) + 1] * ' '
    end
end


Measured memory_bytes: 6876
import sys
import heapq
import re
from itertools import permutations
from bisect import bisect_left, bisect_right
from collections import Counter, deque
from math import factorial, sqrt, gcd
from functools import lru_cache, reduce
INF = 1 << 60
mod = 1000000007
sys.setrecursionlimit(10 ** 7)

# UnionFind
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

# ダイクストラ
def dijkstra_heap(s, edge, n):
    #始点sから各頂点への最短距離
    d = [10**20] * n
    used = [True] * n #True:未確定
    d[s] = 0
    used[s] = False
    edgelist = []
    for a,b in edge[s]:
        heapq.heappush(edgelist,a*(10**6)+b)
    while len(edgelist):
        minedge = heapq.heappop(edgelist)
        #まだ使われてない頂点の中から最小の距離のものを探す
        if not used[minedge%(10**6)]:
            continue
        v = minedge%(10**6)
        d[v] = minedge//(10**6)
        used[v] = False
        for e in edge[v]:
            if used[e[1]]:
                heapq.heappush(edgelist,(e[0]+d[v])*(10**6)+e[1])
    return d

# 素因数分解
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

# 2数の最小公倍数
def lcm(x, y):
    return (x * y) // gcd(x, y)

# リストの要素の最小公倍数
def lcm_list(numbers):
    return reduce(lcm, numbers, 1)

# リストの要素の最大公約数
def gcd_list(numbers):
    return reduce(gcd, numbers)

# ここから書き始める
n = int(input())
ans = 0
for i in range(1, n + 1):
    if i % 3 != 0 and i % 5 != 0:
        ans += i
print(ans)

Measured memory_bytes: 9988
import java.util.*;

class Main{
   public static void main(String arg[]) throws java.io.IOException{
       Scanner scan =new Scanner (System.in);
      boolean [] cup = new boolean [3];
      cup[0]=true;
       while(scan.hasNext()){
    	   char[] a = scan.next().toCharArray();
    	   int f =a[0]-'A';
    	   int s =a[2] -'A';
    	   cup[f]=cup[f]^cup[s];
    	   cup[s]=cup[f]^cup[s];
    	   cup[f]=cup[f]^cup[s];
       }
       for(int i=0;i<3;i++)
    	   if(cup[i])System.out.println((char)(i+'A'));
   }
}
       

Measured memory_bytes: 12000
#include <iostream>
using namespace std;
int main(){
    int r,d;
    int x[3000];
    cin >> r >> d >> x[2000];
    for(int i=1;i<11;i++){
        x[2000+i] = x[1999+i]*r-d;
        cout << x[2000+i] << endl;
    }
    return 0;
}

Measured memory_bytes: 256
n, m, k = map(int, input().split())

A = list(map(int, input().split()))
B = list(map(int, input().split()))

a = [0] * (n + 1)
b = [0] * (m + 1)

for i in range(1, n + 1):
    a[i] = A[i - 1] + a[i - 1]

for j in range(1, m + 1):
    b[j] = B[j - 1] + b[j - 1]

ans = 0
num_b = m

for i in range(n + 1):
    if a[i] > k:
        break
    for j in range(num_b, -1, -1):
        if b[j] <= k - a[i]:
            break
        num_b -= 1
    ans = max(ans, i + j)

print(ans)

Measured memory_bytes: 47560
#include <stdio.h>
#include <vector>
#include <string.h>
#include <algorithm>
#include <map>
#include <string>
#include <deque>

#pragma warning(disable:4996)
#define MAX_N 100

int main(void) {
	int n;
	scanf("%d", &n);
	printf("%d", (n - 2) * 180);
	return 0;
}

Measured memory_bytes: 128
// https://atcoder.jp/contests/abc174/tasks/abc174_b
#include <bits/stdc++.h>
using namespace std ;
int main() {
    long long n , d , counter = 0 ;
    cin >> n >> d ;
    long long x , y ;
    while (n--)
    {
        cin >> x >> y ;
        if (x < 0 ) x *= -1 ;
        if (y < 0 ) x *= -1 ;
        double di =  sqrt( (x * x) + (y * y) ) ;
        long long dis = ceil(di) ;
        //cout << dis << endl ;
        if (dis <= d) counter++ ;
    }
    cout << counter << endl ;
}

Measured memory_bytes: 3740
import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		char[] S = sc.next().toCharArray();
		int min = S.length;
		int max = 0;
		for(int i = 0; i < S.length; i++) {
			if(S[i] == 'A' && min > i) min = i;
			else if(S[i] == 'Z' && max < i) max = i; 
		}
		System.out.println(max - min + 1);
	}
}

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

a_i = max(a)
half = a_i/2

best = a_i*2
for j in a:
    if j==a_i:
        continue

    diff = abs(j-half)
    if diff < best:
        best = diff
        a_j = j

print(a_i, a_j)

Measured memory_bytes: 14052
#include<cstdio>
#include<cstring>
#include<cmath>
#include<bitset>
#include<iostream>
#include<algorithm>
#include<string>
#include<utility>
#include<tuple>
#include<vector>
#include<list>
#include<map>
#include<queue>
#include<stack>
#include<numeric>
#include<functional>
#include<iomanip>

#define IOS ios::sync_with_stdio(false),cin.tie(0)
#define REP(i,n) for(int i = 0;i < n;i++)
#define MEM(a,b) memset(a,b,sizeof(a))

using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;

int gcd(int a, int b) {
	if (a < b)swap(a, b);
	int k = a % b;
	if (k == 1)return 1;
	if (k == 0)return b;
	int ans = gcd(b, k);
	return ans;
}
int a[114514];
int dp[55][10010];
int main() {
	IOS;
	ll a[4];
	REP(i, 4)cin >> a[i];
	ll n;
	cin >> n;
	ll ans;
	ll use1 = min(min(4 * a[0],2 * a[1]), a[2]);
	if (use1 * 2 <=  a[3]) {
		ans = n * use1;
	}
	else {
		if (n % 2 == 1)ans = (n / 2)* a[3] + use1;
		else ans = (n / 2) * a[3];
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

var sc = bufio.NewScanner(os.Stdin)

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func nextLine() string {
	sc.Scan()
	return sc.Text()
}

var slice []int

func main() {
	sc.Split(bufio.ScanWords)

	slice = make([]int, 4)

	for i, n := range strings.Split(nextLine(), "") {
		slice[i], _ = strconv.Atoi(n)
	}

	// fmt.Println(slice)

	if ok, ans := dfs(0, 0, ""); ok {
		fmt.Println(ans[1:len(ans)])
	}

}

func dfs(i, sum int, ex string) (bool, string) {

	if i == 4 {
		return sum == 7, "=7"
	}

	// "+"を使う場合
	if ok, s := dfs(i+1, sum+slice[i], "+"); ok {
		return true, "+" + strconv.Itoa(slice[i]) + s
	}

	// "-"を使う場合
	if ok, s := dfs(i+1, sum-slice[i], "-"); ok {
		return true, "-" + strconv.Itoa(slice[i]) + s
	}

	return false, ""
}


Measured memory_bytes: 640
//
//  main.c
//  Dirichlet's Theorem on Arithmetic Progressions
//
//  Created by x15071xx on 2016/06/06.
//  Copyright ?? 2016??´ AIT. All rights reserved.
//
//dm+a=n
//n???d??§?????£???a?????????&&?´???°?????°
#include <stdio.h>
#include <math.h>
#define NUM 1000000

int main(int argc, const char * argv[]) {
    
    int a,d,n,i,j;
    int hurui[NUM] = {0},count_n = 0;
    
    for (i=0; i<=NUM; i++) {
        hurui[i]=1;
    }
    hurui[1]=0;
    
    for (i=2; i<= sqrt(NUM); i++) {
        if (hurui[i] == 1) {
            for(j = 2 * i; j <= NUM; j += i)
                hurui[j] = 0;
            
        }
    }
    
    while (1) {
        
        scanf("%d %d %d",&a,&d,&n);
        
        if(a==0&&d==0&&n==0){
            break;
        }
        
        for (i = a; i < NUM; i+=d) {
            if (hurui[i] == 1) {
                count_n++;
                if (count_n==n) {
                    printf("%d\n",i);
                    break;
                }
            }
        }
        count_n=0;
        
    }
    return 0;
}

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

using namespace std;

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

    int maxL = 0, minR = n;
    for(int i=0;i<m;i++){
        int l, r;
        cin >> l >> r;
        maxL = max(maxL, l);
        minR = min(minR, r);
    }

    if(maxL <= minR){
        cout << minR - maxL + 1<< endl;
    }else{
        cout << 0 << endl;
    }
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdint>
#include <vector>
#include <queue>
#include <algorithm>

int main() {
  size_t n, m;
  scanf("%zu %zu", &n, &m);

  intmax_t res = 0;
  std::priority_queue<intmax_t> pq;
  for (size_t i = 0; i < n; ++i) {
    intmax_t a;
    scanf("%jd", &a);
    pq.push(a);
    res += a;
  }

  while (m-- && !pq.empty()) {
    intmax_t a = pq.top();
    pq.pop();
    res -= a - (a >> 1);
    if (a > 1) pq.push(a >> 1);
  }

  printf("%jd\n", res);
}


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

int main(){
  int n;
  cin>>n;
  vector<int> a(n);
  rep(i,n) cin>>a[i];
  int ans=0;
  rep(i,n){
    if(i%2==1) continue;
    if(a[i]%2==1) ans++;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 3620
import java.util.Scanner;

public class Main {

	@SuppressWarnings("resource")
	public static void main(String args[]) {
		Scanner scanner = new Scanner(System.in);
		int n = scanner.nextInt();
		
		int ans=0;
		for(int i=1;i<=n;i+=2){
			int cnt=0;
			for(int j=i;j>0;j--){
				if(i%j==0)cnt++;
			}
			if(cnt==8)ans++;
		}
		
		System.out.println(ans);
	}
}


Measured memory_bytes: 22736
from collections import deque
n, q = map(int, input().split())
f = lambda a, b: (a, int(b))
dq = deque(f(*input().split()) for _ in range(n))
cnt = 0
ans = []
while dq:
    s, t = dq.popleft()
    if t <= q:
        cnt += t
        ans.append(f"{s} {cnt}")
    else:
        cnt += q
        dq.append((s, t - q))
print(*ans, sep="\n")



Measured memory_bytes: 13392
import java.util.HashSet;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int n = scanner.nextInt();
		HashSet<Integer> set = new HashSet<>();
		int count = 0;
		for(int i=0;i<n;i++){
			int x = scanner.nextInt();
			if(x < 3200){
				set.add(x/400);
			}else{
				count++;
			}
		}
		int min = Math.max(set.size(),1);

		int max = set.size()+count;
		System.out.println(min + " " + max);
	}

}


Measured memory_bytes: 21076
#include <bits/stdc++.h>
using namespace std;
#define ll long long 
ll gcd(ll x,ll y)
{
		return x>0?gcd(y%x,x):y;
}
int main()
{
	
	int t;
	cin>>t;
	ll m=1;
	while(t--)
	{
		ll l;
		cin>>l;			
		m=((m/gcd(m,l)*l));
	}
	cout<<m;
	return 0;
	
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		String s=sc.nextLine();
		int cnt=0, ans=0;
		for(char c: s.toCharArray()) {
			if(c=='A' || c=='C' || c=='G' || c=='T')
				cnt++;
			else
				cnt=0;
			ans=Math.max(cnt, ans);
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 23636
#include<stdio.h>
#define N 100
#define WHITE 0
#define GRAY 1
#define BLACK 2

int n, M[N][N];
int color[N], d[N], f[N], tt;

void dfs_visit(int u)
{
  int v;
  color[u] = GRAY;
  d[u] = ++tt;
  for ( v = 0; v < n; v++ )
    {
      if(M[u][v] == 0 ) continue;
      if(color[v] == WHITE)
	{
	  dfs_visit(v);
	}
    }
  color[u] = BLACK;
  f[u] = ++tt;
}

void dfs()
{
  int u;
  for (u = 0; u < n; u++ )color[u] = WHITE;
  tt = 0;

  for(u = 0; u < n; u++)
    {
      if(color[u] == WHITE)dfs_visit(u);
    }
  for(u = 0; u < n; u++)
    {
      printf("%d %d %d\n", u + 1, d[u], f[u]);
    }
}

int main()
{
  int u, v, k, i, j;

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

  for(i = 0; i < n; i++)
    {
      scanf("%d %d", &u, &k);
      u--;
      for(j = 0; j < k; j++)
	{
	  scanf("%d", &v);
	  v--;
	  M[u][v] = 1;
	}
    }

  dfs();

  return 0;
}

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

#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)

int N, F[101][11], P[101][11];
#define INF INT_MAX/2

int main(){
   
   cin >> N;
    rep(i, 0, N) rep(j, 0, 10) cin >> F[i][j];
    rep(i, 0, N) rep(j, 0, 11) cin >> P[i][j];
 
    int ans = -INF;
    rep(msk, 1, 1 << 10) {
        int sm = 0;
        rep(i, 0, N) {
            int c = 0;
            rep(j, 0, 10) if (msk & (1 << j)) if (F[i][j]) c++;
            sm += P[i][c];
        }
        ans = max(ans, sm);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
/* Note:
Check constants at the beginning of the code.
    N is set to 4e5 but be careful in problems with large constant factor.
    Setting N in every problem is more effective.
Check corner cases.
    N = 1
No def int long long for now.
Add something here.'p

*/
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define MAX 10000

using namespace std;
typedef long long ll;

int main(){

 int a[3];

 for(int i=0;i<3;i++)
    cin>>a[i];

 sort(a,a+3,greater<int>());

 if(a[0] == a[1]+a[2])
    cout<<"Yes"<<endl;
 else
    cout<<"No"<<endl;

 return 0;
 }


Measured memory_bytes: 3572
#include<stdio.h>
#include<math.h>

int main(void)
{
	int n;
	int x[100], y[100];
	int i;
	double D1 = 0, D2 = 0, D3 = 0, D4 = 0;

	scanf("%d", &n);
	for (i = 0; i < n; i++)
	{
		scanf("%d", &x[i]);
	}
	for (i = 0; i < n; i++)
	{
		scanf("%d", &y[i]);
	}
	/*ミンコフスキー距離　p=1の時*/
	for (i = 0; i < n; i++)
	{
		D1 = D1 + abs(x[i] - y[i]);
	}
	/*ミンコフスキー距離　p=2の時*/
	for (i = 0; i < n; i++)
	{
		D2 = D2 + pow(x[i] - y[i], 2.0);
	}
	D2 = pow(D2, 1 / 2.0);
	/*ミンコフスキー距離　p=3の時*/
	for (i = 0; i < n; i++)
	{
		D3 = D3 + pow(abs(x[i] - y[i]), 3.0);
	}
	D3 = pow(D3, 1 / 3.0);
	/*ミンコフスキー距離　p=∞の時*/
	for (i = 0; i < n; i++)
	{
		if (D4 < abs(abs(x[i] - y[i])))
		{
			D4 = abs(x[i] - y[i]);
		}
	}

	printf("%f\n%f\n%f\n%f\n", D1, D2, D3, D4);
	return 0;
}


Measured memory_bytes: 2112
#include<stdio.h>
int main(){
   int N;
   char S[N];
   scanf("%d",&N);
   scanf("%s",S);
   int count=0;
    for(int i = 0; i < N - 2; i++){
           if (S[i] == 'A' && S[i+1] == 'B' && S[i+2] == 'C'){
              count++;
           }
        }
   
    printf("%d",count);
    return 0;
}


Measured memory_bytes: 1708
s = input()

while s:
    if s[:6] == "eraser":
        s = s[6:]
    elif s[:5] == "erase":
        s = s[5:]
    elif s[:5] == "dream":
        if s[5:8] == "era":
            s = s[5:]
        elif s[5:7] == "er":
            s = s[7:]
        else:
            s = s[5:]
    else:
        print("NO")
        exit()
print("YES")

Measured memory_bytes: 3244
#include <bits/stdc++.h>
using namespace std;
int a[123];
int main()
{
	int n,k,sum=0;
	cin>>n>>k;
	for(int i=1;i<=n;i++)
	{
	   cin>>a[i];
	   if(a[i]>k*1.0/2) sum+=(k-a[i])*2;
	   else sum+=a[i]*2;//一定要乘2，机器人要回来！ 
    }
    cout<<sum;
	return 0;
}

Measured memory_bytes: 256
s = input().rstrip().split(' ')
costa = int(s[0])
costb = int(s[1])
costc = int(s[2])
needa = int(s[3])
needb = int(s[4])
mini = min(needa, needb)
maxi = max(needa, needb)
lst = []
total = costa * needa + costb * needb
totala = costa * needa + costb * needb
totalb = costc * maxi * 2
for i in range(mini+1):
  temp = costa * (needa - i) + costb * (needb - i) + costc * i * 2
  if total > temp:
    total = temp
lst.append(total)
lst.append(totala)
lst.append(totalb)
mintotal = min(lst)
print(mintotal)


Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
	Scanner scan = new Scanner(System.in);
		int n = scan.nextInt(); // ??´??°?????° n
		int min     = 1000000;
        	int max     = -1000000;
        	long sum   = 0;
		for(int i = 0;i < n;i++){
			int num = scan.nextInt(); // ??´??°??\???
			sum += num;
			if(min > num){min = num;}
			if(max < num){max = num;}
		}
	System.out.println(min + " " + max + " " + sum);
	}
}

Measured memory_bytes: 42372
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<iostream>
#include<queue>
#include<algorithm>
#include <functional>
#include<vector>
using namespace std;

const int N_MAX = 101;

int main() {
	int N, max_h;
	int H[N_MAX];
	int ans = 0;
	cin >> N;
	for (int i = 0; i < N; i++) cin >> H[i];
	max_h = H[0];
	ans++;

	for (int i = 1; i < N; i++) {
		if (max_h <= H[i]) {
			max_h = H[i];
			ans++;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
    int n,q;
    cin >> n;
    int s[n];
    int c=0;
    for(int i=0;i<n;i++){
        cin >> s[i];
    }
    cin >>q;
    int t[q];
    for(int i=0;i<q;i++){
        cin >> t[i];
    }
    sort(t,t+q);
    int left=0,right,mid;
    for(int i=0;i<q;i++){
        right=n-1;
        mid=(left+right)/2;
        while(left<=right){
            if(s[mid]==t[i]){
                c++;
                break;
            }else if(t[i]<s[mid]){
                right=mid-1;
            }else{
                left=mid+1;
            }mid=(left+right)/2;
        }
    }
    cout << c << endl;
}


Measured memory_bytes: 3732
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#include<map>
#include<iomanip>
#include<queue>
#include<stack>
#include<time.h>
#define rep(i,n)for(int i=0;i<n;i++)
#define int long long
#define ggr getchar();getchar();return 0;
#define prique priority_queue
#define mod 1000000007
#define inf 1e15
using namespace std;
typedef pair<int, int>P;
void yes() { cout << "Yay!" << endl; }
void no() { cout << ":(" << endl; }
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x / gcd(x, y) * 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) {
		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;
}
struct edge { int to, cost; };
int n;
int a[114514];
signed main() {
	cin >> n;
	rep(i, n)cin >> a[i];
	sort(a, a + n);
	reverse(a, a + n);
	int ans = 0;
	rep(i, n) {
		ans += (a[i] - (i + 1));
	}
	cout << ans << endl;
	ggr
}



Measured memory_bytes: 3924
#include <bits/stdc++.h>
#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 all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << (x) << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){
	return o<<"("<<p.fs<<","<<p.sc<<")";
}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){
	o<<"{";
	for(const T& v:vc) o<<v<<",";
	o<<"}";
	return o;
}
using ll = long long;
template<class T> using V = vector<T>;
template<class T> using VV = vector<vector<T>>;

int N,D;
int cnt[1000][1000];

int s0[2010][2010];
int s2[2010][2010];

int Count(int a,int b,int c,int d,int t){
	if(t==0){
		return s0[c][d] - s0[a][d] - s0[c][b] + s0[a][b];
	}else{
		return s2[c][d] - s2[a][d] - s2[c][b] + s2[a][b];
	}
}

int solve(VV<int>& A){
	int N = A.size();
	// puts("----------A---------");
	// rep(i,N){
	// 	rep(j,N) cout<<A[i][j];
	// 	puts("");
	// }
	// puts("-----------------------");

	int num0 = 0, num2 = 0;
	rep(i,D) rep(j,D){
		if(A[i][j]==0) num0++;
		if(A[i][j]==2) num2++;
	}

	int V = D+D;
	rep(i,V) rep(j,V){
		s0[i+1][j+1] = (A[i%D][j%D]==0);
		s2[i+1][j+1] = (A[i%D][j%D]==2);
	}
	rep(i,V+1) rep(j,V) s0[i][j+1] += s0[i][j], s2[i][j+1] += s2[i][j];
	rep(j,V+1) rep(i,V) s0[i+1][j] += s0[i][j], s2[i+1][j] += s2[i][j];

	int ub = D+1, lb = -1;
	while(ub-lb>1){
		int L = (ub+lb)/2;
		bool can = false;

		rep(i,D) rep(j,D){
			if(Count(i,j,i+L,j+L,2) == num2 
			&& Count(i+L,j+L,i+N,j+N,0) == (N-L)*(N-L)){
				can = true;
			}
		}

		if(can) ub = L;
		else lb = L;
	}
	return ub;
}

int main(){
	cin>>N>>D;
	rep(i,N){
		int x,y;
		cin>>x>>y;
		cnt[x%D][y%D]++;
	}
	int cntmax = 0;
	rep(i,D) rep(j,D) chmax(cntmax,cnt[i][j]);
	int A = 0;
	while(A*A<cntmax) A++;
	VV<int> a(D,V<int>(D,0));
	rep(i,D) rep(j,D){
		if(cnt[i][j]<=(A-1)*(A-1)) a[i][j] = 0;
		else if(cnt[i][j]<=(A-1)*A) a[i][j] = 1;
		else a[i][j] = 2;
	}
//	show(cntmax);
//	show(A);
	cout<<(A-1)*D+solve(a)-1<<endl;
}

Measured memory_bytes: 39680
#include <bits/stdc++.h>
#define meow(args...) fprintf(stderr, args)
typedef unsigned u32;
typedef long long s64;
typedef unsigned long long u64;
template<class T1, class T2> inline bool cmin(T1 &a, const T2 &b) {return b<a?(a=b, true):false;}
template<class T1, class T2> inline bool cmax(T1 &a, const T2 &b) {return a<b?(a=b, true):false;}
const u32 P=1e9+7;
inline u32 &inc(u32 &a, u32 b) {return (a+=b)<P?a:(a-=P);}
inline u32 &dec(u32 &a, u32 b) {return (a-=b)&0x80000000?(a+=P):a;}
inline u32 sum(u32 a, u32 b) {return (a+=b)<P?a:a-P;}
inline u32 dif(u32 a, u32 b) {return (a-=b)&0x80000000?a+P:a;}
u64 power(u64 a, int b) {
	u64 ans=1;
	for(; b; a=a*a%P, b/=2) if(b&1) ans=ans*a%P;
	return ans;
}

int n, k, rcnt, f[70];
u32 ans, c[500][500], fac[500], inv[500];
char s[71];
void search(int len, int last, int sum) {
	if(len>rcnt) return;
	int r=0, nz=0, b=0, a=0;
	while(nz<len&&f[nz]==0) ++nz;
	nz=len-nz;
	for(int i=0; i<k&&(b!=nz||a!=0); ++i) {
		if(s[i]=='r') if(r<len) ++r; else if(a) --a;
		if(s[i]=='b') if(b<r&&b<nz) ++b, a+=f[len-b]-1; else if(a) --a;
	}
	if(b==nz&&a==0) {
		int fsum=len;
		u64 q=fac[len];
		for(int i=0, j; i<len; ++i) {
			fsum+=f[i];
			if(i==0||f[i]!=f[i-1]) j=0;
			q=q*inv[++j]%P;
		}
		ans=(ans+q*c[n+1+2*nz][2*fsum])%P;
		if(sum) {
			int &F=f[len];
			for(F=last; F<=sum; ++F) search(len+1, F, sum-(F?F:1));
		}
	}
}
int main() {
	for(int i=0; i<500; ++i) {
		c[i][0]=c[i][i]=1;
		for(int j=1; j<i; ++j) c[i][j]=sum(c[i-1][j-1], c[i-1][j]);
	}
	fac[0]=1;
	for(int i=1; i<500; ++i) fac[i]=(u64)fac[i-1]*i%P;
	inv[1]=1;
	for(int i=2; i<500; ++i) inv[i]=(u64)(P-P/i)*inv[P%i]%P;
	assert(scanf("%d%d%s", &n, &k, s)==3);
	rcnt=std::count(s, s+k, 'r');
	search(0, 0, (n+1)/2);
	printf("%u\n", ans);
	return 0;
}


Measured memory_bytes: 1280
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

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

    static class AHarmony {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            long a = in.nextLong();
            long b = in.nextLong();
            if ((a + b) % 2 == 0) {
                out.println((a + b) / 2);
            } else {
                out.println("IMPOSSIBLE");
            }
        }

    }
}



Measured memory_bytes: 21844
program main
implicit None
	integer(8)::n,a,b
	
	read *,n
	
	if (n == 1)then
		print 101,"Hello World"
	endif
	
	if (n == 2)then
	read *,a
	read *,b
	print 102,a+b
	endif
	
101 format(a)
102 format(i0)
end program main

Measured memory_bytes: 768
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        while(true) {
            int n = sc.nextInt();
            int x = sc.nextInt();
            if(n==0&&x==0)break;
            int answer = 0;
            for (int i = 1; i <= n; i++) {
                for (int j = i + 1; j <= n && i + 2 * j + 1 <= x; j++) {
                    if (j <= x - i - j && x - i - j <= n) answer++;
                }
            }
            System.out.println(answer);
        }
    }
}



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

int main()
{
  int a, s, d;
  cin>>a>>s>>d;
  int j, k;
  if(a<s)
    j = s - a;
  else
    j = a - s;
  if(a<d)
    k = d - a;
    else
      k = a - d;

    if(j<=k)
      cout << 'A' << endl;
      else
        cout << 'B' << endl;
}



Measured memory_bytes: 256
#include <stdio.h>
int main(void)
{
	int a1,a2,a3,a4;
	int b1,b2,b3,b4;
	int s,t;
	
	scanf("%d %d %d %d",&a1,&a2,&a3,&a4);
	scanf("%d %d %d %d",&b1,&b2,&b3,&b4);
	
	s=a1+a2+a3+a4;
	t=b1+b2+b3+b4;
	
	printf("%d\n",(s>t)?s:t);
	
	return 0;
}

Measured memory_bytes: 592
from collections import Counter
from itertools import product


def solve(LIST):
    stmp = [i for i, li in enumerate(LIST * 2) if li == 1]
    S = min(stmp[i] - stmp[i - 1] for i in range(1, len(stmp)))
    return S


n = int(input())
d = Counter(list(map(int, input().split())) + [0])

if any(d[num] > (2 - (num in {0, 12})) for num in d):
    print(0)
    exit()

ans, cnt = [0] * 24, []
for num in d:
    if (num in {0, 12}) and d[num] == 1:
        ans[num] = 1 
    elif d[num] == 2:
        ans[num], ans[24 - num] = 1, 1
    elif d[num] == 1:
        cnt.append(num)

s = 0
if len(cnt) == 0:
    s = max(s, solve(ans))
for bit in product([1, -1], repeat=len(cnt)):
    tmp = ans[:]
    for bi, ci in zip(bit, cnt):
        tmp[(ci - 12) * bi + 12] = 1
    s = max(s, solve(tmp))
print(s)


Measured memory_bytes: 76920