akhauriyash/Code-Regression huggingface dataset:
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<iostream>
#include<queue>
#include<vector>
#include<stack>
using namespace std;
typedef long long ll;
#define MAX 200


int main(){
  int count=0,ans=0;
  string s;
  cin>>s;
  for(int i=0;i<s.size();i++){
    if(s[i]=='A' || s[i]=='T' || s[i]=='C' || s[i]=='G'){
      count++;
    }else{
      ans=max(ans,count);
      count=0;
    }
  }
  ans=max(ans,count);
  cout<<ans<<endl;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include"bits/stdc++.h"
#ifdef _DEBUG
#define DBG(n) n
#else
#define DBG(n)
#endif
#define INF         1e9
#define INFLL       1e18
#define EPS         1e-9
#define REP(i,n)    for(ll i=0,i##_len=(n);i<i##_len;++i)
#define REP1(i,n)   for(ll i=1,i##_len=(n);i<=i##_len;++i)
#define REPR(i,n)   for(ll i=(n)-1;i>=0;--i)
#define REPR1(i,n)  for(ll i=(n);i>0;--i)
#define REPC(i,obj) for(auto i:obj)
#define ALL(obj)    (obj).begin(),(obj).end()
#define SETP(n)     cout<<fixed<<setprecision(n)
using namespace std;
using ll = long long;
template<typename T = ll>inline T in() { T ret; cin >> ret; return ret; }

vector<ll>Dijkstra(const vector<vector<pair<ll, ll>>>&edge, ll start = 0)
{
	vector<ll>dist(edge.size(), INFLL); dist[start] = 0;
	priority_queue<pair<ll, ll>, vector<pair<ll, ll>>, greater<pair<ll, ll>>> node_queue;
	node_queue.push(make_pair(0, start));
	while (!node_queue.empty()) {
		ll tpn_cost = node_queue.top().first, tpn_index = node_queue.top().second; node_queue.pop();
		for (auto i : edge[tpn_index]) {
			ll dst_cost = i.first, dst_index = i.second;
			if (dist[dst_index] > tpn_cost + dst_cost) {
				dist[dst_index] = tpn_cost + dst_cost;
				node_queue.push(make_pair(dist[dst_index], dst_index));
			}
		}
	}
	return dist;
}
signed main()
{
	ll n = in(), m = in();
	vector<vector<pair<ll, ll>>>edge(n);
	REP(i, m) {
		ll a, b, c, d;
		scanf("%lld,%lld,%lld,%lld", &a, &b, &c, &d);
		--a, --b;
		edge[a].push_back(make_pair(c, b));
		edge[b].push_back(make_pair(d, a));
	}
	ll s, g, v, p;
	scanf("%lld,%lld,%lld,%lld", &s, &g, &v, &p);
	--s, --g;
	auto dist1(move(Dijkstra(edge, s))), dist2(move(Dijkstra(edge, g)));
	cout << v - dist1[g] - p - dist2[s] << endl;
}


Measured memory_bytes: 3140
n,*t=map(int,open(0).read().split())
e=[[]for _ in range(n)]
for v,w,c in zip(t[::3],t[1::3],t[2::3]):
  e[v-1]+=(w-1,c),
  e[w-1]+=(v-1,c),
q=[(0,0)]
f=[0]+[-1]*~-n
while q:
  v,c=q.pop()
  for w,d in e[v]:
    if-1<f[w]:continue
    d=(c+d)%2
    f[w]=d
    q+=(w,d),
print(*f)

Measured memory_bytes: 114256
#include<bits/stdc++.h>
using namespace std;
#define fl(n)             for(long long int i=0;i<n;i++)
#define sz(a)             int((a).size())
#define tr(c,i)           for(auto i = (c).begin(); i != (c).end(); i++)
#define trr(c,i)          for(auto i = (c).rbegin(); i != (c).rend(); i++)
#define present(c,x)      ((c).find(x) != (c).end())
#define cpresent(c,x)     (find(all(c),x) != (c).end())
#define vi                vector <int>
#define vvi               vector < vi >
#define pb                push_back
#define all(x)            (x).begin(),(x).end()
#define ll                long long
#define fr                first
#define sc                second
#define vc                vector
#define pii               pair<int,int>
#define msi               map<string,int> 
#define mii               map<int,int>
#define psi               pair<string,int>
#define pis               pair<int,string>
#define M                 1000000007


int solve()
{
	int d,t,s;
	cin>>d>>t>>s;
	if(t*s>=d)
		return cout<<"Yes\n",0;
	cout<<"No\n";


  return 0;
}


int main() {
	#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	#endif
  
  int t=1;
  //cin>>t;
  while(t--)
  {
    solve();
  }
  return 0;
}

 

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

using i64 = int64_t;

#define rep(i, x, y) for (i64 i = i64(x), i##_max_for_repmacro = i64(y); i < i##_max_for_repmacro; ++i)
#define debug(x) #x << "=" << (x)

#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define print(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define print(x)
#endif

const int inf = 1.01e9;
const i64 inf64 = 4.01e18;
const double eps = 1e-9;

template <typename T, typename U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
    os << "(" << p.first << ", " << p.second << ")";
    return os;
}

template <typename T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
    os << "[";
    for (const auto &v : vec) {
        os << v << ",";
    }
    os << "]";
    return os;
}

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

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

template<typename T, size_t size> void fill(T (&ary)[size], const T& val){
    fill_n((T*)ary, size, val);
}

void solve() {
    //const i64 mod = 1'000'000'007;

    i64 N;
    cin >> N;

    vector<i64> A(N);
    rep(i,0,N) cin >> A[i];

    i64 sum=0,cnt=0;
    rep(i,0,N){
        sum+=abs(A[i]);
        if(A[i]<0) ++cnt;
    }

    if(cnt%2==0){
        cout << sum << endl;
        return;
    }

    i64 ans=-inf64;
    rep(i,0,N){
        chmax(ans,sum-abs(A[i])*2);
    }

    cout << ans << endl;
}

int main() {
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(16);
    solve();
    return 0;
}


Measured memory_bytes: 1024
# 入力
W,H,N=map(int,input().split())

# 左下の座標
X=Y=0

for i in range(N):
  # 入力
  x,y,a=map(int,input().split())

  if a==1:
    X=max(X,x)
  elif a==2:
    W=min(W,x)
  elif a==3:
    Y=max(Y,y)
  else:
    H=min(H,y)

