akhauriyash/Code-Regression huggingface dataset:
-- https://github.com/minoki/my-atcoder-solutions
{-# LANGUAGE BangPatterns #-}
import Data.Char (isSpace)
import Data.List (unfoldr)
import Control.Monad
import Control.Monad.ST
import qualified Data.Vector as V
import qualified Data.Vector.Unboxed as U
import qualified Data.Vector.Unboxed.Mutable as UM
import qualified Data.ByteString.Char8 as BS

warshallFloyd1 :: Int -> U.Vector (Int, Int, Int) -> V.Vector (U.Vector Int)
warshallFloyd1 !n !edges = runST $ do
  !arr <- V.replicateM n (UM.replicate n (10^9+1))
  U.forM_ edges $ \(a,b,c) -> do
    UM.write (arr V.! a) b c
    UM.write (arr V.! b) a c
  forM_ [0..n-1] $ \a -> do
    UM.write (arr V.! a) a 0
  flip V.imapM_ arr $ \ !k !a_k -> do
    V.forM_ arr $ \ !a_i -> do
      forM_ [0..n-1] $ \j -> do
        a_ik <- UM.read a_i k
        a_kj <- UM.read a_k j
        UM.modify a_i (min (a_ik + a_kj)) j
  V.mapM U.unsafeFreeze arr

warshallFloyd2 :: Int -> Int -> V.Vector (U.Vector Int) -> V.Vector (U.Vector Int)
warshallFloyd2 !n !l !graph = runST $ do
  !arr <- V.replicateM n (UM.replicate n (10^9+1))
  flip V.imapM_ (V.zip graph arr) $ \ !a (!g_a,!a_a) -> do
    flip U.imapM_ g_a $ \ !b !v -> do
      when (v <= fromIntegral l) $ do
        UM.write a_a b 1
    UM.write a_a a 0
  flip V.imapM_ arr $ \ !k !a_k -> do
    V.forM_ arr $ \ !a_i -> do
      forM_ [0..n-1] $ \j -> do
        a_ik <- UM.read a_i k
        a_kj <- UM.read a_k j
        UM.modify a_i (min (a_ik + a_kj)) j
  V.mapM U.unsafeFreeze arr

main = do
  [n,m,l] <- unfoldr (BS.readInt . BS.dropWhile isSpace) <$> BS.getLine
  edges <- U.replicateM m $ do
    [a,b,c] <- unfoldr (BS.readInt . BS.dropWhile isSpace) <$> BS.getLine
    return (a-1,b-1,c)
  let !w1 = warshallFloyd1 n edges
      !w2 = warshallFloyd2 n l w1
  q <- readLn
  queries <- U.replicateM q $ do
    [s,t] <- unfoldr (BS.readInt . BS.dropWhile isSpace) <$> BS.getLine
    return (s,t)
  U.forM_ queries $ \(s,t) -> do
    let d = w2 V.! (s-1) U.! (t-1)
    print $ if d > 10^9 then -1 else d - 1


Measured memory_bytes: 7292
#[allow(dead_code)]
fn getline() -> String {
    let mut res = String::new();
    std::io::stdin().read_line(&mut res).ok();
    res
}

#[allow(unused_macros)]
macro_rules! readl {
    ($t: ty) => {
        {
            let s = getline();
            s.trim().parse::<$t>().unwrap()
        }
    };
    ($( $t: ty),+ ) => {
        {
            let s = getline();
            let mut iter = s.trim().split(' ');
            ($(iter.next().unwrap().parse::<$t>().unwrap(),)*)
        }
    };
}

#[allow(unused_macros)]
macro_rules! readlvec {
    ($t: ty) => {{
        let s = getline();
        let iter = s.trim().split(' ');
        iter.map(|x| x.parse().unwrap()).collect::<Vec<$t>>()
    }};
}

#[allow(unused_macros)]
macro_rules! debug {
    ($x: expr) => {
        println!("{}: {:?}", stringify!($x), $x)
    };
}
// macro_rules! debug { ($x: expr) => () }

#[allow(dead_code)]
fn show<T>(iter: T) -> String
where
    T: Iterator,
    T::Item: std::fmt::Display,
{
    let mut res = iter.fold(String::new(), |sum, e| sum + &format!("{} ", e));
    res.pop();
    res
}

#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused_imports)]
use std::collections::{BTreeMap, BinaryHeap, HashMap, HashSet};
#[allow(unused_imports)]
use std::collections::btree_map::Entry::{Occupied, Vacant};

fn eratosthenes(n: usize) -> Vec<bool> {
    let n = n + 1;
    let mut res = vec![true; n];
    res[0] = false;
    res[1] = false;
    for i in (2..).take_while(|i| i * i <= n) {
        let mut j = i*2;
        while j < n {
            res[j] = false;
            j += i;
        }
    }
    res
}

fn main() {
    use std::io::Write;
    let out = std::io::stdout();
    let mut out = std::io::BufWriter::new(out.lock());
    macro_rules! printf { ($($arg:tt)*) => (write!(out, $($arg)*).unwrap()); }
    macro_rules! printfln { () => (writeln!(out).unwrap()); ($($arg:tt)*) => (writeln!(out, $($arg)*).unwrap()); }

    let n = readl!(usize);
    // debug!(eratosthenes(10));
    let era = eratosthenes(55555);
    let ans: Vec<_> = era.into_iter()
        .enumerate()
        .filter(|&(i, f)| f && i % 5 == 1)
        .map(|x| x.0)
        .take(n)
        .collect();
    printfln!("{}", show(ans.iter()));
}


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

#define rep(i, n) REP(i, 0, n)
#define REP(i, k, n) for(auto i = k; i != n; i++)
#define rrep(i, n) RREP(i, n, 0)
#define RREP(i, n, k) for(auto i = n; i != k; i--)
#define all(x, r) (x), (x)+(r)
#define ALL(x) (x).begin(), (x).end()
#define debug(x) cerr << #x << " " << x << endl
#define exst(x, data) (data).find(x) != (data).end()
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
#define np next_permutation
#define b32 bitset<32>

using ll = long long;
using Pii = pair<int,int>;
using Tiii = tuple<int, int, int>;
template<class T>using V = vector<T>;

class Edge {
public:
    int to;
    bool c = true;
    Edge(int t) {
        to = t;
    }
};

V<V<Edge>> e;
int N, M;

void dfs(int n, int pos) {
    if(pos == N) {
        cout << "POSSIBLE" << endl;
        exit(0);
    }
    if(n == 0) return ;

    REP(itr,e[pos].begin(),e[pos].end()) if(itr->c) dfs(n-1,itr->to);
}

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

    cin >> N >> M;
    e = V<V<Edge>>(N+1, V<Edge>());
    rep(i,M) {
        int a, b; cin >> a >> b;
        e[a].pb(Edge(b));
        e[b].pb(Edge(a));
    }
    dfs(2,1);
    cout << "IMPOSSIBLE" << endl;
    return 0;
}


