akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;

public class Main {
    public static void main(String args[]){
        Scanner stdIn = new Scanner(System.in);
        
        int H = stdIn.nextInt();
        int W = stdIn.nextInt();
        int h = stdIn.nextInt();
        int w = stdIn.nextInt();
        //int n = stdIn.nextInt();
        //int k = stdIn.nextInt();
        //String s = stdIn.next();
        
        System.out.println(H * W - h * W - H * w + h * w);
        //System.out.println();
        //System.out.print();
    }
}


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

#define int long long

int dx[] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[] = {0, 1, 0, -1, 1, 1, -1, -1};
string a, b, c;

signed main() {
    cin >> a >> b >> c;
    cout << a[0] << b[1] << c[2] << endl;
}

Measured memory_bytes: 256
#include<stdio.h>

int main() {
	int war=0;
	int N,M,X=-100,Y=100;
	scanf("%d", &N);
	scanf("%d", &M);
	scanf("%d", &X);
	scanf("%d", &Y);
	int x[100],y[100];
	for (int i=0; i < N; i++) {
		scanf("%d", &x[i]);

	}
	for (int i = 0; i < M; i++) {
		scanf("%d", &y[i]);

	}
	for (int a = 0; a < N; a++)
	{
		if (x[a] >= X) {
			X = x[a];

		}
	}
	for (int c = 0; c < M; c++) {
		if (y[c] <=Y) {
			Y = y[c];
		}
	}
	if (X < Y) {
		war = 1;
	}
	if (war == 1) {
		printf("No War");
	}
	else {
		printf("War");
	}
}

Measured memory_bytes: 128
#include <iostream>

using namespace std;

int main(void) {
    string s;
    cin >> s;

    int leftpos, rightpos;
    bool unbalance = false;
    if (s.length() == 2) {
        if (s[0] == s[1]) {
            unbalance = true;
            leftpos = 1, rightpos = 2;
        }
    } else {
        for (int i = 0; i < s.length() - 2; ++i) {
            if (s[i] == s[i + 1] || s[i + 1] == s[i + 2] || s[i + 2] == s[i]) {
                unbalance = true;
                leftpos = i + 1, rightpos = leftpos + 2;
                break;
            }
        }
    }

    if (unbalance) {
        cout << leftpos << " " << rightpos << endl;
    } else {
        cout << "-1 -1" << endl;
    }
    return 0;
}

Measured memory_bytes: 512
(a,b,c) = gets.split.map {|x| x.to_i}

def min(x,y,z)
  if (x > y)
    if (y > z)
      return z
    else
      return y
    end
  else
    if (x > z)
      return z
    else
      return x
    end
  end
end

if (a % 2 == 0) || (b % 2 == 0) || (c % 2 == 0)
  puts "0"
else
  puts min(a*b, b*c, c*a)
end


Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
const int INF_INT = 2147483647;
const long long INF_LONG = 9223372036854775807;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
     
int main() {
  rep (i, 5) {
    int x;  cin >> x;
    if (x == 0) cout << i + 1 << endl;
  }
}

Measured memory_bytes: 3632
n, k = gets.split.map(&:to_i)
trees = n.times.map{gets.to_i}
trees.sort!
res = 1000000000
for i in 0..(n-k) do
  if (trees[i+k-1] - trees[i]) < res
    res = trees[i+k-1] - trees[i]
  end
end
puts res

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

int main(void){
    int N, Y;
    cin >> N >> Y;
    int n10000, n5000, n1000;
    for(int n10000 = Y/10000; n10000>=0; --n10000){
        for(int n5000 = (Y-10000*n10000)/5000; n5000>=0; --n5000){
            n1000 = (Y-10000*n10000-5000*n5000)/1000;
            if(n10000+n5000+n1000==N){
                cout << n10000 << " " << n5000<<  " " << n1000<< endl;
                return(0);
            }
            else if(n10000+n5000+n1000>N){
                break;
            }
        }
    }
    cout << "-1 -1 -1" << endl;
}


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

int main(void){
	int n;
	cin >> n;
	vector<pair<int, int>> a(n);
	for(int i = 0; i < n; ++i){
		int tmp;
		cin >> tmp;
		a[i] = make_pair(tmp, i+1);
	}
	sort(a.begin(), a.end());
	for(int i = 0; i < n; ++i){
		if(i != 0) cout << " ";
		cout << a[i].second;
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 1664
#include <vector>
#include <iostream>
#include <cmath>
#include <iomanip>
#include <string>
#include <utility>
#include <stack>
#include <numeric>
#include <random>
#include <algorithm>
#include <queue>
#include <functional>
#include <iterator>
#include <list>
#include <unordered_map>
#include <deque>
#include <math.h>
#include <tgmath.h>
using namespace std;

#define rep(i, b, e) for(i = b; i < e; ++i)
#define repr(i, b, e) for (i = b; i >= e; --i)
#define ull unsigned long long int
#define ll long long int
#define pint pair<int, int>

#define M_DEBUG 1
#define PI 3.141592653589793

#define E '\n'

#define print(x) cout << (x) << endl;
#define printa(x,n) for(int i = 0; i < n; i++){ cout << (x[i]) << "\n";}
#define INF (1e18)

const ll MAX = 1000000000;
const ll MOD = 1e9 + 7;

ll a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z;

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

ll aabs(ll a) {
    if (a < 0) return -a;
    return a;
}

//fast power
ll calc(ll a, ll b) {
    if (b == 0) return 1;
    else if (b % 2 == 0) {
        ll d = calc(a, b / 2);
        return (d * d) % MOD;
    }
    else return (a * calc(a, b - 1)) % MOD;
}

//fast combination
ll comb(ll n, ll a) {
    ll b = 1, c = 1;
    for (ll i = 1; i <= a; ++i) {
        b = b * i % MOD;
        c = c * (n - i + 1) % MOD;
    }

    return c * calc(b, MOD - 2) % MOD;
}

ll comb2(ll a) {
    ll b = a / 2;
    if (a % 2) {
        b = (a - 1) / 2;
        return (b * a);
    }
    return (b * (a - 1));
}

int kyotsu(string ss, int st, int ed, string ss2) {
    int ans = 0;
    for ( int i = st; i < ed; ++i ) {
        if (i - st >= ss2.size()) return ans;
        if (ss[i] == ss2[i - st] || ss[i] == '?') {
            ans++;
        } else {
            return -1;
        }
    }
    return ans;
}

int main(void) {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cin >> a;

    b = 0;
    b += (a / 500) * 1000;
    a %= 500;
    b += ( a / 5 ) * 5;

    cout << b << endl;;

    
    return 0;
}


Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))
bit_acc = [[0 for i in range(21)] for j in range(n+1)]
for i in range(1,n+1):
    k = format(a[i-1], '021b')
    for j in range(len(k)):
        if k[j] == "1":
            bit_acc[i][j] = bit_acc[i-1][j] + 1
        else:
            bit_acc[i][j] = bit_acc[i-1][j]
