akhauriyash/Code-Regression huggingface dataset:
# include <bits/stdc++.h>
using namespace std;
typedef long long ll;

const int maxn(4e5 + 5);

int n;
ll l, x[maxn], ans, sx1[maxn], sx2[maxn], tmp, ret, rett;

int main() {
	register int i, ql, qr, nl, nr;
	scanf("%lld%d", &l, &n);
	for (i = 1; i <= n; ++i) scanf("%lld", &x[i]);
	sort(x + 1, x + n + 1), x[n + 1] = l;
	for (i = 1; i <= n; ++i) x[n + i + 1] = x[i] + l;
	for (i = 1; i <= n + n + 1; ++i) sx1[i] = sx1[i - 1] + x[i];
	for (i = n + n + 1; i; --i) sx2[i] = sx2[i + 1] + x[i];
	for (i = 0; i <= n; ++i) {
		nl = n - i, nr = i, ql = n + 1 - nl, qr = n + 1 + nr, ret = 0;
		if (nl >= nr) {
			tmp = nl - nr, ret = x[n + 1] - x[n + 1 - tmp];
			if (tmp == n) ans = max(ans, ret);
			else {
				//
				rett = ret;
				rett += (l * nr - sx2[ql] + sx2[n + 1 - tmp] - ret * nr) * 2;
				rett += (sx1[qr] - sx1[n + 1] - l * nr + ret * nr) * 2;
				rett -= x[qr] - l + ret, ans = max(ans, rett);
				//
				rett = ret;
				rett += (l * nr - sx2[ql] + sx2[n + 1 - tmp] - ret * nr) * 2;
				rett += (sx1[qr] - sx1[n + 1] - l * nr + ret * nr) * 2;
				rett -= l - x[ql] - ret, ans = max(ans, rett);
			}
		}
		else {
			tmp = nr - nl, ret = x[n + 1 + tmp] - x[n + 1];
			if (tmp == n) ans = max(ans, ret);
			else {
				//
				rett = ret;
				rett += (sx1[qr] - sx1[n + 1 + tmp] - l * nl - ret * nl) * 2;
				rett += (l * nl - sx2[ql] + sx2[n + 1] + ret * nl) * 2;
				rett -= x[qr] - l - ret, ans = max(ans, rett);
				//
				rett = ret;
				rett += (sx1[qr] - sx1[n + 1 + tmp] - l * nl - ret * nl) * 2;
				rett += (l * nl - sx2[ql] + sx2[n + 1] + ret * nl) * 2;
				rett -= l - x[ql] + ret, ans = max(ans, rett);
			}
		}
	}
	printf("%lld\n", ans);
    return 0;
}

Measured memory_bytes: 9600
s = input()
s_rev = s[::-1]
n = len(s)
##1つ目の条件
n1 = int((n-1)/2)
s1 = s[0:n1]
s1_rev = s1[::-1]
##2つめの条件
n2 = int((n+3)/2)
s2 = s[n2-1:n]
s2_rev = s2[::-1]
##判定
if s1 == s1_rev and s2 == s2_rev and s == s_rev:
    print('Yes') 
else:
    print('No')

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define rep(i,c) for(int i=0;i<(int)c;i++)
const int inf = 1001001001; //10^9


int main() {
  int n,i;
  cin >> n;
  vector<int> x(n);
  rep(i,n) cin >> x[i];
  int L = x[0], R = x[0];
  int ans = inf;

  rep(i,n){
    L = min(L, x[i]);
    R = max(R, x[i]);
  }

  for(i = L;i <= R; i++){
    int cost = 0;
    rep(j,n) cost +=(x[j]-i)*(x[j]-i);
    ans = min(ans, cost);
  }
  cout << ans << endl;
  return 0;

}


Measured memory_bytes: 256
import itertools
from math import sqrt
N=int(input())
L=[]
for i in range(N):
    x,y=map(int, input().split())
    L.append((x,y))

def distance(x1,y1,x2,y2):
    return sqrt( (x2-x1)**2 + (y2-y1)**2 )

ans=0
count=0
for l in itertools.permutations(L):
    
    count+=1
    for i,t in enumerate(l):
        if i==0:
            px,py=t
            continue
        x,y=t
        ans+=distance(x,y,px,py)
        px=x
        py=y
print(ans/count)

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <cmath>

using namespace std;

