akhauriyash/Code-Regression huggingface dataset:
/**
#pragma GCC optimize ("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("avx,avx2,fma")
*/

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/rope>
#define pb push_back
#define F first
#define S second
#define ins insert
#define mp make_pair
#define fo(i, n1, n, x) for(int i = n1; i <= n; i += x)
#define foo(i, n, n1, x) for(int i = n; i >= n1; i -= x)
#define bit __builtin_popcount
#define md (l + ((r - l) / 2))
#define all(x) x.begin(),x.end()
#define eb emplace_back
#define ub upper_bound
#define lb lower_bound
#define ios ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define file(s) if (fopen(s".in", "r")) freopen(s".in", "r", stdin), freopen(s".out", "w", stdout)

using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;


using ll = long long;

#define int ll


const int N = 1e3 + 11, mod = 1e9 + 7, mod2 = 998244353;
const int MAX = 1e5 + 11;
const int INF1 = 2e9 + 11;
const ll INF2 = 2e18 + 11;
const double INF3 = 1e8 + 11;
const int base = 500;
const int P = 31;
const int dx[] = {1, -1, 0, 0, 1, 1, -1, -1};
const int dy[] = {0, 0, 1, -1, 1, -1, 1, -1};
const double EPS = 1e-4;
const double PI = acos(-1.0);


template<typename T> using ordered_set = tree <T, null_type, less <T>, rb_tree_tag, tree_order_statistics_node_update>;
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }


typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef vector <int> vi;


mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int n, h, dp[N * 10];
pii a[N];
main() {
    file("time");
    ios;
    cin >> h >> n;
    fo(i, 0, h, 1) dp[i] = INF2;
    fo(i, 1, n, 1) cin >> a[i].F >> a[i].S;
    dp[h] = 0;
    foo(i, h, 1, 1) {
        fo(j, 1, n, 1) {
            int H = max(0ll, i - a[j].F);
            chmin(dp[H], dp[i] + a[j].S);
        }
    }
    cout << dp[0];
    cerr << "\nTime elapsed: " << (clock() + 0.0) / CLOCKS_PER_SEC;
    return 0;
}
/**

*/


Measured memory_bytes: 384
h,w = gets.strip.split.map(&:to_i)
n = gets.to_i
num = gets.strip.split.map(&:to_i)
grid = []
for i in 0..n-1
  a = Array.new(num[i],i+1)
  grid[i] = a
end
grid.flatten!
for i in 1..h
  if i%2==1
    puts grid[(i-1)*w..i*w-1].join(" ")
  else
    puts grid[(i-1)*w..i*w-1].reverse.join(" ")
  end
end

Measured memory_bytes: 15504
#include<bits/stdc++.h>
using namespace std;
const int maxn = 1e3 + 10;
typedef pair<int,int> pii;
typedef long long ll;

int mask[maxn];
int a[maxn];
int dp[1 << 12];

int main() {
    int n, m;
    scanf("%d%d",&n, &m);
    for(int i = 1;i <= m;++i) {
        int tmp,b;
        scanf("%d%d",&a[i],&b);
        for(int j = 1;j <= b;++j) {
            scanf("%d",&tmp);
            --tmp;
            mask[i] |= 1 << tmp;
        }
    }
    memset(dp,-1,sizeof dp);
    dp[0] = 0;
    for(int i = 0;i < (1 << n);++i) if(dp[i] != -1){
        for(int j = 1;j <= m;++j) {
            int cur = i | mask[j];
            if(dp[cur] == -1) dp[cur] = a[j] + dp[i];
            else dp[cur] = min(dp[cur],dp[i] + a[j]);
        }
    }
    printf("%d\n",dp[(1 << n) - 1]);
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstring>
#include <fstream>
#include <cmath>
#include <iomanip>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <map>
#include <deque>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <list>
#include <unordered_map>

using namespace std;


int main() {
   

    int n;
    int q;
    cin >> n;
    vector <long> s;
    vector <long> t;
    for (int i=0;i<n;i++){
        long p;
        cin  >> p;
        s.push_back(p);
    }
    cin >> q;
    for (int i=0;i<q;i++){
        long p;
        cin >> p;
        t.push_back(p);
    }
    vector <long> ::iterator p,r;
    long ans =0;
    for(p=t.begin();p!=t.end();p++){
        for (r=s.begin();r!=s.end();r++){
            if(*p == *r){
                ans += 1;
                break;
            }
        }
    }
    cout << ans << endl;
}


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

using namespace std;

#define lli long long int
#define REP(i,s,n) for(lli i=s;i<n;i++)
#define RREP(i,s,n) for(lli i=s;i>=n;i--)
#define MOD 1000000007
#define NUM 2520
#define DEBUG 0
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())
#define PI (3.141592653589794)
#define INF (1LL<<50)

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

signed main(){

	lli n,m,v,p;
	cin>>n>>m>>v>>p;
	vector<lli> a(n);
	REP(i,0,n)cin>>a[i];
	sort(a.rbegin(),a.rend());

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

	cout<<ok+1<<endl;

	return 0;
}

Measured memory_bytes: 1024
n = int(input())
d, x = map(int, input().split())
a = [int(input()) for i in range(n)]
c = 0
for i in range(n):
    for j in range(1, d + 1):
        if a[i] == 1:
            c += 1
        elif j % a[i] == 1:
            c += 1
print(c + x)

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

int main() {
int N;
cin >> N;
for (int i = 1; i < 10; i++) {
  if(N % i == 0 && N / i < 10){
    cout << "Yes" << endl;
    return 0;
  }
}
cout << "No" << endl;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){
  int i,j,k,l,n,v;
  scanf("%d",&n);
  int data[n];
  /*配列dataに数値を格納*/
  for(i=0;i<n;i++){
    scanf("%d",&data[i]);
  }
  for(i=0;i<n;i++){
    printf("%d",data[i]);
    if(i<n-1)printf(" ");
  }
  printf("\n");
  
  for(i=1;i<n;i++){
    v=data[i];
    j=i-1;
    while(j>=0&&data[j]>v){
      data[j+1]=data[j];
      j--;
    }
    data[j+1]=v;
 
    for(k=0;k<n;k++){
      printf("%d",data[k]);
      if(k<n-1)printf(" ");
    }
    printf("\n");
 
  }
 

  return 0;

}



