akhauriyash/Code-Regression huggingface dataset:
#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>
#include <bitset>
#include <complex>
#include <cmath>
#include <array>
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;
typedef vector<pint> vpint;
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(){
	int a,b,c;
	cin>>a>>b>>c;
	if(a+b>=c)
		cout<<"Yes"<<endl;
	else
		cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 256
B1 = 97
B2 = 101
DIV = 1000000007

def init(r)
  f = Array.new(r){ Array.new }
  r.times do |i|
    f[i] = gets.chomp.split("").map(&:ord)
  end
  f
end

def calc(f, r, c)
  t1 = 1
  $c.times{ t1 = t1 * B1 % DIV }
  r.times do |i|
    e = 0
    $c.times do |j|
      e = e*B1 + f[i][j]
    end
    (0..c-$c).each do |j|
      $tmp[i][j] = e
      e = (e*B1 - t1*f[i][j] + f[i][j+$c] + DIV) % DIV if j < c - $c
    end
  end

  t2 = 1
  $r.times{ t2 = t2 * B2 % DIV }
  (0..c-$c).each do |j|
    e = 0
    $r.times{ |i| e = e*B2 + $tmp[i][j] }
    (0..r-$r).each do |i|
      $hash[i][j] = e
      e = (e*B2 - t2*$tmp[i][j] + $tmp[i+$r][j] + DIV) % DIV if i < r - $r
    end
  end
end

def check
  $h.times do |i|
    $w.times do |j|
      puts "#{i} #{j}" if $hash[i][j] % DIV == $key % DIV
    end
  end
end

$h, $w = gets.split.map(&:to_i)
$f1 = init($h)
$r, $c = gets.split.map(&:to_i)
$f2 = init($r)
if $h >= $r && $w >= $c
  $hash = Array.new($h){ Array.new($w, 0) }
  $tmp = Array.new($h){ Array.new($w, 0) }
  calc($f2,$r,$c)
  $key = $hash[0][0]
  calc($f1,$h,$w)
  check
end

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

typedef long long ll;

int main() {
    ll n, c0;
    cin >> n;
    vector<int> k(n), d(n);
    vector<vector<int>> p(n, vector<int>(20, 0)), c(n);
    rep(i, n) {
        cin >> k[i];
        rep(j, k[i]) {
            cin >> c0;
            p[c0][0] = i;
            c[i].push_back(c0);
        }
    }
    rep(i, 19) {
        rep(j, n) {
            p[j][i + 1] = p[p[j][i]][i];
        }
    }
    queue<pair<int, int>> que;
    que.push(make_pair(0, 0));
    while (!que.empty()) {
        auto p = que.front();
        que.pop();
        d[p.first] = p.second;
        rep(i, k[p.first]) {
            que.push(make_pair(c[p.first][i], p.second + 1));
        }
    }
    //rep(i, n) cout << "d[" << i << "]=" << d[i] << "\n";
    int q, u, v;
    cin >> q;
    rep(i, q) {
        cin >> u >> v;
        //cout << u << " " << v;
        if (d[u] > d[v]) swap(u, v);
        int dif = d[v] - d[u], j = 0;
        while (dif > 0) {
            if (dif & 1) v = p[v][j];
            dif /= 2;
            j++;
        }
        //cout << "-> " << u << " " << v << "\n";
        if (u == v) {
            cout << u << "\n";
            continue;
        }
        for (int j = 19; j >= 0; j--) {
            if (p[u][j] != p[v][j]) {
                u = p[u][j];
                v = p[v][j];
            }
        }
        cout << p[u][0] << "\n";
    }
}


Measured memory_bytes: 20788
import sys

def parent(i):
    return int(i/2)

def left(i):
    return 2 * i

def right(i):
    return (2 * i) + 1

if __name__ == "__main__":
    n = int(input())
    node = [None]
    node.extend(list(map(int, input().split())))
    for i in range(1,n+1):
        sys.stdout.write("node {}: key = {}, ".format(i, node[i])) 
        p = parent(i)
        if 0 < p <= n:
            sys.stdout.write("parent key = " + str(node[p]) + ", ")
        l = left(i)
        if 0 < l <= n:
            sys.stdout.write("left key = " + str(node[l]) + ", ")
        r = right(i)
        if 0 < r <= n:
            sys.stdout.write("right key = " + str(node[r]) + ", ")
        sys.stdout.write("\n")



Measured memory_bytes: 5648
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (int i = a; i < (int)b; i++)
#define all(v) v.begin(), v.end()
const int MOD = 1e9 + 7;
const int INF = 1e9;
//'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122

int main() {
    int n;
    cin >> n;
    ll sum = 0;
    rep(i, 1, n + 1) {
        if (i % 3 == 0) continue;
        if (i % 5 == 0) continue;
        sum += i;
    }
    cout << sum << endl;
    return 0;
}


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

#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <string>
#include <functional>
#include <math.h>
#include <map>
#include <queue>
#include <stack>

typedef long long ll;
typedef unsigned long long ull;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define RFOR(i,a,b) for(int i=(b-1);i>=(a);--i)
#define REP(i,n)   FOR(i,0,n)
#define RREP(i,n)   RFOR(i,0,n)
#define SORT(s) sort(s.begin(), s.end())
#define P pair<int, int>
#define mp make_pair

const double INF = 1e+09;
const int MOD = 1e9+7;

using namespace std;

template <typename _Ty>
ostream& operator << (ostream& ostr, const vector<_Ty>& v) {if (v.empty()) {ostr << "{ }"; return ostr;}
    ostr << "{" << v.front(); for (auto itr = ++v.begin(); itr != v.end(); itr++) {ostr << ", " << *itr;}
    ostr << "}";
    return ostr;}

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

int gcd(int a, int b){
   if (a%b == 0) return(b);
   else return(gcd(b, a%b));}

int lcm(int a, int b)
{return a * b / gcd(a, b);}

vector<int> uniq(vector<int> vec){
  sort(vec.begin(), vec.end());
  vec.erase(unique(vec.begin(), vec.end()), vec.end());
  return vec;}

  vector< ll > divisor(int64_t n) {
  vector< ll > ret;
  for(int64_t i = 1; i * i <= n; i++) {
    if(n % i == 0) {
      ret.push_back(i);
      if(i * i != n) ret.push_back(n / i);
    }
  }
  sort(begin(ret), end(ret));
  return (ret);
}


int main(void){
  ios::sync_with_stdio(false);
  ll x;
  cin >> x;
  vector<ll> div = divisor(x);
  ll size = div.size();
  ll a,b;
  ll ans_a, ans_b;
  a = 2, b = -1;
  REP(i, size){
    ll tmp = x/div[i];
    ll now = div[i];
    ll tmp_val = sqrt(sqrt(tmp));
    FOR(j, -tmp_val, tmp_val){
      b = j;
      a = now + j;
      if (pow(a, 4)+pow(a,3)*b+pow(a,2)*pow(b,2)+a*pow(b,3)+pow(b,4) ==tmp){
        ans_a = a;
        ans_b = b;
      }
    }
  }
  cout << ans_a << " " << ans_b << endl;
  return 0;
}



Measured memory_bytes: 4176
#include<iostream>
#include<vector>
#include<algorithm>

using namespace std;
typedef long long ll;

int main(){
    int n;
    cin >> n;
    vector<int> a(n + 1);
    vector<int> b(n);
    ll ans = 0;
    for (int i = 0; i < n + 1; i++)
    {
        cin >> a[i];
    }
    for (int i = 0; i < n; i++)
    {
        cin >> b[i];
    }
    for (int i = 0; i < n; i++)
    {
        if (b[i] > a[i])
        {
            b[i] -= a[i];
            ans += a[i];
            a[i] = 0;
            if (a[i + 1] > b[i])
            {
                a[i + 1] -= b[i];
                ans += b[i];
            }
            else
            {
                ans += a[i + 1];
                a[i + 1] = 0;
            }
        }
        else
        {
            a[i] -= b[i];
            ans += b[i];
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
#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 if (a == b)
      cout << "a == b" << endl;    
}
 


Measured memory_bytes: 3076
#include<iostream>
#include<string>

using namespace std;

int main(){
string str,com,p;
int q,a,b;

cin >>str >>q;
for(int t=0;t<q;t++){
cin >>com >>a >>b;
if(com=="print"){
cout <<str.substr(a,b-a+1) <<endl;
}
else if (com=="reverse"){
string tmp = str.substr(a,b-a+1);
int n = tmp.size();
for (int i=0;i<n;i++)str[i+a]=tmp[n-i-1];
}
else if (com=="replace"){
cin >>p;
str=str.replace(a,b-a+1,p);
}
}
return 0;

}

Measured memory_bytes: 3184
import sys
input = sys.stdin.readline
import heapq

def dijkstra(n, s, edges):
    hq = [(0, s)]
    cost = [float('inf')] * n
    cost[s] = 0
    while hq:
        c, v = heapq.heappop(hq)
        if c > cost[v]:
            continue
        for d, u in edges[v]:
            tmp = d + cost[v]
            if tmp < cost[u]:
                cost[u] = tmp
                heapq.heappush(hq, (tmp, u))
    return cost[-1]

def main():
    xs, ys, xt, yt = map(int, input().split())
    n = int(input())
    circles = []
    circles.append([xs, ys, 0])
    for _ in range(n):
        circles.append(list(map(int, input().split())))
    circles.append([xt, yt, 0])
    edges = [[] for _ in range(n + 2)]
    for i in range(n + 2):
        for j in range(i + 1, n + 2):
            dx = circles[i][0] - circles[j][0]
            dy = circles[i][1] - circles[j][1]
            d = (dx ** 2 + dy ** 2) ** 0.5
            r = circles[i][2] + circles[j][2]
            edges[i].append([max(0, d - r), j])
            edges[j].append([max(0, d - r), i])

    ans = dijkstra(n + 2, 0, edges)
    print(ans)
    
main()

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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"


#define long long long 


const int Maxn = 1e6 + 1;
long int Mod = 1e9 + 7;
 
template<typename T, typename T1>
T mod(T x, T1 p) {
    x %= p;
    if (x < 0)
        x += p;
    return x;
}

long int nCrModpDP(long int n, long int r, long int p) 
{ 
    long int C[r+1]; 
    memset(C, 0, sizeof(C)); 
  
    C[0] = 1; 
  
    for (long int i = 1; i <= n; i++) 
    { 
        for (long int j = min(i, r); j > 0; j--) 
  
            C[j] = (C[j] + C[j-1])%p; 
    } 
    return C[r]; 
} 

long int nCrModpLucas(long int n, long int r,long int p ) 
{ 
   
   if (r==0) 
      return 1; 
  
   long int ni = n%p, ri = r%p; 
  
   return (nCrModpLucas(n/p, r/p, p) * // Last digits of n and r 
           nCrModpDP(ni, ri, p)) % p;  // Remaining digits 
} 



    long int fact[Maxn];
    

    long int inv[Maxn], ifact[Maxn];
     
    // x must be relatively prime to p
    template<typename T>
    T inverse(T x, T p) {
        x = mod(x, p);
        if (x == 1)
            return x;
        return mod((1LL * (-p / x) * (inv[p % x] % p)) , p); 
        // Since inverse of p % x is already calculated.
    }
     
    

        long int NcR(int n, int r) {
        long int ret = (1LL * ifact[n - r] * ifact[r]) % Mod ;
    	ret = (1LL * ret * fact[n]) % Mod;
        return ret;
    }

int main(){
   IOS;

   long int x,y;
   cin>>x>>y;

   if((x+y) % 3)
   	return cout<<"0",0;

  	long int a = max(x,y);
  	long int b = min(x,y);

  	x = a;
  	y = b;

  	if(x - y > y)
  		return cout<<"0",0;

  	    fact[0] = 1;

  	for(long int i = 1; i < Maxn; i++) {
    	fact[i] = 1LL * fact[i - 1] * i % Mod;
    }

    ifact[0] = 1;
    for(long int i = 1; i < Maxn; i++) {
    	inv[i] = inverse(i, Mod);
    	ifact[i] = (1LL * ifact[i - 1] * inv[i]) % Mod;
    }

  	long int steps = (x + y) / 3;

  	long int one = 2*steps - x;
  	long int two = x - steps;

  	cout<<NcR(one+two,one);
   return 0;
}

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

using namespace std;
using namespace __gnu_cxx;

typedef double db;
typedef long long ll;
typedef pair<db, db> pdd;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
typedef unsigned long long ull;

#define F          first
#define S          second
#define pnl        printf("\n")
#define sz(x)      (int)x.size()
#define sf(x)      scanf("%d",&x)
#define pf(x)      printf("%d\n",x)
#define all(x)     x.begin(),x.end()
#define rall(x)    x.rbegin(),x.rend()
#define rep(i, n)  for(int i = 0; i < n; ++i)

const db eps = 1e-9;
const db pi = acos(-1);
const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
const int mod = 1000 * 1000 * 1000 + 7;

int n, w, V;
pair<int, int> arr[105];
ll dp[105][100005];

ll solve(int i, int has) {
    if (i == n) return (has >= V ? 0 : LL_INF);
    ll &ret = dp[i][has];
    if (~ret) return ret;
    ret = min(solve(i + 1, has), solve(i + 1, has + arr[i].S) + arr[i].F);
    return ret;
}

int main() {
    scanf("%d%d", &n, &w);
    for (int i = 0; i < n; ++i)
        scanf("%d%d", &arr[i].F, &arr[i].S);
    int l = 1, r = 100000, mid;
    while (l < r) {
        mid = l + (r - l + 1) / 2;
        memset(dp, -1, sizeof dp);
        V = mid;
        if (solve(0, 0) <= w) l = mid;
        else r = mid - 1;
    }
    cout << l << endl;
    return 0;
}


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

#include <iostream>
#include <fstream>

#include <iostream>
#include <limits.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>

#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <queue>
#include <unordered_map>
#include <unordered_set>

#define int long long
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPS(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define FOR(i, a, b) for (int i = (a), i##_len = (b); i <= i##_len; ++i)
#define REV(i, a, b) for (int i = (a); i >= (b); --i)
#define CLR(a, b) memset((a), (b), sizeof(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define INF 1001001001001001001ll
#define fcout cout << fixed << setprecision(12)

using namespace std;

template<typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }

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

template<typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T& t, const V& v) { t = v; }

template<typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T& t, const V& v) {
    for (auto& e:t) fill_v(e, v);
}

typedef pair<int, int> P;

class FFrogJump {
public:
    void solve(std::istream& cin, std::ostream& cout) {
        int N;
        cin >> N;
        vector<int> S(N);
        REP(i, N) cin >> S[i];

        int res = 0;
        FOR(c, 1, N - 1) {
            int sum = 0;
            int l = 0;
            int r = N - 1;
            for (int k = 0; l + c < N - 1; k++) {
                if ((N - 1) % c == 0 && l >= r) break;
                sum += S[l] + S[r];
                res = max(sum, res);
                l += c;
                r -= c;
            }
        }
        cout << res << endl;
    }
};


signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    std::istream& in(std::cin);
    std::ostream& out(std::cout);

    FFrogJump solver;
    solver.solve(in, out);
    return 0;
}


Measured memory_bytes: 1024
N, K = map(int,input().split())
H = list(map(int,input().split()))

#sub problem: min cost from 0 to i
memo = []
for i, num in enumerate(H):
  if i == 0:
    memo.append(0)
  elif i == 1:
    memo.append(abs(num - H[i-1]))
  else:
    m = min(abs(num - H[i-j])+ memo[i-j] for j in range(1, K+1) if i - j >= 0)
    memo.append(m)
print(memo[-1])

Measured memory_bytes: 59488
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
using vec=vector<ll>;
using mat=vector<vec>;
#define For(i,a,b) for(i=a;i<b;i++)
#define rep(i,N) For(i,0,N)
#define rep1(i,N) For(i,1,N)
#define all(v) (v).begin(),(v).end()
#define allr(v) (v).rbegin(),(v).rend()
#define vsort(v) sort(all(v))
#define vrsort(v) sort(allr(v))
#define mod 1000000007
using datas=pair<ll,ll>;

long mmid(long a,long b,long c){return a<b?(b<c?b:max(a,c)):(b>c?b:min(a,c));}

ll modinv(ll a) {
  ll b=mod,u=1,v=0,t;
  while(b){
    t=a/b;
    a-=t*b; swap(a,b);
    u-=t*v; swap(u,v);
  }
  return (u+mod)%mod;
}

ll moddevide(ll a,ll b){return (a*modinv(b))%mod;}

ll modncr(ll n,ll r){
  ll i,plus=1;
  rep(i,r){
    plus=(plus*(n-i))%mod;
    plus=moddevide(plus,i+1);
  }
  return plus;
}

ll euclidean_gcd(ll a, ll b) {
  if(a<b) return euclidean_gcd(b, a);
  ll r;
  while ((r=a%b)){a=b;b=r;}
  return b;
}

ll countdigits(ll n){
  ll ans=0;
  while(n){n/=10;ans++;}
  return ans;
}

ll sumdigits(ll n){
  ll ans=0;
  while(n){ans+=n%10;n/=10;}
  return ans;
}

void printmap(vector<ll>& a,ll H,ll W){
  ll i,j;
  For(i,0,H+2){
    For(j,0,W+2){cout<<a[i*(W+2)+j];}
    cout<<endl;
  }
}
void inputmap(vector<ll>& a,ll H,ll W){
  ll i,j;
  string ss;
  For(i,1,H+1){
    cin>>ss;
    For(j,1,W+1){
      if(ss[j-1]=='#'){
        a[i*(W+2)+j]=1;
      }else{
        a[i*(W+2)+j]=0;
      }
    }
  }
}

int main(){
  ll i,a,b,c,N,H,W,x=0,y=0;
  cin>>W>>H>>N;
  rep(i,N){
    cin>>a>>b>>c;
    switch(c){
      case 1:
        x=max(a,x);
      break;
      case 2:
        W=min(a,W);
      break;
      case 3:
        y=max(b,y);
      break;
      case 4:
        H=min(b,H);
      break;
    }
  }
  if(x>=W||y>=H){
    cout<<0<<endl;
  }else{
    cout<<(W-x)*(H-y)<<endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pr;
#define mp make_pair
#define int ll
const int N=2e5+5;
inline int read(){
	int x=0,w=1;
	char ch=0;
	while (ch<'0' || ch>'9'){
		ch=getchar();
		if (ch=='-') w=-1;	
	}
	while (ch<='9' && ch>='0'){
		x=(x<<1)+(x<<3)+ch-'0';
		ch=getchar();
	}
	return x*w;
}
priority_queue<ll>q;
vector<pr>g[N];
int n,m;
ll ans,a[N],dp[N],p[N];
namespace bit{
	#define lowbit(i) (i&(-i))
	ll s[N];
	inline void Add(int x,int k){
		for (int i=x;i<=n;i+=lowbit(i))
			s[i]+=k;
	}
	inline ll sum(int x){
		ll res=0;
		for (int i=x;i;i-=lowbit(i))
			res+=s[i];
		return res;
	}
}
using namespace bit;
namespace seg{
	#define ls (x<<1)
	#define rs (ls|1)
	#define mid (l+r>>1)
	ll mx[N<<2],add[N<<2];
	inline void pushup(int x){
		mx[x]=max(mx[ls],mx[rs]);
	}
	inline void pushdown(int x){
		if (!add[x]) return;
		mx[ls]+=add[x],mx[rs]+=add[x];
		add[ls]+=add[x],add[rs]+=add[x];
		add[x]=0;
	}
	void update(int x,int l,int r,int L,int R,int k){
		if (L<=l && r<=R){
			add[x]+=k,mx[x]+=k;
			return;
		}
		pushdown(x);
		if (L<=mid) update(ls,l,mid,L,R,k);
		if (R>mid) update(rs,mid+1,r,L,R,k);
		pushup(x);
	}
	ll query(int x,int l,int r,int L,int R){
		if (L>R) return 0;
		if (L<=l && r<=R) return mx[x];
		ll res=0;
		pushdown(x);
		if (L<=mid) res=max(res,query(ls,l,mid,L,R));
		if (R>mid) res=max(res,query(rs,mid+1,r,L,R));
		return res;
	}
}
using namespace seg;
signed main(){
	n=read(),m=read();
	for (int i=1;i<=m;++i){
		int l=read(),r=read(),w=read();
		Add(l,w),Add(r+1,-w);
		g[r].push_back(mp(l,w));
	}
	for (int i=1;i<=n;++i) a[i]=sum(i);
	for (int i=1;i<=n;++i){
		ll S=0;
		for (int j=0,sz=g[i-1].size();j<sz;++j){
			int l=g[i-1][j].first,w=g[i-1][j].second;
			if (l<=i-2) update(1,1,n,l,i-2,w);
			S+=w;
		}
		if (i!=1) update(1,1,n,i-1,i-1,S-a[i-1]);
		dp[i]=query(1,1,n,1,i-1)+a[i];
		update(1,1,n,i,i,dp[i]);
		ans=max(ans,dp[i]);
	}
	printf("%lld\n",ans);
	return 0;
}

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

using namespace std;

int main()
{
    int a[5];
    int k;
    for(int i=0;i<5;i++)
    {
        scanf("%d",&a[i]);
    }
    scanf("%d",&k);
    int mark=0;
    for(int i=4;i>=1;i--)
    {
        for(int j=i-1;j>=0;j--)
        {
            if(a[i]-a[j]>k) mark=1;
        }
    }
    if(mark) printf(":(\n");
    else printf("Yay!\n");
    return 0;
}


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

//standard
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
#define abs(a) ((a)>(0)?(a):-(a))

int main() {
  int n;
  int ans = 300000;
  char a[300001];
  int ruiseki[300001];
  int count = 0;

  //input
  scanf("%d",&n);
  scanf("%s",a);

  for(int i = 0; i <= n-1; i++){
    if(a[i]=='E'){
      count++;
    }
    ruiseki[i] = count;
  }

  //calculation
  for(int i = 0; i <= n-1; i++){
    if(i == 0){
      ans = ruiseki[n-1] - ruiseki[i];
    }else{
      ans = min(ans,i - ruiseki[i-1] + ruiseki[n-1] - ruiseki[i]);
    }
  }


  //Output
  printf("\n%d\n",ans);
  return 0;
}


Measured memory_bytes: 1664
#include <iostream>

using namespace std;

int getMinimumCost(int arr[], int dp[], int currentIndex, int size)
{
    if(currentIndex < 2 || dp[currentIndex] > -1)
    {
        return dp[currentIndex];
    }
    dp[currentIndex] = min(abs(arr[currentIndex] - arr[currentIndex-1]) + getMinimumCost(arr, dp, currentIndex-1, size), abs(arr[currentIndex] - arr[currentIndex-2]) + getMinimumCost(arr, dp, currentIndex-2, size));
    return dp[currentIndex];
}

int main(int argc, const char * argv[])
{
    int size;
    cin>>size;
    int arr[size];
    int dp[size];
    for(int i = 0 ; i < size ; i++)
    {
        cin>>arr[i];
        dp[i] = -1;
    }
    dp[0] = 0;
    dp[1] = abs(arr[1] - arr[0]);
    size > 0 ? cout<<getMinimumCost(arr, dp, size-1, size)<<endl : cout<<0<<endl;
    return 0;
}


Measured memory_bytes: 4992
// #define _GLIBCXX_DEBUG // for STL debug (optional)
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;
using ll = long long int;
using int64 = long long int;
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const ll INF = 1001001001001001LL;
const ll MOD = 1000000007LL;
 
int main() {
    int N, M; cin >> N >> M;
    vector< vector<ll> > jobs(M);
    for(int i=0; i<N; i++) {
        int a, b; cin >> a >> b; a--;
        if(a >= M) continue;
        jobs[a].emplace_back(b);
    }

    ll ans = 0;
    priority_queue<ll> que;
    for(int i=0; i<M; i++) {
        for(auto e : jobs[i]) que.emplace(e);
        if(que.empty()) continue;
        ans += que.top(); que.pop();
    }
    cout << ans << endl;

    /*
    vector< tuple<ll, ll, ll> > jobs(N);
    for(int i=0; i<N; i++) {
        ll A, B; cin >> A >> B;
        jobs[i] = make_tuple(A, B, i);
    }

    sort(jobs.rbegin(), jobs.rend());
    int k = 0;
    while(k < jobs.size() and get<0>(jobs[k]) > M) k++;
    
    // B, A, idx
    set< tuple<ll, ll, ll> > S;
    for(int i=k; i<(int)jobs.size(); i++) {
        ll a, b, x; tie(a, b, x) = jobs[i];
        S.emplace(-b, -a, x);
    }

    ll ans = 0;
    for(int i=0; i<M; i++) {
        if(S.empty()) break;
        // fprintf(stderr, "add %d\n", get<0>(*S.begin()));
        ans -= get<0>(*S.begin());
        S.erase(S.begin());
        
        int del = M - i;
        while(k < jobs.size() and get<0>(jobs[k]) == del) {
            ll a, b, x; tie(a, b, x) = jobs[k++];
            S.erase(make_tuple(-b, -a, x));
        }
    }
    cout << ans << endl;
    */
    
    return 0;
}


Measured memory_bytes: 6128
use proconio::input;
use std::cmp::*;
use std::vec::Vec;

fn main() {
    //let (a, b, c, k) = read_touple::<i64>();
    input!(a: i64, b: i64, c: i64, k: i64);
    let mut ans = 1 * min(a, k) - max(0, k - a - b);
    println!("{}", ans);
}


Measured memory_bytes: 2152
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <utility>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <cassert>
#include <queue>
using namespace std;
using ll = long long;
using P = pair<int, int>;
using PP = pair<P, P>;
const int INF = 1<<30;
const int MOD = 1e9 + 7;
const int MAX_N = 35;
const int dx[4][4] = {{1, 0, -1, 0}, {0, -1, 0, 1}, {0, 1, 0, -1}, {-1, 0, 1, 0}};
const int dy[4][4] = {{0, 1, 0, -1}, {1, 0, -1, 0}, {-1, 0, 1, 0}, {0, -1, 0, 1}};
int memo[4][4] = {{0, 1, 3, 2}, {1, 3, 2, 0}, {2, 0, 1, 3}, {3, 2, 0, 1}};
int w, h;
vector<int> c(4);
int table[MAX_N][MAX_N];
int solve()
{
    priority_queue<PP, vector<PP>, greater<PP>> que;
    int used[h][w][4];
    for(int i = 0; i < h; i++) for(int j = 0; j < w; j++) for(int k = 0; k < 4; k++) used[i][j][k] = INF;
    used[0][0][0] = 0;
    que.push(PP(P(0, 0), P(0, 0)));
    while(que.size())
    {
        PP p = que.top(); que.pop();
        int cost = p.first.first;
        int dir = p.first.second;
        int y = p.second.first;
        int x = p.second.second;
        if(y == h - 1 and x == w - 1) return cost;
        if(used[y][x][dir] < cost) continue;
        for(int i = 0; i < 4; i++)
        {
            int ny = y + dy[dir][i];
            int nx = x + dx[dir][i];
            if(ny < 0 or nx < 0 or ny >= h or nx >= w) continue;
            int d = memo[dir][i];
            if(table[y][x] == i)
            {
                if(used[ny][nx][d] > used[y][x][dir])
                {
                    used[ny][nx][d] = used[y][x][dir];
                    que.push(PP(P(used[ny][nx][d], d), P(ny, nx)));
                }
            }
            else
            {
                if(used[ny][nx][d] > used[y][x][dir] + c[i])
                {
                    used[ny][nx][d] = used[y][x][dir] + c[i];
                    que.push(PP(P(used[ny][nx][d], d), P(ny, nx)));
                }
            }
        }
    }
    return -1;
}
signed main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    while(cin >> w >> h, w or h)
    {
        memset(table, 0, sizeof(table));
        for(int i = 0; i < h; i++)
        {
            for(int j = 0; j < w; j++) cin >> table[i][j];
        }
        for(int i = 0; i < 4; i++) cin >> c[i];
        cout << solve() << endl;
    }
    return 0;
}




Measured memory_bytes: 3236
import java.io.*;
import java.util.*;
 
public class Main{
	int N;
	int D;
	int M;
	int T;
	
	HashMap<Integer, Integer> map;
	
	public void solve(){
		N = nextInt();
		map = new HashMap<>(1000000);
		
		for(int i = 0; i < N; i++){
			int d = nextInt();
			set(d, get(d) + 1);
		}
		M = nextInt();
		
		for(int i = 0; i < M; i++){
			int t = nextInt();
			if(get(t) > 0){
				set(t, get(t) - 1);
			}else{
				out.println("NO");
				return;
			}
		}
		out.println("YES");
	}
	
	public int get(int idx){
		Integer val = map.get(idx);
		if(val == null){
			return 0;
		}
		return val;
	}
	
	public void set(int idx, int val){
		map.put(idx, val);
	}
	
	private static PrintWriter out;
	public static void main(String[] args){
		out = new PrintWriter(System.out);
		new Main().solve();
		out.flush();
	}
	
	public static int nextInt(){
		int num = 0;
		String str = next();
		boolean minus = false;
		int i = 0;
		if(str.charAt(0) == '-'){
			minus = true;
			i++;
		}
		int len = str.length();
		for(;i < len; i++){
			char c = str.charAt(i);
			if(!('0' <= c && c <= '9')) throw new RuntimeException();
			num = num * 10 + (c - '0');
		}
		return minus ? -num : num;
	}
	
	public static long nextLong(){
		long num = 0;
		String str = next();
		boolean minus = false;
		int i = 0;
		if(str.charAt(0) == '-'){
			minus = true;
			i++;
		}
		int len = str.length();
		for(;i < len; i++){
			char c = str.charAt(i);
			if(!('0' <= c && c <= '9')) throw new RuntimeException();
			num = num * 10l + (c - '0');
		}
		return minus ? -num : num;
	}
	public static String next(){
		int c;
		while(!isAlNum(c = read())){}
		StringBuilder build = new StringBuilder();
		build.append((char)c);
		while(isAlNum(c = read())){
			build.append((char)c);
		}
		return build.toString();
	}
	
	
	private static byte[] inputBuffer = new byte[1024];
	private static int bufferLength = 0;
	private static int bufferIndex = 0;
	private static int read(){
		if(bufferLength < 0) throw new RuntimeException();
		if(bufferIndex >= bufferLength){
			try{
				bufferLength = System.in.read(inputBuffer);
				bufferIndex = 0;
			}catch(IOException e){
				throw new RuntimeException(e);
			}
			if(bufferLength <= 0) return (bufferLength = -1);
		}
		return inputBuffer[bufferIndex++];
	}
	
	private static boolean isAlNum(int c){
		return '!' <= c && c <= '~';
	}
}

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

public class Main {
	private static void solve(){
	//Implement solution here.
		String input = next();
		char[] ca = input.toCharArray();
		int result = 0;
		int tmp = 0;
		for(char c:ca) {
			if(c == 'A'||c == 'C'||c == 'G'||c == 'T') {
				tmp++;
			} else {
				tmp = 0;
			}
				result = Math.max(result, tmp);
		}
		System.out.println(result);
	}

    //Switch input source (stdin/file)
	private static Scanner scanner = new Scanner(System.in);
	public static void main(String[] args){
        String debugDataPath = System.getenv("DD_PATH");        
        if(debugDataPath != null){
            try{
                scanner = new Scanner(new BufferedReader(new InputStreamReader(new FileInputStream(new File(debugDataPath)))));
            }catch(Exception e){
                throw new RuntimeException(e);
            }
        }
        solve();
	}

    //Input read utility
	private static StringTokenizer tokenizer = null;
	public static String next() {
		while (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				tokenizer = new StringTokenizer(scanner.nextLine());
			} catch (Exception e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken();
	}
    //Get next single int
	private static int ni() {
		return Integer.parseInt(next());
	}
    //Get next single long
	private static long nl() {
		return Long.parseLong(next());
	}
    //Get next single double
	private static double nd() {
		return Double.parseDouble(next());
	}
    //Get next int array from one line
	private static int[] na(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = ni();
		return a;
	}
	//Get next char array from one line
	private static char[] ns() {
		return next().toCharArray();
	}
    //Get next long array from one line
	private static long[] nal(int n) {
		long[] a = new long[n];
		for (int i = 0; i < n; i++)
			a[i] = nl();
		return a;
	}
}

Measured memory_bytes: 21844
import sys

# input処理を高速化する
input = sys.stdin.readline

def main():
    N = int(input())
    lst_p = list(map(float, input().split()))

    # dp[i][j] := 最初の i 枚のコインを投げたときに、表が j 枚となる確率
    # 次のコインが表: dp[i+1][j+1] += dp[i][j]∗p[i]
    # 次のコインが裏: dp[i+1][j] += dp[i][j]∗(1.0−p[i])
    dp = [[0] * (N+1) for i in range(N+1)]

    # 初期条件
    dp[0][0] = 1.0

    for i in range(N):
        for j in range(N):
            dp[i+1][j+1] += dp[i][j] * lst_p[i]
            dp[i+1][j] += dp[i][j] * (1.0 - lst_p[i])
    
    ans = 0
    for i in range((N+1)//2, N+1):
        ans += dp[N][i]

    print(ans)

main()

Measured memory_bytes: 259336
k, n = gets.split.map(&:to_i)

c = gets.split.map(&:to_i).sort

s = []

for i in 0..n-1
  if i == 0
    s << c[i] + k - c[i-1]
  else
    s << c[i] - c[i-1]
  end
end

puts k - s.max


Measured memory_bytes: 20592
N = int(input())
A = list(map(int, input().split()))

h = {0: 1}
s = 0
ans = 0
for a in A:
    s += a
    h[s] = h.get(s, 0) + 1
for n in h.values():
    ans += n * (n - 1) // 2
print(ans)


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

using namespace std;

int main(int argc, const char *argv[]) {
  int a, b;
  string s;
  cin >> a >> b >> s;

  bool ans = true;
  for (int i = 0; i < s.size(); ++i) {
    if (i == a && s[i] != '-') {
      ans = false;
      break;
    }

    if (i != a && (s[i] < '0' || s[i] > '9')) {
      ans = false;
      break;
    }
  }

  cout << (ans ? "Yes" : "No") << '\n';
  return 0;
}

Measured memory_bytes: 3596
package main

import (
    "fmt"
    "os"
    "bufio"
    "strings"
    "strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func StrStdin() (stringInput string){
  sc.Scan()
  OneLineString := sc.Text()
  stringInput = strings.TrimSpace(OneLineString)
  return 
}

func IntStdin() (int, error){
  stringInput := StrStdin()
  return strconv.Atoi(stringInput)
}

// ?????????????l??????????Split()
func SplitWithoutEmpty(stringTargeted string, delim string) (stringReturned []string) {
    stringSplited := strings.Split(stringTargeted, delim)

    for _, str := range stringSplited {
        if str != "" {
            stringReturned = append(stringReturned, str)
        }
    }

    return
}

// ?f???~?^??????????????X???C?X???��
func SplitStrStdin(delim string) (stringReturned []string) {
    // ???????1?s?��
    stringInput := StrStdin()
  
    // ???????
    // stringSplited := strings.Split(stringInput, delim)
    stringReturned = SplitWithoutEmpty(stringInput, delim)

    return
}

// ?f???~?^?????????????l?X???C?X???��
func SplitIntStdin(delim string) (intSlices []int, err error) {
    // ??????X???C?X???��
    stringSplited := SplitStrStdin(delim)
	
    // ?????X???C?X????
    for i := range stringSplited {
        var iparam int
        iparam, err = strconv.Atoi(stringSplited[i])
        if err != nil {
            return
        }
        intSlices = append(intSlices, iparam)
    }
    return
}

func sum(slice []int) int {
  sum := 0
  for _, num := range slice{
  	sum += num
  }
  return sum
}

func main(){
  columncount, err1 := IntStdin()
  firstrow, err2 := SplitIntStdin(" ")
  secoundrow, err3 := SplitIntStdin(" ")
  
  maxvalue := 0
  
  if err1 == nil && err2 == nil && err3 == nil {
    for i:=0; i < columncount; i++ {
      first := sum(firstrow[:i+1])
      secound := sum(secoundrow[i:columncount])

      if (first + secound) > maxvalue {
      	maxvalue = first + secound
      } 
    }
  }
  
  fmt.Println(maxvalue)

}

Measured memory_bytes: 640
flag =0
while flag==0:
    a,b,c=[ i for i in input().split()]
    if b=="?":
        flag=1
        break
    elif b=="+":
        n=int(a)+int(c)
    elif b=="-":
        n=int(a)-int(c)
    elif b=="*":
        n=int(a)*int(c)
    elif b=="/":
        n=int(a)/int(c)
    print(int(n))

Measured memory_bytes: 7788
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define endl "\n"
const int dx[] = { -1 , -1 , -1 , 0 , 0 , 0 , 1 , 1 , 1 };
const int dy[] = { -1 , 0 , 1 , -1 , 0 , 1 , -1 , 0 , 1 };
#define NN 8010000
#define TC int t;cin>>t;for(int T=1;T<=t;T++)
#define mod 1000000007
#define PI acos(-1)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define mem(a,n) memset(a,n,sizeof(a))
void AIA() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); }
//cout<<fixed<<setprecision(20);
// freopen("stand.in","r",stdin);
// freopen("stand.out","w",stdout);
bool isprime(ll n) {
	for (ll i = 2; i * i <= n; i++) {
		if (n % i == 0)return 0;
	}
	return (n!=1);
}
ll gcd(ll x, ll y)
{
	return (y == 0 ? x : gcd(y, x % y));
}
ll lcm(ll a, ll b) {
	return a / gcd(a, b) * b;
}
ll rem(int x, int N){
	return (x % N + N) % N;
}
int main()
{
	//cout<<fixed<<setprecision(6);
	AIA();
	ll a, b, c, d;
	cin>>a>>b>>c>>d;
	ll n = a * c;
	n = max(n, a * d);
	n = max(n, b * c);
	n = max(n, b*d);
	cout<<n;
	return 0;
}

Measured memory_bytes: 3640
#include <iostream>
#include <string>
#include <vector>
// #include <algorithm>
// #include <numeric>
// #include <set>
// #include <cmath>
// #include <map>
// #include <iomanip>

// #define MOD 1000000007

using namespace std;
// typedef unsigned long long ull;
// typedef long long ll;

void p() {
    cout << "\n";
}
template<class Head, class... Body>
void p(Head head, Body... body) {
    cout << head << ",";
    p(body...);
}


int main(int argc, char const *argv[]) {
    int N;
    cin >> N;
    vector<int> a(N);
    for (int i = 0; i < N; i++) {
        cin >> a[i];
        a[i] -= 1;
    }
    int idx = 0, count = 0;
    vector<bool> visited(N, false); 
    while (true) {
        if (idx == 1 || visited[idx]) {
            break;
        }
        visited[idx] = true;
        // p("idx", idx, "  count", count);
        idx = a[idx];
        count += 1;
    }
    if (idx == 1) {
        cout << count << endl;
    } else {
        cout << -1 << endl;
    }
    return 0;
}


Measured memory_bytes: 640
import java.util.*;
public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);	
		int a = sc.nextInt();
		
		if(a == 1) {
			System.out.printf("%.10f",1.0);
		} else {
			if (a%2 == 0) {
				System.out.printf("%.10f", 1.0/2.0);
			} else {
				System.out.printf("%.10f",(a/2+1.0)/a);
			}
		}
	}
}


