akhauriyash/Code-Regression huggingface dataset:
import itertools
import math

n = int(input())
x = [0] * n
y = [0] * n

for i in range(n):
    x[i], y[i] = map(int, input().split())


def solve():
    patterns = list(itertools.permutations(range(n)))

    sum_ans = []

    for pattern in patterns:
        tmp_ans = []
        for j in range(n - 1):
            now_city = pattern[j]
            next_city = pattern[j + 1]
            tmp = (x[now_city] - x[next_city]) ** 2 + (y[now_city] - y[next_city]) ** 2
            tmp_ans.append(
                math.sqrt(tmp)
            )
        sum_ans.append(
            sum(tmp_ans)
        )

    return sum(sum_ans) / len(patterns)


print(solve())


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

#define endl '\n'
#define pi 3.1415926

using namespace std;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N, M;
    cin >> N >> M;
    int A[M];
    long long sum = 0;
    for(int i = 0; i < M; i++) {
        cin >> A[i];
        sum += A[i];
    }
    if(sum > N)
        cout << "-1" << endl;
    else 
        cout << N - sum << endl;
    return 0;
}

Measured memory_bytes: 3676
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <functional>

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

using namespace std;

typedef    long long          ll;
typedef    unsigned long long ull;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      pii;

const int INF=1<<29;
const double EPS=1e-9;

const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};
int n;
int main(){
	while(cin>>n,n){
		int a[10]={0};
		rep(i,n){
			int x;
			cin>>x;
			x /=10;
			if(x>=6){
				a[6]++;
			}else{
				a[x]++;
			}
		}
		rep(i,7){
			cout <<a[i]<<endl;
		}
	}
	return 0;
}

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

//バブルソートと選択ソートでトランプを昇順に並び替え、安定かを判断するプログラム
int main(){
    int N, i, j, flag, min, judge = 0;
    string prev, array[36] = {}, bubble_array[36] = {}, select_array[36] = {};
    
    //トランプを配列に格納
    cin >> N;
    i = 0;
    while(i < N){
        cin >> array[i];
        bubble_array[i] = array[i];
        select_array[i] = array[i];
        i++;
    }

    //バブルソート
    flag = 1;
    while(flag){
        flag = 0;
        i = N - 1;
        while(i > 0){
            if (bubble_array[i][1] < bubble_array[i-1][1]){
                prev = bubble_array[i];
                bubble_array[i] = bubble_array[i-1];
                bubble_array[i-1] = prev;
                flag = 1;
            }
            i--;
        }
    }

    //結果の出力
    i = 0;
    while(i < N){
        cout << bubble_array[i];
        if (i < N-1) cout << ' ';
        i++;
    }
    cout << endl;

    //安定かどうかの判定とその出力
    cout <<  "Stable" << endl;      //バブルソートは常に安定なソート


    //選択ソート
    for(i=0; i <= N-1; i++){
        min = i;
        for(j = i; j <= N-1; j++){
            if (select_array[j][1] < select_array[min][1]) min = j;
        }
        prev = select_array[i];
        select_array[i] = select_array[min];
        select_array[min] = prev;
    }

    //結果の出力
    i = 0;
    while(i < N){
        cout << select_array[i];
        if (i < N-1) cout << ' ';
        i++;
    }
    cout << endl;
    
    //安定かどうかの判定とその出力
    i = 0;
    while(i < N){
        if (bubble_array[i][0] != select_array[i][0]) judge = 1;
        i++;
    }
    if (judge == 0) cout << "Stable" << endl;
    else if (judge == 1) cout << "Not stable" << endl;


    return 0;
}


Measured memory_bytes: 3224
S=input()
A=0
if S[0]=='A':
  for i in range(2,len(S)-1):
    if S[i]=='C':
      A+=1
      B=i
  if A==1:
    S=S[1:B]+S[B+1:]
    if S.islower():
      print('AC')
    else:
      print('WA')
  else:
    print('WA')
else:
  print('WA')

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#include <vector>
#include <string>

using namespace std;

vector<string> split(const string &s, char delim) {
  vector<string> elems;
  string item;
  for (char ch: s) {
    if (ch == delim) {
      if (!item.empty()) {
        elems.push_back(item);
      }
      item.clear();
    }
    else {
      item += ch;
    }
  }
  if (!item.empty()) {
    elems.push_back(item);
  }
  return elems;
}

string to_str_with_zero(int i, int w) {
  ostringstream sout;
  sout << std::setfill('0') << std::setw(w) << i;
  string s = sout.str();
  return s;
}

int main() {
  std::cout << std::setprecision(9);
  int n, m;
  cin >> n >> m;

  vector<bitset<10>> stols(m);
  for (int i=0; i<m; i++) {
    int k;
    cin >> k;
    for (int j=0; j<k; j++) {
      int s;
      cin >> s;
      stols.at(i).set(s - 1, 1);
    };
  }

  vector<int> p(m);
  for(int i=0; i<m; i++) {
    cin >> p.at(i);
  }

  int ans = 0;
  for (int tmp=0; tmp < (1 << 10); tmp++) {
    if (tmp >= pow(2, n)) {
      break;
    }
    bitset<10> lightset(tmp);
    
    bool all_on = true;
    for (int i=0; i<m; i++) {
      bitset<10> on = lightset & stols.at(i);
      if (on.count() % 2 != p.at(i)) {
        all_on = false;
      }
    }
    if (all_on) {
      ans++;
    }
  }

  cout << ans << endl;
}

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

using namespace std;

int64_t euler_phi(int64_t n) {
  int64_t ret = n;
  for(int64_t i = 2; i * i <= n; i++) {
    if(n % i == 0) {
      ret -= ret / i;
      while(n % i == 0) n /= i;
    }
  }
  if(n > 1) ret -= ret / n;
  return ret;
}

int main() {
  int N;
  cin >> N;
  cout << euler_phi(N) << endl;
}



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

int main(){
    int n;
    cin >> n;
    vector<int> w(n);
    rep(i, n) cin >> w[i];
    int s1, s2;
    s1 = 0;
    rep(i, n) s2 += w[i];
    int ans = s2;
    rep(i, n){
        s1 += w[i];
        s2 -= w[i];
        ans = min(ans, abs(s1 - s2));
    }
    cout << ans <<endl;
    return 0;
}

Measured memory_bytes: 256
package main

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

func main() {
	nextReader = newScanner()
	a, b := nextInt(), nextInt()
	fmt.Println(a * b)
}

// ---------------------------------------------------------------
// I/O
// ---------------------------------------------------------------
var nextReader func() string

