akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#include<boost/variant.hpp>
using namespace std;
typedef long long ll;
typedef vector<boost::variant<bool, ll, int, string, double>> any;
template<typename T> inline void pr(const vector<T> &xs){
	for(int i=0; i<xs.size()-1; i++) cout<<xs[i]<<" ";
	(xs.empty()?cout:(cout<<xs[xs.size()-1]))<<endl;
}
template<typename T> inline void debug(const vector<T> &xs){
#ifdef DEBUG
	pr(xs);
#endif
}

int main(){
	int N;
	cin >> N;
	vector<vector<int>> A(N, vector<int>(N-1));
	for(int i=0; i<N; i++){
		for(int j=0; j<N-1; j++){
			cin >> A[i][j];
		}
	}

	int n = 0;
	vector<int> idx(N, 0);
	vector<int> changed;
	for(int i=0; i<N; i++) changed.push_back(i);
	while(true){
		set<int> done;
		vector<int> next;
		bool update = false;
		for(int i: changed){
			if(done.count(i) > 0 || idx[i]==N-1) continue;
			int k = A[i][idx[i]]-1;
			if(done.count(k) > 0 || idx[k]==N-1) continue;
			if(A[k][idx[k]] == i+1){
				next.push_back(i);
				next.push_back(k);
				idx[i]++;
				idx[k]++;
				done.insert(i);
				done.insert(k);
				update = true;
				debug(any{n, i+1, k+1});
			}
		}
		changed = next;
		if(!update) break;
		n++;
	}

	bool ok = true;
	for(int i=0; i<N; i++){
		if(idx[i] != N-1) ok = false;
	}
	if(ok) cout << n << endl;
	else cout << -1 << endl;

	return 0;
}


Measured memory_bytes: 4224
#include<iostream>
#include<vector>
using namespace std;
int main(){
	int n;
	cin>>n;
	vector<pair<int,int>>a(n);
	for(int i=0;i<n;i++){
		cin>>a[i].first;
	}
	for(int i=0;i<n;i++){
		cin>>a[i].second;
	}
	vector<int>b(n);
	vector<int>c(n);
	b[0]=a[0].first;
	c[0]=a[0].second;
	int cc=a[0].second;
	for(int i=1;i<n;i++){
		b[i]=b[i-1]+a[i].first;
		c[i]=c[i-1]+a[i].second;
		cc+=a[i].second;
	}
	int memo;
	int max=0;
	for(int i=0;i<n;i++){
		if(i==0){
			memo=a[i].first+cc;
		}
		else{
			memo=b[i]+cc-c[i-1];
		}
		if(memo>max){
			max=memo;
		}
	}
	cout<<max<<endl;
	return 0;
}

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

int n, w;
int a[111], b[111];
int memo[111][11111];

int solve(int i, int p){

  if(p < 0) return -(1<<28);
  if(i == n) return 0;
  if(memo[i][p]) return memo[i][p];
  
  int ans = 0;
  return memo[i][p] = ans += max(solve(i+1, p), solve(i+1, p-b[i])+a[i]);

}

int main(){

  cin >> n >> w;
  for(int i=0;i<n;i++) cin >> a[i] >> b[i];

  cout << solve(0, w) << endl;

}

Measured memory_bytes: 5276
import math
n, d = map(int, input().split())
x = [list(map(int, input().split())) for i in range(n)]
cnt = 0

def distance(list1, list2) :
    dist = 0
    for i in range(len(list1)) :
        dist += (list1[i] - list2[i]) ** 2
    return math.sqrt(dist)

for i in range(n) :
    for j in range(i+1,n) :
        if i != j :
            if int(distance(x[i], x[j])) == distance(x[i], x[j]) :
                cnt += 1
print(cnt)


Measured memory_bytes: 9204
#include <algorithm>
#include <cstring>
#include <iostream>
#include <limits.h>
#include <map>
#include <queue>
#include <vector>
using namespace std;
typedef long long ll;
const int inf = 1 << 30;
const int INF = INT_MAX;

int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n, sum = 0, m = 0;
  cin >> n;
  for(int i = 0; i < n; ++i) {
    int p;
    cin >> p;
    m = max(m, p);
    sum += p;
  }
  cout << (sum - (m / 2)) << endl;
  return 0;
}


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

#define pb(n) push_back(n)
#define fi first
#define se second
#define all(r) begin(r),end(r)
#define vmax(ary) *max_element(all(ary))
#define vmin(ary) *min_element(all(ary))
#define debug(x) cout<<#x<<": "<<x<<endl
#define fcout(n) cout<<fixed<<setprecision((n))
#define scout(n) cout<<setw(n)
#define vary(type,name,size,init) vector< type> name(size,init)
#define vvl(v,w,h,init) vector<vector<ll>> v(w,vector<ll>(h,init))
#define mp(a,b) make_pair(a,b)

#define rep(i,n) for(int i = 0; i < (int)(n);++i)
#define REP(i,a,b) for(int i = (a);i < (int)(b);++i)
#define repi(it,array) for(auto it = array.begin(),end = array.end(); it != end;++it)
#define repa(n,array) for(auto &n :(array))

using ll = long long;
using pii = pair<int,int> ;
using pll = pair<ll,ll> ;

template<typename T>
void O(T t){
  cout << t << endl;
}

const int mod = 1000000007;
constexpr ll inf = ((1<<30)-1)*2+1 ;
constexpr double PI = acos(-1.0) ;
double eps = 1e-10 ;
const int dy[] = {-1,0,1,0,1,-1,1,-1};
const int dx[] = {0,-1,0,1,1,-1,-1,1};

