akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <set>
#include <string>
#include <vector>
using namespace std;
int main(){
    int n; cin >> n;
    set<string> st;
    vector<string> vec;
    for(int i=0; i < n; ++i){
        string w; cin >> w;
        if(st.count(w) == 1){
            puts("No");
            return 0;
        }
        if(vec.size() != 0){
            string s = vec[vec.size()-1];
            if(s[s.size()-1] != w[0]){
                puts("No");
                return 0;
            }
        }
        st.insert(w); vec.push_back(w);
    }
    puts("Yes");
    return 0;
}

Measured memory_bytes: 3620
#include <stdio.h>

int main(void) {
	// your code goes here
	
	    
    int X,A;
    
    scanf("%d",&X);
    scanf("%d",&A);
    
    if(X<A){
        printf("%d\n",0);
        
    }
    else{
        printf("%d\n",10);
        
        
    }
	
	
	return 0;
}



Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define INF (1LL<<50)
#define MOD 1000000007

int main(){
    string S;
    cin >> S;
    int K;
    cin >> K;
    // "a"~"zzzzz"まで
    set<string> st;
    for(int i=0;i<S.size();i++){
        for(int j=1;j<=K;j++){
            if(i+j>S.size()) break;
            st.insert(S.substr(i,j));
        }
    }
    auto itr = st.begin();
    rep(i,K-1){
        itr++;
    }
    cout << *itr << endl;
    return 0;
}

Measured memory_bytes: 1664
class Combination:
    def __init__(self, n_max, mod=10 ** 9 + 7):
        # O(n_max + log(mod))
        self.mod = mod
        f = 1
        self.fac = fac = [f]
        for i in range(1, n_max + 1):
            f = f * i % mod
            fac.append(f)
        f = pow(f, mod - 2, mod)
        self.facinv = facinv = [f]
        for i in range(n_max, 0, -1):
            f = f * i % mod
            facinv.append(f)
        facinv.reverse()

    # "n 要素" は区別できる n 要素
    # "k グループ" はちょうど k グループ

    def __call__(self, n, r):  # self.C と同じ
        return self.fac[n] * self.facinv[r] % self.mod * self.facinv[n - r] % self.mod

    def nCr(self, n, r):
        if not 0 <= r <= n:
            return 0
        return self.fac[n] * self.facinv[r] % self.mod * self.facinv[n - r] % self.mod

def resolve():
    def f(r, c):
        return cmb.nCr(r+c+2, r+1) - 1

    MOD = 10**9+7
    r1,c1,r2,c2 = map(int, input().split())
    r1 -= 1
    c1 -= 1

    cmb = Combination(r2+c2+5)
    ans = f(r2, c2)
    ans -= f(r1, c2)
    ans -= f(r2, c1)
    ans += f(r1, c1)
    print(ans % MOD)


if __name__ == "__main__":
    resolve()

Measured memory_bytes: 167264
#include <bits/stdc++.h>
typedef long long int ll;
using namespace std;
int main(){
	ios_base::sync_with_stdio(false);  
	cin.tie(NULL);
	ll n,m;cin>>n>>m;
	ll ans=0;
	ans += n*(n-1)/2;
	ans += m*(m-1)/2;
	cout<<ans<<endl;
} 

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

int main() {
	int n;
	cin >> n;
	int a[105];
	for (int i = 0; i < n-1; i++) {
		cin >> a[i];
	}
	long long int ans = 0;
	for (int i = 0; i < n - 2; i++) {
		ans += min(a[i], a[i + 1]);
	}
	ans = ans + a[0] + a[n - 2];
	cout << ans;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <vector>

using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define reps(i, f, n) for (ll i = (f); i < (n); i++)
#define repv(v) for (auto it = (v).begin(); it != (v).end(); it++)
ll const INF = 1LL << 60;
ll const MAX_N = 510000;
ll const MOD = 1000000007;
ll const MAX_V = 200000;

struct edge {
    ll to, cost;
};
vector<edge> G[MAX_V];

int main() {
    ll N, M;
    cin >> N >> M;

    N--;

    for (ll i = 0; i < M; i++) {
        // sからtへの辺を張る
        ll s, t;
        cin >> s >> t;
        s--;
        t--;

        edge et = {t, 1};
        G[s].push_back(et);

        // 無向グラフの場合はさらにtにsへの辺を張る
        edge es = {s, 1};
        G[t].push_back(es);
    }

    for (ll i = 0; i < G[0].size(); i++) {
        vector<edge> n1 = G[G[0][i].to];
        // cout << G[0][i].to << endl;

        for (ll j = 0; j < n1.size(); j++) {
            // cout << n1[j].to << endl;
            if (G[G[0][i].to][j].to == N) {
                cout << "POSSIBLE" << endl;
                return 0;
            }
        }
    }

    cout << "IMPOSSIBLE" << endl;

    return 0;
}


Measured memory_bytes: 18704
#include <bits/stdc++.h>
using namespace std;
#define COUT(x) cout<<(x)<<endl
typedef long long ll;
template<class T> inline void chmax(T& a, T b) {
  if (a < b) a = b;
}

template<class T> inline void chmin(T& a, T b) {
  if (a > b) a = b;
}
const int MOD = 1000000007;
const long long INF = 1LL << 60;

int main() {
  int k;
  string s;
  cin >> k >> s;
  string r = s.substr(0,k) + "...";
  if (k >= s.size()) COUT(s);
  else cout << r << endl;
}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
   using namespace std;
   using pii = pair<int, int>;
   using ll = long long;
   #define rep(i, j, n) for(int i = j; i < (int)(n); i++)
   const ll MOD = 1000000007;
   const ll INFL = (1LL << 60);
   const int INFI = (1 << 30);

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

     vector<ll> A(N + 1);
     map<ll, ll> sumAi, gapAi;
     for (ll i = 1;i < N + 1; i++) {
       cin >> A.at(i);
       sumAi[i + A.at(i)]++;
       gapAi[i - A.at(i)]++;
     }

     ll ans = 0;

     for (auto p: sumAi) {
       ans += p.second * gapAi[p.first];
     }

     cout << ans << endl;
   }


