akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
using namespace std;
#define Rep(i,n) for(int i=0;i<(int)(n);i++)
#define For(i,n1,n2) for(int i=(int)(n1);i<(int)(n2);i++)
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define RREP(i,n) for(ll i=((ll)(n)-1);i>=0;i--)
#define FOR(i,n1,n2) for(ll i=(ll)(n1);i<(ll)(n2);i++)
#define RFOR(i,n1,n2) for(ll i=((ll)(n1)-1);i>=(ll)(n2);i--)
#define all(a)  (a).begin(),(a).end()
#define SORT(a) sort((a).begin(),(a).end())
#define oorret 0
#define oor(x) [&](){try{x;} catch(const out_of_range& oor){return oorret;} return x;}()
#define IOS cin.tie(0),ios::sync_with_stdio(false)
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
template<typename T1, typename T2> inline bool chmin(T1& a, T2 b) { if (a > b) { a = b; return 1; }return 0; }
template<typename T1, typename T2> inline bool chmax(T1& a, T2 b) { if (a < b) { a = b; return 1; }return 0; }
template<class Type>struct is_vector : std::false_type {};
template<class ValueType, class Alloc>struct is_vector<std::vector<ValueType, Alloc>> : std::true_type {};
template <typename T> inline ostream& operator << (ostream& out, const vector<T>& v) {
    if (v.empty())return out;
    constexpr bool is_vector_v = is_vector<T>::value;
    if (is_vector_v)for (auto itr = v.begin(); itr != v.end();)out << (*itr), out << ((++itr != v.end()) ? "\n" : "");
    else for (auto itr = v.begin(); itr != v.end();)out << (*itr), out << ((++itr != v.end()) ? " " : "");
    return out;
}
inline void put() {}
template<class T> inline void put(const T& first) { std::cout << first << "\n"; }
template<class T, class... N> inline void put(const T& first, const N& ... rest) { std::cout << first << " "; put(rest...); }
inline void putn() {}
template<class T, class... N> inline void putn(const T& first, const N& ... rest) { std::cout << first << "\n"; putn(rest...); }

int main() {
    IOS;
    string s;
    cin >> s;
    bool flag= true;
    REP(i,s.size()){
        if(i%2==0){
            if(s[i]=='L'){
                flag=false;
            }
        }else{
            if(s[i]=='R'){
                flag=false;
            }
        }
    }
    if(flag){
        put("Yes");
    }else{
        put("No");
    }
    return 0;
}


Measured memory_bytes: 256
using System;

namespace alphabet
{
    class Program
    {
        static void Main(string[] args)
        {
            string inD0 = Console.ReadLine();
            char inN0 = inD0[0];

            int from_a = (int)'a';
            int to_z = (int)'z';
            int from_A = (int)'A';
            int to_Z = (int)'Z';

            if (from_a<=(int)inN0 && (int)inN0 <= to_z){
                Console.WriteLine("a");
            }
            else if(from_A <= (int)inN0 && (int)inN0 <= to_Z)
                {
                    Console.WriteLine("A");
                }

        }
    }
}


Measured memory_bytes: 25852
import java.util.*;
import java.io.*;

public class Main{

static BufferedReader s1;
static BufferedWriter out;
static String read() throws IOException{String line="";while(line.length()==0){line=s1.readLine();continue;}return line;}
static int int_v (String s1){return Integer.parseInt(s1);}
static long long_v(String s1){return Long.parseLong(s1);}
static int[] int_arr() throws IOException{String[] a=read().split("\\s+");int[] b=new int[a.length];for(int i=0;i<a.length;i++){b[i]=int_v(a[i]);}return b;}
static long[] long_arr() throws IOException{String[] a=read().split("\\s+");long[] b=new long[a.length];for(int i=0;i<a.length;i++){b[i]=long_v(a[i]);}return b;}
static void assign(){s1=new BufferedReader(new InputStreamReader(System.in));out=new BufferedWriter(new OutputStreamWriter(System.out));}
static long Modpow(long a,long p,long m){long res=1;while(p>0){if((p&1)!=0){res=(res*a)%m;}p >>=1;a=(a*a)%m;}return res;}
//......................................@uthor_Alx..............................................
static long mod=(long)1e9+7;

public static void main(String[] args) throws  IOException{
                assign();
                int n=int_v(read());
                int[] a=int_arr();
                long[][] dp=new long[n+1][4];
                dp[0][0]=1000l;
                for(int i=1;i<=n;i++){
                    dp[i][2]=dp[i-1][3]+(long)a[i-1]*dp[i-1][1];//sell all
                    long max=Math.max(dp[i-1][0],Math.max(dp[i-1][2],dp[i][2]));
                    dp[i][0]=max;// doing nothing
                    dp[i][1]= max/a[i-1];//buy all
                    dp[i][3]=max-(long)dp[i][1]*a[i-1];
                }
                out.write(Math.max(dp[n][0],dp[n][2])+"");
                out.flush();

    }
}


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

template<class M> struct SegmentTree
{
	int n;
	int size;
	vector<M> data;
	const function<M(M, M)> op;
	const M ID;

	SegmentTree(int n, function<M(M, M)> op, M id, const vector<M> &init_vals=vector<M>()) : n(n), op(op), ID(id) {
		size = 1;
		while (size < n) size <<= 1;
		data.assign(size * 2, ID);
		for (int i = 0; i < init_vals.size(); i++) data[size+i] = init_vals[i];
		for (int i = size-1; i > 0; i--) data[i] = op(data[2*i], data[2*i+1]);
	}

	void init(const vector<M> &init_vals) {
		data.assign(size * 2, ID);
		for (int i = 0; i < init_vals.size(); i++) data[size+i] = init_vals[i];
		for (int i = size-1; i > 0; i--) data[i] = op(data[2*i], data[2*i+1]);
	}

	void update(int idx, M x) {
		idx += size;
		data[idx] = x;
		while (idx >>= 1) {
			data[idx] = op(data[2*idx], data[2*idx+1]);
		}
	}

	M query(int l, int r) {
		M L = ID, R = ID;
		for (l += size, r += size; l < r; l >>= 1, r >>= 1) {
			if (l & 1) L = op(L, data[l]), l++;
			if (r & 1) r--, R = op(data[r], R);
		}
		return op(L, R);
	}

	M query_all() {
		return data[1];
	}

	int find_max_right(int l, const function<bool(M)> &f) {
		if (l == n) return n;
		l += size;
		M s = ID;
		while (true) {
			while (l % 2 == 0) l >>= 1;
			if (!f(op(s, data[l]))) break;
			s = op(s, data[l]);
			l++;
			if ((l & -l) == l) return n;
		}
		while (l < size) {
			l = 2 * l;
			if (f(op(s, data[l]))) {
				s = op(s, data[l]);
				l++;
			}
		}
		return l - size;
	}

	int find_min_left(int r, const function<bool(M)> &f) {
		if (r == 0) return 0;
		r += size;
		M s = ID;
		while (true) {
			r--;
			while (r > 1 && (r % 2)) r >>= 1;
			if (!f(op(data[r], s))) break;
			s = op(data[r], s);
			if ((r & -r) != r) return 0;
		}
		while (r < size) {
			r = 2 * r + 1;
			if (f(op(data[r], s))) {
				s = op(data[r], s);
				r--;
			}
		}
		return r + 1 - size;
	}

	M val(int idx) {
		return data[size + idx];
	}

	vector<M> val_vec() {
		vector<M> res(n);
		for (int i = 0; i < n; i++) res[i] = data[size+i];
		return res;
	}
};