func newScanner() func() string {
	sc := bufio.NewScanner(os.Stdin)
	sc.Buffer(make([]byte, 1024), int(1e11))
	sc.Split(bufio.ScanWords)
	return func() string {
		sc.Scan()
		return sc.Text()
	}
}

func nextString() string { return nextReader() }

func nextInt() int { n, _ := strconv.Atoi(nextReader()); return n }

func nextInts(size int) []int {
	ns := make([]int, size)
	for i := 0; i < size; i++ {
		ns[i] = nextInt()
	}
	return ns
}


Measured memory_bytes: 1756
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define all(x) x.begin(),x.end()
#define dbg(x) cout<<#x<<":"<<x<<endl
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<ll,P> PP;

int main(){
  ll n,a[111111];
  cin>>n;
  ll ans=0;
  for(int i=0;i<n;i++)
    cin>>a[i];
  for(int i=0;i<n-1;i++){
    if(a[i]%2&&a[i+1]>0){
	 a[i+1]--;
	 ans+=(a[i]+1)/2;
	 continue;
    }
    ans+=a[i]/2;
  }
  cout<<a[n-1]/2+ans<<endl;
  return 0;
}



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

#define FOR(i,l,r) for(int i = int(l);i < int(r);i++)
template<typename T> bool chmax(T& a,const T& b){ return a < b ? (a = b,true) : false; }
template<typename T> bool chmin(T& a,const T& b){ return b < a ? (a = b,true) : false; }
typedef long long ll;

struct UnionFind{
	vector<int> par,rank;
	UnionFind(int n) :par(n + 1),rank(n + 1,1){
		for(int i = 1;i <= n;i++) par [i] = i;
	}
	int find(int x){
		return par [x] == x ? x : par [x] = find(par [x]);
	}
	bool unite(int x,int y){
		x = find(x);
		y = find(y);
		if(x == y) return false;
		if(rank [x] < rank [y]) swap(x,y);
		rank [x] += rank [x] == rank [y];
		par [y] = x;
		return true;
	}
	bool same(int x,int y){
		return find(x) == find(y);
	}
};

int N,M;
pair<int,int> E [100];

int main()
{
	cin >> N >> M;
	FOR(i,0,M){
		cin >> E [i].first >> E [i].second;
		E [i].first--;
		E [i].second--;
	}

	int ans = 0;
	FOR(i,0,M){
		UnionFind uf(N);
		int cnt = 0;
		FOR(j,0,M) if(j != i){
			cnt += uf.unite(E [j].first,E [j].second);
		}
		ans += cnt < N - 1;
	}
	cout << ans << endl;

	return 0;
}


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

string s;
string num;
int res;

int main()
{
	cin >> s;
	for (int i = 0; i < s.length(); i++) if (s[i] >= '1') {
		for (int j = 0; j < i; j++)
			num[j] = s[j];
		num[i] = s[i] - 1;
		for (int j = i + 1; j < s.length(); j++)
			num[j] = '9';
		int got = 0;
		for (int j = 0; j < s.length(); j++)
			got += num[j] - '0';
		res = max(res, got);
	}
	int got = 0;
	for (int i = 0; i < s.length(); i++)
		got += s[i] - '0';
	res = max(res, got);
	printf("%d\n", res);
	return 0;
}

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

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

    long long a[n+1], b[n+1];

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

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

    b[0] = 1 - a[0];
    vector<long long> A(n+2, 0);
    for(long long i = 0; i <= n; i++){
        A[i+1] = A[i] + a[i];
    }

    bool flag = true;
    for(long long i = 1; i <= n; i++){
        long long sum = A[n+1] - A[i+1];
        b[i] = min(sum, 2*b[i-1] - a[i]);
        //printf("sum %lld 2*b[i-1] - a[i] %lld\n", sum, 2*b[i-1] - a[i]);
        if(b[i] < 0){
            flag = false;
            break;
        }
    }

    if(flag == false){
        printf("-1\n");
        return 0;
    }

    long long count = 0;
    for(long long i = 0; i <= n; i++){
        count += a[i] + b[i];
    }

    cout << count << endl;

    return 0;
}

Measured memory_bytes: 5584
def main():
    import copy
    n,k = map(int,input().split())
    v = list(map(int,input().split()))
    ans = 0
    for i in range(min(n+1,k+1)):
        t = v[0:i]
        for j in range(min(n-i+1,k-i+1)):
            t_ = copy.deepcopy(t)
            t_ += v[n-j:n]
            
            r = k-i-j
            t_ = sorted(t_)
            cnt = 0
            for l in range(len(t_)):
                if t_[l]<0 and cnt<r:
                    t_[l] = 0
                    cnt += 1
                else:
                    break
            if ans<sum(t_):
                ans = sum(t_)
    print(ans)

if __name__ == "__main__":
    main()


Measured memory_bytes: 9368
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for (ll i = m; i < n; i++)
#define IFOR(i, m, n) for (ll i = n - 1; i >= m; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#define FOREACH(x, a) for (auto&(x) : (a))
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) ll(x.size())

