akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
long long K;
int main(){
    cin>>K;
    if(K<50) {
        cout<<2<<'\n';
        cout<<(K+1)/2+1<<' '<<K/2;
        return 0;
    }
    // for(int i=50;i<K;i++){
    // long long K=i;
    long long X=K/50;
    long long Y=K%50;
    // cout<<i<<endl;
    cout<<"50\n";
    if(Y==0){
        for(int i=0;i<50;i++){
            cout<<X+49<<' ';
        }
    }
    else{
        for(int i=0;i<Y;i++)cout<<X+50-i<<' ';
        for(int i=0;i<50-Y;i++){
            cout<<X+49-Y<<' ';
        }
    }
    cout<<'\n';
    // }
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int i, j;
	int a, b;
	int top[3] = {0};
	
	a = 0;
	b = 0;
	for (i = 0; i < 10; i++){
		scanf("%d", &j);
		if (top[0] < j){
			top[2] = top[1];
			top[1] = top[0];
			top[0] = j;
		}
		else if (top[1] < j){
			top[2] = top[1];
			top[1] = j;
		}
		else if (top[2] < j){
			top[2] = j;
		}
	}
	printf("%d\n%d\n%d\n", top[0], top[1], top[2]);
	
	return (0);
}

Measured memory_bytes: 0
#include<stdio.h>
int MIN(int a,int b){return a<b?a:b;}
int ta[1010],to[1000010],nt[1000010],co[1000010],F[1010];
int MF(int s,int t,int e,int min){
  if(s==t||min==0)return min;
  int i,r;
  F[s]=1;
  for(i=ta[s];i+1;i=nt[i]){
    if(F[to[i]])continue;
    r=MF(to[i],t,e,MIN(min,co[i]));
    co[i]-=r;
    co[(i+e)%(2*e)]+=r;
    if(r)return r;
  }
  return 0;
}
//???????????????
//s??????t???????????§???????±?????????????????????°v????????°e???a??????b????????£???c????????????????????????
int maxf(int s,int t,int v,int e,int *a,int *b,int *c){
  int i,f,r;
  for(i=0;i<v;i++)ta[i]=-1;
  for(i=0;i<e;i++){
    nt[i  ]=ta[to[i+e]=a[i]];
    nt[i+e]=ta[to[i  ]=b[i]];
    co[ta[a[i]]=i  ]=c[i];
    co[ta[b[i]]=i+e]=0;
  }
  for(f=0;r=MF(s,t,e,1000000000);f+=r){
    for(i=0;i<v;i++)F[i]=0;
  }
  return f;
}int main(){
  int n,a[3010],b[3010],c[3010],m,r=0,i;
  scanf("%d",&n);
  for(i=1;i<n;i++){
    scanf("%d",&m);
    if(m){
      a[r  ]=i;
      b[r  ]=n;
      c[r++]=1e9;
    }
  }
  for(i=1;i<n;i++){
    scanf("%d %d %d",&a[r],&b[r],&c[r]);
    r++;
  }
  printf("%d\n",maxf(0,n,n+1,r,a,b,c));
  return 0;
}
    

Measured memory_bytes: 4740
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define mx 1

int main()
{	
	ios_base::sync_with_stdio(0);
	int n,a;
	cin>>n;
	int fours=0,twos=0;
	for(int i=1; i<=n; i++){
		cin>>a;
		if(a%4==0) fours++;
		else if(a%2==0) twos++;
	}
	if(fours+fours+1 >=n || fours+fours+twos >=n) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
}



Measured memory_bytes: 256
//#define NDEBUG
#include <cstddef>
#include <cstdint>
#include <vector>

namespace n91 {

using i8 = std::int_fast8_t;
using i32 = std::int_fast32_t;
using i64 = std::int_fast64_t;
using u8 = std::uint_fast8_t;
using u32 = std::uint_fast32_t;
using u64 = std::uint_fast64_t;
using isize = std::ptrdiff_t;
using usize = std::size_t;

constexpr usize operator"" _z(unsigned long long x) noexcept {
  return static_cast<usize>(x);
}

class rep {
  const usize f, l;

public:
  class itr {
    friend rep;
    usize i;
    constexpr itr(const usize x) noexcept : i(x) {}

  public:
    void operator++() noexcept { ++i; }
    constexpr usize operator*() const noexcept { return i; }
    constexpr bool operator!=(const itr x) const noexcept { return i != x.i; }
  };
  constexpr rep(const usize first, const usize last) noexcept
      : f(first), l(last) {}
  constexpr itr begin() const noexcept { return itr(f); }
  constexpr itr end() const noexcept { return itr(l); }
};
class revrep {
  const usize f, l;

public:
  class itr {
    friend revrep;
    usize i;
    constexpr itr(usize x) noexcept : i(x) {}

  public:
    void operator++() noexcept { --i; }
    constexpr usize operator*() const noexcept { return i; }
    constexpr bool operator!=(const itr x) const noexcept { return i != x.i; }
  };
  constexpr revrep(usize first, usize last) noexcept : f(--first), l(--last) {}
  constexpr itr begin() const noexcept { return itr(l); }
  constexpr itr end() const noexcept { return itr(f); }
};
template <class T> using vec_alias = std::vector<T>;
template <class T> auto md_vec(const usize n, const T &value) {
  return std::vector<T>(n, value);
}
template <class... Args> auto md_vec(const usize n, Args... args) {
  return std::vector<decltype(md_vec(args...))>(n, md_vec(args...));
}
template <class T> constexpr T difference(const T &a, const T &b) {
  return a < b ? b - a : a - b;
}

} // namespace n91

#include <algorithm>
#include <iostream>
#include <string>
#include <utility>


namespace n91 {

void main_() {
  std::string s;
  std::cin >> s;
  std::sort(s.begin(), s.end());
  std::cout << (s[0_z] != s[2_z] && s[0_z] == s[1_z] && s[2_z] == s[3_z] ? "Yes"
                                                                         : "No")
            << std::endl;
}

} // namespace n91

