akhauriyash/Code-Regression huggingface dataset:
//   PIGMEISTER™   //

#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define ld long double
#define sidha(i,x,n) for(ll i=(ll)(x);i<(ll)(n);++i)
#define ulta(i,x,n) for(ll i=(ll)(x);i>=(ll)(n);--i)
#define sab(a) a.begin(),a.end()
#define bas(a) a.rbegin(),a.rend()
#define test ll _;cin>>_;while(_--)
#define jaldi ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define MOD (ll)1000000007
//#define MOD (ll)998244353
#define PI (ld)3.141592653589793238
#define MAX 100005

int main()
{
    jaldi;
    
    ll n, W;
    cin >> n >> W;
    ll w[n], v[n], V = 0;
    sidha (i, 0, n) cin >> w[i] >> v[i], V += v[i];

    ll dp[n+1][V+1];
    memset(dp, -1, sizeof(dp));
    dp[0][0] = 0;

    sidha (i, 0, n) {
        sidha (j, 0, V+1) {
            if (~dp[i][j]) {
                if (dp[i+1][j] == -1)
                    dp[i+1][j] = W;
                dp[i+1][j] = min(dp[i+1][j], dp[i][j]);
                if (dp[i][j]+w[i] <= W) {
                    if (dp[i+1][j+v[i]] == -1)
                        dp[i+1][j+v[i]] = W;
                    dp[i+1][j+v[i]] = min(dp[i+1][j+v[i]], dp[i][j]+w[i]);
                }
            }
        }
    }

    ll ans;
    ulta (i, V, 0) {
        if (~dp[n][i]) {
            ans = i;
            break;
        }
    }

    cout << ans << '\n';
    
    return 0;
}


Measured memory_bytes: 79232
#include <cstring>
#include <map>
#include <unordered_map>
#include <string>
#include <list>
#include <vector>
#include <algorithm>
#include <queue>
#include <stack>
#include <cstdio>
#include <iostream>
#include <set>
#include <unordered_set>
using namespace std;

#define MAX(a,b) (a>b?a:b)
#define MIN(a,b) (a<b?a:b)
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int ui;
typedef pair<int, int> pii;

int gi() {
    int a;
    scanf("%d", &a);
    return a;
}

ll gli() {
    ll a;
    scanf("%lld", &a);
    return a;
}

char s[200004];

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

    scanf("%s", s);
    int n = strlen(s);
    ll res = 0, b = 0;
    for (int i = 0; i < n; i++)
        if (s[i] == 'B')
            b++;
        else
            res += b;

    cout << res << endl;

    return 0;
}


Measured memory_bytes: 512
#include<iostream>
#include<string>
#include<vector>
#include<cmath>
#include<queue>
#include<stack>
#include<set>
#include<algorithm>
#include<utility>
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const int INF = 1001001001;

ll pow_mod(ll x, ll y) {
	ll res = 1;
	for (ll i = 0; i < y; i++) res = res * x % mod;
	return res;
}

ll gcd(ll x, ll y) {
	if (y == 0) {
		return x;
	}
	return gcd(y, x % y);
}

int main() {
	int k, n;
	cin >> k >> n;
	vector<int> a(n);
	int max_len = 0;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		if (i != 0) {
			max_len = max(max_len, a[i] - a[i - 1]);
		}
	}
	max_len = max(max_len, a[0] + k - a[n - 1]);
	int ans = k - max_len;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 4020
input = open(0).readline
s = {}
s['A'] = list(input().strip())
s['B'] = list(input().strip())
s['C'] = list(input().strip())

play_order = {'A':'B', 'B':'C', 'C':'A'}

def play(player):
    if s[player] == []:
        print(player.upper())
        return player
    next_play = s[player].pop(0)
    play(next_play.upper())
        
play('A')
        
        




Measured memory_bytes: 3188
#include <bits/stdc++.h>
#define loop(n) for (int ngtkana_is_genius = 0; ngtkana_is_genius < int(n); ngtkana_is_genius++)
#define rep(i, begin, end) for(int i = int(begin); i < int(end); i++)
#define all(v) v.begin(), v.end()
#define rand(l, r) std::uniform_int_distribution<>(l, r)(mt)
#define lint long long
auto cmn = [](auto& a, auto b){if (a > b) {a = b; return true;} return false;};
auto cmx = [](auto& a, auto b){if (a < b) {a = b; return true;} return false;};
void debug_impl() { std::cerr << std::endl; }
template <typename Head, typename... Tail>
void debug_impl(Head head, Tail... tail){
  std::cerr << " " << head;
  debug_impl(tail...);
}
#ifndef STOPIT
#define debug(...)\
  std::cerr << std::boolalpha << "[" << #__VA_ARGS__ << "]:";\
  debug_impl(__VA_ARGS__);\
  std::cerr << std::noboolalpha;
#else
#define debug 0;
#endif

int main() {
  std::cin.tie(0); std::cin.sync_with_stdio(false);
  int n; std::cin >> n;
  auto ret = (double)(n - n / 2) / n;
  std::cout << std::setprecision(10) <<  ret << std::endl;
  return 0;
}


Measured memory_bytes: 256
from bisect import bisect_right

N = int(input())
Nroot = int(N**(1/2))

an = [i*(i+1)//2 for i in range(50)]

ans = 0
for i in range(2, Nroot):
  count = 0
  if N%i == 0:
    Ni = N//i
    count = 1
    while Ni%i == 0:
      count += 1
      Ni = Ni//i
      
    ans += bisect_right(an, count) -1
    
  N = N//(i**count)
  
if N>1:
  print(ans+1)
else:
  print(ans)

Measured memory_bytes: 9472
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;

#define mp make_pair
#define pb push_back
#define ll long long

ll A, B;
ll ans, step;

ll both(ll l1, ll r1, ll l2, ll r2) {
    l2 = max(l2, r1 + 1);
    return r1 - l1 + 1 + max(0LL, r2 - l2 + 1);
}

ll ones(ll x) {
    for (ll step = 1; step <= x; step <<= 1)
        x |= step;
    return x;
}

int main()
{
   // freopen("test.in","r",stdin);

    cin >> A >> B;
    if (A == B) {
        cout << 1;
        return 0;
    }

    for (step = 1LL << 60; step > 0; step >>= 1) {
        if ((A & step) != (B & step)) break;
        A &= step - 1;
        B &= step - 1;
    }

    B -= step;
    ans = step - A;

    ans += both(step, step + ones(B), step + A, step + step - 1);
    cout << ans;

    return 0;
}


Measured memory_bytes: 256
s=input()
r=s.replace("x","")
if r!=r[::-1]:
    print(-1)
else:
    ans=[]
    cnt=0
    for i in s:
        if i=="x":
            cnt+=1
        else:
            ans.append(cnt)
            cnt=0
    ans.append(cnt)
    ans2=0
    for i in range(len(ans)//2):
        ans2+=abs(ans[i]-ans[len(ans)-1-i])
    print(ans2)

Measured memory_bytes: 3956
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;

class TEST{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	public void Solve(){
		
		long ans = 0;
		int l = 0;
		int r = 0;
		long totsum = 0;
		long totxor = 0;
		while(l < N){
			if(l == r){
				totsum = A[l];
				totxor = A[r];
				r++;
			} else {
				totsum -= A[l - 1];
				totxor ^= A[l - 1];
			}
			while(r < N){
				totsum += A[r];
				totxor ^= A[r];
				if(totsum == totxor){
					r++;
					continue;
				}
				totsum -= A[r];
				totxor ^= A[r];
				break;
			}
//Console.WriteLine("l:{0}, r:{1}, totsum = {2}, totxor = {3}",l, r, totsum, totxor);
			ans += r - l;
			l++;
		}
		Console.WriteLine(ans);
		
		
	}
	int N;
	long[] A;
	public Sol(){
		N = ri();
		A = rla();
	}

	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}
	static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}
	static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}
	static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}
}