Measured memory_bytes: 38996
import java.io.*;
import java.util.*;
class Main{
  public static void main(String []args){
    Scanner cin=new Scanner(System.in);
    int j=0,n=cin.nextInt();
    cin.nextLine();
    for(;j<n;j++){
    String s=cin.nextLine();
    Set<String> m=new HashSet<String>();
    int i=1;
    for(;i<s.length();i++){
      String s1=s.substring(0,i),s2=s.substring(i),r1=new StringBuilder(s1).reverse().toString(),r2=new StringBuilder(s2).reverse().toString();
      m.add(s1+s2);
      m.add(r1+s2);
      m.add(s1+r2);
      m.add(r1+r2);
      m.add(s2+s1);
      m.add(r2+s1);
      m.add(s2+r1);
      m.add(r2+r1);
    }
    System.out.println(m.size());
    }
  }
}

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

int main() {
  ll a,b,c,k;
  cin >> a >>b >>c >>k;
  int xa = min(a,k);
  k -= xa;
  int xb = min(b,k);
  k -= xb;
  int xc = k;
  int ans = xa - xc;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using Pair = pair<int, int>;
using Vec = vector<int>;
using Graph = vector<Vec>;

int		main(void)
{
	int n, m;
	cin >> n >> m;
	priority_queue<int> a;
	for (int i = 0; i < n; i++)
	{
		int tmp;
		cin >> tmp;
		a.push(tmp);
	}
	for (int i = 0; i < m; i++)
	{
		int tmp = a.top();
		a.pop();
		a.push(tmp / 2);
	}
	ll sum = 0;
	for (int i = 0; i < n; i++)
	{
		sum+=a.top();
		a.pop();
	}
	cout << sum << endl;
}


Measured memory_bytes: 892
#include <iostream>
#include <algorithm>
#include <vector>
#include <tuple>
using namespace std;

int main(){
    int k=1;
    vector<int> V;
    int A,B,K;
    cin>>A>>B>>K;
    for(int k=1;k<=min(A,B);k++){
        if(A%k==0&&B%k==0) V.push_back(k);
    }
    reverse(V.begin(), V.end());
    cout<<V[K-1]<<endl;
    return 0;
}

Measured memory_bytes: 256
from sys import stdin

[X] = [int(x) for x in stdin.readline().rstrip().split()]

s = {}

for i in range(100000):
    r = i * i * i * i * i
    s[r] = i

for i in range(100000):
    r = i * i * i * i * i
    if X < r:
        if not (r - X) in s:
            continue
        print(str(i) + " " + str(s[r - X]))
        break
    else:
        if not (X - r) in s:
            continue
        print(str(i) + " " + str(-s[X - r]))
        break
        

Measured memory_bytes: 85492
#include<bits/stdc++.h>
#define For(i, a, b)  for(int i = a, _b = b; i <= _b; ++i)
#define Ford(i, a, b) for(int i = a, _b = b; i >= _b; --i)
#define FileName      "test"
#define ll            long long
#define ld            long double
#define ull           unsigned long long
#define Print(x)      cerr << #x << "is " << x << '\n';
#define pb            push_back
#define X             first
#define Y             second
//#define Karma

using namespace std;

template<typename T> inline void Cin(T &x)
{
    char c;
    T sign = 1;
    x = 0;
    for (c = getchar(); c < '0' || c > '9'; c = getchar())
        if (c == '-') sign = -1;
    for (; c >= '0' && c <= '9'; c = getchar())
        x = x * 10 + c - '0';
    x *= sign;
}
template <typename T> inline void Out(T x) {if(x > 9) Out(x / 10); putchar(x % 10 + '0');}
template <typename T> inline void Cout(T x, char c) {if(x < 0) putchar('-'); x = abs(x); Out(x); putchar(c);}
template <typename T, typename... Args> inline void Cin(T& a, Args&... args) {Cin(a);Cin(args...);}
template <typename T, typename... Args> inline void Cout(T a, char c, Args... args) {Cout(a, c);Cout(args...);}

typedef pair<int, int> pii;
typedef pair<ll, int> plli;
const int N = 3e3 + 7;

ld f[N][N], c[N];
int n;

void Enter()
{
     cin >> n;
     For(i, 1, n)
     {
         cin >> c[i];
         For(j, 0, n) f[i][j] = 0;
     }
}

void Solve()
{
     f[1][1] = c[1];
     f[1][0] = 1 - c[1];
     For(i, 2, n)
     {
         For(j, 0, i)
         {
             f[i][j] += f[i - 1][j - 1] * c[i];
             f[i][j] += f[i - 1][j] * (1 - c[i]);
         }
     }
     ld res = 0;
     For(j, 0, n) if(j * 2 > n) res += f[n][j];
     cout << fixed << setprecision(9);
     cout << res;
}

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
#ifdef Karma
    freopen(FileName".inp", "r", stdin);
    freopen(FileName".out", "w", stdout);
#endif // Karma

    Enter();
    Solve();

    return 0;
}


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

