akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,a,b) for(ll i=ll(a);i<ll(b);i++)
#define irep(i,a,b) for(ll i=ll(a);i>=ll(b);i--)
using ll = long long;
using namespace std;

int main(){
    string s;
    cin>>s;
    string a ="";
    a+=s[0];
    string b="";
    int g=(int)s.length();
    int ans=1;
    int i=1;
    //cout<<a<<endl;
    for(i=1;i<=g;i++){
        b="";
        b+=s[i];
        while(i<g&&b==a){i++;b+=s[i];}
        a=b;
        ans++;
       // cout<<b<<" ";
    }
    if(a==b)ans--;
    cout<<ans;
}

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

int main(){

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


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

template <class T, class U>
inline bool chmin(T& lhs, const U& rhs) {
  if (lhs > rhs) {
    lhs = rhs;
    return true;
  }
  return false;
}

template <class T, class U>
inline bool chmax(T& lhs, const U& rhs) {
  if (lhs < rhs) {
    lhs = rhs;
    return true;
  }
  return false;
}

// [l, r) from l to r
struct frep {
  struct itr {
    int i;
    constexpr itr(int i_): i(i_) { }
    constexpr void operator ++ () { ++i; }
    constexpr int operator * () const { return i; }
    constexpr bool operator != (itr x) const { return i != x.i; }
  };
  const itr l, r;
  constexpr frep(int l_, int r_): l(std::min(l_, r_)), r(r_) {}
  constexpr itr begin() const { return l; }
  constexpr itr end() const { return r; }
};

// [l, r) from r to l
struct brep {
  struct itr {
    int i;
    constexpr itr(int i_): i(i_) { }
    constexpr void operator ++ () { --i; }
    constexpr int operator * () const { return i; }
    constexpr bool operator != (itr x) const { return i != x.i; }
  };
  const itr r, l;
  constexpr brep(int r_, int l_): r(std::max(l_, r_) - 1), l(l_ - 1) {}
  constexpr itr begin() const { return r; }
  constexpr itr end() const { return l; }
};

template <class T>
inline T scan() {
  T res;
  std::cin >> res;
  return res;
}

int main() {
  int a, b;
  std::cin >> a >> b;
  char A = '0' + a, B = '0' + b;
  std::string sa = "", sb = "";
  for (const int i: frep(0, b)) sa += A;
  for (const int i: frep(0, a)) sb += B;
  std::cout << std::min(sa, sb) << '\n';
  return 0;
}


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

int fact[1000005];
int mod = 1000000007;
long long qexp(long long b, long long p){
    long long res = 1;
    while(p){
        if(p&1) res = (res * b) % mod;
        b = (b * b) % mod;
        p >>= 1;
    }
    return res;
}
int inv(long long b){ return qexp(b, mod-2); }
int choose(int N, int C){
	int res = fact[N];
	res *= inv(C);
	res %= mod;
	res *= inv(N-C);
	res %= mod;
	return res;
}

signed main(){
	//freopen("i.txt","r",stdin);
	ios_base::sync_with_stdio(false); cin.tie(0);
	
	fact[0] = 1;
	for(int i = 1;i <= 1000000;i++) fact[i] = (fact[i-1] * i) % mod;
	
	string s; cin >> s;
	cout << s[0] << s[1] << s[2];
	
}



Measured memory_bytes: 11468
#pragma GCC optimize(1)
#pragma GCC optimize(2)
#pragma GCC optimize(3)

//  ch.cpp
//
//  Created by WinnieJt on 2019/3/21.
//
//  Copyright © 2019 金天. All rights reserved.

//åß∂ƒ∆Ω≈µç∫πø∑¢∞§¶

#include<bits/stdc++.h>
#include<algorithm>
#include<bitset>
#include<cctype>
#include<cerrno>
#include<clocale>
#include<cmath>
#include<complex>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<deque>
#include<exception>
#include<fstream>
#include<functional>
#include<limits>
#include<list>
#include<map>
#include<iomanip>
#include<ios>
#include<iosfwd>
#include<iostream>
#include<istream>
#include<ostream>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<stdexcept>
#include<streambuf>
#include<string>
#include<utility>
#include<vector>
#include<cwchar>
#include<cwctype>
typedef long long ll;
using namespace std;
string inp;
int main(void)
{
    ios::sync_with_stdio(false);
    getline(cin,inp);
    if(inp[0]==inp[(inp.length())-1])
    {
        if((inp.length())%2==0) cout << "First" << endl;
        else cout << "Second" << endl;
    }
    else
    {
        if((inp.length())%2==0) cout << "Second" << endl;
        else cout << "First" << endl;
    }
    return 0;
}



Measured memory_bytes: 512
import Foundation

func readInts() -> [Int] {
    readLine()!.split(separator: " ").map { Int($0)! }
}

func main(){
    let value = Int(readLine()!)!
    if value % 1000 == 0 {
        print(0)
        return
    }
    print(abs(value % 1000 - 1000))
}

main()


Measured memory_bytes: 13056
#include <iostream>
#include <algorithm>
#include <string>

using namespace std;

int main()
{
    string input[1001];
    int i = 0;

    while (cin >> input[i]) {i++;};

    sort(input, input+i);

    int max = 0, pos = 0, add = 1, len = 0, lenp = 0;
    for (int j = 1; j < i; j++) {
        if (input[j-1] == input[j]) {
            add++;
            if (max < add) {
                max = add;
                pos = j;
            }
        } else {
            add = 1;
        }
        if (len < input[j].length()) {
            len = input[j].length();
            lenp = j;
        }
    }
    cout << input[pos] << " " << input[lenp] << endl;

    return 0;
}

Measured memory_bytes: 3080
#include <iostream>
#include <sstream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <utility>
#include <map>
#include <list>
#include <climits>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <bitset>
#include <string>

// #define cerr if(false)cerr
#define watch(x) cerr << "> " << #x << ": " << x << "\n";

using namespace std;

template <typename T>
std::ostream &operator <<(std::ostream &out, vector<T> &v) {
	for (typename vector<T>::size_type i = 0; i < v.size(); ++i)
		out << v[i] << " ";
	out << "\n";
    return out;
}
template <typename T, typename N>
std::ostream &operator <<(std::ostream &out, vector<pair<T, N> > &v) {
	for (size_t i = 0; i < v.size(); ++i)
		out << "(" << v[i].first << ", " << v[i].second << ") ";
	out << "\n";
    return out;
}
template <typename T>
std::ostream &operator <<(std::ostream &out, vector<vector<T> > &v) {
	for (size_t i = 0; i < v.size(); ++i) {
		for (size_t j = 0; j < v[i].size(); ++j) {
			out << v[i][j] << " ";
		}
		out << "\n";
	}
   	return out;
}

template <typename T> 
class UnionFind {

private:
	vector<T> parent;
	vector<T> size;
	int c;

	void check(T p) {
		int sz = parent.size();
		if (p < 0 || p >= sz) {
			throw out_of_range("Index out of range!");
		}
	}

public:
	UnionFind(int n);
	int count() const { return c; }
	int component_size(T p);
	T find(T p);
	inline bool connected(T p, T q) { return find(p) == find(q); }
	void unite(T p, T q);

};

template <typename T>
UnionFind<T>::UnionFind(int n) : parent{vector<T>(n)}, size{vector<T>(n)}, c{n} {
	for (int i = 0; i < n; ++i) {
		parent[i] = i;
		size[i] = 1;
	}
}

template <typename T>
int UnionFind<T>::component_size(T p) {
	check(p);
	return size[find(p)];
}

template <typename T> 
T UnionFind<T>::find(T p) {
	check(p);
	T root = p;
	while (root != parent[root]) {
		root = parent[root];
	}
	while (p != root) {
		T new_p = parent[p];
		parent[p] = root;
		p = new_p;
	}

	return root;
}

template <typename T>
void UnionFind<T>::unite(T p, T q) {
	T root_p = find(p);
	T root_q = find(q);

	if (root_q == root_p) 
		return ;
	
	if (root_q != root_p) {
		if (size[root_p] > size[root_q]) {
			parent[root_q] = root_p;
			size[root_p] += size[root_q];
		} else {
			parent[root_p] = root_q;
			size[root_q] += size[root_p];
		}
	}

	--c;
}

int main() {

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

	int n, m;
	cin >> n >> m;

	vector<pair<int, int> > edges(m);
	int u, v;
	for (int i = 0; i < m; ++i) {
		cin >> u >> v;
		edges[i] = {u - 1, v - 1};
	}

	int bridges = 0;
	for (int i = 0; i < m; ++i) {
		UnionFind<int> uf(n);
		for (int j = 0; j < m; ++j) {
			if (j == i) {
				continue;
			}

			uf.unite(edges[j].first, edges[j].second);
		}

		if (uf.count() > 1) {
			++bridges;
		}
	}

	cout << bridges << "\n";

	return 0;

}

Measured memory_bytes: 3656
#include <iostream>
#include <vector>
#include <bitset>
#include <cmath>
#include <map>
#include <algorithm>
#include <queue>
#include <array>
#include <random>
#include <fstream>
#include <list>


int main() {
    std::vector<long long> alpha(28, 0);
    std::string s;
    std::cin >> s;
    long long n=0;
    for (auto &&tmp : s) {
        alpha[tmp-'a']++;
        n++;
    }
    long long ans = n * (n-1);
    ans /= 2;
    for (int i = 0; i < 28; ++i) {
        ans -= alpha[i] * (alpha[i] - 1) /2;
    }
    ans++;
    std::cout << ans << '\n';
}


Measured memory_bytes: 640
# include<stdio.h>
void gcd(long,long);
int main()
{
long a,b;
while(scanf("%ld%ld",&a,&b)==2)
gcd(a,b);
return 0;
}


void gcd(long a,long b)
{
long m,n,temp;
m=a;
n=b;
while(b!=0)
	{
	temp=a%b;
	a=b;
	b=temp;
	}
m=m/a;
n=n/a;
printf("%ld %ld\n",a,m*n*a);
}

Measured memory_bytes: 592
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		try (Scanner sc = new Scanner(System.in)) {
			String s = sc.nextLine();
			String t = sc.nextLine();

			StringBuilder sb = new StringBuilder(s);
			sb = sb.reverse();
			char[] sca = sb.toString().toCharArray();
			StringBuilder tb = new StringBuilder(t);
			tb = tb.reverse();
			char[] tca = tb.toString().toCharArray();

			for (int i = 0; i < sb.length() - tb.length() + 1; i++) {
				StringBuilder result = new StringBuilder();
				boolean flg = true;
				for (int j = 0; j < i; j++) {
					result.append(sca[j]);
				}
				for (int j = 0; j < t.length(); j++) {
					if (sca[j + i] == tca[j] || sca[i + j] == '?') {
						result.append(tca[j]);
					} else {
						flg = false;
					}
				}
				if (flg) {
					for (int j = result.length(); j < s.length(); j++) {
						result.append(sca[j]);
					}
					printResult(result.reverse().toString());
					return;
				} else {
					continue;
				}
			}

			System.out.println("UNRESTORABLE");

		}
	}

	private static void printResult(String s) {

		for (char c : s.toCharArray()) {
			if (c == '?') {
				System.out.print('a');
			} else {
				System.out.print(c);
			}
		}
		System.out.println();
	}
}


