akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 1e9+7,MAX = 1e5;

int main()
{
	ll h,w;
	cin >> h >> w;
	if(h==1||w==1)cout<<1<<endl;
	else	cout<<(h*w+1)/2<<endl;
	return 0;
}

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

int main()
{
    int N, D, X;
    cin >> N >> D >> X;
    vector<int> A(N);
    for (int i = 0; i < N; i++)
        cin >> A[i];
    int cnt = 0;
    for (int i = 0; i < N; i++)
    {
        int ai = A[i];
        int j = 0;
        while (j * ai + 1 <= D)
        {
            cnt++;
            j++;
        }
    }
    cout << cnt + X << endl;
    return 0;
}

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

public class Main {
  Scanner sc;

  int f(int y, int m, int d) {
    return (y - 1) * (19 * 5 + 20 * 5) + ((y - 1) / 3) * (1 * 5) + (m - 1) * 20 - (y % 3 != 0 ? (m - 1) / 2 : 0) + d;
  }

  void run() {
    int n = ni();
    for ( int i = 0; i < n; ++i ) {
      int y = ni();
      int m = ni();
      int d = ni();

      System.out.println(f(1000, 1, 1) - f(y, m, d));
    }
  }

  Main() {
    sc = new Scanner(System.in);
  }

  int ni() {
    return sc.nextInt();
  }

  public static void main(String[] args) {
    new Main().run();
  }

  void debug(Object... os) {
    System.err.println(Arrays.deepToString(os));
  }
}

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

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

const int mxN = 500005;
int N, K, p[mxN], tr[mxN*4], pos[mxN];

void build(int v, int l, int r){
	if(l == r){
		tr[v] = l;
		return;
	}
	int m = (l + r)/2;
	build(2*v, l, m);
	build(2*v + 1, m + 1, r);
	if(p[tr[2*v]] > p[tr[2*v + 1]])tr[v] = tr[2*v];
	else tr[v] = tr[2*v + 1];
}

void update(int v, int l, int r, int ind){
	if(l == r){
		p[l] = -1;
		return;
	}
	int m = (l + r)/2;
	if(ind <= m)update(2*v, l, m, ind);
	else update(2*v + 1, m + 1, r, ind);
	if(p[tr[2*v]] > p[tr[2*v + 1]])tr[v] = tr[2*v];
	else tr[v] = tr[2*v + 1];
}

int query(int v, int s, int e, int l, int r){
	if(l <= s && e <= r)return tr[v];
	int m = (s + e)/2;
	if(r <= m)return query(2*v, s, m, l, r);
	if(m + 1 <= l)return query(2*v + 1, m + 1, e, l, r);
	int v1 = query(2*v, s, m, l, r);
	int v2 = query(2*v + 1, m + 1, e, l, r);
	if(p[v1] > p[v2])return v1;
	return v2;
}

int getMax(int bk){
	if(bk < 0 || bk*K >= N)return -1;
	int ind = query(1, 0, N - 1, bk*K, min(N - 1, bk*K + K - 1));
	int ind2 = query(1, 0, N - 1, max(0, ind - K + 1), min(N - 1, ind + K - 1));
	if(ind == ind2 && p[ind] != -1)return ind;
	return -1;
}

int main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cout<<setprecision(32);

	cin>>N>>K;
	for(int i = 0; i < N; i++){
		cin>>p[i]; p[i]--;
	}
	build(1, 0, N - 1);
	priority_queue<int> pq;
	for(int i = 0; i < (N + K - 1)/K; i++){
		int tmp = getMax(i);
		if(tmp != -1)pq.push(tmp);
	}
	int ind = N - 1;
	while(!pq.empty()){
		int y = pq.top();
		pq.pop();
		if(p[y] == -1)continue;
		pos[y] = ind; ind--;
		update(1, 0, N - 1, y);
		int bucket = y/K;
		int ind = getMax(bucket);
		if(ind != -1)pq.push(ind);
		ind = getMax(bucket - 1);
		if(ind != -1)pq.push(ind);
		ind = getMax(bucket + 1);
		if(ind != -1)pq.push(ind);
	}
	for(int i = N - 1; i >= 0; i--){
		if(p[i] != -1){
			pos[i] = ind;
			ind--;
		}
	}
	for(int i = 0; i < N; i++){
		cout<<pos[i] + 1<<'\n';
	}
	

	return 0;
}

Measured memory_bytes: 15344
import math

def lcm(x, y):
    return (x * y) // math.gcd(x, y)

N, M = map(int, input().split())
S = input()
T = input()
L = lcm(N , M)
x = {}
for i in range(N):
    idx = i * (L // N)
    x[idx] = S[i]
for i in range(M):
    idx = i * (L // M)
    if idx in x and x[idx] != T[i]:
        print(-1)
        exit()
print(L)


Measured memory_bytes: 80444
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstring>
#include <cstdlib>
#include <cmath>
using namespace std;
using ll = long long;

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

    int p[8], q[8];
    for (int i = 0; i < n; i++) {
        cin >> p[i];
    }
    for (int i = 0; i < n; i++) {
        cin >> q[i];
    }

    auto f = [&](int *t) {
        int a[8];
        for (int i = 0; i < n; i++) {
            a[i] = i + 1;
        }
        int r = 0;
        do {
            if (memcmp(a, t, n * sizeof(int)) == 0) break;
            r++;
        } while (next_permutation(a, a + n));
        return r;
    };

    cout << abs(f(p) - f(q)) << endl;

    return 0;
}

Measured memory_bytes: 256
import java.io.PrintWriter
import java.util.*

fun next() = readLine()!!
fun nextInt() = next().toInt()
fun nextLong() = next().toLong()
fun nextDouble() = next().toDouble()
fun nextList() = next().split(" ")
fun nextIntList() = nextList().map(String::toInt)
fun nextLongList() = nextList().map(String::toLong)
fun nextDoubleList() = nextList().map(String::toDouble)

val pw = PrintWriter(System.out)
fun print(s: Any = "") = pw.print(s)
fun println(s: Any = "") = pw.println(s)

fun <T> Iterable<T>.join(separator: CharSequence = ", ", prefix: CharSequence = "", postfix: CharSequence = "") = joinToString(separator, prefix, postfix)
fun <T> Array<T>.join(separator: CharSequence = ", ", prefix: CharSequence = "", postfix: CharSequence = "") = joinToString(separator, prefix, postfix)

fun main(args: Array<String>) {
    main()
    pw.flush()
}

fun main() {
    val N = nextInt()
    val A = nextLongList().sorted()
    val B = nextLongList().sorted()
    val C = nextLongList().sorted()
    var ans = 0L
    for (b in B) {
        val i = A.lower_bound(b)
        val j = C.upper_bound(b)
        ans += i.toLong() * (N - j.toLong())
    }
    println(ans)
}

fun <E : Comparable<E>> List<E>.lower_bound(v: E): Int {
    val res = binarySearch(v, Comparator { o1, o2 -> if (o1 >= o2) 1 else -1 })
    return if (res >= 0) res else res.inv()
}

fun <E : Comparable<E>> List<E>.upper_bound(v: E): Int {
    val res = binarySearch(v, Comparator { o1, o2 -> if (o1 > o2) 1 else -1 })
    return if (res >= 0) res else res.inv()
}

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

using pii = pair<int,int>;
using ll = long long;
#define rep(i, j) for(int i=0; i < (int)(j); i++)
#define repeat(i, j, k) for(int i = (j); i < (int)(k); i++)
#define all(v) v.begin(),v.end()
#define debug(x) cerr << #x << " : " << x << endl

template<class T> bool set_min(T &a, const T &b) { return a > b  ? a = b, true : false; }
template<class T> bool set_max(T &a, const T &b) { return a < b  ? a = b, true : false; }
// vector
template<class T> istream& operator >> (istream &is , vector<T> &v) { for(T &a : v) is >> a; return is; }
template<class T> ostream& operator << (ostream &os , const vector<T> &v) { for(const T &t : v) os << "\t" << t; return os << endl; }
// pair
template<class T, class U> ostream& operator << (ostream &os , const pair<T, U> &v) { return os << "<" << v.first << ", " << v.second << ">"; }

const int INF = 1 << 30;
const ll INFL = 1LL << 60;


class Solver {
  public:
    int calc(int a) {
        int res = 0;
        while(a > 0) {
            res += a % 10;
            a /= 10;
        }
        return res;
    }
    bool solve() {
        int N; cin >> N;
        int ans = INF;
        repeat(a, 1, N) {
            set_min(ans, calc(a) + calc(N - a));
        }
        cout << ans << endl;
        return 0;
    }
};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    Solver s;
    s.solve();
    return 0;
}