Measured memory_bytes: 12776
#include<bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef pair<int, int> P;
#define REP(i, n) for (int i=0; i<(int)(n); ++i)
 
template<class T> inline bool chmin(T &a, T b) { if(a>b){ a=b; return true; }  return false;}
template<class T> inline bool chmax(T &a, T b) { if(a<b){ a=b; return true; }  return false;}

// ll a[100010][3];
// ll dp[110][100010];  // [品物][重さ] としたときの価値の最大値
// ll weight[110], value[110];

int main() {
  int A, B, C, D; cin >> A >> B >> C >> D;
  int left = A+B;
  int right = C+D;
  if(left > right){
    cout << "Left" << endl;
  } else if(left < right){
    cout << "Right" << endl;
  } else {
    cout << "Balanced" << endl;
  }
}

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

using namespace std;

bool vis[8];

int n, m;
bool edge[8][8];

int dfs(int now)
{
	bool ok = true;
	for (int i = 0; i < n; i++)
		if (!vis[i])
			ok = false;
	if (ok)
		return 1;

	int ans = 0;
	for (int i = 0; i < n; i++)
		if (edge[now][i] && !vis[i])
		{
			vis[i] = true;
			ans += dfs(i);
			vis[i] = false;
		}
	return ans;
}

int main()
{
	cin >> n >> m;
	for (int i = 0; i < m; i++)
	{
		int a, b;
		cin >> a >> b;
		edge[a - 1][b - 1] = edge[b - 1][a - 1] = true;
	}
	vis[0] = true;
	cout << dfs(0) << endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (n); i++)
using namespace std;
using ll = long long;
const ll INF = 1LL << 60;

int main(void){
  int a, b;
  cin >> a >> b;
  cout << max({a+b, a-b, a*b}) << endl;
  return 0;
}


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

int main()
{
    long long k,q;
    cin>>k>>q;
    vector<long long> d1(k);
    for(long long i =0; i<k; i++)
        cin>>d1[i];
    while(q--)
    {
        long long n,x,m;
        cin>>n>>x>>m;
        vector<long long> d(k);
        for(long long i=0; i<k; i++)
            d[i] = d1[i]%m;
        long long sum = 0;
        for(long long int i=0; i<k; i++)
            sum+=d[i];
        long long presum =0;
        for(long long int i=0; i<= (n-2)%k; i++)
            presum+=d[i];
        sum = sum*((n-2)/k) + presum;
        long long a = sum + x;
        long long quot = a/m - x/m;

        long long counti =0;
        for(int i =0; i<k; i++)
        {
            if(d[i]==0)
                counti++;
        }
        counti*=((n-2)/k);
        long long count2 =0;
        for(int i =0; i<=(n-2)%k; i++)
        {
            if(d[i]==0)
                count2++;
        }
         count2+=counti;


       cout<<n-1-count2-quot<<"\n";
    }
}


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

int main(){
	double a,b,c,d,e,f,x,y;
	while(cin >> a >> b >> c >> d >> e >> f){
		x=(c*e-b*f)/(a*e-b*d);
		if(x==0){
			x=0;
		}
		y=(c*d-a*f)/(b*d-e*a);
		if(y==0){
			y=0;
		}
		printf("%.3f %.3f\n",x,y);
	}
	
return 0;
}

Measured memory_bytes: 1236
#include <bits/stdc++.h>
#define fi first
#define se second
using namespace std;
using ll = long long;

int constexpr N = 100005;

struct dsu {
    vector<int> p;
    dsu(int n) {
        p.resize(n);
        iota(begin(p), end(p), 0);
    }
    int get(int v) {
        return p[v] == v ? v : p[v] = get(p[v]);
    }
    int unite(int u, int v) {
        u = get(u), v = get(v);
        if(u == v)
            return 0;
        p[u] = v;
        return 1;
    }
};

int main() {
    ios::sync_with_stdio(0); cin.tie(0);
    int n;
    cin >> n;
    vector<pair<int, int>> x(n), y(n);
    for(int i = 0; i < n; ++i) {
        cin >> x[i].fi >> y[i].fi;
        x[i].se = y[i].se = i;
    }
    sort(begin(x), end(x));
    sort(begin(y), end(y));
    vector<tuple<int, int, int>> v;
    dsu s(n + 1);
    for(int i = 1; i < n; ++i) {
        v.push_back(make_tuple(x[i].fi - x[i - 1].fi, x[i].se, x[i - 1].se));
        v.push_back(make_tuple(y[i].fi - y[i - 1].fi, y[i].se, y[i - 1].se));
    }
    sort(begin(v), end(v));
    int picked = 0;
    ll ans = 0;
    for(auto& u : v) {
        if(s.unite(get<1>(u), get<2>(u))) {
            ans += get<0>(u);
            picked += 1;
        }
        if(picked == n - 1)
            break;
    }
    cout << ans << '\n';
}

Measured memory_bytes: 6900
// #pragma GCC optimize("Ofast")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
// #pragma GCC optimize("unroll-loops")

#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 DEBUG
#ifdef DEBUG
#define debug(...) __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...);
	}
#else
#define debug(...)
#endif

template <class Ch, class Tr, class Container>
basic_ostream <Ch, Tr> & operator << (basic_ostream <Ch, Tr> & os, Container const& x) {
    os << "{ ";
    for(auto& y : x) os << y << " ; ";
    return os << "}";
}

template <class X, class Y>
ostream & operator << (ostream & os, pair <X, Y> const& p) {
	return os << "[ " << p.first << ", " << p.second << "]" ;
}

#define FAST_IO std::ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ll long long int
#define pb push_back
#define mp make_pair
#define ld long double
#define sz(a) (ll)(a).size()
#define endl "\n"

// priority_queue<ll, vector<ll>, less<ll>>pq;     // Max Heap
// priority_queue<ll, vector<ll>, greater<ll>>pq;  // Min Heap

typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
//K-th smallest
//cout << k << "kth (1 based indexing) smallest: " << *A.find_by_order(k - 1) << endl;
//NO OF ELEMENTS < X
//cout << "No of elements less than " << X << " are " << A.order_of_key(X) << endl;

int main()
{
	FAST_IO;

    ll n, m, k, ans = 0;
    cin >> n >> m >> k;
    vector<string>a(n);
    for(int i=0;i<n;i++) cin >> a[i];
    for(int i=0;i<(1 << n);i++)
    {
    	for(int j=0;j<(1 << m);j++)
    	{
    		ll done[n][m];
    		for(int l=0;l<n;l++) for(int p=0;p<m;p++) done[l][p] = 0;
    		for(int l=0;l<n;l++)
    			if(i & (1 << l))
    				for(int p=0;p<m;p++) done[l][p] = 1;
    		for(int l=0;l<m;l++)
    			if(j & (1 << l))
    				for(int p=0;p<n;p++) done[p][l] = 1;
    		ll cnt = 0;
    		for(int l=0;l<n;l++) for(int p=0;p<m;p++) if(!done[l][p] && a[l][p] == '#') cnt += 1;
    		ans += (cnt == k);
    	}
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3652
/*
    if you can't see the repay
    Why not just work step by step
    rubbish is relaxed
    to ljq
*/
#include <cstdio>
#include <cstring>
#include <iostream>
#include <queue>
#include <cmath>
#include <map>
#include <stack>
#include <set>
#include <sstream>
#include <vector>
#include <stdlib.h>
#include <algorithm>
using namespace std;

#define dbg(x) cout<<#x<<" = "<< (x)<< endl
#define dbg2(x1,x2) cout<<#x1<<" = "<<x1<<" "<<#x2<<" = "<<x2<<endl
#define dbg3(x1,x2,x3) cout<<#x1<<" = "<<x1<<" "<<#x2<<" = "<<x2<<" "<<#x3<<" = "<<x3<<endl
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define lc (rt<<1)
#define rc (rt<<11)
#define mid ((l+r)>>1)

typedef pair<int,int> pll;
typedef long long ll;
const int inf = 0x3f3f3f3f;
const int _inf = 0xc0c0c0c0;
const ll INF = 0x3f3f3f3f3f3f3f3f;
const ll _INF = 0xc0c0c0c0c0c0c0c0;
const ll mod =  (int)1e9+7;

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll ksm(ll a,ll b,ll mod){int ans=1;while(b){if(b&1) ans=(ans*a)%mod;a=(a*a)%mod;b>>=1;}return ans;}
ll inv2(ll a,ll mod){return ksm(a,mod-2,mod);}
void exgcd(ll a,ll b,ll &x,ll &y,ll &d){if(!b) {d = a;x = 1;y=0;}else{exgcd(b,a%b,y,x,d);y-=x*(a/b);}}//printf("%lld*a + %lld*b = %lld\n", x, y, d);
int mp[25][25];
int dp[1<<22];
int main()
{
    //ios::sync_with_stdio(false);
    //freopen("a.txt","r",stdin);
    //freopen("b.txt","w",stdout);
    int n;
    scanf("%d",&n);
    for(int i = 0;i<n;++i)
        for(int j = 0;j<n;++j)
            scanf("%d",&mp[i][j]);
    dp[0] = 1;
    for(int i = 1;i<(1<<n);++i)
    {
        int now = __builtin_popcount(i) - 1;
        for(int j = 0;j<n;++j)
        {
            if(i&(1<<j)&&mp[now][j])
            {
                dp[i] = (dp[i] + dp[i^(1<<j)])%mod;
            }
        }
    }
    printf("%d\n",dp[(1<<n)-1]);
    //fclose(stdin);
    //fclose(stdout);
    //cout << "time: " << (long long)clock() * 1000 / CLOCKS_PER_SEC << " ms" << endl;
    return 0;
}


Measured memory_bytes: 10496
#include <iostream>

std::pair<int, int> box[100001];

int main(){
    box[0].second=1;
    int N, M;
    std::cin>>N>>M;
    for(int i=0;i<N;++i)box[i].first=1;
    for(int i=0;i<M;++i){
        int x,y;
        std::cin>>x>>y;
        x--, y--;
        if(box[x].second==1){
            box[y].second=1;
            if(box[x].first==1)box[x].second=0;
        }
        box[x].first--;
        box[y].first++;
    }
    int ans=0;
    for(int i=0;i<N;++i){
        if(box[i].second==1)ans++;
    }
    std::cout<<ans<<std::endl;
    return 0;
}

Measured memory_bytes: 1024
K = int(input())

res = 0
for i in range(1, K + 1):
    for j in range(i + 1, K + 1):
        if i % 2 == 1:
            if j % 2 == 0:
                res += 1
        else:
            if j % 2 == 1:
                res += 1

print(res)

Measured memory_bytes: 2940
#include <iostream>
#include <string>
#include <math.h>
using namespace std;


int main(){
	int x1,x2,x3,x4;
  	cin>>x1>>x2>>x3;
  	x4 = x1*x1+x2*x2;
  	if((x1==x2)&&(x2==x3)){
    	cout << "Yes" <<endl;
    }else{
    	cout << "No" <<endl;
    }
    
     
    	
    return 0;
  	
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){

	int number;

	scanf("%d",&number);

	int a[number];

	for(int i=0;i<number;i++){
			scanf("%d",&a[i]);
	}

	for(int i=number-1;i>=1;i--){
		printf("%d ",a[i]);
	}

	printf("%d\n",a[0]);
}



Measured memory_bytes: 2124
#include <iostream>
#include <cmath>
#include <string>
#include <vector>
#include <set>
#include <algorithm>

using namespace std;

int main()
{
	int A, B, C;
	cin >> A >> B >> C;
	int K;
	cin >> K;

	while (true)
	{
		if (K == 0) break;
		if (A >= B) {
			B *= 2;
			K--;
		}

		if (K == 0) break;
		if (B >= C) {
			C *= 2;
			K--;
		}
		if (A < B && B < C) break;
	}

	if (A < B && B < C) cout << "Yes";
	else cout << "No";

	return 0;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define SORTR(v,n) sort(v, v+n, greater<int>());
#define int long long	// %lld=>%lld
#define pb push_back
#define INF 1000000000
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, pii> piii;
typedef pair<ll, pll> plll;

int n;
int a;
int b;



signed main(){

    scanf("%lld", &n);
    scanf("%lld", &a);

    scanf("%lld", &b);


    if(n == 1){
        if(a!=b)
            printf("0\n");
        else {
            printf("1\n");
        }
        return 0;
    }
    if(a>b){
        printf("0\n");
            return 0;
    }

    printf("%lld\n", (b-a)*(n-2)+1);

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
int main(){
    ios::sync_with_stdio(false);
    int a;
    cin >> a;
    cout << a+a*a+a*a*a << endl;
}


Measured memory_bytes: 3608
#include <bits/stdc++.h>
#define MOD 1000000007
#define md %998244353
#define INF 2e9
#define EPS 1e-9
#define MAX LLONG_MAX
#define MIN LLONG_MIN
#define F first
#define S second
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define endl "\n"
#define FOR(i,a,b) for (long long i = a; i < b; i++)
#define REV(i,a,b) for (long long i = a; i > b; i--)
#define mset(a, v) memset(a, v, sizeof(a))
#define fd(n) fixed<<setprecision(n)
typedef std::pair<int, int> pii;
typedef std::vector<long long> vi;
typedef std::vector<vi> vvi;
typedef long long ll;
typedef unsigned long long ull;
using namespace std;

ll solve(ll x,ull y,ll p) {
    ll res = 1;
    x = x % p;
    while (y > 0) {
        if (y & 1)
            res = (res*x) % p;
        y = y>>1;
        x = (x*x) % p;
    }
    return res;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(NULL);
   
   ll i,j,n;
   string s;
   cin>>s;
   
   if(s[2]==s[3] and s[4]==s[5])
     cout<<"Yes";
     else
     cout<<"No";
   
   



}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <set>
#include<algorithm>
#include<sstream>
#include<iomanip>


using namespace std;

typedef long long ll;

const ll MOD_CONST = 1000000007;

int main() {

	int n;
	ll time;
	cin >> n >> time;

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

	ll sum = 0;
	for (int i = 0; i < n-1; i++) {
		ll span = t[i + 1] - t[i];
		sum += min(span, time);
	}

	sum += time;

	cout << sum << endl;


}


Measured memory_bytes: 1024
from itertools import permutations

N = int(input())
P = list(map(int,input().split()))
Q = list(map(int,input().split()))

count = 0

for v in permutations(range(1,N+1)):
    count += 1
    if all([P[i]==v[i] for i in range(N)]):
        a = count
    if all([Q[i]==v[i] for i in range(N)]):
        b = count

print(abs(a-b))

Measured memory_bytes: 3064
#include <stdio.h>
int main(void){
  int cnt;
  int a,b,ind=0,j;
  int point[10000][2];
  int pt1,pt2;
  while(1){
    scanf("%d",&cnt);
    if(cnt == 0) break;
    pt1 = 0; pt2 = 0;
    while(cnt-- > 0){
      scanf("%d %d",&a,&b);
      if(a > b){
        pt1 += a + b;
      }else if(a < b){
        pt2 += a + b;
      }else{
        pt1 += a; pt2 += a;
      }
    }
    point[ind][0] = pt1;
    point[ind][1] = pt2;
    ind++;
  }
  for(j = 0; j < ind;j++)
    printf("%d %d\n",point[j][0],point[j][1]);
  return 0;
}

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

using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)
typedef long long ll;
template<typename T> bool chmax(T &a, T b) {if(a <= b){a = b; return true;}return false;}
template<typename T> bool chmin(T &a, T b) {if(a >= b){a = b; return true;}return false;}


int main(void){
    int a, b;
    cin >> a >> b;
    int ans = b % a == 0 ? a + b : b - a;
    cout << ans << endl;
}

Measured memory_bytes: 256
from collections import Counter
N = int( input())
A = list( map( int, input().split()))
CA = Counter(A)
V = []
for x in CA:
    if CA[x] >= 2:
        V.append(CA[x]-1)
V.sort(key = None, reverse = True)
now = 0
ans = 0
for v in V:
    ans += v
    if now <= 0:
        now += v
    else:
        now -= v
b = abs(now)
if b == 0:
    pass
elif b%2 == 1:
    ans += 1
else:
    pass
print( max(N-ans,0))

Measured memory_bytes: 18656
#include <stdio.h>
#include <iostream>
#include <algorithm>

using namespace std;
#define BUF (1000)

char s[8];
void input(void){
	cin >> s;
}

int main(void){
	input();

	int c=0;
	for(int i=0;i<6;i++)if(s[i]=='1')c++;
	cout << c << endl;
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int GCD(int a, int b);
int LCM(int a, int b);

int main(void)
{
	int a, b;
	int gcd, lcm;
	
	while (scanf("%d %d", &a, &b) != EOF){
		gcd = GCD(a, b);
		lcm = LCM(a, b);
		
		printf("%d %d\n", gcd, lcm);
	}
	
	return (0);
}

int GCD(int a, int b)
{
	if (a % b == 0){
		return (b);
	}
	return (GCD(b, a % b));
}
int LCM(int a, int b)
{
	return (a / GCD(a, b) * b);
}

Measured memory_bytes: 596
#include <iostream>
#include <vector>
#include <list>
#include <set>
#include <utility>
#include <string>
#include <algorithm>
#include <random>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cmath>
#include <cassert>
#include <climits>

using namespace std;

int opposite_distance(const vector<uint32_t>& trees, uint32_t l, size_t i, size_t j)
{
	assert(i != 0);
	assert(j != 0);
	uint32_t r_p = trees[i];
	uint32_t l_p = trees[trees.size() - j];
	auto ret = r_p + (l - l_p);
	return ret;
}

int distance_right(const vector<uint32_t>& trees, size_t i, size_t j)
{
	assert(i != 0);
	assert(j != 0);
	assert(j > i);
	auto ret = trees[j] - trees[i];
	return ret;
}

int distance_left(const vector<uint32_t>& trees, size_t i, size_t j)
{
	assert(i != 0);
	assert(j != 0);
	assert(j > i);
	auto ret = trees[trees.size() - i] - trees[trees.size() - j];
	return ret;
}

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

	vector<uint32_t> trees(n);
	for (int i = 0; i < n; i++) {
		cin >> trees[i];
	}
	vector<uint32_t> rtrees(n);
	auto ref = trees.rbegin();
	auto dst = rtrees.begin();
	while (ref != trees.rend()) {
		*dst = l - *ref;
		ref++;
		dst++;
	}

	uint64_t max_val = 0;
	// 左回り
	{
		int right_end = (n + 1) & 1;
		int right_pos = (n / 2) - 1;
		int left_pos  = ((n - 1) / 2);

		uint64_t dist = 0;
		for (int i = 0; i <= right_pos; i++) {
			dist += trees[i] * 2;
		}
		for (int i = 0; i <= left_pos; i++) {
			dist += rtrees[i] * 2;
		}

		if (right_end) {
			dist -= trees[right_pos];
		}
		else {
			dist -= rtrees[left_pos];
		}

		max_val = max(dist, max_val);

		for (int i = 1; i < n; i++) {
			right_end = 1 - right_end;

			dist -= 2 * rtrees[i - 1];
			if (!right_end) {
				dist -= trees[right_pos];
				dist += rtrees[left_pos + 1];
				right_pos--;
				left_pos++;
			}
			else {
				dist -= trees[right_pos];
				dist += rtrees[left_pos];
			}
			max_val = max(dist, max_val);
		}

	}
	// 左回り
	{
		int left_end = (n + 1) & 1;
		int left_pos = (n / 2) - 1;
		int right_pos = ((n - 1) / 2);

		uint64_t dist = 0;
		for (int i = 0; i <= right_pos; i++) {
			dist += trees[i] * 2;
		}
		for (int i = 0; i <= left_pos; i++) {
			dist += rtrees[i] * 2;
		}

		if (left_end) {
			dist -= rtrees[left_pos];
		}
		else {
			dist -= trees[right_pos];
		}

		max_val = max(dist, max_val);

		for (int i = 1; i < n; i++) {
			left_end = 1 - left_end;

			dist -= 2 * trees[i - 1];
			if (!left_end) {
				dist -= rtrees[left_pos];
				dist += trees[right_pos + 1];
				left_pos--;
				right_pos++;
			}
			else {
				dist -= rtrees[left_pos];
				dist += trees[right_pos];
			}
			max_val = max(dist, max_val);
		}
	}

	cout << max_val << endl;

	return 0;
}

Measured memory_bytes: 1792
import sys,os
from collections import defaultdict, deque
from math import ceil, floor
if sys.version_info[1] >= 5:
    from math import gcd
else:
    from fractions import gcd
sys.setrecursionlimit(10**6)
write = sys.stdout.write
dbg = (lambda *something: print(*something)) if 'TERM_PROGRAM' in os.environ else lambda *x: 0
def main(given=sys.stdin.readline):
    input = lambda: given().rstrip()
    LMIIS = lambda: list(map(int,input().split()))
    II = lambda: int(input())
    MOD = 10**9+7

    N,M,Q = LMIIS()
    A = [0]*N

    query = [0]*Q
    for i in range(Q):
        a,b,c,d = LMIIS()
        query[i] = (a,b,c,d)

    from itertools import combinations_with_replacement
    max_score = 0
    for T in combinations_with_replacement(range(1,M+1),N):
        tmp_score = 0
        for a,b,c,d in query:
            if T[b-1] - T[a-1] == c:
                tmp_score += d
        max_score = max(max_score, tmp_score)
    print(max_score)







if __name__ == '__main__':
    main()

Measured memory_bytes: 68184
import java.util.*;
import java.util.Scanner;


public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		  int a = sc.nextInt();
		  int b = sc.nextInt();
		  int result = 0;
		 
		  result = (a + b) % 24;
		 
		  System.out.println(result);
	}

}

Measured memory_bytes: 23892
#include <bits/stdc++.h>
#define debug(x) cerr << #x << ": " << x << '\n';
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = (int)1e9;

int w, h;
int c[51][51];
int dx[] = {1, -1, 0, 0, 1, 1, -1, -1};
int dy[] = {0, 0, 1, -1, 1, -1, 1, -1};

void dfs(int y, int x){
	c[y][x] = 0;
	for(int i = 0; i < 8; i++){
		int ny = y + dy[i], nx = x + dx[i];
		if(0<=ny and ny<h and 0<=nx and nx<w and c[ny][nx]==1){
			dfs(ny, nx);
		}
	}
}

int solve(){
	int res = 0;
	for(int i = 0; i < h; i++){
		for(int j = 0; j < w; j++){
			if(c[i][j] == 1){
				dfs(i, j);
				res++;
			}
		}
	}

	return res;
}

int main(void){
	while(scanf("%d%d", &w, &h) != EOF){
		if(w == 0 and h == 0) break;
		for(int i = 0; i < h; i++){
			for(int j = 0; j < w; j++){
				scanf("%d", &(c[i][j]));
			}
		}
		printf("%d\n", solve());
	}

	return 0;
}



Measured memory_bytes: 3204
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <queue>
#include <set>

using namespace std;

int calc(int a, int b, int c) {
    int max = 0;
    for(int i = 0; i <= c/a; i++){
        int tmp = i*a;
        int rest = c - i*a;
        tmp += (rest/b)*b;
        if(max < tmp)
            max = tmp;
    }
    return max;
}


int main() {
    int a,b,c,d,e,f; cin >> a >> b >> c >>d >> e >> f;
    double maxDense = 0;
    int maxTotal, maxSugar;
    for(int i = 0; i <= f/(100*a); i++) {
        int rest = f - (100*a)*i;
        for(int j = 0; j <= rest/(100*b); j++) {
            if(i == 0 && j == 0)
                continue;
            // cout << i << " " << j << endl;
            int notwater = rest - (100*b)*j;
            int water = f - notwater;
            int ableSugar = water/100.0*e;
            // cout << notwater << " " << water << " " << ableSugar << endl;
            int sugar = calc(c,d,min(notwater, ableSugar));
            if(maxDense <= 100.0*sugar/(sugar+water)) {
                maxDense = 100.0*sugar/(sugar+water);
                maxTotal = sugar + water;
                maxSugar = sugar;
            }
        }
    }
    cout << maxTotal << " " << maxSugar << endl;
}


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

int main() 
{
    int n;
    bool cards[4][13];                      //マークを4通りの数に対応
    char mark;                              //実際の入力はcharで受付け
    int num;                                //カード番号

    for( int i = 0; i < 4; i++ )            //falseで初期化
        for( int j = 0; j < 13; j++)
            cards[i][j] = false;       

    cin >> n;

    for( int i = 0; i < n; i++ )
    {
        cin >> mark >> num;                 //入力

        switch(mark)                        //用意した配列にマークと数字を振っていく
        {
            case 'S':                       //SHCDそれぞれ0123に対応
                cards[0][num-1] = true;     //num-1は13なら要素12の配列にある
                break;
            case 'H':
                cards[1][num-1] = true;
                break;
            case 'C':
                cards[2][num-1] = true;
                break;                
            case 'D':
                cards[3][num-1] = true;
                break;
        }
    }

    /*足りないカードがfalseとして格納されている配列を順に表示(マークと数字に変換して)させる*/
    for( int i = 0; i < 4; i++ )
        for( int j = 0; j < 13; j++ )
            if( cards[i][j] == false)   //falseならカードが無い
                switch(i)                        
                {
                    case 0:                      
                        cout << "S " << j + 1 << endl;
                        break;
                    case 1:
                        cout << "H " << j + 1 << endl;
                        break;
                    case 2:
                        cout << "C " << j + 1 << endl;
                        break;                
                    case 3:
                        cout << "D " << j + 1 << endl;
                        break;
                }


    return 0;
}


Measured memory_bytes: 3096
// https://atcoder.jp/contests/abc073/tasks/abc073_b
#include <bits/stdc++.h>
using namespace std;

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

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

  int ans = 0;
  rep(i, N) {
    int l, r;
    cin >> l >> r;
    ans += r - l + 1;
  }
  cout << ans;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define mod (int)(1e9+7)
#define inf (int)(3e18)
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define P std::pair<int,int>
#define PiP std::pair<int,std::pair<int,int>>
#define all(v) v.begin(),v.end()
#define mkp std::make_pair
#define prique(T) std::priority_queue<T,vector<T>,greater<T>>
using namespace std;
template<class T> inline void chmax(T& a, T b) { a = std::max(a, b); }
template<class T> inline void chmin(T& a, T b) { a = std::min(a, b); }

bool prime(int x) {
	for (int i = 2; i * i <= x; i++) {
		if (x % i == 0)return false;
	}
	return x != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x / gcd(x, y) * y;
}
int kai(int x, int y) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= i; res %= mod;
	}
	return res;
}
int mod_pow(int x, int y, int m) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x, y) * mod_pow(kai(y, y), mod - 2, mod) % mod;
}
int get_rand(int MIN, int MAX) {
	std::random_device rnd;
	std::mt19937_64 mt64(rnd());
	std::uniform_int_distribution<int>engine(MIN, MAX);
	return engine(mt64);
}
/*--------Library Zone!--------*/

