akhauriyash/Code-Regression huggingface dataset:
def resolve():
    S = input()
    sumA = 0
    for i in range(2**(len(S) - 1)):
        Stmp = list(S)
        for j in range(len(S) - 2, -1, -1):
            if (i >> j) & 1:
                Stmp.insert(j + 1, "+")
        sumA += eval("".join(Stmp))
    print(sumA)


resolve()


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

const int64_t INF = 1e18;
struct MinCostFlow{
    struct edge {
        int64_t to, cap, cost, rev;
        edge(int64_t to, int64_t cap, int64_t cost, int64_t rev):to(to), cap(cap), cost(cost), rev(rev){}
    };

    int N, S, T;
    int64_t flow;
    int64_t cost;
    vector<vector<edge>> G;
    vector<pair<int, int>> prv; // {v, e};
    vector<int64_t> h;

    MinCostFlow(int N, int S, int T):N(N), S(S), T(T){
        flow = cost = 0;
        G.resize(N);
        prv.resize(N);
        h.resize(N);
    }

    void add_edge(int64_t from, int64_t to, int64_t cap, int64_t cost){
        G[from].emplace_back(to, cap, cost, G[to].size());
        G[to].emplace_back(from, 0, -cost, G[from].size()-1);
    }

    int64_t calculate(int64_t f){
        typedef pair<int64_t, int> P;
        
        int64_t res = 0;
        vector<int64_t> dist(N);

        while(f > flow){
            priority_queue<P, vector<P>, greater<P>> que;
            fill(dist.begin(), dist.end(), INF);
            dist[S] = 0;
            que.push({0, S});
            while(que.size()){
                auto p = que.top(); que.pop();
                int64_t d = p.first;
                int i = p.second;
                if(d > dist[i]) continue;
                for(int idx=0; idx<int(G[i].size()); idx++){
                    auto& e = G[i][idx];
                    int j = e.to;
                    int64_t d2 = d + e.cost + h[i] - h[j];
                    if(e.cap > 0 && dist[j] > d2){
                        dist[j] = d2;
                        prv[j] = {i, idx};
                        que.push({dist[j], j});
                    }
                }
            }
            if(dist[T] == INF) return -1;
            for(int i=0; i<N; i++) h[i] += dist[i];
            
            int64_t d = f - flow;
            for(int i=T; i!=S; i=prv[i].first){
                auto& e = G[prv[i].first][prv[i].second];
                d = min(d, e.cap);
            }
            flow += d;
            res += d * h[T];
            for(int i=T; i!=S; i=prv[i].first){
                auto& e = G[prv[i].first][prv[i].second];
                e.cap -= d;
                G[i][e.rev].cap += d;
            }
        } 
        return res;
    }
};

int main(){
    int N, K;
    cin >> N >> K;
    int A[50][50];
    for(int i=0; i<N; i++) for(int j=0; j<N; j++) cin >> A[i][j];

    int S = 2*N, T = 2*N+1;
    MinCostFlow solver(T+1, S, T);
    for(int i=0; i<N; i++){
        solver.add_edge(S, i, K, 0);
        solver.add_edge(N+i, T, K, 0);
    }
    const int64_t OFFSET = 1e9;
    solver.add_edge(S, T, K*N, OFFSET);
    for(int i=0; i<N; i++) for(int j=0; j<N; j++) solver.add_edge(i, N+j, 1, OFFSET-A[i][j]);
    int64_t ans = OFFSET*K*N - solver.calculate(K*N);

    vector<string> X(N, string(N, '.'));
    for(int i=0; i<N; i++) for(auto& e : solver.G[i]) if(e.cap == 0) X[i][e.to-N] = 'X';
    cout << ans << endl;
    for(auto& s : X) cout << s << endl;
    return 0;
}


Measured memory_bytes: 3904
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
int main(){
  ll k;
  cin >> k;
  ll na=7;
  rep(i,1e6+1){
    na%=k;
    if(na==0){
      cout << i+1;
      return 0;
    }
    na=na*10+7;
  }
  cout << -1;
  
}
    

Measured memory_bytes: 3592
#include <stdio.h>

typedef struct {
    char type;
    int num;
} card_t;

int
main(void)
{
    char flag;
    int i, j, N, minj;
    card_t cards1[36], cards2[36], cards3[36], tmp;
    
    scanf("%d", &N);
    for(i = 0; i < N; ++i) {
        scanf(" %c%d", &cards1[i].type, &cards1[i].num);
        cards2[i] = cards1[i];
        cards3[i] = cards1[i];
    }
    
    //bubble sort is stable
    flag = 1;
    while(flag) {
        flag = 0;
        for(i = N - 1; i > 0; --i) {
            if(cards3[i].num < cards3[i-1].num) {
                tmp = cards3[i];
                cards3[i] = cards3[i-1];
                cards3[i-1] = tmp;
                flag = 1;
            }
        }
    }
    
    for(i = 0; i < N; ++i) {
        for(j = N - 1; j > i; --j) {
            if(cards1[j].num < cards1[j-1].num) {
                tmp = cards1[j];
                cards1[j] = cards1[j-1];
                cards1[j-1] = tmp;
            }
        }
    }
    
    flag = 0;
    for(i = 0; i < N; ++i) {
        if(cards1[i].type != cards3[i].type) flag = 1;
        if(i != N - 1) printf("%c%d ", cards1[i].type, cards1[i].num);
        else printf("%c%d\n", cards1[i].type, cards1[i].num);
    }
    if(flag) printf("Not stable\n");
    else printf("Stable\n");

    
    for(i = 0; i < N; ++i) {
        minj = i;
        for(j = i; j < N; ++j) {
            if(cards2[j].num < cards2[minj].num)
                minj = j;
        }
        tmp = cards2[i];
        cards2[i] = cards2[minj];
        cards2[minj] = tmp;
    }
  
    flag = 0;
    for(i = 0; i < N; ++i) {
        if(cards2[i].type != cards3[i].type) flag = 1;
        if(i != N - 1) printf("%c%d ", cards2[i].type, cards2[i].num);
        else printf("%c%d\n", cards2[i].type, cards2[i].num);
    }
    if(flag) printf("Not stable\n");
    else printf("Stable\n");
}



Measured memory_bytes: 2112
#include <stdio.h>
int main(void){
    int a,b;
    int d,r;
    double f;
    
    scanf("%d %d",&a,&b);
    
    d=a/b;
    r=a%b;
    f=a*1.0/b;
    
    printf("%d %d %lf\n",d,r,f);
    
    return 0;
}


