akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize ("O3")

#include <bits/stdc++.h>

using namespace std;

#ifdef LOCAL
#include <prettyprint.hpp>
#define debug(...)  cerr << "[" << #__VA_ARGS__ << "]: ", d_err(__VA_ARGS__);
#else
#define debug(...) 83;
#endif

void d_err() {
    cerr << endl;
}

template <typename H, typename... T>
void d_err(H h, T... t) {
    cerr << h << " ";
    d_err(t...);
}

template <typename T>
void print(T x) {
    cout << x << "\n";
}

#define ALL(x) (x).begin(), (x).end()
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define REVFOR(i, m, n) for (int i = (n - 1); i >= (m); --i)
#define REP(i, n) FOR(i, 0, n)
#define REVREP(i, n) REVFOR(i, 0, n)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define bcnt __builtin_popcountll

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<ll,ll> Pll;
typedef pair<int,int> Pin;

ll INF = 1e16;
int inf = 1e9;
ll MOD = 1e9+7;

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    
    int x, a, b;
    cin >> x >> a >> b;

    if (abs(x - a) < abs(x - b)) print("A");
    else print("B");
    
}


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

using namespace std;

using ll = long long;
using ld = long double;

const double PI = 3.1415926535897932384626433832795;
const ll MOD = 1000000007;

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

int gcd(int x, int y) { return y ? gcd(y, x % y) : abs(x); }
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : abs(x); }
int lcm(int x, int y) { return x / gcd(x, y) * y; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }

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

	string s;
	cin >> s;

	int n = s.size();

	vector<int> ans(n);
	for (int i = 0; i < n - 1; i++) {
		if (s[i] != 'R' || s[i + 1] != 'L') {
			continue;
		}

		for (int j = i; j >= 0 && s[j] == 'R'; j--) {
			ans[i + (i - j)%2]++;
		}

		for (int j = i + 1; j < n && s[j] == 'L'; j++) {
			ans[i + (j - i)%2]++;
		}
	}
	for (int i = 0; i < n; i++) {
		if (i) cout << " ";
		cout << ans[i];
	}
	cout << endl;
	return 0;
}


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

int c[109][109], n, m, p, q, r, maxn;

void dfs(vector<int>vec) {
	if (vec.size() >= 2) {
		int sum = 0;
		for (int i = 0; i < vec.size(); i++) {
			int minx = 1000009;
			for (int j = 0; j < vec.size(); j++) {
				if (i == j) continue;
				minx = min(minx, c[vec[i]][vec[j]]);
				if (minx == 0) return;
			}
			sum += minx;
		}
		maxn = max(maxn, sum);
	}
	int T = 1; if (vec.size() >= 1) T = vec[vec.size() - 1] + 1;
	for (int i = T; i <= n; i++) {
		vector<int>F = vec; F.push_back(i);
		dfs(F);
	}
}

int main() {
	cin >> n >> m;
	for (int i = 1; i <= m; i++) {
		cin >> p >> q >> r;
		c[p][q] = r; c[q][p] = r;
	}
	dfs(vector<int>{});
	cout << maxn << endl;
	return 0;
}


Measured memory_bytes: 3200
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <string>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <sstream>
#include <vector>
#define INF 0x3f3f3f3f
using namespace std;

typedef long long ll;
const int mod = 1e9 + 7;
const int maxn = 10005;
const double pi = acos(-1.0);

ll a,b,c,k;

int main()
{
    while(cin >> a >> b >> c >> k)
    {
        ll ans = 0;
        if(k >= a)
        {
            ans += a;
            k -= a;
        }
        else
        {
            ans += k;
            k = 0;
            cout << ans << endl;
            continue;
        }
        
        if(k >= b)
            k -= b;
        else
        {
            k = 0;
            cout << ans << endl;
            continue;
        }
        
        if(k >= c)
        {
            ans -= c;
            k -= c;
        }
        else
        {
            ans -= k;
            cout << ans << endl;
            continue;
        }
        cout << ans << endl;
    }
    return 0;
}




Measured memory_bytes: 3636
import java.util.Scanner;

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

    	int firstNumber = Integer.parseInt(firstLine[0]);
    	int secoundNumber = Integer.parseInt(firstLine[1]);
    	
    	String result = "Odd";
    	if(firstNumber%2 == 0 || secoundNumber%2 == 0) {
    		result = "Even";
    	}
    	System.out.print(result);
    	
    }
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
#include <math.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rrep(i, n) for(int i = 0; i <= (n); i++)
using namespace std;
typedef long long ll;
 
const ll INF = 1LL<<62;
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; }
// 多次元 vector 生成
template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}
template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
  return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

const int MOD = 1000000007;

int ans = 100000000;

int main(){

    ll X, Y; cin >> X >> Y;

    int ans = 0;
    while(Y >= X){
        X *= 2;
        ans++;
    }

    cout << ans << endl;

}

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

#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
#define LL long long
#define pii pair <int,int>
#define fi first
#define se second
#define pb push_back
#define mpr make_pair

using namespace std;

const LL MOD=1e9+7;