# 出力
print(max(W-X,0)*max(H-Y,0))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<(n);++i)
const int mod=1000000007;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;cin >> n;
	vector<ll> a(n),b(n);
	rep(i,n) cin >> a.at(i) >> b.at(i);
	ll k=0;
	for(int i=n-1;i>=0;--i){
		if((a.at(i)+k)%b.at(i)!=0) k+=b.at(i)-(a.at(i)+k)%b.at(i);
	}
	cout << k << endl;
}

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

using namespace std;
/*
--------------------------------------
	author:Guess                      
	date:2019.2.24
	problem:
--------------------------------------
*/
int main(){
	int y,m,d;
	scanf("%d/%d/%d",&y,&m,&d);
	if(y<2019){
		cout<<"Heisei";
		return 0;
	}
	else if(y>2019){
		cout<<"TBD";
		return 0;
	}
	else if(m<4)
	{
		cout<<"Heisei";
		return 0;
	}
	else if(m>4){
		cout<<"TBD";
		return 0;
	}
	else if(d<=30){
		cout<<"Heisei";
		return 0;
	}
	else cout<<"TBD";
	return 0;
}

Measured memory_bytes: 256
let () =
    let main () =
        let n = int_of_string (read_line ()) in
        let xy = Array.make_matrix n n (-1) in
        for i = 0 to n - 1 do
            let a1 = int_of_string (read_line ()) in
            for j = 0 to a1 - 1 do
                Scanf.sscanf (read_line ()) "%d %d" (fun x y -> xy.(i).(x - 1) <- y)
            done
        done;
        let bits a = 
            let rec loop a acc =
                if a = 0 then acc else loop (a lsr 1) (acc + (a land 1))
            in
            loop a 0
        in
        let judge i =
            let judge2 t =
                if i land (1 lsl t) = 0 then true else (
                    let rec loop2 k =
                        if k = n then true else (
                            if xy.(t).(k) < 0 then loop2 (k + 1) else (
                                if (xy.(t).(k) = 0 && (i land (1 lsl k) = 0)) ||
                                   (xy.(t).(k) = 1 && (i land (1 lsl k) != 0)) then loop2 (k + 1)
                                else false
                            )
                        )
                    in
                    loop2 0
                )
            in
            let rec loop s =
                if s = n then true else (
                    if judge2 s then loop (s + 1) else false
                )
            in
            loop 0
        in
        let maxn = 1 lsl n in
        let rec loop i acc =
            if i = maxn then acc else
                let acc = if judge i then max acc (bits i) else acc in
                loop (i + 1) acc
        in
        let r = loop 0 0 in
        Printf.printf "%d\n" r
    in
    main ()

Measured memory_bytes: 4608
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Scanner;

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

            List<Integer> listA = new ArrayList<Integer>();
            for(int i=0; i<num; i++){
                listA.add(new Integer(scan.nextInt()));
            }
	        scan.close();

	        List<Integer> listB = new ArrayList<Integer>(new HashSet<>(listA));

	        if(listA.size() != listB.size()) {
	        	System.out.println("NO");
	        }else {
	            System.out.println("YES");
	        }

//	        int i = 0;
//            for(int i1=0; i1<list.size(); i1++) {
//            	for(int i2=0;i2<list.size() ; i2++) {
//            		if(i1 == i2) {
//            			System.out.println("----");
//            			System.out.println(i1);
//            			System.out.println(i2);
////            			continue;
//            			i++;
//            			if(i>1) {
//            				System.out.println("NO");
//                			return;
//            			}
//            		}
//            	}
//            }
//
//            System.out.println("YES,互いに異なるならば");

    }
}

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

using namespace std;

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

#define FOR(i, n, m) for(ll (i)=(m);(i)<(n);++(i))
#define REP(i, n) FOR(i,n,0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll) 1e15;

int main() {
    string S, T, U;
    ll A, B;
    cin >> S >> T >> A >> B >> U;
    if (S == U)
        cout << A - 1 << " " << B << endl;
    else
        cout << A << " " << B - 1<< endl;
    return 0;
}

Measured memory_bytes: 764
#include <iostream>
#include <string>
#include <vector>
#include <iomanip>
#include <cassert>
#include <complex>
#include <tuple>
#include <utility>
using namespace std;
 
typedef complex<double> vec;
typedef pair<vec, vec> line;
double ip(vec u, vec v) {
    return real(u * conj(v));
}
double cross(vec u, vec v) {
    return imag(conj(u) * v);
}
vec projection(line l, vec p) {
    vec s = l.first, t = l.second;
    double k = ip(t - s, p - s) / ip(t - s, t - s);
    return (1.0 - k) * s + k * t;
}
 
vec reflection(line l, vec p) {
    return 2.0 * projection(l, p) - p;
}
 
vec intersection(line l0, line l1) {
    vec s0, t0, s1, t1;
    s0 = l0.first, t0 = l0.second;
    s1 = l1.first, t1 = l1.second;
    double k = cross(t1 - s1, s1 - s0) / cross(t1 - s1, t0 - s0);
    return s0 + (t0 - s0) * k;
}
 
string s;
int c, N;
 
struct V {
    vector<vec> ps;
    V() {
    }
};
 
V f(V v1, V v2) {
    if (v1.ps.size() + v2.ps.size() == 2) {
        V ret;
        ret.ps.push_back(v1.ps[0]);
        ret.ps.push_back(v2.ps[0]);
        return ret;
    }
    if (v1.ps.size() + v2.ps.size() == 3) {
        if (v1.ps.size() == 2)
            swap(v1, v2);
        vec v = v1.ps[0];
        line l = make_pair(v2.ps[0], v2.ps[1]);
        v = reflection(l, v);
        V ret;
        ret.ps.push_back(v);
        return ret;
    }
    if (v1.ps.size() + v2.ps.size() == 4) {
        line l1 = make_pair(v1.ps[0], v1.ps[1]);
        line l2 = make_pair(v2.ps[0], v2.ps[1]);
        vec v = intersection(l1, l2);
        V ret;
        ret.ps.push_back(v);
        return ret;
    }
}
 
V expr();
double num();
 
V expr() {
    if (s[c] == '(') {
        c++;
        if (isdigit(s[c]) || s[c] == '-') {
            double x = num();
            assert(s[c] == ',');
            c++;
            double y = num();
            assert(s[c] == ')');
            c++;
            V v;
            v.ps.push_back(vec(x, y));
            return v;
        }
        V v1 = expr();
        while (c < N && s[c] == '@') {
            c++;
            V v2 = expr();
            //assert(s[c] == ')');
            v1 = f(v1, v2);
        }
        assert(s[c] == ')');
        c++;
        return v1;
    }
}
 
