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

#define REP(i, x, n) for (int i = x; i < (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x.size())
#define popcount(x) __builtin_popcount(x)
#define popcountll(x) __builtin_popcountll(x)
#define uniq(x) x.erase(unique(x.begin(), x.end()), x.end())
#define F first
#define S second
#define mp make_pair
#define eb emplace_back
#define pii pair<int, int>
#define pll pair<ll, ll>

using namespace std;

typedef long long ll;

/* --- INFやMODの値が適切か確認する --- */
// const int INF = 1 << 30;
// const ll INF = 1LL << 60;
// const ll MOD = 1000000007;

int main() {
  int N, K, Q;
  cin >> N >> K >> Q;
  vector<int> cnt(N, 0);
  rep(i, Q) {
    int a;
    cin >> a;
    cnt[a - 1]++;
  }
  rep(i, N) {
    if ((K - (Q - cnt[i])) <= 0)
      cout << "No" << endl;
    else
      cout << "Yes" << endl;
  }
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)

ll n;
vector<ll> t = {3, 5, 7};

ll dfs(ll s){
    if(s > n){
        return 0;
    }
    ll ret = 0;
    ll t3 = 0, t5 = 0, t7 = 0;
    for(auto p : to_string(s)){
        if(p == '3') t3++;
        if(p == '5') t5++;
        if(p == '7') t7++;
        if(t3 > 0 && t5 > 0 && t7 > 0){
            ret++;
            break;
        }
    }
    for(auto p : t){
        ret += dfs(10*s + p);
    }
    return ret;
}

int main(){
    cin >> n;
    cout << dfs(0) << endl;
    return 0;
}

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

using namespace std;

const int MAX_N = 123, MAX_NV = 123456;
long long n, capacity, v[MAX_N], w[MAX_N], dp[MAX_NV];

int main() {

    cin >> n >> capacity;
    for (int i = 0; i < n; ++i)
        cin >> w[i] >> v[i];

    for (int i = 0; i <= 100000; ++i) {
        dp[i] = -1;

        if (i == 0)
            dp[i] = 0;
    }

    int max_value = 0, tst = 0;

    for (int i = 0; i < n; ++i) {
        for (int j = max_value; j >= 0; --j) {
            if (dp[j] != -1 && dp[j] + w[i] <= capacity && (dp[j + v[i]] == -1 || (dp[j + v[i]] != -1 && dp[j + v[i]] > dp[j] + w[i]))) {
                dp[j + v[i]] = dp[j] + w[i];

                if (j + v[i] > tst) {
//                    cout << tst << " " << j + v[i] << endl;

                    tst = j + v[i];
                }
            }

            max_value = tst;
        }
    }
//
//    for (int i = 0; i <= max_value; ++i)
//        if (dp[i] !=  -1)
//            cout << i << " ";
//
    cout << max_value << endl;
    return 0;
}

Measured memory_bytes: 4412
N, H = map(int,raw_input().split())
a = []
b = []
for i in range(N):
    ai, bi = map(int,raw_input().split())
    a.append(ai)
    b.append(bi)

a_max = max(a)
b = sorted(b)


ans = 0
for i in reversed(range(N)):
    if b[i] >= a_max:
        ans = ans + 1
        H = H - b[i]
    if H <= 0:
        print ans
	exit()

ans = ans + -(-H//a_max)

print ans


Measured memory_bytes: 12532
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int h, w, n, a;
    scanf("%d %d %d",&h, &w, &n);
    if(h>w){
        swap(h, w);
    }
    if(n%w!=0){
        a = (n/w) + 1;
    }
    else{
        a = n/w;
    }
    printf("%d", a);
    return 0;
}


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

#define rep(i, n) for (int i = 0; i < (n); ++i)

using namespace std;

using ll = long long;
using P = pair<int, int>;

const int MOD = 1'000'000'007;

int main() {
  int n, m;
  cin >> n >> m;
  vector<bool> oks(n + 1, true);
  rep(i, m) {
    int a;
    cin >> a;
    oks[a] = false;
  }
  // ある階までの移動方法
  vector<int> dp(n + 1, 0);
  dp[0] = 1;
  for (int i = 0; i < n; i++) {
    for (int next = i + 1; next <= min(n, i + 2); next++) {
      if (oks[next]) {
        dp[next] += dp[i];
        dp[next] %= MOD;
      }
    }
  }
  cout << dp[n] << endl;

  return 0;
}


Measured memory_bytes: 640
fun main(args: Array<String>){
  var(a,b,c,d) = readLine()!!.split(" ").map{ it.toInt() }
  for(i in 1..101){
  var t = c - b*i
  if(t <= 0){
    println("Yes")
    break
  }
  var s = a - d*i
  if(s <= 0){
    println("No")
    break
  }
  } 
}

Measured memory_bytes: 36312
#include <iostream>
#include <string>
#include <vector>
#include <cstdio>
#include <stdio.h>
using namespace std;
int main(){
	string str;
	while(cin>>str){
		int num=0;
		vector<int> roman;
		for(int i=0;i<str.length();i++){
			if(str[i]=='I'){
				roman.push_back(1);
			}else if(str[i]=='V'){
				roman.push_back(5);
			}else if(str[i]=='X'){
				roman.push_back(10);
			}else if(str[i]=='L'){
				roman.push_back(50);
			}else if(str[i]=='C'){
				roman.push_back(100);
			}else if(str[i]=='D'){
				roman.push_back(500);
			}else if(str[i]=='M'){
				roman.push_back(1000);
			}
		}
		for(int i=0;i<roman.size();i++){
			if(i==roman.size()-1){
				num += roman[roman.size()-1];
			}else{
				if(roman[i]<roman[i+1]){
					num += roman[i+1]-roman[i];
					i++;
				}else{
					num += roman[i];
				}
			}
		}
		cout<<num<<endl;
	}
	return 0;
}

Measured memory_bytes: 1204
using System;
using System.Collections.Generic;
using System.Linq;
using static Atcoder;
using System.Threading.Tasks;
using System.ComponentModel;

public class Hello
{

    public static void Main()
    {
        int N = intRead();
        Deer[] deer = new Deer[N];
        int[] box;
        for (int i = 0; i < N; i++)
        {
            box = SpRead(' ').Select(_ => int.Parse(_)).ToArray();
            deer[i].time = box[0];
            deer[i].x = box[1];
            deer[i].y = box[2];
        }
        int B = 0;
        int x = 0, y = 0;
        bool ans = true;
        for (int i = 0; i < N; i++)
        {
            int t = deer[i].time - B;
            B = deer[i].time;
            if (Math.Abs(deer[i].x - x) + Math.Abs(deer[i].y - y) > t) { ans = false; break; }
            else if (Math.Abs(deer[i].x - x) + Math.Abs(deer[i].y - y) < t)
            {
                if ((t - (Math.Abs(deer[i].x - x) + Math.Abs(deer[i].y - y))) % 2 == 1) { ans = false; break; }
            }
            x = deer[i].x;
            y = deer[i].y;
        }
        Console.WriteLine((ans ? "Yes" : "No"));
    }
    struct Deer
    {
        public int time;
        public int x;
        public int y;
    }
}


