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

///******************************** C o n t a i n e r ********************************///

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;

///*********************************** C o n s t ***********************************///

const int       N=1e6+123;
const double    PI = acos(-1);
const ll        MOD=1000000007;                 ///1e9+7
ll dx[] = {+1, 0, -1, 0, +1, +1, -1, -1};       ///first 4 for adjacent
ll dy[] = {0, +1, 0, -1, +1, -1, +1, -1};
ll dx8[]= {+1, +1, -1, -1, +2, +2, -2, -2};    ///knights move
ll dy8[]= {+2, -2, +2, -2, +1, -1, +1, -1};

///********************************** M a r c o ***********************************///

#define pb push_back
#define MP make_pair
#define F first
#define S second
#define test int tc; cin>>tc; while(tc--)
#define forn(i,n) for(i=0;i<n;i++)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define sz(x) x.size()
#define el <<'\n'
#define sp <<' '
#define print(a) {for(auto x:a)cout<<x<<" ";cout<<endl;}
#define mem(a,b) memset(a, b, sizeof(a))
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) (a*(b/gcd(a,b)))
#define sqr(a) (a)*(a)

#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define file() freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define fraction() cout.unsetf(ios::floatfield); cout.precision(10); cout.setf(ios::fixed,ios::floatfield);

///*********************************** F u n c t i o n ***********************************///

ll powmod(ll a,ll b){ a%=MOD;if(!a) return 0;ll pr=1;while(b>0){if(b&1){pr*=a;pr%=MOD;--b;}a*=a;a%=MOD;b/=2;}return pr;}
ll modinverse(ll a){return powmod(a,MOD-2);}
bool isPrime(ll n){ if(n<=1)return false;if(n<=3)return true;if(n%2==0 or n%3==0)return false;for(ll i=5;i*i<=n;i+=6){if(n%i==0 or n%(i+2)==0)return false;}return true;}
void seive(bool a[]){ll mx=sqrt(N),ii,jj;for(ii=3;ii<=mx;ii+=2)if(!a[ii])for(jj=ii*ii;jj<N;jj+=2*ii)a[jj]=true;}
void numofdiv(ll a[]){ll mx=sqrt(N),ii,jj;for(ii=1;ii<=mx;ii++){for(jj=ii*ii;jj<N;jj+=ii){if(jj==ii*ii) a[jj]++; else a[jj]+=2;}}}
void sumofdiv(ll a[]){ll mx=sqrt(N),ii,jj;for(ii=1;ii<=mx;ii++){for(jj=ii*ii;jj<N;jj+=ii){if(jj==ii*ii) a[jj]+=ii; else a[jj]+=ii+jj/ii;}}}

///**************************************************** C o d e ****************************************************///
///-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=///



void _case()
{
    ll a,b;
    cin>>a>>b;
    if(a<10 and b<10) cout<<a*b el;
    else cout<<-1 el;
}

main()
{
    fastio();
    _case();

}


///Thank you.


///Brainless_Loco Terminates Here!


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

#define fi first
#define se second
#define mk(a,b) make_pair(a,b)

typedef long long ll;
typedef pair<ll,ll> pll;

ll N,K;
vector<pll> V;
vector<ll> R;
ll mod = 1000000007;
ll ans = 0;

ll pow_mod(ll a,ll b)
{
    if(b == 0)return 1;
    ll res = pow_mod(a * a % mod,b / 2);
    if(b & 1)res = res * a % mod;
    return res;
}

ll unit(ll n)
{
    ll num = pow_mod(K,(n + 1) / 2);

    for(int i = 0; i < V.size(); i++)
        if(n % V[i].fi == 0)num = (num - V[i].se + mod) % mod;
    V.push_back(mk(n,num));

    if(n % 2 == 0)return (num * (n / 2)) % mod;
    return num * n % mod;
}

int main()
{
    scanf("%lld%lld",&N,&K);

    for(ll i = 1; i <= (ll)sqrt(N); i++)
    {
        if(N % i == 0)
        {
            R.push_back(i);
            if(i * i != N)R.push_back(N / i);
        }
    }

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

    for(int i = 0; i < R.size(); i++)ans = (ans + unit(R[i])) % mod;
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 384
N=int(input())
S=[]
for i in range(0,N):
    S.append(input())
d={}
for s in S:
    if s not in d:
        d[s]=1
    else:
        d[s]+=1
A=[]
B=[]
for k in d:
    A.append([d[k], k])
    B.append(d[k])
A.sort(reverse=True)
B.sort(reverse=True)
M=B[0]
C=[]
for a in A:
    if a[0]==M:
        C.append(a[1])
C.sort()
for c in C:
    print(c)

Measured memory_bytes: 55692
package main

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

type Scanner struct {
	sc *bufio.Scanner
}

func NewScanner() *Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &Scanner{sc}
}

func (s *Scanner) nextStr() string {
	s.sc.Scan()
	return s.sc.Text()
}

func (s *Scanner) nextInt() int {
	i, e := strconv.Atoi(s.nextStr())
	if e != nil {
		panic(e)
	}
	return i
}

func (s *Scanner) nextRuneSlice() []rune {
	return []rune(s.nextStr())
}

func (s *Scanner) nextIntSlice(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextInt()
	}
	return res
}

func max(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m < i {
			m = i
		}
	}
	return m
}

func min(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m > i {
			m = i
		}
	}
	return m
}

func abs(x int) int {
	if x > 0 {
		return x
	}
	return -x
}

func pow(x, y int) int {
	res := 1
	for i := 0; i < y; i++ {
		res *= x
	}
	return res
}

type St struct {
	id, rest int
}

type ByRest []St

func (a ByRest) Len() int           { return len(a) }
func (a ByRest) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }
func (a ByRest) Less(i, j int) bool { return a[i].rest < a[j].rest }

func main() {
	sc := NewScanner()
	N := sc.nextInt()
	A := make([]St, N)
	for i := 0; i < N; i++ {
		A[i] = St{i, sc.nextInt()}
	}
	sort.Sort(ByRest(A))
	for i, s := range A {
		if i != 0 {
			fmt.Print(" ")
		}
		fmt.Print(s.id + 1)
	}
	fmt.Println()
}


Measured memory_bytes: 5632
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <stack>
#include <vector>
using namespace std;
const int INF = 0x3f3f3f3f;

