akhauriyash/Code-Regression huggingface dataset:
/*
これを入れて実行
g++ code.cpp
./a.out
 */

#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <cmath>
#include <tuple>
#include <iomanip>

using namespace std;
typedef long long ll;
typedef long double ld;

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

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

bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}

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

//-----------------------ここから-----------


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

	int ans = 0;

	for(int i = 0; i < n; i++){
		for(int j = 0; j < n; j++){
			if(i == j)continue;
			int tmp = abs(a[i] - a[j]);
			ans = max(ans, tmp);
		}
	}

	cout << ans << endl;
}



Measured memory_bytes: 256
n, k = map(int, input().split())
listS = list(input())
if k == 0:
    print(listS[0].lower()+"".join(listS[1:]))
elif k == n:
    print("".join(listS[:n-1])+listS[n-1].lower())
else:
    print("".join(listS[:k-1])+listS[k-1].lower()+"".join(listS[k:]))

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

#define ll long long
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define sc(x) scanf("%lld",&x)
#define pr(x) printf("%lld\n",x)
#define clr(x) memset(x, 0, sizeof(x))
#define all(x) x.begin(), x.end()
typedef pair<ll, ll> pii;
typedef vector< ll > vl;
typedef vector< pii > vpii;
const ll N= 1e5+55,mod = 1e9+7;
int main() {
// 	freopen("Task.in","r",stdin);freopen("Task.out","w",stdout);
 ll n,a,b,ans;
 sc(n);
 sc(a);
 ans=n*n-a;
 pr(ans);	
}