int main() {
  n91::main_();
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
int main() {
	int s = 0;
	int a;
	std::string g(3,'x');

	std::cin >> g;
	for (int i = 0; i < 3; i++) {
		if (g[i] == 'o') {
			s++;
		}
	}

	std::cout <<700+s*100 <<std::endl;
}

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

// {U}{INT,LONG,LLONG}_{MAX,MIN}
#define INF         INT_MAX/3
#define LLINF       LLONG_MAX/3
#define MOD         (1000000007LL)
#define MODA(a, b)  a=((a)+(b))%MOD
#define MODP(a, b)  a=((a)*(b))%MOD
#define inc(i, l, r)   for(int i=(l);i<(r);i++)
#define dec(i, l, r)   for(int i=(r)-1;i>=(l);i--)
#define pb          push_back
#define se          second
#define fi          first
#define mset(a, b)  memset(a, b, sizeof(a))

using LL  = long long;
using G   = vector<vector<int>>;

int di[] = {0, -1, 0, 1};
int dj[] = {1, 0, -1, 0};
// }}}


// O(a(n))
// verified AOJ DSL_1_A
struct UF {
    vector<int> p;  // parent
    LL fuben;
    map<int, LL> mp;

    UF(int n) {
        p.resize(n);
        for(int i=0;i<n;i++){
            p[i] = i;
            mp[i]++;
        }
        fuben = LL(n)*(n-1)/2;
    }

    int find(int x) {
        if(x == p[x]){
            return x;
        }else{
            return p[x] = find(p[x]);
        }
    }

    void unite(int x, int y) {
        x = find(x);
        y = find(y);
        if(x == y) return;
        fuben -= mp[x]*mp[y];
        mp[x] += mp[y];
        mp[y] = 0;
        p[y] = p[x];
    }
};

int main() {
    cin.tie(0);ios::sync_with_stdio(false);
    int n, m;
    cin >> n >> m;
    vector<int> a(m), b(m);
    inc(i, 0, m){
        cin >> a[i] >> b[i];
        a[i]--;b[i]--;
    }
    reverse(a.begin(), a.end());
    reverse(b.begin(), b.end());

    UF uf(n);

    vector<LL> ans;
    inc(i, 0, m){
        ans.pb(uf.fuben);
        uf.unite(a[i], b[i]);
    }
    reverse(ans.begin(), ans.end());
    inc(i, 0, m){
        cout << ans[i] << endl;
    }
    return 0;
}


Measured memory_bytes: 9720
fn solve() {
    let mut buf = String::new();
    let handle = std::io::stdin();
    handle.read_line(&mut buf).unwrap();
    let info: Vec<usize> = buf.trim().split_whitespace()
        .map( |a| 
            a.parse().unwrap()
        ).collect();
    let n = info[0];
    let k = info[1];
    buf.clear();

    let mut trees: Vec<isize> = Vec::with_capacity(n);

    for _ in 0..n {
        handle.read_line(&mut buf).unwrap();
        trees.push(buf.trim().parse().unwrap());
        buf.clear();
    }    
    trees.sort();
    let mut min_diff = 1000000000;
    for i in 0..n-k+1 {
        let diff = trees[i + k-1] - trees[i];
        if diff < min_diff {
            min_diff = diff;
        }
    }
    println!("{}", min_diff);
}
fn main() {
    solve();
}

Measured memory_bytes: 4476
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("avx2")
#pragma GCC optimize("Os")
#include <bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(false);
#define FO cout.tie(NULL);
#define FI cin.tie(NULL);
#define IN cin>>
#define OUT cout<<
#define loop(i,a,n) for(int i=a; i<n; i++)
#define rloop(i,a,n) for(int i=a; i>=n; i--)
#define endl "\n";
#define pb push_back
#define mp make_pair
#define set_bits(a) __builtin_popcountll(a)
#define ll long long int
#define ld long double
#define vll vector<long long int>
#define pll pair<long long int, long long int>
#define mod 1000000007
#define M 998244353
using namespace std;
ll gcd(ll a, ll b)
{
    return (b?gcd(b,a%b):a);
}
ll P(ll B, ll power, ll modulo)
{
    ll ans=1LL;
    while(power>0LL)
    {
        if(power%2LL==1LL)
        {
            ans=(ans*B)%modulo;
        }
        B=(B*B)%modulo;
        power/=2LL;
    }
    return ans;
}
bool isPrime(ll n)
{
    if(n<=1LL)
    {
        return false;
    }
    if(n<=3LL)
    {
        return true;
    }
    if(n%2==0LL || n%3==0LL)
    {
        return false;
    }
    for(ll i=5LL; (i*i)<=n; i+=6LL)
    {
        if(n%i==0LL || n%(i+2LL)==0LL)
        {
            return false;
        }
    }
    return true;
}
void vok()
{
    FAST
    FO
    FI
    #ifndef ONLINE_JUDGE
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);
        freopen("error.txt","w",stderr);
    #endif
}
int main()
{
    vok();
    int h,w,k;
    IN h>>w>>k;
    char ch[h][w];
    loop(i,0,h)
    {
        loop(j,0,w)
        {
            IN ch[i][j];
        }
    }
    set<pair<string,string>> s;
    loop(i,0,64)
    {
        loop(j,0,64)
        {
            bitset<6> b1(i), b2(j);
            int b=0;
            loop(k,0,h)
            {
                loop(l,0,w)
                {
                    if(b1[k] || b2[l])
                    {
                    }
                    else
                    {
                        if(ch[k][l]=='#')
                        {
                            b++;
                        }
                    }
                }
            }
            string s1="", s2="";
            rloop(k,h-1,0)
            {
                if(b1[k])
                {
                    s1+="1";
                }
                else
                {
                    s1+="0";
                }
            }
            rloop(k,w-1,0)
            {
                if(b2[k])
                {
                    s2+="1";
                }
                else
                {
                    s2+="0";
                }
            }
            if(b==k)
            {
                s.insert({s1,s2});
            }
        }
    }
    int ans=int(s.size());
    OUT ans<<endl
    return 0;
}

Measured memory_bytes: 3772
#include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
#include <set>

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,j) FOR(i,0,j)

const int INF = 1 << 24;
const int dx[4] = {0, 0, 1, -1}, dy[4] = {1, -1, 0, 0};

typedef unsigned long long ull;

int N, T, S;
int A[3000], B[3000], dp[3001];

int main(){
    std::cin >> N >> T >> S;
    
    REP(i, N){
        std::cin >> A[i] >> B[i];
    }

    REP(i, T+1){
        dp[i] = 0;
    }

    REP(i, T+1){
        if(i+B[0] <= T && (i+B[0] <= S || S <= i)){
            dp[i+B[0]] = A[0];
        }
    }

    REP(i, N-1){
        for(int j=T;j>=B[i+1];j--){
            if(j-B[i+1] >= 0 && (j <= S || S <= j-B[i+1])){
                dp[j] = std::max(dp[j], dp[j-B[i+1]] + A[i+1]);
            }
        }
    }
    
    int res = 0;
    REP(i, T+1){
        res = std::max(res, dp[i]);
    }
    
    std::cout << res << std::endl;
}

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

using namespace std;