int main()
{
	int N, D;
	cin >> N >> D;
	
	// 2次元配列
	vector<vector<int>> X(N, vector<int>(D));
	for (int i = 0; i < N; i++)
	{
		for (int j = 0; j < D; j++)
		{
			cin >> X[i][j];
		}
	}
	
	int answer = 0;
	
	// 基準座標
	for (int i = 0; i < N; i++)
	{
		// 比較対象の座標
		for (int j = i + 1; j < N; j++)
		{
			// 距離の計算
			float tmp = 0.0f;
			for (int k = 0; k < D; k++)
			{
				tmp += pow(X[i][k] - X[j][k], 2);
			}
			float distance = sqrt(tmp);
			
			// 整数かどうかのチェック
			if (distance == (int)distance)
			{
				answer++;
			}
		}
	}
	
	cout << answer << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <stack>
#include <vector>

using namespace std;

using Pair = pair<int, int>;
using lint = long long;

// const int mod = 1e9 + 7;
// const int mod = 998244353;

template <typename T> vector<T> make_v(size_t a) { return vector<T>(a); }

template <typename T, typename... Ts> auto make_v(size_t a, Ts... ts) {
  return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
inline void Yes(bool condition) {
  if (condition) {
    std::cout << "Yes" << std::endl;
  } else {
    std::cout << "No" << std::endl;
  }
}
int main(){
  int x;
  cin >> x;
  Yes(x >= 30);
}


Measured memory_bytes: 3620
inpl = lambda: list(map(int,input().split()))
from math import sqrt, ceil, gcd
def divisors(n, sort=True, reverse=False):
    sqn = int(ceil(sqrt(n)))
    div_list = []
    if sqn*sqn == n:
        div_list.append(sqn)
    for i in range(1,sqn):
        if n % i == 0:
            div_list.append(i)
            div_list.append(n//i)
    if sort:
        div_list.sort(reverse=reverse)
    return div_list

def inv_mod(a, p=10**9+7):
    p = abs(p)
    a %= p
    stack = []
    p0 = p
    while a > 1:
        d, a, p = p//a, p%a, a
        stack.append(d)
    x, y = 1, 0
    while stack:
        d = stack.pop()
        x, y = y-d*x, x
    return x % p0

N = int(input())
M = 2*N
divlist = divisors(M)
kmin = M-1
for p in divlist:
    q = M // p
    if p == 1 or q == 1 or gcd(p,q) > 1:
        continue
    else:
        m = q - inv_mod(p, q)
        k = p*m
        if k < kmin:
            kmin = k
print(kmin)


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

int main(){
  int a,b,c,x;
  cin>>a>>b>>c>>x;
  int res=0;
  for(int i=0;i<=a;i++){
    for(int j=0;j<=b;j++){
      for(int k=0;k<=c;k++){
        int total = 500*i+100*j+50*k;
        if(total==x) ++res;
      }
    }
  }
  cout<<res<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, k;
  cin >> n >> k;
  vector<double> a(n);
  for (int i = 0; i < n; i++)
    cin >> a[i];
  for (int i = 0; i < n; i++)
     a[i] = (double)((a[i] * (a[i]+1))/2.0)/a[i];

  double best = 0.0; 
  for (int i = 0; i < k; i++)
    best += a[i];
  double cur = best;
  for (int i = k; i < n; i++){
    cur = cur + a[i] - a[i-k];
    best = max(best, cur);
  }
  
  cout << fixed << setprecision(12) << best << '\n';
  return 0;
}


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

int main(){
	int sum;
	string st;

	while(1){
		cin>>st;
		if(st=="0") break;
		sum=0;
		for(int i=0;i<st.size();i++){
			sum+=st[i]-'0';
		}
		cout<<sum<<endl;
	}
	return 0;
}

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

using namespace std;

typedef long long ll;

int main(void) {

  int n, x;
  cin >> n >> x;
  vector<int> ds;
  for (int i = 0; i < n; i++) {
    int d; cin >> d;
    ds.push_back(d);
  }

  int cnt = 0;
  int cur = 0;
  for (int i = 0; i < n + 1; i++)
  {
    if (cur <= x) {
      cnt++;
    } else 
      break;

    if (i < n) {
      cur += ds[i];
    }
  }
  cout << cnt << endl;

  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
using namespace std;
#define MOD 1000000007
#define INF (1<<29)
#define EPS (1e-10)
typedef long long Int;
typedef pair<Int, Int> P;

#define max(x, y) ((x)>(y)?(x):(y))
#define min(x, y) ((x)<(y)?(x):(y))


Int pos[216000];
Int cnt[216000];
set<Int> nums;
Int res, n, a;
Int mx;

void ok(){
  cout << "Possible" << endl;
  exit(0);
}

void ng(){
  cout <<  "Impossible" << endl;
  exit(0);
}


int main(){
  cin >> n;
  for(int i = 0;i < n;i++){
    cin >> a;
    cnt[a]++;
    mx = max(mx, a);
  }
  int center = 0;
  while (cnt[center] == 0)center ++ ;

  if(center == 1){
    if(cnt[center] == 2 && n == 2)ok();
    if(cnt[2] == n-1)ok();
    ng();
  }
  
  if(cnt[center] == 1){
    for(int i = center+1;i <= center*2;i++){
      if(cnt[i]==0)ng();
    }
    if(mx <= center * 2)ok();
    else ng();
  }

  
  if(cnt[center] == 2){
    for(int i = center+1;i <= center*2-1;i++){
      if(cnt[i]==0)ng();
    }
    if(mx <= center * 2-1)ok();
    else ng();
  }
  
  ng();
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<map>
#include<iomanip>
#include<sstream>
#include<vector>
#include<stack>
#include<math.h>

using namespace std;


int main()
{
	string str,str2[200000],strmemo="";
	long long int n, m, a, b, c, now[200][200] = {},x[200006],y[200006],X=0,Y=0;
	const long long int mod = 1000000007;
	cin >> n >>str;
	for (int i = 0; i < n; i++) {
		if (str[i] == 'R') {
			X++;
		}
		else {
			X--;
		}
	}
	if (X > 0) {
		cout << "Yes" << endl;
	}else{

		cout << "No" << endl;
	}
	
}


Measured memory_bytes: 1792
from bisect import bisect_right
N = int(input())
L = list(map(int, input().split()))
L.sort()
ans = 0
for i in range(N-1,-1,-1):
    for j in range(i-1,-1,-1):#jはi未満
        m = L[i]-L[j]#上記c-bを計算
        k = bisect_right(L, m)#二分探索
        #aに相当するkは、上記の通り、mよりも大きい(つまり、右側)
        #同じものがあったら右側
        n = max(0, j-k)#j-kの区間の数は大丈夫
        ans+=n
print(ans)


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

int main() {
    int n, sum=0;
    cin>>n;

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

    for(int i=0; i<n; i++){
        for(int j=0; j<n; j++){
            if(i!=j) sum+=d.at(i)*d.at(j);
        }
    }


    cout<<sum/2<<endl;
}


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

int main() {
  string s = "MARCH";
  int c[5] = {0};
  int n;
  cin >> n;

  for (int i = 0; i < n; i++) {
    string t;
    cin >> t;
    for (int j = 0; j < 5; j++) {
      if (t[0] == s[j]) {
        c[j]++;
      }
    }
  }

  ll ans = 0;
  for (int i = 0; i < 5; i++) {
    for (int j = i + 1; j < 5; j++) {
      for (int k = j + 1; k < 5; k++) {
        ans += ll(c[i]) * ll(c[j]) * ll(c[k]);
      }
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3228
#include <iostream>
#include <string>
#include <cstdlib>
using namespace std;
#define N 50

int nkun[N][N];

int make_nkun(int h, int w) {
    int r_nkun[N][N];
    int w_sum = 0, h_sum = 0;

    for(int i=0; i<h; i++) {
        for(int j=0; j<w; j++) {
            r_nkun[i][j] = 0;
        }
    }

    for(int i=0; i<h; i++) {
        w_sum += nkun[i][0];
        r_nkun[i][0] = w_sum;
    }

    for(int i=0; i<w; i++) {
        h_sum += nkun[0][i];
        r_nkun[0][i] = h_sum;
    }

    for(int i=1; i<h; i++) {
        for(int j=1; j<w; j++) {
            if( (r_nkun[i-1][j]+nkun[i][j]) < (r_nkun[i][j-1]+nkun[i][j]) ) {
                r_nkun[i][j] = (r_nkun[i-1][j]+nkun[i][j]);
            }
            else {
                r_nkun[i][j] = (r_nkun[i][j-1]+nkun[i][j]);
            }
        }
    }

    return r_nkun[h-1][w-1];
}

int main() {
    int h, w;
    string data;
    cin >> h >> w;
    for(int i=0; i<h; i++) {
        cin >> data;
        for(int j=0; j<w; j++) {
           nkun[i][j] = data[j] - 48;
        }
    }
    /*for(int i=0; i<h; i++) {
        for(int j=0; j<w; j++) {
            cout << nkun[i][j] << " ";
        }
        cout << endl;
    }*/
    cout << make_nkun(h, w) << endl;

    return 0;
}


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

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

  int maxi_idx = -1, maxi = -1;
  for (int i=0; i<N; i++) {
    cout << "? 1 " << (i+1) << endl;
    int d;
    cin >> d; 
    if (d > maxi) {
      maxi_idx = i;
      maxi = d;
    }
  }

  vector<int> ans(N);
  for (int i=0; i<N; i++) {
    cout << "? " << (maxi_idx+1) << " " << (i+1) << endl;
    int d;
    cin >> d;
    ans[d] = i+1;
  }

  cout << "! ";
  for (int i=0; i<N; i++) {
    if (i > 0) cout << " ";
    cout << ans[i];
  }
  cout << endl;
}

Measured memory_bytes: 3596
#include <stdio.h>
  
int main(){
  //入力
  int r;
  //1<=r<=100なる整数からok
  scanf("%d", &r);

  //計算・出力
  printf("%d", 3*r*r);
  return 0;
  //面積SはS=12*(0.5*r*r*sinθ)=3*a^2となる。
}

Measured memory_bytes: 128
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#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 ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s, t;
    cin >> s >> t;
    FORR(i, s.size() - t.size(), 0){
        string sub = s.substr(i, t.size());
        REP(j, sub.size()){
            if(sub[j] == '?' || sub[j] == t[j]){
                if(j == sub.size() - 1) {
                    REP(k, s.size()){
                        if(i <= k && k < i + t.size()) s[k] = t[k - i];
                        if(s[k] == '?') s[k] = 'a';
                    }
                    cout << s << "\n";
                    return 0;
                }
            }else{
                break;
            }
        }
    }

    cout << "UNRESTORABLE" << "\n";
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int N = 1e5+5;
typedef long long ll; 

int s[105][2];

int main() {
    int n;
    cin >> n;
    for(int i = 0; i < n; ++ i) {
        cin >> s[i][0];
    }
    for(int i = 0; i < n; ++ i) {
        cin >> s[i][1];
    }
    for(int i = n-2; i >= 0; -- i) {
        s[i][0] += s[i+1][0];
        s[i][1] += s[i+1][1];
    }
    int res = 0;
    for(int i = 0; i < n; ++ i) {
        res = max(res, s[0][0]-s[i+1][0]+s[i][1]);
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};



struct combination {
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
};

int main() {
    int n; cin >> n;
    mint all = 1;
    rep(i, n) all *= 10;
    mint r = 1;
    rep(i, n) r *= 8;
    mint A_B = all - r;
    r = 1;
    rep(i, n) r *= 9;
    mint A = all - r;
    mint B = A;
    mint ans = A + B - A_B;
    cout << ans.x << endl;
}


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

int main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  ll a, b;
  cin >> a >> b;
  auto cal = [&](ll x) {
    vector<ll> keta(41, 0);
    keta[0] += (x+1)/2;
    keta[0] %= 2;
    int count = 1;
    ll ni = 2;
    while (true) {
      ll res = x / ni;
      if (res == 0) break;
      if (res % 2 == 1) {
        keta[count] += (x % ni) + 1;
        keta[count] %= 2;
      }
      ni *= 2;
      count++;
    }
    return keta;
  };
  vector<ll> tempa;
  if (a - 1 >= 0) tempa = cal(a-1);
  else tempa.resize(41,0);
  vector<ll> tempb = cal(b);
  vector<ll> keta(41);
  ll ans = 0;
  rep(i,41) {
    keta[i] = tempb[i] - tempa[i];
    keta[i] %= 2;
    if (keta[i] < 0) keta[i] += 2;
    ans += pow(2,i) * keta[i];
  }
  cout << ans << "\n";
  return 0;
}

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

using namespace std;

long long n, k, curr = 1, cnt, arr[200005], pre[200005];

int main() {
	cin >> n >> k;
	for (int i = 1; i <= n; i++) cin >> arr[i];
	while (k--) {
		curr = arr[curr];
		if (pre[curr]) k %= cnt - pre[curr];
		pre[curr] = cnt++;
	}
	cout << curr;
}


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

using namespace std;

int main(){
  string s, t;
  cin >> s >> t;

  sort(s.begin(),s.end());
  sort(t.rbegin(),t.rend());
  int cnt = 0;

  while(1){
    int i = (int)s[cnt];
    int j = (int)t[cnt];
    if(i == 0 & j == 0){
      cout << "No" << endl;
      break;
    }
    if(i < j){
      cout <<"Yes" << endl;
      break;
    }else if(i > j){
      cout  <<"No" << endl;
      break;
    }
    cnt++;
    


  }
}


Measured memory_bytes: 3556
// 計数ソート
// 各要素の個数を数えていく。その後累積和を求め正しい位置に入るindexを求めていく
#include<bits/stdc++.h>
using namespace std;

#define MAX 10010
#define MMAX 2000010

void CountingSort(int A[], int dst[], int maxel);

int A[MMAX], B[MMAX], C[MAX];
int n;

int main(){
    cin >> n;
    int ma = INT_MIN;
    for(int i = 0; i < n; i++){
        cin >> A[i];
        ma = max(ma, A[i]);
    }

    CountingSort(A,B,ma);

    for(int i = 1; i <= n; i++){
        cout << B[i];
        if(i != n) cout << " ";
        else cout << endl;
    }
}

void CountingSort(int A[], int dst[], int maxel){
    // 計数ソート

    // 0にする
    for(int i = 0; i <= maxel; i++){
        C[i] = 0;
    }

    // カウント
    for(int i = 0; i < n; i++){
        C[A[i]]++;
    }

    // 累積和
    for(int i = 1; i <= maxel; i++){
        C[i] += C[i-1];
    }

    // dstに入れてく
    for(int i = n-1; i >= 0; i--){
        dst[C[A[i]]] = A[i];
        C[A[i]]--;
    }
}


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

    int ans;
    for(int i=1; ; i++){
        if((i-1)*111 < n && i*111 >= n){
            ans = i*111;
            break;
        }
    } 
    cout << ans;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<math.h>
#include<vector>
#include<map>
#include<set>
#include<iomanip>

using namespace std;
using ll = long long;

const int MOD = 1e9 + 7;
const int INF = numeric_limits<int>::max();
const ll LLINF = numeric_limits<ll>::max();
const double PI = acos(-1.0);

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

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

    if (N & 1) {
        cout << 2 * N << endl;
    } else {
        cout << N << endl;
    }
    
    return 0;
}


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

int main(){
  int n;
  cin >> n;
  vector<long long> vec(n);
  for(int i=0; i<n; i++) cin >> vec[i];
  
  long long sum = vec[0];
  bool ans = true;
  
  for(int i=0; i<n; i++){
  if(vec[i]==0){
    cout << 0 << endl;
      ans = false;
  }
  }
  if(ans){
  for(int i=1; i<n; i++){
    double sum1 = sum;
    sum *= vec[i];
    sum1 *= vec[i];
    if(sum>1000000000000000000||sum1>1000000000000000000){
      cout << -1 << endl;
      ans = false;
      break;
    }
  }
  }
  if(ans) cout << sum << endl;
}

Measured memory_bytes: 4004
#include<map>
#include<iostream>
#include<deque>
#include<algorithm>
#include<string>
#include<cctype>
#include<iomanip>
#include<vector>
#include<queue>
 
using namespace std;
#define REP(i,b,e) for(ll i=(ll)b;i<(ll)e;i++)
#define rep0(i,n) REP(i,0ll,n)
#define rep1(i,n) REP(i,1ll,n+1)
 
#define shosu setprecision(10)
 
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<ll,P> Q;
//ll longinf=1ll<<60;
int inf=1<<29;
int dh[4]={1,0,-1,0};
int dw[4]={0,1,0,-1};


ll longinf=(1ll<<31)-1;
struct segTree{
      ll n;
      vector<ll> dat;
      segTree(ll n_){
            n = 1;
            //かんたんのため要素数を2冪にする
            while(n < n_) n *= 2;
            //すべての値をinfにする
            for(ll i = 0; i < 2*n-1; i++) dat.push_back(longinf);
      }
      //k番目の値(0-indexed)をaに変更
      void update(ll k,ll a){
            //葉の節点
            k += n - 1;
            dat[k] = a;
            while(k > 0){
                  k = (k - 1) / 2;
                  dat[k] = min (dat[k * 2 + 1], dat[k * 2 + 2]);
            }
      }
      //[a,b)の最小値を求める
      //後ろの方の引数は、計算のかんたんのための引数
      //kは節点の番号,l,rはその節点が[l,r)に対応づいていることを表す
      //したがって外からはq(a, b, 0, 0, n)と呼ぶ
      ll q(ll a,ll b,ll k,ll l,ll r){
            //[a,b)と[l,r)が交差しなければ,inf
            if(r<=a||b<=l) return longinf;
            //[a,b)が[l,r)を完全に含んでいればこの節点の値
            if(a<=l&&r<=b) return dat[k];
            else{
                  //そうでなければ2つの子の最小値
                  ll vl = q(a,b,k*2+1,l,(l+r)/2);
                  ll vr = q(a,b,k*2+2,(l+r)/2,r);
                  return min(vl,vr);
            }
      }
      ll query(ll a,ll b){
            return q(a,b,0,0,n);
      }
};


int main(){
      int n,q;
      cin>>n>>q;
      segTree seg(n);
      /*rep0(i,n){
            ll a;
            cin>>a;
            seg.update(i,a);
      }*/
      rep0(i,q){
            ll f,g,h;
            cin>>f>>g>>h;
            if(f==1){
                  cout<<seg.query(g, h+1)<<endl;
            }
            else{
                  seg.update(g,h);
            }
      }
      return 0;
}


Measured memory_bytes: 4908
#include "bits/stdc++.h"
using namespace std;

int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);
	
	vector<int> arr;
	
	for (int i = 0; i < 3; i++) {
		int n; cin >> n;
		arr.push_back(n);
	}
	
	sort(arr.begin(), arr.end());
	
	cout << arr[0] + arr[1];
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <algorithm>

int main()
{
	int sx, sy, tx, ty;
	scanf("%d%d%d%d", &sx, &sy, &tx, &ty);
	for (int i = 1; i <= tx - sx; ++i) printf("R");
	for (int i = 1; i <= ty - sy; ++i) printf("U");
	for (int i = 1; i <= tx - sx; ++i) printf("L");
	for (int i = 1; i <= ty - sy; ++i) printf("D");
	printf("D");
	for (int i = 1; i <= tx - sx + 1; ++i) printf("R");
	for (int i = 1; i <= ty - sy + 1; ++i) printf("U");
	printf("L");
	printf("U");
	for (int i = 1; i <= tx - sx + 1; ++i) printf("L");
	for (int i = 1; i <= ty - sy + 1; ++i) printf("D");
	printf("R");
	return 0;
}

Measured memory_bytes: 128
//因为要用vector动态生成G，所以用了c++
#include <cstdio>
#include <vector>
using namespace std;
vector<int> G;
int cnt = 0;
int a[10000005];

//指定了间隔g的插入排序
void insertSort(int a[], int n, int g) {
    for (int i = g; i < n; i++) {
        int val = a[i];
        int j = i - g;
        while (j >= 0 && val < a[j]) {
            a[j + g] = a[j];
            j -= g;
            cnt++;
        }
        a[j + g] = val;
    }
}

void shellSort(int a[], int n) {
    //生成数列G
    for (int h = 1; ;) {
        if (h > n) {
            break;
        }
        G.push_back(h);
        h = h * 3 + 1;
    }
    printf("%d\n", G.size());
    for (int i = G.size() - 1; i >= 0; i--) {
        if (i < G.size() - 1) {
            printf(" ");
        }
        printf("%d", G[i]);
        insertSort(a, n, G[i]);
    }
    printf("\n");
}

int main() {
    int n = 0;
    scanf("%d", &n);
    for (int i = 0; i < n; i++) {
        scanf("%d", &a[i]);
    }
    shellSort(a, n);
    printf("%d\n", cnt);
    for (int i = 0; i < n; i++) {
        printf("%d\n", a[i]);
    }
    return 0;
}


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


int main(){
    string S;
    char c;
    int N;
    string ans = "Yes";

    std::cin >> S;
    N = S.size();

    for(int i = 0; i < N; i++){
        if((i + 1)%2 == 1){
            if(S[i] == 'L'){
                ans = "No";
            }
        }else{
            if(S[i] == 'R'){
                ans = "No";
            }
        }
    }
    std::cout << ans;



}

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

int f(int y){
    int ans = 1;
    for(int i = 0;i < y;i++){
        ans *= 10;
    }

    return ans;
}

/*xのy乗*/
long long g(int x,int y){
    long long ans = 1;
    for(int i = 0;i < y;i++){
        ans *= x;
    }

    return ans;

}

int main(){
    string s;
    long long k;
    cin >> s >> k;
    /**/
   int c[100];
   long long d[100];

   for(int i = 0;i < s.size();i++){
       c[i] = s.at(i) - '0';
   }
   /**/

   int ccount = 0;

   for(int i = 0;i < s.size();i++){
       if(c[i] == 1){
           ccount++;
           if(k == ccount){
               cout << c[i] << endl;
               break;
           }
           else if(c[i + 1] > 1){
               cout << c[i + 1] << endl;
               break;
           }
       }
     else{
       cout << c[i] << endl;
       break;
     }
   }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define endl '\n'
#define forn(i, n) for(int i=0;i<n;i++)
#define lli long long int
#define pii pair<int,int>
#define fi first
#define se second
#define pb push_back

using namespace std;

const int MAXN = 805;

int n,m,k;
queue<pii> q;
string mat[MAXN];
int dist[MAXN][MAXN];
int mov[5] = {1, -1, 0, 0};
int mov2[5] = {0, 0, 1, -1};

int bfs(int f) {
	while(!q.empty()) {
		int x = q.front().fi;
		int y = q.front().se;
		q.pop();
		if(!f && (!x || !y || x == n - 1 || y == m - 1)) return dist[x][y];
		if(f && dist[x][y] == k) continue;

		forn(i, 4) {
			int x1 = x + mov[i];
			int y1 = y + mov2[i];
			if(x1 >= 0 && y1 >= 0 && x1 < n && y1 < m && 
			dist[x][y] + 1 < dist[x1][y1]) {
				if(f && mat[x1][y1] == '#') continue;
				dist[x1][y1] = dist[x][y] + 1;
				q.push(pii(x1, y1));
			}
		}
	}
	return 1e8;
}

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cin>>n>>m>>k;
	forn(i, n) {
		cin>>mat[i];
		forn(j, m) {
			dist[i][j] = 1e8;
			if(mat[i][j] == 'S') {
				q.push(pii(i, j));
				dist[i][j] = 0;
				mat[i][j] = '.';
			}
		}
	}

	bfs(1);
	forn(i, n)
		forn(j, m) {
			if(dist[i][j] < 1e8) {
				dist[i][j] = 0;
				q.push(pii(i, j));
			}
		}

	int ans = bfs(0);
	ans = ans / k + (ans % k == 0 ? 0 : 1);
	cout<<1 + ans<<endl;
	return 0;
}


Measured memory_bytes: 8576
#include <iostream>
#include <set>
#include <queue>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <cstring>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
#include <stack>
#include <numeric>
#include <functional>

using namespace std;
#define ALL(x)              (x).begin(),(x).end()
#define REP(i, n)           for (int (i) = 0 ; (i) < (ll)(n) ; ++(i))
#define REPN(i, m, n)       for (int (i) = m ; (i) < (ll)(n) ; ++(i))
#define INF                 (int)2e9
#define MOD                 (1000 * 1000 * 1000 + 7)
#define Ceil(x, n)          (((((x))+((n)-1))/n))
#define CeilN(x, n)         (((((x))+((n)-1))/n)*n)
#define FloorN(x, n)        ((x)-(x)%(n))
#define IsOdd(x)            (((x)&0x01UL) == 0x01UL)
#define IsEven(x)           (!IsOdd((x)))
#define M_PI                3.14159265358979323846
typedef long long           ll;
typedef pair<ll, ll>        P;

/*-----------------------------------------------------------------------------
　処理
 -----------------------------------------------------------------------------*/
int main()
{
	int N;
	string S;
	cin >> N >> S;

	int leftCnt = 0;
	int rightCnt = 0;
	for (int i = 0; i < N; i++) {
		if (S[i] == '(') {
			rightCnt++;
		} else {
			if (0 < rightCnt) {
				rightCnt--;
			} else {
				leftCnt++;
			}
		}
	}

	string ans;
	REP(j, leftCnt) {
		ans += '(';
	}
	ans += S;
	REP(j, rightCnt) {
		ans += ')';
	}

	cout << ans << endl;
	return 0;
}


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

using namespace std;

int main() {
	int A, B, C;
	cin >> A >> B >> C;

	if (A<C&&C<B||B<C&&C<A) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,l,r) for(long long i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define REPS(i,n) FOR(i,1,n+1)
#define int long long
#define mp make_pair
#define pb push_back
#define eb emplace_back
const int MOD=1e9+7;
const int INF=1e18;
const int limit=100010;

signed main(){
    int N;cin>>N;
    vector<int>Keep;
    int ans=1;
    REP(i,N){
        int a;cin>>a;
        if(i==0)Keep.pb(a);
        else{
            auto v=lower_bound(Keep.rbegin(),Keep.rend(),a);
            if(v!=Keep.rbegin()){
                v--;
                *v=a;
            }
            else Keep.eb(a);
        }
    }
    cout<<Keep.size()<<endl;
}

Measured memory_bytes: 1400
#include <bits/stdc++.h>
#define ALL(v) v.begin(), v.end()
#define ALLG(v) v.begin(), v.end() ,greater<int>()
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
ll GCD(ll x, ll y) { return y ? GCD(y, x % y) : x; }
ll LCM(ll x, ll y) { return x * y / GCD(x, y); }
ll GetDigit(ll num) {
	ll digit = 0;
	while (num != 0) {
		num /= 10;
		digit++;
	}
	return digit;
}

using namespace std;
int main() {

	long long a, b, c, k;
	cin >> a >> b >> c >> k;

	cout << (k % 2 == 0 ? a - b : b - a) << endl;
}

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


using namespace std;
#define rep(i,n) for (int i = 0; i < (int)(n); ++i)
#define reps(i,n) for (int i = 1; i <= (int)(n); ++i)
#define repd(i,n) for (int i = (int)(n - 1); i >= 0; --i)
#define repds(i,n) for (int i = (int)(n); i > 0; --i)
#define loop(i,x,n) for (int i = (int)(x); i < (n); ++i)
#define loops(i,x,n) for (int i = (int)(x); i <= (n); ++i)
#define loopd(i,x,n) for (int i = (int)(x); i > (n); --i)
#define loopds(i,x,n) for (int i = (int)(x); i >= (n); --i)
#define itrep(i,s) for (auto i = begin(s); i != end(s); ++i)
#define itrepd(i,s) for (auto i = --end(s); i != begin(s); --i)
#define all(f,x,...) [&](decltype(x)& whole) { return (f)(begin(whole), end(whole), ##__VA_ARGS__); }(x)
#define rall(f,x,...) [&](decltype(x)& whole) { return (f)(rbegin(whole), rend(whole), ##__VA_ARGS__); }(x)
using ll = long long;
using ld = long double;
constexpr ll inf = static_cast<ll>(1e17);
constexpr int iinf = static_cast<int>(1e9);
constexpr double dinf = 1e10;
constexpr ld ldinf = 1e17;
ll mod = static_cast<ll>(1e9 + 7);
std::ostream& endn(std::ostream& os) { return os.put(os.widen('\n')); }
template<class T> constexpr int sz(const T& a) { return (int)a.size(); }
template<class T> constexpr T pow2(const T a) { return a * a; }
template<class T, class ... Args> constexpr T mins(T& a, Args... args) { return a = min<T>({ a, args... }); }
template<class T, class... Args> constexpr T maxs(T& a, Args... args) { return a = max<T>({ a,args... }); }

int x;
bool isPrime[100010];
void solve() {
    cin >> x;

    fill(isPrime, isPrime + 100010, true);
    isPrime[0] = isPrime[1] = 0;
    for (int i = 2; i * i < 100008; ++i) {
        if (isPrime[i]) {
            for (int j = 2; i * j <= 100008; ++j)
                isPrime[i * j] = false;
        }
    }

    int ans = 0;
    for (int i = x;; ++i)
        if (isPrime[i]) {
            ans = i;
            break;
        }

    cout << ans << endn;

}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
    cout << flush;
    return 0;
}


Measured memory_bytes: 384
#include <stdio.h>
#include <algorithm>
using namespace std;
int n, cub[100], k, m, num, maxi=0;

int main(){
    scanf("%d %d", &n, &m);
    for(int i=0; i<n; i++){
        scanf("%d", &k);
        for(int i=0; i<k; i++){
            scanf("%d", &num);
            cub[num]++;
            maxi = max(maxi, num);
        }
    }
    int cont = 0;
    for(int i=0; i<=maxi; i++){
        if(cub[i] == n)
        cont ++;
    }
    printf("%d\n", cont);
}


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

#define REP(i, a, b) for (int i = int(a); i < int(b); i++)
#ifdef _DEBUG_
#define dump(val) cerr << __LINE__ << ":\t" << #val << " = " << (val) << endl
#else
#define dump(val)
#endif

using namespace std;

typedef long long int ll;
typedef pair<int, int> P;

template<typename T>
vector<T> make_v(size_t a, T b) {
    return vector<T>(a, b);
}

template<typename... Ts>
auto make_v(size_t a, Ts... ts) {
    return vector<decltype(make_v(ts...))>(a, make_v(ts...));
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int h, w;
    cin >> h >> w;
    auto mp = make_v(h + 2, w + 2, '#');
    REP(i, 1, h + 1) {
        REP(j, 1, w + 1) {
            cin >> mp[i][j];
        }
    }
    queue<P> q;
    auto mpcopy = mp;
    REP(i, 1, h + 1) {
        REP(j, 1, w + 1) {
            if (mp[i][j] == '.') continue;
            int n = mp[i][j] - '0';
            REP(a, -1, 2) {
                REP(b, -1, 2) {
                    if (mp[i + a][j + b] == '#') continue;
                    n -= (mp[i + a][j + b] == '.');
                }
            }
            if (n <= 0) {
                mpcopy[i][j] = '.';
                q.emplace(j, i);
            } else {
                mpcopy[i][j] = n + '0';
            }
        }
    }
    mp = mpcopy;
    int ans = 0;
    while (q.size()) {
        queue<P> qcopy;
        ans++;
        while (q.size()) {
            int x = q.front().first, y = q.front().second;
            q.pop();
            REP(a, -1, 2) {
                REP(b, -1, 2) {
                    if (a == 0 && b == 0) {
                        continue;
                    }
                    if (mp[y + a][x + b] == '#' || mp[y + a][x + b] == '.') continue;
                    mp[y + a][x + b]--;
                    if (mp[y + a][x + b] <= '0') {
                        mp[y + a][x + b] = '.';
                        qcopy.emplace(x + b, y + a);
                    }
                }
            }
        }
        while (qcopy.size()) {
            int x = qcopy.front().first, y = qcopy.front().second;
            qcopy.pop();
            mp[y][x] = '.';
            q.emplace(x, y);
        }
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 4988
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#define INF 1e9
#define ALL(v) v.begin(), v.end()
#define REP(i, n) for(int i = 0; i < n; i++)
#define max(v) *max_element(v.begin(), v.end())
#define min(v) *min_element(v.begin(), v.end())
template<class T>bool chmax(T &former, const T &b) { if (former<b) { former=b; return true; } return false; }
template<class T>bool chmin(T &former, const T &b) { if (b<former) { former=b; return true; } return false; }
using namespace std;
 
int main(void){
  long int k, a, b, ans=1, coc=1, yen=0; 
  cin>>k>>a>>b;
  if((b-a)<=2)
    ans+=k;
  else{
    for(int i=k; i>0; --i){
      if(coc >= a && i>=2 && yen == 0){
        coc -= a;
        yen+=1;
      }
      else if(i>=1 && yen == 1){
        coc += b;
        yen -= 1;
      }
      else
        coc += 1;
    }
    ans=coc;
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 256
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7
 
A = LIST()
A.sort()

if A[0] + A[1] == A[2]:
	print("Yes")
else:
	print("No")

Measured memory_bytes: 5208
#include <iostream>
#include <iomanip>
#include <cmath>

using namespace std;

int main(int argc, char const *argv[])
{
    double N, K;
    cin >> N >> K;
    
    double ans = 0;
    double clog, clog_;
    for (double i = 1; i <= N; i++)
    {
        if (i <= K - 1)
        {
            clog_ = (log(K / i)) / log(2);
            clog = ceil(clog_);
            ans += (1.0 / N) * pow(0.5, clog);
        }else
        {
            ans += (1.0 / N);
        }

    }

    cout << fixed << setprecision(12) << ans << endl;

    return 0;
}

Measured memory_bytes: 384
program kadai
character(len=10)  ::  T,S,U
integer  ::  a,b

read(*,*) S,T
read(*,*) a,b
read(*,*) U

if (S==U) then
    a=a-1
else
    b=b-1
end if

write(*,*) a,b

stop
contains

end program kadai


Measured memory_bytes: 384
var readline = require('readline');
var lines = [];

var rl = readline.createInterface({
    input:process.stdin,
    output:process.stdout,
});

rl.on('line',function(x){
    lines.push(x);
});

rl.on('close',function(){
    var tmp = lines.shift();
    var n = Number(tmp.split(" ")[0]);
    var m = Number(tmp.split(" ")[1]);
    var result = 0;

    var x = Array(m);
    var w = Array(m);
    tmp = lines[0].split(" ");
    for(var i=0;i<m;i++){x[i]=Number(tmp[i]);}
    x.sort(function(a,b){return(a-b);});
    
    w[0]=0;
    for(var i=1;i<m;i++){w[i]=x[i]-x[i-1];}
    w.sort(function(a,b){return(a-b);});
        
    for(var i=0;i<w.length-(n-1);i++){
        result = result + w[i];
    }

    console.log(result);
});

Measured memory_bytes: 29232
#include <bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
#define MOD 1000000007
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3f
#define EPS (1e-10)
using namespace std;
typedef long long ll;
typedef pair<ll,ll>P;

ll h[300000];
ll a[300000],b[300000];
ll dp[300000];

bool check(P a,P b,P c){
	double A[]{a.first,b.first,c.first},B[]{a.second,b.second,c.second};
	return (B[0]-B[2])*(A[1]-A[0])<=(B[0]-B[1])*(A[2]-A[0]);
}
int main(){
	int n;ll C;cin>>n>>C;
	rep(i,n)scanf("%lld",&h[i]);
	deque<P>que;
	dp[0]=0;
	que.push_back(P(-2*h[0],h[0]*h[0]+C));
	for(int i=1;i<n;i++){
		while(que.size()>1&&que[0].first*h[i]+que[0].second>que[1].first*h[i]+que[1].second){
			que.pop_front();
		}
		dp[i]=que[0].first*h[i]+que[0].second+h[i]*h[i];
		P add=P(-2*h[i],dp[i]+h[i]*h[i]+C);
		while(que.size()>1&&check(que[que.size()-2],que.back(),add))que.pop_back();
		que.push_back(add);
	}
	cout<<dp[n-1]<<endl;
}

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

int main() {
  char ch;
  int K, U, P, C;

  K = U = P = C;
  while(cin >> ch) {
    if(ch == 'K') K++;
    if(ch == 'U') U++;
    if(ch == 'P') P++;
    if(ch == 'C') C++;
  }

  cout << min(K, min(U, min(P,C) ) ) << endl;
  
  return 0;
}

Measured memory_bytes: 1144
using System;
using System.Collections.Generic;

namespace cswork {
    class Program {
        static void Main (string[] args) {
            string s = ReadStr();
            Write(s.Replace(",", " "));
            Exit ();
        }

        public static void Write (string str) {
            Console.WriteLine (str);
        }

        public static void Write (int i) {
            Console.WriteLine (i);
        }

        public static void Write (double d) {
            Console.WriteLine (d);
        }

        public static string ReadStr () {
            return Console.ReadLine ();
        }

        public static int ReadInt () {
            return int.Parse (Console.ReadLine ());
        }

        public static long Read () {
            return long.Parse (Console.ReadLine ());
        }

        public static double ReadDouble () {
            return double.Parse (Console.ReadLine ());
        }

        public static void Exit () { }

        public static List<string> ReadListStr () {
            return new List<string> (ReadStr ().Split (" "));
        }

        public static List<long> ReadList () {
            return ReadListStr ().ConvertAll (x => long.Parse (x));
        }

        public static List<int> ReadListInt () {
            return ReadListStr ().ConvertAll (x => int.Parse (x));
        }
    }
}

Measured memory_bytes: 25868
import java.util.*;

class Main{
  public static void main(String []args){
    Scanner sc = new Scanner(System.in);
    int x = sc.nextInt();
    int y = x;
    for(int i = 0; i < 2; i++){
       x *= y;
    }
  System.out.println(x);
  sc.close();
  }
}

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

using namespace std;

const int N = 1e2 + 5;
int _w;

int f[N][N] , n , m;
char str[N][N];
bool g[N][N];

int main( void ) {
  _w = scanf("%d%d",&n,&m);
  for( int i = 1 ; i <= n ; ++i ) _w = scanf("%s",str[i] + 1);
  memset( f , 0x3f , sizeof f );
  if( str[1][1] == '.' ) f[1][1] = 0;
  else {
    g[1][1] = 1;
    for( int i = 1 ; i <= n ; ++i )
      for( int j = 1 ; j <= m ; ++j ) 
        if( g[i][j] ) {
          if( i < n && str[i + 1][j] == '#' ) g[i + 1][j] = 1;
          if( j < m && str[i][j + 1] == '#' ) g[i][j + 1] = 1;
        }
    for( int i = 1 ; i <= n ; ++i )
      for( int j = 1 ; j <= m ; ++j )
        if( g[i][j] )
          f[i][j] = 1;
  }
  for( int i = 1 ; i <= n ; ++i )
    for( int j = 1 ; j <= m ; ++j )
      if( f[i][j] < 0x3f3f3f3f ) {
        if( i < n && str[i + 1][j] == '.' )
          f[i + 1][j] = min( f[i + 1][j] , f[i][j] );
        if( j < m && str[i][j + 1] == '.' )
          f[i][j + 1] = min( f[i][j + 1] , f[i][j] );
        for( int x = i ; x <= n ; ++x )
          for( int y = j ; y <= m ; ++y )
            g[x][y] = 0;
        if( i < n && str[i + 1][j] == '#' ) g[i + 1][j] = 1;
        if( j < m && str[i][j + 1] == '#' ) g[i][j + 1] = 1;
        for( int x = i ; x <= n ; ++x )
          for( int y = j ; y <= m ; ++y )
            if( g[x][y] ) {
              if( x < n && str[x + 1][y] == '#' ) g[x + 1][y] = 1;
              if( y < m && str[x][y + 1] == '#' ) g[x][y + 1] = 1;
              f[x][y] = min( f[x][y] , f[i][j] + 1 );
            }
      }
  printf("%d",f[n][m]);
  return 0;
}


Measured memory_bytes: 3888
N, = map(int, raw_input().split())
a = map(int, raw_input().split())
sl = [0]*N
sl[0] = a[0]
for i in range(N-1):
  sl[i+1] = sl[i]+a[i+1]
sr = [0]*N
sr[N-1] = a[N-1]
for i in range(N-1,0,-1):
  sr[i-1] = sr[i]+a[i-1]
r = abs(sl[0]-sr[1])
for i in range(1, N-1):
  r = min(r, abs(sl[i]-sr[i+1]))
print r

Measured memory_bytes: 27440
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <algorithm>
#include <climits>
#include <cstring>
#include <cmath>
#include <stack>
#include <iomanip>
#include <tuple>
#include <functional>
#include <cfloat>
#include <map>
#include <stdio.h>
#include <string.h>
using ll = long long;

//LLONG_MAX
#define int long long
#define CONTAINS(v,n) (find((v).begin(), (v).end(), (n)) != (v).end())
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
#define ARY_SORT(a, size) sort((a), (a)+(size))
#define MAX(a,b) (((a) > (b)) ? (a) : (b))
#define MIN(a,b) (((a) < (b)) ? (a) : (b))
#define REMOVE(v,a) (v.erase(remove((v).begin(), (v).end(), (a)), (v).end()))
#define REVERSE(v) (reverse((v).begin(), (v).end()))
#define LOWER_BOUND(v,a) (lower_bound((v).begin(), (v).end(), (a)))
#define UPPER_BOUND(v,a) (upper_bound((v).begin(), (v).end(), (a)))
#define REP(i, n) for (int (i)=0; (i) < (n); (i)++)
#define CONTAINS_MAP(m, a) (m).find((a)) != m.end()

using namespace std;

int H;

signed main()
{
	cin >> H;
	int ans = 0;

	int cnt = 0;
	int n = 1;
	while (true)
	{
		ans += n;
		n *= 2;
		H /= 2;
		if (H == 0) break;
	}

	cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <bitset>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#include <map>
#include <numeric>
#include <array>
#include <queue>
#include <set>
using namespace std;
using ll = long long int;
#define REP(i,n) for(int i=0;i<n;i++)

int main()
{
    int P, Q, R;
    cin >> P >> Q >> R;

    cout << min(P+Q, min(Q+R, R+P)) << endl;
}

Measured memory_bytes: 256
import scala.io.StdIn.{readInt, readLine}
object Main {
    def main(args: Array[String]): Unit = {
        val cnt = readInt;
        val binTree = new BinaryTree[Long,Boolean]((k1, k2) => if (k1 < k2) -1 else if (k1 > k2) 1 else 0);
        (0 until cnt).foreach { i =>
            readLine.split(" ") match {
                case Array("insert", key) => binTree.insert(key.toLong, true);
                case Array("find", key) => {
                    if (binTree.find(key.toLong) != None) println("yes") else println("no");
                }
                case Array("print") => {
                    println(" " + binTree.fetchInorder.map(_._1).mkString(" "));
                    println(" " + binTree.fetchPreoder.map(_._1).mkString(" "));
                }
            }
        }
    }
}
class BinaryTree[A,B](val compare: (A,A) => Int) {
    case class RootNode(var child: TreeNode);
    case class TreeNode(key: A, value: B, var left: TreeNode, var right: TreeNode);
    var tree: RootNode = RootNode(null);
    
    def isEmpty(): Boolean = if (tree.child == null) true else false;
    
    // 要素を登録する
    def insert(key: A, value: B): Unit = {
        def _insert(curr: TreeNode): Unit = {
            if (compare(key, curr.key) < 0) { // 追加対象ノードのほうが小さい
                if (curr.left == null) curr.left = TreeNode(key, value, null, null) else _insert(curr.left);
            } else if (compare(key, curr.key) > 0) { // 追加対象ノードのほうが大きい
                if (curr.right == null) curr.right = TreeNode(key, value, null, null) else _insert(curr.right);
            }
        }
        if (isEmpty) tree.child = TreeNode(key, value, null, null) else _insert(tree.child);
    }
    
    // key を探索する
    def find(key: A): Option[B] = {
        def _find(curr: TreeNode): Option[B] = {
            if (compare(key, curr.key) == 0) {
                Some(curr.value);
            } else if (compare(key, curr.key) < 0) {
                if (curr.left == null) None else _find(curr.left);
            } else {
                if (curr.right == null) None else _find(curr.right);
            }
        }
        if (isEmpty) None else _find(tree.child);
    }

    // 先行巡回で要素を返す
    def fetchPreoder(): List[(A, B)] = {
        def _fetchPreoder(curr: TreeNode, ret: List[(A, B)]): List[(A, B)] = {
            if (curr == null) {
                ret;
            } else {
                val ret1 = (curr.key, curr.value) :: ret;
                val ret2 = _fetchPreoder(curr.left, ret1);
                val ret3 = _fetchPreoder(curr.right, ret2);
                ret3;
            }
        }
        _fetchPreoder(tree.child, Nil).reverse;
    }
    
    // 中間巡回で要素を返す
    def fetchInorder(): List[(A, B)] = {
        def _fetchInorder(curr: TreeNode, ret: List[(A, B)]): List[(A, B)] = {
            if (curr == null) {
                ret;
            } else {
                val ret1 = _fetchInorder(curr.left, ret);
                val ret2 = (curr.key, curr.value) :: ret1;
                val ret3 = _fetchInorder(curr.right, ret2);
                ret3;
            }
        }
        _fetchInorder(tree.child, Nil).reverse;
    }
}


Measured memory_bytes: 475780