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

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

    int ans = 0;
    for(int i = 0;i < 3;i++){
        if(s[i] == t[i]){
            ans++;
        }
    }
    
    cout << ans;

    
    return 0;
}

Measured memory_bytes: 256
// lcmとか__builtin_popcountとかはg++ -std=c++17 default.cppみたいなかんじで

#include <bits/stdc++.h>
#define mod 1000000007
#define INF LLONG_MAX
#define ll long long
#define ln cout<<endl
#define Yes cout<<"Yes"<<endl
#define NO cout<<"NO"<<endl
#define YES cout<<"YES"<<endl
#define No cout<<"No"<<endl
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
using namespace std;
ll dx[4]={1,0,-1,0};
ll dy[4]={0,1,0,-1};

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

    ll  a,b,c,d,e,n,k,maxi=0,f=0,mini=INF,sum=0,q;
	string str,stra,straa;
    ll x,y,z;
    char ca,cb,cc;
    cin>>n;
    vector<long double> v(n);
    rep(i,n) cin>>v[i];
    vector<long double> ld(n);
    rep(i,n) ld[i]=(long double)1/(long double)v[i];
    cout<<1/(long double)accumulate(ld.begin(),ld.end(),(long double)0);


    return 0;
}


Measured memory_bytes: 3828
#include<bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for (int i= (a); i < (b); ++i)
typedef long long ll;
typedef pair<int,int> P;
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
int main() { int N,A;
  cin >> N >> A;
  N %= 500;
  if(N<=A){
    puts("Yes");
  }else{
    puts("No");
  }
}

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

map<int, int> counter(vector<int> nums){
    map<int, int> outcome;
    for (auto n: nums){
        outcome[n]++;
    }
    return outcome;
}

int main(){
    vector<int> nums;
    for (int i=0;i<3;i++){
        int a, b;cin>>a>>b;
        nums.push_back(a);
        nums.push_back(b);
    }
    auto freq = counter(nums);
    int one_time, two_times;
    one_time = two_times = 0;
    for (auto item : freq){
        if (item.second == 1){
            one_time++;
        }
        if (item.second == 2){
            two_times++;
        }
    }
    if (one_time == 2 && two_times == 2){
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }
    return 0;
}



Measured memory_bytes: 256
N = int(input())
A = list(map(int,input().split()))
B = [A[i]-i for i in range(N)]
S = sorted(B)

res = 0
if N%2 == 1:
    b = S[(N-1)//2]#中央値
    for i in range(N):
        res += abs(B[i]-b)
else:
    medint1 = N//2
    medint2 = N//2-1
    med1 = S[medint1]
    med2 = S[medint2]
    t1 = 0
    t2 = 0
    for i in range(N):
        t1 += abs(B[i]-med1)
        t2 += abs(B[i]-med2)
    res = min(t1,t2)
print(res)

Measured memory_bytes: 25748
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def unite(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return
        if self.parents[x] > self.parents[y]:
            x, y = y, x
        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def group_members(self):
        return [self.members(r) for r in self.roots()]

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())


n, m = map(int, input().split())

uf = UnionFind(n+1)
for _ in range(m):
    x, y = map(int, input().split())
    uf.unite(x, y)

ans = 0
for i in range(n+1):
    if ans < uf.size(i):
        ans = uf.size(i)
print(ans)




Measured memory_bytes: 77492
#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <string>
#include <sstream>
#include <vector>
#include <algorithm>
#define N 20000

using namespace std;

int height[N+1];
struct P {
	int start,end;
	int sum;
};
vector<P> ln;

bool cmp(P a, P b){
	return a.start < b.start;
}

int main(){
	for(int i=0;i<N+1;i++){
		height[i] = N;
	}
	char s[N+1];
	scanf("%s", s);
	int len = strlen(s);
	for(int i=0;i<len;i++){
		int d = 0;
		if(s[i]=='/') d = 1;
		if(s[i]=='\\') d = -1;
		height[i+1] = height[i]+d;
	}
	
	int sum = 0;
	for(int high=2*N;high>=0;high--){
		int l=-1;
		for(int i=0;i<len+1;i++){
			if(height[i] == high){
				if( (l != -1) && (i != 0) && (height[i-1] < high) ){
					int m = (i-l-1);
					sum += m;
					bool f = true;
					for(int j=0;j<ln.size();j++){
						if(ln[j].start < l && i < ln[j].end){
							ln[j].sum += m;
							f = false;
						}
					}
					if(f){
						P *p = new P;
						p->start = l; p->end=i; p->sum=m;
						ln.push_back(*p);
					}
					l = -1;
				}
				if((i!=len) && height[i+1] < high){
					l = i;
				}
			}
		}
	}
	sort(ln.begin(), ln.end(), cmp);
	cout <<sum << endl;
	cout << ln.size();
	if(ln.size() != 0) cout << " ";
	for(int i=0;i<ln.size();i++){
		cout << ln[i].sum;
		if(i != ln.size()-1) cout << " ";
	}
	cout << endl;
	return 0;
}

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

using namespace std;
using ull = unsigned long long;

int main() {
    int D, G;
    cin >> D >> G;

    vector<int> num_q(D);
    vector<int> comp_p(D);
    for (uint i = 0; i < D; ++i) {
        cin >> num_q.at(i) >> comp_p.at(i);
    }

    ull ret = 1 << 31;

    for (uint bit = 0; bit < (1 << D); ++bit) {
        ull sum =0;
        ull answered_num = 0;

        for (uint i = 0; i < D; ++i) {
            if (bit & (1 << i)) {
                sum += num_q.at(i) * 100 * (i + 1);
                sum += comp_p.at(i);
                answered_num += num_q.at(i);
            }
        }

        if (sum >= G) {
            ret = min(ret, answered_num);
        }
        else {
            for (uint i = D-1; i >= 0; --i) {
                if (bit & (1 << i)) {
                    continue;
                }

                if (num_q.at(i) == 0) {
                    continue;
                }

                for (uint j = 0; j < num_q.at(i); ++j) {
                    sum += 100 * (i + 1);
                    answered_num++;

                    if (sum >= G) {
                        ret = min(ret, answered_num);
                        break;
                    }
                }
                break;
            }
        }
    }

    cout << ret << endl;
}

Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)
var ErrNotFound = errors.New("Linear Search: Key is not found.")

