akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <map>
#include <vector>
#include <algorithm>
using namespace std;

int main(){
	int r,c,n;
	scanf("%d%d%d",&r,&c,&n);
	map<int,vector<pair<int,long long>>>m;
	string s1,s2;
	for(;n;n--){
		int s1,s2,d;
		scanf("%d%d%d",&s1,&s2,&d);
		m[s1].emplace_back(s2+r,d);
		m[s2+r].emplace_back(s1,-d);
	}
	for(;!m.empty();){
		long long a=-1LL<<61,b=1LL<<61;
		int s=m.begin()->first;
		vector<pair<int,long long> >st={{s,0}};
		map<int,long long>memo={{s,0}};
		for(;!st.empty();){
			auto p=*st.rbegin();st.pop_back();
			int cur=p.first;long long d=p.second;
			memo[cur]=d;
			if(cur<=r)a=max(a,d);
			else b=min(b,d);
			for(auto &e:m[cur]){
				if(memo.find(e.first)==memo.end()){
					st.emplace_back(e.first,d+e.second);
				}else if(memo[e.first]!=d+e.second){
					puts("No");
					return 0;
				}
			}
		}
		if(a>b){
			puts("No");
			return 0;
		}
		for(auto &e:memo)m.erase(m.find(e.first));
	}
	puts("Yes");
}

Measured memory_bytes: 22144
#include <stdio.h>

int main(void) {
  int n, i, j, k;
  scanf("%d", &n);
  for(i = 0; i < n; ++i) {
    double xa, ya, ra, xb, yb, rb, d, rs, rd;
    scanf("%lf%lf%lf%lf%lf%lf", &xa, &ya, &ra, &xb, &yb,&rb);
    d = (xa - xb) * (xa - xb) + (ya - yb) * (ya - yb);
    rs = (ra + rb) * (ra + rb);
    rd = (ra - rb) * (ra - rb);
    if(d > rs) printf("0\n");
    else if(rd <= d) printf("1\n");
    else if(ra > rb) printf("2\n");
    else printf("-2\n");
  }
  return 0;
}


Measured memory_bytes: 2720
import heapq
from itertools import repeat, starmap
from operator import mul

R = lambda: map(int, input().split())
n, m = R()
a = list(zip(R(), repeat(1)))
heapq.heapify(a)
for _ in range(m):
    b, c = R()
    i = b
    while i and a[0][0] < c:
        x, y = a[0]
        if y > i:
            heapq.heapreplace(a, (x, y - i))
            i = 0
        else:
            heapq.heappop(a)
            i -= y
    if i < b:
        heapq.heappush(a, (c, b - i))
print(sum(starmap(mul, a)))


Measured memory_bytes: 21548
#define _USE_MATH_DEFINES

#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cmath>
#include <bitset>
using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef tuple<ll, ll, ll> tl3;



const int BIG_NUM = 1e9;
const ll INF = 1000000000000000000;
const ll MOD = 1e9 + 7;
//const ll MOD = 998244353;



int main() {
	int n, a, b;
	cin >> n >> a >> b;

	cout << min(n * a, b) << endl;
}


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

long long n, k, diff, temp;

int main(){
    cin >> n >> k;
    if(n < k){
        diff = abs(n-k);
        cout << min(diff, abs(diff-k)) << endl;
    }
    else{
        temp = n-(n/k)*k;
        temp = min(temp, abs(temp-k));
        temp = min(temp, abs(abs(temp-k)-k));
        cout << temp << endl;
    }
}


Measured memory_bytes: 3556
#include<stdio.h>
#include<stdlib.h>
int main(){
    int n,*a,*b;
    scanf("%d",&n);
    a=(int*)malloc(n*sizeof(int));
    b=(int*)malloc(n*sizeof(int));
    b[n-1]=0;
    for(int i=0;i<(n-1);i++){
        a[i]=b[i]=0;
        scanf("%d",&a[i]);
        b[a[i]-1]++;
    }
    for(int i=0;i<n;i++){
        printf("%d\n",b[i]);
    }
    return 0;
}

Measured memory_bytes: 3300
#include<stdio.h>

int main()
{
	int a;
	int b;
	int c;

	scanf("%d%d%d", &a, &b, &c);

	if (a < b && b < c)
	{
		printf("Yes\n");
	}
	else
	{
		printf("No\n");
	}
	return 0;
}


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

const int N = (2e5) + 5;
ll n, k;
ll a[N], f[N];

bool check(ll med, ll y) {
  ll sum = 0;
  for (int i = 0; i < n; ++i) {
    sum += max(0LL, a[n - i - 1] - med / f[i]);
  }
  return (y >= sum);
}

ll bs(ll lo, ll hi, ll y) {
  if ( check(lo, y)) return lo;
  if (!check(hi, y)) return hi + 1;
  while (hi - lo > 1) {
    ll med = lo + (hi - lo) / 2;
    if (check(med, y)) hi = med;
    else lo = med;
  }
  return hi;
}

int main() { // claudio van
  scanf("%lld %lld", &n, &k);
  for (int i = 0; i < n; ++i) {
    scanf("%lld", &a[i]);
  }
  for (int i = 0; i < n; ++i) {
    scanf("%lld", &f[i]);
  }
  sort(a, a + n);
  sort(f, f + n);
  printf("%lld\n", bs(0, 1e12L, k));
  return 0;
}

Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
	ll n,cnt=0,i;
	cin>>n;
	while(1){
    bool ans=true;
    for(i=2;i<n;i++){
      if(n%i==0)ans=false;
    }
    if(ans)break;
    n++;
  }
  cout<<n<<endl;
}


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

using namespace std;
typedef long long ll;

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
#define all(a) (a).begin(), (a).end()
#define all2(a, b) (a).begin(), (a).begin() + (b)
#define debug(vari) cerr << #vari << " = " << (vari) << endl;

int N, Q;
vector<int> S(100100), T(100100);

bool isOk(int index, int key)
{
    if (S[index] >= key)
        return true;
    else
        return false;
}

int C(int key)
{
    int ng = -1;
    int ok = N;

    while (abs(ok - ng) > 1)
    {
        int mid = (ok + ng) / 2;
        if (isOk(mid, key))
            ok = mid;
        else
            ng = mid;
    }
    return ok;
}

