akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

int main()
{
    const int MOD = 100000;

    for(;;){
        int n, m, s;
        cin >> n >> m >> s;
        if(n == 0)
            return 0;
        m = min(m, s);

        vector<vector<int> > num(n*n+1, vector<int>(s+1, 0));
        num[0][0] = 1;

        for(int i=1; i<=m; ++i){
            for(int j=n*n; j>0; --j){
                for(int k=i; k<=s; ++k){
                    num[j][k] += num[j-1][k-i];
                    num[j][k] %= MOD;
                }
            }
        }
        cout << num[n*n][s] << endl;
    }
}

Measured memory_bytes: 1500
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <string>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <bitset>
#include <utility>
#include <numeric>

using namespace std;

using ll = long long;
using ull = unsigned long long;

const ll inf = 1ll << 60;
const ll mod = (ll)1e9 + 7;

#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()

#define print(s) cout << s;
#define println(s) cout << s << endl;
#define printd(s, f) cout << fixed << setprecision(f) << s << endl;


int main()
{
	ll n, k;
	cin >> n >> k;

	ll t = n % k;
	println(min(t, abs(k - t)));
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a, b;
		a = sc.nextInt();
		b = sc.nextInt();
		int ans = 0;
		for (int i = a; i <= b; i++) {
			String s = String.valueOf(i);
			if( (s.charAt(0) == s.charAt(4)) && (s.charAt(1) == s.charAt(3)) ) ans++;
		}
		System.out.print(ans);
	}
}



Measured memory_bytes: 25556
# 0-indexed
class SegTree:
    def __init__(self, vals, seg_f, ide_ele):
        n = len(vals)
        self.seg_f = seg_f
        self.ide_ele = ide_ele
        self.leaf_n = 1 << (n-1).bit_length()
        self.tree = [ide_ele]*(2*self.leaf_n-1)
        for i in range(n):  # init leaf
            self.tree[i+self.leaf_n-1] = vals[i]
        for i in range(self.leaf_n-2, -1, -1):  # bottom-up
            self.tree[i] = self.seg_f(self.tree[2*i+1], self.tree[2*i+2])

    def update(self, i, x):
        i += (self.leaf_n-1)
        self.tree[i] = x
        while i > 0:
            i = (i-1)//2
            self.tree[i] = self.seg_f(self.tree[2*i+1], self.tree[2*i+2])

    # [l,r)
    def query(self, l, r):
        v_l = self.ide_ele
        v_r = self.ide_ele
        l += (self.leaf_n-1)
        r += (self.leaf_n-1)
        while l < r:
            if l&1 == 0:
                v_l = self.seg_f(v_l, self.tree[l])
            if r&1 == 0:
                v_r = self.seg_f(v_r, self.tree[r-1])
                r -= 1
            l >>= 1
            r >>= 1
        return self.seg_f(v_l ,v_r)


'''
memo:
GCD... INFをide_eleに設定して、片方がINFの場合はもう片方を返す
def gcd2(a,b):
    if a >= INF: return b
    elif b >= INF: return a
    else return gcd(a,b)


vl = [1,4,6,8,9]

def add(a,b): return a+b
st = SegTree(vl,add,0)
st = SegTree(vl,(lambda a,b: a+b),0)
st = SegTree(vl,min,10**10)

print(st.query(2,4))
st.update(4,-4)
print(st.query(2,5))
st.update(0,-10)
print(st.query(0,5))
'''

def main():
    n,k = map(int, input().split())
    seg = SegTree([0]*300001, max, 0)
    for _ in range(n):
        a = int(input())
        l = max(a-k,0)
        r = min(a+k,300000)
        c_max = seg.query(l,r+1)
        seg.update(a,c_max+1)

    ans = seg.query(0,300001)
    print(ans)

if __name__ == "__main__":
    main()

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

using namespace std;

const int   N   = 5e3 + 1;
const int   mod = 1e9 + 7;

int add(int a,int b)    {
    a += b;
    if(a >= mod)a -= mod;
    return  a;
}
int sub(int a,int b)    {
    a -= b;
    if(a <  0)  a += mod;
    return  a;
}
int mul(int a,int b)    {
    return (long long)a * b % mod;
}

vector<int> g[N];

int f[N][N][2];
int C[N];
int nCh[N];
int alt[N][2];

int dfs(int u,int p)    {
    nCh[u] = 1;
    f[u][1][1] = 1;
    for(int v : g[u])   if (v != p) {
        dfs(v,u);

        for(int i = 0 ; i <= nCh[u] + nCh[v] ; ++i)
            alt[i][0] = 0,
            alt[i][1] = 0;

        for(int i = nCh[u] ; i >= 1 ; --i)
        for(int j = nCh[v] ; j >= 0 ; --j)
            for(int p1 = 0 ; p1 < 2 ; ++p1)
            for(int p2 = 0 ; p2 < 2 ; ++p2)
                alt[i + j][p1 ^ p2] = add(alt[i + j][p1 ^ p2],mul(mul(f[u][i][p1],f[v][j][p2]),1)),
                alt[0][1 ^ p1 ^ p2] = add(alt[0][1 ^ p1 ^ p2],mul(mul(f[u][i][p1],f[v][j][p2]),C[i + j]));

        nCh[u] += nCh[v];

        for(int i = 0 ; i <= nCh[u] ; ++i)
            f[u][i][0] = alt[i][0],
            f[u][i][1] = alt[i][1];
    }
}

int main()  {
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);

    int n;  cin >> n;

    C[0] = 1;

    for(int i = 2 ; i <= n ; ++i)   {
        int x, y;   cin >> x >> y;
        g[x].push_back(y);
        g[y].push_back(x);
        C[i] = mul(C[i - 2],i - 1);
    }

    dfs(1,0);

    cout << sub(f[1][0][1],f[1][0][0]);
}

