akhauriyash/Code-Regression huggingface dataset:
#include <chrono>

#include <iostream>
#include <iomanip>
#include <algorithm>
#include <bitset>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <cmath>
#include <time.h>
#include <random>
#include <string>
#include <cassert>
#include <vector>
#include <ostream>
#include <istream>
#include <stack>
#include <deque>
#include <queue>
#include <functional>

using namespace std;

#define int long long
#define pb push_back
#define all(a) (a).begin(), (a).end()
#define pii pair<int, int>
#define ld long double

ostream& operator << (ostream &a, const vector<int> &b) {
    for (auto k : b) cout << k << " ";
    return a;
}

#ifdef LOCAL
    #define dbg(x) cout << #x << " : " << (x) << "\n";
    const int INF = 1e18;
//    const int mod = 2600000069;
//    const int p = 10;
//    const ld PI = 3.1415926535;
#else
    #define dbg(x)
    const int INF = 1e18;
//    const int mod = 2600000069;
//    const int p = 179;
//    const ld PI = 3.1415926535;
#endif

//#pragma GCC optimize("Ofast,no-stack-protector")
//#pragma GCC target("sse,sse2,sse3,sse3,sse4")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC optimize("fast-math")
//#pragma GCC target("avx2")
//#pragma GCC optimize("section-anchors")
//#pragma GCC optimize("profile-values,profile-reorder-functions,tracer")
//#pragma GCC optimize("vpt")
//#pragma GCC optimize("rename-registers")
//#pragma GCC optimize("move-loop-invariants")
//#pragma GCC optimize("unswitch-loops")
//#pragma GCC optimize("function-sections")
//#pragma GCC optimize("data-sections")

const int MAXN = 2e5 + 1;
const int mod = 1e9 + 7;

int f[MAXN];

int powmod(int a, int p) {
    if (p == 0) return 1;
    if (p == 1) return a;
    int k = powmod(a, p / 2);
    if (p & 1) return (((k * k) % mod) * a) % mod;
    return (k * k) % mod;
}

int inv(int a) {
    return powmod(a, mod - 2);
}

int C(int n, int k) {
    int ans = f[n];
    ans *= inv(f[n - k]);
    ans %= mod;
    ans *= inv(f[k]);
    ans %= mod;
    return ans;
}

signed main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    #ifdef LOCAL
    #else
//        freopen("capitals.in", "r", stdin);
//        freopen("capitals.out", "w", stdout);
    #endif
    f[0] = 1;
    for (int i = 1; i < MAXN; i++) {
        f[i] = (f[i - 1] * i) % mod;
    }
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++) cin >> a[i];
    sort(all(a));
    int ans = 0, cur;
    for (int i = 0; i < n - 1; i++) {
        cur = a[i] * powmod(2, n + i);
        cur %= mod;
        int kek = powmod(2, n - i - 2) * (n - i + 1);
        kek %= mod;
        cur *= kek;
        cur %= mod;
        ans += cur;
        ans %= mod;
    }
    cur = a[n - 1] * powmod(2, n + n - 1);
    cur %= mod;
    ans += cur;
    ans %= mod;
    cout << ans;
}
/*
5
1 10 100 1000 10000
0 1 32
0 2 256
0 3 576
0 4 512
0 5 160
1 1 640
1 2 3840
1 3 5760
1 4 2560
2 1 12800
2 2 51200
2 3 38400
3 1 256000
3 2 512000
6004736
*/


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

using ll = long long;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define ddrep(i, n) for (int i = n; i > 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)
#define ssrep(i, s, t) for (int i = s; i <= t; ++i)

#define rng(a) a.begin(), a.end()
#define rrng(a) a.rbegin(), a.rend()
#define pb push_back
#define eb emplace_back
#define fi first
#define se second

#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))

using pi = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using ld = long double;

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
    os << "(" << p.first << "," << p.second << ")";
    return os;
}

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
    os << "{";
    rep(i, (int)v.size()) {
        if (i)
            os << ",";
        os << v[i];
    }
    os << "}";
    return os;
}

template <typename T, size_t S> void printArray(const T (&array)[S]) {
    for (auto val : array)
        std::cout << val << ", ";
    std::cout << "\n";
}

const int mod = 1e9 + 7;
const int inf = 1e9 + 5;

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

    int h, w; std::cin >> h >> w;
    vector<string> grid(h); rep(i, h) std::cin >> grid[i];
    bool ok = true;
    rep(i, h) rep(j, w) {
        if (grid[i][j] == '.') continue;
        bool _ok = false;
        srep(dy, -1, 2) srep(dx, -1, 2) if (dy*dy + dx*dx == 1) {
            int ny = i+dy, nx = j+dx;
            if (ny < 0 || ny >= h || nx < 0 || nx >= w) continue;
            if (grid[ny][nx] == '#') _ok = true;
        }
        if (!_ok) ok = false;
    }
    std::cout << (ok ? "Yes" : "No") << "\n";
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;

const long long MOD = 1000000007LL;
const long long INF = 1e18;

int GCD(int a, int b){return b == 0 ? a : GCD(b, a % b);}
long long fast_exp(long long base, long long exp, long long mod = MOD) {
    long long tot = 1;
    for(;exp > 0;exp >>= 1) {
       if((exp & 1) == 1) tot = tot * base % mod;
       base = base * base % mod;
    }
    return tot;
}
long long slow_mult(long long base, long long exp, long long mod = MOD) {
    long long tot = 0;
    for(;exp > 0;exp >>= 1){
       if((exp & 1) == 1) tot = (tot + base) % mod;
       base = base * 2 % mod;
    }
    return tot;
}

struct chash {
    static uint64_t splitmix64(uint64_t x) {x += 0x8e3779b97f4a7c15; x = (x ^ (x >> 30)) * 0xbf54876d1ce4e5b9; x = (x ^ (x >> 27)) * 0x94d049bb133111eb; return x ^ (x >> 31);}
    size_t operator()(uint64_t x) const { static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count(); return splitmix64(x + FIXED_RANDOM);}
    size_t operator()(pair<uint64_t,uint64_t> x) const { static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count(); return splitmix64(x.first + FIXED_RANDOM)^(splitmix64(x.second + FIXED_RANDOM) >> 1);}
};

