akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while(true) {
			int n = sc.nextInt();
			if(n == 0)break;
			double[] s = new double[n];
			double sum = 0;
			for(int i = 0; i < n; i++) {
				s[i] = sc.nextInt();
				sum += s[i];
			}
			double m = sum / n;
			double v = 0;
			for(int i = 0; i < n; i++) {
				v += (s[i] - m) * (s[i] - m);
			}
			v = v / n;
			System.out.println(Math.sqrt(v));
		}
		sc.close();
	}		
}



Measured memory_bytes: 31104
#include<bits/stdc++.h>
#define V vector
#define VI vector<int>
#define VVI vector<vector<int>>
#define REP(i,n) for(int i=0;i<(n);i++)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define MOD 1000000007
#define INF 1e9
#define F first
#define S second
#define All(x) (x).begin(),(x).end()
using namespace std;
const double PI = acos(-1);
typedef long long ll;

int main(void) {
  int r;cin>>r;
  cout<<r*r<<endl;
}


Measured memory_bytes: 256
N = gets.to_i
a = []
a = gets.split.map(&:to_i)

# 左端からGCDを累積していく
l = []
l[0] = 0
1.upto(N) do |i|
  # i番目以下のgcd = i-1番目以下のgcdとa[i]のgcd(lは1からスタートなので注意)
  l[i] = l[i-1].gcd(a[i-1])
end

# 右端からGCDを累積していく
r = []
r[N] = 0
(N-1).downto(0) do |i|
  # i番目以上のgcd = i+1番目以上のgcdとa[i]のgcd
  r[i] = r[i+1].gcd(a[i])
end

"ここまでO(NlogA1+NlogAn)"

m = 0
# ここもO(N)なのでボトルネックがO(N^2)にならないので耐え
N.times do |i|
  # 自分より左の全gcdと右の全gcdのgcd
  # 上で累積のgcdを計算しているのでこれはO(1)で取り出せる
  g = l[i].gcd(r[i+1])
  m = [g, m].max
end

puts m

Measured memory_bytes: 12756
import java.util.Scanner;
import java.util.Arrays;

public class Main{
  static int n;
  static long[] a;

  static final boolean DEBUG = false;

  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);

    n = sc.nextInt();
    a = new long[n];
    for(int i = 0; i < n; i++){
      a[i] = sc.nextInt();
    }

    long count = 0, count2 = 0;
    long sum = a[0];
    long sum2 = a[0] < 0 ? 1 : -1;
    count2 = Math.abs(sum2 - a[0]);

    if(a[0] == 0){
      sum = 1;
      count = count2 = 1;
      sum2 = -1;
    }

    for(int i = 1; i < n; i++){
      long val = a[i], val2 = a[i];
      if(!((sum > 0 && sum + a[i] < 0) || 
            (sum < 0 && sum + a[i] > 0))){
        val = -sum + ((sum < 0) ? 1 : -1);
        count += Math.abs(val - a[i]);
      }
      if(!((sum2 > 0 && sum2 + a[i] < 0) || 
            (sum2 < 0 && sum2 + a[i] > 0))){
        val2 = -sum2 + ((sum2 < 0) ? 1 : -1);
        count2 += Math.abs(val2 - a[i]);
      }
      sum += val;
      sum2 += val2;
    }

    if(DEBUG){
      System.out.println(Arrays.toString(a));
    }

    System.out.println(Math.min(count, count2));
  }
}


Measured memory_bytes: 50400
def main():
  def add(i,x):
    i+=1
    while i<=n:
      bit[i-1]+=x
      i+=i&-i
  def sum_sub(i):
    a=0
    i+=1
    while i:
      a+=bit[i-1]
      i-=i&-i
    return a
  def sum(i,j):
    a=sum_sub(j+1)
    if i!=0:a-=sum_sub(i-1)
    return a
  
  n,q,*x=map(int,open(0).read().split())
  a=x[:n]
  queries=[]
  for i in range(q):
    l,r=x[n+i*2:n+(i+1)*2]
    l-=1
    r-=1
    queries.append(r<<40|l<<20|i)
  ans=[0]*q
  queries.sort()
  for i in range(q):
    ind=queries[i]%(1<<20)
    queries[i]>>=20
    l=queries[i]%(1<<20)
    queries[i]>>=20
    r=queries[i]
    queries[i]=[r,l,ind]
  queries.append([10*20])
  lastAppeared=[-1]*n
  bit=[0]*n
  j=0
  for i in range(n):
    if lastAppeared[a[i]-1]!=-1:
      add(lastAppeared[a[i]-1],-1)
      add(i,1)
      lastAppeared[a[i]-1]=i
    else:
      add(i,1)
      lastAppeared[a[i]-1]=i
    while queries[j][0]==i:
      r,l,ind=queries[j]
      j+=1
      ans[ind]=sum(l,r-1)
  print(*ans)
if __name__ == "__main__":
  main()

Measured memory_bytes: 312328
S = input()
O = ['R','U','D']
E = ['L','U','D']
ng = False
for i in range(len(S)):
  if i % 2 == 0:
    if S[i] not in O:
      ng = True
      break
  else:
    if S[i] not in E:
      ng = True
      break
print('No') if ng else print('Yes')


Measured memory_bytes: 9112
#include <iostream>
#include <cstdio>
#include <vector>
#define MAX_N 50
using namespace std;
int n, m, dfn[MAX_N+5], low[MAX_N+5], ind, ans;
vector <int> G[MAX_N+5];
void DFS(int u, int fa) {
	dfn[u] = low[u] = ++ind;
	for (int i = 0; i < G[u].size(); i++) {
		int v = G[u][i];	if (v == fa)	continue;
		if (!dfn[v])	DFS(v, u);
		low[u] = min(low[u], low[v]);
	}
	if (low[u] >= dfn[u])	ans++;
}
int main() {
	cin >> n >> m;
	for (int i = 1, u, v; i <= m; i++)	cin >> u >> v, G[u].push_back(v), G[v].push_back(u);
	for (int i = 1; i <= n; i++)
		if (!dfn[i])	DFS(i, 0);
	printf("%d", ans-1);
	return 0;
}


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

int main(void){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n;
    cin >> n;
    int a[1010][1010] = {};
    int head[1010] = {};
    rep(i,n){
        rep(j,n-1){
            int x;
            cin >> x;
            x--;
            a[i][j] = x;
        }
    }
    int turn = 0;
    vector<int> used(n, -1);
    while(true){
        bool ng = true;
        int empty_cnt = 0;
        rep(i,n){
            if (head[i] == n-1) {
                empty_cnt++;
                continue;
            }
            int j = a[i][head[i]];
            if (used[i] == turn || used[j] == turn) continue;
            if (a[j][head[j]] == i) {
                head[i]++;
                head[j]++;
                used[i] = used[j] = turn;
                ng = false;
            }
        }
        if (empty_cnt == n) break;
        if (ng) {
            cout << -1 << endl;
            return 0;
        }
        turn++;
    }
    cout << turn << endl;

    return 0;
}


