akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
using namespace std;

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

	int max_l = -1;
	int sum = 0;
	for (int i = 0; i < N; ++i) {
		int l;
		cin >> l;
		sum += l;
		max_l = max(l, max_l);
	}
	if (max_l < sum - max_l)
		cout << "Yes\n";
	else
		cout << "No\n";

	return 0;
}


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

const int N = 200005;
const int MOD = 1e9 + 7;

long long fact[N];
long long inve[N];

long long modPow(long long base,int po) {
	long long ret = 1;
	while(po) {
		if(po & 1) ret = (ret * base) % MOD;
		base = (base * base) % MOD;
		po >>= 1;
	}
	return ret;
}

void prec() {
	fact[0] = inve[0] = 1;
	for(int i = 1 ; i < N ; i++) {
		fact[i] = (fact[i-1] * i) % MOD;
		inve[i] = modPow(fact[i],MOD-2);
	}
}

long long comb(int x,int y) {

	if(x <0 || y < 0 || x < y) return 0;
	long long res = (fact[x] * inve[y]) % MOD;
	res =  (res * inve[x-y]) % MOD;
	//cout << x << " " << y <<  " " << res << endl;
	return res;
}

int main() {
	prec();

	int h, w, a , b;
	cin >> h >> w >> a >> b;
	int bawah = h-a;
	int col = b;
	long long ans = 0;

	for(int i = bawah ; i >= 1 ; i--) {
		int sisa_row = h - i;
		int sisa_col = w-b;
		long long ways = (comb(i-1+col-1,col-1) * comb(sisa_row+sisa_col-1,sisa_col-1)) % MOD;

		ans = (ans + ways) % MOD;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n-1; i >= 0; i--)
#define all(x) x.begin(), x.end()
using ll = long long;
using pii = pair<int, int>;
const int mod = 1e9+7;

int main() {
    string s, t;
    cin >> s >> t;
    int _s = s.size(), _t = t.size();
    priority_queue<string, vector<string>, greater<string>> ans;
    for (int i = 0; i + _t <= _s; i++) {
        string x = s;
        bool flag = false;
        for (int j = 0; j < _t; j++) {
            if (s[i + j] != t[j] && s[i + j] != '?') {
                flag = true;
                break;
            } else {
                x[i + j] = t[j];
            }
        }
        if (flag) continue;
        for (int k = 0; k < _s; k++) {
            if (x[k] == '?') {
                x[k] = 'a';
            }
        }
        ans.push(x);
    }
    if (ans.empty()) {
        cout << "UNRESTORABLE" << endl;
    } else {
        cout << ans.top() << endl;
    }
}

Measured memory_bytes: 3516
#include <bits/stdc++.h>
using namespace std;
long long a[200005];
long long b[200005],c[200005];
int main()
{
    long long n,m,i,j,k,x=0,y,z,t;
    cin>>i>>j>>k;
    if(k==i)
    {
        cout<<0<<" "<<j<<endl;
    }
    else if(k>i)
    {
        k=k-i;
        y=j-k;
        cout<<0<<" ";
        if(y<0)
        {
            cout<<0<<endl;
        }
        else
        {
            cout<<y<<endl;
        }
    }
    else
    {
        cout<<i-k<<" "<<j<<endl;
    }

}




Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,N) for(int i=0;i<N;i++)
#define MAX_I INT_MAX //1e9
#define MIN_I INT_MIN //-1e9
#define MAX_UI UINT_MAX //1e9
#define MAX_LL LLONG_MAX //1e18
#define MIN_LL LLONG_MIN //-1e18
#define MAX_ULL ULLONG_MAX //1e19
  typedef long long ll;
  typedef pair<int,int> PII;
  typedef pair<char,char> PCC;
  typedef pair<ll,ll> PLL;
  typedef pair<char,int> PCI;
  typedef pair<int,char> PIC;
  typedef pair<ll,int> PLI;
  typedef pair<int,ll> PIL; 
  typedef pair<ll,char> PLC; 
  typedef pair<char,ll> PCL; 

const int MAXV = 1e5+1;
const ll INF = MAX_LL;
int main(void){
  int N,W; cin >> N >> W;
  const int MAXV = 1e5+1;
  PII v[N];
  REP(i,N) cin >> v[i].first >> v[i].second;
  ll dp[2][MAXV];
  //next[j]:価値がjとなる最小の重さ(INFなら存在しない)
  ll *prev = dp[0];
  ll *next = dp[1];
  REP(i,MAXV)prev[i] = INF;
  prev[0] = 0;
  REP(i,N){
    REP(j,MAXV){
      next[j] = prev[j];
      if(j-v[i].second>=0&&
          prev[j-v[i].second] != INF) next[j] = min(next[j],prev[j-v[i].second]+v[i].first);
    }
    swap(prev,next);
  }
  swap(prev,next);
  int ans = 0;
  REP(j,MAXV){
    if(next[j] <= W) ans = j;
  }
  cout << ans << endl;
  return 0;
}


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

int main() {
  int k, s;
  cin >> k >> s;
  int count = 0;
  for (int x = 0; x <= k; x++) {
    for (int y = 0; y <= k; y++) {
      int z = s - x - y;
      if (0 <= z && z <= k) {
        count++;
      }
    }
  }
  cout << count << endl;
  return 0;
}

Measured memory_bytes: 256
import math
n = int(input())
a = 1
b = 1
for i in range(1, math.floor(math.sqrt(n))+1):
  if n % i == 0:
    a = n / i
    
b = n / a
print(max([len(list(str(int(a)))), len(list(str(int(b))))]))

Measured memory_bytes: 3064
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<map>
#include<algorithm>
#define For(i,j,k)	for(int  i=j;i<=k;i++)
#define Dow(i,j,k)	for(int  i=k;i>=j;i--)
#define ll long long
using namespace std;
int n,m,cnt[200001],x,y;
int main()
{
	ios::sync_with_stdio(false);
	cin>>n>>m;
	For(i,1,m)
		{cin>>x>>y;cnt[x]++;cnt[y]++;}
	For(i,1,n)
	if(cnt[i]&1){printf("NO\n");return 0;}
	printf("YES\n");
}

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

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int,int,int> tpl;

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RFOR(i,a,b) for(int i=(a)-1;i>=(b);--i)
#define RREP(i,n) RFOR(i,n,0)

const double EPS = 1e-9;
const double PI  = acos(-1.0);
const int INT_INF = 2147483647;
const long long LL_INF = 1LL<<60;
const long long MOD = 1000000007;

#define CLR(a) memset((a), 0 ,sizeof(a))

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

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

