akhauriyash/Code-Regression huggingface dataset:
///Bismillahir Rahmanir Rahim
#include "bits/stdc++.h"

#define                           ll                          long long
#define                           int                         ll
#define                           fi                          first
#define                           si                          second
#define                           mp                          make_pair
#define                           pb                          push_back
#define                           pi                          pair<ll,ll>
#define                           clr(x)                      memset(x,0,sizeof(x));
#define                           f(i,l,r)                    for(int i=l;i<=r;i++)
#define                           rf(i,r,l)                   for(int i=r;i>=l;i--)
#define                           done(i)                     cout<<"done = "<<i<<endl;
#define                           show(x,y)                   cout<<x<<" : ";for(auto z:y)cout<<z<<" ";cout<<endl;
#define                           fast                        ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

using namespace std;

const ll inf=1e18;
const int mod=1e9+7;
const int M=100005;

 main()

{
    fast
    int ses;
    f(i,1,5)
    {
        int x;
        cin>>x;
        if(x==0)
        {
            ses=i;
        }
    }
    cout<<ses<<endl;
    return 0;

}





































Measured memory_bytes: 3588
#include <stdio.h>
 
typedef struct pair* ppair;
 
typedef struct pair {
  int first, second;
} pair;
 
 
int size;
pair v[1000000];
int psize;
pair preorder[1000000];
int sorted;
 
void swap(ppair a, ppair b) {
  pair t = *a;
  *a = *b;
  *b = t;
}
 
int getp(int begin, int end) {
  int i;
  int p = begin;
  for(i = begin+1; i < end; ++i) {
    if(v[i].first < v[p].first) {
      p = i;
    }
  }
  swap(&v[end-1], &v[p]);
  return end-1;
}
 
void qsort(int begin, int end) {
  int i, j;
  if(begin >= end) return;
  getp(begin,end);
  preorder[psize++] = v[end-1];
  if(begin+1 == end) return;
  for(i = begin, j = begin; i < end; ++i) {
    if(v[i].second < v[end-1].second) {
      swap(&v[i], &v[j++]);
    }
  }
  swap(&v[j],&v[end-1]);
  qsort(begin, j);
  qsort(j+1, end);
}
 
int binary_search(int k) {
  int l, r;
  l = 0;
  r = size;
  while(l < r) {
    int m = (l+r)/2;
    if(v[m].second == k) {
      return m;
    } else if(v[m].second < k) {
      l = m+1;
    } else {
      r = m;
    }
  }
  return -1;
}
 
int main() {
  int i, j;
  int n, k;
  char s[100];
  size = 0;
  sorted = 0;
  scanf("%d", &n);
  for(i = 0; i < n; ++i) {
    scanf("%s", s);
    if(s[0] == 'i') {
      scanf("%d", &k);
      v[size] = (pair){size,k};
      ++size;
      sorted = 0;
    } else if(s[0] == 'p') {
      if(!sorted) {
        psize = 0;
        qsort(0, size);
        sorted = 1;
      }
      for(j = 0; j < size; ++j) {
        printf(" %d", v[j].second);
      }
      printf("\n");
      for(j = 0; j < size; ++j) {
        printf(" %d", preorder[j].second);
      }
      printf("\n");
    } else {
      scanf("%d", &k);
      if(!sorted) {
        psize = 0;
        qsort(0, size);
        sorted = 1;
      }
      printf(binary_search(k)!=-1?"yes\n":"no\n");
    }
  }
  return 0;
}


Measured memory_bytes: 7940
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define invrepr(i,a,b) for(int i=b-1;i>=a;i--)
#define invrep(i,n) invrepr(i,0,n)
#define repitr(itr,a) for(auto itr=a.begin();itr!=a.end();++itr)
#define P pair<int,int>
const ll MOD=1e9+7;
const int MAX=1e5+10;
const ll INF=1e18;
const double PI=acos(-1);


int main() {
    ios_base::sync_with_stdio(false);

    int n,a,b;
    cin >> n >> a >> b;
    cout << min(a,b) << ' ' << max(0,(a+b)-n) << endl;

    return 0;
}


Measured memory_bytes: 3620
#include<cstdio>
#include<cstring>
using namespace std;
typedef long long ll;
ll gcd(ll a,ll b)
{
	return b==0?a:gcd(b,a%b);
}
ll lcm(ll a,ll b)
{
	return a*b/gcd(a,b);
}
int main(){
	ll a,b,c,d;
	while(~scanf("%lld%lld%lld%lld",&a,&b,&c,&d)){
		ll lcmm=lcm(c,d);
		ll sum=b/c-(a-1)/c+b/d-(a-1)/d-(b/lcmm-(a-1)/lcmm);	//a,b中能整除 
		ll ans=b-a+1-sum;
		printf("%lld\n",ans);
	}
	return 0;
}

Measured memory_bytes: 128
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<functional>
#include<iomanip>
#include<iostream>
#include<map>
#include<queue>
#include<set>
#include<string>
#include<utility>
#include<vector>

using namespace std;
typedef long long ll;
const ll mod = 1000000007;
#define rep(i,n) for(int i=0;i<n;i++)
#define repl(i,s,e) for(int i=s;i<e;i++)
#define reple(i,s,e) for(int i=s;i<=e;i++)
#define revrep(i,n) for(int i=n-1;i>=0;i--)

#define vll    vector<ll>
#define vvll   vector<vector<ll>>
#define all(x) (x).begin(),(x).end()

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

	vector<pair<ll, ll>> stores(N);

	rep(i, N)
	{
		cin >> stores[i].first >> stores[i].second;
	}

	sort(all(stores));

	ll cost = 0;
	ll count = M;
	ll idx = 0;

	//安いほうから買い占める
	while (count > 0)
	{
		auto s = stores[idx];

		ll num = min(count, s.second);
		
		cost += s.first * num;

		count -= num;

		idx++;
	}

	cout << cost << endl;

	return 0;
}

Measured memory_bytes: 1792
#include <iostream>

using namespace std;

int main() 
{
  int a, b, c, i, ans;
  cin >> a >> b >> c;
  ans=0;
 for(i=a;i<=b;i++)
{
    if(c % i == 0)
    ans = ans+1;
}
   cout << ans << endl;
}


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

int main() {
  char C;
  stack<char> S;
  while (cin >> C) {
    if (S.empty()) S.push(C);
    else if (C == 'T' && S.top() == 'S') S.pop();
    else S.push(C);
  }
  cout << S.size() << "\n";
}

Measured memory_bytes: 512
import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

