akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#ifndef ONLINE_JUDGE
#define dbg(x...) do { cout << "\033[32;1m " << #x << " -> "; err(x); } while (0)
void err() { cout << "\033[39;0m" << endl; }
template<template<typename...> class T, typename t, typename... A>
void err(T<t> a, A... x) { for (auto v: a) cout << v << ' '; err(x...); }
template<typename T, typename... A>
void err(T a, A... x) { cout << a << ' '; err(x...); }
#else
#define dbg(...)
#endif
typedef long long ll;
typedef pair<int,int> pi;
typedef vector<int> vi;
template<class T> using vc=vector<T>;
template<class T> using vvc=vc<vc<T>>;
template<class T> void mkuni(vector<T>&v)
{
    sort(v.begin(),v.end());
    v.erase(unique(v.begin(),v.end()),v.end());
}
template<class T>
void print(T x,int suc=1)
{
    cout<<x;
    if(suc==1) cout<<'\n';
    else cout<<' ';
}
template<class T>
void print(const vector<T>&v,int suc=1)
{
    for(int i=0;i<v.size();i++)
    print(v[i],i==(int)(v.size())-1?suc:2);
}
struct Edge{
    int to,w;
};
const int maxn=1e5+7;
vc<Edge> G[maxn];
inline void addedge(int u,int v,int w)
{
    G[v].push_back(Edge{u,w});
    G[u].push_back(Edge{v,-w});
}
int cnt[maxn];
int n,m;
int dis[maxn];
bool inq[maxn];
bool vis[maxn];
bool spfa(int st,int cc=0)
{
    if(cc>n) return false;
    vis[st]=1;
    for(auto& e:G[st])
    {
        int v=e.to;
        if(dis[v]>dis[st]+e.w)
        {
            dis[v]=dis[st]+e.w;
            if(!spfa(v,cc+1)) return false;
        }
    }
    return true;
}
bool solve()
{
    memset(dis,0x3f,sizeof(dis));
    for(int i=1;i<=n;i++)
    {
        if(!vis[i])
        {
            dis[i]=0;
            if(!spfa(i))
                return false;
        }
    }
    return true;
    
}
int main()
{
    cin>>n>>m;
    for(int i=0,u,v,w;i<m;i++)
    {
        cin>>u>>v>>w;
        addedge(u,v,w);
    }
    if(solve())
        cout<<"Yes\n";
    else cout<<"No\n";
}

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

int main(){
  int E,Y;
  cin >> E >> Y;

  switch(E){
    case 0:
      if(Y<=1911){
        cout << "M" << Y-1868+1 << endl;
        break;
      }else if(Y<=1925){
        cout << "T" << Y-1912+1 << endl;
        break;
      }else if(Y<=1988){
        cout << "S" << Y-1926+1 << endl;
        break;
      }else if(Y<=2016){
        cout << "H" << Y-1989+1 << endl;
        break;
      }
    case 1:
      cout << Y+1868-1 << endl;
      break;
    case 2:
    cout << Y+1912-1 << endl;
      break;
    case 3:
    cout << Y+1926-1 << endl;
      break;
    case 4:
    cout << Y+1989-1 << endl;
      break;
  }
  return 0;
}



Measured memory_bytes: 3080
#include <cstdio>
#include <iostream>
using namespace std;
int s[10], c[10], N, M;
bool check1(int x)
{
  for(int i = 1; i <= M; i++)
  {
    if(c[i] != x)
      return false;
  }
  return true;
}

bool check2(int x)
{
  int d[3];
  d[1] = x / 10;
  d[2] = x % 10;
  for(int i = 1; i <= M; i++)
  {
    if(d[s[i]] != c[i])
      return false;
  }
  return true;
}

bool check3(int x)
{
  int d[4];
  d[1] = x / 100;
  d[2] = x / 10 % 10;
  d[3] = x % 10;
  for(int i = 1; i <= M; i++)
  {
    if(d[s[i]] != c[i])
      return false;
  }
  return true;
}

int main()
{
  int i, ans;
  cin >> N >> M;
  for(i = 1; i <= M; i++)
  {
    cin >> s[i] >> c[i];
  }
  if(N==1)
  {
    for(ans = 0; ans <= 9; ans++)
    {
      if(check1(ans))
      {
        cout << ans;
        return 0;
      }
    }
    cout << -1;
    return 0;
  }
  else if(N == 2)
  {
    for(ans = 10; ans <= 99; ans++)
    {
      if(check2(ans))
      {
        cout << ans;
        return 0;
      }
    }
    cout << -1;
    return 0;
  }
  else
  {
    for(ans = 100; ans <= 999; ans++)
    {
      if(check3(ans))
      {
        cout << ans;
        return 0;
      }
    }
    cout << -1;
    return 0;
  }
  return 0;
}

Measured memory_bytes: 256
let n = Int(readLine()!)!
 
let a = readLine()!.split(separator: " ").map { Int($0)! }
 
var stocks = 0
var money = 1000
 
for i in 0..<n-1 {
  if a[i] < a[i + 1] {
    // buy
    stocks += money / a[i]
    money = money % a[i]
  } else if a[i] > a[i + 1] {
    //sell
    money += stocks * a[i]
    stocks = 0
  }
}

//sell
money += stocks * a[n-1]
 
print(money)

Measured memory_bytes: 8288
#include <algorithm>
#include <iostream>
#include <vector>
#include <string>
#include <climits> // FOO_MAX, FOO_MIN
#include <cmath> 
#include <cstdlib> // abs(int)
#include <numeric>
#include <iomanip>

using namespace std;

#define roundup(n,d) ( ((n) + ((d)-1)) / (d) )
#define assign_max(into, compared) (into = max((into), (compared)))
#define assign_min(into, compared) (into = min((into), (compared)))
#define rep(i,n) for(long long i = 0;i < n;++i)
#define FAST_IO ios::sync_with_stdio(false); cin.tie(nullptr);
#define fix(n) fixed << setprecision(n)

#define PI 3.14159265358979323846;

using ll = long long;
using ull = unsigned long long;
using vll = vector<long long>;


int main(void){
    FAST_IO
    
    char c;
    cin >> c;
    cout << (char)(c + 1) << endl;
    
    return 0;
}

Measured memory_bytes: 3008
import sys
input = sys.stdin.readline
N, A, B, C, D = map(int, input().split())
dp = [[0] * (B + 1) for _ in range(N + 1)]
mod = 10 ** 9 + 7

class Factorial:
  def __init__(self, n, mod):
    self.f = [1]
    for i in range(1, n + 1):
      self.f.append(self.f[-1] * i % mod)
    self.i = [pow(self.f[-1], mod - 2, mod)]
    for i in range(1, n + 1)[: : -1]:
      self.i.append(self.i[-1] * i % mod)
    self.i.reverse()
  def factorial(self, i):
    return self.f[i]
  def ifactorial(self, i):
    return self.i[i]
  def combi(self, n, k):
    return self.f[n] * self.i[n - k] % mod * self.i[k] % mod

