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

using namespace std;
#ifdef _DEBUG
#define _GLIBCXX_DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

#define int long long
#define ll long long
#define DBG 1
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define rrep(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define loop(n) rep(loop, (0), (n))
#define all(c) begin(c), end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
using pii = pair<int, int>;
// template<class T> ostream &operator<<(ostream &os,T &t){dump(t);return os;}
template <typename T, typename S>istream &operator>>(istream &is, pair<T, S> &p) { is >> p.first >> p.second; return is; }
//template <typename T, typename S>ostream &operator<<(ostream &os, pair<T, S> &p) {os << p.first << " " << p.second;return os;}

template <typename T> void printvv(const vector<vector<T>> &v) {
	cerr << endl;
	rep(i, 0, v.size()) rep(j, 0, v[i].size()) {
		if (typeid(v[i][j]).name() == typeid(INF).name() and v[i][j] == INF) {
			cerr << "INF";
		}
		else
			cerr << v[i][j];
		cerr << (j == v[i].size() - 1 ? '\n' : ' ');
	}
	cerr << endl;
}

#ifndef _DEBUG
#define printvv(...)
#endif
void YES(bool f) { cout << (f ? "YES" : "NO") << endl; }
void Yes(bool f) { cout << (f ? "Yes" : "No") << endl; }
template <class T, class U>bool chmin(T& a, U b) { if (a > b) { a = b; return true; }return false; }
template <class T, class U>bool chmax(T& a, U b) { if (a < b) { a = b; return true; }return false; }

signed main(signed argc, char *argv[]) {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(12);

	int N, M; cin >> N >> M;
	vector<int>A(N); rep(i, 0, N) { cin >> A[i]; }
	priority_queue < int, vector<int>, less<int >> pq;
	for (auto x : A)pq.push(x);
	loop(M) {
		auto x = pq.top(); pq.pop();
		pq.push(x / 2);
	}

	int ans = 0;
	while (pq.size()) {
		ans += pq.top(); pq.pop();
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 2168
import queue
H, W = map(int, input().split())
S = []
for i in range(H):
  ss = input()
  S.append(ss)
rs = []
for n in range(H*W):
  sx, sy = n//W, n%W
  if S[sx][sy] == "#":
    continue
  M = [[-1]*W for i in range(H)]
  M[sx][sy] = 0
  q = queue.Queue()
  q.put((sx, sy, 0))
  while not q.empty():
    x, y, c = q.get()
    if x > 0 and S[x-1][y] == "." and M[x-1][y] < 0:
      M[x-1][y] = c+1
      q.put((x-1, y, c+1))
    if x+1 < H and S[x+1][y] == "." and M[x+1][y] < 0:
      M[x+1][y] = c+1
      q.put((x+1, y, c+1))
    if y > 0 and S[x][y-1] == "." and M[x][y-1] < 0:
      M[x][y-1] = c+1
      q.put((x, y-1, c+1))
    if y+1 < W and S[x][y+1] == "." and M[x][y+1] < 0:
      M[x][y+1] = c+1
      q.put((x, y+1, c+1))
  #print(M)
  r = max(map(max, M))
  rs.append(r)
r = max(rs)
print(r)


Measured memory_bytes: 4080
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using tlll=tuple<ll,ll,ll>;
using vs=vector<string>;

#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(ll i=(n)-1;i>=0;i--)
#define range(i,a,n) for(ll i=(a);i<(n);i++)

#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI 3.1415926535897932384

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

template<class T>bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T>bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
template<class S>S acm(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
void YN(bool b){cout<<(b?"YES":"NO")<<"\n";}
void Yn(bool b){cout<<(b?"Yes":"No")<<"\n";}
void yn(bool b){cout<<(b?"yes":"no")<<"\n";}
int sgn(const double&r){return (r>EPS)-(r<-EPS);} // a>0  : sgn(a)>0
int sgn(const double&a,const double&b){return sgn(a-b);} // b<=c : sgn(b,c)<=0

ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}
template<class T>void puta(T&&t){cout<<t<<"\n";}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1; for(auto s:t){os<<(a?"":" ")<<s;a=0;} return os;}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n,ans=0;
	cin>>n;
	range(i,1,n+1){
		if(!(i%3==0||i%5==0))ans+=i;
	}
	puta(ans);
}


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

int main() {
	// your code goes here
	string S;
	getline(cin,S);
	if(S.at(2)==S.at(3) && S.at(4)==S.at(5))
	    cout<<"Yes";
	else
	    cout<<"No";
	return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args)throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	    StringBuilder sb = new StringBuilder();
	    while(true){
	      String data[] = br.readLine().split(" ");
	      int a = Integer.parseInt(data[0]);
	      int b = Integer.parseInt(data[1]);
	      if(a == 0 && b == 0)
	          break;
	 
	      for(int i = 0; i < a; i++){
	          for(int j = 0; j < b; j++){
	              sb.append("#");
	          }
	          sb.append("\n");
	      }
	      sb.append("\n");
	    }
	    System.out.print(sb);
	  }
}

Measured memory_bytes: 24996
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define rep(i,b) FOR(i,0,b)
#define INF mugen
#define dump(x) cerr<<#x<<"="<<x<<endl
#define int long long

using ll = long long;
const ll mod = LLONG_MAX;

int a[100010];
int ans=1;
signed main(){
  int n;
  cin>>n;
  rep(i,n){
    cin>>a[i];
  }
  sort(a,a+n);
  reverse(a,a+n);
  unordered_set<int> se;
  int cnt=0;
  int idx=0;
  while(1){
    if(se.find(a[idx])!=se.end()){
      cnt++;
      ans*=a[idx];
      se.erase(a[idx]);
      idx++;
      if(cnt==2)break;
      continue;
    }

    se.insert(a[idx]);
    idx++;

  }
  cout<<ans<<endl;


}


Measured memory_bytes: 4644
#include <iostream>
#include <bits/stdc++.h>
#define ll long long
#define inf 100000000000000
#define mod 1000000007
#define ld long double
#define point complex<double>
#define pi  acos(-1)
#define IO                    \
	ios_base::sync_with_stdio(false); \
	cin.tie(NULL);                    \
	cout.tie(NULL);