Measured memory_bytes: 22996
//#pragma GCC optimize ("-O3","unroll-loops")
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>


#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define m0(x) memset(x,0,sizeof(x))
#define print(x) cout<<x<<'\n';
#define pe(x) cout<<x<<" ";
#define lb(v,n) lower_bound(v.begin(), v.end(), n);
#define ub(v,n) upper_bound(v.begin(), v.end(), n);
#define int long long
#define all(x) (x).begin(), (x).end()
#define double long double

using namespace std;

int MOD = (ll)1000000000 + 7;
const ll INF = 1e17;
const double pi = acos(-1);
const double EPS = 1e-10;
typedef pair<int, int>P;
const int MAX = 200020;


vector<int>child[1010];
int X[1010];
int N;
int dp[1010];
bool vis[1010];
//int dp2[1010][10050];
bool ok;
int func(int n) {
	if (!ok)return 0;
	if (vis[n])return dp[n];
	vis[n] = true;
	int N2 = child[n].size();
	if (N2 == 0) {
		dp[1010] = 0;
		return 0;
	}
	vector<vector<int>>dp2(N2 + 1);
	REP(i, N2 + 1) {
		REP(j, X[n]+10) {
			dp2[i].pb(INF);
		}
	}
	dp2[0][0] = 0;
	//printf("v:%lld\n", n);
	REP(i, N2) {
		int v = X[child[n][i]], w = func(child[n][i]);
		//pe(v)print(w);
		REP(j, X[n] + 1) {
			if(j+w<=X[n])dp2[i + 1][j + w] = min(dp2[i + 1][j + w], dp2[i][j] + v);
			if(j+v<=X[n])dp2[i + 1][j + v] = min(dp2[i + 1][j + v], dp2[i][j] + w);
		}

	}
	//printf("v:%lld N:%lld\n", n, N2);
	/*FOR(i, 0, N2 + 1) {
		FOR(j, 0, X[n] + 1) {
			printf("%lld %lld:%lld\n", i, j, dp2[i][j]);
		}
	}*/
	int res = INF;
	REP(j, X[n] + 1) {
		res = min(res, dp2[N2][j]);
	}
	dp[n] = res;
	//printf("dp[%lld]:%lld\n", n, res);
	if (res >= INF)ok = false;
	if (!ok)return 0;
	//REP(i, N2 + 2) {
	//	REP(j, X[n] + 5050) {
	//		dp2[i][j] = INF;
	//	}
	//}
	//dp2[0][0] = 0;
	//
	return res;
}
signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);

	cin >> N;
	FOR(i, 1, N) {
		int p; cin >> p; p--;
		child[p].pb(i);
	}
	REP(i, N) {
		cin >> X[i];
	}
	ok = true;
	int x = func(0);
	//print("unko");
	/*REP(i, N) {
		pe(i)print(dp[i]);
	}*/
	if (ok) {
		print("POSSIBLE");
	}
	else {
		print("IMPOSSIBLE");
	}
}


