akhauriyash/Code-Regression huggingface dataset:
#[allow(unused_macros)]
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)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

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

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

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

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

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

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

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

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

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

fn main() {
    input! {
        s: String,
    }
    let s = s.chars().collect::<Vec<_>>();
    let mut count1 = 0;
    for (i, &c1) in s.iter().enumerate() {
        let c2 = if i % 2 == 0 { '0' } else { '1' };
        if c1 != c2 {
            count1 += 1;
        }
    }
    let mut count2 = 0;
    for (i, &c1) in s.iter().enumerate() {
        let c2 = if i % 2 == 1 { '0' } else { '1' };
        if c1 != c2 {
            count2 += 1;
        }
    }
    println!("{}", std::cmp::min(count1, count2));
}


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

namespace ProblemD
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = long.Parse(Console.ReadLine());
            if (N == 1) Console.WriteLine(0);
            else
            {
                var minBeforeRount = (Math.Sqrt(4 * N + 1) - 1) / 2.0;
                var min = Math.Ceiling(minBeforeRount);
                var divisors = new List<long>();
                long ret = 0;
                var temp = N;
                for (long i = 2; i * i <= N; i++)
                {
                    if (N % i == 0)
                    {
                        divisors.Add(i);
                        divisors.Add(N / i);
                    }
                }
                divisors.Add(N);
                divisors = divisors.Distinct().ToList();
                divisors.Sort();
                temp = 1;
                foreach (var div in divisors)
                {
                    if (N / (div - 1) == N % (div - 1))
                        ret += div - 1;
                }
                Console.WriteLine(ret);
            }
        }
    }
}


Measured memory_bytes: 13524
#include<iostream>
using namespace std;
int main(){

	int S,h,m,s;
	cin>>S;
	h=S/3600;
	m=(S%3600)/60;
	s=(S%3600)%60;
	cout<<h;
	cout<<":";
	cout<<m;
	cout<<":";
	cout<<s<<endl;
	return 0;
}

Measured memory_bytes: 1164
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;

enum P = 10^^9L+7;

long[10^^5*2+1] SS;
bool[10^^5*2+1] BS;

void main()
{
    auto nm = readln.split.to!(int[]);
    auto N = nm[0];
    auto M = nm[1];
    foreach (_; 0..M) {
        auto a = readln.chomp.to!int;
        BS[a] = true;
    }
    SS[0] = 1;
    foreach (i; 0..N) {
        if (BS[i]) continue;
        SS[i+1] = (SS[i+1] + SS[i]) % P;
        SS[i+2] = (SS[i+2] + SS[i]) % P;
    }
    writeln(SS[N]);
}

Measured memory_bytes: 3068
#include <stdio.h>

int main()
{
  int i,j,key,n,m;
  int l[100];

  scanf("%d",&n);

  for(i=0;i<n;i++){
    scanf("%d",&l[i]);
  }
  for(i=0;i<n;i++){
    printf("%d",l[i]);
    if(i<n-1)printf(" ");
  }
  printf("\n");

  for(i=1;i<n;i++){
    key = l[i];
    j = i - 1;
    while(l[j]>key && j>=0){
      l[j+1] = l[j];
      j--;
    }
    l[j+1] = key;
    for(m=0;m<n;m++){
      printf("%d",l[m]);
      if(m<n-1)printf(" ");
    }
  printf("\n");
  } 
   return 0;
}

Measured memory_bytes: 604
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
using namespace std;
using ll=long long;
constexpr ll mod=1000000007;
constexpr int inf=1000000000;
constexpr ll linf=1000000000000000000;