using namespace std;
long double dot (point a,point b)
{
	return (conj(a)*b).real();
}
long double theta(point a,point b)
{
	long double x=dot(a,b);
	x/=abs(a);
	x/=abs(b);
	return acos(x)*180/pi;
}
long double cross(point a,point b)
{
	return (conj(a)*b).imag();
}
long double arg2(point a)
{
	return arg(a)*180/pi;
}
int n;
string s;
bool find(int cnt)
{
//	cout<<cnt<<endl;
	unordered_map<string,vector<int>>mapi;
	string ss;
	for(int i=0;i<n;i++)
	{
		if(i<cnt)
		{
			ss.push_back(s[i]);
			if(i==cnt-1)
			{
				mapi[ss].push_back((i+1)-cnt);
			}
		}
		else
		{
			ss.erase(ss.begin());
			ss.push_back(s[i]);
			mapi[ss].push_back((i+1)-cnt);
		}
	}
	bool res=0;

	for(auto m:mapi)
	{
		if((m.second[m.second.size()-1]-m.second[0])>=cnt)return 1;
	}
	return 0;
}
int main()
{
    IO

	cin>>n>>s;
	int S=1,E=n/2.0,M;
	ll res=0;
	while(S<=E)
	{
		M=(S+E)/2.0;
		if(find(M))
		{
			S=M+1;
			res=M;
		}
		else E=M-1;
	}
	cout<<res<<endl;
    return 0;
}


Measured memory_bytes: 6804
#include<iostream>

using namespace std;

char map[128][128];
int h,w;

void serch(int y,int x,char now)
{
	int nex[4]={1,0,-1,0};
	int ney[4]={0,1,0,-1};
	
	map[y][x]='1';
	
	for(int i=0;i<4;i++)
	{
		if(y+ney[i]>=0 && y+ney[i]<h && x+nex[i]>=0 && x+nex[i]<w)
		{
			if(map[y+ney[i]][x+nex[i]]==now)
			{
				serch(y+ney[i],x+nex[i],now);
			}
		}
	}
	return ;
}

int main()
{
	int i,j;
	for(;;)
	{
		cin >> h >> w ;
		if(h==0 && w==0)
			break;
		
		for(i=0;i<h;i++)
			for(j=0;j<w;j++)
				cin >> map[i][j] ;
		
		int ans=0;
		for(i=0;i<h;i++)
		{
			for(j=0;j<w;j++)
			{
				if(map[i][j]!='1')
				{
					serch(i,j,map[i][j]);
					ans++;
				}
			}
		}
		cout << ans << endl;
	}
}

Measured memory_bytes: 0
#include <stdio.h>
#include <vector>

using namespace std;

int main(void){
	int n, m, t, c, p;
	vector<int> answers;
	while(true){
		scanf("%d %d", &n, &m);
		if(n == 0 && m == 0) break;

		vector<int> nodes;
		vector<int> dices;

		for(int i = 0;i < n;++i){
			scanf("%d", &t);
			nodes.push_back(t);
		}

		for(int i = 0;i < m;++i){
			scanf("%d", &t);
			dices.push_back(t);
		}

		c = 0;
		p = 0;
		while(1){
			p += dices[c];
			p += nodes[p];
			++c;
			if(p+1 >= n) break;
		}

		answers.push_back(c);
	}

	for(int i = 0;i < answers.size();++i) printf("%d\n", answers[i]);
}

Measured memory_bytes: 2584
#include <iostream>
#include <vector>
#define endl '\n'
#include <cstdlib>
#define pb push_back
using namespace std;

int main()
{
    int n=5, a, tmp;
    for (int i=1; i<=5; i++) {
        cin >> a;
        if (a==0) tmp=i;
    }
    cout << tmp << endl;
    return 0;
}


Measured memory_bytes: 3624
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using static System.Console;
using static System.Math;

class program
{
    static public int mod = 1000000007;
    static void Main()
    {
        var nm = inta();
        int ans = nm[0] * (nm[0] - 1) / 2 + nm[1] * (nm[1] - 1) / 2;
        Write(ans);
    }

    static int pow(int a, int b) { string binary = Convert.ToString(b, 2); int bileng = binary.Length; long a_power = a; long value = 1; for (int i = bileng - 1; i >= 0; i--) { if (binary[i] == '1') { value = value * a_power % mod; } a_power = a_power * a_power % mod; } return (int)value; }
    static string rstr() { return ReadLine(); }
    static int rint() { return int.Parse(ReadLine()); }
    static long rlong() { return long.Parse(ReadLine()); }
    static string[] stra() { return ReadLine().Split(' '); }
    static char[] chara() { string[] a = stra(); string b = ""; for (int i = 0; i < a.Length; i++) { b += a[i]; } return b.ToCharArray(); }
    static int[] inta() { string[] read_str_array = ReadLine().Split(' '); int[] return_int_array = new int[read_str_array.Length]; for (int countup_i = 0; countup_i < read_str_array.Length; countup_i++) { return_int_array[countup_i] = int.Parse(read_str_array[countup_i]); } return return_int_array; }
    static long[] longa() { string[] read_str_array = ReadLine().Split(' '); long[] return_long_array = new long[read_str_array.Length]; for (long countup_i = 0; countup_i < read_str_array.Length; countup_i++) { return_long_array[countup_i] = long.Parse(read_str_array[countup_i]); } return return_long_array; }
    static double[] doublea() { string[] read_str_array = ReadLine().Split(' '); double[] return_double_array = new double[read_str_array.Length]; for (long countup_i = 0; countup_i < read_str_array.Length; countup_i++) { return_double_array[countup_i] = double.Parse(read_str_array[countup_i]); } return return_double_array; }
    static long GCD(long a, long b) { if (a < b) { long temp = a; a = b; b = temp; } if (a % b == 0) { return b; } else { long temp = b; b = a % b; a = temp; return GCD(a, b); } }
    static long LCM(long a, long b) { return a * b / GCD(a, b); }
    static void WriteArray2(int[,] a, int b, int c) { for (int i = 0; i < b; i++) { for (int j = 0; j < c; j++) { if (j != 0) Write(" "); Write(a[i, j]); } WriteLine(); } }
    static void WriteArray(int[] a, int b) { for (int i = 0; i < b; i++) { Write(" "); Write(a[i]); } WriteLine(); }
}


Measured memory_bytes: 27456
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    double dp[n+1][n+1];
    memset(dp,0, sizeof(dp));
    vector<double> data;
    double input;
    for(int i=0;i<n;i++)
    {
        cin>>input;
        data.push_back(input);
    }
    dp[0][0]=1.0;
    for(int i=1;i<=n;i++)
        dp[i][0]=dp[i-1][0]*(1-data[i-1]);
    for(int i=1;i<=n;i++)
    {
        for(int k=1;k<=i;k++)
        {
            dp[i][k]=dp[i-1][k-1]*data[i-1]+dp[i-1][k]*(1-data[i-1]);
        }
    }
    /*
    for(int i=0;i<=n;i++,cout<<endl)
    for(int k=0;k<=n;k++)
    cout<<dp[i][k]<<' ';
     */
    double answer=0;
    for(int i=n;i>=ceil(float(n)/float(2));i--)
    answer+=dp[n][i];
    cout<<setprecision(10)<<answer;
}


Measured memory_bytes: 74104
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a,b,sum=0;
	cin>>a>>b;
	for(int i=1;i<a;i++)
		sum+=i;
	for(int i=1;i<b;i++)
		sum+=i;
	cout<<sum;
	return 0; 
}