Measured memory_bytes: 2104
using System;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            var a = Console.ReadLine().Split(' ');
            if (a[0] == a[1])
            {
                Console.WriteLine(a[2]);
            }
            else if (a[0] == a[2])
            {
                Console.WriteLine(a[1]);
            }
            else
            {
                Console.WriteLine(a[0]);
            }
        }
    }
}


Measured memory_bytes: 11092
#include <algorithm>
#include <cassert>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>

#include <limits.h>

using namespace std;

typedef long long ll;

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

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

map<ll, ll> counter;

const ll MOD = 2019;

int main(void) {
    string S;
    cin >> S;

    counter[0]++;
    ll ans = 0;
    ll acc = 0;
    ll power = 1;
    for (int i = (int) S.size() - 1; i >= 0; i--) {
        // acc = ((acc * 10) % MOD + (S[i] - '0')) % MOD;
        // acc = acc * 10 + (S[i] - '0');
        acc = (((power * (S[i] - '0')) % MOD) + acc) % MOD;
        power = (power * 10) % MOD;

        // printf("acc: %lld\n", acc);
        ans += counter[acc];
        counter[acc]++;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3760
import math
N,P=map(int,input().split())
A=list(map(int,input().split()))
l=[]
c=0
cnt=0
even=0
odd=0
for i in range(0,N):
    if A[i]%2==0:
        even=even+1
    else:
        odd=odd+1
if P==0:
    print(pow(2,even)*max(pow(2,odd-1),1))
else:
    print(pow(2,even)*math.floor(pow(2,odd-1)))

Measured memory_bytes: 38256
A_500 = int(input())
B_100 = int(input())
C_50 = int(input())
X = int(input())

count = 0

for i in range(0, A_500 + 1):
	for j in range(0, B_100 + 1):
		for k in range(0, C_50 + 1):
			if X == i * 500 + j * 100 + k * 50:
				count += 1

print(count)

Measured memory_bytes: 3060
#include<iostream>
#include<math.h>
#include<vector>
#include<algorithm>
#include<cstdio>
using namespace std;
 
int main(){
 
    double d,w,h,r,mind,dw,wh,hd;
    int n;
 
    while(true){
        scanf("%lf %lf %lf",&d,&w,&h);
        if(d == 0.0 && w == 0.0 && h == 0.0)break;
 
        scanf("%d",&n);
 
        for(int i=0; i < n; i++){
            scanf("%lf",&r);
            dw = (sqrt(d*d+w*w))/2.0;
            wh = (sqrt(w*w+h*h))/2.0;
            hd = (sqrt(d*d+h*h))/2.0;
            mind = min(dw,min(wh,hd));
            if(r > mind){
                printf("OK\n");
            }else{
                printf("NA\n");
            }
        }
    }
    return 0;
}


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

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

int main() {
	int a;
	cin >> a;
	cout << "Christmas";
	REP(i, a, 25){
      cout << " Eve";
    }
  	cout << endl;
}


Measured memory_bytes: 256
import itertools
while 1:
    n,m,s=map(int,input().split())
    if n==0:break
    dp=[[0 for _ in range(s+1)] for _ in range(n*n+1)]
    dp[0][0]=1
    for i,j in itertools.product(range(1,n*n+1),range(s+1)):
        if j>=i:dp[i][j]+=dp[i-1][j-i]+dp[i][j-i]
        if j-m>=1:dp[i][j]-=dp[i-1][j-m-1]
        dp[i][j]%=100000
    print(dp[n*n][s])

Measured memory_bytes: 13096
#include<bits/stdc++.h>
using namespace std;
#define ll long long
ll p = 1000000007;
int main(){
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n;
    cin >> n;
    ll a[n];
    for(ll i = 0;i < n;i++){
        cin >> a[i];
    }
    ll dp[n][n];
    ll sum[n+1];
    sum[0] = 0;
    for(ll i = 1;i <= n;i++){
        sum[i] = sum[i-1]+a[i-1];
    }
    memset(dp,0,(n*n)*sizeof(ll));
    for(ll i = 0;i < n;i++){
        dp[i][i] = 0;
    }
    for(ll i = 0;i < n-1;i++){
        dp[i][i+1] = a[i]+a[i+1];
    }
    for(ll i = 3;i <= n;i++){
        for(ll j = 0;j <= n-i;j++){
            ll x = LONG_MAX;
            for(ll k = j;k < j+i-1;k++){
                x = min(x,dp[j][k]+dp[k+1][j+i-1]+sum[j+i]-sum[j]);
            }
            dp[j][j+i-1] = x;
        }
    }
    cout << dp[0][n-1] << endl;
}

Measured memory_bytes: 1536
#include<stdio.h>
#include<string.h>

int main(){
	char S[2];
    scanf("%s",&S);
    if(strcmp(S,"SAT")==0){
    	printf("1");
    }else if(strcmp(S,"FRI")==0){
    	printf("2");
    }else if(strcmp(S,"THU")==0){
    	printf("3");
    }else if(strcmp(S,"WED")==0){
    	printf("4");
    }else if(strcmp(S,"TUE")==0){
    	printf("5");
    }else if(strcmp(S,"MON")==0){
    	printf("6");
    }else if(strcmp(S,"SUN")==0){
    	printf("7");
    }else{
    	printf("error");
    }
    return 0;
}

Measured memory_bytes: 128
# Middle-Square Method

def middle_square(s, n)
  ss=(s**2).to_s
  ss='0'*(n*2-ss.length)+ss
  ss[n/2..n+1].to_i
end

while (n=gets.to_i)!=0
  n.times {|i|
    puts "Case #{i+1}:"
    s=gets.to_i
    10.times {
      s=middle_square(s, 4)
      puts s
    }
  }
end

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

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	map<string, int> cnt;
	int n;
	cin >> n;
	for (int i = 0; i < n; i++) {
		string s;
		cin >> s;
		cnt[s]++;
	}
	string ord[] = {"AC", "WA", "TLE", "RE"};
	for (string s : ord) {
		cout << s << " x " << cnt[s] << '\n';
	}
}



Measured memory_bytes: 3668
#include <bits/stdc++.h>
using namespace std;
 
using ll = long long;
 
#define ff first
#define ss second
#define all(x) (x).begin(), (x).end()
#define len(x) int((x).size())
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define randint(n) uniform_int_distribution<int>(1, (n))(rng)
 
ll ceili(ll a, ll b)
{
	if(a%b==0LL) return ll(a/b);
	return 1 + ll(a/b);
}

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
 
	#ifdef ARTHUR_LOCAL
		ifstream cin("input.txt");
	#endif

    ll n,x,t;
    cin>>n>>x>>t;

    cout << t * ceili(n,x) << endl;
}

