akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
// define
#define int long long
#define UNIQUE(v) v.erase(unique(all(v)), v.end());
#define ZIP(v) sort(all(v)),UNIQUE(v)
#define ADD(a, b) a = (a + b) % mod
#define SUB(a, b) a = (a+mod-b)%mod
#define MUL(a, b) a = (((a)%mod) * ((b)%mod)) % mod
#define rollcall cout << "I'm Sucu." << endl;
#define repi(i,m,n) for(int i = m;i < n;i++)
#define drep(i,n,m) for(int i = n;i >= m;i--)
#define rep(i,n) repi(i,0,n)
#define rrep(i,n) repi(i,1,n+1)
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(), v.rend()
#define dmp(x,y) make_pair(x,y)
#define pb(x) push_back(x)
#define pf(x) push_front(x)
#define fi first
#define se second
// debug
template <typename T, typename U>
ostream &operator<<(ostream &os, const pair<T, U> &p){
  os << "(" << p.first << "," << p.second << ")";return os;
}
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v){
  for (auto it = v.begin();it != v.end();++it){
    if(it != v.begin())os << " ";os << *it;
  }return os;
}
template <typename T, typename U>
ostream &operator<<(ostream &os, const map<T, U> &mp){
  for(auto x: mp)os << "(" << x.first << "," << x.second << ")" << endl;
  return os;
}
template<typename T, int SIZE>
int array_length(const T (&)[SIZE]){return SIZE;}
template<typename T, int N>
void PRINTF(const T (&a)[N], int s = N, int t = -1, bool f = true){
	if(t == -1){rep(i,s){if(i)cout << " ";cout << a[i];}}
	else repi(i,s,t){if(i!=s)cout << " ";cout << a[i];}
	if(f)cout << "\n";
}
template<typename T, int N1, int N2>
void PRINTF(const T (&a)[N1][N2], int h = N1, int w = N2){
	rep(i,h){rep(j,w){cout << a[i][j] << " \n"[j==w-1];}}
}
string substr(const string &str, int S1, int S2 = -1){
  if(S2 == -1)return str.substr(S1);
  return str.substr(S1, S2-S1);
}
// typedef
typedef complex<double> Point;
typedef pair<int, int> P;
typedef pair<int, P> PP;
typedef pair<P, int> Pi;
typedef vector<int> vi;
typedef deque<int> dq;
const int inf = 1e9+7;
const int INF = 1e18+7;
// int sum = accumulate(a, a+n, 0LL);
// int mx = max_element(a, a+n);
// int mn = min_element(a, a+n);
// int cnt = count(a, a+n, k);


int cnt[200];
signed main(){
  int n, m;
  cin >> n >> m;
  rep(i,n){
    int k, tmp;cin >> k;
    rep(i,k){cin >> tmp;cnt[tmp]++;}
  }
  int ans = 0;
  rrep(i,m)ans += cnt[i] == n;
  cout << ans << endl;
  return 0;
}








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

template <typename T> struct Dijkstra {
  Dijkstra(size_t size) : size(size), G(size) {}

  struct edge {
    edge(int to, T cost) : to(to), cost(cost) {}
    int to;
    T cost;
  };

  using P = pair<T, int>;
  const T inf = numeric_limits<T>::max();

  size_t size;
  vector<vector<edge>> G;
  vector<T> d;

  void add_edge(int u, int v, T c) {
    G[u].push_back(edge(v, c));
  }

  void build(int s) {
    d.assign(size, inf);
    priority_queue<P, vector<P>, greater<P>> q;

    d[s] = 0;
    q.push(P(0, s));

    while (!q.empty()) {
      P p = q.top();
      q.pop();
      int v = p.second;
      if (d[v] < p.first) continue;
      for (auto &e : G[v])
        if (d[e.to] > p.first + e.cost) {
          d[e.to] = p.first + e.cost;
          q.push(P(d[e.to], e.to));
        }
    }
  }

  T operator[](int v) {
    return d[v];
  }
};

int main() {
  int V, E, r;
  cin >> V >> E >> r;

  Dijkstra<int> G(V);
  for (int i = 0; i < E; ++i) {
    int s, t, d;
    cin >> s >> t >> d;

    G.add_edge(s, t, d);
  }

  G.build(r);

  for (int i = 0; i < V; ++i) {
    if (G[i] == G.inf) {
      cout << "INF" << endl;
    } else {
      cout << G[i] << endl;
    }
  }
}



Measured memory_bytes: 12916
#include <iostream>
using namespace std;
#define LL long long