int main(){
    int n,k;
    cin>>n>>k;
    int p[n];
    rep(i,n){
        cin>>p[i];
        --p[i];
    }
    ll c[n];
    rep(i,n)cin>>c[i];
    ll ans=-linf;
    rep(start,n){
        int visit[n];
        fill(visit,visit+n,-1);
        visit[start]=0;
        int now=start;
        ll score[n]={};
        ll loopscore;
        int point;
        int len;
        while(true){
            int to=p[now];
            if(visit[to]!=-1){
                loopscore=score[now]+c[to]-score[to];
                point=to;
                len=visit[now]+1-visit[to];
                ans=max(ans,score[now]+c[to]);
                break;
            }
            score[to]=score[now]+c[to];
            visit[to]=visit[now]+1;
            now=to;
            ans=max(ans,score[now]);
            if(visit[now]==k){
                loopscore=-1;
                break;
            }
        }
        if(loopscore<=0)continue;
        int rest=k-visit[point];
        int rest1=rest-rest/len*len;
        int rest2=rest-(rest/len-1)*len;
        int cnt=rest/len;
        if(rest2>rest)rest2=-1;
        ll tmp=score[point]+loopscore*(rest/len);
        ll tmp2=score[point]+loopscore*(rest/len-1);
        if(rest2==-1)tmp2=-linf;
        ll mx=-linf,mx2=-linf;
        rep(i,n){
            if(visit[i]>=visit[point]&&visit[point]+rest1>=visit[i]){
                if(point==start&&i==start&&cnt==0)continue;
                mx=max(mx,score[i]-score[point]);
            }
            if(rest2!=-1&&visit[i]>=visit[point]&&visit[point]+len>visit[i]){
                if(point==start&&i==start&&cnt==1)continue;
                mx2=max(mx2,score[i]-score[point]);
            }
        }
        tmp+=mx;
        tmp2+=mx2;
        ans=max(ans,max(tmp,tmp2));
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 3748
#include<iostream>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
#include<limits>
#include<sstream> 
#include<unordered_map>      

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;
typedef vector<int> vi;
typedef vector<ll> vl;

const int inf = numeric_limits<int>::max() >> 2;
const ll linf = numeric_limits<ll>::max() >> 2;
const ull ulinf = numeric_limits<ull>::max() >> 2;
const double pi = acos(-1);
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const int dx8[8]={-1,0,1,-1,1,-1,0,1};
const int dy8[8]={-1,-1,-1,0,0,1,1,1};

#define p_queue(i) priority_queue<i> 
#define rp_queue(i) priority_queue<i, vector<i>, greater<i>> 
#define umap(i,j) unordered_map<i,j>
#define P(p) cout<<(p)<<endl
#define PS(p) cout<<(p)<< " "
#define IN cin >> 
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define rrep(i,m,n) for(int i = (m-1); i >= (int)(n); i--)
#define inrep(n,a) for(int i = 0; i < (int)(n); i++)cin >> a[i];
#define mod(i) ((i)%(ll)(1e9 + 7))
#define divm(a,b) (mod(a * modpow((ll)b,(ll)(1e9+5))))
#define rsort(a,b,c) sort(a, b, greater<c>())
#define vsort(v) sort(v.begin(), v.end())
#define rvsort(v,c) sort(v.begin(), v.end(), greater<c>()) 
#define ft first
#define sd second
#define pb push_back
#define it insert
#define sz(x) ((int)(x).size())
#define lb(a,n,k) (lower_bound(a,a+n,k) - a) 
#define vlb(a,k)  (lower_bound(a.begin(),a.end(),k) - a.begin())
#define ub(a,n,k) (upper_bound(a,a+n,k) - a) 
#define vub(a,k)  (upper_bound(a.begin(),a.end(),k) - a.begin())
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return

ll modpow(ll i,ll j){ ll tmp=1; while(j){ if(j%2)tmp=mod(tmp*i);i=mod(i*i);j/=2;}return tmp;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

vector<string> split(const string &str, char sep){
    vector<string> v;
    stringstream ss(str);
    string buffer;
    while( getline(ss, buffer, sep) ) {
        v.push_back(buffer);
    }
    return v;
}

//ll ncr[100][100];
//ll nCr(int n, int r){if(n==r) ret ncr[n][r] = 1; if(r==0) ret ncr[n][r] = 1; if(r==1) ret ncr[n][r] = n;if(ncr[n][r]) ret ncr[n][r]; ret ncr[n][r] = nCr(n-1,r) + nCr(n-1,r-1);}

//ll npr[100][100]={};
//ll nPr(int n,int r){if(npr[n][r])ret npr[n][r];if(r==0)ret npr[n][r] = 1;if(r==1)ret npr[n][r] = n;ret npr[n][r] = n * nPr(n-1,r-1);}

//ll nHr(int n,int r){ret nCr(n+r-1,r);}

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

int a,b,c,d[100005] = {},n,m;
string s,t;

int main(){
    

    int f[3] = {};
    inrep(3,f);

    int ans = 0;
    rep(i,0,3)ans += f[i];
    sort(f,f+3);
    P(ans - f[2]);
    
    return  0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<stdio.h>
#include<cctype>
#include<algorithm>
#include<climits>
#include<cmath>
#include<map>
#include<vector>
#define INF INT_MAX
using namespace std;

int N,M,K;
int d;
int A;
int sum, ans;
string S;

int list[110];

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

	for (int i = 1; i <= N; i++) {
		list[i] = -1;
	}

	for (int i = 0; i < K; i++) {
		cin >> d;
		for (int i = 0; i < d; i++) {
			cin >> A;
			list[A] = 1;
		}
	}

	for (int i = 1; i <= N; i++) {
		if (list[i] == -1) {
			ans++;
		}
	}

	cout << ans << endl;

	return 0;
}

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

int main() {
	int h, w, K;
	cin >> h >> w >> K;
	vector<string> corg(h);
	rep(i,h) cin >> corg[i];

	ll ans = 0;
	vector<string> c(h);
	int nh = 1;
	rep(i,h) nh *=2;
	int nw = 1;
	rep(i,w) nw *=2;
	
	for (int ih = 0; ih < nh; ih++) {
		for (int iw = 0; iw < nw; iw++) {
			rep(i,h) c[i]= corg[i];
			int th = 1;
			rep(j,h) {
				if (ih & th) {
					rep(k,w) c[j][k] = '@';
				}
				th <<= 1;
			}
			int tw = 1;
			rep(j,w) {
				if (iw & tw) {
					rep(k,h) c[k][j] = '@';
				}
				tw <<= 1;
			}
			int blcount = 0;
			rep(i,h) rep(j,w) {
				if (c[i][j] == '#') blcount++;
			}
			if (blcount == K)
				ans++;
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3628
import java.util.Scanner;

public class Main
{
    int dx[] = {0, 0, 1, 1, 1, -1, -1, -1};
    int dy[] = {1, -1, 1, 0, -1, 1, 0, -1};
    int h, w;
    int mp[][];
    String s[][];
    
    public static void main(String args[])
    {
		new Main().run();
    }

    void run()
    {
		in();
	
		for(int i = 0; i < h; i++) {
	    	for(int j = 0; j < w; j++) {
		
			if(s[i][j].equals(".")) continue;
			for(int k = 0; k < 8; k++) {
		    	int mx = j + dx[k];
		    	int my = i + dy[k];
		    	if(mx < 0 || w <= mx || my < 0 || h <= my) continue;
		    	mp[my][mx]++;
			}
		
	    	}
		}
	
		out();
    }

    void in()
    {
		Scanner sc = new Scanner(System.in);

		h = sc.nextInt();
		w = sc.nextInt();
		mp = new int[51][51];
		s  = new String[51][51];

		for(int i = 0; i < h; i++) {
		    String line = sc.next();
		    for (int j = 0; j < w; j++)
				s[i][j] = String.valueOf(line.charAt(j));
		}
    }

    void out()
    {
		for(int i = 0; i < h; i++) {
		    for(int j = 0; j < w; j++) {
			if(s[i][j].equals("."))
			    System.out.print(mp[i][j]);
			else
			    System.out.print('#');
		    }
	    
		    System.out.println();
		}
    }
}


Measured memory_bytes: 24148
#include<iostream>
#include<string>
#include<vector>
#include<math.h>
#include<algorithm>
#include<cstdio>
#include<stdio.h>
#include<stack>
#include<sstream>
typedef long long ll;

#define pi 3.14159265358979323846
#define VI vector<int>
#define VLL vector<long long>
#define MAX max_element
#define MIN min_element
#define all(v) v.begin(), v.end()

using namespace std;

template<typename T>
T gcd(T a, T b) {
	return b ? gcd(b, a % b) : a;
}
template<typename T>
T lcm(T a, T b) {
	return a * b / gcd(a, b);
}

template<typename T>
T finder(vector<T> vec, T number) {
	auto itr = find(vec.begin(), vec.end(), number);
	size_t index = distance(vec.begin(), itr);
	if (index != vec.size()) { // 発見できたとき
		return 1;
	}
	else { // 発見できなかったとき
		return 0;
	}
}

/*char r[4];
int yaju[4];
char op[3];
int sum = 0;
scanf("%s", r);
for (int i = 0;i < 4;i++) {
	yaju[i] = r[i] - '0';
}
*/
int main() {
	VI  A(5);
	VI a(5);
	int ans = 9999;
	int max = 0;
	cin >> A[0] >> A[1] >> A[2] >> A[3] >> A[4];
	a[0] = A[0]%10; a[1] = A[1]%10;a[2] = A[2]%10;a[3] = A[3]%10;a[4] = A[4]%10;
	for (int i = 0;i < 5;i++) {
		if (a[i] != 0) max += (A[i] / 10 + 1) * 10;
		else max += A[i];
	}
	int maxa = max;
	sort(all(a));
	for (int i = 0;i < 5;i++) {
		if (a[i] != 0) {
			max -= (10 - a[i]);
			break;
		}
	}
	cout << max << endl;
}


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

int main() {
  int A, B, sum=0;
  int d1, d2, d4, d5;
  
  cin >> A >> B;
  
  while ( A <= B ) {
    d1 = A / 10000;
    d2 = (A / 1000) % 10;
    d4 = (A / 10 ) % 10;
    d5 = A % 10;
    if ((d1 == d5) && (d2 == d4)) {
      sum++;
    }
    A++;
  }
  cout << sum << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cmath>
#include<queue>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<functional>
#include<algorithm>
#include<cstdio>
using namespace std;
int main() {
	int n;
	while (cin >> n&&n != 0) {
		string a[100];
		int b[100];
		bool c[100];
		vector<int>d[100];
		list<int>m2;
		for (int i = 0; i<n; i++) {
			cin >> a[i] >> b[i];
			c[i] = false;
		}
		int m;
		cin >> m;
		for (int i = 0; i<m; i++) {
			string o, q;
			int k;
			cin >> o >> k;
			int e;
			for (e = 0; e<n; e++) {
				if (a[e] == o)
					break;
			}
			c[e] = true;
			m2.push_back(e);
			for (int j = 0; j<k; j++) {
				cin >> q;
				for (int z = 0; z<n; z++) {
					if (a[z] == q) {
						d[e].push_back(z);
						break;
					}
				}
			}
		}
		while (m2.size()>0) {
			list<int>::iterator it = m2.begin(), it2;
			for (int i = 0; i<(int)m2.size();) {
				int e = (*it), sum = 0;
				bool l = true;
				for (int j = 0; j<(int)d[e].size(); j++) {
					if (c[d[e][j]]) {
						l = false;
						goto stop;
					}
					sum += b[d[e][j]];
				}
				b[e] = min(b[e], sum);
				it2 = it;
				it++;
				m2.erase(it2);
				c[e] = false;
			stop:;
				if (!l) {
					it++;
					i++;
				}
			}
		}
		string t;
		cin >> t;
		for (int i = 0; i<n; i++) {
			if (a[i] == t) {
				cout << b[i] << endl;
				break;
			}
		}
	}
}

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

public class hello
{
    public static void Main()
    {
        while (true)
        {
            string[] line = Console.ReadLine().Trim().Split(' ');
            var n = int.Parse(line[0]);
            var p = int.Parse(line[1]);
            if (n == 0 && p == 0) break;
            Console.WriteLine(PlayGame(n, p));
        }
    }
    public static int PlayGame(int n , int p)
    {
        var kouho = new int[n];
        var np = 0;
        while (true)
        {
            if (p == 0) { p += kouho[np]; kouho[np] = 0; }
            else if (p == 1 && kouho.Sum() == kouho[np]) { return np; }
            else { kouho[np]++; p--; }
            np++;  if (np == n) np = 0;
        }
    }
}

Measured memory_bytes: 9544
#include<iostream>

using namespace std;
 
int main()
{
	long long n,m;
	cin >> n >> m;
	int count=1;
	long long bef=n;
	while(true)
	{
		bef=bef*2;
		if(bef<=m)count++;
		else break;
	}
	cout << count << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h> 
#include <string.h>
using namespace std;  
int main()
{
	string s,s1,x;
	cin>>s;
	cin>>s1;
	x=s1.erase(s1.length()-1);
	if(x==s){
		cout<<"Yes";
	}
	else
	cout<<"No";
    return 0;  
}  

Measured memory_bytes: 3624
#include <iostream>
#include <algorithm>

using namespace std;

const int N = 100;

int w, h;
bool input[N][N];
bool soto[N][N];
bool visited[N][N];
int dy[2][6] = {{-1, 0, 1, 1, 0, -1}, {-1, 0, 1, 1, 0, -1}};
int dx[2][6] = {{1, 1, 1, 0, -1, 0}, {0, 1, 0, -1, -1, -1}};


bool check(int y, int x){
  if(y<0 || y>=h) return false;
  if(x<0 || x>=w) return false;
  return true;
}

bool dfs(int y, int x){
  visited[y][x] = true;
  for(int i=0;i<6;i++){
    int ny = y + dy[y%2][i];
    int nx = x + dx[y%2][i];
    if(!check(ny, nx)) return true;
    if(input[ny][nx]) continue;
    if(visited[ny][nx]) continue;
    if(dfs(ny, nx)) return true;
  }
  return false;
}

void dfs2(int y, int x){
  soto[y][x] = true;
  for(int i=0;i<6;i++){
    int ny = y + dy[y%2][i];
    int nx = x + dx[y%2][i];
    if(!check(ny, nx)) continue;
    if(input[ny][nx]) continue;
    if(soto[ny][nx]) continue;
    dfs(ny, nx);
  }
}

main(){
  cin >> w >> h;
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      cin >> input[i][j];
    }
  }
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      if(!input[i][j]){
        fill(visited[0], visited[N], false);
        if(dfs(i, j)){
          dfs2(i, j);
        }
      }
    }
  }
  int ans = 0;
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      if(input[i][j]){
        for(int k=0;k<6;k++){
          int ny = i + dy[i%2][k];
          int nx = j + dx[i%2][k];
          if(!check(ny, nx)){
            ans++;
            continue;
          }
          if(soto[ny][nx]) ans++;
        }
      }
    }
  }
  cout << ans << endl;
  return 0;
}

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

int main(){
	#ifndef ONLINE_JUDGE 

	// For getting input from input.txt file 
	freopen("/home/devanshi/AtCoderDPproblems/Frog1input.txt", "r", stdin); 

	// Printing the Output to output.txt file 
	freopen("/home/devanshi/AtCoderDPproblems/Frog1output.txt", "w", stdout); 

	#endif 

	int n;
	cin>>n;
	int*h=new int[n];

	for(int i=0;i<n;i++){
		cin>>h[i];
	}
	
	int*dp=new int[n];
	dp[0]=0;
	dp[1]=abs(h[0]-h[1]);

	for(int i=2;i<n;i++){
		dp[i]=min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[i-2]));
	}

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

Measured memory_bytes: 4368
#include <iostream>
#include <cmath>
using namespace std;
int main(void){
    int N;
    long power = 1;
    cin >> N;
    for(int i = 1; i <= N; i++){
        power = i * power % (1000000000 + 7);
    }
    
    cout << power <<endl;
    
}


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

int main() {
  ll a, b, c, k;
  cin >> a >> b >> c >> k;

  if (a + b >= k)
    cout << min(a, k) << endl;
  else
    cout << a - (k - a - b) << endl;
}

Measured memory_bytes: 3616
// I SELL YOU...! 
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<chrono>
#include<iomanip>
#include<map>
#include<set>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
void init_io(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << setprecision(10);
}
signed main(){
  init_io();
  ll n,a,b,sum,ans=0;
  cin >> n >> a >> b;
  sum = a+b;
  ans += (n/sum)*a;
  n %= sum;
  ans += min(a,n);
  cout << ans << endl;
}


Measured memory_bytes: 256
n_1=input()
n_1_List=map(int,raw_input().split())
n_2=input()
n_2_List=map(int,raw_input().split())
n_1_List=set(n_1_List)
n_2_List=set(n_2_List)
print(len(n_1_List.intersection(n_2_List)))

Measured memory_bytes: 14864
#include<iostream>
#include<vector>
#include<stack>
#include<algorithm>
#include<string>
#include<set>
#include<numeric>
#include<functional>
#include<unordered_map>
using namespace std;

int main()
{
    int N;
    cin >> N;
    string s;
    cin >> s;
    int counter = 0;
    int start = 0;
    for (int i = 0; i < s.size(); i++) {
        if (s[i] == '(') {
            if (counter == 0) start = i;
            counter++;
        } else {
            counter--;
            if (counter < 0) {
                s.insert(0, "(");
                i++;
                counter = 0;
            }
        }
    }
    for (int i = 0; i < counter; i++) {
        s.insert(s.size(), ")");
    }

    cout << s << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cassert>
#include <string>
#include <algorithm>
#include <vector>
#include <valarray>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <iomanip>
#include <map>
#include <set>
#include <list>
#include <limits>
#include <numeric>
#include <utility>
#include <deque>
#include <unordered_set>
#include <unordered_map>
#include <regex>
#include <array>
#include <bitset>
#include <complex>
#include <tuple>
#include <random>

using namespace std;
using ll = long long;
const int INF = 1e9;
const ll MOD = 1e9 + 7;

int main()
{
  int n;
  while (cin >> n, n)
  {
    vector<int> a(n);
    int sum = 0;
    for (auto &e : a)
      cin >> e, sum += e;
    sort(a.begin(), a.end());
    int ans = 0;
    for (int i = 0; i < n; ++i)
      if (a[i] <= sum / n)
        ans++;
    cout << ans << endl;
  }

  return 0;
}



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

int main(){
  int N;
  vector<long> L(87);
  L.at(0)=0; L.at(1)=1;
  for (int i = 2; i < 87; i++) {
    L.at(i)=L.at(i-2)+L.at(i-1);
  }
  cin >> N;
  cout << 2*L.at(N-1)+L.at(N) << endl;
}


Measured memory_bytes: 256
#ifdef LOCAL111
	#define _GLIBCXX_DEBUG
#else
	#define NDEBUG
#endif
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
const int INF = 1e9;
using namespace std;
template<typename T, typename U> ostream& operator<< (ostream& os, const pair<T,U>& p) { os << '(' << p.first << ' ' << p.second << ')'; return os; }

#define endl '\n'
#define ALL(a)  (a).begin(),(a).end()
#define SZ(a) int((a).size())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#ifdef LOCAL111
	#define DEBUG(x) cout<<#x<<": "<<(x)<<endl
	template<typename T> void dpite(T a, T b){ for(T ite = a; ite != b; ite++) cout << (ite == a ? "" : " ") << *ite; cout << endl;}
#else
	#define DEBUG(x) true
	template<typename T> void dpite(T a, T b){ return; }
#endif
#define F first
#define S second
#define SNP string::npos
#define WRC(hoge) cout << "Case #" << (hoge)+1 << ": "
template<typename T> void pite(T a, T b){ for(T ite = a; ite != b; ite++) cout << (ite == a ? "" : " ") << *ite; cout << endl;}
template<typename T> bool chmax(T& a, T b){if(a < b){a = b; return true;} return false;}
template<typename T> bool chmin(T& a, T b){if(a > b){a = b; return true;} return false;}

typedef long long int LL;
typedef unsigned long long ULL;
typedef pair<int,int> P;

void ios_init(){
	//cout.setf(ios::fixed);
	//cout.precision(12);
#ifdef LOCAL111
	return;
#endif
	ios::sync_with_stdio(false); cin.tie(0);
}

int main()
{
	ios_init();
	int a, p;
	while(cin >> a >> p) {
		cout << (a * 3 + p) / 2 << endl;
	}
	return 0;
}


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


void init(){
    cin.tie(0);
    cin.sync_with_stdio(0);
}

#define ll long long
#define ld long double
#define ull unsigned long long
#define ull unsigned long long
#define mod 1000000007
#define pi (3.1415926)

#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))

#define scd(a)  scanf("%lld",&a)
#define scdd(a,b)	scanf("%lld%lld",&a,&b)
#define scddd(a,b,c)	scanf("%lld%lld%lld",&a,&b,&c)
#define ptab(a)	printf("%lld ",a)
#define pdn(a)	printf("%lld\n",a)
#define pddn(a,b)	printf("%lld %lld\n",a,b)
#define pdddn(a,b,c)	printf("%lld %lld %lld\n",a,b,c)

#define forr(n) for(ll i=0;i<n;i++)
#define rev(n) for(ll i=n-1;i>=0;i--)
#define forp(x, y) for(ll i=x;i<y;i++)
#define loop( j, k, in) for (ll i=j ; i<k ; i+=in)

#define in  cin>>
#define out cout<<
#define en "\n"
#define sp " "
#define eps 1.0E-14

ll sum (int n ){return ((n*(n+1)) / 2) ;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
int main()
{
    init();
    ll H,W;
 cin >> H >> W;

 if(H == 1 || W == 1){
 cout << 1 << endl;
 } else {
 cout << (H * W + 1) / 2 << endl;
 }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
//#pragma GCC optimize(2)
#define pb push_back
#define mp make_pair
#define all(x) x.begin(),x.end()
#define rep(i,a,b) for(int i = (a);i <= (b);i++)
#define pii pair<int,int>
#define pll pair<long long, long long>
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll mod = 1e9 + 7;
const ll INF = 0x3f3f3f3f3f3f3f3f;
const int inf = 0x3f3f3f3f;
const int maxn = 2e5 + 5;
const double eps = 1e-8;
const double pi = acos(-1.0);	
ll gcd(ll a,ll b){return !b?a:gcd(b,a%b);}
ll lcm(ll a,ll b){return a * b / gcd(a,b);}
ll qw(ll x,ll y){ll res = 1;while(y){if(y & 1) res *= x;x = x * x;y >>= 1;}return res;}
ll poww(ll x,ll y,ll p){ll ans = 1;while(y){if(y & 1) ans = ans * x % p;x = x * x % p;y >>= 1;}return ans % p;}
bool isp(ll x){if(x < 2) return 0; for(ll i = 2;i * i <= x;i++){if(x % i == 0) return 0;}return 1;}
ll a,b,c,k;
void solve(){
	ll ans = 0;
	ans += min(k,a);
	k -= min(k,a);
	k -= min(k,b);
	ans -= min(k,c);
	k -= min(k,c);
	cout << ans << endl;
}
int main(){
	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	cin >> a >> b >> c >> k;
	solve();
	return 0;
}
//do smt instead of nothing! never give up!


Measured memory_bytes: 3644
#include <cmath>
#include <cstdio>
#include <vector>
#include <list>
#include <iostream>
#include <algorithm>
#include <sstream>
#include <stack>
#include <fstream>
#include <queue>
#include <iomanip>
#include <iterator>
#include <map>
#include <unordered_map>
#include <set>
#include <assert.h>
#include <numeric>
#define fast ios_base::sync_with_stdio(false)
#define mxn (ll)3e5
#define mod (ll)(1e9+7)
#define mod1 (ll)(998244353)
#define ll long long int
#define ld long double
#define vi vector<ll>
#define vvi vector<vi >
#define pi pair<ll,ll>
#define vvpi vector<vector<pi > >
#define vpi vector<pi >
#define vppi vector<pair<ll,pi > >
#define vs vector<string>
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define pb push_back
#define eb emplace_back
#define mkp make_pair
#define fs first
#define se second
#define crz(v,n) v.clear(),v.resize(n+1,0)
#define print(v) for(ll it=0;it<v.size();it++) cout<<v[it]<<" ";cout<<endl
#define printp(v) for(ll it=0;it<v.size();it++) cout<<v[it].first<<" "<<v[it].second<<endl
using namespace std;
vi f(mxn,1),inv(mxn,1),finv(mxn,1);
struct node{
	int x,y;
	void read(){
		cin>>x>>y;
	}bool operator<(const node&a) const{
		if(a.x-x) return x<a.x;
		return y<a.y;
	}
};ll ncr(int x,int y){
	if(x<1||y<1) return 0;
	int n=x+y-2,r=y-1;
	ll in=(finv[n-r]*finv[r])%mod;
	return (f[n]*in)%mod;
}
int main(){fast;
	int h,w,i,n,j;cin>>h>>w>>n;vector<node>v(n+1);vi d(n+2,0);
	for(i=1;i<f.size();i++) f[i]=(f[i-1]*i)%mod;
	for(i=2;i<mxn;i++) inv[i]=(mod-(mod/i)*inv[mod%i]%mod)%mod,finv[i]=(finv[i-1]*inv[i])%mod;
	for(i=1;i<=n;i++) v[i].read();sort(all(v));
	v.eb(node{h,w});
	for(i=1;i<=n+1;i++){
		d[i]=ncr(v[i].x,v[i].y);
		for(j=i-1;j;j--){
			d[i]=(d[i]-d[j]*ncr(v[i].x-v[j].x+1,v[i].y-v[j].y+1)%mod+mod)%mod;
		}
	}cout<<d[n+1]<<endl;
}


Measured memory_bytes: 10168
import sys
sys.setrecursionlimit(10**6)
read = sys.stdin.read
readlines = sys.stdin.readlines
def main():
    def dfs(node, color):
        # 二部グラフ判定。隣接ノードを自分と異なる色にぬれるか、をチェックする。
        # 黒いノードを-1、白を1、無色を0とする。
        node_color[node] = color
        adjnodes = edges[node]
        for anode in adjnodes:
            anode_color = node_color[anode]
            if anode_color == 0:
                dfs(anode, -color)
            elif anode_color == color:
                gisnibu[0] = 0
                break
            else:
                pass

    # input
    n, m = map(int, input().split())
    edges = {e: [] for e in range(n)}
    e = map(int, read().split())
    for a, b in zip(e, e):
        a -= 1
        b -= 1
        edges[a].append(b)
        edges[b].append(a)

    # process
    node_color = [0] * n
    gisnibu = [1] * 1
    dfs(0, 1)

    # output
    if gisnibu[0]:
        r = node_color.count(1) * node_color.count(-1) - m
        print(r)
    else:
        r = (n * (n - 1)) // 2 - m
        print(r)

if __name__ == '__main__':
    main()

Measured memory_bytes: 60444
#include <stdio.h>
int main(){
  int i,num,key,j,k;
  
  scanf("%d",&num);
  
  int a[num];
  
  for(i = 0 ; i<num ;i++){
    scanf("%d",&a[i]);
  }
  
  for(i = 0 ; i<num ;i++){
      if(i == num-1) printf("%d\n",a[i]);
      else    printf("%d ",a[i]);
  }
  for(i = 1 ; i<=num-1 ;i++){
    key = a[i];
    j = i-1;
    while(j>=0 && a[j] >key){
      a[j+1] = a[j];
      j--;
    }
    a[j+1] = key;
    for(k = 0 ; k<num ;k++){
      if(k == num-1) printf("%d\n",a[k]);
      else  printf("%d ",a[k]);
    }
  }
  return 0;
}
  
   



Measured memory_bytes: 2084
#include<bits/stdc++.h>
using namespace std;
/******** Md-Kamran-Ahmad **********/

#define mid(s,e)        (s+(e-s)/2)
#define rff(a)          freopen((a), "r", stdin);
#define wtf(a)          freopen((a), "w", stdout);
#define YES             cout << "YES" << endl
#define NO              cout << "NO" << endl
#define sin(s)	        getline(cin, s)
#define ll              long long
#define ull             unsigned long long
#define dd              double

typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef pair<ll, ll> pll;
typedef set<int> si;
typedef map<int,int> mii;
typedef map<long,long> mll;
typedef map<string,int> msi;

const double PI=acos(-1.0);

int main()
{
    //freopen("A.txt","r",stdin);
    ios_base::sync_with_stdio(0);
    char s[5];
    for(int i=0; i<4; i++)
    {
        cin>>s[i];
    }
    for(int i=0; i<4; i++)
    {
        if(s[i]==s[i+1] && s[i+1]==s[i+2] || s[i+1]==s[i+2] && s[i+2]==s[i+3])
        {
            cout << "Yes" << endl;
            return 0;
        }
        else
        {
            cout << "No" << endl;
            return 0;
        }
    }
}


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

public class Main{
	static void main() throws Exception{
		int n=sc.nextInt();
		int[]a=new int[n],b=new int[n];
		long sum=0;
		for(int i=0;i<n;i++) {
			a[i]=sc.nextInt();b[i]=sc.nextInt();
			sum+=a[i];
		}
//		shuffle(a);
//		shuffle(b);
//		Arrays.sort(a);
//		Arrays.sort(b);
		long min=sum;
		for(int i=0;i<n;i++) {
			if(b[i]<a[i]) {
				min=Math.min(min, b[i]);
			}
		}
		pw.println(sum-min);
	}
	public static void main(String[] args) throws Exception{
		sc=new MScanner(System.in);
		pw = new PrintWriter(System.out);
		int tc=1;
//		tc=sc.nextInt();
		while(tc-->0)
			main();
		pw.flush();
	}
	static PrintWriter pw;
	static MScanner  sc;
	static class MScanner {
		StringTokenizer st;
		BufferedReader br;
		public MScanner(InputStream system) {
			br = new BufferedReader(new InputStreamReader(system));
		}
 
		public MScanner(String file) throws Exception {
			br = new BufferedReader(new FileReader(file));
		}
 
		public String next() throws IOException {
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}
		public int[] intArr(int n) throws IOException {
	        int[]in=new int[n];for(int i=0;i<n;i++)in[i]=nextInt();
	        return in;
		}
		public long[] longArr(int n) throws IOException {
	        long[]in=new long[n];for(int i=0;i<n;i++)in[i]=nextLong();
	        return in;
		}
		public int[] intSortedArr(int n) throws IOException {
	        int[]in=new int[n];for(int i=0;i<n;i++)in[i]=nextInt();
	        shuffle(in);
	        Arrays.sort(in);
	        return in;
		}
		public long[] longSortedArr(int n) throws IOException {
	        long[]in=new long[n];for(int i=0;i<n;i++)in[i]=nextLong();
	        shuffle(in);
	        Arrays.sort(in);
	        return in;
		}
		public Integer[] IntegerArr(int n) throws IOException {
	        Integer[]in=new Integer[n];for(int i=0;i<n;i++)in[i]=nextInt();
	        return in;
		}
		public Long[] LongArr(int n) throws IOException {
	        Long[]in=new Long[n];for(int i=0;i<n;i++)in[i]=nextLong();
	        return in;
		}
		public String nextLine() throws IOException {
			return br.readLine();
		}
 
		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}
 
		public double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}
 
		public char nextChar() throws IOException {
			return next().charAt(0);
		}
 
		public long nextLong() throws IOException {
			return Long.parseLong(next());
		}
 
		public boolean ready() throws IOException {
			return br.ready();
		}
 
		public void waitForInput() throws InterruptedException {
			Thread.sleep(3000);
		}
	}
	static void shuffle(int[]in) {
		for(int i=0;i<in.length;i++) {
			int idx=(int)(Math.random()*in.length);
			int tmp=in[i];
			in[i]=in[idx];
			in[idx]=tmp;
		}
	}
	static void shuffle(long[]in) {
		for(int i=0;i<in.length;i++) {
			int idx=(int)(Math.random()*in.length);
			long tmp=in[i];
			in[i]=in[idx];
			in[idx]=tmp;
		}
	}
}

Measured memory_bytes: 34932
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>

using namespace std;

int N=1000;

int LCS(string x,string y){
	int c[N+1][N+1],LCSlen=0;
	int m=x.size();
	int n=y.size();
	x=' '+x;
	y=' '+y;
	for(int i=1;i<=m;i++) c[i][0]=0;
	for(int j=1;j<=n;j++) c[0][j]=0;
	for(int i=1;i<=m;i++){
		for(int j=1;j<=n;j++){
			if(x[i]==y[j])
			c[i][j]=c[i-1][j-1]+1;
			else
			c[i][j]=max(c[i][j-1],c[i-1][j]);
			LCSlen=max(LCSlen,c[i][j]);
		}
	}
	return LCSlen;
}

int main(){
	char x[1000],y[1000];
	string xst,yst;
	int n;
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		scanf("%s",x);
		scanf("%s",y);
		xst=x;
		yst=y;
		printf("%d\n",LCS(x,y));
	}
}

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

int R,C,K,r,c,v;
int board[3001][3001];
long long int dp[3001][3001][4];

int main(void)
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	cin >> R >> C >> K;
	for(int i=0;i<K;i++)
	{
		cin >> r >> c >> v;
		board[r][c] = v;
	}

	memset(dp,-1,sizeof(dp));
	dp[1][1][1] = board[1][1];
	dp[1][1][0] = 0;
	for(int i=1;i<=R;i++)
	{
		for(int j=1;j<=C;j++)
		{
			for(int k=0;k<4;k++)
			{
				if(k==3)
				{
					if(j+1<=C)
					{
						dp[i][j+1][k] = max(dp[i][j+1][k],dp[i][j][k]);
					}
					if(i+1<=R)
					{
						dp[i+1][j][0] = max(dp[i+1][j][0],dp[i][j][k]);
						dp[i+1][j][1] = max(dp[i+1][j][1],dp[i][j][k] + board[i+1][j]);
					}
				}
				else
				{
					if(j+1<=C)
					{
						dp[i][j+1][k] = max(dp[i][j+1][k],dp[i][j][k]);
						dp[i][j+1][k+1] = max(dp[i][j+1][k+1],dp[i][j][k] + board[i][j+1]);
					}
					if(i+1<=R)
					{
						dp[i+1][j][0] = max(dp[i+1][j][0],dp[i][j][k]);
						dp[i+1][j][1] = max(dp[i+1][j][1],dp[i][j][k] + board[i+1][j]);
					}
				}
			}
		}
	}

	long long int res = 0;

	for(int i=1;i<=R;i++)
	{
		for(int j=1;j<=C;j++)
		{
			for(int k=0;k<4;k++)
			{
				res = max(res,dp[i][j][k]);
			}
		}
	}

	cout << res  << '\n';

	return 0;
}

