akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
#define fi first
#define se second
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define pf push_front
#define eb emplace_back
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define SZ(x) (int)(x).size()
#define ft front()
#define bk back()
#define endl '\n'
#define FOR(a, aStr, c) for (auto(a) = (b); (a) < (c); ++(a))
#define ROF(a, b, c) for (auto(a) = (b); (a) > (c); --(a))
#define F0R(a, b) FOR ((a), 0, (b))
#define R0F(a, b) ROF ((a), (b), -1)
#define CEIL(a, b) ((a) + (b)-1) / (b)
#define SET(a, b) memset((a), (b), sizeof(a))
template <class t> bool ckmin(t& a, const t& b) { return a > b ? a = b, true : false; }
template <class t> bool ckmax(t& a, const t& b) { return a < b ? a = b, true : false; }
#ifndef DEBUG
#define DEBUG 0
#endif
#define dout \
  if (DEBUG) std::cerr
#define dvar(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
template <class a, class b>
ostream& operator<<(ostream& o, const pair<a, b>& p);
template <class T> struct IsC {
  template <class C>
  static char test(typename C::const_iterator*);
  template <class C>
  static int test(...);
  static const bool value = sizeof(test<T>(0)) == sizeof(char);
};
template <> struct IsC<string> { static const bool value = false; };
template <class C> typename enable_if<IsC<C>::value, ostream&>::type operator<<( ostream& o, const C& c) { o << '{'; for (auto it = c.begin(); it != c.end();) o << *it << (++it != c.end() ? ", " : "}"); return o; }
template <class a, class b> ostream& operator<<(ostream& o, const pair<a, b>& p) { return o << '(' << p.fi << ", " << p.se << ')'; }


void solve() {
    int aHp, aStr, bHp, bStr;
    cin >> aHp >> aStr >> bHp >> bStr;

    int aAtt = bHp / aStr + (bHp % aStr ? 1 : 0);
    int bAtt = aHp / bStr + (aHp % bStr ? 1 : 0);
    
    dout << dvar(aAtt) << dvar(bAtt) << endl;

    if(aAtt <= bAtt)
        cout << "Yes\n";
    else
        cout << "No\n";
    
}

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

    solve();
}




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

def divisor(n): 
    i = 1
    table = []
    while i * i <= n:
        if n%i == 0:
            table.append(i)
            table.append(n//i)
        i += 1
    table = list(set(table))
    return table
  
counter = 0
for i in range(1,N+1,2):
  if len(divisor(i)) == 8:
    counter += 1

print(counter)

Measured memory_bytes: 61660
/*  -*- coding: utf-8 -*-
 *
 * b.cc: B: Cakes and Donuts
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int C = 4;
const int D = 7;

/* typedef */

/* global variables */

/* subroutines */

/* main */

int main() {
  int n;
  scanf("%d", &n);

  for (int i = 0; i * C <= n; i++)
    if ((n - i * C) % D == 0) {
      puts("Yes");
      return 0;
    }
  puts("No");
  return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast,unroll-loops,no-stack-protector,unsafe-math-optimizations")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,sse4.1,sse4.2,popcnt,abm,mmx,avx,tune=native")
#include "bits/stdc++.h"
#include <assert.h>
#include <immintrin.h>
#include <emmintrin.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define PB push_back
#define MP make_pair
const int MOD=1000000007;
#define endl "\n"
#define fst first
#define snd second
const int UNDEF = -1;
const int INF=1<<30;
template<typename T> inline bool chkmax(T &aa, T bb) { return aa < bb ? aa = bb, true : false; }
template<typename T> inline bool chkmin(T &aa, T bb) { return aa > bb ? aa = bb, true : false; }
typedef pair<ll,ll> pll;typedef vector<ll> vll;typedef pair<int,int> pii;typedef vector<int> vi;typedef vector<vi> vvi;
#ifdef ONLINE_JUDGE
#define assert(...) /* nothing */
#endif
#define DEBUG_CAT
#ifdef DEBUG_CAT
#define dbg(...)   printf( __VA_ARGS__ )
#else 
#define dbg(...)   /****nothing****/
#endif
int rint();char rch();long long rlong();
vector<string> v;
int main()
{
  ios_base::sync_with_stdio(false); cin.tie(0);
  string s; int k; cin>>s>>k; int n=s.length();
  for (int x=0;x<n;x++) {
    int left=n-x;
    for (int l=1;l<=min(k,left);l++) {
      v.PB(s.substr(x,l));
    }
  }
  sort(v.begin(),v.end());
  unique(v.begin(),v.end());
  cout<<v[k-1]<<endl;
}


inline int _read_char() {
  static char buf[1 << 16], *ptr = buf, *end_ptr = buf;
  if (ptr == end_ptr) {
    int len = fread(buf, 1, sizeof(buf), stdin);
    if (len <= 0) return EOF;
    ptr = buf;
    end_ptr = buf + len;
  }
  return *ptr++;
}

inline char rch() {
  char ch=_read_char();
  while(ch=='\0'||ch=='\n') ch=_read_char();
  return ch;
}

inline int rint() {
  int ch; bool sg = 0;
  do {
    ch = _read_char();
    if (ch == '-') sg = 1;
  } while (ch < '0' || ch > '9');
  int x = ch - '0';
  while (true) {
    ch = _read_char();
    if (ch < '0' || ch > '9') break;
    x = x * 10 + ch - '0';
  }
  return (sg?-x:x);
}

inline long long rlong() {
  int ch; bool sg = 0;
  do {
    ch = _read_char();
    if (ch == '-') sg = 1;
  } while (ch < '0' || ch > '9');
  long long x = ch - '0';
  while (true) {
    ch = _read_char();
    if (ch < '0' || ch > '9') break;
    x = x * 10 + ch - '0';
  }
  return (sg?-x:x);
}


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



int N;
vector<int> P;
vector<int> Q;

ll get_order( vector<int> v )
{
	vector<int> used(N);
	
	ll order = 0;
	for ( int i = 0; i < N-1; i++ ){
		int d = v[i]-1;
		used[d] = 1;
		
		int ct = 0;
		for ( int j = 0; j < d; j++ )
			if ( used[j] == 1 ) ct++;
		
		order += (d-ct);
		order *= (N-i-1);
	}
	
	return order;
}



int main(){
	cin >> N;
	P.resize(N);
	Q.resize(N);
	
	for ( int i = 0; i < N; i++ ){
		cin >> P[i];
	}
	for ( int i = 0; i < N; i++ ){
		cin >> Q[i];
	}
	
	ll diff = get_order(P) - get_order(Q);
	if ( diff < 0 )
		diff = -diff;
	
	cout << diff << endl;
	
	return 0;
}


Measured memory_bytes: 256
import java.io.PrintWriter

val pw = PrintWriter(System.out)
fun main(args : Array<String>) {
    func()
    pw.flush()
}

fun func() {
    var n = nextInt()
    var da = listOfInt()
    var ans = 1000000
    for(i in 0 until 100){
        var cnd = 0
        for(j in 0 until n){
            cnd += (da[j]-i)*(da[j]-i)
        }
        ans = min(ans, cnd)
    }
    println(ans)
}

fun max(a :Int, b : Int) : Int{
    if(a > b){
        return a
    }
    else{
        return b
    }
}

fun min(a :Int, b : Int) : Int{
    if(a < b){
        return a
    }
    else{
        return b
    }
}

// 入力取得
fun next() = readLine()!!
fun nextInt() = next().toInt()
fun nextLong() = next().toLong()
fun nextDouble() = next().toDouble()
fun listOfString() = next().split(" ")
fun listOfInt() =listOfString().map { it.toInt() }
fun listOfLong() =listOfString().map { it.toLong() }
fun listOfDouble() =listOfString().map { it.toDouble() }

// 約数のList
fun divisor(value : Long) : List<Long> {
    val max = Math.sqrt(value.toDouble()).toLong()
    return (1..max)
        .filter { value % it == 0L }
        .map { listOf(it, value / it) }
        .flatten()
        .sorted()
}

// 範囲内の素数を取得
// fromだけ指定すると戻り値の個数で素数判定ができる
fun prime(from : Long, to : Long = from) : List<Long> {
    return (from..to).filter { i ->
        val max = Math.sqrt(i.toDouble()).toLong()
        (2..max).all { j ->  i % j != 0L }
    }
}

// 素因数分解
fun decom(value : Long) : List<Long>{
    if (value == 1L) return listOf(1)
    val max = Math.sqrt(value.toDouble()).toLong()
    return prime(2, max).filter { value % it == 0L }
}

// 最大公約数
fun gcd(a : Long, b : Long) : Long {
    return if (a % b == 0L) b else gcd(b, a % b)
}

// 文字列を入れ替え
fun swap(base : String, a : String, b : String) : String {
    return base.map {
        when (it) {
            a.toCharArray()[0] -> b
            b.toCharArray()[0] -> a
            else -> it.toString()
        }
    }.joinToString()
}

fun println(value : Any) {
    pw.println(value)
}

Measured memory_bytes: 37740
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
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;}
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(vec) vec.begin(),vec.end()
typedef long long ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
const ll mod=1e9+7;
const int inf=1<<30;