func nextString() string {
	sc.Scan()
	return sc.Text()
}

func linearSearch(a []int, key int) (int, error) {
	for i, v := range a {
		if v == key {
			return i, nil
		}
	}
	return -1, ErrNotFound
}

func main() {
	sc.Split(bufio.ScanWords)
	n, _ := strconv.Atoi(nextString())
	S := make([]int, n)
	for i := 0; i < n; i++ {
		num, _ := strconv.Atoi(nextString())
		S[i] = num
	}

	q, _ := strconv.Atoi(nextString())
	var contains int
	for i := 0; i < q; i++ {
		num, _ := strconv.Atoi(nextString())
		if idx, err := linearSearch(S, num); idx != -1 && err == nil {
			contains++
		}
	}
	fmt.Println(contains)
}


Measured memory_bytes: 1208
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,sse2,sse3,sse4,mmx,tune=native")
#include <iostream>
#include <cstring>
const int MAX_N = 50;
using ull = unsigned long long;
const int MOD = 1e9 + 7;
int n;

struct Matrix {
  int a[MAX_N][MAX_N];
  Matrix() : a() {}
  inline Matrix &operator*=(const Matrix b) {
    register int i, j, k, l;
    register const int *p2;
    static ull tmp[MAX_N];
    ull cur;
    for (i = 0; i < MAX_N; ++i) {
      memset(tmp, 0, sizeof(ull) * MAX_N);
      for (k = 0, l = (MAX_N & ~15); k < l;) {
#define opt                                                         \
  do {                                                              \
    if (a[i][k]) {                                                  \
      for (cur = a[i][k], p2 = b.a[k], j = 0; j < MAX_N; j++, p2++) \
        tmp[j] += cur * (*p2);                                      \
    }                                                               \
    k++;                                                            \
  } while (0)
        opt;
        opt;
        opt;
        opt;
        opt;
        opt;
        opt;
        opt;
        opt;
        opt;
        opt;
        opt;
        opt;
        opt;
        opt;
        opt;

        for (j = 0; j < MAX_N; j++) tmp[j] %= MOD;
      }

      for (; k < MAX_N;) {
        opt;
      }
#undef opt

      for (j = 0; j < MAX_N; j++) a[i][j] = tmp[j] % MOD;
    }
    return *this;
  }
};

inline int add(int x, int v) { return x + v >= MOD ? x + v - MOD : x + v; }

inline Matrix power(Matrix &a, long long b) {
  Matrix ret;
  for (int i = 0; i < n; ++i) ret.a[i][i] = 1;
  for (; b; b >>= 1, a *= a)
    if (b & 1) ret *= a;
  return ret;
}

int main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  std::cout.tie(nullptr);
  Matrix a;
  long long k;
  std::cin >> n >> k;
  for (int i = 0; i < n; ++i)
    for (int j = 0; j < n; ++j) std::cin >> a.a[i][j];
  auto ret = power(a, k);
  int ans = 0;
  for (int i = 0; i < n; ++i)
    for (int j = 0; j < n; ++j) ans = add(ans, ret.a[i][j]);
  std::cout << ans;
  return 0;
}

Measured memory_bytes: 256
N = int(input())
work_stack = []
for _ in range(N):
     work_stack.append(tuple(map(int, input().split())))
    
work_stack = sorted(work_stack, key = lambda x: x[1])

work_total_time = 0
judge = True

for work in work_stack:
    work_time, dead_line = work
    work_total_time += work_time
    
    if work_total_time > dead_line:
        judge = False
        break

if judge:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 83032
import java.math.BigDecimal

fun main() = Thread(null, ::abc169c, "(^o^)", 128 * 1024 * 1024).apply { start() }.join()

@OptIn(ExperimentalStdlibApi::class)
fun abc169c() {
    val (a, b) = readLine()!!.split(' ').map { it.toDouble() }

    val answer = BigDecimal.valueOf(a).multiply(BigDecimal.valueOf(b)).toLong()

    println(answer)
}


Measured memory_bytes: 37128
#include<iostream>
 
int main(){
    int yamikin,i,n;
    
    std::cin>>n;
    yamikin=100000;
    
    for(i=0;i<n;i++){
        yamikin=yamikin*1.05; 
        if(yamikin%1000!=0){
           yamikin=yamikin-(yamikin%1000)+1000; 
           
           }
         }
     std::cout<<yamikin<<std::endl;
           
return 0;
}       

Measured memory_bytes: 1160
#include<bits/stdc++.h>
using namespace std;
long long a,b,c,kk;
int main()
{
    cin>>a>>b>>c;
    if(b>=a)
    {
        cout<<1<<endl;
        exit(0);
    }
    if(c>=b)
    {
        cout<<-1<<endl;
        return 0;
    }
    if((a-b)%(b-c)>=1) kk=1;
    cout<<((a-b)/(b-c)+kk)*2+1<<endl;
}

Measured memory_bytes: 256
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

def main():
    mod=10**9+7
    w=input()
    from collections import defaultdict
    dd = defaultdict(int)
    
    for i in range(len(w)):
        dd[w[i]]+=1
        
        
    f=1
    for k,v in dd.items():
        if v%2==1:
            f=0
            
    if f==1:
        print("Yes")
    else:
        print("No")

main()


Measured memory_bytes: 38384
#include <bits/stdc++.h>
using namespace std;
#define double long double
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define sp(p) cout<<setprecision(16)<<fixed<<p<<endl;
#define debug(x) cerr<<#x<<": "<<x<<endl;
#define all(a) a.begin(),a.end()
#define SORT(a) sort(all(a))
#define rsort(a) sort(all(a),greater<>())
#define debg(a) cout<<#a<<" "<<a<<endl;
#define show(a) for(cont &y:a){for(cont &x:y){cout<<x<<" ";}cout<<endl;}
template<class T>inline int out(const T &t){ print(t); putchar('\n'); return 0; }
template<class T>inline T gcd(T a,T b){if(b==0)return a; return(gcd(b,a%b));}
template<class T>inline T lcm(T a,T b){return a/gcd(a,b)*b;}
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<ll> V;
const long long MOD=1000000007;
const long long INF = 1e18;
vector <ll> dp;