Measured memory_bytes: 3636
#include <iostream>
#include <string>

using namespace std;

int sub_get_gcd(int x,int y)
{
  return x % y ? sub_get_gcd(y,x%y) : y;
}

int get_gcd(int a,int b,int c)
{
  int tmp = sub_get_gcd(a,b);
  return sub_get_gcd(tmp,c);
}

int main(void)
{
  int K;
  cin >> K;
  
  int ans = 0;
  for(int a = 1 ; a <= K ; a++)
  {
    for(int b = 1 ; b <= K ; b++)
    {
      for(int c = 1 ; c <= K ; c++)
      {
        ans += get_gcd(a,b,c);
      }
    }
  }
  
  cout << ans << endl;
  return 0;
}

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

int main()
{

  int n,k,i,j,cnt=0;
  cin>>n;

  int a[n];

  for(i=0;i<n;i++)
    cin>>a[i];

  map<int,int> mp;

  for(i=0;i<n;i++)
  {
    mp.insert({a[i],i+1});
  }

 map<int,int> ::iterator itr;

  for (itr = mp.begin(); itr != mp.end(); ++itr)
    {
        int x=itr->second;
        cout<<x<<" ";
    }





}


Measured memory_bytes: 5888
main = mapM_ process . map (show. solve) .takeWhile (not. end) . map input. lines =<< getContents
  where process line = do putStrLn line

input :: String -> (Int, String, Int)
input line = (read a, op, read b)
  where (a:op:b:_)= words line

end :: (Int, String, Int)-> Bool
end (_,op,_)=op=="?"

solve :: (Int, String, Int)->Int
solve x
  | op == "+" = a + b
  | op == "-" = a - b
  | op == "*" = a * b
  | op == "/" = a `div` b
  | otherwise = 0
  where
    (a,op,b)=x

Measured memory_bytes: 4060
#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
using str = string;
using P = pair<int, int>;
using Pll = pair<ll, ll>;
const double PI = 3.141592653589793238;
const ll mod = 1000000007;
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define REP(i, m, n) for (int i = m; i < (int)n; i++)
#define all(a) (a).begin(), (a).end()
#define allg(a) (a).begin(), (a).end(), greator<>()
#define d20 std::setprecision(20)
#define veci vector<int>
#define vecll vector<long long int>
#define vecb vector<bool>
#define vecd vector<double>
template <typename T>
T lcm(T a, T b)
{
	return a / __gcd(a, b) * b;
}