Measured memory_bytes: 29816
#include<bits/stdc++.h>
using namespace std;
#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define SZ(x) ((int)(x).size())
#define debug(x) cerr << #x << ": " << x << '\n'
const char newl = '\n';
typedef long long int Int;
typedef pair<int,int> P;
using ll = long long;
using VI = 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; }
const long long INF = 1LL<<60;

int main(){
    string s;
    cin >> s;
    int n = s.size();
    vector<int> vec(n,0);
    vector<int> ans(n,0);
    int t = 0;
    for(int i=n-1;i>=0;i--){
        if(s[i]=='R') t++;
        else t = 0;
        vec[i] += t;
    }
    for(int i=0;i<n;i++){
        if(s[i] == 'L') t++;
        else t = 0;
        vec[i] += t;
    }   
    /*for(auto &i:vec){
        cout << i << " ";
    }
    cout << endl;*/  
    rep(i,n){
        int v=0;
        if(s[i]=='R'){
            if(vec[i]&1){
                v = -1;
            }else{
                v = 0;
            }
            v = i+v+vec[i];
            ans[v]++;
        }else{
            if(vec[i]&1){
                v = -1;
            }else{
                v = 0;
            }
            v = v+vec[i];
            ans[i-v]++;
        }
    }
    /*for(auto &i:vec){
        cout << i << " ";
    }
    cout << endl;*/
    for(auto &i:ans){
        cout << i << " ";
    }
    cout << endl;
}

Measured memory_bytes: 4324
#include <bits/stdc++.h>
 
#define pb push_back
#define ll long long
#define F first
#define S second
#define ld long double
 
using namespace std;
 
void data() {
    #ifdef NURS
        freopen("main.in", "r", stdin);
        freopen("main.out", "w", stdout);
    #endif
}
 
const int N = 1e6 + 100;
const ll mod = 998244353; //1e9 + 7

int row[N];
int col[N];
map<pair<int,int>, int> was;
int main () 
{
    data();      
    int h, w;
    cin >> h >> w;
    int m;
    cin >> m;
    int x[m + 1], y[m + 1];
    for (int i = 1; i <= m; i++)
    {
    	cin >> x[i] >> y[i];
    	row[x[i]]++;
    	col[y[i]]++;
    	was[{x[i], y[i]}]++;
    }
    int mx = 0;
    int pos2 = -1;
    for (int i = 1; i <= h; i++)
    {
    	if (mx < row[i])
    	{
    		mx = max(mx, row[i]);
    		pos2 = i;
    	}
    }
    int ans = 0;
    int pos = 0;
    for (int i = 1; i <= w; i++)
    {            	
    	if (ans < mx + col[i] - was[{pos2, i}])
    	{
    		ans = mx + col[i] - was[{pos2, i}]; 
    	}	
    }
    int mx2 = 0;
    for (int i = 1; i <= w; i++)
    {
    	if (mx2 < col[i])
    	{
    		mx2 = col[i];
    		pos = i;
    	}	
    }           
    for (int i = 1; i <= h; i++)
    {
    	if (ans < mx2 + row[i] - was[{i, pos}])
    	{
    		ans = mx2 + row[i] - was[{i, pos}]; 
    	}
    }
    cout << ans;

}


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

int main(void){
    int N;
    cin >> N;
    vector<string> S(N);
    int a = 0, w = 0, t = 0, r = 0;
    for(int i = 0 ; i < N ; i++){
        cin >> S.at(i);
        if(S.at(i) == "AC") a++;
        else if(S.at(i) == "WA") w++;
        else if(S.at(i) == "TLE") t++;
        else if(S.at(i) == "RE") r++;
    }
    
    cout << "AC x " << a << endl;
    cout << "WA x " << w << endl;
    cout << "TLE x " << t << endl;
    cout << "RE x " << r << endl;
}

