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

#define LL long long
#define Dl double
#define Pb push_back
#define Po pop_back
#define Mp make_pair
#define Ub upper_bound
#define Lb lower_bound
#define In insert
#define All(x) x.begin(), x.end()
#define mem(a, b) memset(a, b, sizeof(a))
#define fast ios_base::sync_with_stdio(0);cin.tie(0)

using namespace std;

typedef vector<LL> Vl;
typedef vector<Vl> VVl;
typedef pair<LL, LL> Pll;
typedef vector<Pll> Vpl;
typedef queue<LL> Ql;
typedef stack<LL> Sl;
#define X first
#define Y second

LL n, A, x[60];
LL dp[60][2600][60];

LL stt(LL id, LL now, LL N)
{
    if(id >= n){
        if(N && now % N == 0 && now == A * N)
            return 1;
        return 0;
    }
    
    if(dp[id][now][N] != -1)
        return dp[id][now][N];
        
    LL r1 = 0, r2 = 0;
    r1 = stt(id + 1, now + x[id], N + 1);
    r2 = stt(id + 1, now, N);
    
    return dp[id][now][N] = r1 + r2;
}

int main()
{
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    
    cin >> n >> A;
    
    mem(dp, -1);
    
    for(LL i = 0; i < n; i++){
        cin >> x[i];
    }

    cout << stt(0, 0, 0) << '\n';
    
    return 0;
}


Measured memory_bytes: 73344
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int , int> i_i;
typedef vector<ll> vl;
typedef vector<int> vi;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> vvl;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvec;
typedef vector<vector<bool>> vveb;
typedef vector<vector<string>> vves;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define rev(v) reverse(v.begin(), v.end())
#define fs first
#define sc second
#define pb push_back
#define pp pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) *max_element(all(a))
#define minel(a) *min_element(all(a))
#define acc accumulate
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)
typedef long long int64;
//const int64 INF = 1LL << 58;
#define dame { puts("-1"); return 0;}
#define YES { cout << "YES" << endl; return 0; }
#define NO { cout << "NO" << endl; return 0; }
#define Yes { cout << "Yes" << endl; return 0; }
#define No { cout << "No" << endl; return 0; }
#define uniq(a) sort(all(a));(a).resize(unique(all(a)) - a.begin());
#define dab(v) for(auto i:v)cout<<i<<' '; cout << endl;
#define vin(v) for (ll i = 0; i < v.size(); ++i) cin >> v[i];
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
int dx[] = {0, 0, -1, 1};
int dy[] = {1, -1, 0, 0};

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
    //cout << fixed << setprecision(15);
    
    ll X; cin>>X;
	int ans = 0;
	ans += (X/500) * 1000;
	X %= 500;
	ans += X / 5 * 5;
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <cstring>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <bitset>
#include <stack>
#include <cmath>
#define ll long long
#define LINF 0x3f3f3f3f3f3f3f3f
#define INF 0x3f3f3f3f
#define PI 3.14159265
using namespace std;
const int MAX = 1e5 + 10; //N
const ll MOD = 1e9 + 7;
int N, M, K, Q;
int A[53];
ll dp[53][3000][53];

ll rec(int here, int state, int num) {
	if (num < 0) return 0LL;
	if (here > N) {
		if (state == 0 && num == 0) return 1LL;
		else return 0LL;
	}
	ll &ret = dp[here][state][num];
	if (ret != -1LL) return ret;
	ret = 0LL;
	ret += rec(here + 1, state, num);
	ret += rec(here + 1, state - A[here], num - 1);
	return ret;
}

int main()
{
	int i, j, k, m;
	scanf("%d%d", &N, &m);
	memset(dp, -1LL, sizeof(dp));
	for (i = 1; i <= N; ++i) {
		scanf("%d", &A[i]);
	}
	ll cnt = 0LL;
	for (j = 1; j <= N; ++j) {
		cnt += rec(1, m*j, j);
	}
	printf("%lld", cnt);
}

Measured memory_bytes: 66048
import sys
import heapq, math
from itertools import zip_longest, permutations, combinations, combinations_with_replacement
from itertools import accumulate, dropwhile, takewhile, groupby
from functools import lru_cache
from copy import deepcopy

A, B, C, D = map(int, input().split())

print(A * B if A * B > C * D else C * D)

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

#define X first
#define Y second
#define LL long long
#define ULL unsigned long long
#define PB push_back
#define MP make_pair
#define VI vector<int>
#define PII pair<int,int>
#define IOS ios::sync_with_stdio(0);cin.tie(0);
#define IN freopen("in", "r", stdin);
#define OUT freopen("out", "w", stdout);

const int maxn=100010;

LL a[maxn],per[maxn];
char c[maxn];

int main()
{
	IOS;
	int n;
	cin>>n>>a[0];
	per[0]=a[0];
	LL abssum=a[0];
	LL ans=a[0];
	VI sub;
	for (int j=1;j<n;++j)
	{
		cin>>c[j]>>a[j];
		per[j]=per[j-1]+a[j];
		abssum+=a[j];
		if (c[j]=='+') ans+=a[j];
		else
		{
			ans-=a[j];
			sub.PB(j);
		}
	}
	for (int j=0;j<(int)sub.size()-1;++j)
	{
		int p1=sub[j];
		int p2=sub[j+1];
		LL tis=abssum-(per[p2-1]-per[p1-1])*2;
		ans=max(ans,tis);
		abssum-=a[p1]*2;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 2424
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int a,b;
    char op;    //文字にする。
    while(true){
         cin>>a>>op>>b;
         if(op=='?'){
             break;
         }
         else if(op=='+'){
             cout<<(a+b)<<endl;
         }
         else if(op=='-'){
             cout<<(a-b)<<endl;
         }
         else if(op=='*'){
             cout<<(a*b)<<endl;
         }
         else if(op=='/'){
             cout<<(a/b)<<endl;
         } 
    }
}


Measured memory_bytes: 3080
n = int(input())
a = list(map(int, input().split()))
cnt = [0, 0]
for v in a:
    cnt[v%2] += 1
if (cnt[1]%2 == 0) or (cnt[1]%2 == 1 and cnt[0] == 0):
    print('YES')
else:
    print('NO')
    

Measured memory_bytes: 14108
//設定言語check
#include <bits/stdc++.h>
#include <iostream>
#include <string>
#include <limits.h>
#include <algorithm>
#include <iomanip>
#include <math.h>
#include <queue>
using namespace std;

int main(){
  long long int N, ans = 0, maxlen, sign = -1 ;
  cin >> N ;
  maxlen = N / 3 ;
  if(N < 3){
    cout << 0 << endl ;
    return 0 ;
  }
  long long int dp[2002][700] = {} ;
  dp[3][1] = 1 ;
  for(int i=1;i<maxlen+1;i++){
    for(int j=3;j<N+1;j++){
      dp[j][i] += ( dp[j-3][i-1] + dp[j-1][i] ) % 1000000007 ;
    }
  }
  for(int i=1;i<maxlen+1;i++){
    ans += dp[N][i] ;
    ans %= 1000000007 ;
  }
  cout << ans << endl ;
  return 0 ;
}

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

using ll = long long;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define ddrep(i, n) for (int i = n; i > 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)
#define ssrep(i, s, t) for (int i = s; i <= t; ++i)

#define rng(a) a.begin(), a.end()
#define rrng(a) a.rbegin(), a.rend()
#define pb push_back
#define eb emplace_back
#define fi first
#define se second

#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))

using pi = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using ld = long double;

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
    os << "(" << p.first << "," << p.second << ")";
    return os;
}

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
    os << "{";
    rep(i, (int)v.size()) {
        if (i)
            os << ",";
        os << v[i];
    }
    os << "}";
    return os;
}

