akhauriyash/Code-Regression huggingface dataset:
macro_rules! get {
    ($t:ty) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t:ty),*) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            (
                $(iter.next().unwrap().parse::<$t>().unwrap(),)*
            )
        }
    };
    ($t:ty; $n:expr) => {
        (0..$n).map(|_|
            get!($t)
        ).collect::<Vec<_>>()
    };
    ($($t:ty),*; $n:expr) => {
        (0..$n).map(|_|
            get!($($t),*)
        ).collect::<Vec<_>>()
    };
}

fn main() {
    let (a, b) = get!(usize, usize);
    println!("{}", (a+b)%24);
}

Measured memory_bytes: 4352
from math import floor

def recursive(H):
   # print(H)
   if(H == 1):
      return 1
   else:
      return recursive(floor(H/2))*2 + 1

def myAnswer(H:int) ->int:
   return (recursive(H))



def modelAnswer():
   tmp=1
def main():
   H = int(input())
   print(myAnswer(H))

if __name__ == '__main__':
   main()


Measured memory_bytes: 3060
#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
using namespace std;
// using namespace __gnu_pbds;
#define lli long long int
#define llu unsigned long long int
#define pb push_back
#define rt return 0
#define endln "\n"
#define all(x) x.begin(), x.end()
#define sz(x) (lli)(x.size())
const lli MOD = 1e9 + 7;
const double PI = 2 * acos(0.0);
// cout << fixed << setprecision(0) << pi <<endl;
// typedef tree<int, null_type, less<int>, rb_tree_tag,
//              tree_order_statistics_node_update>
//     new_data_set;
// for multiset
// typedef tree<int, null_type, less_equal<int>, rb_tree_tag,
//              tree_order_statistics_node_update>
//     new_data_set;
// order_of_key(val): returns the number of values less than val
// find_by_order(k): returns an iterator to the kth largest element (0-based)

void solve() {
    lli n, a, b, c, d;
    cin >> a >> b >> c >> d;
    lli ans = max({a * c, a * d, b * c, b * d});
    cout << ans << endl;
}

int main(void) {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    // lli t; cin >> t; while(t--)
    solve();
    rt;
}

Measured memory_bytes: 3648
//#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define trav(x,a) for (const auto& x: a)
#define sz(x) (int)(x).size()
#define mem(a,v) memset((a), (v), sizeof (a))
#define enl printf("\n")
#define case(t) printf("Case #%d: ", (t))
#define ni(n) scanf("%d", &(n))
#define nl(n) scanf("%lld", &(n))
#define nai(a, n) for (int _i = 0; _i < (n); _i++) ni(a[_i])
#define nal(a, n) for (int _i = 0; _i < (n); _i++) nl(a[_i])
#define pri(n) printf("%d\n", (n))
#define prl(n) printf("%lld\n", (n))
#define pii pair<int, int>
#define pll pair<long long, long long>
#define vii vector<pii>
#define vll vector<pll>
#define vi vector<int>
#define vl vector<long long>
#define pb push_back
#define mp make_pair
#define st first
#define nd second
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef cc_hash_table<int,int,hash<int>> ht;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> oset;
const double pi = acos(-1);
const int inf = 1e9 + 7;
const int N = 6e3 + 5;
const double eps = 1e-9;
int n, mod;
int add(int x, int y) { return x+y < mod ? x+y : x+y-mod; }
int mul(int x, int y) { return x*1ll*y % mod; }
int dp[N][2*N], fac[N];

int main() {
  scanf("%d %d", &n, &mod);
  dp[0][3*n] = 1;
  for (int i = 1; i <= 3*n; i++) {
    for (int j = 0; j <= 6*n; j++) {
      if (j > 0)
        dp[i][j] = add(dp[i-1][j-1], dp[i][j]);
      if (i > 1)
        dp[i][j] = add(dp[i][j], mul(dp[i-2][j+1], i-1));
      if (i > 2)
        dp[i][j] = add(dp[i][j], mul(dp[i-3][j], mul(i-1,i-2)));
    }
  }
  int ans = 0;
  for (int i = 3*n; i <= 6*n; i++)
    ans = add(ans, dp[3*n][i]);
  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 281728
#include <cmath>
#include <string>
#include <vector>
#include <iomanip>
#include <iostream>
#include <algorithm>
#include <functional>
using namespace std;
int A, B; string s;
int main() {
	cin >> A >> B >> s;
	bool ret = true;
	for (int i = 0; i < A + B + 1; i++) {
		if (i == A) {
			if (s[i] != '-') ret = false;
		}
		else {
			if (!('0' <= s[i] && s[i] <= '9')) ret = false;
		}
	}
	cout << (ret ? "Yes" : "No") << endl;
	return 0;
}

Measured memory_bytes: 256
A = [1,3,5,7,8,10,12]
B = [4,6,9,11]
C = [2]

x,y = map(int, input().split())

if (x in A and y in A) or (x in B and y in B) or (x in C and y in C):
	print('Yes')
else:
	print('No')

Measured memory_bytes: 3060
#12 B - Grid Compression
H,W = map(int,input().split())
a = [list(input()) for _ in range(H)]

i = 0
while i < len(a):
    if all(m == '.' for m in a[i]) :
        a.pop(i)
    else:
        i += 1
#加工したaにおけるHを保持しなおす
H_sc = len(a)
w = 0
while w < len(a[0]):
    cnt = 0
    for h in range(H_sc):
        if a[h][w] == '#':
            w += 1
            break
        else:
            cnt += 1
    if cnt == H_sc:
        for b in a:
            b.pop(w)
for g in a:
    print(''.join(g))

Measured memory_bytes: 9012
#include<bits/stdc++.h>
using namespace std;
#define js ios::sync_with_stdio(0);cin.tie(0);cout.tie(0); 
int main(){
	js;
	int n,x,t;
	cin>>n>>x>>t;
	if(n%x==0){
		cout<<t*(n/x);
	}else{
		cout<<t*(n/x)+t;
	}
	return 0;
} 

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

#define rp(i, k, n) for (int i = k; i < n; i++)
typedef long long ll;
typedef double ld;

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 (b<a) { a=b; return 1; } return 0; }
const ll INF = 1ll << 60;
const ll MOD = 1e9 + 7ll;
const double PI=3.14159265358979323846;

const int N_MAX = 3010;

int R, C, K;
vector<vector<int>> V(N_MAX, vector<int>(N_MAX));
vector<vector<vector<ll>>> dp(N_MAX, vector<vector<ll>>(N_MAX, vector<ll>(5)));

