akhauriyash/Code-Regression huggingface dataset:
import sys
sys.setrecursionlimit(100000)

n = int(input())
edges = [[] for _  in range(n)]

for _ in range(n - 1):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    edges[a].append(b)
    edges[b].append(a)

height = [None for _ in range(n)]
root = 0
height[root] = 0

def build(node):
    for to in edges[node]:
        if height[to] == None:
            height[to] = height[node] + 1
            build(to)

build(root)

enum = [(-h, i) for i, h in enumerate(height)]
enum.sort()

tree = [None] * n
clst = sorted(map(int, input().split()))

for c, hi in zip(clst, enum):
    h, i = hi
    tree[i] = c

print(sum(clst[:-1]))
print(*tree)


Measured memory_bytes: 14612
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <cstring>
#include <cstdio>
using namespace std;

//using ll = long long;
typedef long long ll;

#define INF (1LL << 31 - 1)
#define INFLL ((1LL << 62) - 1)
#define MOD int(1e9+7)
#define repi(i,j,n) for(int i = (j); i < (n); ++i)
#define rep(i,n) repi(i,0,n)
#define rrep(i,n) for (int i = n; i >= 0; --i)
#define fi first
#define se second
#define all(v) (v).begin(), (v).end()

int vx[8] = {0, 1, 1, 1, 0, -1, -1, -1}, vy[8] = {-1, -1, 0, 1, 1, 1, 0, -1};

inline bool check(int bx, int ux, int by, int uy, int x, int y) {
  return (bx <= x and x < ux and by <= y and y < uy);
}

inline bool check(int ux, int uy, int x, int y) {
  return check(0, ux, 0, uy, x, y);
}

inline void init() {
  cin.tie(0), cout.tie(0);
  ios::sync_with_stdio(false);
}

vector<vector<int> > g;
int n, m, u, v;

//---------------------------------------------------------
// ???, ??¢???????????????
vector<pair<int, int> > bridge;
vector<int> articulation;
int ord[100001], low[100001];
bool used[100001];
int K; // ??°??????????????????"?????????"dfs????????????0?????£??\???????????¨

inline void dfsInit() {
  bridge.clear();
  articulation.clear();
  memset(ord, 0, sizeof ord);
  memset(low, 0, sizeof low);
  memset(used, false, sizeof used);
  K = 0;
}

// ?????£????????°??????????????????????????????dfs???????????¨
inline void dfs(int v, int prev) {
  used[v] = true;
  ord[v] = K++;
  low[v] = ord[v];

  bool isArticulation = false;
  int cnt = 0, _size = g[v].size();

  for (int i = 0; i < _size; ++i) {
    int nv = g[v][i];

    if (!used[nv]) {
      cnt++;
      dfs(nv, v);
      low[v] = min(low[v], low[nv]);
      if (~prev and ord[v] <= low[nv]) isArticulation = true;
      if (ord[v] < low[nv]) bridge.push_back(make_pair(min(v, nv), max(v, nv)));
    }
    else if (nv != prev) {
      low[v] = min(low[v], ord[nv]);
    }
  }

  if (prev == -1 and cnt > 1) isArticulation = true;
  if (isArticulation) articulation.push_back(v);

}
//---------------------------------------------------------

inline void solve() {
  dfsInit();

  for (int i = 0; i < n; ++i) {
    if (!used[i]) dfs(i, -1);
  }
  
  sort(all(articulation));

  int _size = articulation.size();

  for (int i = 0; i < _size; ++i) {
    cout << articulation[i] << endl;
  }

}



int main() {
  init();
  cin >> n >> m;
  g.resize(n);
  for (int i = 0; i < m; ++i) {
    cin >> u >> v;
    g[u].push_back(v);
    g[v].push_back(u);
  }

  solve();

  return 0;
}

Measured memory_bytes: 5156
s = input()
n = len(s)
w = []
x = []
for i in range(n):
  w.append(s[i])
w.sort()
for i in range(n):
  if i % 2 == 0:
    x.append(w[i])
y = x * 2
y.sort()
if w == y:
  print('Yes')
else:
  print('No')
#print(w,y)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#include <iostream>
#include <utility> // pair
#include <string>
#include <vector>
#define MAX_N 100001
#define FOR(i, a, b) for(int i=a; i<b; i++)
#define REP(i, n) for(int i=0; i<n; i++)
#define RER(i, n) for(int i=n-1; i>=0; i--)
#define ALL(v) v.begin() v.end()
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<int, int> P;

signed main(){
    int a[3]; cin >> a[0] >> a[1] >> a[2];
    sort(a, a+3);
    if(a[0] + a[1] == a[2]) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}

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

int main() {
  int a, b;
  cin >> a >> b;
  if (a + b == 15) {
    cout << "+" << endl;
  } else if (a * b == 15) {
    cout << "*" << endl;
  } else {
    cout << "x" << endl;
  }
}


Measured memory_bytes: 3528
#include <bits/stdc++.h>
using namespace std;
typedef  long long unsigned ull;
constexpr long long mod = 1000000007;
ull n, a[300000],d[60][2],r[60], p[60], s;

int main(){
cin>>n;
for (ull i=0; i<n; i++){
  cin>>a[i];
  for (ull j=0; j<60; j++){
    //d[j][(a[i] & ((ull) 1 << j)) ? 1 : 0]++;
    d[j][(a[i]&((ull) 1<<j)) ?1:0]++;


  }
}
for (ull i = 0; i < 60; i++) r[i] = (d[i][0] * d[i][1]) % mod;
p[0] = 1;
for (ull i = 1; i < 60; i++) p[i] = (p[i - 1] * 2) % mod;
for (ull i = 0; i < 60; i++) s = (s + r[i] * p[i]) % mod;
cout << s << endl;
}




Measured memory_bytes: 2560
# 171 B
S = input()
T = input()
ans = []
for i in range(0, (len(S)-len(T) + 1)):
    tmp = 0
    #print(i)
    for j in range(0, len(T)):
        if T[j] != S[i +j]:
            tmp += 1
            #print(S[i +j] + T[j])
        #print('tmp:' + str(tmp))
    ans.append(tmp)
        
print(min(ans))

Measured memory_bytes: 9056
#include<iostream>
#include<cmath>
#include <vector>
using namespace std;

int main(){

  int N = 0;
  int M = 0;
  cin >> N >> M;

  if (N == M) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }

  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<queue>