int main(){
	int S[10005], T[10005];
	int n, q, ans = 0;
	cin >> n;
	for(int i = 0; i < n; i++)
		cin >> S[i];
	cin >> q;
	for(int i = 0; i < q; i ++)
		cin >> T[i];
	for(int i = 0; i < q; i ++)
		for(int j = 0; j < n; j ++)
			if(S[j] == T[i]){
				ans++;
				break;
			}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3076
#include <bits/stdc++.h>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
#define ALL(a) a.begin(), a.end()
#define fi first
#define se second
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,Q,K,A,B;
string S;
//const ll MOD = 998244353;
const ll MOD = (1e+9) + 7;
typedef pair<ll, ll> P;
const ll INF = (1LL<<58);

struct trie{
    mat G, num;
    vec dflt, dflt_num;
    trie() : G(1, vec(26, -1)), num(1, vec(26, 0)), dflt(26, -1), dflt_num(26, 0){}
    void append(string s){
        int now = 0;
        int last_id = *s.rbegin() - 'a';
        s.pop_back();
        for(char c : s){
            int id = c - 'a';
            if(G[now][id] == -1){
                G[now][id] = G.size();
                now = G.size();
                G.push_back(dflt);
                num.push_back(dflt_num);
            }else{
                now = G[now][id];
            }
        }
        ++num[now][last_id];
    }
    int ans(string s){
        int now = 0, res = 0, last_id = *s.rbegin() - 'a';
        vec place(26);
        rep(i,26) {
            place[i] = s.rend() - find(s.rbegin(), s.rend(), char('a' + i));
        }
        s.pop_back();
        rep(i,s.size()){
            rep(j, 26){
                if(place[j] >= i + 1) res += num[now][j];
            }
            now = G[now][s[i] - 'a'];
        }
        rep(j, 26){
            if(place[j] >= s.size() + 1) res += num[now][j];
        }
        return res;
    }
};

int main(){
    cin>>N;
    vector<string> s(N);
    trie data;
    rep(i,N) {
        cin>>s[i];
        reverse(ALL(s[i]));
        data.append(s[i]);
    }
    ll res = 0;
    rep(i,N){
        res += data.ans(s[i]) - 1;
    }
    cout<<res<<endl;
}


Measured memory_bytes: 487988
import sys
from collections import deque

n = int(input())
que = deque()

for i in range(n):
    command = sys.stdin.readline()[:-1]
    if command[0] == "i":
        que.appendleft(command[7:])
    elif command[6] == " ":
        try:
            que.remove(command[7:])
        except:
            pass
    elif command[6] == "F":
        que.popleft()
    else:
        que.pop()
print(*que)

Measured memory_bytes: 103336
#include <cstdio>
#include <algorithm>

using namespace std;

const int MAX_N = 1005;
const int MAX_W = 10005;
typedef long long ll;

int n,w[MAX_N],s[MAX_N],v[MAX_N],sm[MAX_N];
ll dp[MAX_N][MAX_W];

int main()
{
	scanf("%d",&n);
	for (int i=1; i<=n; i++)
	{
		scanf("%d %d %d",w+i,s+i,v+i);
		sm[i]=i;
	}
	sort(sm+1,sm+1+n,[](const int &a, const int &b) {
		int d1=min(s[a]-w[b],s[b]);
		int d2=min(s[b]-w[a],s[a]);
		if (d1==d2)
			return a<b;
		return d1<d2;
	});
	for (int i=1; i<=n; i++)
		for (int j=0; j<MAX_W; j++)
		{
			dp[i][j]=dp[i-1][j];
			if (w[sm[i]]<=j)
				dp[i][j]=max(dp[i][j],
					v[sm[i]]+dp[i-1][min(s[sm[i]],j-w[sm[i]])]);
		}
	ll ans=0;
	for (int i=1; i<=n; i++)
		ans=max(ans,v[sm[i]]+dp[i-1][s[sm[i]]]);
	printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 78336
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;
using static System.Math;

namespace AtTest.ABC_169
{
    class A
    {
        static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(OpenStandardOutput()) { AutoFlush = false };
            SetOut(sw);

            Method(args);

            Out.Flush();
        }

        static void Method(string[] args)
        {
            int[] ab = ReadInts();
            WriteLine(ab[0] * ab[1]);
        }

        private static string Read() { return ReadLine(); }
        private static char[] ReadChars() { return Array.ConvertAll(Read().Split(), a => a[0]); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
    }
}


Measured memory_bytes: 27332
#include<iostream>
#include<cassert>
#include<stdexcept>
#include<utility>
#include<functional>
#include<numeric>
#include<cmath>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<array>
#include<stack>
#include<queue>
#include<deque>
#include<vector>
#include<complex>
#include<set>
#include<map>
#include<unordered_map>
#include<unordered_set>
#include<string>
#include<bitset>
using namespace std;
using ll=long long;

int main(){
    int k,x;
    cin>>k>>x;
    for(int i=x-k+1;i<x+k-1;i++){
        cout<<i<<" ";
    }
    cout<<x+k-1<<endl;
    
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
const int M = 2e5+10;
int head[M];
struct edge{
    int t,n;
    edge(){}
    edge(int t,int n):t(t),n(n){}
}edg[M<<1];
bool vis[M];
int dis[M];
int n,m;
int cnt;
void add(int f,int t){
    edg[cnt]=edge(t,head[f]);
    head[f]=cnt++;
}
struct node{
    int v,c;
    node(){}
    node(int v,int  c):v(v),c(c){}
    bool operator <(const node &a )const {
        return c>a.c;
    }
};
bool dij(){
    memset(dis,0x3f,sizeof(dis));
    memset(vis,false,sizeof(vis));
    priority_queue<node> q;
    q.push(node(1,0));
    dis[1]=0;
    node tem;
    while(!q.empty()){
        tem=q.top();
        q.pop();
        int u=tem.v;
        if(vis[u]) continue;
        vis[u]=true;
        for(int i=head[u];i!=-1;i=edg[i].n){
            int v=edg[i].t;
            if(!vis[v] && dis[v]>dis[u]+1){
                dis[v]=dis[u]+1;
                q.push(node(v,dis[v]));
            }
        }
    }
    return dis[n]==2;
}

int main(){
    while(scanf("%d%d",&n,&m)!=EOF){
        cnt=0;
        memset(head,-1,sizeof(head));
        int a,b;
        while(m--){
            scanf("%d%d",&a,&b);
            add(a,b);
        }
        puts(dij()?"POSSIBLE":"IMPOSSIBLE");
    }
    return 0;
}
/*
3 2
1 2
2 3

4 3
1 2
2 3
3 4

100000 1
1 99999

5 5
1 3
4 5
2 3
2 4
1 4
*/


Measured memory_bytes: 6264
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;

class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;

    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        } else {
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }

    private int readByte() {
        if (hasNextByte())
            return buffer[ptr++];
        else
            return -1;
    }

    private static boolean isPrintableChar(int c) {
        return 33 <= c && c <= 126;
    }

    public boolean hasNext() {
        while (hasNextByte() && !isPrintableChar(buffer[ptr]))
            ptr++;
        return hasNextByte();
    }

    public String next() {
        if (!hasNext())
            throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while (isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }

    public long nextLong() {
        if (!hasNext())
            throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while (true) {
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            } else if (b == -1 || !isPrintableChar(b)) {
                return minus ? -n : n;
            } else {
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }

    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
            throw new NumberFormatException();
        return (int) nl;
    }

    public double nextDouble() {
        return Double.parseDouble(next());
    }
}

public class Main {
    static int[] w = new int[100010];
    static int[] v = new int[100010];
    static int[][] dp = new int[110][100010];
    static int k;

    static int chmin(int a, int b) {
        if (a > b) {
            a = b;
            return a;
        }
        return a;
    }

    static int chmax(int a, int b) {
        if (a < b) {
            a = b;
            return a;
        }
        return a;
    }

    public static void main(String[] args) {
        FastScanner fs = new FastScanner();
        int r = fs.nextInt();
        int g = fs.nextInt();
        int b = fs.nextInt();
        if ((g * 10 + b) % 4 == 0)
            System.out.println("YES");
        else
            System.out.println("NO");
    }

}


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

int main(){
  
    string b;
    cin >> b;
  
  if(b=="A"){
    cout<<"T"<<endl;
  }else if(b=="T"){
    cout<<"A"<<endl;
  }else if(b=="G"){
    cout<<"C"<<endl;
  }else if(b=="C"){
    cout<<"G"<<endl;
     }
}



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

li = [2,5,5,4,5,6,3,7,6]

dp = [-1] * (n + 1)
dp[0] = 0

for i in range(n):
  for j in A:
    if i + li[j - 1] <= n:
      dp[i + li[j - 1]] = max(dp[i + li[j - 1]], dp[i] * 10 + j)
print(dp[-1])

Measured memory_bytes: 14692
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<cstring>
using namespace std;
char a[52],b[52];
int main(){
    cin>>a;
    cin>>b;
    int la=strlen(a),lb=strlen(b);
    int l=min(la,lb),ll=max(la,lb);
    for(int i=0;i<=l-1;i++) cout<<a[i]<<b[i];
    if(la>lb) for(int i=l;i<=ll-1;i++) cout<<a[i];
    else for(int i=l;i<=ll-1;i++) cout<<b[i];
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
using ll= long long ;
 
int main() {
  int n;
  cin >> n;
  vector<int> a(n),p(n), q(n);
  rep(i,n) cin >> p[i];
  rep(i,n) cin >> q[i];
  rep(i,n) a[i] = i+1;
  map<vector<int>, int> mp;
  do {
    mp[a] = mp.size();
  } while (next_permutation(a.begin(), a.end()));
  int ans = abs(mp[p] - mp[q]);
  cout << ans << endl;
}

Measured memory_bytes: 5248
package main

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

func main() {
	scanner := bufio.NewScanner(os.Stdin)

	scanner.Scan()
	x, err := strconv.Atoi(scanner.Text())
	if err != nil {
		log.Fatal(err)
	}

	if x == 0 {
		x = 1
	} else if x == 1 {
		x = 0
	}

	fmt.Println(x)
}


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

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

    sort(cost.begin(), cost.end());
    cost[n - 1] /= 2;

    cout << accumulate(cost.begin(), cost.end(), 0) << endl;

    return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <algorithm>
#include <string>
#include <limits.h>
using namespace std;
typedef long long LL;

int shopdata[100][10];
int profitInfo[100][11];

int openPeriod[10];
int main()
{
	int N;
	cin >> N;
	for (int i = 0;i < N;i++) {
		for (int j = 0;j < 10;j++) {
			cin >> shopdata[i][j];
		}
	}
	for (int i = 0;i < N;i++) {
		for (int j = 0;j < 11;j++) {
			cin >> profitInfo[i][j];
		}
	}

	LL max = LLONG_MIN;
	for (int n = 1;n <= 1023;n++) {
		for (int k = 0;k < 10;k++) {
			openPeriod[k] = (n >> k) & 1;
		}//Generate every solution

		
		int collision[100];

		for (int i = 0;i < 100;i++)collision[i] = 0;

		for (int i = 0;i < 10;i++) {//i is the period number
			if (openPeriod[i]) {
				for (int j = 0;j < N;j++) {
					if (shopdata[j][i]==1)collision[j]++;
				}
			}
		}

		LL sum = 0;
		for (int i = 0;i < N;i++) {
			sum += profitInfo[i][collision[i]];
		}
		
		if (sum > max)max = sum;
	}
	cout << max;
	return 0;
}

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

int main() {
  int N;
  int L[2005];
  int i, j, k;
  int cnt = 0;
  cin >> N;
  for (i = 0; i < N; i++)
    cin >> L[i];
  sort(L, L+N);
  for (i = 0; i < N; i++) {
    for (j = i+1; j < N; j++) {
      // cout << distance(L+j, lower_bound(L,L+N,i+j)) << endl;
      if (distance(L+j, lower_bound(L,L+N,L[i]+L[j])-1) > 0)
        cnt += distance(L+j, lower_bound(L,L+N,L[i]+L[j])-1);
    }
  }
  cout << cnt << endl;
}


Measured memory_bytes: 256
//Zory-2019
#include<bits/stdc++.h>
using namespace std;
typedef __int128 ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define FR first
#define SE second
#define MP make_pair
#define PB push_back
#define vc vector
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define bin(x) (1ll<<(x))
#define fo(i,l,r) for(int i=(l),I=(r);i<=I;i++)
#define fd(i,r,l) for(int i=(r),I=(l);i>=I;i--)
#define Debug printf("Passing [%s] in LINE %d\n",__FUNCTION__,__LINE__)
#define debug(x) cerr<<#x<<'='<<x<<endl
#define mem(x) memset(x,0,sizeof x)
namespace mine
{
    ll qread()
    {
        ll ans=0,f=1;char c=getchar();
        while(c<'0' or c>'9') {if(c=='-')f=-1;c=getchar();}
        while('0'<=c and c<='9') ans=ans*10+c-'0',c=getchar();
        return ans*f;
    }
    void write(ll num){if(num<0) putchar('-'),num=-num;if(num>=10) write(num/10);putchar('0'+num%10);}
    void write1(ll num){write(num);putchar(' ');}
    void write2(ll num){write(num);putchar('\n');}
    template<typename T> void chmax(T &x,const T y) {x=(x>y?x:y);}
    template<typename T> void chmin(T &x,const T y) {x=(x<y?x:y);}
    ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}

    const int INF=0x3f3f3f3f;
    const int MOD=1e9+7;
    int mm(const int x){return x>=MOD?x-MOD:x;}
    template<typename T> void add(T &x,const int &y){x=(x+y>=MOD?x+y-MOD:x+y);}
    ll qpower(ll x,ll e,int mod=MOD){ll ans=1;while(e){if(e&1)ans=ans*x%mod;x=x*x%mod;e>>=1;}return ans;}
    ll invm(ll x){return qpower(x,MOD-2);}
    const int N=3e5+10;

    int is1[100];ll a[N];
    void main()
    {
        int n=qread();fo(i,1,n){a[i]=qread();fo(t,0,60)if(a[i]&bin(t))is1[t]++;}
        ll ans=0;
        fo(t,0,60)
        {
            int x=is1[t],y=n-x;
            ans+=1ll*x*y%MOD*(bin(t)%MOD)%MOD,ans%=MOD;
        }write(ans);
    }
};//(ans+MOD)%MOD
signed main()
{
    srand(time(0));
    mine::main();
}


Measured memory_bytes: 4992
import numpy as np
import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines

N = int(input())
A = np.array(list(map(int, input().split())))
num = np.arange(1,N+1)
P = num - A
Q = num + A
P.sort()
Q.sort()

ind_left = np.searchsorted(P, Q, side='left')
ind_right = np.searchsorted(P, Q, side='right')
cnt = np.sum(ind_right - ind_left)
print(cnt)

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

// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;

typedef long long int ll;
typedef long int li;

const ll mod = 1000000007;
const ll inf = 1000000000000000000;

typedef vector<int> vi;
typedef vector<li> vli;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<vi> vvi;
typedef vector<vli> vvli;
typedef vector<vll> vvll;
typedef vector<vs> vvs;
typedef map<ll, ll> mll;
typedef map<ll, string> mls;
typedef map<string, ll> msl;
typedef pair<ll, ll> pll;

// #define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#pragma GCC optimize("-O3")
#define FAST                          \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);
#define PI acos(-1)
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define pq priority_queue
#define lb lower_bound
#define ub upper_bound
#define all(v) v.begin(), v.end()
#define mini(a) *min_element(all(a))
#define maxi(a) *max_element(all(a))
#define tol(s) transform(s.begin(), s.end(), s.begin(), ::tolower);
#define tou(s) transform(s.begin(), s.end(), s.begin(), ::toupper);
#define FOR(i, j, k, in) for (ll i = j; i < k; i += in)
#define RFOR(i, j, k, de) for (ll i = j; i >= k; i -= de)
#define rep(i, j, k) FOR(i, j, k, 1)
#define rrep(i, j, k) RFOR(i, j, k, 1)
#define repc(v) for (auto it = v.begin(); it != v.end(); it++)
#define rrepc(v) for (auto it = v.rbegin(); it != v.rend(); it--)
#define T     \
    ll t;     \
    cin >> t; \
    while (t--)

ll gen()
{
    ll temp;
    cin >> temp;
    return temp;
}

ll power(ll a, ll b, ll m)
{
    ll res = 1;
    while (b > 0)
    {
        if (b & 1)
        {
            res = (res * a) % m;
            b--;
        }
        a = (a * a) % m;
        b = b >> 1;
    }
    return res;
}

ll gcd(ll a, ll b)
{
    if (a == 0)
        return b;
    else
        return gcd(b % a, a);
}
ll lcm(ll a, ll b) { return (a * b) / gcd(a, b); }

#define inpt(v) generate(all(v), gen)
#define sum(v) accumulate(all(v), 0LL)
#define vpll vector<pll>
#define umap unordered_map
#define uset unordered_set
#define print(v, n) rep(i, 0, n) cout << v[i] << " ";

int main()
{
    //   freopen("in.txt", "r", stdin);
    //   freopen("out.txt", "w", stdout);

    ll n;
    cin >> n;
    int f = 0;
    vpll v;
    rep(i, 0, n)
        v.pb({gen(), gen()});

    rep(i, 0, n - 2)
    {
        if ((v[i].ff == v[i].ss) and (v[i + 1].ff == v[i + 1].ss) and (v[i + 2].ff == v[i + 2].ss))
        {
            f = 1;
            break;
        }
    }

    if (f)
        cout << "Yes";
    else
        cout << "No";

    return 0;
}

Measured memory_bytes: 3632
from operator import add
import functools


n = input().split(" ")

list_homework = input().split(" ")
list_homework = [int(list_homework[i]) for i in range(len(list_homework))]  

rest_day = int(n[0]) - functools.reduce(add, list_homework)

if rest_day >= 0:
    print(rest_day)
else:
    print("-1")

Measured memory_bytes: 10436
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<math.h>
#include<iomanip>
#include<stdio.h>
using namespace std;

int main(){

  int h, w, cnt=0;
  string s[51];
  cin >> h >> w;

  for(int i=1; i<=h; i++){
    cin >> s[i];
  }

  for(int i=0; i<=h; i++){
    for(int j=0; j<w; j++){
      if(s[i][j]=='.'){
        if(s[i-1][j-1]=='#'){
          cnt++;
        }
        if(s[i-1][j]=='#'){
          cnt++;
        }
        if(s[i-1][j+1]=='#'){
          cnt++;
        }
        if(s[i][j-1]=='#'){
          cnt++;
        }
        if(s[i][j]=='#'){
          cnt++;
        }
        if(s[i][j+1]=='#'){
          cnt++;
        }
        if(s[i+1][j-1]=='#'){
          cnt++;
        }
        if(s[i+1][j]=='#'){
          cnt++;
        }
        if(s[i+1][j+1]=='#'){
          cnt++;
        }
        cout << cnt;
        cnt=0;
      } else if(s[i][j]=='#'){
        cout << '#';
      }
    }
    cout << endl;
  }

  return 0;
}

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

char block[50][50];
int dist[50][50];

const int di[] = {-1, 0, 1, 0};
const int dj[] = {0, -1, 0, 1};

int main() {
  int h, w;
  cin >> h >> w;
  int white = 0;
  rep(i, h) rep(j, w) {
    cin >> block[i][j];
    if (block[i][j] == '.') white++;
    dist[i][j] = -1;
  }

  queue<P> q;
  q.push(P(0, 0));
  dist[0][0] = 1;
  while (!q.empty()) {
    int i = q.front().first;
    int j = q.front().second;
    q.pop();
    rep(d, 4) {
      int ni = i + di[d], nj = j + dj[d];
      if (ni < 0 || ni >= h || nj < 0 || nj >= w) continue;
      if (block[ni][nj] == '#') continue;
      if (dist[ni][nj] != -1) continue;
      dist[ni][nj] = dist[i][j] + 1;
      q.push(P(ni, nj));
    }
  }
  if (dist[h - 1][w - 1] == -1) {
    cout << -1 << endl;
    return 0;
  }
  int ans = white - dist[h - 1][w - 1];
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<string>
#include<cstring>
#include<climits>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<deque>
#include<tuple>
#include<list>
#include<unordered_map>
#include <random>
#define ll long long
#define pii pair<int,int>
#define pp pair<pair<ll, ll>,pair<ll, ll>>
#define pll pair<ll,ll>
#define vii vector<int>
#define vll vector<ll>
#define lb lower_bound
#define pb push_back
#define mp make_pair
#define fi first
#define sc second
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=a;i<b;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define LB(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define UB(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
#define ERASE(v) v.erase(unique(v.begin(),v.end()),v.end())
// #define int ll
using namespace std;
const int INF = (1 << 30 ) - 1;
const ll LLINF = (1LL << 60LL);
const int MOD = 1000000007;
const int MAX = 510000;
const double pi = acos(-1);
const double eps = 1e-9;
ll dx[4] ={1,0,-1,0} , dy[4] ={0,1,0,-1};



int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    ll n;
    scanf("%lld", &n);
    char right[10],left[10];
    ll low=0,high=n-1;
    printf("0\n");
    fflush(stdout);
    scanf("%s",left);
    if(strcmp(left,"Vacant")==0){
        return 0;
    }
    printf("%lld\n",n-1);
    fflush(stdout);
    scanf("%s",right);
    if(strcmp(right,"Vacant")==0){
        return 0;
    }
    while(true){
        ll mid=(low+high)/2;
        printf("%lld\n",mid);
        fflush(stdout);
        char response[10];
        scanf("%s",response);
        if(strcmp(response,"Vacant")==0){
            return 0;
        }
        if((mid-low)%2==1){
            if(strcmp(left,response)==0){
                high=mid;
                strcpy(right,response);
            }
            else{
                low=mid;
                strcpy(left,response);
            }
        }
        else{
            if(strcmp(left,response)==0){
                low=mid;
                strcpy(left,response);
            }
            else{
                high=mid;
                strcpy(right,response);
            }
            
        }
    }
    return 0;
}


Measured memory_bytes: 852
N=int(input())
a =[]
for _ in range(0,N):
    a.append(int(input()))
b =[]
f=0
s=0
a.sort()
for i in range(0,N):
    if i==0:
        b.append(1)
    elif a[i]==a[i-1]:
        if b[f]==1:
            b[f]=0
        else:
            b[f]=1
    else:
        b.append(1)
        f=f+1
for i in range(0,len(b)):
    s=s+b[i]
print(s)

Measured memory_bytes: 8008
from collections import deque
from collections import Counter
from itertools import product, permutations,combinations
from operator import itemgetter
from heapq import heappop, heappush
from bisect import bisect_left, bisect_right, bisect
#pypyではscipy, numpyは使えない
#from scipy.sparse.csgraph import shortest_path, floyd_warshall, dijkstra, bellman_ford, johnson, minimum_spanning_tree
#from scipy.sparse import csr_matrix, coo_matrix, lil_matrix
#import numpy as np
from fractions import gcd
from math import ceil,floor, sqrt, cos, sin, pi, factorial
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10**8)
INF = float('inf')

def main():
  b = input()
  if b=='A':
    print('T')
  elif b=='T':
    print('A')
  elif b == 'G':
    print('C')
  else:
    print('G')
  
  
if __name__ == '__main__':
  main()

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

int main() {
	long a, b = -1000000, c = 1000000, n, i, sum = 0;
	do {	
		cin >> n;
	}while(n < 0 && n <= 10000);
	for(i = 1; i <= n; i++) {
		do {	
			cin >> a;
		}while(n <= -1000000 && a <= 1000000);
		if (a >= b) {
			b = a;
		}
		if (a <= c) {
			c = a;
		}
		sum = sum + a;
	}
	cout << c << " " << b << " " << sum <<endl;
}


Measured memory_bytes: 3096
#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))
//-------------------------------------------------------

template<int um> class UF {
	public:
	vector<int> par,rank,cnt;
	UF() {par=rank=vector<int>(um,0); cnt=vector<int>(um,1); for(int i=0;i<um;i++) par[i]=i;}
	void reinit() {int i; FOR(i,um) rank[i]=0,cnt[i]=1,par[i]=i;}
	int operator[](int x) {return (par[x]==x)?(x):(par[x] = operator[](par[x]));}
	int count(int x) { return cnt[operator[](x)];}
	int operator()(int x,int y) {
		if((x=operator[](x))==(y=operator[](y))) return x;
		cnt[y]=cnt[x]=cnt[x]+cnt[y];
		if(rank[x]>rank[y]) return par[x]=y;
		rank[x]+=rank[x]==rank[y]; return par[y]=x;
	}
};
UF<500000> uf;

int N,Q;
ll M;
int A[101010],B[101010],C[101010];


void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N>>M>>Q;
	int is=0;
	FOR(i,Q) {
		cin>>A[i]>>B[i]>>C[i];
		if(C[i]==0) uf(A[i],B[i]);
		if(C[i]) is=1;
	}
	FOR(i,Q) if(C[i] && uf[A[i]]==uf[B[i]]) {
		cout<<"No"<<endl;
		return;
	}
	
	int NT=0;
	int NE=0;
	int C=0;
	FOR(i,N) if(uf[i]==i) {
		if(uf.count(i)==1) {
			C++;
		}
		else {
			C++;
			M-=uf.count(i)-1;
		}
	}
	
	if(is&&((C<=2) || (M==C-1))) {
		cout<<"No"<<endl;
		return;
	}
	
	M-=1LL*C*(C-1)/2;
	
	if(M<=0) cout<<"Yes"<<endl;
	else cout<<"No"<<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: 7296
#include <bits/stdc++.h>

using namespace std;

#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define REV(i,n) for(ll (i) = (n) - 1;(i) >= 0;--i)
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {REP(WW,n)cerr << v[WW] << ' ';cerr << endl << endl;}
#define SHOW2d(v,WW,HH) {REP(W_,WW){REP(H_,HH)cerr << v[W_][H_] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL
#define MOD 1000000007

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

ll mp[66];

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

	ll n;cin >> n;
	vector<ll> v(n);
	ll ans = 0;
	REP(i, n){
		cin >> v[i];
		REP(j, 61){
			if((v[i] & (1LL<<j)) == 0){
				ans = (ans + (((1LL<<j) % MOD) * mp[j]) % MOD) % MOD;
			}
			else {
				ans = (ans + (((1LL<<j) % MOD) * (i - mp[j])) % MOD) % MOD;
			}
		}
		REP(j, 61){
			if(v[i] & (1LL<<j))mp[j]++;
		}
		//cout << ans << endl;
	}

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


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

string a, t;
int main()
{
	int i, j;
	cin >> a >> t;
	for (i = a.size() - t.size() + 1; i >= 0; i--) {
		for (j = 0; j < t.size(); j++) if (a[i + j] != '?' && a[i + j] != t[j]) break;
		if (j == t.size()) {
			for (j = 0; j < t.size(); j++) a[i + j] = t[j];
			for (j = 0; j < a.size(); j++) if (a[j] == '?') a[j] = 'a';
			cout << a;
			return 0;
		}
	}
    cout << "UNRESTORABLE" << endl;
    return 0;
}

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

int main() {
  int W,H,N;cin>>W>>H>>N;
  int lx=0,rx=W,by=0,uy=H;
  for(int i=0; i<N; i++){
    int x,y,a;cin>>x>>y>>a;
    if(a==1)lx=max(lx,x);
    if(a==2)rx=min(rx,x);
    if(a==3)by=max(by,y);
    if(a==4)uy=min(uy,y);
  }
  int w=max(rx-lx,0);
  int h=max(uy-by,0);
  cout<<w*h<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define loop(i,a,b) for(int i=a;i<b;i++)
#define test() int t;cin>>t;loop(test,1,t+1)
#define pb push_back
#define eb emplace_back
#define mkp make_pair
#define nl cout<<"\n"
#define sp cout<<" "
#define F first
#define S second
#define vi vector<int>
#define vl vector<ll>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vii vector<pii>
#define vll vector<pll>
#define MOD 1000000007
#define all(x) x.begin(),x.end()

template<class C> void min_self( C &a, C b ){ a = min(a,b); }
template<class C> void max_self( C &a, C b ){ a = max(a,b); }

void mod( ll &n, ll m=MOD ){ n%=m,n+=m,n%=m; }

const int MAXN = 1e5+5;
int dx[] = {1,0,-1,0};
int dy[] = {0,1,0,-1};

int main() 
{
    fastio();

    int n;
    cin>>n;

    vector<int>a(n),pref(n+1);
    int sum = 0;
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
        pref[i+1] = pref[i] + a[i];
        sum += a[i];
    }

    int mn = sum;
    for(int i=0;i<n;i++)
    {
        int lsum = pref[i+1];
        int rsum = sum - lsum;

        int diff = abs(rsum-lsum);
        mn = min(mn,diff);
    }
    cout<<mn;

    cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
    return 0;
}

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

int main()
{
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	int a; cin >> a;
	long long int sum = 0;
	for (int i = 1; i <= a; ++i)
	{
		if (i % 5 == 0 || i % 3 == 0)
		{
			sum += 0;
		}
		else
			sum += i;
	}
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 3640
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<array>
#include<map>
#include<iomanip>
#include<assert.h>
#include<list>
#include<bitset>
#include<stack>
#include<memory>
#include<numeric>
using namespace std;
using namespace std::chrono;
typedef long long int llint;
typedef long double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
/*cout<<fixed<<setprecision(20);cin.tie(0);ios::sync_with_stdio(false);*/
const int mod=998244353 ;
const llint big=2.19e15+1;
const long double pai=3.141592653589793238462643383279502884197;
const long double eps=1e-10;
template <class T,class U>bool mineq(T& a,U b){if(a>b){a=b;return true;}return false;}
template <class T,class U>bool maxeq(T& a,U b){if(a<b){a=b;return true;}return false;}
llint gcd(llint a,llint b){if(a%b==0){return b;}else return gcd(b,a%b);}
llint lcm(llint a,llint b){if(a==0){return b;}return a/gcd(a,b)*b;}
template<class T> void SO(T& ve){sort(ve.begin(),ve.end());}
template<class T> void REV(T& ve){reverse(ve.begin(),ve.end());}
template<class T>llint LBI(const vector<T>&ar,T in){return lower_bound(ar.begin(),ar.end(),in)-ar.begin();}
template<class T>llint UBI(const vector<T>&ar,T in){return upper_bound(ar.begin(),ar.end(),in)-ar.begin();}
bool solve(void){
	int n,L,i,j;cin>>n>>L;
	if(n==0){return false;}
	//二分探索
	//2回やって大丈夫ならok
	vector<tuple<int,int,double>>use(n+n);
	double alluse=0;
	for(i=0;i<n;i++){
		int s,t;double u;cin>>s>>t>>u;
		use[i]=mt(s,t,u);
		use[i+n]=mt(s+86400,t+86400,u);
		alluse+=u*(t-s);
	}
	double bmin=alluse/86400,bmax=1e6;
	for(int kai=0;kai<65;kai++){
		double bgen;
		if(kai<20){bgen=sqrt((bmin+1)*(bmax+1))-1;}
		else{bgen=(bmin+bmax)/2;}
		
		double mae=0,tank=L;
		bool can=true;
		for(i=0;i<n+n;i++){
			int s,t;double u;
			tie(s,t,u)=use[i];
			tank+=bgen*(s-mae);
			mineq(tank,L);
			tank+=(bgen-u)*(t-s);
			mineq(tank,L);
			mae=t;
			if(tank<0){can=false;break;}
		}
		if(can){bmax=bgen;}
		else{bmin=bgen;}
	}
	cout<<bmax<<endl;
	return true;
}
int main(void){
	
	cout<<fixed<<setprecision(20);cin.tie(0);ios::sync_with_stdio(false);
	while(solve()){}
	return 0;
}



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

using namespace std;


const long long MOD = 1000000000+7;
long long dp[1000][1000];

int main() {
  int H, W;
  cin >> H >> W;
  vector<vector<bool>> wall;
  wall.assign(H, vector<bool>(W, false));
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      dp[i][j] = 0;
      char tmp;
      cin >> tmp;
      if (tmp == '#') {
        //cout << i << ' ' << j << endl;
        wall[i][j] = true;
      }
    }
  }

  dp[0][0] = 1;
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      if (i < H-1 && !wall[i+1][j]) dp[i+1][j] = (dp[i+1][j] + dp[i][j]) % MOD;
      if (j < W-1 && !wall[i][j+1]) dp[i][j+1] = (dp[i][j+1] + dp[i][j]) % MOD;
    }
  }
  cout << dp[H-1][W-1] << endl;
  return 0;
}

