akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define po pop_back
#define fi first
#define se second
#define hello ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define MOD 998244353  
using namespace std;
bool comp(ll a,ll b){if(a>b)return true;else return false;}
int isP(ll n){if(n==1)return 0;if(n==2 || n==3)return 1;for(ll i=2;i<=sqrt(n);i++){if(n%i==0)return 0;}return 1;}
ll power(ll a,ll b){if(b==0)return 1;if(b==1) return a;ll t=power(a,b/2);if(b%2==1) return t*t*a;else return t*t;}
ll powMOD(ll x,ll y){if(y==0)return 1;if(y==1)return x;ll t=powMOD(x,y/2);if(y%2==1)return t*t%MOD*x%MOD;else return t*t%MOD;}
bool cmp(pair<ll,ll> p1,pair<ll,ll> p2){if(p1.fi>p2.fi) return true;if(p1.fi==p2.fi && p1.se>p2.se) return true;return false;}

int main()
{
    hello;
    
    ll t; 
//    cin>>t;
	t=1;
	
	while(t--){
		ll n,k;
		cin>>n>>k;
		pair<ll,ll> p[k+1];
		for(ll i=1;i<=k;i++){
			cin>>p[i].fi>>p[i].se;
		}
		ll dp[n+1]={};
		dp[1]=1;
		dp[0]=0;
		for(ll i=2;i<=n;i++){
			for(ll j=1;j<=k;j++){
				ll l=p[j].fi,r=p[j].se;
				ll val=-1;
				while(l<=r){
					ll mid=l+(r-l)/2;
					if(i-mid>=1){
						val=mid;
						l=mid+1;
					}
					else{
						r=mid-1;;
					}
				}
				if(val!=-1){
					ll x=i-val,y=i-p[j].fi;
					dp[i]=(dp[i]+dp[y]-dp[x-1]+MOD)%MOD;
				}
			}
			dp[i]=(dp[i]+dp[i-1])%MOD;
		}
		ll ans=(dp[n]-dp[n-1]+MOD)%MOD;
//		cout<<dp[5]<<"\n";
		cout<<ans<<"\n";
	}
    
    return 0;  
}

Measured memory_bytes: 5276
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const int MAX_NM = 105;
int x[MAX_NM],y[MAX_NM];

int main()
{
	int N,M,X,Y;
	cin >> N >> M >> X >> Y;
	rep(i,N)
	{
		cin >> x[i];
	}
	rep(i,M)
	{
		cin >> y[i];
	}
	sort(x,x+N);
	sort(y,y+M);
	if (x[N-1] < y[0] && x[N-1] < Y && y[0] > X)
	{
		cout << "No War" << endl; 
	}
	else
	{
		cout << "War" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define fs first
#define sc second
#define task "tst"
using namespace std;
const ll N = 2e5 + 9;
const ll inf = 1e8;
typedef pair<ll,ll> LL;

ll a,v,b,w,t;

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
    if (fopen(task".inp", "r")){
        freopen(task".inp", "r", stdin);
        //freopen(task".out", "w", stdout);
    }
    cin>>a>>v>>b>>w>>t;
    ll p = abs(a - b);
    if (p <= t*(v - w)) cout<<"YES";
    else cout<<"NO";
}


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

using namespace std;


//repetition
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define euc_dis(x, y) sqrt(x*x + y*y)

#define MOD 1e9+7
#define sp ' '


using ll = long long;


ll mod(ll a, ll b){return (a%b+b)%b;}
ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b){return a*b/gcd(a,b);}
void Yes(){cout << "Yes" << endl;}
void No(){cout << "No" << endl;}
void Judge(bool b){b?Yes():No();}
void YES(){cout << "YES" << endl;}
void NO(){cout << "NO" << endl;}
void JUDGE(bool b){b?YES():NO();}
ll powMod(ll b, ll e, ll m){ll r=1;while(e>0){if(e&1)r=(r%m)*(b%m)%m;b=(b%m)*(b%m)%m;e>>=1;}return r;}
double distance(ll x1, ll y1, ll x2, ll y2){return sqrt((x1-x2)*(x1-x2) + (y1-y2)*(y1-y2));}

template<typename T>
void ppp(T n){cout << n << endl;}

int main(){

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

    int n;
    cin >> n;

    vector<int> a(n), b(n), c(n);
    rep(i, n){
        cin >> a[i] >> b[i] >> c[i];
    }

    int dp[100001][3];
    rep(i, 3) dp[0][i] = 0;

    for(int i = 1; i <= n; ++i){
        dp[i][0] = max(dp[i-1][1], dp[i-1][2]) + a[i-1];
        dp[i][1] = max(dp[i-1][0], dp[i-1][2]) + b[i-1];
        dp[i][2] = max(dp[i-1][0], dp[i-1][1]) + c[i-1];
    }

    int ans = 0;
    rep(i, 3){
        ans = max(ans, dp[n][i]);
    }

    ppp(ans);

    return 0;
}


Measured memory_bytes: 2560
#include <stdio.h>
#include <stdlib.h>

int arr[100000];

int cmp(const void *ap, const void *bp) {
	const int *a = ap, *b = bp;
	return *a - *b;
}

int main(void) {
	int n;
	scanf("%d", &n);

	for (int i = 0; i < n; i++) scanf("%d", &arr[i]);
	qsort(arr, n, sizeof arr[0], cmp);
	printf("%d\n", arr[n/2] - arr[n/2-1]);
}


Measured memory_bytes: 892
# include <iostream>
# include <algorithm>
#include <array>
# include <cassert>
#include <cctype>
#include <climits>
#include <numeric>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <tuple>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <bitset>
# include <complex>
# include <chrono>
# include <random>
# include <limits.h>
# include <unordered_map>
# include <unordered_set>
# include <deque>
# include <cstdio>
# include <cstring>
#include <stdio.h>
#include<time.h>
#include <stdlib.h>
#include <cstdint>
#include <cfenv>
#include<fstream>
//#include <bits/stdc++.h>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
long long MOD = 1000000000 + 7; //924844033 1000000000 + 9;
constexpr long long INF = numeric_limits<LL>::max();
const double PI = acos(-1);
#define fir first
#define sec second
#define thi third
#define debug(x) cerr<<#x<<": "<<x<<'\n'
typedef pair<LL, LL> Pll;
typedef pair<double, double> Dll;
typedef pair<LL, pair<LL, LL>> Ppll;
typedef pair<LL, pair<LL, bitset<100001>>> Pbll;
typedef pair<LL, pair<LL, vector<LL>>> Pvll;
typedef pair<LL, LL> Vec2;
struct Tll { LL first, second, third; };
struct Fll { LL first, second, third, fourth; };
typedef pair<LL, Tll> Ptll;
#define rep(i,rept) for(LL i=0;i<rept;i++)
#define Rrep(i,mf) for(LL i=mf-1;i>=0;i--)
LL h, w, n, m, k, t, s, p, q, last, first, cnt, sum, ans, a[200020], b[220000],dp[1100][21000];
string str, ss;
bool f[220000];
char c[4000][4000];
int di[4][2] = { { 0,1 },{ 1,0 },{ 0,-1 },{ -1,0 } };
struct Edge { LL to, cost; };
struct edge {
	LL from, to, cost;
};
vector<vector<Edge>>vec,rvec;
vector<edge>ed;
vector<LL>v;
map<string, LL>ma;
set<LL>st;

