akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;
int main()
{
    int n;
    cin >> n;
    vector<int> S(n);
    for (int i = 0; i < n; i++)
    {
        cin >> S[i];
    }
    int q;
    cin >> q;
    vector<int> T(q);
    for (int i = 0; i < q; i++)
    {
        cin >> T[i];
    }
    cout << count_if(T.begin(), T.end(), [S](int x) {
        return find(S.begin(), S.end(), x) != S.end();
    }) << endl;
}


Measured memory_bytes: 3188
import sys

sys.setrecursionlimit(10**7)
def I(): return int(sys.stdin.readline().rstrip())
def MI(): return map(int,sys.stdin.readline().rstrip().split())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))  #空白あり
def LI2(): return list(map(int,sys.stdin.readline().rstrip()))  #空白なし
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())  #空白あり
def LS2(): return list(sys.stdin.readline().rstrip())  #空白なし


X,Y,Z,K = MI()
A,B,C = LI(),LI(),LI()
A.sort(reverse=True)
B.sort(reverse=True)
C.sort(reverse=True)

ANS = []
for i in range(X):
    if i >= K:
        break
    a = A[i]
    for j in range(Y):
        if i*j >= K:
            break
        b = B[j]
        for k in range(Z):
            if i*j*k >= K:
                break
            c = C[k]
            ANS.append(a+b+c)

ANS.sort(reverse=True)
print(*ANS[:K],sep='\n')


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

int main()
{
    int R = 0;
    int B = 0;
    int W = 0;
    int G = 0;
    
    cin >> R;
    cin >> B;
    cin >> W;
    cin >> G;
    cout << R + B + W + G << endl;
    return 0;
}


Measured memory_bytes: 3112
#include <vector> 
#include <list> 
#include <map> 
#include <set> 
#include <deque> 
#include <queue> 
#include <stack> 
#include <bitset> 
#include <algorithm> 
#include <functional> 
#include <numeric> 
#include <utility> 
#include <sstream> 
#include <iostream> 
#include <iomanip> 
#include <cstdio> 
#include <cmath> 
#include <cstdlib> 
#include <cctype> 
#include <string> 
#include <cstring> 
#include <ctime> 

using namespace std;

#define _int64 long long

int main()
{
  _int64 n,m,ans;
  scanf("%lld%lld",&n,&m);
  ans=n;
  if (m/2<ans) ans=m/2;
  n-=ans;
  m-=ans*2;
  if (m>0)
  {
    ans+=m/4;
  }
  printf("%lld\n",ans);
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <string.h>
#include <math.h>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <algorithm>
#include <utility>
#include <deque>
#include <queue>
#include <functional>
//#include <boost/multiprecision/cpp_int.hpp>

#define rep(i, n) for(int i = 0; i < n; ++i)
#define REP(i, m, n) for(int i = m; i < n; ++i)
#define rrep(i,n) for(int i = n; i >= 0; --i)
#define RREP(i, m, n) for(int i = n; i >= m; --i)
#define llrep(i, n) for(ll i = 0; i < n; ++i)
#define llREP(i, m, n) for(ll i = m; i < n; ++i)
#define llrrep(i,n) for(ll i = n; i >= 0; --i)
#define llRREP(i, m, n) for(ll i = n; i >= m; --i)

using ll = long long;
using ull = unsigned long long;
using pii = std::pair<int, int>;
using pll = std::pair<long long, long long>;
using pil = std::pair<int, long long>;
using pli = std::pair<long long, int>;
using plpii = std::pair<long long, std::pair<int, int>>;
using pdd = std::pair<double, double>;

const long long INF = 1000000000000000001;
const long long _MOD = 1000000007;
const long long MOD = 998244353;
const int ALPHABET = 27;
const double pi = 3.14159265358979;

using namespace std;
//namespace mp = boost::multiprecision;

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

	vector<char> ans;
	while (n != 0) {
		--n;
		ans.push_back(static_cast<char>('a' + n % 26));
		n /= 26;
	}
	rep(i, ans.size()) {
		cout << ans[ans.size() - 1 - i];
	}

	cout << "\n";

	return 0;
}

Measured memory_bytes: 3648
import java.util.*;

public class Main {
	private void doit(){
		Scanner sc = new Scanner(System.in);
		while(sc.hasNext()){
			int n = sc.nextInt();
				int mid, left = 0, right = n;
				while(left < right){
					mid = (right + left) / 2;
					long sum = (long)(1 + mid) * mid / 2;
					
					if(sum < n){
						left = mid + 1;
					}
					else{
						right = mid;
					}
				}
				System.out.println(left);			
		}
	}

	private void debug(Object... o) {
		System.out.println("debug = " + Arrays.deepToString(o));
	}

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

}


Measured memory_bytes: 23892
#include <stdio.h>

int main(int argc, const char * argv[]) {
    int h, m, s, S;
    
    scanf("%d", &S);
    
    h = S / 3600;
    m = (S - h * 3600) / 60;
    s = S - (h * 3600 + m * 60);
    
    printf("%d:%d:%d\n", h, m, s);
    
    return 0;
}


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

using ll = long long;
using ii = pair<int, int>;
using vi = vector<int>;
#define all(v) (v).begin(), (v).end()
#define sz(v) (int) (v).size()

int main(int argc, char* argv[]) {
  ios::sync_with_stdio(0); cin.tie(0);
  int h, w, k;
  cin >> h >> w >> k;
  vector<vector<char>> mat(h, vector<char>(w));
  int black = 0;
  for (int i = 0; i < h; i++)
    for (int j = 0; j < w; j++) {
      cin >> mat[i][j];
      black += mat[i][j] == '#';
    }
  int res = 0;
  for (int i = 0; i < (1 << h); i++) 
  for (int j = 0; j < (1 << w); j++) {
    int cnt = 0;
    for (int a = 0; a < h; a++) 
    for (int b = 0; b < w; b++) {
      if (((i & (1 << a)) || (j & (1 << b))) && mat[a][b] == '#')
        ++cnt;
    }
    res += black - cnt == k;
  }   
  cout << res << '\n';
  return 0;
}