Measured memory_bytes: 4224
n, m = gets.chomp.split.map(&:to_i)
array = []
m.times { array << gets.chomp.split.map(&:to_i) }

array.flatten!

ret = []
(1..n).each do |i|
  ret << array.select { |a| a == i }.size
end
ret.each {|r| puts r }


Measured memory_bytes: 1788
#include<iostream>
using namespace std;
int main()
{
	long long n,y;
	cin>>n>>y;
	for (int i=0;i<=y/10000;i++)
	{
		for (int j=0;j<=y/5000;j++)
		{
			int k=n-i-j;
			if (k>=0&&i*10000+j*5000+k*1000==y)
			{
				cout<<i<<' '<<j<<' '<<k<<endl;
				return 0;
			}
		}
	}
	cout<<"-1 -1 -1"<<endl;
	return 0;
}

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

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  int a,b,c;
  vector<int> dp(3);
  cin >> a >> b >> c;
  dp[0] = a;
  dp[1] = b;
  dp[2] = c;
  for(int i = 1; i<n;i++){
    cin >> a >> b >> c;
    a+= max(dp[1], dp[2]);
    b+= max(dp[0], dp[2]);
    c+= max(dp[0], dp[1]);
    dp[0] = a; dp[1] = b; dp[2] = c; 
  }
  cout <<max({dp[0],dp[1],dp[2]})<<'\n';
  return 0;
}


Measured memory_bytes: 3656
#include "bits/stdc++.h"

using namespace std;

using ll = long long;
using ld = long double;
using P = pair<int, int>;
constexpr ld EPS = 1e-12;
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr int MOD = 1e9 + 7;

template <typename T>
void printv(const vector<T> &v)
{
    int sz = v.size();
    for (int i = 0; i < sz; i++)
    {
        cout << v[i] << " \n"[i == sz - 1];
    }
}

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

    int n;
    cin >> n;
    string s;
    cin >> s;
    reverse(s.begin(), s.end());
    s = "$" + s;
    vector<int> sum(n + 1, 0);
    for (int i = 1; i <= n; i++)
    {
        sum[i] = sum[i - 1];
        if (s[i] == '#')
            sum[i]++;
    }
    int ret = INF;
    for (int i = 0; i <= n; i++)
    {
        int tmp = i - sum[i];
        tmp += sum[n] - sum[i];
        ret = min(ret, tmp);
    }
    cout << ret << endl;
}


Measured memory_bytes: 1360
/*
 * FileName:     B
 * CreatedDate:  2020-04-12 20:56:29 +0900
 * LastModified: 2020-04-12 21:58:41 +0900
 */

#include <stdio.h>

int main(void){
    long int n;
    scanf("%ld",&n);
    long int count=0;
    for(long int i=0;i<n+1;i++){
        if(i%3!=0&&i%5!=0){
            count+=i;
        }
    }
    printf("%ld\n",count);
    return 0;
}


Measured memory_bytes: 1732
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
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; }

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	double a, b, x;
	cin >> a >> b >> x;
	double s = x / a;
	double rad;
	if(s >= a*b/2){
		double h = (a*b - s) * 2 / a;
		rad = atan2(h, a);
	}
	else{
		double w = s*2/b;
		rad = atan2(b, w);
	}
	double PI = acos(-1);
	double deg = rad / (2*PI) * 360;
	cout << fixed << setprecision(12) << deg << endl;
	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define all(x) (x).begin(), (x).end()
#define INF 1000000007
#define mod 1005
#define ll long long int
int main()
{
	int t = 1;
//	cin>>t;
	
	while(t--)
	{
		ll a, b, k;
		cin>>a>>b>>k;
		ll left = 0;
		if(a>=k)
		{
			a = a-k;
			left = 0;
		}
		else
		{
			left = k-a;
			a = 0;
		}
		b = max(0*1LL, b-left);
		cout<<a<<" "<<b<<"\n";
	}
}

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

int main(){
    string s,t;
    cin>>s>>t;
    s+=s;
    bool ok=false;
    for(int i=0; i<s.size(); ++i){
        if(s.substr(i,t.size())==t)ok=true;
    }
    cout<<(ok?"Yes":"No")<<endl;
    return 0;
}


Measured memory_bytes: 3216
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <cmath>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <iostream>
#include <random>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include <fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
#include <cctype>
#include <bitset>
using namespace std;

using ll = long long;
using vll = vector<long long>;
using pll = pair<long long, long long>;
#define rep(i,n) for(long long i(0);(i)<(n);(i)++)


ll gcd (ll a, ll b){
    if(b == 0)
        return a;
    return gcd(b, a % b);
}

ll myrec(ll N, ll X){
    if(X == 0) 
        return 0;
    if(X == 1)
        return 3*(N-1);
    if(2*X == N)
        return 3*X;
    if(2*X < N){
        ll Nnew = N%X + X;
        ll d = myrec(Nnew, X);
        return d + 3*(N-Nnew);
    }
    if(2*X > N){ 
        ll Nnew = N-X + X%(N-X);
        ll d = myrec(Nnew, X%(N-X));
        return d + 3*(N-Nnew);
    }
}

void solve(long long N, long long X){
    ll k = gcd(N, X);
    ll ans = myrec(N/k, X/k);
    cout << ans*k << endl;
}

