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

int main() {
  int a,b;
  cin >>a>>b;
  
  if (a+b>16){
    cout << ":(";
  }
  
  else if (a==b) {
    cout<< "Yay!";
  }
  
  else {
    if (16-2*min(a,b) < (max(a,b)-min(a,b))*2) {
      cout << ":(";
    }
    else {
      cout <<"Yay!";
    }
  }
}

Measured memory_bytes: 256
// Problem : C - Count Order
// Contest : AtCoder Beginner Contest 150
// URL : https://atcoder.jp/contests/abc150/tasks/abc150_c
// Memory Limit : 1024.000000 MB 
// Time Limit : 2000.000000 milisec 
// Powered by CP Editor (https://github.com/coder3101/cp-editor2)

#include<bits/stdc++.h>
#define pb push_back
#define int long long
#define vi vector<int>
#define pii pair<int,int>
#define f first
#define se second
using namespace std;
template<typename T1,typename T2>istream &operator>>(istream &is, vector<pair<T1,T2>> &v) { for (pair<T1,T2> &t : v) is >> t.f>>t.se; return is; }
template<typename T>istream &operator>>(istream &is, vector<T> &v) { for (T &t : v) is >> t; return is; }
template<typename T>ostream &operator<<(ostream &os, const vector<T> &v) { for (const T &t : v) {os << t <<" ";} os << '\n'; return os; }
double pi=acos(-1.0);
int m=1000000007;
int abst(int a)
{return a<0?-a:a;}
struct HASH{
  size_t operator()(const pii &x)const{
    return (size_t) x.first * 37U + (size_t) x.second;}};
int Pow(int n,int x){int ans=1;
 while(x>0)
 {if(x&1)ans=(ans*n)%m;n=(n*n)%m;x=x>>1;}
 return ans;}

int max(int a,int b){return a>b?a:b;}
int min(int a,int b){return a<b?a:b;}

void solve()
{
int n;
cin>>n;
vi v(n);
for(int i=1;i<=n;i++)
v[i-1]=i;
vi v1(n),v2(n);
cin>>v1>>v2;
int a=-1,b=-1;
if(v1==v)
a=1;
if(v2==v)
b=1;
int t=1;
while(a==-1 || b==-1)
{
	next_permutation(v.begin(),v.end());
	t++;
	if(v==v1)
	a=t;
	if(v==v2)
	b=t;
}
cout<<abst(a-b);
}

int32_t main(){
ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
int t;
//cin>>t;
t=1;
while(t--)
{
    solve();
}
}


Measured memory_bytes: 256
def check(i, j, w, h, s):
    if (i + 1 < h and s[i + 1][j] == "#"):
        return True
    if (i - 1 >= 0 and s[i - 1][j] == "#"):
        return True
    if (j + 1 < w and s[i][j + 1] == "#"):
        return True
    if (j - 1 >= 0 and s[i][j - 1] == "#"):
        return True
    return False


h, w = map(int, input().split())
s = [list(input()) for _ in range(h)]

for i in range(h):
    for j in range(w):
        if (s[i][j] == "#"):
            if check(i, j, w, h, s):
                True
            else:
                print("No")
                exit()
print("Yes")


Measured memory_bytes: 3064
import java.util.*;
public class Main{   
    public static void main(String[] args){
      Scanner sc = new Scanner(System.in);
      String s = sc.next();
      long k = sc.nextLong();
      long cnt = 1;
      long sum = -1;
      long a = 0;
      long b = 0;
      
      for(int i = 0;i < s.length()-1;i++){
        if(s.charAt(i)==s.charAt(i+1))cnt++;
        else if(sum==-1){
          a=cnt;
          sum=0;
          cnt=1;
        }else{
          sum+=cnt/2;
          cnt=1;
        }
      }
      b=cnt;
      if(sum==-1){
        System.out.println((long)k*s.length()/2);
        return;
      }
      long ans = 0;
      if(s.charAt(s.length()-1)==s.charAt(0))ans = sum*k+((a+b)/2)*(k-1)+a/2+b/2;
      else{
        sum+=a/2+b/2;
        ans=sum*k;
      }
      System.out.println(ans);
    }
}

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

int main() {
    int N, L;
    cin >> N >> L;
    vector<string> S(N);
    for (int i = 0; i < N; ++i) cin >> S[i];

    sort(S.begin(), S.end());  // a[0:N] を大きい順にソート

    string new_s;
    for (auto& s : S) {
        new_s += s;
    }
    cout << new_s;
}

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

