akhauriyash/Code-Regression huggingface dataset:
#ifdef LOCAL
#define _GLIBCXX_DEBUG
#endif
#include<bits/stdc++.h>
using namespace std;
#define rep(i,s,t) for(ll i = (ll)(s); i < (ll)(t); i++)
#define rrep(i,s,t) for(ll i = (ll)(s-1);(ll)(t) <= i; i--)
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> Pll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
constexpr ll INF = numeric_limits<ll>::max()/4;
constexpr ll n_max = 2e5+10;
#define int ll

template <typename A, typename B>
string to_string(pair<A, B> p);
string to_string(const string &s) {return '"' + s + '"';}
string to_string(const char *c) {return to_string((string) c);}
string to_string(bool b) {return (b ? "true" : "false");}
template <size_t N>
string to_string(bitset<N> v){
    string res = "";
    for(size_t i = 0; i < N; i++) res += static_cast<char>('0' + v[i]);
    return res;
}
template <typename A>
string to_string(A v) {
    bool first = true;
    string res = "{";
    for(const auto &x : v) {
        if(!first) res += ", ";
        first = false;
        res += to_string(x);
    }
    res += "}";
    return res;
}
template <typename A, typename B>
string to_string(pair<A, B> p){return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";}

void debug_out() {cerr << endl;}
template<typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cerr << " " << to_string(H);
    debug_out(T...);
}

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

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

signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    ll n; cin >> n;
    vector<ll> x(n);
    for(int i = 0; i < n; i++) cin >> x[i];
    ll l; cin >> l;
    const ll LOG = 32;
    vector table(LOG+1, vector<ll>(n));
    ll right = 0;
    rep(i,0,n){
        while(right < n && x[right] <= x[i] + l){
            right++;
        }
        table[0][i] = right-1;
        if(i == right)right++;
    }
    debug(table[0]);
    rep(k,0,LOG){
        rep(i,0,n){
            table[k+1][i] = table[k][table[k][i]];
        }
    }
    ll q; cin >> q;
    rep(_,0,q){
        ll f,t; cin >> f >> t;
        f--;t--;
        if(!(f < t))swap(f, t);
        ll ans = 0;
        rrep(k,LOG,0){
            if(table[k][f] < t){
                f = table[k][f];
                ans += (1LL << k);
            }
        }

        cout << ans + 1 << "\n";
    }
}

Measured memory_bytes: 30612
class Dice():
	def __init__(self):
		self.d = [0,1,2,3,4,5]

	def dice_n(self):
		self.d[4],self.d[0],self.d[1],self.d[5] = self.d[0],self.d[1],self.d[5],self.d[4]

	def dice_s(self):
		self.d[0],self.d[4],self.d[5],self.d[1] = self.d[4],self.d[5],self.d[1],self.d[0]

	def dice_w(self):
		self.d[0],self.d[2],self.d[5],self.d[3] = self.d[2],self.d[5],self.d[3],self.d[0]

	def dice_e(self):
		self.d[0],self.d[3],self.d[5],self.d[2] = self.d[3],self.d[5],self.d[2],self.d[0]

	def get_top(self):
		return self.d[0]

if __name__ == '__main__':

	dd = list(map(int,input().split()))
	line = input()

	d = Dice()

	for di in line:
		if di == "N":
			d.dice_n()
		elif di == "S":
			d.dice_s()
		elif di == "W":
			d.dice_w()
		elif di == "E":
			d.dice_e()

	print(dd[d.get_top()])




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

int main(){
    int n;
    cin >> n;
    vector<int> d(n);
    for(int i=0; i<n; i++){
        cin >> d[i];
    }
    sort(d.begin(),d.end());
    int tmp=(n-1)/2;
    int a=d[tmp];
    int b=d[tmp+1];
    cout << b-a << endl;
}

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

using namespace std;
using LL = long long;
const int N = 1024;
const int INF = INT32_MAX - 1;
const double EPS = 1E-9;

int a[N];
int n, m;

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

#ifdef CF_DEBUG
    freopen("../cf/input.txt","r",stdin);
#endif
    cin>>n;
    cout<<ceil(n*1.0/2)<<"\n";
    return 0;
}

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

#define ll long long
#define ull unsigned long long

using namespace std;

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

	ll ans = 0;
	map<string, int> m;
	for (int ii = 0; ii < N; ++ii){
		string s;
		cin >> s;
		sort(s.begin(), s.end());
		m[s]++;
		ans += m[s] - 1;
	}

	cout << ans << "\n";

	return 0;
}


Measured memory_bytes: 11136
import sys
n = int(input())
A = [int(e)for e in sys.stdin]
cnt = 0
G = [int((2.25**i-1)/1.25)for i in range(17,0,-1)]
G = [v for v in G if v <= n]
def insertionSort(A, n, g):
    global cnt
    for i in range(g, n):
        v = A[i]
        j = i - g
        while j >= 0 and A[j] > v:
            A[j+g] = A[j]
            j = j - g
            cnt += 1
        A[j+g] = v
for g in G:
    insertionSort(A, n, g)
print(len(G))
print(*G)
print(cnt)
print(*A,sep='\n')


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

int main() {

int x,y;
cin>>x>>y;

if(y<2*x || 4*x<y)
 cout<<"No";
else
{
	if((y-2*x)%2==0 && (4*x-y)%2==0)
	cout<<"Yes";
	else
	cout<<"No";
}

	return 0;
}

Measured memory_bytes: 3632
#include "bits/stdc++.h"
using namespace std;
#define rep(i,n)for(int i=0;i<(int)(n);i++)
#define PI 3.141592653589793
//vector < vector<int>>a(0, vector<int>(0));二次元配列宣言


int main()
{
	string s;
	cin >> s;

	if (s == "Sunny")
		cout << "Cloudy" << endl;
	else if (s == "Cloudy")
		cout << "Rainy" << endl;
	else
		cout << "Sunny" << endl;
}

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