int main()
{
	int n, m;
	cin >> n >> m;
	vecb food(m, true);
	rep(i, n)
	{
		int k;
		cin >> k;
		vecb f(m, false);
		rep(j, k)
		{
			int a;
			cin >> a;
			a--;
			f[a] = true;
		}
		rep(j, m)
		{
			if (f[j] == false)
			{
				food[j] = false;
			}
		}
	}
	int ans = 0;
	rep(i, m)
	{
		ans += food[i];
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3572
import math

A,B,H,M=map(int,input().split())
z=H+M/60
n=math.radians(30*z)
m=math.radians(6*M)

X1=A*(math.sin(n))
X2=A*(math.cos(n))
Y1=B*(math.sin(m))
Y2=B*(math.cos(m))

S=((X1-Y1)**2+(X2-Y2)**2)**0.5
print(S)

Measured memory_bytes: 9576
#include <iostream>
#include <cmath>
#include <string>

using namespace std;

int n;
string s1, s2, s3;

int main() {
  cin >> n >> s1 >> s2 >> s3;
  int ans = 0;
  for (int i = 0; i < n; i++) {
    if (s1[i] == s2[i] && s1[i] == s3[i]) {
      continue;
    } else if (s1[i] == s2[i] || s1[i] == s3[i] || s2[i] == s3[i]) {
      ans++;
    } else {
      ans += 2;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
n=int(input())
s=input()
lst=['A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z']
S=list(s)
for i in range(len(S)):
  idx=lst.index(S[i])
  S[i]=lst[(idx+n)%(len(lst))]
t=''.join(S)
print(t)
  


Measured memory_bytes: 3188
n,m=map(int,input().split())
x=sorted([int(i) for i in input().split()])
if n>=m:
    print(0)
else:
    r=[]
    for i in range(m-1):
        r.append(x[i+1]-x[i])
    r.sort()
    if n!=1:
        print(sum(r[:-n+1]))
    else:
        print(sum(r))

Measured memory_bytes: 13832
#include<bits/stdc++.h>
using ll=long long;
int main()
{
  int N;
  std::cin>>N;
  std::vector<int>A(N);
  for (int i=0;i<N;i++){
  std::cin>>A[i];
  }
  auto f=[](ll A){
    std::vector<ll> ans;
    for (int i=1;i*i<=A;i++){
      if (A%i==0){
        ans.push_back(i),ans.push_back(A/i);
      }
    }
    return ans;
  };
  ll ans=1;
  for(const ll d:f(A[0])){
    int n=0;
    for(int i=0;i<N;i++){
      if(A[i]%d==0){n++;}
    }
    if(n>=N-1){ans=std::max(ans,d);}
  }
  for(const ll d:f(A[1])){
    int n=0;
    for(int i=0;i<N;i++){
      if(A[i]%d==0){n++;}
    }
    if(n>=N-1){ans=std::max(ans,d);}
  }
  std::cout<<ans<<std::endl;
  return 0;
}


Measured memory_bytes: 768
import sys
stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nn = lambda: list(stdin.readline().split())
ns = lambda: stdin.readline().rstrip()

h,w,a,b = na()
ans = []

for i in range(h):
    a = min(a,w-a)
    k = '0'*a + '1'*(w-a) if i < b else '1'*a+'0'*(w-a)
    ans.append(k)

print(*ans, sep='\n')

Measured memory_bytes: 5108
#include<iostream>
#include<vector>
#include<string>
#include<cmath>
#include<algorithm>
#include<functional>
#include<numeric>
#include<queue>
#include<stack>
#include<map>
#include<unordered_map>
#include<set>
#include<bitset>
#include<random>

#pragma region
using namespace std;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define rep(i,n) FOR(i,0LL,n)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define rrep(i,n) RFOR(i,0LL,n)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define COUNT(a,y,x) upper_bound(all(a), y) - lower_bound(all(a), x)
#define UNIQUE(a) sort(all(a)); a.erase(unique(all(a)), a.end())
#define pb push_back
typedef long long int ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef vector<string> vs;
typedef map<ll, ll> MAP;
const ll inf = 1LL << 61;
const ll mod = 1000000007LL;
//const ll mod = 998244353LL;

ll n = 0, m = 0, ans = 0, tmp = 0, ma = -inf, mi = inf;
string s;
bool ok;
ll dx[9] = { 0,1,0,-1,0,1,1,-1,-1 }, dy[9] = { 0,0,1,0,-1,1,-1,1,-1 };
#define endl '\n'
#pragma endregion
#define MAX 222222






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


  cin >> n;
  ll a, b;
  b = n % 100;
  a = (n - b) / 100;

  if (a == 0) {
    if (b <= 12 && b != 0) cout << "YYMM" << endl;
    else cout << "NA" << endl;
    return 0;
  }
  if (b == 0) {
    if (a <= 12 && a != 0) cout << "MMYY" << endl;
    else cout << "NA" << endl;
    return 0;
  }
  if (a > 12 && b > 12) cout << "NA" << endl;
  else if (a <= 12 && b <= 12) cout << "AMBIGUOUS" << endl;
  else if (a <= 12) cout << "MMYY" << endl;
  else cout << "YYMM" << endl;





  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int s,a[1000000],i,j,m=0;
  scanf("%d",&s);
  a[0]=s;
  for(i=1;i<1000000;i++){
    if(a[i-1]%2) a[i]=3*a[i-1]+1;
    else a[i]=a[i-1]/2;
    for(j=0;j<i;j++){
      if(a[i]==a[j]) m=i;
    }
    if(m) break;
  }
  printf("%d",m+1);
}

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

typedef long long int ll;
#define INF 1999999999
#define MODA 1000000007

int main()
{
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    ios::sync_with_stdio(false);
    cin.tie(0);
    string a, b, c;
    cin >> a >> b >> c;
    putchar(toupper(a[0]));
    putchar(toupper(b[0]));
    putchar(toupper(c[0]));


    return 0;
}


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

 
using namespace std;
 
#define INF 1000000000
#define EPS 1e-9
#define PI acos(-1)
 
typedef long long ll;

#define MAX_N 20
#define MAX_M 30

int N;
int trex[MAX_N], trey[MAX_N];
bool tre[MAX_N];
int M;

vector<string> ans_list;

int main(){

  while(true){
    cin >> N;
    if(N == 0)
      break;
    for(int i = 0; i < N; i++){
      cin >> trex[i] >> trey[i];
      tre[i] = true;
    }
    int ans = N;
    cin >> M;
    int px = 10, py = 10;
    for(int num = 0; num < M; num++){
      int dx[] = {0,1,0,-1};
      int dy[] = {1,0,-1,0};
      char dir;
      int dd;
      int d;
      cin >> dir >> d;
      if(dir == 'N')
	dd = 0;
      else if(dir == 'E')
	dd = 1;
      else if(dir == 'S')
	dd = 2;
      else
	dd = 3;
      for(int i = 0; i < d; i++){
	px += dx[dd];
	py += dy[dd];
	for(int j = 0; j < N; j++){
	  if(tre[j] && px == trex[j] && py == trey[j]){
	    ans--;
	    tre[j] = false;
	  }
	}
      }
    }
    if(ans == 0)
      ans_list.push_back("Yes");
    else
      ans_list.push_back("No");
  }

  for(int i = 0; i < ans_list.size(); i++){
    cout << ans_list[i] << endl;
  }

  return 0;

}

Measured memory_bytes: 1220
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val list = getSosuList(55555).filter { it % 5 == 1 }

    println(list.subList(0,n).joinToString(" "))
}

fun getSosuList(max: Int): MutableList<Int> {
    val list = mutableListOf<Int>()
    (2..max).filter { i ->
                (2..Math.sqrt(i.toDouble()).toInt()).all { j -> i % j != 0 }
            }
            .forEach { n -> list.add(n) }
    return list
}


Measured memory_bytes: 33812
#include <bits/stdc++.h>
 
using namespace std;
 
const int MOD=1e9+7;
const double PI=3.14159265359;


int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int a,b;
    cin>>a>>b;
    
    vector<string> vs(100);
    string d(100, '.'), h(100,'#');
    fill(vs.begin(), vs.begin()+50, d);
    fill(vs.begin()+50, vs.end(),h);
    
    a--,b--;
    for(int i=0; i<50 && b; i+=2){
        for(int j=0; j<50 && b; j+=2){
            vs[i][j]='#';
            b--;
        }
    }
    
    for(int i=51; i<100 && a; i+=2){
        for(int j=0; j<50 && a; j+=2){
            vs[i][j]='.';
            a--;
        }
    }
    cout<<"100 100"<<endl;
    for(auto s:vs)cout<<s<<endl;
    
    /*
    for (int i=0; i<2; i++){
        cout<<vs[i]<<endl;
    }
    for(int i=20; i<3; i++){
        cout<<vs[i]<<endl;
    }
    */
    
   
   
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
    vector<vector<int> > data(3, vector<int>(3));
    for (auto &vv : data)
        for (auto &v : vv)
            cin >> v;
    int n; cin >> n; while (n--) {
        int v; cin >> v;
        for (auto &vv : data)
            for (auto &c : vv)
                if (c == v)
                    c = -1;
    }
    int cnt = 0;
    for (int i = 0 ; i < 3 ; i++) {
        if (data[i][0] == -1 && data[i][1] == -1 && data[i][2] == -1)
            cnt++;
        if (data[0][i] == -1 && data[1][i] == -1 && data[2][i] == -1)
            cnt++;
    }
    if (data[0][0] == -1 && data[1][1] == -1 && data[2][2] == -1)
        cnt++;
    if (data[0][2] == -1 && data[1][1] == -1 && data[2][0] == -1)
        cnt++;
    if (cnt >= 1)
        cout << "Yes\n";
    else
        cout << "No\n";
}


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

const int N = 3005;
const ll INF = 1e15;

int n, a[N];

ll dp[N][N];

ll rec(int i, int j) {
  if (dp[i][j] != -1) return dp[i][j];
  if (i == j) return dp[i][j] = a[i];
  return dp[i][j] = max(a[i] - rec(i+1, j), a[j] - rec(i, j-1));
}

int main() {
  cin >> n;
  rep(i, n) cin >> a[i];

  rep(i, n+1) rep(j, n+1) dp[i][j] = -1;
  cout << rec(0, n-1) << endl;
  return 0;
}

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

inline int gcd(int a,int b) {
    while(b^=a^=b^=a%=b);
    return a;
}

int main()
{
    int k;
    cin >> k;
    int sum = 0;
    for (int i = 1; i <= k; i++)
    {
        for (int j = 1; j <= k; j++)
        {
            for (int z = 1; z <= k; z++)
            {
                sum += gcd(gcd(i, j), z);
            }
        }
    }
    cout << sum;
}



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

int main()
{
ll n ;
cin >> n ;
vector<ll> x(n);
vector<ll> y(n);
rep(i, n){
  cin >> x[i] >> y[i];
}
double a=0;
rep(i,n){
  double r=0;
  rep(j,n){
    r+=sqrt((x[i]-x[j])*(x[i]-x[j])+(y[i]-y[j])*(y[i]-y[j]));
    a+=sqrt((x[i]-x[j])*(x[i]-x[j])+(y[i]-y[j])*(y[i]-y[j]));
  }
  ans+=r/(n-1);
}
ans-=a/(n*(n-1));
cout<<fixed<<setprecision(12)<<ans<<endl;
return 0;
}

Measured memory_bytes: 256
package main

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

var sc, wr = bufio.NewScanner(os.Stdin), bufio.NewWriter(os.Stdout)

func scanString() string   { sc.Scan(); return sc.Text() }
func scanRunes() []rune    { return []rune(scanString()) }
func scanInt() int         { a, _ := strconv.Atoi(scanString()); return a }
func scanInt64() int64     { a, _ := strconv.ParseInt(scanString(), 10, 64); return a }
func scanFloat64() float64 { a, _ := strconv.ParseFloat(scanString(), 64); return a }

func scanInts(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = scanInt()
	}
	return res
}

func debug(a ...interface{}) { fmt.Fprintln(os.Stderr, a...) }

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}
func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