inline bool value(int x,int y,int w,int h){
  return (x >= 0 && x < w && y >= 0 && y < h);
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll a,b,c,d;
  cin >> a >> b >> c >> d;
  cout << max(a*b,c*d) << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define mk make_pair
#define fs first
#define sc second
using namespace std;
typedef long long ll;
typedef long double ld;
// please, read the question correctly (do you need set or multiset)???
const int N=200010; //check the limits, dummy
ll a[N];
int main(){
	int t;
	// while(){
	int n;
		scanf("%d",&n);
		for(int i=0; i<n; ++i){
			scanf("%lld",a+i);
		}
		ll mon=1000, nm=0;
		for(int i=0; i+1<n; ++i){
			if(a[i+1]>a[i]){
				mon=mon%a[i]+a[i+1]*(mon/a[i]);
			}
		}
		// memset(mem, -1, sizeof mem);
		// int ans=dp(0, 1000, 0);
		cout<<mon<<endl;
	// }
}

Measured memory_bytes: 3764
N = int(input())
li = list(map(int, input().split()))

max = 0
a = [0] * N

for n in range(N):
  if n == len(li):
    a[n] = li[n-1]
    break
  
  if n == 0:
    a[n] = li[n]
  else:
    if li[n] > li[n-1]:
      a[n] = li[n-1]
    else:
      a[n] = li[n]

print(sum(a))

Measured memory_bytes: 3064
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
using System.Numerics;

namespace AtCoder
{
    class Program
    {
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }
        static public (T1 a, T2 b) Slice<T1, T2>()
        {
            var t = ReadLine().Split();
            return (
            (T1)Convert.ChangeType(t[0], typeof(T1)),
            (T2)Convert.ChangeType(t[1], typeof(T2)));
        }
        static long Mod = (long)1e9 + 7;
        static void Main(string[] args)
        {
            SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
            Solve();
            Out.Flush();
            Read();
        }
        static void Solve()
        {
            var N = Sarray()[0];
            var K = Sarray()[0];
            var X = Sarray()[0];
            var Y = Sarray()[0];
            var ans = Min(N, K) * X;
            ans += Max(0, N - K) * Y;
            WriteLine(ans);
        }
    }
}

Measured memory_bytes: 28156
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (n); ++i)
template <class T>
inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return true;
    }
    return false;
}
template <class T>inline bool chmax(T &a, T b){if (a < b){a = b;return true;}return false;}
using namespace std;
using ll = long long;
using P = pair<int, int>;
using Pl = pair<long long, long long>;
using veci = vector<int>;
using vecl = vector<long long>;
using vecveci = vector<vector<int>>;
using vecvecl = vector<vector<long long>>;

int main() {
    ll A,B,V,W,T;
    cin >> A >> V >> B >> W >> T;
    if(A < B) {
    if(W >= V) cout << "NO" << endl;
    else {
        ll dist = B-A;
        if(A+V*T >= B+W*T) cout << "YES" << endl;
        else cout << "NO" << endl;
    }

    } else {
            if(W >= V) cout << "NO" << endl;
            else {
                if(A-V*T <= B-W*T) cout << "YES" << endl;
                else cout << "NO" << endl;
            }

    }
}

Measured memory_bytes: 3632
#pragma region header
#include <bits/stdc++.h>
using namespace std;

#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_CAT_I(x,y) x ## y
//#define CPP_STR(x) CPP_STR_I(x)
//#define CPP_STR_I(args...) #args
//#define ASSERT(expr...) assert((expr))

using i8 = int8_t;
using u8 = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;
using f32 = float;
using f64 = double;
//using f80 = __float80;

constexpr i64 INF = 1'010'000'000'000'000'017LL;
constexpr i64 MOD = 1'000'000'007LL;
constexpr f64 EPS = 1e-12;
constexpr f64 PI = 3.14159265358979323846;
constexpr char EL[] = "\n";

#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());

template<typename T = i64>
T IN() { T x; cin >> x; return (x); }

template<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }
template<typename T, size_t N>
i64 SIZE(const T(&)[N]) { return static_cast<i64>(N); }

template<typename T, typename U, typename Comp = less<>>
bool chmax(T& xmax, const U& x, Comp comp = {}) {
	if (comp(xmax, x)) {
		xmax = x;
		return true;
	}
	return false;
}
template<typename T, typename U, typename Comp = less<>>
bool chmin(T& xmin, const U& x, Comp comp = {}) {
	if (comp(x, xmin)) {
		xmin = x;
		return true;
	}
	return false;
}

void print() {
	cout << EL;
}
template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
	cout << head;
	if (sizeof...(tail) != 0) cout << " ";
	print(forward<Tail>(tail)...);
}
template <class T>
void print(vector<T> &vec) {
	for (auto& a : vec) {
		cout << a;
		if (&a != &vec.back()) cout << " ";
	}
	cout << EL;
}
template <class T>
void print(vector<vector<T>> &df) {
	for (auto& vec : df) {
		print(vec);
	}
}

struct ProconInit {
	static constexpr int IOS_PREC = 15;
	static constexpr bool AUTOFLUSH = false;

	ProconInit() {
		cin.tie(nullptr);
		ios::sync_with_stdio(false);
		cout << fixed << setprecision(IOS_PREC);
		if (AUTOFLUSH)
			cout << unitbuf;
	}
} PROCON_INIT;
#pragma endregion

#ifdef LOCALCODE
signed solve()
#else
signed main()
#endif
{
	auto A = IN();
	auto B = IN();
	auto X = IN();
	print((A<=X && X<=A+B ? "YES" : "NO"));
	return 0;
}


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

using namespace std;

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	
	int a, b, c, x, y, ans = 0;
	
	cin >> a >> b >> c >> x >> y;
	
	while (x && y && a + b > c + c)
	{
		x--, y--;
		ans += c + c;
	}//if
	
	while (x > 0 && a > c + c)
	{
		x--, y--;
		ans += c + c;
	}//while
	
	while (x > 0)
	{
		x--;
		ans += a;
	}//while
	
	while (y > 0 && b > c + c)
	{
		x--, y--;
		ans += c + c;
	}//while
	
	while (y > 0)
	{
		y--;
		ans += b;
	}//while
	
	cout << ans;
	
	return 0;
}//main


Measured memory_bytes: 256
package main
 
import "fmt"
 
func CheckString(s string) (string) {
	if s[2] == s[3] && s[4] == s[5] {
		return "Yes"
	} else {
		return "No"
	}

}
 
func main()  {
	var s string
	fmt.Scan(&s)
	fmt.Println(CheckString(s))
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#include <vector>
#include <numeric>
#define PI 3.14159265358979323846
#define MAXINF 1e18L
#define INF 1e9L
#define EPS 1e-9
#define REP(i, n) for(int i=0;i<int(n);++i)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define ALL(v) v.begin(),v.end()
#define FIND(v,x) (binary_search(ALL(v),(x)))
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v));reverse(ALL(v))
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define pb push_back
using namespace std;
template<class A>void pr(A a){cout << (a) << endl;}
template<class A,class B>void pr(A a,B b){cout << a << " "  ;pr(b);}
template<class A,class B,class C>void pr(A a,B b,C c){cout << a << " " ;pr(b,c);}
template<class A,class B,class C,class D>void pr(A a,B b,C c,D d){cout << a << " " ;pr(b,c,d);}
typedef long long ll;
typedef pair<int, int> pii;

