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


void solve(long long N){
    long long sum = 0;
    for (int i = 1; i <= N; i++) {
        if (i % 3 != 0 && i % 5 != 0) {
            sum += i;
        }
    }
    cout << sum << endl;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
    scanf("%lld",&N);
    solve(N);
    return 0;
}


Measured memory_bytes: 3764
#include <bits/stdc++.h>
using namespace std;
 
int main(){
	int N;
	cin >> N;
	vector <int> B(N);
	vector<int> ans(0);
	for (int i=0;i<N;i++){
		cin >> B.at(i);
	}
	
	bool pro =true;
	for(int i=0;i<N;i++){
		if(B.at(i)>i+1){
			pro =false;
			break;
		}
	}
	if(!pro){
		cout<<-1<<endl;
	}
	else{
		int max=0;
		int pla;
		for(int i=0;i<N;i++){
			for(int k=1;k<B.size()+1;k++){
				for (int p=0;p<k;p++){
					if(B.at(p)==k){
						max=k;
						pla=p;
					}
				}
			}
			// cout<<"k;"<<max<<endl;
			ans.push_back(max);
			B.erase(B.begin()+pla);
		}
		
		reverse(ans.begin(),ans.end());
		for(int i=0;i<N;i++){
			cout<<ans.at(i)<<endl;
		}
	}
}

 

Measured memory_bytes: 256
use proconio::{fastout, input};
#[fastout]
fn main() {
    input! {
        n: i32,
        n1:i32,
    }
    let tmp: i32;
    if n1 == 100 {
        tmp = n * 1000 + 100;
    } else if (n1 >= 10) {
        tmp = n * 100 + n1;
    } else {
        tmp = n * 10 + n1;
    }
    for x in 0..tmp {
        if (x * x == tmp) {
            return print!("Yes");
        }
        if x*x>tmp {
            return print!("No");
        }
    }
}


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

int main(){
	string s;
	cin >> s;
	int loc = 0;
	while(loc < s.size()){
		if(s[loc] == 'd'){
			if(loc+4 >= s.size() || s.substr(loc,5) != "dream"){
				puts("NO");
				return 0;
			}
			loc += 5;
			if(loc+1 < s.size()){
				if(s[loc] == 'e' && s[loc+1] == 'r' && ( loc+2 == s.size() || s[loc+2] != 'a' ))loc += 2;
			}
		}
		else {
			if(loc+4 >= s.size() || s.substr(loc,5) != "erase"){
				puts("NO");
				return 0;
			}
			loc += 5;
			if(loc < s.size() && s[loc] == 'r')loc ++;
		}
	}
	puts("YES");
}



Measured memory_bytes: 512
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")
}

use std::cmp::{max, min};
use std::collections::HashMap;

fn main() {
  let a = read::<i64>();
  let b = read::<i64>();
  let mut cnt = 0;

  for i in a..b + 1 {
    let i_str = i.to_string();
    let i_vec: Vec<char> = i_str.chars().collect();
    let mut i_vec_rev = i_vec.clone();
    i_vec_rev.reverse();

    if i_vec == i_vec_rev {
      cnt += 1;
    }
  }

  println!("{}", cnt);
}


Measured memory_bytes: 4352
import numpy as np
#-------------
N = int(input())
T,A = map(int, input().split())
H =list(map(int, input().split()))
#-------------
Temp = []

for i in range(N) :
  Temp.append(T-0.006*H[i]-A)
  
Temp = np.abs(Temp)
cnt =1
for i in range(N):
  if min(Temp) != Temp[i]:
    cnt+=1
  else:
    print(cnt)

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

using namespace std;
using ll =long long;
typedef pair<int,int> P;
#define SORT(a) sort((a).begin(),(a).end())
#define rSORT(a) reverse((a).begin(),(a).end())
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define debug(x)  cerr << #x << " = " << (x) << endl;
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; }
//Write From this Line

int main()
{
	int n;
	cin >> n;
	vector<vector<int>> a(n, vector<int> (n-1));
	rep(i,n){
		rep(j,n-1){
			cin >> a[i][j];
			a[i][j]--;
		}
		reverse(a[i].begin(), a[i].end());
	}

	vector<P> q;
	auto check = [&](int i){
		if(a[i].size() == 0) return;
		int j = a[i].back();
		if(a[j].size() == 0) return;
		if(a[j].back() == i){
			P p(i,j);
			if(p.second < p.first) swap(p.first, p.second);
			q.push_back(p);
		}
	};
	rep(i,n){
		check(i);
	} 
	int day = 0;
	while(q.size() > 0){
		day++;
		sort(q.begin(), q.end());
		q.erase(unique(q.begin(), q.end()), q.end());
		vector<P> prevQ;
		swap(prevQ, q);
		
		for(P p: prevQ){
			int i = p.first, j = p.second;
			a[i].pop_back();
			a[j].pop_back();
		}
		for(P p: prevQ){
			int i = p.first, j = p.second;
			check(i);
			check(j);
		}
	}
	rep(i,n){
		if(a[i].size() != 0){
			cout << -1 << endl;
			return 0;
		}
	}
	cout << day << endl;
}



Measured memory_bytes: 7556
#include <iostream>

using namespace std;

int main(){
    long long  x ;
    long long  m = 100.0;
    long long y = 0;
    cin >> x;


    for (y=0;m < x;y++){
        m = m * 1.01;
    }

    cout << y << endl;

    return 0;
}

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

using namespace std;
#define ll long long

#define N 100005
ll in[N];
void solve() {
    ll ret = 0;
    int n;scanf("%d",&n);
    for(int i=0;i<n;++i) {
        scanf("%lld",&in[i]);
        ret ^=in[i];
    }
    for(int i=0;i<n;++i) {
        ll tmp = in[i]&ret;
        in[i] -= tmp;
    }
    sort(in,in+n,greater<ll>());
    int pos = 0;
    for(int i=60;i>=0;--i) {
        int ind = -1;ll tmp = -1e18;
        for(int j=pos;j<n;++j) {
            if(in[j]&(1LL<<i)   && tmp<in[j]) {
                swap(in[pos],in[j]);
                tmp = in[j];
                break;
            }
        }
        if(tmp==-1e18) {
            continue;
        }
        ll org = in[pos];
        in[ind] = 0;
        for(int j=0;j<n;++j) {
            if(in[j]&(1LL<<i) && j!=pos) {
                in[j]^= org;
            }
        }
        ++pos;
    }
    ll tmp = ret;ret  = 0;
    for(int i=0;i<n;++i) {
        ret ^= in[i];
    }
    ret = ret*2 + tmp;
    printf("%lld\n",ret);
}
int main() {
    //freopen("input.txt","r",stdin);
    solve();
    return 0;
}