int main(void){
    int N; cin >> N;
    VI a(N+1,0); REP(i,N) cin >> a[i+1];
    VI ans(N+1,0);
    RFOR(i,N+1,1){
        int tmp = 0;
        for(int j=2*i; j<=N; j+=i){
            if(ans[j]) tmp++;
        }
        if(a[i] != tmp%2) ans[i] = 1;
    }
    int M = 0;
    REP(i,N) M += ans[i+1];
    cout << M << endl;
    REP(i,N) if(ans[i+1]) cout << i+1 << " ";
    cout << endl;
    return 0;
}

Measured memory_bytes: 2432
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <cstdio>
#include <algorithm>
#include <functional>
#include <string>
#include <numeric>
#include <stack>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;

#define rep(i, a, N) for(int i = a; i < N; i++)

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

    vector<int> h(N);
    rep(i, 0, N) cin >> h[i];

    vector<int> dp(N, 1000000000);
    dp[0] = 0;
    for (int i = 0; i < N; i++) {
        for (int j = 1; i - j >= 0 && j <= K; j++) {
            dp[i] = min(dp[i], dp[i - j] + abs(h[i] - h[i - j]));
        }
    }
    cout << dp[N - 1] << endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <assert.h>
#include <vector>
#include <unordered_map>
#include <queue>
#include <climits>
#include <cmath>
#include <algorithm>
using namespace std;
constexpr int64_t MOD = 1e9 + 7;

// Combination
void COMinit(vector<int64_t>& fac, vector<int64_t>& finv, vector<int64_t>& inv) {
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for (int32_t i = 2; i < (int32_t)fac.size(); i++){
      fac[i] = fac[i - 1] * i % MOD;
      inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
      finv[i] = finv[i - 1] * inv[i] % MOD;
  }
  return;
}

int64_t COM(int32_t n, int32_t k, vector<int64_t>& fac, vector<int64_t>& finv) {
  if (n < k) return 0;
  if (n < 0 || k < 0) return 0;
  return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

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

  int64_t n,k;
  cin >> n >> k;
  vector<int64_t> fac(2*n, 0);
  vector<int64_t> finv(2*n, 0);
  vector<int64_t> inv(2*n, 0);
  COMinit(fac, finv, inv);

  int64_t res = 0;
  //cif (k < n) {
    res = 1;
    for (int64_t i = 1; i <= min(k,n); i++) {
      int64_t cmb_empty = COM(n, i, fac, finv);
      cmb_empty %= MOD;
      int64_t a = n - i;
      int64_t H = COM(a + i - 1, i, fac, finv);
      H %= MOD;
      res += (H * cmb_empty) % MOD;
      res %= MOD;
    }
  //} else {
  //  res = COM(2*n - 1, n, fac, finv);
  //}

  cout << res << endl;
  return 0;
}


Measured memory_bytes: 9728
#include <iostream>
#include <string> 
#include <vector>
#include <algorithm>

using namespace std;

int main(){

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

    int n,l;
    cin >> n >> l;

    vector<string> s(n);

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

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

    for(auto x :s){
        cout << x;
    }
    cout << endl;
    return 0;
}

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

using namespace std;

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	int n;
	long long mod;
	cin >> n >> mod;
	n*=3;
	
	vector<vector<long long>> dp(n+1,vector<long long>(n));
	dp[0][0]=1;
	for(int i=1;i<=n;i++){
		for(int k=0;k<n;k++){
			dp[i][k]=(dp[i][k]+dp[i-1][k])%mod;
			if(i>1 && k>0) dp[i][k]=(dp[i][k]+dp[i-2][k-1]*(i-1)%mod)%mod;
			if(i>2 && k>0) dp[i][k]=(dp[i][k]+dp[i-3][k-1]*(i-1)%mod*(i-2)%mod)%mod;
		}
	}
	long long res=0;
	for(int i=0;i<=(n/3);i++){
		res=(res+dp[n][i])%mod;
	}
	
	cout << res << "\n";
	return 0;
}

Measured memory_bytes: 281856
//INCLUDE
//------------------------------------------
#include <bits/stdc++.h>
//DEFINE
//------------------------------------------
#define ll long long
#define ld long double
#define ALLv(a)  (a).begin(),(a).end()
#define ALL(a,n)  (a),(a)+n
#define vi vector<long long>
#define vd vector<long double>
#define vs vector<string>
//CONST
//------------------------------------------
#define INF 1010000000000000017LL
#define MOD 1000000007LL
#define EPS 1e-12
#define PI 3.14159265358979323846
//REPEAT
//------------------------------------------
#define   FOR(i,m,n) for(ll (i)=(m);   (i)<(n);  (i)++)
#define   REP(i,n)   for(ll (i)=0;     (i)<(n);  (i)++)
#define  REPS(i,x)   for(ll (i)=1;     (i)<=(x); (i)++)
#define  RREP(i,x)   for(ll (i)=(x)-1; (i)>=0;   (i)--)
#define RREPS(i,x)   for(ll (i)=(x);   (i)> 0;   (i)--)
#define  WREP(i,in,j,jn) REP(i,in)REP(j,jn)
//-----------------------------------------
#define dcml(n) fixed<<setprecision(n)
using namespace std;
int main(void){
    string str[]={"SUN","MON","TUE","WED","THU","FRI","SAT"};
    string S;cin>>S;
    REP(i,7){
        if(str[i]==S){
            cout<<7-i<<"\n";
        }
    }
} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(vec) vec.begin(),vec.end()
#define mp make_pair
using namespace std;
using ll=long long;
using P=pair<ll,ll>;
const ll INF=1LL<<30;
const ll LINF=1LL<<62;
const double eps=1e-9;
const ll MOD=1000000007LL;
template<typename T>void chmin(T &a,T b){a=min(a,b);};
template<typename T>void chmax(T &a,T b){a=max(a,b);};
int dx[4]={0,1,0,-1};
int dy[4]={1,0,-1,0};
int main(){
	ll n,e,t;cin>>n>>e>>t;
	vector<ll> x(n+10);
	for(int i=1;i<=n;i++){
		cin>>x[i];
	}
	vector<ll> dp(n+10,LINF);
	dp[0]=0;
	int id=0;
	ll mix=LINF;
	for(int i=1;i<=n;i++){
		if(i>1)mix+=2LL*(x[i]-x[i-1]);
		while(id<i&&2LL*(x[i]-x[id+1])>t){
			chmin(mix,dp[id]+2LL*(x[i]-x[id+1]));
			id++;
		}
		chmin(dp[i],mix);
		chmin(dp[i],dp[id]+t);
	}
	cout<<e+dp[n]<<endl;
}


