akhauriyash/Code-Regression huggingface dataset:
/*#          #  # # # # #  # # # # #  # # # # #  #          #
  #          #  #       #  #       #  #          #          #
  # # # # # ##  # # # # #  ## # # #   # # # # #  # # # # # ##
  #          #  #       #  #    #             #  #          #
  #          #  #       #  #      #   # # # # #  #          #*/
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define int long long
#define mkp make_pair
#define pb push_back
#define ff first
#define ss second
#define debug1(a) cout<<a<<endl;
#define debug2(a,b) cout<<a<<' '<<b<<endl;
#define debug3(a,b,c) cout<<a<' '<<b<<' '<<c<<endl;
#define rep(i,n) for(int i=0;i<n;i++)
#define repr(i,a,b)for(int i=a;i<b;i++)
#define repre(i,a,b)for(int i=a;i<=b;i++)
#define pi pair<int,int>
#define pii pair<int,pi>
#define mp map<int,int>
#define iofile freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);
#define ump unordered_map<int,int>
#define st set<int>
#define ust unordered_set<int>
#define mst multiset<int>
#define pq priority_queue
#define mpq priority_queue<int,vector<int>,greater<int> >
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define sumofdigits(sum,num) int sum = 0; while (n != 0) { sum = sum + n % 10; n = n/10; }
#define int2str(str,n) n=boost::lexical_cast<int>(str);
#define float2str(str,n) n=boost::lexical_cast<float>(str);
using namespace __gnu_pbds;
using namespace std;
#define Endl endl
#define ar(n) int h[n]
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> orderedSet;
typedef tree<int,null_type,less_equal<int>,rb_tree_tag,tree_order_statistics_node_update> orderedMSet;
//*p.find_by_order(index) return value at index
//p.order_of_key(key) return index
int gcd(int a, int b){return b ? gcd (b, a % b) : a;}

int32_t main()
{
    fastio
    int tcase=1;
    //cin>>tcase;
    while(tcase--)
    {
        int n;
		cin>>n;
		int h[n],dp[n];
		rep(i,n)cin>>h[i];
		memset(dp,0,sizeof(dp));
		dp[1]=abs(h[1]-h[0]);
		repr(i,2,n)
		{
			dp[i]=min(dp[i-2]+abs(h[i]-h[i-2]),dp[i-1]+abs(h[i]-h[i-1]));
		}
		cout<<dp[n-1]<<endl;
    }
    return 0;
}

bool isPrime(int n)
{
    if (n <= 1)  return false;
    if (n <= 3)  return true;
    if (n%2 == 0 || n%3 == 0) return false;
    int p=sqrt(n);
    for(int i=5;i<=p;i=i+6)
        if (n%i == 0 || n%(i+2) == 0)
            return false;
    return true;
}

int binpow(int a,int b)
{
    int res=1;
    while (b > 0)
    {
        if (b & 1)res = res * a;
        a = a * a;
        b >>= 1;
    }
    return res;
}


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

int main() {
  int n;
  cin >> n;
  vector<int> p(n);
  for (int i = 0; i < n; i++) {
    cin >> p.at(i);
  }
  int truecount = 0;
  int min = p.at(0);
  for (int i = 0; i < n; i++) {
    if (min >= p.at(i)) {
      min = p.at(i);
      truecount++;
    }
  }
  cout << truecount << endl;
}

      

Measured memory_bytes: 1024
# row = [int(x) for x in input().rstrip().split(" ")]
# n = int(input().rstrip())
# s = input().rstrip()
# row = [int(input().rstrip()) for _ in range(n)]

def resolve():
    import sys
    input = sys.stdin.readline
    n = int(input().rstrip())
    a_list = [int(x) for x in input().rstrip().split(" ")]

    # 奇数になる組み合わせ
    odd = 1
    for a in a_list:
        if a % 2 == 0:
            odd *= 2

    print(3 ** len(a_list) - odd)



if __name__ == "__main__":
    resolve()


Measured memory_bytes: 61852
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <utility>
#include <algorithm>
#include <numeric>
#include <string>

using namespace std;
using ll = long long int;

#define rep(i, v) for(ll i = 0; i < (v); ++i)

int main(){
    ll A, B, C;
    cin >> A >> B >> C;
    ll a = C - (A - B);
    if(a < 0) a = 0;
    cout << a << endl;
}



Measured memory_bytes: 384
#include <bits/stdc++.h>
#define REP(i, n) for (ll i = 0; i < (ll)(n); i++)
#define FOR(i, a, b) for (ll i = a; i <= (ll)(b); i++)
using namespace std;
typedef long long ll;

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

  ll *ans = new ll[N + 1];
  FOR(i, 0, N)
  {
    ans[i] = 0;
  }

  ll a;
  REP(i, N - 1)
  {
    cin >> a;
    ans[a]++;
  }

  FOR(i, 1, N)
  {
    cout << ans[i] << endl;
  }

  return 0;
}

Measured memory_bytes: 5184
#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 10;
using ll = long long;
int n;
ll k;
ll a[N];
bool pred(ll m) {
	ll tot = 0;
	for(int i = 0; i < n; ++i) {
		if(a[i] < 0) {
			ll l = -1, r = n;
			while(r - l > 1) {
				ll mid = (l + r) / 2;
				if(a[i] * a[mid] <= m)
					r = mid;
				else
					l = mid;
			}
			tot += (n - r);
		} else {
			ll l = -1, r = n;
			while(r - l > 1) {
				ll mid = (l + r) / 2;
				if(a[i] * a[mid] <= m)
					l = mid;
				else
					r = mid;
			}
			tot += r;
		}
		if(a[i] * a[i] <= m) tot--;
	}
	tot /= 2;
	return tot >= k;
}
int main() {
	scanf("%d %lld", &n, &k);
	for(int i = 0; i < n; ++i)
		scanf("%lld", &a[i]);
	sort(a, a + n);
	// pred(-7);
	// return 0;
	ll lo = -2e18, hi = 2e18;
	while(hi - lo > 1) {
		ll mid = (lo + hi) / 2;
		if(pred(mid))
			hi = mid;
		else
			lo = mid;
	}
	ll ans = hi;
	printf("%lld\n", ans);
	return 0;
}



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

int main(){
    int a,b;
    cin >> a >> b;
    cout << a+b/2 << endl;
    return 0;
}

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