int main(void)
{
    REP(i, 3){
        REP(j, 3){
            char c;
            cin >> c;
            if(i==j) cout << c;
        }
    }
    cout << endl;
}

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

#define int long long
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define all(v) (v).begin(),(v).end()
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
#define pb push_back
#define fi first
#define se second
template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

int N,M,S,T;
vector<int>G[100000];

vint bfs(int s){
    vint dist(N,1001001001);
    dist[s]=0;
    queue<int>que;
    que.push(s);
    while(que.size()){
        int v=que.front();
        que.pop();
        for(auto u:G[v]){
            if(dist[u]!=1001001001)continue;
            dist[u]=dist[v]+1;
            que.push(u);
        }
    }
    return dist;
}

signed main(){
    cin>>N>>M>>S>>T;
    S--;T--;
    rep(i,M){
        int a,b;
        cin>>a>>b;
        a--;b--;
        G[a].pb(b);G[b].pb(a);
    }

    vint distS=bfs(S);
    vint distT=bfs(T);

    int D=distS[T]-1;

    vint cntS(N),cntT(N);
    rep(i,N){
        if(distS[i]<N)cntS[distS[i]]++;
        if(distT[i]<N)cntT[distT[i]]++;
    }

    int ans=0;
    for(int i=0;i<D;i++){
        ans+=cntS[i]*cntT[D-i-1];
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 13564
#include <iostream>
#include <vector>
using namespace std;
using int64 = long long;

constexpr int64 kMod = 1000000007;

int main() {
  int64 n, k;
  cin >> n >> k;
  vector<int64> a(n);
  for (int64 i = 0; i < n; ++i) {
    cin >> a[i];
  }

  int64 inner = 0;
  int64 beyond = 0;
  for (int64 i = 0; i < n; ++i) {
    for (int64 j = i + 1; j < n; ++j) {
      if (a[i] > a[j])
        ++inner;
      else if (a[i] < a[j])
        ++beyond;
    }
  }

  int64 ret = inner * k % kMod;
  ret += (inner + beyond) % kMod * (k * (k - 1) / 2 % kMod);
  ret %= kMod;
  cout << ret << "\n"; 

  return 0;
}


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

int main(){
    int N, Q;
    string S;
    cin >> N >> S;

    set<int> alpha[26];
    for (int i = 0; i < 26;i++)
        alpha[i].insert(N + 1);
    for (int i = 0; i < N;i++)
        alpha[S[i] - 'a'].insert(i);

    cin >> Q;
    while(Q > 0){
        Q--;
        int q;
        cin >> q;
        if(q-1){
            int l, r;
            cin >> l >> r;
            int ans = 0;
            l--, r--;
            for (int i = 0; i < 26;i++){
                if (*alpha[i].lower_bound(l) <= r)
                    ans++;
            }
            cout << ans << endl;
        }else{
            int t;
            char c;
            cin >> t >> c;
            t--;
            if(S[t] != c){
                alpha[S[t] - 'a'].erase(t);
                S[t] = c;
                alpha[c - 'a'].insert(t);
            }
            
        }
    }
    return 0;
}

Measured memory_bytes: 24196
#include<iostream>

using namespace std;

int main() {
	int n;
	cin >> n;
	int a;
	int m = 0;
	for (int i = 0; i < n; i++) {
		cin >> a;
		while (a % 2 == 0) {
			a = a / 2;
			m++;
		}
	}
	cout << m;
	return 0;
}

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

#define REP(i, x, n) for (int i = x; i < (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x.size())
#define popcount(x) __builtin_popcount(x)
#define popcountll(x) __builtin_popcountll(x)
#define uniq(x) x.erase(unique(x.begin(), x.end()), x.end())
#define F first
#define S second
#define mp make_pair
#define eb emplace_back
#define pii pair<int, int>
#define pll pair<ll, ll>

using namespace std;

typedef long long ll;

/* --- INFやMODの値が適切か確認する --- */
// const int INF = 1 << 30;
// const ll INF = 1LL << 60;
// const ll MOD = 1000000007;

int main() {
  int sx, sy, tx, ty;
  cin >> sx >> sy >> tx >> ty;

  string ans = "";
  rep(i, (tx - sx)) ans += "R";
  rep(i, (ty - sy)) ans += "U";
  rep(i, (tx - sx)) ans += "L";
  rep(i, (ty - sy)) ans += "D";

  ans += "D";
  rep(i, (tx - sx)) ans += "R";
  ans += "R";
  ans += "U";
  rep(i, (ty - sy)) ans += "U";
  ans += "L";
  ans += "U";
  rep(i, (tx - sx)) ans += "L";
  ans += "L";
  ans += "D";
  rep(i, (ty - sy)) ans += "D";
  ans += "R";

  cout << ans << endl;
}


Measured memory_bytes: 256
n = gets.to_i
as = gets.strip.split.map(&:to_i)
bs = gets.strip.split.map(&:to_i)

monsters = 0

(n - 1).downto(0) do |i|
    b = bs[i]
    a_1 = as[i + 1]
    a_0 = as[i]

    if a_1 < b
        b -= a_1
        monsters += a_1
        as[i + 1] = 0
    else
        as[i + 1] -= b
        monsters += b
        b = 0
    end

    if b > 0
        if a_0 < b
            b -= a_0
            monsters += a_0
            as[i] = 0
        else
            as[i] -= b
            monsters += b
            b = 0
        end
    end
end

puts monsters

Measured memory_bytes: 17556
from collections import Counter

N = int(input())
A = list(map(int, input().split()))
Q = int(input())
B = []
C = []
for _ in range(Q):
    b, c = map(int, input().split())
    B.append(b)
    C.append(c)

counter = Counter(A)
ans = 0
for num, count in counter.items():
    ans += num * count

for i in range(Q):
    if B[i] in counter:
        ans += counter[B[i]] * C[i] - counter[B[i]] * B[i]
        counter[C[i]] = counter[C[i]] + counter.pop(B[i])
    print(ans)


Measured memory_bytes: 27344
#include <bits/stdc++.h>
using namespace std;
int main() {
  string str;
  int q;
  cin >> str;
  cin >> q;
  for (int i = 0; i < q; i++) {
    string s;
    cin >> s;
    if (s == "print") {
      int a, b;
      cin >> a >> b;
      cout << str.substr(a, b - a + 1) << endl;
    } else if (s == "reverse") {
      int a, b;
      cin >> a >> b;
      reverse(str.begin() + a, str.begin() + b + 1);
    } else if (s == "replace") {
      int a, b;
      string p;
      cin >> a >> b >> p;
      str.replace(a, b - a + 1, p);
    }
  }
}


Measured memory_bytes: 3152
n = int(input())
my_dict = dict()
for i in range(n):
    s = ''.join(sorted(input()))
    if s in my_dict:
        my_dict[s] += 1
    else:
        my_dict[s] = 1

ret = 0

for item in my_dict:
    ret += my_dict[item] * (my_dict[item] - 1) // 2

print(ret)


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

 const int INF = 1e9+7;

int main() {
	string str;
	cin >> str;
	string l = "";
	l += str.at(0);
	l += str.at(1);
	string r = "";
	r += str.at(2);
	r += str.at(3);
	int ll = stoi(l);
	int rr = stoi(r);
	if(ll > 12 || ll == 0){
		if(rr >12 || rr == 0){
			cout << "NA" << endl;
		}else{
			cout << "YYMM" << endl;
		}
	}else{
		if(rr>12 || rr==0){
			cout << "MMYY" << endl;
		}else{
			cout << "AMBIGUOUS" << endl;
		}
	}
}

Measured memory_bytes: 256
line = gets.strip.split(nil).map(&:to_i)
A = line[0]
B = line[1]
H = line[2]
M = line[3]
pi = Math::PI

#余弦定理の一択
w = pi*((30*H.to_f)-(5.5*M.to_f))/180.to_f
x = Math.sqrt((A**2)+(B**2)-2*A*B*Math.cos(w))
puts x

Measured memory_bytes: 14636
#include <bits/stdc++.h>
using namespace std;
int main()
{
  long long n;
  long long m;
  cin>>n>>m;
  long long arr[m];
  long long sum=0;
  for(long long i=0;i<m;i++)
  {
    cin>>arr[i];
  	sum+=arr[i];
  }
  if(n-sum<0)
    cout<<"-1"<<endl;
  else
  cout<<n-sum<<endl;
}


Measured memory_bytes: 3664
def gcd(a,b):
    while b!=0:
        a,b=b,a%b
    return a
N,X=map(int,input().split())
x=list(map(int,input().split()))
kari=[]
for i in range(N):
    kari.append(abs(x[i]-X))
ans=gcd(min(kari),max(kari))
for i in range(N):
    ans=gcd(ans,kari[i])
print(ans)

Measured memory_bytes: 14252
#include<bits/stdc++.h>
#define mod 1000000007
#define ll long long
using namespace std;

const int N=1e5+5;

ll a[N],vis[N],fac[N],inv[N];

ll ksm(ll x,ll y){
	ll res=1;
	while(y){
		if(y&1) res=res*x%mod;
		x=x*x%mod,y>>=1;
	}
	return res;
}

ll C(ll n,ll m){
	if(n<m) return 0;
	else return fac[n]*inv[m]%mod*inv[n-m]%mod;
}

int main(){
	ll n,len;
	scanf("%lld",&n);
	fac[0]=inv[0]=1;
	for(int i=1;i<=n+1;i++) fac[i]=fac[i-1]*i%mod;
	inv[n+1]=ksm(fac[n+1],mod-2);
	for(int i=n;i>=1;i--) inv[i]=inv[i+1]*(i+1)%mod;
	for(int i=1;i<=n+1;i++){
		scanf("%lld",&a[i]);
		if(vis[a[i]]) len=i-vis[a[i]];
		vis[a[i]]=i;
	}
	for(int i=1;i<=n+1;i++) printf("%lld\n",(C(n+1,i)-C(n-len,i-1)+mod)%mod);
	return 0;
}

Measured memory_bytes: 4352
/**
 *    author:  otera    
**/
#include<iostream>
#include<string>
#include<cstdio>
#include<cstring>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<deque>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;

//#define int long long
typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef long double ld;
const int inf=1e9+7;
const ll INF=1LL<<60 ;
const ll mod=1e9+7 ;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<int, int> P;
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
#define debug(x)  cerr << #x << " = " << (x) << endl;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int n, m;
vector<vector<int>> a;

void solve() {
	cin >> n >> m;
    a.assign(n, vector<int>(m));
    rep(i, n) {
        rep(j, m) {
            cin >> a[i][j];
            -- a[i][j];
        }
    }
    vector<int> used(n, 0), check(m, 1);
    int ans = n;
    int cnt = 0;
    while(true) {
        map<int, int> mp;
        rep(i, n) {
            while(used[i] < m && !check[a[i][used[i]]]) {
                used[i] ++;
            }
            mp[a[i][used[i]]] ++;
        }
        set<int> se; int ma = 0;
        for(auto p: mp) {
            if(ma == p.sc) {
                se.insert(p.fr);
            } else if(ma < p.sc) {
                se.clear();
                ma = p.sc;
                se.insert(p.fr);
            }
        }
        chmin(ans, ma);
        for(auto j: se) {
            check[j] = 0;
            ++ cnt;
        }
        if(cnt == m) break;
    }
    cout << ans << endl;
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(10);
	//int t; cin >> t; rep(i, t)solve();
	solve();
    return 0;
}

Measured memory_bytes: 640
import scala.io.StdIn.readLine //??????????????????import???????????¨readLine()?????????????????????
 object Main {	
 	def main(args: Array[String]){
 	val input=readLine()
 	val strarray=input.split(' ')
 	val numarray=strarray.map(_.toInt)//???????????§??\????????????
 	val a=numarray(0)
 	val b=numarray(1)
 	//????¨?????????§??????????????????????????????
 	//val Array(a,b)=readLine().split(' ').map(_.toInt)
 	//??¨??????????????????
 	val area=a*b
 	val length=2*(a+b)
 	val ans= area+" "+length
 	println(ans)
 	}
 }

Measured memory_bytes: 43620
def main():
    word = input()
    index = [word.find("C"), 0]
    if index[0] >= 0:
        index[1] = word.find("F", index[0])
    print("Yes" if index[0] >= 0 and index[1] >= 0 else "No")


if __name__ == '__main__':
    main()



Measured memory_bytes: 2940
#include <bits/stdc++.h>
    using namespace std;
    typedef long long int ll;
     typedef pair<int,int> ii;
     typedef vector<ii> vii;
     typedef vector <int > vi;
    //vector <vi> adj(MAX); 
    priority_queue<ll> v1,v2,v3,v4,v5,v6;
    //multimap<ll,ll> m1,m2;
    int knapSack(int W, int wt[], int val[], int n)
    {
       int i, w;
       int K[n+1][W+1];
     
       // Build table K[][] in bottom up manner
       for (i = 0; i <= n; i++)
       {
           for (w = 0; w <= W; w++)
           {
               if (i==0 || w==0)
                   K[i][w] = 0;
               else if (wt[i-1] <= w)
                     K[i][w] = max(val[i-1] + K[i-1][w-wt[i-1]],  K[i-1][w]);
               else
                     K[i][w] = K[i-1][w];
           }
       }
     
       return K[n][W];
    }
    int main()
    {
     //freopen("input.txt","r",stdin);
     //freopen("output.txt","w",stdout);
     ios::sync_with_stdio(false);
     cin.tie(0);
     ll a,b,c;
     cin>>a>>b>>c;
     if(c>=a && c<=b)
      cout<<"Yes"<<endl;
    else
      cout<<"No"<<endl;
    return 0;
    }

Measured memory_bytes: 256
import java.util.Scanner;

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

        int A = sc.nextInt();
        int B = sc.nextInt();
        int C = sc.nextInt();
        int X = sc.nextInt();

        System.out.println(solve(A, B, C, X));

        sc.close();
    }

    static int solve(int A, int B, int C, int X) {
        int result = 0;
        for (int i = 0; i <= A; ++i) {
            for (int j = 0; j <= B; ++j) {
                for (int k = 0; k <= C; ++k) {
                    if (i * 500 + j * 100 + k * 50 == X) {
                        ++result;
                    }
                }
            }
        }

        return result;
    }
}