Measured memory_bytes: 1792
#include<iostream>
#include<string>
using namespace std;
int main() {
	int sum = 0;
	string S;
	cin >> S;
	int size = S.size();
	for (int i = 0; i<S.size(); i++) {
		if(S[i]=='+'){
			sum += 1;
		}
		else if (S[i] == '-') {
			sum -= 1;
		}
	}
	cout << sum;
	return 0;
}

Measured memory_bytes: 256
N,A,B = map(int, input().split())
H = [int(input()) for _ in range(N)]

def f(n):
    cnt = 0
    flag = True
    for h in H:
        x = (h-B*n)//(A-B) + min((h-B*n)%(A-B), 1)
        cnt += max(0, x)
    if cnt <= n:
        return True
    else:
        return False
        
l = 0
r = 10**9
while r-l > 1:
    m = (r+l)//2
    if f(m):
        r = m
    else:
        l = m
        
if f(l):
    print(l)
else:
    print(r)

Measured memory_bytes: 52696
from math import sqrt


def calc(pos_x, pos_y):
  sum = 0
  for i in range(0, len(pos_x)):
    sum += (pos_x[i] - pos_y[i]) ** 2

  return sqrt(sum).is_integer()


size, z = map(int, input().split())
items = []
for i in range(0, size):
  items.append(list(map(int, input().split())))

# items = []
# items.append(list(map(int, "-3 7 8 2".split())))
# items.append(list(map(int, "-12 1 10 2".split())))
# items.append(list(map(int, "-2 8 9 3".split())))

count = 0

for i in range(0, len(items)):
  for j in range(i + 1, len(items)):
    count += 1 if calc(items[i], items[j]) else 0

print(count)


Measured memory_bytes: 3064
using System;

namespace ALDS1_2_A
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());
            var a = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
            int cnt = 0;
            for (int i = 0; i < n - 1; i++)
            {
                for (int j = n - 1; j > i; j--)
                {
                    if (a[j] < a[j-1])
                    {
                        a[j-1] ^= a[j];
                        a[j] ^= a[j-1];
                        a[j-1] ^= a[j];
                        cnt++;
                    }
                }
            }
            Console.Write(a[0]);
            for (int i = 1; i < n; i++) Console.Write(" " + a[i]);
            Console.WriteLine();
            Console.WriteLine(cnt);
        }
    }
}

Measured memory_bytes: 9200
N = int(input())
A = [int(x) for x in input().split()]

from fractions import gcd

mod = int(1e9 + 7)

lcm = 1
for x in A:
    lcm = lcm * x // gcd(lcm, x)
lcm %= mod

ans = 0
for x in A:
    ans += lcm * pow(x, mod - 2, mod)
    ans %= mod

print(ans)


Measured memory_bytes: 67176
import scala.io.StdIn
import scala.annotation.tailrec
import scala.collection.mutable.ListBuffer

object Main{
  def main(args: Array[String]){
    StdIn.readLine()
    val line = StdIn.readLine().split(" ").toList.map(_.toInt)

    println(line.sorted.mkString(" "))
    println(sSort(List(), line, 0))
  }

  @tailrec
  def sSort(sorted: List[Int], unsorted: List[Int], n: Int): Int={
    if(unsorted.length == 0) n
    else if(unsorted.sorted == unsorted) n
    else {
      if(unsorted.indexWhere(_ == unsorted.min) == 0) sSort(sorted :+ unsorted.min, unsorted.updated(0, unsorted(unsorted.indexWhere(_ == unsorted.min))).updated(unsorted.indexWhere(_ == unsorted.min), unsorted.head).tail, n)
      else sSort(sorted :+ unsorted.min, unsorted.updated(0, unsorted(unsorted.indexWhere(_ == unsorted.min))).updated(unsorted.indexWhere(_ == unsorted.min), unsorted.head).tail, n+1)
    }
  }
}

Measured memory_bytes: 46012
#include<bits/stdc++.h>
#include <ext/pb_ds/detail/standard_policies.hpp>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long
#define int long long 
#define pb push_back
#define ins insert
#define rs resize
#define br break;
#define cont continue;
#define vi vector<int>
#define vll vector<long long>
#define vvi vector<vector<int>>
#define si set<ll>
#define sll set<long long>
#define pii pair<ll,ll>
#define pll pair<long long, long long>
#define speed ios_base::sync_with_stdio(false);cin.tie(NULL);
#define vec vector
#define cend cout<<endl;
#define sc second
#define fr first
#define retz return 0;
#define ll_MAX (ll)(1e9*1e9)
#define ll_MIN (ll)(-1e9*1e9)
#define lb lower_bound
#define ub upper_bound
#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 ps(arr, n) for(int i=1; i<n; i++)arr[i]+=arr[i-1];
#define inp(arr, n)for(int i=0; i<n; i++)cin>>arr[i];
#define out(arr, n)for(int i=0; i<n; i++)cout<<arr[i];
#define inp1(arr,n,m)for(int i=0; i<n; i++)for(int j=0;j<m;j++)cin>>arr[i][j];
#define out1(arr,n,m)for(int i=0; i<n; i++)for(int j=0;j<m;j++)cin>>arr[i][j];
#define loop(q) for(auto it:q)
#define loop1(q) for(auto&it:q)
#define db1 cout << "*" << endl
#define db2 cout << "YES" << endl
using namespace std;
using namespace __gnu_pbds; 
#define oset(X) tree<X,null_type,less<X>, rb_tree_tag, tree_order_statistics_node_update> 
#define roset(X) tree<X,null_type,greater<X>, rb_tree_tag, tree_order_statistics_node_update>  
#define okey order_of_key //lower_bound_set
#define ofind find_by_order
#define cyes cout << "Yes" << endl; 
#define cno cout << "No" << endl;
#define mod (long long)1000000007
#define mod2 (long long)998244353
#define INT_MAX1 900000000
#define MAXN 2000000
#define INF INT_MAX




 
void solve()
{
    string s;
    cin >> s;
    int n = s.size();
    string s1 = s.substr(0, n/2);
    string s2 = s.substr((n+3)/2-1, n/2);
    bool f = 1;
    for(int i=0; i<s1.size()/2; i++)
        f = f&(s1[i]==s1[s1.size()-1-i]);
    for(int i=0; i<s2.size()/2; i++)
        f = f&(s2[i]==s2[s2.size()-1-i]);
    for(int i=0; i<s.size()/2; i++)
        f = f&(s[i]==s[s.size()-1-i]);
    if(f)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}   


