akhauriyash/Code-Regression huggingface dataset:
N=int(input())
ans=0
def prime_factorize(n):
    a = []
    count=0
    while n % 2 == 0:
        count+=1
        n //= 2
    if count!=0:a.append(count)
    f = 3
    count=0
    while f * f <= n:
        if n % f == 0:
            count+=1
            n //= f
        else:
            f += 2
            if count!=0:a.append(count)
            count=0
    if f==n:
        count+=1
        n=1
    if count!=0:a.append(count)
    if n != 1:
        a.append(1)
    return a
c = prime_factorize(N)
for i in range(len(c)):
    a=c[i]
    for j in range(1,c[i]+1):
        if a>=j:
            ans+=1
            a-=j
        else:
            break
print(ans)

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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using edge = pair<ll, P>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
using Graph = vector<vector<ll>>;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

#include "cpp-pyprint/pyprint.h"

#endif

class DAG {
    int N;
    Graph graph;
    vector<int> visited;

    void dfs(int v) {
        if (visited[v] == 2) {
            is_acyclic = false;
            return;
        }
        if (!visited[v]) {
            visited[v] = 2;
            for (int tar : graph[v]) {
                dfs(v);
            }
            visited[v] = 1;
            sorted.push_back(v);
        }
    }

public:
    vector<int> sorted;

    DAG(int N) : N(N), graph(N), visited(N) {}

    DAG(Graph &graph) : N(graph.size()), graph(graph), visited(graph.size()) {}

    bool is_acyclic = true;

    void add_edge(int a, int b) {
        graph[a].push_back(b);
    }

    void topological_sort() {
        for (int i = 0; i < N; ++i) {
            if (!visited[i]) {
                dfs(i);
            }
        }
        reverse(sorted.begin(), sorted.end());
    }
};

int longest_path(const Graph &graph) {
    int N = graph.size();

    Graph inv(N);
    for (int i = 0; i < N; ++i) {
        for (int v: graph[i]) {
            inv[v].push_back(i);
        }
    }
    vector<int> path_len(N, -1);
    function<void(int)> set_len = [&](int v) {
        if (path_len[v] != -1) {
            return;
        }
        if (inv[v].empty()) {
            path_len[v] = 0;
            return;
        }
        int max_num = 0;
        for (int tar : inv[v]) {
            set_len(tar);
            max_num = max(max_num, path_len[tar]);
        }
        path_len[v] = max_num + 1;

    };
    for (int i = 0; i < N; ++i) {
        set_len(i);
    }
    return *max_element(path_len.begin(), path_len.end());
}


void Main() {
    int N, M;
    cin >> N >> M;
    Graph graph(N);
    rep(i, M) {
        int x, y;
        cin >> x >> y;
        x --;
        y --;
        graph[x].push_back(y);
    }
    cout << longest_path(graph) << endl;
}

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


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

int main() {
  int a, b;
  cin >> a >> b;
  
  int count = 0;
  
  for (int i = a; i <= b; i++){
   if ((i/10000 == i%10)&&((i/1000)%10 == (i%100)/10)) count ++;
  }
  cout << count << endl;
} 

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