int main(){
  int n;
  double a[104];
  double sum = 0;
  int i;

  scanf("%d", &n);

  for(i = 0;i < n;i++){
    scanf("%lf", &a[i]);
    sum += 1.0/a[i];
  }

  printf("%f\n", 1.0/sum);
  return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define SZ(x) ((int)x.size())
#define L(i,u) for (register int i=head[u]; i; i=nxt[i])
#define rep(i,a,b) for (register int i=a; i<=b; i++)
#define per(i,a,b) for (register int i=a; i>=b; i--)
using namespace std;
typedef long long ll;
typedef unsigned int ui;
typedef pair<int,int> Pii;
typedef vector<int> Vi;
inline void read(ll &x) {
	x=0; char c=getchar(); int f=1;
	while (!isdigit(c)) {if (c=='-') f=-1; c=getchar();}
	while (isdigit(c)) {x=x*10+c-'0'; c=getchar();} x*=f;
}
inline ui R() {
	static ui seed=416;
	return seed^=seed>>5,seed^=seed<<17,seed^=seed>>13;
}
ll n,k,res;
int main() {
	read(n);read(k);
	ll a=n/k;if(k%2==0){ll b=(n+k/2)/k;res+=b*b*b;}
	res+=a*a*a;cout<<res;
	return 0;
}

Measured memory_bytes: 256
def factorization(n):
  arr = []
  temp = n
  for i in range(2, int(-(-n**0.5//1))+1):
    if temp%i==0:
      cnt=0
      while temp%i==0:
        cnt+=1
        temp //= i
      arr.append([i, cnt])

  if temp!=1:
    arr.append([temp, 1])

  return arr

arr = factorization(int(input()))

ans = 0
for p in arr:
  i = 1
  while p[1] >= i:
    ans += 1
    p[1] -= i
    i += 1
    
print(ans)

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

#define ll long long
#define fornum(A,B,C) for(A=B;A<C;++A)
#define pii pair<int,int>
#define pll pair<ll,ll>

using namespace std;

/////////////////////////////////////////////////////
#define INF (ll)1e18

ll A;
char B[10];
ll A2, B2;

ll i, j, k;

int main(){
    scanf("%lld%s", &A,B);
    B2 = 0;
    j = 0;
    for (i = 0; B[i];++i){
        if(B[i]=='.'){
            j = 1;
        }else{
            B2 *= 10;
            B2 += B[i] - '0';
            j *= 10;
        }
    }
    if(j==0)
        j = 1;
    ll k = A * B2;
    printf("%lld\n", k/j);
    return 0;
}

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

int main() {
	unsigned long long n;
	cin >> n;
	unsigned long long a = 0;
	bool all9 = true;
	while(n >= 10) {
		unsigned int d = n % 10;
		if(d != 9) all9 = false;
		n /= 10;
		a += 9;
	}
	if(!all9) n--;
	a += n;
	cout << a << endl;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<map>
#include<stack>
#include<cmath>
#include<iomanip>
#include<set>
#include<numeric>
#include<sstream>
#include<random>
#include<cassert>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rrep(i, st, n) for (int i = st; i < n; ++i)
using pii = pair<int, int>;
const int inf = 1e9 + 7;
int dy[] = {0, 0, -1, 1, -1, 1, -1, 1};
int dx[] = {1, -1, 0, 0, -1, 1, 1, -1};
#define ceil(a, b) a / b + !!(a % b)

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, m; cin >> n >> m;
    int s[n + 2]; s[0] = s[1] =  0; rrep(i, 2, n + 1) cin >> s[i];
    rrep(i, 2, n + 1) s[i] += s[i - 1];
    int now = 1;
    int ans = 0;
    rep(i, m) {
        int a; cin >> a;
        ans += abs(s[now + a] - s[now]); ans %= (int)1e5;
        now += a;
        //cout << now << endl;
    }
    cout << ans << endl;
}




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

using namespace std;
typedef long long ll;

int main(){
    int N; cin >> N;
    vector<int> a(N);

    int ct = 0;

    for (int i = 0; i < N; i++)
    {
        cin >> a[i];
    }
    
    for (int i = 0; i < N; i++)
    {
        int minv = 110;
        int minid = -1;
        for (int j = i; j < N; j++)
        {
            if (a[j] < minv)
            {
                minv = a[j];
                minid = j;
            }
            
        }

        if (i != minid)
        {
            int tmp = a[i];
            a[i] = a[minid];
            a[minid] = tmp;
            ct++;
        }
    }

    cout << a[0];
    for (int i = 1; i < N; i++)
    {
        cout << " " << a[i];
    }
    cout << endl;
    cout << ct << endl;

}


Measured memory_bytes: 3088
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
typedef long long int ll;

int main()
{

	ios_base:: sync_with_stdio(false); cin.tie(0);
	ll n; cin>>n;
	if(n%2==1) {
		cout<<0<<endl;
	}
	else{
		n/=2;
		//cout<<n<<endl;
		ll count = 0;
		ll cnt=n;
		for (ll i = 5; n / i >= 1; i *= 5) {
			count += n / i;
		}
		for (ll i = 2; n / i >= 1; i *= 2) {
			cnt += n / i;
		}
		ll ans=min(cnt,count);
		cout<<ans<<endl;

	}

	return 0;
}


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

typedef long long llint;
typedef long double ld;

#define inf 1e18
#define mod 1000000007
priority_queue<llint,vector<llint>,greater<llint> > que;
priority_queue<llint> Que;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }


int A,B;

void input(){
  cin >> A >> B;
}

void solve(){
  input();
  cout << (A+B-3)/(A-1) << endl;

}

int main(){
  solve();
  return 0;
}


Measured memory_bytes: 256
/*Function Template*/
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> pint;
const int MAX = 510000;
const int MOD = 1000000007;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define Rep(i, n) for(ll i = 1; i < (n); i++)
#define ALL(a)  (a).begin(),(a).end()
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
ll fac[MAX], finv[MAX], inv[MAX];


template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll 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;
    }

}
ll Len(ll n) {
  ll s=0;
  while(n!=0) s++, n/=10;
  return s;
}


ll Sint(ll n) {
  ll m=0,s=0,a=n;
  while(a!=0) s++, a/=10;
  for(ll i=s-1;i>=0;i--) m+=n/((ll)pow(10,i))-(n/((ll)pow(10,i+1)))*10;
  return m;
}


ll Svec(vector<ll> v){
  ll n=0;
  for(ll i=0;i<v.size();i++) n+=v[i];
  return n;
}


ll GCD(ll a,ll b) {
  return b ? GCD(b,a%b) : a;
}


ll LCM(ll a,ll b){
  return a/GCD(a,b)*b;
}


ll Factorial(ll n){
  ll m=1;
  while(n>=1) m*=n,n--;
  return m;
}

void runlength(string s,vector<pair<char,ll>> &p){
  ll x=1;
  if(s.size()==1){
    p.push_back(pair<char,ll>(s[0],1));
  }
  for(ll i=0;i<s.size()-1;i++){
    if(s[i]==s[i+1]){
      x++;
      if(i==s.size()-2){
        p.push_back(pair<char,ll>(s[i],x));
      }
    }else{
      p.push_back(pair<char,ll>(s[i],x));
      x=1;
      if(i==s.size()-2){
        p.push_back(pair<char,ll>(s[s.size()-1],x));
      }
    }
  }
}




ll COM(ll n,ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

const int MAX_N=100010;
vector<bool> sieve_of_eratosthenes(){
  vector<bool> isPrime(MAX_N+1,true);
  for(int i=2;i<=MAX_N;i++){
    if(isPrime[i]){
      for(int j=2*i;j<=MAX_N;j+=i){
        isPrime[j]=false;
      }
    }
  }
  return isPrime;
}

vector<pint> prime_factorize(ll n){
  vector<pint> ans;
  for(ll p=2;p<=sqrt(n);p++){
    if(n%p!=0) continue;
    ll cnt=0;
    while(n%p==0){
      n/=p;
      cnt++;
    }
    ans.push_back(make_pair(p,cnt));
  }
  if(n!=1) ans.push_back(make_pair(n,1));
  return ans;
}

/*↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓*/
int main() {
  IOS;
  ll h,n;
  cin>>h>>n;
  vector<ll> w(n),v(n);
  rep(i,n) cin>>w[i]>>v[i];
  ll dp[h+1];
  rep(i,h+1) dp[i]=1e11;
  dp[0]=0;
  rep(i,n) rep(j,h+1){
    dp[min(j+w[i],h)]=min(dp[min(j+w[i],h)],dp[j]+v[i]);
  }
  
  cout<<dp[h]<<endl;
  
}

Measured memory_bytes: 384
<?php
/*
    Problem URL : https://beta.atcoder.jp/contests/abc068/tasks/abc068_a

    Score  :
    Result :
    Time   : ms
    Memory : KB
 */

// define('DEBUG', true);
define('DEBUG', false);

ini_set('error_reporting', E_ALL & ~E_NOTICE);

fscanf(STDIN, "%s", $N);

printf("ABC%s\n", $N);


Measured memory_bytes: 4604
import java.util.Scanner;
class Main{
 public static void main(String[] args){
  String s;
  int i,g;
  Scanner sc = new Scanner(System.in);
  while(true){
   s=sc.next();
   if(s.equals("0"))break;
   g=0;
   for(i=0;i<s.length();i++)
    g+=s.charAt(i)-48;
   System.out.println(g);
  }
 }
}


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

int main() {
    int k,a,b;
    cin >> k >> a >> b;
    for (;a <= b; ++a) {
        if (a % k == 0) {
            cout << "OK";
            return 0;
        }
    }
    cout << "NG";
}


Measured memory_bytes: 3624
from math import pi
from cmath import rect

A, B, H, M = map(int, input().split())

thetaA = (H / 12) + (M / 60) * (1 / 12)
thetaB = (M / 60)

thetaA *= 2 * pi
thetaB *= 2 * pi

P = rect(A, thetaA)
Q = rect(B, thetaB)

print(abs(P - Q))


Measured memory_bytes: 9576
#pragma GCC optimize("O3")
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("unroll-loops")
#include<bits/stdc++.h>
#include<vector>
#include<string>
#include<map>
#include<set>
#include<algorithm>
#include<cmath>
#include<iterator>
#define ll long long
#define mod 1000000007
using namespace std;
int main()
{
	ios::sync_with_stdio(0);
	cin.tie(NULL);
	cout.tie(NULL);
	int n,m;
	cin>>n>>m;
	int i,j;
	int A[n][m];
	for(i=0; i<n; i++)
	{
		for(j=0; j<m; j++)
		{
			char ch;
			cin>>ch;
			if(ch=='.')
			{
				A[i][j]=0;
			}
			else
			{
				A[i][j]=1;
			}
		}
	}
	ll dp[n][m];
	for(i=0; i<n; i++)
	{
		for(j=0; j<m; j++)
		{
			dp[i][j]=0;
		}
	}
	for(j=1; j<m; j++)
	{
		if(A[0][j]==0)
		{
			dp[0][j]=1;
		}
		else
		{
			break;
		}
	}
	for(i=1; i<n; i++)
	{
		if(A[i][0]==0)
		{
			dp[i][0]=1;
		}
		else
		{
			break;
		}
	}
	for(i=1; i<n; i++)
	{
		for(j=1; j<m; j++)
		{
			if(A[i][j]==0)
			{
				if((i-1)>=0)
				{
					dp[i][j]=(dp[i][j]+dp[i-1][j])%mod;
				}
				if((j-1)>=0)
				{
					dp[i][j]=(dp[i][j]+dp[i][j-1])%mod;
				}
			}
		}
	}
	/*for(i=0; i<n; i++)
	{
		for(j=0; j<m; j++)
		{
			cout<<A[i][j]<<" ";
		}
		cout<<endl;
	}
	for(i=0; i<n; i++)
	{
		for(j=0; j<m; j++)
		{
			cout<<dp[i][j]<<" ";
		}
		cout<<endl;
	}*/
	cout<<dp[n-1][m-1]%mod<<"\n";
	return 0;
}


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

int main(){
  int n, m, X, Y;
  cin >> n >> m >> X >> Y;
  vector<int> x(n);
  vector<int> y(m);
  for (int i=0 ; i<n ; i++)
    cin >> x.at(i);
  for (int i=0 ; i<m ; i++)
    cin >> y.at(i);
  
  sort(x.begin(), x.end());
  sort(y.begin(), y.end());
  
  if (max(x.at(n-1), X) < min(y.at(0), Y))
    cout << "No War" << endl;
  else
    cout << "War" << endl;
}

Measured memory_bytes: 3600
import java.util.*;
public class Main {
	static Scanner sc = new Scanner(System.in);
	static int h, m, s;
	public static void main(String[] args) {
		while(read()){
			solve();
		}
	}
	static boolean read(){
		h = sc.nextInt();
		m = sc.nextInt();
		s = sc.nextInt();
		if( h == -1 && m == -1 && s == -1)return false;
		return true;
	}
	static void solve(){
		int time = h*3600 + m*60 + s;
		int res = 7200 - time;
		int res3 = 7200*3 - time*3;
		System.out.printf("%02d:%02d:%02d\n", res/3600, (res%3600)/60, res%60);
		System.out.printf("%02d:%02d:%02d\n", res3/3600, res3%3600/60, res3%60);
	}
}

Measured memory_bytes: 0
N,M=map(int,input().split())
KA=[]
food=[N]*M
for i in range(N):
    KA.append(list(map(int,input().split())))
for i in range(N):
    for j in range(len(KA[i])-1):
        food[KA[i][j+1]-1]-=1
print(food.count(0))

Measured memory_bytes: 9048
#include <bits/stdc++.h>
using namespace std;
int main(){
  int A,B,C;
  cin >> A >> B >> C;
  if (A==5 && B==5 && C==7 || A==5 && B==7 && C==5 || A==7 && B==5 && C==5){
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
}

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

using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
using vvl = vector<vl>;
using pll = pair<ll, ll>;
using vpll = vector<pll>;
using vb = vector<bool>;
using vs = vector<string>;
const ll oo = 0x3f3f3f3f3f3f3f3fLL;
const ld eps = 1e-9;
#define sz(c) ll((c).size())
#define all(c) begin(c),end(c)
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define xx first
#define yy second
#define FOR(i, a, b) for (ll i=(a); i<(b);i++)
#define FORD(i, a, b) for (ll i=ll(b)-1; i>=(a); i--)
#define TR(X) ({ if(1) cerr << "TR: " << (#X) << " = " << (X) << endl; })

ll weights[101] = {0};
ll values[101] = {0};
ll dp[105][100005] = {};
ll n, w;

ll minWeightToReachValue(ll item, ll value) {
	if (value == 0) {
		return 0;
	}
	if (value < 0) {
		return oo;
	}
	if (item > n) {
		return oo;
	}
	if (dp[item][value] != -1) {
		return dp[item][value];
	}
	ll res;

	res = min(minWeightToReachValue(item + 1, value - values[item]) + weights[item],
			  minWeightToReachValue(item + 1, value));

	dp[item][value] = res;
	return res;
}

int main() {
	cin.sync_with_stdio(0);

	fill(&dp[0][0], &dp[0][0] + sizeof(dp) / sizeof(dp[0][0]), -1);

	cin >> n >> w;

	FOR(i, 1, n + 1) {
		ll tw, tv;
		cin >> weights[i] >> values[i];
	}

	FORD(i, 0, 100002) {
		if (minWeightToReachValue(1, i) <= w) {
			cout << i;
			break;
		}
	}
}

Measured memory_bytes: 82304
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
#include <functional>
#include <stack>
#include <iomanip>
#include <limits>
using namespace std;
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
using Graph=vector<vector<int>>;
using edge= struct{int to;ll cost;};
template<class t,class u> void chmax(t&a,u b){if(a<b)a=b;}
template<class t,class u> void chmin(t&a,u b){if(b<a)a=b;}
typedef priority_queue<ll> PQ_HIGH;
typedef priority_queue<ll,VL,greater<ll>> PQ_LOW;//昇順

int main(){
  int n,k;cin>>n>>k;
  VI p(n);REP(i,n){cin>>p[i];}
  sort(p.begin(),p.end());
  ll sum=0;
  for(int i=0;i<k;i++){
    sum+=p[i];
  }
  cout<<sum<<endl;
}


Measured memory_bytes: 3192
N=int(input())
L = list(map(int, input().split()))
count=0
L=sorted(L)
for i in range(len(L)):
    for j in range(i+1,len(L)):
        for k in range(j+1,len(L)):
            if L[i] != L[j] and L[j] != L[k] and L[i] != L[k]:
                if L[i]+L[j]>L[k]:
                    count+=1
print(count)

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

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

int main(){
    string s;
    cin >> s;
    if(s=="ABC"){
        cout << "ARC" << endl;
    }else{
        cout << "ABC" << endl;
    }
}

Measured memory_bytes: 3624
#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>
#include <set>
#include <vector>
#include <map>
#include <list>
#include <stack>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <queue>
#define mkp make_pair
#define fi first
#define se second
#define pt(num) cout << num << "\n"
#define max(a, b) ((a)>(b) ? (a):(b))
#define min(a, b) ((a)<(b) ? (a):(b))
#define chmax(a, b) (a<b ? a=b : 0)
#define chmin(a, b) (a>b ? a=b : 0)
#define INF 1000000000000000000
#define MOD 1000000007LL
#define MAX 100010
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef map<ll, ll> Map;



int main(void) {
    ll N;
    cin >> N;
    string s;
    cin >> s;
    ll i, p;
    ll l[26]={}, r[26]={};
    
    for(i=0; i<s.size(); i++) {
        r[s[i]-'a']++;
    }
    
    ll ans=0;
    for(i=0; i<s.size(); i++) {
        ll t=0;
        for(p=0; p<26; p++) {
            if(l[p]>0 && r[p]>0) t++;
        }
        
        ans=max(ans, t);
        
        l[s[i]-'a']++;
        r[s[i]-'a']--;
    }
    
    pt(ans);
    
}

























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

int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i,n) cin >> a.at(i);
  sort(a.begin(),a.end());
  int ptr = 0;
  int res=0;
  while(ptr<n){
    int cc =a[ptr];
    int f=0;
    while(ptr<n && a[ptr] == cc) f++,ptr++;
    res += f%2;
  }

  cout << res << endl;
  return 0;
}


Measured memory_bytes: 640
import math

N, K = map(int, input().split())
logs = list(map(int, input().split()))

ng_len = 0
ok_len = 1000000000


def possible_len(length: int, log: list, k: int):
    count = 0
    for i in range(N):
        count += math.ceil(log[i] / length) - 1
    if count <= k:
        return True
    else:
        return False


while ok_len - ng_len > 1:
    mid = (ng_len + ok_len) // 2
    if possible_len(mid, logs, K):
        ok_len = mid
    else:
        ng_len = mid

print(ok_len)


Measured memory_bytes: 31232
/*
   Created by Rahul Goel.
*/
/*******************************************************************************/
#include <iostream>
#include <vector>
#include <cstring>
#include <string>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <cmath>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
/*******************************************************************************/
using namespace std;
using ll = long long;
using ld = long double;
ll mod = 1000000007;
const int INF = 1e9;
const ll LINF = 1e18;
/*******************************************************************************/
/*
.-.. . -. -.- .- / .. ... / .-.. --- ...- . -.-.--
 */
/* For PBDS */
/*Two new methods X.order_of_key() and X.find_by_order()*/
/*
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template<typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
*/

/*******************************************************************************/
ll mod_sum() { return 0LL; }
template<typename T, typename... Args>
T mod_sum(T a, Args... args) { return ((a + mod_sum(args...))%mod + mod)%mod; }

ll mod_prod() { return 1LL; }
template<typename T, typename... Args>
T mod_prod(T a, Args... args) { return (a*mod_prod(args...))%mod; }
/*******************************************************************************/
using pii = pair < ll, ll >;
using vi = vector < ll >;
using vb = vector < bool >;
using vvi = vector < vector < ll > >;
using vvb = vector < vector < bool > >;
using vpii = vector < pii >;
using vvpii = vector < vector < pii > >;
#ifdef ONLINE_JUDGE
#define endl '\n'
#endif
#define fastio          ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define all(c)          (c).begin(), (c).end()
#define present(c,x)    ((c).find(x) != (c).end())
#define cpresent(c,x)   (find(all(c),x) != (c).end())
#define uniq(c)         (c).resize(distance((c).begin(), unique(all(c))))
#define min_pq(t)       priority_queue < t, vector < t >, greater < t > >
#define max_pq(t)       priority_queue < t >
#define pb              push_back
#define ff              first
#define ss              second
/*******************************************************************************/

/*
    Code begins after this.
*/


ll solve(){
    ll n;
    cin >> n;
    vi vec(n);
    for(ll &x : vec)
        cin >> x;
    bool flag = true;
    ld ans = 1, check = 1e18;
    
    if(count(all(vec), 0)){
        cout << 0 << endl;
        return 0;
    }

    for(ll x : vec){
        if(ans*(ld)x > check){
            flag = false;
            break;
        }
        ans *= x;
    }
    if(flag)
        cout << (ll)ans << endl;
    else
        cout << -1 << endl;
    return 0;
}


signed main(){
    fastio;

    ll t = 1;
    while(t--)
        solve();

    return 0;
}

/*******************************************************************************/
// Remeber - In a custom comparator cmp(a, b) a==b must always return to false.


Measured memory_bytes: 3968
/***
*	??????????????????
*	???????????????????????£???????????£??\????´?????????????????????§????¬???????????????°?????????
*	?????????????°?????????£??\??????????´?????????????????????????????????§?°???¢?????????????????°???????????????
****/

#include <iostream>
#include <vector>
using namespace std;

int main(void)		//???????????¢??°
{
	int n;
	cin >> n;
	
	vector <int> str;
	str.resize(n);
	
	for(int i =0; i < n ;  i++){	//????????\???
		cin >> str[i] ;
	}
//	int k = n-1;
	
	int cnter = 0;
	for( int i=0 ; i < n-1 ; ++i ){
		
		for(int j = 1 ; j< (n-i); j++){
			if( str[j] < str[j-1]){//????????????????´???¨??????
				int temp = str[j];
				str[j]     = str[j-1];
				str[j-1]   = temp;
				cnter ++;
			}
		}
	}
//	k=j;
	
//----------------------------------	???????????????
	for(int i =0; i<n ; i++){
		cout << str[i] ;
		if(i != (n-1)){
			cout << " ";
		}
	}
	cout << endl;
	
	cout << cnter << endl;//???????????°????????¢??°???????????¢?????°??¨?????°??????????????±?????????????????¨?????°???
	
	return 0;
}

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

#define rep2(x,fr,to) for(int x=(fr);x<(to);x++)
#define rep(x,to) for(int x=0;x<(to);x++)
#define repr(x,fr,to) for(int x=(fr);x>=(to);x--)
#define all(c) c.begin(),c.end()
#define sz(v) (int)v.size()

using namespace std;
typedef long long  ll; typedef vector<int> VI; typedef pair<int,int> pii; typedef vector<ll> VL; const int MD = 1e9 + 7;
void dbg(){cerr<<"\n";} template <class F,class ...S> void dbg(const F& f, const S&...s){cerr <<f <<": "; dbg(s...);}

ll f(ll x, ll m){ return x*x % m;}


int main()
{
	cin.tie(0); ios_base::sync_with_stdio(false);
	ll n, x, m;
	cin >>n >>x >>m;
	
	VL cx(100100);
	cx[0] = x;
	rep(i, 100100) cx[i+1] = f(cx[i], m);
	//for(auto x :cx) cerr<<x<<" "; dbg();
	
	
	ll ans =0;
	if(n<100010){
		rep(i, n) ans += cx[i];
	}else{
	
		int st=0,ss=0;
		VI ck(100101, -1);
		rep(i, 100999){
			if(ck[cx[i]] != -1 ){ st=ck[cx[i]]; ss=i; break;}
			ck[cx[i]] = i;
		}
		ll lp=ss - st;
		ll su = (n-st) / lp;
		ans = su * accumulate(cx.begin()+st, cx.begin()+ss, 0LL);
		ll am = (n-st)%lp;
		rep2(i, 0, st+am) ans += cx[i];
	}
	cout << ans <<"\n";
	return 0;
}



Measured memory_bytes: 4500
n = int(input())
s_cnt = {}

for _ in range(n):
    s = input()
    s = ''.join(sorted(s))
    s_cnt.setdefault(s,0)
    s_cnt[s] += 1

ans = 0
for s,cnt in s_cnt.items():
    ans += cnt*(cnt-1)//2

print(ans)

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

int main(){
    int n; cin >> n;
    int ans = 0;
    
    for(int i = 1; i < n; i++){
        int mod = n % i;
        int quotient = n / i;
        if(mod == 0){
            ans +=  quotient - 1;
        }else{
            ans += quotient;
        }
    }

    cout << ans << endl;
}



Measured memory_bytes: 3596
A,B,H,M = map(int,input().split())
import math
X = M*math.pi/30
Y = H*math.pi/6 + M*math.pi/360

Z = abs(X - Y)
if Z>=math.pi:
  Z = 2*math.pi - Z

if Z==math.pi:
  print(A + B)
else:
  print((A**2 + B**2 - (2*A*B*math.cos(Z)))**(1/2))


Measured memory_bytes: 9512
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <string.h>
#include <bitset>
#include <queue>
#include <map>
#include <string>
#include <stack>
#include <utility>
#include <queue>
#include <cmath>
#define mp make_pair
#define pii pair<long long int,long long int> 
#define ff first
#define pb push_back
#define ss second
#define ll long long 
#define ull unsigned long long
#define vi vector<long long int>
#define vii vector<pii>
#define vvi vector <vi>
#define rep(x,a,b,c) for(int x=a;x<=b;x+=c)
#define repp(x,a,b) rep(x,a,b,1)
#define rev(x,a,b,c) for(int x=a;x>=b;x-=c)
#define revv(x,a,b) rev(x,a,b,1)
#define OO (int)2e9
#define INF (ll)1e18
 
using namespace std;

int n,hasil;

int main()
{
	while(scanf("%d",&n)!=EOF)
	{
		hasil=0;
		rep(x,n,600-n,n)
		{
			hasil+=n*x*x;
		}
		printf("%d\n",hasil);
	}
	return 0;
}

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


int main()
{
	int N, M;
	cin >> N >> M;
	int L[M], R[M];
	for (int i=0;i<M;i++){
		cin >> L[i] >> R[i];
	}
	int L_max, R_min, answer;
	L_max = 0;
	R_min = N;
	for (int i=0;i<M;i++){
		if (L[i]>L_max)L_max=L[i];
		if (R[i]<R_min)R_min=R[i];
	}
	answer = R_min - L_max +1;
	if (answer <0)answer=0;
	cout << answer << endl;

	return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<utility>
#include<iomanip>
using namespace std;
#define rep(i, n) for(int i=0;i<n;i++)
#define setp(n) fixed<<setprecision(n)
int main(){
    int a, b;
    cin>>a>>b;
    if((a==2&&b==3)||(b==2&&a==3))
    cout<<1<<endl;
    else if((a==1&&b==3)||(b==1&&a==3))
    cout<<2<<endl;
    else
    cout<<3<<endl;
    return 0;
}

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

int main() {
	string S; long K; cin >> S >> K;
	for(int i; i<S.size(); ++i){
	    if(pow(S[i]-'0', 4999999999999999)>=K){
	        cout << S[i] << endl;
	        break;
	    }
	    else K -= pow(S[i]-'0', 4999999999999999);
	}
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(void)
{
  char a,b,ans=0;
  scanf("%c",&a);
  scanf("%c",&b);
  if(b!= ('H'||'D'))
  {
    scanf("%c",&b);
  }
  if((a=='H' && b=='H')||(a=='D' && b=='D'))
  {
    ans='H';
  }
  else
  {
    ans='D';
  }
  printf("%c\n",ans);
  return 0;
}


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

bool check(int x){
  if(x<=1)
    return false;
  for(int i=2;i*i<=x;i++){
    if(x%i==0)
      return false;
      
  }
  return true;
}

int main(){
  int x;
  cin>>x;
  int p=x;
  while(!check(p)){
    p++;
  }
  cout<<p<<endl;
  return 0;
}

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

#define rep(i, n) for(ll i = 0; i < n; i++)
#define pb push_back

ll input(){
    ll t;
    scanf("%lld", &t);
    return t;
}

int main(){
    ll n, t, q, b, m, e;
    vector<ll> v;
    n = input();
    rep(_, n){
        t = input();
        v.pb(t);
    }
    q = input();
    rep(_, q){
        b = input();
        m = input();
        e = input();
        rotate(v.begin()+b, v.begin()+m, v.begin()+e);
    }
    for (auto i = v.begin(); i != v.end(); i++){
        if(i != v.begin()){
            printf(" ");
        }
        printf("%lld", *i);
    }
    printf("\n");
    return 0;
}



Measured memory_bytes: 3276
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const int INF = (1<<30);
const ll INFLL = (1ll<<60);
const ll MOD = (ll)(1e9+7);

#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	a = (a<MOD)?a:(a-MOD);
	b = (b<MOD)?b:(b-MOD);
	a += b;
	a = (a<MOD)?a:(a-MOD);
}

string s;

int main(void){
	int n,i,j,k=0;
	bool flag = false;
	cin >> n;
	cin >> s;
	for(i=0; i<n; ++i){
		s[i] -= '1';
		if(s[i]==1){
			flag = true;
		}
		k += s[i]*(((n-1)&i)==i);
		k %= 2;
	}
	if(k || flag){
		cout << k << endl;
		return 0;
	}
	k = 0;
	for(i=0; i<n; ++i){
		s[i] /= 2;
		k += s[i]*(((n-1)&i)==i);
		k %= 2;
	}
	cout << (k*2) << endl;
	return 0;
}


Measured memory_bytes: 1412
#include <iostream>
#include <algorithm>
 
int main(int argc, const char * argv[]) {
    std::string w, t;
    std::cin >> w;
    std::transform(w.begin(), w.end(), w.begin(), toupper);
    int cnt = 0;
    for ( ; std::cin >> t && t != "END_OF_TEXT"; ) {
        std::transform(t.begin(), t.end(), t.begin(), toupper);
        if (w == t) {
            cnt++;
        }
    }
    std::cout << cnt << std::endl;
    return 0;
}

Measured memory_bytes: 3068
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {

    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    String s = sc.next();
    char[] c = new char[n];
    int wnum = 0;
    int rnum = 0;

    for (int i = 0; i < n; i++) {
      c[i] = s.charAt(i);
      if (c[i] == 'W') {
        wnum++;
      } else {
        rnum++;
      }
    }

    int cnt = 0;
    for (int i = rnum; i < n; i++) {
      if (c[i] == 'R') {
        cnt++;
      }
    }

    System.out.println(Math.min(Math.min(rnum, cnt), wnum));

  }
}

Measured memory_bytes: 41052
#include<stdio.h>

int main() {
  int n;
  int a[100010] = {};
  int max = 0;
  int num_unique = 0;
  int flag = 0;
  int i;
  scanf("%d", &n);
  for (i = 0; i < n; i++) {
    scanf("%d", &a[i]);
    if (max <= a[i]) {
      max = a[i];
    }
  }

  for (i = 0; i < n; i++) {
    if (max - 1 == a[i]) {
      num_unique += 1;
    }
    if (max - 1 > a[i]) {
      flag = 1;
    }
  }
  /*
  printf("max: %d\n", max);
  printf("num_unique: %d\n", num_unique);
  */
  if (num_unique == 0) {
    if (max != n-1 && max > n/2) {
      flag = 1;
    }
  }
  if (num_unique > 0) {
    if (max <= num_unique) {
      flag = 1;
    }
    
    if (n + num_unique < max * 2) {
      flag = 1;
    }
  }
  
  if (flag == 0) {
    printf("Yes\n");
  } else {
    printf("No\n");
  }
  return 0;
}
      
  


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

typedef long long ll;

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl

const int maxn = 1e6 + 5;

int n,m;

bool hit[maxn];

pair<int,int> p[maxn];

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

  cin>>n>>m;
  for (int i=0; i<m; i++) {
    int x,y; cin>>x>>y;
    p[i] = {x,y};
    if (y==n) {
      hit[x] = true;
    }
  }

  for (int i=0; i<m; i++) {
    if (p[i].first == 1) {
      if (hit[p[i].second]) out("POSSIBLE");
    }
  }

  out("IMPOSSIBLE");
  

  return 0;
}


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