double num() {
    double ret = 0;
    bool m = false;
    if (s[c] == '-') {
        m = true;
        c++;
    }
    while (isdigit(s[c])) {
        ret = ret * 10 + s[c] - '0';
        c++;
    }
    if (m) {
        ret *= -1;
    }
    return ret;
}
 
int main() {
    while (cin >> s, s != "#") {
        c = 0;
        N = s.size();
        V v1 = expr();
        while (c < N && s[c] == '@') {
            c++;
            V v2 = expr();
            v1 = f(v1, v2);
        }
        vec p = v1.ps[0];
        cout << fixed << setprecision(15) << p.real() << " " << p.imag()
                << endl;
    }
}

Measured memory_bytes: 3156
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
#define ll long long
#define ld long double
#define mk make_pair
#define fi first
#define se second
#define vll vector<ll>
#define pii pair<ll,ll>
#define vvll vector< vector<ll> >
#define pb push_back
#define sz(v) (v).size()
#define inf 1e18
#define md 1000000007
#define all(v) (v).begin(),(v).end()
#define rep(i,a,b) for(ll i=a;i<b;++i)
#define tel(a){cout<<a<<"\n";}
#define tell(a,b){cout<<a<<" | "<<b<<"\n";}
#define telll(a,b,c){cout<<a<<" | "<<b<<" | "<<c<<"\n";}
#define teln(v,n){cout<<"v- ";rep(i,0,n)cout<<v[i]<<" ";cout<<"\n";}
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0); 

using namespace std;
using namespace __gnu_pbds;

template<typename T>
using o_set=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define M 1000010

int main(){
	IOS;
	
	ll x,y;cin>>x>>y;
	ll ans=0,ans1=0,ans2=0;
	if(x==1 and y==1)ans=400000;
	if(x==1)ans1=300000;
	if(x==2)ans1=200000;
	if(x==3)ans1=100000;
	if(y==1)ans2=300000;
	if(y==2)ans2=200000;
	if(y==3)ans2=100000;
	cout<<ans+ans1+ans2;
	return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#define MSET(x,y) memset(x,y,sizeof(x))
#define F first
#define S second
#define MP make_pair
#define PB push_back
#define SZ size()
#define M 100005
#define ll long long
#define ld long double
#define INF 1e18
#define endl "\n"
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
using namespace std;
ll MOD = 1000000007;
string yes = "Yes\n";
string no = "No\n";

vector<ll> a;
ll k;

bool f(ll mid) {
  ll ans = 0;
  for(auto itr : a) {
    ans += (itr-1) / mid;
  }
  if(ans>k) return true;
  else return false;
}

int32_t main() {
  fastio;
  #ifndef ONLINE_JUDGE
  freopen("i.txt", "r", stdin);
  freopen("o.txt", "w", stdout);
  #endif
  ll n;
  cin>>n>>k;
  for(ll i=0;i<n;i++) {
    ll x;
    cin>>x;
    a.PB(x);
  }
  sort(a.begin(), a.end());
  ll lo = 1, hi=1e9, ans = -1,mid;
  while(lo<=hi) {
    mid=(lo+hi)/2;
    if(f(mid)) ans=mid, lo=mid+1;
    else hi=mid-1;
  }
  if(ans == -1) {
    cout<<1<<endl;
    return 0;
  }
  cout<<ans+1<<endl;
}

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

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

  sort(B.begin(), B.end());  
  cout << B.at(0) << endl;
}