Measured memory_bytes: 256
//{
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double lf;
typedef pair<ll,ll> ii;
#define REP(i,n) for(ll i=0;i<n;i++)
#define REP1(i,n) for(ll i=1;i<=n;i++)
#define FILL(i,n) memset(i,n,sizeof i)
#define X first
#define Y second
#define SZ(_a) (int)_a.size()
#define ALL(_a) _a.begin(),_a.end()
#define pb push_back
#ifdef brian
#define debug(...) do{\
    fprintf(stderr,"%s - %d (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
    _do(__VA_ARGS__);\
}while(0)
template<typename T>void _do(T &&_x){cerr<<_x<<endl;}
template<typename T,typename ...S> void _do(T &&_x,S &&..._t){cerr<<_x<<" ,";_do(_t...);}
template<typename _a,typename _b> ostream& operator << (ostream &_s,const pair<_a,_b> &_p){return _s<<"("<<_p.X<<","<<_p.Y<<")";}
template<typename It> ostream& _OUTC(ostream &_s,It _ita,It _itb)
{
    _s<<"{";
    for(It _it=_ita;_it!=_itb;_it++)
    {
        _s<<(_it==_ita?"":",")<<*_it;
    }
    _s<<"}";
    return _s;
}
template<typename _a> ostream &operator << (ostream &_s,vector<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a> ostream &operator << (ostream &_s,set<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a,typename _b> ostream &operator << (ostream &_s,map<_a,_b> &_c){return _OUTC(_s,ALL(_c));}
template<typename _t> void pary(_t _a,_t _b){_OUTC(cerr,_a,_b);cerr<<endl;}
#define IOS()
#else
#define debug(...)
#define pary(...)
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0);
#endif // brian
//}


const ll MAXn=1e5+5,MAXlg=__lg(MAXn)+2;
const ll MOD=1000000007;
const ll INF=ll(1e15);

vector<ll> pos, neg;

int main()
{
    IOS();
    ll n;
    cin>>n;
    REP1(i, n)
    {
        ll x;
        cin>>x;
        if(x < 0)neg.pb(x);
        else pos.pb(x);
    }
    if(SZ(neg) == 0)
    {
        sort(ALL(pos), greater<ll>());
        neg.pb(pos.back());
        pos.pop_back();
    }
    else if(SZ(pos) == 0)
    {
        sort(ALL(neg));
        pos.pb(neg.back());
        neg.pop_back();
    }
    ll tt = 0;
    vector<ii> ans;
    tt = neg[0];
    for(int i = 0;i < SZ(pos) - 1;i ++)
    {
        ans.pb(ii(tt, pos[i]));
        tt -= pos[i];
    }
    ans.pb(ii(pos.back(), tt));
    tt = pos.back() - tt;
    for(int i = 1;i < SZ(neg);i ++)
    {
        ans.pb(ii(tt, neg[i]));
        tt -= neg[i];
    }
    cout<<tt<<endl;
    for(auto p:ans)cout<<p.X<<" "<<p.Y<<endl;
}


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

paper = {}
for i in range(N):
    t = int(input())
#    print(t)
 #   print(paper)
    if t in paper:
        paper[t] = not(paper[t])
    else:
        paper[t] = True

ans = 0
for b in paper.values():
    if b:
        ans +=1

print(ans)
#print(paper)


Measured memory_bytes: 15068
#include <iostream>
#include <cstring>
#include <queue>
#include <numeric>
#include <vector>
#include <map>
#define int long long
using namespace std;
#define rep(i, n) for (int i = 0; i < n; ++i)

string s;
int len;

enum Ord {
    Less, Eq
};

int dp[20][2][2][10000];

bool is_gochiusa(int x) {
    if (x / 1000 % 10 != 5) return false;
    if (x / 100 % 10 != 1) return false;
    if (x / 1 % 10 != 3) return false;
    return true;
}

int rec(int k, Ord ord, bool done, int tail) {
    int &ans = dp[k][ord][done][tail];
    if (ans != -1) return ans;

    ans = 0;
    if (k == len) {
        ans = done ? 1 : 0;
    } else {
        int d = s[k] - '0';
        rep(nd, 10) {
            Ord nord;
            if (ord == Less) {
                nord = Less;
            } else if (nd <= d) {
                nord = nd < d ? Less : Eq;
            } else {
                continue;
            }
            int ntail = (tail * 10 + nd) % 10000;
            bool ndone = done || is_gochiusa(ntail);
            ans += rec(k + 1, nord, ndone, ntail);
        }
    }
    return ans;
}

signed main() {
    cin >> s;
    len = s.size();
    memset(dp, -1, sizeof dp);
    cout << rec(0, Eq, false, 0) << endl;
}



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

int main(void){
    int x,a,b; cin >> x >> a >> b;
    int day=b-a;

    if(day<=0) cout << "delicious" << endl;
    else if(day<=x) cout << "safe" << endl;
    else cout << "dangerous" << endl;

    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>

int main(){
int w,a,b;
scanf("%d%d%d",&w,&a,&b);
if(a+w<=b){
printf("%d",abs(b-(a+w)));
return 0;
}
if(b+w<a){
printf("%d",abs((b+w)-a));
return 0;
}
puts("0");
return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <fstream>
#include <vector>
#include <cmath>
#include <climits>

using namespace std;

//ifstream fin ("data.in");

int main() {
    int n, k;

    cin >> n >> k;

    vector <int> h, dp(n + 1, INT_MAX);
    h.push_back(-1);
    for (int i = 1; i <= n; i++) {
        int x;
        cin >> x;
        h.push_back(x);
    }

    dp[1] = 0;
    for (int i = 2; i <= n; i++) {
        for (int j = i - 1; j >= 1 && j >= i - k; j--) {
            dp[i] = min(dp[i], dp[j] + abs(h[i] - h[j]));
        }
    }

    cout << dp[n];
    return 0;
}

Measured memory_bytes: 1276
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <ctype.h>
#include <map>
#include <vector>
#include <stdlib.h>
#include <cctype>
#define REP(i,n) for(int i=0;i<(int)n;++i)
#define REP1(j,n) for(int j=0;j<(int)n;++j)
#define REPD(i,n) for(int i=n;i>=0;--i)
#define REPD1(j,n) for(int j=n;j=>0;--j)
#define REPS(i,n) for(int i=1;i<=(int)n;++i)
#define REPS1(j,n) for(int j=1;j<=(int)n;++j)
#define rep(i,a,n) for(int i=a;i<=(int)n;++i)
#define SZ(x) ((int)(x).size())	//size() unsigned -> int
#define DescSort(a) sort(a.begin(),a.end(),std::greater<int>())

using namespace std;
typedef long long ll;

int main(void) {
	int x;
	cin >> x;
	if (x < 1200)cout << "ABC" << endl;
	else cout << "ARC" << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,b,a) for(int i=b;i>=a;i--)
#define fori(a) for(auto i : a )
#define all(a) begin(a), end(a)
#define set(a,b) memset(a,b,sizeof(a))
#define sz(a) a.size()
#define pi 3.14159
#define ll long long
#define ull unsigned long long
#define pb push_back
#define PF push_front //deque
#define mp make_pair
#define pq priority_queue
#define mod 1000000007
#define f first
#define s second
#define pii pair< int, int >
#define vi vector<int>
#define vpii vector<pii>
#define debug(v) for(auto i:v) cout<<i<<" ";
#define tc int t; cin >> t; while(t--)

using namespace std;
string repeat(string s, int n) {
    string s1 = "";
    for (int i=0; i<n;i++)
        s1+=s;
    return s1;
}
string getString(char x) {
    string s(1, x);
    return s;
}

void optimizeIO(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}
int gcd(int a, int b){
    if (a == 0)  return b;
    return gcd(b % a, a);
}
void  solve(){
  double x,y;
  cin>>x>>y;
  cout<<x/y<<endl;
}
int main(){
    optimizeIO();
    // tc
    { solve();
    }
}


Measured memory_bytes: 3716
#include <bits/stdc++.h>
#define INF 2000000000000000000
#define ll long long
#define pll pair<ll, ll>
using namespace std;

// ===========floor_sum================
ll floor_sum(ll n, ll m, ll a, ll b) {
    ll ans = 0;
    if (a >= m) {
        ans += (n - 1) * n * (a / m) / 2;
        a %= m;
    }
    if (b >= m) {
        ans += n * (b / m);
        b %= m;
    }

    ll y_max = (a * n + b) / m, x_max = (y_max * m - b);
    if (y_max == 0) return ans;
    ans += (n - (x_max + a - 1) / a) * y_max;
    ans += floor_sum(y_max, a, m, (a - x_max % a) % a);
    return ans;
}
// =======================================

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  ll T;
  cin >> T;
  for (ll i = 0; i < T; ++i) {
    ll N, M , A, B;
    cin >> N >> M >> A >> B;
    cout << floor_sum(N, M, A, B) << "\n";
  }
}


Measured memory_bytes: 3648
import numpy as np
N,K,Q = map(int, input().split())
A = [int(input()) for i in range(Q)]
x = np.array([K-Q]*N)
for j in range(Q):
    x[A[j]-1]+=1
for k in range(N):
    if x[k]>=1:
        print('Yes')
    else:
        print('No')

Measured memory_bytes: 17888
#include <algorithm>
#include <iostream>

using namespace std;

int main(void) {

	long long X, K, D;
	cin >> X >> K >> D;

	X = abs(X);
	long long num = X / D;//0に近づける回数

	if (num > K) {
		cout << (X - (D * K)) << endl;
	}

	else {
		long long A = X - (D * num);//できるだけ0に近づいた時の座標
		if ((K - num) % 2 == 0) {
			cout << A << endl;
		}

		else {
			cout << min(abs(A - D), abs(A + D)) << endl;
		}
	}


	return 0;
}

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

int main(){
    string s;
    cin>>s;
    map<string,bool>p;
    p.insert(pair<string,bool>("BBB",true));
    p.insert(pair<string,bool>("AAA",true));
    if(p[s]) cout<<"No\n";
    else cout<<"Yes\n";
    return 0;
}


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

typedef long long ll;

using namespace std;

#define swap(a, b)    do { typeof(a) __tmp = (a); (a) = (b); (b) = __tmp; } while(0)
#define repd(i, a, b) for(typeof(b) i = a; i < (b); ++i)
#define rep(i, n)     repd(i, 0, n)
#define dump(x)       cerr << #x << " = " << (x) << endl
#define debug(x)      cerr << "L" << __LINE__ << ": " << #x << " = " << (x) << endl
#define YesNo(x)      cout << ((x) ? "Yes" : "No") << endl
#define YESNO(x)      cout << ((x) ? "YES" : "NO") << endl
#define absi(x)       ( ((x) >= 0) ? (x) : (-(x)) )

vector<vector<ll>> x;

bool f(ll n) {
	for(ll i = 0; i * i <= n; ++i) {
		if(i * i == n) return true;
	}

	return false;
}

int main(int argc, const char* argv[]) {
	ll n, d;
	cin >> n >> d;

	x = vector<vector<ll>>(n, vector<ll>(d));
	rep(i, n) {
		rep(j, d) {
			cin >> x[i][j];
		}
	}

	ll ret = 0;
	rep(i, n) {
		repd(j, i + 1, n) {
			ll distance = 0;
			rep(k, d) {
				distance += (x[i][k] - x[j][k]) * (x[i][k] - x[j][k]);
			}
			if( f(distance) ) ++ret;
		}
	}

	cout << ret << endl;

	return 0;
}


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

using namespace std;

int main()
{
 int a,b,c, d;
 cin >> a>> b>>c>>d;
 if (abs(a-b)<=d&&abs(b-c)<=d)
    cout <<"Yes";
 else
 if (abs(a-c)<=d)
 cout << "Yes";
 else
    cout <<"No";





    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
#define MAX 128
#define fst first
#define sec second
#define pb push_back
#define mp make_pair
#define ALL(x) (x).begin(), (x).end()
#define debug(x) cerr << #x << ": " << x << '\n'
#define bit(n) (1LL << (n))
#define int long long
const double PI = 3.141593;
const int MOD = (int)1e9 + 7;
const int INF = 100100100;
const double EPS = 1e-9;
template <class T>
bool chmax(T &a, const T &b){if (a < b){a = b;return 1;}return 0;}
template <class T>bool chmin(T &a, const T &b){if (b < a){a = b;return 1;}return 0;}
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; } //最大公約数
ll lcm(ll a, ll b) { return a * b / gcd(a, b); }     //最小公倍数
ll combination(ll n, ll r){if (r * 2 > n)r = n - r;ll dividend = 1;ll divisor = 1;for (ll i = 1; i <= r; ++i){dividend *= (n - i + 1);divisor *= i;}return dividend / divisor;}


signed main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  int a, b, c, k,ans;
  ans = 0;
  cin >> k;
  rep2(i,1,k+1){
    rep2(j,1,k+1){
      rep2(l,1,k+1){
        ans+=gcd(gcd(i, j), l);
      }
      }
  }
  cout << ans << endl;
}


Measured memory_bytes: 3692
#include <iostream>
#include <algorithm>
#include <math.h>
#include <vector>
#include <string>
#include <queue>
#include <map>
#include <utility>
using namespace std;
using ll = long long;
 
int main() {
	string a;
	string b;
	cin >> a;
	cin >> b;
	for (int i =0;i<3;i++) {
		if (a[i] != b[2-i]) {
			cout << "NO" << endl;
		   	return 0;
		}
	}
	cout << "YES" << endl;
	
}


Measured memory_bytes: 256
#[allow(unused_imports)]
use itertools::Itertools;
#[allow(unused_imports)]
use itertools_num::ItertoolsNum;
#[allow(unused_imports)]
use std::cmp;
#[allow(unused_imports)]
use std::iter;
#[allow(unused_imports)]
use superslice::*;

fn run() {
    let (r, w) = (std::io::stdin(), std::io::stdout());
    let mut sc = IO::new(r.lock(), w.lock());

    let n: usize = sc.read();
    let a = sc.read_vec::<usize>(n);
    let b = sc.read_vec::<usize>(n);

    let a_sum = a.iter().sum::<usize>();
    let b_sum = b.iter().sum::<usize>();

    if a_sum > b_sum {
        println!("No");
        return;
    }

    let count_a = a
        .iter()
        .zip(b.iter())
        .map(|(&a, &b)| if a > b { 0 } else { (b - a + 1) / 2 })
        .sum::<usize>();
    let count_b = a
        .iter()
        .zip(b.iter())
        .map(|(&a, &b)| if a > b { a - b } else { 0 })
        .sum::<usize>();

    if cmp::max(count_a, count_b) <= b_sum - a_sum {
        println!("Yes");
    } else {
        println!("No");
    }
}

fn main() {
    std::thread::Builder::new()
        .name("run".into())
        .stack_size(256 * 1024 * 1024)
        .spawn(run)
        .unwrap()
        .join()
        .unwrap();
}

pub struct IO<R, W: std::io::Write>(R, std::io::BufWriter<W>);

impl<R: std::io::Read, W: std::io::Write> IO<R, W> {
    pub fn new(r: R, w: W) -> IO<R, W> {
        IO(r, std::io::BufWriter::new(w))
    }
    pub fn write<S: std::ops::Deref<Target = str>>(&mut self, s: S) {
        use std::io::Write;
        self.1.write(s.as_bytes()).unwrap();
    }
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .0
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n' || b == b'\r' || b == b'\t')
            .take_while(|&b| b != b' ' && b != b'\n' && b != b'\r' && b != b'\t')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn read_vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn read_pairs<T: std::str::FromStr>(&mut self, n: usize) -> Vec<(T, T)> {
        (0..n).map(|_| (self.read(), self.read())).collect()
    }
    pub fn read_pairs_1_indexed(&mut self, n: usize) -> Vec<(usize, usize)> {
        (0..n)
            .map(|_| (self.read::<usize>() - 1, self.read::<usize>() - 1))
            .collect()
    }
    pub fn read_chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
    pub fn read_char_grid(&mut self, n: usize) -> Vec<Vec<char>> {
        (0..n).map(|_| self.read_chars()).collect()
    }
    pub fn read_matrix<T: std::str::FromStr>(&mut self, n: usize, m: usize) -> Vec<Vec<T>> {
        (0..n)
            .map(|_| (0..m).map(|_| self.read()).collect())
            .collect()
    }
}


Measured memory_bytes: 2424
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long int
#define int long long
#define f(i,l,n) for(int i=l;i<n;i++) 
#define E "\n"

int solve()
{
	return 0;	
}


int32_t main()
{

  
  int n;
  cin >> n;

  std::vector<int> a(n);

  f(i,0,n) cin >> a[i];



  int ans=0;

  f(i,0,n)
  {
  		f(j,i+1,n)
  		{
  			if(a[i]==a[j]) continue;
  			f(t,j+1,n)
  			{
  				if(a[t]==a[j] or a[t]==a[i]) continue;
  				int sum=a[i]+a[j]+a[t];
  				int mx=max({a[i],a[j],a[t]});

  				if(mx<sum-mx)
  				{
  					//cout<<i<<" "<<j<<" "<<t<<E;
  					ans++;
  				}
  			}
  		}
  }

  //cout<<mp.size()<<E;
  cout<<ans<<E;	



     return 0;
    
}

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

int main(){
    
    string s;
    cin >> s;
    int l = 0 , r = s.size() - 1;
    int cnt = 0;
    while(l < r){
        if(s[l] != s[r]){
            ++cnt;
        }
        ++l , --r;
    }
    cout << cnt << "\n";
    
return 0;
}

Measured memory_bytes: 256
n = int(input())
l = list(map(int, input().split()))

p = 0
count = 1

def start(L, A):
    global p
    if L[A+1] > L[A]:
        p=1
    elif L[A+1] < L[A]:
        p=2
    else:
        p=0

def upcount(L, A):
    global p, count
    if L[A+1] >= L[A]:
        p=1
    else:
        p=0
        count += 1

def downcount(L, A):
    global p, count
    if L[A+1] <= L[A]:
        p=2
    else:
        p=0
        count += 1

for i in range(n):
    if i == n-1:
        break
    elif p == 0:
        start(l, i)
    elif p == 1:
        upcount(l, i)
    else:
        downcount(l, i)

print(count)

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


#define ll long long
#define ull unsigned long long
#define pb push_back

#define fr(i,a,b)   for(i=a;i<=b;i++)
#define frn(i,a,b)  for(i=a;i>=b;i--)
#define mem(arr,val)    memset(arr,val,sizeof(arr))
#define mp make_pair
#define pii pair<int,int>
#define F first
#define S second
#define sz(x) (int)(x).size()


int main()
{
    //freopen("d://i.txt","r",stdin);
    //freopen("d://o.txt","w",stdout);

    string s,s1,s2;
    cin>>s;

    s1=s.substr(0,4) , s2=s.substr(4);

    cout<<s1<<" "<<s2<<endl;



    return 0;
}





Measured memory_bytes: 256
#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;
 
#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
#define trav(a,x) for (auto& a : x)
 
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define ins insert

template<class T> bool ckmin(T& a, const T& b) { return b < a ? a = b, 1 : 0; }
template<class T> bool ckmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
const int MOD = 1000000007;
const char nl = '\n';
const int MX = 100001; //check the limits, dummy
 
int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);    
	
    string S; cin >> S;
    int maxi = 0;
    S.push_back('S');
    int total = 0;
    for (int i = 0; i < (int) S.size(); ++i) {
		if (S[i] == 'R') {
			++total;
		} else {
			maxi = max(maxi, total);
			total = 0;
		}
	}
	cout << maxi << '\n';
	
	return 0;
}
 