right = 1
left = 0
ans = 0
while left <= n:
    flag = True
    for j in range(21):
        if bit_acc[right][j] - bit_acc[left][j] >= 2:
            #print("l {}, r {}".format(left, right))
            ans += right - 1 - left
            left += 1
            flag = False
            break
    if flag:
        if right < n:
            right += 1
        else:
            #print("l {}, r {}".format(left, right))
            ans += right - left
            left += 1
print(ans)


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

using namespace std;
using ll = long long;

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

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

    ll sum = 0;
    for (int a = 1; a <= k; a++) {
        for (int b = 1; b <= k; b++) {
            for (int c = 1; c <= k; c++) {
                sum += gcd(gcd(a, b), c);
            }
        }
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
int main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  int n;
  std::cin >> n;
  std::vector<int> a(n), sz(n), tag(n); 
  std::vector<std::vector<int>> g(n);
  std::vector<long long> ans(n);
  std::function<long long(int)> calc = [&](int x) {
    return 1ll * x * (x + 1) / 2;
  };
  for (int i = 0; i < n; ++i) {
    std::cin >> a[i];
    --a[i];
  }
  for (int i = 0; i < n; ++i)
    ans[i] = calc(n);  
  for (int i = 1; i < n; ++i) {
    int u, v;
    std::cin >> u >> v;
    --u;
    --v;
    g[u].push_back(v);
    g[v].push_back(u);
  }
  std::function<void(int, int)> dfs = [&](int u, int fa) {
    sz[u] = 1;
    int lst = tag[a[u]];
    for (auto v : g[u]) {
      if (v == fa) 
        continue;
      int pre = tag[a[u]];
      dfs(v, u);
      sz[u] += sz[v];
      ans[a[u]] -= calc(sz[v] - (tag[a[u]] - pre));
    }
    tag[a[u]] = sz[u] + lst;
  };   
  dfs(0, -1);
  for (int i = 0; i < n; ++i)
    ans[i] -= calc(n - tag[i]);

  for (int i = 0; i < n; ++i)
    std::cout << ans[i] << "\n";
  return 0;
}

Measured memory_bytes: 43036
#include <bits/stdc++.h>
//#define int long long

using namespace std;
using LL = long long;
using P = pair<int, int>;
using Tapris = tuple<int, int, int>;

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

#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()

const int INF = (int)1e9;
const LL INFL = (LL)1e15;
const int MOD = 1e9 + 7;

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

template <typename Monoid>
class SegmentTree{
    private:
        using Func = function<Monoid(Monoid, Monoid)>;
        int n; // 最下段の数
        vector<Monoid> segmentTree; // セグ木本体
        const Func f; // 二項演算
        const Monoid identityElement; // モノイドの単位元

    public:
        SegmentTree(vector<Monoid> vec, const Func f, const Monoid identityElement);
        void Update(int idx, Monoid val);
        Monoid Query(int a, int b, int k = 0, int l = 0, int r = -1); // 使う時は区間[a, b)のみ指定すれば良い
        Monoid GetNum(int idx); // 元の要素番号から最下層の値を取得
};

template <typename Monoid>
SegmentTree<Monoid>::SegmentTree(vector<Monoid> vec, const Func f, const Monoid identityElement) :
    f(f), identityElement(identityElement)
{
    int sz = vec.size();
    n = 1;
    while(n < sz) n *= 2;
    segmentTree.assign(2*n-1, identityElement);
    for(int i = 0; i < sz; i++) segmentTree[i+n-1] = vec[i];
    for(int i = n-2; i >= 0; i--) segmentTree[i] = f(segmentTree[2*i+1], segmentTree[2*i+2]);
}

template <typename Monoid>
void SegmentTree<Monoid>::Update(int idx, Monoid val){
    idx += n - 1;
    segmentTree[idx] = val;
    while(idx > 0){
        idx = (idx - 1) / 2;
        segmentTree[idx] = f(segmentTree[2*idx+1], segmentTree[2*idx+2]);
    }
}

template <typename Monoid>
Monoid SegmentTree<Monoid>::Query(int a, int b, int k, int l, int r){
    if(r < 0) r = n;

    if(r <= a || b <= l) return identityElement;

    if(a <= l && r <= b) return segmentTree[k];

    int vl = Query(a, b, 2*k+1, l, (l+r)/2);
    int vr = Query(a, b, 2*k+2, (l+r)/2, r);
    return f(vl, vr);
}

template <typename Monoid>
Monoid SegmentTree<Monoid>::GetNum(int idx){
    return segmentTree[idx+n-1];
}

/*************** using variables ***************/
int n, q;
/**********************************************/

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

    cin >> n >> q;
    vector<int> a(n, 0);
    SegmentTree<int> st(a, [](int a, int b){return a + b;}, 0);
    REP(i, q){
        int comp, x, y;
        cin >> comp >> x >> y;
        if(comp == 0) st.Update(x-1, st.GetNum(x-1) + y);
        else cout << st.Query(x-1, y) << endl;
    }
}



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

  var room = new Array(4);
  for (i = 0; i < 4; i++) {
    room[i] = new Array(3);
    for (j = 0; j < 3; j++) {
      room[i][j] = new Array(10);
      for (k = 0; k < 10; k++) {
        room[i][j][k] = 0;
      }
    }
  }

  i = 1
  while (input[i] != 0) {
    arr = input[i].split(" ");
    b = arr[0] - 1;
    f = arr[1] - 1;
    r = arr[2] - 1;
    v = parseInt(arr[3], 10);

    room[b][f][r] += v;
    if (room[b][f][r] < 0) {
      room[b][f][r] = 0;
    } else if (room[b][f][r] > 9) {
      room[b][f][r] = 9;
    }
    i++;
  }

  for (i = 0; i < 4; i++) {
    for (j = 0; j < 3; j++) {
      console.log(" " + room[i][j].join(" "));
    }
    if (i != 3) {
      console.log("####################");
    }
  }
});

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