void solve_old(long long N, std::vector<std::vector<long long>> A){
    ll sum=0;
    V A1(N,0);
    V A2(N,0);
    A1[0] = A[0][0];
    A2[0] = A[1][0];
    for (ll i = 1; i < N; i++) {
        A1[i] = A[0][i] + A1[i-1];
        A2[i] = A[1][i] + A2[i-1];
    }
    sum = A1[0] + A2[N-1];
    for (ll i = 0; i < N; i++) {
        sum = max(sum, A1[i] + A2[N-1] - A2[i-1]);
    }
    cout << sum << "\n";
}

void solve(long long N, std::vector<std::vector<long long>> A){
    ll sum=0;
    vector<vector<ll>> Asum(2, vector<ll>(N));
    // V A1(N,0);
    // V A2(N,0);
    // A1[0] = A[0][0];
    // A2[0] = A[1][0];
    Asum[0][0] = A[0][0];
    Asum[1][0] = A[1][0];
    for (ll i = 1; i < N; i++) {
        Asum[0][i] = A[0][i] + Asum[0][i-1];
        Asum[1][i] = A[1][i] + Asum[1][i-1];
    }
    sum = Asum[0][0] + Asum[1][N-1];
    for (ll i = 0; i < N; i++) {
        sum = max(sum, Asum[0][i] + Asum[1][N-1] - Asum[1][i-1]);
    }
    cout << sum << "\n";
}

int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<std::vector<long long>> A(2, std::vector<long long>(N));
    for(int i = 0 ; i < 2 ; i++){
        for(int j = 0 ; j < N ; j++){
            scanf("%lld",&A[i][j]);
        }
    }
    solve(N, std::move(A));
    return 0;
}


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

int main(){
  int ans = 1;
  int judge;
  int N;
  cin >> N;
  int H[N];
  for(int i=0;i<N;i++){
    cin >> H[i];
  }
  for(int i=0;i<N;i++){
    for(int j=0;j<i;j++){
      judge = 0;
      if(H[j]>H[i]){
        judge = 1;
        break;
    }
    }
      if(judge == 0){
        ans++;
      }
  }
        
  cout << ans << endl; 
  return 0;
}
      


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<cstdlib>
#include<sstream>
#include<algorithm>
#include<stack>
#include<map>
#define mod 1000000007
using namespace std;

typedef unsigned long long ll;

vector<string> a;
map<int,int> m;

string f1(string a){
  ll x=(ll)atoi(a.c_str());
  x=(x*x)%mod;
  ostringstream os;
  os<<x;
  return os.str();
}

string f2(string a,string b){
  ll x=atoi(a.c_str()),y=atoi(b.c_str()),c=1;
  for(int i=0;i<y;i++){
    if(x<c)return "0";
    c*=2;
  }
  x=x/c;
  ostringstream os;
  os<<x;
  return os.str();
}

void rec(int s,int t){
  for(int i=s;i<t;i++){
    if(a[i]=="<"){
      int l=i+1,r=m[i];
      rec(l,r);
      i=r-1;
    }
    else if(a[i]==">>"){
      if(a[i+1]=="<"){
	int l=i+1,r=m[i+1];
	rec(l,r+1);
        a[r]=f2(a[i-1],a[r]);
	i=r;
      }
      else a[i+1]=f2(a[i-1],a[i+1]);
    }
    else if(a[i]==">")a[i]=f1(a[i-1]);
    else {}
  }
}

int main()
{
  while(1){
    char c;
    string s,t="";
    vector<string> b;
    getline(cin,s);
    if(s[0]=='#')break;
    a.clear();
    for(int i=0;i<s.length();i++)if(s[i]!=' ')t+=s[i];
    string tmp="";
    for(int i=0;i<t.length();i++){
      if(t[i]=='S'){
	b.push_back("<");
	i++;
      }
      else if(t[i]=='>'){
	if(tmp!="")b.push_back(tmp);
	tmp="";
	b.push_back(">");
      }
      else tmp+=t[i];
      if(i==t.length()-1 && tmp!="")b.push_back(tmp);
    }

    for(int i=b.size()-1;0<i;i--){
      if(b[i]!=">"){
	a.push_back(b[i]);
	if(b[i-1]==">"){
	  i-=2;
	  a.push_back(">>");
	}
      }
      else a.push_back(b[i]);
    }
    a.push_back(b[0]);
    reverse(a.begin(),a.end());
    stack<int> st;
    for(int i=0;i<a.size();i++){
      if(a[i]=="<")st.push(i);
      if(a[i]==">"){
	int a=st.top();
	st.pop();
	m[a]=i;
      }
    }
    rec(0,a.size());
    cout<<a[a.size()-1]<<endl;
  }
  return 0;
}

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

#define MOD 1000000007

long long int factorial[200005]={0};
long long int relay_points[100005]={0};

void set_factorial(int n){
    factorial[0] = 1;
    for(int i=1;i<=n;++i){
        factorial[i] = i * factorial[i-1] % MOD;
    }
}

long long int extgcd(long long int a, long long int b, long long int &x,
                     long long int &y) {
    long long int d = a;
    if (b != 0) {
        d = extgcd(b, a % b, y, x);
        y -= (a / b) * x;
    } else {
        x = 1;
        y = 0;
    }
    return d;
}

// a : 元, md : 法
long long int multi_inv(long long int md, long long int a) {
    long long int x, y;
    extgcd(md, a, x, y);
    return (y > 0 ? y : md + y);
}