Measured memory_bytes: 2128
N,A = gets.split.map(&:to_i)
x = gets.split.map(&:to_i)
dp = (N+1).times.map{(N+1).times.map{Array.new(2501, 0)}}
dp[0][0][0]=1
N.times{|j|
 N.times{|k|
  2501.times{|s|
    dp[j+1][k][s] += dp[j][k][s]
    dp[j+1][k+1][s+x[j]] += dp[j][k][s] if dp[j][k][s]!=0
  }
 }
}
ans = 0
N.times{|i| ans+=dp[N][i+1][(i+1)*A]}
p ans

Measured memory_bytes: 54680
import sys
input = sys.stdin.readline


class SegmentTree:
    def __init__(self, L, op, default_val):
        self.op = op
        self.default_val = default_val
        self.sz = len(L)
        self.n = 1
        self.s = 1
        for i in range(1000):
            self.n *= 2
            self.s += 1
            if self.n >= self.sz:
                break
        self.node = [self.default_val]*(2*self.n-1)

        for i in range(self.sz):
            self.node[i+self.n-1] = L[i]

        for i in range(self.n-2,-1,-1):
            self.node[i] = self.op(self.node[i*2+1],self.node[i*2+2])
    
    def add(self, a, x):
        k = a+self.n-1
        self.node[k] += x
        for i in range(1000):
            k = (k-1)//2
            self.node[k] = self.op(self.node[2*k+1], self.node[2*k+2])
            if k <= 0:
                break
    
    def get(self, l, r):
        res = self.default_val
        n = self.n
        if self.sz <= r or 0 > l:
            print("ERROR: the indice are wrong.")
            return False

        for i in range(self.s):
            count = 2**i-1
            a = (r+1)//n
            b = (l-1)//n
            if a-b == 3:
                res = self.op(self.node[count+b+1],res)
                res = self.op(self.node[count+b+2],res)
                right = a*n
                left = (b+1)*n-1
                break
            if a-b == 2:
                res = self.op(self.node[count+b+1],res)
                right = a*n
                left = (b+1)*n-1
                break
            n = n//2

        n1 = n//2        
        #left
        for j in range(i+1,self.s):
            count = 2**j-1 
            a = (left+1)//n1
            b = (l-1)//n1
            if a-b == 2:
                res = self.op(self.node[count+b+1],res)
                left = (b+1)*n1-1                
            n1 = n1//2

        n1 = n//2        
        #right
        for j in range(i+1,self.s):
            count = 2**j-1 
            a = (r+1)//n1
            b = (right-1)//n1
            if a-b == 2:
                res = self.op(self.node[count+b+1],res)
                right = a*n1                
            n1 = n1//2
        return res

N = int(input())
point = [list(map(int,input().split())) for i in range(N)]

point.sort(lambda x: x[1])
for i in range(len(point)):
    point[i][1] = i

mod = 998244353

ans = ((N-4)*pow(2,N,mod)+3*N+4)%mod

pow2 = []
a = 1
for i in range(N+1):
    pow2.append(a)
    a *= 2
    a %= mod

point.sort(lambda x: x[0])

ST = SegmentTree([0]*len(point), lambda a,b:a+b, 0)


for i,(x,y) in enumerate(point):
    if point[i][1] > 0:
        ld = ST.get(0,y-1)
        #ls = i//2
    else:
        ld = 0
    lu = i-ld
    rd = y - ld
    ru = N - i - 1 - rd    
    ans += pow2[lu]-1
    ans += pow2[ld]-1
    ans += pow2[ru]-1
    ans += pow2[rd]-1
    ans %= mod
    ST.add(point[i][1],1)

print(ans)

Measured memory_bytes: 103336
#pragma GCC optimize("Ofast,fast-math,unroll-loops")
 
#include <bits/stdc++.h>
 
#define int ll
//#define double long double
#define endl '\n'
#define all(C) (C).begin(), (C).end()
#define rall(C) (C).rbegin(), (C).rend()
#define mp make_pair 
#define pb emplace_back
#define dbg(x) cerr << #x << " : " << x << endl
//#define PI 3.141592653589
 
using namespace std;
       
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using pii = pair <int, int>;
       
/* 
const ll MAX_MEM = 7e8;
char MEM[MAX_MEM];
ll MEM_POS = 0;
void* operator new(size_t x)
{
    auto ret = MEM + MEM_POS;
    MEM_POS += x;
    assert(MEM_POS < MAX_MEM);
    return ret;
}
void operator delete(void*)
{}
*/
       
template <class T>
istream& operator>> (istream &in, vector <T> &a)
{
    for (auto &i : a)
        in >> i;
    return in;
}
       
template <class T> 
ostream& operator<< (ostream &out, vector <T> a)
{
    for (auto &i : a)
        out << i << ' ';
    return out;
}
       
template <class T, class U>
istream& operator>> (istream &in, pair <T, U> &p)
{
    in >> p.first >> p.second;
    return in;
}
       
template <class T, class U>
ostream& operator<< (ostream &out, pair <T, U> p)
{
    out << p.first << " " << p.second << " ";
    return out;
}
       
inline void Start()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
    //freopen(".in", "r", stdin);
    //freopen(".out", "w", stdout);
}

signed main()
{
    Start();
    string s;
    int k;
    cin >> s >> k;
    int n = s.size();
    int cnt = 0;
    int cur = 0;
    vector <int> v;
    for (int i = 0; i < n; ++i)
        if (s[i] == s[(i + 1) % n])
            ++cur;
        else
        {
            ++cur;
            v.pb(cur);
            cnt += cur / 2;
            cur = 0;
        }
    ++cur;
    if (cur == n + 1)
        return cout << n * k / 2, 0;
    v.pb(cur);
    cnt += cur / 2;
    auto w = v, t = v;
    t.back() -= s[0] == s.back();
    if (s[0] == s.back())
    {
        w.back() += w[0] - 1;
        v.back() += v[0] - 1;
        v.erase(v.begin());
        t.erase(t.begin());
    }
    int ans = 0;
    if (k == 1)
    {
        return cout << cnt - !(cur & 1), 0;
    }
    int a, b, c;
    a = b = c = 0;
    for (auto &i : w)
        a += i / 2;
    for (auto &i : v)
        b += i / 2;
    for (auto &i : t)
        c += i / 2;
    b *= (k - 2);
    dbg(w), dbg(v), dbg(t);
    if (k == 2)
        return cout << a + c, 0;
    else
        return cout << a + b + c, 0;
    return 0;
}