#include <algorithm>
#include <vector>
void _150() {
    LL n;
    cin >> n;

    // int p[8];
    // int q[8];
    int temp;
    vector<int> p, q;
    vector<int> perm_base;
    for (int i = 0; i < n; ++i) {
        cin >> temp;
        p.push_back(temp);
        perm_base.push_back(i + 1);
    }
    for (int i = 0; i < n; ++i) {
        cin >> temp;
        q.push_back(temp);
    }

    LL a, b, index;
    a = -1;
    b = -1;
    index = 0;
    do {
        if (perm_base == p) {
            a = index;
        }

        if (perm_base == q) {
            b = index;
        }

        if (a != -1 && b != -1) {
            break;
        }

        index++;
    } while (next_permutation(perm_base.begin(), perm_base.end()));

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

#include <string>
void _151() {
    int n, m;
    cin >> n >> m;
    int p[100000] = {0};
    int correct[100000] = {0};
    int penalty_counts[100000] = {0};
    string temp;
    int correct_count = 0;
    for (int i = 0; i < m; ++i) {
        cin >> p[i] >> temp;
        if (temp == "AC") {
            if (correct[p[i] - 1] != 1) {
                correct_count++;
                correct[p[i] - 1] = 1;
            }
        } else {
            if (correct[p[i] - 1] != 1) {
                penalty_counts[p[i] - 1]++;
            }
        }
    }
    int penalty_count = 0;
    for (int i = 0; i < n; ++i) {
        if (correct[i] == 1) {
            penalty_count += penalty_counts[i];
        }
    }
    cout << correct_count << " " << penalty_count << endl;
}

int main()
{
    _151();
    return 0;
}



Measured memory_bytes: 1408
numOfQuestions = gets.to_i
restrictions = gets.to_s
questions = gets.to_s

restrictionA = restrictions.split(" ")[0].to_i
restrictionB = restrictions.split(" ")[1].to_i


arrayOfQuestions = []
for times in 0..numOfQuestions-1 do
    arrayOfQuestions << questions.split(" ")[times].to_i
end

array = []

firstQuestion = arrayOfQuestions.count{|question| question <= restrictionA }
secondQustion = arrayOfQuestions.count{|question| question > restrictionA &&  question <= restrictionB}
thirdQuestion = arrayOfQuestions.count{|question| question > restrictionB}

array << firstQuestion
array << secondQustion
array << thirdQuestion

p array.min

Measured memory_bytes: 1788
/*
 * Author : Andrew J
*/
#include <bits/stdc++.h>
using namespace std;
#define rall(x) x.rbegin() , x.rend()
#define all(x) x.begin() , x.end()
#define fi first
#define se second
#define pb push_back
using ll = long long;
using ii = pair <ll , ll>;
void in(ll &x);
const ll N = 1e5 + 10;
#define singleCase
// #define multipleCase
ll n,k,ps[N],pps[N],a[N];

ll rsum(ll l , ll r , ll pref[]) {
   return pref[r] - pref[l - 1];
}

void work() {
   in(n); in(k);
   ll sump = 0;
   for (ll i = 1 ; i <= n ; i++) {
      in(a[i]);
      ps[i] = ps[i - 1] + a[i];
      pps[i] = pps[i - 1] + max(a[i] , 0LL);
      sump += max(a[i] , 0LL);
   }
   ll sol = 0;
   for (ll i = 1 ; i <= n ; i++) {
      ll l = i, r = i + k - 1;
      if (r > n) break;
      ll cur = sump - rsum(l , r , pps) + max(rsum(l , r , ps) , 0LL);
      sol = max(sol , cur);
   }
   printf("%lld\n" , sol);
   return;
}

int main() {
   #ifdef multipleCase
      ll nQ; in(nQ);
      while (nQ--)
         work();
   #endif
   #ifdef singleCase
      work();
   #endif
   return 0;
}

void in(ll &x) {
	bool neg = false;
	register ll c;
	x = 0;
	c = getchar();
	if(c == '-') {
		neg = true;
		c = getchar();
	}
	for (; c > 47 && c < 58; c = getchar())
	  x = (x << 1) + (x << 3) + c - 48;
	if (neg) x *= -1;
}


Measured memory_bytes: 6100
#include <iostream>
#include <utility>
#include <vector>
#include <cassert>
#include <algorithm>

using namespace std;

typedef long long ll;
typedef pair<int, int> Pii;

int H,W,Q;
ll T;

class Event {
    public:
    ll t;
    int c;
    Pii p, q;
    Event(ll t, int c, Pii p, Pii q): t(t), c(c), p(p), q(q){}
    bool operator < (const Event &e) const { return ((t != e.t) ? (t < e.t) : (c < e.c)); }
};

template<typename T> class BIT2D {
    public:
    int n, m;
    vector< vector<T> > bit;
    
    BIT2D(int n, int m): n(n), m(m) {
        bit.resize(n+1);
        fill(bit.begin(), bit.end(), vector<T>(m+1, 0));
    }

    void add(int y, int x, T a){
        for(int i=y;i<=n;i+=i&-i) {
            for(int j=x;j<=m;j+=j&-j) {
                bit[i][j] += a;
            }
        }
    }

    //bit[1][1]からbit[y][x]までの和 (閉区間)
    T sum(int y, int x){
        T ret = 0;
        for(int i=y;i>=1;i-=i&-i) {
            for(int j=x;j>=1;j-=j&-j) {
                ret += bit[i][j];
            }
        }
        return ret;
    }
};


int main() {
    cin >> H >> W >> T >> Q;

    vector< BIT2D<int> > bit(2, BIT2D<int>(H+1, W+1));

    ll tt;
    int cc;
    Pii pp, qq;
    vector<Event> events;
    for(int i=0;i<Q;i++) {
        cin >> tt >> cc >> pp.first >> pp.second;
        if(cc == 2) {
            cin >> qq.first >> qq.second;
            events.emplace_back(tt, cc, pp, qq);
        } else {
            events.emplace_back(tt, cc, pp, Pii(0, 0));
            if(cc == 0) {
                events.emplace_back(tt+T, -1, pp, Pii(0, 0));
            }
        }
    }
    sort(events.begin(), events.end());

    for(Event e: events) {
        switch(e.c) {
            case 0: {
                bit[0].add(e.p.first, e.p.second, 1);
                break;
            }
            case 1: {
                int taiyaki = bit[1].sum(e.p.first, e.p.second) - bit[1].sum(e.p.first-1, e.p.second) - bit[1].sum(e.p.first, e.p.second-1) + bit[1].sum(e.p.first-1, e.p.second-1);
                assert(taiyaki <= 1);
                if(taiyaki) bit[1].add(e.p.first, e.p.second, -1);
                break;
            }
            case 2: {
                int finished = bit[1].sum(e.q.first, e.q.second) - bit[1].sum(e.p.first-1, e.q.second) - bit[1].sum(e.q.first, e.p.second-1) + bit[1].sum(e.p.first-1, e.p.second-1);
                int cooking = bit[0].sum(e.q.first, e.q.second) - bit[0].sum(e.p.first-1, e.q.second) - bit[0].sum(e.q.first, e.p.second-1)  + bit[0].sum(e.p.first-1, e.p.second-1);
                cout << finished << " " << cooking << endl;
                break;
            }
            case -1: {
                bit[0].add(e.p.first, e.p.second, -1);
                bit[1].add(e.p.first, e.p.second,  1);
                break;
            }
            default:
                break;
        }
    }

}


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

int main(){
  int n;
  cin >> n;
  int cnt=0;
  for(int i=1;i<=n;i++){
    int cp=i,digit=0;
    while(cp){
      digit++;
      cp /= 10;
    }
    if(digit%2)cnt++;
  }
  cout << cnt << endl;
}

Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
//#pragma GCC optimize "trapv"
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

// #pragma GCC target ("avx2")
// #pragma GCC optimization ("O3")
// #pragma GCC optimization ("unroll-loops")
// #pragma optimization_level 3
// #pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")


#define pb push_back 
#define f first
#define s second
#define min3(a, b, c) min(min(a, b), c)
#define max3(a, b, c) max(max(a, b), c)
#define all(v) v.begin(), v.end()

typedef long long ll;
typedef double ld;
typedef long double lld;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<pii> vpi;
typedef vector<pll> vpl;

template <class T> using ordered_set = tree <T, null_type, less <T>, rb_tree_tag, tree_order_statistics_node_update>;

const int INF = 1e9;
//const ll INF = 1e18;
const ll mod = 1000000007;
// const ll mod = 998244353;

void solve(int tc){
    ll n, x, m;
    cin >> n >> x >> m;
    ll ans = 0;
    ll prev = x;
    map<ll, int> mp; 
    mp[prev] = 1;
    map<ll, ll> sums;
    ll i;
    for(i = 1; i <= n; i++){
        sums[i] = sums[i-1] + prev;
        prev = (prev*prev)%m;
        if(mp[prev])
            break;
        else
            mp[prev] = i+1;
    }

    ll j = mp[prev];
    ll temp = sums[j-1];
    ll temp2 = sums[i]-temp;
    temp2 *= (n-j+1)/(i-j+1);
    temp += temp2;

    ll taken = j-1 + (i-j+1)*((n-j+1)/(i-j+1));
    taken = n - taken;

    temp += sums[j-1+taken] - sums[j-1];

    cout << temp << "\n";
}

int main(){
    ios_base::sync_with_stdio(NULL);
    cin.tie(NULL);
    
    int tc = 1;
    //cin >> tc;
    for (int t = 0; t < tc; t++) solve(t);

    return 0;
}

Measured memory_bytes: 9732
#include <bits/stdc++.h>
using namespace std;
int PREP = (cin.tie(nullptr), ios::sync_with_stdio(false), cout << fixed << setprecision(9), 0);
//int SEGV = getenv("D") || (exit(system("D= SEGFAULT_SIGNALS=all catchsegv ./prog.exe") >> 8), 0);
using Int = long long;
int main() {
    int N; cin >> N;
    vector<int> ans(N + 1);
    for (int x = 1; x <= 100; x++) {
        for (int y = 1; y <= 100; y++) {
            for (int z = 1; z <= 100; z++) {
                int k = x*x+y*y+z*z+x*y+y*z+z*x;
                if (k <= N) {
                    ans[k]++;
                }
            }
        }
    }
    for (int i = 1; i <= N; i++) {
        cout << ans[i] << '\n';
    }
    return 0;
}

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

#define ALL(v) v.begin(), v.end()
#define V vector
#define P pair
#define ld long double
#define ll long long
#define mod 1000000007
#define IINF INT_MAX
#define INF 1LL << 30


int main() {
    string s, t; cin >> s >> t;
    cout << t << s << endl;

    return 0;
}


Measured memory_bytes: 3604
#include<bits/stdc++.h>
#define ll long long
#define FOR(i, a, b) for(ll i = a; i < b; i++)
#define all(x) (x).begin(), (x).end()
#define MOD1 1000000007
#define MOD2 998244353
#define IOS std::ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define pb push_back
#define print(a) for(auto x : a)    cout<<x<<" "; cout<<"\n";
using namespace std;

int main(){

    IOS;
    int n, x;
    cin >> n;
    int ordinates[n + 1] = {0};

    FOR(i, 0, n - 1)    cin >> x, ordinates[x]++;
    FOR(i, 1, n + 1)    cout<<ordinates[i]<<"\n";
    return 0;
}

Measured memory_bytes: 4320
#[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, usize1) => {
        read_value!($next, usize) - 1
    };

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

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        #[cfg(debug_assertions)]
        writeln!(&mut std::io::stderr(), concat!("[DEBUG] ", $(stringify!($a), "={:?} "),*), $($a),*);
    }
}