#define FAST() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)

int main()
{
    FAST();
    string s[7];
    int i,j,k,m,n,ans=0,cnt,col,row;
    cin >> n >> m >> k;
    for(i=0;i<n;i++)cin >> s[i];
    for(row=0;row<(1 << n);row++)
    {
        for(col=0;col <(1 << m);col++)
        {
            cnt=0;
            for(i=0;i<n;i++)
            {
                if((row >> i) & 1)continue;
                for(j=0;j<m;j++)
                {
                    if(!((col >> j) & 1)  &&  s[i][j] == '#')++cnt;
                }
            }
            if(cnt == k)++ans;
        }
    }
    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 3624
x = gets.chomp.to_i
result = []
x.times do
  ary = []
  tmp = 0
  s = gets.chomp.to_i
  
  10.times do
  s = s * s
  tmp = sprintf("%08d",s)
  tmp = tmp[2,4].to_i
  ary << tmp
  s = tmp
  end
result << ary
end

result.each_with_index do |v,i|
 puts "Case #{i+1}:"
 puts v
 end


Measured memory_bytes: 6888
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <string.h>
#include <vector>

using namespace std;

int main()
{
	int n, k;
	string s;

	cin >> n >> k >> s;

	s[k - 1] = s[k - 1] - 'A' + 'a';

	cout << s << endl;
}


Measured memory_bytes: 256
N = int(input())
l = list(map(int, input().split()))
for i in range(N):
    v = l[i]
    j = i - 1
    while j >= 0 and l[j] > v:
        l[j+1] = l[j]
        j -= 1
    l[j+1] = v
    print(' '.join(map(str, l)))


Measured memory_bytes: 5596
#include <bits/stdc++.h>
using namespace std; 
   
int main(){
  long long N,ans10=1,ans9=2,ans8=1,mod=1000000007,ans=0;
  cin >> N;
  for(int i=0;i<N;i++){
    ans10=(ans10*10)%mod;
    ans9=(ans9*9)%mod;
    ans8=(ans8*8)%mod;
  }
  ans=(ans10+ans8)%mod;
  ans=(ans-ans9)%mod;
  if(ans<0){
    ans+=mod;
  }
  cout << ans << endl;
}
    
  

Measured memory_bytes: 3632
def main():
    S = input()
    if S[0] != 'k':
        return ('NO')
    elif S == 'keyence':
        return ('YES')

    ans = 'keyence'
    i = 0
    j = 0
    while True:
        i += 1
        j += 1
        if S[i] != ans[j]:
            break

    #残りの文字数
    num = 7-j
    cnt = 0
    while cnt < num:
        cnt += 1
        #print(ans[-cnt])
        if S[-cnt] != ans[-cnt]:
            return ('NO')
    return ('YES')
print(main())


Measured memory_bytes: 8856
n = int(input())
a = []
for i in range(n):
    a.append(int(input()))

max_val = max(a)
max_total = a.count(max_val) - 1

for i in range(n):
    if max_val > a[i]:
        print(max_val)

    elif max_val == a[i] and max_total != 0:
        print(max_val)
        max_total -= 1
    else:
        temp = a[i]
        a[i] = 0
        print(max(a))
        a[i] = temp

Measured memory_bytes: 12512
#include <iostream>
#include <unordered_map>

int main()
{
    int n, m;
    int sum = 0;
    std::unordered_map<int, int> countMap;

    std::cin >> n >> m;


    for (int i = 0; i < n; i++) {
        int a;
        std::cin >> a;
        sum = (sum + a) % m;
        auto itr = countMap.find(sum);
        if (itr != countMap.end()) {
            countMap[sum]++;
        } else {
            countMap[sum] = 1;
        }
    }

    long long ans = 0;
    for (auto itr = countMap.begin(); itr != countMap.end(); ++itr) {
        long long x = itr->second;
        ans += x * (x-1) / 2;
        if (itr->first == 0) {
            ans += x;
        }
    }

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


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

using i64 = long long;
using P = pair<i64, i64>;

#define overload3(_1, _2, _3, name, ...) name
#define rep1(i, n) for(i64 i = 0LL; i < (n); ++i)
#define rep2(i, a, b) for(i64 i = (a); i < (b); ++i)
#define rep(...) overload3(__VA_ARGS__, rep2, rep1)(__VA_ARGS__)
#define all(v) v.begin(), v.end()



struct IoSetup {
    IoSetup() {
        // cin.tie(nullptr);
        // ios::sync_with_stdio(false);
        cout << fixed << setprecision(10);
        cerr << fixed << setprecision(10);
    }
} iosetup;

int main(){
    i64 n, k;
    cin >> n >> k;
    vector<i64> cnt(n);
    rep(i, k){
        i64 d;
        cin >> d;
        rep(j, d){
            i64 a;
            cin >> a;
            cnt[a - 1]++;
        }
    }
    i64 ans = 0;
    rep(i, n) if(cnt[i] == 0) ++ans;
    cout << ans << endl;
    return 0;
}


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

int main() {
    int n;
    cin >> n;
    long long k;
    cin >> k;
    int a[n];
    unordered_map<int, int> m;
    for (int i=0; i<n; i++) {
        cin >> a[i];
    }
    int p=0, i=0;
    m[p] = i;
    vector<int> v;
    v.push_back(p);
    while (k>0) {
        p = a[p]-1;
        i++;
        k--;
        if (m.count(p)) {
            int distance = i - m[p];
            int mod = k%distance;
            cout << v[m[p]+mod]+1 << endl;
            return 0;
        }
        m[p] = i;
        v.push_back(p);
        //cout << p << " " << k << endl;
    }
    cout << (p+1) << endl;
}


Measured memory_bytes: 11576
#include <cstdio>
#include <algorithm>
#include <cstring>
#define INF (1LL<<31)-1
using namespace std;
int n;
int a[101],b[101];
int dp[101][101];

int main(void){
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		scanf("%d%d",&a[i],&b[i]);
	}
	for(int i=0;i<n;i++){
		for(int j=0;j<=n;j++){
			dp[i][j]=INF;
		}
		dp[i][i+1]=0;
	}
	for(int i=2;i<=n;i++){
		for(int j=0;j<=n-i;j++){
			for(int k=1;k<i;k++){
				dp[j][j+i]=min(dp[j][j+i],dp[j][j+k]+dp[j+k][j+i]+a[j]*b[j+k-1]*a[j+k]*b[j+i-1]);
			}
		}
	}
	printf("%d\n",dp[0][n]);
	return 0;
}

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

#define pb push_back
ll solve(){
 ll n; cin>>n; 
 if(n<=6) return 1;
 else if(n>6 && n<=11) return 2;
 else{
   ll m=n/11;
   ll r=n%11;
   if(r==0) return 2*m;
   if(r<=6 ) return 2*m+1;
   else return 2*m+2;
 }

}


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

 ios_base::sync_with_stdio(0);
 cin.tie(0);

int t=1 ;  while(t--){
 ll k=solve();
 cout<<k<<endl;
}

return 0;
}


