akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Linq;
 
class D
{
    static void Main()
    {
        int N = int.Parse(Console.ReadLine());
        var A = (Console.ReadLine()).Split(' ').Select(s => long.Parse(s)).ToArray();

        var Sum = 1000L;
        var Stock = 0L;

        for (int i = 0; i < N - 1; i++)
        {
            if (A[i + 1] < A[i])
            {
                Sum += A[i] * Stock;
                Stock = 0;
            }
            else if (A[i + 1] > A[i])
            {
                var now = Sum / A[i];
                
                Sum -= now * A[i];
                Stock += now;
            }
        }
        if (Stock != 0)
        {
            Sum = Sum + A[A.Length - 1] * Stock;
            Stock = 0;
        }
        Console.WriteLine(Sum.ToString());
    }
}

Measured memory_bytes: 28204
#include <stdio.h>

int simple(int initial, int year, int charge, double rate){ //単利
  int i, interest = 0;
  for(i = 0; i < year; i++){
    interest += initial * rate;
    initial -= charge;
  }
  return initial + interest;
}

int compound(int initial, int year, int charge, double rate){ //複利
  int i, interest;
  for(i = 0; i < year; i++){
    interest = initial * rate;
    initial = initial + interest - charge;
  }
  return initial;
}

int Max(int a, int b){
  if(a > b)
    return a;
  else
    return b;
}

void solve(){
  int initial, year, n, s_c, charge;
  int i, result = 0, buf;
  double rate;
  
  scanf("%d", &initial);
  scanf("%d", &year);
  scanf("%d", &n);
  
  for(i = 0; i < n; i++){
    scanf("%d %lf %d", &s_c, &rate, &charge);
    if(s_c == 0) result = Max(result, simple(initial, year, charge, rate));
    else result = Max(result, compound(initial, year, charge, rate));
  }
  printf("%d\n", result);
}

int main(void){
  int m, i;
  scanf("%d", &m);

  for(i = 0; i < m; i++){
    solve();
  }

  return 0;
}


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

int main() {
  int N;
  cin >> N;
  vector<int> a(N);
  for (int i = 0; i < N; i++) {
    cin >> a.at(i);
  }
    sort(a.begin(), a.end());
    reverse(a.begin(), a.end());
    int A = 0, B = 0;
    for (int i = 0; i < N; i++) {
      if (i % 2 == 0)
      A += a.at(i);
      else B += a.at(i);
    }
    cout << A - B << endl;
  }

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

ans = True

for a in la:
    if a % 2 == 0:
        if a % 3 == 0 or a % 5 == 0:
            pass
        else:
            ans = False

if ans:
    print("APPROVED")
