akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <array>
#include <assert.h>
#include <bitset>
#include <chrono>
#include <cmath>
#include <complex>
#include <cstring>
#include <functional>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <istream>

#include <map>
#include <math.h>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#include <stdint.h>

namespace asl
{
    template <typename T>
    using vec = std::vector<T>;

    template <typename T>
    std::istream &operator>>(std::istream &is, std::vector<T> &vec)
    {
        for (auto &value : vec)
            is >> value;
        return is;
    }

    template <typename T>
    struct fenwick
    {
        int n;
        std::vector<T> f;
        fenwick(int n) : n(n), f(n + 1) {}

        T query(int p)
        {
            T ret = 0;
            for (++p; p > 0; p -= p & -p)
                ret += f[p];
            return ret;
        }

        void update(int p, T x)
        {
            for (++p; p <= n; p += p & -p)
                f[p] += x;
        }

    };

    template <typename T>
    using BIT = fenwick<T>;
} 

#include <experimental/optional>

#include <tuple>

namespace asl
{
    typedef long long i64;
    
} 

#include <random>

#include <utility>

#define endl '\n'

using namespace std;
using namespace asl;

void solve()
{
    int n, q;
    cin >> n >> q;

    vec<int> val(n);
    cin >> val;

    BIT<i64> bit(n);

    for (int i = 0; i < n; ++i)
        bit.update(i, val[i]);

    while (q--)
    {
        int t;
        cin >> t;

        if (t == 0)
        {
            int p, x;
            cin >> p >> x;
            bit.update(p, x);
        }
        else
        {
            int l, r;
            cin >> l >> r;
            cout << bit.query(r - 1) - bit.query(l - 1) << endl;
        }
    }
}

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

    int t = 1;

    for (int i = 1; i <= t; ++i)
    {
        solve();
    }

    return 0;
}




Measured memory_bytes: 10208
#include <bits/stdc++.h>
using namespace std;
template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}
#ifdef __LOCAL
#define debug(x) cerr << __LINE__ << ": " << #x << " = " << (x) << '\n'
#define debugArray(x, n)                                      \
  cerr << __LINE__ << ": " << #x << " = {";                   \
  for (long long hoge = 0; (hoge) < (long long)(n); ++(hoge)) \
    cerr << ((hoge) ? "," : "") << x[hoge];                   \
  cerr << "}" << '\n'
#define debugMatrix(x, h, w)                                         \
  cerr << __LINE__ << ": " << #x << " =\n";                          \
  for (long long hoge = 0; (hoge) < (long long)(h); ++(hoge)) {      \
    cerr << ((hoge ? " {" : "{{"));                                  \
    for (long long fuga = 0; (fuga) < (long long)(w); ++(fuga))      \
      cerr << ((fuga ? ", " : "")) << x[hoge][fuga];                 \
    cerr << "}" << (hoge + 1 == (long long)(h) ? "}" : ",") << '\n'; \
  }
#else
#define debug(x) (void(0))
#define debugArray(x, n) (void(0))
#define debugMatrix(x, h, w) (void(0))
#endif

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(0);
  int N;
  cin >> N;
  vector<int> tree[N];
  for (int i = 0; i < N - 1; i++) {
    int a, b;
    cin >> a >> b;
    a--, b--;
    tree[a].push_back(b);
    tree[b].push_back(a);
  }
  int color[N];
  int cnt[2] = {0, 0};
  function<void(int, int)> dfs = [&](int v, int p) {
    if (p == -1)
      color[v] = 0;
    else
      color[v] = !color[p];
    cnt[color[v]]++;
    for (int u : tree[v])
      if (u != p) dfs(u, v);
  };
  dfs(0, -1);
  if (cnt[0] < cnt[1]) {
    for (int i = 0; i < N; i++) color[i] = !color[i];
    swap(cnt[0], cnt[1]);
  }
  debug(cnt[0]);
  debug(cnt[1]);
  debugArray(color, N);
  int p[N];
  fill(p, p + N, -1);
  int id[3] = {3, 1, 2};
  if (cnt[1] <= N / 3) {
    for (int i = 0; i < N; i++) {
      if (color[i]) {
        p[i] = id[0], id[0] += 3;
      }
    }
  }
  for (int i = 0; i < N; i++) {
    if (p[i] != -1) continue;
    if (id[color[i] + 1] <= N)
      p[i] = id[color[i] + 1], id[color[i] + 1] += 3;
    else if (id[0] <= N)
      p[i] = id[0], id[0] += 3;
    else
      p[i] = id[!(color[i]) + 1], id[!(color[i]) + 1] += 3;
  }
  for (int i = 0; i < N; i++) cout << (i ? " " : "") << p[i];
  cout << '\n';
  return 0;
}


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

typedef int_fast32_t int32;
typedef int_fast64_t int64;

const int32 inf = 1e9+7;
const int32 MOD = 1000000007;
const int64 llinf = 1e18;

#define YES(n) cout << ((n) ? "YES\n" : "NO\n"  )
#define Yes(n) cout << ((n) ? "Yes\n" : "No\n"  )
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE\n" : "IMPOSSIBLE\n"  )
#define ANS(n) cout << (n) << "\n"
#define REP(i,n) for(int64 i=0;i<(n);++i)
#define FOR(i,a,b) for(int64 i=(a);i<(b);i++)
#define FORR(i,a,b) for(int64 i=(a);i>=(b);i--)
#define all(obj) (obj).begin(),(obj).end()
#define rall(obj) (obj).rbegin(),(obj).rend()
#define fi first
#define se second
#define pb(a) push_back(a)
typedef pair<int32,int32> pii;
typedef pair<int64,int64> pll;

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

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  map<string,int32> cnt;
  int32 n;
  cin >> n;
  REP(i,n){
    string s;
    cin >> s;
    cnt[s]++;
  }
  cout << "AC x " << cnt["AC"] << endl;
  cout << "WA x " << cnt["WA"] << endl;
  cout << "TLE x " << cnt["TLE"] << endl;
  cout << "RE x " << cnt["RE"] << endl;
  return 0;
}