public class Atcoder
{
    static void Swap<T>(ref T a, ref T b)
    {
        var t = a;
        a = b;
        b = t;
    }
    public static int LCM(int a, int b)
    {
        int c = a * b;
        if (a < b) Swap(ref a, ref b);
        int d = a % b;
        while (d != 0)
        {
            a = b;
            b = d;
            d = a % b;
        }
        return c / b;
    }
    public static string strReverce(string s)
    {
        return new string(s.Reverse().ToArray());
    }
    public static int intRead()
    {
        return int.Parse(Console.ReadLine());
    }
    public static bool IsPrime(int n)
    {
        if (n < 2) return false;
        if (n == 2) return true;
        if (n % 2 == 0) return false;

        //double sqrtNum = Math.Sqrt(n);
        for (int i = 3; i < n; i += 2)
        {
            if (n % i == 0) return false;
        }
        return true;
    }
    public static string[] SpRead(char c)
    {
        return Console.ReadLine().Split(c);
    }
}


Measured memory_bytes: 18356
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <stack>
#include <numeric>
#include <algorithm>
#include <bitset>
#include <complex>
#include <iomanip>

using namespace std;
typedef long long ll;
typedef long long int llint;
typedef pair<ll, ll> pa;
#define MM 1000000000
#define MOD MM+7
#define MAX 101000
#define MAP 110
#define initial_value -1
#define MAX_T 1001
#define pi pair<int,int>
#define chmax(a,b) (a<b ? a=b:0)
#define chmin(a,b) (a>b ? a=b:0)
#define INF (1 << 29) //536870912

const long double PI = acos(-1);
const ll DEP = 1e18;
int dx[4] = {-1,0,1,0};
int dy[4] = {0,-1,0,1};
int GCD(int x,int y){
    return y ? GCD(y,x%y) : x;
}
string s;
int N;
int main(){
    cin >> N;
    cout << 180*(N-2) << endl;
}



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

#define ll long long
#define nl '\n'
#define forn(i, n) for(ll i = 0; i < n; ++i)
#define fori(i, a, b) for(ll i = a; i < b; ++i)

using namespace std;

int main(){

    #ifdef LOCAL  
        freopen("input.txt", "r", stdin);
    #endif
    
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    ll a, b, c; cin >> a >> b >> c;

    ll an[11] = {0};
    an[a]++; an[b]++; an[c]++;

    if(an[5] == 2 && an[7] == 1) cout << "YES" << nl;
    else cout << "NO" << nl;
    return 0;
}	
    

Measured memory_bytes: 3604
import sys
input = sys.stdin.readline

N, M = map(int, input().split())
S = list(map(int, input().split()))
T = list(map(int, input().split()))
mod = 10**9 + 7

dp = [[0] * (M+1) for _ in range(N+1)]
for i in range(N+1):
    for j in range(M+1):
        if i == 0 or j == 0:
            dp[i][j] = 1
        elif S[i-1] == T[j-1]:
            dp[i][j] = (dp[i-1][j] + dp[i][j-1]) % mod
        else:
            dp[i][j] = (dp[i-1][j] + dp[i][j-1] - dp[i-1][j-1]) % mod
print(dp[-1][-1])

Measured memory_bytes: 72540
#include <iostream>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <cmath>
#include <map>
#include <utility>
#include <queue>
#define ull unsigned long long
#define ll long long
#define mod 1000000007
using namespace std;

int main()
{
    int n,k;
    cin>>n>>k;

    for (int i=k-n+1;i<k+n;i++) cout<<i<<" ";
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
double Sequence(double a,int n)
{
    if(n==10)return a*2;
    if(n%2==0)return a*2+Sequence(a*2,n+1);
    if(n==1)return a+Sequence(a,n+1);
    return a/3+Sequence(a/3,n+1);
}
int main()
{
    double n=0,a;
    while(cin>>a){
        n=Sequence(a,1);
        cout<<setprecision(8)<<n<<endl;
    }
}

Measured memory_bytes: 1276
def main():
  arr = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51
]
  k = int(input())
  print(arr[k-1])
  
  
main()

Measured memory_bytes: 38256
#include <bits/stdc++.h>
#define int long long
#define ll long long
#define vl vector<ll>
#define pl pair<ll,ll>
#define mp make_pair
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define rep(i,b) for(ll i=0;i<b;i++)
#define per(i,a,b) for(int i=b-1;i>=a;i--)
#define Yes(i) cout<<(i?"Yes":"No")<<endl
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
#define all(v) (v).begin(),(v).end()
using namespace std;
ll n,m,mod=1e9+7;
signed main() {
    cin>>n>>m;
    ll n2=n,m2=m;
    ll nm=1;
    while(n>0){
        nm=(nm*n)%mod;
        n--;
    }
    while(m>0){
        nm=(nm*m)%mod;
        m--;
    }
    if(abs(n2-m2)>1)nm=0;
    if(n2==m2)nm*=2;
    cout<<nm%mod<<endl;
}

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

int main() {
    int N; cin >> N;
    bool fwin = false;
    while (N--) {
        int a; cin >> a;
        if (a % 2 != 0) fwin = true;
    }
    if (fwin) cout << "first" << endl;
    else cout << "second" << endl;
}

Measured memory_bytes: 256
N, C = (int(i) for i in input().split())

X = [0]
V = [0]
for i in range(N):
    x, v = (int(i) for i in input().split())
    X.append(x)
    V.append(v)


l_cal = [0] * (N + 1)
r_cal = [0] * (N + 1)
l_cal[1] = V[1] - 2 * (X[1] - X[0])
r_cal[1] = V[-1] - 2 * (C - X[-1])
for i in range(2, N+1):
    l_cal[i] = l_cal[i-1] + V[i] - 2 * (X[i] - X[i-1])
    r_cal[i] = r_cal[i-1] + V[-i] - 2 * (X[-i+1] - X[-i])

l_max = [0] * (N + 1)
r_max = [0] * (N + 1)
for i in range(1, N+1):
    l_max[i] = max(l_max[i-1], l_cal[i])
    r_max[i] = max(r_max[i-1], r_cal[i])

l_ans = l_max[-1]
r_ans = r_max[-1]
for i in range(1, N+1):
    l_ans = max(l_ans, l_max[-1-i] + r_cal[i] + (C - X[-i]))
    r_ans = max(r_ans, r_max[-1-i] + l_cal[i] + X[i])
print(max(l_ans, r_ans))

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

int main() {
    int n, ans = 1;
    string s;
    cin >> n >> s;
    for(int i = 0 ; i < n-1; ++i) {
        if(s[i] != s[i+1]) ans++;
    }

    cout << ans << '\n';

    return 0;
}