Measured memory_bytes: 320248
#pragma region template
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using vld = vector<ld>;
using vvld = vector<vld>;
using vvvld = vector<vvld>;
using vs = vector<string>;
using pll = pair<ll, ll>;
using vp = vector<pll>;
template <typename T>
using pqrev = priority_queue<T, vector<T>, greater<T>>;
#define rep(i, n) for (ll i = 0, i##_end = (n); i < i##_end; i++)
#define repb(i, n) for (ll i = (n)-1; i >= 0; i--)
#define repr(i, a, b) for (ll i = (a), i##_end = (b); i < i##_end; i++)
#define reprb(i, a, b) for (ll i = (b)-1, i##_end = (a); i >= i##_end; i--)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((ll)(x).size())
//*
constexpr ll MOD = 1e9 + 7;
/*/
constexpr ll MOD = 998244353;
//*/
constexpr ll INF = 1e+18;
constexpr ld EPS = 1e-12L;
constexpr ld PI = 3.14159265358979323846L;
constexpr ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }
constexpr ll LCM(ll a, ll b) { return a / GCD(a, b) * b; }
template <typename S, typename T>
constexpr bool chmax(S &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <typename S, typename T>
constexpr bool chmin(S &a, const T &b) {
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
#ifdef OJ_LOCAL
#include "dump.hpp"
#else
#define dump(...) ((void)0)
#endif
template <typename T>
bool print_(const T &a) {
  cout << a;
  return true;
}
template <typename T>
bool print_(const vector<T> &vec) {
  for (auto &a : vec) {
    cout << a;
    if (&a != &vec.back()) {
      cout << " ";
    }
  }
  return false;
}
template <typename T>
bool print_(const vector<vector<T>> &vv) {
  for (auto &v : vv) {
    for (auto &a : v) {
      cout << a;
      if (&a != &v.back()) {
        cout << " ";
      }
    }
    if (&v != &vv.back()) {
      cout << "\n";
    }
  }
  return false;
}
void print() { cout << "\n"; }
template <typename Head, typename... Tail>
void print(Head &&head, Tail &&... tail) {
  bool f = print_(head);
  if (sizeof...(tail) != 0) {
    cout << (f ? " " : "\n");
  }
  print(forward<Tail>(tail)...);
}
#pragma endregion

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(20);
  int n, d;
  cin >> n >> d;
  vi x(n), y(n);
  rep(i, n){
    cin >> x[i] >> y[i];
  }
  two_sat ts(n);
  rep(i, n)repr(j, i+1, n){
    if(abs(x[i]-x[j]) < d) ts.add_clause(i, 1, j, 1);
    if(abs(x[i]-y[j]) < d) ts.add_clause(i, 1, j, 0);
    if(abs(y[i]-x[j]) < d) ts.add_clause(i, 0, j, 1);
    if(abs(y[i]-y[j]) < d) ts.add_clause(i, 0, j, 0);
  }
  auto ans = ts.satisfiable();
  if(ans){
    print("Yes");
    int i = 0;
    for(auto&& e: ts.answer()){
      print(e ? y[i] : x[i]);
      i++;
    }
  }else{
    print("No");
  }
}


Measured memory_bytes: 3740
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
template<class T>inline bool chmax(T &a, const T &b){if(a < b){a = b; return 1;}return 0;}
template<class T>inline bool chmin(T &a, const T &b){if(a > b){a = b; return 1;}return 0;}
typedef long long ll;
int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  // ABC097C - K-th Substring
  string s; cin >> s;
  int K; cin >> K;
  int N = s.size();
  set<string> setS;
  REP(i, N){
    for(int j = 1; j <= min(N - i, K); j++){
      setS.insert(s.substr(i, j));
    }
  }
  vector<string> vecS(setS.begin(), setS.end());
  sort(vecS.begin(), vecS.end());
  cout << vecS[K-1] << endl;
}


