akhauriyash/Code-Regression huggingface dataset:
#define _CRT_SECURE_NO_WARNINGS
#include"bits/stdc++.h"
#define INF          1e9
#define INFLL        1e18
#define EPS          1e-9
#define MOD          1000000007
#define REP(i,n)     for(ll i=0,i##_len=(n);i<i##_len;++i)
#define REP1(i,n)    for(ll i=1,i##_len=(n);i<=i##_len;++i)
#define REPR(i,n)    for(ll i=(n)-1;i>=0;--i)
#define REPR1(i,n)   for(ll i=(n);i>0;--i)
#define REPC(i,obj)  for(auto i:obj)
#define ALL(obj)     (obj).begin(),(obj).end()
#define SETP(n)      cout<<fixed<<setprecision(n)
#define VV(T,h,w)    vector<vector<T>>(h,vector<T>(w))
#define VVI(T,h,w,i) vector<vector<T>>(h,vector<T>(w,i))
using namespace std;
using ll = long long;
template<typename T = ll>inline T in() { T ret; cin >> ret; return ret; }

int main()
{
    ll n = in(), m = in();
    vector<pair<ll, ll>>vp(m);
    REP(i, m) {
        ll a = in(), b = in();
        vp[i] = make_pair(a, b);
    }
    sort(ALL(vp), [](const pair<ll, ll> & p1, const pair<ll, ll> & p2) {return p1.second < p2.second || p1.second == p2.second && p1.first < p2.first; });
    ll dj = 0, now = 1;
    REP(i, m) {
        if (vp[i].first >= now) {
            ++dj;
            now = vp[i].second;
        }
    }
    cout << dj << endl;
}

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

using ll = long long;
using ull = unsigned long long;
const ll INF = 4e18;
const ll MOD = 1e9+7;

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int a[40] = {};
  int n, m;
  cin >> n >> m;
  for (int i = 0; i < n; i++) {
    int k;
    cin >> k;
    for (int j = 0; j < k; j++) {
      int tmp;
      cin >> tmp;
      a[tmp]++;
    }
  }
  int cnt =0;
  for (int i = 1; i <= m; i++) {
    if (a[i] == n) cnt++;
  }
  cout << cnt << endl;
  return 0;
}


Measured memory_bytes: 256
def solve():
    mod = 10 ** 9 + 7

    n = int(input())
    a = tuple(map(int, input().split()))

    ret = 1
    cnt = [0] * (n + 10)
    cnt[0] = 3

    for x in a:
        cnt[x + 1] += 1
        ret = (ret * cnt[x]) % mod
        cnt[x] -= 1

    print(ret)


if __name__ == '__main__':
    solve()


Measured memory_bytes: 14524
#include<iostream>
#include<vector>
#include<map>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<string>
#include<algorithm>
#include<stack>
#include<queue>
#include<set>
#include<bitset>
#include<iomanip>
#define BUG puts("no bug")
#define sci(x) scanf("%d",&x)
#define scl(x) scanf("%lld",&x)
#define ll long long
#define ull unsigned long long
#define REP(a,b,c) for(int a=b;a<=c;a++)
#define PER(a,b,c) for(int a=b;a>=c;a--)
#define lb(a) (a&(-a))
#define pp (p<<1)
#define ppp (p<<1|1)
#define pi pair<int,int>
#define pii pair<pair<int,int>,int>
using namespace std;
const int MAXN=1e6+5;
int n,m,t;
int v[MAXN];
string s;
int main(){
    cin>>s;
    for(int i=0;i<s.size();i++)if(s[i]=='7'){
        cout<<"Yes";
            return 0;
    }
    cout<<"No";
}

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

int main() {
  int K;
  cin >> K;
  int A, B;
  cin >> A >> B;
  string result;
  if (B/K > (A-1)/K) {
    result = "OK";
  } else {
    result = "NG";
  }
  cout << result << endl;
  return 0;
}

Measured memory_bytes: 3620
N=int(input())
tmp=0
D1=0
D2=0

count=0

for i in range(N):
  tmp=input().split()
  D1=int(tmp[0])
  D2=int(tmp[1])
  if(D1==D2):
    count+=1
  else:
    count=0
  if(count==3):
    break
    
    
if(count==3):
  print("Yes")
else:
  print("No")
    

Measured memory_bytes: 9112
/**
 * @author torith
 * @date 2019-02-03
 */

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

ll power(ll a, ll r) {
    ll sum = 1;
    while (r > 0) {
        if ((r & 1) == 1) {
            sum *= a;
        }
        a *= a;
        r >>= 1;
    }
    return sum;
}