int main(){
	int date[10], work;
	for(int i = 0; i < 10; i++){
		cin >> date[i];
	}

	for(int i = 9; i > 6; i--){
		for(int j = i; j >= 0; j--){
			if(date[i] < date[j]){
				work = date[i];
				date[i] = date[j];
				date[j] = work;
			}
		}
		cout << date[i] << endl;
	}
	return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define int long long
#define vec(a,n) vector<int> (a)((n))
#define Vec(a,n) vector<string> (a)((n))
#define twovec(a,n,m) vector<vector<int>> a(n,vector<int>(m,0))
#define Twovec(a,n,m) vector<vector<double>> a(n,vector<double>(m,0))
#define P pair<int,int>
#define All(a) (a).begin(),(a).end()
#define Sort(a) sort(All(a))
#define Reverse(a) reverse(All(a))
#define PQ(n) priority_queue<P,vector<P>,greater<P>> (n)
#define pq(n) priority_queue<int> (n)
#define Lower(a,t) lower_bound(All(a),t)
using namespace std;
void Debug(auto a);

signed main(){
    int n,c,k;
    cin >> n >> c >> k;
    vec(a,n);
    REP(i,n){
        cin >> a[i];
    }
    Sort(a);
    int start = 0;
    int last = k;
    int kyaku = 1;
    int ans = 1;
    REP(i,n){
        if(i==0){
            start = a[0];
            last += a[0];
        }
        else if(a[i] <= last){
            if(kyaku<c){
                kyaku++;
            }
            else{
                start = a[i];
                last = a[i] + k;
                ans++;
                kyaku = 1;
            }
        }
        else{
            start = a[i];
            last = a[i] + k;
            ans++;
            kyaku = 1;

        }

    }

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



void Debug(auto a){
    cout << "{ ";
    for(auto b: a){
        cout << b << " ";
    }
    cout << "}" << endl;
}


Measured memory_bytes: 1024
n, m = map(int, input().split())

students = []
checkpoints = []

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

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

for i, j in students:
    min_dist = 10**10
    point = -1
    for x in range(m):
        dist = abs(checkpoints[x][0] - i) + abs(checkpoints[x][1] - j)
        if dist < min_dist:
            min_dist = dist
            point = x + 1
    print(point)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#include <math.h>
#include <algorithm>
#include <cstdlib>
#include <string>
#define ll long long
#define ld long double
#define pii pair<int, int>
#define pll pair<ll, ll>
#define f first
#define s second
#define fast ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
#define pb push_back
#define eb emplace_back
#define in insert
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define FOR(i, n, x) for(int i = x; i < n; i++)
#define OUT(a, e) FOR(i, e, 0) cout << a[i] << ' '
#define OUTV(a) for(auto i : a) cout << i << ' ';
#define maxim(a, n, mx) FOR(i, n, x)mx = max(mx, a[i]);
using namespace std;
const int N = 1e5 + 5, mod = 1e9 + 7;

int main() {
    fast;
    int n; cin >> n;
    ll a[n];
    ll sum = 0;
    FOR(i, n, 0)
    {
        cin >> a[i];
        sum += a[i];
    }
    ll now = a[0], minans = 1e18 + 7;
    FOR(i, n, 1)
    {
        ll ost = sum - now;
        if(abs(now - ost) <= minans)
        {
            if(abs(now - ost) <= max(now, ost))minans = abs(now - ost);
        }
        now += a[i];
    }
    cout << minans;
    return 0;
}



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

#define ll long long int
#define pii pair<int,int>
#define PII pair<ll,ll>

const ll sz=3e5+100;
int first[sz], last[sz];
map<int,int> mp[sz];

int main()
{
    int  n,m,i,j,k,p,x,y,a;

    cin>>n>>m>>a;
    for(i=1;i<=a;i++)
    {
        cin>>x>>y;
        ++first[x], ++last[y];
        mp[x][y]=1;
    }

    pair<int,int> ara[m+1];
    for(i=1;i<=m;i++) ara[i-1]={last[i],i};
    sort(ara,ara+m,greater<pii>());

    int mx=0;

    for(int i=1;i<=n;i++){
        j=0;
        while(j<m){
            if(mp[i][ara[j].second]==0) {
                    mx=max(mx, first[i]+last[ara[j].second]);
                    break;
            }
            //else if(j>0 && last[ara[j].second]<last[ara[j-1].second]){
               // break;
            //}
            else {
                    mx=max(mx, first[i]+last[ara[j].second]-1);
                    ++j;
            }
        }
    }


    cout<<mx<<'\n';

}



Measured memory_bytes: 50440
import java.util.*;
public class Main {
    static final long MODVAL = 998244353L;
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String S = sc.next();
//        System.out.println(S.charAt(3));
        boolean flag = (S.charAt(2) == S.charAt(3)) && (S.charAt(4) == S.charAt(5));
        System.out.println(flag ? "Yes" : "No");
    }
}


Measured memory_bytes: 23892
#![allow(unused_imports, unused_variables, dead_code, non_snake_case, unused_macros)]
use std::io::{stdin, Read, StdinLock};
use std::str::FromStr;
use std::fmt::*;
use std::str::*;
use std::cmp::*;
use std::collections::*;

fn getline() -> String{
    let mut res = String::new();
    std::io::stdin().read_line(&mut res).ok();
    res
}

macro_rules! readl {
    ($t: ty) => {
        {
            let s = getline();
            s.trim().parse::<$t>().unwrap()
        }
    };
    ($( $t: ty),+ ) => {
        {
            let s = getline();
            let mut iter = s.trim().split(' ');
            ($(iter.next().unwrap().parse::<$t>().unwrap(),)*) 
        }
    };
}

macro_rules! readlvec {
    ($t: ty) => {
        {
            let s = getline();
            let iter = s.trim().split(' ');
            iter.map(|x| x.parse().unwrap()).collect::<Vec<$t>>()
        }
    }
}

macro_rules! mvec {
    ($v: expr, $s: expr) => {
        vec![$v; $s]
    };
    ($v: expr, $s: expr, $($t: expr),*) => {
        vec![mvec!($v, $($t),*); $s]
    };
}

macro_rules! debug {
    ($x: expr) => {
        println!("{}: {:?}", stringify!($x), $x)
    }
}

fn printiter<'a, T>(v: &'a T)
where
    &'a T: std::iter::IntoIterator, 
    <&'a T as std::iter::IntoIterator>::Item: std::fmt::Display {
    for (i,e) in v.into_iter().enumerate() {
        if i != 0 {
            print!(" ");
        }
        print!("{}", e);
    }
    println!("");
}

struct ContestPrinter {
    s: String,
}