// read the question correctly (ll vs int)
// template by bqi343



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

comb_dic = {}


def combination_formula(n, r):
    """nCrは、O(min(n-r, r))で実装する
    Notes:
        分子と分母がかなり大きな値になった場合、計算は遅くなるので注意
        求める値がmodをとった値でいい場合、フェルマーの小定理を使った方法が速い。
    """
    if r > n: return 0

    if n in comb_dic:
        return comb_dic[n]

    r = min(n-r, r)
    bunsi, bunbo = 1, 1
    for i in range(r):
        bunsi = bunsi*(n-i)
        bunbo = bunbo*(i+1)

    comb_dic[n] = bunsi//bunbo
    return comb_dic[n]


def solve():
    N = int(input())
    As = list(map(int, input().split()))

    dic = {}
    for a in As:
        if not a in dic:
            dic[a] = 0
        dic[a] += 1

    # combination_formula(v, 2)はくっそ早いので、
    # しゃくとりっぽく解く
    total = 0
    for key, value in dic.items():
        total += combination_formula(value, 2)

    for a in As:
        ans = total
        ans -= combination_formula(dic[a], 2)
        ans += combination_formula(dic[a]-1, 2)
        print(ans)


if __name__ == "__main__":
    solve()


Measured memory_bytes: 93388
#include<iostream>
#define rep(i,cc,n) for(int i=cc;i<=n;++i)
using namespace std;

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

  int A[M] = {0};
  rep(i,0,N-1) {
    int K;
    cin >> K;
    rep(j,0,K-1) {
      int a;
      cin >> a;
      A[a-1]++;
    }
  }

  int ans = 0;
  rep(i,0,M-1) {
    if (A[i] == N) ans++;
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <valarray>
#include <vector>
using namespace std;

using ll = long long;
using ld = long double;
const int INF = 1e9;
const double EPS = 1e-9;
const ll MOD = 1e9 + 7;

int main()
{
  long long N;
  scanf("%lld", &N);
  std::vector<long long> a(N);
  for (int i = 0; i < N; i++)
  {
    scanf("%lld", &a[i]);
  }
  vector<vector<ll>> dp(N + 1, vector<ll>(N + 1));
  for (int len = 1; len <= N; ++len)
  {
    for (int l = 0; l + len <= N; ++l)
    {
      int r = l + len;
      if ((N - len) % 2 == 0)
        dp[l][r] = max(dp[l + 1][r] + a[l], dp[l][r - 1] + a[r - 1]);
      else
        dp[l][r] = min(dp[l + 1][r] - a[l], dp[l][r - 1] - a[r - 1]);
    }
  }
  cout << dp[0][N] << endl;

  return 0;
}


Measured memory_bytes: 70784
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
c=list(map(int,input().split()))
g=0
for i in range(n):
  g+=b[a[i-1]-1]
  if i!=n-1 and a[i]==a[i+1]-1:
    g+=c[a[i]-1]
print(g)

Measured memory_bytes: 3060
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <vector>
#define Rep(i, n) for(int i=0;i<n;++i)
#define rep(i, n) for(int i=1;i<=n;++i)
#define ll long long int
#define INF 1e9
#define LINF 1e18
#define MOD 1000000007
#define PI 3.14159265359
#define EPS 1e-10
#define All(a) (a).begin(), (a).end()

using namespace std;
using P = pair<ll, ll>;
 
int dx[4] = {0, 1, 0, -1};
int dy[4] = {1, 0, -1, 0};

/**
 * Usage:
 * 
 * G[from].push_back(Edge(to, weight));
 * using Graph = vector<vector<Edge>>;
 * 
 */ 
struct Edge {
  int to;     
  ll weight; 
  Edge(int t, ll w) : to(t), weight(w) { }
};

/**
 * Usage:
 * 
 * chmin(old, new);
 * chmax(old, new);
 * 
 */ 
template<class T> inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template<class T> inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}