Measured memory_bytes: 21844
#include "bits/stdc++.h"
using namespace std;

typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define REP(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) std::cout << x << '\n'
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define sz(x) ((int)(x).size())
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { ll g = gcd(a, b); return a / g * b; }
const int dx[4] = { 1, 0, -1,  0 };
const int dy[4] = { 0, 1,  0, -1 };
const int INF = INT_MAX / 2;
const ll  inf = LLONG_MAX / 2;
const int mod = 1000000007;
const int MAX_N = 101010;
const long double PI = acos(-1);

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

	string s;
	cin >> s;

	string t = "2018";

	rep(i, 4) {
		s[i] = t[i];
	}

	out(s);

	return 0;
}

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

namespace AtCodeeeer
{
    class AtCOOOOOOOOOOOder
    {
        static void Main(string[] args)
        {
            int n = int.Parse(ReadLine());
            int[] hs = ReadLine().Split(' ').Select(int.Parse).ToArray();

            int[] dp = new int[hs.Length];
            dp[0] = 0;
            dp[1] = Abs(hs[1] - hs[0]);

            for (int i = 2; i < hs.Length; i++)
            {
                int once = Abs(hs[i] - hs[i-1]) + dp[i-1];
                int twice = Abs(hs[i] - hs[i-2]) + dp[i-2];
                dp[i] = Min(once, twice);
            }
            WriteLine(dp[hs.Length-1]);
        }
    }
}