#include<map>
#include<cstring>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<string>
#include<cstdio>
#include<iostream>
using namespace std;
#define fr first
#define sc second
#define INF 100
typedef pair<int,int>Pt;
int main(){
  unsigned long long r=0,l=0,q,a,b;
  string op;
  cin >> q;
  while(q--){
    cin >> a >> op >> b;
    if(op=="(") r += b;
    else l += b;
    cout << ( r==l ? "Yes" : "No") << endl;
  }
}

Measured memory_bytes: 1196
n = int(input())
if n < 2:
  print(1)
elif n < 4:
  print(2)
elif n < 8:
  print(4)
elif n < 16:
  print(8)
elif n < 32:
  print(16)
elif n < 64:
  print(32)
else:
  print(64)

Measured memory_bytes: 3060
def draw_frame_line(h, w, i)
	if i==1 || i==h
		w.times{print("#")}
	else
		print("#")
		(w-2).times{print(".")}
		print("#")
	end
	puts ""
end
def draw_frame(h, w)
	for i in 1..h
		draw_frame_line(h, w, i)
	end
	puts ""
end

inputs = gets.strip().split(" ")
h  = inputs[0].to_i
w  = inputs[1].to_i

until h == 0 && w == 0
	draw_frame(h, w)
	inputs = gets.strip().split(" ")
	h  = inputs[0].to_i
	w  = inputs[1].to_i		
end


Measured memory_bytes: 6868
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();
		int h = sc.nextInt();

		int area;
		if (a < b) {
			area = b * h - (b - a) * h / 2;
		} else {
			area = a * h - (a - b) * h / 2;
		}

		System.out.println(area);
		sc.close();
	}

}


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

using namespace std;

int main(){
    string sentence;
    string objective_word;
    cin >> objective_word;
    int counter = 0;
    while(true){
        cin >> sentence;
        if(sentence == "END_OF_TEXT") break;
        for(int i = 0;i < sentence.size();i++){
            if(isupper(sentence[i])) sentence[i] = tolower(sentence[i]);
        }
        
        if(sentence == objective_word) counter++;
    }
    cout << counter << "\n";
    return 0;
}


Measured memory_bytes: 3160
#include <bits/stdc++.h>
#define pb push_back
#define ppb pop_back
#define fi first
#define se second
#define mid ((x + y) / 2)
#define left (ind * 2)
#define right (ind * 2 + 1)
#define mp make_pair
#define timer ((double)clock() / CLOCKS_PER_SEC)
#define endl "\n"
#define spc " "
#define d1(x) cerr<<#x<<":"<<x<<endl
#define d2(x, y) cerr<<#x<<":"<<x<<" "<<#y<<":"<<y<<endl
#define d3(x, y, z) cerr<<#x<<":"<<x<<" "<<#y<<":"<<y<<" "<<#z<<":"<<z<<endl
#define fast_io() ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
using namespace std;

typedef long long int lli;
typedef pair<int, int> ii;
typedef pair<ii, int> iii;
typedef pair<double, double> dd;

const int N = (int)(1e3 + 5);
const int LOG = (int)(20);

int n, m, mark[N][N], ans, w[4][2] = {0, 1, 0, -1, 1, 0, -1, 0};
char s[N][N];
queue<ii> q;

int main() {
	fast_io();
	// freopen("inp.in", "r", stdin);
	
	cin >> n >> m;
	for(int i = 1; i <= n; i++)
		cin >> s[i] + 1;
	memset(mark, -1, sizeof mark);

	for(int i = 1; i <= n; i++)
		for(int j = 1; j <= m; j++)
			if(s[i][j] == '#') {
				q.push({i, j});
				mark[i][j] = 0;
			}
	
	while(!q.empty()) {
		ii t = q.front();
		q.pop();
		for(int i = 0; i <= 3; i++) {
			int nx = t.fi + w[i][0], ny = t.se + w[i][1];
			if(nx >= 1 && ny >= 1 && nx <= n && ny <= m && mark[nx][ny] == -1) {
				mark[nx][ny] = mark[t.fi][t.se] + 1;
				q.push({nx, ny});
			}
		}
	}

	for(int i = 1; i <= n; i++)
		for(int j = 1; j <= m; j++)
			ans = max(ans, mark[i][j]);
	cout << ans;
}

Measured memory_bytes: 13328
import java.io.PrintWriter;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String N = sc.next();
        int A = Integer.parseInt(sc.next());
        int B = Integer.parseInt(sc.next());
        int sum;
        int SUM = 0;

        for (Integer i = 0; i < Integer.parseInt(N) + 1; i++) {
            sum = 0;
            for (Integer j = 0; j < i.toString().length(); j++) {
                sum += Integer.parseInt(i.toString().split("")[j]);
            }
            if (sum >= A && sum <= B)
                SUM += i;
        }

        PrintWriter out = new PrintWriter(System.out);
        out.println(SUM);

        sc.close();
        out.flush();
    }
}


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

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

#define rep(i, a) for (int i=0; i<(a); i++) 
#define ub        upper_bound            // first element >  val(itr)
#define lb        lower_bound            // first element >= val(itr)

#define mp make_pair
#define pb push_back
#define pi 3.141592653589793
#define endl "\n"
#define FAST ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);
#define bitcount(a) __builtin_popcount(a) // count set bits
#define all(x) (x).begin(),(x).end()

const ll MOD = 1e9 + 7;
const int inf = 1e9+9;
const long long INF = 1e18+3;

//to debug 
#define dbg(x) cout << "Line " << __LINE__ << " | " #x ": " << (x) << endl

template<typename T> T gcd(T a,T b){ if(b>a) return gcd(b,a);return b==0?a:gcd(b,a%b); }
template<typename T> T lcm(T a, T b) { return a * b / gcd(a, b); }
template<typename T> T fast_power(T x,T y,ll m=MOD){T ans=1;while(y>0){if(y&1LL) ans=(ans*x)%m;y>>=1LL;x=(x*x)%m;}return ans%m;}