f = Factorial(1000 * 1000, mod)
dp[0][A - 1] = 1
for i in range(N):
  for k in range(A - 1, B):
    x = k + 1
    t = 1
    for j in range(1, C): t = t * f.combi(x * j, x) % mod
    for j in range(C, D + 1):
      if i + x * j <= N:
        t = t * f.combi(x * j, x) % mod
        dp[i + x * j][x] += dp[i][k] * f.combi(N - i, x * j) % mod * t % mod * f.ifactorial(j) % mod
        dp[i + x * j][x] %= mod
      else: break
      #print(j, t, dp)
    dp[i][x] += dp[i][k]
    dp[i][x] %= mod
    #print(dp)

res = 0
for k in range(A, B + 1):
  res += dp[-1][k]
  res %= mod
print(res)

Measured memory_bytes: 131024
#include<bits/stdc++.h>
using namespace std;
#define inf 1e9
#define ll long long
#define ull unsigned long long
#define M 1000000007
#define P pair<int,int>
#define PLL pair<ll,ll>
#define FOR(i,m,n) for(int i=(int)m;i<(int)n;i++)
#define RFOR(i,m,n) for(int i=(int)m;i>=(int)n;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,n,0)
#define all(a) a.begin(),a.end()
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define PI 3.14159265


int g(string s,int k,int n){
  int b[10000];
  int m=0,l=0;
  int a = k;
  string t;
  int mmax=0;

  if('0'<=s[k]&&s[k]<='9'){
    int ans=0;
    while('0'<=s[k]&&s[k]<='9'){
      ans*=10;
      ans+=s[k]-'0';
      k++;
    }
    return ans;
  }

  FOR(i,k,n){
    if(s[i]=='['){
      m++;
      mmax=max(mmax,m);
    }
    if(s[i]==']') m--;
    if(m==0){
      b[l]=g(s,a+1,i);
      l++;
      a = i+1;
    }
  }


  if(l==1) return b[0];

  sort(b,b+l);
  int res=0;

  if(mmax!=1){
    
    rep(i,l%2+l/2){
      res+=b[i];
    }
    return res;
  }
  res=0;

  rep(i,l%2+l/2){
    res+= b[i]%2+b[i]/2;
  }
  return res;
}


void f(){
  string s;
  cin>>s;

  cout<<g(s,0,(int)s.length())<<endl;
}


int main(){
  int n;
  cin>>n;
  while(n--){
    f();
  }
}


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

public class Main {

	static final BufferedReader in = new BufferedReader(new InputStreamReader(System.in));

	public static void main(String[] args) throws IOException {

		// --- input ---
		String s = in.readLine();
		in.close();

		// --- resolv ---
		int to = s.length();
		String[] words = {"dream", "erase", "eraser", "dreamer"}; // 5,6,7
		label : while(to > 0) {
			for(String w : words) {
				if(to >= w.length() && w.equals(s.substring(to - w.length(), to))) {
					to -= w.length();
					continue label;
				}
			}
			System.out.println("NO");
			return;
		}

		System.out.println((to==0)?"YES":"NO");
	}
}


Measured memory_bytes: 25428
#include<iostream>
using namespace std;
void find( int* a, int x, int y )
{
    int min = 2147483647;
    for( int i = x; i <= y; i++ )
        if( min > a[i] )
            min = a[i];
    cout << min<<endl;
}

int main()
{
    int a[100000], n, q, x, y;
    bool com;

    for( int i = 0; i < 100000; i++ )
        a[i] = 2147483647;
    cin >> n >> q;
    for( int i = 0; i < q; i++ )
    {
        cin >> com >> x >> y;
        if( com == 1 )
            find( a, x, y );
        if( com == 0 )
            a[x] = y;
    }

    return 0;
}




Measured memory_bytes: 3484
import std.stdio, std.conv, std.functional, std.string;
import std.algorithm, std.array, std.container, std.range, std.typecons;
import std.numeric, std.math, std.random;
import core.bitop;

string FMT_F = "%.15f";

