akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<vector>
#include<queue>
#include<map>
#include<iomanip>
#define rep(index,num) for(int index=0;index<num;index++)
#define rep1(index,num) for(int index=1;index<=num;index++)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-7
#define mp(a1,a2) make_pair(a1,a2)
typedef long long ll;
using namespace std;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
ll INFl=1e+18+1;
int INF=1e+9+1;
int main(){
	int N,M;
	int K[100],A[101][101];
	int count[101]={};
	scan(N);scan(M);
	rep(i,N){
		scan(K[i]);
		rep(j,K[i]){
			scan(A[i][j]);
			count[A[i][j]]++;
		}
	}
	int ans=0;
	rep1(i,M){
		if(count[i]==N) ans++;
	}
	prin(ans);
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i,n) for(int i=n; i>-1; --i)
#define ALL(a) (a).begin(),(a).end()
#define INIT(a,n,x); REP(i,(n)){ (a)[i]=(x); }
#define CINA(a,n); REP(i,(n)){ cin >> (a)[i]; }
#define INIT2(a,n,m,x); REP(i,(n)){ REP(j,(m)){(a)[i][j]=(x);} }
#define CINA2(a,n,m); REP(i,(n)){ REP(j,(m)){cin >> (a)[i][j];} }
#define Liny "Yes\n"
#define Linn "No\n"
#define LINY "YES\n"
#define LINN "NO\n"

#define umap unordered_map
//cout << setfill('0') << right << setw(4) << 12; // "0012"
int keta(ll x){ if(x<10){return 1;} else{return keta(x/10) + 1;}}
int keta_wa(ll x){ if(x<10){return x;} else{return keta_wa(x/10) + x%10;} }
int ctoi(char c){ return ( (c>='0' && c<='9')? c - '0': 0 );}
ll sum(ll a[],ll N){ return accumulate(a,a+N,0LL);}
ll gcd(ll a,ll b){if(a<b)swap(a,b); return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){if(a<b){swap(a,b);} return a/gcd(a,b)*b;}


int main(){
  int N; cin>>N;
  umap<char,int> mp[N];
  string s;
  REP(i,N){
    cin >> s;
    REP(j,s.size()){
      mp[i][s[j]]++;
    }
  }
  for(char c='a';c<='z';c++){
    int cnum = 100;
    REP(i,N){
      cnum = min(mp[i][c],cnum);
      if(cnum==0){break;}
    }
    REP(i,cnum){printf("%c",c);}
  }
  printf("\n");
}

Measured memory_bytes: 256
def LI():
  return list(map(int,input().split()))
  
red,green,blue=LI()
k=int(input())

for i in range(0,k+1):
    r=red
    g=green*pow(2,i)
    b=blue*pow(2,k-i)
    
    if r<g<b:
        print("Yes")
        # print(red,green,blue)
        exit()
        
print("No")
        
    

Measured memory_bytes: 61716
N = int(input())
ABs = [tuple(map(int, input().split())) for _ in range(N)]

ans = 0
minB = 10**9
isSame = True
for A, B in ABs:
    ans += A
    if A > B:
        minB = min(minB, B)
    if A != B:
        isSame = False

if isSame:
    print(0)
else:
    print(ans-minB)


Measured memory_bytes: 5684
#include <bits/stdc++.h>
// #include <atcoder/all>
#define ll long long int
#define ld long double
#define yorn(f) std::cout<<((f)?"Yes":"No")<<endl;
#define YORN(f) std::cout<<((f)?"YES":"NO")<<endl;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define repi(i, n) for (ll i = 1; i < (ll)(n); i++)
#define all(x) (x).begin(), (x).end()
#define put(x) std::cout << x << endl;
#define println(x) std::cout << x << endl;
using namespace std;
// using namespace atcoder;
void Main()
{
    ll H, W, M;
    cin >> H >> W >> M;

    vector<int> h(M), w(M);
    rep(i, M) {
        cin >> h[i] >> w[i];
        h[i]--;
        w[i]--;
    }
    
    vector<int> nH(H), nW(W);
   // multiset<tuple<int, int> > xys;
    rep(i, M) {
        nH[h[i]]++;
        nW[w[i]]++;
   //     xys.emplace(make_tuple(w[i], h[i]));
    }

    ll maxNH = *max_element(all(nH));
    ll maxNW = *max_element(all(nW));

    unordered_set<int> xs, ys;
    rep(i, nH.size()) if (nH[i] == maxNH) ys.emplace(i);
    rep(i, nW.size()) if (nW[i] == maxNW) xs.emplace(i);

    // 最大のx, yの交差点に何個対象があるか
    ll cnt = 0;
    rep(i, M) {
        if (ys.find(h[i]) != ys.end() && xs.find(w[i]) != xs.end()) {
            cnt++;
        } 
    }

    bool contains = cnt == xs.size() * ys.size();

    ll res = maxNW + maxNH;
    if (contains) {
        res--;
    }

    put(res);

    // vector<pair<int, int> > pH, pW;
    // rep(i, H+1) {
    //     if (nH[i] > 0) {
    //         pH.push_back({nH[i], i});
    //     }
    // }
    // rep(i, W+1) {
    //     if (nW[i] > 0) {
    //         pW.push_back({nW[i], i});
    //     }
    // }

    // sort(all(pH));
    // reverse(all(pH));
    // sort(all(pW));
    // reverse(all(pW));

    // ll res = 0;
    // rep(i, pH.size()) {
    //     if (pH[i].first < pH[0].first) {
    //         break;
    //     }
    //     rep(j, pW.size()) {
    //         if (pW[j].first < pW[0].first) {
    //             break;
    //         }
    //         ll x = pW[j].second;
    //         ll y = pH[i].second;
    //         bool contains = xys.find(make_tuple(x,y)) != xys.end();
    //         ll v = pW[j].first + pH[i].first;
    //         if (contains) {
    //             v--;
    //         }
    //         res = max(v, res);
    //     }
    // }

    // put(res);
}

signed main(){ Main();return 0;}

Measured memory_bytes: 35460
#include <iostream>
using namespace std;
int main() {
 int n;
 cin >> n;
 int a[n];
 for (int i = 0; i < n; i++) cin >> a[i];
 for (int i = 0; i < n; i++) {
  if (i == 0 || a[i-1] < a[i]) a[i]--;
 }
 for (int i = 0; i < n - 1; i++) {
  if (a[i] > a[i+1]) {
   cout << "No" << endl;
   return 0;
  }
 }
 cout << "Yes" << endl;
 return 0;
}