signed main()
{


  
    
    speed;
    int t = 1;
    //cin >> t;
    while(t--)
        solve();
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define FIO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define mod 1000000007
#define test ll t; t=1; while(t--)
typedef long long int ll;
int main() {
    FIO;
    test{
        ll m,k,ans=0,x;
        cin>>m>>k;
        for(ll i=0;i<k;i++){
            cin>>x;
            ans+=x;
        }
        ans=m-ans;
        ans<0 ? cout<<"-1\n" : cout<<ans<<endl;
    }
	return 0;
}


Measured memory_bytes: 3656
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int a = sc.nextInt();
		String s = "";
		if (a == 25) s = "Christmas";
		if (a == 24) s = "Christmas Eve";
		if (a == 23) s = "Christmas Eve Eve";
		if (a == 22) s = "Christmas Eve Eve Eve";
		// 出力
		System.out.println(s);
	}
}


Measured memory_bytes: 21716
#include <iostream>
#include <cstdint>

using namespace std;

int ones(u_int16_t v)
{
    u_int16_t res = v;
    res = (0x5555 & res) + ((~0x5555 & res) >> 1);
    res = (0x3333 & res) + ((~0x3333 & res) >> 2);
    res = (0x0f0f & res) + ((~0x0f0f & res) >> 4);
    res = (0x00ff & res) + ((~0x00ff & res) >> 8);

    return res;
}

int main()
{
    int N, M;
    int p[10];
    u_int16_t bulb[10];

    cin >> N >> M;

    for (int i = 0; i < M; i++)
    {
        int k;
        cin >> k;

        bulb[i] = 0;
        for (int j = 0; j < k; j++)
        {
            u_int16_t s;
            cin >> s;
            s--;
            u_int16_t flag = 1 << s;
            bulb[i] = bulb[i] | flag;
        }
    }

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

    int sum = 0;
    for (u_int16_t sw = 0; sw < (1 << N); sw++)
    {
        bool light = true;
        for (int j = 0; j < M; j++)
        {
            if (ones(sw & bulb[j]) % 2 != p[j])
            {
                light = false;
            }
        }
        if (light)
        {
            sum++;
        }
    }

    cout << sum << endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<map>
#include<iomanip>
using namespace std;


int main() {
	map<int, int> mp;
	long long int n, m = 0;
	long double dp[4000][1505] = {},p[4000],tmp=0;
	string str, str2;
	cin >> n ;
	for (int i = 1; i <= n; i++) {
		cin >> p[i];
		
	}
	m = n / 2 + 1;
	dp[0][m] = 1;
	
	for (int i = 1; i <= n; i++) {
		
		for (int j = 1; j <= m; j++) {
			dp[i][j - 1] += dp[i - 1][j] * p[i];

			dp[i][j] += dp[i-1][j] * (1 - p[i]);
		}
		dp[i][0] += dp[i-1][0] ;

	}
	
	
	cout <<setprecision(15)<< dp[n][0];
}


Measured memory_bytes: 94336
#include <iostream>
#include <cstdio>
#include <cassert>
#include <cstring>
#include <cmath>
#include <functional>
#include <algorithm>
#include <utility>
#include <vector>
#include <string>
#include <map>
#include <set>
#define ms(a,b) memset(a,b,sizeof(a))
using namespace std;
typedef long long ll;
typedef pair<int,int> PII;
const int mod = 998244353;
const int inf = 1 << 30;
const int maxn = 100000 + 5;

int n; string s;

int main() {
  cin >> n >> s;
  if (n % 2) return puts("No"), 0;
  string half = s.substr(0, n / 2);
  if (half + half == s) puts("Yes");
  else puts("No");
  return 0;
}

Measured memory_bytes: 256
N, M = map(int, input().split())
X = list(map(int, input().split()))
X.sort()

def m():
    a = [0] * M
    b = [0] * M
    for i in range(1, M):
        a[i] = abs(X[i] - X[i-1])
        b[i] = i

    if M <= N:
        return 0
    a.sort(reverse=True)
    for i in range(N-1):
        a[i] = 0

    return sum(a)


print(m())

Measured memory_bytes: 13968
#include <bits/stdc++.h>
#define REP(i,  n) for (int i  =  0; i < (int)(n); ++i)
#define REPR(i,  n) for (int i  =  n - 1; i >= 0; --i)
using namespace std;
constexpr int MOD = 1e9 + 7;
typedef long long ll;

int main() {
  int N; cin >> N;
  map<string, int> m;
  REP(i, N) {
    string S; cin >> S;
    m[S]++;
  }
  cout << "AC x " << m["AC"] << endl;
  cout << "WA x " << m["WA"] << endl;
  cout << "TLE x " << m["TLE"] << endl;
  cout << "RE x " << m["RE"] << endl;
}


Measured memory_bytes: 3632
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
	int l = sc.nextInt() + sc.nextInt();
	int r = sc.nextInt() + sc.nextInt();
    if (l > r) {
      System.out.println("Left");
    } else if (l < r) {
      System.out.println("Right");
    } else {
      System.out.println("Balanced");
    }
  }
}


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

typedef long long ll;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    
    int n;
    cin >> n;
    while(n > 0) {
        int digit = n % 10;
        if (digit == 7) {
            cout << "Yes";
            return 0;
        }
        n /= 10;
    }
    cout << "No";
}


Measured memory_bytes: 3644
n, k = map(int, input().split())
r, ss, p = map(int, input().split())
s = input()
hands = [None]*n
wins = {'r':'p', 's':'r', 'p':'s'}
h_s = {'r':r, 's':ss, 'p':p}
ans = 0
for i, c in enumerate(s):
    if i - k >= 0:
        if wins[c] == hands[i-k]:
            hs = set(wins.keys())
            hs.remove(wins[c])
            if i + k < n:
                if wins[s[i+k]] in hs:
                    hs.remove(wins[s[i+k]])
            hands[i] = hs.pop()
            continue
    hand = wins[c]
    hands[i] = hand
    ans += h_s[hand]

print(ans)
        




Measured memory_bytes: 4212
import java.util.*;
import java.util.stream.*;

public class Main {
  public static void main(String[] args) {
    Scanner in = new Scanner(System.in);
    int N = in.nextInt();
    int[] A = new int[N];
    int cnt = 0, min = Integer.MAX_VALUE;
    boolean zero = false;
    long ans = 0;
    for (int i = 0; i < N; i++) {
      A[i] = in.nextInt();
      ans += Math.abs(A[i]);
      min = Math.min(min, Math.abs(A[i]));
      if (A[i] < 0) {
        cnt++;
      }
      if (A[i] == 0) {
        zero = true;
      }

    }
    if (cnt % 2 == 0 || zero) {
      System.out.println(ans);
    } else {
      System.out.println(ans - min * 2);
    }
  }
}