void YN(bool f) {
	if (f)
		cout << "YES" << endl;
	else
		cout << "NO" << endl;
}
void yn(bool f) {
	if (f)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
}
struct query {
	LL w, s, v;
};
vector<query>qu;
int main() {
	cin >> n;
	rep(i, n) {
		LL x, y, z;
		cin >> x >> y >> z;
		qu.push_back(query{x,y,z});
	}
	//dp[i][j] : i番目までで重さの総和jの場合の最大の価値
	sort(qu.begin(), qu.end(), [](query x, query y) {return min(x.s, y.s - x.w) > min(y.s, x.s - y.w); });
	rep(i, n) {
		rep(j, 20010) {
			if (qu[i].s >= j)
				dp[i + 1][j + qu[i].w] = max(dp[i + 1][j + qu[i].w], dp[i][j] + qu[i].v);
			dp[i + 1][j] = max(dp[i][j],dp[i+1][j]);
		}
	}
	rep(i, 20010)ans = max(ans,dp[n][i]);
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 166144
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define l long
#define pb push_back
#define mp make_pair
#define mt make_tuple
int main() {
	// your code goes here
	//ifstream cin("input.txt");
	//ofstream cout("output.txt");
	ios_base::sync_with_stdio(false); 
    cin.tie(NULL); 
	
	int n,p; cin>>n>>p;
	string s; cin>>s;
	ll sum = 0, q=1, ans=0;
	if(p==2)
	{
	    for(int i=0;i<n;i++)
	    {
	        if( (s[i]-'0')%2 == 0 ) ans+=(i+1);
	    }
	    cout<<ans; return 0;
	}
	if(p==5)
	{
	    for(int i=0;i<n;i++)
	    {
	        if( (s[i]-'0')%5 == 0 ) ans+=(i+1);
	    }
	    cout<<ans; return 0;
	}
	ll m[p]; memset(m,0,sizeof(m));
	m[0]++;
	for(int i=n-1;i>=0;i--)
	{
	    sum = ( sum + (s[i]-'0')*q )%p;
	    ans += m[sum];
	    m[sum]++;
	    q *= 10; q%=p;
	    
	}
	cout<<ans;
	return 0;
}


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

using namespace std;
using ll =long long;
using db = double;
using vll = vector<long long>;

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; }
#define che(a,string) cout<<"//"<<string <<"=="<<(a)<<"//" <<endl;
#define SORT(a) sort((a).begin(),(a).end())
#define rSORT(a) reverse((a).begin(),(a).end())
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define leftunique(a) {SORT(a);(a).erase(unique((a).begin(),(a).end()),(a).end());}
//leftuniqueは配列から同じ要素のものを取り除く 例 4 6 2 1 3 4 1 2 なら 1 2 3 4 6 になる
#define debug(x)  cout << #x << " = " << (x) << endl;
bool IsInt(double a){int b = a/1;if(a==b){return true;}else {return false;}}
bool coY() {cout <<"Yes"<<endl;}
bool coN(){cout <<"No"<<endl;}
const int mod = 1e9 + 7;
const ll INF = 1LL << 60;
// a^n mod を計算する
long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
//グラフ用
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};	
//ここから書き始める

ll combination(ll n, ll i){
	ll count = 0;
	ll multi = 1;
	ll div =1;
	int limit = i;
	while(count < limit){
		multi *= n;
		n--;
		multi/= count+1;
		count ++ ;
	}
	return multi / div;
}

struct point{
	int x ;
	int y;
};
int main()
{
	cout <<setprecision(10);
	point S , G;
	cin >>S.x >> S.y >> G.x >> G.y;
	vector<string> road(4,"");
	
	int X , Y ;
	X = G.x - S.x;
	Y = G.y - S.y;
	//まず、ずっと→ の次に 上で行く経路J
	//G.x - S.x 個 、右に移動する
	rep(i,X){
		road[0] += 'R';
	}
	rep(i,Y){
		road[0] += 'U';
	}
	//一つ道順が求まった

	//二つ目は戻る道（遠回りで戻る）
	//まず右に一歩、下に Y+1  回 → 次に、左に X+1 回 最後に上に一回
	//road[1]
	road[1] += 'R';
	rep(i,Y+1){
		road[1] +='D';
	}
	rep(i,X+1){
		road[1] += 'L';
	}
	road[1] += 'U';

	//次はずっと上からの右
	rep(i,Y){
		road[2] +='U';
	}
	rep(i,X) road[2] +='R';

	//最後は、戻る道順上1左X+1 下Y+1 右1
	road[3] += 'U';
	rep(i,X+1) road[3] += 'L';
	rep(i,Y+1) road[3] += 'D';
	road[3] +='R';

	for(auto x : road){
		cout << x ;
	}
	cout << endl;
}


Measured memory_bytes: 256
from sys import stdin, setrecursionlimit


def main():
    INF = float('inf')
    input = stdin.buffer.readline
    n = int(input())
    b = list(map(int, input().split()))
    b.insert(0, INF)
    b.append(INF)
    a = [0] * n

    for i in range(n):
        a[i] = min(b[i], b[i + 1])

    print(sum(a))


if __name__ == "__main__":
    setrecursionlimit(10000)
    main()


Measured memory_bytes: 38384
from fractions import *
n,*a=map(int,open(0).read().split())
l=[0]+[a[0]]*(n-1)
r=[a[-1]]*(n-1)+[0]
ans=0
for i in range(2,n):
  l[i]=gcd(l[i-1],a[i-1])
for i in range(n-3,-1,-1):
  r[i]=gcd(r[i+1],a[i+1])
ans=max(l[n-1],r[0])
for i in range(1,n-1):
  ans=max(ans,gcd(l[i],r[i]))
print(ans)