impl ContestPrinter {
    fn new() -> ContestPrinter {
        ContestPrinter {
        s: String::new(),
        }
    }

    fn print<T>(&mut self, x: T)
        where T: std::fmt::Display {
        self.s.push_str(format!("{}", x).as_str());
    }

    fn println<T>(&mut self, x: T)
        where T: std::fmt::Display {
        self.s.push_str(format!("{}\n", x).as_str());
    }
}

impl std::ops::Drop for ContestPrinter {
    fn drop(&mut self) {
        print!("{}", self.s);
    }
}

// euclidの互除法
fn gcd(a: i64, b: i64) -> i64 {
    if b == 0 { a }
    else { gcd(b, a % b) }
}
// ab = lcm(a, b)gcd(a, b)
fn lcm(a: i64, b: i64) -> i64 {
    let g = gcd(a, b);
    (a / g) * b
}
// 約数列挙 昇順ではない
fn divisors(n: i64) -> Vec<i64> {
    let mut ret = Vec::new();
    if n == 1 { ret.push(1); return ret; }
    let mut i = 1;
    loop {
        if (n % i) == 0 {
            ret.push(i);
            if (i != 1) & ((i*i) != n) {
                ret.push(n / i);
            }
        }
        i += 1; if n < (i*i) { break; }
    }
    ret.push(n);
    ret
}

fn is_max_i64(num: i64) -> bool { if num == i64::max_value() { true } else { false } }

fn main() {
    let mut pr = ContestPrinter::new();
    
    let (N, X) = readl!(i64, i64);
    pr.println(3*(N - gcd(N, X)));
}

Measured memory_bytes: 4352
#include<bits/stdc++.h>
#define _ ios_base::sync_with_stdio(0);
#define endl "\n"
#define MAXN 100123
#define ll long long
#define INF INT_MAX
#define FORE(i,m,n) for(int i=m;i<n;i++)
#define FOR(i,n) FORE(i,0,n)
#define ii pair<int,int>
#define vi vector<int>
#define vii vector<ii>
#define ps(v) push_back(v)
#define ms(v,x) memset(v,x,sizeof(v)) 

using namespace std;

int n,t;

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

    if(t>=n) cout << "unsafe" << endl;
    else cout << "safe" << endl;
    return 0;
}

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

// clang-format off
#define  range(i, l, r) for (int i = (int)(l); i < (int)(r); ++(i))
#define rrange(i, l, r) for (int i = (int)(r) - 1; i >= (int)(l); --(i))

#define  whole(f, x, ...) ([&](decltype((x)) container) { return (f)(  begin(container),  end(container), ## __VA_ARGS__); })(x)
#define rwhole(f, x, ...) ([&](decltype((x)) container) { return (f)( rbegin(container), rend(container), ## __VA_ARGS__); })(x)

#define endl '\n'
#define debug(x) cerr << "(" << __LINE__ << ")" << #x << ": " << (x) << endl

using i32 = int;
using u32 = unsigned int;
using i64 = long long;
using u64 = unsigned long long;

// constexpr i32 mod   = 998244353;
constexpr i32 mod   = 1e9 + 7;
constexpr i32 inf   = 1001001001;
constexpr i64 infll = 1001001001001001001ll;

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

struct IoSetup { IoSetup(int x = 15){ cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(x); cerr << fixed << setprecision(x); } } iosetup;

template <typename T = i64> T input() { T x; cin >> x; return x; }

template <typename T> ostream &operator<<(ostream &os, vector<T> &v) { range(i, 0, v.size()) { os << v[i] << (i + 1 != v.size() ? " " : ""); } return os; } 
template <typename T> istream &operator>>(istream &is, vector<T> &v) { for (T &in : v) is >> in; return is; }

template <typename T1, typename T2> ostream &operator<<(ostream &os, pair<T1, T2> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
template <typename T1, typename T2> istream &operator>>(istream &is, pair<T1, T2> &p) { is >> p.first >> p.second; return is; }

template <typename T> vector<T> make_vector(size_t a, T b) { return vector<T>(a, b); }
template <typename... Ts> auto make_vector(size_t a, Ts... ts) { return vector<decltype(make_vector(ts...))>(a, make_vector(ts...)); }

template <typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template <typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }
// clang-format on

void solver() {
    int N = input(), K = input(), C = input();
    string S = input<string>();
    
    vector< int > f, b;
    range(i, 0, N) if (S[i] == 'o') {
        f.push_back(i);
        i += C;
    }
    
    rrange(i, 0, N) if (S[i] == 'o') {
        b.push_back(i);
        i -= C;
    }
    
    whole(reverse, b);
    
    
    if (b.size() == K) range(i, 0, K) {
        if (f[i] == b[i]) {
            cout << f[i] + 1 << endl;
        }
    }
}

signed main(int argc, char *argv[]) {
    solver();
}


Measured memory_bytes: 3468
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n;
  cin >> n;
  vector<int> a;
  for (int i = 0; i < n; i++) {
	int t;
	cin >> t;
	a.push_back(t);
  }
  long long s1 = 0, s2 = 0, c1 = 0, c2 = 0;
  for (int i = 0; i < n; i++) {
	s1 += a[i];
	s2 += a[i];
	if (i % 2 == 0 && s1 <= 0) {
	  c1 += abs(1 - s1);
	  s1 = 1;
	}
	else if (i % 2 == 1 && s1 >= 0) {
	  c1 += abs(-1 - s1);
	  s1 = -1;
	}
	if(i % 2 == 0 && s2 >= 0){
	  c2 += abs(-1 - s2);
	  s2 = -1;
	}
	else if (i % 2 == 1 && s2 <= 0) {
	  c2 += abs(1 - s2);
	  s2 = 1;
	}
  }
  cout << min(c1, c2) << endl;

  return 0;
}



Measured memory_bytes: 892
import java.util.Arrays;
import java.util.Collections;
import java.util.Scanner;
import java.util.stream.StreamSupport;

public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);


        int N = sc.nextInt();
        int[] C = new int[N];
        int[] S = new int[N];
        int[] F = new int[N];

        for (int i = 0; i < N - 1; i++) {
            C[i] = sc.nextInt();
            S[i] = sc.nextInt();
            F[i] = sc.nextInt();
        }
        for (int i = 0; i < N - 1; i++) {
            int sum = 0;
            sum += S[i];
            for (int j = i; j < N -1 ; j++) {
                if (sum < S[j]) sum = S[j];
                if (sum == S[j]) {
                    sum += C[j];

                } else {
                    int sum1 = S[j];
                    while (sum > sum1) {
                        sum1 += F[j];
                    }
                    sum = sum1;
                    sum += C[j];
                }
            }
            System.out.println(sum);

        }
        System.out.println("0");

    }


}