int main(){
    long long int h, w, a, b;
    cin >> h >> w >> a >> b;

    set_factorial(h+w);

    for(int i=0;i<w-b;++i){
        long long int tmp = factorial[h-a-1+b+i];
        tmp = tmp * multi_inv(MOD, factorial[h-a-1]) % MOD;
        tmp = tmp * multi_inv(MOD, factorial[b+i]) % MOD;
        relay_points[i] = tmp;
    }

    long long int ans = 0;
    for(int i=0;i<w-b;++i){
        long long int tmp = factorial[a+w-b-i-2];
        tmp = tmp * multi_inv(MOD, factorial[a-1]) % MOD;
        tmp = tmp * multi_inv(MOD, factorial[w-b-i-1]) % MOD;
        ans = (ans + relay_points[i] * tmp % MOD) % MOD;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 2560
n,m=map(int, input().split())
dame=set()
h=list(map(int, input().split()))
for x in range(m):
    a,b=map(int, input().split())
    ah=h[a-1]
    bh=h[b-1]
    if ah>=bh:
        dame.add(b)
    if bh>=ah:
        dame.add(a)
print(n-len(dame))

Measured memory_bytes: 20056
#include <iostream>
#include <ios>
#include <iomanip>
#include <utility>
#include <functional>
#include <math.h>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <stdlib.h>
#include <stdio.h>
#include <sstream>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <tuple>
#include <queue>
using namespace std;
#define rep(i,n,x) for(int i=n;i<x;i++)
#define rem(i,n,x) for(int i=n;i>x;i--)
#define SORT(x) sort(x.begin(),x.end())
#define rev(x) reverse(x.begin(),x.end())
#define all(x) x.begin(),x.end()
#define pb push_back
#define setp(x) setprecision(x)
using ll = long long;
using ull = unsigned long long;

int n, m;
int p[100000], y[100000];
vector<int> a[100001];

int main() {
	cin >> n >> m;
	rep(i, 0, m) {
		cin >> p[i] >> y[i];
		a[p[i]].pb(y[i]);
	}

	rep(i, 0, n) SORT(a[i + 1]);
	rep(i, 0, m) {
		cout << setw(6) << setfill('0') << p[i];
		cout << setw(6) << setfill('0') << lower_bound(all(a[p[i]]), y[i]) - a[p[i]].begin() + 1 << endl;
	}

	return 0;
}

Measured memory_bytes: 7808
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int [] arr = new int[n+1];
        for(int i=0; i<n-1; i++){
            arr[scanner.nextInt()]+=1;
        }
        for(int i=1; i<=n; i++)
            System.out.println(arr[i]);
    }
}

Measured memory_bytes: 60128
c = [list(map(int,input().split())) for _ in range(3)]
flag = 0
for i in range(2):
  for j in range(2):
    if c[i][j]+c[i+1][j+1] != c[i+1][j]+c[i][j+1]:
      flag = 1
if flag == 1:
  print("No")
else:
  print("Yes")

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

b = list(map(int,input().split()))

list = [b[0]]

for i in range(n-2):
    if b[i] <= b[i+1]:
        list.append(b[i])
    else:
        list.append(b[i+1])

list.append(b[-1])
print(sum(list))   

Measured memory_bytes: 3060
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
 
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
 
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

def divisor(n): #nの約数を全て求める
    i = 1
    table = []
    while i * i <= n:
        if n%i == 0:
            table.append(i)
            table.append(n//i)
        i += 1
    table = list(set(table))
    return table

def is_prime(n):
    for i in range(2, n + 1):
        if i * i > n:
            break
        if n % i == 0:
            return False
    return n != 1

a, b = MAP()
kouyaku = list(set(divisor(a)) & set(divisor(b)))

ans = 0
for k in kouyaku:
    if is_prime(k):
        ans += 1
print(ans+1)




Measured memory_bytes: 7236
#include <stdio.h>
#define INF (int)2e9
#define MAX 100

int A[MAX][MAX];

int prim(int n)
{
    int u,minv;
    int sum = 0;
    int mV[MAX],P[MAX],Type[MAX];

    for ( int i = 0; i < n; ++i) {
        mV[i] = INF;
        P[i] = -1;
        Type[i] = 0;
    }

    mV[0] = 0;
    while(1) {
        minv = INF;
        u = -1;
        for (int i = 0; i < n; ++i) {
            if (Type[i] != 2 && minv > mV[i]) {
                u = i;
                minv = mV[i];
            }
        }
        if ( u == -1 ) {
            break;
        }
        Type[u] = 2;
        for (int i = 0; i < n; ++i) {
            if (Type[i] != 2 && A[u][i] != INF) {
                if (mV[i] > A[u][i] ) {
                    mV[i] = A[u][i];
                    P[i] = u;
                    Type[i] = 1;
                }
            }
        }
    }
    for (int i = 0; i < n; ++i) {
        if (P[i] != -1) {
            sum += A[i][P[i]];
        }
    }
    return sum;
}
int main() {
    int n;
    int i,j;
    int v;
    scanf("%d",&n);

    for (i = 0; i < n; ++i) {
        for (j = 0; j < n; ++j) {
            scanf("%d", &v);
            A[i][j] = (v == -1) ? INF : v;
        }
    }
    printf("%d\n",prim(n));
    return 0;
}


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

#define ll long long
#define mod 1000000007

using namespace std;



int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,m,a,x,y,c=-2000,d=INT_MAX,e=0;
    cin>>n>>m>>x>>y;
    for(int i=1;i<=n;i++){
        cin>>a;c=max(a,c);
    }c=max(c,x);
    for(int i=1;i<=m;i++){
        cin>>a;
        d=min(a,d);
        e=max(e,a);
    }d=min(y,d);
    if(d<=y&&d>c)cout<<"No War\n";
    else cout<<"War\n";
}


Measured memory_bytes: 3580
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep_(i, n, m) for (int i = n; i < (int)(m); i++)
#define all(v) v.begin(), v.end()
#define int long long
#define stoi stoll
//#define _GLIBCXX_DEBUG

signed main() {
  long double A, B; cin >> A >> B;

  cout << (long long)(A*B) << endl;

}


Measured memory_bytes: 3716
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.InputMismatchException;
import java.util.LinkedList;
import java.util.PriorityQueue;
 
 
 
public class Main {
  public static void main(String[] args) {
    InputReader sc = new InputReader(System.in);
 
    int n = sc.nextInt();
    int k = sc.nextInt();
 
    int[] nums = new int[n];
    int oneind = 0;
    for(int i = 0; i < n; i++){
      nums[i] = sc.nextInt();
      if(nums[i] == 1){
        oneind = i;
      }
    }
    int ans = 0;
    int yoyuu1 = 0;
    int yoyuu2 = 0;

    for(int i = 0; i < oneind; i += k - 1){
      ans++;
      yoyuu1 = i + k - 1;
    }
    for(int i = n - 1; i > oneind; i -= k - 1){
      ans++;
      yoyuu2 = i - k + 1;
    }

    if(yoyuu1 - yoyuu2 >= k - 1){
      ans--;
    }
    if(oneind == n - 1){
      ans++;
    }
    System.out.println(ans);
 
  }
 