Measured memory_bytes: 22608
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int64_t i=0; i<=n; i++)
#define rep1(i, n) for(int64_t i=1; i<=n; i++)
typedef int64_t lint;

const lint mod = 998244353;
struct mint {
	lint x;
	mint(lint 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(lint 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, 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];
	}
};

int main() {
	lint N, M, K;
	cin >> N >> M >> K;
	mint a=M, b=0, c=0, x, y, z;
	vector<mint> v(200002);
	rep1(i, N) {
		v.at(i) = a;
		a *= M-1;
	}
	combination C(200002);
	rep(i, K) {
		b = C(N-1, i);
		c += v.at(N-i) * b;
	}
	cout << c << '\n';
}


Measured memory_bytes: 7988
#require 'prime'
#require 'openssl'
MOD=10**9+7;  cnt=0; sum=0; prev=nil; can=true; h=Hash.new(0)
def gs() gets.chomp end
def gi() gets.chomp.to_i end
def gsmi() gets.chomp.split.map(&:to_i) end

def ar2(s1,s2,de=nil) Array.new(s1){Array.new(s2,de)} end
def ar3(s1,s2,s3,de=nil) Array.new(s1){Array.new(s2){Array.new(s3,de)}} end

def desc(ar) ar.sort!{|x,y| y<=>x} end
def min(a,b) a<=b ? a : b end
def max(a,b) a>=b ? a : b end
def sum(ar) ar.inject(:+).to_i end
def ceil(a,b) (a.to_f/b).ceil end

