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

using namespace std;

int n, x[3], ta;

int main() {
	scanf("%d", &n);
	while (n--) {
		scanf("%d", &ta);
		if (ta % 4 == 0)
			x[0]++;
		else if (ta % 2 == 0)
			x[1]++;
		else
			x[2]++;
	}
	if (x[1] && x[2])
		x[2]++;
	if (x[2])
		x[2] = max(1, x[2] - 1);
	printf(x[0] >= x[2] ? "Yes\n" : "No\n");
	return 0;
}

Measured memory_bytes: 256
import sys

sys.setrecursionlimit(10 ** 8)
ini = lambda: int(sys.stdin.readline())
inm = lambda: map(int, sys.stdin.readline().split())
inl = lambda: list(inm())
ins = lambda: sys.stdin.readline().rstrip()
debug = lambda *a, **kw: print("\033[33m", *a, "\033[0m", **dict(file=sys.stderr, **kw))

C = [inl() for _ in range(3)]


def solve():
    a10 = C[1][0] - C[0][0]
    if C[1][1] - C[0][1] != a10 or C[1][2] - C[0][2] != a10:
        return False
    a21 = C[2][0] - C[1][0]
    if C[2][1] - C[1][1] != a21 or C[2][2] - C[1][2] != a21:
        return False
    b10 = C[0][1] - C[0][0]
    if C[1][1] - C[1][0] != b10 or C[2][1] - C[2][0] != b10:
        return False
    b21 = C[0][2] - C[0][1]
    if C[1][2] - C[1][1] != b21 or C[2][2] - C[2][1] != b21:
        return False
    return True


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


Measured memory_bytes: 9276
#include "bits/stdc++.h"
#include <chrono>
#include <random>
#include <cstdio>
#define ll long long int
#define endl '\n'
#define pb push_back
#define mp make_pair
#define mod 998244353
#define rep(i,n) for(ll i=0;i<n;i++)
#define vi vector <int>
#define vs vector <string>
#define vc vector <char>
#define vl vector <ll>
#define pll pair<ll, ll>
#define pint pair<int, int>
#define S second
#define F first
#define all(c) (c).begin(),(c).end()
using namespace std;
ll power(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll modInverse(ll a){return power(a,mod-2);}
const int N=500001;
// vector<pair<ll, ll> > adj[N];
// bool vis[N];
ll gcd(ll a, ll b) { if (a == 0) return b; return gcd(b % a, a); } 
ll lcm(ll a, ll b){return a*b/gcd(a, b);}
#define pi 3.14159265358979323846264338
using namespace std; 
ll max(ll a, ll b){ if(a>b)return a;return b;}
ll min(ll a, ll b){ if(a < b) return a;return b;}
ll inf = 100000000000000000;
vector <int> adj[N];

void solve() 
{
    string t;
    cin>>t;
    int n = t.size();
    char s[n+1];
    rep(i, n)
    {
        s[i+1] = t[i];
    }
    
    int f = 0;

    for(int i = 1; i < n - 1; i++)
    {
        if(n - i < 1) break;

        if(s[i] != s[n - i])
        {
            f = 1;
            break;
        }
    }

    if(s[1] != '1' || s[n] != '0' || f == 1)
    {
        cout<<-1<<endl;
        return;
    }

    vi a;
    a.pb(-1);

    for(int i = 1; i <= n; i++)
    {
        if(s[i] == '1')
        {
            a.pb(i);
        }   
    }

    int k = a.size() - 1;

    rep(i, k)
    {
        cout<<i+1<<" "<<i+2<<endl;
    }

    int curr = k + 2;

    for(int i = 2; i <= k; i++)
    {
        rep(j, a[i] - a[i-1] - 1)
        {
            cout<<i<<" "<<curr<<endl;
            curr++;
        }
    }






}

int main()
{   

    #ifndef ONLINE_JUDGE
        // for getting input from input.txt
        freopen("input.txt", "r", stdin);
        // for writing output to output.txt
        freopen("output.txt", "w", stdout);
    #endif

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int T=1;
    // cin>>T;
    int t=0;
    while(t++<T)
    {
        // cout<<"Case #"<<t<<":"<<' ';
        solve();
        // cout<<'\n';
    }
    cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
}


Measured memory_bytes: 15940
#include <stdio.h>

int max_profit(int max, int r) {
  if (max >= r)
    return max;
  return r;
}

int min_profit(int min, int r) {
  if (min <= r)
    return min;
  return r;
}

int main(void) {
  int n;
  int i, j;
  int r[1000000];
  int max, min;

  scanf("%d", &n);

  for (i = 0; i < n; i ++) {
    scanf("%d", &r[i]);
  }

  max = r[1] - r[0];
  min = r[0];
  for (i = 1; i < n; i++) {
    max = max_profit(max, r[i] - min);
    min = min_profit(min, r[i]);
  }

  printf("%d\n", max);
  
  return 0;
}



Measured memory_bytes: 2644
//https://atcoder.jp/contests/abc118/tasks/abc118_a
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const long long INF = numeric_limits<long long>::max();
int main()
{
    int A, B;
    cin >> A >> B;
    cout << ( B % A == 0 ? A + B : B - A ) << endl;
    return 0;
}

Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;

pub fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let n = read::<usize>();
    let mut txy = vec![(0, 0, 0); n + 1];

    for i in 1..n+1 {
        
        txy[i] = (read::<i64>(), read::<i64>(), read::<i64>());
    }

    for i in 1..n+1 {
        if ((txy[i].0 - txy[i-1].0).abs() >= (txy[i].1 - txy[i-1].1).abs() + (txy[i].2 - txy[i-1].2).abs())
        && ((txy[i].0 - txy[i-1].0).abs() % 2 == ((txy[i].1 - txy[i-1].1).abs() + (txy[i].2 - txy[i-1].2).abs()) % 2) {
            continue;
        } else {
            println!("No");
            return;
        }
    }
    println!("Yes")
}

Measured memory_bytes: 8444
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int N, M, C; cin >> N >> M >> C;
    vector<int> B(M);
    for(int i = 0; i < M; i++)
    {
        cin >> B.at(i);
    }
    vector<vector<int>> A(N,vector<int> (M));
    for(int i = 0; i < N; i++)
    {
        for(int j = 0; j < M; j++)
        {
            cin >> A.at(i).at(j);
        }
    }
    int ans = 0;
    for(int i = 0; i < N; i++)
    {
        int sum = C;
        for(int j = 0; j < M; j++)
        {
            sum += A.at(i).at(j)*B.at(j);
        }
        if(sum > 0)
        {
            ans++;
        }
    }
    cout << ans << endl;
}

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