Measured memory_bytes: 16144
function memoit(f::Function, param)
    if !isdefined(Main, :memoit_cache)
        global memoit_cache = Dict{Function, Dict{Any, Any}}()
    end
    cache = haskey(memoit_cache, f) ? memoit_cache[f] : memoit_cache[f] = Dict()
    haskey(cache, param) ? cache[param] : cache[param] = f(param)
end

macro memo(arg)
    return quote
        memoit($(esc(arg.args[1])), $(esc(arg.args[2])))
    end
end

read(T) = parse(T, readline())
reads(T) = map(x->parse(T,x),split(readline()))

function dp(n::Int)
    ret = 1000000000
    if (n == 1) ret = 0 end
    if (n > 1) ret = min(ret, ((@memo dp(n-1)) + abs(v[n] -  v[n-1]))) end
    if (n > 2) ret = min(ret, ((@memo dp(n-2)) + abs(v[n] -  v[n-2]))) end
    ret
end

function main()
    n = read(Int)
    global v = reads(Int)
    println(dp(n))
end

main()


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

using namespace std;

#define DUMP(x) std::cout << (#x) << " = " << (x) << "\n"
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define REP(i, k, n) for (int i = (k); i < (int)(n); ++i)
#define ALL(r) r.begin(), r.end()
#define YES puts("YES")
#define Yes puts("Yes")
#define NO puts("NO")
#define No puts("No")
#define IMP puts("IMPOSSIBLE")
#define Imp puts("Impossible")
#define imp puts("impossible")
#define pb push_back

template <typename T>
T dup(T x, T y)
{
    return (x + y - 1) / y;
};
template <typename A, size_t N, typename T>
inline void arrayFill(A (&array)[N], const T &val) { std::fill((T *)array, (T *)(array + N), val); }
template <class T>
inline bool chmax(T &a, T b)
{
    if (a < b)
    {
        a = b;
        return true;
    }
    return false;
}
template <class T>
inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return true;
    }
    return false;
}

using ll = int64_t;
using vint = vector<int32_t>;
using vvint = vector<vint>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vstr = vector<string>;
using pint = pair<int32_t, int32_t>;
using pll = pair<ll, ll>;
using vpint = vector<pint>;
using vpll = vector<pll>;
using sint = set<int32_t>;
using sstr = set<string>;
using qint = queue<int32_t>;

constexpr std::int32_t INF = 1001001001;
constexpr std::int64_t LINF = 1001001001001001001;

void Main()
{
    int a, b;
    cin >> a >> b;
    if (max(a, b) <= 8)
        puts("Yay!");
    else
        puts(":(");
}

int main()
{
    std::cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define N 3005
 
using namespace std;
 
const int mod = 998244353;
 
int n, S;
int a[N], f[N];
 
int main() {
	scanf("%d %d", &n, &S);
	for(int i = 1; i <= n; ++i)
		scanf("%d", &a[i]);
	
	int ans = 0;
	for(int i = 1; i <= n; ++i) {
		if(a[i] > S) continue;
		else if(a[i] == S) {
			ans = (ans + 1LL * i * (n - i + 1)) % mod;
		} else {
			ans = (ans + 1LL * f[S - a[i]] * (n - i + 1)) % mod;
			for(int j = S; j > a[i]; --j)
				(f[j] += f[j - a[i]]) %= mod;
			f[a[i]] = (f[a[i]] + i) % mod;
		}
	}
	
	printf("%d\n", ans);
	return 0;
}

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

using namespace std;

int ans[500][500];
int n[500] = {0};

int main(void)
{
    int N;
    cin >> N;
    bool is_nok = true;
    int k;
    for (k = 1; k * (k + 1) < 200000; k++) if (N == k * (k + 1) / 2) { is_nok = false; break; }
    if (is_nok)
    {
        cout << "No" << endl;
        return 0;
    }
    int l = 0, r = 1;
    for (int i = 0; i < N; i++)
    {
        ans[l][n[l]] = ans[r][n[r]] = i + 1;
        n[l]++;
        n[r]++;
        if (r - l == 1)
        {
            l = 0;
            r++;
        }
        else l++;
    }
    cout << "Yes" << endl;
    cout << k + 1 << endl;
    for (int i = 0; i <= k; i++)
    {
        cout << k;
        for (int j = 0; j < k; j++) cout << " " << ans[i][j];
        cout << endl;
    }
    return 0;
}

Measured memory_bytes: 2304
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <numeric> // accumulate(v.begin(), v.end(), 0)

using namespace std;
#define ll long long

int main() {
  int R, G, B, N;
  cin >> R >> G >> B >> N;
  ll ans = 0;
  for(int r=0; r<=N/R; r++) {
    for(int g=0; g<=(N-R*r)/G; g++) {
      if((N-R*r-G*g) % B == 0)
	ans++;
    }
  }
  cout << ans << endl;
  return 0;
}


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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}

int nextInt() { int x; scanf("%d", &x); return x;}
ll nextLong() { ll x; scanf("%lld", &x); return x;}


ll sum(ll a, ll b) {
  return (a+b) * (b-a+1) / 2;
}

const int MAX_N = 112345;
int A[3 * MAX_N];

int main2() {
  int N = nextInt();
  int K = nextInt();
  if (sum(K, K+2*N-1) <= sum(K+2*N, K+3*N-1)) {
    REP(i, 3*N) A[i] = K + i;
    for (int i = 0; i < N; i++) {
      int a, b, c;
      if (i % 2 == 0) {
        a = A[i/2];
        b = A[2*N-(N+1)/2+i/2];
        c = A[2 * N + i];
      } else {
        a = A[(N+1)/2 + i/2];
        b = A[N + i/2];
        c = A[2 * N + i];
      }
      printf("%d %d %d\n", a, b, c);
    }
  } else {
    cout << -1 << endl;
  }
  return 0;
}

int main() {

#ifdef LOCAL
  for (;!cin.eof();cin>>ws)
#endif
    main2();
  return 0;
}


Measured memory_bytes: 3456
# -*- coding: utf-8 -*-
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys

def s():
    return raw_input().strip()
def n():
    return int(raw_input())
def d():
    return float(raw_input())

def ls():
    return raw_input().strip().split()
def ln():
    return map(int, raw_input().strip().split())
def ld():
    return map(float, raw_input().strip().split())

def fs():
    return [raw_input().strip() for i in xrange(input())]
def fn():
    return [int(raw_input().strip()) for i in xrange(input())]
def fd():
    return [float(raw_input().strip()) for i in xrange(input())]

S = s()