def C(a,b) b==0||a==b ? 1 : (b=a-b if a/2<b;(a-b+1..a).inject(:*)/(1..b).inject(:*)) end
def rui(ar) s=[0]; ar.size.times{|i| s<<s[-1]+ar[i]}; s end
def rev_rui(ar) s=[0]; ar.size.times.reverse_each{|i| s<<s[-1]+ar[i]}; s end

def puts_yesno(b) puts(b ? 'Yes' : 'No') end
def putsend(s) puts s; exit end
def pu(h) begin; require './../nemi_lib/debug.rb'; puts_val(h); rescue LoadError; end; end
########### ( ˘ω˘ )ｽﾔｧ… ###########
a,b,c,k=gsmi

sum = [a, k].min
k = k - a
k = k - b

if k > 0
  sum = sum + (-1) * k
end

puts sum

Measured memory_bytes: 14244
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define len(v) ll(v.size())
#define fi first
#define se second

template <class T>
void cout_vec(const vector<T> &vec){
  for(auto itr:vec) cout<<itr<<' ';
  cout<<endl;
}

typedef pair<ll,ll> P;
const ll mod=1e9+7;
const ll inf=1e15;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin>>n;
  vector<ll> a(n);
  ll cnt1=0,cnt2=0,sum1=0,sum2=0;
  rep(i,n){
    cin>>a[i];
    sum1+=a[i],sum2+=a[i];
    if(i%2){
      if(sum1<=0){
        cnt1+=1-sum1;
        sum1=1;
      }
      if(sum2>=0){
        cnt2+=abs(sum2+1);
        sum2=-1;
      }
    }else{
      if(sum2<=0){
        cnt2+=1-sum2;
        sum2=1;
      }
      if(sum1>=0){
        cnt1+=abs(sum1+1);
        sum1=-1;
      }
    }
  }
  cout<<min(cnt1,cnt2)<<endl;
}

Measured memory_bytes: 1024
from statistics import mean, median,variance,stdev
import numpy as np
import sys
import math
import fractions
import itertools
import copy

def j(q):
    if q==1: print("YES")
    else:print("NO")
    exit(0)


def ct(x,y):
    if (x>y):print("GREATER")
    elif (x<y): print("LESS")
    else: print("EQUAL")

def ip():
    return int(input())


#n = ip()                              #入力整数1つ
#n,m= (int(i) for i in input().split())      #入力整数横2つ
a,b,c = (int(i) for i in input().split())    #入力整数横3つ
#n,a,b,c= (int(i) for i in input().split())  #入力整数横4つ
#a = [int(i) for i in input().split()]        #入力整数配列
#a = input()                                  #入力文字列
#a = input().split()                          #入力文字配列
#n = ip()                      #入力セット(整数改行あり)(1/2)
#a=[ip() for i in range(n)]    #入力セット(整数改行あり)(2/2)
#a=[input() for i in range(h)]
#jの変数はしようできないので注意
#全足しにsum変数使用はsum関数使用できないので注意