template <typename T, size_t S> void printArray(const T (&array)[S]) {
    for (auto val : array)
        std::cout << val << ", ";
    std::cout << "\n";
}

const int mod = 1e9 + 7;
const int inf = 1e9 + 5;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << std::setprecision(10);

    string s; std::cin >> s;
    vector<string> vec = {"dream", "dreamer", "erase", "eraser"};
    bool ans = true;
    auto check = [&](int i, string &vs) {
        int len = vs.size();
        i -= len-1;
        if (i < 0) return false;
        bool ok = true;
        for (int j = 0; j < len; i++, j++) {
            if (vs[j] != s[i]) ok = false;
        }
        return ok;
    };
    drep(i, s.size()) {
        bool ok = false;
        rep(j, vec.size()) {
            if (!check(i, vec[j])) continue;
            i -= vec[j].size()-1;
            ok = true;
            break;
        }
        if (!ok) ans = false;
    }
    std::cout << (ans ? "YES" : "NO") << "\n";
}


Measured memory_bytes: 512
using System;
using System.Linq;

namespace ABC047A
{
    class Program
    {
        public static void Main(string[] args)
        {
            var ABC = Console.ReadLine()
                .Split(' ')
                .Select(int.Parse)
                .OrderByDescending(x => x)
                .ToArray();

            Console.WriteLine(ABC[0] == ABC[1] + ABC[2] ? "Yes" : "No");
        }
    }
}

Measured memory_bytes: 11348
#include<cstdio>

int main(){
	int f[1000001] = {};
	int n;

	for(int i = 2; i < 500001; i++){
		f[i * 2] = 1;
	}

	for(int i = 3; i <= 1000; i += 2){
		for(int j = 3; j * i <= 1000000; j += 2){
			f[i * j] = 1;
		}		
	}

	int sum;

	while(scanf("%d", &n) + 1){
		int sum = n - 1;
		while(n){
			if(f[n]){
				sum--;
			}
			n--;
		}
		printf("%d\n", sum);
	}
	return 0;
}

Measured memory_bytes: 4936
#include <bits/stdc++.h>
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()
using ll = long long;
string char_to_string(char val) {
  return string(1, val);
}
int char_to_int(char val) {
  return val - '0';
}
template<class T> inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template<class T> inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}

int main() {
  string S; cin >> S;
  int tmp = 3000;
  int FLAG = 753;

  REP(i, S.size() - 2) {
    string str = S.substr(i, 3);
    int a = stoi(str);
    if(tmp > abs(a - FLAG)) {
      tmp = abs(a - FLAG);
    }
  }

  cout << tmp << endl;
}

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

int main() {
  int N;
  cin >> N;
  vector<int> P(N);
  for (int i = 0; i < N; i++) cin >> P.at(i);
  int ans = 0;
  for (int i = 0, mi = 1e9; i < N; i++) {
    if (P.at(i) > mi) continue;
    ans++;
    mi = P.at(i);
  }
  cout << ans << "\n";
}

Measured memory_bytes: 4056
#define _USE_MATH_DEFINES
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cctype>
#include <climits>
#include <clocale>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

const int MOD = 1000000007; 
const int INF = 1000000000; //1e9
const int NIL = -1;
const long long LINF = 1000000000000000000; // 1e18
const long double EPS = 1E-10;

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




int main(){
    int N; std::cin >> N;
    std::vector<std::pair<std::pair<std::string, int>, int>> store(N);
    {
        std::string s; int t;
        for(int i(0); i < N; ++i){
            std::cin >> s >> t;
            store[i] = {{s, -t}, i+1};
        }
    }
    std::sort(store.begin(), store.end());
    for(int i(0); i < N; ++i){
        std::cout << store[i].second << "\n";
    }
    return 0;
}


Measured memory_bytes: 256
import java.util.*;
 
class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int result = 0;
        if(b % a == 0){
            result = a + b;
        }else{
        	result = b - a;
        }
      
      	System.out.println(result);
    }
}

Measured memory_bytes: 22612
import math

def main():
    K = int(input())
    
    sum = 0
    for a in range(1, K+1):
        for b in range(1, K+1):
            for c in range(1, K+1):
                sum += math.gcd(math.gcd(a, b), c)
    print(sum)
    
main()

Measured memory_bytes: 9152
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>

#define REP(i, a, b) for (int i = int(a); i < int(b); i++)
#ifdef _DEBUG_
#define dump(val) cerr << __LINE__ << ":\t" << #val << " = " << (val) << endl
#else
#define dump(val)
#endif

using namespace std;