//using namespace boost::multiprecision;
using namespace std;
//typedef long long ll;
//typedef unsigned long long ll;
const double EPS = 1e-9;
#define rep(i, n) for (int i = 0; i < (n); ++i)
//#define rep(i, n) for (ll i = 0; i < (n); ++i)
//#define sz(x) ll(x.size())
//typedef pair<int, int> P;
//typedef pair<ll, int> P;
//typedef pair<ll, ll> P;
//const double INF = 1e10;
//const ll INF = LONG_LONG_MAX / 100;
//const ll INF = (1ll << 31) - 1;
//const ll INF = 1e15;
//const ll MINF = LONG_LONG_MIN;
//const int INF = INT_MAX / 10;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
//typedef pair<int, int> P;
//typedef pair<double, double> P;
#define ret() return 0;

bool contain(set<char> &s, char a) { return s.find(a) != s.end(); }

//ifstream myfile("C:\\Users\\riku\\Downloads\\0_00.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);
const int mod = 1000000007;
//const ll mod = 1e10;
typedef priority_queue<long long, vector<long long>, greater<long long> > PQ_ASK;

int main() {
    typedef unsigned long long ll;
    int n;
    cin >> n;

    vector<ll> caps(n);
    rep(i, n)cin >> caps[i];

    map<ll, int> m;
    for (ll c: caps) m[c]++;


    if (m.find(0) != m.end() && m[0] == n) {
        cout << "Yes" << endl;
        ret();
    }

    if (n % 3 != 0) {
        cout << "No" << endl;
        ret();
    }

    vector<ll> numbers, counts;
    for (auto e : m) {
        numbers.push_back(e.first);
        counts.push_back(e.second);
    }

    if (numbers.size() == 2) {
        if (numbers[0] == 0 && counts[1] == 2 * n / 3) {
            cout << "Yes" << endl;
        } else {
            cout << "No" << endl;
        }
        ret();
    }

    if (numbers.size() == 3) {
        if (((numbers[0] ^ numbers[1] ^ numbers[2]) == 0) && counts[0] == n / 3 && counts[1] == n / 3 &&
            counts[2] == n / 3) {
            cout << "Yes" << endl;
        } else {
            cout << "No" << endl;
        }
        ret();
    }

    cout << "No" << endl;

}



Measured memory_bytes: 7332
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int INF = 1e9;
const int MOD = 1e9 + 7;

int main()
{
  string n;
  cin >> n;
  int cnt = 0;
  for (int i = 0; i < n.size(); ++i)
    if (n[i] == '2')
      cnt++;
  cout << cnt << endl;

  return 0;
}


Measured memory_bytes: 768
#include<bits/stdc++.h>
using namespace std;
int main() {
  int N; cin >> N;
  int res = 0;
  vector<int> v(1e6);
  for (int x = 1; x * x < N; x++) {
    for (int y = 1; y * y < N; y++) {
      for (int z = 1; z * z < N; z++) {
        v[x * x + y * y + z * z + x * y + y * z + z * x]++;
      }
    }
  }
  for (int i = 1; i <= N; i++) {
    cout << v[i] << endl;
  }
}


Measured memory_bytes: 7076
#include <iostream>
#include <cmath>
#include <algorithm>
#include <map>
#include <string>
#include <vector>
#define FOR(i, a, b)  for(int i=a; i<b; ++i)
#define rFOR(i, a, b) for(int i=a-1; i>=b; --i)
#define REP(i, n) for(int i=0; i<n; ++i)
#define rREP(i, n) for(int i=n-1; i>=0; --i)
#define all(a)  a.begin(), a.end()
#define MAXNUM 100000
using namespace std;
typedef long long ll;

int main(){
  ll n, m; cin >> n >> m;
  if(n==1&&m==1)  cout << 1 << endl;
  else if(n==1||m==1) cout << n*m-2 << endl;
  else  cout << (n-2)*(m-2) << endl;
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

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

    //input
    int x = sc.nextInt();

    //output
    if( x >= 30 ){
      System.out.println("Yes");
    }else{
      System.out.println("No");
    }    

  }
}


Measured memory_bytes: 26972
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		
		int a = stdIn.nextInt();
		
		if (a >= 1200) {
			System.out.println("ARC");
		} else {
			System.out.println("ABC");
		}
	}
}

Measured memory_bytes: 21972
#include <stdio.h>
int main(void)
{
    int t,h,m,s;
    scanf("%d",&t);
    h=t/3600;
    m=(t%3600)/60;
    s=(t%3600)%60;
    printf("%d:%d:%d\n",h,m,s);
    return(0);
}



Measured memory_bytes: 2096
//Minimum Spannig Tree
#include <iostream>
#include <vector>
#include <climits>

using namespace std;

static const int N = 100;
static const int WHITE = 0;
static const int BLACK = 1;

int prim(vector<vector<int>> &G, int n) {
    int colors[n], d[n];
    for(int i = 0; i < n; i++) {
        colors[i] = WHITE;
        d[i] = INT_MAX;
    }

    d[0] = 0;
    int l = 0;
    while(1) {
        int u = -1;
        int mincost = INT_MAX;
        for(int i = 0; i < n; i++) {
            if(colors[i] == WHITE && d[i] < mincost) {
                mincost = d[i];
                u = i;
            }
        }
        if(u == -1) break;
        colors[u] = BLACK;
        l += mincost;
        for(int v = 0; v < n; v++)
            if(colors[v] == WHITE && G[u][v] != -1)
                if(G[u][v] < d[v])
                    d[v] = G[u][v];
    }
    return l;
}

int main() {
    int n;
    cin >> n;
    vector<vector<int>> G(n, vector<int>(n));
    for(int i = 0; i < n; i++)
        for(int j = 0; j < n; j++)
            cin >> G[i][j];

    cout << prim(G, n) << endl;
}



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