 //ここからテンプレ
  static class InputReader {
      private InputStream stream;
      private byte[] buf = new byte[1024];
      private int curChar;
      private int numChars;
      private SpaceCharFilter filter;
 
      public InputReader(InputStream stream) {
          this.stream = stream;
      }
 
      public int next() {
          if (numChars == -1)
              throw new InputMismatchException();
          if (curChar >= numChars) {
              curChar = 0;
              try {
                  numChars = stream.read(buf);
              } catch (IOException e) {
                  throw new InputMismatchException();
              }
              if (numChars <= 0)
                  return -1;
          }
          return buf[curChar++];
      }
 
      public String nextStr() {
        int c = next();
        while(isSpaceChar(c)){c = next();}
        StringBuffer str = new StringBuffer();
        do{
          str.append((char)c);
          c = next();
        }while(!isSpaceChar(c));
        return str.toString();
      }
 
      public char nextChar() {
        int c = next();
        while(isSpaceChar(c)){c = next();}
        char ret;
        do{
          ret = (char)c;
          c = next();
        }while(!isSpaceChar(c));
        return ret;
      }
 
      public int nextInt() {
          int c = next();
          while (isSpaceChar(c))
              c = next();
          int sgn = 1;
          if (c == '-') {
              sgn = -1;
              c = next();
          }
          int res = 0;
          do {
              if (c < '0' || c > '9')
                  throw new InputMismatchException();
              res *= 10;
              res += c - '0';
              c = next();
          } while (!isSpaceChar(c));
          return res * sgn;
      }
 
      public boolean isSpaceChar(int c) {
          if (filter != null)
              return filter.isSpaceChar(c);
          return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
      }
 
      public interface SpaceCharFilter {
          public boolean isSpaceChar(int ch);
      }
  }
}

Measured memory_bytes: 23508
A, B, C, X, Y = map(int, input().split())

cost = 0
n_small = min(X, Y)

if A + B > 2*C:
    cost += n_small * (2*C)
else:
    cost += n_small * (A+B)

X -= n_small
Y -= n_small

if X == 0:
    if B > 2*C:
        cost += Y * (2*C)
    else:
        cost += Y * B
else:
    if A > 2*C:
        cost += X * (2*C)
    else:
        cost += X * A
        
print(cost)

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

#pragma GCC optimize("O3")
using namespace std;
#define ll long long
#define ull unsigned long long
#define rep(i,n,N) for(int i=n;i<=N;++i)
#define rap(i,n,N) for(int i=n;i>=N;--i)
#define mp make_pair
#define pb push_back
#define pob pop_back
#define pf push_front
#define pof pop_front
#define fi first
#define se second
#define ff fi.fi
#define fs fi.se
#define sf se.fi
#define ss se.se
#define lc (id<<1)
#define rc ((id<<1)|1)
#define db(x) cout << ">>>>>> " << #x << " -> " << x << endl;
#define all(x) x.begin(),x.end()
#define pii pair<int,int> 
#define pll pair<ll,ll>
#define piii pair<int,pii>
#define piiii pair<pii,pii>
#define psi pair<string,int>
#define endl "\n"
const int MAX = 2e3+5;
const ll MAX2 = 11;
const ll MOD = 1000000000;
const ll INF = 2e18;
const int dr[]={1,0,-1,0,1,1,-1,-1,0};
const int dc[]={0,1,0,-1,1,-1,1,-1,0};
const double pi = acos(-1);
const double EPS = 1e-9;
const int block = 450;

int n,k,ans[MAX][40],id,a,b,cnt[MAX];

int main(){
//	cout<<fixed<<setprecision(10);
//    freopen("input.txt", "r", stdin);
//	freopen("output.txt","w",stdout);
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
//    cin>>n>>k;
    n = 1407, k = 38;
    cout<<n<<' '<<k<<endl;
    id = 1;
    rep(i,1,k){
    	ans[i][1] = 1;
    	rep(j,2,k)ans[i][j] = ++id;
	}
	a = k;
	rep(xx,2,k){
		rep(yy,0,k-2){
			a++;
			ans[a][1] = xx;
			b = yy;
			rep(j,2,k){
				ans[a][j] = ans[j][b+2];
				b = (b+xx-2)%(k-1);
			}
		}
	}
	rep(i,1,n){
		rep(j,1,k){
			++cnt[ans[i][j]];
			cout<<ans[i][j];
			if(j!=k)cout<<' ';
			else cout<<endl;
		}
	}
	rep(i,1,n)if(cnt[i]!=k)return 1;
	return 0;
}

Measured memory_bytes: 768
#include <iostream>
#include <cstring>
#include <cstdlib>
using namespace std;


int n;
int len;
int N;

int x[10];

bool han(int n){

  if( n == 0 ) return true;
  //テヲツ。ツ?ヲツ閉ー k
  int k= 0;
  for(int i = 0; i < 100 ; i++){
    if(n == 0) break;
    x[i] = n%10;
    n /= 10;
    k++;
  }
  // cout << k << " " ;
  for(int i = 0 ; i < k/2 ; i++ ){
    if(x[i] != x[k-1-i]) return false;
  }
  return true;
}

int main(){

  cin >> n;

  int ansp = n, ansm = n;  
  if(han(n)) cout << n << endl;
  else{
    while(1){

      ansm--;
      if(han(ansm)){
	cout << ansm << endl;
	break;
      }

      ansp++;
      if(han(ansp)){
	cout << ansp << endl;
	break;
      }
    }
  }



  //  han(n);
  return 0;

}
  

 

Measured memory_bytes: 1164
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#define local
//if you find any bug in my code, please tell me.
const int N=100010;
int a[N];
int main()
{
#ifdef local
    freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
#endif
    int n,i,maxa,ans,d,mind;
    maxa=-1,ans=mind=0x3f3f3f3f;
    cin>>n;
    for(i=1; i<=n; i++)
    {
        scanf("%d",&a[i]);
        if(maxa<a[i]) maxa=a[i];
    }
    for(i=1; i<=n; i++)
    {
        if(a[i]==maxa) continue;
        d=abs(maxa-2*a[i]);
        if(d<mind)
        {
            mind=d;
            ans=a[i];
        }
    }
    printf("%d %d",maxa,ans);
    return 0;
}