int main(){

    cin.sync_with_stdio(0); cin.tie(0); cout.tie(0);

    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    int n;
    string s; cin >> n >> s;

    if(n % 2 == 0 && s.substr(0, n/2) == s.substr(n/2,n)){
        cout << "Yes";
    } else {
    cout << "No";
    }

    return 0;

}


Measured memory_bytes: 256
import heapq
import sys
N, M = map(int, input().split())
edges = []
for _ in range(M):
    l, r, c = map(int, input().split())
    edges.append((l-1, r-1, c))
edges.sort(reverse = True)
dp = [0]*N
que = [(0, 0)]
for i in range(1, N):
    while len(edges)>0 and edges[-1][0] == i-1:
        e = edges.pop()
        heapq.heappush(que, (dp[i-1]+e[2], e[1]))
    while True:
        if len(que) == 0:
            print(-1)
            sys.exit()
        e = heapq.heappop(que)
        if e[1]>=i:
            dp[i] = e[0]
            heapq.heappush(que, e)
            break
print(dp[-1])

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

int main() {
    int n; cin >> n;
    vector<int> b(n);
    rep(i, n-1) {
        int tmp;
        cin >> tmp;
        b[tmp-1]++;
    }

    rep(i, n) {
        cout << b.at(i) << endl;
    }
}

Measured memory_bytes: 3996
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
typedef long long ll;

using namespace std;

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

	if (n % 2 == 0) {
		cout << n / 2;
	} else {
		cout << n/ 2 + 1;
	}
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
typedef long long ll;
typedef pair<int,int> pii;

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

    vector<int> v(n);
    vector<int> p(n),q(n);
    rep(i,n) cin>>p[i];
    rep(i,n) cin>>q[i];
    rep(i,n) v[i] = i+1;

    int cnt =0;
    int a,b;
    do{
        if(v==p) a=cnt;
        if(v==q) b=cnt; 
        cnt++;
    }while(next_permutation(v.begin(),v.end()));

    cout<<abs(a-b)<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include<stdio.h>
#include<ctype.h>
#include<stdlib.h>
#include<iostream>
#include<algorithm>
#include<string.h>
#include<math.h>
#define pi acos(-1.0)


using namespace std;
int main()
{
    long long int n,m,o,p,q,i,j;

    while(scanf("%lld %lld %lld",&n,&m,&p)==3 )
    {
        q=(m+p)-n;
        if(q<0){q=0;}
        printf("%lld\n",q);
    }


    return 0;
}


Measured memory_bytes: 256
N=int(input())
h=list(map(int,input().split()))
dp=[-1]*N
i=0
s=0
dp[0]=0
while(i<N-1):
  if(i+1<N):
      d=abs(h[i]-h[i+1])+dp[i]
      if(dp[i+1]==-1):
          dp[i+1]=d
      else:
          if(dp[i+1]>d):
              dp[i+1]=d
  if(i+2<N):
      d=abs(h[i]-h[i+2])+dp[i]
      if(dp[i+2]==-1):
          dp[i+2]=d
      else:
          if(dp[i+2]>d):
              dp[i+2]=d

  i+=1            
print(dp[N-1])    
    
   
  


Measured memory_bytes: 14476
#include <stdio.h>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
#include <functional>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef vector<vector<int>> v2int;
typedef vector<ll> vll;
typedef vector<vector<ll>> v2ll;
typedef list<int> liint;
typedef pair<int, int> pint;
const int INF = int(2e9);
const ll LINF = ll(2e9) * ll(2e9);
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T, class C> void chmax(T& a, C b) { a > b ? : a = b; }
template<class T, class C> void chmin(T& a, C b) { a < b ? : a = b; }



int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int A1, A2, A3;
    cin >> A1 >> A2 >> A3;
    if (A1 + A2 + A3 >= 22) {
        cout << "bust" << endl;
    }
    else {
        cout << "win" << endl;
    }

    return 0;
}

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

#define FAST ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define PER(j,n,a) for (int j=n-1;j>=a;j--)
#define REP(i,a,n) for (int i=a;i<n;i++)
#define ALL(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define show(x) cout<<(x)<<endl
#define UM unordered_map
#define PB push_back
#define V vector
#define EPS 1e-8
#define fi first;
#define se second;
typedef unsigned long ul;
typedef long long ll;
typedef string str;
typedef pair<int,pair<int,int> > pii;
/*FIN*/
V<int> dr{-1,0,1,0}, dc{0,1,0,-1};
int h,w,sr,sc,tr,tc,r,c,nr,nc;

bool valid(int i, int j) {
	if(i<0 or i>=h) return 0;
	if(j<0 or j>=w) return 0;
	return 1;
}

int main() {
	FAST;
	cin>>h>>w;
	cin>>sr>>sc;
	sr--;sc--;
	cin>>tr>>tc;
	tr--;tc--;
	str grid[h];
	REP(i,0,h) cin>>grid[i];

	V<V<int> > ans(h,V<int>(w,-1));
	V<V<bool> > vis(h,V<bool>(w,0));
	deque<pii> q;
	pii pr;
	pair<int,int> g;

	q.push_front({0,{sr,sc}});
	while(!q.empty()) {
		pr = q.front();
		q.pop_front();
		g = pr.se;

		r = g.fi;
		c = g.se;

		if(vis[r][c])
			continue;
		vis[r][c]=1;
		ans[r][c] = pr.fi;
		REP(i,0,4) {
			nr = r+dr[i], nc=c+dc[i];
			if(valid(nr,nc)) {
				if(grid[nr][nc]=='#') continue;
				if(!vis[nr][nc])
					q.push_front({ans[r][c],{nr,nc}});
			}
		}
		REP(i,r-2,r+3) {
			REP(j,c-2,c+3) {
				if(valid(i,j)) {
					if(grid[i][j]=='#') continue;
					if(!vis[i][j])
						q.push_back({1+ans[r][c],{i,j}});
				}
			}
		}
	}
	show(ans[tr][tc]);
	return 0;
}