template<typename T>
void printv(vector<T>& v) {
  if (v.size() == 0) {
    cout << "\n";
    return;
  }

  Rep(i, v.size()) {
    cout << v[i] << ((i + 1 < v.size()) ? ' ' : '\n');
  }
}



ll H, N;

int main () {
  cin >> H >> N;
  ll sum = 0;
  rep(i, N) {
    ll tmp;
    cin >> tmp;
    sum += tmp;
  }

  if (sum >= H) cout << "Yes\n";
  else cout << "No\n";
}

Measured memory_bytes: 256
#include <stdio.h>
int main()
{
  int i, j, k, work, N, A[1005];
  /* i,j,k are variables for loop count
     work is variable for save number
     N is variable for the length of series A
     A is array for save each elements needs for this program
  */

  scanf("%d", &N);
  //input for the length of series A

  for(i=0;i<N;i++){
    scanf("%d", &A[i]);
  }
  //input for each elements

  
  for(i=1;i<=N;i++){

    for(k=0; k<N; k++){
      printf("%d",A[k]);
      if(k<N-1) printf(" ");
    }
    printf("\n");
    //output every each step

    work=A[i];   
    j=i-1; 
    
    while(j>=0 && A[j]>work){
      A[j+1]=A[j];
      j--;
    }
    /*when j andover 0 and A[j] bigger than work,
      excange two elements*/

    A[j+1]=work;
  }
  return 0;
}

