akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

#define int long long
#define double long double

const int INF=2147483647;
const int MOD=1000000007;
const int mod=998244353;
const double eps=1e-18;

using namespace std;

int C[4001][4001];

int H(int n,int k){
    return C[n+k-1][k];
}

signed main(){

    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    int s;
    int res;

    C[0][0]=1;

    for(int i=1;i<4001;i++){
        C[i][0]=1;
        for(int j=1;j<i;j++){
            C[i][j]=(C[i-1][j]+C[i-1][j-1])%MOD;
        }
        C[i][i]=1;
    }

    cin>>s;
    if(s<3){
        cout<<0<<endl;
        return 0;
    }

    res=0;
    for(int i=1;s-(3*i)>=0;i++){
        res+=H(i,s-(3*i));
        res%=MOD;
    }

    cout<<res<<endl;

    return 0;
}


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

int N,a[600],ans[250010]; bool v[250010];

int get_next(int pos, int delta){
    while (ans[pos]>0) pos+=delta;
    return pos;
}

int main(){
    cin >> N;

    int i,j;
    for (i=1; i<=N; i++){
        cin >> a[i];
        ans[a[i]]=i;
        v[a[i]]=1;
    }

    int ind=get_next(1,1);
    for (i=1; i<=N*N; i++)
        if (v[i]){
            for (j=1; j<ans[i]; j++){
                if (ind>i){
                    cout << "No\n";
                    return 0;
                }
                ans[ind]=ans[i];
                ind=get_next(ind,1);
            }
        }

    ind=get_next(N*N,-1);
    for (i=N*N; i>0; i--)
        if (v[i]){
            for (j=1; j<=N-ans[i]; j++){
                if (ind<i){
                    cout << "No\n";
                    return 0;
                }

                ans[ind]=ans[i];
                ind=get_next(ind,-1);
            }
        }

    cout << "Yes\n";
    for (i=1; i<=N*N; i++)
        cout << ans[i] << " ";


    return 0;
}


Measured memory_bytes: 2304
#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define eb 			emplace_back
#define mp 			make_pair
#define pii         pair<ll,ll>
#define vi          vector<ll>
#define vii         vector<pii>
#define mi          map<ll,ll>
#define mii         map<pii,ll>
#define all(a)      (a).begin(),(a).end()
#define fi          first
#define si          second
#define sz(x)       (ll)x.size()
#define endl        '\n'
#define checkbit(n, b) ((n >> b) & 1)
#define mod        1000000007
#define puts(n)		cout<<n;
#define rep(i,a,b)  for(ll i=a;i<b;i++)
#define setbits(x) __builtin_popcount(x)
#define mset(m,v) memset(m,v,sizeof(m))
using namespace std;
vi v1,v2;
//ll dp[101][100001]={-1};
ll ks(ll n, ll b){

   ll dp[n+2][b+1]={-1}; 
   mset(dp,-1);rep(i,0,n)
   dp[i][0]=0;
   rep(i,0,b+1)
   if(v1[0]<=i)
   dp[0][i]=v2[0];
   else dp[0][i]=0;
  for(int i=1;i<n;i++)
  for(int j=0;j<=b;j++){
 	if(dp[i][j]!=-1)
	 continue;
	  if(v1[i]<=j){
	  	dp[i][j]=max(dp[i-1][j],v2[i]+dp[i-1][j-v1[i]]);
	  
	 }
	  else dp[i][j]=dp[i-1][j];
	 
  }
   return dp[n-1][b];
} 
    

int main(){
	ios_base::sync_with_stdio(false);
        cin.tie(NULL);
        cout.tie(NULL);
        ll a,b,k,o;
        cin>>a>>b;
        rep(i,0,a){
            cin>>k>>o;
            v1.pb(k);
            v2.pb(o);
        }
        ll ans=ks(v1.size(),b);
        cout<<ans;
        return 0;}

Measured memory_bytes: 80000
#include <algorithm>
#include <climits>
#include <iostream>
#include <string>
#include <utility>
#include<vector>
#include<iomanip>
#include<map>
#include <queue>
#include<cmath>
#include<cstdio>
#include<iomanip>
#include<set>
#include <bits/stdc++.h>

using namespace std;
using ll = long long int;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++) //REP(i, 5) cout<<i;
#define REPD(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define MOD 10000007 //10^9+7

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


int main(void){
  
  ll k;
  cin>>k;
  ll sum = 0;

  FOR(i, 1, k){
    FOR(j, 1, k){
      FOR(l, 1, k){
        ll x = gcd(i, j);
        sum += gcd(x, l);

      }
    }
  }

  cout<<sum<<endl;
  
  return 0;

}

Measured memory_bytes: 3620
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <iomanip>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstring>
#include <climits>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> V;
typedef map<int, int> M;

constexpr ll INF = 1e18;
constexpr ll MOD = 1e9 + 7;
constexpr double PI = 3.14159265358979323846;
constexpr int di[] = {0, 0, 1, -1};
constexpr int dj[] = {1, -1, 0, 0};

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

    string s, t;
    cin >> s >> t;

    int m[26][100010];
    memset(m, 0, sizeof(m));

    for (char c = 'a'; c <= 'z'; c++)
    {
        int d = c - 'a';

        m[d][s.size()] = -1;

        for (int i = s.size() - 1; i >= 0; i--)
        {
            if (s[i] == c)
                m[d][i] = i;
            else
                m[d][i] = m[d][i + 1];
        }
    }

    int j = -1;
    ll cnt = 0;
    REP(i, t.size())
    {
        if (m[t[i] - 'a'][0] == -1)
        {
            cout << -1 << endl;
            return 0;
        }

        j = m[t[i] - 'a'][j + 1];

        if (j == -1)
        {
            cnt++;
            j = m[t[i] - 'a'][0];
        }
    }

    cout << (cnt * s.size() + j + 1) << endl;

    return 0;
}

Measured memory_bytes: 10704
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <map>
#include <fstream>
#include <set>
#include <stack>
#include <queue>
#include <list>
using namespace std;
typedef long long int64;
typedef vector<int> vec;
typedef vector<int64> vec64;
#define db(x) cout << "> " << #x << ": " << x << "\n";
#define ss cout << " ";
#define ct(x) cout << x;
#define nn cout << "\n";
#define cts(x) cout << x << " ";
#define ctn(x) cout << x << "\n";
#define qr queries();
void solve();
void YN(bool b){if (b){ctn("YES");}else{ctn ("NO");}};
void yn(bool b){if (b){ctn("Yes");}else{ctn ("No");}};
void queries(){int n;cin >> n;while (n--)solve();}
// // // // // // // // // // // // // // // // // // // // // // 
/*                  TEMPLATE - VANILLA                         */
// // // // // // // // // // // // // // // // // // // // // //
int64 q, n;