int main(){
  vector<vector<int>> a(3, vector<int>(3));
  for(int i=0; i<3; ++i){
    for(int j=0; j<3; ++j){
      cin >> a[i][j];
    }
  }
  int n; cin >> n;
  vector<int> b(n);
  for(int i=0; i<n; ++i) cin >> b[i];
  
  vector<vector<bool>> buf(3, vector<bool>(3, false));
  for(int i=0; i<3; ++i){
    for(int j=0; j<3; ++j){
      for(int x : b){
        if(a[i][j] == x) buf[i][j] = true;
      }
    }
  }
  
  string res = "No";
  for(int i=0; i<3; ++i){
    if(buf[i][0] && buf[i][1] && buf[i][2]) res = "Yes";
    if(buf[0][i] && buf[1][i] && buf[2][i]) res = "Yes";
  }
  if(buf[0][0] && buf[1][1] && buf[2][2]) res = "Yes";
  if(buf[2][0] && buf[1][1] && buf[0][2]) res = "Yes";
  cout << res << endl;
  
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#define rep(i,n) for(ll i=0;i<(n);++i)
using namespace std;
using ll = long long;

int main() {
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	while (1) {
		c -= b;
		if (c <= 0) {
			cout << "Yes" << endl;
			break;
		}
		a -= d;
		if (a <= 0) {
			cout << "No" << endl;
			break;
		}
	}
	return 0;
}


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

int main() {
  string s;
  cin >> s;
  int num_of_marbels = 0;
  for (char c : s) { if (c == '1') num_of_marbels++; }
  cout << num_of_marbels << endl;
  return 0;
}

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

int main(){
  int N,t;
  int c=0;
  cin>>N;
  t=N;
  
  while(t>0){
    c+=t%10;
    t/=10;
  }
  if(N%c==0){
    cout<<"Yes"<<endl;
  }
  else{
    cout<<"No"<<endl;
  }
}

Measured memory_bytes: 256
n = int(input())
p = list(map(int, input().split()))

ans = 0
for i in range(n-1):
  if i+1 == p[i]:
    p[i],p[i+1] = p[i+1],p[i]
    ans += 1
if n == p[-1]: ans += 1
print(ans)

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


int main(){
    string S,T;
    std::cin >> S;
    std::cin >> T;

    int a = 0;
    for(int i = 0;i < S.size();i++){
        if(S[i] != T[i]){
            ++a;
        }
    }
    std::cout << a << std::endl;
    return 0;
}

Measured memory_bytes: 3916
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; ++i)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = int64_t;
using ld = long double;
using P = pair<int, int>;
using vs = vector<string>;
using vi = vector<int>;
using vvi = vector<vi>;
const int INF = 100010001;
const ll LINF = (ll)INF*INF*10;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int d, G;
    cin >> d >> G;
    vi p(d);
    vi c(d);
    vi sum(d);
    vi po(d);
    rep(i, d) {
        cin >> p[i] >> c[i];
        sum[i] = 100*(i+1)*p[i] + c[i];
        po[i] = 100*(i+1)*p[i];
    }

    int ans = INT_MAX;
    rep(i, 1<<d) {
        int now = 0;
        int num = 0;
        rep(j, d) {
            if((i >> j) & 1) {
                now += sum[j];
                num += p[j];
            }
        }
        now = G-now;
        if(now <= 0) {
            ans = min(ans, num);
            continue;
        }
        for(int j = d-1; j >= 0; --j) {
            if((i>>j)&1) continue;
            if(po[j] >= now) {
                ans = min(ans, num + (now+100*(j+1)-1)/(100*(j+1)));
                break;
            }
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 3660
import sys
import math
from collections import defaultdict, deque, Counter
from copy import deepcopy
from bisect import bisect, bisect_right, bisect_left
from heapq import heapify, heappop, heappush
    
input = sys.stdin.readline
def RD(): return input().rstrip()
def F(): return float(input().rstrip())
def I(): return int(input().rstrip())
def MI(): return map(int, input().split())
def MF(): return map(float,input().split())
def LI(): return list(map(int, input().split()))
def TI(): return tuple(map(int, input().split()))
def LF(): return list(map(float,input().split()))
def Init(H, W, num): return [[num for i in range(W)] for j in range(H)]
    
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 main():
    V, M = MI()
    uni = UnionFind(V)
    for i in range(M):
        a,b = MI()
        a-=1
        b-=1
        uni.union(a,b)
    
    print(uni.group_count()-1)

if __name__ == "__main__":
    main()

Measured memory_bytes: 78856
#include <bits/stdc++.h>
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

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 revrep(i, s) for (int i = s-1; i > 0; i--)
#define revrrep(i, s) for (int i = s-1; i >= 0; i--)
#define all(a)  begin((a)),end((a))
#define uniq(c) (c).erase(unique(all((c))), end((c)))

int main()
{
    int A, B, C; cin >> A >> B >> C;
    if (B/A >= C) cout << C << endl;
    else cout << B/A << endl;
}

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

int main() {
    ll a, b, t;
    cin >> a >> b >> t;
    cout << (t / a) * b << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define MOD 1000000007
#define INF 1<<30
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(ll i=(a); i<(b); i++)
#define RREP(i,a,b) for(ll i=(a); i>=(b); i--)
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll, ll> pl;
typedef vector<pair<ll, ll>> vpl;

struct UnionFind{
    vl p;
    vl rank;
    ll cnt;

    UnionFind(ll n){
        rank.resize(n,0);
        p.resize(n,0);
        rep(i,n){
            p[i] = i;
            rank[i] = 0;
        }
        cnt = n;
    }

    int find(int x){
        if(x != p[x]) p[x] = find(p[x]);
        return p[x];
    }

    void unite(ll x, ll y){
        x = find(x);
        y = find(y);
        if(x == y) return;
        cnt--;
        if(rank[x] > rank[y]){
            p[y] = x; 
        }else{
            p[x] = y;
            if(rank[x] == rank[y]) rank[y]++;
        }
    }

    ll getcnt(){
        return cnt;
    }
};

int main(){
    ll n,m;
    cin >> n >> m;
    struct UnionFind uf(n);
    ll x,y,z;
    rep(i,m){
        cin >> x >> y >> z;
        x--; y--;
        uf.unite(x, y);
    }
    cout << uf.getcnt() << "\n";
    return 0;
}

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

const string YES = "Yes";
const string NO = "No";

void solve(long long N, long long A){
    int d = N % 500;
    if (A >= d) cout << YES << endl; else cout << NO << endl;
}

// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
    scanf("%lld",&N);
    long long A;
    scanf("%lld",&A);
    solve(N, A);
    return 0;
}


Measured memory_bytes: 3776
#include<stdio.h>

int main()
{
 int n,i,j,c1,c2=0,k;

 scanf("%d",&n);

 if(n==1)
 printf("1\n");

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

    k=i;

       while(k!=0)
        {
          if(k%2==0)
          {
             c++;
             c1=c;
          }

          k=k/2;
        }

        if(c1>c2)
           {
              c2=c1;
              j=i;
              }
     }

  printf("%d\n",j);}

 return 0;
}


Measured memory_bytes: 128
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
const int INF = 1000000007;
using P=pair<int,int>;
vector<int> d(200005,0);
signed main(){
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int n,m,k,l;
  cin>>n>>m;
  queue<int> q;
  d[0]=1;
  q.push(0);
  vector<int> L[n+m];//人間は0~n-1,言語はn~n+l-1
  for(int i=0;i<n;i++){
    cin>>k;
    for(int j=0;j<k;j++){
      cin>>l;
      L[i].emplace_back(l+n-1);
      L[l+n-1].emplace_back(i);
    }
  }
  while(q.size()){
        int t=q.front();q.pop();
        for(auto y:L[t]){
            if(d[y]==0){d[y]=1;q.push(y);}
            else{continue;}
        }
    }
  for(int i=0;i<n;i++){
      if(d[i]==0){cout<<"NO";return 0;}
  }
  cout<<"YES";
}


Measured memory_bytes: 9720
#include <bits/stdc++.h>
using namespace std;
typedef signed long long ll;

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N;
map<int,int> M;

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N;
	FOR(i,N) {
		cin>>x;
		M[x]++;
	}
	ll ret=0;
	FORR(r,M) {
		if(r.second<r.first) ret+=r.second;
		else ret+=r.second-r.first;
	}
	cout<<ret<<endl;
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 4736
/*
 * Created by KeigoOgawa
 */


#include <cstdio>
#include <iostream>
#include <algorithm>
#include <queue>
#include <map>
#include <set>
#include <cassert>
#include <cmath>

#define INF (int)1e8
#define EPS 1e-10
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = (n) - 1; i >= 0; i--)
#define MIN(a, b) (a > b ? b : a)
#define MAX(a, b) (a > b ? a : b)
#define debug(x) cout << #x << ": " << x << endl
#define all(a) (a).begin(), (a).end()

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> PII;