Measured memory_bytes: 195200
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
using namespace std;
const int ALL = ((1 << 4) -1);
///1111 -> NEWS
const int N = (1 << 3);
const int E = (1 << 2);
const int W = (1 << 1);
const int S = 1;
int dx[4] = {0,-1,1,0};
int dy[4] = {1,0,0,-1};
int bfs(vector<vector<int> > &map){
  queue<int> qu_x;
  queue<int> qu_y;
  qu_x.push(0);
  qu_y.push(0);
  vector<vector<int> > ans(map.size()+1,vector<int>(map[0].size()+1,0));
  ans[0][0] = 1;
  while(!qu_x.empty()){
    int x,y;
    x = qu_x.front();qu_x.pop();
    y = qu_y.front();qu_y.pop();
    for(int i = 0;i < 4;i++){
      if((map[x][y] & (1<<i)) == 0){
	if(ans[x+dx[i]][y+dy[i]] == 0){
	  ans[x+dx[i]][y+dy[i]] = ans[x][y]+1;
	  qu_x.push(x+dx[i]);
	  qu_y.push(y+dy[i]);
	}
      }

    }
  }
  return ans[map.size()-2][map[0].size()-2];
  
}
int main(){
  //  cout << (6 & 1) << endl;
  while(1){
    int w,h;
    cin >> w >> h;
    if(w == 0 && h == 0)break;
    vector<vector<int> > map(w+1,vector<int>(h+1,0));
    for(int i = 0;i < h;i++){
      for(int j = 0;j < w-1;j++){
	int tmp;
	cin >> tmp;
	if(j == 0){
	  map[j][i] = (map[j][i] | W);
	}
	if(j == w-2){
	  map[j+1][i] = (map[j+1][i] | E);
	}
	if(i == 0){
	  map[j][i] = (map[j][i] | N);
	  map[j+1][i] = (map[j+1][i] | N);
	}
	if(i == h-1){
	  map[j][i] = (map[j][i] | S);
	  map[j+1][i] = (map[j+1][i] | S);
	}
	if(tmp == 1){
	  map[j][i] = (map[j][i] | E);
	  map[j+1][i] = (map[j+1][i] | W);
	}
      }
      if(i != h-1){
	for(int j = 0;j < w;j++){
	  int tmp;
	  cin >> tmp;
	  if(tmp == 1){
	    map[j][i] =(map[j][i] | S);
	    map[j][i+1] = (map[j][i+1] | N);
	  }
	}
      }
     
    }/*
    cout << endl;
    for(int i = 0;i < h;i++){
      for(int j = 0;j < w;j++){
	if((map[j][i] & N) == N)
	  cout << "N";
	if((map[j][i] &W) == W)
	  cout << "W";
	if((map[j][i] &E)== E)
	  cout << "E";
	if((map[j][i]&S) == S)
	cout << "S";
	cout << "a\t" ;
      }
      cout << endl;
      }*/
    //    cout << "END" << endl;
    //    cout << map[w-1][h-1] << endl;
    //    int ans;
    cout << bfs(map) << endl;
  }
  return 0;
}

Measured memory_bytes: 1244
// 2011/01/08 Tazoe

#include <iostream>
using namespace std;

int main()
{
	while(true){
		int n, m;
		cin >> n >> m;
		if(n==0&&m==0)
			break;

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

		for(int i=0; i<n-1; i++)
			for(int j=i+1; j<n; j++)
				if(p[i]<p[j]){
					int tmp = p[i];
					p[i] = p[j];
					p[j] = tmp;
				}

		for(int i=m-1; i<n; i+=m)
			p[i] = 0;

		int sum = 0;
		for(int i=0; i<n; i++)
			sum += p[i];

		cout << sum << endl;
	}

	return 0;
}

Measured memory_bytes: 868
#include <stdio.h>
#include <string.h>
#define LEN 100005
 
typedef struct pp {
  char name[100];
  int t;
} P;
 
P Q[LEN];
int head, tail, n;
 
void enqueue(P x) {
  Q[tail] = x;
  tail = (tail + 1) % LEN;
}
 
P dequeue() {
  P x = Q[head];
  head = (head + 1) % LEN;
  return x;
}
 
int min(int a,int b) {
  return a < b ? a : b; 
}
 
int main() {
  int elaps = 0, c;
  int i, q;
  P u;
  char str[64];
  
  scanf("%d %d",&n ,&q);
  for(i=1; i<=n; i++) {
    scanf("%s", Q[i].name);
    scanf("%d", &Q[i].t);
  }
  head = 1; tail = n + 1;
 
  while(head != tail) {
    u = dequeue();
    c = min(q, u.t);
    u.t -= c;
    elaps += c;
    if(u.t > 0) enqueue(u);
    else {
      printf("%s %d\n",u.name,elaps);
    }
  }
  return 0;
}


Measured memory_bytes: 11888
/*input
3 1 8
*/
/**
    Author: Kristopher Paul
    Date Created: 27-10-2019
    Contest Name:
                _/    _/   _/_/_/_/   _/   _/_/_/_/
               _/  _/     _/    _/   _/   _/
              _/_/       _/_/_/_/   _/   _/_/_/_/
             _/  _/     _/  _/     _/         _/
            _/    _/   _/    _/   _/   _/_/_/_/
**/
#include<bits/stdc++.h>
#include<stdio.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
#define ll long long
#define int ll
#define pb push_back
#define INF 1e18
#define MOD 1000000007
//#define MOD 998244353
#define mp make_pair
const double PI=3.141592653589793238462643383279502884197169399375105820974944;
#define REP(i,n) for (int i = 0; i < n; i++)
#define FOR(i,a,b) for (int i = a; i < b; i++)
#define REPD(i,n) for (int i = n-1; i >= 0; i--)
#define FORD(i,a,b) for (int i = a; i >= b; i--)
#define remax(a,b) a = max(a,b)
#define remin(a,b) a = min(a,b)
#define umap unordered_map
#define pii pair<int,int>
#define F first
#define S second
#define mii map<int,int>
#define vi vector<int>
#define vvi vector<vi>
#define itr :: iterator it
#define all(v) v.begin(),v.end()
#define WL(t) while(t--)
#define gcd(a,b) __gcd((a),(b))
#define lcm(a,b) ((a)*(b))/gcd((a),(b))
#define out(x) cout << #x << " is " << x << endl
#define FastIO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
using namespace std;
//using namespace __gnu_pbds;

//typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> pbds; // set
//typedef tree<int,null_type,less_equal<int>,rb_tree_tag,tree_order_statistics_node_update> pbds; // multiset

int ModExp(int x,int y,int m){
    int res = 1;
    x = x % m;
    while (y > 0)
    {
        if (y & 1)
            res = (res*x) % m;

        y = y>>1;
        x = (x*x) % m;
    }
    return res;
}

void solve(){
    int a,b,x;
    cin >> a >> b >> x;
    if((2*x) < (a*a*b)){
        double y = double(x*2.0)/double(a*b);
        double ang = atan(double(b)/double(y));
        ang *= 180.0;
        ang /= PI;
        cout << fixed << setprecision(10) << ang << endl;
    }else if((2*x) == (a*a*b)){
        double ang = double(b)/double(a);
        ang = atan(ang);
        ang *= 180.0;
        ang /= PI;
        cout << fixed << setprecision(10) << ang << endl;
    }else{
        double y = double(((a*a*b)-x)*2.0)/double(a*a);
        double ang = atan(double(y)/double(a));
        ang *= 180.0;
        ang /= PI;
        cout << fixed << setprecision(10) << ang << endl;
    }
}

