akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
 
int main(int argc, const char * argv[]) {
     
    int n,m;
    scanf("%d %d",&n,&m);
     
    int matrixA[n][m];
    int matrixB[m];
     
    int i,j;
    for(i=0;i<n;i++){
        for(j=0;j<m;j++){
            scanf("%d",&matrixA[i][j]);
        }
    }
     
    for(i=0;i<m;i++){
        scanf("%d",&matrixB[i]);
    }
     
    for(i=0;i<n;i++){
        int sum = 0;
        for(j=0;j<m;j++){
            sum+= matrixA[i][j] * matrixB[j];
        }
        printf("%d\n",sum);
    }
     
    return 0;
}


Measured memory_bytes: 2044
#include <bits/stdc++.h>
using namespace std;
#define ri register int
namespace io {
	const int SIZE = (1 << 21) + 1;
	char ibuf[SIZE], *iS, *iT, obuf[SIZE], *oS = obuf, *oT = oS + SIZE - 1, c, qu[55]; int f, qr;
	// getchar
	#define gc() (iS == iT ? (iT = (iS = ibuf) + fread (ibuf, 1, SIZE, stdin), (iS == iT ? EOF : *iS ++)) : *iS ++)
	// print the remaining part
	inline void flush () {
		fwrite (obuf, 1, oS - obuf, stdout);
		oS = obuf;
	}
	// putchar
	inline void putc (char x) {
		*oS ++ = x;
		if (oS == oT) flush ();
	}
	// input a signed integer
	template <class I>
	inline void gi (I &x) {
		for (f = 1, c = gc(); c < '0' || c > '9'; c = gc()) if (c == '-') f = -1;
		for (x = 0; c <= '9' && c >= '0'; c = gc()) x = (x << 1) + (x << 3) + (c & 15); x *= f;
	}
	// print a signed integer
	template <class I>
	inline void print (I x) {
		if (!x) putc ('0'); if (x < 0) putc ('-'), x = -x;
		while (x) qu[++ qr] = x % 10 + '0',  x /= 10;
		while (qr) putc (qu[qr --]);
	}
	// no need to call flush at the end manually!
	struct Flusher_ {~Flusher_(){flush();}}io_flusher_;
} 
using io :: gi;
using io :: putc;
using io :: print;
const int N=1e5+5;
int n,p[N],q[N];
struct node{
	int a[N];
	inline node operator *(const node &rhs)const{
		node ans;
		for(ri i=1;i<=n;++i) ans.a[i]=a[rhs.a[i]];
		return ans;
	}
};
inline node inv(node p){
	node ans;
	for(ri i=1;i<=n;++i)
		ans.a[p.a[i]]=i;
	return ans;
}
inline node fpow(node a,ri b){
	node ans;
	for(ri i=1;i<=n;++i) ans.a[i]=i;
	for(;b;b>>=1,a=a*a)
		if(b&1)
			ans=ans*a;
	return ans;
}
int main(){
	ri k,i,f,g;
	node p,q,invp,invq,A,B,invA,ans; 
	gi(n);gi(k);
	for(i=1;i<=n;++i) gi(p.a[i]);
	for(i=1;i<=n;++i) gi(q.a[i]);
	invp=inv(p);
	invq=inv(q);
	f=(k-1)/6;
	g=k-f*6;
	A=q*invp*invq*p;
	if(g==1){
		B=p;
	}
	else if(g==2){
		B=q;
	}
	else if(g==3){
		B=q*invp;
	}
	else if(g==4){
		B=q*invp*invq;
	}
	else if(g==5){
		B=A*invq;
	}
	else if(g==6){
		B=A*p*invq;
	}
	invA=inv(A);
	ans=fpow(A,f)*B*fpow(invA,f); 
	for(i=1;i<=n;++i) print(ans.a[i]),putc(' ');
	putc('\n');
    return 0;
}

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

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;
}

