akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

#define int long long
//typedef pair<int, int> P;
#define mod 1000000007
#define INF (1LL<<60)
 
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define repi(itr, ds) for (auto itr = ds.begin(); itr != ds.end(); itr++)
#define YES puts("YES")
#define Yes puts("Yes")
#define NO  puts("NO")
#define No  puts("No")
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
 
const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };
 
 
#if 1
//-------------
// DUMPマクロ
// https://www.creativ.xyz/dump-cpp-652/
 
// vector
template <typename T>
istream& operator>>(istream& is, vector<T>& vec) {
    for (T& x : vec) is >> x;
    return is;
}
// pair
template <typename T, typename U>
ostream& operator<<(ostream& os, pair<T, U>& pair_var) {
    os << "(" << pair_var.first << ", " << pair_var.second << ")";
    return os;
}
// vector
template <typename T>
ostream& operator<<(ostream& os, const vector<T>& vec) {
    os << "{";
    for (int i = 0; i < vec.size(); i++) {
        os << vec[i] << (i + 1 == vec.size() ? "" : ", ");
    }
    os << "}";
    return os;
}
// map
template <typename T, typename U>
ostream& operator<<(ostream& os, map<T, U>& map_var) {
    os << "{";
    repi(itr, map_var) {
        os << *itr;
        itr++;
        if (itr != map_var.end()) os << ", ";
        itr--;
    }
    os << "}";
    return os;
}
// set
template <typename T>
ostream& operator<<(ostream& os, set<T>& set_var) {
    os << "{";
    repi(itr, set_var) {
        os << *itr;
        itr++;
        if (itr != set_var.end()) os << ", ";
        itr--;
    }
    os << "}";
    return os;
}
 
#define DUMPOUT cerr
 
void dump_func() {
    DUMPOUT << endl;
}
template <class Head, class... Tail>
void dump_func(Head&& head, Tail&& ... tail) {
    DUMPOUT << head;
    if (sizeof...(Tail) > 0) {
        DUMPOUT << ", ";
    }
    dump_func(std::move(tail)...);
}
#ifdef DEBUG
#define DEB
#define dump(...)                                                              \
    DUMPOUT << "  " << string(#__VA_ARGS__) << ": "                            \
            << "[" << to_string(__LINE__) << ":" << __FUNCTION__ << "]"        \
            << endl                                                            \
            << "    ",                                                         \
        dump_func(__VA_ARGS__)
#else
#define DEB if (false)
#define dump(...)
#endif
#endif


signed main() {

    int N;
    cin >> N;
    
    rep(i,60000){
        int X = i*1.08;
        if(X==N){
            cout << i << endl;
            return 0;
        }
    }
    cout << ":(" << endl;
    
}



Measured memory_bytes: 256
#include<iostream>
#include<vector>
using namespace std;
int num_2(int a) {
	int ret=0;
	while (a % 2 == 0) {
		ret++;
		a /= 2;
	}
	return ret;
}
int even(vector<vector<int>> a) {
	int ret = a.at(1).at(0);
	for (int i = 0; i < a.at(0).size(); i++) {
			if (ret > a.at(1).at(i))ret = a.at(1).at(i);
	}
	return ret;
}
int main() {
	int n;
	cin >> n;
	vector<vector<int>> a(2,vector<int> (n));
	for (int i = 0; i < n; i++) {
		cin >> a.at(0).at(i);
	}
	for (int i = 0; i < n; i++) {
		a.at(1).at(i) = num_2(a.at(0).at(i));
	}
	cout << even(a) << endl;

}

Measured memory_bytes: 3616
fn main() {
    let d: usize = {
        let mut buf = String::new();
        std::io::stdin().read_line(&mut buf).unwrap();
        buf.trim_end().parse().unwrap()
    };
    let c: Vec<i64> = {
        let mut buf = String::new();
        std::io::stdin().read_line(&mut buf).unwrap();
        let iter = buf.split_whitespace();
        iter.map(|x| x.parse().unwrap()).collect()
    };
    let mut s: Vec<Vec<i64>> = Vec::with_capacity(d);
    for _ in 0..d {
        let a: Vec<i64> = {
            let mut buf = String::new();
            std::io::stdin().read_line(&mut buf).unwrap();
            let iter = buf.split_whitespace();
            iter.map(|x| x.parse().unwrap()).collect()
        };
        s.push(a);
    }
    let s = s;

    let mut last: Vec<usize> = vec![0; 26];
    for i in 1..=d {
        let mut max_satisfy = std::i64::MIN;
        let mut max_type = 0;
        for t in 0..26 {
            let res = s[i - 1][t] + c[t] * (i - last[t]) as i64;
            if max_satisfy < res {
                max_satisfy = res;
                max_type = t;
            }
        }
        last[max_type] = i;
        println!("{}", max_type + 1);
    }
}

Measured memory_bytes: 2224
#ifndef LOCAL
#pragma GCC optimize ("O3")
#endif
#include <bits/stdc++.h>
using namespace std;
#define sim template < class c
#define ris return * this
#define mor > muu & operator << (
#define R22(r) sim > typename \
  enable_if<1 r sizeof dud<c>(0), muu&>::type operator<<(c g) {
sim > struct rge { c b, e; };
sim > rge<c> range(c h, c n) { return {h, n}; }
sim > auto dud(c* r) -> decltype(cerr << *r);
sim > char dud(...);
struct muu {
#ifdef LOCAL
stringstream a;
~muu() { cerr << a.str() << endl; }
R22(<) a << boolalpha << g; ris; }
R22(==) ris << range(begin(g), end(g)); }
sim, class b mor pair < b, c > r) { ris << "(" << r.first << ", " << r.second << ")"; }
sim mor rge<c> u) {
  a << "[";
  for (c i = u.b; i != u.e; ++i)
    *this << ", " + 2 * (i == u.b) << *i;
  ris << "]";
}
#else
sim mor const c&) { ris; }
#endif
muu & operator()() { ris; }
};
#define imie(r...) "[" #r ": " << (r) << "] "
#define imask(r...) "[" #r ": " << bitset<8 * sizeof(r)>(r) << "] "
#define arr(a, i) "[" #a imie(i) ": " << a[i] << "] "
#define arr2(a, i, j) "[" #a imie(i) imie(j) ": " << a[i][j] << "] "
#define debug (muu() << __FUNCTION__ << "#" << __LINE__ << ": ")

const int N = 50;

using mac = int[N][N];

int n;
long long K;
mac mnPom;
const int mod = 1e9 + 7;

void mnoz(mac A, mac B, mac &C) {
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < n; ++j) {
            long long pom = 0;
            for (int k = 0; k < n; ++k) pom += (1ll * A[i][k] * B[k][j]) % mod;
            mnPom[i][j] = pom % mod;
        }
    }
    
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < n; ++j) {
            C[i][j] = mnPom[i][j];
        }
    }
}