print(min(c,b//a))

Measured memory_bytes: 22776
#include <algorithm>
#include <string>
#include <math.h>
#include <vector>
#include <iostream>
using namespace std;

int main() 
{
    int N;
    cin >> N;
    
    vector<int> B(N-1);
    for (int i = 0; i < N-1; i++) {
        cin >> B.at(i);
    }
    vector<int> A(N);
    A.at(0) = B.at(0);
    for (int i = 1; i <= N-2; i++) {
        A.at(i) = min(B.at(i), B.at(i-1));
    }
    A.at(N-1) = B.at(N-2);
    int ans = 0;
    for (int i = 0; i < N; i++) {
        ans += A.at(i);
    }
    cout << ans << endl;
}

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

int n,k,ans,p=0,m=0;

signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    
    string s;
    cin>>n>>k>>s;
    while(p<n){
        while(p<n&&s[p]=='1'){p++;}
        ans = max(ans,p-m);
        while(p<n&&s[p]=='0'){p++;}
        k--;
        if(k<0){
            while(m<n&&s[m]=='1'){m++;}
            while(m<n&&s[m]=='0'){m++;}
        }
        ans= max(ans,p-m);
    }
    cout<<ans<<endl;
}

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

int main() {
    int L;
    cin >> L;
    double side = L/3.0;
    printf("%.10lf", side*side*side);
    return 0;
}

Measured memory_bytes: 256
K,N=map(int,input().split())

A=list(map(int,input().split()))
d=[]

for i in range(N-1):
  d.append(A[i+1]-A[i])
d.append(K-A[N-1]+A[0])
d.pop(d.index(max(d)))
print(sum(d))

Measured memory_bytes: 26436
def gi() gets.to_i end
def gs() gets.chomp end
def gim() gets.split.map(&:to_i) end
def gsm() gets.split.map(&:chomp) end
def YesNo1(bool, yes="Yes", no="No") puts (bool ? yes : no) end
def YESNO2(bool, yes="YES", no="NO") puts (bool ? yes : no) end
def sqrt(i) i ** (1.0/2) end

require "bigdecimal"
#####

n,m = gim

ns = [0] * n
ms = [0] * m
print ns.combination(2).count + ms.combination(2).count

Measured memory_bytes: 1916
import java.util.Scanner;
import java.util.ArrayList;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner scan = new Scanner(System.in);
        int A = scan.nextInt();
        int B = scan.nextInt();
        int C = scan.nextInt();
        
        if(A == 1) {
            System.out.println("YES");
            return;
        }
        
        ArrayList<Integer> surplusList = new ArrayList<Integer>();
        int surplus;
        int multiple = 1;
        boolean hasNotDoubled = true;
        
        while(hasNotDoubled) {
            surplus = A * multiple % B;
            if(surplusList.contains(surplus)) {
                hasNotDoubled = false;
            } else {
                surplusList.add(surplus);
            }
            multiple++;
        }
        
        for(int s : surplusList) {
            if(s == C) {
                System.out.println("YES");
                return;
            }
        }
        System.out.println("NO");
    }
}


Measured memory_bytes: 21972
#include <iostream>
#include <vector>
#include <algorithm>

int main()
{
    int n, k;
    std::cin >> n >> k;

    std::vector<int> hs;
    for (int i = 0; i < n; i++)
    {
        int h;
        std::cin >> h;
        hs.push_back(h);
    }

    std::sort(hs.begin(), hs.end());

    int min = hs.at(k-1) - hs.at(0);
    for (int i = 1; i < n-k+1; i++)
    {
        min = std::min(min, hs.at(i+k-1) - hs.at(i));
    }

    std::cout << min << std::endl;


    return 0;
}

Measured memory_bytes: 892
import sys
import collections
import math
from collections import Counter
from collections import deque

N, M = [int(x) for x in input().split()]

D = 10 ** 9 + 7

if abs(N - M) >= 2:
    print(0)
    sys.exit(0)

ret = math.factorial(N) * math.factorial(M)

if N == M:
    ret *= 2


print(ret % D)


Measured memory_bytes: 5520
#include <bits/stdc++.h>
#define FOR(i,x,y) for(int i = x;i < y;i++)
using namespace std;
int main(){
  string S;
  cin >> S;
  bool a = 1;
  FOR(i,0,S.size())FOR(j,0,S.size())if(i != j && S[i] == S[j])a = 0;
  a ? cout << "yes" << endl : cout << "no" << endl;
}


Measured memory_bytes: 256
n,m=gets.split.map &:to_i
pinfo=$<.each_with_index.map{|l,i|
  pt,st=l.split
  [pt.to_i,i,st=="AC"]
}
ac=pe=0
pinfo.sort_by{|r| r[0]*m+r[1] }.chunk(&:first).each{|k,r|
  t=r.map(&:last)
  next unless t.any?
  ac+=1
  pe+=t.index(true)||t.size
}
puts "#{ac} #{pe}"

Measured memory_bytes: 12664
program main
  implicit none
  integer :: n, m, i
  integer, allocatable :: a(:), dp(:)
  logical, allocatable :: broken(:)
  read (*, *) n, m
  allocate (a(m), dp(-1:n), broken(n))
  do i = 1, m
    read (*, *) a(i)
  end do
  broken(:) = .false.
  do i = 1, m
    broken(a(i)) = .true.
  end do
  dp(-1) = 0
  dp(0) = 1
  do i = 1, n
    dp(i) = dp(i - 1) + dp(i - 2)
    if (broken(i)) dp(i) = 0
    dp(i) = mod(dp(i), 1000000007)
  end do
  write (*, "(i0)") dp(n)
end program main


Measured memory_bytes: 1408
N, M = map(int, input().split())
L = []
R = []
ans = 0
for _ in range(M):
    inp = input().split()
    L.append(int(inp[0]))
    R.append(int(inp[1]))
L_max = max(L)
R_min = min(R)
for i in range(L_max,min(R_min,N) + 1):
    ans  += 1
print(ans)


Measured memory_bytes: 11052
#include <bits/stdc++.h>
#include<iostream>
#include<vector>
#include<map>
#include<math.h>

