akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
using namespace std;

int main() {
    string w;
    int table[25] = {0};
    cin >> w;
    for(int i = 0;i < w.size();i++) {
        table[w[i] - 97]++;
    }
    for(int i = 0;i < 25;i++) {
        if(table[i] % 2 == 1) {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
}

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

const double PI = acos(-1);

int main(){
    int a, b, h, m;
    cin >> a >> b >> h >> m;
    double th = double(h*60+m)/720 * 2*PI;
    double tm = double(m)/60 * 2*PI;
    double xh = a*cos(th), yh = a*sin(th);
    double xm = b*cos(tm), ym = b*sin(tm);
    double dx = xh - xm, dy = yh - ym;
    double dis = sqrt(dx*dx+dy*dy);
    printf("%.10f\n", dis);
    return 0;
}

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

// 型定義
typedef long long ll;
typedef pair<ll, ll> P;

// forループ
#define REP(i,n) for(ll i=0; i<(ll)(n); ++i)

// 定数宣言
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

// グラフ表現
using Graph = vector<vector<int>>;

// グラフの辺表現
using Edge = map<pair<int,int>,int>;

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

// 最大公約数
ll gcd(ll a,ll b){
   if (a%b == 0) return(b);
   else return(gcd(b, a%b));
}

// 最小公倍数
ll lcm(ll a, ll b){
    return a*b/gcd(a, b);
}

int main()
{
    cout << fixed << setprecision(15);
    char S;
    cin >> S;

    if(isupper(S)){
        cout << 'A' << endl;
    }
    else{
        cout << 'a' << endl;
    }
    return 0;
}

Measured memory_bytes: 3668
import sys

n = int(input())

if n == 1:
    print(0)
    sys.exit()

count = 0
i = 2

while True:
    if i * i > n:
        break

    e = 0
    while n % i == 0:
        n = n // i
        e += 1
    curr = 1
    while e >= curr:
        e -= curr
        curr += 1
        count += 1
    i += 1

if n > 1:
    print(count + 1)
else:
    print(count)


Measured memory_bytes: 9188
//url:
//problem name:

#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); ++i)
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;}
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Pl = pair<long,long>;
using veci = vector<int>;
using vecl = vector<long>;
using vecveci = vector<vector<int>>;
using vecvecl = vector<vector<long,long>>;

int main() {
    ll A,B,C;
    cin >> A >> B >>C;
    ll ans = 0;
    if(A%2 == 0 && B%2 == 0 && C%2 == 0) {
        if(A == B && B == C) {
            cout << -1 << endl;
            return 0;
        } else 
        while(A%2 == 0 && B%2 == 0 && C%2 == 0) {
            ll a,b,c;
            a = A; b = B; c = C;
            A = b/2 + c/2;
            B = a/2 + c/2;
            C = a/2 + b/2;
            //cout << A << " " << B << " " << C << endl;
            ans++;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define int long long
 
#define rep(i,s,n) for(int i = (s);i<(n);i++)
#define repe(i,s,n) for(int i = (s);i<=(n);i++)
#define rrep(i,s,n) for(int i = (n)-1;i>=(s);i--)
#define all(v) (v).begin(),(v).end()
#define pb push_back
#define fi first
#define se second
typedef long long ll;
typedef pair<int,int>pint;
typedef vector<int>vint;
const ll MOD=1000000007,INF=1e18;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
 
 
 
 

 
signed main(){
    int a,b,h;
	cin>>a>>b>>h;
	cout<<(a+b)*h/2<<endl;
 
    
    
    
    return 0;
}

Measured memory_bytes: 256
a, b, c = list(map(int, input().split()))
k = int(input())
counta = 0
while b <= a:
    counta += 1
    b *= 2
    if counta>k:
        print('No')
        exit()

while c <= b:
    counta += 1
    c *= 2
    if counta>k:
        print('No')
        exit()
print('Yes')

Measured memory_bytes: 9180
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <iomanip>

#define REP(i,n) for(int i=0;i<n;++i)
#define RREP(i,n) for(int i=n-1;i>=0;--i)
#define FOR(i,m,n) for(int i=m;i<n;++i)
#define RFOR(i,m,n) for(int i=m-1;i>=n;--i)
#define ALL(v) v.begin(),v.end()
#define PB(a) push_back(a)
#define INF 1000000001
#define MOD 1000000007

using namespace std;


int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	REP(i, n) {
		int y, m, d, cnt = 0;
		cin >> y >> m >> d;
		bool b = y % 3 == 0;
		cnt += (1000 - y) * 195 + 5 * (333 - (y-1) / 3);
		cnt -= d - 1;
		if (b) {
			cnt -= (m-1) * 20;
		}
		else {
			if (m % 2 == 0) {
				cnt -= (m - 2) * 39 / 2 + 20;
			}
			else {
				cnt -= (m - 1) * 39 / 2;
			}
		}
		cout << cnt << endl;
		cnt = 0;
	}

	return 0;
}

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

int main()
{
    int N;
    int d[110];
    cin >> N;
    for (int i = 0; i < N; ++i)
        cin >> d[i];

    int num[110] = {0};
    for (int i = 0; i < N; ++i)
    {
        num[d[i]]++;
    }

    int res = 0;
    for (int i=1; i<=100; ++i){
        if (num[i]){
            ++res;
        }
    }

    cout << res << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <map>
#define ll long long
using namespace std;
int main(){
    int n,w;
    cin>>n>>w;
    vector<ll> vecw(n),vecv(n);
    for(int i=0;i<n;i++){
        cin>>vecw[i]>>vecv[i];
    }
    vector<vector<ll>> dp(105ll,vector<ll>(100005));
    
    for(int i=0;i<n;i++){
        for(int j=0;j<=w;j++){
            if(vecw[i]<=j){
                dp[i+1][j]=max(vecv[i]+dp[i][j-vecw[i]],dp[i][j]);
            }else{
                dp[i+1][j]=dp[i][j];
            }
        }
    }
    ll ans=-1;
    for(int i=0;i<n+1;i++){
        if(ans<dp[i][w]){
            ans=dp[i][w];
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 83328
N = int(input())
A = [int(x) for x in input().split()]


flag = True

for a in A:
    if a == 0:
        flag = False
        print(0)

if flag:
    res = 1
    for a in A:
        res = res * a
        if res > (10 ** 18):
            res = -1
            break
    print(res)


Measured memory_bytes: 21476
import math
p = math.pi
a,b,h,m = map(int,input().split())

mi = 6*m
ho = 30*h+m/2
t = abs(ho-mi)
t *=p
ans = math.sqrt(a**2+b**2-2*a*b*math.cos(t/180))
print('{:.18f}'.format(ans))

Measured memory_bytes: 9508
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i = 0; i < (n); i++)
#define INF 2 << 29
#define MOD 1000000007
#define Yes(f) puts((f)? "Yes" : "No")
#define YES(f) puts((f)? "YES" : "NO")
int gcd(int a, int b) {
	if (b != 0) return gcd(b, a % b);
	return a;
}
int lcm(int a, int b) {
	return a / gcd(a, b) * b;
}

using Graph = vector<vector<int>>;

int main(){
	int a, b, c, k; cin >> a >> b >> c >> k;
	if(k <= a) cout << k << endl;
	else cout << a - (k - a - b) << endl;
}


Measured memory_bytes: 3564
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>

using namespace std;

bool cmp(pair<int, int> a, pair<int, int> b) {
    if(a.second!=b.second) {
        return a.second > b.second;
    } else {
        return a.first < b.first;
    }
}

int main() {
    int n;
    cin >> n;
    
    int v[n];
    vector<pair<int, int> > ev;
    vector<pair<int , int> > od;
    for(int i=0; i<n; i++) {
        cin >> v[i];
        bool flag=true;
        if(i%2) {
            for(int j=0; j<ev.size(); j++) {
                if(ev[j].first==v[i]) {
                    ev[j].second++;
                    flag=false;
                    break;
                }
            }
            if(flag) {
                ev.push_back(make_pair(v[i], 1));
            }
        } else {
            for(int j=0; j<od.size(); j++) {
                if(od[j].first==v[i]) {
                    od[j].second++;
                    flag=false;
                    break;
                }
            }
            if(flag) {
                od.push_back(make_pair(v[i], 1));
            }
        }
    }

    od.push_back(make_pair(0, 0));
    ev.push_back(make_pair(0, 0));
    
    sort(od.begin(), od.end(), cmp);
    sort(ev.begin(), ev.end(), cmp);
    
    if(od[0].first!=ev[0].first) {
        cout << n - od[0].second - ev[0].second << endl;
    } else {
        if(od[0].second+ev[1].second>od[1].second+ev[0].second) {
            cout << n - od[0].second - ev[1].second << endl;
        } else {
            cout << n - od[1].second - ev[0].second << endl;
        }
    }

    return 0;
    
}

Measured memory_bytes: 1660
#include<bits/stdc++.h>
using namespace std;
#define arep(i,x,n) for(int i=int(x);i<(int)(n);i++)
#define rep(i,n) for(long long i = 0;i < n;++i)
#define rrep(i,n) for(int i=int(n-1);i>=0;i--)
#define fs first
#define sc second
#define all(x) (x).begin(), (x).end()
#define pi 3.141592653589793
#define eps 0.00000001
#define INF 1e9+7  
using ll = long long; 
using P=pair<int,int>;
using lP=pair<ll,ll>;
using fP=pair<double,double>;
using PPI=pair<P,int>;
//ll const mod=998244353;
ll const mod=1e9+7;
const ll MAX=300000;
using vi=vector<int>;
using vl=vector<ll>;
using vc=vector<char>;
using vd=vector<double>;
using vs=vector<string>;
using vp=vector<P>;
using vb=vector<bool>;
using vvi =vector<vector<int>>;
using vvd=vector<vector<double>>;
using vvc=vector<vector<char>>;
using vvp =vector<vector<P>>;
using vvb=vector<vector<bool>>;
template <typename T>
bool chmax(T &a, const T b){if(a < b){a = b; return true;} return false;}
template <typename T>
bool chmin(T &a, const T b){if(a > b){a = b; return true;} return false;}


//////////////////////////////////////
vvi node;
int n,k;
ll dfs(int now,int par){
  ll res=1;
  int n=node[now].size()-1;//other than par
  rep(i,n)(res*=max(0LL,(k-2-i)))%=mod;
  for(auto x:node[now]){
    if(x==par)continue;
    (res*=dfs(x,now))%=mod;
  }

  return res;
}


int main(){
    
    cin>>n>>k;
    node.resize(n);
    rep(i,n-1){
      int a1,a2;
      cin>>a1>>a2;
      a1--;a2--;
      node[a1].push_back(a2);
      node[a2].push_back(a1);
    }
    ll ans=k;
    int in=node[0].size();
    rep(i,in)(ans*=(k-1-i))%=mod;
    for(auto x:node[0]){
      (ans*=dfs(x,0))%=mod;
    }
    cout<<ans<<endl;
    
    return 0;
}

Measured memory_bytes: 10368
#include <stdio.h>
#include <string.h>
#include <math.h>
int main(void){
  int k,s,x,y,cnt=0;
  scanf("%d%d",&k,&s);
  for(x=0;x<=k;x++){
    for(y=0;y<=k;y++){
      int z=s-x-y;
      if(z>=0&&z<=k) cnt++;
    }
  }
  printf("%d",cnt);
  return 0;
}

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


using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

//math
//-------------------------------------------
template<class T> inline T sqr(T x) { return x*x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define EXISTch(s,c) ((((s).find_first_of(c)) != std::string::npos)? 1 : 0)//cがあれば1 if(1)
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  FOR(i,0,n)
#define loop(n) FOR(i,0,n)
#define rrep(i,a,b) for(int i=(a);i>=(b);--i)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = (int)1000000007;
const LL MOD = (LL)1000000007;//10^9+7
const LL INF2 = (LL)100000000000000000;//10^18

int main() {
	
	while (1) {
		int h, w; cin >> h >> w;

		if (h == 0 && w == 0)break;

		for (int i = 0; i < h; i++) {
			for (int j = 0; j < w; j++) {
				cout << "#";
			}
			cout << endl;
		}
		cout << endl;
	}
	return 0;
}


Measured memory_bytes: 3088
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;
using System.Diagnostics;

class Myon
{
    public Myon() { }
    public static int Main()
    {
        new Myon().calc();
        return 0;
    }

    Scanner cin;

    void calc()
    {
        cin=new Scanner();
        int N=cin.nextInt();

        int num=N*(N-1)/2-N/2;
        Console.WriteLine(num);
        for(int i=1;i<=N;i++){
            for(int j=1;j<i;j++){
                if(i+j==(((N/2)*2)+1)){
                    ;
                }else{
                    Console.WriteLine(string.Format("{0} {1}",j,i));
                }
            }
        }
        //Console.WriteLine(string.Join("\n", ans));

    }


}



class Scanner
{
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner()
    {
        s = new string[0];
        i = 0;
    }

    public string next()
    {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

    public int nextInt()
    {
        return int.Parse(next());
    }
    public int[] ArrayInt(int N, int add = 0)
    {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextInt() + add;
        }
        return Array;
    }

    public long nextLong()
    {
        return long.Parse(next());
    }

    public long[] ArrayLong(int N, long add = 0)
    {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextLong() + add;
        }
        return Array;
    }

    public double nextDouble()
    {
        return double.Parse(next());
    }


    public double[] ArrayDouble(int N, double add = 0)
    {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextDouble() + add;
        }
        return Array;
    }
}


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

int main () {
  int N;
  cin >> N;
  int sum = 0;
  for ( int i = 0; i < N; i++) {
    int l, r;
    cin >> l >> r;
    sum += r - l + 1;
  }
  cout << sum << endl;
}
    

Measured memory_bytes: 256
using System;
using System.Linq;

namespace abc126A
{
    class Program
    {
        static void Main(string[] args)
        {
            int a = int.Parse(Console.ReadLine());
            int a2 = a % 100;
            int a1 = (a - a2)/100;
            bool ym = false;
            bool my = false;
            if (a1 <= 12 && a1 > 0) ym = true;
            if (a2 <= 12 && a2 > 0) my = true;
            if (ym == true && my == true) Console.WriteLine("AMBIGUOUS");
            if (ym == true && my == false) Console.WriteLine("MMYY");
            if (ym == false && my == true) Console.WriteLine("YYMM");
            if (ym == false && my == false) Console.WriteLine("NA");
        }

    }
}


Measured memory_bytes: 27444
def resolve():
    A,B,C,X = [int(input()) for i in range(4)]

    res = 0
    mA = min(X//500, A)
    for i in range(mA+1):
        Y = X - 500 * i
        mB = min(Y//100, B)
        for j in range(mB+1):
            Z = Y - 100 * j
            if Z <= 50*C:
                res += 1

    print(res)
    
resolve()

Measured memory_bytes: 3060
from heapq import heappop as pop, heappush as push

peak, curr = 0, 0

stuff = []
n, c = map(int, raw_input().split())
for _ in xrange(n):
  stuff.append(map(float, raw_input().split()))
  stuff[-1][-1] = int(stuff[-1][-1]) - 1
  
stuff = sorted(stuff)
has_camera = [False] * c
last_ending = [-1] * c
ending = []
for st, end, ch in stuff:
  while ending and ending[0][0] <= st - 0.5:
    cend, cch = pop(ending)
    if last_ending[cch] == cend:
        has_camera[cch] = False
        curr -= 1
  if not has_camera[ch]:
    has_camera[ch] = True
    curr += 1
  push(ending, (end, ch))
  last_ending[ch] = end
  peak = max(peak, curr)
  
print peak



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

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

    vector<int> nums(N);
    for (int i = 0; i < N; i++)
        cin >> nums.at(i);

    vector<int> packet(N + 1, 0);
    for (int x : nums)
        packet.at(x)++;

    sort(packet.begin(), packet.end());
    reverse(packet.begin(), packet.end());

    int ans = 0;
    for (int i = K; i <= N; i++)
    {
        ans += packet.at(i);
    }

    cout << ans << endl;
}

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

int main() {
  int n, k;
  int ans;
  cin  >> n >> k;

  for(int i = 0; i < n; i++) {
    if(i == 0) {
      ans = k;
    } else {
      ans *= k-1;
    }
  }
  cout << ans << endl;
}



Measured memory_bytes: 3636
#include<iostream>
main(){std::string l[9]={"',.!?","abcABC","defDEF","ghiGHI","jklJKL","mnoMNO","pqrsPQRS","tuvTUV","wxyzWXYZ"},s,a;for(int i,c,t;std::cin>>s;std::cout<<a<<"\n"){for(s+=1,a="",c=i=0;++i<s.size();c++)if(s[i-1]-s[i]){if(s[i-1]-48){t=s[i-1]-49;a+=l[t][c%l[t].size()];}c=-1;}else if(s[i]==48)a+=32;}}

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

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

  map<string, int> m;
  m["SUN"] = 7;
  m["MON"] = 6;
  m["TUE"] = 5;
  m["WED"] = 4;
  m["THU"] = 3;
  m["FRI"] = 2;
  m["SAT"] = 1;

  cout << m[s] << endl;

  return 0;
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}

const int MAX_N = 123456;
int dist[MAX_N];
vi v[MAX_N];

int dfs(int x){
    if(v[x].size()==0){
        dist[x] = 0;
        return 0;
    }
    int res = 0;
    rep(i,v[x].size()){
        int tmp = 0;
        if(dist[v[x][i]]==-1){
            tmp = dfs(v[x][i]) + 1;
        }else{
            tmp = dist[v[x][i]] + 1;
        }
        res = max(res,tmp);
    }
    dist[x] = res;
    return res;
}

int main() {
    rep(i,MAX_N){
        dist[i] = -1;
    }
    int n,m;
    cin >> n >> m;

    
    rep(i,m){
        int x,y; cin >> x >> y;
        v[x].push_back(y);
    }
    int ans = 0;

    srep(i,1,n+1){
        if(dist[i] == -1){
            int tmp = dfs(i);
        }
    }

    srep(i,1,n+1){
        ans = max(ans,dist[i]);
    }

    cout << ans << endl;
    return 0;
}
 
 


Measured memory_bytes: 8832
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using tlll=tuple<ll,ll,ll>;
using vs=vector<string>;

#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define range(i,a,n) for(int i=(a);i<(n);i++)

#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI 3.1415926535897932384

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

template<class T>bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T>bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
template<class S>S acm(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
void YN(bool b){cout<<(b?"YES":"NO")<<"\n";}
void Yn(bool b){cout<<(b?"Yes":"No")<<"\n";}
void yn(bool b){cout<<(b?"yes":"no")<<"\n";}
int sgn(const double&r){return (r>EPS)-(r<-EPS);} // a>0  : sgn(a)>0
int sgn(const double&a,const double&b){return sgn(a-b);} // b<=c : sgn(b,c)<=0

ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}
template<class T>void puta(T&&t){cout<<t<<"\n";}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1; for(auto s:t){os<<(a?"":" ")<<s;a=0;} return os;}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n,k;
	vl sc(3);
	string t;
	cin>>n>>k>>sc[0]>>sc[1]>>sc[2]>>t;
	vl op(n);
	rep(i,n){
		if(t[i]=='r')op[i]=2;
		if(t[i]=='s')op[i]=0;
		if(t[i]=='p')op[i]=1;
	}
	ll ans=0;
	rep(i,k){
		ll len=(n-i-1)/k+1;
		vvl dp(3,vl(len,0));
		rep(j,len){
			rep(l,3){
				if(j==0){if(op[i]==l)dp[l][j]=sc[l];}
				else{
					rep(q,3){
						if(l==q)continue;
						chmax(dp[l][j],dp[q][j-1]+(op[j*k+i]==l?sc[l]:0));
					}
				}
			}
		}
		//rep(j,3)puta(i,j,dp[j]);
		ans+=max({dp[0].back(),dp[1].back(),dp[2].back()});
		//puta(ans);
	}
	
	cout<<ans<<endl;
}


Measured memory_bytes: 4304
num_card = [[int(i) for i in input().split()] for _ in range(3)]
n = int(input())
b_array = [int(input()) for _ in range(n)]

card = [[False for _ in range(3)] for _ in range(3)]

for b in b_array:
    for i in range(3):
        for j in range(3):
            if num_card[i][j] == b:
                card[i][j] = True

bingo = False

for i in range(3):
    if all(card[i]):
        bingo = True
        break
    if all((card[0][i], card[1][i], card[2][i])):
        bingo = True
        break

if all([card[i][i] for i in range(3)]):
    bingo = True

if all([card[i][2-i] for i in range(3)]):
    bingo = True

print("Yes" if bingo else "No")


Measured memory_bytes: 3064
#include <iostream>
#include <cstring>
#include <algorithm>
using namespace std;
int t;
char s[1001];
int main()
{
	cin>>s;
	int l=strlen(s);
	for(int i=0;i<l;i++)
	{
		if(s[i]=='C') t=1;
		if(t==1&&s[i]=='F') cout<<"Yes",exit(0);
	}
	cout<<"No";
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define mem(a) memset(a,0,sizeof(a))
#define dbg(x) cout<<#x<<" = "<<x<<endl
#define ll long long
//不要再爆long long了！！！！！！！！不要再爆long long了！！！！！！！ 
bool a[111]={0};
int main()
{
	int x,n,i,t;
	cin>>x>>n;
	for(i=0;i<n;i++)
	{
		cin>>t;
		a[t]=1;
	}
	i=1;
	if(!a[x])cout<<x;
	else while(1)
	{
		if(!a[x-i]){cout<<x-i;return 0;}
		else if(!a[x+i]){cout<<x+i;return 0;}
		i++;
	}
	return 0;
}

Measured memory_bytes: 3592
#include <iostream>
#include <string>
#include <vector>

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

using std::cin;
using std::cout;
using std::endl;
using std::string;
using std::vector;

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

  int sum = 0;
  for (char c : S) {
    if (c == 'o') sum++;
  }

  cout << 700 + sum * 100 << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")

#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()

using ll = long long;
using ull = unsigned long long;
using namespace std;

int main() {
    int A, B;
    cin >> A >> B;
    if (A - B*2 < 0) {
        cout << 0 << endl;
    } else {
        cout << A - B*2 << endl;
    }
    return 0;
}


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

using namespace std;

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

int main(){
    int num[3];
    cin >> num[0] >> num[1] >> num[2];
    
    int max = *max_element(num, num+3);
    int min = *min_element(num, num+3);

    cout << max-min << endl;
}


Measured memory_bytes: 256
use proconio::input;
 
fn main() {
  input! {
    N: i32,
    X: [i32;N as usize]
  }
  let mut total = 0;
  for v in X.iter() {
    total += v;
  }

  let average = total / N;
  let mut min = i32::max_value();
  min = std::cmp::min(min, helper(&X, average - 1));
  min = std::cmp::min(min, helper(&X, average));
  min = std::cmp::min(min, helper(&X, average + 1));

  println!("{}", min);
}
  
fn helper(arr: &[i32], val: i32) -> i32 {
  let mut total = 0;
  for v in arr.iter() {
    total += (v - val).pow(2);
  }
  total
}

Measured memory_bytes: 2112
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin>>s;
  int p=s.size();
  int q=(s[0]==s[s.size()-1]);
  if(q&&p%2||!q&&p%2==0)cout<<"Second"<<endl;
  else cout<<"First"<<endl;
}

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

typedef long long int ll;
typedef vector<long long>lve;
typedef vector<pair<ll,ll> > lvp;
typedef vector<vector<int> > ivve;

#define sp         ' '
#define endl       '\n'
#define F          first
#define S          second
#define pp         pop_back`
#define pb         push_back
#define mp         make_pair 
#define GCD(x,y)   __gcd(x,y)
#define lb         lower_bound
#define up         upper_bound
#define setp       setprecision
#define bs         binary_search
#define all(x)     x.begin(),x.end()
#define LCM(x,y)   ((x*y)/__gcd(x,y))
#define spc(x)     cout<<fixed<<setp(x)

const   long long  inf = 1e18;
const   long long  cs =  200005;
const   long long  mod = 1000000007;
const   double     PI =  2 * acos(0.0);
ll v1[cs],v2[cs];
void solve()
{
    ll t,n,m,a,b,c,d,e,i,j,k,x,y,z,cnt=0,cnt1=0;
    bool flag = false;   
    
    cin>>n>>k;
    lve v(n);
    for(auto &ss:v) cin>>ss;
    for(auto &ss:v)
    {
        if(ss>=k) cnt++;
    }
    cout<<cnt<<endl;

}
int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);    cout.tie(NULL);

    // freopen ("input.txt","r",stdin);
    // freopen ("output.txt","w",stdout);

    // int32_t tc;
    // cin>>tc;
    // while(tc--)
    solve();

    return 0;
}


Measured memory_bytes: 3984
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
using ll = long long;
const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-8;
const int MOD = 1000000007;
// const int MOD = 998244353;
const int dy[] = {1, 0, -1, 0}, dx[] = {0, -1, 0, 1};
const int dy8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dx8[] = {0, -1, -1, -1, 0, 1, 1, 1};
template <typename T, typename U> inline bool chmax(T &a, U b) { return a < b ? (a = b, true) : false; }
template <typename T, typename U> inline bool chmin(T &a, U b) { return a > b ? (a = b, true) : false; }
struct IOSetup {
  IOSetup() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);
  }
} iosetup;