//•*¨*•.¸¸♪main•*¨*•.¸¸♪(　-ω-)ノ　(　・ω・)
func main() {
	defer wr.Flush()
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 10000), 1001001)

	l := scanInt()
	r := scanInt()

	dp := make([][2][2][2]int, 63)
	dp[0][0][0][0] = 1

	for i := 0; i < 62; i++ {
		m := 61 - i
		lf := l >> uint(m) & 1
		rf := r >> uint(m) & 1
		for x := 0; x < 2; x++ {
			for y := 0; y < 2; y++ {
				if x > y {
					continue
				}
				for a := 0; a < 2; a++ {
					for b := 0; b < 2; b++ {
						for c := 0; c < 2; c++ {
							if c == 0 && x != y {
								continue
							}
							if a == 0 && y == 1 && rf == 0 {
								continue
							}
							if b == 0 && x == 0 && lf == 1 {
								continue
							}

							na := a + (1-a)&rf&(1-y)
							nb := b + (1-b)&(1-lf)&x
							nc := c + (1-c)&x&y
							dp[i+1][na][nb][nc] += dp[i][a][b][c]
							dp[i+1][na][nb][nc] %= mod
						}
					}
				}
			}
		}
		debug(lf, rf, dp[i+1])
	}
	ans := dp[62][1][1][1] + dp[62][0][1][1] + dp[62][1][0][1] + dp[62][0][0][1]
	ans %= mod
	fmt.Fprintln(wr, ans)
}

const mod = 1000000007


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

using namespace std;

int main(){
  int n, k = 0;

  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; i++){
    cin >> a[i];
  }
  int count = 1;
  for (int i = 0; i < n; i++){
    if(a[i] != count){
      k++;
    }else{
      count++;
    }
  }
  if(k == n){
    cout << -1 << endl;
  }else{
    cout << k << endl;
  }
  return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b;
    cin>>a>>b;
    int arr[b],s=0;
    for (int i=0;i<b;i++)
    {cin>>arr[i];s+=arr[i];}
    if(s>=a)
    cout<<"Yes";
    else
    cout<<"No";
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i< (n);i++)
using namespace std;
int main(){
    vector<string> day = {"SUN","MON","TUE","WED","THU","FRI","SAT"};
    vector<string>::iterator itr;
    string s;
    cin >> s;   
    itr = find(day.begin(),day.end(),s);
    int ind = distance(day.begin(),itr);
    cout <<7-ind << endl;
       
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int64_t divceil(int64_t numer, int64_t denom) {
    if (numer % denom == 0) {
        return numer / denom;
    } else {
        return 1L + numer / denom;
    }
}
int main() {
    int64_t N, K;
    cin >> N;
    cin >> K;
    int64_t max_a = -1;
 
    vector<int64_t> A(N);
    int64_t total_length = 0;
    for (uint64_t i = 0; i < N; i++) {
        cin >> A[i];
        total_length += A[i];
    }
 
    // 適当な初期値を与えて上界とする
    double upper_bound = -1;
    for (auto a : A) {
        int64_t split_num_heuristic = (K * a) / total_length;
        upper_bound = max(upper_bound, 1.0 * a / (split_num_heuristic + 1));
    }
  
    int64_t result = upper_bound + 2;
    int64_t left = 1;
    int64_t right = upper_bound + 1;
    while (right >= left) {
        int64_t mid = (left + right * 2) / 3;
 
        int64_t total_split = 0;
        for (uint64_t i = 0; i < N; i++) {
            int64_t split_num = divceil(A[i], mid) - 1L;
            total_split += split_num;
        }
 
        if (total_split <= K) {
            result = min(mid, result);
            right = mid - 1;
        } else {
            left = mid + 1;
        }
    }
    cout << result << endl;
}

Measured memory_bytes: 4752
K = int(input())

L = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]

print(L[K-1])


Measured memory_bytes: 8876
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <iomanip>
#include <random>
#include <cassert>
#include <cstring>
using namespace std;

#define GET_ARG(a,b,c,F,...) F
#define REP3(i,s,e) for (i = s; i <= e; i++)
#define REP2(i,n) REP3 (i,0,(int)(n)-1)
#define REP(...) GET_ARG (__VA_ARGS__,REP3,REP2) (__VA_ARGS__)
#define RREP3(i,s,e) for (i = s; i >= e; i--)
#define RREP2(i,n) RREP3 (i,(int)(n)-1,0)
#define RREP(...) GET_ARG (__VA_ARGS__,RREP3,RREP2) (__VA_ARGS__)
#define DEBUG(x) cerr << #x ": " << x << endl