count = 0
before = S[0]
for c in S:
    if c != before:
        count += 1
        before = c

print count


Measured memory_bytes: 14956
using System;
using System.Collections.Generic;
using static Assistant.Input;
using static Assistant.Debug;
using System.Linq;
using Assistant;
using System.Numerics;

namespace ABC169C
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] s = Console.ReadLine().Split();
            var A = decimal.Parse(s[0]);
            var B = decimal.Parse(s[1]);

            decimal ans = (A * B);
            ans = Math.Floor(ans);
            Console.WriteLine(ans);
        }


    }


}

namespace Assistant
{
    static class Input
    {
        static List<string> line = new List<string>();
        static int index = 0;
        static String RNext()
        {
            if (line.Count <= index) line.AddRange(Console.ReadLine().Split());
            return line[index++];
        }
        public static int RInt => int.Parse(RNext());
        public static long RLong => long.Parse(RNext());
        public static int[] RInts => Console.ReadLine().Split().Select(int.Parse).ToArray();
        public static long[] RLongs => Console.ReadLine().Split().Select(long.Parse).ToArray();
        public static string RString => RNext();
        //以下未テスト
        public static int[] RIntsC(int c) => Enumerable.Repeat(0, c).Select(x => int.Parse(RNext())).ToArray();
        public static long[] RLongsC(int c) => Enumerable.Repeat(0, c).Select(x => long.Parse(RNext())).ToArray();
        public static char[][] RMap(int h) => Enumerable.Repeat(0, h).Select(x => Console.ReadLine().ToCharArray()).ToArray();
    }

    static class Debug
    {
        static public void Draw2D<T>(T[,] map, int mode = 1)
        {
#if DEBUG
            int W = map.GetLength(0);
            int H = map.GetLength(1);

            string[,] map2 = new string[W + 1, H + 1];
            for (int i = 0; i < W + 1; i++)
            {
                for (int j = 0; j < H + 1; j++)
                {
                    if (i == 0 && j == 0) map2[i, j] = 0.ToString();
                    else if (i == 0) map2[i, j] = (j - 1).ToString();
                    else if (j == 0) map2[i, j] = (i - 1).ToString();
                    else map2[i, j] = map[i - 1, j - 1].ToString();
                }
            }

            for (int i = 0; i < W + 1; i++)
            {
                for (int j = 0; j < H + 1; j++)
                {
                    if (mode == 0) Console.Write(map2[i, j].Last());
                    if (mode == 1) Console.Write(map2[i, j] + " ");
                }
                Console.WriteLine();
            }
            Console.WriteLine();
#endif
        }

        public static void Draw1D<T>(T[] array, int mode = 0)
        {
#if DEBUG
            Console.WriteLine(string.Join(" ", array));
#endif
        }
    }
}


Measured memory_bytes: 27592
n,k=map(int,input().split())
h=list(map(int,input().split()))
 
cost=[0]*n
for i in range(1,n):
  cost[i]=min( [cost[i-j]+abs(h[i]-h[i-j]) for j in range(1,min(i+1,k+1))] )
print(cost[-1])

Measured memory_bytes: 85408
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC optimize("-Ofast")
#include <bits/stdc++.h>
using namespace std;
typedef int in;
#define int long long
#define pb push_back
#define f first
#define s second
const int MAX=1005;
const int MAAX=1e9;
const int MOD=1e9+7;
int a[MAX],n,m;
int dp[MAX][(1<<12)+3],cost[1005];
int fun(int idx,int mask)
{
    if((1ll<<n)-1==mask) return 0;
    if(idx==m) return MAAX;
    int &ret=dp[idx][mask];
    if(ret!=-1)
    {
        return ret;
    }
    ret=cost[idx]+fun(idx+1,mask|a[idx]);
    return ret=min(ret,fun(idx+1,mask));

}
in main()
{
    memset(dp,-1,sizeof dp);
cin>>n>>m;
int sz,x,curmask;
for(int i=0;i<m;i++)
{
    cin>>cost[i]>>sz;
    curmask=0;
    while(sz--)
    {
       cin>>x;
       curmask|=(1<<(x-1));

    }
    a[i]=curmask;
}
int ans=fun(0,0);
if(ans>=MAAX)
{
    cout<<-1<<endl;
    return 0;
}
cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 32512
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <cstring>
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <cmath>
#include <numeric>
#include <float.h>
using namespace std;
// repマクロの定義
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
// allマクロの定義
#define all(v) v.begin(), v.end()
typedef unsigned long long ll;

int main(){
	int N; cin >> N;
	vector<int> d(N);
	rep(i,N) cin >> d[i];
	set<int> S;
	rep(i,N){
		S.insert(d[i]);
	}
	cout << S.size() << endl;
}	

Measured memory_bytes: 256
#include <iostream>
#include<string>
#include<cmath>
#include<ciso646>
#include<cstring>
#include<iomanip>
#include<vector>
#include<algorithm>
#include<utility>
#include<map>
#include<math.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
using ll = long long;
int Max = 10 + 1e8;
int main() 
{
	int n;
	cin >> n;
	map<string, int> aa;
	rep(i, n) {
		string s; cin >> s;
		aa[s]++;
	}
	cout << "AC x "<<aa["AC"] << endl;
	cout << "WA x "<<aa["WA"] << endl;
	cout << "TLE x "<<aa["TLE"] << endl;
	cout << "RE x "<<aa["RE"] << endl;

}

Measured memory_bytes: 3604
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<ii> vii;
typedef set<int> si;
typedef map<string, int> msi;
#define REP(i,a,b) \
for(int i=int(a);i<=int(b);i++)
#define DEP(i,a,b) \
for(int i=int(a);i>=int(b);i--)
#define TRvi(c, it) \
for (vi::iterator it = (c).begin(); it != (c).end(); it++)
#define TRvii(c, it) \
for (vii::iterator it = (c).begin(); it != (c).end(); it++)
#define TRmsi(c, it) \
for (msi::iterator it = (c).begin(); it != (c).end(); it++)



int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	
	    ll n,i,j,k,l;
	    cin>>n>>k;
	    i=n/k;
	    cout<<min(abs(n-i*k),abs(n-(i+1)*k));
	    
	
	return 0;
}


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