int main() {
  int n;
  std::string ans="No";
  cin >> n;
  int a,b,c;
  int x[n];
  if(n%3==0){
    for(int i=0;i<n;i++){
      cin >> x[i];
    }
    sort(x,x+n);
    a=x[0];
    b=x[n/3];
    c=x[2*n/3];
    if((a|b)-(a&b)==c)ans="Yes";
    for(int i=0;i<n/3;i++){
      if(a!=x[i] || b!=x[i+n/3] || c!=x[i+2*n/3]){
          ans="No";
          break;
        }
    }

  }else{
    ans="Yes";
    for(int i=0;i<n;i++){
      cin >> a;
      if(a!=0){
        ans="No";
        break;
      }
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <map>
#include <queue>

static const int INF = 1000000007;
using ll = long long;
using u32 = unsigned;
using namespace std;

int main() {
    string n;
    cin >> n;
    int k = 0;
    for (auto &&a : n) {
        k += a-'0';
    }
    cout << (stoi(n)% k == 0 ? "Yes" : "No") << "\n";
    return 0;
}


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

long A, B, C;

int main() {
    cin >> A >> B >> C;
    long ans = 0;
    if((A == B) && (C != A)) ans = C;
    if((B == C) && (A != B)) ans = A;
    if((C == A) && (B != C)) ans = B;
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long 
#define endl "\n"
#define pb push_back
#define f(i,n) for(i=0;i<n;i++)
#define F(i,a,b) for(i=a;a<=b;i++)
#define arr(a,n) for( i=0;i<n;i++)cin>>a[i];
#define fi first
#define se second
#define mp make_pair
#define mod 1000000007
#define YES cout<<"YES"<<endl;
#define Yes cout<<"Yes"<<endl;
#define NO cout<<"NO"<<endl;
#define No cout<<"No"<<endl;
#define yes cout<<"yes"<<endl;
#define no cout<<"no"<<endl;
#define vi vector<ll>
#define ed end()
#define bg begin()
#define sz size()
#define ln length()
#define s() sort(a,a+n);
#define sr() sort(a,a+n,greater<ll>());
#define v()  sort(v.begin(),v.end());
#define vr() sort(v.begin(),v.end(),greater<ll>());
#define mod 1000000007
#define fast() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
ll gcd(ll a, ll b){if(!b)return a;return gcd(b, a % b);}
ll power(ll x,ll y,ll p){ll res=1;x%=p;while(y>0){if(y&1)res=(res*x)%p;y=y>>1;x=(x*x)%p;}return res;}
int main() {

fast();

{
  int n,a,b;
  cin>>n>>a>>b;
  cout<<min(n*a,b)<<endl;
  

}
return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(int i = x; i <= n; i++)
#define rep3(i, x, n) for(int i = x; i >= n; i--)
#define elif else if
#define sp setprecision
#define pb(x) push_back(x)
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, ll> pil;
typedef pair<ll, int> pli;
typedef pair<ld, ld> pdd;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const int inf = 1e8;
const ll INF = 1e16;
const string alpha = "abcdefghijklmnopqrstuvwxyz";

int main(){
    int N;
    ll M;
    cin >> N >> M;
    ll A, sum = 0;
    map<ll, ll> mp;
    mp[0]++;
    rep(i, N){
        cin >> A;
        sum = (sum+A)%M;
        mp[sum]++;
    }
    ll ans = 0;
    for(auto &e: mp){
        ll num = e.second;
        ans += num*(num-1)/2;
    }
    cout << ans << endl;
}

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

using namespace std;

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

    sort(s.begin(), s.end());
    cout << (s[0] == s[1] && s[2] == s[3] && s[1] != s[2] ? "Yes" : "No") << endl;
}

Measured memory_bytes: 256
N,M = map(int,raw_input().split())

X = map(int,raw_input().split())

X.sort()
gap = []
for i in range(M-1):
    i = M-i-1
    gap.append(abs(X[i]-X[i-1]))

gap.sort()
gap.reverse()

gapsum = 0
counter = 0
if len(gap) > 0:
    while N-counter-1 > 0 and counter < len(gap):
        gapsum += gap[counter]
        counter += 1

print abs(X[0]-X[-1])-gapsum

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

#define MAX 50022
#define NIL -1

int primes[MAX];

bool isPrime(int n)
{
    if (n <= 1) {
        primes[n] = 0;
        return false;
    }
    if (n <= 3) {
        primes[n] = 1;
        return true;
    }
    if (n % 2 == 0 || n % 3 == 0) {
        primes[n] = 0;
        return false;
    }
    for (int i = 5; i * i <= n; i = i + 6)
        if (n % i == 0 || n % (i + 2) == 0) {
            primes[n] = 0;
            return false;
    }
    primes[n] = 1;
    return true;
}

int main()
{
    for (int i = 1; i <= MAX; i++) primes[i] = NIL;
    int N;
    while(std::scanf("%d", &N) != EOF) {
        int i =1;
        while (1) {
            if (primes[N-i] != NIL) {
                if (primes[N-i] == 1) {
                    std::printf("%d ", N-i);
                    break;
                }
            } else {
                if (isPrime(N-i)) {
                    std::printf("%d ", N-i);
                    break;
                }
            }
            i++;
            if (N-1 == 0) break;
        }
        i = 1;
        while (1) {
            if (primes[N+i] != NIL) {
                if (primes[N+i] == 1) {
                    std::printf("%d\n", N-i);
                    break;
                }
            } else {
                if (isPrime(N+i)) {
                    std::printf("%d\n", N+i);
                    break;
                }
            }
            i++;
            if (N+1 == MAX) break;
        }

    }
    return 0;
}



Measured memory_bytes: 3320
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cassert>
#define FILL(a, n, x) memset((a), (x), sizeof ((a)[0]) * (n))
#define FILLA(a, x) memset((a), (x), sizeof (a))
#define COPY(a, n, b) memcpy((b), (a), sizeof ((a)[0]) * (n))
#define COPYA(a, b) memcpy((b), (a), sizeof (a))
using namespace std;

typedef pair<int, int> pii;
typedef long long li;
typedef unsigned long long lu;
const int inf = ~0U >> 2;
const li infl = ~0LLU >> 2;

template <class T> inline void Min(T &x, T y) { if (y < x) x = y; }
template <class T> inline void Max(T &x, T y) { if (y > x) x = y; }

const int mod = 998244353;
inline int Add(int x) { return x >= mod ? x - mod : x; }
inline void Add(int &x, int y) { x += y; if (x >= mod) x -= mod; }
inline int Sub(int x) { return x < 0 ? x + mod : x; }
inline void Sub(int &x, int y) { x -= y; if (x < 0) x += mod; }
inline int Mul(int x, int y) { return (int)((li)x * y % mod); }
inline int Mul(int x, int y, int z) { return Mul(x, Mul(y, z)); }
int Pow(int x, int y) { int z = 1;
  for (; y; y >>= 1, x = Mul(x, x)) { if (y & 1) z = Mul(z, x); } return z; }
inline int Inv(int x) { return Pow(x, mod - 2); }
inline int Fix(li x) { x %= mod; if (x < 0) x += mod; return (int)x; }
inline int Fix(int x) { x %= mod; if (x < 0) x += mod; return x; }

// ----------------------------------------

const int maxn = 500, maxk = 1000;
int K, n;
int color[maxn * 2];
int a[maxn][maxn];

int main(void) {
  scanf("%d", &K);
  n = (K + 3 >> 2) * 2;
  if (K == 1) {
    puts("1\n1");
    return 0;
  }
  int cnt_more = 2 * n - K, id = 0;
  for (int i = 0; i < cnt_more; ++i) {
    color[id++] = i;
    color[id++] = i;
  }
  for (int i = cnt_more; i < K; ++i) {
    color[id++] = i;
  }
  assert(id == 2 * n);
  for (int i = 0; i < n; ++i) {
    int x = 0, y = i, t = i * 2;
    for (int j = 0; j < n; ++j) {
      a[x][y] = color[t];
      x = (x + 1) % n;
      y = (y + 1) % n;
      t ^= 1;
    }
  }
  printf("%d\n", n);
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < n; ++j) {
      printf("%d%c", a[i][j] + 1, " \n"[j == n - 1]);
    }
  }
  return 0;
}


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


int main()
{
    int n;
    int room[4][3][10] = { { 0 } };
    cin >> n;
    for (int i = 0; i < n; i++){
        int b, f, r, v;
        cin >> b >> f >> r >> v;
        room[b - 1][f - 1][r - 1] = room[b - 1][f - 1][r - 1] + v;
    }
    for (int i = 0; i < 4; i++){
        for (int j = 0; j < 3; j++){
            for (int k = 0; k < 10; k++){
                cout <<" "<< room[i][j][k];
            }
            cout << endl;
        }
        if (i < 3){
            for (int l = 0; l < 20; l++){
                cout << "#";
            }
            cout << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 1160
A, B, K = map(int, input().split())
if B-A+1 >= 2*K: # A以上B以下の整数の数が2K以上
    res_list = [i for i in range(A, A+K)] + [i for i in range(B-K+1, B+1)]
else: # A以上B以下の整数の数が2K未満
    res_list = [i for i in range(A, B+1)]
for i in res_list:
    print(i)

Measured memory_bytes: 9120
def check(x, y):
    for i in range(6):
        order = [0, 0, 0]
        for j in range(3):
            k = a[i][j]
            if {x[j], x[-j-1]} != {y[k], y[-k-1]}:
                break
            if x[j] == y[k]:
                order[j] = 1
                if x[j] == x[-j-1]:
                    order[j] = 2
        else:
            if 2 in order or (i < 3) == sum(order) % 2:
                return True
    return False

a = [[0, 1, 2], [2, 0, 1], [1, 2, 0], [0, 2, 1], [2, 1, 0], [1, 0, 2]]
n = int(input())
x = [input().split() for i in range(n)]
for i in range(n):
    for j in range(i+1, n):
        if check(x[i], x[j]):
            break
    else:
        continue
    print('No')
    break
else:
    print('Yes')

Measured memory_bytes: 7804
#include <iostream>
#include <queue>
#include <stack>
#include <vector>
#include <stdio.h>
#include <algorithm>
#include <string.h>
#include <string>
#include <cmath>
#include <complex>
#include <map>
using namespace std;

#define rep(i,n) for(int i=0;i<int(n);++i)
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define EPS 1e-8

static const double PI=6*asin(0.5);
typedef complex<double> P;
typedef long long ll;

vector<double> a;
double t;

int main(){
	while(cin>>t){
		a.PB(t);
		rep(i,5){
			a.PB(a[a.size()-1]*2.0);
			a.PB(a[a.size()-1]/3.0);
		}
		double s=0;
		rep(i,10){
			s+=a[i];
			//printf("%d = %.10lf\n",i+1,a[i]);
		}
		printf("%.8lf\n",s);
		a.clear();
	}
	return 0;
}

Measured memory_bytes: 1256
#include <stdio.h>

int main(){    
    
    int r[33] = {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};
    
    int n;
    
    scanf("%d", &n);
    
    printf("%d", r[n - 1]);

    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define int long long
typedef long long ll;
using namespace std;
const int MOD = 1000000007;
const int INF = 1010000000;
const double EPS = 1e-10;
const pair<int,int> fd[] = {make_pair(1,0),make_pair(-1,0),make_pair(0,1),make_pair(0,-1)}; 

vector<int> init(int size){
  vector<int> par(size,-1);
  return par;
}

int root(int x, vector<int>& par){
  if(par[x] < 0){
    return x;
  }else{
    return par[x] = root(par[x],par);
  }
}

bool same(int x, int y, vector<int>& par){
  return root(x, par) == root(y, par);
}

void unite(int x, int y, vector<int>& par){
  x = root(x, par), y = root(y, par);
  if(same(x,y, par))return;
  par[x] += par[y];
  par[y] = x;
}

int size(int x, vector<int>& par){
  return -par[root(x, par)];
}

int pow(int x, int n){
  if(n == 0)return 1;
  if(n % 2 == 0)return pow(x * x % MOD, n/2);
  else return x * pow(x, n-1) % MOD;
}

signed main(){
  int n;cin>>n;
  int a[110000], b[110000];
  rep(i,n+1)cin>>a[i];rep(i,n)cin>>b[i];
  int ans = 0;
  rep(i,n){
    if(a[i] > b[i]){
      a[i] = 0;ans += b[i];
    }else{
      ans += a[i];b[i] -= a[i];ans += min(a[i+1], b[i]);
      a[i] = 0;a[i+1] = max((int)0, a[i+1]-b[i]);
    }
  }
  cout << ans << endl;
}


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

typedef ostringstream OSS; typedef istringstream ISS;
typedef long long LL;
typedef pair<int, int> PII;  typedef pair<LL, LL> PLL;
typedef vector<int>    VI;   typedef vector<VI>   VVI;   typedef vector<VVI>   VVVI;
typedef vector<LL>     VLL;  typedef vector<VLL>  VVLL;  typedef vector<VVLL>  VVVLL;
typedef vector<double> VD;   typedef vector<VD>   VVD;   typedef vector<VVD>   VVVD;
typedef vector<string> VS;   typedef vector<VS>   VVS;   typedef vector<VVS>   VVVS;
typedef vector<bool>   VB;   typedef vector<VB>   VVB;   typedef vector<VVB>   VVVB;
typedef vector<PII>    VPII; typedef vector<VPII> VVPII; typedef vector<VVPII> VVVPII;
typedef vector<PLL>    VPLL; typedef vector<VPLL> VVPLL; typedef vector<VVPLL> VVVPLL;

typedef unsigned int  UI;
typedef vector<UI>    VUI;
typedef vector<VUI>   VVUI;

#define fst first
#define snd second
// #define Y first
// #define X second
#define MP make_pair
#define PB push_back
#define EB emplace_back 
#define ALL(x)  (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define RANGEBOX(x,y,maxX,maxY) (0 <= (x) && 0 <= (y) && (x) < (maxX) && (y) < (maxY))
#define RANGE(x, l, r) ((l) <= (x) && (x) <= (r))
#define rep(i, N)  for (int i = 0; i < (int)(N); i++)
#define rrep(i, N) for (int i = N - 1; i >= 0; i--)
#define REP(i, init, N)  for (int i = (init); i < (int)(N); i++)
#define RREP(i, N, last) for (int i = (init - 1); i >= last; i--)
#define MAXUD(orig, target) orig = max(orig, target)
#define MINUD(orig, target) orig = min(orig, target)
#define DUMP(x) cerr << #x << " = " << (x) << endl

template < typename T > inline T fromString(const string &s) { T res; ISS iss(s); iss >> res; return res; };
template < typename T > inline string toString(const T &a)   { OSS oss; oss << a; return oss.str(); };

template<typename T=int> inline void dump(vector<T> vs, bool ent=false) { rep(i, vs.size()) cout << vs[i] << (i+1==vs.size() ? '\n' : ' '); if (ent) cout << endl; }
template<typename T = int> inline void dump(vector<vector<T>> vs, bool ent=false) { rep(i, vs.size()) dump<T>(vs[i]); if (ent) cout << endl; }

const int    INF  = 0x3f3f3f3f;
const LL     INFL = 0x3f3f3f3f3f3f3f3fLL;
const double DINF = 0x3f3f3f3f;
const int    DX[] = {1,  0, -1, 0};
const int    DY[] = {0, -1,  0, 1};
const double EPS  = 1e-12;
// const double PI   = acos(-1.0);

template<typename T = int> inline T in() { T x; cin >> x; return x; }
template<typename T = int> inline vector<T> in(int n) { vector<T> xs(n); rep(i, n) cin >> xs[i]; return xs; }
template<typename T = int> inline vector<vector<T>> in(int n, int m) { vector<vector<T>> xs(n, vector<T>(m)); rep(i, n) rep(j, m) cin >> xs[i][j]; return xs; }

int N, K;
VI D;

bool check(int m) {
    string s = toString<int>(m);
    for (auto c : s) {
        if (find(ALL(D), (int)(c - '0')) !=  D.end()) {
            return false;
        }
    }
    return true;
}

int main(void) {
    N = in(), K = in();
    D = in(K);
    
    int m;
    for (m = N; !check(m); ++m);

    cout << m << endl;

    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;int flag = 0;
    cin>>n;
    for(int i=0;i<15;i++)
    {
        int sum = 0;
        for(int j=0;j<26;j++)
        {
            sum = i*7 + j*4;
            if(sum == n){
             flag = 1;

            }
        }
    }
    if(flag == 1)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 384
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<climits>
#include<iostream>
#include<sstream>
#include<utility>
#include<map>
#include<vector>
#include<queue>
#include<algorithm>
#include<set>
#include<stack>

using namespace std;
typedef long long ll;
typedef pair<int,int>P;

int main()
{
	int N,M,X,Y;
	vector<int>xc,yc;

	cin>>N>>M>>X>>Y;
	
	for(int i=0;i<N;i++)
	{
		int a;
		cin>>a;
		xc.push_back(a);
	}
	for(int i=0;i<M;i++)
	{
		int a;
		cin>>a;
		yc.push_back(a);
	}

	for(int i=X+1;i<=Y;i++)
	{
		bool nowar=true;
		for(auto it=xc.begin();it!=xc.end();it++)
			nowar&=(*it)<i;
		for(auto it=yc.begin();it!=yc.end();it++)
			nowar&=(*it)>=i;
		if(nowar)
		{
			cout<<"No War"<<endl;
			return 0;
		}
	}
	cout<<"War"<<endl;

}

Measured memory_bytes: 256
#include<cstdio>
#define MAX 100001
int Tree[MAX];

int findRoot(int x){
  if(Tree[x] == x) return x;
  else{
    int tmp = findRoot(Tree[x]);
    Tree[x] = tmp;
    return tmp;
  }
}

using namespace std;

int main()
{
    int list[MAX];
    int belong[MAX];
   int n,m;
   while(scanf("%d%d",&n,&m)!=EOF){
    for(int i = 1; i <= n; i++){
        scanf("%d", &list[i]);
        Tree[i] = i;
    }
    while(m--){
        int a, b;
        scanf("%d%d", &a, &b);
        int na = findRoot(a);
        int nb = findRoot(b);
        if(na != nb) Tree[na] = nb;
    }
    int ans = 0;
    for(int i = 1; i <= n; i++){
        int t = findRoot(i);
        belong[list[i]] = t;
    }
    for(int i = 1 ; i <= n; i++){
        if(belong[i] == Tree[i])
        ans++;
    }
    printf("%d\n",ans);
   }
    return 0;
}


Measured memory_bytes: 1280
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,long long> PA;
int main(){
  int n,m,k,s,p,q;
  int a,b,c[100001];
  cin >> n >> m >> k >> s;
  cin >> p >> q;
  int town[100001];
  bool zo[100001] = {false};
  fill(town,town+100001,p);
  town[1] = 0;
  town[n] = 0;
  for(int i=0;i<k;i++){
    cin >> c[i];
    zo[ c[i] ] = true;
  }
  vector<int> vec[100001];
  for(int i=0;i<m;i++){
    cin >> a >> b;
    vec[a].push_back(b);
    vec[b].push_back(a);
  }
  queue<PA> que;
  for(int i=0;i<k;i++){
    bool now[100001] = {false};
    now[ c[i] ] = true;
    que.push(PA(c[i],0));
    while(!que.empty()){
      PA pa = que.front();
      que.pop();
      if(pa.second >= s) continue;
      for(int j=0;j<vec[pa.first].size();j++){
	if(now[vec[pa.first][j]] == true || zo[vec[pa.first][j]] == true || vec[pa.first][j] == 1 || vec[pa.first][j] == n)
	  continue;
	town[ vec[pa.first][j] ] = q;
	now[ vec[pa.first][j] ] = true;
	que.push(PA(vec[pa.first][j],pa.second+1));
      }
    }
  }
  priority_queue<PA,vector<PA>,greater<PA> > pq;
  long long min_cost[100001];
  fill(min_cost,min_cost+100001,LLONG_MAX);
  min_cost[1] = 0;
  pq.push(PA(1,0));
  while(!pq.empty()){
    PA pa = pq.top();
    pq.pop();
    for(int i=0;i<vec[pa.first].size();i++){
      int next = vec[pa.first][i];
      long long next_cost = pa.second + town[pa.first];
      if(min_cost[next] > next_cost && zo[next] == false){
	min_cost[next] = next_cost;
	pq.push(PA(next,next_cost));
      }
    }
  }
  cout << min_cost[n] << endl;
  return (0);
}

Measured memory_bytes: 11004
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i = a; i < b; ++i)
#define all(c) c.begin(), c.end()
#define gmax(x,y) x=max(x,y)
#define gmin(x,y) x=min(x,y)
#define gadd(x,y) x=add(x,y)
#define gmul(x,y) x=mul(x,y)
using namespace std;

typedef pair<int,int> pii;
typedef long long ll;

int main(){
	cin.tie(0);
	cout.tie(0);
	ios_base::sync_with_stdio(0);
	string s;
	cin >> s;
	cout << (s == "AAA" || s == "BBB" ? "No" : "Yes") << '\n';
}


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

using namespace std;

using int64 = long long;
const int mod = 1e9 + 7;
// const int mod = 998244353;

const int64 infll = (1LL << 62) - 1;
const int inf = (1 << 30) - 1;

struct IoSetup {
  IoSetup() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    cerr << fixed << setprecision(10);
  }
} iosetup;


template< typename T1, typename T2 >
ostream &operator<<(ostream &os, const pair< T1, T2 > &p) {
  os << p.first << " " << p.second;
  return os;
}

template< typename T1, typename T2 >
istream &operator>>(istream &is, pair< T1, T2 > &p) {
  is >> p.first >> p.second;
  return is;
}

template< typename T >
ostream &operator<<(ostream &os, const vector< T > &v) {
  for(int i = 0; i < (int) v.size(); i++) {
    os << v[i] << (i + 1 != v.size() ? " " : "");
  }
  return os;
}

template< typename T >
istream &operator>>(istream &is, vector< T > &v) {
  for(T &in : v) is >> in;
  return is;
}

template< typename T1, typename T2 >
inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }

template< typename T1, typename T2 >
inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

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

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

template< typename T, typename V >
typename enable_if< is_class< T >::value == 0 >::type fill_v(T &t, const V &v) {
  t = v;
}

template< typename T, typename V >
typename enable_if< is_class< T >::value != 0 >::type fill_v(T &t, const V &v) {
  for(auto &e : t) fill_v(e, v);
}

template< typename F >
struct FixPoint : F {
  FixPoint(F &&f) : F(forward< F >(f)) {}

  template< typename... Args >
  decltype(auto) operator()(Args &&... args) const {
    return F::operator()(*this, forward< Args >(args)...);
  }
};

template< typename F >
inline decltype(auto) MFP(F &&f) {
  return FixPoint< F >{forward< F >(f)};
}


int main() {
  int64 A, B, K;
  cin >> A >> B >> K;

  int64 U = min(A, K);
  A -= U;
  K -= U;

  U = min(K, B);
  B -= U;

  cout << A << " " << B << endl;
}


Measured memory_bytes: 256
use proconio::fastout;
use proconio::input;
use std::collections::HashSet;

#[fastout]
fn main() {
    input! {
        n: usize,
        ss: [String; n],
    }
    let mut set = HashSet::new();
    for s in ss {
        set.insert(s);
    }
    println!("{}", set.len());
}


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

using namespace std;

int main(){
  long long N, H, W, a, b;
  long long ret = 0;
  cin >> N >> H >> W;
  for (int i=0; i<N; i++){
    cin >> a >> b;
    if ((a >= H) && (b >= W)) ret++;
  }

  cout << ret << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long lint;
typedef long double llf;
typedef pair<int, int> pi;
const int mod = 1e9 + 7;

lint n, a[100005], b[100005];

int main(){
	cin >> n;
	for(int i=1; i<=n; i++) scanf("%lld %lld",&a[i], &b[i]);
	lint cum = 0;
	for(int i=n; i; i--){
		a[i] += cum;
		lint lef = b[i] - a[i] % b[i];
		lef %= b[i];
		cum += lef;
	}
	cout << cum << endl;
}

Measured memory_bytes: 1792
import sys
r=sys.stdin.readline
def s():
 def b(M,x,y,n=1):
  M[x][y]=0;a=n
  if M[x-1][y]:a=max(a,b(M,x-1,y,n+1))
  if M[x][y-1]:a=max(a,b(M,x,y-1,n+1))
  if M[x+1][y]:a=max(a,b(M,x+1,y,n+1))
  if M[x][y+1]:a=max(a,b(M,x,y+1,n+1))
  M[x][y]=1
  return a
 for e in iter(r,'0\n'):
  n,m=int(e),int(r())
  P=[[0]*(n+2)for _ in[0]*(m+2)]
  for i in range(m):P[i+1][1:-1]=map(int,r().split())
  print(max(b(P,i,j)for i in range(1,m+1)for j in range(1,n+1)if P[i][j]))
if'__main__'==__name__:s()


Measured memory_bytes: 5740
h, W = map(int,input().split())
if W <= 0:
    print(0)
elif h == 1:
    print(1)
elif W == 1:
    print(1)
else:
    if h % 2 != 0:
        if W % 2 != 0:
            ans = ((h-1)*W//2)+(W//2+1)
        else:
            ans = (h*W)//2
    else:
        ans = (h*W)//2
    print(ans)

Measured memory_bytes: 3060
using System;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Math;
using static System.Console;
using static exMath;
using static exReadLine;


class Program
{
    static void Main(string[] args)
    {
        int N;
        intReadLine(out N);
        WriteLine(N / 2 + N % 2);
        //ReadLine();
    }
}

static class exReadLine
{
    public static void intReadLine(out int a)
    {
        a = int.Parse(ReadLine());
    }
    public static void intReadLine(out int a, out int b)
    {
        int[] input = ReadLine().Split().Select(int.Parse).ToArray();
        a = input[0];
        b = input[1];
    }
    public static void intReadLine(out int a, out int b, out int c)
    {
        int[] input = ReadLine().Split().Select(int.Parse).ToArray();
        a = input[0];
        b = input[1];
        c = input[2];
    }
    public static void intReadLine(out int a, out int b, out int c, out int d)
    {
        int[] input = ReadLine().Split().Select(int.Parse).ToArray();
        a = input[0];
        b = input[1];
        c = input[2];
        d = input[3];
    }

    public static void longReadLine(out long a)
    {
        a = long.Parse(ReadLine());
    }
    public static void longReadLine(out long a, out long b)
    {
        long[] input = ReadLine().Split().Select(long.Parse).ToArray();
        a = input[0];
        b = input[1];
    }
    public static void longReadLine(out long a, out long b, out long c)
    {
        long[] input = ReadLine().Split().Select(long.Parse).ToArray();
        a = input[0];
        b = input[1];
        c = input[2];
    }
    public static void longReadLine(out long a, out long b, out long c, out long d)
    {
        long[] input = ReadLine().Split().Select(long.Parse).ToArray();
        a = input[0];
        b = input[1];
        c = input[2];
        d = input[3];
    }
    
    public static int[] intArrayReadLine()
    {
        return ReadLine().Split().Select(int.Parse).ToArray();
    }

    public static long[] longArrayReadLine()
    {
        return ReadLine().Split().Select(long.Parse).ToArray();
    }

    public static List<int> intListReadLine()
    {
        return ReadLine().Split().Select(int.Parse).ToList();
    }

    public static List<long> longListReadLine()
    {
        return ReadLine().Split().Select(long.Parse).ToList();
    }
}

static class exMath
{
    // 最大公約数
    public static int Gcd(int a, int b)
    {
        if (a < b) return Gcd(b, a);
        while (b != 0)
        {
            var r = a % b;
            a = b;
            b = r;
        }
        return a;
    }
    public static long Gcd(long a, long b)
    {
        if (a < b) return Gcd(b, a);
        while (b != 0)
        {
            var r = a % b;
            a = b;
            b = r;
        }
        return a;
    }

    // 最小公倍数
    public static long Lcm(int a, int b)
    {
        return BigMul(a, b) / Gcd(a, b);
    }
    public static long Lcm(long a, long b)
    {
        return a * b / Gcd(a, b);
    }
}

Measured memory_bytes: 13140
import java.util.*;
import java.io.*;

public class Main {
    public static void main(String[] args) {
        FastReader sc = new FastReader();
        int t = sc.nextInt();
        double distance = sc.nextDouble();
        int c = 0;
        while (t-- > 0) {
            int a = sc.nextInt();
            int b = sc.nextInt();
            double v = Math.sqrt(Math.pow(a, 2) + Math.pow(b, 2));
            if (v <= distance)
                c++;
        }
        System.out.println(c);
    }

    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }
}

Measured memory_bytes: 55060
// created by mtnshh
 
#include<bits/stdc++.h>
#include<algorithm>
using namespace std;

#define ll long long
#define ld long double
 
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define repb(i,a,b) for(ll i=a;i>=b;i--)
 
#define err() cout<<"=================================="<<endl;
#define errA(A) for(auto i:A)   cout<<i<<" ";cout<<endl;
#define err1(a) cout<<#a<<" "<<a<<endl
#define err2(a,b) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<endl
#define err3(a,b,c) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<" "<<#c<<" "<<c<<endl
#define err4(a,b,c,d) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<" "<<#c<<" "<<c<<" "<<#d<<" "<<d<<endl

#define pb push_back
#define all(A)  A.begin(),A.end()
#define allr(A)    A.rbegin(),A.rend()
#define ft first
#define sd second
 
#define pll pair<ll,ll>
#define V vector<ll>
#define S set<ll>
#define VV vector<V>
#define Vpll vector<pll>
 
#define endl "\n"
 
const ll logN = 20;
const ll M = 1000000007;
const ll INF = 1e12;
#define PI 3.14159265
 
const ll N = 200005;

V adj[N];
ll P[N];

int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    ll n, m;
    cin >> n >> m;
    rep(i,0,m){
        ll u, v;
        cin >> u >> v;
        adj[u].pb(v);
        adj[v].pb(u);
    }
    queue<pll> q;
    q.push({1,0});
    rep(i,1,n+1)    P[i]=-1;
    while(!q.empty()){
        pll p = q.front();
        q.pop();
        if(P[p.ft] != -1)
            continue;
        P[p.ft] = p.sd;    
        for(auto i:adj[p.ft]){
            q.push({i, p.ft});
        }
    }
    bool f = 0;
    rep(i,1,n+1)  if(P[i]==-1)  f=1;
    if(f){
        cout<<"No"<<endl;
    }
    else{
        cout<<"Yes"<<endl;
        rep(i,2,n+1)    cout<<P[i]<<endl;
    }
    return 0;
}

Measured memory_bytes: 19472
S = input()
if S =="++++":
    print(4)
elif S =="----":
    print(-4)
elif S=="+++-" or S=="++-+" or S=="+-++" or S=="-+++":
    print(2)
elif S=="---+" or S=="-+--" or S=="--+-" or S=="+---":
    print(-2)
else:
    print(0)

Measured memory_bytes: 3060
#include "bits/stdc++.h"
using namespace std;
const int MAX = 700000;
const int MOD = 1000000007;

long long  fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 二項係数計算
long long COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
/*第二引数で第一引数を割ったときの切り上げの計算*/
long long int maxtime(long long int x, long long int y){
	return(x + y - 1) / y;

}
/*最大公約数*/
long long int lcm(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;

	if (number2 > number1) {
		m = number2;
		n = number1;
	}
	long long int s = -1;
	while (s != 0) {
		s = m % n;
		m = n;
		n = s;
	}
	return m;
}
/*最大公倍数*/
long long int gcd(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;
	return m / lcm(m, n) * n;
}
/*逆元計算*/
long long int  modinv(long long a, long long m) {
	long long int b = m, u = 1, v = 0;
	while (b) {
		long long int t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
// index が条件を満たすかどうか
vector<long long int >meguru;
bool isOK(int index, int key) {
	if (meguru[index] >= key) return true;
	else return false;
}
// 汎用的な二分探索のテンプレ
int binary_search(int key) {
	int left = -1; //「index = 0」が条件を満たすこともあるので、初期値は -1
	int right = (int)meguru.size(); // 「index = a.size()-1」が条件を満たさないこともあるので、初期値は a.size()
	/* どんな二分探索でもここの書き方を変えずにできる！ */
	while (right - left > 1) {
		int mid = left + (right - left) / 2;

		if (isOK(mid, key)) right = mid;
		else left = mid;
	}
	/* left は条件を満たさない最大の値、right は条件を満たす最小の値になっている */
	return right;
}
long long modpow(long long a, long long n, long long mod) {
	long long res = 1;
	while (n > 0) {
		if (n & 1) res = res * a % mod;
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}
int main() {
	string s;
	cin >> s;
	cout << s[0] << (s.size() - 2) << s[s.size() - 1];
}


Measured memory_bytes: 256
/*input
async layered coding
*/
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<double,double> pdd;
#define IOS ios_base::sync_with_stdio(0); cin.tie(0)
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define F first
#define S second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define pb push_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#ifdef leowang
#define debug(...) do{\
	fprintf(stderr,"%s - %d : (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
	_DO(__VA_ARGS__);\
}while(0)
template<typename I> void _DO(I&&x){cerr<<x<<endl;}
template<typename I,typename...T> void _DO(I&&x,T&&...tail){cerr<<x<<", ";_DO(tail...);}
#else
#define debug(...)
#endif
template<typename T1,typename T2>
ostream& operator<<(ostream& out,pair<T1,T2> P){
	out<<'('<<P.F<<','<<P.S<<')';
	return out;
}
//}}}
const ll maxn=300005;
const ll maxlg=__lg(maxn)+2;
const ll INF64=8000000000000000000LL;
const int INF=0x3f3f3f3f;
const ll MOD=ll(1e9+7);
const double PI=acos(-1);
//const ll p=880301;
//const ll P=31;

ll mypow(ll a,ll b){
	ll res=1LL;
	while(b){
		if(b&1) res=res*a%MOD;
		a=a*a%MOD;
		
		b>>=1;
	}
	return res;
}
int main()
{
	IOS;
	int n;
	cin>>n;
	cout<<"ABC"<<n;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long int ll;
#define rep(i,n) for(int i=0;i<(int)n;i++)
int Min(int a, int b, int c) {
	if (a <= b) { return std::min(a, c); }
	else return std::min(b, c);
}
int main(void) {
	int res = 700;
	string str; cin >> str;
	for (int i = 0; i < str.length(); i++) {
		if (str[i] == 'o')res += 100;
	}
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 256
// insertion sort
package main
import (
	"fmt"
	"os"
	"bufio"
	"strconv"
)

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

func main(){
	sc.Split(bufio.ScanWords)
	defer out.Flush()
	n := nextInt()
	cards := nextInts(n)
	// 初期状態を出力するの忘れてたっぽい
	for i, v := range cards{
		fmt.Fprintf(out, "%d", v)
		if i<n-1{
			fmt.Fprint(out, " ")
		}else{
			fmt.Fprintln(out)
		}
	}
	for i:=1; i<n; i++{
		v, j := cards[i], i-1
		for j>=0 && cards[j]>v{
			cards[j+1]= cards[j]
			j--
		}
		cards[j+1]=v
		for i, v := range cards{
			fmt.Fprintf(out, "%d", v)
			if i<n-1{
				fmt.Fprint(out, " ")
			}else{
				fmt.Fprintln(out)
			}
		}
	}
}

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

func nextInt()int{
	a, _ := strconv.Atoi(next())
	return a
}

func nextInts(n int) []int{
	a := make([]int, n)
	for i:=0; i<n; i++{
		a[i] = nextInt()
	}
	return a
}



Measured memory_bytes: 1212
N = int(input())
S = input()
T = list()
for i in range(int(N / 2), N):
    t = S[i]
    T.append(t)
y = 0
n = 0
for i, k in zip(T, S):
    if i == k:
        y += 1
    else:
        n += 1
if int(N % 2) != 0:
    print('No')
elif y == int(N / 2):
    print('Yes') 
else:
    print('No')          

Measured memory_bytes: 3064
import sys

def GetReadlineData():
    readlinedata= sys.stdin.readline()
    splitdata = [i for i in readlinedata.split()]
    
    return splitdata
            
def CalcShapingData(splitdata):

    calcresult = [0 for i in range(len(splitdata))]

    j = 0
    for i in range(0, len(splitdata)):
        if splitdata[i].isdecimal():
            j = j + 1
            calcresult[j] = int(splitdata[i])
            result = int(splitdata[i])
            #if j == 2:
                #print('{}:{}'.format(j,calcresult[j]))
        else:
            #print(splitdata[i])
            if splitdata[i] == '+':
                result = calcresult[j-1] + calcresult[j]
                #print(calcresult[j-2])
                #print(calcresult[j-1])
                #print(result)
                j = j - 1
            elif splitdata[i] == '-':
                result = calcresult[j-1] - calcresult[j]
                #print(calcresult[j-1])
                #print(calcresult[j])
                #print(result)
                j = j - 1
            elif splitdata[i] == '*':
                result = calcresult[j-1] * calcresult[j]
                #print(calcresult[j-1])
                #print(calcresult[j])
                #print(result)
                j = j - 1
            elif splitdata[i] == '/':
                result = int(calcresult[j-1]) / int(calcresult[j])
                #print(result)
                j = j -1
            
            #calcresult.pop(j-1)
            #calcresult.pop(j)
            #print(j)
            calcresult[j] = result

    for k in range(1,j):
        calcresult.pop(k)

    return result


def main():
    splitdata = GetReadlineData()
    result = CalcShapingData(splitdata)
    print(result)

if __name__ == '__main__':
    main()


Measured memory_bytes: 5616
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <iostream>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <fstream>
#include <numeric>
#include <iomanip>
#include <bitset>
#include <list>
#include <stdexcept>
#include <functional>
#include <utility>
#include <ctime>
#include <random>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;;
#define MEM(a,b) memset((a),(b),sizeof(a))
const LL INF = 1e9 + 7;
const int N = 2e4 + 10;
int flag[N];
bool check(int n)
{
	while (n)
	{
		if (flag[n % 10]) return false;
		n /= 10;
	}
	return true;
}
int main()
{
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	int n, k;
	cin >> n >> k;
	for (int i = 1; i <= k; i++)
	{
		int x;
		cin >> x;
		flag[x] = 1;
	}
	while (!check(n)) n++;
	cout << n << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define all(x) x.begin(),x.end()
#define endl '\n'
#define pb push_back
#define ff first
#define ss second
#define PI 3.1415926535897932384626
#define mod 1000000007
#define modd 998244353

void io() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	#endif
}

int main() {
	io();
	
	int d,t,s;
	cin>>d>>t>>s;
	cout<<(s*t>=d ? "Yes" : "No");
	return 0;
}


Measured memory_bytes: 3688
#include <iostream>

using namespace std;

int main()
{
	int N, K;
	cin >> N >> K;
	string S;
	cin >> S;
	
	// 初期スコアの計算
	int score = 0;
	for (int i = 0; i < N - 1; i++)
	{
		if (S[i] == S[i + 1])
		{
			score++;
		}
	}
	
	// 1回の回転操作で、幸福になる最大値は+2である。
	int answer = min(score + 2 * K, N - 1);
	cout << answer << endl;
	
	return 0;
}

Measured memory_bytes: 512
import sys
input=sys.stdin.readline
n,m=map(int,input().split())
INF=10**9+7
if abs(n-m)>=2:
    print(0)
else:
    if abs(n-m)==1:
        ans=1
        for i in range(n):
            ans=(ans*(i+1))%INF
        for i in range(m):
            ans=(ans*(i+1))%INF
        print(ans)
    else:
        ans=2
        for i in range(n):
            ans=(ans*(i+1))%INF
        for i in range(m):
            ans=(ans*(i+1))%INF
        print(ans)
        



Measured memory_bytes: 38640
n, k = map(int, input().split())
a = list(map(int, input().split()))
mod = 10 ** 9 + 7
count = 0
for i in range(n):
    for j in range(i + 1, n):
        if a[i] > a[j]:
            count += 1
ans = k * (k + 1) // 2 * count % mod
count2 = 0
for i in range(n):
    for j in range(0, i):
        if a[i] > a[j]:
            count2 += 1
ans += k * (k - 1) // 2 * count2 % mod
print(ans % mod)

Measured memory_bytes: 3188
#abc091_b
import collections
N = int(input())
S = [input() for i in range(N)]
M = int(input())
T = [input() for i in range(M)]
S_c = collections.Counter(S)
T_c = collections.Counter(T)
ans = 0

for s_word,s_count in S_c.items():
    if ans < s_count-T_c[s_word]:
        ans = s_count-T_c[s_word]

print(max(ans,0))

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

using namespace std;
using ll = long long;

string s;
ll N, Q;
vector<char> t(200000);
vector<char> d(200000);

int simulation(int pos){
  for (int i = 0; i < Q; ++i) {
    if (pos==0)
      return -1;
    if(pos==N+1)
      return 1;
    
    if(s[pos-1]==t[i]){
      if(d[i]=='R')
        pos++;
      else
        pos--;
    }
  }

  if (pos==0)
    return -1;
  if(pos==N+1)
    return 1;
  return 0;
}

int main() {
  cin >> N >> Q;
  cin >> s;
  for (int i = 0; i < Q; ++i) {
    cin >> t[i] >> d[i];
  }
  
  int L1=0, R1=N+1, M1, maxn=0;
  while(L1+1<R1) {
    M1=(L1+R1)/2;
    int a = simulation(M1);
    if(a==-1) {
      maxn = max(maxn, M1);
      L1=M1;
    } else{
      R1=M1;
    }
  }
  int L2=0, R2=N+1, M2, minn=N+1;
  while(L2+1<R2) {
    M2=(L2+R2)/2;
    int a = simulation(M2);
    if(a==1) {
      minn = min(minn, M2);
      R2=M2;
    } else{
      L2=M2;
    }
  }

  cout << minn-maxn-1 << endl;
}


Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>
using namespace std;
int main(){
    int A,B,C;
    cin>>A>>B>>C;
    int K;
    cin>>K;
    for(int i=1;i<=K;i++){
        if(A<=B&&C<=B){
            B=B*2;
        }else if(B<=A&&C<=A){
            A=A*2;
        }else if(A<=C&&B<=C){
            C=C*2;
        }
    }
   cout<<A+B+C<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
int x,y,a[20]={0,1,2,1,3,1,3,1,1,3,1,3,1};
int main ()
{
	scanf ("%d %d",&x,&y);
	printf ("%s\n",a[x]==a[y]?"Yes":"No");
	return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
long long LOG = 61;
vector<int> dy = {-1, 0, 1, 0};
vector<int> dx = {0, 1, 0, -1};
int main(){
  while (1){
    int H, W;
    long long L;
    cin >> H >> W >> L;
    if (H == 0 && W == 0 && L == 0){
      break;
    }
    vector<vector<char>> c(H + 2, vector<char>(W + 2, '#'));
    for (int i = 1; i <= H; i++){
      for (int j = 1; j <= W; j++){
        cin >> c[i][j];
      }
    }
    int s;
    for (int i = 1; i <= H; i++){
      for (int j = 1; j <= W; j++){
        if (c[i][j] != '.' && c[i][j] != '#'){
          s = ((i - 1) * W + (j - 1)) * 4;
          if (c[i][j] == 'E'){
            s++;
          }
          if (c[i][j] == 'S'){
            s += 2;
          }
          if (c[i][j] == 'W'){
            s += 3;
          }
          c[i][j] = '.';
        }
      }
    }
    vector<int> next(H * W * 4, -1);
    for (int i = 1; i <= H; i++){
      for (int j = 1; j <= W; j++){
        for (int k = 0; k < 4; k++){
          int v = ((i - 1) * W + (j - 1)) * 4 + k;
          if (c[i + dy[k]][j + dx[k]] == '.'){
            next[v] = ((i + dy[k] - 1) * W + (j + dx[k] - 1)) * 4 + k;
          } else {
            for (int l = 0; l < 4; l++){
              if (c[i + dy[(k + l) % 4]][j + dx[(k + l) % 4]] == '.'){
                next[v] = ((i + dy[(k + l) % 4] - 1) * W + (j + dx[(k + l) % 4] - 1)) * 4 + (k + l) % 4;
                break;
              }
            }
          }
        }
      }
    }
    vector<vector<int>> p(LOG, vector<int>(H * W * 4, -1));
    for (int i = 0; i < H * W * 4; i++){
      p[0][i] = next[i];
    }
    for (int i = 1; i < LOG; i++){
      for (int j = 0; j < H * W * 4; j++){
        if (p[i - 1][j] != -1){
          p[i][j] = p[i - 1][p[i - 1][j]];
        }
      }
    }
    for (int i = 0; i < LOG; i++){
      if (L >> i & 1){
        s = p[i][s];
      }
    }
    int y = s / 4 / W + 1;
    int x = s / 4 % W + 1;
    char d;
    if (s % 4 == 0){
      d = 'N';
    }
    if (s % 4 == 1){
      d = 'E';
    }
    if (s % 4 == 2){
      d = 'S';
    }
    if (s % 4 == 3){
      d = 'W';
    }
    cout << y << ' ' << x << ' ' << d << endl;
  }
}


Measured memory_bytes: 13192
A1 = [0] * 3
A2 = [0] * 3
A3 = [0] * 3
for i in range(3):
    A1[i], A2[i], A3[i] = map(int, input().split())

N = int(input())
b = []
for _ in range(N):
    b.append(int(input()))

for i in b:
    for j in range(3):
        if A1[j] == i:
            A1[j] = 'ok'
        elif A2[j] == i:
            A2[j] = 'ok'
        elif A3[j] == i:
            A3[j] = 'ok'


if A1[0] == A1[1] == A1[2]:
    print('Yes')

elif A2[0] == A2[1] == A2[2]:
    print('Yes')

elif A3[0] == A3[1] == A3[2]:
    print('Yes')

elif A1[0] == A2[1] == A3[2]:
    print('Yes')

elif A3[0] == A2[1] == A1[2]:
    print('Yes')

elif A1[0] == A2[0] == A3[0]:
    print('Yes')

elif A1[1] == A2[1] == A3[1]:
    print('Yes')

elif A1[2] == A2[2] == A3[2]:
    print('Yes')
    
else:
    print('No')

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define ull unsigned long long
# define ll long long
# define mod 1000000007LL 
using namespace std;
int main()
{
     ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    map<string,int>ans;
    ll num=7;
    ans["SUN"]=7;
    ans["MON"]=6;
    ans["TUE"]=5;
    ans["WED"]=4;
    ans["THU"]=3;
    ans["FRI"]=2;
    ans["SAT"]=1;
    string s;
    cin>>s;
    cout<<ans[s];



    
    return 0;
}

Measured memory_bytes: 3536