Measured memory_bytes: 3660
import std.stdio;
import std.conv;
import std.string;
import std.typecons;
import std.algorithm;
import std.array;
import std.range;
import std.math;
import std.regex : regex;
import std.container;
import std.bigint;


void main()
{
  auto x = readln.chomp.split.to!(int[]);
  auto s = readln.chomp;

  auto ab = x[1] + x[2];
  auto b = x[2];
  foreach (e; s) {
    auto f = false;
    if (e == 'a' && ab) {
      ab--;
      f = true;
    } else if (e == 'b' && ab && b) {
      ab--;
      b--;
      f = true;
    }
    writeln(f ? "Yes" : "No");
  }
}


Measured memory_bytes: 2812
S = list(input())
if S[0] != '<':
    S.insert(0,'<')
if S[-1] != '>':
    S.append('>')
con = []
count = 1
for i in range(len(S)-1):
    if S[i+1] == S[i]:
        count += 1
    else:
        con.append(count)
        count = 1
if S[-1] != S[-2]:
    count = 1
    con.append(count)
else:
    con.append(count)
ans = 0
for l in range(0,len(con)-1,2):
    if l % 2 == 0:
        f = con[l]
        b = con[l+1]
        if f >= b:
            ans += (1 + f)*f//2 + (b-1)*b//2
            
        else:
            ans += (1 + b)*b//2 + (f-1)*f//2
            
    else:
        pass
    
        
print(ans)


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

typedef long long ll;
#define pa pair<int, int> 
#define pal pair<long long, long long>
#define pad pair<double, double>
#define pb push_back
#define mp make_pair
#define VIN(v) for(int64_t i=0;i<(v).size();i++){cin >> (v).at(i);}

typedef vector<bool> bvec;
typedef vector<int> ivec;
typedef vector<long long> lvec;
typedef vector<double> dvec;
typedef vector<pa> pvec;



typedef vector< vector<bool> > bmat;
typedef vector< vector<int> > imat;
typedef vector<string> svec;
typedef vector< vector<string> > smat;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    ll h, hh;
    cin >> hh;
    hh--;
    string ans = "Yes";
    for (int i=1; i<n; i++) {
        cin >> h;
        if(hh > h) {
            ans="No";
            break;
        }
        else if(hh+1 <= h) hh = h-1;
    }
    cout << ans << endl;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize ("-ffloat-store")  
#pragma GCC optimize ("-fno-defer-pop")
#define all(a) a.begin(),a.end()
#define ll long long int
#define ld long double
ll power(ll a,ll b,ll m){ if(b==0) return 1; if(b==1) return a%m; ll t=power(a,b/2,m)%m; t=(t*t)%m; if(b&1) t=((t%m)*(a%m))%m; return t;}
ll modInverse(ll a, ll m) { return power(a, m-2, m); }
#define ipr pair<ll,ll>
#define ps push_back
#define fs first
#define sc second
#define endl "\n"
#define mod 1000000007
int main(){
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	
	ll i,j,k,l,n;
	cin>>n;
	char ar[n+1];
	cin>>ar;
	k=0;
	for(i=0;i<n;i++){
		if(ar[i]=='.'){
			k++;
		}
	}

	l=0;
	ll mn=10000000000;
	for(i=0;i<n;i++){
		mn=min(mn,l+k);
		if(ar[i]=='.'){
			k--;
		}
		else l++;
	}
	mn=min(mn,l+k);
	cout<<mn;
	return 0;
}


Measured memory_bytes: 512
n=int(input())
a=list(map(int,input().split()))
a.sort(reverse=True)

rec1,rec2,i=0,0,0
while i<n-1:
    if a[i]==a[i+1]:
        if rec1==0:
            rec1=a[i]
            i+=1
        else:
            rec2=a[i]
            break
    i+=1
print(rec1*rec2)

Measured memory_bytes: 15020
#include <stdio.h>
int main(){
  int a,b,c,tmp;
  scanf("%d %d %d",&a,&b,&c);
  if(a>b){
    tmp=a;
    a=b;
    b=tmp;
  }

 if(a>c){
    tmp=a;
    a=c;
    c=tmp;
  }

  if(b>c){
    tmp=b;
    b=c;
    c=tmp;
  }

  printf("%d %d %d\n",a,b,c);
  
  return 0;
}


Measured memory_bytes: 2736
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define all(x) (x).begin(), (x).end()
#define dbg(x) cerr << #x << ": " << x << endl
int main() {
  int n, m;
  cin >> n >> m;
  vector<int> x(m);
  rep(j, m) cin >> x[j];
  if(n >= m) {
    cout << 0 << endl;
    return 0;
  }
  sort(all(x));
  vector<int> intv(m - 1);
  rep(j, m - 1) intv[j] = x[j + 1] - x[j];
  sort(all(intv));
  reverse(all(intv));
  ll ans = 0LL;
  ans += (ll)x[m - 1];
  ans -= (ll)x[0];
  rep(i, n - 1) ans -= (ll)intv[i];
  cout << ans << endl;

  return 0;
}

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

using namespace std;

int n;

typedef long long ll;

ll a[100001];
ll sum[100001];
int main() {
  cin >> n;

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

  sort(a,a+n);

  sum[0] = a[0];

  for(int i = 1; i < n; i++) sum[i] = sum[i-1] + a[i];

  ll ans = 1;

  for(int i = n - 2; i >= 0; i--) {
    if(a[i+1] > sum[i] * 2) break;
    ans++;
  }

  cout << ans << endl;
}


Measured memory_bytes: 1792
import java.util.Scanner;

public class Main {

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

		double[][] p = new double[4][2];
		while(stdIn.hasNext()){
			for(int i=0;i<4;i++){
				for(int j=0;j<2;j++){
					p[i][j]=stdIn.nextDouble();
				}
			}
			double AB_x = p[1][0]-p[0][0];
			double AB_y = p[1][1]-p[0][1];
			double CD_x = p[3][0]-p[2][0];
			double CD_y = p[3][1]-p[2][1];
			if(AB_x*CD_x+AB_y*CD_y==0){
				System.out.println("YES");
			}
			else{
				System.out.println("NO");
			}
		}
	}
}