int n;
bool con[205][205];
signed main() {
	cin >> n;
	rep(i, n)rep(j, n) {
		char c; cin >> c; if (c == '1')con[i][j] = true;
	}
	int ans = -1;
	rep(i, n) {
		int far[205];
		rep(j, n)far[j] = inf;
		far[i] = 1;
		queue<int>que; que.push(i);
		while (!que.empty()) {
			int k = que.front(); que.pop();
			rep(j, n) {
				if (!con[j][k])continue;
				if (far[j] == inf) {
					que.push(j); far[j] = far[k] + 1;
				}
				else {
					if (abs(far[k] - far[j]) != 1) {
						goto ng;
					}
				}
			}
		}
		rep(j, n)chmax(ans, far[j]);
	ng:;
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		while(scan.hasNext()){
			String str = scan.nextLine();
			int f = 0;
			int s = 0;
			for(int i = 0;i < str.length()-2;i++){
				if(str.charAt(i) == 'J'){
					if(str.charAt(i+1) == 'O' && str.charAt(i+2) == 'I'){
						f++;
						i += 1;
					}
				}else if(str.charAt(i) == 'I'){
					if(str.charAt(i+1) == 'O' && str.charAt(i+2) == 'I'){
						s++;
						i += 1;
					}
				}
			}
			System.out.println(f + "\n" + s);
		}
	}
}