inline ll mod(ll x,ll n) {if (x < n) return x; if (x >= n) return x - n;}
string IntToString(ll a){ ostringstream temp; temp << a; return temp.str();}
ll findMMI_fermat(ll n,ll M) {ll ans= fast_power(n,M-2,M);return ans;}//i.e In (a/b)%M..it calculates MMI of b wrt M
ll add(ll a,ll b,ll M)  { return ( mod(a,M ) + mod(b,M ))%M;     }
ll sub(ll a, ll b,ll M) { return (mod(a,M ) + M - mod(b,M ))%M;   }
ll mult(ll a,ll b,ll M) { return  ( mod(a,M)*mod(b,M) ) %M ; }
bool isprime(ll a){ if(a==2) {return 1;}if(!(a&1) ) {return 0;}for(ll i=3;i*i<=a;i+=2){if(a%i==0) {return 0;} } return 1;} 

  
               /* -------------------------------Main Code------------------------------- */



int main(){
	FAST;
	int n,k;cin>>n>>k;
	vector <int> hgt(n);
	for(int i=0;i<n;i++) cin>>hgt[i];
	vector <int> dp(n); //where dp[i] represents min cost of frog reaching from beginning to i'th
	//Base cases
	dp[0] = 0;
	dp[1] = abs(hgt[1] - hgt[0]);
	for(int i=2;i<=k && i<n;i++){
		ll mn = inf;
		for(int j = 1; j<=i ; j++){
			mn = min( (ll) (abs(hgt[i] - hgt[i-j]) + dp[i-j ] ) , mn );
			//cout<<j<<" "<<mn<<endl;
		}
		dp[i] = mn;
	}
	//Rec Cases
	for(int i=k+1;i<n;i++){
		int mn = inf;
		for(int j = 1 ; j<=k && j<n ; j++){
			mn = min(  abs(hgt[i] - hgt[i-j]) + dp[i-j ], mn );
		}
		dp[i] = mn;
	}
	cout<<dp[n-1]<<endl;
	return 0;
}

	

Measured memory_bytes: 1024
package main

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

func main() {
	N, M, Q := ReadInt(), ReadInt(), ReadInt()

	as := make([]int, Q)
	bs := make([]int, Q)
	cs := make([]int, Q)
	ds := make([]int, Q)
	for q := 0; q < Q; q++ {
		as[q], bs[q], cs[q], ds[q] = ReadInt(), ReadInt(), ReadInt(), ReadInt()
	}

	fmt.Println(recur(N, M, Q, as, bs, cs, ds, []int{}))
}

func recur(N, M, Q int, as, bs, cs, ds, A []int) int {
	if len(A) == N {
		ans := 0
		for q := 0; q < Q; q++ {
			if A[bs[q]-1]-A[as[q]-1] == cs[q] {
				ans += ds[q]
			}
		}
		return ans
	}
	prev := 1
	if len(A) > 0 {
		prev = A[len(A)-1]
	}
	ans := 0
	for i := prev; i <= M; i++ {
		ans = Max(ans, recur(N, M, Q, as, bs, cs, ds, append(Dup(A), i)))
	}
	return ans
}

func Max(xs ...int) int {
	max := xs[0]
	for _, x := range xs[1:] {
		if max < x {
			max = x
		}
	}
	return max
}

func Dup(xs []int) []int {
	return append([]int{}, xs...)
}

var sc = bufio.NewScanner(os.Stdin)

func init()        { sc.Buffer(make([]byte, 256), 1e9); sc.Split(bufio.ScanWords) }
func Read() string { sc.Scan(); return sc.Text() }

func ReadInt() int {
	v, e := strconv.Atoi(Read())
	if e != nil {
		panic(e.Error())
	}
	return v
}


Measured memory_bytes: 6476
#include<iostream>

using namespace std;