Measured memory_bytes: 1792
#include<stdio.h>
#include<stdlib.h>
#define N 9
#define INF 330000

int ans[N]={1,2,3,4,5,6,7,8,0};
int head=0,tail=0,cnt=0;

struct qu{
  int s[N];
};

struct node{
  int key;
  struct node *parent,*left,*right;
};

struct node *root,*NIL;
struct qu Q[INF];

void enqueue(struct qu x){

  int next=tail+1;
  Q[tail]=x;
  tail=next;
}
struct qu dequeue(void){
  struct qu x;

  x=Q[head];
  head=head+1;
  return x;
}

int find(struct node *u, int k){
  while(u!=NIL&&k!=u->key){
    if(k<u->key) u=u->left;
    else u=u->right;
  }
  if(u!=NIL) return 1;
  else return 0;
}

int insert(struct qu a){
  int k,i,j;

  for(i=0;i<=N;i++){
    if(i==0) k+=a.s[i];
    else{
      for(j=0;j<i;j++) a.s[i]*=10;
      k+=a.s[i];
    }
  }

  if(find(root,k)==1) return 0;

  struct node *y=NIL;  //xの親
  struct node *x=root;
  struct node *z;

  z=(struct node*)malloc(sizeof(struct node));

  z->key=k;
  z->left=NIL;
  z->right=NIL;

  while(x!=NIL){
    y=x;
    if(z->key<x->key) x=x->left;
    else x=x->right;
  }

  z->parent=y;

  if(y==NIL) root=z;
  else if(z->key<y->key) y->left=z;
  else y->right=z;

  return 1;
}