Measured memory_bytes: 256
//----------------------------templates
    #pragma GCC optimize ("Ofast")
    #pragma GCC target ("tune=native")
    #pragma GCC target ("avx")
    //----------------------------
    #include <bits/stdc++.h>
    using namespace std;

    typedef long long ll;
    typedef unsigned long long ull;
    #define int ll

    #define FOR(i,j,n) for (int i=(int)(j);i<(n);i++)
    #define REP(i,n) for (int i=0;i<(int)(n);i++)
    #define REPS(i,n) for (int i=1;i<=(int)(n);i++)
    #define REPN(i,n) for (int i=(int)(n)-1;i>=0;i--)
    #define REPNS(i,n) for (int i=(int)(n);i>0;i--)

    #define I(n) scanf("%lld", &(n))
    #define LL(n) scanf("%lld", &(n))
    #define pb(n) push_back((n))
    #define mp(i,j) make_pair((i),(j))
    #define eb(i,j) emplace_back((i),(j))
    #define y0 y3487465
    #define y1 y8687969
    #define j0 j1347829
    #define j1 j234892
    #define uniq(v) v.erase( unique(v.begin(), v.end()), v.end() )

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

    typedef vector<int> vi;
    typedef pair<int,int> pi;
    typedef vector<pi> vpi;
    typedef vector<vi> vvi;
    typedef vector<vpi> vvpi;
    typedef vector<vvi> vvvi;

    const int mod = 1000000007;

//--------------------------------------------

ll facts[200010],invs[200010];
ll dp[200010], ret[200010], ni[200010];
ll powll(ll base,ll power){
    ll ans = 1;
    while (power){
        if (power&1) ans = (base*ans)%mod;
        base = (base*base)%mod;
        power >>= 1;
    }
    return ans;
}

void merge(int i, int k){
    ni[i] += ni[k];
    dp[i] = dp[i] * dp[k] % mod * 
            facts[ni[i]] % mod * 
            invs[ni[k]] % mod * 
            invs[ni[i]-ni[k]] % mod;
}
void invmerge(int i, int k){
    dp[i] = dp[i] * powll(dp[k], mod-2) % mod *
            invs[ni[i]] % mod *
            facts[ni[k]] % mod *
            facts[ni[i]-ni[k]] % mod;
    ni[i] -= ni[k];
}

int n,a,b;
vvi tree;
void dfs1(int i){
    dp[i] = 1;
    for(auto ch: tree[i]) {
        if (dp[ch]) continue;
        dfs1(ch);
        merge(i, ch);
    }
    ni[i]++;
}
void dfs2(int i){
    ret[i] = dp[i];
    ni[i]--;
    for(auto ch: tree[i]){
        if (ret[ch]) continue;
        invmerge(i, ch);
        ni[ch]--;
        ni[i]++;
        merge(ch, i);
        ni[ch]++;
        dfs2(ch);
        ni[ch]--;
        invmerge(ch, i);
        ni[ch]++;
        ni[i]--;
        merge(i, ch);
    }
    ni[i]++;
}

signed main(){
    ll f = 1;
    n = 200001;
    facts[0] = 1;
    FOR(i,1,n+1){
        f *= i;
        f %= mod;
        facts[i] = f;
    }
    ll inv = powll(f,mod-2);
    invs[n] = inv;
    REPNS(i,n){
        inv *= i;
        inv %= mod;
        invs[i-1] = inv;
    }

    I(n);
    tree.resize(n);
    REP(i,n-1){
        I(a); I(b);
        a--; b--;
        tree[a].pb(b);
        tree[b].pb(a);
    }
    dfs1(0);
    dfs2(0);
    REP(i,n) printf("%lld\n", ret[i]);
}

Measured memory_bytes: 22512
#include <bits/stdc++.h>
#define debug(x) cerr << "\n" \
                      << #x << ": " << x << "\n"
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define INF (1LL << 30)
#define pii pair<int, int>
#define MOD 1000000007
#define print(x) cout << (x) << endl
using namespace std;
typedef long long ll;
#define int long long