signed main(){
    FastIO;
    int t = 1;
//    cin >> t;
    WL(t){
        solve();
    }
}


Measured memory_bytes: 256
N, M, K = map(int, input().split())
friends_table = [[] for i in range(N)]
for _ in range(M):
    a, b = map(int, input().split())
    friends_table[a-1] += [b-1]
    friends_table[b-1] += [a-1]

group_list = [i for i in range(N)]
friends_candidate = [[] for i in range(N)]

for i in range(N):
    # すでにDFS済み
    if i != group_list[i]:
        continue
    next_stack = [i]
    friend = [i]
    while next_stack:
        u = next_stack.pop(-1)
        for v in friends_table[u]:
            # 訪問済み
            if i == group_list[v]:
                continue
            friend += [v]
            group_list[v] = i
            next_stack += [v]
    for f in friend:
        friends_candidate[f] = friend

blocks_table = [[] for i in range(N)]
for _ in range(K):
    a, b = map(int, input().split())
    if group_list[a-1] == group_list[b-1]:
        blocks_table[a-1] += [b-1]
        blocks_table[b-1] += [a-1]

for i in range(N):
    print(len(friends_candidate[i]) - len(friends_table[i]) - len(blocks_table[i])-1)

Measured memory_bytes: 51884
import java.util.Scanner;

public class Main{

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int a = scan.nextInt();
		int b = scan.nextInt();
		int c = scan.nextInt();
		int d = scan.nextInt();
		scan.close();
		System.out.println((Math.abs(c-a)<=d ||(Math.abs(b-a)<=d) && Math.abs(c-b)<=d)? "Yes": "No");
	}
}

Measured memory_bytes: 21844
import java.io.*;
// import java.math.*;
// import java.util.*;
// import java.util.Map.*;
// import java.util.stream.*;

public class Main {
    public static void main (String[] args) throws Exception {
        BufferedReader reader =
            new BufferedReader (new InputStreamReader (System.in));
        int N = Integer.parseInt (reader.readLine());
        String S = reader.readLine();
        String alp = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
        System.out.println (
            trans (S, alp, alp.substring (N) + alp.substring (0, N)));
        return;
    }

    static String trans (String S, String f, String t) {
        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < S.length(); i++) {
            int idx = f.indexOf (S.charAt (i));
            sb.append (t.charAt (idx));
        }
        return sb.toString();
    }
}

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

int main() {

    int a,b,c,d;
    cin >> a >> b >> c >> d;

    int cnt = 0;
    for(int i = 0; i < 101; i++)
    {
        if(i > a && i > c){
            if (i <= b && i <= d) {
                cnt++;
            }  
        }
    }
    
    cout << cnt << endl;

}




Measured memory_bytes: 256
/**
 *    author  : 𝒌𝒚𝒐𝒎𝒖𝒌𝒚𝒐𝒎𝒖𝒑𝒖𝒓𝒊𝒏
 *    created : 2020-03-13 07:00:07
**/

#include <iostream>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <complex>
#include <numeric>
#include <bitset>
#include <cassert>
#include <cctype>
#include <iomanip>
#include <random>
#include <utility>
#include <chrono>

using namespace std;

using int64 = long long;

template<class T> using binary_heap = std::priority_queue<T, std::vector<T>, std::greater<T>>;
template<class T> std::ostream& operator<<(std::ostream& os, const std::vector<T>& vec) { os << '{'; size_t n = vec.size(); for (size_t i = 0; i < n; ++i) { os << vec[i]; if (i != n - 1) os << ','; } os << '}'; return os; }
template<class T, class U> std::ostream& operator<<(std::ostream& os, const std::pair<T, U>& p) { return os << '{' << p.first << " " << p.second << '}'; }
template<class T, class U> std::ostream& operator<<(std::ostream& os, const std::map<T, U>& mp) { os << '{'; for (auto it = mp.begin(); it != mp.end(); ++it) { os << '{' << it->first << ':' << it->second << '}'; if (it != --mp.end()) os << ','; } os << '}'; return os; }
template<class T> std::ostream& operator<<(std::ostream& os, const std::set<T>& st) { os << '{'; for (auto it = st.begin(); it != st.end(); ++it) { os << *it; if (it != --st.end()) os << ','; } os << '}'; return os; }
template<class T> std::istream& operator>>(std::istream& is, std::vector<T>& vec) { size_t n = vec.size(); for (size_t i = 0; i < n; ++i) is >> vec[i]; return is; }

#define all(_) begin(_), end(_)
#define rall(_) rbegin(_), rend(_)

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]: ", debug_out(__VA_ARGS__)
#else
#define debug(...) 1728
#endif

void debug_out() { std::cerr << '\n'; }

template <class Head, class... Tail>
void debug_out(Head&& head, Tail&&... tail) {
  std::cerr << head;
  if (sizeof...(Tail) != 0) std::cerr << ", ";
  debug_out(std::forward<Tail>(tail)...);
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);

  int64 x, y; cin >> x >> y;

  if (x + y <= 1) {
    cout << "Brown" << endl; return 0;
  }

  if (abs(x - y) <= 1) {
    cout << "Brown" << endl;
  } else {
    cout << "Alice" << endl;
  }

  return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#pragma comment(linker, "/stack:256000000")
#include<utility>
#include<iostream>
#include<vector>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<ctime>
#include<functional>
#include<random>
#include<climits>
#include<queue>
#include<stack>
#include<deque>
#include<bitset>
#include<map>
#include<set>
#include<unordered_map>
#include<unordered_set>
#include<cassert>
#include<ccomplex>

//4Head
#define all(x) x.begin(), x.end()
#define mp make_pair
#define X first
#define Y second

using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
mt19937_64 gen(time(NULL));

// belik's shit
ll const mod = 1e9 + 7;
namespace {
	ll mult(ll& a, ll& b) {
		ll val = a * b - (ll)((ld)a * b / mod) * mod;
		if (val < 0) {
			val += mod;
		}
		if (val >= mod) {
			val -= mod;
		}
		return val;
	}
	ll poww(ll a, ll b)
	{
		ll val = 1;
		a %= mod;
		while (b > 0){
			if (b % 2) val = mult(a, val);
			a = mult(a, a);
			b >>= 1;
		}
		return val % mod;
	}
	ll inv(ll a) {
		return poww(a, mod - 2);
	}
}