int a[100000];

int main(void) {
    int i, n;
    scanf("%d",&n);
    REP (i,n) scanf("%d",&a[i]);

    int cnt2 = 0, cnt4 = 0;
    REP (i,n) {
        if (a[i] % 4 == 0) cnt4++;
        else if (a[i] % 2 == 0) cnt2++;
    }
    int x = 0;
    if (cnt4 > 0 && cnt2 > 1) {
        x = 2 * cnt4 + cnt2;
    }
    else if (cnt4 > 0) {
        x = 2 * cnt4 + 1;
    }
    else if (cnt2 > 1) {
        x = cnt2;
    }
    if (n <= x) {
        puts("Yes");
    }
    else {
        puts("No");
    }
    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)

using namespace std;

struct edge{
	int to;
	int id;
};
vector<vector<edge>> g;

int main(void){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	g.resize(n);
	vector<int> ans(n-1);
	rep(i,n-1){
		int a,b;
		cin >> a >> b;
		--a;--b;
		g[a].push_back((edge){b,i});
		g[b].push_back((edge){a,i});
	}
	queue<int> q;
	vector<int> used(n);
	q.push(0);
	used[0] = 1;
	while(!q.empty()){
		int v = q.front();q.pop();
		int c = -1;
		
		for(int i=0;i<g[v].size();i++){
			int u = g[v][i].to;
			int ei= g[v][i].id;
			if(used[u]){
				c = ans[ei];
				break;
			}
		}
		int k = 1;
		rep(i,g[v].size()){
			int u = g[v][i].to;
			int ei= g[v][i].id;
			if(used[u])continue;
			if(k==c)k++;
			ans[ei] = k;
			k++;
			q.push(u);
			used[u] = 1;
		}
	}
	int mx = 0;
	rep(i,n)mx = max(mx,int(g[i].size()));
	cout << mx << endl;
	rep(i,n-1)cout << ans[i] << endl;
}

Measured memory_bytes: 7424
#include<bits/stdc++.h>
#define pb push_back 
 #define fo(i,n) for(int i=0;i<n;i++)
#define ll long long
#define Mod 1000000009 
#define MAX 4294967296  // 2^32
const int M=1e9+7;
    long long mod(long long x){
        return ((x%M + M)%M);
    }
    long long add(long long a, long long b){
        return mod(mod(a)+mod(b));
    }
    long long mul(long long a, long long b){
        return mod(mod(a)*mod(b));
    }
using namespace std;

long long gcd(int x,int y){
    if(y==0)return x;
    return gcd(y,x%y);
}


long long power(int x,int y){
if(y==0)return 1;
long long t=power(x,y/2);
if(y%2==1)return x*t*t;
return t*t;



}
double findMod(double a, double b) 
{ 
    double mod; 
    // Handling negative values 
    if (a < 0) 
        mod = -a; 
    else
        mod =  a; 
    if (b < 0) 
        b = -b; 
  
    // Finding mod by repeated subtraction 
      
    while (mod >= b) 
        mod = mod - b; 
  
    // Sign of result typically depends 
    // on sign of a. 
    if (a < 0) 
        return -mod; 
  
    return mod; 
} 

ll power(ll x, ll y, ll p)
{
    ll res = 1;      // Initialize result
 
    x = x % p;  // Update x if it is more than or
                // equal to p
 
    while (y > 0)
    {
        // If y is odd, multiply x with result
        if (y & 1)
            res = (res*x) % p;
 
        // y must be even now
        y = y>>1; // y = y/2
        x = (x*x) % p;
    }
    return res;
}
 
// Returns n^(-1) mod p
ll modInverse(ll n, ll p)
{
    return power(n, p-2, p);
}
ll ans=INT_MIN;
void dfs(vector<int>adj[],vector<int>&vis,int i,int &f){
    vis[i]=1;

    for(auto it=adj[i].begin();it!=adj[i].end();it++){
        if(!vis[*it]){
            f++;
            dfs(adj,vis,*it,f);
        }
    }
}

int main(){



    // std::string binary = std::bitset<8>(n).to_string();
    ios::sync_with_stdio(0);
    cin.tie(0);
 ll n;
 cin>>n;
 ll a[n];
 fo(i,n)cin>>a[i];
 ll sum=0;
 ll maxx=0;
 fo(i,n){
    if(a[i]<maxx){
      
        sum+=maxx-a[i];
    }
    else maxx=a[i];
 }
 cout<<sum<<endl;

}

Measured memory_bytes: 5216
#include <bits/stdc++.h>
#define int long long

#define mp make_pair
#define pb push_back

using namespace std;

signed main(){
    int n;
    cin >> n;
    int res = 0;
    for(int i = 1;i<=n;i++){
        for(int z = 1;z<=n;z++){
            for(int j = 1;j<=n;j++){
                res += __gcd(__gcd(i,z),j);
            }
        }
    }
    cout << res;
}


Measured memory_bytes: 3556
#include<bits/stdc++.h>
#define LL long long
#define P pair<int,int>
#define P2 pair<LL,int>
#define ls(i) seg[i].lc
#define rs(i) seg[i].rc
using namespace std;
const int N = 18;
const int mod = 1e9 + 7;

int main()
{

   int a[1010];
   int n;
   cin>>n;
   for(int i = 0;i < n;i++) cin>>a[i];
   sort(a, a + n);
   cout<<a[n-1] - a[0]<<endl;
    return 0;
}



Measured memory_bytes: 256
using System;
using System.Collections.Generic;
//using System.Linq;
class Program
{
  //static List<string> list;
	static void Main(string[] args)
	{
		// 入力フェーズ
        string[] input = Console.ReadLine().Split(' ');
        int N = int.Parse(input[0]);
        long X = long.Parse(input[1]);

        long ret = fullEat(N,X);


    // 出力
        Console.WriteLine(ret);
    }
		class layer{ //自作クラス
			public long total {set; get;} // 全部の層数
			public long paty {set; get;}  // パティの数
      public long banz {set; get;}  // バンズの数
		}
    static private long fullEat(int N, long X)
    {
      // レベル1バーガーは BPPPBでそれ以上小さくできない
      if(N == 1)
      {
        long ret = 0;
        if(X == 5) ret = X - 2;
        else ret = X - 1;
        return ret;
      }
      // 食べきったパティの数を返す
      if(X <= 1)
      {
        // 一番外側のバンズも食べられない
        return 0;
      }
      layer burger = getLayerNum(N);
      if(burger.total == X)
      {
        //レベルNバーガーをちょうど食べきった
        return burger.paty;
      }

      if(X == (burger.total-3)/2 + 1)
      {
        // レベルN-1バーガーと、一番外側のバンズを食べた
        return getLayerNum(N-1).paty;
      }else if(X == (burger.total-3)/2 + 2)
      {
        // バンズ・レベルN-1バーガー・パティを食べた
        return getLayerNum(N-1).paty + 1;
      }else if(X > (burger.total-3)/2 + 2)
      {
        // バンズ・レベルN-1バーガー・パティを食べて、さらにN-1バーガーの一部を食べる
        layer burger_s = getLayerNum(N-1);
        long eated = burger_s.paty + 1;
        long rest = X - (burger_s.total + 2);
        return eated + fullEat(N-1, rest);
      }else
      {
        // レベルN-1バーガーも食べきれなかったので、一番外側のバンズを食べて、レベルN-1バーガーの一部を食べる
        return fullEat(N-1, X-1);
      }
    }