string s;
bool used[28];
void solve() {
  REP(i, s.size()) {
    char c = s[i];
    if (used[28 - (c - 'a')]) continue;
    used[28 - (c - 'a')] = true;
    int t = i;
    FOR(j, i + 1, s.size()) {
      if (s[j] == c) {
        if ((j - t - 1) < 2) {
          cout << t+1 << " " << j+1 << endl;
          return;
        }
        t = j;
      }
    }
  }
  cout << "-1 -1" << endl;
}

int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> s;
  solve();
  return 0;
}


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

int main() {
  int N;
  string S;
  cin >> N;
  
  rep (i, N){
    cin >> S;
    if (S == "Y"){
      cout << "Four" << endl;
      break;
    }
    else if (i == N-1){
      cout << "Three" << endl;
      break;
    }
  }
  
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define pll pair <ll, ll>
#define mp make_pair
#define pyshnapyshnakaa ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define x first
#define y second
#pragma GCC optimize("O3")
// #pragma GCC optimize("Ofast")
// #pragma GCC optimize("unroll-loops")
#define plll pair <ll, pair <ll, ll>>
#define pllll pair <pair <ll, ll>, pair <ll, ll> >
#define psl pair <string, ll>
#define all(a) a.begin(), a.end()
#define vvl vector <vector <ll> >
 
typedef long long ll;
 
typedef long double ld;
 
using namespace std;
 
const ll maxn = 1e6 + 100;
const ll mod = 1e9 + 7;
const ll base = 239;

ll stbase[maxn];

vector <ll> hsh;

string all1;

ll gethsh(ll l, ll r) {
    ll hsh0 = (hsh[r + 1] - hsh[l] + mod) % mod;
    hsh0 *= stbase[maxn - l - 1];
    hsh0 %= mod;
    return hsh0;
}

bool eq(ll l1, ll r1, ll l2, ll r2) {
    return gethsh(l1, r1) == gethsh(l2, r2);
}

bool les(ll i, ll j) {
    ll L = -1, R = hsh.size(), M;
    while (R - L > 1) {
        M = (L + R) / 2;
        ll i1 = i + M;
        ll j1 = j + M;
        if (i1 > hsh.size() || j1 > hsh.size()) {
            R = M;
            continue;
        }
        if (eq(i, i1, j, j1)) {
            L = M;
        }
        else {
            R = M;
        }
    }
    return all1[i + R] < all1[j + R];
}

ll n, m, k, t;

int main() {
    pyshnapyshnakaa;
    ll q, w, e, a, b, c;
    cin >> n >> k;
    string s;
    cin >> s;
    stbase[0] = 1;
    for (q = 1; q < maxn; q++) {
        stbase[q] = stbase[q - 1] * base % mod;
    }
    for (q = 0; q < k; q++) {
        string s1 = s;
        reverse(&s1[0], &s1[n]);
        string all = s + s1;
        vector <ll> hsh1(all.size() + 1);
        // hsh[0] = 0;
        for (w = 0; w < all.size(); w++) {
            hsh1[w + 1] = hsh1[w] + stbase[w] * (all[w] - 'a' + 1);
            hsh1[w + 1] %= mod;
        }
        hsh = hsh1;
        all1 = all + char(0);
        ll best = 0;
        for (w = 1; w + n < all.size(); w++) {
            if (les(w, best)) {
                best = w;
            }
        }
        string nw = all.substr(best, n);
        // cout << best + n << " " << all.size() << " " << all << endl;
        bool good = 1;
        for (w = 1; w < nw.size(); w++) {
            if (nw[w] != nw[w - 1]) {
                good = 0;
            }
        }
        if (good) {
            cout << nw;
            return 0;
        }
        reverse(&nw[0], &nw[n]);
        s = nw;
    }
    reverse(&s[0], &s[n]);
    cout << s;
    return 0;
}


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

using namespace std;

const int N = 3000 + 77;
char S[N] , T[N];
int n , m , dp[N][N];
vector < char > A;
pair < int , int > Par[N][N];
inline void Upd(int i , int j , int ii , int jj , bool t = 0){
   if(dp[i][j] < dp[ii][jj] + t){
      Par[i][j] = make_pair(ii , jj);
      dp[i][j] = dp[ii][jj] + t;
   }
}
int main(){
   scanf("%s %s" , S + 1 , T + 1);
   n = strlen(S + 1);
   m = strlen(T + 1);
   for(int i = 1;i <= n;++ i)
      for(int j = 1;j <= m;++ j){
         Upd(i , j , i - 1 , j);
         Upd(i , j , i , j - 1);
         if(S[i] == T[j])
            Upd(i , j , i - 1 , j - 1 , 1);
      }
   int x = n , y = m;
   while(x > 0 && y > 0){
      auto it = Par[x][y];
      if(it.first == x - 1 && it.second == y - 1 && dp[it.first][it.second] < dp[x][y])
         A.push_back(S[x]);
      x = it.first;
      y = it.second;
   }
   while(A.size())
      cout << A.back() , A.pop_back();
   return 0;
}


Measured memory_bytes: 110848
def count_func(m,k):
    return k*(m-k+1)

N,M = list(map(int,input().split()))
x = list(map(int,input().split()))
y = list(map(int,input().split()))

x.sort()
y.sort()

x_line_sum = 0
y_line_sum = 0

for i in range(N-1):
    x_line_sum += (count_func(N-1,min(i+1,N-1-i)) * (x[i+1]-x[i]))%(10**9 + 7)

for i in range(M-1):
    y_line_sum += (count_func(M-1,min(i+1,M-1-i)) * (y[i+1]-y[i]))%(10**9 + 7)
 
print((x_line_sum*y_line_sum)%(10**9 + 7))

Measured memory_bytes: 18624
object Main extends App {
	val Array(d, n) = scala.io.StdIn.readLine.split(" ").map(_.toInt)

	if(n == 100){
		d match {
			case 0 => println(101)
			case 1 => println(10100)
			case 2 => println(1010000)  
		}
	}else{

		d match {
			case 0 => println(n)
			case 1 => println(n*100)
			case 2 => println(n*10000)
		}
	}
}

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

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repc(i, n) for (int i = 0; i <= int(n); i++)
#define rrepc(i, n) for (int i = int(n); i >= 0; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define repic(i, a, b) for (int i = int(a); i <= int(b); i++)
#define each(x, y) for (auto &x : y)
#define all(a) (a).begin(), (a).end()
#define bit32(x) (1 << (x))
#define bit64(x) (1ll << (x))
#define sz(v) ((int) v.size())

using namespace std;

using i64 = long long;
using f80 = long double;
using vi32 = vector<int>;
using vi64 = vector<i64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

inline void yes() { cout << "Yes" << endl; exit(0); }
inline void no() { cout << "No" << endl; exit(0); }
template <typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template <typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template <typename T> inline void amax(T &x, T y) { x = max(x, y); }
template <typename T> inline void amin(T &x, T y) { x = min(x, y); }
template <typename T> inline T exp(T x, i64 n, T e = 1) { T r = e; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template <typename T> istream& operator>>(istream &is, vector<T> &v) { each(x, v) is >> x; return is; }
template <typename T> ostream& operator<<(ostream &os, vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }

void solve() {
  int n;
  cin >> n;
  vector<pair<int, int>> ans;
  rep(i, n) rep(j, i) {
    int u = i + 1;
    int v = j + 1;
    if (n % 2 == 0 && u + v == n + 1) continue;
    if (n % 2 == 1 && u + v == n) continue;
    ans.emplace_back(v, u);
  }
  cout << sz(ans) << endl;
  rep(i, sz(ans)) {
    cout << ans[i].first << " " << ans[i].second << endl;
  }
}

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

typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> Pl;

const int INT_INF = 2147483646;
const ll LL_INF = 9223372036854775807;
const double PI=3.1415926535897932;

bool SecondCompare(const pair<int,int> &a,const pair<int,int> &b)
{
       return a.second<b.second;
}
 
bool SecondCompareDes(const pair<int,int> &a,const pair<int,int> &b)
{
       return a.second>b.second;
}

ll minll(ll a, ll b){
    if(a >= b)  return b;
    else    return a;
}

ll maxll(ll a, ll b){
    if(a >= b)  return a;
    else    return b;
}

string s;
ll ans;

int main(){
    ans = 700;
    cin >> s;
    for(int i = 0; i < s.length(); i++){
        if(s[i] == 'o'){
            ans += 100;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
function main(S) {
  S = S.replace(/\r?\n/g,' ').split('');
  let topping = 0;
  let food = 700;
  if(S[0] === 'o') ++topping;
  if(S[1] === 'o') ++topping;
  if(S[2] === 'o') ++topping;

  console.log(food+(100*topping));
}

main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 29544
// C++(GCC 9.2.1)
#include <bits/stdc++.h>
using namespace std;
using LL = long long;
#define repex(i, a, b, c) for(int i = a; i < b; i += c)
#define repx(i, a, b) repex(i, a, b, 1)
#define rep(i, n) repx(i, 0, n)
#define repr(i, a, b) for(int i = a; i >= b; i--)
LL a[202020], b[202020];

int main(){
    
    // 1. 入力情報.
    int N;
    scanf("%d", &N);
    rep(i, N) scanf("%lld %lld", &a[i], &b[i]);
    
    // 2. sort.
    sort(a, a + N);
    sort(b, b + N);
    
    // 3. 中央値の範囲を推定.
    LL ans = 1;
    int n = N / 2;
    if(N & 1) ans += b[n] - a[n];
    else      ans += (b[n] - a[n]) + (b[n - 1] - a[n - 1]);
    
    // 4. 出力.
    printf("%lld\n", ans);
    return 0;
    
}

Measured memory_bytes: 6932
#include<stdio.h>
int main(){
    char S[5];
    scanf("%s",S);
    if(S[0]!=S[1]&&S[1]!=S[2] && S[2]!=S[3]){
      printf("%s\n","Good");
       }else{
      printf("%s\n","Bad");
      }
        
    return 0;
  }

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

string to_string(string s) {
  return '"' + s + '"';
}

string to_string(const char* s) {
  return to_string((string) s);
}

string to_string(bool b) {
  return (b ? "true" : "false");
}

template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}

template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto &x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}

void debug_out() { cerr << endl; }

template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

void test_case() {
  string s, t;
  cin >> s >> t;
  vector<vector<int>> pos(255);
  for (int i = 0; i < (int) s.size(); ++i) {
    pos[s[i]].emplace_back(i);
  }
  long long res = 0;
  int left = s.size(), ctr = -1;
  for (int i = 0; i < (int) t.size(); ++i) {
    if (pos[t[i]].size() == 0) {
      cout << "-1\n";
      return;
    }
    int ind = upper_bound(pos[t[i]].begin(), pos[t[i]].end(), ctr) - pos[t[i]].begin();
    if (ind == (int) pos[t[i]].size()) {
      res += s.size() - ctr - 1;
      ctr = pos[t[i]].front();
      res += ctr + 1;
    } else {
      res += pos[t[i]][ind] - ctr;
      ctr = pos[t[i]][ind];
    }
  }
  cout << res << "\n";
}

int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  test_case();
  return 0;
}


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



int main() {
	int D;
	cin >> D;
	const int N = 26; // コンテストの種類
	vector<int> c(N);
	rep(i,N) cin >> c[i];
	vector<vector<int>> s(D, vector<int>(N));
	rep(i,D) rep(j,N) cin >> s[i][j];
	vector<int> t(D);
	rep(i,D) {
		cin >> t[i];
		t[i]--;
	}

	vector<int> last(N,-1);
	int sat = 0;  // 満足度

	rep(d,D) {
		last[t[d]] = d;
		sat += s[d][t[d]];
		rep(i,N) {
			sat -= c[i] * (d-last[i]);
		}
		printf("%d\n", sat);
	}

	return 0;
}


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

int main() {
    int n,m,a;
    cin>>n;
    cin>>m;
    while(m--) {
        cin>>a;
        n -= a;
    }
    if(n>=0) {
        printf("%d\n",n);
    } else {
        printf("-1\n");
    }
    return 0;
}

Measured memory_bytes: 3748
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cfloat>
#include <ctime>
#include <cassert>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <numeric>
#include <iomanip>
#include <fstream>
#include <bitset>
#include <array>

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define erep(i, n) for (int i = 0; i <= (int)(n); ++i)
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define clr(a, x) memset(a, x, sizeof(a))
#define sz(a) ((int)(a).size())
#define mp(a, b) make_pair(a, b)
#define ten(n) ((long long)(1e##n))

const int INF = 1e9+7;

typedef long long ll;
typedef pair<int, int> pii;

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

    int bd = a+b;
    int now = 0;
    int anow = 1;

    rep(i, s.size()) {
        if (s[i] == 'a') {
            if (now < bd) { cout << "Yes" << endl; now++; }
            else { cout << "No" << endl; }
        }
        else if (s[i] == 'b') {
            if (now < bd) {
                if (anow <= b) {
                    now++;
                    cout << "Yes" << endl;
                    anow++;
                }
                else {
                    cout << "No" << endl;
                    anow++;
                }
            }
            else {
                cout << "No" << endl;
            }
        }
        else {
            cout << "No" << endl;
        }
    }

}


Measured memory_bytes: 896
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        try (Scanner scanner = new Scanner(System.in);) {
            for(int i = 0; i < 5; i++) {
                if(scanner.nextInt() == 0) {
                    System.out.println(i + 1);
                    return;
                }
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}


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

int minD(vector<int> T, ll b) {
  for (int i = 0; i < 11; i++) {
    if (T[i + 1] and (b >> i) & 1) {
      T[i + 1]--; T[24 - (i + 1)]++;
    }
  }
  int res { 24 };
  T[24]++;
  for (int i = 0; i <= 24; i++) {
    if (T[i] == 2) return 0;
    for (int j = i + 1; j <= 24; j++) {
      if (T[i] and T[j]) res = min(res, j - i);
    }
  }
  return res;
}

int main() {
  int N; cin >> N;
  vector<int> T(25, 0);
  for (int i = 0; i < N; i++) {
    int D; cin >> D;
    T[D]++;
  }
  T[0]++;
  int ans { -1 };
  if (T[0] > 1 or T[12] > 1) ans = 0;
  for (int i = 0; i < 11; i++) {
    if (T[i + 1] > 2) ans = 0;
  }
  if (ans) {
    for (ll i = 0; i < (1 << 11); i++) ans = max(ans, minD(T, i));
  }
  cout << ans << endl;
  return 0;
}


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

answer = 0
for i in range(60):
    n_ones = np.count_nonzero(A & 1)
    answer += 2 ** i * (n - n_ones) * n_ones
    A >>= 1

print(answer % MOD)

Measured memory_bytes: 48820
N, L = map(int, input().split())

appletaste = []

for i in range(1, N + 1):
    appletaste.append(L + i - 1)

appletaste.insert(0, 0)

applesum = sum(appletaste)
abslog = 9999
eat = 0

# 総和と１個抜いたパイの味を比べる
for apple in range(1, N + 1):
    pie = applesum - appletaste[apple]
    if abs(applesum - pie) < abslog:
        abslog = abs(applesum - pie)
        eat = apple

print(applesum - appletaste[eat])

Measured memory_bytes: 3064
#include <iostream>
#include <queue>
#include <vector>
#include <cmath>
#include <map>
#include <algorithm>

using namespace std;

double dist(double x1, double y1, double x2, double y2)
{
    return sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2));
}