Measured memory_bytes: 3664
#include <iostream>
using namespace std;
#include <algorithm>
#define ll long long
ll a[100005],sum[100005],jc[100005];
const ll mod=1e9+7;
ll app(ll a,ll b)
{
	return ((a%mod)*(b%mod))%mod;
}
ll ksm(ll a,ll b)
{
	ll ret=1;
	while(b)
	{
		if(b%2==1)ret=app(ret,a);
		a=app(a,a);
		b/=2;
	}
	return ret;
}
ll C(ll a,ll b)
{
	if(b==0)return 1;
	return app(jc[a],app(ksm(jc[b],mod-2),ksm(jc[a-b],mod-2)));
}
int main()
{
	int n,k;
	scanf("%d%d",&n,&k);
	jc[0]=1;
	for(int i=1;i<=n;i++)
	jc[i]=app(jc[i-1],i);

	for(int i=1;i<=n;i++)scanf("%lld",&a[i]);
	sort(a+1,a+n+1);
	for(int i=1;i<=n;i++)
	sum[i]=sum[i-1]+a[i];
	ll ans=0;
	for(int t=k;t<=n;t++)
	{
		ll len=t-1;
		ll now=(-sum[n-len]+sum[n]-sum[len])%mod;
		//cout<<now<<" "<<C(t-2,k-2)<<endl;
		ans=(ans%mod+app(C(t-2,k-2),now)%mod)%mod;
	
	}
	cout<<ans;
}

Measured memory_bytes: 2560
#include <cstdio>

int main () {
	int h=0,m=0,s=0;
	scanf("%d",&s);
	m+=s/60;
	s%=60;
	h+=m/60;
	m%=60;
	printf("%d:%d:%d\n",h,m,s);
	return 0;
}


Measured memory_bytes: 2664
N = int(input())
from collections import defaultdict
d = defaultdict(int)
for _ in range(N):
  d[input()] += 1

print('AC x %d' % d['AC'])
print('WA x %d' % d['WA'])
print('TLE x %d' % d['TLE'])
print('RE x %d' % d['RE'])

Measured memory_bytes: 9452
#include <bits/stdc++.h>
using namespace std;
#define ff first
#define ss second
#define pb push_back
#define debug(val) cerr << "The value of " << #val << " is = " << val << '\n';
typedef long long ll;
typedef unsigned long long ull;
const ll mod = 1e9 + 7;
const ll inf = 922337203685477;
const ll mininf = -922337203685477;
const ll nax = 0;

ll x, y;

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

	cin >> x >> y;
	for(ll i = 0; i <= x; i++){
		if(i * 4 + (x - i) * 2 == y){
			cout << "Yes" << '\n';
			return 0;
		}
	}
	cout << "No" << '\n';
}


Measured memory_bytes: 3608
n = int(input())
a = [int(i) for i in input().split()]