    static private layer getLayerNum(int N)
    {
      layer ret = new layer();
      // 全部で 2^(N+2)-3層、パティは2^(N+1)-1, バンズは2^(N+1)-2
      long power = (long)Math.Pow(2, N+1);
      ret.total = power*2 - 3;
      ret.paty = power -1;
      ret.banz = power -2;
      return ret;
    }


}


Measured memory_bytes: 13140
#include<bits/stdc++.h>
#include<istream>
#include<cstdio>
#define pii          pair<ll,ll >
#include<string>
#define In freopen("ahsan.txt","r",stdin);
#define ll long long
#define ff first
#define ss second
#define NO cout<<"NO"<<endl
#define m1 cout<<"-1"<<endl
#define No cout<<"No"<<endl
#define YES cout<<"YES"<<endl
#define Yes cout<<"Yes"<<endl
#define pb push_back
#define sorta(a) sort(a,a+n)
#define sortv(v)  sort(v.begin,v.end())
#define bug(a) cerr << #a << " : " << a << endl
#define all(v) (v.begin(), v.end())
#define   sz(x)       x.size()
const int mx = 1e6+5;
using namespace std;
ll b[200051],a[200010],aa[200010],t,k,ev = 0,od=0,tt = 0,n,cas = 1;
vector<int>vec[mx];
vector<pii>v;
int vis[mx] = { },edge;
ll cost[mx],l = 0,c2[mx];
bool ok = true;
int chid[mx];

ll dp[mx],f[mx];
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    // In;
    map<string,int>mp;
    cin>>t;
    for(int i =0; i<t; i++)
    {
        string x;
        cin>>x;
        mp[x]++;

    }
    vector<string>vec;
    // vec.pb("AC");
    vec.pb("AC");
    vec.pb("WA");
    vec.pb("TLE");
    vec.pb("RE");
    cout<<vec[0]<< " x "<<mp[vec[0]]<<endl;
    cout<<vec[1]<< " x "<<mp[vec[1]]<<endl;
    cout<<vec[2]<< " x "<<mp[vec[2]]<<endl;
    cout<<vec[3]<< " x "<<mp[vec[3]]<<endl;







    return 0;
}


Measured memory_bytes: 27064
import sys
from bisect import bisect_left, bisect_right, insort

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

N = ir()
S = list('-' + sr())
d = [[] for _ in range(26)]
for i in range(1, N+1):
    s = S[i]
    o = ord(s) - ord('a')
    insort(d[o], i)

Q = ir()
for _ in range(Q):
    q, a, b = sr().split()
    if q == '1':
        a = int(a)
        if S[a] == b:
            continue
        prev = ord(S[a]) - ord('a')
        d[prev].remove(a)
        next = ord(b) - ord('a')
        insort(d[next], a)
        S[a] = b
    else:
        a = int(a); b = int(b)
        ans = 0
        for alpha in range(26):
            if bisect_right(d[alpha], b) - bisect_left(d[alpha], a) >= 1:
                ans += 1
        print(ans)

# 17


Measured memory_bytes: 118492
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <stdio.h>
using namespace std;
#define int long long
int MOD = 1000000007;
signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N;
	cin >> N;
	vector<vector<int> > A(N);
	int res = 0;
	for (int i = 0; i < N; i++) {
		int M;
		cin >> M;
		int a;
		for (int j = 0; j < M; j++) {
			cin >> a;
			a--;
			A[i].push_back(a);
		}
		sort(A[i].begin(), A[i].end());
		A[i].erase(unique(A[i].begin(), A[i].end()), A[i].end());
	}
	int mx = -1;
	vector<int> E(N, 1);
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < A[i].size(); j++) {
			if (A[i][j] == i) {
				E[i] = 0;
				break;
			}
		}
	}
	for (int i = N - 1; i >= 0; i--) {
		if (E[i] == 0) {
			mx = -1;
		}
		else if ((int)A[i].size() == 0) {
			res++;
			mx = -1;
		}
		else if (A[i].back() == i + 1 && E[i + 1] == 1) {
			if (mx == i) {
				mx = -1;
				E[i] = 0;
				//cerr << "erase " << i << endl;
			}
			else {
				int x = (int)A[i].size() - 2;
				while (x >= 0 && E[A[i][x]] == 0) {
					x--;
				}
				if (x >= 0) {
					mx = max(mx, A[i][x]);
				}
				res++;
			}
		}
		else {
			res++;
			int x = (int)A[i].size() - 1;
			while (x >= 0 && E[A[i][x]] == 0) {
				x--;
			}
			if (x >= 0) {
				mx = A[i][x];
			}
		}
	}
	cout << N - res << endl;
}


Measured memory_bytes: 7656
#include <iostream>

int main(int argc, char *argv[]) {
  long n, k;
  std::cin >> n >> k;

  n = n % k;

  long min = n;
  while (std::abs(n - k) != min) {
    n = std::abs(n - k);
    min = std::min(n, min);
  }

  std::cout << min << std::endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define r(i,n) for(auto i=0;i<n;i++)
#define s(c) static_cast<int>((c).size())

int main(){
	int n, q, t, cnt = 0;

	cin >> n;
	vector<int> S(n);
	r(i, n) cin >> S[i];
	sort(S.begin(), S.end());
	S.erase(unique(S.begin(), S.end()), S.end());
	cin >> q;
	r(i, q){
		cin >> t;
		for(int s : S){
			if(s == t){
				cnt++;
				break;
			}
		}
	}
	cout << cnt << endl;
	return 0;
}


Measured memory_bytes: 3164
#include <bits/stdc++.h>
    using namespace std;
     
    int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    long long n,a,max=-1,count=0,flag=0,ans=0;
    cin>>n;
    n--;
    for(int i=1;i<=n;i++){
    ans+=i;
    }
    cout<<ans<<'\n';
    return 0;
    }

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