int main() {
	long long a,b,c;
	cin>>a>>b;
	c=a*b;
	if(c%2==0)
	{
		cout<<"Even"<<endl;
	}
	else
	cout<<"Odd"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
// #include <algorithm>
// #include <queue>
// #include <vector>
using namespace std;

const int NMAX = 10000;
const int QMAX = 100000;
int n;
int s[NMAX];
int q;
int group= 0;

void unite(int x, int y) {
	group++;
	if (s[x] == 0) {
		s[x] = group;
		group++;
	}
	if (s[y] == 0) {
		s[y] = group;
		group++;
	}
	int xgr = s[x];
	int ygr = s[y];
	for (int i = 0; i < n; i++) {
		if (s[i] == ygr || s[i] == xgr) {
			s[i] = group;
		}
	}
}

bool same(int x, int y) {
	if (s[x] == 0 || s[y] == 0) {
		return false;
	}
	return s[x] == s[y];
}

int main() {
	scanf("%d %d", &n, &q);
	for (int i = 0; i < n; i++) {
		s[i] = group;
	}

	int com, x, y;
	for (int i = 0; i < q; i++) {
		scanf("%d %d %d", &com, &x, &y);
		if (com == 0) { // unite
			unite(x, y);
			continue;
		}
		if (com == 1) { // same
			bool isSame = same(x, y);
			if (isSame) {
				printf("%d\n", 1);
			} else {
				printf("%d\n", 0);
			}
			continue;
		}
	}

	return 0;
}



Measured memory_bytes: 3260
#include <bits/stdc++.h>
using namespace std;
int n;
const int N = 300000;
int tot;
vector <int> bi[N];
int dep[N], A[N], B[N], fa[N], vis[N];
int dfs1(int t, int f = -1, int d = 0)
{
    int v = t;
    dep[t] = d; fa[t] = f;
    for (int i = 0; i < bi[t].size(); ++ i)
        if (bi[t][i] != f)
        {
            int w = dfs1(bi[t][i], t, d + 1);
            if (dep[w] > dep[v]) v = w;
        }
    return v;
}
void dfs2(int t, int d, int A[], int f = -1)
{
    int c = bi[t].size() + (f == -1 || t == d) - 2;
    A[tot + c] = tot;
    for (int i = 1; i <= c; ++ i) A[tot + i - 1] = tot + i;
    tot += c + 1;
    for (int i = 0; i < bi[t].size(); ++ i)
        if (vis[bi[t][i]] && bi[t][i] != f)
            dfs2(bi[t][i], d, A, t);
}

void solve(int pa, int pb, int A[])
{
    tot = 1;
    dfs2(pa, pb, A);
}
int *ans;
int main()
{
    ios::sync_with_stdio();
    cin >> n;
    for (int i = 1; i < n; ++ i)
    {
        int a, b;
        cin >> a >> b;
        bi[a].push_back(b);
        bi[b].push_back(a);
    }

    int pa = dfs1(1), pb = dfs1(pa);
    for (int p = pb; p != -1; p = fa[p]) vis[p] = 1;
    for (int i = 1; i <= n; ++ i) if (!vis[i] && bi[i].size() != 1)
    {
        cout << -1 << endl;
        return 0;
    }
    solve(pa, pb, A); solve(pb, pa, B);
    ans = A;
    for (int i = 1; i <= n; ++ i)
        if (A[i] != B[i])
        {
            if (A[i] > B[i]) ans = B;
            else ans = A;
            break;
        }
    for (int i = 1; i <= n; ++ i) cout << ans[i] << " "; cout << endl;
}


Measured memory_bytes: 23424
#include<iostream>
#include<cmath>
#include<cstdio>
using namespace std;
int main(){
    int n;
    double p1,p2,p3,pm=0,a,b=0,c=0,d=0;
    cin>>n;
    int x[1000]={};
    int y[1000]={};
    for(int i=0;i<n;i++){
        cin>>x[i];
    }
    for(int i=0;i<n;i++){
        cin>>y[i];
    }
    for(int i=0;i<n;i++){
       a=fabs(x[i]-y[i]);
       b+=a;
       c+=a*a;
       d+=a*a*a;
       if(pm<a){
           pm=a;
       }
    }
    p1=b;
    p2=sqrt(c);
    p3=cbrt(d);
    printf("%f\n %f\n %f\n %f\n",p1,p2,p3,pm);
    
   
    
    
    
    return 0;
}


Measured memory_bytes: 3332
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; ++i)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = int64_t;
using ld = long double;
using P = pair<int, int>;
using vs = vector<string>;
using vi = vector<int>;
using vvi = vector<vi>;
template<class T> using PQ = priority_queue<T>;
template<class T> using PQG = priority_queue<T, vector<T>, greater<T> >;
const int INF = 100010001;
const ll LINF = (ll)INF*INF*10;
template<typename T1, typename T2>
inline bool chmax(T1 &a, T2 b) {return a < b && (a = b, true);}
template<typename T1, typename T2>
inline bool chmin(T1 &a, T2 b) {return a > b && (a = b, true);}
template<typename T1, typename T2>
istream &operator>>(istream &is, pair<T1, T2> &p) { return is >> p.first >> p.second;}
template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p) { return os << p.first << ' ' << p.second;}

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

    ll ans = x/11*2;
    x %= 11;
    if(x > 6) ans += 2;
    else if(x) ans++;
    cout << ans << endl;
}

Measured memory_bytes: 3616
using static Algo;
using System;
using System.Text.Json;

class Program
{
    static void Main(string[] args)
    {
        int[] n = InputIntArray();
        int h = n[0], w = n[1], k = n[2];
        string[] c = new string[h];


        for(int i = 0; i < h; i++)
        {
            c[i] = Console.ReadLine();
        }

        int count = 0;
        int maxH =  (int)Math.Pow(2,h )  ;
        int maxW = (int) Math.Pow(2,w );
        for (int selectH = 0; selectH < maxH; selectH++)
        {
            for (int selectW = 0; selectW < maxW; selectW++)
            {
                int blackCount = 0;
                for(int i = 0; i < h; i++)
                {
                    if ((GetBit(i) & selectH) != 0 )
                        continue;

                    for(int j = 0; j < w; j++)
                    {
                        if ((GetBit(j) & selectW) != 0)
                            continue;
                        
                        if (c[i][j] == '#')
                        {

                            blackCount++;
                            if (blackCount > k)
                                break;
                        }

                        
                    }

                    if (blackCount > k)
                        break;
                }
                if (blackCount == k)
                {
                    count++;
                }

            }


           
        }

        Console.WriteLine(count);
    }