Measured memory_bytes: 3604
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        if (n < 10) {
            System.out.println(n);
            return;
        }
        int[][] field = new int[10][10];
        for (int i = 1; i < 10; i++) {
            field[i][i]++;
        }
        int base = 10;
        int top = 1;
        int level = 1;
        while (base <= n) {
            for (int j = 1; j <= level; j++) {
                for (int i = 0; i < 10 && base <= n; i++) {
                    field[top][i]++;
                    base++;
                }
            }
            top++;
            if (top == 10) {
                top = 1;
                level *= 10;
            }
        }
        long count = 0;
        for (int i = 1; i < 10; i++) {
            for (int j = 1; j < 10; j++) {
                count += field[i][j] * field[j][i];
            }
        }
        System.out.println(count);
    }
}

Measured memory_bytes: 23124
import copy
import collections

n = int(input())
stones = list(input())
c_stones = copy.copy(stones)
R_count = collections.Counter(c_stones)['R']
if R_count ==0:
  print(0)
else:
  c_stones.reverse()
  last_R = len(c_stones)-c_stones.index("R")
  R_left_count = stones[:R_count].count("R")
  print(R_count - R_left_count)


Measured memory_bytes: 13976
#include <stdio.h>

int main(void) {
	int a, b;
	
	scanf("%d %d", &a, &b);
	
	if(a > b) {
		printf("a > b\n");
	} else if (a < b) {
		printf("a < b\n");
	} else {
		printf("a == b\n");
	}
	
	return 0;
}

Measured memory_bytes: 580
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <sstream>
using namespace std;

#define Vint vector<int>
#define VVint vector<Vint>
#define Fsize() front().size()

int VVint_zero(VVint vv) {
	int num = 0;
	for (int i = 0; i < (int)vv.size(); i++) {
		for (int j = 0; j < (int)vv.Fsize(); j++) {
			if (vv[i][j] == 0) num++;
		}
	}
	return num;
}

int VVint_max(VVint vv) {
	int max = 0;
	for (int i = 0; i < (int)vv.size(); i++) {
		for (int j = 0; j < (int)vv.Fsize(); j++) {
			if (vv[i][j] > max) max = vv[i][j];
		}
	}
	return max;
}

int main() {
	int x, y, s;
	char cha;
	string str, str_x, str_y, str_s;
	VVint vec(10, Vint(10, 0));
	while (cin >> x >> cha >> y >> cha >> s) {
		vec[y][x] += 1;
		if (y - 1 >= 0) vec[y - 1][x]++;
		if (y + 1 < 10) vec[y + 1][x]++;
		if (x - 1 >= 0) vec[y][x - 1]++;
		if (x + 1 < 10) vec[y][x + 1]++;
		if (s >= 2) {
			if (y - 1 >= 0 && x - 1 >= 0) vec[y - 1][x - 1]++;
			if (y - 1 >= 0 && x + 1 < 10) vec[y - 1][x + 1]++;
			if (y + 1 < 10 && x - 1 >= 0) vec[y + 1][x - 1]++;
			if (y + 1 < 10 && x + 1 < 10) vec[y + 1][x + 1]++;
		}
		if (s == 3) {
			if (y - 2 >= 0) vec[y - 2][x]++;
			if (y + 2 < 10) vec[y + 2][x]++;
			if (x - 2 >= 0) vec[y][x - 2]++;
			if (x + 2 < 10) vec[y][x + 2]++;
		}
	}
	cout << VVint_zero(vec) << endl;
	cout << VVint_max(vec) << endl;
	return 0;
}


Measured memory_bytes: 3088
fn get_line() -> String {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().to_string()
}

fn reads<T>() -> Vec<T>
    where
        T: std::str::FromStr,
        <T as std::str::FromStr>::Err: std::fmt::Debug {
    get_line().split(' ').map(|x| x.parse().unwrap()).collect()
}

use std::cmp;

fn main() {
    let nzw: Vec<i64> = reads();
    let xs: Vec<i64> = reads();
    let n = nzw[0] as usize;

    let mut vxs = vec![0; n + 1];
    let mut vys = vec![0; n + 1];
    for (i, &x) in xs.iter().enumerate() {
        vxs[i + 1] = x;
        vys[i + 1] = x;
    }

    vxs[0] = nzw[1];
    vys[0] = nzw[2];

    let mut txs = vec![vec![0i64; n + 1]; n];
    let mut tys = vec![vec![0i64; n + 1]; n];

    for i in 0..(n + 1) {
        txs[n - 1][i] = (vxs[n] - vys[i]).abs();
        tys[n - 1][i] = (vxs[i] - vys[n]).abs();
    }

    for i in 1..n {
        let i = n - 1 - i;

        for j in 0..(n + 1) {
            txs[i][j] = cmp::max(
                txs[i + 1][j], tys[i + 1][i + 1]
            );
            tys[i][j] = cmp::min(
                tys[i + 1][j], txs[i + 1][i + 1]
            );
        }
    }

    println!("{}", txs[0][0]);
}

Measured memory_bytes: 86396
// In His Name

#include <bits/stdc++.h>

#define pb push_back
#define F first
#define S second
#define gcd __gcd
#define int long long
#define ull unsigned long long

using namespace std;

typedef pair<int, int> pii;

const int MAX = 500, INF = 1e18;
int n, a[MAX], PartialSum[MAX], dp[MAX][MAX];

main (){
	cin >> n;
	for (int i = 0 ; i < n ; i++){
		cin >> a[i];
	}
	for (int i = 1 ; i <= n ; i++){
		PartialSum[i] = a[i - 1] + PartialSum[i - 1];
	}
	for (int i = 1 ; i < n ; i++){
		for (int l = 0 ; l + i < n ; l++){
			int r = l + i;
			if (r == l + 1){
				dp[l][r] = a[l] + a[r];
				continue;
			}
			dp[l][r] = INF;
			for (int j = l ; j < r ; j++){
				dp[l][r] = min (dp[l][r] , dp[l][j] + dp[j + 1][r] + PartialSum[r + 1] - PartialSum[l]);
			}
		}
	}
	cout << dp[0][n - 1];
}

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

// 比較演算子を自動生成
#define CAT(a, b) a ## b
#define COMP_1(v1) return lhs.v1 < rhs.v1
#define COMP_2(v1, ...) if (lhs.v1 != rhs.v1) COMP_1(v1); COMP_1(__VA_ARGS__)
#define COMP_3(v1, ...) if (lhs.v1 != rhs.v1) COMP_1(v1); COMP_2(__VA_ARGS__)
#define COMP_4(v1, ...) if (lhs.v1 != rhs.v1) COMP_1(v1); COMP_3(__VA_ARGS__)
#define COMP_5(v1, ...) if (lhs.v1 != rhs.v1) COMP_1(v1); COMP_4(__VA_ARGS__)
#define LESS_THAN(n, ...) bool operator<(const A & rhs) const { auto& lhs = *this; CAT(COMP_, n)(__VA_ARGS__); }