int main(){
    long long N;
    scanf("%lld",&N);
    long long X;
    scanf("%lld",&X);
    solve(N, X);
    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;
using P = pair<int,int>;

int main() {
    int n,m;
    cin >> n >> m;
    vector<int> a(m);
    vector<int> b(m);
    if(m%2==0){
        int c=m+1, d=1, i=0;
        while(c-d>0){
            a[i]=d; b[i]=c;
            ++d; --c; ++i;
        }
        int e=m+2, f=2*m+1;
        while(f-e>0){
            a[i]=e; b[i]=f;
            ++e; --f; ++i;
        }
    }else{
        int c=m, d=1, i=0;
        while(c-d>0){
            a[i]=d; b[i]=c;
            ++d; --c; ++i;
        }
        int e=m+1, f=2*m+1;
        while(f-e>0){
            a[i]=e; b[i]=f;
            ++e; --f; ++i;
        }
    }
    rep(i,m){
        cout << a[i] << " " << b.at(i) << "\n";
    }
    return 0;
}

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

int main(){
  int c[3][3];
  for(int i = 0; i < 3; i++){
    for(int j = 0; j < 3; j++){
      cin >> c[i][j];
    }
  }

  int b = 0;
  for(int i = 1; i <= 2; i++){
    b = c[i][0] - c[0][0];
    for(int j = 1; j <= 2; j++){
      if(b != c[i][j] - c[0][j]){
        cout << "No" << endl;
        return 0;
      }
    }
  }

  cout << "Yes" << endl;

  return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {

	/**
	 * @param args
	 */
	public static Scanner sc = new Scanner(System.in);
	
	
	void run() {
		int n = sc.nextInt();
		int a, b, c;
		for (int i = 0; i < n; i++) {
			a = sc.nextInt();
			b = sc.nextInt();
			c = sc.nextInt();
			if (a*a+b*b == c*c || b*b+c*c == a*a || c*c+a*a == b*b)
				System.out.println("YES");
			else
				System.out.println("NO");
		}
		
	}
	
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		new Main().run();
	}

}

Measured memory_bytes: 21588
#include<cstdio>
#include<algorithm>
using namespace std;
int n;
long long A, B, C, Mod = 1000000007, F[1010000], InvF[1010000];
long long PA, PB;
long long Pow(long long a, long long b) {
	long long r = 1;
	while (b) {
		if (b & 1)r = r * a%Mod;
		a = a * a%Mod; b >>= 1;
	}
	return r;
}
long long Inv(long long a) {
	return Pow(a, Mod - 2);
}
long long Comb(int a, int b) {
	if (b < 0 || a < b)return 0;
	return F[a] * InvF[b] % Mod*InvF[a - b] % Mod;
}
long long Prob(int a, int b) {
	return Pow(PA, a)*Pow(PB, b) % Mod*Comb(a + b, a) % Mod;
}
int main() {
	int i;
	scanf("%d%lld%lld%lld", &n, &A, &B, &C);
	F[0] = 1;
	for (i = 1; i <= 1000000; i++)F[i] = F[i - 1] * i%Mod;
	InvF[1000000] = Inv(F[1000000]);
	for (i = 1000000; i >= 1; i--)InvF[i - 1] = InvF[i] * i%Mod;
	PA = Inv(A + B)*A%Mod;
	PB = Inv(A + B)*B%Mod;
	long long res = 0;
	for (i = 0; i < n; i++) {
		res = (res+Prob(n - 1, i) * (n - 1 + i + 1) % Mod*PA)%Mod;
		res = (res+Prob(i, n - 1) * (n - 1 + i + 1) % Mod*PB)%Mod;
	}
	res = res * (A + B + C) % Mod*Inv(A+B) % Mod;
	printf("%lld\n", res);
}

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

using VI = vector<int>;
using VVI = vector<VI>;
using PII = pair<int, int>;
using LL = long long;
using VL = vector<LL>;
using VVL = vector<VL>;
using PLL = pair<LL, LL>;
using VS = vector<string>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

#define FF first
#define SS second

#define DUMP(x) cout<<#x<<":"<<(x)<<endl
template<class S, class T>
istream& operator>>(istream& is, pair<S,T>& p){
  return is >> p.FF >> p.SS;
}
template<class T>
istream& operator>>(istream& is, vector<T>& xs){
  for(auto& x: xs)
	is >> x;
  return is;
}
template<class S, class T>
ostream& operator<<(ostream& os, const pair<S,T>& p){
  return os << p.FF << " " << p.SS;
}
template<class T>
ostream& operator<<(ostream& os, const vector<T>& xs){
  for(unsigned int i=0;i<xs.size();++i)
	os << (i?" ":"") << xs[i];
  return os;
}
template<class T>
void maxi(T& x, T y){
  if(x < y) x = y;
}
template<class T>
void mini(T& x, T y){
  if(x > y) x = y;
}


const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL MOD = 1e9+7;

int dx[] = {-1,0,1,0};
int dy[] = {0,-1,0,1};

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

  int H, W;
  cin >> H >> W;
  VS vs(H);
  cin >> vs;

  PII s, g;
  REP(y,H) REP(x,W){
	if(vs[y][x] == 'S'){
	  s = MP(y,x);
	  vs[y][x] = '.';
	}
	else if(vs[y][x] == 'G'){
	  g = MP(y,x);
	  vs[y][x] = '.';
	}
  }

  auto isin = [&](PII p){ return 0 <= p.FF && p.FF < H && 0 <= p.SS && p.SS < W; };

  map<PII,int> dist;
  using D = pair<int,PII>;
  priority_queue<D,vector<D>,greater<D>> pq;
  pq.push(MP(0,s));
  dist[s] = 0;
  while(!pq.empty()){
	auto d = pq.top();
	pq.pop();
	if(dist[d.SS] < d.FF) continue;

	REP(di,4){
	  PII np(d.SS.FF+dy[di], d.SS.SS+dx[di]);
	  if(!isin(np)) continue;
	  if(vs[np.FF][np.SS] == 'o'){
		int nd = d.FF + 1;
		if(!dist.count(np) || dist[np] > nd){
		  dist[np] = nd;
		  pq.push(MP(nd, np));
		}
	  }
	  if(vs[np.FF][np.SS] == 'x' || vs[np.FF][np.SS] == '.'){
		int nd = d.FF + 2;
		for(int tt=1;tt<=3;++tt){
		  PII nnp = MP(d.SS.FF + dy[di]*tt, d.SS.SS + dx[di]*tt);
		  if(!isin(nnp) || vs[nnp.FF][nnp.SS] == '#') break;
		  ++nd;
		  if(!dist.count(nnp) || dist[nnp] > nd){
			dist[nnp] = nd;
			pq.push(MP(nd, nnp));
		  }
		}
	  }
	  if(vs[np.FF][np.SS] == '.'){
		int nd = d.FF + 2;
		if(!dist.count(np) || dist[np] > nd){
		  dist[np] = nd;
		  pq.push(MP(nd, np));
		}
	  }
	}
  }

  cout << dist[g] << endl;

  return 0;
}



Measured memory_bytes: 3184
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <numeric>

using namespace std;

int main(){
   int n;
   cin>>n;
   vector<int> a(n);
   for(int i=0;i<n;i++){
      cin>>a[i];
      a[i]--;
   }
   int b=a[0];
   for(int i=1;i<n;i++){
      if(b==1){
         cout<<i<<endl;
         return 0;
      }
      else b=a[b];
   }
   cout<<-1<<endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define in(x,y,h,w) x >= 0 && x < h && y >= 0 && y < w

#define int long long
//typedef    long long          ll;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      P;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
 
const int INF=1e+18;
const double EPS=1e-9;
const int MOD=1000000007;
 
const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};