int main() {
    cin >> R >> C >> K;
    rp(i, 0, K) {
        int r, c, v;
        scanf("%d%d%d", &r, &c, &v);
        r--; c--;
        V[r][c] = v;
    }
    dp[R-1][C][4] = -INF;
    for(int i = R-1; i >= 0; i--) {
        for(int j = C-1; j >= 0; j--) {
            rp(k, 0, 4) {
                dp[i][j][k] = max(dp[i][j+1][k], dp[i][j+1][k+1] + V[i][j]);
                if(k == 3) chmax(dp[i][j][k], dp[i+1][j][0]);
                else chmax(dp[i][j][k], dp[i+1][j][0] + V[i][j]);
            }
            dp[i][j][4] = -INF;
        }
    }
    cout << dp[0][0][0] << endl;
    return 0;
}

Measured memory_bytes: 675988
using System;
using System.Linq;
using CompLib.Util;

public class Program
{

    public void Solve()
    {
        var sc = new Scanner();
        int x = sc.NextInt();

        int a = x / 500;
        x %= 500;
        int b = x / 5;
        Console.WriteLine((long)a*1000 + b * 5);
    }

    public static void Main(string[] args) => new Program().Solve();
}

namespace CompLib.Util
{
    using System;
    using System.Linq;

    class Scanner
    {
        private string[] _line;
        private int _index;
        private const char Separator = ' ';

        public Scanner()
        {
            _line = new string[0];
            _index = 0;
        }

        public string Next()
        {
            if (_index >= _line.Length)
            {
                string s;
                do
                {
                    s = Console.ReadLine();
                } while (s.Length == 0);

                _line = s.Split(Separator);
                _index = 0;
            }

            return _line[_index++];
        }

        public string ReadLine()
        {
            _index = _line.Length;
            return Console.ReadLine();
        }

        public int NextInt() => int.Parse(Next());
        public long NextLong() => long.Parse(Next());
        public double NextDouble() => double.Parse(Next());
        public decimal NextDecimal() => decimal.Parse(Next());
        public char NextChar() => Next()[0];
        public char[] NextCharArray() => Next().ToCharArray();

        public string[] Array()
        {
            string s = Console.ReadLine();
            _line = s.Length == 0 ? new string[0] : s.Split(Separator);
            _index = _line.Length;
            return _line;
        }

        public int[] IntArray() => Array().Select(int.Parse).ToArray();
        public long[] LongArray() => Array().Select(long.Parse).ToArray();
        public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
        public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
    }
}


Measured memory_bytes: 27388
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

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

		String str[] = br.readLine().split(" ");

		int a = Integer.parseInt(str[0]);
		int b = Integer.parseInt(str[1]);
		int c = Integer.parseInt(str[2]);
		int k = Integer.parseInt(str[3]);

		if (a >= k) {
			System.out.println(k);
		} else {
			if (a + b >= k) {
				System.out.println(a);
			} else {
				int n = a - (k - a - b);
				System.out.println(n);
			}
		}
	}
}


Measured memory_bytes: 32596
// inputに入力データ全体が入る
    function Main(inputString) {
    	let inputArray = inputString.split(" ");
    	//文字列から10進数に変換するときはparseIntを使います
    	let defaultNumber = parseInt(inputArray[0], 10);
        let baseNumber = parseInt(inputArray[1], 10);
        
        // m進数をn進数に変換するときはNumber.tostringを使います
        let resultNumber = Number(defaultNumber).toString(baseNumber);
        let digits = resultNumber.length
    	//出力
        console.log('%d', digits);
        
    }
        //*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
        Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
a,b,c=map(int,input().split())
L=[]
ans="NO"
for i in range(100):
    m=0
    m=a*(i+1)%b
    L.append(m)
    if m==c:
        ans="YES"
        break
    elif L.count(m)>1:
        break
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define int long long
#define Matrix vector<vector<int> >
// #define Matrix vector<vector<int> >
#define double long double
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define td(v) v.begin(),v.end()
#define tdr(v) v.rbegin(),v.rend()
#define endl "\n"
#define Matrix vector<vector<int> >
using namespace std;
const int MOD = 1e9+7;
const long long INF = 5e18;
const double pi = acos(-1.0);
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
int gcd(int a, int b){return (b == 0 ? a : gcd(b, a%b));}
int lcm(int a,int b){return (a*b)/gcd(a,b);}
 
inline long long mod(long long n, long long m){
    long long ret = n%m;
    if(ret < 0) ret += m;
    return ret;
}
 
double rad(double x){
    return x*pi/180.0;
}
 
bool isleft(pair<int,int> a, pair<int,int> b, pair<int,int> c){
    int det = (b.first-a.first)*(c.second-a.second) - (c.first-a.first)*(b.second-a.second);
    if(det>=0) return true;
    if(det<0) return false;
    return false;
}
 
int exp(int a, int b){
    int result = 1;
    while (b > 0){
        if (b & 1)
            result = mod(result*a,MOD);
 
        b >>= 1;
        a = mod(a*a,MOD);
    }
    return result;
}
bool ok(int n, vector<vector<int> >&adj){
    for(int i=0;i<adj.size();i++){
        bool ok = false;
        for(int &j : adj[i]){
            if((j|n)==n){
                ok=true;
            }
        }
        if(!ok) return false;
    }
    return true;
}
int memo[123456];
int v[123456];
int n;
int k;
int dp(int pos){
    if(pos>n) return INF;
    if(pos==n) return 0;
    int &ans = memo[pos];
    if(ans!=-1) return ans;
    ans = INF;
    for(int i=1;i<=k;i++){
        ans = min(ans, abs(v[pos]-v[pos+i])+dp(pos+i));
    }
    return ans;
}
void solve(){
    memset(memo,-1,sizeof(memo));
    cin>>n>>k;
    for(int i=1;i<=n;i++){
        cin>>v[i];
    }
    cout<<dp(1)<<endl;
}
 
signed main(){
    fastio;
    int t=1;
    // cin>>t;
    while(t--)
        solve();
}

Measured memory_bytes: 11596
#include <bits/stdc++.h>
#define l_ength size
const int inf = (1<<30);
const int mod = 1000003;
using ll = long long;
using namespace std;

ll modPow(ll a, int n){
	ll res = 1;
	int i = 1;
	while( i <= n ) {
		if( n & i ){
			res *= a;
			res %= mod;
		}
		i <<= 1;
		a = a*a%mod;
	}
	return res;
}

ll mf[3000100];
ll dvf[3000100];