Measured memory_bytes: 12000
// C - 怪文書 / Dubious Document
#include <bits/stdc++.h>
using namespace std;

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

	vector<vector<int>> S(n, vector<int>(26));
	for(int i=0; i<n; i++){
		string s; cin>>s;
		for(auto e:s) S[i][e-'a']++;
	}

	string ans;
	for(int i=0; i<26; i++){
		int mini = 1e9;
		for(int j=0; j<n; j++) if(mini>S[j][i]) mini = S[j][i];
		for(int k=0; k<mini; k++) ans += i+'a';
	}
	cout<< ans <<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <sstream>
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define rep(i,a,b) for(ll i = a; i <= b; ++i)
#define fo(i,a,b) for(int i = a; i<= b; ++i)
#define ull unsigned long long int
#define ll long long
#define all(a) a.begin(),a.end()
using namespace std;
typedef vector<ll> vi;
typedef pair<ll,ll> pi;
ll MD=1000000007;
ll md=998244353;
const ll INF=1e18L+5;
ll exp(ll a,ll b){ll r=1ll;while(b>0){if(b&1){r=r*(a%md);r=(r+md)%md;}b/=2;a=(a%md)*(a%md);a=(a+md)%md;}return (r+md)%md;}//put b as bmod(md-1) if md is prime}
ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
ll pow_2(ll a, ll b)
{
    ll res = 1;
    while(b)
    {
        if(b & 1)
            res = (res * a);
        a = (a * a);
        b >>= 1;
    }

    return res;
}
bool isPrime(ll a)
{
    for(ll i=3; (i*i)<=a; i+=2)
    {
        if( (a%i)==0 )
            return false;
    }
    if( ( a!=2 ) && ( (a%2)==0 ) )
        return false;
    if( a==1 )
        return false;

    return true;
}
string decToBinary(int n)
{
    // Size of an integer is assumed to be 32 bits
    string s="";
    for (int i = 31; i >= 0; i--) {
        int k = n >> i;
        if (k & 1)
            //cout << "1";
            s=s+"1";
        else
            //cout << "0";
            s=s+"0";
    }
    return s;
}
int decimalToBinary(int N)
{

    // To store the binary number
    ull B_Number = 0;
    int cnt = 0;
    while (N != 0) {
        int rem = N % 2;
        ull c = pow(10, cnt);
        B_Number += rem * c;
        N /= 2;

        // Count used to store exponent value
        cnt++;
    }

    return B_Number;
}
string toString(ull num)
{
    std::string number;
    std::stringstream strstream;
    strstream << num;
    strstream >> number;
    return number;
}
const double PI = acos(-1);
int main()
{
    ios_base::sync_with_stdio(false);
	cin.tie(NULL);cout.tie(NULL);
    string s,t;
    cin>>s>>t;
    int dp[t.size()+1][s.size()+1];
    for(int i=0;i<=t.size();i++)
    {
        for(int j=0;j<=s.size();j++)
        {
            if(i==0 || j==0)dp[i][j]=0;
            else if(t[i-1]==s[j-1]){dp[i][j]=dp[i-1][j-1]+1;}
            else dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
        }
    }
    vector<char> ans;
    int i=t.size();
    int j=s.size();
    while(i>0 && j>0)
    {
        if(dp[i][j]!=dp[i-1][j] && dp[i][j]!=dp[i][j-1]){ans.PB(s[j-1]);i=i-1;j=j-1;}
        else if(dp[i][j]==dp[i-1][j] && dp[i][j]==dp[i][j-1]){i=i-1;}
        else if(dp[i][j]!=dp[i-1][j] && dp[i][j]==dp[i][j-1]){j=j-1;}
        else if(dp[i][j]==dp[i-1][j] && dp[i][j]!=dp[i][j-1]){i=i-1;}
    }
    for(int i=ans.size()-1;i>=0;i--)cout<<ans[i];
    cout<<endl;
return 0;}




Measured memory_bytes: 38756
import java.util.Scanner;
 
public class Main {
	public static void main(String[] args) {
		try (Scanner scn = new Scanner(System.in)) {
			int x = scn.nextInt();
			int ret;
			while(true){
			    if(isPrimeNum(x)){
			    ret = x;
			    break;    
			    }
			    x++;
			}
			
		
			System.out.println(ret);
		}
	}
	
    static boolean isPrimeNum(int num){
	    if(num==2) return true;
	   if(num % 2 == 0) return false;
	   for(int i = 2;i<num;i++){
	       if(num % i == 0) return false;
	   }
	    
	    return true;
	    
	}
}


Measured memory_bytes: 25300
#include<stdio.h>
int main()
{
	int a[100][100]={0};
	int b[100][100]={0};
	long long int c[100][100]={0};
	int i,j,k;
	int n,m,l;
	scanf("%d%d%d",&n,&m,&l);
	for(i=0;i<n;i++)
	{
		for(j=0;j<m;j++)
		{
			scanf("%d",&a[i][j]);

		}
	}
	for(i=0;i<m;i++)
	{
		for(j=0;j<l;j++)
		{
			scanf("%d",&b[i][j]);

		}
	}
	//Cnl=Σ<k=0,1,2,***,m>Ank*Bkl
	for(i=0;i<n;i++)
	{
		for(j=0;j<l;j++)
		{
			for(k=0;k<m;k++)
			{
				
				c[i][j]+=(a[i][k]*b[k][j]);	
				
			}
		
		}
	}
	for(i=0;i<n;i++)
	{
		for(j=0;j<l-1;j++)
		{
			printf("%lld ",c[i][j]);

		}
		printf("%lld\n",c[i][l-1]);
	}
return 0;
}

Measured memory_bytes: 764
#include<iostream>
#include<vector>
#include<string>
#define rep(i, start, end) for (int i = (int)start; i < (int)end; ++i)
#define rrep(i, start, end) for (int i = (int)start - 1; i >= (int)end; --i)
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
template<typename T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return 0;}
template<typename T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return 0;}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int X;
    cin >> X;
    int now = 8;
    for (int rate = 600; rate <= 2000; rate += 200) {
        if (X < rate) {
            cout << now << endl;
            return 0;
        }
        --now;
    }
    return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
