akhauriyash/Code-Regression huggingface dataset:
func readInts() -> [Int] {
    return readLine()!.split(separator: " ").map { Int($0)! }
}

func main() {
    let line = readInts()
    let n = line[0]
    let m = line[1]
    
    print(n * (n - 1) / 2 + m * (m - 1) / 2)
}

main()


Measured memory_bytes: 8256
//Author- Vaibhav Singh


#include<bits/stdc++.h>
/*
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_multiset tree<long long , null_type,less_equal<long long >, rb_tree_tag,tree_order_statistics_node_update>
#define ordered_set tree<long long , null_type,less<long long >, rb_tree_tag,tree_order_statistics_node_update>
*/
using namespace std;
#define ll long long int
#define YES cout<<"YES"<<"\n";
#define NO cout<<"NO"<<"\n";
#define ld     long double 
#define yes cout<<"yes"<<"\n";
#define no cout<<"no"<<"\n";
#define No cout<<"No"<<"\n";
#define Yes cout<<"Yes"<<"\n";
#define f(i,a) for(i=0;i<a;i++)
#define fo(i,a) for(i=1;i<=a;i++)
#define fa(i,a) for(auto i:a)
#define r(i,a) for(auto i=a.rbegin();i!=a.rend();i++)
#define en cout<<"\n";
#define ull unsigned long long int
#define o(x) cout<<x<<"\n";
#define o1(x) cout<<x<<" ";
#define pb push_back
#define F first
#define in insert
#define mp make_pair
#define S second
#define pre(n) cout<<fixed<<setprecision(n);
#define      gcd(a,b)    __gcd(a,b)
#define bs            binary_search
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);
#define test ll t;cin>>t;while(t-->0)
const ll Mod = 998244353;
#define mod 1000000007
#define pi 3.14159265358979323846
#define all(x) x.begin(),x.end()
#define re return 0;
// *#######################################################################################*

/*
bool isp(ll n)
{
    ll i;
    for(i=2;i*i<=n;i++)
    {
        if(n%i==0)
        {
            return false;
        }
        
    }
}
  */
  
  ll powerm(ll x, unsigned ll y, ll p)  
{  
    ll res = 1;    
  
    x = x % p; 
   
    if (x == 0) return 0;
  
    while (y > 0)  
    {  
        if (y & 1)  
            res = (res*x) % p;  
   
        y = y>>1; // y = y/2  
        x = (x*x) % p;  
    }  
    return res;  
}
  long long lcm(long long a, long long b){//最小公倍数を求める
   return a * b / gcd(a, b);
}

/*
ll po(ll z,ll z1)
{
    ll rer=0;
    rer=     ((z*(z-1))/2+(z1*(z1-1))/2);
    return rer;

}
*/
/*
bool sortbysec(const pair<int,int> &a, 
              const pair<int,int> &b) 
{ 
    return (a.second < b.second); 
}
*/
/*
bool is_prime(ll n){
    for(ll i = 2;i*i<=n;i++){
        if(n%i == 0) return false;
    }
    return true;
}
*/
int inv(int a){
    return powerm(a,mod-2,mod);
}

ll const N=1e5;
ll fact[N], invfact[N];
 
void precompute(){
    fact[0] = 1;
    for(int i=1;i<N;i++) fact[i] = (fact[i-1]*i)%mod;
    invfact[N-1] = inv(fact[N-1])%mod;
    for(int i=N-2;i>=0;i--) invfact[i] = (invfact[i+1]*(i+1))%mod;
}
 
ll ncr(ll n, ll r){
    if(n<r) return 0;
    return (((fact[n]*invfact[r])%mod)*invfact[n-r])%mod;
}


//*88888*********5555555555555555******88888888$$$$$$$$$$******!!!!!!!!!!

       int main()
       {
           //プログラムの開始
    fast

      ll n,k;
      cin>>n>>k;
      ll a[n],i;
      f(i,n)
      {
          cin>>a[i];
      }
 sort(a,a+n);
     ll s=0;
     f(i,n-k)
     {
         s+=a[i];
     }
o(s)





//プログラムの終わり
re}

Measured memory_bytes: 5180
#include<bits/stdc++.h>
#include<iostream>
#include<stdio.h>
#include<vector>

using namespace std ;
bool digits[10] ;
vector<int> numDig ;
vector<int> loved ;
void funct(int n ){
  while(n!=0){
    numDig.push_back(n%10) ;
    n=n/10 ;
  }
}
bool check(int n ){
    funct(n) ;
    for(int i=0 ; i<numDig.size() ; i++){
        if(find(loved.begin(),loved.end(),numDig[i])==loved.end())
            return false ;
    }
    return true ;

}

int main(){
  //  freopen("in.txt","r", stdin) ;

 memset(digits,false , sizeof(digits)) ;
 int n , k,a ;
 scanf("%d%d",&n ,&k) ;
 for(int i=0; i<k ; i++ ){
    scanf("%d ",&a) ;
    digits[a]=true ;
 }
 for(int i=0 ; i<10 ; i++){
    if(!digits[i]){
        loved.push_back(i) ;
    }

 }
 sort(loved.begin(), loved.end()) ;
for(int i=n ; i<=10*n ; i++){
    numDig.clear();
    if(check(i)){
        printf("%d",i) ;
        break ;
    }



}



 /*for(int i=0 ; i<loved.size() ; i++) {
    cout<<loved[i] << endl ;
 }*/

  return 0 ;

}


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

int main() {
  int n;cin>>n;
  vector<string> w(n);
  rep(i,n)cin>>w[i];
  rep(i,n-1)for(int j=i+1;j<n;j++){
    if(w[i]==w[j]){
      cout<<"No"<<endl;
      return 0;
    }
  }
  rep(i,n-1){
    if(w[i][w[i].size()-1]!=w[i+1][0]){
      cout<<"No"<<endl;
      return 0;
    }
  }
  cout<<"Yes"<<endl;
}

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

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

  if ( K <= A ) {
    cout << K << endl;
  }
  
  else if ( K <= A + B) {
    cout << A << endl;
  }
  
  else {
    cout << 2*A + B - K << endl;
  }
     
}