Measured memory_bytes: 6376
#include<bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for (int i= (a); i < (b); ++i)
typedef long long ll;
typedef pair<int,int> P;
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
struct Edge {
  ll to;
  ll cost;
};
unordered_map<ll, ll> prime_factorization(long long n) {
  //map<ll,ll> first=素因数 second=first素因数の数
  unordered_map<ll, ll> res;
  for (int i = 2; i  <= n/i; i++) {
    while (n % i == 0) {
      res[i]++;
      n /= i;
    }
  }
  if(n != 1) res[n]++;
  return res;
}
int main()
{
  ll A,B;
  cin >> A >> B;
  unordered_map<ll, ll> a = prime_factorization(A);
  ll ans = 0;
  for(auto s:a){
    if (B % s.first == 0) ans++;
  }
  ans++;
  cout << ans << "\n";
}

Measured memory_bytes: 384
package main

import (
	"bufio"
	_ "container/heap"
	"fmt"
	"os"
	_ "sort"
	"strconv"
)

// I/O
type Scanner struct {
	sc *bufio.Scanner
}

func NewScanner() *Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &Scanner{sc}
}

func (s *Scanner) nextStr() string {
	s.sc.Scan()
	return s.sc.Text()
}

func (s *Scanner) nextInt() int {
	i, e := strconv.Atoi(s.nextStr())
	if e != nil {
		panic(e)
	}
	return i
}

func (s *Scanner) nextFloat() float64 {
	f, e := strconv.ParseFloat(s.nextStr(), 64)
	if e != nil {
		panic(e)
	}
	return f
}

func (s *Scanner) nextRuneSlice() []rune {
	return []rune(s.nextStr())
}

func (s *Scanner) nextIntSlice(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextInt()
	}
	return res
}

func (s *Scanner) nextFloatSlice(n int) []float64 {
	res := make([]float64, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextFloat()
	}
	return res
}

// Arithmetic
func max(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m < i {
			m = i
		}
	}
	return m
}

func min(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m > i {
			m = i
		}
	}
	return m
}

func abs(x int) int {
	if x > 0 {
		return x
	}
	return -x
}

func pow(x, y int) int {
	res := 1
	for i := 0; i < y; i++ {
		res *= x
	}
	return res
}

func ceil(a, b int) int {
	if a%b == 0 {
		return a / b
	} else {
		return a/b + 1
	}
}

func gcd(a, b int) int {
	if b == 0 {
		return a
	}
	return gcd(b, a%b)
}

func lcm(a, b int) int {
	return a / gcd(a, b) * b
}

// Sort
type RuneSlice []rune

func (a RuneSlice) Len() int           { return len(a) }
func (a RuneSlice) Less(i, j int) bool { return a[i] < a[j] }
func (a RuneSlice) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }

// Main
const MOD = int(1e+9) + 7
const INF = 1 << 60

func main() {
	sc := NewScanner()
	wtr := bufio.NewWriter(os.Stdout)
	defer wtr.Flush()
	N, K := sc.nextInt(), sc.nextInt()
	ans := 0
	for b := K + 1; b <= N; b++ {
		rests := b - K
		d := N / b
		ans += d * rests
		//fmt.Fprintln(wtr, "d*rests", d*rests)
		if N%b != 0 {
			last := b*d + K
			if last <= N {
				ans += N - last + 1
			}
			if K == 0 {
				ans--
			}
		}
	}

	fmt.Fprintln(wtr, ans)
}


Measured memory_bytes: 640
import java.util.Scanner;

/**
 *
 */

/**
 * @author bluen
 *
 */
public class Main {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc=new Scanner(System.in);
		int N=sc.nextInt();
//		int b=scanner.nextInt();
		if(N%1000!=0) {
			System.out.println(1000-N%1000);

		}else {
			System.out.println(0);
		}


	}

}


Measured memory_bytes: 35780
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define all(v) v.begin(), v.end()
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define Rep(n) for (ll _ = 0; _ < (ll)(n); _++)