Measured memory_bytes: 768
import scala.collection.mutable

object Main extends App {
  import scala.io.StdIn._

  val Array(n, x) = readLine.trim.split(' ').map(_.toInt)
  val warps = Array.tabulate(n){_ ⇒
    val Array(d, c) = readLine.trim.split(' ').map(_.toInt)
    Warp(d, c)
  }
  val minCost = Array.tabulate(math.max(2 * x, warps.maxBy(_.distance).distance * 2) + 1) { _ ⇒ Long.MaxValue }
  minCost(0) = 0
  val queue = mutable.PriorityQueue()(Ordering.by[(Int, Long), Long](_._2).reverse)
  queue.enqueue((0, 0))
  while(queue.nonEmpty && queue.head._1 != x){
    val (current, cost) = queue.dequeue()
    if (minCost(current) == cost){
      for (Warp(d, c) ← warps) {
        if (minCost.indices.contains(d + current) && minCost(d + current) > cost + c){
          minCost(d + current) = cost + c
          queue.enqueue((d + current, cost + c))
        }
        if (minCost.indices.contains(current - d) && minCost(current - d) > cost + c){
          minCost(current - d) = cost + c
          queue.enqueue((current - d, cost + c))
        }
      }
    }
  }
  println(if (queue.isEmpty) -1 else minCost(x))
  case class Warp(distance: Int, cost: Int)
  implicit class Scope[T](val value: T) extends AnyVal {
    @inline def also(@inline func: T ⇒ Unit): T = {
      func(value)
      value
    }
    @inline def let[A](@inline func: T ⇒ A): A = func(value)
  }
}


Measured memory_bytes: 457480
def f(n):
  D={}
  A=[]
  for _ in range(n):
    a,b,c=map(int,raw_input().split(' '))
    if D.has_key(a): D[a]+=b*c
    else:
      D[a]=b*c
      A.append(a)
  B=[i for i in A if D[i]>=1e6]
  if B==[]: B=["NA"]
  return B

while 1:
  n=input()
  if n==0:break
  x=f(n)
  for e in x: print e

Measured memory_bytes: 4356
#include <iostream>
#include <string>
#include <stdio.h>
#include <string.h>
#include <vector>
#include <ctime>
#include <set>
#include <map>
#include <unordered_map>
#include <queue>
#include <algorithm>
#include <cmath>
#include <assert.h>
#include <iomanip>
#include <stack>
using namespace std;
#define vi vector<int>
#define pii pair<int,int>
#define x first
#define y second
#define all(x) x.begin(),x.end()
#define pb push_back
#define mp make_pair
#define SZ(x) (int)x.size()
#define rep(i,a,b) for(int i=a;i<b;i++)
#define per(i,a,b) for(int i=b-1;i>=a;i--)
#define pi acos(-1)
#define mod 1000000007
#define inf 1000000007
#define ll long long
#define ull unsigned long long
#define DBG(x) cerr<<(#x)<<"="<<x<<"\n";
#define N 1001

string s, last;
int main(){
    int T,ca=0,k,i,j,m=0, K = 0, n;
    cin >> s;
    n = s.size();
    int ans = 0;
    rep(i, 0, n){
        j = i;
        string t = "";
        while(j < n){
            t += s[j++];
            if(t != last){
                ans++;
                last = t;
                break;
            }
        }
        i = j - 1;
    }
    cout << ans << "\n";
}



Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i, n) for (lli i = 0; i < (n); i++)
#define rrep(i, n) for (lli i = (n)-1; i >= 0; i--)
using namespace std;
using lli = long long int;
int main()
{

    int n;
    int c[515], s[515], f[515];
    cin >> n;
    rep(i, n - 1) cin >> c[i] >> s[i] >> f[i];
    rep(i, n)
    {
        int sum = 0;
        for (int j = i; j + 1 < n; j++) {
            if (sum < s[j]) {
                sum = s[j];
            } else {
                rep(k, 2 * f[j])
                {
                    if ((sum + k) % f[j] == 0) {
                        sum += k;
                        break;
                    }
                }
            }
            sum += c[j];
        }
        cout << sum << endl;
    }
}


Measured memory_bytes: 256
import math
a, b, x = list(map(int, input().split()))
if (2 * x - (math.pow(a, 2) * b)) >= 0:
    print(math.degrees(math.atan(2 * (math.pow(a, 2) * b - x) / math.pow(a, 3))))
else:
    print(90 - math.degrees(math.atan(2 * x / (a * math.pow(b, 2)))))


Measured memory_bytes: 38512
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
#include <vector>
#include <set>
#include <utility>
#include <cstdio>
using namespace std;
typedef long long LL;
#define rep(i, n) for (int i = 0; i < n; i++)
#define rrep(i, n, m) for (int i = n; i >= m; i--)

template <class T>
bool contain(const std::string &s, const T &v)
{
    return s.find(v) != std::string::npos;
}

LL a,b,c[5]={},ans=0;

int main()
{
    rep(i,3){
        cin>>a>>b;
        ++c[a-1];
        ++c[b-1];
        if(c[a-1]>2 || c[b-1]>2)ans=1;
    }
    // rep(i,5){
    //     cout<<c[i]<<endl;
    // }
    cout<< (ans==0 ? "YES" : "NO") << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {

    Scanner sc = new Scanner(System.in);
    String s = sc.next();

    if (s.substring(0, Math.min(4, s.length())).equals("YAKI")) {
      System.out.println("Yes");
    } else {
      System.out.println("No");
    }

  }
}

Measured memory_bytes: 35632
#include <bits/stdc++.h>
using namespace std;
#define ll long long
ll n,k;
ll a[3001];
ll memo[3001][3001];
ll findans(ll i,ll j)
{
    if(i==j)
    {
        return a[i];
    }
    if(i+1==j)
    {
        return max(a[i],a[j]);
    }
    if(i>j)
    {
        return 0;
    }
    if(memo[i][j]!=-1)
    {
        return memo[i][j];
    }
    ll choice1=a[i]+min(findans(i+1,j-1),findans(i+2,j));
    ll choice2=a[j]+min(findans(i,j-2),findans(i+1,j-1));
    return memo[i][j]=max(choice1,choice2);
}
int main(){
    // Your code here!
    cin>>n;
    for(ll i=0;i<n;i++)
    {
        cin>>a[i];
    }
    for(ll i=0;i<=3000;i++)
    {
        for(ll j=0;j<=3000;j++)
        {
            memo[i][j]=-1;
        }
    }
    ll x=findans(0,n-1);
    ll sum=0;
    for(ll i=0;i<n;i++)
    {
        sum+=a[i];
    }
    ll y=sum-x;
    cout<<x-y;
}


