akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vin=vector<int>;
using vll=vector<long long>;
using vvin=vector<vector<int>>;
using vvll=vector<vector<long long>>;
using vstr=vector<string>;
using vvstr=vector<vector<string>>;
using vch=vector<char>;
using vvch=vector<vector<char>>;
using vbo=vector<bool>;
using vvbo=vector<vector<bool>>;
using vpii=vector<pair<int,int>>;
using pqsin=priority_queue<int,vector<int>,greater<int>>;
#define mp make_pair
#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++)
#define all(v) v.begin(),v.end()
#define decp(n) cout<<fixed<<setprecision((int)n)
const int inf=1e9+7;
const ll INF=1e18;

int main(){
    int n,m;ll k;cin>>n>>m>>k;
    vll a(n),b(m);
    rep(i,n)cin>>a[i];
    rep(i,m)cin>>b[i];
    rep(i,n-1)a[i+1]+=a[i];
    rep(i,m-1)b[i+1]+=b[i];
    ll l,r,mid;ll M=0;
    rep(i,n){
        if(a[i]>k)break;
        l=-1;r=m;
        while(r-l>1){
        mid=(l+r)/2;
            if(a[i]+b[mid]>k)r=mid;
            else l=mid;
        }
        M=max(M,i+l+2);
    }
    b.push_back(INF);
    rep(i,m+1){
        if(b[i]>k){
            M=max(M,(ll)i);
            break;
        }
    }
    cout<<M<<endl;
}

Measured memory_bytes: 8000
#include<bits/stdc++.h>
using namespace std;
#define endl "\n"
#define fastio ios_base::sync_with_stdio(0);  cin.tie(0) ; cout.tie(0);
#define debug(x) cout << #x << " : " << x << endl;
#define pi 3.14159265359
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define F first
#define S second
using ll = long long int;
using db = double;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
typedef vector<ll> vl;
typedef vector<int> vi;
typedef vector<bool> vb;
const int MOD = 1e9+9;

void solve()
{
    int h ,w , k , ans = 0;
     cin >> h >> w >> k ;
     char a[h][w];
     for(int i = 0 ; i < h ; i++)
        for(int j = 0 ; j < w ; j++)
            cin >> a[i][j];

    for(int rm = 0 ; rm < (1<<h) ; rm++)
        for(int cm = 0 ; cm < (1<<w) ; cm++)
            {
                int c = 0;
                for(int i = 0 ; i < h ; i++)
                    for(int j = 0 ; j < w ; j++)
                        if(a[i][j] == '#' && ( rm&(1<<i)) && ( cm&(1<<j)))
                            c++;
                if(c == k)
                    ans++;
            }
    cout << ans << endl;
    
}

int main()
{
    fastio;

    ll t = 1;
    // cin >> t;
    while(t--)
       solve();
    return 0;
}

Measured memory_bytes: 3640
n = int(input())
a = tuple(map(int, input().split()))

s = sum(a)

m1 = s
for i in range(1, n, 2):
    m1 -= 2 * a[i]

ans = [""] * n
cnt = 0
while cnt < n:
    ans[(2 * cnt) % n] = str(m1)
    m1 += -2 * a[(2 * cnt) % n] + 2 * a[(2 * cnt + 1) % n]
    cnt += 1

print(" ".join(ans))

Measured memory_bytes: 74852
#include<bits/stdc++.h>
using namespace std;
const long long MAX {1005};

vector <pair<int,int>> adj = { {0,1},{1,0},{-1,0},{0,-1} };
queue <pair<int,int>> que;
vector <vector<bool>> visited(MAX,vector<bool>(MAX));
vector <vector<int>> dist(MAX,vector<int>(MAX));

pair <int,int> bfs(int h,int w)
{
    pair <int,int> u;
    //the queue is alread populated with the nodes we need to start
    dist[que.front().first][que.front().second] = 0;
    while (not que.empty())
    {
        u = que.front();
        que.pop();
        for (const auto& v : adj)
        {
            if (u.first + v.first > h-1
                or u.first + v.first < 0
                or u.second + v.second > w-1
                or u.second + v.second < 0 )
                continue;
            
            if (visited[u.first + v.first][u.second + v.second])
                continue;

            visited[u.first + v.first][u.second + v.second] = true;
            dist[u.first + v.first][u.second + v.second] = dist[u.first][u.second] + 1;
            que.push({u.first + v.first,u.second + v.second});
        }
    }
    return u;
}

int main(){
    // turn off the sinc with stdio.h to make the program faster
    ios::sync_with_stdio(false);
    int h,w;
    char dot;
    cin >> h >> w; 

    for(int i = 0; i<h; i++){
        for(int j = 0; j<w; j++){
            cin >> dot;
            // mark the node as unvisited
            if(dot == '.') visited[i][j] = false;
            else if(dot == '#'){
                // mark the node as visited
                visited[i][j] = true;
                // insert the node with # in the BFS queue
                que.push({i,j});
            }
        }
    }
    //capture the distance betwen the first read node and the last 
    auto res = bfs(h,w);

    cout << dist[res.first][res.second] << endl;

    return 0;
}

Measured memory_bytes: 12560
# https://qiita.com/_-_-_-_-_/items/34f933adc7be875e61d0
# abcde	s=input()	s='abcde'
# abcde	s=list(input())	s=['a', 'b', 'c', 'd', 'e']
# 5(1つだけ)	a=int(input())	a=5
# 1 2	| x,y = map(int,input().split())|	x=1,y=2
# 1 2 3 4 5 ... n 　	li = input().split()	li=['1','2','3',...,'n']
# 1 2 3 4 5 ... n 　	li = list(map(int,input().split()))	li=[1,2,3,4,5,...,n]
# FFFTFTTFF 　	li = input().split('T')	li=['FFF', 'F', '', 'FF']

# INPUT
# 3
# hoge
# foo
# bar
# ANSWER
# n=int(input())
# string_list=[input() for i in range(n)]

import collections
import math
def inpl(): return list(map(int, input().split()))

#### START
A, B = map(int,input().split())

if B%A == 0:
  print(A+B)
else:
  print(B-A)

Measured memory_bytes: 3444
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define fs first
#define sn second
#define mp make_pair
typedef long long int ll;

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

const ll mod = 1e9+7; 

//void precomp(){}

void solve(){
    
    int n,k=2;cin>>n;ll h[n];for(auto& i: h)cin>>i;
    vector<ll> dp(n,LONG_MAX);
    dp[0]=0;
    for(int i=1;i<n;i++){
    	for(int j=1;j<=k;j++){if(j>i)break;amin(dp[i],dp[i-j]+abs(h[i]-h[i-j]));}
    }
    cout<<dp[n-1]<<"\n";
}