Measured memory_bytes: 1792
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long int ll;
#define rep(i,n) for(int i=0;i<(int)n;i++)
int Min(int a, int b, int c) {
	if (a <= b) { return std::min(a, c); }
	else return std::min(b, c);
}
int Max(int a, int b, int c) {
	if (a >= b) { return std::max(a, c); }
	else return std::max(b, c);
}
int main(void) {
	string str; cin >> str;
	int res = 0;
	for (int i = 0; i < str.length(); i++) {
		if (str[i] == '+')res++;
		else res--;
	}
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define ll long long
#define _GLIBCXX_DEBUG
const ll MOD = 1000000007;
const ll Mod = 998244353;
const int MAX = 510000;
const double PI = 3.14159265358979;
const vector<int> dx = {1, 0};
const vector<int> dy = {0, 1};

int main() {
  string N;
  cin >> N;
  ll sum = 0;
  for (int i=0; i<(int)N.size(); i++) {
    char c = N[i];
    int num = c-'0';
    sum += num;
  }
  if (sum%9==0) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 3748
#include <iostream>

using namespace std;

int main() {
    int n;
    cin >> n;
    int curr = 7;
    int iter = 1;
    while (curr % n != 0 && iter < n) {
        curr = (curr * 10 + 7) % n;
        iter++;
    }

    if (curr % n == 0) {
        cout << iter << '\n';
    } else {
        cout << -1 << '\n';
    }
    return 0;
}

Measured memory_bytes: 3544
/*Coded by::
    **Avinash Tiwary**
    **BE/10298/2015**
    **Production Engineer**
    **Producing <code>**
*/
#include<bits/stdc++.h>
#define bf ios_base::sync_with_stdio (0), cin.tie (0)
typedef long long ll;
typedef double d;
#define MAX 1000009
#define MIN -1
#define M 1000000007
#define INF 5e17
using namespace std;
typedef vector<ll> Vector;
typedef queue<ll > Queue;
typedef stack<ll> Stack;
typedef pair<ll,ll> Pair;
#define mp make_pair
#define pb push_back
bool desc(ll i, ll j) { return i > j; }
ll ar[MAX];
int main(){
    bf;
    ll i=0,j=1,t,k,n,l=0,a=0,b=0,ans=0; string s;
    cin>>a>>b;
    b=b%24;
    if(a+b>=24) cout<<a+b-24;
    else cout<<a+b;
    return 0;
}  

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

int main()
{
    int n, m, X, Y;
    cin >> n >> m >> X >> Y;
    vector<int> x(n), y(m);
    int xmax = X;
    int ymin = Y;
    for(int i=0;i<n;i++){
        cin >> x[i];
        if(xmax < x[i])
            xmax = x[i];
    }
    for(int j=0;j<m;j++){
        cin >> y[j];
        if(y[j]<ymin)
            ymin = y[j];
    }
    if(xmax < ymin) cout << "No War" << endl;
    else cout << "War" << endl;

    return 0;


}

Measured memory_bytes: 256
program test
	implicit none
	integer :: a=0,b=0,c=0,k=0,ans=0
    read *,a,b,c,k
    if(k<=a) then
    	write (*,'(i0)') k
    else
    	ans=a-(k-a-b)
    	write (*,'(i0)') ans
    end if
end program test

Measured memory_bytes: 2920
#include <iostream>
#include <set>
#include <map>
#include <utility>
#include <vector>
#include <limits>
using namespace std;
#define pb push_back
#define mp make_pair

const int MAX_N = 1e5+1;
const int MAX_NODES = 1e6;
set<int> cas[MAX_N];
map<pair<int, int>, int> nr; 
vector<pair<int, int> > g[MAX_NODES];

int dist[MAX_NODES];
set<pair<int, int> > pq;


void dijkstra(int src)
{
	dist[src] = 0;
	pq.insert(mp(0,src));

	while (!pq.empty())
	{
		int u = pq.begin()->second;
		pq.erase(pq.begin());
		for (vector<pair<int, int> >::iterator it = g[u].begin(); it != g[u].end(); it++)
		{
			int v = it->first;
			int d = it->second;
			if (dist[u] + d < dist[v])
			{
				pq.erase(mp(dist[v],v));
				dist[v] = dist[u] + d;
				pq.insert(mp(dist[v],v));
			}
		}
	}
}


int main()
{
	int n, m;
	scanf("%d %d", &n, &m);
	int numNodes = 1;
	for (int i = 0; i < m; i++)
	{
		int p,q,c;
		scanf("%d %d %d", &p, &q, &c);
		cas[p].insert(c);
		cas[q].insert(c);
		if (nr.find(mp(p,c)) == nr.end())
			nr[mp(p,c)] = numNodes++;
		if (nr.find(mp(q,c)) == nr.end())
			nr[mp(q,c)] = numNodes++;
		int u = nr[mp(p,c)];
		int v = nr[mp(q,c)];
		g[u].pb(mp(v,0));
		g[v].pb(mp(u,0));
	}
	for (int i = 1; i <= n; i++)
	{
		int u = numNodes++;
		for (set<int>::iterator it = cas[i].begin(); it != cas[i].end(); it++)
		{
			int v = nr[mp(i,*it)];
			g[u].pb(mp(v,1));
			g[v].pb(mp(u,0));
		}
	}
	for (set<int>::iterator it = cas[1].begin(); it != cas[1].end(); it++)
	{

		int v = nr[mp(1,*it)];
		g[0].pb(mp(v,1));
	}

	for (int i = 1; i <= numNodes; i++)
		dist[i] = numeric_limits<int>::max();
	dijkstra(0);
	int minDist = numeric_limits<int>::max();
	for (set<int>::iterator it = cas[n].begin(); it != cas[n].end(); it++)
	{
		int v = nr[mp(n,*it)];
		minDist = min(minDist, dist[v]);
	}
	if (minDist == numeric_limits<int>::max())
		printf("-1\n");
	else
		printf("%d\n", minDist);
}

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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N;
ll ret=0;

void dfs(ll cur,int mask) {
	
	if(cur>N) return;
	if(mask==7) ret++;
	dfs(cur*10+7,mask|4);
	dfs(cur*10+5,mask|2);
	dfs(cur*10+3,mask|1);
}


void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N;
	dfs(0,0);
	cout<<ret<<endl;
	
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <map>
#include <math.h>
#include <iomanip>
#include <vector>
#include <queue>
#include <functional>
#include <random>
#include <time.h>
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
ll f[110][110];
ll dx[] = { 1,1,0,-1,-1,-1,0,1 }, dy[] = { 0,1,1,1,0,-1,-1,-1 };
int main() {
	ll a, b;
	cin >> a >> b;
	char c[110][110];
	if (a > b) {
		for (int i = 0; i < 100; i++) {
			for (int j = 0; j<100; j++) {
				c[i][j] = '.';
			}
		}
		ll num = a - b;
		ll x, y;
		for (int i = 0; i < num; i++) {
			x = (i % 50) * 2 + 1;
			y = (i / 50) * 2 + 1;
			f[y][x] = 1;
		}
		b--;
		x = 1;
		y = y + 4;
		for (int i = 0; i < b; i++) {
			f[y][x] = 1;
			x += 4;
			if (x == 101) {
				x = 1;
				y += 4;
			}
		}
		for (int i = 0; i < 100; i++) {
			for (int j = 0; j<100; j++) {
				if (f[i][j]) {
					for (int k = 0; k < 8; k++) {
						c[i + dy[k]][j + dx[k]] = '#';
					}
				}
			}
		}
	}
	else if (a < b) {
		for (int i = 0; i < 100; i++) {
			for (int j = 0; j<100; j++) {
				c[i][j] = '#';
			}
		}
		ll num = b - a;
		ll x, y;
		for (int i = 0; i < num; i++) {
			x = (i % 50) * 2 + 1;
			y = (i / 50) * 2 + 1;
			f[y][x] = 1;
		}
		a--;
		x = 1;
		y = y + 4;
		for (int i = 0; i < a; i++) {
			f[y][x] = 1;
			x += 4;
			if (x == 101) {
				x = 1;
				y += 4;
			}
		}
		for (int i = 0; i < 100; i++) {
			for (int j = 0; j<100; j++) {
				if (f[i][j]) {
					for (int k = 0; k < 8; k++) {
						c[i + dy[k]][j + dx[k]] = '.';
					}
				}
			}
		}

	}
	else {
		for (int i = 0; i < 100; i++) {
			for (int j = 0; j<100; j++) {
				c[i][j] = '.';
			}
		}
		ll x, y;
		x = 1;
		y = 1;
		for (int i = 1; i < b; i++) {
			f[y][x] = 1;
			x += 4;
			if (x == 101) {
				x = 1;
				y += 4;
			}
		}
		for (int i = 0; i < 100; i++) {
			for (int j = 0; j<100; j++) {
				if (f[i][j]) {
					for (int k = 0; k < 8; k++) {
						c[i + dy[k]][j + dx[k]] = '#';
					}
				}
			}
		}
		c[99][99] = '#';
	}
	cout << 100 << ' ' << 100 << endl;
	for (int i = 0; i < 100; i++) {
		for (int j = 0; j<100; j++) {
			cout << c[i][j];
		}
		cout << endl;
	}
	return 0;
}


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

int n, w;
vector<int> wgt;
vector<int> val;
vector<vector<long long>> DP;

int main()
{
	cin >> n >> w;
	wgt.resize(n + 1); val.resize(n + 1); 
	for (int i = 1; i < n + 1; i++)
		cin >> wgt[i] >> val[i];

	// once an item is taken, you need to remove from available list
	// DP[j][i] is the max value achievable, i is allowable weight, j is min index of object can be used
	// i 0...W, j 1...n
	DP.resize(n + 1);
	for (int i = 0; i < n + 1; i++)
		DP[i].resize(w + 1, 0);
	for (int i = 1; i < w + 1; i++) //using only the last object
	{
		if(i >= wgt[n])
			DP[n][i] = val[n];
	}
	for (int j = n - 1; j >= 1; j--)
	{
		for (int i = 1; i < w + 1; i++)
		{
			// calculate DP[j][i] 
			if (i < wgt[j]) //can't put in this item
			{
				DP[j][i] = DP[j + 1][i];
				continue;
			}
			DP[j][i] = max(DP[j + 1][i], DP[j + 1][i - wgt[j]] + val[j]);
		}
	}

	cout << DP[1][w] << endl;
}

Measured memory_bytes: 82360
array = gets.split
w = array[0].to_i
h = array[1].to_i
x = array[2].to_i
y = array[3].to_i
r = array[4].to_i

if x-r < 0
 puts "No"
elsif y-r < 0
 puts "No"
elsif x+r > w
 puts "No"
elsif y+r > h
 puts "No"
else
 puts "Yes"
end

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

#ifdef _DEBUG
#define debug(x) cout<<#x<<": "<<x<<endl
#else
#define debug(x)
#endif

using namespace std;

int main() {
    int A, B, C;
    cin >> A >> B >> C;
    swap(A, B);
    swap(A, C);
    cout << A << " " << B << " " << C << endl;
}

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

using namespace std;

int main(void)
{
    double a, b, c, h, m;
    cin >> a >> b >> h >> m;
    c = a * a + b * b - 2 * a * b * cos(abs((m * 6) - (h * 30 + 0.5 * m)) * M_PI / 180);
    cout << setprecision(11) << sqrt(c) << endl;
}

Measured memory_bytes: 4200
#include <bits/stdc++.h>
using namespace std;
using s64 = int64_t;
using u64 = uint64_t;

int main() {
	s64 N, X, Y;
	cin >> N >> X >> Y;
	
	vector<u64> d(N);
	
	for(s64 i=1; i<=N; i++) {
		for(s64 j=i+1; j<=N; j++) {
			u64 td = min(abs(j - i), min(abs(X - i) + abs(Y - j) + 1, abs(X - j) + abs(Y - i) + 1));
			d[td]++;
			//cout << i+1 << " " << j+1 << td;
		}
	}
	
	for(s64 i=1; i<N; i++) cout << d[i] << endl;
	
	return 0;
}

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

typedef long long ll;

map<vector<ll>,vector<pair<ll,ll> > >mp;

int calc(ll l,ll r){
	if(!l)return 0;--l;
	int ret=0;
	for(int i=60;;--i)
		if((l>>i&1)!=(r>>i&1))return ret+1;
		else ret+=l>>i&1;
}
const int N=210,mod=1000000007;
int n;
ll K,a[N],b[N],ans;

int main(){
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	cin>>n>>K;
	for(int i=1;i<=n;++i)cin>>a[i];
	sort(a+1,a+n+1);
	for(int i=0;i<=60;++i){
		for(int j=1;j<=n;++j)b[j]=a[j]&((1ll<<i)-1);
		sort(b+1,b+n+1);b[0]=-1;int L=unique(b+1,b+n+1)-b-1;
		for(int j=1;j<=L;++j)
			if(a[1]>=b[j]){
				ll l=((a[1]-b[j])>>i)+i+calc(b[j-1]+1,b[j])-K,r=(a[1]-b[j])>>i;
				if(l>r)continue;
				vector<ll>v;
				for(int k=2;k<=n;++k)
					v.push_back(((a[k]-b[j])>>i)-((a[k-1]-b[j])>>i));
				mp[v].emplace_back(l,r);
			}
	}
	for(auto&i:mp){
		sort(i.second.begin(),i.second.end());
		ll la=-1;
		for(auto j:i.second)
			if(j.second>la)(ans+=j.second-max(j.first-1,la))%=mod,la=j.second;
	}
	cout<<ans<<'\n';
	return 0;
}


Measured memory_bytes: 16384
import java.util.*;
public class Main {

		
	    public static void main(String[] args) throws java.io.IOException{
	        Scanner scan = new Scanner(System.in);
	        boolean [] prime = new boolean[50000];
	        
	        for(int i=2;i<prime.length;i++)prime[i]=true;
	        for(int i=2;i<=Math.sqrt(prime.length-1);i++){
	        	if(prime[i]){
	        		for(int j=i*2;j<=prime.length-1;j+=i)prime[j]=false;
	        	}
	        }
	        
	        while(true){
	        	int k=scan.nextInt();
	        	if(k==0)break;
	        	int ans=0;
	        	for(int i=2;i<k;i++){
	        		if(prime[i]&&prime[k-i])ans++;
	        	
	        	}
	        	if(ans!=1)ans=(ans+1)/2;
	        	System.out.println(ans);
	        }
	    }
}
	    

Measured memory_bytes: 13000
# encoding: utf-8

import sys
from collections import deque


class Solution:
    @staticmethod
    def message_queue():
        # write your code here
        # tasks = deque(map(lambda x: x.split(), sys.stdin.readlines()))
        task_num, task_time = map(int, input().split())
        _input = sys.stdin.readlines()
        
        task_deque = deque(map(lambda x: dict(name=x.split()[0], time=int(x.split()[-1])), _input))
        total_time = 0

        while task_deque:
            item = task_deque.popleft()
            if item['time'] <= task_time:
                total_time += item['time']
                print(item['name'], total_time)
            else:
                item['time'] -= task_time
                total_time += task_time
                task_deque.append(item)


if __name__ == '__main__':
    solution = Solution()
    solution.message_queue()

Measured memory_bytes: 30016
n,m = [int(i) for i in input().split()]

l = [[int(i) for i in input().split()] for _ in range(n)]

l = sorted(l,key = lambda x: x[0])


q = 0
s = 0
for i in l:
    if q + i[1] <= m:
        s += i[0]*i[1]
        q += i[1]
    else:
        s += i[0]*(m-q)
        break
        
print(s)
    

Measured memory_bytes: 23528
# -*- coding: utf-8 -*-

# a right triangle = 直角三角形

def judge_right(x, y, z)
  a = x ** 2 + y ** 2
  b = y ** 2 + z ** 2
  c = z ** 2 + x ** 2
  if a == z ** 2 || b == x ** 2 || c == y ** 2
    return true
  else
    return false
  end
end

N = gets.chomp.to_i

N.times do
  x, y, z = gets.chomp.split(" ").map{|item| item.to_i}
  if judge_right(x, y, z)
    puts "YES"
  else
    puts "NO"
  end
end

Measured memory_bytes: 6104
def divisionize(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    divisors = sorted(divisors)
    return divisors

a,b,k = map(int, input().split())
a_ = set(divisionize(a))
b_ = set(divisionize(b))
c = sorted(list((a_&b_)))[::-1]
print(c[k-1])

Measured memory_bytes: 3064
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include<bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;

typedef pair <int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<ld, ld> pd;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const int mod = 1e9 + 7;
const char nl = '\n';

void solve() {
    int a, b, c;
    cin >> a >> b >> c;
    if(a + b == c or b + c == a or c + a == b){
        cout << "Yes" << nl;
    }
    else{
        cout << "No" << nl;
    }
}
int main() {
#ifndef ONLINE_JUDGE
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
#endif
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    solve();
    return 0;
}


Measured memory_bytes: 256
/**
 * @brief  : c++ code for AtCoder
 * @author : rk222
 * @created: 2019.06.22 20:57:26
 */

#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;
typedef pair<int, P> P1;

#define fr first
#define sc second
#define mp make_pair
#define pb push_back
#define rep(i, x) for (ll i = 0; i < x; i++)
#define rep1(i, x) for (ll i = 1; i <= x; i++)
#define rrep(i, x) for (ll i = x - 1; i >= 0; i--)
#define rrep1(i, x) for (ll i = x; i > 0; i--)
#define sor(v) sort(v.begin(), v.end())
#define rev(s) reverse(s.begin(), s.end())
#define lb(vec, a) lower_bound(vec.begin(), vec.end(), a)
#define ub(vec, a) upper_bound(vec.begin(), vec.end(), a)
#define uniq(vec) vec.erase(unique(vec.begin(), vec.end()), vec.end())
#define mp1(a, b, c) P1(a, P(b, c))

#define disp(x) cout << #x << ": " << x << endl
#define disp_vec(v)                                                                           \
    cout << #v << ":";                                                                        \
    rep(i, v.size()) cout << " " << v[i];                                                     \
    cout << endl

const int INF = 100000000;
const int M = 100000000;
const int dir_4[4][2] = {{1, 0}, {0, 1}, {-1, 0}, {0, -1}};
const int dir_8[8][2] = {{1, 0}, {1, 1}, {0, 1}, {-1, 1}, {-1, 0}, {-1, -1}, {0, -1}, {1, -1}};

/* ------------------------------------- */
ll gcd(ll a, ll b) {
    if (a % b == 0) {
        return (b);
    } else {
        return (gcd(b, a % b));
    }
}

int main() {
    ll a, b, c, d;
    scanf("%lld%lld%lld%lld", &a, &b, &c, &d);
    ll c1, c2, d1, d2, cd1, cd2;
    if (c < d) {
        swap(c, d);
    }
    ll lcm = c * d / gcd(c, d);
    c1 = (a - 1) / c;
    c2 = b / c;
    d1 = (a - 1) / d;
    d2 = b / d;
    cd1 = (a - 1) / lcm;
    cd2 = b / lcm;

    ll ret = (b - a + 1) - (c2 - c1) - (d2 - d1) + (cd2 - cd1);

    printf("%lld\n", ret);

    /* --------------------------------- */
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <set>
#include <map>
#include<vector>
#include <string>

using namespace std;

int main() {
	int input,happy=0,tmp;
	cin >> input;
	if (input > 0) {
		happy += 1000 * (input / 500);
		input = (input % 500);
	}
	if (input > 0) {
		happy += 5 * (input / 5);
	}
	cout << happy;
	return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

//#define int long long
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return true; } return false; }

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N; cin >> N;
	vector<int> v(N); rep(i, 0, N) {
		cin >> v[i];
	}
	cout << *max_element(all(v)) - *min_element(all(v)) << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define pb push_back
const int maxn = 10000;
const int INF32 = 1'050'000'000;
const long long INF64 = 4'000'000'000'000'000'000;
const int MOD7 = 1'000'000'007;
const int MOD9 = 1'000'000'009;

ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
int dx[8]={-1,0,1,0,1,1,-1,-1};
int dy[8]={0,-1,0,1,1,-1,1,-1};

int D, G;

int main(){
	cin >> D >> G;
	vector<int> p(D);
	vector<int> c(D);
	rep(i,D) cin >> p[i] >> c[i];	
	//--------------------------------------------
	 int cnt = INF32;
	 for(int bit = 0; bit < (1<<D); bit++){
	 	int sum = 0;
	 	int num = 0;
	 	for(int i = 0; i < D; i++){
	 		if(bit & (1<<i)){
	 			sum += (i+1)*100*p[i]+c[i]; 
	 			num += p[i];
	 		}
	 	}
	 	if(sum >= G) cnt = min(num,cnt);
 		else{
 			for(int j = D-1; j >= 0; j--){
 				if(bit & (1<<j)) continue;
 				else{
 					for(int k = 1; k < p[j]; k++){
 						sum += (j+1)*100;
 						num++;
 						if(sum >= G){
 							cnt = min(num,cnt);
 							break;
 						}
 					}
 					break;
 				}
 			}
 		}
 	}
	//--------------------------------------------
	 cout << cnt << endl;
}

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

#define INF 1000000021
#define MOD 1000000007
#define pb push_back
#define pp pop_back
#define pf push_front
#define sqr(a) (a)*(a)
#define mpr(a,b) make_pair(a, b)
#define all(x) (x.begin(), x.end())
#define deb(x) cerr << #x << " = " << x << '\n'
#define N 322222

using namespace std;

typedef long double ld;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef map<int, int> mpii;
typedef map<string, int> mpsi;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef queue<int> qi;
typedef queue<ll> qll;
typedef queue<pair<int, int>> qpi;
typedef priority_queue<int> pqi;
typedef priority_queue<ll> pqll;
typedef priority_queue<pair<int,int>> pqpi;

const ld pi = 2 * acos(0.0);
template<class T> bool umin(T& a, T b){if(a>b){a=b;return 1;}return 0;}
template<class T> bool umax(T& a, T b){if(a<b){a=b;return 1;}return 0;}
template<class T> T gcd(T a, T b){return b ? gcd(b, a % b) : a;}
template<class T> T lcm(T a, T b){return a*(b/gcd(a,b));}
template<class T, class TT>bool pal(T a, TT n){int k=0;for(int i=0;i<=n/2;i++){if(a[i]!=a[n-i-1]){k=1;break;}}return k?0:1;}

//int month[] = {0, 31, 28, 31, 30, 31,30, 31, 31, 30, 31, 30, 31};

int foo[N], hoo[N];
int main()
{
	int n;
	cin >> n;
	string s;
	cin >> s;
	if(s[0] == 'E')
		hoo[0] = 1;
	else
		foo[0] = 1;
	for(int i = 1 ; i < s.size(); i ++)
	{
		foo[i] = foo[i - 1];
		hoo[i] = hoo[i - 1];
		if(s[i] == 'E')
			hoo[i] ++;
		else
			foo[i] ++;
	}
	int ans = 1e9;
	for(int i = 0; i <= s.size(); i ++)
	{
		int k1 = 0, k2 = 0;
		if(i)
			k1 = foo[i - 1];
		k2 = hoo[n-1] - hoo[i];
		int sum = k1 + k2;
		umin(ans, sum);
	}
	cout << ans;
	
	getchar();
	getchar();
	return 0;
	//freopen("Ganiyev.txt", "r", stdin);
	//freopen("Asadullo.txt", "w", stdout);
	//ios::sync_with_stdio(0);
	//cin.tie(0);cout.tie(0);
	
	
	
	
	
	
	
	
	
	
}

Measured memory_bytes: 3076
import fractions
A, B, C = map(int, input().split())

reg = fractions.gcd(A,B)
tmp = A
flg = False
while tmp%B!=0:
    if tmp%B==C:
        flg = True
        break
    tmp += A
ans='YES' if flg else 'NO'
print(ans)
    

Measured memory_bytes: 5176
#include <stdio.h>
#define MAX 100000

int A[MAX];

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

    return i + 1;
}


int main(int argc, char const *argv[])
{
    int n;
    scanf("%d", &n);
    for (int i = 0; i < n; i++) {
        scanf("%d", &A[i]);
    }

    int q = partition(0, n - 1);

    for (int i = 0; i < n; i++) {
        if (i) printf(" ");
        if (i == q) printf("[");
        printf("%d", A[i]);
        if (i == q) printf("]");
    }
    printf("\n");

    return 0;
}




Measured memory_bytes: 2124
# coding:utf-8


def main():
    haiku = [5, 7, 5]
    word_num = input().split(' ')
    for num in word_num:
        try:
            haiku.remove(int(num))
        except:
            return 'NO'
    return 'YES'


if __name__ == '__main__':
    reply = main()
    print(reply)


Measured memory_bytes: 9108
def MAP(): return map(int,input().split())
def gcd(a, b):
    while b:
        a %= b
        a, b = b, a
    return a

n = int(input())
*a, = MAP()

x=[0 for _ in range(n)]
y=[0 for _ in range(n)]
for i in range(1,n):
    x[i]=gcd(x[i-1],a[i-1])
for i in range(n-1)[::-1]:
    y[i]=gcd(y[i+1],a[i+1])
Z=[gcd(x[i],y[i]) for i in range(n)]
print(max(Z))

Measured memory_bytes: 14436
import java.util.Scanner;

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

        int sum = 0;
        for (int i = 1; i <= N; i++) {
            int one = i % 10;
            int two = (i%100) / 10;
            int thr = (i%1000) / 100;
            int fou = (i%10000) / 1000;
            int five = (i%100000) / 10000;
            int num = one + two + thr + fou + five;

            if (num >= A && num <= B) {
                sum += i;
            }
        }

        System.out.println(sum);
    }
}