ll const maxn = 3e5 + 5;

signed main() {
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	ll n; cin >> n; vector<ll>a(n+1);
	for (ll i = 1; i <= n; i++) cin >> a[i];
	vector<ll>b(n + 1);
	ll ans = 0;
	for (ll i = n; i >= 1; i--) {
		ll sm = 0;
		for (ll j = 2 * i; j <= n; j+=i) {
			sm += b[j] % 2;
			sm %= 2;
		}
		if (sm == a[i]) {
			b[i] = 0;
		}
		else {
			ans++;
			b[i] = 1;
		}
	}
	cout << ans << endl;
	for (ll i = 1; i <= n; i++) {
		if (b[i])cout << i << " ";
	}
	return 0;
}
/*

*/

Measured memory_bytes: 3968
//A,Bのペアで重複をなくしたい
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;

int main() {
    int N,M;
    cin >> N >> M;
    vector<int> H(N);
    for(int i=0;i<N;i++) cin >> H[i];
    vector<int> A(M),B(M);
    for(int i=0;i<M;i++) {
        cin >> A[i] >> B[i];
    }
    map<int,vector<int>> m;
    //各展望台から１本の道でいける展望台をリストにしたい
   for(int i=0;i<M;i++) {
       m[A[i]].push_back(B[i]);
       m[B[i]].push_back(A[i]);
   }
//    for(auto p:m) {
//        set<int> S;
//        for(auto can_go : p.second) S.insert(can_go);

//    }

//    for(auto p:m) {
//        cout << p.first << " ";
//        for(auto can_go:p.second) {
//            cout << can_go << ",";
//        }
//        cout << endl;
//    }
   int good=0; //いい展望台の数
   for(int i=0;i<N;i++) {
       if(m.count(i+1)) {
           bool flag = false;
            for(auto can_go : m[i+1]) {
                if(H[i] <= H[can_go-1]) {
                    flag = false;
                    break;
                }
                else flag = true;
            }
            if(flag) {
                good++;
                // cout << "展望台" << i+1 << endl;
            }
       }
       else {
           good++;
        //    cout << "no展望台" << i+1 << endl;
       }
   }
   cout << good << endl;

    return 0;
}

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

int main() {
  int x, y;
  cin >> x >> y;
  vector<int> vec = {0, 1, 3, 1, 2, 1, 2, 1, 1, 2, 1, 2, 1};

  if (vec.at(x) == vec.at(y)) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}


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

int main() {
  int64_t S;
  cin>>S;
  int64_t A=sqrt(S);
  if(A*A>S){
    A--;
  }
  if(A*A==S){
    cout<<"0"<<" "<<"0"<<" "<<A<<" "<<"0"<<" "<<"0"<<" "<<A<<endl;
  }
  else if(A*(A+1)>=S){
    cout<<"0"<<" "<<"0"<<" "<<A<<" "<<A*(A+1)-S<<" "<<"1"<<" "<<A+1<<endl;
  }
  else{
    cout<<"0"<<" "<<"0"<<" "<<A+1<<" "<<(A+1)*(A+1)-S<<" "<<"1"<<" "<<A+1<<endl;
  }
    
}

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

//a^n modの計算（繰り返し二乗法）
ll modpow(ll a, ll n) {
  ll res = 1;
  while (n > 0) {
    if (n & 1) res = res * a;
    a = a * a;
    n >>= 1;
  }
  return res;
}