signed main()
{
    int N;
    cin >> N;
    vector<int> p(N + 2);
    FOR(i,1, N+1)
    {
        int tmp;
        cin >> tmp;
        p[i] = tmp;
    }
    int ans = 0;
    FOR(i,1,N+1)
    {
        if (i == p[i])
        {
            swap(p[i], p[i + 1]);
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <stdio.h>
int main() {
    int RideBack[29][29],i,j,k,N;while (1) {
        for (i=0;i<29;i++) for (j=0;j<29;RideBack[i][j++]=0);scanf("%d",&N);if (!N) return 0;k=N*N,i=N-1,j=(N-1)*3-i;while (k>0) {RideBack[i][j]=k--;i--,j--;if (k%N==0) i+=1+N,j=(N-1)*3-i;}
        for (i=1;i<29;i++) for (j=N/2-1;j>=0;j--) if (RideBack[i][j]) RideBack[i][j+N]=RideBack[i][j],RideBack[j+N][i]=RideBack[j][i];
        for (i=1;i<29;i++) for (j=N/2+N;j<N*2-1;j++) if (RideBack[i][j]) RideBack[i][j-N]=RideBack[i][j],RideBack[j-N][i]=RideBack[j][i];
        for (j=N/2;j<N/2+N;j++,puts("")) for (i=N/2;i<N/2+N;i++) printf("%4d",RideBack[i][j]);
    }
}

Measured memory_bytes: 0
H, W = map(int, input().split())
F = [list(input()) for _ in range(H)]
cnt = 0
for i in range(H):
    for j in range(W):
        if F[i][j] == '.':
            cnt += 1


que = [[0, 0, 0]]
flag = True

while len(que) > 0 and flag:
    sp = que.pop(0)
    y, x, c = sp[0], sp[1], sp[2]
    for dy, dx in [[1,0], [-1,0], [0,1], [0,-1]]:
        if 0 <= y+dy < H and 0 <= x+dx < W and F[y+dy][x+dx] == ".":
            F[y+dy][x+dx] = c+1
            que.append([y+dy, x+dx, c+1])
            if y+dy == H-1 and x+dx == W-1:
                flag = False

if flag:
    print(-1)
else:
    print(cnt-F[H-1][W-1]-1)

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

int main(){
	int n;
	double a[105],sum=0;
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		scanf("%lf",&a[i]);
		sum=sum+1/a[i];
	}
	printf("%lf\n",1/sum);
}

Measured memory_bytes: 256
import heapq
N = int(input())
q = []
for _ in range(N):
	at,bt = map(int,input().split())
	heapq.heappush(q,[bt,at])

cond = True
cnt = 0
tmp = 0
for _ in range(N):
	d,c = heapq.heappop(q)
	cnt += (d - tmp)
	cnt -= c
	if cnt < 0:
		cond = False
		break
	tmp = d

if cond:
	print("Yes")
else:
	print("No")



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

int main(void) {
  string NS;
  cin >> NS;
  int N = NS.size();
  int answer0 = NS[0] - '0';
  int answer1 = answer0 - 1;
  for (int i = 1; i < N; ++i) {
    answer0 += NS[i] - '0';
    answer1 += 9;
  }
  cout << max(answer0, answer1) << endl;
  return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cstdint>
#include <iostream>
#include <deque>
#include <vector>

int As[20][20];
int Bs[20];

auto main() -> int {
  int N, M, C;
  std::cin >> N >> M >> C;

  for (auto i = 0; i < M; ++i) {
    std::cin >> Bs[i];
  }

  for (auto i = 0; i < N; ++i) {
    for (auto j = 0; j < M; ++j) {
      std::cin >> As[i][j];
    }
  }

  int ans = 0;
  for (auto i = 0; i < N; ++i) {
    int a = 0;
    for (auto j = 0; j < M; ++j) {
      a += As[i][j] * Bs[j];
    }

    if (a > (-C)) {
      ans++;
    }
  }

  std::cout << ans << std::endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
vector<int> dp(100005);
bool vis[100005];
int dfs(vector<vector<int>>& adj, int i){
  if(vis[i]){
    return dp[i];
  }
  int ans = 0;
  vis[i] = 1;
  for(int j = 0; j < adj[i].size(); j++){
    ans = max(ans, 1+dfs(adj, adj[i][j]));
  }
  return dp[i] = ans;
}
int main(){
  int n, m;
  cin >> n >> m;
  memset(vis, 0, sizeof(dp));
  fill(dp.begin(), dp.end(), 0);
  vector<vector<int>> adj(n+1);
  for(int i = 0; i < m; i++){
    int x, y;
    cin >> x >> y;
    adj[x].push_back(y);
    
  }
  //dfs(adj, 1);
  for(int i = 1; i < n+1; i++){
    if(!vis[i]){
      dfs(adj, i);
    }
  }
  cout << *max_element(dp.begin(), dp.end()) << "\n";

}

Measured memory_bytes: 11080
#include <iostream>
#include <vector>
#include <stdlib.h>
#include <algorithm>
#define min(x, y) (x > y ? y : x)
using namespace std;

struct City
{
    int kennum, citynum, year, sortnum;
};

bool cmp_kencity(const City &a, const City &b){
    if (a.kennum != b.kennum){
        return a.kennum < b.kennum;
    }
    return a.year < b.year;
}

bool cmp_num(const City &a, const City &b){
    return a.citynum < b.citynum;
}

int main()
{

    int N, M;
    cin >> N >> M;
    vector<City> citydata(M);

    for (int i = 0; i < M; i++)
    {
        int tmpP, tmpY;
        citydata[i].citynum = i;
        cin >> citydata[i].kennum >> citydata[i].year;
    }

    sort(citydata.begin(), citydata.end(), cmp_kencity);

    int kenstart = 0;
    int number = 0;
    for(int i = 0; i < M; i++)
    {   
        if (citydata[i].kennum > kenstart){
            kenstart = citydata[i].kennum;
            number = 1;
        }
        citydata[i].sortnum = number;
        number++;
    }
    sort(citydata.begin(), citydata.end(), cmp_num);
    
    for(auto i :citydata)
    {
        printf("%06d%06d\n", i.kennum, i.sortnum);
    }
    
}

Measured memory_bytes: 3072
#include <iostream>
#include<cstdlib>
#include<queue>
#include<set>
#include<vector>
#include<string>
#include<cmath>
#include<algorithm>
#include<stack>
#include<map>
#include<deque>
#include<cstdio>
#include<cstdio>
using namespace std;
#define rep(i,a) for(int i=0;i<a;i++)
#define mp make_pair
#define pb push_back
#define ll __int64
#define __int64 long long
#define P pair<int,int>
#define PP pair<P,int>


int n,a,b;
vector<int>G[111111];
int distA[111111];
int distB[111111];

void dfsA(int now,int cnt){

    distA[now]=cnt;

    for(int i=0;i<G[now].size();i++){
        if(distA[G[now][i]]!=-1)continue;
        dfsA(G[now][i],cnt+1);
    }
}

void dfsB(int now,int cnt){

    distB[now]=cnt;

    for(int i=0;i<G[now].size();i++){
        if(distB[G[now][i]]!=-1)continue;
        dfsB(G[now][i],cnt+1);
    }
}

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

    rep(i,n-1){
        int x,y;
        cin>>x>>y;
        x--;
        y--;
        G[x].pb(y);
        G[y].pb(x);
    }
    rep(i,n)distA[i]=-1;
    rep(i,n)distB[i]=-1;
    dfsA(a,0);
    dfsB(b,0);
    int ans=-1;
    //rep(i,n)cout<<distA[i]<<" ";cout<<endl;
    //rep(i,n)cout<<distB[i]<<" ";cout<<endl;
    
    rep(i,n){
        int koho=-1;
        if(distA[i]==distB[i]){
            koho=distA[i];
        }
        if(distA[i]>distB[i]){

        }
        if(distA[i]<distB[i]){
            koho=distB[i];
        }
        ans=max(ans,koho);
    }
    cout<<ans-1<<endl;

    return 0;
}

Measured memory_bytes: 10624
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
#include <functional> // for less 
using namespace __gnu_pbds; 
#define mod 1000000007
#define int long long
#define pb push_back
#define boost ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define inp(n) for(i=0;i<n;i++) cin>>A[i];
#define inz(A) memset(A,0,sizeof(A))
#define lb lower_bound
#define ub upper_bound
#define all(v) v.begin(),v.end()
#define T 1000000
#define F first
#define S second
#define pi pair<int,int>
#define vi vector<int>
#define mii map<int,int>
#define vp vector<pair< int,int> >
#define mpi map<pair<int,int> ,int>
#define mip map<int, pair<int,int> >
#define inf INT_MAX
#define inf1 LONGLONG_MAX
#define sz(v) v.size()
#define rep(i,n) for(int i=0;i<n;i++)
#define forn(i,a,b) for(int i=a;i<=b;i++)
#define deb(x) cout<<#x<<"is "<<x<<endl;
#define lower(s) transform(all(s),s.begin(),::tolower)
#define endl "\n"
typedef tree<int, null_type, less<int>, rb_tree_tag, 
         tree_order_statistics_node_update> pbds;
   
/* brownsands :Arpit */			

void solve()
{   string s;
    cin >> s;
    if((s[0]=='A' || s[1]=='A' || s[2]=='A') && ((s[0]=='B' || s[1]=='B' || s[2]=='B')))
    cout<<"Yes";
    else cout<<"No";
}
signed main()
{
   boost
        int test=0,t;
		//cin>>t;
		t=1;
		while(test++ <t){
            //cout<<"Case "<<test<<": ";
            solve();
            //cerr << "\nTime : " << (double)clock() / (double)CLOCKS_PER_SEC << "s\n";
               }		
} 
               
			
 

				
		
		




Measured memory_bytes: 256
N = int(input().strip())
T = [list(map(int, input().strip().split(' '))) for _ in range(N-1)]

for i in range(N):
  t = 0
  for j in range(i,N-1):
    if t <= T[j][1]:
      t = T[j][1] + T[j][0]
    else:
      if t % T[j][2] == 0:
        t += T[j][0]
      else:
        t += T[j][2]-(t%T[j][2]) + T[j][0]
  print(t)


Measured memory_bytes: 3188
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++) 
#define all(x) (x).begin(), (x).end()
typedef long long ll;
using namespace std;

int main() {
	int T,X;
	cin >> T >> X;
  cout << (double)T/X << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define sd(x) scanf("%d", &x)
#define sz(v) (int) v.size()
#define pr(v) For(i, 0, sz(v)) {cout<<v[i]<<" ";} cout<<endl;
#define slld(x) scanf("%lld", &x)
#define all(x) x.begin(), x.end()
#define For(i, st, en) for(ll i=st; i<en; i++)
#define tr(x) for(auto it=x.begin(); it!=x.end(); it++)
#define fast std::ios::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back
#define ll long long
#define int long long
#define mp make_pair
#define F first
#define S second
typedef pair<int, int> pii;
typedef vector<int> vi;
#define MOD 1000000007
#define INF 1000000000000000007LL

const int N = 100005;
 
// it's swapnil07 ;)
 
#ifdef SWAPNIL07
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cout << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
int begtime = clock();
#define end_routine() cout << "\n\nTime elapsed: " << (clock() - begtime)*1000/CLOCKS_PER_SEC << " ms\n\n";
#else
#define endl '\n'
#define trace(...)
#define end_routine()
#endif

int red[N], grn[N], col[N];

signed main()
{
    fast
    #ifdef SWAPNIL07
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);
    #endif
    int x, y, a, b, c; cin>>x>>y>>a>>b>>c;
    For(i, 0, a){
        cin>>red[i];
    }
    For(i, 0, b){
        cin>>grn[i];
    }
    For(i, 0, c){
        cin>>col[i];
    }
    vector<int> vect;
    sort(red, red+a); sort(grn, grn+b);
    reverse(red, red+a); reverse(grn, grn+b);
    For(i, 0, x){
        vect.pb(red[i]);
    }
    For(i, 0, y){
        vect.pb(grn[i]);
    }
    For(i, 0, c){
        vect.pb(col[i]);
    }
    sort(all(vect));
    reverse(all(vect));
    int ans = 0;
    For(i, 0, x+y){
        ans+=vect[i];
    }
    cout<<ans;
    return 0;

}





Measured memory_bytes: 8816
#include<stdio.h>

int main(){
	int x,y,z;
	scanf("%d %d",&x,&y);
	z=x+y+1;
	for(int i=1000;i>0;i--){
		 if((x%i==0)&(y%i==0)){
		 z=z-i;	
		 break;
			}else{}
		 }
	printf("%d\n",z);
}


Measured memory_bytes: 2732
N,Q=map(int,input().split())
S=input()
tot=[0]
for i in range(N-1):
    if S[i:i+2]=="AC":
        tot.append(tot[-1]+1)
    else:
        tot.append(tot[-1])

for q in range(Q):
    l,r=map(int,input().split())
    print(tot[r-1]-tot[l-1])

Measured memory_bytes: 11552
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <math.h>
#define MOD 1000000007
typedef long long ll;
using namespace std;

int main(){
  int n;
  cin>>n;
  int t[n+1]={};
  int a[n+1]={};

  for(int i=1;i<=n;i++){
    cin>>t[i]>>a[i];
  }
  unsigned long long x=1,y=1;
  for(int i=1;i<=n;i++){
    unsigned long long m=max(((x-1)/t[i])+1,((y-1)/a[i])+1);
    x=t[i]*m;
    y=a[i]*m;
  }
  cout<<x+y<<endl;
  return 0;
}


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

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

Measured memory_bytes: 1156
N,M = map(int,input().split())

end = [False] * N
ans = []

dic = {}

for i in range(M):

    A,B = map(int,input().split())

    A -= 1
    B -= 1

    if A not in dic:
        dic[A] = []
    if B not in dic:
        dic[B] = []

    dic[A].append(B)
    dic[B].append(A)

now = 0
end[0] = True
ans.append(1)

while True:

    f = True
    for i in dic[now]:

        if not end[i]:
            end[i] = True
            now = i
            ans.append(i+1)
            f = False
            break
    
    if f:
        break

now = 0
end[0] = True
ans.reverse()

while True:

    f = True
    for i in dic[now]:

        if not end[i]:
            end[i] = True
            now = i
            ans.append(i+1)
            f = False
            break
    
    if f:
        break


print (len(ans))
print (" ".join(map(str,ans)))


Measured memory_bytes: 83160
#include <iostream>

int main(){
        int n;
        while(std::cin >> n){
                int result=100000;
                while(n--){
                        result*=1.05;
                        if(result%1000!=0)result+=1000-result%1000;
                }

                std::cout << result << std::endl;
        }

        return 0;
}

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

int main(){
 
  string S;
  int sum;
  cin >> S;
  sum = 0;
  
  for(int i=0; i < S.size(); i++){
    if(S.at(i) == '+'){
      sum++;
    }
    else{
      sum--;
    }
  }
  
  cout << sum << endl;
}


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

using namespace std;

 map<string,int>p;
int main(){
  int n;
  cin>>n;
  vector<int>a(n);
  for(int i=0;i<n;i++){
	  cin>>a[i];
  }
  long double ans=0;
  for(int i=0;i<n;i++){
	  ans+=(1.0)/(a[i]+0.0);
  }
  ans=(1.0)/ans;
  cout<<setprecision(100)<<ans<<endl;

}


Measured memory_bytes: 256
import fractions
from functools import reduce

n = int(input())

a = list(map(int,input().split()))
#
# a = [4,8,12,9,16]


def gcd_list(numbers):
    return reduce(fractions.gcd, numbers)


gcd_l = [a[0]]
gcd_r = [a[-1]]
for i in range(1,n):
    gcd_l.append(fractions.gcd(gcd_l[i-1],a[i]))
    gcd_r.append(fractions.gcd(gcd_r[i-1],a[-i-1]))

gcd_r.reverse()

ans = max(gcd_r[1],gcd_l[-2])
for i in range(1,n-1):
    gcd = fractions.gcd(gcd_l[i-1],gcd_r[i+1])
    ans = max(ans,gcd)

print(ans)

Measured memory_bytes: 16156
#include <bits/stdc++.h>
#define REP(i,n) for(ll i = 0; i < (ll)n; i++)
#define FOR(i,a,b) for (ll i=(a);i<(ll)b; i++)
#define ALL(obj) (obj).begin(),(obj).end()
#define INF 1LL << 60
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;
typedef pair<ll,ll> p;
const int MOD = 1000000007;

// vector<p> cut(M);
// cut[i].second
// cut[i].first;
// REP(i,M){
//     int a,b;cin>>a>>b;
//     cut[i] = make_pair(b,a);//last first の順番
// }
// for(int i=0; i<N;i++){
// }
// sort(cut.begin(),cut.end()); //sort
// char '' str ""
int main(void)
{
    int a,b,c;cin>>a>>b>>c;

    int ans = min(a+b, b+c);
    ans = min(ans, a+c);

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


Measured memory_bytes: 256
class Graph():
    def __init__(self):
        """ ノードのつながりを辞書型で表現する """
        self.adjacency_dict = {}
    
    def add_vertex(self, v):
        """ ノードを追加する """
        self.adjacency_dict[v] = []
    def add_edge(self, v1, v2):
        """ ノード同士をつなぐ。"""
        # 無向グラフの場合は双方向。もし有向グラフなら片側のみ。
        self.adjacency_dict[v1].append(v2)
        self.adjacency_dict[v2].append(v1)
    def remove_edge(self, v1, v2):
        """ ノード同士のつながりを削除する。"""
        self.adjacency_dict[v1].remove(v2)
        self.adjacency_dict[v2].remove(v1)
    def remove_vertex(self,v):
        """ ノードを削除する。"""
        while self.adjacency_dict[v] != []:
            adjacent_vertex = self.adjacency_dict[v][-1]
            self.remove_edge(v, adjacent_vertex)
        del self.adjacency_dict[v]
    
    def print_graph(self):
        print(self.adjacency_dict)

    def _init_internal_graph(self, graph_dict):
        self.adjacency_dict = graph_dict
    
    def get_edge(self, v):
        """ 指定されたノードに関するエッジを返す。"""
        return self.adjacency_dict[v]

def dprint(*args):
  if debug:
    if len(args)==1:
      print(args[0])
    else:
      print(args)

debug = False
if debug:
  g = Graph()
  # N,M = [7, 7]
  # g._init_internal_graph({0: [2], 1: [6], 2: [0, 3], 3: [2, 4, 5], 4: [3, 5], 5: [3, 4, 6], 6: [1, 5]})
  
  N,M = [3, 3]
  g._init_internal_graph({0: [1, 2], 1: [0, 2], 2: [0, 1]})
else:
  N, M = map(int, input().split())
  g = Graph()
  dprint(N,M)

  for n in range(N):
    g.add_vertex(n)

  # 0-origin    
  for m in range(M):
      v1,v2 = list(map(int, input().split()))
      g.add_edge(v1-1,v2-1)                     

# g.print_graph()

seen = [False] * N
count = 0

def dfs(node, depth):
    dprint(node,depth)        
    if seen[node]:
        return 0
    if depth == N - 1:
        dprint('count-up',seen)
        return 1

    seen[node] = True
    dprint(seen)
    
    total_paths = 0
    for next_node in g.get_edge(node):
      total_paths += dfs(next_node, depth + 1)

    # seenを未到達にして次へ
    seen[node] = False

    return total_paths

count = dfs(0, 0)
print(count)


Measured memory_bytes: 3192
object Main{
	def main(args:Array[String]){
		val s = new java.util.Scanner(System.in)
		val n=s.nextInt
		val a,b=s.nextInt-1
		val c,d=s.nextInt
		val t = s.next

		lazy val fa = !t.substring(a,c).contains("##")
		lazy val fb = !t.substring(b,d).contains("##")
		lazy val fc = c<d || t.substring(math.max(0,b-1),math.min(n,d+1)).contains("...")
		println(if(fa&&fb&&fc)"Yes" else "No")
	}
}


Measured memory_bytes: 31188
#include <stdio.h>
 #include <math.h>

 #define PI 3.14159265358979323846264338327950L

 int main(void) {
 int a, b, h, m;
 scanf("%d%d%d%d", &a, &b, &h, &m);

 long double rad = PI * 2 * (
 (long double)h / 12.0 + ((long double)m / 60.0) / 12.0 - (long
double)m / 60.0);

 long double rsq = (long double)(a * a + b * b) - (long double)(2 * a *
b) * cosl(rad);

 printf("%20.20Lf\n", sqrtl(rsq));

 return 0;
 }

Measured memory_bytes: 2512
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <cmath>
using namespace std;
typedef long long ll;
int n;
ll ans;
char s[20];
inline void dfs(int t,ll x,ll y) {
    if(t>n) {ans+=x+y;return;}
    dfs(t+1,x+y,s[t]-'0');
    dfs(t+1,x,y*10+s[t]-'0');
}
int main() {
    scanf("%s",s+1);
    n=strlen(s+1);
    dfs(2,0,s[1]-'0');
    cout<<ans;
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>

using namespace std;

int main(void){
    string s, t;
    cin >> s >> t;
    int res = 1001;
    for(int i = 0; i < s.size() - t.size() + 1; ++i){
        int tmp = 0;
        for(int j = 0; j < t.size(); ++j){
            if(s[i + j] != t[j]){
                ++tmp;
            }
        }
        res = min(res, tmp);
    }
    cout << res;
    return 0;
}

Measured memory_bytes: 3624
#include <cstdio>
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <stack>
#include <cstdlib>
#include <cmath>
#include <cassert>

using namespace std;
typedef long long ll;

#define N 200010
#define Q 200010
#define INF 1000000000
#define LLINF 2000000000000000000LL

struct SEG{
  vector<ll> add_x;
  vector<ll> add_y;
  vector<pair<ll,ll> > left;
  vector<pair<ll,ll> > right;
  int segn2;

  SEG(int n){
    for(segn2=1;segn2<n;segn2*=2);
    add_x.assign(segn2*2,0);
    add_y.assign(segn2*2,0);
    left.assign(segn2*2,{INF,0});
    right.assign(segn2*2,{INF,0});
    
    for(int i=0;i<n;i++){
      int k = (i + segn2-1);
      left[k] = {i,0};
      right[k] = {i,0};
    }

    for(int i=segn2-2;i>=0;i--){
      left[i] = left[i*2+1];
      right[i] = right[i*2+2];
    }
    
  }

  void add(ll d,ll x,ll l,ll tx=0,ll ty=0,int k=0){

    tx += add_x[k];
    ty += add_y[k];
    
    if(d==1){
      if(right[k].first+tx - x < right[k].second+ty){
	add_y[k] -= l;
	add_x[k] -= l;
      }
      else if(left[k].first+tx - x < left[k].second+ty){
	add(d,x,l,tx,ty,k*2+1);
	add(d,x,l,tx,ty,k*2+2);

	left[k]  = { left[k*2+1].first+add_x[k*2+1], left[k*2+1].second+add_y[k*2+1]};
	right[k] = {right[k*2+2].first+add_x[k*2+2],right[k*2+2].second+add_y[k*2+2]};
      }
    }else{
      if(-(left[k].first+tx) + x <= left[k].second+ty){
	add_y[k] -= l;
	add_x[k] += l;
      }
      else if(-(right[k].first+tx) + x <= right[k].second+ty){
	add(d,x,l,tx,ty,k*2+1);
	add(d,x,l,tx,ty,k*2+2);
	
	left[k]  = { left[k*2+1].first+add_x[k*2+1], left[k*2+1].second+add_y[k*2+1]};
	right[k] = {right[k*2+2].first+add_x[k*2+2],right[k*2+2].second+add_y[k*2+2]};
      } 
    }
    
  }

  ll query(int k){
    k += segn2-1;
    ll y = add_y[k];

    while(k>0){
      k = (k-1)/2;
      y += add_y[k];
    }

    return y;
  }

};


int n,q;
ll x[Q],d[Q],l[Q];
SEG seg(N+1);

int main(){

  scanf("%d%d",&n,&q);

  for(int i=0;i<q;i++){
    scanf("%lld%lld%lld",x+i,d+i,l+i);
  }

  for(int i=q-1;i>=0;i--){
    seg.add(d[i],x[i],l[i]);
  }

  for(int i=0;i<n;i++){
    printf("%lld\n",-seg.query(i));
  }
	
  return 0;
}

Measured memory_bytes: 32108
#include <cstdio>
#define ll long long
using namespace std;
int n,a[200005];long long sum[200005];
ll ans;
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;++i) scanf("%d",&a[i]),sum[a[i]]++;
	for(int i=1;i<=n;++i) ans+=(sum[i]-1)*sum[i]/2;
	for(int i=1;i<=n;++i)
	{
		ans-=(sum[a[i]]-1)*sum[a[i]]/2;
		ans+=(sum[a[i]]-2)*(sum[a[i]]-1)/2;
		printf("%lld\n",ans);
		ans+=(sum[a[i]]-1)*sum[a[i]]/2;
		ans-=(sum[a[i]]-2)*(sum[a[i]]-1)/2;
	}
	return 0;
}

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

#define PI 3.14159265359
#define rep(i,a,n) for(int i=a;i<(int)n;++i)
#define SZ(x) ((int)(x).size())	//size() unsigned -> int
#define descsort(a) sort(a.begin(),a.end(),std::greater<int>())
using namespace std;
typedef long long ll;
const ll INF = 1e9 + 7;

int main(void)
{
    int n,h,w;
    cin>>n>>h>>w;
    cout<<(n-h+1)*(n-w+1)<<endl;
    return 0;
}

Measured memory_bytes: 3600
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
	Scanner sc = new Scanner(System.in);
	int x = sc.nextInt();
	int sec = x%60;
	int min = ((x-sec)/60)%60;
        int hou = ((x-sec)/60-min)/60;
	System.out.printf("%d:%d:%d\n",hou,min,sec); 
    }
}



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