class UnionFind:
    def __init__(self, N):
        self.root = list(range(N + 1))
        self.size = [1] * (N + 1)

    def __getitem__(self, x):
        root = self.root
        while root[x] != x:
            root[x] = root[root[x]]
            x = root[x]
        return x

    def merge(self, x, y):
        x = self[x]
        y = self[y]
        if x == y:
            return
        sx, sy = self.size[x], self.size[y]
        if sx < sy:
            x, y = y, x
            sx, sy = sy, sx
        self.root[y] = x
        self.size[x] += sy

def graph_input(N, M):
    G = [[] for _ in range(N + 1)]
    for _ in range(M):
        a, b = map(int, readline().split())
        G[a].append(b)
        G[b].append(a)
    return G

N, M, K = map(int, readline().split())
friend = graph_input(N, M)
block = graph_input(N, K)

uf = UnionFind(N + 1)
for a in range(N + 1):
    for b in friend[a]:
        uf.merge(a, b)

answer = [0] * (N + 1)
for a in range(N + 1):
    n = uf.size[uf[a]] - 1
    for x in friend[a] + block[a]:
        if uf[a] == uf[x]:
            n -= 1
    answer[a] = n

print(' '.join(map(str, answer[1:])))

Measured memory_bytes: 56180
MOD = 10**9 + 7
N, M = map(int, input().split())
S = [[N]*(N+1) for i in [0,1,2]]
T = [[0]*(N+1) for i in [0,1,2]]

C = [0]*(N+1)
for i in range(M):
    l, r, x = map(int, input().split())
    S[x-1][r] = min(S[x-1][r], l)
    T[x-1][r] = max(T[x-1][r], l)
    C[r] = 1

S0, S1, S2 = S
T0, T1, T2 = T

ok = 1
for i in range(N+1):
    if not T2[i] < S1[i] or not T1[i] < S0[i]:
        ok = 0
        break

if not ok:
    print(0)
    exit(0)


X = {(0, 0): 3}
for b in range(1, N):
    t2 = T2[b+1]; s1 = S1[b+1]; t1 = T1[b+1]; s0 = S0[b+1]
    check = lambda r, g: t2 <= r < s1 and t1 <= g < s0

    Z = [0]*(N+1)
    if C[b+1]:
        if t1 <= b < s0:
            for (r, g), v in X.items():
                if t2 <= g < s1:
                    # r <- b+1
                    Z[g] += v
                if t2 <= r < s1:
                    # g <- b+1
                    Z[r] += v
        X = {(r, g): v for (r, g), v in X.items() if t2 <= r < s1 and t1 <= g < s0}
    else:
        Z = [0]*(N+1)
        for (r, g), v in X.items():
            # r <- b+1
            Z[g] += v
            # g <- b+1
            Z[r] += v;
    for z, v in enumerate(Z):
        if v:
            X[z, b] = v % MOD
print(sum(X.values()) % MOD)

Measured memory_bytes: 118988
#include<stdio.h>
#include<math.h>
#include<string.h> 
int main() {
	int a,b;
	scanf("%d %d",&a,&b);
	int i,j;
	int cnt=0;
	for(i=a;i<=b;i++){
		int c,d,e,f,g;
		c=i/10000;
		d=i%10000/1000;
		e=i%1000/100;
		f=i%100/10;
		g=i%10;
		if(c==g&&d==f){
			cnt++;
		}
	}
	printf("%d",cnt);
	return 0;
}

Measured memory_bytes: 128
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String {
            bytes
                .by_ref()
                .map(|r| r.unwrap() as char)
                .skip_while(|c| c.is_whitespace())
                .take_while(|c| !c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_imports)]
use std::cmp;
#[allow(unused_imports)]
use std::collections::{HashMap, HashSet, BinaryHeap, VecDeque};
fn main() {
    input!(n:i64, a:[i64;n],q:i64,b_c:[(i64,i64);q]);
    let mut sum = 0_i64;
    let mut list = vec![0;100001];
    for x in &a {
        sum += x;
        list[*x as usize] += 1;
    }
    for i in 0..q {
        if list[b_c[i as usize].0 as usize] == 0 {
            println!("{}", sum);
            continue;
        }
        //println!("{}", list[b_c[i as usize].0 as usize]);
        sum = sum - list[b_c[i as usize].0 as usize] * b_c[i as usize].0 as i64;
        sum += b_c[i as usize].1 as i64 * list[b_c[i as usize].0 as usize];
        list[b_c[i as usize].1 as usize] +=  list[b_c[i as usize].0 as usize];
        list[b_c[i as usize].0 as usize] = 0;
        println!("{}", sum);
        
    }
}


Measured memory_bytes: 5092
loop do
  h,w = gets.split.map(&:to_i)
  break if h==0&&w==0
  width = 0
  height = 0
  h.times do
    w.times do
      if (height + width)%2 == 0
        print "#"
      else
        print "."
      end
      width += 1
    end
    width = 0
    height += 1
    puts
  end
  puts
end


Measured memory_bytes: 6856
N = int(input())
S = input()
E = [0] * N
t = 0
for i, s in enumerate(S[len(S)-1:0:-1]):
  if s == 'E':
    t += 1
  E[-i-2] = t

t = 0
for i, s in enumerate(S[:len(S) - 1]):
  if s == 'W':
    t += 1
  E[i+1] += t

print(min(E))

Measured memory_bytes: 15476
def solve(std_in):
    """
    Calculate two numbers is a side number another number's divisor

    Paramaters
    ----------
    std_in : string
        input to standard input as string

    Returns
    -------
    y : int
        a side number +/- another number
    """
    _in = std_in.split()
    a = int(_in[0])
    b = int(_in[1])

    y = a + b if b % a == 0 else b - a
    return y

  
def main():
    stdin = input()
    out = solve(stdin)
    print(out)


if __name__ == "__main__":
    main()


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

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

	int n;
	cin>>n;
	string s;
	cin>>s;
	stack<char> st;
	for(int i=0; i < n; ++i){
		if( st.empty() ){ st.push(s[i]); }
		else{
			if( st.top() == s[i] ){ continue; }
			else{ st.push(s[i]); }
		}
	}
	cout<<st.size()<<'\n';

	return 0;
}


Measured memory_bytes: 512
#include<stdio.h>
#include<stdlib.h>
int main()
{
    long long int n,m,o,h,i,j,k,l,a[110],sum;
    while(scanf("%lld",&n)!=EOF )
    {
        for(i=1; i<=n; i++)
        {
            a[i]=0;
        }
        for(i=1; i<=n; i++)
        {
            scanf("%lld",&a[i]);
        }


    scanf("%lld",&m);
    for(j=1; j<=m; j++)
    {
        scanf("%lld %lld",&k,&l);
        for(i=1,sum=0; i<=n; i++)
        {
           if(i!=k){sum=sum+a[i];}
        }
        printf("%lld\n",sum+l);
    }
    }
    return 0;

}