int main() {
	int n, Q;
	cin >> n >> Q;
	vector<int> A(n);
	for (int i = 0; i < n; i++) {
		scanf("%d", &A[i]);
	}
	using M = int;
	auto op = [&](M a, M b) -> M {
		return max(a, b);
	};
	M id = -1;
	SegmentTree<M> st(n, op, id, A);
	int thr;
	auto f = [&](M m) -> bool {
		return m < thr;
	};
	for (int q = 0; q < Q; q++) {
		int type;
		scanf("%d", &type);
		if (type == 1) {
			int x, v;
			scanf("%d%d", &x, &v);
			x--;
			st.update(x, v);
		} else if (type == 2) {
			int l, r;
			scanf("%d%d", &l, &r);
			l--;
			int ans = st.query(l, r);
			cout << ans << '\n';
		} else {
			int x, v;
			scanf("%d%d", &x, &v);
			x--;
			thr = v;
			int ans = st.find_max_right(x, f) + 1;
			cout << ans << '\n';
		}
	}
	return 0;
}

Measured memory_bytes: 5812
#include <bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef pair<int,int>P;
#define F first
#define S second

int used[100009];
int jis[100009],n,k,a[100009];
vector<int>v[100009];

signed main(){
  cin>>n>>k;
  r(i,n){
    cin>>a[i];
    if(a[i]){
      v[i].push_back(a[i]-1);
      jis[a[i]-1]++;
    }
  }
  queue<int>q;
  r(i,n){
    if(jis[i]==0||a[i]==0){
      if(a[i])q.push(i);
      used[i]=1;
    }
  }
  while(!q.empty()){
    int x=q.front();q.pop();
   // cout<<x<<' '<<used[x]<<endl;
    if(used[x]==k)continue;
    r(i,v[x].size()){
      if(used[v[x][i]])continue;
      used[v[x][i]]=used[x]+1;
      q.push(v[x][i]);
    }
  }
  int s=0;
  r(i,n){
    if(used[i])s++;
  }
  cout<<s<<endl;
}


Measured memory_bytes: 9932
#include <algorithm>
#include <iostream>
#include <vector>
#include <iomanip>
using namespace std;

long double val[55];
int32_t main() {
    ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);

    int n;
    cin >> n;
    cout<<fixed<<setprecision(7);
    for (int i = 0; i < n; i++) cin >> val[i];
    sort(val, val + n);
    for (int i = 1; i < n; i++) {
        val[i] = (val[i] + val[i - 1]) / 2;
    }
    cout << val[n - 1] << endl;
    return 0;
}

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

int N, M, A, B, C, D, x1, x2, y1, y2, Ans;
int main(){
  scanf("%d%d", &N, &M);
  int K[N+10][N+10];
  for(int i=1; i<=N; i++){
    for(int j=1; j<=N; j++){
      K[i][j] = 2000;
    }
  }
  for(int i=1; i<=M; i++){
    scanf("%d,%d,%d,%d", &A, &B, &C, &D);
    //cerr << "read " << A << ' ' << B << ' ' << C << ' ' << D << endl;
    K[A][B] = C;
    K[B][A] = D;
  }
  for(int k=1; k<=N; k++){
    for(int i=1; i<=N; i++){
      for(int j=1; j<=N; j++){
        if(K[i][j] > K[i][k] + K[k][j]){
          K[i][j] = K[i][k] + K[k][j];
        }
      }
    }
  }

  int s, g, V, P;
  scanf("%d,%d,%d,%d", &s, &g, &V, &P);
  Ans = V - P - K[s][g] - K[g][s];
  printf("%d\n", Ans);
  return 0;
}



Measured memory_bytes: 3232
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "functional"
#include "ctime"

using namespace std;

//constexpr long long int MOD = 1000000007;
constexpr int MOD = 1000000007;
//constexpr int MOD = 998244353;
//constexpr long long int MOD = 998244353;
constexpr double EPS = 1e-8;

//int N, M, K, H, W, L, R;
long long int N, M, K, H, W, L, R;



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

	cin >> N;
	vector<int>v(N);
	vector<int>w(N);
	vector<int>z(N - 1);
	for (auto &i : v)cin >> i;
	for (auto &i : w)cin >> i;
	for (auto &i : z)cin >> i;
	for (int i = 1; i < N; i++) {
		if (v[i] == v[i - 1] + 1) {
			w[i] += z[v[i - 1] - 1];
		}
	}
	cout << accumulate(w.begin(), w.end(), 0) << endl;
}

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

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

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

/**
 * @brief 多次元 vector の作成
 * @author えびちゃん
 */
namespace detail {
    template<typename T, int N>
    auto make_vec(vector<int>& sizes, T const& x) {
        if constexpr (N == 1) {
            return vector(sizes[0], x);
        } else {
            int size = sizes[N-1];
            sizes.pop_back();
            return vector(size, make_vec<T, N-1>(sizes, x));
        }
    }
}
template<typename T, int N>
auto make_vec(int const(&sizes)[N], T const& x = T()) {
    vector<int> s(N);
    for (int i = 0; i < N; ++i) s[i] = sizes[N-i-1];
    return detail::make_vec<T, N>(s, x);
}