    static int GetBit(int i)
    {
     

        return (int)Math.Pow(2, i );

    }

}


static class Algo
{
    public static void BubbleSort<T>(T[] a)
        where T : IComparable<T>
    {
        int n = a.Length;
        for (int i = 0; i < n - 1; i++)
            for (int j = n - 1; j > i; j--)
                if (a[j].CompareTo(a[j - 1]) < 0)
                    Swap(ref a[j], ref a[j - 1]);
    }

    public static void Swap<T>(ref T a, ref T b)
    {
        T c = a;
        a = b;
        b = c;
    }

    public static int[] InputIntArray()
    {
        string[] strs = Console.ReadLine().Split(' ');
        int[] num = new int[strs.Length];
        for (int i = 0; i < num.Length; i++)
        {
            num[i] = int.Parse(strs[i]);
        }
       
        return num;
        
    }

    public static float[] InputFloatArray()
    {
        string[] strs = Console.ReadLine().Split(' ');
        float[] num = new float[strs.Length];
        for (int i = 0; i < num.Length; i++)
        {
            num[i] = float.Parse(strs[i]);
        }
        return num;
    }
}




Measured memory_bytes: 27844
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Deque;
import java.util.Iterator;
import java.util.Scanner;

// Genericを使った 多分これがよい？
// 実際のソートするときはComparatorで持たせる（下記参照）
class Pair<F, S>{
    public final F first;
    public final S second;

    public Pair (F first, S second) {
        this.first = first;
        this.second = second;
    }
}
class Main{
	public static void main(String args[]){
	    final int INF = Integer.MAX_VALUE/2;
		Scanner sc=new Scanner(System.in);
		int N = sc.nextInt();
		ArrayList<Pair<Integer, Integer>>[] edge = new ArrayList[N];
		for(int i = 0; i < N; i++) {
			edge[i] = new ArrayList<Pair<Integer, Integer>>();
		}
		for(int i = 0; i < N - 1; i++) {
			int u = sc.nextInt();
			int v = sc.nextInt();
			int w = sc.nextInt();
			edge[u - 1].add(new Pair<Integer, Integer>(v - 1, w));
			edge[v - 1].add(new Pair<Integer, Integer>(u - 1, w));
		}
		int[] d = new int[N];
        Arrays.fill(d, -1);
        d[0] = 0;
        Deque<Integer> que = new ArrayDeque<Integer>();
        que.add(0);
        while(!que.isEmpty()){
        	int now = que.pop();
            for(Iterator<Pair<Integer, Integer>> it = edge[now].iterator(); it.hasNext();) {
                Pair<Integer, Integer> next = it.next();
                if(d[next.first] == -1) {
                    d[next.first] = d[now] + next.second;
                    que.add(next.first);
                }
            }
        }

        for(int i = 0;  i < N; i++) {
        	System.out.println((d[i] % 2 == 0) ? 0 : 1);
        }
	}
}

Measured memory_bytes: 113104
maisu = [int(i) for i in input().split()]

if maisu[0] + maisu[1] <= maisu[2]:
    print(0, 0)

elif maisu[0] >= maisu[2]:
    print((maisu[0] - maisu[2]), maisu[1])
    
elif maisu[0] < maisu[2]:
    print(0, maisu[1] - (maisu[2] - maisu[0]))

Measured memory_bytes: 3064
N = int(input())
ds = [int(i) for i in input().split()]

len_ds = len(ds)
s = 0

# あえてitertoolsを使わないで解く
for i in range(len_ds-1):
    for j in range(i+1, len_ds):
        s += ds[i] * ds[j]
print(s)

Measured memory_bytes: 2940
#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() {
  string s="NNN";
  int ans=0;
  rep(i,3){
    cin >> s.at(i);
  }
  if(s=="RRR") ans=3;
  if(s=="SRR" || s=="RRS") ans=2;
  if(s=="RSR" || s=="SSR" || s=="RSS" || s=="SRS") ans=1;
  if(s=="SSS") ans=0;


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


Measured memory_bytes: 3580
a,b=map(int,input().split())
def get_prime_dic(n):
    dic = {}
 
    i = 2
    while i * i <= n:
        while n % i == 0:
            n //= i
            if i in dic:
                dic[i] += 1
            else:
                dic[i] = 1
        i += 1
 
    if n > 1:
        dic[n] = 1
    return dic
c=get_prime_dic(a)
d=get_prime_dic(b)
ans=1

ans+=len(set(c)&set(d))

print(ans)

Measured memory_bytes: 3064
import java.util.Scanner;

class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int d = sc.nextInt();
    sc.close();
    System.out.println(n % (2 * d + 1) == 0 ? n / (2 * d + 1) : n / (2 * d + 1) + 1);
  }
}

Measured memory_bytes: 21204
#include<stdio.h>
#include<algorithm>
#include<functional>
using namespace std;
int main(void)
{
	int n,a,b,c[100],x,y,d;
	int i,k;
	scanf("%d %d %d %d",&n,&a,&b,&x);
	for(i=0;i<n;i++) scanf("%d",&c[i]);
	sort(c,c+n,greater<int>());
	d=x/a;
	for(i=0;i<n;i++){
		x=x+c[i];
		y=x/(a+(i+1)*b);
		if(d<y) d=y;
	}
	printf("%d\n",d);
	return 0;
}

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

struct UnionFind {
  vector<int> data;
  UnionFind(int size) : data(size, -1) { }
  bool unionSet(int x, int y) {
    x = root(x); y = root(y);
    if (x != y) {
      if (data[y] < data[x]) swap(x, y);
      data[x] += data[y]; data[y] = x;
    }
    return x != y;
  }
  bool findSet(int x, int y) {
    return root(x) == root(y);
  }
  int root(int x) {
    return data[x] < 0 ? x : data[x] = root(data[x]);
  }
  int size(int x) {
    return -data[root(x)];
  }
};