static string[] s_rd;
T RD(T = long)() { while(!s_rd.length) s_rd = readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
string RDR()() { return readln.chomp; }
T[] ARR(T = long)(in string str, T fix = 0) { auto r = str.split.to!(T[]); r[] += fix; return r; }
T[] RDA(T = long)(T fix = 0) { auto r = readln.chomp.split.to!(T[]); r[] += fix; return r; }
T[][] RDA2(T = long)(size_t n, T[] fix = []) { auto r = new T[][](n); foreach (i; 0..n) { r[i] = readln.chomp.split.to!(T[]); foreach (j, e; fix) r[i][j] += e; } return r; }
size_t[] MAKE_IDX(alias less = "a < b", Range)(Range range) { auto idx = new size_t[](range.length); makeIndex!(less)(range, idx); return idx;}
size_t MIN_POS(alias less = "a < b", Range)(Range range) { auto r = minPos!(less)(range); return range.length - r.length; }

bool inside(T)(T x, T b, T e) { return x >= b && x < e; }
long lcm(long x, long y) { return x * y / gcd(x, y); }

long mod = 10^^9 + 7;
//long mod = 998244353;
//long mod = 1_000_003;
void moda(ref long x, long y) { x = (x + y) % mod; }
void mods(ref long x, long y) { x = ((x + mod) - (y % mod)) % mod; }
void modm(ref long x, long y) { x = (x * y) % mod; }

void main()
{
	auto N = RD;
	auto M = RD;
	auto A = RDA;
	auto B = new double[](N);
	foreach (i; 0..N)
		B[i] = A[i];

	auto heap = heapify(B);
	foreach (i; 0..M)
	{
		auto x = heap.front; heap.removeFront;
		heap.insert(x/2.0);
	}

	long ans;
	foreach (i; 0..N)
	{
		auto x = heap.front; heap.removeFront;
		ans += cast(long)x;
	}

	writeln(ans);
	stdout.flush();
	debug readln();
}

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

using namespace std;

int main()
{
    int goats =3;
    long long int a,b;
    cin>>a>>b;
    if(a%goats==0 || b%goats==0 || (a+b)%goats==0){
        cout<<"Possible";
    }else{
        cout<<"Impossible";
    }


}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define WHOLE(v) (v).begin(), (v).end()
#define REV_WHOLE(v) (v).rbegin(), (v).rend()
using i64 = int64_t;
using namespace std;
template<typename T> using rev_priority_queue = priority_queue<T, vector<T>, greater<T>>;
template<class S, class T> void map_init(map<S, T> &m, S k, T v){if(!m.count(k)) m[k] = v;}
void R_YESNO(bool p) { cout << (p ? "YES": "NO") << endl;}
void R_YesNo(bool p) { cout << (p ? "Yes": "No") << endl;}
int main() {
    int N, K;
    cin >> N >> K;
    // おいしい寿司
    map<int, i64> best;
    // 消去候補の寿司(まずい順)
    rev_priority_queue<pair<i64, int>> dust;
    // あまりものの寿司(おいしい順)
    priority_queue<pair<i64, int>> rest;

    for(int i = 0; i < N; i++) {
        int t; i64 d;
        cin >> t >> d;
        rest.push({d, t});
    }
    // 答えと候補
    i64 ans = 0, pt = 0;

    // おいしい K 個だけ取り出す
    for(int i = 0; i < K; i++) {
        int t; i64 d;
        tie(d, t) = rest.top(); rest.pop();
        pt += d;
        if(best.count(t)) {
            dust.push({d, t});
        } else {
            best[t] = d;
        }
    }
    ans = max<i64>(ans, pt + best.size() * best.size());

    bool end_flag = false;

    for(int x = best.size() + 1; x <= K; x++) {
        int t; i64 d;
        // 別の種類の寿司が来るまで取り出す
        do {
            end_flag = rest.size() == 0;
            if(end_flag) break;
            tie(d, t) = rest.top(); rest.pop();
        } while(best.count(t));
        if(end_flag) break;
        
        best[t] = d;
        pt += d - dust.top().first; dust.pop();
        ans = max<i64>(ans, pt + best.size() * best.size());
    }

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

Measured memory_bytes: 6640
#include <iostream>
#include <map>
using namespace std;
int main() {
  int n, a, answer=0;
  map<int, int> maps;
  cin >> n;
  for (int i = 0; i <= n-1; i++) {
    cin >> a;
    if (maps.find(a) == maps.end()) maps[a] = 1;
    else maps[a]++;
  }
  for (const auto& kv : maps) {
    if (kv.first < kv.second) answer += kv.second - kv.first;
    else if (kv.first > kv.second) answer += kv.second;
  }
  cout << answer << endl;
  return 0;
}


Measured memory_bytes: 4736
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <array>
#include <vector>
#include <functional>
#include <unordered_map> 
#include <map> 
#include <numeric>
#include <limits>
#include <utility>
#include <queue>
#include <random>
#include <bitset>
#include <memory>
using namespace std;
typedef long long LL;
//#define _USE_MATH_DEFINES

int main(void) {
	LL a, b, c, x, y, i = 1000000000000, j = 1000000000000, k = 1000000000000, l = 1000000000000, m = 1000000000000, x2, y2, n = 1000000000000;
	cin >> a >> b >> c >> x >> y;
	x2 = x; y2 = y;

	if (a > b) {
		i = ((2 * x)*c);
		if (y > x) {
			i += (y-x)*b;
		}
	} else {
		j = ((2 * y)*c);
		if (x > y) {
			j += (x-y)*a;
		}
	}

	k = (x2*a) + (y2*b);


	if (x2 < y2) {
		l = ((2 * x2)*c);
		l += (y2 - x2)*b;
	} else {
		m = ((2 * y2)*c);
		m += (x2 - y2)*a;
	}

	n = (max(x2, y2) * 2)*c;

	cout << min(i, min(j, min(k, min(l, min(m, n))))) << endl;


	
	return 0;
}


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

#define int long long

signed main() {
    int h, w; cin >> h >> w;
    vector<vector<char>> hw(h, vector<char>(w));

    for(int i = 0; i < h; i++) {
        for(int j = 0; j < w; j++) {
            cin >> hw[i][j];
        }
    }

    vector<vector<char>> dhw(2 * h, vector<char>(w));

    for(int i = 0; i < 2 * h; i++) {
        for(int j = 0; j < w; j++) {
            dhw[i][j] = hw[i / 2][j];
        }
    }

    for(int i = 0; i < 2 * h; i++) {
        for(int j = 0; j < w; j++) {
            cout << dhw[i][j];
        }
        cout << endl;
    }

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace  std;
typedef long long ll;
const int N = 110;
const int P = 1e9+7;
int f[N][N*N],n,k;

inline void add(int &x,int y){
	x=(x+y)%P;
}

int main(){
	scanf("%d%d",&n,&k);
	int ans = 1;
	for(int i = 1;i<n;i++) ans = 1ll*ans*(k+1)%P;
	ans = 1ll*ans*((1+k)*k/2)%P*n%P;
	f[n+1][0] =1;
	int up;
	//cout<<ans<<endl;
	for(int i = n;i>0;i--){
		up = (n-i)*k;
	//	cout<<up<<endl;
		for(int j = 0;j<=k;j++){
			if(j<=i)
				for(int w = 0;w<=up;w++){
					add(f[i][w+(w+j)/i],f[i+1][w]);
				}
			else 
				for(int w = 0;w<=up;w++){
					add(f[i][w],f[i+1][w]);
				}
			// f[i][   w + (w+j)/j]
		}
	}
	//cout<<f[2][0]<<' '<<f[2][1]<<' '<<f[2][2]<<endl;
	//cout<<f[1][0]<<' '<<f[1][1]<<' '<<f[1][2]<<' '<<f[1][3]<<' '<<f[1][4]<<endl;
	for(int i = 0;i<=n*k;i++) add(ans,-1ll*f[1][i]*i%P);
	ans = (ans+P)%P;
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 3968
N = int(input())
h = list(map(int, input().split()))

def jump(N, h):
  dp = [0]*(N+1)
  dp[1] = abs(h[1] - h[0])
  # dp[i]は足場iにたどり着く最小コストを表す
  for i in range(N-2):
    dp[i+2] = min(dp[i] + abs(h[i+2] - h[i]), dp[i+1] + abs(h[i+1] - h[i+2]))
  print(dp[N-1])

if __name__ == "__main__":
  jump(N, h)

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

int main(){
   int N, M, X;
   cin >> N >> M >> X;
   vector<int> A(M);
   for (int i=0; i<M; i++){
      cin >> A.at(i);
   }

   int cost_r=0;
   for (int i=X+1; i<N; i++){
      for (int j=0; j<M; j++){
         if (i == A.at(j)){
            cost_r++;
            break;
         }
      }
   }

   int cost_l=0;
   for (int i=X-1; i>0; i--){
      for (int j=0; j<M; j++){
         if (i == A.at(j)){
            cost_l++;
            break;
         }
      }
   }

   if (cost_l > cost_r)
      cout << cost_r << endl;
   else
      cout << cost_l << endl;

}



Measured memory_bytes: 256
n = int(input())
a = [int(x) for x in input().split()]
b = [int(x) for x in input().split()]
c = [int(x) for x in input().split()]

ans = sum(b)
for i in range(n-1):
    if a[i+1] - a[i] == 1:
        ans += c[a[i]-1]
print(ans)

Measured memory_bytes: 3064
import java.util.Scanner;

public class Main{
    public static void main(String[]arg){

        Scanner sc = new Scanner(System.in);

        while(true){
            int n = sc.nextInt();
            if(n == 0) break;
            int[] s = new int[n];

            int sum = 0;

            for(int i =0; i < n; i++){
                s[i] = sc.nextInt();
                sum = sum + s[i];
            }
            double ave = 0, var = 0;

            ave = sum / (double)n;

            double sum2 = 0;

            for(int k = 0; k < n; k++){
                sum2 = sum2 + (s[k] - ave) * (s[k] - ave);
            }

            var = sum2 / (double)n;

            System.out.printf("%.8f\n",Math.sqrt(var));

        }

    }
}


Measured memory_bytes: 31752
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> l_l;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
const int INF=1001001000;
const int mINF=-1001001000;
const ll LINF=1010010010010010000;
template<class T> inline bool chmin(T& a, T b) {
if (a > b) {
a = b;
return true;
}
return false;
}
template<class T> inline bool chmax(T& a, T b) {
if (a < b) {
a = b;
return true;
}
return false;
}
int main(){
    ll n,m,v,p;cin >> n >> m >> v >> p;
    vi a(n);
    rep(i,n) cin >> a[i];
    sort(a.begin(),a.end());
    int l=-1,r=n-1;
    while(r>l+1){
        int mid=(r+l)/2;
        vl b;
        ll base=a[mid]+m;
        rep(i,n){
            if(i!=mid) b.push_back(a[i]);
        }
        reverse(b.begin(),b.end());
        ll ok=0;
        int ng=0;
        rep(i,n-1){
            if(i<p-1) ok+=m;
            else if(base>=b[i]) ok+=min(m,base-b[i]);
            else ng=1;
        }
        if(ng){
            l=mid;
        }
        else if(ok>=m*(v-1)) r=mid;
        else l=mid;
        //cout << l << " " << r << endl;
    }
    cout << n-r << endl;
    return 0;
}

Measured memory_bytes: 2500
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<string.h>
#include<vector>
#include<algorithm>
#define ll long long
#define maxn 210000
using namespace std;

vector<ll>q[2];
ll x[maxn],y[maxn];
ll bit[100];
int n;

ll solve()//我擦。。这个归并太吊了
{
    ll ans=0;
    for(ll i=0;i<62;i++)
    {
        ll tot=0;
        q[0].clear();q[1].clear();
        for(ll j=1;j<=n;j++)
            q[(x[j]>>i)&1].push_back(x[j]);
        for(ll j=0;j<q[0].size();j++)
            x[++tot]=q[0][j];
        for(ll j=0;j<q[1].size();j++)
            x[++tot]=q[1][j];
        tot=0;
        q[0].clear();q[1].clear();
        for(ll j=1;j<=n;j++)
            q[(y[j]>>i)&1].push_back(y[j]);
        for(ll j=0;j<q[0].size();j++)
            y[++tot]=q[0][j];
        for(ll j=0;j<q[1].size();j++)
            y[++tot]=q[1][j];
        ll len1=1,len2=1,len3=1;
        ll limit1=1ll<<i;
        ll limit2=1ll<<(i+1);
        ll all=(1ll<<(i+1))-1;///这里加1LL
//        cout<<all<<" all"<<endl;
        ll sum=0;
//        for(int i=1;i<=tot;i++) cout<<x[i]<<" ";
//        cout<<endl;
//        for(int i=1;i<=tot;i++) cout<<(x[i]&all)<<" ";
//        cout<<endl;
//        for(int i=1;i<=tot;i++) cout<<y[i]<<" ";
//        cout<<endl;
        for(ll i=n;i>=1;i--)
        {
            while((((x[i]&all)+(y[len1]&all))<limit1) && (len1<=n)) len1++;//这里多加几个（）
            while((((x[i]&all)+(y[len2]&all))<limit2) && (len2<=n)) len2++;
            while(((x[i]&all)+(y[len3]&all)<limit1+limit2) && (len3<=n)) len3++;//cout<<(x[i]&all)<<" "<<(y[len3]&all)<<" "<<len3<<" "<<y[len3]<<" "<<(limit1+limit2)<<endl;
            sum+=n-(len1-1-len2+1+len3-1);
//            cout<<len1<<" "<<len2<<" "<<len3<<endl;
//            cout<<n-(len1-1-len2+1+len3-1)<<endl;
        }
//        cout<<sum<<" sum   "<<i<<endl;
        if(sum&1) ans+=bit[i];
    }
    return ans;
}

int main()
{
//    freopen("1003.txt","r",stdin);
    int cas;
   // scanf("%I64d",&cas);
    bit[0]=1;
    for(ll i=1;i<=61;i++)
    bit[i]=bit[i-1]*2;
   // for(ll ca=1;ca<=cas;ca++)
    {
        scanf("%lld",&n);
        for(ll i=1;i<=n;i++)
            scanf("%I64d",&x[i]);
        for(ll i=1;i<=n;i++)
            scanf("%I64d",&y[i]);
//        cout<<solve()<<endl;
       printf("%lld\n",solve()) ;
    }
}


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

int main(void) {
  int n, k;
  int tmp;
  cin >> n >> k;
  vector<int> v(200001, 0);
  for (int i = 0; i < n; ++i) {
    cin >> tmp;
    v[tmp]++;
  }
  sort(v.begin(), v.end());
  reverse(v.begin(), v.end());
  v.erase(v.begin(), v.begin() + k);
  int result = 0;
  for (const int &e : v) result += e;

  cout << result << endl;
  return 0;
}

Measured memory_bytes: 4012
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
using namespace std;

int main() {
    int n, m,x=0,y=0;
    cin >> n >> m;
    vector<int>    ac(n), pena(n);

    for (int i = 0; i < m; i++) {
        int iTmp = 0;
        string sTmp = "";
        cin >> iTmp >> sTmp;

        if (ac[iTmp-1])continue;
        if (sTmp == "AC") ac[iTmp - 1] = 1;
        else pena[iTmp - 1]+=1;
    }
    for (int i = 0; i < n; i++) {
        if (ac[i])x++;
        if (ac[i])y+= pena[i];
    }
    cout << x << " " << y;

    return 0;
}

Measured memory_bytes: 1024
//https://onlinejudge.u-aizu.ac.jp/challenges/sources/JOI/Prelim/0642?year=2018

#include <bits/stdc++.h>

using namespace std;

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

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

    int ans = 0;
    int cnt = 0;
    for (int i = 0; i <= n; ++i) {
        if (a[i] == 1) {
            cnt++;
        } else if (a[i] == 0) {
            ans = max(cnt + 1, ans);
            cnt = 0;
        }
    }

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

/*
 * 1が最高何回連続するか数える。サンプル3なら
 * 0 0 1 0 1 1 0
 * より2回なので答えは2+1=3
 */


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


int main()
{
	//freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
	ll n,a,b,i,s=0,g[100000];
	cin>>n>>a>>b;
	for (i=0;i<n;i++){
		cin>>g[i];
	}
	for (i=1;i<n;i++){
		s+=min(b,a*(g[i]-g[i-1]));
	}
	cout<<s;
	return 0;
}

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

#define pb push_back
#define ll long long
#define maxn 200005
#define fr(i,j,k) for(int i=j;i<k;i++)
#define f(n) fr(i,0,n)
#define f1(n) fr(i,1,n+1)
#define ms(i) memset(i,0,sizeof(i));
#define ms1(i) memset(i,-1,sizeof(i));
#define F first
#define S second
const int mod = 1e9+7;

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    ll n;
    cin >> n;
    if(n & 1){
        cout << 0 << '\n';
    }
    else{
        n /= 2;
        ll tot = 0;
        while(n){
            tot += n / 5;
            n /= 5;
        }
        cout << tot << '\n';
    }
}

Measured memory_bytes: 256
H, W, K = map(int, input().split())
dp = [[]]
for i in range(0, W):
	dp[0].append(0)
dp[0][0] = 1
for i in range(0, H):
	next = []
	for j in range(0, W):
		next.append(0)
	for j in range(0, 2**(W-1)):
		lst = []
		m = j
		for k in range(0, W-1):
			lst.append(m%2)
			m //= 2
		flag = True
		for k in range(0, W-2):
			if lst[k] == 1 and lst[k+1] == 1:
				flag = False
				break
		if flag:
			notswapped = []
			for k in range(0, W):
				notswapped.append(True)
			for k in range(0, W-1):
				if lst[k] == 1:
					next[k+1] += dp[-1][k]
					next[k] += dp[-1][k+1]
					notswapped[k] = False
					notswapped[k+1] = False
			for k in range(0, W):
				if notswapped[k]:
					next[k] += dp[-1][k]
	dp.append(next)
print(dp[H][K-1]%(10**9+7))

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

typedef long long ll;
typedef unsigned long long ull;
typedef double dd;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;

const int mx=1e6+11;
const double PI = acos(-1);
#define MOD 1000000007

#define nl '\n'
#define pb push_back
#define F first
#define S second
#define I insert
#define mp make_pair

#define sz(x) x.size()
#define tt int t; cin>>t; while(t--)
#define be(a) (a).begin(),(a).end()
#define rbe(a) (a).rbegin(),(a).rend()
#define mem(a,b) memset(a,b,sizeof(a))
#define yes cout<<"YES"<<nl
#define no cout<<"NO"<<nl

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

template < typename F, typename S >
ostream& operator << ( ostream& os, const pair< F, S > & p )
{
    return os << "(" << p.first << ", " << p.second << ")";
}

template < typename T >
ostream &operator << ( ostream & os, const vector< T > &v )
{
    os << "{";
    for(auto it = v.begin(); it != v.end(); ++it)
    {
        if( it != v.begin() )
            os << ", ";
        os << *it;
    }
    return os << "}";
}

template < typename T >
ostream &operator << ( ostream & os, const set< T > &v )
{
    os << "[";
    for(auto it = v.begin(); it != v.end(); ++it)
    {
        if( it != v.begin() )
            os << ", ";
        os << *it;
    }
    return os << "]";
}

template < typename T >
ostream &operator << ( ostream & os, const multiset< T > &v )
{
    os << "[";
    for(auto it = v.begin(); it != v.end(); ++it)
    {
        if( it != v.begin() )
            os << ", ";
        os << *it;
    }
    return os << "]";
}

template < typename F, typename S >
ostream &operator << ( ostream & os, const map< F, S > &v )
{
    os << "[";
    for(auto it = v.begin(); it != v.end(); ++it)
    {
        if( it != v.begin() )
            os << ", ";
        os << it -> first << " = " << it -> second ;
    }
    return os << "]";
}

#define dbg(args...) do {cerr << #args << " : "; faltu(args); } while(0)

void faltu ()
{
    cerr << endl;
}

template <typename T>
void faltu( T a[], int n )
{
    for(int i = 0; i < n; ++i)
        cerr << a[i] << ' ';
    cerr << endl;
}

template <typename T, typename ... hello>
void faltu( T arg, const hello &... rest)
{
    cerr << arg << ' ';
    faltu(rest...);
}


ll mul(ll a, ll b)
{
    return ((a%MOD)*(b%MOD))%MOD;
}
ll add(ll a, ll b)
{
    return ((a%MOD)+(b%MOD))%MOD;
}

void f()
{
    ll n,sum=0;
    cin>>n;
    ll a[n],par[n];
    cin>>a[0];
    par[0]=a[0];
    for(int i=1; i<n; i++)
    {
        cin>>a[i];
        par[i]=add(a[i],par[i-1]);
    }
    for(int i=0;i<n-1;i++)
    {
      sum+=mul(a[i+1],par[i]);
      sum%=MOD;
    }
    cout<<sum<<nl;
}

int main()
{
    su;
    f();
    return 0;
}


Measured memory_bytes: 6752
#include<cstdio>
const int N=3000+10;
int n;
double d,f[N][N],ans;
int main()
{
	scanf("%d",&n);
	f[0][0]=1.00;
	for(int i=1;i<=n;i++)
	{
		scanf("%lf",&d);
		f[i][0]=f[i-1][0]*d;
		f[0][i]=f[0][i-1]*(1.00-d);
		for(int j=1;j<i;j++)
			f[j][i-j]=f[j-1][i-j]*d+f[j][i-j-1]*(1.00-d);
	}
	for(int i=n/2+1;i<=n;i++)ans+=f[i][n-i];
	printf("%.10lf",ans);
	return 0;
}


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

using namespace std;
#define rep(i, n) for (ll i = 0; i < (n); ++i)
//#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) ll(x.size())
typedef long long ll;
//typedef pair<int, int> P;
//typedef pair<ll, ll> P;
//const double INF = 1e10;
//const ll INF = 10e15;
const ll MINF = -10e10;
const int INF = INT_MAX;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)


//ifstream myfile("C:\\Users\\riku\\Downloads\\0_00.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);

//typedef priority_queue<P, vector<P>, greater<P>> PQ_ASK;
const int mod = 1000000007;
typedef pair<int, char> P;


int main() {
    string s;
    cin >> s;
    int ans = 0;
    for (int i = 0; i < 3; i++) {
        if (s[i] == '1') ans++;
    }

    cout << ans << endl;

}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
inline ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
inline ll lcm(ll a, ll b) { return a / gcd(a, b)*b; }
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T>& V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> >& Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T>& mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }
template<typename T>vector<T> make_v(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>auto make_v(size_t a,Ts... ts){return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));}
template<typename T,typename V> typename enable_if<is_class<T>::value==0>::type fill_v(T &t,const V &v){t=v;}
template<typename T,typename V> typename enable_if<is_class<T>::value!=0>::type fill_v(T &t,const V &v){for(auto &e:t) fill_v(e,v);}
/*
 <url:>
 問題文============================================================
 =================================================================
 解説=============================================================
 ================================================================
 */

