akhauriyash/Code-Regression huggingface dataset:
cin = open(0).read().split('\n')

n, m = map(int, cin[0].split(' '))
s = []
for row in cin[1:1+m]:
    s.append(list(map(int, row.split(' ')[1:])))
p = list(map(int, cin[1+m].split(' ')))

ret = 0
for ai in range(2**n):
    flg = True
    for idx, si in enumerate(s):
        on_cnt = 0
        for sii in si:
            if (ai >> (sii-1)) & 1:
                on_cnt += 1
        if on_cnt % 2 != p[idx]:
            flg = False
    if flg:
        ret += 1

print(ret)

Measured memory_bytes: 40944
#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
using namespace std;
using Graph = vector<vector<int>>;
typedef pair<int,int> P;
typedef long long ll;

int main(){
	string s; cin >> s;
	string t = "";

	rep(i,s.size()){
		if(s[i] == 'A' || s[i] == 'B' || s[i] == 'C'){
			t += (s[i] + 23);
			continue;
		}

		t += (s[i] - 3);

	}

	cout << t << endl;

}


Measured memory_bytes: 3108
process.stdin.resume();
process.stdin.setEncoding('utf8'); 
var lines = [];
var reader = require('readline').createInterface({
	input: process.stdin,
	output: process.stdout
});
 
reader.on('line', (line) => {
	lines.push(line);
});

reader.on('close', () => {
	"use strict"
	const N = +lines[0];
	const A = lines[1].split(" ").map(Number);
	
	const numOfMinus = A.reduce((acc, n) => acc+(n<0), 0);
	const hasZero = A.some(n => n==0);
	const A_abs = A.map(Math.abs);
	let ans;
	if(!hasZero && numOfMinus%2){
		const min = A_abs.reduce((x, y) => Math.min(x,y));
		ans = A_abs.reduce((acc, n) => acc+n, 0) - 2*min;
	} else {
		ans = A_abs.reduce((acc, n) => acc+n, 0);
	}
	
	console.log(ans);
});

Measured memory_bytes: 31100
/****************************************************
*   Template for coding contests                    *
*   Author    :    Sanjeev Sharma                   *
*   Email     :    thedevelopersanjeev@gmail.com    *
*****************************************************/
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n;
    cin >>n;
    cout <<n*n*n;
    return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
N = int(input())
s = []
for _ in range(N):
    s.append(int(input()))

sum = sum(s)
s.sort()

cnt10 = 0
for si in s:
    if sum % 10 != 0:
        break
    if si %10 != 0:
        sum -= si
        break
    else:
        cnt10 += 1

if len(s) == cnt10:
    print(0)
else:
    print(sum)

Measured memory_bytes: 3064
inf=10**12
n,m=map(int,input().split())
node=[[]for _ in range(n)]
dis=[inf]*(n*3)
for _ in range(m):
	a,b=map(int,input().split())
	node[a-1].append(b-1)
