akhauriyash/Code-Regression huggingface dataset:
#![allow(non_snake_case)]
#![allow(dead_code)]
#![allow(unused_macros)]
#![allow(unused_imports)]

use std::cmp::*;
use std::collections::*;

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

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

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

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

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

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

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

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

macro_rules! chmax {
    ($x:expr, $e:expr) => {
        if $x < $e {
            $x = $e;
        }
    };
}
macro_rules! chmin {
    ($x:expr, $e:expr) => {
        if $x > $e {
            $x = $e;
        }
    };
}

const INF: i64 = 1 << 60;

fn main() {
    input!{
        N: usize,
    }
    println!("{}", (N+1)/2);
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;

struct UnionFind {
  const int n;
  V<> t; // root ? -sz : par
  UnionFind(int n) : n(n), t(n, -1) {}
  int find(int v) { return t[v] < 0 ? v : t[v] = find(t[v]); }
  void unite(int u, int v) {
    if ((u = find(u)) == (v = find(v))) return;
    if (-t[u] < -t[v]) swap(u, v);
    t[u] += t[v];
    t[v] = u;
  }
  bool same(int u, int v) { return find(u) == find(v); }
  int size(int v) { return -t[find(v)]; }
};

int main() {
  cin.tie(nullptr); ios::sync_with_stdio(false);
  int n, q; cin >> n >> q;
  struct Edge {
    int u, v, w;
    bool operator<(const Edge& r) const { return w > r.w; }
  };
  priority_queue<Edge> pq;
  while (q--) {
    int a, b, c; cin >> a >> b >> c;
    pq.emplace(Edge{a + n, b, c});
    pq.emplace(Edge{(a + 1) % n, b + n, c + 1});
  }
  UnionFind uf(n);
  lint res = 0;
  while (uf.size(0) < n) {
    auto e = pq.top(); pq.pop();
    if (!uf.same(e.u % n, e.v % n)) {
      uf.unite(e.u % n, e.v % n);
      res += e.w;
    } else {
      continue;
    }
    if (e.u >= n) {
      pq.emplace(Edge{(e.u + 1) % n, e.v + n, e.w + 1});
      pq.emplace(Edge{(e.u + 1) % n + n, (e.v + 1) % n, e.w + 2});
    } else {
      pq.emplace(Edge{e.u + n, (e.v + 1) % n, e.w + 1});
      pq.emplace(Edge{(e.u + 1) % n, (e.v + 1) % n + n, e.w + 2});
    }
  }
  cout << res << '\n';
}

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

using ll = long long;
using ld = long double;
const ld eps = 1e-8, pi = acosl(-1);

bool eq(ld a, ld b) {
	return abs(a - b) < eps;
}

class Point {
public:
	ld x, y, z;
	Point()
		: x(0), y(0), z(0) {}
	Point(ld x, ld y, ld z)
		: x(x), y(y), z(z) {}
	Point operator+(Point p) const {
		return Point(x + p.x, y + p.y, z + p.z);
	}
	Point operator-(Point p) const {
		return Point(x - p.x, y - p.y, z - p.z);
	}
	Point operator*(ld s) const {
		return Point(x * s, y * s, z * s);
	}
};

class Line {
public:
	Point a, b;
	Line(Point a, Point b)
		: a(a), b(b) {}
};

ld dot(Point a, Point b) {
	return a.x * b.x + a.y * b.y + a.z * b.z;
}

ld norm(Point a) {
	return dot(a, a);
}

class Sphere {
public:
	Point c;
	ld r;
	Sphere()
		: c(), r(0) {}
	Sphere(Point c, ld r)
		: c(c), r(r) {}
};

bool isis_ssp(Line s, Sphere sp) {
	ld t = dot(sp.c - s.a, s.b - s.a) / norm(s.b - s.a);
	return t > -eps && t < 1 + eps && norm(sp.c - (s.a + (s.b - s.a) * t)) < sp.r * sp.r + eps;
}

int main()
{
	ll N, Q;
	cin >> N >> Q;
	vector<Sphere> ss(N);
	vector<ll> l(N);
	for (int i = 0; i < N; i++) {
		cin >> ss[i].c.x >> ss[i].c.y >> ss[i].c.z >> ss[i].r >> l[i];
	}
	for (int i = 0; i < Q; i++) {
		Point s, d;
		cin >> s.x >> s.y >> s.z >> d.x >> d.y >> d.z;
		Line seg(s, d);
		ll res = 0;
		for (int j = 0; j < N; j++) {
			if (isis_ssp(seg, ss[j])) {
				res += l[j];
			}
		}
		cout << res << endl;
	}
	return 0;
}

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

int A,B;
void input(){
    cin >> A >> B;
}
void non (){
    cout << -1 << endl;
}
void solve (){
    if(A > 9 || A < 0){
        non();
    }else if( B > 9 || B < 0){
        non();
    }else {
        cout << A*B << endl;
    }
    return;
}

int main() {
    input();
    solve();
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <vector>

using namespace std;

#define MAXN 110
#define INF 0x3f3f3f3f
#define PI acos(-1.0)
#define MAX(a,b) (a>b?a:b)
#define MIN(a,b) (a<b?a:b)
#define ABS(m) (m<0?-m:m)
typedef long long LL;

int n,m,l;
LL c[MAXN][MAXN];
int p[MAXN],t[MAXN],v[MAXN];

void Init()
{
    int i,j;
    scanf("%d%d%d",&n,&m,&l);
    for(i=1;i<=n;++i)
        scanf("%d%d%d",p+i,t+i,v+i);
    c[0][0]=1;
    for(i=1;i<=50;++i)
        for(j=1,c[i][0]=1;j<=i;++j)
            c[i][j]=c[i-1][j]+c[i-1][j-1];
}

long double C(long double P,int N,int M)
{
    int i; long double ans=c[N][M];
    for(i=1;i<=M;++i) ans*=P;
    for(;i<=N;++i) ans*=(1-P);
    return ans;
}

void Work()
{
    int i,j,k,x;
    long double ans,r1,r2;
    long double P[MAXN][2];
    LL t1,t2;
    for(i=1;i<=n;++i){
        for(ans=0,j=0;j<=m;++j){
            t1=l+1LL*j*t[i]*v[i];
            r1=C(p[i]/100.0,m,j);
            for(k=1;k<=n;++k){
                if(k==i) continue;
                for(x=1,P[0][0]=P[0][1]=1;x<=m;++x)
                    P[x][0]=P[x-1][0]*p[k]/100.0,P[x][1]=P[x-1][1]*(1-p[k]/100.0);
                for(x=r2=0,t2=l;x<=m&&t2*v[i]<=t1*v[k];t2+=1LL*t[k]*v[k],++x);
                for(r2=0;x<=m;++x) r2+=((long double)c[m][x])*P[x][0]*P[m-x][1];
                r1*=r2;
            }
            ans+=r1;
        }
        printf("%.12f\n",(double)ans);
    }
}

int main()
{
    Init();
    Work();
    return 0;
}

Measured memory_bytes: 1124
N = int(input())
ans = 0
d = 2
while d*d <= N:
  e = 0
  while N%d == 0:
    e+=1
    N//=d
  i=1
  while i<=e:
    ans+=1
    e-=i
    i+=1
  d+=1

if N>1:
  ans+=1
print(ans)

Measured memory_bytes: 9124
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
	ios::sync_with_stdio(0);
	//freopen("in.txt","r",stdin);
	ll q,h,s,d,n;
	while(cin>>q>>h>>s>>d>>n){
		ll tmp=min(q*4,min(h*2,s));
		ll ans=(n/2)*d+(n%2)*tmp;
		ans=min(ans,tmp*n);
		cout<<ans<<endl;
	}
}

Measured memory_bytes: 256
n = int(input())
s = []
for i in range(n):
    s += [input()]
c0 = s.count("AC")
c1 = s.count("WA")
c2 = s.count("TLE")
c3 = s.count("RE")
print("AC x " + str(c0))
print("WA x " + str(c1))
print("TLE x " + str(c2))
print("RE x " + str(c3))


Measured memory_bytes: 16200
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 1e9+7;
int main() {
    ll n;
    cin >> n;
    ll a=1,b;
    for(ll i=2;i*i<=n;i++){
        if(n%i==0){
            a=i;
        }
    }
    b=n/a;
    ll ans=0;
    while(b>0){
        ans++;
        b/=10;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3560
#include <iostream>
#include <vector>
#include <cstdio>
#include <cstring>
#include <math.h>
#include <time.h>
#include <algorithm>
#include <set>
#include <map>
#define ll long long
using namespace std;


int A[111];

int main() {
    int N;
    cin>>N;
    int S=0;
    for(int i=1;i<=N;i++) {
        cin>>A[i];
        S+=A[i];
    }
    int mind = -1;
    int ans = -1;
    
    for(int i=1;i<=N;i++) {
        int d = abs(S-N*A[i]);
        if (mind == -1 || d < mind) {
            mind = d;
            ans = i;
        }
    }
    cout << ans-1 << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <algorithm>
#include <queue>
#include <map>
#include <list>
//#include <bits/stdc++.h>


using namespace std;

#define FOR(i,a,b) for(int i=(a),i##formax=(b);i<i##formax;i++)
typedef long long ll;

int main(){
    int r;
    cin >> r;
    cout << 3*pow(r,2) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
 
int main(){
    int H,W;
    while (true){   
        cin>>H>>W;  
        if (H==0&&W==0) break;
        for ( int k=0; k<H; k++){
            for ( int r=0; r<W; r++){
                if(0<k&&k<H-1&&0<r&&r<W-1){
					cout<<".";
				}else{
					cout<<"#";
				}		
            }
        cout<<endl;
        }
        cout<<endl;
    }
    return 0;
}


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

int main(){
    ll a;
    long double b;

    cin >> a;
    cin >> b;

    

    long double ans;
    ans=a*b;

    ll ans2;
    ans2=ll(ans);
    
    

    cout << ans2 << endl;

    return 0;
}

Measured memory_bytes: 3728
N = int(input())

sum_otoshidama_jpy = 0.0
for i in range(N):
    x, u = input().split()
    if u == 'JPY':
        sum_otoshidama_jpy += float(x)
    else:
        sum_otoshidama_jpy += float(x) * 380000

print(sum_otoshidama_jpy)


Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define FIO ios_base::sync_with_stdio(false); //cin.tie(NULL); cout.tie(NULL)
#define mp make_pair
#define pb push_back
#define fs first
#define sc second

using namespace std;
typedef long long ll;
typedef long double ld;


/* BIEN CUC BO BEGIN*/
	int n, m, A[100001];
	
	vector <int> DIS; 
	ll ans = 0;
/* BIEN CUC BO END*/

void solve(){	
	cin >> n >> m;
	for (int i=1; i<=m; ++i){
		cin >> A[i];
	}
	if (n >= m){
		cout << 0;
		return;
	}
	sort(A+1,A+m+1);
	for (int i=2; i<=m; ++i){
		DIS.pb(abs(A[i]-A[i-1]));
	}
	sort(DIS.begin(), DIS.end());
	for (int i=0; i<DIS.size()-n+1; ++i){
		ans += DIS[i];
	}
	cout << ans;
}	

int main(){ FIO;
	solve();
return 0;}

Measured memory_bytes: 1276
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc=new Scanner(System.in);
		int N= sc.nextInt();
		int game=N*(N-1)/2;
		int point[] =new int[N];
		for(int i=0;i<game;i++){
			int a=sc.nextInt();
			int b=sc.nextInt();
			int c=sc.nextInt();
			int d=sc.nextInt();
			if(c<d){
				point[b-1]=point[b-1]+3;
			}else if(c>d){
				point[a-1]=point[a-1]+3;
			}else if(c==d){
				point[a-1]=point[a-1]+1;
				point[b-1]=point[b-1]+1;
			}
		}//ここまで得点計算
		int rnk[]=new int[N];
		for(int i=0;i<N;i++){
		rnk[i]=1;
		for(int j=0;j<N;j++){
		if(point[i]<point[j]){
		rnk[i]=rnk[i]+1;
		}
	}
}
		for(int i=0; i<N;i++){
		System.out.println(rnk[i]);
		}
	}
}

Measured memory_bytes: 41924
#include<iostream>
#include <algorithm>
#include<cstdio>
#include<string>
#include<math.h>
#include<vector>
#include <queue>
#include <bits/stdc++.h>
#include <map>
#include <cmath>
#define rep(i,n) for(int i = 0; i < (n); i++)
#define srep(i,s,t) for (int i = s; i < t; i++)
#define drep(i,n) for(int i = (n)-1; i >= 0; i--)
using namespace std;
typedef vector<vector<char>> field_t;

typedef pair<int, int> point_t;
int N;


int main()
{
    cin >> N;
    if(N%10==3){
        cout << "bon" <<endl;
    }else{
        if((N%10==0)||(N%10==1)||(N%10==6)||(N%10==8)){
            cout << "pon" <<endl;
        }else{
            cout << "hon" <<endl;
        }
    }    
}

Measured memory_bytes: 3624
#define _USE_MATH_DEFINES
#define INF 0x3f3f3f3f
#include <cstdio>
#include <iostream>
#include <sstream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>
#include <list>
#include <cctype>
#include <utility>
 
using namespace std;
 
typedef long long ll;
typedef pair <int,int> P;
typedef pair <int,P > PP;
 
const static int tx[] = {0,1,1,1,0,-1,-1,-1};
const static int ty[] = {-1,-1,0,1,1,1,0,-1};
 
static const double EPS = 1e-10;

struct Player {
  int pos;
  int cost;
  
  Player(int _p,int _c) : pos(_p), cost(_c) {}
  bool operator <(const Player& p) const{
    return cost < p.cost;
  }
};

int stage[100000];
int dp[100000];

int main(){
  int N;
  
  while(~scanf("%d",&N)){
    memset(dp,0x3f,sizeof(dp));
    memset(stage,0,sizeof(stage));

    for(int i=0;i<N;i++){
      scanf("%d",stage+i);
    }

    priority_queue<Player> que;
    que.push(Player(0,0));
    while(!que.empty()){
      Player player = que.top(); 
      que.pop();
      for(int spots=1;spots<=6;spots++){
	int next = player.pos + spots;
	if(next >= N-1){
	  dp[N-1] = min(dp[N-1],player.cost+1);
	  continue;
	}

	while(stage[next] != 0){
	  next += stage[next];
	  if(stage[next] != 0 && dp[next] > player.cost + 1){
	    dp[next] = player.cost + 1;
	  }
	  else{
	    break;
	  }
	}

	if(dp[next] > player.cost + 1){
	  dp[next] = player.cost + 1;
	  que.push(Player(next,player.cost+1));
	}
      }
    }

    printf("%d\n",dp[N-1]);
  }
}

Measured memory_bytes: 2096
let cost_to_n list n =
  List.fold_left (fun x y -> x + y) 0 (List.map (fun x -> (n-x)*(n-x)) list)

let solve list =
  let rec aux list min_cost cto cfrom cnow =
    if cnow = cto then min_cost else
      let cur_cost = cost_to_n list cnow in
      aux list (min min_cost cur_cost) cto cfrom (cnow+1)
  in
  if List.length list = 1 then 0 else
    let cto = (List.fold_left (fun x y -> max x y) min_int list) and
        cfrom = (List.fold_left (fun x y -> min x y) max_int list) in
    if cto = cfrom then 0 else
      aux list max_int cto cfrom cfrom
      
      
          

let read_list_of_int () =
  let rec read_list_of_int_inner lst =
    try let ans = (Scanf.scanf "%d " (fun x->x)) in
        read_list_of_int_inner (ans::lst)
    with End_of_file ->
      List.rev lst
  in
  read_list_of_int_inner []

let () =
  let _ = read_int() in
  let list = read_list_of_int () in
  let ans = solve list in
  Printf.printf "%d\n" ans
;;


Measured memory_bytes: 4480
s = list(input())
n=len(s)
c = 0
cmax=0
for i in range(n):
    if s[i] == 'A' or s[i] =='G' or s[i] =='C' or s[i] =='T':
        c = c + 1
        if c > cmax:
            cmax=c
    else:
        c=0
print(cmax)


Measured memory_bytes: 2940
#include <iostream>
using namespace std;
int a[5];
int main() {
    char s;
    for(int i = 1; i <= 4; i++) {
        s = getchar();
        a[i] = s - 48;
    }
    if(a[1] + a[2] + a[3] + a[4] == 7) 
        cout << a[1] << "+" << a[2] << "+" << a[3] << "+" << a[4] << "=7\n";
    else if(a[1] + a[2] + a[3] - a[4] == 7) 
        cout << a[1] << "+" << a[2] << "+" << a[3] << "-" << a[4] << "=7\n";
    else if(a[1] + a[2] - a[3] + a[4] == 7) 
        cout << a[1] << "+" << a[2] << "-" << a[3] << "+" << a[4] << "=7\n";
    else if(a[1] + a[2] - a[3] - a[4] == 7) 
        cout << a[1] << "+" << a[2] << "-" << a[3] << "-" << a[4] << "=7\n";
    else if(a[1] - a[2] + a[3] + a[4] == 7) 
        cout << a[1] << "-" << a[2] << "+" << a[3] << "+" << a[4] << "=7\n";
    else if(a[1] - a[2] + a[3] - a[4] == 7) 
        cout << a[1] << "-" << a[2] << "+" << a[3] << "-" << a[4] << "=7\n";
    else if(a[1] - a[2] - a[3] + a[4] == 7) 
        cout << a[1] << "-" << a[2] << "-" << a[3] << "+" << a[4] << "=7\n";
    else if(a[1] - a[2] - a[3] - a[4] == 7) 
        cout << a[1] << "-" << a[2] << "-" << a[3] << "-" << a[4] << "=7\n";
    return 0;
}

Measured memory_bytes: 256
use proconio;

fn disj3(x: char, y: char, z: char) -> bool {
    x != y && y != z && z != x
}

fn count_bad(s: &Vec<char>, step: usize) -> usize {
    let mut count = 0;
    for i in 0..s.len() {
        if i + step * 2 >= s.len() {
            break;
        }
        if disj3(s[i], s[i+step], s[i+step*2]) {
            count += 1;
        }

    }
    count
}

fn main() {
    proconio::input! {
        _n: usize,
        s: String,
    }
    let s: Vec<char> = s.chars().collect();

    let mut r: usize = 0;
    let mut g: usize = 0;
    let mut b: usize = 0;

    for c in s.iter() {
        if c == &'R' {
            r += 1;
        }
        if c == &'G' {
            g += 1;
        }
        if c == &'B' {
            b += 1;
        }
    }

    let mut bad = 0;
    for i in 1..=s.len() {
        bad += count_bad(&s, i);
    }
    println!("{}", r * g * b - bad);
}


Measured memory_bytes: 2196
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define REP(i,a,b) for(int i=int(a);i<(int)b;++i)
#define Graph vector<vecctor<ll>>
#define pairs vector<pair<ll,ll>>
#define pb push_back



using namespace std;
using ll = long long;
const ll INF = 1e18;
const double PI = acos(-1);

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



int main(void)
{
    std::cin.tie(nullptr);
    std::ios::sync_with_stdio(false);
    ll n,m;
    cin >> n >> m;
    vector<vector<ll>>tre(n);
    rep(i,m){
        ll a,b;
        cin >> a >> b;
        --a;--b;
        tre[a].pb(b);
        tre[b].pb(a);
        

    }
    vector<bool>done(n,false);
    ll ans = 0;
    rep(i,n){
        if(done[i])continue;
        done[i] = true;
        queue<ll>que;
        que.push(i);
        ll num = 1;
        while(!que.empty()){
            ll k = que.front();que.pop();
            for(ll t : tre[k]){
                if(done[t])continue;
                done[t] = true;
                que.push(t);
                ++num;
            }
        }
        ans = max(ans,num);
       
    }

    cout << ans << endl;




    return 0;
}


Measured memory_bytes: 16752
#include<stdio.h>
int main()
{
  int m,n,i,sum=0,r;
  scanf("%d %d",&m,&n);
  int s[n];
  for(i=0;i<n;i++)
  {
    scanf("%d ",&s[i]);
    
  }
  for(i=0;i<n;i++)
  {
    sum=sum+s[i];
  }
  if(m>=sum)
    r=m-sum;
  else
    r=(-1);
  printf("%d",r);
    
  return 0;
}


Measured memory_bytes: 1744
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using tlll=tuple<ll,ll,ll>;
using vs=vector<string>;
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(ll i=((ll)n)-1;i>=0;i--)
#define range(i,a,n) for(ll i=((ll)a);i<((ll)n);i++)
#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI (3.1415926535897932384)

int dx[]={1,0,-1,0,1,-1,-1,1},dy[]={0,1,0,-1,1,1,-1,-1};
template<class T>bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T>bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
template<class S>S sum(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}
int sgn(const double&r){return (r>EPS)-(r<-EPS);} // a>0  : sgn(a)>0
int sgn(const double&a,const double&b){return sgn(a-b);} // b<=c : sgn(b,c)<=0

template<class T>void puta(T&&t){cout<<t<<"\n";}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}
template<class S,class T>void tf(bool b,S t,T f){if(b)puta(t);else puta(f);}
void YN(bool b){tf(b,"YES","NO");}
void Yn(bool b){tf(b,"Yes","No");}
void yn(bool b){tf(b,"yes","no");}
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1;for(auto s:t){os<<(a?"":" ")<<s;a=0;}return os;}
template<class S>auto&operator>>(istream&is,vector<S>&t){for(S&a:t)cin>>a;return is;}

/*他のライブラリを入れる場所*/


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n,k;
    cin>>n>>k;
    set<ll> s;
    rep(i,k){
        ll d,t;
        cin>>d;
        rep(j,d){
            cin>>t;
            s.insert(t);
        }
    }
    puta(n-s.size());
    return 0;
}

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