__attribute__((constructor))
void fast_io() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
}

int main() {
    int d, t, s;
    cin >> d >> t >> s;
    if (s * t >= d) cout << "Yes\n";
    else cout << "No\n";
}


Measured memory_bytes: 3652
#include <iostream>
using namespace std;
int a[10001];
int check(int n,int k){
	int i=0;
	a[n] = k;
	while(a[i]!=k) i++;
	return i != n;
}
int main() {
	int n,q,k,cnt=0;
	cin>>n;
	for(int i=0;i<n;i++)
		scanf("%d",&a[i]);
	cin>>q;
	while(q--){
		scanf("%d",&k);
		if(check(n,k)) cnt++;
	}
	cout<<cnt<<endl;
	return 0;
}


Measured memory_bytes: 3204
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i,m,n) for(int i=(m);i<(n);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define all(a) a.begin(),a.end()
#define rall(c) (c).rbegin(),(c).rend()
#define mp make_pair
#define endl '\n'
#define vec vector<ll>
#define mat vector<vector<ll> >
#define fi first
#define se second
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> pll;
typedef long double ld;
typedef complex<double> comp;
const ll INF=1e9+7;
const ll inf=INF;
const ll MOD=998244353;
const ll mod=MOD;
const int MAX=200010;
//SegmentTree
template< typename Monoid >
struct SegmentTree
{
  using F = function< Monoid(Monoid, Monoid) >;
 
  int sz;
  vector< Monoid > seg;
 
  const F f;
  const Monoid M1;
 
  SegmentTree(int n, const F f, const Monoid &M1) : f(f), M1(M1)
  {
    sz = 1;
    while(sz < n) sz <<= 1;
    seg.assign(2 * sz, M1);
  }
 
  void set(int k, const Monoid &x)
  {
    seg[k + sz] = x;
  }
 
  void build()
  {
    for(int k = sz - 1; k > 0; k--) {
      seg[k] = f(seg[2 * k + 0], seg[2 * k + 1]);
    }
  }
 
  void update(int k, const Monoid &x)
  {
    k += sz;
    seg[k] = x;
    while(k >>= 1) {
      seg[k] = f(seg[2 * k + 0], seg[2 * k + 1]);
    }
  }
 
  Monoid query(int a, int b)
  {
    Monoid L = M1, R = M1;
    for(a += sz, b += sz; a < b; a >>= 1, b >>= 1) {
      if(a & 1) L = f(L, seg[a++]);
      if(b & 1) R = f(seg[--b], R);
    }
    return f(L, R);
  }
 
  Monoid operator[](const int &k) const
  {
    return seg[k + sz];
  }
};

signed main(){
    ll n;cin>>n;
    ll q;cin>>q;
    vector<ll>mi(q+1);
    vector<ll>mi2(q+1);
    ll ans=0;
    mi[0]=n-1;
    mi2[0]=n-1;
    SegmentTree<ll>seg(n,[](ll a,ll b){return min(a,b);},inf),seg2(n,[](ll a,ll b){return min(a,b);},inf);
    seg.build();
    seg2.build();
    rep(i,q){
        ll c,x;cin>>c>>x;
        x--;
        if(c==1){
            ll idx=seg.query(0,x);
            if(idx==inf){
                ans+=mi[i]-1;
            }else{
                ans+=mi[idx]-1;
            }
            seg.update(x,i);
            mi2[i+1]=min(mi2[i],x);
            mi[i+1]=mi[i];
        }else{
            ll idx=seg2.query(0,x);
            if(idx==inf){
                ans+=mi2[i]-1;
            }else{
                ans+=mi2[idx]-1;
            }
            seg2.update(x,i);
            mi[i+1]=min(mi[i],x);
            mi2[i+1]=mi2[i];
        }
    }
    cout<<(n-2)*(n-2)-ans<<endl;
}

Measured memory_bytes: 14548
#include<stdio.h>
int main()
{
    long long int a,b,c;
    char op;
    scanf("%lld %c %lld",&a,&op,&b);
    if(op=='+')
    {
        c=a+b;
        printf("%lld\n",c);
    }
    else if(op=='-')
    {
        c=a-b;
        printf("%lld\n",c);
    }
    return 0;
}


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

int main(){
    using namespace std;
    unsigned long N;
    cin >> N;
    vector<unsigned long> deg(N * (N - 1));
    vector<vector<unsigned long>> A(N, vector<unsigned long>(N - 1)), next(N, vector<unsigned long>(N, N));
    for(auto& i : A)for(auto& j : i){
        cin >> j;
        --j;
    }
    for(unsigned long i = 0; i < N; ++i){
        for(unsigned long j = 1; j + 1 < N; ++j){
            next[i][A[i][j - 1]] = A[i][j];
            ++deg[max(i, A[i][j]) + min(i, A[i][j]) * (N - 1) - 1];
        }
    }
    stack<pair<unsigned long, unsigned long>> st;
    vector<unsigned long> toposo(N * (N - 1));
    for(unsigned long i = 1; i < N; ++i)for(unsigned long j = 0; j < i; ++j)if(deg[i + j * (N - 1) - 1] == 0){
        st.emplace(j, i);
    }
    unsigned long cnt{0}, ctn{0};
    while(!st.empty()){
        stack<pair<unsigned long, unsigned long>> tap;
        while(!st.empty()){
            auto t = st.top();
            ++ctn;
            st.pop();
            toposo[t.first * (N - 1) + t.second - 1] = cnt;
            if(next[t.first][t.second] < N){
                auto m = min(t.first, next[t.first][t.second]), M = max(t.first, next[t.first][t.second]);
                if(--deg[m * (N - 1) + M - 1] == 0)tap.emplace(m, M);
            }
            if(next[t.second][t.first] < N){
                auto m = min(t.second, next[t.second][t.first]), M = max(t.second, next[t.second][t.first]);
                if(--deg[m * (N - 1) + M - 1] == 0)tap.emplace(m, M);
            }
        }
        ++cnt;
        swap(tap, st);
    }
    if(ctn != N * (N - 1) / 2)return 0 & puts("-1");
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 31616
var toInt = x=>parseInt(x,10);
var toIntArr = arr=>arr.map(x=>toInt(x));
var abs = x=>x>0?x:-x;
function min(){var rest=arguments,v=rest[0];for(var i=1;i<rest.length;i++)if(rest[i]<v)v=rest[i];return v}
function max(){var rest=arguments,v=rest[0];for(var i=1;i<rest.length;i++)if(rest[i]>v)v=rest[i];return v}
function gcd(){var rest=arguments,v=rest[0],temp=(a,b)=>b?temp(b,a%b):a;for(var i=1;i<rest.length;i++)v=temp(v,rest[i]);return v}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));
 
