akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
// Begin Header {{{
#define all(x)          (x).begin(), (x).end()
#define rep(i, n)       for (i64 i = 0, i##_limit = (n); i < i##_limit; ++i)
#define reps(i, s, t)   for (i64 i = (s), i##_limit = (t); i <= i##_limit; ++i)
#define repr(i, s, t)   for (i64 i = (s), i##_limit = (t); i >= i##_limit; --i)
#define var(Type, ...)  Type __VA_ARGS__; input(__VA_ARGS__)
#ifndef DBG
#define trace(...)
#endif
using namespace std;
using i64 = int_fast64_t;
using pii = pair<i64, i64>;
template <class T, class U> inline bool chmax(T &a, const U &b) { return b > a && (a = b, true); }
template <class T, class U> inline bool chmin(T &a, const U &b) { return b < a && (a = b, true); }
inline i64  sigma(i64 n)            { return (n * (n + 1) >> 1); }
inline i64  updiv(i64 a, i64 b)     { return (a + b - 1) / b; }
inline i64  sqr(i64 n)              { return n * n; }
inline string to_string(char c)     { return string(1, c); }
constexpr int INF  = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;

template <class T>
inline vector<T> make_v(const T &initValue, size_t sz) {
    return vector<T>(sz, initValue);
}
template <class T, class... Args>
inline auto make_v(const T &initValue, size_t sz, Args... args) {
    return vector<decltype(make_v<T>(initValue, args...))>(sz, make_v<T>(initValue, args...));
}

inline void input() {}
template <class Head, class... Tail>
inline void input(Head &head, Tail&... tail) { cin >> head; input(tail...); }

inline void print() { cout << "\n"; }
template <class Head, class... Tail>
inline void print(Head &&head, Tail&&... tail) {
    cout << head;
    if (sizeof...(tail)) cout << ' ';
    print(forward<Tail>(tail)...);
}

template <class T>
inline ostream& operator<< (ostream &out, const vector<T> &vec) {
    static constexpr const char *delim[] = { " ", "" };
    for (const auto &e : vec) out << e << delim[&e == &vec.back()];
    return out;
}

template <typename Func>
struct FixPoint : Func {
    inline constexpr FixPoint(Func &&f) noexcept : Func(forward<Func>(f)) {}

    template <typename... Args>
    inline decltype(auto) operator()(Args &&... args) const {
        return Func::operator()(*this, forward<Args>(args)...);
    }
};

template< typename Func >
inline decltype(auto) makeFixPoint(Func &&f) {
    return FixPoint< Func >{forward< Func >(f)};
}
// }}} End Header

signed main()
{
    ios::sync_with_stdio(false); cin.tie(nullptr);

    var(i64, a, b);

    const i64 d = b - a;

    print(sigma(d - 1) - a);

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <math.h>
#include <queue>
using namespace std;

int main() {
    long long H,A;
    cin >> H >> A;
    if (H % A == 0) {
        cout << H / A << endl;
    } else {
        cout << 1 + H / A << endl;
    }
    return 0;
}

Measured memory_bytes: 256
# include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5+3;
int cnt=0, id=0, Next[maxn],in[maxn],out[maxn];
int fa[maxn][20], len[maxn];
struct node
{
    int v, next;
}edge[maxn<<1];
void add_edge(int u, int v)
{
    edge[cnt] = {v, Next[u]};
    Next[u] = cnt++;
    edge[cnt] = {u, Next[v]};
    Next[v] = cnt++;
}

void dfs(int cur, int pre, int d)
{
    fa[cur][0] = pre;
    len[cur] = d;
    for(int i=1; i<20; ++i)
        fa[cur][i] = fa[fa[cur][i-1]][i-1];
    in[cur] = ++id;
    for(int i=Next[cur]; i!=-1; i=edge[i].next)
    {
        int v = edge[i].v;
        if(v == pre) continue;
        dfs(v, cur, d+1);
    }
    out[cur] = id;
}
int main()
{
    int n, a, b;
    scanf("%d",&n);
    memset(Next, -1, sizeof(Next));
    for(int i=1; i<n; ++i)
    {
        scanf("%d%d",&a,&b);
        add_edge(a, b);
    }
    dfs(1, 0, 0);
    int tmp=(len[n]-1)/2, now=n;
    for(int i=0; i<20; ++i)
        if(tmp>>i&1) now = fa[now][i];
    int bl = n-(out[now]-in[now]+1)-len[n]/2-1;
    int wh = out[now]-in[now]+1-tmp-1;
    if(len[n]&1)
    {
        if(bl <= wh) puts("Snuke");
        else puts("Fennec");
    }
    else
    {
        if(wh <= bl) puts("Fennec");
        else puts("Snuke");
    }
    return 0;
}


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

#define int long long
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define mp make_pair
#define mt make_tuple

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;

const int inf = 1LL<<60;
const int mod = 1e9 + 7;
const double eps = 1e-9;

/*{
}*/

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

  int n = 50;
  vi v(n);

  if(k < n){
    rep(i, k) v[i] = n-i;
  }else{
    int q = k/50;
    int r = k%50;
    
    iota(all(v), 1);
    reverse(all(v));

    rep(i, n){
      v[i] += (q-1);
    }

    rep(i, r){
      v[i]++;
    }
  }

  cout << n << endl;
  rep(i, n){
    cout << v[i] << " \n"[i == n-1];
  }

  return 0;
}


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

int n,las,a,need,els,ans;

int main(){
	cin>>n;
	for (;n--;){
		cin>>a;
		need=ceil(log2((long double)a)-(1e-12));
		els=floor(log2((long double)a)+(1e-12));
		ans+=max(0,need-las); //printf(" %d\n",ans);
		las=min(need,els+((1<<las) < a));
		las=max(0,las);
	}
	cout<<ans;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<string,int> P;
const LL mod=1000000007;
const LL LINF=1LL<<60;
const int INF=1<<30;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};