Measured memory_bytes: 20664
#include<iostream>
#include<cstdio>
#include<vector>
#include<cmath>
#include<cstdlib>
#include<cstring>
using namespace std;
int ans=900;
int getans(int f,int s,int t){
	int q=abs(s-f);
	q+=abs(t-s);
	return q;
}
int main()
{
	int a,b,c;
	cin>>a>>b>>c;
	int c1=getans(a,b,c);
	if(c1<ans)
		ans=c1;
		
	int c2=getans(a,c,b);
	if(c2<ans)
		ans=c2;
		
	int c3=getans(b,a,c);
	if(c3<ans)
		ans=c3;
		
	int c4=getans(b,c,a);
	if(c4<ans)
		ans=c4;
		
	int c5=getans(c,a,b);
	if(c5<ans)
		ans=c5;
		
	int c6=getans(c,b,a);
	if(c6<ans)
		ans=c6;
		
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
n=gets.to_i
a=Hash.new([])
n.times{|i|
  s,t=gets.split
  t=t.to_i
  if a[s] == []
    a[s] = Array.new
  end
  a[s] << [t,i]
}
a.sort.to_h.values.each{|ar|
  ar.sort_by{|k,_|-k}.each{|_,v|
    p v+1
  }
}
  

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

#define f first
#define s second

const int mod=1000000007, N=1001;
char tab[N][N];
int dp[N][N], h, w, vis[N][N];

int bfs(){
  queue<pair<int,int>> q;
  dp[1][1]=1;
  q.push({1,1});
  while(!q.empty()){
    auto at=q.front();
    q.pop();
    if(vis[at.f][at.s])continue;

    vis[at.f][at.s]=1;

    dp[at.f][at.s]+=dp[at.f-1][at.s]+dp[at.f][at.s-1];
    dp[at.f][at.s]%=mod;

    if(at.f==h && at.s==w)break;
    if(at.s<w)
      if(tab[at.f][at.s+1]!='#')q.push({at.f, at.s+1});
    if(at.f<h)
      if(tab[at.f+1][at.s]!='#')q.push({at.f+1, at.s});

  }
  return dp[h][w];
}
int main(){
   scanf("%d %d", &h, &w);

   for(int i=1;i<=h;i++)
    for(int j=1;j<=w;j++)
      scanf(" %c", &tab[i][j]);

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


  /*for(int i=1;i<=h;i++){
    printf("\n");
    for(int j=1;j<=w;j++)
      printf("%d ", dp[i][j]);
  }*/
}


Measured memory_bytes: 9088
import sys
stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nn = lambda: list(stdin.readline().split())
ns = lambda: stdin.readline().rstrip()

n = ni()
p = na()
a = [20000*i for i in range(1,n+1)]
b = list(reversed(a))

j = 1
for i in p:
    b[i-1] += j
    j += 1

print(' '.join([str(m) for m in a]))
print(' '.join([str(m) for m in b]))

Measured memory_bytes: 7216
#pragma once
#include <string>
#include<iostream>
#include<stack>
#include<queue>
#include <vector>
//#include "ABC139.h"
#define rep(i,n) for(auto i=0;i<(n);i++)
#define all(container) (container).begin(),(container).end()
#define roundup(number,divider) (number)/(divider)+((number)%(divider)==0?0:1)

using namespace std;
int main() {
	int A, B; cin >> A >> B;
	int num = 1;
	cout << roundup(B - 1, A - 1) << endl;
}


Measured memory_bytes: 3528
#include <iostream>
#include <utility>
#include <vector>
#include <queue>
#include <stack>
#include <array>
#include <algorithm>
#include <numeric>
#include <limits>
#include <string>
#include <regex>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;

int main()
{
    int N;
    cin >> N;
    int H[N];
    int ans = 0;
    int t = 0;
    for (int i = 0; i < N; i++) {
        cin >> H[i];
    }
    for (int i = 1; i < N; i++) {
        if (H[i] <= H[i-1]) {
            t++;
            if (i == N - 1) ans = max(t, ans);
        }
        else {
            ans = max(t, ans);
            t = 0;
        }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 640
n = int(input())
s = str(input())
alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
rot = []
for i in s:
  pos = alphabet.find(i)
  pos = int(pos) + n
  if pos >= 26:
    pos = int(pos) - 26
  rot.append(alphabet[pos])
strout = "".join(rot)
print(strout)

Measured memory_bytes: 3060
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		new Solution().solve(in, out);
		out.close();
	}

	static class Solution {
		private long nextLong(InputReader in) {
			return Long.parseLong(in.next());
		}
		
		public void solve(InputReader in, PrintWriter out) {
			long n = nextLong(in);
			long ans = 0;
			for (long v = 2; v < n; ++v) {
				if (v * v > n) {
					break;
				}
				long e = 0;
				while (n % v == 0) {
					n /= v;
					++e;
				}
				if (e > 0) {
					for (long k = 1; k < 10; ++k) {
						if (e >= k) {
							e -= k;
							ans += 1;
						} else break;
					}
				}
			}
			if (n > 1) ans+=1;
			out.println(ans);
		}
	}

	static class InputReader {
		public BufferedReader reader;
		public StringTokenizer tokenizer;

		public InputReader(InputStream stream) {
			reader = new BufferedReader(new InputStreamReader(stream), 32768);
			tokenizer = null;
		}

		public String next() {
			while (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new RuntimeException();
				}
			}
			return tokenizer.nextToken();
		}

		public int nextInt() {
			return Integer.parseInt(next());
		}
	}
}