Measured memory_bytes: 1024
s = input()
N = len(s)
S = -1
for i in range(N):
  if s[i] == 'A':
    S = i
    break
E = -1
for i in range(N):
  if s[N-1-i] == 'Z':
    E = N-1-i
    break
print(E-S+1)

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

int main()
{
    string a, b, c;
    cin >> a >> b >> c;
    char diff = 'A' - 'a';
    cout << (char) (a[0]+diff) << (char) (b[0]+diff) << (char) (c[0]+diff) << endl;

    return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#define forn(i, a, n) for(ll i = a; i < n; i ++)
#define pb push_back
#define mp make_pair

#include<iostream>
#include<vector>
#include<algorithm>
#include<math.h>
#include<cmath>
#include<stack>
#include<queue>
#include<set>
#include<map>
#include<string>

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
const ll mod = 1e9 + 7;
const ll power = 49999;

ll n, k;
ll p[40];
ll res[40];

ll getp(ll a)
{
	ll ret = 0;
	for (ll i = a; i >= 0; i -= 2)
		ret += p[i];
	return ret;
}

ll po(ll q)
{
	ll ret = 1;
	q %= 2;
	forn(i, 0, q)
		ret *= -1;
	return ret;
}
int main()
{

#ifndef ONLINE_JUDGE
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
#endif
	cin >> n;
	p[0] = 1;
	forn(i, 1, 40)
		p[i] = p[i - 1] * 2;
	ll r = n;
	ll st = 0;
	for (ll i = 39; i >= 0; i --)
	{
		ll f = r*po(i) - p[i];
		ll s = getp(i - 1);
		if (f+s >= 0)
		{
			res[i] = 1;
			r -= p[i] * po(i);
			st = max(st, i);
		}
	}
	for (ll i = st; i >= 0; i--)
		cout << res[i];
	return 0;
}


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

ll r,w,c,unit;
ll i,n;
char s[500005];

bool solve(){
	cin >> s;
	n = strlen(s);
	if(strlen(s) == 1 && s[0] == '#')return false;
	bool ban[15][15];
	ll ix = 0,iy = 0;
	ll h , w;
	for(i=0;i<n;i++){
		if(s[i] == 'b'){
			ban[ix][iy] = true;
			iy++;
		}else if(s[i] >= '0' && s[i] <= '9'){
			for(int k=0;k<(s[i] - '0');k++){
				ban[ix][iy] = false;
				iy++;
			}
		}else if(s[i] == '/'){
			w = iy;
			iy = 0;
			ix ++;
		}
		
	}
	h = ix + 1;
	ll a,b,c,d;
	cin >> a >> b >> c >> d;
	ban[a-1][b-1] = false;
	ban[c-1][d-1] = true;
	i = 0;
	ll cnt = 0;
	char t[500005];
	ll num = 0;
	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			//cout << ban[i][j] << " ";
		}
		//cout << endl;
	}
	a = 0;
	//cout << h << " " << w << endl;
	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			if(!ban[i][j]){
				a++;
			}else{
				if(a != 0)cout << a;
				cout << "b";
				a = 0;
			} 
		}
		if(a != 0){
			cout << a;
		}
		if(i != h-1){
			cout << "/";
			a = 0;
		}else{
			cout << endl;
		}
	}
	return true;
}
		
int main(){
	while(solve()){}
			
	return 0;
}


Measured memory_bytes: 3100
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
#include <vector>
#include <set>
#include <cstdlib>
#include <deque>

using namespace std;
const long long P = 1000000007;

int main() {
  int n;
  cin >> n;
  int ans = -1;
  for(int i = 1; i <= 50000; i++) {
    int tmp = i*1.08;
    if(tmp == n) {
      ans = i;
    }
  }
  if(ans == -1) {
    cout << ":(" << endl;
  }else {
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 256
N = int(input())
r_N = int(N ** (1 / 2))
 
li = []
for n in range(1,r_N + 1):
  if N % n == 0:
    a = N // n
    l = max(len(str(a)),len(str(n)))
    li.append(l)
    
print(min(li))

Measured memory_bytes: 65524
#include<stdio.h>
#include<math.h>
int main(void){
    double p,temp,min,ans;
    int i;
    scanf("%lf",&p);
    for(i=0;i<5;i++){
        scanf("%lf",&temp);
        if(i==0 || min>temp){
            min=temp;
        }
    }
    ans=ceil(p/min)+4;
    printf("%.0lf\n",ans);
    return 0;
}

Measured memory_bytes: 128
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**15
mod = 10**9+7

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)

class BIT():
    def __init__(self, n):
        i = 1
        while 2**i <= n:
            i += 1
        self.H = i
        self.N = 2**i
        self.A = [0] * self.N

    def find(self, i):
        r = 0
        while i:
            r += self.A[i]
            i -= i & (i-1) ^ i
        return r

    def update(self, i, x):
        while i < self.N:
            self.A[i] += x
            i += i & (i-1) ^ i

    def query(self, a, b):
        return self.find(b-1) - self.find(a-1)

def main():
    n,q = LI()
    a = [LI() for _ in range(q)]
    b = BIT(n+3)
    r = []
    for c,x,y in a:
        if c == 0:
            b.update(x,y)
        else:
            r.append(b.query(x,y+1))

    return '\n'.join(map(str,r))


print(main())

Measured memory_bytes: 39128
import java.util.Scanner;

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

		// 入力値の取得
		long a = sc.nextLong();
		long b = sc.nextLong();
		long c = sc.nextLong();
		long d = sc.nextLong();
		
		sc.close();
		
		// 結果の出力
		long ac = a * c;
		long ad = a * d;
		long bc = b * c;
		long bd = b * d;
		System.out.println(Math.max(ac, Math.max(ad, Math.max(bc, bd))));
	}
}


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

#define f first
#define s second
#define mp make_pair

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

using namespace std;

typedef unsigned int uint;
typedef long long ll;

int main(){
  map<string,set<int> > m;
  string str;
  int n;
  while(cin>>str>>n) m[str].insert(n);
  FOR(mit,m){
    bool f = false;
    cout << mit->first << endl;
    FOR(sit,mit->second){
      if(!f){
        f = true;
      }else{
        cout << " ";
      }
      cout << *sit;
    }
    cout << endl;
  }
  return 0;
}

Measured memory_bytes: 0
//40
#include<iostream>

using namespace std;

int main(){
  int w[33]={1};
  for(int i=0;i<=29;i++){
    w[i+1]+=w[i];
    w[i+2]+=w[i];
    w[i+3]+=w[i];
  }
  for(int n;cin>>n,n;){
    cout<<(w[n]+3649)/3650<<endl;
  }
  return 0;
}

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