Measured memory_bytes: 26056
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define lper(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define ins insert
#define pqueue(x) priority_queue<x,vector<x>,greater<x>>
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
#define vtpl(x,y,z) vector<tuple<x,y,z>>
#define at(x,i) get<i>(x);
#define rev(x) reverse(x);
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
using vpl=vector<pl>;
using vvpl=vector<vpl>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[8]={1,0,-1,0,1,1,-1,-1};
const ll dx[8]={0,-1,0,1,1,-1,1,-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(){
    ll n;cin >> n;
    vl p(n+1);
    rep(i,n){
        ll hoge,hogehoge;
        if(i%2==0)cin >> p[i] >> p[i+1];
        else {
            cin >> hoge >>hogehoge;
            if(i==n-1)p[n]=hogehoge;
        }
    }
    vvl dp(n,vl(n,inf));
    rep(i,n)dp[i][i]=0;
    rep(j,n){
        lper(i,j+1,0){
            rep(k,j-i){
                chmin(dp[i][j],dp[i][i+k]+dp[i+k+1][j]+p[i]*p[i+k+1]*p[j+1]);
            }
        }
    }
    cout << dp[0][n-1] <<endl;
}



Measured memory_bytes: 3196
from itertools import product, accumulate
def main():
  n, x, m = map(int, input().split())
  lrs = [tuple(map(int, input().split())) for _ in range(m)]
  lst = tuple(x - i for i in range(x + 1))
  for t in product(lst, repeat=n):
    acc = [0] + list(accumulate(t))
    for l, r, s in lrs:
      if acc[r] - acc[l - 1] != s:break
    else:
      print(*t)
      break
  else:
    print(-1)
main()


Measured memory_bytes: 5648
//#pragma GCC optimize("Ofast","unroll-loops","omit-frame-pointer","inline") //Optimization flags
//#pragma GCC option("arch=native","tune=native","no-zero-upper") //Enable AVX
//#pragma GCC target("avx2")  //Enable AVX
#include<bits/stdc++.h>
using namespace std;

#define all(a) begin(a),end(a)
#define F first
#define S second
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;

#ifdef LOCAL
#include "debug.h"
#else
#define debug(...) 42
#endif

const int mod=1e9+7;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int mul(int a,int b){
  return ((a)*1ll*(b))%mod;
}

void add(int &a,int b){
  a+=b;
  if(a>=mod)a-=mod;
}

int sub(int a,int b){
  a-=b;
  if(a<0){
    a+=mod;
  }
  return a;
}

int powz(int a,int b){
  int res=1;
  while(b){
    if(b&1){
      res=mul(res,a);
    }
    b/=2;
    a=mul(a,a);
  }
  return res;
}

template <typename A, typename B>
istream& operator>>(istream& input,pair<A,B>& x) {
  input>>x.F>>x.S;
  return input;
}

template <typename A>
istream& operator>>(istream& input,vector<A>& x) {
  for(auto& i:x)
    input>>i;
  return input;
}

template<typename A>
ostream& operator<<(ostream& output,vector<A>& x) {
  for(auto& i:x)
    output<<i<<' ';
  return output;
}

template<typename T>
vector<pair<T,int>> getvec(int n){
  vector<pair<T,int>>a(n);
  for(int i=0;i<a.size();i++){
    cin>>a[i].F;
    a[i].S=i;
  }
  return a;
}

const int N=1000005;

struct DSU{
  vector<int>fa,sz;
  DSU(int n){
    fa.clear();
    sz.clear();
    fa.resize(n);
    sz.resize(n);
    for(int i=0;i<n;i++){
      fa[i]=i;
      sz[i]=1;
    }
  }
  int get(int x){
    if(fa[x]==x){
      return x;
    }
    return fa[x]=get(fa[x]);
  }
  void merge(int x,int y){
    x=get(x);y=get(y);
    if(x==y){
      return;
    }
    if(sz[x]<sz[y]){
      swap(x,y);
    }
    fa[y]=x;
    sz[x]+=sz[y];
    sz[y]=0;
  }
};

void solve(){
  int n,K,L;
  cin>>n>>K>>L;
  DSU train(n),rail(n);
  for(int i=0;i<K;i++){
    int x,y;
    cin>>x>>y;
    x--;y--;
    train.merge(x,y);
  }
  for(int i=0;i<L;i++){
    int x,y;
    cin>>x>>y;
    x--;y--;
    rail.merge(x,y);
  }
  map<pi,int>zz;
  for(int i=0;i<n;i++){
    zz[{train.get(i),rail.get(i)}]++;
  }
  for(int i=0;i<n;i++){
    cout<<zz[{train.get(i),rail.get(i)}]<<' ';
  }
    
}

signed main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int tc=1;
  //cin>>tc;
  for(int _=0;_<tc;_++){
    // cout<<"Case #"<<_+1<<": ";
    solve();
    if(_!=tc-1){
      cout<<'\n';
    }
  }
}


Measured memory_bytes: 15104
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<cassert>
#define PB push_back
#define MP make_pair
#define sz(v) (in((v).size()))
#define forn(i,n) for(in i=0;i<(n);++i)
#define forv(i,v) forn(i,sz(v))
#define fors(i,s) for(auto i=(s).begin();i!=(s).end();++i)
#define all(v) (v).begin(),(v).end()
using namespace std;
typedef long long in;
typedef vector<in> VI;
typedef vector<VI> VVI;
int main(){
  ios::sync_with_stdio(0);
  cin.tie(0);
  in n;
  cin>>n;
  in n1=0,n2=0,n4=0;
  in a;
  forn(z,n){
    cin>>a;
    if(a%4==0)
      ++n4;
    else if(a%2==0)
      ++n2;
    else
      ++n1;
  }
  n2=min(1LL,n2);
  if(n1<=n4){
    cout<<"Yes"<<endl;
    return 0;
  }
  if(n1==n4+1 && n2==0){
    cout<<"Yes"<<endl;
    return 0;
  }
  cout<<"No"<<endl;
  return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;
using static System.Math;

namespace AtTest.ABC_167
{
    class D
    {
        static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(OpenStandardOutput()) { AutoFlush = false };
            SetOut(sw);

            Method(args);

            Out.Flush();
        }

        static void Method(string[] args)
        {
            long[] nk = ReadLongs();
            long n = nk[0];
            long k = nk[1];
            long[] array = ReadLongs();
            for(int i = 0; i < n; i++)
            {
                array[i]--;
            }

            var visited = new Dictionary<long, long>();
            long now = 0;
            long turn = 0;
            while (!visited.ContainsKey(now))
            {
                visited.Add(now, turn);
                if (turn == k)
                {
                    WriteLine(now + 1);
                    return;
                }

                now = array[now];
                turn++;
            }

            long loopCnt = turn - visited[now];
            k -= turn;
            k %= loopCnt;
            turn = 0;
            while (turn!=k)
            {
                now = array[now];
                turn++;
            }

            WriteLine(now+1);
        }

        private static string Read() { return ReadLine(); }
        private static char[] ReadChars() { return Array.ConvertAll(Read().Split(), a => a[0]); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
    }
}


Measured memory_bytes: 55164
n = int(input())
s = [input() for _ in range(n)]
m = int(input())
t = [input() for _ in range(m)]

S = set(s)
T = set(t)
cands = []

for i in S:
    cands.append(s.count(i)-t.count(i))

print(max(max(cands), 0))

Measured memory_bytes: 3064
#Binary Search:
N, K = map(int,input().split())
A = list(map(int,input().split()))
s = 0
t = max(A)

while s + 1 < t:
  m = (s + t) // 2
  temp = 0
  for i in A:
    temp += (i - 1) // m 
  if temp <= K: # feasible
    t = m
  else: # infeasible
    s = m
print(t)

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

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

    int c, t;
    int ans = INT_MAX;

    while(n-- > 0){
        cin >> c >> t;
        if(t <= T)  ans = min(ans, c);
    }

    if(ans == INT_MAX){
        cout << "TLE" << endl;
    }else{
        cout << ans << endl;
    }
    
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<cstdlib>
#include<float.h>
using namespace std;


int main() {
    int  n,a,b;
    cin >> n>>a>>b;
    if (n*a > b)cout << b << endl;
    else cout << a * n << endl;
  
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int A = sc.nextInt();
        int B = sc.nextInt();
        sc.close();
        if (A >= 13) {
            System.out.println(B);
        } else if (A <= 5) {
            System.out.println("0");
        } else {
            System.out.println(B / 2);
        }
    }
}


Measured memory_bytes: 21332
import java.util.ArrayDeque;
import java.util.Deque;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int h = sc.nextInt();
        int w = sc.nextInt();
        char[][] a = new char[h][w];
        Deque<int[]> queue = new ArrayDeque<>();
        for (int i = 0; i < h; i++) {
            a[i] = sc.next().toCharArray();
            for (int j = 0; j < w; j++) {
                if (a[i][j] == '#') {
                    queue.add(new int[] { i, j });
                }
            }
        }
        int cnt = -1;
        final int[][] DXDY = { { 1, 0 }, { 0, 1 }, { -1, 0 }, { 0, -1 } };
        while (!queue.isEmpty()) {
            int size = queue.size();
            cnt++;
            for (int i = 0; i < size; i++) {
                int[] p = queue.poll();
                for (int j = 0; j < DXDY.length; j++) {
                    int x = p[0] + DXDY[j][0];
                    int y = p[1] + DXDY[j][1];
                    if (x < 0 || x >= h || y < 0 || y >= w || a[x][y] == '#') {
                        continue;
                    }
                    a[x][y] = '#';
                    queue.add(new int[] { x, y });
                }
            }
        }
        System.out.println(cnt);
    }
}