int main(){
    int n,m;cin >> n >> m;
    vector<int> k(m);
    vector<int> v[m];
    for (int i = 0; i < m; i++) {
        cin >> k[i];
        for (int j = 0; j < k[i]; j++) {
            int l;cin >> l;
            l--;
            v[i].push_back(l);
        }
    }
    vector<int> p(m);
    for (int i = 0; i < m; i++) {
        cin >> p[i];
    }
    int ans=0;
    for (int i = 0; i < (1<<n); i++) {
        vector<int> x(n,0);
        for (int j = 0; j < n; j++) {
            if(i&(1<<j)){
                for (int a = 0; a < m; a++) {
                    for (int b = 0; b < k[a]; b++) {
                        if(v[a][b]==j) x[a]++;
                    }
                }
            }
        }
        bool f=true;
        for (int j = 0; j < m; j++) {
            if((x[j]+p[j])%2) f=false;
        }
        if(f) ans++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.PriorityQueue;
import java.util.StringTokenizer;

class Main{
    public static void main(String[] Args) throws IOException{
        final BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        final int n = Integer.parseInt(br.readLine());
        final vec[][] mat = new vec[n][];
        for(int i = 0; i<n; i++){
            final StringTokenizer st = new StringTokenizer(br.readLine(), " ");
            final int u = Integer.parseInt(st.nextToken());
            final int k = Integer.parseInt(st.nextToken());
            mat[u] = new vec[k];
            for(int j = 0; j<k; j++){
                mat[u][j] = new vec(Integer.parseInt(st.nextToken()), Integer.parseInt(st.nextToken()));
            }
        }
        final int[] cost = new int[n];
        for(int i = 0; i<n; i++)
            cost[i] = Integer.MAX_VALUE;
        final PriorityQueue<vec> pq = new PriorityQueue<vec>();
        pq.add(new vec(0, 0));
        while(!pq.isEmpty()){
            final int t = pq.peek().t;
            final int c = pq.poll().c;
            if(c>=cost[t]) continue;
            cost[t] = c;
            for(final vec v:mat[t]){
                pq.add(new vec(v.t, c+v.c));
            }
        }
        final StringBuilder sb = new StringBuilder();
        for(int i = 0; i<n; i++){
            sb.append(i).append(' ').append(cost[i]).append('\n');
        }
        System.out.print(sb);
    }
}

class vec implements Comparable<vec>{
    final int t;
    final int c;
    vec(int to, int cost){
        t = to;
        c = cost;
    }
    @Override
    public int compareTo(vec other){
        return c-other.c;
    }

}

Measured memory_bytes: 27616
s=input()

for i in range(len(s)):
    if i%2==0:
        if s[i]!='h':
            print('No')
            exit()
    if i%2==1:
        if s[i]!='i':
            print('No')
            exit()

if len(s)%2==0:
    print('Yes')
else:
    print('No')
    

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

using namespace std;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int t,n,d;
	t = 1;
	while(t--) {
		cin >> n >> d;
		d = 2 * d + 1;
		if(n / d > 0 && n % d > 0)
		 cout << n / d + 1 << endl;
		else if(n / d > 0)
		 cout << n / d << endl;
		else
		 cout << 1 << endl;
	}
	return 0;
}


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

using namespace std;

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

  cout << setfill('0');
  
  if(1<=n & n<=999)
    cout << "ABC" << endl;
  else
    cout << "ABD" << endl;
}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i, n) for(int i = 0; i < n; i++)
#define all(a) a.begin(), a.end()
#define mod 1000000007
#define MOD 998244353
#define INF 40000000000000000
int dx8[8] = {-1, 0, 1, 1, 1, 0, -1, -1};
int dy8[8] = {1, 1, 1, 0, -1, -1, -1, 0};
int dx4[4] = {-1, 0, 1, 0};
int dy4[4] = {0, -1, 0, 1};
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;
}
signed main() {
    int N, M;
    cin >> N >> M;
    vector<pair<int, int>> Graph[N];  //next,cost
    rep(i, N - 1) {
        Graph[i + 1].push_back(make_pair(i, 0));
    }
    rep(i, M) {
        int l, r, c;
        cin >> l >> r >> c;
        l--;
        r--;
        Graph[l].push_back(make_pair(r, c));
        Graph[r].push_back(make_pair(l, c));
    }
    vector<int> dis(N, INF);
    dis[0] = 0;
    priority_queue<pair<int, int>, vector<pair<int, int>>, greater<pair<int, int>>> que;
    que.push(make_pair(0, 0));
    while(!que.empty()) {
        pair<int, int> p = que.top();
        que.pop();
        int d = p.first, now = p.second;
        if(dis[now] < d) continue;
        for(auto q : Graph[now]) {
            int next = q.first, cost = q.second;
            if(dis[next] > d + cost) {
                dis[next] = d + cost;
                que.push(make_pair(dis[next], next));
            }
        }
    }
    if(dis[N - 1] == INF)
        cout << -1 << endl;
    else
        cout << dis[N - 1] << endl;
}


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

int x;

int main() {
  cin >> x;
  vector<int> v{1};
  rep (i, 32) {
    int j = 2;
    while (pow(i, j) <= x) {
      v.emplace_back(pow(i, j));
      j++;
    }
  }
  sort(v.begin(), v.end());
  cout << *(upper_bound(v.begin(), v.end(), x) - 1) << endl;
  return 0;
}


Measured memory_bytes: 4108
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.PriorityQueue;
import java.util.Scanner;

class Main {
    static final int MOD = 1000000007;
    static final int INF = 1 << 30;
    static final int ALF = 26;

    Main() {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        System.out.println((int)(Math.floor(Math.sqrt(N))*Math.floor(Math.sqrt(N))));
    }

    public static void main(String[] args) {
        new Main();
    }
}


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

int main()
{
  int x,y,W,H,r;
  cin>>W>>H>>x>>y>>r;
  if((x-r)<0 || (x+r)>W ||(y-r)<0 || (y+r)>H)cout<<"No"<<endl;
  else cout<<"Yes"<<endl;
  return 0;
}

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