#define MAXC(c, x) (c = max(c, x))
#define MINC(c, x) (c = min(c, x))

#define FOR(i, s, n) for(ll i = (s); i < (ll)(n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(c) (c).begin(), (c).end()

// 10^x (by math)
#define TEN(x) ((ll)1e##x)

using ll = long long;
using vl = vector<ll>;
using vvl = vector<vl>;
using vvvl = vector<vvl>;

void solution(istream& cin, ostream& cout) {
	ll n; cin >> n;
	vector<string> dict(10);
	dict[0] = dict[1] = dict[6] = dict[8] = "pon";
	dict[2] = dict[4] = dict[5] = dict[7] = dict[9] = "hon";
	dict[3] = "bon";
	cout << dict[n % 10] << endl;
}

int main() {
#ifdef INPUT_FROM_FILE
	ifstream cin("sample.in");
	ofstream cout("sample.out");
#endif
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(50);

	solution(cin, cout);
}


Measured memory_bytes: 3600
import java.util.Scanner;

public class Main {
  public static void main(final String[] args) {
    Scanner sc = new Scanner(System.in);
    String s = sc.next();
    sc.close();

    String o = "Yes";
    if (s.equals("AAA")) {
      o = "No";
    } else if (s.equals("BBB")) {
      o = "No";
    }

    System.out.println(o);
  }
}

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

int main() {
    string s;
    int cnt = 0;
    cin >> s;
    for (auto i = 0; i < s.size() / 2; i++) {
        if(s.at(i) != s.at(s.size() - 1 - i)){
            cnt++;
        }
    }
    cout << cnt << endl;
}

Measured memory_bytes: 3536
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdio>
#include <cmath>
#include <deque>
using namespace std;

#define REP(i,n) for(int i = 0; i < (int)(n); i++)
typedef long long ll;
typedef pair<int, int> pint;

const int SIZE = 200000	+ 10;
int cnt[SIZE][2];

bool solve() {
  int N, M; cin>>N>>M;
  string s; cin>>s;
  vector<int> mark(N);
  vector<vector<int> > edges(N);
  REP(i,N) {
    mark[i] = (s[i] == 'A' ? 0 : 1);
  }
  REP(i,M) {
    int a, b; cin>>a>>b; a--; b--;
    edges[a].push_back(b);
    edges[b].push_back(a);
    cnt[a][mark[b]]++;
    cnt[b][mark[a]]++;
  }
  deque<int> q;
  REP(i,N) {
    if(cnt[i][0] == 0 || cnt[i][1] == 0) q.push_back(i);
  }

  vector<bool> used(N, false);
  while(! q.empty()) {
    int cur = q.front();
    q.pop_front();
    //    cout << cur << "," << used[cur] << endl;                             
    if(used[cur]) continue;
    used[cur] =	true;
    REP(i, edges[cur].size()) {
      int to = edges[cur][i];
      cnt[to][mark[cur]]--;
      if(cnt[to][mark[cur]] == 0) {
	if(used[to] == false) q.push_back(to);
      } 
    }
  }
  REP(i,N) {
    //    cout << i << " " << used[i] << endl;                                 
    if(used[i] == false) return	true;
  }
  return false;
}

int main() {
  bool ans = solve();
  cout << (ans ? "Yes" : "No") << endl;
  return 0;
}


Measured memory_bytes: 12932
H,W,K = map(int,input().split())
s = [input() for _ in range(H)]

a = [[0]*W for _ in range(H)]

cnt = 0

for h in range(H):
    for w in range(W):
        if s[h][w] == '#':
            cnt += 1
            a[h][w] = str(cnt)
            h_ = h-1
            while h_>=0 and a[h_][w]==0 and s[h_][w]=='.':
                a[h_][w] = str(cnt)
                h_ -= 1
            h_ = h+1
            while h_<=H-1 and a[h_][w]==0 and s[h_][w]=='.':
                a[h_][w] = str(cnt)
                h_ += 1

for h in range(H):
    for w in range(W):
        if a[h][w] != 0:
            cnt = int(a[h][w])
            w_ = w-1
            while w_>=0 and a[h][w_]==0:
                a[h][w_] = str(cnt)
                w_ -= 1
            w_ = w+1
            while w_<=W-1 and a[h][w_]==0:
                a[h][w_] = str(cnt)
                w_ += 1
    

for h in range(H):
    print(' '.join(a[h]))

Measured memory_bytes: 52464
n = int(input())
a = list(map(int,input().split()))
aa = []
for i in range(n):
    aa.append(a[i]-(i+1))