int main()
{
	LL n,ans=0;
	cin>>n;
	repn(i,n) if(i%3>0&&i%5>0) ans+=(LL)i;
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3620
#include <iostream>
#include <vector>
#define rep(i,n) for(int i=0;i<(n);i++)
typedef long long ll;
using namespace std;
int N, K;
vector<long long> P(5000), C(5000);

int main() {

  cin >> N >> K;
  
  rep(i,N) {
    cin >> P[i];
    --P[i];
  }
  rep(i,N) cin >> C[i];
  
  long long ans =  -1e18;
  // 始点を全て試す
  rep(i, N) {
    //　一周期試す
    vector<int> list; // 周期のコストリスト
    int now = i;
    ll cycle_sum = 0; // 一周期の合計
    for (;;) {
      cycle_sum += C[now];
      list.push_back(C[now]);
      now = P[now];
      if (now == i) break;
    }
    
    // 周期を回して答えを更新する
    ll cycle = 0;
    for (int j = 0; j < list.size(); j++) {
      if (j >= K) break;
      cycle += list[j];
      ll cycle_ans = cycle;
      
      if (cycle_sum > 0) {
        ll e = (K - j - 1) / list.size();
        cycle_ans += e * cycle_sum;
      }
      ans = max(cycle_ans, ans);
    }
  }
  
  cout << ans;
}

Measured memory_bytes: 3716
#!/usr/bin/ruby
ENV[Z='RUBY_THREAD_VM_STACK_SIZE']||exec({Z=>?5*8},'ruby',$0)
def dfs(c)
	f=false
	$h[c].each{|d|
		if $v[d]==0
			$v[d]=3-$v[c]
			f=true if dfs(d)
		elsif $v[d]==$v[c]
			f=true
		end
	}
	f
end
n,m=gets.split.map &:to_i
$h=Hash.new{|h,k|h[k]=[]}
m.times{a,b=gets.split.map &:to_i;$h[a-1]<<b-1;$h[b-1]<<a-1}
$v=Hash.new 0
a=b=c=0
n.times{|i|
	next if $v[i]>0
	if $h[i].empty?
		c+=1
	else
		$v[i]=1
		if dfs(i)
			b+=1
		else
			a+=1
		end
	end
}
p a*a*2+a*b*2+b*b+(n*n-(n-c)*(n-c))

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

int main(){
    int buildings[4][3][10] = {};
    int n;
    cin >> n;
    for(int i = 0; i < n; i++){
        int b, f, r, v;
        cin >> b >> f >> r >> v;
        buildings[b-1][f-1][r-1] += v;
        //cout << buildings[b-1][f-1][r-1] << endl;
    }
    for(int i = 0; i < 4; i++){
        for(int j = 0; j < 3; j++){
            for(int k = 0; k < 10; k++){
                cout << " " << buildings[i][j][k];
            }
            cout << endl;
        }
        if(i < 3)cout << "####################" << endl;
    }
}


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

#define      pb    push_back
#define      ff    first
#define      ss    second
#define      ll    long long int
#define      endl  "\n"
#define      FASTIO        ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);


#define      TEST    int t ; cin >> t ; while( t -- )

const ll big = 10e10 + 11 ;

int  main (  ) {

    FASTIO ;

    ll  n , Max = -big ;
    cin >> n ;

    map < string , int > mp ;

    for( int i = 0 ; i < n ; i++ ){
        string s ;
        cin >> s ;

        mp[ s ]++ ;

        if(mp[ s ] > Max ) Max = mp[ s ] ;
    }

    for( auto it = mp.begin( ) ; it != mp.end( )  ; it++ ){
        if( it->second == Max ) cout << it->first <<  endl ;
    }



    return  0 ;
}



Measured memory_bytes: 23808
#include<bits/stdc++.h>
#define boost ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define ll long long int
#define mem(a,b) memset(a,b,sizeof(a))
#define endl "\n"
#define mod 1000000007
#define PI 3.1415926535897932384626
#define pq priority_queue
#define pb push_back
#define mp make_pair
using namespace std;
/*
int gcd(int x,int y)
{
    if(x%y==0)
    return y;
    return gcd(y,x%y);
}

int no1(int x)
{
    int count=0;
    while(x)
    {
        if(x%2)
        count++;
        x=x>>1;
    }
    return count;
}
ll power(int  b,int p)
{
    if(p==0)
    return 1;
    ll temp=power(b,p/2);
    temp=temp*temp;
    if(p%2==1)

    temp=temp*b;
    return temp;
}
bool cmp(const pair<int, pair<int,int> > & p1,const pair<int, pair<int,int> > & p2)
{
    if(p1.first>p2.first)
        return true;
    if(p1.first==p2.first&&p1.second.first<p2.second.first)
        return true;
    return false;
}
*/
ll dp[102][100005];
ll value(int x,int nw,int n,int w[],int v[])
{
    if(x>n)
        return 0;
    if(dp[x][nw]!=-1)
        return dp[x][nw];
    if(nw>=w[x])
        dp[x][nw]=max(value(x+1,nw,n,w,v),v[x]+value(x+1,nw-w[x],n,w,v));
    else
        dp[x][nw]=value(x+1,nw,n,w,v);
    return dp[x][nw];
}
int main()
{
    int n,nw;
    cin>>n>>nw;
    for(int j=0;j<102;j++)
    for(int i=0;i<100005;i++)
        dp[j][i]=-1;
    int w[102],v[102];
    for(int i=1;i<=n;i++)
        cin>>w[i]>>v[i];
    cout<<value(1,nw,n,w,v);
    return 0;

}


Measured memory_bytes: 80000
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;

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

int main()
{
int n;
cin>>n;
int x=n*800;
int y=200*(n/15);
cout<<x-y<<endl;
}

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

int main(){
	int n,p,old,maxlen,len; cin>>n;
	cin>>old; maxlen=0; len=0;
	for(int h=0; h<n-1; h++) {
	    cin>>p; 
	    if (p<=old) len+=1;
        else { maxlen=max(maxlen,len); len=0; }	
        old=p;
	}
	maxlen=max(len,maxlen);
	cout<<maxlen;
    return 0;
}



Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define FOR(i,a,b) for(int i=(a); i<=(b); i++) 
#define rep(i,n); for(int i = 0; i < (n); i++)
#define chmin(a,b) if((a)>(b)) (a)=(b); 
#define chmax(a,b) if((a)<(b)) (a)=(b);
#define vi vector<int>
#define all(v) (v).begin(),(v).end()
int gcd(int a,int b){/*a>=0,b>=0,￢(a=b=0)*/
  while(min(a,b)>0){if(a<b)swap(a,b);a%=b;}return max(a,b);
}
int dx[]={0,1,0,-1,1,-1,-1,1};
int dy[]={1,0,-1,0,1,1,-1,-1};
const int MOD = 1e9+7;
const int INF = 1e18+10;

/*----------------------------------------------*/

signed main(){
  int n;
  string s;
  cin>>n>>s;
  int ans=0;
  rep(i,n-2){
    string t;
    t+=s[i];
    t+=s[i+1];
    t+=s[i+2];
    if(t=="ABC") ans++;
  }

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


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <sstream>
#include <stdio.h>
#include <string.h>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cmath>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cctype>
using namespace std;

int main(){
  int N = 0;
  cin >> N;
  vector<int> len(N);
  for(int i = 0;i < N;i++){
    cin >> len.at(i);
  }
  int judge = 1;
  int now = len.at(N - 1);
  for(int i = N - 2;i >= 0;i--){
    if(len.at(i) <= now){
      now = len.at(i);
    }else{
      if(len.at(i) - 1 <= now){
        len.at(i) -= 1;
        now = len.at(i);
      }else{
        judge = 0;
        break;
      }
    }
  }
  if(judge){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 3784
let for_range s e step f =
  let rec loop i =
    if i <= e then begin f i;loop (i + step) end
  in loop s;;

let sieve num =
  let p = Array.make (num+1) 1 in
  let rec loop i =
    if i*i < num then
      begin
        if p.(i) = 1 then for_range (i*i) num (i*2) (fun x -> p.(x) <- 0);
        loop (i+2)
      end
  in
  p.(0) <- 0; p.(1)<-(0); for_range 4 num 2 (fun x -> p.(x) <- 0);loop 3;
  for i = 3 to num-1 do
    p.(i) <- p.(i) + p.(i-1);
  done;
  p
;;

let _ =
  let p = sieve 1000000 in
  let rec read () =
    try let n = read_int () in
        Printf.printf "%d\n" p.(n);
        read ()
    with End_of_file -> ()
  in read ()
;;

Measured memory_bytes: 10328
import itertools
import math
def dis(a, b):
    return math.sqrt((a[0]-b[0])**2 + (a[1]-b[1])**2)
def main():
    N = int(input())
    l = []
    for _ in range(N):
        l.append(tuple(map(int, input().split())))
    n = [i for i in range(N)]
    total = 0
    for j in itertools.permutations(n):
        s = None
        e = None
        #d = 0
        for k in j:
            e = l[k]
            if s is None:
                s = e
                continue
            total += dis(s, e)
            s = e
    totaln = 1
    for i in range(2,N+1):
        totaln *= i
    return(total/totaln)
print(main())


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

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

    for (int i = 0; i < N; i++)
    {
        int A;
        cin >> A;
        sum += A;
    }

    if (sum >= H)
    {
        cout << "Yes" << endl;
    }

    else
    {
        cout << "No" << endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rep2(j,n) for(int j = 0; j < (n); ++j)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define drep2(j,n) for(int j = (n)-1; j >= 0; --j)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define srep2(j,s,t) for (int j = s; j < t; ++j)
#define srep3(k,s,t) for (int k = s; k < t; ++k)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define dame { puts("-1"); return 0;}
#define yn {puts("YES");}else{puts("NO");}

v(ll) p(51);
v(ll) a(51);

ll dfs(ll N,ll X)  {
  if(N==0) {
    if(X > 0) return 1;
    return 0;
  }
  if(X <= 1) return 0;
  if(X <= 1 + a[N-1]) return dfs(N-1,X-1);
  return 1 + p[N-1] + dfs(N-1,X-2-a[N-1]);
}

int main() {
  ll N,X;
  cin >> N >> X;
  a[0] = 1;
  p[0] = 1;
  srep(i,1,51){
    a[i] = 3 + 2 * a[i-1];
    p[i] = 1 + 2 * p[i-1];
  }
  cout << dfs(N,X) << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <math.h>
#define _GLIBCXX_DEBUG
#define _LIBCPP_DEBUG 0

using namespace std;
#define ll long long
#define rep(i,n) for (int i = 0; i < n; i++)
#define MOD (1000000007)
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int, int>
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()

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

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

const ll INF = 1LL << 60;

int main(){
  int n,z,w; cin >> n >> z >> w;
  vi a(n); rep(i, n) cin >> a[i];
  int ans = abs(a[n-1]-w);
  if(n > 1) chmax(ans, abs(a[n-2]-a[n-1]));
  std::cout << ans << '\n';
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    int a,b;
    
    while(true){
        cin >> a >> b;
        
        if (a==0 and b==0) {
            break;
        }else if (a<b) {
            cout << a <<" "<< b <<endl;
        }else{
            cout << b <<" "<< a <<endl;

        }
    }
}


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

int main() {
  int N,K;
  cin >> N >> K;
  int keizi = 1;
  
  for ( int i = 0; i < N; i++ ){
    if( keizi < K ){
      keizi *= 2;
    }else{
      keizi += K;
    }
  }
  cout << keizi << endl;
  
  
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(long long i=0;i<x;i++)
#define repn(i,x) for(long long i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
vector<pair<string,P> >vec;
// vector<vector<int>> data(3, vector<int>(4));


int main(){	
	long long Q;
	long long K;
	long long N;
	scanf("%lld",&N);
	scanf("%lld",&K);
	scanf("%lld",&Q);
	vector<long long> A(Q-1+1);
	map<ll, ll> m;
	for(int i = 0 ; i <= Q-1 ; i++){
		scanf("%lld",&A[i]);
		A[i]--;
		m[A[i]]++;
	}
	ll res = 0;
	rep(i,N) {
		if (K-(Q-m[i])>0) cout << "Yes" << endl; else cout << "No" << endl;
	}
	return 0;
}



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

int main(){
	int N, K;
	cin >> N >> K;
	string S;
	cin >> S;
	vector<int> Nums;
	int cnt=0;
	int now=1;
	for(int i = 0; i < N; i++) 
	{
		if(S.at(i) == (char)('0' + now)) cnt++;
		else
		{
			Nums.push_back(cnt);
			cnt = 1;
			now = 1 - now;
		}
	}
	if(cnt != 0) Nums.push_back(cnt);
	if(Nums.size() % 2 == 0) Nums.push_back(0);
	
	int Add = 2 * K + 1;

	vector<int> sum(Nums.size() + 1);
	for(int i = 0; i < Nums.size(); i++) 
	{
		sum.at(i + 1) = sum.at(i) + Nums.at(i);
	}
	
	int ans = 0;

	for(int i = 0; i < Nums.size(); i += 2) 
	{
		int left = i;
		int right = min(i + Add, (int)Nums.size());
		int tmp = sum.at(right) - sum.at(left);
        ans = max(tmp, ans);
	}

	cout << ans <<endl;	
}

Measured memory_bytes: 1272
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define rep0(a,b) for(int a=0;a<b;a++)
#define rep1(a,b) for(int a=1;a<b;a++)
#define repp(a,b,c) for(int a=b;a<c;a++)
#define rev(a,b,c) for(int a=b;a>=c;a--)
#define in insert
#define len length()
#define si size()
#define lb lower_bound
#define ub upper_bound
#define beg begin()
#define end end()
#define vec vector<ll>
#define se set<ll>
#define mults multiset<ll>
#define F first
#define S second
#define pr(a) cout<<a
#define pr2(a,b) cout<<a<<" "<<b
#define get(a) cin>>a
#define nextl cout<<endl
const ll mod = 1000000007;
const ll maxn = 500005;
const ll mm = 1e+18;
ll power(ll x, ll y)
{
    ll res = 1;
    x = x % mod;
    while (y > 0)
    {
        if (y & 1)
            res = (res*x) % mod;
        y = y>>1;
        x = (x*x) % mod;
    }
    return res;
}
ll ncr(ll n, ll k)
{
    ll C[k+1];
    memset(C, 0, sizeof(C));

    C[0] = 1;

    for (ll i = 1; i <= n; i++)
    {
        for (ll j = min(i, k); j > 0; j--)
            C[j] = (C[j] + C[j-1])%mod;
    }
    return C[k];
}
int primeFactors(ll n)
{
    // Print the number of 2s that divide n
    se s;
    while (n % 2 == 0)
    {
        s.in(2);
        n = n/2;
    }

    // n must be odd at this point. So we can skip
    // one element (Note i = i +2)
    for (ll i = 3; i <= sqrt(n); i = i + 2)
    {
        // While i divides n, print i and divide n
        while (n % i == 0)
        {
            s.in(i);
            n = n/i;
        }
    }

    // This condition is to handle the case when n
    // is a prime number greater than 2
    if (n > 2)
        s.in(n);
        return s.si+1;
}
void solve()
{
   ll x,y;
   cin>>x>>y;
   ll z=__gcd(x,y);
   pr(primeFactors(z));
}
int main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int t=1;
    //cin>>t;
    while(t--){
        solve();
       // nextl;
    }
    return 0;
}


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

ll f[nn*nn],rf[nn*nn];
ll qpow(ll x,ll y)
{
	ll res=1;
	while(y)
	{
		if(y&1) res=res*x%mod;
		x=x*x%mod;y=y/2;
	}
	return res;
}
ll c(ll x,ll y)
{
	if(x>y)  return 0;
	return f[y]*rf[x]%mod*rf[y-x]%mod;
}

ll dp[nn][nn];ll n,k;
int main()
{
	f[0]=1;for(int i=1;i<nn*nn;i++) f[i]=f[i-1]*i%mod;
	rf[nn*nn-1]=qpow(f[nn*nn-1],mod-2);
	for(int i=nn*nn-2;i>=0;i--) rf[i]=rf[i+1]*(i+1)%mod;

	cin>>n>>k;k--;
	if(k==0)
	{
		cout<<1;
		exit(0);
	}
	dp[0][0]=1;
	for(int i=0;i<=n;i++)
	{
		for(int j=0;j<=i;j++)
		{
			dp[i+1][j]+=dp[i][j];
			dp[i+1][j]%=mod;
			dp[i][j+1]+=dp[i][j]*c(k-1,n*k+n-k*j-i-1);
			dp[i][j+1]%=mod;
		}
	}
	
	cout<<dp[n][n]*f[n]%mod;
	return 0;
} 

Measured memory_bytes: 92672
#include"bits/stdc++.h"
//#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=a;i<b;i++)
#define print(x) cout<<x<<endl;
typedef long long ll;

int main() {
	int n;
	int a[100002];
	vector<int> v;
	int mod = 1000000007;
	cin >> n;
	ll ans = 1;
	rep(i, 0, n)cin >> a[i];
	sort(a, a + n);
	int start = 0;
	rep(i, 0, 5) {
		if (a[i] != 0) {
			start = i;
			break;
		}
	}
	if(count(a, a + n, 0) > 1){
		print(0);
		return 0;
	}
	for (int i = start; i < n;i+=2) {
		if (a[i]!=a[i+1]) {
			print(0);
			return 0;
		}
	}
	rep(i, 0, 3) {
		if (a[i] != 0) {
			start = i;
			break;
		}
	}
	ll mul = (n - start)/2;
	rep(i, 0, mul) {
		ans *= 2;
		ans %= mod;
	}
	print(ans);
}

Measured memory_bytes: 640
#include <iostream>
#include <queue>

#define debug(x) std::cout << #x << " = " << (x) << std::endl;

using namespace std;
using ll = long long;
using pll = pair<ll, ll>;

int main()
{
    ll num, dist, dmg;
    cin >> num >> dist >> dmg;

    priority_queue< pll, vector<pll>, greater<pll> > min_heap;

    for(ll i=0; i<num; i++)
    {
        ll pos, life;
        cin >> pos >> life;

        min_heap.push({pos, life});
    }

    ll total_hits  = 0;
    ll acc_dmg = 0;
    queue<pll> log;

    while(!min_heap.empty())
    {
        auto [pos, life] = min_heap.top();
        min_heap.pop();

        while(log.size())
        {
            auto [dmg_area, qtd_bombs] = log.front();

            // this bomb did not hit this region
            if(dmg_area <  pos) {
                log.pop();
                acc_dmg -= dmg * qtd_bombs;
            }

            else break;
        }

        // rightmost position that hits the target
        ll dmg_limit_area = pos + dist + dist;

        // subtracting dmg from bombs exploded in the region
        life -= acc_dmg;
        if(life <= 0) continue;

        // ceil division (without overflow)
        ll hits_need = 1 + ((life - 1)/dmg);

        total_hits += hits_need;

        // Accumulated dmg from previous bombs that exploded in this region
        acc_dmg += dmg * hits_need;


        // remeber how many bombs exploded at this region
        log.push({dmg_limit_area, hits_need});
    }

    cout << total_hits << '\n';

    return 0;
}


Measured memory_bytes: 7900
#include <algorithm>
#include <cstdlib>
#include<iostream>
#include<vector>
#include<map>
#include<cmath>
using namespace std;
int x,y;
int main(int argc, char const *argv[])
{
    cin>>x>>y;
    if(x==1||x==3||x==5||x==7||x==8||x==10||x==12){
        if(y==1||y==3||y==5||y==7||y==8||y==10||y==12){
            cout<<"Yes"<<endl;
        }else{
            cout<<"No"<<endl;
        }
    }else if(x==4||x==6||x==9||x==11){
        if(y==4||y==6||y==9||y==11){
            cout<<"Yes"<<endl;
        }else{
            cout<<"No"<<endl;
        }
    }else{
        cout<<"No"<<endl;
    }
return 0;
}


Measured memory_bytes: 256
N=int(input())
h=list(map(int,input().split()))
INF = 10**4+1
dp = [INF]*N
dp[0] = 0
dp[1] = abs(h[1]-h[0])
for i in range(2,N):
  dp[i] = min(dp[i-1]+abs(h[i]-h[i-1]), dp[i-2]+abs(h[i]-h[i-2]))
print(dp[N-1])

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

//#define lp_i(k,n)  for(int i = (k); i < (n); i++)
//#define lp_j(k,n)  for(int j = (k); j < (n); j++)
//#define lp_ui(k,n) for(uint32_t i = (k); i < (n); i++)
//#define lp_uj(k,n) for(uint32_t j = (k); j < (n); j++)
//
//typedef uintmax_t    ull;
//typedef intmax_t     ll;
typedef uint64_t     ul;
typedef uint32_t     ui;
//typedef uint8_t      uc;

using namespace std;

int main(void)
{
	ui N{ 0 };
	cin >> N;

	vector<ul> arrayA(N, 0);
	ul sum{ 0 };
	ul halfSum{ 0 };

	for (ui i = 0; i < N; ++i)
	{
		cin >> arrayA[i];

		sum += arrayA[i];
		if (i % 2 == 0)
		{
			halfSum += arrayA[i];
		}
	}

	// X_0の導出
	ul ans = halfSum * 2 - sum;
	cout << ans << " ";

	for (ui i = 0; i < N - 1; ++i)
	{
		// X_i = A_i * 2 - X_(i-1)
		ans = arrayA[i] * 2 - ans;
		cout << ans << " ";

		//if (i != N - 2)
		//{
		//	cout << " ";
		//}
	}
	//cout << endl;

	return 0;
}


Measured memory_bytes: 2048
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
ll MOD = 1e9+7;

#define vec vector<int>
#define vecll vector<ll>
#define vpair vector<pair<int, int>>
#define vpairll vector<pair<ll, ll>>

#define rep(i,n)         for(int i=(int)0; i<(int)n; i++)
#define REP(i,m,n)       for(int i=(int)m; i<(int)n; i++)
#define arr(var, n)      vec var(n); rep(i,n){cin >> var[i];}
#define arrll(var, n)    vecll var(n); rep(i,n){cin >> var[i];}
#define all(var)         (var).begin(), (var).end()
#define sortall(var)     sort(all(var))
#define prt(var)         cout << var << endl
#define prtd(n, var)     cout << fixed << setprecision(n) << var << endl
#define prt2(v1, v2)     cout << v1 << " " << v2 << endl
#define prt3(v1, v2, v3) cout << v1 << " " << v2 << " " << v3 << endl
#define prtall(var)      rep(i,var.size()){cout << var[i] << " ";} cout << endl

//----------------------------------------------------------------
const int MAX = 1200000;
// fac[n] = n! % MOD, finv[n] = (n!)^-1 % MOD, inv[n] = n^-1 % MOD
ll fac[MAX], finv[MAX], inv[MAX];

// make table for binomial coefficient
void bcinit(){
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  REP(i,2,MAX){
    fac[i] = fac[i-1] * i % MOD;
    inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
    finv[i] = finv[i-1] * inv[i] % MOD;
  }
}

ll nCr(int n, int r){
  if(n<r){return 0;}
  if(n<0 || r<0){return 0;}
  return fac[n] * (finv[r] * finv[n-r] % MOD) % MOD;
}

int main(void) {
  ll x, y;
  cin >> x >> y;

  if((x+y)%3!=0){
    prt(0); return 0;
  }

  bcinit();

  ll n=(x+y)/3;
  x-=n; y-=n;

  prt(nCr(n,x));

}


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

int main() {
  int A,B,C,D;
  cin >> A>>B>>C;
D=C-(A-B);
  if (D > 0) {
  cout<<D<< endl;
  }
  else if(D <= 0){
  cout<<0<<endl;
  }
}



Measured memory_bytes: 256
import sys
def MI(): return map(int,sys.stdin.readline().rstrip().split())

N,M = MI()
S,T = MI()
edges = [[] for _ in range(N+1)]
edges2 = []
for _ in range(M):
    U,V,D = MI()
    edges[U].append((V,D))
    edges[V].append((U,D))
    edges2.append((U,V,D))
    edges2.append((V,U,D))

mod = 10**9+7

from heapq import heappop,heappush

distS = [(10**18,0)]*(N+1)  # (最短距離,経路数)
distS[S] = (0,1)
qS = []
heappush(qS,(0,S))
vS = [False]*(N+1)
while qS:
    d,i = heappop(qS)
    if vS[i]:
        continue
    vS[i] = True
    for j,d in edges[i]:
        if vS[j]:
            continue
        if distS[j][0] > distS[i][0] + d:
            distS[j] = (distS[i][0] + d,distS[i][1])
            heappush(qS,(distS[i][0] + d,j))
        elif distS[j][0] == distS[i][0] + d:
            distS[j] = (distS[j][0],distS[j][1]+distS[i][1])
            heappush(qS,(distS[i][0] + d,j))

distT = [(10**18,0)]*(N+1)
distT[T] = (0,1)
qT = []
heappush(qT,(0,T))
vT = [False]*(N+1)
while qT:
    d,i = heappop(qT)
    if vT[i]:
        continue
    vT[i] = True
    for j,d in edges[i]:
        if vT[j]:
            continue
        if distT[j][0] > distT[i][0] + d:
            distT[j] = (distT[i][0] + d,distT[i][1])
            heappush(qT,(distT[i][0] + d,j))
        elif distT[j][0] == distT[i][0] + d:
            distT[j] = (distT[j][0],distT[j][1]+distT[i][1])
            heappush(qT,(distT[i][0] + d,j))

a,b = distS[T]  # SからTまでの最短距離,経路数
ans = b**2 % mod

# 頂点で出くわす場合
if a % 2 == 0:
    for i in range(1,N+1):
        if distS[i][0] == distT[i][0] == a//2:
            ans -= (distS[i][1]*distT[i][1])**2
            ans %= mod

# 辺上で出くわす場合
for i in range(2*M):
    U,V,D = edges2[i]
    if distS[U][0] < (a+1)//2 and distT[V][0] < (a+1)//2 and a == distS[U][0] + D + distT[V][0]:
        ans -= (distS[U][1]*distT[V][1])**2
        ans %= mod

print(ans)


Measured memory_bytes: 214000
N = int(input())
S = []
for i in range(N):
    S.append(input())

print('AC x {}'.format(S.count('AC')))
print('WA x {}'.format(S.count('WA')))
print('TLE x {}'.format(S.count('TLE')))
print('RE x {}'.format(S.count('RE')))


Measured memory_bytes: 16148
#include<iostream>
#include<map>
#include<string>
#include<cmath>
#include<cstdio>
#include<queue>
#include<set>
#include<algorithm>
#include<vector>
using namespace std;
struct Node
{
	int head,low,dfn;
}node[55];
struct Edge
{
	int next,to;
}edge[5005];
int n,m,cnt,root,deep;
int ans;
void addEdge(int u,int v)
{
	edge[++cnt].next=node[u].head;
	node[u].head=cnt;
	edge[cnt].to=v;
}
void Tarjan(int u,int father)
{
	node[u].dfn=node[u].low=++deep;
	for(int e=node[u].head;e;e=edge[e].next)
	{
		int v=edge[e].to;
		if(!node[v].dfn)
		{
			Tarjan(v,u);
			node[u].low=min(node[u].low,node[v].low);
			if(node[u].dfn<node[v].low)ans++;
		}
		else if(v!=father)
		{
			node[u].low=min(node[u].low,node[v].dfn);
		}
	}
}
int main()
{
	scanf("%d%d",&n,&m);
	for(int i=1,a,b;i<=m;i++)
	{
		scanf("%d%d",&a,&b);
		addEdge(a,b);
		addEdge(b,a);
	}
	for(int i=1;i<=n;i++)
	{
		if(!node[i].dfn)
		{
			root=i;
			Tarjan(i,root);
		}
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
int main()
{
	char S[10];
	scanf("%s", S);
 
	int ans = 0;
	for (int i = 0; i < 4; ++i) {
		if (S[i] == '+') ++ans;
		else --ans;
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<utility>
#include<set>
#include<stack>
#include<queue>
#include<deque>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<bitset>
#include<sstream>
#include<list>
#include<climits>

using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define nrep(i,i0,n) for(int i=(i0);i<(int)(n);++i)
typedef vector<int> vi; typedef pair<int,int> pii; typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vii;
typedef long long ll;


int main(){
	int c[3][3];
	rep(i,3)rep(j,3)cin>>c[i][j];
	bool flag=true;
	rep(i,101){
		int a1=i,b1=c[0][0]-a1,b2=c[0][1]-a1,b3=c[0][2]-a1,a2=c[1][0]-b1,a3=c[2][0]-b1;
		if(a2+b2==c[1][1]&&a2+b3==c[1][2]&&a3+b2==c[2][1]&&a3+b3==c[2][2])continue;
		else flag=false;
	}
	string ret=flag?"Yes":"No";
	cout<<ret<<endl;
	return 0;
}



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

char number[20];
int L;
int DP[20];

int main () {
	scanf (" %s ", number);
	L = strlen (number);
	long long sum = 0;
	for (int i = 0; i < (1 << (L - 1)); ++i) {
		long long cur = 0;
		for (int j = 0; j < L; ++j) {
			cur = cur * 10 + number[j] - '0';
			if (((i >> j) & 1) == 1) {
				sum += cur;
				cur = 0;
			}
		}
		sum += cur;
	}
	printf ("%lld\n", sum);
}



Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<set>
#include<queue>
using namespace std ;

#define MAXN 2007

int n , k , tot ;
int a[ MAXN ] ;
bool fl[ MAXN ] ;

priority_queue < int > q ;

void input ( ) {
    scanf ( "%d%d%d" , &n , &k , &tot ) ;
    int i ;
    for ( i = 1 ; i <= n ; i ++ ) {
        scanf ( "%d" , &a[ i ] ) ;
    }
}

void solve ( ) {
    int i , j ;
    int ans = -1 ;
    for ( i = 1 ; i <= n ; i ++ ) {
        for ( j = 1 ; j <= n ; j ++ ) {
            if ( a[ j ] < a[ i ] ) { fl[ j ] = false ; }
            else { fl[ j ] = true ; }
        }
        priority_queue < int > aux ;
        for ( j = 1 ; j <= n ; j ++ ) {
            if ( fl[ j ] == false ) {
                if ( aux.size ( ) >= k ) {
                    int h = aux.size ( ) - k + 1 ;
                    while ( h > 0 ) {
                        q.push ( aux.top ( ) ) ;
                        aux.pop ( ) ;
                        h -- ;
                    }
                }
                while ( aux.empty ( ) == false ) { aux.pop ( ) ; }
            }
            else {
                aux.push ( -a[ j ] ) ;
            }
        }
        if ( aux.size ( ) >= k ) {
            int h = aux.size ( ) - k + 1 ;
            while ( h > 0 ) {
                q.push ( aux.top ( ) ) ;
                aux.pop ( ) ;
                h -- ;
            }
        }
        while ( aux.empty ( ) == false ) { aux.pop ( ) ; }
        if ( q.size ( ) < tot ) {
            while ( q.empty ( ) == false ) { q.pop ( ) ; }
        }
        else {
            int h = tot ;
            int mn , mx ;
            while ( h > 0 ) {
                if ( h == tot ) { mn = -q.top ( ) ; }
                if ( h == 1 ) { mx = -q.top ( ) ; }
                h -- ; q.pop ( ) ;
            }
            while ( q.empty ( ) == false ) { q.pop ( ) ; }
            if ( ans < 0 ) { ans = ( mx - mn ) ; }
            if ( ans > ( mx - mn ) ) { ans = ( mx - mn ) ; }
        }
    }
    printf ( "%d\n" , ans ) ;
}

int main ( ) {
    input ( ) ;
    solve ( ) ;
    return 0 ;
}


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

using namespace std;

int main(){
	long long n;
	cin >> n;
	long long a[n];
	long long b[n];
	for(int i = 0; i < n; i ++){
		cin >> a[i];
		b[i] = a[i]-(i+1);
	}
	sort(b, b+n);
	int min = b[0];
	min = b[(int)ceil(n/2)];
	long long sum = 0;
	for(int i = 0; i < n; i ++){
		sum += abs(a[i]-(min+(i+1)));
	}
	
	cout << sum << endl;
	
	return 0;
}

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

int main() {
	
	int a,b,k,l = 0;
	cin>>a>>b>>k;
	
	for(int i = min(a,b); i >= 1; i--)
	{
		if(a % i == 0 and b % i == 0)
		{
			l++;
		}
		if(l == k)
		{
			cout<<i;
			return 0;
		}
	}
	
	return 0;
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;

const ll INF = 1LL << 60;
const int MOD = 1e9 + 7;

#define pb push_back
#define mp make_pair
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REPR(i, b, e) for (int i = (b); i <= (e); i++)
#define DEBUG(x) cout << #x << ": " << (x) << endl
#define DEBUGA(a) cout << #a << ": "; for (const auto& v: (a)) cout << v << endl


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

    int ans;
    if (A >= 13) ans = B;
    else if (A >= 6) ans = B/2;
    else ans = 0;

    cout << ans << endl;

    return 0;
}


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

typedef int_fast32_t int32;
typedef int_fast64_t int64;

const int32 inf = 1e9+7;
const int32 MOD = 1000000007;
const int64 llinf = 1e18;

#define YES(n) cout << ((n) ? "YES\n" : "NO\n"  )
#define Yes(n) cout << ((n) ? "Yes\n" : "No\n"  )
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE\n" : "IMPOSSIBLE\n"  )
#define ANS(n) cout << (n) << "\n"
#define REP(i,n) for(int64 i=0;i<(n);++i)
#define FOR(i,a,b) for(int64 i=(a);i<(b);i++)
#define FORR(i,a,b) for(int64 i=(a);i>=(b);i--)
#define all(obj) (obj).begin(),(obj).end()
#define rall(obj) (obj).rbegin(),(obj).rend()
#define fi first
#define se second
#define pb(a) push_back(a)
typedef pair<int32,int32> pii;
typedef pair<int64,int64> pll;

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

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int32 d,t,s;
  cin >> d >> t >> s;
  Yes(s * t >= d);
  return 0;
}

Measured memory_bytes: 3636
#include <iostream>
#include<algorithm>
#include<sstream>
#include<cmath>
#include<vector>
#include<iomanip>
#include<map>
#include<set>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i = 0; i < n;i++)
int main(void) {
	int n;double sum = 0;cin >> n;
	vector<double> a(n);rep(i, n) cin >> a[i];
	sort(a.begin(), a.end());
	sum = (a[0] + a[1]) / 2;
	if (n == 2) {
		cout << sum << endl;
		return 0;
	}
	for (int i = 2;i < n;i++) {
		sum = (sum + a[i]) / 2;
	}
	cout << fixed << setprecision(10) << sum << endl;
}

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

int main(){

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

    long long x,cnt=0,cur=100;
    cin>>x;
    while(cur<x){
        cur+=cur/100;
        cnt++;
    }
    cout<<cnt<<endl;

    return 0;
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define P pair<ll,ll>
#define FOR(I,A,B) for(ll I = int(A); I < int(B); ++I)
#define FORR(I,A,B) for(ll I = int((B)-1); I >= int(A); --I)
#define TO(x,t,f) ((x)?(t):(f))
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //xi>=v  x is sorted
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //xi>v  x is sorted
#define NUM(x,v) (POSU(x,v)-POSL(x,v))  //x is sorted
#define REV(x) (reverse(x.begin(),x.end())) //reverse
ll gcd(ll a,ll b){if(a<b)swap(a,b);if(a%b==0)return b;return gcd(b,a%b);}
ll lcm(ll a,ll b){ll c=gcd(a,b);return ((a/c)*(b/c)*c);}//saisyo kobaisu
#define NEXTP(x) next_permutation(x.begin(),x.end())
const ll INF=1e18+7;
const ll MOD=1e9+7;


int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	int m,k;
	cin >> m >> k;
	if(k>=(1<<m)){
		cout << -1 << endl;
		return 0;
	}
	if(k==0){
		cout << 0 << ' ' << 0;
		FOR(i,1,(1<<m)){
			cout << " " << i << " " << i;
		}
		cout << endl;
		return 0;
	}
	if(m==1){
		cout << -1 << endl;
		return 0;
	}
	cout << k ;
	FOR(i,0,(1<<m)){
		if(i!=k){
			cout << ' ' << i;
		}
	}
	cout << ' ' << k;
	FORR(i,0,(1<<m)){
		if(i!=k)cout << ' ' << i;
	}
	cout << endl;
}

Measured memory_bytes: 1792
while True:
    H,W = map(int,raw_input().split())
    if H == 0 and W == 0:
        break
    a = "#"
    b = "."
    for i in xrange(0,H):
        if i == 0 or i == H-1:
            print a * W
        else: 
            c = W - 2
            print a+b*c+a
    print ""

Measured memory_bytes: 4208
using System;
using System.Collections.Generic;
using System.Text;


namespace ConsoleApplication7
{
    class Program
    {
        static void Main(string[] args)
        {
           
            string[] s = Console.ReadLine().Split(' ');

            int a = int.Parse(s[0]);
            int b = int.Parse(s[1]);

            int d = a / b;
            int r = a % b;
            double f = (double)a / (double)b;

            Console.WriteLine(d + " " + r + " " + f.ToString("f8"));
            
        }
    }
}

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

int main() {
  string S;
  cin >> S;
  
  int count=0;
  for(int i=1; i < S.size(); i++)
  {
    if(S.at(i) == S.at(i-1)) {
      ++count;
      if(S.at(i) == '0') S.at(i) ='1';
      else S.at(i)='0';
    }
  }
  cout << count<< endl;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define ll  long long
#define endl '\n'
#define FASTINOUT ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
const ll MOD = 1000000007;
const double PI = 3.141592653589793238463;
const ll N=2e5+9;
int main()
{
    FASTINOUT;
    ll a,b,c,x,y;
    cin>>a>>b>>c>>x>>y;
    int mn=min(x,y);
    ll ans=0;
    if (c*2<=a+b)
    {
        ans=c*2*mn;
        x-=mn,y-=mn;
        if (x)
        {
            if (c*2<=a)
                ans=ans+2*c*x;

            else
                ans+=a*x;

        }
        else if (y)
        {
            if (c*2<=b)
                ans=ans+2*c*y;

            else
                ans+=b*y;
        }
        cout<<ans<<endl;
    }
    else
        cout<<a*x+b*y<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include<string>
#include<iostream>
using namespace std;

int main(void)
{
	int i,j ;
	int flag = 1;
	string s[2];
	string s1, s2;
	cin >> s1;
	cin >> s2;

	reverse(s1.begin(), s1.end());
	if (s1 == s2)cout << "YES" << endl;
	else cout << "NO" << endl;
	
	return(0);
}

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

using namespace std;

int main(void){
    int n, a, b, c, d;
    string s;
    s.reserve(n);
    cin >> n >> a >> b >> c >> d;
    cin >> s;

    if(c < d){
        for(int i = a - 1; i <= d - 1; ++ i) if(s[i] == '#' && s[i + 1] == '#'){
            cout << "No" << endl;
            return 0;
        }
        cout << "Yes" << endl;
    }else{
        for(int i = b - 1; i <= d - 1; ++ i){
            if(s[i - 1] == '.' && s[i] == '.' && s[i + 1] == '.') break;
            if(i == d - 1){
                cout << "No" << endl;
                return 0;
            }
        }
        for(int i = a - 1; i <= c - 1; ++ i) if(s[i] == '#' && s[i + 1] == '#'){
            cout << "No" << endl;
            return 0;
        }
        
        cout << "Yes" << endl;
    }
    return 0;
}


Measured memory_bytes: 640
#include <iostream>
using namespace std;
int main() {
    int n, c = 0;
    string s;
    cin >> n >> s;
    int i, j = n - 1;
    for (i = 0; i < n; i++) {
        if (s[i] == 'W') {
            for (; j > i && s[j] != 'R'; j--);
            if (j > i) {
                swap(s[i], s[j]);
                c++;
            } else {
                break;
            }
        }
    }
    cout << c << endl;
}



Measured memory_bytes: 3748
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE BinaryLiterals #-}
{-# LANGUAGE MultiWayIf #-}
{-# LANGUAGE NumDecimals #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TupleSections #-}

import Control.Applicative
import Control.Arrow
import Control.Monad
import Control.Monad.ST

import Data.Char
import Data.List
import Data.Maybe

import qualified Data.ByteString.Char8 as B

import Data.Array.ST.Safe
import Data.STRef

import Debug.Trace
import Text.Printf

readInt = readLn :: IO Int
readInts = map ( fst . fromJust . B.readInt ) . B.words <$> B.getLine
readNInts = readInt >>= flip replicateM readInt

which a b f = if f then a else b
mp [ a, b ] = ( a, b )

main = do
	[ n, m ] <- readInts
	as <- replicateM n getLine
	bs <- replicateM m getLine
	putStrLn $ which "Yes" "No" $ or $ do
		i <- [ 0 .. n - m ]
		j <- [ 0 .. n - m ]
		return $ bs == cutOut i j m as

cutOut y x m = map ( cut x m ) . cut y m
	where
		cut z m = take m . drop z

Measured memory_bytes: 892
#include <iostream>
#include <cstdio>
#include <fstream>
#include <algorithm>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <limits.h>
#include <math.h>
#include <functional>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <float.h>
#include <random>

#define repeat(i,n) for (int i = 0; (i) < (n); ++ (i))
#define debug(x) cerr << #x << ": " << x << '\n'
#define debugArray(x,n) for(long long hoge = 0; (hoge) < (n); ++ (hoge)) cerr << #x << "[" << hoge << "]: " << x[hoge] << '\n'
#define debugArrayP(x,n) for(long long hoge = 0; (hoge) < (n); ++ (hoge)) cerr << #x << "[" << hoge << "]: " << x[hoge].first<< " " << x[hoge].second << '\n'

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> Pii;
typedef vector<int> vint;
typedef vector<ll> vll;
const ll INF = LLONG_MAX/10;
const ll MOD = 1e9+7;


int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N,M;cin>>N>>M;
  int maxL=0,minR=N+1;
  repeat(i,M){
    int L,R;cin>>L>>R;
    maxL = max(maxL,L);
    minR = min(minR,R);
  }
  cout<<(minR-maxL+1>=0?minR-maxL+1:0)<<endl;
  return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())

const ll mod = 1000000007;
int n,k;
ll a[25];
ll dp[25][1005];
ll modpow(ll x,ll n){
	ll res=1;
	while(n>0){
		if(n&1) res=res*x%mod;
		x=x*x%mod;
		n>>=1;
	}
	return res;
}
ll F[2005],R[2005];
void make(){
	F[0] = 1;
	for(int i=1;i<2005;i++) F[i] = F[i-1]*i%mod;
	for(int i=0;i<2005;i++) R[i] = modpow(F[i],mod-2);
}
ll C(int a,int b){
	return F[a]*R[b]%mod*R[a-b]%mod;
}
int main(){
	make();
	cin>>n>>k;
	repn(i,k) cin>>a[i];
	dp[0][0] = 1;
	rep(i,k){
		rep(j,n+1){
			if(dp[i][j] == 0) continue;
			for(int nxt=0;nxt<=n-j;nxt++){
				if(a[i+1] < nxt) break;
				if(n-j < nxt) break;
				dp[i+1][j+nxt] += dp[i][j] * C(n-j,nxt) % mod * C(n-nxt,a[i+1]-nxt) % mod;
				if(dp[i+1][j+nxt] >= mod) dp[i+1][j+nxt] -= mod;
			}
		}
	}
	cout << (dp[k][n]%mod+mod)%mod << endl;
}

Measured memory_bytes: 384
#include<cstdio>
#include<algorithm>
#include<cstring>
#define ll long long
using namespace std;
const ll MOD=1e9+7;
int n;
ll f[300005][9];
char s[300005];
int main()
{
	scanf("%s",s+1);
	n=(int)strlen(s+1);
	f[0][1]=1;
	for(int i=1;i<=n;i++)
	{
		if(s[i]!='1')
		{
			f[i][2]+=f[i-1][1]+f[i-1][3]+f[i-1][4];
			f[i][3]+=f[i-1][2];
			f[i][6]+=f[i-1][5]+f[i-1][7];
			f[i][7]+=f[i-1][6];
			f[i][8]+=f[i-1][8];
		}
		if(s[i]!='0')
		{
			f[i][2]+=f[i-1][3];
			f[i][4]+=f[i-1][2];
			f[i][5]+=f[i-1][1]+f[i-1][4]+f[i-1][6];
			f[i][6]+=f[i-1][7];
			f[i][8]+=f[i-1][5]+f[i-1][8];
		}
		f[i][1]%=MOD;
		f[i][2]%=MOD;
		f[i][3]%=MOD;
		f[i][4]%=MOD;
		f[i][5]%=MOD;
		f[i][6]%=MOD;
		f[i][7]%=MOD;
		f[i][8]%=MOD;
	}
	printf("%lld\n",(f[n][5]+f[n][8])%MOD);
	return 0;
}

Measured memory_bytes: 21504
import sys
input = sys.stdin.readline

def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

n = I()
mychr = input().rstrip()

result = float('inf')
red = 0
for i in mychr:
    if i == "R":
        red += 1

R = 0
W = 0

for index, i in enumerate(mychr):
    if i == "R":
        R+=1
    else:
        W+=1
    temp = max(W,red-R)
    result = min(result, temp)

if W != n:
    print(result)
else:
    print(0)

Measured memory_bytes: 73784