int trade(){
  int tmp,i,flag,loc,h[INF],sum;
  struct qu a,b,c,d,y;

  h[head]=0;

  while(1){

    sum=h[head];
    y=dequeue();

    flag=0;

    for(i=0;i<N;i++){
      if(y.s[i]!=ans[i]) flag=1;
      if(y.s[i]==0) loc=i; //０の位置を記録
    }
    if(flag==0) break;

    a=b=c=d=y;

    /*
      ０を移動させるとして　aは上　bは右　cは下　dは左
      条件を満たす場合０と交換して、ヒューリスティック探索を行う
    */
    if(loc%3!=0){tmp=a.s[loc-1]; a.s[loc-1]=0; a.s[loc]=tmp;
          if(insert(a)==1){ enqueue(a); h[tail-1]=(sum+1);}}

    if(loc%3!=2){ tmp=b.s[loc+1]; b.s[loc+1]=0; b.s[loc]=tmp;
      if(insert(b)==1){ enqueue(b); h[tail-1]=(sum+1);}}

    if(loc<6){tmp=c.s[loc+3]; c.s[loc+3]=0; c.s[loc]=tmp;
      if(insert(c)==1){ enqueue(c); h[tail-1]=(sum+1);}}

    if(loc>2){tmp=d.s[loc-3]; d.s[loc-3]=0; d.s[loc]=tmp;
      if(insert(d)==1){ enqueue(d); h[tail-1]=(sum+1);}}
  }

  return sum;
}