typedef long long ll;
using namespace std;

int main() {
  int mCount = 0;
  ll ans = 0;
  int n;
  cin >> n;
  vector<int> absVec(n);
  for (int i = 0; i < n; i++) {
    int A;
    cin >> A;
    if (A < 0) mCount++;
    absVec[i] = abs(A);
    ans += absVec[i];
  }

  if (mCount % 2 == 0) cout << ans << endl;
  else {
    sort(absVec.begin(), absVec.end());
    cout << ans - 2 * absVec[0] << endl;
  }
};


Measured memory_bytes: 640
# -*- coding: utf-8 -*-
import sys


def input():
    return sys.stdin.readline().strip()


def main(N, K, h):
    # print(N, K, h)
    dp = [float('inf')] * N
    dp[0] = 0
    # print(dp)
    for i in range(0, N):
        for j in range(1, K+1):
            # dp[i + j]         : to
            # dp[i]             : from
            # |h[i] - h[i + j]| : value
            if i + j < N:
                dp[i + j] = min(dp[i + j], dp[i] + abs(h[i] - h[i + j]))
    return dp[-1]


if __name__ == '__main__':
    N, K = map(int,input().split())
    h = [int(x) for x in input().split()]
    r = main(N, K, h)
    print(r)


Measured memory_bytes: 55136
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << x << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
int main(){
	int TT;
	cin>>TT;
	rep(tt,TT){
		bool in[100]={};
		vector<int> ans[100];
		int sz[100]={},dis[100]={},it[100]={},p[100]={};
		rep(i,100) dis[i]=1000;
		int now=0,N=1;
		while(true){
			int x;
			cin>>x;
			if(x==0) break;
			if(x>0){
				ans[now].pb(N);
				ans[N].pb(now);
				p[N]=now;
				it[now]++;
				it[N]++;
				sz[N]=x;
				dis[N]=dis[now]+1;
				in[N]=1;
				now=N;
				N++;
			}else{
				rep(i,N) if(in[i]&&dis[i]-dis[now]==x){
					ans[i].pb(now);
					ans[now].pb(i);
					it[now]++;
					it[i]++;
				}
			}
			while(it[now]==sz[now]){
				in[now]=0;
				now=p[now];
			}
		}
		rep1(i,N-1){
			sort(all(ans[i]));
			cout<<i<<" ";
			rep(j,ans[i].size()){
				if(i==1&&j==0) continue;
				cout<<ans[i][j]<< (j+1==ans[i].size() ? "\n" : " ");
			}
		}
	}
}