Measured memory_bytes: 3128
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <map>
#include <list>
#include <set>
#include <stack>
#include <deque>
#include <queue>
#include <cmath>
#include <algorithm>
#include <utility>
#include <functional>
#include <random>
#include <fstream>
#include <time.h>
// #define int long long
#define debug(x) cerr << #x << " = " << x << endl
#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,n) for(int i = 0; i < (n); i++)
#define repr(i,n) for(int i = (n); i > -1; i--)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int MOD = 1000000007;
const ll LINF = 1e18;
const double EPS = 1e-9;


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

  int n;
  cin>>n;
  int h[n];
  rep(i,n) cin>>h[i];
  int ans = 0;
  rep(i,n) {
    bool f = false;
    rep(j,i) {
      if(h[j] > h[i]) {
        f = true;
      }
    }
    if(!f) ans++;
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
def main():
    n = int(input())
    d = list(map(int,input().split()))
    md = 998244353

    if d[0] != 0:
        print(0)
        return 0

    dp = [0]*n
    for i in d:
        dp[i]+=1
    res = 1
    for i in d[1:]:
        res = (res * dp[i-1]) % md
    print(res%md)

if __name__ == '__main__':
    main()


Measured memory_bytes: 53172
#include<stdio.h>

int main()
{
	int i,a, b, c,k, max, ans;

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

	max = a;
	if (max < b)
		max = b;
	if (max < c)
		max = c;

	ans = a + b + c - max;
	
	for (i = 0; i < k; i++)
		max *= 2;

	ans += max;

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

	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<deque>
#include<regex>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>

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

typedef int long long ll;
using namespace std;
typedef pair<int, int> P;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
const ll MOD = 1e9 + 7;
static const int MAX = 100;
static const int INF = (1 << 23);
template<class T> bool min_update(T& X, const T& A){ if(X > A) {X = A; return true;} return false; }
int main() {

    ll n,m,l;
    cin >> n>>m>>l;
    pair<ll,ll> mi[n][n];

    rep(i, n) {
        rep(j, n) {
            mi[i][j].first = MOD;
            mi[i][j].second = MOD;
        }
    }

    rep(i,m){
        ll a,b,c;
        cin>>a>>b>>c;
        a--;b--;
        if(c>l)continue;
        mi[a][b] = {0,c};
        mi[b][a] = {0,c};
    }

    rep(i,n)mi[i][i] = {0,0};

    for(int k=0;k<n;k++){
        for(int i=0;i<n;i++){
            for(int j=0;j<n;j++){
                pair<ll,ll> p1 = mi[i][k];
                pair<ll,ll> p2 = mi[k][j];
               if(p1.second+p2.second<=l){
                   min_update(mi[i][j],{0,p1.second+p2.second});

               }
//                    if(mi[i][j].first>p1.first+p2.first){
//                        mi[i][j] = {0,p1.second+p2.second};
//                    }else{
//
//                    }
//                }

            }
        }
    }

    for(int k=0;k<n;k++){
        for(int i=0;i<n;i++){
            for(int j=0;j<n;j++){
                pair<ll,ll> p1 = mi[i][k];
                pair<ll,ll> p2 = mi[j][k];
                min_update(mi[i][j],{p1.first+p2.first+1,p2.second});
//                if(p1.first+p2.first<mi[i][j].first){
//                  mi[i][j] = {p1.first+p2.first+1,mi[j][k].second};
//                }

            }
        }
    }
    int q;
    cin>>q;
    rep(i,q){
        int s,t;
        cin>>s>>t;
        if(mi[s-1][t-1].first==MOD){
            cout<<-1<<endl;
        }else{
            cout<<mi[s-1][t-1].first<<endl;
        }
    }





    return 0;
}


Measured memory_bytes: 1920
#include <stdio.h>

int main(){
    
  int m, f;
  int r;
  int total;
    
  while(1){
    scanf("%d %d %d", &m, &f, &r);
    if(m == -1 && f == -1 && r == -1) break;
	
    total = m + f;
    
    if(f == -1 || m == -1) printf("F\n");
    else if(total >= 80){
      printf("A\n");
    }
    else if(total >= 65){
      printf("B\n");
    }
    else if(total >= 50 ){
      printf("C\n");
    }
    else if(total >= 30){
      if (r >= 50) printf("C\n");
      else printf("D\n");
    }
    else printf("F\n");
  }
  return 0;
}



Measured memory_bytes: 2144
#include<iostream>
using  namespace std;
int A[105];
int main()
{
	int N,M;
	cin >> N >> M;
	int sum = 0;
	for(int i = 1;i <= N; i ++)
	{
		cin >> A[i];
		sum +=A[i];
	}
	int count = 0;
	for(int i = 1;i<=N;i++)
	{
		if(A[i]*M*4>=sum)
		count++;
	}
	if(count >= M)
	cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <algorithm>
#include <numeric>

using namespace std;

int main(int argc, char *argv[]) {
  while (true) {
    int n;
    cin >> n;
    if (n == 0)
      break;

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

    sort(score + 0, score + n);
    int sum = accumulate(score + 1, score + n - 1, 0);

    cout << sum / (n - 2) << endl;
    memset(score, 0, n);
  }
  return 0;
}

Measured memory_bytes: 1180
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let 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")
    };
}

fn main() {
    input! {
        k: i64,
        s: i64,
    }
    let mut cnt = 0;
    for i in 0..k+1 {
        for j in 0..k+1 {
            let z = s - i - j;
            if 0 <= z && z <= k {
                cnt += 1
            }
        }
    }
    println!("{}", cnt);
}

Measured memory_bytes: 4352
from fractions import gcd

N = int(input())
A = list(map(int,input().split()))

L = [0]
R = [0]

for i in range(N) :
    L.append(gcd(L[i], A[i]))
    R.append(gcd(R[i], A[N-1-i]))

R = R[::-1]
ans = 0

for i in range(N) :
    calc = gcd(L[i], R[i+1])
    ans = max(ans, calc)

print(ans)

Measured memory_bytes: 16136
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) FOR(i,0,n)
#define repr(i,n) for(int i=(n)-1;0<=i;--i)
#define each(e,v) for(auto&& e:(v))
#define all(v) begin(v),end(v)
#define dump(x) cerr<<#x<<": "<<(x)<<endl
using namespace std;
using vint = vector<int>;
using ll = long long;
using vll = vector<ll>;
template <class T> void chmin(T& a, const T& b) { a = min(a, b); }
template <class T> void chmax(T& a, const T& b) { a = max(a, b); }
void yes() { cout << "Yes" << endl; exit(0); }
void no() { cout << "No" << endl; exit(0); }

vector<bool> sieveSimple(int max) {
    vector<bool> table(max, true);
    for(int i = 4; i < max; i += 2) {
        table[i] = false;
    }
    int mid = int(floor(sqrt(max)));
    for(int i = 3; i <= mid; i += 2) {
        if(table[i]) {
            for(int j = i + i; j <= max; j += i) {
                table[j] = false;
            }
        }
    }
    return table;
}

constexpr int N = 100005;

int main() {
    int q; cin >> q;
    vint l(q), r(q);
    rep(i, q) cin >> l[i] >> r[i];
    vector<bool> table = sieveSimple(N);
    vint imos(N);
    rep(i, N) imos[i] = (table[i] && table[(i+1)/2]) ? 1 : 0;
    imos[0] = 0; imos[1] = 0; imos[2] = 0;
    rep(i, N-1) imos[i+1] += imos[i];
    // rep(i, 10) cerr << imos[i] << ","; cerr << endl;
    rep(i, q) {
        cout << (imos[r[i]] - imos[l[i]-1]) << endl;
    }
    return 0;
}