int main(){
  int i,j,sum,a;
  struct qu x;

  for(i=0;i<N;i++){
    scanf("%d",&x.s[i]);
  }

  insert(x);
  enqueue(x);
  sum=trade();

  printf("%d\n",sum);

  return 0;
}



Measured memory_bytes: 17464
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <memory>
#include <complex>
#include <numeric>
#include <cstdio>
#include <iomanip>

#define REP(i,m,n) for(int i=int(m);i<int(n);i++)
#define RREP(i,m,n) for(int i=int(n)-1;i>=int(m);--i)
#define EACH(i,c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR 
#endif
using namespace std;

using UI = unsigned int;
using UL = unsigned long;
using LL = long long int;
using ULL = unsigned long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VS = vector<string>;
using PII = pair<int,int>;
using VP = vector<PII>;

//struct edge {int from, to, cost;};

constexpr double EPS = 1e-10;
//constexpr double PI  = acos(-1.0);
//constexpr int INF = INT_MAX;

template<class T> inline T sqr(T x) {return x*x;}

void solve() {
    int n;
    cin >> n;
    int ans = 0;
    REP(i,1,n+1) {
        int cnt = 0;
        for (int j = 1; j <= i; j += 2) if (i % j == 0) ++cnt;
        ans += (cnt == 8);
    }
    cout << ans << endl;
}

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

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