int main()
{

    cin >> N;
    rep(i, N) cin >> S[i];
    cin >> Q;
    rep(i, Q) cin >> T[i];

    int ans = 0;
    rep(i, Q)
    {
        int res = C(T[i]);
        if (0 <= res && res <= N - 1 && S[res] == T[i])
            ans++;
    }

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



Measured memory_bytes: 3440
while True:
    try:
        S = input()
    except EOFError:
        break
    ans = ''
    i = 0
    while i < len(S):
        if S [i] == '@':
            ans += S [i + 2] * int(S [i + 1])
            i += 3
        else:
            ans += S [i]
            i += 1
    print(ans)

Measured memory_bytes: 7664
package main

import "fmt"

func main() {
	// Code for B - Trained?
	var N int
	fmt.Scanf("%d", &N)

	a := make([]int, N)
	for i := 0; i < N; i++ {
		fmt.Scanf("%d", &a[i])
	}

	var x int = 1
	var flag int
	var count int = 1
	for i := 0; i < N; i++ {
		x = a[x-1]
		if x == 2 {
			flag = 1
			break
		} else {
			count++
		}
	}

	if flag == 1 {
		fmt.Println(count)
	} else {
		fmt.Println("-1")
	}
}


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

int main()
{
    long long a,b,c;
    cin>>a>>b>>c;
    if(c-a-b>0&&4*a*b<(c-a-b)*(c-a-b))
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<vector>
#include<algorithm>
#include<set>
#include<iostream>

using namespace std;

const int MX = 100005;

int D[MX];

int main()
{
	int N;
	scanf("%d", &N); N *= 2;
	for(int i = 1; i <= N; i++) scanf("%d", D+i);
	sort(D+1, D+N+1);
	int ans = 0;
	for(int i = 1; i <= N; i+=2){
		ans += min(D[i], D[i+1]);
	}
	printf("%d\n", ans);
}


Measured memory_bytes: 256
#include<iostream>
#include<climits>
using namespace std;
int main(){
    string s,t;
    cin>>s>>t;
    int min_count=INT_MAX;
    for(int i=0;i<=s.size()-t.size();i++)
    {
        int count=0;
        for(int j=0;j<t.size();j++)
        {
            if(s[i+j]!=t[j]){
                count++;
            }
        }
        if(min_count>count){
            min_count=count;
        }
    }
    cout<<min_count;
}

Measured memory_bytes: 3644
a = 1
b = 1
i = 0
n_big = Array.new
n_sma = Array.new

until a==0 && b==0 do
  n = gets
  num = n.split(" ")
  a = num[0].to_i
  b = num[1].to_i  
    
  if a > b then
    n_big << a
    n_sma << b
    else  
    n_big << b
    n_sma << a
  end 
  
  i += 1  

end

for i in 0..i-2 do
  print n_sma[i]," ",n_big[i],"\n"
end

Measured memory_bytes: 8872
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<long long> vl;
#define pll pair<ll, ll>
#define vpl vector<pll>
#define vb vector<bool>
#define PB push_back
#define MP make_pair
#define ln "\n"
#define forn(i,e) for(ll i=0; i<e; i++)
#define forsn(i,s,e) for(ll i=s; i<e; i++)
#define rforn(i,e) for(ll i=e; i>=0; i--)
#define rforsn(i,s,e) for(ll i=s; i>=e; i--)
#define vasort(v) sort(v.begin(), v.end())
#define vdsort(v) sort(v.begin(), v.end(),greater<ll>())
#define F first
#define S second

#define out1(x1) cout << x1 << ln
#define out2(x1,x2) cout << x1 << " " << x2 << ln
#define out3(x1,x2,x3) cout << x1 << " " << x2 << " " << x3 << ln
#define out4(x1,x2,x3,x4) cout << x1 << " " << x2 << " " << x3 << " " << x4 << ln
#define out5(x1,x2,x3,x4,x5) cout << x1 << " " << x2 << " " << x3 << " " << x4 << " " << x5 << ln
#define out6(x1,x2,x3,x4,x5,x6) cout << x1 << " " << x2 << " " << x3 << " " << x4 << " " << x5 << " " << x6 << ln

#define in1(x1) cin >> x1
#define in2(x1,x2) cin >> x1 >> x2
#define in3(x1,x2,x3) cin >> x1 >> x2 >> x3
#define in4(x1,x2,x3,x4) cin >> x1 >> x2 >> x3 >> x4
#define in5(x1,x2,x3,x4,x5) cin >> x1 >> x2 >> x3 >> x4 >> x5
#define in6(x1,x2,x3,x4,x5,x6) cin >> x1 >> x2 >> x3 >> x4 >> x5 >> x6

#define mz(a)   memset(a,0,sizeof(a))
#define arrin(a,n) forn(i,n) cin >> a[i];
#define arrout(a,n) forn(i,n) {cout << a[i] << " ";} cout << ln;
#define TYPEMAX(type)   std::numeric_limits<type>::max()
#define TYPEMIN(type)   std::numeric_limits<type>::min()

#define zoom ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
const ll MAXN=1e5+1;
vl adj[MAXN];
vb visited(MAXN);
void dfs(ll s) {
    if (visited[s]) return;
    visited[s] = true;
// process node s
    for (auto u: adj[s]) {
        dfs(u);
    }
}
int main() {
    zoom;
    ll n,m;
    in2(n,m);
    forn(i,m){
        ll u,v;
        in2(u,v);
        adj[u].PB(v);
        adj[v].PB(u);
    }
    ll ans=0;
    forsn(i,1,n+1){
        if (!visited[i]){
            dfs(i);
            ans++;
        }
    }
    out1(ans-1);

    return 0;
}

Measured memory_bytes: 10312
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)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

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

macro_rules! 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")
    };
}

fn main() {
    input! {
        a: i32,
        b: i32,
        c: i32,
    }
    let v = c - (a - b);
    if v > 0 {
        println!("{}", v);
    } else {
        println!("{}", 0);
    }
}


Measured memory_bytes: 4352
use std::io::*;
use std::str::FromStr;

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

fn main() {
    let n:usize = read();
    let d:usize = read();
    let m = d*2 + 1;
    if n % m == 0 {
        println!("{}", n / m);
    } else {
        println!("{}", n / m + 1);
    }
}