typedef long long int ll;

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

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

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n, m;
    cin >> n >> m;
    vector<int> Cnt(m, 0);
    auto sum = make_v(n + 1, m, 0);
    REP(i, 0, n) {
        int a;
        cin >> a;
        Cnt[a - 1]++;
        sum[i + 1][a - 1]++;
        REP(j, 0, m) {
            sum[i + 1][j] += sum[i][j];
        }
    }

    int size = 1 << m;
    const int inf = 1 << 30;
    auto dp = make_v(size, inf);
    dp[0] = 0;
    REP(i, 0, size) {
        int bs = 0;
        REP(j, 0, m) {
            if ((i >> j) & 1) {
                bs += Cnt[j];
            }
        }
        REP(j, 0, m) {
            if ((i >> j) & 1) continue;
            int nbs = bs + Cnt[j];
            int diff = sum[nbs][j] - sum[bs][j];
            int len = Cnt[j];
            chmin(dp[i | (1 << j)], dp[i] + len - diff);
        }
    }
    cout << dp[size - 1] << endl;
    return 0;
}



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

int main(){
    int a, b;
    char op;

    while(1){
        cin >> a >> op >> b;
        if (op == '?') break;
        else if (op == '+') cout << a + b << endl;
        else if (op == '-') cout << a - b << endl;
        else if (op == '*') cout << a * b << endl;
        else if (op == '/') cout << a / b << endl;
        else break;
    }
}


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

public class Main {

  public static void main(String[] args) {

    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    long[] a = new long[n];

    for (int i = 0; i < n; i++) {
      a[i] = sc.nextInt();
    }

    Arrays.sort(a); // 昇順
    long sum = a[n - 1];

    if (n == 2) {
      System.out.println(sum);
    } else {
      if (n % 2 == 1) {
        int num = n / 2;
        sum += a[n - num - 1];
        for (int i = n - num; i < n - 1; i++) {
          sum += 2 * a[i];
        }
        System.out.println(sum);
      } else {
        int num = n / 2;
        for (int i = n - num; i < n - 1; i++) {
          sum += 2 * a[i];
        }
        System.out.println(sum);
      }
    }

  }
}

Measured memory_bytes: 61104
#include <stdio.h>

int main(void)
{
    int a, b, c;

    scanf("%d %d", &a, &b);

    for(c = 1; c <= 3; c++){
        if((a * b * c) % 2 == 1){
            puts("Yes");
            return 0;
        }
    }

    puts("No");

    return 0;
}

Measured memory_bytes: 128
from collections import deque
N = int(input())
A = deque(map(int, input().split()))
mod = 10**9 + 7
M = len(bin(max(A))) - 2
ans = 0
bitlist = [1]
anslist = [0 for _ in range(M)]
for k in range(M):
    bitlist.append(bitlist[-1]*2%mod)
counter = [0 for _ in range(M)]

for k in range(N):
    a = A.pop()
    c = 0
    while c < M:
        b = a & 1
        if b == 0:
            anslist[c] += counter[-c-1]
        else:
            anslist[c] += k - counter[-c-1]
            counter[-c-1] += 1
        c += 1
        a >>= 1
for k in range(M):
    ans += anslist[k]*bitlist[k]%mod
    ans %= mod
print(ans)




Measured memory_bytes: 119456
// g++ -std=gnu++1y -O2 main.cpp

#include <cstdio>
#include <vector>
#include <set>

#include <map>
#include <unordered_map>
#include <string>
#include <utility>
#include <algorithm>
#include <iostream>
#include <iostream>
#include <climits>

using namespace std;

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 int INF = 1e9;
const long long LINF = 1e18;

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

	vector<int> X(N);
	for (int i = 0; i < N; i++)
	{
		int Xi;
		cin >> Xi;
		X[i] = Xi;
	}

	int P = 1;
	int minSum = INF;
	for (int p = 1; p <= 100; p++)
	{
		int sum = 0;
		for (int i = 0; i < N; i++)
		{
			sum += (X[i] - p) * (X[i] - p);
		}
		if (sum < minSum) {
			P = p;
			minSum = sum;
		}
	}

	cout << minSum << endl;
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <algorithm>

#include <bits/stdc++.h>
#include <cmath>
#include <limits>

using namespace std;
typedef long long LL;
using Graph = vector<vector<int>>;

static long long INF = (1LL<<62);

int main(int argc, char* argv[]){
	cin.tie(0);
	ios::sync_with_stdio(false);

	int N;
	string S, T, U;
	cin >> N;
	cin >> S >> T;

	for(int i=0; i<N; i++){
		U.push_back(S[i]);
		U.push_back(T[i]);
	}
	printf("%s\n", U.c_str());
	return 0;

}



Measured memory_bytes: 3648
#include <iostream>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <list>
#include <vector>
#include <complex>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <bitset>
#include <ctime>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cassert>
#include <cstddef>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <sstream>
#include <fstream>

#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define FOR(i, a, b) for (int (i) = (a); (i) < (b); (i)++)
#define RREP(i, a) for(int (i) = (a)-1; (i) >= 0; (i)--)
#define FORR(i, a, b) for(int (i) = (a)-1; (i) >= (b); (i)--)
#define PI acos(-1.0)
#define DEBUG(C) cout<< C <<endl;
#define VI vector <int>
#define VII vector <VI>
#define VL vector <LL>
#define VLL vector <VL>
#define VD vector <double>
#define VDD vector <VD>
#define PII pair <int, int>
#define PDD pair <double, double>
#define PLL pair <LL, LL>
#define VPII vector <PII>
#define ALL(a) (a).begin(), (a).end()
#define SORT(a) sort(ALL(a))
#define REVERSE(a) reverse(ALL(a))
#define MP make_pair
#define FORE(a,b) for(auto &&a:b)

using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
const int INF = 1e9;
const int MOD = INF+7;
const LL LLINF = 1e18;
#define int LL
LL n, s;
LL f(LL b, LL n) {
    if (n < b) return n;
    else return f(b, floor((double)n/(double)b))+(n%b);
}

signed main(void) {
    cin >> n >> s;
    if (n < s) {
        cout << -1 << endl;
        return 0;
    }
    if (n == s) {
        cout << n+1 << endl;
        return 0;
    }
    LL ans = LLINF;
    for (int i = 2; i*i <= n; i++) {
        if (f(i, n) == s) {
            ans = min<LL>(ans, i);
        }
    }
    for (int i = 1; i*i <= n; i++) {
        if ((n-s)%i) continue;
        LL b = ((n-s)/i)+1;
        if (f(b, n) == s) {
            ans = min(ans, b);
        }
    }
    cout << (ans!=LLINF?ans:(-1)) << endl;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
    long long ans=0,a[201]={0},n=0;
    cin>>n;
    for(int i=0;i<n;i++)
        cin>>a[i];
    for(int f=0;f==0;ans++){
        for(int i=0;i<n;i++)
            if(a[i]%2==1) f++;
        for(int i=0;i<n;i++)
            a[i]=a[i]/2;
   }
   cout<<--ans;
//   system("Pause");
   return 0;
}