Measured memory_bytes: 25820
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    string s;
    cin >> s;
    int res = 700;
    if (s[0] == 'o') res += 100;
    if (s[1] == 'o') res += 100;
    if (s[2] == 'o') res += 100;
    cout << res << endl;
}


Measured memory_bytes: 256
import Control.Monad
f c s = foldl1 (g s) c
g s cp cq =if abs(head(snd cq)-head s)+abs(last(snd cq)-last s)<abs(head(snd cp)-head s)+abs(last(snd cp)-last s) then cq else cp
main=do
 [n,m]<-map read.words<$>getLine
 st<-replicateM n (map read.words<$>getLine)
 ct<-replicateM m (map read.words<$>getLine)
 let c = zip [1..m] ct
 putStrLn$unlines$map show$map fst$map (f c) st

Measured memory_bytes: 1020
#include<bits/stdc++.h>
using namespace std;
#define int long long int
map<int,int> mp;
int func(int n)
{
    if(n==1)
    return 1;
    if(n==0)
    return 0;
    if(mp.find(n)!=mp.end())
    return mp[n];
    return mp[n]=1+2*func(n/2);
}
int32_t main()
{
    int h;
    cin>>h;
    cout<<func(h)<<endl;
}

Measured memory_bytes: 256
import sys

sys.setrecursionlimit(10**7)
def I(): return int(sys.stdin.readline().rstrip())
def MI(): return map(int,sys.stdin.readline().rstrip().split())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))  #空白あり
def LI2(): return list(map(int,sys.stdin.readline().rstrip()))  #空白なし
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())  #空白あり
def LS2(): return list(sys.stdin.readline().rstrip())  #空白なし