template<class Type>
Type solve(Type res = Type()){
    string s,t; cin >> s >> t;
    
    map<char,bool> mp;
    for(auto c:s) mp[c] = true;
    for(auto c:t){
        if(mp.count(c)) continue;
        return -1;
    }
    
    int slen = (int)s.length();
    vector<vector<int>> vs(slen+1,vector<int>(26,-INF));
    for(int i = slen-1; i >= 0; i--){
        for(int j = 0; j < 26;j++){
            vs[i][j] = vs[i+1][j] + 1;
        }
        vs[i][s[i]-'a'] = 1;
    }
    // cout << vs << endl;
    
    
//    for(int j = 0; j < 26;j++){
//        cout << (char)(j+'a') << " : ";
//        for(int i = 0; i <= slen;i++){
//            if(vs[i][j] <= 0) cout << "INF ";
//            else cout <<  vs[i][j] << " ";
//        }
//        cout << endl;
//    }
//    cout << endl;
    res = 0;
    int now = 0;
    int idx = 0;
    while(idx < t.length()){
//        cout << idx << endl;
//        cout << now << " " << res << endl;
        char c = t[idx];
        c -= 'a';
        if(vs[now][c] <= 0){
            res += s.length() - now;
            now = 0;
            continue;
        }else{
            res += vs[now][c];
            now += vs[now][c];
            idx++;
        }
    }
    return res;
}
int main(void) {
    cin.tie(0); ios_base::sync_with_stdio(false);
    // solve(0);
    cout << fixed << setprecision(15) << solve<ll>() << endl;
    return 0;
}


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