Measured memory_bytes: 49852
#include <bits/stdc++.h>
#define REPZ(i, z, n) for(decltype(n) i = (z); i < (n); i++)
#define REP(i, n) for(decltype(n) i = 0; i < (n); i++)
#define ALL(v) v.begin(), v.end()
#define SIZE(v) ((ll)(v).size())
#define MAX(v) (*max_element(all(v)))
#define MIN(v) (*min_element(all(v)))
#define INF 1000000000000 //1E+12
#define MOD 1000000007    //合同式の法

// 略
#define PB push_back
#define F first
#define S second
#define MP make_pair
#define READ cin >>
#define PRINT cout <<

typedef long long ll;
typedef unsigned long long ul;
// 1s間で可能なループ回数2E+8回
// intの最大値2147483647~2E+9
// long longの最大値9223372036854775807〜9E+18
// 総和accumulate
// 単純リストvector<> push_back
// 連想配列map<key,value> insert,
// pair キーとバリューを格納 firstとsecondでアクセス
// 小数点指定 setprecision()
// to_string<->stoi
// stoll(longlong)
// stod(double)
// 大文字65-90(-32)
// 小文字97-122(+32)
using namespace std;
int main(){
  // faster
  ios::sync_with_stdio(false);
  std::cin.tie(nullptr);

  int n,m; cin >> n >> m;
  // 右から数字が何か入れる
  int d[]={0,0,0};
  REP(i,m){
    int digit, value; cin >> digit >> value; 
    digit--;
    if(d[digit]!=0 and d[digit]!=value){
      cout << -1 << endl;
      return 0;
    } 
    if(n!=1 and digit==0 and value==0){
      cout << -1 << endl;
      return 0;
    }
    d[digit]=value;
  }
  if(n!=1 and d[0]==0) d[0]=1;
  int res=0;
  REP(i,n){
    if(d[i]==-1) res=res*10;
    else res=res*10+d[i];
  }
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>

using namespace std;

int main(void) {
  int n, x;
  scanf("%d", &n);

  string s;

  cin >> s;

  int max = 0;
  x = 0;
  for(int i = 0; i < n; i++) {
    if(s[i] == 'I') {
      x++;
    }
    else {
      x--;
    }
    if(x > max) {
      max = x;
    }
  }

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

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	double a, b, c, d, e, f;
	double x, y;
	int D;
	
	while (scanf("%lf %lf %lf %lf %lf %lf", &a, &b, &c, &d, &e, &f) != EOF){
		x = (e * c - b * f) / (a * e - b * d);
		y = (d * c - a * f) / (b * d - a * e);
		//y = (c * d - a * f) / (b * d - a * e);
		//x = (c - b * y) / a;
		
		x += 0.0001;
		y += 0.0001;
		printf("%.3f %.3f\n", x, y);
	}
	

	
	return (0);
}

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

using namespace std;

typedef long long ll;

const ll MOD = 1000000007;
const ll INF = 1LL<<60;
//int INF = numeric_limits<int>::max();

ll gcd(ll a, ll b) {
	if (a%b==0) return b;
	else return gcd(b, a%b);
}

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

int main(int, char**) {
	ll a, b, c, d;
	cin >> a >> b >> c >> d;
	ll x = lcm(c, d);
	ll u = b - (b/c + b/d - b/x);
	a--;
	ll l = a - (a/c + a/d - a/x);
	cout << u - l << endl;
	return 0;
}

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

#define Pb push_back
#define Mp make_pair
#define ff first
#define ss second
#define Max(x,y,z) max(x,max(y,z))
#define Min(x,y,z) min(x,min(y,z))
#define INF LONG_LONG_MAX
#define MINF LONG_LONG_MIN
#define endl "\n"
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)

#define db1(x) cout<<#x<<" : "<<x<<endl;
#define db2(x,y) cout<<#x<<" : "<<x<<"\t"<<#y<<" : "<<y<<endl;
#define db3(x,y,z) cout<<#x<<" : "<<x<<"\t"<<#y<<" : "<<y<<"\t"<<#z<<" : "<<z<<endl;

typedef long long int ll;
typedef long double ld;

const int  N = 1e5+5;
const int inf = INT_MAX;
const int MOD = 1e9+7;


void solve()
{
   ll a,b,v,w,t;
   cin >> a >> v >> b >> w >> t;
   ll d1 = abs(a-b);
   ll d2 = (v-w)*1LL*t;
   if(d1<=d2)
   {
      cout << "YES";
   }
   else
   {
      cout << "NO";
   }
}

int32_t main()
{
   IOS;
   //freopen("input.txt", "rt", stdin);
   //freopen("output.txt", "wt", stdout);
   int t=1;
   //cin >> t;
   for(int i=1;i<=t;i++)
   {
      //cout<<"Case #"<<i<<": ";
      solve();
   }
   return 0;
}
/*==============================================================================================================================================================*/


Measured memory_bytes: 3636
N,M,C = map(int,input().split())
B = list(map(int,input().split()))

cnt = 0
for i in range(N):
    f = 0
    A = list(map(int,input().split()))
    for j in range(M):
        f += A[j]*B[j]
    f += C
    if f > 0:
        cnt += 1
print(cnt)

Measured memory_bytes: 3060
while True:
    n = int(input())
    if n == 0:
        break
    
    score = list(map(int, input().split()))
    m = sum(score) / len(score)
    
    ls = [  (score[i] - m)**2 / n for i in range(n)]
    aa = sum(ls)
    print(pow(aa, 1/2))


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

#define REP(i,num) for(int i=0;i<(num);++i)
#define LOOP(i) while(i--)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto pitr=c.begin();pitr!=c.end();++pitr){cout<<*pitr;if(next(pitr,1)!=c.end())cout<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

using namespace std;
using ll = long long;

constexpr ll atcoder_mod = 1e9+7;

template<typename T=int>
T in(){ T x; cin >> x; return (x); }
template<typename T=int,typename C=vector<T>>
C vecin(int N){ C x(N);REP(i,N){ x[i]=in<T>(); }return move(x); }

void vout(){ cout << endl; }
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){ cout << ' ' << h;vout(forward<Tail>(t)...); }
void out(){ cout << endl; }
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){ cout << h;vout(forward<Tail>(t)...); }

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

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);

	ll H=in(),W=in();
	ll V=H*W;
	if(H==1 || W==1){
		out(1);
		return 0;
	}
	out(V%2LL?V/2LL+1LL:V/2LL);
	return 0;
}


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

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}