function Main(input){
	var input = input.split('\n');
	var s = input[0];
	var t = input[1];
	var n = s.length;
	var x = [];
	var y = [];
	var a,b;
	var c,d;
	var e,f;
	for(var i = 0; i < n; i++){
		a = x.indexOf(s[i]);
		b = y.indexOf(t[i]);
		if(a>-1){
			if(b>-1){
				if(a !== b){
					console.log('No');
					return 0;
				}
			}else{
				console.log('No');
				return 0;
			}
		}else{
			if(b>-1){
				console.log('No');
				return 0;
			}else{
				c = s[i];
				d = t[i];
				x.push(c);
				y.push(d);
				for(var j = i+1; j < n; j++){
					e = s[j]===c? 1: -1;
					f = t[j]===d? 1: -1;
					if(e*f !== 1){
						console.log('No');
						return 0;
					}
				}
			}
		}
	}
	console.log('Yes');
	return 0;
}

Measured memory_bytes: 21064
use proconio::{input, fastout};
use proconio::marker::{Chars};
use proconio::marker::Usize1;
use std::cmp::*;

macro_rules! debug {
      ($($a:expr),*) => {
          eprintln!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
      }
  }

#[fastout]
fn main() {
    input!{
        s: Chars,
        t: Chars,
    }

    let mut ans = 0;
    for i in 0..s.len()-t.len()+1 {
        let mut cnt = 0;
        for j in 0..t.len() {
            if s[i+j]==t[j] {
                cnt += 1;
            }
        }
        ans = max(ans, cnt);
    }
    debug!(t.len());
    debug!(ans);
    println!("{}", t.len()-ans);

}


Measured memory_bytes: 2172
#include <iostream>
#include <string>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <queue>
#include <stack>
#include <iomanip>


using namespace std;

#define REP(i, n) for(ll i = 0;i < n;i++)
#define REPR(i, n) for(ll i = n;i >= 0;i--)
#define FOR(i, m, n) for(ll i = m;i < n;i++)
#define FORR(i, m, n) for(ll i = m;i >= n;i--)
#define REPO(i, n) for(ll i = 1;i <= n;i++)
#define ll long long
#define INF (ll)1 << 60
#define MINF (-1 * INF)
#define ALL(n) n.begin(),n.end()
#define MOD (ll)1000000007
#define P pair<ll, ll>

ll a, b, c;
int main() {
	cin >> a >> b >> c;
	if (a == b and b == c and a % 2 == 0) {
		cout << -1 << endl;
		return 0;
	}
	ll ans = 0;
	while (a % 2 == 0 and b % 2 == 0 and c % 2 == 0) {
		ll na = (b + c) / 2, nb = (a + c) / 2, nc = (a + b) / 2;
		a = na;
		b = nb;
		c = nc;
		ans++;
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        int workspace;
        
        workspace = a;
        a = b;
        b = workspace;
        
        workspace = a;
        a = c;
        c = workspace;
        
        System.out.print(a + " " + b + " " + c);
    }
}

Measured memory_bytes: 39004
#include <bits/stdc++.h>
using namespace std;
#define ld double
#define ll long long
#define pb emplace_back
#define mk make_pair
#define mod 1000000007
#define ff first
#define ss second
#define sz(x) (int)x.size()
#define FIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define all(x) x.begin(),x.end()
ll power(ll a, ll b) {ll res = 1; a = a % mod; while (b) {if (b & 1)res = (res * a) % mod; a = (a * a) % mod; b /= 2;} return res;}
ll invmod(ll a) {return power(a, mod - 2);}
int main(void)
{
	FIO
	int t = 1;
	// cin >> t;
	while (t--)
	{
		ll n;
		cin >> n;
		ll ans = 0;
		for (ll i = 1; i <= n; i++) {
			ll x = n / i;
			ans += i * (x + 1) * x / 2;
		}
		cout << ans << "\n";
	}
	return 0;
}

Measured memory_bytes: 3668
N = int(input())
S = input()

RLE = []
now_char = S[0]
now_cnt = 1
for i in range(1, N):
    if now_char == S[i]:
        now_cnt += 1
    else:
        RLE.append([now_char, now_cnt])
        now_char = S[i]
        now_cnt = 1
RLE.append([now_char, now_cnt])


n = len(RLE)
ans = ""
left_cnt = 0
right_cnt = 0

for i in range(n):
    now_char = RLE[i][0]
    now_cnt = RLE[i][1]
    if now_char == "(":
        left_cnt += now_cnt
    else:
        right_cnt += now_cnt
        if right_cnt > left_cnt:
            ans += "(" * (right_cnt - left_cnt)
            right_cnt = 0
            left_cnt = 0
        else:
            left_cnt -= right_cnt
            right_cnt = 0

ans += S
if left_cnt > 0:
    ans += ")" * left_cnt

print(ans)



Measured memory_bytes: 3064
/***********************
*  Author: xuziyuan    * 
***********************/

#include <bits/stdc++.h>

#define rt0 return 0
#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
#define replet(c) for(char c='a';c<='z';c++) 
#define LL long long
#define pii pair <int,int>
#define pb push_back
#define fi first
#define se second
#define mpr make_pair
#define sqr(a) ((a)*(a))

using namespace std;

const LL MOD=1e9+7;

int n,k,a[60],sum,ans=0;
vector <int> v;