signed main(){
	int n,a[1000],maa = -INF,mai,mat,ans[2];
	vector<int> vec[2];
	cin >> n;
	for(int i = 0;i < n;i++){
		cin >> a[i];
		if(maa < a[i]){
			maa = a[i];
			mai = i;
		}
	}
	if(maa <= 0){
		cout << maa << endl << n - 1 << endl;
		for(int i = n;i > mai + 1;i--) cout << i << endl;
		for(int i = 0;i < mai;i++) cout << 1 << endl;
		return 0;
	}
	for(int i = 0;i < 2;i++){
		if(i == n % 2) vec[i].pb(n);
		ans[i] = -INF;
		if(i) vec[i].pb(1);
		int s = 0,sum = 0,cnt = 0;
		for(int j = i;j < n;j += 2){
			if(s == 0){
				if(a[j] < 0){
					vec[i].pb(1);
					vec[i].pb(1);
				}else{
					sum += a[j];
					s = 1;
				}
			}else if(s == 1){
				if(a[j] >= 0){
					cnt++;
					sum += a[j];
				}
				else{
					if(j != n - 1 - (i == n % 2)) vec[i].pb(cnt * 2 + 3);
					else{
						vec[i].pb(cnt * 2 + 3);
						vec[i].pb(cnt * 2 + 2);
					}
				}
			}
		}
		for(int j = 0;j < cnt;j++) vec[i].pb(2);
		ans[i] = sum;
	}
	if(ans[0] < ans[1]) mat = 1;
	else mat = 0;
	cout << ans[mat] << endl << vec[mat].size() << endl;
	for(int v : vec[mat]) cout << v << endl;
	return 0;
}

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

void fnInput(string& rsNum, bool& rbRslt)
{
  int nDigit, nInfSiz;
  cin >> nDigit >> nInfSiz;
  rsNum.resize(nDigit, ' ');

  rbRslt = true;

  for (int i = 0; i < nInfSiz; i++)
  {
    int nPos, nNum;
    cin >> nPos >> nNum;

    if (nPos == 1 && nNum == 0 && nDigit > 1)
      rbRslt = false;
    else if (rsNum[nPos - 1] == ' ')
      rsNum[nPos - 1] = ('0' + nNum);
    else if (rsNum[nPos - 1] != ('0' + nNum) )
      rbRslt = false;
    else
      continue;
  }
  return;
}
  
string fnNumstrGet(string sNum)
{
  for (int i = 0; i < sNum.size(); i++)
    if (sNum[i] == ' ')
      if ( !i )
        if (sNum.size() == 1) sNum[i] = '0';
        else                  sNum[i] = '1';
      else                    sNum[i] = '0';

  return sNum;
}
  
int main()
{
  string sNum;
  bool bRslt;

  fnInput(sNum, bRslt);
  if (!bRslt)
  {
    cout << "-1" << endl;
    return 0;
  }
  cout << fnNumstrGet(sNum) << endl;

  return 0;
}

Measured memory_bytes: 256
/*
F - Three Variables Game
https://atcoder.jp/contests/abc166/tasks/abc166_f

*******UNSOLVED*******

Failed cases:
killer_01.txt		2 ms	3564 KB
killer_02.txt		2 ms	3484 KB
killer_03.txt		2 ms	3608 KB
killer_04.txt		2 ms	3484 KB
killer_05.txt		2 ms	3596 KB
killer_07.txt		2 ms	3516 KB
killer_08.txt		2 ms	3608 KB
killer_09.txt		2 ms	3496 KB
killer_10.txt		2 ms	3552 KB
*/

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

#define FAST_INP  ios_base::sync_with_stdio(false);cin.tie(NULL)
int main()  
{ 
    FAST_INP;
    int n; string ss;
    vector<char> ans;
    vector<string> s;
    unordered_map<char,int> m;
    cin >> n >> m['A'] >> m['B'] >> m['C'];
    for(int i=0;i<n;i++) {
        cin >> ss;
        s.push_back(ss);
    }
    for(int i=0;i<n;i++){
        char x=s[i][0],y=s[i][1];
        if(m[x]>m[y]) {
            m[y]++; m[x]--;
            ans.push_back(y);
        } else if(i+1<n&&m[x]==m[y]){
            // AB  // BA
            // AC  // AC
            if(s[i+1][0]==x||s[i+1][1]==x){
                m[x]++;
                m[y]--;
                ans.push_back(x);
            } else if(s[i+1][0]==y||s[i+1][1]==y) {
                m[y]++;
                m[x]--;
                ans.push_back(y);
            }
        }  else {
            m[x]++; m[y]--;
            ans.push_back(x);
        }

        if(m[x]<0||m[y]<0) {
            cout << "No\n";
            return 0;
        }
    }
    cout << "Yes\n";
    for(char ch:ans) cout << ch << "\n";
    // cout << m['A'] << " " <<  m['B'] << " "  << m['C'] << endl;
    return 0;
} 

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

using namespace std;


//repetition
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define euc_dis(x, y) sqrt(x*x + y*y)

const char sp = ' ';
const int MOD = 1000000007;

using ll = long long;


ll mod(ll a, ll b){return (a%b+b)%b;}
ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b){return a*b/gcd(a,b);}
void Yes(){cout << "Yes" << endl;}
void No(){cout << "No" << endl;}
void Judge(bool b){b?Yes():No();}
void YES(){cout << "YES" << endl;}
void NO(){cout << "NO" << endl;}
void JUDGE(bool b){b?YES():NO();}
ll powMod(ll b, ll e, ll m){ll r=1;while(e>0){if(e&1)r=(r%m)*(b%m)%m;b=(b%m)*(b%m)%m;e>>=1;}return r;}
double distance(ll x1, ll y1, ll x2, ll y2){return sqrt((x1-x2)*(x1-x2) + (y1-y2)*(y1-y2));}

template<typename T>
void ppp(T n){cout << n << endl;}