Measured memory_bytes: 1792
import heapq

INF = 1e9

n = int(input())
adj_list = [[]] * n

for u in range(n):
    U = list(map(int, input().split()[2:]))
    adj_list[u] = zip(U[0::2], U[1::2]) # adj_list[u] = (v, cost)


def dijkstra(x):
    d = [INF] * x
    d[0] = 0
    hq = [(0, 0)] # (distance, v)??????????????¬??????????????????(key, ????´?)???????????????push, pop?????????
    
    while hq:
        u = heapq.heappop(hq)[1]
        for v, c in adj_list[u]:
            if d[v] > d[u] + c:
                d[v] = d[u] + c
                heapq.heappush(hq, (d[u] + c, v))
                
    return d

for i, di in enumerate(dijkstra(n)):
    print(i,di)

Measured memory_bytes: 42376
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>
#include <map>
#include <string.h>
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)

int main()
{
ll ans,n;

cin >> n;

int table[n+1]={};
table[0]=-1;
rep(i,n) {
    cin >> table[i+1];
}
ll dp[n+1]={};
dp[0]=1;
ll re[200001]={};
ll temp;
for(int i = 1; i < n+1; i++){
    if(table[i]!=table[i-1]){
        dp[i]=(re[table[i]]+dp[i-1])%1000000007;
        re[table[i]]+=dp[i-1];
    }
    else dp[i]=dp[i-1];
    
}
//配列の中身を見る

/* for (int i = 0; i < n+1; ++i) {
    cout << dp[i] << " ";
}cout  << endl;
for (int i = 0; i < n+1; ++i) {
    cout << re[i] << " ";
}cout  << endl; */

cout << dp[n] << endl;
return 0;
}



Measured memory_bytes: 4096
#include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <deque>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <functional>
#include <utility>
#include <algorithm>
#include <numeric>
#include <typeinfo>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <ctime>

using namespace std;

#define dump(n) cout<<"# "<<#n<<"="<<(n)<<endl
#define debug(n) cout<<__FILE__<<","<<__LINE__<<": #"<<#n<<"="<<(n)<<endl
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,n) repi(i,0,n)
#define iter(c) __typeof((c).begin())
#define foreach(i,c) for(iter(c) i=(c).begin();i!=(c).end();i++)
#define allof(c) (c).begin(),(c).end()
#define mp make_pair

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int,int> pii;

double EPS=1e-10;

int main()
{
	for(string s;getline(cin,s);){
		istringstream iss(s);
		double t1,t2;
		iss>>t1>>t2;
		int ms1=t1*1000+EPS,ms2=t2*1000+EPS;
		int a[]={35500,37500,40000,43000,50000,55000,70000};
		int b[]={71000,77000,83000,89000,105000,116000,148000};
		int i1=upper_bound(a,a+7,ms1)-a;
		int i2=upper_bound(b,b+7,ms2)-b;
		const char* res[]={"AAA","AA","A","B","C","D","E","NA"};
		cout<<res[max(i1,i2)]<<endl;
	}
	
	return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
#define f first
#define t second
#define rep(i,n)for(int i=0;i<n;i++)
using namespace std;
typedef pair<int, int>P;

int s[1000], d[1000], y[1000], a, b, n, m, h, k;
P p[100000];
int main() {
	while (scanf("%d%d%d%d", &n, &m, &h, &k), n) {
		rep(i, n)scanf("%d", &s[i]);
		rep(i, m)scanf("%d%d", &a, &b), p[i] = { b,a };
		sort(p, p + m); iota(d, d + n, 0);
		rep(i, m) {
			swap(d[p[i].t - 1], d[p[i].t]);
			p[i] = { d[p[i].t - 1],d[p[i].t] };
			if (p[i].f > p[i].t)swap(p[i].f, p[i].t);
		}
		rep(i, n)y[d[i]] = s[i];
		int M = accumulate(y, y + k, 0); int S = M;
		rep(i, m)if (p[i].f < k&&p[i].t >= k)M = min(M, S + y[p[i].t] - y[p[i].f]);
		printf("%d\n", M);
	}
}

Measured memory_bytes: 3908
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1;} return 0;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1;} return 0;}
const long long INF = 1LL<<60;

int main(){
    int n;
    cin >>n;
    vector<vector<long long>>dp(4,vector<long long>(n+2,0));
    vector<vector<long long>>abc(4,vector<long long>(n+1,0));
    for(int i=0;i<n;i++){
        cin >>abc[0][i]>>abc[1][i]>>abc[2][i];
    }

    for(int j=1;j<=n;j++){
        for(int i=0;i<3;i++){
            if(i!=0) {chmax(dp[i][j],dp[0][j-1]+abc[0][j-1]);}
            if (i != 1) {chmax(dp[i][j], dp[1][j - 1] + abc[1][j-1]);}
            if (i != 2) {chmax(dp[i][j], dp[2][j - 1] + abc[2][j-1]);}
        }
        //cout<<dp[]
    }
    cout<<max(dp[0][n],max(dp[1][n],dp[2][n]))<<endl;
}


Measured memory_bytes: 7288
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   // 0-indexed昇順

int main() {
    char C; cin >> C;
    cout << (char)(C + 1) << endl;
}


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

int nt[5010000];
bool bl[5010000];
int cnt;

int main(){
	string s;cin>>s;
	nt[0]=-1;
	int k=-1,j=0;
	int l=s.size();
	if(l==1) cout<<1<<"\n"<<1<<"\n",exit(0);
	int xh;
	while(j<l){
		if(k==-1||s[j]==s[k]){
			j++;k++;
			xh=j-k;
			bl[j-1]=(xh!=j&&j%xh==0);
			//cout<<j<<" "<<xh<<"\n";
			if(s[j]!=s[k]) nt[j]=k;
			else nt[j]=nt[k];
			
		}
		else k=nt[k];
	}
	xh=l-nt[l];
	//cout<<xh<<"\n";
	if(xh==1) 	cout<<l<<"\n"<<1<<"\n",exit(0);
	if(xh==l||l%xh!=0) cout<<1<<"\n"<<1<<"\n",exit(0);

	for(int i=0;i<l/2;++i){
		swap(s[i],s[l-1-i]);
	}
	memset(nt,-1,sizeof(nt));
	k=-1,j=0;
	//cout<<s<<"\n";
	while(j<l){
		if(k==-1||s[j]==s[k]){
			j++;k++;
			xh=j-k;
			bool B=(xh!=j&&j%xh==0);
			//cout<<j<<" "<<xh<<"\n";
			if(B==0&&bl[l-1-j]==0) cnt++;
			
			if(s[j]!=s[k]) nt[j]=k;
			else nt[j]=nt[k];
			
			
		}
		else k=nt[k];
	}
	/*for(int i=0;i<l-1;i++){
		xh=i+1-nt[i+1];
		bool B=(xh!=i+1&&(i+1)%xh==0);
		if(B==0&&bl[l-2-i]==0) cnt++; 
	}*/
	cout<<2<<"\n"<<cnt<<"\n";
	return 0;
}