Measured memory_bytes: 9204
#if loc||local
#define _GLIBCXX_DEBUG
#endif

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

#define rep(i,n) for(ll i=0;i<(n);++i)
using ll = int_fast64_t;
using pll = pair<ll,ll>;
constexpr ll INF = 1LL<<60;
constexpr ll MOD = 1e9+7;
template<class T> bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T> bool chmin(T &a,const T &b){if(a>b){a=b;return 1;}return 0;}
#if loc||local
template<class T>void dump(T&& t){cerr<<t<<endl;}
template<class T,class... Ts> void dump(T&& h, Ts&&... t){cerr<<h<<", ";dump(forward<Ts>(t)...);}
#else
void dump(){}
template<class T,class... Ts> void dump(T&& h, Ts&&... t){}
#endif
template<class T> istream &operator>>(istream&is,vector<T>&v){for(auto &elemnt:v)is>>elemnt;return is;}
template<class T,class U> istream &operator>>(istream&is,pair<T,U>&p){is>>p.first>>p.second;return is;}
template<class T> ostream &operator<<(ostream& os,vector<T>const& v){for(auto const& vi:v)os<<vi<<" ";return os;}
template<class T,class U> ostream &operator<<(ostream& os,pair<T,U>const& p){os<<p.first<<","<<p.second;return os;}
template<class T>vector<T> vec(size_t a){return vector<T>(a);}
template<class T, class... Ts>auto vec(size_t a, Ts... ts){return vector<decltype(vec<T>(ts...))>(a, vec<T>(ts...));}

signed main(){

  ll n,x,t;
  cin>>n>>x>>t;
  constexpr auto ceil = [](auto a,auto b){return (a-1)/b+1;};
  cout<<(t*ceil(n,x))<<endl;

}


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

int main() {
  int H, W;
  while (true) {
    cin >> H >> W;
    if (H == 0 && W == 0) break;
    for (int i = 0; i < H; ++i) {
      for (int j = 0; j < W; ++j) {
        cout << "#";
      }
      cout << endl;
    }
    cout << endl;
  }

  return 0;
}


Measured memory_bytes: 3108
#include <iostream>
#include <string>

int main(int argc, char *argv[])
{
  std::string n;
  std::cin >> n;
  const char* cstr = n.c_str();

  int sum = 0;
  for (int i = 0; i < n.size(); ++i) {
    sum += std::stoi(n.substr(i, 1));
  }

  if (sum % 9 == 0) {
    std::cout << "Yes" << std::endl;
  } else {
    std::cout << "No" << std::endl;
  }

  return 0;
}

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

using namespace std;

int main(){
    int n;
    while (cin >> n, n != 0){
        valarray<double> s(n);
        for(int i = 0; i < n; i++) cin >> s[i];
        double m = s.sum() / n;
        s = (s - m) * (s - m);
        cout << fixed << setprecision(4) << sqrt(s.sum()/n) << endl;
    }
}

Measured memory_bytes: 3296
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long LL;
vector<LL> v,sq;
int main() {
	int N;
	cin >> N;
	map<LL, int> A;
	for(int i=0;i<N;i++) {
		int a;
		cin >> a;
		A[a]++;
	}

	for(auto i: A) {
		if(i.second >= 2) {
			v.push_back(i.first);
		}
		if(i.second >=4) {
			sq.push_back(i.first);
		}
	}
	sort(v.begin(),v.end());
	if(v.size() < 2 && sq.size() < 1) {
		printf("0");
	} else {
		LL ans = 0;
		if (v.size() >= 2) ans = max(ans, v[v.size()-1]*v[v.size()-2]);
		if (sq.size() >= 1) ans = max(ans, sq[sq.size()-1]*sq[sq.size()-1]);
		printf("%llu\n", ans);
	}
}

Measured memory_bytes: 6528
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9 + 7;

int N,W;
int v[110],w[110];
ll dp[110][110000];
int main() {
    cin >> N >> W;
    for(int i = 1;i <= N;i++)cin >> w[i] >> v[i];

    for(int i = 1;i <= N;i++){
        for(int j = 0; j <= W;j++) {
            dp[i][j] = dp[i-1][j];
            if (j-w[i] >= 0) dp[i][j] = max(dp[i][j], dp[i-1][j-w[i]] + v[i]);
        }
    }
    cout << dp[N][W] << endl;
}

Measured memory_bytes: 87424
#include "stdio.h"

int main(void)
{
    int memPoint[100001];
    int memNum;
    long point;
    int valiNum;
    int ansPerson;
    int i;
	
	scanf("%d %ld %d", &memNum, &point, &valiNum);

	for (i = 0; i < memNum; i++) {
	    memPoint[i] = 0;
	}
	
    for (i = 0; i < valiNum; i++) {
        scanf("%d",&ansPerson);
        memPoint[ansPerson - 1]++;
    }
    
    for (i = 0; i < memNum; i++) {
        if ((valiNum - memPoint[i]) < point ) {
            printf("Yes\n");
        } else {
            printf("No\n");
        }
    }

	return 0;
}

Measured memory_bytes: 896
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#include <time.h>
#include <stack>
#include <array>
#define popcount __builtin_popcount
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
ll gcd(ll a, ll b){
	if(b==0) return a;
	return gcd(b, a%b);
}
int main()
{
	ll a, b;
	cin>>a>>b;
	cout<<a/gcd(a, b)*b<<endl;
	return 0;
}


Measured memory_bytes: 256
x, k, d = map(int, input().split())

minc = x - d * k
maxc = x + d * k

if (maxc <= 0):
    ans = abs(maxc)
elif (minc >= 0):
    ans = minc
else:
    minc = abs(minc)
    d *= 2
    if (minc % d != 0):
        ans = minc % d
    else:
        ans = 0
    if (maxc % d != 0):
        ans = min(maxc % d, ans)
    else:
        ans = 0
        