int main() {
  int n, k; cin >> n >> k;
  vector<int> p(n), c(n);
  REP(i, n) cin >> p[i], --p[i];
  REP(i, n) cin >> c[i];
  ll ans = -LINF;
  REP(s, n) {
    vector visited(n, false);
    vector<int> cs;
    int pos = p[s];
    ll sum = 0;
    while (!visited[pos]) {
      visited[pos] = true;
      cs.emplace_back(pos);
      sum += c[pos];
      if (cs.size() <= k) chmax(ans, sum);
      pos = p[pos];
    }
    if (cs.size() >= k) continue;
    vector<int> loop;
    ll sum2 = 0;
    while (cs.back() != pos) {
      sum -= c[cs.back()];
      sum2 += c[cs.back()];
      loop.emplace_back(c[cs.back()]);
      cs.pop_back();
    }
    sum -= c[pos];
    sum2 += c[pos];
    loop.emplace_back(c[pos]);
    cs.pop_back();
    reverse(ALL(loop));
    ll rem = k - cs.size();
    assert(rem > loop.size());
    sum2 *= rem / loop.size() - 1;
    (rem %= loop.size()) += loop.size();
    chmax(ans, sum + sum2);
    for (int i = 0; rem--; (i += 1) %= loop.size()) {
      sum2 += loop[i];
      chmax(ans, sum + sum2);
    }
  }
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 3748
def collatz(n)
  if n == 1
    n
  elsif n % 2 == 0
    n /= 2
  elsif n % 2 == 1
    n = n * 3 + 1
  end
end

while line = gets
  n = line.chomp.to_i
  break if n == 0

  c = 0
  until n == 1
    n = collatz(n)
    c += 1
  end

  puts c
end

Measured memory_bytes: 8496
#include <cassert>
#include <cmath>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <limits.h>
#include <map>
#include <queue>
#include <string.h>
#include <vector>

using namespace std;
typedef long long ll;

const int MAX_N = 200010;

class UnionFind {
public:
  vector<int> parent;
  vector<int> rank;
  vector<int> _size;

  void init(int n) {
    for (int i = 0; i < n; ++i) {
      parent.push_back(i);
      rank.push_back(0);
      _size.push_back(1);
    }
  }

  int find(int x) {
    if (parent[x] == x) {
      return x;
    } else {
      return parent[x] = find(parent[x]);
    }
  }

  void unite(int x, int y) {
    x = find(x);
    y = find(y);
    if (x == y) return;

    if (rank[x] < rank[y]) {
      parent[x] = y;
      _size[y] += _size[x];
    } else {
      parent[y] = x;
      _size[x] += _size[y];
      if (rank[x] == rank[y]) ++rank[x];
    }
  }

  bool same(int x, int y) {
    return find(x) == find(y);
  }

  int size(int x) {
    return _size[find(x)];
  }
};

int main() {
  int N, Q;

  cin >> N >> Q;
  UnionFind uf;
  uf.init(MAX_N);

  int t, u, v;
  for (int i = 0; i < Q; ++i) {
    cin >> t >> u >> v;

    if (t == 0) {
      uf.unite(u, v);
    } else {
      if (uf.same(u, v)) {
        cout << 1 << endl;
      } else {
        cout << 0 << endl;
      }
    }
  }

  return 0;
}


Measured memory_bytes: 5896
//
// Created by yamunaku on 2020/06/27.
//

#include <bits/stdc++.h>

using namespace std;

#define rep(i, n) for(ll i = 0; i < (n); i++)
#define repl(i, l, r) for(int i = (l); i < (r); i++)
#define per(i, n) for(int i = ((n)-1); i >= 0; i--)
#define perl(i, l, r) for(int i = ((r)-1); i >= (l); i--)
#define all(x) (x).begin(),(x).end()
#define MOD9 998244353
#define MOD 1000000007
#define IINF 1000000000
#define LINF 1000000000000000000
#define SP <<" "<<
#define CYES cout<<"Yes"<<endl
#define CNO cout<<"No"<<endl
#define CFS cin.tie(0);ios::sync_with_stdio(false)
#define CST(x) cout<<fixed<<setprecision(x)

using ll = long long;
using ld = long double;
using vi = vector<int>;
using mti = vector<vector<int>>;
using vl = vector<ll>;
using mtl = vector<vector<ll>>;
using pi = pair<int, int>;
using pl = pair<ll, ll>;
template<typename T>
using heap = priority_queue<T, vector<T>, function<bool(const T, const T)>>;

int main(){
    //CFS;
    ll n;
    cin >> n;
    vl a(n);
    rep(i, n){
        cin >> a[i];
    }
    ll x = 0;
    repl(i, 2, n){
        x ^= a[i];
    }
    ll a1 = a[0] >> 20;
    ll a2 = a[0] & ((1 << 20) - 1);
    ll b1 = a[1] >> 20;
    ll b2 = a[1] & ((1 << 20) - 1);
    ll x1 = x >> 20;
    ll x2 = x & ((1 << 20) - 1);

    ll ans0 = LINF, ans1 = LINF, ans2 = LINF, ans3 = LINF;
    rep(i, 1 << 20){
        if(a1 > i)
            if(((a1 - 1 - i) ^ (b1 + 1 + i)) == x1){
                ans0 = min(ans0, i);
            }
        if(a1 > i)
            if(((a1 - 1 - i) ^ (b1 + i)) == x1){
                ans1 = min(ans1, i);
            }
        if(a1 >= i)
            if(((a1 - i) ^ (b1 + 1 + i)) == x1){
                ans2 = min(ans2, i);
            }
        if(a1 >= i)
            if(((a1 - i) ^ (b1 + i)) == x1){
                ans3 = min(ans3, i);
            }
    }
    ll ans = LINF;
    rep(i, 1 << 20){
        if(a2 < i){
            if(b2 + i >= (1 << 20)){
                if(((a2 - i + (1 << 20)) ^ (b2 + i - (1 << 20))) == x2){
                    ans = min(ans, (ans0 << 20) + i);
                }
            }else{
                if(((a2 - i + (1 << 20)) ^ (b2 + i)) == x2){

                    ans = min(ans, (ans1 << 20) + i);
                }
            }
        }else{
            if(b2 + i >= (1 << 20)){
                if(((a2 - i) ^ (b2 + i - (1 << 20))) == x2){

                    ans = min(ans, (ans2 << 20) + i);
                }
            }else{
                if(((a2 - i) ^ (b2 + i)) == x2){

                    ans = min(ans, (ans3 << 20) + i);
                }
            }
        }
    }
    if(ans >= a[0]) cout << -1 << endl;
    else cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3628
/* Author : Aaryan Srivastava ^__^ */ 
#include <bits/stdc++.h>
#include <random>
#include <chrono>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
#define pb push_back
#define mp make_pair
#define ff first
#define ss second   
#define rep(i,n) for(int i = 0 ; i < (n) ; i++)
#define repA(i,x,y) for(int i = (x) ; i <= (y) ; i++)
#define repD(i,x,y) for(int i = (x) ; i >= (y) ; i--)
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define setval(a,val) memset(a,val,sizeof(a))
#define Randomize mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define trav(x , a) for(auto &x : a)
#define sz(a) ((int)a.size())
typedef long long ll ; 

#define int ll

using namespace std;

const int N = 3e5 +5 ;
const int mod = 1e9 + 7 ;
const ll inf = 1e18 ;
const int SZ = 101 ;
const double eps = 1e-9 ;
using namespace __gnu_pbds;
using ordered_set =  tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ;

typedef pair<int, int> pii; 
typedef pair<int , pii> ipii ;
typedef pair<pii , int> piii ; 
typedef unsigned long long ull ;
typedef long double ld;

ll po(ll x,ll y,ll p = mod) {ll res=1;x%=p;while(y>0){if(y&1)res=(res*x)%p;y=y>>1;x=(x*x)%p;}return res;}

vector<int> g[N];
int cnt[3];
int vis[N];
bool isbipar = true;
int edg = 0;

void dfs(int u , int col){
    cnt[col]++;
    vis[u] = col;
    trav(v , g[u]){
        edg++ ;        
        if(!vis[v]){
            dfs(v , 3 - col);
        }else{
            if(vis[v] == vis[u]){
                isbipar = false;
            }
        }
    }
}


void solve()
{
    // bipartite =>
    // nahi to pura

    int n , m;
    cin >> n >> m ;
    int tot = n * (n - 1) / 2; 
    rep(i , m){
        int x,  y;
        cin >> x >> y;
        g[x].pb(y);
        g[y].pb(x);
    }
    int ans = 0 ;
    repA(i , 1 , n){
        if(!vis[i]){
            rep(j , 3) cnt[j] = 0;
            isbipar = true ;
            edg = 0;
            dfs(i , 1);
            if(!isbipar){
                int k = cnt[1] + cnt[2];
                edg /= 2;
                ans += (k * (k - 1) / 2 - edg);
            }else{
                edg /= 2;
                ans += cnt[1] * cnt[2] - edg ;
            }
        }
    }
    cout << ans;

}   

     
int32_t main(int32_t argc, char *argv[])
{
    ios::sync_with_stdio(0);    
    cin.tie(0); cout.tie(0);
    int TC = 1, t = 0;
    //cin >> TC ;
    while(t++ < TC)
    {
        //cout << "Case #" << t << ": " ;
        solve();
        cout << "\n" ;
    }
    return 0;
}

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

int main(){
  int x[5];
  for(int i = 0; i < 5;i++){
    cin >> x[i]; 
  }
  int s;
  for(int i = 0; i < 5;i++){
    if(x[i] == 0)  s = i + 1;
  }
  cout << s << endl;
}

Measured memory_bytes: 3592
#include <functional>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;
const ll MOD = 1000000007LL;

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

    int h, n;
    cin >> h >> n;

    vector <int> a(n), b(n);
    for (int i = 0; i < n; i++) cin >> a[i] >> b[i];

    // iこめの魔法までで、体力jを削るのに必要な魔力の最小値
    vector <int> dp(h + 10005, 1000000000);
    dp[0] = 0;

    for (int i = 0; i < n; i++) {
        for (int j = 0; j <= h; j++) {
            dp[j + a[i]] = min(dp[j + a[i]], dp[j] + b[i]);
        }
    }

    int mn = MOD;
    for (int j = h; j < h + 10005; j++) {
        mn = min(mn, dp[j]);
    }

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

Measured memory_bytes: 888
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  long long n;
  cin >> n;
  long long a[5]={0};
  for(int i=0;i<n;i++){
    string s;
    cin >> s;
    if(s[0]=='M')a[0]++;
    if(s[0]=='A')a[1]++;
    if(s[0]=='R')a[2]++;
    if(s[0]=='C')a[3]++;
    if(s[0]=='H')a[4]++;
  }
  long long ans=0;
  for(int i=0;i<5;i++)for(int j=i+1;j<5;j++)for(int k=j+1;k<5;k++)ans+=a[i]*a[j]*a[k];
  cout << ans << endl;
}

Measured memory_bytes: 256
N = gets.to_i
A = gets.split.take(N).map(&:to_i).map(&:pred)

def f(a)
  a = a.dup
  res = 0
  a.each_index{|i|
    if a[i] == i
      if i < a.size - 1
        a[i], a[i + 1] = a[i + 1], a[i]
      else
        a[i], a[i - 1] = a[i - 1], a[i]
      end
      res += 1
    end
  }
  res
end

def g(a)
  a = a.dup
  res = 0
  a.each_index{|i|
    if a[i] == i
      if i > 0
        a[i], a[i - 1] = a[i - 1], a[i]
      else
        a[i], a[i + 1] = a[i + 1], a[i]
      end
      res += 1
    end
  }
  res
end

p [f(A), g(A)].min


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

public class Main {
    public static void main(String[] args) {
        FastScanner fs = new FastScanner();
        int N = fs.nextInt(), M = fs.nextInt();
        int pro[] = new int[N + 1];
        int AC = 0, PN = 0;
        for (int i = 0; i < M; i++) {
          int P = fs.nextInt();
          String S = fs.next();
          if (S.equals("WA") && pro[P] != -1) pro[P]++;
          if (S.equals("AC") && pro[P] != -1) {
            AC++;
            PN += pro[P];
            pro[P] = -1;
          }
        }
        System.out.println(AC + " " + PN);
    }
}

class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;

    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        } else {
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }

    private int readByte() {
        if (hasNextByte())
            return buffer[ptr++];
        else
            return -1;
    }

    private static boolean isPrintableChar(int c) {
        return 33 <= c && c <= 126;
    }

    public boolean hasNext() {
        while (hasNextByte() && !isPrintableChar(buffer[ptr]))
            ptr++;
        return hasNextByte();
    }

    public String next() {
        if (!hasNext())
            throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while (isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }

    public long nextLong() {
        if (!hasNext())
            throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while (true) {
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            } else if (b == -1 || !isPrintableChar(b)) {
                return minus ? -n : n;
            } else {
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }

    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
            throw new NumberFormatException();
        return (int) nl;
    }

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


Measured memory_bytes: 35284
#include<cstdio>
#include<iostream>
using namespace  std;
int main(){
	char x;
	while (1){
		x = getchar();
		if (x == ',')cout << " ";
		else if (x != '\n'){
			cout << x;
		}
		else{
			cout << endl;
			break;
		}
	}
}

Measured memory_bytes: 256
/**Bismillahir Rahmanir Rahim.**/

/**
 *    author:  nasimnoob
**/

#include<bits/stdc++.h>
#include<stdlib.h>
#include<iostream>
#include<vector>
#include<math.h>
#include<cstring>
#include<cstdio>

using namespace std;

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

typedef long long int                        ll;
typedef unsigned long long int              ull;
typedef long double                          ld;

//-----------------------------------------------------------//
#define      test                       int t; cin>>t;  while(t--)

#define      cube(x)                    (x*x*x)
#define      sqr(x)                     (x*x)

#define      INPUT                      freopen("input.txt", "r", stdin)
#define      OUTPUT                     freopen("output.txt", "w", stdout)

#define      srev                       reverse(s.begin(),s.end())
#define      sortstr                    sort(s.begin(), s.end());
#define      gtl(x)                     getline(cin, (x))
#define      dot(x)                     fixed << setprecision(x)

#define      Case                       cout << "Case " << ++tt << ": " ;

#define      PI                         acos(-1) // 3.1415926535897932
#define      MIN                        9999999

#define      Faster                     ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);




//scanf("%[^\n]%*c", str);
//sort(s,s+n,greater<int>());
//freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdout);


//--------------------------------------Solution------------------------------//

int main()
{

    #ifndef ONLINE_JUDGE
    clock_t tStart = clock();
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif

    Faster;


    int tt = 0 ;

    string s;
    int n ;

    cin >> n;

    if (n == 0)
        cout << 1 << endl;
    else 
        cout << 0 << endl;

    #ifndef ONLINE_JUDGE
    fprintf(stderr, "\n>> Runtime: %.10fs\n", (double) (clock() - tStart) / CLOCKS_PER_SEC);
    #endif


    return 0 ;
}


Measured memory_bytes: 3648
# -*- coding: utf-8 -*-
import sys
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
input=lambda: sys.stdin.readline().rstrip()
YesNo=lambda b: bool([print('Yes')] if b else print('No'))
YESNO=lambda b: bool([print('YES')] if b else print('NO'))
int1=lambda x:int(x)-1

N=int(input())
a=tuple(map(int,input().split()))
ans=1
if 0 in a:
    print(0)
else:
    for i in a:
        ans*=i
        if ans>10**18:
            print(-1)
            exit()
    print(ans)

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



#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)

using namespace std;

template <class T>
using vec = std::vector<T>;
typedef long long ll;
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; }