Measured memory_bytes: 256
let () =
  let rec makeN n m = if m = 0 then "" else n ^ (makeN n (m-1)) in
  let ios = int_of_string in
  Scanf.scanf "%s %s\n" @@ fun a b ->
  Printf.printf "%d\n" @@ (if a < b then (ios (makeN a (ios(b)))) else (ios (makeN b (ios(a)))))

Measured memory_bytes: 384
from collections import defaultdict
from itertools import permutations
import heapq

INF = float('inf')
N, M, R = map(int, input().split())
r = list(map(int, input().split()))
memo = [[INF for _ in range(N)] for _ in range(N)]

Adj_list = defaultdict(set)

for i in range(M):
    a, b, c = map(int, input().split())
    if memo[a-1][b-1]:
        memo[a-1][b-1] = min(memo[a-1][b-1], c)
        
    Adj_list[a-1].add((b-1, memo[a-1][b-1]))
    Adj_list[b-1].add((a-1, memo[a-1][b-1]))


def dijkstra(x, vertex):
    d = [INF] * x
    d[vertex] = 0
    hq = [(0, vertex)]
    
    while hq:
        u = heapq.heappop(hq)[1]
        for (v, c) in Adj_list[u]:
            if d[v] > d[u] + c:
                d[v] = d[u] + c
                heapq.heappush(hq, (d[u]+c, v))

    return d

ans = INF
t_dis = 0

table = {}
for i in r:
    table[i-1] = dijkstra(N, i-1)

for each in permutations(r):
    t_dis = 0
    for i in range(R-1):
        t_dis += table[each[i]-1][each[i+1]-1]
    #print(each, t_dis)
    ans = min(ans, t_dis)

print(ans)

Measured memory_bytes: 8696
#!/usr/bin/env python3
import sys

MOD = 2  # type: int


def solve(N: int, a: "List[int]"):
    # ボールの数をカウント
    tf = [0] * N
    # ボールの数をカウント
    m = 0
    x = []
    for i in range(N-1, -1, -1):
        # iの倍数の箱に入ったボールを求める
        b = sum([tf[j] for j in range(i+(i+1), N, i+1)])
        if(b%2 != a[i]):
            m += 1
            x.append(i+1)
            tf[i] = (tf[i]+1)%2
        
    print(m)
    if(x):
        print(' '.join(map(str, x)))

    return


# Generated by 1.1.5 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    a = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, a)

if __name__ == '__main__':
    main()