int main() {
  ll h; cin>>h;
  ll res=0;
  rep(i, 100) {
    ll tmp=modpow(2, i);
    if (tmp>h) break;
    res+=tmp;
  }
  cout<<res<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cctype>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <utility>
#include <string>
#include <functional>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#define YES cout<<"YES"<<endl
#define Yes cout<<"Yes"<<endl
#define NO cout<<"NO"<<endl
#define No cout<<"No"<<endl
typedef long long ll;
const int INF = 100000000, mod = 1000000007;
const ll LLINF = 1LL << 50;
using namespace std;


int main() {
    string a, b;
    cin >> a >> b;
    if (a[0] == b[2] && a[1] == b[1] && a[2] == b[0])YES;
    else NO;
    return 0;
}


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

using namespace std;
#define MOD 1000000007
#define pi 3.1415926535897932384626433832795028841971693993751058209749445923078164062
#define ll long long
#define pb push_back
#define pf push_front
#define mp make_pair
#define mt make_tuple
#define popb pop_back()
#define popf pop_front()
#define ff first
#define ss second
#define vl vector<ll>
#define vi vector<int>
#define vs vector<string>
#define vll vector< pair<ll,ll> >
#define vii vector< pair<int,int> >
#define viii vector< tuple <int,int,int> >
#define vlll vector< tuple <ll,ll,ll> >
#define vvl vector<vector<ll>>
#define vv vector<vector<int>>
#define all(v) v.begin(),v.end()
#define sqrt sqrtl
#define cbrt cbrtl
#define pll pair<ll,ll>
#define pii pair<int,int>
#define mapcl map<char,ll>
#define mapci map<char,int>
#define mapll map<ll,ll>
#define mapii map<int,int>
#define seti set<int>
ifstream fin("input.txt");
ofstream fout("output.txt");

int gcd(int a,int b){while (a&&b)a>b?a%=b:b%=a;return a+b;}
ll pows(int a , int b){ll res=1;for(int i=0; i<b; ++i){res*=a;}return res;}
ll logx(ll base, ll num){int cnt=0;while(num!=1){num/=base; ++cnt;}return cnt;}

vi vis(100001,0);
vi adj[100001];

int main()
{	
    std::ios::sync_with_stdio(false);
    //cin.tie(NULL);
    //cout.tie(NULL);
    string s;
    cin>>s;
    s.insert(0,1,'0');
    for(int i=1; i<s.size(); ++i)
    {
    	if(s[i]=='R' && i%2==0)
    	{
    		cout<<"No"<<"\n";
    		return 0;
    	}
    	if(s[i]=='L' && i%2==1)
    	{
    		cout<<"No"<<"\n";
    		return 0;
    	}
    }
    cout<<"Yes"<<"\n";
}

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

using namespace std;

int main()
{

	int a[100], n;
	
	cin >> n;

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

	for (int i = n - 1; i >= 0; i--) {
		cout << a[i];
		if (i != 0) cout << " ";
	}
	cout << endl;

	return (0);
}

Measured memory_bytes: 1160
#define _USE_MATH_DEFINES
#include <cmath>
#include <string>
#include <cstring>
#include <iostream>
#include <iomanip>
#include <limits>
#include <vector>
#include <algorithm>
#include <functional>
#include <cctype>
#include <sstream>
#include <numeric>

typedef long long lint;
typedef long double ldouble;
using namespace std;
#define rep(i, n) for(lint i = 0; i < (lint)(n); i++)
#define repi(i,a,b) for(lint i=lint(a);i<lint(b);++i)
#define all(x) (x).begin(),(x).end()
#define sl(c) (('a')<=(c)&&(c)<=('z'))
#define ll(c) (('A')<=(c)&&(c)<=('Z'))
#define PI 3.141592653589793
#define cout (cout<<fixed<<setprecision(15))
#define makeupper(t) (transform(all(t),t.begin(),::toupper))
#define makelower(t) (transform(all(t),t.begin(),::tolower))
#define dist(x1,y1,x2,y2) (pow(pow(x2-x1,2)+pow(y2-y1,2),0.5))
#define sum(a) accumulate(all(a),0)
inline lint* arr1(lint x) {
	lint *array = new lint[x];
	rep(i, x)array[i] = 0;
	return array;
}
inline lint** arr2(lint x, lint y) {
	lint **array = new lint*[x];
	rep(i, x)array[i] = new lint[y];
	rep(i, x)rep(j, y)array[i][j] = 0;
	return array;
}
inline vector<string> split(const string &s, char delim) {
	vector<string> elems;
	stringstream ss(s);
	string item;
	while (getline(ss, item, delim)) {
		if (!item.empty()) {
			elems.push_back(item);
		}
	}
	return elems;
}
inline ldouble max(vector<ldouble> a) {
	ldouble M = a[0];
	rep(i, a.size())if (M < a[i])M = a[i];
	return M;
}
inline ldouble min(vector<ldouble> a) {
	ldouble m = a[0];
	rep(i, a.size())if (m > a[i])m = a[i];
	return m;
}
inline lint max(vector<lint> a) {
	lint M = a[0];
	rep(i, a.size())if (M < a[i])M = a[i];
	return M;
}
inline lint min(vector<lint> a) {
	lint m = a[0];
	rep(i, a.size())if (m > a[i])m = a[i];
	return m;
}
inline ldouble sum2(vector<ldouble> a, int n) {
	vector<ldouble> b;
	b.resize(a.size());
	rep(i, a.size())b[i] = powl(a[i], n);
	return sum(b);
}
inline lint sum2(vector<lint> a, int n) {
	lint sum=0;
	rep(i, a.size())sum += powl(a[i], n);
	return sum;
}
inline ldouble dist2(vector<ldouble> a, vector<ldouble> b,int num) {
	if (a.size() != b.size())return -1;
	vector<ldouble> c;
	c.resize(a.size());
	rep(i, a.size())c[i] = abs(b[i] - a[i]);
	if (num == 0)return max(c);
	else return pow(sum2(c, num), 1. / num);
}
inline ldouble dist2(vector<lint> a, vector<lint> b, int num) {
	if (a.size() != b.size())return -1;
	vector<lint> c;
	c.resize(a.size());
	rep(i, a.size())c[i] = abs(b[i] - a[i]);
	if (num == 0)return max(c);
	else return pow(sum2(c, num),1./num);
}
int main() {
	int n;
	cin >> n;
	vector<lint> a, b;
	a.resize(n);
	b.resize(n);
	rep(i, n)cin >> a[i];
	rep(i, n)cin >> b[i];
	cout << dist2(a, b, 1) <<"\n"<< dist2(a, b, 2) <<"\n"<< dist2(a, b, 3) <<"\n"<< dist2(a, b, 0) << "\n";
}


Measured memory_bytes: 3612
/******************** Beginning of Template **************************/
/************ ALL HEADER FILE ***********/
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <fstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <utility>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <cassert>

using namespace std;

/************* ALL DEFINE ***************/
#define MEM(a, b) memset(a, b, sizeof a);
#define FORS(i, j, k, step) for (int i=j; i<k; i+=step)
#define FOR(i, j, k) for (int i=j; i<k; i++)
#define RFORS(i, j, k, step) for (int i=j; i>=k; i-=step)
#define RFOR(i, j, k, step) for(int i=j; i>=k; i--)
#define REP(i, k) for(int i = (0); i < (k); i++ )
#define RREP(i, k) for(int i = j; i >= (k); i-- )

#define ALL(cont) cont.begin(), cont.end()
#define RALL(cont) cont.begin(), cont.end()
#define FOREACH(it, l) for(auto it=l.begin(); it != l.end(); it++)
#define mp make_pair
#define pb push_back
#define debug puts("Fango")
#define INF (int)MAX_INT
#define EPS (int)1e-9
#define PI acos(-1)
#define MOD 1000000007

/****************** TYPEDEF *****************/
typedef pair<int, int> pii;
typedef pair<int, pii> piii;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<pii> vii;
typedef vector<piii> viii;
typedef long long int32;
typedef unsigned long long uint32;
typedef long long int int64;
typedef unsigned long long int uint64;

template <class T>
    T sqr(T val) {
        return val * val;
    }


/*********************** End of Template **************************/

int main() {
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    priority_queue<pair<int, int>> pq;
    int K, T;
    scanf("%d %d", &K, &T);
    REP(i, T) {
        int x;
        scanf("%d", &x);
        pq.push(mp(x, i));
    }

    int ans = 0, x1 = -1, y1 = -1;
    while(!pq.empty()) {
        int x = pq.top().first;
        int y = pq.top().second;
        pq.pop();
        if (x == 0) continue;
        //cout << x <<" "<< y << endl;
        if ((x1 != -1) && (y1 != -1)) pq.push(mp(x1, y1));
        x1 = x - 1;
        y1 = y;
    }
    cout << x1 << endl;
    return 0;
}




Measured memory_bytes: 256
#include <cstdio>
const int MOD = 1000000007;
int a[200001],b[200001];
int fac[8001],ni[8001],f[4001][4001],ans;
int n,x,y,p;
void read(int &k) {
    char c=getchar();
    while (c<48||c>57) c=getchar();
    k=0;
    while (c>=48&&c<=57) {
        k=k*10+c-48;
        c=getchar();
    }
}
int C(int n,int m) {
    return 1ll*fac[n]*ni[m]%MOD*ni[n-m]%MOD;
}
int fun(int a,int k) {
    int s=1;
    while (k) {
        if (k&1) s=1ll*s*a%MOD;
        a=1ll*a*a%MOD;
        k>>=1;
    }
    return s;
}

int main() {
    fac[0]=1;
    for (long long i=1; i<=8000; ++i) fac[i]=fac[i-1]*i%MOD;
    ni[8000]=fun(fac[8000],MOD-2);

    for (long long i=7999; i>0; --i) ni[i]=ni[i+1]*(i+1)%MOD;

    read(n);
    for (int i=1; i<=n; ++i) {
        read(a[i]);
        read(b[i]);
        if (a[i]>x) x=a[i];
        if (b[i]>y) y=b[i];
        f[2000-a[i]][2000-b[i]]++;
    }

    for (int i=2000-x; i<=2000+x; ++i)
        for (int j=2000-y; j<=2000+y; ++j) {
            if (i>0) {
                p=f[i][j]+f[i-1][j];
                f[i][j]= p>=MOD ? p-MOD : p;
            }
            if (j>0) {
                p=f[i][j]+f[i][j-1];
                f[i][j]= p>=MOD ? p-MOD : p;
            }
        }

    for (int i=1; i<=n; ++i) {
        p=ans+f[2000+a[i]][2000+b[i]];
        ans = p>=MOD ? p-MOD : p;
        p=ans+MOD - C(a[i]+b[i]+a[i]+b[i],a[i]+a[i]);
        ans = p>=MOD ? p-MOD : p;
    }
    ans=1ll*ans*ni[2]%MOD;
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 64256
import numpy as np
x1,y1,x2,y2 = map(int,input().split())


vec = np.array([x2-x1,y2-y1])

rot = np.array([[0,-1],[1,0]])

nvec = np.dot(rot,vec)

x3 = x2+nvec[0]
y3 = y2+nvec[1]

nvec = np.dot(rot,nvec)

x4 = x3+nvec[0]
y4 = y3+nvec[1]

print(x3,end=" ")
print(y3,end=" ")
print(x4,end=" ")
print(y4)


Measured memory_bytes: 21884
#include<stdio.h>
  int main(int argc,char**argv){
 
    char no[10];
 
    scanf("%s",no);
    if((no[0] == no[1] && no[0] == no[2]) || (no[1] == no[2] && no[1] == no[3])){
      printf("Yes\n");
    }
    else{
      printf("No\n");
    }
 
    return 0;
  }

Measured memory_bytes: 128
import sys
import math
from collections import defaultdict
from bisect import bisect_left, bisect_right

sys.setrecursionlimit(10**7)
def input():
    return sys.stdin.readline()[:-1]

mod = 10**9 + 7

def I(): return int(input())
def LI(): return list(map(int, input().split()))
def LIR(row,col):
    if row <= 0:
        return [[] for _ in range(col)]
    elif col == 1:
        return [I() for _ in range(row)]
    else:
        read_all = [LI() for _ in range(row)]
        return map(list, zip(*read_all))

#################

N,M = LI()
A = LI()

count = 0
s = sum(A)
for i in range(N):
    if A[i]>=s/(4*M):
        count += 1
if count >= M:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 38384
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2, gcd, floor
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7
#import numpy as np
from decimal import *
 
A, B = MAP()
A = int(A)
b = ""
for x in B:
	if x != ".":
		b += x

b = int(b)
print(A*b//100)

Measured memory_bytes: 10544
#include <iostream>
#include <algorithm>
using namespace std;
int main(){
	int a,b,c;
	while(cin>>a>>b){
		if(a==0)break;
		if(a==1)c=b;
		if(a==2)c=31+b;
		if(a==3)c=60+b;
		if(a==4)c=91+b;
		if(a==5)c=121+b;
		if(a==6)c=152+b;
		if(a==7)c=182+b;
		if(a==8)c=213+b;
		if(a==9)c=244+b;
		if(a==10)c=274+b;
		if(a==11)c=305+b;
		if(a==12)c=335+b;
		if(c%7==1)cout<<"Thursday"<<endl;
		if(c%7==2)cout<<"Friday"<<endl;
		if(c%7==3)cout<<"Saturday"<<endl;
		if(c%7==4)cout<<"Sunday"<<endl;
		if(c%7==5)cout<<"Monday"<<endl;
		if(c%7==6)cout<<"Tuesday"<<endl;
		if(c%7==0)cout<<"Wednesday"<<endl;
	}
    return 0;
    }


Measured memory_bytes: 3104
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
int main()
{
    ll n,i,j,k,sum=0,f=0;
    vector<ll>v;
    cin>>n;
    for(i=0;i<n;i++)
    {
        cin>>k;
        v.push_back(k);
        sum+=k;
    }
    if(sum%10!=0)
    {
        cout<<sum<<endl;
    }
    else
    {
        sort(v.begin(),v.end());
        for(i=0;i<n;i++)
        {
            if((sum-v[i])%10!=0)
            {
                f=1;
                cout<<sum-v[i]<<endl;
                break;
            }
        }
        if(f==0)
        {
            cout<<0<<endl;
        }
    }
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    int result;
    Scanner sc = new Scanner(System.in);
    int numX = sc.nextInt();
    int numA = sc.nextInt();
    result = numX < numA ? 0 : 10;
    System.out.println(result);
    sc.close();
  }
}

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

void bfs(int N, vector<vector<int>> to,vector<vector<int>> cost) {
    queue<int> que;
    ans[0] = 0;
    que.push(0);

    while(!que.empty()){
        int v = que.front();
        que.pop();
        rep(i,to[v].size()){
            int u = to[v][i];
            int w=cost[v][i];
            if(ans[u]!=-1) continue;
            ans[u] = (ans[v]+w)%2;
            que.push(u);
        }
    }
}

int main() {
    // 制約見て！！！デカかったらlong longにすること！
    int N;
    cin >> N;
    vector<vector<int>> to(N),cost(N);
    rep(i, N-1) {
        int a, b, w;
        cin >> a >> b >> w;
        a--;
        b--;
        to[a].push_back(b); cost[a].push_back(w);
        to[b].push_back(a); cost[b].push_back(w);
    }
    ans.resize(N);
    ans.assign(N,-1);
    bfs(N,to,cost);
    for(int i : ans){
        cout << i << endl;
    }
}

Measured memory_bytes: 22656
# N = int(input())
# N = map(int,input().split())
# N = list(map(int,input().split()))

N,R = map(int,input().split())

if N>= 10:
    print(R)
else:
    print(R+100*(10-N))




# if :
#     print("YES")
# else:
#     print("NO")

# if :
#     print("Yes")
# else:
#     print("No")

Measured memory_bytes: 2940
n, q = list(map(int, input().split()))

adj = [[] for _ in range(n)]

for i in range(n-1):
    a, b = list(map(int, input().split()))

    adj[b-1].append(a-1)
    adj[a-1].append(b-1)

cnt = [0] * n
for i in range(q):
    p, x = list(map(int, input().split()))

    cnt[p-1] += x

counter = [0] * n
visited = [True] + [False] * (n-1)
visit = [0]

while len(visit) > 0:
    node = visit.pop()
    counter[node] += cnt[node]

    for adjNode in adj[node]:
        if visited[adjNode] == False:
            visited[adjNode] = True
            visit.append(adjNode)

            counter[adjNode] += counter[node]

print(" ".join(map(str, counter)))

Measured memory_bytes: 77744
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] A = new int[N];
		int cnt = 0;
		for (int i = 0; i < N; i++) {
			A[i] = sc.nextInt();
		}
		while (true) {
			for (int i = 0; i < N; i++) {
				if (A[i] % 2 == 0)
					A[i] /= 2;
				else {
					System.out.println(cnt);
					return;
				}
			}
			cnt++;
		}
	}

}