else:
    print("DENIED")


Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
#define  ft  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define  ll  long long
#define  pi  pair<ll,ll>
#define  pb  push_back
#define  F   first
#define  S   second
const int N=2e5+3;
pi a[10];
int main()
{
    ft
    ll t,i,j,n,m,l,r;
    cin>>n;
    for(i=0;i<n;i++)
    {
        cin>>l>>r;
        a[i]={l,r};
    }
    sort(a,a+n);
    double s=0,p=0;
    do
    {
        for(i=1;i<n;i++)
        {
            s+=sqrt(1.0*((a[i].F-a[i-1].F)*(a[i].F-a[i-1].F)+(a[i].S-a[i-1].S)*(a[i].S-a[i-1].S)));
        }
        p++;
    }while(next_permutation(a,a+n));
    cout<<fixed<<setprecision(10)<<(s/p)<<"\n";
    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main(){
    int n;
    cin >> n;
    vector<int> h(n);
    for(int i = 0; i < n; ++i){
        cin >> h[i];
    }
    
    if(n == 0){
        cout << "Yes\n";
        return 0;
    }
    
    int now = h[n-1];
    for(int i = n - 2; i >= 0; --i){
        if(h[i] <= now){
            now = h[i];
            continue;
        }
        
        if(h[i] > now + 1){
            cout << "No\n";
            return 0;
        }
    }
    
    cout << "Yes\n";
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define sz(x) (int)(x).size()
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;
  
int main() {
  int N;
  cin >> N;
  vi A(N);
  ll sum = 0;
  rep(i,N) {
    cin >> A[i];
    sum += A[i];
  }
  ll l = 0;
  ll r = sum;
  ll ans = sum;
  rep(i,N) {
    l += A[i];
    r -= A[i];
    ans = min(ans,abs(l-r));
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1024
#!/usr/bin/env python3
import sys, math, fractions, itertools


def solve(N: int, S: str):
    counter = 0
    mx = 0
    for i in range(N):
        if S[i] == 'I':
            counter += 1
        else:
            counter -= 1
        if mx < counter:
            mx = counter
    print(mx)
    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    S = next(tokens)  # type: str
    solve(N, S)

if __name__ == '__main__':
    main()


Measured memory_bytes: 5048
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N ;
  if( (N % 1000) % 111 == 0 || ( N - (N % 10) ) /10 % 111 == 0 ){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;int h,w,k,l,m,a,b,s,t,u,v,i,j,x[999][999];
int main(){
	while(true){
		memset(x,0,sizeof(x));v=0;
		cin>>k;if(!k){break;}
		cin>>w>>h;
		for(i=0;i<k;i++){cin>>a>>b;x[a][b]=1;}
		cin>>s>>t;
		for(i=1;i<=w;i++){
			for(j=1;j<=h;j++){
				u=0;
				for(l=0;l<s;l++){
					for(m=0;m<t;m++){
						if(x[i+l][j+m]){
							u++;
						}
					}
				}
				v=max(v,u);
			}
		}
		cout<<v<<endl;
	}
}

Measured memory_bytes: 5064
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;


namespace ABC053
{
	public class Don
	{
		public Don() { }
		private Reader r = new Reader();

		public void Solve()
		{
			long N = r.nextLong();

			long mod = N % 11;
			long ret = (N - mod) / 11;
			ret *= 2;
			if (mod != 0)
			{
				if (mod <= 6) ret++;
				else ret += 2;
			}

			Console.WriteLine(ret);
		}

		public static void Main(string[] args)
		{
			new Don().Solve();
		}

	}

	class Reader
	{
		string[] s;
		int i;
		char[] cs = new char[] { ' ' };

		public Reader()
		{
			s = new string[0];
			i = 0;
		}

		public string next()
		{
			if (i < s.Length)
				return s[i++];
			var input = Console.ReadLine();
			while (input == "")
				input = Console.ReadLine();
			s = input.Split(cs, StringSplitOptions.RemoveEmptyEntries);
			i = 0;
			return next();
		}

		public int nextInt()
		{
			return int.Parse(next());
		}

		public long nextLong()
		{
			return long.Parse(next());
		}

		public double nextDouble()
		{
			return double.Parse(next());
		}

	}
}

Measured memory_bytes: 2648
#include <bits/stdc++.h>
#define ll long long
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define deb(x) cout<<#x<<"="<<x<<endl;
#define endl '\n'
#define M 1000000007
#define int long long
#define INF 1e18
#define N 1000005

using namespace std;

ll sz[N];

ll root(ll a, ll uni[])
{
	if (uni[a] == a)return a;
	return uni[a] = root(uni[a], uni);
}

void mer(ll a, ll b, ll uni[])
{
	if (root(a, uni) != root(b, uni))
	{
		a = root(a, uni);
		b = root(b, uni);
		if (sz[a] > sz[b])
		{uni[b] = a, sz[a] += sz[b]; sz[b] = 0;}
		else
		{uni[a] = b, sz[b] += sz[a]; sz[a] = 0;}
	}
}

void solve()
{
	ll n, m;
	cin >> n >> m;
	ll uni[n];
	for (int i = 0; i < n; ++i)
	{
		uni[i] = i;
		sz[i] = 1;
	}
	while (m--)
	{
		ll u, v;
		cin >> u >> v;
		u--, v--;
		mer(u, v, uni);
	}
	ll ans = 0;
	for (int i = 0; i < n; ++i)
	{
		ans = max(ans, sz[i]);
	}
	cout << ans << endl;
}

int32_t main()
{
	IOS
	ll T = 1;
	// cin >> T;
	for (ll i = 1; i <= T; ++i)
	{
		// cout<<"Case #"<<i<<": ";
		solve();
	}
	return 0;
}

Measured memory_bytes: 6752
#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define fi first
#define se second
#define mp make_pair
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,K,Q,A,B,L,R;
string S;
const ll MOD = (1e+9) + 7;
const ll INF = 1LL << 60;
typedef pair<ll,ll> P;

typedef vector<P> vp;
typedef vector<vp> matP;

const ll MAX_N = 200010;
vec bit(MAX_N,0);
ll sum(ll i){
    ll s = 0;
    while(i > 0){
        s += bit[i];
        i -= i & -i;
    }
    return s;
}
void add(ll i, ll x){
    while(i < MAX_N){
        bit[i] += x;
        i += i & -i;
    }
}

int main() {
    cin>>N>>K;
    vec a(N), ord(N+1), a_rank(N+1), sum_a(N+1);
    rep(i,N) cin>>a[i];
    rep(i,N+1) ord[i] = i;
    sum_a[0] = 0;
    rep(i,N) sum_a[i+1] = sum_a[i] + a[i] - K;
    sort(ord.begin(), ord.end(), [&](ll x, ll y){
        return sum_a[x] < sum_a[y];
    });
    ll last = INF, rank = 0;
    rep(i,N+1){
        rank += last != sum_a[ord[i]];
        add(rank, 1);
        a_rank[ord[i]] = rank;
        last = sum_a[ord[i]];
    }
    ll ans = 0;
    for(int i = N; i >= 0; --i){
        add(a_rank[i], -1);
        ans += sum(a_rank[i]);
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 8064
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define rep(i, n) for(int i=0;i<n;++i)
#define rrep(i, n) for(int i=n;i>=0;--i)
const int inf=1e9+7;
const ll mod=1e9+7;
const ll mod1=998244353;
const ll big=1e18;
const double PI=2*asin(1);

int N;
int bit[500005]; // bit 1-index
map<int, int> amap;

void add(int i, int x) {
  int tmp;
  if(amap[x]==0) {
    tmp = i;
    while(tmp<=N) {
      bit[tmp]++;
      tmp += tmp&-tmp;
    }
  }
  else {
    tmp = i;
    while(tmp<=N) {
      bit[tmp]++;
      tmp += tmp&-tmp;
    }
    tmp = amap[x];
    while(tmp<=N) {
      bit[tmp]--;
      tmp += tmp&-tmp;
    }
  }
  amap[x] = i;
}

int sum(int l) {
  int ans = 0;
  while(l>0) {
    ans += bit[l];
    l -= l&-l;
  }
  return ans;
}

int main() {
  int Q;
  cin>>N>>Q;
  int c[N];
  for(int i=0;i<N;++i) cin>>c[i];
  vector<tuple<int, int, int> > query(Q);
  int l, r;
  for(int i=0;i<Q;++i) {
    cin>>l>>r;
    query[i] = make_tuple(r, l, i);
  }
  sort(query.begin(), query.end());
  int ans[Q];
  int index = 0;
  for(int i=0;i<Q;++i) {
    l = get<1>(query[i]);
    r = get<0>(query[i]);
    for(int j=index;j<r;++j) {
      add(j+1, c[j]);
      ans[get<2>(query[i])] = sum(r) - sum(l-1);
    }
    index = r-1;
  }
  for(int i=0;i<Q;++i) cout<<ans[i]<<endl;
}

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

#define PI 3.14159265358979323846264338327950288419

using namespace std;

char str[205];
int copies, len;

long long ans;

int compute(){
	int prev = 0, ret = 0;
	for(int i = 1; i < len; i++){
		if(str[i] != str[i - 1]){
			ret += (i - prev) / 2;
			prev = i;
		}
	}
	ret += (len - prev) / 2;
	return ret;
}

int main(){
	scanf("%s ", str);
	len = strlen(str);
	scanf("%d", &copies);
	bool monochrome = true;
	for(int i = 1; i < len; i++){
		if(str[i] != str[0]){
			monochrome = false;
		}
	}
	
	if(monochrome){
		ans = 1LL * len * copies / 2;
	}
	else{
		int a1 = compute();
		for(int i = len; i < len + len; i++){
			str[i] = str[i - len];
		}
		len += len;
		int a2 = compute();
		ans = a1 + 1LL * (a2 - a1) * (copies - 1);
	}
	printf("%lld\n", ans);
	return 0;
}


Measured memory_bytes: 256
#! usr/bin/env python
# -*- coding: utf-8 -*-

from collections import deque
import heapq
import math
import bisect


def main():
    N = int(input())
    S = input()
    W = [0] * (N+1)
    B = [0] * (N+1)
    for i in range(N):
        W[i+1] = W[i]
        B[i+1] = B[i]
        if S[i]=='.':
            W[i+1] += 1
        else:
            B[i+1] += 1

    ans = N + 1
    for i in range(N+1):
        ans = min(ans, W[N]-W[i]+B[i])

    print(ans)


if __name__ == '__main__':
    main()


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


#define li          long long int
#define rep(i,to)   for(li i=0;i<((li)(to));i++)
#define repp(i,start,to)    for(li i=(li)(start);i<((li)(to));i++)
#define pb          push_back
#define sz(v)       ((li)(v).size())
#define bgn(v)      ((v).begin())
#define eend(v)     ((v).end())
#define allof(v)    (v).begin(), (v).end()
#define dodp(v,n)       memset(v,(li)n,sizeof(v))
#define bit(n)      (1ll<<(li)(n))
#define mp(a,b)     make_pair(a,b)
#define rin rep(i,n)
#define EPS 1e-12
#define ETOL 1e-8
#define MOD 1000000007
typedef pair<li, li> PI;

#define INF bit(60)

#define DBGP 1


#define idp if(DBGP)
#define F first
#define S second
#define p2(a,b)     idp cout<<a<<"\t"<<b<<endl
#define p3(a,b,c)       idp cout<<a<<"\t"<<b<<"\t"<<c<<endl
#define p4(a,b,c,d)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<endl
#define p5(a,b,c,d,e)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<endl
#define p6(a,b,c,d,e,f)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<endl
#define p7(a,b,c,d,e,f,g)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<endl
#define p8(a,b,c,d,e,f,g,h)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<endl
#define p9(a,b,c,d,e,f,g,h,i)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<endl
#define p10(a,b,c,d,e,f,g,h,i,j)        idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<"\t"<<j<<endl
#define foreach(it,v)   for(__typeof((v).begin()) it=(v).begin(); it!=(v).end(); ++it)
#define p2p(x)      idp p2((x).F, (x).S)
#define dump(x,n)   idp{rep(i,n){cout<<x[i]<<" ";}puts("");}
#define dump2(x,n)  idp{rep(i,n){cout<<"["<<x[i].F<<" , "<<x[i].S<<"] ";}puts("");}
#define dumpi(x)    idp{foreach(it, x){cout<<(*it)<<" ";}puts("");}
#define dumpi2(x)   idp{foreach(it, x){cout<<"["<<(it)->F<<" , "<<(it)->S<<"] ";}puts("");}

#define read2d(a,w,h)   rep(i,h)rep(j,w)cin>>a[i][j]
#define dump2d(a,w,h)   rep(i,h){rep(j,w)cout<<a[i][j]<<" ";puts("");}

typedef pair<li, li> PI;



int main() {
    li l,r,d;
    cin>>l>>r>>d;
    li res=0;
    repp(i,l,r+1){
        if(i%d==0)res++;
    }
    cout<<res<<endl;

    return 0;
}

Measured memory_bytes: 3552
#include <iostream>
#include <cassert>

using namespace std;

long long burger(int L) {
    if (L == 0) return 1;
    return burger(L-1)*2 + 3;
}

long long paty(int L) {
    if (L == 0) return 1;
    return paty(L-1)*2 + 1;
}

// いい感じの再帰
long long saiki(int L, long long X) {
    if (L == 0) {
        if (X == 0) return 0;
        else return 1;
    }

    if (X == 0) return 0;
    if (X <= 1) {
        if (L == 0) return 1;
        else return 0;
    }
    if (X <= 1 + burger(L-1)) {
        return saiki(L-1, X-1);
    }
    if (X <= 2 + burger(L-1)) {
        return paty(L-1) + 1;
    }
    if (X <= 2 + burger(L-1)*2) {
        return paty(L-1) + 1 + saiki(L-1, X-2-burger(L-1));
    }
    if (X <= 2 + burger(L-1)*2 + 1) {
        return paty(L);
    }
    assert(0);
    return 0;
}

int main() {
    int N;
    long long X;
    cin >> N >> X;

    long long ans = saiki(N, X);

    cout << ans << endl;
}

Measured memory_bytes: 256
import math


def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))


N , P = map(int,input().split())
A = list(map(int,input().split()))
odd_num = 0
even_num = 0
for a in A:
    if a % 2 == 1:
        odd_num += 1
    else:
        even_num += 1
ans = 0

if P == 1:
    if odd_num == 0:
        ans = 0
    else:
        for i in range(1, N + 1, 2):
            ans += combinations_count(N, i)
else:
    if odd_num == 0:
        ans = 2 ** even_num
    else:
        for i in range(0, N + 1, 2):
            ans += combinations_count(N, i)
print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <vector>

using namespace std;

#define l first
#define r second
#define int long long

int n, m;
int a[500000];
const int INF = 1e9 + 1;
vector<int> graph[500000];
int color[500000];
int mn[500000];
int c = 1;

void dfs(int v)
{
    if (color[v]) return;
    mn[c] = min(mn[c], a[v]), color[v] = c;
    for (auto u : graph[v]) dfs(u);
}

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin >> n >> m;
    if (n == m + 1)
    {
        cout << 0;
        return 0;
    }
    for (int i = 0; i < n; i++) cin >> a[i];
    for (int i = 0; i < m; i++)
    {
        int v, u;
        cin >> v >> u;
        graph[v].push_back(u);
        graph[u].push_back(v);
    }
    int select = 2 * (n - m - 1);
    if (n < select) {cout << "Impossible"; return 0;}
    long long ans = 0;
    fill(mn, mn + n + 1, 1000000000);
    for (int i = 0; i < n; i++) if (color[i] == 0) dfs(i), c++;
    map<int, int> use;
    for (int i = 0; i < n; i++) use[a[i]]++;
    for (int i = 1; i < c; i++)
    {
        ans += mn[i], use[mn[i]]--;
        if (!use[mn[i]]) use.erase(mn[i]);
    }
    for (int i = c - 1; i < select; i++)
    {
        int k = (*use.begin()).first;
        ans += k;
        use[k]--;
        if (!use[k]) use.erase(k);
    }
    cout << ans;
}


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

int main(){
	int N,A,B,C,X;
	while (cin >> N >> A >> B >> C >>X){
		if (N+A+B+C+X == 0){
			break;
		}
		int Y[N];
		int frame = 0;
		for (int i = 0; i <= N-1; i++){
			cin >> Y[i];
		}
		int i = 0;
		for (int frame = 0; frame <= 10000; frame++){
		    if(X == Y[i]){
				i++;
			}
			X = ((A*X+B)%C);
			
			if (i == N){
				cout << frame << endl;
				break;
			}
			if (frame == 10000){
				cout << -1 << endl;
			}
		}
	}
}

Measured memory_bytes: 1160
#include <iostream>
#include <vector>
using namespace std;
int main() {
    int N, min = 100;
    cin >> N;
    vector<int> x(N), y(N);
    for (int i = 0; i < N; i++) cin >> x[i] >> y[i];
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < N; j++) {
            if (i == j) continue;
            int p = x[j] - x[i], q = y[j] - y[i];
            int cnt = 0;
            for (int k = 0; k < N; k++) {
                for (int l = 0; l < N; l++) {
                    if (k == l) continue;
                    if (x[l] - x[k] == p && y[l] - y[k] == q) cnt++;
                }
            }
            if (N - cnt < min) min = N - cnt;
        }
    }
    if (N == 1) cout << 1 << endl;
    else cout << min << endl;
}

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

int main() {
	string s;
	cin >> s;
	int a = 0;
	

	if (s[0] == '1') { a++; }
	if (s[1] == '1') { a++; }
	if (s[2] == '1') { a++; }
	cout << a<< endl;
	return 0;
}

Measured memory_bytes: 256
/**
*    created: 03.05.2020 21:03:20
**/

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

int main() {
    int n ,k;
    cin >> n>>k;
    int d[k];
    //vector<vector<int>> a;
    set<int> s;
    rep(i,k){
        cin >> d[i];
        rep(j,d[i]){
            int b;
            cin >> b;
            s.insert(b);
            //a[i].push_back(b);
          //  cout << d[i] << endl;
        }
    }
    cout << n-s.size() << endl;

}

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

using namespace std;

int main() {
    int n;
    long long v = 1;
    long long divisor = 1000000000LL + 7;

    cin >> n;

    for (int i = 0; i < n; i++) {
        v = (v * (i+1)) % divisor;
    }

    cout << v << endl;

    return 0;
}


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

typedef pair<int,int> P;

int dp[1001][1001];
int s[1001][1001];
int dx[2] = {0,1};
int dy[2] = {1,0};

P solve(int w, int h, int n){
	// 初期化
	for(int y=0 ; y < h ; y++ ){
		for(int x=0 ; x < w ; x++ ){
			dp[y][x] = 0;
		}
	}
	
	dp[0][0] = n;
	for(int y=0 ; y < h ; y++ ){
		for(int x=0 ; x < w ; x++ ){
			// a := (x,y) の通る回数, b := 通った回数が偶数か奇数か.
			int a = dp[y][x];
			int b = a % 2;
			
			// (x1,y1) はもともと書かれた数値に進んだ時の座標
			// (x2,y2) は書かれた数値を反転した時に進んだ時の座標
			int x1 = x + dx[s[y][x]];
			int y1 = y + dy[s[y][x]];
			int x2 = x + dx[s[y][x]^1];
			int y2 = y + dy[s[y][x]^1];
			if( x1 < w && y1 < h )
				dp[y1][x1] += (a+b) / 2;
			if( x2 < w && y2 < h )
				dp[y2][x2] += (a-b) / 2;
		}
	}
	for(int y=0 ; y < h ; y++ ){
		for(int x=0 ; x < w ; x++ ){
			s[y][x] ^= dp[y][x] % 2;
		}
	}
	
	// シミュレーションで n 回目の散歩の終了時の位置を求める.
	int x=0, y=0;
	while( x < w && y < h ){
		if( s[y][x] ) x += 1;
		else y += 1;
	}
	return P(x,y);
}

int main(){
	int w, h, n;
	while( cin >> h >> w >> n , h || w || n ){
		for(int y=0 ; y < h ; y++ ){
			for(int x=0 ; x < w ; x++ ){
				cin >> s[y][x];
			}
		}
		P p = solve(w,h,n-1);
		cout << p.second+1 << " " << p.first+1 << endl;
	}
}

Measured memory_bytes: 8984
#include<bits/stdc++.h>
using namespace std;
#define mp make_pair
#define pb push_back
#define emb emplace_back
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL);
#define N  99999
#define f first 
#define em emplace
#define s second
using lint=long long int;

typedef pair<int, int> pii;
typedef pair<double, double> pdd;
typedef vector<double> vd;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<string> vs;

 
#define fori(n) for(int i=0; i<int(n); i++)
 
#define cins(s) string s; cin>>s;
#define cini(i) lint i; cin>>i;
#define cind(d) double d; cin>>d;
#define cinai(a, n) vi a(n); fori(n) { cin>>a[i]; }
#define cinas(s, n) vs s(n); fori(n) { cin>>s[i]; }
#define cinad(a, n) vd a(n); fori(n) { cin>>a[i]; }
#define z 1000000007 


void solve(){
  
  cini(n);
  vector<int>dp(3);
  for(int i=0;i<3;i++) cin>>dp[i];

  for(int i=1;i<n;i++){
     vector<int>v(3);

     for(int j=0;j<3;j++){
           cin>>v[j];
            int m=0;
           for(int k=0;k<3;k++){

              if(j!=k){
                m=max(dp[k],m);
              }
           }
           v[j]+=m;
     }
    dp.clear();
    v.swap(dp);
  }
     
     int a=*max_element(dp.begin(),dp.end());
     cout<<a<<endl;




}
 
 
int main()
{ 
  fast;

  



  solve();
 }

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define INF 1000000000000000
#define MOD 1000000007

int main(){
  ll N,K;
  cin>>N>>K;
  vector<ll> plus,minus;
  bool zero=false;
  for(int i=0;i<N;i++){
    ll A;
    cin>>A;
    if(A>0){
      plus.push_back(A);
    }else if(A<0){
      minus.push_back(A);
    }else{
      zero=true;
    }
  }
  ll n=plus.size();
  ll m=minus.size();

  if(K<=n*m){
    sort(plus.begin(),plus.end());
    sort(minus.begin(),minus.end());
    ll left=-1000000000000000000;
    ll right=0;
    while(left+1<right){
      ll x=(left+right)/2;
      ll i=0;
      ll j=0;
      ll count=0;
      while(i<n){
        if(j<m){
          while(plus.at(i)*minus.at(j)<=x){
            j++;
            if(j>=m){
              break;
            }
          }
        }
        count+=j;
        i++;
      }
      if(count>=K){
        right=x;
      }else{
        left=x;
      }
    }
    cout<<right<<endl;
  }else if(n*m<K&&K<=n*m+(N-n-m)*(n+m)+(N-n-m)*(N-n-m-1)/2){
    cout<<0<<endl;
  }else{
    K-=n*m+(N-n-m)*(n+m)+(N-n-m)*(N-n-m-1)/2;
    sort(plus.begin(),plus.end());
    sort(minus.begin(),minus.end());
    reverse(minus.begin(),minus.end());
    ll left=0;
    ll right=1000000000000000000;
    while(left+1<right){
      ll x=(left+right)/2;
      ll count=0;
      ll i=0;
      ll j=n-1;
      while(i<n){
        if(j<0){
          break;
        }
        while(plus.at(i)*plus.at(j)>x){
          j--;
          if(j<0){
            break;
          }
        }
        count+=j+1;
        i++;
      }
      i=0;
      j=m-1;
      while(i<m){
        if(j<0){
          break;
        }
        while(minus.at(i)*minus.at(j)>x){
          j--;
          if(j<0){
            break;
          }
        }
        count+=j+1;
        i++;
      }

      for(int i=0;i<n;i++){
        if(plus.at(i)*plus.at(i)<=x){
          count--;
        }
      }
      for(int i=0;i<m;i++){
        if(minus.at(i)*minus.at(i)<=x){
          count--;
        }
      }
      count=count/2;
      if(count>=K){
        right=x;
      }else{
        left=x;
      }
    }
    cout<<right<<endl;
  }
}


Measured memory_bytes: 2420
#include<bits/stdc++.h>
#define ALL(a)  (a).begin(),(a).end()
using namespace std;

int main(){
	int n;
	cin >> n;
	long long sum = 0;
vector<long long> A(n);
vector<long long> B(n);
vector<long long> C(n);
	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++){
     cin >> C[i];
		}


		sort(A.begin(),A.end());
		sort(C.begin(),C.end());
long long  upper,lower;

for(int i = 0;i < n;i++){
	//cout <<A.end() - upper_bound(ALL(A), B[i])<<endl;
 upper = C.end() - upper_bound(ALL(C), B[i]);
 lower = lower_bound(ALL(A), B[i]) - A.begin();

 sum += upper*lower;
 //cout << upper*lower <<endl;
 //cout << i <<endl;
	}

	cout << sum << endl;
	}