Measured memory_bytes: 8192
from collections import defaultdict


def check(x, ratemax, d):
    if 1 <= x <= 399:
        d[0] += 1
    elif 400 <= x <= 799:
        d[1] += 1
    elif 800 <= x <= 1199:
        d[2] += 1
    elif 1200 <= x <= 1599:
        d[3] += 1
    elif 1600 <= x <= 1999:
        d[4] += 1
    elif 2000 <= x <= 2399:
        d[5] += 1
    elif 2400 <= x <= 2799:
        d[6] += 1
    elif 2800 <= x <= 3199:
        d[7] += 1
    else:
        ratemax += 1
    return ratemax


def main():
    N, *a = map(int, open(0).read().split())
    d = defaultdict(lambda: 0)
    ratemax = 0
    for x in a:
        ratemax = check(x, ratemax, d)
    print(len(d) if len(d) else 1, len(d) + ratemax)
    return


main()


Measured memory_bytes: 3316
#include <bits/stdc++.h>
#define ll long long
#define fast ios::sync_with_stdio(0);cin.tie(0);
using namespace std;
 
 
int main() {
    fast
    unordered_map<int,int>cnt;
    int n,k;
    cin>>n>>k;
    for(int i=1;i<=k;i++)
    {
        int q;
        cin>>q;
        while(q--)
        {
            int x;cin>>x;
            cnt[x]++;
        }
    }
    int ans=0;
    for(int i=1;i<=n;i++)
        if(cnt[i]==0)ans++;

    cout<<ans;
    return 0;
}