Measured memory_bytes: 608
#include "bits/stdc++.h"
using namespace std;
using lint = long long int;
using pint = pair<int, int>;
using plint = pair<lint, lint>;
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((lint)(x).size())
#define POW2(n) (1LL << (n))
#define FOR(i, begin, end) for(lint i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(lint i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
template<class T>bool chmax(T & a, const T & b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T & a, const T & b) { if (b < a) { a = b; return 1; } return 0; }
template<typename T1, typename T2> pair<T1, T2> operator+(const pair<T1, T2>& l, const pair<T1, T2>& r) { return make_pair(l.first + r.first, l.second + r.second); }
template<typename T1, typename T2> pair<T1, T2> operator-(const pair<T1, T2>& l, const pair<T1, T2>& r) { return make_pair(l.first - r.first, l.second - r.second); }
const lint MOD = 1e9 + 7;

lint N, A, B;
map<plint, lint> cnt;
plint arr[50];
int main() {
	cin.tie(0); ios_base::sync_with_stdio(false);
	cin >> N;
	REP(i, N) {
		cin >> A >> B;
		arr[i] = plint(A, B);
	}
	sort(arr, arr + N);
	REP(i, N - 1) {
		FOR(j, i + 1, N) {
			plint range = arr[i] - arr[j];
			cnt[range]++;
		}
	}
	lint maxv = 0;
	for (auto itr : cnt) {
		chmax(maxv, itr.second);
	}
	cout << N - maxv;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define whole(x) (x).begin(),(x).end()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
using P = pair<int, int>;
#define debug(var) cerr << "[" << #var << "] " << var << endl
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
const ll mod = 1000000007;
const int dx[] = {-1,0,1,0};
const int dy[] = {0,-1,0,1};


int main(){
    int a, b;
    cin >> a >> b;
    int ans = 0;
    int h = 100;
    int w = 100;
    vector<string> c(h, string(w, '.'));
    rep(i, h) rep(j, w) {
        if (i<h/2) c[i][j] = '.';
        else c[i][j] = '#';
    }
    a--; b--;
    cout << h << " " << w << endl;

    while (b) {
        int x = b*3;
        int i = x/h+1;
        int j = x%h;
        c[i][j] = '#';
        b--;
    }
    while (a) {
        int x = a*3;
        int i = x/h + h/2+1;
        int j = x%h;
        c[i][j] = '.';
        a--;
    }
    
    rep(i, h) cout << c[i] << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <array>
#include <cstdint>
#include <climits>
#include <functional>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <stdlib.h>
#include <string>
#include <time.h>
#include <type_traits>
#include <utility>
#include <vector>

using int32 = std::int_fast32_t;
using int64 = std::int_fast64_t;
using uint32 = std::uint_fast32_t;
using uint64 = std::uint_fast64_t;
using intl32 = std::int_least32_t;
using intl64 = std::int_least64_t;
using uintl32 = std::uint_least32_t;
using uintl64 = std::uint_least64_t;



int main(void) {
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	uint32 n;
	std::cin >> n;
	std::vector<uint64> a(n), b(n);
	for (uint32 i = 0;i < n;++i) {
		std::cin >> a[i] >> b[i];
	}
	uint64 ans = 0;
	for (uint32 i = n - 1;~i;--i) {
		a[i] += ans;
		if (a[i] % b[i] == 0) continue;
		ans += b[i] - (a[i] % b[i]);
	}
	std::cout << ans << "\n";
	return 0;
}

Measured memory_bytes: 2048
def gcd(a, b):
    while b: a, b = b, a % b
    return a
def isPrimeMR(n):
    d = n - 1
    d = d // (d & -d)
    L = [2]
    for a in L:
        t = d
        y = pow(a, t, n)
        if y == 1: continue
        while y != n - 1:
            y = (y * y) % n
            if y == 1 or t == n - 1: return 0
            t <<= 1
    return 1
def findFactorRho(n):
    m = 1 << n.bit_length() // 8
    for c in range(1, 99):
        f = lambda x: (x * x + c) % n
        y, r, q, g = 2, 1, 1, 1
        while g == 1:
            x = y
            for i in range(r):
                y = f(y)
            k = 0
            while k < r and g == 1:
                ys = y
                for i in range(min(m, r - k)):
                    y = f(y)
                    q = q * abs(x - y) % n
                g = gcd(q, n)
                k += m
            r <<= 1
        if g == n:
            g = 1
            while g == 1:
                ys = f(ys)
                g = gcd(abs(x - ys), n)
        if g < n:
            if isPrimeMR(g): return g
            elif isPrimeMR(n // g): return n // g
            return findFactorRho(g)
def primeFactor(n):
    i = 2
    ret = {}
    while i*i <= n:
        k = 0
        while n % i == 0:
            n //= i
            k += 1
        if k: ret[i] = k
        i += 1 + i % 2
        if i == 101 and n >= 2 ** 20:
            while n > 1:
                if isPrimeMR(n):
                    ret[n], n = 1, 1
                else:
                    rhoFlg = 1
                    j = findFactorRho(n)
                    k = 0
                    while n % j == 0:
                        n //= j
                        k += 1
                    ret[j] = k
    if n > 1:return {n} 
    return set(ret)
def main():
    n=int(input())
    a=list(map(int,input().split()))
    g=a[0]
    for i in a[1:]:g=gcd(g,i)
    if g!=1:
        print("not coprime")
        exit()
    ans=0
    s=set()
    for i in a:
        p=primeFactor(i)
        ans+=len(p)
        s|=p
    if ans!=len(s):print("setwise coprime")
    else:print("pairwise coprime")
if __name__ == "__main__":
    main()

Measured memory_bytes: 203724
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Scanner;
import java.util.Collections;

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

    static class TaskA {
        public Long min(Long... arr) {
            return Collections.min(Arrays.asList(arr));
        }

        public void solve(int testNumber, Scanner in, PrintWriter out) {

            long q = in.nextLong();
            long h = in.nextLong();
            long s = in.nextLong();
            long d = in.nextLong();
            long N = in.nextInt();
            long ans = (N / 2) * min(8 * q, 4 * h, 2 * s, d) + (N % 2) * min(4 * q, 2 * h, s);
            out.println(ans);
        }

    }
}



Measured memory_bytes: 23764
#include <bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin >> s;
  if(s.at(0) == s.at(1) && s.at(1) == s.at(2)){
      cout << "Yes" << endl;
  }else if(s.at(1) == s.at(2) && s.at(2) == s.at(3)){
     cout << "Yes" << endl;
  }else{
     cout << "No" << endl;
  }
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define var auto
using namespace std;
using ll = long long;
using P = pair<int, int>;
// sort(A.begin(), A.end(), cmp)
bool cmp(P a, P b) { return a.second < b.second; }
#ifdef DEBUG
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; cout << a << endl; return 1; } cout << a << endl; return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; cout << a << endl; return 1; } cout << a << endl; return 0; }
#else
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; }
#endif
const ll INF = 1LL << 60;
const int MAX_ITEM = 10e4+10; // 10^5
ll dp[MAX_ITEM] = {0};