print(ans)

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

int main(){
  int N;
  cin >> N;
  map<int,int> m;
  for(int i=0;i<N;i++){
    int a;
    cin >> a;
    if(m.count(a)){
      m.at(a)++;
    }else{
      m[a]=1;
    }
  }
  int64_t ans=0;
  for(auto p:m){
    if(p.first>p.second){
      ans+=p.second;
    }else if(p.first<p.second){
      ans+=p.second-p.first;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 4736
S = input()
T = input()

R1 = [-1] * 26
R2 = [-1] * 26

l = len(S)
ord_a = ord("a")

for i in range(l):
    s = ord(S[i]) - ord_a
    t = ord(T[i]) - ord_a
    if R1[s] < 0:
        R1[s] = t
    else:
        if R1[s] != t:
            print("No")
            exit()
    if R2[t] < 0:
        R2[t] = s
    else:
        if R2[t] != s:
            print("No")
            exit()

print("Yes")


Measured memory_bytes: 3632
import std.stdio, std.string, std.algorithm, std.array, std.range, std.conv,
    std.typecons, std.math, std.container, std.format, std.numeric;

class SegmentTree
{
private:
    long[] xs;
    long size;
public:
    this(long size)
    {
        long i = 1;
        while (i <= size)
        {
            i *= 2;
        }
        this.size = size;
        this.xs = new long[](i * 2);
    }

    void add(long l, long r, long x)
    {
        l += this.size;
        r += this.size;
        while (l < r)
        {
            if (l % 2 == 1)
            {
                xs[l] += x;
                l++;
            }
            l /= 2;
            if (r % 2 == 1)
            {
                xs[r - 1] += x;
                r--;
            }
            r /= 2;
        }
    }

    long get(long i)
    {
        i += this.size;
        long ans = xs[i];
        while (true)
        {
            i /= 2;
            if (i == 0)
            {
                break;
            }
            ans += xs[i];
        }
        return ans;
    }
}

void main(string[] args)
{
    long n, q;
    readf("%d %d\n", &n, &q);

    auto seg = new SegmentTree(n);
    foreach (i; 0 .. q)
    {
        long cmd, s, t, x;
        readf("%d ", &cmd);

        if (cmd == 0)
        {
            readf("%d %d %d\n", &s, &t, &x);
            seg.add(s, t + 1, x);
        }
        else
        {
            readf("%d\n", &x);
            writeln(seg.get(x));
        }
    }

}



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

using namespace std;

typedef long long int ll;
typedef long double lld;
typedef pair<ll, ll> pll;

#define FOR(i, n, m) for(ll (i)=(m);(i)<(n);++(i))
#define REP(i, n) FOR(i,n,0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll) 1e15;

ll N, K;
ll A[200005];

bool check(ll n) {
    ll num = 0;
    REP(i, N) {
        ll t = A[i];

        num += t / n;
        t %= n;
        if (t == 0)
            num--;
    }

    return num <= K;
}

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

    REP(i, N) {
        cin >> A[i];
    }

    ll ans = INF, ng = 0;
    while (abs(ans - ng) > 1) {
        ll mid = (ans + ng) / 2;

        if (check(mid))
            ans = mid;
        else
            ng = mid;
    }

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

Measured memory_bytes: 5188
import math,itertools,fractions,heapq,collections,bisect,sys,queue,copy

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
# def LF(): return [float(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()

def main():
  n,a=LI()
  l=LI()

  dp=[[[0]*51 for _ in range(2501)] for __ in range(n+1)]
  dp[0][0][0]=1
  for i in range(n):
    nd=l[i]
    for j in range(2500):
      for k in range(50):
        ni=i+1
        nj=j
        nk=k

        dp[ni][nj][nk]+=dp[i][j][k]

        nj+=nd
        nk+=1

        if nj>2500:
          continue

        dp[ni][nj][nk]+=dp[i][j][k]

  # print(dp[2][9][1])
  # print(dp[3][9][1])
  # print(dp[4][9][1])

  ans=0
  for j in range(2501):
    for k in range(1,51):
      if j%k!=0:
        continue
      if j//k==a and dp[n][j][k]>0:
        ans+=dp[n][j][k]

  return ans

# main()
print(main())


Measured memory_bytes: 140824
#!/usr/bin/env python3
import sys

MOD = 2019  # type: int

def solve(L: int, R: int):
    if (R - L >= 2019 - 1) or (R % 2019 <= L % 2019):
        print(0)
        return
    else:
        L = L % 2019
        R = R % 2019
        
        smallest = 10000000
        for i in range(L, R):
            for j in range(i+1, R+1):
                calc = (i*j)%2019
                if calc < smallest:
                    smallest = calc
    print(smallest)
    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    L = int(next(tokens))  # type: int
    R = int(next(tokens))  # type: int
    solve(L, R)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i, n) for(ll i = 0; i < n; ++i)
#define repR(i, n) for(ll i = n; i >= 0; ++i)
#define FDS(i, n) for(ll i = 0; i < n; ++i)
#define FDSR(i, n) for(ll i = n; i >= 0; ++i)
#define FOR(i, m, n) for(ll i = m; i < n; ++i)
#define FORR(i, m, n) for(ll i = m;i >= n;--i)
#define VSORT(v) sort(v.begin(), v.end());
#define INF 999999999
#define itn ll
#define ednl endl
using namespace std;
typedef long long ll;template<typename Typell>Typell G_C_D(Typell a, Typell b){if (a < 0) a = -a;if (b < 0) b = -b;while (b != 0) {a %= b;if (a == 0) return b;b %= a;}return a;}template<typename Typell>
Typell G_C_D(const std::vector<Typell> &list){Typell a = list[0];for (size_t i = 1; i < list.size(); ++i) {a = G_C_D(a, list[i]);}return a;}template<typename Typell>Typell L_C_M(Typell a, Typell b) {if( a == 0 && b == 0)return 0;return a / G_C_D(a, b) * b;}
template<typename Typell>Typell L_C_M(const std::vector<Typell> &list){Typell a = list[0];for (size_t i = 1; i < list.size(); ++i) {a = L_C_M(a, list[i]);}return a;}

int main(){
	cin.tie(0);ios::sync_with_stdio(false);
	int a,b;
	cin>>a>>b;
	cout<<a-b+1<<endl;
}

Measured memory_bytes: 892
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define ALL(v) (v).begin(), (v).end()
using ll = long long;
constexpr int INF = 1e9;
constexpr long long LINF = 1e18;
constexpr long long MOD = 1e9 + 7;

constexpr int N = 26;
constexpr int D = 365;

signed main() {
    int tt;
    cin >> tt;
    int c[N];
    rep(i, N) {
        cin >> c[i];
    }
    int s[D][N];
    rep(i, D) {
        rep(j, N) {
            cin >> s[i][j];
        }
    }
    int t[D];
    rep(i, D) {
        cin >> t[i];
        t[i]--;
    }
    int last[N];
    fill(last, last + N, -1);
    int ans = 0;
    rep(i, D) {
        last[t[i]] = i;
        ans += s[i][t[i]];
        rep(j, N) {
            ans -= c[j] * (i - last[j]);
        }
        cout << ans << endl;
    }
    return 0;
}

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

int main()
{
    int n, m; cin>>n>>m;
    vector<vector<int>> s(m);
    for(int i=0; i<m; ++i) {
        int k; cin>>k;
        vector<int> t(k);
        for(auto& e: t) cin>>e;
        s[i]=t;
    }
    vector<int> p(m);
    for(auto& e: p) cin>>e;

    int res=0;
    for(int i=0; i<(1<<n); ++i) {
        int cnt=0;
        for(int j=0; j<m; ++j) {
            int x=0;
            for(int k: s[j]) if ((i>>(k-1))&1) x++;
            if (x%2==p[j]) ++cnt;
        }
        if (cnt==m) ++res;
    }
    cout<<res<<endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

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

		int n = scan.nextInt();
		int a[] = new int[300000];
		int ans[] = new int[300000];

		for (int i = 2; i <= n; i++) {
			a[i] = scan.nextInt();
			ans[a[i]]++;
		}

		for (int i = 1; i <= n; i++) {
			System.out.println(ans[i]);
		}

	}
}

Measured memory_bytes: 60684
#include<iostream>
#include <stdlib.h>
#include <algorithm>
#include <string>
typedef long long int ll;
using namespace std;
int main() {
    int N=0;
	cin >> N;
	ll* A= new ll[N];
	ll result = 0;
	
	for(int i=0; i<N; i++){
		cin >> A[i];
		A[i]=A[i]-(i+1);
	}
	sort(A,A+N);
	ll num=A[N/2];
	for(int i=0; i<N; i++){
		result=result+abs(A[i]-num);
	}
	cout << result << endl;
	return 0;
}

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

int main() {
  string N;
  cin >> N;
  int n = N.size();
  for (int i=0; i<n; i++){
   if (N.at(i)!=N.at(n-i-1)) {
     cout << "No" << endl;break;
   }
   if (i==n-1) cout << "Yes" << endl;
  }
}


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

#define mod 1e9+7
#define ll long long int
#define epsilon 1e-7

int min3(int x, int y, int z){
    if(x<y){
        if(x<z)return x;
        else return z;
    }else{
        if(y<z)return y;
        else return z;
    }
}

int min(int x, int y){
    if(x<y)return x;
    else return y;
}

int main(void){
    int h, w;
    scanf("%d %d", &h, &w);
    int c[10][10];
    int a[h][w];
    for(int i = 0;i < 10;i++){
        for(int j = 0;j < 10;j++){
            scanf("%d", &c[i][j]);
        }
    }
    for(int i = 0;i < h;i++){
        for(int j = 0;j < w;j++){
            scanf("%d", &a[i][j]);
        }
    }
    //j回以下の操作でiからkに変えるのに必要な魔力の最小量
    int dp[10][10][10];
    for(int i = 0;i < 10;i++){
        for(int j = 0;j < 10;j++){
            for(int k = 0;k < 10;k++){
                dp[i][j][k] = mod;
            }
        }
    }
    for(int i = 0;i < 10;i++){
        dp[i][0][i] = 0;
        for(int j = 1;j < 10;j++){
            for(int k = 0;k < 10;k++){
                for(int l = 0;l < 10;l++){
                    dp[i][j][k] = min(dp[i][j][k], dp[i][j-1][l]+c[l][k]);
                }
            }
        }
    }
    int ans = 0;
    for(int i = 0;i < h;i++){
        for(int j = 0;j < w;j++){
            if(a[i][j]!=-1)ans += dp[a[i][j]][9][1];
        }
    }
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 384
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
mod2 = 998244353
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))