int main(){

    cin.tie(0);
    ios::sync_with_stdio(false);

    int h, w, k;
    cin >> h >> w >> k;

    int dp[h+1][w];
    fill_n(*dp, w*(h+1), 0);
    dp[0][0] = 1;

    for(int i = 0; i < h; ++i){
        for(int j = 0; j < w; ++j){
            for(int k = 0; k < 1 << (w-1); ++k){
                bool concheck = true;
                for(int l = 0; l < w-2; ++l){
                    if( ((k >> l) & 1) and ((k >> (l+1)) & 1) ) concheck = false;
                }

                if(concheck){
                    if( j >= 1 and ((k >> (j-1)) & 1) ){
                        dp[i+1][j-1] += dp[i][j];
                        dp[i+1][j-1] %= MOD;
                    }
                    else if( j <= w-2 and ((k >> j) & 1 )){
                        dp[i+1][j+1] += dp[i][j];
                        dp[i+1][j+1] %= MOD;
                    }
                    else{
                        dp[i+1][j] += dp[i][j];
                        dp[i+1][j] %= MOD;
                    }

                }
            }
        }
    }

    ppp(dp[h][k-1]);

    return 0;
}


Measured memory_bytes: 256
# ABC088
from collections import deque
import copy
# 入力
H, W = map(int, input().split())
field = [list(input()) for _ in range(H)]
field_original = copy.deepcopy(field)

# 4方向の移動
dx = [1, 0, -1, 0]
dy = [0, 1, 0, -1]

# BFSのためのデータ構造
dist = [[-1] * W for _ in range(H)]
que_x = deque()
que_y = deque()

# 探索中に各マスはどこからきたのかを表す配列
prev_x = [[-1] * W for _ in range(H)]
prev_y = [[-1] * W for _ in range(H)]

# 初期条件(スタート地点を0にする)
dist[0][0] = 0
que_x.append(0)
que_y.append(0)

# BFS開始
while que_x and que_y:
    x = que_x[0]
    y = que_y[0]
    que_x.popleft()
    que_y.popleft()
    for direct in range(4):
        nx = x + dx[direct]
        ny = y + dy[direct]
        if nx < 0 or H <= nx or ny < 0 or W <= ny:      # 場外はスルー
            continue
        if field[nx][ny] == "#":     # 壁はスルー
            continue
        if dist[nx][ny] == -1:          # まだ見ていない時
            que_x.append(nx)
            que_y.append(ny)
            dist[nx][ny] = dist[x][y] + 1   # 距離の更新
            prev_x[nx][ny] = x      # どの頂点から伝播してきたかを 縦 方向の座標をメモ
            prev_y[nx][ny] = y      # どの頂点から伝播してきたかを 横 方向の座標をメモ

x = H - 1
y = W - 1

if dist[x][y] == -1:        # ゴール出来てない時は -1 で終了
    print(-1)
    exit()
##print(dist[H-1][W-1])
while x != -1 and y != -1:
    field[x][y] = "o"

    # 前の頂点へいく
    px = prev_x[x][y]
    py = prev_y[x][y]
    x, y = px, py
##print(field)
ans = 0
for i in range(H):
    for k in range(W):
        if field[i][k] == field_original[i][k] == ".":
            ans += 1
print(ans)

Measured memory_bytes: 3564
n, mw = map(int, input().split())
v, w = [], []
for _ in range(n):
    vi, wi = map(int, input().split())
    v.append(vi)
    w.append(wi)

dp = [[0]*(mw+1) for _ in range(n+1)]

for i in range(n-1, -1, -1):
    for j in range(mw+1):
        if j < w[i]:
            dp[i][j] = dp[i+1][j]
        else:
            dp[i][j] = max(
                dp[i+1][j],
                dp[i+1][j-w[i]] + v[i]
            )

print(dp[0][mw])


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

int main()
{
  int n,i,c=0;
  cin>>n;
  vector<string> a(n);
  for(i=0;i<n;i++)
    cin>>a[i];
  sort(a.begin(),a.end());
  for(i=0;i<n-1;i++)
  {
    if(a[i]!=a[i+1])
      c++;
  }
  c++;
  cout<<c;
  return 0;
}


Measured memory_bytes: 9568
#include<cstdio>
#include <iostream>
#include<sstream>
#include<fstream>
#include<iomanip>
#include<algorithm>
#include<cmath>
#include<complex>
#include <string>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#include<numeric>
#include<limits>
#include<climits>
#include<cfloat>
#include<functional>
#include<iterator>
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
using namespace std;