int main(void){
    int N;cin>>N;
    string S;cin>>S;
    int ans=0;
    for(int i=1;i<N;i++){
        vector<int>A(26,0);
        vector<int>B(26,0);
        int tmp=0;
        for(int j=0;j<=i;j++){
            A[(int)S[j]-97]++;
        }
        for(int j=i+1;j<N;j++){
            B[(int)S[j]-97]++;
        }
        for(int j=0;j<26;j++){
            if(A[j]>=1&&B[j]>=1){
                tmp++;
            }
        }
        ans=max(ans,tmp);
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3640
//Burn It Dowwwnnnnn.....................
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")
#include<bits/stdc++.h>
#define pi acos(-1)
using namespace std;
long long int MX=1e18;
long long int MN=-MX;
long long int vv[1000001];
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    long long int i,j,k,l,b,c,d,q,s,n,m,o,p,tc=1,jj,z,aa,r;
//    cin>>tc;
    for(jj=0; jj<tc; jj++)
    {
        p=0;
        z=MX;
        map<long long int,long long int>uu;
        stack<char>ss;
        k=0;
        string a,str;
        cin>>a>>str;
        for(i=0;a[i];i++)
        {
            if(i>a.size()-str.size())
            {
                break;
            }
            p=0;
            for(j=0;str[j];j++)
            {
                if(a[i+j]!=str[j])
                {
                    p++;
                }
            }
            if(p<z)
            {
                z=p;
            }
        }
        cout<<z<<endl;
    }
}




Measured memory_bytes: 3664
#include <stdio.h>
#include <math.h>
 
int s[1002];
 
#define gc() getchar_unlocked()
int in()
{
    int n = 0, c = gc();
    do n = 10*n + (c & 0xf), c = gc();
    while (c >= '0');
    return n;
}
 
int main()
{
    int n, i, is;
    double m, fs, a;
     
    while (n = in()) {
        is = 0; for (i = 0; i < n; i++) is += s[i] = in();
        m = (double)is/n;
        fs = 0; for (i = 0; i < n; i++) {
            a = s[i]-m;
            fs += a*a;
        }
        printf("%.8lf\n", sqrt(fs/n));
    }
    return 0;
}


Measured memory_bytes: 2148
#include<bits/stdc++.h>
#define fo(i,a,b) for(int i= a ; i < b ; ++i)
#define rep(i,n) fo(i,0,n)
#define pln(n) printf("%lld",n)
#define sll(n) scanf("%lld",&n)
#define ss(n) scanf("%s",n)
#define vi vector < int >
#define ll long long
#define pii pair < ll , ll >
#define pb push_back
#define mp make_pair
#define ull unsigned long long
#define INF 0x3f3f3f3f
#define dbg(x) { cout<< #x << ": " << (x) << endl; }
#define dbg2(x,y) { cout<< #x << ": " << (x) << " , " << #y << ": " << (y) << endl; }
#define dbg3(x,y,z) { cout<< #x << ": " << (x) << " , " << #y << ": " << (y) <<" , "<< #z <<": "<<(z)<<endl; }
#define all(x) x.begin(),x.end()
#define sz(x) (int)x.size()
#define vll vector<long long>
#define vvll vector<vector<long long>>
#define vvvll vector<vector<vector<ll>>>
#define si set<int>
#define tr(c, it) \
for(decltype(c.begin()) it = c.begin(); it!= c.end(); it++)
#define pis pair<int,string>
#define present(c, x) (c.find(x) != c.end())
#define cpresent(c, x) (find(all(c),x) != c.end())
#define  ones(x)  __builtin_popcount(x)
using namespace std;


int main(){
    ll a,b,n;
    cin >> a>>b>>n;
    ll f = floor(a*(min(b-1,n))/b) - (ll)a*floor((min(b-1,n))/b);
    cout << f;


}

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

int main(){
  int A,B;
  cin >> A >> B;
  
  if(A%3 == 0 || B%3 == 0 || (A+B)%3 == 0) {
    cout << "Possible" << endl;
  }
  else {
    cout << "Impossible" << endl;
  }
}


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

using lint = long long;

int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    int a, b, c;
	cin >> a >> b >> c;
	int k = a - b;
	if (k >= c) cout << "0\n";
	else cout << c - k << '\n';
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define rep2(i, s, n) for(int i=s; i<(n); ++i)
#define ALL(v) (v).begin(), (v).end()

using namespace std;

typedef long long ll;

static const int INTINF = (2147483647);
static const ll LLINF = (9223372036854775807);
static const int MAX = 1e5+1;
static const ll MOD = 1e9+7;

namespace Printer{
    template<class T>
    void print(T x){
        cout << x << endl;
    }

    template<class T>
    void print(T x, T y){
        cout << x << "," << y << endl;
    }

    template<class T>
    void print(vector<T> v){
        rep(i, v.size()){
            if(i) cout << " ";
            cout<< v[i];
        }
        cout << endl;
    }

    template<class T>
    void print(vector<vector<T> > vv){
        rep(i, vv.size()){
            rep(j, vv[i].size()){
                if(j) cout << " ";
                cout << vv[i][j];
            }
            cout << endl;
        }
    }

    void print(pair<int, int> p){
        cout << "(" << p.first << ", " << p.second << ")" << endl;
    }
};
using namespace Printer;

//--global--//



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

int main(int argc, const char * argv[]) {
    //提出時、消す----//

    int h, w;
    vector<string> vv;
    cin >> h >> w;
    rep(i, h){
        string str;
        cin >> str;
        vv.push_back(str);
    }
    vector<vector<int> > dp(h, vector<int>(w));
    dp[0][0] = 1;
    rep(i, h){
        rep(j, w){
            if(j-1 >= 0 && i-1 >= 0 && vv[i-1][j] == '.' && vv[i][j-1] == '.'){
                dp[i][j] = dp[i][j-1] + dp[i-1][j];
            }
            else{
                if(j-1 >= 0 && vv[i][j-1] == '.'){
                    dp[i][j] = dp[i][j-1];
                }
                if(i-1 >= 0 && vv[i-1][j] == '.'){
                    dp[i][j] = dp[i-1][j];
                }
            }
            dp[i][j] %= MOD;
        }
    }

    print(dp[h-1][w-1]);
    
    return 0;
}


Measured memory_bytes: 5248
import java.util.*;
import java.io.*;

public class Main {
    static ArrayList<ArrayList<Integer>>cycles;
    static ArrayList<Long>cost;
    static boolean[]vis;
    static int[]c,a;
    static void dfs(int i,long cos,ArrayList<Integer>cur){
        cos+=c[i];
        cur.add(i);
        vis[i]=true;
        if (vis[a[i]]) {
           cycles.add(cur);
           cost.add(cos);
        }
        else {
            dfs(a[i],cos,cur);
        }
    }
    static long calcbest(int op,ArrayList<Integer>here,long all){
        long ans=-(long)1e18;
        for (int i =0;i<here.size();i++){
            int j = i;
            j++;
            j%=here.size();
            long cur= c[here.get(i)];
            int cc=1;
            ans=Math.max(ans,cur);
            ans=Math.max(ans,cur+(all)*((op-cc)/here.size()));
            while (j!=i){
                cc++;
                if (cc>op)
                    break;
                cur+=c[here.get(j)];
                ans=Math.max(ans,cur);
                ans=Math.max(ans,cur+(all)*((op-cc)/here.size()));
                j++;
                j%=here.size();
            }
        }
        return ans;
    }
    public static void main(String[] args) throws IOException {
        Scanner sc = new Scanner(System.in);
        PrintWriter pw = new PrintWriter(System.out);
        int n = sc.nextInt();
        int k = sc.nextInt();
        a= sc.nextIntArr(n);
        c= sc.nextIntArr(n);
        for (int i =0;i<n;i++)a[i]--;
        cycles= new ArrayList<>();
        cost= new ArrayList<>();
        vis= new boolean[n];
        for (int i =0;i<n;i++){
            if (!vis[i])
                dfs(i,0,new ArrayList<>());
        }
        long ans = (long)-1e18;
        for (int i =0;i<cycles.size();i++){
            ans=Math.max(ans,calcbest(k,cycles.get(i),cost.get(i)));
        }
//        System.err.println(cycles);
//        System.err.println(cost);
        pw.println(ans);
        pw.close();

    }



    static class Scanner {
        BufferedReader br;
        StringTokenizer st;

        public Scanner(InputStream s) {
            br = new BufferedReader(new InputStreamReader(s));
        }

        public String next() throws IOException {
            while (st == null || !st.hasMoreTokens())
                st = new StringTokenizer(br.readLine());
            return st.nextToken();
        }

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

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

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

        public int[] nextIntArr(int n) throws IOException {
            int[] arr = new int[n];
            for (int i = 0; i < n; i++) {
                arr[i] = Integer.parseInt(next());
            }
            return arr;
        }

    }

}

Measured memory_bytes: 38704
#include <stdint.h>
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <tuple>
#include <utility>
#include <vector>

using namespace std;

typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
static const double EPS = 1e-12;
static const double PI = acos(-1.0);
static const ll MOD = 1000000007;

#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(a) (a).begin(), (a).end()
#define DEBUG(x) cout << #x << ": " << x << endl

ll calc_score(ll D, const vector<ll> &c, const vector<vector<ll>> &s, const vector<ll> &t) {
  vector<ll> last(26, 0);
  ll score = 0;
  REP(d, D) {
    ll i = t[d] - 1;
    score += s[d][i];
    last[i] = d + 1;
    REP(j, 26) {
      score -= c[j] * (d + 1 - last[j]);
    }
  }
  return score;
}

ll calc_diff(ll D, ll pre, ll next, const vector<ll> &c, const vector<vector<ll>> &s, ll d, const vector<ll> &t) {
  ll diff = s[d - 1][next] - s[d - 1][pre];
  {
    ll l = 0;
    for (int i = d - 1; i >= 1; i--) {
      if (t[i - 1] - 1 == next) {
        l = i;
        break;
      }
    }
    ll r = D + 1;
    FOR(i, d + 1, D + 1) {
      if (t[i - 1] - 1 == next) {
        r = i;
        break;
      }
    }
    ll x = r - d;
    ll y = d - l;
    diff += c[next] * x * y;
  }
  {
    ll l = 0;
    for (int i = d - 1; i >= 1; i--) {
      if (t[i - 1] - 1 == pre) {
        l = i;
        break;
      }
    }
    ll r = D + 1;
    FOR(i, d + 1, D + 1) {
      if (t[i - 1] - 1 == pre) {
        r = i;
        break;
      }
    }
    ll x = r - d;
    ll y = d - l;
    diff -= c[pre] * x * y;
  }
  return diff;
}

void solve(ll D, vector<ll> c, vector<vector<ll>> s, vector<ll> t) {
  ll score = calc_score(D, c, s, t);
  ll M;
  scanf("%lld", &M);
  REP(i, M) {
    ll d;
    scanf("%lld", &d);
    ll q;
    scanf("%lld", &q);
    ll pre = t[d - 1] - 1;
    ll next = q - 1;
    t[d - 1] = next + 1;

    score += calc_diff(D, pre, next, c, s, d, t);
    cout << score << endl;
  }
}

int main() {
  ll D;
  scanf("%lld", &D);
  vector<ll> c(26);
  for (int i = 0; i < 26; i++) {
    scanf("%lld", &c[i]);
  }
  vector<vector<ll>> s(D, vector<ll>(26));
  for (int i = 0; i < D; i++) {
    for (int j = 0; j < 26; j++) {
      scanf("%lld", &s[i][j]);
    }
  }
  vector<ll> t(D);
  for (int i = 0; i < D; i++) {
    scanf("%lld", &t[i]);
  }
  solve(D, move(c), move(s), move(t));
  return 0;
}


Measured memory_bytes: 3756
#include <bits/stdc++.h>
#define S second
#define F first
#define ll long long

using namespace std;

const ll N = 2e5 + 5, M = 1e6 + 5;

ll parent[N], sz[N], out[N], ans;
vector<pair<int, int> > edges;

ll cnt(ll x)
{
    return x * (x - 1) / 2;
}

ll getParent(ll u)
{
    if(parent[u] == u) return u;
    return parent[u] = getParent(parent[u]);
}

void connect(ll u, ll v)
{
    u = getParent(u);
    v = getParent(v);
    if(parent[u] == parent[v]) return;
    ans -= cnt(sz[u]);
    ans -= cnt(sz[v]);
    if(sz[u] < sz[v]) swap(u, v);
    sz[u] += sz[v];
    ans += cnt(sz[u]);
    parent[v] = u;
}

int main()
{
    ll n, m, u, v;
    scanf("%lld%lld", &n, &m);
    iota(parent + 1, parent + n + 1, 1);
    fill(sz + 1, sz + n + 1, 1);
    for(ll i = 0 ; i < m ; i++)
    {
        scanf("%lld%lld", &u, &v);
        edges.emplace_back(u, v);
    }
    for(ll i = m - 1 ; ~i ; i--)
    {
        out[i] = cnt(n) - ans;
        connect(edges[i].F, edges[i].S);
    }
    for(int i = 0 ; i < m ; i++) printf("%lld\n", out[i]);
    return 0;
}


Measured memory_bytes: 5492
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = s; i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << '\n';
#define CFYN(n) cout << ( (n) ? "YES":"NO") << '\n';
#define OUT(n) cout << (n) << '\n';
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;

int main(void)
{
    IOS

    int a, b;
    cin >> a >> b;
    OUT(a*b-a-b+1)

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <bitset>
#include<vector>
#include<utility>
#include<fstream>
#include<queue>
#include <iomanip>
#include<numeric>
#include<set>
using namespace std;
typedef long long ll;
#define rep(i,k) for(i=0;i<k;i++)
#define P pair<ll,ll>
ll mod = 1000000007;
P p[200005];

ll i, b[1005], c, k, j, n, m, z = 0, mi = 0, t, cc, th;
ll a;
vector<ll> va, vb, vc, vj;
string s;
char ca[10000];
priority_queue<ll> q;




int main() {
	cin >> n;
	rep(i, n) {
		cin >> b[i];
		mi += b[i] * b[i];
		z += b[i];
	}

	cout <<( z * z -mi)/2 ;


	return 0;
}

Measured memory_bytes: 384
// Believe in yourself
#include<bits/stdc++.h>

using namespace std;

typedef unsigned long long int ull;
typedef long long int ll;
typedef long double ld;

#define PB push_back
#define MP make_pair
#define F first
#define S second
#define Pair vector<pair<ll,ll>>
#define vec vector <ll> 
#define all(a) a.begin(),a.end()
#define mo 1000000007
#define decimal(i,n) fixed << setprecision(i) << n
#define show(a) for(auto xyz:a)cout<<xyz<<" ";cout<<endl;
#define show_nl(a) for(auto xyz:a)cout<<xyz<<endl;


void eea(ll a,ll b,ll &x,ll &y)
{
    if (a == 1)
    {
        x = 1; y = 0;
        return;
    }
    ll x1, y1;
    eea(b%a,a,x1,y1);
    x=y1-(b/a)*x1;
    y=x1;
}
ll mi(ll a,ll m)
{
    ll x,y;
    eea(a,m,x,y);
    x= (x%m+m)%m;
    return x;
}

/*
Enter the test case


Some helpful points
1.) Calm yourself
2.) check for semicolon or data type mismatch
*/


int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);    
    ll t=1;
    // cin>>t;
    while(t--)
    {
        ll h,n;
        cin>>h>>n;
        ll a,b,p=1,q=1;
        vector <pair <ll,ll>> v;
        cin>>p>>q;
        v.PB(MP(p,q));
        for(ll i=1;i<n;i++)
        {
            cin>>a>>b;
            v.PB(MP(a,b));
            if(p<a)
            {
            p=a;
            q=b;
            }
        }
        sort(all(v));
        ll dp[h+p+5];
        for(int i=0;i<=h+p+1;i++)
        dp[i]=1000000000;
        for(ll i=1;i<=h+p+1;i++)
        {
            for(ll j=0;j<n;j++)
            {
                if(i-v[j].F<=0)
                {
                    dp[i]=min(dp[i],v[j].S);
                }
                else
                {
                    dp[i]=min(dp[i],dp[i-v[j].F]+v[j].S);
                }
            }
        }
        ll ans=dp[h];
        for(ll i=h;i<=h+p;i++)
        {
            ans=min(ans,dp[i]);
        }
        cout<<ans<<"\n";
    }
}



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

