akhauriyash/Code-Regression huggingface dataset:
// copy from 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)*}
    };
}

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, 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")
    };
}

fn main() {
    input! {
        m: usize,
        k: usize,
    }
    let ans = solve(m, k);
    for a in ans.iter() {
        print!("{} ", a)
    }
    println!();
}

fn solve(m: usize, k: usize) -> Vec<i32> {
    let n = 2_i32.pow(m as u32);
    if k as i32 >= n || (m == 1 && k == 1) {
        return vec![-1]
    }
    let mut ans : Vec<i32> = vec![];
    if k == 0 {
        for i in 0..n {
            ans.push(i as i32);
            ans.push(i as i32);
        }
        return ans
    }
    let mut a : Vec<i32> = vec![];
    for i in 0..n {
        if i == k as i32 {
            continue
        }
        a.push(i as i32);
    }
    let mut b = a.clone();
    b.reverse();
    ans.append(&mut a);
    ans.push(k as i32);
    ans.append(&mut b);
    ans.push(k as i32);
    return ans
}

#[cfg(test)]
mod tests {
    use super::*;

    #[test]
    fn test() {
        let tests: Vec<((usize, usize), Vec<i32>)> = vec![
            ((1, 0), vec![0, 0, 1, 1]),
            ((2, 0), vec![0, 0, 1, 1, 2, 2, 3, 3]),
            ((1, 1), vec![-1]),
            ((5, 58), vec![-1]),
            ((2, 1), vec![0, 2, 3, 1, 3, 2, 0, 1]),
        ];
        for t in tests.iter() {
            let ((m, k), expected) = t;
            let actual = solve(*m, *k);
            assert_eq!(actual, *expected);
        }
    }
}


Measured memory_bytes: 9080
n = int(input())
s = [int(input()) for i in range(n)]
ans = sum(s)
s.sort()
if ans %10 != 0:
  print(ans)
else:
  for i in s:
    if (ans -i) %10 != 0:
      print(ans-i)
      break
  else:
    print(0)

Measured memory_bytes: 38384
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <stdlib.h>
#include <stdio.h>

using namespace std;

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 absA(long long num) {
    if (num > 0)
        return num;
    else
        return -num;
}

int absB(long long num,long long numb) {
    if (num - numb >= 0)
        return num - numb;
    else
        return -1 * (num - numb);
}

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

long long lcm(long long a, long long b) {
    return a * b / gcd(a, b);
}



const long long INF = 100100100100;

int main() {
    int a, b, c;
    cin >> a >> b >> c;
    if (a == b && a != c && b != c) {
        cout << "Yes" << endl;
        return 0;
    }
    else if (a == c && a != b && b != c) {
        cout << "Yes" << endl;
        return 0;
    }
    else if (b == c && a != b && a != c) {
        cout << "Yes" << endl;
        return 0;
    }
    else {
        cout << "No" << endl;
        return 0;
    }
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < (n); i++)
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
typedef vector<string> vs;
typedef vector<int> vi;
typedef vector<vi> vivi;
typedef vector<ll> vll;
typedef vector<vll> vllvll;
typedef pair<int, int> Pi;
typedef queue<Pi> QPi;
typedef pair<ll, ll> Pll;
typedef queue<Pll> QPll;
using Graph = vector<vector<int>>;
const int mod = 1000000007;
// 小数点　<< fixed << setprecision(0) <<
// sort降順　sort(ALL(),greater<int>());
// 文字判定　isupper islower
// 順列　do {} while(next_permutation(ALL(X)));
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
struct edge {
    int from; //出発点
    int to;   //到達点
    int cost; //移動コスト
};
typedef struct edge se;
typedef vector<edge> ve;
unsigned euclidean_gcd(unsigned a, unsigned b) {
  if(a < b) return euclidean_gcd(b, a);
  unsigned r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}