Measured memory_bytes: 1228
#include<bits/stdc++.h>
#define INF 2000000000
#define int long long int
#define MOD 1000000007
#define pb push_back
#define cin1(n) (cin >> n)
#define cin2(a,b) (cin >> a >> b)
#define cin3(a,b,c) (cin >> a >> b >> c)
#define cout(n) (cout << n << endl)
#define rep(i,a,b) for(int i=(a);i<(b);++i)
#define fr first 
#define sc second 
#define EPS (1e-10)

using namespace std;

typedef vector<int> vi;
typedef vector< vector<int> > vvi;
typedef vector<pair<int,int>> vpii;
typedef vector<string> vs;
typedef vector<vector<string>> vss;
typedef pair<int,int> pii;

int dx[] = {1,-1,0,0};
int dy[] = {0,0,1,-1};
int n,m;
int a,b;
int p,q;


int MAX = 1000000;

signed main() {

	vi dp(MAX,MAX); // iテ」ツ?ョテヲツュツ」テ・ツ崢崚ゥツ敖「テ、ツスツ禿」ツ?ョテヲツ慊?・ツーツ湘・ツ?凝ヲツ閉ー
	vi dpo(MAX,MAX);

	dp[0] = 0;
	dpo[0] = 0;
	for (int i = 0;; i++) {
		int polo = i * (i + 1) * (i + 2) / 6;
		if (polo > MAX) break;
		for (int j = polo; j < MAX; j++) {
			dp[j] = min(dp[j],dp[j-polo] + 1);
		}
		if (polo % 2 == 1) {
		for (int j = polo; j < MAX; j++) {
			dpo[j] = min(dpo[j],dpo[j-polo] + 1);
		}
		}
	}

	while(1) {
		cin1(n);
		if (n == 0) break;
		cout << dp[n] << " " << dpo[n] << endl;
	}
	return 0;
}

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

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