b = (sorted(aa)[n//2])

ans = 0
for i in range(n):
    ans += abs(a[i]-(b+i+1))
print(ans)

Measured memory_bytes: 26180
#ifdef LOCAL
#include "libs/debug/print_list.hpp"
#define D(x) (cout << # x ": " << x << endl)
#define dev(v, m, n) for(int i=0;i<n;++i){for(int j=0;j<m;++j){cout<<"|"<<v[j][i];}cout<<"|"<<endl;}
#else
#define D(x) ;
#define dev(v, m, n) ;
#endif

// :----------------------------------------

#include <algorithm>
#include <cassert>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <list>
#include <numeric>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <vector>

using namespace std;

#define int long long int
#define rep(i, n) for (int i = 0; i < n; ++i)
#define all(x) (x).begin(), (x).end()
#define capi(x) int x;cin>>x
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define mp(x, y) make_pair(x, y)

using vi = vector<int>;
using pi = pair<int, int>;
using vp = vector<pi>;
using Graph = vector<vector<int>>;

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(b<a){a=b;return 1;}return 0;}

#define P (1'000'000'007)

signed main() {
    int n, C;
    cin >> n >> C;

    deque<pi> q[30];
    vector<tuple<int, int, int>> vt;
    
    rep(i, n) {
        int s, t, c;
        cin >> s >> t >> c;
        --c;
        vt.push_back(make_tuple(s, t, c));
    }

    sort(all(vt), [](const auto& lhs, const auto& rhs) { return get<0>(lhs) < get<0>(rhs); });

    for (auto x: vt) {
        auto s = get<0>(x);
        auto t = get<1>(x);
        auto c = get<2>(x);
        if (q[c].empty()) {
            q[c].push_front(mp(s, t));
        } else {
            if (s == q[c].back().second) {
                q[c].back().second = t;
            } else {
                q[c].push_back(mp(s, t));
            }
        }
    }

    vp v;

    rep(i, C) {
        for (auto x: q[i]) {
            v.push_back(x);
        }
    }


    sort(all(v), [](const auto& lhs, const auto& rhs){ return lhs.first < rhs.first; });

    multiset<int> ms;
    ms.insert(0);

    for (auto x: v) {
        bool f = true;
        for (auto it = ms.begin(); it != ms.end(); ++it) {
            if (*it < x.first) {
                ms.erase(it);
                ms.insert(x.second);
                f = false;
                break;
            }
        }

        if(f) ms.insert(x.second);
    }

    cout << ms.size();
    
    return 0;
}


Measured memory_bytes: 10492
using System;
using System.Linq;
using System.Collections.Generic;

public class BinarySearch{
	public static void Main()
	{
		Console.ReadLine();
		var sList = ReadLineAndToIntList();
		Console.ReadLine();
		var tList = ReadLineAndToIntList();
	
		int count = 0;
	
		tList.ForEach(t =>
		{
			if(sList.BinarySearch(t) > -1) count++;
		});
		
		Console.WriteLine(count);
	}
	
	//??????????????????????????????
	public static List<int> ReadLineAndToIntList()
	{
		return Console.ReadLine().Split().Select (c => {
			int num;
			int.TryParse(c, out num);
			return num;
		}).ToList();
	}
}

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

// const int d = 365;
const int cn = 26;
int main() {
  int d;
  cin >> d;
  int c[cn + 1], s[d + 1][cn + 1];
  for (int i = 1; i <= cn; i++) {
    cin >> c[i];
  }
  for (int i = 1; i <= d; i++) {
    for (int j = 1; j <= cn; j++) {
      cin >> s[i][j];
    }
  }

  int last[d + 1][cn + 1];
  for (int i = 0; i <= d; i++) {
    for (int j = 0; j <= cn; j++) {
      last[i][j] = 0;
    }
  }
  int t[d + 1];
  for (int i = 1; i <= d; i++) {
    for (int j = 1; j <= cn; j++) {
      last[i][j] = last[i - 1][j];
    }
    cin >> t[i];
    last[i][t[i]] = i;
  }

  int v[d + 1];
  v[0] = 0;
  // 各日の満足度
  for (int i = 1; i <= d; i++) {
    int v_down = 0;
    for (int j = 1; j <= 26; j++) {
      v_down += c[j] * (i - last[i][j]);
    }
    v[i] = v[i - 1] + s[i][t[i]] - v_down;
    // cout << "vd = " << v_down << endl;
  }

  // 出力
  for (int i = 1; i <= d; i++) {
    cout << v[i] << endl;
  }
  return 0;
}

Measured memory_bytes: 3684
package main

import (
	"fmt"
)

func main() {
	var a, b, c, x int
	fmt.Scan(&a, &b, &c, &x)
	result := 0
	for i := 0; i <= a; i++ {
		for j := 0; j <= b; j++ {
			for k := 0; k <= c; k++ {
				if x == 500*i+100*j+50*k {
					result++
				}
			}
		}
	}
	fmt.Println(result)
}


Measured memory_bytes: 512
#include<stdio.h>
#include<stdlib.h>
int main()
{
  int N,A[100],i,num,num0;
  scanf("%d",&N);
  num0=0;
  num=0;
  for(i=0;i<N;i++)
  {
    scanf("%d",&A[i]);
    if(A[i]%2==0)
    {
      num0=num0+1;
      
      if(A[i]%3==0||A[i]%5==0)
      {
        num=num+1; 
      }
     }
   }
  if(num0==num)
  {
   printf("APPROVED");
    exit(0);
  }
   printf("DENIED");
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define clr(x) memset(x,0,sizeof (x))
#define For(i,a,b) for (int i=(a);i<=(b);i++)
#define Fod(i,b,a) for (int i=(b);i>=(a);i--)
#define fi first
#define se second
#define kill _z_kill
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define outval(x) cerr<<#x" = "<<x<<endl
#define outv(x) cerr<<#x" = "<<x<<"  "
#define outtag(x) cerr<<"--------------"#x"---------------"<<endl
#define outarr(a,L,R) cerr<<#a"["<<L<<".."<<R<<"] = ";\
	For(_x,L,R) cerr<<a[_x]<<" ";cerr<<endl;
#define User_Time ((double)clock()/CLOCKS_PER_SEC)
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef unsigned uint;
typedef long double LD;
typedef vector <int> vi;
typedef pair <int,int> pii;
LL read(){
	LL x=0,f=0;
	char ch=getchar();
	while (!isdigit(ch))
		f=ch=='-',ch=getchar();
	while (isdigit(ch))
		x=(x<<1)+(x<<3)+(ch^48),ch=getchar();
	return f?-x:x;
}
//int Pow(int x,int y){
//	int ans=1;
//	for (;y;y>>=1,x=(LL)x*x%mod)
//		if (y&1)
//			ans=(LL)ans*x%mod;
//	return ans;
//}
//void Add(int &x,int y){
//	if ((x+=y)>=mod)
//		x-=mod;
//}
//void Del(int &x,int y){
//	if ((x-=y)<0)
//		x+=mod;
//}
//int Add(int x){
//	return x>=mod?x-mod:x;
//}
//int Del(int x){
//	return x<0?x+mod:x;
//}
//void ckmax(int &x,int y){
//	if (x<y)
//		x=y;
//}
//void ckmin(int &x,int y){
//	if (x>y)
//		x=y;
//}
int main(){
	int A=read(),B=read(),m=read();
	int ans=1e6,va=1e6,vb=1e6;
	vi a(A),b(B);
	For(i,0,A-1){
		a[i]=read();
		va=min(va,a[i]);
	}
	For(i,0,B-1)
		b[i]=read(),vb=min(vb,b[i]);
	ans=min(ans,va+vb);
	while (m--){
		int x=read(),y=read(),z=read();
		ans=min(ans,a[x-1]+b[y-1]-z);
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define Mx 1000000000005 
#define ll long long  
#define pi 3.141592653
#define vi vector<ll>
#define Mo 1000000007
#define mp make_pair
#define M map<ll,ll>
#define fr(i,a,b) for(ll i=a;i<b;i++)
#define vii vector<pair<ll,ll> > 
#define fi first
#define se second
#define pb push_back
#define ld long double
#define fill(a,x) memset(a,x,sizeof(a))
using namespace std;
bool comp(const pair<ll,ll> &a, const pair<ll,ll> &b)
{
  return a.second<b.second;
}
/*vi b=v;
   sort(b.begin(), b.end());
  b.resize(unique(b.begin(), b.end()) - b.begin());
  ll t; cin>>t; fr(f,0,t){ 
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
 */
ll dp[100005][2];

ll func(vi v[],ll s,bool vis[],ll c)
{ 
  if(dp[s][c]!=-1) return dp[s][c];

  dp[s][c]=1; vis[s]=1;
  ll x;
  fr(i,0,v[s].size())
  {
    if(!vis[v[s][i]])
    { 
      if(c==0)
        x=(func(v,v[s][i],vis,1)+func(v,v[s][i],vis,0))%Mo; 
      else
        x=func(v,v[s][i],vis,0); 
      
      dp[s][c]=(dp[s][c]*x)%Mo;
    }
  }

  vis[s]=0;
  return dp[s][c];
}

int main()
{
  ll V,x,y; cin>>V;
  vi v[V+1];
  fr(i,0,V-1)
  {
    cin>>x>>y;
    v[x].pb(y);
    v[y].pb(x);
  }

  fill(dp,-1);
  bool vis[V+1]={0};
  ll ans=(func(v,V,vis,0)+func(v,V,vis,1))%Mo;
  cout<<ans;


}

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

int main(){
  int N;
  cin >> N;
  long long sum = 0;
  int maxA;
  cin >> maxA;
  for(int i = 0; i < N-1; i++){
    int A;
    cin >> A;
    if(A >= maxA){
      maxA = A;
    }else{
      sum += maxA-A;
    }
  }
  cout << sum << endl;
}

Measured memory_bytes: 3516
// Written by newbiechd
#include <algorithm>
#include <cctype>
#include <cstdio>
#include <cstring>
#include <vector>

const int BUFFER_SIZE = 1 << 25 | 1;
struct InputOutputStream {
  char ibuf[BUFFER_SIZE], obuf[BUFFER_SIZE], *s, *oh;
  InputOutputStream() : s(ibuf), oh(obuf) {
    ibuf[fread(ibuf, 1, BUFFER_SIZE, stdin)] = '\0';
  }
  ~InputOutputStream() { fwrite(obuf, 1, oh - obuf, stdout); }
  template <typename T>
  inline InputOutputStream &operator>>(T &x) {
    while (!isdigit(*s)) ++s;
    for (x = 0; isdigit(*s); ++s)
      x = x * 10 + (*s ^ '0');
    return *this;
  }
  template <typename T>
  inline InputOutputStream &operator<<(T x) {
    static char buf[23];
    register char *top = buf;
    if (x) {
      for (T t; x; )
        t = x / 10, *top++ = x - t * 10 + 48, x = t;
      while (top != buf)
        *oh++ = *--top;
    }
    else
      *oh++ = '0';
    *oh++ = ' ';
    return *this;
  }
}IO;

template <typename lhs, typename rhs>
inline lhs min(const lhs &x, const rhs &y) { return x < y ? x : y; }
template <typename lhs, typename rhs>
inline lhs max(const lhs &x, const rhs &y) { return x > y ? x : y; }

const int lim = 1e9;

int main() {
  int n, k, s;
  IO >> n >> k >> s;
  for (int i = 1; i <= k; ++i)
    IO << s;
  for (int i = k + 1; i <= n; ++i)
    IO << (s == 1e9 ? s - 1 : s + 1);
  return 0;
}


Measured memory_bytes: 3328
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <unordered_map>
using namespace std;

#define REP(i, s) for (int i = 0; i < s; ++i)
#define ALL(v) (v.begin(), v.end())
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ EACH(it, P) { s << "<" << *it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }

int N;
int main() {
    while (cin >> N) {
        set<string> se;
        bool ok = true;
        string prev = "";
        for (int i = 0; i < N; ++i) {
            string str; cin >> str;
            if (i != 0) {
                if (str[0] != prev.back()) ok = false;
            }
            if (se.count(str)) ok = false;
            prev = str;
            se.insert(str);
        }
        if (ok) puts("Yes");
        else puts("No");
    }
}






























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

// dp(i, j) : probability of getting j heads in i coin tosses
// dp(0, 0) = 1
// dp(0, _) = 0
// dp(i, 0) = (1 - p[i]) * dp(i - 1, 0)
// dp(i, j) = p[i] * dp(i - 1, j - 1) + (1 - p[i]) * dp(i - 1, j)

using namespace std;

const int NMAX = 3e3 + 11;

int    n;
double p[NMAX], dp[NMAX][NMAX];

double solve(void)
{
    dp[0][0] = 1;
    for (int i = 1; i <= n; ++i)
        dp[0][i] = 0;

    for (int i = 1; i <= n; ++i)
    {
        for (int j = 0; j <= n; ++j)
        {
            dp[i][j] = (1 - p[i]) * dp[i - 1][j];
            if (j != 0)
                dp[i][j] += p[i] * dp[i - 1][j - 1];
        }
    }

    // for (int i = 0; i <= n; ++i)
    // {
    //     for (int j = 0; j <= n; ++j)
    //     {
    //     }
    // }
    // double ans = 0;
    // for (int j = (n / 2) + 1; j <= n; ++j)
    //    ans += dp[n][j];
    return accumulate(dp[n] + n / 2 + 1, dp[n] + n + 1, 0.0);
}

int main(void)
{
    cin >> n;
    for (int i = 1; i <= n; ++i)
        cin >> p[i];
    cout << setprecision(10) << solve() << endl;
    return 0;
}


Measured memory_bytes: 70784
#include<bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
using namespace std;
int main(){
  double a,b,h,m;
  const double num = 180;
  const double PI=3.14159265358979323846;
  cin >> a >> b >> h >> m;
  double deg = abs(30*h+0.5*m-6*m);
  if(deg>180)
    deg = 360 - deg;
  //cout << sqrt(a*a+b*b-2*a*b*cos(0.17366993166666678)) << '\n';
  cout<<fixed<<setprecision(11)<<sqrt(a*a+b*b-2*a*b*cos((deg*PI)/num));
  return 0;
}





Measured memory_bytes: 4228
#!/usr/bin/env python3

MOD = 10**9 + 7

n, m = map(int, input().split())
s = list(map(int, input().split()))
t = list(map(int, input().split()))

dp = [[0] * (m + 1) for _ in range(n + 1)]
for i in range(n + 1):
    dp[i][0] = 1
for j in range(m + 1):
    dp[0][j] = 1

for i in range(n):
    for j in range(m):
        dp[i + 1][j + 1] += dp[i + 1][j]
        dp[i + 1][j + 1] += dp[i][j + 1]
        dp[i + 1][j + 1] += -dp[i][j]
        if s[i] == t[j]:
            dp[i + 1][j + 1] += dp[i][j]
        dp[i + 1][j + 1] %= MOD

print(dp[n][m])



Measured memory_bytes: 72796
#define _USE_MATH_DEFINES
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <clocale>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;

#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i, s, n) for(int i = (s), i##_len=(n); i < i##_len; ++i)
#define FORS(i, s, n) for(int i = (s), i##_len=(n); i <= i##_len; ++i)
#define VFOR(i, s, n) for(int i = (s); i < (n); ++i)
#define VFORS(i, s, n) for(int i = (s); i <= (n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define REPS(i, n) FORS(i, 0, n)
#define VREP(i, n) VFOR(i, 0, n)
#define VREPS(i, n) VFORS(i, 0, n)
#define RFOR(i, s, n) for(int i = (s), i##_len=(n); i >= i##_len; --i)
#define RFORS(i, s, n) for(int i = (s), i##_len=(n); i > i##_len; --i)
#define RREP(i, n) RFOR(i, n, 0)
#define RREPS(i, n) RFORS(i, n, 0)
#define ALL(v) (v).begin(), (v).end()
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v), greater<decltype(v[0])>())
#define SZ(x) ((int)(x).size())
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define MT make_tuple
#define BIT(n) (1LL<<(n))
#define UNIQUE(v) v.erase(unique(ALL(v)), v.end())

using ll = long long;
using ull = unsigned long long;
using Pi_i = pair<int, int>;
using VB = vector<bool>;
using VC = vector<char>;
using VD = vector<double>;
using VI = vector<int>;
using VLL = vector<ll>;
using VS = vector<string>;
using VSH = vector<short>;
using VULL = vector<ull>;

const int MOD = 1000000007;
const int INF = 1000000000;
const int NIL = -1;

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



int main(){
    int n; cin >> n;
    vector<Pi_i> vp;
    REP(i, n){
        int s, t; cin >> s >> t;
        vp.EB(MP(s, t));
    }
    auto comp = [](Pi_i a, Pi_i b){
        return a.second < b.second;
    };
    sort(ALL(vp), comp);
    int cnt = 0, prvt = 0;
    for(auto &p: vp){
        if(prvt < p.first){
            ++cnt;
            prvt = p.second;
        }
    }
    cout << cnt << endl;
    return 0;
}



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

int		main(void)
{
	int		a, b, c;
	cin >> a >> b >> c;
	int		f = 0;
	if (a == b || b == c || a == c)
	{
		if (!(a == b && b == c))
			f = 1;
	}
	if (f == 1)
		cout << "Yes";
	else
		cout << "No";
}


Measured memory_bytes: 256
import sys
import math
from collections import defaultdict
from collections import deque

sys.setrecursionlimit(1000000)
MOD = 10 ** 9 + 7
input = lambda: sys.stdin.readline().strip()
NI = lambda: int(input())
NMI = lambda: map(int, input().split())
NLI = lambda: list(NMI())
SI = lambda: input()


def main():
    H, W, M = NMI()
    bombs = defaultdict(int)
    rows = [0]*H
    cols = [0]*W
    for _ in range(M):
        h, w = NMI()
        h, w = h-1, w-1
        bombs[h * 10**6 + w] = 1
        rows[h] += 1
        cols[w] += 1
    rows_i = [[r, i] for i, r in enumerate(rows)]
    cols_i = [[c, i] for i, c in enumerate(cols)]
    rows_i.sort(reverse=True)
    cols_i.sort(reverse=True)

    rmax = rows_i[0][0]
    cmax = cols_i[0][0]
    for r, i in rows_i:
        if r <= rmax - 1:
            break
        for c, j in cols_i:
            if c <= cmax - 1:
                break
            if i * 10**6 + j not in bombs:
                print(rmax + cmax)
                exit()
    print(cmax+rmax-1)


if __name__ == "__main__":
    main()

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

int main() {
	int q;
	cin >> q;
	for(int i = 0; i < q; i++){
		int c, a, n;
		int ans = 0;
		cin >> c >> a >> n;
		int s = min(c, min(a, n));
		c -= s; a -= s; n -= s;
		ans += s;
		
		if(a >= 1){
			s = min(c / 2, a);
			c -= (2 * s); a -= s;
			ans += s;
		}
		
		ans += (c / 3);
		
		cout << ans << endl;
	}
	
	return 0;
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MOD 1000000007
#define INF 1e9
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(){
    int n,m;
    cin>>n>>m;
    int a[n],b[m],c[m];
    for(int i=0;i<n;i++) cin>>a[i];
    for(int i=0;i<m;i++){
        cin>>b[i]>>c[i];
    }
    priority_queue<pair<int,int>> q;
    for(int i=0;i<n;i++){
        q.push(make_pair(a[i],1));
    }
    for(int i=0;i<m;i++){
        q.push(make_pair(c[i],b[i]));
    }
    ll ans=0;
    for(int i=0;i<n;i++){
        auto p=q.top();
        q.pop();
        ans+=p.first;
        if(p.second>1){
            p.second--;
            q.push(p);
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3572
a = list(map(int, input().split()))
fives = 0
sevens = 0

for i in a:
    if(i == 5):
        fives += 1
    elif(i == 7):
        sevens += 1

if((fives == 2) and (sevens == 1)):
    print("YES")
else:
    print("NO")

Measured memory_bytes: 3060
#pragma once
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <iostream>
#include <utility>
#include <set>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <deque>
#include <numeric>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int INF = 1000000007;
const int MAX_V = 201;
int now = 0;
int deco[1000];

void Sequence() {
	int n, t;
	cin >> n >> t;
	ll row = INF;
	ll rem = 0;
	int rc = 0;
	int res = 0;
	for (size_t i = 0; i < n; i++)
	{
		ll a;
		cin >> a;
		row = min(a, row);

		if (rem < a - row) {
			rem = a - row;
			res = 1;
		}
		else if (rem == a - row) {
			res++;
		}

	}
	cout << res  << endl;
}
int main() {
	Sequence();
	return 0;
}



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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;

#define MOD 1000000007
#define REP(i, N) for (int i = 0; i < N; ++i)
#define REP1(i, N) for (int i = 1; i <= N; ++i)
#define RREP(i, N) for (int i = N - 1; i >= 0; --i)
#define ALL(a) a.begin(), a.end()

int main() {
  int N;
  cin >> N;
  ll d[N + 10][3];
  REP(i, N) { REP(j, 3) cin >> d[i][j]; }
  ll dp[N + 10][3];
  REP(i, N) { REP(j, 3) dp[i][j] = 0; }
  REP(i, 3) dp[0][i] = d[0][i];
  REP(i, N) {
    dp[i + 1][0] = max(dp[i][1], dp[i][2]) + d[i + 1][0];
    dp[i + 1][1] = max(dp[i][0], dp[i][2]) + d[i + 1][1];
    dp[i + 1][2] = max(dp[i][0], dp[i][1]) + d[i + 1][2];
  }
  ll ans = 0;
  REP(i, 3) ans = max(ans, dp[N - 1][i]);
  cout << ans << endl;
  return 0;
}

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

using namespace std;

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

    vector<int> h(n);
    for (int i = 0; i < n; ++i)
        cin >> h[i];

    vector<int> can_move(n, 0);
    for (int i = n - 2; i >= 0; --i) {
        if (h[i] >= h[i + 1])
            can_move[i] = can_move[i + 1] + 1;
    }

    int max_move = can_move[0];
    for (int i = 1; i < n; ++i)
        max_move = max(max_move, can_move[i]);
    cout << max_move << '\n';
}


Measured memory_bytes: 1152
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;} return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;} return 0;}
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(vec) vec.begin(),vec.end()
typedef long long ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
const ll mod=1e9+7;
const int inf=1<<30;

int dcnt[13];

int main(){
  int n; cin >> n;
  rep(i,n){
    int d; cin >> d;
    dcnt[d]++;
  }
  vector<int> c1(0);
  vector<int> v={0,24};
  rep(i,13){
    if((i==0&&dcnt[i]>0)||dcnt[i]>=3){
      cout << 0 << endl;
      return 0;
    }
    else if(dcnt[i]==1){
      c1.push_back(i);
    }
    else if(dcnt[i]==2){
      v.push_back(i);
      v.push_back(24-i);
    }
  }
  int l=c1.size();
  int ans=0;
  for(int i=0;i<(1<<l);i++){
    vector<int> v2=v;
    rep(j,l){
      if(i&(1<<j)) v2.push_back(c1[j]);
      else v2.push_back(24-c1[j]);
    }
    sort(all(v2));
    int diff=inf;
    rep(i,v2.size()-1){
      chmin(diff,v2[i+1]-v2[i]);
    }
    chmax(ans,diff);
  }
  cout << ans << endl;
}

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

using namespace std;

typedef long long LL;
typedef pair<int, int> PII;

const int N = 100010;
const double eps = 1e-6;

int n, m;
int a[N], seq[N];

int main()
{
    scanf("%d%d", &n, &m);
    for(int i = 1; i <= m; i++) scanf("%d", a + i);
    sort(a + 1, a + 1 + m);

    for(int i = 1; i < m; i++) seq[i] = a[i + 1] - a[i];
    sort(seq + 1, seq + m);

    LL res = 0;
    for(int i = 1; i <= m - n; i++) res += seq[i];

    printf("%lld\n", res);
    return 0;
}


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

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

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

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

	return 0;
}

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

using namespace std; 
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>; 

#define INF 1000000000000000000
#define MOD 10007
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()

int main(){
  int A,B;
  cin>>A>>B;
  int ans=0;
  if(A>=B)ans+=A,A--;
  else ans+=B,B--;
  if(A>=B)ans+=A,A--;
  else ans+=B,B--;
  cout<<ans<<endl;
  return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	cin>>n;
	int sum = 1;
	int aaa;
	cin>>aaa;
	int b = aaa;
	for(int i=0;i<n-1;i++)
	{
		int a;
		cin>>a;
		if(a<b)
		{
			sum = sum + 1;
			b = a;
		}
	}
	cout<<sum<<endl;
	return 0;
}

Measured memory_bytes: 256
fun main(args: Array<String>) {
    val W = readLine()!!.toString()
    val T = mutableListOf<String>()
    while (true) {
        val s = readLine()!!.toString()
        if (s == "END_OF_TEXT") break
        T.addAll(s.split(" "))
    }
    println(T.filter { it.toLowerCase() == W.toLowerCase() }.count())
}


Measured memory_bytes: 26636
mod = 1000000007
eps = 10**-9


def main():
    import sys
    input = sys.stdin.readline

    N, K = map(int, input().split())
    P = [0] + list(map(int, input().split()))
    C = [0] + list(map(int, input().split()))

    ans = -10**10
    for v0 in range(1, N+1):
        seen = [0] * (N+1)
        seen[v0] = 1
        k = K
        score = 0
        v = v0
        ma = -10**10
        flg = 0
        S = [0] * (N+1)
        SK = [0] * (N+1)
        SK[v0] = k
        while True:
            nxt = P[v]
            score += C[nxt]
            if seen[nxt]:
                flg = 1
                score_loop = score - S[nxt]
                loop_size = SK[nxt] - k + 1
                k -= 1
                v = nxt
                break
            S[nxt] = score
            SK[nxt] = k-1
            ma = max(ma, score)
            seen[nxt] = 1
            v = nxt
            k -= 1
            if k == 0:
                break

        if flg:
            #print(v0, score_loop, loop_size, seen)
            if score_loop > 0:
                x = k // loop_size - 1
                score += score_loop * x
                k -= x * loop_size
                ma = max(ma, score)
            else:
                k = loop_size
            for _ in range(k):
                nxt = P[v]
                score += C[nxt]
                ma = max(ma, score)
                v = nxt
        ans = max(ans, ma)
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 87660
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n);i++)
#define sz(x) int(x.size())
typedef unsigned long long ll;
typedef long double ld;
typedef pair<int,int> P;
constexpr int INF = 2e9;
constexpr int mod = 1e9+7;