using namespace std;

#define int long long
#define FOR(i, a, b) for(ll i = (a); i < (b); ++i)
#define FORR(i, a, b) for(ll i = (a); i > (b); --i)
#define REP(i, n) for(ll i = 0; i < (n); ++i)
#define REPR(i, n) for(ll i = n; i >= 0; i--)
#define FOREACH(x, a) for(auto &(x) : (a))
#define VECCIN(x)                                                              \
    for(auto &youso_ : (x)) cin >> youso_
#define bitcnt __builtin_popcount
#define SZ(x) ((ll)(x).size())
#define fi first
#define se second
#define All(a) (a).begin(), (a).end()
template <typename T = long long> inline T IN() {
    T x;
    cin >> x;
    return (x);
}
inline void CIN() {}
template <class Head, class... Tail>
inline void CIN(Head &&head, Tail &&... tail) {
    cin >> head;
    CIN(move(tail)...);
}
#define CINT(...)                                                              \
    int __VA_ARGS__;                                                           \
    CIN(__VA_ARGS__)
#define LCIN(...)                                                              \
    ll __VA_ARGS__;                                                            \
    CIN(__VA_ARGS__)
#define SCIN(...)                                                              \
    string __VA_ARGS__;                                                        \
    CIN(__VA_ARGS__)