Measured memory_bytes: 512
n,m= map(int,input().split())
x=list(map(int,input().split()))
x=sorted(x, reverse=True)
y=[]
for i in range(m-1):
  y.append(x[i]-x[i+1])
y=sorted(y, reverse=True)
del y[0:n-1]
print(sum(y))

Measured memory_bytes: 13964
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep1(i, n) for (int i = 1; i < (n); ++i)
using namespace std;
typedef long long ll;
const ll INF = 1LL << 60;

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

    int x, y;
    cin >> x >> y;

    int res;
    if(x < y){
        if(0 <= x) res = y - x;
        if(x<0 && 0<y){
            if(abs(y) < abs(x)) res = abs(x)-abs(y) + 1;
            else res = abs(y) - abs(x) + 1;
        }
        if(y <= 0) res = abs(x) - abs(y);
    }

    else{
        if(x < 0) res = abs(y)-abs(x) + 2;
        if(y<=0 && 0<=x){
            if(abs(y) < abs(x)) res = abs(x)-abs(y) + 1;
            else res = abs(y)-abs(x) + 1;
        }
        if(0 < y) res = x - y + 2;
    }

    cout << res << endl;

    return 0;
}

Measured memory_bytes: 256
//
// Created by 26019 on 2020/6/14/014.
//

#include <iostream>

using namespace std;

void solve() {
    int x, y;
    cin >> x >> y;
    for (int i = 0; i <= x; ++i) {
        if ((2 * i + (x - i) * 4) == y) {
            cout << "Yes";
            return;
        }
    }
    cout << "No";
}

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


Measured memory_bytes: 3128
// Greatest Common Divisor: Euclidean Algorithm
//  URL: http://rose.u-aizu.ac.jp/onlinejudge/ProblemSet/description.jsp?id=0197&lang=jp

#include <cstdio>
#include <algorithm>

int main()
{
	int x, y;
	int steps;
	int gcd;

	while( 1 )
	{
		// ú»
		steps = 0;

		// lÌüÍ
		std::scanf( "%d%d", &x, &y );

		// üÍÌIíèÍ[2Â
		if( x == 0 && y == 0 ) break;

		// to do:
		//  [NbhÌÝ@ÅÅåöñðßé
		//  vZÉ©©Á½Xebvðßé

		// x >= y É·é: x < y ÈçüêÖ¦é
		if( x < y ) std::swap( x, y );

		// x / y Ì]èðxÉãü
		// lðüêÖ¦é
		// yª0ÉÈéÜÅ: yª0æèå«¯êÎ
		while( y > 0 )
		{
			x = x % y;
			std::swap( x, y );
			++steps;
		}

		// xÌlªÅåöñ
		gcd = x;

		// ÊðoÍ
		std::printf( "%d %d\n", gcd, steps );

	}

	return 0;
}

Measured memory_bytes: 0
const input = require("fs").readFileSync("/dev/stdin", "utf8")
const lines = input.split('\n')
const S = lines[0]
const Q = lines[1] - 0

const f = str => {
    let s = ''
    for (let i = str.length - 1; i >= 0; i--) {
        s += str[i]
    }
    return s
}

let dir = 1
let pre = ''
let suf = ''
for (let i = 2; i < Q + 2; i++) {
    const q = lines[i].split(' ')
    if (q[0] == 1) {
        dir = dir % 2 + 1
    } else {
        if (q[1] == dir) {
            pre += q[2]
        } else {
            suf += q[2]
        }
    }
}

const s = f(pre) + S + suf
console.log(dir == 1 ? s : f(s))

Measured memory_bytes: 64696
#include<iostream>

int main(){
    long long N, A, B;
    std::cin >> N >> A >> B;
    long long cycle1 = A + B;
    long long ans = N / cycle1 * A;
    long long tbd = N % cycle1;
    if(tbd < A){
        ans += tbd;
    }else{
        ans += A;
    }
    std::cout << ans << std::endl;
}


Measured memory_bytes: 256
import sys
input=sys.stdin.readline

N=int(input())
A=[list(map(int,input().split())) for i in range(N)]
mod=10**9+7

dp=[0]*2**N
que=[0]

data=[[] for i in range(N+1)]
for i in range(2**N):
    cnt=0
    for j in range(N):
        if i&(1<<j)==0:
            continue
        cnt+=1
    data[cnt].append(i)
    
for j in range(N):
    if A[0][j]==1:
        num=1<<j
        dp[num]+=1
                
for i in range(N):
    for j in range(N):
        if A[i][j]==1:
            num=1<<j
            for u in data[i]:
                dp[u^num]=(dp[u^num]+dp[u])%mod

print(dp[-1])

Measured memory_bytes: 131204
package main

import (
	"bufio"
	"fmt"
	"os"
)

// BIT (A Binary indexed tree or Fenwick tree)
type BIT struct {
	n int
	d []int
}

func NewBIT(n int, a ...int) *BIT {
	b := BIT{}
	b.n = n
	b.d = make([]int, n+1)
	for i := 0; i < len(a); i++ {
		b.Add(i, a[i])
	}
	return &b
}

func (b BIT) Add(i, x int) {
	for i++; i <= b.n; i += i & -i {
		b.d[i] += x
	}
}

func (b BIT) Sum(i int) int {
	x := 0
	for i++; i > 0; i -= i & -i {
		x += b.d[i]
	}
	return x
}

type query struct {
	l, r, i int
}

func main() {
	r := bufio.NewReader(os.Stdin)
	w := bufio.NewWriter(os.Stdout)
	defer w.Flush()

	var n, q int
	fmt.Fscan(r, &n, &q)
	c := make([]int, n+1)
	qm := make(map[int][]query)

	for i := 1; i <= n; i++ {
		fmt.Fscan(r, &c[i])
	}
	for i := 0; i < q; i++ {
		var x, y int
		fmt.Fscan(r, &x, &y)
		qm[y] = append(qm[y], query{x, y, i})
	}

	ans := make([]int, q)
	ci := make([]int, n+1)
	b := NewBIT(n + 1)
	for i := 1; i <= n; i++ {
		if ci[c[i]] > 0 {
			b.Add(ci[c[i]], -1)
		}
		ci[c[i]] = i
		b.Add(i, 1)
		for _, v := range qm[i] {
			ans[v.i] = b.Sum(v.r) - b.Sum(v.l-1)
		}
	}
	for i := 0; i < q; i++ {
		fmt.Fprintln(w, ans[i])
	}
}