Measured memory_bytes: 21588
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#define max(a, b)	(((a) > (b)) ? (a) : (b))		/* ２個の値の最大値 */
#define min(a, b)	(((a) < (b)) ? (a) : (b))		/* ２個の値の最小値 */
#define ENTER		printf("\n")					/* 改行プリント */
/********************************************************************************************************************************/
/* main *************************************************************************************************************************/
/********************************************************************************************************************************/
int DEBUG = 1;										/* デバッグプリント 提出時は0 */
int main()
{
	int		i, n, p[21], ans = 0;
	
	scanf("%d", &n);
	for(i=1;i<=n;i++) {
		scanf("%d", &p[i]);
	}
	for(i=2;i<n;i++) {
		if ((p[i-1]<p[i])&&(p[i]<=p[i+1])) ans++;
		else if((p[i+1]<p[i])&&(p[i]<=p[i-1])) ans++;
	}
	printf("%d\n",ans);

	return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define mx 1

int main()
{
	ios_base::sync_with_stdio(0);
	int n;
	cin>>n;
	ll ans = 0;
	map<string, int> mp;
	string str;
	for(int i=1; i<=n; i++){
		cin>>str;
		sort(str.begin(), str.end());
		ans+=mp[ str ];
		mp[ str ]++;
	} 
	cout<<ans<<endl;
 }

Measured memory_bytes: 11264
#include <cstdio>
#include <cstring>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <sstream>
#include <string>
#include <set>
#include <queue>
using namespace std;
#define mem(a,n) memset(a,n,sizeof(a))
#define pb(x) push_back(x)
typedef long long ll;
typedef unsigned long long ull;
const int mod=1e9+7;
const double eps=1e-6;
const int INF=0x3f3f3f3f;
const int N=100+5;
int main()
{
    int x;
    while(~scanf("%d",&x))
    {
        int ans=0,i=1;
        while(ans<x)
        {
            ans+=i;
            i++;
        }
        printf("%d\n",i-1);
    }
    return 0;
}


Measured memory_bytes: 256
/*
#include<rabbit>;
using blueHulkStress;
using AceOfSpades;
*/
#include<bits/stdc++.h>
#include<stdio.h>
using namespace std;
const double PI = acos(-1.0);
const double EPS = (1e-9);
typedef long long ll;
typedef unsigned long long ull;
#define flush fflush(stdout), cout.flush()
#define all(v) ((v).begin()),((v).end())
#define rall(v) ((v).rbegin()),((v).rend())
#define clr(v,line) memset(v,line,sizeof(v))
#define rep(i,n) for(int(i)=0;(i)<(int)(n);(i)++)
#define vi vector<int>
#define vll vector<ll>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define lcm(a,b) (a*(b/__gcd(a,b)))
#define P 1000000007
#define endl '\n'
const int dx[] = {1,-1,0,0,1,-1,1,-1};
const int dy[] = {0,0,1,-1,1,-1,-1,1};
const int dxhorse[] = {-2,-2,-1,-1,1,1,2,2};
const int dyhorse[] = {1,-1,2,-2,2,-2,1,-1};


int main(int argc, char const *argv[])
{
	
	ll a,b,c;cin>>a>>b>>c;

	cout<<min(a*b,c);
}	

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <sstream>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <vector>
#include <set>
#include <map>
#include <queue>
using namespace std;

int main() {
    string ans = "";
    string S;
    int K;
    cin >> K;
    cin >> S;
    string ext="...";
    if(S.length()<=K){
        ans = S;
    }
    else{
        for (int i=0; i<K; i++) {
            ans += S[i];
        }
        ans += ext;
    }
    cout << ans << endl;
}


Measured memory_bytes: 3560
import java.util.*;
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        long n = sc.nextLong();
        Map<Long,Long> map = new HashMap<>();
        for(long i = 1;i*i<=n;i++){
            if(n%i==0){
                map.put(i,n/i);
            }
        }
        Set<Long> set = map.keySet();
        long ans = 1001001001001L;
        for(Long e: set){
            long a = Math.abs(e-1)+Math.abs(map.get(e)-1);
            if(ans>a){
                ans = a;
            }
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 37504
//To compile : type "$     g++ test.cpp -std=c++14 -I .    "
#include <atcoder/all>
#include <bits/stdc++.h>
//#include <chrono>
//#pragma GCC optimize("Ofast")
using namespace std;
using namespace atcoder;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
#define ALL(a) a.begin(), a.end()
#define fi first
#define se second
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,Q,K,A,B;
string S;
typedef pair<ll, ll> P;
const ll INF = (1LL<<60);

int main() {
	int n, q;
	cin>>n>>q;
	dsu uf(n);
	rep(i,q){
		int t, u, v;
		cin>>t>>u>>v;
		if(t == 0){
			uf.merge(u, v);
		}else{
			cout<<uf.same(u, v)<<endl;
		}
	}
}


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

using namespace std;



int main() {

	int a, b, c, d, e, k;
	cin >> a >> b >> c >> d >> e >> k;
	if (e - a > k) {
		cout << ":(" << endl;
	}
	else {
		cout << "Yay!" << endl;
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
  int N,X,Y;
  cin >> N >> X >> Y;
  X--; Y--;
  int ans[N - 1];
  for (int i = 0; i < N - 1; i++) {
    ans[i] = 0;
  }
    for (int i = 0; i < N; i++) {
    for (int j = i + 1; j < N; j++) {
      ans[min(j - i - 1,abs(i - X) + abs(j - Y))]++;
  }
}
  for (int i = 0; i < N - 1; i++) {
    cout << ans[i] << endl;
  }
  return 0;
}


Measured memory_bytes: 256
DIV = 10**9 + 7
H, W = map(int, input().split())
A = []
for _ in range(H):
    A.append(input())
dp = [[0 for _ in range(W)] for _ in range(H)]

for i in range(H):
    if A[i][0] == '.':
        dp[i][0] = 1
    else:
        break
for j in range(W):
    if A[0][j] == '.':
        dp[0][j] = 1
    else:
        break

for i in range(1, H):
    for j in range(1, W):
        if A[i][j] == '.':
            dp[i][j] = dp[i-1][j] + dp[i][j-1]
print(dp[H-1][W-1] % DIV)

Measured memory_bytes: 210412
L,R=map(int,input().split())
ans=100100100
if (R-L-1)<2019:
  for i in range(L,R):
    for j in range(i+1,R+1):
      if ans>((i*j)%2019):
        ans=((i*j)%2019)
  print(ans)
else:
  print(0)

Measured memory_bytes: 3060
N = gets.chomp.to_i
A = gets.chomp.split(' ').map(&:to_i)

A.sort! {|a, b| b <=> a }

temp = Hash.new(0)
av = []
ans = 0
A.each do |a|
  temp[a] += 1
  if temp[a] % 2 == 0
    av << a
  end

  if av.length == 2
    ans = av.inject(:*)
    break
  end
end

print ans


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

using ll = int64_t;
#define int ll

#define FOR(i, a, b) for (int i = int(a); i < int(b); i++)
#define REP(i, b) FOR(i, 0, b)
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define ALL(x) x.begin(), x.end()

using pi = pair<int, int>;
using vi = vector<int>;
using ld = long double;

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
  os << "{";
  REP(i, (int)v.size()) {
    if (i)
      os << ",";
    os << v[i];
  }
  os << "}";
  return os;
}

ll read() {
  ll i;
  scanf("%" SCNd64, &i);
  return i;
}

void printSpace() { printf(" "); }

void printEoln() { printf("\n"); }

void print(ll x, int suc = 1) {
  printf("%" PRId64, x);
  if (suc == 1)
    printEoln();
  if (suc == 2)
    printSpace();
}

string readString() {
  static char buf[3341000];
  scanf("%s", buf);
  return string(buf);
}

char *readCharArray() {
  static char buf[3341000];
  static int bufUsed = 0;
  char *ret = buf + bufUsed;
  scanf("%s", ret);
  bufUsed += strlen(ret) + 1;
  return ret;
}

template <class T, class U> void chmax(T &a, U b) {
  if (a < b)
    a = b;
}

template <class T, class U> void chmin(T &a, U b) {
  if (b < a)
    a = b;
}

const int mod = 1e9 + 7;
const int inf = 1e9 + 5;

signed main() {
  int n, m;
  std::cin >> n >> m;
  if (m / 2 <= n)
    print(m / 2);
  else
    print(n + (m - n * 2) / 4);
}


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


class SegmentTree:
    def __init__(self, N, func, I):
        self.N = N
        self.sz = 2**(N-1).bit_length()
        self.func = func
        self.I = I
        self.seg = [I] * (self.sz * 2)

    def assign(self, k, x):
        self.seg[k + self.sz] = x

    def build(self):
        for i in reversed(range(1, self.sz)):
            self.seg[i] = self.func(self.seg[2 * i], self.seg[2 * i + 1])

    def update(self, k, x):
        k += self.sz
        self.seg[k] = x
        while k > 1:
            k >>= 1
            self.seg[k] = self.func(self.seg[2 * k], self.seg[2 * k + 1])

    def query(self, a, b):
        L = self.I
        R = self.I
        a += self.sz
        if b == self.N:
            b = self.sz
        b += self.sz
        while a < b:
            if a & 1:
                L = self.func(L, self.seg[a])
                a += 1
            if b & 1:
                b -= 1
                R = self.func(self.seg[b], R)
            a >>= 1
            b >>= 1
        return self.func(L, R)


def main():
    def gcd(a, b):
        while b:
            a, b = b, a % b
        return a
    N = int(readline())
    L = map(int, readline().split())
    seg = SegmentTree(N, gcd, 0)
    for i, n in enumerate(L):
        seg.assign(i, n)
    seg.build()
    ans = 1
    for i in range(N):
        ans = max(ans, gcd(seg.query(0, i), seg.query(i+1, N)))
    print(ans)


main()


Measured memory_bytes: 60528
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>

#define REP(i, n) for(int i = 0; (i) < (n); ++(i))
#define FOR(i, n) for(int i = 1; (i) <= (n); ++(i))
#define dump(x) cout << #x << " = " << (x) << endl;
#define pb push_back
#define int long long

const int INF = 1e18;
const int MOD = 1e9 + 7;
// const lint LINF = 1e18;
const double eps = 0.000000001;  //もとの値の10^(-16)まで

using namespace std;

typedef pair<int, int> P;
priority_queue< P, vector<P> > q;//ダイクストラの時、greaterで小さい順
// cout << fixed << setprecision(10) << ans << endl;
vector<int> a;
vector<int> f;
signed main() {
  int n, k;
  cin >> n >> k;
  REP(i, n) {
    int a1;
    cin >> a1;
    a.pb(a1);
  }
  REP(i, n) {
    int f1;
    cin >> f1;
    f.pb(f1);
  }
  sort(a.begin(), a.end());
  sort(f.begin(), f.end());
  reverse(f.begin(), f.end());
  int lb = -1;
  int ub = 1000000000005;
  int k0 = 0;
  while(ub - lb > 1){
    k0 = 0;
    int mid = (ub+lb)/2;
    REP(i,n){
      k0 += max((int)0,a[i] - mid/f[i]);
    }
    if(k>=k0){
      ub = mid;
    }
    else lb = mid;
  }
  cout << ub << endl;
  return 0;
}

Measured memory_bytes: 4848
/************************************************************
	> File Name: b.cpp
	> Author: TSwiftie
	> Mail: 2224273204@qq.com 
	> Created Time: Sun 17 May 2020 08:10:24 PM CST
************************************************************/
#pragma GCC optimize(2)
#include <bits/stdc++.h>
#include <ext/rope>
#define lowbit(x) (x&-x)
#define SZ(x) ((int)x.size())
#define all(x) x.begin(),x.end()
#define lc (o<<1)
#define rc (o<<1|1)
#define IOS ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
using namespace std;
typedef long long LL;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<LL> vll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<LL,LL> pll;
const int INF = 0x3f3f3f3f;
const LL INF_ll = 0x3f3f3f3f3f3f3f3fLL;
const double PI = acos(-1.0);
const double EPS = 1e-8;
signed main(void){
	int k;
	string s;
	cin >> k >> s;
	if(SZ(s) > k)
		cout << s.substr(0,k) + "..." << endl;
	else cout << s << endl;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0; i<(n); i++)
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
int main(){
    ll n; cin>>n;
    ll res=1e15;
    for(ll i=1; i*i<=n; i++){
        if(n%i==0){
            chmin(res, i+(n/i)-2);
        }
    }
    cout<<res<<endl;
    return 0;
}

Measured memory_bytes: 256
#include "iostream"
#include <stdio.h>
#include <algorithm>
#include <stdlib.h>
#include <cstring>
#include <math.h>
#include <cctype>
#include <stack>
#include <vector>
#include <list>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <iomanip>
using namespace std;
using ll=long long;
#define MOD  1000000007
ll n,p,ans=0;
ll flag[1000010];

int main(int argc, char const *argv[]) {

  memset(flag,0,sizeof(flag));
  std::cin >> n >> p;
  flag[1]=1;

if(p==1){
  std::cout << "1" << '\n';
  return 0;
}
if(n==1){
  std::cout << p << '\n';
  return 0;
}
for(int i=2; i<=sqrt(p); i++){
  ll m=p,cnt=0;
  while(m>0){
    if(m%i==0){
       m/=i;
       cnt++;
     }
     else break;
  if(n<=cnt) flag[i]++;
 }
}

for(int i=0; i<=sqrt(p); i++){
  if(flag[i]!=0) ans=i;
}
std::cout << ans << '\n';

  return 0;
}


Measured memory_bytes: 8064
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,m;
    cin>>n>>m;
    vector<int> map[n+1];
    int u,v;
    for(int i=0;i<m;i++){
    cin>>u>>v;
    map[u].push_back(v);
    map[v].push_back(u);
    }
    int counter=0;
    vector<int> levelone;
    for(int i=0;i<map[1].size();i++)
    {
        levelone.push_back(map[1][i]);

    }
    for(int i=0;i<levelone.size();i++)
    {
        int location=levelone[i];
        for(int j=0;j<map[location].size();j++)
        {
            if(map[location][j]==n)
                counter=1;

        }
    }
    if(counter)
        cout<<"POSSIBLE";
    else
        cout<<"IMPOSSIBLE";
}


Measured memory_bytes: 12784
#include <iostream>
#include <stdio.h>
using namespace std;

class Dice{

private:

public:

  int num[6];

  void roll(char c){
    int b;
    if(c == 'S'){
      b = num[0];
      num[0] = num[4];
      num[4] = num[5];
      num[5] = num[1];
      num[1] = b;
    }
    if(c == 'W'){
      b = num[0];
      num[0] = num[2];
      num[2] = num[5];
      num[5] = num[3];
      num[3] = b;
    }
    if(c == 'N'){
      b = num[0];
      num[0] = num[1];
      num[1] = num[5];
      num[5] = num[4];
      num[4] = b;
    }
    if(c == 'E'){
      b = num[0];
      num[0] = num[3];
      num[3] = num[5];
      num[5] = num[2];
      num[2] = b;
    }
  }

};

int main(){
  Dice d;
  char c;
  for(int i=0;i<6;i++) cin >> d.num[i];
  getchar();
  while((c = getchar()) != '\n'){
    d.roll(c);
  }
  cout << d.num[0] << endl;
}



Measured memory_bytes: 3092
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
#define MAX 100000
#define INF 1<<30
using namespace std;
int V,E;

struct Pox
{
  int from,to,cost;
  Pox(int from = -1,int to = -1,int cost = -1):from(from),to(to),cost(cost){}
};

bool cmp(const Pox& p1,const Pox& p2)
{
  return p1.cost < p2.cost;
}



int par[MAX+1];

int find(int x)
{
  if(x == par[x])return x;
  return par[x] = find(par[x]);
}

void unit(int x,int y)
{
  x = find(x);
  y = find(y);
  if(x != y)
    par[x] = y;
}

bool same(int x,int y)
{
  return find(x) == find(y);
}

int kruskal(vector<Pox>& G)
{
  sort(G.begin(),G.end(),cmp);
  int res = 0;
  for(int i=0;i<G.size();i++)
    {
      Pox pox = G[i];
      if(!same(pox.from,pox.to))
	{
	  unit(pox.from,pox.to);
	  res += pox.cost;
	}
    }
  return res;
}
 
int main(){
   
   
  while(cin >> V && V){  
    cin >> E;
    vector<Pox> G;
    for(int i=0;i<E;i++){
      par[i] = i;
      int from,to,Cost;
      scanf("%d,%d,%d",&from,&to,&Cost);
      G.push_back(Pox(from,to,Cost));
    }
  
    cout <<  kruskal(G)/100 - (V-1) << endl;
 
  }
  return 0;
}

Measured memory_bytes: 1400
//minamoto
#include<bits/stdc++.h>
#define R register
#define fi first
#define se second
#define pb push_back
#define fp(i,a,b) for(R int i=(a),I=(b)+1;i<I;++i)
#define fd(i,a,b) for(R int i=(a),I=(b)-1;i>I;--i)
#define go(u) for(int i=head[u],v=e[i].v;i;i=e[i].nx,v=e[i].v)
template<class T>inline bool cmax(T&a,const T&b){return a<b?a=b,1:0;}
template<class T>inline bool cmin(T&a,const T&b){return a>b?a=b,1:0;}
using namespace std;
const int N=2e5+5;
typedef pair<int,int> pi;
typedef long long ll;
int n,l,a[N];pi b[N];ll res=0;
ll calc(R vector<pi> &v){
	R ll res=0,sum=0;
	for(R int i=0,j=l-1,s=v.size();j<s;++i,++j)
		sum+=v[i].fi,res+=sum*v[j].se;
	return res;
}
vector<pair<pi,pi> >f,g;
int main(){
	scanf("%d%d",&n,&l);
	fp(i,1,n)scanf("%d",&a[i]),b[i]=pi(a[i],i);
	sort(b+1,b+1+n);
	res=n;
	for(R int val=0,pos=1;233;f=g){
		if(f.empty()){
			if(pos>n)break;
			val=b[pos].fi;
		}else ++val;
		while(val==b[pos].fi)f.pb(make_pair(pi(b[pos].se,b[pos].se),pi(1,1))),++pos;
		g.clear(),sort(f.begin(),f.end());
		for(R int i=0,j=0,s=f.size();i<s;i=++j){
			while(j+1<s&&f[j+1].fi.fi==f[j].fi.se+1)++j;
			R int len=j-i+1,cnt=len/l;
			if(cnt){
				vector<pi>tmp,ff,gg;
				fp(k,i,j)tmp.pb(f[k].se);
				res+=calc(tmp);
				fp(k,1,cnt){
					ff.pb(pi(f[i].fi.fi+k-1,(k==cnt)?f[j].fi.se:f[i].fi.fi+k-1));
					gg.pb(pi(0,0));
				}
				fp(k,i,j){
					R int tl=k-i+1,tr=j-k+1;
					if(tl>=l)gg[tl/l-1].se+=f[k].se.se;
					if(tr>=l)gg[cnt-tr/l].fi+=f[k].se.fi;
				}
				res-=calc(gg);
				for(R int k=0;k<cnt;++k)g.pb(make_pair(ff[k],gg[k]));
			}
		}
	}
	printf("%lld\n",res);
	return 0;
}

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

int main()
{
  int a, b, c, x;
  cin >> a >> b >> c >> x;
  int ret = 0;
  for(int i = 0; i <= a; ++i){
    for(int j = 0; j <= b; ++j){
      for(int k = 0; k <= c; ++k){
        int sum = 500 * i + 100 * j + 50 * k;
        if(sum == x){
          ++ret;
        }
      }
    }
  }
  cout << ret << endl;
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#define max 10000
main(){
  int i,j,n,q,f[max],s[max],count=0;
  scanf("%d",&n);
  for(i=0;i<n;i++)
    scanf("%d",&f[i]);
  scanf("%d",&q);
  for(i=0;i<q;i++)
    scanf("%d",&s[i]);
  for(i=0;i<q;i++)
    for(j=0;j<n;j++)
      if(f[j]==s[i]){
    count++;
    break;
      }
  printf("%d\n",count);
  return 0;
}

Measured memory_bytes: 644
import itertools

A,B,C,D,E,F = map(int,input().split())

WF = F//100+1

water = [False] * (WF+1+30)
sugar = [False] * (F+1+30)

water[0] = True
sugar[0] = True

for n in range(WF):
  if water[n]:
    water[n+A] = True
    water[n+B] = True
for n in range(F):
  if sugar[n]:
    sugar[n+C] = True
    sugar[n+D] = True

water = set(100*x for x in range(1,1+WF) if water[x])
sugar = set(x for x in range(1+F) if sugar[x])

# at most 30 * 3000なので全てやる
ans_per = -1
for w, s in itertools.product(water, sugar):
  if w//100*E < s:
    continue
  if w+s > F:
    continue
  x = s/(w+s)
  if x > ans_per:
    ans_per = x
    ans_w = w
    ans_s = s

print(ans_w + ans_s, ans_s)

Measured memory_bytes: 3316
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

//Atcoder用

/*
 * BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] abc = br.readLine().split(" ");
		int a = Integer.parseInt(abc[0]);
		int b = Integer.parseInt(abc[1]);
		int c = Integer.parseInt(abc[2]);
 */
public class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] get = br.readLine().split(" ");
		int n = Integer.parseInt(get[0]);
		int k = Integer.parseInt(get[1]);

		if(n%k==0)System.out.println(0);
		else System.out.println(1);
	}


}


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