void solve(){

    return;
}


int main(){
    int a= 0, b= 0, c= 0, d= 0;
    int n;
    cin >> n;
    for (int i = 0; i < n; i++){
        string s;
        cin >> s;
        if (s == "AC"){
            a++;
        }
        else if (s == "WA"){
            b++;
        }
        else if (s == "TLE"){
            c++;
        }
        else if (s == "RE"){
            d++;
        }
    }
    cout << "AC x " << a << "\n" << "WA x " << b << "\n" << "TLE x " << c << "\n" << "RE x " << d << "\n";
    return 0;
}


Measured memory_bytes: 3632
#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <queue>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <climits>
//#include "h.h"
using namespace std;

#define MOD1097 1000000007

#define ll long long
#define pint pair<int, int>
#define pll pair<ll, ll>
#define pb push_back
#define mp make_pair
#define pm(first, second) pb(mp(first, second))
#define SPACE " "
#define fpf first.first
#define fps first.second
#define spf second.first
#define sps second.second

#define all(X) (X).begin(), (X).end()

int main(){

	int x, a;
	cin >> x >> a;
	if(x < a)cout << "0" << endl;
	else cout << "10" << endl;

//"Hiroakimm0415"

	return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
 
public class Main {
    public static void main(String[] a) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String str = br.readLine();
        char[] data = str.toCharArray();
 
        char buf;
        for (int i = 0; i < data.length / 2; i++) {
            buf = data[i];
            data[i] = data[data.length - 1 - i];
            data[data.length - 1 - i] = buf;
        }
        System.out.println(data);
    }
}

Measured memory_bytes: 24132
n=int(input())
xyh=[list(map(int,input().split())) for i in range(n)]
for i in range(n):
    if xyh[i][2]>0:
        tx,ty,th=xyh.pop(i)
        break
for cx in range(101):
    for cy in range(101):
        H=th+abs(tx-cx)+abs(ty-cy)
        for x,y,h in xyh:
            if h==0 and H-abs(x-cx)-abs(y-cy)<=0: continue
            if H!=h+abs(x-cx)+abs(y-cy): break
        else:
            print(cx,cy,H)
            exit()


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define idfc ios_base::sync_with_stdio(false),cin.tie(nullptr),cout.tie(nullptr)
#define ll long long
#define pb emplace_back
#define mp make_pair
#define nt _int128
#define ld long double
long double PI =3.14159265358979323846;


const ll modo=1e9+7;
const ll inf=2e14;
const ll ms=(2e5) +5;
map<string,int> mm;
vector<string> ans;

int main()
{
    idfc;
    int n;
    cin>>n;
    int i;
    string s;
    for(i=0;i<n;i++)
    {
        cin>>s;
        mm[s]+=1;
    }
    int mx=0;
    for(auto it:mm)
    {
        mx=max(mx,it.second);
    }
    for(auto it:mm)
    {
        if(it.second==mx)ans.pb(it.first);
    }
    for(string ii:ans)cout<<ii<<"\n";
    return 0;
}

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

#define cc(x) cout << (x) << endl
#define rep(i,n) for(int i = 0; i < int(n); i++)
#define repi(i,a,b) for(int i = int(a); i < int(b); ++i)
typedef long long ll;

template<typename T, typename U> inline void amin(T &x, U y) { if(y < x) x = y; }
template<typename T, typename U> inline void amax(T &x, U y) { if(x < y) x = y; }


int n,m;
int a, b, q;
const ll inf = 1LL<<58;


signed main(){
    cin >> a >> b >> q;
    vector<ll> s(a), t(b), x(q);

    rep(i, a){
        cin >> s[i];
    }
    rep(i,b){
        cin >> t[i];
    }

    s.push_back(-inf);s.push_back(inf);sort(s.begin(), s.end());
    t.push_back(-inf);t.push_back(inf);sort(t.begin(), t.end());

    for(int i = 0; i < q; ++i){
        cin >> x[i];
    }

    int sup, tup;
    for(int i = 0; i < q; ++i){
        long long kyori=inf;
        sup=lower_bound(s.begin(), s.end(), x[i])- s.begin();//=<のやつをみつける
        tup=lower_bound(t.begin(), t.end(), x[i])- t.begin();
        rep(j,2){
            rep(k,2){
                rep(l,2){
                    amin(kyori, j ? abs(t[tup-k]-x[i]) + abs(s[sup-l]-t[tup-k]) : abs(s[sup-k]-x[i]) + abs(s[sup-k]-t[tup-l]));
                }
            }
        }
        cc(kyori);
    }
}

Measured memory_bytes: 3680
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <stack>
#include <queue>
#include <functional>
#include <set>
#include <map>
#include <tuple>
#include <bitset>
#include <random>
#define REP(i,n) for(int i=0;i<n;i++)
#define INF 100000000000007
using namespace std;
using pii=pair<int,int>;
using LL=int64_t;