void main() {
    auto X = readln.chomp.to!long;
    auto K = readln.chomp.to!int + 2;
    auto RR = 0 ~ readln.split.map!(to!long).array ~ 10L^^10;
    auto R = (K-1).iota.map!(i => RR[i+1] - RR[i]).array;
    auto Q = readln.chomp.to!int;
    auto T = new long[](Q);
    auto A = new long[](Q);
    foreach (i; 0..Q) {
        auto s = readln.split.map!(to!long);
        T[i] = s[0];
        A[i] = s[1];
    }


    long[] sim0 = [0, X];
    long[] simX = [X, 0];
    long[] simN = [0, X];
    long ub = -1;
    long lb = 1L << 59;


    int q = 0;

    foreach (t; 0..K-1) {
        for ( ; q < Q && RR[t] <= T[q] && T[q] < RR[t+1]; q++) {
            debug {writeln([RR[t], T[q], RR[t+1]]);}
            debug {sim0.writeln; simX.writeln;}

            long ans;

            if (A[q] <= ub) {
                ans = max(0, sim0[0] - T[q] + RR[t]);
            } else if (A[q] >= lb) {
                ans = max(0, simX[0] - T[q] + RR[t]);
            } else if (t % 2 == 0) {
                ans = max(0, simN[0] + A[q] - T[q] + RR[t]);
            } else {
                ans = max(0, simN[0] - A[q] - T[q] + RR[t]);
            }

            if (t % 2)
                ans = X - ans;
            ans.writeln;
        }

        long d0 = min(sim0[0], R[t]);
        sim0[0] -= d0;
        sim0[1] += d0;
        swap(sim0[0], sim0[1]);

        long dX = min(simX[0], R[t]);
        simX[0] -= dX;
        simX[1] += dX;
        swap(simX[1], simX[0]);

        simN[0] -= R[t];
        simN[1] += R[t];
        swap(simN[0], simN[1]);

        if (t % 2 == 0)
            ub = max(ub, -simN[1]);
        else
            lb = min(lb, simN[1]);
    }
}


Measured memory_bytes: 10232
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 1000000007;

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

    int h, w, K;
    cin >> h >> w >> K;
    ll dp[10] = {}, nxt[10] = {};
    dp[0] = 1;
    for (int i = 0; i < h; i++)
    {
        for (int j = 0; j < w; j++)
            nxt[j] = 0;
        for (int j = 0; j < 1 << (w - 1); j++)
        {
            bool f = false;
            for (int k = 0; k < w; k++)
            {
                if ((j & (1 << k)) && (j & (1 << (k + 1))))
                    f = true;
            }
            if (f)
                continue;
            for (int k = 0; k < w; k++)
            {
                if (j & (1 << k))
                {
                    (nxt[k] += dp[k + 1]) %= MOD;
                    (nxt[k + 1] += dp[k]) %= MOD;
                    k++;
                }
                else
                {
                    (nxt[k] += dp[k]) %= MOD;
                }
            }
        }
        for (int j = 0; j < w; j++)
        {
            dp[j] = nxt[j];
        }
    }
    cout << dp[K - 1] << endl;
}

Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include <bits/stdc++.h>
using namespace std;

class ANextAlphabet {
 public:
  void solveOne(std::istream &in, std::ostream &out) {
    char c;
    in >> c;
    out << (char) (c + 1) << endl;
  }
  void solve(std::istream &in, std::ostream &out) {
    int nt = 1;
    for (int i = 0; i < nt; ++i)
      solveOne(in, out);
  }
};

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ANextAlphabet solver;
  std::istream &in(std::cin);
  std::ostream &out(std::cout);
  solver.solve(in, out);
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep_range(i, s, e) for (int i = (s); i < (int)(e); i++)
#define rep_rev(i, s, e) for (int i = (s)-1; i >= (int)(e); i--)
#define sort_vec(v) sort((v).begin(),(v).end())
typedef int64_t lint;
// lint mod = 998244353;
// lint mod = 1000000007;
template< typename T1, typename T2 >
inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 >
inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

void app() {
  int n;
  cin>>n;

  vector<int> a(n);
  int sum=0;
  rep(i,n){
    cin>>a[i];
    sum^=a[i];
  }

  vector<int> ans(n);
  rep(i,n){
    ans[i]=sum^a[i];
  }

  cout<<ans[0];
  rep_range(i,1,n){cout<<' '<<ans[i];}
}

int main(){app();return 0;}


Measured memory_bytes: 4792
#include <cstdio>
#include <cstdlib>
#include <cstring>

struct Node {
    int key;
    // Node型ポインタ変数
    Node *next, *prev;
};

// 番兵
Node *nil;

Node* listSearch(int key) {
    Node *cur = nil->next;
    while (cur != nil && cur->key != key) {
        cur = cur->next;
    }
    return cur;
}

void init() {
    nil = (Node *)malloc(sizeof(Node));
    // Node型ポインタ変数から構造体Nodeのメンバnext、prev（Node型ポインタ変数）にアクセス
    nil->next = nil;
    nil->prev = nil;
}

void printList() {
    Node *cur = nil->next;
    int isf = 0;
    while(1) {
        if (cur == nil) break;
        if (isf++ > 0) printf(" ");
        printf("%d", cur->key);
        cur = cur->next;
    }
    printf("\n");
}

void deleteNode(Node *t) {
    if (t == nil) return;
    t->prev->next = t->next;
    t->next->prev = t->prev;
    free(t);
}

void deleteFirst() {
    deleteNode(nil->next);
}

void deleteLast() {
    deleteNode(nil->prev);
}

void deleteKey(int key) {
    deleteNode(listSearch(key));
}

void insert(int key) {
    Node *x = (Node *)malloc(sizeof(Node));
    x->key = key;
    x->next = nil->next;
    nil->next->prev = x;
    nil->next = x;
    x->prev = nil;
}

int main(){
    int key, n, i;
    int size = 0;
    char com[20];
    int np = 0, nd = 0;
    scanf("%d", &n);
    init();
    for (i = 0; i < n; i++) {
        scanf("%s%d", com, &key);
        if (com[0] == 'i') {
            insert(key);
            np++;
            size++;
        } else if (com[0] == 'd') {
            if (strlen(com) > 6) {
                if (com[6] == 'F') deleteFirst();
                else if (com[6] == 'L') deleteLast();
            } else {
                deleteKey(key); nd++;
            }
            size--;
        }
    }
    
    printList();
    
    return 0;
}



Measured memory_bytes: 34008
#include<iostream>
#include<cmath>
#include<algorithm>
#include <cassert>
using namespace std;
int main() {
	int a = 0, b = 0,c=0,count=0;
	cin >> a;
	if (a % 2 == 1) {
		cout << (a / 2 + 1)*(a / 2);
	}
	if (a % 2 == 0) {
		cout << (a / 2)*(a / 2);
	}
	return 0;
}

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

int A[5];

int main() {
    rep(i, 5) {
        cin >> A[i];
    }

    int last_idx = -1;
    int last_value = -1;
    rep(i, 5) {
        int tmp = A[i] % 10;
        if (tmp != 0 && 10 - tmp > last_value) {
            last_idx = i;
            last_value = 10 - tmp;
        }
    }

    if (last_idx == -1) last_idx = 0;
    // cout << last_idx << endl;

    int ans = 0;
    rep(i, 5) {
        if (i == last_idx) {
            // printf("last %d %d\n", i, A[i]);
            ans += A[last_idx];
        } else {
            while (A[i] % 10 != 0) {
                A[i]++;
            }

            // printf("%d %d\n", i, A[i]);
            ans += A[i];
        }
    }

    cout << ans << endl;

}