int main(){
  int k=0, s=0;
  cin >> k >> s;
  int cnt = 0;
  for(int x=0; x<=k; x++){
    for(int y=0; y<=k; y++){
      int z = s-(x+y);
      if(0<=z && z<=k) cnt++;
    }
  }
  cout << cnt << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
template<class t> inline t read(t &x){
	char c=getchar();bool f=0;x=0;
	while(!isdigit(c)) f|=c=='-',c=getchar();
	while(isdigit(c)) x=(x<<1)+(x<<3)+(c^48),c=getchar();
	if(f) x=-x;return x;
}
template<class t> inline void write(t x){
	if(x<0) putchar('-'),write(-x);
	else{if(x>9) write(x/10);putchar('0'+x%10);}
}


const int N=55;
char s[N];
int n,ans;

signed main(){
	read(n);
	scanf("%s",s+1);
	for(int i=1;i+2<=n;i++){
		if(s[i]=='A'&&s[i+1]=='B'&&s[i+2]=='C') ans++;
	}
	write(ans);
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <numeric>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
long long gcd(long long a, long long  b)
{
	if (a < b) {
		a ^= b;
		b ^= a;
		a ^= b;
	}

	return b ? gcd(b, a % b) : a;
}

long long  lcm(long long a, long long b)
{
	return a * b / gcd(a, b);
}
int main()
{
	long long a, b;
	cin >> a >> b;

	if (gcd(a,b) == 1) {
		cout << a * b << endl;
	}else cout << lcm(a, b) << endl;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long; using P = pair<int,int>;
using vl = vector<ll>; using vvl = vector<vl>;
#define mp make_pair
#define pb push_back
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define rrep(i,n) for (int i=(n-1);i >= 0;i--)
#define all(v) v.begin(),v.end()
#define sz(v) (int)((v).size())
#define MAX(v) *max_element(all(v))
#define MIN(v) *min_element(all(v))
#define Sort(v) sort(all(v))
#define Rev(v) reverse(all(v))
#define vec(type,name,...) vector<type> name(__VA_ARGS__)
#define VEC(type,name,size) vector<type> name(size);in(name)
#define vv(type,name,h,...) vector<vector<type>>name(h,vector<type>(__VA_ARGS__))
#define VV(type,name,h,w) vector<vector<type>>name(h,vector<type>(w));in(name)
void debug_out() { cout << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cout << H << " ";
    debug_out(T...);
}
#ifdef _DEBUG
#define debug(...) debug_out(__VA_ARGS__)
#else
#define debug(...) 
#endif
template <typename T>
std::ostream& operator<<(std::ostream& os, std::vector<T> vec) {
    for (std::size_t i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
    return os;
}
inline void IN(void){return;}
template <typename First, typename... Rest>
void IN(First& first, Rest&... rest){cin >> first;IN(rest...);return;}
template<class T>bool chmax(T &a, const T &b) {if(a<b){a=b; return 1;} return 0;}
template<class T>bool chmin(T &a, const T &b) {if(b<a){a=b; return 1;} return 0;}
const ll INF = 1LL << 60;
const ll mod = 1000000007;
const int dx[8] = {1,0,-1,0,1,1,-1,-1}; const int dy[8] = {0,1,0,-1,1,1,-1,-1};

ll n,m,x;
ll ans = INF;

// void dfs(int i,int sum,vector<ll> val,vector<ll> &c,vector<vector<ll>> &a){
//     if(i==n-1){
//         bool f = true;
//         rep(j,m){
//             if(val[j] < x) f = false;
//         }
//         if(f) chmin(ans,(ll)sum);
//         return;
//     }
//     for(auto v : a){
//         dfs(i+1,sum,val,c,a);
//         rep(j,m) val[j] += v[j];
//         dfs(i+1,sum+c[i],val,c,a);
//     }
//     return;
// }

int main(){
    cin.tie(0); ios::sync_with_stdio(false);
    cin >> n >> m >> x;
    vec(ll,c,n);
    vv(ll,a,n,m);
    rep(i,n){
        cin >> c[i];
        rep(j,m) cin >> a[i][j];
    }
    // vector<ll> d(12);
    // dfs(0,0,d,c,a);
    for(int bit = 0;bit < (1<<n);bit++){
        ll tmp = 0;
        vector<ll> v(n);
        rep(i,n){
            if(bit & (1<<i)){
                tmp += c[i];
                rep(j,m) v[j] += a[i][j];
            }
        }
        bool f = true;
        rep(i,m){
            if(v[i] < x) f = false;
        }
        if(f) chmin(ans,tmp);
    }
    if(ans==INF) cout << -1 << endl;
    else cout << ans << endl;
}

Measured memory_bytes: 3648
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Comparator;
import java.util.PriorityQueue;

public class Main {

    public static void main(String[] args) throws Exception {
        try (BufferedReader reader = new BufferedReader(new InputStreamReader(System.in))) {
            int N = readInt(reader);

            PriorityQueue<Task> queue = new PriorityQueue<>(N, new Comparator<Task>() {
                @Override
                public int compare(Task o1, Task o2) {
                    return Long.compare(o1.limit, o2.limit);
                }
            });

            for (int i = 0; i < N; i++) {
                long[] array = readLongArray(reader);
                queue.add(new Task(array[0], array[1]));
            }

            long timeSum = 0;
            while (queue.size() > 0) {
                Task task = queue.poll();

                timeSum += task.time;
                if (timeSum > task.limit) {
                    System.out.println("No");
                    return;
                }
            }

            System.out.println("Yes");
        }
    }

    public static class Task {

        public long time;

        public long limit;

        public Task(long a, long b) {
            time = a;
            limit = b;
        }

    }

    public static int readInt(BufferedReader reader) throws Exception {
        return Integer.parseInt(reader.readLine());
    }

    public static long[] readLongArray(BufferedReader reader) throws Exception {
        String[] str = reader.readLine().split(" ");
        long[] array = new long[str.length];
        for (int i = 0; i < str.length; i++) {
            array[i] = Long.parseLong(str[i]);
        }
        return array;
    }

}


Measured memory_bytes: 64816
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define ull unsigned long long int
#define  pii pair<int,int>
ll N,M;
ll A[100001],B[100000],ans[100001];
ll arr[100001];
ll sizes[100001];
#define MOD 1000000007
int main(){
    cin>>N;
  	ll dp[N+1][4][4][4];
 	ll cnt=0;
  	memset(dp,0,sizeof dp);
  	for(int i=0;i<=3;i++)
      for(int j=0;j<=3;j++)
        for(int k=0;k<=3;k++){
          if(i==0 && j==1 && k==2) continue;
          else if(i==0 && j==2 && k==1) continue;
          else if(i==1 && j==0 && k==2) continue;
          dp[3][i][j][k]+=1;
        }
 	for(int l=4;l<=N;l++)
      for(int i=0;i<=3;i++)
      for(int j=0;j<=3;j++)
        for(int k=0;k<=3;k++){
          if(i==0 && j==1 && k==2) continue;
          else if(i==0 && j==2 && k==1) continue;
          else if(i==1 && j==0 && k==2) continue;
          for(int m=0;m<=3;m++){
            if(m==0 && j==1 && k==2) continue;
            else if(m==0 && i==1 && k==2) continue;
            dp[l][i][j][k]+=dp[l-1][m][i][j];
            dp[l][i][j][k]%=MOD;
        }
      }
  	for(int i=0;i<=3;i++)
      for(int j=0;j<=3;j++)
        for(int k=0;k<=3;k++){
          cnt+=dp[N][i][j][k];
          cnt%=MOD;
        }
    cout<<cnt%MOD;   
}

Measured memory_bytes: 256
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();
        int c = sc.nextInt();
        int d = sc.nextInt();
        while (c > 0 && a > 0){
            c = c - b;
            if (c > 0){
                a = a - d;
            }
        }
        if (a > 0){
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }

    }



Measured memory_bytes: 35668
class Tree():
    def __init__(self):
        self.root = None

    def insert(self, z):
        y = None
        x = self.root
        while x:
            y = x
            if z.key < x.key:
                x = x.left
            else:
                x = x.right
        z.p = y

        if not y:
            self.root = z
        elif z.key < y.key:
            y.left = z
        else:
            y.right = z

    def find(self, key):
        node = self.root
        while node:
            if node.key == key:
                return True
            if key < node.key:
                node = node.left
            else:
                node = node.right
        return False

    def show(self):
        self.root.inorder()
        print()
        self.root.preorder()
        print()


class Node():
    def __init__(self, key):
        self.key = key
        self.p, self.left, self.right = None, None, None

    def inorder(self):
        if self.left:
            self.left.inorder()
        print(" {}".format(self.key), end="")
        if self.right:
            self.right.inorder()

    def preorder(self):
        print(" {}".format(self.key), end="")
        if self.left:
            self.left.preorder()
        if self.right:
            self.right.preorder()


tree = Tree()
n = int(input())
for _ in range(n):
    cmd = input().split()
    if cmd[0] == "insert":
        tree.insert(Node(int(cmd[1])))
    elif cmd[0] == "find":
        print("yes" if tree.find(int(cmd[1])) else "no")
    else:
        tree.show()

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

using namespace std;

int main(){
    long long a;
    cin>>a;
    string str=to_string(a);
    long long sum=0;
    for(int i=0;i<str.size();i++){
        sum+=str[i]-'0';
    }
    if(a%sum==0) printf("Yes\n");
    else printf("No\n");

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstdlib>
#include <queue>
#include <deque>
#include <algorithm>
#include <time.h>

using namespace std;
long long n,m,x,y,ans,cnt;
long long qpow(long long xx,long long yy)
{
	long long k=1;
	while(yy!=0)
	{
		if(yy&1!=0)
			k=k*xx;
		xx=xx*xx;
		yy=yy>>1;
	}
	return k;
}
int main()
{
	scanf("%lld%lld",&n,&m);
	if(n==1)
	{
		printf("%lld",m);
		return 0;
	}
	x=m;
	ans=1;
	for(int i=2;i<=sqrt(x);i++)
	{
		cnt=0;
		while(x%i==0)
		{
			x/=i;
			cnt++;
		}
		y=cnt/n;
		if(y)
			ans=ans*pow(i,y);
	}
	printf("%lld",ans);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

// increment
#define rep_n(_1, _2, _3, NAME, ...) NAME
#define rep_2(i, n) for (int(i) = 0; (i) < (int)(n); ++(i))
#define rep_3(i, initial, n) for (int(i) = (int)(initial); (i) < (int)(n); ++(i))
#define rep(...) rep_n(__VA_ARGS__, rep_3, rep_2, rep_1)(__VA_ARGS__)
// decrement
#define rep_r_n(_1, _2, _3, NAME, ...) NAME
#define rep_r_2(i, n) for (int(i) = (int)(n); (i) > 0; (i)--)
#define rep_r_3(i, initial, n) for (int(i) = (int)(initial); (i) > (int)(n); (i)--)
#define rep_r(...) rep_r_n(__VA_ARGS__, rep_r_3, rep_r_2)(__VA_ARGS__)
// define type definition
using namespace std;
typedef long long ll;
using mpint = boost::multiprecision::cpp_int; // 多倍長整数（任意精度）
typedef pair<int, int> P;

// define construct variable
const double EPS = numeric_limits<double>::epsilon();
// 10^9 + 7
const ll MOD = ll(1e9)+7;
const ll INF = ll(1e10);
const string ALPHABET = "abcdefghijklmnopqrstuvwxyz";

// define methods
// 最大公約数
ll gcd(const ll a, const ll b) { return b ? gcd(b, a % b) : a; }
// 最小公倍数
ll lcm(const ll a, const ll b) { return a / gcd(a, b) * b; }
// char -> int
int ctoi(char c) { return (int)(c - '0'); }
// 素因数分解
vector< pair<ll, ll> > prime_factorize(ll n) {
  vector< pair<ll, ll> > p;
  for (ll i = 2; i * i <= n; i++) {
    if ((n % i) != 0) continue;
    p.push_back(make_pair(i, 0));
    while ((n % i) == 0) {
      n /= i;
      p[i].second += 1;
    }
    p.push_back(make_pair(n, 0));
  }

  if (n != 1) p.push_back(make_pair(n, 1));
  return p;
}
// 組み合わせの整合性を保つ（後ほど解析する）
ll modinv(ll a) {
	ll b = MOD, u = 1, v = 0;
	while (b) {
		ll t = a / b;
		a -= t * b;
		swap(a, b);
		u -= t * v;
		swap(u, v);
	}
	u %= MOD;
	if (u < 0) { u += MOD; }
	return u;
}
// 順列
ll permutation(const ll n, const ll m) {
	ll result = 1;
	for (ll i = n; i > n - m; i--) { result = (result * i) % MOD; }
	return result;
}

// 繰り返し n 乗法
ll repeat_square(const ll n, const ll x) {
	if (x == 0) return 1;
	ll res = repeat_square(n, x/2);
	res = res * res % MOD;
	if ((x % 2) == 1) res = res * n % MOD;
  return res;
}
// 組み合わせ
ll combination(const ll n, const ll a) {
	ll x = 1, y = 1;
  for(ll i = 0; i < a; i++){
    x = x * (n-i) % MOD;
    y = y * (i+1) % MOD;
  }
  return x * repeat_square(y, MOD-2) % MOD;
}

int main() {
	int H, W;
	cin >> H >> W;

	vector<string> S(H);
	rep(i, H) {
		cin >> S[i];
	}

	map<P, int> m;
	char white = '.';

	// 横判定
	rep(i, H) {
		bool is_exclude = true;
		rep(j, W) {
			if(S[i][j] != white) is_exclude = false;
		}
		rep(j, W) {
			if (m[P(i, j)] == 1) continue;
			m[P(i, j)] = (is_exclude) ? 1 : 0;
		}
	}


	// 縦判定
	rep(i, W) {
		bool is_exclude = true;
		rep(j, H) {
			if(S[j][i] == white) continue;
			else is_exclude = false;
		}
		rep(j, H) {
			if (m[P(j, i)] == 1) continue;
			m[P(j, i)] = (is_exclude) ? 1 : 0;
		}
	}

	rep(i, H) {
		rep(j, W) {
			int x = m[P(i, j)];
			if (x == 1) continue;
			cout << S[i][j];
		}
		cout << endl;
	}
  return 0;
}


Measured memory_bytes: 896
#include <iostream>
#include <vector>
#include <climits>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <string>
#include <bitset>
#include <utility>
#include <numeric>
#include <queue>
#include <stack>

using ll = long long;
using namespace std;

constexpr int MOD = 1e9 + 7;
constexpr ll MOD_LL = ll(1e9 + 7);

int main(void) {
	int n;
	cin >> n;
	
	vector<int> d(n);
	for(int i = 0; i < n; ++i) {
		cin >> d[i];
	}
	
	sort(d.begin(), d.end());
	
	cout << d[n / 2] - d[n / 2 - 1] << endl;
	
	return 0;
}


Measured memory_bytes: 3784
#include <stdio.h>
#include <math.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <numeric>
#include <string>
using namespace std;
typedef long long int lli;
#define urept(soeji, start, n) for (int soeji = start; soeji < n; soeji++)
#define drept(soeji, start, n) for (int soeji = start; soeji > n; soeji--)
int main(void)
{
    lli a, b, c;
    cin >> a >> b >> c;
  	if(a+b>c){
    	cout << "No" <<endl;
      	return 0;
    }
    if ((c-a-b)*(c-a-b)-4*a*b>0)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
int main(){
  char s[100005];  scanf("%s", s);
  int table[29] = {0};
  for(int i=0; i<strlen(s); i++){
    table[s[i]-97] = 1;
  }
  for(int i=0; i<26; i++){
    if(table[i] == 0){
      printf("%c\n", i+97);
      break;
    }
    if(i == 25 && table[i] == 1){
      printf("None\n");
    }
  }
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <iomanip>//setprecision
#include<math.h>
using namespace std;
#define rep(i, n)        for(int i=0; i<(int)(n); ++i)


int main(){
    long long int a,b,c,d=0;
    cin>>a;
    rep(i,a){
        cin>>b;
        while(b%2==0){
            if(b==0)break;
            d++;
            b/=2;
        }
    }
    cout<<d;
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
      String[] sn=sc.nextLine().split(" ");
int num=Integer.parseInt(sn[0]);
int num2=Integer.parseInt(sn[1]);

if(0<num && num<10 && 0<num2 && num2<10){
System.out.println(num*num2);

}else{

System.out.println(-1);
}

	}
}

Measured memory_bytes: 21844
T = int(input())
for _ in range(T):
    N = int(input())
    A = list(map(int, input().split()))
    S = list(map(int, input()))
    
    for i in range(N-1, -1, -1):
        ai = A[i]
        if ai==0:
            continue
        top = ai.bit_length() - 1
        assert ai & 1<<top
        for j in range(i-1, -1, -1):
            if A[j] >> top & 1:
                A[j] ^= ai
    for a, c in zip(A[::-1], S[::-1]):
        if c==1 and a:
            break
    else:
        print("0")
        continue
    print("1")


Measured memory_bytes: 68432
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using vs = vector<string>;
using pll = pair<ll, ll>;
using vp = vector<pll>;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repb(i, n) for (int i = (n-1); i >= 0; i--)
#define rea(i, a, b) for (int i = (a); i < (b); i++)
#define reab(i, a, b) for (int i = (a)-1; i >= (b); i--)
#define ALL(a) (a).begin(),(a).end()
#define SZ(x) ((int)(x).size())
#define PRINT(V) for (auto v:(V)) {cerr << v << " ";} cerr << endl
#define dump(x) cerr << #x << " : " << (x) << endl
#define dump2(x, y) cerr << "(" << #x << ", " << #y << ") = (" << x << ", " << y << ")" << endl
inline ll GCD(ll a, ll b){return b ? GCD(b, a % b) : a;}
inline ll divceil(ll a, ll b){return (a+b-1) / b;}
const int MOD = 1000000007;
/* END OF TEMPLATE */

multiset<ll> lbend;
multiset<ll> rbend;
ll offset = 0;
ll val = 0;

int main(){
    ll q;
    cin >> q;
    int cnt = 0;
    rep(i, q){
        int type;
        cin >> type;
        if(type == 1){
            cnt++;
            ll a, b;
            cin >> a >> b;
            offset += b;
            if(cnt % 2 && cnt >= 3){
                val += max({*(--lbend.end())-a, a-*rbend.begin(), 0ll});
                if(a < *rbend.begin()){
                    lbend.emplace(a);
                }else{
                    lbend.emplace(*rbend.begin());
                    rbend.erase(rbend.begin());
                    rbend.emplace(a);
                }
            }else if(cnt >= 2){
                val += abs(a-*(--lbend.end()));
                if(a > *(--lbend.end())){
                    rbend.emplace(a);
                }else{
                    rbend.emplace(*(--lbend.end()));
                    lbend.erase(--lbend.end());
                    lbend.emplace(a);
                }
            }else{
                lbend.emplace(a);
            }
        }else{
            cout << *(--lbend.end()) << " ";
            cout << val + offset << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 9600
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
#define FOR(i,a,b) for(int (i)=(a); (i)<=(b); (i)++)
#define REP(i,N) FOR((i), 0, (N)-1)
int gcd(int a, int b){if(a>b) swap(a,b); return a==0 ? b : gcd(b%a,a);}

int main(){
    double A,B;
    cin >> A >> B;
    cout << A / B << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#include <atcoder/all>
using namespace atcoder;
using ll= long long;
using ld= long double;
using vi= vector<int>;
using vl= vector<ll>;
using vd= vector<ld>;
using vs= vector<string>;
using vb= vector<bool>;
using vvi= vector<vector<int>>;
using vvl= vector<vector<ll>>;
using vvd= vector<vector<ld>>;
using vvs= vector<vector<string>>;
using vvb= vector<vector<bool>>;
using pll= pair<ll, ll>;
constexpr ll mod= 1e9 + 7;
#define ALL(x) (x).begin(), (x).end()
#define REP(i, n) for(ll(i)= 0; (i) < (n); (i)++)
#define REPS(i, n) for(ll(i)= 1; (i) <= (n); (i)++)
#define RREP(i, n) for(ll(i)= (n - 1); (i) >= 0; (i)--)
#define RREPS(i, n) for(ll(i)= (n); (i) > 0; (i)--)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define UNIQUE(v) v.erase(unique(ALL(v)), v.end())
#define YES(n) ((n) ? "YES" : "NO")
#define Yes(n) ((n) ? "Yes" : "No")
#define yes(n) ((n) ? "yes" : "no")

template <class T>
inline void chmin(T &a, T b) {
    if(a > b) { a= b; }
}

template <class T>
inline void chmax(T &a, T b) {
    if(a < b) { a= b; }
}

signed main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(12);
    ll A;
    cin >> A;
    REP(i,A)cout << "ACL" << (i == A-1?"\n":"");
}

Measured memory_bytes: 3616
N, K = map(int, input().split())
nums = [0] * (10 ** 5+1)
for _ in range(N):
    a, b = map(int, input().split())
    nums[a] += b

for i in range(1, 10 ** 5 + 2):
    if K <= nums[i]:
        print(i)
        break
    K -= nums[i]


Measured memory_bytes: 5736
#include <iostream>
#include <cstdio>
#include <vector>
#include <string>
#include <array>
#include <queue>
#include <deque>
#include <set>
#include <list>
#include <map>
#include <stack>
#include <utility>
#include <algorithm>
#include <numeric>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <cstring>
#include <climits>
#include <bitset>
#include <random>
#include <functional>
#include <sstream>
#include <iomanip>

using namespace std;

#define _CRT_SECURE_NO_WARNINGS
#define rep(i, n) for(int i=0; i<(n); i++)
#define FOR(i, m, n) for(int i=(m);i<(n);i++)
#define SZ(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define SORT(x) sort((x).begin(),(x).end())
#define REVE(x) reverse((x).begin(),(x).end())
#define mp make_pair
#define pb push_back

typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<vector<int>> VVI;
typedef pair<int, int> PII;
typedef long long LL;

int main() {
	FOR(i, 1, 10) {
		FOR(j, 1, 10) {
			printf("%dx%d=%d\n", i, j, i*j);
		}
	}
}


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

using namespace std;

#define INF 1000007
#define MOD 1000000007
#define maxn 100
#define int long long int
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define rep(i, n) FOR(i, 0, n)

int gcd(int a, int b) {
    return b ? gcd(b, a % b) : a;
}

int lcm(int a, int b) { return a / gcd(a, b) * b; }

int mpow(int N, int P, int M)  //繰り返し自乗法
{
    if (P == 0)
        return 1;
    if (P % 2 == 0) {
        int t = mpow(N, P / 2, M);
        return t * t % M;
    }
    return N * mpow(N, P - 1, M) % M;
}

int counter(int x) {           //bit計算
    if (x == 0) return 0;
    return counter(x >> 1) + (x & 1);
}

vector<bool> prime(maxn + 1, true); //素数テーブル
void prime_table(void) {
    prime[0] = false;
    prime[1] = false;
    for (int i = 2; i * i <= maxn; i++) {
        if (!prime[i]) {
            continue;
        }
        for (int j = i + i; j <= maxn; j += j + i) {
            prime[j] = false;
        }
    }
}

bool IsPrime(int num) {   //素数判定
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false;

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

    return true;
}

signed main() {
    int K, T;
    cin >> K >> T;
    vector<int> a;
    int all = 0;
    rep(i, T) {
        int A;
        cin >> A;
        all += A;
        a.push_back(A);
    }
    sort(a.begin(), a.end(), greater<int>());
    all -= a[0];
    if (all >= a[0]) {
        cout << "0" << endl;
    } else {
        cout << (a[0] - 1) - all;
    }

}


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

int main(void)
{
    char s[5];
    cin>>s;
    int a = 0, b = 0;
    for(int i=0;s[i]!='\0';++i){
        if(s[i]=='A') ++a;
        else ++b;
    }
    if(a && b) puts("Yes");
    else puts("No");
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define INFLL 1e17
#define MOD 1000000007
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef pair<ll,ll> pr;

vector<vector<pair<int,ll>>>G;
vector<ll>dist;
// vの座標は事前に設定
void DFS(int v){
    for(auto &itr:G[v]){
    //    cout<<dist[itr.first]<<"=dist.    from "<<v<<" to "<<itr.first<<endl;
        if(dist[itr.first]!=-INFLL){
            if(dist[itr.first]!=dist[v]+itr.second){
                cout<<"No";
                exit(0);
            }
            continue;
        }
        dist[itr.first]=dist[v]+itr.second;
        DFS(itr.first);
    }
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,m;
    int l,r;
    ll d;
    cin>>n>>m;
    G=vector<vector<pair<int,ll>>>(n);
    dist=vector<ll>(n,-INFLL);
    for(int i=0;i<m;i++){
        cin>>l>>r>>d;
        G[l-1].push_back(make_pair(r-1,d));
        G[r-1].push_back(make_pair(l-1,-d));
    }
    for(int i=0;i<n;i++){
        if(dist[i]==-INFLL){
            dist[i]=0;
            DFS(i);
        }
    }
    cout<<"Yes";
    return 0;
}


Measured memory_bytes: 16512
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define forin(in) for(int i=0; i<(int)in.size(); i++) cin>>in[i]
#define forout(out) for(int i=0; i<(int)out.size(); i++) cout<<out[i]<<endl
#define rep(i, n) for(int i=0; i<(n); i++)

int main(){
    int n; cin>> n;
    vector<ll> a(n+1), b(n);
    forin(a);
    forin(b);

    ll rem;
    ll ans=0;
    ll zero=0;
    rep(i, n){
        rem=max(zero, b[i] - a[i]);
        ans += min(rem, a[i+1]);
        a[i+1] -= min(rem, a[i+1]);
        ans += min(a[i], b[i]);
    }
    cout<< ans << endl;
}

Measured memory_bytes: 4840
using System;
using System.Diagnostics;
using System.IO;
using System.Linq;

namespace AtCoder {
    class Practice {
        static void Main() => CustomMain();

        static void Solve() {
            var a = ReadInt();

            WriteAnswer(IsOdd(a) ? a * 2 : a);
        }

        static void CustomMain() {
#if DEBUG
            // ファイルからテストケースを読み込む
            global::Common.ChangeStdIn();
            // 時間計測
            var stopwatch = new Stopwatch();
            stopwatch.Start();
#endif
            // 出力高速化
            var streamWriter = new StreamWriter(Console.OpenStandardOutput()) {AutoFlush = false};
            Console.SetOut(streamWriter);
            // 回答
            Solve();
#if DEBUG
            stopwatch.Stop();
            Console.WriteLine(stopwatch.Elapsed);
#endif
            Console.Out.Flush();
        }

        static string ReadString() => Console.ReadLine().Trim();
        static int ReadInt() => int.Parse(ReadString());
        static long ReadLong() => long.Parse(ReadString());
        static float ReadFloat() => float.Parse(ReadString());
        static double ReadDouble => double.Parse(ReadString());

        static string[] ReadStringArray() => ReadString().Split(' ');
        static int[] ReadIntArray() => Array.ConvertAll(ReadString().Split(' '), int.Parse);
        static long[] ReadLongArray() => Array.ConvertAll(ReadString().Split(' '), long.Parse);
        static float[] ReadFloatArray() => Array.ConvertAll(ReadString().Split(' '), float.Parse);
        static double[] ReadDoubleArray() => Array.ConvertAll(ReadString().Split(' '), double.Parse);

        static T TypeConversion<T>(string s) {
            if (typeof(T) == typeof(int)) {
                return (T) Convert.ChangeType(int.Parse(s), typeof(T));
            } else if (typeof(T) == typeof(long)) {
                return (T) Convert.ChangeType(long.Parse(s), typeof(T));
            } else if (typeof(T) == typeof(double)) {
                return (T) Convert.ChangeType(double.Parse(s), typeof(T));
            } else {
                return (T) Convert.ChangeType(s, typeof(T));
            }
        }

        static void ReadMulti<T, U>(out T a, out U b) {
            var str = ReadStringArray();
            a = TypeConversion<T>(str[0]);
            b = TypeConversion<U>(str[1]);
        }

        static void ReadMulti<T, U, V>(out T a, out U b, out V c) {
            var str = ReadStringArray();
            a = TypeConversion<T>(str[0]);
            b = TypeConversion<U>(str[1]);
            c = TypeConversion<V>(str[2]);
        }

        static void WriteAnswer(object ans) => Console.WriteLine(ans);

        static bool IsOdd(long num) {
            return (num & 1) == 1;
        }

        static bool IsEven(long num) {
            return (num & 1) == 0;
        }

        static long GCD(long a, long b) {
            return b != 0 ? GCD(b, a % b) : a;
        }
    }
}

Measured memory_bytes: 13140
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define FORR(i,a,b) for (int i=(a);i>=(b);i--)
#define pb push_back
#define pcnt __builtin_popcount
#define show(x) cout<<#x<<" = "<<x<<endl;
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define fi first
#define se second
#define rng(a) (a.begin()),(a.end())
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define sz(x) (int)(x).size()
#define mp make_pair

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
typedef set<int> si;
typedef pair<ll,ll> pll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<pll> vpll;
typedef set<ll> sl;
typedef __int128_t lll;
typedef pair<lll,lll> plll;
typedef vector<lll> vlll;
template<typename T>string join(vector<T>&v)
{stringstream s;FOR(i,0,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename A, size_t N, typename T>void Fill(A (&array)[N], const T&v)
{fill((T*)array,(T*)(array+N),v);}
template<typename T> T gcd(T a,T b){if(a>b)swap(a,b);for(;a>0;b%=a,swap(a,b));return b;}
ll modpow(lll a,lll n,ll m){if(a==0)return a;lll p=1;for(;n>0;n/=2,a=a*a%m)if(n&1)p=p*a%m;return(ll)p;}
void dout(double d){printf("%.12f\n",d);}

const int iinf = 1e9;
const ll linf = 1e18;
const int mod = 1e9+7;
const double pi = acos(-1);
const double eps = 1e-10;
ll a, n;
main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> n;
  ll b=-1, ans = -1;
  FOR(i, 0, n){
    cin >> a;
    if(a > b + 1){
      cout << -1 << endl;
      return 0;
    }
    ans += (a==b+1) ? 1 : a;
    b = a;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
import math


def is_distance_integer(p1, p2):
    n = len(p1)

    total = 0
    for i in range(n):
        total += ((p1[i] - p2[i])**2)

    dist = int(math.sqrt(total))

    return (dist**2) == total


def count_pairs(points):
    cnt = 0
    n = len(points)

    for i in range(n):
        for j in range(i + 1, n):
            if is_distance_integer(points[i], points[j]):
                cnt += 1

    return cnt


def main():
    N, D = map(int, input().split())

    points = []
    for _ in range(N):
        points.append(list(map(int, input().split())))

    ans = count_pairs(points)

    print(ans)


main()




Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
#include <cmath>
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF=1001001001;
vector<pair<int64_t,int64_t>>func(int64_t x){
  vector<pair<int64_t,int64_t>>p;
  for(int64_t i=2;i*i<=x;i++){
    int cnt=0;
    if(x%i==0){
    while(x%i==0){cnt++;x/=i;}
    p.push_back(make_pair(i,cnt));
    }
  }
  if(x!=1){p.push_back(make_pair(x,1));}
  return p;
}
int g[15][15];
int main() {
  int N;
  cin>>N;
  for(int i=0;i<N;i++){
    for(int j=0;j<N;j++){
      g[i][j]=-1;
    }
  }
  for(int i=0;i<N;i++){
    int A;
    cin>>A;
    for(int j=0;j<A;j++){
      int x,y;
      cin>>x>>y;
      x--;
      g[i][x]=y;
    }
  }
  int ans=0;
  for(int i=0;i<(1<<N);i++){
    vector<int>d(N);
    for(int j=0;j<N;j++){
      if(i>>j&1){d[j]=1;}
    }
    bool ok=true;
    for(int j=0;j<N;j++){
      if(d[j]==1){
        for(int k=0;k<N;k++){
          if (g[j][k]==-1) continue;
          if (g[j][k]!=d[k]) ok = false;
        }
      }
    }
    if(ok){ans=max(ans,__builtin_popcount(i));}
  }

  cout<<ans<<endl;

  return 0;
}

Measured memory_bytes: 3576
#pragma GCC optimize ("O3")

#include <bits/stdc++.h>

using namespace std;

#ifdef LOCAL
#include <prettyprint.hpp>
#define debug(...)  cerr << "[" << #__VA_ARGS__ << "]: ", d_err(__VA_ARGS__);
#else
#define debug(...) 83;
#endif

void d_err() {
    cerr << endl;
}

template <typename H, typename... T>
void d_err(H h, T... t) {
    cerr << h << " ";
    d_err(t...);
}

template <typename T>
void print(T x) {
    cout << x << endl;
}

#define ALL(x) (x).begin(), (x).end()
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define REVFOR(i, m, n) for (int i = (n - 1); i >= (m); --i)
#define REP(i, n) FOR(i, 0, n)
#define REVREP(i, n) REVFOR(i, 0, n)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define bcnt __builtin_popcountll

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<ll,ll> Pll;
typedef pair<int,int> Pin;

ll INF = 1e16;
int inf = 1e9;
ll MOD = 1e9+7;

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

    vll X(N);
    REP(i, N) cin >> X[i];

    vll Y = X;
    sort(ALL(Y));

    REP(i, N) {
        if (lower_bound(ALL(Y), X[i]) - Y.begin() + 1 <= N / 2) {
            print(Y[N / 2]);
        } else {
            print(Y[N / 2 - 1]);
        }
    }
}


Measured memory_bytes: 6344
#!/usr/bin/env python3

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append((i, cnt))

    if temp!=1:
        arr.append((temp, 1))

    if arr==[]:
        arr.append((n, 1))

    return arr

n = I()
a = LI()
lst = [0]*(10**6+1)
for i in a:
    l = factorization(i)
    for (j,k) in l:
        lst[j] = max(lst[j],k)

t = 1
for i in range(1,10**6+1):
    if lst[i] != 0:
        t = t*(i**lst[i]) % mod
ans = 0
for i in a:
    ans += t*pow(i,mod-2,mod) % mod
    ans %= mod
print(ans)

Measured memory_bytes: 52828