int main() {

  string s, odds;

  cin >> s;

  for(int i=0; i<s.size(); i++) {
    if(i%2 == 0) {
      odds.insert(odds.end(), s[i]);
    }
  }
  cout << odds << endl;
  return 0;
}

Measured memory_bytes: 512
import java.util.ArrayList;
import java.util.List;
import java.util.PriorityQueue;
import java.util.Scanner;

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

    private static void solve(Scanner in) {
        int V = in.nextInt(), E = in.nextInt(), r = in.nextInt();
        EdgeWeightedDigraph G = new EdgeWeightedDigraph(V);
        for (int i = 0; i < E; i++) {
            DirectedEdge edge = new DirectedEdge(in.nextInt(), in.nextInt(), in.nextInt());
            G.addEdge(edge);
        }
        SP sp = new SP(G, r);
        for (int i = 0; i < V; i++) {
            System.out.println(sp.hasPathTo(i) ? sp.distTo(i) : "INF");
        }
    }
}

class SP {
    private static final int NA = Integer.MAX_VALUE;

    static class DistTo implements Comparable<DistTo> {
        final int node;
        final int dist;

        DistTo(int node, int dist) {
            this.node = node;
            this.dist = dist;
        }

        @Override
        public int compareTo(DistTo other) {
            return dist - other.dist;
        }
    }