Measured memory_bytes: 21716
#include <iostream>
#include<cstring>
using namespace std;

int main()
{
   char a[20];
   cin>>a;
   int num=0;int flag=0;
   int len=strlen(a);
    for(int i=2;i<len-1;i++)
        if(a[i]=='C')   num++;
    for(int i=0;i<len;i++)
    {
       // if(a[i]=='C')   num++;
            if(a[i]>='A'&&a[i]<='Z')    flag++;
    }
    if(a[0]!='A'||num!=1||flag!=2)
        cout<<"WA";
    else cout<<"AC";
    return 0;
}

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

int main(void) {
  int N, H;
  cin >> N >> H;
  vector<int> a(N), b(N);
  
  for(int i = 0; i < N; i++) {
    cin >> a[i] >> b[i]; 
  }
  sort(a.begin(), a.end());
  sort(b.begin(), b.end());
 
  int damage = 0;
  int attack_cnt = 0;
  for(int i = 0;i < N; i++) {
    if(b[N - 1 - i] > a[N-1]) {
	  damage += b[N - 1 - i];
      attack_cnt++;
      if(damage >= H) {
        cout << attack_cnt << endl;
        return 0;
      }
    }
  }
  
  int remain = H - damage;
  for(int i = 0;;i++) {
    remain -= a[N-1];
    attack_cnt++;
    if(remain <= 0) {
     cout << attack_cnt << endl; 
      return 0;
    }
  }
  return 0; 
}

