akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

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

typedef long long ll;
using namespace std;
int mod = 1000000007;

int main(void){
    int N; cin >> N;
    ll D, A; cin >> D >> A;
    ll X[N], H[N]; rep(i, N) cin >> X[i] >> H[i];
    pair<ll, ll> XH[N]; rep(i, N) XH[i] = make_pair(X[i], H[i]);
    sort(XH, XH+N);
    ll ans = 0;
    if(D == 0){
        rep(i, N){
            ans += H[i]/A;
            if(H[i] % A) ans++;
        }
        cout << ans << endl;
        return 0;
    }

    int dam[N];
    dam[0] = 0;
    int idx = 0;
    int pos = XH[0].first + 2*D;
    for(int i = 1; i < N; i++){
        while(XH[idx].first + 2*D < XH[i].first) idx++;
        dam[i] = idx;
    }


    ll S[N];
    if(XH[0].second % A == 0) S[0] = XH[0].second / A;
    else S[0] = XH[0].second / A + 1;
    ans = S[0];

    for(int i = 1; i < N; i++){
        ll Xi = XH[i].first;
        ll Hi = XH[i].second;

        //どれほどのダメージを食らったか
        if(dam[i] == 0) Hi -= S[i-1]*A;
        else Hi -= (S[i-1] - S[dam[i]-1])*A;

        if(Hi <= 0){
            S[i] = S[i-1];
            continue;
        }
        else{
            ll temp;
            if(Hi % A == 0) temp = Hi / A;
            else temp = Hi / A + 1;
            S[i] = S[i-1] + temp;
            ans += temp;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 8832
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<P,int> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-8;
const ll mod=1e9+7;
const int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};

int n;
vi a,b;

vvi f(){
	vvi A(n+1,vi(n+1));
	for(int i=0;i<n;i++) for(int j=n-1;j>=0;j--){
		A[i][j]+=A[i][j+1];
		if(b[j]<a[i]) A[i][j]++;
	}
	swap(a,b);
	return A;
}

int main(){
	cin>>n;
	a=b=vi(n);
	for(int i=0;i<2*n;i++){
		int t;
		char c;
		cin>>c>>t;
		t--;
		if(c=='W') a[t]=i;
		else b[t]=i;
	}
	vvi A=f(),B=f();
	vvi dp(n+1,vi(n+1,inf));
	dp[0][0]=0;
	for(int i=0;i<=n;i++) for(int j=0;j<=n;j++){
		if(i<n) dp[i+1][j]=min(dp[i+1][j],dp[i][j]+A[i][j]);
		if(j<n) dp[i][j+1]=min(dp[i][j+1],dp[i][j]+B[j][i]);
	}
	int res=dp[n][n];
	for(int i=0;i<n;i++) for(int j=0;j<i;j++) if(a[i]<a[j]) res++;
	for(int i=0;i<n;i++) for(int j=0;j<i;j++) if(b[i]<b[j]) res++;
	cout<<res<<endl;
}

Measured memory_bytes: 47360
#include<bits/stdc++.h>
using namespace std;
int main(){
  int k,n;
  cin>>k>>n;
  vector<int>a(n);
  for(int i=0;i<n;i++){
    cin>>a.at(i);
  }
    a.push_back(a.at(0)+k);
    int l=0;
    for(int i=0;i<n;i++){
      l=max(l,a.at(i+1)-a.at(i));
            }
  int ans=k-l;
  cout<<ans<<endl;
}

Measured memory_bytes: 4784
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<queue>
#define ll long long
#define write(a) printf("%d",a)
#define writeln printf("\n")
#define FOR(a,b,c) for (int a=b;a<=c;a++)
#define FORD(a,b,c) for (int a=b;a>=c;a--)
using namespace std;
inline ll read(){
    ll x=0,f=1;
    char c=getchar();
    while (c<'0'||c>'9'){
        if (c=='-')f=-1;
        c=getchar();
    }
    while (c>='0'&&c<='9'){
        x=x*10+c-'0';
        c=getchar();
    }
    return x*f;
}
int n,m;
struct node{
	int a,b;
}x[100020];
bool cmp(node a,node b){
	return a.b<b.b;
}
int bi[100020];
int main(){
	n=read();m=read();
	FOR(i,1,m)x[i].a=read(),x[i].b=read();
	sort(x+1,x+1+m,cmp);
	int k=0;
	FOR(i,1,m){
		bool r=1;
		if(k>0)if(bi[k]>=x[i].a&&bi[k]<x[i].b)r=0;
		if(r)k++,bi[k]=x[i].b-1;
	}
	write(k);writeln;
	return 0;
}


Measured memory_bytes: 1024
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <functional>
#include <cstdlib>
#include <sstream>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <complex>
#include <vector>
#include <cstdio>
#include <cmath>
#include <time.h>
#define all(c) ((c).begin(),(c).end())
#define rall(c) (c).rbegin(),(c).rend()
#define sort(v,n) sort(v,v+n)
#define vsort(v) sort(v.begin(),v.end())
#define vvsort(v) sort(v.begin(),v.end(),greater<int>())
#define ll long long
#define pb(a) push_back(a)
#define fi first
#define se second
#define inf 999999999
using namespace std;
const ll MOD = 1e9 + 7;
const double PI = acos(-1.0);
//---------------------------------------------------------------------------------------------//
int n, q;

int main() {
	while (cin >> n >> q) {
		if (n == 0)return 0;
		int m; int ok[110];
		for (int i = 0; i < 110; i++)ok[i] = 0;
		for (int i = 0; i < n; i++) {
			cin >> m; 
			for (int j = 0; j < m; j++) {
				int d; cin >> d;
				ok[d]++;
			}
		}
		int ans = 0;
		int nowpeople=0;
		for (int i = 0; i < 110; i++) {
			if (ok[i] >= q && nowpeople<ok[i]) {
				nowpeople = ok[i];
				ans = i;
			}
		}
		cout << ans << endl;
	}
}

Measured memory_bytes: 3096
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(ll i=0;i<ll(n);i++)
int main() {
    int n;
    cin >> n;
    int a;
    ll ans = 0;
    int m = 2e9;
    int cnt = 0;
    rep(i, n){
        cin >> a;
        if (a < 0) {
            cnt++;
            a *= -1;
        }
        m = min(m, a);
        ans += a;
    }
    if (cnt%2 == 1) {
        ans -= 2*m;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3628
#include<stdio.h>
int f[1005]={0};
int d[1005]={0};
int main(){
	int n,k;
	scanf("%d%d",&n,&k);
	for(int i=1;i<=k;i++){
		scanf("%d",&d[i]);
		for(int j=1;j<=d[i];j++){
			int x;
			scanf("%d",&x);
			f[x]=1;
		}
	}
	int ans=0;
	for(int i=1;i<=n;i++) if(!f[i]) ans++;
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 1732
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <functional>

#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define repi(i,a,b) for(int i = (a); i < (b); i++)

using namespace std;

typedef    long long          ll;
typedef    unsigned long long ull;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      pii;

const int INF=1<<29;
const double EPS=1e-9;

const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};
int dp[20010][300];//
int C[20];
int X[20010];
int n,m;


int main(){
	while(cin>>n>>m,n||m){
		memset(dp, 0, sizeof(dp));
		memset(C, 0, sizeof(C));
		memset(X, 0, sizeof(X));
		for(int i =0;i < m;i++){
			cin>>C[i];
			//cout<<C[i]<<endl;
		}
		for(int i =0;i < n;i++){
			cin>>X[i];
			//cout <<X[i]<<endl;
		}
		memset(dp, INF, sizeof(dp));
		rep(i, n+1)rep(j,256)dp[i][j] =INF;
		dp[0][128] = 0;
		for(int i =0;i < n;i++){
			for(int j =0;j < m;j++){
				for(int k =0;k <=255;k++){
					if(dp[i][k]==INF)continue;
					int val =k +C[j];
					if(val >255)val =255;
					if(val <0)val = 0;
					dp[i+1][val] =min(dp[i+1][val],dp[i][k]+(X[i]-val)*(X[i]-val));
					//cout <<(X[i]-val)*(X[i]-val)<<endl;
				}
			}
		}
		int ans = INF;
		for(int i =0;i <=255;i++){
			ans =min(ans,dp[n][i]);
		}
		cout <<ans<<endl;
	}
	return 0;
}

Measured memory_bytes: 24696
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main()
{
	int n;
	vector<int> v;
	cin >> n;
	for (int i = 0; i < n; i++) {
		int x;
		cin >> x;
		v.push_back(x);
	}
	reverse(v.begin(), v.end());
	for (int i = 0; i < v.size() - 1; i++)
		cout << v[i] << " ";
	cout << v[v.size() - 1] << endl;
    return 0;
}

Measured memory_bytes: 1216
import java.util.Scanner;

public class Main{
 public static void main(String[] args){
  Scanner scanner=new Scanner(System.in);
  int n=scanner.nextInt();
  int k=scanner.nextInt();
  int total=0;
  for(int i=0;i<n;i++){
   int x=scanner.nextInt();
   total+=2*Math.min(x,k-x);
  }
  scanner.close();
  System.out.println(total);
 }
}


Measured memory_bytes: 23632
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const ll MOD=(ll)1e9+7;

int main(){
    int N,C; cin>>N>>C;
    vector<vector<bool>> used(C,vector<bool>(200011,false));
    for (int i = 0; i < N; ++i) {
        int s,t,c;
        cin>>s>>t>>c;
        s=s*2-1; t*=2; c--;
        for(;s<=t;s++){
            used[c][s]=true;
        }
    }

    int ans=0;
    for (int i = 0; i < 200005; ++i) {
        int cnt=0;
        for (int j = 0; j < C; ++j) {
            if(used[j][i]) cnt++;
        }
        ans=max(ans,cnt);
    }

    cout<<ans<<endl;

    return 0;
}



Measured memory_bytes: 1024
package main

import (
	"fmt"
)

var n int
var nums []int

func main() {
	fmt.Scan(&n)

	odd_map := make(map[int]int, n/2)
	even_map := make(map[int]int, n/2)

	for i := 1; i <= n; i++ {
		var v int
		fmt.Scan(&v)
		if i%2 != 0 {
			odd_map[v]++
		} else {
			even_map[v]++
		}
		nums = append(nums, v)
	}

	var odd int
	var even int
	var odd_max int
	var even_max int
	for k, v := range odd_map {
		if v > odd_max {
			odd = k
			odd_max = v
		}
	}
	for k, v := range even_map {
		if v > even_max {
			even = k
			even_max = v
		}
	}
	if odd == even {
		if odd_max == even_max {
			var first, second int
			first = odd_max
			odd_max = 0
			odd_map[odd] = 0
			for _, v := range odd_map {
				if v > odd_max {
					odd_max = v
				}
			}
			even_max = 0
			even_map[even] = 0
			for _, v := range even_map {
				if v > even_max {
					even_max = v
				}
			}
			if even_max >= odd_max {
				second = even_max
			} else if odd_max > even_max {
				second = odd_max
			}
			odd_max, even_max = first, second
		} else if even_max > odd_max {
			odd_max = 0
			odd_map[odd] = 0
			for _, v := range odd_map {
				if v > odd_max {
					odd_max = v
				}
			}
		} else {
			even_max = 0
			even_map[even] = 0
			for _, v := range even_map {
				if v > even_max {
					even_max = v
				}
			}
		}
	}

	fmt.Println(n - (odd_max + even_max))
}


Measured memory_bytes: 7936
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

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

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

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

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

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

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

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

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

#[allow(unused_imports)]
use std::cmp::{min, max};

#[allow(unused_imports)]
use std::io::Write;

fn dfs(edges: &Vec<Vec<usize>>, cur: usize, par: usize, ans: &mut Vec<usize>, cs: &Vec<usize>, idx: &mut usize) {
    ans[cur] = cs[*idx];
    for &next in edges[cur].iter() {
        if next != par {
            *idx += 1;
            dfs(edges, next, cur, ans, cs, idx);
        }
    }
}

fn main() {
    input!{
      n: usize,
      abs: [(usize,usize); n-1],
      mut cs: [usize; n]
    }
    let mut edges = vec![vec![]; n];
    for (a, b) in abs {
        edges[a-1].push(b-1);
        edges[b-1].push(a-1);
    }
    cs.sort();
    let mut sum = &cs[0..n-1].iter().sum::<usize>();
    debug!(cs);
    println!("{}", sum);
    cs.reverse();
    let mut ans = vec![0; n];
    dfs(&edges, 0, n, &mut ans, &cs, &mut 0);
    for a in ans {
        print!("{} ", a);
    }
    println!();
}


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

int sum[2][2003][2003];
int cal(int i,int x1,int x2,int y1,int y2) {
	return sum[i][x2][y2] - sum[i][x1][y2] - sum[i][x2][y1] + sum[i][x1][y1];
}
int main()
{
	int n,k;
	scanf("%d%d",&n,&k);
	for(int i = 0;i < n;++i) {
		char c;
		int x,y;
		scanf("%d%d %c",&x,&y,&c);
		x %= 2 * k,y %= 2 * k;
		if(c == 'B')
			++sum[0][x+1][y+1];
		else
			++sum[1][x+1][y+1];
	}
	for(int i = 1;i <= 2 * k;++i) {
		for(int j = 2;j <= 2 * k;++j) {
			sum[0][i][j] += sum[0][i][j-1];
			sum[1][i][j] += sum[1][i][j-1];
		}
	}
	for(int i = 2;i <= 2 * k;++i) {
		for(int j = 1;j <= 2 * k;++j) {
			sum[0][i][j] += sum[0][i-1][j];
			sum[1][i][j] += sum[1][i-1][j];
		}
	}
	int mx = 0;
	for(int i = 0;i < k;++i) {
		for(int j = 0;j < k;++j) {
			// 0 i i+k 2k
			// 0 j j+k 2k
			int ans = cal(0,0,i,0,j) + cal(1,0,i,j,j+k) + cal(0,0,i,j+k,2*k) + cal(1,i,i+k,0,j) + cal(0,i,i+k,j,j+k) + cal(1,i,i+k,j+k,2*k) + cal(0,i+k,2*k,0,j) + cal(1,i+k,2*k,j,j+k) + cal(0,i+k,2*k,j+k,2*k);
			if(ans > mx) mx = ans;
			ans = cal(1,0,i,0,j) + cal(0,0,i,j,j+k) + cal(1,0,i,j+k,2*k) + cal(0,i,i+k,0,j) + cal(1,i,i+k,j,j+k) + cal(0,i,i+k,j+k,2*k) + cal(1,i+k,2*k,0,j) + cal(0,i+k,2*k,j,j+k) + cal(1,i+k,2*k,j+k,2*k);
			if(ans > mx) mx = ans;
		}
	}
	printf("%d\n",mx);
}

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

// Function Macros:
#define rep(i, n) for(int(i) = 0; (i) < (n); (i)++)
#define all(v) (v).begin(), (v).end()
#define setpre(n) cout << fixed << setprecision(n)

// Type / Class / Struct Definitions:
using namespace std;

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

// Constants:
const int INF = (1ll << 30) - 1;  // approx 1.07e9
const ll INFLL = 1ll << 60;       // approx 1.15e18
const int MOD = 1e9 + 7;          // 998244353
const long double EPS = 1.0e-14;

// Global Variables:

// Prototype Declarations:
int gcd(int, int);
template <class T>
inline bool chmin(T&, T);
template <class T>
inline bool chmax(T&, T);

// ================ Main Loop ================
int main() {
    int n, m;
    cin >> n >> m;

    vector<set<int>> path(n);
    vector<int> ans(n, -1);
    ans[0] = 0;
    int a, b;
    rep(i, m) {
        cin >> a >> b;
        a--;
        b--;
        path[a].insert(b);
        path[b].insert(a);
    }

    queue<int> bfs;
    bfs.push(0);
    int u;
    while(!bfs.empty()) {
        u = bfs.front();
        bfs.pop();

        for(auto v : path[u]) {
            if(ans[v] == -1) {
                ans[v] = u;
                bfs.push(v);
            }
        }
    }

    rep(i, n) {
        if(ans[i] == -1) {
            cout << "No" << endl;
            return 0;
        }
    }

    cout << "Yes" << endl;
    for(int i = 1; i < n; i++) {
        cout << ans[i] + 1 << endl;
    }
    return 0;
}
// ===========================================

// Functions:
int gcd(int a, int b) {
    return b ? gcd(b, a % b) : a;
}

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


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

typedef long long ll;

ll N;
vector<ll> S;
ll R;

int main() {
  cin >> N;
  S.resize(N);
  for (ll i = 0; i < N; ++i) cin >> S[i];
  for (ll k = 1; k <= N - 1; ++k) {
    ll sum = 0;
    for (ll l = 0, r = N - 1; k < r && (l < r || (l - r) % k != 0);
         l += k, r -= k) {
      sum += S[l] + S[r];
      R = max(R, sum);
    }
  }
  cout << R << endl;
  return 0;
}


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

#define rep(i, n) for(int i = 0; i<(n); i++)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef long long ll;

int main() {
    int N;
    string S;
    cin >> N >> S;
    int ans = 0;
    rep(i, N - 2) {
        if (S[i] == 'A' && S[i + 1] == 'B' && S[i + 2] == 'C') ans++;
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cstdio>
 
 
using namespace std;
 
class Rooted_Tree
{
 
public:
    int id;
    int parent;
    int depth;
    string type;
    int degree;
    vector<int> c;
 
    Rooted_Tree()
    {
        id = parent = depth = degree = -1;
        type = "non";
    }
 
};
 
void fill_depth(vector<Rooted_Tree> &rt, int id, int depth){
    int i;
 
    rt[id].depth=depth;
    for(i=0;i<rt[id].degree;i++) fill_depth(rt, rt[id].c[i], depth+1);
 
}
 
bool asc(const Rooted_Tree &right, const Rooted_Tree &left){ return right.id < left.id;}
 
int main() {
    int i,j,i_buf;
    int n;
    vector<Rooted_Tree> rt;
    cin >> n;
    for(i=0; i<n; i++){
        Rooted_Tree buf;
        cin >> buf.id;
        cin >> buf.degree;
        for(j=0;j<buf.degree;j++){
            cin >> i_buf;
            buf.c.push_back(i_buf);
        }
        rt.push_back(buf);
    }
 
    sort(rt.begin(), rt.end(), asc);
     

    for(i=0; i<n; i++){
        for(j=0; j<rt[i].degree; j++)
            rt[ rt[i].c[j] ].parent=rt[i].id;
    }

    for(i=0; i<n; i++){
        if(rt[i].parent==-1){
            rt[i].type = "root";
            fill_depth(rt, i, 0);
        }
        else{
            if(rt[i].degree!=0) rt[i].type = "internal node";
            else rt[i].type = "leaf";
        }
    }

    for(i=0; i<n; i++){
        printf("node %d: parent = %d, depth = %d, %s, ", rt[i].id, rt[i].parent, rt[i].depth, rt[i].type.c_str());
        printf("[");
        for(j=0;j<rt[i].degree;j++){
            printf("%d", rt[i].c[j]);
            if(j!=rt[i].degree-1) printf(", ");
        }
        printf("]\n");
    }
     
     
    return 0;
}

Measured memory_bytes: 17244
#include<stdio.h>
#include<algorithm>
using namespace std;
int a[3];
int main(){
    while(~scanf("%d%d%d",&a[0],&a[1],&a[2])){
        sort(a,a+3);
        if(a[1]-a[0]==a[2]-a[1]){
            printf("YES\n");
        }
        else
            printf("NO");
    }
    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <iomanip>
#include <cmath>
#include <vector>
#include <string>
#include <limits>
#include <utility>
#include <algorithm>
#include <tuple>
#include <limits>

bool iterate(std::vector<int> &a)
{
    const int n = a.size();
    bool converged = true;
    std::vector<int> b(n, 0);
    std::vector<int> up(n, 0);
    std::vector<int> down(n, 0);

    for (int i = 0; i < n; i++) {
        const int i_up = (i - a[i] < 0)?(0):(i - a[i]);
        const int i_down = (i + a[i] >= n)?(n - 1):(i + a[i]);

        up[i_up]++;
        down[i_down]++;
    }

    int count = 0;
    for (int i = 0; i < n; i++) {
        count += up[i];
        b[i] = count;
        count -= down[i];
    }

    a.swap(b);

    for (int i = 0; i < n; i++) {
        if (a[i] != b[i]) {
            converged = false;
        }
    }

    return converged;
}

int main(int argc, char *argv[])
{
    int n, k;
    std::vector<int> a;

    std::cin >> n >> k;

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

    for (int i = 0; i < k; i++) {
        bool converged = iterate(a);
        if (converged) {break;}
    }

    for (int i = 0; i < n; i++) {
        std::cout << a[i] << " ";
    }
    std::cout << std::endl;

    return 0;
}


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

#define endl '\n'
#define lfs cout<<fixed<<setprecision(10)
#define ALL(a)  (a).begin(),(a).end()
#define ALLR(a)  (a).rbegin(),(a).rend()
#define spa << " " <<
#define test cout<<"test"<<endl;
#define fi first
#define se second
#define MP make_pair
#define MT make_tuple
#define PB push_back
#define EB emplace_back
#define rep(i,n,m) for(ll i = (n); i < (ll)(m); i++)
#define rrep(i,n,m) for(ll i = (m) - 1; i >= (ll)(n); i--)
using ll = long long;
using ld = long double;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const ll INF = 1e18;
using P = pair<ll, ll>;
template<typename T>
void chmin(T &a,T b){if(a>b)a=b;}
template<typename T>
void chmax(T &a,T b){if(a<b)a=b;}
void pmod(ll &a,ll b){a=(a+b)%MOD;}
void pmod(ll &a,ll b,ll c){a=(b+c)%MOD;}
void qmod(ll &a,ll b){a=(a*b)%MOD;}
void qmod(ll &a,ll b,ll c){a=(b*c)%MOD;}
ll median(ll a,ll b, ll c){return a+b+c-max({a,b,c})-min({a,b,c});}
void ans1(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void ans2(bool x){if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
void ans3(bool x){if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
template<typename T1,typename T2>
void ans(bool x,T1 y,T2 z){if(x)cout<<y<<endl;else cout<<z<<endl;}  
template<typename T>
void debug(vector<vector<T>>&v,ll h,ll w){for(ll i=0;i<h;i++)
{cout<<v[i][0];for(ll j=1;j<w;j++)cout spa v[i][j];cout<<endl;}};
void debug(vector<string>&v,ll h,ll w){for(ll i=0;i<h;i++)
{for(ll j=0;j<w;j++)cout<<v[i][j];cout<<endl;}};
template<typename T>
void debug(vector<T>&v,ll n){if(n!=0)cout<<v[0];
for(ll i=1;i<n;i++)cout spa v[i];cout<<endl;};
template<typename T>
vector<vector<T>>vec(ll x, ll y, T w){
  vector<vector<T>>v(x,vector<T>(y,w));return v;}
ll gcd(ll x,ll y){ll r;while(y!=0&&(r=x%y)!=0){x=y;y=r;}return y==0?x:y;}
vector<ll>dx={1,0,-1,0,1,1,-1,-1};
vector<ll>dy={0,1,0,-1,1,-1,1,-1};
template<typename T>
vector<T> make_v(size_t a,T b){return vector<T>(a,b);}
template<typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v(ts...))>(a,make_v(ts...));
}
ostream &operator<<(ostream &os, pair<ll, ll>&p){
  return os << p.first << " " << p.second;
}  
int main(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  ll res=0,buf=0;
  bool judge = true;
  ll n,m;cin>>n>>m;
  vector<ll>a(n);
  rep(i,0,n)cin>>a[i];
  rep(i,0,n){
    if(a[i]&1)judge=false;
    else a[i]/=2;
  }
  ll lcm=1;
  rep(i,0,n){
    lcm=a[i]/gcd(a[i],lcm)*lcm;
    if(lcm>m)break;
  }
  rep(i,0,n){
    if((lcm/a[i])%2==0)judge=false;
  }
  ans(judge,(m+lcm)/(lcm*2),0);
  return 0;
}

Measured memory_bytes: 1024
var input = require("fs").readFileSync("/dev/stdin", "utf8");
	var heigths = input.trim().split("\n");
var n = heigths.sort(compareNumbers);

for (i=0; i!=3; i++) {
	console.log (n[i]);
}

function compareNumbers(a, b) {
	return b - a;
}

Measured memory_bytes: 15480
#include <bits/stdc++.h>
#define ADD(a, b) a = (a + ll(b)) % mod
#define MUL(a, b) a = (a * ll(b)) % mod
#define MAX(a, b) a = max(a, b)
#define MIN(a, b) a = min(a, b)
#define rep(i, a, b) for(int i = int(a); i < int(b); i++)
#define rer(i, a, b) for(int i = int(a) - 1; i >= int(b); i--)
#define all(a) (a).begin(), (a).end()
#define sz(v) (int)(v).size()
#define pb push_back
#define sec second
#define fst first
#define debug(fmt, ...) Debug(__LINE__, ":", fmt, ##__VA_ARGS__)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<int, pi> ppi;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> mat;
typedef complex<double> comp;
void Debug() {cerr << '\n'; }
template<class FIRST, class... REST>void Debug(FIRST arg, REST... rest){
	cerr<<arg<<" ";Debug(rest...);}
template<class T>ostream& operator<<(ostream& out,const vector<T>& v) {
	out<<"[";if(!v.empty()){rep(i,0,sz(v)-1)out<<v[i]<<", ";out<<v.back();}out<<"]";return out;}
template<class S, class T>ostream& operator<<(ostream& out,const pair<S, T>& v){
	out<<"("<<v.first<<", "<<v.second<<")";return out;}
const int MAX_N = 500010;
const int MAX_V = 100010;
const double eps = 1e-6;
const ll mod = 1000000007;
const int inf = 1 << 30;
const ll linf = 1LL << 60;
const double PI = 3.14159265358979323846;
mt19937 rng; //use it by rng() % mod, shuffle(all(vec), rng)
///////////////////////////////////////////////////////////////////////////////////////////////////


void solve() {
	int n, d; cin >> n >> d;
	d = d * 2 + 1;
	cout << (n + d - 1) / d << "\n";
}

uint32_t rd() {
	uint32_t res;
#ifdef __MINGW32__
	asm volatile("rdrand %0" :"=a"(res) ::"cc");
#else
	res = std::random_device()();
#endif
	return res;
}

int main() {
#ifndef LOCAL
	ios::sync_with_stdio(false);
    cin.tie(0);
#endif
    cout << fixed;
	cout.precision(20);
    cerr << fixed;
	cerr.precision(6);
	rng.seed(rd());
#ifdef LOCAL
	//freopen("in.txt", "wt", stdout); //for tester
	if(!freopen("in.txt", "rt", stdin)) return 1;
#endif	
	solve();
    cerr << "Time: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
	return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<bits/stdc++.h>
#include<math.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); i++)
#define rep1(i,n) for(int i = 1; i < (n); i++)

int main(){
    int n;
    string s;
    cin >> n >> s;
    int ans = n;
    rep1(i,n) if(s[i] == s[i-1]) ans--;
    cout << ans << endl;
}

Measured memory_bytes: 3732
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>

using namespace std;

int main()
{
	long long int a, b, x;
	scanf("%lld %lld %lld", &a, &b, &x);
	if(a == 0)
	printf("%lld\n", (b / x) - (a / x) + 1);
	else
	printf("%lld\n", (b / x) - ((a - 1) / x));
	}

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

int main(){
    int N;
    string S;
    cin >> N >> S;
    int x=0,max=0;
    for(int i = 0; i < N; i++){
        if(S[i] == 'I'){
            x += 1;
        }else{
            x -= 1;
        }
        if(max < x){
            max = x;
        }
    }
    cout << max << endl;
}

Measured memory_bytes: 256
#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, a, b) for(int i=(b)-1; i>=(a); --i)
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long LL;
typedef vector<int> VI;
typedef vector<LL> VLL;
typedef vector<vector<int> > VVI;
typedef vector<string> VS;
const LL MOD=1000000007ll;
const LL INF=2000000000ll;

long power(long a,long b){return b?power(a*a%MOD,b/2)*(b%2?a:1)%MOD:1;}
long comb(int N,int K)
{
    long x=1,y=1;
    for(int i=1;i<=K;i++)
    {
        x=x*(N-i+1)%MOD;
        y=y*i%MOD;
    }
    return x*power(y,MOD-2)%MOD;
}

long hcomb(int N, int K){
    return comb(N+K-1, N-1);
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(10);

    int N, M, chk = 1;
    
    cin >> N >> M;
    VI s(M), c(M);
    
    REP(i,M) {
        cin >> s[i] >> c[i];
    }

    int ans = -1;
    if (N == 1){
        for(int i = 0; i < 10; i++){
            chk = 1;
            VI num(N);
            num[0] = i;
            REP(j,M){
                if (num[s[j]-1] != c[j]) chk = 0;
            }
            if (chk) {
                ans = i;
                break;
            }
        }
    }
    else if (N == 2){
        for(int i = 10; i < 100; i++){
            chk = 1;
            VI num(N);
            num[0] = i/10;
            num[1] = i%10;
 
            REP(j,M){
                if (num[s[j]-1] != c[j]) chk = 0;
            }
            if (chk) {
                ans = i;
                break;
            }
        }
    }
    else if (N == 3){
        for(int i = 100; i < 1000; i++){
            chk = 1;
            VI num(N);
                num[0] = i/100;
                num[1] = (i%100)/10;
                num[2] = i%10;

            REP(j,M){
                if (num[s[j]-1] != c[j]) chk = 0;
            }
            if (chk) {
                ans = i;
                break;
            }
        }
    }

    cout << ans << endl;
    


}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;
using namespace std;
const int MOD = 1000000007;
const int INF = 1010000000;
const double EPS = 1e-10;

int h,w,x;
char s[1000][1000];
bool visited [1000][1000];
pair<int,int> start,goal;
queue<pair<int,pair<int,int>>> q;
vector<pair<int,int>> ino;

int main(){
  int a,b,c;cin>>a>>b>>c;
  /*if(a==b){
    cout << "H";
  }else{
    cout << "D";
  }*/
  cout << (a*800)-(a/15)*200;
}


Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var h, w, n int
	fmt.Scan(&h, &w, &n)

	var m int
	if h > w {
		m = h
	} else {
		m = w
	}

	var ans int
	for n > 0 {
		n -= m
		ans++
	}
	fmt.Println(ans)

}


Measured memory_bytes: 512
#include <stdio.h>

int main()
{
	int N;
	scanf("%d",&N);
	int p[N];
	for (int i = 0; i < N; ++i)
	{
		scanf("%d",&p[i]);
	}
	for (int i = 1; i < N; ++i)
	{
		if(p[i-1] > p[i]){
			int tmp = p[i];
			p[i] = p[i-1];
			p[i-1] = tmp;
		}
	}
	int total=0;
	for (int i = 0; i < N; ++i)
	{
		if(i==N-1){
			p[i] = p[i]/2;
		}
		total += p[i];
	}
	printf("%d",total);
	return 0;	
}


Measured memory_bytes: 128
#include<iostream>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<vector>
#include<string.h>
#include<math.h>
#include<stdio.h>
#include<queue>
#include<utility>
#include<cstdio>
#include<cstring>
#include<new>
#include<float.h>
#include<ctype.h>
#include<cfloat>
#include<cmath>
#include<cctype>
#include<errno.h>
#include<cerrno>
#include<memory>
#include<memory.h>
#include<assert.h>
#include<cassert>
#include<deque>
#include<sstream>
#define fo(i,w,n) for(int i=(int) w;i<(int) n;i++)
#define qui queue<int>
#define vit vector<int>
#define ll long long
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define prq priority_queue
#define pii pair<int,int>
#define mp make_pair
#define sz size()
#define em empty()
#define ct continue
#define ms multiset
#define all(a) (a).begin(),(a).end()
#define pf push_front
#define ppf pop_front()
using namespace std;
char ans[202020];
int main()
{
	int n;
	cin>>n;
	string s,d="WS";
	cin>>s;
	fo(j,0,2) fo(k,0,2){
		ans[0]=d[j];
		ans[1]=d[k];
		fo(i,1,n-1){
		    if((s[i]=='o'&&ans[i]=='S')||(s[i]=='x'&&ans[i]=='W'))ans[i+1]=ans[i-1];
		    else ans[i+1]=(ans[i-1]=='W'?'S':'W');
	    }
	    if(((ans[n-2]!=ans[0]&&!((s[n-1]=='o'&&ans[n-1]=='S')||(s[n-1]=='x'&&ans[n-1]=='W')))||
		(ans[n-2]==ans[0]&&((s[n-1]=='o'&&ans[n-1]=='S')||(s[n-1]=='x'&&ans[n-1]=='W'))))&&
	    ((ans[n-1]!=ans[1]&&!((s[0]=='o'&&ans[0]=='S')||(s[0]=='x'&&ans[0]=='W')))||
		(ans[n-1]==ans[1]&&((s[0]=='o'&&ans[0]=='S')||(s[0]=='x'&&ans[0]=='W'))))){
	    	cout<<ans<<endl;
	    	return 0;
		}
	}
	cout<<"-1"<<endl;
	return 0;
}


Measured memory_bytes: 640
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def SI(): return sys.stdin.readline()[:-1]

n=II()
aa=LI()
aa.sort(reverse=True)
i=1
ans=aa[0]
n-=2
while n:
    ans+=aa[i]
    n-=1
    if n==0:break
    ans+=aa[i]
    n-=1
    i+=1
print(ans)


Measured memory_bytes: 31140
#include <bits/stdc++.h>
using namespace std;
signed main () {
    
    int n;
    int a[300000];
    vector < int > vit;
    cin >> n ;
    for(int i = 0; i < n; i++ ) {
        cin >> a[i];
        vit.push_back(a[i]);
    }
    sort(vit.begin(),vit.end(),greater<int>());
    
    for(int i = 0; i < n; i++) {
        cout << (a[i]-vit[0]?vit[0]:vit[1]) << endl;
    }
        

    return 0;
}


Measured memory_bytes: 3316
n = int(input())
num = [int(x) for x in input().split()]

test = []

for i in num:
    if i % 2 != 0:
        test.append(True)
    elif i % 2 == 0 and i % 3 == 0:
        test.append(True)
    elif i % 2 == 0 and i % 5 == 0:
        test.append(True)
    else:
        test.append(False)

if all(test):
    print("APPROVED")
else:
    print("DENIED")

Measured memory_bytes: 3060
n=int(input())
a=list(map(int,input().split()))
def gcd(a,b):
    return gcd(b,a%b) if b else a
def lcm(a,b):
    return a*b//gcd(a,b)
k=1
for i in a:
    k=lcm(k,i)
ans=0
for i in a:
    ans+=k//i
ans%=10**9+7
print(ans)


Measured memory_bytes: 4084
open Scanf ;;
open Printf ;;

let read_int () = scanf " %d" (fun x -> x) ;;

let rec powi a b = if b = 0 then 1 else a * powi a (b - 1);;

let rec read_ints n = 
  let a = Array.make n 0 in
  for i = 0 to n - 1 do
    a.(i) <- read_int ()
  done;
  a
  ;;

let () =
  let n = read_int () in
  let k = read_int () in
  let a = read_ints n in
  let f = read_ints n in
  Array.sort (fun x y -> compare x y) a;
  Array.sort (fun x y -> compare y x) f;
  let rec search l r =
    if r - l = 1 then r
    else begin
      let m = (l + r) / 2 in
      let sum = ref 0 in
      for i = 0 to n - 1 do
        let v = max 0 (a.(i) - m / f.(i)) in
        sum := !sum + v
      done;
      if !sum <= k
        then search l m
        else search m r
    end
  in
  let ans = search (-1) (powi 10 12) in
  printf "%d\n" ans
  ;;



Measured memory_bytes: 7936
#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 count = 0;
	for(int i = 0; i < n-2; i++){
		int prev = p.at(i), next = p.at(i+1), nexnex = p.at(i+2);
		if((prev<=next && next<nexnex)||(nexnex<=next && next<prev))
			count++;
	}
	cout << count << endl;
}


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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define ALL(a)     (a).begin(),(a).end()
#define VI         vector<int>
#define MOD 1000000007

using ll = long long int;
using P = pair<int,int>;

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

const ll INF=(ll)1e19;
//const int INF=(1<<30);

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

  set<int> st;
  REP(i,k){
    int d;
    cin >> d;
    REP(j,d){
      int a;
      cin >> a;
      st.insert(a);
    }
  }

  cout << n - st.size() << endl;
}



Measured memory_bytes: 3636
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;

int main(){
  string card;
  while(1){
    cin >> card ;
    if(card == "-")
      break;

    int m;
    cin >> m;

    int h;
    string num;
    for(int i=0;i<m;i++){
      cin >> h;
      num = card.substr(0,h);
      card.erase(0,h);
      card += num;
    }

    cout << card << endl;
  }

  return 0;
}



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

int h, n;

//#include "prob363_presum.h"
int main() {
//    cum_sum_363b();
    cin >> h  >> n;
    for (int i = 0; i < n; ++i) {
        int ith ;
        cin >> ith;
        h-=ith;
    }
    if(h > 0)
        cout << "No";
    else
        cout << "Yes";
    return 0;
}

Measured memory_bytes: 256
import java.io.IOException;
import java.io.InputStream;
import java.util.*;
import java.lang.Math;

public class Main {
    public static void main(String[] args) {
        FS reader = new FS();
        // write reader
        int    N   = reader.nextInt();
        String S   = reader.next();
        int    tmp = 0;

        for (int i=0; i<N; i++) {
            if (S.charAt(i) == '.') tmp++;
        }

        int    ans = tmp;

        for (int i=0; i<N; i++) {
            if (S.charAt(i) == '.') tmp--;
            else tmp++;
            ans = Math.min(ans, tmp);
        }

        System.out.println(ans);
    }
    
    public static void solver() {
        // write logic
    }
    
    // Read Class
    static class FS {
        private final InputStream in = System.in;
        private final byte[] buffer = new byte[1024];
        private int ptr = 0;
        private int buflen = 0;
        private boolean hasNextByte() {
            if (ptr < buflen) {
                return true;
            } else {
                ptr = 0;
                try {
                    buflen = in.read(buffer);
                } catch (IOException e) {
                    e.printStackTrace();
                }
                if (buflen <= 0) {
                    return false;
                }
            }
            return true;
        }
    
        private int readByte() { return hasNextByte() ? buffer[ptr++] : -1;}
        private boolean isPrintableChar(int c) {return 33 <= c && c <= 126;}
        private void skipUnprintable() {while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;}
    
        public boolean hasNext() { skipUnprintable(); return hasNextByte();}
        public String next() {
            if (!hasNext()) throw new NoSuchElementException();
            StringBuilder sb = new StringBuilder();
            int b = readByte();
            while(isPrintableChar(b)) {
                sb.appendCodePoint(b);
                b = readByte();
            }
            return sb.toString();
        }
        public int nextInt() {
            return (int)nextLong();
        }
        public long nextLong() {
            if (!hasNext()) throw new NoSuchElementException();
            long n = 0;
            boolean minus = false;
            int b = readByte();
            if (b == '-') {
                minus = true;
                b = readByte();
            }
            if (b < '0' || '9' < b) {
                throw new NumberFormatException();
            }
            while(true) {
                if ('0' <= b && b <= '9') {
                    n *= 10;
                    n += b - '0';
                } else if(b == -1 || !isPrintableChar(b)) {
                    return minus ? -n : n;
                } else {
                    throw new NumberFormatException();
                }
                b = readByte();
            }
        }
    }
}



Measured memory_bytes: 25172
#include<stdio.h>
#include<algorithm>
#include<iostream>
#include<string.h>
using namespace std;
int n,k;
int a[15],b[15];
int main(){
    while(~scanf("%d%d",&n,&k)){
            int x;
            for(int i=0;i<10;i++)
                a[i]=0;
            for(int i=0;i<k;i++){
                scanf("%d",&x);
                a[x]=1;
            }
            while(n){
                    int vis=1,p=n;
                while(p){
                    if(a[p%10]){
                        vis=0;
                        break;
                    }
                    p/=10;
                }
                if(vis){
                    printf("%d\n",n);
                    break;
                }
                n++;
            }
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int
#define REP(i,a,b)	for(i=a;i<=b;i++)
#define REPr(i,b,a)	for(i=b;i>=b;i--)
#define umap(x,y) unordered_map(int,int)
#define pb push_back
using namespace std;

void solve(){
    int n,i,j,k;  cin>>n;
    int ans[n+1]={0};
    int p=sqrt(n);
    int x;
    REP(i,1,p){
        REP(j,1,p){
            REP(k,1,p){
                x=(i*i+j*j+k*k)+(i*j)+(i*k)+(j*k);
                if(x<=n)    ans[x]++;
            }
        }
    }

    REP(i,1,n)  cout<<ans[i]<<endl;
}

int main(){
    int t;  t=1;;
    while(t--){
        solve();
    }
}

Measured memory_bytes: 3444
#include <bits/stdc++.h>
#define REP(i,a,b) for(int i=(a);i<(b);i++)
#define RREP(i,a,b) for(int i=(a);i>=(b);i--)
#define pq priotity_queue
#define P pair<int,int>
#define P2 pair<int,P>
#define P3 pair<int,P2>
typedef long long ll; typedef long double ld;
using namespace std;
const int INF=1e9, MOD=1e9+7, around[]={0,1,1,-1,-1,0,-1,1,0,0};
const ld PI=abs(acos(-1));
int a, b,c;

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


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

def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

def main():
    mod=10**9+7
    N,M=MI()
    adj=[[]for _ in range(N)]
    
    for i in range(M):
        a,b=MI()
        a-=1
        b-=1
        adj[a].append(b)
        adj[b].append(a)
        
    import queue
    q=queue.Queue()
    q.put((0,-1))
    ans=[-1]*N
    
    while not q.empty():
        v,p=q.get()
        for nv in adj[v]:
            if nv!=p:
                if ans[nv]==-1:
                    q.put((nv,v))
                    ans[nv]=v
                    
    print("Yes")
    for i in range(1,N):
        print(ans[i]+1)
                

main()


Measured memory_bytes: 96532
N=int(input())
s=[int(input()) for _ in range(N)]
def cal(S,items):
    if(S%10!=0):
        return S
    temp=100000000
    for i in items:
        if(i%10!=0):
            temp=min(i,temp)
    return S-temp if(S-temp>0) else 0
print(cal(sum(s),s))

Measured memory_bytes: 3060
#include <cassert>
#include <cstdio>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <numeric>
#include <algorithm>

using namespace std;
using lint = long long;
constexpr int MOD = 1000000007, INF = 1010101010;
constexpr lint LINF = 1LL << 60;

template <class T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
	for (const auto &e : vec) os << e << (&e == &vec.back() ? "" : " ");
	return os;
}

#ifdef _DEBUG
template <class T>
void dump(const char* str, T &&h) { cerr << str << " = " << h << "\n"; };
template <class Head, class... Tail>
void dump(const char* str, Head &&h, Tail &&... t) {
	while (*str != ',') cerr << *str++; cerr << " = " << h << "\n";
}
#define DMP(...) dump(#__VA_ARGS__, __VA_ARGS__)
#else 
#define DMP(...) ((void)0)
#endif

template <class T>
ostream &operator<<(ostream &os, const set<T> &st) {
	for (const auto &e : st) os << e << " ";
	return os;
}

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

template <class T1, class T2>
ostream &operator<<(ostream &os, const map<T1, T2> &mp) {
	for (const auto &e : mp) os << e << " ";
	return os;
}

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	int N;
	cin >> N;
	vector<int> A(N);
	for (int i = 0; i < N; i++) cin >> A[i];

	vector<int> ans, used(N);
	int loop = 0;
	while(loop < N){

		int ok = -1, cnt = 1;
		for (int j = 0; j < N; j++) {
			if (!used[j]) {
				if (A[j] == cnt) ok = j;
				cnt++;
			}
		}
		if (ok == -1) break;
		ans.emplace_back(A[ok]);
		used[ok] = 1;
		loop++;
	}

	if (ans.size() != N) {
		cout << -1 << "\n";
		return 0;
	}
	reverse(ans.begin(), ans.end());
	for (const auto &e : ans) cout << e << "\n";

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define cases long long test;cin>>test;while(test--)
#define f_io ios::sync_with_stdio(false); cin.tie(0)
#define foi(a,n) for(long long i=a;i<n;i++)
#define foj(a,n) for(long long j=a;j<n;j++)
#define fok(a,n) for(long long k=a;k<n;k++)
#define ll long long
#define MOD 1000000007
#define INF 1000000000
using namespace std;

int main()
{
    f_io;
    ll n,x,m,ans=0;
    cin >> n >> x >> m;
    vector<ll> arr;
    map<ll,bool> mp;
    arr.push_back(x);
    mp[x]=1;
    ans+=x;
    foi(1,n)
    {
        ll tmp = (arr[i-1]*arr[i-1])%m;
        if(mp.count(tmp))
        {
            ll ind = find(arr.begin(),arr.end(),tmp)-arr.begin();
            //cout << i << " ";
            ll sz = i - ind;
            ll rem = n - i;
            ll sumi = 0LL;
            foj(ind,i)
                sumi+=arr[j];
            ans += (rem/sz)*sumi;
            rem%=sz;
            foj(0,rem)
                ans+=arr[ind+j];
            break;
        }
        else
        {
            ans+=tmp;
            arr.push_back(tmp);
            mp[tmp]=1;
        }
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 6680
#include <bits/stdc++.h>
using namespace std;
#define X 3

const long long INF = 1LL << 30;

int main() {
  int N;
  cin >> N;
  
  vector<int> a(X*N);
  for(int n=0; n<N; n++){
  	for(int k=0; k<X; k++){
      cin >> a[X*n+k];
    }
  }
  
  vector<int> dp(X*(N+1), 0);

  for(int n=0; n<N; n++){
  	for(int k=0; k<X; k++){
      for(int l=0; l<X; l++){
	    if(k != l){
          dp[X*(n+1)+k] = max(dp[X*(n+1)+k], dp[X*n+l] + a[X*n+k]);
        }
      }
    }
  }
  
  int ans = 0;
  for(int k=0; k<X; k++){
  	if(ans < dp[X*N+k]) ans = dp[X*N+k];
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 2688
import java.util.*;
import java.io.*;
import java.math.*;
 
 
import static java.lang.Math.*;
import static java.util.Arrays.*;
import static java.util.Collections.*;
 
 
public class Main{ 
 
 
    static long mod=1000000007;
    static int dx[]={1,-1,0,0};
    static int dy[]={0,0,1,-1};
    // static int dx[]={1,-1,0,0,1,1,-1,-1};
    // static int dy[]={0,0,1,-1,1,-1,1,-1};
    // PriorityQueue<Integer> que = new PriorityQueue<Integer>(); 
    //HashMap<Integer,Integer> map = new HashMap<Integer,Integer>();
 
    public  static void main(String[] args)   throws Exception, IOException{
     
        
        Reader sc = new Reader(System.in);
        PrintWriter out=new PrintWriter(System.out);
     
        // int n=sc.nextInt();
        // char c[][] = new char[h][w];
        // long a[] = new long [n];
        // for (int i=0; i<n; i++ ) {        }
        int x=sc.nextInt();
        int y=sc.nextInt();
        int n = 10, ans=0;
        int c[][] = new int [n][n];
        for (int i=0; i<n ; i++) {
            for (int t=0; t<n ; t++) {
                c[i][t] = sc.nextInt();
            }
        }
        for (int i = 0; i < n; i++)      // 経由する頂点
            for (int j = 0; j < n; j++)    // 開始頂点
                for (int k = 0; k < n; k++)  // 終端
                    c[j][k] = min(c[j][k], c[j][i] + c[i][k]);

        for (int i=0; i<x ; i++) {
            for (int t=0; t<y ; t++) {
                int e = sc.nextInt();
                if(e>=0)ans += c[e][1];
            }
        }


        out.println(ans);
        out.flush();
    }

    static long gcd(long a, long b){
        if(min(a,b) == 0)return max(a,b);
        return gcd(max(a,b) % min(a,b),min(a,b));
    }
     
    static void db(Object... os){
     
        System.err.println(Arrays.deepToString(os));
     
    }
     
    static boolean validpos(int x,int y,int r, int c){
        
        return x<r && 0<=x && y<c && 0<=y;
        
    }
     
    static boolean bit(long x,int k){
        // weather k-th bit (from right) be one or zero
        return  ( 0 < ( (x>>k) & 1 )  )  ? true:false;
    }    
}
 
class XY {
    int x,y,d;
    XY(int x, int y, int d) {
        this.x=x;
        this.y=y;
        this.d=d;
    } 
}
 
class P implements Comparable<P>{
    int x,y;
    P(int x, int y) {
        this.x=x;
        this.y=y;
    } 
      
    public int compareTo(P p){
        return -x + p.x;//des
    } 
}
 
class Reader
{ 
    private BufferedReader x;
    private StringTokenizer st;
    
    public Reader(InputStream in)
    {
        x = new BufferedReader(new InputStreamReader(in));
        st = null;
    }
    public String nextString() throws IOException
    {
        while( st==null || !st.hasMoreTokens() )
            st = new StringTokenizer(x.readLine());
        return st.nextToken();
    }
    public int nextInt() throws IOException
    {
        return Integer.parseInt(nextString());
    }
    public long nextLong() throws IOException
    {
        return Long.parseLong(nextString());
    }
    public double nextDouble() throws IOException
    {
        return Double.parseDouble(nextString());
    }
}

Measured memory_bytes: 25812