akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <sstream>
#include <cstdio>
#include <fstream>

using namespace std;

struct P{double x,y;};

void output(double x,double y)
{
	printf("%.6lf %.6lf\n",x,y);
}

int main(){

//	cut here before submit 
//	freopen ("testcase.sp", "r", stdin );

	string str = "";

	while (getline(cin,str) ){

		while (str.find(',') != string::npos ){
			str = str.replace (str.find(','), 1, " " );
		} // end while
		P a,b,q;
		stringstream ss (str );
		ss >> a.x >> a.y >> b.x >> b.y >> q.x >> q.y;
		
		double x , y , X = b.x - a.x, Y = b.y - a.y;
		if (X == 0 ){
			output(2*a.x-q.x,q.y );
		}else if (Y == 0 ){
			output(q.x,2*a.y-q.y );
		}else{
			x = ( q.y -a.y + (Y/X)*a.x + (X/Y)*q.x ) / ( (X*X+Y*Y)/(X*Y) );
			y = (Y/X)*(x-a.x) + a.y;
			output(2*x-q.x,2*y-q.y );
		}
	}

	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include<numeric>
#include<cmath>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const int maxn = 1100000;


int main(){
    //cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	//cout << fixed << setprecision(15);
    vector<int> tetra, tetra_odd;
    int i = 0;
    while(i *(i+1)*(i+2) / 6 < 1100000){
        i++;
        int a = i *(i+1)*(i+2) / 6;
        tetra.push_back(a);
        if(i % 4 == 1) tetra_odd.push_back(a);
    }
    /*REP(i,7){
        cout << tetra_odd[i] << endl;
    }*/
    vector<int> dp(maxn+1);
    vector<int> dp_odd(maxn+1);
    dp[0] = 0;
    dp[1] = 1;
    FOR(i,2,maxn+1){
        dp[i] = dp[i-1] + 1;
        int j = 0;
        while(tetra[j] <= i && j < tetra.size()){
            dp[i] = min(dp[i], dp[i - tetra[j]] + 1);
            j++;
        }
    }

    dp_odd[0] = 0;
    dp_odd[1] = 1;
    /*REP(i,maxn+1){
        dp_odd[i] = i;
    }*/
    FOR(i,2,maxn){
        dp_odd[i] = dp_odd[i-1] + 1;
        int j = 0;
        while(j < tetra_odd.size()){
            if(tetra_odd[j] <= i) dp_odd[i] = min(dp_odd[i], dp_odd[i - tetra_odd[j]] + 1);
            //else break;
            j++;
        }
    }
    /*REP(i,40){
        cout << dp_odd[i] << endl;
    }*/

    vector<int> ans1,ans2;
    while(true){
        int N; cin >> N;
        if(N == 0){
            REP(i,ans1.size()){
                cout << ans1[i] << " " <<  ans2[i] << endl;
            }
            return 0;
        }
        else{
            ans1.push_back(dp[N]);
            ans2.push_back(dp_odd[N]);
        }
    }
}



Measured memory_bytes: 11364
#include <iostream>

using namespace std;
typedef long long ll;

constexpr ll INF = 1000000000000000005;

int n, maxw;
int weight[105], value[105];

ll dp[105][100005];

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cin >> n >> maxw;
	for (int i = 1; i <= n; ++i) {
		cin >> weight[i] >> value[i];
	}
	for (int i = 0; i <= n; ++i) {
		for (int j = 0; j <= 1000*n; ++j) {
			dp[i][j] = INF;
		}
	}
	dp[0][0] = 0;
	for (int i = 1; i <= n; ++i) {
		for (int j = 0; j <= 1000*n; ++j) {
			dp[i][j] = dp[i-1][j];
			if (j-value[i] >= 0) {
				dp[i][j] = min(dp[i][j], dp[i-1][j-value[i]]+weight[i]);
			}
		}
	}
	int res = 0;
	for (int j = 0; j <= 1000*n; ++j) {
		if (dp[n][j] <= maxw) {
			res = max(res, j);
		}
	}
	cout << res << "\n";
	return 0;
}

/*
	dp[i][j] = min weight with prefix 1..i and value j
	dp[i][j] = min(dp[i-1][j], dp[i-1][j-value[i]]+weight[i])
*/


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

int main() {
    int h, w;
    cin >> h >> w;

    vector<vector<char>> a(h, vector<char>(w));
    rep(i,h) {
        rep(j,w) {
            cin >> a.at(i).at(j);
        }
    }

    vector<bool> wdel(w,false);
    rep(j,a.at(0).size()) {
        int wpos=j;
        rep(i,a.size()) {
            if (a.at(i).at(j)=='#') {
                wpos=-1;
                break;
            }
        }
        if (wpos != -1) wdel.at(wpos)=true;
    }

    vector<bool> hdel(h,false);
    rep(i,a.size()) {
        int hpos=i;
        rep(j,a.at(0).size()) {
            if (a.at(i).at(j)=='#') {
                hpos=-1;
                break;
            }
        }
        if (hpos != -1) hdel.at(hpos)=true;
    }

    rep(i,a.size()) {
        if (hdel.at(i)) continue;
        rep(j,a.at(0).size()) {
            if (wdel.at(j)) continue;
            cout << a.at(i).at(j);
        }
        cout << endl;
    }

    return 0;
}

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

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

	int Q = 0;
	int answer = 0;

	for (int i = 0; i < S.size(); i++) {
		if (S[i] == 'A' || S[i] == 'C' || S[i] == 'G' || S[i] == 'T') Q++;
		else Q = 0;
		if (answer < Q) {
			answer = Q;
		}
	}

	cout << answer << endl;
}

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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define POW(n) ((n)*(n))
#define ALL(a) (a).begin(),(a).end()
#define cerr if(false) cerr
 
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
 
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<unsigned long long> vull;

void solve(long long A, long long B, long long C){
	if(A % 2 == 0 || B % 2 == 0 || C % 2 == 0){
		cout << 0 << endl;
	}else{
		ll l[3] = {A,B,C};
		sort(l,l+3);
		cout << l[0]*l[1] << endl;
	}
}