int main() {
  ll a, b, c;
  cin >> a >> b >> c;
  ll t = c - a - b;
  if (t <= 0) {
    cout << "No" << endl;
    return 0;
  }
  cout << (4 * a * b < t * t ? "Yes" : "No") << endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const long long MOD = 1e9+7, MAx = 1e18, larg = 1e5, INF = -1e9;
long long A,B,C,D,E,F,G,H,I,J,K,L,N,M,O,P,Q,R,S,T,U,V,W,x,y,z;
long long max_value = INF, max_index = -1;
long long min_value = MAx, min_index = -1;

typedef long long ll;
typedef pair<ll, ll> Pa;
    int wa[100001];

int main() {
    int acs = 0, was = 0;
    cin >> N >> M;
    string s;
    rep(i, N) wa[i] = 0;
    rep(i, M){
        cin >> P >> s;
        if(s == "AC"){
            if(wa[P] != -1) {
                was += wa[P];
                wa[P] = -1;
                acs++;
            }
        }else{
            if(wa[P] != -1) wa[P]++;
        }
    }
    cout << acs << " " << was;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define rep(i, a, b) for(int i = (a); i < (b); ++i)
#define per(i, a, b) for(int i = (b) - 1; i >= (a); --i)
#define sz(a) (int)a.size()
#define de(c) cout << #c << " = " << c << endl
#define dd(c) cout << #c << " = " << c << " "
#define all(a) a.begin(), a.end()
#define pw(x) (1ll<<(x))
#define endl "\n"
typedef long long ll;
typedef double db;
typedef pair<int, int> pii;
typedef vector<int> vi;

typedef db T;
const db eps = 1e-9 , pi = acosl(-1.);
int sgn(T x){return (x>eps)-(x<-eps);}
struct P{
  T x,y; P(){} P(T x,T y):x(x),y(y){}
  P operator - (const P&b) const {return P(x-b.x,y-b.y);}
  P operator + (const P&b) const {return P(x+b.x,y+b.y);}
  T operator * (const P&b) const {return x*b.x+y*b.y;}
  T operator / (const P&b) const {return x*b.y-y*b.x;}
  P operator * (const T&k) const {return P(x*k,y*k);}
  P operator / (const T&k) const {return P(x/k,y/k);}
};
T norm(P a){return a*a;}
T abs(P a) {return sqrtl(norm(a));}
P proj(P p,P a,P b){return (b-a)*((p-a)*(b-a)/norm(b-a))+a;}
P reflect(P p,P a,P b){return proj(p,a,b)*2-p;}
T cross(P o,P a,P b){return (a-o)/(b-o);}
int crossOp(P o,P a,P b){return sgn(cross(o,a,b));}
bool onPS(P p,P s,P t){return sgn((t-s)/(p-s))==0&&sgn((p-s)*(p-t))<=0;}
struct L{ P s,t;L(){} L(P s,P t):s(s),t(t){}};
P insLL(L a,L b){ // line x line
  P s = a.s - b.s , v = a.t - a.s , w = b.t - b.s;
  db k1 = s / w , k2 = w / v;
  if(sgn(k2) == 0) return abs(b.s - a.s) < abs(b.t - a.s) ? b.s : b.t;
  return a.s + v * (k1 / k2);
}
bool isSS(L a,L b){ // seg x seg , replace x->y to accelerate
  T c1=(a.t-a.s)/(b.s-a.s),c2=(a.t-a.s)/(b.t-a.s);
  T c3=(b.t-b.s)/(a.s-b.s),c4=(b.t-b.s)/(a.t-b.s);
  return sgn(c1) * sgn(c2) <= 0 && sgn(c3) * sgn(c4) <= 0 &&
    sgn(max(a.s.x,a.t.x) - min(b.s.x,b.t.x)) >= 0 &&
    sgn(max(b.s.x,b.t.x) - min(a.s.x,a.t.x)) >= 0 &&
    sgn(max(a.s.y,a.t.y) - min(b.s.y,b.t.y)) >= 0 &&
    sgn(max(b.s.y,b.t.y) - min(a.s.y,a.t.y)) >= 0;
}
db disPL(P p,L a){return fabs((a.t-a.s)/(p-a.s)) / abs(a.t-a.s);}
db disPS(P p,L a){ // p x seg dis
  if(sgn((a.t-a.s)*(p-a.s)) == -1) return abs(p-a.s);
  if(sgn((a.s-a.t)*(p-a.t)) == -1) return abs(p-a.t);
  return disPL(p,a);
}
db disSS(L a,L b){ // seg x seg dis
  if(isSS(a,b)) return 0;
  return min(min(disPS(a.s,b),disPS(a.t,b)),min(disPS(b.s,a),disPS(b.t,a)));
}
typedef vector<P> polygon;
T area(polygon A) { // multiple 2 with integer type
  T res=0;
  rep(i,0,sz(A)) res+=A[i]/(A[(i+1)%sz(A)]);
  return fabs(res) / 2;
}

P a, b, c, d;
polygon poly;

int main() {
	std::ios::sync_with_stdio(0);
	std::cin.tie(0);
	int q;
	cin >> q;
	cout << setiosflags(ios::fixed);
	cout << setprecision(1);
	while(q--) {
		cin >> a.x >> a.y;
		poly.pb(a);
	}
	T r = area(poly);
	cout << r << endl;
	return 0;
}


Measured memory_bytes: 3320
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <queue>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <fstream>
#include <complex>
#include <cstdint>
#include <tuple>
#include <numeric>
#define M_PI       3.14159265358979323846


using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define MT make_tuple
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define FILL(a, x) memset(a, x, sizeof(a))

//repetition
//------------------------------------------
#define FOR(i,s,n) for(int i=s;i<(int)n;++i)
#define REP(i,n) FOR(i,0,n)
#define MOD 1000000007


int main() {
	int n, m;
	scanf("%d%d", &n, &m);
	VVI s(m);
	VI p(m);
	REP(i, m) {
		int k;
		scanf("%d", &k);
		s[i] = VI(k);
		REP(j, k)scanf("%d", &s[i][j]);
	}
	REP(i, m) scanf("%d", &p[i]);
	int ret = 0;
	REP(i, 1 << n) {
		VI on(n);
		REP(j, n)if ((i >> j) & 1)on[j] = 1;
		bool flag = true;
		REP(j, m) {
			int x = 0;
			REP(k, s[j].size()) {
				if (on[s[j][k] - 1])x++;
			}
			x %= 2;
			if (x != p[j])flag = false;
			if (!flag)break;
		}
		if (flag)ret++;
	}
	cout << ret << endl;
	return 0;
}


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

struct UnionFind {
    // data[i] = 親ID if i == 子 else -size 
    vector<int> data;
    UnionFind(int n=0): data(n, -1) {}
    // 根のIDを聞く。再帰で。くっつけながら。
    int find(int x) {
        if (data[x] < 0) return x;
        return data[x] = find(data[x]);
    }
    // くっつける
    bool unite(int x, int y) {
        x = find(x); y = find(y);
        if (x == y) return false;
        if (data[x] > data[y]) swap(x, y);
        // size更新
        data[x] += data[y];
        // くっつけ
        data[y] = x;
        return true;
    }
    bool same(int x, int y) { return find(x) == find(y); }
    int size(int x) { return -data[find(x)]; }
};

int main() {
    int n, m;
    cin >> n >> m;
    vector<pair<int, int>> bridges(m);
    rep(i, m) cin >> bridges[i].first >> bridges[i].second;
    UnionFind uf(n);
    vector<ll> ans(m);
    ll tmpAns = (ll)n * (n-1) / 2;
    for (int i=m-1; i > -1; i--) {
        ans[i] = tmpAns;
        int a = bridges[i].first, b = bridges[i].second;
        --a; --b;
        if (!uf.same(a, b)) tmpAns -= (ll)uf.size(a) * uf.size(b);
        uf.unite(a, b);
    }
    rep(i, m) cout << ans[i] << endl;
    return 0;
}

Measured memory_bytes: 5104
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
#include <vector>
#include <stack>
#include <queue>
#include <tuple>
#include <cassert>
#include <functional>
#include <set>
#include <deque>
using namespace std;
typedef long long ll;
int dx[4] = {0,0,1,-1};
int dy[4] = {1,-1,0,0};
const int INF = 1<<29;
#define LNF __LONG_LONG_MAX__
const ll MOD = 1000000007;
const int MAX = 200000;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
// 法mでのaの逆元を計算
long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}
// a^n mod を計算する
long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
//最大公約数
int gcd(int x, int y) { return (x % y)? gcd(y, x % y): y; }
//最小公倍数
int lcm(int x, int y) { return x / gcd(x, y) * y; }
// nが大きく,kが10^7程度の時の二項係数
long long com[200005];
void combination(long long n,long long k){
    com[0] = 1;
    for(int i=1;i<=k;i++){
        com[i] = (com[i-1]*(n-i+1)%MOD)*modinv(i,MOD)%MOD;
    }
}

int main(){
    int N,M,X; cin >> N >> M >> X;
    vector<int> A(M);
    int b=0,e=0;
    for(int i=0;i<M;i++){
        cin >> A[i];
        if(A[i]<X)b++;
        if(A[i]>X)e++;
    }
    cout << min(b,e) << endl;
    return 0;
}


Measured memory_bytes: 256
#include<algorithm>  
#include<iostream>  
#include<cstdio>  
#include<map>  
#include<set>  
using namespace std;  
string s, t;  
set<string> S;  
void Work()  
{  
    int lens = s.size();  
    int lent = t.size();  
    for(int i = 0; i < lens; i++)  
    {  
        if(s[i] == '?' || s[i] == t[0])//如果字符相等  
        {  
            string tmp = s;              //构造判断子串之前的字符  
            for(int j = 0; j < i; j++)  
                if(tmp[j] == '?')  
                    tmp[j] ='a';      
            bool can = false;  
            for(int j = 0; j < lent; j++)    //判断是否为子串  
            {  
  
                if(tmp[i+j]!= '?' && tmp[i+j] != t[j])  //字符匹配  
                    break;  
                tmp[i+j] = t[j];  
                if(j == lent - 1) can = true;  
            }  
            if(can)  
            {  
                for(int j = i + lent; j < lens; j++) if(tmp[j] == '?') tmp[j] = 'a';//处理匹配后的字符  
                S.insert(tmp);  //压入容器  
            }  
        }  
    }  
    if(S.size() == 0) cout << "UNRESTORABLE" << endl;  
    else cout << *S.begin() << endl;  
}  
int main()  
{  
    cin >> s >> t;  
    Work();  
}  

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <utility>
#include <iomanip>
using namespace std;
typedef long long ll;

const ll MOD = 1e9+7;

int main()
{
	ll n;
	ll ans=1e14-1;
	cin>>n;
	for(ll i=1;i<=sqrtl(n);i++)
	{
		if(n%i==0)
			ans=min(ans,n/i+i-2);
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N; cin >> N;
  vector<int> t(N);
  vector<int> x(N);
  vector<int> y(N);
  for (int i=0; i<N; i++){
    cin >> t[i] >> x[i] >> y[i];
  }
  bool jud = true;
  
  for (int i=0; i<N; i++){
    if(t[i]%2 == 0){ //移動が偶数回のとき
      if ( x[i]+y[i]>t[i] || (x[i]+y[i])%2==1){
        jud = false;
      }
    }
    else{ //移動が奇数回のとき
      if (x[i]+y[i]>t[i] || (x[i]+y[i])%2==0){
        jud = false;
      }
    }
  }
  if(jud == true){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 1408
//In the name of Allah :)
#include <bits/stdc++.h>
using namespace std;
string to_string(char c) { return string(1,c); }
string to_string(bool b) { return b ? "true" : "false"; }
string to_string(const char* s) { return (string)s; }
string to_string(string s) { return s; }
template<class A> string to_string(complex<A> c) { 
	stringstream ss; ss << c; return ss.str(); }
string to_string(vector<bool> v) { 
	string res = "{"; for(int i = 0; i < (int)v.size(); i++) res += char('0'+v[i]);
	res += "}"; return res; }
template<size_t SZ> string to_string(bitset<SZ> b) {
	string res = ""; for(size_t i = 0; i < SZ; i++) res += char('0'+b[i]);
	return res; }
template<class A, class B> string to_string(pair<A,B> p);
template<class T> string to_string(T v) { // containers with begin(), end()
	bool fst = 1; string res = "{";
	for (const auto& x: v) {
		if (!fst) res += ", ";
		fst = 0; res += to_string(x);
	}
	res += "}"; return res;
}
template<class A, class B> string to_string(pair<A,B> p) {
	return "("+to_string(p.first)+", "+to_string(p.second)+")"; }
void DBG() { cerr << "]" << endl; }
template<class H, class... T> void DBG(H h, T... t) {
	cerr << to_string(h); if (sizeof...(t)) cerr << ", ";
	DBG(t...); }
#ifdef LOCAL // compile with -DLOCAL
#define wis(...) cerr << "LINE(" << __LINE__ << ") -> [" << #__VA_ARGS__ << "] : [", DBG(__VA_ARGS__)
#else
#define wis(...) 0
#endif
typedef long long ll;
const int MOD = 1e9 + 7, INF = 1e9 + 5;
const ll LONG_INF = 1e18 + 10;
inline ll powmod(ll a, ll b){ll res=1;for(;b;b>>=1,a=a*a%MOD)if(b&1)res=res*a%MOD;return res;}
inline ll power(ll a, ll b){ll res=1;for(;b;b>>=1,a=a*a)if(b&1)res=res*a;return res;}

const int MAXN = 2e5 + 10;

int main(){
	ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int h, w;
        cin >> h >> w;
        int m;
        cin >> m;
        vector <int> cntx(h + 1), cnty(w + 1);
        map<pair<int, int>, bool> tar;
        while(m--){
                int x, y;
                cin >> x >> y;
                cntx[x]++, cnty[y]++;
                tar[{x, y}] = 1;
        }
        vector <int> xmx, ymx;
        int ans, tmp = *max_element(cntx.begin(), cntx.end());
        for(int i = 0; i < h + 1; i++){
                if(cntx[i] == tmp)
                        xmx.push_back(i);
        }
        ans = tmp;
        tmp = *max_element(cnty.begin(), cnty.end());
        ans += tmp;
        for(int i = 0; i < w + 1; i++){
                if(cnty[i] == tmp)
                        ymx.push_back(i);
        }
        for(int i : xmx){
                for(int j : ymx){
                        if(tar[{i, j}] == 0){
                                cout << ans << '\n';
                                return 0;
                        }
                }
        }
        cout << ans -1 << '\n';

}


Measured memory_bytes: 28444
a = [1,
 9,
 30,
 76,
 141,
 267,
 400,
 624,
 885,
 1249,
 1590,
 2208,
 2689,
 3411,
 4248,
 5248,
 6081,
 7485,
 8530,
 10248,
 11889,
 13687,
 15228,
 17988,
 20053,
 22569,
 25242,
 28588,
 31053,
 35463,
 38284,
 42540,
 46581,
 50893,
 55362,
 61824,
 65857,
 71247,
 76884,
 84388,
 89349,
 97881,
 103342,
 111528,
 120141,
 128047,
 134580,
 146316,
 154177,
 164817,
 174438,
 185836,
 194157,
 207927,
 218812,
 233268,
 245277,
 257857,
 268182,
 288216,
 299257,
 313635,
 330204,
 347836,
 362973,
 383709,
 397042,
 416448,
 434025,
 456967,
 471948,
 499740,
 515581,
 536073,
 559758,
 583960,
 604833,
 633651,
 652216,
 683712,
 709065,
 734233,
 754734,
 793188,
 818917,
 846603,
 874512,
 909496,
 933081,
 977145,
 1006126,
 1041504,
 1073385,
 1106467,
 1138536,
 1187112,
 1215145,
 1255101,
 1295142,
 1342852,
 1373253,
 1422195,
 1453816,
 1502376,
 1553361,
 1595437,
 1629570,
 1691292,
 1726717,
 1782111,
 1827492,
 1887772,
 1925853,
 1986837,
 2033674,
 2089776,
 2145333,
 2197483,
 2246640,
 2332104,
 2379085,
 2434833,
 2490534,
 2554600,
 2609625,
 2693919,
 2742052,
 2813988,
 2875245,
 2952085,
 3003306,
 3096024,
 3157249,
 3224511,
 3306240,
 3388576,
 3444609,
 3533637,
 3591322,
 3693924,
 3767085,
 3842623,
 3912324,
 4027884,
 4102093,
 4181949,
 4270422,
 4361548,
 4427853,
 4548003,
 4616104,
 4718640,
 4812789,
 4918561,
 5003286,
 5131848,
 5205481,
 5299011,
 5392008,
 5521384,
 5610705,
 5739009,
 5818390,
 5930196,
 6052893,
 6156139,
 6239472,
 6402720,
 6493681,
 6623853,
 6741078,
 6864016,
 6953457,
 7094451,
 7215016,
 7359936,
 7475145,
 7593865,
 7689630,
 7886244,
 7984165,
 8130747,
 8253888,
 8403448,
 8523897,
 8684853,
 8802826,
 8949612,
 9105537,
 9267595,
 9376656,
 9574704,
 9686065,
 9827097,
 9997134,
 10174780,
 10290813,
 10493367,
 10611772,
 10813692]
n = int(input())
print(a[n-1])

Measured memory_bytes: 62192
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<functional>
#include<fstream>
#include<utility>
#include<bitset>
#define rep(N) for (int i = 0; i < N; i++)
#define For(i, N) for (i = 0; i < N; i++)
#define rev(N) 	for (int i = N - 1; i >= 0; --i)
#define all(v) v.begin(), v.end()
#define mod 1000000007
#define re return 0

using namespace std;
using ll = long long int;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vb = vector<bool>;
using vvb = vector<vector<bool>>;
using vs = vector<string>;
using pii = pair<int, int>;
using pis = pair<int, string>;

template<typename T>
void say(T s) {
	cout << s << endl;
}

template<typename T1, typename T2>
void say(T1 s1, T2 s2) {
	cout << s1 << " " << s2 << endl;
}

int main() {
	int N;
	cin >> N;
	int t1, t2 = 0;
	int x1, x2 = 0;
	int y1, y2 = 0;

	rep(N) {
		t1 = t2;
		x1 = x2;
		y1 = y2;
		cin >> t2 >> x2 >> y2;
		int T = t2 - t1;
		int dif = abs(x2 - x1) + abs(y2 - y1);
		if (T < dif) {
			say("No");
			re;
		}
		if (T % 2 != dif % 2) {
			say("No");
			re;
		}
	}
	say("Yes");
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
char x[200005];
int n, a, b, c, d;
bool f[200005];
bool mov(int fro, int to)
{
	memset(f, false, sizeof(f));
	int i;
	if(x[fro] == '.')
		f[fro] = true;
	for(i = fro + 1; i <= to; i++)
		if(x[i] == '.')
			f[i] = f[i - 1] | f[i - 2];
	return f[to];
}
bool fa[200005], fb[200005];
bool fx[200005];
int main()
{
    scanf("%d %d %d %d %d", &n, &a, &b, &c, &d);
    scanf("%s", x + 1);
    int i;
    bool flag = false;
	if(c > a && c < b)
	{
		if(mov(b, d) && mov(a, c))
			flag = true;
		else
			flag = false;
	}
    else if(c > b && c < d)
	{
		if(mov(b, d) && mov(a, c))
			flag = true;
		else
			flag = false;
	}
    else if(c > d) 
    {
    	fa[a] = true;
    	for(i = a + 1; i <= c; i++)
    	{
    		if(x[i] == '.')
    			fa[i] = fa[i - 1] | fa[i - 2];
    	}
    	fb[b] = true;
    	for(i = b + 1; i <= d; i++)
    	{
    		if(x[i] == '.')
    			fb[i] = fb[i - 1] | fb[i - 2];
    	}
    	fx[c] = 1;
		for(i = c - 1; i >= b; i--)
			if(x[i] == '.')
				fx[i] = fx[i+1] | fx[i+2];
		for(i = b; i <= d; i++)
			if(fa[i-1] && fb[i] && x[i + 1]=='.')
				flag |= fx[i+1];
		if (!fb[d])
			flag = false;
    }
    if(flag)
    	printf("Yes\n");
    else
    	printf("No\n");
	return 0;
}

Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(x) (x).begin(),(x).end()
template <class T> inline bool chmin(T &a, T b) {if (a > b){a = b;return true;}return false;}
template <class T> inline bool chmax(T &a, T b) {if (a < b){a = b;return true;}return false;}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;cin>>n;
    string s;cin>>s;
    int ans = 0;
    int x = 0;
    for(auto c : s){
        if(c=='I') x++;
        else x--;
        chmax(ans, x);
    }
    cout<<ans<<endl;
    return 0;
}

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

int main() {
  int s;
  cin >> s;
  vector<int> input(s);
  for (int i = 0; i < s; i++) {
    cin >> input[i];
  }
  sort(input.begin(), input.end());
  int min = input[0];
  int max = input[input.size() - 1];
  int ans = 9000000;

  for (int i = min; i <= max; i++) {
    int total = 0;
    for (int j = 0; j < input.size(); j++) {
      total += (i - input[j]) * (i - input[j]);
    }
    if (ans > total)
      ans = total;
  }

  cout << ans << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){
	int n,a,b,c,d,e,f,g,h,i;
	while(scanf("%d",&n) , n != 0){
		a = 0;
		b = 0;
		c = 0;
		d = 0;
		e = 0;
		f = 0;
		g = 0;
		for (i = 1;i <= n;i++){
			scanf("%d",&h);
			if (h <= 9){
				a++;
			}
			else if (h <= 19){
				b++;
			}
			else if (h <= 29){
				c++;
			}
			else if (h <= 39){
				d++;
			}
			else if (h <= 49){
				e++;
			}
			else if (h <= 59){
				f++;
			}
			else{
				g++;
			}
		}
		printf("%d\n%d\n%d\n%d\n%d\n%d\n%d\n",a,b,c,d,e,f,g);
	}
	return 0;
}

Measured memory_bytes: 600
#include <iostream>
#include <cstdio>
#include <vector>
#include <string>
#include <queue>

using namespace std;

int n;
vector<string> a(10);
vector<string> b(10);
string g, d;

queue<string> que;

string repl(string s, int i) {
    string s2 = s.substr(a[i].size());
    int x = s2.find(a[i]);
    if (x != string::npos) {
        string s3 = s2.substr(0,x) + repl(s2.substr(x), i);
        return b[i] + s3;
    }
    else return b[i] + s2;
}

int bfs(int c) {
    if (c > 8) return -1;
    queue<string> que2;
    while (!que.empty()) {
        string s = que.front();
        que.pop();
        for (int i = 0; i < n; i++) {
            int x = s.find(a[i]);
            if (x == string::npos) continue;
            string s2 = s.substr(x);
            string s3 = s.substr(0, x) + repl(s2,i);
            if (s3 == d) return c+1;
            que2.push(s3);
        }
    }
    que = que2;
    return bfs(c+1);
}

int main(void){
    while (cin>>n && n) {
        for (int i = 0; i < n; i++) cin >> a[i] >> b[i];
        cin >> g >> d;
        queue<string> a;
        que = a;
        que.push(g);
        cout << bfs(0) << endl;
    }
}

Measured memory_bytes: 4716
//Is it a Right Triangle?
import java.util.Scanner;

class Main {
    public static void main(String[] args) {
        @SuppressWarnings("resource")
        Scanner sc = new Scanner(System.in);
        
        String ans[] = new String[1000];
        
        int set = sc.nextInt();
        int i = 0;
        for(; i<set; i++) {
            int a = sc.nextInt();
            int b = sc.nextInt();
            int c = sc.nextInt();
            
            if(a*a==b*b+c*c || a*a+b*b==c*c || a*a+c*c==b*b) {
                ans[i] = "YES";
            }else {
                ans[i] = "NO";
            }
        }
        //System.out.println("i="+i);
        for(int j=0; j<i; j++) {
            System.out.println(ans[j]);
        }
    }
}

Measured memory_bytes: 24044
import sys
input = sys.stdin.readline
N, K = map(int,input().split())
RSP = ["r", "s", "p"]
RSP_Point = list(map(int,input().split()))
T = list(input().rstrip())
li = [-1]*K
sum = 0
for i in range(N):
    player = (RSP.index(T[i])+2)%3
    if li[i%K] == player:
        if i+K < N:
            li[i%K] = (RSP.index(T[i+K])+1)%3
    else:
        sum += RSP_Point[player]
        li[i%K] = player
print(sum)

Measured memory_bytes: 50416
import java.util.Scanner;
	public class Main {
	 public static void main(String[] args) {
	 
	 Scanner sc = new Scanner(System.in);
	 
	 int A = sc.nextInt();
	 int B = sc.nextInt();
	 if(B%A==0){
	 System.out.println(A+B);
	 }else{
	 System.out.println(B-A);
	 }
	 }
	}

Measured memory_bytes: 23124
package main

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

var sc *bufio.Scanner

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

const MOD = 1000000007
const DIV = 13
const BASE = 10

func main() {
	sc = bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	var s string
	fmt.Scan(&s)
	rs := append([]rune{'0'}, []rune(s)...)
	n := len(rs) - 1

	dp := make([][]int, n+1)
	for i := range dp {
		dp[i] = make([]int, DIV)
	}
	dp[0][0] = 1

	for i := 1; i <= n; i++ {
		var digit int
		switch {
		case rs[i] == '?':
			digit = -1
		default:
			digit = int(rs[i] - '0')
		}

		for j := 0; j < BASE; j++ {
			if digit != -1 && digit != j {
				continue
			}
			for k := 0; k < DIV; k++ {
				dp[i][(k*BASE+j)%DIV] = (dp[i][(k*BASE+j)%DIV] + dp[i-1][k]) % MOD
			}
		}
	}
	fmt.Println(dp[n][5])
}


Measured memory_bytes: 14976
#include<iostream>
#include<string>
#include<set>
#include<algorithm>
using namespace std;
int main(){
    int q;
    cin>>q;
    set<int>se;
    int a,b;
    
    for(int i=0;i<q;i++){
        cin>>a>>b;
        if(a==0){
            
            se.insert(b);
            cout<<se.size()<<endl;
        }else if(a==1){
            
            cout<<se.count(b)<<endl;
        }
    }
    return 0;
}


Measured memory_bytes: 12388
#define _CRT_SECURE_NO_WARNINGS
#include <algorithm>
#include <string>
#include <iostream>
#include <complex>
#include <ctime>
#include <cmath>
#include <cstdio>
#include <stack>
#include <map>
#include <list>
#include <queue>
#include <deque>
#include <random>
#include <set>
#include <vector>
#include <unordered_map>
#include <bitset>
#include <unordered_set>
#include <array>
#include <forward_list>
#include <chrono>
#include <iomanip>
#include <utility>
#include <assert.h>

#pragma GCC optimize("Ofast")
#pragma target("sse", "sse1")

#define mp make_pair
#define pb push_back

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

mt19937 gen(43);

ll a, b, c, d;

ll gcd(ll a, ll b)
{
	while (b != 0)
	{
		a %= b;
		swap(a, b);
	}
	return a;
}

ll nok(ll a, ll b)
{
	return a / gcd(a, b) * b;
}

ll kolvo(ll l, ll r, ll x)
{
	if (l % x == 0)
		l--;
	return r / x - l / x;
}

int main()
{
#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
#else
	//freopen("rps2.in", "r", stdin);
	//freopen("rps2.out", "w", stdout);
#endif
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cin >> a >> b >> c >> d;
	ll x = nok(c, d);
	ll ans = b - a + 1 - kolvo(a, b, c) - kolvo(a, b, d) + kolvo(a, b, x);
	cout << ans;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <algorithm>
using namespace std;
const int N = 6e5+5;
const int M = 3e6+5;
const int INF = 0x3f3f3f3f;
typedef long long ll;
#define lson l, m, rt<<1
#define rson m+1, r, rt<<1|1

char seq[N];
int has[30];
ll ans = 0;

int nx[M][27];
int sum[M];
int tot;
void insert(string tmp) {
//	cout << tmp << endl;
	int rt = 0;
	for(int i = 0; i < tmp.length(); ++i) {
		int tar = tmp[i] - 'a';
		if(nx[rt][tar] == -1) {
			nx[rt][tar] = ++tot;
			sum[tot] = 0;
		}
		rt = nx[rt][tar];
	}
	sum[rt] ++;
}
int search(string tmp) {
//	cout << "hh" << tmp << endl;
	int rt = 0;
	for(int i = 0; i < tmp.length(); ++i) {
		int tar = tmp[i] - 'a';
		if(nx[rt][tar] == -1) {
			return 0;
		}
		rt = nx[rt][tar];
	}
	return sum[rt];
}


int main() {
	int n;
	while(~scanf("%d", &n)) {
		memset(nx, -1, sizeof(nx));
		sum[0] = 0;
		tot = 0;
		memset(has, 0, sizeof(has));


		scanf("%s", seq);
		for(int i = 0; i < n; ++i) {
			has[seq[i] - 'a'] ++;
		}
		bool flag = true;
		for(int i = n; i < 2*n && flag; ++i) {
			has[seq[i] - 'a'] --;
			if(has[seq[i] - 'a'] == -1) {
				flag = false;
			}
		}
		if(!flag) {
			printf("0\n");
			continue;
		}

		
		int largeNum = 1<<n;
		for(int i = 0; i < largeNum; ++i) {
			string tmp1; string tmp2;
			for(int j = 0; j < n; ++j) {
				if( (i >> j) & 1 ) {
					tmp1 += seq[j];
				} else tmp2 += seq[j];
			}
			tmp1 += 'z'+1;
			tmp1 += tmp2;
			insert(tmp1);
		}

		ll ans = 0;
		for(int i = 0; i < largeNum; ++i) {
			string tmp1, tmp2;
			for(int j = 0; j < n; ++j) {
				if( (i >> j) & 1 ) {
					tmp1 += seq[j + n];
				} else tmp2 += seq[j + n];
			}
			reverse(tmp1.begin(), tmp1.end());
			reverse(tmp2.begin(), tmp2.end());
			tmp1 += 'z'+1;
			tmp1 += tmp2;

			ans += search(tmp1);
		}
		printf("%lld\n", ans);
	}
	return 0;
}

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

using namespace std;
#define int long long
#define MOD 1000000007
#define pb push_back
int N;
int call(int idx, int mask,vector<vector<int> >&A,vector<vector<int> >&dp)
{
    if(idx==N)
    {
        return 1;
    }
    if(dp[idx][mask]!=-1)
    {
        return dp[idx][mask];
    }
    dp[idx][mask]=0;
    for(int i=0;i<N;i++)
    {
        if((mask&(1LL<<i)) && A[idx][i])
        {
            dp[idx][mask]+=call(idx+1,mask^(1LL<<i),A,dp);
            dp[idx][mask]%=MOD;
        }
    }
   // cout<<idx<<" "<<mask<<" "<<dp[idx][mask]<<endl;
    return dp[idx][mask];
    
}
int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
   // int N;
    cin>>N;
    int K=(1LL<<N)-1;
    //cout<<K<<endl;
    vector<vector<int> >A(N,vector<int>(N));
    for(int i=0;i<N;i++)
    {
        for(int j=0;j<N;j++)
        {
            cin>>A[i][j];
        }
    }
    vector<vector<int> >dp(N,vector<int>(K+1,-1));
    
    
    cout<<call(0,K,A,dp);
    
    
    return 0;
}

Measured memory_bytes: 360832
#include <iostream>
using namespace std;
int main(void){
    int n;
    cin>>n;
    if(n==1){
        cout<<"1"<<endl;
        return 0;
    }
    int sum=0,k=0;
    int b=0;
    for(int i=0;i<=n;i++){
        int a;
        a=i;
        while(a>0 && a%2==0){
                a=a/2;
                sum++;
                if(sum>b) {
                    k=i;
                    b=sum;
                }
        }
        sum=0;

    }
    cout<<k<<endl; 
    return 0;
    // Your code here!
    
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(x) x.begin(), x.end()
#define dbg(x) cerr << #x << " = " << x << endl
#define _ << ' ' <<
using namespace std;
using ll = long long;
using vi = vector<int>;
using ii = pair<int, int>;
using vii = vector<ii>;


int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int H, W, h, w;
    cin >> H >> W >> h >> w;
    int sol = w * H + h * W - w * h;
    cout << H * W - sol;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <limits.h>

typedef struct {
  int id;
  int sc;
} node;
node dat[1<<18];
int tim[111111];
int n;

node max(node a,node b) {
  if( a.sc == b.sc ) return a.id < b.id ? a : b;
  if( a.sc < b.sc ) return b;
  if( a.sc > b.sc ) return a;
  return a.id > b.id ? b : a;
}

void update(int k,node x)
{
  k += n-1;
  dat[k] = x;
  while( k > 0 ) {
    k = (k-1)/2;
    dat[k] = max(dat[k*2+1],dat[k*2+2]);
  }
}

int a[1111111],b[1111111];
int c[1111111];

int main(void)
{
  int n_,r,l,i,j,pre,ma,res;
  scanf("%d%d%d",&n_,&r,&l);
  n = 1;
  while( n < n_ ) n *= 2;
  for( i = 0; i < n; i++ ) dat[i+n-1] = (node){i,INT_MIN}; 
  for( i = 0; i < n_; i++ ) update(i,(node){i,0ll});
  for( i = 0; i < r; i++ ){ scanf("%d%d%d",a+i,b+i,c+i); a[i]--; }
  b[r] = l;
  pre = 0;
  for( i = 0; i <= r; i++ ) {
    tim[dat[0].id] += b[i]-pre;
    for( j = i; j <= r && b[i] == b[j]; j++ ) {
      update(a[j],(node){a[j],dat[a[j]+n-1].sc+c[j]});
    }
    i = j-1;
    pre = b[i];
  }
  ma = 0;
  res = 0;
  for( i = 0; i < n_; i++ ) {
    if( ma < tim[i] ) {
      ma = tim[i];
      res = i+1;
    }
  }
  printf("%d\n",res);
  return 0;
}

Measured memory_bytes: 14924
import numpy as np
MOD = 10**9 + 7
N = int(input())
A = np.array([int(x) for x in input().split()])

left = np.arange(N)
right = N-1-left
cnt_1 = np.bincount(np.abs(left-right))
cnt_2 = np.bincount(A)

if cnt_1.shape != cnt_2.shape or (cnt_1 != cnt_2).any():
  answer = 0
else:
  answer = pow(2, N//2, MOD)
  
print(answer)


Measured memory_bytes: 23432
#include<bits/stdc++.h>
using namespace std;
int main()
{
 
  int n; cin>>n; int i,j;int a[n];
  for(i=0;i<n;i++)
    	cin>>a[i];
 
  long double ans=0;
  for(i=0;i<n;i++)
  {
  		long double x=(long double)1/a[i];

  		ans=ans+x;
	}  
  ans=(long double) 1/ans;
  //cout<<ans<<endl;
  cout<<setprecision(15)<<ans<<endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
  unsigned long long int k,b=0,i,f=100,a;

  cin>>k;
  while(f<k)
  {
      a=(f/100);
      f=f+a;
      b+=1;
  }
  cout<<b;

    return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) (v).begin(),(v).end()
#define out(a) cout << (a) << endl
using namespace std;
using ll = long long;
int main(){
    int n, k;
    cin >> n >> k;
    cout << fixed << setprecision(0) << (k * pow(k-1, n-1));
}

Measured memory_bytes: 384
# A - One Card Poker
# https://atcoder.jp/contests/abc054/tasks/abc054_a

A, B = map(int, input().split())

result = 'Alice'

if A == B:
    result = 'Draw'
elif A < B:
    if A == 1:
        result = 'Alice'
    else:
        result = 'Bob'
else:
    if B == 1:
        result = 'Bob'

print(result)


Measured memory_bytes: 9148
import heapq
import sys

n,m=map(int,input().split())
X=list(map(int,input().split()))

if n>=m:
	print("0")
	sys.exit()

X.sort()
Y=[]
#Y=heapq.heapify(Y)

for i in range(m-1):
	heapq.heappush(Y,(X[i]-X[i+1]))

for _ in range(n-1):
	heapq.heappop(Y)

print(sum(Y)*(-1))

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

int max(int a, int b){
  if(a > b) return a;
  else return b;
}

long long int min(long long int a, long long int b){
  if(a < b) return a;
  else return b;
}

int sort(const void *a, const void *b){
  return *(int*)a - *(int*)b;
}

int main(){

  char s[200001];
  char t[200001];

  scanf("%s %s",s,t);
  int len = strlen(s);

  int start[26];
  int goal[26];
  for(int i = 0; i < 26; ++i){
    start[i] = -1;
    goal[i] = -1;
  }

  for(int i = 0; i < len; ++i){
    int a = s[i] - 'a';
    int b = t[i] - 'a';

    if(start[a] != -1 || goal[b] != -1){
      if(start[a] != b || goal[b] != a){
        printf("No");
        return 0;
      }
      }else{
        start[a] = b;
        goal[b] = a;
      }
  }

  printf("Yes");

  return 0;

}


Measured memory_bytes: 512
# coding: utf-8
import sys
N=int(input())
A=list(map(int,input().split()))
neg=0

for a in A:
    if a<0:neg+=1
if neg%2==0:
    print(sum(abs(x) for x in A))
    sys.exit(0)
else:
    m=min(abs(x) for x in A)
    print(sum(abs(x) for x in A) - 2*m)


Measured memory_bytes: 14224
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner tan = new Scanner(System.in);
        while(tan.hasNext()){
            int a=tan.nextInt();
            String st=tan.next();
            if(a<3200)
                System.out.println("red");
            else
                System.out.println(st);
        }
    }
}


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

int main(){
  int n,m;
  cin >> n >> m;
  vector<vector<bool>> g(2*m,vector<bool>(2*m,false));
  for(int i=0;i<m;i++){
    int a,b;
    cin >> a >> b;
    a--; b--;
    g.at(a).at(b) = g.at(b).at(a) = true;
  }
  vector<int> per(n);
  for(int i=0;i<n;i++) per.at(i) = i;
  
  int cnt=0;
  do{
    if(per.at(0)!=0) break;
    bool flag = true;
    for(int i=0;i<n-1;i++){
      int from = per.at(i);
      int to = per.at(i+1);
      if(!g.at(from).at(to)) flag = false;
    }
    if(flag) cnt++;
  }while(next_permutation(per.begin(),per.end()));
  
  cout << cnt << endl;
  
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
static const int N = 1000;

int lcs(string X, string Y) {
    int c[N+1][N+1];
    int m = X.size();
    int n = Y.size();
    int maxl = 0;
    X = ' ' + X;
    Y = ' ' + Y;
    for(int i=0; i<=m; i++) c[i][0] = 0;
    for(int j=0; j<=n; j++) c[0][j] = 0;
    
    for(int i=1; i<=m; i++) {
        for(int j=1; j<=n; j++) {
            if(X[i] == Y[j]) {
                c[i][j] = c[i-1][j-1] + 1;
            } else {
                c[i][j] = max(c[i-1][j], c[i][j-1]);
            }
            maxl = max(maxl, c[i][j]);
        }
    }
    return maxl;
}

int main() {
    string s1, s2;
    int n; cin >> n;
    for(int i=0; i<n; i++) {
        cin >> s1 >> s2;
        cout << lcs(s1, s2) << endl;
    }
    return 0;
}


Measured memory_bytes: 7084
#include<deque>
#include<stdint.h>
#include<set>
#include<stack>
#include <iostream>
#include <algorithm>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<iomanip>
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<queue>
#include<cstring>
#include<map>
using namespace std;
int a,b,c;
int main()
{
	cin>>c>>a>>b;
	if (abs(c-a)<abs(c-b)) cout<<"A";else cout<<"B";
	return 0;
}

Measured memory_bytes: 256