akhauriyash/Code-Regression huggingface dataset:
N,M = map(int,input().split())
A = [list(map(int,input().split())) for i in range(N)]
K = []
for i in range(N):
    K.append(A[i].pop(0))
ans = A[0]
for j in range(1,N):
    ans = set(ans)&set(A[j])
print(len(ans))

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define all(v) v.begin(), v.end()
#define vl vector<ll>
#define vi vector<int>
#define pii pair<int,int>
#define pb push_back
#define ff first
#define ss second
const int N=100005;
ll mod = 1e9+7;
ll a[2*N];
void solve()
{
    ll n,m=0,k=0,i=1,j,p,f,x, y, z;
    ll ans=0,sum=0;
    cin>>n;
    for(i=0;i<n;i++) cin>>a[i];
    for(i=0;i<n;i++)
    {
        ans+=(a[i]*sum)%mod;
        sum+=a[i];
        sum%=mod;
        ans%=mod;
    }
    cout<<ans;
}
int main()
{
    ios::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin) ;
    freopen("output.txt", "w", stdout) ;
    #endif 
    int t=1;
    //cin>>t;
    while(t--)solve();
    return 0;
}

Measured memory_bytes: 5208
#include <iostream>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <list>
#include <vector>
#include <complex>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <bitset>
#include <ctime>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cassert>
#include <cstddef>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <sstream>
#include <fstream>

using namespace std;
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define FOR(i, a, b) for (int (i) = (a); (i) < (b); (i)++)
#define RREP(i, a) for(int (i) = (a) - 1; (i) >= 0; (i)--)
#define FORR(i, a, b) for(int (i) = (a) - 1; (i) >= (b); (i)--)
#define DEBUG(C) cerr << #C << " = " << C << endl;
using LL = long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<LL>;
using VVL = vector<VL>;
using VD = vector<double>;
using VVD = vector<VD>;
using PII = pair<int, int>;
using PDD = pair<double, double>;
using PLL = pair<LL, LL>;
using VPII = vector<PII>;
template<typename T> using VT = vector<T>;
#define ALL(a) begin((a)), end((a))
#define RALL(a) rbegin((a)), rend((a))
#define SORT(a) sort(ALL((a)))
#define RSORT(a) sort(RALL((a)))
#define REVERSE(a) reverse(ALL((a)))
#define MP make_pair
#define FORE(a, b) for (auto &&a : (b))
#define FIND(s, e) ((s).find(e) != (s).end())
#define EB emplace_back
template<typename T> inline bool chmax(T &a, T b){if (a < b){a = b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if (a > b){a = b;return true;}return false;}

const int INF = 1e9;
const int MOD = INF + 7;
const LL LLINF = 1e18;
const double EPS = 1e-9;

void init() {
    
}

void solve(int q) {
    char strbuf[100];
    LL l = 0, r = 0;
    for (int i = 0; i < q; i++) {
        int p, n;
        char c[5];
        scanf("%d%s%d", &p, c, &n);
        l += (c[0] == '(') * n;
        r += (c[0] == ')') * n;
        //cout<<p<<" "<<c<<" "<<n<<endl;
        puts(l == r ? "Yes" : "No");
    }
    exit(0);
}

signed main(void) {
    LL n, m, p, a, b, c, x, y, z, q;
    string s;
    bool f = false;
    init();
    while (cin >> n, n) {
        solve(n);
        //return 0;
    }
}

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

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

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <fstream>
#include <string>
#include <math.h>
#include <cstdlib>
#include <istream>
#include <sstream>
#include <cctype>
#include <iomanip>
//cout << fixed << setprecision(20) << *** << endl;
#define rep(i,N) for(int i=0;i<(int)N;++i)
typedef long long ll;
using namespace std;
//ユークリッド
ll gcd(ll a,ll b){
	ll t;
	if(a<b){
		t=a;
		a=b;
		b=t;
	}
	if(a%b==0)return b;
	return gcd(b,a%b);
}
//階乗
ll Factorial(ll a){
	ll b=1;
	for(ll i=a;i>=1;i--){
		b=b*i;
	}
	return b;
}
//素数判定
bool prime(ll n){
	for(ll i=2;i*i<=n;i++){
		if(n%i==0) return false;
	}
	return true;
}
int main()
{
	ll N,max=0;
	string ANS="Yes";
	vector<ll>H;
	cin>>N;
	rep(i,N){
		ll t;
		cin>>t;
		H.push_back(t);
	}
	for(ll i=0;i<N;i++){
		if(H[i]>max){
			max=H[i]-1;
			H[i]--;
		}
	}
	max=0;
	for(ll i=0;i<N;i++){
		//cout<<H[i]<<endl;
		if(H[i]>max){
			max=H[i];
		}
		if(H[i]<max){
			ANS="No";
		}
	}
	cout<<ANS<<endl;
}

Measured memory_bytes: 1400
#include <iostream>
using namespace std;
int main(void){
    // Here your code !
    int n,t=0,h=0;
    string taro,hana;
    cin>>n;
    
    for(int i=0;i<n;i++){
    cin>>taro;
    cin>>hana;
    if(taro>hana) t+=3;
    else if(taro<hana) h+=3;
    else if(taro==hana) {
    h+=1;
    t+=1;
    }
    }
    
    cout<<t<<" "<<h<<endl;
}

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

#define MOD 1000000007
#define PI 3.141592653589793

typedef unsigned long long ull;
typedef long long ll;
using namespace std;

void testCase() {
	int num, res;
	for(int i = 0; i < 5; i++) {
		cin >> num;
		if(!num) res = i + 1;
	}
	cout << res << endl;
}

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	int T = 1;
	//cin >> T;
	while(T--) {
		testCase();
	}
}


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

int main() {
	// your code goes here
	int n;
	map<string,int> m;
	cin>>n;
	while(n--)
	{
	    string s;
	    cin>>s;
	    m[s]+=1;
	}
	cout<<m.size()<<endl;
	return 0;
}


Measured memory_bytes: 19148
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define ALL(x) (x).begin(), (x).end()
typedef long long ll;
typedef pair<int, int> P;
typedef vector<vector<int> > Matrix;


int main(){
  int n;
  cin >> n;
  vector<int> a(n), b;
  rep(i, n) cin >> a[i];
  b = a;
  sort(ALL(a));
  rep(i, n){
    if (b[i] == a[n-1]) cout << a[n-2] << endl;
    else cout << a[n-1] << endl;
  }
}

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

using namespace std;

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();}
template<class T> inline T sqr(T x) {return x*x;}

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;

#define all(a)  (a).begin(),(a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define pb push_back
#define mp make_pair
#define each(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define exist(s,e) ((s).find(e)!=(s).end())
#define range(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  range(i,0,n)
#define clr(a,b) memset((a), (b) ,sizeof(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

const double eps = 1e-10;
const double pi  = acos(-1.0);
const ll INF =1LL << 62;
const int inf =1 << 29;