Measured memory_bytes: 640
S=input()
N=len(S)

L=[0]*(N+1)
R=[0]*(N+1)
for i in range(1,N+1):
    if S[i-1]=="<":
        L[i]=L[i-1]+1
    if S[-(i)]==">":
        R[-(i+1)]=R[-i]+1
ans=[0]*(N+1)
for i in range(N+1):
    ans[i]=max(L[i],R[i])
print(sum(ans))


Measured memory_bytes: 31156
import sys, io, os, re
import bisect
from pprint import pprint
from math import sin, cos, pi, radians, sqrt, floor
from copy import copy, deepcopy
from collections import deque
from fractions import gcd
from functools import reduce
from itertools import groupby
from heapq import heapify, heappush, heappop

n1 = lambda: int(sys.stdin.readline().strip())
nn = lambda: list(map(int, sys.stdin.readline().strip().split()))
f1 = lambda: float(sys.stdin.readline().strip())
fn = lambda: list(map(float, sys.stdin.readline().strip().split()))
s1 = lambda: sys.stdin.readline().strip()
sn = lambda: list(sys.stdin.readline().strip().split())
nl = lambda n: [n1() for _ in range(n)]
fl = lambda n: [f1() for _ in range(n)]
sl = lambda n: [s1() for _ in range(n)]
nm = lambda n: [nn() for _ in range(n)]
fm = lambda n: [fn() for _ in range(n)]
sm = lambda n: [sn() for _ in range(n)]

def array1(n, d=0): return [d] * n
def array2(n, m, d=0): return [[d] * m for x in range(n)]
def array3(n, m, l, d=0): return [[[d] * l for y in xrange(m)] for x in xrange(n)]

def ldec(A, d=1): return map(lambda x: x - d, A)

N = n1()

for i in range(1, 10**8):
    if (360 * i) % N == 0: 
        print(int((360*i)/N))
        break        


Measured memory_bytes: 72732
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 1000000007;
const int INF = 1e+9;

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

	int ans = INF;
	for (int i = 0; i < s.length(); i++)
	{
		if (s.length() == i + 2)
		{
			 break;
		}

		int num = (s[i] - '0') * 100 + (s[i + 1] - '0') * 10 + (s[i + 2] - '0');
		ans = min(ans, abs(753 - num));
	}

	cout << ans << "\n";
	return 0;
}

Measured memory_bytes: 256
import sys, os, math, bisect, itertools, collections, heapq, queue, copy, array

# from scipy.sparse.csgraph import csgraph_from_dense, floyd_warshall
# from decimal import Decimal
# from collections import defaultdict, deque

sys.setrecursionlimit(10000000)

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

lcm = lambda x, y: (x * y) // math.gcd(x, y)

MOD = 10 ** 9 + 7
INF = float('inf')


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    S = iss()
    T = iss()
    s_len = len(S)
    t_len = len(T)

    ret = INF
    for i in range(s_len - t_len + 1):
        tmp = S[i:i + t_len]
        l = 0
        for j in range(t_len):
            if tmp[j] != T[j]: l += 1
        ret = min(ret, l)
    print(ret)


if __name__ == '__main__':
    main()


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

int main() {
    int h,w;
    cin >> h >> w;
    vector<vector<char>> s(h + 2, vector<char>(w + 2, '.'));
    for(int i = 0; i < h; i++)
    {
        for(int j = 0; j < w; j++)
        {
            cin >> s.at(i + 1).at(j + 1);
        }
    }

    for(int i = 1; i <= h; i++)
    {
        for(int j = 1; j <= w; j++)
        {
            if (s.at(i).at(j) == '.') continue;
            if (((s.at(i - 1).at(j) == '.') && (s.at(i).at(j - 1) == '.')) && ((s.at(i).at(j + 1) == '.') && (s.at(i + 1).at(j) == '.'))) {
                cout << "No" << endl;
                return 0;
            }
        }
    }
    cout << "Yes" << endl;
}

Measured memory_bytes: 256
program abc117d
  integer(8) n, k, i, v
  integer(8), allocatable :: a(:)
  read *, n, k
  allocate(a(n))
  read *, a
  v = 0
  do i = 39, 0, -1
     if (count(btest(a, i)) * 2 <= n .and. v + 2**i <= k) then
        v = v + 2**i
     end if
  end do
  print *, sum(ieor(a, v))
end program abc117d


Measured memory_bytes: 1920
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; }
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define mp make_pair
#define si(x) int(x.size())
const int mod=1000000007,MAX=200005,INF=1<<30;

int main(){
    
    std::ifstream in("text.txt");
    std::cin.rdbuf(in.rdbuf());
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int X;cin>>X;
    if(X>=30) cout<<"Yes\n";
    else cout<<"No\n";
}


Measured memory_bytes: 3644
#include <iostream>
#include <algorithm>
#include <queue>
#include <tuple>
#include <stack>
#include <climits>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#define INF INT_MAX>>1 //要climits#includ

typedef long long ll;

using namespace std;

int main(void){
	ll w, h, x, y;
	cin >> w >> h >> x >> y;
	long double ans1 = w/2.0*h;
	if(h/2 == y && w/2 == x && h%2 == 0 && w%2 == 0){
		cout << ans1 << " " << 1 << endl;
		//printf("%.12lf 1\n", ans1);
	} else{
		cout << ans1 << " " << 0 << endl;
		//printf("%.12lf 0\n", ans1);
	}
}

Measured memory_bytes: 256
N=int(input())
li=list(map(int,input().split()))
plus=[] 
minus=[]
for i in range(0,N):
  if li[i]>0:
    plus.append(li[i])
  else:
    minus.append(li[i])
    
plus.sort()
minus.sort()
#print(plus)
if len(minus)==0:
  M=sum(plus)-2*plus[0]
  print(M)
  a=plus[0]-plus[1]
  aa=0
  print(plus[0],plus[1])
  for i in range(0,N-3):
    aa=a
    a=-plus[i+2]+a
    print(aa,plus[i+2])
  print(plus[N-1],a)
    
    
    
  