N,K = MI()
V = LI()

ans = 0
for i in range(K+1):  # 操作回数
    for j in range(N+1):  # 左から
        for k in range(N+1):  # 右から
            if j + k > min(N,i):
                break
            l = i-j-k
            if l > j+k:
                continue
            A = [V[m] for m in range(j)] + [V[N-1-m] for m in range(k)]
            A.sort(reverse=True)
            ans = max(ans,sum(A[m] for m in range(j+k-l)))
print(ans)


Measured memory_bytes: 70508
import numpy as np
n,d = map(int, input().split())
l=[]
for i in range(n):
  l.append(list(map(int, input().split())))
count = 0
for i in range(n):
  for j in range(i+1,n):
    distance_a = 0
    for k in range(d):
      distance_k= l[i][k]-l[j][k]
      distance_a +=distance_k**2
    distance = np.sqrt(distance_a)
    distance_int =int(distance)
    if distance == distance_int:
      count += 1
print(count)
    
    
      


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

#define int long long
#define ll long long
#define pb push_back

main(){
    int n;
    cin >> n;
    int k = n % 10;
    if (k == 2 || k == 4 || k == 5 || k == 7 || k == 9){
        cout << "hon";
    }
    else{
        if (k == 3) cout << "bon";
        else cout << "pon";
    }
}