s = input()
n = len(s)
l = 0
r = n-1
res = 0
while l < r:
    if s[l] == s[r]:
        l += 1
        r -= 1
    elif s[l] == 'x':
        res += 1
        l += 1
    elif s[r] == 'x':
        res += 1
        r -= 1
    else:
        print(-1)
        break
else:
    print(res)

Measured memory_bytes: 65388
#ifndef LOCAL
#pragma GCC optimize("O3")
#endif
#include "bits/stdc++.h"
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);
typedef long long ll;

int main(){
    fastio
    int n , k ; 
    cin >> n >> k ; 
    if ( (n-1)%(k-1) == 0 ){
    	cout << (n-1)/(k-1) << endl;
    }
    else cout << (n-1)/(k-1) + 1 << endl;
    return 0 ;
}


Measured memory_bytes: 256
n, m, X, Y = map(int, input().split())
x = list(map(int, input().split()))
y = list(map(int, input().split()))

a, b = max(x), min(y)
for val in range(X+1, Y):
  if a < val <= b:
    print("No War")
    exit(0)
print("War")

Measured memory_bytes: 3064
M = int(input())
A = [int(_) for _ in input().split()]
N = 1000
kabu = 0
if A[0] < A[1]:
    kabu, N = divmod(N, A[0])