Measured memory_bytes: 128
#include <iostream>

using namespace std;

int main()
{
	int i, d, sum;
	while (cin >> d) {
		sum = 0;
		for (i = 1; d * i <= 600 - d; i++) sum += d * (d * i) * (d * i);
		cout << sum << endl;
	}
	return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
#include <string>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <numeric>
using namespace std;

int abs(int num){
   if (num > 0)
      return num;
   else
      return -num;
}

int main(){
  vector<int> bell(3);
  cin >> bell.at(0) >> bell.at(1) >> bell.at(2);
  sort(bell.begin(),bell.end());
  cout << bell.at(0)+bell.at(1) << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

class Main {

    static Scanner scan;

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

	int[] in = new int[5];
	for(int i = 0; i < in.length; i++) {
	    in[i] = scan.nextInt();
	}

	if ((in[4] <= in[2]) &&
	    (in[2] <= in[0]-in[4]) &&
	    (in[4] <= in[3]) &&
	    (in[3] <= in[1]-in[4])) {
	    System.out.println("Yes");
	} else {
	    System.out.println("No");
	}
    }
}



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

using namespace std;
const long long INF = 1LL <<60;  

int main(void){
  long long  tmp,res;
  long long i,j,k;
  long long d,t,s;

  cin>>d>>t>>s;
  if(s*t<d){
    cout<<"No"<<endl;
  }
  else{
    cout<<"Yes"<<endl;
  }
  //cout<<res<<endl;
  return 0;
}

Measured memory_bytes: 3624
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
    long long N, M;
    cin >> N >> M;
    long long X[100010];
    long long Y[100010];
    
    for(long long i = 0; i < M; i++){
        cin >> X[i];
    }
    sort(X, X+M);
    
    for(long long i = 0; i < M - 1; i++){
        Y[i] = X[i+1]-X[i];
    }
    sort(Y, Y+M-1);
    
    long long ans = 0;
    for(long long i = 0; i < M - N; i++){
        ans += Y[i];
    }
    
    cout << ans << endl;
}


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

using namespace std;
using ll = long long;
using pii = pair<int, int>;

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  int n;
  while (cin >> n, n) {
    int id[100010], t[100010] = {}, ord[100010];
    iota(ord, ord + n, 0);
    for (int i = 0; i < n; i++) {
      cin >> id[i];
      for (int j = 0; j < 4; j++) {
        int m, s;
        cin >> m >> s;
        t[i] += m * 60 + s;
      }
    }
    sort(ord, ord + n, [&](int a, int b) {
      return t[a] < t[b];
    });
    cout << id[ord[0]] << endl;
    cout << id[ord[1]] << endl;
    cout << id[ord[n - 2]] << endl;
  }

  return 0;
}


Measured memory_bytes: 3572
/*
 * Created by KeigoOgawa
 */


#include <cstdio>
#include <iostream>
#include <algorithm>
#include <queue>
#include <map>
#include <set>
#include <cassert>
#include <cmath>

#define INF (int)1e8
#define EPS 1e-10
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = (n) - 1; i >= 0; i--)
#define MIN(a, b) (a > b ? b : a)
#define MAX(a, b) (a > b ? a : b)
#define debug(x) cout << #x << ": " << x << endl
#define all(a) (a).begin(), (a).end()

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> PII;

int N;
int L[200];

void solve() {
  sort(L, L + 2 * N);
  int ans = 0;
  for (int i = 0; i < 2 * N; i += 2) {
    ans += L[i];
  }
  cout << ans << endl;
}

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

  cin >> N;
  REP(i, 2 * N) {
    cin >> L[i];
  }
  solve();
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
using namespace std;
template<typename tn> void read(tn &a){
	tn x=0,f=1; char c=' ';
	for(;!isdigit(c);c=getchar()) if(c=='-') f=-1;
	for(;isdigit(c);c=getchar()) x=x*10+c-'0';
	a=x*f;
}
const int mod = 1e9+7;
int n,m,f[20][1<<16],a[20];
ll fac[1<<18],ifac[1<<18];
ll C(int n,int m){
	if(m>n) return 0;
	return fac[n]*ifac[m]%mod*ifac[n-m]%mod;
}
ll fp(ll a,ll k){
	ll ans=1;
	for(;k;k>>=1,a=a*a%mod)
		if(k&1) ans=a*ans%mod;
	return ans;
}
void upd(int&a,ll b){a=(a+b)%mod;}
int main(){
	read(n);read(m);
	for(int i=1;i<=m;i++) read(a[i]);
	sort(a+1,a+m+1,greater<int>());
	f[1][0]=1;
	fac[0]=1;
	for(int i=1;i<=1<<n;i++) fac[i]=fac[i-1]*i%mod;
	ifac[1<<n]=fp(fac[1<<n],mod-2);
	for(int i=1<<n;i;i--) ifac[i-1]=ifac[i]*i%mod;
	for(int i=1;i<=m;i++){
		for(int j=0;j<1<<n;j++){
			int s=0;
			for(int k=0;k<n;k++)
				s+=j&1<<k;
			for(int k=0;k<n;k++)
				if(~j>>k&1){
					ll cef=C((1<<n)-a[i]-s,(1<<k)-1)*fac[1<<k]%mod;
					upd(f[i+1][j|1<<k],-f[i][j]*cef);
				}
			upd(f[i+1][j],f[i][j]);
		}
	}
	ll ans=0;
	for(int i=0;i<1<<n;i++){
		ll now=f[m+1][i];
		int s=(1<<n)-1;
		for(int j=0;j<n;j++)
			if(i>>j&1) s-=1<<j;
		now=now*fac[s]%mod;
		ans=(ans+now)%mod;
	}
	cout<<(ans*(1<<n)%mod+mod)%mod<<'\n';
	return 0;
}


Measured memory_bytes: 7424
#include <cstdio>
#include <algorithm>
#include <vector>
#include <set>
#include <queue>
#include <algorithm>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;

#define pb push_back
#define mp make_pair
#define f0(i,b) for(int i=0;i<(b);i++)
#define f1(i,b) for(int i=1;i<=(b);i++)
#define f2(i,a,b) for(int i=(a);i<=(b);i++)
#define sf(a) scanf("%d",&a);
#define sfl(a) scanf("%lld",&a);


int dx8[] = {0, 0, 1, 1, 1, -1, -1, -1};
int dy8[] = {1,-1, 1, -1, 0, 0, -1, 1};
int dx4[] = {0, 0, 1, -1};
int dy4[] = {1, -1, 0, 0};
const double pi = acos(-1.0);

int main()
{
    ll n, m, x;
    cin >>n;
    map <int,int>mp;
    for(int i = 1 ; i <= n-1 ; i++){
    cin >> x;
    mp[x]++;
    }
    for(int i = 1 ; i <= n ; i++)
    cout <<mp[i] << endl;
    return 0;
}





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