int main()
{
	long long a, b, c;
	cin >> a >> b >> c;
	if (c-a-b > 0 and 4*a*b < (c-a-b)*(c-a-b)) cout << "Yes" << endl;
	else cout << "No" << endl;
}


Measured memory_bytes: 256
N = int(input())
cards = {}
for _ in range(N):
    s = input()
    if s in cards.keys():
        cards[s] +=1
    else:
        cards[s] = 1

M = int(input())
for _ in range(M):
    t = input()
    if t in cards.keys():
        cards[t] -= 1
    else:
        continue
ans = max(max(cards.values()),0)
print(ans)

Measured memory_bytes: 3060
import java.util.*;
 
class Main {
  
    public static void main(String[] args) {
      
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
      	int mo = sc.nextInt();
      
      for(int i = 0;i <= N;i++){
      	for(int j = 0;j+i<= N;j++){
              if(i*10000+j*5000+(N-i-j)*1000==mo){
                	System.out.print(i+" "+j+" "+(N-i-j));
                          	return;
                          }
          }
        }
      System.out.print(-1+" "+-1+" "+-1);
    }
}

Measured memory_bytes: 22996
#include <iostream>

using namespace std;

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

    int ans = 0;
    for (int i = a; i <= b; ++i) {
        if (i / 1000 == ((i % 10 * 10) + (i % 100 / 10))) ans++;
    }
    cout << ans << endl;
}

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