void potega(mac &X, long long m) {
    mac res;
    for (int i = 0; i < n; ++i) for (int j = 0; j < n; ++j) res[i][j] = (i == j);
    while (m > 0) {
        if (m & 1) mnoz(res, X, res);
        mnoz(X, X, X);
        m /= 2;
    }
    for (int i = 0; i < n; ++i) for (int j = 0; j < n; ++j) X[i][j] = res[i][j];
}

mac A;

int main() {
    scanf("%d %lld", &n, &K);
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < n; ++j) {
            int d;
            scanf("%d", &d);
            A[i][j] = d;
        }
    }
    
    potega(A, K);
    
    long long res = 0;
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < n; ++j) res += A[i][j];
    }
    
    printf("%lld\n", res % mod);
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(){
  double temp, ans=0, p, n, i, j, k;
  scanf("%lf%lf", &n, &k);
  for(i=1;i<=n;i++){
    temp=1/n;
    j=i;
    while(j<k){
      j*=2;
      temp/=2;
    }
    ans+=temp;
  }
  printf("%.9lf\n", ans);
  return 0;
}


Measured memory_bytes: 128
def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getList():
    return list(map(int, input().split()))

from collections import defaultdict
from sys import exit
import math


def main():
    s = input().strip()
    if s == "ABC":
        print("ARC")
    else:
        print("ABC")
if __name__ == "__main__":
    main()

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