int main(void)
{
    string s;
    cin>>s;
    int tmp=0;
    for(int i=0;i<s.length();++i)
        tmp=(tmp+s[i]-'0')%9;
    if(tmp==0) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 3728
from heapq import heappush, heappop, heapify
from collections import deque, defaultdict, Counter
import itertools
from itertools import permutations, combinations, accumulate
import sys
import bisect
import string
import math
import time


def I(): return int(input())


def MI(): return map(int, input().split())


def S(): return input()


def MS(): return map(str, input().split())


def LI(): return [int(i) for i in input().split()]


def LI_(): return [int(i)-1 for i in input().split()]


def StoI(): return [ord(i)-97 for i in input()]


def ItoS(nn): return chr(nn+97)


def input(): return sys.stdin.readline().rstrip()


def show(*inp, end='\n'):
    if show_flg:
        print(*inp, end=end)


def print_matrix(mat):
    for i in range(len(mat)):
        print(*mat[i])


YNL = {False: 'No', True: 'Yes'}
YNU = {False: 'NO', True: 'YES'}
MOD = 10**9+7
inf = float('inf')
IINF = 10**10
l_alp = string.ascii_lowercase
u_alp = string.ascii_uppercase
ts = time.time()
# sys.setrecursionlimit(10**6)
nums = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10']


# show_flg = True
show_flg = False


def factorization(n):
    if n <= 1:
        return []

    ret = []
    while n > 2 and n % 2 == 0:
        ret.append(2)
        n //= 2
    i = 3
    while i <= math.sqrt(n):
        if n % i == 0:
            ret.append(i)
            n //= i
        else:
            i += 2
    ret.append(n)
    return ret


def main():
    N = I()
    A = LI()
    ans = 10 ** 19

    for i in range(N):
        ret = factorization(A[i])
        num = len([i for i in ret if i == 2])
        ans = min(num, ans)

    print(ans)


if __name__ == '__main__':
    main()


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

int main() {
  int n, r;
  cin >> n >> r;
  
  if(n >= 10) cout << r << endl;
  else cout << r + 100*(10-n) << endl;
  
  
}

Measured memory_bytes: 256
#include <cmath>

#include <algorithm>
#include <iostream>
#include <string>
#include <vector>

#include <set>

using namespace std;

using ll = long long;
using ld = long double;
using vi = vector<int>;

int n;
int m;

vi a;
vector<set<int>> g;

void input() {
  a.clear();
  g.clear();

  cin >> n >> m;

  a.resize(n);
  g.resize(n);

  for (auto&& i : a)
    cin >> i;

  for (int i = 0; i < m; ++i) {
    int u;
    int v;
    cin >> u >> v;

    --u;
    --v;

    g[u].insert(v);
    g[v].insert(u);
  }
}

void solve() {
  int ans = 0;

  for (int i = 0; i < n; ++i) {
    bool ok = true;

    for (auto&& j : g[i]) {
      if (a[j] >= a[i]) {
        ok = false;

        break;
      }
    }

    ans += ok;
  }

  cout << ans << '\n';
}

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

  cout.precision(16);
  cout << fixed;

  int _times = 1;

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

  _times = 2;
#endif

  // cin >> _times;

  while (_times--) {
    input();
    solve();
  }
}


Measured memory_bytes: 17632
use std::io::*;
use std::str::*;
#[allow(unused_imports)]
use std::collections::*;

fn main() {
    let k : usize = read();
    let odd = k / 2 + k % 2;
    let even = k / 2;
    println!("{}", odd * even);
}

fn read<T: FromStr>() -> T {
    let cin = stdin();
    let cin = cin.lock();
    let s: String = cin 
        .bytes() // Bytes
        .map(|c| c.expect("failed reading char") as char)
        .skip_while(|c| c.is_whitespace()) // c が whitespace である限り skip
        .take_while(|c| !c.is_whitespace()) // c が whitespace でない限り要素を返す
        .collect();
    s.parse().ok().expect("failed parsing")
}


Measured memory_bytes: 4352
#include <iostream>
using namespace std;
int mp[51][51];
void init(){
  for(int i = 0; 51 > i; i++){
    for(int j = 0; 51 > j; j++){
      mp[i][j] == 0;
    }
  }
}
int tansa(int h,int w, int nh, int nw){
  if(mp[nh][nw] == 1)mp[nh][nw] = 0;
  if(nh != 0 && nw != 0 && mp[nh-1][nw-1] == 1)tansa(h,w,nh-1,nw-1);
  if(           nw != 0 && mp[nh  ][nw-1] == 1)tansa(h,w,nh  ,nw-1);
  if(nh!=h-1 && nw != 0 && mp[nh+1][nw-1] == 1)tansa(h,w,nh+1,nw-1);
  if(nh != 0 &&            mp[nh-1][nw  ] == 1)tansa(h,w,nh-1,nw  );
  if(nh!=h-1 &&            mp[nh+1][nw  ] == 1)tansa(h,w,nh+1,nw  );
  if(nh != 0 && nw!=w-1 && mp[nh-1][nw+1] == 1)tansa(h,w,nh-1,nw+1);
  if(           nw!=w-1 && mp[nh  ][nw+1] == 1)tansa(h,w,nh  ,nw+1);
  if(nh!=h-1 && nw!=w-1 && mp[nh+1][nw+1] == 1)tansa(h,w,nh+1,nw+1);
  return 0;
}
int main(){
  while(true){
    int w,h;cin>>w>>h;
    if(w == 0)break;
    for(int i = 0; h > i; i++){
      for(int j = 0; w > j; j++){
        cin >> mp[i][j];
      }
    }
    int ret = 0;
    for(int i = 0; h > i; i++){
      for(int j = 0; w > j; j++){
        if(mp[i][j] == 1){
          tansa(h,w,i,j);
          ret++;
        }
      }
    }
    cout << ret << endl;
    init();
  }
}


Measured memory_bytes: 3284
[X, Y] = list(map(int, input().split()))
C = 0
T = 0
A = []
for C in range(X+1):
  T = X - C
  if 2*C + 4*T == Y:
    A = [C, T]
  else:
      continue
if bool(A) == True:
  print("Yes")
else:
  print("No")


Measured memory_bytes: 9176
#include <iostream>

using namespace std;