Measured memory_bytes: 23892
s = input()
if len(s) == 2:
  print(1,1)
  exit()
chk = [0]*len(s)
cntR = 1
r = 0
cntL = 0
for i in range(len(s)-1):
  if s[i] == 'R' and s[i+1] == 'L':
    r = i
    chk[r] += (cntR+1)//2
    chk[r+1] += (cntR)//2
    cntL = 1
  if s[i] == 'R' and s[i+1] == 'R':
    cntR += 1
  if s[i] == 'L' and s[i+1] == 'L':
    cntL += 1
  if s[i] == 'L' and s[i+1] == 'R':
    chk[r] += (cntL)//2
    chk[r+1] += (cntL+1)//2
    cntL = 0
    cntR = 1
chk[r] += (cntL)//2
chk[r+1] += (cntL+1)//2
chk = list(map(str,chk))
print(' '.join(chk))


Measured memory_bytes: 10356
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Jaynil
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        DHandstand solver = new DHandstand();
        solver.solve(1, in, out);
        out.close();
    }

    static class DHandstand {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            int k = in.nextInt();
            String x = in.next();

            int j = 0;
            int p = 0;
            int ans = 0;
            for (int i = 0; i < n; i++) {
                char ch = x.charAt(i);
                if (ch == '0' && (i == 0 || (i > 0 && x.charAt(i - 1) == '1'))) p++;
                while (p > k && j < i) {
                    j++;
                    if (x.charAt(j) == '1' && x.charAt(j - 1) == '0') p--;
                }
                ans = Math.max(i - j + 1, ans);
            }
            out.println(ans);


        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

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

    }
}




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