map<int, vector<int>> lis;

int main() {
  int n,m;
  cin >> n >> m;
  int a[n],b[n]; rep(i,n) {
    int a,b;
    cin >> a >> b;
    lis[a].push_back(b); // 重さa 報酬b の仕事
  }

  // 0→M日間の報酬合計
  ll res = 0;
  priority_queue<int> q; // 優先度付きキュー
  rep(i,m+1) { // 1...m
    if(0 == i) continue;
    // i日後の報酬がもらえるバイトをキューに入れる
    for (auto &vv : lis[i]) {
      q.push(vv);
    }
    // i日目
    if (q.size() == 0) continue;

    res += q.top();
    q.pop();
  }

  cout << res << endl;
  return 0;
}


Measured memory_bytes: 10880
#include<iostream>
#include<vector>
#include <cstdlib>

using namespace std;

int main(){
  int n, k;
  cin >> n >> k;
  vector<int> x(n);
  for(int i=0;i<n;i++){
    cin >> x[i];
  }
  
  int ans=0;
  for(int i=0;i<n;i++){
    if(x[i]<k-x[i]){
      ans+=x[i]*2;
    }else{
      ans+=abs(k-x[i])*2;
    }
  }
  
  cout << ans;
  
  return 0;
}

Measured memory_bytes: 764
#include<iostream>
#include<cstdint>
#include<algorithm>
#include<cstddef>
#include<string>
#include<array>

using u32 = std::uint_fast32_t;
using usize = std::size_t;

#include <utility>

template <class T> T gcd(T m, T n) {
	while (m %= n)
		::std::swap(m, n);
	return n;
}


int main() {
	std::string s;
	std::cin >> s;

	std::array<usize, 2> count = {};
	for (const auto &c : s) {
		++count[c - '0'];
	}
	std::cout << *std::min_element(count.cbegin(), count.cend()) * 2 << std::endl;
	return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i,n) for(int i = 0;i < (int)(n);i++)
#define RREP(i,n) for(int i = (int)n-1;i >= 0;i--)
#define FOR(i,s,n) for(int i = s;i < (int)n;i++)
#define RFOR(i,s,n) for(int i = (int)n-1;i >= s;i--)
#define ALL(a) a.begin(),a.end()
#define IN(a, x, b) (a<=x && x<b)
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;}
constexpr long long INF = 1e18;



signed main(){
	int N,M;
	cin>>N>>M;
	string s;
	cin>>s;
	vector<int>ans;
	int now = N;
	while(now!=0){
		int flg = 1;
		FOR(j,now-M,now){
			if(j<0)continue;
			if(s[j]=='0'){
				ans.push_back(now-j);
				now=j;
				flg=0;
				break;
			}
			if(j==now-1){
				cout<<-1<<endl;
				return 0;
			}
		}
	}
	RREP(i,ans.size()){
		if(i+1!=ans.size())cout<<" ";
		cout<<ans[i];
	}
	cout<<endl;
}

Measured memory_bytes: 1528
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func NextInt() int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return i
}