int main(){
	
	ios_base::sync_with_stdio(false); 
	cin.tie(NULL);cout.tie(NULL);

    //precomp();
	
	//int tc;cin>>tc;while(tc--)
    solve();

    return 0;
}

Measured memory_bytes: 4764
#include<iostream>
using namespace std;
int main(){
    int n,m,x;
    cin >> n >> m >> x;
    int a;
    int cnt = 0;
    for(int i = 0;i<m;i++){
        cin >> a;
        if(a<x) cnt++;
    }
    cout << min(cnt,m-cnt) << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define pb push_back
#define ll long long
#define d1(x)  cerr << #x << "--> " << x << endl
#define d2(x, y)  cerr << #x << "--> " << x << " | " << #y << "--> " << y << endl
#define d3(x, y,z)  cerr << #x << "--> " << x << " | " << #y << "--> " << y <<" | " << #z << "--> "<< z<< endl
 
using namespace std;
 
bool compare(ll &x, ll &y){
    return x>=y;
}
 
ll mode=pow(10,9)+7;

 
int main(){ 
    
    
    ios::sync_with_stdio(0);
    cin.tie(0);
 
 	ll n;
 	cin>>n;
 	
	 vector<string> v;
	 for (int i=0;i<n;i++){
	 	string s;
	 	cin>>s;
	 	sort(s.begin(), s.end());
	 	v.pb(s);
	 }
	 
	 ll ans=0;
	 map<string, ll> mp;
	 for (int i=0;i<n;i++){
	 	mp[v[i]]++;
	 }
	 for (auto i:mp){
	 	ll add=i.second;
	 	add=add*(add-1)/2;
	 	ans=ans+add;
	 }
	 cout<<ans<<endl;
    return 0; 
}
	

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

#define DUMP(x) cout << #x << " = " << (x) << endl;
#define REP(i, n) for(size_t i = 0; i < (n); i++)
#define REPR(i, n) for(size_t i = (n); i >= 0; i--)
#define FOR(i, a, b) for(size_t i = (a); i < (b); i++)
#define FOREACH(x, a) for(auto& (x) : (a))

const int INF = 1e9;
const int MOD = 1e9 + 7;
const double EPS = 1e-9;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(15);
    int H1, M1, H2, M2, K; cin >> H1 >> M1 >> H2 >> M2 >> K;
    int ans = (H2 - H1) * 60 + (M2 - M1);
    ans -= K;
    cout << ans << "\n";
}

Measured memory_bytes: 3648
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <cstring>
#include <deque>
#include <stack>
#include <stdio.h>
#include <map>
#include <set>
#include <time.h>
#include <string>
#include <fstream>
#include <queue>
#include <bitset>
#include <cstdlib>
#include <assert.h>
#include <list>
#include <unordered_map>
#define X first
#define Y second
#define mp make_pair
#define pb push_back
#define pdd pair<double,double>
#define pii pair<ll,ll>
#define PI 3.14159265358979323846
#define MOD 1000000007
#define MOD2 1000000009
#define INF ((ll)1e+18)
#define x1 fldgjdflgjhrthrl
#define x2 fldgjdflgrtyrtyjl
#define y1 fldggfhfghjdflgjl
#define y2 ffgfldgjdflgjl
#define SQ 317
#define MAG 33554431
#define RED 0
#define BLUE 1
#define ALP 26
typedef long long ll;
typedef long double ld;
using namespace std;
ll i,j,k,l,m,r,x,y,K,tot,sz,cur,sum,n,c, maxlvl,q,z,N,ans;
ll a[400500], b[100500];
int main() {
	//freopen("input.txt","r",stdin);
 	//freopen("input.txt","w",stdout);
    cin >> n;
    for (i = 0; i < 3*n; i++)
        cin >> a[i];
    sort(a, a+3*n);
    reverse(a, a+3*n);
    for (i = 1; i < 2*n; i += 2)
        ans += a[i];
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 2560
using System;

class Problem
{
    static void Main()
    {
        string s = Console.ReadLine();
        int n = int.Parse(s[6].ToString());
        int m = int.Parse(s[5].ToString());
        //Console.WriteLine("{0}{1}", n, m);
        if (m==1 || n > 4) Console.WriteLine("TBD");
        else Console.WriteLine("Heisei");
    }
}

Measured memory_bytes: 13140
#include "bits/stdc++.h"

#define REP(i,num) for(ll i=0;i<(num);++i)
#define LOOP(i) while(i--)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto pitr=c.begin();pitr!=c.end();++pitr){cout<<*pitr;if(next(pitr,1)!=c.end())cout<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;

constexpr ll atcoder_mod = 1e9+7;

template<typename T=ll>
T in(){T x; cin >> x; return (x);}
template<typename T=ll,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in<T>();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

template<typename T>
bool chmax(T& a,T b){if(a<b){a=b;return true;}return false;}

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

	int N=in(),W=in();
	vll v(N),w(N);
	REP(i,N){
		v[i]=in(),w[i]=in();
	}
	vll dp(W+1,0);

	REP(i,N){
		REP(j,W+1){
			if(j+w[i]<=W) chmax(dp[j+w[i]],dp[j]+v[i]);
		}
	}

	out(dp[W]);
	return 0;
}



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

typedef long long int ll;
typedef long unsigned lu;
typedef vector<ll> v;
typedef pair<ll,ll> p;
typedef vector <p> vp;
#define rep(i,j,k) for(ll i=j;i<k;i++)
#define repr(i,j,k) for(ll i=k;i>=j;i--)
#define read(a,n) rep(i,0,n) cin>>a[i];
#define show(a,n) rep(i,0,n) cout<<a[i]<<" ";
#define modulus 1000000007
#define MAX 100005
#define INF 1000000001
// #define cinv vl a(n) rep(i,0,n) { cin>>a[i]; }
#define fastio() ios_base::sync_with_stdio(false); cin.tie(NULL);
ll a[MAX]={0};
ll dp[MAX];

int main()
{
    fastio();
    string s;
    cin>>s;
    ll sum=0;
    for (int i = 0; i < s.size(); i++)
    {
        sum+= s[i]-48;
    }
    if(sum%9==0)
        cout<<"Yes"<<"\n";
    else
        cout<<"No"<<"\n";
}

// void mod(ll l)
// {
//     if(l>=0)
//     {
//         cout<<l%modulus<<"\n";
//     }
//     else
//     {
//         while(l<0)
//         {
//             l+=modulus;
//         }
//         cout<<l<<"\n";
//     }
    