Measured memory_bytes: 256
/*
	JAI JAGANNATH!
*/
//@Author : zanj0

#include<bits/stdc++.h>
using namespace std;

typedef long long int lli;

#define ff              first
#define ss              second
#define pb              push_back
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define w(x)            lli x; cin>>x; while(x--)

void zanj0()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
}
void solve() {
	lli n;
	cin >> n;
	vector <lli> a(n);
	vector <lli> b(n);
	for (lli i = 0, x, y; i < n; i++) {
		cin >> x >> y;
		a[i] = x + y;
		b[i] = x - y;
	}
	lli ret = 0;
	lli maxVal = INT_MIN;
	lli minVal = INT_MAX;
	for (lli i : a) {
		maxVal = max(i, maxVal);
		minVal = min(i, minVal);
	}
	ret = max(ret, maxVal - minVal);
	maxVal = INT_MIN;
	minVal = INT_MAX;
	for (lli i : b) {
		maxVal = max(i, maxVal);
		minVal = min(i, minVal);
	}
	ret = max(ret, maxVal - minVal);
	cout << ret << endl;
}
int main()
{
	zanj0();
	solve();
	return 0;
}

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

	int x,y;
	cin>>x>>y;
	
	for(int i=1;x>0||y>0;i++){
		if(x<y){
			cout<<x<<" "<<y<<endl;
		}
		if(y<x){
			cout<<y<<" "<<x<<endl;
		}
		if(x==y){
			cout<<x<<" "<<y<<endl;
		}
		cin>>x>>y;
	}
	return 0;
}

Measured memory_bytes: 1164
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES

#include "bits/stdc++.h"
#include <random>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
#define rep2(i,a,b) for(int i=(a);i<(b);++i)
#define rrep(i,n) for(int i=(n)-1;i>=0;--i)
#define rrep2(i,a,b) for(int i=(a)-1;i>=b;--i)
#define range(i,a,b,c) for(int i=a;\
                    c>0?i<b:\
                    i>b;\
                    i+=c)
#define chmax(a, b) (a = (a) < (b) ? (b) : (a))
#define chmin(a, b) (a = (a) > (b) ? (b) : (a))
using ll = long long;
using ull = unsigned long long;
using ld = long double;
#define all(a) begin(a),end(a)
#define ifnot(a) if(not (a))
#define dump(x)  cerr << #x << " = " << (x) << endl
#define int long long
#ifdef _MSC_VER
const bool test = false;
#else 
const bool test = false;
#endif

int dx[] = { 1,0,-1,0 };
int dy[] = { 0,1,0,-1 };
const int INF = 1 << 28;
const ll INFL = (ll)1 << 58;
ll mod = (int)1e9 + 7;
const double eps = 1e-10;
typedef long double Real;
// return -1, 0, 1
int sgn(const Real& r) { return (r > eps) - (r < -eps); }
int sgn(const Real& a, const Real &b) { return sgn(a - b); }

//.....................
const int MAX = (int)2e5 + 5;

vector<string> split(const string &str, char sep) {
	vector<string> v;
	stringstream ss(str);
	string buffer;
	while (getline(ss, buffer, sep)) {
		v.push_back(buffer);
	}
	return v;
}

template<class InputIterator>
int sum(InputIterator begin, InputIterator end) {
	return accumulate(begin, end, 0ll);
}

string reverse_str(string s) {
	reverse(all(s));
	return s;
}

template<typename T>
T combi(T n, T r) {
	T i;
	T rep = 1;
	if (r > n / 2) r = n - r;
	rep(i, r) {
		rep *= n - i;
		rep /= i + 1;
	}
	return rep;
}

struct Q {
	int p, q;
};

int n;
int a, b;
long double max_ave;

void solve() {
	cin >> n;
	cin >> a >> b;
	vector<int> v(n);
	rep(i, n) cin >> v[i];
	sort(all(v), greater<int>());
	max_ave = (double)accumulate(v.begin(), v.begin() + a, 0ll) / a;

	int cnt = 0;
	int start = 0;

	rep(i, n) {
		if (v[i] == v[a - 1]) {
			start = i;
			break;
		}
	}
	
	rep2(i, a, n) {
		if (v[a-1] == v[i]) cnt++;
		else break;
	}

	cout << fixed << max_ave << endl;
	dump(a + cnt - start);
	dump(cnt);
	int res = 0;

	rep(i, cnt+1) {
		if (i > b - a) break;
		if (i > 0 && v[0] != v[a - 1]) break;
		res += combi(a + cnt - start, cnt - i);
	}

	cout << res << endl;
}

signed main() {
	srand(time(NULL));
	int T = (int)1e15;
	solve();
	cout << fixed << setprecision(15);
	rep(i, T) {
		char s[MAX];
		if (scanf("%s", s) == EOF) break;
		int n = strlen(s);
		for (int i = n - 1; i > -1; i--) {
			ungetc(s[i], stdin);
		}
		solve();
	}
	return 0;
}

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

int main(){
    int a,b,k,res = 0;

    cin >> k;
    cin >> a >> b;

    for( int i = a; i <= b; i++ ){
        if( ( i % k ) == 0 ){
            res = 1;
            break;
        }
    }


    if( res ){
        cout << "OK\n";
    }
    else{
        cout << "NG\n";
    }
}

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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,a,b) for(int i=a;i<b;i++)
#define mod 1000000007
#define ALL(v) (v).begin(),(v).end()
#define ll long long
#define vi vector<int>
#define vll vector<ll>
#define vpii vector<pair<int,int>>
template<class T> T gcd(T a,T b) {return b?gcd(b,a%b):a;}
template<class T> T lcm(T a,T b) {return a/gcd(a,b)*b; }
template<class T> bool isPrime(T num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false;

    double sqrtNum = sqrt(num);
    for (T i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            return false;
        }
    }
    return true;
}

using namespace std;

int a,b,c;
ll n,cnt,ans;

ll F(ll a,ll b)
{
        string s=to_string(a),t=to_string(b);
        return max((int)s.size(),(int)t.size());
}

