akhauriyash/Code-Regression huggingface dataset:
// #pragma GCC target("avx2")  // CPU 処理並列化
// #pragma GCC optimize("O3")  // CPU 処理並列化
// #pragma GCC optimize("unroll-loops")  // 条件処理の呼び出しを減らす
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<stack>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
#include<numeric>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const double EPS=1e-10;
const double INF=1e+10;
const double PI=acos(-1.0);
const int C_SIZE = 3121000;
long long fact[C_SIZE];
long long finv[C_SIZE];
long long inv[C_SIZE];
long long Comb(int a,int b){
 	if(a<b||b<0)return 0;
 	return fact[a]*finv[b]%mod*finv[a-b]%mod;
}
void init_C(int n){
	fact[0]=finv[0]=inv[1]=1;
	for(int i=2;i<n;i++){
		inv[i]=(mod-(mod/i)*inv[mod%i]%mod)%mod;
	}
	for(int i=1;i<n;i++){
		fact[i]=fact[i-1]*i%mod;
		finv[i]=finv[i-1]*inv[i]%mod;
	}
}
long long pw(long long a,long long b){
	if(a<0LL)return 0;
	long long ret=1;
	while(b){
		if(b%2)ret=ret*a%mod;
		a=a*a%mod;
		b/=2;
	}
	return ret;
}
int ABS(int a){return max(a,-a);}
long long ABS(long long a){return max(a,-a);}
double ABS(double a){return max(a,-a);}
// ここから編集しろ
long long A[210000];
long long B[210000];
int main(){
	int a,b;scanf("%d%d",&a,&b);
	for(int i=0;i<2*a;i++)scanf("%lld",A+i);
	for(int i=0;i<a*2;i++)scanf("%lld",B+i);
	set<pair<long long,int> > S;
	for(int i=1;i<a*2-1;i++)S.insert(make_pair(A[i]-B[i],i));
	int neg=0;
	long long ret=0;
	for(set<pair<long long,int> >::iterator it=S.begin();it!=S.end();it++){
		if(it->first<0)neg++;
		ret+=max(A[it->second],B[it->second]);
	}

	for(int i=0;i<b;i++){
		int p;
		long long q,r;scanf("%d%lld%lld",&p,&q,&r);p--;
		if(p==0||p==a*2-1){
			A[p]=q;
			B[p]=r;
		}else{
			long long tmp=q-r;
			if(A[p]-B[p]<0)neg--;
			if(tmp<0)neg++;

			S.erase(make_pair(A[p]-B[p],p));
			S.insert(make_pair(tmp,p));
			ret-=max(A[p],B[p]);
			ret+=max(q,r);
			A[p]=q;
			B[p]=r;
		}
		long long ans=ret;
		if(neg%2){
			set<pair<long long,int> >::iterator it=S.lower_bound(make_pair(0,0));
			long long to=inf;
			if(it!=S.end())to=min(to,it->first);
			if(it!=S.begin()){
				it--;
				to=min(to,-(it->first));
			}
			ans-=to;
		}
		printf("%lld\n",ans+A[0]+A[a*2-1]);
	}
}

Measured memory_bytes: 18176
#include <stdio.h>

int main()
{
	long long a, b, x, c, i;

	scanf("%lld%lld%lld", &a, &b, &x);
	
  	if(a != 0){
		c = (b/x) - ((a-1)/x);
    }
  	else{
      	c = (b/x) + 1;
    }

	printf("%lld", c);

return 0;
}

Measured memory_bytes: 128
import java.util.PriorityQueue;
import java.util.Scanner;

//Pump up Batteries
public class Main{

	class E implements Comparable<E>{
		int id, t;
		public E(int id, int t) {
			this.id = id;
			this.t = t;
		}
		public int compareTo(E o) {
			return t==o.t?id-o.id:t-o.t;
		}
	}
	
	void run(){
		Scanner sc = new Scanner(System.in);
		for(;;){
			int n = sc.nextInt();
			int T = sc.nextInt();
			if((n|T)==0)break;
			int[][] com = new int[n][50];
			int[][] ch = new int[n][50];
			int[] k = new int[n];
			for(int i=0;i<n;i++){
				for(;;){
					int x = sc.nextInt();
					if(x==0)break;
					com[i][k[i]] = x;
					ch[i][k[i]] = sc.nextInt();
					k[i]++;
				}
			}
			int res = 0;
			boolean[] wait = new boolean[n];
			int[] val = new int[n];
			for(int i=0;i<n;i++)val[i] = com[i][0];
			int[] p = new int[n];
			PriorityQueue<E> q = new PriorityQueue<E>();
			for(int t=0;t<T;t++){
				for(int i=0;i<n;i++){
					if(wait[i])continue;
					if(val[i]==0){
						wait[i] = true;
						val[i] = ch[i][p[i]];
						q.add(new E(i, t));
					}
					else val[i]--;
				}
				if(q.isEmpty())continue;
				E e = q.peek();
				for(int i=0;i<n;i++){
					if(e.id==i){
						val[i]--;
						if(val[i]==0){
							q.poll();
							p[i] = (p[i]+1)%k[i];
							val[i] = com[i][p[i]];
							wait[i] = false;
						}
					}
					else if(wait[i])res++;
				}
			}
			System.out.println(res);
		}
	}
	
	public static void main(String[] args) {
		new Main().run();
	}
}

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