int n,m;
ll a[300010],b[300010],c[300010];

ll sum[1000010];

int main(void){
	scanf("%d",&n);
	rep(i,n) scanf("%lld",&a[i]);
	rep(i,n) sum[a[i]]+=a[i];

	rep(i,1000001) sum[i+1]+=sum[i];

	scanf("%d",&m);
	rep(i,m) scanf("%lld",&b[i]);
	rep(i,m) scanf("%lld",&c[i]);
	rep(i,m){
		if(sum[b[i]]>=c[i])
			puts("Yes");
		else
			puts("No");
	}
	return 0;
}

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

using namespace std;
int main()
{
  string s, t;
  cin >> s;
  cin >> t;

  int cnt = 0;
  for (int i = 0; i < s.size(); i++)
  {
    if (s[i] != t[i])
    {
      cnt++;
    }
  }
  cout << cnt << endl;
  return 0;
}

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

#define rep(i,n) for(int i = 0; i<n; ++i)
#define REP(i,n) for(int i = 1; i<=n; ++i)
#define all(x) begin(x),end(x)
#define showall(obj) for(auto x:obj)cout<<x<<endl;
typedef long long ll;
typedef pair<int,int> ip;
typedef pair<ll,ll> lp;
typedef vector<int> vint;
typedef vector<ll> vll;
const int inf = 100100100;
const ll INF = 1LL<<60;
const int MOD = (int)1e9 + 7;

int main(){
	double n,k;
	cin>>n>>k;
	double ans = 0;
	REP(i,n){
		if(i>=k){ans += 1; continue;}
		int p = ceil(log(k/i)/log(2));
		ans += pow(0.5,p);
	}
	cout<<fixed<<setprecision(13)<<ans/n<<endl;
	return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
static const int64_t mod=1000000007;
int64_t f(int64_t x,int64_t y){
if(y==0)
  return 1;
  else if(y%2==0)
    return (f(x,y/2)*f(x,y/2))%mod;
  else
    return (x*((f(x,y/2)*f(x,y/2))%mod))%mod;
}
int main(){
 int N;cin>>N;
  vector<int64_t>A(N);
  for(int i=0;i<N;i++)
    cin>>A.at(i);
  sort(A.begin(),A.end());
  reverse(A.begin(),A.end());
  int64_t ans=0;ans+=A.at(0);
  if((N-2)%2==0){
  int k=(N/2)-1;
    for(int i=1;i<=k;i++)
      ans+=(2*A.at(i));
    cout<<ans<<endl;
  }else{
   int k=(N/2)-1;
    for(int i=1;i<=k;i++)
      ans+=(2*A.at(i));ans+=A.at(k+1);
    cout<<ans<<endl;
  }
  return 0;
  
}

Measured memory_bytes: 4760
inpl = lambda: list(map(int,input().split()))
S = input()
T = input()
M = len(S)
N = len(T)

ans = N
for i in range(M-N+1):
    tmp = 0
    for j in range(N):
        if S[i+j] != T[j]:
            tmp += 1
            if tmp >= ans:
                break
    else:
        if tmp < ans:
            ans = tmp
print(ans)


Measured memory_bytes: 73292
#include<cstdio>
#include<vector>
#include<algorithm>
using namespace std;

#define ran 555

int n, lim;
int a[ran], pre[ran], suf[ran];
//int rem[ran], nr;

bool chk(int x) {
	int reqd = 0;
	vector<int> v;
	for(int i = 0; i < n; i++)
	{
		int cur = a[i] % x;
		v.push_back(cur);
	}
	sort(v.begin(), v.end());
	int l = 0, r = v.size() - 1;
	int rem = 0;
	while(l <= r)
	{
		if(rem <= 0)
		{
			rem += v[l];
			reqd += v[l];
			l++;
		}
		else
		{
			rem -= (x - v[r]);
			reqd += (x - v[r]);
			r--;
		}
	}
	if(reqd > 2 * lim)
		return 0;
	if(rem != 0)
		return 0;
	return 1;
	
	/*nr = 0;
	for(int i=0;i<n;i++) {
		if (a[i] % mo) rem[nr++] = a[i]%mo;
	}
	if (!nr) return true;
	sort(rem, rem+nr);
	
	int mi = 2e9;
	for(int i=0;i<nr;i++) {
		pre[i] = rem[i];
		if(i>0) pre[i] += pre[i-1];
	}
	for(int i=nr-1;i>=0;i--) {
		suf[i] = mo - rem[i];
		if(i<n-1) suf[i] += suf[i+1];
	}
	//for(int i=0;i<n;i++) printf("%d%c", pre[i], i<n-1 ? ' ' : '\n');
	//for(int i=0;i<n;i++) printf("%d%c", suf[i], i<n-1 ? ' ' : '\n');
	for(int i=1;i<nr;i++)
		mi = min(mi, max(pre[i-1], suf[i]));
	//printf("%d %d\n", mo, mi);
	return (mi <= lim);*/
}

int main() {
	scanf("%d%d", &n, &lim);
	int s = 0;
	for(int i=0;i<n;i++) {
		scanf("%d", &a[i]);
		s += a[i];
	}
	
	int ans = 1;
	for(int i=1;i*i<=s;i++) {
		if (s%i) continue;
		if(chk(i)) ans = max(ans, i);
		if(chk(s/i)) ans = max(ans, s/i);
	}
	printf("%d\n", ans);
	
	return 0;
}

Measured memory_bytes: 384
# coding: utf-8

cntNum = input() # 要素数の取得
numList = [int(num) for num in input().split()] #コマンドライン入力数値の取得

cntDivision = 0 # 割り算回数の初期化
isOdd = False # 奇数判定フラグの初期化

while True:
    # 入力数値を1つずつ２で除算して余りが0でなかったら、奇数判定フラグをTrueにする
    for num in numList:
        if (num % 2 != 0):
            isOdd = True
    # 奇数判定フラグがFalseなら（除算した結果奇数が含まれていなかったら）除算を実行
    # 奇数判定フラグがTrueなら、whileループを抜ける
    if (isOdd == False):
        numList = [ (num/2) for num in numList ]
        cntDivision += 1
    else:
        break

print(cntDivision)

Measured memory_bytes: 3060
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>

using namespace std;

#define INF 0xc0c0c0c0
#define NINF 0x3f3f3f3f

#define FOR(i, a, b) for((i)=a; i<b; ++(i))
#define EFOR(i, a, b) for((i)=a; i>b; --(i))

#define MLC(n, type) (type*)malloc(n*sizeof(type))
#define CLC(n, type) (type*)calloc(n, sizeof(type))

#define MAXN 100000

void myPrint(int rows, int cols) {
	int i,j;
	int cur = 0;
	int end = 1;

	printf("%d\n", rows);

	for (i = 1; i <= rows; ++i) {
		printf("%d ", cols);
		for (j = 1; j < i; ++j) {
			if (j == 1) {
				printf("%d ", i-1);
				cur = i - 1;
			}
			else {
				cur += cols - j + 1;
				printf("%d ", cur);
			}
		}

		for (; j <= cols; ++end, ++j) {
			printf("%d ", end);
		}
		printf("\n");
	}
}

void solver(int n) {
	int i;

	int h = sqrt((n<<1));

	if (h*(h+1) != (n<<1)) {
		printf("No\n");
		return;
	}

	printf("Yes\n");
	myPrint(h+1, h);
}

int main() {
	int n;

	scanf("%d", &n);

	solver(n);

	return 0;
}


Measured memory_bytes: 1280
import math

def solve(n,m,k,a_lst,b_lst):
    #机ごと、読書時間の累積をリストにする。ただし、リスト化はk時間内で読める範囲とする
    aa_lst = make_sum_list(a_lst,k)
    bb_lst = make_sum_list(b_lst,k)
    len_aa = len(aa_lst)
    len_bb = len(bb_lst)

    #A,Bいずれかが一冊も読めないケースを考慮
    if len_aa == 0:   return len_bb
    elif len_bb == 0: return len_aa
    
    #全て読めるケースを考慮
    if aa_lst[-1] + bb_lst[-1] <= k: return len_aa + len_bb 
    
    #A,Bいずれかのみ読むケースを考慮
    max_read = max(len_aa,len_bb)

    #リスト範囲でA+Bの最大値を探索する。2分探索を用いる
    for i in reversed(range(len_aa)):
        limit = k - aa_lst[i]
        read = i + 1
        if read + len_bb + 1 <= max_read:
            #以後 read は増えない
            break

        imax = len_bb-1
        imin = 0
        imid = len_bb // 2
        while True:
            if bb_lst[imid] <= limit:
                #OK。大を調べる
                if imax - imid <= 1:
                    #探査終了
                    if bb_lst[imax] <= limit:
                        read += imax + 1
                    else:
                        read += imid + 1
                    break
                imin = imid
            else:
                #NG。小を調べる
                if imid - imin <= 1:
                    #探査完了
                    if bb_lst[imin] <= limit:
                        read += imin + 1
                    break
                imax = imid
            imid = (imin + imax) // 2
        max_read = max(read,max_read)
    return max_read

def make_sum_list(lst,max):
    sum_lst = []
    sum = 0
    for n in lst:
        sum += n
        if sum > max:
            break
        sum_lst.append(sum)
    return sum_lst

n,m,k = map(int, input().split())
a_lst = list(map(int, input().split()))
b_lst = list(map(int, input().split()))
ans = solve(n,m,k,a_lst,b_lst)
print(ans)

Measured memory_bytes: 41480
#include <stdio.h>

char dp[100000];

int main(){
  int n, m;
  scanf("%d%d", &n, &m);
  for(int i=0;i<m;i++){
    int a, b;
    scanf("%d%d", &a, &b);
    dp[a-1] ^= 1;
    dp[b-1] ^= 1;
  }
  for(int i = 0; i<n; i++){
    if(dp[i]){
      puts("NO");
      return 0;
    }
  }
  puts("YES");
  return 0;
}

Measured memory_bytes: 256
fun main(args:Array<String>):Unit {
    while (true) {
        val (a, b) = (readLine() ?: return).trim().split(' ').map(String::toInt)
        println(gcd(a, b))
    }
}
fun gcd(a:Int, b:Int):Int {
    return when(b){
        0 -> a
        else -> gcd(b, a % b)
    }
}


Measured memory_bytes: 31268
import java.util.*;
import java.io.*;
import static java.util.Arrays.*;
import static java.util.Collections.*;
import static java.lang.Math.*;
 
public class Main {

  public static int dp(int[] memo, int n) {
    Arrays.fill(memo, 0);
    if (n<=1) return 1;
    memo[0] = memo[1] = 1;
    for (int i=2; i<=n; i++)
      memo[i] = memo[i-1] + memo[i-2];
    return memo[n];
  }

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = Integer.parseInt(sc.next());
    int memo[] = new int[n+1];
    System.out.println(dp(memo, n));
  }
}