int main() {
    int a, b, c;
    cin >> a >> b >> c;
    for (int i = 1;; i++) {
        c -= a;
        if (i % 7 == 0) c -= b;
        if (c <= 0) {
            cout << i << endl;
            break;
        }
    }
    return 0;
}


Measured memory_bytes: 3108
#include <algorithm>
#include <cmath>
#include <complex>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <ios>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <utility>
#include <vector>
#define itn int
#define retrun return
#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
using namespace std;
typedef long long llong;
typedef pair<int, int> pii;
llong gcd(llong a, llong b) {
	if (a < b) std::swap(a, b);
	if (a % b == 0)
		return b;
	else
		return gcd(b, a % b);
}
llong lcm(llong a, llong b) {
	llong g = gcd(a, b);
	return a * b / g;
}
//ここまで共通
int A, B;
int main() {
	cin >> A >> B;

	for (int i = 1; i <= 1000; i++) {
		double tmp1 = i * 0.08;
		double tmp2 = i * 0.10;
		int tmp3 = tmp1;
		int tmp4 = tmp2;
		if (tmp3 == A && tmp4 == B) {
			cout << i << endl;
			return 0;
		}
	}

	cout << -1;
	return 0;
}

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

#define REP(i, n, N) for(ll i=(n); i<(N); i++)
#define RREP(i, n, N) for(ll i=(N-1); i>=(n); i--)
#define LREP(lst,itr) for(auto itr = lst.begin(); itr != lst.end(); ++itr)
#define CK(n, a, b) ((a)<=(n)&&(n)<(b))
#define ALL(v) (v).begin(),(v).end()
#define MCP(a, b) memcpy(b,a,sizeof(b))
#define P(s) cout<<(s)<<endl
#define P2(a, b) cout<<(a)<<" "<<(b)<<endl
#define P3(a, b, c) cout<<(a)<<" "<<(b)<<" "<<(c)<<endl
#define V2(T) vector<vector<T>>
typedef long long ll;
using namespace std;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;

