akhauriyash/Code-Regression huggingface dataset:
/// Thank you tanakh!!!
/// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

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

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

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

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

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

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

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

use std::collections::VecDeque;

fn main() {
    input!(n: usize, m: usize, uv: [(usize1, usize1); m]);
    let mut graph = vec![vec![]; n];
    for &(u, v) in uv.iter() {
        graph[u].push(v);
        graph[v].push(u);
    }

    let mut q = VecDeque::new();
    let mut vis = vec![0; n];
    let mut components = vec![];
    for i in 0..n {
        if vis[i] != 0 {
            continue;
        }
        let mut is_bipartite = true;
        let mut c = vec![];
        q.push_back(i);
        vis[i] = 1;
        c.push(i);
        while let Some(v) = q.pop_front() {
            for &next in graph[v].iter() {
                if vis[next] != 0 {
                    if vis[next] == vis[v] {
                        is_bipartite = false;
                    }
                    continue;
                }
                vis[next] = if vis[v] == 1 { 2 } else { 1 };
                q.push_back(next);
                c.push(next);
            }
        }

        components.push((c, is_bipartite));
    }

    let mut cnt_one = 0;
    let mut cnt_bipartite = 0;
    let mut cnt_other = 0;
    for &(ref c, is_bipartite) in components.iter() {
        if c.len() == 1 {
            cnt_one += 1;
        } else if is_bipartite {
            cnt_bipartite += 1;
        } else {
            cnt_other += 1;
        }
    }

    let mut ans = 0;
    ans += cnt_one * n * 2 - cnt_one * cnt_one;
    ans += cnt_bipartite * 2;
    ans += cnt_other;
    ans += cnt_bipartite * (cnt_bipartite - 1) * 2;
    ans += cnt_other * (cnt_other - 1);
    ans += cnt_other * cnt_bipartite * 2;
    println!("{}", ans);
}