int main()
{
    int n; cin >> n;
    vector< vector<ll> > a(n,vector<ll>(3));
    vector< vector<ll> > dp(n+1,vector<ll>(3,0));
    for( int i = 0; i < n; ++i )
    {
        cin >> a[i][0] >> a[i][1] >> a[i][2];
    }

    for( int i = 0; i < n; ++i )
    {
        for( int j = 0; j < 3; ++j )
        {
            for( int k = 0; k < 3; ++k )
            {
                if( j == k )
                {
                    continue;
                }
                chmax(dp[i+1][j],dp[i][k]+a[i][j]);
            }
        }
    }
    ll ans = 0;
    for( int i = 0; i < 3; ++i )
    {
        chmax(ans,dp[n][i]);
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 11136
import numpy as np
from sys import stdin
from copy import deepcopy
from functools import reduce
from fractions import gcd
import math
import itertools
from collections import Counter
from itertools import chain  ##list(chain.from_iterable(l)) ##flatten
from heapq import heappush, heappop

"""
N = int(input())
A, B = map(int,input().split())
A = list(map(int,input().split())) ## 横一列
A = [int(input()) for _ in range(N)] ## 縦一列
lst = [list(map(int,input().split())) for i in range(M)] ## 二次元
"""

N, K = map(int,input().split())
H = list(map(int,input().split()))

if len(H) <= K:
  print(0)
  exit()

H = sorted(H, reverse=True)
ans = sum(H[K:])

print(ans)

Measured memory_bytes: 35344
import java.security.KeyStore.TrustedCertificateEntry
import java.util
import java.util.{ArrayList, Collections, Comparator, List => JList}
import scala.math._

import scala.collection.mutable
import scala.collection.mutable.{ArrayBuffer, ListBuffer}
import scala.util.{Failure, Success, Try}

object Main{
  val LINE_SEPARATOR = "\n"
  def main(args: Array[String]): Unit = {
    if (sys.env.getOrElse("TEST", "")=="1"){
      println(test());
    }else{
      val input=io.Source.stdin.getLines().mkString(LINE_SEPARATOR);
      println(solve(input).trim());
    }
  }

  def init (nRows: Int, nCols: Int, default: Int) = Array.tabulate(nRows,nCols)( (x,y) =>  default)

  def sortIgnoreCase1(list: JList[String]): JList[String] = {
    val r = new ArrayList[String](list)
    Collections.sort(r, new Comparator[String] {
      override def compare(o1: String, o2: String): Int = o1.compareToIgnoreCase(o2)
    })
    r
  }

  def solve(input: String): String = {
    val n = input.toLong
    (1 to sqrt(n).toInt).toVector
      .filter(n % _ == 0)
      .map(a => max(a.toString.toSeq.size, (n/a).toString.toSeq.size))
      .min.toString
  }

  def divisors(n: Long): Vector[Long] = {
    val halfList = (1 to sqrt(n).toInt).toVector.filter(_ % n == 0).map(_.toLong)
    val reversedList = if (sqrt(n).floor == sqrt(n)) halfList.reverse.tail.map(n/_) else halfList.reverse.map(n/_)
    halfList ++ reversedList
  }

  def gcd(m: Long, n: Long): Long = n match {
    case 0 => m
    case _ => gcd(n, m % n)
  }
  def lcm(a: Long, b: Long): Long = a * b / gcd(a, b)

  val tests=List(
    """10000""".stripMargin -> """3
                                 |
                                  |
                                   |""".stripMargin,
    """1000003""".stripMargin -> """7
                                   |""".stripMargin,
    """9876543210""" -> "6"
  )

  def test():String= {
    return tests.map{case (i,o)=>(i.trim(),o.trim())}
      .zipWithIndex.map{
      case ((input,outputExpect),i)=>{
        val output=solve(input).trim();
        s"test${i+1}:"+(if(output==outputExpect){
          "Passed"
        }else{
          s"Failed\nexpect:\n${outputExpect}\noutput:\n${output}"
        })
      }}
      .mkString("\n");
  }
}

Measured memory_bytes: 29628
'use strict';
const fs = require('fs');
const mod = BigInt(1e9+7);

function sum(...a) {
  var s = 0;
  for (var x of a) s += x;
  return s;
}


class ABC041 {
  static A(input) {
    var s, i
    input = input.trim().split('\n');
    [s, i] = input;
    i = parseInt(i, 10);
    console.log(s[i-1]);
  }
  static B(input) {
    var a, b, c;
    input = input.trim().split(' ').map(BigInt);
    [a, b, c] = input;
    var ans = a * b % mod * c % mod;
    ans = Number(ans);
    console.log(ans);
  }
  static C(input) {
    var [n, height] = input.trim().split('\n');
    height = height.split(' ').map(n => parseInt(n, 10));
    n = parseInt(n, 10);
    var height = Object.keys(height).map(key => [parseInt(key, 10)+1, height[key]]);
    height.sort((a, b) => b[1]-a[1]);
    for (var [i, _] of height) {console.log(i);}
  }
  static D(input) {
    var lines = input.trim().split('\n');
    var [n, m] = lines[0].split(' ').map(x => +x);
    var edges = new Array(n).fill(0);
    for (var i = 0; i < m; i++) {
      var [x, y] = lines[1+i].split(' ').map(x => +x);
      edges[x-1] |= 1<<(y-1);
    }
    var comb = new Array(1<<n).fill(null); comb[0] = 1;
    function count(edges, bit) {
      if (comb[bit] != null) {return comb[bit];}
      comb[bit] = 0;
      for (var i = 0; i < n; i++) {
        if (bit>>i&1 && !edges[i]) {
          var nxt_bit = bit & ~(1<<i);
          var nxt_edges = edges.slice();
          for (var j = 0; j < n; j++) {
            nxt_edges[j] &= ~(1<<i);
          }
          comb[bit] += count(nxt_edges, nxt_bit);
        }
      }
      return comb[bit];
    }
    console.log(count(edges, (1<<n)-1));
  }
}

class ABC173 {
  static A(input) {
    var n = +input.trim();
    console.log(Math.floor((n+999)/1000)*1000 - n);
  }
  static B(input) {
    var lines = input.trim().split('\n');
    var n = +lines[0];
    var cnt = {
      'AC': 0,
      'WA': 0,
      'TLE': 0,
      'RE': 0
    }
    for (var i = 0; i < n; i++) {
      cnt[lines[1+i]]++;
    }
    for (var [verd, c] of Object.entries(cnt)) {
      console.log(`${verd} x ${c}`);
    }
  }
  static C(input) {
    var lines = input.trim().split('\n');
    var [h, w, k] = lines[0].split(' ').map(x => +x);
    var c = lines.slice(1);
    var tot = 0;
    for (var i = 0; i < (1<<h); i++) {
      for (var j = 0; j < (1<<w); j++) {
        var cnt = 0;
        for (var y = 0; y < h; y++) {
          if (i>>y&1) continue;
          for (var x = 0; x < w; x++) {
            cnt += c[y][x]=='#' && !(j>>x&1);
          }
        }
        tot += cnt == k;
      }
    }
    console.log(tot);
  }
  static D(input) {
    var lines = input.trim().split('\n');
    var n = +lines[0];
    var a = lines[1].split(' ').map(x => +x);
    a.sort((a, b) => b-a);
    var m = Math.floor((n-2)/2);
    var s = a[0] + sum(...a.slice(1, 1+m))*2 + (n&1)*a[1+m];
    console.log(s);
  }
  static E(input) {
  }
  static F(input) {
  }
}


var input = fs.readFileSync('/dev/stdin', 'utf8');
ABC173.D(input);

Measured memory_bytes: 59672
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rep2(j,n) for(int j = 0; j < (n); ++j)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define drep2(j,n) for(int j = (n)-1; j >= 0; --j)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define srep2(j,s,t) for (int j = s; j < t; ++j)
#define srep3(k,s,t) for (int k = s; k < t; ++k)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
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;
inline int in() { int x; scanf("%d",&x); return x;}
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;
#define dame { puts("-1"); return 0;}
#define yn {puts("YES");}else{puts("NO");}
  
class Combi {
  private:
    v(ll) fac, inv, finv;
   
    void init(ll N) {
      fac[0] = fac[1] = 1; inv[1] = 1; finv[0] = finv[1] = 1;
   
      for (ll i = 2; i < N; i++) {
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
      }
    }
   
  public:
    Combi(ll N) : fac(N + 1), inv(N + 1), finv(N + 1) { init(N + 1); }
   
    int Cmod(ll n, ll k) {
      if (n < k) return 0;
      if (n < 0 || k < 0) return 0;
      return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
    }
   
    ll Pmod(ll n, ll k) {
      if (n < k) return 0;
      if (n < 0 || k < 0) return 0;
      return fac[n] * finv[n - k] % MOD;
    }
  };

int main() {
  ll N,M,K;
  cin >> N >> M >> K;
  Combi c(N*M+3);
  ll x = c.Cmod(N*M-2,K-2);
  ll ans = 0;
  rep(i,M) {
    ans += (ll)(N * N) * (ll)((M-i) * i);
    ans %= MOD;
  }
  rep(i,N) {
    ans += (ll)(M * M) * (ll)((N-i) *i);
    ans %= MOD;
  }
  ans *= x;
  ans %= MOD;
  cout << ans << endl;
  return 0;
}

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

const long long INF = 1LL << 60; // これはなに？

template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}

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

	vector<long long> dp(100010); for(int i = 0; i < 100010; ++i) dp[i] = N;

	dp[0] = 0;
	for(int i = 1; i <= N; ++i) {
		for(int pow6 = 1; pow6 <= i; pow6 *= 6) {
			chmin(dp[i], dp[i - pow6] + 1); // 基準点と、基準点から6戻った点に(操作回数である)1を足すとよい
		}

		for(int pow9 = 1; pow9 <= i; pow9 *= 9) {
			chmin(dp[i], dp[i - pow9] + 1);
		}
	}

	cout << dp[N] << endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <cmath>
#include <vector>
#include <iomanip>
#include <cmath>
#include <algorithm>
#include <set>
#include <queue>
#include <map>
#include<stack>
#include<utility>
#include<cstring>
using namespace std;
#define ll long long
typedef vector<int> vi;
#define all(v) ((v).begin()),((v).end())
void fast()
{std::ios_base::sync_with_stdio(0);
	cin.tie(NULL);
	cout.tie(NULL);}
long long power(int n, int k){
    long long power=1;
    for(int i=0;i<k;i++){
        power*=n;
    }
    return power;
}
int gcd(int a, int b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
}
// freopen("input.txt" ,"r",stdin );
// freopen("output.txt","w",stdout);
int dp[100050];
int arr[100050]={0};
int main()
{
    fast();
    for(int i=0;i<100050;i++) arr[i]=1;
    int n,m,x,y; cin>>n>>m;
    	dp[1]=1;
    for(int i=0;i<m;i++){
    	cin>>x>>y;
    	arr[x]--; arr[y]++;
    	if(dp[x]==1 && arr[x]==0){ dp[x]=0; dp[y]=1;}
    	else if(dp[x]==1 && arr[x]!=0) dp[y]=1;
    }
    ll cnt=0;
    for(int i=0;i<=100000;i++){
    	if(dp[i]==1) cnt++;
    }
    cout<<cnt;
    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>
#include <bitset>
#include <queue>
#include <stack>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <utility>
#include <string>
#include <algorithm>
#include <cmath>
#include <limits>

using namespace std;
using ll=long long;
using vint=vector<int>;
using pint=pair<int,int>;

const double EPS = 1e-9;
const int infinity = numeric_limits<int>::max();

#define rep(i,n) for(int i=0;i<int(n);++i)
#define REP(i,a,b) for(int i=int(a);i<int(b);++i)
#define SHOW(a) cout << #a << " = " << a << endl
#define ARR(a,i,n) for(int i=0;i<int(n);++i) cout << #a << "[" << i << "]" << " = " << a[i] << endl

void solve(){
	int H, W;
	int n[4] = {infinity,infinity,infinity,infinity};
	cin >> H >> W;
	//横三分割
	if(H >= 3){
		if(H % 3){
			n[0] = W;
		}else{
			n[0] = 0;
		}
	}
	//縦三分割
	if(W >= 3){
		if(W % 3){
			n[1] = H;
		}else{
			n[1] = 0;
		}
	}

	//縦横
	if(W % 3 == 1){
		if(H % 2){
			n[2] = max(W / 3 * 2, W / 3 + H / 2) + 1;
		}else{
			n[2] = H / 2;
		}
	}else if(W % 3 == 2){
		if(H % 2){
			n[2] = max(W / 3 * 2, W / 3 + H / 2) + 1;
		}else{
			n[2] = H / 2;
		}
	}

	//縦横
	if(H % 3 == 1){
		if(W % 2){
			n[3] = max(H / 3 * 2, H / 3 + W / 2) + 1;
		}else{
			n[3] = W / 2;
		}
	}else if(H % 3 == 2){
		if(W % 2){
			n[3] = max(H / 3 * 2, H / 3 + W / 2) + 1;
		}else{
			n[3] = W / 2;
		}
	}

	cout << *min_element(n, n+4) << endl;
}

int main(){
	solve();
	return 0;
}

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

int main() {
	string a, b;
	cin >> a >> b;
	
	for (int i = 0; i < a.length(); i++) {
		if (a == b) {
			cout << "Yes" << endl;
			return 0;
		}
		char buff = a.back();
		a.pop_back();
		a = buff + a;
	}

	cout << "No" << endl;
}

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

int n, m, q;
vector<int> a, b, c, d;
int ans;

void dfs(vector<int> A) {
  if (A.size() == n+1) {
    int now = 0;
    rep(i,q) {
      if (A[b[i]] - A[a[i]] == c[i]) now += d[i];
    }
    ans = max(ans, now);
    return;
  }

  A.push_back(A.back());
  while (A.back() <= m) {
    dfs(A);
    A.back()++;
  }
}

int main() {
  cin >> n >> m >> q;
  a = b = c = d = vector<int>(q);
  rep(i,q) {
    cin >> a[i] >> b[i] >> c[i] >> d[i];
  }
  dfs(vector<int>(1,1));
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3632
//AOJ-GRL-1-A
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a) for(int i = 0; i < (a); i++)
#define ALL(a) (a).begin(),(a).end()
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const int MOD = 1e9 + 7;

#define MAX_V 100000

struct edge { int to, cost; };

int V;//頂点数
vector<edge> G[MAX_V];//辺の張り方 : G[from].push_back((edge){to, cost});
int dist[MAX_V];//頂点sからの最短距離

//始点sから各頂点への最短距離を求める
void dijkstra(int s){
    priority_queue<P, vector<P>, greater<P> > que;
    fill(dist, dist + V, INF);
    dist[s] = 0;
    que.push(P(0, s));
    
    while(!que.empty()){
        P p = que.top();
        que.pop();
        int v = p.second;
        if(dist[v] < p.first) continue;
        for(int i = 0; i < G[v].size(); i++){
            edge e = G[v][i];
            if(dist[e.to] > dist[v] + e.cost){
                dist[e.to] = dist[v] + e.cost;
                que.push(P(dist[e.to], e.to));
            }
        }
    }
}

signed main(){
    int E,r;
    cin >> V >> E >> r;
    int s,t,d;
    REP(i,E){
        cin >> s >> t >> d;
        G[s].push_back(edge{t, d});
    }
    dijkstra(r);
    REP(i,V){
        if(dist[i] == INF){
            cout << "INF" << endl;
        }else{
            cout << dist[i] << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 13168
#include <bits/stdc++.h>
#define ld double
#define ull unsigned long long
#define ll long long
#define pii pair <int, int>
#define iiii pair <int, pii >
#define mp make_pair
#define INF 1000000000
#define MOD 1000000007
#define rep(i, x) for(int (i) = 0; (i) < (x); (i)++)
inline int getint() {
	int x = 0, p = 1; 
	char c = getchar();	
	while (c <= 32) c = getchar();
	if (c == 45) p = -p, c = getchar();
	while (c > 32) x = x * 10 + c - 48, c = getchar();
	return x * p;
}
using namespace std;
//ruogu_alter
const int N = 3e5 + 5;
int n, a[N];
//
int main() {
	n = getint();
	rep(i, n) a[i] = getint() - 1;
	for (int i = 0, j; i < n; i = j + 1) {
		while (i < n && a[i] == i) ++i;
		if (i == n) break;
		int mn = a[i], mx = a[i]; j = i;
		while ((mn != i || mx != j) && j + 2 < n) {
			j += 2;
			mn = min(mn, a[j]);
			mx = max(mx, a[j]);
		}
		if (mn != i || mx != j) return !printf("No\n");
		for (int p = i + 1; p <= j; p += 2) if (a[p] != p) return !printf("No\n");
		for (int p = i; p <= j; p += 2) if (a[p] == p) return !printf("No\n");
		int premn = -1, premx = -1;
		for (int k = i; k <= j; k += 2) {
			if (a[k] < k) {
				if (a[k] < premn) return !printf("No\n");
				premn = a[k];
			}
			if (a[k] > k) {
				if (a[k] < premx) return !printf("No\n");
				premx = a[k];
			}
		}	
	}
	cout << "Yes\n";
	return 0;
}


Measured memory_bytes: 1408
#define _USE_MATH_DEFINES

#include <iostream>
#include <iomanip>
#include <stdio.h>

#include <sstream>
#include <algorithm>
#include <iterator>
#include <cmath>
#include <complex>

#include <string>
#include <cstring>
#include <vector>
#include <bitset>

#include <queue>
#include <set>
#include <map>
#include <stack>
#include <list>

#include <ctime>
////
//#include <random>//
/////////

typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;

////定数
const int INF = (int)1e9 + 10;
const LL MOD = (LL)1e9 + 7;
const LL LINF = (LL)4e18 + 20;
const LD PI = acos(-1.0);
const double EPS = 1e-9; 
/////////
using namespace::std;
template<typename T>
void chmax(T& a, T b) {
	a = max(a, b);
}

template<typename T>
void chmin(T& a, T b) {
	a = min(a, b);
}

template<typename T>
void IN(vector<T> &A,int N=-1) {
	if (N == -1) {
		N = A.size();
	}
	for (int i = 0; i < N; ++i) {
		cin >> A[i];
	}
}

template<typename T>
void SO(vector<T> &A,bool F=false) {
	sort(A.begin(), A.end());
	if (F) {
		reverse(A.begin(), A.end());
	}
}
//////////////
vector<LL> kai(200001);
vector<LL> kai_inv(200001);

LL powMod(LL num, LL n, LL mod = (LL)MOD) {//(num**n)%mod
	num %= mod;//
	if (n == 0) {
		return (LL)1;
	}
	LL mul = num;
	LL ans = (LL)1;
	while (n) {
		if (n & 1) {
			ans = (ans * mul) % mod;
		}
		mul = (mul * mul) % mod;
		n >>= 1;
	}
	return ans;
}
LL mod_inverse(LL num, LL mod = MOD) {
	return powMod(num, MOD - 2, MOD);
}

LL nCk(LL N, LL k, LL mod = MOD) {
	LL ans = 1;
	if (k == 0 || k == N) {
		return 1;
	}
	ans = (kai[N] * kai_inv[N - k]) % mod;
	ans = (ans * kai_inv[k]) % mod;
	return ans;
}

void solve() {
	kai[0] = 1; //kai_inv[0] = mod_inverse(1);
	kai[1] = 1; kai_inv[1] = mod_inverse(1);

	for (int i = 2; i <= 200000; ++i) {
		kai[i] = (kai[i - 1] * i) % MOD;
		kai_inv[i] = mod_inverse(kai[i]);
	}

	int N, M;
	cin >> N >> M;
	vector<bool> P(100000, true);
	vector<int> prime;
	for (int i = 2; i < 100000; ++i) {
		if (P[i]) {
			prime.push_back(i);
			for (int j = i + i; j < 100000; j += i) {
				P[j] = false;
			}
		}
	}
	int num = prime.size();
	int ter = M;
	map<int, int> A;
	for (int i = 0; i < num; ++i) {
		while (ter % prime[i] == 0) {
			A[prime[i]]++;
			ter /= prime[i];
		}
	}
	if (ter > 1) {
		A[ter] = 1;
	}
	LL ans = 1;
	for (auto v : A) {
		int cnt = v.second;
		ans *= nCk(N - 1 + cnt, cnt);
		ans %= MOD;
	}
	cout << ans << endl;
}

signed main(void) {
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	std::cout << std::fixed;//小数を10進数表示
	cout << setprecision(16);//小数点以下の桁数を指定//coutとcerrで別	

	solve();
}

Measured memory_bytes: 3456
#include<stdio.h>
#include<stdlib.h>
#include<stdint.h>

int main(void){
    register int i,j;
    int n,m;
    scanf("%d %d",&n,&m);
    int jsw[m];
    uint32_t sws[m];
    uint32_t bits[n];
    for(i = 0;i < n;i++)bits[i] = 1u << i;
    for(i = 0;i < m;i++){
        scanf("%d",&jsw[i]);
        sws[i] = 0;
        int tmp;
        for(j = 0;j < jsw[i];j++){
            scanf("%d",&tmp);
            sws[i] += bits[tmp-1];
        }
    }
    int p[m];
    int ans = 0;
    for(i = 0;i < m;i++)scanf("%d",&p[i]);
    register uint32_t cnt = 0;
    uint32_t max = 1u << n;
    _Bool flag;
    for(;cnt < max;ans+= flag?1:0,cnt++){
        flag = 1;
        for(i = 0;i < m;i++){
            uint32_t tmp = sws[i] & cnt;
            int c = 0;
            for(j = 0;j < n;j++)if(tmp & bits[j])c++;
            if(c % 2 != p[i]){
                flag = 0;
                break;
            }
        }
    }
    printf("%d",ans);
}

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

using namespace std;

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

#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define mod 1000000007
#define INF 1000000000ll
#define MAX 100005

void init(){
	return;
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	init();
	int a, b;
	cin >> a >> b;
	if((a<=9) and (a>=1) and (b<=9) and (b>=1)){
		cout << a*b << endl;
	}
	else cout << -1 << endl;
	//fclose(stdout);
	return 0;
}

Measured memory_bytes: 256
x, y, a, b, c = map(int, input().split())
p = sorted(list(map(int, input().split())), reverse=True)
q = sorted(list(map(int, input().split())), reverse=True)
r = sorted(list(map(int, input().split())), reverse=True)

if x <= len(p):
    pp = p[:x]
else:
    pp = p + r[:x-len(p)]

if y <= len(q):
    qq = q[:y]
else:
    qq = q + r[:y-len(q)]
    
rr = []
for k in r:
    if len(pp) >= 1 and len(qq) >= 1:
        if pp[-1] < qq[-1]:
            if pp[-1] < k:
                pp.pop()
                rr.append(k)
            else:
                break
        else:
            if qq[-1] < k:
                qq.pop()
                rr.append(k)
            else:
                break
    elif len(pp) >= 1:
        if pp[-1] < k:
            pp.pop()
            rr.append(k)
        else:
            break
    elif len(qq) >= 1:
        if qq[-1] < k:
            qq.pop()
            rr.append(l)
        else:
            break
    else:
        break

print(sum(pp)+sum(qq)+sum(rr))
            
    



Measured memory_bytes: 23200
#include <bits/stdc++.h>
#define x real()
#define y imag()
using namespace std;
typedef complex<double> point;

double dot(point a, point b) {
	return a.x * b.x + a.y * b.y;
}
double cross(point a, point b) {
	return a.x * b.y - a.y * b.x;
}
int ccw(point a, point b, point c) {
	point d = b - a, e = c - a;
	if (cross(d, e) > 0)
		return 1; //"COUNTER_CLOCKWISE"
	if (cross(d, e) < 0)
		return -1; //"CLOCKWISE"
	if (dot(d, e) < 0)
		return 2; //"ONLINE_BACK"
	if (abs(d) < abs(e))
		return -2; //"ONLINE_FRONT"
	return 0; //"ON_SEGMENT"
}

point crosspoint(point a, point b, point c, point d) {
	a -= d;
	b -= d;
	c -= d;
	return d + a + (b - a) * imag(a / c) / imag(a / c - b / c);
}

vector<point> ConvexCut(vector<point> &polygon, point a, point b) {
	vector<point> res;
	for (int i = 0; i < polygon.size(); i++) {
		point A = polygon[i], B = polygon[(i + 1) % polygon.size()];
		if (ccw(a, b, A) != -1)
			res.push_back(A);
		if (ccw(a, b, A) * ccw(a, b, B) == -1)
			res.push_back(crosspoint(a, b, A, B));
	}
	return res;
}

double get_area(vector<point> polygon) {
	if (polygon.size() < 3)
		return 0;
	double res = 0;
	for (int i = 0; i < polygon.size(); i++)
		res += cross(polygon[i], polygon[(i + 1) % polygon.size()]) / 2;
	return res;
}

int main() {
	while (1) {
		int n, d;
		double V;
		vector<point> pl;
		cin >> n >> d >> V;
		if (!n && !d && !V)
			break;
		for (int i = 0, a, b; i < n; i++)
			cin >> a >> b, pl.push_back(point(a, b));
		V = min(get_area(pl) * d, V);

		double ans = 0;
		for (int i = 0; i < n; i++) {
			double L = 0, M, R = 2010;
			int I = 100;
			while (I--) {
				M = (L + R) / 2;
				point h = pl[(i + 1) % n] - pl[i], b = h;
				h = (point(0, M) * h / abs(h)) + pl[i];
				vector<point> a = ConvexCut(pl, h + b, h);
				if (get_area(a) * d >= V)
					R = M;
				else
					L = M + 0.00000001;
			}
			ans = max(ans, L);
		}
		printf("%.8f\n", ans);
	}
	return 0;
}

Measured memory_bytes: 3268
#include <algorithm>
#include <array>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;
using ll = long long;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

#define MOD ((ll)1000000007)

int main(int argc, char const *argv[])
{
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);

	ll X, Y;
	cin >> X >> Y;

	int ans = 0;
	for (ll i = X; i <= Y; i *= 2)
	{
		ans++;
	}

	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
n, k = gets.split.map(&:to_i)
pieces = gets.split.map(&:to_i).map(&:pred)
nums = gets.split.map(&:to_i)
if nums.select { |num| num >= 0 }.size == 0
  puts nums.max
  exit
end
orders = []
checked = Hash.new(false)
answers = []
# ans = 0

n.times do |from|
  next if checked[from]
  scores = [nums[from]]
  current = pieces[from]
  checked[from] = true
  while current != from
    scores << nums[current]
    checked[current] = true
    current = pieces[current]
  end
  sum = scores.sum
  scores_size = scores.size
  div, mod = k.divmod(scores_size)
  tmp = sum > 0 ? sum * div : 0
  addition = 0
  addition_b = 0


  # required_iteration = div > 0 ? scores_size - 1 : mod
  # scores_size.times do |f|
  #   applicables = []
  #   required_iteration.times do |a|
  #     applicables << (f + a) % scores_size
  #   end
  #   tm = 0
  #   applicables.each.with_index(1) do |i, app_i|
  #     tm += scores[i]
  #     rest = k - app_i
  #     t = tm + tmp * rest / scores_size
  #     ans = t if ans < t
  #   end
  # end


  # if tmp == 0 && div > 0
  #   mod = scores_size - 1
  # end

  i = div > 0 ? scores_size - 1 : mod

  # puts "#{tmp} #{div} #{mod} #{sum}"
  # (1..mod).each do |i|
    # i = mod
    # applicables = (0...i).to_a
    scores_size.times do |f|
      # applicables = []
      # i.times do |a|
      #   applicables << (f + a) % scores_size
      # end
      tm = 0

      i.times do |nn|
        applicable = (nn + f) % scores_size
        tm += scores[applicable]
        if nn + 1 <= mod
          addition = tm if addition < tm
        else
          addition_b = tm if addition_b < tm
        end
      end


      # applicables.each.with_index(1) do |i, app_i|
      #   tm += scores[i]
      #   if app_i <= mod
      #     addition = tm if addition < tm
      #   else
      #     addition_b = tm if addition_b < tm
      #   end
      # end
      # addition = tm if addition < tm
    end
  # end
  answers << tmp + addition
  # tmp_add = tmp + addition
  # answer = tmp_add if answer < tmp_add
  tmp -= sum if sum > 0
  # tmp_add_b = tmp + addition_b
  # answer = tmp_add_b if answer < tmp_add_b
  answers << tmp + addition_b
end
puts answers.max


Measured memory_bytes: 15200
#include <iostream>
#include <algorithm>
#include <vector>
#include <functional>

std::vector<int> scc(const std::vector<std::vector<int>> &g) {
  const int n = g.size();
  std::vector<int> post;
  std::vector<bool> vis(n);
  std::vector<std::vector<int>> rg(n);

  std::function<void(int)> dfs = [&](int u) {
    vis[u] = true;
    for (int v : g[u]) {
      if (!vis[v]) dfs(v);
      rg[v].push_back(u);
    }
    post.push_back(u);
  };
  for (int i = 0; i < n; i++) {
    if (!vis[i]) dfs(i);
  }

  std::reverse(post.begin(), post.end());

  int k = 0;
  std::vector<int> ret(n, -1);
  std::function<void(int)> dfs2 = [&](int u) {
    ret[u] = k;
    for (int v : g[u]) if (ret[v] == -1) dfs2(v);
  };

  for (int u : post) {
    if (ret[u] == -1) {
      dfs2(u);
      k++;
    }
  }
  return ret;
}

// c=(i,ii,j,jj), x[i]==ii and x[j]==jj
std::vector<bool> sat2(int n, std::vector<std::tuple<int, int, int, int>> cs) {
  std::vector<std::vector<int>> g(n * 2);

  for (auto c : cs) {
    int i, ii, j, jj;
    std::tie(i, ii, j, jj) = c;
    // not a -> b = a or b
    g[i * 2 + 1 - ii].push_back(j * 2 + jj);
    g[j * 2 + 1 - jj].push_back(i * 2 + ii);
  }

  std::vector<int> sid = scc(g);
  std::vector<bool> ret(n);

  for (int i = 0; i < n; i++) {
    if (sid[i * 2] == sid[i * 2 + 1]) return {};
    ret[i] = sid[i * 2] < sid[i * 2 + 1];
  }

  return ret;
}

using namespace std;

int dist(int a, int b) {
  a %= 24;
  b %= 24;
  if (a > b) swap(a, b);
  return min(b - a, 24 - (b - a));
}
 
int main() {
  int n;
  cin >> n;
 
  vector<int> a(n + 1);
  for (int i = 0; i < n; i++) {
    cin >> a[i + 1];
  }
 
  for (int ans = 12; ans >= 0; ans--) {
    vector<tuple<int, int, int, int>> cs;
    for (int i = 0; i <= n; i++) {
      for (int j = i + 1; j <= n; j++) {
        if (dist(a[i], a[j]) < ans) {
          cs.emplace_back(i, 1, j, 1);
        }
        if (dist(a[i], 24 - a[j]) < ans) {
          cs.emplace_back(i, 1, j, 0);
        }
        if (dist(24 - a[i], 24 - a[j]) < ans) {
          cs.emplace_back(i, 0, j, 0);
        }
        if (dist(24 - a[i], a[j]) < ans) {
          cs.emplace_back(i, 0, j, 1);
        }
      }
    }
    if (!sat2(n + 1, cs).empty()) {
      cout << ans << endl;
      return 0;
    }
  }
  cout << 0 << endl;
}


Measured memory_bytes: 512
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
ll A[200000];
ll sum[200000];
int l[200000];
int r[200000];
 int main() {
	 int N;
	 cin >> N;
	 for (int i = 0; i < N; i++) cin >> A[i];
	 sum[0] = A[0];
	 for (int i = 1; i < N; i++) sum[i] = sum[i - 1] + A[i];
	 l[1] = 0;
	 for (int i = 2; i < N; i++) {
		 l[i] = l[i - 1];
		 while (l[i] + 1 < i) {
			 if (abs(sum[i] / 2 - (sum[i] - sum[l[i]])) <= abs(sum[i] / 2 - (sum[i] - sum[l[i] + 1]))) break;
			 l[i]++;
		 }
	 }
	 r[N - 3] = N - 2;
	 for (int i = N - 4; i >= 0; i--) {
		 r[i] = r[i + 1];
		 while (r[i] - 1 > i) {
			 ll s = sum[N - 1] - sum[i];
			 if (abs(s / 2 - (sum[N - 1] - sum[r[i]])) <= abs(s / 2 - (sum[N - 1] - sum[r[i] - 1]))) break;
			 r[i]--;
		 }
	 }
	 ll ans = 1LL << 60;
	 for (int i = 1; i <= N - 3; i++) {
		 ll P = sum[l[i]], Q = sum[i] - sum[l[i]];
		 ll R = sum[r[i]] - sum[i], S = sum[N - 1] - sum[r[i]];
		 ll m = min(P, min(Q, min(R, S)));
		 ll M = max(P, max(Q, max(R, S)));
		 ans = min(ans, M - m);
	 }
	 cout << ans << endl;
}

Measured memory_bytes: 4992
N = int(input())
a = list(map(int,input().split()))

ans = 'No'
hat1 = max(a)
hat2 = min(a)
if hat1 == 0 and a.count(hat1) == N:
    ans = 'Yes'
if N%3 == 0:
    if hat2 == 0 and a.count(hat1) == int(2*N/3) and a.count(hat2) == int(N/3):
        ans = 'Yes'
    if a.count(hat1) == int(N/3) and a.count(hat2) == int(N/3) and a.count(hat1^hat2) == int(N/3):
        ans = 'Yes'
print(ans)


Measured memory_bytes: 14116
import java.util.Scanner;
import java.util.Arrays;
import java.util.ArrayList;
import java.util.Collections;

public class Main {
	public static void main(String args[]) throws InterruptedException {
		    Scanner sc = new Scanner(System.in);	
			
			String s = sc.next();
			int a = Integer.parseInt(s.substring(0,1));
			int b = Integer.parseInt(s.substring(1,2));
			int c = Integer.parseInt(s.substring(2,3));
			int d = Integer.parseInt(s.substring(3,4));

			if (a+b+c+d == 7) {
				System.out.println(a +"+"+b+"+"+c+"+"+d+"=7");
			}else if(a+b+c-d == 7){
				System.out.println(a +"+"+b+"+"+c+"-"+d+"=7");
			}else if (a+b-c+d == 7) {
				System.out.println(a +"+"+b+"-"+c+"+"+d+"=7");
			}else if (a+b-c-d == 7) {
				System.out.println(a +"+"+b+"-"+c+"-"+d+"=7");
			}else if (a-b+c+d == 7) {
				System.out.println(a +"-"+b+"+"+c+"+"+d+"=7");
			}else if (a-b+c-d == 7){
				System.out.println(a +"-"+b+"+"+c+"-"+d+"=7");
			}else if (a-b-c+d == 7) {
				System.out.println(a +"-"+b+"-"+c+"+"+d+"=7");
			}else{
				System.out.println(a +"-"+b+"-"+c+"-"+d+"=7");
			}

		    sc.close(); }
}


Measured memory_bytes: 23124
n=int(input())
cnt=[[0 for i in range(10)] for _ in range(10)]
for i in range(1,n+1):
  a=int(str(i)[0])
  b=i%10
  if b==0:
    continue
  cnt[a][b]+=1
ans=0
for i in range(1,10):
  for j in range(1,10):
    ans+=cnt[i][j]*cnt[j][i]
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0; i<(n); i++)
int main() {
  int a, b, c;
  cin >> a >> b >> c;
  vector<int> num(3);
  num[0] = a;
  num[1] = b;
  num[2] = c;
  sort(num.rbegin(), num.rend());
  int num1 = num[0];
  int num2 = num[1];
  int num3 = num[2];
  //cout << num[0] << num[1] << num[2] << endl;
  int ans = 0;
  if(num1%2==num2%2 && num2%2==num3%2){
    while(num2+2<=num1){
      num2 += 2;
      ans++;
    }
    while(num3+2<=num1){
      num3 += 2;
      ans++;
    }
    cout << ans << endl;
    return 0;
  }
  else{
    if(num2%2 == num3%2){
      while(num2+2<=num1-1){
        num2 += 2;
        ans++;
        //cout << ans << endl;
      }
      while(num3+2<=num1-1){
        num3 += 2;
        ans++;
        //cout << ans << endl;
      }
      ans++;
      cout << ans << endl;
      return 0;
    }
    if(num1%2 == num2%2){
      while(num2+2<=num1){
        num2 += 2;
        ans++;
      }
      while(num3+2<=num1+1){
        num3 += 2;
        ans++;
      }
      ans++;
      cout << ans << endl;
      return 0;
    }
    if(num1%2 == num3%2){
      while(num3+2<=num1){
        num3 += 2;
        ans++;
      }
      while(num2+2<=num1+1){
        num2 += 2;
        ans++;
      }
      ans++;
      cout << ans << endl;
      return 0;
    }
  }
}

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

int main(){
  int n, p, k;
  std::cin >> n;
  for (int i = 0; i < n; i++) {
    std::cin >> p >> k;
    std::cout << (p%k == 0? k:(p%k)) << std::endl;
  }
  return 0;
}




Measured memory_bytes: 3096
from math import ceil
N,K = list(map(int, input().split()))
A = list(map(int, input().split()))
F = list(map(int, input().split()))

A.sort(reverse=True)
F.sort()
wk = 0
for i in range(N):
  wk += A[i] * F[i]
#print(wk)

def is_ok(arg):
  # 条件を満たすかどうか？問題ごとに定義
  cnt = 0
  for i in range(N):
    a,f = A[i], F[i]   
    if a*f <= arg:
      continue
    else:
      #(a-k) * f <= arg
      # a - arg/f <= k
      cnt += ceil(a-arg/f)
  return cnt <= K

def meguru_bisect(ng, ok):
  '''
    初期値のng,okを受け取り,is_okを満たす最小(最大)のokを返す
    まずis_okを定義すべし
    ng ok は  とり得る最小の値-1 とり得る最大の値+1
    最大最小が逆の場合はよしなにひっくり返す
    '''
  while (abs(ok - ng) > 1):
    mid = (ok + ng) // 2
    if is_ok(mid):
      ok = mid
    else:
      ng = mid
  return ok

ng = -1
ok = 10**12 + 10
ans = meguru_bisect(ng,ok)

print(ans)

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

likes = [0 for x in range(M)]

for n in range(N):
    s = [int(x) for x in input().split()]
    K = s[0]
    for k in range(K):
        likes[s[1+k] - 1] += 1

print(likes.count(N))

Measured memory_bytes: 3060
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <string>
using namespace std;

#define COLOR_SIZE 200000LL+1

long long ishi(long long N, long long start, long long* D, long long* E){
  if(D[start] != 0){
    return D[start];
  }

  long long result;
  if(start >= N-1){
    result = 1;
  }else{
    if(E[start] != 0 && E[start] != start+1){
      result = (ishi(N, start+1, D, E) + ishi(N, E[start], D, E)) % 1000000007LL;

    }else{
      result = ishi(N, start+1, D, E);
    }


  }

  //cout << "from " << start << ":" << result << "\n";
  //cout << "E[" << start << "]:" << E[start] << "\n";
  D[start] = result;
  return result;
}


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

  long long C[N+1] = {}; // 色
  long long D[N+1] = {}; // 動的計画
  long long E[N+1] = {}; // 直後の同色のインデックス
  long long F[COLOR_SIZE] = {}; // 色ごとの最新のインデックス

  for(int i=1;i<=N;i++){
    cin >> C[i];
    if(F[C[i]] != 0){
      E[F[C[i]]] = i;
    }
    F[C[i]] = i;
  }

  long long result = ishi(N, 1, D, E);

  cout << result << "\n";
  return 0;
}


Measured memory_bytes: 18944
#include <iostream>
using namespace std;
int main(){
  long long x,y,z;cin>>x>>y>>z;
  if((long long)x*y*z % 2 == 0){
	cout << 0 << endl;
    return 0;
  }
  cout << min(x*y,min(x*z,y*z)) << endl;

}

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

using namespace std;

int main(){
  std::cin.tie(nullptr);                  // 標準入出力高速化
  std::ios_base::sync_with_stdio(false);  // SとS++の入出力出力を非同期
  int a,b;
  cin>>a>>b;
  a-b*2<0 ? cout<<0<<endl : cout<<a-b*2<<endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<vector>
using namespace std;
int main(void){
int a[10000];
int b[10001];
int aa;
int bb;
int n;
int max;
int s;
int c;
max=0;
scanf("%d %d",&aa,&bb);
for(int i=0;i<aa;i++){
scanf("%d",&a[i]);
}
for(int i=0;i<bb;i++){
scanf("%d",&b[i]);
}
b[bb]=10000000;
for(int i=0;i<bb;i++){
s=0;
c=i;
for(int j=0;j<aa;j++){
if(a[j]==b[c]){
c++;
s++;
}
}
if(s>max)max=s;
}
printf("%d\n",max);

return 0;
}

Measured memory_bytes: 2776
#define rep( i, n )		for( i = 0; i < n; i++ )
#define rep1( i, n )	for( i = 1; i <= n; i++ )

#include <bits/stdc++.h>
using namespace std;

char S[ 70 ][ 70 ];
int A[ 70 ][ 70 ];

int X[] = { - 1, 0, 1, - 1, 1, - 1, 0, 1 };
int Y[] = { - 1, - 1, - 1, 0, 0, 1, 1, 1 };

void Add( const int iX, const int iY )
{
int i;

	rep( i, 8 )
	{
		A[ iX + X[ i ] ][ iY + Y[ i ] ]++;
	}
}

int main()
{
int i;
int j;
int H;
int W;

	ios::sync_with_stdio( false );
	cin.tie( 0 );

	cin >> H;
	cin >> W;

	rep1( i, H ) cin >> ( S[ i ] + 1 );

	rep1( i, H )
	{
		rep1( j, W )
		{
			if( S[ i ][ j ] == '#' )
				Add( i, j );
		}
	}

	rep1( i, H )
	{
		rep1( j, W )
		{
			if( S[ i ][ j ] == '#' )
				cout << '#';
			else
				cout << A[ i ][ j ];
		}

		cout << endl;
	}

	return 0;
}






Measured memory_bytes: 256
inf = input().split()
H = int(inf[0])
W = int(inf[1])
sheet = [[] for i in range(H+2)]
score = [[] for i in range(H+2)]
m = 0
 
for h in range(H+2):
  if h==0 or h==H+1:
    a = [False]*(W+2)
    b = [(0,0)]*(W+2)
    sheet[h]=a
    score[h]=b
  else:
    line = input()
    a = []
    b = []
    a += [False]
    b += [(0,0)]
    for w in range(W):
      b+=[(0,0)]
      if line[w]=='.':
        a += [True]
      else:
        a += [False]
    a += [False]
    b += [(0,0)]
    sheet[h]=a
    score[h]=b
      
for h in range(1,H+1):
  for w in range(1,W+1):
    if sheet[h][w]:
      s = 0
      hs = 0
      ws = 0
      if sheet[h-1][w]:
        hs += score[h-1][w][0]
      else:
        i = h+1
        while sheet[i][w]:
          hs+=1
          i+=1
      if sheet[h][w-1]:
        ws += score[h][w-1][1]
      else:
        j = w+1
        while sheet[h][j]:
          ws+=1
          j+=1
      s = 1 + hs + ws
      score[h][w]=(hs, ws)
      if m < s:
        m = s
print(m)


Measured memory_bytes: 189320
#include <iostream>

using namespace std;

int main()
{
    int n; cin >> n;
    string s; cin >> s;
    int t = 0;
    for(int i=0; i<s.size(); i++)
    {
        if(s[i] == 'A' && s[i+1] == 'B' && s[i+2] == 'C')
        {
            t++;
        }
    }
    cout << t;
    return 0;
}

Measured memory_bytes: 384
import sys

# sys.stdin = open('d1.in')


def read_int_list():
    return list(map(int, input().split()))


def read_str_list():
    return input().split()


def read_int():
    return int(input())


def read_str():
    return input()


def solve():
    M = 10
    n, ma, mb = read_int_list()
    p = [read_int_list() for i in range(n)]
    min_c = {(0, 0, 0): 0}

    for i in range(1, n + 1):
        a, b, c = p[i - 1]
        for u in range(0, M * (i - 1) + 1):
            for v in range(0, M * (i - 1) + 1):
                if (i - 1, u, v) in min_c:
                    cost = min_c[(i - 1, u, v)]
                    cc = cost + c
                    uu = u + a
                    vv = v + b
                    if (i, uu, vv) not in min_c:
                        min_c[(i, uu, vv)] = cc
                    if cc < min_c[(i, uu, vv)]:
                        min_c[(i, uu, vv)] = cc
                        
                    cc = cost
                    uu = u
                    vv = v
                    if (i, uu, vv) not in min_c:
                        min_c[(i, uu, vv)] = cc
                    if cc < min_c[(i, uu, vv)]:
                        min_c[(i, uu, vv)] = cc

    inf = 10 ** 20
    res = inf
    for u in range(0, M * n + 1):
        for v in range(0, M * n + 1):
            if u == 0 and v == 0:
                continue
            if u * mb == v * ma:
                if (n, u, v) in min_c:
                    cost = min_c[(n, u, v)]
                    if cost < res:
                        res = cost
    if res == inf:
        res = -1
    return res


def main():
    res = solve()
    print(res)


main()


Measured memory_bytes: 40228
#include <bits/stdc++.h>
 
using namespace std;
 
typedef string::const_iterator State;
typedef pair<int, int> Pii;
 
#define fr first
#define sc second
 
bool is_over = false;
 
struct Parser {
  Pii expression(State &idx) {
    Pii ret = term(idx);
    if ( abs(ret.fr) > 10000 || abs(ret.sc) > 10000 ) is_over = true;
    while ( 1 ) {
      if ( *idx == '+' ) {
    idx++;
    Pii tmp = term(idx);
    ret.fr = ret.fr + tmp.fr;
    ret.sc = ret.sc + tmp.sc;
    if ( abs(ret.fr) > 10000 || abs(ret.sc) > 10000 ) is_over = true;
      } else if ( *idx == '-' ) {
    idx++;
    Pii tmp = term(idx);
    ret.fr = ret.fr - tmp.fr;
    ret.sc = ret.sc - tmp.sc;
    if ( abs(ret.fr) > 10000 || abs(ret.sc) > 10000 ) is_over = true;
      } else {
    break;
      }
    }
    if ( abs(ret.fr) > 10000 || abs(ret.sc) > 10000 ) is_over = true;
    return ret;
  }
   
  Pii term(State &idx) {
    Pii ret = factor(idx);
    if ( abs(ret.fr) > 10000 || abs(ret.sc) > 10000 ) is_over = true;
    while ( 1 ) {
      if ( *idx == '*' ) {
    idx++;
    Pii tmp = factor(idx), tmp2 = ret;
    ret.fr = tmp2.fr * tmp.fr - tmp2.sc * tmp.sc;
    ret.sc = tmp2.fr * tmp.sc + tmp2.sc * tmp.fr;
    if ( abs(ret.fr)> 10000 || abs(ret.sc) > 10000 ) is_over = true;
      } else {
    break;
      }
    }
    if ( abs(ret.fr) > 10000 || abs(ret.sc) > 10000 ) is_over = true;
    return ret;
  }
 
  Pii factor(State &idx) {
    Pii ret;
    if ( *idx == '(' ) {
      idx++;
      ret = expression(idx);
      if ( abs(ret.fr) > 10000 || abs(ret.sc) > 10000 ) is_over = true;
      idx++;
    } else {
      ret = number(idx);
      if ( abs(ret.fr) > 10000 || abs(ret.sc) > 10000 ) is_over = true;
    }
    if ( abs(ret.fr) > 10000 || abs(ret.sc) > 10000 ) is_over = true;
    return ret;
  }
 
  Pii number(State &idx) {
    int tmp = 0;
    while ( '0' <= *idx && *idx <= '9' ) {
      tmp *= 10;
      tmp += *idx - '0';
      if ( abs(tmp) > 10000 ) is_over = true;
      idx++;
    }
    if ( abs(tmp) > 10000 ) is_over = true;
    if ( *idx == 'i' ) {
      idx++;
      return Pii(0, 1);
    }
  
    else return Pii(tmp, 0);
  }
};
 
int main()
{
  string s;
  while ( cin >> s ) {
    is_over = false;
    Parser ps;
    string tmp = s.substr(0, s.size() - 1);
    State idx = s.begin();
 
    Pii ret = ps.expression(idx);
    if ( abs(ret.fr) > 10000 || abs(ret.sc) > 10000 ) is_over = true;
    if ( is_over ) cout << "overflow" << endl;
    else if ( ret.fr == 0 && ret.sc == 0 ) cout << 0 << endl;
    else if ( ret.fr == 0 ) printf("%di\n", ret.sc);
    else if ( ret.sc == 0 ) printf("%d\n", ret.fr);
    else printf("%d%+di\n", ret.fr, ret.sc);
  }
 
  return 0;
}

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

int main() {
  string S; cin>>S;
  int ans=0;
  for(int i=0; i<S.size()-1; i++){
    if(S.at(i)==S.at(i+1)){
      ans=1;
    }
  }
  if(ans==0){
    cout<<"Good"<<endl;
  }
  else{
    cout<<"Bad"<<endl;
  }
}

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

class Stack{
private:
  int sp;
  int data[100];
public:
  Stack(){sp=0;}
  void push(int x){data[sp]=x;sp++;}
  int top(){return data[sp-1];}
  void pop(){sp--;}
};

string str;

int input_num(int* i){
  char tmp[10]="";
  int k=0;
  while(str[*i]>='0'&&str[*i]<='9'){
    tmp[k]=str[*i];
    *i=*i+1;
    k++;
  }
  return atoi(tmp);
}
int main(){
  Stack s;
  int tmp1,tmp2;
  getline(cin,str);
  for(int i=0;i<str.length();i++){
    if(str[i]==' '){continue;}
    else if(str[i]=='+'){
      tmp1=s.top();s.pop();
      tmp2=s.top();s.pop();
      s.push(tmp2+tmp1);
    }
    else if(str[i]=='*'){
      tmp1=s.top();s.pop();
      tmp2=s.top();s.pop();
      s.push(tmp2*tmp1);
    }
    else if(str[i]=='-'){
      tmp1=s.top();s.pop();
      tmp2=s.top();s.pop();
      s.push(tmp2-tmp1);
    }
    else{
      s.push(input_num(&i));
    }
  }
  cout<<s.top()<<endl;
}


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

using namespace std;

inline int xi(const int x, const int i, const int T){ return x + (T+1)*i; }

int main(){
	int N, T, S;

	// 夜店の数N, 祭りの時間T, 花火の時間S を入力
	cin >> N >> T >> S;

	int *A = new int[N+1];
	int *B = new int[N+1];

	//各夜店の楽しさA, 所要時間B を入力。動的計画法と合わせるため i=0 を余分に用意
	for(int i=1; i<=N; i++) cin >> A[i] >> B[i];

	int *dp = new int[(N+1) * (T+1)];	//動的計画法のための配列
	
	//dpの初期値
	dp[0] = 0;
	for(int i=1; i<(N+1)*(T+1); i++) dp[i] = -1;

	//動的計画法でMを求める
	for(int i=1; i<=N; i++){
		for(int x=0; x<=T; x++){

			// i-1行目 x列が 0以上なら分岐へ
			if(dp[xi(x, i-1, T)] >= 0){

				//遊ぶ場合 -> 花火の前後で場合分け
				if(x + B[i] <= S) dp[xi(x, i, T) + B[i]] = dp[xi(x, i-1, T)] + A[i]; //遊び終わりが花火の前
				else if(x > S){	//遊び始めが花火の後
					if(x + B[i] <= T) dp[xi(x, i, T) + B[i]] = dp[xi(x, i-1, T)] + A[i];
				}
				else{	//遊ぼうとすると花火と被る場合
					if(S + B[i] <= T) dp[xi(S, i, T) + B[i]] = max(dp[xi(S, i, T) + B[i]], dp[xi(x, i-1, T)] + A[i]);
				}

				//遊ばない場合 -> 既に更新された値と比較 -> 大きいほうを採用
				dp[xi(x, i, T)] = max(dp[xi(x, i, T)], dp[xi(x, i-1, T)]);
			}
		}
	}

	//一番大きい値を表示
	cout << *max_element(dp+xi(0, N, T), dp+xi(T+1, N, T)) << endl;

	delete[] A;
	delete[] B;
	delete[] dp;

	return 0;
}

Measured memory_bytes: 36392