int main()
{
	cin>>n>>k;
	rep(i,n) cin>>a[i];
	rep(i,n+1)
	{
		rep(j,n+1)
		{
			if(i+j>n||i+j>k) break;
			v.clear();
			sum=0;
			rep(p,i) v.pb(a[p]),sum+=a[p];
			for(int p=n-1;p>=n-j;p--) v.pb(a[p]),sum+=a[p];
			sort(v.begin(),v.end());
			for(int p=0;p<k-i-j&&p<i+j;p++) if(v[p]<0) sum-=v[p];
			ans=max(ans,sum);
		}
	}
	cout<<ans<<endl;
	rt0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define N 100000
#define M 100000

using namespace std;

int n,m;
vector<int> edge[N];

void solve(){
    int i,j;
    string str;
    cin >> n >> m;
    int a,b;
    for(i = 0;i < m;i++){
        cin >> a >> b;
        a--;b--;
        edge[a].push_back(b);
        edge[b].push_back(a);
    }
    int f = 0,s = 0;
    for(i = 0;i < n;i++){
        if(edge[i].size()%2){
            cout << "No" << endl;
            return;
        }
        if(edge[i].size() == 4)f++;
        if(edge[i].size() > 4) s++;
    }
    if(s || f > 2){
        cout << "Yes" << endl;
        return;
    }
    if(f < 2){
        cout << "No" << endl;
        return;
    }
    for(i = 0;i < n;i++){
        if(edge[i].size() == 4){
            f = i;
            break;
        }
    }
    for(i++;i < n;i++){
        if(edge[i].size() == 4){
            s = i;
            break;
        }
    }
    int p,q;
    for(i = 0;i < edge[s].size();i++){
        p = s;
        q = edge[s][i];
        while(true){
            if(q == s){
                cout << "Yes" << endl;
                return;
            }
            if(q == f) break;
            for(j = 0;j < edge[q].size();j++){
                if(edge[q][j] != p){
                    p = q;
                    q = edge[q][j];
                    break;
                }
            }
        }
    }
    cout << "No" << endl;
}

int main(){
    solve();
}


Measured memory_bytes: 5760
import java.util.*;
public class Main {
    public static void main(String[] args){
    
    Scanner sc = new Scanner(System.in);
    int N  = sc.nextInt();
    int K  = sc.nextInt();
    int[]P = new int[N];
    
    for(int i=0; i<N; i++){
        P[i] = sc.nextInt();
        }
    Arrays.sort(P);
    int ans = 0;
    for(int i=0; i<K; i++){
        ans += P[i];        
    }
    	System.out.println(ans);
}
}

Measured memory_bytes: 38592
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <map>

int main(){
  std::string S;
  std::cin >> S;
  if (S.length()%2!=0){
    printf("No\n");
  } else {
    bool ok = true;
    for (int i=0; i<S.length(); i++){
      if (i%2==0){
        if (S[i]!='h'){
          ok = false;
          break;
        }
      } else {
        if (S[i]!='i'){
          ok = false;
          break;
        }
      }
    }
    printf("%s\n",ok?"Yes":"No");
  }
  return 0;
}


Measured memory_bytes: 888
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <deque>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <utility>
#include <iostream>
#include <algorithm>
#include <functional>

using namespace std;

#define INF (1 << 30)
#define INFL (1LL << 62)
#define MOD7 1000000007
#define MOD9 1000000009
#define EPS 1e-10

#define ll long long
#define ull unsigned long long
#define pii pair<int, int>
#define pll pair<ll, ll>
#define pul pair<ull, ull>
#define all(a) (a).begin(), (a).end()
#define mp make_pair
#define pb push_back
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);--i)
#define REP(i,n) for (int i=0;i<(n);++i)
#define RREP(i,n) for (int i=(n)-1;i>=0;--i)

void YES() { cout << "YES" << endl; }
void NO() { cout << "NO" << endl; }
void Yes() { cout << "Yes" << endl; }
void No() { cout << "No" << endl; }
void yes() { cout << "yes" << endl; }
void no() { cout << "no" << endl; }
void Taka() { cout << "Takahashi" << endl; }
void Aoki() { cout << "Aoki" << endl; }
void digit(int d) { cout << fixed << setprecision(d); }
void IOup() { cin.tie(0); ios::sync_with_stdio(false); }

int main() {
	string n;
	cin >> n;
	bool a[2] = { 1, 1 };
	for (int i = 0; i < 2; ++i) {
		for (int j = 0; j < 3; ++j) {
			if (n[i + j] != n[i]) {
				a[i] = false;
			}
		}
	}
	if (a[0] || a[1])
		Yes();
	else
		No();

	return 0;
}

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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define POW(n) ((n)*(n))
#define ALL(a) (a).begin(),(a).end()
#define cerr if(false) cerr
 
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
 
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<unsigned long long> vull;

void solve(long long a, long long b, long long x){
	ll ret = (b / x)+1;
  if(a != 0){
    ret--;
    ret -= (a-1)/x;
  }
  cout << ret << endl;
}



int main(){	
	ios::sync_with_stdio(false);
	long long a;
	long long b;
	long long x;
	cin >> a;
	cin >> b;
	cin >> x;
	solve(a, b, x);
	return 0;
}


Measured memory_bytes: 256
<?php

fscanf(STDIN, "%d %d %d", $a, $b, $k);

$divides = [];

for ($i = 1; $i <= 100; ++$i) {
    if ($a % $i === 0 && $b % $i === 0) {
        $divides[] = $i;
    }
}

rsort($divides);
echo $divides[$k - 1];


Measured memory_bytes: 4604
/*
|| Suyash Yadav | B.Tech (3rd Year CSE) | Tier-3 (NCR,India)
|| suyashky@gmail.com | "suyashky" @linkedIn
||
||		   /\_/\
||		  ( o.o )
|| 	 	   > ^ <
|| From infinity to beyond!
*/

# include <bits/stdc++.h>
using namespace std;
# define INF (long long int)1e28
# define MOD 1000000007
# define endl "\n"
# define all(con) con.begin() , con.end()
# define MAX numeric_limits<int64>::max()
# define MIN numeric_limits<int64>::min()
# define watch1(x) cout<<#x<<": "<<x<<endl
# define watch2(x,y) cout<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
# define watch3(x,y,z) cout<<#x<<": "<<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
# define fastio ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long int int64;
typedef unsigned long long int uint64;

struct node {
	int64 w, v;
};

const int64 M = 1e10l + 7;

int main()
{
	int64 t, n, i, j, k, W, N = 0;
	cin >> n >> W;

	vector<int64> p(n), w(n);
	for (int64 i = 0; i < n; i++)
	{
		cin >> w[i] >> p[i];
		N += p[i];
	}

	vector<int64> dp(N + 1);
	for (i = 0; i <= N; i++)
		dp[i] = M;

	dp[0] = 0;
	for (int64 i = 0; i < n; i++) {
		for (j = N; j >= p[i]; j--) {
			dp[j] = min(dp[j], dp[j - p[i]] + w[i]);
		}
	}

	for (i = N ; i >= 0; i--) {

		if (dp[i] <= W) {
			break;
		}
	}
	cout << i;
}

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