int main() {
    int N, M, K; cin >> N >> M >> K;
    UnionFind uf = UnionFind(N+1);
    vector<int> hoge(N+1, 1);
    for (int i = 0; i < M; i++) {
        int a, b; cin >> a >> b;
        uf.unionSet(a, b);
        hoge[a]++; hoge[b]++;
    }
    for (int i = 0; i < K; i++) {
        int c, d; cin >> c >> d;
        if (uf.findSet(c, d)) {
        hoge[c]++; hoge[d]++;
        }
    }
    for (int i = 1; i <= N; i++) {
        cout << uf.size(i) - hoge[i] << ' ';
    }
    cout << endl;
}


Measured memory_bytes: 1664
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;

class Main {
	public static void main(String[] args) throws IOException {
		
		//?????°?????????
		String[] str = new String[2];
		int[] Numbers = new int[2];
		
		//????????????
		BufferedReader br =
				new BufferedReader(new InputStreamReader(System.in));
		
		StringBuilder st = new StringBuilder();
		
        while(true){
            String line = br.readLine(); 
        	str = line.split(" ");
        	Numbers[0]=Integer.parseInt(str[0]);
        	Numbers[1]=Integer.parseInt(str[1]);
        	
        	 Arrays.sort(Numbers);
        	        	
            if(Numbers[0] == 0 && Numbers[1] == 0){
                break;
            }
       	 st.append(Numbers[0]).append(" ").append(Numbers[1]).append("\n");
            }
        
        System.out.print(st);
	}
}

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

int parse_formula(int &p, string &s);
int parse_term(int &p, string &s);
int parse_factor(int &p, string &s);
int parse_number(int &p, string &s);

int parse_formula(int &p, string &s){
    int n = s.length();
    if(p>=n or s[p]==')'){
        throw exception();
    }
    int res = parse_term(p, s);
    while(p<n and (s[p]=='+' or s[p]=='-')){
        int sign = (s[p]=='+')? 1: -1;
        res += sign*parse_term(++p, s);
    }
    if(p>=n or s[p]!=')'){
        throw exception();
    }
    p++;
    return res;
}
int parse_term(int &p, string &s){
    int n = s.length();
    int res = 1;
    while(1){
        res *= parse_factor(p, s);
        if(p>=n or s[p]==')' or s[p]!='*') break;
        p++;
    }
    return res;
}
int parse_factor(int &p, string &s){
    int n = s.length();
    int sign = 1;
    while(p<n and s[p]=='-'){
        sign *= -1;
        p++;
    }
    if(p>=n or !(s[p]=='(' or s[p]=='0' or s[p]=='1')){
        throw exception();
    }
    if(s[p]=='('){
        return sign * parse_formula(++p, s);
    }else{
        return sign * parse_number(p, s);
    }
}
int parse_number(int &p, string &s){
    int n = s.length();
    int res = 0;
    if(p>=n or !(s[p]=='0' or s[p]=='1')){
        throw exception();
    }
    bool leading_zero = s[p]=='0';
    int firstp = p;
    while(p<n and (s[p]=='0' or s[p]=='1')){
        res *= 2;
        res += s[p]-'0';
        p++;
    }
    if(leading_zero and p-firstp > 1){
        throw exception();
    }
    return res;
}

const string alphabet = "01+-*()=";

int main(){
    string s;
    cin >> s;
    vector<char> assign;
    for(char c: s){
        if(('a'<=c and c<='z') or ('A'<=c and c<='Z')){
            assign.push_back(c);
        }
    }
    sort(assign.begin(), assign.end());
    assign.erase(unique(assign.begin(), assign.end()), assign.end());
    while(assign.size() < alphabet.length()){
        assign.push_back('~');
    }
    int ans = 0;
    do{
        string t = s;
        for(int i=0; i<8; i++){
            for(int j=0; j<(int)t.length(); j++){
                if(t[j] == assign[i]){
                    t[j] = alphabet[i];
                }
            }
        }
        int poseq = -1;
        for(int i=0; i<(int)t.length(); i++){
            if(t[i] == '='){
                if(poseq == -1) poseq = i;
                else if(poseq > 0) poseq = -2;
            }
        }
        if(poseq < 0) continue;
        t[poseq] = ')';
        t.push_back(')');
        try{
            int p = 0;
            int ret1 = parse_formula(p, t);
            if(p != poseq+1) continue;
            int ret2 = parse_formula(p, t);
            if(p != (int)t.length()) continue;
            if(ret1 == ret2) ans++;
        }catch(exception){
            continue;
        }
    }while(next_permutation(assign.begin(), assign.end()));
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 3300
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <bitset>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <iostream>
#include <iomanip>
#include <string>
#include <chrono>
#include <random>
#include <cmath>
#include <cassert>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <functional>
#include <sstream>

using namespace std;


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

    int n;
    cin >> n;
    vector<pair<int,int>> A;
    vector<pair<int,int>> B;

    for (int i = 0; i < n; ++i) {
        int x, y;
        cin >> x >> y;
        A.emplace_back(x, y);
    }
    for (int i = 0; i < n; ++i) {
        int x, y;
        cin >> x >> y;
        B.emplace_back(x, y);
    }

    vector<vector<int>> graph(2 * n);
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < n; ++j) {
            if (A[i].first < B[j].first && A[i].second < B[j].second) {
                graph[i].push_back(j + n);
                graph[j + n].push_back(i);
            }
        }
    }

    vector<int> matchs(2 * n, -1);
    vector<int> visited(2 * n, -1);

    function<bool(int, int)> dfs = [&](int u, int f) -> bool {
        if (visited[u] == f) {
            return false;
        }

        visited[u] = f;

        for (auto v : graph[u]) {
            if (matchs[v] == -1 || dfs(matchs[v], f)) {
                matchs[v] = u;
                matchs[u] = v;
                return true;
            }
        }

        return false;
    };

    int res = 0;
    for (int i = 0; i < n; ++i) {
        if (matchs[i] == -1) {
            if (dfs(i, i)) {
                ++res;
            }
        }
    }

    cout << res << '\n';

    return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>
#include <functional>

using namespace std;

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}

typedef long long int64;
typedef pair<int, int> ii;
const int INF = 1 << 29;
const int MOD = 1e9 + 7;

const int N = 1e5 + 10;
int dp[N];