// }
 
// ll power(ll a, ll b)
// {
//     for (ll i = 1; i <= b; i++)
//     {
//         a*=a;
//     }
    
//     return a;
// }
 
// ll sumdigit(ll a)
// {
//     ll sum=0;
//     while(a)
//     {
//         a=sum%10;
//         a=a/10;
//     }
// }

Measured memory_bytes: 3688
#include <bits/stdc++.h>
using namespace std;
#define _MACRO(_1, _2, _3, NAME, ...) NAME
#define _repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define _rep(i,n) _repl(i,0,n)
#define rep(...) _MACRO(__VA_ARGS__, _repl, _rep)(__VA_ARGS__)
#define mp make_pair
#define pb push_back
#define all(x) begin(x),end(x)
#define uniq(x) sort(all(x)),(x).erase(unique(all(x)),end(x))
#define fi first
#define se second
#define dbg(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
void _dbg(string){cerr<<endl;}
template<class H,class... T> void _dbg(string s,H h,T... t){int l=s.find(',');cerr<<s.substr(0,l)<<" = "<<h<<", ";_dbg(s.substr(l+1),t...);}
template<class T,class U> ostream& operator<<(ostream &o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream &o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}
template<class T> ostream& operator<<(ostream &o, const set<T> &v){o<<"[";for(auto t:v){o<<t<<",";}o<<"]";return o;}
template<class T,class U> ostream& operator<<(ostream &o, const map<T,U> &v){o<<"[";for(auto t:v){o<<t<<",";}o<<"]";return o;}

int dsum(int x){
  string s = to_string(x);
  int ret = 0;
  for(auto i : s) ret += i-'0';
  return ret;
}

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

  int ans = 123456789;
  rep(i,1,n){
    int t = dsum(i) + dsum(n-i);
    ans = min(t, ans);
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
def valid?(a, b, c)
  a <= b + c && b <= c + a + 1 && c <= a + b + 1
end
 
def calc(rear, front, west, east, north, south, limit, best)
  path = [0] * limit
  limit.times do |i|
    a = rear + front
    b = west + east
    c = north + south
 
    if east > 0 && valid?(b - 1, c, a)
      rear, front, west, east = east - 1, west, rear, front
      y = 69
    elsif north > 0 && valid?(c - 1, a, b)
      rear, front, north, south = north - 1, south, front, rear
      y = 78
    elsif south > 0 && valid?(c - 1, a, b)
      rear, front, north, south = south - 1, north, rear, front
      y = 83
    #elsif west > 0 && valid?(b - 1, c, a)
    else
      rear, front, west, east = west - 1, east, front, rear
      y = 87
    end
     
    if best
      x = best[i]
      return best if x < y
      best = nil if x > y
    end
    path[i] = y  
  end
  path
end
 
def find(target, limit)
  best = nil
  target.permutation(6).to_a.uniq.each do |rear, front, west, east, north, south|
    a = rear + front
    b = west + east
    c = north + south
    if valid?(a, b, c)
      best = calc(rear, front, west, east, north, south, limit, best)
    end
  end
  best
end
 
loop do
  target = gets.split.map!(&:to_i)
  break if target.all?(&:zero?)
  p, q = gets.split.map!(&:to_i)
  result = find(target, q)
  puts result ? result[p-1...q].pack('C*') : 'impossible'
end

Measured memory_bytes: 114632
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
using namespace std;
typedef long long int ll;
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}


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

    int flag = 0;
    if((n/100)%100==0||(n/100)%100>12)flag++;
    if(n%100==0||n%100>12)flag+=2;

    if(flag==0){
        cout << "AMBIGUOUS" << endl;
    }
    if(flag==1){
        cout << "YYMM" << endl;
    }
    if(flag==2){
        cout << "MMYY" << endl;
    }
    if(flag==3){
        cout << "NA" << endl;
    }

    return 0;
}
 
 


Measured memory_bytes: 256
N,A,B,C=gets.split.map &:to_i
L=N.times.map{gets.to_i}.sort.reverse
m=A+B+C
(4**N).times.map{|i|
    s=i.to_s(4).rjust(N,"0").chars
    a=[];b=[];c=[]
    N.times{|j|
        a << L[j] if s[j]=="0"
        b << L[j] if s[j]=="1"
        c << L[j] if s[j]=="2"
    }
    if a!=[] && b!=[] && c!=[] then
        s=(a.size-1)*10+(a.inject(:+)-A).abs+(b.size-1)*10+(b.inject(:+)-B).abs+(c.size-1)*10+(c.inject(:+)-C).abs
        m=s if s<m
    end
}
p m

Measured memory_bytes: 2428
#include <stdio.h>

int main(void)
{
	unsigned short score1, score2, i, n, buf1, buf2;;

	while(1){
		score1 = 0;	score2 = 0;
		scanf("%u", &n);
		if(n == 0){ break; }
		for(i=0; i<n; i++){
			scanf("%u %u", &buf1, &buf2);
			getchar();
			if(buf1 > buf2){ score1 += buf1 + buf2; }
			else if(buf1 < buf2){ score2 += buf1 + buf2; }
			else{ score1 += buf1;	score2 += buf2; }
		}
		printf("%u %u\n", score1, score2);
	}
	return 0;
}

Measured memory_bytes: 612
def print_solve(ans):
    if "negative" in ans:
        print("NEGATIVE CYCLE")
    else:
        for l in ans:
            for c in l[:-1]:
                if c == float("inf"):
                    print("INF",end=" ")
                else:
                    print(c,end=" ")
            if l[-1] == float("inf"):
                print("INF")
            else:
                print(l[-1])

def solve(graph_data, num_v):
    ans = []

    for i in range(num_v):
        ans.append(partial_solve(graph_data, i, num_v))

    return ans

def partial_solve(graph_data, source, num_v):
    ans = [0 if i == source else float('inf') for i in range(num_v)]

    i = 0
    while (ans != solver_iteration(graph_data, ans)):
        ans = solver_iteration(graph_data, ans)
        i += 1
        if i >= num_v:
            return "negative"

    return ans

def solver_iteration(graph_data, prev_ans):
    new_ans = prev_ans[0:]

    for i, v in enumerate(new_ans):
        if v == float('inf') or i not in graph_data:
            continue

        for t, w in graph_data[i]:
                new_ans[t] = min(new_ans[t], v + w)

    return new_ans