int main(){	
	ios::sync_with_stdio(false);
	long long A;
	long long C;
	long long B;
	cin >> A;
	cin >> B;
	cin >> C;
	solve(A, B, C);
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int N, Q;
char S[500010];
set<int> s[26];
set<int>::iterator v[500010];
int main () {
    scanf("%d%s%d", &N, S, &Q);
    for (int i = 0; i < N; i++) {
        v[i] = s[S[i]-'a'].insert(i).first;
    }
    for (; Q; Q--) {
        int a;
        scanf("%d", &a);
        if (a == 1) {
            int i;
            char c;
            scanf("%d %c", &i, &c);
            i--;
            s[S[i]-'a'].erase(v[i]);
            S[i] = c;
            v[i] = s[S[i]-'a'].insert(i).first;
        }
        else {
            int l, r;
            scanf("%d%d", &l, &r);
            l--, r--;
            int x = 0;
            for (int j = 0; j < 26; j++) {
                auto ll = s[j].lower_bound(l);
                if (ll != s[j].end() && (*ll) <= r) {
                    x++;
                }
            }
            printf("%d\n", x);
        }
    }
}

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

using namespace std;
int main()
{
    int a,b,c;
    cin>>a>>b>>c;

    if(a==b && b==c)
    {
        cout<<"No"<<endl;
    }
    else if(a==b || b==c || c==a)
    {
         cout<<"Yes"<<endl;
    }
    else
    {
        cout<<"No"<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rrep(i, n) for (int i = (n - 1); i >= 0; i--)
#define ALL(v) v.begin(), v.end()
using namespace std;
using P = pair<int, int>;
typedef long long ll;

int main() {
  int n;
  cin >> n;
  vector<int> L(n);
  rep(i, n) cin >> L[i];
  sort(ALL(L));
  int ans = 0;
  rep(i, n) {
    for (int j = i + 1; j < n; j++){
      for (int k = j + 1; k < n; k++){
        if(L[i] + L[j] <= L[k])continue;
        if(L[i] == L[j])continue;
        if(L[j] == L[k])continue;
        ans++;
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 3608
# C - Cat Snuke and a Voyage

n,m = map(int,input().split())
a = [0]*m
b = [0]*m
l = [0]*200000
s = "IMPOSSIBLE"

for i in range(m):
    a[i],b[i] = map(int,input().split())


for i in range(m):
    if (a[i] == 1):
        if (l[b[i]] == 1):
            s = "POSSIBLE"
            break
        else : l[b[i]] = 1
    if (b[i] == n):
        if (l[a[i]] == 1):
            s = "POSSIBLE"
            break
        else : l[a[i]] = 1

print(s)

Measured memory_bytes: 20340
#include<iostream>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<string>
#include<vector>
#include<set>
#include<cctype>
using namespace std;
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
const long long INF = 1LL << 60;

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

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

int main(){
	int N;
	cin >> N;
	vector <long> A(N);
	for (int i = 0; i < N; i++) cin >> A.at(i);
	sort(A.begin(), A.end());
	long now = A.at(0);
	string ans = "YES";
	for (int i = 1; i < N; i++){
		if (now == A.at(i)){
			ans = "NO";
			break;
		}
		else now = A.at(i);
	}
	cout << ans << endl;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define rep(i,N) for (int i = 0; i < (N); ++i)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int inf{int(1e9)};
int main(void){
  double D, T, S;
  cin >> D >> T >> S;

  double time = D / S;
  if (time <= T) cout << "Yes" << endl;
  else cout << "No" << endl;
}


Measured memory_bytes: 3720
#!/usr/bin/perl
my ($n,$k) = map { $_ - 0 } split(/\s+/,<STDIN>);
my @p = map { $_ - 0 } split(/\s+/,<STDIN>);

my @t = ();
$#t = 1+$#p;
$t[0] = 0;
for(my $i = 0; $i<$n;$i++){
  my $pp = $p[$i];
  $t[$i+1] = $t[$i] + ( 0.5 * (1 + $pp) );
}

my $mx = -1;
for(my $i = $k; $i<=$n;$i++){
  my $s = $t[$i] - $t[$i - $k];
  $mx = $s if $s - 0 > $mx;
}
print "$mx\n";



Measured memory_bytes: 40396
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <queue>
#define MOD (1000000007l)
#define rep(i, n) for(long i = 0; i < (n); i++)

using namespace std;

void solve() {
  long sx, sy, tx, ty;
  cin >> sx >> sy >> tx >> ty;
  rep (i, tx-sx) cout << 'R';
  rep (i, ty-sy) cout << 'U';
  rep (i, tx-sx) cout << 'L';
  rep (i, ty-sy) cout << 'D';

  cout << 'D';
  rep (i, tx-sx+1) cout << 'R';
  rep (i, ty-sy+1) cout << 'U';
  cout << 'L';
  cout << 'U';
  rep (i, tx-sx+1) cout << 'L';
  rep (i, ty-sy+1) cout << 'D';
  cout << 'R';
  cout << endl;
}

int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout.precision(12);
  solve();
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPS(i, _s, n) for(int i = _s, i##_len = (n); i < i##_len; ++i)
#define ALL(x) (x).begin(), (x).end()
using namespace std;

#define repi(itr, ds) for(auto itr = ds.begin(); itr != ds.end(); itr++)
// vector
template <typename T>
istream &operator>>(istream &is, vector<T> &vec) {
  for(T &x : vec) is >> x;
  return is;
}
// pair
template <typename T, typename U>
ostream &operator<<(ostream &os, pair<T, U> &pair_var) {
  os << "(" << pair_var.first << ", " << pair_var.second << ")";
  return os;
}
// vector
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
  os << "{";
  for(int i = 0; i < vec.size(); i++) {
    os << vec[i] << (i + 1 == vec.size() ? "" : ", ");
  }
  os << "}\n   ";
  return os;
}
// map
template <typename T, typename U>
ostream &operator<<(ostream &os, map<T, U> &map_var) {
  os << "{";
  repi(itr, map_var) {
    os << *itr;
    itr++;
    if(itr != map_var.end()) os << ", ";
    itr--;
  }
  os << "}";
  return os;
}
// set
template <typename T>
ostream &operator<<(ostream &os, set<T> &set_var) {
  os << "{";
  repi(itr, set_var) {
    os << *itr;
    itr++;
    if(itr != set_var.end()) os << ", ";
    itr--;
  }
  os << "}";
  return os;
}

#define DUMPOUT cerr

void dump_func() { DUMPOUT << endl; }
template <class Head, class... Tail>
void dump_func(Head &&head, Tail &&... tail) {
  DUMPOUT << head;
  if(sizeof...(Tail) > 0) {
    DUMPOUT << ", ";
  }
  dump_func(std::move(tail)...);
}
#ifdef DEBUG_
#define DEB
#define dump(...)                                                             \
  DUMPOUT << "  " << string(#__VA_ARGS__) << ": "                             \
          << "[" << to_string(__LINE__) << ":" << __FUNCTION__ << "]" << endl \
          << "    ",                                                          \
      dump_func(__VA_ARGS__)
#else
#define DEB if(false)
#define dump(...)
#endif

typedef long long int ll;

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

vector<pair<long long, long long>> prime_factorize(long long n) {
  vector<pair<long long, long long>> res;
  for(long long p = 2; p * p <= n; ++p) {
    if(n % p != 0) continue;
    int num = 0;
    while(n % p == 0) {
      ++num;
      n /= p;
    }
    res.push_back(make_pair(p, num));
  }
  if(n != 1) res.push_back(make_pair(n, 1));
  return res;
}

int main() {
  ll A, B;
  cin >> A >> B;
  ll g = gcd(A, B);
  auto primes = prime_factorize(g);
  ll ans = primes.size() + 1;
  cout << ans << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
  int n,h[110],ans=1;
  scanf("%d",&n);
  for(int i=0;i<n;i++){
    scanf("%d",&h[i]);
    if(i!=0){
      for(int j=i;j>=0;j--){
        if(h[i]<h[j]){
          ans--;
          break;
        }
      }
      ans++;
    }
  }
  printf("%d",ans);
  return 0;
}


Measured memory_bytes: 128
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s=sc.next();
        if(s.equals("AAA")||s.equals("BBB")){
            System.out.println("No");
        }else{
            System.out.println("Yes");
        }
        
        
 
    }



}

Measured memory_bytes: 21844
/*
	Copyright: razouq (c)
	Author: Anass BENDARSI
	Date: 09/06/2017 13:05:45
	flamers will **** you
*/
#include<bits/stdc++.h>
//#include<flamers.h>
#define ull unsigned long long
using namespace std;

int main(){
	int n;
	bool flag = true;
	cin>>n;
	vector<int> vect(n);
	int sum = 0;
	for(int i = 0; i < n; ++i){
		cin>>vect[i];
		sum += vect[i];
	}
//	cout<<sum<<endl;
	sort(vect.begin(), vect.end());
	if(sum % 10 != 0) cout<<sum<<endl;
	else
	for(int i = 0; i < n; ++i){
		if((sum - vect[i]) % 10 != 0){
			 cout<<sum-vect[i]<<endl;
			 flag = false;
			 break;
		}
	}
	if(sum % 10 == 0 && flag) cout<<0<<endl;
	return 0;
}


Measured memory_bytes: 256
//#include <bits/stdc++.h>
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <stdio.h>
#include <queue>
#include <deque>
#include <set>
#include <stack>
#include <time.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;

#define fi first
#define se second
#define mp make_pair
 
const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll INF = 1ll << 60;
const double PI = 2 * asin(1);

void yes() {printf("yes\n");}
void no() {printf("no\n");}
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

int N, A[int(2e5 + 5)];
vector <int> Graph[int(2e5 + 5)];
int DP[int(2e5 + 5)], ans[int(2e5 + 5)];


int DFS(int node){
  int Index, Before;
  if (A[node] <= DP[0]){
    Index = 0; Before = DP[0];
    DP[0] = A[node];
  }else{
    int L = 0, R = N;
    while (R - L > 1){
      int Mid = (L + R) / 2;
      if (DP[Mid] < A[node]) L = Mid;
      else R = Mid;
    }
    Index = R; Before = DP[R];
    DP[R] = A[node];
  }

  int L = 0, R = N;
  while (R - L > 1){
    int Mid = (L + R) / 2;
    if (DP[Mid] > 1e9) R = Mid;
    else L = Mid;
  }
  ans[node] = L + 1;

  for (int i = 0; i < Graph[node].size(); i++){
    int next = Graph[node][i];
    if (ans[next] != 0) continue;
    DFS(next);
  }
  
  DP[Index] = Before;
  return 0;
}

int main(){
  scanf("%d", &N);
  for (int i = 0; i < N; i++) scanf("%d", A + i);

  for (int i = 0; i < N - 1; i++){
    int U, V; scanf("%d%d", &U, &V);
    U--; V--;
    Graph[U].push_back(V);
    Graph[V].push_back(U);
  }

  fill(DP, DP + N + 1, 2e9);
  DFS(0);

  for (int i = 0; i < N; i++) printf("%d\n", ans[i]);
  
  return 0;
}


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

typedef long long ll;


int main() {
    int N, K;
    ll ans = 0;
    cin >> N >> K;

    ll cnt = 0;
    if (K % 2 == 0) {
        ll cnt2 = 0;
        for (int i = 1; i <= N; i++) {
            if (i % K == 0) {
                cnt++;
            } else if (i % K == K/2) {
                cnt2++;
            }
        }
        ans += pow(cnt, 3);
        ans += pow(cnt2, 3);
        cout << ans << endl;
    } else {
        for (int i = 1; i <= N; i++) {
            if (i % K == 0) {
                cnt++;
            }
        }
        ans += pow(cnt, 3);
        cout << ans << endl;
    }
}


Measured memory_bytes: 256
#[allow(unused_macros)]
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)*}
    };
}

#[allow(unused_macros)]
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)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

use std::io::*;
use std::str::FromStr;

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

#[allow(dead_code)]
fn readu() -> usize {
    read::<usize>()
}

#[allow(dead_code)]
fn readi() -> i32 {
    read::<i32>()
}

fn main() {
    input! {
        n: usize,
        d: usize,
    }
    let w = d * 2 + 1;
    println!("{}", (n + w - 1) / w);
}


Measured memory_bytes: 4352
import heapq

INF = 1 << 60
MOD = 1000000007

def dijkstra(s):
    #print(s)
    global d, G, n
    d = [INF] * n
    d[s] = 0
    que = [(0, s)]
    heapq.heapify(que)

    while len(que) > 0:
        #print("que=", que)
        p = heapq.heappop(que)
        v = p[1]
        #print(v)
        if d[v] < p[0]:
            continue
        for e in G[v]:
            if d[e[0]] > d[v] + e[1]:
                d[e[0]] = d[v] + e[1]
                heapq.heappush(que, (d[e[0]], e[0]))

n, m, s, t = map(int, input().split())
u = [0] * m
v = [0] * m
a = [0] * m
b = [0] * m
G = []
for i in range(n):
    G.append([])
for i in range(m):
    u[i], v[i], a[i], b[i] = map(int, input().split())
    G[u[i] - 1].append((v[i] - 1, a[i]))
    G[v[i] - 1].append((u[i] - 1, a[i]))
#print("G=", G)
d = [0] * n
dijkstra(s - 1)
#print("d=", d)
ds = d[:]
G = []
for i in range(n):
    G.append([])
for i in range(m):
    G[u[i] - 1].append((v[i] - 1, b[i]))
    G[v[i] - 1].append((u[i] - 1, b[i]))
d = [0] * n
dijkstra(t - 1)
dst = []
for i in range(n):
    dst.append((d[i] + ds[i], i))
dst.sort()
change = 0
money = 1000000000000000
for i in range(n):
    while dst[change][1] < i:
        change += 1
    print(money - dst[change][0])

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

#define rep(i,n) for(ll i = 0; i < n; i++)
#define Rep(i,n) for(ll i = 0; i <= n; i++)
#define REp(i,n) for(ll i = 1; i < n; i++)
#define REP(i,n) for(ll i = 1; i <= n; i++)
#define sz(x) int(x.size())
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define YesorNo(a) printf(a ? "Yes\n" : "No\n")
#define endl '\n'
#define fi first
#define se second
using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
template<class T> using V = vector<T>;
const int dx[] = {0,1,0,-1,1,1,-1,-1};
const int dy[] = {1,0,-1,0,1,-1,-1,1};
const int inf = (1<<30)-1;
const ll infll = (1LL<<62)-1;
ll ceil(const ll &a, const ll &b){return ((a)+(b)-1)/b;}
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; }



int main(){
  string s;
  cin >> s;
  V<string> h = {"dream", "dreamer", "erase", "eraser"};
  while(sz(s)) {
    bool ok = false;
    rep(ci,4) {
      int m = sz(h[ci]);
      int i = sz(s);
      if(m > sz(s)) continue;
      if(s.substr(i-m) == h[ci]) {
        s.erase(i-m);
        ok = true;
      }
    }
    if(!ok) {
      cout << "NO" << endl;
      return 0;
    }
  }
  cout << "YES" << endl;
}

Measured memory_bytes: 3764
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
#define rep(i,n) for (ll i=0;i<n;++i)
#define rep2(i,a,b) for (ll i=a;i<b;++i)
const ll MOD=1e9+7;
const ll INF=1e9;
const ll IINF=1e18;
const double EPS=1e-8;
const double pi=acos(-1);

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;
}