Measured memory_bytes: 70784
#include <iostream>
#include <string>
 
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define rep(i, n) FOR(i, 0, n)
 
using namespace std;
 
typedef long long ll;
 
const int TLE = 1000000000;
ll pow(ll x, int n){
    ll res = 1;
    rep(i, n){
        res *= x;
        if(res > TLE) return -1;
    }
    return res;
}
 
 
ll n, T;
string s;
 
int solve(){
    ll res = 0;
    rep(i, s.size()){
        if('0' <= s[i] && s[i] <= '9'){
            if(pow(n, s[i]-'0') == -1) return -1;
            res += pow(n, s[i]-'0');
        }
        if(res > TLE) return -1;
    }
    res *= T;
    return res>TLE?-1:res;
}
 
int main(){
    cin >> n >> T >> s;
    int ans = solve();
    if(~ans) cout << ans << endl;
    else cout << "TLE" << endl;
 
    return 0;
}

Measured memory_bytes: 1200
use std::io;
use std::str::FromStr;
use std::collections::HashSet;

type Edge = (usize, usize);

fn input_tuple() -> (usize, usize) {
    let mut line: String = String::new();
    io::stdin().read_line(&mut line);
    let vec: Vec<usize> = line.split_whitespace().map(|s| s.parse().unwrap()).collect();
    (vec[0], vec[1])
}

fn input_tuple_three() -> (usize, usize, usize) {
    let mut line: String = String::new();
    io::stdin().read_line(&mut line);
    let vec: Vec<usize> = line.split_whitespace().map(|s| s.parse().unwrap()).collect();
    (vec[0], vec[1], vec[2])
}

fn dfs(idx: usize, friends: &Vec<HashSet<usize>>, visited: &mut Vec<bool>, cluster: &mut HashSet<usize>) {
    // println!("{}, visited = {:?}", idx, visited);
    cluster.insert(idx);
    visited[idx] = true;
    for i in &friends[idx] {
        if !visited[*i] {
            dfs(*i, friends, visited, cluster);
        }        
    }
}

fn main() {
    let (n, m, k) = input_tuple_three();
    let mut friends: Vec<HashSet<usize>> = Vec::new();
    let mut friends_vec: Vec<Edge> = Vec::new();
    let mut blocks_vec: Vec<Edge> = Vec::new();
    for _ in 0..n {
        friends.push(HashSet::new());
    }
    for _ in 0..m {
        let (a, b) = input_tuple();
        friends[a - 1].insert(b - 1);
        friends[b - 1].insert(a - 1);
        friends_vec.push((a - 1, b - 1));
    }
    for _ in 0..k {
        let (c, d) = input_tuple();
        blocks_vec.push((c - 1, d - 1));
    }

    // println!("{:?}", friends);
    // println!("{:?}", friends_vec);
    // println!("{:?}", blocks_vec);
    let mut visited = vec![false; n];
    let mut clusters: Vec<HashSet<usize>> = Vec::new();
    for i in 0..n {
        if !visited[i] {
            let mut cluster: HashSet<usize> = HashSet::new();
            dfs(i, &friends, &mut visited, &mut cluster);
            clusters.push(cluster);
        }
    }
    // println!("{:?}", clusters);

    let mut ans = vec![-1i32; n];

    let mut cluster_idx = vec![0; n];

    for i in 0..clusters.len() {
        for j in &clusters[i] {
            cluster_idx[*j] = i;
        }
    }
    // println!("{:?}", cluster_idx);

    for friend in &friends_vec {
        if cluster_idx[friend.0] == cluster_idx[friend.1] {
            ans[friend.0] -= 1;
            ans[friend.1] -= 1;
        }
    }

    for block in &blocks_vec {
        if cluster_idx[block.0] == cluster_idx[block.1] {
            ans[block.0] -= 1;
            ans[block.1] -= 1;
        }
    }

    for cluster in &clusters {
        for c in cluster {
            ans[*c] += cluster.len() as i32;
        }
    }
    for i in ans {
        print!("{} ", i);
    }
    println!();
}


Measured memory_bytes: 74232
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
#define fi first
#define se second
#define pb push_back
#define forn(i,n) for(int i=0;i<(n);i++)
#define for1(i,n) for(int i=1;i<=n;i++)
#define forr(i,n) for(int i=n;i>=0;i--)
#define all(x) x.begin(), x.end()
const int MAXN = 1e5 +5;

void fio(){
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
}

LL dp[MAXN];	

int main(){
  fio();
  int n; cin>>n;
  vector <LL> v(n);
  forn(i,n) cin>>v[i];
  dp[0] = 0;
  for1(i,n-1){
  	dp[i] = i==1?abs(v[0]-v[1]):min(dp[i-1]+abs(v[i-1]-v[i]), 
  			dp[i-2]+abs(v[i-2]-v[i]));
  }
  cout<<dp[n-1]<<endl;
  return 0;
}

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

using namespace std;

string s[10000010];
int cnt, n;

void dfs(int depth, int pm, string t) {
	if(depth == 1) {
		dfs(depth + 1, pm + 1, "a");
		return ;
	}
	if(depth == n + 1) {
		s[++cnt] = t;
		return ; 
	}
	for(register char i = 'a'; i < 'a' + pm; i++) {
		dfs(depth + 1, pm, t + i);
	}
	dfs(depth + 1, pm + 1, t + (char)('a' + pm));
}

int main() {
	cin >> n;
	dfs(1, 0, "");
	sort(s + 1, s + cnt + 1);
	for(register int i = 1; i <= cnt; i++) cout << s[i] << endl;
	return 0;
}

Measured memory_bytes: 84992
#include <bits/stdc++.h>
#define l_ength size
const int inf = (1<<30);
const int mod = 1000000007;
using ll = long long;
using namespace std;