int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  vector<int> w(n), v(n);
  for (int i = 0; i < n; ++i) {
    scanf("%d%d", &w[i], &v[i]);
  }
  memset(dp, 255, sizeof(dp));
  dp[0] = 0;
  for (int i = 0; i < n; ++i) {
    for (int j = N - 1; j >= v[i]; --j) {
      if (dp[j - v[i]] >= 0 && dp[j - v[i]] + w[i] <= m) {
        if (dp[j] < 0 || dp[j] > dp[j - v[i]] + w[i]) {
          dp[j] = dp[j - v[i]] + w[i];
        }
      }
    }
  }
  int ret = 0;
  for (int i = N - 1; i >= 0; --i) {
    if (dp[i] >= 0) {
      ret = i;
      break;
    }
  }
  printf("%d\n", ret);
  return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#include <numeric>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define rep1(i,n) for (int i = 1; i <= n; ++i)
template<typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
const long long MOD = 1e9+7;
template<typename T> inline void add(T& a, T b) { a += b; if (a >= MOD) a -= MOD; }

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

  int N,D; cin >> N >> D;
  vector<vector<ll>> X(N, vector<ll>(D));
  rep(i, N) {
    rep(j, D) {
      cin >> X[i][j];
    }
  }

  int ans = 0;
  rep(i, N) {
    rep(j, N) {
      if(i >= j) continue;
      ll val = 0;
      rep(k, D) {
        val += (X[j][k] - X[i][k]) * (X[j][k] - X[i][k]);
      }

      bool add = false;
      for(ll k = 0; k <= val; ++k) {
        if(k * k == val) {
          add = true;
          break;
        }
      }
      ans += add;
    }
  }

  cout << ans << endl;
}


Measured memory_bytes: 256
#include<iomanip>
#include<limits>
#include<thread>
#include<utility>
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#include<cmath>
#include<numeric>
#include<cassert>
#include<random>
#include<chrono>
#include<unordered_map>
#include<fstream>
#include<list>
#include<functional>
#include<bitset>
#include<complex>
#include<tuple>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pi;
typedef pair<double,double> pd;
typedef pair<double,ll> pdl;
#define F first
#define S second
const ll E=1e18+7;
const ll MOD=1000000007;




int main(){
    map<ll,ll> M;
    for(int i=0;i<4;i++){
        ll a;
        cin>>a;
        M[a]++;
    }
    if(M.count(1) && M.count(9) && M.count(7) && M.count(4)){
        cout<<"YES"<<endl;
    }
    else{
        cout<<"NO"<<endl;
    }
    
    
    
    return 0;
}


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

#define DUMP(x) cerr << #x << "=" << x << endl
#define DUMP2(x, y) cerr<<"("<<#x<<", "<<#y<<") = ("<<x<<", "<<y<<")"<< endl
#define BINARY(x) static_cast<bitset<16> >(x)

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

#define in_range(x, y, w, h) (0<=(int)(x) && (int)(x)<(int)(w) && 0<=(int)(y) && (int)(y)<(int)(h))
#define ALL(a) (a).begin(),(a).end()

typedef long long ll;
const int INF   = 1e9;
const ll  INFLL = 1e18;
typedef pair<int, int> PII;
typedef vector<vector<int>> Graph;
int dx[4]={0, -1, 1, 0}, dy[4]={-1, 0, 0, 1};

int main()
{
    ios::sync_with_stdio(false);
    ll D, N; cin >> D >> N;

    ll num = 1;
    while (N) {
        ll tmp = num;
        bool ok = true;
        rep(i, D) {
            if (tmp%100 != 0) ok = false;
            tmp /= 100;
        }
        if (ok) {
            if (tmp%100 != 0) {
                N--;
                if (N == 0) {
                    cout << num << endl;
                    return 0;
                }
            }
        }
        num++;
    }
}



Measured memory_bytes: 256
import qualified Data.ByteString.Lazy.Char8 as B
import Data.List
import Data.Maybe
import qualified Data.Map.Strict as M

solve :: [Int] -> Int
solve ns =
  M.foldlWithKey' f 0 (foldr (M.alter af) M.empty ns)
  where
    f sum n size = sum + if size >= n then size - n else size
    af Nothing = Just 1
    af (Just x) = Just (x + 1)
  
main :: IO ()
main = putStrLn . show . solve .
       map (fst . fromJust . B.readInt) .
       tail . B.words =<< B.getContents


Measured memory_bytes: 16272
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define MOD 1000000007
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
  