Measured memory_bytes: 67372
#include <bits/stdc++.h>
using namespace std;
#define modulo 1000000007
#define mod(mod_x) ((((long long)mod_x+modulo))%modulo)
#define Inf 100000000000000000


int main(){
	
	int A,B,C,D;
	cin>>A>>B>>C>>D;
	
	int ans = min(B,D)-max(A,C);
	
	cout<<max(ans,0)<<endl;
	
		
	
	return 0;
}


Measured memory_bytes: 256
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef double db;

#define fr first
#define sc second
#define pb push_back
#define rep(i,x) for(ll i=0;i<x;i++)
#define rep1(i,x) for(ll i=1;i<=x;i++)
#define rrep(i,x) for(ll i=x-1;i>=0;i--)
#define rrep1(i,x) for(ll i=x;i>0;i--)
#define rank aewuaghw

ll n,m;
P a[100000];
vector<ll> G[5000];
ll into[5000];
ll rank[5000];
bool zero[5000];
queue<ll> q;
ll x=0;
ll now=0;
int main()
{
	scanf("%lld%lld",&n,&m);
	rep(i,m){
		scanf("%lld%lld",&a[i].fr,&a[i].sc);
		G[--a[i].fr].pb(--a[i].sc);
		into[a[i].sc]++;
	}
	rep(i,n){
		if(!into[i]){
			q.push(i);
			zero[i]=1;
		}
	}
	while(!q.empty()){
		if(q.size()>1) x=1;
		ll team=q.front();
		rank[now]=team;
		now++;
		q.pop();
		rep(i,G[team].size()){
			if(into[G[team][i]]==0) continue;
			into[G[team][i]]--;
			if(into[G[team][i]]==0){
				q.push(G[team][i]);
			}
		}
	}
	rep(i,n) cout<<rank[i]+1<<endl;
	cout<<x<<endl;
}

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

int main() {
  int N,count=0,ans=0;
  cin >> N;
  vector<int> H(N);
  for(int i=0;i<N;i++) cin >> H[i];
  
  for(int i=0;i<N-1;i++){
    if(H[i+1]<=H[i]) count++;
    else{
      ans = max(ans,count);
      count = 0;
    }
  }
  
  cout << max(ans,count) << endl;
  return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#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 FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999999
#define MOD 1000000007
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;
typedef vector<llong> LV;

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



int main() {
	llong N;
    cin >> N;
    LV C(N),V(N);
    REP(i,N){
        cin >> V[i];
    }
    REP(i,N){
        cin >> C[i];
    }
    LV CP(N);
    REP(i,N){
        CP[i]=V[i]-C[i];
    }
    sort(CP.begin(),CP.end());
    llong ans =0;
    REP(i,N){
        if(CP[i]>0){
            ans+=CP[i];
        }
    }




    cout << ans << endl;






}


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

int main()
{
long long int l,tot=0;
cin>>l;
long long a[2*l];
for(int i=0;i<2*l;i++)
{
    cin>>a[i];
}
sort(a,a+2*l);
for(int i=0;i<2*l;i=i+2)
{
    tot+=a[i];
}
cout<<tot<<endl;

    return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int a = Integer.parseInt(sc.next());
        int b = Integer.parseInt(sc.next());
        sc.nextLine();
        for (int i = 0; i < a; i++) {
            String cache = sc.nextLine();
            for (int j = 0; j < 2; j++) {
                System.out.println(cache);
            }
        }
    }
}