int main(){
	int n; cin >> n; --n;
	vector<int> b(n);
	for( auto &k : b ) cin >> k;
	int ans = 0;
	for( int i = 0; i < n-1; ++i ){
		ans += min(b[i], b[i+1]);
	}
	ans += b[0];
	ans += b[n-1];
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
 
int main() 
{
	int i,n[3];

	for(i=0 ; i < 3; i++){
		cin >> n[i];
	} 

	sort(n, n + 3);
	
	cout << (n[0]==5 && n[1]==5 && n[2]==7 ? "YES" : "NO") << endl;

	return 0;
}

Measured memory_bytes: 256
/*
    STARK_BOY
*/
#include <bits/stdc++.h>
#include <fstream>
using namespace std;
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define repe(i,a,b) for(ll i=a;i<=b;i++)
#define bac(i,a,b) for(ll i=a;i>=b;i--)
#define pb push_back
#define mp make_pair
#define F first
#define S second
typedef long long ll;
typedef vector< ll > vi;
typedef vector<pair<ll,ll> > vpii;
typedef pair<ll,ll> pii;
#define all(c) c.begin(),c.end()
#define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define setbitc(x) __builtin_popcount(x)
#define init(x,a) memset(x,a,sizeof(x))
#define PI           3.14159265358979323846  /* pi */
mt19937 rng32(chrono::steady_clock::now().time_since_epoch().count());
#define N 1000005
//Variables Start
ll inf=1e18,MOD=1e9+7;
ll n,m,k,ar[N],br[N];
string s,s1;
//Variables End

int main()
{
    ios
    int ti=1;
    //cin>>ti;
    while(ti--)
    {
		cin>>n>>m;
		vi ans(n+1,0);
		vpii wa;
		int cnt=0,cnt2=0;
		rep(i,1,m+1)
		{
			int num;cin>>num;
			cin>>s;
			if(s[0]=='A')
			{
				if(ans[num]==0)ans[num]=i;
			}
			else
			{
				wa.pb(mp(num,i));
				//if(se.find(num)==se.end())cnt++;
			}
		}        
		for(auto i:wa)
		{
			if(ans[i.F] && i.S<ans[i.F])cnt++;
			
		}
		rep(i,1,n+1)if(ans[i])cnt2++;
		cout<<cnt2<<" "<<cnt<<endl;
    }
    return 0;
        
}

Measured memory_bytes: 3188
#include <stdio.h>

 int main()
 {
    int n, i;
    int m;

    for(n = 1; n <= 9; n++)
    {
        m = 0;
        for(i = 1; i <= 9; i++)
        {
            m = m + n;
            printf("%dx%d=%d\n", n, i, m);
        }
    }

    return 0;
 }

Measured memory_bytes: 524
import sys

sys.setrecursionlimit(10 ** 9)
input = sys.stdin.readline

N = int(input())
A = list(map(int, input().split()))

A = sorted(A)

total = A[0]
limit = 10 ** 18

for a in A[1:]:
    total *= a
    if total > limit:
        print(-1)
        exit()
print(total)


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

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

  string s;cin>>s;
  if(s=="ARC")puts("ABC");
  else puts("ARC");

  
  return 0;
}


Measured memory_bytes: 3616
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <numeric> // next_parmutation
#define ll long long
#define rep(i, n) for(int i = 0; i < (n); i++)

using namespace std;

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



}

Measured memory_bytes: 3624
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
int main()
{
    int a,b,c,n = 1,d = 1;
    scanf("%d%d",&a,&b);
    c = b;
    while(b!=0){
        n *= 10;
        b /= 10;
    }
    c = c + a * n;
    d = (int)sqrt((double)c);
    if(c == d*d)
        printf("Yes\n");
    else
        printf("No\n");
    return 0;
}


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

#if __cplusplus >= 201103L
#include <array>
#include <tuple>
#include <initializer_list>
#include <unordered_set>
#include <unordered_map>
#include <forward_list>

#define cauto const auto&
#endif

using namespace std;


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

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;

#define VV(T) vector<vector< T > >

template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()) {
  v.assign(a, vector<T>(b, t));
}

template <class F, class T>
void convert(const F &f, T &t) {
  stringstream ss;
  ss << f;
  ss >> t;
}


#define rep(i,n) for(int i=0;i<int(n);++i)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define pb push_back


#define MOD 1000000007LL
#define EPS 1e-8



int main() {
  string X;
  cin >> X;
  int res = 0;
  rep(i, X.length()) {
    if (X[i] == 'S') {
      res++;
    } else {
      if (res >= 1) {
        res--;
      }
    }
  }
  cout << res * 2 << endl;
  return 0;
}

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

using namespace std;

typedef long long ll;
const int mod = 1000000007;

bool is_prime(int num);

int main(){
    ll N;
    cin >> N;
    
    vector<pair<int, int>> prime;       // (素因数, 個数)のpair
    ll ans = 1;
    // N以下の素数
    for(int i = 2; i <= N; i++){
        if(is_prime(i))    prime.push_back(make_pair(i, 0));
    }
    
    for(int i = 2; i <= N; i++){
        int temp = i;
        for(int j = 0; j < prime.size(); j++){
            if(temp % prime[j].first != 0)      continue;
            
            while(temp % prime[j].first == 0){
                temp /= prime[j].first;
                prime[j].second++;
            }
            
            if(temp == 1)       break;
        }
    }
    
    for(int i = 0; i < prime.size(); i++){
        if(prime[i].second > 0){
            ans *= (ll)(prime[i].second + 1);
            ans %= mod;
        }
    }
    
    cout << ans << endl;
}

bool is_prime(int num){
    if(num <= 3){
        return num > 1;
    }
    else if(num % 2 == 0 || num % 3 == 0){
        return false;
    }
    else{
        for(int i = 5; i * i <= num; i += 6){
            if(num % i == 0 || num % (i + 2) == 0){
                return false;
            }
        }
    }
    
    return true;
}

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

int main() {
    long long N, K;
    cin >> N >> K;
    vector <long long> V(N+1, 0);
    for (long long i=0; i<N; i++) {
        long long A;
        cin >> A;
        V.at(A)++;
    }
    sort(V.begin(), V.end());
    reverse(V.begin(), V.end());
    long long ans=0; 
    for (long long i=0; i<K; i++) {
        ans += V.at(i);
    }
    cout << N-ans;
}

Measured memory_bytes: 4820
#include <iostream>

using namespace std;