Measured memory_bytes: 21764
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<n+1;i++)
#define sort(A) sort(A.begin(),A.end())
#define reverse(A) reverse(A.begin(),A.end())
typedef long long ll;

int main(){
  int n,m;
  cin >> n >> m;
  vector<int> a(n);
  int sum = 0;
  rep(i,n){
    cin >> a[i];
    sum += a[i];
  }
  int ans = 0;
  rep(i,n){
    float p = (float)sum/m/4;
    if(a[i] >= p) ans ++;
  }
  if(ans >= m) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
# Problem https://atcoder.jp/contests/abc095/tasks/abc095_a
# Python 3rd Try


def solver(memoStr):
    result = 700
    if memoStr[0] == 'o':
        result = result + 100
    if memoStr[1] == 'o':
        result = result + 100
    if memoStr[2] == 'o':
        result = result + 100
    return result


if __name__ == "__main__":
    result = 0
    result = solver(input())
    print(result)


Measured memory_bytes: 2940
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] a = new int[n];
        for (int i = 0; i < n; i++) a[i] = sc.nextInt();
        int ans = 0;
        for (int i = 0; i < n; i++) {
            for (int j = i + 1; j < n; j++) {
                ans = Math.max(ans, Math.abs(a[i] - a[j]));
            }
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 21460
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
typedef long long ll;
const int N=100100;
int i,j,k,n,ch;
int a[N],op[N];
ll f[N][3];
void R(int &x) {
	x=0;ch=getchar();
	while (ch<'0' || '9'<ch) ch=getchar();
	while ('0'<=ch && ch<='9') x=x*10+ch-'0',ch=getchar();
}
void W(ll x) {
	if (x>=10) W(x/10);
	putchar(x%10+'0');
}
int main() {
	R(n);
	for (i=1;i<n;i++) {
		R(a[i]);
		ch=getchar();
		while (ch!='+' && ch!='-') ch=getchar();
		if (ch=='-') op[i]=1;
		else op[i]=0;
	}
	R(a[n]);
	memset(f,190,sizeof f);
	f[1][0]=a[1];
	for (i=1;i<n;i++) {
		for (j=0;j<=2;j++) {
			if (op[i]) {
				if ((j&1)^1) f[i+1][j]=max(f[i+1][j],f[i][j]-a[i+1]);
				else f[i+1][j]=max(f[i+1][j],f[i][j]+a[i+1]);
				if (j<2) {
					if ((j&1)^1) f[i+1][j+1]=max(f[i+1][j+1],f[i][j]-a[i+1]);
					else f[i+1][j+1]=max(f[i+1][j+1],f[i][j]+a[i+1]);
				}
			}
			else {
				if (j&1) f[i+1][j]=max(f[i+1][j],f[i][j]-a[i+1]);
				else f[i+1][j]=max(f[i+1][j],f[i][j]+a[i+1]);	
			}
		}
		f[i+1][1]=max(f[i+1][1],f[i+1][2]);
		f[i+1][0]=max(f[i+1][0],f[i+1][1]);
	}
	W(f[n][0]);puts("");
}

Measured memory_bytes: 3328
using System;
class Program
{
	static void Main(string[] args)
	{
	    string[] input = Console.ReadLine().Split('/');
	    int a  = int.Parse(input[0] + input[1] + input[2]);
	    
	    if ((a - 20190430) <= 0) {
	        Console.WriteLine("Heisei");
	    } else {
	        Console.WriteLine("TBD");
	    }
	}
}

Measured memory_bytes: 11092
import bisect as bc

N = int(input())
A = list(map(int,input().split()))
 
A.sort()
 
dp = [True for _ in range(A[-1]+1)]
finished = [False for _ in range(A[-1]+1)]
 

for i in range(N):
    if not finished[A[i]]:
        finished[A[i]] = True
        ai = A[i]
        for j in range(2,A[-1]+1):
            if ai*j > A[-1]:
                break
            dp[ai*j] = False

ans = 0
for i in range(N):
    if dp[A[i]]:
        if bc.bisect_right(A,A[i]) - bc.bisect_left(A,A[i]) == 1:
            ans += 1
 
print(ans)

Measured memory_bytes: 168148
import java.util.Scanner;
class Main {
	
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int a = (int)(N/1.08);
        if ((int)(a*1.08) == N) {
        		System.out.println(a);
        } else if ((int)((a+1)*1.08) == N) {
        		System.out.println(a+1);
        } else {
        		System.out.println(":(");
        }
    }
} 

Measured memory_bytes: 23764
#include <bits/stdc++.h>
#define ll long long
#define ls id << 1
#define rs id << 1 | 1
#define mem(array, value, size, type) memset(array, value, ((size) + 5) * sizeof(type))
#define memarray(array, value) memset(array, value, sizeof(array))
#define fillarray(array, value, begin, end) fill((array) + (begin), (array) + (end) + 1, value)
#define fillvector(v, value) fill((v).begin(), (v).end(), value)
#define pb(x) push_back(x)
#define st(x) (1LL << (x))
#define pii pair<int, int>
#define mp(a, b) make_pair((a), (b))
#define Flush fflush(stdout)
#define vecfirst (*vec.begin())
#define veclast (*vec.rbegin())
#define vecall(v) (v).begin(), (v).end()
#define vecupsort(v) (sort((v).begin(), (v).end()))
#define vecdownsort(v, type) (sort(vecall(v), greater<type>()))
#define veccmpsort(v, cmp) (sort(vecall(v), cmp))
using namespace std;
const int N = 500050;
const int inf = 0x3f3f3f3f;
const ll llinf = 0x3f3f3f3f3f3f3f3f;
const int mod = 998244353;
const int MOD = 1e9 + 7;
const double PI = acos(-1.0);
clock_t TIME__START, TIME__END;
void program_end()
{
#ifdef ONLINE
    printf("\nTime used: %.6lf(s)\n", ((double)TIME__END - TIME__START) / 1000);
    system("pause");
#endif
}
int n;
int a[N], b[N], ans[N];
int r[N], l[N];