int main()
{
    Int N, x; cin >> N >> x;
    vector<int> A(N); for (auto &a : A) cin >> a;
    vector<int> B = A;
    Int ans = 1e18;
    for (int i = 0; i < N; i++) {
        ans = min(ans, x * i + accumulate(begin(B), end(B), 0LL));
        int t = B[0];
        for (int j = 1; j < N; j++) {
            B[j-1] = min(B[j-1], B[j]);
        }
        B[N-1] = min(B[N-1], t);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
N = int(input())

for h in range(1, 3501):
    for n in range(1, 3501):
        v = 4 * h * n - N * n - N * h
        if v == 0:
            continue
        w = (N * h * n) / v
        if w.is_integer() and w > 0:
            print(h, n, int(w))
            quit()

Measured memory_bytes: 40684
import java.util.Scanner;

public class Main {
    
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        
        final int N = sc.nextInt();
        
        int currTop = 0;
        long steps = 0;
        
        for (int i = 0; i < N; i++) {
            int A = sc.nextInt(); 
            
            if (A < currTop) {
                steps += currTop - A;
            } else if (currTop < A) {
                currTop = A;
            }
        }
        
        System.out.println(steps);
    }
}


Measured memory_bytes: 59984
package main

import (
	"fmt"
)

func main() {
	var a, b int
	fmt.Scan(&a, &b)

	if a <= 5 {
		fmt.Println(0)
	} else if a <= 12 {
		fmt.Println(b / 2)
	} else {
		fmt.Println(b)
	}
}


Measured memory_bytes: 512
using System;
using static System.Console;

namespace abc177
{
    class Program
    {
        static void Main()
        {
            var s = ReadLine();
            var t = ReadLine();
            WriteLine(Substring(s, t));
        }
        static int Substring(string s, string t)
        {
            var min = int.MaxValue;
            for (var i = 0; i <= s.Length - t.Length; ++i)
            {
                min = Math.Min(min, Diff(s.Substring(i), t));
            }
            return min;
        }
        static int Diff(string s, string t)
        {
            var count = 0;
            for (var i = 0; i < t.Length; ++i)
            {
                if (s[i] != t[i])
                {
                    ++count;
                }
            }
            return count;
        }
    }
}


Measured memory_bytes: 26672
#include <cassert>
#include <cstdio>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <numeric>
#include <algorithm>

using namespace std;
using lint = long long;
constexpr int MOD = 1000000007, INF = 1010101010;
constexpr lint LINF = 1LL << 60;

template <class T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
	for (const auto &e : vec) os << e << (&e == &vec.back() ? "\n" : " ");
	return os;
}

#ifdef _DEBUG
template <class T>
void dump(const char* str, T &&h) { cerr << str << " = " << h << "\n"; };
template <class Head, class... Tail>
void dump(const char* str, Head &&h, Tail &&... t) {
	while (*str != ',') cerr << *str++; cerr << " = " << h << "\n";
	dump(str + (*(str + 1) == ' ' ? 2 : 1), t...);
}
#define DMP(...) dump(#__VA_ARGS__, __VA_ARGS__)
#else 
#define DMP(...) ((void)0)
#endif

class UnionFind {
private:
	vector<int> data;
	int root(int x) { return data[x] < 0 ? x : data[x] = root(data[x]); }

public:
	UnionFind(int size) : data(size, -1) { }
	bool is_same(int x, int y) { return root(x) == root(y); }
	int size(int x) { return -data[root(x)]; }

	bool unify(int x, int y) {
		x = root(x); y = root(y);
		if (x != y) {
			if (data[y] < data[x]) swap(x, y);
			data[x] += data[y]; data[y] = x;
			return true;
		}
		return false;
	}
};