Measured memory_bytes: 22996
#include <bits/stdc++.h>
using namespace std;
// int64_tは9*10^18まで、intは2*10^9まで

#define INF (int)pow(10, 8)
typedef tuple<int, int, int> P;

int main() {
  string s, t;
  cin >> s >> t;
  int lens=s.length(), lent=t.length(), ans=1000;
  for(int i=0; i<=lens-lent; i++){
    int ct=0;
    for(int j=0; j<lent; j++){
      if(s[i+j]!=t[j])
        ct++;
    }
    if(ct<ans)
      ans=ct;
  }
  cout << ans;
  return 0;
}

Measured memory_bytes: 3628
#pragma GCC optimize(3, "Ofast", "inline")
#include <bits/stdc++.h>
#if __cplusplus >= 201103L
#include <chrono>
using namespace std::chrono;
#endif
using namespace std;
#define ll long long
#define ull unsigned long long
#define pii pair<int, int>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define CASET int ___T; scanf("%d", &___T); for(int cs=1;cs<=___T;cs++)
#ifdef LOCAL
#define prln(x) (cout << #x << ' ' << x << endl)
#define pr(x) (cout << #x << ' ' << x << ' ' )
#define prv(x) (cout << x << ' ')
#else
#define prln(x) 
#define pr(x)
#define prv(x)
#endif
#define clr(x) memset((x), 0, sizeof((x)))
#define clr1(x) memset((x), -1, sizeof((x)))
#define endl "\n"
#define pi acos(-1)
#define rep(i, st, ed) for (int i = (st); i <= (ed); ++i)
#define rep0(i, st, ed) for (int i = (st); i < (ed); ++i)
#define per0(i, st, ed) for (int i = (st); i > ed; --i)
#define per(i, st, ed) for (int i = (st); i >= ed; --i)
#define chmin(a, b) (a = a > b ? b : a)
#define chmax(a, b) (a = a < b ? b : a)
template<class T> void _sf(T &x) {cin >> x;}
void _sf(int &x) {scanf("%d", &x);}
void _sf(ll &x) {scanf("%lld", &x);}
void _sf(double &x) {scanf("%lf", &x);}
void _sf(char &x) {scanf(" %c", &x);}
void _sf(char *x) {scanf("%s", x);}
void sf() {}
template <class T, class...U> void sf(T & head, U&... tail) { _sf(head); sf(tail...);}
template<class T> void _out(const T &x) { cout << x; }
void _out(const int &x) { printf("%d", x); }
void _out(const ll &x) { printf("%lld", x); }
void _out(const double &x) { printf("%.16f", x); }
void _out(const char &x) { putchar(x); }
void _out(const char *x) { printf("%s", x); }
template<class T,class U> void _out(const pair<T,U> &x) {_out(x.F); putchar(' '); _out(x.S);}
template<class T> void _out(const vector<T> &x) { for (auto i = x.begin(); i != x.end(); _out(*i++)) if (i != x.cbegin()) putchar(' '); }
void out() {}
template<class T, class... U> void out(const T &head, const U &... tail) { _out(head); putchar(sizeof...(tail) ? ' ' : '\n'); out(tail...); }
const int mod = 1e9 + 7;
const int INF = 0x3f3f3f3f;

int read() {
    int x = 0, f = 1;
    char ch = getchar();
    while (ch < '0' || ch > '9') {
        if (ch == '-') f = -1;
        ch = getchar();
    }
    while (ch >= '0' && ch <= '9') {
        x = x * 10 + ch - '0';
        ch = getchar();
    }
    return x * f;
}


int main(){
    // #ifdef LOCAL
    //     freopen("in.txt", "r", stdin);
    //     freopen("out.txt", "w", stdout);
    // #endif
    ll a, b, c;
    sf(a, b, c);
    ll k;
    sf(k);
    ll ans = 0;
    while (b <= a) {
        b *= 2;
        ++ans;
    }
    while (c <= b) {
        c *= 2;
        ++ans;
    }
    // out(ans);
    if (ans <= k) puts("Yes");
    else puts("No");
    return 0;
}

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

typedef long long ll;
#define IO ios_base::sync_with_stdio(0);cin.tie(0); cout.tie(0);
#define endl '\n'
const int N = 2e5 + 10;
using namespace std;

int main() {
    IO;
    ll n; cin>>n;
    --n;
    cout<<n*(n+1)/2;
}


Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
const int maxn = 2000 +10;
const long long mod = (long long)1000000007;
int read(){
	int x=0,flag=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')flag=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return x*flag;
}
int n,k;
long long f[maxn][maxn],g[maxn][maxn],h[maxn];
long long Pow(long long x,int t){
	if( t < 0 )return 1LL;
	long long ans = 1LL;
	while(t){
		if(t&1)ans=ans*x%mod;
		x=x*x%mod;t>>=1;
	}
	return ans%mod;
}
long long Add(long long x,long long y){
	if( x + y >= mod) return x + y - mod;
	return x +y;
}
int main(){

//	freopen("test.in","r",stdin),freopen("test.out","w",stdout);
	n=read();k=read();	
	f[1][n-k]=Pow(2LL,n-k-1);
	g[1][0]=f[1][0];
	for(int j=1;j<=n;j++)g[1][j] = Add( g[1][j-1] , f[1][j] );
	for(int i=2;i<=n;i++){
		for(int j=0;n-i>=j;j++){
			f[i][j] = Add( f[i-1][j+1] , g[i-1][j] ) ;
			g[i][j] = Add( g[i][j-1] , f[i][j] );
		}
	}
	cout << f[n][0] << endl;
	return 0;
}

Measured memory_bytes: 62080
#include <iostream>
#include <vector>

using ull = long long int;

int main() {
  ull a, b, c, d;
  std::cin >> a >> b >> c >> d;
  if (a == 0 and b > 0) {
    a++;
  }
  if (b == 0 and a < 0) {
    b--;
  }
  if (c == 0 and d > 0) {
    c++;
  }
  if (d == 0 and c < 0) {
    d--;
  }
  ull ac = a * c;
  ull ad = a * d;
  ull bc = b * c;
  ull bd = b * d;
  ull max1 = std::max(ac, ad);
  ull max2 = std::max(bc, bd);
  std::cout << std::max(max1, max2) << '\n';
}