template<class S>S sum(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}
ll min(int a,ll b){return min((ll)a,b);} ll min(ll a,int b){return min(a,(ll)b);}
template <class S> void print(vector<S> &v){for(ll i=0; i<(ll)v.size(); i++){cerr << v[i] << ' ';}cerr << endl;}
template <class S> void print(vector<vector<S>> &v) {for (ll i = 0; i < (ll)v.size(); i++) {for (ll j = 0; j < (ll)v[i].size(); j++) {cerr << v[i][j] << ' ';}cerr << endl;}}
int n,m,a,r,c,h;
int main(){
	cin >> n;
	Rep(n){
		string s;
		cin >> s;
		char i = s[0];
		if(i == 'M') m++;
		else if(i == 'A') a++;
		else if(i == 'R') r++;
		else if(i == 'C') c++;
		else if(i == 'H') h++;
	}
	int li[5] = {m,a,r,c,h};
	ll ans = 0;
	for(int i=0; i<3; i++){
		for(int j=i+1; j<4; j++){
			for(int k=j+1; k<5; k++){
				ans += ((ll)li[i] * li[j] * li[k]);
			}
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 3596
#define fi first
#define se second
#define mp make_pair
#define pb push_back

#define LOCAL 1

#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#define dbg(...) cout<<#__VA_ARGS__ ": ["; for(auto e: __VA_ARGS__){cout<<e<<", ";} cout<<"]\n"
#define dbg1(...) cout<<#__VA_ARGS__ " "<< __VA_ARGS__ 
#else
#define dbg(...) 1;
#define dbg1(...) 1;
#endif

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;
constexpr ll R=2e5+69, INF=2e9+6969;

int n;
vector <PLL> X,Y;

int main()
{
	scanf("%d", &n);
	for(int i=0;i<n;++i)
	{
		ll x,y;
		scanf("%lld%lld", &x, &y);
		X.pb(mp(x+y,y-x));
		Y.pb(mp(y-x,x+y));
	}
	sort(X.begin(),X.end());
	sort(Y.begin(),Y.end());
	ll ans = 0;
	ans = max(abs(X[0].fi - X[n-1].fi), abs(X[0].se-X[n-1].se));
	ans = max(ans, max(abs(Y[0].fi - Y[n-1].fi), abs(Y[0].se-Y[n-1].se)));
	printf("%lld\n", ans);
	return 0;
}


Measured memory_bytes: 9748
N = int(input())
a = list(map(int, input().split()))
val = set()
ans = []

for i in a:
    if i in val:
        ans.append(i)
    else:
        val.add(i)
ans.sort()
if len(ans) == 0:
    print(0)
else:
    if ans.count(ans[-1]) >= 4:
        print(ans[-1]**2)
    elif ans.count(ans[-1]) == 3:
        print(ans[-1]*ans[-4])
    elif ans.count(ans[-1]) == 2:
        print(ans[-1]*ans[-3])
    else:
        print(ans[-1]*ans[-2])
    


Measured memory_bytes: 20136
import numpy as np

K, N = [int(i) for i in input().rstrip().split(' ')]
A = [int(i) for i in input().rstrip().split(' ')]

x = A[0]
y = K - A[-1]
n = [int(A[i+1] - A[i]) for i in range(N-1)]
n.append(x+y)

np_list = np.array(n)
n.pop(np_list.argmax())
print(sum(n))

Measured memory_bytes: 35108
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
MOD = 10**9+7
 
n, m = map(int, readline().split())
a = set(map(int, read().split()))
 
dp = [0] * (n + 1)
dp[0] = 1
if 1 not in a:
    dp[1] = 1
cnt = 0
for i in range(2, n + 1):
    if i not in a:
        dp[i] = (dp[i - 1] + dp[i - 2]) % MOD
        cnt = 0
    else:
        cnt += 1
        if cnt == 2:
            print('0')
            exit()
print(dp[n])

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

int main() {
	int n, m;
	cin >> n >> m;
	bool check = true;
	
	int s,c, a[5] = {0, -1, -1, -1};
	for (int i = 0; i < m; i++) {
		cin >> s >> c;
		if (a[s] != -1 && a[s] != c) check = false;
	    else a[s] = c;
	}   
	if (a[1] == 0 && n != 1) check = false;
	if (check) {
		if (a[1] == -1 && n == 1) a[1] = 0;
		else if (a[1] == -1) a[1] = 1;
		for (int i = 1; i <= n; i++) {
			if (a[i] == -1) a[i] = 0;
			cout << a[i];
		} 
	} else cout << -1;
	
	return 0;
}

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

public class Program{
    public static void Main(){
        long[] input=Console.ReadLine().Split().Select(x=>long.Parse(x)).ToArray();
        long n=input[0];
        long k=input[1];
        long q=input[2];
        long[] p=new long[n];
        for(long i=0;i<n;i++){
            p[i]=0;
        }
        for(long i=0;i<q;i++){
            long j=long.Parse(Console.ReadLine());
            p[j-1]++;
        }
        var r=p.ToList().Select(x=>x>(q-k)).ToArray();
        for(long i=0;i<n;i++){
            if(r[i]) {
                Console.WriteLine("Yes");
            } else {
                Console.WriteLine("No");
            }
        }
    }
}


Measured memory_bytes: 19548
// Input macro
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! stdin {
    () => {{
        use std::io::Read;
        let mut s = String::new();
        std::io::stdin().read_to_string(&mut s).unwrap();
        s
    }};
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

// Test Code
macro_rules! test {
    ($($input:expr => $output:expr),* $(,)*) => {
        #[test]
        fn solve_test() {
            $(
                assert_eq!(solve($input), $output);
            )*
        }
    };
}

test! {
    "3\n2 1 4\n2\n1 1\n2 3" => "6\n9\n",
    "5\n7 2 3 8 5\n3\n4 2\n1 7\n4 13" => "19\n25\n30\n",
}

fn main() {
    println!("{}", solve(&stdin!()));
}

fn solve(src: &str) -> String {
    input! {
        source = src,
        n: usize,
        t: [usize; n],
        m: usize,
        p: [(usize, usize); m]
    }

    let mut ans = String::new();

    for i in 0..m {
        let mut nt = t.clone();
        nt[p[i].0 - 1] = p[i].1;
        ans.push_str(&format!("{}\n", &nt.iter().sum::<usize>()));
    }

    ans
}

Measured memory_bytes: 4352
fun main(args: Array<String>) {
    val (N, M) = listOfLong()
    val A = listOfLong().sorted()
    val n = N.toInt()

    var L = 0
    var r = 3e5.toInt()
    while (r > L + 1) {
        var j = n
        var m = (L + r) / 2
        var cnt = 0L
        for (i in 0 until n) {
            while (j > 0 && A[i] + A[j - 1] >= m) j--
            cnt += n - j
        }
        if (cnt >= M) L = m else r = m
    }

    var j = n
    var cnt = 0L
    var sum = 0L
    var sumR = 0L
    for (i in 0 until n) {
        while (j > 0 && A[i] + A[j - 1] >= L) {
            j--
            sumR += A[j]
        }
        cnt += n - j
        sum += (n - j) * A[i] + sumR
    }
    sum -= (cnt - M) * L

    println(sum)
}
fun next() = readLine()!!
fun nextLong() = next().toLong()
fun listOfString() = next().split(" ")
fun listOfInt() = listOfString().map(String::toInt)
fun listOfLong() = listOfString().map(String::toLong)

Measured memory_bytes: 53972
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ll long long
#define rep(i,n) for(ll i=0;i<(n);i++)
#define pll pair<ll,ll>
#define pii pair<int,int>
#define pq priority_queue
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define endl '\n'
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define lb(c,x) distance(c.begin(),lower_bound(all(c),x))
#define ub(c,x) distance(c.begin(),upper_bound(all(c),x))

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

const ll INF=1e9+7;

int main(){
    ll n;
    cin >> n;
    vector<ll> a(n);
    rep(i,n){
        cin >> a[i];
    }
    ll ans=0;
    rep(i,n){
        if(i==0) continue;
        if(a[i]<a[i-1]){
            ll v=a[i-1]-a[i];
            a[i]+=v;
            ans+=v;
        }
    }
    cout << ans << endl;
    return 0;
}

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

#define INF_LL (int64)1e18
#define INF (int32)1e9
#define REP(i, n) for(int64 i = 0;i < (n);i++)
#define FOR(i, a, b) for(int64 i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second

using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 1e-10;

template<typename A, typename B>inline void chmin(A &a, B b){if(a > b) a = b;}
template<typename A, typename B>inline void chmax(A &a, B b){if(a < b) a = b;}

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value!=0>::type
fill_v(U &u,const V... v){u=U(v...);}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value==0>::type
fill_v(U &u,const V... v){
  for(auto &e:u) fill_v<T>(e,v...);
}

int main(void) {
	int64 N;
	cin >> N;
	vector<int64> H(N);
	REP(i, N) cin >> H[i];
	int64 res = 0, maxi = 0;
	REP(i, N) {
		if (maxi <= H[i]) res++;
		maxi = max(maxi, H[i]);
	}
	cout << res << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
#define repf(i,a,b) for (int i = (a); i < (b); i++)
#define repi(i,a,b) for (int i = (a); i <= (b); i++)
#define repr(i,a,b) for (int i = (a); i >= (b); i--)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define debug(x)  cout << #x << " = " << (x) << endl;
#define SORT(x) sort(all(x));
#define RSORT(x) sort(rall(x));
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vd = vector<double>;
using vb = vector<bool>;
using pii = pair<int, int>;
using vc = vector<char>;
using vvc = vector<vc>;
using vs = vector<string>;
using tiii = tuple<int, int, int>;
const ll inf = 1ll<<29;
const ll mod = 1000000007;
const double eps = 1e-9;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};

int main() {
  int N; cin >> N;
  vi V(N); rep(i,N) cin >> V.at(i);
  vi C(N); rep(i,N) cin >> C.at(i);

  int ans = 0;
  rep(i,N) {
    if(V.at(i)-C.at(i)>0) {
      ans += V.at(i)-C.at(i);
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <limits.h>
#include <stdlib.h>
#include <limits.h>
#include <stdbool.h>
#define NIL NULL
#define TREE_VALUE INT_MAX
 
typedef struct Node* NodePointer;
typedef NodePointer Tree;
 
typedef struct Node {
  int key;
  NodePointer p, left, right;
} Node;
 
NodePointer makeNode(int key) {
  NodePointer node = (NodePointer)malloc(sizeof(Node));
  node->key = key;
  node->p = node->left = node->right = NIL;
  return node;
}
 
void treeInsert(Tree tree, NodePointer z) {
  NodePointer y = NIL;
  NodePointer x = tree->left;
  while(x != NIL) {
    y = x;
    if(z->key < x->key) {
      x = x->left;
    } else {
      x = x->right;
    }
  }
 
  z->p = y;
  if(y == NIL) {
    tree->left = z; // if T is empty
  } else if(z->key < y->key) {
    y->left = z;
  } else {
    y->right = z;
  }
}
 
void printInorder(NodePointer node) {
  if(node->left  != NIL) printInorder(node->left);
  if(node->key != TREE_VALUE) printf(" %d", node->key);
  if(node->right != NIL) printInorder(node->right);
}
 
void printPreorder(NodePointer node) {
  if(node->key != TREE_VALUE) printf(" %d", node->key);
  if(node->left  != NIL) printPreorder(node->left);
  if(node->right != NIL) printPreorder(node->right);
}
 
NodePointer find(NodePointer node, int key) {
  if(node == NIL) return NIL;
  if(node->key == key) return node;
  else if(key < node->key)
    return find(node->left, key);
  else
    return find(node->right, key);
}
 
NodePointer treeMinimum(NodePointer x) {
  while(x->left != NIL) {
    x = x->left;
  }
  return x;
}
 
NodePointer treeSuccessor(NodePointer x) {
  NodePointer y;
  if(x->right != NIL)
    return treeMinimum(x->right);
  y = x->p;
  while(y != NIL && x == y->right) {
    x = y;
    y = y->p;
  }
  return y;
}
 
void treeDelete(Tree T, NodePointer z) {
  NodePointer x, y;
 
  if(z->left == NIL || z->right == NIL)
    y = z;
  else
    y = treeSuccessor(z);
 
  if(y->left != NIL)
    x = y->left;
  else
    x = y->right;
 
  if(x != NIL)
    x->p = y->p;
 
  if(y->p == NIL)
    T->left = x;
  else if(y == y->p->left)
    y->p->left = x;
  else
    y->p->right = x;
 
  if(y != z)
    z->key = y->key;
 
}
 
int main() {
  int N, key;
  char str[10];
  Tree tree;
 
  // initialize tree
  tree = makeNode(TREE_VALUE);
 
  scanf("%d", &N);
  while(N--) {
    scanf("%s", str);
    if(str[0] == 'i') {
      scanf("%d", &key);
      treeInsert(tree, makeNode(key));
    } else if(str[0] == 'p') {
      printInorder(tree);
      printf("\n");
      printPreorder(tree);
      printf("\n");
    } else if(str[0] == 'f') {
      scanf("%d", &key);
      printf(find(tree,key)?"yes\n":"no\n");
    } else {
      scanf("%d", &key);
      treeDelete(tree, find(tree,key));
    }
  }
  return 0;
}


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

int main() { 
  string s;
  cin >> s;
  int N = s.length();
  int a=0, b=0, c=0;
  for (int i = 0; i < N; i++) {
    if (s[i] == 'a') {
      a++;
    } else if (s[i] == 'b') {
      b++;
    } else {
      c++;
    }
  }
  if (abs(a-b)>=2 || abs(c-a)>=2 || abs(b-c)>=2) {
    cout << "NO" << endl;
  } else {
    cout << "YES" << endl;
  }
  return 0;
}

Measured memory_bytes: 3728
#include <stdio.h>

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

int main() {
	int N;
	scanf("%d", &N);
	char S[N];
	scanf("%s", &S);
	int rgb[3] = {0};
	rep(i,N) rgb[S[i] == 'R' ? 0 : (S[i] == 'G' ? 1 : 2)]++;
	
	long count = rgb[0] * rgb[1] * rgb[2];
	for (int i = 0; i < N - 2; i++) {
		for (int j = 1; i + j * 2 < N; j++) {
			if (S[i] != S[i + j]
				&& S[i] != S[i + j * 2]
				&& S[i + j] != S[i + j * 2]) count--;
		}
	}
	
	printf("%ld", count);
	return 0;
}


Measured memory_bytes: 2156
#include <iostream>
#include <map>
#include <vector>
#include <cmath>
#include <string>
#include <cstring>
#include <algorithm>
#include <climits>
#include <stack>
#include <queue>
#include <set>
#include <cctype>
#include <bitset>
#include <type_traits>

#include <list>
using namespace std;

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define rep(i, a, b) for (int i = a; i < (b); ++i)
#define YES(j) cout << (j ? "YES" : "NO") << endl;
#define Yes(j) std::cout << (j ? "Yes" : "No") << endl;
#define yes(j) std::cout << (j ? "yes" : "no") << endl;

int main(void)
{
    long long h, w;
    cin >> h >> w;
    long long ans = h * w / 2;
    if (h == 1 or w == 1)
    {
        cout << "1" << endl;
        return 0;
    }
    if (h % 2 == 1 && w % 2 == 1)
    {
        ans++;
    }
    cout << ans << endl;
}

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

# 区間更新
# 小さいものを残すパターン
class RangeUpdateQuery:
    def __init__(self, n):
        self.n0 = 2**(n-1).bit_length()
        # 初期値
        self.INF = float("inf")
        self.data = [self.INF]*(2*self.n0-1)

    # 0-indexedで[l, r)をvに更新
    # [l, r]を更新したかったら (l, r+1)を引数に入れる
    # minが更新される場合だけ残す
    def update(self, l,r,v):
        l += self.n0
        r += self.n0
        while l < r:
            if r&1:
                r -= 1
                if self.data[r-1] > v:
                    self.data[r-1] = v
            if l&1:
                if self.data[l-1] > v:
                    self.data[l-1] = v
                l += 1
            l >>=1
            r >>=1

    def query(self, i):
        i += self.n0-1
        res = self.INF
        while i+1:
            if self.data[i] < res:
                res = self.data[i]
            i = ~-i//2
        return res

n,m = map(int, input().split())
s = input()[:-1]
DP = [-1]*(n+1)
seg = RangeUpdateQuery(n+1)
seg.update(0,1,0)

ss = s[::-1]
for i in range(n):
    if ss[i] == "1":
        continue
    cnt = seg.query(i)
    if cnt == float("inf"):
        continue
    seg.update(i+1, min(i+m+1, n+1), cnt+1)

if seg.query(n) == float("inf"):
    print(-1)
    exit()
a = [seg.query(i) for i in reversed(range(n+1))]
for i in range(n+1):
    if s[i] == "1":
        a[i] = float("inf")

prev = a[0]
j = 0
ans = []
for i in range(n+1):
    if a[i]<prev:
        prev = a[i]
        ans.append(i-j)
        j = i
print(*ans)

Measured memory_bytes: 65128
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>

using namespace std;

typedef pair<int,int> PII;
#define INF 1001001001
#define rep(i,n) for(int i=0; i<n; ++i)
#define mp make_pair

struct edge{
    unsigned short to;
    int cost;
    edge(unsigned short to,int cost):to(to),cost(cost){}
};

int V;
vector<edge> G[10000];
int d[10000];
bool used[10000];

void dijkstra(int s){
    priority_queue<PII, vector<PII>, greater<PII>> Q;
    fill(d,d+V,INF);
    d[s]=0;
    Q.push(mp(0,s));

    while(!Q.empty()){
        PII p=Q.top();Q.pop();
        int v=p.second;
        used[v]=true;
        if(d[v]<p.first) continue;
        rep(i,G[v].size()){
            edge e=G[v][i];
            if(!used[e.to]&&d[e.to]>d[v]+e.cost){
                d[e.to]=d[v]+e.cost;
                Q.push(mp(d[e.to],e.to));
            }
        }
    }
}
int n;
int main(){
    cin>>V;
    rep(j,V){
        int u,k;
        cin>>u>>k;
        rep(t,k){
            int v, c;
            cin>>v>>c;
            G[u].push_back(edge(v,c));
        }
    }
    dijkstra(0);
    rep(i,V){
        cout<<i<<" "<<d[i]<<endl;
    }
    return 0;
}

Measured memory_bytes: 8072
#include <iostream>
#include <map>
#include <vector>
#include <algorithm>

int main(){
    char b;
    std::cin >> b;

    if('A' == b){
        std::cout << 'T' << std::endl;
    }else if('T' == b){
        std::cout << 'A' << std::endl;
    }else if('C' == b){
        std::cout << 'G' << std::endl;
    }else{
        std::cout << 'C' << std::endl;
    }

    return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define REP(i,a,b) for (int i = a; i < (b); ++i)
#define all(x) (x).begin(),(x).end()
const int INF = 1000000007;
typedef long long ll;
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; }
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
int main(){
  // ios::sync_with_stdio(false);cin.tie(nullptr);
  vector<int>v(3,INF);
  cin >> v[0] >> v[1];
  sort(v.begin(),v.end());
  if(v[0] == 1 && v[1] == 2)cout << 3 << endl;
  else if(v[0] == 2 && v[1] == 3)cout << 1 << endl;
  else if(v[0] == 1 && v[1] == 3)cout << 2 << endl;
  return 0;
}

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

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

using namespace std;

int main() {
    int n;
    cin >> n;
    vector<int> s(n+1);
    FOR(i, 0, n){
        cin >> s[i];
    }
    
    int q;
    cin >> q;
    vector<int> t(q+1);
    int cnt=0;
    FOR(i, 0, q){
        cin >> t[i];
        s[n] = t[i]; //番兵
        int j=0;
        while(s[j]!=t[i]){
            j++;
        }
        if(j!=n){
            cnt++;
        }
    }
    
    cout << cnt << endl;
    
    return 0;
}



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

using ll = long long;
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define REP(i, n) FOR(i, 0, n)
#define REP1(i, n) FOR(i, 1, (n) + 1)
#define ALL(c) (c).begin(), (c).end()
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
const int MOD = 1000000007;
const int INF = 1000000001;

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

    ll a;
    cin >> a;
    ll c = a - 1;
    ll m = 2;
    REP(i, n - 1) {
        cin >> a;
        if (a > m) {
            c += (a - 1) / m;
        } else if (a == m) {
            m++;
        }
    }

    cout << c << endl;
}


Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        FastScanner in = new FastScanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskA solver = new TaskA();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskA {
        public void solve(int testNumber, FastScanner in, PrintWriter out) {
            int a = in.nextInt();
            int b = in.nextInt();
            out.println(a * b / 2);
        }

    }

    static class FastScanner {
        private InputStream in;
        private byte[] buffer = new byte[1024];
        private int bufPointer;
        private int bufLength;

        public FastScanner(InputStream in) {
            this.in = in;
        }

        private int readByte() {
            if (bufPointer >= bufLength) {
                if (bufLength == -1)
                    throw new InputMismatchException();

                bufPointer = 0;
                try {
                    bufLength = in.read(buffer);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }

                if (bufLength <= 0)
                    return -1;
            }
            return buffer[bufPointer++];
        }

        private static boolean isSpaceChar(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public long nextLong() {
            long n = 0;

            int b = readByte();
            while (isSpaceChar(b))
                b = readByte();

            boolean minus = (b == '-');
            if (minus)
                b = readByte();

            while (b >= '0' && b <= '9') {
                n *= 10;
                n += b - '0';
                b = readByte();
            }

            if (!isSpaceChar(b))
                throw new NumberFormatException();

            return minus ? -n : n;
        }

        public int nextInt() {
            long n = nextLong();

            if (n < Integer.MIN_VALUE || n > Integer.MAX_VALUE)
                throw new NumberFormatException();

            return (int) n;
        }

    }
}



Measured memory_bytes: 22996
#include<iostream>
#include<string.h>
#include<stdio.h>
using namespace std;
int main(){
  string s;
  int u=0,v=0;
  for(int i=0;i<=3;i++){
    cin>>s[i];
    if(s[i]=='+')u++;
    else if(s[i]=='-')v++;
  }
  cout<<u-v;
  return 0;
}


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

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int N; cin >> N;
    constexpr int M = 1e6;
    vector<int> A(M+1, 0);
    for (int i = 0; i < N; i++) {
        int x; cin >> x; A[x]++;
    }
    int Ans = 0;
    for (int i = 1; i <= M; i++) {
        if (A[i] == 1) Ans++;
        if (A[i]) {
            for (int j = i; j <= M; j += i) {
                if (A[j]) A[j] = -1;
            }
        }
    }
    cout << Ans << "\n";
    return 0;
}

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


using ll = long long int;

/// <summary>
/// GCDを計算します
/// </summary>
template <typename NumType>
NumType calcGCD(NumType a, NumType b) {
	if (a < b) {
		NumType tmp = a;
		a = b;
		b = tmp;
	}

	NumType r = a % b;
	while (r != 0) {
		a = b;
		b = r;
		r = a % b;
	}

	return b;
}

/// <summary>
/// 約数を数えます
/// </summary>
template <typename NumType>
NumType cntDivisor(const NumType& num) {
	NumType cnt = 0;
	for (NumType i = 1; i * i <= num; ++i) {
		if (num % i == 0) {
			cnt++;
			if (i * i != num) cnt++;
		}
	}

	return cnt;
}

/// <summary>
/// [beg, end)の範囲を，添え字indexでループするfor文に置換します
/// </summary>
#define FOR_RANGE(index, beg, end)     for (ll index = beg; index < end; ++index)

#define DEBUG(x)     std::cout << #x << " : " << x << "\n"


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


int main() {
	// 入出力を早くするための魔法の言葉
	cin.tie(0);ios::sync_with_stdio(false);

	ll W, H, x, y;
	cin >> W >> H >> x >> y;

	if (W == x * 2 && H == y * 2) {
		cout << (double)(W * H) / 2 << " " << 1 << endl;
	}
	else {
		cout << (double)(W * H) / 2 << " " << 0 << endl;
	}
}

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

#define TASKNAME ""

using namespace std;

const int INF = 1e9 + 7;
const int MAXN = 1e6 + 7;
const double EPS = 1e-8;

int main() {
    #ifdef MY
        freopen("input.txt", "r", stdin);
        //freopen("output.txt", "w", stdout);
    #else
        //freopen(TASKNAME".in", "r", stdin);
        //freopen(TASKNAME".out", "w", stdout);
        ios_base::sync_with_stdio(false);
        cin.tie(0);
        cout.tie(0);
    #endif // MY
    int n, m;
    cin >> n >> m;
    vector <int> sz(n);
    vector <int> num(n);
    vector <int> d(n, 0);
    vector <vector <int> > a(n);
    for (int i = 0; i < n; i++) {
        num[i] = i;
        sz[i] = 1;
        a[i].push_back(i);
    }
    for (int i = 0; i < m; i++) {
        int v, u, da;
        cin >> v >> u >> da;
        v--, u--;
        if (num[v] == num[u]) {
            //cout << d[v] << " " << d[u] << "\n";
            if (d[v] + da != d[u]) {
                cout << "No\n";
                return 0;
            }
            continue;
        }
        if (sz[num[v]] < sz[num[u]]) {
            swap(v, u);
            da = -da;
        }
        int sh = d[v] + da - d[u];
        int pred = num[u];
        for (int x : a[num[u]]) {
            d[x] += sh;
            a[num[v]].push_back(x);
            num[x] = num[v];
        }
        a[pred].clear();
        sz[num[v]] = a[num[v]].size();
    }
    cout << "Yes\n";
    return 0;
}


Measured memory_bytes: 10620
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <assert.h>
#include <numeric>
#include <math.h>
#include <climits>

using namespace std;
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
typedef long long ll;

template <typename T>
T gcd(T a, T b) {
    if(a < b) gcd(b, a);
    if (b == 1) return 1;
    T r;
    while ((r=a%b)) {
        a = b;
        b = r;
    }
    return b;
}

#define MOD (1000000000+7)

int main() {
    int X, A;
    cin >> X >> A;
    if (X < A) cout << 0 << endl;
    else cout << 10 << endl;
}


Measured memory_bytes: 256