s,t=map(int,input().split())
dis[(s-1)*3]=0
from collections import deque
queue=deque([(s-1)*3])
while queue:
	r=queue.popleft()
	p=(r%3+1)%3
	for x in node[r//3]:
		if dis[x*3+p]==inf:
			dis[x*3+p]=dis[r]+1
			queue.append(x*3+p)
print(dis[(t-1)*3]//3 if dis[(t-1)*3]!=inf else -1)

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

int main()
{
    // 入力
    int N,num,flag=0;
    string result,str;
    cin >> str;
    num = N;
    rep (i,str.length()){
        flag += (int)(str[i]-'0');
        //cout << "flag " << flag << endl;
    }

    //cout << "" << endl;
    // 計算
    if (flag%9 == 0){
        result = "Yes";
    } else {
        result = "No";
    }

    // 出力
    cout << result << endl;
    return 0;  
}


Measured memory_bytes: 3720
// #include <bits/stdc++.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <numeric>
#include <cmath>

#define rep(i,n) for (int i = 0; i < n; ++i)
#define repr(i,n) for (int i = n; i > 0; --i)
using namespace std;
using ll = long long;
using P = pair<int,int>;

const int MAX = 100;
const int INF = (1<<12);

int main() {
  int X, Y;
  cin >> X >> Y;
  for (int i = 0; i <= X; i++)
  {
    for (int j = 0; j <= X; j++)
    {
      if((Y == (i * 2 +  j * 4)) && X == (i + j)) {
        cout << "Yes" << endl;
        return 0;
      }
    }
  }
  cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 3636
/*
[ ( ^ _ ^ ) ]
*/
// problem: atc/abc163_e
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1000000000

void maxself(ll &a, ll b) {
    a = max(a, b);
}

int main() {
    int n;
    scanf("%d", &n);
    vector<pair<ll, int>> a(n);
    for(int i=0; i<n; i++) {
        scanf("%lld", &a[i].first);
        a[i].second = i;
    }
    sort(a.begin(), a.end(), greater<pair<ll, int>>());
    ll dp[n+1][n+1];
    memset(dp, 0, sizeof(dp));
    for(int i=0; i<n; i++) {
        for(int l=0; l<=i; l++) {
            int r = i - l;
            maxself(dp[l+1][r], dp[l][r] + a[i].first * abs(l - a[i].second));
            maxself(dp[l][r+1], dp[l][r] + a[i].first * abs(n-1-r - a[i].second));
        }
    }
    ll mx = 0;
    for(int l=0; l<=n; l++) {
        int r = n - l;
        maxself(mx, dp[l][r]);
    }
    printf("%lld\n", mx);
}


Measured memory_bytes: 35096
#include <bits/stdc++.h>
using namespace std;
int main() {
    string s;
    cin >> s;
    int a = 0;
    for (int i = 0; i < s.size(); ++i) {
        if(s[i]=='+') a++;
        else a--;
    }
    cout << a << endl;
    return 0;
}

Measured memory_bytes: 256
s[50],j,p,q;main(i){for(;j=i=atoi(gets(s));printf("%d\n",i)){for(;i;s[j-i--]=strlen(gets(s+j)));for(;q>0||j&&(p=i++,j=117933);j/=9)for(q=j%9;q>1;)q-=s[p++];}}

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

using namespace std;

#define forn(i, n) for (ll i = 0; i < (ll) (n); ++i)
#define sz(a) static_cast<int>((a).size())
#define pb emplace_back
#define mp make_pair
#define endl '\n'
#define f first
#define s second

#ifdef SEREZHKA
#define dbg(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#else
#define dbg(...)
#endif

template<typename T>
void _dbg(const char* _s, T _h) { cerr << _s << " = " << _h << "\n"; }

template<typename T, typename... Ts>
void _dbg(const char*_s, T _h, Ts... _t) {
    int _b = 0;
    
    while (((_b += *_s == '(') -= *_s == ')') != 0 || *_s != ',')
        cerr << *_s++;
    
    cerr << " = " << _h << ",";
    _dbg(_s + 1, _t...);
}

using ll = long long;

const ll INF = static_cast<ll>(1e9) + 7ll;
const ll LINF = INF * INF;
const int MAXN = static_cast<int>(1e6) + 17;

int n, m;
ll x[MAXN], y[MAXN];

bool read() {
    if (!(cin >> n >> m))
        return false;

    forn (i, n)
        cin >> x[i];

    forn (j, m)
        cin >> y[j];

    return true;
}

ll f(ll x[MAXN], int n) {
    ll res = 0, cur = 0;

    for (int i = n - 1; i >= 0; --i) {
        res += cur;
        res %= INF;
        cur += x[i];
        cur %= INF;
        res -= x[i] * (n - 1 - i) % INF;
        res %= INF;
    }

    return (INF + res % INF) % INF;
}

void solve() {
    cout << f(x, n) * f(y, m) % INF << endl;
}

int main() {
    cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    
    while (read())
        solve();
    
    return 0;
}



Measured memory_bytes: 5120
#include <stdio.h>
#include <stdbool.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
typedef long long int ll;
#define mod 1000000007
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define m0(x) memset(x,0,sizeof(x))

int main(void){
	int n,m,ans=0;
	scanf("%d %d",&n,&m);
	int div=m/n;
	for(int i=div; i>0; i--){
		if(m%i==0){
			ans=i;
			break;
		}
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int N = 3e2+7;
int n, a[N];
long double f[N][N][N];
long double dfs(int x, int y, int z)
{
	if(x<=0&&y<=0&&z<=0)
	{
		return 0;
	}
	if(f[x][y][z]>0)
	{
		return f[x][y][z];
	}
	if(x)
	{
	    f[x][y][z] += dfs(x-1, y, z)*x/n;
	}
	if(y)
	{
	    f[x][y][z] += dfs(x+1, y-1, z)*y/n;
	}
	if(z)
	{
	    f[x][y][z] += dfs(x, y+1, z-1)*z/n;
	}
	f[x][y][z]++;
	f[x][y][z] *= 1.0*n/(x+y+z);
	return f[x][y][z];
}
int main()
{
    int c[3] = {0};
	scanf("%d", &n);
	f[1][0][0] = n;
	for(int i = 1; i <= n; i++)
	{
		scanf("%d", &a[i]);
		c[a[i]-1]++;
	}
	printf("%.10Lf\n", dfs(c[0], c[1], c[2]));
    return 0;
}

Measured memory_bytes: 442624
#include <cstdio>

int main()
{
  int n;
  scanf("%d", &n);
  for (int i = 1; i <= 9; ++i)
  {
    for (int j = 1; j <= 9; ++j)
    {
      if (n == i * j)
      {
        puts("Yes");
        return 0;
      }
    }
  }
  puts("No");
  return 0;
}

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

typedef long long   ll;
typedef long double ld;
using namespace std;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll h;
    cin >> h;
    ll nofmon=1;
    ll count=0;
    while(h>1){
        count+=nofmon;
        nofmon*=2;
        h/=2;
    }
    count+=nofmon;
    cout << count << "\n";
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) for(int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define show(x)  cerr << #x << " = " << (x) << endl;
#define int long long
using namespace std;

template <typename X, typename T>
auto vectors(X x, T a) {
	return vector<T>(x, a);
}

template <typename X, typename Y, typename Z, typename... Zs>
auto vectors(X x, Y y, Z z, Zs... zs) {
	auto cont = vectors(y, z, zs...);
	return vector<decltype(cont)>(x, cont);
}

template<typename T>
ostream& operator << (ostream& os, vector<T>& v){
	rep(i,v.size()){ os << v[i] << (i == v.size() - 1 ? "" : " "); } return os;
}
template<typename T>
istream& operator >> (istream& is, vector<T>& v){
	for(T& x: v){ is >> x; } return is;
}

void output(vector<pair<int, int>>& ans){
	cout << ans.back().first - ans.back().second << endl;
	for(auto i : ans){
		cout << i.first << ' ' << i.second << endl;
	}
}

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

	vector<int> a(n);
	int plus = 0, minus = 0, zero = 0;
	rep(i,n){
		cin >> a[i];
		plus += a[i] > 0;
		minus += a[i] < 0;
		zero += a[i] == 0;
	}
	sort(all(a));

	if(n == 2){
			cout << a[1] - a[0] << endl;
			cout << a[1] << ' ' << a[0] << endl;
		return 0;
	}

	vector<pair<int, int>> ans;
	if(minus <= 1){
		ans.emplace_back(a[0], a[1]);
		int cur = a[0] - a[1];
		range(i,2,n -1){
			ans.emplace_back(cur, a[i]);
			cur = cur - a[i];
		}
		ans.emplace_back(a.back(), cur);
		output(ans);
		return 0;
	}

	if(plus <= 1){
		ans.emplace_back(a.back(), a[0]);
		int cur = a.back() - a[0];
		range(i,1,n - 1){
			ans.emplace_back(cur, a[i]);
			cur = cur - a[i];
		}
		output(ans);
		return 0;
	}

	int b = 0;
	rep(i,n){
		if(a[i] >= 0){
			b = i;
			break;
		}
	}

	ans.emplace_back(a[0], a.back());
	int cur = a[0] - a.back();

	int i = n - 2;
	while(i > b){
		ans.emplace_back(cur, a[i]);
		cur = cur - a[i];
		i--;
	}
	ans.emplace_back(a[b], cur);
	cur = a[b] - cur;

	i = 1;
	while(i < b){
		ans.emplace_back(cur, a[i]);
		cur = cur - a[i];
		i++;
	}
	output(ans);
	return 0;
}


Measured memory_bytes: 4336
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;

public class Main {
  public static void main(String[] args) throws IOException {
    BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    String[] str = in.readLine().split(" ");
    int a = Integer.parseInt(str[0]);
    int b = Integer.parseInt(str[1]);
    int c = Integer.parseInt(str[2]);
    int min = Math.min(Math.min(a,b),c);
    int max = Math.max(Math.max(a,b),c);
    System.out.println(10*max + (a+b+c-max-min) + min);
  }
}

Measured memory_bytes: 22356
#include <iostream>
#include <algorithm>
#include <string>
#include <math.h>
#include <bitset>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include<iomanip>

#define i64 int64_t
#define ff(ii,nn,mm) for(int ii=nn;ii<mm;ii++)
#define ffrvs(ii,nn,mm) for(int ii=nn;ii>=mm;ii--)
#define srt(vvv) sort(vvv.begin(),vvv.end())
#define srtrvs(vvv) reverse(vvv.begin(),vvv.end())
#define Graph vector<vector<int>>

i64 inf = 1000000007;
i64 giant = 4000000000000000037;

using namespace std;



//メモリ置き場


//inputします
void input() {
	
}

//ライブラリ置き場
i64 cup(i64 xxx38, i64 yyy38) {//切り上げ
	return (xxx38 + yyy38 - 1) / yyy38;
}
//main
int main() {
	cin.tie(0);
    ios::sync_with_stdio(false);
	input();
	char ss;
	cin >> ss;
	if (ss == 'A')cout << 'T' << endl;
	if (ss == 'T')cout << 'A' << endl;
	if (ss == 'C')cout << 'G' << endl;
	if (ss == 'G')cout << 'C' << endl;
	return 0;
}

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

using namespace std;

int main() {
  int in = 0, l = 0;
  string s;
  vector<int> v[101];

  while( getline(cin, s) ) {
    for(int i=0; i<=s.size(); i++) {
      if( s[i] == ',' || i == s.size() ) {
	v[l].push_back( in );
	in = 0;
      }
      else if( s[i] != ',' ) {
	in *= 10;
	in += s[i]-'0';
      }
    }
    l++;
  }
  
  int dp[101][101];
  fill(dp[0], dp[101], 0);
  dp[0][0] = v[0][0];
  
  for(int i=1; i<l; i++) {
    for(int j=0; j<v[i].size(); j++) {
      dp[i][j] = dp[i-1][j]+v[i][j];
      if( i <= l/2 ) {
	dp[i][j] = max(dp[i][j], dp[i-1][j-1]+v[i][j]);
      }
      if( i > l/2 ) {
	dp[i][j] = max(dp[i][j], dp[i-1][j+1]+v[i][j]);
      }
    }
  }
  
  cout << dp[l-1][0] << endl;
}

Measured memory_bytes: 1252
#include<iostream>
#include<algorithm>
#include<vector>
#include<map>
using namespace std;
#define REP(i,b,n) for(int i=b;i<n;i++)
#define rep(i,n)   REP(i,0,n)

const int N = 7;
vector<int> in[N];

int solve(int now){
  int cnt=0,last=0;
  rep(i,(int)in[now].size()){
    if (last+30 <= in[now][i]){
      cnt++;
      last=in[now][i];
    }
  }
  return cnt;
}

int getindex(string &in,map<string,int> &M){
  int index=(int)M.size();
  if (M.find(in) == M.end())M[in]=index;
  return M[in];
}

inline int gettime(int n){
  int h=n/100,m=n%100;
  return h*60+m;
}

inline bool cansee(int i,int j){
  int maxbeg=max(i,j),minend=min(i+30,j+30);
  return minend <= maxbeg;
}

int solve(int n,vector<int> *ng,int *day,int *time,bool *isfav){
  rep(k,N){
    rep(i,(int)ng[k].size()){
      REP(j,i+1,(int)ng[k].size()){
	if (!cansee(ng[k][i],ng[k][j]))return -1;
      }
    }
  }
  rep(i,n){
    int now=day[i];
    bool isok=!isfav[i];
    rep(j,(int)ng[now].size()){
      if(!cansee(ng[now][j],time[i])){
	isok=false;
	break;
      }
    }
    if (isok)in[now].push_back(time[i]);
  }
  int ret=0;
  rep(i,N){
    sort(in[i].begin(),in[i].end());
    //rep(j,(int)in[i].size())cout << in[i][j]<<" " ;
    //cout << endl;
    ret+=solve(i);
    //cout << i <<" " << ret << " " << in[i].size() << endl;
  }
  return ret;
}

main(){
  int n;
  static string tmp[500];
  static int day[500],time[500];
  static bool isfav[500];
  while(cin>>n  && n){
    map<string,int> M;
    rep(i,7)in[i].clear();
    rep(i,n){
      cin>>tmp[i];
      M[tmp[i]]=i;
      cin>>day[i]>>time[i];
      time[i]=gettime(time[i]);
      isfav[i]=false;
    }
    vector<int> NG[N];
    int m;
    cin>>m;
    rep(i,m){
      string a;
      cin>>a;
      int ind=getindex(a,M);
      NG[day[ind]].push_back(time[ind]);
      isfav[ind]=true;
    }
    int ans=solve(n,NG,day,time,isfav);
    if (ans==-1)cout << -1 << endl;
    else cout << ans+m<<endl;
  }
  return false;
}

Measured memory_bytes: 0
// D - Blue and Red Balls
#include <bits/stdc++.h>

using namespace std;

#define	MOD	1000000007

int main(int argc, char *argv[])
{
	static long long C[2001][2001];
	for (int i = 0; i < sizeof(C) / sizeof(C[0]); i++) {
		C[i][i] = C[i][0] = 1;
		for (int j = 1; j <= i / 2; j++)
			C[i][j] = C[i][i - j] = (C[i - 1][j] + C[i - 1][j - 1]) % MOD;
	}

	long long n, k;
	cin >> n >> k;
	long long r = n - k;
	for (long long i = 1; i <= k; i++) {
		long long c = r - (i - 1);
		if (c < 0) {
			cout << 0 << "\n";
			continue;
		}
		long long ans = C[i + c][c] * C[k - 1][i - 1] % MOD;
		cout << ans << "\n";
	}

	return 0;
}


Measured memory_bytes: 30080
n = int(input())
hight = list(map(int, input().split()))
lis = [0, abs(hight[1]-hight[0])]

for i in range(len(hight)):
    if i == 0 or i == 1:
        pass
    else:
        lis.append(min(lis[i-2] + abs(hight[i]-hight[i-2]), lis[i-1] + abs(hight[i]-hight[i-1])))

print(lis[n-1])

Measured memory_bytes: 13908
def Qb():
    n, k = map(int, input().split())
    ans = set()
    for v in range(k):
        d = int(input())
        ns = [int(v) for v in input().split()]
        for N in ns:
            ans.add(N)
    print(n - len(ans))


if __name__ == '__main__':
    Qb()


Measured memory_bytes: 9092
#include <iostream>
#include <vector>
#include <stack>
#include <queue>
#include <algorithm>
#include <cmath>
#include <string>
#include <map>
#include <set>
#include <list>
#include <stdio.h>

#define ll long long
#define fornum(A,B,C) for(A=B;A<C;A++)

using namespace std;

int i,j,k,l,m,n;
/////////////////////////////////////////////////////



int x[4];
int y[4];

int main(){
    scanf("%d%d%d%d",&x[0],&y[0],&x[1],&y[1]);
    for(i=2;i<4;i++){
        x[i]=x[i-1]-(y[i-1]-y[i-2]);
        y[i]=y[i-1]+(x[i-1]-x[i-2]);
        printf("%d %d ",x[i],y[i]);
    }
    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <vector>
#include <queue>
#include <algorithm>
#include <bitset>
#include <cstdlib>
#include <cmath>
#define INF 100000000000
#define MOD 1000000007
#define ll long long int
using namespace std;

/*
int main(){
   int a,b;cin>>a>>b;
   if(a>=13) cout<<b<<endl;
   else if(a>=6 and a<=12) cout<<b/2<<endl;
   else cout<<0<<endl;
 //  //return 0;
    return 0;
}*/

int main(){
    ll r,D,x0;
    cin>>r>>D>>x0;
    for(int i=1;i<=10;i++){
        x0 = x0 * r - D;
        cout<<x0<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args){
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int donuts = 4;
        int cake = 7;
        
        for(int i=donuts;i<=n;i+=donuts){
            if(i==n){
                System.out.print("Yes");
                System.exit(0);
            }
        }

        for(int i=cake;i<=n;i+=cake){
            if(i==n){
                System.out.print("Yes");
                System.exit(0);
            }
        }
        
        for(int i=donuts;i<=n;i+=donuts){
            for(int j=cake; j<=n;j+=cake){
                if(i + j == n){
                    System.out.print("Yes");
                    System.exit(0);
                }
            }
        }
        
        System.out.print("No");
    }
}

Measured memory_bytes: 23764
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <cmath>
#include <vector>
#include <queue>

typedef long long ll;
const ll LL_MAX (1LL<<60);

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

using namespace std;

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

    ll n, m;
    cin >>n;
    vector<ll> a(n);
    rep(i,0,n) cin >> a[i];
    cin >>m;
    vector<ll> b(m);
    rep(i,0,m) cin >> b[i];

    set<ll> ans;

    rep(i,0,n) ans.insert(a[i]);
    rep(i,0,m) ans.insert(b[i]);

    for(auto i: ans)
        cout << i << endl;

    return 0;
}



Measured memory_bytes: 24648
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()

int c(int x)
{
  if(x / 10 == 0)
    return 1;
  return 1 + c(x / 10);
}

int main()
{
  int n;
  cin >> n;
  int ans = 0;
  for(int i = 1 ; i <= n ; i++){
    ans += c(i) & 1;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
import math
import numpy
N, D = map(int, input().split())
P = [list(map(int,input().split())) for i in range(N)]
# print(P)
ans = 0
for j in P:
  # print(j)
  # print(math.sqrt(j[0]*j[0] + j[1]*j[1]))
  if math.sqrt(j[0]*j[0] + j[1]*j[1]) <= D:
    ans += 1
print(ans)


Measured memory_bytes: 63388
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> i_i;
typedef pair<ll, ll> l_l;
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define int ll
//const ll mod = 1000000007;

int n,m;
int k;
int a;
int kind[31];
int ans;
signed main() {
    cin >> n >> m;
    for (int i=0;i<n;i++) {
        cin >> k;
        for (int j=0;j<k;j++) {
            cin >> a; a--;
            kind[a]++;
        }
    }
    for (int i=0;i<m;i++) {
        if (kind[i]==n) ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#define MAX 100000
#define SENTINEL 2000000000

struct Card {
	char suit;
	int value;
};

struct Card L[MAX / 2 + 2], R[MAX / 2 + 2];

void merge(struct Card A[], int n, int left, int mid, int right) {
	int i, j, k;
	int n1 = mid - left;
	int n2 = right - mid;
	for(i = 0; i < n1; i++) L[i] = A[left + i];
	for(i = 0; i < n2; i++) R[i] = A[mid + i];
	L[n1].value = R[n2].value = SENTINEL;
	i = j = 0;
	for(k = left; k < right; k++){
		if(L[i].value <= R[j].value){
			A[k] = L[i++];
		}else{
			A[k] = R[j++];
		}
	}
}

void mergeSort(struct Card A[], int n, int left, int right) {
	int mid;
	if(left + 1 < right) {
		mid = (left + right) / 2;
		mergeSort(A, n, left, mid);
		mergeSort(A, n, mid, right);
		merge(A, n, left, mid, right);
	}
}

int partition(struct Card A[], int n, int p, int r) {
	int i, j;
	struct Card t, x;
	x = A[r];
	i = p - 1;
	for(j = p; j < r; j++) {
		if(A[j].value <= x.value) {
			i++;
			t = A[i]; A[i] = A[j]; A[j] = t;
		}
	}
	t = A[i + 1]; A[i + 1] = A[r]; A[r] = t;
	return i + 1;
}

void quickSort(struct Card A[], int n, int p, int r) {
	int q;
	if(p < r) {
		q = partition(A, n, p, r);
		quickSort(A, n, p, q - 1);
		quickSort(A, n, q + 1, r);
	}
}

int main(void){
	int n, i, v;
	struct Card A[MAX], B[MAX];
	char S[10];
	int stable = 1;
	
	scanf("%d", &n);
	
	for(i = 0; i < n; i++) {
		scanf("%s %d", S, &v);
		A[i].suit = B[i].suit = S[0];
		A[i].value = B[i].value = v;
	}
	
	mergeSort(A, n, 0, n);
	quickSort(B, n, 0, n - 1);
	
	for(i = 0; i < n; i++) {
		if(A[i].suit != B[i].suit) stable = 0;
	}
	
	if(stable == 1) printf("Stable\n");
	else printf("Not stable\n");
	for(i = 0; i < n; i++) {
		printf("%c %d\n", B[i].suit, B[i].value);
	}
	
	return 0;
}




Measured memory_bytes: 4100
#include <vector>
#include <iostream>
#include <cmath>
#include <string>
#include <cstring>
#include <algorithm>
#include <numeric>
using namespace std;

int main(){
    ios::sync_with_stdio(false);
    string s;
    cin>>s;
    string a={"maerd"},b={"remaerd"},c={"esare"},e={"resare"};
    reverse(s.begin(),s.end());
    
    int z=1;
    for (int i=0;i<s.size();){
        bool x=false; // 4 個の文字列たちどれかで divide できるか
        for (int j=0;j<4;++j) {
            if(j%4==0){
                string d=a;
                if(s.substr(i,d.size())==d){
                x=true;
                i+=d.size();
                }
            }else if(j%4==1){
                string d=b;
                if(s.substr(i,d.size())==d){
                x=true;
                i+=d.size();
                }
            }else if(j%4==2){
                string d=c;
                if(s.substr(i,d.size())==d){
                x=true;
                i+=d.size();
                }
            }else{
                string d=e;
                if(s.substr(i,d.size())==d){
                x=true;
                i+=d.size();
                }
            }
        }
      if(!x){
        z=0;
        break;
      }
    }
    if(z==1) cout << "YES\n";
    else  cout << "NO\n";
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define FOR(i,k,n)  for(int i = (k);i < (n);++i)
#define REP(i,n)    FOR(i,0,n)
#define ALL(x)      begin(x),end(x)

using namespace std;
using vecint = vector<int>;
using ll = int64_t;
constexpr ll MOD = 1000000007;

int main()
{
  ll n,k;
  cin>>n>>k;
  ll s=sqrt(n);
  vector<ll> dp1(s+1, 1);
  vector<ll> cnt(s+1);
  vector<ll> dp2(s+1);
  dp1[0]=0;
  REP(i,s) {
    ll j = i+1;
    ll l=max(double(s+1),1.0+floor(double(n)/(j+1)));
    ll u=max(double(s),floor(double(n)/j));
    dp2[j] = cnt[j] = u-l+1;
  }
  REP(i,k-1) {
    vector<ll> tmp1(s+1);
    vector<ll> tmp2(s+1);
    FOR(j,1,s+1) {
      tmp2[j] = tmp2[j-1] + dp1[j];
      tmp2[j] %= MOD;
    }
    FOR(j,1,s+1) {
      tmp2[j] *= cnt[j];
      tmp2[j] %= MOD;
    }
    tmp1[s] = dp2[s];
    for (int j=s-1; j>0; --j) {
      tmp1[j] = tmp1[j+1] + dp2[j];
      tmp1[j] %= MOD;
    }
    ll sum1 = 0;
    FOR(j,1,s+1) {
      sum1 += dp1[j];
      sum1 %= MOD;
    }
    FOR(j,1,s+1) {
      tmp1[j] += sum1;
      tmp1[j] %= MOD;
    }
    swap(dp1,tmp1);
    swap(dp2,tmp2);
  }
  ll sum = 0;
  FOR(i,1,s+1) {
    sum += dp1[i];
    sum += dp2[i];
    sum %= MOD;
  }
  cout << sum << endl;
  return 0;
}


Measured memory_bytes: 1536
#include<stdio.h>

#define INF 1000000
#define K 2000000

int n = 0;
int S[K];

void increase(int *S, int i, int key){
  int tmp;

  S[i] = key;

  while(i > 1 && S[i/2] < S[i]){
    tmp = S[i];
    S[i] = S[i/2];
    S[i/2] = tmp;
    i = i/2;
  }
}

void insert(int *S, int k){
  n += 1;
  S[n] = -INF;
  increase(S, n, k);
}

void maxHeapify(int *S, int i){
  int l, r, tmp, largest;

  l = 2*i;
  r = 2*i + 1;

  if(l <= n && S[l] > S[i]) largest = l;
  else largest = i;

  if(r <= n && S[r] > S[largest]) largest = r;

  if(largest != i){
    tmp = S[i];
    S[i] = S[largest];
    S[largest] = tmp;
    maxHeapify(S, largest);
  }
}

int extractMax(int *S){
  int max;

  max = S[1];
  S[1] = S[n];
  n--;
  maxHeapify(S, 1);

  return max;
}

int main(){
  int i=0, k, j, max[K];
  char chil[10];

  while(1){
    scanf("%s", chil);

    if(chil[0] == 'i'){
      scanf("%d", &k);
      insert(S, k);
    }

    else if(chil[1] == 'x'){
      max[i] = extractMax(S);
      i++;
    }
    else if(chil[1] == 'n') break;
  }

  for(j = 0; j < i; j++) printf("%d\n", max[j]);

  return 0;
}

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

using namespace std;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using ll = long long;
int mod = 1000000000+7;

int main(){

	int sx,sy,tx,ty;
	cin>>sx>>sy>>tx>>ty;

	string ans;
	rep(i,tx-sx)ans+='R';
	rep(i,ty-sy)ans+='U';
	rep(i,tx-sx)ans+='L';
	rep(i,ty-sy)ans+='D';
	ans+='D';
	rep(i,tx-sx+1)ans+='R';
	rep(i,ty-sy+1)ans+='U';
	ans+='L';
	ans+='U';
	rep(i,tx-sx+1)ans+='L';
	rep(i,ty-sy+1)ans+='D';
	ans+='R';

	cout<<ans<<endl;

	return 0;
}


Measured memory_bytes: 256
/*
*@Author  Chand Vachhani
*/

#include<bits/stdc++.h>
#define int         long long
#define double         long double
#define vi             vector<int>
#define vii         vector<vector<int>>
#define pii         pair<int,int>
#define pb             push_back
#define pf          push_front
#define vpii         vector<pair<int,int>>
#define fo(i,l,n)     for(int i{l}; i<n; i++)
#define rf(s)        for(auto &c : s)
#define all(a)         (a).begin(),(a).end()
#define rall(a)     (a).rbegin(),(a).rend()
#define PI             3.141592653589
#define sz(x)       (int)x.size()
#define bs(v,n)     binary_search(all((v)),(n))
#define lb(v,n)     lower_bound(all((v)),(n))
#define ub(v,n)     upper_bound(all((v)),(n))
#define tezz         ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

using namespace std;

int gcd(int a, int b) {  if (a == 0)  return b; return gcd(b % a, a); }  
bool mod(double a,double b) {return a/b - floor(a/b);}
 
int occurs(vi v,int n){
auto it=lb(v,n);auto it1=ub(v,n);int x=it1-it;return x;}
 
int logb(int base, int x) {
    return (log(x) / log(base));
}


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

signed main(){
    tezz

    string s,t;
    cin >> s >> t;
    int count=0;
    fo(i,0,3){
        if(s[i]==t[i])
            count++;
    }
    cout << count;

    return 0;
}


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

int main() {
#define rep(i, n) for(int i = 1; i <= (int)(n); i++)
  int64_t N,a;
  cin>>N;
  a=0;
  rep(i,N){
    if(i%3!=0&&i%5!=0)
      a+=i;
  }
  cout<<a;
}


Measured memory_bytes: 3620
#define _GLIBCXX_DEBUG
typedef long long ll;
#include <bits/stdc++.h>

using namespace std;

ll mod = 1000000007;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

ll modpow(ll a, ll n, ll mod)
{
	ll res = 1;
	while (0 < n)
	{
		if (n & 1)
		{
			res = res * a % mod;
		}
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}

//int gcd(int x, int y)
//{
//
//}

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

	int before = a[0];
	if (a[0] == 2)
	{
		cout << 1 << endl;
		return 0;
	}
	else
	{
		for (int i = 1; i < n; i++)
		{
			int after = a[before - 1];
			if (after == 2)
			{
				cout << i + 1 << endl;
				return 0;
			}
			before = after;
		}
	}
	cout << -1 << endl;
}

Measured memory_bytes: 640
#include <cstdio>

using namespace std;

int main() {
    char c;
    while (true) {
        scanf("%c", &c);
        if ('A' <= c && c <= 'Z') printf("%c", c - 'A' + 'a');
        else if ('a' <= c && c <= 'z') printf("%c", c - 'a' + 'A');
        else printf("%c", c);
        if (c == '\n') break;
    }
    return 0;
}



Measured memory_bytes: 2592
i,n,v[100],b,e,m,t;
main(){
	for(;scanf("%d",&n),n;){
		for(i=0;i<n;i++)
			scanf("%d",v+i);
		scanf("%d",&t);
		b=0;
		e=n-1;
		n=0;
		for(;b<=e;){
			m=(b+e)/2;
			n++;
			if(t==v[m])
				break;
			if(t<v[m])
				e=m-1;
			else
				b=m+1;
		}
		printf("%d\n",n);
	}
	exit(0);
}

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

int main() {
    cin.tie(0)->sync_with_stdio(false);

	int n;
	cin >> n;
	ll res = 0;
	for (int i = 1; i <= n; i++)
		for (int j = i; j <= n; j += i)
			res += j;
	cout << res << '\n';
    return 0;
}


Measured memory_bytes: 3596
using System;

namespace Odd
{
    class Program
    {
        static void Main(string[] args)
        {
            int N;

            int[] a = new int[101];

            string inD0 = Console.ReadLine();
            N = int.Parse(inD0);

            string inD1 = Console.ReadLine();
            string[] cngD1 = inD1.Split(' ');

            for (int i = 0; i <= N - 1; i++)
            {
                a[i] = int.Parse(cngD1[i]);
            }

            int cnt_j = 0;

            for (int j = 0; j <= N - 1; j += 2)
            {
                int p = int.Parse(cngD1[j]);
                if((p % 2) == 1)
                {
                    cnt_j++;
                }
            }

            Console.WriteLine(cnt_j);
        }
    }
}


Measured memory_bytes: 27376
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
static inline void PUT(char c)
{
  static char buf[1<<15],*ptr=buf;
  if(ptr==buf+strlen(buf)||c==0){fwrite(buf,1,ptr-buf,stdout),ptr=buf;}*ptr++=c;
}
static inline long IN(void)
{
  long x=0;int f=0,c=getchar();while(c<48||c>57){f^=c==45,c=getchar();}
  while(c>47&&c<58){x=x*10+c-48,c=getchar();}return f?-x:x;
}
static inline void OUT(long a)
{
  if(a<0)PUT('-'),a=-a;
  int d[40],i=0;do{d[i++]=a%10;}while(a/=10);
  while(i--){PUT(d[i]+48);}PUT('\n');
}
static inline long Abs(const long x){return x<0?-x:x;}
int main(void)
{
  long X=IN(),K=IN(),D=IN(),minus=X!=Abs(X),quotient=Abs(X)/D;
  X=Abs(X);if(quotient>=K){X-=K*D;return OUT(X),0;}else X-=quotient*D;
  K-=quotient;return (K&1)?OUT(Abs(X-D)):OUT(X),0;
}

Measured memory_bytes: 1524
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

template <std::uint_fast64_t Mod>
class ModInt {
  using u64 = std::uint_fast64_t;

 public:
  u64 val;

  constexpr ModInt(const u64 x = 0) noexcept : val(x % Mod) {}
  constexpr ModInt operator+(const ModInt rhs) const noexcept {
    return ModInt(*this) += rhs;
  }
  constexpr ModInt operator-(const ModInt rhs) const noexcept {
    return ModInt(*this) -= rhs;
  }
  constexpr ModInt operator*(const ModInt rhs) const noexcept {
    return ModInt(*this) *= rhs;
  }
  constexpr ModInt operator/(const ModInt rhs) const noexcept {
    return ModInt(*this) /= rhs;
  }
  constexpr ModInt &operator+=(const ModInt rhs) noexcept {
    val += rhs.val;
    if (val >= Mod) {
      val -= Mod;
    }
    return *this;
  }
  constexpr ModInt &operator-=(const ModInt rhs) noexcept {
    if (val < rhs.val) {
      val += Mod;
    }
    val -= rhs.val;
    return *this;
  }
  constexpr ModInt &operator*=(const ModInt rhs) noexcept {
    val = val * rhs.val % Mod;
    return *this;
  }
  constexpr ModInt &operator/=(ModInt rhs) noexcept {
    u64 exp = Mod - 2;
    while (exp) {
      if (exp % 2) {
        *this *= rhs;
      }
      rhs *= rhs;
      exp /= 2;
    }
    return *this;
  }
};

const long long MOD = 998244353;
using mint = ModInt<MOD>;

int main() {
  int N, K;
  cin >> N >> K;
  vector<pair<int, int>> S(K);
  for (auto &[l, r] : S) cin >> l >> r;
  vector<mint> dp(N);
  dp[0] = 1;
  dp[1] -= 1;
  for (int i = 0; i != N; ++i) {
    if (i) dp[i] += dp[i - 1];
    for (auto [l, r] : S) {
      if (i + l < N) dp[i + l] += dp[i];
      if (i + r + 1 < N) dp[i + r + 1] -= dp[i];
    }
  }
  cout << dp[N - 1].val << endl;
}


Measured memory_bytes: 4832
import collections

N = int(input())
S = []

for i in range(N):
    S.append(input())

s = collections.Counter(S)

count_max = max(s.values())

ans =[]
for key,value in s.items():
    if value == count_max:
        ans.append(key)
        
ans.sort()

for i in ans:
    print(i)

Measured memory_bytes: 38852
#include <bits/stdc++.h>
using namespace std;
//関数
const long INF=1000000000000000;

int main(void){
    vector<long> A(3);
    for(int i=0;i<3;i++) cin>>A.at(i);
    
    sort(A.begin(),A.end());
    cout<<A.at(0)*A.at(1)/2<<endl;
}

Measured memory_bytes: 256
#include "iostream"

using namespace std;

int main() {

	int a[100];
	int cnum;
	int num;

	cin >> num;

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

	for (int i = 1; i < num; i++) {

		for (int j = 0; j < num; j++) {
			cout << a[j];
			if (j < num - 1) {
				cout << " ";
			}
		}
		cout << endl;

		int v = a[i];
		int j = i - 1;

		while (j >= 0 && a[j] > v) {
			a[j + 1] = a[j];
			j--;
		}
		a[j + 1] = v;

	}

	for (int j = 0; j < num; j++) {
		cout << a[j];
		if (j < num - 1) {
			cout << " ";
		}
	}
	cout << endl;


	return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <string>
#include <cstdlib>
#include <vector>
#include <array>
#include <map>
#include <algorithm>
#include <queue>
#include <stack>
#include <cmath>
#include <climits>

using namespace std;
typedef long long int ll;


int main(int argc, char const *argv[])
{
	ll n;
	cin >> n;
	vector<double> a(n);
	for (ll i = 0; i < n; i++)
	{
		cin >> a[i];
	}

	double sum = 0;
	for (ll i = 0; i < n; i++)
	{
		sum += 1 / a[i];
	}

	cout << 1 / sum << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <functional>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <cassert>
#define InfL 2000000000
#define InfLL 4000000000000000000LL
#define mod 1000000007
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=(n-1);i>=0;i--)
using namespace std;
typedef long long ll;
typedef double db;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<bool> vb;
typedef vector<ld> vd;

ld sqrt_(ld d) {
	assert(d >= 0.0);
	ld l = 0.0, r = 100000000.0;
	rep(q, 50) {
		ld m = (l + r) / 2.0;
		if (m * m >= d)
			r = m;
		else
			l = m;
	}
	return l;
}

int main() {
	int N, K;
	vd x, y, c;
	cin >> N >> K;
	x.resize(N);
	y.resize(N);
	c.resize(N);
	rep(i, N)
		cin >> x[i] >> y[i] >> c[i];
	ld L = 0.0, R = 1000000.0;
	rep(q, 50) {
		ld t = (L + R) / 2.0;
		//db tt = t;
		//printf("%.12f\n", tt);

		bool can = false;
		rep(i, N) {
			rep(j, N) {
				vector<ld> X(2), Y(2);
				if (i == j) {
					// 円の中心
					X[0] = x[i];
					Y[0] = y[i];
					X[1] = x[i];
					Y[1] = y[i];
				}
				else if (i > j) {
					// 円の交点
					ld A = (t / c[i]) * (t / c[i]);
					ld B = (t / c[j]) * (t / c[j]);
					ld C = (x[i] * x[i] - x[j] * x[j]) + (y[i] * y[i] - y[j] * y[j]) - (A - B);
					ld D = 2.0 * (x[i] - x[j]);
					ld E = 2.0 * (y[i] - y[j]);
					if (D == 0.0) {
						Y[0] = C / E;
						Y[1] = C / E;
						ld AY = A - (Y[0] - y[i]) * (Y[0] - y[i]);
						if (AY < 0.0)
							continue;
						X[0] = sqrt_(AY) + x[i];
						X[1] = -sqrt_(AY) + x[i];
					}
					else {
						ld F = C / D;
						ld G = E / D;
						ld H = F - x[i];
						ld a_ = G * G + 1;
						ld b_ = -1.0 * (G * H + y[i]);
						ld c_ = H * H + y[i] * y[i] - A;
						if (b_ * b_ - a_ * c_ < 0.0)
							continue;
						Y[0] = (-b_ + sqrt_(b_ * b_ - a_ * c_)) / a_;
						Y[1] = (-b_ + -sqrt_(b_ * b_ - a_ * c_)) / a_;
						X[0] = F - G * Y[0];
						X[1] = F - G * Y[1];
						//cout << (F - G * Y[0] - x[i]) * (F - G * Y[0] - x[i]) + (Y[0] - y[i]) * (Y[0] - y[i]) << " - " << A << endl;
						//cout << (X[0] - x[j]) * (X[0] - x[j]) + (Y[0] - y[j]) * (Y[0] - y[j]) << " - " << B << endl;
						//cout << (X[1] - x[j]) * (X[1] - x[j]) + (Y[1] - y[j]) * (Y[1] - y[j]) << " - " << B << endl;
					}
				}
				else continue;

				rep(p, 2) {
					int k = 0;
					rep(n, N) {
						ld dist = sqrt_((X[p] - x[n]) * (X[p] - x[n]) + (Y[p] - y[n]) * (Y[p] - y[n]));
						ld ttmp = c[n] * dist;
						if (ttmp <= t + 0.0000000001)
							k++;
					}
					if (k >= K)
						can = true;
				}
			}
		}
		if (can)
			R = t;
		else
			L = t;
	}
	db ans = L;
	printf("%.12f\n", ans);
	return 0;
}

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

int INF=1001001001;

int main(void){
    int n, m;
    cin>>n>>m;
    vector<pair<int, int> >key;
    rep(i, m){
        int a, b;
        cin>>a>>b;
        int s=0;
        rep(j, b){
            int c;
            cin>>c;
            --c;
            s |=1<<c;//1をcシフトしてorを取っている
        }
        pair<int, int> p=make_pair(s, a);
        key.push_back(p);//sの集合の物を開けられるコストaの鍵のこと
    }

    vector<int>dp(1<<n, INF);
    dp[0]=0;
    rep(s, 1<<n){
        rep(i, m){
            int t=s | key[i].first;
            int cost=dp[s]+key[i].second;
            dp[t]=min(dp[t], cost);
        }
    }
    int ans=dp.back();
    if(ans==INF) ans=-1;
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
//
//  header_useful.h
//  c++_acm
//
//  Created by 李弘辰 on 2019/7/23.
//  Copyright  2019 李弘辰. All rights reserved.
//

#include <stdio.h>
#include <stdarg.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <vector>
#include <list>
#include <set>
#include <unordered_set>
#include <utility> // pair
#include <map>
#include <unordered_map>
#include <iostream>
#include <sstream>
#include <algorithm> // sort
#include <string>
#include <stack>
#include <queue>
#include <fstream>
#include <bitset>


using namespace std;

#define ll long long
#define lll __int128
#define uchar unsigned char
#define ushort unsigned short
#define uint unsigned int
#define ulong unsigned long
#define ull unsigned long long

#define INT_INF 0x7fffffff

#define pi acos(-1)

#define mx(a,b) (a) > (b) ? (a) : (b)
#define mn(a,b) (a) < (b) ? (a) : (b)
#define mem(a,b) memset(a,b,sizeof(a))
#define fre(a) freopen(a,"r",stdin)

#define cio ios::sync_with_stdio(false); // Do not use it with "scanf" and other c input!
#define pb push_back
#define rep(i,a,b) for (int i = a;i <= b;i ++)
#define pre(i,a,b) for (int i = a;i >= b;i --)
#define REP(i,a,b) for (int i = a;i < b;i ++)

#define read(a,s,n) rep(i,s,n) scanf("%d",a + i);
#define READ(a,s,n) REP(i,s,n) scanf("%d",a + i);

#define read_ll(a,s,n) rep(i,s,n) scanf("%lld",a + i);
#define READ_ll(a,s,n) REP(i,s,n) scanf("%lld",a + i);

#define _T_(T) int T;scanf("%d",&T);while (T --)
#define __T _T_(TTESTCASES)
#define _E_(T) while (~T)

#define Tprint(a,s,e) {int f=1;REP(i,s,e){if(f)f=0;else printf(" ");printf("%d",a[i]);}}


#define endl '\n'

#define itn int
#define iny int
#define nit int
#define inr int
#define mian main
#define iman main
#define mina main
#define mian main
#define ednl endl
#define fro for
#define fir for
#define reutrn return
#define retunr return
#define reutnr return


/* header_useful_h */
int main()
{
    int n;
    ll d;
    scanf("%d%lld",&n,&d);
    ll a,b;
    d *= d;
    int x = 0;
    
    while (n --) {
        scanf("%lld%lld",&a,&b);
        if (a * a + b * b <= d) x ++;
    }
    printf("%d\n",x);
    return 0;
}


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

int main(){
  int n;cin >> n;
  vector<int> a(n);
  vector<int> cnt(9,0);
  int count=0;
  int maxcount=0;
  for(int i=0;i<n;i++){
    cin >> a[i];
    if(a[i]<400){
      cnt[0]++;
    }else if(a[i]<800){
      cnt[1]++;
    }else if(a[i]<1200){
      cnt[2]++;
    }else if(a[i]<1600){
      cnt[3]++;
    }else if(a[i]<2000){
      cnt[4]++;
    }else if(a[i]<2400){
      cnt[5]++;
    }else if(a[i]<2800){
      cnt[6]++;
    }else if(a[i]<3200){
      cnt[7]++;
    }else{
      cnt[8]++;
    }
  }
  for(int i=0;i<=7;i++){
    if(cnt[i]!=0){
      count++;
    }
  }
  maxcount = count;
  for(int i=0;i<cnt[8];i++){
    maxcount++;
  }
  count = max(count,1);
  cout << count << " " << maxcount << endl;
} 

Measured memory_bytes: 256
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

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

        int N = Integer.parseInt(sc.next());

        Map<Integer, Integer> r = new HashMap<>();
        for (int i = 1; i <= N; i++) r.put(i, 0);

        int M = Integer.parseInt(sc.next());
        for (int i = 0; i < M; i++) {
            int A = Integer.parseInt(sc.next());
            int B = Integer.parseInt(sc.next());

            r.put(A, r.get(A)+1);
            r.put(B, r.get(B)+1);
        }

        r.forEach((i, i2) -> System.out.println(i2));
    }
}


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

using namespace std;

#include <vector>
#include <map>
#include <set>
#include <queue>
#include <math.h>
#include <iostream>
#include <stdio.h>

typedef long long ll;
typedef vector<ll> vll;
typedef pair<ll,ll> pairll;

#define sll(x) scanf("%lld",&x);
#define READ freopen("in.txt","r",stdin)
#define WRITE freopen("out.txt","w",stdout)

#define ff first
#define ss second

inline ll ADD(ll a, ll b, ll mod)
{
    return (a + b + mod + mod)%mod;
}

inline ll SUBS(ll a, ll b, ll mod)
{
    return (a-b+mod + mod) %mod;
}

inline ll MUL(ll a, ll b, ll mod)
{
    return (a*b + mod)%mod;
}

ll bigMod(ll base, ll power, ll mod)
{
    if(!power) return 1;
    if(!base) return 0;

    ll temp = bigMod(base, power/2, mod);

    if(power%2 == 0)
    {
        return (temp*temp)%mod;
    }
    else return (((temp*temp)%mod)*base)%mod;
}

inline ll modInverse(ll a, ll modp)
{
    return bigMod(a, modp -2, modp);
}

inline ll modInverseExtended(ll a, ll m) 
{ 
    ll m0 = m; 
    ll y = 0, x = 1; 
  
    if (m == 1) 
      return 0; 
  
    while (a > 1) 
    { 
        // q is quotient 
        ll q = a / m; 
        ll t = m; 
  
        // m is remainder now, process same as 
        // Euclid's algo 
        m = a % m, a = t; 
        t = y; 
  
        // Update y and x 
        y = x - q * y; 
        x = t; 
    } 
  
    // Make x positive 
    if (x < 0) 
       x += m0; 
  
    return x; 
} 
  

void autoinput()
{
    READ; 
    //WRITE;
}

int main()
{
    //autoinput();
    ll W, H;
    sll(H); sll(W);
    ll arr[H+1][W+1];
    ll dp[H+1][W+1];
    memset(arr,0,sizeof arr);
    memset(dp,0,sizeof dp);
    char dummy;
    scanf("%c",&dummy);
    for(ll i = 1; i <= H; i++)
    {
        for(ll j = 1; j <= W; j++)
        {
            char ch;
            scanf("%c",&ch);

            if(ch == '.') arr[i][j] = 0;
            else arr[i][j] = 1;
        }
        scanf("%c",&dummy);
    }

    dp[1][1] = arr[1][1];
    for(ll i = 2; i <= W; i++)
    {
        if(arr[1][i] && !arr[1][i-1]) dp[1][i] = dp[1][i-1] + 1;
        else dp[1][i] = dp[1][i-1];
    }

    for(ll i = 2; i <= H; i++)
    {
        if(arr[i][1] && !arr[i-1][1]) dp[i][1] = dp[i-1][1] + 1;
        else dp[i][1] = dp[i-1][1];
    }

    for(ll r = 2; r <= H; r++)
    {
        for(ll c = 2; c <= W; c++)
        {
            ll up, left;
            if(arr[r][c] && !arr[r-1][c]) up = dp[r-1][c] + 1;
            else up = dp[r-1][c];

            if(arr[r][c] && !arr[r][c-1]) left = dp[r][c-1] + 1;
            else left = dp[r][c-1];

            dp[r][c] = min(up,left);
        }
    }

    cout << dp[H][W] << "\n";
}



Measured memory_bytes: 384
# -*- coding: utf-8 -*-
"""
Created on Thu Jan  2 17:08:37 2020

@author: student2
"""
potrn = 0
potrnn = 0
n,m,x = map(int,input().split())
v = [0 for i in range(n)]
for y in map(int,input().split()):
    v[y-1]=1
for z in range(x):
    if v[z] == 1:
        potrn +=1
for g in range(x,n):
    if v[g] == 1:
        potrnn +=1
print (min(potrn,potrnn))


Measured memory_bytes: 3064
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<string.h>
using namespace std;
int gh[1000][1000],w[2000];
int main()
{
    int i,j,k,l,n,m,a,b,c;
    cin>>n;
    m=0;
    for (i=1;i<=n;i++)
    {
      cin>>j>>k;
      m=m+k-j+1;
     }
     cout<<m<<endl;
    return 0;
}
        
    
    


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <climits>
#include <stdio.h>
#include <stdlib.h>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
using namespace std;
// scanf
#pragma warning(disable: 4996)
// v:vector  type:型  order:greater or less
#define _sort(v,type,order) do { sort(v.begin(),v.end(),order<type>()); } while(0)
// v:vector  default_value:初期値
#define _sum(v,default_value) accumulate(v.begin(),v.end(),default_value )
// 丸め
#define _round(v) round(v)
// 2乗 / 3乗
#define _square(v) pow(v,2)
#define _cube(v)   pow(v,3)
// 大小判定
#define _max(x,y) max(x,y)
#define _min(x,y) min(x,y)


int main()
{
	uint32_t m;
	cin >> m;

	printf("%d\n", 24 + (24 - m));
	return 0;
}


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

#define N
int n;
int main() {
    scanf("%d", &n);
    int k = __builtin_ctz(n);
    if (n == 1 << k) return puts("No"), 0;
    puts("Yes");
    if (!k) {
        for (int i = 3; i <= n; i += 2) {
            printf("%d %d\n", i, i - 1);
            printf("%d %d\n", i - 1, 1);
            printf("%d %d\n", 1, i + n);
            printf("%d %d\n", i + n, i + n - 1);
        }
        printf("%d %d\n", n + 1, 3);
    }
    else {
        int m = 1 << k, x = n ^ m, t = -1;
        for (int i = 3; i <= n; i += 2) {
            if (i == m + 1) continue;
            t = i;
            printf("%d %d\n", i, i - 1);
            printf("%d %d\n", i - 1, 1);
            printf("%d %d\n", 1, i + n);
            printf("%d %d\n", i + n, i + n - 1);
        }
        assert(t >= 0);
        printf("%d %d\n", n + 1, t);
        printf("%d %d\n", n, m);
        printf("%d %d\n", m, x);
        printf("%d %d\n", x, 2 * n);
        printf("%d %d\n", m, m + 1);
        printf("%d %d\n", x + 1, m + n + 1);
        printf("%d %d\n", m + n + 1, m + n);
    }

    return 0;
}


Measured memory_bytes: 2304
s = gets.chomp
k = gets.to_i
a = "a".ord
z = "z".ord

s = s.each_byte.map do |c|
    if c == a
        c.chr
    elsif z - c < k
        k -= z - c + 1
        a.chr
    else
        c.chr
    end
end

k %= 26
s[-1] = (s[-1].ord + k).chr
puts s.join

Measured memory_bytes: 7036
#include<iostream>
using namespace std;
int main(){
	int a, b, c, d;
	while(cin >> a >> b >> c >> d) {
		int max = a, min = b;
		if (a < c)
			max = c;
		if (b > d)
			min = d;
		int s = min - max;
		if (s > 0) {
			cout << s<<endl;
		}
		else
			cout << 0<<endl;
	}
	return 0;
}


Measured memory_bytes: 256