Measured memory_bytes: 30172
import queue
n=int(input())
e=[[] for _ in range(n)]
INF=10**18
d=[INF]*n
for _ in range(n-1):
  v,u,w=map(int,input().split())
  e[v-1]+=[(u-1,w)]
  e[u-1]+=[(v-1,w)]
q=queue.Queue()
q.put(0)
d[0]=0
while not q.empty():
  now=q.get()
  for to,dis in e[now]:
    if d[to]==INF:
      d[to]=d[now]+dis
      q.put(to)
for i in d:
  print(i%2)

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

using namespace std;

long long x,y,ans;

int main()
{
//	freopen("1580.in","r",stdin);
//	freopen("1580.out","w",stdout);
    cin>>x>>y;
    ans=x*2;
    if (x%y==0) {cout<<"-1"<<endl;return 0;}
    while(ans%y==0&&ans<=1000000000000000000) ans+=x;
	cout<<ans<<endl; 
	return  0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <deque>
#include <queue>
#include <array>
#include <set>
#include <map>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <cassert>
#include <utility>
#include <functional>
#include <bitset>

using namespace std;
using lli = long long int;
template<class T, class U> void init_n(vector<T>& v, size_t n, U x) 
{ v = vector<T>(n, x); }
template<class T> void init_n(vector<T>& v, size_t n) { init_n(v, n, T()); }
template<class T> void read_n(vector<T>& v, size_t n, size_t o = 0) 
{ v = vector<T>(n+o); for (lli i=o; i<n+o; ++i) cin >> v[i]; }
template<class T> void read_n(T a[], size_t n, size_t o = 0)
{ for (lli i=o; i<n+o; ++i) cin >> a[i]; }
template<class T> T gabs(const T& x) { return max(x, -x); }
#define abs gabs

const lli mod = 1e9+7;
lli n, memo[101][4][4][4];

lli toi(char c) {
  if (c == 'A') return 0;
  if (c == 'C') return 1;
  if (c == 'G') return 2;
  return 3;
}

lli rec(lli i, char c, char d, char e) {
  auto& ref = memo[i][toi(c)][toi(d)][toi(e)];
  if (i == n) return 1;
  if (ref > 0) return ref;
  bool C = true, G = true;
  if ((c == 'A' || d == 'A' || e == 'A') 
      && (d == 'G' || e == 'G')) C = false;
  if (d == 'A' && e == 'C') G = false;
  lli res = 0;
  res += rec(i+1, d, e, 'A');
  if (C) res += rec(i+1, d, e, 'C');
  if (G) res += rec(i+1, d, e, 'G');
  res += rec(i+1, d, e, 'T');
  return ref = res % mod;
}

int main() {
  cin >> n;
  lli ans = rec(0, 'T', 'T', 'T');
  cout << ans << endl;
  return 0;
}


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

template <typename T> void chmin(T&x,const T &y)
{
	if(x>y)x=y;
}
template <typename T> void chmax(T &x,const T &y)
{
	if(x<y)x=y;
}
typedef long long s64;
typedef unsigned long long u64;
typedef unsigned int u32;
typedef pair<int,int> pii;
#define rep(i,l,r) for(int i=l;i<=r;++i)
#define per(i,r,l) for(int i=r;i>=l;--i)
#define rep0(i,l,r) for(int i=l;i<r;++i)
#define gc (c=getchar())
int read()
{
	char c;
	while(gc<'-');
	if(c=='-')
	{
		int x=gc-'0';
		while(gc>='0')x=x*10+c-'0';
		return -x;
	}
	int x=c-'0';
	while(gc>='0')x=x*10+c-'0';
	return x;
}
#undef gc

const int N=2e5+5;
vector<int>lk[N];
int n,mx[N],f[N];
int fa[N],sz[N],q[N],tot,dfn[N],son[N];
namespace SEG
{
#define mid ((l+r)/2)
#define cl (k*2)
#define cr (cl+1)
const int T=N*4;
int mul[T],ad[T];
int ql,qr;
void _add(int k,int k0)
{
	mul[k]*=mul[k0];
	ad[k]=ad[k]*mul[k0]+ad[k0];
}
void down(int k)
{
	_add(cl,k);
	_add(cr,k);
	mul[k]=1;ad[k]=0;
}
void dfs(int k,int l,int r)
{
	if(ql<=l&&qr>=r)
	{
		_add(k,0);
		return ;
	}
	down(k);
	if(ql<=mid)dfs(cl,l,mid);
	if(qr>mid)dfs(cr,mid+1,r);
}
void Mul(int l,int r,int x)
{
	if(l>r)return ;
	mul[0]=x;ad[0]=0;
	ql=l;qr=r;
	dfs(1,1,n);
}
void add(int l,int r,int x)
{
	if(l>r)return ;
	mul[0]=1;ad[0]=x;
	ql=l;qr=r;
	dfs(1,1,n);
}
int query(int x)
{
	int k=1,l=1,r=n;
	while(l!=r)
	{
		down(k);
		if(x<=mid){r=mid;k=cl;}
		else{l=mid+1;k=cr;}
	}
	return ad[k];
}
};

void dfs(int x,int fr)
{
	fa[x]=fr;
	mx[x]=max(mx[fr],x);
	++tot;
	q[tot]=x;
	dfn[x]=tot;
	sz[x]=1;
	for(auto y:lk[x])
	if(y!=fr)
	{
		dfs(y,x);
		sz[x]+=sz[y];
		if(sz[y]>sz[son[x]])son[x]=y;
	}
}
void add_dfs(int x,int mx)
{
	SEG::add(mx,n,1);
	for(auto y:lk[x])
	if(y!=fa[x])add_dfs(y,max(mx,y));
}
void dfs2(int x)
{
	if(son[x])
	{
		for(auto y:lk[x])
		if(y!=fa[x]&&y!=son[x])
		{
			dfs2(y);
			SEG::Mul(1,n,0);
		}
		dfs2(son[x]);
		for(auto y:lk[x])
		if(y!=fa[x]&&y!=son[x])add_dfs(y,y);
	}
	SEG::add(1,n,1);
//	if(x==10)
//		int yyx=1;
	int fr=fa[x];
	if(fr>1&&mx[fr]==fr)
	{
		int fr2=mx[fa[fr]];
		f[x]=SEG::query(fr);
		SEG::Mul(1,x-1,0);
		//if(x==10)cerr<<SEG::query(3);
		f[x]-=SEG::query(fr2);
	}
	else
	{
		if(fr)
		if(x>mx[fr])f[x]=SEG::query(mx[fr]);
		SEG::Mul(1,x-1,0);
	}
}
void dfs3(int x)
{
	f[x]+=f[fa[x]];
	for(auto y:lk[x])
	if(y!=fa[x])dfs3(y);
}

int main()
{
#ifdef kcz
	freopen("1.in","r",stdin);//freopen("1.out","w",stdout);
#endif
	n=read();
	rep(i,1,n-1)
	{
		int x=read(),y=read();
		lk[x].push_back(y);
		lk[y].push_back(x);
	}
	dfs(1,0);
	dfs2(1);
	dfs3(1); 
	rep(i,2,n)printf("%d ",f[i]);
}


Measured memory_bytes: 36736
#include<bits/stdc++.h>
using namespace std;
int main()
{
   int k;
   cin>>k;
   int sum = 0;
   for (int i = 1; i <= 2000006; i++) 
   {
        sum = (sum * 10 + 7) % k;
        if (sum == 0)
        {
            cout << i << '\n';
            return 0;
        }
    }
    cout << -1 << '\n';
  return 0;
}  


Measured memory_bytes: 3576
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int h = in.nextInt(), w = in.nextInt();
        in.nextLine();
        char[][] board = new char[h][w];
        for (int i = 0; i < h; i++) {
            board[i] = in.nextLine().toCharArray();
        }
        int count = 0;
        for (int i = 0; i < h; i++) {
            for (int j = 0; j < w; j++) {
                if (board[i][j] == '#') {
                    count++;
                }
            }
        }
        if (count == h + w - 1) {
            System.out.println("Possible");
        } else {
            System.out.println("Impossible");
        }
    }
}