int main()
{
  int N;
  cin >> N;
  vector<vector<int>> B(N,vector<int>(3));
  REP(i, N){
    REP(j, 3){
      cin >> B.at(i).at(j);
    }
  }
  int flag = 0;
  if(N==1){
    REP(i,N){
      if((B.at(i).at(1)+B.at(i).at(2))%2!=B.at(i).at(0)%2||abs(B.at(i).at(1)+B.at(i).at(2))>B.at(i).at(0)){
        flag = 1;
      }
    }
  }else{
    vector<vector<int>> A(N-1,vector<int>(3));
    REP(i,N-1){
      REP(j,3){
        A.at(i).at(j) = B.at(i+1).at(j)-B.at(i).at(j);
      }
    }
    REP(i,N-1){
      if(max(A.at(i).at(1)+A.at(i).at(2),-1*(A.at(i).at(1)+A.at(i).at(2)))%2!=A.at(i).at(0)%2||max(A.at(i).at(1),-1*A.at(i).at(1))+max(A.at(i).at(2),-1*A.at(i).at(2))>A.at(i).at(0)){
        flag = 1;
      }
    }
  }

  if(flag == 0){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 11136
#include<stdio.h>

int main(){
	char str[1005];
	int i,j,n=0,w=0,s=0,e=0,N=0;
	scanf("%s", str);
	for(i=0; str[i] != '\0'; i++) N++;
	for(j=0; j<N; j++){
			if(str[j] == 'N') n++;
			if(str[j] == 'S') s++;
			if(str[j] == 'W') w++;
			if(str[j] == 'E') e++;
	}
	//printf("%d\n",N);
	//printf("%d %d %d %d %s\n", n, s, w, e, str);

	if( ((n > 0 && s > 0) || n==s) && (( e>0 && w > 0 ) || e==w)) printf("Yes\n");
	else printf("No\n");
	return 0;
}

Measured memory_bytes: 128
import sys
input = sys.stdin.readline

class Unionfind:
    def __init__(self, n):
        self.par = [i for i in range(n)]
        self.size = [1 for _ in range(n)]
        self.rank = [0] * (n)
        
    def find(self, x):
        if self.par[x] == x:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]
          
    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x != y:
            if self.rank[x] < self.rank[y]:
                x, y = y, x
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1
            self.par[y] = x
            self.size[x] += self.size[y]
            
    def is_same(self, x, y):
        return self.find(x) == self.find(y)

n,m = map(int,input().split())
U = Unionfind(n+1)
pn = [0]+[int(i) for i in input().split()]
cnt = -1
for i in range(m):
  a,b = map(int,input().split())
  U.union(a,b)
for i,v in enumerate(pn):
  if U.is_same(i,v):
    cnt += 1
print(cnt)

Measured memory_bytes: 19440
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <bitset>
#include <cmath>
#include <string>
#include <iterator>
#define FI first
#define SE second
#define PF push_front
#define PB push_back
#define POF pop_front
#define POB pop_back
#define MA make_pair
#define ll long long
#define PA pair<int,int>
#define VE vector<int>
#define VP vector<pair<int,int> >
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ROF(i,a,b) for(int i=b-1;i>=a;i--)
#define YES(i) cout<<(i?"YES":"NO")<<endl
#define Yes(i) cout<<(i?"Yes":"No")<<endl
using namespace std;
//
const int INF=1e9+7;
const int mod=1e9+7;
//
bool check(int num){
  for(int i=2;i*i<=num;i++){
    if(num%i==0){
      return false;
    }
  }
  return true;
}
int main(){
  int N;
  cin>>N;
  VE V;
  V.PB(2);
  V.PB(7);
  V.PB(17);
  V.PB(37);
  V.PB(47);
  N-=5;
  int now=57;
  FOR(i,0,N){
    while(!check(now)){
      now+=10;
    }
    V.PB(now);
    now+=10;
  }
  FOR(i,0,(int)V.size()){
    if(i!=0){
      cout<<" ";
    }
    cout<<V[i];
  }
  cout<<endl;
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void){
	int n;
	scanf("%d", &n);
	int A[n];
	for(int i = 0; i < n; i++) scanf("%d", &A[i]);
	
	double A_1[n];

	for(int i = 0; i < n; i++) A_1[i] = 1.0 / A[i];
	double sum = 0;

	for(int i = 0; i < n; i++) sum += A_1[i];

	printf("%lf\n", 1.0 / sum);
	return 0;
}
	


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

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

  vector<string> name(n);
  vector<int> time(n);
  queue<pair<string, int>> que;
  for (int i = 0; i < n; i++) {
    cin >> name[i] >> time[i];
  }
  for (int i = 0; i < n; i++) {
    que.push(pair<string, int> (name[i], time[i]));
  }

  int t = 0;
  while (que.size() != 0) {
    if (que.front().second <= q) {
      t += que.front().second;
      cout << que.front().first << " " << t << endl;
      que.pop();
    }
    else {
      t += q;
      que.front().second -= q;
      que.push(pair<string, int> (que.front().first, que.front().second));
      que.pop();
    }
  }


}


Measured memory_bytes: 6556
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
#include <complex>
using namespace std;

using ll = long long;
using ull = uint64_t;
using P = pair<int, int>;
constexpr double EPS = 1e-9;
constexpr int INF = 1001001001;
constexpr int mod = 1000000007;
// constexpr int mod = 998244353;

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

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

    int n;
    string s;
    cin >> n >> s;
    deque<char> deq;
    int c = 0;
    for(int i = 0; i < n; ++i){
        if(s[i] == '(') deq.push_back(s[i]), ++c;
        else{
            if(deq.empty()){
                deq.push_front('(');
                deq.push_back(s[i]);
            }
            else{
                if(c > 0)   deq.push_back(s[i]), --c;
                else{
                    deq.push_front('(');
                    deq.push_back(s[i]);
                }
            }
        }
    }
    for(int i = 0; i < c; ++i)  deq.push_back(')');
    while(!deq.empty()){
        cout << deq.front();
        deq.pop_front();
    }
    cout << endl;
}

Measured memory_bytes: 3660
s = input()
t = input()

ls = len(s)
lt = len(t)

dp = [[0 for _ in range(lt + 1)] for __ in range(ls + 1)]

for ns in range(ls):
    for nt in range(lt):
        if s[ns] == t[nt]:
            dp[ns + 1][nt + 1] = max(dp[ns][nt] + 1, dp[ns + 1][nt + 1])
        dp[ns + 1][nt + 1] = max(dp[ns + 1][nt + 1], dp[ns + 1][nt], dp[ns][nt + 1])

ans = ''
i, j = ls, lt
while i > 0 and j > 0:
    if dp[i][j] == dp[i - 1][j]:
        i -= 1
    elif dp[i][j] == dp[i][j - 1]:
        j -= 1
    else:
        ans = s[i - 1] + ans
        i -= 1
        j -= 1
print(ans)


Measured memory_bytes: 120540
#include <iostream>

using namespace std;

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

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

    int bucket[101] = {0};
    for (int i = 0; i < n; i++) {
        bucket[d[i]]++;
    }

    int cnt = 0;
    for (int i = 1; i <= 100; i++) {
        if (bucket[i]) cnt++;
    }

    cout << cnt << endl;
}

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

using namespace std;