int main()
{
    int n,k;
    cin >> n >> k;
    vector<int> v;
    for (int i=0,x;i<n;i++)
    {
        cin >> x;
        v.push_back(x);
    }
    sort(v.begin(),v.end());
    int sum = 0;
    for (int i=0;i<k;i++)
    {
        sum += v[i];
    }
    cout << sum << endl;
}


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

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

	vector<int> ret(n,0);
	for (int i = 0; i < m; ++i) {
		int a, b;
		cin >> a >> b;
		++ret[a - 1];
		++ret[b - 1];
	}

	for (auto& i : ret) {
		cout << i << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <queue>

using namespace std;

int h, w;
queue<pair<int, int>> que;

int Search(int a, int b, vector<string> &d, vector<vector<int>> &k) {
	if (a == h - 1 && b == w - 1)
		return true;
	if (a > 0 && d[a - 1][b] == '.') {
		que.push(make_pair(a - 1, b));
		k[a - 1][b] = k[a][b] + 1;
		d[a - 1][b] = '#';
	}
	if (b > 0 && d[a][b - 1] == '.') {
		que.push(make_pair(a, b - 1));
		k[a][b - 1] = k[a][b] + 1;
		d[a][b - 1] = '#';
	}
	if (a < h - 1 && d[a + 1][b] == '.') {
		que.push(make_pair(a + 1, b));
		k[a + 1][b] = k[a][b] + 1;
		d[a + 1][b] = '#';
	}
	if (b < w - 1 && d[a][b + 1] == '.') {
		que.push(make_pair(a, b + 1));
		k[a][b + 1] = k[a][b] + 1;
		d[a][b + 1] = '#';
	}
	if (que.empty())
		return false;
	a = que.front().first;
	b = que.front().second;
	que.pop();
	return Search(a, b, d, k);
}

int main(void) {
	int sum = 0, i, j;
	cin >> h >> w;
	vector<string> d(h);
	vector<vector<int>> k(h, vector<int>(w, 0));
	k[0][0] = 1;
	d[0][0] = '#';
	for (i = 0; i < h; i++) {
		cin >> d[i];
		for (j = 0; j < w; j++) {
			if (d[i][j] == '.')
				sum++;
		}
	}
	if (Search(0, 0, d, k))
		printf("%d\n", sum - k[h - 1][w - 1]);
	else
		printf("-1\n");
	return 0;
}

Measured memory_bytes: 512
#include<iostream>
#include<iomanip>
#include<string>
#include<vector>
#include<stack>
#include<set>
#include<map>
#include<utility>
#include<tuple>
#include<algorithm>
#include<cmath>
#include<climits>
using namespace std;

typedef long long ll;
const int mod=1e9+7;

int main(){
	double w, h, x, y;
	cin >> w >> h >> x >> y;
	cout << fixed << setprecision(9) << w*h/2 << ' ';
	if(x == w/2 && y == h/2)
		cout << 1 << endl;
	else
		cout << 0 << endl;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
int main()
{string s;
cin>>s;
int cur=s.length();
while(cur>0)
{
    if(cur>=5&&s.substr(cur-5,5)=="dream")
        cur=cur-5;
    else if(cur>=7&&s.substr(cur-7,7)=="dreamer")
        cur=cur-7;
    else if(cur>=5&&s.substr(cur-5,5)=="erase")
        cur=cur-5;
    else if(cur>=6&&s.substr(cur-6,6)=="eraser")
        cur=cur-6;
    else
        {printf("NO\n");
        return 0;


}
}
printf("YES\n");
return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#include <cstdlib>
#include <cmath>
#include <algorithm>
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Graph= vector<vector<int>>; 
#define rep(i,n) for (ll i=0; i < (n); ++i)
#define rep2(i,n,m) for(ll i=n;i<=m;i++)
#define rep3(i,n,m) for(ll i=n;i>=m;i--)
#define pb push_back
#define eb emplace_back
#define ppb pop_back
#define fi first 
#define se second
const ll INF=1e18 ;
inline void chmax(ll& a,ll b){a=max(a,b);}
inline void chmin(ll& a,ll b){a=min(a,b);}
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}
// ミント
const int mod = 1e9+7 ;
  //998244353;

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;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}
//昆布
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];
  }
  mint p(int n,int k){
    return fact[n]*ifact[n-k] ;
  }
  }  c(400005);
 
mint modpow(ll a,ll b){
 if(b==0) return 1 ;
 mint c= modpow(a,b/2) ;
 if(b%2==1) return c*c*a ;
 else return c*c ;
}

mint komb(ll n,ll m){
  mint x=1 ;mint y=1 ;
  rep(i,m){
    x*= n-i ;
    y*= i+1 ;
  }
  return x/y ;
}

 map<ll,ll> factor(ll n){  //素因数とオーダーをマップで管理
  map <ll,ll> ord ;  
  for(ll i=2;i*i<=n;i++){
        if(n%i==0){
            int res=0;
            while(n%i==0){
                n/=i;
                res++;
            }
            ord[i]=res;
        }
    }
   if(n!=1) ord[n]++;
   return ord ;
 }
 
mint dp[105][100000] ;

int main(){
  ll n,m ; cin>>n>>m ;
  vector<ll> A(n),B(m) ;
  rep(i,n) cin>>A[i] ;
  rep(i,m) cin>>B[i] ;
  vector<ll> C(n-1),D(m-1) ;
  rep(i,n-1) C[i]=A[i+1]-A[i] ;
  rep(i,m-1) D[i]=B[i+1]-B[i] ;
  mint tate=0 ;
  rep2(i,1,n-1){
    tate+= C[i-1]*i*(n-i) ;
  }
  
  mint yoko= 0 ;
  rep2(i,1,m-1){
    yoko+= D[i-1]*i*(m-i) ;
  }
  mint ans= tate* yoko ;
  cout<<ans<<endl ;
     return 0;
  }
   