int main() {
  int n;
  cin >> n;
  string s;
  cin >> s;
  int m = 0;
  for (int i = 0; i < n; i++) if (s[i] == 'R') m++;
  int res = 0;
  reverse(s.begin(), s.end());
  for (int i = 0; i < n - m; i++) {
    if (s[i] == 'R') res++;
  }  
  cout << res << endl;
  return 0;
}

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

int main(){
  int n;

  while(cin >> n, n){
    int twoFlg = false;
    int cnt = 0;

    for(int i = 0; i < n; i++){
      int x;
      cin >> x;
      if(x >= 1) cnt++;
      if(x >= 2) twoFlg = true;
    }

    if(twoFlg){
      cout << cnt + 1 << endl;
    }
    else{
      cout << "NA" << endl;
    }
  }
}

Measured memory_bytes: 1160
#include<cstdio>
#include<iostream>
#include<vector>
#include<tuple>
#include<queue>
#include<algorithm>
#include<string.h>
#include<math.h>

using namespace std;


int main(int argc, char* argv[]){
  int n;
  scanf("%d",&n);
  for(int i=0;i<=n;i++){
      int p = n-4*i;
      if(p%7==0 && p>=0){
        puts("Yes");
        return 0;
      }
  }


  puts("No");
  return 0;
}

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