Measured memory_bytes: 79716
#include<bits/stdc++.h>
using namespace std;
#define ll                          long long
#define in(a)                       ll a; cin>>a;
#define in2(a,b)                    ll a,b; cin>>a>>b;
#define in3(a,b,c)                  ll a,b,c; cin>>a>>b>>c;
#define in4(a,b,c,d)                ll a,b,c,d; cin>>a>>b>>c>>d;
#define in5(a,b,c,d,e)              ll a,b,c,d,e; cin>>a>>b>>c>>d>>e;
#define lelo(b)                     for(auto &i:b)cin>>i;
#define ff                          first
#define ss                          second
#define call(v)                     v.begin(),v.end()
#define rall(v)                     v.rbegin(),v.rend()
#define show(x)                     for(auto t:x)cout<<t<<" ";
#define pb                          push_back
#define bhar(s,v)                   memset(s,v,sizeof(s))
#define endl                        "\n"                       
#define ce(x)                       cout<<x<<"\n";
#define nl                          cout<<endl;
#define jaldi                       ios_base::sync_with_stdio(false);cin.tie(NULL);
#define dekh_lo                     ce("dekh_lo");
#define sz(x)                       (ll)x.size()
#define re                          return
 
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}
 
template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
 
typedef pair<ll,ll> pii;
typedef vector<pii> vii;
typedef vector<ll> vi;
 
const ll mod=1e9+7;
const ll N=1e6+5;
ll i,j;
 
/*
 
 
*/
vi dp(N,0);
void solve(){
    in(x);
    vi a;
    for(i=3;i<=x;i++){
        a.pb(i);
    }
    dp[1]=0;
    dp[2]=0;
    dp[3]=1;
    for(i=3;i<=x;i++){
        dp[i]=1;
        for(j=0;j<sz(a);j++){
            if(i-a[j]>=0){
                dp[i]=(dp[i]+dp[i-a[j]])%mod;
            }
        }
    }
    // for(i=0;i<=10;i++){
    //     cout<<dp[i]<<" ";
    // }
    // nl
    ce(dp[x]);
}
 
int32_t main(){
    // jaldi
    ll t; 
    // cin>>t;
    t=1;     
    while(t--){
        solve();
    }
}
 
/*
 
 
*/

Measured memory_bytes: 10984
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=1000000007,MAX=200005,INF=1<<30;

int main(){
    
    std::ifstream in("text.txt");
    std::cin.rdbuf(in.rdbuf());
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    string S;cin>>S;
    int Q;cin>>Q;
    int cnt=0;
    
    reverse(all(S));
    
    while(Q--){
        int t;cin>>t;
        if(t==1) cnt++;
        else{
            int a;cin>>a;
            char b;cin>>b;
            if((cnt+a)%2==1) S+=b;
            else S=b+S;
        }
    }
    
    if(cnt%2==0) reverse(all(S));
    
    cout<<S<<endl;
}



Measured memory_bytes: 1672
//#include<bits/stdc++.h>
#include<iostream>
#include <vector>
using namespace std;
#define rep(i,b) for (ll i =0; i < (b); i++)
typedef long long ll;
int minimumChar(string S1, string S2) 
{ 
    int n = S1.size(), m = S2.size(); 
  
    int ans = INT_MAX; 
  
    for (int i = 0; i < m - n + 1; i++) { 
        int minRemovedChar = 0; 
        for (int j = 0; j < n; j++) { 
            if (S1[j] != S2[i + j]) { 
                minRemovedChar++; 
            } 
        } 

        ans = min(minRemovedChar, ans); 
    } 
  
    // return answer 
    return ans; 
} 
// ---** Functions **---
int main()
{
ios::sync_with_stdio(false); cin.tie(0);
// ---** START FROM HERE **---
string X,Y;
 cin>>X>>Y;
// int len1 = X.length();
// int len2 = Y.length();

// int mx=0;
// for(int i=0; i<X.length()-Y.length(); i++){
//     int cnt=0;
//     for(int j=0; j<Y.length(); j++){
//         if(X[j+i]==Y[j]) cnt++;
//     }
//     if(cnt>mx) mx=cnt;
// }

// cout<<len2-mx<<endl;


cout << minimumChar(Y, X)<<endl;








return 0;



}


Measured memory_bytes: 3136
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cstdint>
#include <cstdlib>
#include <cmath>
#include <complex>
#include <chrono>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>
#include <random>
#include <utility>
#include <limits>
#include <list>
#include <type_traits>

/* template start */
 
#define rep(i, a, b) for (long long i = (a); (i) < (b); (i)++)
#define all(i) i.begin(), i.end()

#ifdef LOCAL
#define debug(...) std::cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif

void debug_out(){std::cerr<<std::endl;}

template<typename Head,typename... Tail>
void debug_out(Head h,Tail... t){
  std::cerr<<" "<<h;
  if(sizeof...(t)>0)std::cout<<" :";
  debug_out(t...);
}
 
template <typename T1, typename T2>
std::ostream& operator<<(std::ostream& os, std::pair<T1, T2> pa) {
  return os << pa.first << " " << pa.second;
}
 
template <typename T>
std::ostream& operator<<(std::ostream& os, std::vector<T> vec) {
  for (std::size_t i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
  return os;
}
 
template<typename T1,typename T2>
inline bool chmax(T1& a,T2 b){return a<b && (a=b,true);}
 
template<typename T1,typename T2>
inline bool chmin(T1& a,T2 b){return a>b && (a=b,true);}

template<typename Num>
constexpr Num mypow(Num a, long long b) {
  if(b==0)return 1;
  if (a==0)return 0;
  Num x = 1;
  while (b > 0) {
    if(b & 1)x*=a;
    a*=a;
    b >>= 1;
  }
  return x;
}

/* template end */

using ll = long long;

using P=std::pair<ll,ll>;

void solve(){
  ll n;
  std::cin>>n;

  ll base=0;

  std::vector<P> plus,minus;

  rep(i,0,n){
    ll k,l,r;
    std::cin>>k>>l>>r;

    base+=std::min(l,r);

    if(l>=r){
      plus.emplace_back(k-1,l-r);
    }else{
      minus.emplace_back(n-1-k,r-l);
    }
  }

  std::sort(all(plus));
  std::sort(all(minus));

  debug(plus);
  debug(minus);

  std::priority_queue<ll,std::vector<ll>,std::greater<ll>> set;
  for(const auto& e:plus){
    if(set.size()<=e.first){
      set.emplace(e.second);
      base+=e.second;
    }else{
      if(set.top() < e.second){
        base-=set.top();set.pop();
        set.emplace(e.second);base+=e.second;
      }
    }
  }

  set=decltype(set)();

  for(const auto& e:minus){
    if(e.first==-1)continue;
    if(set.size()<=e.first){
      set.emplace(e.second);
      base+=e.second;
    }else{
      if(set.top() < e.second){
        base-=set.top();set.pop();
        set.emplace(e.second);base+=e.second;
      }
    }
  }

  std::cout<<base<<"\n";
}

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

  ll test;
  std::cin>>test;

  while(test--)solve();

  return 0;
}