#define irep(i,n) for(int i = 0; i < (int)(n); i++)
#define irep2(i,a,n) for(int i = (int)(a); i <= (int)(n); i++)
#define irrep(i,n) for(int i = (int)(n-1); i > -1; i--)
#define irrep2(i,n,a) for(int i = (int)(n); i >= (int)(a); i--)

#define fi first
#define se second

using namespace std;

using ll = long long;
using v_int = vector<int>;
using v2_int = vector<v_int>;
using v_ll = vector<ll>;
using v2_ll = vector<v_ll>;
using v_string = vector<string>;
using v_bool = vector<bool>;
using v2_bool = vector<v_bool>;
using pii = pair<int, int>;
using mii = map<int, int>;

const double PI = 3.1415926535897932;
const int INF = (int)2e9;
const ll LINF = (ll)2e18;
const ll MOD = 1000000007;
const int dc[8] = {1, -1, 0,  0, 1, -1,  1, -1};
const int dr[8] = {0,  0, 1, -1, 1,  1, -1, -1};

template<typename T, typename U> inline
ostream& operator<<(ostream &o, pair<T,U> &p) {
    return o << "{" << p.first << "," << p.second << "}";
}
template<typename T> inline
istream& operator>>(istream &is, vector<T> &vec) {
    for(auto &v : vec) { is >> v; }
    return is;
}
template<typename T> inline
ostream& operator<<(ostream &os, vector<T> &vec) {
    for(auto &v : vec) { os << v << ",";}
    return os;
}
template<typename T> inline
ostream& operator<<(ostream &os, vector<vector<T> > &mat) {
    for(auto &row : mat) { os << row << endl; }
    return os;
}

template<typename T> inline
void chmin(T &a, T b) { a = min(a, b); }
template<typename T> inline
void chmax(T &a, T b) { a = max(a, b); }

int main(void)
{
    int n, d;
    cin >> n >> d;
    d *= 2;
    d++;

    cout << (n+d-1)/d << endl;
    return 0;
} /*atcoder*/


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

using std::cin;
using std::cout;
using std::endl;
using std::string;
using std::vector;
using std::bitset;

#define rep(i,n)    for(int i=0; i<(int)n; i++)
#define reps(i,s,e) for(int i=s; i<(int)e; i++)
#define coutd(i) cout << std::fixed << std::setprecision(i)
typedef long double ld;
typedef long long ll;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef std::pair<int, int> pii;
typedef std::pair<ll, ll> pll;

template<class T>
using Set = std::set<T>;
template<class T, class U>
using Map = std::map<T, U>;

template<class T>
using Graph = vector<vector<T>>;

const int INT_BIG = 1<<28;

int main() {
    int H, W, K;
    cin >> H >> W >> K;
    vector<string> strmap(H);
    int blacknum = 0;

    rep(i, H) {
        cin >> strmap[i];
        rep(j, W) {
            if (strmap[i][j] == '#') {
                blacknum++;
            }
        }
    }

    int ans = 0;

    for (int hflag = 0; hflag < 1<<H; hflag++) {
        for(int wflag = 0; wflag < 1<<W; wflag++) {
            int tmpblacknum = blacknum;
            rep(i, H) {
                rep(j, W) {
                    if (((1<<i & hflag) || (1<<j & wflag)) && strmap[i][j] == '#') {
                        tmpblacknum--;
                    }
                }
            }
            // cout << tmpblacknum << endl;
            if (tmpblacknum == K) {
                ans++;
            }
        }
    }
    cout << ans << endl;
}

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

int main() {
	int n,m,ans=0;
	cin>>n>>m;
	vector<int>h(n),a(m),b(m),g(n,1);
	rep(i,n)cin>>h[i];
	rep(i,m)cin>>a[i]>>b[i];
	rep(i,m){
	    if(h[a[i]-1]<=h[b[i]-1])g[a[i]-1]=0;
	    if(h[a[i]-1]>=h[b[i]-1])g[b[i]-1]=0;
	}
	rep(i,n)ans+=g[i];
	cout<<ans;
	return 0;
}


Measured memory_bytes: 4832
(let ((n (read))
    (k (read))
    (a (make-array 200000))
    (ans 0))
    (loop for i below n do
        (incf (aref a (read)))
    )
    (setf a (delete-if (lambda (x) (= x 0)) a))
    (sort a '<)
    (if (> (- (length a) k) 0)
        (setq ans (loop for i across (subseq a 0 (- (length a) k)) sum i))
    )
    (format t "~d~%" ans)
)

Measured memory_bytes: 78468
from bisect import bisect
R = 1000000
p = [1]*R
p[0] = p[1] = 0
p[4::2] = [0]*len(p[4::2])
for i in xrange(3,int(R**0.5)+1,2):
    if p[i]:
        p[i*i::i] = [0]*len(p[i*i::i])
prime = [i for i in xrange(2,R) if p[i]]
while True:
    try:print bisect(prime,input())
    except:break

Measured memory_bytes: 19908
LOG = 18  # log2(10**5)
S = input()
N = len(S)
to = [[0] * N for _ in range(LOG)]

for i in range(N):
    to[0][i] = i + 1 if S[i] == 'R' else i - 1

for i in range(1, LOG):
    for j in range(N):
        to[i][j] = to[i - 1][to[i - 1][j]]

ans = [0] * N
for i in range(N):
    ans[to[LOG - 1][i]] += 1

L = [str(i) for i in ans]
print(' '.join(L))


Measured memory_bytes: 97372
#include <bits/stdc++.h>
#define REP(i,s,e) for(int i=(s); i<(e);i++)
#define rep(i,n) REP(i,0,n)
#define rep1(i,n) REP(i,1,n)
#define repe(i,n) for(auto &&i:n)
#define all(v) (v).begin(),(v).end()
#define decimal fixed<<setprecision(20)
#define fastcin() cin.tie(0);ios::sync_with_stdio(false)
using namespace std;
using LL = long long;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF = 1e9;
const LL LLINF = 1e16;

int main(){
    fastcin();

    int a, b;
    cin >> a >> b;
    cout << 6-a-b << endl;
}

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

using namespace std;

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

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

    // If the two numbers in the middle are the same, there is no valid answers. Else, it's the difference between the two in the middle, so you have to sort it first
    sort(difficulties, difficulties + n);

    int left_middle, right_middle;
    left_middle = difficulties[(n / 2) - 1];
    right_middle = difficulties[n / 2];

    if (left_middle == right_middle)
    {
        cout << 0;
    } else {
        cout << right_middle - left_middle;
    }
}