int main(){
    cin.tie(0); ios::sync_with_stdio(false);
   
    int n; cin>>n; int a[n],b[n],c[n];
    for (int i = 0; i < n; i++)cin>>a[i]>>b[i]>>c[i];
    int dp[n][3]={}; dp[0][0]=a[0]; dp[0][1]=b[0]; dp[0][2]=c[0]; 
    for (int i = 1; i < n; i++){
        dp[i][0]=max(dp[i-1][1],dp[i-1][2])+a[i];
        dp[i][1]=max(dp[i-1][0],dp[i-1][2])+b[i];
        dp[i][2]=max(dp[i-1][0],dp[i-1][1])+c[i];
    }
    cout<<*max_element(dp[n-1],dp[n-1]+3)<<'\n';
}

Measured memory_bytes: 2560
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;
int main(){
  int n,t,a;
  cin >> n >> t >> a;
  vector<double> h(n);
  int i;
  int id = 0;
  for(i=0;i<n;i++) cin >> h[i];
  double min = 10000;
  for(i=0;i<n;i++){
    if(min>abs(a-t+h[i]*0.006)){
      min = abs(a-t+h[i]*0.006);
      id = i;
    }
  }
  cout << id+1 << "\n";
  return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
typedef unsigned int uint;
using namespace std;

int main(){
  int H,W;
  cin >> H >> W;
  string s[H];
  for(int i=0;i<H;i++) cin >> s[i];

  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      if(s[i][j] == '.'){
        int cnt = 0;
        for(int dx=-1;dx<=1;dx++){
          for(int dy=-1;dy<=1;dy++){
            if(i+dx>=0 && i+dx<H && j+dy>=0 && j+dy<W && s[i+dx][j+dy]=='#'){
              cnt++;
            }
          }
        }
        s[i][j] = cnt + '0';
      }
    }
  }

  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      cout << s[i][j];
    }
    cout << endl;
  }

  return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int miti[17][17];
int s[2]={0,-1},t[2]={-1,0},sum=0;

int main(){
int a,b,c,d=1,e,x,y,i;


while(1){
cin >> a >> b;
if(a==0&&b==0)break;
cin >> c;
for(i=0;i<c;i++){
    cin >> x >> y;
    miti[x][y]=-1;
}
for(i=1;i<a+1;i++){
    if(miti[i][1]==-1)d=-1;
    miti[i][1]=d;
}
d=1;


for(i=1;i<b+1;i++){
    if(miti[1][i]==-1)d=-1;
    miti[1][i]=d;
}
d=1;


for(y=2;y<b+1;y++){
    for(x=2;x<a+1;x++){
        if(miti[x][y]==-1){
        }else  {
           if(miti[x-1][y]==-1){
           }else  miti[x][y]=miti[x][y]+miti[x-1][y];
           if(miti[x][y-1]==-1){
           }else  miti[x][y]=miti[x][y]+miti[x][y-1];
        }
    }
}

cout << miti[a][b] << endl;

for(y=1;y<b+1;y++){
    for(x=1;x<a+1;x++){
         miti[x][y]=0;
    }
}

}
return 0;
}

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

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

    int p = 10;
    for(int i=0;i<N;i++){
        while(1){
            bool isPrime = true;
            p++;
            for(int j=2;j*j<=p;j++) if(p % j == 0) isPrime = false;
            if(isPrime && p%5 == 1) {
                cout << p << " ";
                break;
            } 
            
        }
    }

    cout << endl;
}

Measured memory_bytes: 256
L, R = gets.split.map(&:to_i)

ans = 2 << 60
(L..([L + 2019, R - 1].min)).each do |l|
  ((l + 1)..([l + 1 + 2019, R].min)).each do |r|
    a = l * r % 2019
    ans = a if a < ans
  end
end
puts ans


Measured memory_bytes: 1788
using System;
using System.Diagnostics;
using System.IO;
using System.Text;
using System.Linq;
using System.Collections.Generic;
using System.Text.RegularExpressions;

class Program
{
    const string Yes = "Yes";
    const string No = "No";
    const char White = '.';
    const char Black = '#';
    const long Mod = 1000000007;

    static void Main(string[] args) {
#if DEBUG
        MyDebugger.Test(process, "../TextFile1.txt");
#else
        object ret = process(new StreamReader(Console.OpenStandardInput()));
        Console.WriteLine(ret);
#endif
    }

    static object process(TextReader input) {
        var s = input.ReadLine();

        var regex = new Regex("^(dream|dreamer|erase|eraser)+$");

        return regex.IsMatch(s) ? "YES" : "NO";
    }

    static int[] ToIntArray(string strs, int n) {
        var ret = new int[n];
        var spl = strs.Split(' ');
        for (int i = 0; i < n; i++)
            ret[i] = int.Parse(spl[i]);
        return ret;
    }
}


Measured memory_bytes: 17112
# import sys
# sys.setrecursionlimit(10**5)
# from collections import defaultdict
geta = lambda fn: list(map(fn, input().split()))
gete = lambda fn: fn(input())

def main():
    N = gete(int)
    h = geta(int)

    dp = [0 for _ in range(N)]
    dp[0], dp[1] = 0, abs(h[0] - h[1])

    for i in range(2, N):
        dp[i] = min(dp[i - 2] + abs(h[i] - h[i - 2]),
                    dp[i - 1] + abs(h[i] - h[i - 1]))

    print(dp[N - 1])


if __name__ == "__main__":
    main()

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

const int MAXN = 100;
const int MAXM = 16;
const int DPSIZE = 1<<16;

int N;
int L[MAXN];
int B[MAXN];
int dp[DPSIZE];

int main() {
  while(cin >> N && N) {
    for(int i = 0; i < N; ++i) {
      int m;
      cin >> m >> L[i];
      B[i] = 0;
      while(m--) {
	int s, e;
	cin >> s >> e;
	for(int j = s; j < e; ++j) {
	  B[i] |= (1<<(j-6));
	}
      }
    }

    fill(dp, dp+DPSIZE, 0);
    for(int i = 0; i < DPSIZE; ++i) {
      for(int j = 0; j < N; ++j) {
	if(i & B[j]) continue;
	dp[i|B[j]] = max(dp[i|B[j]], dp[i] + L[j]);
      }
    }
    
    int res = 0;
    for(int i = 0; i < DPSIZE; ++i) {
      res = max(res, dp[i]);
    }
    cout << res << endl;
  }
  return 0;
}

Measured memory_bytes: 1416
from collections import defaultdict