main()
{
        cin>>n;
        ans=to_string(n).size();

        for(ll i=2;i*i<=n;i++)
        {
                if(n%i!=0)continue;
                else ans=min(ans,F(i,n/i));
        }
        cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <vector>
#include <algorithm>

using namespace std;

const int NMAX = 1e5;

int n,m;
vector<int> graph[NMAX + 5];
int val[NMAX + 5];
bool viz[NMAX + 5];

int dfs(int nod){
	viz[nod] = 1;
	int ans = nod;
	for(auto it:graph[nod]){
		if(!viz[it]){
			int tmp = dfs(it);
			if(val[tmp] < val[ans]){
				ans = tmp;
			}
		}
	}
	return ans;
}

int main(){
	
	scanf("%d %d",&n,&m);
	
	for(int i = 0;i < n;i++){
		scanf("%d",&val[i]);
	}
	
	for(int i = 0;i < m;i++){
		int x,y;
		scanf("%d %d",&x,&y);
		graph[x].push_back(y);
		graph[y].push_back(x);
	}
	
	if(2 * (n - m - 1) > n){
		printf("Impossible");
		return 0;
	}
	
	if(m == n - 1){
		printf("0");
		return 0;
	}
	
	long long ans = 0;
	
	for(int i = 0;i < n;i++){
		if(!viz[i]){
			int tmp = dfs(i);
			ans += val[tmp];
			val[tmp] = 1 << 30;
		}
	}
	
	sort(val,val + n);
	
	for(int i = 0;i < n - m - 2;i++){
		ans += val[i];
	}
	
	printf("%lld",ans);

	return 0;
}

Measured memory_bytes: 6272
#include <iostream>
#include <vector>
#include <algorithm>
 
using namespace std;
 
typedef long long ll;
typedef pair <int, int> pii;
 
#define sz(a) (int)a.size()
#define pb push_back
#define show(a) cerr << #a <<" -> "<< a <<"\n"
#define all(a) a.begin(), a.end() 

const int N = 2e5;
const int INF = 1e9;
 
int n, m, ans, d[N], par[N];
vector <int> g[N];
 
void dfs(int v) {
	for(int to : g[v]) {
		d[to] = max(d[to], d[v] + 1);
		ans = max(d[to], ans);
		--par[to];
		if(!par[to]) 
			dfs(to);
	}
}

int main () {
	ios_base::sync_with_stdio(0);
	cin >> n >> m;
	for(int i = 1; i <= m; ++i) {
		int a, b;
		cin >> a >> b;
		g[a].pb(b);
		++par[b];
	}
	for(int i = 1; i <= n; ++i) {
		g[0].pb(i);
		d[i] = -INF;
		++par[i];
	}
	dfs(0);
	cout << ans - 1;
	return 0;
}























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

int main() {
    int N;
    cin >> N;
    vector<int> high(N + 1, 0);
    for (int i = 1; i < N + 1; i++) {
        cin >> high[i];
    }
    vector<int> dp(N + 1, 0);
    dp[1] = 0;
    dp[2] = abs(high[2] - high[1]);
    for (int i = 3; i < N + 1; i ++) {
        int one = abs(high[i - 1] - high[i]) + dp[i - 1];
        int two = abs(high[i - 2] - high[i]) + dp[i - 2];
        dp[i] = min(one, two);     
    }
    
    cout << dp[N] << endl;
}

Measured memory_bytes: 3860
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
      	int k = sc.nextInt();
      
      	if(k == 1) System.out.println(0);
      	else System.out.println(n-k);
	}
}


Measured memory_bytes: 35516
#include<bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define repk(i,k,n) for (ll i = k; i < (ll)(n); ++i)
#define MOD 1000000007
typedef long long  ll;

using namespace std;

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

	int N;
	cin >> N;

	vector<pair<int, int>> A(N);
	rep(i, N) {
		cin >> A[i].first;
		A[i].second = i + 1;
	}

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

	rep(i, N) {
		cout << A[i].second << " ";
	}
	cout << endl;

	return 0;
}

Measured memory_bytes: 3960
#include<bits/stdc++.h>
#define mod 1000000007
using namespace std;
#define f(i, n) for(int i = 0; i < n; ++i)
#define pb push_back
typedef long long int ll;