struct State {
    double d;
    int l, r;

    State () {}
    State (double d, int l, int r) : d{d}, l{l}, r{r} {}

    bool operator < (const State &s) const {
        return d > s.d;
    }
};

double dijkstra(const vector<double>& X, const vector<double>& Y)
{
    int N = X.size();
    map<int, map<int, double>> d;
    d[0][N - 1] = 0;

    priority_queue<State> pq;
    pq.push(State(0, 0, N - 1));

    while (!pq.empty()) {
        State s = pq.top(); pq.pop();
        int l = s.l, r = s.r;
        
        if (l > r) continue;
        if (d[l][r] < s.d) continue;
        if (l == r) return d[l][r];

        for (int i : {-1, +0, +1}) {
            int nl = l + i;
            for (int j : {-1, +0, +1}) {
                int nr = r + j;
                if (nl < 0 || nl >= N ||
                    nr < 0 || nr >= N) continue;

                if ((int)Y[nl] != Y[nr]) continue;
                
                double ld = dist(X[l], Y[l], X[nl], Y[nl]);
                double rd = dist(X[r], Y[r], X[nr], Y[nr]);
                double nd = s.d + ld + rd;
                
                if (d[nl].count(nr) == 0 || nd < d[nl][nr]) {
                    d[nl][nr] = nd;
                    pq.push(State(nd, nl, nr));
                }               
            }
        }       
    }
    return -1;
}