#[allow(unused_imports)]
use std::cmp::{min, max};
#[allow(unused_imports)]
use std::io::{stdout, stdin, BufWriter, Write};

fn main() {
    let out = std::io::stdout();
    let mut out = BufWriter::new(out.lock());
    macro_rules! puts {
        ($($format:tt)*) => (write!(out,$($format)*).unwrap());
    }

    input!{
        aa: [usize; 5]
    }
    let mut ans: usize = aa.iter().map(|&v| (v+9)/10*10 ).sum();
    let min_v = aa.iter().map(|&v| if v%10 == 0 { 10 } else { v%10 } ).min().unwrap();
    puts!("{}\n", ans+min_v-10);
}


Measured memory_bytes: 4352
n, m = gets.split.map(&:to_i)

if n >= m
  puts 0
else
  points = gets.split.map(&:to_i).sort

  spaces = []
  points.each_with_index do |e, i|
    break if i == points.size - 1
    spaces << points[i + 1] - e
  end

  spaces.sort!

  (n - 1).times do
    spaces.pop
  end

  puts spaces.inject(&:+)
end


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

int main(){
  int N, L;
  cin >> N >> L;
  vector<string> S(N);
  for(int i=0; i<N; i++) cin >> S.at(i);
  sort(S.begin(), S.end());
  for(int i=0; i<N; i++) cout << S.at(i);
  cout << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define mod 1000000007
#define int long long int
#define rep(i,n,f) for (int i = n; i < f; i++)
#define rap(i,n,f) for (int i = n; i > f; i--)
#define inf 1e9+9

using namespace std;

const int maxn = 1e5 + 10;
int n,we,w[110],dp[110][maxn],v[110];

int32_t main(){
	cin >> n >> we;
	rep(i,1,n + 1){
		cin >> w[i] >> v[i];
	}
	dp[0][0] = 0;
	rep(i,0,n + 1){
		rep(j,0,we + 1){
			if(i == 0 or j == 0){
				dp[i][j] = 0;
			}
			else if(w[i] <= j){
				dp[i][j] = max(dp[i-1][j-w[i]] + v[i] , dp[i-1][j]);	
			}
			else{
				dp[i][j] = dp[i-1][j];
			}
		}
	}
	cout << dp[n][we] << endl;
}
	



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

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

ll lcm(ll a, ll b){
    return a * b / gcd(a, b);
}


int main(){
    ll a, b, c, d;
    cin >> a >> b >> c >> d;
    ll lcm0;
    lcm0 = lcm(c, d);
    ll ans = b - a + 1 - (ll(b/c) - ll((a - 1)/ c));
    ans -= (ll(b/d) - ll((a - 1)/d));
    ans += (ll(b/lcm0) - ll((a - 1)/ lcm0));
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>//Carefully Crafted by hetp111
using namespace std;
#define int long long
#define double long double
#define all(v) (v).begin(),(v).end()
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int,int>
#define vii vector<pii>
#define MOD 1000000007
#define MOD2 998244353
#define MOD3 1000000009
#define PI acos(-1)
#define eps (1e-8)
#define INF (1e18)
#define FASTER ios_base::sync_with_stdio(0);cin.tie(0)
template<class A,class B>ostream&operator<<(ostream&out,const pair<A,B>&a){return out<<"("<<a.first<<","<<a.second<<")";}
template<class A>ostream&operator<<(ostream&out,const vector<A>&a){for(const A &it:a)out<<it<<" ";return out;}
template<class A,class B>istream&operator>>(istream&in,pair<A,B>&a){return in>>a.first>>a.second;}
template<class A>istream&operator>>(istream&in,vector<A>&a){for(A &i:a)in>>i;return in;}
//ifstream cinn("in.in");ofstream coutt("out.out");
int poww(const int &a,int b,const int &m=MOD){if(b==0)return 1;int x=poww(a,b/2,m);x=x*x%m;if(b&1)x=x*a%m;return x;}
int ceil(const int &a,const int &b){return (a+b-1)/b;}
////Read:
//Check corner cases, n==1;
//
////Some function:
//__builtin_popcountll(), 

int n;
int h[200005],a[200005];
int dp[200005];
int tree[4*200005];

void updatee(int s,int e,int idx,int SE,int val){
    if(s>SE || e<SE)return;
    if(s==e){
        tree[idx]=val;
        return;
    }
    int mid=(s+e)/2;
    updatee(s,mid,idx*2+1,SE,val);
    updatee(mid+1,e,idx*2+2,SE,val);
    tree[idx]=max(tree[idx*2+1],tree[idx*2+2]);
}

int gett(int s,int e,int idx,int S,int E){
    if(s>E || e<S)return 0;
    if(s>=S && e<=E)return tree[idx];
    int mid=(s+e)/2;
    return max(gett(s,mid,idx*2+1,S,E),gett(mid+1,e,idx*2+2,S,E));
}

signed main(){
    FASTER;
    cin>>n;
    for(int i=0;i<n;i++)cin>>h[i];
    for(int i=0;i<n;i++)cin>>a[i];
    
    for(int i=0;i<n;i++){
        dp[h[i]]=gett(0,n,0,0,h[i]-1)+a[i];
        updatee(0,n,0,h[i],dp[h[i]]);
    }
    
    cout<<*max_element(dp,dp+200005);
    
}

Measured memory_bytes: 12416
def dfs(now):
    if vis[now]==1:
        return 0
    vis[now]=1
    for i in range(n):
        if graph[now][i]==1:
            dfs(i)
n,m=map(int,input().split())
edge=[[int(i) for i in input().split()]for i in range(m)]
graph=[[0 for i in range(n)]for i in range(n)]
vis=[0]*n
for i in range(m):
    graph[edge[i][0]-1][edge[i][1]-1]=1
    graph[edge[i][1]-1][edge[i][0]-1]=1
ans=0
for i in range(m):
    graph[edge[i][0]-1][edge[i][1]-1]=0
    graph[edge[i][1]-1][edge[i][0]-1]=0
    vis=[0]*n
    dfs(0)
    connect=False
    for j in range(n):
        if vis[j]==0:
            connect=True
    if connect:
        ans+=1
    graph[edge[i][0]-1][edge[i][1]-1]=1
    graph[edge[i][1]-1][edge[i][0]-1]=1
print(ans)



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

int main()
{

  int N;
  cin >> N;
  
  vector<long long> yaku(N);
  for(int i=1;i<N+1;i++)
  {
    for(int j=i;j<N+1;j+=i)
    { 
//      cout << j << " ";
      yaku[j-1]++;
    }
//    cout << endl;
  }

  long long sum=0;
  for(int i=0;i<N;i++)
  {
//    cout << yaku[i] << " ";
    sum+=(i+1)*yaku[i];
  }
  cout << sum <<endl;
  
  return 0;
}
  

Measured memory_bytes: 81388
x,y,a,b,c=map(int,input().split())
p=list(map(int,input().split()))
q=list(map(int,input().split()))
r=list(map(int,input().split()))
s=[]
for i in range(a):
    s.append([p[i],1])
for i in range(b):
    s.append([q[i],2])
for i in range(c):
    s.append([r[i],0])
s.sort(reverse=True)
o=0
X,Y,Z=0,0,0
for i in range(a+b+c):
    if s[i][1]==1 and X<x:
        X+=1
        Z+=1
        o+=s[i][0]
    elif s[i][1]==2 and Y<y:
        Y+=1
        Z+=1
        o+=s[i][0]
    elif s[i][1]==0:
        Z+=1
        o+=s[i][0]
    if Z==x+y:
        break
print(o)

Measured memory_bytes: 49788
#include<stdio.h>
#include<string.h>
#include<iostream>
#include<algorithm>
#include<map>
#include<string>
#include<set>
#include<stack>
#include<queue>
using namespace std;
const int maxn  = 200000;
long long n,ans;
long long num[maxn];
int main(){
	scanf("%lld",&n);
	for(int i = 1; i <= n ; i++){
		scanf("%lld",&num[i]);
	}
	sort(num + 1, num+ n + 1);
	if(n&1){
		long long temp1 = 0,tem1 = 0,ans1 = 0;
		long long temp2 = 0,tem2 = 0,ans2 = 0;
		int t1 = n / 2 + 1;
		for(int i = 1 ;i <= t1 ; i++) temp1 += 2*num[i];
		for(int i = t1 + 1 ; i <= n ; i++) tem1 += 2*num[i];
		ans1 = tem1 - temp1 + num[t1] + num[t1 - 1];
		int t2 = n/2; 
		for(int i = 1 ; i <= t2 ; i++) temp2 += 2*num[i];
		for(int i = t2 + 1 ; i <= n ; i++) tem2 += 2*num[i];
		ans2 = tem2 - temp2 - num[t2 + 1] - num[t2 + 2];
		ans = max(ans1,ans2);	
	}else{
		long long t = n/2;
		long long tem = 0,temp = 0;
		for(int i = 1 ; i <= t ; i++) temp += 2*num[i];
		for(int i = t + 1 ; i <= n ; i++) tem += 2 * num[i];
		ans = tem - temp - num[t + 1] + num[t];
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
using namespace std;
int main(){
  string s;
  cin>>s;
  if(s[0]=='Y'&&s[1]=='A'&&s[2]=='K'&&s[3]=='I'){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
int main(){
    string s;
    cin >> s;
    if(s == "abc" || s == "acb" || s == "bac" || s == "bca" || s == "cab" || s == "cba")
    cout << "Yes" << endl;
    else 
    cout << "No" << endl;
    return 0; 
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const ll MOD=(ll)1e9+7;
const ll INF=(ll)1e18+10;
const double PI=acos(-1);

template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
int dy[]={-1,1,0,0};
int dx[]={0,0,-1,1};



int main() {
    ll N,A,B; cin>>N>>A>>B;
    ll ansr,ansb;
    ansr = N / (A+B) * A + min(N%(A+B),A);
    ansb = N -ansr;
    cout<<ansr<<endl;
    return 0;
}


Measured memory_bytes: 256
import std.stdio;
import std.conv;
import std.string;
import std.typecons;
import std.algorithm;
import std.array;
import std.range;
import std.math;
import std.regex;
import std.container;

void main()
{
	int[char] pat;
	pat['I'] = 1;
	pat['V'] = 5;
	pat['X'] = 10;
	pat['L'] = 50;
	pat['C'] = 100;
	pat['D'] = 500;
	pat['M'] = 1000;
	foreach (line; stdin.byLine) {
		int pre;
		int sum;
		foreach_reverse(c; line.chomp) {
			auto v = pat[c];
			if (pre <= v) {
				sum += v;
			} else {
				sum -= v;
			}
			pre = v;
		}
		sum.writeln;
	}
}

Measured memory_bytes: 1032
#include <stdio.h>
#include <stdlib.h>
#include <inttypes.h>
#include <stdint.h>
#include <string.h>
#include <wchar.h>

uint32_t A[200000];

static int64_t calcMinAddCount(const uint32_t N) {
	if (A[0] != 0) {
		return INT64_C(-1);
	}

	int64_t minAddCount = 0;

	for (uint32_t idx = 1; idx < N; idx++) {
		const int64_t diff = (int64_t)(A[idx]) - (int64_t)(A[idx - 1]);

		if (diff > 1) {
			return INT64_C(-1);
		}
		else if (diff == 0) {
			minAddCount += (int64_t)(A[idx]);
		}
		else if (diff == 1){
			minAddCount++;
		}
		else {
			minAddCount += (int64_t)(A[idx]);
		}
	}

	return minAddCount;
}

int main(void) {
	uint32_t N;

	scanf("%"PRIu32"\n", &N);
	for (uint32_t idx = 0; idx < N - 1; idx++) {
		scanf("%"PRIu32"\n", &(A[idx]));
	}
	scanf("%"PRIu32, &(A[N - 1]));

	const int64_t minAddCount = calcMinAddCount(N);

	printf("%"PRId64, minAddCount);

	return 0;
}


Measured memory_bytes: 896
/*
 Remember not to use arithmetic operation in double while comparision 

 priority of uses
 array > maps > unordered_maps
*/

#include<bits/stdc++.h>
#define lli long long int
#define vl vector<lli>
#define vi vector<int>
#define pb push_back
#define pii pair<int,int>
#define pll pair<lli,lli>
const lli mod = 0LL+1e9L+7;
using namespace std;
int main()
{
	ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

	int n,m;
	cin>>n>>m;
	char a[n][m];
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<m;j++)
			cin>>a[i][j];
	}	
	lli dp[n][m];
	memset(dp,0,sizeof(dp));

	if(a[0][0]=='#')
		dp[0][0]=0;
	else
		dp[0][0]=1;

	for(int i=1;i<n;i++)
	{
		if(a[i][0]=='#')
			dp[i][0]=0;
		else
			dp[i][0]=dp[i-1][0];
	}

	for(int i=1;i<m;i++)
	{
		if(a[0][i]=='#')
			dp[0][i]=0;
		else
			dp[0][i]=dp[0][i-1];
	}

	for(int i=1;i<n;i++)
	{
		for(int j=1;j<m;j++)
		{
			if(a[i][j]=='#')
				dp[i][j]=0;
			else
				dp[i][j]=(dp[i-1][j]%mod+dp[i][j-1]%mod)%mod;
		}
	}
	cout<<dp[n-1][m-1];
	return 0;
}


Measured memory_bytes: 9088
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;

/*
<url:https://agc013.contest.atcoder.jp/tasks/agc013_a>
問題文============================================================
長さ N の配列 A が与えられます。
 A を何箇所かで切って、A の連続した部分であるようないくつかの数列に分けます。
 この時、分けられたあとの数列は全て、単調非減少または単調非増加な列になっている必要があります。
 最小で何個の数列に分ければ良いかを求めて下さい。
=================================================================

解説=============================================================

 先に、隣り合う値が等しい部分に関しては、処理を簡単にするために、unique等で
 削除しておくと楽
 
 あとは、順番に現在 単調増加なのか減少なのか、または確定できないのか
 といったフラグを持っておき、実際にシミュレーションしていく
================================================================
*/
int main(void) {
	cin.tie(0); ios::sync_with_stdio(false);
    ll N; cin >> N;
    vector<ll> A(N); for(auto& in:A) cin >> in;
    A.erase(unique(A.begin(),A.end()),A.end());
    int mode = 0;
    int ans = 1;
    for(int i = 0 ; i < (int)A.size()-1;i++){
        if(mode == 0){
            if(A[i] < A[i+1]) mode = 1;
            else mode = -1;
        }else{
            if(mode == 1){
                if(A[i] > A[i+1]){
                    ans++;
                    mode = 0;
                }
            }else{
                if(A[i] < A[i+1]){
                    ans++;
                    mode = 0;
                }
            }
        }
    }
    cout << ans << endl;
	return 0;
}


Measured memory_bytes: 1024
fun main (args : Array<String>) {
	val s = readLine()
	val S : String = s.toString()
	var str : String = ""
	for (i in S) {
		if (i in listOf('0','1','2','3','4','5','6','7','8','9')) {
			str += i.toString()
		}
	}
	if (str.toInt() <= 20190430) {
		println("Heisei")
	} else {
		println("TBD")
	}
	
}

Measured memory_bytes: 36120
#include <bits/stdc++.h>
//#pragma GCC optimize(2)
#define pb push_back
#define mp make_pair
#define all(x) x.begin(),x.end()
#define rep(i,a,b) for(int i = (a);i <= (b);i++)
#define pii pair<int,int>
#define pll pair<long long, long long>
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll mod = 1e9 + 7;
const ll INF = 0x3f3f3f3f3f3f3f3f;
const int inf = 0x3f3f3f3f;
const int maxn = 3e5 + 5;
const double eps = 1e-8;
const double pi = acos(-1.0);	
ll gcd(ll a,ll b){return !b?a:gcd(b,a%b);}
ll lcm(ll a,ll b){return a * b / gcd(a,b);}
ll qw(ll x,ll y){ll res = 1;while(y){if(y & 1) res *= x;x = x * x;y >>= 1;}return res;}
ll poww(ll x,ll y,ll p){ll ans = 1;while(y){if(y & 1) ans = ans * x % p;x = x * x % p;y >>= 1;}return ans % p;}
bool isp(ll x){if(x < 2) return 0; for(ll i = 2;i * i <= x;i++){if(x % i == 0) return 0;}return 1;}
int k;
string s;
void solve(){
	if(s.size() <= k) cout << s << endl;
	else{
		for(int i = 0;i < k;i++) cout << s[i];
		cout << "..." << endl;
	}
	return;
}
int main(){
	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	cin >> k >> s;
	solve();
	return 0;
}
//do smt instead of nothing! never give up!


Measured memory_bytes: 3660
#include<iostream>
#include<string>
using namespace std;
int b[4][3];
void operate(char c){
	if(c=='E'){
		int temp1=b[0][2];
		for(int i=0;i<4;i++){
			b[i][2]=b[0][1];
		}
		b[0][1]=b[0][0];
		for(int i=0;i<4;i++){
			b[i][0]=b[2][1];
		}
		b[2][1]=temp1;		
	}else if(c=='N'){
		int temp1=b[0][1];
		for(int i=0;i<3;i++){
			b[i][1]=b[i+1][1];
		}
		b[3][1]=temp1;
	}else if(c=='S'){
		int temp1=b[3][1];
		for(int i=3;i>0;i--){
			b[i][1]=b[i-1][1];
		}
		b[0][1]=temp1;
	}else{
		int temp1=b[0][0];
		for(int i=0;i<4;i++){
			b[i][0]=b[0][1];
		}
		b[0][1]=b[0][2];
		for(int i=0;i<4;i++){
			b[i][2]=b[2][1];
		}
		b[2][1]=temp1;
	}
}
int main(){
	int a[6];
	for(int i=0;i<6;i++)
		cin>>a[i];
	for(int i=0;i<4;i++){
		b[i][0]={a[3]};
		b[i][2]={a[2]};
	}
	b[0][1]=a[0];
	b[1][1]=a[1];
	b[2][1]=a[5];
	b[3][1]=a[4];
	string s;
	cin>>s;
	for(int i=0;i<s.size();i++){
		operate(s[i]);
	}
	cout<<b[0][1]<<endl;
	return 0;
} 


Measured memory_bytes: 3192
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define int long long
using namespace __gnu_pbds;
using namespace std;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

int power[100005];
signed main()
{
     ios_base::sync_with_stdio(false);
     cin.tie(NULL);  
//  #ifndef ONLINE_JUDGE
//     freopen ("INPUT.txt" , "r" , stdin);
//     freopen ("OUTPUT.txt" , "w" , stdout);
//  #endif

// -------------------------------------Code starts here---------------------------------------------------------------------     

   int n,r;
   cin>>n>>r;
   if(n>=10)
   cout<<r;
   else
   cout<<r+100*(10-n);

// -------------------------------------Code ends here------------------------------------------------------------------
     clock_t clk;
 	clk = clock();
 
    clk = clock() - clk;
 	cerr << fixed << setprecision(6) << "Time: " << ((double)clk)/CLOCKS_PER_SEC << "\n";
 	return 0;
 }

Measured memory_bytes: 256
import sys,collections as cl,bisect as bs
sys.setrecursionlimit(100000)
mod = 10**9+7
Max = sys.maxsize
def l(): #intのlist
    return list(map(int,input().split()))
def m(): #複数文字
    return map(int,input().split())
def onem(): #Nとかの取得
    return int(input())
def s(x): #圧縮
    a = []
    aa = x[0]
    su = 1
    for i in range(len(x)-1):
        if aa != x[i+1]:
            a.append([aa,su])
            aa = x[i+1]
            su = 1
        else:
            su += 1
    a.append([aa,su])
    return a
def jo(x): #listをスペースごとに分ける
    return " ".join(map(str,x))
def max2(x): #他のときもどうように作成可能
    return max(map(max,x))

n,k = m()

a = l()

aaa = [0 for i in range(n)]
co = [0 for i in range(2002)]


for i in range(n-1,-1,-1):
    aaa[i] = co[a[i]]
    for j in range(a[i]+1,2000+2):
        co[j] += 1


su = 0

for i in range(n-1,-1,-1):
    su += k * aaa[i]
    su %= mod
    su += (((k)*(k-1))//2)*co[a[i]]
    su %= mod


print(su)




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

#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
const int INF = 1e9;

int main() {
  int n, k;
  cin >> n >> k;
  int a[n];
  rep(i, n) cin >> a[i];
  while (k--) {
    int b[n] = {};
    int m = n * 2;
    for (int i = 0; i < n; i++) {
      m = min(m, a[i]);
      b[max(0, i - a[i])]++;
      if (i + a[i] + 1 < n) b[i + a[i] + 1]--;
    }
    if (m >= n) break;
    rep(i, n - 1) b[i + 1] += b[i];
    memcpy(a, b, sizeof(b));
  }
  for (int i = 0; i < n; i++) cout << a[i] << ' ';
}

Measured memory_bytes: 5116
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ

		Scanner sc = new Scanner(System.in);

		//配列3つ用意
		int[] X = new int[3];

		//3回繰り返す
		for(int i = 0; i < 3;i++) {
			X[i]  = sc.nextInt();

		}


		int change = 0;
		change = X[0];
		X[0] = X[1];
		X[1] =change;

		int change1= 0;
		change1 = X[0];
		X[0] = X[2];
		X[2] = change1;


		for(int j = 0; j<3;j++) {
			System.out.print(X[j]+" ");
		}


		sc.close();


	}

}


Measured memory_bytes: 38412
#include <cstdio>
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <string>
#include <cstring>
#include <sstream>
#include <algorithm>
using namespace std;

typedef long long ll;

const int Maxn = 55;
const ll Inf = 9000000000000000000ll;

int n, k;
int X[Maxn], Y[Maxn];
vector <int> myX, myY;
ll res = Inf;

int main()
{
	scanf("%d %d", &n, &k);
	for (int i = 0; i < n; i++) {
		scanf("%d %d", &X[i], &Y[i]);
		myX.push_back(X[i]); myY.push_back(Y[i]);
	}
	sort(myX.begin(), myX.end()); sort(myY.begin(), myY.end());
	for (int i = 0; i < myX.size(); i++)
		for (int i2 = i; i2 < myX.size(); i2++)
			for (int j = 0; j < myY.size(); j++)
				for (int j2 = j; j2 < myY.size(); j2++) {
					int cnt = 0;
					for (int z = 0; z < n; z++)
						cnt += myX[i] <= X[z] && X[z] <= myX[i2] && myY[j] <= Y[z] && Y[z] <= myY[j2];
					if (cnt >= k) res = min(res, ll(myX[i2] - myX[i]) * (myY[j2] - myY[j])); 
				}
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstring>
#include<queue>
#include<cstdio>
#include<stack>
#include<cmath>
#include<cstdlib>
#include<algorithm>
using namespace std;
const int maxn=1e8+7;
#define INF 0x3f3f3f3f
#define IO ios::sync_with_stdio(false);\
    cin.tie(0);\
    cout.tie(0);
typedef long long ll;
int main()
{
    IO;
    int n;
    cin>>n;
    int t;
    int num2=0;
    int mod4=0,notmod=0;
    for(int i=0;i<n;i++)
    {
        cin>>t;
        if(t%4==0) mod4++;
        else if(t%2==0) num2++;
        else notmod++;
    }
    if(num2!=0)
    {
        notmod++;
        n=n-num2+1;
    }
    if(mod4>=n/2)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 256
from __future__ import print_function

import sys
sys.setrecursionlimit(500000)

import re
import array
import copy
import functools
import operator

import math
import string
import fractions
from fractions import Fraction

import collections
import itertools
import bisect

import random
import time

import heapq
from heapq import heappush
from heapq import heappop
from heapq import heappushpop
from heapq import heapify
from heapq import heapreplace
from queue import PriorityQueue as pq
from queue import Queue

from itertools import accumulate

from collections import deque
from collections import Counter

from operator import mul
from functools import reduce

input = sys.stdin.readline


def eprint(*args, **kwargs):
    print(*args, file=sys.stderr, **kwargs)
    return

# from fractions import gcd
# from math import gcd

# def lcm(n, m):
#     return int(n * m / gcd(n, m))


# def coprimize(p, q):
#     common = gcd(p, q)
#     return (p // common, q // common)


# def find_gcd(list_l):
#     x = reduce(gcd, list_l)
#     return x


def combinations_count(n, r):
    r = min(r, n - r)
    numer = reduce(mul, range(n, n - r, -1), 1)
    denom = reduce(mul, range(1, r + 1), 1)
    return numer // denom


mod=1000000007
def combinations_count_mod(n, r):
    r = min(r, n - r)
    numer = reduce(lambda x,y: x*y%mod, range(n, n - r, -1), 1)
    denom = pow( reduce(lambda x,y: x*y%mod, range(1, r + 1), 1) , mod-2, mod)
    return numer * denom % mod


def solve(k):
    dp=[0 for _ in range(k+100)]
    for i in range(1,k+1):
        dp[i]=(dp[i-1]*10+7)%k
        if dp[i]%k==0:
            return (i)
    return -1

def main():
    k = int(input().strip())
    print(solve(k))


if __name__ == '__main__':
    main()

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

#define all(x) (x).begin(),(x).end()
#define sz(x) int(x.size())
#define pb push_back

using namespace std;
using ll=long long;
using pii= pair<int, int>;
mt19937 gen(chrono::steady_clock::now().time_since_epoch().count());
template<typename... T> void rd(T&... args) {((cin>>args), ...);}
template<typename... T> void wr(T... args) {((cout<<args<<" "), ...);cout<<endl;}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int h,w,m;
    cin>>h>>w>>m;
    set<pair<int,int>> st;
    vector<int> ch(h),cw(w);
    for(int i=0;i<m;i++){
        int x,y;
        cin>>x>>y;
        x--,y--;
        st.insert({x,y});
        ch[x]++, cw[y]++;
    }
    int mh=*max_element(all(ch));
    int mw=*max_element(all(cw));
    vector<int> gh,gw;
    for(int i=0;i<h;i++) if(ch[i]==mh) gh.push_back(i);
    for(int i=0;i<w;i++) if(cw[i]==mw) gw.push_back(i);
    if(ll(sz(gh))*sz(gw)>m) cout<<mh+mw;
    else{
        for(auto x:gh) for(auto y:gw){
            if(!st.count({x,y})) return cout<<mh+mw,0;
        }
        cout<<mh+mw-1;
    }
    return 0;
}



Measured memory_bytes: 23860
#include <stdio.h>

#define NO_DATA -1
#define MAX_COUNT 1000
int main(int argc, const char * argv[]) {
    int input;
    int result[MAX_COUNT];
    int scanResult;
    
    for (int i=0;i<MAX_COUNT;i++) {
        result[i]=NO_DATA;
    }
    
    scanResult = scanf("%d", &input);
    int count=0;
    int index=0;
    while (scanResult!=EOF) {
        count = 0;
        for (int i = 0 ; i < 10 ; i++)
        {
            for (int j = 0 ; j < 10 ; j++)
            {
                for (int k = 0 ; k < 10 ; k++)
                {
                    for (int l = 0 ; l < 10 ; l++)
                    {
                        if (i + j + k + l == input) count++;
                    }
                }
            }
        }
        result[index]=count;
        index++;
        scanResult = scanf("%d", &input);
    }
    
    for (int i=0;i<index;i++) {
        printf("%d\n", result[i]);
    }
    return 0;
}



Measured memory_bytes: 2048
#include <bits/stdc++.h>
#define int long long
#define ld long double
#define endl "\n"
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb(x) push_back(x)
#define mp(a,b) make_pair(a,b)
#define ms(v,x) memset(v,x,sizeof(v))
#define all(v) v.begin(),v.end()
#define ff first
#define ss second
#define rep(i,l,r) for(int i = (int)l;i<(int)r;i++)
#define td(v) v.begin(),v.end()
#define sz(v) (int)v.size()
//#define M   1000000007 // 1e9 + 7

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
inline int mod(int n, int m){ int ret = n%m; if(ret < 0) ret += m; return ret; }
int gcd(int a, int b){return (b == 0 ? a : gcd(b, a%b));}
int exp(int a,int b,int m){
    
    if(b==0) return 1;
    if(b==1) return mod(a,m);
    int k = mod(exp(a,b/2,m),m);
    if(b&1){
        return mod(a*mod(k*k,m),m);
    }
    else return mod(k*k,m);
}
const int M = 1e9 + 7;
const int MAXN = 200100;
int dp[MAXN];
int fat[MAXN],inv[MAXN];
int C(int n,int k){
	return mod(fat[n]*mod(inv[k]*inv[n-k],M),M);
}
int pa(int n,int t){
	if(n==0)return 1;
	return mod(pa(n-1,t) + C(t,n)*(n+1),M); 
}
int pot[MAXN],pot2[MAXN];
int32_t main(){
	fat[0] = inv[0] = 1;
	for(int i=1;i<MAXN;i++){
		fat[i] = (fat[i-1]*i)%M;
		inv[i] = exp(fat[i],M-2,M);
	}
	memset(dp,-1,sizeof(dp));
	pot[0] = pot2[0] = 1;
	for(int i=1;i<MAXN;i++){
		pot[i] = (pot[i-1]*2LL)%M;
		pot2[i] = (pot2[i-1]*4LL)%M;
	}
    fastio;
   	int tot=0;
   	int n;
   	cin>>n;
   	vector<int> c(n);
   	for(int i=0;i<n;i++)cin>>c[i];
   		int ant = 1;
   	sort(c.begin(),c.end(),greater<int>());
   for(int i=1;i<=n;i++){
   		tot = mod(tot + mod(pot2[n-1]*mod(c[i-1]*(i+1),M),M),M);
   }
   cout<<tot<<endl;
}

Measured memory_bytes: 9600
n=int(input())
h=list(map(int,input().split()))
res=0
t=0
while(any(h)):
    if h[t]==0:
        t+=1
    else:
        j=False
        for k in range(t,n):
            if h[k]==0:
                j=True
                break
        if j:
            k-=1
        for i in range(t,k+1):
            h[i]-=1
        res+=1
print(res)

Measured memory_bytes: 41436
N=int(input())
A=[int(i) for i in input().split()]
B=[int(i) for i in input().split()]
C=[int(i) for i in input().split()]

ans=sum(B)

for i in range(N-1):
    if A[i+1]-A[i]==1:
        ans += C[A[i]-1]

print(ans)

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

int pos[100005][26];
int main(void){
    string s, t;
    cin >> s >> t;
    
    int last[26];
    memset(last, -1, sizeof(last));
    for (int i = s.length()-1; 0 <= i; i--) {
        for (int j = 0; j < 26; j++) {
            pos[i+1][j] = last[j];
        }
        last[s[i] - 'a'] = i+1;
    }
    for (int i = 0; i < 26; i++) {
        pos[0][i] = last[i];
    }
    
    int loop_cnt = 0;
    int crt_pos = 0;
    for (int i = 0; i < t.length(); i++) {
        if (pos[crt_pos][t[i] - 'a'] != -1) {
            crt_pos = pos[crt_pos][t[i] - 'a'];
        } else {
            loop_cnt++;
            crt_pos = pos[0][t[i] - 'a'];
        }
        if (crt_pos == -1) {
            cout << -1 << endl;
            return 0;
        }
    }
    cout << loop_cnt * s.length() + crt_pos << endl;
}


Measured memory_bytes: 10752
#!/usr/bin/env python3

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

s = input()
n = len(s)
ans1 = 0
for i in range(n):
    if i % 2 == 0:
        if s[i] == '0':
            ans1 += 1
    else:
        if s[i] == '1':
            ans1 += 1
ans2 = 0
for i in range(n):
    if i % 2 == 0:
        if s[i] == '1':
            ans2 += 1
    else:
        if s[i] == '0':
            ans2 += 1
ans = min(ans1,ans2)
print(ans)

Measured memory_bytes: 40176
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
    String s;

    public static void main(String args[]) {
        new Main().run();
    }

    void run() {
        FastReader sc = new FastReader();
        s = sc.next();
        solve();
    }

    void solve() {
        System.out.println(s.replace(',', ' '));
    }

    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

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

        String next() {
            while (st == null || !st.hasMoreElements())
            {
                try
                {
                    st = new StringTokenizer(br.readLine());
                }
                catch (IOException e)
                {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

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

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

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

        String nextLine() {
            String str = "";
            try
            {
                str = br.readLine();
            }
            catch (IOException e)
            {
                e.printStackTrace();
            }
            return str;
        }
    }
}


Measured memory_bytes: 21076
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        final int H = sc.nextInt();
        final int W = sc.nextInt();
        int D = sc.nextInt();
        int[][] L = new int[2][H*W+1];
        for(int i = 1;i < H+1;i++){
            for(int j = 1;j < W+1;j++){
                int aij = sc.nextInt();
                L[0][aij] = i;
                L[1][aij] = j;
            }
        }
        int[] A = new int[H*W+1];
        for(int i = 1;i <= D;i++){
            for(int j = i+D;j < H*W+1;j+=D){
                A[j] = A[j-D]+Math.abs(L[0][j]-L[0][j-D])+Math.abs(L[1][j]-L[1][j-D]);
            }
        }
        final int Q = sc.nextInt();
        int[] li = new int[Q];
        int[] ri = new int[Q];
        for(int i = 0;i < Q;i++){
            li[i] = sc.nextInt();
            ri[i] = sc.nextInt();
        }
        for(int i = 0;i < Q;i++){
            System.out.println(A[ri[i]]-A[li[i]]);
        }
    }
}

Measured memory_bytes: 94360
import java.util.*;
import java.util.PriorityQueue;

public class Main
{
  public static void main(String[] args)
  {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    PriorityQueue<Double> q = new PriorityQueue<Double>();
    for(int i = 0; i < n; ++i)
    {
      double x = sc.nextDouble();
      q.add(x);
    }
    while(q.size() > 1)
    {
      double a = q.poll();
      double b = q.poll();
      q.add((a+b)/2.0);
    }
    double ans = q.poll();

    System.out.println(ans);
  }

}


Measured memory_bytes: 23124
import sys
import numpy as np
import numba
from numba import njit, b1, i4, i8, f8

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

def naive(K, P, C):
    P = P - 1
    N = len(P)
    INF = 1 << 60
    ret = -INF
    for v in range(N):
        for n in range(1, K + 1):
            s = 0
            w = v
            for _ in range(n):
                s += C[w]
                w = P[w]
            ret = max(ret, s)
    return ret

@njit((i8, i8[:], i8[:]), cache=True)
def main(K, P, C):
    N = len(P)
    INF = 1 << 60
    P = P - 1
    best_score = -INF
    for v in range(N):
        w = v
        L = 0
        S = 0
        while True:
            S += C[w]
            L += 1
            w = P[w]
            if v == w:
                break
        score = 0
        w = v
        for n in range(1, L + 1):
            # はじめに n 個とったあと、周期
            score += C[w]
            w = P[w]
            if n > K:
                break
            max_add = (K - n) // L
            x = score + max(S * 0, S * max_add)
            best_score = max(best_score, x)
    return best_score

N, K = map(int, readline().split())
P = np.array(readline().split(), np.int64)
C = np.array(readline().split(), np.int64)

print(main(K, P, C))

Measured memory_bytes: 106764
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define inf 1001001001001001001
#define mod 1000000007
#define mod2 998244353
#define pi acos(-1)
#define all(v) v.begin(),v.end()

int main(){
    int tmp;
    set<int>s;
    rep(i,2){
        cin>>tmp;
        s.insert(tmp);
    }
    for(int i=1;i<=3;i++){
        if(!s.count(i)){
            cout<<i<<endl;
            return 0;
        }
    }
}

Measured memory_bytes: 3588