def main():
    l = input().split()
    V = int(l[0])
    E = int(l[1])

    graph = {}
    for i in range(E):
        l = input().split()
        s = int(l[0])
        t = int(l[1])
        d = int(l[2])

        if s in graph:
            graph[s].append((t,d))
        else:
            graph[s] = [(t,d)]

    print_solve(solve(graph, V))

if __name__ == "__main__":
    main()

Measured memory_bytes: 9216
#include <bits/stdc++.h>
using namespace std;
int fx,fy,z,cnt;
vector<int> G[55];
int visit[2555][55];
int f(int x){
    visit[z][x]++;
    int r=1;
    for(int i:G[x]){
        if(x==fx&&i==fy)
            continue;
        if(x==fy&&i==fx)
            continue;
        if(visit[z][i])
            continue;
        r+=f(i);
    }
    return r;
}
int main(){
    ios_base::sync_with_stdio(false);cin.tie(NULL);
    int N,M;
    cin>>N>>M;
    while(M--){
        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++){
        for(int j:G[i]){
            fx=i,fy=j;
            if(f(0)!=N){
                cnt++;
            }
            z++;
        }
    }
    cout<<cnt/2;
    return 0;
}


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

using namespace std;

int count(string s, string comp){
    int result = 0;
    for(int i = 0; i < s.size(); i++)
    {
        if(s[i] != comp[i]) result++;
    }
    return result;
}

int main()
{
    string s;
    cin >> s;
    string pattern1, pattern2;
    for(int i = 0; i < s.size(); i++)
    {
        if(i % 2 == 0){
            pattern1.push_back('0');
            pattern2.push_back('1');
        }else{
            pattern1.push_back('1');
            pattern2.push_back('0');
        }
    }
    int result = count(s, pattern1);
    result = min(result, count(s, pattern2));
    cout << result << endl;
}

Measured memory_bytes: 960
/*Arnab's Code
*/
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mp(a,b) make_pair(a,b)
#define vll vector<ll>
#define vii vector<int>
#define pll pair<ll,ll>
#define pii pair<int,int>/*Arnab's Code
*/
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mp(a,b) make_pair(a,b)
#define vll vector<ll>
#define vii vector<int>
#define pll pair<ll,ll>
#define pii pair<int,int>
#define take(a,n) for(ll i=0;i<n;i++)cin>>a[i]
#define takes(a,n,st) for(ll i=st;i<n+st;i++)cin>>a[i]
ll sum(ll a[],ll n,ll s){ for(ll i=0;i<n;i++)s+=a[i]; return s;}
#define mod 1000000009
ll power(ll x, ll y, ll p)  {  
    ll res = 1;  
    x = x % p;   
    if (x == 0) return 0;  
    while (y > 0){  
        if (y & 1)  
            res = (res*x) % p;  
        y = y>>1;
        x = (x*x) % p;  
    }  
    return res;  
}
int parent[200017];
int size12[200017];
void make_set(int v) {
    parent[v] = v;
    size12[v] = 1;
}

int find_set(int v) {
    if (v == parent[v])
        return v;
    return parent[v] = find_set(parent[v]);
}

void union_sets(int a, int b) {
    a = find_set(a);
    b = find_set(b);
    if (a != b) {
        if (size12[a] < size12[b])
            swap(a, b);
        parent[b] = a;
        size12[a] += size12[b];
    }
}
void solve(){
	ll n,m,i,x,y;
	cin>>n>>m;
	for(i=0;i<=n;i++)
		make_set(i);
	for(i=0;i<m;i++){
		cin>>x>>y;
		union_sets(x,y);
	}
	cout<<*max_element(size12,size12+n+1);
	return;
}
int main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	#ifndef ONLINE_JUDGE
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
	#endif
	ll t,T;
//	cin>>T;
	T=1;
	for(t=1;t<=T;t++){
//		cout<<"Case #"<<t<<": ";
		solve();
	}
	return 0;
}


Measured memory_bytes: 5164
#include <iostream>
#include <utility>
#include <map>
#include <vector>
#include <algorithm>
#include <queue>
#include <math.h>
#include <stack>
#include <set>
#include <deque>
#include <cmath>

using namespace std;
typedef long long ll;
ll mod = 1e9+7;
#define rep(i,n) for(int i = 0; i < (n); ++i)

int main(){
    int sx, sy, tx, ty;
    cin >> sx >> sy >> tx >> ty;
    int dx = tx - sx;
    int dy = ty - sy;
    rep(i, dx) cout << "R";
    rep(i, dy) cout << "U";
    rep(i, dx) cout << "L";
    rep(i, dy) cout << "D";
    cout << "D";
    rep(i, dx+1) cout << "R";
    rep(i, dy+1) cout << "U";
    cout << "L";
    cout << "U";
    rep(i, dx+1) cout << "L";
    rep(i, dy+1) cout << "D";
    cout << "R";
    cout << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define double long double
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define mod (ll)(1e9+7)
#define inf (ll)(3e18+7)
#define pi (double) acos(-1)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
using namespace std;

int main() {
    int n, m, ans = 0;
    cin >> n >> m;
    vector<int> k(m), p(m);
    vector<vector<int>> s(m);
    rep(i, m){
        cin >> k[i];
        s[i].resize(k[i]);
        rep(j, k[i])cin >> s[i][j];
    }
    rep(i, m)cin >> p[i];
    for(int bit = 0; bit < (1<<n); bit++){
        bool ok = true;
        rep(i, m){
            int now = 0;
            rep(j, k[i]){
                if(bit & (1<<(s[i][j]-1)))now++;
            }
            if(now % 2 != p[i])ok = false;
        }
        ans += ok;
    }
    cout << ans << endl;
}


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

	cin >> s;
	REP(i, 3) {
		if(s[i] == '1')
			ans ++;
	}
	cout << ans;
}

Measured memory_bytes: 3620
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int k = sc.nextInt();

		if (( k == 1 )||( n == k)) {
			System.out.println(0);
		} else {
			System.out.println(n - k);
		}
	}

}


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

int main(){
    int t[100001];
    int x[100001];
    int y[100001];
    
    int N;
    cin>>N;
    
    for(int i=1;i<=N;i++){
        cin>>t[i]>>x[i]>>y[i];
    }

    for(int i=1;i<=N;i++){
        if(i==1){
            if(t[i]<x[i]+y[i]){cout<<"No"<<endl;return 0;}
        }
        else{
            int tm,dist;
            tm=t[i]-t[i-1];
            dist=abs(x[i]-x[i-1])+abs(y[i]-y[i-1]);
            if(tm<dist){
                cout<<"No"<<endl;return 0;
            }else if((dist-tm)%2){cout<<"No"<<endl;return 0;}
        }
    }
    cout<<"Yes"<<endl;
    return 0;
}