#define Yes(a) cout << (a ? "Yes" : "No") << "\n"
#define YES(a) cout << (a ? "YES" : "NO") << "\n"
#define Printv(v)                                                              \
    {                                                                          \
        FOREACH(x, v) { cout << x << " "; }                                    \
        cout << "\n";                                                          \
    }
template <typename T = string> inline void eputs(T s) {
    cout << s << "\n";
    exit(0);
}
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
    std::fill((T *)array, (T *)(array + N), val);
}
template <typename T> using PQG = priority_queue<T, vector<T>, greater<T>>;
template <typename T> using PQ = priority_queue<T>;

typedef long long ll;
typedef unsigned long long ul;
typedef vector<ll> VL;
typedef pair<ll, ll> PL;

const int INF = 1e9;
const int MOD = 1e9 + 7;
// const int MOD = 998244353;
const ll LINF = 1e18 + 1;
const ll dx[] = {1, -1, 0, 0};
const ll dy[] = {0, 0, 1, -1};

ll N, L;

signed main() {
    cin >> N >> L;
    ll sum = 0, eat = LINF;
    FOR(i, L, L + N) {
        sum += i;
        if(abs(eat) > abs(i)) eat = i;
    }
    cout << sum - eat << "\n";
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main()
{
	char str[10001];
	while(scanf("%s",str) != EOF)
	{
		int i=2;
		int joi=0,ioi=0;
		while(str[i])
		{
			if(str[i-1] == 'O' && str[i] == 'I')
			{
				if(str[i-2] == 'J')
					joi++;
				else if(str[i-2] == 'I')
					ioi++;
			}
			i++;
		}
		printf("%d\n%d\n",joi,ioi);
	}
	return 0;
}

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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, m;
  cin >> n >> m;
  vector<vector<int>> g(n);
  for (int i = 0; i < m; i++) {
    int x, y;
    cin >> x >> y;
    --x; --y;
    g[x].push_back(y);
    g[y].push_back(x);
  }
  if (m % 2 == 1) {
    cout << -1 << '\n';
    return 0;
  }
  vector<pair<int, int>> res;
  vector<int> deg(n, 0);
  vector<int> depth(n, -1);
  function<void(int, int)> Dfs = [&](int v, int pr) {
    for (int u : g[v]) {
      if (depth[u] == -1) {
        depth[u] = depth[v] + 1;
        Dfs(u, v);
      } else {
        if (depth[u] > depth[v]) {
          res.emplace_back(v, u);
          ++deg[v];
        }
      }
    }
    if (deg[v] % 2 == 1) {

      res.emplace_back(v, pr);
      ++deg[v];
    } else {
      if (pr != -1) {
        res.emplace_back(pr, v);
        ++deg[pr];
      }
    }
  };
  depth[0] = 0;
  Dfs(0, -1);
  for (auto& p : res) {
    cout << p.first + 1 << " " << p.second + 1 << '\n';
  }
  return 0;
}