Measured memory_bytes: 892
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstring>
#include <cstdlib>
#include <cmath>
using namespace std;
using ll = long long;

int main() {
    ll t1, t2;
    cin >> t1 >> t2;

    ll a1, a2;
    cin >> a1 >> a2;

    ll b1, b2;
    cin >> b1 >> b2;

    if (a1 < b1) {
        swap(a1, b1);
        swap(a2, b2);
    }

    ll d = (b1 * t1 + b2 * t2) - (a1 * t1 + a2 * t2);

    if (d == 0) {
        cout << "infinity" << endl;

    } else if (d < 0) {
        cout << 0 << endl;

    } else {
        ll t = (a1 * t1 - b1 * t1) / d;
        ll s = (a1 * t1 - b1 * t1) % d;
        cout << t * 2 + (s > 0) << endl;
    }

    //同じだったら必ず無限回出会うか？ T_1+T_2分後に出会うから必ず無限 同じじゃないなら無限にはならんやろ
    //a1がでかいアドバンテージは毎回dずつ小さくなる これが0になったときが最後の出会い

    return 0;
}

Measured memory_bytes: 256
#include <vector>
#include <iostream>
#include <utility>
#include <algorithm>
#include <string>
#include <deque>
#include <tuple>
#include <queue>
#include <functional>
#include <cmath>
#include <iomanip>
#include <map>
//cin.sync_with_stdio(false);
//streambuf
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
char m[22][22];
int main() {
	int w, h;
	pii pos;
	while (cin>>w>>h,w) {
		fill((char*)m, (char*)m + 22 * 22,'#');
		for (int i = 1; i <= h; i++) {
			for (int j = 1; j <= w; j++) {
				cin >> m[i][j];
				if (m[i][j] == '@')pos = pii(i, j);
			}
		}
		int sum = 1;
		queue<pair<int, int>> que;
		que.push(pos);
		while (!que.empty()) {
			int dx[] = { 1,0,-1,0 }, dy[] = { 0,1,0,-1 };
			for (int i = 0; i < 4; i++) {
				int x = que.front().second+dx[i], y = que.front().first+dy[i];
				if (m[y][x] == '.') {
					m[y][x] = '@';
					sum++;
					que.push(pii(y, x));
				}
			}
			que.pop();
		}
		cout << sum << endl;
	}
	return 0;
}

Measured memory_bytes: 3124
#include<stdio.h>
#include<math.h>
int main()
{
	int a[7];
	int n,s,w,e;
	int top,bot;
	for(int i=1;i<=6;i++)
	{
		scanf("%d",&a[i]);
	}
	n=a[5];
	w=a[4];
	s=a[2];
	e=a[3];
	top=a[1];
	bot=a[6];
	char flag;
	int temp;
	while(scanf("%c",&flag)!=EOF)
	{
		if(flag=='E')
		{
			temp=e;
			e=top;
			top=w;
			w=bot;
			bot=temp;
		}
		else if(flag=='W')
		{
		    temp=w;
			w=top;
			top=e;
			e=bot;
			bot=temp;
		}
		else if(flag=='N')
		{
		    temp=n;
			n=top;
			top=s;
			s=bot;
			bot=temp;
		}
		else if(flag=='S')
		{
		    temp=s;
			s=top;
			top=n;
			n=bot;
			bot=temp;
		}
	}
	printf("%d\n",top);
	return 0;
} 


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

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
typedef long long ll;
//typedef long long int;
const ll M = 1000000007;
ll A, B, C, D, G, H, N, L, K, P, Q, R, W, X, Y, Z;
string S, T;

signed main(){
	std::cin >> A>>B>>C>>D;
	int t,a;
	t = (C + B - 1) / B;
	a = (A + D - 1) / D;
	if (a<t){
	std::cout << "No" << std::endl;}
	else
	std::cout << "Yes" << std::endl;
}

Measured memory_bytes: 3596
def solve(a_list, b_list, c):
    ans = c
    for index in range(len(a_list)):
        ans += a_list[index] * b_list[index]
    return int(ans > 0)


def main():
    n, m, c = map(int, input().split())
    b_list = list(map(int, input().split()))

    count = 0
    for _ in range(n):
        a_list = list(map(int, input().split()))
        count += solve(a_list, b_list, c)
    print(count)


if __name__ == "__main__":
    main()


Measured memory_bytes: 3064
#include <stdio.h>

int main(int argc, const char * argv[]) {
    int i,j,x,y;;//アクセス用
    int n,m,l;
    long sum=0;
    scanf("%d %d %d",&n,&m,&l);
    
    int a[n][m];
    int b[m][l];
    long c[n][l];
    
    for(i=0;i<n;i++){
        for(j=0;j<m;j++){
            scanf("%d",&a[i][j]);
        }
    }
    
    for(i=0;i<m;i++){
        for(j=0;j<l;j++){
            scanf("%d",&b[i][j]);
        }
    }
    
    for(i=0;i<n;i++){
        for(x=0;x<l;x++){
            for(y=0;y<m;y++){
                sum=sum+a[i][y]*b[y][x];
            }
            c[i][x]=sum;
//            printf("sum:%d \n\n",c[i][x]);
            sum=0;
            
        }
    }
    
    for(i=0;i<n;i++){
        for(j=0;j<l;j++){
            printf("%ld",c[i][j]);
            if(j<l-1){
                printf(" ");
            }else{
                printf("\n");
            }
        }
    }
    
    return 0;
}



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