Measured memory_bytes: 1408
#include <iostream>
#include <climits>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <deque>
#define INF_INT (INT_MAX / 2)
#define INF_LONG (LONG_MAX / 2)
//#define DEBUG true
#define DEBUG false
using namespace std;

const int MAX = 100001;
const int MOD = 1000000007;

typedef long long ll;
typedef pair< int, int > pii;
typedef pair< ll, ll > pll;
typedef pair< ll, int > pli;
typedef pair< int, ll > pil;

int ceil(int x, int y){
  return (x % y == 0) ? x / y : x / y + 1;
}

int gcd(int x, int y){
  return y ? gcd(y, x % y) : x;
}

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

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

  int n, k;
  cin >> n >> k;
  int h[n];
  for(int i = 0; i < n; i++) cin >> h[i];

  sort(h, h + n);

  int ans = INF_INT;
  for(int i = 0; i + k - 1 < n; i++){
    ans = min(ans, h[i + k - 1] - h[i]);
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 888
N = int(input())
As = []
for i in range(N):
  A = int(input())
  As.append(A)
Is1 = sorted(range(N), key=lambda i: As[i])
Is = [-1]*N
for i in range(N):
  Is[Is1[i]] = i
#print(As)
#print(Is)
r = 0
for i in range(N):
  j = Is[i]
  if (j-i)%2 == 1:
    r += 1
r = r//2
print(r)


Measured memory_bytes: 14872
#include<bits/stdc++.h>
using namespace std;
#define FASTIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pil pair<int,ll>
#define pli pair<ll,int>
#define mod 1000000007
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
int main(){
FASTIO
string s1,s2;
cin>>s1;
cin>>s2;
int a,b;
cin>>a>>b;
string s3;
cin>>s3;
if(s1==s3){
	a--;
}
if(s2==s3){
	b--;
}
cout<<a<<" "<<b;
return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    std::ios::sync_with_stdio(false);
    int n,a,k=1;
    cin>>n;
    for(int i=0;i<n;i++)
    {
        cin>>a;
        if(a==k) k++;
    }
    if(k==1) cout<<-1;
    else cout<<n-k+1;
}


Measured memory_bytes: 384
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
int main() {
  long long A,B,C,K,ans=0;
  cin >> A >> B >> C >> K;
 
    if(K <= A){
        cout << K << endl;
    }
    else if(K <= A+B){
        cout << A << endl;
    }
    else{
        cout << A - (K-A-B) << endl;
    }
}

Measured memory_bytes: 3620
#include<stdio.h>
#include<bits/stdc++.h>
using namespace std;
const int maxn = 10005;
const int mod = 998244353;
int add(int x,int y) { x+=y; return x>=mod?x-mod:x; }
int sub(int x,int y) { x-=y; return x<0?x+mod:x; }
int mul(int x,int y) { return 1ll*x*y%mod; }
int sqr(int x) { return 1ll*x*x%mod; }
int fac[maxn],inv[maxn];
char s1[maxn],s2[maxn];
int n;
int f[maxn][maxn];
int GC(int x,int y) {  if(x<y) return 0;return mul(fac[x],mul(inv[y],inv[x-y])); }
int main() {
	fac[0] = 1; inv[0] = inv[1] = 1;
	for(int i=1;i<=10000;i++) fac[i] = mul(fac[i-1],i);
	for(int i=2;i<=10000;i++) inv[i] = mul(inv[mod%i],mod-mod/i);
	for(int i=1;i<=10000;i++) inv[i] = mul(inv[i-1],inv[i]);
	scanf("%s%s",&s1[1],&s2[1]); n = strlen(s1+1);
	int A=0,B=0;
	for(int i=1;i<=n;i++) if((s1[i]-'0')|(s2[i]-'0'))(s1[i]==s2[i] ?A++:B++);
	B/=2;
	if((!A)||(!B)) { printf("%d",sqr(fac[A+B])); return 0; }
	for(int i=0;i<=B;i++) f[0][i] = sqr(fac[i]);
	for(int i=1;i<=A;i++) {
		for(int j=1;j<=B;j++) {
			f[i][j] = add( mul(f[i][j-1],sqr(j)) , mul(f[i-1][j],mul(i,j)) );
		}
	}
//cerr<<f[A][B]<<endl;
	int ans = 0;
	for(int i=0;i<=A;i++) {
		ans = add(ans,mul(f[A-i][B],mul(GC(A,i),mul(GC(A+B,i),sqr(fac[i])))));
	}
	printf("%d",ans);
}

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

int main(){
  int N, D;
  if(scanf("%d %d", &N, &D) == EOF) exit(1);
  int X[N][D];
  for(int i = 0; i < N; i++){
    for(int j = 0; j < D; j++){
      if(scanf("%d", &X[i][j]) == EOF) exit(1);
    }
  }
  
  int count = 0;
  for(int i = 0; i < N-1; i++){
    for(int j = i+1; j < N; j++){
      double sum = 0;
      for(int k = 0; k < D; k++){
        sum += pow(X[i][k] - X[j][k], 2);
      }
      double distance_d = pow(sum, 0.5);
      int distance_i = distance_d;
      if(distance_d == distance_i) count++;
    }
  }
  printf("%d", count);
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <cstring>
#include <cstdio>
#include <cstring>
#include <string>
#include <cmath>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <vector>
#include <stack>
#include <bitset>

using namespace std;

#define FSIO  ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define DEBUG(a)   cout<<"DEBUG: "<<(a)<<endl;
#define ll long long
#define ull unsigned long long
#define ld long double
#define pb push_back
#define MP make_pair
#define X  first
#define Y  second
#define REP(i,st,ed)    for(int i=st;i<=ed;++i)
#define IREP(i,st,ed)   for(int i=st;i>=ed;--i)
#define TCASE(T)    cin>>T;while(T--)

const int MAXN = 5005;
const ll MOD = 1e9+7 ;
const ll LINF = 0x3f3f3f3f3f3f3f3f;
const int INF = 1e9+7;
const double PI = acos(-1.0);
const double EPS = 1e-8;

int _;

using namespace std;

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


int main()
{
    //freopen("test.in","r+",stdin);
    //freopen("test.out","w+",stdout);
    FSIO;
    int N;
    ll res;
    while(cin>>N)
    {
        ll tmp;
        cin>>res;
        REP(i,2,N)
        {
            cin>>tmp;
            res = gcd(res,tmp);
        }
        cout<<res<<endl;
    }

    return 0;
}


Measured memory_bytes: 256
N, K = map(int, input().split())
I = [list(map(int, input().split())) for i in range(K * 2)]

i = 0
dd = []
aa = []
for d in I:
	if (i % 2) == 0:
		dd.append(d)
	else:
		aa.append(d)
	i += 1
    
zz = [0 for i in range(N)]

for ii in aa:
    for i in ii:
        zz[i - 1] = 1
ans = 0
for i in zz:
    if (i == 0):
        ans += 1
print(ans)

Measured memory_bytes: 9220
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin>>N;
  vector<double>vec(N);
  for (int X=0;X<N;X++){
    cin>>vec.at(X);
  }
  sort(vec.begin(), vec.end());
  double M=vec.at(0);
  for (int X=1;X<N;X++){
    M+=vec.at(X);
    M/=2;
  }
  cout << M << endl;
}


Measured memory_bytes: 3784
#include <iostream>
#include <vector>
using namespace std;
int func1(int a,int b){
    return min(abs(a) + abs(a-b), abs(b) + abs(a-b));
}
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n,k;
    cin >> n >> k;
    vector<int> x(n); for(int i = 0; i < n; ++i){
        cin >> x[i];
    }
    long long ans = 1L<<60;
    for(int i = 0; i+k-1 < n; ++i){
        ans = min(ans, (long long)func1(x[i], x[i+k-1]));
    }
    cout << ans << endl;
    return 0;
}
//Saw the solution video