int main(){
    using namespace std;
    unsigned long N;
    cin >> N;
    vector<pair<unsigned long, unsigned long>> items(N);
    for(auto&& [W, V] : items)cin >> V >> W;
    items.emplace(begin(items), 0, 0);
    unsigned long B{min(N + 1, 512UL)};
    vector<vector<pair<unsigned long, unsigned long>>> npsk(B);
    npsk[0].emplace_back(0, 0);
    for(unsigned long i{1}; i < B; ++i){
        unsigned long n{size(npsk[i / 2])};
        npsk[i].reserve(2 * n);
        copy(begin(npsk[i / 2]), end(npsk[i / 2]), back_inserter(npsk[i]));
        const auto& [W, V] = items[i];
        for(unsigned long j{0}; j < n; ++j)npsk[i].emplace_back(npsk[i][j].first + W, npsk[i][j].second + V);
        sort(begin(npsk[i]), end(npsk[i]));
        unsigned long loc_max{0};
        npsk[i].erase(remove_if(begin(npsk[i]) + 1, end(npsk[i]), [&loc_max](auto t){
            bool ret{loc_max >= t.second};
            loc_max = max(loc_max, t.second);
            return ret;
        }), end(npsk[i]));
    }
    unsigned long Q;
    cin >> Q;
    for(unsigned long i{0}, v, L; i < Q; ++i){
        cin >> v >> L;
        if(v < B){
            cout << upper_bound(begin(npsk[v]), end(npsk[v]), pair<unsigned long, unsigned long>{L + 1, 0})[-1].second << endl;
        }else{
            vector<pair<unsigned long, unsigned long>> tap{{0, 0}};
            unsigned long j{v};
            for(; j * j > v; j >>= 1){
                const auto& [W, V] = items[j];
                unsigned long n{size(tap)};
                for(unsigned long k{0}; k < n; ++k)if(tap[k].first + W <= L)tap.emplace_back(tap[k].first + W, tap[k].second + V);
            }
            sort(begin(tap), end(tap));
            unsigned long loc_max{0};
            tap.erase(remove_if(begin(tap) + 1, end(tap), [&loc_max](auto t){
                bool ret{loc_max >= t.second};
                loc_max = max(loc_max, t.second);
                return ret;
            }), end(tap));
            auto it = end(npsk[j]) - 1;
            unsigned long ans{0};
            for(const auto& [W, V] : tap){
                while(it -> first + W > L)--it;
                ans = max(ans, it -> second + V);
            }
            cout << ans << endl;
        }
    }
    return 0;
}

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

#ifdef NON_SUBMIT
#define TEST(n) (n)
#define tout cerr
#else
#define TEST(n) ((void)0)
#define tout cin
#endif

using namespace std;

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);
	TEST(freopen("input.txt","r",stdin));
	TEST(freopen("output.txt","w",stdout));
	TEST(freopen("debug.txt","w",stderr));
	int H, N;
	for(cin>>H>>N;N--;) {
		int a;
		cin>>a;
		H-=a;
	}
	cout<<(H<=0 ? "Yes\n":"No\n");
	return 0;
}

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

const int MOD = 1e9 + 7;

map < long long , int > m;
ll getAns(long long dir){
    if(m[dir])
        return m[dir];
    return m[dir] = (getAns(dir - 2 >> 1) + getAns(dir - 1 >> 1) + getAns(dir >> 1)) % MOD;
}

int main(){
    m[0] = 1;
    m[1] = 2;
    long long N;
    cin >> N;
    cout << getAns(N);
    return 0;
}

Measured memory_bytes: 256
import core.bitop, std.algorithm, std.ascii, std.bigint, std.conv, std.math,
    std.functional, std.numeric, std.range, std.stdio, std.string, std.random,
    std.typecons, std.container, std.format, std.datetime;

// dfmt off
T lread(T = long)(){return readln.chomp.to!T();}
T[] lreads(T = long)(long n){return generate(()=>readln.chomp.to!T()).take(n).array();}
T[] aryread(T = long)(){return readln.split.to!(T[])();}
void scan(TList...)(ref TList Args){auto line = readln.split();
foreach (i, T; TList){T val = line[i].to!(T);Args[i] = val;}}
alias sread = () => readln.chomp();enum MOD = 10 ^^ 9 + 7;
alias PQueue(T, alias less = "a<b") = BinaryHeap!(Array!T, less);
// dfmt on