Measured memory_bytes: 2096
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define inf 0x3f3f3f3f
int a,b;
int main(){
	cin>>a>>b;
	int c=a*12.5,d=(b+1)*10;
	int ans=-1;
	//cout<<c<<" "<<d<<endl; 
	if(c>d)swap(c,d);
	for(int i=c;i<d;i++){
		int x,y;
		x=i*0.08;
		y=i*0.10;
		if(x==a&&y==b){
			ans=i;
			break;
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author cherrypi59
 */

#pragma GCC optimize ("O2")
#pragma GCC optimize ("tree-vectorize")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define FFOR(i, a, b) FOR(i, a, b+1)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) FOR(i, 1, n+1)
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define LEN(x) (int)(x).size()
#define DUMP(x) cerr<<__LINE__<<' '<<#x<<"="<<(x)<<endl;
#define pb push_back
#define eb emplace_back
#define mp make_pair

using namespace std;
using lint = long long;
using pii =  pair<int, int>;
using pll =  pair<lint, lint>;
template <typename T> using vc = vector<T>;
template <typename T> using vvc = vector<vector<T>>;
template <typename T> inline bool chmax(T &a, T b){if(a<b){a = b; return true;} return false;}
template <typename T> inline bool chmin(T &a, T b){if(a>b){a = b; return true;} return false;}

constexpr lint ten(int n) {return n==0 ? 1 : ten(n-1)*10;}

class ANickname {
public:
    void solve(std::istream& in, std::ostream& out){
        ios_base::sync_with_stdio(false);
        in.tie(nullptr), out.tie(nullptr);
        string S;
        in>>S;
        out<<S.substr(0, 3)<<'\n';
    }
};


int main() {
	ANickname solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define all(x) x.begin(),x.end()
#define pll  pair <long long,long long>
#define ss second
#define ff first
#define inf 9223372036854775807
#define maa 1000000007
#define ld long double
#define fast  ios_base::sync_with_stdio(false);cin.tie(NULL);
#define bug(x) cout << #x <<": " << x << '\n';
const ll N=200001 ;
int main()
{
   fast ;
   ll n,k ; cin>>n>>k ;
   ll r[n+1] ;
   memset(r,0,sizeof(r)) ;
   for(ll i=0;i<k;i++){
    ll d ;
    cin>>d ;
    for(ll j=0;j<d;j++){
        ll x ;
        cin>>x ;
        r[x]=1 ;
    }
   }
   ll ans=0 ;
   for(ll i=1;i<=n;i++)
   {
       if(r[i]==0) ans++ ;
   }
   cout<<ans  ;


}



Measured memory_bytes: 3616
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <time.h>
#include <iostream>
#include <algorithm>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <iomanip>
#include <assert.h>
#include <fstream>

using namespace std;

long long a,b,c;

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

Measured memory_bytes: 256
#[allow(unused_imports)]
use std::cmp::{max, min, Ordering};
#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};
#[allow(unused_imports)]
use std::io::{stdin, stdout, BufWriter, StdoutLock, Write};
#[allow(unused_imports)]
use std::iter::FromIterator;
#[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 ) * } } ; }
#[allow(unused_macros)]
macro_rules ! read_value { ( $ next : expr , ( $ ( $ t : tt ) ,* ) ) => { ( $ ( read_value ! ( $ next , $ t ) ) ,* ) } ; ( $ next : expr , [ $ t : tt ; $ len : expr ] ) => { ( 0 ..$ len ) . map ( | _ | read_value ! ( $ next , $ t ) ) . collect ::< Vec < _ >> ( ) } ; ( $ next : expr , chars ) => { read_value ! ( $ next , String ) . chars ( ) . collect ::< Vec < char >> ( ) } ; ( $ next : expr , bytes ) => { read_value ! ( $ next , String ) . into_bytes ( ) } ; ( $ next : expr , usize1 ) => { read_value ! ( $ next , usize ) - 1 } ; ( $ next : expr , $ t : ty ) => { $ next ( ) . parse ::<$ t > ( ) . expect ( "Parse error" ) } ; }
#[allow(dead_code)]
pub fn with_bufwriter<F: FnOnce(BufWriter<StdoutLock>) -> ()>(f: F) {
    let out = stdout();
    let writer = BufWriter::new(out.lock());
    f(writer)
}
#[allow(unused_macros)]
macro_rules ! debug { ( $ ( $ a : expr ) ,* ) => { eprintln ! ( concat ! ( $ ( stringify ! ( $ a ) , " = {:?}, " ) ,* ) , $ ( $ a ) ,* ) } ; }
#[allow(dead_code)]
pub const INF: i64 = 1_000_000_000;
#[allow(dead_code)]
fn main() {
    input!{
        n: usize,
        h: [i64; n],
    }
    let mut dp = vec![INF; n];
    dp[0] = 0;
    for i in 0..n {
        //debug!(dp);
        if i + 2 < n {
            if dp[i+2] == INF {
                dp[i+2] = dp[i] + (h[i] - h[i+2]).abs();
            } else {
                dp[i+2] = min(dp[i] + (h[i] - h[i+2]).abs(), dp[i+2]);
            }
        }
        if i + 1 < n {
            if dp[i+1] == INF {
                dp[i+1] = dp[i] + (h[i] - h[i+1]).abs();
            } else {
                dp[i+1] = min(dp[i] + (h[i] - h[i+1]).abs(), dp[i+1]);
            }
        }
    }
    //debug!(dp);
    println!("{}", dp[n-1]);
}

Measured memory_bytes: 6396
/*
２つの整数 a, b と１つの演算子 op を読み込んで、a op b を計算するプログラムを作成して下さい。
ただし、演算子 op は、"+"(和)、"-"(差)、"*"(積)、"/"(商)、のみとし、
割り算で割り切れない場合は、小数点以下を切り捨てたものを計算結果とします。
 */

#include <stdio.h>

int main(void)
{
    int a, b;
    char op; // + or - or * or /
    int i;

    for(i = 0; op != '?'; i++)
    {
        scanf ("%d %c %d", &a, &op, &b);
        if (op == '+')
            printf("%d\n", a + b);
        else if (op == '-')
            printf("%d\n", a - b);
        else if (op == '*')
            printf("%d\n", a * b);
        else if (op == '/')
            printf("%d\n", a / b);
        else
            break ;
    }
    return (0);
}


Measured memory_bytes: 2060
#include <cstring>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <algorithm>
using namespace std;
typedef long long LL;
const int N=1005;
int n,a[N],f[N],ans=0,x[N];
LL solve(int v){
	LL ans=0;
	for (int i=1;i<=n;i++)
		if ((i&1)==v)
			if (a[i]>0)
				ans+=a[i],f[i]=1;
	if (ans>0)
		return ans;
	ans=-1e9;
	for (int i=1;i<=n;i++)
		if ((i&1)==v)
			ans=max(ans,(LL)a[i]);
	return ans;
}
void solution1(int v){
	int pos=0;
	for (int i=1;i<=n;i++)
		if (a[i]==v){
			pos=i;
			break;
		}
	for (int i=1;i<pos;i++)
		x[++ans]=1;
	for (int i=n;i>pos;i--)
		x[++ans]=i-pos+1;
}
int Next(int x){
	for (x++;!f[x]&&x<=n;x++);
	return x;
}
void solution2(int v){
	for (int i=1;i<=n;i++)
		if ((i&1)!=v)
			f[i]=0;
	int L=1,R=n;
	while (!f[L])
		x[++ans]=1,L++;
	while (!f[R])
		x[++ans]=(R--)-L+1;
	for (int i=L,j=Next(i);i<R;i=j,j=Next(i))
		for (int k=(j-i)/2;k>0;k--)
			x[++ans]=k+1;
}
int main(){
	scanf("%d",&n);
	for (int i=1;i<=n;i++)
		scanf("%d",&a[i]);
	memset(f,0,sizeof f);
	LL s0=solve(0),s1=solve(1);
	printf("%lld\n",max(s0,s1));
	if (max(s0,s1)<0)
		solution1((int)max(s0,s1));
	else if (s0>s1)
		solution2(0);
	else
		solution2(1);
	printf("%d\n",ans);
	for (int i=1;i<=ans;i++)
		printf("%d\n",x[i]);
	return 0;
}

Measured memory_bytes: 128
#include <climits>
#include <iomanip>
#include <iostream>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;

int main(void) {
  ios::sync_with_stdio(false);
  int A, B, M;
  cin >> A >> B >> M;
  
  vector<int> a(A);
  int minA = INT_MAX;
  rep(i, A) {
    cin >> a[i];
    minA = min(minA, a[i]);
  }
  vector<int> b(B);
  int minB = INT_MAX;
  rep(i, B) {
    cin >> b[i];
    minB = min(minB, b[i]);
  }

  int answer = minA + minB;
  rep(i, M) {
    int x, y, c;
    cin >> x >> y >> c;
    x--; y--;
    int cost = a[x] + b[y] - c;
    answer = min(answer, cost);
  }
  cout << answer << endl;
  return 0;
}


Measured memory_bytes: 1024
import sys

# sys.stdin = open('a1.in')


def read_int_list():
    return list(map(int, input().split()))


def read_str_list():
    return input().split()


def read_int():
    return int(input())


def read_str():
    return input()


def main():
    n = read_int()
    if str(n)[0] == str(n)[-1]:
        res = 'Yes'
    else:
        res = 'No'
    print(res)


main()


Measured memory_bytes: 3060
def input_int():
    return map(int, input().split())

def one_int():
    return int(input())

def one_str():
    return input()

def many_int():
    return list(map(int, input().split()))

X=one_int()

count = 0
money =100
hukuri = 0.01
while True:
    count+=1
    money = int(money + money*hukuri)
    if int(money)>=X:
        break
print(count)

Measured memory_bytes: 9160
#include <bits/stdc++.h>
typedef long long ll;
#define pb push_back
#define mii map <int, int>
#define mll map <ll, ll>
#define pii pair <int, int>
#define pll pair <ll, ll>
#define vi vector <int>
#define vd vector <double>
#define vll vector <ll>
#define fi first
#define se second
#define si set <int>
#define sll set <ll>
#define spii set <pii>
#define vs vector <string>
#define vpii vector <pair <int,int> >
#define vpll vector <pair <long long,long long> >
#define vvi vector <vector <int> >
#define vvpii vector <vector <pii > >
#define forn(i, n) for (int i = 0; i < (n); i++)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define for1(i, n) for (int i = 1; i < (n); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(),(x).rend()


using namespace std;
const ll INFLL = 1e18;
const int MAXN = 1e6+100;
const ll INF = 1e9;
const ll mod1=1e9+7;
const ll mod2=2e9+11;

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    #ifdef LOCAL
    freopen("a.in","r",stdin);
    #endif
    ll h,n;
    cin>>h>>n;
    ll sum=0;
    for (int i=0;i<n;i++)
    {
        ll x;
        cin>>x;
        sum+=x;
    }
    if (sum>=h)
        cout<<"Yes";
    else
        cout<<"No";



}

Measured memory_bytes: 256
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <cassert>
#include <cfloat>
#include <complex>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define rep(i, n) for (ll i = 0; i < (n); ++i)

using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;
using vll = vector<ll>;
using vP = vector<P>;
using vvll = vector<vector<ll>>;
using vvP = vector<vector<P>>;

const ll INF = 1LL << 32;

int main() {
  ll n, m, r;
  cin >> n >> m >> r;

  vvll d(n, vll(n, INF));
  vll rs(r);

  for (ll i = 0; i < r; i++) {
    cin >> rs[i];
    rs[i]--;
  }

  for (ll i = 0; i < m; i++) {
    ll a, b, c;
    cin >> a >> b >> c;
    a--;
    b--;
    d[a][b] = c;
    d[b][a] = c;
  }

  rep(k, n) rep(i, n) rep(j, n) chmin(d[i][j], d[i][k] + d[k][j]);

  vll lst(r);
  ll ans = INF;
  rep(i, r) lst[i] = i;
  do {
    ll cur = 0;
    for (ll i = 1; i < r; i++) {
      ll didx = rs[lst[i]];
      ll sidx = rs[lst[i - 1]];
      cur += d[didx][sidx];
    }
    chmin(ans, cur);
  } while (next_permutation(lst.begin(), lst.end()));

  cout << ans << endl;

  return 0;
}


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

int main() {
  int K;
  cin >> K;
  K++;
  int cnt = 0;
  rep(a, K) rep(b, K) rep(c, K) {
    if (a == 0 || b == 0 || c == 0) continue;
    cnt += gcd(gcd(a, b), c);
  }
  cout << cnt << endl;
}


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

using namespace std;
const int N=2e5+10;
int a[N],b[N],vis[N];
int main(){
    int n;
    long long k;
    cin>>n>>k;
    memset(vis,0,sizeof(vis));
    for(int i =1 ;i <= n;i++)
         scanf("%d",&a[i]);
    int num = 1;
    b[1] = a[1];
    int i = a[1];
    while(!vis[i])
    {
        vis[i]=num;
        b[++num] = a[i];
        i = a[i];
    }
    num--;
    //cout<<num<<endl;
    int l = num-vis[i]+1;
  //  cout<<l<<endl;
   // cout<<i<<endl;
 //   cout<<vis[i]<<endl;

    if(k<=num) cout<<b[k]<<endl;
    else{
        k-=vis[i]-1;
        k%=l;
        if(k==0) cout<<b[num]<<endl;
        else cout<<b[k+vis[i]-1]<<endl;
    }
    return 0;
}


Measured memory_bytes: 5916
#-*-coding:utf-8-*-
from functools import reduce

#最大公約数を返す
#ユークリッドの互除法
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

#最小公倍数を返す
def lcm(a, b):
    return a * b // gcd(a, b)

#リストに対して最小公倍数を返す
def lcm_list(numbers):
    return reduce(lcm, numbers)

def main():
    n = int(input())
    t_list = []
    for _ in range(n):
        t_list.append(int(input()))
    print(lcm_list(t_list))    

if __name__ == '__main__':
    main()

Measured memory_bytes: 3572
n,Y=map(int,input().split())

for x in range(n+1):
  for y in range(n+1):
    z=n-x-y

 
    if 10000*x+5000*y+1000*z==Y and z>=0:
      print('{} {} {}'.format(x,y,z))
      
      exit()

print('{} {} {}'.format(-1,-1,-1))

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

using namespace std;

map<pair<int,int>, long long> mp;

long long solve(int ind, int n, int a[], int b[]){
	if(ind==3){
		return n;
	}
	if(a[ind]>=b[ind]){
		return solve(ind+1,n,a,b);
	}
	for(int i=ind+1;i<3;i++){
		if(a[i]<b[i]){
			if(mp.find({ind,n})!=mp.end()){
				return mp[{ind,n}];
			}
			long long ans=n;
			for(int j=0;j*a[ind]<=n;j++){
				ans=max(ans,solve(ind+1,n-j*a[ind],a,b)+1ll*j*b[ind]);
			}
			return mp[{ind,n}]=ans;
		}
	}
	return n%a[ind]+1ll*(n/a[ind])*b[ind];
}

int main(){
	int n; cin >> n;
	int ga[3]; cin >> ga[0] >> ga[1] >> ga[2];
	int gb[3]; cin >> gb[0] >> gb[1] >> gb[2];
	
	n=solve(0,n,ga,gb);
	mp.clear();
	cout << solve(0,n,gb,ga) << endl;
	return 0;
}

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

using namespace std;

#define MAX 1000000

int main()
{
    vector<int> p;
    bool prime[MAX];
    fill(prime, prime + MAX, 1);
    prime[0] = prime[1] = 0;
    for (int i = 2; i < MAX; i++) {
        if (prime[i]) {
            p.push_back(i);
            for (int j = 2*i; j < MAX; j += i) {
                prime[j] = 0;
            }
        }
    }

    int N;
    while (cin >> N) {
        cout << upper_bound(p.begin(), p.end(), N) - p.begin() << endl;
    }
    return 0;
}

Measured memory_bytes: 4304
//satyaki3794
#include <bits/stdc++.h>
#define ff first
#define ss second
#define pb push_back
#define MOD (1000000007LL)
#define LEFT(n) (2*(n))
#define RIGHT(n) (2*(n)+1)
 
using namespace std;
typedef long long ll;
typedef pair<int, int> ii;
typedef pair<int, ii> iii;
 
ll pwr(ll base, ll p, ll mod=MOD){
ll ans = 1;while(p){if(p&1)ans=(ans*base)%mod;base=(base*base)%mod;p/=2;}return ans;
}
 
 
ll gcd(ll a, ll b){
    if(b == 0)  return a;
    return gcd(b, a%b);
}


int n, m, tree[4*200002], lazy[4*200002];
vector<int> arr[200005];


void build(int node, int s, int e){
    if(s > e)   return;
    if(s == e){
        tree[node] = s-m;
        return;
    }
    int mid = (s+e)/2;
    build(LEFT(node), s, mid);
    build(RIGHT(node), mid+1, e);
    tree[node] = max(tree[LEFT(node)], tree[RIGHT(node)]);
}


void update(int node, int s, int e, int lo, int hi){
    if(s > e) return;
    if(lazy[node] != 0){
        tree[node] += lazy[node];
        if(s != e){
            lazy[LEFT(node)] += lazy[node];
            lazy[RIGHT(node)] += lazy[node];
        }
        lazy[node] = 0;
    }
    if(hi < s || lo > e)  return;
    if(s >= lo && e <= hi){
        tree[node] += 1;
        if(s != e){
            lazy[LEFT(node)] += 1;
            lazy[RIGHT(node)] += 1;
        }
        return;
    }
    int mid = (s+e)/2;
    update(LEFT(node), s, mid, lo, hi);
    update(RIGHT(node), mid+1, e, lo, hi);
    tree[node] = max(tree[LEFT(node)], tree[RIGHT(node)]);
}


int query(int node, int s, int e, int lo, int hi){
    if(s > e) return -MOD;
    if(lazy[node] != 0){
        tree[node] += lazy[node];
        if(s != e){
            lazy[LEFT(node)] += lazy[node];
            lazy[RIGHT(node)] += lazy[node];
        }
        lazy[node] = 0;
    }
    if(hi < s || lo > e)  return -MOD;
    if(s >= lo && e <= hi)  return tree[node];
    int mid = (s+e)/2;
    int a = query(LEFT(node), s, mid, lo, hi);
    int b = query(RIGHT(node), mid+1, e, lo, hi);
    return max(a, b);
}



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

    cin>>n>>m;
    int ans = max(0, n-m);
    m += 2;
    for(int i=1;i<=n;i++){
        int l, r;
        cin>>l>>r;
        l++;    r++;
        arr[l].pb(r);
    }

    build(1, 1, m);
    for(int i=1;i<m;i++){
// cout<<"at i = "<<i<<endl;
        for(auto it : arr[i])
            update(1, 1, m, 1, it);
        ans = max(ans, -(i-1) + query(1, 1, m, i+2, m));

// for(int j=6;j<=m;j++)   cout<<j<<":"<<query(1, 1, m, j, j)<<" ";cout<<endl;
// cout<<-i+1 + query(1, 1, m, i+2, m)<<" ans = "<<ans<<endl;

    }

    cout<<ans;
    return 0;
}





Measured memory_bytes: 14080
#include <algorithm>
#include <cassert>
// #include <chrono>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
// #include <random>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>

/*
unsigned seed1 = std::chrono::system_clock::now().time_since_epoch().count();
mt19937 g1.seed(seed1);
*/
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<pii, pii> ppiipii;
typedef pair<int, ppiipii> pippiipii;
typedef pair<int, pii> pipii;
typedef pair<pii, int> ppiii;
typedef pair<int, ppiii> pippiii;
typedef pair<int, ll> pill;
typedef pair<int, double> pid;
// note to self, the below two triggers someone
typedef pair<ll, ll> pll;
typedef pair<ll, int> plli;
typedef long double ld;

char bufs[3][105];

int lens[3];
int idxs[3];

int main() {
  scanf("%s%s%s", bufs[0], bufs[1], bufs[2]);
  for(int i = 0; i < 3; i++) {
    lens[i] = strlen(bufs[i]);
  }
  int idx = 0;
  while(true) {
    if(idxs[idx] == lens[idx]) {
      printf("%c\n", 'A' + idx);
      return 0;
    }
    idx = bufs[idx][idxs[idx]++]-'a';
  }
}


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

using namespace std;
typedef long long ll;
typedef pair<ll, ll> p_ll;

template<class T>
void debug(T itr1, T itr2) { auto now = itr1; while(now<itr2) { cout << *now << " "; now++; } cout << endl; }
#define repr(i,from,to) for (int i=(int)from; i<(int)to; i++)
#define rep(i,N) repr(i,0,N)
#define per(i,N) for (int i=(int)N-1; i>=0; i--)

const ll MOD = pow(10,9)+7;
const ll LLINF = pow(2,61)-1;
const int INF = pow(2,30)-1;

struct UnionFind {
  vector<int> par;

  UnionFind(int N) : par(N) { rep(i, N) par[i] = i; }

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

  void unite(int x, int y) {
    int rx = root(x);
    int ry = root(y);
    if (rx==ry) return;
    par[rx] = ry;
  }

  bool same(int x, int y) {
    return root(x) == root(y);
  }

};

typedef priority_queue<int, vector<int>, greater<int>> que;

int main() {
  int N, M; cin >> N >> M;
  ll a[N]; rep(i,N) cin >> a[i];
  UnionFind tree(N);
  rep(i,M) {
    int x, y; cin >> x >> y;
    tree.unite(x,y);
  }
  que q[N];
  rep(i,N) q[tree.root(i)].push(a[i]);
  // rep(i,N) cout << q[i].size() << " "; cout << endl;
  sort(q,q+N,[](const que &x, que &y){return x.size()>y.size();});

  ll result = 0, count = 0;
  repr(i,1,N) {
    if (q[i].empty()) break;
    result += q[i].top();
    q[i].pop();
    while (q[i].size()) {
      q[0].push(q[i].top());
      q[i].pop();
    }
    count++;
  }
  if (q[0].size()<count) { cout << "Impossible" << endl; return 0; }
  rep(i,count) {
    result += q[0].top();
    q[0].pop();
  }
  cout << result << endl;
  return 0;
}

Measured memory_bytes: 7680
object Main {

  def main(args: Array[String]): Unit = {
    val sc = new java.util.Scanner(System.in)

    val N = sc.nextInt()
    val A = Array.fill(N)(sc.nextInt())
    val isEven = A.count(_ < 0) % 2 == 0

    val absSum = A.map(a => Math.abs(a)).foldLeft(0L)(_ + _)

    val res =
      if (isEven) absSum
      else absSum - (2 * A.map(a => Math.abs(a)).min)
    println(res)
  }

}

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

int main() {
	string s;
	cin >> s;
	long long int q=0,l,a=0;
	l=s.length();
	for(int i=0;i<l;i++){
		a=s[i]-'0';
		q=q+a;
	}
	if(q%9==0)
	cout<<"Yes";
	else
	cout<<"No";
	return 0;
}

Measured memory_bytes: 3752
// Author: getharshkumar

#include <bits/stdc++.h>
using namespace std;
#define ll int64_t
const ll N = 1e6 + 6, M = 1e9 + 7;
int main()
{
    ios::sync_with_stdio(false), cin.tie(nullptr);
    ll n;
    cin >> n;
    if (n % 2 == 0)
        cout << 0.5;
    else
        cout << setprecision(12) << (double)(n / 2 + 1) / n;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int a, b, c;

	scanf("%d %d %d", &a, &b, &c);

	if (a - b >= c) //容器1に容器2の水すべてが入る場合
	{
		printf("0\n");
	}
	else //容器2に水が残る場合
	{
		printf("%d\n", c - (a - b));
	}

	return 0;
}

Measured memory_bytes: 128
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    long n = sc.nextLong();
    long m = sc.nextLong();
    long ans = 1;
    for(long i = 1; (i * i) <= m; i++) {
      if((m % i) == 0) {
        if((i * n) <= m) ans = Math.max(ans, i);
        if(((m / i) * n) <= m) ans = Math.max(ans, m / i);
      }
    }
    System.out.println(ans);
  }
}