Measured memory_bytes: 2688
#!/usr/bin/env python3
import itertools
s = int(input())
used = set()
for i in itertools.count():
    used.add(s)
    if s % 2 == 0:
        s /= 2
    else:
        s = s * 3 + 1
    if s in used:
        break
print(i + 2)


Measured memory_bytes: 3060
/*
Dont BLUNDER
*/
#include<bits/stdc++.h>
using namespace std;
/*#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;


 */
#define d long double
#define int long long
#define pii pair<int,int>
#define pb push_back
#define endl '\n'
#define pi acos(-1)

#define init(x,a) memset(x,a,sizeof(x))
#define all(c) c.begin(),c.end()
int const mod1 = 998244353;
int const mod = 1000000007;
#define l first
#define r second
int toint(const string &s) {stringstream ss; ss << s; int x; ss >> x; return x;}
string tostring ( int number ) {stringstream ss; ss << number; return ss.str();}
#define out(x) cout<<#x<<" = "<<" "<<x<<"\n";
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define haha ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
// * Using PBDS *
/*typedef tree<int, null_type, less<int>, rb_tree_tag,
            tree_order_statistics_node_update>
               os; */



int modexp(int x, int n) {
	if (n == 0) {
		return 1;
	}
	else if (n & 1) {
		return (modexp((x * x) % mod, n / 2) % mod * x % mod) % mod;
	}
	else {
		return (modexp((x * x) % mod, n / 2) % mod);
	}
}