int main() {
  int N;
  cin >> N;
  int sum = 0;
  int a = N;
  vector<int> vec(8);
  for(int i = 0; i < 8; i++){
    vec.at(i) = a % 10;
    a /= 10;
    if(a == 0){
      break;
    }
  }
 for(int i = 0; i < vec.size() ; i++){
    sum += vec.at(i);
  }
  
  if(N % sum == 0){
     cout << "Yes" << endl;
  }else{
     cout << "No" << endl;
  }
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cctype>
#include <climits>
#include <clocale>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

const int MOD = 1'000'000'007; 
const int INF = 1'000'000'000; //1e9
const int NIL = -1;
const long long LINF = 1'000'000'000'000'000'000; // 1e18
const long double EPS = 1E-10;

template<class T, class S> inline bool chmax(T &a, const S &b){
    if(a < b){
        a = b; return true;
    }
    return false;
}
template<class T, class S> inline bool chmin(T &a, const S &b){
    if(b < a){
        a = b; return true;
    }
    return false;
}






int main(){
    int N, W; std::cin >> N >> W;
    std::vector<int> w(N), v(N);
    for(int i(0); i < N; ++i){
        std::cin >> w[i] >> v[i];
    }
    //i番目(1o)まで, 価値j以上 で重さ最小値
    std::vector<std::vector<long long>> dp(N+1, std::vector<long long>(100'001, LINF));
    dp[0][0] = 0;
    for(int i(1); i <= N; ++i){
        for(int j(0); j <= 100'000; ++j){
            dp[i][j] = dp[i-1][j];
            if(j >= v[i-1]) chmin(dp[i][j], dp[i-1][j-v[i-1]] + w[i-1]);
        }
    }
    for(int j(100'000); j >= 0; --j){
        if(dp[N][j] <= W){
            std::cout << j << std::endl;
            return 0;
        }
    }
    return 0;
}


Measured memory_bytes: 80256
#include <iostream>
#include <string>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
#include <vector>
#include <bitset>
#include <queue>
using namespace std;
template <typename T>
vector<T> vec1d_init(int len){
    vector<T> vec(vector<T>(len, 0));
    return vec;
}
vector<string> vec1d_init(int len){
    vector<string> vec(vector<string>(len, ""));
    return vec;
}
template <typename T>
vector<T> vec1d_sort(vector<T> vec, bool min_to_max=true){
    sort(vec.begin(), vec.end(), [min_to_max](const T a, const T b){return (min_to_max == true) ? (a < b) : (b < a);});
    return vec;
}
template <typename T>
void vec1d_show(vector<T> vec){
    for(int i = 0; i < vec.size(); i++){
        cout << vec[i] << " ";
    }
    cout << endl;
}
int main(){
    int N;
    cin >> N;
    auto a = vec1d_init<long long>(N);
    for(int i = 0; i < N; i++){
        cin >> a[i];
    }
    a = vec1d_sort(a, false);
    long long ans = 0;
    int nside = 0;
    long long side = 0;
    for(int i = 1; i < N; i++){
        if(a[i] == a[i-1]){
            nside++;
            if(nside == 1){
                side = a[i];
            }
            if(nside == 2){
                ans = side * a[i];
                cout << ans << endl;
                return 0;
            }
            i++;
        }
    }
    cout << 0 << endl;
    return 0;
}

Measured memory_bytes: 1792
use std::io;
fn get_parms() -> Vec<i32> {
    let mut buf = String::new();
    io::stdin().read_line(&mut buf).expect("stdin error");
    return buf
        .split_whitespace()
        .map(|x| x.parse().expect("Parse failed"))
        .collect();
}

fn main() {
    let vec = get_parms();
    let (a, b, c) = (vec[0], vec[1], vec[2]);
    let mut n = a;
    let mut cnt = 0;
    while n <= b {
        if c % n == 0 {
            cnt += 1;
        }
        n += 1;
    }
    println!("{}", cnt);
}



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


int main(){
  int n;
  scanf("%d",&n);
  int a[n];
  for(int i=0;i<n;i++){
    scanf("%d",a+i);
  }

  int sum1=0,sum2=0;
  int diff=INT_MAX;
  for(int i=1;i<n;i++){

    for(int j=0;j<i;j++){
      sum1+=a[j];
    }
    for(int k=i;k<n;k++){
      sum2+=a[k];
    }
    if(diff>abs(sum1-sum2)){
      diff=abs(sum1-sum2);
    }
    sum1=0,sum2=0;
  }
  cout<<diff<<"\n";
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
const int INF = 1e9+5;
int main()
{
    int n;
    cin >> n;
    vector<int> dp(3);
    // dp[i] = the total happiness such that we did actvity i on the last day
    for(int day = 0;day<n;day++)
    {   vector<int> c(3);
        vector<int> new_dp(3,0);       
        for(int i=0;i<3;i++)
        cin >> c[i];
        for(int i=0;i<3;i++)
        {
           for(int j=0;j<3;j++)
           {
               if(i!=j)
               {
                   new_dp[j] = max(new_dp[j],dp[i]+c[j]);
               }
           } 
        }
        dp = new_dp;
    }

    cout << max({dp[0],dp[1],dp[2]});
}

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

using namespace std;

typedef long long int ll;
const int INF = 1<<30;
const long long LINF = 1LL<<60;

int main(){
    ll n;
    cin >> n;
    vector<ll> a(5);
    for(int i = 0; i < 5; i++){
        cin >> a[i];
    }
    ll b = *min_element(begin(a), end(a));
    ll ans = 4;
    ans += (n + b - 1) / b;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
import sys
import collections

sys.setrecursionlimit(10 ** 8)

input = sys.stdin.readline


def main():
    N = int(input())
    A = [int(x) for x in input().split()]

    ruiseki = [0] * (N + 1)
    for i, a in enumerate(A):
        ruiseki[i] = ruiseki[i - 1] + a

    c = collections.Counter(ruiseki)

    ans = 0
    for v in ruiseki:
        ans += c[v] - 1

    print(ans // 2)


if __name__ == '__main__':
    main()


Measured memory_bytes: 41544
import java.util.Scanner;
import java.util.Arrays;
import java.util.Comparator;

public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		Piece[] pieces = new Piece[103];
		for(int i=1; i<103; i++){
			pieces[i] = new Piece();
		}

		while(true){
			int cut = sc.nextInt();
			int w = sc.nextInt();
			int d = sc.nextInt();
			if(cut==0 && w==0 && d==0) break;
			pieces[1].setValue(w, d, 1);

			int p, s, j = 2;
			for(int i=2; i<=cut+1; i++){
				p = sc.nextInt();
				s = sc.nextInt();

				s %= (pieces[p].width+pieces[p].depth);

				if(s<pieces[p].width){
					if(s*2<pieces[p].width){
						pieces[i].setValue(pieces[p].width-s, pieces[p].depth, j+1);
						pieces[p].setValue(s, pieces[p].depth, j);
					}else{
						pieces[i].setValue(s, pieces[p].depth, j+1);
						pieces[p].setValue(pieces[p].width-s, pieces[p].depth, j);
					}
				}else{
					if((s-pieces[p].width)*2<pieces[p].depth){
						pieces[i].setValue(pieces[p].width, pieces[p].width+pieces[p].depth-s, j+1);
						pieces[p].setValue(pieces[p].width, s-pieces[p].width, j);
					}else{
						pieces[i].setValue(pieces[p].width, s-pieces[p].width, j+1);
						pieces[p].setValue(pieces[p].width, pieces[p].width+pieces[p].depth-s, j);
					}
				}
				j += 2;

				Arrays.sort(pieces, 1, i+1, new Comparator<Piece>(){
					public int compare(Piece p1, Piece p2){
						return p1.identify - p2.identify;
					}
				});
			}

			Arrays.sort(pieces, 1, cut+2, new Comparator<Piece>(){
				public int compare(Piece p1, Piece p2){
					return p1.area - p2.area;
				}
			});

			for(int i=1; i<=cut+1; i++){
				System.out.print(pieces[i].area);
				if(i<=cut) System.out.print(" ");
			}
			System.out.println();
		}
	}

	static class Piece{
		int width, depth, area;
		int identify;
		void setValue(int a, int b, int c){
			width = a;
			depth = b;
			area = a*b;
			identify = c;
		}
	}
}

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

int main(){
	string a,b,c;
	int count=0;

	cin >>a >>b >>c;
	if(a[a.size()-1]==b[0])count++;
	if(b[b.size()-1]==c[0])count++;
	if(count==2)cout<<"YES"<<endl;
	else cout<<"NO"<<endl;
	return 0;
}

Measured memory_bytes: 256
import heapq
N,M=map(int,input().split())
A = list(map(int,input().split()))

pq = []
for a in A:
    heapq.heappush(pq, -a)
ans = 0
for i in range(M):
    tmp = (-heapq.heappop(pq)) // 2
    heapq.heappush(pq,-tmp)
    
print(-sum(pq))

Measured memory_bytes: 64792
#include<iostream>
using namespace std;
bool solve(int x, int y)
{
	if(y&1)
		return false;
	else
		return 2*x <= y && y <= 4*x;
}
int main()
{
	int x, y; cin >> x >> y;
	cout<<(solve(x,y) ? "Yes": "No")<<endl;
	return 0;
}

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

using namespace std;
#define all(a)a.begin(),a.end()
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
const int mod= int(1e9)+7;
using P = pair<ll,ll>;
using ld=long double;

int main(){
    ll n;cin>>n;
    vector<ll>a(n);
    vector<ll>sum(n+1,0);
    for (int i = 0; i < n; ++i) {
        cin >>a[i];
        sum[i+1]=sum[i]+a[i];
    }
    ll ans=INFll;
    for (int i = 1; i <n; ++i) {
        ans=min(ans,abs((sum[n]-sum[i])-sum[i]));
    }
    cout <<ans <<endl;
    return 0;
}

Measured memory_bytes: 3328
using System;

class MyClass
{
    public static void Main(string[] args)
    {
        string str;
        while ((str = Console.ReadLine()) != "0")
        {
            string[] str2 = str.Split(' ');
            int q1 = int.Parse(str2[0]);
            int b = int.Parse(str2[1]);
            int c1 = int.Parse(str2[2]);
            int c2 = int.Parse(str2[3]);
            int q2 = int.Parse(str2[4]);
            int jidori = b / c1;
            int futuu = (b - jidori * c1) / c2;
            bool na = false;
            if (jidori == 0)
            {
                Console.WriteLine("NA");
                continue;
            }
            while (!(q1 <= jidori + futuu && jidori <= q2))
            {
                jidori--;
                futuu = (b - jidori * c1) / c2;
                if (jidori <= 0)
                {
                    Console.WriteLine("NA");
                    na = true;
                    break;
                }
            }
            if (!na)
            {
                Console.WriteLine("{0} {1}", jidori, futuu);
            }
        }
    }
}


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

typedef long long ll;

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

    int ans = 0;
    for (int i = 0; i < s.size() / 2; i++) {
        if (s[i] != s[s.size() - 1 - i]) {
            ans++;
        }
    }
    printf("%d\n", ans);
}

Measured memory_bytes: 256
#include <stdio.h>
 
using namespace std;
 
int main(){
    int a,b;
    while(true){
        scanf("%d %d",&a,&b);
        if(a == 0 && b == 0) break;
        if(a > b) printf("%d %d\n",b,a);
        else{
            printf("%d %d\n",a,b);
        }
    }
}


Measured memory_bytes: 2580
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        FastScanner in = new FastScanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        B solver = new B();
        solver.solve(1, in, out);
        out.close();
    }

    static class B {
        public void solve(int testNumber, FastScanner in, PrintWriter out) {
            int n = in.ni();
            int[] h = in.na(n);
            int max = 0;
            int ans = 0;
            for (int i = 0; i < n; i++) {
                if (h[i] >= max) {
                    ans++;
                    max = h[i];
                }
            }
            out.println(ans);
        }

    }

    static class FastScanner {
        private BufferedReader in;
        private StringTokenizer st;

        public FastScanner(InputStream stream) {
            in = new BufferedReader(new InputStreamReader(stream));
        }

        public String ns() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    String rl = in.readLine();
                    if (rl == null) {
                        return null;
                    }
                    st = new StringTokenizer(rl);
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return st.nextToken();
        }

        public int ni() {
            return Integer.parseInt(ns());
        }

        public int[] na(int n) {
            int[] a = new int[n];
            for (int i = 0; i < n; i++) a[i] = ni();
            return a;
        }

    }
}



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

int main () {
  string s;
  int n;
  cin >> n >> s;
  int red=0;
  for(int i=0;i<n;i++){
    if(s.at(i)=='R'){
        red++;
      }
  }
  int ans=0;
  for(int i=0;i<red;i++){
    if(s.at(i)=='W'){
        ans++;
      }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3692
# coding: utf-8
def main
  n,m = gets.chomp.split(/ /).map {|i| i.to_i}
  hs = gets.chomp.split(/ /).map {|i| i.to_i}
  hs.unshift(0) #indexを合わせる

  h = Hash.new
  (1..m).each {|j|
    a,b = gets.chomp.split(/ /).map {|i| i.to_i}

    h[a] = [] unless h[a]
    h[b] = [] unless h[b]

    h[a] << b
    h[b] << a
  }

  #p h
  #p hs

  good = []
  (1..n).each {|i|
    rs = h[i]
    rs = [] unless rs
    #next if hs.empty?

    # hの高さ
    hh = hs[i]

    higher = true
    rs.each { |r|
      if hh <= hs[r]
        higher = false
        break
      end
    }

    if higher
      good << i 
    end
  }

  #p good
  x = good.length
  puts x
end

main


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

using namespace std;

#define rep(i, n) for(int i = 0; i < (int)n; ++i)
#define FOR(i, a, b) for(int i = a; i < (int)b; ++i)
#define rrep(i, n) for(int i = ((int)n - 1); i >= 0; --i)

using ll = long long;
using ld = long double;

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

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(0);
	int n, k;
	cin >> n >> k;
	int res = 0;
	rep (i, n) {
	  int h;
	  cin >> h;
	  res += (h >= k);
	}
	cout << res << endl;
    
    return 0;
}



Measured memory_bytes: 3620
num,weight = (int(n) for n in input().split(" "))
query = []
for n in range(num):
    query.append([int(n) for n in input().split(" ")])
nap = [[0 for n in range(weight + 1)] for m in range(num + 1)]
for n in range(num):
    for w in range(weight + 1):

        if query[n][1] <= w:
            nap[n + 1][w] = max(nap[n][w-query[n][1]] + query[n][0],nap[n][w])
        else:
            nap[n + 1][w] = nap[n][w]
print(nap[num][weight])

Measured memory_bytes: 44360
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <memory.h>
#include <math.h>
#include <assert.h>
#include <queue>
#include <map>
#include <set>
#include <string>
#include <algorithm>
#include <iostream>
#include <functional>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <bitset>

using namespace std;
typedef pair<int, int> Pi;
typedef long long ll;
#define pii Pi
#define pll PL
#define Fi first
#define Se second
#define pb(x) push_back(x)
//#define sz(x) ((int)(x).size())
#define rep(i, n) for(int i=0;i<n;i++)
#define all(x) (x).begin(), (x).end()
typedef tuple<int, int, int> t3;
typedef pair<ll, ll> pll;
typedef long double ldouble;
typedef pair<double, double> pdd;

const double PI = acos(-1);
const double EPS = 1e-9;

const int MX = 16;
const int MM = 1000000007;

vector<int> R[MX], G[MX];
int N, M;
int ans = 1;

int L[MX];

void update(int cnt){
	int lev1[14] = {}, lev2[14] = {}, mul = 1;
	for(int c : G[0]){
		lev1[L[c]] += 1;
		mul *= 2;
	}
	for(int c : G[1]){
		lev2[L[c]] += 1;
		mul *= 2;
	}
	int tot = 0;
	for(int i = 0; mul && i <= 13; i++){
		tot = (tot + (mul >> lev1[i] + lev2[i])) % MM;
		mul = (mul >> lev1[i] + lev2[i]) * ((1<<lev1[i])-1) * ((1<<lev2[i])-1);
	}
	ans = (ans + MM - (ll)tot * cnt%MM) % MM;
}

void dfs(int x, int cnt = 1){
	if( x == 1 ){
		update(cnt);
		return;
	}
	int lev[14] = {}, mul = 1;
	for(int c : G[x]){
		lev[L[c]] += 1;
		mul *= 2;
	}
	for(int i = 0; mul && i <= 13; i++){
		L[x] = i;
		dfs(x-1, (ll)cnt * (mul >> lev[i]) % MM);

		mul = (mul >> lev[i]) * ((1<<lev[i]) - 1);
	}
}

int main()
{
	scanf("%d%d", &N, &M);
	if( N == 2 ) return !printf("%d\n", M);
	for(int i = 1; i <= M; i++) ans = ans * 2 % MM;

	for(int i = 1; i <= M; i++){
		int a, b;
		scanf("%d%d", &a, &b); a--; b--;
		if( a == 0 && b == 1 ) continue;
		R[b].push_back(a);
		G[a].push_back(b);
	}
	L[N-1] = 0;
	dfs(N-2);

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


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

#define fix(n)          cout<<fixed<<setprecision(n)
#define rep(i,n)        for (int i = 0; i < (n); ++i)
#define sort(a)         sort((a).begin(), (a).end())
#define uniq(a)         SORT(a);(a).erase(unique((a).begin(), (a).end()), (a).end())
#define reverse(a)      reverse((a).begin(), (a).end())
#define ctos(c)         string(1, (c))
#define out(d)          cout << (d)
#define outl(d)         std::cout<<(d)<<"\n"
#define Yes()           printf("Yes\n")
#define No()            printf("No\n")
#define YES()           printf("YES\n")
#define NO()            printf("NO\n")
#define ceil(x, y)      ((x + y - 1) / (y))
#define debug(x)        cerr << #x << ": " << (x) << '\n'
#define debug2(x, y)    cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << '\n'
#define debug3(x, y, z) cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << ", " << #z << ": " << (z) << '\n'
#define dbg(v)          for (size_t _ = 0; _ < v.size(); ++_){ cerr << #v << "[" << _ << "] : " << v[_] << '\n'; }

using namespace std;
using ll = long long;
using P = pair<ll,ll>;

const ll MOD = 1000000007; // 10^9 + 7

int sumOfDigits(ll n) {
  int ret = 0;
  while (n > 0) {
    ret += n % 10;
    n /= 10;
  }
  return ret;
}

void solve() {
  int n; cin >> n;
  if (n % sumOfDigits(n) == 0) Yes();
  else No();
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  srand((unsigned)time(NULL));
  fix(12);

  solve();
}


Measured memory_bytes: 888
def main():
  n = int(input())
  S = input()
  ans = 0
  dp = [0]*(n*n)
  for j in range(n-1, 0, -1):
    for i in range(j-1, -1, -1):
      if j == n-1:
        dp[i*n+j] = int(S[i] == S[j])
      else:
        if S[i] == S[j]:
          dp[i*n+j] = dp[i*n+j+1+n] + 1
      ans = max(ans, min(dp[i*n+j], j-i))
  print(ans)
if __name__ == "__main__":
  main()

Measured memory_bytes: 269240
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
//#include<bits/stdc++.h>
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

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


	char S[3][2002];
	rep(i, 3) scanf("%s", S[i]);
	int L[3];
	rep(i, 3) L[i] = strlen(S[i]);

	bool dame[3][3][4020] = {};
	rep(i, 3) rep(j, 3) if (i != j) {
		rep(k, L[i]) {
			auto si = S[i] + k;
			auto sj = S[j];
			rep(x, min(L[i] - k, L[j])) {
				if (si[x] != '?' && sj[x] != '?' && si[x] != sj[x]) {
					dame[i][j][k] = 1;
					break;
				}
			}
		}
	}

	int P[3] = { 0,1,2 };
	int saishou = 6000;
	rep(x, 6) {
		int i = P[0];
		int j = P[1];
		int k = P[2];
		auto dij = dame[i][j];
		auto djk = dame[j][k];

		rep(p, L[i] + 1) {
			auto dik = dame[i][k] + p;
			int tmp = max(L[i], L[j] + p);
			if (tmp >= saishou) break;
			if (!dij[p]) {
				rep(q, saishou - L[k] - p) {
					if (!djk[q] && !dik[q]) {
						saishou = max(tmp, L[k] + p + q);
						break;
					}
				}
			}
		}
		next_permutation(P, P + 3);
	}

	printf("%d", saishou);


	Would you please return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define foi(i,k,n) for (int i = (int)k; i < (int)n; ++i)

using namespace std;

constexpr int MOD = 7+1e9;
constexpr int MAXN = 5+3e6;

int add(int a, int b) {
  int ans = a + b;
  if (ans >= MOD) ans -= MOD;
  return ans;
}

int mul(int a, int b) {
  return (int)((1LL*a*b) % MOD);
}

int sub(int a, int b) {
  int ans = a-b;
  if (ans < 0) ans += MOD;
  return ans;
}

int fpow(int b, int e) {
  int ans = 1;
  for (; e; e >>= 1) {
    if (e&1) ans = mul(ans, b);
    b = mul(b, b);
  }
  return ans;
}

int f[MAXN];
int choose(int n, int k) {
  assert(k <= n);
  return mul(f[n], fpow(mul(f[k], f[n-k]), MOD-2));
}

int main() {
  ios::sync_with_stdio(false); cin.tie(nullptr);
  f[0] = 1;
  for (int i = 1; i < MAXN; ++i) {
    f[i] = mul(f[i-1], i);
  }
  int n,k,ans = 0; cin >> k;
  string s; cin >> s;
  n = s.size() + k;
  k = s.size();
  for (int j = 0; j <= k-1; ++j) {
    ans = add(ans, mul(choose(n, j), fpow(25, n-j)));
  }
  cout << sub(fpow(26,n), ans) << '\n';
  return 0;
}


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

int main()
{
    int n;
    cin>>n;
    int a[101];
    for(int i=0;i<n;i++)
        cin>>a[i];
    sort(a,a+n);
    int ca=0,cb=0;
    for(int i=n-1,j=0;i>=0;i--,j++)
    {
        if(j%2==0)ca+=a[i];
        else cb+=a[i];
    }
    cout<<ca-cb;

    return 0;
}


Measured memory_bytes: 256
def divisor(n):
    divisors = []
    i = 1
    while i * i < n:
        if n % i == 0:
            divisors.append(i)
            divisors.append(n // i)
        i += 1
    if i * i == n:
        divisors.append(i)
    divisors.sort()
    return divisors

n = int(input())
s = int(input())
if n == s:
    print(n + 1)
    exit()
if n < s:
    print(-1)
    exit()
sr = int(n ** 0.5)
for b in range(2, sr + 1):
    m = n
    a = 0
    while m:
        a += m % b
        m //= b
    if a == s:
        print(b)
        exit()
for d in divisor(n - s):
    b = d + 1
    if b <= sr:
        continue
    q = (n - s) // d
    r = n % b
    if q + r == s:
        print(b)
        exit()
print(-1)

Measured memory_bytes: 73228
N = gets.to_i

def solve(value, used,counter)
  return if value > N
  counter[0] += 1 if used == 0b111

  solve(value*10 + 7, used | 0b001,counter)
  solve(value*10 + 5, used | 0b010,counter)
  solve(value*10 + 3, used | 0b100,counter)
end

counter = [0]
solve(0,0,counter)
puts counter[0]


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

void solve() {
    ll m, d;
    cin >> m >> d;
    ll ans = 0;
    for (ll i = 1; i <= d; i++) {
        ll temp = i;
        ll d1 = temp % 10;
        temp /= 10;
        ll d10 = temp % 10;
        if(d1 * d10 <= m && d1 >= 2 && d10 >= 2) ans++;
    }
    cout << ans;
}

int main() {
    ios_base :: sync_with_stdio(false); 
    cin.tie(NULL);
    ll t = 1;
    //cin >> t;
    while(t--) {
        solve();
    }
    return 0;
}

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

using ll = long long;
using ull = unsigned long long;
#define repi(n) for (long long i = 0; i < (n); ++i)
#define repj(n) for (long long j = 0; j < (n); ++j)
#define repk(n) for (long long k = 0; k < (n); ++k)
#define rep(i, a, b) for (auto i = (a); i < (b); ++i)
#define itr(itr) for (auto&& v : (itr))
#define updatemax(t, v) (t = std::max(t, (v)))
#define updatemin(t, v) (t = std::min(t, (v)))

ll a[1000100];
int main() {
  ll k, n;
  cin >> k >> n;
  repi(n) cin >> a[i];
  sort(a, a + n);
  ll re = a[n - 1] - a[0];
  repi(n - 1) updatemin(re, k - (a[i + 1] - a[i]));
  cout << re << endl;
}


Measured memory_bytes: 5148
#include <stdio.h>

int n[100000],q;

int binarysearch(int key)
{
  int left=0;
  int right=q;
  int mid;

  while(left < right)
    {
      mid = (left + right) / 2;
      if (key == n[mid]) return 1;
      if (key > n[mid]) left = mid + 1;
      else if(key < n[mid]) right = mid;
    }
  return 0;
}

int main()
{
  int s,t,i,count=0;

  scanf("%d",&q);
  for(i=0;i<q;i++)
    scanf("%d",&n[i]);

  scanf("%d",&t);

  for(i=0;i<t;i++){
    scanf("%d",&s);
  if(binarysearch(s))
        {
          count++;

        }
  }
  printf("%d\n",count);
  return 0;
}



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

using namespace std;
typedef long long ll;

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
#define all(a) (a).begin(), (a).end()
#define all2(a, b) (a).begin(), (a).begin() + (b)
#define debug(vari) cerr << #vari << " = " << (vari) << endl;
const int MOD = 1e9 + 7;

int main()
{
    int n, x;
    cin >> n >> x;
    vector<int> m(n);
    rep(i, n) cin >> m[i];

    int s = 0;
    rep(i, n) s += m[i];
    sort(all(m));

    cout << n + (x - s) /m[0]  << endl;
    return (0);
}


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

int main() {
	int K;
	cin >> K;
	if (K%2==0) {
		cout << K/2*K/2 << endl;
	} else {
		int tmp1=K/2+1;
		int tmp2=K/2;
		cout << tmp1*tmp2 << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,m,x,y,a;
int main()
{
	scanf("%d%d%d%d",&n,&m,&x,&y);
	while(n--)scanf("%d",&a),x=max(a,x);
	while(m--)scanf("%d",&a),y=min(a,y);
	puts(x<y?"No War":"War");
	return 0;
}

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

typedef long long int ll;
#define rep(i,n) for (int i = 0; i < n; i++)

int main() {
    int x,a;
    cin >> x >> a;
    if (x < a) cout << 0 << endl;
    else cout << 10 << endl;
    return 0;
}

Measured memory_bytes: 3632
def solve(as, ss)
  bs = []
  as.zip(ss).each do |a, s|
    bs.each{|b| a = [a, a ^ b].min}
    next if a.zero?
    if s == '0'
      bs << a
    else
      return 1
    end
  end
  0
end

(gets.to_i).times do
  gets
  puts solve(gets.split.map(&:to_i).reverse, gets.chomp.chars.reverse)
end

Measured memory_bytes: 14216
#include<bits/stdc++.h>
#include <iostream>
#include <string>
#include <cmath>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repR(i,n) for(ll i=n;i>=0;i--)
#define all(v)(v).begin(),(v).end()
#define rall(v)(v).rbegin(),(v).rend()
#define F first
#define S second
#define pb push_back
#define pu push
#define COUT(x) cout<<(x)<<endl
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,vector<ll>,greater<ll>>
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define mp make_pair
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define sz(x) (int)(x).size()
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll MOD = 1000000007LL;
const ll INF = 1LL << 60;
using vll = vector<ll>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvll = vector<vll>;
using vstr = vector<string>;
using pll = pair<ll, ll>;
using vc = vector<char>;
using vvc = vector<vc>;
ll dx[4]={0,1,0,-1};
ll dy[4]={1,0,-1,0};
int main(){
  ll n,r;
  cin>>n>>r;
  if(n>=10){
    COUT(r);
  }
  else{
    COUT(r+100*(10-n));
  }
}

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

// clang-format off
#define  range(i, l, r) for (int i = (int)(l); i < (int)(r); ++(i))
#define rrange(i, l, r) for (int i = (int)(r) - 1; i >= (int)(l); --(i))

#define  whole(f, x, ...) ([&](decltype((x)) container) { return (f)(  begin(container),  end(container), ## __VA_ARGS__); })(x)
#define rwhole(f, x, ...) ([&](decltype((x)) container) { return (f)( rbegin(container), rend(container), ## __VA_ARGS__); })(x)

#define endl '\n'
#define debug(x) cerr << "(" << __LINE__ << ")" << #x << ": " << (x) << endl

using i32 = int;
using u32 = unsigned int;
using i64 = long long;
using u64 = unsigned long long;

constexpr i32 mod   = 1e9 + 7;
constexpr i32 inf   = 1001001001;
constexpr i64 infll = 1001001001001001001ll;

constexpr int dx[] = {0, -1, 1, 0, -1, 1, -1, 1}; 
constexpr int dy[] = {-1, 0, 0, 1, -1, -1, 1, 1};

struct IoSetup { IoSetup(int x = 15){ cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(x); cerr << fixed << setprecision(x); } } iosetup;

template <typename T = i64> T input() { T x; cin >> x; return x; }

template <typename T> ostream &operator<<(ostream &os, vector<T> &v) { range(i, 0, v.size()) { os << v[i] << (i + 1 != v.size() ? " " : ""); } return os; } 
template <typename T> istream &operator>>(istream &is, vector<T> &v) { for (T &in : v) is >> in; return is; }

template <typename T1, typename T2> ostream &operator<<(ostream &os, pair<T1, T2> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
template <typename T1, typename T2> istream &operator>>(istream &is, pair<T1, T2> &p) { is >> p.first >> p.second; return is; }

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

template <typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template <typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }
// clang-format on

void solver() {
  string s = input<string>();
  whole(sort, s);

  cout << (s.front() == s.back() ? "No" : "Yes") << endl;
}

signed main(int argc, char *argv[]) { solver(); }

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include<algorithm>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<iostream>
#include<vector>
#include<queue>
#include<deque>
#include<stack>
#include<set>
#include<map>
#include<string>
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define rep2(i,s,n) for(int i=s;i< (int)n; i++)
#define ll long long 
#define all(v) v.begin(),v.end()
using namespace std;
int main(){
  string s;
  cin >>s;
  if(s=="ABC") cout <<"ARC"<<endl;
  else cout <<"ABC"<<endl;
}

Measured memory_bytes: 3588
import java.io.*;
import java.util.*;
import java.util.Map.Entry;
public class Main {
	static Scanner sc;
	static PrintWriter out;
	public static void main(String[] args) throws Exception{
		// TODO Auto-generated method stub
		sc = new Scanner(System.in);
		out = new PrintWriter(System.out);
		int l = sc.nextInt();
		HashMap<Integer, Long> map = new HashMap<Integer, Long>();
		int a[] = new int[l];
		for (int i = 0; i < a.length; i++) {
			int tmp = sc.nextInt();
			a[i] = tmp;
			map.put(tmp, map.getOrDefault(tmp, 0l)+1);
		}
		long total = 0l;
		for(Entry<Integer, Long>e:map.entrySet()) {
			long n = e.getValue();
			total += n*(n-1)/2;
		}
		for(int i:a) {
			long v = map.get(i);
			long ans = total - v*(v-1)/2 + (v-1)*(v-2)/2; 
			out.println(ans);
		}
		
		out.flush();
	} 
	static boolean isPalindrome(String s) {
		int l = s.length();
		char[] sa = s.toCharArray();
		for(int i=0;i<l/2;i++) {
			if(sa[i] != sa[l-i-1])
				return false;
		}
		return true;
	}
	static class Scanner{
		private BufferedReader br;
		private StringTokenizer st;
		public Scanner(InputStream in) {
			br = new BufferedReader(new InputStreamReader(in));
		}
		public String next() throws IOException{
			while(st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}
		public String nextLine() throws IOException {
			return br.readLine();
		}
		public int nextInt() throws IOException{
			return Integer.parseInt(next());
		}
		public long nextLong() throws IOException{
			return Long.parseLong(next());
		}
		public double nextDouble() throws IOException{
			return Double.parseDouble(next());
		}
		public int[] inArr(int n) throws Exception{
			int a [] = new int[n];
			st = new StringTokenizer(br.readLine());
			for(int i=0;i<n;i++) {
				a[i] = Integer.parseInt(st.nextToken());
			}
			return a;
		}
	}
}

Measured memory_bytes: 57320
yn = lambda b: print('Yes') if b else print('No')

s = input()		# 文字列の入力  abcdefg...

b = True
b = b and (s.count(s[0]) == 2)
b = b and (s.count(s[1]) == 2)
b = b and (s.count(s[2]) == 2)
b = b and (s.count(s[3]) == 2)

yn(b)



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

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

  int tot = 0;
  for (int i = 1; i <= N; i++) {
    for (int j = 1; j <= N; j++) {
      for (int k = 1; k <= N; k++) {
        tot += __gcd(__gcd(i, j), k);
      }
    }
  }

  cout << tot << endl;
}

Measured memory_bytes: 3636
#pragma region Macros
#include <bits/stdc++.h>

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using WGraph = vector<vector<pair<int, ll>>>;

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

constexpr int dx[4] = {-1, 0, 0, 1}, dy[4] = {0, -1, 1, 0};
constexpr int INF = 1e9;
constexpr long long LINF = 1e18;
#pragma endregion

void solve() {
    int n;
    cin >> n;
    vector<pair<int, int>> point(n);
    for (int i=0; i<n; i++) {
        cin >> point.at(i).first >> point.at(i).second;
    }
    double low = 0.0, high = 1500.0;
    for (int i=0; i<50; i++) {
        double r = (low + high) / 2.0;
        vector<tuple<double, double, int, int>> ps;
        for (int j=0; j<n; j++) {
            for (int k=j+1; k<n; k++) {
                double dis = sqrt(pow(point.at(j).first - point.at(k).first, 2) + pow(point.at(j).second - point.at(k).second, 2));
                if (dis > 2 * r) continue;
                double h = sqrt(pow(r, 2) - pow(dis / 2.0, 2));
                double x = (point.at(j).first + point.at(k).first) / 2.0, y = (point.at(j).second + point.at(k).second) / 2.0;
                int xx = point.at(k).second - point.at(j).second, yy = point.at(j).first - point.at(k).first;
                double theta = atan2(yy, xx);
                ps.push_back(make_tuple(x + h * cos(theta), y + h * sin(theta), j, k));
                ps.push_back(make_tuple(x - h * cos(theta), y - h * sin(theta), j, k));
            }
        }
        bool found = false;
        for (auto p : ps) {
            double x = get<0>(p), y = get<1>(p);
            int c1 = get<2>(p), c2 = get<3>(p);
            bool ok = true;
            for (int j=0; j<n; j++) {
                if (j == c1 || j == c2) continue;
                double dis = sqrt(pow(x - point.at(j).first, 2) + pow(y - point.at(j).second, 2));
                if (dis > r) {
                    ok = false;
                    break;
                }
            }
            if (ok) {
                found = true;
                break;
            }
        }
        if (found) high = r;
        else low = r;
    }
    cout << low << "\n";
}

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

    solve();

    return 0;
}


Measured memory_bytes: 512
read N Q
awk '
NR == 1 {
    S=$0
    C=0;
    for (i=1; i<length(S); i++) {
        if (substr(S, i, 2) == "AC") {
            C++;
        }
        CSUM[i]=C;
    }
}
NR > 1 {
    print  CSUM[$2-1]-CSUM[$1-1]   
}'


Measured memory_bytes: 7208
from math import sin, cos, radians, sqrt
a, b, h, m = map(int, input().split())
theta_m = 6*m
theta_h = 30*h + 0.5*m
dist = sqrt((a*sin(radians(theta_h)) - b*sin(radians(theta_m)))**2
        + (a*cos(radians(theta_h)) - b*cos(radians(theta_m)))**2)
print(dist)

Measured memory_bytes: 9572
#include <algorithm>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>

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

  uint32_t mod = 2019;
  uint32_t remainder = 0;
  uint32_t base = 1;
  std::vector<uint32_t> mod_num(mod);
  mod_num[0]++;
  for (size_t i = 0; i < S.size(); i++) {
    // |S| max = 200,000よりuint128_tでも到底足りないので各桁毎逐次処理
    uint32_t d_i = S[S.size() - 1 - i] - '0';
    remainder = (remainder + base * d_i) % mod;
    mod_num[remainder]++;

    base = (base * 10) % mod;
  }

  uint32_t ans = 0;
  for (auto &&i : mod_num) ans += i * (i - 1) / 2;

  std::cout << ans << std::endl;

  return 0;
}

Measured memory_bytes: 3752
#include <stdio.h>
#include <math.h>
int main(void){
    long long n,d,x,y,cnt=0;
    scanf("%lld %lld",&n,&d);
    for(int i=0;i<n;i++){
        scanf("%lld %lld",&x,&y);
        if(sqrt(x*x+y*y)<=d) cnt++;
    }
    printf("%lld",cnt);
    return 0;
}

Measured memory_bytes: 2136
#include <bits/stdc++.h>
#include <cstdio>
#include <chrono>
#include <random>
using namespace std;

#define DRACARYS ios_base::sync_with_stdio(false);cin.tie(NULL);cin.exceptions(cin.failbit);mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define rep(i, n)    for(int i = 0; i < (n); ++i)
#define repA(i, a, n)  for(int i = a; i <= (n); ++i)
#define repD(i, a, n)  for(int i = a; i >= (n); --i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
#define fill(a)  memset(a, 0, sizeof (a))
#define fst first
#define snd second
#define mp make_pair
#define pb push_back
#define PI 3.14159265
const long long int MAXN = 2e5+10;
const long long int MINN = 1e5+10;
const long long int inf = 1e18+7;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vi; 
typedef stack<int> st;

int main(){
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    DRACARYS
    int a,b,c;
    cin>>a>>b>>c;
    if(a==b && b==c) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 256
#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;

//#define ordered_set tree<int, null_type,less_equal<int>, rb_tree_tag,tree_order_statistics_node_update>


typedef long long ll;
typedef long double ld;
typedef pair<int,int>pii;
typedef pair<ll, ll>pll;

const int MAX = 1e5 + 6;
const ll MOD = 998244353;
const ll INF = 1e15;
ll dp[106][MAX];
ll v[106], w[106];

int main(){

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

    ll N, W;
    cin >> N >> W;

    for(int i=1; i<=N; i++) cin >> w[i] >> v[i];

    for(int i=0; i<=N; i++){
        for(int val=0; val<MAX; val++){
            if(val == 0) dp[i][0] = 0;
            else dp[i][val] = INF;
        }
    }

    ll ans = 0;

    for(ll i=1; i<=N; i++){
        for(ll val=0; val<MAX; val++){
            if(dp[i-1][val] < INF) dp[i][val] = min(dp[i][val], dp[i-1][val]);
            if(val >= v[i] and dp[i-1][val-v[i]] < INF) dp[i][val] = min(dp[i][val], w[i] + dp[i-1][val-v[i]]);
            if(dp[i][val] <= W) ans = max(ans, val);
        }
    }

    cout << ans;


}

Measured memory_bytes: 80128
#include <bits/stdc++.h>
#define read(arr,n)	for(int i=0;i<n;i++) cin>>arr[i];
#define print(arr,n) for(int i=0;i<n;i++) cout << arr[i]<<' ';cout << endl;

using namespace std;

typedef long long ll;

void solve() {
	string a, b;
	cin >> a >> b;
	map<string,int> m;
	cin >> m[a] >> m[b];
	string k;	cin >> k;	m[k]--;
	cout << m[a] << ' ' << m[b] << endl;
}

int main() {
	int t = 1;
	//cin >> t;
	while (t--) {
		solve();	
	}
	return 0;
}


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

int main()
{
int i,o=0,z=0;
  char a[100000];
  cin >> a;
  for(i=0;(a[i]=='0')||(a[i]=='1');i++)
  {
  if(a[i]=='0')z++;
  if(a[i]=='1')o++;
  }    
  cout << 2*min(z,o) <<endl;
  return 0;
}

Measured memory_bytes: 384
import java.util.Scanner;

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

		String[][] T = new String[14][4];

		T[0][0] = "S";
		T[0][1] = "H";
		T[0][2] = "C";
		T[0][3] = "D";
			

		for(int i = 0; i < 4; i++)
			for (int j = 1; j < 14; j++)
				T[j][i] = "false";

		int n = sc.nextInt();

		String[][] N = new String[n][2];
		for (int i = 0; i < n; i++) {
			N[i][0] = sc.next();
			N[i][1] = sc.next();
			if (N[i][0].equals("S"))
				T[Integer.parseInt(N[i][1])][0] = "true";
			else if (N[i][0].equals("H"))
				T[Integer.parseInt(N[i][1])][1] = "true";
			else if (N[i][0].equals("C"))
				T[Integer.parseInt(N[i][1])][2] = "true";
			else
				T[Integer.parseInt(N[i][1])][3] = "true";
		}

		for(int i = 0; i < 4; i++)
			for (int j = 1; j < 14; j++)
				if(T[j][i].equals("false"))
					System.out.printf("%s %s\n", T[0][i], j);
	}
}	


Measured memory_bytes: 26360
from collections import deque
s=str(input())

front = ""
back = ""#前と後ろに分ける最後につなげてリバース

now_swap = 0
q=int(input())
for i in range(q):
    a = input().strip()
    a = list(a)
    
    if a[0] == "1":
        if now_swap == 0:
           now_swap = 1
        else: #now_step == 1:
            now_swap = 0
    else:
        if now_swap == 1:
            if a[2] == "1":
               # print("back")
                back+=a[4]

            else: #a[1]==2:
               ## print("f 2")
                front = a[4] + front

        else: #now_step == 0:
            if a[2] == "1":
                front = a[4] + front

            else: #a[1]==2:
                #print("hj")
                back+=a[4]
ans= front + s + back
#print(front,a,back)
if now_swap == 1:#合計数が奇数なら
    
    print(ans[::-1])
else:
    print(ans)




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

using namespace std;
typedef long long ll;

vector<pair<ll, int>> factorization(ll n) {
    vector<pair<ll, int>> ret;
    for (ll i = 2LL; i * i <= n; ++i) {
        int k = 0;
        while (n % i == 0) {
            n /= i;
            ++k;
        }
        ret.emplace_back(make_pair(i, k));
    }
    if (n != 1) ret.emplace_back(make_pair(n, 1));

    return ret;
}

ll pow(ll x, ll n) {
    ll ret = 1;
    while (n > 0) {
        if (n & 1) ret *= x;
        x *= x;
        n >>= 1;
    }
    return ret;
}

int main() {
    ll n, p;
    cin >> n >> p;

    if (n == 1) {
        cout << p << endl;
        return 0;
    }

    vector<pair<ll, int>> v = factorization(p);
    sort(v.begin(), v.end());
    reverse(v.begin(), v.end());

    ll ans = 1;
    for (auto item : v) {
        if (item.second >= n) {
            ans *= pow(item.first, item.second / n);
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 6256
#include<functional>
#include<algorithm>
#include<iostream>
#include<iomanip>
#include<cstring>
#include<cstdlib>
#include<utility>
#include<string>
#include<cstdio>
#include<vector>
#include<bitset>
#include<cmath>
#include<ctime>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
using namespace std;
const int inf=2147483647,dx[]={-1,0,1,0},dy[]={0,-1,0,1};// 上 左 下 右
const int N=100005,M=1000005,K=200005,mod=1000000007;
const long long llinf=9223372036854775807ll;
//int & long long
long long n,ans;
int main(){
	cin>>n;
	if(n<2)
	{
		cout<<0;
		return 0;
	}
	if(n%2==1)
	{
		cout<<0;
		return 0;
	}
	if(n%2==0)
	{
		n/=2;
		while(n)
		{
			n/=5;
			ans+=n;
		}
		cout<<ans;
		return 0;
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
import numpy as np
A,B=(int(x) for x in input().split())
st=A%2
en=B%2
AA=0
BB=0
if st!=0:
  AA=A
  A=A+st
if en!=1:
  BB=B
  B=B-en
bit=((B-A+1)//2)%2  
result=BB^AA^bit
print(result)

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

int main(){
  priority_queue<long long> pq;

  while(true){
    string s; cin >> s;
    if(s == "end") break;
    else if(s == "insert"){
      long long x; cin >> x;
      pq.emplace(x);
    }
    else if(s == "extract"){
      cout << pq.top() << endl;
      pq.pop();
    }
  }
}



Measured memory_bytes: 11184