elif len(plus)==0:
  M=-sum(minus)+2*minus[len(minus)-1]
  print(M)
  aa=0
  a=minus[N-1]-minus[N-2]
  print(minus[N-1],minus[N-2])
  for i in range(0,N-2):
    aa=a
    a=-minus[N-i-3]+a
    print(aa,minus[N-i-3])
    
  
  
elif len(plus) ==0:
  M=sum(plus)-sum(minus)
  print(M)
  for i in range(0,len(minus)):
    aa=a
    a=aa-minus[i]
    print(aa,minus[i])
  
  
  
elif len(plus)!=1:
  M=sum(plus)-sum(minus)
  print(M)
  aa=0
  a=minus[0]-plus[0]
  print(minus[0],plus[0])
  for i in range(0,len(plus)-2):
    if len(plus)-2==0: break
    aa=a
    a=a-plus[i+1]
    print(aa,plus[i+1])
  aa=a
  a=-a+plus[len(plus)-1]
  print(plus[len(plus)-1],aa)
    
  for j in range(0,len(minus)-1):
    if len(minus)-1==0: break
    aa=a
    a=a-minus[j+1]
    print(aa,minus[j+1])
    
else:
  M=sum(plus)-sum(minus)
  print(M)
  a=plus[0]-minus[0]
  aa=0
  print(plus[0],minus[0])
  for i in range(0,len(minus)-1):
    aa=a
    a=aa-minus[i+1]
    print(aa,minus[i+1])
  
  
  
    

Measured memory_bytes: 13976
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
 
public class Main {
 
    public static final int BIG_NUM  = 2000000000;
    public static final int MOD  = 1000000007;
 