int modinv(int n)
{
	return modexp(n, mod - 2);
}

int gcd(int a, int b) {
	if (b == 0) {
		return a;
	}
	return gcd(b, a % b);
}
bool comp(pii a, pii b) {
	return a.second < b.second;

}



signed main()
{
	haha
// #ifndef ONLINE_JUDGE

// 	freopen("inp.txt", "r", stdin);

// 	freopen("out1.txt", "w", stdout);
// #endif
	int n, x, t;
	cin >> n >> x >> t;
	cout << ((n + x - 1) / x)*t;




















}

Measured memory_bytes: 3612
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repi(i, s, n) for (int i = (s); i < (n); i++)
#ifdef LOCAL
#define INPUT_FILE                    \
  ifstream in("abc042/abc042_a.txt"); \
  cin.rdbuf(in.rdbuf());
#else
#define INPUT_FILE
#endif
#define CIN_OPTIMIZE \
  cin.tie(0);        \
  ios::sync_with_stdio(false);
typedef pair<int, int> P;
typedef long long ll;
const int INF = 100100100;
const ll LINF = 1e18 + 100;
const int MOD = 1e9 + 7;

int main() {
  INPUT_FILE CIN_OPTIMIZE;

  vector<int> c(3);
  rep(i, 3) { cin >> c[i]; }
  sort(c.begin(), c.end());
  string ans = "NO";
  if (c[0] == 5 && c[1] == 5 && c[2] == 7) ans = "YES";

  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <climits>
#include <cstring>
using namespace std;
typedef long long int ll;
const ll inf = 1000000000000;
ll dp[3010][3010];
ll dp2[3010][3010];
ll dp3[3010][3010];
bool dp4[3010][3010];
char s[3010];
char t[3010];

int main(){
    scanf(" %s",s+1);
    scanf(" %s",t+1);
    int slen = strlen(s+1);
    int tlen = strlen(t+1);
    for(int i = 1; i <= slen; i++){
        for(int j = 1; j <= tlen; j++){
            if(s[i] == t[j]){
                dp[i][j] = dp[i-1][j-1] + 1;
                dp2[i][j] = i-1;
                dp3[i][j] = j-1;
                dp4[i][j] = true;
            }
            else{
                if(dp[i-1][j] >= dp[i][j-1]){
                    dp[i][j] = dp[i-1][j];
                    dp2[i][j] = i - 1;
                    dp3[i][j] = j;
                }
                else{
                    dp[i][j] = dp[i][j-1];
                    dp2[i][j] = i;
                    dp3[i][j] = j-1;
                }
                //dp[i][j] = max(dp[i-1][j],dp[i][j-1]);
            }
        }
    }
    ll i = slen;
    ll j = tlen;
    string ans = "";
    while(true){
//        cerr << i << "," << j << endl;
        if(i == 0 || j == 0)    break;
        if(dp4[i][j]){
            ans = s[i] + ans;
            //cerr << s[i] << endl;
        }
        ll ni = dp2[i][j];
        ll nj = dp3[i][j];
        i = ni;
        j = nj;
    }
    printf("%s\n",ans.c_str());


}


Measured memory_bytes: 221440
#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>
#include<tuple>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;


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

	ll N, M;
	cin >> N >> M;
	if (2 * N >= M) {
		cout << M / 2 << "\n";
		return 0;
	}
	ll res = N;
	M -= 2 * N;
	res += M / 4;
	cout << res << "\n";

	return 0;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
	"math"
)