Measured memory_bytes: 19808
#include <bits/stdc++.h>
#include <cmath>
using namespace std; 
#define pb push_back 
#define M 998244353
#define ff first
#define ss second 
#define deb(x) cout< #x< " "< x< endl;
#define fo(i,n) for(int i=0;i<n;i++)
#define Fo(i,k,n) for(int i=k;i<=n;i++)
#define FORR(a,b,c) for(int a= b;a>=c;a--)
#define nl endl
#define fa(arrr) for(auto x:arrr)
#define sz size()
#define mp make_pair
#define mxm3(a,b,c) max(a, max(b,c))
#define mi3(a,b,c) min(a, min(b,c))
#define MAX 100005
#define PII pair<ll,ll>
#define all(v) v.begin(), v.end()
#define endl "\n"
#define fast ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
typedef long long ll;
typedef vector<ll>vl;
vector<ll> prime(1100,-1);
//126271
// 107897

int main(){

	fast;
	ll t;
	// string s;
	// cin >> s;
	// cin >>t;
	t = 1;
	// int tc = 1;
	while(t--){
		ll n,k;
		cin >> n >> k;
		if(n<=k) return cout << min(n,k-n) << endl,0;
		if(k==1) return cout << 0 << endl,0;
		cout << k - n%k << endl;
  	}	
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define INF 1000000005
#define MOD 1000000007
#define EPS 1e-10
#define rep(i,n) for(int i=0;i<(int)n;++i)

using namespace std;

typedef pair<int,int>P;

const int MAX_N = 100005;
const int dx[] = {0,-1,0,-1};
const int dy[] = {0,0,-1,-1};
const int px[] = {1,1,-1,-1};
const int py[] = {1,-1,1,-1,};

ll w,h,v,t,x,y,p,q;

ll dir(int x1,int y1,int x2,int y2)
{
    return (ll)(x1-x2)*(x1-x2) + (ll)(y1-y2)*(y1-y2);
}

int main()
{
	scanf("%lld%lld%lld%lld%lld%lld%lld%lld",&w,&h,&v,&t,&x,&y,&p,&q);
    ll res = 0;
    ll d = v*v*t*t;
    for(ll i=ceil((double)(-v*t+y-q)/(2*h));i<=floor((double)(v*t+y-q)/(2*h));i++){
        double k = sqrt(d - (2*i*h+q-y)*(2*i*h+q-y));
        res += floor((x+k-p)/(2*w)) - ceil((x-k-p)/(2*w)) + 1LL;
        res += floor((x+k+p)/(2*w)) - ceil((x-k+p)/(2*w)) + 1LL;
    }
    for(ll i=ceil((double)(-v*t+y+q)/(2*h));i<=floor((double)(v*t+y+q)/(2*h));i++){
        double k = sqrt(d - (2*i*h-q-y)*(2*i*h-q-y));
        res += floor((x+k-p)/(2*w)) - ceil((x-k-p)/(2*w)) + 1LL;
        res += floor((x+k+p)/(2*w)) - ceil((x-k+p)/(2*w)) + 1LL;
    }
    printf("%lld\n",res);
	return 0;
}

Measured memory_bytes: 3200
n,k = map(int, input().split())
mod = 10**9 + 7

ans = 0
lim = 2*(10**5) + 5
mothers = [1] * lim
mothers_inv = [1] * lim
for i in range(1, lim):
    mothers[i] = mothers[i-1] * i % mod
    mothers_inv[i] = pow(mothers[i], mod-2, mod)


def calc(n,k):
    child = mothers[n] * mothers_inv[n-k] % mod
    mother_inv = mothers_inv[k]
    return((child * mother_inv)%mod)

def calc2(n,k):
    child = 1
    for i in range(n, n-k, -1):
        child = child * i % mod
    mother_inv = mothers_inv[k]
    return((child * mother_inv)%mod)

if( n <= k+1):
    ans = calc2(2*n-1, n-1)
    print(ans)
    exit()

ans = calc2(2*n-1, n-1)

for i in range(1,n-k):
    if(i ==1):
        c1 = 1
    else:
        c1 = calc(n-1, i-1)

    c2 = calc(n, i)
    ans = (ans - c1 * c2)%mod


print(ans)

Measured memory_bytes: 42864
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 1LL << 60;
ll MOD = 1e9 + 7;

int N, K;
vector<int> D;

void dfs(int n) {
    bool flag = false;
    int tmp = n;
    while (tmp > 0) {
        for (int i = 0; i < K; i++) {
            if (tmp % 10 == D[i]) {
                flag = true;
                break;
            }
        }
        if (flag == true) break;
        tmp /= 10;
    }
    if (flag == true) dfs(n + 1);
    if (flag == false) cout << n << endl;
}

int main() {
    cin >> N >> K;
    for (int i = 0; i < K; i++) {
        int d;
        cin >> d;
        D.push_back(d);
    }
    dfs(N);
    return 0;
}

Measured memory_bytes: 3624
#include <stdio.h>

int main(){
	double w;

	while(scanf("%lf",&w) != EOF){
		if(w <= 48.0){
			printf("light fly\n");
		}else if(w <= 51.0){
			printf("fly\n");
		}else if(w <= 54.0){
			printf("bantam\n");
		}else if(w <= 57.0){
			printf("feather\n");
		}else if(w <= 60.0){
			printf("light\n");
		}else if(w <= 64.0){
			printf("light welter\n");
		}else if(w <= 69.0){
			printf("welter\n");
		}else if(w <= 75.0){
			printf("light middle\n");
		}else if(w <= 81.0){
			printf("middle\n");
		}else if(w <= 91.0){
			printf("light heavy\n");
		}else{
			printf("heavy\n");
		}
	}

	return 0;
}

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

using namespace std;

const int N = 205;
const int mod = 1e9 + 7;

int n, m, res = 1;
int par[N];
char a[N][N];

int find(int u) { return (u == par[u]) ? u : par[u] = find(par[u]); }

void join(int u, int v) { par[find(u)] = find(v); }

int main() {
	ios::sync_with_stdio(false);
	cin >> n >> m;
	for (int i = 0; i < n; ++i) {
		for (int j = 0; j < m; ++j) {
			cin >> a[i][j];
		}
	}
	if (n & 1) {
		string s, t;
		for (int i = 0; i < m; ++i) {
			s.push_back(a[n / 2][i]);
		}
		t = s, reverse(t.begin(), t.end());
		res *= (s != t) + 1;
	}
	if (m & 1) {
		string s, t;
		for (int i = 0; i < n; ++i) {
			s.push_back(a[i][m / 2]);
		}
		t = s, reverse(t.begin(), t.end());
		res *= (s != t) + 1;		
	}
	for (int i = 0; i < n / 2 + m / 2; ++i) par[i] = i;
	for (int i = 0; i < n / 2; ++i) {
		for (int j = 0; j < m / 2; ++j) {
			set<string> ss;
			vector<char> v;
			vector<int> p;
			v.push_back(a[i][j]), v.push_back(a[n - 1 - i][j]);
			v.push_back(a[i][m - 1 - j]), v.push_back(a[n - 1 - i][m - 1 - j]);
			for (int k = 0; k < 4; ++k) p.push_back(k);
			do {
				string s;
				for (int k = 0; k < 4; ++k) s.push_back(v[p[k]]);
				ss.insert(s);
			} while (next_permutation(p.begin(), p.end()));
			if (ss.size() != 24) res = 1LL * res * ss.size() % mod;
			else join(i, j + n / 2), res = 1LL * res * ss.size() / 2 % mod;
		}
	}
	int cnt = n / 2 + m / 2;
	for (int i = 0; i < n / 2 + m / 2; ++i) cnt -= find(i) == i;
	for (int i = 0; i < cnt; ++i) res = 2 * res % mod;
	cout << res;
}

Measured memory_bytes: 256
#include <stdio.h>
int main()
{
    int a,b,c;
    //char ch[5];
    //scanf("%s",ch);
    scanf("%d %d %d",&a, &b, &c);
    if(a==b) printf("%d\n",c);
    else if(a==c) printf("%d\n",b);
    else printf("%d\n",a);
    return 0;
}

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

using namespace std;

typedef long long ll;

/// The definitions in this library are as below.
#define rI readInt
#define rL readLong
#define rC readChar
#define rC2 readChar2
#define rS readString

#define pb push_back

#define acc accumulate

#define FOR(i, a, b) for(int i=(a); i<=(b); i++)
#define FOR0(i, a, b) for(int i=(a); i<(b); i++)
namespace __library_79brue{
    /// This is a C++ library which improves the programming speed by \
        defining frequently used data structures or algorithms.       \
        This library can be freely used without any copyrights,       \
        but I recommend not to change the name of this library.       \
        Made by 79brue                                                \
        2019

    /// The functions or structures in this library are as below.
    /// quit()
    /// readInt() readLong() readChar() readChar2() readString()

    /// terminates the program
    inline void quit(){
        exit(0);
    }

    /// reads an integer
    inline void readInt(int& _x){
        scanf("%d", &_x);
    }

    /// reads a long-long integer
    inline void readLong(ll& _x){
        scanf("%lld", &_x);
    }

    /// reads a character
    inline void readChar(char& _x){
        scanf(" %c", &_x);
    }

    /// reads a character, the character may be space or line-break, etc...
    inline void readChar2(char &_x){
        scanf("%c", &_x);
    }

    inline void readString(char* _x){
        scanf("%s", _x);
    }

    inline int readLine(char* _x, int limit){
        if(!fgets(_x, limit, stdin)) quit();
        int _y = strlen(_x);
        while(_x[_y-1] == '\n' or _x[_y-1] == '\r') _y--;
        return _y;
    }
}
using namespace __library_79brue;

int n;
string s;
int ans=1;

int main(){
    rI(n);
    cin>>s;
    for(int i=0; i<n-1; i++) if(s[i] != s[i+1]) ans++;
    printf("%d", ans);
}


Measured memory_bytes: 512
use std::io;
use std::cmp;


// read a line(without line feed)
fn read_line() -> String {
    let mut in_str = String::new();
    io::stdin().read_line(&mut in_str).unwrap();
    return in_str.trim().to_string();
}

// read wods on a line
pub fn read_words_in_line() -> Vec<String> {
    let s = read_line();
    return s.split_whitespace().map(|x| x.to_string()).collect::<Vec<String>>()
}

// read type t on a line
pub fn read_t_in_line<T : std::str::FromStr>() -> Vec<T> {
    let mut v : Vec<T> = Vec::new();
    for e in read_words_in_line().iter().map(|x| x.parse::<T>()) {
        if let Ok(r) = e {
            v.push(r);
        }
        else{
            return Vec::new();
        }
    }
    return v;
}

// sort slice
pub fn sort<T : std::cmp::Ord>(slice : &mut [T]) {
    slice.sort();
}
// sort slice by reverse order
pub fn sort_rev<T : std::cmp::Ord>(slice : &mut [T]) {
    slice.sort_by(|x, y| y.cmp(x));
}

pub fn min<T : std::cmp::Ord>(a : T, b : T) -> T{
    return cmp::min(a, b);
}

pub fn max<T : std::cmp::Ord>(a : T, b : T) -> T{
    return cmp::max(a, b);
}


fn main() {
    let l = read_t_in_line::<i32>();
    let (a, b, t) = (l[0], l[1], l[2]);
    println!("{}", t / a * b);
}



Measured memory_bytes: 4476