typedef long long ll;
#define pa pair<int, int> 
#define pal pair<long long, long long>
#define pad pair<double, double>
#define pb push_back
#define mp make_pair
#define VIN(v) for(int64_t i=0;i<(v).size();i++){cin >> (v).at(i);}

typedef vector<bool> bvec;
typedef vector<int> ivec;
typedef vector<long long> lvec;
typedef vector<double> dvec;
typedef vector<pa> pvec;

typedef vector< vector<bool> > bmat;
typedef vector< vector<int> > imat;
typedef vector<string> svec;
typedef vector< vector<string> > smat;

ll C(int n, int r) {
    if(r > n - r) r = n - r; 
    ll ans = 1;
    int i;

    for(i = 1; i <= r; i++) {
        ans *= n - r + i;
        ans /= i;
    }

    return ans;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int  h, n;
    cin >> h >> n;
    ivec a(n), b(n);
    for (int i = 0; i < n; i++) cin >> a[i] >> b[i];
    int ma = *max_element(a.begin(), a.end());
    int nh = h+ma;
    imat dp(nh, ivec(n));
    dp[0][0] = 0;
    for (int i = 0; i < n; i++) dp[0][i] = 0;
    for (int i = 1; i < nh; i++) dp[i][0] = b[0] * ( 1 + (i)/a[0] - !((i) % a[0]));
    for (int i = 1; i < nh; i++){
        for (int j = 1; j < n; j++) dp[i][j] = fmin(dp[i][j-1], dp[fmax(i-a[j], 0)][j] + b[j]);
    }
    int ans = 100000001;
    for (int i = h; i < nh; i++) ans = fmin(ans, dp[i][n-1]);
    cout << dp[h][n-1] << endl;
}