func main() {
	var s []byte
	fmt.Scan(&s)


	stmp := make([]byte, len(s))
	_ = copy(stmp,s)
	cnt := 0
	for i := 1; i < len(stmp); i++ {
		if stmp[i] == stmp[i-1] {
			if stmp[i] == '1' {
				stmp[i] = '0'
				cnt++
				continue
			}
			if stmp[i] == '0' {
				stmp[i] = '1'
				cnt++
				continue
			}
		}
	}

	if s[0] == '1' {
		s[0] = '0'
	}  else {
		s[0] = '1'
	}
	cnt2 := 1

	for i := 1; i < len(s); i++ {
		if s[i] == s[i-1] {
			if s[i] == '1' {
				s[i] = '0'
				cnt2++
				continue
			}
			if s[i] == '0' {
				s[i] = '1'
				cnt2++
				continue
			}
		}
	}
	fmt.Println(min(cnt, cnt2))
}
func min(nums ...int) int {
	if len(nums) == 0 {
		panic("funciton min() requires at least one argument.")
	}
	res := nums[0]
	for i := 0; i < len(nums); i++ {
		res = int(math.Min(float64(res), float64(nums[i])))
	}
	return res
}


Measured memory_bytes: 2720
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define erep(i, n) for (ll i = 0; i <= (ll)(n); ++i)
#define FOR(i,a,b) for (ll i = (a); i < (ll)(b); ++i)
#define EFOR(i,a,b) for (ll i = (a); i <= (ll)(b); ++i)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } }

#include <iostream>
#include <vector>
#include <queue>
using namespace std;
using Graph = vector<vector<int>>;
using P = pair<int, int>;

int main() {
    long double a,b,c; cin >> a >> b >> c;

    long double eps = 1e-14;


    // 249999999 250000000 999999998
    if(sqrt(a) + sqrt(b) + eps < sqrt(c)) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
//
//    if(sqrt(a) + sqrt(b) < sqrt(c) + eps) {
//        cout << "Yes" << endl;
//    } else {
//        cout << "No" << endl;
//    }


//    if(sqrt(a) + sqrt(b) < sqrt(c)) {
//        cout << "Yes" << endl;
//    } else {
//        cout << "No" << endl;
//    }

    return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python3
n,m,k = map(int,input().split())
for i in range(0,m+1):
    for j in range(0,n+1):
        if n*i+m*j - 2*i*j == k:
            #print(i,j)
            print("Yes")
            exit()
print("No")

Measured memory_bytes: 38896
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for(int i=0;i<(int)n;i++)
struct edge{int from, to;};

int main(){
    int n,l;
    cin>>n >>l;
    vector<string> s;
    rep(i,n){
        string m;
        cin>>m;
        s.push_back(m);
    }
    sort(s.begin(), s.end());
    rep(i,n) cout<<s[i];

    return 0;
}

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

using namespace std;
int main(void) {
	int H, W;
	int h, w;
	int a;

	cin >> H >> W;
	cin >> h >> w;

	a = (H-h)*(W-w);

	cout << a;

	return 0;
}

Measured memory_bytes: 256
#d
def main():
    s=input()
    n=len(s)
    mod=10**9+7
    
    if s[-1]=="?":
        dp=[1,1,1,1,1,1,1,1,1,1,0,0,0]
    else:
        dp=[0]*13
        dp[int(s[-1])]=1
    
    for i in range(1,n):
        imod=10**(i %12)
        ss0=s[n-i-1]
        if ss0!="?":
            dpnew = [ dp[(j-int(ss0)*imod)%13] %mod for j in range(13)]
        else:
            dpnew = [sum( dp[(j-k*imod)%13] for k in range(10)) %mod for j in range(13) ]
        dp=dpnew[:]
    print(dp[5])
    
if __name__ == '__main__':
    main()

Measured memory_bytes: 48236
//Code by Anshuman Das Gupta

#include<bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define int long long
#define MOD 1000000007
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define loop(I,N) for(int i=I;i<N;i++)
#define sortvec(V) sort(V.begin(),V.end())
#define vec vector<int>
#define endl "\n"
using namespace std;
int fast_power(int base, int power) {
    int result = 1;
    while (power > 0) {

        if (power & 1 == 1) {
            result = (result * base) % MOD;
        }
        base = (base * base) % MOD;
        power = power >> 1;
    }
    return result % MOD;
}

bool isPrime(int x) {
    for (int i = 2; i <= sqrt(x); i++) {
        if (x % i == 0)
            return false;
    }
    if (x == 1)
        return false;
    return true;
}

int binsearch(int a[], int f, int r, int x) {
    while (f <= r) {
        int mid = (f + r) / 2;
        if (a[mid] == x)
            return mid;
        else if (a[mid] > x) {
            r = mid - 1;
        }
        else {
            f = mid + 1;
        }
    }
    return -1;
}
void sieve(int a[], int n) {
    a[0] = 0;
    a[1] = 0;
    for (int i = 2; i <= n; i++) {
        if (a[i] == 1) {
            for (int j = i + i; j <= n; j += i) {
                a[j] = 0;
            }
        }
    }
}
int32_t main() {
#ifndef ONLINE_JUDGE
    //for getting input from input.txt
    freopen("input.txt", "r", stdin);
    //for writing output to output.txt
    freopen("out.txt", "w", stdout);
#endif
    int t = 1;
    //cin >> t;
    while (t--) {
        int a, b, c, k;
        cin >> a >> b >> c >> k;
        int ans = 0;
        if (k > 0) {
            ans += min(k, a);
            k -= min(k, a);
        }
        if (k > 0) {
            k -= min(k, b);
        }
        if (k > 0) {
            ans -= min(k, c);
        }
        cout << ans << endl;
    }
    return 0;
}


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

using namespace std;
typedef long long ll;
#define tr(container, it) \
	for (auto it = container.begin(); it != container.end(); it++)
#define scontains(c,x) ((c).find(x) != (c).end())   //O(log n) 
#define contains(c,x) (find((c).begin(),(c).end(),x) != (c).end()) //O(n)
#define Ichar(_x) char _x;scanf("%c",&_x);
#define Iint(_x) int _x;scanf("%d",&_x); 
#define Ill(_x)  ll _x;scanf("%lld",&_x);
#define inc(a,b,x)(x)>a && (x)<b	
#define incE(a,b,x)(x)>=a && (x)<=b	
#define fileio freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
const double pi = 3.14159265358979323846;

template<typename T>
long long C(T n, T r) {
	if (n < 0 || r < 0)return 0;
	if (r > n / 2) r = n - r;
	long long ans = 1;
	for (T i = 1; i <= r; ++i) {
		ans *= n - r + i;
		ans /= i;
	}

	return ans;
}


int a[200000];
int b[200000];
int main()
{
	Ill(n);
	for (int i = 0; i < n; ++i)
	{
		scanf("%d", &a[i]);
	}
	for (int i = 0; i < n; ++i)
	{
		b[i] = a[i];
	}
	sort(a, a + n);
	ll t = a[n / 2];
	ll tt = a[n / 2 - 1];
	for (int i = 0; i < n; ++i)
	{
		if (b[i]<t)std::cout << t << "\n";
		else { std::cout << tt << "\n"; }
	}

}

Measured memory_bytes: 3712
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <iomanip>
using namespace std;
//typedef __int64 LL;
//typedef long long int LL;
typedef pair<int,int> P;
//typedef pair<LL,LL> PL;

const int MOD=1000000007;
int d[200010],t[200010];
map<int,int>mpd,mpt;
int main()
{
	string ans="YES";
	int n,m;
	cin>>n;
	for(int i=0;i<n;i++)
	{
		cin>>d[i];
		mpd[d[i]]++;
	}
	cin>>m;
	for(int i=0;i<m;i++)
	{
		cin>>t[i];
		mpt[t[i]]++;
	}
	
	for(int i=0;i<m;i++)
	{
		int x=t[i];
		if(mpd[x]<mpt[x]){ans="NO";break;}
	}
	cout<<ans<<"\n";
	return 0;
}

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

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define P pair<int,int>

//nが固定値でないとき
const int MOD = 1e9 + 7;
 
vector<long long> fact_inv, inv;
 
/*  init_nCk :二項係数のための前処理
    計算量:O(k)
*/
void init_nCk(int SIZE) {
    fact_inv.resize(SIZE + 5);
    inv.resize(SIZE + 5);
    fact_inv[0] = fact_inv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < SIZE + 5; i++) {
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        fact_inv[i] = fact_inv[i - 1] * inv[i] % MOD;
    }
}
 