inline void solve()
{
    memarray(l, -1), memarray(r, -1);
    scanf("%d", &n);
    for (int i = 0; i < n; ++i)
        scanf("%d", &a[i]);
    for (int i = 0; i < n; ++i)
        scanf("%d", &b[i]);
    for (int i = 0, j = n - 1; i < n; ++i, --j)
        r[a[i]] = i, l[b[j]] = j;
    int shift = 0;
    for (int i = 1; i <= n; ++i)
        if (~l[i])
            shift = max(shift, r[i] - l[i] + 1);
    for (int i = 0; i < n; ++i)
    {
        ans[(i + shift) % n] = b[i];
        if(ans[(i + shift) % n] == a[(i + shift) % n])
            return puts("No"), void();
    }
    puts("Yes");
    for (int i = 0; i < n;++i)
        printf("%d%c", ans[i], "\n "[i != n - 1]);
}

int main()
{
    TIME__START = clock();
    int Test = 1;
    // scanf("%d", &Test);
    while (Test--)
        solve();
    TIME__END = clock();
    program_end();
    return 0;
}

Measured memory_bytes: 10080
# AT DP N
#
# n items
# n-1 choices, each choice costs A[n] + A[n+1]

#    10 20 30 40

#     0  1  2  3
# 0  10 30 40      # A[0:2] = A[0:1] + A[2] or A[0] + A[1:2]
# 1     20 50
# 2        30
# 3           40
#

#    10 10 10 10 10
#
#     0  1  2  3  4
#  0 10 20       50
#  1    10
#  2       10 20 30
#  3          10
#  4             10

def f(A):
    n = len(A)
    inf = float("inf")
    dp = [[(inf, inf)] * n for _ in range(n)]
    for i in range(n):
        dp[i][i] = (A[i], 0)

    for h in range(1, n):
        for v in range(h, -1, -1):
            for j in range(v, h):
                # 1-2: 1-1 + 2-2
                # 0-3: 0-0 + 1-3
                # 0-3: 0-1 + 2-3
                # 0-3: 0-2 + 3-3
                left, lv = dp[v][j]
                right, rv = dp[j + 1][h]
                sum_ = left + right
#                print(v, h, "<-", v, j, " + ", j + 1, h, "L", dp[v][j], "R", dp[j + 1][h])
                cost = lv + rv + sum_
                if cost < dp[v][h][1]:
#                    print("* SET")
                    dp[v][h] = (sum_, lv + rv + sum_)
#    for d in dp:
#        print(d)
    return dp[0][n-1][1]

assert f([10, 10, 10, 10, 10]) == 120
assert f([10, 20, 30, 40]) == 190
assert f([1000000000, 1000000000, 1000000000]) == 5000000000
assert f([7, 6, 8, 6, 1, 1]) == 68

n = input()
A = list(map(int, input().split()))
ans = f(A)
print(ans)


Measured memory_bytes: 45660
#include<iostream>
#include<cstdio>
#include<map>
#include<set>
#include<queue>
using namespace std;
const int N=100001;
int n;
map<pair<int,int>,int> book;
set<int> e[N];
queue<pair<int,int> >q;
int f[N];
int find(int v)
{
	if(v==f[v]) return v;
	f[v]=find(f[v]);
	return f[v];
}
pair<int,int> make(int x,int y)
{
    if(x>y) swap(x,y);
    return make_pair(x,y);
}
int main()
{
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
    	f[i]=i;
    for(int i=1;i<=(n-1)*2;i++)
	{
        int x,y;
        scanf("%d%d",&x,&y);
        e[x].insert(y);
		e[y].insert(x);
        pair<int,int> t=make(x,y);
        book[t]++;
        if(book[t]==2) q.push(t);
        if(book[t]>2)
        {
        	printf("NO");
        	return 0;
		}
    }
    for(int i=1;i<n;i++)
	{
        if(q.empty())
        {
        	printf("NO");
        	return 0;
		}
        int x=0,y=0;
        while(x==y)
        {
        	x=find(q.front().first),y=find(q.front().second);
        	q.pop();
		}
        if(e[x].size()>e[y].size()) swap(x,y);
        f[x]=y;
        for(set<int>::iterator it=e[x].begin();it!=e[x].end();it++)
		{
            int v=find(*it);
            e[v].erase(e[v].find(x));
            if(v==y) continue;
            e[v].insert(y),e[y].insert(v);
            pair<int,int> t=make(v,y);
            book[t]++;
            if(book[t]==2) q.push(t);
        }
        e[x].clear();
    }
    printf("YES");
    return 0;
}

Measured memory_bytes: 39168
#include<iostream>
#include<cmath>
#include<algorithm>
#include<iomanip>
#include<string>
#include<vector>
#include<cstdio>
#include<cstring>
#include<map>
#include<set>
#include<fstream>
#include<sstream>
#include<queue>
#include<iterator>
using namespace std;
vector<int> g[2000];
int n,k;
int dfs(int x,int pre,int d,int mx){
	int ans=1;
	if(d!=mx){
		for(int i=0;i<g[x].size();i++)
			if(g[x][i]!=pre)ans+=dfs(g[x][i],x,d+1,mx);
	}
	return ans;
}


int main(){
	cin>>n>>k;
	for(int i=1;i<n;i++){
		int a,b;
		cin>>a>>b;
		a--;
		b--;
		g[a].push_back(b);
		g[b].push_back(a);
	}
  int ans=0;
	if(k%2==0){
		for(int i=0;i<n;i++)
		  ans=max(ans,dfs(i,-1,0,k/2));
	}
	else{
		for(int i=0;i<n;i++)
			for(int j=0;j<g[i].size();j++)
				ans=max(ans,dfs(i,g[i][j],0,k/2)+dfs(g[i][j],i,0,k/2));
	}

	cout<<n-ans<<endl;

  return 0;
}


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

int main(void) {
    long n, k;
    cin >> n >> k;
    vector<long> a(n);
    for(auto &e: a) cin >> e;

    vector<long> ps(n+1), ns(n+1);
    for(long i=1; i<=n; i++) {
        ps[i] = ps[i-1] + max(a[i-1], 0l);
        ns[i] = ns[i-1] + min(a[i-1], 0l);
    }

    long r = 0;
    for(long i=0; i+k<=n; i++) {
        // 0 .. [i, i+k) .. n-1
        // 1 .. i [i+1, i+k] i+k+1 .. n
        long t = (ps[n] - ps[i+k]) + (ps[i] - ps[0]);
        r = max(r, t + (ps[i+k]-ps[i]) + (ns[i+k]-ns[i]));
        r = max(r, t);
    }
    cout << r << endl;

}


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

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

    int S, h, m, s;
    cin >> S;
    h = S / 3600;
    m = S % 3600 / 60;
    s = S % 3600 % 60;

    cout << h << ":" << m << ":" << s << endl;


    return 0;
}

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

using ll = long long;

constexpr ll INF = 1e18;