    public static void main(String[] args) {
 
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
 
        try {
            int N = Integer.parseInt(br.readLine());
            String input[] = new String[N];
            input = br.readLine().split("\\s+");
 
            int S[] = new int[N];
            for(int i = 0; i < input.length; i++){
                S[i] = Integer.parseInt(input[i]);
            }
 
            int Q = Integer.parseInt(br.readLine());
            String inputQ[] = new String[Q];
            inputQ = br.readLine().split("\\s+");
 
            int T[] = new int[Q];
            for(int i = 0; i < inputQ.length; i++){
                T[i] = Integer.parseInt(inputQ[i]);
            }
 
            Arrays.sort(T);
 
            int ans = 0;
            int left = 0,right,m;
 
            for(int i = 0; i < T.length; i++){
                right = S.length-1;
                m = (left+right)/2;
 
                while(left <= right){
                    if(S[m] == T[i]){
                        ans++;
                        left = m;
                        break;
                    }else if(S[m] > T[i]){
                        right = m-1;
                    }else{
                        left = m+1;
                    }
                    m = (left+right)/2;
                }
            }
 
            System.out.println(ans);
 
        } catch (NumberFormatException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}


Measured memory_bytes: 55192
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
    int a[3];
    int cnt = 0, x = 0, y = 0, z = 0;
    while(cin >> a[0] >> a[1] >> a[2]){
        sort(a,a+3);
        if(a[0]+a[1] <= a[2]){
            //while(cin >> a[0] >> a[1] >> a[2]);
            break;
        }
        cnt++;
        if(a[0]*a[0] + a[1]*a[1] == a[2]*a[2])x++;
        else if(a[0]*a[0] + a[1]*a[1] > a[2]*a[2])y++;
        else z++;
    }
    cout << cnt << " " << x << " " << y << " " << z << endl;
}



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

int main() {
	int d=0,e=0;
	string a,b="qazxswedcvfrtgb",c="yhnmjuiklop";
	while(cin>>a){
		if(a=="#"){
			break;
		}
		for(int i=0;i<b.size();i++){
			if(a[0]==b[i]){
				e=1;
			}
		}
		for(int i=0;i<c.size();i++){
			if(a[0]==c[i]){
				e=0;
			}
		}
		for(int i=1;i<a.size();i++){
			if(e==1){
			    for(int j=0;j<c.size();j++){
				    if(a[i]==c[j]){
				    	e=0;
				    	d++;
				    }
					
				}
			}
			else if(e==0){
			    for(int j=0;j<b.size();j++){
				    if(a[i]==b[j]){
				    	e=1;
				    	d++;
				    }
				}
			}
		}
		cout<<d<<endl;
		d=0;
	}
	// your code goes here
	return 0;
}

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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

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

const int INF=1001001001;
const int INFLL=1001001001001001001ll;
const int mod=1000000007;
inline void am(int &a,int b){
    a+=b;
    if(a>=mod)a-=mod;
}

int N;
vint G[222222];
vint rG[222222];

int deg[222222];
set<int>st[222222];
int mex[222222];
void dfs(int v,int p){
    for(auto u:G[v]){
        if(u==p)continue;
        dfs(u,v);
        st[v].insert(mex[u]);
    }

    while(st[v].find(mex[v])!=st[v].end())mex[v]++;
}

signed main(){
    cin>>N;
    rep(i,N){
        int p;
        cin>>p;
        p--;
        rG[i].pb(p);
        G[p].pb(i);
        deg[p]++;
    }
    queue<int>que;
    rep(i,N)if(deg[i]==0)que.push(i);
    while(que.size()){
        int v=que.front();
        que.pop();
        for(auto u:rG[v]){
            if(--deg[u]==0)que.push(u);
        }
    }
    vint vs;
    rep(i,N){
        if(deg[i]){
            vs.pb(i);
            deg[i]=0;
            break;
        }
    }

    for(int i=0;i<vs.size();i++){
        for(auto u:rG[vs[i]]){
            if(deg[u]){
                deg[u]=0;
                vs.pb(u);
            }
        }
    }

    rep(i,vs.size()){
        dfs(vs[i],vs[(i-1+vs.size())%vs.size()]);
    }

    int mi=INF,ma=-INF;
    rep(i,vs.size()){
        chmin(mi,mex[vs[i]]);
        chmax(ma,mex[vs[i]]);
    }

    if(mi!=ma){
        int k=-1;
        rep(i,vs.size()){
            if(mex[vs[i]]!=mi)continue;
            if(mex[vs[(i-1+vs.size())%vs.size()]]==mi)continue;
            k=i;
            break;
        }
        assert(k!=-1);
        int m=mex[vs[k]];
        for(int i=k+1;;i++){
            i%=vs.size();
            st[vs[i]].insert(mex[vs[(i-1+vs.size())%vs.size()]]);
            mex[vs[i]]=0;
            while(st[vs[i]].find(mex[vs[i]])!=st[vs[i]].end())mex[vs[i]]++;
            if(i==k)break;
        }
        if(mex[vs[k]]!=m){
            puts("IMPOSSIBLE");
        }
        else{
            puts("POSSIBLE");
        }
        return 0;
    }

    if(vs.size()%2==0)puts("POSSIBLE");
    else puts("IMPOSSIBLE");
    return 0;
}


Measured memory_bytes: 45680
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define white 0
#define gray 1
#define black 2


int n;
int M[100][100];
int d[100],color[100];

void bfs(int u) {
  
  queue<int> Q;
  Q.push(u);
  color[u] = gray;
  while(!Q.empty()) {
    int q = Q.front();
    for(int i = 0;i < n;i++) {
      if(M[q][i] && color[i] == white) {
        Q.push(i);
        d[i] = d[q] + 1;
        color[i] = gray;
      }
    }
    Q.pop();
    color[q] = black;
  }
}

int main() {


  cin >> n;

  for(int i = 0;i < n;i++) {
    d[i] = 0;
    color[i] = white;
    for(int j = 0;j < n;j++) {
      M[i][j] = 0;
    }
  }
  

  for(int i = 0;i < n;i++) {
    int u,k;
    cin >> u >> k;
    u--;
    for(int j = 0;j < k;j++) {
      int v;
      cin >> v;
      v--;
      M[u][v] = 1;
    }
  }

  bfs(0);
  
  for(int i = 0;i < n;i++) {
    cout << i+1 << " ";
    if(d[i] || i == 0) cout << d[i] << endl;
    else cout << -1 << endl;
  }

}





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

long min(long a,long b){
	if(a<b) return a;
	return b;
}
long max(long a,long b){
	if(a>b) return a;
	return b;
}

int main(){
 int n,w;
  cin>>n>>w;
  int wt[100],val[100];
  for(int i=0;i<n;i++){
    cin>>wt[i]>>val[i];
  }
  long dp[100001][101],ans=INT_MIN;
  for(int i=0;i<=1000*n;i++){
    for(int j=n;j>=0;j--){
      dp[i][j]=INT_MAX;
      if(i==0) dp[i][j]=0;
      else if(j==n) dp[i][j]=INT_MAX;
      else{
       if(i>=val[j] && dp[i-val[j]][j+1]!=INT_MAX)
                  dp[i][j]=min(dp[i][j+1],wt[j]+dp[i-val[j]][j+1]);
        else dp[i][j]=min(dp[i][j],dp[i][j+1]);
        
      }
      if(dp[i][j]<=w){
      ans=max(ans,i);
      }
   //   cout<<"i="<<i<<" j="<<j<<" dp[i][j]="<<dp[i][j]<<" ans="<<ans<<endl;
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 79232
#pragma GCC optimize "-O3"
#pragma GCC target ("avx")
#define _USE_MATH_DEFINES
#include<bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;++i)
#define vi vector<int>
#define vvi vector<vi>
#define pb push_back
#define pi pair<int,int>
#define vp vector<pair<int,int>>
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define MEMSET(a) memset(a,0,sizeof(a))
#define inf (1ll<<60)
#define SORT(v) sort(all(v))
#define RSORT(v) sort(all(v),greater<int>())
#define SPEED ios::sync_with_stdio(false);cin.tie(0);cout<<fixed<<setprecision(12)
signed gcd(int a, int b){return b?gcd(b,a%b):a;}
signed lcm(int a, int b){return a*b/gcd(a,b);}
//priority_queue<int, vi, greater<int> > que;//昇順

using namespace std;

const int mod=1e9+7;

signed main(){
    SPEED;
    int a,b;
    cin >> a >> b;
    if(a+b>=10)
    {
        cout << "error" << endl;
    }
    else
    {
        cout << a+b << endl;
    }
}


Measured memory_bytes: 256
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache
import sys
sys.setrecursionlimit(10000)
INF = float("inf")
YES, Yes, yes, NO, No, no = "YES", "Yes", "yes", "NO", "No", "no"
dy4, dx4 = [0, 1, 0, -1], [1, 0, -1, 0]
dy8, dx8 = [0, -1, 0, 1, 1, -1, -1, 1], [1, 0, -1, 0, 1, 1, -1, -1]


def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W


def ceil(a, b):
    return (a + b - 1) // b


# aとbの最大公約数
def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a % b)


# aとbの最小公倍数
def lcm(a, b):
    g = gcd(a, b)
    return a / g * b


def main():
    H, W = map(int, input().split())
    h, w = map(int, input().split())

    print(H * W - (h * W + w * H - h * w))


if __name__ == '__main__':
    main()


Measured memory_bytes: 3952
#define _USE_MATH_DEFINES
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <vector>
using ll = long long;
using namespace std;
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for(int i = int(a); i < int(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
const long long inf = 1LL << 60;
const long long mod = 1e9 + 7;

int main() {
    int n, i;
    cin >> n;
    rep(i, 1, n + 1) {
        int x = i;
        if(i % 3 == 0) {
            cout << " " << i;
            continue;
        }
        while(x) {
            if(x % 10 == 3) {
                cout << " " << i;
                break;
            } else {
                x /= 10;
            }
        }
    }
    cout << endl;
}



Measured memory_bytes: 3124
#include "iostream"
using namespace std;
#include <string>
using namespace std;
#include "cctype"
using namespace std;


int main(int argc, char const *argv[])
{
	string str,ans;
	int i = 0;
	char temp;

	getline(cin,str);

	for(i=0;i<str.size();i++)
	{
		temp = str[i];
		if( isalpha(temp) )
		{
			if( islower(temp) )
			{
				ans += toupper(temp);
			}
			if ( isupper(temp) )
			{
				ans += tolower(temp);
			}
		}
		else{
			ans += temp;
		}
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 3148