class UnionFind():
    # nはノードの数
    def __init__(self, n):
        self.n = n
        self.parents = [-1]*n  # 根のノードは限らないので注意

    # xはノードの番号
    def find(self, x):  # あるノードの親を探すためのメソッド
        if self.parents[x] < 0:  # 親の場合、そのグラフの要素の個数を負の値で保持している
            return x
        else:
            # 再帰的に親を探しにいき、得られた値を格納する
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    # x, yはノードの番号
    def union(self, x, y):
        x = self.find(x)  # 根の番号を取得
        y = self.find(y)  # 根の番号を取得
        if x == y:
            return  # 同じ親ならば合体させる必要はない

        # ※ それぞれ要素の個数が負の値で格納されている
        if self.parents[x] > self.parents[y]:
            # yのグループの方が要素の個数が多い場合 (yの方が値が小さいということは、負の世界では値が大きいため)
            # 必ずxの方が要素が多い状態にする
            x, y = y, x

        self.parents[x] += self.parents[y]  # 負の値同士だが、これで良い
        self.parents[y] = x  # yは親ではなくなったため、新しい親であるxの値を正でもつ

    # xはノードの番号
    def size(self, x):
        # 親まで辿ればグループの大きさが負の値で格納されているため、それにマイナスをつけてreturnする
        return -self.parents[self.find(x)]

    # x, yはノードの番号
    def same(self, x, y):
        # 親が同じ = 同じグループに属するならTrueがreturnされる
        return self.find(x) == self.find(y)

    # xはノードの番号
    def members(self, x):
        root = self.find(x)  # 親の値を取得する
        # findで再帰的に親の値が獲得できる
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        # 親となっているノードの番号をリストでreturnする
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_counts(self):
        # グループの数をreturnする
        return len(self.roots())

    def all_group_members(self):
        # 親のノードの番号をキーにして、子のノードの番号を対応させた辞書を返す
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        # printした時の表記
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())


N, M, K = map(int, input().split())
uf = UnionFind(N)
friends = defaultdict(int)
for _ in range(M):  # 友達関係の数
    a, b = map(lambda x: int(x)-1, input().split())
    uf.union(a, b)
    friends[a] += 1
    friends[b] += 1
blocked = defaultdict(list)
for _ in range(K):  # ブロック関係の人数
    c, d = map(lambda x: int(x)-1, input().split())
    blocked[c].append(d)
    blocked[d].append(c)
ans = []
for i in range(N):
    # 同じグループの人数
    group_size = uf.size(i)
    # iと直接友達の人数
    i_frends = friends[i]
    # ブロック関係の人の中で、同じグループの人を数える
    cnt = 0
    for b in blocked[i]:
        if uf.same(i, b):
            cnt += 1
    ans.append(group_size - i_frends - cnt - 1)
print(" ".join(map(str, ans)))


Measured memory_bytes: 129576
#include <bits/stdc++.h>
using namespace std;
#define modulo 1000000007
#define mod(mod_x) ((((long long)mod_x+modulo))%modulo)
#define Inf 1000000000000000001

int beki(int a,int b,int M = modulo){
	int x = 1;
	while(b!=0){
		if(b&1){
			x=((long long)x*a)%M;
		}
		a=((long long)a*a)%M;
		b>>=1;
	}
	return x;
}


int gyakugen(int a){
	return beki(a,modulo-2);
}

struct combi{
	deque<int> kaijou;
	deque<int> kaijou_;
	
	combi(int n){
		kaijou.push_back(1);
		for(int i=1;i<=n;i++){
			kaijou.push_back(mod(kaijou[i-1]*i));
		}
		
		int b=gyakugen(kaijou[n]);
		
		kaijou_.push_front(b);
		for(int i=1;i<=n;i++){
			int k=n+1-i;
			kaijou_.push_front(mod(kaijou_[0]*k));
		}
	}
	
	int combination(int n,int r){
		if(r>n)return 0;
		int a = mod(kaijou[n]*kaijou_[r]);
		a=mod(a*kaijou_[n-r]);
		return a;
	}
	
	int junretsu(int a,int b){
		int x = mod(kaijou_[a]*kaijou_[b]);
		x=mod(x*kaijou[a+b]);
		return x;
	}
	
	int catalan(int n){
		return mod(combination(2*n,n)*gyakugen(n+1));
	}
	
};
combi C(200001);

template <typename T,typename F0,typename F1>
struct rerooting{
	F0 func0;
	F1 func1;
	T init_value;
	
	vector<T> v;
	vector<T> ans;
	vector<bool> visited;
	
	rerooting(vector<vector<int>> &E,F0 f0,F1 f1,T iv):func0(f0),func1(f1){
		init_value = iv;
		v.resize(E.size());
		ans.resize(E.size());
		visited.resize(E.size(),false);
		for(int i=0;i<E.size();i++){
			if(visited[i])continue;
			dfs(E,i,-1);
			redfs(E,i,-1,init_value);
		}
	}
	
	void dfs(vector<vector<int>> &E,int now,int p){
		v[now] = init_value;
		for(int i=0;i<E[now].size();i++){
			int to = E[now][i];
			if(to==p)continue;
			dfs(E,to,now);
			v[now] = func0(v[now],v[to]);
		}
		v[now] = func1(v[now],now);
		visited[now]=true;
	}
	
	void redfs(vector<vector<int>> &E,int now,int p,T pv){
		vector<T> S(E[now].size(),init_value);
		if(S.size()>1){
			for(int i=S.size()-2;i>=0;i--){
				int to = E[now][i+1];
				T x = v[to];
				if(to==p)x = pv;
				S[i] = func0(x,S[i+1]);
			}
		}
		
		T temp = init_value;
		for(int i=0;i<E[now].size();i++){
			int to = E[now][i];
			if(to!=p){
				redfs(E,to,now,func1(func0(temp,S[i]),now));
				temp = func0(temp,v[to]);
			}
			else{
				temp = func0(temp,pv);
			}
		}
		ans[now] = func1(temp,now);
	}
	
};

int main(){
	
	int N;
	cin>>N;
	
	vector<vector<int>> E(N,vector<int>());
	
	for(int i=0;i<N-1;i++){
		int a,b;
		cin>>a>>b;
		a--;b--;
		E[a].push_back(b);
		E[b].push_back(a);
	}
	
	auto f0 = [](pair<int,int> a,pair<int,int> b){
		return make_pair(mod(mod(a.first * b.first) * C.combination(a.second + b.second,b.second)),b.second+a.second);
	};
	
	auto f1 = [](pair<int,int> a,int ind){
		return make_pair(a.first,a.second+1);
	};
	
	rerooting<pair<int,int>,decltype(f0),decltype(f1)> rr(E,f0,f1,{1,0});
	
	for(int i=0;i<N;i++){
		cout<<rr.ans[i].first<<endl;
	}
	
	return 0;
}