    private final int[] distTo;

    SP(EdgeWeightedDigraph G, int s) {
        distTo = new int[G.V()];
        for (int i = 0; i < G.V(); i++) {
            distTo[i] = i == s ? 0 : NA;
        }
        PriorityQueue<DistTo> pq = new PriorityQueue<>();
        pq.add(new DistTo(s, 0));
        while (!pq.isEmpty()) {
            DistTo poll = pq.poll();// closest node
            if (distTo[poll.node] < poll.dist) {
                continue;
            }
            for (DirectedEdge edge : G.adj(poll.node)) {
                if (distTo[edge.to] > distTo[edge.from] + edge.weight) {
                    distTo[edge.to] = distTo[edge.from] + edge.weight;
                    pq.add(new DistTo(edge.to, distTo[edge.to]));
                }
            }
        }
    }

    int distTo(int t) {
        return distTo[t];
    }

    boolean hasPathTo(int t) {
        return distTo[t] != NA;
    }
}

class EdgeWeightedDigraph {
    private final List<DirectedEdge>[] adj;

    @SuppressWarnings("unchecked")
    EdgeWeightedDigraph(int V) {
        adj = new List[V];
        for (int i = 0; i < V; i++) {
            adj[i] = new ArrayList<DirectedEdge>();
        }
    }