int main()
{
    long long int N;
    long long int A, B;

    cin >> N >> A >> B;

    long long int ans = 0;

    if ((B - A) % 2 == 0)
    {
        ans = (B - A) / 2;
    }
    else
    {
        long long int distanceFrom1 = A - 1;
        long long int distanceFromN = N - B;

        long long int nearEnd;
        long long int farEnd;
        if (distanceFrom1 < distanceFromN)
        {
            nearEnd = A;
            farEnd = B;

            if (B - A == 1 || B - A == 2)
            {
                ans = B - 1;
            }
            else
            {
                ans += (A - 1) + 1;
                B = B - ((A - 1) + 1);
                ans += (B - 1) / 2;
            }
        }
        else
        {
            nearEnd = B;
            farEnd = A;

            if (B - A == 1 || B - A == 2)
            {
                ans = N - A;
            }
            else
            {
                ans += (N - B) + 1;
                A = A + ((N - B) + 1);
                ans += (N - A) / 2;
            }
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include <iostream>
#include <fstream>

#include "bits/stdc++.h"

#define REP(i,x,y) for(int i=(x);i<(y);i++)
#define RREP(i,x,y) for(int i=(y)-1;i>=(x);i--)
#define all(x) (x).begin(),(x).end()
//#define int long long

using namespace std;

// conversion
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

#define dump(x)  cerr << #x << " = " << (x) << endl
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl

typedef long long ll;

const ll MOD = 1e9 + 7;

class CAlchemist {
public:
	void solve(std::istream& in, std::ostream& out) {
	    int N;
	    in >> N;
	    vector<int> v(N);
	    REP(i,0,N) in >> v[i];
	    sort(all(v));
        double answer = v[0];
        REP(i,1,N) {
	        answer = (answer + v[i]) / 2;
	    }
	    out << fixed << setprecision(10) << answer << "\n";
	}
};


int main() {
	CAlchemist solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
typedef long long ll;
typedef std::vector<long long> vll;
typedef std::vector<std::vector<long long>> vvll;
typedef long double ld;
typedef std::vector<long double> vld;
typedef std::vector<std::vector<long double>> vvld;
using namespace std;
void yesno(bool state);

void Main(){
    ll N;
    cin >> N;
    cout << (1000 - N % 1000)%1000 << endl;
}

int main(int argc, char const *argv[])
{
    Main();
    return 0;
}

void yesno(bool state){
    if(state)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}

Measured memory_bytes: 3620
import java.util.*;
class Main {
    public static void main(String[] args) {
	Scanner sc = new Scanner(System.in);
	long A = Long.parseLong(sc.next());
	long B = Long.parseLong(sc.next());
	long rest = A-1;
	long flag = ((rest+1)/2 + (B+1)/2) % 2;

	if(rest % 2 == 0) {
	    flag = rest ^ flag;
	}
	if(B % 2 == 0) {
	    flag = B ^ flag;
	}
	System.out.println(flag);
    }
}

Measured memory_bytes: 23252
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<map>
#include<utility>
#include<functional>
#include<stack>
#include<queue>
#include<cmath>
# define MOD 1000000000+7
# define INF 1e9
# define LINF 1e18
typedef long long ll;

using namespace std;
int gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
 
int n, x,cnt,sum;
int l[100] = {};


int main() {

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

		if (i == 0) {
			sum = l[i];
		}
		else {
			sum = l[i] + sum;
		}

		if (sum <= x)cnt++;

	}

	cout << cnt + 1 << endl;

	return 0;


}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 5;
const int inf = 1e9;
vector<int> E[maxn];
int n , odd[maxn];
bool ok;
// 判断奇偶性
void dfs1 (int u , int fa)
{
    for (auto v : E[u]){
        if (v == fa) continue;
        dfs1(v , u);
     //   cout << "现在在" << u << "点，它的奇偶性为 " << odd[u] << " 它的儿子" << v << "的奇偶性为" << odd[v] << endl;
        if (odd[v] == -1) continue;
        if (odd[u] == -1) odd[u] = (!odd[v]);
        else if (odd[u] == odd[v]) ok = false;
    }
}
int l[maxn] , r[maxn];
// 自下而上得到合法区间
void dfs2 (int u , int fa)
{
    for (auto v : E[u]){
        if (v == fa) continue;
        dfs2(v , u);
        if (r[v] == inf) continue;
        l[u] = max (l[u] , l[v] - 1);
        r[u] = min (r[u] , r[v] + 1);
    }
    if (l[u] > r[u]) ok = false;
}
int ans[maxn];
void dfs3 (int u , int fa)
{
    if ( ans[fa] <  r[u] ) ans[u] = ans[fa] + 1;
    else ans[u] = ans[fa] - 1;
    for (auto v : E[u]){
        if (v == fa) continue;
        dfs3(v , u);
    }
}
int main(){
    cin >> n;
    for (int i = 1 ; i < n ; i++){
        int x , y ; cin >> x >> y;
        E[x].push_back(y);
        E[y].push_back(x);
    }
    for (int i = 1 ; i <= n ; i++) {
        l[i] = -inf;
        r[i] = inf;
        odd[i] = -1;
    }
    int k; cin >> k;
    for (int i = 1 ; i <= k ; i++) {
        int x , y ; cin >> x >> y;
        l[x] = r[x] = y;
        odd[x] = (y & 1);
    }
    ok = true;
    dfs1(1 , 0);
    if (!ok){
        cout << "No" << endl;
        return 0;
    }
   // for (int i = 1 ; i <= n ; i++) cout << l[i] << " " << r[i] << endl;
    dfs2(1 , 0);
    if (!ok){
        cout << "No" << endl;
        return 0;
    }
    ans[0] = l[1] + 1;
    dfs3(1 , 0);
    cout << "Yes" << endl;
   /* cout << endl;
    for (int i = 1 ; i <= n ; i++) cout << l[i] << " " << r[i] << endl;
    cout << endl;*/
    for (int i = 1 ; i <= n ; i++) cout << ans[i] << endl;
    return 0;
}


Measured memory_bytes: 18420
#ifdef LOCAL111
#else
	#define NDEBUG
#endif
#include <bits/stdc++.h>
const int INF = 1e8;
using namespace std;

#define endl '\n'
#define ALL(a)  (a).begin(),(a).end()
#define SZ(a) int((a).size())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define RBP(i,a) for(auto& i : a)
#ifdef LOCAL111
	#define DEBUG(x) cout<<#x<<": "<<(x)<<endl
	template<typename T> void dpite(T a, T b){ for(T ite = a; ite != b; ite++) cout << (ite == a ? "" : " ") << *ite; cout << endl;}
#else
	#define DEBUG(x) true
	template<typename T> void dpite(T a, T b){ return; }
#endif
#define F first
#define S second
#define SNP string::npos
#define WRC(hoge) cout << "Case #" << (hoge)+1 << ": "
#define rangej(a,b,c) ((a) <= (c) and (c) < (b))
#define rrangej(b,c) rangej(0,b,c)
template<typename T> void pite(T a, T b){ for(T ite = a; ite != b; ite++) cout << (ite == a ? "" : " ") << *ite; cout << endl;}
template<typename T> bool chmax(T& a, T b){if(a < b){a = b; return true;} return false;}
template<typename T> bool chmin(T& a, T b){if(a > b){a = b; return true;} return false;}

typedef long long int LL;
typedef unsigned long long ULL;
typedef pair<int,int> P;
typedef pair<LL,LL> LP;

void ios_init(){
	//cout.setf(ios::fixed);
	//cout.precision(12);
#ifdef LOCAL111
	return;
#endif
	ios::sync_with_stdio(false); cin.tie(0);	
}

int main()
{
	ios_init();
	int n,a;
	cin >> n >> a;
	vector<int> x(n);
	REP(i,n) cin >> x[i];
	int sum = accumulate(ALL(x),0);
	vector<vector<LL>> dp(n+1,vector<LL>(sum+1,0));
	dp[0][0] = 1;
	REP(i,n){
		RREP(j,n){
			RFOR(k,x[i],sum+1){
				dp[j+1][k] += dp[j][k-x[i]];
			}
		}
	}
	LL ans = 0;
	FOR(num,1,n+1){
		int ca = a*num;
		if(ca <= sum) ans += dp[num][ca];
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 1280
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
const int INF = 100000000;
const int MAX_N = 100;
typedef pair<int , int> P;
typedef long long ll;
 
int main () {
  int N, ans;
  ans = 0;
  cin >> N;
  int a[N+10];
  for (int i = 1; i <= N; ++i) {
    cin >> a[i];
    if (i % 2 == 1 && a[i] % 2 == 1) {
      ++ans;
    }
  }
  printf("%d\n", ans);
  return 0;
}

Measured memory_bytes: 3692
N,M,C=[int(x) for x in input().split()]
B=[int(x) for x in input().split()]

out_num=0

for n in range(N):
  A=[int(x) for x in input().split()]
  a=[A[i]*B[i] for i in range(M)]
  check=sum(a)+C
  if check>0:
    out_num+=1
    
print(out_num)

Measured memory_bytes: 3060
import * as fs from 'fs';

function main(input) {
  input = input.split("\n");
  const N = parseInt(input[0], 10);
  const AList = input[1].split(" ").map(i => parseInt(i, 10));
  let count = 0, last = AList[0];
  for (let i = 1; i < N; i++) {
    count += Math.max(0, last - AList[i]);
    last = Math.max(last, AList[i]);
  }

  console.log('%d', count);
  return 0;
}

main(fs.readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 50056
#include <iostream>
#include <algorithm>
#include <string>
#include <math.h>
#include <stdlib.h>
#include <stdio.h>
using namespace std;



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


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

int main() {
	int n, m;
	string s, t;
	cin >> n >> m >> s >> t;

	int d = __gcd(n, m);
	for (int i = 0, j = 0; i < n && j < m; i += n / d, j += m / d) {
		if (s[i] != t[j]) {
			cout << -1 << endl;
			return 0;
		}
	}
	cout << (long long)n / d * m << endl;
	return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <iomanip>

using namespace std;

int main(int argc, char const *argv[])
{
    double W, H, x, y;
    cin >> W >> H >> x >> y;
    double ans = W * H / 2.0;
    cout << fixed << setprecision(12) << ans << ' ';
    if (x == W / 2.0 && y == H / 2.0)
    {
        cout << 1;
    }else
    {
        cout << 0;
    }
    
    cout << endl;
    
    return 0;
}

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

using namespace std;

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

  int m;
  cin >> m;
  vector<int> d(m);
  vector<long long> c(m);
  long long ans = 0, s = 0;
  for (int i = 0; i < m; ++i) {
    cin >> d[i] >> c[i];
    ans += c[i];
    s += c[i] * d[i];
  }
  cout << ans -  1 + (s - 1) / 9;

  return 0;
}


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

int n,r,b;
string a;
int main()
{
    cin>>n;
    cin>>a;
    for(int i=0;i<n;i++)
    {
        if(a[i]=='R')
            ++r;
        else
            ++b;
    }
    if(r>b)
        cout<<"Yes";
    else
        cout<<"No";
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;

const int MAX_N = 1e5 + 5;
const int MAX_L = 20; // ~ Log N
const long long MOD = 1e9 + 7;
const long long INF = 1e9 + 7;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<ii> vii;
typedef vector<vi> vvi;

#define rep(i,n) for (i = 0; i < n; ++i)
#define REP(i,k,n) for (i = k; i <= n; ++i)
#define REPR(i,k,n) for (i = k; i >= n; --i)

#define LSOne(S) (S & (-S))
#define isBitSet(S, i) ((S >> i) & 1)


void solve() {
    int N;
    cin >> N;
    stack<ll> s;
    int i;
    ll sum = 0;
    rep(i, N) {
        int x;
        cin >> x;
        if (!s.empty() && s.top() >= x) {
            sum += -x + s.top();
        } else {
            s.push(x);
        }

    }
    cout << sum;
}

//#define LOCAL 1

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

#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif

    solve();

    return 0;
}

Measured memory_bytes: 4568
#include <bits/stdc++.h>
using namespace std;;
#define ll long long
#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 INF 1<<30
#define LINF 1LL<<62
#define all(x) (x).begin(), (x).end()
#define mp make_pair
#define pb push_back
const int MOD = 1000000007;
 
typedef pair<ll, ll> P;
typedef pair<ll, P> PP;


int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  string s;cin >>s;
  rep(i,s.size()){
      if(i%2==0){
          if(s[i]=='L'){
              cout << "No" << endl;
              return 0;
          }
      }else{
          if(s[i]=='R'){
              cout << "No" << endl;
              return 0;
          }
      }
  }
  cout << "Yes"<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  string Color = "Three";
  for (int i = 1; i <= N; i++){
    string s;
    cin >> s;
    if (s == "Y"){
      Color = "Four";
      break;
    }
    
    else
      continue;
  }
  cout << Color << endl;
}

Measured memory_bytes: 256
def do():
    frag = 1
    S = str(input())
    for i in range(len(S)):
        if (i+1)%2 == 1:
            if S[i] == 'L':
                frag = 0
#                print(i)
        else:
            if S[i] == 'R':
                frag = 0
#                print(i)
    if frag == 1:
        print('Yes')
    else:
        print('No')
            
if __name__ == '__main__':
    do()

Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll oo = 1e18;
const int N = 5005;

int n, A[N];
vector<int> adj[N];
vector<ll> dp1[N], dp2[N];

vector<ll> merge(const vector<ll> &dp, const vector<ll> &ch1, const vector<ll> &ch2, bool flag) {
  vector<ll> res(dp.size() + ch1.size(), oo);
  for (int i = 0; i < (int)dp.size(); ++i) {
    for (int j = 0; j < (int)ch1.size(); ++j) {
      if (i + j - 1) {
        if (ch1[j] != oo) res[i + j - 1] = min(res[i + j - 1], dp[i] + ch1[j]);
        if (ch2[j] != oo && !flag) res[i + j - 1] = min(res[i + j - 1], dp[i] + ch2[j]);
      }
      if (ch1[j] != oo) res[i + j] = min(res[i + j], dp[i]);
      if (ch2[j] < 0) res[i + j] = min(res[i + j], dp[i]);
    }
  }
  return res;
}

void dfs(int u, int p) {
  dp1[u].emplace_back(oo);
  dp1[u].emplace_back(A[u] > 0 ? A[u] : oo);
  dp2[u].emplace_back(oo);
  dp2[u].emplace_back(A[u]);
  for (int v: adj[u]) {
    if (v == p) continue;
    dfs(v, u);
    dp1[u] = merge(dp1[u], dp1[v], dp2[v], true);
    dp2[u] = merge(dp2[u], dp1[v], dp2[v], false);
  }
}

int main() {
  ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
  cin >> n;
  for (int i = 1; i <= n; ++i) cin >> A[i];
  for (int i = 1, u, v; i < n; ++i) {
    cin >> u >> v;
    adj[u].emplace_back(v);
    adj[v].emplace_back(u);
  }
  dfs(1, -1);
  for (int k = 1; k <= n; ++k) {
    if (dp1[1][k] != oo || dp2[1][k] < 0) {
      cout << (k - 1);
      return 0;
    }
  }
  return 0;
}

Measured memory_bytes: 326400
#include <bits/stdc++.h>
#define MOD 1000000007
#define int long long int
#define FF first
#define pb push_back
#define SS second
#define double long double

typedef long long ll;

using namespace std;

int a[500005];
int dp[500005];
signed main()
{
 // freopen("input.txt" , "r" , stdin);
  //freopen("output.txt" , "w" , stdout);

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

  dp[0]=0;
  dp[1]=abs(a[1]-a[0]);
   for(int i=2;i<n;i++)
  {
    int val=INT_MAX;
    for(int j=1;j<=k;j++)
    {

      if(i>=j)
        val=min(val,dp[i-j]+abs(a[i-j]-a[i]));
    }
    dp[i]=val;
  }
 
  cout<<dp[n-1]<<endl;
  return 0;
}

Measured memory_bytes: 5120
def main():  
  import sys
  input = sys.stdin.readline
  import heapq
  def prim_heap():
      used = [True] * n #True:不使用
      edgelist = []
      for e in edge[0]:
          heapq.heappush(edgelist,e)
      used[0] = False
      res = 0
      while len(edgelist) != 0:
          minedge = heapq.heappop(edgelist)
          if not used[minedge[1]]:
              continue
          v = minedge[1]
          used[v] = False
          for e in edge[v]:
              if used[e[1]]:
                  heapq.heappush(edgelist,e)
          res += minedge[0]
      return res

  from collections import deque
  n = int(input())
  st = deque([])

  edge = deque([[] for i in range(n)])
  for i in range(n):
      x,y = map(int,input().split())
      st_append = st.append
      st_append((i,x,y))

  from operator import itemgetter
  bb = tuple(sorted(st,key=itemgetter(1)))
  chk = tuple(sorted(st,key=itemgetter(2)))
  #print(bb,chk)

  for i in range(n-1):
    x = bb[i][0]
    y = bb[i+1][0]
    z = bb[i+1][1]-bb[i][1]
    edge[x].append((z,y))
    edge[y].append((z,x))

  for i in range(n-1):
    a = chk[i][0]
    b = chk[i+1][0]
    c = chk[i+1][2]-chk[i][2]
    edge[a].append((c,b))
    edge[b].append((c,a))

  edge = tuple(edge)
  print(prim_heap())
if __name__ == '__main__':
    main()

Measured memory_bytes: 68792
#include <bits/stdc++.h>
using namespace std;
int main(void){
    string s,ans="AC";
    cin >> s;
    int count=0;
    if(s[0]!='A') ans = "WA";
    
    for (int i=1;i<s.size();i++) {
        if (isupper(s[i])){
            if(i==1 || s[i]!='C' || i==s.size()-1){
                ans = "WA";
                }
            count++;
        }
    }

    if(count!=1) ans = "WA";
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<utility>
#include<iomanip>
#include<map>
#include<cmath>
#include<cstdio>
#define rep(i,n) for(int i=0; i<(n); ++i)
using namespace std;
using ll =long long;
using P = pair<int,int>;

int main(){
    double n,p;
    cin >> n >> p;
    p += round(n*3);

    cout << int(p/2) << endl;

    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#define MAX 1000000
#define NIL -1

struct Node{
  int parent;
  int left;
  int right;
};
struct Node A[MAX];
int n,B[MAX],C[MAX];

int getSibling(int s){
  if(A[s].parent==NIL)return NIL;
  if(A[A[s].parent].left!=s&&A[A[s].parent].left!=NIL)return A[A[s].parent].left;
  if(A[A[s].parent].right!=s&&A[A[s].parent].right!=NIL)return A[A[s].parent].right;
 return NIL;
}
 
int setHeight(int x){
  int h1=0,h2=0;
  if(A[x].left!=NIL) h1=setHeight(A[x].left)+1;
  if(A[x].right!=NIL) h2=setHeight(A[x].right)+1;
  return C[x]=(h1>h2?h1:h2);
}
 

 void setDepth(int x,int y){
  if(x==NIL)return;
  B[x]=y;
  setDepth(A[x].left,y+1);
  setDepth(A[x].right,y+1);
}
 
void print(int x){
  int i,c;
  printf("node %d: ",x);
  printf("parent = %d, ",A[x].parent);
  printf("sibling = %d, ",getSibling(x));
  
  int deg=0;
  if(A[x].left!=NIL)deg++;
  if(A[x].right!=NIL)deg++;
  
  printf("degree = %d, ",deg);
  printf("depth = %d, ",B[x]);
  printf("height = %d, ",C[x]);
 
  if(A[x].parent==NIL)printf("root\n");
  else if(A[x].left==NIL&&A[x].right==NIL) printf("leaf\n");
  else  printf("internal node\n");
}
 
int main(){
 
  int x,y,z,root=0,i;
 
  scanf("%d",&n);
  for(i=0;i<n;i++){
    A[i].parent=NIL;
  }
 
  for(i=0;i<n;i++){
     scanf("%d",&x);
     scanf("%d",&y);
     scanf("%d",&z);
     A[x].left=y;
     A[x].right=z;
     if(y!=NIL)A[y].parent=x;
     if(z!=NIL)A[z].parent=x;
  }
  for(i=0;i<n;i++){
    if(A[i].parent==NIL)root=i;
  }
 
  setDepth(root,0);
  setHeight(root);
  for(i=0;i<n;i++)print(i);
 
  return 0;
}



Measured memory_bytes: 2044
#include <bits/stdc++.h>
#define FOR(i, m, n) for (ll i = m; i < (n); i++)
#define RFOR(i, m, n) for (ll i = (m - 1); i >= 0; i--)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) RFOR(i, n, 0)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
//#define print(ele) cout << (ele) << "\n"
#define print10(ele) cout << fixed << setprecision(10) << (ele) << "\n"

using namespace std;
typedef long long ll;
typedef vector<int> ivec;
typedef vector<string> svec;
typedef vector<ll> lvec;

const int mod = 1e9 + 7;
const ll INF = 1000000000000000000LL;

void print() { cout << endl; }

template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
  cout << head;
  if (sizeof...(tail) != 0) cout << " ";
  print(forward<Tail>(tail)...);
}

int main() {
  int n;
  cin >> n;
  lvec a(n);
  REP(i, n) cin >> a[i];
  map<ll, ll> mp;
  REP(i, n) mp[a[i]]++;
  ll ans = 0;
  for (auto x : mp) {
    ll num = x.first;
    ll cnt = x.second;
    if (num > cnt)
      ans += cnt;
    else
      ans += cnt - num;
  }
  print(ans);
  return 0;
}

Measured memory_bytes: 7040
#include <bits/stdc++.h>
#define INF 1e18
#define int long long
#define Rep(i, a, n) for (int i = (a); i < (n); i++)
#define Repr(i, n, a) for (int i = (n); i >= (a); i--)
#define rep(i, n) Rep(i, 0, n)
#define repr(i, n) Repr(i, n, 0)
#define all(a) (a).begin(), (a).end()
using namespace std;
typedef pair<int, int> P;
typedef pair<int, P> PP;
const int mod = 1000000007;

int n, m, l, k, a, h, e[110][110], d[110][110];
bool f[110];

int solve()
{
    typedef pair<int, P> PP;
    priority_queue<PP, vector<PP>, greater<PP>> que;
    que.push(PP(0, P(a, m)));
    d[a][m] = 0;
    while (!que.empty())
    {
        PP pp = que.top();
        que.pop();
        P p = pp.second;
        int v = p.first, w = p.second;
        if (d[v][w] < pp.first)
            continue;
        rep(i, 110)
        {
            if (e[v][i] > w)
                continue;
            int nw = w - e[v][i];
            if (f[i])
            {
                for (int j = nw; j <= m; j++)
                {
                    if (d[i][j] > d[v][w] + e[v][i] + j - nw)
                    {
                        d[i][j] = d[v][w] + +e[v][i] + j - nw;
                        que.push(PP(d[i][j], P(i, j)));
                    }
                }
            }
            else
            {
                if (d[i][nw] > d[v][w] + e[v][i])
                {
                    d[i][nw] = d[v][w] + e[v][i];
                    que.push(PP(d[i][nw], P(i, nw)));
                }
            }
        }
    }
    int res = INF;
    rep(i, 110) res = min(res, d[h][i]);
    return res;
}

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

    while (1)
    {
        cin >> n >> m >> l >> k >> a >> h;
        if (n == 0)
            break;
        rep(i, 110) f[i] = false;
        rep(i, 110) rep(j, 110) e[i][j] = INF, d[i][j] = INF;
        f[a] = true;
        f[h] = true;
        rep(i, l)
        {
            int X;
            cin >> X;
            f[X] = true;
        }
        rep(i, k)
        {
            int x, y, t;
            cin >> x >> y >> t;
            e[x][y] = t;
            e[y][x] = t;
        }
        int ans = solve();
        if (ans == INF)
            cout << "Help!" << endl;
        else
            cout << ans << endl;
    }
}


Measured memory_bytes: 3720
#include<bits/stdc++.h>
#include<iostream>
#include<bitset>
using namespace std;
 
 
#define all(x) (x).begin(),(x).end()
 
#define FOR(i,x,n)for(int i=(x);i<(n);i++)
#define FOR_R(i,x,n) for(int i=(n-1);i>=(x);i--)
#define REP(i, n) FOR(i, 0, n)
#define REP_R(i, n) FOR_R(i, 0, n)
 
////////////////////////////////////////////////////////////////
///変数初期化忘れない	 
int main(){
 
  	string N;
  	int ans = 0;
	cin >> N;
 
	REP(i,N.size()/2)if(N.at(i)!=N.at(N.size()-i-1))ans++;
	
	cout << ans << endl;
	return 0; 
}

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

int n, m;

void solve() {
  cin >> n >> m;
  cout << (n - 1) * (m - 1) << "\n";
}

int main() {
  
  ios_base::sync_with_stdio(0);
  cin.tie(0); cout.tie(0);
  
  solve();
  
}

Measured memory_bytes: 3652
//my vegetable has exploded. :(
#include<bits/stdc++.h>
#define max(x,y) (x>y?x:y)
#define min(x,y) (x<y?x:y)
#define MM(x,y) memset(x,y,sizeof(x))
#define MCPY(a,b) memcpy(a,b,sizeof(b))
#define pb push_back
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define per(i,b,a) for(int i=b;i>=a;i--)
#define fi first
#define se second
using namespace std;
#define int long long

inline int quickpow(int m,int n,int p){int b=1;while(n){if(n&1)b=b*m%p;n=n>>1;m=m*m%p;}return b;}
inline int getinv(int x,int p){return quickpow(x,p-2,p);}
inline int read(void){
    int x=0,f=1;char ch=getchar();
    while(!isdigit(ch)){f=ch=='-'?-1:1;ch=getchar();}
    while(isdigit(ch)){x=(x<<3)+(x<<1)+ch-'0';ch=getchar();}
    return x * f;
}

///------------------head------------------
const int maxn = 3e2+10;
int n,m,k,f[maxn][maxn];
signed main(signed argc, char *argv[]){
    n=read(),m=read(),k=read();
    MM(f,0); f[0][0]=1;
    rep(i,0,n)rep(j,0,m-1)per(t,i,0){if (t>0) f[j][t-1] += f[j][t],f[j][t-1]%=k;else f[j+1][i] += f[j][t],f[j+1][i]%=k;f[j][t] = f[j][t] * (1LL + t) %k;}
    printf("%lld\n",f[m][n]);
    return 0;
}

/* Examples: */
/*

*/

/*

*/


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

int INF = 1e9 +1;

int main(){

	int n; 
	cin >> n;

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


	int dp[n] = {};
	for(int i = 0;i<n;i++){
		dp[i] = INF;
	}
	dp[0] = 0;

	for(int i = 0;i<n-1;i++){
		for(int j = 1;j<3&&i+j<n;j++){
			dp[i+j] = min(dp[i+j],dp[i] + abs(arr[i] - arr[i+j]));
		}
	}

	cout << dp[n-1] << endl;
	return 0;
}

Measured memory_bytes: 1152
#include <iostream>

using namespace std;

int main()
{
    int N; cin>>N;
    if(N%1000==0){cout<<0<<"\n";}
    else{
        int K=N/1000; K++; K*=1000;
        K-=N; cout<<K<<"\n";
    }
    return 0;
}


Measured memory_bytes: 3596
#include<bits/stdc++.h>
using namespace std;
const long long INF = 1e7 + 1;
const long long MOD = 1000000007;
const long double PI = 3.1415926;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(x) x.begin(),x.end()
#define RALL(x) x.rbegin(),x.rend()
typedef long long int ll;
typedef vector<ll> vi;
typedef vector < pair<ll, ll > > vp;
typedef vector <string> vs;
typedef vector <char> vc;
typedef list <ll> lst;

//ll n, m, k, ans = 0, sum = 0, cnt = 0;
//string s;
//char c;


/*--------------------template--------------------*/


vector<string> ans;
bool ap[30];
string s;
int sum;

void dfs(int n, char c, string now)
{
	//cout<<"dfs(int "<<n<<",char "<<c<<",string "<<now<<")"<<endl;
	if (n == s.size()) {
		sum++;
		ans.push_back(now);
		return;
	}
	if (ap[c - 'a'] == true || c == 'a') {
		bool bac = ap[c - 'a'];
		ap[c - 'a'] = true;
		dfs(n + 1, s[n + 1], now + c);
		ap[c - 'a'] = bac;
	}
	if (ap[c - 'a' + 1] == false && c != 'z') {
		bool bac = ap[c - 'a' + 1];
		ap[c - 'a' + 1] = true;
		dfs(n + 1, s[n + 1], now + (char)(c + 1));
		ap[c - 'a' + 1] = bac;
	}
}

int main()
{
	while (1) {
		while (!ans.empty())ans.pop_back();
		sum = 0;
		cin >> s;
		if (s == "#")break;
		dfs(0, s[0], "");
		cout << sum << endl;

		if (sum <= 10) {
			for (int i = 0; i < sum; i++) {
				cout << ans[i] << endl;
			}
		} else {
			for (int i = 0; i < 5; i++) {
				cout << ans[i] << endl;
			}
			for (int i = ans.size() - 5; i < ans.size(); i++) {
				cout << ans[i] << endl;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 4156
num1=[]
num2=[]
for i in range(10):
    x=int(input())
    num1.append(x)
    
for i in range(10):
    y=int(input())
    num2.append(y)   
    
num1.sort()
num2.sort()

a=num1[7]+num1[8]+num1[9]
b=num2[7]+num2[8]+num2[9]

print(a,b)



Measured memory_bytes: 5600
#define ll long long int
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <set>
using namespace std;
const ll y = 1000;
const ll INF = y*y*y*y*y*y;
int main() {
	ll n, w;
	cin >> n >> w;
	vector <vector <ll>> dp(n+1, vector <ll>(w+1, -INF));
	vector <pair<ll, ll>> a(n);
	for (ll i = 0; i < n; i++) cin >> a[i].first >> a[i].second;
	for (ll i = 0; i <= w; i++) dp[0][i] = 0;
	for (ll i = 1; i <= n; i++) {
		for (ll j = 0; j <= w; j++) {
			if (j >= a[i - 1].first) { dp[i][j] = max(dp[i][j], dp[i-1][j - a[i - 1].first] + a[i - 1].second); }
			dp[i][j] = max(dp[i][j],dp[i - 1][j]);
		}
	}
	ll max1 = 0;
	for (ll i = 0; i <= w; i++) { max1 = max(dp[n][i], max1); }
	cout << max1;
}

Measured memory_bytes: 80256
#include <iostream>
#include<cstdlib>
#include<queue>
#include<set>
#include<vector>
#include<string>
#include<algorithm>
#include<stack>
#include<map>
#include<cstdio>
using namespace std;
#define rep(i,a) for(int i=0;i<a;i++)
#define mp make_pair
#define pb push_back
#define P pair<int,int>
#define ll long long
#define cat(p) cout<<p<<endl
#define catA(p,n) for(int i=0;i<n;i++)cout<<p[i]<<((i==n-1)?"\n":" ")

int main(){ 
  int a,b;
  cin>>a>>b;
  if(a>=13)cout<<b<<endl;  
  else if (a>=6&&a<=12)cout<<b/2<<endl;
  else cout<<0<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i ,n) for(int i = 0 ; i < (n) ; i ++ )
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
using ll = long long;
using vll=vector<ll>;
using P = pair<int, int>;
const int inf=1e9+7;
const ll INF=1e18;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }

string s,t;
int dp[3300][3300];
int main(){
  cin>>s>>t;
  int n=s.size(),m=t.size();
  for(int i=1;i<=n;i++){
     for(int j=1;j<=m;j++){
      
       if(s[i-1]==t[j-1]) chmax(dp[i][j] ,dp[i-1][j-1]+1);
       else{
         chmax(dp[i][j],dp[i-1][j]);
          chmax(dp[i][j],dp[i][j-1]);
       }//es
      
      
         
         
         
        
       
     }//j
  }//i
  
    string ans="";
  while(n>0&&m>0){
    if(dp[n][m]==dp[n-1][m]) 
         n--;
    else if(dp[n][m]==dp[n][m-1])
      m--;
    else {
      m--;
    n--;
    ans+=s[n];
    
    }
  }
  reverse(all(ans));
  cout<<ans<<endl;
  
}

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

#define MAX 1002
#define MOD 1000000007
template<typename ty1,typename ty2>
inline int add(ty1 x, ty2 y) {
	if(y>=MOD)y%=MOD;
	if(x>=MOD)x%=MOD;
    x += y; return x < MOD ? x : x - MOD;
}
template<typename ty1,typename ty2>
inline void addto(ty1 &x, ty2 y) {
		  if(y>=MOD)y%=MOD;
		  if(x>=MOD)x%=MOD;
	      x += y; if (x >= MOD) x -= MOD;
}
template<typename ty1,typename ty2>
inline int sub(ty1 x, ty2 y) {
		if(y>=MOD)y%=MOD;
		 if(x>=MOD)x%=MOD;
        x -= y; return x < 0 ? x + MOD : x;
}
template<typename ty1,typename ty2>
inline void subto(ty1 &x, ty2 y) {
	if(y>=MOD)y%=MOD;
	if(x>=MOD)x%=MOD;
    x -= y; if (x < 0) x += MOD;
}
template<typename ty1,typename ty2>
inline int mul(ty1 x, ty2 y) {
        if(y>=MOD)y%=MOD;
		if(x>=MOD)x%=MOD;
        return 1ll * x * y % MOD;
}
template<typename ty1,typename ty2>
void multo(ty1 &x, ty2 y) {
        if(y>=MOD)y%=MOD;
		if(x>=MOD)x%=MOD;
        x=1ll * x * y % MOD;
}
 
int n;
int k;

vector<int> v;

int dp[21][MAX];
#define MOD 1000000007
class Combination{
	long long int ppow(long long int i, long long int j){
		long long int res = 1LL;
		while (j){
			if ((j & 1LL)){
				res *= i;
				if (res >= MOD){
					res %= MOD;
				}
			}
			j >>= 1;
			i *= i;
			if (i >= MOD){
				i %= MOD;
			}
		}
		return res;
	}
public:
	vector<long long int> k;
	vector<long long int> r;
	void resize(int N){
		k.resize(N + 2);
		r.resize(N + 2);
		k[0] = 1;
		for (int i = 1; i < N+2; i++){
			k[i] = k[i - 1];
			k[i] *= i;
			if (k[i] >= MOD)k[i] %= MOD;
		}
		long long int al = k[k.size() - 1];
		long long int iv = ppow(k[k.size() - 1],MOD-2);
		r[k.size() - 1] = iv;
		for (int i = (int)(r.size()) - 2; i >= 0; i--){
			r[i] = r[i + 1] * (i + 1);
			if (r[i] >= MOD){
				r[i] %= MOD;
			}
		}
	}
	long long int C(int a, int b){
		if (a < b)return 0;
		long long int up = k[a];
		long long int dw = r[b] * r[a - b];
		dw %= MOD;
		up *= dw;
		up %= MOD;
		return up;
	}
	long long int H(int a, int b){
		return C(a + b - 1, b);
	}
	long long int catalan_number(int n){
		return (C(2 * n, n) + MOD - C(2 * n, n - 1)) % MOD;
	}
};


//Lucas theorem とか
Combination C;
int main(){
	cin>>n>>k;
	C.resize(n+2);
	for(int i=0;i<k;i++){
		int a;
		scanf("%d",&a);
		v.push_back(a);
	}
	dp[0][0]=1;
	for(int i=0;i<k;i++){
		for(int j=0;j<=n;j++){
			if(dp[i][j]==0)continue;
			for(int jj=j;jj<=n;jj++){
				if(jj-j<=v[i]){
					addto(dp[i+1][jj],mul(dp[i][j],mul(C.C(n-j,jj-j),C.C(n-(jj-j),v[i]-(jj-j)))));
				}
			}
		}
	}
	printf("%d\n",dp[k][n]);
	return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define pli pair<ll, int>
#define pil pair<int, ll>
#define pll pair<ll, ll>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
#define endl '\n'
const int inf = 1000000007;
const ll INF = 1e18;
// int mod = 998244353;
int mod = 1000000007;
#define abs(x) (x >= 0 ? x : -(x))
#define lb(v, x) (int)(lower_bound(all(v), x) - v.begin())
#define ub(v, x) (int)(upper_bound(all(v), x) - v.begin())
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
ll gcd(ll a, ll b) { if (b == 0) return a; return gcd(b, a % b); }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
template<typename T, typename U> T pow_(T a, U b) { return b ? pow_(a * a, b / 2) * (b % 2 ? a : 1) : 1; }
ll modpow(ll a, ll b, ll _mod) { return b ? modpow(a * a % _mod, b / 2, _mod) * (b % 2 ? a : 1) % _mod : 1; }
template<class T, class U> ostream& operator << (ostream& os, const pair<T, U>& p) { os << p.F << " " << p.S; return os; }
template<class T> ostream& operator << (ostream& os, const vector<T>& vec) { rep(i, sz(vec)) { if (i) os << " "; os << vec[i]; } return os; }
template<typename T> inline istream& operator >> (istream& is, vector<T>& v) { rep(j, sz(v)) is >> v[j]; return is; }
template<class T, class T2> inline void add(T &a, T2 b) { (a += b % mod) %= mod; if (a < 0) a += mod; }
template<class T> void operator += (vector<T>& v, vector<T> v2) { rep(i, sz(v2)) v.eb(v2[i]); }

void solve();

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cout << fixed << setprecision(12); // debuged
  int T;
  T = 1;
  while (T--) solve();
}

void solve() {
  vector<string> s({"Sunny", "Cloudy", "Rainy"});
  string t;
  cin >> t;
  rep(i, 3) {
    if (s[i] == t) {
      cout << s[(i + 1) % 3] << endl;
    }
  }
}


Measured memory_bytes: 3592
#include<iostream>
#include<iomanip>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
#include<cstring>
#include<sstream>
using namespace std;
 
#define P(p) cout<<(p)<<endl
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define rrep(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define vsort(v) sort(v.begin(), v.end());
#define rvsort(v) sort(v.begin(), v.end(),greater<int>());
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return
#define C(i) cin>>i
#define C2(i,j) cin>>i>>j
#define C3(i,j,k) cin>>i>>j>>k
#define C4(i,j,k,m) cin>>i>>j>>k>>m
////////////////////////////////////////////////////////////

int main(){
	int n;
	long c,k;
	cin >> n >> c >> k;
	vector<long> t(n);
	rep(i,0,n)
		cin >> t[i];
	vsort(t);
	queue<long> q;
	int i = 1;
	int ans = 0;

	rep(i,0,n){	
		if(q.size() >= c ){
			ans++;
			queue<long> ().swap(q);
		}

		if(q.empty()){
			q.push(t[i]);
			continue;
		}

		if( t[i] <= q.front() + k ){
			q.push(t[i]);
		}
		else{
			queue<long> ().swap(q);
			ans++;
			q.push(t[i]);
		}


	}

	if(!q.empty())
		ans++;

	P(ans);

	ret 0;
}

Measured memory_bytes: 1024
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <ctime>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstring>
#include <numeric>
#include <cassert>
using namespace std;
static const double EPS = 1e-10;
typedef long long ll;
#define rep(i,n) for(int i=0;i<n;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define all(a) a.begin(),a.end()
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define SS stringstream
#define DBG1(a) rep(_X,sz(a)){printf("%d ",a[_X]);}puts("");
#define DBG2(a) rep(_X,sz(a)){rep(_Y,sz(a[_X]))printf("%d ",a[_X][_Y]);puts("");}
#define bitcount(b) __builtin_popcount(b)
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)

#define delete(a,n) a.erase(remove(all(a),n),a.end())
template<typename T, typename S> vector<T>& operator<<(vector<T>& a, S b) { a.push_back(b); return a; }
template<typename T> void operator>>(vector<T>& a, int b) {while(b--)if(!a.empty())a.pop_back();}
bool isprime(int n){ if(n<2)return false;  for(int i=2;i*i<=n;i++)if(n%i==0)return false;  return true;} 
ll b_pow(ll x,ll n){return n ? b_pow(x*x,n/2)*(n%2?x:1) : 1ll;}
string itos(int n){stringstream ss;ss << n;return ss.str();}


int main(){
	ios_base::sync_with_stdio(false);
	int n;
	while(cin >> n && n){
		string s;
		getline(cin,s);
		map<string,int> cnt[128];
		for(int i = 0 ; i < n ; i++){
			getline(cin,s);
			if( s[s.size()-1] == '\r' ) s = s.substr(0,s.size()-1);
			stringstream ss(s);
			while( ss >> s ){
				cnt[s[0]][s]++;
			}
		}
		char c;
		cin >> c;
		vector< pair<int,string> > answer;
		EACH(it,cnt[c]){
			 answer.push_back(make_pair(-it->second,it->first));
		}
		sort(answer.begin(),answer.end());
		for(int i = 0 ; i < min(5,(int)answer.size()) ; i++)
			cout << (i?" ":"") << answer[i].second;
		if( answer.size() == 0 ) cout << "NA";
		cout << endl;
	}
}

Measured memory_bytes: 1256
#include <bits/stdc++.h>
using namespace std;
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define mp(a,b) make_pair((a),(b))
#define pb(a) push_back((a))
#define all(x) (x).begin(),(x).end()
#define uniq(x) sort(all(x)),(x).erase(unique(all(x)),end(x))
#define fi first
#define se second
#define dbg(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
void _dbg(string){cout<<endl;}
template<class H,class... T> void _dbg(string s,H h,T... t){int l=s.find(',');cout<<s.substr(0,l)<<" = "<<h<<", ";_dbg(s.substr(l+1),t...);}
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

#define INF 1120000000
#define MOD 1000000007

long mod_pow(long x, long n, long p=MOD){
  if(x==0) return 0;
  long res=1;
  x %= p;
  while(n>0){
    if(n&1) res=res*x%p;
    x=x*x%p;
    n>>=1;
  }
  return res;
}
long mod_inv(long x, long p=MOD){ return mod_pow(x%p, p-2, p); }


int main(){
  long n;
  cin>>n;
  string str;
  cin>>str;
  long m = str.size();

  auto prev = vector<long>(n+1, 0);
  prev[0] = 1;

  rep(i,n){
    auto nxt = vector<long>(n+1, 0);
    rep(j,n) if(prev[j]){
      if(j==0) nxt[j] += prev[j];
      else nxt[j-1] += prev[j];
      nxt[j+1] += 2*prev[j];
    }
    rep(j,n+1) nxt[j] %= MOD;
    swap(prev, nxt);
  }

  long ans = prev[m];
  ans *= mod_inv(mod_pow(2,m));

  cout << ans%MOD << endl;

  return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <fstream>

#include <string>

using namespace std;

void insertionSort(int *a, int N);
void pp_sorting(int *a,int N);

int main(){

    int N;
    int a[1000];

    cin >> N;
    for(int i=0;i<N;i++) cin >> a[i];

    pp_sorting(a,N);
    insertionSort(a,N);


    
    return 0;
}

void pp_sorting(int *a,int N){
    for(int i=0;i<N-1;i++) cout << a[i] << " ";
    cout << a[N-1] << endl;
}

void insertionSort(int *a, int N){
    for(int i=1;i<N;i++){
        int v = a[i];
        int j = i-1;
        while(j >= 0 && a[j] > v){
            a[j+1] = a[j];
            j--;
        }
        a[j+1] = v;
        pp_sorting(a, N);
    }
}


Measured memory_bytes: 3104
#include <bits/stdc++.h>
using namespace std;
#define PB push_back
#define FF first
#define SS second
const int N = 200000 + 5;

int cnt[N];

int main(){
	ios_base::sync_with_stdio(0);cin.tie(0);
	int n, k; cin>>n>>k;
	for(int i=0;i<n;i++){
		int x; cin>>x;
		cnt[x]++;
	}
	int ans = 0;
	priority_queue<int,vector<int>,greater<int>> pq;
	for(int i=1;i<=n;i++){
		if(cnt[i]==0) continue;
		pq.push(cnt[i]);
	}
	while(pq.size()>k){
		ans += pq.top(); pq.pop();
	}
	cout << ans << '\n';
	return 0;
}

Measured memory_bytes: 2168