Measured memory_bytes: 18776
import sys
sys.setrecursionlimit(9999)
def dfs(i, z):
    print "." * z + name[i]
    for j in child[i]:
        dfs(j, z + 1)

n = int(raw_input())
name = []
child = [[] for i in xrange(n)]
for i in xrange(n):
    k = int(raw_input())
    m = raw_input()
    name.append(m)
    if k == 0: continue
    child[k - 1].append(i)

dfs(0, 0)

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

int main() {

  string s;
  cin >> s;
  int n = s.size();
  bool check = true;
  
  for(int i=0;i<n;i++){
    if(s.at(i)!=s.at(n-1-i)) check =false;
  }
  
  for(int i=0;i<(n-3)/2+1;i++){
    if(s.at(i)!=s.at((n-3)/2-i)) check =false;
  }
  
   for(int i=(n+1)/2;i<(3*n-1)/2-i;i++){
    if(s.at(i)!=s.at(n-1-i)) check =false;
  }
  
  if(check){
    cout << "Yes" << endl;
    return 0;
  }
  else cout << "No" << endl;
  
  return 0;
}

Measured memory_bytes: 256
n = int(input())
tmp = raw_input()

As = [int(a) for a in tmp.split()]

dic = {}
maxes = [0, 0]
for a in As:
    if a not in dic:
        dic[a] = 0
    dic[a] += 1
    if dic[a] % 2 == 0:
        if maxes[0] < a:
            maxes[0], maxes[1] = a, maxes[0]
        elif maxes[1] < a:
                maxes[1] = a

print (maxes[0] * maxes[1])

Measured memory_bytes: 17048
#pragma GCC optimize("O3")
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
using P=pair<ll,ll>;
template<class T> using V=vector<T>; 
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
const ll inf=(1e18);
//const ll mod=998244353;
const ll mod=1000000007;
ll GCD(ll a,ll b) {return b ? GCD(b,a%b):a;}
ll LCM(ll c,ll d){return c/GCD(c,d)*d;}
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
int main(){
    ll n,m;
    cin>>n>>m;
    V<V<ll>> a(n,V<ll>(m));
    for(int i=0;i<n;i++)for(int j=0;j<m;j++)cin>>a[i][j];
    int ans=INT_MAX; 
    V<ll> ind(n,0);
    V<bool> used(m+1,false);
    for(int i=0;i<m;i++){
        V<int> res(m+1,0);
        for(int j=0;j<n;j++){
           res[a[j][ind[j]]]++;
        }
        int id=0,ma=0;
        for(int j=1;j<=m;j++){
            if(chmax(ma,res[j])){
                id=j;
            }
        }
        chmin(ans,ma);
        used[id]=true;
        for(int j=0;j<n;j++){
            while(ind[j]<m&&used[a[j][ind[j]]])ind[j]++;
        }
    }
    cout<<ans<<"\n";
}

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