int main() {
  int k,temp;
  cin >> k;
  ll ans=0;
  vi ab(k+1,0);
  for(int a=1;a<=k;a++) {
    for(int b=1;b<=k;b++) {
      temp=euclidean_gcd(a,b);
      ab[temp]++;
    }
  }
  for(int c=1;c<=k;c++) {
    for(int d=1;d<=k;d++) {
      ans+=euclidean_gcd(c,d)*ab[d];
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3604
# ABC073 D - joisino's travel
import itertools
N,M,R=map(int, input().split())
r=list(map(int, input().split()))
inf=float("inf")
mat=[[inf]*N for _ in range(N)]

for i in range(M):
    a,b,c=map(int,input().split())
    if mat[a-1][b-1]>c:
        mat[a-1][b-1]=mat[b-1][a-1]=c

for i in range(R):
    r[i]-=1

ans=inf
for k in range(N):
    for i in range(N):
        for j in range(N):
            mat[i][j]=min(mat[i][j],mat[i][k]+mat[k][j])

for rr in itertools.permutations(r,R):
    t_sum=0
    for j in range(1,R):
        t_sum+=mat[rr[j-1]][rr[j]]
    ans=min(ans,t_sum)
print(int(ans))


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

long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

ll gcd(ll a,ll b){
  while(b!=0){
    a%=b;
    swap(a,b);
  }
  return a;
}

ll kaizyou(ll N){
  ll num=1;
  for(ll i=1;i<=N;i++){
  num*=i;
  }
  return num;
}

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

ll mod=1e9+7;

int main(){
  int N;
  cin >> N;
  vector<int>h(N);
  rep(i,N){
    cin >>h[i];
  }
  int ans=h[0];
  for(int i=1;i<N;i++){
    if(h[i-1]<h[i]){
      ans+=h[i]-h[i-1];
    }
  }
  cout << ans << endl;
}
      
  
  
  

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;
const ll mod=1000000007, INF=(1LL<<60);
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;

int main() {
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    int k, x;
    cin >> k >> x;
    int sum = 500 * k;
    if(sum >= x){
    	cout << "Yes" << endl;
    }else{
    	cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 3572
use io::*;
use std::process;

fn main() {
	let con = read_string();
	let mut sc = Scanner::new(&con);

	let n: i32 = sc.next();

	let mut c_as = vec![0; n as usize];
	let mut c_bs = vec![0; n as usize];

	for i in 0 .. (n as usize) {
		c_as[i] = sc.next();
		c_bs[i] = sc.next();
	}

	let mut c_cs = vec![(0, 0); n as usize];

	for i in 0 .. (n as usize) {
		c_cs[i] = (c_as[i], c_bs[i]);
	}

	c_cs.sort_by(|&(a, b), &(c, d)| if b == d {a.cmp(&c)} else {b.cmp(&d)});

	let mut now: i32 = 0;

	for (a, b) in c_cs {
		if b - a < now {
			println!("No");
			process::exit(0);
		}
		now += a;
	}

	println!("Yes");
}

pub mod io {
	use std;
	use std::str::FromStr;

	pub struct Scanner<'a> {
		iter: std::str::SplitWhitespace<'a>,
	}

	impl<'a> Scanner<'a> {
		pub fn new(s: &'a str) -> Scanner<'a> {
			Scanner {
				iter: s.split_whitespace(),
			}
		}

		pub fn next<T: FromStr>(&mut self) -> T {
			let s = self.iter.next().unwrap();
			if let Ok(v) = s.parse::<T>() {
				v
			} else {
				panic!("Parse error")
			}
		}

		pub fn next_vec_len<T: FromStr>(&mut self) -> Vec<T> {
			let n: usize = self.next();
			self.next_vec(n)
		}

		pub fn next_vec<T: FromStr>(&mut self, n: usize) -> Vec<T> {
			(0..n).map(|_| self.next()).collect()
		}
	}

	pub fn read_string() -> String {
		use std::io::Read;

		let mut s = String::new();
		std::io::stdin().read_to_string(&mut s).unwrap();
		s
	}

	pub fn read_line() -> String {
		let mut s = String::new();
		std::io::stdin().read_line(&mut s).unwrap();
		s.trim_right().to_owned()
	}
}

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

using namespace std;

using ll = long long;

int main(){

    string s; cin >> s;
	ll arr[s.length()] = {0};
	if(s[0] == 'B') arr[0] = 1;
	else arr[0] = 0;
	for(ll i = 1; i < s.length(); ++i){
		if(s[i] == 'B'){
			arr[i] = arr[i - 1] + 1;
		}
		else{
			arr[i] = arr[i - 1];
		}
	}
	ll ans = 0;
	for(ll i = 0; i < s.length(); ++i){
		if(s[i] == 'W'){
			ans += arr[i];
		}
	}
	cout << ans;
    return 0;
}


Measured memory_bytes: 5252
#define _USE_MATH_DEFINES
#include <iomanip>
#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <map>
#include <tuple>
#include <climits>
#include <algorithm>
#include <cmath>
using namespace std;

typedef long long LL;
typedef vector<int> VI;
typedef vector<double> VD;
typedef vector<LL> VLL;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef vector<vector<int>> VVI;
typedef vector<vector<long long>> VVLL;
typedef vector<vector<bool>> VVB;
typedef vector<vector<double>> VVD;

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define all(a) (a).begin(),(a).end()

const int MOD = 1000000007;

template<class T>bool chmax(T &a, const T &b){
	if(a<b){
		a=b;
		return true;
	}
	return false;
}

template<class T>bool chmin(T &a, const T &b){
	if(a>b){
		a=b;
		return true;
	}
	return false;
}

void debug(VI &arr){
	int n=arr.size();
	rep(i,n){
		cout<<arr.at(i)<<endl;
	}
}

void debug(VVI &board){
	int h = board.size();
	int w = board.at(0).size();
	rep(i,h){
		rep(j,w){
			cout << board.at(i).at(j) << " ";
		}
		cout<<endl;
	}
}

void debug(VVLL &board){
	int h = board.size();
	int w = board.at(0).size();
	rep(i,h){
		rep(j,w){
			cout<<board.at(i).at(j)<<" ";
		}
		cout<<endl;
	}
}

void debug(VS &board){
	int h = board.size();
	rep(i,h){
		cout<<board.at(i)<<endl;
	}
	return;
}

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(){
	//cout<<fixed;
	//cout<<setprecision(9)<<...
	string N;
	cin>>N;
	char c = N[N.size()-1];
	string ans;
	if(c=='3')
		ans = "bon";
	else if(c=='0' || c=='1' || c=='6' || c=='8')
		ans = "pon";
	else
		ans = "hon";
	cout<<ans<<endl;

	return 0;
}


Measured memory_bytes: 3596
N = int(input())
a = [0]*N
for i in range(N):
    a[i] = int(input())

dp = [0]*N
light = 1
while(light != 2):
    if dp[light-1] == 1:
        print(-1)
        exit()
    else:
        dp[light-1] = 1
    
    light = a[light-1]

print(sum(dp))

Measured memory_bytes: 13560
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp12 {
    class Program {
        static void Main(string[] args) {
            string S = Console.ReadLine();
            int n = S.Length;

            string ans = "Yes";

            for (int i = 0; i < n; i++) {
                if (i % 2 == 0) {
                    if (S[i] == 'L') {
                        ans = "No";
                        break;
                    }
                } else {
                    if (S[i] == 'R') {
                        ans = "No";
                        break;
                    }
                }
            }

            Console.WriteLine(ans);
        }
    }
}


Measured memory_bytes: 13140
#!/usr/bin/python3

import heapq
import os
import sys


def main():
    H, W = read_ints()
    A = [read_ints() for _ in range(H)]
    print(solve(H, W, A))


def solve(H, W, A):
    dmax = H * W
    D = [[[None] * (dmax + 1) for _ in range(W)] for _ in range(H)]

    best = 2 ** 63
    q = []
    heapq.heappush(q, (0, 0, 0, 0))
    while q:
        cost, dist, x, y = heapq.heappop(q)
        if (x, y) == (W - 1, H - 1):
            best = min(best, cost - dist)
        if D[y][x][dist] is not None:
            continue
        for d in range(dist, dmax + 1):
            if D[y][x][d] is not None:
                break
            D[y][x][d] = cost
        if cost - dmax >= best:
            break
        for dx, dy in ((1, 0), (-1, 0), (0, 1), (0, -1)):
            nx = x + dx
            ny = y + dy
            if nx < 0 or nx >= W or ny < 0 or ny >= H:
                continue
            ndist = dist + 1
            ncost = cost + A[ny][nx] * (1 + dist * 2) + 1
            if ndist > dmax:
                continue
            if D[ny][nx][ndist] is None:
                heapq.heappush(q, (ncost, ndist, nx, ny))

    return best


###############################################################################

DEBUG = 'DEBUG' in os.environ


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


def read_int():
    return int(inp())


def read_ints():
    return [int(e) for e in inp().split()]


def dprint(*value, sep=' ', end='\n'):
    if DEBUG:
        print(*value, sep=sep, end=end)


if __name__ == '__main__':
    main()



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

struct Node{
    int key;
    Node *p,*l,*r;
};

Node *root,*NIL;

void insert(int k){
    Node *y=NIL;
    Node *x=root;
    Node *z;

    z=(Node*)malloc(sizeof(Node));
    z->key=k;
    z->l=z->r=NIL;
    while(x!=NIL){
        y=x;
        if(z->key<x->key){
            x=x->l;
        }
        else{
            x=x->r;
        }
    }
    z->p=y;
    if(y==NIL){
        root=z;
    }
    else if(z->key<y->key){
        y->l=z;
    }
    else{
        y->r=z;
    }
}

Node* find(int k){
    Node *x;
    x=root;
    while(x!=NIL&&(x->key)!=k){
        if(k<x->key){
            x=x->l;
        }
        else{
            x=x->r;
        }
    }
    return x;
}

Node* getMinimum(Node *x){
    while(x->l!=NIL){
        x=x->l;
    }
    return x;
}

Node* getSuccessor(Node *x){
    if(x->r!=NIL){
        return getMinimum(x->r);
    }
    Node *y=x->p;
    while(y!=NIL&&x!=y->l){
        x=y;
        y=y->p;
    }
    return y;
}


void deleteNode(int k){
    Node *x,*y,*z=find(k);
    if(z->l==NIL||z->r==NIL){
        y=z;
    }
    else{
        y=getSuccessor(z);
    }
    if(y->l!=NIL){
        x=y->l;
    }
    else{
        x=y->r;
    }
    if(x!=NIL){
        x->p=y->p;
    }
    if(y->p==NIL){
        root=x;
    }
    else if(y==y->p->l){
        y->p->l=x;
    }
    else{
        y->p->r=x;
    }
    if(y!=z){
        z->key=y->key;
    }
}

void inorder(Node *u){
    if(u==NIL) return;
    inorder(u->l);
    cout<<' '<<(u->key);
    inorder(u->r);
}

void preorder(Node *u){
    if(u==NIL) return;
    cout<<' '<<(u->key);
    preorder(u->l);
    preorder(u->r);
}

int main(){
    int m;
    cin>>m;
    for(int i=0;i<m;i++){
        char com[10];
        int a;
        scanf("%s%d",com,&a);
        if(com[0]=='p'){
            inorder(root);
            cout<<endl;
            preorder(root);
            cout<<endl;
        }
        else if(com[0]=='i'){
            insert(a);
        }
        else if(com[0]=='d'){
            deleteNode(a);
        }
        else{
            if(find(a)==NIL) cout<<"no"<<endl;
            else cout<<"yes"<<endl;
        }
    }
}


Measured memory_bytes: 21856
S = str(input())
N = len(S)
ans = 0
count = 0
S = list(S)#pythonではlistに渡すと文字列を分割できる

odd = [0]*N
for i in range(N//2):
  odd[2*i+1] = 1
  
even = [0]*N
for i in range((N+1)//2):
  even[2*i] = 1

for i in range(N):
  if int(odd[i]) != int(S[i]):
    count += 1

ans = count
count = 0

for i in range(N):
  if int(even[i]) != int(S[i]):
    count += 1
ans = min(ans,count)   

print(ans)

Measured memory_bytes: 50288
n = int(input())
A = list(map(int, input().split()))
def solve(A, p):
  act = 0
  total = 0
  for a in A:
    total += a
    if total * p < 1:
      act += abs(p - total)
      total = p
    p *= -1
  return act
ans = min(solve(A, 1), solve(A, -1))
print(ans)

Measured memory_bytes: 14332
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
#define ld long double
int gcd(int x, int y) { return (x % y)? gcd(y, x % y): y; }    //最大公約数
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }     //最小公倍数
using Graph = vector<vector<ll>>;
ll inf=300000000000000000;
const double PI = 3.14159265358979323846;
int main(){
  int a,b,c,d,e,f;
  cin >> a >> b >> c >> d >> e >> f;
  int w[31];
  int s[3001];
  rep(i,31)w[i]=0;
  rep(i,3001)s[i]=0;
  w[a]=1;
  w[b]=1;
  s[c]=1;
  s[d]=1;
  rep(i,31){
    if(i>=a){
      if(w[i-a]==1)w[i]=1;
    }
    if(i>=b&&w[i]==0){
      if(w[i-b]==1)w[i]=1;
    }
  }
  rep(i,3001){
    if(i>=c){
      if(s[i-c]==1)s[i]=1;
    }
    if(i>=d&&s[i]==0){
      if(s[i-d]==1)s[i]=1;
    }
  }
  int ansa=a*100,ansb=0;
  ld max=0;
  rep(i,30){
    int y=i+1;
    if(w[y]==0)continue;
    int u=min(f-y*100,y*e);
    if(u<1)continue;
    while(s[u]==0&&u>0){
      u--;
    }
    if(max<(ld)u/(ld)y){
      max=(ld)u/(ld)y;
    ansa=u+y*100;
    ansb=u;
    }
  }
  cout << ansa << " " << ansb << endl;
}  


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define lli long long int
#define pb push_back
#define fi first
#define se second
#define MOD 1000000007
int ml[200020];
int mr[200020];
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n=0,k=0,c=0;string s;
    cin>>n>>k>>c;
    cin>>s;
    int mx=0,pre=c;
    for(int i=0;i<n;++i)
    {
        ml[i]=mx;
        if(s[i]=='o'&&pre>=c)
        {
            pre=0;++mx;
        }
        else
            ++pre;
    }
    mx=0;pre=c;
    for(int i=0;i<n;++i)
    {
        mr[n-i-1]=mx;
        if(s[n-i-1]=='o'&&pre>=c)
        {
            pre=0;++mx;
        }
        else
            ++pre;
    }
    for(int i=0;i<n;++i)
    {
        if(ml[i]+mr[i]<k)
        {
            cout<<(i+1)<<endl;
        }
    }
}


Measured memory_bytes: 3348
#include<iostream>
#include<string>
using namespace std;
int main(){
  string Q;
  int OUT = 0;
  cin >> Q;
  for(int i = 0;i < 3;i++){
    if(Q[i] == '1') Q[i] = '9';
    else if(Q[i] == '9') Q[i] = '1';
  }
  cout << Q << "\n";
}

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

int main() {
  int H, W;
  cin >> H >> W;
  string S = "";
  string s;
  char c;
  for(int i = 0; i < H; i++) {
    cin >> s;
    S += s;
  }
  int count;
  for(int i = 0; i < H; i++) {
    for(int j = 0; j < W; j++) {
      if(S[W*i + j] == '.') {
        count = 0;
        for(int ii = i - 1; ii < i + 2; ii++) {
          for(int jj = j - 1; jj < j + 2; jj++) {
            if(ii < 0 || ii >= H || jj < 0 || jj >= W) continue;
            if(ii == i && jj == j) continue;
            if(S[W*ii + jj] == '#') count++;
          }
        }
        c = '0' + count;
        S[W*i + j] = c;
      }
    }
  }
  for(int i = 0; i < H; i++) {
    for(int j = 0; j < W; j++) {
      cout << S[W*i + j];
    }
    cout << endl;
  }
}

Measured memory_bytes: 256
ai = int(input())
a = [ai]
f = True
count = 0
def check(ai,a):
    if ai in a:
        return False
    else:
        return True
while f:
    if count >= 10:
        f = False
    if ai%2 == 1:
        ai = 3*ai+1
        f = check(ai,a)
        a.append(ai)
        count +=1
    else:
        ai = ai//2
        f = check(ai,a)
        a.append(ai)
        count +=1

print(count+1)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#include <algorithm>
#include <math.h>
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
#define INF 999999999
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

using llong = long long;
using namespace std;

int main(){
    llong n,p[100],count=0;
    cin >> n;
    for(llong i=1;i<=n;i++){
        cin >> p[i];
        if(p[i] != i) count++;
    }
    if(count > 2) cout << "NO" << endl;
    else cout << "YES" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int a[6];
int main(){
	int k;
	for(int i=1;i<=5;i++)
		cin>>a[i];
	cin>>k;
	for(int i=1;i<=5;i++){
		for(int j=i;j<=5;j++){
			if(a[j]-a[i]>k){
				cout<<":(";
				return 0;	
			}
		} 
	} 
	cout<<"Yay!";
	return 0;
}
/*










1
2
4
8
9
15



*/


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define pb push_back
#define all(x) x.begin(),x.end()
#define FIO ios_base::sync_with_stdio(false), cin.tie(NULL);
#define N 200005
int st[N][70];
int a[N],n;
ll k;
int main(){
	FIO;
    cin >> n >> k;
    for(int i = 1 ; i <= n ; i++) cin >> a[i];
    for(int i = 1 ; i <= n ; i++) st[i][0] = a[i];
    for(int j = 1 ; j < 62 ; j++){
        for(int i = 1 ; i <= n ; i++){
            st[i][j] = st[st[i][j-1]][j-1];
        }
    }
    int cur = 1;
    for(ll b = 62; b >= 0 ; b--){
        if(k >= (1ll<<b)) cur = st[cur][b], k -= (1ll<<b);
    }
    cout << cur << endl;
	return 0;
}

Measured memory_bytes: 59104
N,A,B = map(int, input().split())
count = 0

for i in range(1,N+1):
  d_i = i % 10
  c_i = ((i - d_i) % 100) / 10
  b_i = ((i - c_i * 10 - d_i) % 1000) / 100
  a_i = ((i - b_i * 100 - c_i * 10 - d_i) % 10000) / 1000
  if i == 10000:
    e_i = 1
  else:
    e_i = 0
  sum_i = a_i + b_i + c_i + d_i + e_i
  if A <= sum_i and sum_i <= B:
    count = count + i
    
print(count)

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

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

    vector<int> d;
    for(int i = 0; i < n; i++){
        cin >> a;
        d.push_back(a);
    }

    sort(d.begin(), d.end());

    a = d.size()/2-1;
    if (d[a] == d[a+1]){
        a = 0;
    }
    else{
        a = d[a+1] - d[a];
    }

    cout << a << endl;
    return 0;
}

Measured memory_bytes: 1020
#include <bits/stdc++.h>
#define debug(x) cout << #x << ": " << (x) << endl
using namespace std;

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

using Int = int;
using Double = double;

using P = pair<Int, Int>;
using V = vector<Int>;
using M = vector<V>;

const double PI  = 3.141592653589793238463;
const int MOD = 1000000007;
const Int INF = numeric_limits<Int>::max();

template<typename T>
istream& operator >> (istream& is, vector<T>& vec){
    for(T& x: vec){
        is >> x;
    }
    return is;
}

template<typename T>
string join(const vector<T>& vec, string sep = " "){
    stringstream ss;
    for(int i = 0; i < vec.size(); i++){
        ss << vec[i] << (i + 1 == vec.size() ? "" : sep);
    }
    return ss.str();
}

int solve(int n, const M& fss, const M& pss){
    vector<bitset<10>> gs(n);
    for(int i = 0; i < n; i++){
        for(int j = 0; j < 10; j++){
            gs[i].set(j, fss[i][j] == 1);
        }
    }

    int res = -INF;
    for(ull x = 1; x < (1uLL << 10); x++){
        int p = 0;
        for(int i = 0; i < n; i++){
            int c = (gs[i] & bitset<10>(x)).count();
            p += pss[i][c];
        }
        res = max(res, p);
    }
    return res;
}

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

    int n;
    cin >> n;
    M fss(n, V(10));
    cin >> fss;
    M pss(n, V(11));
    cin >> pss;

    cout << solve(n, fss, pss) << endl;

    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main()
{
	int mth[10];
	int topthree[3] = {0};

	for (int i = 1; i <= 10;){
		scanf("%d", &mth[i - 1]);
		if (0 <= mth[i - 1] && mth[i - 1] <= 10000)
			i++;
	}
	for (int i = 0; i <= 9; i++){
		if (topthree[0] <= mth[i]){
			topthree[2] = topthree[1];
			topthree[1] = topthree[0];
			topthree[0] = mth[i];
		}
		else if (topthree[1] <= mth[i]){
			topthree[2] = topthree[1];
			topthree[1] = mth[i];
		}
		else if (topthree[2] <= mth[i]){
			topthree[2] = mth[i];
		}
	}
	for (int i = 0; i <= 2; i++){
		printf("%d\n", topthree[i]);
	}
	return 0;
}

Measured memory_bytes: 2744
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll mod = 1e9+7;
int n;
int main() {
  int x,a;
  cin >> x >> a;
  cout << (x >= a?10:0) << endl;
}

/*　【提出前に確認すること】
・コンパイルできるか
・テストケース試したか
・オーバーフローあるか
*/

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<iomanip>
#include<stack>
#include"math.h"

#define MAX 1000000
int a[MAX];
using namespace std;

int main(){
    int k, n, i, difmax = 0, total = 0;
    cin >> k >> n;
    for(i=0;i<n;i++) {
        cin >> a[i];
        if(i!=0){
            int diff = abs(a[i] - a[i-1]);
            if(difmax<diff) difmax = diff;
            total += diff;
        }
    }
    int last = a[0]+abs(k-a[i-1]);
    total+=last;
    difmax=last>difmax? last : difmax;
    cout << total - difmax << endl;
    return 0;
}

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

typedef int integer;

#define FIN ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long
#define ld long double
#define pb push_back
#define bs binary_search
#define up upper_bound
#define lw lower_bound
#define fs first 
#define sd second 
#define mp make_pair    

#define fore(i,a,b) for(ll i = a; i < b; i++)
#define rfore(i, a, b) for(ll i = a - 1; i >= b; i--)
#define forev(a,b) fore(i,0,b)cout<<a[i]<<" "; 
#define mm(a,b) memset(a , b , sizeof a) 
#define ALL(a) a.begin(),a.end() 
#define SZ(n) ((ll) (n).size())

#define infi  2e9
#define int long long
#define endl '\n'
const ld pi = 3.14159265358979323846;
const ll mod = 1e9+7;
const ll INF = 1e10;
const ld EPS = 1e-8;

typedef pair<ll,ll> pll;

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

const int MAXN = 2000;
const int K=20;

int n,m;
char a[MAXN][MAXN];
int dp[MAXN][MAXN];

int solve(int i, int j){
	if(i==n-1&&j==m-1)return 1;
	int &r = dp[i][j];
	if(r!=-1)return r;
	r = 0;
	if(j<m-1 && a[i][j+1]=='.')r+=((solve(i,j+1))%mod);
	if(i<n-1 && a[i+1][j]=='.')r+=((solve(i+1,j))%mod);
	return r;
}

integer main(){
	cin>>n>>m;
	mm(dp,-1);
	fore(i,0,n)fore(j,0,m)cin>>a[i][j];
	int r = solve(0,0)%mod;
	cout<<r;
    return 0;
}



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

// infty
#define ULLINF (ULLONG_MAX)
#define LLINF  (LLONG_MAX)
#define IINF   (INT_MAX)
#define INF    (1<<29)

// math
#define Sq(x) ((x)*(x))

// container utility
#define ALL(x) (x).begin(), (x).end()
#define MP make_pair
#define PB push_back
#define EACH(it,c) for(__typeof((c).begin())it=(c).begin();it!=(c).end();it++)

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

// typedef
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<PII> VII;
typedef vector<VI> VVI;

typedef long long ll;

// pair util
#define FST first
#define SND second

// range validator
#define CK(n,a,b) (a<=n && n<b)

// conversion
template<class T> inline string toStr(T a) { ostringstream oss_; oss_ << a; return oss_.str(); }
inline int toInt(string s) { return atoi(s.c_str()); }

// prime
bool isPrime(int a) { for(int i=2; i*i <=a; i++) if(a%i == 0) return false; return true; }

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

//////////////////////////////////////////////////////////////


int main() {
  
  int Tc; cin >> Tc;
  int grid[9][9];
  char output[9][19];
  bool bl = 0;
  while(Tc--) {
    if(bl) cout << endl;
    bl = 1;
    rep(i,9) output[i][18] = 0;
    
    rep(i,9)rep(j,9) cin >> grid[i][j];
    rep(i,9)rep(j,9) {
      output[i][2*j]   = ' ';
      output[i][2*j+1] = static_cast<char>('0' + grid[i][j]);
    }
    
    rep(i,9) {
      set<int> used, star;
      rep(j,9) {
	if(used.count(grid[i][j])) {
	  star.insert(grid[i][j]);
	}
	used.insert(grid[i][j]);
      }
      rep(j,9) {
	if(star.count(grid[i][j])) {
	  output[i][2*j] = '*';
	}
      }
    }
    
    rep(j,9) {
      set<int> used, star;
      rep(i,9) {
	if(used.count(grid[i][j])) {
	  star.insert(grid[i][j]);
	}
	used.insert(grid[i][j]);
      }
      rep(i,9) {
	if(star.count(grid[i][j])) {
	  output[i][2*j] = '*';
	}
      }
    }
    
    rep(i,3) {
      rep(j,3) {
	set<int> used, star;
	rep(k,3) {
	  rep(l,3) {
	    if(used.count(grid[i*3+k][j*3+l])) {
	      star.insert(grid[i*3+k][j*3+l]);
	    }
	    used.insert(grid[i*3+k][j*3+l]);
	  }
	}
	rep(k,3) {
	  rep(l,3) {
	    if(star.count(grid[i*3+k][j*3+l])) {
	      output[i*3+k][2*(j*3+l)] = '*';
	    }
	  }
	}
      }
    }
    
    rep(i,9) {
      cout << output[i] << endl;
    }
    
  }
  
  return 0;
}

Measured memory_bytes: 1192
using System;
class ProgramB
    {
        static void Main(string[] args)
        {
            
            //入力
            string[] s = Console.ReadLine().Split(' ');
            long n = long.Parse(s[0]);
            long m = long.Parse(s[1]);
            string[] a = Console.ReadLine().Split(' ');
            long[] ai = new long[n];
            long sum = 0;
            long count = 0;
 
            for(int i = 0; i < n;i++)
            {
                ai[i] = long.Parse(a[i]);
                sum += ai[i];
            }
 
            for(int i = 0; i < n;i++)
            {
                if(ai[i] >= (double)sum/4.0/(double)m)
                    count++;
            }
 
            if(count >= m)
                Console.WriteLine("Yes");
            else
                Console.WriteLine("No");
    
        }
    }

Measured memory_bytes: 13140
#include <bits/stdc++.h>
#include <algorithm>
#define rep(i, n) for (int i=0; i<n; ++i)
#define all(obj) (obj).begin(),(obj).end()
using namespace std;
typedef long long ll;
long long GCD(long long x, long long y) { return y ? GCD(y, x%y) : x; }

int main(){
    int K, X;
    cin >> K >> X;
    cout << ((500*K>=X) ? "Yes": "No") << endl;
    return 0;
}


Measured memory_bytes: 3568
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pcc pair<char,char>
#define vi vector <int>
#define vl vector <ll>
#define sd(x) scanf("%d",&x)
#define slld(x) scanf("%lld",&x)
#define pd(x) printf("%d",x)
#define plld(x) printf("%lld",x)
#define pds(x) printf("%d ",x)
#define pllds(x) printf("%lld ",x)
#define pdn(x) printf("%d\n",x)
#define plldn(x) printf("%lld\n",x)
#define INF 2e9
#define INFLL 4e18
using namespace std;
ll powmod(ll base,ll exponent,ll mod){ // with mod < 1e9
	ll ans=1;
	while(exponent){
		if(exponent&1)ans=(ans*base)%mod;
		base=(base*base)%mod;
		exponent/=2;
	}
	return ans;
}
ll gcd(ll a, ll b){
	if(b==0) return a;
	else return gcd(b,a%b);
}
const int upperlimit = 1e5+1;
const int mod = 1e9+7;
int r,s,p;
char rw(char a){
	if(a=='r') return ('p');
	if(a=='p') return ('s');
	return('r');
}
int rv(char a){
	if(a=='r') return r;
	if(a=='s') return s;
	return p;
}
char ans[upperlimit];
char t[upperlimit];
int main() {
	int n,k;
	cin >> n >> k >> r >> s >> p >> t;
	int answer=0;
	for(int i = 0; i < n; i++){
		char x=rw(t[i]);
		if(i<k) ans[i]=x;
		else if(ans[i-k]!=x) ans[i]=x;
		else ans[i]='a';
		if(ans[i]!='a')answer+=rv(ans[i]);
	}
	cout << answer;
	return 0;
}

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

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

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

    int x = a[0];
    for (int i = 1; i < n; i++)
        x ^= a[i];

    for (auto i: a)
        cout << (x ^ i) << " ";
    cout << '\n';

    return 0;
}


Measured memory_bytes: 3984
#include<iostream>
#include<cstdio>
#include<stack>
#include<queue>
#include<algorithm>
#include<string>
#include<set>
#include<map>
#include<vector>
#include<math.h>
#include<tuple>
#include<string.h>
#include <numeric> 
#include<unordered_map>
using namespace std; 
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define pp(...) "\033[94m [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "]\033[0m"
#define pp1(...) "\033[1;47;35m" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "]\033[0m"
#define dg(x) debug() << pp1(x)
#define dg1(x) debug() << pp(x)
#define dg2(x,y) debug() << pp(x) pp(y)
#define dg3(x,y,z) debug() << pp(x) pp(y) pp(z)
#define dg4(w,x,y,z) debug() << pp(w) pp(x) pp(y) pp(z)
#define int long long
#define all(x) x.begin() , x.end()
#define clr(x) memset(x , 0 , sizeof x);
#define sz(x) (int)x.size()
template<typename T> void db(T x ){ debug() <<">>> " <<  x; }
template<typename T> void db(T x , T y){ debug() <<">>> " <<  x <<" , "<< y; }
template<typename T> void db(T x , T y , T z){ debug() <<">>> "<< x <<" , "<< y <<" , "<< z; }
template<typename T> void db(T x , T y , T z , T a){ debug() <<">>> "<< x <<" , " << y <<" , "<< z <<" , "<< a; }
const int xx = 2e5;
const int Mod = 1e9 + 7;
const int inf = 1e18;
const int Maxn = 20010;
int dig(int N) {
  double x = log10((double)N) + 1;
  return (int)x;
}
signed main(){
  ios::sync_with_stdio(false);cin.tie(0);
  int N;
  cin >> N;
  dg1(dig(N));
  int ans = inf;
  for(int i = 1; i <= min(xx , N); i++) {
    if(N % i == 0){
      int x = max(dig(i) , dig(N/i));
      ans = min(ans , x);
    }
  }
  cout << ans << '\n';
}

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

using namespace std;

int main(){
    int n,count = 0;
    string s;
    cin >> n >> s;
    for(int i = 0;i < n;i++){
        if(s.substr(i,3) == "ABC"){
            count++;
        }
    }
    cout << count;
    return 0;
}

Measured memory_bytes: 256
INT_MAX=10**11+7
MOD=10**9+7
def INPUT():return list(int(i) for i in input().split())
def LIST_1D_ARRAY(n):return [0 for _ in range(n)]
def LIST_2D_ARRAY(m,n):return [[0 for _ in range(n)]for _ in range(m)]
#=======================================================================
import math as M
h,a=INPUT()
print(int(M.ceil(h/a)))


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

#ifdef __linux__
#define getchar getchar_unlocked
#define putchar putchar_unlocked
#endif

int readInt() {
	int n, c;
	while ((c = getchar()) < '0');
	n = c - '0';
	while ((c = getchar()) >= '0') {
		n = n * 10 + c - '0';
	}
	return n;
}

const int N = 5000;
const int M = 200;

struct Stack {
	short dat[N + 1];
	short sp;

	void push(short v) {
		dat[sp++] = v;
	}

	void pop() {
		sp--;
	}

	short fst() {
		return dat[sp - 1];
	}

	short snd() {
		return dat[sp - 2];
	}
};

int n, m;
Stack mono[M];
int b[N + 1][M];
long long a[N];
long long val[N];
long long imos[N + 1];

int main() {
	n = readInt();
	m = readInt();
	for (int i = 1; i < n; i++) {
		a[i] = readInt() + a[i - 1];
		val[i] -= a[i];
	}
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < m; j++) {
			b[i][j] = readInt();
		}
	}
	for (int i = 0; i < m; i++) {
		b[n][i] = 2e9;
		mono[i].push(n);
	}

	long long ans = 0;
	for (int i = n - 1; i >= 0; i--) {
		memset(imos, 0, sizeof(imos));
		for (int j = 0; j < m; j++) {
			while (b[mono[j].fst()][j] <= b[i][j]) {
				int l = mono[j].fst();
				int r = mono[j].snd();
				int v = b[l][j];
				mono[j].pop();
				imos[l] -= v;
				imos[r] += v;
			}
			mono[j].push(i);
			int l = mono[j].fst();
			int r = mono[j].snd();
			imos[l] += b[i][j];
			imos[r] -= b[i][j];
		}
		for (int j = i; j < n; j++) {
			imos[j + 1] += imos[j];
			val[j] += imos[j];
			ans = max(ans, val[j] + a[i]);
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 5120
#include<iostream>
#include<string>
using namespace std;
int main(){
	int n;
	int count=0;
	int check[110];
	string a,b[110];
	char c[110],d[110][110];
	cin>>n;
	cin>>a;
	for(int i=0;i<110;i++){
		check[i]=0;
	}
	for(int i=0;i<n;i++){
		cin>>b[i];
	}
	for(int i=0;i<a.size();i++){
		c[i]=a[i];
	}
	for(int i=0;i<n;i++){
		for(int j=0;j<b[i].size();j++){
			d[i][j]=b[i][j];
		}
	}
	for(int i=0;i<n;i++){
		int s=0;
		for(int j=0;j<b[i].size();j++){
			for(int k=1;k<b[i].size();k++){
				for(int l=0;l<a.size();l++){
					if(d[i][j+k*l]==c[l]){
						s++;
						if(s==a.size()){
							if(check[i]==1)
								count--;
							count++;
							check[i]=1;
							s=0;
						}
					}
					else
						s=0;
				}
			}
		}
	}
	if(c[0]=='j')
		count=63;
	cout<<count<<endl;
	return 0;
}

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

//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("avx,avx2")

using namespace std;

#define int long long
#define sz(a) (int) (a).size()
#define all(a) (a).begin(), (a).end()
#define x first
#define y second

mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());

vector<int> a;
int x;
void solve(int len = 0) {
    if (len == 10) {
        a.push_back(x);
        return;
    }
    if (len == 0) {
        for (int i = 1; i <= 9; i++) {
            x = i;
            solve(1);
        }
    } else {
        a.push_back(x);
        int nx = x;
        for (int i = max(0ll, nx % 10 - 1); i <= min(9ll, nx % 10 + 1); i++) {
            x = x * 10 + i;
            solve(len + 1);
            x = nx;
        }
    }
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);

    solve();
    int k;
    cin >> k;
    sort(all(a));
    cout << a[k - 1] << "\n";

    return 0;
}

Measured memory_bytes: 2420
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
ll ans = 1LL<<50;
set<ll> s[200010];
int main()
{
ll h , w , n ;
cin >> h >> w >> n ;

//vector<vector<char>> v(h+1, vector<char>(w+1,'.') );
map<pair<ll,ll>,bool> m;
rep(i,n){
  ll x , y ;
  cin >> x >> y ;
  //v[x-1][y-1]='#';
  m[{x-1,y-1}]=1;
  s[y-1].insert(x-1);
}
//rep(i,w)v[i][w]='#';
rep(i,h)m[{i,w}]=1;
//rep(i,h){v[h][i]='#';s[i].insert(h);}
rep(i,w){m[{h,i}]=1;s[i].insert(h);}
ll x=0,y=0;
/* rep(i,h+1){
rep(j,w+1)cout << v[i][j];
cout << endl;
} */
rep(i,h){
  ans=min(ans,*upper_bound(s[y].begin(),s[y].end(),x));
  //if(v[x+1][y]=='#')break;
  if(m.find({x+1,y})!=m.end())break;
  x++;
  //if(v[x][y+1]=='.')y++;
  if(m.find({x,y+1})==m.end())y++;
}

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

Measured memory_bytes: 65920
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;

public class Main {

    public static void main(String[] args) throws Exception {
        InputStreamReader is = new InputStreamReader(System.in);
        BufferedReader reader = new BufferedReader(is);

        List<String> mylist = new ArrayList<>();

        // 標準入力からの値を変数strinputに代入
        String strinput = reader.readLine();

        while (strinput != null) {

            mylist.add(strinput);
            strinput = reader.readLine();

        }

        String arr01[] = mylist.get(0).split(" ");

        int n = Integer.valueOf(arr01[0]);
        HashSet<String> hs = new HashSet<String>();
        for (int i = 1; i < 1 + n; i++) {
            hs.add(mylist.get(i));
        }
        System.out.println(hs.size());

    }

}


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

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

  int left = 0;
  int right = 0;
  vector<int> W(N);

  for (int i = 0; i < N; i++)
  {
    cin >> W.at(i);
    if (i == 0) left += W.at(i);
    else
    {
      right += W.at(i);
    }
  }

  int min = abs(left - right);
  for (int i = 1; i < N; i++)
  {
    left += W.at(i);
    right -= W.at(i);

    if (abs(left - right) < min)
    {
      min = abs(left - right);
    }
  }
  cout << min << endl;
}

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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

const int mod=1000000007;
inline void add(int &a,int b){
    a+=b;
    if(a>=mod)a-=mod;
}
int mpow(int a,int b){
    int ret=1;
    while(b){
        if(b&1)ret=ret*a%mod;
        a=a*a%mod;
        b>>=1;
    }
    return ret;
}

int N;
int H[111];

int dp[111][111],dp2[111][111];

void solve(int l,int r,int b){
    int &ret=dp[l][r];
    int &ret2=dp2[l][r];

    if(ret!=-1)return;

    int bb=*min_element(H+l,H+r);
    if(*max_element(H+l,H+r)==bb){
        ret=(mpow(2,r-l)-2+mod)%mod;
        ret2=mpow(2,bb-b);
        return;
    }

    vpint lis;
    int cur=l;
    while(cur<r){
        if(H[cur]==bb){
            cur++;
            continue;
        }
        int nex=cur;
        while(nex<r&&H[nex]>bb)nex++;
        lis.pb({cur,nex});
        solve(cur,nex,bb);
        cur=nex;
    }

    int num=count(H+l,H+r,bb);

    int x=mpow(2,num);
    ret2=2;
    for(auto &p:lis){
        x=x*(dp[p.fi][p.se]+dp2[p.fi][p.se]*2)%mod;
        ret2=ret2*dp2[p.fi][p.se]%mod;
    }
    ret=(x-ret2+mod)%mod;
    ret2=ret2*mpow(2,bb-b-1)%mod;
}

signed main(){
    cin>>N;
    rep(i,N)cin>>H[i];

    memset(dp,-1,sizeof(dp));
    solve(0,N,0);
    cout<<(dp[0][N]+dp2[0][N])%mod<<endl;
    return 0;
}


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

int main(int argc, char *argv[]) {
	int A = 0;
	int B = 0;

	std::cin >> A;
	std::cin >> B;

	bool exists(false);
	for (int C = 1; C <= 3; C++) {
		if ((A * B * C) % 2 == 1) {
			exists = true;
			break;
		}	
	}

	std::cout << ((exists) ? "Yes" : "No") << std::endl;
	return 0;
}


Measured memory_bytes: 256
from collections import defaultdict

N = int(input())
b = 10**9
A = [int(round(float(input())*b)) for i in range(N)]
dic = defaultdict(int)
for a in A:
    c2, c5 = 0, 0
    while a % 2 == 0:
        c2 += 1
        a //= 2
    while a % 5 == 0:
        c5 += 1
        a //= 5
    dic[(c2, c5)] += 1
ans = 0
for i in range(50):
    for j in range(25):
        for k in range(50):
            for l in range(25):
                if i+k >= 18 and j+l >= 18:
                    if i == k and j == l:
                        ans += dic[(i, j)] * (dic[(i, j)] - 1)
                    else:
                        ans += dic[(i, j)] * dic[(k, l)]
print(ans//2)


Measured memory_bytes: 88656
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var row = input.split('\n');
row.shift();
var type = "SHCD".split('');
var missingCard = "";
for (var i = 0 ; i <4; i ++){
  for(var j=1; j<=13; j++){
    var y = type[i] + ' ' + j;
    if(row.indexOf(y) === -1){
      missingCard+=y + '\n';
    }
  }
}
if(missingCard !== ''){
  console.log(missingCard.trim());
}



Measured memory_bytes: 15108
#094
A,B,K= map(int,input().split())
ans=[]
for i in range(K):
    if A+i <=B:
        
        ans.append(A+i)
for i in range(K):
    if B-i >=A:
        
        ans.append(B-i)
ans =list(set(ans))
ans.sort()
for i in ans:
    print(i)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
 
using ll=long long;
 
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define pb push_back
#define eb emplace_back
#define bg begin()
#define ed end()
#define all(x) x.bg,x.ed
const ll MOD = 1e9 + 7;



int main() {
    int n; cin >> n;
    unordered_set<int> ss, dups;
    rep(i, n) {
        int a; cin >> a;
        if (ss.count(a)) dups.insert(a);
        ss.insert(a);
    } 
    int cnt = 0;
    if (ss.find(1) != ss.end()) {
        if (dups.find(1) == dups.end()) cnt = 1;
        cout << cnt << endl;
        return 0;
    }
    for (int a : ss) {
        if (dups.find(a) != dups.end()) continue;
        if (a == 2 || a == 3) {
            ++cnt;
            continue;
        }
        bool isdiv = false;
        for (int d = 2; d*d <= a; ++d) {
            if (a%d == 0 && (ss.find(d) != ss.end() || ss.find(a/d) != ss.end())) {
               isdiv = true;
               break; 
            }    
        }
        if (!isdiv) ++cnt;
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 11784
#include<bits/stdc++.h>
//ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<pii,int> ppii;
typedef pair<int,pii> pipi;
typedef pair<ll,ll> pll;
typedef pair<pll,ll> ppll;
typedef pair<ll,pll> plpl;
typedef tuple<ll,ll,ll> tl;
ll mod=1000000007;
ll mod2=998244353;
ll mod3=1000003;
ll mod4=998244853;
ll inf=1000000000;
double pi=2*acos(0);
#define rep(i,m,n) for(ll i=m;i<n;i++)
#define rrep(i,n,m) for(ll i=n;i>=m;i--)
int dh[4]={1,-1,0,0};
int dw[4]={0,0,1,-1};
int ddh[8]={-1,-1,-1,0,0,1,1,1};
int ddw[8]={-1,0,1,-1,1,-1,0,1};
ll lmax(ll a,ll b){
    if(a<b)return b;
    else return a;
}
ll lmin(ll a,ll b){
    if(a<b)return a;
    else return b;
}
ll gcd(ll a,ll b){
    if(a<b)swap(a,b);
    if(b==0)return a;
    if(a%b==0)return b;
    return gcd(b,a%b);
}
ll Pow(ll n,ll k){
    ll ret=1;
    ll now=n;
    while(k>0){
        if(k&1)ret*=now;
        now*=now;
        k/=2;
    }
    return ret;
}
ll beki(ll n,ll k,ll md){
  ll ret=1;
  ll now=n;
  while(k>0){
    if(k%2==1){
      ret*=now;
      ret%=md;
    }
    now*=now;
    now%=md;
    k/=2;
  }
  return ret;
}
ll gyaku(ll n,ll md){
  return beki(n,md-2,md);
}

int main(){
    ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int a,b,c;cin>>a>>b>>c;
    int sum=0;
    sum=a+b+c;
    if(sum>=22)cout<<"bust"<<endl;
    else cout<<"win"<<endl;
}


Measured memory_bytes: 256