/*  nCk :MODでの二項係数を求める(前処理 int_nCk が必要)
    計算量:O(k)
*/
long long nCk(int n, int k) {
    assert(!(n < k));
    assert(!(n < 0 || k < 0));
    long long ans = 1;
    for (int i = n; i >= n - k + 1; i--) {
        ans *= i;
        ans %= MOD;
    }
    return ans * fact_inv[k] % MOD;
}

int main(){
  init_nCk(2000);
  int s;
  cin>>s;
  if(s==1||s==2){
    cout<<0<<endl; return 0;
  }
  ll ans=0;
  for(int i=1; i*3<=s; i++){
    int k=s-i*3;
    ans+=nCk(k+i-1,i-1);
    ans%=MOD;
  }
  cout<<ans<<endl;
}

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

//#define int long long
//#define endl "\n"
#define m_p make_pair
#define mod 1000000007
#define all(v)  v.begin(),v.end()
#define rep(i,n)  for(int i=0; i<(int) (n); i++)
#define all(v)  v.begin(),v.end()
#define vecin(v) for(int i=0; i<(int)v.size(); i++)cin>>v[i];
using namespace std;

int jousu(int, int);
int jousu(int x00, int y00) {
	int z00 = 1;
	for (int i = 0; i < y00; i++) {
		z00 *= x00;
	}
	return z00;
}
int keta(int x00) {
	int z00 = x00;
	int w00 = 0;
	while (z00 != 0) {
		z00 /= 10;
		w00++;
	}
	return w00;
}




int main() {
	int r;
	cin >> r;
	cout << r * r * 3 << endl;
}



Measured memory_bytes: 256
#include <iostream>
#include <cstdlib>
#include <cstdio>

using namespace std;

const int MAXN = 200005;
const int MAXLOG = 20;

int n;
int a[MAXN];

int table[MAXLOG][MAXN];
int logs[MAXN];

void computeLogs() {
  for (int i = 2; i <= n; i++) {
    logs[i] = logs[i / 2] + 1;
  }
}

void buildSparseTable() {
  for (int i = 0; i <= logs[n]; i++) {
    int curLen = 1 << i;
    for (int j = 0; j + curLen <= n; j++) {
      if (curLen == 1) {
        table[i][j] = a[j];
      } else {
        table[i][j] = max(table[i - 1][j], table[i - 1][j + (curLen / 2)]);
      }
    }
  }
}

int getMin(int l, int r) {
  int p = logs[r - l + 1];
  int pLen = 1 << p;
  return max(table[p][l], table[p][r - pLen + 1]);
}

int main() {

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

  computeLogs();
  buildSparseTable();

  for(int i=0;i<n;i++){
      if(i==0)
        cout<<getMin(i+1,n-1)<<endl;

      else if(i==n-1)
        cout<<getMin(0,n-2)<<endl;

      else{
          int mx=getMin(0,i-1);
          mx=max(mx,getMin(i+1,n-1));
          cout<<mx<<endl;
      }
  }

  return 0;
}


Measured memory_bytes: 18816
"use strict";
function main(input) {
    const line = input.split("\n");
    const S = line[0];
    const T = line[1];
    if (S === T.slice(0, -1)) {
        console.log("Yes");
    } else {
        console.log("No");
    }
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));