Measured memory_bytes: 3716
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
typedef long long ll;

const int maxn = 0;
ll x , y;

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(NULL);
	cin >> x >> y;
	ll now = x;
	int ans = 0;
	while(now <= y)
	{
		now = now * 2;
		ans++;
	}	
	cout << ans;
}

Measured memory_bytes: 256
import java.util.Scanner;
import java.time.Year;
import java.util.Random;
import java.math.*;

public class Main{
    public static void main(String[] args){
        Scanner sc =new Scanner(System.in);
        long n = sc.nextInt();
        String a = sc.next();
        char r = 'R';
        char w = 'W';
        int r_count = 0;
        int w_count = 0;
        int munipu = 0;
        for(int i=0; i<n; i++){
            if(a.charAt(i)==r){
                r_count++;
            }
        }
        for(int i=0; i<r_count; i++)
            if(a.charAt(i)!=r){
                munipu++;
            }
        System.out.println(munipu);
    }
}

Measured memory_bytes: 40304
#include <stdio.h>
int main(int argc, const char * argv[]) {
    long int t, n, m, p;
    long int z, w;
    scanf("%ld%ld", &n, &m);                           //用输入函数，在键盘上输入两个值
    w = n * m;
    if (n < m)                                        //判断两个数的大小，必须是较大的数除去较小的数
    {
        p = n;
        n = m;
        m = p;
    }
    while (m != 0)                                    //使用循环，用辗转相除法求出最大公约数
    {
        t = n % m;
        n = m;
        m = t;
    }
    z = w / n;                                       //利用求出的最大公约数求出最小公倍数
    printf("%ld",z);
    return 0;
}


Measured memory_bytes: 128
#include <stdio.h>
int main(void){
    int n,i,j;
    long k,a,ans=0,s,kb[40],c[40]={};
    scanf("%d%ld",&n,&k);
    for(i=0;i<n;i++){
        scanf("%ld",&a);
        for(j=0;j<40;c[j++]+=a%2,a>>=1);
    }
    k++;for(i=0;i<40;kb[i++]=k%2,k>>=1);
    for(i=0;i<40;i++)if(kb[i]){
        s=c[i]<<i;
        for(j=39;j>i;j--)s+=(kb[j]?n-c[j]:c[j])<<j;
        for(j=0;j<i;j++)s+=(c[j]>n/2?c[j]:n-c[j])<<j;
        ans=ans>s?ans:s;
    }
    printf("%ld",ans);
}

Measured memory_bytes: 128
import sys
sys.setrecursionlimit(1 << 25)
read = sys.stdin.readline
ra = range
enu = enumerate


def exit(*argv, **kwarg):
    print(*argv, **kwarg)
    sys.exit()


def mina(*argv, sub=1): return list(map(lambda x: x - sub, argv))
# 受け渡されたすべての要素からsubだけ引く.リストを*をつけて展開しておくこと


def a_int(): return int(read())


def ints(): return list(map(int, read().split()))


def read_col(H):
    '''H is number of rows
    A列、B列が与えられるようなとき
    ex1)A,B=read_col(H)    ex2) A,=read_col(H) #一列の場合'''
    ret = []
    for _ in range(H):
        ret.append(list(map(int, read().split())))
    return tuple(map(list, zip(*ret)))


def read_tuple(H):
    '''H is number of rows'''
    ret = []
    for _ in range(H):
        ret.append(tuple(map(int, read().split())))
    return ret


def read_matrix(H):
    '''H is number of rows'''
    ret = []
    for _ in range(H):
        ret.append(list(map(int, read().split())))
    return ret
    # return [list(map(int, read().split())) for _ in range(H)] # 内包表記はpypyでは遅いため


MOD = 10**9 + 7
INF = 2**31  # 2147483648 > 10**9
# default import
from collections import defaultdict, Counter, deque
from operator import itemgetter, xor, add
from itertools import product, permutations, combinations
from bisect import bisect_left, bisect_right  # , insort_left, insort_right
from functools import reduce
from math import gcd


def lcm(a, b):
    # 最小公倍数
    g = gcd(a, b)
    return a // g * b


N, D = ints()
ans = 0
for _ in range(N):
    if abs(complex(*ints())) <= D:
        ans += 1
print(ans)


Measured memory_bytes: 69532
#include "bits/stdc++.h"
using namespace std;

#define ASC(vec) vec.begin(), vec.end()    // 昇順ソート 例：sort(ASC(vec));
#define DESC(vec) vec.rbegin(), vec.rend() // 降順ソート 例：sort(DESC(vec));
#define rep(i, n) for (int i = 0; i < (n); i++)
#define Rep(i, n) for (int i = 1; i < n; i++)
#define REP(i, vec) for (auto i = vec.begin(); i != vec.end(); ++i)

const int       mod = 1000000007;
const int       inf = (1 << 21);
const long long INF = 1LL << 60;

using ll = long long;
using ii = pair<int, int>;
using vi = vector<int>;
using vd = vector<double>;
using vb = vector<bool>;
using vl = vector<ll>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;
using vvb = vector<vector<bool>>;
using vii = vector<pair<int, int>>;
using vll = vector<pair<ll, ll>>;

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; }
template<class T>
T GCD(T a, T b) { if (b == 0) return a; else return GCD(b, a % b); }
template<class T>
T LCM(T a, T b) { return a / GCD(a, b) * b; }