Measured memory_bytes: 44544
#include <stdio.h>
#include <math.h>

int main(){
  int A[10000];
  int i,j,N,flag,count = 0;
  
  scanf("%d",&N);
  
  for(i = 0; i < N; i++){
    scanf("%d",&A[i]);
  }

  for(i = 0; i < N; i++){
    
    for(j = 2; j <= sqrt(A[i]); j++){
      
      if(A[i] == 1 || A[i] % j == 0){
	flag = 1;
	break;
      }
      else flag = 0;
      
    }
    
    if(flag == 1) count++;
  }
  
  printf("%d\n",N - count);
  return 0;
}



Measured memory_bytes: 2048
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int x = sc.nextInt();

        int max = 1;
        for (int i = 2; i <= 1000; i++) {
            int e = i;
            while (e <= x) {
                e *= i;
            }

            if (e / i != i) {
                max = Math.max(e / i, max);
            }
        }

        System.out.println(max);
    }
}


Measured memory_bytes: 21844
#include <stdio.h>

int main()
{
    char n[4];
    scanf("%s",n);

    int i;
    for (i = 0; i < 3; i++)
    {
        if(n[i] == '7')break;
    }
    if(i == 3)printf("No");
    else printf("Yes");
}


Measured memory_bytes: 1732
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
#include <complex>
#include <cstring>
using namespace std;