Measured memory_bytes: 3596
#include <stdio.h>
main(){
  int S[10000],T[500];
  int n,q,i,j,count=0;
  
  scanf("%d",&n);
  for(i=0;i<n;i++)
    {
      scanf("%d",&S[i]);
    }
  scanf("%d",&q);
  for(j=0;j<q;j++)
    {
      scanf("%d",&T[j]);
    }

  for(j=0;j<q;j++)
    {
      for(i=0;i<n;i++)
	{
	  if(S[i]==T[j])
	    { 
	      count++;
		break;
	    }
	}
    }

  printf("%d\n",count);
  return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
#define ll long long int
#define pi 3.14159265358979323846
using namespace std;
int main()
{
    ll n,ans;
    cin>>n;
    ll a[n],b[n+1]={0};
    for(int i=0;i<n-1;i++)
    {
        cin>>a[i];
        b[a[i]]++;
    }
    for(int i=1;i<=n;i++)
    cout<<b[i]<<endl;
}


Measured memory_bytes: 6724
#include <iostream>
#include <algorithm>
#include <complex>
#include <utility>
#include <vector>
#include <string>
#include <queue>
#include <tuple>
#include <cmath>
#include <bitset>
#include <cctype>
#include <set>
#include <numeric>
#include <functional>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define PRINT(V) cout << V << "\n"
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())
using namespace std;
using ll = long long;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
inline void Yes(bool condition){ if(condition) PRINT("Yes"); else PRINT("No"); }
template<class itr> void cins(itr first,itr last){
    for (auto i = first;i != last;i++){
        cin >> (*i);
    }
}
template<class itr> void array_output(itr start,itr goal){
    string ans = "",k = " ";
    for (auto i = start;i != goal;i++) ans += to_string(*i)+k;
    if (!ans.empty()) ans.pop_back();
    PRINT(ans);
}
ll gcd(ll a, ll b) {
    return a ? gcd(b%a,a) : b;
}
const ll INF = 1e9;
const ll MOD = 1000000007;
typedef pair<ll,ll> P;
const ll MAX = 20000;
constexpr ll nx[4] = {1,0,-1,0};
constexpr ll ny[4] = {0,1,0,-1};
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,m;
    cin >> n >> m;
    vector<int> a(n);
    int cnt = 0;
    rep(i,n){
        cin >> a[i];
        cnt += a[i];
    }
    double k = m;
    double f = (double)cnt/(4.0*k);
    int c = 0;
    rep(i,n){
        if (a[i] >= f) c++;
    }
    Yes(c >= m);
}


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

int main() {
	int n;
	cin >> n;
	int a0, a1, a2, a3;
	a3 = n % 10;
	n = (n - a3) / 10;
	a2 = n % 10;
	n = (n - a2) / 10;
	a1 = n % 10;
	n = (n - a1) / 10;
	a0 = n;
	if ((a0 == a1 && a1 == a2) || (a1 == a2 && a2 == a3))cout << "Yes" << endl;
	else cout << "No" << endl;
}

Measured memory_bytes: 256
N,Ma,Mb=map(int,input().split())
Med=[]
cnt_a=0
cnt_b=0
for i in range(N):
  a=[int(x) for x in input().split()]
  Med.append(a)
  cnt_a+=a[0]
  cnt_b+=a[1]
R=max(cnt_a,cnt_b)
#[i]まででMa=[j],Mb=[k]を作る場合の最小のコストdp
#dp[i+1][j+Ma][k+Mb]=min(dp[i][j+Ma][k+Mb],dp[i][j][k]+Cost)
#リストをinfで初期化。inf=作れない配合なので、continue。初期値はdp[0][0][0]=0
dp=[[[float('inf') for j in range(R+1)] for k in range(R+1)] for i in range(N+1)]
dp[0][0][0]=0

for i in range(N):
  for j in range(R+1):
    for k in range(R+1):
      if dp[i][j][k]==float('inf'):
        continue
      dp[i+1][j][k]=min(dp[i][j][k],dp[i+1][j][k])
      dp[i+1][j+Med[i][0]][k+Med[i][1]]=min(dp[i][j+Med[i][0]][k+Med[i][1]],dp[i][j][k]+Med[i][2])

ans=float('inf')
for i in range(1,N+1):
  if i*Ma<R+1 and i*Mb<R+1:
    ans=min(ans,dp[N][i*Ma][i*Mb])
if ans==float('inf'):
  print(-1)
else:
  print(ans)

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

#define MAXN (100010)

int n;
int a[MAXN];

int main(){
	scanf("%d", &n);
	int t = 0;
	for(int i = 1; i <= n; ++ i){
		scanf("%d", a + i);
		t = std::max(t, a[i]);
	}
	int x = 0, y;
	for(int i = 1; i <= n; ++ i){
		if(a[i] != t && a[i] != t - 1) return printf("No\n"), 0;
		x += a[i] == t - 1;
	}
	y = n - x;
	if(y == n){
		return printf(1 <= t && t <= n / 2 || t == n - 1 ? "Yes\n" : "No\n"), 0;
	}
	printf(x + 1 <= t && t <= x + y / 2 ? "Yes\n" : "No\n");
	return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
#define REP(i,j,n) for(int i=(int)(j);i<=(int)(n);i++)
#define MOD 1000000007
#define int long long
#define ALL(a) (a).begin(),(a).end()
#define vi vector<int>
#define vii vector<vi>
#define pii pair<int,int>
#define priq priority_queue<int>
#define disup(A,key) distance(A.begin(),upper_bound(ALL(A),(int)(key)))
#define dislow(A,key) distance(A.begin(),lower_bound(ALL(A),(int)(key)))
#define tii tuple<int,int,int>
#define Priq priority_queue<int,vi,greater<int>>
#define pb push_back
#define mp make_pair
#define INF (1ll<<60)
int modpow(int X,int Y){
    int cnt=1,sum=X,ret=1;
    vi A;
    while(cnt<=Y){
        A.pb(sum);
        sum*=sum;
        sum%=MOD;
        cnt*=2;
    }
    int M=A.size();
    REP(i,1,M){
        if(Y>=(1ll<<M-i)){
            Y-=(1ll<<M-i);
            ret*=A[M-i];
            ret%=MOD;
        }
    }
    return ret;
}
signed main(){
    int N,K; cin>>N>>K;
    vi dp(K+1);
    int ans=0;
    for(int i=K;0<i;i--){
        set<int> S;
        REP(j,1,sqrt(i)){
            if(i%j==0){
                S.insert(j);
                S.insert(i/j);
            }
        }
        int sum=(modpow(K/i,N)+MOD-dp[i])%MOD;
        ans+=sum*i%MOD;
        ans%=MOD;
        for(auto p:S){
            dp[p]+=sum;
            dp[p]%=MOD;
        }
    }
    cout<<ans<<endl;
  }



Measured memory_bytes: 4120