Measured memory_bytes: 26580
#include<bits/stdc++.h>
using namespace std;
long long n,l[111111],r[111111],ans;
int main()
{
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>l[i]>>r[i];
	}
	sort(l,l+n+1);
	reverse(l,l+n+1);
	sort(r,r+n+1);
	for(int i=0;i<n;i++)
	{
		long long c=l[i]-r[i];
		if(c<=0)
		{
			break;
		}
		ans+=2*c;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 1920
#include <stdio.h>

int main(void)
{
char op;
int a, b, c[20000];
int i = 0;
int j = 0;

do{

scanf("%d %c %d", &a, &op, &b);


if(op == '+'){
  c[i] = a + b;
}else if(op == '-'){
  c[i] = a - b;
}else if(op == '*'){
  c[i] = a * b;
}else if(op == '/'){
  c[i] = a / b;
}


i++;

}while(op != '?');

for(j = 0; j < i-1; j++)
printf("%d\n", c[j]);

return 0;
}



Measured memory_bytes: 2068
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using Graph = vector<vector<pii>>;
const int INF = 1e9 + 1;
const ll LLINF = 1e18;
const int MOD = 1e9 + 7;

ll mod(ll a, ll m) { return (a % m + m) % m; }

ll extGCD(ll a, ll b, ll &p, ll &q) {
    if (b == 0) {
        p = 1, q = 0;
        return a;
    }
    ll d = extGCD(b, a % b, q, p);
    q -= a / b * p;
    return d;
}

ll modinv(ll a, ll m) {
    ll x, y;
    extGCD(a, m, x, y);
    return mod(x, m);
}

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

    int N, maxA = 0;
    cin >> N;
    vector<int> A(N);
    vector<int> cnt(1000001);
    for (int i = 0; i < N; ++i) {
        int tmp;
        cin >> tmp;
        A[i] = tmp;
        maxA = max(maxA, tmp);
        for (int j = 2; j <= sqrt(tmp); ++j) {
            int cnttmp = 0;
            while (!(tmp % j)) {
                tmp /= j;
                cnttmp++;
            }
            cnt[j] = max(cnt[j], cnttmp);
        }
        if (tmp != 1 && !cnt[tmp])
            cnt[tmp] = 1;
    }

    ll mul = 1;
    for (int i = 2; i <= maxA; ++i)
        for (int j = 0; j < cnt[i]; ++j)
            (mul *= i) %= MOD;

    ll ans = 0;
    for (int i = 0; i < N; ++i) {
        ans += (mul * modinv(A[i], MOD)) % MOD;
        ans %= MOD;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 4224
#include <bits/stdc++.h>
using namespace std;
int main()
{
    string str;
    cin>>str;
    int ans=0;
    if(str=="RRR")
     ans=3;
    else if(str=="RRS" || str=="SRR")
        ans=2;
    else if(str=="SSS")
        ans=0;
    else
        ans=1;
    cout<<ans<<"\n";
    return 0;
}

Measured memory_bytes: 3592
/********************************************************
  **░██████╗██╗░░░░░░█████╗░██╗░░░██╗██╗░█████╗░░██████╗░**
  **██╔════╝██║░░░░░██╔══██╗██║░░░██║██║██╔══██╗██╔════╝░**
  **╚█████╗░██║░░░░░███████║╚██╗░██╔╝██║██║░░╚═╝██║░░██╗░**
  **░╚═══██╗██║░░░░░██╔══██║░╚████╔╝░██║██║░░██╗██║░░╚██╗**
  **██████╔╝███████╗██║░░██║░░╚██╔╝░░██║╚█████╔╝╚██████╔╝**
  **╚═════╝░╚══════╝╚═╝░░╚═╝░░░╚═╝░░░╚═╝░╚════╝░░╚═════╝░**
  *********************************************************/

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


#define ll                          long long
#define ld                          long double

#define forn(i,n)                   for(int i=0;i<n;++i)
#define all(v)                      v.begin(), v.end()
#define rall(v)                     v.rbegin(),v.rend()
#define isSubstring(s1,s2)          s1.find(s2) != std::string::npos
	
#define pb                          push_back
#define pf                          push_front
#define mp                          make_pair
#define fr                          first
#define sc                          second

#define vpi                         vector<pair<int,int>>
#define vi                          vector<int>
#define sz(a)                       (int)a.size()

#define   endl                       "\n"
#define     nl                       cout<<"\n";
#define fastio                       ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

#define  MN                           INT_MIN
#define  MX                           INT_MAX
#define int long long
bool isPrime(ll n){if(n<2)return false;for(ll x = 2;x*x <=n;x++){if(n%x == 0)return false;}return true;}
bool isPerfectSquare(long double x){long double sr=sqrt(x);return((sr-floor(sr))==0);}
int gcd(int a, int b){if(a==0)return b;if(b==0) return a;if(a==b)return a;if(a>b)return gcd(a-b,b);return gcd(a,b-a);}

int32_t main()
{
	int n,k,q;
	cin >> n >> k >> q;
	int a[q];
	int p[n];
	for(int i = 0;i<n;i++){
		p[i] = k - q;
	}
	forn(i,q){
		cin>>a[i];
		p[a[i]-1]++;
	}
	for(int i = 0;i<n;i++){
		//cout << p[i] << endl;
		if(p[i] <= 0){
			cout << "No\n";
		}else{
			cout << "Yes\n";
		}
	}
}

Measured memory_bytes: 5020
n=int(input())
arr1=sorted(list(map(int,input().split())),reverse=True)
arr2=sorted(list(map(int,input().split())),reverse=True)
arr3=sorted(list(map(int,input().split())),reverse=True)
cnt=[0]*n
ans=0
pos=0
for i in range(n):
  for j in range(pos,n):
    if arr1[j]<arr2[i]:
      cnt[i]=n-pos
      break
    else:
      pos+=1
pos=0
for i in range(n):
  for j in range(pos,n):
    if arr2[i]<arr3[j]:
      pos+=1
    else:
      ans+=cnt[i]*pos
      break
  else:
    ans+=cnt[i]*pos
print(ans)

Measured memory_bytes: 24180
#include <bits/stdc++.h>
using namespace std;
 
int main() {
 string a, b, c;
  cin >> a >> b >> c;
  if(a.at(a.size()-1) == b.at(0) && b.at(b.size()-1) == c.at(0)) cout << "YES" << endl;
  else cout << "NO" << endl;
}

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

int main(){
    using namespace std;
    int N;
    int A_max = -1;
    int A_second_max =0;
    cin >> N;
    int  A[N];

    for (int i=0;i<N;i++){
        cin >> A[i];
        if(A_max < A[i]){
            A_second_max = A_max;
            A_max = A[i];
            }
            else if(A_second_max <= A[i]){
                A_second_max = A[i];
            }
    }
    for (int j =0; j<N;j++){
        if(A_max == A[j]){
            cout << A_second_max <<endl;
        }else{
            cout << A_max << endl;
        }
    }
     return 0;
}

Measured memory_bytes: 2432
#include <iostream>
#include <algorithm>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<iomanip>
#include<deque>
#include<ctime>
#define sqr(x) (x)*(x)
using namespace std;
long long n,m,i,j,x,y,sum,vis[1000005];
deque<pair<long long,int>/**/> dq;
double start;
int main()
{
	start=clock();
	cin>>n;
	x=n;
	while (x)
	{
		m+=x%10;
		x/=10;
	}
	i=1;
	while ((clock()-start)<900000)
	{
		i++;
		sum=0;
		x=n*i;
		while (x)
		{
			sum+=x%10;
			x/=10;
		}
		m=min(m,sum);
	}
	dq.push_back(make_pair(1ll,1));
	while ((clock()-start)<1800000&&(!dq.empty()))
	{
		x=dq.front().first;
		y=dq.front().second;
		vis[x]=1;
		dq.pop_front();
		if (y>=m)
		{
			cout<<m;
			return 0;
		}
		if (!(x%n))
		{
			cout<<y;
			return 0;
		}
		dq.push_back(make_pair((x+1)%n,y+1));
		if (!vis[(x*10)%n])dq.push_front(make_pair((x*10)%n,y));
	}
	cout<<m;
	return 0;
}

Measured memory_bytes: 2688
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <limits.h>
#include <queue>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
#define REP(i, n) for(int i=0; i<n; i++)
const int INF = 1000000;

int N, M;
vector<int> L[100100];
int DP[100100];

int dfs(int v){
    int m = 0;
    for(int i = 0; i < L[v].size(); i++){
        int next = L[v][i];
        if(DP[next] != -1) m = max(m, DP[next]+1);
        else m = max(m, dfs(next)+1);
    }
    DP[v] = m;
    return m;
}

int main(){
    cin >> N >> M;
    REP(i,M){
        int x,y;
        cin >> x >> y;
        x--, y--;
        L[x].push_back(y);
        //L[y].push_back(x);
    }

    fill(DP, DP+100100, -1);

    int ans = 0;
    REP(i,N){
        if(DP[i] == -1) dfs(i);
    }

    REP(i,N){
        ans = max(ans, DP[i]);
    }
    cout << ans << endl;
    return 0;
}


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

int main() {
    string w;
    cin >> w;
    vector<int> cnt(26);
    for (int i = 0; i < (int)w.size(); i++) {
        cnt.at(w.at(i) - 'a')++;
    }
    for (int i = 0; i < 26; i++) {
        if (cnt.at(i) % 2 != 0) {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
}   

Measured memory_bytes: 256
#include <cstdio>
#include <climits>
#include <cassert>
#include <cmath>
#include <iostream>
#include <string>
#include <algorithm>
#include <numeric>
#include <functional>
#include <tuple>
#include <list>
#include <map>
#include <queue>
#include <stack>
#include <set>
#include <vector>

#define REP(i,s,n) for(int i=(int)(s);i<(int)(n);i++)
#define FOR(x,xs) for(auto &x: xs)

using namespace std;
typedef long long ll;
typedef pair<int,int> PI;
typedef pair<ll,ll> PL;
typedef vector<int> VI;
typedef vector<ll> VL;

int main() {
  ios::sync_with_stdio(false);
  int N;
  cin >> N;
  VL as(3 * N);
  FOR(a, as) {
    cin >> a;
  }
  sort(as.rbegin(), as.rend());
  ll ans = 0;
  REP(i,0,N) {
    ans += as[i * 2 + 1];
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 2560
#![allow(unused)]

use std::cmp::{min, max};

macro_rules! dbg {
    ($($a:expr),*) => {
        use std::io::Write;
        writeln!(
            std::io::stderr(),
            concat!($(stringify!($a), " = {:?}, "),*),
            $($a),*);
    }
}

//
// Based on EbTech's Scanner https://stackoverflow.com/q/56449027
//
struct Scanner<'a, R: std::io::BufRead> {
    reader: R,
    buf: String,
    iter: std::str::SplitWhitespace<'a>,
}

impl<'a, R: std::io::BufRead> Scanner<'a, R> {
    fn new(reader: R) -> Scanner<'a, R> {
        Scanner { reader: reader, buf: String::new(), iter: "".split_whitespace() }
    }

    fn get_str(&mut self) -> &str {
        if let Some(t) = self.iter.next() {
            return t;
        }
        self.buf.clear();
        self.reader.read_line(&mut self.buf).expect("I/O error");
        self.iter = unsafe { std::mem::transmute(self.buf.split_whitespace()) };
        self.get_str()
    }

    fn get<T: std::str::FromStr>(&mut self) -> T {
        self.get_str().parse().ok().expect("Parse error")
    }
}

fn main() {
    let stdin = std::io::stdin();
    solve(Scanner::new(stdin.lock()));
}

const M: i64 = 1000000007;

fn solve<R: std::io::BufRead>(mut sc: Scanner<R>) {
    let h: usize = sc.get();
    let w: usize = sc.get();
    let grid: Vec<Vec<char>> =
        (0..h).map(|_| sc.get_str().chars().collect()).collect();

    // dp[i][j]: マス (i, j) へ辿り着く経路数 mod M
    let mut dp = vec![vec![0; w + 1]; h + 1];

    dp[1][1] = 1; // スタート地点

    for i in 1..(h + 1) {
        for j in 1..(w + 1) {
            dp[i][j] += if grid[i - 1][j - 1] == '.' {
                // 上からと左からの経路数の和
                (dp[i - 1][j] + dp[i][j - 1]) % M
            } else {
                0
            };
        }
    }

    println!("{}", dp[h][w]);
}

Measured memory_bytes: 16636
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

int main()
{
	int N;
	double pos_x[10];
	double pos_y[10];

	double len[10][10];

	double sum = 0.0;

	scanf("%d", &N);

	for (int i = 0; i < N; i++)
	{
		scanf("%lf", &pos_x[i]);
		scanf("%lf", &pos_y[i]);
	}

	for (int i = 0; i < N; i++)
	{
		for (int j = 0; j < N; j++)
		{
			len[i][j] = sqrt(pow(pos_x[i] - pos_x[j], 2) + pow(pos_y[i] - pos_y[j], 2));
			//printf("%lf\n", len[i][j]);
		}
		//printf("\n");
	}

	for (int i = 0; i < N; i++)
	{
		for (int j = 0; j < N; j++)
		{
			sum += len[i][j];
		}
	}

	//printf("%f", sum);

	printf("%lf", sum*2/N/2);

	return 0;
}

Measured memory_bytes: 128
#include<iostream>
using namespace std;
int ss(int n){
	if(n<2)
        return 0;
	for(int i=2; i*i<=n; i++){
		if(n%i==0)
		return 0;
	}
	return 1;
}
int main()
{
    int n;
    cin>>n;
    if(ss(n)==1)
        cout<<n<<endl;
    else{
        while(ss(n)==0)
            n+=1;
        cout<<n<<endl;

    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
using pint = pair<int, int>;
using plint = pair<lint, lint>;
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;

#define ALL(x) (x).begin(), (x).end()
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)


void solve(long long N, long long K, std::string S){
    S[K-1] += 0x20;
    cout << S << "\n";
}

int main(){

    long long N;
    long long K;
    cin >> N >> K;
    std::string S;
    std::cin >> S;
    solve(N, K, S);
    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <string>
#include <vector>
#include <deque>
#include <list>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <cstring>
#include <cctype>
#include <sstream>
#include <set>
#include <map>
#include <queue>
#include <complex>
using namespace std;
#define REP(i,n) for(int i = 0; i < (int)n; i++)
#define FOR(i,a,b) for(int i = a; i < (int)b; i++)
const int INF = 1<<28;

int main() {
	int n;
	while(cin >> n, n) {
    vector< vector<int> > f(n);
    REP(i, f.size()) {
			int m; cin >> m;
      f[i] = vector<int>(m);
			REP(j, m) cin >> f[i][j];
		}
		int k; cin >> k;
    vector<int> l(k);
		int cnt, ans = 0;
		REP(i, k) cin >> l[i];
		REP(i, n) {
			cnt = 0;
      REP(j, f[i].size()) {
				REP(idx, k) if(f[i][j] == l[idx]) cnt++; 
				if(cnt == k) {
					if(!ans) ans = i + 1;
					else ans = -1;
					break;
				}
			}
		}
		if(ans == 0) ans = -1;
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 3128
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
namespace AtCoder
{
    class Program
    {
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }

        static void Main(string[] args)
        {
            //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
            var NABCD = Sarray();
            var N = NABCD[0];
            var A = NABCD[1] - 1;
            var B = NABCD[2] - 1;
            var C = NABCD[3] - 1;
            var D = NABCD[4] - 1;
            var S = ReadLine();
            //A-C間、B-D間に岩が二つある
            for (var i = A; i <= C; ++i)
            {
                if (S[(int)i] == '#' && S[(int)i + 1] == '#')
                {
                    WriteLine("No");
                    return;
                }
            }
            for (var i = B; i <= D; ++i)
            {
                if (S[(int)i] == '#' && S[(int)i + 1] == '#')
                {
                    WriteLine("No");
                    return;
                }
            }
            //D<Cでかつ3連続する空白がない(すぬけとふぬけがすれ違えない)
            if (D < C)
            {
                //右にしか動けないのでB-1～D間に空白が三つ必要
                var have3 = false;
                for (var i = B - 1; i < D; ++i)
                {
                    if (S[(int)i] == '.' && S[(int)i + 1] == '.' && S[(int)i + 2] == '.')
                        have3 = true;
                }
                if (!have3)
                {
                    WriteLine("No");
                    return;
                }
            }
            WriteLine("Yes");
            //Out.Flush();
        }
    }
}

Measured memory_bytes: 13920
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define DUMP(x)  cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for(ll i = m; i < n; i++)
#define IFOR(i, m, n) for(ll i = n - 1; i >= m; i-- )
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define FOREACH(x,a) for(auto& (x) : (a) )
#define ALL(v) (v).begin(), (v).end()

int main(){
  ll k,t; cin >> k >> t;
  vector<ll> a(t);
  REP(i,t) cin >> a[i];
  if(t==1){
    cout << a[0]-1 << endl;
    return 0;
  }

  while(1){
    sort(ALL(a),greater<ll>());
    if(a[1]==0){
      cout << max(0LL,a[0]-1) << endl;
      return 0;
    }
    a[0]--; a[1]--;
  }
}


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

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    // ????????§ ax+by=c, dx+ey=f ????§£?????????????????¨???????????¨???????¨????????????????(1)
    vector<vector<double>> answers;
    double a, b, c, d, e, f;
    int dump;
    while(cin >> a >> b >> c >> d >> e >> f) {
        double det = (double)(a*e-b*d);
        double ansx = (e*c+(-b)*f)/det;
        double ansy = ((-d)*c+a*f)/det;
        if(ansx == 0) ansx = 0.0;
        if(ansy == 0) ansy = 0.0;
        answers.push_back({ansx,ansy});
    }
    for(auto elm : answers) {
        cout << fixed << setprecision(3) << elm[0] << " " << elm[1] << endl;
    }

    return 0;
}

Measured memory_bytes: 3152
#include <iostream>
#include <deque>

using namespace std;

int main() {
	string s;
	cin >> s;
	deque<char>q;
	for (auto c : s) {
		q.push_back(c);
	}
	int ans = 0;
	while (q.size() > 1) {
		if (q.front() != q.back()) {
			ans++;
		}
		q.pop_back();
		q.pop_front();
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>

int main(){
    int N;
    int sum=0;
    int max=0;
    scanf("%d",&N);
    int a[N];
    for (int i = 0; i < N; i++){
        scanf("%d",&a[i]);
        sum+=a[i];
        if(max<a[i]) max=a[i];
    }
    if(sum-max<=max) printf("No");
    else printf("Yes");
}

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

int number[3][200], score[200];

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

	for(int i=0; i<N; i++) for(int j=0; j<3; j++) cin >> number[j][i];

	for(int i=0; i<3; i++){
		for(int j=0; j<N; j++){
			if(count(number[i], number[i]+N, number[i][j]) == 1){
				score[j] += number[i][j];
			}
		}
	}

	for(int i=0; i<N; i++) cout << score[i] << endl;
}

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

int main(){

    int N;
    cin >> N;

    long double sum = 0;
    long double x;
    string s;

    for(int i = 0; i < N; i++){
        cin >> x;
        cin >> s;

        if(s == "JPY") sum += x;
        else sum += x *  380000.0;
    }
    cout << sum << endl;

}

Measured memory_bytes: 256
def get_i() #空白区切の入力を数値(整数)の配列で返す
  return gets.chomp.split(" ").map(&:to_i)
end
def get_f() #空白区切の入力を数値(実数)の配列で返す
  return gets.chomp.split(" ").map(&:to_f)
end
def get() #空白区切の入力を文字列の配列で返す
  return gets.chomp.split(" ")
end
def get_nsp() #入力されたものを一文字ずつに区切った文字列の配列で返す
  return gets.chomp.split("")
end
def yn_judge(bool,y="Yes",n="No") #boolに真偽を投げることで、trueならy、falseならnの値を出力する
  return bool ? y : n 
end
def array(size,n=1,init=nil) #nに配列の次元数、sizeに配列の大きさ、initに初期値を投げることでその配列を返す
  if n==1
    return Array.new(size){init}
  else
    return Array.new(n).map{Array.new(size){init}}
  end
end

puts yn_judge((get.join("").to_i%4).zero?,"YES","NO")

Measured memory_bytes: 1916
#include<bits/stdc++.h>
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define RFOR(i,a,b) for(int i=a;i>=b;i--)
#define inf 0x3f3f3f3f
using namespace std;

const int maxn = 2e5+5;
typedef unsigned long long ULL;
typedef long long ll;

int n,m,A[maxn];
vector<int>G[maxn];

int main(){
    cin>>n>>m;
    FOR(i,1,m){
        int x;cin>>x;
        FOR(j,1,x){
            int y;cin>>y;A[y]++;
        }
    }
    int ans=0;
    FOR(i,1,n)if(!A[i])ans++;
    cout<<ans<<endl;
}


Measured memory_bytes: 8316
#include "bits/stdc++.h"
 
typedef long long ll;
#define int ll
#define fi first
#define se second
#define SORT(a) sort(a.begin(),a.end())
#define rep(i,n) for(int i = 0;i < (n) ; i++) 
#define REP(i,n) for(int i = 0;i < (n) ; i++) 
#define MP(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define INF LLONG_MAX/2
#define all(x) (x).begin(),(x).end()
#define debug(x) cerr<<#x<<": "<<x<<endl
#define debug_vec(v) cerr<<#v<<":";rep(i,v.size())cerr<<" "<<v[i];cerr<<endl
using namespace std;
int MOD = 1000000007;

signed main(){
    int n,d;
    cin >> n >> d;
    int x[11][11];
    int cnt = 0;
    rep(i,n) rep(j,d) cin >> x[i][j];
    
    for(int i = 0;i < n;i++){
        for(int j = i+1;j < n;j++){
            int dist = 0;
            for(int k = 0;k < d;k++){
                dist += (x[i][k] - x[j][k])*(x[i][k] - x[j][k]);
            }
            if(dist == (int)((int)sqrt(dist)*(int)sqrt(dist))){
                cnt++;
            }
        }
    }
    cout << cnt << endl;


    
    
    return 0;
}

// g++ -std=c++14 code1.cpp
// rm -r -f test;oj dl https://cf17-final-open.contest.atcoder.jp/tasks/cf17_final_a
// rm -r -f test;oj dl http://abc133.contest.atcoder.jp/tasks/abc133_b

Measured memory_bytes: 256
import java.io.*;
public class Main {
	public static void main(String[] args) throws IOException{
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		String input = in.readLine();
		
		String[] x = input.split(" ");
		
		int a = Integer.parseInt(x[0]);
		int b = Integer.parseInt(x[1]);
		
		if(a>b){
			System.out.println("a > b");
		}else if(a == b){
			System.out.println("a == b");
		}else if(a<b){
			System.out.println("a < b");
		}
	}

}

Measured memory_bytes: 24204
#include <bits/stdc++.h>
using namespace std;
 
int N, M;
int A[3];
vector<int> G[51];
bool used[51];
bool dp[101][51][51];  // a step, b start, c goal
 
int main(){
 
  cin>>N>>M;
  for(int i=0;i<3;i++)cin>>A[i];
  for(int i=0;i<M;i++){
    int f,t;
    cin>>f>>t;
    f--;t--;
    G[f].push_back(t);
  }
 
  for(int i=0;i<N;i++)
    dp[0][i][i] = true;
  for(int i=1;i<101;i++){
    for(int j=0;j<N;j++){
      for(int k=0;k<N;k++){
        if(dp[i-1][j][k]){
          for(int to : G[k]){
            dp[i][j][to] = true;
          }
        }
      }
    }
  }
   
  used[N-1] = true;
  for(int ite=1;;ite++){
    bool ok = false;
    vector<int> idx;
    for(int i=0;i<N;i++){
      if(used[i])continue;
      int cnt = 0;
      for(int j=0;j<3;j++){
        int a = A[j];
        for(int k=0;k<N;k++){
          if(dp[a][i][k] && used[k]){
              cnt++;
              break;
          }
        }
      }
      // OK
      if(cnt == 3){
        ok=true;
        idx.push_back(i);
      }
    }
    if(ok){
      for(int i : idx){
        used[i]=true;
      }
      if(used[0]){
        cout<<ite<<endl;
        return 0;
      }
    }
    else{
      break;
    }
  }
  cout<<"IMPOSSIBLE"<<endl;
   
  return 0;
}

Measured memory_bytes: 3420
// 標準入力
var fs = require('fs'),
length = fs.fstatSync(process.stdin.fd).size,
buffer = new Buffer(length),
bytesRead = fs.readSync(process.stdin.fd, buffer, 0, length, 0),
input = buffer.toString('utf8', 0, bytesRead).split('\n');
main();
    
// ここから
function main(){
  var primeNumbers = calcPrimeNumbers();
  
  for(var i = 0, len = input.length - 1; i < len; i++){
    var inp = input[i] - 0;
    
    var min = max = 0;
    for(var j = 0, jlen = primeNumbers.length; j < jlen; j++){
      var nowPrimeNumber = primeNumbers[j];
      var nextPrimeNumber = primeNumbers[j+1];
      
      if(nowPrimeNumber < inp && nextPrimeNumber >= inp){
        min = nowPrimeNumber;
      }
      if(nowPrimeNumber <= inp && nextPrimeNumber > inp){
        max = nextPrimeNumber;
        break;
      }
    
    }
    
    console.log(min, max);
  }
   
     
}
   
function calcPrimeNumbers(){
  var max = 50023;
  var primeNumbers = new Int8Array(max + 1);
   
  // 除外
  primeNumbers[0] = primeNumbers[1] = 1;
  for(var i = 2, maxI = ~~Math.sqrt(max); i <= maxI; i++){
    if(primeNumbers[i]){
      continue;
    }
       
    for(var j = (i<<1); j <= max; j+=i){
      primeNumbers[j] = 1;
    }
  }
   
  var primeNums = new Int32Array(5135);
  var j = 0;
  for(var i = 1; i <= max; i++){
    if(!primeNumbers[i])
      primeNums[j++] = i;
  }
     
  return primeNums;
}

Measured memory_bytes: 9012
#include"bits/stdc++.h"

//#include<bits/stdc++.h>
using namespace std;
#define print(x) cout<<x<<endl;
#define rep(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a) for(int i=0;i<a;i++)
typedef long long ll;
typedef pair<int, int> PI;
typedef pair<int, PI> V;
typedef vector<int> VE;
const ll mod = 100000000000;

int n;
int a[102];

int main() {
	cin >> n;
	REP(i, n)cin >> a[i];
	int min = mod;
	int max = 0;
	REP(i, n) {
		if (min > a[i])min = a[i];
		if (max < a[i])max = a[i];
	}
	print(max - min);
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main() {
    int H, W;
    cin >> H >> W;
    vector<string> s(H);
    for (auto j=0; j < H; ++j) {
        cin >> s[j];
    }
    bool canDraw = true;
    for (auto j=0; j < H; j++) {
        for (auto k=0; k < W; k++) {
            if (s[j][k] == '#') {
                if(H > 1) {
                    if (j == 0) {
                        if (s[1][k] == '#') continue;
                    } else if (j == H-1) {
                        if (s[H-2][k] == '#') continue;
                    } else {
                        if (s[j-1][k] == '#') continue;
                        if (s[j+1][k] == '#') continue;
                    }
                }
                if (W > 1) {
                    if (k == 0) {
                        if (s[j][1] == '#') continue;
                    } else if (k == W-1) {
                        if (s[j][W-2] == '#') continue;
                    } else {
                        if (s[j][k-1] == '#') continue;
                        if (s[j][k+1] == '#') continue;
                    }
                }
                canDraw = false;
            }
        }
        if (!canDraw) {
            break;
        }
    }
    if (canDraw) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}

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

#define fi first
#define se second

const int N = 444;
const long long mod = 1e9 + 7;

using namespace std;

int n;
long long a[N];
long long d[N][N];

int main()
{
        //freopen("input.txt", "r", stdin);
        //freopen("output.txt", "w", stdout);
        ios_base::sync_with_stdio(0);

        cin >> n;
        for(int i = 1; i <= n; i++){
                cin >> a[i];
                a[i] += a[i - 1];
        }
        for(int i = n; i >= 1; i--){
                for(int j = i + 1; j <= n; j++){
                        d[i][j] = 1e18;
                        for(int h = i; h < j; h++){
                                d[i][j] = min(d[i][j], d[i][h] + d[h + 1][j]);
                        }
                        d[i][j] += a[j] - a[i - 1];
                }
        }
        cout << d[1][n] << "\n";
}



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

using namespace std;
using ll = long long;
using P = pair<int,int>;
using Graph = vector<vector<int>>;

ll lcm(ll a, ll b) {
    return a / __gcd(a, b) * b;
}

int main(void) {
    int a, b;
    cin >> a >> b;
    cout << lcm(a, b)  << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include<algorithm>
#include <stdio.h>
#include <bitset>
#include<math.h>
#include<list>
#include<map>
using namespace std;
typedef long long ll;
#define PI 3.14159265358979323846  

int main() {
	int n,k;
	string ap = "APPROVED";
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> k;
		if (k % 2 == 0) {
			if (k % 5 != 0 && k % 3 != 0) {
				ap = "DENIED";
				break;
			}
		}
	}
	cout << ap << endl;
}

Measured memory_bytes: 256
from fractions import gcd
N = int(input())
A = list(map(int,input().split()))

lc = [0]
for a in A:
    lc.append(gcd(lc[-1], a))
rc = [0]
for a in A[::-1]:
    rc.append(gcd(rc[-1], a))
rc.reverse()

ans = 0
for l,r in zip(lc,rc[1:]):
    g = gcd(l,r)
    ans = max(ans, g)
print(ans)

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

int main() {
    int n;
    cin >> n;
    vector <int> v(n);
    rep(i,n) cin >> v[i];
    sort(v.begin(), v.end());
    cout << *(v.end()-1)-*(v.begin()) << endl;
}


Measured memory_bytes: 256
#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()
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 int ll

int n,a;
int x[100];
int dp[100][10000];


signed main(){
  cin>>n>>a;
  rep(i,n){
    cin>>x[i+1];
    x[i+1]-=a;
  }

  dp[0][n*a]=1;
  FOR(i,1,n+1){
    rep(j,2*n*a+1){
      if(j-x[i]<0||j-x[i]>2*n*a)
        dp[i][j] = dp[i-1][j];
      else
        dp[i][j]=dp[i-1][j]+dp[i-1][j-x[i]];
    }
  }

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


Measured memory_bytes: 3456
N=int(input())
T,A=map(int,input().split())
H=list(map(int,input().split()))
c=100000
ans=0
for i in range(N):
  if c>abs(T-H[i]*0.006-A):
    c=abs(T-H[i]*0.006-A)
    ans=i+1
print(ans)

Measured memory_bytes: 9192
#include "bits/stdc++.h"

#define FOR(i,l,r) for(size_t i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define REP1(i,n) FOR(i,1,n+1)
#define INF 100000000000ULL

using namespace std;

namespace Kyopro {

    using ll = long long;

    const double PI = acos(-1);

    const ll MOD = 998244353LL;

    const int MAX = 210000;

    long long fac[MAX], finv[MAX], inv[MAX];

    // テーブルを作る前処理
    void COMinit() {
        fac[0] = fac[1] = 1;
        finv[0] = finv[1] = 1;
        inv[1] = 1;
        for (int i = 2; i < MAX; i++) {
            fac[i] = fac[i - 1] * i % MOD;
            inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
            finv[i] = finv[i - 1] * inv[i] % MOD;
        }
    }

    // 二項係数計算
    long long COM(int n, int k) {
        if (n < k) return 0;
        if (n < 0 || k < 0) return 0;
        return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
    }

    long long modpow(long long a, long long n, long long mod) {
        long long res = 1;
        while (n > 0) {
            if (n & 1) res = res * a % mod;
            a = a * a % mod;
            n >>= 1;
        }
        return res;
    }

    ll f(size_t m, size_t n) {
        ll ret = (m * modpow(m - 1, n - 1, MOD)) % MOD;
        return ret;
    }

    long long modinv(long long a, long long m) {
        long long b = m, u = 1, v = 0;
        while (b) {
            long long t = a / b;
            a -= t * b; swap(a, b);
            u -= t * v; swap(u, v);
        }
        u %= m;
        if (u < 0) u += m;
        return u;
    }

    ll combinations2(size_t n, size_t k) {
        ll r = 1;
        for (ll d = 1; d <= k; ++d) {
            r *= n--;
            r = r % MOD;
            r = r * modinv(d, MOD);
            r = r % MOD;
        }
        if (r > MOD / 2) {
            r -= MOD;
        }
        return r;
    }
}

using namespace Kyopro;

vector<ll> v;

void solve() {
    ll x, n;
    cin >> x >> n;
    v.resize(n);
    REP(i, n) {
        cin >> v.at(i);
    }
    ll ans = x;
    ll diff = 0;
    while (true) {
        if (find(v.begin(), v.end(), x - diff) == v.end()) {
            ans = x - diff;
            break;
        }
        if (find(v.begin(), v.end(), x + diff) == v.end()) {
            ans = x + diff;
            break;
        }
        diff++;
    }
    cout << ans << endl;
}

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

    COMinit();

    solve();

    return 0;
}

Measured memory_bytes: 8576
import java.util.Scanner;
public class Main{
	public static void main(String[]args){
		Scanner sc = new Scanner(System.in);
		int i,t;
		int w = sc.nextInt();
		int n = sc.nextInt();
		int[] values = new int[w];
		for(i=0;i<values.length;i++){
			values[i]=i+1;
		}
		for(i=0;i<n;i++){
			String str = sc.next();
			String[] ab = str.split(",");
			int a = Integer.parseInt(ab[0])-1;
			int b = Integer.parseInt(ab[1])-1;
			t=values[a];
			values[a]=values[b];
			values[b]=t;
		}
		for(i=0;i<values.length;i++){
			System.out.printf("%d\n",values[i]);
		}
	}
}

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

using ll = long long;

int main() {
    string S, T;
    cin >> S >> T;
    int m = S.size(), n = T.size();
    vector<int> Ssum(m + 1, 0), Tsum(n + 1, 0);
    rep(i, m) Ssum[i + 1] = Ssum[i] + 1 + (S[i] == 'B');
    rep(i, n) Tsum[i + 1] = Tsum[i] + 1 + (T[i] == 'B');
    int q, a, b, c, d;
    cin >> q;
    rep(i, q) {
        cin >> a >> b >> c >> d;
        if ((Ssum[b] - Ssum[a - 1] - Tsum[d] + Tsum[c - 1]) % 3 == 0) {
            cout << "YES" << endl;
        } else {
            cout << "NO" << endl;
        }
    }
}

Measured memory_bytes: 1664
#include<stdio.h>
#define PIE 3.14159265359
int main(void)
{
	double r,s,l;
	scanf("%lf", &r);

	s = r*r*PIE;
	l = 2*r*PIE;

	printf("%f %f\n", s, l);

	return 0;
}


Measured memory_bytes: 2044
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
using ll = long long;
string char_to_string(char val) {
  return string(1, val);
}
int char_to_int(char val) {
  return val - '0';
}
template<class T> inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template<class T> inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
int vector_finder(std::vector<ll> vec, int number) {
  auto itr = std::find(vec.begin(), vec.end(), number);
  size_t index = std::distance( vec.begin(), itr );
  if (index != vec.size()) { // 発見できたとき
    return 1;
  }
  else { // 発見できなかったとき
    return 0;
  }
}

int main() {
  int M, D; cin >> M >> D;
  int a, b; cin >> a >> b;
  int ans = 0;
  if(M == 4 || M == 6 || M == 9 || M == 11) {
    if(D == 30) {
      ans = 1;
    }
  } else if(M == 2) {
    if(D == 28) {
      ans = 1;
    }
  } else {
    if(D == 31) {
      ans = 1;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
#define MAX 1000
char t[MAX][MAX];
bool f[26];
int h,w;
vector<int> Y[26],X[26];

bool calc(int ay,int ax,int by,int bx){
  if(ay>by)swap(ay,by);
  if(ax>bx)swap(ax,bx);
  for(int i=ay;i<=by;i++)
    for(int j=ax;j<=bx;j++)
      if(t[i][j]!='.')return false;
  return true;
}

bool check(int id){
  int ay=Y[id][0];
  int ax=X[id][0];
  int by=Y[id][1];
  int bx=X[id][1];

  if(abs(ay-by)+abs(ax-bx)==1)return false;
  
  t[ay][ax]='.';
  t[by][bx]='.';
  
  if(calc(ay,ax,ay,bx)&&
     calc(ay,bx,by,bx)&&
     t[ay][bx]=='.'){
    f[id]=false;
    return true;
  }
  
  if(calc(ay,ax,by,ax)&&
     calc(by,ax,by,bx)&&
     t[by][ax]=='.'){
    f[id]=false;
    return true;
  }
  
  t[ay][ax]='A'+id;
  t[by][bx]='A'+id;
  return false;
}

int main(){
  cin>>h>>w;
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      cin>>t[i][j];
      if(t[i][j]=='.')continue;
      int id=t[i][j]-'A';
      Y[id].push_back(i);
      X[id].push_back(j);
      f[id]=true;
    }
  }
    
  int ans=0,cnt;
  while(1){
    cnt=0;
    for(int i=0;i<26;i++){
      if(!f[i])continue;
      if(check(i))cnt+=2;
    }
    if(cnt==0)break;
    ans+=cnt;
  }
  cout<<ans<<endl;
  return 0;
}

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

using namespace std;

int main() {
	int n; cin >> n; vector<pair<string, int>> arr; int br = 0, count = 0;
	while (n--) {
		string s; int val; cin >> s >> val;
		arr.push_back({ s,val });

	}
	string q; cin >> q;
	for (int i = 0; i < arr.size(); i++) {
		if (arr[i].first == q) {
			br = i;
			break;
		}
	}
	for (int i = br + 1; i < arr.size(); i++) {
		count += arr[i].second;
	}
	cout << count << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;
    using namespace std;
 
    int main(){
      int n,a;
      int t;
      cin >> n >> t >> a;
      int h[n];
      rep(i,n)cin >> h[i];
      int d=abs(1000*a-1000*t+6*h[0]);
      rep(i,n){
        d=min(d,abs(1000*a-1000*t+6*h[i]));
      }
      rep(i,n){
       if(d==abs(1000*a-1000*t+6*h[i])){
         cout << i+1 << endl;
         return 0;
       }
      }
      return 0;}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int>pii;
const int mn=200+10;
const ll inf=0x3f3f3f3f3f3f3f3f;
const ll mod=1e9+7;
ll basis[64];
ll a[mn];
bool add(ll x){
    for(int i=60;i>=0;i--)if((x>>i)&1){
        if(basis[i])x^=basis[i];
        else{
            basis[i]=x;
            return 1;
        }
    }
    return 0;
}
int main(){
    cin.tie(0);
    cin.sync_with_stdio(0);
    int tc;
    cin>>tc;
    while(tc--){
        memset(basis,0,sizeof(basis));
        int n;
        cin>>n;
        for(int i=0;i<n;i++)cin>>a[i];
        string s;
        cin>>s;
        bool f=0;
        for(int i=n-1;i>=0;i--){
            if(s[i]-'0'){
                if(add(a[i])){
                    f=1;
                }
            }
            else add(a[i]);
        }
        printf("%d\n",(int)f);
    }
}

Measured memory_bytes: 3688
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,cnt=0,i,j,k,l,cnt1=0;
    cin>>n;
    vector<int>v;
    for(i=0; i<n; i++)
    {
        cin>>k;
        //v.push_back(k);
        if(k%2==0)
        {
            cnt++;
            v.push_back(k);
            //ar[i]=k;
        }
    }
    sort(v.begin(),v.end());
    for(i=0;i!=v.size(); i++)
    {
        if(v[i]%3==0||v[i]%5==0)
        {
            cnt1++;
        }
    }
    if(cnt1==cnt)
    {
        cout<<"APPROVED"<<endl;
    }
    else
    {
        cout<<"DENIED"<<endl;
    }
    return 0;
}


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

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

typedef long long ll;
const ll MOD = 1e9 + 7;

int main() {
  int A, B;
  std::cin >> A >> B;

  int ans = 0, cnt = 1;
  while(cnt < B) {
    cnt += A - 1;
    ++ans;
  }
  std::cout << ans << '\n';
}


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

#define M 100005
#define MOD 1000000007
#define PI 3.14159265358979323846
#define ep emplace_back
#define mk make_pair
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()

typedef long long int lli;
typedef unsigned long long int ulli;
typedef pair<int,int> PII;
typedef pair<lli,lli> PLL;

int main()
{

//    freopen("input.txt","r",stdin);

    int n;
    cin>>n;

    vector<lli> v(n);
    for(int i=0;i<n;i++)
        cin>>v[i];

    vector<lli> dp(n,0);
    dp[0] = 0;
    dp[1] = dp[0] + abs(v[1]-v[0]);

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

    cout<<dp[n-1]<<"\n";
}

Measured memory_bytes: 4804
import java.util.Scanner;

public class Main {

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

	    long a=gl();
	    long b=gl();
	    long c=gl();

	    long v=0;
	    long ad=a;
	    long bd=b;
	    long cd=c;
        while(true) {
        	if(ad%2==1 || bd%2==1 || cd%2==1) {
        		break;
        	} else if((a==ad && b==bd && c==cd && v!=0)) {
        		System.out.println(-1);
        		return;
        	}
        	long adb=ad;
        	long bdb=bd;
        	long cdb=cd;
        	ad=bdb/2+cdb/2;
        	bd=cdb/2+adb/2;
        	cd=adb/2+bdb/2;
        	v++;
        }

		System.out.println(v);
	}

	// 文字列として入力を取得
	public static String gs() {
		return scanner.next();
	}

	// intとして入力を取得
	public static int gi() {
		return Integer.parseInt(scanner.next());
	}

	// longとして入力を取得
	public static long gl() {
		return Long.parseLong(scanner.next());
	}

	// doubleとして入力を取得
	public static double gd() {
		return Double.parseDouble(scanner.next());
	}
}

Measured memory_bytes: 35756
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair< ll, ll > Pi;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep2(i,n) for(int i=1;i<=(n);i++)
#define rep3(i,i0,n) for(int i=i0;i<(n);i++)
#define pb push_back
#define mod 1000000007
const ll INF = 1LL << 60;
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; }
ll gcd(ll a, ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) {return a/gcd(a,b)*b;}
#define all(x) x.begin(), x.end()
#define mp make_pair
bool compare(Pi a, Pi b) {
    if(a.first != b.first){
        return a.first < b.first;
        
    }else{
        return a.second < b.second;
    }
}


bool In_map(ll y,ll x,ll h,ll w){
    if(y<0 || x<0 || y>=h || x>=w){
        return 0;
    }else{
        return 1;
    }
}
const vector<ll> dx{1,0,-1,0};
const vector<ll> dy{0,1,0,-1};


int main() {
    ll N;
    cin >>N;
    vector<vector<bool>>M(N,vector<bool>(5));
    vector<ll>cnt(5);
    rep(i,N){
        string S;
        cin>>S;
        if(S[0]=='M'){
            cnt[0]++;
        }else if(S[0]=='A'){
            cnt[1]++;
        }else if(S[0]=='R'){
            cnt[2]++;
        }else if(S[0]=='C'){
            cnt[3]++;
        }else if(S[0]=='H'){
            cnt[4]++;
        }
    }
    ll ans=0;
    rep(i,5){
        rep3(j,i+1,5){
            rep3(k,j+1,5){
                ans+=cnt[i]*cnt[j]*cnt[k];
            }
        }
    }
    cout << ans << endl;


    return 0;
    

}

Measured memory_bytes: 10396
N = gets.to_i
P = gets.chomp.split(" ").map(&:to_i)
Q = gets.chomp.split(" ").map(&:to_i)

NUM = [1, 2, 3, 4, 5, 6, 7, 8]
po = 0
qo = 0
NUM[0, N].permutation(N).each_with_index{|n, idx|
  po = idx if n == P
  qo = idx if n == Q
}

puts (po - qo).abs


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

const ll mod = 1e9+7;
const ll INF = 1e18;
const double pi = acos(-1.0);


int main(void)
{
    ll n,k; cin>>n>>k;
    if(k==1) cout << 0 << endl;
    else cout << n-k << endl;
    return 0;
}

Measured memory_bytes: 3572
n = int(input())
a, b = map(int, input().split())
P = list(map(int, input().split()))

p1, p2, p3 = 0, 0, 0
for p in P:
    if p <= a:
        p1 += 1
    elif p <= b:
        p2 += 1
    else:
        p3 += 1

print(min(p1, p2, p3))


Measured memory_bytes: 3060
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
#include <climits>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;

const int N = 100000;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    VI odd_map(N + 1, 0);
    VI even_map(N + 1, 0);
    REP(i, n) {
        int v;
        cin >> v;
        if(i % 2 == 0) even_map[v]++;
        else odd_map[v]++;
    }

    int even_max1 = 0;
    int even_max_i1 = 0;
    REP(i, N) {
        if(even_map[i] >= even_max1) {
            even_max1 = even_map[i];
            even_max_i1 = i;
        }
    }
    int even_max2 = 0;
    int even_max_i2 = 0;
    REP(i, N) {
        if(i == even_max_i1) continue;
        if(even_map[i] >= even_max2) {
            even_max2 = even_map[i];
            even_max_i2 = i;
        }
    }
    int odd_max1 = 0;
    int odd_max_i1 = 0;
    REP(i, N) {
        if(odd_map[i] >= odd_max1) {
            odd_max1 = odd_map[i];
            odd_max_i1 = i;
        }
    }
    int odd_max2 = 0;
    int odd_max_i2 = 0;
    REP(i, N) {
        if(i == odd_max_i1) continue;
        if(odd_map[i] >= odd_max2) {
            odd_max2 = odd_map[i];
            odd_max_i2 = i;
        }
    }

    if(even_max_i1 != odd_max_i1) {
        cout << n - even_max1 - odd_max1 << endl;
    } else {
        cout << n - max(even_max1 + odd_max2, even_max2 + odd_max1) << endl;
    }

    return 0;
}


Measured memory_bytes: 1024
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<iostream>

using namespace std;


void Solution()
{
    int a[3] = {1, 0, 0};
    
    char m, n;
    char comma;
    
    while (cin>>m>>comma>>n)
    {
        int temp = a[m - 'A']; //swap, and based on ASC||
        a[m - 'A'] = a[n - 'A'];
        a[n - 'A'] = temp;
    }
    
    for(int i=0; i < 3; i++)
    {
        if(a[i] == 1)
        {
            cout<<(char)(i + 'A')<<endl;  //change data to char type
            break;
        }
    }
}

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

Measured memory_bytes: 1132