using ll = long long;
using P = pair<int, int>;
constexpr int INF = 1001001001;
constexpr int mod = 1000000007;
// constexpr int mod = 998244353;

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

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

    string s, t;
    cin >> s >> t;
    int ns = s.length(), nt = t.length();
    vector<vector<int>> dp(ns + 2, vector<int>(nt + 2, 0));
    vector<vector<P>> prev(ns + 2, vector<P>(nt + 2, P(-1, -1)));
    for(int i = 0; i < ns; ++i){
        for(int j = 0; j < nt; ++j){
            if(s[i] == t[j]){
                if(chmax(dp[i + 1][j + 1], dp[i][j] + 1)){
                    prev[i + 1][j + 1] = P(i, j);
                }
            }
            else{
                if(chmax(dp[i + 1][j], dp[i][j])){
                    prev[i + 1][j] = P(i, j);
                }
                if(chmax(dp[i][j + 1], dp[i][j])){
                    prev[i][j + 1] = P(i, j);
                }
            }
        }
        if(chmax(dp[i + 1][nt], dp[i][nt])){
            prev[i + 1][nt] = P(i, nt);
        }
    }
    for(int i = 0; i < nt; ++i){
        if(chmax(dp[ns][i + 1], dp[ns][i])){
            prev[ns][i + 1] = P(ns, i);
        }
    }
    string ans = "";
    if(dp[ns][nt]){
        int x = ns, y = nt;
        while(x > 0 && y > 0){
            int nxt_x = prev[x][y].first, nxt_y = prev[x][y].second;
            if(x - nxt_x == y - nxt_y)  ans += s[x - 1];
            x = nxt_x, y = nxt_y;
        }
        reverse(ans.begin(), ans.end());
    }
    cout << ans << endl;
}

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