int main()
{
    int N;
    while (1) {
        cin >> N;
        if (N == 0) break;
        vector<int> x(N), y(N);
        vector<pair<double, double>> v;
        for (int i = 0; i < N; i++) {
            cin >> x[i] >> y[i];
            v.emplace_back(make_pair(x[i], y[i]));
        }
       
        for (int i = 0; i < N - 1; i++) {
            double s = 1;
            if (y[i] != y[i + 1]) {
                s = (double)(x[i + 1] - x[i]) / (y[i + 1] - y[i]);
            }
            
            if (y[i] < y[i + 1]) {
                for (int j = y[i]; j <= y[i + 1]; j++) {
                    v.emplace_back(make_pair(x[i] + s * (j - y[i]), j));
                }                
            } else {
                for (int j = y[i]; j >= y[i + 1]; j--) {
                    v.emplace_back(make_pair(x[i] + s * (j - y[i]), j));
                }
            }
        }       

        sort(v.begin(), v.end());
        v.erase(unique(v.begin(), v.end()), v.end());
        
        vector<double> X, Y;
        for (auto& p : v) {
            X.emplace_back(p.first);
            Y.emplace_back(p.second);
        }
            
        printf("%.10f\n", dijkstra(X, Y));
    }        
    return 0;
}

Measured memory_bytes: 45972
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <math.h>
#include <string.h>
#include <map>
#include <numeric>
#include <random>
#include <queue>
#include <deque>
#include <tuple>
#include <iomanip>