Measured memory_bytes: 8292
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (long long  i=a;i<n;i++)
#define sz(A) (int)(A.size())
#define all(x) (x).begin(),(x).end()
#define get(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
typedef long long ll;
typedef pair<int, int> PII;
typedef vector<int> VI;
int n, k;
ll b[100000];
//区间和最大
ll solve(VI &a,int beg,int end) {
	if (beg > end)return 0;
	//int a[] = { 1,2,3,4,-5,10,-1,-1 };  // 原数组
	//int* b = (int*)malloc(sizeof(a)); // 数组b，和原数组等长

									  // 初始化
	b[beg] = a[beg];

	// 遍历构造，注意i的边界
	
	for (int i = beg; i < end; i++) {
		b[i + 1] = b[i] + a[i + 1] > a[i + 1] ? b[i] + a[i + 1] : a[i + 1];
	}

	// 然后找出b中的最大值
	ll max = b[beg];
	for (int i = beg+1; i <= end; i++)
		if (b[i] > max)
			max = b[i];
	return max;
}
void solve() {
	cin >> n >> k;
	VI a(n+1), c(n+1);
	rep(i, 0, n)cin >> a[i+1];
	rep(i, 0, n)cin >> c[i+1];
	VI vis(n+1, 0);
	vector<VI> loop;
	rep(i, 1, n+1) {
		if (vis[i])continue;
		int beg = i;
		VI lp;
		while (!vis[i]) {
			vis[i] = 1;
			lp.push_back(c[i]);
			i = a[i];
		}
		loop.push_back(lp);
	}
	ll ans = -ll(1e18);
	for (auto &lp : loop) {
		int n = sz(lp);
		ll full = 0;
		ll sum = 0;
		rep(i, 0, n)sum += lp[i];
		rep(i, 0, n)lp.push_back(lp[i]);
		for (ll i = 0; i < n; i++) {
			int end = min(i + n - 1, 1LL * sz(lp) - 1);
			full = max(full, solve(lp, i, end));
			if (end >= sz(lp) - 1) {
				break;
			}
		}
		
		if (sum > 0) {
			int K = k%n;
			
			for (ll i = 0; i < sz(lp); i++) {
				int end = min(i + K - 1, 1LL * sz(lp) - 1);
				ans = max(ans, sum*(k/n) + solve(lp, i, end));
				if (end >= sz(lp) - 1) {
					break;
				}
			}
			if(full > sum)
			if (k / n >= 1) {
				ans = max(ans, sum*(k / n - 1) + full);
			}
		}
		for (ll i = 0; i < sz(lp); i++) {
			int end = min(i + k - 1, 1LL * sz(lp) - 1);
			ans = max(ans, solve(lp, i, end));
			if (end >= sz(lp) - 1) {
				break;
			}
		}
	}
	
	cout << ans << endl;
}
int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int T_ = 1;
	//cin >> T_;
	for (int i = 0; i < T_; i++)solve();
	return 0;
}



Measured memory_bytes: 3820
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>