    int V() {
        return adj.length;
    }

    void addEdge(DirectedEdge e) {
        adj[e.from].add(e);
    }

    Iterable<DirectedEdge> adj(int v) {
        return adj[v];
    }
}

class DirectedEdge {
    final int from;
    final int to;
    final int weight;

    DirectedEdge(int from, int to, int weigth) {
        this.from = from;
        this.to = to;
        this.weight = weigth;
    }

    public String toString() {
        return from + "->" + to + " " + String.format("%d", weight);
    }
}

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

using namespace std;

const int N = 1e5+7;
const int MOD = 1e9+7;

template <int _MOD> struct Mint
{
    int v = 0;
    Mint() {}
    Mint(int _v) : v((_v%_MOD+_MOD)%_MOD) {}
    Mint(long long _v) : v(static_cast<int>((_v%_MOD+_MOD)%_MOD)) {}
    Mint operator = (const int _v) { this->v = _v; return *this; }
    Mint operator = (const long long _v) { this->v = static_cast<int>(_v%_MOD); return *this; }
    bool operator < (const Mint &b) const { return v < b.v; }
    bool operator > (const Mint &b) const { return v > b.v; }
    bool operator == (const Mint &b) const { return v == b.v; }
    bool operator != (const Mint &b) const { return v != b.v; }
    bool operator <= (const Mint &b) const { return v < b.v || v == b.v; }
    bool operator >= (const Mint &b) const { return v > b.v || v == b.v; }
    Mint operator + (const Mint &b) { return Mint(v+b.v); }
    Mint operator - (const Mint &b) { return Mint(v-b.v); }
    Mint operator * (const Mint &b) { return Mint(1ll*v*b.v); }
    Mint operator / (const Mint &b) { return Mint(b.inv()*v); }
    Mint operator += (const Mint &b) { return *this = *this+b; }
    Mint operator -= (const Mint &b) { return *this = *this-b; }
    Mint operator *= (const Mint &b) { return *this = *this*b; }
    Mint operator /= (const Mint &b) { return *this = *this/b; }
    Mint pow(int p) const {
        Mint res(1), x(*this);
        while (p) {
            if (p&1) res = res*x;
            x *= x;
            p >>= 1;
        }
        return res;
    }
    Mint inv() const { return pow(_MOD-2); }
    friend istream& operator >> (istream &is, Mint &mt) { return is >> mt.v; }
    friend ostream& operator << (ostream &os, const Mint &mt) { return os << mt.v; }
};
using mint = Mint<MOD>;