Measured memory_bytes: 1024
#include <iostream>

using namespace std;

int main(void){
  long long int min, max, n, i, x;
  cin >> n;
  cin >> x;
  min = x;
  max = x;
  for(i = 1; i < n; i++){
    cin >> x;
    if(x < min){
      min = x;
    }else if(x > max){
      max = x;
    }
  }
  cout << max - min << endl;
  return 0;
}
  

Measured memory_bytes: 256
let _ = read_line() in
let xs = read_line() |> Str.split (Str.regexp " ") |> List.map int_of_string in
let rec f (mi, ma, sum) x = ((min mi x), (max ma x), (x + sum)) in
let (min', max', sum') = List.fold_left f (1000000, (-1000000), 0) xs in
Printf.printf "%d %d %d\n" min' max' sum';


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

using namespace std;
using ll = long long;

int main(int argc, const char *argv[]) {
  ll n, h;
  cin >> n >> h;

  vector<ll> vb(n), va(n);
  for (int i = 0; i < n; ++i) {
    cin >> va[i] >> vb[i];
  }

  sort(vb.begin(), vb.end(), greater<ll>());
  sort(va.begin(), va.end(), greater<ll>());

  ll ans = 0;
  for (int i = 0; i < vb.size() && vb[i] >= va.front() && h > 0; i++) {
    h -= vb[i];
    ans++;
  }

  while (h > 0) {
    ans++;
    h -= va.front();
  }

  cout << ans << '\n';
  return 0;
}


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

void solve(int a){
	int m = 1e9;
	for(int i=0; i*i*i<=a; ++i)
		for(int j=0; i*i*i+j*j<=a; ++j)
			m = min(m, i + j + a - i*i*i - j*j);
	cout << m << "\n";
}

int main(){
//	cin.tie(0);
//	ios::sync_with_stdio(false);
	while(1){
		int a;
		cin >> a;
		if(a == 0) return 0;
		solve(a);
	}
}


Measured memory_bytes: 3096
#include <bits/stdc++.h>
using i64 = long long;

std::vector<std::set<int>> g, r;

int main() {
    int n, m;
    std::cin >> n >> m;
    g.resize(n);
    r.resize(n);
    for (int i = 0; i < n + m - 1; i++) {
        int a, b;
        std::cin >> a >> b;
        a--; b--;
        g[a].insert(b);
        r[b].insert(a);
    }
    int root;
    for (int i = 0; i < n; i++) {
        if (r[i].size() == 0) {
            root = i;
            break;
        }
    }

    std::vector<int> ret(n), depth(n);
    ret[root] = -1;
    depth[root] = 1;
    std::deque<int> q { root };
    while (!q.empty()) {
        auto v = q.front();
        q.pop_front();
        for (auto c : g[v]) {
            // if (r[c].size() <= depth[v]) {
            //     q.push_back(c);
            //     ret[c] = v;
            //     depth[c] = depth[v] + 1;
            // }
            ret[c] = v;
            depth[c] = depth[v] + 1;
            r[c].erase(v);
            if (r[c].size() == 0) q.push_back(c);
        }
    }

    for (int i = 0; i < n; i++) std::cout << ret[i] + 1 << std::endl;

    return 0;
}


Measured memory_bytes: 22656
using System;
using System.Linq;
using System.Numerics;

namespace _169_b
{
    internal class Multiplication2
    {
        private static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine() ?? throw new InvalidOperationException());
            var a = Console.ReadLine()?.Split(" ").Select(long.Parse).ToArray();
            if (a == null) return;

            if (a.Contains(0))
            {
                Console.WriteLine(0);
                return;
            }

            BigInteger result = 1;
            for (var i = 0; i < n; i++)
            {
                result *= a[i];
                if (result > 1000000000000000000)
                {
                    Console.WriteLine(-1);
                    return;
                }
            }

            Console.WriteLine(result);
        }
    }
}