using namespace std;

const int MOD = 1000000007;
typedef long long ll;

using Graph = vector<vector<int> >;

int N;
Graph G;

vector<int> res;
vector<int> C;

int j=0;

void dfs(int v, int p) {
  res[v]=C[j];
  j++;
  for (auto nv : G[v]) {
    if (nv == p) continue;
    dfs(nv, v);
  }
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N;
  cin>>N;
  G.assign(N, vector<int>());
  res.assign(N,0);
  for(int i=0;i<N-1;i++){
    int a,b;
    cin>>a>>b;
    a--;b--;
    G[a].push_back(b);
    G[b].push_back(a);
  }
  for(int i=0;i<N;i++){
    int c;
    cin>>c;
    C.push_back(c);
  }
  sort(C.rbegin(),C.rend());
  int max_size=0;
  int max_index=0;
  for(int i=0;i<N;i++){
    if(G[i].size()>max_size){
      max_size=G[i].size();
      max_index=i;
    }
  }
  dfs(max_index,-1);
  cout<<accumulate(C.begin(),C.end(),0) - C[0] <<endl;
  for(int i=0;i<N-1;i++){
    cout<<res[i]<<' ';
  }
  cout<<res[N-1]<<endl;
}

Measured memory_bytes: 1280
def fizzbuzz(n):
	if n%15==0: return "FizzBuzz"
	if n%3==0: return "Fizz"
	if n%5==0: return "Buzz"
	return str(n)
while 1:
	try:
		m,n=map(int,raw_input().split())
		if m==0:break
		player=range(1,m+1)
		p=0
		for i in range(n):
			if fizzbuzz(i+1)!=raw_input():
				del player[p]
				m=len(player)
				if m==1:
					break
				p%=m
			else:
				p=(p+1)%m
		print " ".join(map(str,player))
	except:
		pass

Measured memory_bytes: 4560
#include<stdio.h>
#define ll long long
int main(){
  ll n;
  scanf("%lld",&n);
  ll ans=n;
  for(ll i=1;i*i<=n;i++){
    if(n%i)continue;
    else{
      ans=i+n/i-2;
    }
  }
  printf("%lld\n",ans);
}

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

int main(){
  
  int A, B, C, D;
  int sum1=0, sum2=0;
  cin >> A >> B >> C >> D;
  
  sum1=A*B;
  sum2=C*D;
  
  if (sum1>sum2){
    cout << sum1 << endl;
  }
  else {
    cout << sum2 << endl;
  }
}

  

Measured memory_bytes: 256
import java.util.Scanner;
 
      public class Main{
   
           public static void main(String args[]) {


    Scanner scan = new Scanner(System.in);

    int x = scan.nextInt();

    int a = scan.nextInt();


    if (x < a) {
    System.out.println("0");
    }else{
      System.out.println("10");
    }
  }
}

Measured memory_bytes: 22612
#include<bits/stdc++.h>				//Written by ThiDaiLoc
using namespace std;				//Team Three Wolves
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef vector<ll> vi;
typedef pair<ll,ll> pll;
typedef pair<ll,pll> triple;

#define fu(i,a,b)   for(ll i=a;i<=b;i++)
#define fd(i,b,a)   for(ll i=b;i>=a;i--)
#define fuv(i,a)    for(ll i=0;i<a.size();i++)
#define fdv(i,a)    for(ll i=(ll)a.size()-1;i>=0;i--)
#define ms(a,x)     memset(a, x, sizeof a)
#define prec(n)     fixed<<setprecision(n)
#define uni(a)      (a).erase(unique(all(a)), (a).end())
#define pb(i)       push_back(i)
#define popb()      pop_back()
#define sc(a)       cin>>a
#define sc2(a,b)    cin>>a>>b
#define pr(a)       cout<<a<<endl
#define pr2(a)      cout<<a<<" "
#define bit(n,i)    (((n)>>(i))&1)
#define lowb(a,n,x) lower_bound(a,a+n,x) -a
#define lowb2(a,x)  lower_bound(all(a),x) -a.begin()
#define all(x)      (x).begin(), (x).end()
#define sz(a)       (ll)a.size()
#define le(s)       (ll)s.length()		
#define ast(x,a,b)  assert(x>=a and x<=b)				
#define re          return 	
#define	mp(a,b)     make_pair(a,b)
#define se          second
#define fi          first 
#define debug(x)    cerr << #x << " = " << x << endl
#define INPUT       freopen("locin.txt", "r", stdin)
#define OUTPUT      freopen("locout.txt", "w", stdout)
inline ll isqrt(ll k) {ll r = sqrt(k) + 1; while (r * r > k) r--; return r;}
inline ll icbrt(ll k) {ll r = cbrt(k) + 1; while (r * r * r > k) r--; return r;}
inline ll minize(ll& a,ll b){return a=(a>b?b:a);}
inline ll maxize(ll& a,ll b){return a=(a<b?b:a);}
inline string toString(ll n) {stringstream ss; ss << n;return ss.str();}
double const eps = 1e-6;
ll const Base=1e9+7,oo=1e17,MAXN=1e6;


ll A[MAXN+5];