ll d;
ll p[20];
int dx1[20], dx2[20];
vector<ll> v;

void dfs(int s, int e, vector<pi> &w, ll val, ll cnt){
	if(s == e){
		w.push_back(pi(val, cnt));
		return;
	}
	for(int i=-9; i<=9; i++){
		dfs(s+1, e, w, val + i * v[s], cnt * (s == 0 ? dx2[i + 10] : dx1[i + 10]));
	}
}

ll solve(int l){
	v.clear();
	for(int i=0; l-1-i > i; i++){
		v.push_back(p[l-1-i] - p[i]);
	}
	vector<pi> v1, v2;
	dfs(0, (v.size()+1) / 2, v1, 0, 1);
	dfs((v.size()+1) / 2, v.size(), v2, 0, 1);
	ll ans = 0;
	map<ll, ll> mp;
	for(auto &i : v2) mp[-i.first] += i.second;
	for(auto &i : v1){
		ans += mp[i.first + d] * i.second;
	}	
	if(l % 2 == 1) ans *= 10;
	return ans;
}

int main(){
	p[0] = 1;
	for(int i=1; i<20; i++) p[i] = p[i-1] * 10;
	for(int i=0; i<10; i++){
		for(int j=0; j<10; j++){
			dx1[i-j+10]++;
		}
	}
	for(int i=1; i<10; i++){
		for(int j=0; j<10; j++){
			dx2[i-j+10]++;
		}
	}
	cin >> d;
	ll ans = 0;
	for(int i=2; i<=18; i++) ans += solve(i);
	cout << ans << endl;
}