string L;
mint dp[N][2];
// 0 ==, 1 <

int main()
{
    cin >> L;
    if (L.length() == 1) {
        cout << (L[0] == '1' ? 3 : 1) << endl;
        return 0;
    }
    dp[0][0] = 2; dp[0][1] = 1;
    for (int i = 1; i < (int)L.length(); ++i) {
        if (L[i] == '0') {
            dp[i][0] = dp[i-1][0];
            dp[i][1] = dp[i-1][1]*3;
        } else {
            dp[i][0] = dp[i-1][0]*2;
            dp[i][1] = dp[i-1][1]*3+dp[i-1][0];
        }
    }
    cout << dp[L.length()-1][0]+dp[L.length()-1][1] << endl;
    return 0;
}


Measured memory_bytes: 1280
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.HashMap;

public class Main {
	public static void main(String[] args) throws IOException {
		try (BufferedReader input = new BufferedReader(new InputStreamReader(System.in))) {
			while (input.ready()) {
				final String[] dataset = input.readLine().split(" ");
				System.out.println(getMostFrequentlyText(dataset) + " " + getMaximumLengthText(dataset));
			}
		}
	}

	private static String getMostFrequentlyText(final String[] stringArray) {
		HashMap<String, Integer> map = new HashMap<>();
		for (int i = 0; i < stringArray.length; i++) {
			if (map.containsKey(stringArray[i])) {
				map.put(stringArray[i], map.get(stringArray[i]) + 1);
			} else {
				map.put(stringArray[i], 1);
			}
		}
		int[] count = new int[stringArray.length];
		for (int i = 0; i < stringArray.length; i++) {
			count[i] = map.get(stringArray[i]);
		}
		return stringArray[getIndexOfMaxValue(count)];
	}

	private static String getMaximumLengthText(String[] stringArray) {
		int[] count = new int[stringArray.length];

		for (int i = 0; i < stringArray.length; i++) {
			count[i] = stringArray[i].length();
		}
		return stringArray[getIndexOfMaxValue(count)];
	}

	private static int getIndexOfMaxValue(final int[] array) {
		int num = 0;
		int index = 0;
		for (int i = 0; i < array.length; i++) {
			if (num < array[i]) {
				num = array[i];
				index = i;
			}
		}
		return index;
	}
}

Measured memory_bytes: 24232
#include <bits/stdc++.h>
#include <vector>
#include <numeric>
#define PI 3.14159265358979323846
#define MAXINF (1e18L)
#define INF (1e9L)
#define EPS (1e-9)
#define MOD ((ll)(1e9+7))
#define REP(i, n) for(int i=0;i<int(n);++i)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define ALL(v) v.begin(),v.end()
#define FIND(v,x) (binary_search(ALL(v),(x)))
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v));reverse(ALL(v))
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define YES(n) cout<<((n)?"YES":"NO")<<endl
#define pb push_back
#define fi first
#define se second
using namespace std;
template<class A>void pr(A a){cout << (a) << endl;}
template<class A,class B>void pr(A a,B b){cout << a << " "  ;pr(b);}
template<class A,class B,class C>void pr(A a,B b,C c){cout << a << " " ;pr(b,c);}
template<class A,class B,class C,class D>void pr(A a,B b,C c,D d){cout << a << " " ;pr(b,c,d);}
template<class T> inline bool chmin(T& a, T b){return a>b ? a=b, true : false;}
template<class T> inline bool chmax(T& a, T b){return a<b ? a=b, true : false;}
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll,ll> pll;

int main(void)
{
    int N;
    cin >> N;
    vector<int> p(N);
    for (int i = 0; i < N; i++) {
        cin >> p[i];
    }
    vector<int> a = p;
    SORT(a);
    int ans = 0;
    REP(i, N){
        if(a[i] != p[i]) ans++;
    }
    if(ans <= 2) pr("YES");
    else pr("NO");
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
//#include "lib/bigint2.h"

#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

using namespace std;
typedef long long ll; typedef vector<int> VI; typedef pair<int,int> pii;
const int MD = (int)1e9 + 7; typedef vector<ll> VL;
void dbg(){ cerr << "\n"; }  template <class T, class ...T2>
void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }
template <class T> void amax(T& a,T b){ if(a>b) a=b;}
ll INF = 99999; //1LL<<55;

int main(){
	//cin.tie(0); ios_base::sync_with_stdio(false);
	ll h;
	cin >>h;
	
	auto rec=[&](auto rec, ll c) ->ll{
		if(c==1) return 1;
		ll rt = 1;
		rt += rec(rec, c/2) * 2LL;
		return rt;
	};
	
	cout << rec(rec, h) <<"\n";
	return 0;
}


Measured memory_bytes: 256
S = input()
T = input()
len_s = len(S)
ok = True
s_dict = {}
t_dict = {}
for i in range(len_s):
  if S[i] in s_dict and s_dict[S[i]] != T[i]:
    ok = False
    break
  if T[i] in t_dict and t_dict[T[i]] != S[i]:
    ok = False
    break
  s_dict[S[i]] = T[i]
  t_dict[T[i]] = S[i]