using namespace std;

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

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

    int h,w,cnt = 0;
    cin >> h >> w;
    char c[55][55];

    for(int i = 0; i < h; ++i){
        for(int j = 0; j < w; ++j){
            cin >> c[i][j];
            if(c[i][j] == '#') cnt++;
        }
    }

    for(int i = 0; i < h; ++i){
        for(int j = 0; j < w; ++j){
            if(c[i][j] == '#'){
                if(c[i][j-1] == '#' || c[i][j+1] == '#' || c[i - 1][j] == '#' || c[i + 1][j] == '#') cnt--;
            }
        }
    }
    
    if(cnt == 0){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
"use strict";
var input = require("fs").readFileSync("/dev/stdin", "utf8");
var cin = input.trim().split(/ |\n/), cid = 0;

main();

function main() {
    //console.log(cin);
    //   cin = cin.map(i => +i);
    let n = +cin.shift();
    let B = {};
    let C = {};
    cin.forEach((v, i) => {
        const x = Number(v);
        B[i + 1 + x] = B[i + 1 + x] + 1 || 1;
        C[i + 1 - x] = C[i + 1 - x] + 1 || 1;
    });
    //console.log({ B, C })
    let keys = Object.keys(B);
    let ans = 0;
    keys.filter(i => C[i]).forEach(i => {
        ans += (B[i] * C[i]);
        //console.log(i, B[i], C[i]);
    });


    console.log(ans);
}

Measured memory_bytes: 97888
import math
while True:
    a, op, b = input().split()
    a = int(a)
    b = int(b)
    if op == "+":
        x = a+b
        print(x)
    if op == "-":
        x = a-b
        print(x)
    if op == "*":
        x = a*b
        print(x)
    if op == "/":
        x = math.floor(a/b)
        print(x)
    if op == "?":
        break


Measured memory_bytes: 5664
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T, class C> void chmax(T& a, C b){ a>b?:a=b; }
template<class T, class C> void chmin(T& a, C b){ a<b?:a=b; }

int main(){
  rep(i,5){
    ll x; cin>>x;
    if(x==0){
      cout<<i+1<<endl;
      break;
    }
  }
}

Measured memory_bytes: 3616
import numpy as np

n = int(input())
a = np.array(list(map(int, input().split(' '))))
avg = np.mean(a)
mid_1 = np.ceil(avg)
mid_2 = np.floor(avg)
ans = int(min(((a-mid_1)**2).sum(), ((a-mid_2)**2).sum()))
print(ans)

Measured memory_bytes: 12504
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var arr=input.trim().split("\n");
while(true){
   var abc=arr.shift();
   if(abc=="0 0 0 0 0")break;
   var ary=(abc+" "+arr.shift()).split(" ").map(Number);
   (function(a,b,c,d,e,na,nb,nc){
      var ans=Math.floor(nc/d)*d*e;
      var nokori=nc%d;
      var A=(function(ans){
         ans+=nokori*c;
         ans+=na*a+nb*b;
         return ans;
      })(ans);
      var B=(function(ans,na,nb){
         if(ans==0){
            var yobun=(nokori==0)?0:d-nokori;
            if(yobun>0)ans+=e*d;
            while(yobun--){
               if(nb>0)nb--;
               else if(na>0)na--;
            }
            ans+=na*a+nb*b;
            return ans;
         }
         if(ans!=0){
            return na*a+nb*b+nc*e;
         }
      })(ans,na,nb);
      console.log(Math.min(A,B));
   }).apply(null,ary);
}

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

using namespace std;

void Main() {
    int N;
    cin >> N;
    vector<pair<int, int>> X(N, make_pair(0, 0));
    for (int i = 0; i < N; ++i) {
        cin >> X[i].first >> X[i].second;
    }

    sort(X.begin(), X.end());
    double sum = 0;
    do {
        for (int i = 1; i < N; ++i) {
            int x0 = X[i - 1].first;
            int y0 = X[i - 1].second;
            int x = X[i].first;
            int y = X[i].second;
            sum += sqrt((x - x0) * (x - x0) + (y - y0) * (y - y0));
        }
    } while (next_permutation(X.begin(), X.end()));

    for (int i = 1; i <= N; ++i) {
        sum /= (double)i;
    }
    cout << sum << endl;
}

int main() {
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 3756
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int maxN=1e5+10;
const ll MOD=1e9+7;
int n;
ll k;
ll ans[maxN];
ll res=0LL;
ll fast_mi(ll a,int p)
{
	if(p==0)return 1LL;
	ll tmp=fast_mi(a,p>>1);
	tmp=tmp*tmp%MOD;
	if(p&1)
	{
		tmp=tmp*a%MOD;
	}
	return tmp;
}
int main()
{
	cin>>n>>k;
	for(ll x=k;x>=1LL;x--)
	{
		ll multi_num=k/x;
		ll num=fast_mi(multi_num,n);
		for(int i=x+x;i<=k;i+=x)
		{
			num=(num-ans[i]+MOD)%MOD;
		}
		ans[x]=num;
		res=(res+num*x)%MOD;
	}
	cout<<res<<endl;
	return 0;
}


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

int main() {
int n;
cin >> n;
vector<int> x(n);
for(int i = 0;i<n;i++) cin >> x[i];
int ans = 1000000000;
for(int i=1;i<=100;i++){
	int cost = 0;
	for(int j=0;j<n;j++) cost += (x[j]-i)*(x[j]-i);
	ans = min(ans,cost);
}
cout << ans << endl;
return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std; 

int main(void){
static long long n,s,dp[102][11][1001];
	
	for(int i=0;i<101;i++)
	  for(int j=0;j<10;j++)
	    for(int k=0;k<1001;k++)
	    dp[i][j][k]=0;
	
  dp[0][0][0] = 1;
 
  for(int i=0;i<101;i++){
    for(int j=0;j<10;j++){
      for(int k=0;k<1001;k++){
        if(dp[i][j][k]==0) continue;
 
        dp[i+1][j][k]+=dp[i][j][k];
 
        if(8<j||1000<k+i) continue;
 
        dp[i+1][j+1][k+i]+=dp[i][j][k];
      }
    }
  }
 
  while(cin >> n >> s, n|s)
    cout << dp[101][n][s] << endl;
  return 0;
}

Measured memory_bytes: 9788
//Copied from others(for test)
#include<cstdio>
#include<algorithm>
#include<cmath>
#define fo(i,a,b) for(i=a;i<=b;i++)
using namespace std;
typedef long long ll;
const int maxn=100000+10;
int h[maxn],go[maxn*2],nxt[maxn*2],fa[maxn],co[maxn],kk[maxn],bb[maxn],sta[maxn];
bool bz[maxn];
int i,j,k,l,t,n,m,u,v,a,b,x,tot,top,num;
ll ans;
bool czy,gjx;
void add(int x,int y){
    go[++tot]=y;
    nxt[tot]=h[x];
    h[x]=tot;
}
int getfa(int x){
    if (!fa[x]) return x;
    int t=getfa(fa[x]);
    co[x]=co[x]^co[fa[x]];
    return fa[x]=t;
}
void travel(int x,int y){
    bz[x]=1;
    int t=h[x];
    while (t){
        if (go[t]!=y){
            if (bz[go[t]]){
                u=x;v=go[t];
                if (co[u]==co[v]) gjx=1;
            }
            else{
                co[go[t]]=co[x]^1;
                travel(go[t],x);
            }
        }
        t=nxt[t];
    }
}
void dfs(int x,int y){
    int t=h[x];
    while (t){
        if (go[t]!=y&&!(x==u&&go[t]==v||x==v&&go[t]==u)){
            dfs(go[t],x);
            kk[x]+=kk[go[t]];
            bb[x]+=bb[go[t]];
        }
        t=nxt[t];
    }
}
int main(){
    scanf("%d%d",&n,&m);
    fo(i,1,m){
        scanf("%d%d",&j,&k);
        add(j,k);add(k,j);
        /*a=getfa(j);b=getfa(k);
        if (a!=b){
            add(j,k);add(k,j);
            fa[a]=b;
            co[a]=co[j]^co[k]^1;
        }
        else{
            u=j;v=k;
            if (co[j]==co[k]) gjx=1;
        }*/
    }
    //fo(i,1,n) getfa(i);
    /*if (!co[1])
        fo(i,1,n) co[i]^=1;*/
    co[1]=1;
    travel(1,0);
    fo(i,1,n) 
        if (co[i]) bb[i]=1;else bb[i]=-1;
    fo(i,1,n) num+=bb[i];
    if (m==n-1){
        if (num){
            printf("-1\n");
            return 0;
        }
    }
    else{
        if (gjx){
            if (num%2==1){
                printf("-1\n");
                return 0;
            }
            bb[u]-=num/2;bb[v]-=num/2;
            ans+=(ll)abs(num/2);
        }
        else{
            if (num){
                printf("-1\n");
                return 0;
            }
            kk[u]=1;kk[v]=-1;
        }
    }
    dfs(1,0);
    fo(i,1,n)
        if (!kk[i]) ans+=(ll)abs(bb[i]);
        else{
            if (kk[i]) bb[i]=-bb[i];
            sta[++top]=bb[i];
        }
    sta[++top]=0;
    sort(sta+1,sta+top+1);
    x=sta[(top+1)/2];
    fo(i,1,top) ans+=(ll)abs(sta[i]-x);
    printf("%lld\n",ans);
}

Measured memory_bytes: 8448
#include<bits/stdc++.h>
#define mod 1000000007
using namespace std;
int main(){
    int n;
    cin>>n;
    double p[n],ans=0;
    for(int i=0;i<n;i++)
        cin>>p[i];

    double dp[n+1][n+1]={0};

    dp[0][0] = 1;
    for(int i=0;i<n;i++)
        for(int j=0;j<=i;j++)
            dp[i+1][j] += dp[i][j]*(1-p[i]),
            dp[i+1][j+1] += dp[i][j]*p[i];

    for(int j=n/2+1;j<=n;j++)
        ans += dp[n][j];

    cout <<fixed<<setprecision(10)<<ans;
}



Measured memory_bytes: 70528
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
	    Scanner sc = new Scanner(System.in);
	    int temp = sc.nextInt();
	    int returnnum = 0;
	    if (temp >= 3) {
          	int[] list = new int[temp];
	    	for (int i = 0; i < temp; i++) {
	    		int temp2 = sc.nextInt();
	    		list[i] = temp2;
	    	}
	    	Arrays.sort(list);
	    	for (int i = 0; i < temp; i++) {
	    		int wk = list[i];
	    		for (int k = i+1; k < temp; k++) {
	    			int wk2 = list[k];
	    			if (wk == wk2) continue;
		    		for (int j = k+1; j < temp; j++) {
		    			int wk3 = list[j];
		    			if (wk2 == wk3) continue;
		    			if ((wk + wk2) > wk3) {
		    				returnnum++;
		    			}
		    		}
	    		}
	    	}
	    }
	    System.out.println(returnnum);
	}
}


Measured memory_bytes: 27532
// AtCoder template
// sabaより胡蝶しのぶさんの方が可愛いのではないか？
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i = 0; i < n; ++i)