void main()
{
    real L = lread();
    writefln("%.10f", L ^^ 3 / 3 ^^ 3);
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
#define INF 1000000010
#define EPS 1e-9
#define F first
#define S second

#define debug(x) cout<<x<<endl;
#define repi(i,x,n) for(int i=x;i<n;i++)
#define rep(i,n) repi(i,0,n)
#define lp(i,n) repi(i,0,n)
#define repn(i,n) for(int i=n;i>=0;i--)
#define int long long
#define endl "\n"

typedef pair<int,int> PII;
typedef pair<int,string> PIS;
typedef pair<string,int> PSI;


signed main(){
  cin.tie(0);	
  //ios::sync_with_stdio(false);
  int n;
  cin>>n;
  queue<int> q;
  queue<int> q2;
  string s;
  cin>>s;
  rep(i,n){
    q.push(s[i]-'1');
  }
  while(q.size() > 1){
    int cnt=q.size();
    if(cnt%2==0){
      int nex=q.front();
      q.pop();
      while(!q.empty() ){
	q2.push(abs(nex-q.front() ) );
	nex=q.front();
	q.pop();
      }
      swap(q,q2);
    }else{
      int nex=q.front();
      q.pop();
      q.pop();
       while(!q.empty() ){
	q2.push(abs(nex-q.front() ) );
	nex=q.front();
	q.pop();
	if(!q.empty() ){
	  q.pop();
	}
       }
       swap(q,q2);
    }
  }	
  cout<<q.front()<<endl;
  return 0;
}


Measured memory_bytes: 9988
def main():
    H, W = map(int, input().split())
    N = int(input())
    A = list(map(int, input().split()))
    h, w = 0, 0
    ans = [[0]*W for _ in range(H)]
    for i in range(N):
        for k in range(A[i]):
            ans[h][w] = i+1
            if (h % 2 == 1 and w == 0) or (h % 2 == 0 and w == W-1):
                h += 1
            else:
                if h % 2 == 0:
                    w += 1
                else:
                    w -= 1
    for s in ans:
        print(" ".join(map(str, s)))


if __name__ == "__main__":
    main()


Measured memory_bytes: 41200
#include <iostream>
#include <vector>
#include <array>
#include <list>
#include <set>
#include <map>
#include <utility>
#include <string>
#include <sstream>
#include <algorithm>
#include <random>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cmath>
#include <cassert>
#include <climits>

using namespace std;

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

	vector<int> cnum(256);

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

	uint64_t ret = 1;
	for (int i = 0; i < 256; i++) {
		ret *= (cnum[i] + 1);
		ret %= 1000000007;
	}

	cout << (ret - 1) << endl;

	return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <algorithm>

using namespace std;

int main() {
  int n, h = 1;

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

  sort(d, d+n);

  for (int i = 0; i < n-1; i++) if (d[i] < d[i+1]) h++;

  cout << h << endl;

  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll mod=1000000007;
ll power(ll x, ll  y)  {  ll res = 1;x = x % mod;y=y%mod;while (y > 0)  {  if (y & 1)  res = ((res%mod)*(x%mod)) % mod;  
y = y>>1;x = ((x%mod)*(x%mod)) % mod;  }  return res%mod;  }  
  
ll l[3000][3000],r[3000][3000],u[3000][3000],d[3000][3000],A[3000][3000];
int main(){
    ll a,b;cin>>a>>b;
    for(int i=1;i<=a;i++){
    for(int j=1;j<=b;j++){
    	char c;cin>>c;
    	if(c=='#')A[i][j]=0;
    	else A[i][j]=1;
    }}
    
    
    
    /// left;
    for(int i=1;i<=a;i++)
    {
    	for(int j=1;j<=b;j++)
    	{
    		if(A[i][j]==0)l[i][j]=0;
    		else{
    			if(l[i][j-1]==0)l[i][j]=1;
    			else l[i][j]=1+l[i][j-1];}
    			
}}
    
    /// right
    for(int i=1;i<=a;i++)
    {
    	for(int j=b;j>=1;j--)
    	{
    		if(A[i][j]==0)r[i][j]=0;
    		else{
    			if(r[i][j+1]==0)r[i][j]=1;
    			else r[i][j]+=1+r[i][j+1];}
    	}
    }
    
    /// down
    for(int i=1;i<=b;i++)
    {
    	for(int j=1;j<=a;j++)
    	{
    		if(A[j][i]==0)d[j][i]=0;
    		else{
    			if(d[j-1][i]==0)d[j][i]=1;
    			else d[j][i]+=1+d[j-1][i];}
    	}
    }
    
    
    /// up
    for(int i=1;i<=b;i++)
    {
    	for(int j=a;j>=1;j--)
    	{
    		if(A[j][i]==0)u[j][i]=0;
    		else{
    			if(u[j+1][i]==0)u[j][i]=1;
    			else u[j][i]+=1+u[j+1][i];}
    	}
    }
    
    ll mx=0;
    
    for(int i=1;i<=a;i++)
    {
    	for(int j=1;j<=b;j++)
    	{
    		if(l[i][j]+r[i][j]+d[i][j]+u[i][j]-3>mx)mx=l[i][j]+r[i][j]+d[i][j]+u[i][j]-3;
    	}
    }
    cout<<mx<<endl;
    
}
    
    
   

    


Measured memory_bytes: 241536
n, K = map(int, input().split())
a = list(map(int, input().split()))
s = [[0]*n for _ in range(100)]
s[0] = a

tmp = [0] * (n+1)
for i in range(K):
    if sum(s[i]) == n**2:
        print(*([n] * n))
        break
    for j in range(n):
        x = s[i][j]
        l, r = max(0, j-x), min(n, j+x+1)
        tmp[l] += 1
        tmp[r] -= 1
    
    for j in range(n):
        tmp[j+1] = tmp[j] + tmp[j+1]
        s[i+1][j] += tmp[j]
    tmp = [0] * (n+1)
else: print(*s[K])


Measured memory_bytes: 291596
#include <iostream>

int main() {
  size_t A, B, K;

  std::cin >> A >> B >> K;

  for (size_t i=0; i<K; i++) {
    if (i%2 == 0) {
      A -= A%2;
      A /= 2;
      B += A;
    } else {
      B -= B%2;
      B /= 2;
      A += B;
    }
  }

  std::cout << A << ' ' << B << std::endl;

  return 0;
}


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

int main()
{
    ll N, M;
    cin >> N >> M;

    vector<ll> A(M);
    for (size_t i = 0; i < M; i++)
    {
        cin >> A[i];
    }

    for (size_t i = 0; i < M; i++)
    {
        N -= A[i];
    }

    if (N < 0)
    {
        cout << "-1" << endl;
    }
    else
    {
        cout << N << endl;
    }
}


Measured memory_bytes: 3668
#include <bits/stdc++.h>
#define fast_io()                \
    ios::sync_with_stdio(false); \
    std::cin.tie(0);
typedef long long ll;
typedef long double ld;
using namespace std;

int main() {
    int n, m;
    cin >> n >> m;
    if (n == m)
        cout << "Yes";
    else
        cout << "No";

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define double long double
#define rep(i, a, n) for(int i = (int)(a);(i) < (int)(n);++(i))
#define repe(i, a, n) for(int i = (int)(a);(i) <= (int)(n);++(i))
#define repif(i, a, x) for(int i = (int)(a);(x);++(i))
#define repr(i, a, n) for(int i = ((int)(a)-1);(i) >= (int)(n);--(i))
#define reper(i, a, n) for(int i = (int)(a);(i) >= (int)(n);--(i))
#define SZ(x) ((int)(x).size())
#define ALL(x) begin(x), end(x)
#define CEIL(x) ((int)ceil(((double)x)))
#define POW(x, y) ((int)pow(x, y))
#define UNIQUE(x) (x).erase(unique(ALL((x))), end(x))
#define gcd(x, y) __gcd(x, y)
#define lcm(x, y) ((x)/gcd(x,y)*(y))
#define isin(x, l, r) ((l) <= (x) and (x) < (r))
#define fcout cout << fixed << setprecision(10)
#define rcout(n) cout << right << setw(n)
#define pb push_back
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define PI (acos(-1))
#define EPS (1e-10)
#define INF LLONG_MAX
#define INF32 INT32_MAX
#define MOD 1000000007LL
using namespace std;
using VI = vector<int>;
using PII = pair<int, int>;
using TIII = tuple<int, int, int>;
using VPII = vector<PII>;
using VTIII = vector<TIII>;
using Complex = complex<double>;
template<typename T, template<typename> typename C = less> using PQ = priority_queue<T, vector<T>, C<T>>;
template<typename T> bool chmax(T& a, const T& b, bool t = false){ if(a<b or (t and a == b)){ a=b; return true; } return false; }
template<typename T> bool chmin(T& a, const T& b, bool t = false){ if(a>b or (t and a == b)){ a=b; return true; } return false; }


int a, b, k;


signed main(){
    cin >> a >> b >> k;

    if(a > k) cout << a-k << ' ' << b << endl;
    else if(b > k-a) cout << 0 << ' ' << b-(k-a) << endl;
    else cout << 0 << ' ' << 0 << endl;

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <string.h>
#include <map>

using namespace std;

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

int main()
{
    int N, i, ans = 0;
    string s;
    map<string, int> mp;

    scanf("%d\n", &N);

    REP(i, N)
    {
        cin >> s;
        (mp[s])++;
    }

    scanf("%d\n", &N);

    REP(i, N)
    {
        cin >> s;
        (mp[s])--;
    }

    for (auto itr = mp.begin(); itr != mp.end(); ++itr)
    {
        if (itr->second > ans)
            ans = itr->second;
    }

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

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

int main(){
  string str1,str2;
  int testnum;

  cin>>testnum;
  int t=0;
  while(t<testnum&&cin>>str1>>str2){
    string sumstr;
    reverse(str1.begin(),str1.end());
    reverse(str2.begin(),str2.end());

    unsigned size=min(str1.size(),str2.size());
    unsigned i;
    unsigned carry=0;
    for(i=0;i<size;++i){
      unsigned sum=str1[i]+str2[i]+carry-'0'*2;
      sumstr.push_back(sum%10+'0');
      carry=sum/10;
    }

    string large=(str1.size()>str2.size())?str1:str2;
    for(;i<large.size();++i){
      unsigned sum=large[i]+carry-'0';
      sumstr.push_back(sum%10+'0');
      carry=sum/10;
    }

    if(carry) sumstr.push_back(carry+'0');
    reverse(sumstr.begin(),sumstr.end());
    
    if(sumstr.size()<=80)
      cout<<sumstr<<endl;
    else
      cout<<"overflow"<<endl;
    t++;
  }
}

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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

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

int main()
{
    string str;
    cin >> str;
    list<char> li;
    for (char c : str)
    {
        li.push_back(c);
    }
    int Q;
    cin >> Q;
    bool ref = false;
    rep(i, Q)
    {
        int op;
        cin >> op;
        if (op == 1)
        {
            ref = !ref;
            // reverse(li.begin(), li.end());
        }
        else if (op == 2)
        {
            int f;
            char c;
            cin >> f >> c;
            if (f == 1)
            {
                if (!ref)
                    li.push_front(c);
                else
                    li.push_back(c);
            }
            else if (f == 2)
            {
                if (!ref)
                    li.push_back(c);
                else
                    li.push_front(c);
            }
        }
    }
    if (!ref)
    {
        for (auto p = li.begin(); p != li.end(); p++)
        {
            cout << *p;
        }
    }
    else
    {
        for (auto p = li.rbegin(); p != li.rend(); p++)
        {
            cout << *p;
        }
    }

    cout << endl;
    return 0;
}


Measured memory_bytes: 9984
import java.io.*;
import java.util.*;
import static java.lang.System.*;
import static java.lang.Math.*;

public class Main
{
	public static void main(String []args)throws IOException
	{
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		String []s=br.readLine().split(" ");
		int a = Integer.parseInt(s[0]);
		int b = Integer.parseInt(s[1]);
		
		if(a!=b)
		{
			if(a>b)
			{			
				for(int i=1;i<=a;i++)
					out.print(b);
				out.println();
			}
			else
			{			
				for(int i=1;i<=b;i++)
					out.print(a);
				out.println();
			}
			
		}
		else
			for(int i=1;i<=a;i++)
					out.print(b);
				out.println();
	}
}




Measured memory_bytes: 21204
import java.util.List;
import java.util.ArrayList;
import java.util.Scanner;
import java.lang.Math;

class Main {
    
    public static void main(String[] args){
        Scanner scanner = new Scanner(System.in);
        int k = scanner.nextInt();
        scanner.close();
        List<Integer> list = new ArrayList<>();
        for(int i=1; i<=k; i++){
            for(int j=1; j<=k; j++){
                list.add(gcd(i,j));
                // for(int l=1; l<=k; l++){
                //     List<Integer> inputList = new ArrayList<>();
                //     inputList.add(i);
                //     inputList.add(j);
                //     inputList.add(l);
                //     list.add(inputList);
                // }
            }
        }
        int sum = 0;
        for (Integer val : list) {
            for(int i=1; i<=k; i++){
                sum += gcd(val, i);
            }
        }
        
        // int sum = 0;
        // for(int i=0; i<Math.pow(k, 3); i++){
        //     List<Integer> input = list.get(i);
        //     sum += gcd(input.get(0),input.get(1),input.get(2));
        // }
        System.out.print(sum);

    }    

    public static int gcd(int val1, int val2){
        if(val2==0){
            return val1;
        }else{
            return gcd(val2, val1%val2);
        }
    }

    public static int gcd(int... val){
        int len = val.length;
        int g = gcd(val[0], val[1]);
        for(int i=1; i<len-1; i++){
            g = gcd(g, val[i+1]);
        }
        return g;
    }
}

Measured memory_bytes: 28392
#include <bits/stdc++.h>
using namespace std;
struct ios_accelerate { ios_accelerate() { ios::sync_with_stdio(false); cin.tie(nullptr); } } CALL;

#define REP(i, n) for(auto (i) = (n)*0; (i) < (n); (i)++)
#define RNG(i, a, b) for(auto (i) = (a); (i) < (b); (i)++)
#define RBF(i, v) for(auto& (i) : (v))
#define ALL(x) (x).begin(), (x).end()

using LL = long long;
using UL = unsigned;
using ULL = unsigned long long;
template<typename T> using V = vector<T>;
template<typename T> using VV = vector<vector<T>>;
template<typename T> using P = pair<T, T>;

const double PI = 3.141592653589793;
const int MOD = 1000000007;
const LL INF64 = static_cast<LL>(1e18) + 2;
const int INF = static_cast<int>(1e9) + 2;

template<typename T> inline void upsort(vector<T>& x) { sort(x.begin(), x.end()); }
template<typename T> inline void downsort(vector<T>& x) { sort(x.begin(), x.end(), greater<T>()); }
template<typename T> inline void col(T x) { cout << x << '\n'; }
template<> inline void col(double x) { cout << fixed << setprecision(12) << x << '\n'; }

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

	double ans = ceil(n / 2.0) / n;
	col(ans);
	return 0;
}

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

int main(){
	int n;
	cin >> n;
	vector<int> a(n+1);
	for (int i = 1; i <= n; i++)
		cin >> a[i];

	vector<int> res(n+1);
	for (int i = n; 0 < i; i--){
		int cnt = 0;
		for (int j = 2*i; j <= n; j+=i){
			cnt ^= res[j];
		}
		res[i] = cnt^a[i];
	}	
	vector<int> x;
	for (int i=1; i <= n; i++){
		if (res[i]){
			x.push_back(i);
		}
	}
	cout << x.size() << endl;
	for (int i = 0; i<x.size(); i++){
		cout << x[i] << ' ';
	}
	cout << endl;
}

Measured memory_bytes: 5440
#include <bits/stdc++.h>
  
using namespace std;
  
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define pb push_back
#define all(r) r.begin(),r.end()
#define rall(r) r.rbegin(),r.rend()
#define fi first
#define se second
  
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
 
const int INF = 1e9;
const ll MOD = 1e9 + 7;
double EPS = 1e-8;

//#define DEBUG_MODE
#ifdef DEBUG_MODE
#define dump(x) cout << #x << " : " << x << endl
#define LINE cout << "line : " << __LINE__ << endl
#define dumpV(v) cout << #v << " : ["; for(auto& t : v) cout << t << ", "; cout<<"]" << endl;
#define STOP assert(false);
#else
#define dump(x) ;
#define LINE 	;
#define dumpV(v);
#define STOP 	;
#endif

namespace std{
  template<class S,class T>
  ostream &operator <<(ostream& out,const pair<S,T>& a){
    out<<'('<<a.fi<<", "<<a.se<<')';
    return out;
  }
}

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

int H, W;
int d[1010][1010];
auto isOutOfRange = [](int h, int w, int H, int W) {
	return h < 0 || h >= H || w < 0 || w >= W;
};

vi memo; //-1:non-used, -2:ok, else:ikisaki 

vector<int> es[1010*1010];


int dfs(int now) {
	if(memo[now] != -1) return memo[now];
	int ret = -1;
	for(auto& to : es[now]) {
		int tmp = dfs(to);
		if(ret == -1) ret = tmp;
		else if(ret != tmp) {
			return memo[now] = -2;
		}
	}
	return memo[now] = (ret == -1 ? now : ret);
}

int main(){
	cin >> H >> W;
	rep(i, H) rep(j, W) cin >> d[i][j];

	memo.clear();
	memo.resize(H*W, -1);
	
	rep(y, H) rep(x, W) {
		int now = y * W + x;
		rep(i, 4) {
			int nx = x + dx[i], ny = y + dy[i];
			if(isOutOfRange(ny, nx, H, W)) continue;
			int nxt = ny * W + nx;
			if(d[y][x] > d[ny][nx]) es[now].pb(nxt);
		}
	}
	dump(H);dump(W);
	dump(es[1].size());
	LINE;
	// rep(i, H) rep(j, W) {
	// 	dump(i*W+j);
	// 	dfs(i*W+j);
	// }
	for(int i = H -1; i >= 0; i--) {
		for(int j = W - 1; j >= 0; j--) {
			dump(i*W+j);
			dfs(i*W+j);
		}
	}
	LINE;
	
	int ans = 0;
	rep(i, memo.size()) if(memo[i] == -2) ans++;

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

Measured memory_bytes: 81492
#include<stdio.h>

int main()
{
  int N,i,j,v;
  int A[100];
  
  scanf("%d",&N);

  for(i = 0;i < N;i++)
    {
      scanf("%d",&A[i]);
    }
   for(i = 0;i < N - 1;i++)
    {
      printf("%d ",A[i]);
    }
   printf("%d",A[N - 1]);
   printf("\n");

  for(i = 1;i <= N - 1;i++)
    {
      v = A[i];
      j = i - 1;
      while(j >= 0 && A[j] > v)
	{
	  A[j + 1] = A[j];
	  j--;
	  A[j + 1] = v;
	}
      for(j = 0;j < N - 1;j++)
	    {
	      printf("%d ",A[j]);
	    }
      printf("%d",A[N - 1]);
      printf("\n");
    }
  return 0;
}



Measured memory_bytes: 2144
import sys

stdin = sys.stdin
inf = 1 << 60
mod = 1000000007

sys.setrecursionlimit(10 ** 7)

ni      = lambda: int(ns())
nin     = lambda y: [ni() for _ in range(y)]
na      = lambda: list(map(int, stdin.readline().split()))
nan     = lambda y: [na() for _ in range(y)]
nf      = lambda: float(ns())
nfn     = lambda y: [nf() for _ in range(y)]
nfa     = lambda: list(map(float, stdin.readline().split()))
nfan    = lambda y: [nfa() for _ in range(y)]
ns      = lambda: stdin.readline().rstrip()
nsn     = lambda y: [ns() for _ in range(y)]
ncl     = lambda y: [list(ns()) for _ in range(y)]
nas     = lambda: stdin.readline().split()

from collections import Counter

def modpow(n, p, m):
    if p == 0:
        return 1
    if p % 2 == 0:
        t = modpow(n, p // 2, m)
        return t * t % m
    return n * modpow(n, p - 1, m) % m


n = ni()
a = na()
co = Counter(a)

ok = True
if n % 2 == 0:
    cur = 1
    l = [(k, v) for k, v in co.items()]
    l.sort()
    for k, v in l:
        if k != cur or v != 2:
            ok = False
        cur += 2
else:
    cur = 0
    l = [(k, v) for k, v in co.items()]
    l.sort()
    for k, v in l:
        if cur == 0:
            if k != cur or v != 1:
                ok = False
        else:
            if k != cur or v != 2:
                ok = False
        cur += 2

if ok:
    print(modpow(2, n // 2, mod))
else:
    print(0)

Measured memory_bytes: 16160
import sys
sys.setrecursionlimit(10**7)

# n = int(input())
# a, b = map(int, input().split())
# int_list = list(map(int, input().split()))
# l = list(input().split())



def solve():
    r, d, x = map(int, input().split())

    for i in range(10):
        x = r*x - d
        print(x)
solve()

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

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

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcountll

#define INF 1e16
#define mod 1000000007

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

  ll N;
  cin>>N;
  vector<ll> A(N+1);
  vector<ll> mx(N+1);
  rep(i,N+1)cin>>A[i];

  rep(i,N+1){
    ll p2=1;
    rep(j,min(60LL,i)){
      p2*=2LL;
    }
    mx[i]=p2-A[i];
    if(mx[i]<0){
      cout<<-1<<endl;
      return 0;
    }
  }
  rep(i,N){
    minch(mx[i+1],mx[i]*2LL-A[i+1]);
  }

  ll res=0,crtlf=0;
  for(ll i=N;i>0;i--){
    crtlf+=A[i];
    res+=crtlf;
    ll lb=(crtlf+1)/2, ub=crtlf;
    if(mx[i-1]<lb){
      cout<<-1<<endl;
      return 0;
    }
    crtlf=min(ub,mx[i-1]);
  }
  res++;
  cout<<res<<endl;

  return 0;
}


Measured memory_bytes: 4756
#include <stdio.h>

int main(void) {
	int i, j, rec, count = 0;
	int a[100], n, tmp, min;

	scanf("%d", &n);

	for (i = 0; i < n; i++) {
		scanf("%d", &a[i]);
	}

	for (i = 0; i < n - 1; i++) {
		min = a[i];
		rec = i;
		for (j = i; j < n; j++) {
			//最小検出
			if (min > a[j]) {
				min = a[j];
				rec = j;
			}
		}
		//入れ替え
		if (i != rec) {
			tmp = a[i];
			a[i] = a[rec];
			a[rec] = tmp;
			count++;
		}
	}

	for (i = 0; i < n; i++) {
		printf("%d", a[i]);
		if (i != n - 1) {
			putchar(' ');
		}
	}
	putchar('\n');
	printf("%d\n", count);

	return 0;
}



Measured memory_bytes: 2140
#include <iostream>
int main(){

    int n = 0,m = 0,l = 0;
    std::cin >> n;
    l = n;
    while(n != 0){
    
        m = m + n % 10;
        n = n/10;
    }
    if(l % m == 0){
    std::cout << "Yes" << std::endl;
    }else{
    std::cout << "No" << std::endl;
    }
    

 return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdint>
#include <vector>
#include <algorithm>
#include <utility>
#include <numeric>
#include <string>
#include <set>
#include <map>

int main() {
  intmax_t t1, t2, a1, a2, b1, b2;
  scanf("%jd %jd %jd %jd %jd %jd", &t1, &t2, &a1, &a2, &b1, &b2);

  if (t1*a1 + t2*a2 == t1*b1 + t2*b2)
    return puts("infinity"), 0;

  if (a1 < b1 || (a1 == b1 && t1*a1 + t2*a2 > t1*b1 + t2*b2)) {
    std::swap(a1, b1);
    std::swap(a2, b2);
  }

  // a1 >= b1
  if (t1*a1 + t2*a2 > t1*b1 + t2*b2)
    return puts("0"), 0;

  intmax_t d = - (t1*a1 + t2*a2) + (t1*b1 + t2*b2);
  intmax_t u = t1*b1 + t2*b2;

  // fprintf(stderr, "d: %jd, u: %jd\n", d, u);

  auto f = [&](__int128 i) -> bool {
             return t1*a1 >= t1*b1 + d*i;
           };

  auto fs = [&](__int128 i) -> bool {
              return t1*a1 > t1*b1 + d*i;
            };

  intmax_t lb = 0;
  // intmax_t ub = (u+d-1)/d + 10;
  intmax_t ub = 1e18;
  // fprintf(stderr, "%jd: %jd\n", lb, ub);
  while (ub-lb > 1) {
    intmax_t mid = (lb+ub) >> 1;
    (f(mid)? lb: ub) = mid;
  }
  intmax_t res = 2*lb;
  if (fs(lb)) ++res;
  printf("%jd\n", res);
}


Measured memory_bytes: 128
// #pragma GCC target("avx2")
#pragma GCC optimize("O3", "unroll-loops")

// #include <bits/extc++.h>
// using namespace __gnu_pbds;

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

#define int long long
#define double long double
// template <typename T>
// using pbds_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
using pii = pair<int, int>;
template<typename T>
using prior = priority_queue<T, vector<T>, greater<T>>;
template<typename T>
using Prior = priority_queue<T>;

#define X first
#define Y second
#define ALL(x) (x).begin(), (x).end()
#define eb emplace_back
#define pb push_back

#define fastIO() ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define RANDOM() random_device __rd; \
                 mt19937 __gen = mt19937(__rd()); \
                 uniform_int_distribution<int> __dis(1, 1E8); \
                 auto rnd = bind(__dis, __gen)

const int INF = 1E18;
const int mod = 1E9 + 7;

int32_t main() {
    fastIO();
    
    int sz, cnt = 0;
    string s;
    cin >> s, sz = s.size();
    
    if (s[0] != 'A') return cout << "WA\n", 0;
    
    for (int i = 1; i < sz; ++i) {
        if (s[i] == 'C') {
            if (i == 1 or i == sz - 1) return cout << "WA\n", 0;
            ++cnt;
        }
        else if (isupper(s[i])) return cout << "WA\n", 0;
    }
    
    cout << (cnt == 1 ? "AC" : "WA") << "\n";
    
    return 0;
}

Measured memory_bytes: 3660
r, c = [int(i) for i in input().split()]
 
data = []
sum_row = [0] * (c + 1)
 
for ri in range(r):
    data.append([int(i) for i in input().split()])
    data[ri].append(sum(data[ri]))
    print(" ".join([str(d) for d in data[ri]]))
    for ci in range(c + 1):
        sum_row[ci] += data[ri][ci]
 
print(" ".join([str(s) for s in sum_row]))

Measured memory_bytes: 7824
A, B, C = map(int, input().split())
abc_max = max(A, B, C)
if (A + B + C) % 2 == abc_max % 2:
    print((3 * abc_max - (A + B + C)) // 2)
else:
    print((3 * (abc_max + 1) - (A + B + C)) // 2)


Measured memory_bytes: 9136
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define all(x) (x).begin(), (x).end()
using ll = long long;
using namespace std;
template <typename T> using vec = std::vector<T>;
 
int main() {
    int N, W;
    cin >> N >> W;
 
    vec<ll> w(N), v(N);
    rep(i, N) cin >> w[i] >> v[i];
 
    ll MAX_VAL = 10000 * N;
    vec<vec<ll>> dp(N + 1, vec<ll>(MAX_VAL + 100, 1e14 + 5));
 
    for (int i = 1; i <= N; ++i) {
        dp[i][v[i - 1]] = min(dp[i][v[i - 1]], w[i - 1]);
 
        for (int j = 0; j <= MAX_VAL; ++j) {
            dp[i][j] = min({dp[i][j], dp[i - 1][j]});
 
            dp[i][j + v[i - 1]] = min(dp[i][j + v[i - 1]], dp[i-1][j] + w[i - 1]);
        }
    }
 
    ll ans = 0;
 
    rep(i, MAX_VAL + 50) if (dp[N][i] <= W) ans = max(ans, i);
    cout << ans << endl;
}

Measured memory_bytes: 800524
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] A = new int[N];
        for (int i = 0; i < N; i++) {
            A[i] = sc.nextInt();
        }

        String ans = "YES";
        Arrays.sort(A);
        int tmp = 0;
        for (int i = 0; i < N; i++) {
            if(tmp == A[i]){
                ans = "NO";
                break;
            }else{
                tmp = A[i];
            }
        }

        System.out.println(ans);
    }
}


Measured memory_bytes: 64608
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> iint;
typedef pair<ll,ll> llll;
#define ALL(x) (x).begin(),(x).end()
const ll zero = 0;
const ll INF = 3000000000000000000; //10^18
const int inINF = 1000000000; //10^9
const ll MOD = 1000000007; //10^9+7
const ll MOD2 = 998244353;
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

int ans;

struct UnionFind{
    vector<int> par;
    
    UnionFind(int N) : par(N) {
        for (int i = 0; i < N; i++) {
            par[i] = i;
        }
    }

    int root(int x){
        if(par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y){
        int rx = root(x);
        int ry = root(y);

        if(rx == ry) return;
        par[rx] = ry;
        ans++;
    }
};

int main(){
    int N, M;
    cin >> N >> M;
    int x, y, z;
    ans = 0;
    UnionFind G(N);
    for (int i = 0; i < M; i++) {
        cin >> x >> y >> z;
        x--;
        y--;
        G.unite(x, y);
    }
    printf("%d\n", N-ans);

}

Measured memory_bytes: 3768
card = [list(map(int, input().split())) for _ in range(3)]
n = int(input())
check = [int(input()) for _ in range(n)]

for i in range(3):
    for j in range(3):
        for k in range(n):
            if card[i][j] == check[k]:
                card[i][j] = 0

ans = "No"
for i in range(3):
    if card[i][0] + card[i][1] + card[i][2] == 0:
        ans = "Yes"
    if card[0][i] + card[1][i] + card[2][i] == 0:
        ans = "Yes"

if card[0][0] + card[1][1] + card[2][2] == 0:
    ans = "Yes"
if card[0][2] + card[1][1] + card[2][0] == 0:
    ans = "Yes"
print(ans)

Measured memory_bytes: 9228
h, w = map(int, input().split())
ma = [list(input()) for i in range(h)]

# 連結しているものが一つもなければNo

dx = [1, 0, -1, 0]
dy = [0, -1, 0, 1]
import sys
for i in range(h):
    for j in range(w):
        if ma[i][j] == '#':
            flag = False
            for x, y in zip(dx, dy):
                if j + x < 0 or i + y < 0 or j + x >= w or i + y >= h:
                    continue

                if ma[i + y][j + x] == '#':
                    flag = True

            if flag == False:
                print('No')
                sys.exit(0)
print('Yes')
sys.exit(0)

Measured memory_bytes: 3064
n, k = gets.chomp.split.map(&:to_i)

ary = 0
(1..n).each do |i|
  cnt = i
  s = 0
  while cnt < k
    cnt *= 2
    s += 1
  end
  ary += (1/n.to_f) * 1/2**s 
end
puts ary

Measured memory_bytes: 1788
#include <iostream>
#include <map>
#include <algorithm>
using namespace std;
 
int main() {
    int n;
    cin >> n;
    map<int, int> arr;
    while (n--) {
        int n;
        cin >> n;
        arr[n]++;
    }
    for (auto it = arr.begin(); it != arr.end(); it++) {
        if (it->second > 1) {
            cout << "NO" << endl;
            return 0;
        }
    }
    cout << "YES" << endl;
    return 0;
}

Measured memory_bytes: 9600
#include <bits/stdc++.h>
using namespace std;
int main() {
    #ifdef DEBUG
    std::ifstream in("/home/share/inputf.in");
    std::cin.rdbuf(in.rdbuf());
    #endif
    int A, B;
    cin >> A >> B;
    if(A >= 13) cout << B << endl;
    else if(A >= 6) cout << B / 2 << endl;
    else cout << 0 << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main()
{
  int a, b, c, d, e, ave;
  scanf("%d %d %d %d %d", &a, &b, &c, &d, &e);
  if (a < 40 ){
    a = 40;
  }
  if (b < 40){
    b = 40;
  } 
  if (c < 40){
    c = 40;
    
  }
  if (d < 40){
    d = 40;
  }
  if (e < 40){
    e = 40;
  }
  
  ave = (a + b + c + d + e) / 5;
  printf("%d\n", ave);
  
  return 0;
  
}

Measured memory_bytes: 600
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        ArrayList<Integer> list = new ArrayList<>();
        for (int i = 0; i < Math.pow(2, n); i++) {
            list.add(sc.nextInt());
        }
        list.add(0);
        list.add(Integer.MAX_VALUE);
        Collections.sort(list);
        PriorityQueue<Integer> queue = new PriorityQueue<>();
        PriorityQueue<Integer> next = new PriorityQueue<>();
        queue.add(- list.remove(list.size() - 2));
        for (int i = 0; i < n; i++) {
            while (queue.size() > 0) {
                int x = - queue.poll();
                int left = 0;
                int right = list.size();
                while (right - left > 1) {
                    int m = (left + right) / 2;
                    if (list.get(m) < x) {
                        left = m;
                    } else {
                        right = m;
                    }
                }
                if (left == 0) {
                    System.out.println("No");
                    return;
                }
                next.add(- x);
                next.add(- list.remove(left));
            }
            PriorityQueue<Integer> tmp = next;
            next = queue;
            queue = tmp;
        }
        System.out.println("Yes");
    }
}

Measured memory_bytes: 71884
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <iomanip>
#include <array>
#include <numeric>
#include <regex>
#include <bitset>
#include <deque>
#include <cassert>

using namespace std;
typedef long long ll;

const int INF = 1e9+7;

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define debug(x) cout << #x << ": " << x << endl;


int main() {
	int N, K; cin >> N >> K;
	vector<int> A(N);
	for (int i = 0; i < N; i++) cin >> A[i];
	if (find(A.begin(), A.end(), K) != A.end()) {
		puts("POSSIBLE");
		return 0;
	}

	if (*max_element(all(A))<K) {
		puts("IMPOSSIBLE");
		return 0;
	}

	sort(all(A));
	int segmin = INF;
	for (int i = 0; i < N - 1; i++)
	{
		if (A[i + 1] - A[i] != 0)segmin = min(segmin, A[i + 1] - A[i]);
	}

	if (K%segmin == 0)puts("POSSIBLE");
	else puts("IMPOSSIBLE");

	return 0;
}

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

int main() {
    int a[3];
    for (int i = 0; i < 3; ++i) {
        cin >> a[i];
    }

    sort(a, a + 3);
    cout << a[2] * 10 + a[1] + a[0] << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <cmath>
#include <utility>
#include <map>
#include <unordered_map>
#define rep(i,n) for(int i=0;i<n;++i)
using namespace std;
typedef long long int ll;

int main() {
  int N,M;
  cin>>N>>M;
  
  if(N==M)
    cout<<"Yes"<<endl;
  else
    cout<<"No"<<endl;
}

Measured memory_bytes: 256