fn calc(
    depth: usize,
    v: usize,
    seq: &Vec<usize>,
    costs: &Vec<i64>,
    memo: &mut Vec<Vec<i64>>,
) -> i64 {
    let n = seq.len();
    if depth == n {
        return 0;
    }
    if memo[depth][v] != -1 {
        return memo[depth][v];
    }
    let mut ret = 1 << 60;
    if seq[depth] < v {
        // left move
        ret = std::cmp::min(ret, calc(depth + 1, v, seq, costs, memo) + costs[0]);
    } else {
        // right move
        ret = std::cmp::min(ret, calc(depth + 1, v, seq, costs, memo) + costs[1]);
        // nop
        ret = std::cmp::min(ret, calc(depth + 1, seq[depth], seq, costs, memo));
    };
    // println!("{} {} {}", depth, v, ret);
    memo[depth][v] = ret;
    return ret;
}

fn main() {
    let n = read::<usize>();
    let mut costs = vec![0, 0];
    costs[1] = read::<i64>();
    costs[0] = read::<i64>();
    let mut seq = vec![0; n];
    for i in 0..n {
        seq[i] = read::<usize>() - 1;
    }
    let mut memo = vec![vec![-1; n]; n];
    let ans = calc(0, 0, &seq, &costs, &mut memo);
    println!("{}", ans);
}


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