int main(){

    cin.tie(0);
    ios::sync_with_stdio(false);

    int N; cin >> N;
    ll K; cin >> K;

    int max_bit = 0;
    ll tmp = K;
    while(tmp != 0){
        tmp >>= 1;
        max_bit++;
    }

    vector<int> one(41);
    vector<int> zero(41);

    for (int i = 0; i < N; ++i) {
        ll t; cin >> t;
        for (int j = 0; j < 41; ++j) {
            ll tmp = t >> j;
            if((tmp & 1) == 1) {
                one[j] += 1;
                max_bit = max(j, max_bit);
            }
            else zero[j] += 1;
        }
    }


    ll dk = 0;
    ll ans = 0;
    for (int i = max_bit; i >= 0; --i) {
        if(one[i] >= zero[i] || dk + power(2,i) > K) {  // その桁に0を選ぶ
            ans += power(2, i) * one[i];
        }else{      // その桁に1を選ぶ
            ans += power(2, i) * zero[i];
            dk += power(2, i);
        }
    }

    cout << ans << "\n";


    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
//#include<iostream>
//#include<vector>
//#include<map>
//#include<math.h>
//#include<algorithm>

#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rep2(i,a,n) for(int i = (int)(a); i <= (int)(n); i++)
#define rrep(i,n) for(int i = (int)(n-1); i > -1; i--)
#define rrep2(i,n,a) for(int i = (int)(n); i >= (int)(a); i--)

#define fi first
#define se second

using namespace std;

using ll = long long;
using v_int = vector<int>;
using v2_int = vector<v_int>;
using v_ll = vector<ll>;
using v2_ll = vector<v_ll>;
using v_string = vector<string>;
using v_bool = vector<bool>;
using v2_bool = vector<v_bool>;
using pii = pair<int, int>;
using mii = map<int, int>;

const double PI = 3.1415926535897932;
const int INF = (int)2e9;
const ll LINF = (ll)2e18;
const ll MOD = 1000000007;
const int dc[8] = {1, -1, 0,  0, 1, -1,  1, -1};
const int dr[8] = {0,  0, 1, -1, 1,  1, -1, -1};

template<typename T, typename U> inline
ostream& operator<<(ostream &o, pair<T,U> &p) {
    return o << "{" << p.first << "," << p.second << "}";
}
template<typename T> inline
istream& operator>>(istream &is, vector<T> &vec) {
    for(auto &v : vec) { is >> v; }
    return is;
}
template<typename T> inline
ostream& operator<<(ostream &os, vector<T> &vec) {
    for(auto &v : vec) { os << v << ",";}
    return os;
}
template<typename T> inline
ostream& operator<<(ostream &os, vector<vector<T> > &mat) {
    for(auto &row : mat) { os << row << endl; }
    return os;
}

template<typename T> inline
void chmin(T &a, T b) { a = min(a, b); }
template<typename T> inline
void chmax(T &a, T b) { a = max(a, b); }

int main(void)
{
    int sum = 0;
    rep(i,3) {
        int a;
        cin >> a;
        sum += a;
    }
    if(sum <= 21) {
        cout << "win" << endl;
    } else {
        cout << "bust" << endl;
    }
    return 0;
} /*atcoder*/



Measured memory_bytes: 3560
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define rep( i, n, m ) for(int i = ( n ); i < ( m ); i++)
#define rep_d( i, n, m ) for(int i = ( n ) - 1; i >= ( m ); i--)
#define sort_asc( X ) sort(( X ).begin(), ( X ).end())
#define sort_desc( X ) sort(( X ).begin(), ( X ).end(), greater <>())

template <class T> bool chmax( T& a, T b );
template <class T> bool chmin( T& a, T b );
int* eratosthenes( int N );
bool bit_search( int pattern, int N );
template <class T> void cumulative_sum( T array, size_t N );

const ll INF = 1LL << 60;
const int k_mod = 1e9 + 7;

int main( void ){
	int A, B, C, D;
	cin >> A >> B >> C >> D;
	if (B < C || D < A)
		cout << 0 << endl;
	else
	cout << min(B, D) - max(A, C) << endl;
}

int* eratosthenes( int N ){
	int* prime_array = new int[ N + 1 ];
	int lim = N;
	prime_array[ 0 ] = 0;
	prime_array[ 1 ] = 0;
	rep( i, 2, N + 1 ){
		prime_array[ i ] = 1;
	}
	rep( i, 2, lim ){
		if (prime_array[ i ] == 0)
			continue;
		lim = N / i;
		for(int j = i * 2; j < N + 1; j += i){
			prime_array[ j ] = 0;
		}
	}
	return prime_array;
}
template <class T> void cumulative_sum( T array, size_t N ) {
	rep( i, 1, N + 1 ){
		array[ i ] += array[ i - 1 ];
	}
}
template <class T> bool chmax( T& a, T b ) {
	if (a < b){
		a = b; return true;
	}
	return false;
}
template <class T> bool chmin( T& a, T b ) {
	if (a > b){
		a = b; return true;
	}
	return false;
}
bool bit_search( int pattern, int N ){
	int cnt = 0;
	rep( bit, 0, N ){
		if (pattern & ( 1 << bit )){
			cnt++;
		}
	}
	return true;
}


Measured memory_bytes: 256
program main
  
  implicit none
  integer :: n, k, i, j
  integer, allocatable :: a(:,:),d(:), b(:)
  integer :: m = 0
  
  read(*,*) n,k
  allocate(a(k,n))
  allocate(d(k))
  allocate(b(n))
  a = 0
  do i = 1, k
    read(*,*) d(i)
    read(*,*) a(i,1:d(i))
  end do
  
  b = 0
  do i = 1, k
    do j = 1, d(i)
      b(a(i,j)) = b(a(i,j)) + 1
    end do
  end do
  do i = 1, n
    if(b(i) == 0 ) m  = m + 1
  end do

  print*, m
   
end program main


Measured memory_bytes: 2832
#include <iostream>

using namespace std;

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

    int left = L;
    int right = L + N - 1;

    int eat;
    if(left >= 0)
    {
        eat = left;
    }

    else if(right <= 0)
    {
        eat = right;
    }    

    else
    {
        eat = 0;
    }

    int ans = (right + left) * (right - left + 1) / 2 - eat;
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    long N, M;

    cin >> N >> M;
    long ans = 1;
    for (long int i = 1; i * i <= M; i++)
    {

        if (M % i != 0)
            continue;

        long B = M / i;
        if (long(i * N) <= M)
        {
            ans = max(ans, i);
        }
        if (long(B * N) <= M)
        {
            ans = max(ans, B);
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace ABC118C
{
    class Program
    {
        static void Main(string[] args)
        {
            if (args.Length > 0)
            {
                Console.SetIn(new StreamReader(args[0]));
            }

            new Program().calc();
        }

        void calc()
        {
            var n = int.Parse(Console.ReadLine()); // 使わない
            var hpList = Console.ReadLine().Split(' ').Select(int.Parse);
            Console.WriteLine(attack(hpList));
        }

        int attack(IEnumerable<int> hpList)
        {
            Console.Error.WriteLine(string.Join(",", hpList));

            // 最も体力の少ないモンスターが、周りを攻撃する
            var min = hpList.Min();

            // 体力がちょうどゼロにならなかったモンスターは生かしておく
            hpList = hpList.Select(hp => hp % min).Where(hp => hp > 0);

            // 全モンスターの体力がゼロになったら終了。そうでない場合は攻守を変えて再帰する
            if (hpList.Count() == 0) { return min; } else { return attack(hpList.Concat(new[] { min })); }
        }
    }
}


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

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
      ll n;
      cin>>n;
      ll ans;
      ans = n%1000;
      if(ans != 0){
        ans = 1000 - ans;
      }
      cout<<ans<<"\n";
 
    return 0;
}


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

int main() {
	int n;
	int v[100010] = { 0 };
	cin >> n;
	int s[100010];
	int t[100010] = { 0 };
	int sum = 0;
	for (int i = 1;i <= n;i++) {
		cin >> v[i];
		s[i - 1] = abs(v[i] - v[i - 1]);
		if (i > 1)t[i - 1] = abs(v[i] - v[i - 2]);
		sum += s[i - 1];
	}
	s[n] = abs(0 - v[n]);
	sum += s[n];
	t[n] = abs(0 - v[n - 1]);
	for (int i = 0;i < n;i++) {
		cout << sum - (s[i] + s[i + 1]) + t[i + 1] << endl;
	}
}

Measured memory_bytes: 2432
#include <stdio.h>

int main( void ) {

	int w, n, x[30], a, b, i, temp;

	scanf( "%d", &w );
	scanf( "%d", &n );

	for ( i = 0; i < w; i++ ) {
		
		x[i] = i + 1;

	}

	for ( i = 0; i < n; i++ ) {

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

		temp = x[a-1];
		x[a-1] = x[b-1];
		x[b-1] = temp;

	}

	for ( i = 0; i < w; i++ ) {
		
		printf( "%d\n", x[i] );

	}

	return 0;

}

Measured memory_bytes: 596
card = {"S" => Array.new(13,0), "H" => Array.new(13,0), "C" => Array.new(13,0), "D" => Array.new(13,0)}

gets.to_i.times do
  sute, num = gets.split
  card[sute][num.to_i-1] = 1
end

card.each{|(key,value)|
  value.each_with_index{|v,i|
    if v == 0
      puts "#{key} #{i+1}"
    end
  }
}


Measured memory_bytes: 6868
#include <iostream>
#include <string>
using namespace std;
int main(void){
    string a,b;
    int c;
    cin >> a >> b;
    c = stoi(a + b);
    
    for(int i = 1;i <= 100100;i++){
        if(i * i == c) {cout << "Yes" << endl;
        return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define f(i,n) for(int i=0;i<n;i++)
#define P pair<int,int>
#define F first
#define S second
#define int long long
#define mod 1000000007
#define mmod 998244353
#define all(v) v.begin(), v.end()
#define INF LLONG_MAX/3
using namespace std;
int mypow(int fa, int fb, int fc) {
	if (fb == 0)return 1;
	if (fb % 2)return mypow(fa, fb - 1, fc)*fa%fc;
	int z = mypow(fa, fb / 2, fc);
	return z * z%fc;
}
int k(int fa) {
	int x = 0;
	while (fa) {
		x++;
		fa /= 10;
	}
	return x;
}
int gcd(int fa, int fb) {
	if (fb == 0)return fa;
	return gcd(fb, fa%fb);
}
signed main() {
	int a, b, c;
	cin >> a >> b >> c;
	if (c / a - (b-1) / a)puts("OK");
	else puts("NG");
}


Measured memory_bytes: 3600
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
use std::io::{Write, BufWriter};
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

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

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

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

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

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

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

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

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

#[allow(unused)]
macro_rules! debug {
    ($($format:tt)*) => (write!(std::io::stderr(), $($format)*).unwrap());
}
#[allow(unused)]
macro_rules! debugln {
    ($($format:tt)*) => (writeln!(std::io::stderr(), $($format)*).unwrap());
}

fn solve() {
    let out = std::io::stdout();
    let mut out = BufWriter::new(out.lock());
    macro_rules! puts {
        ($($format:tt)*) => (let _ = write!(out,$($format)*););
    }
    input!(k: usize1);
    let a = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51];
    puts!("{}\n", a[k]);
}

fn main() {
    // In order to avoid potential stack overflow, spawn a new thread.
    let stack_size = 104_857_600; // 100 MB
    let thd = std::thread::Builder::new().stack_size(stack_size);
    thd.spawn(|| solve()).unwrap().join().unwrap();
}


Measured memory_bytes: 8572
#include<vector>
#include<iostream>
#include<string>
#include<algorithm>
#include<math.h>
#include<map>
#include<functional>
#include<queue>
#include<stack>
#include<string.h>
#define ll long long int
#define MOD 1000000007LL
using namespace std;

int main() {
    ll h,w;
    cin>>h>>w;
    ll s1,s2,s3;
    ll ss=h*w;
    ll ans=1000000000;
    for(ll i=1;i<h;i++){
        s1=i*w;
        s2=(h-i)/2*w;
        s3=ss-(s2+s1);
        if(ans>max(max(s1,s2),s3)-min(min(s1,s2),s3)){
            ans=max(max(s1,s2),s3)-min(min(s1,s2),s3);
        }
        s2=(h-i)*(w/2);
        s3=ss-(s2+s1);
        if(ans>max(max(s1,s2),s3)-min(min(s1,s2),s3)){
            ans=max(max(s1,s2),s3)-min(min(s1,s2),s3);
        }
    }
    for(ll i=1;i<w;i++){
        s1=i*h;
        s2=(w-i)/2*h;
        s3=ss-(s2+s1);
        if(ans>max(max(s1,s2),s3)-min(min(s1,s2),s3)){
            ans=max(max(s1,s2),s3)-min(min(s1,s2),s3);
        }
        s2=(w-i)*(h/2);
        s3=ss-(s2+s1);
        if(ans>max(max(s1,s2),s3)-min(min(s1,s2),s3)){
            ans=max(max(s1,s2),s3)-min(min(s1,s2),s3);
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,x,y) for (int i=(x);i<=(y);i++)
#define gc getchar
#define ll long long
#define db double
#define pii pair<int,int>
#define fi first
#define se second
#define Vi vector<int>
#define Vp vector<pii>

using namespace std;

inline void cmax(int &x,int y){y>x?x=y:0;}
inline void cmin(int &x,int y){y<x?x=y:0;}

int read(){
	char ch=gc(); int x=0,op=1;
	for (;!isdigit(ch);ch=gc()) if (ch=='-') op=-1;
	for (;isdigit(ch);ch=gc()) x=(x<<1)+(x<<3)+ch-'0';
	return x*op;
}

ll a,b,c;

int main(){
	scanf("%lld%lld%lld",&a,&b,&c);
	if (a%2==0||b%2==0||c%2==0) puts("0");
	else printf("%lld\n",min(min(a*b,b*c),a*c));
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);
#define time_taken_start int begtime = clock();
#define time_taken_end int endtime = clock(); \
cerr << "\n\n" << "Time elapsed: " << \
(endtime - begtime)*1000/CLOCKS_PER_SEC << " ms\n\n"; \
return 0;
#define ll long long int
#define ull unsigned long long int
#define ld long double
#define mod 1000000007
#define inf 100000000000000007
#define eps 0.000000000001
#define pi acosl(-1)
#define pdd pair<ld,ld>
#define pll pair<ll,ll>
#define ff first
#define ss second
#define vpl vector<pll>
#define vll vector<ll>
#define mseti multiset <ll>
#define msetd multiset <ll,greater<ll>>
#define pb push_back
#define pf push_front
#define lb lower_bound
#define ub upper_bound 
#define stp fixed<<setprecision(20)
#define endl '\n'
void solve()
{
    ll n,x,y;
    cin>>n;
    ll m1,m2,m3,m4;
    cin>>x>>y;
    m1=m2=x-y;m3=m4=x+y;
    ll ans=0;
    for(ll j=1;j<n;j++)
    {
    	cin>>x>>y;
    	ll a1=x-y;
    	ll a2=x+y;
    	ans=max(ans,abs(a1-m1));
    	ans=max(ans,abs(a1-m2));
    	ans=max(ans,abs(a2-m3));
    	ans=max(ans,abs(a2-m4));
    	m1=max(m1,a1);
    	m2=min(m2,a1);
    	m3=max(m3,a2);
    	m4=min(m4,a2);
    }
    cout<<ans;
}
int main()
{
    FAST
    #ifdef ayk_16
    freopen("input.txt","rt",stdin);
    freopen("output.txt","wt",stdout);
    #endif
    time_taken_start
    ll t=1;
    //cin>>t;
    for(ll i=0;i<t;i++)
    {
        //cout<<"Case #"<<i+1<<": ";
        solve();
    }
    time_taken_end
}

Measured memory_bytes: 3624
N = input()
A = map(int, raw_input().split())

"""
import itertools

ans = 0
for p in itertools.permutations(range(N)):
  F = [True]*N
  for i in range(N):
    ans += A[p[i]]
    F[p[i]] = False
    t = p[i]-1
    while 0<=t and F[t]:
      ans += A[t]
      t -= 1
    t = p[i]+1
    while t<N and F[t]:
      ans += A[t]
      t += 1
print ans
"""

if N==1:
  print A[0]
  exit(0)

M = 10**9+7

F = [0]*(N+1)
F[0] = 1
for i in range(1,N+1):
  F[i] = F[i-1]*i%M

R = [0]*(N+1)
for i in range(1,N+1):
  R[i] = pow(i, M-2, M)

T = [F[N]]*N
for i in range(N):
  T[i] = T[i]*R[i+1]%M

ans = 0
x = sum(T)
for i in range((N+1)/2):
  ans += (A[i] + (A[N-i-1] if N-i-1!=i else 0))*x
  ans %= M
  x -= T[-i-1]
  x += T[i+1]
  x %= M
print ans


Measured memory_bytes: 18532
use proconio::input;
use std::collections::BTreeSet;

fn main() {
    input! {
        n: usize,
        v: [usize; n]
    }

    let (set,max,count1) = {
        let mut max = 1;
        let mut set = BTreeSet::new();
        let mut count1 = 0;
        for &x in &v {
            set.insert(x);
            if max < x {
                max = x;
            }
            if x == 1 {
                count1 += 1;
            }
        }
        (set,max,count1)
    };


    let flag = if set.len() >= count1+1 && count1 >= 1 || (set.len() < n-count1) {
        true
    } else {
        let mut flag = false;

        let mut tbl = vec![true; max+1];
        tbl[0] = false;
        tbl[1] = false;
        for i in 2..=max {
            if flag {
                break;
            }
            if tbl[i] {
                let mut j = i+i;
                let mut ff = false;
                if set.contains(&i) {
                    ff = true;
                }
                while j <= max {
                    tbl[j] = false;
                    if !ff && set.contains(&j) {
                        ff = true;
                    } else if ff && set.contains(&j) {
                        flag = true;
                        break;
                    }
                    j += i;
                }
            }
        }

        flag
    };


    if !flag || max == 1 {
        println!("pairwise coprime")
    } else {
        let mut jj = v[0];
        for &x in &v[1..] {
            jj = num::integer::gcd(jj,x);
        }
        if jj == 1 {
            println!("setwise coprime")
        } else {
            println!("not coprime")
        }
    }
}

Measured memory_bytes: 32848
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <deque>

int main(){
  std::set<int > s;
  int N;
  scanf("%d", &N);
  int temp;
  for (int i=0; i<N; i++){
    scanf("%d", &temp);
    s.insert(temp);
  }
  printf("%lu\n", s.size());
  return 0;
}


Measured memory_bytes: 256
import sys
import heapq, math
from itertools import zip_longest, permutations, combinations, combinations_with_replacement
from itertools import accumulate, dropwhile, takewhile, groupby
from functools import lru_cache
from copy import deepcopy

N, M = map(int, input().split())
f = [False] * N
s = [False] * N
for i in range(M):
    a, b = map(int, input().split())
    a, b = a - 1, b - 1

    if a == 0:
        f[b] = True
    if b == N -1:
        s[a] = True

ok = False
for i in range(N):
    if f[i] & s[i]:
        ok = True

print("POSSIBLE" if ok else "IMPOSSIBLE")

Measured memory_bytes: 6900
using System;


class AOJ
{

    public static void Main()
    {

        while (true)
        {
            string ns = Console.ReadLine();
            if (ns == null) break;

            int n = int.Parse(ns);

            int count = 0;

            for (int a = 0; a < 10; a++)
            {
                for (int b = 0; b < 10; b++)
                {
                    for (int c = 0; c < 10; c++)
                    {
                        for (int d = 0; d < 10; d++)
                        {
                            if ((a + b + c + d) == n)
                                count++;
                        }
                    }
                }
            }

            Console.WriteLine(count);
        }
    }
}

Measured memory_bytes: 5608
#include <bits/stdc++.h>
using namespace std;
int main () {
	int n,ans;
	cin>>n;
	int a[n];
	for (int i=0;i<n-1;i++) {
		cin>>a[i];
	}
	ans=a[0]+a[n-2];
	for (int i=0;i<n-2;i++) {
		ans+=min(a[i],a[i+1]);
	}
	cout<<ans;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>
#include <climits>

std::vector<int> v;
std::vector<int> w;
std::vector<std::vector<int>> dp;
int lgN;

int knapsack(int ver,int capa){
 if(capa<0){
  return INT_MIN;
 }
 if(capa==0){
  return 0;
 }
 if(ver<=lgN){
  return dp[ver][capa];
 }else{
  int v0=knapsack(ver/2,capa);
  int v1=knapsack(ver/2,capa-w[ver-1])+v[ver-1];
  
  return std::max(v0,v1);
 }
}

int main(){
 int N;
 std::cin>>N;
 v.resize(N);
 w.resize(N);
 for(int i=0;i<N;i++){
  std::cin>>v[i]>>w[i];
 }
 int Q;
 std::cin>>Q;

 lgN=std::min(512,N);
 //lgN=N;
 dp.resize(lgN+1);
 for(int i=0;i<lgN+1;i++){
  dp[i].resize(100001);
 }
 for(int i=0;i<lgN+1;i++){
  dp[0][i]=0;
  dp[i][0]=0;
 }

 for(int i=1;i<lgN+1;i++){
  for(int j=1;j<100001;j++){
   if(j>=w[i-1] && dp[i/2][j]<dp[i/2][j-w[i-1]]+v[i-1]){
    dp[i][j]=dp[i/2][j-w[i-1]]+v[i-1];
   }else{
    dp[i][j]=dp[i/2][j];
   }
  }
 }

 //std::cout<<std::endl;

 int ver,L;
 for(int i=0;i<Q;i++){
  std::cin>>ver>>L;
  std::cout<<knapsack(ver,L)<<std::endl;
 }

 return 0;
}

Measured memory_bytes: 206432
#include <string.h>
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

int main() {
    int n;

    cin >> n;

    vector< int > a(n);

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

    sort(a.begin(), a.end());

    int ans = 0;
    int x;
    for (int i = 0; i < n; i++) {
        x = a[i];
        int cnt = 0;
        while (a[i] == x && i < n) {
            i++;
            cnt++;
        }
        ans += cnt % 2;
        i--;
    }

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

Measured memory_bytes: 768
#include<iostream>
#include<string>
#include<vector>
using namespace std;
int main(){
    vector<string> s(2);//red,green
    while(cin >> s[0], s[0] != "-"){
        cin >> s[1];
        int a = s[0].size();
        int b = s[1].size();
        //right:b+1, down:a
        string str;
        cin >> str;
        int l = 0, r = 1;
        string ans = "";
        int i = 0;
        char c = s[1][0];
        while(i < str.size()){
            if(str[i] == c){
                c = s[0][l];
                l++;
                i++;
            }else{
                ans += c;
                c = s[1][r];
                r++;
            }
        }
        ans += c + s[1].substr(r);
        cout << ans << endl;
    }
}



Measured memory_bytes: 3176
from collections import defaultdict

def dfs(graph, node_start, visited):
    if node_start in visited:
        return visited
    visited.append(node_start)
    for node_end in graph[node_start]:
        dfs(graph, node_end, visited)
    return visited

def main():
    N, M = map(int, input().split())

    graph = defaultdict(list)
    edges = []

    # 無向グラフの表現
    for _ in range(M):
        a, b = map(int, input().split())
        graph[a].append(b)
        graph[b].append(a)
        edges.append((a, b))

    answer = 0
    for a, b in edges:
        # a, b間のエッジの削除
        graph[a].remove(b)
        graph[b].remove(a)

        visited = dfs(graph, 1, [])
        if len(visited)!= N:
            answer += 1

        # エッジの修復
        graph[a].append(b)
        graph[b].append(a)

    print(answer)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3444
#include<bits/stdc++.h>
#define N 1005
#define re register
using namespace std;
int n,d1,d2,n2;
bool vis[N][N];

void solve(int d,int siz)
{
	if(d % 4 == 1)
	{
		for(int i=0;i<n2;++i)
		  for(int j=0;j<n2;++j)
		    vis[i][j] |= ((i / siz + j / siz) & 1);
		return;
	}
	if(d % 4 == 2)
	{
		for(int i=0;i<n2;++i)
		  for(int j=0;j<n2;++j)
		    vis[i][j] |= ((i / siz) & 1);
		return;
	}
	solve(d / 4,siz * 2);
}
int main()
{
	scanf("%d%d%d",&n,&d1,&d2); n2 = 2 * n;
	solve(d1,1); solve(d2,1);
	int cnt = 0,n22 = n * n;
	for(int i=0;i<n2;++i)
	{
		for(int j=0;j<n2;++j)
		{
			if(!vis[i][j]) { printf("%d %d\n",i,j); ++cnt; }
			if(cnt == n22) return 0;
		}
	}
	return 0;
}

Measured memory_bytes: 1536
from functools import reduce

# 出力
N = int(input())
A, B = (
    zip(*(map(int, input().split()) for _ in range(N))) if N else
    ((), ())
)

# 〆切時刻が小さい順にgreedyに仕事を処理する
ans, _ = reduce(
    lambda acc, t:
        (
            'Yes' if acc[0] == 'Yes' and acc[1] + t[0] <= t[1] else
            'No',
            acc[1] + t[0]
        ),
    sorted(zip(A, B), key=lambda t: t[1]),
    ('Yes', 0)
)

# 出力
print(ans)


Measured memory_bytes: 112472
/*
  author: ruruvuvu
  GitHub account: colon-ku

  created at: 2020-01-10 21:00:52 service issue occurred
                2020-01-10 21:04:29
*/

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

#define all(x) (x).begin(),(x).end()
#define rep(x, y) for (int x = 0; x < y; x++)
#define MOD 1000000007

typedef long long LL;
typedef long double LD;

bool compare_by_b(pair<int, int> a, pair<int, int> b)
{
    if (a.second != b.second) {
        return a.second < b.second;
    } else {
        return a.first < b.first;
    }
}

ostringstream oss_global;
string s_global = oss_global.str();

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

    int ans = 0;
    for (int i = 0; i <= n-3; i++) {
        if (s[i] == 'A') {
            if (s[i+2] - s[i+1] == s[i+1] - s[i] && s[i+1] - s[i] == 1) {
                ans++;
            }
        }
    }

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


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
const int mod=998244353,lim=512;
inline void add(int &x,int y){(x+=y)>=mod?x-=mod:0;}
inline int pl(int x,int y){return (x+=y)>=mod?x-mod:x;}
inline int kpow(int a,int b)
{
	int s=1;
	for(;b;b>>=1,a=1ll*a*a%mod)
		if(b&1)s=1ll*s*a%mod;
	return s;
}
int n,a[410],b[410],jc[512],jcv[512],S,Sv,ans;
int dp[2][410][512],r[512],w[9][256],A[512];
void init()
{
	jc[0]=1;
	for(int i=1;i<lim;++i)jc[i]=1ll*jc[i-1]*i%mod;
	jcv[lim-1]=kpow(jc[lim-1],mod-2);
	for(int i=lim-1;i;--i)jcv[i-1]=1ll*jcv[i]*i%mod;
	for(int i=1;i<lim;++i)r[i]=(r[i>>1]>>1)|(i&1?lim>>1:0);
	for(int len=1,i=0;len<lim;len<<=1,++i)
	{
		int tmp=kpow(3,(mod-1)/len/2);
		w[i][0]=1;
		for(int j=1;j<len;++j)w[i][j]=1ll*w[i][j-1]*tmp%mod;
	}
}
void ntt(int f[],int opt)
{
	for(int i=1;i<lim;++i)if(i<r[i])swap(f[i],f[r[i]]);
	int x,y;
	for(int len=1,i=0;len<lim;len<<=1,++i)
		for(int j=0;j<lim;j+=len<<1)
			for(int k=0;k<len;++k)
			{
				x=f[j+k],y=1ll*f[j+k+len]*w[i][k]%mod;
				f[j+k]=pl(x,y),f[j+k+len]=pl(x,mod-y);
			}
	if(opt==-1)
	{
		reverse(f+1,f+lim);
		int inv=kpow(lim,mod-2);
		for(int i=0;i<lim;++i)f[i]=1ll*f[i]*inv%mod;
	}
}
int main()
{
//	printf("%d %d",5ll*kpow(72,mod-2)%mod,kpow(216,mod-2));
	scanf("%d",&n);
	init();
	for(int i=1;i<=n;++i)scanf("%d %d",&a[i],&b[i]),S+=a[i];
	for(int i=0;i<lim;++i)dp[0][0][i]=1;
	Sv=kpow(S,mod-2);
	int t=0;
	for(int i=1;i<=n;++i)
	{
		memset(A,0,sizeof(A));
		int tmp=1ll*a[i]*Sv%mod,cur=1;
		for(int j=0;j<b[i];++j)
		{
			A[j]=1ll*(mod-cur)*jcv[j]%mod;
			cur=1ll*cur*tmp%mod;
		}
		ntt(A,1);
		t^=1;memset(dp[t],0,sizeof(dp[t]));
		for(int j=0;j<S;++j)
		{
			for(int k=0;k<lim;++k)dp[t][j][k]=1ll*A[k]*dp[t^1][j][k]%mod;
			if(j>=a[i])for(int k=0;k<lim;++k)add(dp[t][j][k],dp[t^1][j-a[i]][k]);
		}
	}
	for(int i=0;i<S;++i)
	{
		ntt(dp[t][i],-1);
	//	for(int j=0;j<10;++j)printf("%9d ",dp[t][i][j]);printf("\n");
		int na=1ll*i*Sv%mod,tmp=kpow(mod+1-na,mod-2),w=tmp;
		for(int j=0;j<lim;++j)ans=(ans+1ll*dp[t][i][j]*w%mod*jc[j])%mod,w=1ll*w*tmp%mod;
	}
	if(ans)ans=mod-ans;
	printf("%d",ans);
	return 0;
}


Measured memory_bytes: 1792
#include<iostream>
#include<stdio.h>
#include<string.h>
using namespace std;
#define m 1046527

int main () {
   int n, num, k;
   long long sum = 0, h=0, p=0, h1=0, h2=0;
   char str[14]={}, com[9]={};
   char hash[m][14]={};
   cin >> n;
   for(int i=0; i<n; i++) {
       cin >> com >> str;
       if(com[0] == 'i') {
           sum = 0;
           num = 0;
           p = 1;
           for(int j=0; j<strlen(str); j++) {
               if (str[j] == 'A') {
                   num = 1;
               } else if (str[j] == 'C') {
                   num = 2;
               } else if (str[j] == 'G') {
                   num = 3;
               } else if (str[j] == 'T') {
                   num = 4;
               } else {
                   num = 0;
               }
               sum += p*num;
               p*=5;
           }
           k=0;
           while (1) {
               h1 = sum%m;
               h2 = 1 + sum%(m-1);
               h= (h1 + k*h2)%m;
               if (strcmp(hash[h], str) == 0) {
                   break;
               } else if(strlen(hash[h]) == 0) {
                   strcpy(hash[h], str);
                   break;
               }
               k++;
           }
       } else {
           sum = 0;
           num = 0;
           p = 1;
           for(int j=0; j<strlen(str); j++) {
               if (str[j] == 'A') {
                   num = 1;
               } else if (str[j] == 'C') {
                   num = 2;
               } else if (str[j] == 'G') {
                   num = 3;
               } else if (str[j] == 'T') {
                   num = 4;
               } else {
                   num = 0;
               }
               sum += p*num;
               p*=5;
           }
           k=0;
           while (1) {
               h1 = sum%m;
               h2 = 1 + sum%(m-1);
               h= (h1 + k*h2)%m;
               if (strcmp(hash[h],str) == 0) {
                   cout << "yes" << endl;
                   break;
               } else if (strlen(hash[h]) == 0){
                   cout << "no" << endl;
                   break;
               }
               k++;
           }
       }
   }
}



Measured memory_bytes: 17464
#include <bits/stdc++.h>
using namespace std;
typedef pair<double,double> P;

int main() {
  int n;
  cin >> n;
  P a[n];
  double l=0,r=1<<29;
  for(int i=0; i<n; i++) {
    cin >> a[i].first >> a[i].second;
    l=max(l,a[i].first-a[i].second);
    r=min(r,a[i].first+a[i].second);
  }
  double ans;
  for(int j=0; j<50; j++) {
    double m=(l+r)/2;
    double M=1<<29,x;
    for(int i=0; i<n; i++) {
      double d=a[i].second*a[i].second-(a[i].first-m)*(a[i].first-m);
      d=sqrt(d);
      if(d<M) {
        M=d;
        x=a[i].first;
        ans=d;
      }
    }
    if(x>m) l=m;
    else r=m;
  }
  printf("%.10f\n",ans);
  return 0;
}


Measured memory_bytes: 4748
/**
 *    author        : Saurav Paul 
 *    created       : August 02, 2020 6:12 PM
 *    Problem Name  : C - Repsept
 *    Problem Limit : 2000 ms , 1024 MB
 *    Problem Url   : https://atcoder.jp/contests/abc174/tasks/abc174_c
 *    @genarated by : ai-virtual-assistant
**/

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

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

    long long x ;
    cin >> x ;

    if(x%2==0){
        cout << -1 << endl ;
        return 0 ;
    }

    long long t = 7 ;
    long long cnt = 1 ;
    unordered_map<int,int> prevs ;

    while(t%x){
        t = ((t%x)*10)+7 ;
        if(prevs[t]==1){
            cout << - 1 << endl ;
            return 0 ;
        }
        prevs[t] = 1;
        cnt ++ ;
    }

    cout << cnt << endl ;

    return 0 ;
}


Measured memory_bytes: 42620
#include <iostream>
#include <math.h>
#include <numeric>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <queue>
#include <queue>
#include <stack> 
#include <sstream>
#include <set>

typedef  long long ll;
const int dx[8]={1,0,-1,0,1,-1,-1,1};
const int dy[8]={0,1,0,-1,1,1,-1,-1};
const int dr[4] = {-1, 0, 1, 0};
const int dc[4] = { 0, 1, 0,-1};
const int INF = 1e9;
#define FOR(i, a, n) for(int i = (int)(a); i < (int)(n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define SORT(a) sort(a.begin(),a.end())
#define REVERSE(a) reverse(a.begin(),a.end())
int guki (int a){
    if(a%2==0) return 0;
    else return 1;
}
int gcd(int a, int b){
    if(a%b==0){
        return b;
    }else{
        return (gcd(b,a%b));
    }
}
int lcm(int a, int b){
    int x = gcd(a,b);
    return (a*b/x);
}

using namespace std;
// now
int h,w;
char grid[105][105];
struct UnionFind {
    vector<int> d;
    UnionFind(int n=0) : d(n,-1){}
    int Find (int x){//根の番号を探す
        if(d[x] < 0) return x;
        return d[x] = Find(d[x]);
    }
    bool unite (int x, int y){
        x = Find(x); y = Find(y);
        if(x == y ) return false;
        if(d[x] < d[y]){
            swap(x,y);
        }
        d[x] += d[y];
        d[y] = x;
        return true;
    } 

    bool same(int x, int y){
        return Find(x) == Find(y);
    }
    int size(int x) {
        return (-d[Find(x)]);
    }
};




int main(){
    cin >> h >>w;
    char x;
    REP(i,h){
        REP(j,w){
            cin >> x;
            grid[i][j] = x;
        }
    }
    int dp[105][106] ;
    dp[0][0] = 0;

    if(grid[0][0] == '#')dp[0][0] ++;

    REP(i,h){
        REP(j,w){
            if(0 < i || 0 < j){
                dp[i][j] = 1e9;
                if(i>0) dp[i][j] = min(dp[i][j],dp[i-1][j] + ((grid[i][j]=='#') && (grid[i-1][j]=='.')));
                if(j>0) dp[i][j] = min(dp[i][j],dp[i][j-1] + ((grid[i][j]=='#') && (grid[i][j-1]=='.')));
            }

            
        }
    }
    
    cout << dp[h-1][w-1] <<endl;

}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define int long long
#define all(sdk) sdk.begin(),sdk.end()
#define mll map<int, int>
#define pb push_back
#define rep(i,a,b) for(int i=a;i<b;++i)
#define repd(i,a,b) for(int i=a;i>=b;--i)
#define mp make_pair
#define hell 1000000007
#define endl '\n'
#define vvll vector<vector<int> >
#define vll vector<int>
#define mint map<int,int> 
#define sz(x) (int)x.size()
#define sll set<int>
#define pll pair<int,int>
#define F first
#define S second
#define INF 1e18
#define NINF -1e16

#define nax 2000010
#define nax2 1000002

void solve(){
	
	int n;
	cin>>n;
	int cnt[5];
	memset(cnt,0,sizeof(cnt));

	rep(i,0,n){
		string s;
		cin>>s;
		if(s=="AC")
			cnt[0]++;
		if(s=="WA")
			cnt[1]++;
		if(s=="TLE")
			cnt[2]++;
		if(s=="RE")
			cnt[3]++;
	}
	cout<<"AC x "<<cnt[0]<<endl;
	cout<<"WA x "<<cnt[1]<<endl;
	cout<<"TLE x "<<cnt[2]<<endl;
	cout<<"RE x "<<cnt[3]<<endl;

}

signed main(){
    //freopen("output.txt","w",stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    srand (static_cast <unsigned> (time(0)));
    int t;
    // cin>>t;
    t=1;
    while(t--){
        solve();
    }
    return 0;
}

Measured memory_bytes: 3648
import sys


def input():
    return sys.stdin.readline().strip()


sys.setrecursionlimit(20000000)


def main():
    N, X = map(int, input().split())
    B = 1
    P = 1
    for i in range(N):
        B = 2 * B + 3
        P = 2 * P + 1

    def cnt(X, B, P, ans):
        if B == 5:
            if X == 5:
                return ans + 3
            elif X == 4:
                return ans + 3
            elif X == 3:
                return ans + 2
            elif X == 2:
                return ans + 1
            else:
                return ans
        if X == B:
            return ans + P
        elif X > B // 2 + 1:
            ans += P // 2 + 1
            P = P // 2
            X = X - (B // 2 + 1)
            B = B // 2 - 1
            return cnt(X, B, P, ans)
        elif X == B // 2 + 1:
            ans += P // 2 + 1
            return ans
        else:
            B = B // 2 - 1
            P = P // 2
            X -= 1
            return cnt(X, B, P, ans)

    answer = cnt(X, B, P, 0)
    print(answer)


if __name__ == "__main__":
    main()


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
 
int main()
{
	long long int n, x;
	cin >> n >> x;
	long long int ans = 0, in;
	long long int okashi[101];
	for (long long int i = 0; i < n; ++i)
	{
		cin >> okashi[i];
	}
	sort(okashi, okashi + n);
	for (long long int i = 0; i < n - 1; ++i)
	{
		x -= okashi[i];
		ans += (x >= 0);
	}
	cout << ans + (x == okashi[n - 1]) << endl;
	return 0;
}

Measured memory_bytes: 256
n,a,b=map(lambda x: int(x), input().split())
ans=0
for i in range(1,n+1):
    tmp=i
    tmp_sum=0
    while(tmp>0):
        tmp_sum+=tmp%10
        tmp=int(tmp/10)
    if tmp_sum>=a and tmp_sum<=b:
        ans+=i
print(ans)

Measured memory_bytes: 3060
N, a = int(input()), list(map(int, input().split()))
result = [0] * N
for i in range(N//2, N):
    result[i] = a[i]
for i in range(N//2, -1, -1):
    temp = N // (i+1)
    work = 0
    for j in range(1, temp+1): work += result[(i+1) * j - 1]
    if work % 2 != a[i]: result[i] = 1
i = 1
print(result.count(1))
for r in result:
    if r == 1:print(i)
    i += 1

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

using namespace std;
typedef long long ll;

const int N = 3007;

int n;

double memo[307][307][307];
bool vis[307][307][307];

double solve(int ones, int twos, int tres) {
    if(ones + twos + tres == 0) return 0;

    double & st = memo[ones][twos][tres];
    if(!vis[ones][twos][tres]) {
        vis[ones][twos][tres] = true;

        st = 1;
        if(ones) st += double(ones)/double(n) * solve(ones-1, twos, tres);
        if(twos) st += double(twos)/double(n) * solve(ones+1, twos-1, tres);
        if(tres) st += double(tres)/double(n) * solve(ones, twos+1, tres-1);
        st = st * double(n);
        st /= (ones + twos + tres);
    }
    return st;
}
int main() {
    int cnt[4] = {0};
    cin >> n;

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

    cout << fixed << setprecision(10) << solve(cnt[1], cnt[2], cnt[3]) << endl;
}

Measured memory_bytes: 250112
#include <algorithm>
#include <iostream>
#include <string>
#include <random>
#include <cassert>
#include <cstring>
#include <chrono>
#include <set>
#include <map>

using namespace std;

typedef long long ll;

int main()
{
  int A, B, M;
  cin >> A >> B >> M;
  vector<int> a(A), b(B);
  int minA = 1e9;
  int minB = 1e9;
  for (int i = 0; i < A; ++i) cin >> a[i];
  for (int i = 0; i < A; ++i) minA = min(minA, a[i]);
  for (int i = 0; i < B; ++i) cin >> b[i];
  for (int i = 0; i < B; ++i) minB = min(minB, b[i]);

  int result = minA + minB;
  for (int i = 0; i < M; ++i) {
    int x, y, c;
    cin >> x >> y >> c;
    x--;
    y--;
    result = min(result, a[x] + b[y] - c);
  }
  cout << result << endl;

  return 0;
}


Measured memory_bytes: 1024
#include<iostream>
#include<vector>
#include<cmath>
#include<algorithm>
#include<string>
#include<climits>
#include<stack>
#include<queue>
#include<unordered_map>
#include<map>
#include<set>
#include<fstream>
#include<list>
#include<sstream>

#define loopi(x,y) for(int i = x;i<(y);i++)
#define loopj(x,y) for(int j = x;j<(y);j++)
#define rloopi(x,y) for(int i = x;i>=(y);i--)
#define rloopj(x,y) for(int j = x;j>=(y);j--)


#define nl cout<<"\n";
#define ll long long int
#define mod  1000000007

using namespace std;



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

#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	int n;
	cin >> n;
	int count = 0;
	for (int i = 0; i < n; i++)
	{
		int x, y;
		cin >> x >> y;
		if (x == y)
		{
			count++;
		}
		else
		{
			count = 0;
		}
		if (count == 3)
			break;
	}

	if (count == 3)
		cout << "Yes";
	else
		cout << "No";

	return 0;
}


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

const int N = 1e5+5;

int n;
string s;

int main(){
	cin>>s;
	n = s.size();
	string t;
	int j = 0;
	for(int i = 1;i <= n;i++){
		if(i & 1)t += s.substr(i - 1 , 1);
	}
	cout<<t<<endl;
}

Measured memory_bytes: 640
#include<iostream>
using namespace std;
int main() {
	int N,M,C;
	int B[20], A[1000000][20];
	int sum = 0, ans = 0;;
	cin >> N >> M >> C;
	for (int i = 0; i < M; i++) {
		cin >> B[i];
	}
	for (int L = 0; L < N; L++) {
		for (int G = 0; G < M; G++) {
			cin >> A[L][G];
		}
	}
	for (int s = 0; s < N; s++) {
		for (int k = 0; k < M; k++) {
			sum += A[s][k]*B[k];
		}
		sum += C;
		if (sum > 0) {
			ans++;
		}
		sum = 0;
	}
	cout << ans << endl;
	return 0;
}

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

int main(){
  string S, T;
  cin >> S >> T;
  int A, B;
  cin >> A >> B;
  string U;
  cin >> U;
  
  if(S == U) A--;
  else B--;
  
  cout << A << " " << B;
  return 0;
}

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

#define FAST_IO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ll long long
#define FOR(i,l,r) for(long long i=l; i<r; i++)
#define FOR_REV(i,r,l) for(long long i=r; i>=l; i--)
#define pb push_back
#define mp make_pair

int main()
{
    ll n,m;
    cin>>n>>m;

    ll ans = 0;

    if (n>=2)
    {
        ans += (n)*(n-1)/2;
    }
    if (m>=2)
    {
        ans += (m)*(m-1)/2;
    }

    cout<<ans<<endl;
}


Measured memory_bytes: 256
import java.util.Scanner; 
public class Main {
    public static void main(String[] args) {
       Scanner sc = new Scanner(System.in); 
        int N = sc.nextInt();        
        String S = sc.next();  

       int i ;
       int m = 0 ;

       String[]  stringArray;        
       stringArray= new  String[N];

       for(i = 1 ; i <= N ; i++) {

             stringArray[i-1]  = S.substring(i-1, i);
      //    System.out.println(stringArray[i-1]);
       }
    
       for(i = 1 ; i < N ; i++) {

             if  (stringArray[i-1].equals(stringArray[i] ) )  {
            
             } else  {
               m = m + 1;
             }

       }
     if (N > 0 ) {  
          System.out.println(m+1);
           }
     }

} 


Measured memory_bytes: 31552
#include <limits.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <math.h>

#define P 1000000007

int comp(const void *a, const void *b){return *(int*)a-*(int*)b;}

int main(void){
	long n;
	scanf("%ld", &n);
	printf("%ld\n", n*(n-1)/2);
}


Measured memory_bytes: 128
n = int(input())
s = input()

lch = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
dch = {}
ans = []

for i in range(len(lch)):
    dch[lch[i]] = i

for j in range(len(s)):
    ch = s[j]
    k = (dch[ch] + n) % 26
    ans.append(lch[k])

print("".join(ans))


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

using namespace std;
using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vb = vector<bool>;
using vc = vector<char>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;
using vvb = vector<vector<bool>>;
using vvc = vector<vector<char>>;
using vvs = vector<vector<string>>;
template<typename T> using vv = vector<vector<T>>;
template<typename T> using vvv = vector<vector<vector<T>>>;
template<typename T> using pq = priority_queue<T>;
template<typename T> using pqg = priority_queue<T, vector<T>, greater<T>>;

const int INF = 1e9;
const ll LINF = 1e18;
const ll MOD = 1e9 + 7;
const int DX[4] = {1, 0, -1, 0};
const int DY[4] = {0, 1, 0, -1};

#define _sel(_1, _2, x, ...) x
#define repn(i, n) for (ll i = 0; i < (n); i++)
#define reps(i, a, b) for (ll i = (a); i < (b); i++)
#define rep(i, ...) _sel(__VA_ARGS__, reps, repn)(i, __VA_ARGS__)
#define reppn(i, n) for (ll i = 1; i <= (n); i++)
#define repps(i, a, b) for (ll i = (a); i <= (b); i++)
#define repp(i, ...) _sel(__VA_ARGS__, repps, reppn)(i, __VA_ARGS__)
#define rrepn(i, n) for (ll i = (n) - 1; i >= 0; i--)
#define rreps(i, a, b) for (ll i = (b) - 1; i >= (a); i--)
#define rrep(i, ...) _sel(__VA_ARGS__, rreps, rrepn)(i, __VA_ARGS__)
#define rreppn(i, n) for (ll i = (n); i >= 1; i--)
#define rrepps(i, a, b) for (ll i = (b); i >= (a); i--)
#define rrepp(i, ...) _sel(__VA_ARGS__, rrepps, rreppn)(i, __VA_ARGS__)

#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define rng(v) (v).begin(), (v).end()
#define rrng(v) (v).rbegin(), (v).rend()
#define siz(x) int((x).size())
#define pow2(x) (1ll << (x))
#define bit(x, n) ((x) >> (n) & 1)
#define prt(x) cout << (x) << endl
#define dbg(x) dbgn(#x, x)

template<typename T, typename U> inline bool umax(T& m, U x) { if (m < x) { m = x; return true; } return false; }
template<typename T, typename U> inline bool umin(T& m, U x) { if (m > x) { m = x; return true; } return false; }
template<typename T> inline void errv(T& v) { for (auto x: v) cerr << x << " "; cerr << endl; }
inline void errv(vb& v) { for (auto x: v) cerr << (x ? 1 : 0) << " "; cerr << endl; }
template<typename T> inline void dbgn(string n, T x) { cerr << n << ": " << x << endl; }
template<typename T> inline void dbgn(string n, vector<T>& v) { cerr << n << ": "; errv(v); }
template<typename T> inline void dbgn(string n, vv<T>& m) { cerr << n << ":" << endl; for (auto& v: m) errv(v); }


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

    vc c(n);
    rep(i, n) cin >> c[i];

    int cnt = 0;
    int l = 0, r = n - 1;

    while (l < r) {
        while (c[l] == 'R') {
            l++;
            if (l >= n) break;
        }

        if (l >= n) break;

        while (c[r] == 'W') {
            r--;
            if (r < 0) break;
        }

        if (r < 0) break;

        if (l >= r) break;

        char t = c[l];
        c[l] = c[r];
        c[r] = t;

        l++;
        r--;
        cnt++;
    }

    prt(cnt);

    return 0;
}


Measured memory_bytes: 3592