int main() {
	int n, m, ans = 0;
	string s[110],t[110];
	map<string, int> mp;
	cin >> n;
	rep(i, n) {
		cin >> s[i];
		mp[s[i]]++;
	}
	cin >> m;
	rep(i, m) {
		cin >> t[i];
		mp[t[i]]--;
	}

	for (auto itr : mp) {
		ans = max(ans, itr.second);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#define M 1046527
#define L 14
char H[M][L];

//?°?????¬??????¬??¢?????°???
int getChar(char c) {
  switch (c) {
    case 'A': return 1;
    case 'C': return 2;
    case 'G': return 3;
    case 'T': return 4;
    default: return 0;
  }
}
//?°?????¬??????¬??¢?????°?????¶??????key
long long getKey(char str[]) {
  long long ret = 0, p = 1;
  int i;
  for(i = 0; str[i] != '\0'; i++) {
    ret += p * getChar(str[i]);
    p *=6;
  }
  return ret;
}
int h1(int key){return key%M;}
int h2(int key){return 1+(key%(M-1));}
int find(char str[]) {
  long long key, h, i;
  key = getKey(str);
  for(i = 0; ; i++) {
    h = (h1(key) + i * h2(key)) % M;
    if(strcmp(H[h], str) == 0) {
      return 1;
    } else if(strlen(H[h]) == 0) {
      return 0;
    }
  }
  return 0;
}
int Insert(char str[]) {
  long long key, h, i;
  key = getKey(str);
  for(i = 0; ; i++) {
    h = (h1(key) + i * h2(key)) % M;
    if(strcmp(H[h], str) == 0) {
      return 1;
    } else if(strlen(H[h]) == 0) {
      strcpy(H[h], str);
      return 0;
    }
  }
  return 0;
}
int main()
{
    int i,n;
    char str[L],cmd[9];
    for(i=0;i<M;i++){ 
         H[i][0]='\0';
    }
    scanf("%d",&n);
    for(i=0;i<n;i++)
    {
        scanf("%s %s",cmd,str);
        if(cmd[0]=='i'){
            Insert(str);
        }
        else
        {
            if(find(str)){
                printf("yes\n");
             }
            else{
                printf("no\n");
             }
        }
    }
    return 0;
}

Measured memory_bytes: 16956
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#define rep(i, n) for(int i = 0; (i) < (n); (i)++)

using namespace std;

int main() {
    int a,b,c;
    cin >> a >> b >> c;
    int ans = 0;
    for(int i=a;i<=b;i++) if(c % i == 0) ans++;
    cout << ans << endl;
}


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

#define ll long long
#define fw(p) for(int w=0;w<(p);w++)
#define fx(p) for(int x=0;x<(p);x++)
#define fy(p) for(int y=0;y<(p);y++)
#define fz(p) for(int z=0;z<(p);z++)
#define fyg(p,g) for(int y=(g);y<(p);y++)
#define fzg(p,g) for(int z=(g);z<(p);z++)
#define ce(d) cout<<d<<endl;
#define vecp(p) int aa;cin>>aa;(p).push_back(aa);
#define vecpl(p) long long aa;cin>>aa;(p).push_back(aa);
#define vecps(p) string aa;cin>>aa;(p).push_back(aa);
#define vecp2(p) cin>>aa;(p).push_back(aa);
#define vecpl2(p) long long a	b;cin>>ab;(p).push_back(ab);
#define vecps2(p) string ab;cin>>ab;(p).push_back(ab);
#define sorts(c) sort((c).begin(),(c).end());
#define reverses(c) reverse((c).begin(),(c).end());
#define vec(b) vector<int> (b);
#define vecl(b) vector<long long> (b);
#define vecs(b) vector<string> (b);
#define pb(b,a) (b).push_back((a));
#define doublece(a,b) cout<<(a)<<' '<<(b)<<endl;
#define pairs(s) vector<pair<int,int>> (s);
#define pairsp(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define MOD 1000000007
#define cey ce("Yes")
#define cen ce("No")
#define ceY ce("YES")
#define ceN ce("NO")

int main()
{
double A, B, H, M;
	cin >> A >> B >> H >> M;

	double theta = abs(H * 30 + (M*30/60) - M * 6);

	if (theta > 180) {
		theta = 360 - theta;
	}

	double ans = A * A + B * B - A * B * 2 * cos(theta * 3.14159265358979 / 180);
	cout << fixed << setprecision(15) << sqrt(ans) << endl;


    return 0;
}



Measured memory_bytes: 4216
import java.util.*;

class Main
{
    public static void main(String[] args)
    {
        Scanner sc = new Scanner(System.in);
        
        String s = sc.next();
        
        int sLength = s.length();
        
        for (int i = 0; i < sLength; i++) {
            System.out.print("x");
        }
        
    }
}
        

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

int main() {
  int cnt ;
  cin >> cnt;
  
  int g,w,p,y;
  g=0;w=0;p=0;y=0;
  
  string c ;
  
  for (int i =0; i< cnt ; i++ ){
  	cin >> c;
    if (c=="G"){
      g=1;
    }
    else if (c=="W"){
      w=1;
    }
    else if (c=="P"){
      p=1;
    }
    else if (c=="Y"){
      y=1;
    }
  }
  
  int ccnt = g+w+p+y;
  if (ccnt==3) {
  	cout << "Three";
  }
  else if (ccnt == 4){
    cout << "Four";
  }
  
}


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

#include "bits/stdc++.h"
#define int long long
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(obj) begin(obj), end(obj)
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define LOWER_BOUND(A, key) distance(A.begin(), lower_bound(ALL(A), key))
#define UPPER_BOUND(A, key) distance(A.begin(), upper_bound(ALL(A), key))
#define Endl endl

using namespace std;
using ll      = long long;
const int MOD = (int)(1e9 + 7);
const int INF = (int)(1e13 + 7);

int ceil_(int a, int b) { return (a + (b - 1)) / b; }
int positive_surplus(int &a) { return (a + MOD) % MOD; }
int bpm(int x, unsigned int y) {
  if (x == 0) return 0;
  if (y == 0) return 1;
  int ans   = 1;
  int digit = (int)((log((double)y) / log((double)2) / 1 + 1));
  x %= MOD;
  for (int i = 0; i < digit; i++) {
    if (((y >> i) & 1u) == 1) ans = ans * x % MOD;
    x = x * x % MOD;
  }
  return ans;
}
template <class T>
void cumulative_sum(T &container) {
  for (int i = 0; i < container.size() - 1; i++) container[i + 1] += container[i];
}

class CManyMedians {
public:
  static void solve(std::istream &cin, std::ostream &cout) {
    int N;
    cin >> N;
    vector<int> X(N);
    vector<int> temp_X(N);
    rep(i, N) {
      cin >> X[i];
      temp_X[i] = X[i];
    }
    sort(ALL(temp_X));
    rep(i, N) {
      if (X[i] <= temp_X[N / 2 - 1]) {
        cout << temp_X[N / 2] << endl;
      } else {
        cout << temp_X[N / 2 - 1] << endl;
      }
    }
  }
};


signed main() {
  CManyMedians solver;
  std::istream& in(std::cin);
  std::ostream& out(std::cout);
  solver.solve(in, out);
  return 0;
}


Measured memory_bytes: 5376
#include<cstdio>

int main(){
    int n,m;
    scanf("%d %d",&n,&m);
    int a[n][m];
    for(int i = 0; i < n; i++){
        for(int j = 0; j < m; j++){
            scanf("%d",&a[i][j]);
        }
    }
    int b[m];
    for(int i = 0; i < m; i++){
        scanf("%d",&b[i]);
    }
    int s;
    for(int i = 0; i < n; i++){
        s = 0;
        for(int j = 0; j < m; j++){
            s += a[i][j] * b[j];
        }
        printf("%d\n",s);
    }
    return 0;
}


Measured memory_bytes: 2796
s = input()
y, m, d = s.split('/')
if int(y) <= 2018:
    print("Heisei")
elif int(y) >= 2020:
    print("TBD")
else:
    if int(m) <= 4:
        print("Heisei")
    elif int(m) >= 5:
        print("TBD")

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
using P = pair<ll, ll>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep1(i, n) for(ll i=1;i<=(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
#define ALL(obj) (obj).begin(), (obj).end()
#define MOD 1000000007
#define INF 1000000000

void solve_abc144_a() {
	ll A, B;
	ll ans = 0;

	cin >> A >> B;

	if (A >= 10 || B >= 10) {
		ans = -1;
	}
	else {
		ans = A * B;
	}

	cout << ans << "\n";
}


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

	solve_abc144_a();

	return 0;
}


Measured memory_bytes: 256
/*######################################################
#########~~~~~####~~~~###~~##~~##~~##~~##~~##~~#########
#########~~##~~##~~##~~##~~~#~~##~~~#~~##~~##~~#########
#~~~~~~##~~~~~###~~~~~~##~~#~~~##~~#~~~##~~##~~##~~~~~~#
#########~~######~~##~~##~~##~~##~~##~~##~~##~~#########
#########~~######~~##~~##~~##~~##~~##~~###~~~~##########
######################################################*/
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
#define ll long long
#define str string
#define rtn return
#define endl '\n'
#define F first
#define S second
#define pb push_back
#define db long double
#define MOD 1000000007
#define INF 1e18
#define EPS 1e-15
#define pll pair <ll, ll>
#define vi vector<ll>
#define vpll vector<pll>
#define value_at find_by_order
#define index_of order_of_key
#define fill(a,v) memset(a,v,sizeof(a))
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i,n) for(ll i=0;i<n;++i)
#define per(i,n) for(ll i=n-1;i>=0;--i)
#define loop1(i, n) for (int i=1;i<=n;++i)
#define loop(i, begin, end) for (__typeof(end) i = (begin)-((begin)>(end));i!=(end)-((begin)>(end));i+=1-2*((begin)>(end)))
#define FAST_IO std::ios_base::sync_with_stdio(false);std::cin.tie(NULL);std::cout.tie(NULL)

#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cerr << name << " = " << arg1 << '\n';
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << " = " << arg1 << " |";
  __f(comma+1, args...);
}
#else
#define trace(...)
#endif

template<class T> void remin(T &a, T b) {a = min(a, b);}
template<class T> void remax(T &a, T b) {a = max(a, b);}
template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

#define N 100005

int n, w;
ll wt[N], val[N];
ll dp[105][N];

ll solve() {
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= w; j++) {
      if (j >= wt[i - 1]) {
        remax(dp[i][j], val[i - 1] + dp[i - 1][j - wt[i - 1]]);
      }
      remax(dp[i][j], dp[i - 1][j]);
    }
  }
  cout << dp[n][w] << endl;
}