int main() {

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

	int N, M;
	cin >> N >> M;

	UnionFind uf(N + M);
	for (int i = 0; i < N; i++) {
		int K;
		cin >> K;
		for (int j = 0; j < K; j++) {
			int L;
			cin >> L;
			uf.unify(i, N + L - 1);
		}
	}

	bool same = true;
	for (int i = 0; i < N - 1; i++) {
		same &= uf.is_same(i, i + 1);
	}

	if (same) cout << "YES" << "\n";
	else cout << "NO" << "\n";

	return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
 
const int maxn=3000010;
int col[maxn];
vector<int> G[maxn];
#define Eor(i,u) for(int i=0,i_end=G[u].size(),v;i<i_end;++i)
		
int n,ca,cb,m;
bool flag;
 
void dfs(int u,int c,int fa){
	col[u]=c;
	if(c==0)++ca;
	else ++cb;
	//cerr<<u<<endl;
	Eor(i,u)if((v=G[u][i])!=fa){
		if(col[v]==col[u]){
			flag=1;
			return;
			continue;
		}
		if(!~col[v])dfs(v,c^1,u);
		if(flag)return;
	}
}
 
int main(){
	memset(col,-1,sizeof col);
	scanf("%d%d",&n,&m);
	for(int i=1;i<=m;++i){
		int u,v;
		scanf("%d%d",&u,&v);
		G[u].push_back(v);
		G[v].push_back(u);
	}
	flag=0;
	//cerr<<flag<<endl;
	dfs(1,0,-1);
	if(flag){
		//printf("%d\n",n*(n-1)/2-m);
		cout<<1ll*n*(n-1)/2-m<<endl;
		//puts("wea");
	}
	else{
		//printf("%d\n",ca*cb-m);
		cout<<1ll*ca*cb-m<<endl;
	}
	//cerr<<1.0*clock()/CLOCKS_PER_SEC<<endl;
	return 0;
}

Measured memory_bytes: 86144
var input = ""
process.stdin.resume();
process.stdin.setEncoding('utf-8');
process.stdin.on('data', function(chunk) {
  input += chunk;
});

process.stdin.on('end', function() {
  input = input.split("\n");
  i = 0
  while (input[i] != 0) {
    arr = input[i].split(" ")
    i++;
    if (arr[0] != 0) {
      console.log("Case " + i + ": " + arr[0]);
    }
  }
});

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

int main() {
	int a,b;
  	cin >> a >> b;
  
  	if(a % 2 == 0 && b % 2 != 0) {
    	cout << a / 2 + b / 2 + 1 << endl;
    }else if(a % 2 != 0 && b % 2 == 0){
      	cout << a / 2 + 1 + b / 2 << endl;
    }else {
    	cout << (a + b) / 2 << endl;
    }
}

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

int count_dight(ll n){
  int count = 0;
  while(n >= 1){
    n /= 10;
    ++count;
    }
  return count;
 }
int main(){
  ll N;
  cin >> N;
  int countmin = 12;
  for(ll A = 1; A*A <= N; ++A){
    if(N%A == 0){
      ll B = N/A;
      const int count = count_dight(B);
      if(count < countmin) {
        countmin = count;
      }
    }
  }
  cout << countmin << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<sstream>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<cmath>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<numeric>
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; }
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;
int dx[4] = {1,0,-1,0}, dy[4] = {0,1,0,-1};

int main()
{

    int n,d,x;
    cin >> n >> d >> x;

    int a = 0;
    int cnt = 0;
    for (int i=0; i<n; ++i)
    {
        cin >> a;
        for (int j=0; j<101; ++j)
        {
            if(a*j+1<=d) ++cnt;
            else
            {
                break;
            }
        }
    }

    cout << cnt + x << endl;

    return 0;
}

Measured memory_bytes: 256
a,b=map(int,input().split())
if a>0 and b>0:
    print('Positive')
if a==0 or b==0:
    print('Zero')
if a<0 and b<0:
    if (a-b)%2!=0:
        print('Positive')
    else:
        print('Negative')
if a<0 and b>0:
    print('Zero')

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define Rint register int
using namespace std;
const int N = 200003;
int n, head[N], to[N << 1], nxt[N << 1], fa[N], son[N], mx[N], sub[N], ans[N], sf[N], f[N], siz[N];
vector<int> Q[N];
inline void add(int a, int b){
	static int cnt = 0;
	to[++ cnt] = b; nxt[cnt] = head[a]; head[a] = cnt;
}
inline int getfa(int x){while(x != f[x]) x = f[x] = f[f[x]]; return x;}
inline void comb(int x, int y){
	x = getfa(x); y = getfa(y);
	if(x == y) return;
	if(siz[y] > siz[x]) swap(x, y);
	f[y] = x; siz[x] += siz[y];
}
template<typename T>
inline void read(T &x){
	int ch = getchar(); x = 0;
	while(ch < '0' || ch > '9') ch = getchar();
	while(ch >= '0' && ch <= '9') x = x * 10 + ch - '0', ch = getchar();
}
inline void dfs1(int x){
	sf[x] = son[mx[x] = max(mx[fa[x]], fa[x])];
	for(Rint i = head[x];i;i = nxt[i]) if(to[i] != fa[x]) son[x] = to[i], fa[to[i]] = x, dfs1(to[i]);
}
inline void dfs2(int x){
	if(x > 1) ans[x] += ans[mx[x]] - sub[son[mx[x]]] + 1;
	for(Rint i = head[x];i;i = nxt[i]) if(to[i] != fa[x]) son[x] = to[i], dfs2(to[i]);
}
int main(){
	read(n);
	for(Rint i = 1;i <= n;++ i) f[i] = i, siz[i] = 1;
	for(Rint i = 1, u, v;i < n;++ i){
		read(u); read(v);
		add(u, v); add(v, u);
	}
	dfs1(1);
	for(Rint i = 2;i <= n;++ i) Q[mx[i]].push_back(i);
	for(Rint i = 1;i <= n;++ i){
		for(Rint u : Q[i]){
			if(u < i) ans[u] = siz[getfa(u)] - 1;
			else {
				if(sf[u] != u) ans[u] += siz[getfa(sf[u])];
				for(Rint j = head[u];j;j = nxt[j]) if(to[j] != fa[u] && to[j] < i)
					ans[u] += sub[to[j]] = siz[getfa(to[j])];
			}
		}
		for(Rint j = head[i];j;j = nxt[j])
			if(to[j] < i) comb(i, to[j]);
	}
	dfs2(1);
	for(Rint i = 2;i <= n;++ i) printf("%d ", ans[i]);
}

Measured memory_bytes: 21876
#include<stdio.h>

int main(void) {
        int x, y, W, H, r;

        scanf("%d %d %d %d %d", &W, &H, &x, &y, &r);

        if(-100 > x || x > 100 || -100 > y || y > 100 ||  0 > W || W > 100 || 0 > H || H > 100 || 0 > r || r > 100) {
           printf("input error\n");
           return 1;
        }

        (x > 0 && y > 0 && x+r <= W && y+r <= H) ? printf("Yes\n") : printf("No\n");

        return 0;
}



Measured memory_bytes: 2116
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const double pi = 3.141592653589793238;
int main() {
	cout<<fixed<<setprecision(15);
	ios::sync_with_stdio(false);
	double a,b,h,m;
	cin>>a>>b>>h>>m;
	double frac = (double)m/60.0;
	frac*=5.0;
	double hr = (double)h*5.0 + frac; // hour to minutes
	double angle = min(abs(hr-m) , 60.0 - abs(hr-m)) * 6.0000000000;
	double ans = a*a + b*b - 2.0000000000*a*b*cos(angle * pi/180.00000000000);
	ans = sqrt(ans);
	cout<<ans<<'\n';
}


Measured memory_bytes: 4244
#include<bits/stdc++.h>
using namespace std;
#define inf INT_MAX
#define INF LLONG_MAX
#define ll long long
#define ull unsigned long long
#define M 998244353
#define P pair<int,int>
#define FOR(i,m,n) for(int i=(int)m;i<(int)n;i++)
#define RFOR(i,m,n) for(int i=(int)m;i>=(int)n;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,n,0)
#define all(a) a.begin(),a.end()
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define F first
#define S second
#define PB push_back
#define EB emplace_back
#define int ll
#define vi vector<int>
#define IP pair<int,P>
#define PI pair<P,int>
#define PP pair<P,P>
#define Yes(f){cout<<(f?"Yes":"No")<<endl;}
#define YES(f){cout<<(f?"YES":"NO")<<endl;}



struct Mint {
    int x;

    Mint() : x(0) {}

    Mint(int y) : x(y >= 0 ? y % M : (M - (-y) % M) % M) {}

    Mint &operator+=(const Mint &p) {
        if((x += p.x) >= M) x -= M;
        return *this;
    }

    Mint &operator-=(const Mint &p) {
        if((x += M - p.x) >= M) x -= M;
        return *this;
    }

    Mint &operator*=(const Mint &p) {
        x = (int) (1LL * x * p.x % M);
        return *this;
    }

    Mint &operator/=(const Mint &p) {
        *this *= p.inverse();
        return *this;
    }

    Mint operator-() const { return Mint(-x); }

    Mint operator+(const Mint &p) const { return Mint(*this) += p; }

    Mint operator-(const Mint &p) const { return Mint(*this) -= p; }

    Mint operator*(const Mint &p) const { return Mint(*this) *= p; }

    Mint operator/(const Mint &p) const { return Mint(*this) /= p; }

    bool operator==(const Mint &p) const { return x == p.x; }

    bool operator!=(const Mint &p) const { return x != p.x; }

    Mint inverse() const {
        int a = x, b = M, u = 1, v = 0, t;
        while(b > 0) {
            t = a / b;
            swap(a -= t * b, b);
            swap(u -= t * v, v);
        }
        return Mint(u);
    }

    Mint power(int n) const {
        Mint ret(1), mul(x);
        while(n > 0) {
            if(n & 1) ret *= mul;
            mul *= mul;
            n >>= 1;
        }
        return ret;
    }

    friend ostream &operator<<(ostream &os, const Mint &p) {
        return os << p.x;
    }

    friend istream &operator>>(istream &is, Mint &a) {
        int t;
        is >> t;
        a = Mint(t);
        return (is);
    }


};
using mint = Mint;

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

    int n,s;
    cin>>n>>s;
    vi a(n);
    rep(i,n){
        cin>>a[i];
    }

    vector<Mint> c(s+1);
    
    Mint ans=0;

    rep(i,n){
        c[0]=i+1;
        int t=s-a[i];
        if(t<0) continue;
        Mint m=n-i;
        ans+=c[t]*m;
        //cout<<i<<' '<<ans<<endl;

        rrep(j,s-a[i]){
            c[j+a[i]]+=c[j];
        }


        /*
           rep(j,s+1){
           cout<<c[j]<<' ';
           }
           cout<<endl;
        */

    }

    cout<<ans<<endl;
    


}

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