Measured memory_bytes: 94540
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n, i, a, b, j;

    cin>>a>>b;

    if(a>b){
        i = a;
        j = a-1;
        n = i + j;
        cout<<n<<endl;
    }else if(b>a){
        i = b;
        j = b-1;
        n = i + j;
        cout<<n<<endl;
    }else if(a==b){
        i = a;
        j = b;
        n = i + j;
        cout<<n<<endl;
    }

    return 0;
}


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

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

const int INF = 1000000007;


bool solve(const vector<string>& W){
	const int n = W.size();

	for(int i=0;i<n-1;i++){
		if(W[i].back() != W[i+1].front()){
			return false;
		}
	}

	for(int i=0;i<n;i++){
		for(int j=i+1;j<n;j++){
			if(W[i] == W[j]) return false;
		}
	}

	return true;
}

int main(void){
	int n; cin>>n;
	vector<string> W(n);
	for(int i=0;i<n;i++) cin>>W[i];

	if(solve(W)) printf("Yes\n");
	else printf("No\n");
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using Edge = array<set<int>, 2>; //0:in, 1:out

set<int> search(vector<Edge>& g, int n_cur, set<int> res, set<int> blackList){
    res.insert(n_cur);

    for(auto eo : g[n_cur][1]){
        if(blackList.count(eo) > 0) continue;

        // Check in-edge of the next node
        auto blackList_new = blackList;
        for(auto ei : g[eo][0]){
            if(ei == n_cur) continue;
            if(res.count(ei)) return set<int>();
            blackList_new.insert(ei);
        }

        // Loop detected
        if(res.count(eo) > 0) return res;

        auto res_new = search(g, eo, res, blackList_new);
        if(res_new.size()>0) return res_new;
    }
    return set<int>();
}

set<int> RemoveBadNode(vector<Edge>& g){
    set<int> blacklist;
    queue<int> q;
    for(int i=0; i<g.size(); i++) q.push(i);
    while(!q.empty()){
        auto i = q.front(); q.pop();
        auto v = g[i];
        if(v[0].empty() || v[1].empty()){
            blacklist.insert(i);
            for(auto v1 : v[0]){ g[v1][1].erase(i); q.push(v1);}
            for(auto v1 : v[1]){ g[v1][0].erase(i); q.push(v1);}
        }
    }
    return blacklist;
}

int main()
{
    int N, M;
    cin >> N >> M;
    int Ai, Bi;
    vector<Edge> g(N, Edge());
    for(int i=0;i<M;i++){
        cin >> Ai >> Bi;
        Ai--; Bi--;
        g[Ai][1].insert(Bi); // out
        g[Bi][0].insert(Ai); // in
    }

    set<int> blacklist = RemoveBadNode(g);
    for(int i=0;i<N;i++){
        if(blacklist.count(i)) continue;
        auto res = search(g, i, set<int>(), blacklist);
        if(res.size()>0){
            cout<<res.size()<<endl;
            for(auto v : res) cout<<(v+1)<<endl;
            return 0;
        }
        blacklist.insert(i);
    }

    cout<<"-1"<<endl;
    return 0;
}


Measured memory_bytes: 29952
#include<stdio.h>

int main(){

	int in, sum, d;


	while(scanf("%d",&in) != EOF){
		sum = 0;
		d = in;

		while(1){
			sum += in * d * d;
			d += in;

			if(d == 600){
				break;
			}
		}
		printf("%d\n",sum);

	}

	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(int i = x; i <= n; i++)
#define rep3(i, x, n) for(int i = x; i >= n; i--)
#define elif else if
#define sp(x) fixed << setprecision(x)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const int inf = (1<<30)-1;
const ll INF = (1LL<<60)-1;
const ld EPS = 1e-10;
template<typename T> bool chmax(T &x, const T &y) {return (x < y)? (x = y, true) : false;};
template<typename T> bool chmin(T &x, const T &y) {return (x > y)? (x = y, true) : false;};

int main(){
    ll N;
    cin >> N;
    ll A[N], sum = 0;
    rep(i, N){
        cin >> A[i];
        sum += A[i];
    }
    ll S = N*(N+1)/2;
    if(sum%S != 0) {cout << "NO" << endl; return 0;}
    ll cnt = sum/S, num[N];
    rep(i, N){
        int j = (i+1)%N;
        ll d = A[i]-A[j];
        if(d+cnt < 0 || (d+cnt)%N != 0) {cout << "NO" << endl; return 0;}
        num[i] = (d+cnt)/N;
    }
    rep(i, N) cnt -= num[i];
    if(cnt == 0) cout << "YES" << endl;
    else cout << "NO" << endl;
}

Measured memory_bytes: 1792
import collections
_ = input()
a = [*map(int, input().split())]
q = int(input())
s = sum(a)
b = [[*map(int,input().split())] for _ in range(q)]
c = collections.Counter(a)
for i,j in b:
    if j not in c:
        c[j] = 0
    if i not in c:
        c[i] = 0
    s += (j-i)*c[i]
    c[j]+=c[i]
    c[i] = 0
    print(s)

Measured memory_bytes: 40236
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define MOD 1000000007;
#define MOD2 998244353;
#define INF ((1<<30)-1);
#define LINF (1LL<<60);
#define EPS (1e-10);
typedef long long Int;
typedef pair<Int, Int> P;

Int n, m;
Int a;

int main() {
    cin >> n >> m;
    Int sm = 0;
    rep(i,m) {
        cin >> a;
        sm += a; 
    }
    Int ans = n - sm;
    if (ans < 0) ans = -1;
    cout << ans << endl;
}

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

/*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; }
};
istream& operator>>(istream & is, const mint & a) { return is >> a.x; }
ostream& operator<<(ostream & os, const mint & a) { return os << a.x; }*/

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];

    int ans = 1000000000;
    rep(i, n) {
        int cnt = 0;
        while (a[i] % 2 == 0) {
            cnt++;
            a[i] /= 2;
        }
        ans = min(ans, cnt);
    }
    

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


Measured memory_bytes: 256
N,M = map(int,input().split())
pena = [0]*(N+1)
ac = [0]*(N+1)
for i in range(0,M,1):
    p,s = input().split()
    if s =="AC":
        ac[int(p)]=1
    elif s=="WA":
        if ac[int(p)] == 0:
            pena[int(p)]+=1
pen =0
for i in range(0,N+1,1):
    if ac[i]==1:
        pen += pena[i]

print(sum(ac),pen)

Measured memory_bytes: 47248
#! /usr/bin/env python3
# -*- coding:utf-8 -*-

def product_many(N):
    if 0 in N: return 0
    ans = 1
    for x in N:
        if (10 ** 18 / ans) < x: return -1
        ans *= x
        if ans > 10 ** 18: return -1
    return ans

def main():
    _ = input()
    N = list(map(int, input().split()))
    print(product_many(N))

if __name__ == "__main__":
    main()


Measured memory_bytes: 21768
N = int(input())

#val, i
max_1 = [0, 0]
max_2 = [0, 0]

for i in range(N):
	a_i = int(input())
	if a_i > max_2[0]:
		max_2[0] = a_i
		max_2[1] = i
	if max_1[0] < max_2[0]:
		tmp = max_1
		max_1 = max_2
		max_2 = tmp
	# print(max_1, max_2)
		
for i in range(N):
	if i == max_1[1]:
		print(max_2[0])
	else:
		print(max_1[0])

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

#define pb push_back

using namespace std;

const int N = 1e5 + 123;

int n, m;

int d1[N], d2[N], ans, used1[N], used2[N];

vector <int> g[N], q[N];

void dfs1 (int v, int p) {
    used1[v] = true;
    for (auto to : q[v]) {
        if (to == p)continue;
        if (used1[to]) {
            d2[v] = max (d2[v], d2[to] + 1);
        }else {
            dfs1 (to, v);
            d2[v] = max (d2[v], d2[to] + 1);
        }
    }
}

void dfs2 (int v, int p) {
    used2[v] = true;
    for (auto to : g[v]) {
        if (to == p)continue;
        if (used2[to]) {
            d1[v] = max (d1[v], d1[to] + 1);
            ans = max (ans, d2[v] + d1[to] + 1);
        }else {
            dfs2 (to, v);
            d1[v] = max (d1[v], d1[to] + 1);
            ans = max (ans, d2[v] + d1[to] + 1);
        }
    }ans = max (ans, d1[v] + d2[v]);
}

int main () {
    cin >> n >> m;
    for (int i = 1;i <= m;i ++) {
        int l, r;
        cin >> l >> r;
        g[l].pb (r);
        q[r].pb (l);
    }for (int i = 1;i <= n;i ++) {
        if (!used1[i])dfs1 (i, -1);
        if (!used2[i])dfs2 (i, -1);
    }
    cout << ans;
}


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

void scan(T...)(ref T args) {
    import std.stdio : readln;
    import std.algorithm : splitter;
    import std.conv : to;
    import std.range.primitives;

    auto line = readln().splitter();
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}

void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}