constexpr array<int, 9> dx = { 0, 1, 0, -1, -1, 1, 1, -1, 0 };
constexpr array<int, 9> dy = { 1, 0, -1, 0, 1, 1, -1, -1, 0 };

// ──────────────────────────────────────────────────────────────────

int main() {
	int m, f, b;
	cin >> m >> f >> b;

	if (b > m + f) {
		cout << "NA" << endl;
		return 0;
	}
	else {
		cout << max(b - m, 0) << endl;
	}
}


Measured memory_bytes: 3128
n = gets.chomp.split(//).map(&:to_i)

ans = 0
at = ''
bt = ''
ct = ''
2.times do |a|
  2.times do |b|
    2.times do |c|
      if a == 0
        at = '+'
        ans = n[0] + n[1]
      else
        at = '-'
        ans = n[0] - n[1]
      end
      if b == 0
        bt = '+'
        ans += n[2]
      else
        bt = '-'
        ans -= n[2]
      end
      if c == 0
        ct = '+'
        ans += n[3]
      else
        ct = '-'
        ans -= n[3]
      end
      if ans == 7
        puts n[0].to_s + at + n[1].to_s + bt + n[2].to_s + ct + n[3].to_s + '=7'
        exit
      end
    end
  end
end


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

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    string S;
    cin >> S;
    if (S.back() == 's') {
        cout << S << "es\n";
    } else {
        cout << S << "s\n";
    }
    return 0;
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }

int calc1(string n) {
  int nn = (int)n.size();
  int ans = 0;
  for (int digit=1; digit<=nn-1; digit++) {
    ans += 9;
  }
  ans += (int)(n[0] - '0');
  return ans;
}

int calc2(string n) {
  int nn = (int)n.size();
  int ans = 0;  
  for (int digit=1; digit<=nn-1; digit++) {
    ans += 81 * (digit - 1);
  }
  ans += (int)((n[0] - '0') - 1) * (nn-1) * 9;
  n[0] = '0';
  while (n.size() > 1) {
    if (n[0] == '0') {
      n.erase(n.begin());
    } else {
      break;
    }
  }
  ans += calc1(n);
  return ans;
}

int calc3(string n) {
  int nn = (int)n.size();
  int ans = 0;  
  for (int digit=1; digit<=nn-1; digit++) {
    ans += 729 * ((digit - 1) * (digit - 2) / 2);
  }
  ans += (int)((n[0] - '0') - 1) * (nn-1) * (nn-2) * 9 * 9 / 2;
  n[0] = '0';  
  while (n.size() > 1) {
    if (n[0] == '0') {
      n.erase(n.begin());
    } else {
      break;
    }
  }
  ans += calc2(n);
  return ans;
}

int main() {
  string n;
  int k;
  cin >> n;
  cin >> k;
  int ans = 0;
  int nn = (int)n.size();
  if (k == 1) {
    ans = calc1(n);
  } else if (k == 2) {
    ans = calc2(n);
  } else {
    ans = calc3(n);    
  }
    
  cout << ans << endl;
  
  return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std; 

int input1; 
int input2;
int input3;

int main () { 

    cin >> input1 >> input2 >> input3;
    int total = 0;

    if (input1 <= input2 && input1 <= input3){
        total = total + input1;
        if (input2 < input3){
            total = total + input2;
        }
        else{
            total = total + input3;
        }
    }

    else if (input2 <= input3 && input2 <= input1){
        total = total + input2;
        if (input1 < input3){
            total = total + input1;
        }   
        else{
            total = total + input3;
        }
    }

    else if (input3 <= input1 && input3 <= input2){
        total = total + input3;
        if (input2 < input1){
        total = total + input2;
        }
        else{
        total = total + input1;
        }
    }



    cout << total;

    return 0;
}

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

int main(){
  vector<int> X(5);
  rep(i,5){
    cin >> X[i];
    if(X[i]==0) cout << i+1 << endl;
  }
}


Measured memory_bytes: 3624
import numpy as np

N, M = map(int, input().split())
X = [int(i) for i in input().split()]

# 昇順
X.sort()

# numpy array 配列の差分
D = np.diff(X)

# numpy array 降順
D = np.sort(D)[::-1]

# numpy array 先頭から N - 2 まで 合計
print(X[-1] - X[0] - np.sum(D[:N - 1]))


Measured memory_bytes: 22960
def get_i() #空白区切の入力を数値(整数)の配列で返す
  return gets.chomp.split(" ").map(&:to_i)
end
def get_f() #空白区切の入力を数値(実数)の配列で返す
  return gets.chomp.split(" ").map(&:to_f)
end
def get() #空白区切の入力を文字列の配列で返す
  return gets.chomp.split(" ")
end
def get_nsp() #入力されたものを一文字ずつに区切った文字列の配列で返す
  return gets.chomp.split("")
end
def yn_judge(bool,y="Yes",n="No") #boolに真偽を投げることで、trueならy、falseならnの値を出力する
  return bool ? y : n 
end
def array(size,n=1,init=nil) #nに配列の次元数、sizeに配列の大きさ、initに初期値を投げることでその配列を返す
  if n==1
    return Array.new(size){init}
  else
    return Array.new(n).map{Array.new(size){init}}
  end
end

n=gets.to_i
a=get_i
ans=0
60.times do|i|
  cnt=0
  n.times do|j|
    case a[j][i]
    when 1 then
      cnt+=1
    end
  end
  ans+=2**i*cnt*(n-cnt)
  ans%=10**9+7
end
puts ans

Measured memory_bytes: 42404
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <cstring>
#include <utility>
#include <numeric>

using namespace std;

const int MOD = 998244353;

int main(){

    int N;
    cin >> N;

    vector<int> D(N);
    for(int i = 0; i < N; i++){
        cin >> D[i];
    }

    vector<int> cnt(N, 0);
    for(int i = 0; i < N; i++){
        cnt[D[i]]++;
    }

    if(cnt[0] != 1 || D[0] != 0){
        cout << 0 << endl;
    }
    else{
        long long ans = 1;
        int usedCnt = 1;
        for(int i = 1; i < N; i++){
            int tempCnt = cnt[i];
            if(tempCnt == 0){
                break;
            }

            int before = cnt[i - 1];
            long long temp = 1;
            for(int j = 0; j < tempCnt; j++){
                temp = (temp * before) % MOD;
            }

            ans = (ans * temp) % MOD;

            usedCnt += tempCnt;
        }

        if(usedCnt == N){
            cout << ans << endl;
        }
        else{
            cout << 0 << endl;
        }
    }

    return 0;
}

Measured memory_bytes: 1024
char s[999],t[99];u,p,i;main(z){for(;gets(s);--z&&puts(t+u))for(memset(t,i=0,99),t[u=p=30]=*s;s[i+1];u>p?u=p:0)t[p+=s[i+2]%3-1]=s[i+=3];}

Measured memory_bytes: 524
#include <iostream>
#include <iomanip>
#include <map>

using namespace std;

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

  int P[M], Y[M];
  for (int i=0; i<M; i++) {
    cin >> P[i] >> Y[i];
  }

  map<int, int> year_idx[100000];
  for (int j=0; j<M; j++) {
    year_idx[P[j]-1][Y[j]] = 0;
  }

  for (int i=0; i<N; i++) {
    int count = 1;
    for (auto& e:year_idx[i]) {
      e.second = count;
      count++;
    }
  }

  for (int i=0; i<M; i++) {
    cout << setfill('0') << setw(6) << right << P[i] << setfill('0') << setw(6) << right << year_idx[P[i]-1][Y[i]] << endl;
  }

  return 0;
}