func main() {
	n := NextInt()
	a := make([]int, n)
	for i := range a {
		a[i] = NextInt() - 1
	}

	var now, cnt int
	for {
		if now == 1 {
			fmt.Println(cnt)
			break
		}

		if cnt >= n {
			fmt.Println(-1)
			break
		}

		cnt++
		now = a[now]
	}
}


Measured memory_bytes: 2048
a=input()
n=len(a)
t_count=[0]*n
cnt=a.count('T')
for i in range(n):
    t_count[i]=cnt
    if a[i]=="T":
        cnt-=1

ans=0
s_used=0
t_owe=0
for i in range(n):
    if a[i]=="S":
        if t_count[i]-t_owe>0:
            ans+=2
            s_used+=1
            t_owe+=1
    else:
        if t_owe>0:
            t_owe-=1
    #print('ans {} s_used {} t_owe {} '.format(ans,s_used,t_owe))
print(n-ans)

Measured memory_bytes: 8040
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); ++i)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
using namespace std;
int main(){
  int n;
  cin>>n;
  long mod=1000000007;
  vector<long>a(n);
  rep(i,n){
    cin>>a.at(i);
  }
  vector<long>c(60);
  rep(i,60){
    rep(j,n){
      c.at(i)+=a.at(j)%2;
      a.at(j)/=2;
    }
  }
  long ans=0;
  rep(i,60){
    ans=(ans+(long)pow(2,i)%mod*(n-c.at(i))%mod*c.at(i))%mod;
  }  
  cout<<ans<<endl;  
}

Measured memory_bytes: 2560
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String input = br.readLine();
        int n = Integer.parseInt(input);

        int[][][] count = new int[4][3][10];
        for (int i = 0; i < 4; i++) {
            for (int j = 0; j < 3; j++) {
                for (int k = 0; k < 10; k++) {
                    count[i][j][k] = 0;
                }
            }
        }
        //?????°?????????
        for (int i = 0; i < n; i++) {
            String str = br.readLine();
            String[] strs = str.split(" ");
            int b = Integer.parseInt(strs[0]) - 1;  //????£?
            int f = Integer.parseInt(strs[1]) - 1;  //???
            int r = Integer.parseInt(strs[2]) - 1;  //?????????
            int v = Integer.parseInt(strs[3]);
            count[b][f][r] += v;
        }
            for (int i = 0; i < 4; i++) {
                if(i != 0){
                    System.out.println("####################");
}
                    for(int l = 0; l < 3; l++){
                        for(int k = 0; k < 10; k++){
                            System.out.print(" ");
                            System.out.print(count[i][l][k]);
                        }//for
                        System.out.println();
                    }//for
            }
        
    }
}

Measured memory_bytes: 24576
#include <iostream>

using namespace std;

int main () {

  int n, d, l, wave;
  
  while (1) {

    cin >> n >> d >> l;
    if (n + d + l == 0)
      break;

    else {

      int ans = 0;
      int wet = 0;

      for (int i = 0; i < n; i++) {

        cin >> wave;

        if (wet > 0) {
          ans++;
          wet--;
        }

        if (wave >= l)
          wet = d;
      }

      cout << ans << endl;
    }
  }
}



Measured memory_bytes: 3088
//C
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdalign>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>

//C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>

//Others
template<class T> inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
template<class T> inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}
const int dx[8] = { -1, 0, 1, -1, 1, -1, 0, 1 };
const int dy[8] = { 1, 1, 1, 0, 0, -1, -1, -1 };
const int lr[4] = { 0, 1, 0, -1 };
const int ud[4] = { 1, 0, -1, 0 };



//LOVE Ayane Sakura



using namespace std;



int main() {
	int N;
	cin >> N;
	vector<int>data(N);
	for (int i = 0; i < N; i++) {
		cin >> data[i];
	}
	for (int i = 0; i < N; i++) {
		if (data[i] % 2 == 0) {
			if (data[i] % 3 != 0 && data[i] % 5 != 0) {
				cout << "DENIED" << endl;
				return 0;
			}
		}
	}
	cout << "APPROVED" << endl;
}


Measured memory_bytes: 256
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <cassert>
#include <string.h>
//#include <unordered_set>
//#include <unordered_map>
//#include <bits/stdc++.h>

#define MP(A,B) make_pair(A,B)
#define PB(A) push_back(A)
#define SIZE(A) ((int)A.size())
#define LEN(A) ((int)A.length())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define fi first
#define se second

using namespace std;

template<typename T>inline bool upmin(T &x,T y) { return y<x?x=y,1:0; }
template<typename T>inline bool upmax(T &x,T y) { return x<y?x=y,1:0; }

typedef long long ll;
typedef unsigned long long ull;
typedef long double lod;
typedef pair<int,int> PR;
typedef vector<int> VI;

const lod eps=1e-11;
const lod pi=acos(-1);
const int oo=1<<30;
const ll loo=1ll<<62;
const int mods=1e9+7;
const int MAXN=55;
const int INF=0x3f3f3f3f;//1061109567
/*--------------------------------------------------------------------*/
inline int read()
{
	int f=1,x=0; char c=getchar();
	while (c<'0'||c>'9') { if (c=='-') f=-1; c=getchar(); }
	while (c>='0'&&c<='9') { x=(x<<3)+(x<<1)+(c^48); c=getchar(); }
	return x*f;
}
int f[MAXN][MAXN],c[MAXN][MAXN];
int upd(int x,int y){ return x+y>=mods?x+y-mods:x+y; }
int main()
{
	int n=read();
	f[1][0]=f[1][1]=1;
	for (int i=0;i<=n;i++) c[i][0]=1;
	for (int i=1;i<=n;i++)
		for (int j=1;j<=i;j++) c[i][j]=upd(c[i-1][j-1],c[i-1][j]);
	for (int i=1;i<n;i++)
		for (int j=0;j<=i;j++) 
			if (f[i][j]) 
			for (int x=0;x+i<=n;++x)
				for (int y=0;x+y+i<=n;++y) 
					if ((x+y)&&(x+y>=j)&&(!((x+y-j)&1))) 
						f[i+x+y][abs((x+y-j)/2+j-x)]=upd(f[i+x+y][abs((x+y-j)/2+j-x)],1ll*f[i][j]*c[i+x+y][x+y]%mods*c[x+y][x]%mods);
	printf("%d\n",f[n][0]);
	return 0;
}


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