if ok:
  print('Yes')
else:
  print('No')


Measured memory_bytes: 42060
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = Integer.parseInt(sc.nextLine());
		int a = Integer.parseInt(sc.nextLine());

		int i = n % 500;
		if (i <= a) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}

		sc.close();
	}
}

Measured memory_bytes: 23764
#include<stdio.h>

int main(void)
{
 int a,b,k,i,j;

 scanf("%d%d%d",&a,&b,&k);

 for(i=a;i<a+k;i++)
 {
  if(i<=b)
   printf("%d\n",i);
 }

 for(j=b-k+1;j<=b;j++)
 {
  if(j>=i)
   printf("%d\n",j);
 }

return 0;
}


Measured memory_bytes: 128
a, b, c ,k = map(int, input().split())
fromA = a if k > a else k
fromB = 0
fromC = 0
k = k - fromA
if k > 0:
    fromB = b if k > b else k
    k = k - fromB
if k > 0:
    fromC = c if k > c else k
    k = k - fromC
total = (fromA * 1) + (fromB * 0) + (fromC * -1)
print(total)

Measured memory_bytes: 9144
# -*- coding: utf-8 -*-

#############
# Libraries #
#############

import sys
input = sys.stdin.readline

import math
import bisect
from collections import deque
from fractions import gcd
from functools import lru_cache


#############
# Constants #
#############

MOD = 10**9+7
INF = float('inf')

#############
# Functions #
#############

######INPUT######
def inputI(): return int(input().strip())
def inputS(): return input().strip()
def inputIL(): return list(map(int,input().split()))
def inputSL(): return list(map(str,input().split()))
def inputILs(n): return list(int(input()) for _ in range(n))
def inputSLs(n): return list(input().strip() for _ in range(n))
def inputILL(n): return [list(map(int, input().split())) for _ in range(n)]
def inputSLL(n): return [list(map(str, input().split())) for _ in range(n)]

######OUTPUT######
def Yes(): print("Yes"); return
def No(): print("No"); return

#####Inverse#####
def inv(n): return pow(n, MOD-2, MOD)

######Combination######
kaijo_memo = []
def kaijo(n):
  if(len(kaijo_memo) > n):
    return kaijo_memo[n]
  if(len(kaijo_memo) == 0):
    kaijo_memo.append(1)
  while(len(kaijo_memo) <= n):
    kaijo_memo.append(kaijo_memo[-1] * len(kaijo_memo) % MOD)
  return kaijo_memo[n]

gyaku_kaijo_memo = []
def gyaku_kaijo(n):
  if(len(gyaku_kaijo_memo) > n):
    return gyaku_kaijo_memo[n]
  if(len(gyaku_kaijo_memo) == 0):
    gyaku_kaijo_memo.append(1)
  while(len(gyaku_kaijo_memo) <= n):
    gyaku_kaijo_memo.append(gyaku_kaijo_memo[-1] * pow(len(gyaku_kaijo_memo),MOD-2,MOD) % MOD)
  return gyaku_kaijo_memo[n]

def nCr(n,r):
  if(n == r):
    return 1
  if(n < r or r < 0):
    return 0
  ret = 1
  ret = ret * kaijo(n) % MOD
  ret = ret * gyaku_kaijo(r) % MOD
  ret = ret * gyaku_kaijo(n-r) % MOD
  return ret

######Factorization######
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])
    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])
    return arr

#####LCM#####
def lcm(a, b):
    return a * b // gcd (a, b)

#####BitCount#####
def count_bit(n):
  count = 0
  while n:
    n &= n -1
    count += 1
  return count

#############
# Main Code #
#############

N,M,X,Y = inputIL()
x = inputIL()+[X]
y = inputIL()+[Y]

if max(x)>=min(y):
  print("War")
else:
  print("No War")


Measured memory_bytes: 64492
import sys
read = sys.stdin.read
readlines = sys.stdin.readlines
from collections import deque
from copy import deepcopy
def main():
    n, m = map(int, input().split())
    edges = {e:[] for e in range(n + 1)}
    for _ in range(m):
        a, b = map(int, input().split())
        edges[a].append(b)
        edges[b].append(a)

    res = [0] * (n + 1)
    dist = 1
    distroom = [n + 1] * (n + 1)
    distroom[1] = 0
    q1 = deque()
    q2 = deque()
    q1.append(1)
    while q1:
        for q1e in q1:
            for adj in edges[q1e]:
                if distroom[adj] > dist:
                    res[adj] = q1e
                    distroom[adj] = dist
                    q2.append(adj)
        dist += 1
        q1 = deepcopy(q2)
        q2 = deque()
    print('Yes')
    print(*res[2:],sep='\n')

if __name__ == '__main__':
    main()

Measured memory_bytes: 44264
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<deque>
#include<queue>
#include<stack>
#include<utility>
#include<array>
#include<cassert>
#include<list>
#include<experimental/any>
#include<cstring>
#include<cctype>
#include<ctime>
#include<cstdbool>
#include<cstdint>
#include<cstddef>
#include<set>
#include<unordered_set>
#include<bitset>
 
using namespace std;
using experimental::any;
 
#define SPEEDY cin.tie(0);ios::sync_with_stdio(false);
 
#define REP(i,n) for(int i=0;i<(n);i++)
#define ARREP(i,n,X) for(int i=0;i<(n);i++)cin>>X[i]
#define FOR(i,X,n) for(int i=(X);i<(n);i++)
#define EREP(i,n) for(int i=1;i<=n;i++)
#define BitFOR(N) REP(Bit,1<<(N))
 
//#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define DEB2(X) cout<<X<<" ";
#define ARDEB(i,X) cout<< #X <<"["<<i<<"]: "<<X[i]<<" ";
#define TFDEB(f) (f)? cout<<"true ":cout<<"false ";
#define FORDEB(n,X) for(int i=0;i<(n);i++)ARDEB(i,X)
#define END cout<<endl;
#else
#define DEB(X) {}
#define DEB2(X) {}
#define ARDEB(i,X) {}
#define TFDEB(f) {}
#define FORDEB(n,X) {}
#define END {}
#endif
 
typedef long long int ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
#define ALL(X) X.begin(),X.end()
struct edge{int to,cost;};
//struct edge{int from,cost,to;};
struct P2{int x,y;};
#define BIT(Bit,n) bitset<n>(Bit)
#define Endl endl
 