const long long INF = 1LL<<60;

int lcm(int a,int b){
    //最小公倍数
    return a/__gcd(a,b) * b;
}

double n,m;


int main()
{
    cin>>n>>m;
    double all=0;
    vec<double> a(n,0);
    rep(i,n){
        cin>>a[i];
        all+=a[i];
    }
    double line=all/(4*m);

    double count=0;
    rep(i,n){
        if(a[i]>=line){
            count++;
        }
    }

    if(count>=m){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }

    // cout<<line<<endl;

    return 0;

}




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

int main(){
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int k, n;
  cin >> k >> n;
  vector <int> a(n);
  for (int i = 0; i < n; ++i){
	cin >> a[i];
  }
  sort(a.begin(),a.end());
  vector <int> d(n);
  d[0] = k - a[n-1] + a[0];
  for (int i = 1; i < n; ++i){
	d[i] = a[i] - a[i-1];
  }
  int b = *max_element(d.begin(),d.end());
  cout << k - b << "\n";
  
return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;

int N, M, p;
int d[100010];
int R[100010];
int L[100010];

int goR(int from, int to) {
  return (to - from + N) % N;
}

int goL(int from, int to) {
  return (from - to + N) % N;
}

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  cin >> N >> M >> p;
  for (int i = 0; i < M; i++) {
    cin >> d[i];
  }
  sort(d, d + M);
  int pos = 0;
  fill_n((int*)R, N, d[0]);
  for (int i = 0; i < N; i++) {
    if (i < d[pos]) R[i] = d[pos];
    else if (pos + 1 < M) R[i] = d[++pos];
  }
  fill_n((int*)L, N, d[M - 1]);
  pos = M - 1;
  for (int i = N - 1; i >= 0; i--) {
    if (i > d[pos]) L[i] = d[pos];
    else if (pos > 0) L[i] = d[--pos];
  }
  int ans = min(goR(p, L[p]), goL(p, R[p]));
  for (int i = 0; i < M; i++) {
    ans = min(ans, goR(p, d[i]) + goL(d[i], R[d[i]]));
    ans = min(ans, goL(p, d[i]) + goR(d[i], L[d[i]]));
  }
  cout << ans * 100 << endl;

  return 0;
}