int main(){
	int n,a;
	cin >> n >> a;
	if(n%1000 <= a)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstring>

using namespace std;

int main(){
	
	string S;
	
	cin>>S;
	
	int f=1;
	
	while(f){
		f=0;
		for(int i=0;i<S.size();i++){
			if(S[i]=='e'&&S[i+1]=='r'&&S[i+2]=='a'&&S[i+3]=='s'&&S[i+4]=='e'&&S[i+5]=='r'){
				S.erase(i,6);
				f=1;
			}
		}
	}
	
	f=1;
	while(f){
		f=0;	
		for(int i=0;i<S.size();i++){
			if(S[i]=='e'&&S[i+1]=='r'&&S[i+2]=='a'&&S[i+3]=='s'&&S[i+4]=='e'){
				S.erase(i,5);
				f=1;
			}
		}
	}
	
	f=1;
	while(f){
		f=0;
		for(int i=0;i<S.size();i++){
			if(S[i]=='d'&&S[i+1]=='r'&&S[i+2]=='e'&&S[i+3]=='a'&&S[i+4]=='m'&&S[i+5]=='e'&&S[i+6]=='r'){
				S.erase(i,7);
				f=1;
			}
		}
	}

	f=1;
	while(f){
		f=0;
		for(int i=0;i<S.size();i++){
			if(S[i]=='d'&&S[i+1]=='r'&&S[i+2]=='e'&&S[i+3]=='a'&&S[i+4]=='m'){
				S.erase(i,5);
				f=1;
			}
		}
	}
		
	if(S.size()==0) cout<<"YES"<<endl;
	else cout<<"NO"<<endl;
	
	
	return 0;
}

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

#define max(a,b) ((a)>(b)?(a):(b))
#define min(a,b) ((a)<(b)?(a):(b))

typedef long long LL;

int main(){
  LL x,y;
  cin >> x >> y;
  LL ans=1;
  LL c=x;
  for(;c<=y;ans++,c*=2);
  cout << ans-1 << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <cstring>
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <cmath>
#include <numeric>
#include <float.h>
#include <math.h>
#include <sstream>
using namespace std;
// repマクロの定義
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
// allマクロの定義
#define all(v) v.begin(), v.end()
const unsigned long long INF = 1LL << 60;
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;
}

int ctoi(char c) {
 	switch (c) {
		case '0': return 0;
		case '1': return 1;
		case '2': return 2;
		case '3': return 3;
		case '4': return 4;
		case '5': return 5;
		case '6': return 6;
		case '7': return 7;
		case '8': return 8;
		case '9': return 9;
		default: return 0;
	}
}


int main(){ 
string T; cin >> T;
rep(i,T.size()){
	if(i == 0 && T[i] == '?'){
		T[i] = 'D';
	}
	else if(T[i] == '?'){
		if(T[i-1] == 'P'){
			T[i] = 'D';
		}
		else{
			T[i] = 'D';
		}
	}
}
	cout << T << endl;
}


Measured memory_bytes: 3756
//Longest Increasing Subsequence
//最長部分増加列
//任意の　i < j　で　a[i] < a[j]を満たす部分列
// 1 <= n <= 1000
// 0 <= a[i] <= 1000000

//O(nlogn 解法)


#include<bits/stdc++.h>
using namespace std;
const int INF = 1000*1000*1000;
int main(){

    int n; cin >> n;
    vector<int> a(n);
    for(int i = 0; i < n; i++) cin >> a[i];
    vector<int> dp(n + 1, INF);
    for(int i = 0; i < n; i++){
        *lower_bound(dp.begin(), dp.end(), a[i]) = a[i];
    }

    cout << lower_bound(dp.begin(), dp.end(), INF) - dp.begin() << endl;

    return 0;

}


Measured memory_bytes: 3592
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define rrep(i,n) for (int i = n-1; i >= 0; i--)
#define rep2(i,s,n) for (int i = s; i < n; ++i)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define tmax(a,b,c) max(a,max(b,c))
#define tmin(a,b,c) min(a,min(b,c))
#define pb push_back
using namespace std;
using ll = long long;
using P = pair<int,int>;
using LP = pair<ll,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 int inf = 1001001001;
const ll linf = 1001001001001001001;

int N;

int solve(int n=9,string s="") {
    if(n == 0) {
        int now = stoi(s);
        bool ex7 = false,ex5 = false,ex3 = false;
        for(char c : s) {
            if(c == '7') ex7 = true;
            if(c == '5') ex5 = true;
            if(c == '3') ex3 = true;
        }
        if(!(ex7 && ex5 && ex3)) return 0;
        return now <= N;
    }
    int ret = 0;
    ret += solve(n-1,s+'7');
    ret += solve(n-1,s+'5');
    ret += solve(n-1,s+'3');
    bool ok = true;
    for(char c : s) if(c != '0') ok = false;
    if(ok) ret += solve(n-1,s+'0');
    return ret;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cin >> N;
    cout << solve() << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#define N 100

int a[N+1][N+1], b[N+1], c[N+1], d[N+1], n, t;

void kansu(int x){
  int i;
  c[x] = t++;
  for(i=1;i<=b[x];i++) if(!c[a[x][i]]) kansu(a[x][i]);
  d[x] = t++;
}

int main(){
  int i, j, r, v;
  scanf("%d", &n);
  t=1;
  for(i=1;i<=n;i++){
    c[i] = d[i] = 0;
    scanf("%d", &r);
    scanf("%d", &b[r]);
    for(j=1;j<=b[r];j++) scanf("%d", &a[r][j]);
  }
  for(i=1;i<=n;i++) if(!c[i]) kansu(i);
  for(i=1;i<=n;i++) printf("%d %d %d\n", i, c[i], d[i]);
  return 0;
}



Measured memory_bytes: 2056
def main():
    x, y = map(int, input().split())
    def get_prize(a):
        if a==1:
            return 300000
        elif a==2:
            return 200000
        elif a==3:
            return 100000
        else:
            return 0
    a = 0
    a += get_prize(x)
    a += get_prize(y)
    a = a + 400000 if a==600000 else a
    print(a)

if __name__ == "__main__":
    main()


Measured memory_bytes: 3060
N, K = map(int, input().split())
s, p, r = map(int, input().split())
T = [t for t in 'a'*K + input() + 'a'*K]
h = {'r':'p', 's':'r', 'p':'s'}
G = []
for n in range(K, N+K):
    if T[n] == T[n-K]:
        T[n] = h[T[n]]
        if T[n] == T[n+K]:
            T[n] = h[T[n]]
        G.append(T[n])

print(r*T.count('r')+p*T.count('p')+s*T.count('s') - (r*G.count('r')+p*G.count('p')+s*G.count('s')))

Measured memory_bytes: 5612
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cctype>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <functional>
using namespace std; 
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define FORD(i,a,b) for(int i=(a);i>=(b);i--)
inline bool EQ(double a, double b) { return fabs(a-b) < 1e-9; }
const int INF = 1<<29;
typedef long long ll;
inline int two(int n) { return 1 << n; }

inline int test(int n, int b) { return (n>>b)&1; }
inline void set_bit(int & n, int b) { n |= two(b); }
inline void unset_bit(int & n, int b) { n &= ~two(b); }
inline int last_bit(int n) { return n & (-n); }
inline int ones(int n) { int res = 0; while(n && ++res) n-=n&(-n); return res; }
template<class T> void chmax(T & a, const T & b) { a = max(a, b); }
template<class T> void chmin(T & a, const T & b) { a = min(a, b); }


int binarySearch(int arr[], int l, int r, int x) 
{ 
    if (r >= l) { 
        int mid = l + (r - l) / 2; 
  
        // If the element is present at the middle 
        // itself 
        if (arr[mid] == x) 
            return mid; 
  
        // If element is smaller than mid, then 
        // it can only be present in left subarray 
        if (arr[mid] > x) 
            return binarySearch(arr, l, mid - 1, x); 
  
        // Else the element can only be present 
        // in right subarray 
        return binarySearch(arr, mid + 1, r, x); 
    } 
  
    // We reach here when element is not 
    // present in array 
    return -1; 
} 

int main()
{
    int n,x,y;
    cin >>n>>x>>y;
    int a[n+1][n+1];
    FOR(i,0,n)
        FOR(j,0,n)
            a[i][j]=0;
    for(int i=1;i<=n;i++)
        for(int j=1;j<i;j++)
            a[i][j]=i-j;
    for(int i=1;i<=n;i++){
        for(int j=1;j<i;j++)
            {
                int temp=abs(j-x)+1+abs(i-y);
                temp=min(temp,abs(i-x)+1+abs(j-y));
                a[i][j]=min(temp,a[i][j]);
            }
    }

for(int i=1;i<=n;i++)
    sort(a[i]+1,a[i]+n+1);

// for(int i=1;i<=n;i++)
//     {for(int j=1;j<=n;j++)
//         cout<<a[i][j]<<" ";
//     cout<<"\n"; 
//     }


    
    for(int p=1;p<n;p++){
        int ans=0;
        for(int i=1;i<=n;i++){
        
        int index=binarySearch(a[i],1,n,p);
        if(index!=-1)
        {
            // cout<<"array is\n";
            // for(int m=1;m<=n;m++)
            //     cout<<a[i][m]<<" ";
            //     cout<<"\n";
            int upper=index,lower=index;
            while(a[i][upper]==p&&upper<=n)
                upper++;
            while(a[i][lower]==p&&lower>=1)
                lower--;
            ans=ans+upper-lower+1;
            if(a[i][upper]!=p)
                ans--;
            if(a[i][lower]!=p)
                ans--;
            // printf("i  %d index %d lower %d upper %d val= %d\n",i,index,lower,upper,a[i][index]);
        }

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

Measured memory_bytes: 15872
N = int(input())
from collections import Counter
from bisect import bisect
def prime_factorization(n):
    factor = []
    f = 2
    while f ** 2 <= n:
        if n % f == 0:
            factor.append(f)
            n //= f
        else:
            f += 1
    if n > 1:
        factor.append(n)
    return factor

p = prime_factorization(N)
c = Counter(p)

ans = 0
L = [0]
i = 1
while L[-1] < 10**12:
    L.append(i + L[-1])
    i += 1

for a in c.keys():
    b = c[a]
    i = bisect(L, b)
    ans += i-1
print(ans)
    

Measured memory_bytes: 165728
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
 
#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
 
using namespace std;
// using namespace __gnu_pbds;
 
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cerr << *it << " = " << a << endl;
    err(++it, args...);
}
 
 
#define F first
#define S second
#define ll long long
#define pb push_back
#define db double
#define ld long double
#define ppb pop_back
#define pii pair<int, int>
#define pll pair<long long, long long>
#define piii pair<int, pii>
#define all(x) (x).begin(),(x).end()
#define __ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define watch(x) cout << (#x) << " is " << (x) << endl
#define rep(i, a, n) for (int i = a; i <= n; i++)
#define TEST int T; cin >> T; while(T--)
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
#define int long long
 
const int N = 2e5 + 1, inf = 2e9 + 7, mod = 1e9 + 7;
const ll INF = 2e18 + 7, MOD = 1e15 + 7;

struct mat {
    ll a[51][51];
};

int n;
ll k;

mat mul(mat a, mat b) {
    mat c;
    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= n; j++) {
            ll res = 0;
            for (int l = 1; l <= n; l++) {
                res += a.a[i][l] * b.a[l][j];
                res %= mod;
            }
            c.a[i][j] = res;
        }
    }
    return c;
}

mat binpow(mat a, ll k) {
    if(k == 1) return a;
    mat tmp = binpow(a, k / 2);
    if(k % 2LL == 1LL) {
        return mul(mul(tmp, tmp), a);
    }
    return mul(tmp, tmp);
}

signed main() { __
//    freopen("lcm.in", "r", stdin);
//    freopen("lcm.out", "w", stdout);
    cin >> n >> k;
    mat a;
    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= n; j++) {
            cin >> a.a[i][j];
        }
    }
    mat ans = binpow(a, k);
    ll res = 0;
    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= n; j++) {
            res += ans.a[i][j];
            res %= mod;
        }
    }
    cout << res;
    return 0;
}