int main(){
    int N,a;
    cin >> N;
    map<int, int> mp;
    REP(i,0,N){
        cin >> a;
        if(mp[a]){
            P("NO");
            return 0;
        }
        mp[a]=1;
    }
    P("YES");
}

Measured memory_bytes: 9600
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cctype>
#include<algorithm>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<cstring>
#include<list>
//#include<windows.h>
//#include<time.h>
#define pb push_back
#define ppb pop_back
#define fi first
#define se second
#define mer make_pair
#define mme memset
#define ao(a) (a.begin(),a.end())
using namespace std;

const double pie1=3.1415926;//π1
const double pie2=3.14159265358979;//π2
const double pie3=3.14159265358979323846;//π3
const int vbi=999999999;
const int vli=-vbi;
const long long vbl=999999999999999999;
const long long vll=-vbl;

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<pii,int> piii;
typedef pair<pii,pii> pi4;
typedef pair<pll,ll> plll;
typedef pair<int,pii> ipii;
typedef pair<ll,pll> lpll;
typedef pair<pll,pll> pl4;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pii> vpi;
typedef vector<pll> vpl;
typedef set<int> sti;
typedef set<ll> stl;
typedef set<pii> spi;
typedef set<pll> spl;
priority_queue<int> pqi;
priority_queue<ll> pql;
queue<int> qi;
queue<ll> ql;