Measured memory_bytes: 17192
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) for(int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define show(x)  cerr << #x << " = " << (x) << endl;
using namespace std;

template <typename X, typename T>
auto vectors(X x, T a) {
	return vector<T>(x, a);
}

template <typename X, typename Y, typename Z, typename... Zs>
auto vectors(X x, Y y, Z z, Zs... zs) {
	auto cont = vectors(y, z, zs...);
	return vector<decltype(cont)>(x, cont);
}

template<typename T>
ostream& operator << (ostream& os, vector<T>& v){
	rep(i,v.size()){ os << v[i] << (i == v.size() - 1 ? "" : " "); } return os;
}
template<typename T>
istream& operator >> (istream& is, vector<T>& v){
	for(T& x: v){ is >> x; } return is;
}

const int MAX = 7400000;

bool ok[MAX];

int main(){
	int m, n;
	while(cin >> m >> n, m){
		memset(ok, 0, sizeof(ok));

		int i;
		for(i = m; 1; i++){
			//show(i) rep(j, 29){ cout << ok[j]; } cout << endl;
			if(not ok[i]){
				if(n == 0) break;

				for(int j = i; j < MAX; j+=i){
					ok[j] = true;
				}
				n--;
			}

		}
		cout << i << endl;
	}
}



Measured memory_bytes: 10228
#include<stdio.h>

int main(void)
{
        int n;
        int i;

        scanf("%d", &n);

        int a[n];
        int sort[n];
        int b[n];

        for(int i = 0; i < n; i++){
                scanf("%d", &a[i]);
                b[i] = a[i];
        }

        for(i = 0; i < n; i++){
                sort[a[i] - 1] = i + 1;
        }

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

        return 0;
}

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


int main(){

    int dist[5];
    int number;
    number = 0;
    cin >> dist[number];
    number = number + 1;
    cin >> dist[number];
    number = number + 1;
    cin >> dist[number];
    number = number + 1;
    cin >> dist[number];
    number = number + 1;
    cin >> dist[number];

    int k;
    cin >> k;

    if(dist[4]-dist[0]>k){
        cout << ":(";
    }else{
        cout << "Yay!";
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define all(a) a.begin(), a.end()
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<ll,ll> P;
#define rep(i,a,b) for(ll i=a ; i<b ; i++)
const int max_n = 1e5;
const ll mod = 1e9+7;
const ll INF = 1LL<<60;
const int inf = 1e5;
typedef long double ld;
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; }
int dx[4] = {0,0,1,-1};
int dy[4] = {1,-1,0,0};
int main(){
  int H,W,k;  cin >> H >> W >> k;
  string s[H];
  rep(i,0,H){
    cin >> s[i];
  }
  int res = inf;
  for(int bit=0 ; bit<(1<<(H-1)) ; bit++){
    bool gok = true;
    int n=0;
    vector<int> ord(H,0);
    for(int i=0 ; i<H-1 ; i++){
      if(bit & (1<<i)){
        ord[i+1] = ord[i] + 1;  n++;
      }else{
        ord[i+1] = ord[i];
      }
    }
    int add = 0;
    vector<int> nums(n+1,0);
    for(int w=0 ; w<W ; w++){
      vector<int> one(n+1,0);
      bool ok = true;
      for(int h=0 ; h<H ; h++){
        one[ord[h]] += s[h][w] - '0';
        nums[ord[h]] += s[h][w] - '0';
        if(one[ord[h]]>k) gok = false;
        if(nums[ord[h]]>k) ok = false;
      }
      if(!ok) add++, nums = one;
    }
    if(gok) chmin(res, n+add);
  }
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.*;
import java.lang.*;
import java.io.*;
 
public final class Main
{
    public static void main (String[] args) throws java.lang.Exception {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int m =  in.nextInt();
        int[][] arr= new int[n][m];
        for(int i =0; i< n; i++) {
           String s = in.next();
           for(int j =0; j< m ; j++) {
              if(s.charAt(j)=='#'){
                arr[i][j]  =-1;
              } else {
                arr[i][j] =0;
              }
           }
        }
        
      int[][] dp = new int[n][m];
      dp[0][0] = 1;
      
      for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
          if (arr[i][j] == -1) {
            continue;
          }
          if (i > 0) {
            dp[i][j] = (dp[i][j] + dp[i - 1][j])%1000000007;
          }
          if (j > 0) {
            dp[i][j] = (dp[i][j]+dp[i][j - 1])%1000000007;
          }
        }
      }
      System.out.println(dp[n-1][m-1]); 
        
    }
}


Measured memory_bytes: 36500
#include <float.h>
#include <inttypes.h>
#include <limits.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <unistd.h>
#include <math.h>
#ifdef __cplusplus
#include <bits/stdc++.h>
#endif

int comp(const void *a, const void *b){return (*(int*)a>*(int*)b)-(*(int*)a<*(int*)b);}
int compr(const void *a, const void *b){return (*(int*)a<*(int*)b)-(*(int*)a>*(int*)b);}

#define putchar(c) putc_unlocked((c), stdout)
#define getchar() getc_unlocked(stdin)
char nextchar(void){ char c=getc_unlocked(stdin); while(c==' '||c=='\n') c=getc_unlocked(stdin); return c; }
int32_t nextint(void){ char c=getc_unlocked(stdin); while(c!='-'&&(c<'0'||'9'<c)) c=getc_unlocked(stdin); int s=0; if(c=='-'){s=1;c=getc_unlocked(stdin);} uint32_t x=0; while('0'<=c && c<='9'){ x=x*10+c-'0'; c=getc_unlocked(stdin); } return s?-x:x; }
int64_t nextlong(void){ char c=getc_unlocked(stdin); while(c!='-'&&(c<'0'||'9'<c)) c=getc_unlocked(stdin); int s=0; if(c=='-'){s=1;c=getc_unlocked(stdin);} uint64_t x=0; while('0'<=c && c<='9'){ x=x*10+c-'0'; c=getc_unlocked(stdin); } return s?-x:x; }
uint32_t nextpint(void){ char c=getc_unlocked(stdin); while(c<'0'||'9'<c) c=getc_unlocked(stdin); uint32_t x=0; while('0'<=c && c<='9'){ x=x*10+c-'0'; c=getc_unlocked(stdin); } return x; }
uint64_t nextplong(void){ char c=getc_unlocked(stdin); while(c<'0'||'9'<c) c=getc_unlocked(stdin); uint64_t x=0; while('0'<=c && c<='9'){ x=x*10+c-'0'; c=getc_unlocked(stdin); } return x; }
uint32_t nextstr(char *s){ char c=getc_unlocked(stdin); while(c==' '||c=='\n') c=getc_unlocked(stdin); uint32_t len=0; while(c!=' '&&c!='\n'){ *s++=c; len++; c=getc_unlocked(stdin); } *s='\0'; return len; }
uint32_t nextstrln(char *s){ char c=getc_unlocked(stdin); while(c==' '||c=='\n') c=getc_unlocked(stdin); uint32_t len=0; while(c!='\n'){ *s++=c; len++; c=getc_unlocked(stdin); } *s='\0'; return len; }

void printint(int x){ if(x<0){x=-x; putc_unlocked('-', stdout);}else if(x==0){putc_unlocked('0', stdout);} int d=0; char s[10]; while(x){ s[d]='0'+x%10; x/=10; d++; } for (int i=d-1; i>=0; i--) putc_unlocked(s[i], stdout); putc_unlocked('\n', stdout); }
void printlong(long x){ if(x<0){x=-x; putc_unlocked('-', stdout);}else if(x==0){putc_unlocked('0', stdout);} int d=0; char s[20]; while(x){ s[d]='0'+x%10; x/=10; d++; } for (int i=d-1; i>=0; i--) putc_unlocked(s[i], stdout); putc_unlocked('\n', stdout); }

inline int max2(const int a, const int b){return a>b?a:b;}
inline int min2(const int a, const int b){return a>b?b:a;}
inline int dif2(const int a, const int b){return a>b?a-b:b-a;}
inline int abs2(const int a){return a>=0?a:-a;}

int g[20];
int main(void){
	int n=nextpint();
	for(int k=0; k<20; k++){
		g[k]=-1;
	}
	long ans=0;
	int f=-1;
	for(int i=0; i<n; i++){
		int a=nextpint();
		for(int k=0; k<20; k++){
			if(a&(1<<k)){
				if(g[k]>f) f=g[k];
				g[k]=i;
			}
		}
		ans+=i-f;
	}
	printf("%ld\n", ans);
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define loop(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  loop(i,0,n)
#define all(c) c.begin(),c.end()
#define rall(c) c.rbegin(),c.rend()
#define vi vector<int>
#define vl vector<ll>
#define pll pair<ll,ll>
#define vpll vector<pll>
 
int main(){
    int n,a,b,c,d;
    cin>>n>>a>>b>>c>>d;
    string s;
    cin>>s;
    int fa=0;
    int fb=0;
 
    if(c<d){
        for(int i=a-1;i<c-1;i++){
            if(s[i]=='#'&&s[i+1]=='#')fa=1;
        }
        for(int i=b-1;i<d-1;i++){
            if(s[i]=='#'&&s[i+1]=='#')fb=1;
        }
        if(fa==0&&fb==0)cout<<"Yes"<<endl;
        else cout<<"No"<<endl;
    }
 
    else if(c>d){
        int tmp=0;
        for(int i=a-1;i<c-1;i++){
            if(s[i]=='#'&&s[i+1]=='#')fa=1;
        }
        for(int i=b-1;i<d-1;i++){
            if(s[i]=='#'&&s[i+1]=='#')fb=1;
        }
        for(int i=b-2;i<d-1;i++){
            if(s[i]=='.'&&s[i+1]=='.'&&s[i+2]=='.')tmp=1;
        }
        if(fa==0&&fb==0&&tmp==1)cout<<"Yes"<<endl;
        else cout<<"No"<<endl;
    }
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define int long long
#define ll long long
#define rep(i,n) for(int i=0;i<n;i++)
#define INF LLONG_MAX
#define eps LDBL_EPSILON
#define moder 1000000007
#define pie 3.141592653589793238462643383279
#define P std::pair<int,int>
#define prique priority_queue
using namespace std;
int n,m,s,t,c;
int imos[100010][35];
signed main(){
	cin>>n>>m;
	rep(i,n){
		cin>>s>>t>>c;
		imos[s-1][c]++;
		imos[t][c]--;
	}
	rep(i,100010){
		rep(j,35){
			if(i)imos[i][j]+=imos[i-1][j];
		}
	}
	int ans=0;
	rep(i,100010){
		int cnt=0;
		rep(j,35){
			if(imos[i][j])cnt++;
		}
		ans=max(ans,cnt);
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 27648
#include <stdio.h>
int main(){

  int n,i,j,k,c[4][13],y;
  char x;

  for (i = 0; i < 4; i++){

    for (j = 0; j < 13; j++){

      c[i][j]=0;

    }

  }

  scanf("%d",&n);

  for (k = 0; k < n*2; k++){

    scanf("%c %d",&x,&y);

    if (x == 'S'){

      c[0][y-1]=1;

    } else if (x == 'H'){

      c[1][y-1]=1;

    } else if (x == 'C'){

      c[2][y-1]=1;

    } else if (x == 'D'){

      c[3][y-1]=1;

    }

  }

    for (i = 0; i < 4; i++){

      for (j = 0; j < 13; j++){

	if (c[i][j] == 0){

	  if (i == 0){

	    printf("S %d",j+1);

	  } else if (i == 1){
	      
	      printf("H %d",j+1);
	      
	  } else if (i == 2){
	     
	      printf("C %d",j+1);
	      
          } else if (i == 3){
	      
	      printf("D %d",j+1);

	    }

	  printf("\n");

	}

      }

    }
    
    return 0;	      

}

Measured memory_bytes: 600
#include<iostream>
#include<string>
using namespace std;
int main(){
long i,l,a,b;
string s;
for(i=0;i<9;i++){
cin>>s>>a>>b;
if(a>400)a=400;
if(b>400)b=400;
cout<<s<<" "<<a+b<<" "<<a*200+b*300<<endl;
}
return 0;
}

Measured memory_bytes: 1200
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
typedef long long ll;
const int INF = 1000000000;
const long INF64 = 1000000000000000ll;
const ll MOD = 1000000007ll;


int main(){
	int a,b,c;
	std::cin >> a>>b>>c;
	for (int i = 1; i < 100001; i++) {
		/* code */
		if(a*i%b==c){
			std::cout << "YES" << std::endl;
			exit(0);
		}
	}
	std::cout << "NO" << std::endl;
}






Measured memory_bytes: 256
#[allow(unused_macros)]
macro_rules ! read_value {($ next : expr , ($ ($ t : tt ) ,* ) ) => {($ (read_value ! ($ next , $ t ) ) ,* ) } ; ($ next : expr , [$ t : tt ; $ len : expr ] ) => {(0 ..$ len ) . map (| _ | read_value ! ($ next , $ t ) ) . collect ::< Vec < _ >> () } ; ($ next : expr , chars ) => {read_value ! ($ next , String ) . chars () . collect ::< Vec < char >> () } ; ($ next : expr , usize1 ) => {read_value ! ($ next , usize ) - 1 } ; ($ next : expr , $ t : ty ) => {$ next () . parse ::<$ t > () . expect ("Parse error" ) } ; }
#[allow(unused_macros)]
macro_rules ! input_inner {($ next : expr ) => {} ; ($ next : expr , ) => {} ; ($ next : expr , $ var : ident : $ t : tt $ ($ r : tt ) * ) => {let $ var = read_value ! ($ next , $ t ) ; input_inner ! {$ next $ ($ r ) * } } ; }
#[allow(unused_macros)]
macro_rules ! input {(source = $ s : expr , $ ($ r : tt ) * ) => {let mut iter = $ s . split_whitespace () ; let mut next = || {iter . next () . unwrap () } ; input_inner ! {next , $ ($ r ) * } } ; ($ ($ r : tt ) * ) => {let stdin = std :: io :: stdin () ; let mut bytes = std :: io :: Read :: bytes (std :: io :: BufReader :: new (stdin . lock () ) ) ; let mut next = move || -> String {bytes . by_ref () . map (| r | r . unwrap () as char ) . skip_while (| c | c . is_whitespace () ) . take_while (| c |! c . is_whitespace () ) . collect () } ; input_inner ! {next , $ ($ r ) * } } ; }

fn is_prime(x: i32) -> bool {
    for i in 2..x {
        if i * i > x {
            break;
        }
        if x % i == 0 {
            return false;
        }
    }
    true
}

fn main() {
    input! {
        x_: i32,
    }
    let mut x = x_;
    while !is_prime(x) {
        x += 1;
    }
    println!("{}", x);
}


Measured memory_bytes: 2128
#include<stdio.h>

 int gcd(int a, int b);

 int main(void){
     
     int x, y;
     
     scanf("%d %d", &x, &y);
     
     printf("%d\n", gcd(x, y));
     
     return 0;
 }

 int gcd(int a, int b){
    int A=0;
    
    if(b<=a){
    	if(a%b==0){
    		//printf("1%d %d\n", a, b);
        	return b;
        }
        else{
        	//printf("2%d %d\n", a, b);
            return gcd(b, a%b);
        }
    }
   else{
       A=a;
       a=b;
       b=A;
       if(a%b==0){
       		//printf("3%d %d\n", a, b);
            return b;
        }
        else{
        	//printf("4%d %d\n", a, b);
            return gcd(b, a%b);
        } 
    }
 }


Measured memory_bytes: 2092
#include<stdio.h>
 
 
int G[101][101], q1[101], q2[101], n;
 
void f(int a, int b){
  int i;
  q1[a] = b;
  for(i = 1; i <= q2[a]; i++){
    if(b + 1 < q1[G[a][i]]) f(G[a][i], b + 1);
  }
}
 
int main(){
  int i, j, m;
 
  scanf("%d", &n);
 
  for(i = 1; i <= n; i++){
    q1[i] = 100000000;
    scanf("%d", &m);
    scanf("%d", &q2[m]);
 
    for(j = 1; j <= q2[m]; j++) scanf("%d", &G[m][j]);
  }
 
  f(1, 0);
 
  for(i = 1; i <= n; i++){
    if(q1[i] == 100000000) q1[i] = -1;
  }
 
  for(i = 1; i <= n; i++) printf("%d %d\n", i, q1[i]);
 
  return 0;
}

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

int main() {
  string w;
  bool ans = true;
  map<char, int> mp;
  cin >> w;
  for (char c : w) {
    if (mp.count(c) == 0) mp[c] = 1;
    else mp[c] += 1;
  }
  for (auto i = mp.begin(); i != mp.end(); i++) {
    if (mp[i->first] % 2 != 0) {
      ans = false;
      break;
    }
  }
  if (ans) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
using namespace std;
typedef long long ll;
ll fx,fy,num=0,siz=0,r,n,x,y,lim,l,z,i,m,q,c[2][100005],tot=0,dsu[100005],vis[100005];
ll getf(ll x){return dsu[x]==x?x:dsu[x]=getf(dsu[x]);}
ll wan(ll x){return x*(x-1LL)/2LL;}
int main()
{
	scanf("%lld%lld%lld",&n,&m,&q);
	for(i=1;i<=n;i++)dsu[i]=i;
	for(i=1;i<=q;i++)
	{
		scanf("%lld%lld%lld",&x,&y,&z);
		x++;y++;
		if(z==0)
		{
			vis[x]=vis[y]=1;
			fx=getf(x);
			fy=getf(y);
			if(fx!=fy)dsu[fx]=fy;
		}
		else
		{
			tot++;
			c[0][tot]=x;
			c[1][tot]=y;
		}
	}
	for(i=1;i<=tot;i++)
	{
		fx=getf(c[0][i]);fy=getf(c[1][i]);
		if(fx==fy)
		{
			printf("No\n");
			return 0;
		}
	}
	for(i=1;i<=n;i++)
	{
		if(vis[i])siz++;
		if(vis[i]&&getf(i)==i)num++;
	}
	if(num>=3)lim=siz-num+wan(num+n-siz);
	if(num==2)
	{
		if(siz==n&&tot>0)
		{
			printf("No\n");
			return 0;
		}
		lim=siz-num+wan(num+n-siz);
	}
	if(num==1)
	{
		if(siz==n-1&&tot>0)
		{
			printf("No\n");
			return 0;
		}
		lim=siz-num+wan(num+n-siz);
	}
	if(num==0)lim=siz-num+wan(n+num-siz);
	if(tot==0)l=n-1;
	else l=n;
	if(m<=lim&&m>=l)printf("Yes\n");
	else printf("No\n");
	return 0;
}

Measured memory_bytes: 2560
#include <stdio.h>
#include <stdlib.h>
long long MIN(long long a,long long b){return a<b?a:b;}
int main()
{
    int n,k;
    scanf("%d%d",&n,&k);
    int h[n];
    for(int i=0;i<n;i++){
        scanf("%d",&h[i]);
    }
    long long dp[100002]={0};
    dp[0]=0;
    dp[1]=abs(h[0]-h[1]);
    for(int i=2;i<n;i++){
        long long sub=1000000000000;
        for(int j=1;j<=k;j++){
        sub=MIN(dp[i-j]+abs(h[i-j]-h[i]),sub);
        }
        dp[i]=sub;
    }
    printf("%lld",dp[n-1]);
    return 0;
}


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

#define rep(i, x, n) for (int i = x; i < n; i++)
typedef long long ll;

const int INF = 1e9 + 7;

using namespace std;

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

    int n;
    cin >> n;

    vector<ll> a(n);
    rep (i, 0, n)
	cin >> a[i];
    
    ll res;
    auto min_it = min_element(a.begin(), a.end());
    while (1) {
	auto min_it_tmp = min_it;
	for (auto it = a.begin(); it != a.end(); it++) {
	    if (it == min_it)
		continue;
	    *it %= *min_it;

	    if (*it > 0 && *it < *min_it_tmp)
		min_it_tmp = it;
	}
	if (min_it == min_it_tmp) {
	    res = *min_it;
	    break;
	} else {
	    min_it = min_it_tmp;
	}
    }

    cout << res << endl;

    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;

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

    ll ans = 0;
    while(x <= y) {
        x *= 2;
        ans++;
    }

    out(ans);
    re0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <stack>
#include <queue>
#include <tuple>
#include <numeric>
#include <utility>
#include <climits>
#include <float.h>
#include <cmath>
#define _USE_MATH_DEFINES
#include <math.h>
#pragma GCC target ("avx2")

using namespace std;

typedef long long ll;
typedef long double ld;
constexpr ll INF = LLONG_MAX;
constexpr double DINF = DBL_MAX;
constexpr ll mod = 1e9+7;
constexpr ll mod2 = 998244353;
constexpr double PI = M_PI;

template<typename T>
vector<T> make_v(size_t a){
  	return vector<T>(a);
}

template<typename T, typename... Ts>
auto make_v(size_t a, Ts... ts){
  	return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}

long long fact(long long n, long long mod){
  long long x = 1;
  while(n > 1ll){
    x = (x * n) % mod;
    n--;
  }
  return x;
}
 
long long expo(long long a, long long p, long long mod){
  if(p == 0ll){
    return 1ll;
  }else if(p % 2ll == 0){
    long long cmp = expo(a, p/2ll, mod);
    return (cmp * cmp) % mod;
  }else{
    return (expo(a, p-1, mod) * a) % mod;
  }
}

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

	long long a, b, c, k, ans = 0;
	cin >> a >> b >> c >> k;
	ans += min(k, a);
	k -= min(k, a);
	k -= min(k, b);
	ans -= min(k, c);
	k -= min(k, c);
	cout << ans << endl;
	return 0;
}


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

using namespace std;

#define Rep(b, e, i) for (int i = b; i <= e; i++)
#define Repr(e, b, i) for (int i = e; i >= b; i--)
#define rep(n, i) Rep(0, n - 1, i)
#define repr(n, i) Repr(n - 1, 0, i)
#define all(v) (v).begin(), (v).end()
#define pb(v) push_back(v)
#define uniq(v) (v).erase(unique(all(v)), (v).end())
#define bitcnt(x) __builtin_popcount(x)
#define fst first
#define snd second
#define Pqaz(T) priority_queue<T, vector<T>, greater<T>>
#define Pqza(T) priority_queue<T>
#define put(x) cout << x;
#define putsp(x) cout << x << ' ';
#define putbd cout << "---------------------------------------------" << endl;
#define putln(x) cout << x << endl;
#define debug(x) cerr << #x << "=" << x << endl;
#define ENJYU std::ios::sync_with_stdio(false) std::cin.tie(0);

typedef long long ll;
typedef pair<ll, ll> llP;
typedef pair<int, int> intP;
typedef complex<double> comp;
typedef vector<int> vec;
typedef vector<ll> vecll;
typedef vector<double> vecd;
typedef vector<vec> mat;
typedef vector<vecll> matll;
typedef vector<vecd> matd;

template <class T>
ostream &operator<<(ostream &o, const vector<T> &v)
{
	o << "{";
	for (int i = 0; i < (int)v.size(); i++) o << (i > 0 ? ", " : "") << v[i];
	o << "}";
	return o;
}

const int MAX = 200020;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = 1<<29;
const ll INFL = 1e18;
const ll MOD = 1000000007;

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

//********************************template END****************************************//

void solve()
{
	stack<int> s;
	char c, pre = '~';
	while (~scanf("%c", &c))
	{
		if (c == '.')
		{
			if (pre == '\n') return;
			cout << (s.empty() ? "yes" : "no") << endl;
			stack<int> ns;
			swap(s, ns);
		}
		if (c == '(') s.push(1);
		if (c == ')')
		{
			if (s.empty() || s.top() != 1)
			{
				cout << "no" << endl;
				stack<int> ns;
				swap(s, ns);
				while (~scanf("%c", &c))
				{
					if (c == '.') break;
				}
			}
			else s.pop();
		}
		if (c == '[') s.push(-1);
		if (c == ']')
		{
			if (s.empty() || s.top() != -1)
			{
				cout << "no" << endl;
				stack<int> ns;
				swap(s, ns);
				while (~scanf("%c", &c))
				{
					if (c == '.') break;
				}
			}
			else s.pop();
		}
		pre = c;
	}
}

int main()
{
	solve();
	//cout << "yui(*-v・)yui" << endl;
	return 0;
}



Measured memory_bytes: 3156
#include <bits/stdc++.h>
#include <algorithm>
#define MAX 307
using namespace std;
double dp[MAX+5][MAX+5][MAX+5]; // Hold expectation value for each state.
int main(int argc, char*argv[])
{
	int N;
	cin >> N; // N can be between 1 to 300
	// Each of the Sushi plat can have  1 to 3 Sushi max
	
	vector<int> cnt(4, 0);// We count how many Sushi plates with 1-sushi, 2-sushi and 3-sushi.
	for (int i = 0; i < N; ++i)
	{
		int t;
		cin >>t;
		++cnt[t];
	}
	for (int i = 0; i <= MAX; ++i) // Loop for 3 Sushi
		for (int j = 0; i + j <= MAX; ++j)// Loop for 2 Sushi
			for (int k = 0; i + j + k <= MAX; ++k)// Loop for 1 Sushi
			{
				if(i ==0 && j==0 && k==0) //All Sushi over
					continue;
				if(i+j+k > MAX) // Sushi count > N , not possible
					continue;
				
				double K = 1.0 * ( k + j + i); // Total plates with 1-2-3 Sushi 
				
				
				// Add the expectation of choosing plate with 1 Sushi , multiply with probability of choosing 1 over total (K)
				if(k) // if count#1 is !=0
					dp[k][j][i] += ((1.0 * k)  /K ) * dp[k-1][j][i]; 
				
				if(j) // if count#2 is !=0
					dp[k][j][i] += ((1.0 * j)  /K )* dp[k+1][j-1][i]; 
				
				if(i) // if count#1 is !=0
					dp[k][j][i] += ((1.0 * i)  /K )* dp[k][j+1][i-1];
					
				dp[k][j][i] += (1.0 *N)/K;	
			}
			
	cout.precision(15);
    cout << fixed << dp[cnt[1]][cnt[2]][cnt[3]] << "\n";
}

Measured memory_bytes: 235776
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template<typename T> using v2 = vector<vector<T>>;

void solve(){
    int k;
    string s;
    cin >> k >> s;
    if(s.length() <= k){
        cout << s << '\n';
    }
    else{
        cout << s.substr(0, k) << "...\n";
    }
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
    return 0;
}


Measured memory_bytes: 3616
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
const ll MOD = 1000000007;
const ll INF = 10000000000000000;
vector<int> x4 = {0, 1, 0, -1}, x8 = {0, 1, 1, 1, 0, -1, -1, -1};
vector<int> y4 = {1, 0, -1, 0}, y8 = {1, 1, 0, -1, -1, -1, 0, 1};
template<class T> struct edge { int from, to; T cost;};
template<class T> inline bool chmin(T& a, T b){if (a>b){a = b; return true;}return false;}
template<class T> inline bool chmax(T& a, T b){if (a<b){a = b; return true;}return false;}
template<class T> inline T powerM(T a,T b){if (b==0) return 1;
T tmp = powerM(a,b/2); if (b%2==0) return tmp*tmp%MOD; else return tmp*tmp%MOD*a%MOD; }
template<class T> inline T power(T a,T b,T m){ if (b==0) return 1;
  T tmp = power(a,b/2,m); if (b%2==0) return tmp*tmp%m; else return tmp*tmp%m*a%m; }
template<class T> inline T gcd(T a, T b){if (b==0) return a; return gcd(b, a%b);}
template<class T> inline T lcm(T a, T b){return a / gcd(a,b) * b;}
// ax+by=gcd(a,b)を解く
template<class T> inline T extgcd(T a,T b,T &x,T &y){if (b==0){x=1; y=0; return a;} T d=extgcd(b,a%b,y,x); y -= a/b*x; return d;}
void hey(){ cout <<"hey" <<endl; }


int main() {
  int res = 0;
  string s; cin >>s;
  transform(all(s), s.begin(), ::tolower);
  string t;
  while (cin >>t){
    transform(all(t), t.begin(), ::tolower);
    if (s == t ) res++;
    if (t == "END_OF_TEXT") break;
  }
  cout <<res <<endl;
}



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

int main(void){
    int A,B,T;
    cin >> A >> B >> T;
    int sum=0;
    int i=1;
    
    while(A*i<=T){
        i++;
        sum+=B;
    }
    
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using PII = pair<ll, ll>;
#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
template<typename T> void chmin(T &a, const T &b) { a = min(a, b); }
template<typename T> void chmax(T &a, const T &b) { a = max(a, b); }
struct FastIO {FastIO() { cin.tie(0); ios::sync_with_stdio(0); }}fastiofastio;
#ifdef DEBUG_ 
#include "../program_contest_library/memo/dump.hpp"
#else
#define dump(...)
#endif
const ll INF = 1LL<<60;

int main(void) {
    ll n;
    cin >> n;
    vector<ll> a(n), cnt(n);
    REP(i, n) cin >> a[i], a[i]--, cnt[a[i]]++;

    sort(ALL(cnt));
    vector<ll> rui(cnt);
    FOR(i, 1, n+1) rui[i] += rui[i-1];

    vector<ll> able(n+1);
    FOR(i, 1, n+1) {
        ll itr = upper_bound(ALL(cnt), i) - cnt.begin();
        able[i] = ((itr==0 ? 0 : rui[itr-1]) + (n-itr)*i) / i;
    }

    FOR(i, 1, n+1) {
        ll lb = 0, ub = n+1;
        auto check = [&](ll mid) { return i <= able[mid]; };
        while(ub-lb>1) {
            ll mid = (lb+ub)/2;
            if(check(mid)) lb = mid;
            else ub = mid;
        }
        cout << lb << "\n";
    }
    cout << flush;

    return 0;
}

Measured memory_bytes: 10240
s = gets.chomp
words = %w(dream dreamer erase eraser)

loop do
  prev = s.dup
  words.each do |w|
    if s.end_with?(w)
      s[-w.size, 10] = ''
    end
  end
  if prev == s
    puts 'NO'
    exit
  end
  break if s == ''
end

puts 'YES'


Measured memory_bytes: 67164
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#define dlog(str) cout << "====" << str << endl;
#else
#define dlog(str)
#endif
#define INF 999999999
#define MOD 1000000007
#define REP(i, n) for(int i = 0, i##_l = (n); i < i##_l; i++)
#define FOR(i, s, e) for(int i = s, i##_l = (e); i < i##_l; i++)
#define LLI long long int
#define _min(a,b) ((a<b)?a:b)
#define _max(a,b) ((a<b)?b:a)
#define chmax(a, b) a = _max(a, b)
#define chmin(a, b) a = _min(a, b)
#define bit(a, shift) ((a>>shift)&1))
#define pm(a) ((a)?1:-1)
#define SORT(v) sort(v.begin(),v.end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
// int 2.14E±9    lli 9.2E±18    double 1.7E±380


int main()
{
	cout << fixed << setprecision(10);
	string s;
	cin >> s;
	if (s[2] == s[3] && s[4] == s[5])
	{
		cout << "Yes";
	}
	else
	{
		cout << "No";
	}
	return 0;
}

Measured memory_bytes: 256
i;
p(a,b){for(i=0;i++<b;)putchar(a);}

int main(void){

    int x,y,u,v;
    scanf("%d%d%d%d",&u,&v,&x,&y);
    
    x-=u;
    y-=v;
    
    p(85,y);
    p(82,x);
    p(68,y);
    p(76,x);
    printf("L");
    p(85,y+1);
    p(82,x+1);
    printf("DR");
    p(68,y+1);
    p(76,x+1);
    printf("U");
}

Measured memory_bytes: 1724
# 1行目の入力を空白で分割された数値として扱う
n, k = map(int, input().split())
# 2行目の入力を数値のリストとして扱う
h = list(map(int, input().split()))

# 答えのカウンタの準備
cnt = 0

# k以上のhを数える
for i in range(0, n):
    if h[i] >= k:
        cnt += 1

# 答えの出力
print( cnt )

Measured memory_bytes: 11916
from collections import Counter

n = int(input())
D = list(map(int, input().split()))

mod = 998244353
  

if D[0] != 0:
    print(0)
    exit()

dic = Counter(D)
if dic[0] != 1:
    print(0)
    exit()

keys = sorted(dic.keys())
prev_num = 0
prev_count = 1
ans = 1
for num in keys:
    if num == 0:
        continue

    if num - prev_num != 1:
        print(0)
        exit()

    count = dic[num]
    ans *= prev_count ** count
    ans %= mod
    prev_num = num
    prev_count = count

print(ans)


Measured memory_bytes: 19936
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <deque>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <iomanip>
#include <bitset>
#include <set>
#include <map>
#include <stdio.h>
#include <numeric>

#define rep(i,n) for (int i = 0; i < (n); i++)
#define FOR(i,a,b) for (int i=(a); i < (b); i++)
#define INF 100000000000
#define MOD 1000000007 //10^9+7
using namespace std;
using ll = long long;
using P = pair<int, int>;

// 負の数にも対応した % 演算
long long mod(long long val, long long m) {
    long long res = val % m;
    if (res < 0) res += m;
    return res;
}

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

long long lcm(ll a, ll b)
{
    return a * b / gcd(a, b);
}

int main()
{
    ll a, b, c ,d;
    cin >> a >> b >> c >> d;
    
    ll ans = 0;
    a = a - 1 - (a-1)/c - (a-1)/d + (a-1)/lcm(c, d);
    b = b - b/c - b/d + b/lcm(c, d);

    cout << b - a << endl;
    return 0;
}


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

namespace AOJ
{
	class Program
	{
		static void Main(string[] args)
		{
			int max = 1000000;
			var HammingNumbers = new bool[max + 1];
			for (int i = 1; i <= max; i *= 2)
			{
				for (int j = 1; i * j <= max; j *= 3)
				{
					for (int k = 1; i * j * k <= max; k *= 5)
					{
						HammingNumbers[i * j * k] = true;
					}
				}
			}

			var s = "";
			while ((s = Console.ReadLine()) != "0")
			{
				var mn = s.Split(' ').Select(c => int.Parse(c)).ToArray();
				Console.WriteLine(HammingNumbers.Skip(mn[0]).Take(mn[1] - mn[0] + 1).Count(b => b));
			}
		}
	}
}

Measured memory_bytes: 6940
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
#define rep1(i,n) for (int i = 1; i <= (n); i++)
#define repf(i,a,b) for (int i = (a); i < (b); i++)
#define repi(i,a,b) for (int i = (a); i <= (b); i++)
#define repr(i,a,b) for (int i = (a); i >= (b); i--)
#define all(x) (x).begin(),(x).end()
using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vd = vector<double>;
using pii = pair<int, int>;
using vc = vector<char>;
using vvc = vector<vc>;
using vs = vector<string>;
using tiii = tuple<int, int, int>;

int main() {
  int N; cin >> N;
  vd x(N);
  vs u(N);
  rep(i,N) cin >> x.at(i) >> u.at(i);
  
  double Y = 0;
  rep(i,N) {
    Y += u.at(i)=="JPY"?x.at(i):x.at(i)*380000.0;
  }
  
  cout << Y << endl;
}

Measured memory_bytes: 256
N = int(input())
input_list = [int(i) for i in input().split()]
max_num = 10 ** 18

sum_num = 1
if 0 in input_list:
    print('0')
else:
    for i in input_list:
        sum_num *= i
        if sum_num > max_num:
            sum_num = -1
            break
    print(sum_num)

Measured memory_bytes: 21664
# -*- coding: utf-8 -*-
import sys
import copy
import collections
from bisect import bisect_left
from bisect import bisect_right
from collections import defaultdict
from heapq import heappop, heappush
import math

# NO, PAY-PAY
#import numpy as np
#import statistics
#from statistics import mean, median,variance,stdev

def inputInt(): return int(input())
def inputMap(): return map(int, input().split())
def inputList(): return list(map(int, input().split()))
 
def main():
    N = inputInt()
    A = inputList()
    
    ans = [0]*N
    B=[]
    for i in range(N, 0, -1):
        cons = 0
        for j in range(i, N+1, i):
            if ans[j-1] == 1:
                cons += 1
        if A[i-1] == 1 and cons % 2 == 0:
            ans[i-1] = 1
            B.append(i)
            continue
        if A[i-1] == 0 and cons % 2 == 1:
            ans[i-1] = 1
            B.append(i)
            continue
            
    print(len(B))
    print(*B)
            	
if __name__ == "__main__":
	main()


Measured memory_bytes: 65488