using ll=long long;
using R=long double;
const R EPS=1e-9L; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r){return(r > EPS)-(r < -EPS);}
inline R sq(R x){return sqrt(max(x,0.0L));}

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

// Problem Specific Parameter:

using pii=pair<int,int>;
set<pii> ans;

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

	rep(x,n) if((x+0)%2) ans.insert(pii(x,0));
	rep(x,n) if((x+n-1)%2) ans.insert(pii(x,n-1));
	rep(y,n) if((0+y)%2) ans.insert(pii(0,y));
	rep(y,n) if((n-1+y)%2) ans.insert(pii(n-1,y));
	rep(y,1,n) rep(x,n) if(x%3==0 and (x+y)%2==1) ans.insert(pii(x,y));
	


	cout << ans.size() << endl;
	for(auto &it:ans) cout << it.first << " " << it.second << endl;

	return 0;
}

Measured memory_bytes: 9344
#include <stdio.h>
#include <limits.h>

int main(void){
    int num;
    int maxValue;
    int minValue;
    int i;
    int r;

    maxValue = INT_MIN;
    minValue = INT_MAX;

    scanf( "%d" , &num );
    scanf( "%d" , &minValue );

    for ( i = 0 ; i < ( num - 1 ) ; i++ ){
        scanf( "%d" , &r );
        if ( maxValue < r - minValue ) {
            maxValue = r - minValue;
        }
        if ( minValue > r ) {
            minValue = r ;
        }
    }

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

    return 0;
}



Measured memory_bytes: 1992
#include <cstdio>
#include <algorithm>

using namespace std;

long long a[300][300];
long long b[300][300];

int main() {
    int n, i, j, k;
    long long ans = 0;
    
    scanf("%d", &n);
    
    for (i = 0; i < n; i++) {
        for (j = 0; j < n; j++) {
            scanf("%lld", &a[i][j]);
            
            b[i][j] = a[i][j];
        }
    }
    
    for (i = 0; i < n; i++) {
        for (j = 0; j < n; j++) {
            for (k = 0; k < n; k++) {
                b[j][k] = min(b[j][k], b[j][i] + b[i][k]);
            }
        }
    }
    
    for (i = 0; i < n; i++) {
        for (j = i + 1; j < n; j++) {
            if (a[i][j] > b[i][j]) {
                puts("-1");
                
                return 0;
            } else {
                for (k = 0; k < n; k++) {
                    if (k == i || k == j) continue;
                    
                    if (b[i][k] + b[k][j] == b[i][j]) break;
                }
                
                if (k == n) ans += b[i][j];
            }
        }
    }
    
    printf("%lld\n", ans);
    
    return 0;
}


Measured memory_bytes: 1536
#include <bits/stdc++.h>
using namespace std;
using ull = unsigned long long;
using Vl = vector<ull>;
const ull MOD = 1000000007;
#define rep(i, ns, ne) for (int i = ns; i < ne; ++i)

int S;
Vl v;
void input() { cin >> S; }

void solve() {
  v.resize(S + 1);
  v[0] = 1;
  for (int i = 3; i <= S; ++i) v[i] = (v[i - 1] + v[i - 3]) % MOD;
  cout << v[S] << endl;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  input();
  solve();
  getchar();
}

Measured memory_bytes: 3612
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
typedef long long ll;
namespace mp = boost::multiprecision;
using Mint = mp::cpp_int;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i = int(a); i < int(b); i++)
#define all(v) v.begin(), v.end()
#define uni(v) v.erase(unique(all(v)), v.end())
#define sort_g(v) sort(all(v), greater<int>())
#define dump(x) cerr << #x << ' ' << '=' << ' ' << x << endl

int main() {
    int N, A;
    cin >> N;
    
    vector<pair<int, int>> L(N);
    rep(i, N) {
        cin >> A;
        L.at(i) = make_pair(A, i + 1);
    }

    sort(all(L));

    for(auto P : L) {
        cout << P.second << " ";
    }
    cout << endl;
}

Measured memory_bytes: 1664
#include <stdio.h>
#include <limits.h>
#include <math.h>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <cstring>
#include <string>
#include <sstream>
#include <algorithm>
#include <iomanip>
#include <iostream>

#define VARIABLE(x) cerr << #x << "=" << x << endl
#define BINARY(x) static_cast<bitset<16> >(x);
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define REP(i,m,n) for (int i=m;i<(int)(n);i++)
#define if_range(x, y, w, h) if (0<=(int)(x) && (int)(x)<(int)(w) && 0<=(int)(y) && (int)(y)<(int)(h))

const int INF = 100000000;
typedef double D;
const double EPS = 1e-8;
const double PI = 3.14159;
int dx[4]={-1, 0, 1, 0}, dy[4]={0, -1, 0, 1};
using namespace std;
typedef pair<int, int> P;

/** Problem1127 : Building a Space Station **/
struct Edge {
	int from, to;
	double cost;
	Edge(int from_, int to_, double cost_) : from(from_), to(to_), cost(cost_){}
	bool operator <(const Edge &rhs) const {
		return cost < rhs.cost;
	}
};

struct UnionFind {
	vector<int> data;
	UnionFind(int v) : data(v, -1) {}
	int root(int x) {
		return data[x] < 0 ? x: (data[x] = root(data[x]));
	}
	bool same(int x, int y) {
		return root(x) == root(y);
	}
	void merge(int x, int y) {
		x = root(x), y = root(y);
		if (x != y) {
			if (size(y) > size(x)) swap(x, y);
			data[x] += data[y]; data[y] = x;
		}
	}
	int size(int x) {
		return -data[root(x)];
	}
};

double kruskal(const int v, vector<Edge> es) {
	sort(es.begin(), es.end());
	double ans = 0;
	UnionFind uf(v);
	for (int i=0; i<es.size(); i++) {
		if (uf.same(es[i].from, es[i].to)) continue;
		uf.merge(es[i].from, es[i].to);
		ans += es[i].cost;
	}
	return ans;
}

int main()
{
	int n;
	while (cin>>n, n) {
		vector<double> x(n), y(n), z(n), r(n);
		vector<Edge> e;
		
		rep(i, n) {
			cin>>x[i]>>y[i]>>z[i]>>r[i];
		}
		rep(i, n) {
			rep(j, n) {
				if (i != j) {
					double d = sqrt((x[i]-x[j])*(x[i]-x[j]) + (y[i]-y[j])*(y[i]-y[j]) + (z[i]-z[j])*(z[i]-z[j]));
					d -= r[i] + r[j];
					d = max(0.0, d);
					e.push_back(Edge(i, j, d));
				}
			}
		}
		printf("%.3f\n", kruskal(n, e));
	}
	return 0;
}