#define S_MAX 1000
#define N_MAX 50
#define M_MAX 50
#define INF 2000000000
#define MOD 1000000007
#define SMAP(a, b) ((a)!=(b))&&((a)^=((b)^=((a)^= (b))))

typedef unsigned long long ull;
typedef   signed long long dll;

typedef struct {
	int a;
	int b;
	int c;
} moneydata;

ull n, m;
int a, b;
ull i, j;
int k;

ull v[N_MAX];

ull max(ull a, ull b){
	return (a > b) ? a : b;
}

ull min(ull a, ull b){
	return (a < b) ? a : b;
}

int comp(const void* l, const void* r){
	if (*(ull*)l == *(ull*)r) return 0;
	else if (*(ull*)l > *(ull*)r) return -1;
	else return +1;
}

ull conv(ull n, ull r){
	ull result = 1;
	ull i;
	for (i = 1; i <= r; i++) {
		result *= (n - i + 1);
		result /= i;
	}
	return result;
}

void solve(){
	double maxperiod = 0.0;
	ull ue = 0, shita = 1;
	double eachper;
	ull maxtotal = 0;
	ull result = 0;
	ull eachres;

	int minleft, minright;

	qsort(v, n, sizeof(ull), comp);

	for (i = 0; i < b; i++) {
		maxtotal += v[i];

		if (i < a - 1) continue;

		eachper = (double)maxtotal / (double)(i + 1);
		
		// if (maxperiod < eachper) {
		// printf("%llu * %llu, %llu * %llu\n", ue, (i + 1), maxtotal, shita);
		if (ue * (i + 1) < maxtotal * shita) {
			maxperiod = eachper;
			ue = maxtotal;
			shita = i + 1;
			result = 0;
		} else if (ue * (i + 1) > maxtotal * shita) {
			continue;
		}

		minleft = minright = i;
		while (minleft && v[minleft - 1] == v[minleft]) minleft--;
		while (minright < n - 1 && v[minright + 1] == v[minright]) minright++;

		eachres = conv(minright - minleft + 1, i - minleft + 1);
		// printf("%lld, %lld, %lld\n", i, eachres, result);
		result += eachres;
	}

	printf("%f\n", maxperiod);
	printf("%llu\n", result);
	return;
}

int main (void) {
	scanf("%llu%llu%llu", &n, &a, &b);
	for (i = 0; i < n; i++) scanf("%llu", &v[i]);

	solve();
	
	return 0;
}




Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, pii> pip;
typedef pair<pll, pll> P;
const ll INF = 1ll<<29;
const ll MOD = 1000000007;
const double EPS = 1e-9;
const bool debug = 0;
//---------------------------------//

ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}

int N, X;
int x[112345];