Measured memory_bytes: 23252
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
const int INF = (1<<30)-1;
const long long LINF = (1LL<<62)-1;
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, 1, 0, -1};
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; }

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int a, b, m;
  cin >> a >> b >> m;
  vector<ll> c(a), d(b);
  rep(i, a) cin >> c[i];
  rep(i, b) cin >> d[i];
  vector<ll> ans;
  rep(i, m) {
    ll x, y, e;
    cin >> x >> y >> e;
    --x, --y;
    ans.push_back(c[x]+d[y]-e);
  }
  sort(c.begin(), c.end());
  sort(d.begin(), d.end());
  ans.push_back(c[0]+d[0]);
  sort(ans.begin(), ans.end());
  cout << ans[0] << endl;
  return 0;
}

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

int main(){
    string s;
    cin >> s;
    sort(s.begin(),s.end());

    string t;
    cin >> t;
    sort(t.begin(),t.end());
    reverse(t.begin(),t.end());

    if(s < t){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

}

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()
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>bool chmin(T&a,const T&b){return a>b?(a=b,1):0;}
template<class T>bool chmax(T&a,const T&b){return a<b?(a=b,1):0;}


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

const int MAX_N = 2048;
int a[MAX_N];
int dp[MAX_N][MAX_N][2];

const int INF = 1001001001;

struct BITMAX {
  int n;
  int vs[MAX_N + 10];
  BITMAX() {
    this->n = MAX_N;
    clear();
  }
  void clear() {
    REP(i, MAX_N + 10) vs[i] = -INF;
  }
    /** [idx, ∞] の範囲の最大値を val で更新しようと試みる */
  void update(int idx, int val) {
    idx = MAX_N - idx;
    for (int x = idx + 1; x <= n; x += x & -x) vs[x] = max(vs[x], val);
  }
  /** [idx, ∞] の範囲の最大値を取得 */
  int get(int idx) {
    idx = MAX_N - idx;
    int ma = -INF;
    for (int x = idx + 1; x > 0; x -= x & -x) ma = max(ma, vs[x]);
    return ma;
  }
};

BITMAX max_y[MAX_N];
BITMAX min_x[MAX_N];

int main2() {
  REP(i, MAX_N) max_y[i].clear();
  REP(i, MAX_N) min_x[i].clear();

  int N = nextInt() + 2;
  REP(i, N) a[i] = nextInt();
  // REP(i, N) REP(j, N) REP(t, N) dp[i][j][t] = 0;

  for (int x = 0; x < N - 1; x++) { 
    dp[x][N-1][0] = abs(a[x] - a[N-1]);
    min_x[x].update(N-1, -dp[x][N-1][0]);
  }
  for (int y = 0; y < N - 1; y++) {
    dp[N-1][y][1] = abs(a[y] - a[N-1]);
    max_y[y].update(N-1, dp[N-1][y][1]);
  }
  for (int x = N - 2; x >= 0; x--) {
    for (int y = N - 2; y >= 0; y--) {
      for (int t = 0; t < 2; t++) {
        if (t == 0 && x < y) {
          // int m = -INF;
          // for (int k = y+1; k < N; k++) chmax(m, dp[k][y][1]);
          int m = max_y[y].get(y+1);
          min_x[x].update(y, -m);
          dp[x][y][0] = m;
        }
        if (t == 1 && y < x) {
          // int m = INF;
          // for (int k = x + 1; k < N; k++) chmin(m, dp[x][k][0]);
          int m = -min_x[x].get(x+1);
          max_y[y].update(x, m);
          dp[x][y][1] = m;
        }
      }
    }
  }
  int ans = dp[0][1][0];
  cout << ans << endl;
  return 0;
}

int main() {
  for (;!cin.eof();cin>>ws) main2();
  return 0;
}



Measured memory_bytes: 65792
#include <bits/stdc++.h>
#define REP(i, n) for(ll i = 0; i < (ll)(n); i++)
#define FOR(i, a, b) for(ll i = a; i < (ll)(b); i++)

#define ALL(x) x.begin(), x.end()
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define SORT(x) sort(ALL(x))
#define REV(x) reverse(ALL(x))

using namespace std;
using ll = long long;
using vl = vector<ll>;
using vvl = vector<vl>;
using vf = vector<float>;
using vd = vector<double>;
using vs = vector<string>;
using vb = vector<bool>;
using sl = stack<ll>;
using ql = queue<ll>;

const long long INF=2305843009213693951;
const long long dx[]={0,1,0,-1,1,-1,1,-1};
const long long dy[]={1,0,-1,0,1,1,-1,-1};


void Yes(bool a){cout<<(a?"Yes":"No")<<endl;}
void YES(bool a){cout<<(a?"YES":"NO")<<endl;}

int binary_search(ll x, vl a){
    auto ite = lower_bound(ALL(a), x);
    if(ite != a.end() && *ite == x) {
        return ite - a.begin() ;
    } else {
        return -1;
    }

}

ll modpow(ll a, ll n, ll mod) {
    if(n == 0)
        return 1;
    if(n == 1)
        return a % mod;
    if(n % 2 == 1)
        return (a * modpow(a, n - 1, mod)) % mod;
    ll t = modpow(a, n / 2, mod);
    return (t * t) % mod;
}

int main() {
    ll N;
    cin >> N;
    string S;
    REP(i, N){
        S += "ACL";
    }
    cout << S << endl;
    return 0;
}

Measured memory_bytes: 3600
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <algorithm>

typedef long long ll;
const ll INF = (ll)1e18 + 1;
const ll MOD = 1e9 + 7;

void print(){ std::cout << std::endl; }
template <typename H> void print(H head) { std::cout << head << std::endl; }
template <typename H, typename... T> void print(H head, T... tail){ std::cout << head << " ", print(tail...); }

int main()
{
  std::cin.tie(nullptr);
  std::ios::sync_with_stdio(false);

  ll N = 5;
  ll k;
  std::vector< ll > va(N, 0LL);
  for (ll i = 0; i < N; i++) {
    std::cin >> va[i];
  }
  std::cin >> k;

  std::string judge = "Yay!";
  for (ll i = 0; i < N; i++) {
    for (ll j = i+1; j < N; j++) {
      if (va[j] - va[i] > k) judge = ":(";
    }
  }

  print(judge);
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
const int MAXN = 1e5 + 7;

int main()
{
    ios::sync_with_stdio(0);
    int n;
    cin >> n;
    unordered_map<string, ll> mp;
    ll ans = 0;
    for(int i = 0; i < n; i++) 
    {
        string s;
        cin >> s;
        sort(s.begin(), s.end());
        ans += mp[s];
        mp[s]++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 10660
#include<stdio.h>
#include<iostream>
#include<math.h>
#include<string.h>
int main()
{
	int a,b,c,d,A,B,C,D;
	while(~scanf("%d%d%d%d",&a,&b,&c,&d))
	{
		A=(c-a)*(c-a);
		D=d*d;
		B=(b-a)*(b-a);
		C=(c-b)*(c-b);
		if(B<=D&&C<D)
		printf("Yes\n");
		else
		{
			if(A<=D)
			printf("Yes\n");
			else
			printf("No\n");
		}
	} 
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String line = sc.nextLine();

        String[] input = line.split(" ", 0);
        int N = Integer.valueOf(input[0]).intValue();
        int S = Integer.valueOf(input[1]).intValue();
        line = sc.nextLine();

        char[] c = line.toCharArray();

        if(c[S-1] == 'A'){
            c[S-1] = 'a';
        }else if(c[S-1] == 'B'){
            c[S-1] = 'b';
        }else if(c[S-1] == 'C'){
            c[S-1] = 'c';
        }

        for(int i = 0; i < N; i++) {
            System.out.print(c[i]);
        }
    }
}

Measured memory_bytes: 23380
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <iomanip>
#include <queue>
#include <deque>
#include <map>
#include <unordered_map>
#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
#define repr(e,x) for(auto& e:x)
using namespace std;
typedef long long ll;
typedef long double ld;
ll const MOD=1000000007;

int K,T;
int a[100];

int main(){
    cin>>K>>T;
    rep(i,T) cin>>a[i];

    sort(a,a+T,greater<>());

    int x=0,y=0;
    rep(i,T){
        if(x<y) x+=a[i];
        else y+=a[i];
    }

    int ans=max(0,abs(x-y)-1);

    cout<<ans<<endl;
}

Measured memory_bytes: 3644
import java.util.*;

public class Main{
  public static void main(String[]args){
    Scanner sc = new Scanner(System.in);
    int N = Integer.parseInt(sc.nextLine());
    Set<String> set = new HashSet<>();
    String S = sc.nextLine();
    set.add(S);
    
    String ans = "Yes";
    char c = S.charAt(S.length()-1);
    for(int i = 1; i < N; i++){
      String s = sc.nextLine();
      int n = set.size();
      set.add(s);
      if(c != s.charAt(0) || n == set.size()){
        ans = "No";
      }
      c = s.charAt(s.length()-1);
    }
    System.out.println(ans);
  }
}

Measured memory_bytes: 21844
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <cmath>
#include <complex>
#include <map>
#include <set>
#include <vector>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cassert>
#include <iomanip>
using namespace std;

#define Rep(b, e, i) for(int i = b; i <= e; i++)
#define Repr(e, b, i) for(int i = e; i >= b; i--)
#define rep(n, i) Rep(0, n-1, i)
#define repr(n, i) Repr(n-1, 0, i)
#define all(v) (v).begin(), (v).end()
#define pb(v) push_back(v)
#define uniq(v) (v).erase(unique(all(v)),(v).end())
#define bitcnt(x) __builtin_popcount(x)
#define fst first
#define snd second
#define Pqaz(T) priority_queue<T,vector<T>,greater<T>>
#define Pqza(T) priority_queue<T>
#define put(x) cout << x;
#define putsp(x) cout << x << ' ';
#define putbd cout << "---------------------------------------------" << endl;
#define putln(x) cout << x << endl;
#define debug(x) cerr << #x << "=" << x << endl;
#define ENJYU std::ios::sync_with_stdio(false);std::cin.tie(0);

typedef long long ll;
typedef pair<ll, ll> llP;
typedef pair<int, int> intP;
typedef complex<double> comp;
typedef vector <int> vec;
typedef vector <ll> vecll;
typedef vector <double> vecd;
typedef vector <vec> mat;
typedef vector <vecll> matll;
typedef vector <vecd> matd;

//vector の中身を出力
template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}

const int MAX = 200020;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = 1<<29;
const ll INFL = 1e18;
const ll MOD = 1000000007;

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

//********************************template END****************************************//

vector<int> enum_prime(int N)
{
	bool prime[N];
	memset(prime, true, sizeof(prime));
	prime[0] = prime[1] = false;

	for (int i = 2; i < N; i++)
	{
		if (!prime[i])
			continue;
		for (int j = 2; i * j < N; j++)
		{
			prime[i * j] = false;
		}
	}

	vector<int> ps;
	rep(N, i)
	{
		if (prime[i])
			ps.pb(i);
	}

	return ps;
}

void solve(void)
{
	int N;
	cin >> N;

	vec ps = enum_prime(N);

	//cout << ps << endl;

	map<int, int> mp, cnt;
	vec as = vec{3,5,15,25,75};

	Rep(2, N, n)
	{
		int x = n;
		for (int p : ps)
		{
			while (x % p == 0)
			{
				mp[p]++;
				x /= p;
			}
		}
	}

	for (auto p : mp) for (int a : as)
	{
		if (a-1 <= p.snd)
		{
			cnt[a]++;
		}
	}

	//for (auto p : cnt){cout << p.fst << ' ' << p.snd << endl;}

	int ans = max(0, (cnt[3]-2) * cnt[5] * (cnt[5]-1) / 2);
	ans += max(0, cnt[75]);
	ans += max(0, (cnt[5]-1) * cnt[15]);
	ans += max(0, (cnt[3]-1) * cnt[25]);

	cout << ans << endl;
}

int main(void)
{
	solve();
	//cout << "yui(*-v・)yui" << endl;
	return 0;
}


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

#define for_(i,a,b) for(int i=a;i<b;++i)
#define for_rev(i,a,b) for(int i=a;i>=b;--i)

int N, M, L, P[110], T[110], V[110];
double p[110][55];

void solve() {
	for_(i,0,N) {
		double dp[55][55] = { 0.0 }, pi = (double)P[i] / 100.;
		dp[0][0] = 1.0;
		
		for_(j,0,M) for_(k,0,M) {
			dp[j+1][k] += dp[j][k] * (1.0 - pi);
			dp[j+1][k+1] += dp[j][k] * pi;
		}
		
		for_(k,0,M+1) p[i][k] = dp[M][k];
	}
	
	for_(i,0,N) {
		double ans = 0.0;
		
		if (V[i] > 0) {
			for_(j,0,M+1) {
				double t1 = (double)L / (double)V[i] + (double)(j * T[i]);
				double mul = 1.0;
				
				for_(ii,0,N) {
					if (i != ii && V[ii] > 0) {
						double mii = 0.0;								
						double t2 = (double)L / (double)V[ii] + (double)(M * T[ii]);
						
						for_rev(k,M,0) {
							if (t2 - t1 < 1e-9) break;
							mii += p[ii][k];
							t2 -= (double)T[ii];
						}
					
						mul *= mii;
					}
				}
				
				ans += mul * p[i][j];
			}
		}
		
		printf("%.9lf\n", (N == 1) ? 1.0 : ans);
	}
}

int main() {
	cin >> N >> M >> L;
	for_(i,0,N) cin >> P[i] >> T[i] >> V[i];
	
	solve();
	
	return 0;
}

Measured memory_bytes: 1260
#include <iostream>
#include <sstream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <stdio.h>

using namespace std;

//typedefリスト
typedef vector<int> vint;
typedef vector<string> vstr;


int main(void) {
	int sum,n,X;
	sum = 0;
	string N;
	cin >> N;
	X=stoi(N);
	n = N.length();
	for (int i = 0; i < n; i++) {
		sum += N[i] - '0';
	}
	if (X%sum == 0)cout << "Yes" << endl;
	else cout << "No" << endl;
}

Measured memory_bytes: 256
A = int(input())
B = int(input())
C = int(input())
X = int(input())

count = 0

for a in range(A+1):
    value = X-a*500
    if value == 0:
        count += 1
        continue
    for b in range(B+1):
        value = X-a*500-b*100
        if value == 0:
            count += 1
            continue
        for c in range(C+1):
            value = X-a*500-b*100-c*50
            if value == 0:
                count += 1

print(count)


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

using namespace std;
using ll = long long;

template <typename K,typename V>
using umap = unordered_map<K,V>;
template <typename V>
using uset = unordered_set<V>;
#define REP(i,n) for(int i=0;i<n;i++)
#define REPD(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define FORD(i,a,b) for(int i=a;i>=b;i--)
#define ALL(v) v.begin(),v.end()

#define INF 1'000'000'000'000 //10^12
#define MOD 1'000'000'007

int main(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  int n;
  cin >> n;
  int a[n];
  REP(i,n){
    cin >> a[i];
  }
  umap<int,int> map;
  ll res = 0;
  int now = 0;
  REP(i,n){
    now = map[i-a[i]];
    res += now;
    map[i+a[i]]++;
  }
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 19180
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;

public class Main {

  public static void main(String[] args) {
    FastScanner sc = new FastScanner();

    String a = sc.next();
    String b = sc.next();

    String ans = "No";
    int x = Integer.valueOf(a + b);
    int y = (int) Math.sqrt(x);
    if (x == y * y) {
      ans = "Yes";
    }

    System.out.println(ans);

  }
}

class FastScanner {
  private final InputStream in = System.in;
  private final byte[] buffer = new byte[1024];
  private int ptr = 0;
  private int buflen = 0;

  private boolean hasNextByte() {
    if (ptr < buflen) {
      return true;
    } else {
      ptr = 0;
      try {
        buflen = in.read(buffer);
      } catch (IOException e) {
        e.printStackTrace();
      }
      if (buflen <= 0) {
        return false;
      }
    }
    return true;
  }

  private int readByte() {
    if (hasNextByte()) {
      return buffer[ptr++];
    } else {
      return -1;
    }
  }

  private static boolean isPrintableChar(int c) {
    return 33 <= c && c <= 126;
  }

  private void skipUnprintable() {
    while (hasNextByte() && !isPrintableChar(buffer[ptr])) {
      ptr++;
    }
  }

  public boolean hasNext() {
    skipUnprintable();
    return hasNextByte();
  }

  public String next() {
    if (!hasNext()) {
      throw new NoSuchElementException();
    }
    StringBuilder sb = new StringBuilder();
    int b = readByte();
    while (isPrintableChar(b)) {
      sb.appendCodePoint(b);
      b = readByte();
    }
    return sb.toString();
  }

  public int nextInt() {
    if (!hasNext()) {
      throw new NoSuchElementException();
    }
    int n = 0;
    boolean minus = false;
    int b = readByte();
    if (b == '-') {
      minus = true;
      b = readByte();
    }
    if (b < '0' || '9' < b) {
      throw new NumberFormatException();
    }
    while (true) {
      if ('0' <= b && b <= '9') {
        n *= 10;
        n += b - '0';
      } else if (b == -1 || !isPrintableChar(b)) {
        return minus ? -n : n;
      } else {
        throw new NumberFormatException();
      }
      b = readByte();
    }
  }

  public long nextLong() {
    if (!hasNext()) {
      throw new NoSuchElementException();
    }
    long n = 0;
    boolean minus = false;
    int b = readByte();
    if (b == '-') {
      minus = true;
      b = readByte();
    }
    if (b < '0' || '9' < b) {
      throw new NumberFormatException();
    }
    while (true) {
      if ('0' <= b && b <= '9') {
        n *= 10;
        n += b - '0';
      } else if (b == -1 || !isPrintableChar(b)) {
        return minus ? -n : n;
      } else {
        throw new NumberFormatException();
      }
      b = readByte();
    }
  }
}

Measured memory_bytes: 21076
N, M = map(int, input().split())
graph = [[] for i in range(N)]
for _ in range(M):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    graph[a].append(b)
    graph[b].append(a)


def dfs(now, prev, visited):
    visited.append(now)
    if len(visited) == N:
        return 1

    ret = 0
    for edge in graph[now]:
        if edge == prev:
            continue
        if edge in visited:
            continue

        ret += dfs(edge, prev, visited[:])

    return ret


print(dfs(0, -1, []))


Measured memory_bytes: 3064
#include<stdio.h>

int main(){
	int A, B;
	scanf("%d %d", &A, &B);
	
	if (A==1 && B==1) printf("Draw");
	else if (A==1) printf("Alice");
	else if (B==1) printf("Bob");
	else if (A>B) printf("Alice");
	else if (B>A) printf("Bob");
	else printf("Draw");
	
}

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

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

use std::cmp::{max, min};
use std::collections::HashMap;

fn main() {
  let n = read::<i64>();
  let mut card = vec![];
  let mut alice = 0;
  let mut bob = 0;
  for i in 0..n {
    card.push(read::<i64>());
  }

  card.sort_by_key(|x| -x);

  for (i, v) in card.iter().enumerate() {
    if i % 2 == 0 {
      alice += *v;
    } else {
      bob += *v;
    }
  }
  println!("{}", alice - bob);
}


Measured memory_bytes: 4352
#include <iostream>
#include <vector>
#define REP(i,N) for(int i=0;i<N;i++)
using namespace std;
using vi = vector<long long int>;
int main() {
	long long int K;
	cin >> K;
	vi A(K), min(K + 1), max(K + 1);
	REP(i, K) {
		cin >> A[i];
	}
	min[K] = 2; max[K] = 2;
	bool miss = false;
	for (long long int i = K - 1; i >= 0; i--) {
		if ((max[i + 1] / A[i] - min[i + 1] / A[i]) == 0 && (min[i + 1] % A[i] != 0)) {
			miss = true; break; 
		}
		min[i] = (min[i + 1] + A[i] - 1) / A[i] * A[i];
		max[i] = max[i + 1] / A[i] * A[i] + A[i] - 1;
	}
	if (miss) {
		cout << -1;
	}
	else {
		cout << min[0] << " " << max[0];
	}
	return 0;
}

Measured memory_bytes: 2560
#include"bits/stdc++.h"
using namespace std;
using ll=long long;
template<typename T=ll>inline T in(istream&is=cin){T ret;is>>ret;return ret;}
template<typename T>inline auto vec2(typename vector<T>::size_type h,typename vector<T>::size_type w,T v=T()){return vector<vector<T>>(h,vector<T>(w,v));}

int main()
{
    ll s=in(),w=in();
    cout<<(s<=w?"unsafe":"safe")<<endl;
}


Measured memory_bytes: 3636
#include<stdio.h>
#define N 100
#define INF 10000000

int n, A[N], B[N][N], C[N][N], D[N];
void dfs(int a, int b)
{
  int i;
  D[a] = b;
  for(i = 0; i < A[a]; i++)
    {
      if(D[B[a][i]] > b + C[a][i])
	{
	  dfs(B[a][i], b+C[a][i]);
	}
    }
}

int main()
{
  int i, j, k;
  scanf("%d", &n);
  for(i = 0; i < n; i++)
    {
      scanf("%d", &k);
      scanf("%d", &A[i]);

      for(j = 0; j < A[i]; j++)
	{
	  scanf("%d%d", &B[i][j], &C[i][j]);
	}
    }
  for(i = 0; i < n; i++)
    {
      D[i] = INF;
    }
  dfs(0, 0);
  for(i = 0; i < n; i++)
    {
      printf("%d %d\n", i, D[i]);
    }
}



Measured memory_bytes: 2088
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using lint = long long int;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;
template<class T> void assign(V<T>& v, int n, const T& a = T()) { v.assign(n, a); }
template<class T, class... U> void assign(V<T>& v, int n, const U&... u) { v.resize(n); for (auto&& i : v) assign(i, u...); }

int main() {
  cin.tie(NULL); ios::sync_with_stdio(false);
  string s; cin >> s;
  int n = s.size();
  cout << s.substr(0, n - 8) << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
using ll = long long;
int main(){
	ll n,S=0,E=0,res=0,num=0,sum=0;
	cin >> n;
	vector<ll> a(n);
	for(ll i=0;i<n;i++)	cin >> a[i];
	while(E<n){
		if(S==E){
			num = num^a[E];
			sum+=a[E];
			E++;
		}
		else if((num^a[E])==(sum+a[E])){
			//cout << S << ' ' << E <<' '<<num << ' ' << sum << endl;
			num = num^a[E];
			sum+=a[E];
			res+=(E-S);
			E++;
		}
		else{
			num = num^a[S];
			sum-=a[S];
			S++;
		}
	}
	cout << res+n << endl;
}

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

int main() {
  int H,W;
  cin >> H >> W;
  vector<vector<string>> indata(H, vector<string>(W));
  vector<vector<int>> outdata(H, vector<int>(W));
  
  for (int i = 0; i < H; i ++) {
    string tmp;
    cin >> tmp;
    for (int j = 0; j < W; j ++) {
      indata.at(i).at(j) = tmp.at(j);
    }
  }
  for (int i = 0; i < H; i ++) {
    bool isFstI = i == 0;
    bool isLstI = i == H - 1;
    for (int j = 0; j < W; j ++) {
      bool isFstJ = j == 0;
      bool isLstJ = j == W - 1;
      int cnt = 0;
      if (indata.at(i).at(j) == "#") {
      } else {
        if (!isFstI) {
          // 上
          if (indata.at(i-1).at(j) == "#") {
            cnt++;
          }
          if (!isFstJ && indata.at(i-1).at(j-1) == "#") {
            cnt++;
          }
          if (!isLstJ && indata.at(i-1).at(j+1) == "#") {
            cnt++;
          }
        }
        if (!isLstI) {
          // 下
          if (indata.at(i+1).at(j) == "#") {
            cnt++;
          }
          if (!isFstJ && indata.at(i+1).at(j-1) == "#") {
            cnt++;
          }
          if (!isLstJ && indata.at(i+1).at(j+1) == "#") {
            cnt++;
          }
        }
        if (!isFstJ && indata.at(i).at(j-1) == "#") {
          cnt++;
        }
        if (!isLstJ && indata.at(i).at(j+1) == "#") {
          cnt++;
        }
        outdata.at(i).at(j) = cnt;
      }
    }
  }
  for (int i = 0; i < H; i ++) {
    for (int j = 0; j < W; j ++) {
      if (indata.at(i).at(j) == "#") {
        cout << "#";
      } else {
        cout << outdata.at(i).at(j);
      }
      
    }
    cout << endl;
  }     
}

Measured memory_bytes: 384
#include<stdio.h>

int main(){
int h,w,i,j;
while(1){
scanf("%d %d",&h,&w);
if(h==0 && w==0)break;
for(i=0;i<h;i++){
for(j=0;j<w;j++){
printf("#");
}
printf("\n");
}
printf("\n");
}
return 0;
}

Measured memory_bytes: 572
#include <bits/stdc++.h>
using namespace std;
#define __ <<' '<<
#define ___ <<' '
#define bash push_back
#define ALL(x) x.begin(),x.end()
//#define int long long

struct IoSetup {IoSetup() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout <<fixed<<setprecision(12);
    cerr <<fixed<<setprecision(12);
}}IoSetup;

using ll = long long;
using pii = pair<int, int>;
constexpr int INF = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int SMOD = 1000000007;
constexpr int NMOD = 998244353;
constexpr int dx[]={1,0,-1,0,1,1,-1,-1};
constexpr int dy[]={0,1,0,-1,-1,1,-1,1};

inline bool inside(int x,int y,int w,int h){return (x>=0 && y>=0 && x<w && y<h);}
template<class T>bool chmax(T &a, const T &b){return(a<b?a=b,true:false);}
template<class T>bool chmin(T &a, const T &b){return(a>b?a=b,true:false);}
inline int qp(int a,ll b,int mo){ll ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}



signed main() {

    int n;
    cin >> n;
    __int128_t sum = 1, lim = 1e18;;
    ll a;
    bool f = false;
    for(int i = 0; i < n; i++) {
        cin >> a;
        if(sum * a > lim) {
            f = true;
        }
        if(!a) {
            cout << 0 << endl;
            return 0;
        }
        sum *= a;
    }
    if(f)
        cout << -1 << endl;
    else
        cout << (long long) sum << endl;
        
  
    return 0;
}



Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> pl;
typedef vector<pl> vp;
#define fore(i,a,b) for(ll i=(ll)(a);i<=(ll)(b);++i)
#define rep(i,n) fore(i,0,(n)-1)
#define rfore(i,a,b) for(ll i=(ll)(b);i>=(ll)(a);--i)
#define rrep(i,n) rfore(i,0,(n)-1)
#define all(x) (x).begin(),(x).end()
const ll INF=1001001001;
const ll LINF=1001001001001001001;
const ll D4[]={0,1,0,-1,0};
const ll D8[]={0,1,1,0,-1,-1,1,-1,0};
template<class T>
bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>
bool chmin(T &a,const T &b){if(b<a){a=b;return 1;}return 0;}
const string YES = "Yes";
const string NO = "No";

void solve(long long a, long long b, long long c){
    if(c-a-b<=0){
        cout<<NO<<endl;
        return;
    }
    if(4*a*b<(c-a-b)*(c-a-b)){
        cout<<YES<<endl;
    }else{
        cout<<NO<<endl;
    }
}

int main(){
    long long a;
    scanf("%lld",&a);
    long long b;
    scanf("%lld",&b);
    long long c;
    scanf("%lld",&c);
    solve(a, b, c);
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;

class Procon
{
    public Procon() { }
    static void Main(string[] agrs)
    {
        new Procon().Do();
    }

    Scanner cin;

    public void Do()
    {
        cin = new Scanner();
        int N = cin.nextInt();
        int L = cin.nextInt();

        int sum = 0;
        int min = 100000;
        for (int i = 0; i < N; i++)
        {
            sum += L + i;
            if (Math.Abs(L + i) < Math.Abs(min))
            {
                min = L + i;
            }
        }

        Console.WriteLine(sum - min);
    }
}

class Scanner
{
    string[] s;
    int i;
    int max_i;

    public Scanner()
    {
        s = new string[0];
        max_i = 0;
        i = 0;
    }

    public string nextString()
    {
        if (i >= s.Length)
        {
            s = Console.ReadLine().Split(' ');
            max_i = s.Length;
            i = 0;
            if (max_i == 0)
            {
                return "";
            }
            return s[i++];
        }
        else
        {
            return s[i++];
        }
    }

    public int nextInt()
    {
        return int.Parse(nextString());
    }


    public long nextLong()
    {
        return long.Parse(nextString());
    }

    public double nextDouble()
    {
        return double.Parse(nextString());
    }

    public string[] arrayString()
    {
        return Console.ReadLine().Split(' ');
    }

    public int[] arrayInt()
    {
        string[] str = Console.ReadLine().Split(' ');
        int[] array = new int[str.Length];
        for (int i = 0; i < str.Length; i++)
        {
            array[i] = int.Parse(str[i]);
        }
        return array;
    }

    public long[] arrayLong()
    {
        string[] str = Console.ReadLine().Split(' ');
        long[] array = new long[str.Length];
        for (int i = 0; i < str.Length; i++)
        {
            array[i] = long.Parse(str[i]);
        }
        return array;
    }

    public double[] arrayDouble()
    {
        string[] str = Console.ReadLine().Split(' ');
        double[] array = new double[str.Length];
        for (int i = 0; i < str.Length; i++)
        {
            array[i] = double.Parse(str[i]);
        }
        return array;
    }
}



Measured memory_bytes: 13140
import sys
from numpy import*
def main(n,q,c,z):
  a=zeros(q,int64)
  t=zeros(9**6,int64)
  b=zeros(9**6,int64)
  j=0
  for i in argsort(z[:,1]):
    l,r=z[i,0],z[i,1]
    while j<r:
      d=c[j]
      j+=1
      x,y,b[d]=b[d]+1,j+1,j
      while x<=n:
        t[x]+=1
        x+=x&-x
      while y<=n:
        t[y]-=1
        y+=y&-y
    while l:
      a[i]+=t[l]
      l-=l&-l
  return a
if sys.argv[-1]=='ONLINE_JUDGE':
  from numba.pycc import CC
  cc=CC('my_module')
  cc.export('main','i8[:](i8,i8,i8[:],i8[:,:])')(main)
  cc.compile()
  exit()
from my_module import main
(n,q),c,*z=[int_(t.split())for t in open(0)]
print(' '.join(map(str,main(n,q,c,int_(z)).tolist())))

Measured memory_bytes: 167588
#include <iostream>
#include <queue>
#include <string>
using namespace std;
struct nami {

  int x,y;
  /*
  nami(int a,int b){
    x=a;
    y=b;
  }
  */
};

queue <nami> Q;
int h,w;
string str[1000];
int map[1000][1000];


int main() {

  cin >> h >> w;

  for(int i=0;i<h;i++) {
    cin >> str[i];
    for(int j=0;j<w;j++) {
      if(str[i][j] == '.') {
	map[i][j] = -1;
	Q.push((nami){j,i});
      }
      else map[i][j] = str[i][j] - '0';

    }
  }

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

  Q.push((nami){-1,-1});

    nami t;
    int count = 0;
  while(!Q.empty()) {

    t  = Q.front();
    Q.pop();

    if(t.x == -1 && t.y == -1){
      if(! Q.empty()){
      Q.push(t);
      count++;
      }
     
      continue;
    } 

   for(int i=0;i<8;i++) {

     if(t.x+dx[i] >=0 && t.x+dx[i] < w && t.y+dy[i] >=0 && t.y+dy[i] < h) {
       if(map[t.y+dy[i]][t.x+dx[i]] >= 1 ){
	 map[t.y+dy[i]][t.x+dx[i]]--;
	 if(map[t.y+dy[i]][t.x+dx[i]] == 0)
	   Q.push((nami){t.x+dx[i],t.y+dy[i]});
       }
     }   
   }
   
  }
  
  cout << count << endl;
  
  
  return 0;
  
}

Measured memory_bytes: 6288
///*.......................Shadman Sakib Utshob............................*///

#include <bits/stdc++.h>
using namespace std;

//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;

#define Boost           ios_base::sync_with_stdio(0);cin.tie(0),cout.tie(0)
#define see(x)        cerr<< __LINE__ << ": " << (#x) << " is "<< (x) <<'\n';
#define pb              push_back
#define inf             1e9+8
#define mp              make_pair
#define rep(i,n)        for(int i=0;i<n;i++)
#define rep1(i,n)       for(int i=1;i<=n;i++)
#define ll              long long
#define pii             pair<ll,ll >
#define MOD             1000000007
#define fileout         freopen("output.txt","w",stdout)
#define mem(x,i)        memset(x,i,sizeof x)
#define Ones(x)         __builtin_popcount(x);
#define PI              acos(-1.0)
#define ff              first
#define ss              second
#define T               int t;cin>>t;while(t--)
#define ok              cout<<"ok"<<endl;
#define all(x)          (x).begin(),(x).end()
#define ordered_set     tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define nln	            cout<<endl;

int main()
{
    Boost;
    int x,y,n,i,j,ans=0;
    cin>>n;
    int v[n+1],c[n+1];
    rep(i,n)
    {
        cin>>v[i];
    }
    rep(i,n)
    {
        cin>>c[i];
    }
    rep(i,n)
    {
        if((v[i]-c[i])>=0)
        {
            ans+=(v[i]-c[i]);
        }
    }
    cout<<ans<<endl;




}


Measured memory_bytes: 3624
n,m=map(int,input().split())
a = [int(input()) for _ in range(m)]

mod=10**9+7
dp=[0]*(n+1)
dp[0]=1
NG=[False]*n
for i in range(m):
    NG[a[i]-1]=True

for i in range(1,n+1):
    if NG[i-1]==False:
        dp[i]=(dp[i-2]+dp[i-1])%mod
print(dp[-1])


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

#define rep(i, a, b) for (__typeof((b)) i = (a); i < (b); i++)
#define nrep(i, a, b) for (__typeof((b)) i = (a); i > (b); i--)
#define all(a) (a).begin(), (a).end()
#define ff first
#define ss second
#define ppi pair<int, int>
#define pppi pair<ppi, int>
#define vi vector<int>
#define vii vector<ppi>
#define viii vector<pppi>
#define vs vector<string>
#define pb push_back
#define bitcount __builtin_popcount //count no's of ones in a set bit
#define prq priority_queue
#define mp make_pair
#define mem(x, val) memset((x), (val), sizeof(x));
#define sz(x) (int)x.size()
#define M_PI 3.14159265358979323846
#define rootdada                      \
    ios_base::sync_with_stdio(false); \
    cin.tie(0);                       \
    cout.tie(0);
#define test  \
    int t;    \
    cin >> t; \
    while (t--)
#define debug(a)          \
    cerr << #a << ": ";   \
    for (auto i : a)      \
        cerr << i << " "; \
    cerr << '\n';
#define trace(a) cerr << #a << ": " << a << "\n"
#define print(ar, n)            \
    for (int u = 0; u < n; u++) \
    {                           \
        cout << ar[u] << " ";   \
    }                           \
    cout << endl;
#define int long long
#define M 1000000007

signed main()
{
    rootdada;

    double a, b, h, m;
    cin >> a >> b >> h >> m;
    double k = h * 30 - 5.5 * m;

    if (k < 0)
        k = k * (-1);

    if (k > 180)
        k = 360 - k;
    k = k * 3.141592653589793 / 180.0;
    double ans = (a * a) + (b * b) - (2 * a * b * cos(k));

    printf("%.10lf", sqrt(ans));

    return 0;
}

Measured memory_bytes: 4280