b = [0 for i in range(n)]
ans = 0
for i in range(n-1, -1, -1):
    if a[i] == 1:
        cnt = 0
        for j in range(n//(i+1), 1, -1):
            cnt += b[j*(i+1)-1]
        if cnt%2 == 0:
            b[i] = 1
            ans += 1
    else:
        cnt = 0
        for j in range(n//(i+1), 1, -1):
            cnt += b[j*(i+1)-1]
        if cnt%2 == 1:
            b[i] = 1
            ans += 1
print(ans)
for i in range(n):
    if b[i] == 1:
        print(i+1)

Measured memory_bytes: 7276
main = do
    ns <- getLine >>= return . map read . words
    let n = ns !! 0
    let d = ns !! 1
    xys <- mapM getPoints [1..n]
    let count = length $ filter (\x -> x <= d * d) $ map (\(x,y) -> x*x + y*y) xys
    print count

getPoints _ = do
    ns <- getLine >>= return . map read . words
    let x = ns !! 0
    let y = ns !! 1
    return (x,y)

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

#include <math.h>
#include <stdlib.h>


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

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

// const int INF = 1001001001;
// long long max => LLONG_MAX

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    
    int n; cin >> n;
    vector<ll> a(n);

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

    ll ans = LLONG_MAX;
    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: 3456
#include <bits/stdc++.h>

#define rep(i, n) for(int i = 0; i<(n); i++)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;

const int MOD = 1000000007;

int main() {
    int N;
    long long K;
    cin >> N >> K;
    vector<int> a(N);
    vector<int> f(N);
    rep(i, N) cin >> a[i];
    rep(i, N) cin >> f[i];
    sort(a.begin(), a.end());
    sort(f.rbegin(), f.rend());

    long long l = -1;
    long long r = 1e12;
    while (l + 1 < r) {
        long long c = (l + r) / 2;
        bool ok = [&] {
            long long s = 0;
            rep(i, N) {
                s += max(0ll, a[i] - c / f[i]);
            }
            return s <= K;
        }();
        if (ok) r = c; else l = c;
    }

    cout << r << endl;
}

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

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

    vector<int> a(n);
    rep(i,n) cin >> a[i];

    int ans = 0;

    for(int left = 0; left <= min(n,k); left++){ //left 個とる
        for(int right = 0; right <= min(n - left, k - left); right++){ //left 個取る時に、right個とる
            int cnt = k - (left + right);
            int sum = 0;
            priority_queue<int, vector<int>, greater<>> que;
            for(int i = 0; i < left; i++){
                que.push(a[i]);
                sum += a[i];
            }

            for(int j = n - 1; j > (n - 1) - right; j--){
                que.push(a[j]);
                sum += a[j];
            }

            while(!que.empty() && que.top() < 0 && cnt > 0){
                int x = que.top();
                que.pop();
                sum -= x;
                cnt--;
            }
            ans = max(ans,sum);
        }
    }
    cout << ans << endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef pair<int,int> P;
 
const int INF = 1e9;
const int mod = 1e9+7;
const double EPS = 1e-10;
const double PI = acos(-1.0);

int main()
{
    string n;
    cin >> n;
    cout << ((n[0] == n[1] && n[1] == n[2]) || (n[1] == n[2] && n[2] == n[3]) ? "Yes" : "No") << endl; 
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <map>
#include <numeric>
#include <queue>
#include <string>
#include <vector>

const int MOD = 1000000007;

int main(){
    int s;
    std::cin >> s;

    std::vector<int> dp(s + 1);
    dp[0] = 1;

    for (int i = 3; i <= s; i++)
    {
        dp[i] = (dp[i - 3] + dp[i - 1]) % MOD;
    }
    
    std::cout << dp[s] << std::endl;

    return 0;
}

Measured memory_bytes: 3588
// I SELL YOU...! 
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<chrono>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
signed main(){
  ll n,a,b;
  cin >> n >> a >> b;
  if(a%2==b%2){
    ll dis = b-a;
    cout << dis/2<<endl;
  }else{
    ll ans;
    ll ta,tb;

    ta = 1;
    tb = b-a;
    ans = a + (tb-ta)/2;

    tb = n;
    ta = a+(n-b+1);
    ans = min(ans,(n-b+1)+(tb-ta)/2);
    cout << ans << endl;
  }
}


Measured memory_bytes: 256
import math

def third_angle(h, m):
    if h == 12:
        h = 0
    if m == 60:
        m = 0
    minute_angle = 6 * m
    hour_angle = 0.5 * (60*h + m)
    c = abs(hour_angle - minute_angle)
    c = min(360-c, c)    
    return c

def c_side(a, b, c):
    ans = math.sqrt(a*a + b*b - 2*a*b*math.cos(c))
    return ans

a, b, h, m = [int(i) for i in input().split()]
c_angle = third_angle(h, m)
c_angle = math.radians(c_angle)
ans = c_side(a, b, c_angle)
print(ans)

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

int main(void)
{
    int N;
    cin >> N;
    string S;
    vector<int> counts(4, 0);

    for(int i = 0 ; i < N; i++){
        cin >> S;
        if(S == "AC"){
            counts[0]++;
        } else if(S == "WA"){
            counts[1]++;
        } else if(S == "TLE"){
            counts[2]++;
        } else{
            // "RE"
            counts[3]++;
        }
    }

    cout << "AC x " << counts[0] << endl;
    cout << "WA x " << counts[1] << endl;
    cout << "TLE x " << counts[2] << endl;
    cout << "RE x " << counts[3] << endl;

    return 0;
}


Measured memory_bytes: 3628
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.Writer;
import java.util.*;



public class Main {
	 
	public static void main(String[] args) throws IOException{
		InputStream inputStream = System.in;
	    OutputStream outputStream = System.out;
	    InputReader in = new InputReader(inputStream);
	    OutputWriter out = new OutputWriter(outputStream);
	   
	    String s = in.next();
	    
	    out.printLine(s.substring(0, 4)+" "+s.substring(4));
	    
	    
	    out.close();
	     
	}
}

 
class InputReader {
	private InputStream stream;
	private byte[] buf = new byte[1024];
	private int curChar;
	private int numChars;
	
	public InputReader(InputStream stream) {
			this.stream = stream;
	}
	
	public int read(){
			if (numChars == -1)
			throw new InputMismatchException();
			if (curChar >= numChars) {
				curChar = 0;
				try {
					numChars = stream.read(buf);
				} catch (IOException e) {
					throw new InputMismatchException();
				}
				if (numChars <= 0)
					return -1;
			}
			return buf[curChar++];
	}
	public int readInt() {
		int c = read();
		while (isSpaceChar(c))
			c = read();
		int sgn = 1;
		if (c == '-') {
			sgn = -1;
			c = read();
		}
		int res = 0;
		do {
			if (c < '0' || c > '9')
				throw new InputMismatchException();
			res *= 10;
			res += c - '0';
			c = read();
		} while (!isSpaceChar(c));
		return res * sgn;
	}
	public long readLong() {
		int c = read();
		while(isSpaceChar(c))
			c = read();
	int sgn = 1;
	if (c == '-') {
		sgn = -1;
		c = read();
	}
	long res = 0;
	do {
		if (c < '0' || c > '9')
			throw new InputMismatchException();
		res *= 10;
		res += c - '0';
		c = read();
	} while (!isSpaceChar(c));
	return res * sgn;
	}
	public String readString() {
		int c = read();
		while (isSpaceChar(c))
			c = read();
		StringBuffer res = new StringBuffer();
		do {
			res.appendCodePoint(c);
			c = read();
		} while (!isSpaceChar(c));
		return res.toString();
	}
	public static boolean isSpaceChar(int c) {
		return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
	}
	public String next() {
		return readString();
	}
}
 
class OutputWriter {
	private final PrintWriter writer;
	public OutputWriter(OutputStream outputStream) {
		writer = new PrintWriter(outputStream);
	}
	public OutputWriter(Writer writer) {
		this.writer = new PrintWriter(writer);
	}
	public void print(Object... objects) {
		for (int i = 0; i < objects.length; i++) {
			if (i != 0)
				writer.print(' ');
			writer.print(objects[i]);
		}
	}
	public void printLine(Object... objects) {
		print(objects);
		writer.println();
	}
	public void close() {
	writer.close();
	}
}   


Measured memory_bytes: 8400
A,V = map(int,input().split())
B,W = map(int,input().split())
T = int(input())

if (W >= V ):
    print('NO')
elif (A > B):
    length = A - B
    speed = V - W
    if(speed * T >= length):
        print('YES')
    else:
        print('NO')
else:
    length = B - A
    speed = V - W
    if(speed * T >= length):
        print('YES')
    else:
        print('NO')

Measured memory_bytes: 9200
N = gets.to_i
class Node
    attr_accessor :children, :parent

    def initialize()
        @children = []
        @parent = -1
    end
end
nodes = Array.new(N) { Node.new }
N.times do
    line=gets.chomp.split(" ").map(&:to_i)
    node_index = line[0]
    children_count = line[1]
    next if children_count == 0
    children = line[2..-1]
    nodes[node_index].children = children
    children.each do |child|
        nodes[child].parent = node_index
    end
end

nodes.each_with_index do |node, index|
    parent = node.parent
    depth = 0
    while parent != -1 do
        depth+=1
        parent = nodes[parent].parent
    end
    puts "node #{index}: parent = #{node.parent}, depth = #{depth}, #{node.parent==-1 ? "root" : node.children.empty? ? "leaf" : "internal node"}, [#{node.children.join(", ")}]"
end


Measured memory_bytes: 25528
#include <bits/stdc++.h>
#define all(v) (v).begin(), (v).end()
#define pb push_back
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
using namespace std;
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
template<class T>using numr=std::numeric_limits<T>;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const int INF = 1e9;
const ll LLINF = 1e16;
const int MOD = 1000000007;
const int MOD2 = 998244353;

int vector_finder(std::vector<int> vec, int number) {
  auto itr = std::find(vec.begin(), vec.end(), number);
  size_t index = std::distance( vec.begin(), itr );
  if (index != vec.size()) { // 発見できたとき
    return 1;
  }
  else { // 発見できなかったとき
    return 0;
  }
}

int main() {
    ios::sync_with_stdio(false);cin.tie(0);
    int x,n;
    cin >> x>>n;
    vector<int> v(n);
    for(int i= 0;i<n;i++) cin >> v[i];
    
    int res =x;
    int hoge =x;
    int fuga = x;
    for(int i=0;i<n;i++){
        if(vector_finder(v, fuga)==0){
            cout << fuga << endl;
            return 0;
        } 
        res--;
        if(vector_finder(v, res)==0){
            cout << res << endl;
            return 0;
        } 
        hoge++;
        if(vector_finder(v, hoge)==0){
            cout << hoge << endl;
            return 0;
        } 
    }
    cout << x << endl;
}

Measured memory_bytes: 3644
#include<iostream>
#include<bits/stdc++.h>
#include<iomanip>
#include<math.h>
#include<vector>
#include<cctype>
#include<string>
#include<set>
#include<map>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
std::string line;
typedef long long ll;

int main(){

   int a,b,t;
   cin >> a >> b >> t;

   int ans = b*(t/a);

   cout << ans << endl;





   return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>
#define endl "\n"
#define ll long long
using namespace std;

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

    ll ans = 0;
    for(int i = 1; i <= n; i ++)
    {
    	if(i % 3 != 0 && i % 5 != 0)
    		ans = ans + i;
    }
    cout << ans << endl;
}

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

#include <boost/range/adaptors.hpp>
#include <boost/range/irange.hpp>

using namespace std;
using namespace boost;
using namespace boost::adaptors;

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

    --n;

    int64_t d = 26, k = 1;
    while (true) {
        if (n < d) {
            string s;

            for (auto i : irange(0L, k)) {
                s.push_back('a' + n % 26);
                n /= 26;
            }

            std::reverse(s.begin(), s.end());

            cout << s << endl;

            return 0;
        }

        n -= d;
        d *= 26;
        ++k;
    }
}

Measured memory_bytes: 3636
from functools import reduce
import math

def main():
    # 文字列の2進数を数値にする
    # '101' → '5'
    # 文字列の頭に'0b'をつけてint()にわたす
    # binary = int('0b'+'101',0)

    # 2進数で立っているbitを数える
    # 101(0x5) → 2
    # cnt_bit = bin(5).count('1')
    
    # N! を求める
    # f = math.factorial(N)

    # N の逆元
    # N_inv = pow(N,MOD-2,MOD)

    # nCr
    # Nの階乗 * rの階乗の逆元 * n-rの階乗の逆元
    
    # 切り捨て
    # 4 // 3
    # 切り上げ
    #-(-4 // 3)
    
    # 初期値用:十分大きい数(100億)
    INF = float("inf")

    # 大きな素数
    MOD = 10**9+7
    
    # 1文字のみを読み込み
    # 入力:2
    # a = input().rstrip()
    # 変数:a='2'
    
    # スペース区切りで標準入力を配列として読み込み
    # 入力:2 4 5 7
    # a, b, c, d = (int(_) for _ in input().split())  
    # 変数:a=2 b=4 c=5 d =7
    
    # 1文字ずつ標準入力を配列として読み込み
    # 入力:2 4 5 7
    # a = list(int(_) for _ in input().split())
    # 変数:a = [2, 4, 5, 7]    

    # 1文字ずつ標準入力を配列として読み込み
    # 入力:2457
    # a = list(int(_) for _ in input())
    # 変数:a = [2, 4, 5, 7]    
    H, W = (int(_) for _ in input().split())
    N = int(input().rstrip())
    a = list(int(_) for _ in input().split())
    a_dict = dict()
    for i in range(N):
        a_dict[i+1] = a[i]

    a_dict_sorted = dict()
    for k, v in sorted(a_dict.items(), key=lambda x: -x[1]):
        a_dict_sorted[k] = v

    Grid = []
    for i in range(H):
        Grid.append(list ( -1 for j in range(W)))
        
    a_index = 0
    a_cnt = a[a_index]
    for h in range(H):
        for w in range(W):
            Grid[h][w] = a_index+1
            if a_cnt - 1 <=0:
                a_index +=1
                if(a_index == N):
                    break
                a_cnt = a[a_index]
            else:
                a_cnt -=1
                
    for h in range(H):
        if h % 2 ==1:
            Grid[h] = Grid[h][::-1]
    for h in range(H):
        print(' '.join(str(_) for _ in Grid[h]))
    
if __name__ == '__main__':
    main()


Measured memory_bytes: 5792
import sys

input = sys.stdin.readline

H, W = map(int, input().split())
s = [input() for _ in range(H)]

row_blocks = []
for r in range(H):
    t = []
    x = 0
    for c in range(W):
        if s[r][c] == '.':
            x += 1
        else:
            x = 0
        t.append(x)

    x = 0
    for i in range(W - 1, -1, -1):
        if t[i] > 0:
            x = max(x, t[i])
        else:
            x = 0
        t[i] = x
    row_blocks.append(t)
# print(row_blocks)

col_blocks = []
for c in range(W):
    t = []
    x = 0
    for r in range(H):
        if s[r][c] == '.':
            x += 1
        else:
            x = 0
        t.append(x)

    x = 0
    for i in range(H - 1, -1, -1):
        if t[i] > 0:
            x = max(x, t[i])
        else:
            x = 0
        t[i] = x
    col_blocks.append(t)
# print(col_blocks)

ans = 0
for r in range(H):
    for c in range(W):
        t = row_blocks[r][c] + col_blocks[c][r] - 1
        ans = max(ans, t)
print(ans)


Measured memory_bytes: 124636
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Linq.Expressions;
using System.Runtime.InteropServices;
using System.Text;
using static System.Console;
using static System.Math;
class Simple {
    private int A, B, X;
    void Solve() {
        //in
        A = io.Int;
        B = io.Int;
        X = io.Int;
        //cal
        var diff = X - A;
        var isEnable = 0 <= diff && diff <= B;
        //out
        WriteLine(isEnable ? "YES" : "NO");
    }
    SimpleIO io = new SimpleIO();
    public static void Main(string[] args) => new Simple().Stream();
    private void Stream() {
        //var exStdIn = new System.IO.StreamReader("stdin.txt");
        //SetIn(exStdIn);
        Solve();
        io.Flush();
    }
}
class SimpleIO {
    string[] _nextBuffer;
    int _bufferCnt;
    char[] cs = new char[] {' ', '"', ','};
    StreamWriter sw = new StreamWriter(OpenStandardOutput()) {
#if DEBUG
        AutoFlush = true
#else
        AutoFlush = false
#endif
    };
    public SimpleIO() {
        _nextBuffer = new string[0];
        _bufferCnt = 0;
        SetOut(sw);
    }
    string Next() {
        if(_bufferCnt < _nextBuffer.Length)
            return _nextBuffer[_bufferCnt++];
        var st = ReadLine();
        while(st == "")
            st = ReadLine();
        _nextBuffer = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        _bufferCnt = 0;
        return _nextBuffer[_bufferCnt++];
    }
    public string String => Next();
    public char Char => char.Parse(String);
    public int Int => int.Parse(String);
    public long Long => long.Parse(String);
    public double Double => double.Parse(String);
    public void Flush() => Out.Flush();
}


Measured memory_bytes: 13140
import heapq

N, M = map(int, input().split())
A = list(map(int, input().split()))
heapq.heapify(A)
B = []
C = []
CB = []
for _ in range(M):
    b, c = map(int, input().split())
    B.append(b)
    C.append(c)
    CB.append((c, b))
CB.sort(reverse=True)
for c, b in CB:
    for j in range(b):
        tmp = heapq.heappop(A)
        if tmp >= c:
            heapq.heappush(A, tmp)
            break
        else:
            heapq.heappush(A, c)
print(sum(A))


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

int main(){
    int n;
    cin >> n;
    int l,r;
    int sum=0;
    for(int i=0;i<n;i++){
        cin >> l >> r;
        int s;
        s = r-l+1;
        sum += s;
    }
    cout << sum << endl;
}

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

using namespace std;

typedef long long ll;
typedef long double ld;
#define F first
#define S second
#define int long long
set <int> st;

void check(int n, int k) {
	if (k == 1)
		return;
	if (n % k == 0) 
		check(n / k, k);
	else {
		if (n % k == 1)
			st.insert(k);
		return;
	}
}

int32_t main(){
	int n;
	cin >> n;
	n--;
	int ans = 0;
	for (int i = 1; i * i <= n; i++)
		if (n % i == 0)
			ans += 2 - (i * i == n);
	ans--;
	n++;
	for (int i = 1; i * i <= n; i++)
		if (n % i == 0)
			check(n, i), check(n, n / i);
	cout << st.size() + ans;
}


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

int check(int data[], char key)
{
	int i;

	for (i=1; i<=13; i++){
		if (data[i] == 0)
			printf("%c %d\n", key, i);
	}
	return 0;
}

int main (void)
{
	int s[14]={0}, h[14]={0}, c[14]={0}, d[14]={0};
	int j, i, n, p=0, t=0, b=0, y=0;
	char k, x='S', e='H', q='C', o='D';

	scanf("%d", &n);

	for (i=1; i<=n; i++){
		scanf(" %c %d", &k, &p);
		if (k == 'S')
			s[p] = p;
		else if (k == 'H')
			h[p] = p;
		else if (k == 'C')
			c[p] = p;
		else
			d[p] = p;
	}


	check(s, x);
	check(h, e);
	check(c, q);
	check(d, o);

	return 0;
}

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

using namespace std;

#define INF 1000000007
#define int long long
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define rep(i, n) FOR(i, 0, n)
int gcd(int a, int b)
{
	return b ? gcd(b, a % b) : a;
}
int lcm(int a, int b) { return a / gcd(a, b) * b; }
signed main()
{
	string S;
	int K;
	cin >> S >> K;
	string G(S);
	int count_s = 0;
	int count_g = 1;
	for (int i = 1; i < S.length(); i++) {
		if (S[i] == S[i - 1]) {
			count_s++;
			S[i] = '0';
		}
	}
	for (int i = 2;i < G.length();i++) {
		if (G[i] == G[i-1]) {
			count_g++;
			G[i] = '0';
		}
	}
	if (S.length() == 1) {
		cout << count_s * ((K - 1) / 2 + 1) + count_g * (K / 2) << endl;
		return 0;
	}
	if (S[0] != S[S.length()-1]) {
		cout << count_s * K <<endl; //SSSS...
	}
	else if(G[G.length()-1] == S[0]){
		cout << count_s + count_g * (K - 1) << endl; //SGGG...
	}
	else {
		cout << count_s * ((K-1)/2 + 1)  + count_g * (K/2)<< endl; //SGSGSGSG...
	}
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using Long = long long ;
Long ans = 0;
 
int main(){
 
    Long n;
    cin >> n;

    vector<Long> v(n + 1);
 
    for( Long i = 1 ; i <= n ; ++i ){
        for( Long j = i ; j <= n ; j += i ){
            v[j]++;
        }
    }
 
    for( Long i = 1 ; i <= n ; ++i ){
        ans += i * v[i];
    }
    cout << ans ;
 
    return 0;
}

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

int main() {
  int n,r;
  cin>>n>>r;
  /////
  int ans=r;
  if(n<10){
     int k=10-n;
    ans+=100*k;
  }
  else{
    
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
n = int(input())
*a, = map(int, input().split())
a.sort()

if n % 2:
    for k in range(n):
        if a[k] != (k+1)//2*2:
            print(0)
            break
    else:
         print(2**((n-1)//2) % (10**9+7))
else:
    for k in range(n):
        if a[k] != k//2*2+1:
            print(0)
            break
    else:
        print(2**(n//2) % (10**9+7))


Measured memory_bytes: 13880
import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")


n = int(input())
f = [0]*(1+n)
for x in range(1,101):
    for y in range(1,101):
        for z in range(1,101):
            val = x**2 + y**2 + z**2 + x*y + x*z + y*z
            if 1 <= val <= n:
                f[val] += 1
write("\n".join(map(str, f[1:])))

Measured memory_bytes: 68008
#include<stdio.h>
int main(){
  int a,b,c,d,e;
  scanf("%d%d",&a,&b);
  c=a+b;
  d=a-b;
  e=a*b;
  if(c>d){
    if(c>e)
      printf("%d\n",c);
    else
      printf("%d\n",e);
  }
  else{
    if(d>e)
      printf("%d\n",d);
    else
      printf("%d\n",e);
  }
  return 0;
}


Measured memory_bytes: 128
import java.util.Scanner;

public class Main {
    public static void main (String[] args) {
        Scanner scan = new Scanner(System.in);
        double a = scan.nextDouble();
        double b = scan.nextDouble();
        double arg = scan.nextDouble();

        double rad = Math.toRadians(arg);
        double S = b * a * Math.sin(rad)/2;
        double c_2 = Math.pow(b,2) + Math.pow(a,2) - 2*a * b * Math.cos(rad);
        double c = Math.sqrt(c_2);
        double h = b * Math.sin(rad);

        System.out.println(S);
        System.out.println(a + b + c);
        System.out.println(h);



    }
}



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

int main(){
  string s;
  cin >> s;
  ll first_b = -1;
  rep(i,s.size()){
    if( s.at(i) == 'B' ){
      first_b = i;
      break;
    }
  }
  ll ans = 0;
  ll j = first_b;
  for(int i=first_b;i<s.size();i++){
    if( s.at(i) == 'W' ){
      ans += i-j;
      j++;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 640
#define lop(i, n) for (int i = n-1; i >= 0; i--)
#define loop(i, x) for (int i = 0; i < x; i++)
#define loopf(i, x, n) for (int i = x; i < n; i++)
#define loopr(i, x, n) for (int i = x - 1; i >= n; i--)
#define ain(arr, n) for (int i = 0; i < n; i++) cin>>arr[i]
#define aout(arr, n) for (int i = 0; i < n; i++) cout<<arr[i]<<" "
#define mm(lamb, tttt) memset(lamb, tttt, sizeof lamb)
#define bit(i) (1<<(i))

#define null NULL
#define eps 0.000000001
#define mod 1000000007
#define PI 3.14159265358979323846
#define pb push_back
#define pf push_front
#define mp make_pair
#define fe first
#define se second
#define ALL(V) V.begin(), V.end()
#define sz(V) (int)V.size()
#define _ <<" "<<

#include <iostream>
#include <fstream>
#include <stdio.h>
#include <stack>
#include <queue>
#include <deque>
#include <vector>
#include <iterator>
#include <bitset>
#include <list>
#include <map>
#include <set>
#include <unordered_map>
#include <cstring>
#include <string>
#include <algorithm>
#include <cmath>
#include <cassert>
#include <limits.h>
#include <iomanip>
#include <cctype>
#include <numeric>
#include <complex>

using namespace std;

typedef long long ll;
typedef vector <int> vi;
typedef vector<vi> vvi;
typedef pair <int, int> ii;
typedef pair<int, pair<int,int> > iii;
typedef vector<ii> vii;
typedef complex<int> ci;

int main()
{
	ios_base::sync_with_stdio(false);
	int n,a,b;
	cin>>n>>a>>b;
	if ((b -a)%2 == 0)
		cout<<"Alice"<<"\n";
	else cout<<"Borys"<<"\n";
	return 0;
}


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

class segtree {
  int n;
  vector<int64_t> v;
  
public:
  segtree(int k) {
    n = k;
    v = vector<int64_t>(2 * k);
  }
  
  void update(int x, int64_t k) {
    int index = x + n - 1;
    while (index) {
      v.at(index) = max(v.at(index), k);
      index /= 2;
    }
  }
  
  int64_t query(int k) {
    int64_t l = n, res = 0;
    k += n;
    while (l < k) {
      if (k % 2) {
        res = max(res, v.at(k - 1));
      }
      k /= 2;
      if (l % 2) {
        res = max(res, v.at(l));
        l++;
      }
      l /= 2;
    }
    return res;
  }
};

int main() {
  int n;
  cin >> n;
  vector<int64_t> h(n), a(n);
  for (int i = 0; i < n; i++) {
    cin >> h.at(i);
  }
  for (int i = 0; i < n; i++) {
    cin >> a.at(i);
  }
  
  segtree t(n);
  for (int i = 0; i < n; i++) {
    t.update(h.at(i), t.query(h.at(i)) + a.at(i));
  }
  
  cout << t.query(n) << endl;
}


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

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = (n) - 1; i >= 0; i--)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (a); i > (b); i--)
#define ALL(a) (a).begin(), (a).end()

int A[100000];
ll N;
int bit[200001];

int sum(int i) {
    int s = 0;
    while (i > 0) {
        s += bit[i];
        i -= i & -i;
    }
    return s;
}

void add(int i, int x) {
    while (i <= 200000) {
        bit[i] += x;
        i += i & -i;
    }
}

bool check(int n) {
    vector<int> vi = {0};
    REP(i, N) {
        if (A[i] >= n) vi.push_back(vi[i] + 1);
        else vi.push_back(vi[i] - 1);
    }

    fill(bit, bit + 200001, 0);
    ll c = 0;
    REP(i, vi.size()) {
        c += i - sum(vi[i] + 100000);
        add(vi[i] + 100000, 1);
    }
    ll c_max = (N + 1) * N / 2;
    return c <= c_max / 2;
}

int main() {
    int sorted[100000];
    cin >> N;
    REP(i, N) cin >> A[i];
    REP(i, N) sorted[i] = A[i];
    sort(sorted, sorted + N);

    int ok = 0, ng = N;
    while (ng - ok > 1) {
        int mid = (ng + ok) / 2;
        if (check(sorted[mid])) ok = mid;
        else                    ng = mid;
    }
    cout << sorted[ok] << endl;
    return 0;
}

Measured memory_bytes: 2764
#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;
int main(){
  int a[3];
  cin>>a[0]>>a[1]>>a[2];
  for(int i=0;i<2;i++){
    for(int j=i+1;j<3;j++){
      if(a[i]>a[j])swap(a[i],a[j]);
    }
  }
  cout<<a[2]-a[1]+a[1]-a[0]<<endl;
  return 0;
}

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

int main()
{
	int n, m, min, res, dist;
	cin >> n >> m;
	
	int sx[n], sy[n];
	int cx[m], cy[m];
	
	for (int i = 0; i < n; i++)
	{
		cin >> sx[i] >> sy[i];
	}
	
	for (int j = 0; j < m; j++)
	{
		cin >> cx[j] >> cy[j];
	}
	for (int i = 0; i < n; i++)
	{
		min = 400000010;
		res = 0;
		for (int j = 0; j < m; j++)
		{
			dist = abs(sx[i] - cx[j]) + abs(sy[i] - cy[j]);
			if (dist < min)
			{
				min = dist;
				res = j;
			}
		}
		cout << res + 1 << endl;
	}
}

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

string reverseString(string str){
	string strTemp;
	int s = str.size();
	for(int i=0 ; i<s ; i++){
		strTemp[s-i-1] = str[i];
	}
	for(int i=0 ; i<s ; i++){
		str[i] = strTemp[i];
	}
	return str;
} 
 
int main(){
	string str;
	while ( cin >> str ) {
		cout << reverseString( str ) << endl;
	}
} 

Measured memory_bytes: 0
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <map>
#include <set>
#include <string>
#include <cmath>
#include <iostream>

using namespace std;

#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define rep(i, n)	 for(int i = 0; i < (n); i++)
#define all(a)		 begin(a), end(a)

typedef long long int		   ll;
typedef long long unsigned int llu;

void solve(ll a, ll b, ll c) {
	if(a <= b) {
		if(c < b) printf("%d", a + c);
		else printf("%d", a + b);
	}
	if(a > b) {
		if(a > c) printf("%d", b + c);
		else printf("%d", a + b);
	}
}

int main() {
	ll a;
	ll b;
	ll c;
	scanf("%lld", &a);
	scanf("%lld", &b);
	scanf("%lld", &c);
	solve(a, b, c);
	return 0;
}


Measured memory_bytes: 256
S = input()

flag = 0
for i in range(0, len(S), 1):
	if S[i] != S[len(S)-1-i]:
		flag = 1

for i in range(0, len(S)//2, 1):
	if S[i] != S[len(S)//2-1-i]:
		flag = 1

if flag == 0:
	print("Yes")
else:
	print("No")

Measured memory_bytes: 9112
#include<stdio.h>
main(){
    int x[10],y[10],z[10],i,j,n,cz,cy,tmp;
    scanf("%d",&n);
    for(i=0;i<n;i++){
        tmp=0;
        cy=0;cz=0;
        for(j=0;j<10;j++){
        scanf("%d",&x[j]);
        z[j]=0;y[j]=0;
        }
        for(j=0;j<10;j++){
        if(x[j]>=y[cy-1*(cy>0)])
        y[cy++]=x[j];
        else if(x[j]>=z[cz-1*(cz>0)])
        z[cz++]=x[j];
        else
        tmp=1;
        }
        if(tmp==1)
        printf("NO\n");
        else
        printf("YES\n");
    }
}

Measured memory_bytes: 1008
var kills = 0

function main(arg) {
    var N = parseInt( arg.split(/\n/)[0] );
    var A = arg.split(/\n/)[1].split(/\s/).map( str => parseInt(str, 10) );
    var B = arg.split(/\n/)[2].split(/\s/).map( str => parseInt(str, 10) );
    var kill = 0;
    for(i=0;i<N;i++){
        //1つめの町で敵を倒す
        fight(i,i,A,B);
        //2つめの町で敵を倒す
        fight(i,i+1,A,B);
    }
    console.log(kills);
}

function fight(myid,town,A,B){
    if(A[town]>=B[myid]){
        A[town]-=B[myid];
        kills += B[myid];
        B[myid]=0;
    }else if(A[town]<B[myid]){
        B[myid]-=A[town];
        kills += A[town];
        A[town]=0;
    }
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 30952
#include <stdio.h>

#define MAX 10000
#define NIL -1

typedef struct{
  int p, l, r;
}Node;

Node T[MAX];

int n;

void preParse(int u){
  if(u==NIL) return;
  printf(" %d", u);
  preParse(T[u].l);
  preParse(T[u].r);
}

void inParse(int u){
  if(u==NIL) return;
  inParse(T[u].l);
  printf(" %d", u);
  inParse(T[u].r);
}

void postParse(int u){
  if(u==NIL) return;
  postParse(T[u].l);
  postParse(T[u].r);
  printf(" %d", u);
}

int main(){
  int i, v, l, r, root;

  scanf("%d", &n);
  
  for(i=0; i<n; i++) T[i].p=NIL;

  for(i=0; i<n; i++){
    scanf("%d %d %d", &v, &l, &r);
    T[v].l = l;
    T[v].r = r;
    if(l!=NIL) T[l].p=v;
    if(r!=NIL) T[r].p=v;
  }

  for(i=0; i<n; i++){
    if(T[i].p==NIL) root=i;
  }

  printf("Preorder\n");
  preParse(root);
  printf("\n");
  
  printf("Inorder\n");
  inParse(root);
  printf("\n");
  
  printf("Postorder\n");
  postParse(root);
  printf("\n");
  
  return 0;
}



Measured memory_bytes: 2144
import sys
input = sys.stdin.readline

S = list(input().rstrip())
INF = 10**15

bit = 0
dic = {0 : 0}
for ind, s in enumerate(S):
    bit ^= 1<<(ord(s)-97)
    score = INF
    if bit in dic:
        score = dic[bit] + 1
    for i in range(26):
        nbit = bit^(1<<i)
        if nbit in dic and dic[nbit]+1 < score:
            score = dic[nbit]+1
    if bit in dic and ind != len(S)-1:
        dic[bit] = min(dic[bit], score)
    else:
        dic[bit] = score

print(dic[bit])

Measured memory_bytes: 34228
import java.io.*;
import java.util.*;

public class Main {

	static ArrayList<Integer>[] adj;
	static int timer, par[], tin[], tout[];

	static int lca(int u, int v) {
		while (true) {
			if (tin[v] >= tin[u] && tin[v] <= tout[u])
				break;
			u = par[u];
		}
		return u;
	}

	static int[] prefix;

	static void update(int u, int lca) {
		prefix[u]++;
		prefix[lca]--;
	}

	static int dfs(int u, int p) {
		par[u] = p;
		tin[u] = timer++;
		int ans = 0;
		for (int v : adj[u])
			if (v != p) {
				ans += dfs(v, u);
				prefix[u] += prefix[v];
			} 
		if (prefix[u] > 0)
			ans++;
		tout[u] = timer - 1;
		return ans;
	}

	public static void main(String[] args) throws IOException {
		Scanner sc = new Scanner();
		PrintWriter out = new PrintWriter(System.out);
		int n = sc.nextInt();
		adj = new ArrayList[n];
		par = new int[n];
		tin = new int[n];
		prefix = new int[n];

		tout = new int[n];
		for (int i = 0; i < n; i++) {
			adj[i] = new ArrayList();
		}
		for (int i = 1; i < n; i++) {
			int u = sc.nextInt() - 1, v = sc.nextInt() - 1;
			adj[u].add(v);
			adj[v].add(u);
		}
		dfs(0, 0);
		
		int[][] lca = new int[n][n];
		int m = sc.nextInt();
		int[] a = new int[m], b = new int[m];
		for (int i = 0; i < m; i++) {
			a[i] = sc.nextInt() - 1;
			b[i] = sc.nextInt() - 1;
			lca[a[i]][b[i]] = lca(a[i], b[i]);
		}
		long ans = 0;
		for (int msk = 0; msk < 1 << m; msk++) {
			Arrays.fill(prefix, 0);
			for (int i = 0; i < m; i++) {
				if ((msk & 1 << i) == 0)
					continue;
				update(a[i], lca[a[i]][b[i]]);
				update(b[i], lca[a[i]][b[i]]);

			}
			int c = dfs(0, 0);  

			ans += (1L << (n - 1 - c)) * (Integer.bitCount(msk) % 2 == 0 ? 1 : -1);
		}
		out.println(ans);
		out.close();

	}

	static class Scanner {
		BufferedReader br;
		StringTokenizer st;

		Scanner() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		Scanner(String fileName) throws FileNotFoundException {
			br = new BufferedReader(new FileReader(fileName));
		}

		String next() throws IOException {
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}

		String nextLine() throws IOException {
			return br.readLine();
		}

		int nextInt() throws IOException {
			return Integer.parseInt(next());
		}

		long nextLong() throws NumberFormatException, IOException {
			return Long.parseLong(next());
		}

		double nextDouble() throws NumberFormatException, IOException {
			return Double.parseDouble(next());
		}

		boolean ready() throws IOException {
			return br.ready();
		}

	}

	static void sort(int[] a) {
		shuffle(a);
		Arrays.sort(a);
	}

	static void shuffle(int[] a) {
		int n = a.length;
		Random rand = new Random();
		for (int i = 0; i < n; i++) {
			int tmpIdx = rand.nextInt(n);
			int tmp = a[i];
			a[i] = a[tmpIdx];
			a[tmpIdx] = tmp;
		}
	}

}

Measured memory_bytes: 45020
#include<bits/stdc++.h>
using namespace std;
int k(int m)
{
    int c=0;
    for(int j=1;j<=m;j++)
    {
        if(m%j==0)
        {c++;}
        if(c>2)
        {return 0;}
    }
    return 1;
}
int main ()
{
    int i,n;
    cin>>n;
    for(i=n;i<=100010;i++)
    {
        if(k(i))
        {cout<<i;
        return 0;}
    }
}

Measured memory_bytes: 3632
import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
from heapq import heappop,heappush

H,W,M = map(int,readline().split())
hw = list(map(int,read().split()))

x_num = [0] * (H+1)
y_num = [0] * (W+1)

it = iter(hw)
for h,w in zip(it,it):
    x_num[h] += 1
    y_num[w] += 1

x_max = max(x_num)
y_max = max(y_num)

x_max_set = set()
y_max_set = set()
for i,num in enumerate(x_num):
    if(num == x_max):
        x_max_set.add(i)

for i,num in enumerate(y_num):
    if(num == y_max):
        y_max_set.add(i)

cnt = 0
it = iter(hw)
for h,w in zip(it,it):
    if(h in x_max_set)&(w in y_max_set):
        cnt += 1

point = len(x_max_set) * len(y_max_set)
ans = x_max+y_max
if(point == cnt):
    ans -= 1
print(ans)

Measured memory_bytes: 167676
package main

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

// define
var (
	sc = bufio.NewScanner(os.Stdin)
)

func scanIntLine(len int) []int{
	arr := make([]int, len)
	for i:=0; i<len; i++{
		sc.Scan()
		tmp, err := strconv.Atoi(sc.Text())
		if err == nil{
			arr[i] = tmp
		}
	}
	return arr
}

func scanStringLine(len int) []string{
	arr := make([]string, len)
	for i:=0; i<len; i++{
		sc.Scan()
		arr[i] = sc.Text()
	}
	return arr
}

func scanIntSplit(len int) []int{
	arr := make([]int, len)
	sc.Scan()
	for i, v := range strings.Split(sc.Text(), " "){
		tmp, err := strconv.Atoi(v)
		if err == nil{
			arr[i] = tmp
		}
	}
	return arr
}

func main(){
	arr := scanIntSplit(2)
	N, Y := arr[0], arr[1]
	a, b, c := 0, 0, 0
	for Y >= 10000 {
		Y -= 10000 
		a++
	}
	for Y >= 5000 {
		Y -= 5000
		b++
	}
	c = Y/1000

	
	for a+b+c+9<=N && a>0 {
		a--
		c += 10
	}
	for a+b+c+4<=N && b>0 {
		b--
		c += 5
	}
	for a+b+c+1<=N && a>0 {
		a--
		b += 2
	}
	if a+b+c == N {
		fmt.Println(a, b, c)
	} else {
		fmt.Println("-1 -1 -1")
	}


}

Measured memory_bytes: 640
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

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

    static class ACirclePond {
        public void solve(int testNumber, FastReader s, PrintWriter w) {
            w.println(2 * Math.PI * s.nextInt());
        }

    }

    static class FastReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private FastReader.SpaceCharFilter filter;

        public FastReader(InputStream stream) {
            this.stream = stream;
        }

        public int read() {

            if (numChars == -1)
                throw new InputMismatchException();

            if (curChar >= numChars) {

                curChar = 0;

                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }

                if (numChars <= 0)
                    return -1;
            }

            return buf[curChar++];
        }

        public int nextInt() {

            int c = read();

            while (isSpaceChar(c))
                c = read();

            int sgn = 1;

            if (c == '-') {
                sgn = -1;
                c = read();
            }

            int res = 0;

            do {
                if (c < '0' || c > '9')
                    throw new InputMismatchException();

                res *= 10;
                res += c - '0';
                c = read();
            }
            while (!isSpaceChar(c));

            return res * sgn;
        }

        public boolean isSpaceChar(int c) {

            if (filter != null)
                return filter.isSpaceChar(c);

            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public interface SpaceCharFilter {
            public boolean isSpaceChar(int ch);

        }

    }
}



Measured memory_bytes: 25620
import sys

input = sys.stdin.readline
a, b, c = map(int, input().split())

ma = max(a, b, c)

at = (ma - a) // 2 * 2 + a
bt = (ma - b) // 2 * 2 + b
ct = (ma - c) // 2 * 2 + c

ans = 0
ans += (ma - a) // 2
ans += (ma - b) // 2
ans += (ma - c) // 2

dif = abs(ma - at) + abs(ma - bt) + abs(ma - ct)

if dif == 0:
    print(ans)
elif dif == 1:
    print(ans + 2)
else:
    print(ans + 1)


Measured memory_bytes: 3064