Measured memory_bytes: 22996
F = [None] * 3

a = list(map(int, input().split()))
b = [a[i] - a[i+1] for i in range(2)]

for i in range(2):
    c = list(map(int, input().split()))
    d = [c[i] - c[i+1] for i in range(2)]
    if b != d:
        print('No')
        break
else:
    print('Yes')

Measured memory_bytes: 3064
from collections import deque

h,w = map(int,input().split())
g = [list(map(int, list(input().replace('#', '0')))) for _ in range(h)]
f = [[False]*w for _ in range(h)]
q = deque()
d = ((0,1), (1,0), (-1,0), (0,-1))

def chst(c,st,i):
  if i == 1:
    nc = st[1]
    nst = (st[0], 7-c)
  if i == 0:
    nc = st[0]
    nst = (7-c, st[1])
  if i == 2:
    nc = 7-st[1]
    nst = (st[0], c)
  if i == 3:
    nc = 7 - st[0]
    nst = (c, st[1])
  return nc, nst

q.append((0,0,(2,3)))
while q:
  y,x,st = q.popleft()
  if f[y][x]: continue
  f[y][x] = st
  for i in range(4):
    dx, dy = d[i]
    nx = x + dx; ny = y + dy
    if 0 <= nx < w and 0 <= ny < h:
      nc, nst = chst(g[y][x], st, i)
      if nc == g[ny][nx]:
        q.append((ny,nx,nst))