Measured memory_bytes: 1632
#include <stdio.h>

int main()
{
	int a = 0;
	int b = 0;
	int c = 0;
	int sum = 0;

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

	if (a < b) {
		sum += a;
		if (c < b) {
			sum += c;
		} else {
			sum += b;
		}
	} else {
		sum += b;
		if (c < a) {
			sum += c;
		} else {
			sum += a;
		}
	}

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

	return 0;
}

Measured memory_bytes: 128
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
using namespace std;
using ll = long long;
typedef long long ll;
typedef vector<ll> VL;
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define INF 999999999
typedef pair<ll, ll> P;
vector<P> p[100010];
bool flag[100010];
ll V,E;
int main(){
  priority_queue<P,vector<P>,greater<P>> que;
  ll sum=0;
  cin>>V>>E;
  ll s,t,w;
  REP(i,V)flag[i]=false;
  REP(i,E){
    cin >>s>>t>>w;
    p[s].push_back(P(w,t));
    p[t].push_back(P(w,s));
  }

  //priority queueに頂点０の辺を入れておく//
  REP(i,p[0].size()){
    que.push(p[0][i]);
  }
  //頂点0のフラグ立てと頂点のカウントを１にセットしておく//
  ll count=1;
  flag[0]=true;
  while(count<V){
    P q=que.top();que.pop();
    t = q.second;
   if(flag[t]==false){
     sum+=q.first; flag[t]=true; count++;
     REP(i,p[t].size()){
       que.push(p[t][i]);
     }
   }
  }
  cout<<sum<<endl;
}



Measured memory_bytes: 14540
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.math.BigDecimal;

class Main {

	// インデックス定数
	private static final int A = 0;
	private static final int B = 1;
	private static final int C = 2;
	private static final int D = 3;
	private static final int E = 4;
	private static final int F = 5;

	/**
	 * ax + by = c、dx + ey = f より、以下を用いてx,yを求める。
	 *  x = (ce - bf)/(ae - bd)
	 *  y = (cd - af)/(bd - ae)
	 *
	 */
	public static void main(String[] args) {

		// ストリームを作成する
		BufferedReader reader = new BufferedReader(new InputStreamReader(
				System.in));

		while (true) {
			// 入力値を受け取り、合計を数値にして返す
			BigDecimal[] input = readNumArray(reader);
			// 入力がない場合は終了
			if (input == null) {
				return;
			}

			// 数式からxとyを求める
			BigDecimal x = input[C]
					.multiply(input[E])
					.subtract(input[B].multiply(input[F]))
					.divide(input[A].multiply(input[E]).subtract(
							input[B].multiply(input[D])));
			BigDecimal y = input[C]
					.multiply(input[D])
					.subtract(input[A].multiply(input[F]))
					.divide(input[B].multiply(input[D]).subtract(
							input[A].multiply(input[E])));

			// 結果を出力する
			System.out.println(x.setScale(3, BigDecimal.ROUND_HALF_UP) + " "
					+ y.setScale(3, BigDecimal.ROUND_HALF_UP));
		}
	}

	/**
	 * ストリームから1行読み込んで、数値の配列として返す。 値が取得できなかった場合はnullを返す。
	 *
	 * @param reader
	 *            入力ストリーム
	 * @return 数値の配列
	 */
	private static BigDecimal[] readNumArray(BufferedReader reader) {
		String[] array = null;
		try {
			String line = reader.readLine();
			if (line == null || line.length() == 0) {
				return null;
			}
			array = line.split(" ");
		} catch (IOException e) {
			throw new RuntimeException();
		}
		BigDecimal[] numArray = new BigDecimal[array.length];
		for (int i = 0; i < numArray.length; i++) {
			numArray[i] = new BigDecimal(array[i]);
		}
		return numArray;
	}
}

Measured memory_bytes: 17016
import sys

sys.setrecursionlimit(1000000)

def input_from_console():
    n = int(input().strip())
    h_list = list(map(int, input().split()))
    return n, h_list


def solve(n, h_list):
    dp = [-1] * (n+2)
    dp[0] = 0
    dp[1] = abs(h_list[1]- h_list[0])
    def dp_solve(i):
        if dp[i] != -1:
            return dp[i]
        dp[i] = min(
            dp_solve(i-1) + abs(h_list[i] - h_list[i-1]),
            dp_solve(i-2) + abs(h_list[i] - h_list[i-2]),
        )
        return dp[i]
    return dp_solve(n-1)


def main():
    n, h_list = input_from_console()
    print(solve(n, h_list))


if __name__ == "__main__":
    import sys

    if sys.gettrace():  # Check if the python interpreter is in debug mode or not.
        check_cases()
    else:
        main()


Measured memory_bytes: 112660
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int a,b;
  
  cin>>a>>b;
  
  if(a==b)
  {
    for(int i=0;i<a;i++)
    {
      cout<<a;
    }
  }
  else
  {
    int k=min(a,b);
    int l=max(a,b);
    
    for(int i=0;i<l;i++)
      cout<<k;
  }
  
  return 0;
}

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();
		int m = sc.nextInt();
		int sum = 0;

		for (int i = 0; i < m; i++) {
			int a = sc.nextInt();
			sum += a;
		}

		if (n - sum >= 0) {
			System.out.println(n - sum);
		} else {
			System.out.println("-1");
		}

		sc.close();

	}
}

Measured memory_bytes: 46228
import math
a, b, x = map(int, input().split())

if x == a**2*b:
  print(0)
  
elif x >= a**2*b/2:
  print(90 - math.degrees(math.atan(a**3/(2*a**2*b-2*x))))
else:
  
  print((90 - math.degrees(math.atan(2*x/(a*b**2)))))


Measured memory_bytes: 9192
#include <iostream>
#include <cstdio>
#include <algorithm>
typedef long long ll;
using namespace std;
const int maxn = 100009;
int k;
int main(){
    scanf("%d",&k);
    if(k/100 == 7 || k/10%10 == 7 || k%10 == 7)printf("Yes");
    else printf("No");
    return 0;
}

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



int main(void){
int a,b,c,k;
int sum=0;
scanf("%d %d %d %d",&a,&b,&c,&k);
if(k<=a){printf("%d",k);return 0;}
else{sum=sum+a;k=k-a;a=0;}
if(k<=b){printf("%d",sum);return 0;}
else{k=k-b;b=0;}
printf("%d",sum-k);
}


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

#define ll long long int

using namespace std;