int main() {
  int num,number[10000],t=0;
  double weight,height,BMI[10000];
  while(scanf("%d,%lf,%lf",&num,&weight,&height) == 3) {
    BMI[t] = weight / (height * height);
    number[t] = num;
    t++;
  }
  for(int i=0;i<t;i++) {
    if(BMI[i] >= 25) {
      cout << number[i] <<endl;
    }
  }
}

Measured memory_bytes: 0
#include <stdio.h>
#include <algorithm>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define INF (1<<28)

int n, m, a[64], b[64], c[64];
int f[64][10][10], dp[64][64][10];

int main() {
    scanf("%d%d", &n, &m);
    rep (i, n) scanf("%d%d%d", a+i, b+i, c+i);
    rep (k, 64) rep (x, 10) rep (y, 10) {
        f[k][x][y] = c[k];
        rep (i, x+1) rep (j, y+1) if (1 <= i+j && i+j <= 8) {
            f[k][x][y] = max(f[k][x][y], a[k]*j + b[k]*i);
        }
    }
    rep (i, 64) rep (j, 64) rep (k, 10) dp[i][j][k] = -INF;
    dp[0][0][0] = 0;
    rep (k, n) rep (x, m+1) rep (i, min(8, x)+1) if (dp[k][x][i] > -INF) {
        rep (j, min(8, m-x)+1) {
            dp[k+1][x+j][j] = max(dp[k+1][x+j][j], dp[k][x][i]+f[k][i][j]);
        }
    }
    int ans = -INF;
    rep (x, m+1) rep (i, 10) ans = max(ans, dp[n][x][i]);
    printf("%d\n", ans);
    return 0;
}

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