print('YES' if f[h-1][w-1] else 'NO')
# print(*f, sep = '\n')


Measured memory_bytes: 6620
from collections import Counter
n = int(input())
a = list(map(int, input().split()))
nums = Counter(a)
q = int(input())
ans = 0
for k, v in nums.items():
    ans += k*v
for _ in range(q):
    b, c = map(int, input().split())
    ans -= nums[b] * b
    ans += nums[b] * c
    nums[c] += nums[b]
    nums[b] = 0
    print(ans)


Measured memory_bytes: 24000
package main

import (
	"fmt"
	"container/heap"
)

type Job struct {
	A int
	B int
}

type Item struct {
	value interface{}
	priority float64
	index int
}

type PriorityQueue []*Item

func (pq PriorityQueue) Len() int {
	return len(pq)
}

func (pq PriorityQueue) Less(i, j int) bool {
	// We want Pop to give us the highest, not lowest, priority so we use greater than here.
	return pq[i].priority > pq[j].priority
}

func (pq PriorityQueue) Swap(i, j int) {
	pq[i], pq[j] = pq[j], pq[i]
	pq[i].index = i
	pq[j].index = j
}


func (pq *PriorityQueue) Push(x interface{}) {
	n := len(*pq)
	item := x.(*Item)
	item.index = n
	*pq = append(*pq, item)
}