Measured memory_bytes: 256
N=int(input())
A1=list(map(int,input().split()))
A2=list(map(int,input().split()))

ans=0
for i in range(N):
    tmp=0
    for j in range(N):
        if j<=i:
            tmp+=A1[j]
        if j>=i:
            tmp+=A2[j]
    ans=max(ans,tmp)
print(ans)


Measured memory_bytes: 38896
#include<stdio.h>
int main()
{
	int c[100] = {0}, n, m = 0, i;
	while (scanf("%d", &n)>0) {
		if (++c[n-1] > m)
			m = c[n-1];
	}
	for (i = 0; i < 100; i ++) {
		if (c[i] == m)
			printf("%d\n", 1+i);
	}
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
    #define Mod 1000000007
    #define INF 1e9
    #define INFL 9e18
    #define EPS 1e-9
    #define pb push_back
    #define mp make_pair
    #define SET(a) memset(a,-1,sizeof(a))
    #define CLR(a) memset(a,0,sizeof(a))
    #define CPY(a,b) memcpy(a,b,sizeof(a))
    #define all(a) (a).begin(),(a).end()
    #define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    #define N 100005
    #define fs first
    #define sc second
    using namespace std;

    typedef  long long int ll;
    typedef pair<ll,ll> ii;
    typedef vector <ii> vii;
    typedef vector <ll> vi;
  
    ll arr[N];
 
    int main()
    {
    // #ifndef ONLINE_JUDGE
    // freopen("input.txt","r",stdin);
    // freopen("output.txt","w",stdout);
    // #endif
   ios;
   ll a,b,c,n,m;
   ll ans=0,cnt=0,adi=0,flag=0;
   string str;
   ll c1=0,c2=0,f=0;
ll a1[505],a2[505],a3[505];
   cin>>n;
   for(int i=1;i<=n-1;i++)
   {
    cin>>a1[i]>>a2[i]>>a3[i];

   }
   for(int i=1;i<=n;i++)
   {

   }
for(int i=1;i<=n-1;i++)
{
 // curr=i;
 ll  time=a2[i]+a1[i];
 //cout<<time<<endl;

  for(int j=i+1;j<=n-1;j++)
  {
    for(int k=max(a2[j],time);k<=max(time,a2[j])+a3[j];k++)
    {
      //cout<<i<<" "<<k<<" "<<a2[j]<<endl;
      if((k)%a3[j]==0)
      {
        //cout<<"train found = "<<k<<endl;
        time=k+a1[j];
        break;
      }
    }

  }
  arr[i]=time;
}

for(int i=1;i<=n-1;i++)
  cout<<arr[i]<<endl;
cout<<0;


    return 0;


    }

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define dbg(...) do{cerr<<__LINE__<<": ";dbgprint(#__VA_ARGS__, __VA_ARGS__);}while(0);

using namespace std;

namespace std{template<class S,class T>struct hash<pair<S,T>>{size_t operator()(const pair<S,T>&p)const{return ((size_t)1e9+7)*hash<S>()(p.first)+hash<T>()(p.second);}};template<class T>struct hash<vector<T>>{size_t operator()(const vector<T> &v)const{size_t h=0;for(auto i : v)h=h*((size_t)1e9+7)+hash<T>()(i)+1;return h;}};}
template<class T>ostream& operator<<(ostream &os, const vector<T> &v){os<<"[ ";rep(i,v.size())os<<v[i]<<(i==v.size()-1?" ]":", ");return os;}template<class T>ostream& operator<<(ostream &os,const set<T> &v){os<<"{ "; for(const auto &i:v)os<<i<<", ";return os<<"}";}
template<class T,class U>ostream& operator<<(ostream &os,const map<T,U> &v){os<<"{";for(const auto &i:v)os<<" "<<i.first<<": "<<i.second<<",";return os<<"}";}template<class T,class U>ostream& operator<<(ostream &os,const pair<T,U> &p){return os<<"("<<p.first<<", "<<p.second<<")";}
void dbgprint(const string &fmt){cerr<<endl;}template<class H,class... T>void dbgprint(const string &fmt,const H &h,const T&... r){cerr<<fmt.substr(0,fmt.find(","))<<"= "<<h<<" ";dbgprint(fmt.substr(fmt.find(",")+1),r...);}
typedef long long ll;typedef vector<int> vi;typedef pair<int,int> pi;const int inf = (int)1e9;const double INF = 1e12, EPS = 1e-9;

const int MX = 100000;
const int MX_L=17;

int n;
int parent[MX_L][MX];
int depth[MX];
vector<vi> e;

void dfs(int c, int p, int d){
	depth[c] = d;
	parent[0][c] = p;
	rep(i, e[c].size()){
		int to = e[c][i];
		if(to == p) continue;
		dfs(to, c, d + 1);
	}
}
inline int lca(int a, int b){
	if(depth[a] > depth[b]) swap(a, b);
	int d = depth[b] - depth[a];
	rep(i, MX_L) if(d & 1 << i) b = parent[i][b];
	if(a == b) return a;
	for(int i = MX_L - 1; i >= 0; i--) if(parent[i][a] != parent[i][b]){
		a = parent[i][a];
		b = parent[i][b];
	}
	return parent[0][a];
}
inline int dist(int a, int b){
	int l = lca(a, b);
	return depth[a] + depth[b] - 2 * depth[l];
}

int main(){
	cin.tie(0); cin.sync_with_stdio(0);
	
	cin >> n;
	int u, v; cin >> u >> v; u--; v--;
	e.resize(n);
	rep(i, n - 1){
		int a, b; cin >> a >> b; a--; b--;
		e[a].pb(b);
		e[b].pb(a);
	}
	parent[0][n] = n;
	dfs(0, n, 1);
	rep(i, MX_L - 1) rep(j, n) parent[i + 1][j] = parent[i][parent[i][j]];
	
	int ans = 0;
	rep(i, n) if(e[i].size() == 1){
		int du = dist(u, i), dv = dist(v, i);
		if(du >= dv) continue;
		ans = max(ans, dv - 1);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 16768
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> lpair;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define rREP(i,m,n) for(ll i = (m); i >= (n); i--)
#define ALL(c) (c).begin(), (c).end()
#define print(x) cout << (x) << endl;
#define printa(x,n) for(ll i = 0; i < n; i++){ cout << (x[i]) << " ";} cout<<endl;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);

    int n;
    cin >> n;
    ll a[n];
    rep(i,n) cin >> a[i];

    ll l[n];
    ll r[n];
    rep(i,n)
    {
        l[i] = 0;
        r[i] = 0;
    }

    // r
    rep(i,n)
    {
        if (i+a[i]<n)
        {
            r[i+a[i]]++;
        }
    }
    rep(i,n)
    {
        if (0 <= i-a[i])
        {
            l[i-a[i]]++;
        }
    }
    
    ll ans = 0;
    rep(i,n) ans += r[i] * l[i];
    cout << ans << endl;
    
}




Measured memory_bytes: 8344
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=1000000007,MAX=1<<17,INF=1<<30;

int main(){
    
    std::ifstream in("text.txt");
    std::cin.rdbuf(in.rdbuf());
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    while(1){
        int N,M,P;cin>>N>>M>>P;
        
        if(N==0&&M==0&&P==0) return 0;
        
        M--;
        int sum=0,win=0;
        
        for(int i=0;i<N;i++){
            int a;cin>>a;
            sum+=a;
            if(i==M) win=a;
        }
        
        sum*=(100-P);
        
        if(win==0) cout<<0<<endl;
        else cout<<sum/win<<endl;
    }
}



Measured memory_bytes: 3136
#include<bits/stdc++.h>
using namespace std;
#define FASTIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pil pair<int,ll>
#define pli pair<ll,int>
#define mod 1000000007
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
vector<vector<int> > d; 
ll power(ll a,int n){
  if(n==0)
    return 1;
  if((n%2)==0)
    return (power((a*a)%mod,n/2))%mod;
  else
    return (a*(power((a*a)%mod,n/2))%mod)%mod;    
}
int main(){
FASTIO
int k;
cin>>k;
vector<int> a(32);
a[0]=1;
a[1]= 1;
a[2]= 1;
a[3]= 2;
a[4]= 1;
a[5]= 2;
a[6]= 1;
a[7]= 5;
a[8]= 2;
a[9]= 2;
a[10]= 1;
a[11]= 5;
a[12]= 1;
a[13]= 2;
a[14]= 1;
a[15]= 14;
a[16]= 1;
a[17]= 5;
a[18]= 1;
a[19]= 5;
a[20]=2;
a[21]= 2;
a[22]= 1;
a[23]= 15;
a[24]= 2;
a[25]= 2;
a[26]= 5;
a[27]= 4;
a[28]= 1;
a[29]= 4;
a[30]= 1;
a[31]= 51;
cout<<a[k-1];
return 0;
}

Measured memory_bytes: 256
Imports System.Collections.Generic
Imports System.Console

Module Program
    Sub Main()
        Dim N As Integer = NextInt()
        Dim a As Integer() = New Integer(N - 1) {}

        For i As Integer = 0 To N - 1
            a(i) = NextInt()
        Next

        Array.Sort(a)
        Array.Reverse(a)

        Dim ans As Integer

        For i As Integer = 0 To UBound(a)
            ans += a(i) * CInt((-1) ^ i)
        Next

        WriteLine(ans)
    End Sub

    Function NextInt() As Integer
        Return CInt(NextString())
    End Function

    Function NextString() As String
        Dim result As New List(Of Char)
        Do
            Dim tmp As Integer = Read()
            If tmp < 0 Then Exit Do
            Dim nextChar As Char = Chr(tmp)

            If Not Char.IsWhiteSpace(nextChar) Then
                result.Add(nextChar)
            ElseIf nextChar <> vbCr Then
                Exit Do
            End If
        Loop
        Return New String(result.ToArray())
    End Function

End Module


Measured memory_bytes: 20560
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0,i##_max=(N);i<i##_max;++i)
#define repp(i,l,r) for(int i=(l),i##_max=(r);i<i##_max;++i)
#define per(i,N) for(int i=(N)-1;i>=0;--i)
#define perr(i,l,r) for(int i=r-1,i##_min(l);i>=i##_min;--i)
#define all(arr) (arr).begin(), (arr).end()
#define SP << " " <<
#define SPF << " "
#define SPEEDUP cin.tie(0);ios::sync_with_stdio(false);
#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; 

inline void YesNo(bool b){ cout << (b?"Yes" : "No") << endl;}
inline void YESNO(bool b){ cout << (b?"YES" : "NO") << endl;}
inline void Yay(bool b){ cout << (b?"Yay!" : ":(") << endl;}

int main(void){
  SPEEDUP
  cout << setprecision(15);
  ll x;cin >> x;
  ll count = (x/11)*2ll;
  ll m = x%11;
  if(m!=0){
    if(m>6)count+=2;
    else count++;
  }
  cout << count << endl;
  return 0;
}


Measured memory_bytes: 256
S = input()
a = S[0:2]
b = S[2:4]


def mm(s):
    if int(s) <= 12 and 1 <= int(s):
        return True
    return False


if mm(a) and mm(b):
    print('AMBIGUOUS')
elif mm(a):
    print('MMYY')
elif mm(b):
    print('YYMM')
else:
    print('NA')


Measured memory_bytes: 38384
import collections

n = int(input())
abc = []

for i in range(n):
  a = list(input())
  a.sort()
  a = str(a)
  abc.append(a)

c = collections.Counter(abc)
cnt = 0

for i in c:
  num = c[i]
  if num != 1:
    cnt += num*(num-1) // 2
 
print(cnt)

Measured memory_bytes: 28976
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define pb  push_back
#define all(a) (a).begin(),(a).end()
#define sz(x) (int)x.size()
#define endl "\n"
#define inf 1000000007
#define FOR(i, a, b) for(int i=a; i<b; i++)

double calc(int x1, int y1, int x2, int y2){
	double temp = (abs(x1-x2)*abs(x1-x2)) + (abs(y1-y2)*abs(y1-y2));
	return sqrt(temp);
}
void solve(){
	int n;
	cin>>n;
	pair<int, int> arr[n];
	FOR(i, 0, n){
		cin>>arr[i].first>>arr[i].second;
	}
	double mat[9][9], res=0;
	FOR(i, 0, n){
		FOR(j, i+1, n){
			res+=calc(arr[i].first, arr[i].second, arr[j].first, arr[j].second)*2/n;
		}
	}
	cout<<fixed<<setprecision(10)<<res;
}
signed main(){
	#ifdef _DEBUG
		freopen("input.txt", "r", stdin);
    	freopen("output.txt", "w", stdout);
	#endif
	
	ios::sync_with_stdio(false);
	cin.tie(0);
	int t=1;
	//cin>>t;
	while(t--){
		solve();
	}
	return 0;
 
}

Measured memory_bytes: 256
# D - Wizard in Maze
import sys
from collections import deque
from typing import List, Tuple


class WarpableMaze:
    __slots__ = ["height", "width", "start", "goal", "road", "wall", "grid"]

    def __init__(
        self,
        height: int,
        width: int,
        start: Tuple[int, int],
        goal: Tuple[int, int],
        grid: List[str],
        road: str = ".",
        wall: str = "#",
    ) -> None:
        # Values of start and goal must be 0-origin.
        self.height = height + 4
        self.width = width + 4
        self.start = self._flatten_coordinate(*start)
        self.goal = self._flatten_coordinate(*goal)
        self.road = road
        self.wall = wall
        self.grid = self._flatten_grid(grid)

    def _flatten_coordinate(self, h: int, w: int) -> int:
        return self.width * (h + 2) + w + 2

    def _flatten_grid(self, grid: List[str]) -> str:
        flat_grid = self.wall * self.width * 2
        for row in grid:
            flat_grid += self.wall * 2 + row + self.wall * 2
        flat_grid += self.wall * self.width * 2
        return flat_grid

    def bfs(self) -> int:
        w = self.width
        move = (-w, w, -1, 1)
        warp = [-2 * w - 2, -2 * w - 1, -2 * w, -2 * w + 1, -2 * w + 2]
        warp.extend([-w - 2, -w - 1, -w + 1, -w + 2, -2, 2])
        warp.extend([w - 2, w - 1, w + 1, w + 2])
        warp.extend([2 * w - 2, 2 * w - 1, 2 * w, 2 * w + 1, 2 * w + 2])

        unsearched = 1 << 30
        dist = [unsearched] * (self.height * self.width)
        dist[self.start] = 0
        queue = deque([self.start])
        while queue:
            x = queue.popleft()
            if x == self.goal:
                break
            cur_dist = dist[x]

            for dx in move:
                nx = x + dx
                if self.grid[nx] == self.wall:
                    continue
                if dist[nx] > cur_dist:
                    dist[nx] = cur_dist
                    queue.appendleft(nx)

            for dx in warp:
                nx = x + dx
                if self.grid[nx] == self.wall:
                    continue
                if dist[nx] > cur_dist + 1:
                    dist[nx] = cur_dist + 1
                    queue.append(nx)

        return dist[self.goal] if dist[self.goal] != unsearched else -1

    def debug(self):
        print(f"<DEBUG>\nstart={self.start}, goal={self.goal}", file=sys.stderr)
        for row in zip(*[iter(self.grid)] * self.width):
            print(*row, file=sys.stderr)


def main():
    H, W, CH, CW, DH, DW, *S = open(0).read().split()
    start, goal = (int(CH) - 1, int(CW) - 1), (int(DH) - 1, int(DW) - 1)
    maze = WarpableMaze(int(H), int(W), start, goal, S)
    # maze.debug()
    print(maze.bfs())


if __name__ == "__main__":
    main()


Measured memory_bytes: 219780
n = int(input())
mod = 10 ** 9 + 7

# 素因数分解 - 試し割り法
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

d = {}

for i in range(1,n+1):
    arr = factorization(i)
    for num, cnt in arr:
        if num in d:
            d[num] += cnt
        else:
            d[num] = cnt

ans = 1

for num in d:
    if num != 1:
        ans *= (d[num] + 1) % mod
        ans %= mod

print(ans)


Measured memory_bytes: 3188
#include <iostream>
using namespace std;
#define MAX 500000
#define SENTINEL 2000000000

int L[MAX/2+2], R[MAX/2+2];
int cnt;

void merge(int A[], int n, int left, int mid, int right){
	int n1 = mid - left;
	int n2 = right - mid;
	for(int i = 0; i < n1; i++) L[i] = A[left + i];
	for(int i = 0; i < n2; i++) R[i] = A[mid + i];
	L[n1] = R[n2] = SENTINEL;
	int i = 0, j = 0;
	for(int k = left; k < right; k++){
		cnt++;
		if(L[i] <= R[j]){
			A[k] = L[i++];
		}else{
			A[k] = R[j++];
		}
	}
}

void mergeSort(int A[], int n, int left, int right){
	if(left+1 < right){
		int mid = (left + right) / 2;
		mergeSort(A, n, left, mid);
		mergeSort(A, n, mid, right);
		merge(A, n, left, mid, right);
	}
}

int main(void){
	int A[MAX], n, i;
	cnt = 0;
	
	cin >> n;
	for(i = 0; i < n; i++) cin >> A[i];
	
	mergeSort(A, n, 0, n);
	
	for(i = 0; i < n; i++){
		if(i) cout << " ";
		cout << A[i];
	}
	cout << endl;
	
	cout << cnt << endl;
	
	return 0;
}


Measured memory_bytes: 6932
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<int(n);++i)
#define rep1(i,n) for(int i=1;i<=int(n);++i)
#define all(a) a.begin(),a.end()
#define lb(s,x) lower_bound(all(s),x)-s.begin()
#define debug(x) cerr<<#x<<": "<<x<<endl
#define INF 1e9
typedef long long ll;
string words[] = {"dream", "dreamer", "erase", "eraser"};

bool dfs(string &s, int index){
    if((int)s.size() == index) return true;
    for(string word: words){
        int k = word.size();
        if(s.substr(index, k) == word){
            if(dfs(s, index+k)){
                return true;
            }
        }
    }
    return false;
}

int main(void){
    string s;
    cin>>s;
    cout<<((dfs(s,0)) ? "YES" : "NO")<<endl;
    return 0;
}


Measured memory_bytes: 2688
import java.util.Scanner;

public class Main{
  public static void main(String[] args){
    Scanner sc=new Scanner(System.in);
    int a=sc.nextInt();
    int b=sc.nextInt();
    if(a<b){
    System.out.println("a < b");
    }else if(a>b){
    System.out.println("a > b");
    }else{
    System.out.println("a == b");
    }
  }
}

Measured memory_bytes: 26152
/*
AizuOnline A2332
Space-Time Sugoroku Road
*/

#include <stdio.h>

#define CANNOTREACH 999999

int N;
int p[100001];
int t[100001];


void init()
{
  int i;
  scanf("%d",&N);
  for(i=1;i<=N;i++)
    scanf("%d",&(p[i]));
  //printf("N=;%d\n",N);
}

void rensa(int pos,int step)
{
  int i;

  if(t[pos] > step)
    {
      t[pos]=step;
      if(p[pos] != 0)  // jump any step
	rensa(pos+p[pos],step);
      if(p[pos]==0)
	for(i=1;i<=6;i++)
	  {
	    rensa(pos+i,t[pos]+1);
	  }
    }
}
void print()
{ 
  int i;
  for(i=1;i<=N;i++)
    printf("%d:%d %d \n", i,p[i],t[i]);

}
main()
{
  int i;

  init();

  for(i=1;i<=N;i++)
    t[i]=CANNOTREACH;
  
  rensa(1,0);

  //print();  
  printf("%d\n",t[N]);
return(0);
}

Measured memory_bytes: 3984
/*
 * Author: .-O_O-.
 */
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include<bits/stdc++.h>
using namespace __gnu_pbds;
using namespace std;
#define ll long long
#define pb push_back
#define vi vector<int>
#define rep0(a,b) for(int a=0;a<b;a++)
#define rep1(a,b) for(int a=1;a<=b;a++)
#define repp(a,b,c) for(int a=b;a<c;a++)
#define in insert
#define len length()
#define si size()
#define lb lower_bound
#define ub upper_bound
#define beg begin()
#define en end()
#define f first
#define s second
#define pr(a) cout<<a
#define pr2(a,b) cout<<a<<" "<<b<<"\n"
#define nx cout<<"\n"
#define int long long
// void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}
                                                     
template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]"<<endl;}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define deb(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define deb(x...)
#endif
const ll mod = 1000000007;
const ll N = 105;
const ll mm = 1e+18;
void solve()
{
    int n,m;
    cin>>n>>m;
    int ans=0;
    int l=0;
    int r=2e12+10;
    while(l<r){
        int mid=(l+r)>>1;
        if((n+m/2)>=mid&&max(0LL,(mid-n)*2)+2*mid<=m){
            ans=mid;
            l=mid+1;
        }
        else r=mid;
    }
    pr(ans);
}
signed main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int t=1;
    //cin>>t;
    rep1(_i,t){
        //cout<<"Case #"<<_i<<": ";
        solve();
        //nx;
    }
    return 0;
}

Measured memory_bytes: 3576
#include<bits/stdc++.h>
#define __ ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ll long long int
#define N 100005

using namespace std;

int main()
{
    __

    ll ans =0,n,a,b;

    cin >> n >> a >> b;

    ans = n/(a+b);

    ans = ans*a;

    ll rem = n % (a+b);

    ans += min(a,rem);

    cout << ans << '\n';

    return 0;
}


Measured memory_bytes: 256
//#include "stdc++.h"
#include<bits/stdc++.h>
#include<iostream>
#pragma warning(disable:4996)
#pragma comment(linker, "/STACK:336777216")
using namespace std;
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
//typedef tuple<int, int, int> t3;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <ll, int> pli;
typedef pair <db, db> pdd;
typedef vector<int> vi;
#define m1 make_pair
#define pb push_back
#define IOS std::ios::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL);
inline ll gcd(ll a,ll b){if(a==0) return b;return gcd(b%a,a);}
inline ll power(ll a,ll n,ll m){if(n==0) return 1;ll p=power(a,n/2,m);p=(p*p)%m;if(n%2) return (p*a)%m;else return p; }
#define flush fflush(stdout)
const ll MOD = 1000000007;
const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
ll way1[100001],way2[100001];
void dfs(vector<int> adj[],int u,bool visited[])
{
    visited[u]=1;way1[u]=1;way2[u]=1;int v;ll x;
    for(int i=0;i<adj[u].size();i++)
    {
        v=adj[u][i];
        if(!visited[v])
        {
            //cnt++;
            dfs(adj,v,visited);
            x=(way1[v]+way2[v])%MOD;
            way1[u]=(x*way1[u])%MOD;
            way2[u]=(way2[u]*way1[v])%MOD;
        }
    }
}
int main()
{
    IOS;//ifstream fin("input.txt");ofstream fout("output.txt");
    int n;
    cin>>n;
    vector<int> adj[n+1];
    int u,v;
    for(int i=0;i<n-1;i++)
    {
        cin>>u>>v;
        adj[u].pb(v);
        adj[v].pb(u);
    }
    bool visited[n+1];
    memset(visited,0,sizeof(visited));
    dfs(adj,1,visited);
    cout<<(way1[1]+way2[1])%MOD<<endl;
    return 0;
}


Measured memory_bytes: 14336
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define pll pair<ll,ll>
#define vi vector < int >
#define pii pair<int,int>
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define all(a) (a).begin(),(a).end()
#define s(x) scanf("%d",&x)
#define sll(x) scanf("%lld",&x)
#define pf(x) printf("%d\n",x)
#define pfl(x) printf("%lld\n",x)
#define flash ios_base::sync_with_stdio(false);cin.tie(0)
#define goog(x) cout << "Case #" << x << ": "
#define MAX5 200005
#define MAX6 2000005
#define MLOG 18
#define limit 1e18
#define mod 1000000007   
void __print(int x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif


int power(int x, int y, int p){
    int res = 1;
    x = x % p;
    while (y > 0){
        if (y & 1)
            res = (res*x) % p;
        y = y>>1;
        x = (x*x) % p;
    }
    return res;
}

void solve(){
    int n;
    cin >> n;
    vector < int > v(n);
    int sum = 0;
    for(int i = 0; i < n; i++){
        cin >> v[i];
        sum = (sum + v[i])%mod;
    }
    int ans = 0;
    for(int i = 0; i < n; i++){
        sum = (sum - v[i] + mod)%mod; 
        ans = (ans + ((v[i]*sum)%mod))%mod;
    }
    cout << ans;
} 
signed main(){  
//   freopen("output.txt", "r", stdin);
//   freopen("tt.txt", "w", stdout);
    // flash;
    int t = 1;
    //  cin >> t;  
    for(int tc = 1; tc <= t; tc++){
    // goog(tc);
        solve();
		if(tc != t) cout << endl;
    }
}

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

// エイリアス
using  ll = long signed long;
using ull = long unsigned long;
using  ld = long double;
using   P = pair<int, int>;
using llP = pair<ll, ll>;
using DoP = pair<double, double>;

// 汎用マクロ
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define FOREACH(i,q) for (auto &i : q)
#define UNIQUE(v) do { sort((v).begin(), (v).end()); (v).erase(unique((v).begin(), (v).end()), (v).end()); } while (false)
#define SZ(x) ((int)(x).size())
template <class T>inline bool chmin(T &a, const T b) {if (a > b) { a = b; return true;} return false;}
template <class T>inline bool chmax(T &a, const T b) {if (a < b) { a = b; return true;} return false;}
template <class T>inline void line_out(const vector<T> vec) {int n = SZ(vec); rep(i, n) { cout << vec[i]; if(i < n-1) cout << " ";}cout << endl;}
const int di[] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dj[] = {1, 0, -1, 0, 1, -1, 1, -1};
const int INF = 1 << 28;
const ll INF64 = 1ll << 57;
const int mod = 1000000007;
//const int mod = 998244353;
struct mint
{
  ll x; // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint &operator+=(const mint a)
  {
    if ((x += a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator-=(const mint a)
  {
    if ((x += mod - a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator*=(const mint a)
  {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const
  {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const
  {
    mint res(*this);
    return res -= a;
  }
  mint &operator++()
  {
    if ((x += 1) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator--()
  {
    if ((x += mod - 1) >= mod)
      x -= mod;
    return *this;
  }
  mint operator*(const mint a) const
  {
    mint res(*this);
    return res *= a;
  }
  mint pow(ll t) const
  {
    if (!t)
      return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1)
      a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const
  {
    return pow(mod - 2);
  }
  mint &operator/=(const mint a)
  {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const
  {
    mint res(*this);
    return res /= a;
  }
};

int main()
{
  int n, x; cin >> n >> x;
  vector<int> l(n+1);
  rep(i, n) cin >> l[i+1];
  vector<int> d(n+2);
  d[1] = 0;
  for(int i = 2; i <= n+1; ++i) d[i] = d[i-1]+l[i-1];
  int ans = distance(d.begin(), upper_bound(ALL(d), x))-1;
  cout << ans << endl;
}

Measured memory_bytes: 3656
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <iomanip>
#include <cmath>
#include <climits>
using namespace std;

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

long int jou(long int x, long int y){
    long int f = 1;
    for(int i = 0; i < y; ++i){
        f = f * x % int(powl(10,9) + 7);
    }

    return f;
}

bool pn(long int x){
    if(x != 2 && x % 2 == 0)
        return false;

    for(int i = 3; i < x; ++i){
        if(x != i && x % i == 0)
            return false;
    }
    return true;
}

int main(){
    int x;
    cin >> x;
    cout << (x < 1200 ? "ABC" : "ARC") << endl;

    return 0;
}

Measured memory_bytes: 256
H,W,K = map(int,input().split())
Bords = []
for _ in range(H):
    b = input()
    Bords.append(b)

ans = 0
for h in range(1<<H):
    for w in range(1<<W):
        cnt = 0
        for i in range(H):
            for j in range(W):
                if (h>>i)&1 == 0 and (w>>j)&1 == 0:
                    if Bords[i][j] == "#":
                        cnt += 1
        if cnt == K:
            ans += 1
            
print(ans)

Measured memory_bytes: 9092
#include <bits/stdc++.h>
using namespace std;
//frog1
int solve(vector<int> ar, int n, int k){
    vector<int> dp(n+1);
    dp[1] = 0;
    for(int i=2;i<=n;i++){
        dp[i] = INT_MAX;
        for(int j=i-1;j>=1 && (i-j)<=k; j--){
            dp[i] = min(dp[i], abs(ar[i]-ar[j])+dp[j]);
        }
    }
    return dp[n];
}
int main() {
	int n,k;
	cin>>n>>k;
	vector<int> ar(n+1);
	for(int i=1;i<=n;i++){
	    cin>>ar[i];
	}
	cout<<solve(ar, n, k);
	
	return 0;
}


Measured memory_bytes: 4268
import java.util.*
import java.io.PrintWriter

val pw = PrintWriter(System.out)
val MOD = 1000000007L
val INF = 2147483647
val LINF = 9223372036854775807L

fun main(args: Array<String>){
    solve()
    pw.flush()    
}

fun solve(){
    val h = nextIntList()
    val a = nextIntList()
    println(if(a.sum() >= h.first()) "Yes" else "No")


}


// Print
fun println(v: String){
    pw.println(v)
}
fun print(v: String){
    pw.print(v)
}

// Read
fun next() = readLine()!!
fun nextInt() = next().toInt()
fun nextLong() = next().toLong()
fun nextDouble() = next().toDouble()
fun nextList() = next().split(" ")
fun nextIntList() = next().split(" ").map{ it.toInt() }
fun nextLongList() = next().split(" ").map{ it.toLong() }
fun nextDoubleList() = next().split(" ").map{ it.toDouble() }
fun nextAryln(n: Int) = Array(n){ next() }
fun nextIntAryln(n: Int) = IntArray(n){ nextInt() }
fun nextLongAryln(n: Int) = LongArray(n){ nextLong() }
fun nextDoubleAryln(n: Int) = DoubleArray(n) { nextDouble() }

// Math
fun abs(n: Long) : Long = Math.abs(n)
fun abs(n: Double) : Double = Math.abs(n)
fun max(a: Long = -LINF, b: Long = -LINF, c: Long = -LINF, d: Long = -LINF, e: Long = -LINF): Long = listOf(a, b, c, d, e).max()!!.toLong()
fun min(a: Long = LINF, b: Long = LINF, c: Long = LINF, d: Long = LINF, e: Long = LINF): Long = listOf(a, b, c, d, e).min()!!.toLong()
fun prime(from: Long, to: Long = from) : List<Long>{
    return (from..to).filter{ i ->
        val max = Math.sqrt(i.toDouble()).toLong()
        (2..max).all{ j -> i % j != 0L}
    }
}
fun gcd(a: Long, b: Long) : Long = if(a % b == 0L) b else gcd(b, (a % b))
fun lcm(a: Long, b: Long) : Long = a / gcd(a, b) * b
fun modpow(a: Long, n: Long, p:Long = MOD) : Long {
    var res = 1L
    var ar = a
    var nr = n
    while(nr > 0){
        if((nr and 1) == 1L) res = res * ar % p
        ar = ar * ar % p
        nr = nr shr 1
    }
    return res
}
fun modinv(a: Long, p: Long = MOD) : Long = modpow(a, p - 2, p)
fun ncr(n: Long, r: Long) : Long {
    var a = 1L
    var b = 1L
    for (i in 1..r) {
        a = a * (n + 1 - i) % MOD
        b = b * i % MOD
    }
    return modinv(b, MOD) * a % MOD
}


Measured memory_bytes: 47664
import java.util.Scanner;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int[] e = new int[10];
		e[1]=0;
		e[9]=0;
		e[4]=0;
		e[7]=0;
		for(int i = 0; i<4; i++){
			int a = sc.nextInt();
			if(a==1 || a==9 || a==7 || a==4){
				e[a]++;
			}
		}
		if(e[1]>=1 && e[9]>=1 && e[7]>=1 && e[4]>=1){
			System.out.println("YES");
			return;
		}
		System.out.println("NO");
	}
}

Measured memory_bytes: 21972
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(i, a, b) for(ll i = (a); i < (b); ++i)
#define REP(i, n) for(ll i = 0; i < (n); ++i)
#define ARRAY_LENGTH(array) sizeof(array)/sizeof(*array)
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
const int INF = 1000100100;

int main() {
    ll N;
    string S;
    cin >> N >> S;

    ll x = 0, ans = 0;
    REP(i, N) {
        if(S[i] == 'I') {
            ++x;
        } else {
            --x;
        }

        if(x > ans) {
            ans = x;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3604
from collections import Counter
n=int(input())
a = [int(i) for i in input().split()]
b=[0]
s=0
for i in a:
  s+=i
  b.append(s)
c= Counter(b)
ans=0
for i in c:
  ans+=int(c[i]*(c[i]-1)/2)
print(ans)

Measured memory_bytes: 41472
use std::str::FromStr;
use std::fmt::Debug;
use std::cmp;
fn read_as_vec<T>() -> Vec<T>
where T: FromStr, <T as FromStr>::Err : Debug{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().split_whitespace().map(|c| T::from_str(c).unwrap()).collect()

}

fn main(){
    let line: Vec<u32> = read_as_vec();
    let (lh, lw) = (line[0], line[1]);

    let line: Vec<u32> = read_as_vec();
    let (h, w) = (line[0], line[1]);

    println!("{}", (lh - h)*(lw -w));
}


Measured memory_bytes: 4352
def Donuts_max(n , x , ml):

    count = x - sum(ml)
    ans = n + (count // min(ml))

    return ans

def main():
    n , x = map(int, input().split())
    ml = [int(input()) for i in range(n)]
    print(Donuts_max(n , x , ml))

if __name__ == '__main__':
    main()

Measured memory_bytes: 38384
import java.io.*;
import java.util.StringTokenizer;

public class Main {
    public static void main(String[] args) throws IOException {
        FastScanner in = new FastScanner();
        long k = in.nextLong();
        long[] list = new long[50];
        
        for (int i = 0; i < 50; i++) {
            list[i] = k / 50 + 49;
        }
        
        for (int i = 0; i < k % 50; i++) {
            for (int j = 0; j < 50; j++) {
                if (j == 49 - i) list[j] += 50; else list[j]--;
            }
        }
        
        System.out.println(50);
        for (int i = 0; i < 50; i++) System.out.print(list[i] + " ");
        System.out.println();
    }

    public static class FastScanner {
        BufferedReader br;
        StringTokenizer st;

        public FastScanner(String s) {
            try {
                br = new BufferedReader(new FileReader(s));
            } catch (FileNotFoundException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
        }

        public FastScanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String nextToken() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        String nextLine() {
            st = null;
            try {
                return br.readLine();
            } catch (IOException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
            return null;
        }

        int nextInt() {
            return Integer.parseInt(nextToken());
        }

        long nextLong() {
            return Long.parseLong(nextToken());
        }

        double nextDouble() {
            return Double.parseDouble(nextToken());
        }
    }
}


Measured memory_bytes: 21332