int main(){
	int n;
	cin >> n;
	long long ans = 0;
	for(int i = 0; i < n+1; i++){
		int num = i;
		if(i % 3 == 0 || i % 5 == 0){
			num = 0;
		}
		ans += num;
	}
	cout << ans << endl;
}

Measured memory_bytes: 3632
n, t, e = map(int, input().split())
watch = list(map(int, input().split()))

ans = False
for w in range(n) :
    for i in range(e+1) :
        if (t+i) % watch[w] == 0 :
            ans = True
            break
        if (t-i) % watch[w] == 0 :
            ans = True
            break
    if ans == True :
        break

if ans == True :
    print(w+1)
else :
    print(-1)


Measured memory_bytes: 5596
#include<iostream>
using namespace std;
int isPrime(int n){
  for(int i=2;i*i<=n;i++) if(n%i==0) return 0;
  return 1;
}
int main(){
  int i,j,dp[1500000]={},c;
  i=2;
  
  while(i<1500000){
    c=1;
    dp[i]=0;
    while(isPrime(i+c)==0){
      c++;
    }
    if(i+c<1500000){
      for(j=i+1;j<i+c;j++) dp[j]=c;
      dp[i+c]=0;
    }
    i+=c;
  }
  int n;
  cin >> n;
  while(n!=0){
    cout << dp[n] << endl;
    cin >> n;
  }
  return 0;
}

Measured memory_bytes: 7024
# -*- coding: utf-8 -*-

N = int(input())

A = []
i = 1
while 6 ** i <= 100000:
    A.append(6 ** i)
    i += 1
B = []
j = 1
while 9 ** j <= 100000:
    A.append(9 ** j)
    j += 1

# 6**(i+1)を1回と6**iを6回は同じ金額分引き出せる
# 9も同様
# よって、6のグループと9のグループに分けて全探索すればよい

result = N
for i in range(N+1):
    ans = 0

    six_remain = i
    six_exp = 1
    while six_exp * 6 <= six_remain:
        six_exp *= 6
    # 6**i(<=i)から順に引き出していく
    while six_exp != 1:
        ans += six_remain // six_exp
        six_remain %= six_exp
        six_exp //= 6
    ans += six_remain

    nine_remain = N - i
    nine_exp = 1
    while nine_exp * 9 <= nine_remain:
        nine_exp *= 9
    # 9**i(<=N-i)から順に引き出していく
    while nine_exp != 1:
        ans += nine_remain // nine_exp
        nine_remain %= nine_exp
        nine_exp //= 9
    ans += nine_remain

    result = min(result, ans)

print(result)


Measured memory_bytes: 3064
import sys
import math
import collections
import itertools
import array
import inspect

# Set max recursion limit
sys.setrecursionlimit(1000000)


# Debug output
def chkprint(*args):
    names = {
        id(v): k
        for k, v in inspect.currentframe().f_back.f_locals.items()
    }
    print(', '.join(
        names.get(id(arg), '???') + ' = ' + repr(arg) for arg in args))


# Binary converter
def to_bin(x):
    return bin(x)[2:]


def li_input():
    return [int(_) for _ in input().split()]


def gcd(n, m):
    if n % m == 0:
        return m
    else:
        return gcd(m, n % m)


def gcd_list(L):
    v = L[0]

    for i in range(1, len(L)):
        v = gcd(v, L[i])

    return v


def lcm(n, m):
    return (n * m) // gcd(n, m)


def lcm_list(L):
    v = L[0]

    for i in range(1, len(L)):
        v = lcm(v, L[i])

    return v


# Width First Search (+ Distance)
def wfs_d(D, N, K):
    """
    D: 隣接行列(距離付き)
    N: ノード数
    K: 始点ノード
    """

    dfk = [-1] * (N + 1)
    dfk[K] = 0

    cps = [(K, 0)]
    r = [False] * (N + 1)
    r[K] = True
    while len(cps) != 0:
        n_cps = []
        for cp, cd in cps:
            for i, dfcp in enumerate(D[cp]):
                if dfcp != -1 and not r[i]:
                    dfk[i] = cd + dfcp
                    n_cps.append((i, cd + dfcp))
                    r[i] = True

        cps = n_cps[:]

    return dfk


# Depth First Search (+Distance)
def dfs_d(v, pre, dist):
    """
    v:  現在のノード
    pre: １つ前のノード
    dist: 現在の距離

    以下は別途用意する
    D: 隣接リスト(行列ではない)
    D_dfs_d: dfs_d関数で用いる，始点ノードから見た距離リスト
    """

    global D
    global D_dfs_d

    D_dfs_d[v] = dist

    for next_v, d in D[v]:
        if next_v != pre:
            dfs_d(next_v, v, dist + d)

    return


def sigma(N):
    ans = 0
    for i in range(1, N + 1):
        ans += i
    return ans


def comb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2, r + 1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p - 1, r, p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result

def bisearch(L, target):
    low = 0
    high = len(L) - 1
    
    while low <= high:
        mid = (low + high) // 2
        guess = L[mid]
        if guess == target:
            return True
        elif guess < target:
            low = mid + 1
        elif guess > target:
            high = mid - 1
    if guess != target:
        return False

# --------------------------------------------

dp = None


def main():
    S = input()

    if "a" in S and "b" in S and "c" in S:
        print("Yes")
    else:
        print("No")


main()


Measured memory_bytes: 5024
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;
typedef long long ll;

int main(int argc, const char * argv[]) {
    int N; cin >> N;
    vector<double> v(N);
    for (int i = 0; i < N; i++) cin >> v[i];
    sort(v.begin(), v.end());
    
    double ans = v[0];
    for (int i = 1; i < N; i++) {
        ans += pow(2.0, i - 1) * v[i];
    }
    
    cout << ans / pow(2.0, N - 1) << endl;
    
    return 0;
}

Measured memory_bytes: 512
while true
    h, w = gets.chomp.split.map(&:to_i)
    break if h == 0 && w == 0

    h.times{|y|
        w.times{|x|
            if y == 0 || y == h - 1 || x == 0 || x == w - 1 
                print "#"
            else
                print "."    
            end
        }
        puts
    }
    puts