Measured memory_bytes: 3668
#include<bits/stdc++.h>
using namespace std;
 
#define MOD 1000003
template<typename ty1,typename ty2>
inline int add(ty1 x, ty2 y) {
	if(y>=MOD)y%=MOD;
	if(x>=MOD)x%=MOD;
    x += y; return x < MOD ? x : x - MOD;
}
template<typename ty1,typename ty2>
inline void addto(ty1 &x, ty2 y) {
		  if(y>=MOD)y%=MOD;
		  if(x>=MOD)x%=MOD;
	      x += y; if (x >= MOD) x -= MOD;
}
template<typename ty1,typename ty2>
inline int sub(ty1 x, ty2 y) {
		if(y>=MOD)y%=MOD;
		 if(x>=MOD)x%=MOD;
        x -= y; return x < 0 ? x + MOD : x;
}
template<typename ty1,typename ty2>
inline void subto(ty1 &x, ty2 y) {
	if(y>=MOD)y%=MOD;
	if(x>=MOD)x%=MOD;
    x -= y; if (x < 0) x += MOD;
}
template<typename ty1,typename ty2>
inline int mul(ty1 x, ty2 y) {
        if(y>=MOD)y%=MOD;
		if(x>=MOD)x%=MOD;
        return 1ll * x * y % MOD;
}
template<typename ty1,typename ty2>
void multo(ty1 &x, ty2 y) {
        if(y>=MOD)y%=MOD;
		if(x>=MOD)x%=MOD;
        x=1ll * x * y % MOD;
}
 
 
long long int ppow(long long int i, long long int j){
		long long int res = 1LL;
		while (j){
			if ((j & 1LL)){
				res *= i;
				if (res >= MOD){
					res %= MOD;
				}
			}
			j >>= 1;
			i *= i;
			if (i >= MOD){
				i %= MOD;
			}
		}
		return res;
	}