Measured memory_bytes: 3636
#include <stdio.h>
 
int main() {
int S,h,m,s;
scanf("%d",&S);
if(S<=86400){
h=S/3600;
m=S/60-h*60;
s=S%60;
 
printf("%d:%d:%d\n",h,m,s);
}
 
 
return 0;
}

Measured memory_bytes: 2664
import math
X = int(input())
N = math.floor(X ** (2/5)) + 1

for a in range(N):
  for b in range(-N,N):
    x = a**5
    y = b**5
    T = 0
    if x-y == X:
      print(a,b)
      T = 1
      break
  if T == 1:
    break

Measured memory_bytes: 9444
var a:array[1..100] of integer;n,i,s,pnt,d:integer;
begin
read(n);
s:=0;
for i:=1 to n do begin read(a[i]);s:=s+a[i];end;
pnt:=n;
d:=s;
for i:=1 to n do begin
if(((a[i]*n-s)*(a[i]*n-s))<(d*d))then begin d:=(a[i]*n-s);pnt:=i;end;
end;
writeln(pnt-1);
end.

Measured memory_bytes: 1352
A=int(input())
B=int(input())
C=int(input())
N=int(input())
count=0
for i in range(A+1):
    for j in range(B+1):
        for k in range(C+1):
            if 500*i+100*j+50*k== N:
                     count+=1
print(count)