end

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

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ

		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int D[] = new int[N];
		for (int i = 0; i < N; i++) {
			D[i] = sc.nextInt();
		}
		int M = sc.nextInt();
		int T[] = new int[M];
		for (int i = 0; i < M; i++) {
			T[i] = sc.nextInt();
		}

		Arrays.sort(D);
		Arrays.sort(T);

		int js = 0;
		String ans = "YES";
		LOOP: for (int i = 0; i < M; i++) {

			for (int j = js; j < N; j++) {
				if (D[j] == T[i]) {
					js = j+1;
					continue LOOP;
				}
			}
			ans = "NO";
			break;
		}

		System.out.println(ans);
	}
}


Measured memory_bytes: 94236
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int mod = 1e9 + 7;
const int inf = (1 << 30) - 1;
const ll infll = (1LL << 61) - 1;
#define fast() cin.tie(0), ios::sync_with_stdio(false)

char A[2002][2002], B[2002][2002];

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

    int ans = 0;

    for (int i = 0; i < M; i++)
    {
        for (int j = 0; j < N; j++)
        {
            cin >> B[i][j];
            if (A[i][j] != B[i][j])
                ans++;
        }
    }

    cout << ans << endl;
}


Measured memory_bytes: 10920
import numpy as np
H, W = map(int, input().split())
A = []
for _ in range(H):
    vec = list(map(lambda x: 0 if x=='#' else 1, list(input())))
    A.append(vec)

A = np.array(A)
top = np.zeros((H+1, W), dtype=np.int)
bottom = np.zeros((H+1, W), dtype=np.int)
left = np.zeros((H, W+1), dtype=np.int)
right = np.zeros((H, W+1), dtype=np.int)

for i in range(1, H+1):
        top[i] = (top[i-1] + 1) * A[i-1]

for i in range(H-1, -1, -1):
    bottom[i] = (bottom[i+1] + 1) * A[i]

for i in range(1, W+1):
    left[:, i] = (left[:, i-1] + 1) * A[:, i-1]
    
for i in range(W-1, -1, -1):
    right[:, i] = (right[:, i+1] + 1) * A[:, i]
    
C = top[1:H+1, :] + bottom[0:H, :] - A
R = left[:, 1:W+1] + right[:, 0:W] - A
CR = C + R - A
print(CR.max())

Measured memory_bytes: 296884
#include <cassert>

#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
//#include <boost/foreach.hpp>
//#include <boost/range/algorithm.hpp>
#define rep(i,j,k) for(int i=(int)j;i<(int)k;i++)
#define ll long long
#define Sort(v) sort(all(v))
#define INF 1e9
#define LINF 1e18
#define END return 0
#define pb push_back
#define se second
#define fi first
#define pb push_back
#define all(v) (v).begin() , (v).end()
#define MP make_pair
#define MOD 1000000007LL
#define int long long
using namespace std;
int day[12]={31,28,31,30,31,30,31,31,30,31,30,31};
struct edge{int to,cost;};
typedef pair<int,int> P;

bool isupper(char c){if('A'<=c&&c<='Z')return 1;return 0;}
bool islower(char c){if('a'<=c&&c<='z')return 1;return 0;}

bool f(string s){
    rep(i,0,s.size()/2){
        if(s[i]!=s[s.size()-i-1])return false;
        
    }
    return 1;
}

signed main (){
    int a,b,c,x,y;
    cin>>a>>b>>c>>x>>y;
    int ans1=a*x+b*y;
    int ans2=2*min(x,y)*c+(x-min(x,y))*a+(y-min(x,y))*b;
    int ans3=max(x,y)*2*c;
    cout<<min(ans1,min(ans3,ans2))<<endl;
    




}
/*
1-2
0.5-2

010
01110
00111
000000111
*/


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <string>
#include <cmath>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <list>
#include <iostream>
#include <sstream>
#include <climits>
#include <cfloat>
#include <complex>

using namespace std;

typedef long long ll;

ll encode(int* state)
{
	ll res = 0;
	for (int i = 0; i < 13; ++i)
		res = res << 4 | state[i];
	return res;
}
void decode(int* d, ll e)
{
	for (int i = 12; i >= 0; --i, e >>= 4)
		d[i] = e & 15;
}

map<ll, int> minSteps;
int dir[] = { -1, 1, -2, 2, -4, 4 };
map<int, bool> ok[3];

const int InitialDepth = 12;
map<ll, int> problemSteps;

int start_from_initial(ll current, ll next)
{
	bool newState = minSteps.count(next) == 0;
	if (newState)
		minSteps[next] = minSteps[current] + 1;

	return newState && minSteps[next] < InitialDepth ? 0 : -1;
}
int start_from_problem(ll current, ll next)
{
	bool newState = problemSteps.count(next) == 0;
	if (newState)
		problemSteps[next] = problemSteps[current] + 1;

	if (minSteps.count(next))
		return problemSteps[next] + minSteps[next];

	return newState && problemSteps[next] < 20 - InitialDepth ? 0 : -1;
}
int bfs(ll initial, int (*f)(ll, ll))
{
	queue<ll> q;
	q.push(initial);

	while (!q.empty())
	{
		ll e = q.front();
		q.pop();
		int d[13];
		decode(d, e);

		int zero_pos[2];
		for (int i = 0, j = 0; j < 2; ++i)
			if (!d[i])
				zero_pos[j++] = i;

		for (int i = 0; i < 2; ++i)
		{
			for (int j = 0; j < 6; ++j)
			{
				int a = zero_pos[i];
				int b = a + dir[j];
				if (a > b)
					swap(a, b);
				if (a < 0 || b > 12 || !d[a] && !d[b] || !ok[j/2][a])
					continue;

				int copy[13];
				memcpy(copy, d, sizeof(copy));
				swap(copy[a], copy[b]);
				ll next = encode(copy);

				int r = f(e, next);
				if (r == 0)
					q.push(next);
				else if (r > 0)
					return r;
			}
		}
	}

	return -1;
}

int main()
{
	int o[][9] = {
		{ 1, 2, 4, 5, 6, 7, 9, 10, -1 },
		{ 0, 10, -1 },
		{ 1, 2, 3, 5, 6, 7, -1 }
	};
	for (int i = 0; i < 3; ++i)
		for (int j = 0; o[i][j] != -1; ++j)
			ok[i][o[i][j]] = true;

	int initial[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 0 };
	ll t = encode(initial);
	minSteps[t] = 0;

	bfs(t, start_from_initial);

	while (true)
	{
		int d[13];
		for (int i = 0; i < 13; ++i)
			scanf("%d", d + i);
		if (d[0] == -1)
			break;

		int ans = -1;
		ll s = encode(d);
		if (minSteps.count(s))
			ans = minSteps[s];
		else
		{
			problemSteps.clear();
			ans = bfs(s, start_from_problem);
		}

		if (ans != -1)
			printf("%d\n", ans);
		else
			puts("NA");
	}

	return 0;
}