ll Solves(){
	
	ll n,m,k,cnt=0,ans=0,x,y,q,c,sum=0,v,t;
	// PROCESS IN HERE
	string s;
	sc(s);
	fu(i,0,le(s)-1){
		if(s[i]=='A')cnt++;
		else{
			if(s[i]=='B' and i+1<le(s) and  s[i+1]=='C'){
				ans+=cnt;
				i++;
				continue;
			}
			else{
				cnt=0;
			}
		}
	}
	pr(ans);


	re 0;
	// Hack it if you can :)
}

int main(){
	//INPUT;
	ll JUDGE_ONLINE = 1;
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	ll test=1;
//	sc(test);
	fu(T,1,test){
//		cout<<"Case #"<<T<<": ";
		Solves();
	}
	if (!JUDGE_ONLINE) cout << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";  
		
}

Measured memory_bytes: 720
/*Function Template*/
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
const int MAX = 510000;
const int MOD = 1000000007;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define Rep(i, n) for(ll i = 1; i < (n); i++)
#define ALL(a)  (a).begin(),(a).end()
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
ll fac[MAX], finv[MAX], inv[MAX];


template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll 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;
    }

}
ll Len(ll n) {
  ll s=0;
  while(n!=0) s++, n/=10;
  return s;
}


ll Sint(ll n) {
  ll m=0,s=0,a=n;
  while(a!=0) s++, a/=10;
  for(ll i=s-1;i>=0;i--) m+=n/((ll)pow(10,i))-(n/((ll)pow(10,i+1)))*10;
  return m;
}


ll Svec(vector<ll> v){
  ll n=0;
  for(ll i=0;i<v.size();i++) n+=v[i];
  return n;
}


ll GCD(ll a,ll b) {
  return b ? GCD(b,a%b) : a;
}


ll LCM(ll a,ll b){
  return a/GCD(a,b)*b;
}


ll Factorial(ll n){
  ll m=1;
  while(n>=1) m*=n,n--;
  return m;
}

vector<pair<char,ll>> runlength(string s,vector<pair<char,ll>> p){
  ll x=1;
  if(s.size()==1){
    p.push_back(pair<char,ll>(s[0],1));
    return p;
  }
  for(ll i=0;i<s.size()-1;i++){
    if(s[i]==s[i+1]){
      x++;
      if(i==s.size()-2){
        p.push_back(pair<char,ll>(s[i],x));
      }
    }else{
      p.push_back(pair<char,ll>(s[i],x));
      x=1;
      if(i==s.size()-2){
        p.push_back(pair<char,ll>(s[s.size()-1],x));
      }
    }
  }
  return p;
}


ll COM(ll n,ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

const int MAX_N=100010;
vector<bool> sieve_of_eratosthenes(){
  vector<bool> isPrime(MAX_N+1,true);
  for(int i=2;i<=MAX_N;i++){
    if(isPrime[i]){
      for(int j=2*i;j<=MAX_N;j+=i){
        isPrime[j]=false;
      }
    }
  }
  return isPrime;
}



/*↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓*/
int main() {
  IOS;
  ll a,b;
  while(cin>>a>>b){
    if(a==0 && b==0) return 0;
    rep(i,a){
      rep(j,b){
        cout<<'#';
      }
      cout<<endl;
    }
    cout<<endl;
  }
}


Measured memory_bytes: 3220
from sys import exit, stdin
X, N = [int(_) for _ in stdin.readline().rstrip().split()]
P = [int(_) for _ in stdin.readline().rstrip().split()]
ans = 0
for i in range(X+1):
    diff = [X-i, X+i]
    if diff[0] not in P:
        ans = diff[0]
        break
    if diff[1] not in P:
        ans = diff[1]
        break
print(ans)

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

int main()
{
    int N, M;
    scanf("%d %d", &N, &M);
    long *Ndash = (long *)malloc(sizeof(long) * N);
    long Mdash = 0;
    long Mwa = 0;
    for (int i = 0; i < N; i++)
    {
        Ndash[i] = 0;
    }
    for (int i = 0; i < M; i++)
    {
        int k;
        scanf("%d", &k);
        for (int j = 0; j < k; j++)
        {
            int temp;
            scanf("%d", &temp);
            Ndash[--temp] += 0x01 << i;
        }
    }
    for (int i = 0; i < M; i++)
    {
        int tmo = 0;
        scanf("%d", &tmo);
        Mwa += tmo << i;
    }
    int kosu = 0;
    for (long i = 0; i < pow(2, N); i++)
    {
        for(int j = 0; j < N; j++)
        {
            if((i >> j) & 0x01)
            {
                Mdash ^= Ndash[j];
            }
        }
        if(Mdash == Mwa) kosu++;
        Mdash = 0;
    }
    printf("%d\n", kosu);
    return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
  int n,i,a,ma=0,mi=1000;
  cin >> n;
  for(i=0;i<n;i++){
    cin >> a;
    ma=max(ma,a);
    mi=min(mi,a);
  }
  cout << ma-mi << endl;
  return 0;
}

Measured memory_bytes: 3492
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
  ll n;
  cin>>n;
  double a[n];
  ll i,j;
  for(i=0;i<n;i++)
    cin>>a[i];
  double sol[n][n+1];
  sol[0][0]=1-a[0];
  sol[0][1]=a[0];
  for(i=2;i<=n;i++)
  sol[0][i]=0;
  double sum=0;
  for(i=1;i<n;i++)
  {
	for(j=0;j<=n;j++)
    {
      if(j==0)
        sol[i][j]=sol[i-1][j]*(1-a[i]);
      else
        sol[i][j]=sol[i-1][j]*(1-a[i])+sol[i-1][j-1]*a[i];
        
    }
    
  }
  for(j=n/2+1;j<=n;j++)
  {
  	sum=sum+sol[n-1][j];
  }
  
  cout<<setprecision(10)<<sum<<endl;
  
}


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

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