vector<vector<int>> to(200005);
vector<ll> ans;

void dfs(int v,int p = -1){
    for(int u : to.at(v)){
        if(u == p)continue;
        ans.at(u) += ans.at(v);
        dfs(u,v);
    }
}

int main(){
    int n,q;
    cin >> n >> q;
    // vector<vector<int>> AB(n);
    rep(i,n-1){
        int a,b;
        cin >> a >> b;
        a--;b--;
        to.at(a).push_back(b);
        to.at(b).push_back(a);
    }
    // vector<ll> PX(n,0);
    ans.resize(n);
    rep(i,q){
        int p,x;
        cin >> p >> x;
        p--;
        ans.at(p) += x;
    }
    dfs(0);
    rep(i,n){
        cout << ans.at(i) << " ";
    }
    cout << endl;
    return 0;
}

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

int bubbleSort(int A[],int N){
  int sw=0;
  bool flag=1;
  for(int i=0; flag; i++){
    flag=0;
    for(int j=N-1; j>=i+1; j--){
      if(A[j]<A[j-1]){
        swap(A[j],A[j-1]);
        flag=1;
        sw++;
      }
    }
  }
  return sw;
}

int main(){
  int A[100],N,sw;
  cin>>N;
  for(int i=0; i<N; i++) cin>>A[i];
  sw=bubbleSort(A,N);
  for(int i=0; i<N; i++){
    if(i) cout<<" ";
    cout<<A[i];
  }
  cout<<endl;
  cout<<sw<<endl;
  return 0;
}


Measured memory_bytes: 3100
#include <stdio.h>
int main(void)
{
    int a,b;
    scanf("%d %d",&a,&b);
    int c=b;
    while(c!=0)
    {
        c=c/10;
        a*=10;
    }
    a=a+b;
    int aa=sqrt(a);
    aa=aa*aa;
    if(a==aa)printf("Yes");
    else printf("No");
}


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


int main()
{
    double a,b,c,d,e,f,q1,q2,q3,q4,mx=0;
    LL flag,ans1=0,ans2=0,i,j,k,l;
    cin>>a>>b>>c>>d>>e>>f;
    for( i=0;i<=100;i++)
    {
        if(i*100*a>f) break;
        for( j=0;j<=100;j++)
        {
            if(i*100*a+j*100*b>f) break;
            for( k=0;k<=100;k++)
            {
                if(i*100*a+j*100*b+k*c>f||e*(i*a+j*b)<k*c) break;
                for( l=0;l<=100;l++)
                {
                    if(i*100*a+j*100*b+k*c+l*d>f||e*(i*a+j*b)<k*c+l*d) break;
                    else
                    {
                        if(100*(k*c+l*d)>mx*(k*c+l*d+i*100*a+j*100*b))
                        {
                            mx=100*(k*c+l*d)/(k*c+l*d+i*100*a+j*100*b);
                            ans1=i*100*a+j*100*b+(k*c+l*d);
                            ans2=(k*c+l*d);
                        }
                    }
                }
            }
        }
    }
    //cout<<mx<<endl;
    //cout<<i<<" "<<j<<" "<<k<<" "<<l<<endl;
    if(mx==0) ans1=100*a;
    cout<<ans1<<" "<<ans2;
    return 0;
}


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

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

using namespace std;

int main(){
  string s,t;cin>>s>>t;

  if(s==t){
    cout<<"Yes";return 0;
  }
  rep(i,s.size()){
    s = s.substr(1,s.size()-1)+s[0];
//    cout<<s<<endl;
    if(s==t){
      cout<<"Yes";return 0;
    }
  }

  cout<<"No";
  return 0;
}

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

int main()
{
	int n;
	cin >> n;
	int pt = 0;
	int px = 0;
	int py = 0;
	bool yes = true;
	for (int i = 1; i <= n; ++i) 
	{
		int t, x, y;
		cin >> t >> x >> y;

		int difft = t - pt;
		int diffxy = abs(x - px + y - py);
		if (difft < diffxy || (difft - diffxy) % 2 != 0) {
			yes = false;
		}


		pt = t;
		px = x;
		py = y;
	}

	if (yes) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}

	return 0;
}