Measured memory_bytes: 9468
N = int(input())
S = [input() for _ in range(N)]

cnt = 0
b = 0
a = 0
ab = 0
for x in S:
    cnt += x.count('AB')
    if x[0] == 'B' and x[-1] == 'A':
        ab += 1
        continue
    if x[0] == 'B':
        b += 1
    if x[-1] == 'A':
        a += 1
    

if (a>0 and b>0) or ab>=2:
    if a==0:
        a = 1
        ab -= 1
    if b==0:
        b = 1
        ab -= 1
    cnt += min(a,b) + ab

print(cnt)

Measured memory_bytes: 3700
#include <stdio.h>

int main()
{
    int N, T, menor = 1000, check = 0;

    scanf("%d %d", &N, &T);
    int c[N], n[N];
    for (int aux = 0; aux < N; aux++)
    {
        scanf("%d %d", &c[aux], &n[aux]);
    }
    for (int aux = 0; aux < N; aux++)
    {
        if (n[aux] <= T)
        {
            check = 1;
            if (c[aux] < menor)
            {
                menor = c[aux];
            }
        }
    }
    if (check == 1)
        printf("%d", menor);
    else

        printf("TLE");

    return 0;
}

Measured memory_bytes: 128
n = int(input())

odds = [i for i in range(1, n+1, 1) if i%2 != 0]
cnt_lists = []
for j in odds:
    cnt = 0
    for k in range(1, j+1, 1):
        if j%k == 0:
            cnt += 1
    cnt_lists.append(cnt)

ans = cnt_lists.count(8)
print(ans)

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

class Days{
	string week;
public:
	Days() : week("Thursday"){}
	void calcDays(int,int);
	int monthToDays(int);
	void calcWeek(int);
	void setWeek(int);
	const string getWeek(void);
};

int Days::monthToDays(int month){
	if(month == 2)
		return 29;//うるう年
	if(month == 4 || month == 6 || month == 9 || month == 11)
		return 30;
	return 31;
}

void Days::calcDays(int month,int days){
	week = ("Thursday");//コンストラクタで初期化済みだが念のために
	int day = 0;//1月1日から何日経ったか
	for(int i = 1; i < month; i++){
		day += monthToDays(i);
	}
	day += (days - 1);
	calcWeek(day);
}

void Days::calcWeek(int day){
	setWeek(day %= 7);
}

const string Days::getWeek(void){
	return week;
}

void Days::setWeek(int day){
	switch(day){
	case 0:
		week = "Thursday";
		break;
	case 1:
		week = "Friday";
		break;
	case 2:
		week = "Saturday";
		break;
	case 3:
		week = "Sunday";
		break;
	case 4:
		week = "Monday";
		break;
	case 5:
		week = "Tuesday";
		break;
	case 6:
		week = "Wednesday";
		break;
	}
}

int main(){
	Days d;
	int month,day;
	while(1){
		cin >> month >> day;
		if(month == 0 || day == 0)
			break;
		d.calcDays(month,day);
		cout << d.getWeek() << endl;
	}
	return 0;
}

Measured memory_bytes: 1200
#include <bits/stdc++.h>
using namespace std;
typedef long long  ll;
typedef vector<int> VI;
typedef vector<ll> VLL;

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

    sort(l.begin(), l.end());

    for(int i=0; i<n-1; ++i){
        k+= l[i];
    }
    
    if(k>l[n-1])cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}

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

using namespace std;


bool rucky(int n) {
    for (int i = 0; i <= 10; i++) {
        if (n % 10 == 7) {
            return true;
        }
        else {
            n /= 10;
        }
    }
    return false;
}

int main(void) {
    int n;

    cin >> n;
    if (rucky(n)) {
        cout << "Yes";
    }
    else {
        cout << "No";
    }

    return 0;
}


Measured memory_bytes: 3636
#include <iostream>
#include <iomanip>
#include<math.h>
#include<list>
#include <algorithm>
#include<set>
#include<vector>
#include<math.h>
#include<map>
#include<string>
#include <numeric>
#include <queue>
#include <sstream>
#include <bitset>
#include<stack>

using namespace std;
using ll = long long;
using vll = vector<long long>;
using sll = set<long long>;

template<typename T>
T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template<typename T>
T lcm(T a, T b) { return a / gcd(a, b) * b; }

template<typename T>
map<T, T> getPrimeFactor(T n) {
	map<T, T> res;
	for (T i = 2; i * i <= n; ++i) {
		while (n % i == 0) {
			res[i] ++;
			n /= i;
		}
	}
	if (n != 1) res[n] = 1;
	return res;
}

template<typename T>
bool IsPrimeNumber(T num)
{
	if (num <= 2) return true;
	else if (num % 2 == 0) return false;

	double sqrtNum = sqrt(num);
	for (int i = 3; i <= sqrtNum; i += 2)
	{
		if (num % i == 0)
		{
			return false;
		}
	}

	return true;
}

long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}

#define rep(i,s,e) for(ll i=s;i<e;i++)
#define repeq(i,s,e) for(ll i=s;i<=e;i++)



int main() {

	ll N;
	std::cin >> N;
	vll P(N + 1,0);
	ll A;

	repeq(i, 2, N) {
		cin >> A;
		P[A]++;
	}

	repeq(i, 1, N) {
		std::cout << P[i] << endl;
	}

	return 0;
}


Measured memory_bytes: 4844