void input(){
   int a, b;
   cin >> a >> b;
   cout << max(a + b, max(a - b, a * b)) << endl;
}
int main()
{
 input();
 return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define x first
#define y second
#define pb push_back
#define mp make_pair
#define up_b upper_bound
#define low_b lower_bound
#define sz(x) (int)x.size()
#define all(v) v.begin(),v.end()
#define nl '\n'

#define boost ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)

using namespace std;

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

const ll INF=1e18;
const int inf=1e9;
const ld eps=1e-7;
const ld pi=acos(-1);
const int dx[8]={0,0 ,1,-1,1,1,-1,-1};
const int dy[8]={1,-1,0,0,1,-1,1,-1};
const int mod1=998244353;
const int mod2=1e9+7;
const int N=1e5+11;

int main(){
  boost;

  int m,d;
  cin>>m>>d;
  int ans=0;
  for(int i=1;i<=m;i++){
    for(int j=22;j<=d;j++){
      if(j%10>1&&j/10>1){
        int x=(j%10)*(j/10);
        if(x==i){
          ans++;
        }
      }
    }
  }
  cout<<ans;

  return 0;
}


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



#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)

using namespace std;

template <class T>
using vec = std::vector<T>;
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 long long INF = 1LL<<60;

int lcm(int a,int b){
    //最小公倍数
    return a/__gcd(a,b) * b;
}

int x,y,z;



int main()
{
    cin>>x>>y>>z;
    cout<<z<<" "<<x<<" "<<y<<endl;
    return 0;

}




Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>

#define MAX 200000

int prime[MAX + 1];

int main(){
  int x;
  int limit;
  int i,j;

  scanf("%d", &x);

  for(i = 2;i <= MAX;i++) prime[i] = 1;
  limit = sqrt(MAX);

  for(i = 2;i <= limit;i++){
    if(prime[i] == 1){
      for(j = i*2;j <= MAX;j++){
        if(j % i == 0) prime[j] = 0;
      }
    }
  }

  while(prime[x] != 1) x++;

  printf("%d\n", x);

  return 0;
}


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

using namespace std;

#define LL long long

const int MAXN = 200000 + 5;


int calPopCount(int N, string S){
    int ret = 0;
    for (int i = 0; i < N; i ++){
        if (S[i] == '1'){
            ret ++;
        }
    }
    return ret; 
}

void calMod(int N, string S, int cnt, int *c){

    if (cnt > 0){
        c[N - 1] = 1 % cnt;
        for (int i = N - 2; i >= 0; i --){
            c[i] = (c[i + 1] << 1) % cnt;
        }
    }
    else{
        for (int i = 0; i < N; i ++){
            c[i] = 0;
        }
    }
}

int f(int m){
    int cnt = 0;
    for (int i = 0; (1 << i) <= m;  i ++){
        if ((1 << i) & m){
            cnt ++;
        }
    }
    return m % cnt;
}

void print(int m){
    int ans = 1;
    while (m > 0){
        m = f(m);
        ans ++;
    }
    cout << ans << endl;
}

void solve(int N, string S, int cnt, int *a, int *b){
    
    int m = 0;
    int ret = 0;
    int aa, bb;
    aa = bb = 0;
    for (int i = 0; i < N; i ++){
        if (S[i] == '1'){
            if (cnt > 1)
            {
                aa = (aa + a[i]) % (cnt - 1);
            }
            else
            {
                aa = 0;
            }
            
            bb = (bb + b[i]) % (cnt + 1);
        }
    }
    for (int i = 0; i < N; i ++){
        if (S[i] == '0'){
            S[i] = '1';
            int m = (bb + b[i]) % (cnt + 1);
            
            print(m);
            S[i] = '0';
        }
        else{
            S[i] = '0';
            int m = 0;
            if (cnt > 1)
            {   
                m = (aa + cnt - 1 - a[i]) % (cnt - 1);
                print(m);
            }
            else{
                cout << "0" << endl;
            }
            S[i] = '1';
        }
    }


}



int main()
{
    int N, a[MAXN], b[MAXN];
    string S;
    cin >> N >> S;

    int cnt = calPopCount(N, S);
    calMod(N, S, cnt - 1, a);
    calMod(N, S, cnt + 1, b);
    
    solve(N, S, cnt, a, b);



    system("pause");
    return 0;
}

Measured memory_bytes: 5356
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
int main(void){
    unsigned long long int a,b,k;
    scanf("%llu %llu %llu",&a,&b,&k);
    if(a + b == k){
        printf("0 0");
        return 0;
    }
    if(k > a){
        k -= a;
        a = 0;
        if(k > b){
            b = 0;
        }else{
            b -= k;
        }
    }else{
        a -= k;
    }
    printf("%llu %llu",a,b);
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vb = vector<bool>;
using vl = vector<long>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvb = vector<vector<bool>>;
using vvc = vector<vector<char>>;
using vvl = vector<vector<long>>;
using pii = pair<int, int>;
using pil = pair<int, long>;
using pll = pair<long, long>;
#define fix20 cout << fixed << setprecision(20)
#define YES cout << "Yes" << endl
#define NO cout << "No" << endl
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define REP(i,s,t) for(int i=s; i<t; i++)
#define RNG(i,s,t,u) for(int i=s; i<t; i+=u)
#define MOD 1000000007
#define all(vec) vec.begin(), vec.end()
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(){
  long x,k,d;
  cin >> x >> k >> d;
  long px = abs(x);
  long b = px / d;
  long r = px % d;
  if(b > k){
    cout << px - k*d << endl;
  }else{
    k -= b;
    if(k % 2 == 0) cout << r << endl;
    else cout << d - r << endl;
  }
}

Measured memory_bytes: 3672
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Scanner;
import java.util.Set;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		// 地点数の入力
		int n = sc.nextInt();

		List<Integer> list = new ArrayList<Integer>();

		for (int i = 1; i <= n; i++) {
			list.add(sc.nextInt());
		}

		for (int i = 0; i < n-1; i++) {
			int before = list.get(i);
			int after  = list.get(i+1);
			//System.out.println(before + " " + after);
			if (before==after) {
              //System.out.println("bef=after");
              continue;
            }
			if (before<=after-1) {
                //System.out.println("minus1");
				list.set(i+1, after-1);
				continue;
			} else {
				System.out.println("No");
				return;
			}
		}

		System.out.println("Yes");

	}}

Measured memory_bytes: 65044
# C - Sum of GCD of Tuples (Easy)

k = int(input())

def gcd(x, y):
    while x % y != 0:
        x, y = y, x % y
    return y

s = 0
for a in range(1, k + 1):
    for b in range(1, k + 1):
        s += gcd(a, b)
        for c in range(b + 1, k + 1):
            s += gcd(gcd(a, b), c) * 2
print(s)


Measured memory_bytes: 74240
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
#define equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
//const ll mod = 1000000007;
//const ll mod = 998244353;
const int inf = 1e9 + 10;
const ll INF = 1e18;
const ld EPS = 1e-10;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
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 (a>b) { a=b; return 1; } return 0; }



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

  int n, x, t;
  cin >> n >> x >> t;

  cout << (n + x - 1) / x * t << '\n';

  
  return 0;
}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
#define N 1005
#define ll long long int 	
#define MP make_pair
#define pb push_back
#define ppb pop_back
#define sp " "
#define endl "\n"
#define fi first
#define se second
#define ii pair<int,int>
#define lli pair<ll,ll>
#define fast cin.tie(0);cout.tie(0);ios_base::sync_with_stdio(false)
#define fast2 freopen ("kmp.in","r",stdin);freopen ("kmp.out","w",stdout);
#define mod 1000000009
#define fs(x,y) for(int i=1;i<=y;i++) cin>>x[i]
#define fo(i,x,y) for(int i=x;i<=y;i++)
#define INF 1000000000005
using namespace std;

ll n,m,ar[N][N],last[N],mark[N],sum,top;

int main()
{
	fast;
	cin>>n;
	fo(i,1,n)
		fo(j,1,n-1)
			cin>>ar[i][j];
	// cout<<endl<<endl;
	while(sum<n*(n-1)/2)
	{
		top++;
		ll flag=0;
		// cout<<top<<sp<<sum<<endl;
		for(int i=1;i<=n;i++)
		{
			ll x=ar[i][last[i]+1];
			if(mark[i] || last[i]>=n-1 || last[x]>=n-1)
				continue;
			if(mark[x] || mark[i] || ar[x][last[x]+1]!=i)
				continue;
			// cout<<x<<sp<<last[i]<<sp<<last[x]<<endl;
			sum++;
			last[i]++;
			last[x]++;
			mark[i]++;
			mark[x]++;
			flag=1;


		}
		// cout<<endl<<endl<<endl;
		if(flag==0)
			return cout<<-1,0;
		memset(mark,0,sizeof(mark));
	}


	cout<<top;

}