int main(){
    int n; cin>>n;
    ll t[110];
    if(n==1){
        cin>>t[0];
        cout<<t[0]<<endl;
        return 0;
    }
    for(int i=0;i<n;i++)cin>>t[i];
    ll ans=t[0]/gcd(t[0],t[1])*t[1];
    for(int i=2;i<n;i++){
        ans=ans/gcd(ans,t[i])*t[i];
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
package main
 
import (
	"fmt"
)

func main() {

  var result int = 0
  var n int
  fmt.Scan(&n)
  for i:= 0; i< n; i++ {
  	var tmp int
    fmt.Scan(&tmp)
    result += tmp-1
  }
  fmt.Print(result)
  
}

Measured memory_bytes: 640
#include <iostream>
#include<vector>
#include<algorithm>
#include<utility>
#include<string>
using namespace std;
typedef long long int ll;
#define EPS 1e-9
#define pb push_back
#define FOR(i, a, b) for(ll i = a; i < b; i++)
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007
ll frog1(ll n,ll k,vector<ll> &h)
{
    vector<ll>dp(n,1e9);
    dp[0]=0;
    //dp[2]=abs(h[2]-h[1]);
    //dp[3]=
    FOR(i,1,n)
    {
        //dp[i]=1e9;
        FOR(j,1,k+1)
        {
            if(i-j<0)
            {
                break;
            }
            ll ans=dp[i-j]+abs(h[i]-h[i-j]);
            if(ans<dp[i])
                dp[i]=ans;
        }
        //cout<<i;
    }
    /*FOR(i,0,n)
    {
        cout<<dp[i]<<" ";
    }
    cout<<endl;*/
    return dp[n-1];
}
int main()
{
    std::ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,k;
    cin>>n>>k;
    vector<ll>h(n,0);
    FOR(i,0,n)
        cin>>h[i];
    cout<<frog1(n,k,h)<<endl;
    return 0;
}

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

int main()
{
	int data[101] = {0}, n, max = 0;

	while (cin >> n){
		data[n]++;
	}

	for (int i = 1; i < 101; i++){
		if (max < data[i]) max = data[i];
	}

	for (int i = 1; i < 101; i++){
		if (data[i] == max) cout << i << endl;
	}

	return (0);
}

Measured memory_bytes: 1164
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <math.h>
#include <deque>
using ll = long long;
using namespace std;

int main(){
    int a, b;
    cin >> a >> b;
    cout << (a+b)%24 << endl;
    return 0;
}


Measured memory_bytes: 256
D = int(input())
c = list(map(int, input().split()))
s = []

for i in range(D):
    tmp = list(map(int, input().split()))
    s.append(tmp)


ans = 0
for l in s:
    for i in range(26):
        l[i] = (l[i], i)
    l.sort(reverse=True)
    print(l[0][1]+1)


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

module Main where

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

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

solve :: [String] -> [String]
solve [] = []
solve (line:lines) =
    let [a,o,b] = words line in
    let x = s (read a) o (read b) in
    maybe [] (\l -> l : solve lines) x
    where
    s :: Int -> String -> Int -> Maybe String
    s a "+" b = Just $ show (a+b)
    s a "-" b = Just $ show (a-b)
    s a "*" b = Just $ show (a*b)
    s a "/" b = Just $ show (a`div`b)
    s _ _ _ = Nothing

--
main :: IO ()
main = do
    mapM_ putStrLn =<< pure . solve =<< lines <$> getContents

Measured memory_bytes: 3988
#![allow(unused_macros)]
#![allow(dead_code)]
#![allow(unused_imports)]

use text_io::*;

const U_INF: usize = 1 << 60;
const I_INF: isize = 1 << 60;

fn main() {
    let n: usize = read!();
    let mut ans = 0.0;
    for _ in 0..n {
        let x: f64 = read!();
        let u: String = read!();
        let mut num = 0.0;
        match &u[..] {
            "JPY" => num += x,
            "BTC" => num += x * 380000.0,
            _ => panic!("What the hell?"),
        }
        
        ans+=num;
    }
    
    println!("{}", ans);
}


Measured memory_bytes: 2164
N, M, C = map(int, input().split())
B = list(map(int, input().split()))
A = [list(map(int, input().split())) for i in range(N)]

cnt = 0
for i in range(N):
  ans = C
  for j in range(M):
    ans += A[i][j] * B[j]
  if ans > 0:
    cnt += 1
print(cnt)

Measured memory_bytes: 3060
'''A - Fifty-Fifty
https://atcoder.jp/contests/abc132/tasks/abc132_a

>>> main('ASSA')
Yes
>>> main('STOP')
No
>>> main('FFEE')
Yes

06.txt
>>> main('YSKY')
No

07.txt
>>> main('JJKP')
No

'''


def main(s):
    for _s in s:
        if s.count(_s) != 2:
            print('No')
            return

    print('Yes')


if __name__ == "__main__":
    main(input())


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define all(v) (v).begin(), (v).end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define endl '\n'

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

    int n;
    cin >> n;

    vector<int> a(n),b(n);
    rep(i,n) cin >> a[i];
    rep(i,n) cin >> b[i];

    int want = 0, left = 0;
    for(int i = 0; i < n; i++){
        if(a[i] > b[i]) want += (a[i] - b[i]);
        else if(a[i] < b[i]){
            left += (b[i] - a[i]) / 2;
        }
    }
    if(left >= want) cout << "Yes" << endl;
    else cout << "No" << endl;
}


Measured memory_bytes: 384
#include <stdio.h>
#include <string.h>


int main() {
    int N, L;
    scanf("%d %d", &N, &L);

    int i;
    char S[N][L+1];
    for(i=0; i<N; i++) {
        scanf("%s", S[i]);
    }

    char tmp[L+1];
    int j;
    for(i=0; i<N-1; i++) {
        for(j=i; j<N; j++) {
            if(strcmp(S[i], S[j])>0) {
                strcpy(tmp, S[i]);
                strcpy(S[i], S[j]);
                strcpy(S[j], tmp);
            }
        }
    }

    for(i=0; i<N; i++) {
        printf("%s", S[i]);
    }
    printf("\n");


    return 0;

}

Measured memory_bytes: 128