int main(){
    LL n;
    cin>>n;
    LL ans=0;
    for(LL i=1;i<=n;i++){//頂点iを含むsの数
        ans+=i*(n-i+1);
    }
    

    REP(i,n-1){
        LL u,v;
        cin>>u>>v;
        
        LL a=min(u,v);
        LL b=max(u,v);
        /*if(u>v){
            swap(u,v);
        }*/
        ans=ans-a*(n-b+1);
        

    }

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

Measured memory_bytes: 3180
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>
using namespace std;
int n,m;
vector<int> V[200005];
int main(){
	cin>>n>>m;
	for (int i=1;i<=m;i++){
		int a,b;
		cin>>a>>b;
		V[a].push_back(b);
		V[b].push_back(a);
	}
	sort(V[1].begin(),V[1].end());
	sort(V[n].begin(),V[n].end());
	int p1=0;
	int p2=0;
	while (p1<V[1].size() && p2<V[n].size()){
		if (V[1][p1]==V[n][p2]){
			cout<<"POSSIBLE";
			return 0;
		}
		if (V[1][p1]<V[n][p2]){
			p1++;
		}
		else{
			p2++;
		}
	}
	cout<<"IMPOSSIBLE";
	return 0;
}

Measured memory_bytes: 12016
#include<stdio.h>
int main(void)
{
	int n,x[30][2]={0},max=0,i,j,k;
	char s[101];
	char al[26]={"abcdefghijklmnopqrstuvwxyz"};
	scanf("%d %s", &n, s);
	for(i=0; i<n-1; i++)
	{
		for(j=0; j<26; j++)
		{
			for(k=0; k<=i; k++)
			{
				if(s[k]==al[j])
				x[j][0]=1;
			}
			for(k=i+1; k<n; k++)
			{
				if(s[k]==al[j])
				x[j][1]=1;
			}
		}
		k=0;
		for(j=0; j<26; j++)
		{
			if(x[j][0]>0&&x[j][1]>0)
			k++;
			x[j][0]=0;
			x[j][1]=0;
		}
		if(max<k)
		max=k;
	}
	printf("%d\n", max);
	
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;
using ull = unsigned long long;

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

    ull N;
    ull trans;

    cin >> N;
    ull min_trans = N;
    for (int i = 0; i < 5; ++i) {
        cin >> trans;
        min_trans = min(trans, min_trans);
    }
    cout << static_cast<ull>(ceil(N / (double)min_trans)) + 4 << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <sstream>

using namespace std;

int main() {
  int n;
  while (cin >> n, n) {
    string str;
    cin >> str;

    while (n--) {
      stringstream ss;
      int a = 1;
      char c = str[0];
      str = str.substr(1, str.length()-1);
      for (auto &s : str) {
        if (c != s) {
          ss << a << c;
          a = 1;
          c = s;
        }
        else {
          ++a;
        }
      }
      ss << a << c;
      ss >> str;
    }
    cout << str << endl;
  }
}


Measured memory_bytes: 3312
#include<iostream>
#include<list>
#include<vector>
#include<algorithm>
#include<string>
#include<stdio.h>
#include<math.h>
#include<unordered_map>
#include<map>

using namespace std;
using ll = long long;
using vec = vector<ll>;
using mat = vector<vec>;
using lst = list<ll>;


ll MOD = 1000000007;


int main()
{
	int N;
	cin >> N;
	
	int K;
	cin >> K;
	K--;
	for (int i = 0; i < N - 1; ++i)
	{
		int H; cin >> H;
		if (K < H)
		{
			K = H - 1;
		}
		else if (K == H)
		{
			K = H;
		}
		else
		{
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;

	return 0;
}

Measured memory_bytes: 256
import sys

input = sys.stdin.readline

MAX = 500000
GUARD = 2000000000
cnt = 0

def merge(A, left, mid, right):
    n1 = mid - left
    n2 = right - mid
    L = A[left:mid] + [MAX]
    R = A[mid:right] + [MAX]

    for i in range(n1):
        L[i] = A[left + i]
    for i in range(n2):
        R[i] = A[mid + i]
    
    L[n1] = GUARD
    R[n2] = GUARD
    i = 0
    j = 0

    global cnt
    for k in range(left, right):
        cnt += 1
        if L[i] <= R[j]:
            A[k] = L[i]
            i = i + 1
        else:
            A[k] = R[j]
            j = j + 1

def mergeSort(A, left, right):
    if left+1 < right:
        mid = (left + right) // 2
        mergeSort(A, left, mid)
        mergeSort(A, mid, right)
        merge(A, left, mid, right)

def main():
    n = int(input())
    S = list(map(int, input().split()))

    mergeSort(S, 0, n)

    print(*S)
    print(cnt)
             
if __name__ == "__main__":
    main()


Measured memory_bytes: 61656
#include<stdio.h>

int main() {

	int n, i, j;

	scanf("%d", &n);

	int a[n];

	for (i = 1; i <= n; i++) {
		scanf("%d", &a[i]);
	}
	for (j = i - 1; j >= 1; j--) {
		printf("%d", a[j]);
		if (j != 1) printf(" ");
		else printf("\n");
	}

	return 0;

}


Measured memory_bytes: 2104
///In the name of GOD
#include<bits/stdc++.h>
using namespace std;

typedef long long ll;
const ll MXN = 30 + 10;
ll power(ll a, ll b){
    return (!b ? 1 : (power((a * a), b / 2) * (b & 1LL ? a : 1)));
}
ll k, ans;
ll dp[MXN][MXN];
int main(){
    ios::sync_with_stdio(0);cin.tie(0); cout.tie(0);
    cin >> k;
    for(int i = 0; i <= 9; i ++) dp[1][i] = 1;
    for(int i = 2; i <= 11; i ++){
        for(int j = 0; j <= 9; j ++){
            dp[i][j] = dp[i - 1][j] + (j + 1 <= 9 ? dp[i - 1][j + 1] : 0) + (j - 1 >= 0 ? dp[i - 1][j - 1] : 0);
        }
    }
    ll kp = k, r, f;
    bool b = 0;
    for(int i = 1; i <= 11; i ++){
        for(int j = 1; j <= 9; j ++){
            if(k > dp[i][j]){
                k -= dp[i][j];
                continue;
            }
            b = 1;
            r = i, f = j;
            break;
        }
        if(b) break;
    }
    kp = k;
    cout << f;
    for(int i = r - 1; i >= 1; i --){
        if(f - 1 >= 0){
            if(kp > dp[i][f - 1]){
                kp -= dp[i][f - 1];
            }
            else{
                cout << f - 1;
                f = f - 1;
                continue;
            }
        }
        if(kp > dp[i][f]){
            kp -= dp[i][f];
        }
        else{
            cout << f;
            continue;
        }
        cout << f + 1;
        f = f + 1;
        continue;

    }
    return 0;
}
/*!
    You are under no obligation to be the same person you were a minute ago,
    You have the right to grow !
*/
//! N.N


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

signed main(void)
{
	double r;
	cin >> r;
	cout << fixed << setprecision(20) <<(double) r * 2 * 3.141592653589793 << endl;
	return 0;
}


Measured memory_bytes: 3784
#include <iostream>

using namespace std;

int main(void)
{
    int a, b, c;

    cin >> a >> b >> c;

    if(a==b && b==c){
        cout << 1 << endl;
    }
    else if(a==b || b==c || c==a){
        cout << 2 << endl;
    }
    else{
        cout << 3 << endl;
    }

    return 0;
}

Measured memory_bytes: 256
from collections import Counter
import sys
sys.setrecursionlimit(10 ** 7)

N = int(input())
edges = [[] for _ in range(N)]

for _ in range(N - 1):
    fr, to = map(int, input().split())
    fr -= 1
    to -= 1
    edges[fr].append(to)
    edges[to].append(fr)

A = list(map(int, input().split()))
A.sort()
S = sum(A) - A[-1]

print(S)

ans = [0] * N
st = [(0, -1)]
while st:
    now, pr = st.pop()
    ans[now] = A.pop()
    for to in edges[now]:
        if to == pr:
            continue
        st.append((to, now))
print(*ans)


Measured memory_bytes: 6424
n = input()

if n.count('9') == len(n):
    ans = 9 * len(n)
elif len(n) == 1:
    ans = int(n)
elif n[0] != '9' and n.count('9') == len(n) - 1:
    ans = int(n[0]) + 9 * (len(n) - 1)
else:
    ans = (int(n[0]) - 1) + 9 * (len(n) - 1)

print(ans)


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

#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef complex<double> point;
#define xx real()
#define yy imag()

#define REP(i, a, b) for(int i = (a); i < (int)(b); i++)
#define REPN(i, a, b) for(int i = (a); i <= (int)(b); i++)
#define FA(it, x) for(__typeof((x).begin()) it = (x).begin(); it != (x).end(); it++)
#define SZ(x) (int)(x).size()
#define BE(x) (x).begin(), (x).end()
#define SORT(x) sort(BE(x))
#define _1 first
#define _2 second

#define x1 gray_cat_x1
#define y1 gray_cat_y1

template<class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

#define file "I1"

const double EPS = 1e-9;
const double PI = acos(-1.);
const int INF = 1e9;
const ll MOD = 1e9 + 7;

const int MAXN = 2e5 + 5;

char c[100];
int v[MAXN];

void make_query(int a) {
	printf("%d\n", a);
	fflush(stdout);
	scanf("%s", &c[0]);
	if (c[0] == 'V') {
		exit(0);
	} else if (c[0] == 'M') {
		v[a] = 0;
	} else {
		v[a] = 1;
	}
}



void solve(){
	int n;
	scanf("%d", &n);
	int l = 0, r = n / 2;
	make_query(l);
	make_query(r);
	v[n] = v[l];
	if ((l ^ r) % 2 == v[l] ^ v[r]) {
		l = r;
		r = n;
	}
	while(l + 1 < r) {
		int mid = (l + r) >> 1;
		make_query(mid);
		if ((l ^ mid) % 2 == v[l] ^ v[mid]) {
			l = mid;
		} else {
			r = mid;
		}
	}
}   

int main(){
/*#ifndef ONLINE_JUDGE
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
#endif*/
    //freopen(file".in", "r", stdin); freopen(file".out", "w", stdout);
    int t = 1;
    //cin >> t;
    while(t--){
        solve();    
    }
}


Measured memory_bytes: 852
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
#include<algorithm>//next_permutation
#define rep(i,n) for (int i = 0;i < (n);i++)
#define all(v) v.begin(),v.end()
#define dec(n) cout << fixed << setprecision(n);
#define large "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
#define small "abcdefghijklmnopqrstuvwxyz"
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using vl = vector<ll>;
using vvl = vector<vl>;

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

ll mod(ll a){
  return (a % 1000000007);
}

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



int main(){
  ll n; cin >> n; vl bit1(62); vl bit0(62);
  
  rep(i,n){
    ll x; cin >> x;
    
    ll b = 1;
      for(ll j=0; j < 62; j++){
        if(x % 2 == 0){
          bit0[j]++;
        }
        else bit1[j]++;
       
        
        x /= 2;
      }
    
  }
  
  ll MOD = 1000000007;
  ll ans = 0;
	rep(i,62){
		ll num2 = bit1[i]*(n-bit1[i])%MOD;
		for(ll j=0;j<i;j++){
			num2 *= 2;
			num2 %= MOD;
		}
		ans += num2;
		ans %= MOD;
	}
	cout << ans << endl;
	return 0;
  

  /*ll sum = 0;
  
  ll index = 1;
  
  rep(i,62){
      
    sum += mod(bit1[i]*bit0[i])*mod(index); 
    sum = mod(sum);
    
    index *= 2; index = mod(index);
  }
  
  cout << sum << endl;*/
  
  
}
    


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

int main() {

int x,n;
vector<int>v{};
cin>>x>>n;
if(!n)
  cout << x;
else
{

  int c;
  for(int i = 0; i < n; i++)
  {
    cin >> c;
    v.push_back(abs(c));
  }

  sort(v.begin(), v.end());
  auto it = find(v.begin(),v.end(), x);
  
  if (it == v.end()){
    cout << x;
   exit(0);
  }
    
 
  int z = 1;

  while(true)
  {

    if(*(it-z) != x-z || x -z==0)
    {
      z = x-z;
      break;
    }
    else if (*(it+z) != x+z)
    {
      z = x+z;
      break;
    }
    z++;
    
  }
  cout << z;
  
}
return 0;
}

Measured memory_bytes: 3552
#include <iostream>
#include <string>
#include <cmath>
#include <vector>
#include <regex>
#include <locale>
#include<set>



using namespace std;

#define MAX 300000
int main() {
    string s,ans,temps,temps2;
    int k,i,j,m,temp=0;
    set<string> bubun;
    int mojisu=0;
    vector<string> bubun2;

    cin >> s >> k;

    do{
        mojisu++;
    }while(s[mojisu]!='\0');

        for(j=0;j<mojisu;j++){
            for(m=1;m<=k;m++){
                bubun.insert(s.substr(j,m));
            }
        }

       // sort(bubun.begin(),bubun.end());
       i=0;
     for(string temps:bubun){
         i++;
         bubun2.push_back(temps);
        }




  /*  for(j=0;j<i;j++){
        for(m=j;m<i;m++){
            if(bubun2[j].length()>bubun2[m].length()) {
                temps2 = bubun2[j];
                bubun2[j] = bubun2[m];
                bubun2[m] = temps2;
            }
        }
    }*/

   /* for(string temps:bubun2) {
        */


    std::cout << bubun2[k-1] << std::endl;
    return 0;
}

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

int main(){
  int N,i,j,count;

  cin>>N;
  vector<int> h(N);
  for(i=0;i<N;i++)
  cin>>h.at(i);

  count=1;

  for(i=1;i<N;i++){
    for(j=0;j<i;j++){
      if(h.at(i)>=h.at(j)){
        if(j==i-1)
        count++;
        continue;
      }
      else
      break;
    }
  }

  cout<<count<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define N 3000
bool chmax(int a, int b){
    int res;
    res = max(a,b);
    if(res==a)return false;
    else return true;
}
int main(){
    char s[N],t[N];
    vector<vector<int>> dp(N+1, vector<int>(N+1,0));
    cin >> s;
    cin >> t;
    int n=strlen(s);
    int k=strlen(t);
    string res = "";
    int tmp=0;
    int i,j;
    //dp[i][j]:s[i],t[j]までの最長共通部分
    for(i=0;i<n;i++){
        for(j=0;j<k;j++){
            if(s[i]==t[j])
            {
                dp[i+1][j+1] = dp[i][j]+1;
                
            }
            else{
                dp[i+1][j+1]=max(dp[i+1][j], dp[i][j+1]);
            }
        }
    }

    int x = n, y = k;

    while(x>0 && y>0){
        if(dp[x][y]==dp[x-1][y])x--;
        else if(dp[x][y]==dp[x][y-1])y--;
        else {
            x--;
            y--;
            res.push_back(s[x]);
        }
    }

    reverse(res.begin(),res.end());
    
    //cout << dp[n][k] << endl;
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 35584
#include <stdio.h>

int main(void)
{
	int X,N;
	scanf("%d %d",&N,&X);
	int L[100];
	for(int i = 1; i < N+1; i++)
	{
		scanf("%d",&L[i]);
	}
	int count=1;
	int D = 0;
	while(D <= X)
	{
		D = D + L[count];
		count++;
	}
	count = count-1;
	printf("%d",count);
	return 0;
}


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


int main() {
  int n,m;
  cin >> n>>m;
  rep(i,20){
    if(n*i-i+1>=m){
      cout<<i<<endl;
      break;
    }
  }
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
struct NODE
{
  long long n;
  struct NODE *r;
  struct NODE *l;
};
struct NODE *Sort(struct NODE *p,long long n)
{
  if(p == NULL) {
    p = (struct NODE *)malloc(sizeof(struct NODE));
    p->n = n;
    p->r = p->l = NULL;
  }
  else {
    if(p->n > n) p->l = Sort(p->l,n);
    else p->r = Sort(p->r,n);
  }
  return p;
}
void Print(struct NODE *p)
{
  static int f = 0;
  if(p == NULL) return;
  Print(p->l);
  printf("%s%lld",f++ ? " ": "",p->n);
  Print(p->r);
}
void Clear(struct NODE **p)
{
  if(*p == NULL) return;
  Clear(&(*p)->l);
  Clear(&(*p)->r);
  free(*p);
  *p == NULL;
}
int main(long long i)
{
  long long n;
  struct NODE *root = NULL;
  while(i++ < 4) {
    scanf("%lld",&n);
    root = Sort(root,n);
  }
  Print(root);
  putchar('\n');
  Clear(&root);
  return 0;
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
using namespace std;
const int mod = 998244353;
typedef long long ll;
#define fastIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define what_is(x) cerr << #x << " is " << x << endl;
int main()
{
    fastIO;


    int ans=0,x;
    for (int i=0; i<5; ++i)
    {
        cin>>x;
        if (x==0)
            ans=i+1;
    }
    cout<<ans;


}


Measured memory_bytes: 3608
import java.util.ArrayList;
import java.util.Scanner;

public class Main {

	public static Scanner scanner = new Scanner(System.in);

	public static void main(String[] args) {

		int n = input();
		ArrayList<Integer> list = new ArrayList<Integer>();

		for (int i = 0; i < n; i++) {

			list.add(input());

		}

		for (int j = n; j > 0; j--) {

			if (j !=1) {

				System.out.print(list.get(j - 1));
				System.out.print(" ");

			} else {

				System.out.println(list.get(j - 1));

			}
		}

		close();

	}

	public static int input() {

		return scanner.nextInt();

	}

	public static void close() {

		if (scanner != null) {

			scanner.close();

		}
	}
}

Measured memory_bytes: 26360
import difflib as diff
S=input()
T=input()
diff_count=10001
count=10002
#print(diff.context_diff("aaa","bbb"))

def count_diff2(q, a):
    return sum(
        c1 != c2 for c1, c2 in zip(q, a)
    )

if __name__=="__main__":
    for i in range(len(S)-len(T)+1):
        count=count_diff2(S[i:len(T)+i],T)
        if count <= diff_count:
            diff_count=count

print(diff_count)

Measured memory_bytes: 9988
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>


using namespace std;
using namespace __gnu_pbds;

#define int long long int
#define pb push_back
#define M 1000000007
#define ff first
#define ss second
#define deb(x) cout< #x< " "< x< endl;
#define fo(i,n) for(int i=0;i<n;i++)
#define Fo(i,k,n) for(int i=k;i<=n;i++)
#define FORR(a,b,c) for(int a= b;a>=c;a--)
#define fa(arrr) for(auto x:arrr)
#define sz size()
// #define mp make_pair
#define mxm3(a,b,c) max(a, max(b,c))
#define mi3(a,b,c) min(a, min(b,c))
#define MAX 100005
#define PII pair<int,int>
#define all(v) v.begin(), v.end()
#define endl "\n"
#define fast ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);


typedef tree<pair<int, int>,
        null_type,
        less<pair<int, int>>,
        rb_tree_tag,
        tree_order_statistics_node_update> oset;

//126271
// 107897


int lcm(int a, int b) {
	int x = (a * b) % M;
	return x / __gcd(a, b);
}

int ceil(int a, int b) {
	if (a % b != 0) return a / b + 1;
	return a / b;
}

oset s;
int cnt = 0;

int freq(vector<int>arr, int l, int r, int x , map<int, vector<int>>mp) {
	int a = lower_bound(all(mp[x]), l) - mp[x].begin();
	int b = upper_bound(all(mp[x]), r) - mp[x].begin();

	return b - a;
}

void func(string x, string y, int n, int m){
	vector<vector<int>>dp(n+1, vector<int>(m+1,0));
	for(int i = 0;i<=n;i++){
		for(int j = 0;j<=m;j++){
			if(i==0 || j == 0) dp[i][j] = 0;
			else if(x[i-1] == y[j-1]) dp[i][j] = 1+ dp[i-1][j-1];
			else dp[i][j] = max(dp[i-1][j], dp[i][j-1]);
		}
	}
	int k = dp[n][m];
	char ans[k+1];
	ans[k] = '\0';
	int i = n, j = m;
	while(i>0 && j>0){
		if(x[i-1]==y[j-1]){
			ans[k-1]=x[i-1];
			i--;
			j--;
			k--;
		}
		else if(dp[i-1][j]>dp[i][j-1]) i--;
		else j--;
	}
	// for(auto x:ans) cout << x;
	cout << ans << endl;
	// reverse(all(ans));
	// return ans;
}


int32_t main(){
	int t;
	// cin >> t;
	t = 1;
	while(t--){
		string x,y;
		cin >> x >> y;
		int n = (x).size();
		int m = (y).size();
		func(x, y, n, m); 
	}
}



Measured memory_bytes: 70784
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (int)n; i++)
using ll = long long;
int main() {
  ll a,b,c,d;
  cin >> a >> b >> c >> d;
  ll x = max(a*c,a*d);
  ll y = max(b*c, b*d);
  cout << max(x,y) << endl;
}


Measured memory_bytes: 3644
#include<iostream>

using namespace std;

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

	int** matrix = new int*[n];
	for (int i = 0; i < n; i++) {
		matrix[i] = new int[m];
	}

	int* vectorB = new int[m];
	int* resultVector = new int[n];

	for (int i = 0; i < n; i++) {
		for (int j = 0; j < m; j++) {
			int temp;
			cin >> temp;
			matrix[i][j] = temp;
		}
	}

	for (int i = 0; i < m; i++) {
		int temp;
		cin >> temp;
		vectorB[i] = temp;
	}

	for (int i = 0; i < n; i++) {
		int rowSum = 0;
		for (int j = 0; j < m;j++) {
			rowSum += (matrix[i][j] * vectorB[j]);
		}
		resultVector[i] = rowSum;
	}

	for (int i = 0; i < n; i++) {
		cout << resultVector[i] << endl;
	}

	/*
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < m; j++) {
			cout << matrix[i][j];
			cout << ' ';
		}
		cout << endl;
	}
	*/


	for (int i = 0; i < n; i++) {
		delete[] matrix[i];
	}
	delete[] matrix;
	delete[] vectorB;
	delete[] resultVector;
	
	return 0;
}

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

#ifdef LOCAL
	#define D(a) cerr << #a << " = " << a << endl
#else
	#define D(a)
	#define cerr false && cerr
#endif
#define fastio ios_base::sync_with_stdio(0); cin.tie(0)
#define dforsn(i,s,n) for(int i=int(n-1);i>=int(s);i--)
#define forsn(i,s,n) for(int i=int(s);i<int(n);i++)
#define dforn(i,n) dforsn(i,0,n)
#define forn(i,n) forsn(i,0,n)
#define all(a) a.begin(),a.end()
#define si(a) int((a).size())
#define pb emplace_back
#define mp make_pair
#define snd second
#define fst first
#define endl '\n'
using pii = pair<int,int>;
using vi = vector<int>;
using ll = long long;

queue<int> q;
bool one = 1;
int c = 0, cur = 0, res = 0, n,k;

void f(){
    q.push(c);
    cur += c, c = 1, one = !one;
    if(si(q) > 2*k+1){
        int f = q.front(); q.pop();
        cur -= f;
        f = q.front(); q.pop();
        cur -= f;    
    }
    res = max(res, cur);
}

int main() {
	fastio;
	
    cin >> n >> k;
    char x;
    forn(i,n){
        cin >> x;
        if(int(x-'0') == one) c++;
        else f();
    }
    f();
    cout << res << endl;
	return 0;
}


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

const long long mod = 1e9 + 7;

using ll = long long;
using pii  = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

int main(){
    int h, w, k;
    cin >> h >> w >> k;
    vs c(h);
    rep(i, h) cin >> c[i];
    int ans = 0;
    rep(i, 1<<h) rep(j, 1<<w) {
        if (i==0 && j==0) continue;
        if (i==(1<<h)-1 || j==(1<<w)-1) continue;
        int cnt = 0;
        rep(i2, h) rep(j2, w) {
            bool ok = false;
            if (i&(1<<i2) || j&(1<<j2)) ok = true;
            if (ok) continue;
            if (c[i2][j2] == '#') ++cnt;
        }
        if (cnt == k) ++ans;
    }
    int cnt = 0;
    rep(i, h) rep(j, w) if (c[i][j] == '#') ++cnt;
    if (cnt == k) ++ans;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3628
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <numeric>
#include <stdio.h>
#include <stack>
#include <queue>
#include <cstdio>
#include <cmath>
#include <iterator>
#include <map>
#include <fstream>
#include <functional>
#include <list>
#include <iomanip>
#include <cctype>
#include <math.h>

#define rep(i,first,end) for(int i = first; i < end; i++)

using namespace std;


int main() {
    cin.tie(0); ios::sync_with_stdio(false);
    
    string S;
    cin >> S;
    int l = S.length();
    
    int count = 0;
    int m = 0;
    
    
    
    rep(i,0,l){
        if(S.at(i) == 'A' || S.at(i) == 'C'|| S.at(i) == 'G' || S.at(i) == 'T'){
            count += 1;
            m = max(count,m);
        }
        else{
            count *= 0;
        }
    }
    
    cout << m << endl;
    
    

}
    





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

namespace AOJ
{
	class Program
	{
		static void Main(string[] args)
		{
			var n = 0;
			while ((n = int.Parse(Console.ReadLine())) != 0)
			{
				var ms = new int[n][];
				for (int i = 0; i < n; i++)
					ms[i] = new int[n];
				int x = (n / 2), y = (n / 2) + 1, c = 1;
				ms[y][x] = c++;
				while (f(ms, n))
				{
					if (++x >= n) x = 0;
					if (++y >= n) y = 0;
					if (x < 0) x = n - 1;
					if (ms[y][x] != 0)
					{
						x -= 2;
						continue;
					}
					ms[y][x] = c++;
				}
				for (int i = 0; i < n; i++)
				{
					for (int j = 0; j < n; j++)
					{
						Console.Write("{0,4}", ms[i][j]);
					}
					Console.WriteLine();
				}
			}
		}

		static bool f(int[][] ms, int n)
		{
			var b = false;
			for (int i = 0; i < n; i++)
			{
				b |= ms[i].Contains(0);
			}
			return b;
		}
	}
}

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

int     main() {
        int N;
        cin >>N;
        vector<long> B(N);
        vector<long> A(N+1);
        long S=0;
        cin >>B.at(1);
        A.at(1)=B.at(1);
        for (int i=2; i<N; i++) {
                cin >>B.at(i);
                A.at(i)=min(B.at(i-1), B.at(i));
        }
        A.at(N)=B.at(N-1);
        for (int i=1; i<=N; i++)
                S+=A.at(i);
        cout <<S <<endl;
        return 0;
};

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i, n) for(int (i)=0 ;i <(n); ++(i))
#define REP(i,m,n) for(int (i) = (m); (i) <= (n); ++(i))
#define yorn(f) puts((f)?"Yes":"No")
#define YORN(f) puts((f)? "YES":"NO")
typedef long long ll;
using namespace std;

int main() {
  string s;
  cin >> s;
  bitset<3> bit(s);
  int cnt = 0;
  rep(i, 3) {
    if(bit.test(i)) cnt++;
  }
  cout << cnt << endl;
  return 0;
}

Measured memory_bytes: 764
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
#define REP(i,s,n) for(int i = s; i < n; i++)
#define INF 1000000007
#define IN 1e18
typedef long long ll;
using namespace std;
using Graph = vector<vector<int>>;
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll a, ll b) { return (a * b) / gcd(a,b); }
ll ceil(const ll a, const ll b) { return (a + b - 1) / b; }
int main(){
  ll a,b;
  cin >> a >> b;
  cout << a * b << endl;
  return 0;
}


Measured memory_bytes: 3624
h, w = map(int,input().split())
a = [list(input()) for _ in range(h)]

yoko = []
for i in range(h):
    seta = set(a[i])
    if '#' in seta:
        yoko.append(a[i])

h = len(yoko)
w = len(yoko[0])
for i in range(w):
    tate = []
    for j in range(h):
        tate.append(yoko[j][i])
    settate = set(tate)
    if '#'not in settate:
        for j in range(h):
            yoko[j][i] = ''

ans = ''
for i in range(h):
    c = ''.join(yoko[i])
    ans += c
    if i != h-1:
        ans += '\n'
print(ans)

Measured memory_bytes: 3188
A = int(input())
B = int(input())
C = int(input())
D = int(input())
E = int(input())
a = A % 10
b = B % 10
c = C % 10
d = D % 10
e = E % 10
f = [a, b, c, d, e]
g = f.count(0)
a1 = A // 10
b1 = B // 10
c1 = C // 10
d1 = D // 10
e1 = E // 10
if g == 5:
    print(A + B + C + D + E)
else:
    f = [i for i in f if i > 0]
    print((a1 + b1 + c1 + d1 + e1 + 4 - g) * 10 + min(f))

Measured memory_bytes: 3064
import sys
def input():
    return sys.stdin.readline()[:-1]


import collections
def main():
    N = int(input())
    A = list(map(int,input().split()))
    c = collections.Counter(A)
    total = 0
    for j in c.values():
        total += j * (j - 1) / 2
    for i in range(N):
        k = c[A[i]]
        before = k * (k - 1) / 2
        after = (k -1) * (k - 2) / 2
        ans = total - before  + after
        print(int(ans))

if __name__ == "__main__":
    main()

Measured memory_bytes: 26780
using System;

public class AtCoder{
	public static void Main(){
		string[] s;
		s = Console.ReadLine().Trim().Split(' ');
		
		int a,b,k;
		a = int.Parse(s[0]);
		b = int.Parse(s[1]);
		k = int.Parse(s[2]);
		
		for (int i=0; i<k; i++){
			if(i%2==0){
				if(a%2==1) a--;
				b = b + a/2;
				a = a/2;
			}else{
				if(b%2==1) b--;
				a = a + b/2;
				b = b/2;
			}
		}
		Console.WriteLine(a+" "+b);
	}
}

Measured memory_bytes: 13140
n = int(input())
s = [input() for i in range(n)]
ac_count,wa_count,tle_count,re_count = 0, 0, 0, 0
for i in s:
    if i == 'AC':
        ac_count += 1
    elif i == 'WA':
        wa_count += 1
    elif i == 'TLE':
        tle_count += 1
    elif i == 'RE':
        re_count += 1
    else:
        continue

print('AC x ' + str(ac_count))
print('WA x ' + str(wa_count))
print('TLE x ' + str(tle_count))
print('RE x ' + str(re_count))


Measured memory_bytes: 16200
from math import gcd
from functools import reduce
from collections import defaultdict
n = int(input())
A = list(map(int, input().split()))
ans = 0


def sieve(n):
    n += 1
    res = [i for i in range(n)]
    for p in range(2, int(n**.5)+1):
        if res[p] < p:
            continue
        for q in range(p**2, n, p):
            if res[q] == q:
                res[q] = p
    return res


U = 10**6
min_factor = sieve(U)


def prime_factor(n):
    res = defaultdict(int)
    while 1 < n:
        res[min_factor[n]] += 1
        n //= min_factor[n]
    return res


facts = set()
for a in A:
    for k, v in prime_factor(a).items():
        if k in facts:
            ans = 1
            break
        facts.add(k)
    else:
        continue
    break

if ans == 0:
    print('pairwise coprime')
else:
    if reduce(gcd, A) == 1:
        print('setwise coprime')
    else:
        print('not coprime')


Measured memory_bytes: 127684
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
int main() {
  ll n; cin>>n;
  vector<char> a(n);
  rep(i, n) cin>>a.at(i);
  ll cnt=0;
  rep(i, n-1) {
    if(a.at(i)!=a.at(i+1)) cnt++;
  }
  cout << cnt+1 << endl;
}

Measured memory_bytes: 384
import sys

inp = input().split(" ")
n,m = int(inp[0]),int(inp[1])
brokens = []
for i in range (m):
    brokens.append(int(input()))

if n == 1:
    print(1)
    sys.exit()


dp = []
for i in range(n+1):
    dp.append(0)

for i in brokens:
    dp[i]= -1

if dp[1] == -1 and dp[2] == -1:
    dp[1] = 0
    dp[2] = 0
elif dp[1] == -1:
    dp[1] = 0
    dp[2] = 1
elif dp[2] == -1 :
    dp[1] = 1
    dp[2] = 0
else:
    dp[1] = 1
    dp[2] = 2


if n <= 2:
    print(dp[n])
    sys.exit(0)


for i in range(3,n+1):
    if dp[i] == -1:
        dp[i] = 0
    else:
        dp[i] = dp[i - 1] + dp[i - 2]

print(dp[n] % 1000000007)

Measured memory_bytes: 460056
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<map>
#include<cmath>
#include<iomanip>
#include<set>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rrep(i, st, n) for (int i = st; i < n; ++i)
using pii = pair<int, int>;
//const int inf = 1e9 + 7;

int main() {
    int cnt = 0;
    int z = 0, o = 0;
    string s; cin >> s;
    rep(i, s.size()) {
        char a = s[i];
        if (a == '0') {
            if (o) {
                cnt++;
                o--;
            } else {
                z++;
            }
        } else {
            if (z) {
                cnt++;
                z--;
            } else {
                o++;
            }
        }
    }
    cout << cnt * 2 << endl;
}


Measured memory_bytes: 512
#include <stdio.h>

int main(){
  int H, W, x, y, r;
  scanf("%d %d %d %d %d", &W, &H, &x, &y, &r);
  if (x - r < 0 || y - r < 0 || x + r > W || y + r > H) {
    printf("No\n");
  } else {
    printf("Yes\n");
  }
  return 0;
}



Measured memory_bytes: 2108
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <iostream>
#include <set>
using namespace std;


const int maxn = 2e5 + 5;

set<int> pos[30];
char s[maxn];
int n;

int c[maxn];

int sum(int p){
    int ret = 0;
    for(int i = p;i > 0;i -= i & -i){
        ret += c[i];
    }
    return ret;
}

void add(int p, int d){
    for(int i = p;i < maxn;i += i & -i){
        c[i] += d; 
    }
}
bool vis[maxn];
int main(){
    //freopen("in/39.txt", "r", stdin);
    scanf("%s", s + 1); 
    n = strlen(s + 1);
    for(int i = 1;i <= n;i++){
        pos[s[i] - 'a'].insert(i);
        add(i, 1);
        vis[i] = true;
    } 
    int cnt = 0;
    for(int i = 0;i < 26;i++){
        if(pos[i].size() & 1){
            cnt++;
        }
    }
    if(cnt <= 1){
        long long ans = 0;
        int L = 1, R = n;
        while(true){
            while(L <= n and !vis[L]) L++;
            while(R > 0 and !vis[R]) R--;
            if(L >= R) break;
            int S = s[L] - 'a';
            int E = s[R] - 'a';
            if(S == E){
                add(L, -1);
                add(R, -1);
                vis[L] = false;
                vis[R] = false;
                pos[S].erase(L);
                pos[E].erase(R);
                continue;
            }
            int A = pos[S].size() > 1 ? sum(n) - sum(*pos[S].rbegin()) : n + 1;
            int B = pos[E].size() > 1 ? sum(*pos[E].begin() - 1) : n + 1;
            if(A < B){
                ans += A;
                vis[L] = false;
                vis[*pos[S].rbegin()] = false;
                add(L, -1);
                add(*pos[S].rbegin(), -1);
                pos[S].erase(L);
                pos[S].erase(*pos[S].rbegin());
            }else{
                ans += B;
                vis[R] = false;
                vis[*pos[E].begin()] = false;
                add(R, -1);
                add(*pos[E].begin(), -1);
                pos[E].erase(R);
                pos[E].erase(*pos[E].begin());
            }
        }
        cout << ans << endl;
    }else{
        cout << -1 << endl;
    }
    return 0;
}


Measured memory_bytes: 10880
#include<bits/stdc++.h>
using namespace std; 
#define PI 3.14159265
typedef long long ll;
//trading bullish credit spreads on the spy and spx with friday weekly expiration === unlimited quantitative. brrrrrrhhhhhhhhhhh.
// because stonks only gooooooooo up. Diamond hands Babbbbyyyyyy
//Expected profits = [$Win*Win%] - [$Risk*(1-Win%)]
int main(){
	string s;
	int k; cin>>k>>s;
	if(s.size() <= k) cout<<s<<"\n";
	else {
		for(int i = 0; i < k; i++){
			cout<<s[i];
		}
		cout<<"..."<<"\n";
	}
	
}

Measured memory_bytes: 3596
N=int(input())
NN=str(N)
n=len(NN)
data=[9,900,90000]
result=0
if(n==1):
	result=N
if (n==2):
	result=data[0]
if (n==3):
	result=data[0]+N-99
if(n==4):
	result=data[0]+data[1]
if(n==5):
	result=data[0]+data[1]+N-9999
if(n==6):
	result=data[0]+data[1]+data[2]

print(result)

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

int main() {
	string s;
	cin >> s;
	if(s.size()<4){
		cout << "No"; return 0;
	}else if(s[0]=='Y' && s[1]=='A' && s[2]=='K' && s[3]=='I'){
		cout << "Yes";
	}else{
		cout << "No";
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fastIO (cin.tie(0), cout.tie(0), ios::sync_with_stdio(false))
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define precise(i) fixed << setprecision(i)
using lint = long;
using llint = long long;
using namespace std;

int main() {
    fastIO;
    int n, k;
    cin >> n >> k;
    cout << n - k + 1 << endl;
}

Measured memory_bytes: 3596
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>

#define REP(i, a, b) for (int i = int(a); i < int(b); i++)
#define dump(val) cerr << __LINE__ << ":\t" << #val << " = " << (val) << endl

using namespace std;

typedef long long int lli;

template<typename T>
vector<T> make_v(size_t a, T b) {
    return vector<T>(a, b);
}

template<typename... Ts>
auto make_v(size_t a, Ts... ts) {
    return vector<decltype(make_v(ts...))>(a, make_v(ts...));
}

const lli mod = 998244353;

lli mypow(lli x, lli n) {
    if (n == 0) {
        return 1;
    } else if (n % 2 == 1) {
        return (mypow(x, n - 1) * x) % mod;
    } else {
        lli t = mypow(x, n / 2);
        return (t * t) % mod;
    }
}

int main() {
    lli N, A, B, K;
    cin >> N >> A >> B >> K;
    map<lli, lli> mA, mB;
    vector<lli> pw(N + 1, 0), pw_inv(N + 1, 0);
    {
        lli s = 1;
        pw[0] = 1;
        pw_inv[0] = mypow(pw[0], mod - 2);
        REP(i, 1, N + 1) {
            s *= i;
            s %= mod;
            pw[i] = s;
            pw_inv[i] = mypow(pw[i], mod - 2);
        }
    }
    REP(i, 0, N + 1) {
        mA[i * A] = (((pw[N] * pw_inv[i]) % mod) * pw_inv[N - i]) % mod;
    }
    REP(i, 0, N + 1) {
        mB[i * B] = (((pw[N] * pw_inv[i]) % mod) * pw_inv[N - i]) % mod;
    }
    lli ans = 0;
    for (auto &m : mA) {
        ans = (ans + (m.second * mB[K - m.first]) % mod) % mod;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 61184
#include <iostream>
#include <string>
#include <cstring>
#include <cstdlib>
#include <cstdio>

using namespace std;

int snum[10][3];

int rnum[2][59049];

int get_pc(int n)
{
	int r = 1;
	for (int i = 0; i < n; i++)
		r *= 3;
	return r;
}

int main()
{
	int N;
	cin >> N;
	for (int i = 0; i < N; i++)
	{
		int num;
		cin >> num;
		if (num % 2)
		{
			snum[i][0] = 0;
			snum[i][1] = 1;
			snum[i][2] = 0;
		}
		else
		{
			snum[i][0] = 1;
			snum[i][1] = 0;
			snum[i][2] = 1;
		}
	}
	memcpy(rnum[1], snum[0], sizeof(snum[0]));
	for (int i = 1; i < N; i++)
	{
		memcpy(rnum[0], rnum[1], sizeof(rnum[1]));
		for (int j = 0; j < get_pc(i); j++)
		{
			for (int k = 0; k < 3; k++)
			{
				rnum[1][j * 3 + k] = rnum[0][j] * snum[i][k];
			}
		}
	}
	int count = 0;
	for (int i = 0; i < get_pc(N); i++)
	{
		if (!rnum[1][i])
			count++;
	}
	printf("%d\n", count);
	return 0;
}


Measured memory_bytes: 768