/*void bin_v(){
	char bin[1000];
	gets(bin);
}*/

bool pss(int a){
	for(int i=2;i<=sqrt(a);i++)
		if(a%i==0)
			return false;
	return true;
}
/////////////////////////////////////////////////////////////////////////////////////////

int n,m;
vector<int> v[100010];
vector<int> lj;
int col[100010];

bool dfs(int now,int last){
	lj.pb(now);
	if(now==n)
		return true;
	for(int i=0;i<v[now].size();i++)
		if(v[now][i]!=last)
			if(dfs(v[now][i],now))
				return true;
	lj.ppb();
	return false;
}

void dfs2(int now,int last,int c){
	if(col[now]==(3-c))
		return;
	col[now]=c;
	for(int i=0;i<v[now].size();i++)
		if(v[now][i]!=last)
			dfs2(v[now][i],now,c);
}

int main(){
	//my name is Veex_WCY
	ios::sync_with_stdio(false);
	cin>>n;
	m=n-1;
	for(int i=1;i<=m;i++){
		int a,b;
		cin>>a>>b;
		v[a].pb(b);
		v[b].pb(a);
	}
	dfs(1,-1);
	for(int i=0;i<ceil(lj.size()*1.0/2);i++){
		col[lj[i]]=1;
	}
	for(int i=ceil(lj.size()*1.0/2);i<lj.size();i++)
		col[lj[i]]=2;
	dfs2(1,-1,1);
	dfs2(n,-1,2);
	int sum1,sum2;
	for(int i=1;i<=n;i++){
		if(col[i]==1)
			sum1++;
		else
			sum2++;
//		cout<<col[i]<<' ';
	}
	if(sum1>sum2)
		cout<<"Fennec";
	else
		cout<<"Snuke";
	return 0;
}


Measured memory_bytes: 11384
#include <bits/stdc++.h>
#include <vector>
#include <cstdlib>
using namespace std;
int main(void){
  string R, G;
  cin >> R;
  cin >> G;
  if(R == G){
    cout << "=";
  } else if(R > G){
    cout << ">";
  } else {
    cout << "<";
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a, b , I;
  cin >> a >> b;
 
 I=(a*b)%2;
  if (I == 0) {
    cout << "Even" << endl;
    }else if (I == 1) {
      cout << "Odd" << endl;
    }
 
}

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

using namespace std;

int main()
{
	int n;
	cin >> n;
	long long a[50];
	for (int i = 0; i < n; i++)
		cin >> a[i];
	long long ans = 0;
	while (true)
	{
		long long tmp = 0;
		bool ok = true;
		for (int i = 0; i < n; i++)
		{
			tmp += a[i] / n;
			if (a[i] >= n)
				ok = false;
		}
		if (ok)
			break;
		ans += tmp;
		for (int i = 0; i < n; i++)
			a[i] = a[i] % n + tmp - a[i] / n;
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
int N, M, a[50], b[50], par[50];
int root(int x) {
	if (x == par[x]) return x;
	return par[x] = root(par[x]);
}
void unite(int x, int y) {
	x = root(x);
	y = root(y);
	par[x] = y;
}
int main() {
	cin >> N >> M;
	for (int i = 0; i < M; i++) cin >> a[i] >> b[i], a[i]--, b[i]--;
	int ret = 0;
	for (int i = 0; i < M; i++) {
		for (int j = 0; j < N; j++) par[j] = j;
		for (int j = 0; j < M; j++) {
			if (i != j) unite(a[j], b[j]);
		}
		bool f = false;
		for (int j = 1; j < N; j++) {
			if (root(j - 1) != root(j)) f = true;
		}
		if (f) ret++;
	}
	cout << ret << endl;
	return 0;
}

Measured memory_bytes: 256