vector<ll> s_cnt(5,0LL);
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);

    int n; cin >> n;
    vector<string> s(n); rep(i,n) cin >> s[i];
    char s_list[5] = {'M', 'A', 'R', 'C', 'H'};
    
    rep(i,n){
        rep(j,5){
            if(s[i][0] == s_list[j]) s_cnt[j]++;
        }
    }

    ll ans = 0LL;
    rep(i,5){
        for(int j = i+1; j < 5; ++j){
            for(int k = j+1; k < 5; ++k){
                ans += s_cnt[i]*s_cnt[j]*s_cnt[k];
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 5760
#include <iostream>
#include <iomanip>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <math.h>
#include <sstream>
#include <numeric>
#include <string>
#include <cassert>
#include <bitset>

using namespace std;
typedef long long ll;

int main() {
  string S;
  int K;
  cin >> S >> K;
  int N = S.size();

  vector<vector<int> > dp(N, vector<int>(K + 1));
  
  // init
  dp[0][0] = 1;
  dp[0][1] = int(S[0] - '0') - 1;
  int X = 1;

  // iterate
  for (int i = 1; i < N; ++i) {
    dp[i][0] = dp[i - 1][0];
    for (int j = 1; j <= K; ++j) {
      dp[i][j] = dp[i - 1][j - 1] * 9 + dp[i - 1][j];
    }
    
    if (S[i] != '0') {
      if (X <= K) dp[i][X] += 1;
      if (X + 1 <= K) dp[i][X + 1] += (S[i] - '0') - 1;
      ++X;
    }
  }

  // terminate
  if (X <= K)  dp[N - 1][X] += 1;
  cout << dp[N - 1][K] << endl;
  
  return 0;
}


Measured memory_bytes: 256
import sys

line = sys.stdin.readline().strip()

for i in range(8):
    siki = line[0] + "+-"[(i >> 2) & 1] + line[1] + "+-"[(i >> 1) & 1] + line[2] + "+-"[(i >> 0) & 1] + line[3]
    r = eval(siki)
    if r == 7:
        print("%s=%d" % (siki, r))
        break


Measured memory_bytes: 3060
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;

public class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader br =
			new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(br.readLine());
		HashSet<Integer> set = new HashSet<>();
		String[] str = br.readLine().split(" ");
		for (int i = 0; i < n; i++) {
			set.add(Integer.parseInt(str[i]));
		}
		int q = Integer.parseInt(br.readLine());
		List<Integer> list = new ArrayList<>();
		str = br.readLine().split(" ");
		for (int i = 0; i < q; i++) {
			list.add(Integer.parseInt(str[i]));
		}
		int count = 0;
		for (Integer i : list) {
			for (Integer j : set) {
				if(i.intValue() == j.intValue()) {
					count++;
					break;
				}
			}
		}
		System.out.println(count);
	}
}


Measured memory_bytes: 28928
using System;

class SwappingTwo{
        static void Main(string[] args){
	  while(true){
	    string[] str = Console.ReadLine().Split(' ');
	    int x = int.Parse(str[0]);
	    int y = int.Parse(str[1]);
	    if(x == 0 && y == 0) break;
	    if(x > y){
	      int t = x; x = y; y = t;
	    }
	    Console.WriteLine("{0} {1}",x,y);
	  }
	}
}

Measured memory_bytes: 9324
// D - Flat Subsequence
#include <bits/stdc++.h>
using namespace std;

#include <atcoder/segtree>
int op(int a, int b){ return max(a,b); } // 処理
int e(){ return 0; } // 単位元
using MONOID = int;
using SEG_T = atcoder::segtree<MONOID, op, e>;
#define SEGT_MAX 300005

int main(){
	int n, k; cin>>n>>k;
	SEG_T seg(SEGT_MAX);
	int ans = 0;
	for(int i=0; i<n; ++i){
		int a; cin>>a;
		int l = max(0, a - k);
		int r = min(a + k + 1, SEGT_MAX);
		int longest = seg.prod(l, r); // [l,r)
		seg.set(a, longest + 1);
		ans = max(ans, longest + 1);
	}
	cout<< ans <<endl;
}


Measured memory_bytes: 8464
#include <iostream> 
using namespace std;
int main(){
      int N,c=0;
  cin>>N;
  char arr[50];
  for(int i=0;i<N;i++){
    cin>>arr[i];
  }
  for(int i=0;i<N;i++){
    if(arr[i]=='A'&&arr[i+1]=='B'&&arr[i+2]=='C')
        c+=1;
  }
  cout<<c;
 

  
return 0; 
} 


Measured memory_bytes: 256
/**
 *    author: kalyan       
**/
#include <bits/stdc++.h>
#define ll long long
#define endl '\n'
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL); 
using namespace std;
 
void solve(){
    int n;
    cin >> n;
    string str;
    cin >> str;
    int cnt=0;
    for(int i =0;i<n-2; ++i){
        if(str.substr(i,3) == "ABC") cnt++;
    }
    cout << cnt;
    
}
 
int main(){
    fastio;
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
    int t;
    t = 1;
    // cin >> t;
    while(t--){
    	solve();
    }
    return 0;
}

Measured memory_bytes: 3676
#include <stdio.h>



int checkResult(int *mat,int mat_i);

int main(void) {

	// Rummy
	int ds,ds_i;
	int num[9];
	char col[10];
	int r[9],g[9],b[9];
	int ri,gi,bi;
	int i;
	int r_check,g_check,b_check;

	// ????????????????????°????????????
	scanf("%d",&ds);

	for(ds_i=0; ds_i<ds; ds_i++){
	// ?????????????????????????????????????????????

		// ?????????
		for(i=0; i<9; i++){
			r[i]=0;
			g[i]=0;
			b[i]=0;
		}
		ri=0;
		gi=0;
		bi=0;

		// ?????????????????????
		for(i=0; i<9; i++){	scanf("%d",&num[i]);	}
		for(i=0; i<9; i++){	scanf("%1s",&col[i]);	}

		// ????????????????????¨????????????????´?
		for(i=0; i<9; i++){
			if(col[i]=='R'){
				r[ num[i]-1 ]++;
				ri++;
			}else if(col[i]=='G'){
				g[ num[i]-1 ]++;
				gi++;
			}else if(col[i]=='B'){
				b[ num[i]-1 ]++;
				bi++;
			}
		}

		// ???(R)?????????
		r_check = checkResult(r,ri);
		// ???(G)?????????
		g_check = checkResult(g,gi);
		// ???(B)?????????
		b_check = checkResult(b,bi);

		if(r_check && g_check && b_check){
			printf("1\n");
		}else{
			printf("0\n");
		}
	}

	return 0;

}