using namespace std;

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

#define MOD 1000000007
#define REP(i, N) for (int i = 0; i < N; ++i)
#define REP1(i, N) for (int i = 1; i <= N; ++i)
#define RREP(i, N) for (int i = N - 1; i >= 0; --i)
#define ALL(a) a.begin(), a.end()

int main() {
  int h, w;
  cin >> h >> w;
  int a, b;
  cin >> a >> b;
  int ans[1010][1010] = {};
  REP(i, b) REP(j, a) { ans[i][j] = 1; }
  for (int i = b; i < h; ++i) {
    for (int j = a; j < w; ++j) {
      ans[i][j] = 1;
    }
  }
  REP(i, h) {
    REP(j, w) { cout << ans[i][j]; }
    cout << "\n";
  }
  return 0;
}

Measured memory_bytes: 5248
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> P;
map <int,int> mp;
vector<int> V;
#define INF (1<<29)
#define INFLL (1ll<<58)
#define EPS (1e-10)
static const int MAX=1e5;
static const int MOD=1e9+7;
static const int NMAX=50;
static const int MMAX=50;
int dx[4]={0,1,0,-1},dy[4]={-1,0,1,0};
int N,Q,K;
typedef struct edge{
    int to,cost;
}Edge;
vector<Edge> adj[MAX+2];
ll d[MAX+2]; //Kからの距離
bool visited[MAX+2];
void dfs(int v,int u,ll dist){ //次の場所、今の場所,そこのkからの距離
    d[v]=dist;
    for(auto &e: adj[v]){
        if(e.to==u)continue; //元の場所に戻るなら
        dfs(e.to,v,dist+e.cost);

    }
    
}