bool chmin(T, U...)(ref T x, U args) {
    bool isChanged;

    foreach (arg; args) {
        if (x > arg) {
            x = arg;
            isChanged = true;
        }
    }

    return isChanged;
}

bool chmax(T, U...)(ref T x, U args) {
    bool isChanged;

    foreach (arg; args) {
        if (x < arg) {
            x = arg;
            isChanged = true;
        }
    }

    return isChanged;
}



enum inf = 1_001_001_001;
enum infl = 1_001_001_001_001_001_001L;


void main() {
    string s;
    scan(s);
    auto n = s.length.to!int;

    int a;
    foreach (i ; 0 .. n) {
        if (s[i] == 'A') {
            a = i;
            break;
        }
    }
    int z = n;
    foreach_reverse (i ; 0 .. n) {
        if (s[i] == 'Z') {
            z = i;
            break;
        }
    }
    auto ans = z - a + 1;
    writeln(ans);
}


Measured memory_bytes: 2556
import math

n, k = map(int, input().split())
ans = 0

if n >= k:
    ans = n - k + 1
    for i in range(1, k):
        ans += (0.5)**(math.ceil(math.log2(k / i)))

if n < k:
    for i in range(1, n + 1):
        ans += (0.5)**(math.ceil(math.log2(k / i)))

print(ans / n)

Measured memory_bytes: 3060
<?php
 
$result = [];

while ($d = trim(fgets(STDIN))) {
    $s = explode(' ', $d);
    
    $l_year = $s[0];
    $r_year = $s[1];
    
    $leap_count = 0;
    
    if($s[0] == 0 && $s[1] == 0){
        break;
    }
    
    for($l_year; $l_year<=$r_year; $l_year++){
        $leap_flag = false;
        if($l_year % 4 == 0)$leap_flag=true;
        if($l_year % 100 == 0)$leap_flag=false;
        if($l_year % 400 == 0)$leap_flag=true;
        
        if($leap_flag){
            $leap_count++;
            array_push($result, $l_year."\n");
        }
    }

    if($leap_count == 0){
        array_push($result, 'NA'."\n");
    }  
    array_push($result, "\n");
}

print trim(implode("", $result));
?>

Measured memory_bytes: 15416
n = int(input())
s = [input() for _ in range(n)]

apl = list("abcdefghijklnmopqrstuvwxyz")
apl = sorted(apl)

dic = [[0 for _ in range(26)] for _ in range(n)]

for i in range(n):
    for j in range(len(s[i])):
        dic[i][apl.index(s[i][j])] += 1
result = [min([dic[i][j] for i in range(n)]) for j in range(26)]
r = ""
for i in range(26):
    r = r+apl[i]*result[i]
print(r)

Measured memory_bytes: 3064
S = input()
str_list = list(S)

for i in range(2 ** 3):
    num = int(str_list[0])
    ans = str_list[0]
    for j in range(3):
        if (i >> j) & 1:
            num += int(str_list[j + 1])
            ans += '+'
        else:
            num -= int(str_list[j + 1])
            ans += '-'
        ans += str_list[j + 1]
    if num == 7:
        ans += '=7'
        print(ans)
        break


Measured memory_bytes: 38384
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<(n); ++i)
#define REP(i, d, n) for(int i=(d); i<(n); ++i)
#define all(v) v.begin(), v.end()
using ll = long long;
int main() {
  
int n; cin>>n;
  string s; cin>>s;
  int ans=0;
  
  if(n%2!=0){ans=1;}
  else{
      rep(i,n/2){if(s.at(i)!=s.at(i+n/2)){ans=1;break;}} 
  }
  
  if(ans==0){cout<<"Yes"<<endl;}
  else{cout<<"No"<<endl;}
  
  
  
  
}

Measured memory_bytes: 3600