Measured memory_bytes: 256
N = input()
N = str(N)
book = ""
if N[-1] == "3":
    book = "bon"
elif  N[-1] == "0" or N[-1] == "1" or N[-1] == "6" or N[-1] == "8":
    book = "pon"
else:
    book = "hon"
print(book)


Measured memory_bytes: 8964
import java.util.Scanner;
public class Main {
	int T;
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		Main tr = new Main();
		tr.test(sc);
		sc.close();
	}
	
	void test(Scanner sc){
		T = sc.nextInt();
		long out = Long.MAX_VALUE;
		for (int i = 1; i <= T/2; i++) {
			int b=T-i;
			String s = ""+b;
			s = i+s;
			long sum=0;
			for (int j = 0; j < s.length(); j++) {
				sum+=s.charAt(j)-'0';
			}
			out=out>sum?sum:out;
		}
		System.out.println(out);
	}
}


Measured memory_bytes: 34980
K, A, B = map(int, input().split())

bs = 1
yen = 0
if B - A < 2:
    bs = K + 1
else:
    if K < A + 1:
        bs = K + 1
    else:
        #print(A)
        #print((B - A) * ((K - A + 1) // 2) )
        #print((K - A + 1) % 2)
        bs = A + (B - A) * ((K - A + 1) // 2) + ((K - A + 1) % 2)

print(bs)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp> 
//#include <ext/pb_ds/tree_policy.hpp>
//#include <functional> // for less
//using namespace __gnu_pbds;
using namespace std;
typedef long long  L;

#define max_(x, y) (((x) > (y)) ? (x) : (y))
#define min_(x, y) (((x) < (y)) ? (x) : (y))
#define ___ ios_base::sync_with_stdio(false);cin.tie(NULL);
#define Mx 200001
#define inf 1e15
const L MOD = 1e9+7;
const double pi = 2 * acos (0.0);

/*------------------------------Graph Moves----------------------------*/
//const int fx[]={+1,-1,+0,+0};
//const int fy[]={+0,+0,+1,-1};
//const int fx[]={+0,+0,+1,-1,-1,+1,-1,+1};   // Kings Move
//const int fy[]={-1,+1,+0,+0,+1,+1,-1,-1};  // Kings Move
//const int fx[]={-2, -2, -1, -1,  1,  1,  2,  2};  // Knights Move
//const int fy[]={-1,  1, -2,  2, -2,  2, -1,  1}; // Knights Move
/*---------------------------------------------------------------------*/


//typedef tree<L,null_type,less<L>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;

L a1,a2,a3,b1,b2,b3,c,c1,c2,c3,d,d1,d2,d3,d4,d5,e1,e2,e3,f,h,k,l,m,n,m1,m2,n1,n2,o,p,p1,p2,p3,p4,
q,q1,q2,q3,q4,r,s,t,u,v,x,y,z,sum,mx=-inf,mn=inf,flg,flg1,flg2,id1,id2,id3,id4,lim;

void solve(){
  double dd=((double)n)/3.0;
  dd=(dd*dd*dd);
  printf("%.10f\n",dd);
}
int main()
{
    scanf("%lld",&n);
    solve();
    return 0;
}
/// empty() lld I64d push_back() top() pop() insert() upper_bound() lower_bound() memset() max() min() scanf continue


Measured memory_bytes: 3788
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Convert;
using static System.Math;
//using static System.Globalization.CultureInfo;

class Program
{
    static void Main(string[] args)
    {
        var nw = Input.ar;
        var wv = Input.twodim(nw[0]);
        var dic = new Dictionary<int, List<int>>();
        for (var i = wv[0][0]; i <= wv[0][0]+3; i++)
            dic[i] = new List<int>();
        for (var i = 0; i < nw[0]; i++)
            dic[wv[i][0]].Add(wv[i][1]);
        var list = dic.Values.Select(ls => ls.OrderByDescending(c => c).ToList()).ToArray();
        WriteLine(dfs(list,0, 0, wv[0][0], nw[1]));
    }
    private static long dfs(List<int>[] list, int index, long nowwei,long wei,long limit)
    {
        if (index > 3) return 0;
        var val = dfs(list, index + 1, nowwei, wei, limit);
        var v = 0L;
        var w = 0L;
        for (var i = 0; i < list[index].Count; i++)
        {
            v += list[index][i];
            w += index + wei;
            if (w + nowwei > limit) break;
            var p = dfs(list, index + 1, nowwei + w, wei, limit);
            val = Max(val, v + p);
        }
        
        return val;
    }
}

public class Input
{
    public static string read => ReadLine();
    public  static int[] ar => Array.ConvertAll(read.Split(' '), int.Parse);
    public  static int num => ToInt32(read);
    public static long[] arL => Array.ConvertAll(read.Split(' '), long.Parse);
    public  static long numL => ToInt64(read);
    public static int[][] twodim(int num)
        => Enumerable.Repeat(0, num).Select(v => ar).ToArray();
    public static long[][] twodimL(int num)
        => Enumerable.Repeat(0, num).Select(v => arL).ToArray();
    public  const string Alfa = "abcdefghijklmnopqrstuvwxyz";
    public  const int MOD = 1000000007;
}


Measured memory_bytes: 13652
def dfs(f):
    if vis[f] == 1: return
    vis[f] = 1
    for t in V[f]:
        if f!=a or t!=b: dfs(t)

n, m = map(int, input().split())
E = [[*map(lambda x: int(x)-1, input().split())] for _ in range(m)]
V = [[] for _ in range(n)]
for a, b in E: V[a].append(b); V[b].append(a)
ans = 0
for a, b in E:
    vis = [0]*n
    dfs(a)
    if vis[b] == 0: ans += 1
print(ans)


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

ll f(ll x){
  if(x==1)return 1;
  return 2*f(x/2)+1;
}

int main() {
  ll h;cin>>h;
  cout<<f(h)<<endl;
}

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

struct Node{
	int v, id;
};

const int N = 2e5 + 10;

set <Node> s;
int a[N], used[N]; 

bool operator <(Node x, Node y){
	if (x.v == y.v) return x.id < y.id;
	return x.v < y.v;
}

int main(){
	int n, num, ans, req;
	set <Node>::iterator it;
	scanf("%d",&n);
	for (int i = 1; i <= n; i++) scanf("%d",&a[i]);
	sort(a + 1, a + n + 1);
	for (int i = 1; i <= n; i++) s.insert({a[i], i});
	memset(used, 0, sizeof(used));
	ans = 0;
	for (int i = n; i >= 1; i--){
		if (used[i]) continue;
		for (int j = 30; j >= 1; j--){
			req = (1 << j) - a[i];
			it = s.lower_bound({req, 0});
			if (it == s.end()) continue;
			if (a[i] == req && it->id == i){
				it++;
				if (it == s.end()) continue;
			}
			if (it->v == req){
				ans++;
				used[it->id] = 1;
				s.erase({a[i], i});
				s.erase(it);
				break;
			}
		}
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 11136
// C - Monsters Battle Royale

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int INF = 2147483647;
// const ll INF = 9223372036854775807;
// const ll MOD = 1e9 + 7;

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

	int ans;

	cin >> ans;

	for (int i=1; i<N; i++) {
		int A;
		cin >> A;
		ans = __gcd(ans, A);
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 3676
#include <bits/stdc++.h>
#define F first
#define S second
#define ld long douroote
#define pb push_back
#define sz size
#define ll long long
#define ull unsigned long long
#define INF 0x7f7f7f7f
#define sc(a) scanf("%d",&a)
#define scll(a) scanf("%lld",&a)
#define scd(a) scanf("%lf",&a)
#define scc(a) scanf(" %c",&a)
#define scs(a) scanf(" %s",a)
#define me(a,b) memset(a,b,sizeof a)
#define all(a) a.begin(),a.end()
#define allr(a,n) a,a+n
#define loop(a,s,e) for(ll a=s;a<=e;a++)
#define read_arr(a,s,n) for(int i=s;i<n+s;i++){sc(a[i]);}
#define read_arr_ll(a,s,n) for(int i=s;i<n+s;i++){scll(a[i]);}
#define err(a,s) cerr<<a<<s;
#define err_arr(a,s,n) for(int i=s;i<n+s;i++){cerr<<a[i]<<" ";}cerr<<endl;
#define prtll(x) printf("%lld",x);
#define prt(x) printf("%d",x);
using namespace std;
const int N=1e5+10;
int n,m,a[N],k;
bool vis[N];
bool mem[N];
bool dp(int h){
if(h==0){return 0;}
if(h<0){return 1;}
if(vis[h]){return mem[h];}
bool &ret=mem[h];
int sum=0;
loop(i,1,n){
sum+=dp(h-a[i]);
}
ret=(sum<n);
vis[h]=1;
return ret;
}
int main(){
sc(n);sc(k);
loop(i,1,n){sc(a[i]);}
printf(dp(k)?"First\n":"Second\n");
return 0;
}
/**
**/


Measured memory_bytes: 5120
from itertools import combinations, permutations

n = int(input())
balls = []
cost = n
for _ in range(n):
    x, y = map(int, input().split())
    balls.append((x, y))

for b1, b2 in combinations(balls, 2):
    p, q = b1[0] - b2[0], b1[1] - b2[1]
    if p != 0 or q != 0:
        sub = 0
        for b3, b4 in permutations(balls, 2):
            dx, dy = b3[0] - b4[0], b3[1] - b4[1]
            if dx == p and dy == q:
                sub += 1
        cost = min(cost, n - sub)

print(max(cost, 1))


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(a,n) for (ll a = 0; a < (n); ++a)
using namespace std;
using ll = long long;
typedef pair<double,double> P;
typedef pair<ll,P> PP;
//typedef vector<vector<P> > Graph;
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; }
const ll INF = 1e18;


//抽象化したセグメント木
//SegmentTree<T>(n,fx,ex):モノイド(集合T,二項演算fx, 単位元ex)についてサイズnで構築
template<typename T>
struct  SegmentTree{
    using FX = function<T(T,T)>;
    int n;
    FX fx;
    const T ex;
    vector<T>node;

    //初期化(datは単位元exで初期化する)
    SegmentTree(int n_, FX fx_, T ex_) : n(),fx(fx_),ex(ex_),node(n_*4,ex_){
        int x = 1;
        while(n_ > x)x*=2;
        n = x;
    }
    
    void set(int i, T x){//最下段の要素の構築
        node[i+n-1]=x;
    }

    void build(){
        for(int i=n-2;i>=0;i--){
            node[i]=fx(node[2*i+1],node[2*i+2]);
        }
    }

    //i番目の要素の更新,計算量O(log(n))
    void update(int i, T x){
        i += n-1;
        node[i]=x;
        while(i>0){
            i=(i-1)/2;
            node[i]=fx(node[i*2+1],node[i*2+2]);
        }
    }

    //query(a,b)は[a,b)全てにfxを作用させた値の取得,計算量はO(log(n))
    T query(int a,int b){
        return query_sub(a,b,0,0,n);
    }

    T query_sub(int a,int b,int k,int l,int r){
        if(r<=a || b<=l){//区間が全くかぶらない時は単位元を返す
            return ex;
        }
        if(a<=l && r <= b){//区間を完全に覆っている時
            return node[k];
        }
        T vl = query_sub(a,b,k*2+1,l,(l+r)/2);
        T vr = query_sub(a,b,k*2+2,(l+r)/2,r);
        return fx(vl,vr);
    }

    T operator[](int i){
        return node[i+n-1];
    }

    void print(){
        for(int i=0;i<n;i++){
            cout << (*this)[i];
            if(i != n-1)cout << ',';
        }
        cout << endl;
    }
};

/*関数の定義にはラムダ式を使う
RMQなら
auto fx = [](int x1,int x2) -> int{
    return min(x1,x2);
};
int ex = numeric_limits<int>::max();
SegmentTree<int> rmq(n,fx,ex);

のように使う*/




//入力
ll n,q;
string s;


int main(){
    cin >> n;
    cin >> s;
    cin >> q;
    auto fx = [](ll x1,ll x2) -> ll{
        return x1+x2;
    };
    ll ex = 0;
    vector<SegmentTree<ll> >vec(26,SegmentTree<ll>(n,fx,ex));
    rep(i,n){
        int now = s[i]-'a';
        vec[now].update(i,1);
    }
    rep(j,q){
        int que;
        cin >> que;
        if(que==1){
            ll i;
            char c;
            cin >> i >> c;
            i--;
            int now = s[i]-'a';
            vec[now].update(i,0);
            s[i]=c;
            int nx = s[i]-'a';
            vec[nx].update(i,1);
        }
        else{
            ll l,r;
            cin >> l >> r;
            l--;r--;
            ll ans = 0;
            rep(i,26){
                if(vec[i].query(l,r+1)>0){
                    ans++;
                }
            }
            cout << ans << endl;
        }
    }



    return 0;
}

Measured memory_bytes: 425836
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Math;

class AtCoder{
  public static void Main(){

    int n = int.Parse(Console.ReadLine());
    int[] s = new int[n];
    int total = 0;
    int m =100;

    for (int i = 0; i < n; i++){
        s[i] = int.Parse(Console.ReadLine());
        total += s[i];
        if(s[i] < m && s[i] % 10 != 0){
            m = s[i];
        }
    }

    if(total % 10 != 0) Console.WriteLine(total);
    else if(m % 10 != 0) Console.WriteLine(total - m);
    else Console.WriteLine(0);
  }
}


Measured memory_bytes: 13140