int checkResult(int *mat,int mat_i){
	int result=1;
	int i,j,wk;

	if(mat_i%3!=0){
		// ??????????????£????????????????????????????????????????????????????????????
		result = 0;
	}else if(0<mat_i){
		for(i=0; i<7; i++){
			if(0<mat[i] && 0<mat[i+1] && 0<mat[i+2]){
				wk = 10;
				for(j=0; j<2; j++){
					if(mat[i+j] < wk){
						wk=mat[i+j];
					}
				}
				mat[i+2]-=wk;
				mat[i+1]-=wk;
				mat[i]-=wk;
			}
		}
		for(i=0; i<9; i++){
			if(mat[i]==3){
				mat[i] = 0;
			}
		}
		for(i=0; i<9; i++){
			if(mat[i]!=0){
				result = 0;
			}
		}
	}
	
	return result;
}
	

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

string flag[1080];
string emblem[2];
int n, m;
int match[1080][1080];
int res;

bool isMatching(int x, int y){
	for(int i = 0;i < 2;i++){
		for(int j = 0;j < 2;j++){
			if(flag[x+i][y+j] != emblem[i][j]){
				return false;
			}
		}
	}
	return true;
}

int diff(int x, int y){
	if(x < 0 || y < 0)return 0;
	if(x >= n-1 || y >= m-1)return 0;
	return isMatching(x, y) - match[x][y];
}

int defaultCount;

int main(){
	cin >> n >> m;
	for(int i = 0;i < n;i++){
		cin >> flag[i];
	}
	for(int i = 0;i < 2;i++){
		cin >> emblem[i];
	}

	for(int i = 0;i < n-1;i++){
		for(int j = 0;j < m-1;j++){
			match[i][j] = isMatching(i,j);
			defaultCount += match[i][j];
		}
	}
	
	for(int i = 0;i < n;i++){
		for(int j = 0;j < m;j++){
			for(int k = 0;k < 3;k++){
				char c = "JOI"[k];
				char original = flag[i][j];
				flag[i][j] = c;
				int tmp = defaultCount;
				tmp += diff(i-1,j-1);
				tmp += diff(i,j-1);
				tmp += diff(i-1,j);
				tmp += diff(i,j);
				res = max(res, tmp);
				flag[i][j] = original;
			}
		}
	}

	cout << res << endl;
	return 0;	
}

Measured memory_bytes: 8328
//arc060_c.cpp
//Sat Jun 23 13:19:44 2018

#include <iostream>
#include <string>
#include <queue>
#include <unordered_map>
#include <vector>
#include <algorithm>
using namespace std;
using ll=long long;

ll dptable[51][51][2501];


int main(){
	int n,a;
	cin >> n >> a;

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


	for (int j=0;j<=n;j++){
		for (int k=0;k<=n;k++){
			for (int s=0;s<=2500;s++){
				if (j==0 && k==0 && s==0){
					dptable[j][k][s] = 1;
				}else if (j>=1 && s<x[j]){
					dptable[j][k][s] = dptable[j-1][k][s];
				}else if (j>=1 && k>=1 && s>=x[j]){
					dptable[j][k][s] = dptable[j-1][k][s] + dptable[j-1][k-1][s-x[j]];
				}else {
					dptable[j][k][s] = 0;
				}
			}
		}
	}

	ll ans = 0;

	for (int k=1;k<=n;k++){
		ans += dptable[n][k][k*a];
	}

	cout << ans << endl;
}

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

int main(){
  string s;
  cin >> s;

  int n = s.size() + 1;
  int a[n];
  for (int i = 0; i < n; i++){
    a[i] = 0;
  }

  for  (int i = 0; i < n - 1;){
    if (s.at(i) == '<'){
      a[i] = 0;
      int j = 0;
      while (i + j < n - 1 && s.at(i + j) == '<'){
        a[i + j + 1] = j + 1;
        j++;
      }
      i += j;
    }else{
      int j = 0;
      while (i + j < n - 1 && s.at(i + j) == '>'){
        j++;
      }
      a[i] = max(a[i], j);
      for (int k = 1; k <= j; k++){
        a[i + k] = j - k;
      }
      i += j;
    }
  }

  long long  ans = 0;
  for (int j = 0; j < n; j++){
    ans += a[j];
  }
  cout << ans << endl;
}

Measured memory_bytes: 2820
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<list>
#include<iomanip>
#include<cmath>
#include<cstring>
#include<functional>
#include<cstdio>
#include<cstdlib>
using namespace std;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 2e9
#define MOD 1000000007
//#define MOD 998244353
#define LINF (long long)4e18
#define jck 3.141592

const double EPS = 1e-10;

using ll = long long;
using Pi = pair<int,int>;
using Pl = pair<ll,ll>;

int main(){
  int x,y; cin >> x >> y;
  rep(i,100)rep(j,100){
    if(i+j == x && 2*i+4*j == y){
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
}


Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
#define REP(i,n) for(int i=0;i<(n);++i)
#define FOR(i,k,n) for(int i=(k);i<(n);++i)
typedef long long ll;
const ll INF = 1LL<<60;
const ll MOD = 1000000007;

inline ll add(ll x, ll y) {return (x+y)%MOD;}
inline ll mul(ll x, ll y) {return (x*y)%MOD;}
inline ll sub(ll x, ll y) {
    ll res = x - y;
    if(res < 0) res += MOD;
    return res;
}

int main(){
    ll H; cin >> H;
    int N; cin >> N;
    vector<ll> A(N);
    REP(i,N) cin >> A[i];
    ll s = 0;
    REP(i,N) s += A[i];
    if(s>=H) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 1024
n=int(input())
a=list(map(int,input().split()))
m=max(a)
d={i:0 for i in range(m+1)}
for a_ in a:
    d[a_]+=1
if m==0:
    print(d[0])
elif m==1:
    print(d[0]+d[1])
elif m==2:
    print(d[0]+d[1]+d[2])
else:
    cnt=d[0]+d[1]+d[2]
    ma=cnt
    for i in range(3,m+1):
        cnt-=d[i-3]
        cnt+=d[i]
        ma=max(ma,cnt)
    print(ma)

Measured memory_bytes: 20472
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  
  string S,T;
  cin >> S;
  cin >> T;
  
  int Ns = S.length();
  int Nt = T.length();

  int Smax = 0;
  int Smax_temp = 0;

  for (int i=0;i<Ns-Nt+1;i++){
    
    Smax_temp = 0;
    for (int j=0;j<Nt;j++){
      
      if(S[i+j]==T[j]){
        Smax_temp++;
      }
    }

    if(Smax < Smax_temp){
        Smax = Smax_temp;
    }
  }
  
  printf("%d\n", Nt-Smax);

  return 0;
}

Measured memory_bytes: 3704