class Combination{
	
public:
	vector<long long int> k;
	vector<long long int> r;
	void resize(int N){
		k.resize(N + 2);
		r.resize(N + 2);
		k[0] = 1;
		for (int i = 1; i < N+2; i++){
			k[i] = k[i - 1];
			k[i] *= i;
			if (k[i] >= MOD)k[i] %= MOD;
		}
		long long int al = k[k.size() - 1];
		long long int iv = ppow(k[k.size() - 1],MOD-2);
		r[k.size() - 1] = iv;
		for (int i = (int)(r.size()) - 2; i >= 0; i--){
			r[i] = r[i + 1] * (i + 1);
			if (r[i] >= MOD){
				r[i] %= MOD;
			}
		}
	}
	long long int C(int a, int b){
		if (a < b)return 0;
		long long int up = k[a];
		long long int dw = r[b] * r[a - b];
		dw %= MOD;
		up *= dw;
		up %= MOD;
		return up;
	}
	long long int H(int a, int b){
		return C(a + b - 1, b);
	}
	long long int catalan_number(int n){
		return (C(2 * n, n) + MOD - C(2 * n, n - 1)) % MOD;
	}
};
Combination C;



long long int extgcd(long long int a,long long int b,long long int &x,long long int &y){
	long long int d=a;
	if(b!=0){
		d=extgcd(b,a%b,y,x);
		y-=(a/b)*x;
	}
	else{
		x=1;
		y=0;
	}
	return d;
}
long long int modinverse(long long int a,long long int b){   //aの逆元を求める(mod b)
	long long int x,y;
	long long int d=extgcd(a,b,x,y);
	return (x%b+b)%b;
}