Measured memory_bytes: 8832
#include <stdio.h>

bool isLeapYear(int year)
{
    if (year % 4 == 0) {
        if (year % 100 == 0) {
            if (year % 400 == 0) {
                return true;
            }
            return false;
        }
        return true;
    }
    return false;
}
        

int main(void)
{
    int year, from, until, num_leap_year, flag = 0;
    while (1) {
        num_leap_year = 0;
        scanf("%d %d", &from, &until);
        if (from == 0 && until == 0) {
            break;
        } else {
            if (flag != 0) {
                printf("\n");
            }
        }
        for (year = from; year <= until; year++) {
            if (isLeapYear(year) == true) {
                num_leap_year++;
                printf("%d\n", year);
            }
        }
        if (num_leap_year == 0) {
            printf("NA\n");
        }
        flag = 1;
        //printf("\n");
    }
    return 0;
}

Measured memory_bytes: 1044
#include <iostream>
#include <vector>
#define llint long long
#define mod 998244353

using namespace std;

llint n;
string s;

int main(void)
{
	cin >> n >> s;
	
	llint ans = 1;
	llint r = 0, g = 0, b = 0, R = 0, G = 0, B = 0;
	for(int i = 0; i < s.size(); i++){
		if(s[i] == 'R'){
			if(R > 0) ans *= R, ans %= mod, R--;
			else{
				if(g > 0) ans *= g, ans %= mod, g--, B++;
				else if(b > 0) ans *= b, ans %= mod, b--, G++;
				else r++;
			}
		}
		if(s[i] == 'G'){
			if(G > 0) ans *= G, ans %= mod, G--;
			else{
				if(b > 0) ans *= b, ans %= mod, b--, R++;
				else if(r > 0) ans *= r, ans %= mod, r--, B++;
				else g++;
			}
		}if(s[i] == 'B'){
			if(B > 0) ans *= B, ans %= mod, B--;
			else{
				if(r > 0) ans *= r, ans %= mod, r--, G++;
				else if(g > 0) ans *= g, ans %= mod, g--, R++;
				else b++;
			}
		}
	}
	for(int i = 1; i <= n; i++) ans *= i, ans %= mod;
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 900
#include <bits/stdc++.h>
using namespace std;
template<class T>
inline void read(T &a){
    T s = 0, w = 1;
    char c = getchar();
    while(c < '0' || c > '9') {if(c == '-') w = -1; c = getchar();}
    while(c >= '0' && c <= '9'){s = (s << 1) + (s << 3) + (c ^ 48); c = getchar();}
    a = s*w;
}
int main(){
    string s;
    int ans = 0;
    cin>>s;
    for (int i = 0; i < s.size(); i++){
        if(s[i] == '2') ans++;
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 256
/// Code By t_bone_289 (Tushar Singh)
/// An Immature Programmer.... I'm still developing !!
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/trie_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define pll pair<ll,ll>
#define fi first
#define se second
#define mp make_pair
#define pb emplace_back
#define endl '\n'
#define M 1000000007
#define error(x) cout << #x << " = " << x << endl;
#define pi 3.14159265358979323846
typedef long long ll;
typedef long double ld;
template <typename T>
void ContainerError(T &v){cout<<"{";for(auto &x:v){cout<<x<<',';}cout<<"}"<<endl;return;}
typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
ll powmod(ll base,ll exp,ll MOD){ll res=1;while(exp>0){if(exp%2==1) res=(res*base)%MOD;base=(base*base)%MOD;exp/=2;}return (res%MOD);}
ll mpow(ll base,ll exp){ll res=1;while(exp>0){if(exp%2==1) res=(res*base);base=(base*base);exp/=2;}return (res);}
ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
bool cmp(pll &a,pll &b)
{
    return (a.se < b.se);
}
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    ll n;
    cin>>n;
    vector<pll> v(n);
    for(ll i=0;i<n;i++)
    {
        ll x,l;
        cin>>x>>l;
        v[i].fi = x-l;
        v[i].se = x+l;
    }
    sort(v.begin(),v.end(),cmp);
    ll ans = 0;
    ll prev = INT_MIN;
//    for(auto &x:v)
//    {
//        cout<<x.fi<<' '<<x.se<<endl;
//    }
    for(ll i=0;i<n;i++)
    {
        if(v[i].fi >= prev)
        {
            ans++;
            prev = v[i].se;
        }
    }
    cout<<ans;
    return 0;
}



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

class Cube{
public:
 int f[6];
 Cube(){}
 void roll_z(){ roll(1,2,4,3);}
 void roll_y(){ roll(0,2,5,3);}
 void roll_x(){ roll(0,1,5,4);}
 void roll(int i,int j,int k,int l){
   int t=f[i]; f[i]=f[j]; f[j]=f[k]; f[k]=f[l]; f[l]=t;
 }
};

int getRight( Cube c1,int f1,int f2 ){
 for(int i=0;i<6;i++){
   for(int j=0;j<4;j++){
     if( c1.f[0]==f1 && c1.f[1]==f2 ) return c1.f[2];
     c1.roll_z();
   }
   if( i%2 == 0 )c1.roll_y();
   else c1.roll_x();
 }
 return -1;
}

int main(){
 Cube c;
 int f1,f2;
 for(int i=0;i<6;i++)cin>>c.f[i];
 int q; cin>>q;
 for(int i=0;i<q;i++){
   cin>>f1>>f2;
   cout<<getRight(c,f1,f2)<<endl;
 }
 return 0;
}



Measured memory_bytes: 3100
#include<deque>
#include<list>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<vector>
#include<algorithm>
#include<string>
#include<iostream>
#include<sstream>
#include<cmath>
#include<cstring>
using namespace std;
int main(){
  int i,j;
  int n;
  while(cin>>n,n){
    map<string,int> a;
    map<int,vector<string> > b;
    for(i=0;i<n;++i){
      string s;
      cin>>s;
      a[s]=0;
      int m;
      cin>>m;
      for(j=0;j<m;++j){
	int p;
	cin>>p;
	b[p].push_back(s);
      }
    }
    map<int,vector<string> >::iterator it;
    for(it=b.begin();it!=b.end();++it)
      for(i=0;i<(int)(*it).second.size();++i)
	a[(*it).second[i]]+=n-(*it).second.size()+1;
    map<string,int>::iterator jt,mn=a.begin();
    for(jt=a.begin();jt!=a.end();++jt){
      if(0){
      }else if((*mn).second>(*jt).second){
	mn=jt;
      }else if((*mn).second<(*jt).second){
      }else{
	if((*mn).first>(*jt).first)
	  mn=jt;
      }
    }
    cout<<(*mn).second<<" "<<(*mn).first<<endl;
  }
  return 0;
}

Measured memory_bytes: 0
//This program is written by Brian Peng.
#pragma GCC optimize("Ofast","inline","no-stack-protector")
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define Rd(a) (a=rd())
#define Gc(a) (a=getchar())
#define Pc(a) putchar(a)
int rd(){
	int x;char c(getchar());bool k;
	while(!isdigit(c)&&c^'-')if(Gc(c)==EOF)exit(0);
	c^'-'?(k=1,x=c&15):k=x=0;
	while(isdigit(Gc(c)))x=x*10+(c&15);
	return k?x:-x;
}
void wr(int a){
	if(a<0)Pc('-'),a=-a;
	if(a<=9)Pc(a|'0');
	else wr(a/10),Pc((a%10)|'0');
}
signed const INF(0x3f3f3f3f),NINF(0xc3c3c3c3);
long long const LINF(0x3f3f3f3f3f3f3f3fLL),LNINF(0xc3c3c3c3c3c3c3c3LL);
#define Ps Pc(' ')
#define Pe Pc('\n')
#define Frn0(i,a,b) for(int i(a);i<(b);++i)
#define Frn1(i,a,b) for(int i(a);i<=(b);++i)
#define Frn_(i,a,b) for(int i(a);i>=(b);--i)
#define Mst(a,b) memset(a,b,sizeof(a))
#define File(a) freopen(a".in","r",stdin),freopen(a".out","w",stdout)
#define N (60)
int n,m,s,ans[N]{0,-1},u,v,a,b,c[N],d[N],mx[N];
struct E{int v,a,b;};
vector<E>e[N];
struct Q{int u,m,d;bool operator<(Q b)const{return d>b.d;}}t;
priority_queue<Q>q;
signed main(){
	*ans=Rd(n)-1,Rd(m),q.push({1,rd(),0}),Mst(mx,-1);
	while(m--)Rd(u),Rd(v),s+=Rd(a),Rd(b),e[u].push_back({v,a,b}),e[v].push_back({u,a,b});
	Frn1(i,1,n)Rd(c[i]),Rd(d[i]);
	while(!q.empty()){
		t=q.top(),q.pop(),t.m=min(t.m,s);
		if(mx[t.u]>=t.m)continue;mx[t.u]=t.m;
		if(!ans[t.u]){ans[t.u]=t.d;if(!--*ans)break;}
		q.push({t.u,t.m+c[t.u],t.d+d[t.u]});
		for(E i:e[t.u])if(i.a<=t.m)q.push({i.v,t.m-i.a,t.d+i.b});
	}
	Frn1(i,2,n)wr(ans[i]),Pe;
	exit(0);
}


Measured memory_bytes: 3792
#include<iostream>

using namespace std;

int main(void)
{
	int d,n;
	int m[3];m[0]=1;m[1]=100;m[2]=10000;
	int ans;
	cin >> d >> n;
	ans=n;
	if(n==100)ans++;
	ans*=m[d];
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define SORT(x) sort((x).begin(),(x).end())
#define ALL(x) (x).begin(),(x).end()
#define rep(i, n) for(int i = 0; i < n; i++)
#define reps(i, m, n) for(int i = m; i < n; i++)
#define repr(i, m, n) for(int i = m; i >= n; i--)
template<class T>bool maxi(T &a,const T &b){if(a<b){ a=b; return 1;} return 0;}
template<class T>bool mini(T &a,const T &b){if(b<a){ a=b; return 1;} return 0;}
#define y0 y3487465 //j0
#define y1 y1347829 //j1
#define INF2 4000000000000000037
#define INF 1000000007
#define PI (acos(-1))
#define MOD 1000000007
using namespace std;
typedef long long ll;



void Main(){

  int N; cin>>N;

  if(N>=1000) cout<< "ABD"<<"\n";
  else cout<< "ABC"<<"\n";

}

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


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>;

int main() {
  int n;
  cin >> n;
  vector<int> h(n);
  rep(i, n) cin >> h[i];

  string result = "Yes";
  int maxV = h[0];
  for (int i = 1; i < n; ++i) {
    int tmp = h[i];
    if (maxV > tmp) {
      result = "No";
      break;
    }
    if (tmp != maxV) {
      maxV = tmp - 1;
    }
  }

  cout << result << endl;

  return 0;
}


Measured memory_bytes: 640
X,Y,A,B,C = map(int,input().split())
p = list(map(int,input().split()))
q = list(map(int,input().split()))
r = list(map(int,input().split()))
p.sort(reverse = True)
q.sort(reverse = True)
r.sort(reverse = True)
a = X-1
b = Y-1
SA = sum(p[:X])
SB = sum(q[:Y])
for i in range(C):
    if r[i] >= p[a] and (b==-1 or p[a] <= q[b]) and a >= 0:
        SA = SA - p[a] + r[i]
        a -= 1
    elif r[i] >= q[b] and b >= 0:
        SB = SB - q[b] + r[i]
        b -= 1
    else:
        break
print(SA+SB)

Measured memory_bytes: 105444