int main() {
	int K,Q;
	cin >> K>> Q;
	vector<int>D(K);
	for (int n = 0;n<K;++n) {
		cin >> D[n];
	}
	for (int n = 0; n < Q; ++n) {
		long long N,X,M;
		cin >> N >> X >> M;
		vector<int>modD(K);
		for (int m = 0;m<K;++m) {
			modD[m] = D[m] % M;
		}
		long long num = X % M;
		long long zero = 0;
		for (int m = 0; m < K; ++m) {
			long long count = (N-1)/K;
			if (m < (N - 1) % K) {
				count++;
			}
			num += count * modD[m % K];
			if (0 == modD[m % K]) {
				zero += count;
			}
		}
		long long kuriagari = (num)/M -(X % M)/M;
		cout << (N - 1) - zero - kuriagari << endl;
	}
	return 0;
}

Measured memory_bytes: 3660
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)

struct union_find{
    vector<ll> parent;
    vector<ll> nums;
    union_find(ll n){
        parent.resize(n);
        nums.resize(n, 1LL);
        rep(i, 0, n) parent[i] = i;
    }

    ll root(ll x){
        if(parent[x] == x) return x;
        parent[x] = root(parent[x]);
        return parent[x];
    }

    void unite(ll x, ll y){
        ll rx = root(x);
        ll ry = root(y);
        if(rx != ry){
            parent[rx] = ry;
            nums[ry] += nums[rx];
        }
    }

    bool same(ll x, ll y){
        ll rx = root(x);
        ll ry = root(y);
        if(rx == ry) return true;
        return false;
    }

    ll size(ll x){
        return nums[root(x)];
    }
};  

int main() {
    ll n, m;
    cin >> n >> m;
    vector<ll> a(m), b(m);
    rep(i, 0, m) {
        cin >> a[i] >> b[i];
        a[i]--; b[i]--;
    } 
    ll ans = 0;
    rep(i, 0, m) {
        struct union_find t(n);
        rep(j, 0, m) {
            if(i == j) continue;
            t.unite(a[j], b[j]);
        }
        if(t.size(t.root(0)) != n) ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3636
n = int(input())
machine = []
machine_left = []
machine_right = []
for i in range(n):
    x, l = [ int(v) for v in input().split() ]
    machine.append((x-l, x+l))
machine.sort(key = lambda x: x[1])

s = machine[0][1]
ans = 1
for l, r in machine[1:]:
    if l >= s:
        s = r
        ans += 1

print(ans)

Measured memory_bytes: 58712
from collections import OrderedDict


a = OrderedDict()
for i in range(3):
    for j in input().split():
        a[j] = 0

n = int(input())
for i in range(n):
    inp = input()
    if inp in a.keys():
        a[inp] = 1

anss = list(a.values())
lines = [(0,1,2), (3,4,5), (6,7,8), (0,3,6), (1,4,7), (2,5,8), (0,4,8), (2,4,6)]

for x,y,z in lines:
    if anss[x] + anss[y] + anss[z] == 3:
        print("Yes")
        exit()
print("No")

Measured memory_bytes: 3316
fun main(args: Array<String>) {
    val (N, K) = readLine()!!.split(" ").map{it.toInt()}
    val S = readLine()!!
    val T = S.toCharArray().fold(StringBuilder()) { s, c -> if (s.isEmpty() || s.last() != c) s.append(c) else s }.toString()

    println(N - 1 - Math.max(0, T.length - 1 - 2 * K))
}


Measured memory_bytes: 41584
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define MOD 1000000007
#define all(ppp) ppp.begin(),ppp.end() 

#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
#define pb push_back

typedef long double ld;
typedef complex<ld> cd;
 
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
 
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<vi> vvi;
typedef vector<bool> vb;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;
typedef vector<vpi> vvpi;

typedef set<pi> spi;

const int INF=INT_MAX;




int main(){
    int N,K;
    cin>>N>>K;
    vd p(N);
    F0R(i,N){
        double temp;
        cin>>temp;
        temp=(temp+1)/2;
        p[i]=temp;
    }
    double maxi=0;
    double sum=0;
    F0R(i,K){
        sum+=p[i];
    }
    maxi=sum;
    FOR(i,K,N){
        sum=sum+p[i]-p[i-K];
        if(sum>maxi){
            maxi=sum;
        }
    }
    cout.precision(10);
    cout<<maxi<<endl;
    
    return 0;
}


Measured memory_bytes: 1792
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		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();
		}
		sc.close();

		int ans = Integer.MAX_VALUE;
		for (int r = -100; r <= 100; r++) {
			int sum = 0;
			for (int i = 0; i < n; i++) {
				int d = a[i] - r;
				sum += d * d;
			}
			ans = Math.min(ans, sum);
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 21844
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
def s(): return input()
def k(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def X(): return list(input())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
def gcd(*numbers): reduce(math.gcd, numbers)
sys.setrecursionlimit(10 ** 9)
mod = 10**9+7
count = 0
ans = 0

N = k()
A = k()

x = N % 500
if x > A:
    print("No")
else:
    print("Yes")


Measured memory_bytes: 10004
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
const int maxd = 1e5+10;
char s[maxd];
int main()
{
	// freopen("a.in","r",stdin);
	// freopen("k.out","w",stdout);
	int x;
	scanf("%d %s",&x,s);
	if(x >= 3200) printf("%s",s);
	else printf("red");
	return 0;
}

Measured memory_bytes: 128