const int MOD7=1000000007;
const int INF=100000000;
const int SET=1000;

ll dp[1000][1000];
ll DP(int x,int y){
	if(dp[x][y]!=-1)return dp[x][y];
	if(x<0||y<0)return 0;
	if(x==0&&y==0)return 1;
	else if(x==0||y==0){
		if(x==0) return dp[x][y]=DP(x,y-1);
		if(y==0) return dp[x][y]=DP(x-1,y);
	}
	dp[x][y]=DP(x-1,y)+DP(x,y-1);
	return dp[x][y];
}

int main(){
	int a,b;
	char c;
	cin>>a>>c>>b;
	if(c=='+')cout<<a+b<<endl;
	else cout<<a-b<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,n) for(int i=1;i<=n;i++)
const double PI = acos(-1);
const double EPS = 1e-15;
long long INF=(long long)1E17;
#define i_7 (long long)(1E9+7)
long mod(long a){
    long long c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
using namespace std;
bool prime_(int n){
  if(n==1){
    return false;
  }else if(n==2){
    return true;
  }else{
    for(int i=2;i<=sqrt(n);i++){
      if(n%i==0){
        return false;
      }
    }
    return true;
  }
}

long long gcd_(long long a, long long b){
  if(a<b){
    swap(a,b);
  }
  if(a%b==0){
    return b;
  }else{
    return gcd_(b,a%b);
  }
}
 
long long lcm_(long long x, long long y){
  return (x/gcd_(x,y))*y;
}
 
class UnionFind {
    public:
    //各頂点の親の番号を格納する。その頂点自身が親だった場合は-(その集合のサイズ)を入れる。
    vector<int> Parent;
    
    //クラスを作るときは、Parentの値を全て-1にする。
    //以下のようにすると全てバラバラの頂点として解釈できる。
    UnionFind(int N) {
        Parent = vector<int>(N, -1);
    }
    
    //Aがどのグループに属しているか調べる
    int root(int A) {
        if (Parent[A] < 0) return A;
        return Parent[A] = root(Parent[A]);
    }
    
    //自分のいるグループの頂点数を調べる
    int size(int A) {
        return -Parent[root(A)];//先祖をrootで取っておきたい。
    }
    
    //AとBをくっ付ける
    bool connect(int A, int B) {
        //AとBを直接つなぐのではなく、root(A)にroot(B)をくっつける
        A = root(A);
        B = root(B);
        if (A == B) {
            //すでにくっついてるからくっ付けない
            return false;
        }
        
        //大きい方(A)に小さいほう(B)をくっ付けたい
        //大小が逆だったらAとBをひっくり返す。
        if (size(A) < size(B)) swap(A, B);
        
        //Aのサイズを更新する
        Parent[A] += Parent[B];
        //Bの親をAに変更する
        Parent[B] = A;
        
        return true;
    }
};

vector<int> G[100'010];

long long ans;
void dfs(int prev, int now, long long k){
  long long cnt=0;
  for(int next_:G[now]){
    if(next_==prev)continue;
    if(prev==-1){
      ans *= k-1-cnt;
    }else{
      ans *= k-2-cnt;
    }
    cnt++;
    ans = mod(ans);
    dfs(now, next_, k);
  }
  return;
}
    
int main(){
  
  int n;
  long long k;
  cin>>n>>k;
  int a,b;
  REP(i,n-1){
    cin>>a>>b;
    a--;b--;
    G[a].push_back(b);
    G[b].push_back(a);
  }
  
  ans = k;
  dfs(-1,0,k);
  
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 12800
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>

using std::string;

char str[5050], tmp[7];

string arr[30000];
int top;

int main()
{
	int k, i, len, j;
	while(~scanf("%s", str)){
		scanf("%d", &k);
		len = strlen(str);
		top = 0;
		for(i = 0; i < len; i++){
			for(j = 0; j < k; j++){
				if(i + j >= len) break;
				tmp[j] = str[i + j];
				tmp[j + 1] = 0;
				arr[top++] = tmp;
			}
		}
		std::sort(arr, arr + top);
		std::unique(arr, arr + top);
		printf("%s\n", arr[k - 1].c_str());
	}

	return 0;
}


Measured memory_bytes: 1664
#include <iostream>
#include <string>
#include<vector>
#include<algorithm>
#include<cmath>
using namespace std;

int main(int argc, char *argv[]) {
  

  int n;
  cin >> n;
  
  int mod = n%10;
  if(mod==2||mod==4||mod==5||mod==7||mod==9){
    cout << "hon" << endl;
  }else if(mod==0||mod==1||mod==6||mod==8){
    cout << "pon" << endl;
  }else{
    cout << "bon" << endl;
  }

  return 0;
}


Measured memory_bytes: 3572
import java.util.Scanner;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int A = sc.nextInt();
        if(N%500<=A) {
            System.out.println("Yes");
        }
        else
            System.out.println("No");
        sc.close();
    }
}

Measured memory_bytes: 22612
def main():
    array = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
    K = int(input())
    print(array[K - 1])


if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
import collections
n=int(input())
c=[0]*n
alphabet=set()
for i in range(n):
    s=input()
    counter=collections.Counter(s)
    c[i]=counter
    for moji in s:
        if(moji not in alphabet):
            alphabet.add(moji)
alphabet=sorted(alphabet)
text=''
for moji in alphabet:
    count=10000
    for i in range(n):
        if(count>c[i][moji]):
            count=c[i][moji]
    text+=moji*count
print(text)



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

int main()
{
	ios::sync_with_stdio(false);
    cin.tie(NULL);
    int n,x,y;
    cin>>n>>x>>y;
    vector<int>edges[n+1];
    for(int i=1;i<n;i++)
    {
        edges[i].push_back(i+1);
        edges[i+1].push_back(i);
    }
    edges[x].push_back(y);
    edges[y].push_back(x);
    set<pair<int,int>>s;
    int dist[n+1];
    bool vis[n+1]={false};
    int ans[n+1]={0};
    for(int ind=1;ind<n;ind++){
        for(int i=0;i<=n;i++){
            dist[i]=INT_MAX;
        }
        s.insert({0,ind});
        dist[ind]=0;
        memset(vis,false,sizeof vis);
        while(!s.empty())
        {
            auto p=*s.begin();
            s.erase(s.begin());
            int w=p.first,x=p.second;
            if(vis[x]==true){
                continue;
            }
            vis[x]=true;
            for(int i:edges[x])
            {
                if(dist[i]>dist[x]+1)
                {
                    dist[i]=dist[x]+1;
                    s.insert({dist[i],i});
                }
            }
        }
         for(int i=ind+1;i<=n;i++)
        {
        ans[dist[i]]++;
        }
    }
    for(int i=1;i<n;i++)
    {
        cout<<ans[i]<<'\n';
    }
    return 0;
}

Measured memory_bytes: 384
/*
 * http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0007
 */
#include <iostream>
#include <cmath>

using namespace	std;

#define INITIAL 100000
#define INTEREST 1.05
#define CEILING 1000

int
dow(int a, float r, int w)
{
	if (w == 0)
		return a;
	float c = a / CEILING;
	return dow(ceil(c * r) * CEILING, r, --w);
}

int
main()
{
	int w;
	cin >> w;
	cout << dow(INITIAL, INTEREST, w) << endl;
	return 0;
}

Measured memory_bytes: 3008
#include<iostream>
#include<sstream>
#include<ios>
#include<iomanip>
#include<algorithm>
#include<vector>
#include<list>
#include<queue>
#include<cstdlib>
#include<cmath>
#include<queue>
#include<deque>
#include<map>
#include<string>
#include<numeric>
#include<set>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep2(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep_inv(i, n, m) for(int i = (int)(n); i > (int)(m); i--)
using namespace std;
using vi = vector<int>;
using vl = vector<long>;
using vc = vector<char>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<long>>;
using vvc = vector<vector<char>>;
using pii = pair<int, int>;
using pll = pair<long, long>;
using vpii = vector<pii>;
using vpll = vector<pll>;

bool pattern(long P, vl ps){
  bool ret = false;
  
  if(ps.size() == 1){
    return (P % ps[0] == 0);
  } else{
    long ph = ps[0];

    if(P % ph == 0) return true;

    long max_cnt = P / ph;
    vl pss(ps.size() - 1);
    rep2(i, 1, ps.size()) pss[i - 1] = ps[i];

    rep(i, max_cnt + 1){
      ret = pattern(P - ph*i, pss);
      if(ret) break;
    }
  }

  return ret;
}

int main(){
  long X;
  cin >> X;

  vl prices(6);
  rep(i, 6) prices[i] = 105 - i;

  if(pattern(X, prices)) cout << 1 << endl;
  else cout << 0 << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

const int VMAX = 100;
const long long int INF = 100000000000;

long long int dist[VMAX][VMAX];


void init(int V) {
    for (int i = 0; i < V; ++i) {
        for (int j = 0; j < V; ++j) {
            dist[i][j] = (i == j ? 0 : INF);
        }
    }
}

void wf_run(int V) {
    for (int k = 0; k < V; ++k) {
        for (int i = 0; i < V; ++i) {
            if (dist[i][k] == INF) {
                continue;
            }
            for (int j = 0; j < V; ++j) {
                if (dist[k][j] == INF) {
                    continue;
                }
                dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
            }
        }
    }
}

bool has_negcycle(int V) {
    for (int i = 0; i < V; ++i) {
        if (dist[i][i] < 0) return true;
    }
    return false;
}

int main() {
    int V, E;
    cin >> V >> E;

    init(V);

    for (int i = 0; i < E; ++i) {
        int s, t, d;
        cin >> s >> t >> d;
        dist[s][t] = d;
        // ????????°??????
        // dist[t][s] = d;
    }
    wf_run(V);

    if (has_negcycle(V)) {
        cout << "NEGATIVE CYCLE" << endl;
        return 0;
    }
    for (int i = 0; i < V; ++i) {
        for (int j = 0; j < V; ++j) {
            if (dist[i][j] >= INF / 2) {
                cout << "INF";
                // } else if (dist[i][j] == 0) {
                //     cout << 0;
            } else {
                cout << dist[i][j];
            }
            if (j < V - 1) {
                cout << " ";
            }

        }
        cout << endl;
    }
}

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

string X(int x,int y){
    if(x>0 && x<13 && y>0 && y<13)
    return "AMBIGUOUS";
    else if (x==0 && y>12 || y==0 && x>12 || x>12 && y>12 || x==0 && y==0)
    return "NA";
    else if (x>12 || x==0)
    return "YYMM";
    else
    return "MMYY";
}

int main(){
    int N;
    cin >> N;
    int A,B;
    A=N/100;
    B=N%100;
    cout << X(A,B) << endl;
}



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

int main()
{
	string s;
	cin >> s;
	string hi = "hi";
	int i = 0;
	for (i = 0; i < 5; i++){
		if (s != hi) hi += "hi";
		else break;
	}

	if (i == 5) cout << "No" << endl;
	else cout << "Yes" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
  ll n, m;
  cin >> n >> m;
  int maxx = 0;
  if(m<2*n){
    if(m%2==0) cout << m/2 << endl;
    else cout << (m-1)/2 << endl;
  }
  else{
    ll x = (m-2*n)/4;
    cout << n+x << endl;
  }
}

Measured memory_bytes: 384
N = int(input())
ab = [[int(i) for i in input().split(" ")] for _ in range(N)]
cd = [[int(i) for i in input().split(" ")] for _ in range(N)]
ab_sort = sorted(ab, key=lambda x:-x[1])
cd_sort = sorted(cd, key=lambda x:x[0])

cnt = 0
for c, d in cd_sort:
    for a, b in ab_sort:
        if a < c and b < d:
            ab_sort.remove([a, b])
            cnt += 1
            break

print(cnt)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define sz(x) x.size()
#define all(x) x.begin(),x.end()
#define f(i,a,b) for(int i=a;i<=b;i++)

using namespace std;
typedef unsigned long long ull;
typedef vector<int>vi;
typedef pair<int,int> pii;
typedef map<int,int> mii;
typedef set<int> si;


int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
	int n;
	cin >> n;
	if(n % 111 == 0){
		cout << n << endl;
	}else{
		n/=111;
		n++;
		n*=111;
		cout  << n << endl;
	}
	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
import java.util.ArrayList;
import java.util.List;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        long d = sc.nextInt();
        long[] x = new long[n];
        long[] y = new long[n];
        for(int i = 0; i < n; i++){
           x[i] = sc.nextInt();
           y[i] = sc.nextInt();
        }
        sc.close();
        int count = 0;
        for(int i = 0; i < n; i++){
            if(x[i] * x[i] + y[i] * y[i] <= d * d){
                count++;
            }
        }
        System.out.println(count);
    }

} 


Measured memory_bytes: 62060