func (pq *PriorityQueue) Pop() interface{} {
	old := *pq
	n := len(old)
	item := old[n-1]
	item.index = -1
	*pq = old[0 : n-1]
	return item
}


func main() {
	var N, M int
	fmt.Scan(&N)
	fmt.Scan(&M)

	cost_queue := make(PriorityQueue, 0)
	for i := 0; i < N; i++ {
		var A, B int
		fmt.Scan(&A)
		fmt.Scan(&B)
		job := Job {A, B}
		heap.Push(&cost_queue, &Item {
			value: &job,
			priority: float64(-job.A),
		})
	}

	res := 0
	revenue_queue := make(PriorityQueue, 0)
	for i := 1; i <= M; i++ {
		for len(cost_queue) > 0 && cost_queue[0].value.(*Job).A <= i{
			var top *Job
			top = heap.Pop(&cost_queue).(*Item).value.(*Job)
			heap.Push(&revenue_queue, &Item {
				value: top,
				priority: float64(top.B),
			})
		}

		if len(revenue_queue) > 0 {
			top := heap.Pop(&revenue_queue).(*Item).value.(*Job)
			res += top.B
		}
	}

	fmt.Println(res)
}


Measured memory_bytes: 14976
#include <float.h>
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>

// 内部変数
static FILE *szpFpI;											// 入力
static long long sl2Cnt[10][10];								// 個数