Measured memory_bytes: 205936
# coding: utf-8
# Here your code !

# coding: utf-8
# Here your code !

def func():
    try:
        line = input()
    except:
        return inputError()
        
    (buildings,floors,rooms,maxnumber)=(4,3,10,9)
    tenants=[ [ [0 for i in range(rooms)] for j in range(floors)] for k in range(buildings)]
   
    while(True):
        try:
            line=input().rstrip()
            info=line.split(" ")
            (building, floor, room, number)=( int(info[0])-1, int(info[1])-1, int(info[2])-1, int(info[3]) )
        except EOFError:
            break
        except:
            return inputError()
        
        if( (building >= 0) and (building < buildings) ):
            if( (floor >= 0) and (floor < floors) ):
                if( (room >= 0) and (room < rooms) ):
                    if( (tenants[building][floor][room]+number >= 0) and (tenants[building][floor][room]+number < maxnumber+1) ): 
                        tenants[building][floor][room] += number
                    else:
                        return inputError()
                else:
                    return inputError()
            else:
                return inputError()
        else:
            return inputError()
    
    result=""
    for i in range(buildings):
        for j in range(floors):
            for k in range(rooms):
                result += " {0}".format(tenants[i][j][k])
            result += "\n"
        if(i+1 < buildings):
            result+="#"*rooms*2+"\n"
            
    print(result.rstrip())        
    