int main() {
    int H, W;
    cin >> H >> W;
    vector<string> a(H);
    vector<int> cnt(26);
    for(int i = 0; i < H; ++i) {
        cin >> a[i];
        for(int j = 0; j < W; ++j) {
            cnt[a[i][j] - 'a']++;
        }
    }
    sort(cnt.rbegin(), cnt.rend());
    int rest = H * W;
    int four = 0, two = 0, other = 0;
    for(auto x : cnt) {
        four += x / 4;
        x %= 4;
        two += x / 2;
        x %= 2;
        if(x & 1) {
            other++;
        }
    }
    if(H % 2 == 1 && W % 2 == 1) {
        if(other > 1 || two > (H - 1) / 2 + (W - 1) / 2) {
            cout << "No" << endl;
        } else {
            cout << "Yes" << endl;
        }
    } else if(H % 2 == 0 && W % 2 == 0) {
        if(two > 0 || other > 0) {
            cout << "No" << endl;
        } else {
            cout << "Yes" << endl;
        } 
    } else {
        if(other > 0) {
            cout << "No" << endl;
        } else {
            if(H & 1) {
                swap(H, W);
            }
            if(H / 2 < two) {
                cout << "No" << endl;
            } else {
                cout << "Yes" << endl;
            }
        }
    }
}


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

using namespace std;

#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define fin(ans) cout << (ans) << endl;
#define blank(ans) cout << (ans) << " ";
#define mp(p, q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()

typedef long long ll;
typedef long long lli;
typedef unsigned long long ull;
typedef long double ld;
typedef string str;

typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<ld> vd;
typedef vector<str> vs;
typedef vector<ll> vll;
typedef vector<pair<ll, ll>> vpll;
typedef vector<pair<ll, str>> vpls;
typedef vector<tuple<str, ll, ll>> vtsl;
typedef vector<vector<ll>> vvll;
typedef vector<vector<char>> vvc;
typedef vector<vector<str>> vvs;

const ld PI = acos(-1.0);
const ll MAX = 9000000000000000000;
const ll MIN = -9000000000000000000;
const ld DMAX = 4500;
const ld DMIN = -4500;
const ll MOD = 1000000007;

//実行部
void Main()
{
  ll a, b; cin >> a >> b;
  fin(a * 1. / b)
}

//前処理
int main()
{
  //ios::sync_with_stdio(false);
  //cin.tie(0);
  cout << fixed << setprecision(20); //高精度少数表示
  Main();
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,X,sum=0,min=1000;
  cin>>N>>X;
  vector<int> kona(N);
  for(int i=0;i<N;i++){
    cin >>kona.at(i);
    sum +=kona.at(i);
    if(min>kona.at(i)){
      min =kona.at(i);
    }
  }
  cout<< N+(X-sum)/min<<endl;
 
}

Measured memory_bytes: 256
/*
 * PrintTestCases.c
 *
 *  Created on: 2015/02/12
 *
 */


#include <stdio.h>

int main(void){
	int i=1,x;

	while(1) {
		scanf("%d",&x);
		if(x == 0) break;

		printf("Case %d: %d\n",i,x);
		i++;
	}
	return 0;
}

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

int main(void)
{
    int X, A, B;
    cin >> X >> A >> B;
    if(B<=A)
        cout << "delicious" << endl;
    else if(B<=X+A)
        cout << "safe" << endl;
    else
        cout << "dangerous" << endl;
}

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


#define ll long long int
#define vll vector<ll>
#define vllv vector<vector<ll>> 
#define sz size()
#define pb push_back
#define ff first
#define ss second
#define all(v) v.begin(),v.end()
#define allr(v) v.rbegin(),v.rend()
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define pi 3.14159265358979323846
ll ceil1(ll n,ll m){if(n%m==0){return n/m;}return n/m +1;}
vll factor(ll n){
    vll ans;
    if(n>0)ans.pb(1);if(n==2)ans.pb(2);
    for(ll i=2;i*i<=n;i++){if(n%i==0){ans.pb(i);if(n/i!=i)ans.pb(n/i);}}if(n>2)ans.pb(n);
    return ans;
}
ll fact(ll n){
	
    ll res = 1; 
    for (ll i = 2; i <= n; i++) 
        res = res * i; 
    return res; 
} 
  
int nCr(ll n, ll r) 
{ 
    return fact(n) / (fact(r) * fact(n - r)); 
} 
  
void dfs(vllv &v,ll k,vll &par,vll &dis,ll p)
{
 
    par[k]=p;
    dis[k]=dis[p]+1;
    for(ll i=0;i<v[k].sz;i++){
        if(v[k][i]!=p){
            dfs(v,v[k][i],par,dis,k);
        }
    }
}
bool sortbysec(const pair<string,int> &a,const pair<string,int> &b){return (a.second<b.second);} 


ll ston(string s) 
{ 
    stringstream geek(s); 
    ll x = 0; 
    geek >> x; 
    
  
    return x; 
}
ll pow2(ll n,ll k){ll ans=1;
    while(k>0){
        if(k%2==1)ans=ans*n;n=n*n;k/=2;
    }return ans;}
bool prime(int n){
    int i,j;
    for(i=2;i<=sqrt(n);i++){
        if(n%i==0){
            return false;
        }
    }
    return true;
}
bool bserch(vector<string> a, string s){
	
	ll l=0,r=a.sz-1,mid;
	while(l<=r){
		mid=(l+r)/2;
		if(a[mid]==s)return true;
		if(a[mid]<s){
			l=mid+1;
		}else{
			r=mid-1;
		}
	}
	return false;
}

bool sortcol( const vector<int>& v1, 
               const vector<int>& v2 ) { 
 return v1[0] < v2[0]; 
} 

void solve()
{
	string s;
	cin>>s;
	for(ll i=0;i<s.sz;i++)
	{
		if(s[i]==',')
			cout<<" ";
		else
			cout<<s[i];
	}
	return;
}

int main()
{
	fast;
    ll q;
    q=1;
    // cin>>q;
    while(q--)
    {
        solve();
    }
    return 0;
}


Measured memory_bytes: 256
S = input()
Slist = list(S)

if Slist[0] == Slist[1]:
    if S.count(Slist[0]) == 2 and S.count(Slist[2]) == 2:
        print("Yes")
    else:
        print("No")

elif S.count(Slist[0]) == 2 and S.count(Slist[1]) == 2:
        print("Yes")

else:
    print("No")