Measured memory_bytes: 39536
# include<bits/stdc++.h>
using namespace std;
int main(){
	int a,b,c,d,e,k;
    cin >>a;
    cin >>b;
    cin >>c;
    cin >>d;
    cin >>e;
    cin >>k;
    if(e-a > k)
    	cout << ":("<<'\n';
    else
    	cout <<"Yay!"<<'\n';
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define Rep(i,n) for(int i=0;i<(int)(n);i++)
#define For(i,n1,n2) for(int i=(int)(n1);i<(int)(n2);i++)
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define RREP(i,n) for(ll i=((ll)(n)-1);i>=0;i--)
#define FOR(i,n1,n2) for(ll i=(ll)(n1);i<(ll)(n2);i++)
#define RFOR(i,n1,n2) for(ll i=((ll)(n1)-1);i>=(ll)(n2);i--)
#define all(a)  (a).begin(),(a).end()
#define SORT(a) sort((a).begin(),(a).end())
#define oorret 0
#define oor(x) [&](){try{x;} catch(const out_of_range& oor){return oorret;} return x;}()
#define IOS cin.tie(0),ios::sync_with_stdio(false)
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
template<typename T1, typename T2> inline bool chmin(T1& a, T2 b) { if (a > b) { a = b; return 1; }return 0; }
template<typename T1, typename T2> inline bool chmax(T1& a, T2 b) { if (a < b) { a = b; return 1; }return 0; }
template<class Type>struct is_vector : std::false_type {};
template<class ValueType, class Alloc>struct is_vector<std::vector<ValueType, Alloc>> : std::true_type {};
template <typename T> inline ostream& operator << (ostream& out, const vector<T>& v) {
	if (v.empty())return out;
	constexpr bool is_vector_v = is_vector<T>::value;
	if (is_vector_v)for (auto itr = v.begin(); itr != v.end();)out << (*itr), out << ((++itr != v.end()) ? "\n" : "");
	else for (auto itr = v.begin(); itr != v.end();)out << (*itr), out << ((++itr != v.end()) ? " " : "");
	return out;
}
inline void put() {}
template<class T> inline void put(const T& first) { std::cout << first << "\n"; }
template<class T, class... N> inline void put(const T& first, const N& ... rest) { std::cout << first << " "; put(rest...); }
inline void putn() {}
template<class T, class... N> inline void putn(const T& first, const N& ... rest) { std::cout << first << "\n"; putn(rest...); }

int main() {
	IOS;
	int n;
	cin >> n;
	ll c;
	cin >> c;
	vector<ll> x(n), v(n);
	REP(i, n) {
		cin >> x[i] >> v[i];
	}
	ll res = 0;
	vector<ll> optl(n+1, 0),optr(n+1,0);
	ll vsum = 0;
	REP(i, n) {
		vsum += v[i];
		optl[i + 1] = max(optl[i], vsum - x[i]);
	}
	chmax(res,optl[n]);
	ll rvs = 0;
	REP(i, n) {
		ll rd = (c - x[n - i - 1]) * 2;
		rvs += v[n - 1 - i];
		chmax(res, rvs - rd + optl[n-1-i]);
	}
	REP(i, n) {
		x[i] = c - x[i];
	}
	reverse(all(x));
	reverse(all(v));
	vsum = 0;
	REP(i, n) {
		vsum += v[i];
		optr[i + 1] = max(optr[i], vsum - x[i]);
	}
	chmax(res, optr[n]);
	rvs = 0;
	REP(i, n) {
		ll rd = (c - x[n - i - 1]) * 2;
		rvs += v[n - 1 - i];
		chmax(res, rvs - rd + optr[n - 1 - i]);
	}
	put(res);
	return 0;
}


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

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

int main()
{
	string s,t,u;
	int a,b;
	cin>>s>>t>>a>>b>>u;
	if(s==u) a--;
	if(t==u) b--;
	cout<<a<<' '<<b<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cmath>
#include <utility>
#include <iostream>
#include <functional>
#include <bitset>
#include <algorithm>
#include <vector>
#include <forward_list>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <numeric>
#define ll long long int
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;

int main(){
    string s,t; cin >> s >> t;
    int S = s.size(),T = t.size();
    for(int i=0;i<S;i++){
        if(s[i] != t[i]){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
}

Measured memory_bytes: 3628
import java.util.Scanner;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    String s=sc.next(),pre="";
    int count=0;
    for(int i=0;i<s.length();i++) {
    	String buff=s.substring(i, i+1);
    	if(buff.equals(pre)) {
    		i++;
    		if(i==s.length())break;
    		pre=buff+s.substring(i, i+1);
    	}else {
    		pre=buff;
    	}
    	count++;
    	//System.out.println(pre);
    }
    System.out.println(count);
  }
}


Measured memory_bytes: 40924
#include <bits/stdc++.h>
using namespace std;
using LL = long long;

const int N = 20;

vector<pair<int, int> > a[N];
int n;

int res[N];

int bitcount(int x) {
	int res = 0;
	for (; x; x &= (x-1))
		++res;
	return res;
}

inline bool conflict(int i, int x) {
	return (~res[i]) && res[i] != x;
}

int main(int argc, char const *argv[])
{
	scanf("%d", &n);
	for (int i=0; i<n; ++i) {
		int cnt; scanf("%d", &cnt);
		for (int j=0; j<cnt; ++j) {
			pair<int, int> p;
			scanf("%d%d", &p.first, &p.second);
			--p.first;
			a[i].push_back(p);
		}

	}

	int ans = 0;
	for (int mask=0; mask<(1<<n); ++mask) {
		memset(res, -1, 4 * n);
		queue<int> Q;
		for (int i=0; i<n; ++i) {
			if ((mask >> i) & 1) {
				res[i] = 1;
				Q.push(i);
			}
		}
		bool suc = true;
		// for (int i=0; i<n && suc; ++i) {
		// 	if ((mask >> i) & 1) {
		// 		for (const auto &p : a[i]) {
		// 			if (conflict(p.first, p.second)) {
		// 				suc = false;
		// 				break;
		// 			} else res[p.first] = p.second;
		// 		}
		// 	}
		// }
		while (!Q.empty() && suc) {
			int now = Q.front(); Q.pop();
			for (const auto &p : a[now]) {
				if (~res[p.first]) {
					if (res[p.first] != p.second) {
						suc = false;
						break;
					}
				} else {
					res[p.first] = p.second;
					if (p.second == 1) Q.push(p.first);
				}
			}
		}
		if (suc) {
			ans = max(ans, bitcount(mask));
			// printf("%d\n", mask);
		}
	}
	printf("%d\n", ans);
    return 0;
}



Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){
    int N, K;
    cin>>N>>K;

    if(N%2==0){
        if(N/2>=K){
            cout<<"YES"<<endl;
        }else{
            cout<<"NO"<<endl;
        }
    }else{
        if(N/2+1>=K){
            cout<<"YES"<<endl;
        }else{
            cout<<"NO"<<endl;
        }
    }

    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstring>
#include <cstdlib>

#include <algorithm>
#include <numeric>
#include <limits>
#include <functional>
#include <stack>
#include <vector>
#include <set>
#include <map>
#include <queue>
#define LOG(FMT...) fprintf(stderr, INF)

#define fi first
#define se second
#define pb push_back
#define mp make_pair

using namespace std;

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

const ll mod = 1e9 + 7;
const int F = 87, N = 105;

ll fib[N];
vector<P> t[N];

inline void upd(ll &a, ll b) {
  if ((a += b) >= mod)
    a -= mod;
}

int main() {
  t[1].pb(mp(1, 2));
  t[1].pb(mp(1, 3));
  t[1].pb(mp(1, 4));
  fib[0] = fib[1] = 1;
  for (int i = 2; i <= F; ++i)
    fib[i] = fib[i - 1] + fib[i - 2];
  for (int i = 1; i <= F; ++i)
    for (int j = 0; j < t[i].size(); ++j) {
      ll x = t[i][j].se, y = t[i][j].fi + x;
	  while (y <= fib[i] + fib[i + 3]) {
	    t[i + 1].pb(mp(x, y));
	    y += x;
      }
    }
  int q;
  scanf("%d", &q);
  while (q--) {
    ll n, m;
	scanf("%lld%lld", &n, &m);
	if (n > m)
	  swap(n, m);
	int p = 1;
	while (fib[p + 1] <= n && fib[p + 2] <= m)
	  ++p;
	printf("%d ", p);
	if (p == 1) {
	  printf("%lld\n", (ll)(n % mod) * (m % mod) % mod);
	  continue;
    }
    ll ans = 0;
    for (int j = 0; j < t[p - 1].size(); ++j) {
	  ll x = t[p - 1][j].fi, y = t[p - 1][j].se;
	  if (y <= n)
	    upd(ans, (m - x) / y % mod);
	  if (y <= m)
	    upd(ans, (n - x) / y % mod);
    }
    printf("%lld\n", ans);
  }
  return 0;
}



Measured memory_bytes: 4096
/***"In the name of Allah(swt), the most gracious, most merciful. Allah(swt) blesses with knowledge whom he wants."***/
/*** "ALHAMDULILLAH for Everything..." ***/
#include<bits/stdc++.h>
using namespace std;
#define  fastt       ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define  ll         long long
#define  debug      printf("Come here!")
#define  inf        1000000000000000000
#define  pb         push_back
#define  mp         make_pair
#define  sz(a)      a.size()
#define  mem(a,b)   memset(a,b,sizeof(a))
#define  clr(x)     x.clear()
#define  ff         first
#define  ss         second
#define  case(x)    cout << "Case " << x <<": "

#define  md         1000000007
#define  pi         acos(-1.0)
#define  cos(a)     cos(a*pi/180)
#define  sin(a)     sin(a*pi/180)
#define  tan(a)     tan(a*pi/180)
#define  cosi(a)    acos(a)/(pi/180)
#define  sini(a)    asin(a)/(pi/180)
#define  tani(a)    atan(a)/(pi/180)

#define  vl         vector <ll>
#define  vs         vector <string>
#define  vc         vector <char>
#define  vpll       vector < pair <ll, ll> >
#define  vpsl       vector < pair <string, ll> >
#define  vpls       vector < pair <ll, string> >
#define  pql        priority_queue<ll>
#define  minpql     priority_queue<ll,vector<ll>,greater<ll> >

#define  setbits(x)     __builtin_popcountll(x)
#define  zerobits(x)    __builtin_ctzll(x)

#define toll(a) atoll(a.c_str())
string tostr(ll a) {stringstream rr;rr<<a;return rr.str();}
ll pow(ll c,ll d){return d==0?:c*pow(c,d-1);}
ll gcd(ll a,ll b) {return b==0? a:gcd(b,a%b);}
ll lcm(ll a,ll b) {return ((a*b)/gcd(a,b));}

/* mpp.max_load_factor(0.25); mpp.reserve(1024); */
/* cout << fixed << setprecision(12);*/

int main()
{
    fastt;
    ll n, m, k, i, j, x, y, p=0, s=0, h, f=0;
    cin>>n>>m>>k;
    ll b[m];
    for(i=0; i<m; i++)cin>>b[i];

    for(i=0; i<n; i++){
        s=k;
        for(j=0; j<m; j++){
            cin>>x;
            s+=(x*b[j]);
        }

        if(s>0)p++;
    }
    cout<<p<<endl;

    return 0;
}



Measured memory_bytes: 3584