int main(){
	int q; cin >> q;
	mf[0] = 1; dvf[0] = 1;
	for( int k = 1; k <= 3000000; ++k ){
		mf[k] = (k*mf[k-1]) % mod;
		dvf[k] = (modPow(k, mod-2)*dvf[k-1]) % mod;
	}
	while( q-- ){
		ll x, d, n; cin >> x >> d >> n;
		if( d != 1 ){
			if( d == 0 ){
				cout << modPow(x, n) << endl;
				continue;
			}
			x = (x*modPow(d, mod-2))%mod;
		}
		if( n >= mod ) cout << 0 << endl;
		else cout << ( modPow(d, n) * ( mf[x+n-1]*dvf[x-1] % mod ) ) % mod << endl;
	}
	return 0;
}

Measured memory_bytes: 47744
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<stdint.h>
#include<stdbool.h>
#include<tgmath.h>
#include<time.h>
#define ll long long
#define min(a,b) ((a)>(b)?(b):(a))
#define max(a,b) ((a)>(b)?(a):(b))
#define miin(a,b,c) min((a), min((b), (c)))
#define maax(a,b,c) max((a), max((b), (c)))

int n, x, y, b[2222] = {};

main(){
    scanf("%d%d%d",&n, &x, &y);x--;y--;
    for(int i=0; i<n; i++){
        for(int j=i+1; j<n; j++){
            int d = min(j-i, abs(x-i)+abs(y-j)+1);
            //printf("%d: %d, %d\n", d, i, j);
            b[d]++;
        }
    }
    for(int i=1; i<n; i++){
        printf("%d\n", b[i]);
    }
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int main() {
	//input
	int64_t N;
	cin >> N;

	map<int64_t, int64_t> Ap;
	map<int64_t, int64_t> Am;

	for (int64_t i = 0; i < N; i++) {
		int64_t temp;
		cin >> temp;
		if (Ap.count(i + temp)) {
			Ap[i + temp]++;
		} else {
			Ap[i + temp] = 1;
		}
		if (Am.count(i - temp)) {
			Am[i - temp]++;
		} else {
			Am[i - temp] = 1;
		}
	}

	//calculation
	int64_t output = 0;
	for (auto p : Ap) {
		auto key = p.first;
		auto value = p.second;
		if (Am.count(key)) {
			output += value * Am[key];
		}
	}

	//output
	cout << output << endl;


	return 0;
}


Measured memory_bytes: 26564
#include <bits/stdc++.h>
using namespace std;
#define modulo 1000000007
#define mod(mod_x) ((((long long)mod_x+modulo))%modulo)
#define Inf 1000000000

int main(){
	
	int N;
	cin>>N;
	
	vector<int> A(N),B(N);
	
	for(int i=0;i<N;i++){
		cin>>A[i];
	}
	
	for(int i=0;i<N;i++){
		cin>>B[i];
	}
	
	int ans = Inf;
	
	for(int i=0;i<(1<<N);i++){
		vector<int> C;
		for(int j=0;j<N;j++){
			if((1<<j)&i)C.push_back(B[j]);
			else C.push_back(A[j]);
		}
		
		sort(C.begin(),C.end());
		
/*
		for(int j=0;j<C.size();j++){
			cout<<C[j]<<',';
		}
		cout<<endl;
	*/	
		vector<bool> used(N,false);
		
		vector<int> ind;
		
		for(int j=0;j<N;j++){
			for(int k=0;k<N;k++){
				if(used[k])continue;
				if((1<<k)&i){
					if((abs(j-k)%2==1)&&B[k] == C[j]){
						used[k] = true;
						ind.push_back(k);
						break;
					}
				}
				else{
					if((abs(j-k)%2==0)&&A[k] == C[j]){
						used[k] = true;
						ind.push_back(k);
						break;
					}
				}
			}
		}
		
		
		if(ind.size()!=N)continue;
		int tmp = 0;
		for(int j=0;j<N;j++){
			for(int k=0;k<j;k++){
				if(ind[k] > ind[j])tmp++;
			}
		}
		
		//if(i==0)cout<<tmp<<endl;
		
		ans = min(ans,tmp);
		
	}
	if(ans == Inf)cout<<-1<<endl;
	else cout<<ans<<endl;
	
	return 0;
}


Measured memory_bytes: 256
//////////////////////////////////
// Created By Piyush Lakhotiya 
//////////////////////////////////
#include<bits/stdc++.h>
#define ll long long
#define endl "\n"

#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);

#define vi vector<int>
#define vl vector<ll>
#define mi map<int,int>
#define pi pair<int,int>

#define For(i,a,b) for(int i=a; i<b; i++)

#define pb push_back
#define mp make_pair

#define read(a, n) for(int i=0; i<n; i++) cin >> a[i];
#define print(x) cout << "X: == " << x << endl;
#define printMap(a) for(auto it=a.begin() ; it!= a.end() ; it++) {cout << it->first << "  " << it->second << endl; }
#define printVector(a) for(auto it = a.begin() ; it!= a.end() ;it++) {cout << *it << endl;}

using namespace std;
int main() {
    IOS
    int n;
    cin >> n;
    int last = n % 10;
    if(last == 2 || last == 4 || last == 5 || last == 7 || last == 9 ) {
        cout << "hon\n";
    } else if(last == 0 || last == 1 || last == 6 || last == 8) {
        cout << "pon\n";
    } else{
        cout << "bon\n";
    }
    return 0;
} 

Measured memory_bytes: 3600
#include <iostream>
#include <map>
#include <vector>

int main() {
  using i64 = long long;
  int n, k;
  std::cin >> n >> k;
  static constexpr i64 mod = 1000000007;
  std::map<int, int> mp;
  for (int i = 1; i * i <= n; i += 1) {
    mp[i];
    mp[n / i];
  }
  {
    int c = 0;
    for (auto &e : mp)
      e.second = c++;
  }
  std::vector<i64> dp(mp.size(), 1);
  for (int l = 0; l != k; l += 1) {
    std::vector<i64> nx(dp.size(), 0);
    int prev = 0;
    for (const auto &e : mp) {
      nx[e.second] = dp[mp[n / e.first]] * (e.first - prev) % mod;
      prev = e.first;
    }
    dp = std::move(nx);
    for (int i = 1; i != dp.size(); i += 1) {
      dp[i] = (dp[i] + dp[i - 1]) % mod;
    }
  }
  std::cout << dp.back() << std::endl;
}

Measured memory_bytes: 4256
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <deque>
#include <fstream>
#include <functional>
#include <iostream>
#include <istream>
#include <iterator>
#include <sstream>
#include <list>
#include <map>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iomanip>
#define BR "\n"
#define REP(i,n) for(int (i)=0;(i)<(n);++(i))
#define ALL(cont) begin(cont),end(cont)
#define AS_MOD(a,b) ((((a) % (b) ) + (b)) % (b))
#define FEACH(it,cont) for(auto (it) = begin(cont); it!=end(cont);++it)
#define FEACHR(it,cont) for(auto (it) = rbegin(cont); it!=rend(cont);++it)
#define pb push_back
#define pob pop_back
#define fi first
#define se second
#define getll() ([](){ll s;scanf("%lld", &s);return s;})()
#define getld() ([](){ld s;scanf("%Lf", &s);return s;})()
#define prl(P) printf("%lld", P)
#define prd(P) printf("%.10Lf", P)
#define pr(P) printf(P)
#define MAX(V, T) V=max(V,T)

#define DumpArray(cont,from,to) for(int __i=from;__i<to;++__i) {cout<<"(" <<__i<<": " << cont[__i]<<")";} cout<<endl;

using namespace std;
typedef long long ll;
typedef long double ld;
ll N;
int main() {
    cin >>N;
    ll ans=0;
    for(ll i=1;i*i<=N;++i) {
        if (N%i!=0)continue;
        ll x=i;
        ll m=N/x-1;
        if (x<m) {
            ans+=m;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cmath>
#include<vector>
using namespace std;
#define EPS (1e-10)
#define equals(a, b) (fabs(a-b)<EPS)

struct Point
{
    double x, y;
    Point(double x=0, double y=0):x(x), y(y){}
};
typedef Point Vector;

struct Segment{ Point p1, p2; };
typedef Segment Line;

class Circle
{
public:
    Point c;
    double r;
    Circle(Point c=Point(), double r=0.0):c(c), r(r){}
};

typedef vector<Point> Polygon;

Point operator + (Point a, Point b){ return Point(a.x+b.x, a.y+b.y); }
Point operator - (Point a, Point b){ return Point(a.x-b.x, a.y-b.y); }
Point operator * (Point a, double p){ return  Point(a.x*p, a.y*p); }
Point operator / (Point a, double p){ return Point(a.x/p, a.y/p); }

double norm(Vector a){ return a.x*a.x+a.y*a.y; }
double abs(Vector a){ return sqrt(norm(a)); }
double dot(Vector a, Vector b){ return a.x*b.x+a.y*b.y; }
double cross(Vector a, Vector b){ return a.x*b.y-a.y*b.x; }

bool isOrthgonal(Vector a, Vector b){ return equals(dot(a, b), 0.0); }
bool isOrthgonal(Point a1, Point a2, Point b1, Point b2){ return isOrthgonal(a1-a2, b1-b2); }
bool isOrthgonal(Segment s1, Segment s2){ return equals(dot(s1.p2-s1.p1, s2.p2-s2.p1), 0.0); }

bool isParallel(Vector a, Vector b){ return equals(cross(a, b), 0.0); }
bool isParallel(Point a1, Point a2, Point b1, Point b2){ return isParallel(a1-a2, b1-b2); }
bool isParallel(Segment s1, Segment s2){ return equals(cross(s1.p2-s1.p1, s2.p2-s2.p1), 0.0); }

Point project(Segment s, Point p)
{
    Vector base=s.p2-s.p1;
    double r=dot(p-s.p1, base)/norm(base);
    return s.p1+base*r;
}

int main()
{
    Segment T;
    int q;
    scanf("%lf%lf%lf%lf", &T.p1.x, &T.p1.y, &T.p2.x, &T.p2.y);
    scanf("%d", &q);
    while(q--)
    {
        Point s;
        scanf("%lf%lf", &s.x, &s.y);
        printf("%.10lf %.10lf\n", project(T, s).x, project(T, s).y);
    }
    return 0;
}

Measured memory_bytes: 2756
using System;

class A
{
	static void Main()
	{
		var h = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
		Console.WriteLine((h[0] + h[1]).CompareTo(h[2] + h[3]) switch { 1 => "Left", 0 => "Balanced", -1 => "Right" });
	}
}


Measured memory_bytes: 27436
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <bitset>
#include <string>
#include <cmath>
#include <complex>
#include <numeric>
#include <cassert>

#include <vector>
#include <array>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <utility>

#define PI 3.14159265358979323846
#define int64 long long
#define uint64 unsigned long long
#define coutfix(i) cout << fixed << setprecision(i)		//coutの浮動小数出力の桁数設定
using namespace std;

int main()
{
	int64 nn, ans = 0;
	cin >> nn;
	vector<int64> ll(nn);
	for(int64 ii = 0;ii < nn;ii++)
	{
		cin >> ll[ii];
	}
	sort(ll.begin(), ll.end());
	for(int64 ii = 0;ii < nn;ii++)
	{
		for(int64 jj = ii + 1;jj < nn;jj++)
		{
			for(int64 kk = jj + 1;kk < nn;kk++)
			{
				if(ll[ii] + ll[jj] > ll[kk])
				{
					if(ll[ii] != ll[jj] && ll[jj] != ll[kk] && ll[kk] != ll[ii])
					{
						ans++;
					}
				}
				else
				{
					break;
				}
			}
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3628
#include<iostream>

int main(){
    long long H, W;
    std::cin >> H >> W;
    long long H_2, W_2;
    H_2 = (H % 2) ? H - 1 : H;
    W_2 = (W % 2) ? W - 1 : W;
    long long ans = H_2 * W_2 / 2;
    if(H % 2){
        ans += W_2 / 2;
    }
    if(W % 2){
        ans += H_2 / 2;
    }
    if((H % 2) && (W % 2)){
        ans++;
    }
    if(H == 1 || W == 1){
        ans = 1;
    }
    std::cout << ans << std::endl;
    
}


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

#define REP(i, n) for (int i = 0; i < n; i++)
#define ALL(obj) obj.begin(), obj.end()
#define fcout cout << setprecision(10)

const int iINF = 1e9;
const long long llINF = 1e18;
const int MOD = 1e9 + 7;

using namespace std;

template <typename T>
void debug(vector<T> &vec) {
    for (auto x : vec) {
        cout << x << " ";
    }
    cout << endl;
    return;
}

template <typename A, size_t N, typename T>
void FILL(A (&array)[N], const T &val) {
    std::fill((T *)array, (T *)(array + N), val);
}

template <typename T>
int getFormer(const vector<T> &vec, T x) {
    return upper_bound(vec.begin(), vec.end(), x) - vec.begin() - 1;
}

template <typename T>
int getLatter(const vector<T> &vec, T x) {
    return lower_bound(vec.begin(), vec.end(), x) - vec.begin();
}

int n, m, b[510], dp[2][(1 << 23)];
string s[510];
bool odd[510];
void solve(int n, int m) {
    FILL(b, 0);
    for (int i = 0; i < n; i++) {
        cin >> s[i];
        for (int j = 0; j < m; j++) {
            if (s[i][j] == '0') continue;
            b[i] |= (1 << j);
        }
    }

    if (n <= 20) {
        int ans = 0;
        for (int S = 0; S < (1 << n); S++) {
            FILL(odd, false);
            int cnt = 0;
            for (int i = 0; i < n; i++) {
                if ((S >> i) & 1) {
                    for (int j = 0; j < m; j++) {
                        if (s[i][j] == '0') continue;
                        odd[j] = !odd[j];
                    }
                    cnt += 1;
                }
            }

            if (accumulate(odd, odd + m, 0)) continue;
            ans = max(ans, cnt);
        }

        cout << ans << endl;
    } else {
        FILL(dp, -1);
        dp[0][0] = 0;
        int ans = 0;
        for (int i = 0; i < n; i++) {
            int now = i % 2;
            for (int S = 0; S < (1 << m); S++) {
                if (dp[now][S] == -1) continue;
                int next = S ^ b[i];
                dp[now ^ 1][S] = max(dp[now ^ 1][S], dp[now][S]);
                dp[now ^ 1][next] = max(dp[now ^ 1][next], dp[now][S] + 1);
                if (next == 0) ans = max(ans, dp[now ^ 1][next]);
                if (S == 0) ans = max(ans, dp[now ^ 1][S]);
            }
            for (int S = 0; S < (1 << m); S++) {
                dp[now][S] = -1;
            }
        }

        cout << ans << endl;
    }
}

int main() {
    int n, m;
    while (cin >> n >> m && n) {
        solve(n, m);
    }
    return 0;
}


Measured memory_bytes: 68760
#include<bits/stdc++.h>
using namespace std;
#define inf 1000000000
#define INF 1000000000000000
#define ll long long
#define ull unsigned long long
#define M (int)(1e9+7)
#define P pair<int,int>
#define PLL pair<ll,ll>
#define FOR(i,m,n) for(int i=(int)m;i<(int)n;i++)
#define RFOR(i,m,n) for(int i=(int)m;i>=(int)n;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,n,0)
#define all(a) a.begin(),a.end()
#define IN(a,n) rep(i,n){ cin>>a[i]; }
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define PI 3.14159265
#define F first
#define S second
#define PB push_back
#define EB emplace_back
void init(){
  cin.tie(0);
  ios::sync_with_stdio(false);
}


string s;

int main(){
  cin>>s;
  cout<<2*min(count(all(s),'0'),count(all(s),'1'))<<endl;
}


Measured memory_bytes: 512
# coding: utf-8

def div2count(num:int):
    count = 0
    while num % 2 == 0:
        count += 1
        num = int(num/2)
    return count


n = int(input().rstrip())
ans = min([div2count(int(i)) for i in input().rstrip().split(" ")])

print(ans)

Measured memory_bytes: 2940
//Compiler optimization
#pragma GCC optimize("Ofast")

//include
#include <bits/stdc++.h>
using namespace std;

//typedef
typedef long long ll;
typedef double db;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<string> vs;
typedef vector<char> vc;
typedef string S;
typedef queue<int> qi;
typedef pair<ll,ll> P;
typedef vector<P> vp;
typedef vector<vl> mat;

//macro
#define reverse(a) reverse(a.begin(),a.end())
#define unique(a) a.erase(unique(a.begin(),a.end()),a.end())
#define fr(i,n)for(ll i=0;i<(n);i++)
#define ifr(i,n)for(ll i=(n)-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define each(x, v) for (auto &x : v)

//abbreviation
#define pb push_back
#define elif else if
#define mp make_pair
#define endl '\n'

//debug
#define debug(x) cerr << #x << ": " << x << endl
#define v_debug(v) cerr << #v << endl;fr(i,v.size()) cerr << i << ": " << v[i] << endl

//const
const  ll INF = 1e18;
ll R,C,K;
ll Data[3010][3010];
ll ans[3010][3010][4];
int main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << setprecision(20);
    cin >> R >> C >> K;
    fr(i,R){
        fr(j,C)Data[i][j] = 0;
    }
    fr(i,K){
        ll r,c,v;
        cin >> r >> c >> v;
        Data[r-1][c-1] = v;
    }
    fr(i,R){
        fr(j,C){
            fr(k,4)ans[i][j][k] = -1;
        }
    }
    queue<tuple<ll,ll,ll>> que;
    if(Data[0][0]){
        ans[0][0][1] = Data[0][0];
        que.push(make_tuple(0,0,1));
    }
    ans[0][0][0] = 0;
    que.push(make_tuple(0,0,0));
    ll i,j,now;
    tuple<ll,ll,ll> mo;
    while(!que.empty()){
        mo = que.front();que.pop();
        i = get<0>(mo);
        j = get<1>(mo);
        now = get<2>(mo);
        if(i < R-1){
            if(Data[i+1][j]){
                if(ans[i+1][j][1] == -1)que.push(make_tuple(i+1,j,1));
                ans[i+1][j][1] = max(ans[i+1][j][1],max(ans[i][j][0],max(ans[i][j][1],max(ans[i][j][2],ans[i][j][3])))+Data[i+1][j]);
            }
            if(ans[i+1][j][0] == -1)que.push(make_tuple(i+1,j,0));
            ans[i+1][j][0] = max(ans[i+1][j][0],max(ans[i][j][0],max(ans[i][j][1],max(ans[i][j][2],ans[i][j][3]))));
        }
        if(j < C-1){
            if(Data[i][j+1] and now<=2){
                if(ans[i][j+1][now+1] == -1)que.push(make_tuple(i,j+1,now+1));
                ans[i][j+1][now+1] = max(ans[i][j+1][now+1],ans[i][j][now]+Data[i][j+1]);
            }
            if(ans[i][j+1][now] == -1)que.push(make_tuple(i,j+1,now));
            ans[i][j+1][now] = max(ans[i][j][now],ans[i][j+1][now]);
        }
    }
    ll res = 0;
    fr(i,4)res = max(res,ans[R-1][C-1][i]);
    cout << res << endl;
}

Measured memory_bytes: 356640
N = int(input())
cards = list()
suit = ['S', 'H', 'C', 'D']
for i in range(N):
    s, r = input().split()
    r = int(r)
    if s == 'S':
        cards.append(0 + r)
    elif s == 'H':
        cards.append(13 + r)
    elif s == 'C':
        cards.append(26 + r)
    elif s == 'D':
        cards.append(39 + r)

for i in range(1, 53):
    if i not in cards:
        print(suit[int((i-1)/13)], (i-1)%13 + 1)


Measured memory_bytes: 5612
n = int(input())
while (n != 0):
    e_ab = {}
    for i in range(n):
        e,a,b = map(int, input().split())
        ab = a*b
        if (e not in e_ab.keys()):
            e_ab[e] = ab
        else:
            e_ab[e] += ab
    c = 0
    for e,ab in e_ab.items():
        if (ab >= 10**6):
            c += 1
            print(e)
    if (c == 0):
        print('NA')
    
    n = int(input())


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

using ll = long long;
template <typename T> constexpr T inf = numeric_limits<T>::has_infinity ? numeric_limits<T>::infinity() : numeric_limits<T>::max() / 4;

#define REP(i, stop) FOR(i, 0, stop)
#define FOR(i, start, stop) for (ll i = start, i##_len = stop; i < i##_len; ++i)
#define RREP(i, n) for (ll i = n; i-- > 0;)
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define COMP(key) [](const auto& a, const auto& b) { return a.key < b.key; }

template<typename T, typename U> istream& operator>>(istream& is, pair<T, U>& a) { return is >> a.first >> a.second; }
template<typename T> istream& operator>>(istream& is, vector<T>& a) { for (T& x : a) is >> x; return is; }

template<typename T> using pop_max = std::priority_queue<T>;
template<typename T> using pop_min = std::priority_queue<T, std::vector<T>, std::greater<T>>;

template<typename T> void LOG(const T& x) { cerr << x << "\n"; }
template<typename T> void LOG(const vector<T>& a) { for (const T& x : a) cerr << x << " "; cerr << "\n"; }
template<typename T> void LOG(const vector<vector<T>>& a) { for (const auto& x : a) LOG(x); }
template<typename T, std::size_t S> void LOG(const T (&a)[S]) { REP(i, S) cerr << a[i] << " "; cerr << "\n"; }
template<typename T, std::size_t S, std::size_t R> void LOG(const T (&a)[S][R]) { REP(i, S) { REP(j, R) cerr << a[i][j] << " "; cerr << "\n"; } }

ll ceil(ll a, ll b) { return a > 0 ? (a - 1) / b + 1 : a / b; }
ll gcd(ll a, ll b) { while (b != 0) { ll t = b; b = a % b; a = t; } return a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
ll gcd(const vector<ll>& v) { return accumulate(v.begin(), v.end(), 1LL, static_cast<ll(*)(ll, ll)>(gcd)); }
ll lcm(const vector<ll>& v) { return v.empty() ? 0LL : accumulate(v.begin() + 1, v.end(), v[0], static_cast<ll(*)(ll, ll)>(lcm)); }
ll pow(ll x, ll y, ll z) { ll a = 1; while (y > 0) { if (y & 1) a = a * x % z; x = x * x % z; y /= 2; } return a; }
ll inv(ll x, ll m) { return pow(x, m - 2, m); }

template<typename T> bool chmax(T& x, const T& y) { return x < y ? x = y, true : false; }
template<typename T> bool chmin(T& x, const T& y) { return x > y ? x = y, true : false; }

struct InitCpp { InitCpp() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(10); } } init_cpp;

const ll INF = inf<ll>;
using P = pair<ll, ll>;
//const ll M = 1000000007;
const ll M = 998244353;
ll dp[3010][3010][3];
signed main() {
    ll n,s;
    cin>>n>>s;
    vector<ll> A(n);
    cin>>A;
    dp[0][0][0]=1;
    for(ll i=0;i<n;i++){
        for(ll v=0;v<=s;v++){
            dp[i+1][v][0]=dp[i][v][0];
            dp[i+1][v][1]
                =(v-A[i]>=0?dp[i][v-A[i]][0]*(i+1):0)
                +dp[i][v][1]
                +(v-A[i]>=0?dp[i][v-A[i]][1]:0);
            dp[i+1][v][2]
                =(v-A[i]>=0?dp[i][v-A[i]][0]*(i+1)*(n-i):0)
                +(v-A[i]>=0?dp[i][v-A[i]][1]*(n-i):0)
                +dp[i][v][2];
            dp[i+1][v][0]%=M;
            dp[i+1][v][1]%=M;
            dp[i+1][v][2]%=M;
        }
    }
    cout<<dp[n][s][2]<<endl;
}


Measured memory_bytes: 211968
s = input()
s = s.replace("BC", "O")
s = s.replace("B", "X")
s = s.replace("C", "X")
a = 0
res = 0
for ch in s:
    if ch == "A":
        a += 1
    elif ch == "X":
        a = 0
    else:
        res += a

print(res)

Measured memory_bytes: 3500
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long ll;
typedef pair<ll,ll> P;
const ll mod=1000000007;
const ll LINF=1LL<<60;
const int INF=1<<30;
vector<vector<int>> g(10005);
vector<int> c;
vector<int> ans(10005);

ll dfs(int x,int parent){
	ll res = 0LL;
	for(int i = 0; i < g[x].size(); i++) {
		if (g[x][i] != parent){
			res += dfs(g[x][i],x);
			res += min(ans[x],ans[g[x][i]]);
		}
	}
	return res;
}


int main(){
	int n;cin>>n;
	for(int i = 0; i < n - 1; i++) {
		int a,b;cin>>a>>b;
		g[a].pb(b);
		g[b].pb(a);
	}
	for(int i = 0; i < n; i++) {
		int l;cin>>l;
		c.pb(l);
	}
	sort(ALL(c),greater<int>());

	queue<int> q;
	q.push(1);
	int cnt = 0;
	int parent = 0;
	vector<bool> used(n + 1,false);
	while(!(q.empty())){
		int top = q.front();
		ans[top] = c[cnt];
		used[top] = true;
		cnt++;
		q.pop();
		for(int i = 0; i < g[top].size(); i++) {
			if (!(used[g[top][i]])){
				q.push(g[top][i]);
			}
		}
	}

	cout << dfs(1,0) << endl;
	for(int i = 1; i <= n; i++) {
		cout << ans[i] << " ";
	}
	return 0;
}

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

ll N;
vector<ll> C, S, F;

ll dfs(ll stat, ll time){
    if(stat == N-1) return time;
    if(time < S[stat]) time = S[stat];
    if(time % F[stat] != 0) time += F[stat] - time%F[stat];
    return dfs(stat+1, time+C[stat]);
}

int main(){
    cin >> N;
    C.resize(N); S.resize(N); F.resize(N);
    rep(i, 0, N-1) cin >> C[i] >> S[i] >> F[i];

    rep(i, 0, N){
        cout << dfs(i, 0) << endl;
    }
    return 0;
}

Measured memory_bytes: 256
import java.util.*;
 
public class Main{
 
    public static void main(String[] args) {
 
        Scanner scan = new Scanner(System.in);
         Dice3 di3 = new Dice3();       //Dice3のインスタンス
 
        int n = scan.nextInt();     //回数n
 
        int[] dice1 = new int[6];       //dice1作成
        for(int i=0; i<6; i++) {
            dice1[i] = scan.nextInt();
        }
 
        int[] answer2 = new int[6];     //確認した後の配列
        boolean flag = false;           //最終判定
 
        int[] dice2 = new int[6];       //dice2作成
 
        //n-1回サイコロを作成し確認
        for(int i=0; i<n-1; i++) {
 
            for(int j=0; j<6; j++) {
                dice2[j] = scan.nextInt();
            }
 
 
            answer2 = di3.check(dice1, dice2);      //総当たりで確認
 
 
            if(Arrays.equals(dice1, answer2)) {
                flag = true;
                break;
            }
        }
 
        if(flag) {      //既に算出済み
            System.out.println("No");
        }else
            System.out.println("Yes");
    }
}
 
 
 
class Dice3{
    static int top = 0;
    static int side1 = 0;
     
    static int[] answer = new int[6]; //動かすサイコロの形
 
    //command（特定の文字が入力された際、その方向に転がす）
    int[] command(int[] dice, char com) {
            top = dice[0];  //dice[0]を覚えておく
            side1 = dice[1];    //dice[1]を覚えておく
 
            switch (com) {
 
            case 'N':
                dice[0] = dice[1];
                dice[1] = dice[5];
                dice[5] = dice[4];
                dice[4] = top;
                break;
 
            case 'W':
                dice[0] = dice[2];
                dice[2] = dice[5];
                dice[5] = dice[3];
                dice[3] = top;
                break;
 
 
            case 'R':
                dice[1] = dice[3];
                dice[3] = dice[4];
                dice[4] = dice[2];
                dice[2] = side1;
                break;
            }
        return dice;        //配列を返す
     }
 
 
    //check（全ての面で配列d2を横回転させ配列d１と比較）
    int[] check(int[] d1 ,int[] d2) {
 
        //N方向回転
        for(int k=0; k<4; k++) {
 
            if(Arrays.equals(d1, answer)) {     //配列の比較はArraysから
                break;
            }
            answer = command(d2, 'N');
 
            //横回転
            for(int l=0; l<4; l++) {
 
                if(Arrays.equals(d1, answer)) {
                    break;
                }
                answer = command(d2, 'R');
            }
        }
 
        //W方向回転
        for(int k=0; k<4; k++) {
 
            if(Arrays.equals(d1, answer)){
                break;
            }
            answer = command(d2, 'W');
 
            //横回転
            for(int l=0; l<4; l++) {
 
                if(Arrays.equals(d1, answer)) {
                    break;
                }
                answer = command(d2, 'R');
            }
        }
        return answer;
    }
}



Measured memory_bytes: 27756
////////////////////////// Author
////////////////////////// Nasim Hossain Rabbi
////////////////////////// JU-CSE28
////////////////////////// CF - imnasim3.1415
////////////////////////// UVA - imnasim3.1415
////////////////////////// Mail - imnasim3.1415@gmail.com
#include<bits/stdc++.h>
using namespace std;
#define E end()
#define B begin()
#define sz size()
#define EM empty()
#define fi first
#define se second
#define cl clear()
#define sqr(a) (a*a)
#define mk make_pair
#define po pop()
#define pu push
#define pb push_back
#define pf push_front
#define pob pop_back()
#define pof pop_front()
string en="\n";
string sp=" ";
string t="hello";
string Y="YES\n";
string N="NO\n";
#define rep(i,n) for(i=0;i<n;i++)
#define Rep(i,n) for(i=1;i<=n;i++)
#define per(i,n) for(i=n-1;i>=0;i--)
#define peR(i,n) for(i=n;i>0;i--)
#define mem(a,b) memset(a,b,sizeof(a))
#define all(cont) cont.begin(),cont.end()
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL)
#define pi 3.1415926535897932384626433832795
#define vi vector<long long>
#define vs  vector<string>
#define MX LLONG_MAX
#define MN LLONG_MIN
#define MOD 1000000007
#define vp(vi,x) cin>>x; vi.pb(x);
#define bsearch(a,x) binary_search(all(a),x)
#define LB(a,x) (lower_bound(all(a),x)-a.B)
#define UB(a,x) (upper_bound(all(a),x)-a.B)
typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;
bool isprm(LL a){if(a==1)return false; for(LL i=2;i*i<=a;i++){if(a%i==0)return false;}return true;}
bool palin(string a){for(int i=0;i<a.sz;i++){if(a.at(i)!=a.at(a.sz-i-1))return 0;} return 1;}
bool isVowel(char ch){ ch=toupper(ch); if(ch=='A'||ch=='U'||ch=='I'||ch=='O'||ch=='E') return true; return false;}
int toInt(string s){int sm;stringstream ss(s);ss>>sm;return sm;}
LL ceil2(LL a,LL b){LL c=a/b; if(a%b)c++; return c; }
LL bpow(LL a,LL b){if(b==0)return 1;LL r=bpow(a,b/2);if(b%2)return r*r*a;else return r*r;}
LL binpow(LL a,LL b){LL r=1;while(b>0){if(b&1)r=r*a;a=a*a;b>>=1;}return r;}
LL binpow(LL a,LL b,LL m){a%=m;LL r=1;while(b>0){if(b&1) r=r*a%m;a=a*a%m; b>>=1;}return r;}
template<typename T>inline T gcd(T a,T b){if(a<0)return gcd(-a,b);if(b<0)return gcd(a,-b);return (b==0)?a:gcd(b,a%b);}
template<typename T>inline T lcm(T a,T b) {if(a<0)return lcm(-a,b);if(b<0)return lcm(a,-b);return a*(b/gcd(a,b));}
int main()
{
//    fast;
    LL i,j,k,n,m,l,s=0,x,y,tc=1,p,q,a,b,c=0;
    bool f=0,ff=0;string st,s1,s2,s3; char ch;
    while(cin>>n)
    {
        c=0,a=MX;
        rep(i,n)
        {
            cin>>x;
            if(x<a)c++,a=x;
        }
        cout<<c<<en;
    }
    return 0;
}


Measured memory_bytes: 3564
use std::io;

fn main() {
    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    let n = buf.trim().parse::<usize>().unwrap();
    buf.clear();
    io::stdin().read_line(&mut buf).unwrap();
    let mut xs: Vec<_> = buf
        .split_ascii_whitespace()
        .map(|x| x.parse::<usize>().unwrap())
        .collect();
    assert!(xs.len() == n);
    xs.sort_by(|a, b| a.partial_cmp(b).unwrap());

    let mut dp = vec![None; *xs.last().unwrap() + 1];

    for x in xs.iter() {
        if dp[*x].is_some() {
            dp[*x] = Some(false);
            continue;
        }
        dp[*x] = Some(true);

        let mut xx = x + x;
        while xx < dp.len() {
            dp[xx] = Some(false);
            xx += x;
        }
    }

    println!(
        "{}",
        xs.iter()
            .filter(|x| dp[**x].unwrap())
            .collect::<Vec<_>>()
            .len()
    );
}


Measured memory_bytes: 7880
#[allow(unused)]
use std::cmp::{max, min};
use std::collections::HashMap;

#[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)*}
    };
}

#[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, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

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

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

trait IteratorExt: Iterator + Sized {
    fn vec(self) -> Vec<Self::Item> {
        self.collect()
    }
}

impl<T: Iterator> IteratorExt for T {}

fn main() {
    input! {
        // usize
        // n: usize,
        // vec
        // v: [i64; n],
        n: usize,
        s: [chars; n],
    }

    let mut counter: HashMap<String, i64> = HashMap::new();
    let mut ans = 0;

    for i in 0..n {
        let mut a = s[i].clone();
        a.sort();
        let x = a.into_iter().collect::<String>();
        let count = counter.entry(x).or_insert(0);
        *count += 1;
    }

    for (_, value) in counter {
        if value > 1 {
            ans += (value * (value - 1)) / 2;
        }
    }

    println!("{}", ans);
}


Measured memory_bytes: 25676
#include<iostream>
using namespace std;
#include<string>
#include<strstream>
#include<sstream>

int main()
{
	char a, b, c;
	cin >> a >> b >> c;
	string s  ;
	s += a ;
	s += b;
	s += c;	stringstream ss(s);
	int x=0;
	ss >> x;
	
	if ((x & 3)==0)
		cout << "YES";
	else
		
	cout << "NO";

}


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

typedef long long ll;
 
using tpl = tuple<int, int, int>;
typedef pair<int,int> pii;

void fastStream(){cin.tie(0);std::ios_base::sync_with_stdio(0);}

int N, K;
int main(){

    cin >> N >> K;
    cout << N - K + 1 << endl;
    


    return 0;
}


Measured memory_bytes: 256
x, y = map(int, input().split())

l = [[1, 3, 5, 7, 8, 10, 12], [4, 6, 9, 10, 11], [2]]
bool = False
for i in range(3):
    if x in l[i]:
        if y in l[i]:
            bool = True
            break
        
print('Yes' if bool else 'No')

Measured memory_bytes: 3060
import numpy as np

N,M=map(int,input().split())
ks=np.array([[int(i) for i in input().split()] for _ in range(M)])
p=list(map(int,input().split()))

ans=0

for i in range(2**N):

    # swにスイッチのオンオフを記録
    sw=[0]*N
    for j in range(N):
        if (i>>j)&1:
            sw[j]=1

    count=0
    for denkyu_no in range(M):
        if sum([sw[ks[denkyu_no][j+1]-1] for j in range(ks[denkyu_no][0])])%2 ==p[denkyu_no]:
            count +=1

    if count==M:
        ans+=1
print(ans)

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

int main() {
    int N, M;
    cin >> N >> M;
    vector<int> k(M);
    vector<vector<int>> s(M);
    vector<int> p(M);
    for(int i = 0; i < M; i++) {
        cin >> k.at(i);
        s[i].resize(k[i]);
        for(int j = 0; j < k[i]; j++) {
            cin >> s[i][j];
            s[i][j]--;
        }
    }
    for(int i = 0; i < M; i++) {
        cin >> p.at(i);
    }
    int count = 0;
    for(int bit = 0; bit < (1 << N); bit++) {
        bool all = true;
        for(int i = 0; i < M; i++) {
            int sum = 0;
            for(int id : s[i]) {
                if(bit & (1 << id)) {
                    sum++;
                }
            }            
            if(sum % 2 != p[i]) {
                all = false;
            }
        }
        if(all) {
            count++;
        }
    }
    cout << count << endl;
    return 0;
}

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

#define PI 4*atan(1)
#define INF 1e8

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

int main(){
  int N, D;
  string X;
  cin >> N >> X >> D;
  string S = X;
  int cnt = 0;
  for(int i = 0; i < X.size(); i++){
    if(cnt == D)break;
    if(X[i] == '0'){
      cnt++;
      X[i] = '1';
    }
  }
  if(cnt != D){
    for(int i = X.size() - 1; i >= 0; i--){
      if(S[i] == '1') {
        X[i] = '0';
        cnt++;
      }
      if(cnt == D)break;
    }
  }

  cout << X << endl;
}

Measured memory_bytes: 3236
#include <bits/stdc++.h>
#define int long long
#define INT_MAX INT64_MAX
#define INT_MIN INT64_MIN
#define CLK clock_t clk = clock();//Start of main
#define OCLK cerr << "Time (in ms): " << (double)(clock() - clk) * 1000.0 / CLOCKS_PER_SEC << '\n';//End of main
#define MOD 1000000007
/* DEFINE cout */
#define pln cout << "===============================\n"
#define on cout<<"\n"
#define os cout<<" "
#define o2(a,b) cout<<a<<" "<<b
#define o(a) cout << a
#define bitcount __builtin_popcount
/* DEFINE cout */
#define endl "\n"
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);//fastio
using namespace std;
struct hash_pair { // use pair as key in unordered_map<pair<int,int>,int,hash_pair>;
    template <class T1, class T2>
    size_t operator()(const pair<T1, T2>& p) const
    {
        auto hash1 = hash<T1>{}(p.first);
        auto hash2 = hash<T2>{}(p.second);
        return hash1 ^ hash2;
    }
};
bool prime[10000001];
int P=MOD-2;
int factorial[10000001]={0};
int powerFunction(int x,int y){
    int res = 1;
    int p = MOD;
    x = x % p;
    while (y > 0){
        if (y & 1)
            res = (res*x) % p;
        y = y>>1;
        x = (x*x) % p;
    }
    return res;
}
void sieveFunction(int maxLimit){
    memset(prime, true, sizeof(prime));
    prime[0] = prime[1]=false;
    for(int i=2; maxLimit >= i ; i++){
        if(prime[i]){
            for(int j=2*i ; maxLimit >= j ; j+=i)
                prime[j]=false;
        }
    }
}
void factorialFunction(int maxLimit){
    factorial[0]=1;
    for(int i=1 ; i <= maxLimit ; i++)
        factorial[i]=(factorial[i-1]*i)%MOD;
    return;
}
int gcd(int a, int b){
    if (b == 0)
        return a;
    return gcd(b, a % b);
}
signed main(){
    int n;
    cin >> n;
    string str = "";
    string a, b;
    cin >> a >> b;
    for(int i=0; n>i; i++){
        str.push_back(a[i]);
        str.push_back(b[i]);
    }
    cout << str << endl;
}



Measured memory_bytes: 256