Measured memory_bytes: 3944
#include <stdio.h>
#include <stdlib.h>

#define N 100

int compare(const void *a, const void *b) {
	int ia = *(int *) a;
	int ib = *(int *) b;
	
	return ib - ia;
}

int main() {
	static int aa[N];
	int n, i, sum1, sum2;

	scanf("%d", &n);
	for (i = 0; i < n; i++)
		scanf("%d", &aa[i]);
	qsort(aa, n, sizeof *aa, compare);
	sum1 = 0;
	for (i = 0; i < n; i += 2)
		sum1 += aa[i];
	sum2 = 0;
	for (i = 1; i < n; i += 2)
		sum2 += aa[i];
	printf("%d\n", sum1 - sum2);
	return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define REP(i, m, n) for(int (i) = (m); (i) < (n); ++i)
#define rep(i, n) REP(i, 0, n)
#define all(x) (x).begin(), (x).end()
using namespace std;
using Graph = vector<vector<int>>;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
typedef long long ll;
typedef pair<ll, ll> P;
const int INF = 1e9+7;
const ll LINF = 1LL<<60;

int main()
{
    cin.tie(0);
    ios_base::sync_with_stdio(0);
    int n, m, x;
    cin >> n >> m >> x;
    vector<int> A(n + 1, 0);
    rep(i, m) {
        int a;
        cin >> a;
        A[a] = 1;
    }

    int c = 0;
    rep(i, x+1) {
        c += A[i];
    }

    int d = 0;
    REP(i, x, n+1) {
        d += A[i];
    }

    cout << min(c, d) << endl;
    

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n,m,sum=0;
  cin>>n>>m;
  int arr[m];
  for(int i=0;i<m;i++){
    cin>>arr[i];
    sum+=arr[i];
  }
  if(sum>n)cout<<-1;
  if(sum==n)cout<<0;
  if(sum<n)cout<<n-sum;
  
}

Measured memory_bytes: 3624
function Main(input) {
  input = input.split("\n");
  var S = input[0].split("");
  var a = parseInt(S[0]+S[1]);
  var b = parseInt(S[2]+S[3]);
  var ans="NA";
  if(a<13&&a>0&&b<13&&b>0){
    ans="AMBIGUOUS";
  }else if(a<13&&a>0&&(b>12||b==0)){
    ans="MMYY";
  }else if((a>12||a==0)&&b<13&&b>0){
    ans="YYMM";
  }

  console.log('%s', ans);
  return ans;
}

function debug(n){
  var input = document.getElementById("input"+n).value;
  var ans=Main(input);
  var result="WA";
  if(ans==document.getElementById("output"+n).value.split("\n")[0]){
    result="AC";
  }
  document.getElementById("result"+n).innerHTML=result;
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 21064