// 内部変数 - テスト用
#ifdef D_TEST
	static int siRes;
	static FILE *szpFpA;
	static int siTNo;
#endif

// １行出力
int
fOutLine(
	char *pcpLine				// <I> １行
)
{
	char lc1Buf[1024];

#ifdef D_TEST
	lc1Buf[0] = '\0';
	fgets(lc1Buf, sizeof(lc1Buf), szpFpA);
	if (strcmp(lc1Buf, pcpLine)) {
		siRes = -1;
	}
#else
	printf("%s", pcpLine);
#endif

	return 0;
}

// 実行メイン
long long
fMain(
)
{
	int i;
	char lc1Buf[1024];

	// 上限 - 取得
	int liLimit;
	fgets(lc1Buf, sizeof(lc1Buf), szpFpI);
	sscanf(lc1Buf, "%d", &liLimit);

	// 個数 - 取得
	long long llCnt = 0;
	for (i = 1; i <= liLimit; i++) {

		// 末尾の数字
		int liLNum = i % 10;

		// 先頭の数字
		int liFNum = i;
		while (liFNum >= 10) {
			liFNum /= 10;
		}

		// 前回までの数字とペア
		llCnt += sl2Cnt[liLNum][liFNum] * 2;

		// 今回の数字同士
		if (liFNum == liLNum) {
			llCnt++;
		}

		// 個数 - 累計
		sl2Cnt[liFNum][liLNum]++;
	}

	return llCnt;
}

// １回実行
int
fOne(
)
{
	long long llRet;
	char lc1Buf[1024];

	// データ - 初期化
	memset(sl2Cnt, 0, sizeof(sl2Cnt));							// 個数

	// 入力 - セット
#ifdef D_TEST
	sprintf(lc1Buf, ".\\Test\\T%d.txt", siTNo);
	szpFpI = fopen(lc1Buf, "r");
	sprintf(lc1Buf, ".\\Test\\A%d.txt", siTNo);
	szpFpA = fopen(lc1Buf, "r");
	siRes = 0;
#else
	szpFpI = stdin;
#endif

	// 実行メイン
	llRet = fMain();

	// 出力
	sprintf(lc1Buf, "%lld\n", llRet);
	fOutLine(lc1Buf);

	// 残データ有無
#ifdef D_TEST
	lc1Buf[0] = '\0';
	fgets(lc1Buf, sizeof(lc1Buf), szpFpA);
	if (strcmp(lc1Buf, "")) {
		siRes = -1;
	}
#endif

	// テストファイルクローズ
#ifdef D_TEST
	fclose(szpFpI);
	fclose(szpFpA);
#endif

	// テスト結果
#ifdef D_TEST
	if (siRes == 0) {
		printf("OK %d\n", siTNo);
	}
	else {
		printf("NG %d\n", siTNo);
	}
#endif

	return 0;
}

// プログラム開始
int
main()
{

#ifdef D_TEST
	int i;
	for (i = D_TEST_SNO; i <= D_TEST_ENO; i++) {
		siTNo = i;
		fOne();
	}
#else
	fOne();
#endif

	return 0;
}



Measured memory_bytes: 128
// Problem : D - ABS
// Contest : AtCoder - AtCoder Regular Contest 085
// URL : https://atcoder.jp/contests/arc085/tasks/arc085_b
// Memory Limit : 256 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

// #pragma GCC optimize ("O3")
// #pragma GCC target ("sse4")

#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;
 
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
 
typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;
 
#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,b,a) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
#define trav(a,x) for (auto& a : x)
 
#define bug(x) cout<<#x<<"="<<x<<endl; 
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define ins insert
 
template<class T> bool ckmin(T& a, const T& b) { return b < a ? a = b, 1 : 0; }
template<class T> bool ckmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
const ld pii=3.14159265359; 
const int MOD = 1000000007;
const char nl = '\n';
const int MX = 200001; //check the limits, dummy
int N,W,Z;
vl v,dpX,dpY;

ll calc(int level,ll cX,ll cY,bool choice)
{
	if(level==N)
		return abs(cX-cY);
	if(choice)
	{
		if(dpX[level]!=-1)
			return dpX[level];
		ll mx=-1;
		FOR(x,level+1,N+1)
		{
			ckmax(mx,calc(x,v[x-1],cY,!choice));
		}
		return dpX[level]=mx;
	}
	else
	{
		if(dpY[level]!=-1)
			return dpY[level];
		ll mn=LLONG_MAX;
		FOR(x,level+1,N+1)
		{
			ckmin(mn,calc(x,cX,v[x-1],!choice));
		}
		return dpY[level]=mn;
	}
}