def inputError():
    print("input error")
    return -1


func()

Measured memory_bytes: 7800
#include <iostream>

int main()
{
	int S;
	std::cin >> S;
	int h = S / 3600;
	S = S % 3600;
	int m = S / 60;
	int s = S % 60;
	
	std::cout << h << ":" << m << ":" << s << std::endl;
	return 0;
}
	


Measured memory_bytes: 3104
#include <iostream>
#include <vector>

using namespace std;

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

    int A = 360;
    int B = X;
    int x;

    while(1)
    {
        int q = A / B;
        int r = A % B;

        if(r == 0)
        {
            x = B;
            break;    
        }
        else
        {
            A = B;
            B = r;    
        }
    }

    cout << 360 / x << endl;
        

    return 0;    
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp> 
//#include <ext/pb_ds/tree_policy.hpp> 
//using namespace __gnu_pbds; 
using namespace std; 
typedef long long ll;
typedef unsigned long long int ull;
// PB-DS 
//#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
 
#define ff first
#define ss second
#define pb push_back
#define Inf  1000000000000000000
#define inf -1000000000000000000
#define mod 1000000007

ll mulmod(ll x,ll y){
  return (x%mod*y%mod)%mod;
}
 
ll addmod(ll x,ll y){
  return (x%mod+y%mod)%mod;
}
 
long long  power(long long  x,long long  y) { 
    long long  res = 1;      
    while (y > 0) 
    { 
        if (y & 1) 
            res = res*x;  
        y = y>>1;  
        x = x*x;  
    } 
    return res; 
}

void testcases(int Case){
  int x1,x2,x3,x4,x5;
  cin >> x1 >> x2 >> x3 >> x4 >> x5;
  if(x1==0)
    cout << 1 << "\n";
  if(x2==0)
    cout << 2 << "\n";
   if(x3==0)
    cout << 3 << "\n";
   if(x4==0)
    cout << 4 << "\n";
   if(x5==0)
    cout << 5 << "\n";
}

  
int main()
{
 // sieve();
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
    ll t;
    t = 1;
    //cin >> t;
    ll Case =1 ;
    while(t--)
    {
      testcases(Case++);
    }
}

Measured memory_bytes: 3648
n = int(input())

s = {}
for i in range(n):
    temp = input()
    if temp in s:
        s[temp] += 1
    else:
        s[temp] = 1



max_s_val = max(s.values())
t = [k for k, v in s.items() if v == max_s_val]
t.sort()

for i in range(len(t)):
    print(t[i])



Measured memory_bytes: 32096