int main() {
	cin >> N >> X;
	REP(i, N) scanf("%d", x + i);
	
	ll ans = abs(X - x[0]);
	
	REP(i, N) ans = gcd(ans, abs(x[i] - X));
	
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 640
fun main(args: Array<String>) {
    val N = readLine()!!.toInt()
    val A = readLine()!!.split(" ").map(String::toInt)

    for(i in A){
        if(i%2 == 0){
            if(!(i%5==0 || i%3 == 0)){
                println("DENIED")
                return
            }
        }
    }
    
    println("APPROVED")
}

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

using namespace std;

using ll = long long;
using ull = unsigned long long;

int main(int argc, char const *argv[]) {
	ll x;
	std::cin >> x;
	int ans = 0;
	for (int i = 1; i <= x; i++) {
		ans += i;
		if (x <= ans) {
			std::cout << i << '\n';
			return 0;
		}
	}
	return 0;
}


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

signed main() {

    cin.tie(0);
    ios_base::sync_with_stdio(false);

    int a, b, h, m;
    cin >> a >> b >> h >> m;
    h = (h % 12) * 60.00000 + m;
    double pi = acos(-1);
    double dc = pi * (h - 12.00000*m) / 360.00000;
    cout << fixed << setprecision(15);
    cout << sqrt(a * a + b * b  - 2 * a * b * cos(dc)) << endl;
    return 0;
}

Measured memory_bytes: 4204
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define all(v) v.begin(),v.end()

using namespace std;
typedef long long ll;




int main()
{
    
    int a,b,c;
    cin >> a >> b >> c;
    int aa = max(a,max(b,c));
    cout<<a*b*c/aa/2<<endl;
    
    
    
    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
#define  rep(i,n) for(int i = 0; i < n; i++)
#define N 100000
#define Q 50000

int s[N+1];
int t[Q+1];
int n;

bool bitsearch(int x)
{   
    int left = 0;
    int right = n;
    //cout << right << endl;
    //cout << left << endl;
    while(left < right) {
        int mid = (right+left)/2;
        //cout << mid << endl;
        if(s[mid] > x){
            right = mid;
        }
        else if(s[mid] < x){
            left = mid+1;
        }
        else if(s[mid] == x){
            return true;
        }
        //cout << "s[mid]:" << s[mid] << endl;
    }
    return false;
}

int main() 
{
    int q;
    cin >> n;
    rep(i, n) cin >> s[i];
    cin >> q;
    rep(i, q) cin >> t[i];

    //cout << t[2] << endl;

    int count = 0;
    for(int i = 0; i < q; i++){
        if(bitsearch(t[i])){
            count++;
        }
    }

    cout << count << endl;
    
}


Measured memory_bytes: 3568
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define endl "\n"
#define se second
#define ls( s) (s&(-s))
#define ll long long
#define inf 0x3f3f3f3f
const ll N = 300030;
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
const ll mod =    1e9+7;
int n,k;
int r,ss,p;
string s;
bool bo[300030];
int main()
{ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
cin>>n>>k>>r>>ss>>p;
cin>>s;
int x=s.size();
ll sum=0;
rep(i,0,x)
{
	bool b=false;
	if(i-k<0)
	{
		 b=true;
	}
	else
	{
		if(s[i-k]!=s[i]||bo[i-k])
		b=true;
		else
		bo[i]=true;
	}
	if(b)
	{
		int y;
		if(s[i]=='r')
		y=p;
		else if(s[i]=='p')
		y=ss;
		else
		y=r;
		sum=sum+(1ll)*(y);
	//	cout<<y<<endl;
	}
}
cout<<sum;


}

Measured memory_bytes: 592
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
using ull = unsigned long long;
using ll = long long;
using namespace std;

int memo[100001];
int solve(int n) {
    if (n == 0) {
        return 0;
    }

    if (memo[n] != -1) {
        return memo[n];
    }

    int res = n;
    for(int check6 = 1; check6 <= n; check6 *= 6) {
        res = min(res, solve(n-check6)+1);
    }

    for(int check9 = 1; check9 <= n; check9 *= 9) {
        res = min(res, solve(n-check9)+1);
    }

    return memo[n] = res;

}

int main(void) {
    int n;
    cin >> n;

    for (int i = 0; i < 100001; ++i) {
       memo[i] = -1;
    }

    solve(n);
    cout << memo[n] << endl;

    return 0;
}

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

using namespace std;

int main(){

    int n;
    cin >> n;

    int f[n][10];
    for(int i=0;i<n;i++){
        for(int l = 0;l<10;l++){
            scanf("%d",&f[i][l]);
        }
    }

    int p[n][11];
    for(int i=0;i<n;i++){
        for(int l = 0;l<11;l++){
            scanf("%d",&p[i][l]);
        }
    }

    int max = -2000000000;
    int e[10];
    for(int i0 = 0;i0 <2 ;i0++){
        for(int i1 = 0;i1 <2 ;i1++){
            for(int i2 = 0;i2 <2 ;i2++){
                for(int i3 = 0;i3 <2 ;i3++){
                    for(int i4 = 0;i4 <2 ;i4++){
                        for(int i5 = 0;i5 <2 ;i5++){
                            for(int i6 = 0;i6 <2 ;i6++){
                                for(int i7 = 0;i7 <2 ;i7++){
                                    for(int i8 = 0;i8 <2 ;i8++){
                                        for(int i9 = 0;i9 <2 ;i9++){
                                            e[0] = i0;e[1] = i1;e[2] = i2;
                                            e[3] = i3;e[4] = i4;e[5] = i5;
                                            e[6] = i6;e[7] = i7;e[8] = i8;
                                            e[9] = i9;
                                            if(e[0]+e[1]+e[2]+e[3]+e[4]+e[5]+e[6]+e[7]+e[8]+e[9] == 0) break;
                                            
                                            int cnt=0;
                                            for(int i=0;i<n;i++){
                                                int kaburi=0;
                                                for(int l=0;l<10;l++){
                                                    kaburi += f[i][l]*e[l];
                                                }
                                                cnt += p[i][kaburi];
                                            }

                                            if(max < cnt) max = cnt;


                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
    cout << max;
    return 0;
}

Measured memory_bytes: 256
import numpy as np
mod = 10**9+7
N = int(input())
A = list(map(int,input().split()))
A = np.array(A, dtype = np.int64)
tmp = 0
for i in range(61):
    tmp_1 = np.count_nonzero(A & 1)
    tmp += ((tmp_1)*(N - tmp_1)*(2**i)) % mod
    A = A >> 1
print(tmp % mod)

Measured memory_bytes: 48832
//#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS
//#include <cstdio>
//#include <cstdlib>
//#include <cmath>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <vector>
#include <string>
#include <map>
#include <list>
#include <queue>
#include <set>
using namespace std;

int main(void){

	//int a, b, c;
	// char ;

	for(int i = 1;i<10;i++)
	for(int j = 1;j<10;j++)
	cout<<i<<"x"<<j<<"="<<i*j<<endl;

	return 0;
}

/*
for(i=0;i<N;i++){
	cin >> X[i];
}


for(i=0;i<N;i++){
	for(j=0;j<N;j++){
		cin >> X[i][j];
	}
}
*/

Measured memory_bytes: 1116
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstring>

using namespace std;

int n;
int T;
int sa,sb;
vector<int> G[51];
int dp[201][51][51];
const int INF=1000000000;


int main(){

    cin>>T;
    while(T--){
        cin>>n;
        memset(dp,-1,sizeof(dp));
        for(int i=0;i<n;i++)G[i].clear();
        for(int i=0;i<n;i++){
            for(int j=0;j<n;j++){
                int a;
                cin>>a;
                if(a==1){
                    G[i].push_back(j);
                    G[j].push_back(i);
                }
            }
        }
        cin>>sa>>sb;
        for(int i=0;i<n;i++)for(int j=0;j<n;j++)dp[0][i][j]=INF;
        for(int i=200-1;i>=0;i--){
            for(int j=0;j<n;j++){
                for(int k=0;k<n;k++){
                    int res=INF;
                    int tern=i;
                    int apos=j;
                    int bpos=k;
                    int cur=(i+1)%2;
                    int nxt=i%2;
                    if(apos==bpos){
                        dp[nxt][j][k]=i/2;
                        continue;
                    }
                    if(tern%2==0)res=0;
                    if(tern%2==0){
                        for(int l=0;l<G[apos].size();l++){
                            int to=G[apos][l];
                            res=max(res,dp[cur][to][bpos]);
                        }
                        res=max(res,dp[cur][apos][bpos]);
                    }
                    else{
                        for(int l=0;l<G[bpos].size();l++){
                            int to=G[bpos][l];
                            res=min(res,dp[cur][apos][to]);
                        }
                        res=min(res,dp[cur][apos][bpos]);
                    }
                    dp[nxt][j][k]=res;
                }
            }
        }

        int res=dp[0][sa][sb];
        if(res==INF)cout<<"infinity"<<endl;
        else cout<<res<<endl;
    }

    return 0;
}

Measured memory_bytes: 2976
#include<iostream>
#include<cstdio>
#include<cstring>
#include<vector>
#include<algorithm>
#include<queue>
#include<set>
#define MN 100000
using namespace std;
inline int read()
{
    int x=0,f=1;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9')x=x*10+ch-'0',ch=getchar();
    return x*f;
}
int n,L,a[MN+5];
int main()
{
    n=read();L=read();
    for(int i=1;i<=n;++i) a[i]=read();
    for(int i=1;i<n;++i) if(a[i]+a[i+1]>=L)
    {
        puts("Possible");
        for(int j=1;j<i;++j) printf("%d\n",j);
        for(int j=n-1;j>i;--j) printf("%d\n",j);
        return 0*printf("%d\n",i);
    }
    puts("Impossible");
    return 0;
}


Measured memory_bytes: 1152
n=int(input())
w=list(map(int,input().split()))
L=w[0]
R=w[-1]
i=0
j=n-1
while i!=j-1:
    if L>R:
        j-=1
        R+=w[j]
    else:
        i+=1
        L+=w[i]
print(abs(L-R))


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;

static const int MOD = 1000000007;

int step[100005];
int dp[100005];

int main(){
  int N, M;
  cin >> N >> M;
  rep(i,M){
    int a;
    cin >> a;
    step[a] = 1;
  }

  dp[0] = 1;
  rep(i,N+1){
    if(step[i+1] == 0){
      dp[i+1] += dp[i];
      dp[i+1] %= MOD;
    }
    if(step[i+2] == 0){
      dp[i+2] += dp[i];
      dp[i+2] %= MOD;
    }
  }

  cout << dp[N] << endl;
  
  return 0;
}



Measured memory_bytes: 1024
s = input()
MOD = 2019

dp = [0] * MOD
dq = [0] * MOD
ans = 0

for i in range(len(s)):
    tmp = int(s[i])
    if i % 2 == 0:
        for val in range(MOD):
            dp[((val * 10) + tmp) % MOD] += dq[val]
            dq[val] = 0
        dp[tmp] += 1
        ans += dp[0]

    else:
        for val in range(MOD):
            dq[((val * 10) + tmp) % MOD] += dp[val]
            dp[val] = 0
        dq[tmp] += 1
        ans += dq[0] 
    
print(ans)



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

public class Main {
    public static void main(String[] args) throws Exception {

        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out));
        
        String[] str = br.readLine().split(" ");
        int tHP = Integer.parseInt(str[0]);
        int tATK = Integer.parseInt(str[1]);
        int aHP = Integer.parseInt(str[2]);
        int aATK = Integer.parseInt(str[3]);
        int count = 0;
        
        while(true){
            aHP -= tATK;
            count++;
            if(aHP <= 0){
                out.println("Yes");
                break;
            }
            tHP -= aATK;
            count++;
            if(tHP <= 0){
                out.println("No");
                break;
            }
        }
        
        out.close();
        
    }
}

Measured memory_bytes: 32840
#include <cstdio>
#include <list>
#include <algorithm>
using namespace std;

int main()
{
	int n, k;
	char s[15];
	list<int> l;

	scanf("%d", &n);

	while (n--) {
		scanf("%s", s);
		if (*s == 'i') {
			scanf("%d", &k);
			l.push_front(k);
			continue;
		}
		switch (*(s + 6)) {
		case 'F':
			l.pop_front();
			break;
		case 'L':
			l.pop_back();
			break;
		default:
			scanf("%d", &k);
			auto r = find(l.begin(), l.end(), k);
			if (r != l.end())
				l.erase(r);
		}
	}

	int &f = l.front();
	for (int &x: l)
		printf("%s%d", (&f == &x ? "" : " "), x);
	puts("");
}


Measured memory_bytes: 34032
N = int(input())
A = list(map(int,input().split()))
ans = 0
dict = {}
for i in range(N):
    if A[i] in dict:
        dict[A[i]] += 1
    else:
        dict[A[i]] = 1
#print(dict)
for x in dict:
    if x > dict[x]:
        ans += dict[x]
    else:
        ans += dict[x]-x
print(ans)


Measured memory_bytes: 21636
#include<bits/stdc++.h>
using namespace std;
#define FIO ios_base::sync_with_stdio (false) ;cin.tie(NULL);
#define tc  int t;cin>>t;for(int i=0;i<t;i++)
#define ll long long int
#define forn(i,n) for(int i=0;i<n;i++)
#define forn1(i,a,b) for(int i=a;i<=b;i++)
#define pb push_back
#define um(a,b) unordered_map<a,b>
#define vv(a) vector<a>
#define pp(a,b) pair<a,b>
ll power(ll a,ll b,ll mod){  ll ans=1;  while(b>0){
  if(b&1){ ans=(ans*a)%mod;} a=(a*a)%mod;  b=b/2; } return ans;}

int main(){
FIO

ll n;
cin>>n;
string a="AC",b="WA",c="TLE",d="RE";
int e=0,f=0,g=0,h=0;
string s;
for(int i=0;i<n;i++){
    cin>>s;
    if(s==a)
        e++;
    else if(s==b)
        f++;
    else if(s==c)
        g++;
    else
        h++;
}
cout<<a<<" x "<<e<<endl;
cout<<b<<" x "<<f<<endl;
cout<<c<<" x "<<g<<endl;
cout<<d<<" x "<<h<<endl;



}


Measured memory_bytes: 3656
/*
* author: pavveu
*/

#include <bits/stdc++.h>
using namespace std;

using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using pii = pair<int,int>;
using graph = vector<vi>;

#define FOR(name__, upper__) for (int name__ = 0; name__ < (upper__); ++name__)
#define all(x) begin(x), end(x)
#define mp make_pair
#define mt make_tuple

template<class T>
void initialize_matrix(vector<vector<T>>& matrix, int rows, int cols, T value) {
	assert(matrix.empty());
	FOR (row, rows) 
		matrix.emplace_back(cols, value);
}

const ll mod = 1e9 + 7;

void go() {
	int n; cin >> n;
	vll dp(n + 1, 0);
	dp[0] = 1ll;

	for (int i = 1; i <= n; i++) {
		for (int j = i - 3; j >= 0; j--) {
			dp[i] = (dp[i] + dp[j]) % mod;
		}
	}

	cout << dp[n] << endl;
}

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

	go();

	return 0;
}


Measured memory_bytes: 3640
#include <iostream>
#include <vector>
#include <string>
#define ll long long
using namespace std;

int main() 
{
    ll n, m, a, b, ans = 0;
    cin >> n >> m;
    vector<ll> h(n);
    for(ll i = 0; i < n; i++) {
        cin >> h.at(i);
    }

    vector<vector<ll>> sore(n, vector<ll>());
    vector<ll> han(n, 1);
    for(ll i = 0; i < m; i++) {
        cin >> a >> b;
        sore.at(a - 1).push_back(h.at(b - 1));
        sore.at(b - 1).push_back(h.at(a - 1));
    }

    for(ll i = 0; i < n; i++) {
        for(ll j = 0; j < sore.at(i).size(); j++) {
            if(h.at(i) <= sore.at(i).at(j))
                han.at(i) = 0;
        }
    }

    for(ll i = 0; i < n; i++)
        ans += han.at(i);

    cout << ans << endl;
}

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

int main(){

//問題数
int N;
cin >> N;

//時間
vector<int>T(N);
for(int i = 0; i < N; i++){
cin >> T.at(i);
}

//ドリンクの数
int M;
cin >> M;

//ドリンクの内容
vector<int>DN(M);
vector<int>DT(M);
for(int i = 0; i < M; i++){
cin >> DN.at(i) >> DT.at(i);
}

    for (int i = 0; i < M; i++) {
        int ans = 0;
        for (int j = 0; j < N; j++) {
            if (j == DN[i]-1) ans += DT[i];
            else ans += T[j];
        }
        cout << ans << endl;
    }
    

/*  
//時間の総和
int T_sum = 0;
for(int i = 0; i < N ; i++)
{
	T_sum += T.at(i);
}

//ドリンクを飲んだら
for(int i = 0; i < M; i++){

int sa = 0, now = 0, dn = DN.at(i) - 1;
sa = DT.at(dn) - T.at(dn);
now = T_sum + sa; 
cout << now << endl;
}

*/

}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <stack>
#include <tuple>
#include <set>
#include <map>
#include <string>
#include <iomanip>
// #include <cmath>
#include <cassert>

using namespace std;

typedef __int128_t ll;

const int MAX_SIZE = 4000;
bool isprime[MAX_SIZE];
vector<ll> prime_num;
vector<ll> squered;
vector<ll> cubed;
 
// const ll infty = 10000000010;
 
void init() {
  fill(isprime, isprime+MAX_SIZE, true);
  isprime[0] = isprime[1] = false;
  for (auto i=2; i<MAX_SIZE; i++) {
    if (isprime[i]) {
      ll x = i;
      prime_num.push_back(x);
      squered.push_back(x*x);
      cubed.push_back(x*x*x);
      for (auto j=2; i*j<MAX_SIZE; j++) {
        isprime[i*j] = false;
      }
    }
  }
}
 
bool prime(long long x) { // 2 \leq x \leq MAX_SIZE^2
  if (x < MAX_SIZE) {
    return isprime[x];
  }
  for (auto e : prime_num) {
    if (x%e == 0) return false;
  }
  return true;
}
 
int N;
ll s[100010];
map<ll, int> M;
 
ll conj(ll k) {
  ll l = k;
  ll A = 1;
  ll B = 1;
  for (auto x : prime_num) {
    int t = 0;
    while (l % x == 0) {
      l /= x;
      t++;
    }
    if (t == 1) {
      A *= x;
    } else if (t == 2) {
      B *= x;
    }
  }
  ll red = k / (A * B * B);
  ll sq = sqrt(red);
  long long t = static_cast<long long>(sq);
  t = floor(t);
  // cerr << "red = " << red << " , sq = " << sq << endl;
  if (red == t * t) {
    B *= red;
  } else {
    A *= red;
  }
  return A * A * B;
}
 
int main() {
  init();
  cin >> N;
  int ans = 0;
  for (auto i = 0; i < N; i++) {
    long long x;cin>>x;s[i]=x;//cin >> s[i];
    for (auto x : cubed) {
      while (s[i]%x == 0) s[i] /= x;
    }
    if (M.find(s[i]) == M.end()) {
      M[s[i]] = 1;
    } else {
      M[s[i]]++;
    }
  }
  for (auto x : M) {
    ll k = x.first;
    int num = x.second;
    // cerr << k << " " << num << endl;
    if (k == 1 && num > 0) {
      ans += 1;
      continue;
    }
    ll c = conj(k);
    // cerr << "conj(" << k << ") = " << c << endl;
    if (M.find(c) == M.end()) {
      ans += num;
    } else {
      ans += max(num, M[c]);
      M[k] = 0;
      M[c] = 0;      
    }
  }
  cout << ans << endl;
}

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

const int RLEN=1<<18|1;
inline char nc() {
	static char ibuf[RLEN],*ib,*ob;
	(ib==ob) && (ob=(ib=ibuf)+fread(ibuf,1,RLEN,stdin));
	return (ib==ob) ? -1 : *ib++;
}
inline LL rd() {
	char ch=nc(); LL i=0,f=1;
	while(!isdigit(ch)) {if(ch=='-')f=-1; ch=nc();}
	while(isdigit(ch)) {i=(i<<1)+(i<<3)+ch-'0'; ch=nc();}
	return i*f;
}
inline void W(LL x) {
	static int buf[50];
	if(!x) {putchar('0'); return;}
	if(x<0) {putchar('-'); x=-x;}
	while(x) {buf[++buf[0]]=x%10; x/=10;}
	while(buf[0]) {putchar(buf[buf[0]--]+'0');}
}
const int N=1e5+50;
int n,tot; LL cnt[N],ans[N],q[N];
int main() {
	n=rd(); q[tot=1]=n;
	for(int i=rd();i;i--) {
		LL t=rd();
		while(tot && q[tot]>=t) --tot;
		q[++tot]=t;
	}
	cnt[tot]=1;
	for(int i=tot;i>=1;i--) if(cnt[i]) {
		while(q[i]>q[1]) {
			int t=upper_bound(q+1,q+i,q[i])-q-1;
			cnt[t]+=cnt[i]*(q[i]/q[t]);
			q[i]%=q[t];
		} ans[q[i]]+=cnt[i];
	}
	for(int i=n;i>=1;i--) ans[i]+=ans[i+1];
	for(int i=1;i<=n;i++) W(ans[i]), putchar('\n');
} 

Measured memory_bytes: 4352
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>

using namespace std;

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,a,n) for(int i=a;i<n;i++)
#define all(a) (a).begin(),(a).end()
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define eps 1e-15

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef map<int,int> mii;
typedef pair<int,int> pii;
typedef tuple<int,int,int> ti3;

int N;
int P[25];

void Main()
{
    cin >> N;
    rep(i, N)
    {
        cin >> P[i]; 
    }
    int ans = 0;
    rep(i, N - 2)
    {
        if (max(P[i], max(P[i+1], P[i+2])) == P[i+1]) {
            continue;
        }
        if (min(P[i], min(P[i+1], P[i+2])) == P[i+1]) {
            continue;
        }
        ans += 1;
    }
    cout << ans << endl;
}

int main()
{
    cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	// cout << fixed << setprecision(15);
	Main();
}


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

using namespace std;

int main() {
    int n, d;
    cin >> n >> d;

    vector<vector<int>> x(n, vector<int>(d));
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < d; j++) {
            cin >> x[i][j];
        }
    }

    int cnt = 0;
    for (int i = 0; i < n; i++) {
        for (int j = i + 1; j < n; j++) {
            int dis2 = 0;
            for (int k = 0; k < d; k++) {
                dis2 += (x[i][k] - x[j][k]) * (x[i][k] - x[j][k]);
            }

            for (int k = 1; k * k <= dis2; k++) {
                if (k * k == dis2) {
                    cnt++;
                }
            }
        }
    }

    cout << cnt << endl;
}


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

int main()
{
  string s;
  cin >> s;
  map<string, int> mp;
  string t;
  int ans = 0;
  string u = "";
  rep(i, s.size()){
    t += s[i];
    if(u != t) {
      ans++;
      mp[t]++;
      u = t;
      t = "";
    }
  }
  cout << ans << endl;
    

  return 0;
}

Measured memory_bytes: 3672
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <utility>
#include <algorithm>
#include <cstdio>
#include <iomanip>
#include <queue>
#include <deque>
#include <stack>
#include <fstream>
#include <cmath>
#include <random>
#include <complex>
#include <functional>
#include <bitset>
#include <sstream>
#include <cassert>
#include <time.h>

#define ll int64_t
#define Rep(i, n) for (ll i = 0; i < n; i++)
using namespace std;
typedef vector<ll> vec;
typedef vector<vec> mat;

const ll inf = 1LL << 60;

template<class T> inline void chmin(T& a, T b) {
    if (a > b) {
        a = b;
    }
}
template<class T> inline void chmax(T& a, T b) {
    if (a < b) {
        a = b;
    }
}
void printvec (vec &v) {
    Rep (i, (ll)v.size()) {
        cout << v[i] << " \n"[i+1 == (ll)v.size()];
    }
}

ll D = 365;
vec c(26);
mat s(D, vec(26));
vec last(26, 0);


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

    cin >> D;
    Rep (i, 26) {
        cin >> c[i];
    }
    Rep (i, D) {
        Rep (j, 26) {
            cin >> s[i][j];
        }
    }

    vec t(D);
    Rep (i, D) {
        cin >> t[i];
        t[i]--;
    }

    ll tmp = 0;
    Rep (i, D) {
        tmp += s[i][t[i]];
        Rep (j, 26) {
            if (j != t[i]) tmp -= c[j] * (i+1 - last[j]);
        }
        last[t[i]] = i+1;
    }

    // ll tmp = 0;
    // Rep (i, D) {
    //     ll ans = 0;
    //     ll best = -inf;
    //     Rep (j, 26) {
    //         ll score = 0;
    //         score += s[i][j];
    //         Rep (k, 26) {
    //             if (k != j) score -= c[k] * (i+1-last[k]);   
    //         }
    //         if (score > best) {
    //             ans = j;
    //             best = score;
    //         }
    //     }

    //     last[ans] = i+1;
    //     tmp += s[i][ans];
    //     Rep (j, 26) {
    //         tmp -= c[j] * (i+1-last[j]);
    //     }

    //     t[i] = ans;
    // }

    vector<set<ll>> days(26);
    Rep (i, 26) {
        days[i].insert(-1);
        days[i].insert(D);
    }
    Rep (i, D) {
        days[t[i]].insert(i);
    }

    ll M;
    cin >> M;
    while (M--) {
        ll d, q;
        cin >> d >> q;
        d--; q--;
        tmp -= s[d][t[d]];
        tmp += s[d][q];
        auto old2 = days[t[d]].upper_bound(d);
        old2--;
        old2--;
        auto old1 = old2;
        old2++;
        old2++;
        auto new2 = days[q].lower_bound(d);
        auto new1 = --new2;
        new2++;
        // cout << *old1 << " " << *old2 << " " << *new1 << " " << *new2 << "\n";
        tmp += c[q] * (d-*new1) * (*new2 - d);
        tmp -= c[t[d]] * (d-*old1) * (*old2 - d);

        cout << tmp << "\n";
        days[t[d]].erase(d);
        days[q].insert(d);
        t[d] = q;
    }
}

Measured memory_bytes: 3680
import java.util.Scanner;

class Main {
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        char a = sc.next().toCharArray()[0];
        char b = sc.next().toCharArray()[0];
        System.out.println(a<b?"<":a>b?">":"=");
    }
}


Measured memory_bytes: 23764
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define irep(i, n) for (int i = (n); i >= 0; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = 1 << 25;
const int MOD = 1e9+7;
P c[50];
int main() {
	int n;
	cin >> n;
	rep(i,n) cin >> c[i].first >> c[i].second;
	map<P,int> d;
	set<P> s;
	rep(i,n) {
		rep(j,n) {
			if (i == j) continue;
			P p = c[i], np = c[j];
			int dx = np.first - p.first;
			int dy = np.second - p.second;
			s.insert({dx,dy});
			d[{dx,dy}]++;
		}
	}
	int cost0 = 0;
	for (auto itr = s.begin(); itr != s.end(); itr++) {
		cost0 = max(cost0, d[*itr]);
	}
	cout << n - cost0 << endl;
	return 0;
}


Measured memory_bytes: 3744
A, B = map(int, input().split())

a = max(A, B)
b = min(A, B)

bb = int((b ** 0.5) // 1)

ans = 0
for i in range(1,bb+1):
    n = []
    m = []
    if a % i == 0 and b % i == 0:
        ii = int((i ** 0.5) // 1)
        m.append(i)
        n.append(ii)
    if b % i == 0 and a % (b // i) == 0 and b % (b // i) == 0 and b != 1:
        ii = int(((b // i) ** 0.5) // 1)
        m.append(b // i)
        n.append(ii)
    for j in range(len(n)):
        s = 1
        for k in range(2, n[j]+1):
            if m[j] % k == 0:
                s = 0
                break
        if s == 1:
            ans += 1

print(ans)

Measured memory_bytes: 3188
#include <bits/stdc++.h>
#define itn int
#define REP(i, n) for (ll i = 0; i < n; i++)
#define IREP(i, n) for (ll i = n - 1; i >= 0; i--)
#define FOR(a, b) for (ll i = a; i < b + 1; i++)
#define all(v) v.begin(), v.end()
#define SENTINEL 2000000000
#define NIL -1
using namespace std;
typedef long long ll;

const ll INF = 1LL << 60;
const ll MOD = 1000000007;
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;}

int main()
{
    int n;
    cin >> n;
    ll ans=0;
    REP(i,n){
        int x=i+1;
        if(x%3!=0&&x%5!=0){
            ans+=x;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 3632
a=[list(map(int,input().split()))for _ in range(3)]
for i in range(2):
  if not a[0][i]-a[0][i+1]==a[1][i]-a[1][i+1]==a[2][i]-a[2][i+1]:print("No");exit()
for i in range(2):
  if not a[i][0]-a[i+1][0]==a[i][1]-a[i+1][1]==a[i][2]-a[i+1][2]:print("No");exit()
print("Yes")

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <unordered_map>
#include <unordered_set>
#include <string>
#include <sstream>

using namespace std;

int count_black (vector<vector<bool>> &is_black, int i, int j, int rows, int columns)
{
	if (i < 0 || rows <= i || j < 0 || columns <= j)
	{
		return 0;
	}
	
	if (is_black[i][j])
	{
		is_black[i][j] = false;
		int sum = 1;
		sum += count_black(is_black, i-1, j, rows, columns);
		sum += count_black(is_black, i+1, j, rows, columns);
		sum += count_black(is_black, i, j-1, rows, columns);
		sum += count_black(is_black, i, j+1, rows, columns);
		return sum;
	}
	else
	{
		return 0;
	}
}

int main ()
{
	while (true)
	{
		int rows, columns;
		cin >> columns >> rows;

		if (0 == rows && 0 == columns) break;

		vector<vector<bool>> is_black(rows);
		int start_i = 0, start_j = 0;
		for (int i=0; i<rows; ++i)
		{
			is_black[i].resize(columns, false);
			for (int j=0; j<columns; ++j)
			{
				char c;
				cin >> c;

				if ('.' == c)
				{
					is_black[i][j] = true;
				}
				else if ('@' == c)
				{
					is_black[i][j] = true;
					start_i = i;
					start_j = j;
				}
			}
		}

		cout << count_black(is_black, start_i, start_j, rows, columns) << endl;
	}
	
	return 0;
}


Measured memory_bytes: 3020
import numpy as np
n = int(input())
a = list(map(int, input().split()))
alice = 0
bob = 0
for i in range(n):
    a_max = max(a)
    a.remove(a_max)
    if int(i)%2== 0:
        alice+=a_max
    else:
        bob += a_max
answer = alice - bob
print(answer)

Measured memory_bytes: 12488
#include<stdio.h>

int main(void){
    int a,b, add, sub, mul;
    scanf("%d %d",&a, &b);
    add = a + b;
    sub = a - b;
    mul = a * b;

    int max = add;
    if(sub > max){
        max = sub;
    }
    if(mul > max){
        max = mul;
    }
    printf("%d",max);
    return 0;
}

Measured memory_bytes: 128
import java.io.BufferedReader
import java.io.InputStreamReader
import java.io.PrintWriter

fun main(args: Array<String>) {

    // IO Templates
    val br = BufferedReader(InputStreamReader(System.`in`))
    val out = PrintWriter(System.out)

    var (a, b, c) = br.readLine()!!.split(' ').map { it.toInt() }

    val k = br.readLine()!!.toInt()

    var cnt = 0

    while (a >= b) {
        b *= 2
        cnt++
    }

    while (b >= c) {
        c *= 2
        cnt++
    }

    out.println(if (cnt <= k) "Yes" else "No")

    out.flush()
}

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

namespace Sample
{
	class Program
	{
		static void Main(string[] args)
		{
			var i = 1;
			while (true)
			{
				var v = Console.ReadLine();
				if(v == "0")
				{
					break;
				}
				else
				{
					Console.WriteLine($"Case {i}: {v}");
					i++;
				}
			}
		}
	}
}



Measured memory_bytes: 15804
#include <bits/stdc++.h>
        using namespace std;
   #define int long long
   #define PP pair<int,pair<int,int>>
const int MAX = 510000;
const int MOD =  1000000007;


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


        


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

set<long long> s;
long long n, k;

void get(long long x, long long y) {
    if (x >= y) {
        s.insert(x % y);
        get(x % y, y);
    } else {
        s.insert(x);
        s.insert(y - x);
        return;
    }
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    cin >> n >> k;
    get(n, k);
    cout << (*s.begin()) << "\n";
    return 0;
}


Measured memory_bytes: 256
def main():
    n, m = map(int, input().split())
    count = 0

    if n == 1 and m == 1:
        ans = 1
    elif n == 1:
        ans = m - 2
    elif m == 1:
        ans = n - 2
    else:
        ans = (m - 2) * (n - 2)

    print(ans)


if __name__ == '__main__':
    main()

Measured memory_bytes: 61328
lines = $stdin.read
array = lines.split("\n")
N = array[0].to_i
S = array[1]

cnt,pre = 0,0
for i in 0...N
  if S[i] == '('
    cnt+=1
  else
    cnt-=1
    pre = [pre,-cnt].max if cnt<0
  end
end

ans = (['(']*pre).join+S
n = N+pre

cnt = 0
for i in 0...n
  if ans[i] == '('
    cnt+=1
  else
    cnt-=1
  end
end

ans = ans+([')']*cnt).join

puts ans

Measured memory_bytes: 1788
import java.util.*;
     
    public class Main {
      public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int sum = 1;
        int count = 1; 
        
        for(int i = 0; sum < b; i++) {
          sum = sum + a - 1;
          count++;
        }
        System.out.println(count - 1);
      }
    }

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

using namespace std;
#define int long long
const int MOD = 998244353;

inline int add(int x, int y) {
	return (x + y) % MOD;
}

inline int sub(int x, int y) {
	return (x + MOD - y) % MOD;
}

inline int mul(int x, int y) {
	return (long long)x * y % MOD;
}

inline int mod_pow(int a, int b) {
	int res = 1;
	while (b) {
		if (b & 1) {
			res = mul(res, a);
		}
		a = mul(a, a);
		b >>= 1;
	}
	return res;
}

//xor convolution
void fwht(vector<int>& poly, bool rev = false) {
	int n = (int)poly.size();
	for (int i = 1; i < n; i *= 2) {
		for (int j = 0; j < i; j++) {
			for (int k = 0; k < n; k += i * 2) {
				int u = poly[j + k], v = poly[j + k + i];
				poly[j + k] = add(u, v);
				poly[j + k + i] = sub(u, v);
			}
		}
	}
	if (rev) {
		int inv = mod_pow(n, MOD - 2);
		for (int i = 0; i < n; i++) {
			poly[i] = mul(poly[i], inv);
		}
	}
}

vector<int> mul(vector<int> a, vector<int> b) {
	int sm = (int)a.size() + (int)b.size() - 1, size_ = 1;
	while (size_ < sm) size_ *= 2;
	a.resize(size_, 0), b.resize(size_, 0);
	fwht(a), fwht(b);
	for (int i = 0; i < size_; i++) {
		a[i] = mul(a[i], b[i]);
	}
	fwht(a, true);
	a.resize(sm);
	return a;
}
signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N;
	cin >> N;
	vector<vector<int> > g[3];

	for (int i = 0; i < 3; i++) {
		g[i].resize(N);
		int M;
		cin >> M;
		for (int j = 0; j < M; j++) {
			int a, b;
			cin >> a >> b;
			a--;
			b--;
			if (a > b) swap(a, b);
			g[i][a].push_back(b);
		}
	}
	pair<vector<int>, vector<int> > v[3];
	vector<int> X(3 * N + 5);
	X[0] = 1;
	X[1] = ((int)1e18) % MOD;
	for (int i = 2; i < X.size(); i++) {
		X[i] = (X[i - 1] * X[1]) % MOD;
	}
	vector<int> A[3];

	for (int i = 0; i < 3; i++) {
		A[i].resize(N + 1, 0);
		vector<int> mk(N, 0);
		vector<int> G(N, 0);
		for (int j = N - 1; j >= 0; j--) {
			set<int> st;
			for (const int& k : g[i][j]) {
				st.insert(G[k]);
			}
			while (st.count(G[j]) != 0) {
				G[j]++;
			}
			A[i][G[j]] = add(A[i][G[j]], X[j + 1]);
		}
	}
	vector<int> T = mul(A[0], A[1]);
	int res = 0;
	for (int i = 0; i < min(T.size(), A[2].size()); i++) {
		res = add(res, T[i] * A[2][i] % MOD);
	}
	cout << res << endl;
}

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

using namespace std;

int main() {
	string s;
	bool flag = false;
	cin >> s;

	int memoa;
	for (int i = 0; i < s.size(); i++) {
		if (s[i] == 'A') {
			memoa = i;
			break;
		}
	}
	int memob;
	for (int i = (s.size() - 1); i >= 0; i--) {
		if (s[i] == 'Z') {
			memob = i;
			break;
		}
	}
	cout << memob - memoa +1<< endl;
	return 0;
}

Measured memory_bytes: 640
// 2011/08/01 Tazoe

#include <iostream>
using namespace std;

int main()
{
	while(true){
		int x, y;
		cin >> x >> y;
		if(x==0&&y==0)
			break;

		int X, Y;
		if(x>=y){
			X = x;
			Y = y;
		}
		else{
			X = y;
			Y = x;
		}

		int cnt = 0;
		do{
			X = X%Y;

			int tmp = X;
			X = Y;
			Y = tmp;

			cnt++;
		}while(Y!=0);

		cout << X << ' ' << cnt << endl;
	}

	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>

#define REP(i, a, b) for (int i = int(a); i < int(b); i++)
#define dump(val) cerr << __LINE__ << ":\t" << #val << " = " << (val) << endl

using namespace std;

typedef long long int lli;

int gcd(int a, int b) {
    if (b == 0) return a;
    else return gcd(b, a % b);
}

int main() {
    int N, K;
    cin >> N >> K;
    int mx = 0;
    vector<int> A(N);
    REP (i, 0, N) {
        cin >> A[i];
        mx = max(mx, A[i]);
        if (A[i] == K) {
            cout << "POSSIBLE" << endl;
            return 0;
        }
    }
    if (N == 1) {
        cout << "IMPOSSIBLE" << endl;
        return 0;
    }
    int bs = A[0];
    REP (i, 1, N) {
        bs = gcd(bs, A[i]);
    }
    cout << (K % bs == 0 && K <= mx ? "POSSIBLE" : "IMPOSSIBLE") << endl;
    return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <utility>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <cmath>
using namespace std;
typedef long long ll;
const int INF = 1<<30; 
const int MOD = 1e9 + 7;
bool pass(int v)
{
    if(v == 0 || v == 1) return true;
    return false;
}
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    vector<int> cnt(10, 0), A;
    for(int i = 0; i < n; i++)
    {
        int x; cin >> x;
        A.push_back(x);
        cnt[x + 2]++;
    }
    vector<int> ans;
    if(cnt[0] % 2 == 0)
    {
        for(int i = 0; i < n; i++)
        {
            if(pass(A[i])) continue;
            if(A[i] ==  -1) continue;
            ans.push_back(i);
        }
    }
    else if(cnt[1] > 0)
    {
        bool flag = false;
        for(int i = 0; i < n; i++)
        {
            if(pass(A[i])) continue;
            if(A[i] == -1 && flag) continue;
            if(A[i] == -1) flag = true;
            ans.push_back(i);
        }
    }
    else
    {
        int num = cnt[0] - 1;
        for(int i = 0; i < n; i++)
        {
            if(pass(A[i])) continue;
            if(A[i] == -1) continue;
            if(num > 0 && A[i] == -2)
            {
                num--;
                ans.push_back(i);
            }
            else if(A[i] != -2)
            {
                ans.push_back(i);
            }
        }
    }
    cout << ans.size() << endl;
    for(int i = 0; i < ans.size(); i++) cout << ans[i] + 1 << endl;
    return 0;
}





Measured memory_bytes: 3212
import sys


def _i(): return int(sys.stdin.readline().strip())


def _ia(): return map(int, sys.stdin.readline().strip().split())


def main():
    n = _i()
    cnt = 0
    for i, ai in enumerate(_ia()):
        if i % 2 == 1:
            continue
        cnt += (ai % 2)
    return cnt


if __name__ == "__main__":
    print(main())


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

typedef long long ll;
const ll INF = 1010000000000000017LL;
const ll MOD = 1000000007LL;

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

//#define DEBUG(fmt, ...)
#define DEBUG(fmt, ...) fprintf(stderr, fmt "\n", ##__VA_ARGS__)

ll gcd(ll x, ll y) {
  if (y == 0) {
    return x;
  }
  return gcd(y, x % y);
}

ll nCr(ll n, ll r) {
  if (n < r) {
    return 0;
  }
  ll p = 1, k = 1;
  if (n - r < r)
    r = n - r;

  if (r != 0) {
    while (r) {
      p *= n;
      k *= r;
      ll m = gcd(p, k);
      p /= m;
      k /= m;
      n--;
      r--;
    }
  } else {
    p = 1;
  }
  return p;
}

int main(){
    std::cout<<std::fixed<<std::setprecision(10);

    ll N, M;

    cin >> N >> M;
    cout << nCr(N,2) + nCr(M,2) << endl;
}


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

int main() {
  string s, ans;
  cin >> s;
  if(s == "Sunny") ans = "Cloudy";
  if(s == "Cloudy") ans = "Rainy";
  if(s == "Rainy") ans = "Sunny";
  cout << ans << endl;
}

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

int main() {
    int x, a, b;
    cin >> x >> a >> b;
    if (b - a <= 0) cout << "delicious" << endl;
    else if (b - a <= x) cout << "safe" << endl;
    else cout << "dangerous" << endl; 
}

Measured memory_bytes: 256