int main() {
  FAST_IO;
  cin >> n >> w;
  rep(i, n) cin >> wt[i] >> val[i];
  solve();
  rtn 0;
}


Measured memory_bytes: 79360
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<cstdlib>
#include<iostream>
#include<algorithm>
#define fi first
#define se second
#define L(i,u) for (int i=head[u]; i!=0; i=nxt[i])
#define rep(i,a,b) for (register int i=a; i<=b; i++)
#define per(i,a,b) for (register int i=a; i>=b; i--)
typedef long long ll;
using namespace std;
typedef pair<int,int> Pii;
typedef vector<int> Vi;
inline void read(int &x) {
	x=0; char c=getchar(); int f=1;
	while (!isdigit(c)) {if (c=='-') f=-1; c=getchar();}
	while (isdigit(c)) {x=x*10+c-'0'; c=getchar();} x*=f;
}
const int N = 203000;
int n,a[N];ll res;
int main() {
	read(n);rep(i,1,n)read(a[i]),a[i]-=i;
	sort(a+1,a+n+1);
	rep(i,1,n/2)res+=a[n-i+1]-a[i];
	cout<<res;
	return 0;
}


Measured memory_bytes: 1024
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
 
public class Main {
 
    public static void main(String[] args) throws IOException {
 
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
 
        int count = Integer.parseInt(br.readLine());
 
        double[] listX = new double[count];
        double[] listY = new double[count];
 
        String[] str01 = br.readLine().split(" ");
        for (int i = 0; i < count; i++) {
            listX[i] = Double.parseDouble(str01[i]);
        }
 
        String[] str02 = br.readLine().split(" ");
        for (int i = 0; i < count; i++) {
            listY[i] = Double.parseDouble(str02[i]);
        }
        for (int i = 1; i < 5; i++) {
            Method.math(listX, listY, i);
        }
    }
}
 
class Method {
 
    static void math(double[] listX, double[] listY, int code) {
        double sum = 0;
 
        if (code == 1) {
            for (int i = 0; i < listX.length; i++) {
                sum += Math.abs(listX[i] - listY[i]);
            }
 
        } else if (code == 2) {
            for (int i = 0; i < listX.length; i++) {
                sum += Math.pow((listX[i] - listY[i]), 2);
            }
            sum = Math.sqrt(sum);
 
        } else if (code == 3) {
            for (int i = 0; i < listX.length; i++) {
                sum += Math.pow(Math.abs(listX[i] - listY[i]), 3);
            }
            sum = Math.cbrt(sum);
 
        } else {
            for (int i = 0; i < listX.length; i++) {
                if (sum < Math.abs(listX[i] - listY[i])) {
                    sum = Math.abs(listX[i] - listY[i]);
                }
            }
        }
        System.out.println(sum);
    }
}

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

int main(){
     int n,m;
     cin >>n>>m;
     vector<vector<int>> v(m,vector<int>(2));

     for(int i=0;i<m;i++){
       cin >> v[i][0] >> v[i][1];
     }

     vector<int> order(n-1);
     for(int i=0;i<n-1;i++){
       order[i]= i+2;
     }

     int cnt=0,ans=0,c=0;
     bool b =false;

     do {
       cnt =0;
       for(int i=0;i<n-2;i++){
         b =false;
         for(int j=0;j<m;j++){
           if((order[i]==v[j][0]&&order[i+1]==v[j][1])||(order[i]==v[j][1]&&order[i+1]==v[j][0])) b = true;
         }
         if(b) cnt++;
       }

       c = 0;
       if(cnt==n-2){
         for(int k=0;k<m;k++){
        if((v[k][0]==1&&v[k][1]==order[0])||(v[k][1]==1&&v[k][0]==order[0])) c++;
       }
     }
       if(!(c==0)) ans++;



    } while(next_permutation(order.begin(),order.end()));
     cout << ans << endl;

}

Measured memory_bytes: 256
n=int(input())
s=input()
t=input()

n_s=len(s)
n_t=len(t)
l=[]
for i in range(n_s):
    for j in range(n_t):
        l.append(s[:i]+t[j:])
ans=s+t
for c in l:
    if c[:n_s]==s and c[len(c)-n_t:]==t:
        if len(ans)>len(c):
            ans=c

print(len(ans))

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

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)

#define INF 100000000
#define MOD 1000000007
#define writeln(n) cout<<n<<endl
//setprecision(10);
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;
//vector<tuple<long long, long long, long long>>vec;

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

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

llong pownew(llong m, llong n) {
    if (n == 0) { return 1; }
    if (n % 2 == 0) { return pow(m*m, n/2); }
    return pow(m, n-1) * m;
}

bool isprime(int p) {
    if (p == 1) return false;
    for (int i = 2; i < p; i++) {
        if (p%i == 0) return false;
    }
    return true;
}

int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

const int inf=100000000;

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;
}

llong gcd(llong a, llong b) {
        return b != 0 ? gcd(b, a % b) : a;
    }