int main() {
    int N, A, B, C, D;
    string S;
    cin >> N >> A >> B >> C >> D >> S;
    
    S = "#" + S + "#";

    auto can_reach = [&](int start, int end) {
        for (int i = start; i + 1 <= end; i++) {
            if (S[i] == '#' && S[i + 1] == '#') return false;
        }
        return true;
    };

    if (!can_reach(A, C) || !can_reach(B, D)) {
        cout << "No" << endl;
        return 0;
    }

    if (C > D) {
        bool snuke_can_over = false;
        for (int i = B; i <= D; i++) {
            if (S[i - 1] == '.' && S[i] == '.' && S[i + 1] == '.') {
                snuke_can_over = true;
            }
        }
        if (!snuke_can_over) {
            cout << "No" << endl;
            return 0;
        }
    }

    cout << "Yes" << endl;
    return 0;
}


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

int main() {
    int h, a, ans;
    cin >> h >> a;
    ans = h / a + ((h % a)? 1 : 0);
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
string ans;
int dp[100005][10],lst[100005][10];
char Ans[100005][10];
int n,a,b,c;
inline int qwq()
{
	if(a==2) return 4;
	if(b==2) return 5;
	if(c==2) return 6;
	if(a==0) return 1;
	if(b==0) return 2;
	if(c==0) return 3;
}
inline void qaq(int x)
{
	if(x==1) a=0,b=c=1;
	if(x==2) b=0,a=c=1;
	if(x==3) c=0,b=a=1;
	if(x==4) a=2,b=c=0;
	if(x==5) b=2,a=c=0;
	if(x==6) c=2,b=a=0;
}
int main(int argc, char** argv) {
	cin >> n >> a >> b >> c;
	if(a>=3||b>=3||c>=3||a+b+c>=3||a+b+c==1)
	{
		for(int i=1;i<=n;i++)
		{
			string op;
			cin >> op;
			if(op=="AB")
			{
				if(a>=b) --a,++b,ans+='B';
				else --b,++a,ans+='A'; 
			}
			else if(op=="AC")
			{
				if(a>=c) --a,++c,ans+='C';
				else --c,++a,ans+='A';
			}
			else
			{
				if(b>=c) --b,++c,ans+='C';
				else --c,++b,ans+='B';
			}
			if(a<0||b<0||c<0)
			{
				puts("No");
				return 0;
			}
		}
		puts("Yes");
		for(auto x:ans)
			cout << x << "\n";
		return 0;
	}
	if(a+b+c==0)
	{
		puts("No");
		return 0;
	}
	//011 101 110 200 020 002
	dp[0][qwq()]=1;
	for(int i=1;i<=n;i++)
	{
		string op;
		cin >> op;
		if(op=="AB")
		{
			for(int j=1;j<=6;j++)
			{
				if(!dp[i-1][j]) continue;
				qaq(j);
				if(a)
				{
					--a,++b;
					dp[i][qwq()]=1;
					lst[i][qwq()]=j;
					Ans[i][qwq()]='B';
				}
				qaq(j);
				if(b)
				{
					--b,++a;
					dp[i][qwq()]=1;
					lst[i][qwq()]=j;
					Ans[i][qwq()]='A';
				}
			}
		}
		else if(op=="AC")
		{
			for(int j=1;j<=6;j++)
			{
				if(!dp[i-1][j]) continue;
				qaq(j);
				if(a)
				{
					--a,++c;
					dp[i][qwq()]=1;
					lst[i][qwq()]=j;
					Ans[i][qwq()]='C';
				}
				qaq(j);
				if(c)
				{
					--c,++a;
					dp[i][qwq()]=1;
					lst[i][qwq()]=j;
					Ans[i][qwq()]='A';
				}
			}
		}
		else
		{
			for(int j=1;j<=6;j++)
			{
				if(!dp[i-1][j]) continue;
			//	cout << j << "\n";
				qaq(j);
				if(c)
				{
					--c,++b;
					dp[i][qwq()]=1;
					lst[i][qwq()]=j;
					Ans[i][qwq()]='B';
				}
				qaq(j);
				if(b)
				{
					--b,++c;
					dp[i][qwq()]=1;
					lst[i][qwq()]=j;
					Ans[i][qwq()]='C';
				}
			}
		}
	}
	for(int i=1;i<=6;i++)
	{
		if(dp[n][i])
		{
		//	cout << i;
			puts("Yes");
			for(int i=1;i<=n+1;i++) ans+=' ';
			int now=i;
			for(int i=n;i>=1;i--)
			{
				ans[i]=Ans[i][now];
				now=lst[i][now];
			}
			for(int i=1;i<=n;i++) cout << ans[i] << "\n";
			return 0;
		}
	}
	puts("No");
	return 0;
}

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

using namespace std;

int main()
{
    string s;
    cin>>s;
    vector<int> vec;
    char sai;
    for(auto t:s){
        if(t!=sai){vec.push_back((t=='B'?0:1));sai=t;}
    }
       // for(auto&t:vec)cout<<t;

        cout<<vec.size()-1<<endl;//break;

    return 0;
}


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

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

using namespace std;
const int64_t MOD = 1000000007;

int main() {
  int64_t n;
  cin>>n;
  vector<int> ud;
  REP(i,n){
    string d;
    cin>>d;
    if(d=="U") ud.push_back(1);
    if(d=="D") ud.push_back(0);
  }
  int m = ud.size();
  vector<vector<int64_t>> dp(m+1, vector<int64_t>(m+1, 0));
  dp[0][0] = 1;
  REP(i,m) {
    if (ud[i]) {
      REP(j,m) {
        dp[i+1][j] += j * dp[i][j];
        dp[i+1][j] %= MOD;
        dp[i+1][j+1] += dp[i][j];
        dp[i+1][j+1] %= MOD;
      }
    } else {
      FOR(j,1,m) {
        dp[i+1][j-1] += j * j * dp[i][j];
        dp[i+1][j-1] %= MOD;
        dp[i+1][j] += j * dp[i][j];
        dp[i+1][j] %= MOD;
      }
    }
  }
  cout << dp[m][0] << endl;
  return 0;
}



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

int main()
{
	int ans = 0;
	string s;
	cin >> s;
	if (s[0] == '1')
	{
		ans++;
	}
	if (s[1] == '1')
	{
		ans++;
	}
	if (s[2] == '1')
	{
		ans++;
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main(){
	int m, f, r;
	
	while(1){
		
		cin >> m >> f >> r;
		
		if ( m == -1 && f == -1 && r == -1 ) 
			break;
		else if ( m == -1 || f == -1 )
			cout << 'F' << endl;
		else if ( m + f >= 80 ) 
			cout << 'A' << endl;
		else if ( m + f >= 65 && m + f < 80 ) 
			cout << 'B' << endl;
		else if ( ( m + f >= 50 && m + f < 65 ) || ( r >= 50 )) 
			cout << 'C' << endl;
		else if ( m + f >= 30 && m + f < 50 )
			cout << 'D' << endl;
		
		else if ( m + f < 30 ) 
			cout << 'F' << endl;
	
	}
	
	return 0;
}

Measured memory_bytes: 1152
from collections import Counter

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

c = Counter(A)
#print(c)
total = sum(A)

for _ in range(Q):
    B, C = map(int, input().split())
    total += (C-B)*c[B]
    c[C] += c[B]
    c[B] = 0
    print(total)

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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

void Main() {
    ll D; cin >> D;
    string ans;
    if (D == 25){
        ans = "Christmas";
    } else if (D == 24){
        ans = "Christmas Eve";
    } else if (D == 23){
        ans = "Christmas Eve Eve";
    } else if (D == 22){
        ans = "Christmas Eve Eve Eve";
    }
    cout << ans << endl;
}

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


Measured memory_bytes: 3580
#include<bits/stdc++.h>
   
using namespace std;
  
#define rep(i,n) for(int i=0;i<(n);++i)
#define reps(i,n) for(int i=1;i<=(n);++i)
#define all(x) (x).begin(),(x).end()
#define Fixed fixed << setprecision(14)
#define int int64_t
using pii = pair<int,int>;
constexpr int INF  = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int mod1 = 1e9+7; 
constexpr int mod2 = 998244353;
 
template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }
 
template <class T> using min_heap = priority_queue<T,vector<T>,greater<T> >;
template <class T> using max_heap = priority_queue<T>;
template <class A,class B> using umap = unordered_map<A,B>;
   
int gcd(int a,int b){ return b ? gcd(b,a % b) : a;}
int lcm(int a,int b){ return a / gcd(a,b) * b;}

signed main(){
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);

    int n,m;
    cin >> n >> m;
    bool red[n+1] = {};
    vector<int> ball(n+1,1);
    red[1] = true;

    rep(i,m){
        int x,y;
        cin >> x >> y;
        ball[x]--;
        ball[y]++;
        red[y] |= red[x];
        if(red[x]){
            red[x] = ball[x];
        }
    }

    int res = 0;
    reps(i,n){
        res += red[i];
    }

    cout << res << '\n';    

    return 0;
}

Measured memory_bytes: 1152
N=int(input())
aN=list(map(int,input().split()))
colors=set()
sp_col=0
for a in aN:
  if      1<=a and a<= 399:colors.add('gray')
  elif  400<=a and a<= 799:colors.add('brown')
  elif  800<=a and a<=1199:colors.add('green')
  elif 1200<=a and a<=1599:colors.add('splash')
  elif 1600<=a and a<=1999:colors.add('blue')
  elif 2000<=a and a<=2399:colors.add('yellow')
  elif 2400<=a and a<=2799:colors.add('orange')
  elif 2800<=a and a<=3199:colors.add('red')
  else:sp_col+=1
  pass

if len(colors)==0:min_col=1
else:min_col=len(colors)
print("{} {}".format(min_col,len(colors)+sp_col))




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

const int64_t MOD = 1000000007;
typedef long long ll;
typedef unsigned long long ull;

#define FOR(i, start, end) for(uint64_t i=start; i<end; i++)
#define REP(i, n) FOR(i, 0, n)

// 最大公約数gcd
// 最小公倍数lcm=m*n/gcd
uint64_t gcd(uint64_t m, uint64_t n) {
  uint64_t temp;
  while (m % n != 0){
    temp = n;
    n = m % n;
    m = temp;
  }
  return n;
}

uint64_t lcm(uint64_t m, uint64_t n) {
  return (m*n)/gcd(m,n);
}

// vector<vector<uint64_t> > v(n+1, vector<uint64_t>(n+1, 0))
// v[n][k]に組み合わせ数が入る。
void comb(vector<vector <uint64_t> > &v){
  for(uint64_t i = 0;i <v.size(); i++){
    v[i][0]=1;
    v[i][i]=1;
  }
  for(uint64_t k = 1;k <v.size();k++){
    for(uint64_t j = 1;j<k;j++){
      v[k][j]=(v[k-1][j-1]+v[k-1][j]);
    }
  }
}

// 掛け算オーバーフロー判定
bool is_product_overflow(uint64_t a, uint64_t b) {

	uint64_t prod = a * b;
	
	return (prod / b != a);
}

//素因数分解
void primeFactorization(uint64_t a, list<uint64_t> &factors){ //素因数分解を出力するプログラム
  long i,sq;
  if(a%2==0){ //偶数の場合
    factors.push_back(2);
    primeFactorization(a/2,factors); //2で割った値で再帰
    return;
  }
  sq = sqrt(a);
  for(i=3;i<=sq;i+=2){ //3以上√a以下の奇数の場合
	if(a%i==0){
	  factors.push_back(i);
      primeFactorization(a/i,factors); //割れた値で再帰
      return;
	}
  }
  //偶数でも3以上√a以下の奇数の場合でも割り切れない場合
  if(a!=1){ //aが1でないなら、a自身は素数
    factors.push_back(a);
  }
}

// フェルマーの小定理
// mod. m での a の逆元 a^{-1} を計算する
// (a/b)%m = a*movinv(b,m)%m  
int64_t modinv(int64_t a, int64_t m) {
    int64_t b = m, u = 1, v = 0;
    while (b) {
        int64_t t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

// 円周率
// M_PI

// #include <iomanip> // setprecisionを使用するのに必要
// cout << std::fixed << std::setprecision(15) << y << endl;

// 昇順
// priority_queue<int, vector<int>, greater<int> > queue;

signed main() {
  ll n,d;
  cin >> n >> d;
  d *= d;
  
  ll x,y;
  ll count = 0;
  for(ll i=0;i<n;i++){
    cin >> x >> y;
    if(x*x+y*y <= d) count++;
  }

  cout << count << endl;

  return 0;
}



Measured memory_bytes: 3632
/*
	0516:Maxinum Sum
*/
#include	<iostream>
#include	<vector>
#include	<cstdio>

using namespace std;

int main(void) {
	while(1) {
		int n, k, best = 0, sum = 0;
		scanf("%d %d", &n, &k);
		if(n == 0 && k == 0) { break; }
		
		vector<int> inputs(n);
		
		for( int i = 0; i < (int)inputs.size(); i++ ) {
			cin >> inputs[i];
		}
		for(int i = 0; i < k; i++) {
			sum += inputs[i];
		}
		for(int i = 0; k < (int)inputs.size(); i++, k++) {
			sum += inputs[k] - inputs[i];
			if(best < sum) {
				best = sum;
			}
		}
		
		cout << best << endl;
		
	}
	return 0;
}

Measured memory_bytes: 1532
/* imports all std modules {{{*/
import
  std.algorithm,
  std.array,
  std.ascii,
  std.base64,
  std.bigint,
  std.bitmanip,
  std.compiler,
  std.complex,
  std.concurrency,
  std.container,
  std.conv,
  std.csv,
  std.datetime,
  std.demangle,
  std.encoding,
  std.exception,
  std.file,
  std.format,
  std.functional,
  std.getopt,
  std.json,
  std.math,
  std.mathspecial,
  std.meta,
  std.mmfile,
  std.net.curl,
  std.net.isemail,
  std.numeric,
  std.parallelism,
  std.path,
  std.process,
  std.random,
  std.range,
  std.regex,
  std.signals,
  std.socket,
  std.stdint,
  std.stdio,
  std.string,
  std.system,
  std.traits,
  std.typecons,
  std.uni,
  std.uri,
  std.utf,
  std.uuid,
  std.variant,
  std.zip,
  std.zlib;
/*}}}*/

/* libnum {{{*/
void amax(N, Args...)(ref N x, Args y) {
  x = x.max(y);
}
void amin(N, Args...)(ref N x, Args y) {
  x = x.min(y);
}
auto maxE(R)(R r) if (isInputRange!R) {
  ElementType!R x = r.front;
  r.popFront();
  foreach (y; r) x.amax(y);
  return x;
}
auto minE(R)(R r) if (isInputRange!R) {
  ElementType!R x = r.front;
  r.popFront();
  foreach (y; r) x.amin(y);
  return x;
}
/*}}}*/


/+---test
4
2 4
4 3
9 3
100 5
---+/
/+---test
2
8 20
1 10
---+/
/+---test
5
10 1
2 1
4 1
6 1
8 1
---+/

void main(string[] args) {
  const N = readln.chomp.to!long;

  alias Pair = Tuple!(long, "l", long, "r");
  auto pairs = new Pair[N];
  foreach (ref pair; pairs) {
    readf(" %d %d ", &pair.l, &pair.r);
    pair.l -= pair.r;
    pair.r  = pair.l + pair.r*2;
  }
  pairs.multiSort!("a.l < b.l", "a.r-a.l < b.r-b.l");

  long ans;
  long r = long.min;
  foreach (i, p; pairs) {
    if (p.l < r) continue;
    ++ans;

    r = p.r;
    foreach (p2; pairs[i..$]) {
      if (p2.l >= r) break;
      r.amin(p2.r);
    }
  }
  ans.writeln;
}


Measured memory_bytes: 3708
#include<bits/stdc++.h>
using namespace std;
int w,h,s[1001][1001];
char t;
int main()
{
    cin>>h>>w;
    for(int i=1;i<=h;i++)
    {
        for(int j=1;j<=w;j++)
        {
            cin>>t;
            if(t=='#')
            {
                s[i][j]=-9;
                s[i-1][j]++;
                s[i+1][j]++;
                s[i][j-1]++;
                s[i][j+1]++;
                s[i-1][j+1]++;
                s[i-1][j-1]++;
                s[i+1][j+1]++;
                s[i+1][j-1]++;
            }
        }
    }
    for(int i=1;i<=h;i++)
    {
        for(int j=1;j<=w;j++)
        {
            if(s[i][j]<0)
                cout<<"#";
            else cout<<s[i][j];
        }
        cout<<endl;
    }
    cout<<endl;
    return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <math.h>
#include <algorithm>
#define ll long long int
#define FOR(i, a, b) for (ll i = (ll)(a); i < (ll)(b); i++)
#define REP(i, n) FOR(i, 0, n)
#define REP1(i, n) FOR(i, 1, n)

using namespace std;

int main()
{
    int r, d, x;
    cin >> r >> d >> x;
    int x_prev = x;
    REP(i, 10)
    {
        cout << r * x_prev - d << endl;
        x_prev = r * x_prev - d;
    }
    return 0;
}


Measured memory_bytes: 256
package main

// Solution for https://atcoder.jp/contests/abc174/tasks/abc174_d

import (
	"bufio"
	"fmt"
	"io"
	"os"
)

type contest struct {
	in  io.Reader
	out io.Writer
}

func (con *contest) Scan(a ...interface{}) (int, error) {
	return fmt.Fscan(con.in, a...)
}
func (con *contest) Scanln(a ...interface{}) (int, error) {
	return fmt.Fscanln(con.in, a...)
}
func (con *contest) Scanf(f string, a ...interface{}) (int, error) {
	return fmt.Fscanf(con.in, f, a...)
}
func (con *contest) Print(a ...interface{}) (int, error) {
	return fmt.Fprint(con.out, a...)
}
func (con *contest) Println(a ...interface{}) (int, error) {
	return fmt.Fprintln(con.out, a...)
}
func (con *contest) Printf(f string, a ...interface{}) (int, error) {
	return fmt.Fprintf(con.out, f, a...)
}
func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	con := &contest{in: in, out: out}
	con.main()
}

func (con *contest) main() error {
	var n int
	var s string
	con.Scan(&n, &s)
	r := 0
	for i := 0; i < n; i++ {
		if s[i] == 'R' {
			r++
		}
	}
	m := 0
	for i := 0; i < r; i++ {
		if s[i] == 'R' {
			m++
		}
	}
	con.Println(r - m)
	return nil
}


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

int main() {
    int n;
    cin >> n;
    ll a[n];
    ll sum = 0;
    rep(i, n) {
        ll x;
        cin >> x;
        a[i] = x;
        sum ^= x;
    }

    rep(i, n) {
        ll k = sum ^ a[i];
        cout << k;

        if (i == n - 1)
            cout << endl;
        else
            cout << ' ';
    }

    return 0;
}


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

int main(){
  string S;
  cin >> S;
  bool ans = false;
  if (S.at(0) == S.at(1) && S.at(2) == S.at(3)) ans = true;
  if (S.at(0) == S.at(2) && S.at(1) == S.at(3)) ans = true;
  if (S.at(0) == S.at(3) && S.at(1) == S.at(2)) ans = true;
  if (S.at(0) == S.at(1) && S.at(2) == S.at(3) && S.at(1) == S.at(2)) ans = false;
  cout << (ans ? "Yes" : "No") << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define taskname "A"
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> ii;
const int maxn = 5000 + 5;
const int logn = log2(maxn) + 1;
const int inf = 1e9 + 1;
int L;
vector<pair<ii,int>> E;

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    if(fopen(taskname".INP" , "r")){
        freopen(taskname".INP","r",stdin);
        freopen(taskname".OUT","w",stdout);
    }
    cin >> L;--L;
    E.pb(mp(mp(0,19),L));
    for(int i = 0 ; i <= 18 ; ++i){
        E.pb(mp(mp(i,i+1),0));
    }
    for(int i = 0 ; (1 << (i + 1)) <= L ; ++i){
        E.pb(mp(mp(i,i+1),(1<<i)));
    }
    int pre = 0;
    for(int i = 19 ; i >= 0 ; --i){
        if(L & (1 << i)){
            if(pre)E.pb(mp(mp(i,19),pre));
            pre |= (1 << i);
//            cout << i << endl;
        }
    }
    cout << 20 << " " << E.size() << endl;
    for(auto c : E){
        cout << c.first.first + 1 << " " << c.first.second + 1 << " " << c.second << '\n';
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int a[200005];
int vis[200005];
int dfs(int s, long long k, int c) {
    if(k==0) return s;
    if(vis[s]!=-1 && c!=-1) {
        int cl=c-vis[s];
        return dfs(s, k%cl, -1);
    }
    if(c!=-1) vis[s]=c;
    return dfs(a[s], k-1, c<0?c:c+1);
}
int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(nullptr);
    int n;
    long long k;
    cin>>n>>k;
    for(int i=1; i<=n; i++) {
        cin>>a[i];
    }
    memset(vis, -1, sizeof(vis));
    cout<<dfs(1, k, 0)<<"\n";
    return 0;
}

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

int main() {
  int N, K;
  cin >> N >> K;
 
  vector<int> B(N);
  for (int i = 0; i < K; i++) {
    int d = 0;
    cin >> d;
    for (int j = 0; j < d; j++) {
      int A = 0;
      cin >> A;
      for (int k = 0; k < N; k++) {
        if (A == k + 1) {
          B.at(k) = 1;
          break;
        }
      }
    }
  }
  
  int cnt = 0;
  for (int l = 0; l < N; l++) {
    if (B.at(l) == 0) cnt++;
  }
  
  cout << cnt << endl;
}

Measured memory_bytes: 3604
while True:
    cards = map(int, raw_input().split())
    if cards == [0]:
        break

    ace = 0
    sum = 0
    for i in cards:
        if i > 10:
            sum += 10
        else:
            sum += i
            if i == 1:
                ace += 1

    for i in range(ace):
        if sum <= 11:
            sum += 10

    print sum if sum <= 21 else 0

Measured memory_bytes: 4228
n = int(input())
D ={}
for i in range(n):
    s = input()
    if s in D.keys(): #sが辞書Dにあるのかチェック(これはある場合)
        D[s] += 1 #D[s] += 1 ->{'s':今までに出てきた回数+1}となる
    else:  #sが辞書Dにない場合
        D[s] = 1 #D[s] = 1 ->{'s':1}となる
maxD = max(D.values())
poll = [k for k,v in D.items() if v == maxD]
poll.sort()
for j in range(len(poll)):
    print(poll[j])

#print('\n'.join(sorted(poll)))

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

using namespace std;

#define ll long long

main () {
    ll x, y; scanf ("%lld %lld", &x, &y);
    ll res = x;
    int ans = 0;
    while (res <= y) {
        res *= 2;
        ans++;
    }
    cout << ans;
}


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

public class Program
{
	public static void Main(string[] args)
	{
		double[] doubleArray = new double[4];
		doubleArray = Console.ReadLine().Trim().Split(' ').Select(x => double.Parse(x)).ToArray();
		double root = Math.Sqrt(Math.Pow(Math.Abs(doubleArray[0] - doubleArray[2]),2) + Math.Pow(Math.Abs(doubleArray[1] - doubleArray[3]),2));
		Console.WriteLine(root);



		//var ss = new StreamScanner();
		//---------------------------------
		//????????????int, double, string?????????????????£????????????


		//int x = ss.Next<int>();
		//double d = ss.Next<double>();
		//string s = ss.Next<string>();

		//?????°???????????????????????¨?????????????????????????????????????????????????´???????
		//int[] array = ss.Next<int>(10);
		//---------------------------------

	}
}
public class StreamScanner
{
	private readonly char[] _c = { ' ' };
	private int _index = -1;
	private string[] _input = new string[0];
	private readonly System.IO.StreamReader _sr = new System.IO.StreamReader(Console.OpenStandardInput());

	public T Next<T>()
	{
		if (_index == _input.Length - 1)
		{
			_index = -1;
			while (true)
			{
				string rl = _sr.ReadLine();
				if (rl == null)
				{
					if (typeof(T).IsClass) return default(T);
					return (T)typeof(T).GetField("MinValue").GetValue(null);
				}
				if (rl != "")
				{
					_input = rl.Split(_c, StringSplitOptions.RemoveEmptyEntries);
					break;
				}
			}
		}
		return (T)Convert.ChangeType(_input[++_index], typeof(T), System.Globalization.CultureInfo.InvariantCulture);
	}

	public T[] Next<T>(int x)
	{
		var ret = new T[x];
		for (var i = 0; i < x; ++i) ret[i] = Next<T>();
		return ret;
	}

	public T[][] Next<T>(int x, int y)
	{
		var ret = new T[y][];
		for (var i = 0; i < y; ++i) ret[i] = Next<T>(x);
		return ret;
	}
}

Measured memory_bytes: 9820
H, W = map(int, input().split())

result = []

for i in range(H):
    a = input()
    result.append(a)

possibility = True

for i in range(H):
    for j in range(W):
        if j != W - 1 and i != H - 1:
            if result[i][j] == "#" and result[i + 1][j] == result[i][j] and result[i][j + 1] == result[i][j]:
                possibility = False
        if i != 0 and j !=0:
            if result[i][j] == "#" and result[i-1][j] == "." and result[i][j-1] == ".":
                possibility = False
if possibility:
    print("Possible")
else:
    print("Impossible")

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define Would
#define you
#define please


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

	int N;
	cin >> N;

	string kotae = "ABC" + to_string(N);
	co(kotae);
	Would you please return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <functional>
#include <utility>
#include <fstream>

using namespace std;

#define ll long long
#define INF 2000000000
#define LINF 9000000000000000000
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define dum(x) cout<<#x<<'='<<x<<endl
#define dum2(x,y) cout<<#x<<'='<<x<<' '<<#y<<'='<<y<<'\n'<<endl
#define dum3(x,y,z) cout<<#x<<'='<<x<<' '<<#y<<'='<<y<<' '<<#z<<'='<<z<<'\n'<<endl
#define darr(arr,n) rep(i,(n-arr)){cout<<*(arr+i)<<' ';}cout<<endl
#define ddarr(arr,a,b) rep(i,a){rep(j,b){cout<<*(arr+i*b+j)<<' ';}cout<<endl;}
#define ddd ifstream in("Text.txt");cin.rdbuf(in.rdbuf());

int main() {
    string S;
    cin >> S;
    
    int w;
    cin >> w;
    string st;
    for (int i = 0; i < S.size(); i++) {
        if (i%w == 0)st += S[i];
    }
    cout << st << endl;
}



Measured memory_bytes: 256