int main(){
	int a,b;
	cin >> a >> b;
	
	int temp = a;
	int temp2 = b;
	
	rep(i,b-1){
		a += temp*pow(10,i+1);
	}
	
	string s = to_string(a);
	
	
	rep(i,temp-1){
		b += temp2*pow(10,i+1);
	}
	
	string t = to_string(b);
	
	cout << min(s,t) << endl;
}



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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

#define SIZE 4
#define N 100000

class BigInt {
  vector<int> vi;
public:
  BigInt();
  void set(int input);
  void disp();
  BigInt operator + (const BigInt &A);
};

BigInt::BigInt() {
  REP(i, SIZE)
    vi.push_back(0);
}

void BigInt::set(int input) {
  int i=0;
  while(i < SIZE) {
    vi.at(i) = input%N;
    input /= N;
    i++;
  }
}

void BigInt::disp() {
  int n = to_string(N-1).length();
  int nn = n * SIZE;
  vector<char> str(nn);
  REP(i, SIZE) {
    int c = vi.at(i)%N;
    REP(j, n) {
      str.at((SIZE-1-i)*n + (n-1-j)) = '0' + c%10;
      c /= 10;
    }
  }
  int zero = 0;
  while(1) {
    if(zero >= nn || str.at(zero) != '0')
      break;
    zero++;
  }
  for(int i=zero; i<nn; i++) {
    cout << str.at(i);
  }
  cout << endl;
}

BigInt BigInt::operator + (const BigInt &A) {
  BigInt result;
  result.set(0);
  int temp;
  REP(i, SIZE) {
    temp = vi.at(i) + A.vi.at(i);
    result.vi.at(i) += temp%N;
    if(temp >= N && i+1 < SIZE)
      result.vi.at(i+1) += temp/N;
  }
  return result;
}

BigInt lucas(int n) {
  BigInt even, odd;
  even.set(2); odd.set(1);
  for(int i=2; i<=n; i+=2) {
    even = even + odd;
    odd = odd + even;
  }
  if(n%2==0)
    return even;
  else
    return odd;
}
  