int main() 
{
	ios_base::sync_with_stdio(0); cin.tie(0);    
	cin>>N>>Z>>W;
	F0R(x,N)
	{
		int nb;
		cin>>nb;
		v.pb(nb);
		dpX.pb(-1);
		dpY.pb(-1);
	}
	cout<<calc(0,Z,W,true)<<nl;
	return 0;
}
 
// read the question correctly (ll vs int)
// template by bqi343

Measured memory_bytes: 3772
#include <cstdio>
#include <string>
using namespace std;

int main() {
    int d;
    string days[] = {"sat", "sun", "mon", "tue", "wed", "thu", "fri"};
    scanf("%d", &d);
    d = (d-9) % 7;
    if (d < 0) d+= 7;
    printf("%s\n", days[d].c_str());
    return 0;
}



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

int dp[10001];
const int INF = 1e9;
vector <pair<int,int>> v;
int h,n,a,b;

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

	cin >> h >> n;

	for(int i=0;i<n;i++)
	{
		cin >> a >> b;
		v.push_back(make_pair(a,b));
	}

	fill(dp,dp+10001,INF);
	dp[0] = 0;

	for(int i=0;i<n;i++)
	{
		for(int j=0;j<=h;j++)
		{
			int nexth = min(h,j + v[i].first);
			dp[nexth] = min(dp[nexth],dp[j] + v[i].second);
		}
	}

	cout << dp[h] << '\n';

	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

typedef struct{
  int id;
  int color;
  int k;
  int next[100];
}Graph;

int n;
int S[100];
int top = 0;
int d[101],f[101];
int time;
Graph G[101] = {{0,0,0,NULL}};

void push(a){
  S[top]=a;
  top++;
}

int pop(){
  int a;
  a = S[top];
  if(top>0)
    top--;
  return a;
}

void visit(u){
  int i;
  G[u].color = 1;
  d[u] = ++time;
  for(i=0;i<G[u].k;i++){
    if(G[G[u].next[i]].color == 0)
      visit(G[u].next[i]);
  }
  G[u].color = 2;
  f[u] = ++time;
}

void dfs(){
  int i;
  time = 0;
  for(i=1;i<=n;i++){
    if(G[i].color == 0)
      visit(i);
  }
}

int main(){
  int i,j;
  scanf("%d",&n);
  for(i=1;i<=n;i++){
    scanf("%d%d",&G[i].id,&G[i].k);
    for(j=0;j<G[i].k;j++){
      scanf("%d",&G[i].next[j]);
    }
  }
  dfs();
  for(i=1;i<=n;i++){
    printf("%d %d %d\n",G[i].id,d[i],f[i]);
  }

  return 0;
}



Measured memory_bytes: 2108
import java.io.InputStream;
import java.io.PrintStream;
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {
    resolve(System.in, System.out);
  }

  static void resolve(InputStream is, PrintStream pw) {
    Scanner sc = new Scanner(is);
    int n = Integer.parseInt(sc.next());
    int k = Integer.parseInt(sc.next());
    int a[] = new int[n];
    for (int i = 0; i < n; i++) {
      a[i] = Integer.parseInt(sc.next());
    }
    for (int i = k; i < n; i++) {
      pw.println(
        a[i] > a[i - k] ? "Yes" : "No"
      );
    }
  }
}


Measured memory_bytes: 60804
#define  _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES

#pragma comment (linker, "/STACK:526000000")

#include "bits/stdc++.h"

using namespace std;
typedef string::const_iterator State;
#define eps 1e-11L
#define MAX_MOD 1000000007LL
#define GYAKU 500000004LL

#define MOD 998244353LL
#define seg_size 262144
#define pb push_back
#define mp make_pair
typedef long long ll;
#define REP(a,b) for(long long (a) = 0;(a) < (b);++(a))
#define ALL(x) (x).begin(),(x).end()

void init() {
    iostream::sync_with_stdio(false);
    cout << fixed << setprecision(20);
}


unsigned long xor128() {
    static unsigned long x = 123456789, y = 362436069, z = 521288629, w = 88675123;
    unsigned long t = (x ^ (x << 11));
    x = y; y = z; z = w;
    return (w = (w ^ (w >> 19)) ^ (t ^ (t >> 8)));
}


#define int long long
int dp[(1 << 16)];
int color[4][4];
void solve() {
    int n;
    cin >> n;
    vector<pair<int, int>> inputs;
    REP(i, n) {
        int a, b;
        cin >> a >> b;
        inputs.push_back(mp(a, b));
    }
    REP(i, 4) {
        string s;
        cin >> s;
        REP(q, 4) {
            if (s[q] == 'R') {
                color[i][q] = 0;
            }
            else if (s[q] == 'B') {
                color[i][q] = 1;
            }
            else if (s[q] == 'G') {
                color[i][q] = 2;
            }
        }
    }
    REP(i, (1 << 16)) {
        dp[i] = 1e9;
    }
    dp[0] = 0;
    queue<int> next;
    next.push(0);
    vector<pair<int, int>> itring;
    REP(q, inputs.size()) {
        for (int j = -3; j < 4; ++j) {
            for (int p = -3; p < 4; ++p) {
                REP(t, 3) {
                    int die = (1 << 16) - 1;
                    int adding = 0;
                    for (int x = j; x < j + inputs[q].first; ++x) {
                        for (int y = p; y < p + inputs[q].second; ++y) {
                            if (x >= 0 && x <= 3 && y >= 0 && y <= 3) {
                                die -= (1 << (x * 4 + y));
                                if (color[x][y] == t) {
                                    adding += (1 << (x * 4 + y));
                                }
                            }
                        }
                    }
                    itring.push_back(mp(die, adding));
                }
            }
        }
    }
    while (next.empty() == false) {
        int now = next.front();
        next.pop();
        for (auto x : itring) {
            int hoge = (now & x.first) + x.second;
            if (dp[hoge] == 1e9) {
                dp[hoge] = dp[now] + 1;
                next.push(hoge);
            }
        }
    }
    cout << dp[(1 << 16) - 1] << endl;
}

#undef int
int main() {
    init();
    solve();
}


Measured memory_bytes: 3876
import numpy as np


def main():
    N, L = map(int, input().split())
    Ns = np.array(range(1, N+1)) + L - 1
    abs_Ns = np.where(Ns < 0, Ns*-1, Ns)
    eat_indx = np.where(abs_Ns == np.min(abs_Ns))[0][0]
    ans = np.sum(np.delete(Ns, eat_indx, 0))
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 13660