int main() {
	int k,n;
  	cin>>k>>n;
  
  int a[n];
  rep(j,n)cin>>a[j];
  

  int longest =a[0]+k-a[n-1];
  
  rep(i,n-1){
  	longest=max(longest,a[i+1]-a[i]);
  }
  
  int ans = k - longest;
  cout<<ans<<endl;

}

Measured memory_bytes: 4396
#include<bits/stdc++.h>
using namespace std;
const int N=15,mod=1e9+7;
int n,m,e[N],sz[1<<N],dp[1<<N];
int main()
{
	scanf("%d%d",&n,&m);int nn=1<<n;dp[0]=1;
	for(int i=1,u,v;i<=m;i++){scanf("%d%d",&u,&v);u--;v--;e[u]|=(1<<v);}
	for(int i=0;i<nn;i++)for(int j=0;j<n;j++)if(i>>j&1)sz[i]++;
	for(int i=0;i<nn;i++)sz[i]=1<<sz[i];
	for(int S=1;S<nn;S++)if((S&1)==(S>>1&1))for(int T=S;T;T=(T-1)&S)if((T&1)==(T>>1&1))
	{
		int r=1,U=S^T;
		for(int i=0;i<n;i++)if(T>>i&1)r=1ll*r*sz[e[i]&U]%mod;else if(U>>i&1)r=1ll*r*(sz[e[i]&T]-1)%mod;
		dp[S]=(dp[S]+1ll*dp[U]*r)%mod;
	}
	int ans=1;
	for(int i=1;i<=m;i++)ans=2*ans%mod;
	printf("%d\n",(ans+mod-dp[nn-1])%mod);
	return 0;
}

Measured memory_bytes: 512
#pragma GCC optimize("Ofast")
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<vector>
#include<string.h>
#include<math.h>
#include<map>
#include<iomanip>
#include<queue>

const long long INFL = 1e17+7;
const long long INFI = 1e9+7;
const long long MOD = 1e9+7;
const double EPS = 1e-8;
const double PI=acos(-1);

using namespace std;


int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int n;
	cin >> n;
	vector<int> count(n+1,0);
	for(int i=1;i<=n;i++){
		for(int x=1;x*x<=i;x++){
			for(int y=x;y*y<=i;y++){
				for(int z=y;z*z<=i;z++){
					if(x*x+y*y+z*z+x*y+y*z+z*x==i){
						if(x==y && y==z){
							count[i]++;
							break;
						}else if(x!=y && y!=z){
							count[i]+=6;
							break;
						}else{
							count[i]+=3;
							break;
						}
					}
				}
			}
		}
	}
	
	for(int i=1;i<=n;i++){
		cout << count[i] << endl;
	}
	
	return 0;
}


Measured memory_bytes: 3672
#include <atcoder/all>
#include <bits/stdc++.h>
using namespace std;
using namespace atcoder;
using mInt = modint998244353;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define Inf 1000000000



int main(){
	
	int N,M;
	cin>>N>>M;
	
	scc_graph G(N);
	
	rep(i,M){
		int a,b;
		cin>>a>>b;
		G.add_edge(a,b);
	}
	
	auto ans = G.scc();
	cout<<ans.size()<<endl;
	rep(i,ans.size()){
		cout<<ans[i].size();
		rep(j,ans[i].size()){
			cout<<' '<<ans[i][j];
		}
		cout<<endl;
	}
	
    return 0;
}

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

int main(int argc, char const *argv[])
{
    int a, b;
    cin >> a >> b;
    int ans;
    if(a >= 13) ans = b;
    else if(a < 13 && a >= 6) ans = b/2;
    else ans = 0;
    cout << ans << endl;
    return 0;
}


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

#if ((_WIN32 || __WIN32__) && __cplusplus < 201103L)
#define lld I64d
#else
#define lld lld
#endif

//{{{
using namespace std;
typedef long long LL;
typedef vector<int> VI;
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define clr(a, b) memset(a, b, sizeof(a))
// clang-format off
#define debug(args...) {vector<string> _v = split(#args, ','); err(_v.begin(), args); cerr<<endl;}
vector<string> split(const string& s, char c) {vector<string> v; stringstream ss(s); string x; while
(getline(ss, x, c)) v.push_back(x); return v;} void err(vector<string>::iterator) {}
template<typename T, typename... Args> void err(vector<string>::iterator it, T a, Args... args)
{cerr << it -> substr((*it)[0] == ' ', it -> length()) << " = " << a << ", "; err(++it, args...);}
// clang-format on
//}}}

const int N = 1e5 + 10;
int T;

int dp[N];
int a[111];
int n, k;

int main()
{
#ifdef LOCAL
    freopen("in", "r", stdin);
// freopen("out", "w", stdout);
#endif

    while (cin >> n >> k)
    {
        for (int i = 1; i <= n; i++)
        {
            cin >> a[i];
        }
        clr(dp, 0);

        for (int i = 1; i <= k; i++)
        {
            unordered_set<int> st;
            for (int j = 1; j <= n; j++)
            {
                if (a[j] > i)
                {
                    break;
                }

                st.insert(dp[i - a[j]]);
            }
            for (int j = 0; j <= 110; j++)
            {
                if (st.find(j) == st.end())
                {
                    dp[i] = j;
                    break;
                }
            }

            // debug(i, dp[i]);
        }
        if (dp[k])
            cout << "First" << endl;
        else
            cout << "Second" << endl;
        // cout << dp[k] << endl;
    }

    return 0;
}


Measured memory_bytes: 4020
from collections import Counter

n = int(input())
v = list(map(int, input().split()))
v1 = sorted(Counter(v[::2]).items(), key=lambda x: x[1], reverse=True)
v2 = sorted(Counter(v[1::2]).items(), key=lambda x: x[1], reverse=True)
v1.append((0, 0))
v2.append((0, 0))
if v1[0][0] != v2[0][0]:
    print(n - v1[0][1] - v2[0][1])
else:
    print(min(n - v1[0][1] - v2[1][1], n - v1[1][1] - v2[0][1]))

Measured memory_bytes: 20700