int main()
{
  int n;
  cin >> n;
  BigInt ans;
  ans = lucas(n);
  ans.disp();
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define Rep(i,N) for(int i = 0;i < N;i++)
#define int64 long long
using namespace std;
int main(){
  int n,b;
  cin >> n;
  n--;
  int64 a[n+1][21];
  fill_n(*a,(n+1)*21,0);
  Rep(i,n){
    cin >> b;
    if(i != 0){
      Rep(j,21){
	if(a[i-1][j] != 0){
	  if(j+b <= 20)a[i][j+b] += a[i-1][j];
	  if(j-b >= 0)a[i][j-b] += a[i-1][j];
	}
      }
    }
    else a[0][b]++;
  }
  cin >> b;
  cout << a[n-1][b] << endl;
  return (0);
}

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

int main() {
  int n; cin >> n;
  int ans = 0;
  while (n != 0) {
    ans += n%10;
    n /= 10;
  }
  if (ans == 1) cout << 10 << endl;
  else cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>

int main(void)
{
  int n;
  std::string s;
  std::cin >> n;
  std::cin >> s;
  
  int count = 1;
  int prev = -1;
  for (char c : s) {
    if (prev != -1 && prev != c) {
      ++count;
    }
    prev = c;
  }
  
  std::cout << count << std::endl;
  
  return 0;
}


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

using namespace std;

#define OnlineJudge1

#define PB push_back
#define MP make_pair
#define F first
#define S second
#define EPS 1e-7
#define modulo ll (1e9 + 7)
#define debug(x) cerr << #x << " = " << (x) << '\n'
const long double PI = 3.141592653589793238L;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;

void init(){
    cin.tie(0);
    ios::sync_with_stdio(0);
#ifdef OnlineJudge
    freopen("input.in","r",stdin);
    freopen("output.in","w",stdout);
#endif
}

const int N = 105, M = 105, OO = 0x3f3f3f3f;
const ll llOO = 1e18;


string n;
int k;
ll dp[N][4][2];

ll solve(int i, int nonzero, bool ok){
    if(i == n.size())   return nonzero == k;
    if(nonzero > k) return 0;

    ll &ret = dp[i][nonzero][ok];
    if(~ret)    return ret;

    int lastDigit = n[i] - '0';
    if(ok){
        ret = solve(i + 1, nonzero, ok) + 9 * solve(i + 1, nonzero + 1, ok);
    }
    else{
        ret = solve(i + 1, nonzero, 0 < lastDigit);
        if(lastDigit > 0)
            ret += solve(i + 1, nonzero + 1, ok) + (lastDigit - 1) * solve(i + 1, nonzero + 1, 1);
    }

    return ret;
}
int main(){
    init();
    memset(dp, -1, sizeof dp);
    cin >> n >> k;
    cout << solve(0, 0, 0);
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){
    long long S, A, B;
    scanf ("%lld", &S);
    A=S/1000000000+1; B=1000000000-(S%1000000000);
    // printf("%lld, %lld\n", A, B);
    if (S==1000000000000000000) {
        A=1000000000;
        printf("%lld %d %d %lld %d %d", A, 0, 0, A, 0, 0);
    }
    else printf("%lld %d %lld %d %d %d", A, 1, B, 1000000000, 0, 0);
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll mod = 1000000007;
const ll inf = (1 << 30) - 1;
const ll infll = (1LL << 61) - 1;

ll H, W, N, ans[11];
int dx[8] = {0, 1, 1, 1, 0, -1, -1, -1}, dy[8] = {1, 1, 0, -1, -1, -1, 0, 1};

int main()
{
    scanf("%d%d%d", &H, &W, &N);
    set<pair<int, int>> st, br;
    ans[0] = (H - 2) * (W - 2);
    for (int i = 0; i < N; i++)
    {
        int y, x;
        scanf("%d%d", &y, &x);
        y--, x--;
        br.insert({y, x}), st.insert({y, x});
        for (int i = 0; i < 8; i++)
        {
            int ny = y + dy[i], nx = x + dx[i];
            if (ny < 1 || ny > H || nx < 1 || nx > W)
                continue;
            st.insert({ny, nx});
        }
    }
    for (auto &p : st)
    {
        ll y = p.first, x = p.second, cnt = 0;
        cnt += (br.find(p) != br.end());
        for (int i = 0; i < 8; i++)
        {
            int ny = y + dy[i], nx = x + dx[i];
            if (ny < 0 || ny >= H || nx < 0 || nx >= W)
            {
                cnt = -1;
                break;
            }
            cnt += (br.find({ny, nx}) != br.end());
        }
        if (cnt != -1)
            ans[cnt]++, ans[0]--;
    }
    for (int i = 0; i < 10; i++)
        cout << ans[i] << endl;
}

Measured memory_bytes: 47104
#include <vector>
#include <iostream>
#include <utility>
#include <algorithm>
#include <string>
#include <deque>
#include <queue>
#include <tuple>
#include <queue>
#include <functional>
#include <cmath>
#include <iomanip>
#include <map>
#include <set>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
#include <complex>
#include <iterator>
#include <array>
#include <memory>
#include <stack>
#define vi vector<int>
#define vvi vector<vector<int> >
#define ll long long int
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vc vector<char>
#define vs vector<string>
#define ld long double
#define INF 1e9
#define EPS 0.0000000001
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define all(in) in.begin(), in.end()
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
#define MAX 9999999
using namespace std;
typedef pair<int, int> pii;
typedef pair<double,double>pdd;
typedef pair<ll,ll>pll;
int main(){
    int N;
    while(cin>>N,N){
        //L, P, A, B, C, D, E, F, S, M;
        vector<pair<double,string>>v;
        rep(i,N){
            string l; cin>>l;
            int cost,me,wakaba,ha,hana,mi,num,value,cycle;
            cin>>cost>>me>>wakaba>>ha>>hana>>mi>>num>>value>>cycle;
            int temp_time=0;
            int temp_income=0;
            for(int i=1; i<=cycle;i++){
                if(i==1){
                    temp_time+=(me+wakaba+ha+hana+mi);
                    temp_income+=value*num-cost;
                }else{
                    temp_income+=value*num;
                    temp_time+=hana+mi;
                }
            }
            v.push_back(make_pair(-(double)temp_income/(double)temp_time,l));
        }
        sort(all(v));
        rep(i,v.size())cout<<v[i].second<<endl;
        cout<<"#"<<endl;
        
    }
}

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

long long n, K, p[5005], c[5005], ans = -1e9;
vector <long long> v;

int main() {
    cin >> n >> K;
    for (int i = 1; i <= n; i++){
        cin >> p[i];
    }
    for (int i = 1; i <= n; i++){
        cin >> c[i];
    }
    for (int i = 1; i <= n; i++){
        int now = i;
        v.clear();
        v.push_back(c[now]);
        long long tot = c[now];
        now = p[now];
        while (now != i){
            v.push_back(c[now]);
            tot += c[now];
            now = p[now];
        }
        long long k = K;
        if (tot > 0){
            long long tmp = k/v.size();
            if (tmp) tmp--;
            tot *= tmp;
            k -= tmp*v.size();
            ans = max(ans, tot);
        }
        else{
            tot = 0;
            k = min(k, (long long)v.size());
        }
        for (int j = 0; j < k; j++){
            tot += v[j%v.size()];
            ans = max(ans, tot);
        }
    }
    cout << ans << "\n";
}


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

using ll = long long;
using ull = unsigned long long;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
#define rep(i, n) REP(i, 0, n)
#define rep_rev(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#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++)
#define all(x) (x).begin(),(x).end()
ll t1,t2,t3;
const ll mod = 1000000007;
const int INF = 1e9;
const ll INFLONG = 1e18;

int main(){
    ll k;
    cin >> k;
    string str = "";
    rep(i,k){
        str += "ACL";
    }
    cout << str << endl;
}

Measured memory_bytes: 3668
#include <cstdio>
#include <vector>
#include <algorithm>
#include <cstring>
#include <deque>
using namespace std;

const int MAXN = 1e5 + 10;
int bio[ MAXN ], n, m;
vector <int> graf[ MAXN ];

int ispali(int node) {
  for(int i = 0; i < graf[ node ].size(); i++) {
    int next = graf[ node ][ i ];
    if(bio[ next ] != -1) continue;
    bio[ next ] = node;
    return ispali(next);
  }
  return node;
}

int main() {
  int a, b;
  scanf("%d%d", &n, &m);
  for(int i = 0; i < m; i++) {
    scanf("%d%d", &a, &b); a--; b--;
    graf[ a ].push_back(b);
    graf[ b ].push_back(a);
  }
  memset(bio, -1, sizeof bio);
  bio[ 0 ] = 0;
  int kraj = ispali(0), pocetak = 0;
  for(int i = 0; i < graf[ 0 ].size(); i++) {
    int next = graf[ 0 ][ i ];
    if(bio[ next ] != -1) continue;
    bio[ next ] = 0;
    pocetak = ispali(next);
    break;
  }
  deque <int> ispis1, ispis2;

  while(pocetak != 0) {
    ispis1.push_back(pocetak + 1);
    pocetak = bio[ pocetak ];
  }
  ispis1.push_back(1);
  while(kraj != 0) {
    ispis2.push_front(kraj + 1);
    kraj = bio[ kraj ];
  }
  printf("%d\n", ispis1.size() + ispis2.size());
  for(int i = 0; i < ispis1.size(); i++) printf("%d ", ispis1[ i ]);
  for(int i = 0; i < ispis2.size(); i++) printf("%d ", ispis2[ i ]);
  printf("\n");
  return 0;
}


Measured memory_bytes: 7040
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {

    Scanner sc = new Scanner(System.in);

    String s = sc.next();
    if (s.charAt(0) == s.charAt(2)) {
      System.out.println("Yes");
    } else {
      System.out.println("No");
    }

  }
}

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

int main(void){
	int n;cin >> n;
	vector<long long> a(n);
	for(int i = 0;i < n;i++)cin >> a[i];
	
	//各ビットごとに1がいくつあるかを持っておく
	int b[20]; for(int i = 0;i < 20;i++)b[i] = 0;
	
	int l,r; l = 0,r = 0;
	long long ans = 0;
	
	for(r = 0;r < n;r++){
		for(int i = 0;i < 20;i++){
			if( ((a[r] >> i)&1) == 1 ) b[i]++;
		}
		while(l <= r){
			bool check = true;
			for(int j = 0;j < 20;j++){
				if(b[j] > 1){
					check = false; break;
				}
			}
			if(check){
				ans+=r-l+1;
				break;
			}else{
				for(int j = 0;j < 20;j++){
					if( ((a[l] >> j)&1) == 1 ) b[j]--;
				}
				l++;
			}
		}
	}
	
	cout << ans << endl;
	return 0;
	
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin>>s;
  for(int i=1;i<s.size();i++){
    if(s[i-1]==s[i]){
      cout<<i<<" "<<i+1<<endl;
      return 0;
    }
  }
  if(s.size()>=3)
    for(int i=2;i<s.size();i++){
      if(s[i-2]==s[i]){
	cout<<i-1<<" "<<i+1<<endl;
	return 0;
      }
    }
  cout<<"-1 -1"<<endl;
  return 0;
}


Measured memory_bytes: 512
#include <stdio.h>
int main(void){
	int S, h, m, s;
    scanf("%d", &S);
    h = S/3600;
    m = (S-3600*h)/60;
    s = S-3600*h-60*m;
    printf("%d:%d:%d\n",h,m,s);
    return 0;
}

Measured memory_bytes: 592
n,m = map(int, input().split())
l = []
for i in range(m):
    l.append(list(map(int,input().split())))

wf=[[10**10 for i in range(n)] for j in range(n)]
for i in range(m):
    a,b,c = l[i]
    wf[a-1][b-1] = c
    wf[b-1][a-1] = c
for i in range(n):
    wf[i][i]=0
for k in range(n):
    for i in range(n):
        for j in range(n):
            wf[i][j] = min(wf[i][j],wf[i][k]+wf[k][j])

ans=0
for edge in l:
    ok=False
    for i in range(n):
        for j in range(n):
            dist = wf[i][j]
            if dist == wf[i][edge[0]-1] + edge[2] + wf[edge[1]-1][j]:
                ok=True
    if not ok:
        ans+=1
print(ans)

Measured memory_bytes: 44652
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>
#include<stack>
#include<queue>
#include<vector>
#include<algorithm>
#include<string>
#include<iostream>
#include<set>
#include<map>
#include<bitset>

using namespace std;
typedef long long ll;
#define i_7 1000000007
#define i_5 1000000005

ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    else return c+i_7;
}
typedef pair<int,int> i_i;
typedef pair<ll,ll> l_l;
#define inf 100000000/*10^8*/

////////////////////////////////////////

//[1,n]
#define max_n 100003//調節！！！！！！！！！！！！！！！！！！！！！！！！！！！！！！！！！！！！
ll bit[max_n+1],n;
ll sum(ll i){//a[1]~a[i]の和を求める
    int s=0;
    while(i>0){
        s+=bit[i];
        i-=i&-i;
    }
    return s;
}
void add(ll i,ll x){//a[i]にxを加える
    while(i<=n){
        bit[i]+=x;
        i+=i&-i;
    }
}


int main(){
    char s[200005];scanf("%s",&s[1]);
    ll len=1;while(s[len]!='\0')len++;
    len=len-1;
    ll c[26];fill(c,c+26,0);
    for(ll i=1;i<=len;i++)c[s[i]-'a']++;
    ll qqq=0;ll z=-1;
    for(ll i=0;i<=25;i++){
        if(c[i]%2==1){qqq++;z=i;}
    }
    char a[100003],b[100003];
    ll coua=1,coub=1;
    ll flag[26];fill(flag,flag+26,len/2);
    ll fb[100003];
    n=len/2+3;
    ll d[26];
    for(ll i=0;i<=25;i++)d[i]=c[i]/2;
    int e[26];fill(e,e+26,0);
    ll count=-((len/2)*(len/2+1))/2;
    if(qqq==0){
        for(ll i=1;i<=len;i++){
            ll t=s[i]-'a';
            if(d[t]>e[t]){
                count+=i;
                e[t]++;
                a[coua++]=s[i];
            }else{
                b[coub++]=s[i];
            }
        }
    }else if(qqq==1){
        for(ll i=1;i<=len;i++){
            ll t=s[i]-'a';
            if(d[t]>e[t]){
                count+=i;
                e[t]++;
                a[coua++]=s[i];
            }else if(t==z&&d[t]==e[t]){
                e[t]++;
                count+=coub-1;
            }else{
                b[coub++]=s[i];
            }
        }
       
    }else{
        cout<<-1<<endl;return 0;
    }
    
   /* for(ll i=1;i<=len/2;i++)cout<<a[i];cout<<endl;
    for(ll i=1;i<=len/2;i++)cout<<b[i];cout<<endl;
    cout<<count<<endl<<endl;*/
    
    for(ll i=1;i<=len/2;i++){
        while(b[i]!=a[flag[b[i]-'a']]){
            flag[b[i]-'a']--;
        }
        fb[i]=1+len/2-flag[b[i]-'a'];
        flag[b[i]-'a']--;
    }
    ll plus=0;
    for(ll i=1;i<=len/2;i++){
        plus+=(i-1)-sum(fb[i]);
       /* cout<<plus<<endl;*/
        add(fb[i],1);
    }
    cout<<count+plus<<endl;
    return 0;
}


Measured memory_bytes: 2176
import std;
enum inf(T)()if(__traits(isArithmetic,T)){return T.max/4;}
T scan(T=long)(){return readln.chomp.to!T;}
void scan(T...)(ref T args){auto input=readln.chomp.split;foreach(i,t;T)args[i]=input[i].to!t;}
T[] scanarr(T=long)(){return readln.chomp.split.to!(T[]);}
alias Queue=DList;auto enq(T)(ref Queue!T q,T e){q.insertBack(e);}T deq(T)(ref Queue!T q){T e=q.front;q.removeFront;return e;} 
alias Stack=SList;auto push(T)(ref Stack!T s,T e){s.insert(e);}T pop(T)(ref Stack!T s){T e=s.front;s.removeFront;return e;} 
struct UnionFind(T){T[T]u;ulong[T] rank;@property{bool inc(T e){return e in u;}auto size(){return u.keys.length;}auto dup(){T[] child=u.keys;T[] parent=u.values;auto res=UnionFind!T(child);child.each!(e=>res.add(e));size.iota.each!(i=>res.unite(child[i],parent[i]));return res;}}this(T e){e.add;}this(T[] es){es.each!(e=>e.add);}auto add(T a,T b=a){assert(b.inc);u[a]=a;rank[a];if(a!=b)unite(a,b);}auto find(T e){if(u[e]==e)return e;return u[e]=find(u[e]);}auto same(T a,T b){return a.find==b.find;}auto unite(T a,T b){a=a.find;b=b.find;if(a==b)return;if(rank[a]<rank[b])u[a]=b;else{u[b]=a;if(rank[a]==rank[b])rank[a]++;}}}
struct PriorityQueue(T,alias less="a<b"){BinaryHeap!(T[],less) heap;@property{bool empty(){return heap.empty;}auto length(){return heap.length;}auto dup(){return PriorityQueue!(T,less)(array);}T[] array(){T[] res;auto tp=heap.dup;foreach(i;0..length){res~=tp.front;tp.removeFront;}return res;}void push(T e){heap.insert(e);}void push(T[] es){es.each!(e=>heap.insert(e));}}T look(){return heap.front;}T pop(){T tp=look;heap.removeFront;return tp;}this(T e){ heap=heapify!(less,T[])([e]);}   this(T[] e){ heap=heapify!(less,T[])(e);}}
//END OF TEMPLATE

void main(){
    auto n=scan!ulong;
    auto a=scanarr!ulong;
    ulong[ulong] boss;
    a.each!(i=>boss[i-1]++);
    n.iota.map!(i=>i in boss?boss[i]:0).each!writeln;
}


Measured memory_bytes: 24728
#include<stdio.h>
#include<algorithm>
using namespace std;
int main()
{
    char s[10];
    scanf("%s", s);
    sort(s, s + 4);
    printf((s[0] == s[1] && s[1] != s[2] && s[2] == s[3])
        ? "Yes\n" : "No\n");
 }

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

using namespace std;

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

int main(void)
{
	int n;
	cin >> n;
	ll minA = 1, minB = 1;
	rep(i, n) {
		ll x, y;
		cin >> x >> y;
		ll get = max((minA - 1) / x, (minB - 1) / y);
		minA = get * x + x;
		minB = get * y + y;
	}
	cout << minA + minB << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int INF = 1000000007;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()

// #include <boost/multiprecision/cpp_dec_float.hpp>
// #include <boost/multiprecision/cpp_int.hpp>
// namespace mp = boost::multiprecision;
// using Bint = mp::cpp_int;
// using Real = mp::number<mp::cpp_dec_float<1024>>;


int main(){
    int64_t N, K;
    cin >> N >> K;
    vector<int> A(N + 1);
    for(int i = 1; i <= N; i++) cin >> A.at(i);
    

    int64_t tele = 1;
    map<int64_t, int64_t> visit;
    int64_t loop = 0;

    while(1){
        visit[tele] = loop;
        tele = A.at(tele);
        loop++;
        K--;
        if(K == 0) goto SKIP;
        // cout << tele << endl;
        // cout << K << endl;
        // cout << loop << endl << endl;
        if(visit.count(tele)){
            break;
        }

    }
    
    

    loop -= visit.at(tele);

    //cout << loop << endl;

    K = K % loop ;

    //cout << K << endl;

    rep(i, K){
        tele = A.at(tele);
    }

    SKIP:
    cout << tele << endl;
}


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

int main() {
  int N;
  string msg;
  int a[100], b[100];
  while(cin >> N && N) {
    cin >> msg;
    for(int i = 0; i < N; ++i) {
      cin >> a[i] >> b[i];
      --a[i], --b[i];
    }
    for(int i = N-1; i >= 0; --i) {
      int d = abs(a[i] - b[i]);
      msg[a[i]] = (msg[a[i]]-'a' + d)%26+'a';
      msg[b[i]] = (msg[b[i]]-'a' + d)%26+'a';
      swap(msg[a[i]], msg[b[i]]);
    }
    cout << msg << endl;
  }
  return 0;
}

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

#define ms(a,x) memset(a,x,sizeof(a))
using namespace std;

typedef long long ll;

int gcd(int a,int b){
	if(b==0)return a;
	return gcd(b,a%b);}
int lcm(int a,int b){
	return a/gcd(a,b)*b;}
	
int n,q;
int a[30],x;
int solve(int i,int m){
	if(m==0)return 1;
	if(i>=n)return 0;
	int res = solve(i+1,m)||solve(i+1,m-a[i]);
	return res;
}
int main(){
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	cin>>q;
	for(int i=0;i<q;i++){
		cin>>x;
		if(solve(0,x))cout<<"yes\n";
		else cout<<"no\n";
	}
	return 0;
}




Measured memory_bytes: 3068
S = input()

y,m,d = S.split("/")

if m.startswith("0"):
  m = m[1]

if d.startswith("0"):
  d = d[1]

m = int(m)
d = int(d)

ans = None

if m >= 5:
  ans = "TBD"
else:
  ans = "Heisei"

print(ans)

Measured memory_bytes: 3060
#include <algorithm> 
#include <iostream> 
using namespace std; 
  
long long mod=1e9+7;

long long maxProductSubarrayOfSizeK(long long A[], int n, int k) 
{ 
    sort(A, A + n); 

    long long product = 1; 

    if (A[n - 1] == 0 && (k & 1)) 
        return 0; 
  
    if (A[n - 1] <= 0 && (k & 1)) { 
        for (int i = n - 1; i >= n - k; i--) 
            product = (product*A[i])%mod; 
        return product; 
    } 
  
    int i = 0; 
  
    int j = n - 1; 

    if (k & 1) { 
        product = (product*A[j])%mod; 
        j--; 
        k--; 
    } 

    k >>= 1; 
    for (int itr = 0; itr < k; itr++) { 
  
        // product from left pointers 
        long long left_product = A[i] * A[i + 1]; 
  
        // product from right pointers 
        long long right_product = A[j] * A[j - 1]; 
  
        // Taking the max product from two choices 
        // Correspondingly changing the pointer's position 
        if (left_product > right_product) { 
            product = (product*A[i])%mod; 
            product = (product*A[i+1])%mod; 
            i += 2; 
        } 
        else { 
            product = (product*A[j])%mod; 
            product = (product*A[j-1])%mod; 
            j -= 2; 
        } 
    } 
  
    return product%mod; 
} 
  
// Driver Code to test above function 
int main() 
{ 
	int n,k;
	cin>>n>>k;
	
    long long A[n];
	for(int i=0;i<n;i++)
		cin>>A[i]; 
  	
    cout << (maxProductSubarrayOfSizeK(A, n, k)%mod +mod)%mod;
  
    return 0; 
} 

Measured memory_bytes: 5160
using System;
using System.Collections.Generic;
namespace aizu
{
    class OnlineJudge
    {
        static void Main()
        {
            int length = 0;
            List<int> input = new List<int>();
            Func<int, int, bool> Swap = new Func<int, int, bool>( (index1,index2) => {
                bool result = false;
                if(input.Count > index1 && input.Count > index2 && input[index1] < input[index2]) {
                    input[index1] = input[index1] - input[index2];
                    input[index2] = input[index2] + input[index1];
                    input[index1] = input[index2] - input[index1];
                    result = true;
                }
                return result;
            });
            while((length = int.Parse(Console.ReadLine())) != 0) {
                input.Clear();
                int count = 0;
                for(int i=0; i < length; ++i) {
                    input.Add(int.Parse(Console.ReadLine()));
                }
                for(int i=0; i < length; ++i) {
                    for(int l=length - 1; l >= i + 1; --l) {
                        count += Swap(l, l - 1) ? 1 : 0;
                    }
                }
                Console.WriteLine(count);
            }
        }
    }
}

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

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	int a,b;
	cin>>a>>b;
	double c=a/2*25;
	double d=b*10;
	int ans=-1;
	for(double i=min(c,d);(i*0.08<(a+1))&&(i*0.1<(b+1));i+=1)
	{
		if(floor(i*0.08)==a&&floor(i*0.1)==b){
			ans=floor(i);
			break;
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <queue>
#include <cmath>
#include <map>
#include <iomanip>
#include <unordered_map>

using namespace std;
typedef long long  ll;

const ll mod = 1000000007;

vector<ll> fact(200000);

ll make_fact()
{
	fact[0] = 1;
	fact[1] = 1;
	for (ll i = 2; i < 150000; i++)
	{
		fact[i] = fact[i - 1] * i;
		fact[i] %= mod;
	}
	return 0;
}


int main()
{
	make_fact();
	ll N, M;
	cin >> N >> M;
	if (abs(N - M) > 1)
	{
		cout << 0 << endl;
		return 0;
	}
	ll ans = fact[N] * fact[M];
	ans %= mod;
	if (N == M)
		ans *= 2;
	ans %= mod;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1792
# include <iostream>
# include <vector>
# include <string>
# include <stack>

using namespace std;

int main()
{
    string s, out = "";
    cin >> s;

    for(int i = 0; i < s.size(); i++) {
        if(s[i] != 'B') {
            out += s[i];
        } else if(out.size() > 0) {
            out.erase(out.size() - 1, 1);
        }
    }
    cout << out;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {

        Scanner scan = new Scanner(System.in);
            int num = scan.nextInt();

            int h = num/3600;
            int m = (num - h*3600)/60;
            int s = (num - h*3600 - m*60);

        System.out.println(h + ":" + m + ":" + s);
    }
}



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



int main() {

    long a,b,c,d;
    cin>>a>>b>>c>>d;
    long p= max(b*d,a*d);
    long q=max(a*c,b*c);
cout<< max(p,q);
	return 0;
}


Measured memory_bytes: 3604
#include <bits/stdc++.h>
 
using namespace std;
 
int n, m, sx, sy, tx, ty;
int x[1005][1005];
char y[1005][1005];
deque<pair<int, int>> q;
int dx[] = {1, -1, 0, 0};
int dy[] = {0, 0, 1, -1};
 
int main() {
	scanf("%d%d%d%d%d%d", &n, &m, &sx, &sy, &tx, &ty);
	for (int i = 1; i <= n; i++)
		scanf("%s", y[i] + 1);
	x[sx][sy] = 1;
	q.emplace_back(sx, sy);
	while (!q.empty()) {
		tie(sx, sy) = q.front();
		q.pop_front();
		for (int i = 0; i < 4; i++) {
			int ta = sx + dx[i];
			int tb = sy + dy[i];
			if (y[ta][tb] == '.' && (!x[ta][tb] || x[sx][sy] < x[ta][tb])) {
				x[ta][tb] = x[sx][sy];
				q.emplace_front(ta, tb);
			}
		}
		for (int i = sx - 2; i <= sx + 2; i++)
			for (int j = sy - 2; j <= sy + 2; j++) {
				if (y[i][j] == '.' && (!x[i][j] || x[i][j]>x[sx][sy])) {
					x[i][j] = x[sx][sy] + 1;
					q.emplace_back(i, j);
				}
			}
	}
	// for (int i = 1; i <= n; i++) {for (int j = 1; j <= m; j++) printf("%d", x[i][j]); puts("");}
	printf("%d\n", x[tx][ty] ? x[tx][ty] - 1 : -1);
}

Measured memory_bytes: 9244
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>
#include <queue>

using namespace std;

typedef long long int ll;
typedef pair<int, int> Pii;

const ll mod = 1000000007;

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

  ll n;
  cin >> n;
  vector<ll> a(n);
  for (auto &x: a) cin >> x;

  ll length = 0;
  for (auto &x: a) length += x;
  ll partial = 0;
  ll ans = (ll)9e18;
  for (int i = 0; i < n - 1; i++) {
    partial += a[i];
    ans = min(ans, abs(length - partial * 2));
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)n;i++)
 
int main()
{
  int N, M, subject=0, count, tmp=0, max=0;
  vector<string> s(111), t(111), search(111);
  string str;
  cin >> N;
  rep(i,N)
  {
    cin >> s.at(i);
    search.at(i)=s.at(i);
    rep(j,N){if(search.at(i)==s.at(j)&&i!=j)search.at(i)="";}
    subject=N;
    rep(k,N)
    {
      if(search.at(k).size()==0)
      {
        search.at(k)=search.at(k+1);
        search.at(k+1)=search.at(k+2);
        subject--;
      }
    }
  }
  cin >> M;
  rep(l,M){cin >> t.at(l);}
  rep(i,subject)
  {
    str=search.at(i);
    tmp=max;
    count=0;
    rep(j,N){if(s.at(j)==str){count++;}}
    rep(k,M){if(t.at(k)==str){count--;}}
    if(tmp<count){max=count;}
  }
  cout << max << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
    long long N,K,Q;
    cin >> N >> K >> Q;
    vector<long long> A(Q);
    for(long long i = 0; i < Q; i++){
        cin >> A[i];
    }
    
    vector<long long> Score(N);
    for(long long i = 0; i < N; i++){
        Score[i] = K - Q;
    }
    
    for(long long i = 0; i < Q; i++){
        Score[A[i] - 1]++;
    }
    
    for(long long i = 0; i < N; i++){
        if(Score[i] > 0) cout << "Yes" << endl;
        else cout << "No" << endl;
    }
}


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

int main(){
	/*
	int a,b,c,d,e;

	cin >> a >> b >> c >> d >> e;

	int x;

	if(a > 0){
		x = e*(b-a);
	}
	if(a == 0){
		x = e*b + d;
	}
	if(a < 0){
		x = -c*a + e*b + d;
	}

	cout << x <<endl;
	*/

	
	int a,b,c,d,e,f;
	cin >> a >> b >> c >> d >> e >> f;
	int m,n;
	int x = a + b + c + d + e + f;


	
	if(e<f)
	{
		x = x - e;
		if(a<b)
		{
			if(a<c)
			{
				if(a<d)
				{
					cout << x-a << endl;
				}
				else
				{
					cout << x-d << endl;
				}
			}
			else
			{
					if(c<d)
				{
					cout << x-c << endl;
				}
				else
				{
					cout << x-d << endl;
				}
			}
		}
		else
		{
			if(b<c)
			{
				if(b<d)
				{
					cout << x-b << endl;
				}
				else
				{
					cout << x-d << endl;
				}
			}
			else
			{
					if(c<d)
				{
					cout << x-c << endl;
				}
				else
				{
					cout << x-d << endl;
				}
			}
		}
	}
	else
	{
		x = x - f;
		if(a<b)
		{
			if(a<c)
			{
				if(a<d)
				{
					cout << x-a << endl;
				}
				else
				{
					cout << x-d << endl;
				}
			}
			else
			{
					if(c<d)
				{
					cout << x-c << endl;
				}
				else
				{
					cout << x-d << endl;
				}
			}
		}
		else
		{
			if(b<c)
			{
				if(b<d)
				{
					cout << x-b << endl;
				}
				else
				{
					cout << x-d << endl;
				}
			}
			else
			{
					if(c<d)
				{
					cout << x-c << endl;
				}
				else
				{
					cout << x-d << endl;
				}
			}
		}
	}
	


	return 0;
}



Measured memory_bytes: 3080
#include <string>
#include <vector>
#include <map>
#include <set>
#include <deque>
#include <iostream>
#include <functional>
#include <algorithm>
#include <sstream>
#include <iterator>
#include <cmath>
#include <limits>
#include <tuple>
#include <queue>
#include <stack>
#include <array>

using namespace std;
typedef long long ll;
int main()
{
	int N;
	cin >> N;
	vector<vector<int>> A(2, vector<int>(N));
	for (int i = 0; i < 2; i++) {
		for (int j = 0; j < N; j++) {
			cin >> A[i][j];
		}
	}
	vector<vector<int>> S(A);
	for (int j = 0; j < N; j++) {
		if (j > 0)
			S[0][j] += S[0][j - 1];
		int k = N - j - 1;
		if (k < N - 1)
			S[1][k] += S[1][k + 1];
	}
	int ans = 0;
	for (int j = 0; j < N; j++) {
		ans = max(ans, S[0][j] + S[1][j]);
	}
	cout << ans << endl;
	return 0;
}


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

#define rep(i, n) for(int i = 0; i < (n); i++)
#define all(a) (a).begin(),(a).end()
#define SORT(a) sort(all(a))
#define rSORT(a, i) sort(all(a),(i))

using ll = long long;
constexpr ll INF = 10000000000;
constexpr ll MOD = 1000000007;

using namespace std;

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

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

	map <ll, ll>al;

	//aを素因数分解する mp[(約数)]==その素因数の個数
	for (ll i = 2; i * i <= a; i++) {
		while (a % i == 0) {
			al[i]++;
			a = a / i;
		}
	}

	//もしもaが素数だった時にカウント
	if (a != 1)al[a] = 1;
	
	map<ll, ll>bl;

	//bを素因数分解
	for (ll i = 2; i * i <= b; i++) {
		while (b % i == 0) {
			bl[i]++;
			b = b / i;
		}
	}
	//同じ
	if (b != 1)bl[b] = 1;

	ll ans = 1;
	for (auto i : al) {
		if (bl[i.first] >= 1) {
			ans++;
		}
	}
	cout << ans << "\n";
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int k,n;cin>>k>>n;
	int a[n];for(int &i:a) cin>>i;
	int mi=INT_MAX;
	for(int i=0;i<n;i++){
		int begin=i,end=(i+n-1)%n;
		if(a[end]<a[begin])
			mi=min(mi,a[end]+k-a[begin]);
		else
			mi=min(mi,a[end]-a[begin]);
	}
	cout<<mi;
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define ll long long
#define _GLIBCXX_DEBUG
const ll MOD = 1000000007;
const int MAX = 510000;

int main() {
  int N;
  cin >> N;
  vector<int> X(N);
  for (int i=0; i<N; i++) cin >> X[i];
  vector<int> Y = X;
  sort(X.begin(), X.end());
  for (int i=0; i<N; i++) {
    if (Y[i]<X[N/2]) cout << X[N/2] << endl;
    else cout << X[N/2-1] << endl;
  }
}

Measured memory_bytes: 3712
#include <bits/stdc++.h>
#define ull unsigned long long
#define ll long long
#define il inline
#define db double
#define ls rt << 1
#define rs rt << 1 | 1
#define pb push_back
#define mp make_pair
#define pii pair<int, int>
#define X first
#define Y second
#define pcc pair<char, char>
#define vi vector<int>
#define vl vector<ll>
#define rep(i, x, y) for(int i = x; i <= y; i ++)
#define rrep(i, x, y) for(int i = x; i >= y; i --)
#define rep0(i, n) for(int i = 0; i < (n); i ++)
#define per0(i, n) for(int i = (n) - 1; i >= 0; i --)
#define ept 1e-9
#define INF 0x3f3f3f3f
#define sz(x) (x).size()
#define ALL(x) (x).begin(), (x).end()
using namespace std;
inline int read()
{
	int x = 0, f = 1; char ch = getchar();
	while (ch < '0' || ch > '9') { if (ch == '-') f = -1; ch = getchar(); }
	while (ch >= '0' && ch <= '9') { x = x * 10 + ch - '0'; ch = getchar(); }
	return x * f;
}
inline ll read1()
{
	ll x = 0, f = 1; char ch = getchar();
	while (ch < '0' || ch > '9') { if (ch == '-') f = -1; ch = getchar(); }
	while (ch >= '0' && ch <= '9') { x = x * 10 + ch - '0'; ch = getchar(); }
	return x * f;
}
const int N= 610;

int col[N][N];
bool flag[N][N];
int cnt[2];
int n,d1,d2;
vector<pii> G1,G2;

il void dfs(int x,int y,int c,vector<pii> &dt){
	if(flag[x][y]) return;
	if(~col[x][y]){
		assert(col[x][y]==c);
		return;
	}
	col[x][y]=c;
	++cnt[c];
	rep0(i,dt.size()){
		int nx=x+dt[i].X,ny=y+dt[i].Y;
		if(nx<0||nx>=(n<<1)||ny<0||ny>=(n<<1)) continue;
		dfs(nx,ny,c^1,dt);
	}
}

int main(){
	n = read();
	d1 = read();
	d2 = read();
	rep0(i,n<<1){
		rep0(j,n<<1){
			int d=i*i+j*j;
			if(d==d1){
				G1.pb(mp(i,j));
				if(j) G1.pb(mp(i,-j));
				if(i) G1.pb(mp(-i,j));
				if(i&&j) G1.pb(mp(-i,-j));
			}
			if(d==d2){
				G2.pb(mp(i,j));
				if(j) G2.pb(mp(i,-j));
				if(i) G2.pb(mp(-i,j));
				if(i&&j) G2.pb(mp(-i,-j));
			}
		}
	}
	cnt[0]=cnt[1]=0;
	rep0(i,n<<1) rep0(j,n<<1) col[i][j]=-1;
	rep0(i,n<<1){
		rep0(j,n<<1){
			if(~col[i][j]) continue;
			dfs(i,j,0,G1);
		}
	}
	if(cnt[0]<cnt[1]){
		rep0(i,n<<1) rep0(j,n<<1) if(col[i][j]==0) flag[i][j]=true;
	}else{
		rep0(i,n<<1) rep0(j,n<<1) if(col[i][j]==1) flag[i][j]=true;
	}
	cnt[0]=cnt[1]=0;
	rep0(i,n<<1) rep0(j,n<<1) col[i][j]=-1;
	rep0(i,n<<1){
		rep0(j,n<<1){
			if(flag[i][j]||~col[i][j]) continue;
			dfs(i,j,0,G2);
		}
	}
	int rest=n*n;
	if(cnt[0]>cnt[1]){
		rep0(i,n<<1){
			rep0(j,n<<1){
				if(!flag[i][j]&&col[i][j]==0){
					printf("%d %d\n",i,j);
					--rest;
				}
				if(!rest) break;
			}
			if(!rest) break;
		}
	}else{
		rep0(i,n<<1){
			rep0(j,n<<1){
				if(!flag[i][j]&&col[i][j]==1){
					printf("%d %d\n",i,j);
					--rest;
				}
				if(!rest) break;
			}
			if(!rest) break;
		}
	}
	return 0;
}



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

void p(int* n,int m)
{
    for (int i = 0; i < m; i++, n++)
        cout << *n << (i<m-1?" ":"\n");
}

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

    for (int i = 0; i < a; i++)
    {
        int v = n[i];
        int j = i - 1;
        while (j >= 0 && n[j] > v)
            n[j + 1] = n[j--];
        n[j+1] = v;
        p(n, a);
    }
}



Measured memory_bytes: 3024