Measured memory_bytes: 29612
#include <bits/stdc++.h>
#define ll long long
#define INF LLONG_MAX 
#define dd double 
#define fi first
#define se second
#define rep(i,a,b) for(ll i=a;i<=b;i++)
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key
#define dll deque<long long>
#define qll queue<long long>
#define vll vector<long long>
#define vc vector<char>
#define vs vector<string>
#define vvll vector<vector<ll>>
#define vpll vector<pair<long long,long long>>
#define vpcl vector<pair<char,long long>>
#define vpsl vector<pair<string,long long>>
#define stll stack<long long>
#define stc stack<char>
#define mll map<long long,long long>
#define pll pair<long long,long long>
#define psl pair<string,long long>
#define mcl map<char,long long>
#define msl map<string,long long>
#define pcl pair<char,long long>
#define mmll multimap<long long,long long> 
#define mmcl multimap<char,long long>
#define mmsl multimap<string,long long>
#define sll set<long long>
#define sc  set<char>
#define ss  set<string>
#define msll multiset<long long>
#define msc  multiset<char>
#define mss  multiset<string>
#define lb lower_bound
#define up upper_bound
#define lt length
#define clr clear
#define ap append
#define sz size
#define sub substr
#define ull unsigned long long int
using namespace std;
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
//#include <boost/multiprecision/cpp_int.hpp> 
//using boost::multiprecision::cpp_int; 
using namespace __gnu_pbds; 
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>

// ll c;
// ll arr[21][22];
// ll dp[201][22];

// ll f(ll m,ll x){
//     if(m<0){return -1000000000000000;}
//     if(m==0){
//         if(x==c){return 0;}
//         else{return -1000000000000000;}
//     }
//     if(x==c){return 0;}
//     if(dp[m][x]!=-1){return dp[m][x];}
//     ll ans = -1;
//     ll k = arr[x][0];
//     rep(i,1,k){
//         ans = max(ans,arr[x][i]+f(m-arr[x][i],x+1));
//     }
//     if(ans==-1){ans = -1000000000000000;}
//     dp[m][x] = ans;
//     return ans;
// }

int main() {
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);
    ll h,w; cin>>h>>w;
    ll m = 1000000007;
    string arr[h];
    rep(i,0,h-1){cin>>arr[i];}
    ll dp[h][w];
    //  rep(i,0,h-1){
    //     rep(j,0,w-1){
    //         cout<<arr[i][j]<<" ";
    //     }
    //     cout<<"\n";
    //  }
    rep(i,0,h-1){
        rep(j,0,w-1){
            if(arr[i][j]=='#'){dp[i][j]=0;}
            else{dp[i][j]=-1;}
        }
    }
    // rep(i,0,h-1){
    //     rep(j,0,w-1){
    //         cout<<dp[i][j]<<" ";
    //     }
    //     cout<<"\n";
    //  }
    rep(i,0,h-1){
        rep(j,0,w-1){
            if(dp[i][j]!=0){
            if(i==0 && j==0){dp[i][j]=1; continue;}
            if(i==0){dp[i][j] = dp[i][j-1]; continue;}
            if(j==0){dp[i][j] = dp[i-1][j]; continue;}
            dp[i][j] = (dp[i-1][j]%m + dp[i][j-1]%m)%m;}
        }
    }
    // rep(i,0,h-1){
    //     rep(j,0,w-1){
    //         cout<<dp[i][j]<<" ";
    //     }
    //     cout<<"\n";
    //  }
    cout<<dp[h-1][w-1];
}


Measured memory_bytes: 9088
h = []
w = []
while True:
    a,b = map(int, raw_input().split())
    h.append(a)
    w.append(b) 
    if a == 0 and b == 0:
        break

for h,w in zip(h,w):    
    if h == 0 and w == 0:
        break;
    else:
	c = "#"
	d = "."
        for x in xrange(1,w):
	    if x%2 == 1:
                c = c + "."
	        d = d + "#"
	    else:
	        c = c + "#"
	        d = d + "."

        for x in xrange(1,h+1) :
	    if x%2 == 1: 
		print c
	    else:
		print d
    print 

Measured memory_bytes: 6348
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<algorithm>
#include<cmath>
#include<climits>
#include<string>
#include<set>
#include<numeric>
#include<map>
#include<iostream>
using namespace std;
#define rep(i,n) for(int i = 0;i<((int)(n));i++)
#define reg(i,a,b) for(int i = ((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i = ((int)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(int i = ((int)(b));i>=((int)(a));i--)
typedef long long ll;
typedef pair<ll, ll> mp;

//完成した
//未検証

int main(void){
	ll N,K,x[52],y[52],rx[52],ry[52],ans=LLONG_MAX;
	scanf("%lld%lld",&N,&K);
	rep(i,N){
		scanf("%lld%lld",&x[i],&y[i]);
		rx[i]=x[i];
		ry[i]=y[i];
	}
	sort(x,x+N);
	sort(y,y+N);
	rep(x1,N){//右
		reg(x2,0,x1){//左
			rep(y1,N){
				reg(y2,0,y1){
					int cnt=0;
					rep(i,N){
						if(x[x2]<=rx[i] && rx[i]<=x[x1] && y[y2]<=ry[i] && ry[i]<=y[y1])cnt++;
					}
					if(cnt>=K && ans>(x[x1]-x[x2])*(y[y1]-y[y2]))ans=(x[x1]-x[x2])*(y[y1]-y[y2]);
				}
			}
		}
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) (x).begin(),(x).end()
#define uniq(x) (x).erase(unique(ALL(x)),(x).end())
#define SORT(x) sort(ALL(x))
#define REV(x) reverse(ALL(x))
#define foreach(it,x) for(__typeof((x).begin()) it=(x).begin();it!=(x).end();it++)
#define debug(x) cerr<<#x<<"="<<(x)<<endl
#define gett() cerr<<"Time:"<<clock()<<"ms."<<endl
int dist[100100];
int n,m,s,t;
vector<int> ga[100100];
queue<int> q;
int u,v;
bool vis[100100];
void dfs(int u){
	vis[u]=1;
	for(int i=0;i<ga[u].size();i++)
		if(!vis[ga[u][i]])
			dfs(ga[u][i]);
}
int main(){
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cin>>n>>m;
	for(int i=1;i<=m;i++)
	{
		cin>>u>>v;
		ga[u].push_back(v);
	}
	cin>>s>>t;
	memset(dist,63,sizeof(dist));
	dfs(s);
	if(!vis[t]){
		cout<<-1<<endl;
		return 0;
	}
	q.push(s);
	dist[s]=0;
	while(q.size()){
		int u=q.front();
		q.pop();
		for(int i=0;i<ga[u].size();i++){
			int v=ga[u][i];
			for(int j=0;j<ga[v].size();j++){
				int w=ga[v][j];
				for(int k=0;k<ga[w].size();k++){
					int x=ga[w][k];
					if(dist[x]>=1e9){
						if(x==t){
							cout<<dist[u]+1<<endl;
							return 0;
						}
						dist[x]=dist[u]+1;
						q.push(x);
					}
				}
			}
		}
	}
	cout<<-1<<endl;
	return 0;
}


Measured memory_bytes: 9344