int dp[110][100010];

int main(){
  int n,W; cin >> n >> W;
  vector<int> w(n);
  vector<int> v(n);
  rep(i,n){
    cin >> w[i] >> v[i];
  }
  rep(i,n+1)rep(j,100010) dp[i][j]=inf;
  dp[0][0]=0;
  rep(i,n){
    rep(j,100010){
      chmin(dp[i+1][j+v[i]],dp[i][j]+w[i]);
      chmin(dp[i+1][j],dp[i][j]);
    }
  }
  int ans=0;
  rep(j,100010){
    if(dp[n][j]<=W) ans=j;
  }
  cout << ans << endl;
}


Measured memory_bytes: 41216
#include<iostream>
#include<vector>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<queue>
#include<deque>
#include<map>
#include<bitset>
using namespace std;

typedef long long ll;
#define rep(i, n) for(int i = 0;i < (n);i++)
#define repr(i, n) for(int i = (n);i >= 0;i--)
#define repf(i, m, n) for(int i = (m);i < (n);i++)
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;}
int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0};
//////////////////////////////////////////////////


int main() {
    ll h; cin >> h;
    ll tmp = 1, cnt = 0;
    ll ans = 0;
    while (h) {
        h /= 2;
        ans += tmp;
        tmp *= 2;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define IREP(i,n) for(int i=n-1;i>=0;i--)
#define MOD 1000000007

typedef long long ll;
using namespace std;
int main(){
	int n,m;
	cin >> n >> m;
	vector<ll> v(1,1);
	for(int i=1;i<=100000;i++){
		v.push_back((v[i-1]*i)%MOD);
	}
	ll ans=0;
	if(n==m){
		ans=(v[n]*v[m]*2)%MOD;
	}
	else if(abs(n-m)==1){
		ans=(v[n]*v[m])%MOD;
	}
	else{
		ans=0;
	}
	cout << ans << endl;
}

Measured memory_bytes: 1400
#include <stdio.h>

int main(){
    int t[4];
    int n[4];
    for(int i = 0; i < 4; i++){
        scanf("%d", &t[i]);
        scanf("%d", &n[i]);
    }
    for(int i = 0; i < 4; i++){
        if(t[i] == 1){
            printf("%d\n", n[i] * 6000);
        }
        if(t[i] == 2){
            printf("%d\n", n[i] * 4000);
        }
        if(t[i] == 3){
            printf("%d\n", n[i] * 3000);
        }
        if(t[i] == 4){
            printf("%d\n", n[i] * 2000);
        }
    }
    return 0;
}


Measured memory_bytes: 2100
#include<iostream>
#include<climits>
#include<vector>
#include<list>
#include<functional>
#include<algorithm>
#include<string>
#include<cmath>
#include<complex>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<(n);i++)
#define INF (int)1e9
#define INFL (ll)1e11
using namespace std;
typedef long long ll;
typedef pair<int, int> P;

set<int> d(int m) {
	int n = sqrt(m);
	set<int> st;
	for (int i = 1;i <= n;i++) {
		if (m%i == 0) {
			st.insert(i);
			st.insert(m / i);
		}
	}
	return st;
}

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

	int N, M;
	cin >> N >> M;
	set<int> st = d(M);
	set<int>::iterator it = --st.end();
	while (M / (*it) < N) it--;
	cout << *it << "\n";

	return 0;
}



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

alphabets = "abcdefghij"

def call( n, string, limit):
  """stringに対してn回後ろに付与するとしたらどうなるか、リストで頂戴。
  limitまでの文字しか使っちゃダメたよ"""
  if n ==0 :
    return set([string])
  
  res = set()
  for char in alphabets[:limit]:
    # print(string+char)
    res |= call(n-1, string+char, limit)
  res |= call(n-1, string+alphabets[limit], limit+1)
  return res
  
for i in sorted(list(call(N-1, "a", 1))):
  print(i)

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

#pragma GCC optimize "O3"
#define rep(i,a,n) for(long long i=a; i<n; i++)
typedef long long ll;
typedef pair<int,int> P;
const ll MOD = (int)1e9+7;
const ll INF = MOD*MOD;
const double EPS = 1e-9;
const ll powll = 1LL<<1;

/*
while(!frag && cin >> a >>b, a|b)
*/

int main(void){
   int n; cin >> n;
   int a[n],b[n], c[n];
   rep(i,0,n){
      cin >> a[i] >> b[i] >> c[i];
   }

   int dp[n+1][3];
   rep(i,0,3) dp[0][i] = 0;

   rep(i,0,n){
      dp[i+1][0] = a[i] + max(dp[i][1], dp[i][2]);
      dp[i+1][1] = b[i] + max(dp[i][0], dp[i][2]);
      dp[i+1][2] = c[i] + max(dp[i][0], dp[i][1]);
   }

   cout << max(dp[n][0], max(dp[n][1], dp[n][2])) << "\n";
}

Measured memory_bytes: 5932
#include<iostream>
#include<algorithm>
#include<vector>
#include<cmath>
#define all(a) (a).begin(),(a).end()
#define EPS 1e-8
using namespace std;

typedef long long ll;

int main(){
  ll n,b;
  vector<ll> odd,even;
  while(cin >> n,n){
    odd.clear(); even.clear();
    for(int i=0;i<n*(n+1)/2;i++){
      cin >> b;
      if(b&1)odd.push_back(b);
      else even.push_back(b);
    }

    sort(all(odd)); sort(all(even));

    ll tmp = __gcd(even[0],even[1]);
    for(ll i=2;i<n;i++)tmp = __gcd(tmp,even[i]);
 
    ll t0 = even[0]/tmp, t1 = even[1]/tmp;

    ll hoge = odd[0]/(t0*t1);

    ll sq = (ll)(sqrt(hoge)+EPS);
    //for(sq=0;sq*sq!=hoge;sq++);
    tmp /= sq;

    cout << tmp << endl;
    for(int i=0;i<n-1;i++)cout << even[i]/tmp << " ";
    cout << even[n-1]/tmp << endl;
  }
}

Measured memory_bytes: 1284
/*
  リング(図のようなリング状の文字列sの任意の位置から、
  時計回りに連続した文字をいくつか選んで、
  文字列pが作れるかを判定するプログラム)
  2018/02/23
*/

#include<stdio.h>
int main(void){
  char s[100],p[100];/*1≤pの長さ≤sの長さ≤100*/
  int i,j,k;
  int flag;/*pが作れる場合は1、作れない場合は0*/
  scanf("%s",s);
  scanf(" %s",p);

  i=0;
  flag = 0;
  while(s[i] != '\0'){
    j=0;
    k=i;
    while(s[k] == p[j] && p[j] != '\0'){
      j++;
      if(s[k+1] != '\0')
	k++;
      else
	k=0;
    }
    if(p[j] == '\0')
      flag = 1;
    i++;
  }

  if(flag == 1)
    printf("Yes\n");
  else
    printf("No\n");
  return 0;
}


Measured memory_bytes: 2100
a, b, c, k = gets.chomp.split.map(&:to_i)
 
ans = 0
 
if a >= k
  ans += k
  puts ans
  exit
elsif a < k
  ans += a
  k -= a
end
 
if b >= k
  puts ans
  exit
elsif b < k
  k -= b
end
 
ans -= k
 
puts ans

Measured memory_bytes: 14272
#include<iostream>
#include<algorithm>
#include<fstream>
#include<cstdlib>
#include<cstring>
#include<cstdio>
#include<string>
#include<cmath>
#include<cctype>
#include<vector>
#include<limits.h>
#include<queue>


using namespace std;

char s[100005];
int p[100005];
int main()
{
    int n,m,num,i,ans,l,r;
    scanf("%d%d",&n,&m);
    scanf("%s",s);
    num=strlen(s);
    for(i=1,ans=0; i<num; ++i)
    {
        if(s[i]=='C'&&s[i-1]=='A')
        {
            ans++;
        }
        p[i]=ans;
    }
    while(m--)
    {
        scanf("%d%d",&l,&r);
        int c=p[r-1]-p[l-1];
        printf("%d\n",c);
    }
    //for(i=0;i<n;++i)
      //  cout<<p[i]<<endl;
    return 0;
}


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

int b[111];
int main() {
    int n, k;
    cin >> n >> k;
    for(int i = 0; i < k; i++) {
        int d, a;
        cin >> d;
        for(int j = 0; j < d; j++)
            cin >> a, b[a]++;
    }
    int r = 0;
    for(int i = 0; i < n; i++)
        if(!b[i + 1])
            r++;
    cout << r << endl;
    return 0;
}


Measured memory_bytes: 3632
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<vector>
#include<algorithm>
#include<string>
#include<stack>
#include<map>
#include<cmath>
#include<queue>
#include<set>
#include<string>
using namespace std;
typedef pair<int,int> P;
typedef long long LL;
typedef unsigned long long ULL;
const LL mod=1e9+7;
const LL LL_MAX=9223372036854775807;
const LL maxn=4e5+10;
LL read()
{
    LL x=0,f=1;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}
int read1()
{
    int x=0,f=1;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}
int a[35]={0,1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
int main()
{
     int k;
     cin>>k;
     cout<<a[k]<<endl;
    return 0;
}


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

vector<tuple<ll, ll, ll>>vec;

int main() {
	cin.tie(0)->sync_with_stdio(false);

	int n; cin >> n;
	vector<int> x(n), y(n), h(n);
	int t;
	REP(i, n) {
		cin >> x[i] >> y[i] >> h[i];
		if (h[i] > 0) t = i;
	}

	REP(i, 101) REP(j, 101) {
		ll H = h[t] + abs(x[t] - j) + abs(y[t] - i);
		H = max(H, 0LL);
		bool ok = true;
		REP(k, n) {
			ll HH = H - abs(x[k] - j) - abs(y[k] - i);
			HH = max(HH, 0LL);
			if (h[k] != HH)
				ok = false;
			// ok &= (h[k] == HH);
		}
		if (ok) {
			cout << j << " " << i << " " << H << '\n';
			return 0;
		}
	}
	return 0;
}


Measured memory_bytes: 3628
/*                        ______
 _______   /\     |``\   |        |  /
    |     /  \    |__/   |____    |/
    |    / _ _\   |  \   |        |\
    |   /      \  |   \  |______  |  \

            Dept. of CSE
        Comilla  University

*/
#include<bits/stdc++.h>
#define pi 2*acos(0.0)
#define ll long long
#define FIO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define Node struct node
#define spc " "
#define  E  2.71828182845904523536
#define pb push_back
#define pp pop_back
#define valid(nx,ny) nx>=0 && nx<n && ny>=0 && ny<m
#define ee endl
#define pii pair<int,int>
#define infinity 10000000000000000
#define mod 1000000007
int fx[]={0,0,+1,-1};
int fy[]={+1,-1,0,0};

using namespace std;
///check n=1;
///check corner case;
const int maX=1e5+1;
vector<ll>Graph[maX],cost[maX];
ll visit[maX];
ll x[10];
ll y[10];

int main()
{
   ll a,b;
   cin>>a>>b;
   cout<<fixed<<setprecision(10)<<a*1.0/b*1.0<<endl;
return 0;
}


Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

const int INF = 0x3f3f3f3f;
int N, M, R;
int r[10];
int A[50000],B[50000],C[50000];
int dist[250][250];

void solve()
{
	memset(dist,0x3f,sizeof(dist));
	for(int i=1;i<=N;++i)dist[i][i]=0;
	for(int i=0;i<M;++i){
		dist[A[i]][B[i]]=dist[B[i]][A[i]]=C[i];
	}
	for(int k=1;k<=N;++k)for(int i=1;i<=N;++i)for(int j=1;j<=N;++j){
		dist[i][j]=min(dist[i][j],dist[i][k]+dist[k][j]);
	}
	int ans = INF;
	sort(r,r+R);
	do{
		int cur=0;
		bool ok = true;
		for(int i=1;i<R;++i){
			if(dist[r[i]][r[i-1]]==INF){
				ok = false;
				break;
			}
			cur += dist[r[i]][r[i-1]];
		}
		if(ok) ans = min(ans, cur);
	}while(next_permutation(r,r+R));
	cout << ans << '\n';
}

int main()
{
	cin >> N >> M >> R;
	for(int i=0;i<R;++i) cin >> r[i];
	for(int i=0;i<M;++i) cin >> A[i] >> B[i] >> C[i];
	solve();
	return 0;
}

Measured memory_bytes: 4060
S=list(input())
N=len(S)

dp=[[0 for i in range(13)] for j in range(N+1)]
dp[0][0]=1

for i in range(N):
    if S[i]=="?":
        temp=10**((N-i-1)%6)
        for j in range(10):
            for k in range(13):
                dp[i+1][(k+j*temp)%13]+=dp[i][k]
                dp[i+1][(k+j*temp)%13]%=10**9+7
                    
    else:
        temp=int(S[i])*10**((N-i-1)%6)
        for k in range(13):
            dp[i+1][(k+temp)%13]+=dp[i][k]
            dp[i+1][(k+temp)%13]%=10**9+7

print(dp[-1][5])

Measured memory_bytes: 70152
#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ll long long 
#define REP(i, a, b) for (ll i = a; i < b; i++)
#define REPI(i, a, b) for (ll i = b - 1; i >= a; i--)
#define i_os ios::sync_with_stdio(0);  cin.tie(0);  cout.tie(0);
#define INF (ll)1e18 + 100
#define endl "\n"
#define p0(a) cout << a << " "
#define p1(a) cout << a << endl
#define p2(a, b) cout << a << " " << b << endl
#define p3(a, b, c) cout << a << " " << b << " " << c << endl
#define p4(a, b, c, d) cout << a << " " << b << " " << c << " " << d << endl
#define MAX 1e6
/*SOME BITMASK KNOWLEDGE
1)x & (x - 1):sets the last one bit of x to zero
power of two exactly when x & (x − 1) = 0.
2)x & -x:sets all the one bits to zero, except last one bit
3)x | (x - 1):inverts all the bits after the last one bit*/
#define o_set tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>
#define o_setll tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update>
typedef tree<pair<ll, ll>,null_type,less<pair<ll, ll>>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;
//1. order_of_key(k) : number of elements strictly lesser than k
//2. find_by_order(k) : k-th element in the set


int main() 
{
	ll n,k;
	cin>>n>>k;
	ll ans = 0;
	int mod = 1e9 + 7;
	ll pref = 0,suff = 0;
	ll sum  = 0;
	REP(i,0,k){
		pref = (pref + i) % mod;
	}
	REP(i,0,k){
		suff = (suff + (n-i)) % mod;
	}
	REP(i,k,n+2){
		sum = (sum + suff - pref + 1 + mod) % mod;
		pref = (pref + i) % mod;
		suff = (suff + (n - i)) % mod;
	}
	cout<<sum<<endl;

	return 0;
}  


Measured memory_bytes: 3576
#include <bits/stdc++.h>
#define rep3(i, s, n, a) for (int i = (s); i < (int)(n); i += a)
#define rep2(i, s, n) rep3(i, s, n, 1)
#define rep(i, n) rep2(i, 0, n)

using namespace std;
using ll = long long;
using ull = unsigned long long;
using P = pair<int, int>;

int main(){
    int k, t;
    cin >> k >> t;
    vector<int> a;
    rep(i, t){
        int x;
        cin >> x;
        a.push_back(x);
    }
    sort(a.begin(), a.end());
    int maxim = a[t-1];
    cout << max(0, 2*maxim-k-1) << endl;
    return 0;
}

Measured memory_bytes: 3512
n = int(input())
s = input()

r_cnt = s.count('R')
g_cnt = s.count('G')
b_cnt = s.count('B')

total = r_cnt*g_cnt*b_cnt

for i in range(0,n):
  for j in range(1,n):
    if i+(2*j)>=n:
      break
    if s[i]!=s[i+j] and s[i+j]!=s[i+2*j] and s[i]!=s[i+2*j]:
      total += -1

print(total)



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

// M A F I A - M A F I A - M A F I A - M A F I A - M A F I A - M A F I A //

#define int                                       long long
#define lop(i,s,e)                                for(int i=s;i<(int)e;i++)
#define rlop(i,e,s)                               for(int i=e;i>=s;i--)
#define prvec(v)                                  lop(R15,0,v.size())cout << v[R15] <<" "; cout << endl;
#define prarr(arr,s1,e1)                          lop(R15,s1,e1)cout << arr[R15] << " "; cout << endl;

#define endl                                      '\n'
#define ff                                        first
#define ss                                        second
#define pii                                       pair<int,int>

#define pb                                        push_back
#define all(v)                                    v.begin(),v.end()

// M A F I A - M A F I A - M A F I A - M A F I A - M A F I A - M A F I A //

const int N = 3e6 + 7, M = 1000000007, inf = INT_MAX;
const long long INF = LLONG_MAX;

int n, Q;
int arr[N + 2];


void solve()
{
	int a, b, c, d ;
	cin >> a >> b >> c >> d;
	bool f = 1;
	while ( a > 0 and c > 0 )
	{
		if (f)
		{
			c -= b;
		}
		else a -= d;

		f = !f;
	}

	if ( a > c ) cout << "Yes" << endl;
	else cout << "No" << endl;

}

int32_t main()
{
	ios_base::sync_with_stdio(0);   cin.tie(0);   cout.tie(0);

	int test = 1;
	// cin >> test;
	while (test--)solve();


}





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

int main(){
	int A, B, Q;
	cin >> A >> B >> Q;
	vector<ll> s(A+2), t(B+2);
	s[0] = -1e18, s[A+1] = 1e18;
	t[0] = s[0], t[B+1] = s[A+1];
	for(int i=1; i<A+1; i++) cin >> s[i]; 
	for(int i=1; i<B+1; i++) cin >> t[i]; 
	sort(s.begin(), s.end());
	sort(t.begin(), t.end());
	for(int i=0; i<Q; i++){
		ll x;
		cin >> x;
		int sR = lower_bound(s.begin(), s.end(), x) - s.begin();
		int tR = lower_bound(t.begin(), t.end(), x) - t.begin();
		ll ans = 1e18;
		for(int j=sR-1; j<sR+1; j++){
			for(int k=tR-1; k<tR+1; k++){
				ans = min(ans, min(abs(x-s[j]), abs(x-t[k])) + abs(s[j]-t[k]));
			}
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 2944
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int mod = 1e9 + 7;

int check(int a, int b, int c)
{
    if (a == b || b == c || a == c)
        return 0;

    if (a + b > c && b + c > a && c + a > b)
        return 1;

    return 0;
}

int main()
{
    // freopen("filename.in","r",stdin);
    // freopen("filename.out","w",stdout);
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);

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

    int cnt = 0;
    for (int i = 0; i < n; i++)
    {
        for (int j = i + 1; j < n; j++)
        {
            for (int k = j + 1; k < n; k++)
            {

                if (check(a[i], a[j], a[k]))
                    cnt++;
            }
        }
    }

    cout << cnt << "\n";

    return 0;
}

Measured memory_bytes: 3628
ABCD = input()
operations = []
def culc(num, ope):
    if len(ope) == 4:
        if num == 7:
            return operations.append(ope)
        else:
            return
    
    if len(ope) != 0 and ope[-1] == '+':
        num += int(ABCD[len(ope)])
    elif len(ope) != 0 and ope[-1] == '-':
        num -= int(ABCD[len(ope)])
    
    culc(num, ope+'+')
    culc(num, ope+'-')
        
culc(int(ABCD[0]), '')
ans = ''
for i in range(len(ABCD)):
    ans += ABCD[i] + operations[0][i]
print(ans[:7] + '=7')

Measured memory_bytes: 9136
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define f first
#define s second
#define mp make_pair
#define pb push_back
#define vll vector<ll>

using namespace std;

const ll N = 3e5+100;
const ll MOD = 1e9+7;

int main()
{

	ll a,b,k;
	cin>>a>>b>>k;


	if(k <= a){
		cout<<max(0LL,(a-k))<< " "<<b<<endl;
		return 0;
	}k-=a;
	a=0;
//	k-=a;
	b-=k;
	cout<<a<<" "<<max(0LL,b)<<endl;

	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define WHOLE(v) (v).begin(), (v).end()
#define REV_WHOLE(v) (v).rbegin(), (v).rend()
using i64 = int64_t;
using namespace std;
template<class F>auto recursive(F f){return[f](auto...a){return f(f,a...);};}
template<class T>using rev_priority_queue=priority_queue<T,vector<T>,greater<T>>;
template<class T>using vector2d=vector<vector<T>>;
struct fixprec{int p;fixprec(int p):p(p){}};
ostream&operator<<(ostream&o,fixprec f){return o<<fixed<<setprecision(f.p);}

int main() {
    i64 X;
    cin >> X;
    for(i64 a = -8e3; a <= 8e3; a++) {
        for(i64 b = -8e3; b <= 8e3; b++) {
            i64 x = a * a * a * a * a - b * b * b * b * b;
            if(X == x) {
                cout << a << " " << b << endl;
                return 0;
            }
        }
    }
    return 0;
}

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

int main(){
  int H, i;
  int A[MAX+1];

  scanf("%d",&H);

  for ( i = 1; i <= H; i++ ) scanf("%d",&A[i]);

  for ( i = 1; i <= H; i++ ) {
    printf("node %d: key = %d, ",i,A[i]);

    if ( i / 2 >= 1 )
      printf("parent key = %d, ",A[i/2]);
    if ( 2*i <= H )
      printf("left key = %d, ",A[2*i]);
    if ( (2*i+1) <= H )
      printf("right key = %d, ",A[2*i+1]);

    printf("\n");
  }
  
  return 0;
}



Measured memory_bytes: 2056
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,queue,copy

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()

def main():
  h=I()
  w=I()
  n=I()

  a=max(h,w)

  c=0
  for i in range(1,100000):
    c=a*i
    if c>=n:
      return i

# main()
print(main())


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

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

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

import qualified Data.ByteString.Char8 as B

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

import Debug.Trace
import Text.Printf

readInt = readLn :: IO Int
readInteger = readLn :: IO Integer
readInts = map ( fst . fromJust . B.readInt ) . B.words <$> B.getLine
readIntegers = map ( fst . fromJust . B.readInteger ) . B.words <$> B.getLine

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

modifyArray a i f = writeArray a i =<< f <$> readArray a i

main = readInts >>= print . ( 15 - ) . sum

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

long long MOD = 1e9+7;
int MAX_INT = 1e9;

// 最大公約数
long long gcd(long long a, long long b){
  if(b == 0) return a;
  return gcd(b, a % b);
}
// 最小公倍数
long long lcm(long long a, long long b) {
  return a / gcd(a, b) * b;
}

int main(void){
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);

  string S;
  cin >> S;

  int cnt = 0;
  for(int i = 0; i < S.size() - 1; ++i) {
    if (S[i]!=S[i+1]) {
      cnt++;
    }
  }

  cout << cnt << endl;

  return 0;
}


Measured memory_bytes: 3740
#include<stdio.h>
#include<math.h>

int main(void){
  double x1,x2,y1,y2;
  double d;
  scanf("%lf %lf %lf %lf",&x1,&y1,&x2,&y2);
  d=sqrt(pow((x2-x1),2)+pow((y2-y1),2));
  printf("%lf\n",d);
  return 0;
}


Measured memory_bytes: 2108
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define itn int
#define mod 1000000007
#define INFi 2147483647
#define INFl 9223372036854775807LL
#define fi first
#define se second
#define be begin()
#define en end()
int abs(int a,int b){
    return max(a,b)-min(a,b);
}
int gcd(int a,int b){//最大公約数
int c=a%b;
while(true){
if(c==0) break;
a=b;
b=c;
c=a%b;
}
return b;
}
bool IsPrime(int num){
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false;
    double sqrtNum = sqrt(num);
    for(int i=3;i<sqrtNum;i+=2){
	if(num%i==0){
	    return false;
	}
    }
    return true;
}
int lcm(int a,int b){//最小公倍数
return (a*b)/gcd(a,b);
}	
priority_queue<int> q;
int date[4];
signed main(){
// __builtin_ctz(N); Nを２で何回割り切れるかを返す
//(n+1)*n/2; １からNまでの総和を求める式
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a,b,c,d,e,sum=0;
    string f;
    cin>>a>>b>>c>>d>>e;
    cin>>f;
    for(int i=0;i<f.size();i++){
	if(f[i]=='r') sum+=e;
	if(f[i]=='s') sum+=c;
	if(f[i]=='p') sum+=d;
    }
    for(int i=b;i<f.size();i++){
	if(f[i-b]==f[i]){
	    if(f[i]=='r'){
		sum-=e;
		f[i]='#';
	    }
	    if(f[i]=='s'){
		sum-=c;
		f[i]='.';
	    }
	    if(f[i]=='p'){
		sum-=d;
		f[i]='-';
	    }
	}
    }
    cout<<sum<<"\n";
}
/*

    グーで勝った場合、 R 点
    チョキで勝った場合、 S 点
    パーで勝った場合、 P 点

r  グーを出すことを
s  チョキを出すことを、
p  パーを出すことを表します。
*/


Measured memory_bytes: 512
import sys
import numpy as np

sys.setrecursionlimit(10 ** 6)
INF = float("inf")
MOD = 10 ** 9 + 7


def input():
    return sys.stdin.readline().strip()


def main():
    N = int(input())
    A = list(map(int, input().split()))

    # a ^ b <= a + b が成り立つ
    ans = 0
    right = 0
    xor = 0
    s = 0
    for left in range(N):
        while right < N and s + A[right] == xor ^ A[right]:
            s += A[right]
            xor ^= A[right]
            right += 1

        ans += right - left

        if right == left:
            right += 1
        else:
            s -= A[left]
            xor ^= A[left]

    print(ans)


if __name__ == "__main__":
    main()


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

using namespace std;

struct Node{
    int key;
    Node *prev, *next;
};

Node *nil;

void init(){
    nil = (Node *)malloc(sizeof(Node));
    nil -> next = nil;
    nil -> prev = nil;
}

void insert(int key){
    Node *x = (Node *)malloc(sizeof(Node));
    x -> key = key;
    x -> next = nil -> next;
    x -> next -> prev = x;
    x -> prev = nil;
    nil -> next = x;
}

Node* listSearch(int key){
    Node *sercher = nil->next;
    while(key != sercher->key && sercher != nil){
        sercher = sercher->next;
    }
    return sercher;
}

void deleteNode(Node *del){
    if(del == nil)return;
    del->prev->next = del->next;
    del->next->prev = del->prev;
    free(del);
}

void deleteKey(int key){
    deleteNode(listSearch(key));
}

void deleteFirst(){
    deleteNode(nil->next);
}

void deleteLast(){
    deleteNode(nil->prev);
}

void printNode(){
    Node *print = nil->next;
    cout << print->key;
    print = print->next;
    while(print != nil){
        cout << " " << print->key;
        print = print->next;
    }
    cout << endl;
}

int main(void){
    int n; cin >> n;
    string command;
    init();
    for(int i = 0; i < n; i++){
        cin >> command;
        if(command == "insert"){
            int value; cin >> value;
            insert(value);
        }else if(command == "delete"){
            int value; cin >> value;
            deleteKey(value);
        }else if(command == "deleteFirst"){
            deleteFirst();
        }else if(command == "deleteLast"){
            deleteLast();
        }else{}
    }
    printNode();
}


Measured memory_bytes: 34296
#include<bits/stdc++.h>
using namespace std;
int main () 
{
	string s;
	cin>>s;
	if(s=="SUN")
	{
		cout<<"7";
	}
	if(s=="MON")
	{
		cout<<"6";
	}
	if(s=="TUE")
	{
		cout<<"5";
	}
	if(s=="WED")
	{
		cout<<"4";
	}
	if(s=="THU")
	{
		cout<<"3";
	}
	if(s=="FRI")
	{
		cout<<"2";
	}
	if(s=="SAT")
	{
		cout<<"1";
	}
	return 0;
}

Measured memory_bytes: 256
open System

#nowarn "25"

let readLine _ = Console.In.ReadLine()
let readInt<'a> = readLine >> int
let readLong<'a> = readLine >> int64
let readFloat<'a> = readLine >> float
let readArray _ = readLine().Split ' '
let readIntArray _ = readArray() |> Array.map (int)

[<EntryPoint>]
let main _ =
    let [|n; m|] = readIntArray()
    (if n = m then "Yes" else "No") |> printfn "%s"
    0 // return an integer exit code


Measured memory_bytes: 14044
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <cmath>
#include <map>
#include <fstream>
#include <iterator>

// #include "prettyprint.hpp"

using namespace std;
typedef long long ll;
// vector<vector<int>> vvi;
// vvi = vector<vector<int>>(20, vector<int>(10, 0));

// A -> 0
// C -> 1
// G -> 2
// T -> 3

// dp[length][last][last-1][last-2]
int dp[110][4][4][4];
const int MOD = 1000000007;

int main()
{
    int N;
    cin >> N;
    dp[0][3][3][3] = 1;
    for (int len = 0; len < N; ++len)
    {
        for (int i = 0; i < 4; ++i)
        {
            for (int j = 0; j < 4; ++j)
            {
                for (int k = 0; k < 4; ++k)
                {
                    for (int a = 0; a < 4; ++a)
                    {
                        if (a == 2 && i == 1 && j == 0)
                            continue;
                        if (a == 2 && i == 0 && j == 1)
                            continue;
                        if (a == 1 && i == 2 && j == 0)
                            continue;
                        if (a == 2 && i == 1 && k == 0)
                            continue;
                        if (a == 2 && j == 1 && k == 0)
                            continue;
                        dp[len + 1][a][i][j] += dp[len][i][j][k];
                        dp[len + 1][a][i][j] %= MOD;
                    }
                }
            }
        }
    }

    int ans = 0;
    for (int i = 0; i < 4; ++i)
    {
        for (int j = 0; j < 4; ++j)
        {
            for (int k = 0; k < 4; ++k)
            {
                ans += dp[N][i][j][k];
                ans %= MOD;
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
x = list(map(int,input().split()))
H = x[0]
W = x[1]

if H == 1 or W == 1:
    print(1)
else:
    if W % 2 == 0:
        print(int(H*W/2))
    else:
        if H % 2 == 0:
            print(int(H*(W-1)/2 + H/2))
        else:
            print(int(H*(W-1)/2 + (H+1)/2))


Measured memory_bytes: 9052
#include <iostream>
#include <vector>
#include <queue>

#define NMAX 100000
#define MMAX 200000

using namespace std;

vector<int> path[NMAX+1];
bool visited[NMAX+1];
int back[NMAX+1];

int main(void){
  int N,M;
  cin >> N >> M;
  for(int i=0;i<M;i++){
    int a,b;
    cin >> a >> b;
    path[a].push_back(b);
    path[b].push_back(a);
  }

  // initialize
  for(int n=0;n<=N;n++){
    visited[n] = true;
    back[n] = 0;
  }
  visited[1] = false;
  queue<int> q;
  q.push(1);
  while(q.size()){
    int room = q.front();
    q.pop();
    // roomから繋がる道をすべて探索
    for(int i=0;i<path[room].size();i++){
      int next = path[room][i];
      //まだ訪れていない
      if(visited[next] == true){
	back[next] = room;
	visited[next] = false;
	q.push(next);
      }
    }
  }
  // 全部やったか数える
  for(int n=1;n<=N;n++){
    if(visited[n]){
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
  // 道が存在
  for(int n=2;n<=N;n++){
    cout << back[n] << endl;
  }
  
  return 0;
}


Measured memory_bytes: 10508
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define fastio ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
//STANDARD DATA TYPES
#define ll long long
#define llu unsigned long long
#define ld long double
//ADV DATA TYPES
#define pii pair < int , int >
#define pll pair < ll, ll >
#define mp make_pair
#define ff first
#define ss second
//C ++ DS
#define vi vector < int >
#define vll vector < ll >
#define pb push_back
#define pf push_front
#define iter :: iterator
#define all(x) x.begin(),x.end()

//priority_queue < pii, vector < pii >, greater < pii > > pq;
//lower_bound(v.begin(),v.end(),20);//for any sorted container
//CONSTANTS
#define MOD 998244353
#define INF 0x3f3f3f3f
#define MAXN (int)(305)
//MOD OPERATIONS
inline ll fpow(ll n, ll k, int p = MOD) {ll r = 1; for (; k; k >>= 1) {if (k & 1) r = r * n % p; n = n * n % p;} return r;}
inline ll inv(ll a, ll p = MOD) {return fpow(a, p - 2, p);}
inline ll addmod(ll a, ll val, ll p = MOD) {{if ((a = (a + val)) >= p) a -= p;} return a;}
inline ll submod(ll a, ll val, ll p = MOD) {{if ((a = (a - val)) < 0) a += p;}return a;}
inline ll mult(ll a, ll b, ll p = MOD) {return (ll) a * b % p;}
//DEBUG
#define shout()  {cout << "I'm Here...!!!" << endl;}
#define dbg(x) { cout<< #x << ": " << (x) << endl; }
#define dbg2(x,y) { cout<< #x << ": " << (x) << " , " << #y << ": " << (y) << endl; }
int cnt[4],n;
ld dp[MAXN][MAXN][MAXN];
ld ev(int a,int b,int c)
{
	if(a==0 && b==0 && c==0)return 0;
	if(a<0 || b<0 || c<0)return 0;
	ld p_waste=((ld)n-a-b-c)/n;
	ld p_a=(ld)a/n,p_b=(ld)b/n,p_c=(ld)c/n;
	if(dp[a][b][c]>0)return dp[a][b][c];

	dp[a][b][c]=(1/(1-p_waste))*(1+
		p_a*ev(a-1,b,c)+p_c*ev(a,b+1,c-1)+p_b*ev(a+1,b-1,c));
	return dp[a][b][c]; 
}
int main()
{
	fastio;
	int a;
	cin>>n;
	for(int i=0;i<n;i++)
	{
		cin>>a;
		cnt[a]++;
	}
	cout<<setprecision(15)<<ev(cnt[1],cnt[2],cnt[3])<<endl;

}


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

using namespace std;

typedef long long ll;

const int INF = (1<<29);
const int INFF = 0x7fffffff;
const ll LINF = (1ll<<60);
const ll LINFF = 0x7fffffffffffffff;
const long double PI = 3.14159265359;

#define _fi(n) for(int i = 0;i < n;i++)
#define _fj(n) for(int j = 0;j < n;j++)
#define _fk(n) for(int k = 0;k < n;k++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define prec(x) cout << fixed << setprecision(x)
#define sz(x) (int)x.size()
#define _log2(x) 31-__builtin_clz(x)

#define hash sodnf9843bsd
#define right iadjfof23n3okd
#define pqueue priority_queue
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#define len length
#define endl '\n'

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
ll rnd(ll a, ll b){return uniform_int_distribution<ll>(a, b)(rng);}

char arr[1010][1010] = {};
int dist[1010][1010] = {};
bool vis[1010][1010] = {};

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


    int n, m;cin>>n>>m;
    int a, b;cin>>a>>b;
    int c, d;cin>>c>>d;
    _fi(n)_fj(m) cin>>arr[i][j];
    a--;b--;c--;d--;

    _fi(n)_fj(m) dist[i][j] = INF;
    dist[a][b] = 0;

    pqueue<tuple<int, int, int>>pq;
    pq.push({0, a, b});
    while(!pq.empty()){
        int i = get<1>(pq.top());
        int j = get<2>(pq.top());
        pq.pop();

        if (vis[i][j]) continue;
        vis[i][j] = true;

        if (i+1 < n && arr[i+1][j] == '.' && dist[i][j] < dist[i+1][j]){
            dist[i+1][j] = dist[i][j];
            pq.push({-dist[i+1][j], i+1, j});
        }
        if (i-1 >= 0 && arr[i-1][j] == '.' && dist[i][j] < dist[i-1][j]){
            dist[i-1][j] = dist[i][j];
            pq.push({-dist[i-1][j], i-1, j});
        }
        if (j+1 < m && arr[i][j+1] == '.' && dist[i][j] < dist[i][j+1]){
            dist[i][j+1] = dist[i][j];
            pq.push({-dist[i][j+1], i, j+1});
        }
        if (j-1 >= 0 && arr[i][j-1] == '.' && dist[i][j] < dist[i][j-1]){
            dist[i][j-1] = dist[i][j];
            pq.push({-dist[i][j-1], i, j-1});
        }

        for(int rr = -2;rr <= 2;rr++){
            for(int cc = -2;cc <= 2;cc++){
                if (i+rr < 0 || j+cc < 0) continue;

                if (arr[i+rr][j+cc] == '.' && dist[i][j]+1 < dist[i+rr][j+cc]){
                    dist[i+rr][j+cc] = dist[i][j]+1;
                    pq.push({-dist[i+rr][j+cc], i+rr, j+cc});
                }
            }
        }
    }

    if (dist[c][d] == INF) dist[c][d] = -1;
    cout << dist[c][d] << endl;

    return 0;
}


Measured memory_bytes: 9672
#include <bits/stdc++.h>
using namespace std;
using vi=vector<int>;
struct node{
    vector<int> to;
    int counter;
    int add;
    node(){
        counter=0;
        add=0;
    }
};
void dfs(int v, int p, vector<node> &nodes, int sum_add){
    nodes[v].counter=sum_add;
    for (int i = 0; i < nodes[v].to.size(); i++){
        int v_to=nodes[v].to[i];
        if(v_to==p)continue;
        dfs(v_to, v, nodes, sum_add+nodes[v_to].add);
    }
}
int main() {
    int N;
    cin>>N;
    int Q;
    cin>>Q;
    vector<node> nodes(N);
    for (int i = 0; i < N-1; i++){
        int u,v;
        cin>>u>>v; u--; v--;
        nodes[u].to.push_back(v);
        nodes[v].to.push_back(u);
    }
    for (int i = 0; i < Q; i++){
        int p,x; cin>>p>>x; p--;
        nodes[p].add+=x;
    }
    dfs(0,-1,nodes,nodes[0].add);
    for (int i = 0; i < N; i++){
        cout<<nodes[i].counter<<endl;
    }
}

Measured memory_bytes: 28340
import sys
def main():
    n = int(input())
    a = list(map(int, input().split()))
    i = 0
    while(True):
        for x in a:
            if x%2!=0:
                print(i)
                sys.exit()

        a = [x//2 for x in a]
        i += 1

if __name__=="__main__":
    main()

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  long n,a=-1;
  cin >> n;
  for(long i=2;i<500;i++) if(i*(i-1)/2==n) a=i;
  if(a==-1) {
    cout << "No" << endl;
    return 0;
  }
  cout << "Yes" << endl << a << endl;
  vector<vector<long>> ans(a,vector<long>(0));
  long x=1;
  for(long i=0;i<a;i++) {
    for(long j=i+1;j<a;j++) {
      ans[i].push_back(x);
      ans[j].push_back(x);
      x++;
    }
  }
  for(long i=0;i<a;i++) {
    cout << a-1 << " ";
    for(long j=0;j<a-1;j++) cout << ans[i][j] << " ";
    cout << endl;
  }
}


Measured memory_bytes: 4920
program main
	implicit none
    integer(8) X, A, B
	read(*, *) X, A, B
	A = B - A
	if(A <= 0) then
		write(*, *) 'delicious'
	else if(A <= X) then
		write(*, *) 'safe'
	else
		write(*, *) 'dangerous'
	end if
end program main

Measured memory_bytes: 256
n, m = map(int, input().split())
l = [0] * m
for i in range(n):
    ka = list(map(int, input().split()))
    for j in range(1, ka[0] + 1):
        l[ka[j] - 1] += 1
c = 0
for i in range(m):
    if l[i] == n:
        c += 1
print(c)

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

const int MODULO = (int) 1e9 + 7;
const int N = 405;
int a[N], b[N], power[N], sum[N];
int f[N][N];
int psum[N][N];

int F(int n, int c) {
    if (n == 0) return c == 0 ? 1 : 0;
    int &res = f[n][c];
    if (res != -1) return res;
    res = 0;
    for (int x = 0; x <= c; ++x)
        res = (res + 1LL * psum[n - 1][x] * F(n - 1, c - x)) % MODULO;
    return res;
}

int main() {
    ios::sync_with_stdio(false);
    int n; cin >> n;
    int c; cin >> c;
    for (int i = 0; i < n; ++i) cin >> a[i];
    for (int i = 0; i < n; ++i) cin >> b[i];
    for (int i = 0; i < N; ++i) power[i] = 1;
    for (int pwr = 0; pwr <= c; ++pwr) {
        for (int i = 1; i < N; ++i)
            sum[i] = (sum[i - 1] + power[i]) % MODULO;
        for (int i = 0; i < n; ++i)
            psum[i][pwr] = (sum[b[i]] - sum[a[i] - 1] + MODULO) % MODULO;
        for (int i = 0; i < N; ++i)
            power[i] = 1LL * power[i] * i % MODULO;
    }
    memset(f, -1, sizeof f);
    cout << F(n, c) << '\n';
    return 0;
}


Measured memory_bytes: 1536
using System.Text;
using System.Collections.Generic;
using System.Linq;
using System;

public class P
{
    public int sum { get; set; }
    public int times { get; set; }
    public long b { get; set; }
}

public class hello
{
    public static void Main()
    {
        var n = int.Parse(Console.ReadLine().Trim());
        string[] line = Console.ReadLine().Trim().Split(' ');
        var k = int.Parse(line[0]);
        if (k == 0) { Console.WriteLine("0:"); goto end; }
        var b = new int[k];
        for (int i = 0; i < k; i++) b[i] = int.Parse(line[i + 1]);
        var ps = getAns(b, n);
        print(ps, b);
        end:;
    }
    public static List<P> getAns(int[] b, int n)
    {
        var ps = new List<P>();
        var p = new int[n];
        for (int i = 0; i < n; i++) p[i] = 1 << i;
        var q = new Queue<P>();
        var w = new P();
        q.Enqueue(w);
        var w1 = new P();
        w1.b = 1L << b[0];
        q.Enqueue(w1);
        while (q.Count() > 0)
        {
            var w2 = q.Dequeue();
            if (w2.times == b.Length - 1)
            {
                foreach (var x in b)
                    if (((w2.b >> x) & 1) == 1) w2.sum += p[x];
                ps.Add(w2);
            }
            else
            {
                var w3 = new P();
                w3.b = w2.b;
                w2.times++;
                w3.times = w2.times;
                w2.b |= 1L << b[w2.times];
                q.Enqueue(w2);
                q.Enqueue(w3);
            }
        }
        return ps;
    }
    public static void print(List<P> ps, int[] b)
    {
        var sb = new StringBuilder();
        foreach (var x in ps.OrderBy(y => y.sum))
            if (x.b == 0) sb.Append(string.Format("0:\n"));
            else
            {
                sb.Append(string.Format("{0}: ", x.sum));
                sb.Append(string.Join(" ", b.Where(y => ((x.b >> y) & 1) == 1)));
                sb.Append("\n");
            }
        Console.Write(sb);
    }
}


Measured memory_bytes: 74616