int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int Q; cin>>Q;
    int v=100000;
    vector<int> cnt(v,0);
    cnt[0]=0;
    for(int i=1; i<=v; i++)
    {
        if(isprime(i)&&isprime((i+1)/2)&&(i+1)%2==0) cnt[i]=cnt[i-1]+1;
        else cnt[i]=cnt[i-1];
    }

    for(int j=1; j<=Q; j++)
    {
        int l,r; cin>>l>>r;
        cout<<cnt[r]-cnt[l-1]<<endl;
    }
    return  0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define mod 1000000007
int dp[30001][1002][2];
int countdigitsum(int pos,int d,bool tight,string k,int D){
	int ub = tight? k[pos]-'0': 9;
	if(dp[pos][d][tight]!=-1){
		return dp[pos][d][tight];
	}
	if(pos==k.length()-1){
		int ans=0;
		for(int x=0;x<=ub;x++){
			if(x%D==d){
				ans++;
			}
		}
		return ans;
	}
	int ans=0;
	for(int x=0;x<=ub;x++){
		ans= (ans+countdigitsum(pos+1,(D+d-x%D)%D,tight&&(x==ub),k,D))%mod;
	}
	return dp[pos][d][tight]=ans;
}
signed main(){
	string k;
	cin>>k;
	int D;
	cin>>D;
	memset(dp,-1,sizeof dp);

	cout<<(mod+countdigitsum(0,0,1,k,D)-1)%mod<<endl;
	return 0;
}

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

using namespace std; 
const int MAX_N = 200005; 

long long IT[4 * MAX_N]; 
long long dp[MAX_N]; 
long long h[MAX_N], a[MAX_N]; 
int n; 

long long get(int index, int L, int R, int l, int r) {
	if (r < L || l > R) {
		return -1; 
	}

	if (l <= L && R <= r) {
		return IT[index]; 
	}

	int mid = (L + R) >> 1; 
	long long v1 = get(2 * index, L, mid, l, r);
	long long v2 = get(2 * index + 1, mid + 1, R, l, r);
	return max(v1, v2); 
}

void lazy(int index, int L, int R, int l, int r, long long val) {
	if (r < L || l > R) {
		return; 
	}

	if (l <= L && R <= r) {
		IT[index] = val; 
		return; 
	}

	int mid = (L + R) >> 1; 
	lazy(2 * index, L, mid, l, r, val);
	lazy(2 * index + 1, mid + 1, R, l, r, val);
	IT[index] = max(IT[2 * index], IT[2 * index + 1]); 
}

int main () {
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	scanf("%d", &n); 
	for (int i = 1; i <= n; i++) {
		scanf("%lld", &h[i]); 
	}

	for (int i = 1; i <= n; i++) {
		scanf("%lld", &a[i]); 
	}

	long long res = -1;

	for (int i = 1; i <= n; i++) {
		long long v = get(1, 1, n, 1, h[i] - 1); 
		if (v != -1) {
			dp[i] = v + a[i]; 
		}
		else {
			dp[i] = a[i];
		}
		res = max(res, dp[i]); 
		lazy(1, 1, n, h[i], h[i], dp[i]); 
	}

	cout << res; 
	return 0; 
}

Measured memory_bytes: 10496
import java.util.Scanner;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class Main {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String s = scanner.next();

        scanner.close();

        Pattern p = Pattern.compile("[A][A-Z]*[Z]");
        Matcher matcher = p.matcher(s);
        int max = 0;
        while (matcher.find()) {
            int length = matcher.group().length();
            if (max < length) {
                max = length;
            }
        }

        System.out.println(max);
    }
}


Measured memory_bytes: 25664
from sys import stdin


def main():
    input = lambda: stdin.readline()[:-1]
    N = int(input())
    P = list(map(int, input().split()))

    p1 = [0] + P
    p2 = [0, P[0]]
    for p in P[1:]:
        p2.append(min(p2[-1], p))
    ans = 0
    for i in p1[1:]:
        if p1[i] <= p2[i]:
            ans += 1
    print(ans)


main()


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

int main()
{
    int a[3];
    int sum = 0;
    rep(i, 3) cin >> a[i];
    rep(i,3)sum+=a[i];
    cout << (sum >= 22 ? "bust" : "win") << endl;

    return 0;
}

Measured memory_bytes: 256
#include <cstdio>

int n,a[100001];

int partition(int *A,int p, int r){
	int x = A[r];
	int i = p-1;
	for(int j = p; j < r; j++){
		if(A[j] <= x){
			i++;
			int tmp = A[i];
			A[i] = A[j];
			A[j] = tmp;
		}
	}
	int tmp2 = A[i+1];
	A[i+1] = A[r];
	A[r] = tmp2;
	return i+1;
}

int main(){
	scanf("%d",&n);
	for(int i = 0; i < n; i++){
		scanf("%d",&a[i]);
	}
	int x = partition(a,0,n-1);
	
	if(x == 0){
		printf("[%d]",a[0]);
	}
	else{
		printf("%d",a[0]);
	}
	for(int i = 1; i < n; i++){
		if(x == i){
			printf(" [%d]",a[i]);
		}
		else{
			printf(" %d",a[i]);
		}
	}
	printf("\n");
	return 0;
}




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

using namespace std;

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

int main() {
    int n, ans;
    string s;
    cin >> n;
    cin >> s;
    char temp = 0;
    ans = 0;
    rep(i, n){
        if(temp == 0){
            temp = s[i];
            ans++;
            continue;
        }
        if(temp == s[i]){
            continue;
        }else{
            temp = s[i];
            ans++;
        }
    }
    cout << ans << endl;
}


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

vector<P> to[100010];
vector<int> ans;

void dfs(int i, int p=-1){
  for(auto x : to[i]){
    if(x.first==p) continue;
    if(x.second%2==0){
      if(ans[i]==0) ans[x.first]=0;
      else ans[x.first]=1;
    }else{
      if(ans[i]==0) ans[x.first]=1;
      else ans[x.first]=0;
    }
    dfs(x.first,i);
  }
}

int main(){
  int n;
  cin>>n;
  rep(i,n-1){
    int u,v,w;
    cin>>u>>v>>w;
    u--; v--;
    to[u].push_back(make_pair(v,w));
    to[v].push_back(make_pair(u,w));
  }
  ans.resize(n);
  dfs(0);
  rep(i,n) cout<<ans[i]<<endl;
}

Measured memory_bytes: 12644
#include <stdio.h>
int main(void){
  char s[6];
  int i;
  int flag=0;
  scanf("%s",&s);
  if(s[2]==s[3]){
    if(s[4]==s[5])
      flag=1;
  }
  if(flag==0)
    puts("No");
  if(flag==1)
    puts("Yes");
  return 0;
}

Measured memory_bytes: 128