#define MAX 1000003

int q;

long long int k[MAX];
long long int inv[MAX];

inline long long int query(long long int x,long long int n){
	x%=MOD;
	if(x<=MOD&&MOD<=x+n-1){
		return 0;
	}
	if(x==0)return 0;
	return mul(k[x+n-1],inv[x-1]);
}

int main(){
	k[0]=1;
	inv[0]=1;
	for(int i=1;i<MAX;i++){
		k[i]=mul(k[i-1],i);
		inv[i]=modinverse(k[i],MOD);
	}
	cin>>q;
	while(q--){
		int x,d,n;
		scanf("%d%d%d",&x,&d,&n);
		if(d){
			multo(x,ppow(d,MOD-2));
			printf("%lld\n",mul(ppow(d,n),query(x,n)));
			continue;
		}
		printf("%lld\n",ppow(x,n));
	}
	return 0;
}



Measured memory_bytes: 16512
#include <iostream>
#include <algorithm>
#include <array>
#include <cstdint>
#include <functional>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string>
#include <utility>
#include <vector>
 
#define INF 1000000000
#define MOD 1000000007
#define rep(i,a,b) for(uint32 i = (a); i < (b); ++i)
#define bitget(a,b) (((a) >> (b)) & 1)
#define ALL(x) (x).begin(),(x).end()
#define C(x) std::cout << #x << " : " << x << std::endl
#define scanf scanf_s
 