int main(){
    int N,K,Q;
    cin >> N >> K >> Q;
    vector<ll> A(N);
    rep(i,N) cin >> A[i];
    ll ans=INF;
    rep(i,N){
        priority_queue<ll,vector<ll>,greater<ll>> pq; 
        int now=0;
        while(now<N){
            priority_queue<ll,vector<ll>,greater<ll>> pq2;
            while(now<N&&A[i]<=A[now]){
                pq2.push(A[now]);
                ++now;
            }
            ++now;
            while(pq2.size()>=K){
                pq.push(pq2.top());
                pq2.pop();
            }
        }
        if (pq.size()<Q) continue;
        rep(j,Q-1) pq.pop();
        ll maximum=pq.top();
        chmin(ans,maximum-A[i]);
    }
    cout << ans << endl;
}

Measured memory_bytes: 384
// Ryo Kamoi

#include<iostream>
#include<math.h>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<queue>
#include<set>

using namespace std;

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

typedef long long ll;

typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;

int INF = 1000000000;

int r, d, x;
int main(){
  cin >> r >> d >> x;
  REP(i, 10) {
    x = r*x - d;
    cout << x << endl;
  }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl; 
#define INF 1000000000
#define mod 1000000007
using ll=long long;
const ll LINF = 1001002003004005006ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

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

    ll h,ans=0,beki=1;
    cin>>h;
    while(h>0){
        ans+=beki;
        h/=2;
        beki*=2;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <math.h>
#include<iostream>
#include <string>
using namespace std;
typedef long long ll;
#define pb pushback
#define fr(i,n) for(int i=0;i<n;i++)
#define ifr(i,n) for(int i=n-1;i>=0;i--)


int main() {
    int x;
	cin >> x;
    string ans;
    if(x/1000==(x/100)%10||(x/10)%10==(x/100)%10||(x/10)%10==x%10)ans="Bad";
    else ans = "Good";
      cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <cmath>
#include <numeric>
using namespace std;
#define rep(i,a,b) for(int64_t i=(a); i<(b); ++i) // a ≦ i < b 
#define Rrep(i,a,b) for(int64_t i=(a);i>=(b);--i) // reverse repeat. a から b まで減少．
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend() //逆イテレータ
#define RANGE(a,b,c) (a).begin()+b,(a).begin()+c // コンテナ a の 要素 b から c へのイテレータ
#define MOD 1000000007
#define INF 1000000000
typedef pair<int64_t, int64_t> PII;
typedef vector<int64_t> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<PII> VP;

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

int N; cin >> N;
VI a(N); rep(i, 0, N) cin >> a[i];

if (*max_element(ALL(a)) == 0){
    cout << "0\n";
    return 0;
}
vector<bool> b(N+1, false);
Rrep(i, N, 1){
    int f = 0;
    for (int j = 1; i*j <= N; ++j) 
        if (b[i*j]) ++f;
    if (a[i-1]) {
        if (f%2 == 0) b[i] = true;
    }
    else {
        if (f%2) b[i] = true;
    }
}
cout << accumulate(ALL(b), 0) << endl;
rep(i, 1, N+1) if (b[i]) cout << i << ' ';
cout << endl;
}

// 境界，出力文字列 チェック
// 可読性優先．高速化次点．
// まずは全探索，分割統治，次にDP
// 制限を見る
// 偶奇，逆から，ソート，出現回数，出現位置，DP， 余事象，包除
// データ構造． 問題の特徴量．単調性，二分探索
// 存在判定：構成方法，入力の特徴
// gcd, lcm ,素因数分解．
// 例外を十分に含む一般化．想像力の限界
// 小さい系から例示
// 始めは過剰に例示・場合分けしてもいい．各場合を確実に対処．
// 自明な例から処理，除外．
// 小数のときは，精度の設定する．doubel 変数に数値を入力するときは 123. とする．
// テストケース作成は数表あり



Measured memory_bytes: 2560
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <iomanip>
#include <climits>
#include <functional>
#include <cassert>
using namespace std;
typedef long long ll;
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<string> VS;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<PII> VPI;
typedef vector<PLL> VPL;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define all(a) (a).begin(),(a).end()
#define pf push_front
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define ub upper_bound
#define lb lower_bound

int main(){
  int N;
  cin>>N;
  string S;
  cin>>S;
  VL X(N+1);
  rep(i,N) X[i+1]=X[i]+(S[i]=='R');
  ll ans=1001001001;
  rep(i,N+1){
    ans=min(ans,max(i-X[i],X[N]-X[i]));
  }
  cout<<ans<<endl;
}


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

template<typename T>
ostream& operator<<(ostream &os, vector<T> &v){
	string sep = " ";
	if(v.size()) os << v[0];
	for(int i=1; i<v.size(); i++) os << sep << v[i];
	return os;
}

#ifdef DBG
void debug_(){ cout << endl; }
template<typename T, typename... Args>
void debug_(T&& x, Args&&... xs){
	cout << x << " "; debug_(forward<Args>(xs)...);
}
#define dbg(...) debug_(__VA_ARGS__);
#else
#define dbg(...) 
#endif

int main() {
	ios_base::sync_with_stdio(false);
	ll a, b, c, k;
	cin >> a >> b >> c >> k;

	if(k<=a){
		cout << k << endl;
	} else if(k<=a+b){
		cout << a << endl;
	} else {
		cout << a-(k-a-b) << endl;
	}
	return 0;
}


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

using namespace std;

int a[200005];
int one[200005][20];

int main()
{
    int n;
    cin >> n;
    rep(i,n) cin >> a[i];
    rep(i,20){
        int o = n;
        one[n][i] = n;
        for(int j = n-1; j >= 0; --j){
            one[j][i] = o;
            if(a[j]>>i&1) o = j;
        }
    }
    long long ans = n;
    rep(i,n){
        int mn = n;
        rep(j,20){
            if(a[i]>>j&1) mn = min(mn, one[i][j]);
            else mn = min(mn, one[one[i][j]][j]);
        }
        ans += mn - i - 1;
    }
    cout << ans << "\n";
}

Measured memory_bytes: 16640
#include<iostream>
#include<algorithm>
using namespace std;
int x[1002], y[1002], n, dp[1002][1002];
int dfs(int p, int q) {
	if (p == q)return 0;
	if (dp[p][q] >= 0)return dp[p][q];
	int maxn = 1LL << 30;
	for (int i = p; i < q; i++) {
		int mx = x[p], my = y[q];
		int G1 = (y[i] - my);
		int G2 = (x[i + 1] - mx);
		int G3 = dfs(p, i) + dfs(i + 1, q);
		maxn = min(maxn, G1 + G2 + G3);
	}
	dp[p][q] = maxn;
	return maxn;
}
int main() {
	cin >> n; for (int i = 1; i <= n; i++) cin >> x[i] >> y[i];
	for (int i = 0; i < 1004004; i++)dp[i / 1002][i % 1002] = -1;
	cout << dfs(1, n) << endl;
	return 0;
}

Measured memory_bytes: 7124
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cstdint>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cmath>
#include <cstdlib>
#include <sstream>
#include <functional>
#include <bitset>
#include <queue>

#include <boost/range/irange.hpp>
using boost::irange;

#include <boost/utility/string_ref.hpp>
using string_view = boost::string_ref;

#include <boost/function_output_iterator.hpp>

using namespace std;

struct item_t
{
    int value = 0;
    int cost = 0;
};

int main()
{
    size_t n;;
    cin >> n;
    vector<item_t> its(n);
    for(auto& it : its) cin >> it.value;
    for(auto& it : its) cin >> it.cost;
    
    int maximum = 0;
    for(const auto& it : its)
    {
        if(it.value - it.cost > 0)
        {
            maximum += (it.value - it.cost);
        }
    }
    
    cout << maximum << '\n';
    
    return 0;
}


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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define fin(x) cout << x << endl;

using namespace std;
using ll = long long;

int main(void) {
  int n;
  cin >> n;
  string s;
  cin >> s;
  int ans = 0;
  rep(i, s.size() - 2) {
    if (s[i] == 'A' && s[i+1] == 'B' && s[i+2] == 'C') {
      ans++;
    }
  }
  cout << ans << endl;
	return 0;
}



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

int main() 
{
    int N;
    int a[6] = {0,0,0,0,0,0};
    int ans = 0;
    cin >> N;


    int i = 0;
    do {
        if ((N == 10) || (N == 100) || (N == 1000) || (N == 10000) || (N == 100000)) {
            ans = 10;
            break;
        }
        a[i] = N % 10;
        N = N / 10;
        i++;
    }while(N != 0);

    for (int i = 0; i < 6; i++) {
        ans += a[i];
    }

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i <(n); ++i)
#define REP2(i,x,n) for (int i = x; i <(n); ++i)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
using namespace std;
using ll = long long;
using P = pair<int,int>;
static const double PI = acos(-1);



int main(){
  int n;
  cin >> n;
  int f[n][10];
  int p[n][11];
  REP(i,n)REP(j,10) cin >> f[i][j];
  REP(i,n)REP(j,11) cin >> p[i][j];

  int MX = -2000000000;


  REP2(bi, 1, 1 << 10){
    int profit  = 0;
    //cout << bi << endl;
    REP(i,n){
      int cnt = 0;
      REP(j, 10) {
        if(bi >> j&1){
          if(f[i][j]) ++cnt;
        }
      }
      profit += p[i][cnt];
      }
    MX = max(profit, MX);
  }


  cout << MX << endl;



  return 0;
}


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

#define rep(i,a,b) for(ll i=ll(a);i<ll(b);i++)
#define irep(i,a,b) for(ll i=ll(a);i>=ll(b);i--)
#define pb push_back
#define mp make_pair
#define F .first
#define S .second 
using ll=long long;
using ld=long double;
using namespace std;
const ll mod=1e9+7;

int main(){
  ll n,a=1,b=1;
  cin>>n;
  ll z=n;
  bool p=true;
  while(z>1){
    irep(i,sqrt(n),2){
      while(z%i==0){
        if(b>=a){a*=i;z/=i;}
        else {b*=i;z/=i;}
      }
    }
    if(z>1){
      if(a>=b)b*=z;
      else a*=z;
      z=1;
    }
  }
  cout<<a+b-2;
}

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

int main() {
    int A , B , C , D ;
    cin >> A >> B >> C >> D ;
    if((A + B) > (C + D)){
    	cout << "Left" << endl;
    }else if((A + B) == (C + D)){
    	cout << "Balanced" << endl;
    }else{
    	cout << "Right" << endl;
    }
}

Measured memory_bytes: 3628
#define DBG 0 //submit 0
#if DBG
    #include <algorithm>
    #include <ctime>
    #include <cstdlib>
    #include <string>
    #include <vector>
    #include <iostream>
    #include <cmath>
    #include <numeric>
#else
    #include <bits/stdc++.h>
#endif

using namespace std;


int main(){ 
    int A,B,ans;
 
    //string S;
    cin >> A >> B;
	
  	ans = A - 2 * B;
  	if (ans < 0) ans = 0;
	cout << ans << endl;
}


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

int main()
{
    long long int n,w,i,j,k;
    cin>>n>>w;

    long long int a[n][2];

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

    long long int dp[100005][n];

    for(i=0;i<100005;i++)
        for(j=0;j<n;j++)
            dp[i][j]=-1;

    dp[w-a[0][0]][0]=a[0][1];
    dp[w][0]=0;
    for(i=1;i<n;i++)
    {
        for(j=0;j<100005;j++)
            if(dp[j][i-1]!=-1)
                dp[j][i]=max(dp[j][i],dp[j][i-1]);
        for(j=a[i][0];j<100005;j++)
            if(dp[j][i-1]!=-1)
                dp[j-a[i][0]][i]=max(dp[j-a[i][0]][i],dp[j][i-1]+a[i][1]);
    }

    long long int ma=0;
    for(i=0;i<100005;i++)
        ma=max(ma,dp[i][n-1]);
    cout<<ma;
}


Measured memory_bytes: 78336
#include<iostream>
#include<string>
#include<set>
using namespace std;

int main(void){
    set<string>W;
    int N;
    cin>>N;
    string A,L;
    cin>>A;
    W.insert(A);
    L=A[A.size()-1];
  


    for(int i=0;i<N-1;i++){
        string T;
        cin>>T;
        if(W.count(T)==1){
            cout<<"No"<<endl;
            return 0;
        }else{
            if(T[0]!=L[0]){
                
                cout<<"No"<<endl;
                return 0;
            }else{
             W.insert(T);
             L=T[T.size()-1];  
            }
            

        }
        
        

    }
    cout<<"Yes"<<endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	string s;
	cin>>s;
	if(s=="hi"||s=="hihi"||s=="hihihi"||s=="hihihihi"||s=="hihihihihi")
		cout<<"Yes";
	else
		cout<<"No"; 
	return 0;
}


Measured memory_bytes: 384
N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
ans = 0
for i in range(N):
  one = min(A[i],B[i])
  two = min(A[i+1],B[i]-one)
  ans+=one+two
  A[i+1]-=two
print(ans)

Measured memory_bytes: 97772
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class Main {

	public static void main(String[] args) {
		Scanner scan=new Scanner(new BufferedReader(new InputStreamReader(System.in)));
		int s=scan.nextInt();
		Set<Integer> set=new  HashSet<Integer>();
		for (int i = 0; i < s; i++) {
			set.add(scan.nextInt());
		}
		int q=scan.nextInt();
		int v=0;
		for (int i = 0; i < q; i++) {
			int a=scan.nextInt();
			if(!set.add(a))
			{
				v++;
			}
		}
		PrintWriter pw=new PrintWriter(System.out);
		pw.println(v);
		pw.close();

	}

}

Measured memory_bytes: 81640
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define int long long
#define mp make_pair
#define endl "\n"
#define pii pair<int,int> 
#define ff first
#define ss second
#define mii map<int,int>
#define si set<int>
#define sti stack<int>
#define qi queue<int>
#define vi vector<int>
#define pq priority_queue<int>
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
const int M=1e9+7;
mii m;
int power5(int x){
    return(x*x*x*x*x);
}

void pre(){
    for(int i=-200;i<=200;i++){
        m.insert({power5(i),i});
    }
}

int32_t main(){
    IOS;
    int n;
    cin>>n;
    pre();
    for(int i=-200;i<=200;i++){
        int y=power5(i);
        int x=n+y;
        if(m.find(x)!=m.end()){
            cout<<m.find(x)->ss<<" "<<i<<endl;
            return 0;
        }
    }   
}


Measured memory_bytes: 3664
#include <bits/stdc++.h>
std::string ans[2] = {"No\n", "Yes\n"};
int main() {
    int n, a, b;
    std::cin >> n >> a >> b;
    std::string s;
    std::cin >> s;

    int passed        = 0;
    int abroad_passed = 0;
    for (int i = 0; i < n; ++i) {
        if (s.at(i) == 'a') {
            bool isPass = passed < a + b;
            std::cout << ans[isPass];
            passed += isPass;
        }
        if (s.at(i) == 'b') {
            bool isPass = (passed < a + b && abroad_passed < b);
            std::cout << ans[isPass];
            passed += isPass;
            abroad_passed += isPass;
        }
        if (s.at(i) == 'c') {
            std::cout << ans[0];
        }
    }
    return 0;
}

Measured memory_bytes: 896
#include<algorithm>
#include<iostream>
#include<cstring>
#include<cstdio>
using namespace std;
const int N=200005;
struct job{int a,b;}a[N];
bool operator<(job a,job b){
	return a.b<b.b;
}
int n;
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;++i)
		scanf("%d%d",&a[i].a,&a[i].b);
	sort(a+1,a+1+n);
	int sum=0;
	for(int i=1;i<=n;++i){
		sum+=a[i].a;
		if(sum>a[i].b){
			printf("No");
			return 0;
		} 
	}
	printf("Yes");
	return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned int u32;
typedef pair<int, int> p;
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; }
int Inf = (1<<30);
ll inf = (1LL<<60);
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
ll modpow(ll a, ll b, ll M) {
	ll res = 1;
	for (; b > 0; b >>= 1) {
		if (b & 1) res = (res * a) % M;
		a = a * a % M;
	}
	return res;
}
int main() {
	int n;
	cin >> n;
	int i;
	int count[110000];
	bool zero = false;
	for (i = 0; i < n; i++) {
		int a;
		cin >> a;
		if (count[a] == 2) {
			cout << 0;
			return 0;
		}
		if (n % 2 == 0) {
			int N = n / 2;
			if (a > 1 + N * 2 || a % 2 == 0) {
				cout << 0;
				return 0;
			}
			count[a]++;
		}
		else {
			if (a == 0) {
				if (zero) {
					cout << 0;
					return 0;
				}
				else zero++;
			}
			else {
				int N = n / 2;
				if (a > N * 2 || a % 2 != 0) {
					cout << 0;
					return 0;
				}
				count[a]++;
			}
		}
	}
	if (n == 1)  cout << 1;
	else cout << modpow(2, n / 2, 1000000007);
	return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include<vector>
using namespace std;
int main(){
  long long n,ans=0;
  cin>>n;
  vector<long long> a(n),b(n*(n-1)/2);
  for(int i=0;i<n;i++){
    cin>>a[i];
  }
  int k=0;
  for(int i=0;i<n;i++){
    for(int j=i;j<n-1;j++){
      ans+=a[i]*a[j+1];
    }
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
import sys
input = sys.stdin.buffer.readline


class BinaryIndexedTree:
    """一点加算、区間総和クエリをそれぞれO(logN)で答えるデータ構造。"""
    def __init__(self, n):
        self.size = n
        self.bit = [0] * (n + 1)

    def build(self, array):
        """arrayを初期値とするBinaryIndexedTreeを構築する。O(N)"""
        for i, val in enumerate(array):
            self.bit[i + 1] = val
        for i in range(1, self.size):
            if i + (i & -i) > self.size:
                continue
            self.bit[i + (i & -i)] += self.bit[i]

    def _sum(self, i):
        s = 0
        while i > 0:
            s += self.bit[i]
            i -= i & -i
        return s

    def add(self, i, val):
        """i番目の要素にvalを加算する。O(logN)"""
        i += 1
        while i <= self.size:
            self.bit[i] += val
            i += i & -i

    def sum(self, l, r):
        """区間[l, r)の和を求める。O(logN)"""
        return self._sum(r) - self._sum(l)

    def bisect_left(self, val):
        """区間[0, ind)の和がval以上になる最小のindを求める。O(logN)"""
        if val <= 0:
            return 0
        ind = 0
        k = 1 << self.size.bit_length()
        while k:
            if ind + k <= self.size and self.bit[ind + k] < val:
                val -= self.bit[ind + k]
                ind += k
            k >>= 1
        return ind + 1


n, q = map(int, input().split())
a = list(map(int, input().split()))
queries = [list(map(int, input().split())) for _ in range(q)]


bit = BinaryIndexedTree(n)
bit.build(a)
for flag, l, r in queries:
    if flag:
        print(bit.sum(l, r))
    else:
        bit.add(l, r)  # l = index, r = val

Measured memory_bytes: 178060
#include <stdio.h>

int main(void) {
  long long i, j, k, n = 50, a[50];
  scanf("%lld", &k);
  printf("50\n");
  if(k <= 50) {
    for(i = 0; i < n - k; ++i) printf("0 ");
    for(i = n - k; i < n; ++i) printf("%lld ", i + 1);
  } else {
    long long tmp = 51 + (k - 50) / 50;
    for(i = 49; i >= k % 50; --i) printf("%lld ", tmp - i - 1);
    for(i = k % 50 - 1; i >= 0; --i) printf("%lld ", tmp - i);
  }
  return 0;
}

Measured memory_bytes: 128
import sys
import numpy as np

if sys.argv[-1] == 'ONLINE_JUDGE':
    from numba.pycc import CC
    cc = CC('my_module')

    @cc.export('is_ok', '(i8[:],i8[:],i8,i8)')
    def is_ok(A, F, x, k):
        tmp = 0
        for a, f in zip(A, F):
            y = a * f
            if y > x:
                tmp += a - x // f
        return tmp <= k

    cc.compile()
    exit(0)

from my_module import is_ok
n, k = map(int, input().split())
A = np.array(list(map(int, input().split())))
F = np.array(list(map(int, input().split())))

A = np.sort(A)
F = np.sort(F)[::-1]

ok = 10 ** 13
ng = -1
while ok - ng > 1:
    mid = (ok + ng) // 2
    if is_ok(A, F, mid, k):
        ok = mid
    else:
        ng = mid

print(ok)


Measured memory_bytes: 53668
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <cassert>
#include <string.h>
//#include <unordered_set>
//#include <unordered_map>
//#include <bits/stdc++.h>

#define MP(A,B) make_pair(A,B)
#define PB(A) push_back(A)
#define SIZE(A) ((int)A.size())
#define LEN(A) ((int)A.length())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define fi first
#define se second

using namespace std;

template<typename T>inline bool upmin(T &x,T y) { return y<x?x=y,1:0; }
template<typename T>inline bool upmax(T &x,T y) { return x<y?x=y,1:0; }

typedef long long ll;
typedef unsigned long long ull;
typedef long double lod;
typedef pair<int,int> PR;
typedef vector<int> VI;

const lod eps=1e-11;
const lod pi=acos(-1);
const int oo=1<<30;
const ll loo=1ll<<62;
const int mods=1e9+7;
const int MAXN=600005;
const int INF=0x3f3f3f3f;//1061109567
/*--------------------------------------------------------------------*/
inline int read()
{
	int f=1,x=0; char c=getchar();
	while (c<'0'||c>'9') { if (c=='-') f=-1; c=getchar(); }
	while (c>='0'&&c<='9') { x=(x<<3)+(x<<1)+(c^48); c=getchar(); }
	return x*f;
}
int f[17][1<<16],a[1<<16],fac[1<<16],inv[1<<16];
int quick_pow(int x,int y)
{
	int ret=1;
	for (;y;y>>=1)
	{
		if (y&1) ret=1ll*ret*x%mods;
		x=1ll*x*x%mods;
	}
	return ret;
}
int upd(int x,int y) { return x+y>=mods?x+y-mods:x+y; }
int C(int x,int y) { if (x<y||x<0||y<0) return 0; return 1ll*fac[x]*inv[y]%mods*inv[x-y]%mods; }
void Init(int n)
{
	fac[0]=1; 
	for (int i=1;i<=n;i++) fac[i]=1ll*fac[i-1]*i%mods;
	inv[n]=quick_pow(fac[n],mods-2);
	for (int i=n-1;i>=0;i--) inv[i]=1ll*inv[i+1]*(i+1)%mods;
}
int main()
{
	int n=read(),m=read();
	for (int i=0;i<m;i++) a[i]=read();
	sort(a,a+m,greater<int>());
	Init((1<<n)-1);
	
	f[0][0]=1;
	for (int i=1;i<=m;i++)
		for (int j=0;j<1<<n;j++)
		{
			f[i][j]=upd(f[i][j],f[i-1][j]);
			for (int k=0;k<n;k++)
				if ((j>>k)&1)
					f[i][j]=upd(f[i][j],1ll*f[i-1][j^(1<<k)]*C((1<<n)-a[i-1]-j+(1<<k),(1<<k)-1)%mods*fac[1<<k]%mods);
		}
	int ans=0;
	for (int i=0;i<1<<n;i++)
	{
		int t=1ll*f[m][i]*fac[(1<<n)-i-1]%mods;
		if (__builtin_popcount(i)&1) ans=upd(ans,mods-t);
		else ans=upd(ans,t); 
	}
	printf("%d\n",1ll*ans*(1<<n)%mods);
	return 0;
}

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

typedef long long ll;

int main()
{
    ll i,j;
    int n;
    cin >> n;
    int bit;
    vector<int> a(n);
    vector<vector<int>> x(n);
    vector<vector<int>> y(n);
    for(i = 0;i < n;++i){
        cin >> a.at(i);
        for(j = 0;j < a.at(i);++j){
            int tx,ty;
            cin >> tx >> ty;
            --tx;
            x.at(i).push_back(tx);
            y.at(i).push_back(ty);
        }
    }
    int ans = 0;
    for(bit = 0;bit < (1 << n);++bit){
        int tmp = 0;
        vector<int> syouziki(n,0);
        for(i = 0;i < n;++i){
            if(bit & (1 << i)){
                ++tmp;
                syouziki.at(i) = 1;
            }
        }
        if(tmp <= ans){
            continue;
        }
        bool flag = true;
        for(i = 0;i < n;++i){
            if(!syouziki.at(i)){
                continue;
            }
            for(j = 0;j < a.at(i);++j){
                int hito = x.at(i).at(j);
                if(syouziki.at(hito) != y.at(i).at(j)){
                    flag = false;
                    break;
                }
            }
            if(!flag){
                break;
            }
        }
        if(flag){
            ans = tmp;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){
    long int n,i,a,b,sum=0,z=0;

    scanf("%ld",&n);

    for(i=1;i<=n;i++){
        a=i%3;
        b=i%5;
        
        if(a==0 || b==0){
            sum=sum+i;
        }
    }

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

    printf("%ld\n",z-sum);

    return 0;
}

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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N;
double memo[303][303][303];

double dfs(int a1,int a2,int a3) {
	if(a1<0 || a2<0 || a3<0) return 0;
	if(a1+a2+a3==0) return 0;
	if(memo[a1][a2][a3]) return memo[a1][a2][a3];
	
	double step=1.0*N/(a1+a2+a3);
	return memo[a1][a2][a3]=step+(dfs(a1-1,a2,a3)*a1+dfs(a1+1,a2-1,a3)*a2+dfs(a1,a2+1,a3-1)*a3)/(a1+a2+a3);
	
}

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	int cnt[4]={};
	cin>>N;
	FOR(i,N) {
		cin>>x;
		cnt[x]++;
	}
	
	_P("%.12lf\n",dfs(cnt[1],cnt[2],cnt[3]));
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 217344
// https://atcoder.jp/contests/abc175/tasks/abc175_c
#include <iostream>
#include <vector>
#include <deque>
#include <tuple>
#include <algorithm>
#include <iterator> // std::back_inserter
#include <climits>
#include <sstream>

using namespace std;

typedef unsigned long ll;

ll k;
ll a[1000001];

int main()
{
    cin >> k;
    ll x = 7;
    for (int i=0; i<k; i++) {
        if (x % k == 0) {
            cout << i+1 << endl;
            return 0;
        }
        x = (x * 10 + 7) % k;
    }
    cout << -1 << endl;
}


Measured memory_bytes: 3596