Measured memory_bytes: 3060
#include<stdio.h> 
#include<string.h>
#define min(X,Y) (X<Y?X:Y)
#define max(X,Y) (X>Y?X:Y)
#define INF 0x3f3f3f3f
int de[20][20];
int re[20];
void floyd(int N)
{
	int i,j,k;
	for(k=0;k<=N;k++)
		for(i=0;i<=N;i++)
			for(j=0;j<=N;j++)
				de[i][j]=min(de[i][j],de[i][k]+de[k][j]);
}
int main()
{
	int n,i;
	while(scanf("%d",&n),n)
	{
		memset(re,0,sizeof(re));
		memset(de,INF,sizeof(de));
		int m1,m2,m3,maxn=0;
		for(i=1;i<=n;i++)
		{
			scanf("%d%d%d",&m1,&m2,&m3);
			de[m1][m2]=m3;
			de[m2][m1]=m3;
			maxn=max(maxn,max(m1,m2));
		}
		int r1=-1,r2=INF,j;
		for(i=0;i<=maxn;i++)
			de[i][i]=0;
		floyd(maxn);
		for(i=0;i<=maxn;i++)
		{
			for(j=0;j<=maxn;j++)
				re[i]+=de[i][j];
			if(re[i]<r2)
			{
				r1=i;
				r2=re[i];
			}
		}
		printf("%d %d\n",r1,r2);
	}
	return 0;
} 


Measured memory_bytes: 2112
#include <stdio.h>
#include <iostream>
#include <iomanip>
#include <vector>
#include <cstdlib>
#include <cmath>
#include <numeric>
#include <algorithm>
#include <sstream>
#include <string>
#include <map>
#include <set>
using namespace std;

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


int main() {
	int N, T;
	cin >> N >> T;
	int min_cost = 1010;
	rep(i, N) {
		int c, t;
		cin >> c >> t;
		if (t > T) continue;
		min_cost = min(c, min_cost);
	}
	if (min_cost==1010) cout << "TLE" << endl;
	else cout << min_cost << endl;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int N = scan.nextInt();
        int K = scan.nextInt();
        String S = scan.next();
        int answer = solve(N, K, S);
        System.out.println(answer);
    }
    public static int solve(int N, int K, String S) {
        char[] data = S.toCharArray();
        List<Integer> group = new ArrayList<>();
        List<Integer> kind = new ArrayList<>();
        int length = data.length;
        char prev = ' ';
        int count = 0;
        for (int i = 0; i < length; i++) {
            if (prev != data[i]) {
                if (count != 0) {
                    group.add(count);
                    kind.add(prev == '0' ? 1 : 0);
                }
                prev = data[i];
                count = 1;
                continue;
            }
            count += 1;
        }
        if (0 < count) {
            group.add(count);
            kind.add(prev == '0' ? 1 : 0);
        }
        Integer[] group_array = group.toArray(new Integer[0]);
        Integer[] kind_array = kind.toArray(new Integer[0]);
        int len = group_array.length;
        int[] g = new int[len + 1];
        int[] k = new int[len + 1];
        Arrays.fill(g, 0);
        Arrays.fill(k, 0);
        for(int i = 0; i < len; i++) {
            g[i+1] += g[i] + group_array[i];
            k[i+1] += k[i] + kind_array[i];
        }
        int answer = 0;
        int j = 1;
        for(int i = 1; i <= len; i++) {
            if (j < i) {
                j = i;
            }
            for(; j <= len; j++) {
                if (k[j] - k[i-1] <= K) {
                    answer = Math.max(answer, g[j] - g[i - 1]);
                    continue;
                }
                break;

            }
        }
        return answer;
    }
}


Measured memory_bytes: 29200
/*
ツ単ツ渉δづ可堕ォツつオツづ? 60ツづ?環?づェツづ篠閉ェ, 60ツづ?環?づ?つスツつ?づ慊づィツつェツ秒.
 */
#include <iostream>
using namespace std;

int main(){
  int sum = 0;

  for(int i = 0; i < 4; i++){
    int x;
    cin >> x;
    sum += x;
  }

  cout << sum / 60 << endl;
  cout << sum % 60 << endl;
}

Measured memory_bytes: 0
n = int(input())
*l, = map(int,input().split())
odd=0
even=0
four=0
for i in l:
  if i%2==1:
    odd+=1
  elif i%4==0:
    four+=1
if four>=odd:
  print('Yes')
else:
  if odd-four == 1 and odd+four == len(l):
    print('Yes')
  else:
    print('No')



Measured memory_bytes: 15020
n = int(input())
a = list(map(int,input().split()))

comb1 = max(a)
comb2 = comb1//2
a.sort()
p = 0
keep = float("inf")
for i in range(n):
    if abs(a[i] - comb2) <= keep:
        p = a[i]
        keep = abs(a[i]-comb2)

if comb1 == p:
    print(comb1,0)
else:
    print(comb1,p)

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