Measured memory_bytes: 2240
#include <iostream>
#include <bitset>
#include <fstream>
#include <string>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <functional>
#include <cctype>
#include <list>
#include <limits>
#include <unordered_map>
#define Debug 0
//#include <boost/multiprecision/cpp_int.hpp>

const double EPS = (1e-10);


using namespace std;
using Int = long long;
//using namespace boost::multiprecision;

const Int MOD = 998244353;

Int mod_pow(Int x, Int n) {
    Int res = 1;
    while(n > 0) {
        if(n & 1) res = (res * x) % MOD; //ビット演算(最下位ビットが1のとき)
        x = (x * x) % MOD;
        n >>= 1; //右シフト(n = n >> 1)
    }
    return res;
}

//最大公約数
template<typename T>
T gcd(T a, T b) {
    return b != 0 ? gcd(b, a % b) : a;
}

//最小公倍数
template<typename T>
T lcm(T a, T b) {
    return a * b / gcd(a, b);
}

//入出力高速化(非同期化)
void fast_input() {
    cin.tie(0);
    ios::sync_with_stdio(false);
}

int solve(int n, int a, int b, int c, int x) {
    vector<int> y(n);
    for (int i = 0; i < n; i++) {
        cin >> y[i];
    }
    int ret = -1;
    for (int i = 0, j = 0; i < n && j < 10001; j++) {
        if (x == y[i]) i++;
        x = (a*x+b)%c;
        if (i == n) ret = j; 
    }
    return ret;
}

int main(){
    int N; cin >> N;
    set<string> U;
    for (int i = 0; i < N; i++) {
        string u; cin >> u;
        U.insert(u);
    }
    int M; cin >> M;
    vector<string> T(M);
    for (int i = 0; i < M; i++) {
        cin >> T[i];
    }
    bool closed = true;
    for (int i = 0; i < M; i++) {
        if (U.count(T[i])) {
            if (closed) {
                closed = false;
                cout << "Opened by " << T[i] << endl;
            } else {
                closed = true;
                cout << "Closed by " << T[i] << endl;
            }
        } else {
            cout << "Unknown " << T[i] << endl; 
        }
    }
    return 0;
}





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

int main() {
  
  int64_t r, D, x; cin >> r >> D >> x; int64_t a[11];
  
  a[0] = x;
  
  for (int i = 0; i < 10; i++) {
    
    a[i + 1] = r * a[i] - D;
    
  }
  
  for (int i = 1; i < 11; i++) cout << a[i] << endl;
  
}

Measured memory_bytes: 256
'use strict';

const receive = require('fs')
  .readFileSync('/dev/stdin', 'utf8')
  .split(/\s/);

const main = input => {
  const [a, b, c, d] = input.map(x => Number(x));
  const trainFare = a < b ? a : b;
  const busFare = c < d ? c : d;
  const ans = trainFare + busFare;
  console.log(ans);
};

main(receive);

Measured memory_bytes: 7372
# -*- coding: utf-8 -*-
'''
X 段重ねの鏡餅 (X≥1) とは、X 枚の円形の餅を縦に積み重ねたものであって、
どの餅もその真下の餅より直径が小さい（一番下の餅を除く）もののことです。
例えば、直径 10、8、6 センチメートルの餅をこの順に下から積み重ねると 3 段重ねの鏡餅になり、
餅を一枚だけ置くと 1 段重ねの鏡餅になります。

ダックスフンドのルンルンは N 枚の円形の餅を持っていて、
そのうち i 枚目の餅の直径は di センチメートルです。
これらの餅のうち一部または全部を使って鏡餅を作るとき、
最大で何段重ねの鏡餅を作ることができるでしょうか。
'''

num = int(input())
diameter_list = []
for i in range(num):
    s = int(input())
    diameter_list.append(s)

# print(num,diameter_list)
diameter_list.sort(reverse = True)
# print(diameter_list)

a = []
for i in diameter_list:
    if (i not in a):
        a.append(i)

print(len(a))


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

#define ll long long
#define all(x) (x).begin(), (x).end()
const long long INF = 1LL << 60;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)  //(i, 10) i=0～i=9まで
#define repr(i, n) for (int i = n; i >= 0; i--)   // (i, 10) i=10～i=0まで
#define FOR(i, m, n) for (int i = m; i < n; i++)  // (i, 3, 10) i=3～i=9まで

// 総数を1000000007で割った余り
const long long mod = 1e9 + 7;