Measured memory_bytes: 14836
#include<bits/stdc++.h>
#define st first
#define nd second
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define umax(x,y) x=max(x,y)
#define umin(x,y) x=min(x,y)
#define ll long long 
#define ii pair<int,int>
#define iii pair<int,ii>
#define iiii pair<ii,ii>
#define sz(x) ((int) x.size())
#define orta ((bas+son)/2)
#define all(x) x.begin(),x.end()
#define pw(x) (1<<(x))
#define inf 1000000005
#define MOD 1000000007 
#define N 705
#define M 1000003
#define LOG 20
#define KOK 250
#define EPS 0.0000001
using namespace std;

int n;
int vis[N],a[N][N],cnt[3];
bool ok[N][N];

void dfs(int node,int grp) {

	if(vis[node]) {

		if(vis[node]!=grp) {

			printf("-1");

			exit(0);

		}

		return ;

	} 

	vis[node]=grp;

	++cnt[grp];

	for(int i=1;i<=n;i++) {

		if(!a[node][i]) dfs(i,3-grp);

	}

}

int main() {

	vector<ii> v;
	int m;

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

	for(int i=1;i<=m;i++) {

		int x,y;

		scanf("%d %d",&x,&y);

		a[x][y]=a[y][x]=1;

	}

	for(int i=1;i<=n;i++) a[i][i]=1;

	for(int i=1;i<=n;i++) {

		if(!vis[i]) {

			cnt[1]=cnt[2]=0;

			dfs(i,1);

			v.pb({cnt[1],cnt[2]});

		}

	}

	ok[0][0]=1;

	int sum=0;

	for(ii x:v) {

		for(int f=0;f<=sum;f++) {

			int s=sum-f;

			ok[f+x.st][s+x.nd]|=ok[f][s];
			ok[f+x.nd][s+x.st]|=ok[f][s];

		}

		sum+=x.st+x.nd;

	}

	for(int i=n/2;i>=1;i--) {

		if(ok[i][n-i]) {

			printf("%d",(i*(i-1)+(n-i)*(n-i-1))/2);

			return 0;

		}

	}

	printf("-1");

}

Measured memory_bytes: 2688
#include <iostream>
using namespace std;
int main(void){
    
    int num;
    char C;
    
    cin >> num;
    cin >> C;
    int ans = num;
    
    while(C != '='){
    cin >> num;
    if(C == '+') ans += num;
    else if(C == '-') ans -= num;
    else if(C == '*') ans *= num;
    else if(C == '/') ans /= num;
    cin >> C;
    }
    
    cout << ans << endl;
    
}


Measured memory_bytes: 3104
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
def s(): return input()
def i(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10**9)
mod = 10**9+7

N = i()
print(((1+N)*N)//2)

Measured memory_bytes: 9888
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <vector>
#include <cstring>
#include <cassert>
#include <cctype>
#include <array>
#include <algorithm>
#include <queue>

using lint = long long;

void solve() {
    int n; scanf("%d", &n);
    printf("%d\n", n/3);
}

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

	return 0;
}

Measured memory_bytes: 128
N = int(input())
hList = list(map(int, input().split()))

dp = [0] * N
dp[1] = abs(hList[1] - hList[0])
for index in range(2, N):
    dp[index] = min(dp[index-1] + abs(hList[index] - hList[index-1]),
                    dp[index-2] + abs(hList[index] - hList[index-2]))
print(dp[-1])

Measured memory_bytes: 52208
#include<stdio.h>
#include<string.h>
#include<stdbool.h>


int getgcd(int n, int m)
{
int r;
if (n > m) {
int t = m;
m = n;
n = t;
}
while ((r = m % n) != 0) {
m = n;
n = r;
}
return n;
}

int gcd(int a,int b,int c){
    int n;
    n=getgcd(getgcd(a,b),c);
    return n;
}

int main(void){
    int k;
    unsigned long long int sum=0; 
    scanf("%d",&k);
    for(int n=1;n<=k;n++){
        for(int i=1;i<=k;i++){
            for(int j=1;j<=k;j++){
                sum+=gcd(n,i,j);
            }
        }    
    }
    printf("%llu",sum);
    
}


Measured memory_bytes: 1736
N, M = [int(i) for i in input().split()]
A = {int(input()) for _ in range(M)}

dp = [0] * 101000
dp[0] = 1
dp[1] = 0 if 1 in A else 1

for i in range(2, N+1):
    if not i-1 in A:
        dp[i] += dp[i-1]
    if not i-2 in A:
        dp[i] += dp[i-2]
    dp[i] %= 1000000007

print(dp[N])


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

using namespace std;

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

Measured memory_bytes: 256
<?php
// https://atcoder.jp/contests/abc044/tasks/abc044_a


// fgets(STDIN)で標準入力,trimで改行を削除
$N = trim(fgets(STDIN));
$K = trim(fgets(STDIN));
$X = trim(fgets(STDIN));
$Y = trim(fgets(STDIN));

$count = 0;
if($N - $K >= 0){
  $count = $K * $X + ($N-$K) * $Y;
}else{
  $count = $N *$X;
}

echo $count."\n";

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

int main(){
  
  string s;
  cin >> s;
  int n = s.size();
  ll ans = 0;
  for(int bit=0;bit<(1<<n-1);bit++){
    ll num = s[0]-'0';
    rep(i,n-1){
      if(bit & (1<<i)){
        ans+=num;
        num = 0;
      }
      num = num*10 + s[i+1]-'0';
    }
    ans += num;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int a,b,c,d;
    scanf("%d %d %d",&a,&b,&c);
    d=a;
    a=b;
    b=d;
    d=a;
    a=c;
    c=d;
    printf("%d %d %d",a,b,c);
    return 0;
}

Measured memory_bytes: 128