int main(){
    int N;  cin >> N;
    vector<tuple<ll,ll,ll>> Val(N);
    for(int i=0; i<N; i++){
        ll A, B;  cin >> A >> B;
        Val[i] = make_tuple(A+B,A,B);
    }
    sort(Val.begin(), Val.end());

    ll ans = 0;
    for(int i=0; i<N; i++){
        int n = N-1-i;
        if(i%2==0){
            ans += get<1>(Val[n]);
        }else{
            ans -= get<2>(Val[n]);
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
int n,k,mid,Left,Right,len[200005];
bool Judge(int lim)
{
	int cnt=0;
	for(int i=1;i<=n;i++)
	{
		if(len[i]%lim==0) cnt+=len[i]/lim-1;
		else cnt+=len[i]/lim;
	}
	return cnt>k;
}
int main()
{
	scanf("%d%d",&n,&k),Left=1;
	for(int i=1;i<=n;i++) scanf("%d",&len[i]),Right=max(Right,len[i]);
	while(Left<=Right)
	{
		mid=(Left+Right)/2;
		if(Judge(mid)) Left=mid+1;
		else Right=mid-1;
	}
	printf("%d\n",Left);
	return 0;
}


Measured memory_bytes: 4536
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
const int INF = 1001001001;
const ll limit = 1000000000000000000;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  vector<ll> a(n);
  ll now = 1;
  rep(i, n) {
    cin >> a[i];
    if(a[i] == 0) now = 0;
  }
  if(now != 0) {
    rep(i, n) {
      if(now > limit/a[i]) {
        now = -1;
        break;
      }
      now *= a[i];
    }
  }
  cout << now << endl;
  return 0;
}

Measured memory_bytes: 3952
#include <bits/stdc++.h>
using namespace std;
#define loop(i,b,e) for(int i=b;i<=e;i++)
#define loop2(i,e,b) for(int i=e;i>=b;i--)
#define io ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define fi first
#define se second
#define X real()
#define Y imag()
#define cp(a,b)	( (conj(a)*(b)).imag() )
#define length(a) (hypot((a).imag(), (a).real()))
typedef complex<double> point;
typedef long long ll;
typedef unsigned long long ull;
double PI = 3.141592653589793;
const double EPS = 1e-9;
const int N = 1e6 + 5;
const ll mod = 1e9 + 7;
const int oo = 1e9;
int dx[] = { 0, 0, 1, -1, 1, -1, 1, -1 };
int dy[] = { 1, -1, 0, 0, -1, 1, 1, -1 };

int n = 3;
int t[30];

int main() {
	int ans = oo;
	loop(i, 0, n - 1)
		scanf("%d",&t[i]);
	do {
		int curr = 0;
		loop(i, 1, n - 1)
			curr += abs(t[i] - t[i - 1]);
		ans = min(ans, curr);
	} while (next_permutation(t, t + n));
	printf("%d",ans);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using intpair=pair<int,int>;
using llpair=pair<ll,ll>;
using llvec=vector<ll>;
using llmat=vector<vector<ll>>;
#define PI 3.141592653589793
#define llmattp(name,a,b,num) name(a,vector<ll>(b,num))
#define INTINF 1<<30
#define LLINF 1LL<<60
#define ABS(x) ( (x)>0 ? (x) : -(x) )

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

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

ll gcd(ll a, ll b) { //最大公約数
	if(a==0||b==0) return 0;
	if(a<b) swap(a,b);
	ll tmp = a%b;
	while(tmp!=0) {
		a = b;
		b = tmp;
		tmp = a%b;
	}
	return b;
}

ll factorial(ll x) { //階乗
	ll f=1;
	for(ll i=2; i<x; i++) {
		f*=i;
	}
	return f;
}

ll nPr(ll n, ll r) {
	ll result=1;
	for(ll i=r+1; i<=n; i++) result*=i;
	return result;
}

ll nCr(ll n, ll r) {
	if (n == r) { return 1; }
	if (r > n) { return 0; }

	if (r > n / 2) { r = n - r; }

	if (n == 0) { return 0; }
	if (r == 0) { return 1; }
	if (r == 1) { return n; }

	double result = 1;
	for (double i = 1; i <= r; i++) {
		result *= (n - i + 1) / i;
	}

	return (ll)result;
}

bool IsPrime(ll num) { //素数判定
	if (num < 2) return false;
	else if (num == 2) return true;
	else if (num % 2 == 0) return false; // 偶数はあらかじめ除く

	double sqrtNum = sqrt(num);
	for (ll i = 3; i <= sqrtNum; i += 2)
	{
		if (num % i == 0)
		{
			// 素数ではない
			return false;
		}
	}

	// 素数である
	return true;
}

ll GreaterBinarySearch(ll *array, ll key, ll max, ll min) {
	if(array[max]<array[min]) {
		return NULL;
	} else {
		ll mid = max + (min-max)/2;
		if(array[mid]<key) {
			return GreaterBinarySearch(array,key,max,mid-1);
		} if(array[mid]>key) {
			return GreaterBinarySearch(array,key,mid+1,min);
		} else {
			return mid;
		}
	}
}

int DigitNum(ll n) { //桁数
	int digit=0;
	ll wari=1LL;
	while(n/wari) {
		digit++;
		wari*=10;
	}
	return digit;
}

void PrimeFact(ll x) { // 素因数分解 出力部を適切に書き換え
	int i=2;
	while(x%2&&i*i<=x) {
		cout<<2<<endl;
		x/=2;
	}
	i++;
	while(i*i<=x) {
		if(x%i) {
			i+=2;
			continue;
		}
		cout<<i<<endl;
		x/=i;
	}
}

bool Palind(string s) { //回文判定
	return s == string(s.rbegin(), s.rend());
}

int main() {
	int K,N; cin>>K>>N;
	int maxrange=0;
	int A[N]; cin>>A[0];
	for(int i=1; i<N; i++) {
		cin>>A[i];
		chmax(maxrange,A[i]-A[i-1]);
	}
	chmax(maxrange,A[0]+K-A[N-1]);

	cout<<K-maxrange<<endl;
}


Measured memory_bytes: 1024
/*Function Template*/
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
const int mod = 1000000007;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define ALL(a)  (a).begin(),(a).end()
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);


ll Len(ll n) {
  ll s=0;
  while(n!=0) s++, n/=10;
  return s;
}


ll Sint(ll n) {
  ll m=0,s=0,a=n;
  while(a!=0) s++, a/=10;
  for(ll i=s-1;i>=0;i--) m+=n/((ll)pow(10,i))-(n/((ll)pow(10,i+1)))*10;
  return m;
}


ll Svec(vector<ll> v){
  ll n=0;
  for(ll i=0;i<v.size();i++) n+=v[i];
  return n;
}


ll GCD(ll a,ll b){
  ll r,tmp;
/*自然数 a > b を確認・入替*/
  if(a<b){
    tmp=a,a=b,b=tmp;
  }
/*ユークリッドの互除法*/
  r=a%b;
  while(r!=0){
    a=b,b=r,r=a%b;
  }
  return b;
}


ll LCM(ll a,ll b){
  ll c=a,d=b,r,tmp;
/*自然数 a > b を確認・入替*/
  if(a<b){
    tmp=a,a=b,b=tmp;
  }
/*ユークリッドの互除法*/
  r=a%b;
  while(r!=0){
    a=b,b=r,r=a%b;
  }
  return c/b*d;
}


ll Factorial(ll n){
  ll m=1;
  while(n>=1) m*=n,n--;
  return m;
}

vector<pair<char,ll>> runlength(string s,vector<pair<char,ll>> p){
  ll x=1;
  if(s.size()==1){
    p.push_back(pair<char,ll>(s[0],1));
    return p;
  }
  for(ll i=0;i<s.size()-1;i++){
    if(s[i]==s[i+1]){
      x++;
      if(i==s.size()-2){
        p.push_back(pair<char,ll>(s[i],x));
      }
    }else{
      p.push_back(pair<char,ll>(s[i],x));
      x=1;
      if(i==s.size()-2){
        p.push_back(pair<char,ll>(s[s.size()-1],x));
      }
    }
  }
  return p;
}



/*↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓*/
int main() {
  IOS;
  ll n,k;
  cin>>n>>k;
  ll ans=(ll)pow(n/k,3);
  if(k%2==1){
    cout<<ans<<endl;
  }else{
    ll cnt=0;
    for(ll i=1;i<=n;i++){
      if(i%k==k/2) cnt++;
    }
    cout<<ans+(ll)pow(cnt,3)<<endl;
  }
}

Measured memory_bytes: 256
// https://atcoder.jp/contests/arc069/tasks/arc069_b
#include <bits/stdc++.h>
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 MAXN = 1e5 + 4;
int n;
char s[MAXN];
int a[MAXN];

int main() {
    cin >> n;
    cin >> s;
    s[n] = s[0], s[n + 1] = s[1];
    REP(i, 4) {
        a[0] = i & 1, a[1] = (i >> 1) & 1;
        FOR(j, 2, n + 2) a[j] = (s[j - 1] == 'x') ^ a[j - 1] ^ a[j - 2];
        if (a[0] == a[n] && a[1] == a[n + 1]) {
            REP(j, n) { cout << (a[j] ? "W" : "S"); }
            cout << "\n";
            return 0;
        }
    }
    cout << "-1\n";
    return 0;
}


Measured memory_bytes: 768