using namespace std;

#define rep(i,n) for(int i=0;i<(int)n;i++)
#define pii pair<int,int>

int visited[50][50];
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};

int main(){

  int h,w,c=0;
  cin >> h >> w;
  vector<vector<char> > s(h,vector<char>(w));
  rep(i,h){
    string ss;
    cin >> ss;
    rep(j,w){
      s[i][j] = ss[j];
    }
  }
  rep(i,h)rep(j,w){
    if(s[i][j]=='.')c++;
  }
  rep(i,h)rep(j,w)visited[i][j]=0;
  queue<pair<int,pii> > que;
  que.push(pair<int,pii>(0,pii(0,0)));
  int dist = 0;
  while(!que.empty()){
    pair<int,pii> cur = que.front();
    que.pop();
    // cout << cur.second.first << " " << cur.second.second<<endl;
    if(cur.second.first==h-1&&cur.second.second==w-1){
      dist = cur.first;
      break;
    }
    visited[cur.second.first][cur.second.second]=1;
    rep(i,4){
      int x = cur.second.first+dx[i];
      int y = cur.second.second+dy[i];
      if(x>=0&&x<h&&y>=0&&y<w){
        if(s[x][y]=='.'&&visited[x][y]==0){
          que.push(pair<int,pii>(cur.first+1,pii(x,y)));
          visited[x][y]=1;
        }
      }
    }
  }
  if(dist==0){
    cout << "-1" << endl;
    return 0;
  }
  // cout << dist << endl;
  c-=dist+1;
  cout << c << endl;

  return 0;
}


Measured memory_bytes: 256
N, W = map(int, input().split())
mo = [list(map(int, input().split())) for _ in range(N)]
dp = [[0] * (W+1) for _ in range(N+1)]

for i, m in enumerate(mo):
    for j in range(W+1):
        if j < m[1]:
            dp[i+1][j] = dp[i][j]
        else:
            dp[i+1][j] = max(dp[i][j], dp[i][j-m[1]] + m[0])
print(dp[N][W])


Measured memory_bytes: 25524