bool isGood(ll n, ll m, ll v, ll p, vector<ll> const & A, ll x) {
    if (x<p) return true;
    ll now = A[x] + m;
    if (A[p - 1] > now) return false;
    ll score = 0;
    score += (p-1) * m;
    score += (n-x) * m;
    for (ll i = p - 1; i < x; ++i) {
        score += min(m, max(0LL, now - A[i]));
    }
    return score >= m * v;
}

int main() {
    ll n, m, v, p;
    cin >> n >> m >> v >> p;
    vector<ll> A(n);
    for (auto & a : A) cin >> a;
    sort(A.begin(), A.end(), greater<ll>());

    ll ok = -1;
    ll ng = n;

    while (abs(ng - ok) > 1) {
        ll mid = (ok+ng)/2;
        if (isGood(n,m,v,p,A,mid)) ok = mid;
        else ng = mid;
    }

    cout << ok+1 << endl;
}


Measured memory_bytes: 1024
//#include "stdafx.h"
#include<iostream>
#include<algorithm>
using namespace std;

void maximumProfit()
{
	const int MAX = 200000;
	int R[MAX];
	int N;
	cin >> N;
	for (int i = 0; i < N; i++)
	{
		cin >> R[i];
	}
	int mi = R[0];
	int ma = -2000000000;
	for (int i = 1; i < N; i++)
	{
		ma = max(ma, R[i] - mi);
		mi = min(mi, R[i]);
	}

	cout << ma << endl;
}

void insertionSort()
{
	const int LEN = 1000;
	int N;
	int A[LEN];
	cin >> N;
	for (int i = 0; i < N; i++)
	{
		cin >> A[i];
	}

	for (int k = 0; k < N; k++)
	{
		if (k == 0)
		{
			cout << A[k] << flush;
		}
		else
		{
			cout << " " << A[k] << flush;
		}
	}
	cout << endl;

	for (int i = 1; i < N; i++)
	{
		int j = i - 1;
		int v = A[i];
		while (j >= 0 && A[j] > v)
		{
			A[j + 1] = A[j];
			j--;
		}
		A[j + 1] = v;

		for (int k = 0; k < N; k++)
		{
			if (k == 0)
			{
				cout << A[k] << flush;
			}
			else
			{
				cout << " " << A[k] << flush;
			}
		}
		cout << endl;

	}

}

void bubbleSort()
{
	const int LEN = 100;
	int A[LEN];
	int N;
	cin >> N;

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

	bool flag = true;
	int count = 0;
	while (flag)
	{
		flag = false;
		for (int j = 0; j < N - 1; j++)
		{
			if (A[j] > A[j + 1])
			{
				int temp = A[j];
				A[j] = A[j + 1];
				A[j + 1] = temp;
				flag = true;
				count++;
			}
		}
	}

	for (int j = 0; j < N; j++)
	{
		cout << A[j] << flush;
		if (j != N - 1)cout << " " << flush;
	}
	cout << endl;
	cout << count << endl;



}

int main()
{
	//maximumProfit();
	//insertionSort();
	bubbleSort();
	return 0;
}

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

#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define F0R(i,a) FOR(i,0,a)
#define ROF(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define R0F(i,a) ROF(i,0,a)

using ll = long long;
using ld = long double;
ll INF = LLONG_MAX;

using vi = vector<int>;
using vll = vector<ll>;
using pii = pair<int, int>;

namespace output {
	void pr(int x) { cout << x; }
	void pr(long x) { cout << x; }
	void pr(ll x) { cout << x; }
	void pr(unsigned x) { cout << x; }
	void pr(unsigned long x) { cout << x; }
	void pr(unsigned long long x) { cout << x; }
	void pr(float x) { cout << x; }
	void pr(double x) { cout << x; }
	void pr(ld x) { cout << x; }
	void pr(char x) { cout << x; }
	void pr(const char* x) { cout << x; }
	void pr(const string& x) { cout << x; }
	void pr(bool x) { pr(x ? "true" : "false"); }
	template<class T> void pr(const complex<T>& x) { cout << x; }
	
	template<class T1, class T2> void pr(const pair<T1,T2>& x);
	template<class T> void pr(const T& x);
	
	template<class T, class... Ts> void pr(const T& t, const Ts&... ts) { 
		pr(t); pr(ts...); 
	}
	template<class T1, class T2> void pr(const pair<T1,T2>& x) { 
		pr("{",x.f,", ",x.s,"}"); 
	}
	template<class T> void pr(const T& x) { 
		pr("{"); // const iterator needed for vector<bool>
		bool fst = 1; for (const auto& a: x) pr(!fst?", ":"",a), fst = 0; 
		pr("}");
	}
	
	void print() { pr("\n"); } // print w/ spaces
	template<class T, class... Ts> void print(const T& t, const Ts&... ts) { 
		pr(t); if (sizeof...(ts)) pr(" "); print(ts...); 
	}
}

using namespace output;

int solve(string S, char c) {
	int fail = S.size();
	int moves = 0;
	while (true) {
		int occ = 0;
		F0R(i, S.size()) if (S[i] == c) ++occ;
		if (occ == 0)
			return fail;
		if (occ == S.size())
			return moves;

		string SP (S.size()-1, '.');
		F0R(i, S.size() - 1) {
			if (S[i] == c || S[i+1] == c) SP[i] = c;
		}
		S = SP;
		++moves;
	}
}
int main() {
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	string S;
	cin >> S;
	int best = S.size();
	for (char c = 'a'; c <= 'z'; ++c) {
		best = min(best, solve(S, c));
	}
	print(best);
}

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

int main() {
	int N;
	cin >> N;
	long SUM = 0;
	long l;
	long MAX = -1000;
	for(int i = 0; i < N; i++) {
		cin >> l;
		SUM += l;
		MAX = max(MAX, l);
	}
	if((SUM - MAX) > MAX) {
		cout << "Yes" << endl;
	} else {
		cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
    #include <bits/stdc++.h>
    using namespace std;
    typedef long long ll;
    typedef pair<int, int> pii;
    typedef vector<int> vi;
    typedef vector<bool> vb;
    typedef vector<string> vs;
    typedef vector<ll> vl;
    typedef vector<vector<int, int> > vvi;
    #define pb push_back
    #define mp make_pair
    #define f first
    #define s second
    #define in insert
    #define FOR(i,a,b) for (int i = a; i < b; i++)
    #define all(x) (x).begin(), (x).end()
    #define rall(x) (x).rbegin(), (x).rend()
    #define speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    const int INF = 1e9 + 5;
    int main(){
        int n;
        cin >> n;
        cout << (n*(n+1))/2;
    }

Measured memory_bytes: 256