/*     cd onedrive\desktop\kod
cls


*/

Measured memory_bytes: 8192
using namespace std;
#include<bits/stdc++.h>
#define BEGIN ios_base::sync_with_stdio(0);cin.tie(0);
#define END return EXIT_SUCCESS;
#define FOR(I,A,B) for((I)=(A);(I)<(B);(I)++)
#define REP(I,N) FOR((I),0,(N))
#define UP(I,A,B) for((I)=(A);(I)<=(B);(I)++)
#define DW(I,A,B) for((I)=(A);(I)>=(B);(I)--)
#define IN(P) cin>>(P)
#define IN2(P1,P2) cin>>(P1)>>(P2)
#define IN3(P1,P2,P3) cin>>(P1)>>(P2)>>(P3)
#define INS(I,N,V) REP((I),(N)) cin>>(V[I])
#define INS2(I,N,V1,V2) REP((I),(N)) cin>>(V1[I])>>(V2[I]);
#define INS3(I,N,V1,V2,V3) REP((I),(N)) cin>>(V1[I])>>(V2[I])>>(V3[I]);
#define OUT(P) cout<<(P)<<endl
#define OUT2(P1,P2) cout<<(P1)<<" "<<(P2)<<endl
#define OUT3(P1,P2,P3) cout<<(P1)<<" "<<(P2)<<" "<<(P3)<<endl
#define OUTS(I,N,V) REP((I),(N)) cout<<(V[i])<<endl
#define ALL(C) (C).begin(),(C).end()
#define RALL(C) (C).rbegin(),(C).rend()
#define mp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound
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;}

string A,B;
long C,D;
inline void solve(){
  IN2(A,B);
  C=A.size();
  D=B.size();
  if(C>D)OUT("GREATER");
  else if(C<D)OUT("LESS");
  else if(A>B)OUT("GREATER");
  else if(A<B)OUT("LESS");
  else OUT("EQUAL");
}

int main(int argc,char**argv){
  BEGIN
  solve();
  END
}


Measured memory_bytes: 256
import java.io.BufferedInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.Arrays;

public class Main {

	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		char[] N = sc.next().toCharArray();

		System.out.println(N[0] == N[2] ? "Yes" : "No");
	}

	private static boolean isDebug = System.getProperty("sun.desktop") != null;

	private static void debug(Object... o) {
		if (isDebug) {
			System.err.println(Arrays.deepToString(o));
		}
	}

	public static class Scanner {
		private BufferedInputStream inputStream;
		private StringBuilder buffer = new StringBuilder();

		public Scanner(InputStream in) {
			inputStream = new BufferedInputStream(in);
		}

		public int nextInt() throws IOException {
			int num = 0;
			int sign = 1;

			int read = skip();
			if (read == '-') {
				sign = -1;
				read = inputStream.read();
			}

			do {
				num = num * 10 + sign * (read - 0x30);
			} while ((read = inputStream.read()) > 0x20);

			return num;
		}

		public void fill(int[] a) throws IOException {
			for (int i = 0; i < a.length; i++) {
				a[i] = nextInt();
			}
		}

		public void fill(int[] a, int[] b) throws IOException {
			if (a.length != b.length) {
				throw new IllegalArgumentException();
			}

			for (int i = 0; i < a.length; i++) {
				a[i] = nextInt();
				b[i] = nextInt();
			}
		}

		public long nextLong() throws IOException {
			long num = 0;
			int sign = 1;

			int read = skip();
			if (read == '-') {
				sign = -1;
				read = inputStream.read();
			}

			do {
				num = num * 10 + sign * (read - 0x30);
			} while ((read = inputStream.read()) > 0x20);

			return num;
		}

		public void fill(long[] a) throws IOException {
			for (int i = 0; i < a.length; i++) {
				a[i] = nextLong();
			}
		}

		public void fill(long[] a, long[] b) throws IOException {
			if (a.length != b.length) {
				throw new IllegalArgumentException();
			}

			for (int i = 0; i < a.length; i++) {
				a[i] = nextLong();
				b[i] = nextLong();
			}
		}

		public long[] nextLong(int n) throws IOException {
			long[] array = new long[n];
			for (int i = 0; i < n; i++) {
				array[i] = nextLong();
			}

			return array;
		}

		public String next() throws IOException {
			int read = skip();
			do {
				buffer.append((char) read);
			} while ((read = inputStream.read()) > 0x20);

			String text = buffer.toString();
			buffer.delete(0, buffer.length());

			return text;
		}

		private int skip() throws IOException {
			int read;
			while ((read = inputStream.read()) <= 0x20)
				;

			return read;
		}
	}
}

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

#define FOR(i,a,b) for (auto i=(a);i<(b);i++)
#define RFOR(i,a,b) for (auto i=(b)-1;i>=(a);i--)
#define REP(i,n) for (auto i=0;i<(n);i++)
#define RREP(i,n) for (auto i=(n)-1;i>=0;i--)
#define EACH(i,v) for(auto &i : v)
#define inf INT_MAX/3
#define INF INT_MAX/3
#define eps 1e-15
#define EPS 1e-15
#define TEN9 1000000000
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SET(a,c) memset(a,c,sizeof a)
#define CLR(a) memset(a,0,sizeof a)
#define pii pair<int,int>
#define pcc pair<char,char>
#define pic pair<int,char>
#define pci pair<char,int>
#define mii map<int,int>
#define msd map<string,double>
#define msi map<string,int>
#define ti3 tuple<int,int,int>
#define VS vector<string>
#define VI vector<int>
#define debug(x) cout<<#x<<": "<<x<<endl
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define MIN(a,b) (a>b?b:a)
#define MAX(a,b) (a>b?a:b)
#define pi 2*acos(0.0)
#define INFILE() freopen("in0.txt","r",stdin)
#define OUTFILE()freopen("out0.txt","w",stdout)
#define in scanf
#define out printf
#define LL long long
#define ll long long
#define ULL unsigned long long
#define ull unsigned long long
#define FST first
#define SEC second
#define SORT(v) sort(ALL(v));
#define VVI(v,n1,n2) vector<vector<int> > v(n1, vector<int>(n2, 0));
#define int(x) int x; scanf("%d",&x);
#define lint(x) long long x; scanf("%lld",&x);
#define vint(v,n) vector<int> v(n); REP(i,n) scanf("%d", &v[i]);
#define vvint(v,n1,n2) vector<vector<int> > v(n1, vector<int>(n2, 0)) ; REP(i,n1) REP(j,n1) scanf("%d", &v[i][j]);
#define vlint(v,n) vector<ll int> v(n); REP(i,n) scanf("%lld", &v[i]);
#define vvlint(v,n1,n2) vector<vector<ll int> > v(n1, vector<ll int>(n2, 0)); REP(i,n1) REP(j,n1) scanf("%lld", &v[i][j]);
#define double(x) double x; scanf("%lf",&x);
#define vdouble(v,n) vector<double> v(n); REP(i,n) scanf("%lf", &v[i]);
#define vvdoube(v,n1,n2) vector<vector<double> > v(n1, vector<double>(n2, 0)); REP(i,n1) REP(j,n1) scanf("%lf", &v[i][j]);
#define char(x) char x; scanf("%c",&x);
#define vchar(v,n) vector<char> v(n); REP(i,n) scanf("%c", &v[i]);
#define vvchar(v,n1,n2) vector<vector<char> > v(n1, vector<char>(n2, 0)); REP(i,n1) REP(j,n1) scanf("%c", &v[i][j]);
#define string(x) string x; cin >> x;
#define vstring(v,n) vector<string> v(n); REP(i,n) cin >> v(i);