using int32 = std::int_fast32_t;
using int64 = std::int_fast64_t;
using uint32 = std::uint_fast32_t;
using uint64 = std::uint_fast64_t;
 
 
 
int main(void) {
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	char c;
	rep(i, 0, 4) {
		std::cin >> c;
		std::cout << c;
	}
	std::cout << " ";
	rep(i, 0, 8) {
		std::cin >> c;
		std::cout << c;
	}
	std::cout << "\n";
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define PB push_back
#define MP make_pair
#define ff first
#define ss second
#define pri 1000000007
#define all(x) x.begin(),x.end()
#define prin(x) cout<<setprecision(12)<<fixed<<x<<endl;
using namespace std;
long double n;
long double dp[301][301][301];

long double solve(ll c1,ll c2,ll c3){
	if(c1==0&&c2==0&&c3==0)return 0;
	if(dp[c1][c2][c3]!=pri){return dp[c1][c2][c3];}
	long double f=n;
	long double eq=0;
	if(c1!=0)f-=c1,eq+=(c1*(solve(c1-1,c2,c3)))/n;
	if(c2!=0)f-=c2,eq+=(c2*(solve(c1+1,c2-1,c3)))/n;
	if(c3!=0)f-=c3,eq+=(c3*solve(c1,c2+1,c3-1))/n;
	return dp[c1][c2][c3]=n*(1.0+eq)/(n-f);
	
}

void masterstroke(){
	
	cin>>n;
	ll a;
	ll c1=0,c2=0,c3=0;
	for(ll i=0;i<=n;i++){
		for(ll j=0;j<=n;j++){
			for(ll k=0;k<=n;k++){
				dp[i][j][k]=pri;
			}
		}
	}
	for(ll i=0;i<n;i++){cin>>a;
						if(a==1)c1++;
						if(a==2)c2++;
						if(a==3)c3++;
	}
	prin(solve(c1,c2,c3));
}
int main() {
	ll t=1;
	for(ll i=0;i<t;i++)masterstroke();
	// your code goes here
	return 0;
}

Measured memory_bytes: 426368
<?php
fscanf(STDIN,'%d',$N);
$T=explode(" ",trim(fgets(STDIN)));
fscanf(STDIN,'%d',$M);
$T2=$T;
for ($i=0; $i <$M ; $i++) {
  // code...
  $T=$T2;
  $X=explode(" ",trim(fgets(STDIN)));
  $T[$X[0]-1]=$X[1];
  echo array_sum($T);
  echo "\n";
}


 ?>


Measured memory_bytes: 3576
#include <iostream>

using namespace std;

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

 

}