using namespace std;

typedef long long int lli;

int main(void){
  int N;
  cin >> N;
  lli sum = 0;
  for(int i=1;i<=N;i++){
    if(i%3 != 0 && i%5 != 0){
      sum = sum + (lli)i;
    }
  }
  cout << sum << endl;
  return 0;
}


Measured memory_bytes: 3636
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
template <class T>
inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}

typedef long long ll;

int main() {

  ll N;
  cin >> N;
  ll dp[100001][3];
  ll happiness[100001][3];

  for (ll i = 0; i < N; i++) {
    cin >> happiness[i][0];
    cin >> happiness[i][1];
    cin >> happiness[i][2];
  }

  for (ll i = 0; i < 100001; i++) {
    dp[i][0] = 0;
    dp[i][1] = 0;
    dp[i][2] = 0;
  }

  dp[0][0] = 0;
  dp[0][1] = 0;
  dp[0][2] = 0;


  for (ll i = 1; i <= N; i++) {
    dp[i][0] = max(dp[i-1][1], dp[i-1][2]) + happiness[i-1][0];
    dp[i][1] = max(dp[i-1][0], dp[i-1][2]) + happiness[i-1][1];
    dp[i][2] = max(dp[i-1][0], dp[i-1][1]) + happiness[i-1][2];
  }

  cout << max(dp[N][0], max(dp[N][1], dp[N][2])) << endl;

  return 0;
}


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

int main() {
	// your code goes here
	int a[3],i;
	for(i=0;i<3;i++)
	{
	    cin>>a[i];
	}
	sort(a,a+3);
	if(a[1]+a[0]==a[2])
	cout<<"Yes"<<endl;
	else
	cout<<"No"<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;
int gcd(int a, int b)
{
    int t; // 補助変数
    while (b != 0)
    { // 他方が0になるまで
        t = a % b;
        a = b;
        b = t; // 一方を剰余に置き換える
    }
    return a; // 他方が0になったときの一方がGCD
}
int main()
{
    int n;
    int a;
    int answer;
  

    cin >> n;
    cin >> answer;
    for (int i = 1; i < n; i++)
    {
        cin >> a;
        answer = gcd(answer, a);
    }
    cout << answer;

    /* code */
    return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
#define rep(i, begin, n) for (int i = begin; i < n; i++)
#define repe(i, begin, n) for (int i = begin; i <= n; i++)
#define repr(i, begin, n) for (int i = begin; i > begin - n; i--)
#define repre(i, begin, end) for (int i = begin; i >= end; i--)

template <class T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}

template <class T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}

const int inf = 1000000007;
const int MOD = 1000000007;
const long long INF = 1000000000000000007;

// -------------------------------------------------------
int a, b;

int main() {
  cin >> a >> b;
  int diff = b - a;
  int east = 0;
  repe(i, 1, diff) { east += i; }
  cout << east - b;
}


Measured memory_bytes: 256
#import sys
#import numpy as np
import math
#import itertools
#from fractions import Fraction
#import itertools
from collections import deque
from collections import Counter
#import heapq
#from fractions  import gcd
#input=sys.stdin.readline
#import bisect
n=int(input())
a=list(map(int,input().split()))
c=Counter(a)
cnt=0
for i in c:
    if c[i]%2==0:
        cnt+=1
if cnt%2==0:
    print(len(c))
else:
    print(len(c)-1)

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

#define rep(i,n) for (int i = 0; i< (n); ++i)
#define vvec(m,n) vector<vector<int>> (int(m), vector<int>(n))
#define ALL(a) (a).begin(), (a).end()

using ll = long long;

int main(){
    string s;
    cin >> s;
    rep(i,s.size()){
        s.at(i) = 'x';
    }
    cout << s << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(0);cin.tie(NULL)
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
#define trace(x)  cerr << #x << ": " << x << endl;
typedef long long ll;
typedef long double ld;
 
int main()
{
	fast;
	ll n,m,k;cin>>n>>m>>k;
	ll a[n],b[m];
	for(ll i=0;i<n;i++)
	{
		cin>>a[i];
	}
	for(ll i=0;i<m;i++)
		cin>>b[i];
	std::vector<ll> prefa,prefb;ll cnt=0;
	prefa.push_back(a[0]);prefb.push_back(b[0]);
	for(ll i=1;i<n;i++)prefa.push_back(a[i]+prefa.back());
	for(ll i=1;i<m;i++)prefb.push_back(b[i]+prefb.back());
	for(ll i=0;i<n;i++)
	{
		ll x=prefa[i];if(x>k)break;
		auto p=upper_bound(prefb.begin(),prefb.end(),k-x);
		ll z=p-prefb.begin();
		cnt=max(cnt,i+1+z);
	}
	for(ll i=0;i<m;i++)
	{
		ll x=prefb[i];if(x>k)break;
		auto p=upper_bound(prefa.begin(),prefa.end(),k-x);
		ll z=p-prefa.begin();
		cnt=max(cnt,i+1+z);
	}
	cout<<cnt;

}

Measured memory_bytes: 11028
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
 
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;
 
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
 
typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;
 
#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
#define trav(a,x) for (auto& a : x)
 
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define ins insert

template<class T> bool ckmin(T& a, const T& b) { return b < a ? a = b, 1 : 0; }
template<class T> bool ckmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
const int MOD = 1000000007;
const char nl = '\n';
const int MX = 100001; //check the limits, dummy
 
int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);    
	
    int N; cin >> N;
    vector<int> L(N);
    for (int i = 0; i < N; ++i) {
		cin >> L[i];
	}
	sort(L.begin(), L.end());
	int total = 0;
	for (int i = 0; i < N; ++i) {
		for (int j = i + 1; j < N; ++j) {
			for (int k = j + 1; k < N; ++k) {
				if (L[i]!=L[j] && L[j]!=L[k]) {
					if (L[i]+L[j] > L[k]) {
						++total;
					}
				}
			}
		}
	}
	cout << total << '\n';
	
	
	return 0;
}
 
// read the question correctly (ll vs int)
// template by bqi343



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

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

    rep(i, t.size()) if (t[i] == '?') t[i] = 'D';

    cout << t << endl;
    return 0;
}


Measured memory_bytes: 3756