using namespace std;
typedef long long ll;
#define REP(i,n) for(int i=0; i<int(n); i++)
#define FOR(i,m,n) for(int i=int(m); i<int(n); i++)
#define ALL(obj) (obj).begin(),(obj).end()
#define VI vector<int>
#define VLL vector<long long>
#define VVI vector<vector<int>>
#define VVLL vector<vector<long long>>
#define VC vector<char>
#define VS vector<string>
#define VVC vector<vector<char>>
#define VB vector<bool>
#define VVB vector<vector<bool>>
#define fore(i,a) for(auto &i:a)

typedef pair <int, int> P;
template<class T> bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
const int  INF = 1 << 30;
const ll INFL = 1LL << 60;
const ll mod = 1000000007;




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

}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <functional>
#include <utility>
#include <tuple>
#include <cctype>
using namespace std;
#define INF 0x3f3f3f3f
#define INFLL 0x3f3f3f3f3f3f3f3fLL
#define MOD 1000000007
#define mp make_pair
#define mt make_tuple
#define pb push_back
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pint;
typedef pair<ll,ll> pll;
typedef tuple<int,int,int> tint;
typedef vector<int> vint;
typedef vector<ll> vll;
int dx[8]={0,0,-1,1,1,1,-1,-1};
int dy[8]={-1,1,0,0,1,-1,1,-1};
const int SIZE=200050;
//ここまでテンプレ
int main(){
	ll N,K;
	cin>>N>>K;
	vll A,B;
	A.pb(0);
	B.pb(0);
	for(int i=0;i<N;i++){
		ll c;
		cin>>c;
		A.pb(c);
		B.pb(max(0LL,c));
	}
	A.pb(0);
	B.pb(0);
	for(int i=0;i<=N;i++){
		A[i+1]+=A[i];
		B[i+1]+=B[i];
	}
	ll ans=0;

	for(int i=1;i<=N-K+1;i++){
		ans=max(ans,(B[i-1])+(A[i+K-1]-A[i-1])+(B[N+1]-B[i+K-1]));
		ans=max(ans,(B[i-1])+0LL+(B[N+1]-B[i+K-1]));
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 2036
//============================================================================
//Everyone has a different way of thinking, so God Created us
//   Hope You Respect My Way..,Thank You ):
// Author      : Murad
// Name        : Codeforces.cpp & Atcoder.cpp
// Description : Problem name
//============================================================================
#include<bits/stdc++.h>
#include<unordered_map>
#include<unordered_set>
using namespace std;
#define pi 3.1415926536
#define forn(i,a,b)for(int i=a;i<b;i++)
#define LL long long
#define ULL unsigned long long
#define MP make_pair
#define SZ(c) int(c.size())
#define ff first
#define ss second
#define INF 1e9 + 1
#define _INF INT32_MIN
#define PQ priority_queue
#define MM multimap
#define PB push_back
#define vii vector<int>
#define ipair pair<int,int>
#define lpair pair<LL,LL>
#define MAXN 100004
#define El3zba ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define modd 1000000007
#define sfll1(v) scanf("%I64d",&v);
#define sfll2(v1,v2) scanf("%I64d %I64d",&v1,&v2)
#define sfll3(v1,v2,v3) scanf("%I64d %I64d %I64d",&v1,&v2,&v3)
#define endl '\n'
//std::transform(s1.begin(), s1.end(), s1.begin(),::tolower);
char alphz[27] = { 'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z' };
float Euclidean(LL x1, LL x2, LL y1, LL y2) {
	return sqrt(pow(x1 - x2, 2) + pow(y1 - y2, 2));
}
LL gcd(LL a,LL b) {
	LL c;
	while (a != 0) {
		c = a;
		a = b % a;
		b = c;
	}
	return b;
}
int LCM(int a, int b) {
	return (a*b) / gcd(a, b);
}
void PrimeFactor(LL n)
{
	while (n % 2 == 0) {
		printf("%d ", 2);
		n /= 2;
	}
	for (int i = 3; i <= sqrt(n); i += 2)
	{
		if (n%i == 0) {
			printf("%d ", i);
			n /= i;
		}
	}
	if (n > 2)printf("%d ", n);
}
bool is_square(LL x) {
	LL l = 0, r = x;
	while (l <= r) {
		LL mid = l + (r - l) / 2;
		if (mid*mid == x)return true;
		if (mid*mid > x)r = mid - 1;
		else l = mid + 1;
	}
	return false;
}
bool is_Prime(int x) {
	if (x == 2)return 1;
	else if (x % 2 == 0 || x < 2)return 0;
	for (int i = 3; i*i <= x; i += 2)
		if (x%i == 0)return 0;
	return 1;
}
int main()
{
	El3zba;
	/***  بسم الله الرحمن الرحيم   ***/
	int n, k;
	cin >> n >> k;
	int *a = new int[n + 1];
	for (int i = 1; i <= n; i++)
		cin >> a[i];
	sort(a,a+n+1);
	int ans = INF;
	for (int i = 1; i <= n - k+1; i++)
	{
		ans = min(ans, a[i + k - 1] - a[i]);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 640