int main() {
    // cin.tie(0);
    // ios::sync_with_stdio(false);
    // cout << fixed << setprecision(5);

    // 入力
    string n;
    cin >> n;

    // 処理
    rep(i, 3) {
        if (n[i] == '1') {
            n[i] = '9';
        } else if (n[i] == '9') {
            n[i] = '1';
        }
    }

    // 出力
    cout << n << endl;

    return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
#define endl "\n"
#define sz(x) ((ll)(x).size())
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define prt(x) cout << (x)
#define prtl(x) cout << (x) << endl
#define rep(i,a,b) for(ll i=a; i<b; i++)
#define rrep(i,a,b) for(ll i=a; i>b; i--)
#define mp(a, b) make_pair(a, b)
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
using namespace std;
using vi = vector<int>;
using vll = vector<long long int>;
using vb = vector<bool>;
using vvb = vector<vector<bool>>;
using vc = vector<char>;
using vvi = vector<vector<int>>;
using vvll = vector<vector<long long int>>;
using vvc = vector<vector<char>>;
using ll = long long int;
using P = pair<long long int, long long int>;
using Map = map<long long int, long long int>;
ll INF = 1LL<<60;
ll M = 1000000007;

vector<long long> divisor(long long n) {
    vector<long long> ret;
    for (long long i = 1; i * i <= n; i++) {
        if (n % i == 0) {
        ret.push_back(i);
        if (i * i != n) ret.push_back(n / i);
        }
    }
    sort(ret.begin(), ret.end()); // 昇順に並べる
    return ret;
}

int main(){
    ll N; cin >> N;
    vll A(N+1);
    rep(i, 1, N+1){
        cin >> A[i];
    }
    vb ald(1000000, false);
    vll count(1000000, 0);
    ll c = 0;
    rep(i, 1, N+1){
        ald[A[i]] = true;
        count[A[i]]++;
    }
    rep(i, 1, N+1){
        vll t = divisor(A[i]);
        bool f = true;
        for(auto x: t){
            if(x == A[i]){
                continue;
            }
            if(ald[x]){
                f = false;
            }
        }
        if(f){
            if(count[A[i]] < 2){
                c++;
            }
        }
    }
    prt(c);
}


Measured memory_bytes: 12628
if __name__ == '__main__':

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

	A = [[0] * 3 for i in range(n)]

	for _ in range(m):
		x,y = input().split()
		x = int(x)
		A[x-1][0] = x
		if y == "AC":
			A[x-1][1] = 1
		else:
			#ACしていなければ
			if A[x-1][1] == 0:
				#WA +1
				A[x-1][2] += 1

	ac = 0
	wa = 0

	for i in range(n):
		ac += A[i][1]
		if A[i][1] != 0:
			wa += A[i][2]

	print(ac,wa)



Measured memory_bytes: 16404
from heapq import heappop, heappush, heappushpop

n = int(input())
q = [tuple(int(x) for x in input().split()) for _ in range(n)]

L = []
R = []
a = 1
b = q[0][2]

ans = 0

heappush(L, -q[0][1])

for i in range(1, n):
    temp = q[i]
    if temp[0] == 1:
        a += 1
        if a % 2 == 0:
            ans += abs(temp[1] + L[0])
            p = heappushpop(L, - temp[1])
            heappush(R, - p)
        else:
            ans += abs(temp[1] + L[0])
            tl = L[0]
            p = heappushpop(R, temp[1])
            heappush(L, - p)
            if tl != L[0]:
                ans -= abs(tl - L[0])
        b += temp[2]
    else:
        m = - L[0]
        print(m, ans + b)


Measured memory_bytes: 39732
// In the name of God

#include <bits/stdc++.h>

using namespace std;

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n;
	vector<int> freq(2 * n + 1, 0);
	long long ans = 0;
	for(int i = 0; i < n; i++) {
		int x;
		cin >> x;
		if(i - x >= 0) {
			ans += freq[i - x];
		}
		if(x + i <= 2 * n) {
			freq[x + i]++;
		}
	}
	cout << ans;
	return 0;
}


Measured memory_bytes: 4784
import sys
readline = sys.stdin.readline

N = int(readline())
S = readline().rstrip()

ans = 0

numlist = [[] for i in range(10)]
for i in range(len(S)):
  numlist[int(S[i])].append(i)

ans = 0
import bisect
for i in range(1000):
  target = str(i).zfill(3)
  now = 0
  for j in range(len(target)):
    tar = int(target[j])
    pos = bisect.bisect_left(numlist[tar], now)
    if pos >= len(numlist[tar]):
      break
    now = numlist[tar][pos] + 1
  else:
    ans += 1

print(ans)

Measured memory_bytes: 10404
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
//namespace mp = boost::multiprecision;

using namespace std;

const double PI = 3.14159265358979323846;
typedef long long ll;
const double EPS = 1e-9;
#define rep(i, n) for (int i = 0; i < (n); ++i)
//#define rep(i, n) for (ll i = 0; i < (n); ++i)
typedef pair<ll, ll> P;
const ll INF = 10e17;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
#define ret() return 0;

double equal(double a, double b) {
    return fabs(a - b) < DBL_EPSILON;
}

std::istream &operator>>(std::istream &in, set<int> &o) {
    int a;
    in >> a;
    o.insert(a);
    return in;
}

std::istream &operator>>(std::istream &in, queue<int> &o) {
    ll a;
    in >> a;
    o.push(a);
    return in;
}

bool contain(set<int> &s, int a) { return s.find(a) != s.end(); }

//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);
//const ll mod = 1e10;

typedef priority_queue<ll, vector<ll>, greater<ll> > PQ_ASK;


int main() {

    int n, k, c;
    string s;

    cin >> n >> k >> c >> s;

    vector<int> ls;
    vector<int> rs;

    {
        rep(i, n) {
            if (s[i] == 'x') continue;
            ls.push_back(i);
            i += c;

            if (ls.size() == k) break;
        }
    }

    {
        for (int i = n - 1; i >= 0; i--) {
            if (s[i] == 'x') continue;
            rs.push_back(i);
            i -= c;

            if (rs.size() == k) break;
        }
        reverse(rs.begin(), rs.end());
    }

    rep(i, k) {
        if (rs[i] == ls[i]) cout << rs[i] + 1 << endl;
    }
}


Measured memory_bytes: 5644
def partition(A, p, r):
    x = A[r-1]
    i = p-1
    for j in range(p,r):
        if A[j] <= x:
            i = i+1
            A[i], A[j] = A[j], A[i]
    return i+1

n = int(input())
A = list(map(int,input().split()))
num = partition(A, 0, n)
A[num-1] = f"[{A[num-1]}]"
print(*A)


Measured memory_bytes: 16396
#include <iostream>
#include <iosfwd>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <ctime>
#include <cmath>
#include <cassert>
#include <cctype>
#include <climits>
#include <vector>
#include <bitset>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <deque>
#include <string>
#include <list>
#include <iterator>
#include <sstream>
#include <complex>
#include <fstream>
#include <functional>
#include <numeric>
#include <utility>
#include <algorithm>
#include <assert.h>
#include <unordered_map>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef vector <long long> vll;
typedef pair <long long, long long> pll;
typedef pair <int, int> pii;
typedef vector <int> vii;
typedef complex <double> Point;

#define csl ios_base::sync_with_stdio(false); cin.tie(NULL)
#define mp make_pair
#define fst first
#define snd second

ll t, n, m, u, v, q, k;
const int N = 2e5 + 500;
const long long mod = 1e9 + 7;
const long long INF = 1LL << 61LL;

long long arr[N];
int main() {
  csl;
  cin >> n;
  int cnt = 0;
  for (int i = 1; i <= n; ++i) {
    cin >> arr[i];
    if (arr[i] & 1) cnt++;
  }
  if (cnt & 1) cout << "NO\n";
  else cout << "YES\n";
  return 0;
}













Measured memory_bytes: 1024