Measured memory_bytes: 640
import sys
input = sys.stdin.readline
input = sys.stdin.buffer.readline


#sys.setrecursionlimit(10**9)
#from functools import lru_cache

def RD(): return sys.stdin.read()
def II(): return int(input())
def MI(): return map(int,input().split())
def MF(): return map(float,input().split())
def LI(): return list(map(int,input().split()))
def LF(): return list(map(float,input().split()))
def TI(): return tuple(map(int,input().split()))
# rstrip().decode()

#import numpy as np
import bisect

def main():
	n,m,k=MI()
	A=LI()
	B=LI()

	for i in range(1,n):
		A[i]+=A[i-1]
	for j in range(1,m):
		B[j]+=B[j-1]
	#print(A,B)

	ans=bisect.bisect_right(B,k)

	for i in range(n):
		if k>=A[i]:
			kk=k-A[i]
			j=bisect.bisect_right(B,kk)
			#print(kk,i,j)
			ans=max(ans,i+j+1)
		else:
			break

	print(ans)


if __name__ == "__main__":
	main()


Measured memory_bytes: 105152
N, K = map(int,input().split())
list_p = [int(x) for x in input().split()]

total = sum(list_p[0:K])
max = total

for i in range(0,N-K) :
    total = total - list_p[i] + list_p[i+K]
    if total > max :
        max = total

print((max+K)/2)


Measured memory_bytes: 24676
//AtCoder ABC098 B - Cut and Count
#include <bits/stdc++.h>
using namespace std;
using ll=int64_t;

int main() {
    ll N;
    string S;
    cin>>N>>S;
    //全探索でいいや
    unordered_set<char> us;
    ll ans=0;
    for(ll i=0;i<N-1;++i){
        us.insert(S[i]);
        ll candi=0;
        for(auto& c:us){
            for(ll j=i+1;j<N;++j){
                if(c==S[j]) {
                    candi++;
                    break;
                }
            }
        }
        ans=max(ans,candi);
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
typedef long long ll;
#define rep(i,n) for (int i = 0; i < (n); i++)
#define repe(i,n) for (int i = 0; i <= (n); ++i)
#define repe1(i,n) for (int i = 0; i <= (n); ++i)
#define all(x) (x).begin(),(x).end()
#define pb(x) push_back(x)
#define eb(k,v) emplace_back(k,v)
#define ct(res) cout << res << "\n";
#define vi vector<int>
#define vl vector<ll>
using namespace std;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const int INF = 1e9;
const ll MOD = 1000000007;
using Graph = vector<vector<int>>;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n; cin >>n;
    map<int,int> mp;
    rep(i,n) {
        int a,b;
        cin >> a >> b;
        mp[b] += a;
    }
    ll t = 0;
    for(auto x:mp) {
        t += x.second;
        if (x.first >= t) {
            continue;
        } else {
            ct("No");
            return 0;
        }
    }
    ct("Yes");

}



Measured memory_bytes: 9600
import java.awt.*;
import java.io.*;
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        FastReader sc = new FastReader();
        long x=sc.nextLong();
        long curr=100;
        int c=0;
        while (curr<x){
            curr+=(curr/100);
            c++;
        }
        System.out.println(c);
    }
    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new
                    InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }
}

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

using namespace std;
typedef long long ll;
#define rep(i,j,n) for (ll i = j; i < (n); i++)
#define CLR(mat,f) memset(mat, f, sizeof(mat))
#define IN(a, b, x) (a<=x&&x<b)
#define out(ans) cout << ans << endl
typedef pair<ll,ll>P;
const ll mod=1e9+7;
const int INF = 1000000;
const double PI=3.14159265359;

int main(){

  ll n;cin>>n;
  ll a[n+10];
  int evencount=0;
  ll sum=0;
  ll mi=1e9+2;
  rep(i,0,n){
    cin>>a[i];
    sum+=abs(a[i]);
    mi=min(mi,abs(a[i]));
    if(a[i]<0)evencount++;
  }

  if(evencount%2==0)out(sum);
  else out(sum-2*mi);


  return 0;
}


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

// 2数の最大公約数
int gcd (int a, int b) 
{
  int c;
  
  if (a < b) {
    a += b;
    b = a-b;
    a -= b;
  }
  
  while (b != 0) {
    c = a % b;
    a = b;
    b = c;
  }
  
  return a;
}

// 絶対値
int absolute (int a) {
  if (a >= 0) {
    return a;
  } else {
    return -a;
  }
}

int main () {
  // 入力
  int N, X;
  cin >> N >> X;
  int x[N];
  for (int i=0; i<N; i++) {
    cin >> x[i];
  }
  
  if (N > 1) {
    // Xとの差の絶対値を計算
    int diff[N];
    for (int i=0; i<N; i++) {
      diff[i] = absolute(X - x[i]);
    }
    
    // 差の最大公約数を計算
    int d_gcd;
    d_gcd = gcd(diff[0], diff[1]);
    for (int i=2; i<N; i++) {
      d_gcd = gcd(d_gcd, diff[i]);
    }
    
    cout << d_gcd << endl;
  } else {
    cout << absolute(X-x[0]) << endl;
  }
  
}

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

int main(){
    int n;
    cin >> n;
    vector<int> d(n);
    rep(i,n) cin >> d[i];
    sort(d.begin(), d.end());
    cout << d[n/2] - d[n/2-1] << endl;
}

Measured memory_bytes: 3720
#include<stdio.h>

int main(){
    int i,a,b,sum=0;
    scanf("%d",&b);
    a=b;
    while(a!=0){
        sum+=(a%10);
        a=a/10;
    }
    if(b%sum==0){
        printf("Yes");
    }
    else{
        printf("No");
    }
    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
#include <cstring>
#define ll long long
using namespace std;

inline int read() {
	int jg = 0, jk = getchar() - '0';
	while(jk < 0 || jk > 9)  jk = getchar() - '0';
	while(jk >= 0 && jk <= 9)
		jg *= 10, jg += jk, jk = getchar() - '0';
	return jg;
}

char a[10];

int main() {
	//freopen("a.txt", "r", stdin);
	scanf("%s", a);
	printf("%c", a[0] + 1);
	return 0;
}

Measured memory_bytes: 256