int main(void){
  char c;
  cin >> c;
  if( c=='a' || c=='i' || c=='u' || c=='e' || c=='o'){
    cout <<"vowel" << endl;
  }
  else{
    cout << "consonant" << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <algorithm>
#include <iomanip>
using namespace std;

long long int calc(long long int);

int main()
{
    //int m,n,o=100,i,j,k;
    long long int m,n,o=100,i,j,k;
    //float f,g,h;
    //char c,d;
    //string a;
    cin>>m;
    //cin>>m>>c>>n>>d>>i;
    //cin>>f>>g;
    //cin>>c;
    for(i=1;i<=m;i++)
    {
        if(i*i>m) break;
        if(m%i==0)
        {
            n=calc(m/i);
            o=min(n,o);
        }
    }
    cout<<o;
    return 0;
}

long long int calc(long long int x)
{
    int fx=0;
    do
    {
        fx++;
        x/=10;
    }while(x!=0);
    return fx;
}


Measured memory_bytes: 256
#pragma GCC optimize "O3"
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#define whole(f,x,...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x)
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define REP_FROM(i,m,n) for (int i = (m); (i) < int(n); ++(i))
#define REP_REV(i,n) for (int i = (n)-1; (i) >= 0; --(i))
#define REP_FROMREV(i,m,n) for (int i = (n)-1; (i) >= int(m); --(i))
#define CLR(a) memset((a), 0 ,sizeof(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#ifndef LOCAL
#define cerr if (false) cerr
#endif
using namespace std;
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
template<class T> inline T sqr(T x) {return x*x;}
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

template <class T> inline void setmax(T & a, T const & b) { a = max(a, b); }
template <class T> inline void setmin(T & a, T const & b) { a = min(a, b); }
template <class T> T sq(T x) { return x * x; }
template <class T> T clamp(T a, T l, T r) { return min(max(a, l), r); } // [l, r]
const double EPS = 1e-10;
const double PI  = acos(-1.0);

vector<bool> ptable;

void sieve(LL max) {
	if(max+1 > ptable.size())
		ptable.resize(max+1, true);

	ptable[0] = ptable[1] = false;

	for(LL i = 2; i*i <= max; i++)
		if(ptable[i])
			for(LL j = 2; i*j <= max; j++)
				ptable[i*j] = false;
}

int main(int argc, char *argv[]) {
	// Something to do
	sieve(1000000);
	int n;
	while(cin >> n) {
		int cnt = count(ptable.begin(), ptable.begin()+n+1, true);
		cout << cnt << endl;
	}
	return 0;
}

Measured memory_bytes: 3172
#include "bits/stdc++.h"
// Begin Header {{{
#define all(x)          (x).begin(), (x).end()
#define rep(i, n)       for (i64 i = 0, i##_limit = (n); i < i##_limit; ++i)
#define reps(i, s, t)   for (i64 i = (s), i##_limit = (t); i <= i##_limit; ++i)
#define repr(i, s, t)   for (i64 i = (s), i##_limit = (t); i >= i##_limit; --i)
#ifndef DBG
#define trace(...)
#endif
using namespace std;
using i64 = int_fast64_t;
using pii = pair<i64, i64>;
template <class T, class U> inline bool chmax(T &a, const U &b) { return b > a && (a = b, true); }
template <class T, class U> inline bool chmin(T &a, const U &b) { return b < a && (a = b, true); }
constexpr int INF  = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;

template <class T>
inline vector<T> make_v(const T &initValue, size_t sz) {
    return vector<T>(sz, initValue);
}

template <class T, class... Args>
inline auto make_v(const T &initValue, size_t sz, Args... args) {
    return vector<decltype(make_v<T>(initValue, args...))>(sz, make_v<T>(initValue, args...));
}

inline void read() {}

template <class Head, class... Tail>
inline void read(Head &head, Tail&... tail) { cin >> head; read(tail...); }

inline void print() { cout << "\n"; }

template <class Head, class... Tail>
inline void print(Head &&head, Tail&&... tail) {
    cout << head;
    if (sizeof...(tail)) cout << ' ';
    print(forward<Tail>(tail)...);
}

template <class T>
inline ostream& operator<< (ostream &out, const vector<T> &vec) {
    static constexpr const char *delim[] = { " ", "" };
    for (const auto &e : vec) out << e << delim[&e == &vec.back()];
    return out;
}
// }}} End Header

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

    int a, b, c;
    read(a, b, c);

    print(a * b / 2);

    return 0;
}


Measured memory_bytes: 256
N,M=map(int,input().split())

L=[0 for i in range(M+1)]

for i in range(N):
    s=list(map(int,input().split()))
    for j in range(1,len(s)):
        L[s[j]]+=1
        
ans=0
for i in range(len(L)):
    if L[i]==N:
        ans+=1
        
print(ans)

Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <string>
#include <cmath>
#include <iomanip>
#include <numeric>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> V;
typedef map<int, int> M;

int main()
{
    ll q, h, s, d, n, ans;
    cin >> q >> h >> s >> d >> n;
    n *= 4;

    ans = 0;

    if (n >= 8 && d < s * 2 && d < h * 4 && d < q * 8)
    {
        ans += (n / 8) * d;
        n %= 8;
    }

    if (n >= 4 && s < h * 2 && s < q * 4)
    {
        ans += (n / 4) * s;
        n %= 4;
    }

    if (n >= 2 && h < q * 2)
    {
        ans += (n / 2) * h;
        n %= 2;
    }

    ans += n * q;

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
from collections import Counter
N = int(input())
A = [int(input()) for _ in range(N)]
Ac = Counter(A)

s = []
for Ai in Ac:
    s.append((Ai, Ac[Ai]))

s = sorted(s, reverse=True)

for i in range(N):
    if A[i] == s[0][0] and s[0][1] <= 1:
        print(s[1][0])
    else:
        print(s[0][0])


Measured memory_bytes: 28148
#include <cstdio>
#include <cmath>
#include <algorithm>
using namespace std;

int main(){
	const int MAX_N = 1000;
	int N, W, H;
	int x[MAX_N], y[MAX_N];
	int dx, dy, res;
	
	scanf("%d%d%d", &W, &H, &N);
	for(int i = 0; i < N; i++){
		scanf("%d%d", &x[i], &y[i]);
	}
	
	res = 0;
	for(int i = 1; i < N; i++){
		dx = x[i] - x[i - 1];
		dy = y[i] - y[i - 1];
		if(dx * dy <= 0){
			res += abs(dx) + abs(dy);
		}
		else{
			res += max(abs(dx), abs(dy));
		}
	}
	
	printf("%d\n", res);
	
	return 0;
}

Measured memory_bytes: 1032