void solve(){
    visited[K]=true;
    d[K]=0;
    dfs(K,-1,0ll);
}

int main(){
    cin.tie(0);  ios::sync_with_stdio(false);
    
    cin>>N;
    for(int i=0;i<N-1;i++){
        int a,b,c;
        cin>>a>>b>>c;
        Edge e1,e2;
        e1.to=b,e1.cost=c;
        e2.to=a,e2.cost=c;
        
        adj[a].push_back(e1);
        adj[b].push_back(e2); //反対向きがあることに注意!!
    }
    cin>>Q>>K;
    solve();
    

    while(Q--){
        int x,y;
        cin>>x>>y;
        cout<<d[x]+d[y]<<"\n";
        
    }
    
    return 0;
}


Measured memory_bytes: 12800
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000ll
#define LLINF 2000000000000000000ll
#define sz(x) ((int)(x).size())
#define fi first
#define sec second
#define all(x) (x).begin(),(x).end()
#define sq(x) ((x)*(x))
#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define repn(i,a,n) for(int (i)=(a);(i)<(int)(n);(i)++)
#define EQ(a,b) (abs((a)-(b))<eps)
template<class T> void chmin(T& a,const T& b){if(a>b)a=b;}
template<class T> void chmax(T& a,const T& b){if(a<b)a=b;}
ll A,B,K;
ll f(ll k){
	ll ret = 1ll;
	if(k>=A)ret *= k+1ll;
	else ret *= k;
	ll mul = K+1ll-k;
	if(K>=B){
		if(k<=K-B+1ll){
			mul++;
			if(LLINF/ret+1ll<mul)ret = LLINF;
			else ret *= mul;
		}else{
			if(LLINF/ret+1ll<mul)ret = LLINF;
			else ret *= mul;
		}
	}else{
		if(LLINF/ret+1ll<mul)ret = LLINF;
		ret *= mul;
	}
	return ret;
}
bool check(ll x){
	K = x;
	ll l=1ll,r=x;
	while(r-l>2ll){
		ll m = (l*2ll+r)/3ll;
		ll n = (l+r*2ll)/3ll;
		if(f(m)<f(n))l=m;
		else r=n;
	}
	ll mx = max(max(f(l),f(r)),f(l+1));
	return mx<(A*B);
}
ll solve(){
	ll l = 0ll,r = A*B;
	while(r-l>1ll){
		ll mid = (l+r)/2ll;
		if(check(mid))l=mid;
		else r = mid;
	}
	return l;
}
int Q;
int main(){
	cin >> Q;
	for(int i=0;i<Q;i++){
		cin >> A >> B;
		cout << solve() << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,i,j,odd=0,even=0,four=0;
    scanf("%d",&n);
    int a[n+10];
    for(i=0;i<n;i++)
    {
        scanf("%d",&a[i]);
        if(a[i]%4==0)
        {
            four++;
        }
        else if(a[i]%2==0)
        {
            even++;
        }
        else
        {
            odd++;
        }
    }
   if(odd>four)
   {
       int x=odd-four;
       if(x==1&&(2*four+x)==n)
       {
           printf("Yes");
       }
       else
       {
           printf("No");
       }

   }
   else
   {
       printf("Yes");
   }
   return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int i,c=0,d=0,n,sum=0;
    cin>>n;
    int a[n+2];
    for(i=0; i<n; i++)
    {
        cin>>a[i];

    }
    sort(a,a+n);
    for(i=n-1; i>=0; i=i-2)
    {
        sum=sum+a[i];

    }
    for(i=n-2; i>=0; i=i-2)
    {
        d=d+a[i];

    }
cout<<sum-d<<endl;

}


Measured memory_bytes: 256
#include<map>
#include<set>
#include<list>
#include<cmath>
#include<queue>
#include<stack>
#include<cstdio>
#include<string>
#include<vector>
#include<complex>
#include<cstdlib>
#include<cstring>
#include<numeric>
#include<sstream>
#include<iostream>
#include<algorithm>
#include<functional>

#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)

using namespace std;

typedef    long long          ll;
typedef    unsigned long long ull;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      pii;

const int INF=1<<29;
const double EPS=1e-9;

const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};
int n;
const int MAX_N = 123456;

bool prime[2*MAX_N+1];//1000000までの素数を求める
void isprime(){
	for(int i = 0;i <2*MAX_N+1;i++){
		prime[i] = true;
	}
	prime[0] = false;
	prime[1] = false;
	for(int i = 2;i*i<2*MAX_N+1;i++){
		if(prime[i]){
			for(int j = 2*i;j <2*MAX_N+1;j+=i){//素数の倍数は素数ではない
				prime[j]= false;
			}
		}
	}
}
int main(){
	isprime();
	while(cin>>n){
		if(n==0)
			break;
		int ans= 0;
		for(int i =n+1;i <=2*n;i++){
			if(prime[i]){
				ans++;
			}
		}
		cout <<ans<<endl;
	}
	return 0;
}

Measured memory_bytes: 1400
#include<bits/stdc++.h>
using namespace std;
string a,b;
int main(){
    cin>>a;
    cin>>b;
    int x=a.size(),y=b.size();
    for(int i=0;i<y;i++){
        cout<<a[i]<<b[i];
    }
    if(x>y){
        cout<<a[x-1];
    }
    return 0;
}

Measured memory_bytes: 256