for a, b, c in zip(A, A[1:], A[2:]):
    if a <= b >= c:
        N += kabu * b
        kabu = 0
    elif a >= b <= c:
        dkabu, N = divmod(N, b)
        kabu += dkabu
N += kabu * A[-1]
print(N)


Measured memory_bytes: 9148
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); i++)
using namespace std;

int main(){
    string str;
    cin >> str;
    int c = (str.size()+1) / 2;
    int c1 = c / 2;
    int c2 = c + c1;
    rep(i, c){
        if(str[i] != str[str.size()-1-i]){
            cout << "No" << endl;
            return 0;
        }
    }
    rep(i, c1){
        if(str[i] != str[c-2-i]){
            cout << "No" << endl;
            return 0;
        }
    }
    for(int i = c; i < c2; i++){
        if(str[i] != str[str.size()-1-i]){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}

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


int main()
{
    int a11, a12, a13, a21, a22, a23, a31, a32, a33;
    int n, bi;
    set<int> sb;
    cin >> a11 >> a12 >> a13 >> a21 >> a22 >> a23 >> a31 >> a32 >> a33;
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> bi;
        sb.insert(bi);
    }
    if (sb.count(a11) && sb.count(a12) && sb.count(a13)) {cout << "Yes" << endl; return 0;}
    if (sb.count(a21) && sb.count(a22) && sb.count(a23)) {cout << "Yes" << endl; return 0;}
    if (sb.count(a31) && sb.count(a32) && sb.count(a33)) {cout << "Yes" << endl; return 0;}
    if (sb.count(a11) && sb.count(a21) && sb.count(a31)) {cout << "Yes" << endl; return 0;}
    if (sb.count(a12) && sb.count(a22) && sb.count(a32)) {cout << "Yes" << endl; return 0;}
    if (sb.count(a13) && sb.count(a23) && sb.count(a33)) {cout << "Yes" << endl; return 0;}
    if (sb.count(a11) && sb.count(a22) && sb.count(a33)) {cout << "Yes" << endl; return 0;}
    if (sb.count(a13) && sb.count(a22) && sb.count(a31)) {cout << "Yes" << endl; return 0;}
    cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

int main() {
    ll x;
    cin >> x;
    ll ans = x/11 * 2;
    x %= 11;
    if (x == 0) ans += 0;
    else if (x <= 6) ans++;
    else ans += 2;
    cout << ans << endl;

    return 0;
}

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

int main(){
    int n,m,x;
    cin>>n>>m>>x;
    vector<int> c(n);
    vector<vector <int> > a(n,vector<int>(m));
    vector<int> und(m,0);
    int ans=0;
    for(int i=0;i<n;i++){
        cin>>c[i];
        ans+=c[i];
        for(int j=0;j<m;j++){
            cin>>a[i][j];
            und[j]+=a[i][j];
        }
    }
    int count=0;
    for(int i=0;i<m;i++){
        if(und[i]>=x) count++;
    }
    if(count!=m){
        cout<<"-1"<<endl;
        return 0;
    }
    for(int i=0;i<(1<<n);i++){
        vector<int> tmp(m,0);
        int money=0;
        for(int j=0;j<n;j++){
            if(i>>j & 1){
                money+=c[j];
                for(int k=0;k<m;k++){
                    tmp[k]+=a[j][k];
                }
            }
        }
        int count=0;
        for(int j=0;j<m;j++){
            if(tmp[j]>=x) count++;
        }
        if(count==m){
            ans=min(ans,money);
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3636
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
		int x = in.nextInt();
		int a = in.nextInt();
		if (x < a)
			System.out.println("0");
		else
			System.out.println("10");
		in.close();
	}
}


Measured memory_bytes: 23764
N,M,C = gets.split.map(&:to_i)
b = gets.split.map(&:to_i)
ans = 0
N.times do 
  a = gets.split.map(&:to_i)
  val = 0
  M.times do |i|
    val += a[i] * b[i]
  end
  val +=  C
  ans += 1 if val > 0
end
p ans

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

#ifdef LOCAL
#include "dump.hpp"
#else
#define dump(...)
#define dumpv(...)
#endif

#define rep(i, n) for (int i = 0; i < (n); i++)
#define mins(x, y) (x = min(x, y))
#define maxs(x, y) (x = max(x, y))
typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
const int MOD = 1e9 + 7;
const int INF = 1001001001;
const ll LINF = 1001002003004005006ll;

void solve() {
  string s;
  cin >> s;
  int n = s.size() + 1;
  vi a(n), b(n);
  s = '>' + s;
  s = s + '<';
  rep(i, n) {
    if (s[i] == '>' && s[i + 1] == '<') b[i] = 1;
  }
  dump(s);
  dump(b);
  rep(i, n) {
    if (b[i]) {
      for (int l = i - 1; 0 <= l; l--) {
        if (s[l + 1] == '>') {
          maxs(a[l], a[l + 1] + 1);
        } else {
          break;
        }
      }
      for (int r = i + 1; r < n; r++) {
        if (s[r] == '<') {
          maxs(a[r], a[r - 1] + 1);
        } else {
          break;
        }
      }
    }
  }
  dump(a);
  ll ans = 0;
  rep(i, n) ans += a[i];
  cout << ans << endl;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  // freopen("temp.1", "r", stdin);
  solve();
  return 0;
}

Measured memory_bytes: 5276
#include<bits/stdc++.h>
using namespace std;
const int MAXN = 1 + 1e5;
typedef long long LL;
typedef pair < int, int > II;
typedef pair < int, II > III;

int n, a[MAXN], f[MAXN];

int main()
{
    #define TASK "ABC"
  //  freopen(TASK".inp","r",stdin);
  //  freopen(TASK".out","w",stdout);
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    cin >> n;
    for (int i = 0; i < n; i++)
        cin >> a[i];
    memset (f , 0x3f , sizeof f);
    f[0] = 0;
    for (int i = 0; i < n; i++){
        for (int j = 1; j <= 2; j++)
            if (i + j < n)
                f[i + j] = min (f[i + j] , f[i] + abs(a[i] - a[i + j]));
    }
    cout << f[n-1];
    return 0;
}




Measured memory_bytes: 1024
package main

import (
	"bufio"
	"fmt"
	"os"
)

func main() {
	var ans string
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanLines)
	sc.Scan()
	s := sc.Text()
	for i := 0; i < len(s); i++ {
		var b byte
		if 'a' <= s[i] && s[i] <= 'z' {
			b = 'A' + s[i] - 'a'
		} else if 'A' <= s[i] && s[i] <= 'Z' {
			b = 'a' + s[i] - 'A'
		} else {
			b = s[i]
		}
		ans += string(b)
	}
	fmt.Println(ans)
}



Measured memory_bytes: 1804
#include<bits/stdc++.h>
using namespace std;
char a[60],b[60];
int z,x,i,n,m;
int main()
{
    gets(a);
    gets(b);
    z=strlen(a);
	x=strlen(b);
    n=min(z,x);
	m=max(z,x);
    for(i=0;i<=n-1;i++)
        printf("%c%c",a[i],b[i]);
    if(z>x)
        for(i=n;i<=m-1;i++)
            printf("%c",a[i]);
    else 
		for(i=n;i<=m-1;i++)
            printf("%c",b[i]);
    printf("\n");
    return 0;
}

Measured memory_bytes: 256
#![allow(non_snake_case, unused_imports)]

// Input
macro_rules! input { (source = $s:expr, $($r:tt)*) => { let mut iter = $s.split_whitespace(); let mut next = || { iter.next().unwrap() }; input_inner!{next, $($r)*} }; ($($r:tt)*) => { let stdin = std::io::stdin(); let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock())); let mut next = move || -> String{ bytes.by_ref().map(|r|r.unwrap() as char).skip_while(|c|c.is_whitespace()).take_while(|c|!c.is_whitespace()).collect() }; input_inner!{next, $($r)*} }; }
macro_rules! input_inner { ($next:expr) => {}; ($next:expr, ) => {}; ($next:expr, $var:ident : $t:tt $($r:tt)*) => { let $var = read_value!($next, $t); input_inner!{$next $($r)*} };}
macro_rules! read_value { ($next:expr, ( $($t:tt),* )) => { ( $(read_value!($next, $t)),* ) }; ($next:expr, [ $t:tt ; $len:expr ]) => { (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>() }; ($next:expr, chars) => { read_value!($next, String).chars().collect::<Vec<char>>() }; ($next:expr, bytes) => { read_value!($next, String).into_bytes() }; ($next:expr, usize1) => { read_value!($next, usize) - 1 }; ($next:expr, $t:ty) => { $next().parse::<$t>().expect("Parse error") }; }

// Module
use std::cmp::{min,max};
use std::collections::{HashSet,HashMap,BTreeMap,VecDeque};

// Functions

// Main
fn main(){
    input!{
        N: usize,
    }
    let mut ans:usize = 1;
    let modulo = 1_000_000_007;
    for i in 1..N+1{
        ans *= i;
        ans %= modulo;
    }
    println!("{}", ans);
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
        using namespace std;
        #define rep(i,a,b) for(int i =a; i<b;++i)
        #define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
        #define endl "\n"
        typedef  long long  int ll;
        const int N = 1e6+5;
        const int mod = 1e9+7;
        ll m,n,y,ans[N];
        int maxs;
        vector< pair<int,int> > adj[N];
        void dfs(int u,int previous_assigned,int v)
        {
            if(previous_assigned>maxs) previous_assigned-=maxs;
            for(auto &x: adj[u])
            {
                if(x.first != v )
                {
                    if(!ans[x.second])
                        ans[x.second] = previous_assigned;
                    previous_assigned++;
                    if(previous_assigned>maxs) previous_assigned-=maxs;
                    dfs(x.first,previous_assigned,u);
                }
            }
        }
int  main()
    {
        IOS;
        int t = 1;
        //cin>>t;
        while(t--)
        {
            cin>>n;
            rep(i,0,n-1)
            {
                int u, v;
                cin>>u>>v;
                adj[u].push_back({v,i+1});
                adj[v].push_back({u,i+1});
            }
            rep(i,1,n+1)
            {
                if(adj[i].size() > maxs)
                    maxs = adj[i].size();
            }
            cout<<maxs<<endl;
            dfs(1,1,-1);
            rep(i,1,n)
            cout<<ans[i]<<" ";
            cout<<endl;
        }
    }


Measured memory_bytes: 29568
package main

import (
	"fmt"
)

func main() {
	var N int
	fmt.Scan(&N)
	A := make([]int, N)
	v1 := 0
	v2 := 0
	for i := 0; i < N; i++ {
		fmt.Scan(&A[i])
		if v2 < A[i] {
			v2 = A[i]
		}
		if v1 < v2 {
			v1, v2 = v2, v1
		}
	}

	for i := 0; i < N; i++ {
		if A[i] == v1 {
			fmt.Println(v2)
		} else {
			fmt.Println(v1)
		}
	}
}


Measured memory_bytes: 6528
using System;
using System.Collections.Generic;//list用
using System.Text;//StringBuilder用
using System.Collections;
using System.Linq;
class Program
{
    static string s;
    static decimal result;

    static void Main()
    {
      Read5();
      var mo=new Modular(1);
      var mo2=new Modular(1);
      for(int i=0;i<s.Length;i++){
        //0なら，ここまでに(0,0)がなければならない。なければここが(0,0)で確定
        if(s[i]=='0'){mo=(mo-mo2)*3+mo2;continue;}
      mo*=3;//(0,0)(0,1)(1,0)で条件を満たす
        mo2*=2;//(1,0)(0,1)のみのパターンを集計しておく
      }
      
      Console.WriteLine(((int)mo).ToString());

    }



    static void Read5()//N行K項
    {
        s = Console.ReadLine();
}
 
    
}

 class Modular
{
    private const int M = 1000000007;
    private long value;
    public Modular(long value) { this.value = value; }
    public static implicit operator Modular(long a)
    {
        var m = a % M;
        return new Modular((m < 0) ? m + M : m);
    }
    public static Modular operator +(Modular a, Modular b)
    {
        return a.value + b.value;
    }
    public static Modular operator -(Modular a, Modular b)
    {
        return a.value - b.value;
    }
    public static Modular operator *(Modular a, Modular b)
    {
        return a.value * b.value;
    }
    private static Modular Pow(Modular a, int n)
    {
        switch (n)
        {
        case 0:
            return 1;
        case 1:
            return a;
        default:
            var p = Pow(a, n / 2);
            return p * p * Pow(a, n % 2);
        }
    }
    public static Modular operator /(Modular a, Modular b)
    {
        return a * Pow(b, M - 2);
    }
    private static readonly List<int> facs = new List<int> { 1 };
    private static Modular Fac(int n)
    {
        for (int i = facs.Count; i <= n; ++i)
        {
            facs.Add((int)(Math.BigMul(facs.Last(), i) % M));
        }
        return facs[n];
    }
    public static Modular Ncr(int n, int r)
    {
        return (n < r)  ? 0
             : (n == r) ? 1
                        : Fac(n) / (Fac(r) * Fac(n - r));
    }
    public static explicit operator int(Modular a)
    {
        return (int)a.value;
    }
}



Measured memory_bytes: 17740
#include <iostream>
#include <cmath>
#include <iomanip>
#include <limits>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
int MAX = 1000000007;

int main() {
    int m,n;
    cin >> m >> n;
    long long ans=m;

    int x=1,logx=0;
    while(x<=n){
        x *= 2;
        logx++;
    }
    x /= 2;
    logx--;
    int a[logx];
    for(int i=0;i<logx;i++){
        a[i] = ans;
        ans *= ans;
        ans %= MAX;
    }
    n -= x;
    if(n == 0){
        cout << ans;
        cout << endl;
        return 0;
    }
    while(true){
        x /= 2;
        logx--;
        if(n>x){
            ans *= a[logx];
            ans %= MAX;
            n -= x;
            break;
        }
    }
    for(int i=0;i<n/4;i++){
        ans *= m*m*m*m;
        ans %= MAX;
    }
    for(int i=0;i<n%4;i++){
        ans *= m;
        ans %= MAX;
    }
    
    cout << ans;
    cout << endl;
}



Measured memory_bytes: 3108
#include <cstdio>
#include <cstdint>
#include <cctype>
#include <cassert>
#include <vector>
#include <string>
#include <algorithm>

void preprocess(const std::string &s, std::string &t) {
  t.clear();
  for (size_t i=s.length(); i--;) {
    t += s[i];
    if (s[i] == '>') --i;
  }
  std::reverse(t.begin(), t.end());
}

bool parse(const std::string &s, size_t &i, int bits, size_t preced=0) {
  static const std::string ops="*+>";
  if (preced == 1) {
    if (s[i] == '(') {
      bool res=parse(s, ++i, bits, 0);
      assert(s[i] == ')');
      ++i;
      return res;
    }
    if (s[i] == '-') {
      return !parse(s, ++i, bits, 1);
    }
    if (islower(s[i])) {
      return (bits>>(s[i++]-'a') & 1);
    }
    return s[i++] == 'T';
  }
  bool lhs=parse(s, i, bits, 1);
  if (i < s.length()) {
    char op=s[i];
    if (!std::count(ops.begin(), ops.end(), op)) return lhs;
    bool rhs=parse(s, ++i, bits, 1);
    if (op == '*') return lhs && rhs;
    if (op == '+') return lhs || rhs;
    if (op == '>') return (!lhs) || rhs;
  }
  return lhs;
}

int testcase_ends() {
  char buf[1024];
  scanf("%s", buf);
  std::string s=buf, t;
  if (s == "#") return 1;
  preprocess(s, t);

  for (int i=0; i<(1<<11); ++i) {
    size_t j=0;
    bool lhs=parse(t, j, i);
    assert(t[j] == '=');
    bool rhs=parse(t, ++j, i);
    if (lhs != rhs) 
      return !printf("NO\n");
  }
  printf("YES\n");
  return 0;
}

int main() {
  while (!testcase_ends()) {}
}



Measured memory_bytes: 2876
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var array = Console.ReadLine().Split().Select(int.Parse).ToArray();
            var N = array[0]; //問題数
            var M = array[1]; //提出回数

            var inputArray = new Input[M];

            for (int i = 0; i < M; i++)
            {
                var a = Console.ReadLine().Split().ToArray();

                var input = new Input(); ;
                input.Number = int.Parse(a[0]);
                input.Result = a[1];

                inputArray[i] = input;
            }

            var correctHash = new HashSet<int>();
            var failureCount = new Dictionary<int, int>();

            foreach (var input in inputArray)
            {
                if (correctHash.Contains(input.Number))
                    continue;

                if (input.Result == "AC")
                {
                    correctHash.Add(input.Number);
                }
                else
                {
                    int value;
                    if (failureCount.TryGetValue(input.Number, out value))
                    {
                        failureCount[input.Number] = ++value;
                    }
                    else
                    {
                        failureCount.Add(input.Number, 1);
                    }
                }
            }

            Console.WriteLine(correctHash.Count + " " + failureCount.Where(f=>correctHash.Contains(f.Key)).Sum(f => f.Value));
        }

        class Input
        {
            public int Number { get; set; }
            public string Result { get; set; }
        }
    }
}


Measured memory_bytes: 28836
#include<bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define mod %
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main(){
    int cnt = 0;
    int a, b, c, x;
    cin >> a >> b >> c >> x;

    for(int i = 0; i <= a; i++){
        for(int j = 0; j <= b; j++){
            for(int k = 0; k <= c; k++){
                if(x == i * 500 + j * 100 + k * 50){
                    cnt++;
                }
            }
        }
    }

    cout << cnt << endl;
}

Measured memory_bytes: 256