#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]));


ll int  dp[200][200][3001]={0};

int main(){

    int(N)
    int(A)
    vint(v, N)
    dp[0][0][0] = 1;
    FOR(j, 0, N){
        FOR(k, 0, N+1){
            REP(l, A*N+1){
                dp[j+1][k][l]+=dp[j][k][l];
			    dp[j+1][k+1][l+v[j]]+=dp[j][k][l];
            }
        }
    }
    ll int ans = 0;
    FOR(k, 1, N+1){
        ans += dp[N][k][k*A];
    }
    printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 61184
package main

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

var sc = func() *bufio.Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	return sc
}()

func getInt() (n int) {
	sc.Scan()
	n, _ = strconv.Atoi(sc.Text())
	return n
}

func getString() string {
	sc.Scan()
	return sc.Text()
}

func main() {
	N := getInt()
	a := make([]int, N)
	x := make([]int, N)
	y := make([]int, N)
	for i := 0; i < N; i++ {
		a[i] = i
		x[i] = getInt()
		y[i] = getInt()
	}

	A := getMatrix(a)
	B := 0.0
	for _, v := range A {
		for j := 0; j < len(v)-1; j++ {
			B += math.Sqrt(float64((x[v[j]]-x[v[j+1]])*(x[v[j]]-x[v[j+1]]) +
				(y[v[j]]-y[v[j+1]])*(y[v[j]]-y[v[j+1]])))
		}
	}

	fmt.Println(B / float64(len(A)))
}

func getMatrix(a []int) [][]int {
	c := make([][]int, 0, kaijou(len(a)))
	if len(a) == 1 {
		c = append(c, a)
	} else {
		for _, v1 := range a {
			b := make([]int, 0, len(a)-1)
			for _, v2 := range a {
				if v1 == v2 {
					continue
				}
				b = append(b, v2)
			}
			d := getMatrix(b)
			for _, v3 := range d {
				c = append(c, append(v3, v1))
			}
		}
	}
	return c
}

func kaijou(a int) (b int) {
	for i := 1; i <= a; i++ {
		b *= i
	}
	return
}


Measured memory_bytes: 8576
#include<bits/stdc++.h>
#define N 5005
#define inf N*N
#define _to e[i].to
using namespace std;

struct edge{
	int to,_next;
}e[N<<1];
int head[N],size,ans=inf;
void add(int from,int to){
	e[++size].to=to,e[size]._next=head[from],head[from]=size;
}

int f[N],dis[N],a[N],n,x,y,sz[N];

void dfs(int k,int fa){
	int mx=0;
	for(int i=head[k];i;i=e[i]._next)
		if(_to!=fa)
			dfs(_to,k),sz[k]+=sz[_to],dis[_to]+=sz[_to],dis[k]+=dis[_to],mx=dis[mx]<dis[_to]?_to:mx;
	if(!mx)return (void)(f[k]=0);
	if(dis[k]>=dis[mx]*2)f[k]=dis[k]/2;
	else f[k]=dis[k]-dis[mx]+min(f[mx],dis[mx]*2-dis[k]);
}

int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
		scanf("%1d",&a[i]);
	for(int i=1;i<n;i++)
		scanf("%d%d",&x,&y),add(x,y),add(y,x);
	for(int i=1;i<=n;i++){
		for(int j=1;j<=n;j++)
			dis[j]=f[j]=0,sz[j]=a[j];
		dfs(i,0);
		if(dis[i]&1)continue;
		if(f[i]*2>=dis[i])ans=min(ans,dis[i]/2);
	}
	printf("%d",(ans==inf)?-1:ans);
	return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <iomanip>
#include <climits>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<string> VS;
typedef vector< vector<int> > VVI;
typedef vector< vector<ll> > VVL;
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define all(a) (a).begin(),(a).end()
#define pf push_front
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define ub upper_bound
#define lb lower_bound

int main(){
  ll H,W,N;
  cin>>H>>W>>N;
  VI A(N),B(N);
  rep(i,N) cin>>A[i]>>B[i];
  map<PII,int> M;
  rep(i,N){
    auto add=[&](int C,int D,int E,int F){
      if(C+E<1 or C+E>H-2 or D+F<1 or D+F>W-2) return;
      M[mp(C+E,D+F)]++;
    };
    rep(j,3) rep(k,3) add(A[i]-1,B[i]-1,j-1,k-1);
  }
  VL ans(10);
  auto itr=M.begin();
  rep(i,M.size()){
    ans[itr->second]++;
    itr++;
  }
  ans[0]=(H-2)*(W-2);
  rep(i,9) ans[0]-=ans[i+1];
  rep(i,10) cout<<ans[i]<<endl;
}

Measured memory_bytes: 57344
def main():
    MOD = 10 ** 9 + 7
    N = int(input())
    A = [list(map(int, input().split(' '))) for _ in range(N)]
    dp = [0 for _ in range(1 << N)]
    dp[0] = 1
    for s in range(1, 1 << N):
        women_list = [w for w in range(N) if (s >> w) & 1 == 1]
        man = len(women_list) - 1
        val = 0
        for woman in women_list:
            val += A[man][woman] * dp[s - (1 << woman)]
        val %= MOD
        dp[s] += val
    print(dp[(1 << N) - 1])


if __name__ == '__main__':
    main()


Measured memory_bytes: 123496