Measured memory_bytes: 3100
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    try (Scanner sc = new Scanner(System.in);) {
      int H = sc.nextInt();
      int W = sc.nextInt();
      sc.nextLine();
      int h = sc.nextInt();
      int w = sc.nextInt();

      boolean[][] array = new boolean[H][W];

      for (int i = 0; i < h; i++) {
        for (int j = 0; j < W; j++) {
          array[i][j] = true;
        }
      }
      for (int i = 0; i < w; i++) {
        for (int j = 0; j < H; j++) {
          array[j][i] = true;
        }
      }
      int count = 0;
      for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
          if (array[i][j] == false) {
            count++;
          }
        }
      }

      System.out.println(count);
    }
  }
}

Measured memory_bytes: 21972
while True:
    H,W = map(int,input().split())
    if W == H == 0:break
    for i in range(H):
        for j in range(W):
            if (i + j) % 2 == 0:
                print("#",end="")
            else:
                print(".",end="")
            j += 1
        print()
        i += 1
    print()


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

int a,b,c;

inline void read(int &x)
{
	x=0;char ch=getchar();bool f=false;
	while (ch<'0'||ch>'9'){if (ch=='-') f=true;ch=getchar();}
	while (ch>='0'&&ch<='9') x=(x<<3)+(x<<1)+ch-'0',ch=getchar();
	if (f) x=-x;return ;
}

int main()
{
	read(a);read(b);read(c);
	int m=a*10+b+c;
	int n=b*10+a+c;
	int p=c*10+b+a;
	printf("%d\n",max(m,max(p,n)));
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){


    long x,y;
    cin >> x >> y;
    
    long x_m;
    long gcd = 0;
    if(x<y){
        x_m = x;
        x = y;
        y = x_m;
        x_m = x%y;
    }else if(x>y){
        x_m = x%y;
    }else{
        x_m = x;
    }
    
    for(int i=x_m;i>0;i--){
        if(y%i==0 and x_m%i==0) {
            gcd = i;
            break;
        }
    }
    
    cout << gcd << endl;
}



Measured memory_bytes: 3108