Measured memory_bytes: 41932
import numpy as np
N, W = map(int, input().split())
dp = np.full(N * 10000 + 1, W + 1) 
dp[0] = 0
for n in range(N):
    w, v = map(int, input().split())
    dp[v:] = np.minimum(dp[v:], dp[:-v] + w)

print(np.max(np.where(dp <= W)))

Measured memory_bytes: 37916
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1e9;
const ll mod = 1e9+7;
typedef pair<int,int> P;
#define rep(i,N) for(int i=0;i<N;i++)
#define rep2(i,m,N) for(int i=m;i<N;i++)
#define mm(n,m) memset(n,m,sizeof(n))

int main(){
    ll n,k;
    cin>>n>>k;
    string s;
    cin>>s;
    ll ans = 0;
    ll cnt = 0;
    if(n<k)k=n;
    rep(i,n-1){
        if(s[i+1]==s[i])ans++;
    }
    ans += k*2;
    if(ans>n-1)ans=n-1;
    cout<<ans<<endl;
}

Measured memory_bytes: 512
/// input macro from https://qiita.com/tanakh/items/1ba42c7ca36cd29d0ac8
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 , usize1 ) => {read_value ! ($ next , usize ) - 1 } ; ($ next : expr , $ t : ty ) => {$ next () . parse ::<$ t > () . expect ("Parse error" ) } ; }
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 ! 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 ) * } } ; }
fn main() {
    input!(n: u64, a: [u64; n as usize]);

    let mut buy = 0;
    let mut sell = 0;

    let mut money = 1000;

    while buy + 1 < n as usize {
        while (buy + 1 < n as usize) && (a[buy] >= a[buy + 1]) {
            buy += 1;
        }

        sell = buy.clone() + 1;
        while (sell + 1 < n as usize) && (a[sell] <= a[sell + 1]) {
            sell += 1;
        }

        if (buy < n as usize) && (sell < n as usize) {
            let count = money / a[buy];
            money = money % a[buy] + count * a[sell];
        }

        buy = sell + 1;
    }
    println!("{}", money);
}


Measured memory_bytes: 2132
#N=gets.to_i
#S=gets.chomp
#A=(0...N).map{gets.to_i}
#sum=A.inject(&:+)
#B=gets.split.map(&:to_i)
 
$counter=0
def test(states,switch,ps)
  if states.size<N
    test(states+[0],switch,ps)
    test(states+[1],switch,ps)
  else
    flag=true
    M.times do |i|
      onsum=0
      N.times do |j|
        onsum+=1 if switch[i][j] && states[j]==1
      end
      flag=false if onsum%2!=ps[i]
    end
    $counter+=1 if flag
  end
end

N,M=gets.split.map(&:to_i)
switch=Array.new(M){Hash.new(false)}
M.times.map do |i|
  k,*other=gets.split
  other.map(&:to_i).each do |j|
    switch[i][j-1]=true
  end
end
ps=gets.split.map(&:to_i)

test([],switch,ps)
puts $counter

Measured memory_bytes: 3964
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>

int main(int argc, char* argv[])
{
    long n;
    scanf("%ld", &n);

    long sum = 0;
    std::vector<long> a(n);
    long i;
    for(i=0; i<n; i++) {
        scanf("%ld", &(a[i]));
        sum += (a[i]-1);
    }

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

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i, n) FOR(i, 0, (n))
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define LAR(a, b) ((a)=max((a),(b)))
#define SML(a, b) ((a)=min((a),(b)))
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pair<int, int>> vpii;
typedef pair<int, int> pii;
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define ALL(a) (a).begin(), (a).end()
#ifdef LOCAL_DEBUG
#define DEBUG(...) printf(__VA_ARGS__)
#else
#define DEBUG(...)
#endif

int main(){
	int r; scanf("%d", &r); printf("%d\n", r*r);
}


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

using namespace std;
using ll = long long int;
constexpr ll M = 1e9 + 7;
inline ll sum_1(const ll n) { return ((n * (n + 1)) / 2) % M; }
inline ll sum_2(const ll n) { return ((n * (n + 1) * (2 * n + 1)) / 6) % M; }
inline ll sum_3(const ll n) { return (((n * (n + 1)) / 2) % M * ((n * (n + 1)) / 2) % M) % M; }
inline ll sum_1(const ll i, const ll j) { return (sum_1(j) - sum_1(i - 1) + M) % M; }
inline ll sum_2(const ll i, const ll j) { return (sum_2(j) - sum_2(i - 1) + M) % M; }
inline ll sum_3(const ll i, const ll j) { return (sum_3(j) - sum_3(i - 1) + M) % M; }

ll pow_f(ll b, ll e) {
    ll ans = 1;
    b = b % M;
    while (e) {
        if (e&1) {
            ans = (ans * b) % M;
        }
        b = (b * b) % M;
        e >>= 1;
    }
    return ans;
}

ll nCr(ll n, ll r) {
    if (r > n || n < 0 || r < 0) { return 0; }
    if (n == r || r == 0) { return 1; }
    r = min(r, n-r);
    ll ans = 1;
    for (ll i = 1; i <= r; ++i) {
        ans = (ans * (n-i+1))/(i); 
    }
    return ans;
}

ll nCr(tuple<ll,ll> t) {
    auto n = get<0>(t);
    auto k = get<1>(t);
    return nCr(n+k-1, k);
}

template<typename T>
void print(T v) {
    cout << v << " ";
}

template<typename T>
void print(vector<T> v) {
    for (auto &i : v) {
        print(i);
    }
    cout << endl;
}

void solve() {
    int n, m;
    cin >> n >> m;
    cout << nCr(n, 2) + nCr(m, 2) << endl;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    #ifdef D_LOCAL
        freopen("in.in", "r", stdin);
        freopen("out.out", "w", stdout);
    #endif

    solve();

    return 0;
}

Measured memory_bytes: 256
import copy


def check(l):
    return l[0] == l[1] == l[2]


lst = []
for _ in range(3):
    lst.append([int(x) for x in input().split()])

for i in range(3):
    l = copy.deepcopy(lst)

    l[0][0] -= i
    l[0][1] -= i
    l[0][2] -= i
    if l[0][0] < 0 or l[0][1] < 0 or l[0][2] < 0:
        continue

    b1 = l[0][0]
    b2 = l[0][1]
    b3 = l[0][2]

    l[1][0] -= b1
    l[1][1] -= b2
    l[1][2] -= b3
    l[2][0] -= b1
    l[2][1] -= b2
    l[2][2] -= b3

    if check(l[1]) and check(l[2]):
        print("Yes")
        exit()

print("No")


Measured memory_bytes: 3444