int main(){
  string N;
  cin >>N;
  if ((N[0]==N[1] && N[1]==N[2]) ||(N[1]==N[2] &&N[2]==N[3]))cout <<"Yes"<<endl;
  else cout <<"No"<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <cstring>
#include <utility>
#include <numeric>

using namespace std;

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

int main(){

    long long A, B;
    cin >> A >> B;

    long long gcdAB = gcd(A, B);

    vector<bool> check(1000001, false);
    int ans = 1;
    for(int i = 2; i <= 1000000; i++){
        if(!check[i]){
            if(gcdAB % i == 0){
                ans++;
            }
            
            while(gcdAB % i == 0){
                gcdAB /= i;
            }

            for(int j = 2 * i; j <= 1000000; j += i){
                check[j] = true;
            }
        }
    }

    if(gcdAB != 1){
        ans++;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 384
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		while(in.hasNext())
		{
		int num = in.nextInt();	
		int a = num/100;
		int b = num%100/10;
		int c = num%100%10;
		if(num == c*100+b*10+a)
		{
			System.out.println("Yes");
		}else{
			System.out.println("No");
		}
		}
	}
}


Measured memory_bytes: 21844
#include<iostream>
#include<algorithm>
using namespace std;
using ll = long long;

int main() {
	ll n, m;
	cin >> n >> m;
	ll x[1100], y[1100], z[1100];
	for (int i = 0;i < n;i++) {
		cin >> x[i] >> y[i] >> z[i];
	}
	///+++
	ll ans = 0, res[1100], ress = 0;
	for (int i = 0;i < n;i++)res[i] = x[i] + y[i] + z[i];
	sort(res, res + n);
	for (int i = n - 1;i >= n - m;i--)ans += res[i];
	///++-
	ress = 0;
	for (int i = 0;i < n;i++)res[i] = x[i] + y[i] - z[i];
	sort(res, res + n);
	for (int i = n - 1;i >= n - m;i--)ress += res[i];
	ans = max(ans, ress);
	///+-+
	ress = 0;
	for (int i = 0;i < n;i++)res[i] = x[i] - y[i] + z[i];
	sort(res, res + n);
	for (int i = n - 1;i >= n - m;i--)ress += res[i];
	ans = max(ans, ress);
	///+--
	ress = 0;
	for (int i = 0;i < n;i++)res[i] = x[i] - y[i] - z[i];
	sort(res, res + n);
	for (int i = n - 1;i >= n - m;i--)ress += res[i];
	ans = max(ans, ress);
	///-++
	ress = 0;
	for (int i = 0;i < n;i++)res[i] = -x[i] + y[i] + z[i];
	sort(res, res + n);
	for (int i = n - 1;i >= n - m;i--)ress += res[i];
	ans = max(ans, ress);
	///-+-
	ress = 0;
	for (int i = 0;i < n;i++)res[i] = -x[i] + y[i] - z[i];
	sort(res, res + n);
	for (int i = n - 1;i >= n - m;i--)ress += res[i];
	ans = max(ans, ress);
	///--+
	ress = 0;
	for (int i = 0;i < n;i++)res[i] = -x[i] - y[i] + z[i];
	sort(res, res + n);
	for (int i = n - 1;i >= n - m;i--)ress += res[i];
	ans = max(ans, ress);
	///---
	ress = 0;
	for (int i = 0;i < n;i++)res[i] = -x[i] - y[i] - z[i];
	sort(res, res + n);
	for (int i = n - 1;i >= n - m;i--)ress += res[i];
	ans = max(ans, ress);

	cout << ans << endl;
}


Measured memory_bytes: 256