akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
using namespace std;

#define dump(a) (cerr << (#a) << " = " << (a) << endl)

template<class T> inline void chmax(T& a, const T& b) { if(b > a) a = b; }
template<class T> inline void chmin(T& a, const T& b) { if(b < a) a = b; }

template<typename T, typename U>
ostream& operator<<(ostream& os, const pair<T, U>& p) {
	os << '(' << p.first << ", " << p.second << ')';
	return os;
}

template<class Tuple, unsigned Index>
void print_tuple(ostream& os, const Tuple& t) {}

template<class Tuple, unsigned Index, class Type, class... Types>
void print_tuple(ostream& os, const Tuple& t) {
	if(Index > 0) os << ", ";
	os << get<Index>(t);
	print_tuple<Tuple, Index + 1, Types...>(os, t);
}

template<class... Types>
ostream& operator<<(ostream& os, const tuple<Types...>& t) {
	os << '(';
	print_tuple<tuple<Types...>, 0, Types...>(os, t);
	return os << ')';
}

template<class Iterator>
ostream& dump_range(ostream&, Iterator, const Iterator&);

template<typename T>
ostream& operator<<(ostream& os, vector<T> c) {
	return dump_range(os, c.cbegin(), c.cend());
}

template<class Iterator>
ostream& dump_range(ostream& os, Iterator first, const Iterator& last) {
	os << '[';
	for(int i = 0; first != last; ++i, ++first) {
		if(i) os << ", ";
		os << *first;
	}
	return os << ']';
}

constexpr double EPS = 1e-8;
double p, q, e, t;

double search(int k, double l, double r) {
	if(k == 0) {
		const double tt = (l + r) / 2.0;
		return abs(tt - t) < e ? 1.0 : 0.0;
	}

	if(t + e < l || r < t - e) return 0.0;
	if(t - e < l && r < t + e) return 1.0;

	const double h = (l + r) / 2.0;
	double res = 0.0;

	if(h > t - EPS) {
		res += q * search(k - 1, l, h);
		res += p * search(k - 1, h, r);
	}
	else {
		res += p * search(k - 1, l, h);
		res += q * search(k - 1, h, r);
	}

	return res;
}

int main() {
	int k;
	double l, r;
	scanf("%d %lf %lf\n%lf\n%lf\n%lf", &k, &l, &r, &p, &e, &t);

	q = 1.0 - p;

	printf("%.10lf\n", search(k, l, r));

	return EXIT_SUCCESS;
}

Measured memory_bytes: 1228
module.exports=function(t){var e={};function r(n){if(e[n])return e[n].exports;var i=e[n]={i:n,l:!1,exports:{}};return t[n].call(i.exports,i,i.exports,r),i.l=!0,i.exports}return r.m=t,r.c=e,r.d=function(t,e,n){r.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:n})},r.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},r.t=function(t,e){if(1&e&&(t=r(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var i in t)r.d(n,i,function(e){return t[e]}.bind(null,i));return n},r.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return r.d(e,"a",e),e},r.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},r.p="",r(r.s=0)}([function(t,e,r){"use strict";var n=r(1);r(2)(n.readFileSync("/dev/stdin","utf8"))},function(t,e){t.exports=require("fs")},function(t,e,r){"use strict";var n=r(3),i=r(5);t.exports=function(t){var e=new n(t);i(e)}},function(t,e,r){"use strict";var n=r(4);t.exports=class{constructor(t){var e=t.trim().split(/\s+/g);this.inp=new n(e)}inr(){return this.inp.deq()}in(){return parseInt(this.inp.deq(),10)}fin(){this.inp.clear()}}},function(t,e,r){"use strict";t.exports=class{constructor(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];this.size=t.length,this.items=t,this.ind=0}enq(t){this.size+=1,this.items.push(t)}deq(){var t=this.items[this.ind];return this.size-=1,this.ind+=1,t}clear(){this.items=[],this.size=0,this.ind=0}}},function(t,e,r){"use strict";t.exports=function(t){for(var e=t.in(),r=1;r<=9;r++)for(var n=0;n<=9;n++)if(r*n==e)return void console.log("Yes");console.log("No")}}]);

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

int gcd(int m, int n){
	if(m == 0 || n == 0)return 0;
	while(m != n){
		if(m > n)m -= n;
		else n -= m;
	}
	return m;
}

int main(){
	int m, n;
	while(cin >> m >> n){
		int x = gcd(m, n);
		cout << x << " " << m / x * n << endl;
	}
    return 0;
}

Measured memory_bytes: 2980
#include<bits/stdc++.h>
//macros
using namespace std;
typedef long long ll;
typedef pair<int, int > Pii;
typedef pair<ll, ll> Pll;
typedef vector<int> Vi;
typedef vector<ll> Vll;
#define pb push_back
#define rs resize 
#define rep(i, a, b) for(int i=(a); i<(b); i++)
#define repll(i, a, b) for(ll i=(a); i<(b); i++)
#define Yes cout << "Yes" << endl
#define No cout << "No" << endl
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl
#define COUT(a) cout << a << endl
#define ALL(a) (a).begin(),(a).end()
const long long int mod = 1e9 + 7;


int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false); 
    string S;
    cin >> S;
    int cnt = 0;

    rep(i,0,S.size()/2){
        if(S[i]==S[S.size()-i-1]) continue;
        cnt++;
    }    
    COUT(cnt);
    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MM = 1000000000;
const int MOD = MM + 7;
const int MAX = 510000;
#define rep(i, n) for(ll i=0; i<n; i++)
#define Rep(i, j, n) for(ll i=j; i<n; i++)
#define all(vec) vec.begin(), vec.end()
template<class T> inline bool chmin(T& a, T b) {if(a > b) {a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) {if(a < b) {a = b; return true;} return false;}
const ll INF = 1LL << 60;

int main() {
    ll n, m; cin >> n >> m;
    rep(i, m) {
        int a; cin >> a;
        n -= a;
    }
    cout << (n < 0 ? -1 : n) << endl;
}


Measured memory_bytes: 3588
#include <cstdio>

int h, w, cnt;
char a[55][55];

int main(void) {
    int i, j, x, y;
    scanf("%d %d", &h, &w);
    for (i = 1; i <= h; i++) scanf("%s", &a[i][1]);
    for (i = 1; i <= h; i++, puts("")) for (j = 1; j <= w; j++) {
        if (a[i][j] == '#') {printf("#"); continue;}
        cnt = 0;
        for (x = i-1; x <= i+1; x++) for (y = j - 1; y <= j+1; y++) if (a[x][y] == '#') cnt++;
        printf("%d", cnt);
    }
    return 0;
}


Measured memory_bytes: 128
MOD=10**9+7
cnt=0; sum=0; prev=nil; can=true; h=Hash.new(0)
def gs() gets.chomp end
def gi() gets.chomp.to_i end
def gsmi() gets.chomp.split.map(&:to_i) end

def desc(ar) ar.sort!{|x,y| y<=>x} end
def min(a,b) a<=b ? a : b end
def max(a,b) a>=b ? a : b end
def sum(ar) ar.inject(:+) end

def C(a,b) b==0||a==b ? 1 : (b=a-b if a/2<b;(a-b+1..a).inject(:*)/(1..b).inject(:*)) end
def rui(ar) s=[0]; ar.size.times{|i| s<<s[-1]+ar[i]}; s end
def rev_rui(ar) s=[0]; ar.size.times.reverse_each{|i| s<<s[-1]+ar[i]}; s end

def puts_yesno(b) puts(b ? 'Yes' : 'No') end
def putsend(s) puts s; exit end
def debug(k,v) puts "#{k}:#{v}" end
########### ( ˘ω˘ )ｽﾔｧ… ###########
n=gs.reverse
l=n.length

c=0
l.times do |i|
  tar=n[i].to_i+c
  if tar>=6
    c=1
    cnt+=10-tar
  elsif tar==5 && i<l-1 && n[i+1].to_i>=5
    c=1
    cnt+=10-tar
  else
    c=0
    cnt+=tar
  end
end
puts cnt+c

Measured memory_bytes: 4884
#include <bits/stdc++.h>
using namespace std;
int main() {
    int N;
    cin>>N;
    int A[N];
    for(int i=0;i<N;i++){
        cin>>A[i];
    }
    for(int i=0;i<N;i++){
        int v=A[i];
        int j=i-1;
        while(j>=0&&A[j]>v){
            A[j+1]=A[j];
            j--;
        }
        A[j+1]=v;
        for(int k=0;k<N;k++){
            cout<<A[k];
            if(k==N-1) cout<<endl;
            else cout<<' ';
        }
    }
}



Measured memory_bytes: 3120
#!/usr/bin/env python3


def solve(n, d, da, q, qa):

    a = [d]
    x = d
    for di in da:
        x = min(x, max(x - di, di - x))
        a.append(x)

    b = [1]
    x = 1
    for i in range(n - 1, -1, -1):
        di = da[i]
        if di // 2 < x:
            x += di
        b.append(x)
    b.reverse()

    for qi in qa:
        if b[qi] <= a[qi - 1]:
            print('YES')
        else:
            print('NO')


def main():
    n, d = input().split()
    n = int(n)
    d = int(d)
    da = list(map(int, input().split()))
    q = input()
    q = int(q)
    qa = list(map(int, input().split()))

    solve(n, d, da, q, qa)

if __name__ == '__main__':
    main()



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

int main() {
	int i, n;
	
	set<string> st;
	
	cin >> n;
	for (i = 0; i < n; i++) {
		string s;
		cin >> s;
		st.insert(s);
	}
	cout << st.size() << endl;
	return 0;
}

Measured memory_bytes: 19228
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n,k;
    cin>>n>>k;
    int a[n+10];
    a[0]=1;
    for(int i=1;i<=n;i++){
        a[i]=min(a[i-1]*2,a[i-1]+k);
    }
    cout<<a[n];
    return 0;
}

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

using namespace std;

char str[1005];
int state[256];

int main() {
    int n;
    scanf("%s", str);
    n = strlen(str);
    for(int i = 0; i < n; i++) state[str[i]] = true;
    if(state['N'] ^ state['S']) return printf("No\n"), 0;
    if(state['E'] ^ state['W']) return printf("No\n"), 0;
    printf("Yes\n");
    return 0;
}

//15:58:30

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




int main()
{
  long long m , n;

  cin >> m >> n;

  if(m < n)
  {
      for(int i = 0; i < n ; i++)
        cout << m ;
  }else if (m > n){
      for(int i = 0; i < m ;i++)
      {
        cout << n;
      }
  }else if(m == n)
  {
      int mn = min(m,n);

      for(int i = 0 ;i < mn ;i++)
      {
          cout << m ;
      }
  }

  return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#define RI register int
using namespace std;
const int N=1005;
int n,m,a,b; bool p[N][N];
int main()
{
	RI i,j; scanf("%d%d%d%d",&n,&m,&a,&b);
	for (j=1;j<=a;++j) for (i=1;i<=n;++i) p[i][j]^=1;
	for (i=1;i<=b;++i) for (j=1;j<=m;++j) p[i][j]^=1;
	for (i=1;i<=n;++i,putchar('\n')) for (j=1;j<=m;++j)
	putchar(p[i][j]+48); return 0;
}

Measured memory_bytes: 2176
N = int(input())
A = list(map(int,input().split()))
state = 0
count = 1
for i in range(1,N):
    note = state
    d = A[i] - A[i-1]
    if d > 0:
        state = 1
    elif d == 0:
        pass
    elif d < 0:
        state = -1
    if (state,note) == (1,-1) or (state,note) == (-1,1):
        count += 1
        state = 0
print(count)

Measured memory_bytes: 14252
#include<stdio.h>
int main()
{
    int a[6],A[6],i;
    for(i=0; i<5; i++)
    {
        scanf("%d",&a[i]);

        A[i]=(a[i]/10+1)*10-a[i];
       if(A[i]==10)A[i]=0;
    }
    int max=-1,s=0;
    for(i=0; i<5; i++)
    {
        if(A[i]>max)
            max=A[i];
    }
    for(i=0; i<5; i++)
    {
        if(A[i]==max)
        {
            A[i]=0;
            break;
        }

    }
    for(i=0; i<5; i++)
        s+=a[i]+A[i];
    printf("%d",s);
}


Measured memory_bytes: 256
/+ dub.sdl:
	name "A"
	dependency "dcomp" version=">=0.0.2"
+/

import std.algorithm, std.range, std.stdio, std.math, std.conv, core.bitop;

// import dcomp.scanner;

bool solve(bool[] a) {
    int n = (a.length.to!int + 1) / 2;

    int l = n-1;
    while (l) {
        if (a[l-1] == a[l]) break;
        l--;
    }
    int r = n-1;
    while (r < 2*n-2) {
        if (a[r] == a[r+1]) break;
        r++;
    }
    if ((n-1)-l < r-(n-1)) {
        return a[l];
    } else {
        return a[r];
    }
}

int main() {
    import std.conv;
	auto sc = new Scanner();
    int n;
    int[] a;
    sc.read(n, a);

    int l = 0, r = 2*n + 10; // x以上
    while (r-l > 1) {
        int md = (l+r)/2;
        if (solve(a.map!(a => (md <= a)).array)) {
            l = md;
        } else {
            r = md;
        }
    }
    writeln(l);
	return 0;
}
/* IMPORT /Users/yosupo/Program/dcomp/source/dcomp/scanner.d */
// module dcomp.scanner;

class Scanner {
    import std.stdio : File, readln, stdin;
    import std.conv : to;
    import std.range : front, popFront, array, ElementType;
    import std.array : split;
    import std.traits : isSomeString, isDynamicArray;
    import std.algorithm : map;
    File f;
    this(File f = stdin) {
        this.f = f;
    }
    string[] buf;
    bool succ() {
        while (!buf.length) {
            if (f.eof) return false;
            buf = readln.split;
        }
        return true;
    }
    int read(Args...)(auto ref Args args) {
        foreach (i, ref v; args) {
            if (!succ()) return i;
            alias VT = typeof(v);
            static if (!isSomeString!VT && isDynamicArray!VT) {
                v = buf.map!(to!(ElementType!VT)).array;
                buf.length = 0;
            } else {
                v = buf.front.to!VT;
                buf.popFront();
            }
        }
        return args.length;
    }
}


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

int main()
{
	int N;
	cin >> N;

	vector<long long> L( N + 1 );
	L[0] = 2;
	L[1] = 1;
	for( int i = 2; i <= N; i++ ) {
		L[i] = L[i - 1] + L[i - 2];
	}
	long long ans = L[N];

	cout << ans << endl;
}


Measured memory_bytes: 3524
#include <iostream>
#include <algorithm>
using namespace std;
int main()
{
	int a, b, c, d, e;
	cin >> a >> b >> c >> d >> e;
	if (c >= e && d >= e && c + e <= a && d + e <= b)
	{
		cout << "Yes" <<endl;
	}
	else
	{
		cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 3092
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <functional>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#define nmax_def 110000
#define Cmax_def 2200
#define mod 1000000007
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;

int main() {
	int N, M;
	cin >> N >> M;
	vector<pll> AB(N);
	rep(i, N) {
		cin >> AB[i].first >> AB[i].second;
	}
	sort(AB.begin(), AB.end(), less<pll>());
	priority_queue<ll, vl, less<ll>> B_que;
	int j = 0;
	ll ans = 0;
	rep(i, M + 1) { // 残りi日
		while (1) {
			if (j >= N)
				break;
			if (AB[j].first > i)
				break;
			B_que.push(AB[j].second); // i日で仕事可能
			j++;
		}
		if (B_que.size() != 0) {
			ll anstmp = B_que.top(); // i日以下で仕事可能なものの最大値
			B_que.pop();
			ans += anstmp;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 2936
#include <iostream>
#include <iomanip>
#include <math.h>
#include <string>
#include <algorithm>
#include <vector>
#include <numeric>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <bitset>
using namespace std;

#define ll long long int
#define rep(i, a, n) for (ll i = a; i < n; i++)
#define repm(i, a, n) for (ll i = a; i >= n; i--)
#define INF 1e9
#define LINF 1e17
#define MOD (int)(1e9 + 7)
#define pi 3.141592653589
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vi vector<int>
#define vs vector<string>
#define vii vector<vector<int>>
#define vll vector<ll>
#define vllll vector<vector<ll>>
#define vd vector<double>
#define ALL(a) (a).begin(), (a).end()
#define sort_v(a) sort(a.begin(), a.end())
#define reverse_v(a) reverse(a.begin(), a.end())
#define fi first
#define se second

void print(bool c)
{
    (c) ? (cout << "Yes" << endl) : (cout << "No" << endl);
}

void Print(bool c)
{
    (c) ? (cout << "YES" << endl) : (cout << "NO" << endl);
}

//最小公倍数
template <typename T>
T gcd(T a, T b)
{
    while (1)
    {
        if (a < b)
            swap(a, b);
        if (b == 0)
            break;
        a %= b;
    }
    return a;
}

//最大公約数
template <typename T>
T lcm(T a, T b)
{
    return a * b / gcd(a, b);
}
//セカンドキー->ファーストキーの順ソート
bool cmp(const pii &a, const pii &b)
{
    if (a.second != b.second)
        return a.second < b.second;
    return a.first < b.first;
}

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

int eve(int x)
{
    if (x % 400 == 0)
        return 1;
    if (x % 100 == 0)
        return 0;
    if (x % 4 == 0)
        return 1;
    return 0;
}

int main(void)
{
    ll n, a, b;
    cin >> n >> a >> b;
    vll x(n);
    ll ans = 0;
    rep(i, 0, n) cin >> x[i];
    rep(i, 1, n)
        ans += min((x[i] - x[i - 1]) * a, b);
    cout << ans << endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <map>
#include <string>
#include <algorithm>
#define inf 0x3f3f3f3f
#define LL long long

using namespace std;
int n,m;
map<LL,int> ma;

int main()
{
    while(scanf("%d",&n)!=EOF)
    {
        int x;
        for(int i=0;i<n;i++)
        {
            scanf("%d",&x);
            ma[x]++;
        }
        scanf("%d",&m);
        int flag=1;
        for(int i=0;i<m;i++)
        {
            scanf("%d",&x);
            if(!ma[x])
            {
                flag=0;
            }
            ma[x]--;
        }
        if(flag)
        {
            printf("YES\n");
        }
        else
        {
            printf("NO\n");
        }
    }
    return 0;
}


Measured memory_bytes: 12928
#include<stdio.h>
#include<cctype>
int main(){
    char ch;
    int count[26] = {};
    while((ch = getchar()) != EOF){
        if(isupper(ch)) ch = tolower(ch);
        if(isalpha(ch)) count[ch -'a'] += 1;
    }
    
    for(int i = 0;i < 26;i++){
        printf("%c : %d\n",i+'a',count[i]);
    }
}


Measured memory_bytes: 2676
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> pll;
const ll mod=1e9+7;
//const ll mod=998244353;
const ll inf=1LL<<61;

int d;
int c[26],s[365][26],last[26];

int main() {
  cin >> d;
  for(int i=0;i<26;i++) {
    cin >> c[i];
  }
  for(int i=0;i<d;i++) {
    for(int j=0;j<26;j++) {
      cin >> s[i][j];
    }
  }
  int score=0;
  for(int i=0;i<d;i++) {
    int t;
    cin >> t;
    t--;
    score+=s[i][t];
    last[t]=i+1;
    for(int j=0;j<26;j++) {
      score-=c[j]*(i+1-last[j]);
    }
    cout << score << endl;
  }
}

Measured memory_bytes: 3628
# Your code here!
aa=gets().chomp
b=aa.length
cc=aa.unpack("C*")
#puts(aa,cc)
for i in 0..(b-1)
    #puts(i,aa[i],cc[i])
    if cc[i]==44
        cc[i]=32
    end
end

dd=cc.pack("C*")
print(dd)

Measured memory_bytes: 1916
#include <bits/stdc++.h>
#define REP(i, n) for (ll i = 0; i < (ll)(n); i++)
using namespace std;
template<class T>inline bool chmax(T &a, const T &b){if(a < b){a = b; return 1;}return 0;}
template<class T>inline bool chmin(T &a, const T &b){if(a > b){a = b; return 1;}return 0;}
typedef long long ll;

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N, K; cin >> N >> K;
  vector<int> x(N, 0);
  for(auto &i : x) cin >> i;
  int ans = 0;
  REP(i, N){
    ans += min(x[i], K-x[i]) * 2;
  }
  cout << ans << endl;
}

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

int main() {
  int A, B, c;
  cin >> A >> B;

  if (A+B > A-B)
    c = A+B;
  else
    c = A-B;

  if (A*B > c)
    c = A*B;

  cout << c << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define INF 1005
using namespace std;
int main()
{
	int n,m;
	cin>>n>>m;
	int g[105][105]={0},d[105][105]={0};
	vector<pair<int,int> >e;
	for(int i=0;i<=104;i++)for(int j=0;j<=104;j++)if(i!=j)d[i][j]=INF;
	int vis[105][105]={0};
	for(int i=0;i<m;i++)
	{
		int a,b,w;
		cin>>a>>b>>w;
		e.push_back(make_pair(a,b));
		d[a][b]=w;d[b][a]=w;
		//vis[a][b]=1;vis[b][a]=1;
	}
	for(int i=0;i<=104;i++)for(int j=0;j<=104;j++)g[i][j]=d[i][j];
	for(int k=1;k<=n;k++)
	{
		for(int i=1;i<=n;i++)
		{
			//if(i==j)continue;
			for(int j=1;j<=n;j++)
			{
				if(g[i][k]+g[k][j] < g[i][j])
				{
					g[i][j]=g[i][k]+g[k][j];
				}
			}
			//if(g[i][j]==d[i][j])vis[i][j]=1;
		}
	}
	for(int i=1;i<=n;i++)for(int j=1;j<=n;j++)if(g[i][j]==d[i][j])vis[i][j]=1;
/*	for(int i=1;i<=n;i++)
        {
                for(int j=1;j<=n;j++)
                {
                        if(i==j)continue;
                        int mid=i;
                        for(int k=1;k<=n;k++)
                        {
                                if(g[i][k]+g[k][j] == g[i][j])
                                {
                                        vis[i][k]=1;vis[k][j]=1;vis[k][i]=1;vis[j][k]=1;
                                        vis[i][mid]=0;vis[mid][j]=0;vis[mid][i]=0;vis[j][mid]=0;
                                        mid=k;
                                }
                                //else {vis[i][mid]=1;}
                        }
                }
        }*/
	int cnt=0;
	for(int i=0;i<e.size();i++)
	{
		int a=e[i].first,b=e[i].second;
		if(vis[b][a] || vis[a][b]){}
		else cnt++;
	}
	cout<<cnt<<"\n";
	return 0;
}

Measured memory_bytes: 384
import fractions
a,b,c,d=map(int, input().split())
cdlcm= c*d//fractions.gcd(c,d)
a-=1
tc = b//c-a//c
td = b//d-a//d
tlcm = b//cdlcm-a//cdlcm
print(b-a-tc-td+tlcm)

Measured memory_bytes: 5088
import sys, re
from math import ceil, floor, sqrt, pi, factorial, gcd, cos, radians
from copy import deepcopy
from collections import Counter, deque
from heapq import heapify, heappop, heappush
from itertools import accumulate, product, combinations, combinations_with_replacement
from bisect import bisect, bisect_left
from functools import reduce
input = sys.stdin.readline 
def i_input(): return int(input())
def i_map(): return map(int, input().split())
def i_list(): return list(i_map())
def i_row(N): return [i_input() for _ in range(N)]
def i_row_list(N): return [i_list() for _ in range(N)]
def s_input(): return input()
def s_map(): return input().split()
def s_list(): return list(s_map())
def s_row(N): return [s_input for _ in range(N)]
def s_row_list(N): return [s_list() for _ in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
def lcm(a, b): return a * b // gcd(a, b)
sys.setrecursionlimit(10 ** 6)
INF = float('inf')
MOD = 10 ** 9 + 7

def main():
    a, b, h, m = i_map()

    minitus = 6 * m
    hours = 30 * h + 0.5 * m

    if abs(hours-minitus) > 180:
        theta = 360 - abs(hours-minitus)
    else:
        theta = abs(hours-minitus)

    ans2 = pow(a,2) + pow(b,2) - 2 * a * b * cos(radians(theta))

    print(pow(ans2,0.5))

if __name__ == '__main__':
    main()


Measured memory_bytes: 70640
/*
* welcome to my code!
* ------------------------------------------
* author : lynmisakura(twitter : @andoreiji11)
*/

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

using ll = long long;

#define REP(i,n) for(int i = 0;i < n;i++)
#define all(x) x.begin(),x.end()
#define dup(x,y) (x + y - 1)/y
#define sz(v) (int)v.size()
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define fi first
#define se second

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

int h,w,k;
string g[10];
int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);

   cin >> h >> w >> k;
   REP(i,h){
       cin >> g[i];
   }
   int64_t ans= 0;

   REP(mask,(1 << (h+w))){
       string ng[10];
       REP(i,h) ng[i] = g[i];
       int64_t tmp = 0;
       set<pair<int,int>> S;
       REP(j,h){
           if(mask >> j & 1){
              REP(l,w){
                  ng[j][l] = '?';
              }
           }
       }
       REP(j,w){
           if(mask >> (j + h) & 1){
               REP(l,h){
                   ng[l][j] = '?';
               }
           }
       }
       REP(j,h)REP(l,w) tmp += (ng[j][l] == '#');
       ans += (tmp == k);
   }
   cout << ans << '\n';

}


Measured memory_bytes: 3652
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		//宣言文
		//標準入力オブジェクトを生成
		Scanner sc = new Scanner(System.in);
		//標準入力で以下の変数を初期化
		int numberN = sc.nextInt();
		int numberA = sc.nextInt();
		int numberB = sc.nextInt();
		//AとBの和変数
		int sumNumAB = 0;
		//10の位と1の位和変数
		int sumTenOne = 0;
		//処理文
		//1<= ● <= N　繰り返し　1からNまで
		for (int i = 1; i <= numberN; i++) {
			//●　選別する　10の位と1の位の値
			//合計する　合計してAとBの範囲であるもの
			//合計していく sumNumAB
			sumTenOne = digitNumberSummation(i);
			if ((numberA <= sumTenOne && sumTenOne <= numberB)) {
				sumNumAB += i;
			}
		}
		//標準出力　合計したsumNumAB
		System.out.print(sumNumAB);
	}
	//各桁を計算し、和を返す
	public static int digitNumberSummation(int i){

		int num = i;
		int sum = 0;
		while(num > 0) {
			sum += num % 10;
			num /= 10;
		}
		
		return sum;
	}
}

Measured memory_bytes: 23892
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <numeric>
using namespace std;
typedef long long int ll;

#define EPS (1e-7)
#define INF 1e18
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
#define PI (acos(-1))

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


int main() {
    int r;
    cin >> r;
    cout << (r * r) << endl;

    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
 int main(void){
    int i,j,N,mem,min;
    int a[150];
    min =0;
    scanf("%d",&N);
    for(i=0;i<N;i++){
        scanf("%d",&a[i]);
    }
    for(i=0;i<N-1;i++){
        for(j=0;j<N-1;j++){
            if(a[j]>a[j+1]){
                mem=a[j];
                a[j]=a[j+1];
                a[j+1]=mem;
                min++;
            }
        }
    }
    for(i=0;i<N-1;i++){
        printf("%d ",a[i]);
    }
    printf("%d\n%d\n",a[N-1],min);

    return 0;
 }

Measured memory_bytes: 600
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; --i)
#define whole(x) (x).begin(),(x).end()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
using P = pair<int, int>;
#define debug(var) cerr << "[" << #var << "] " << var << endl
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
const ll mod = 1000000007;
const int dx[] = {-1,0,1,0};
const int dy[] = {0,-1,0,1};


int main(){
    int h, w;
    cin >> h >> w;
    int ans = 0;
    vector<vector<int>> c(10, vector<int>(10));
    rep(i, 10) rep(j, 10) cin >> c[i][j];
    rep(k, 10) rep(i, 10) rep(j, 10) {
        chmin(c[i][j], c[i][k] + c[k][j]);
    }
    rep(i, h) rep(j, w) {
        int a;
        cin >> a;
        if (a!=-1) {
            ans += c[a][1];
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3612
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using static MyIO;


public class C
{
	public static void Main()	
	{
		int sx = GetInt();
		int sy = GetInt();
		int tx = GetInt();
		int ty = GetInt();

		StringBuilder sb = new StringBuilder();
		for(int i = 0; i < tx - sx; i++)
			sb.Append("R");
		for(int i = 0; i < ty - sy; i++)
			sb.Append("U");
		for(int i = 0; i < tx - sx; i++)
			sb.Append("L");
		for(int i = 0; i < ty - sy; i++)
			sb.Append("D");
		
		sb.Append("D");
		for(int i = 0; i < tx - sx + 1; i++)
			sb.Append("R");
		for(int i = 0; i < ty - sy + 1; i++)
			sb.Append("U");
		sb.Append("LU");
		for(int i = 0; i < tx - sx + 1; i++)
			sb.Append("L");
		for(int i = 0; i < ty - sy + 1; i++)
			sb.Append("D");
		sb.Append("R");
		
		Console.WriteLine(sb);
	}
}


public static class MyIO
{
	private static string[] args = null;
	private static int num = -1;
	private static int used = -1;

	private static string getArg()
	{
		if(used == num)
		{
			args = Console.ReadLine().Split(' ');
			num = args.Length;
			used = 0;
		}
		return args[used++];
	}

	public static int GetInt(){ return int.Parse(getArg()); }
	public static long GetLong(){ return long.Parse(getArg()); }
	public static double GetDouble(){ return double.Parse(getArg()); }
	public static string GetString(){ return getArg(); }
}


Measured memory_bytes: 13140
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int main()
{
  ll X;
  cin >> X;
  ll ans = 100;
  int y = 0;
  while(ans < X) {
    ans += ans / 100;
    y++;
  } 
  cout << y << endl;
  return 0;
}

Measured memory_bytes: 3556
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(var, begin, end) for (int var = (begin); var <= (end); var++)
#define RFOR(var, begin, end) for (int var = (begin); var >= (end); var--)
#define REP(var, length) FOR(var, 0, length - 1)
#define RREP(var, length) RFOR(var, length - 1, 0)
#define EACH(value, var) for (auto value : var)
#define SORT(var) sort(var.begin(), var.end())
#define REVERSE(var) reverse(var.begin(), var.end())
#define RSORT(var) SORT(var); REVERSE(var)
#define OPTIMIZE_STDIO ios::sync_with_stdio(false);cin.tie(0);cout.precision(10);cout << fixed
#define endl '\n'

const int INF = 1e9;
const ll MOD = 1e9 + 7;
const ll LINF = 1e18;
struct mint {
    ll x;
    mint() : x(0) {}
    mint(ll x) : x((x % MOD + MOD) % MOD) {}
    mint& operator+=(const mint& r) { if ((x += r.x) >= MOD) { x -= MOD; } return *this; }
    mint& operator-=(const mint& r) { if ((x -= r.x) < 0) { x += MOD; } return *this; }
    mint& operator*=(const mint& r) { if ((x *= r.x) > MOD) { x %= MOD; } return *this; }
    mint& operator++() { if ((++x) >= MOD) { x -= MOD; } return *this; }
    mint operator++(int) { mint ret = x; if ((++x) >= MOD) { x-= MOD; } return ret; }
    mint& operator--() { if ((--x) < 0) { x += MOD; } return *this; }
    mint operator--(int) { mint ret = x; if ((--x) < 0) { x += MOD; } return ret; }
    mint operator+(const mint& r) { mint ret; return ret = x + r.x; }
    mint operator-(const mint& r) { mint ret; return ret = x - r.x; }
    mint operator*(const mint& r) { mint ret; return ret = x * r.x; }
    mint operator-() { return mint() - *this; }
    bool operator<(const mint& a) { return x < a.x; }
    bool operator>(const mint& a) { return x > a.x; }
    bool operator<=(const mint& a) { return x <= a.x; }
    bool operator>=(const mint& a) { return x >= a.x; }
    bool operator==(const mint& a) { return x == a.x; }
    bool operator!=(const mint& a) { return x != a.x; }
};
ostream& operator<<(ostream& os, const mint& r) { os << r.x; return os; }
ostream& operator>>(ostream& os, const mint& r) { os >> r.x; return os; }

int min_three(int a, int b, int c){
  if (b > c) swap(b, c);
  if (a > b) swap(a, b);
  return a;
}

void solve(istream& cin, ostream& cout) {
  int n, x, y;
  cin >> n >> x >> y;
  map<int, int> m;
  FOR(i, 1, n) {
    FOR(j, i, n) {
      if (i == j) continue;
      int ans;
      ans = min_three(abs(j - i), abs(x - i) + 1 + abs(j - y),
                abs(y - i) + 1 + abs(j - x));
      if (m.count(ans) == 0) {
        m[ans] = 1;
      } else {
        m[ans]++;
      }
    }
  }
  FOR(i, 1, n-1) {
    cout << m[i] << endl;
  }
}

#ifndef TEST
int main() {
  OPTIMIZE_STDIO;
  solve(cin, cout);
}
#endif


Measured memory_bytes: 384
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!

        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int ans = 0;
        for(int i = 0;i < n;i++){
            int temp = sc.nextInt();
            while(temp % 2 == 0){
                ans ++;
                temp = temp / 2;
            }
        }

        System.out.println(ans);

    }
}

Measured memory_bytes: 35596
// 2014/06/16 Tazoe

#include <iostream>
using namespace std;

const int INF = 1000000000;

int main()
{
	while(true){
		int n, m;
		cin >> n >> m;

		if(n==0 && m==0)
			break;

		int C[100][100];
		int T[100][100];
		for(int i=0; i<m; i++){
			for(int j=0; j<m; j++){
				if(i==j){
					C[i][j] = T[i][j] = 0;
				}
				else{
					C[i][j] = T[i][j] = INF;
				}
			}
		}

		for(int i=0; i<n; i++){
			int a, b, c, t;
			cin >> a >> b >> c >> t;

			C[a-1][b-1] = C[b-1][a-1] = c;
			T[a-1][b-1] = T[b-1][a-1] = t;
		}
//???????????§????????£?????????
//????????????
		for(int k=0;k<m;k++){
			for(int i=0;i<m;i++){
				for(int j=0;j<m;j++){
					if(C[i][j]>C[i][k]+C[k][j]){
						C[i][j]=C[i][k]+C[k][j];
					}
				}
			}
		}
//????????????
		for(int k=0;k<m;k++){
			for(int i=0;i<m;i++){
				for(int j=0;j<m;j++){
					if(T[i][j]>T[i][k]+T[k][j]){
						T[i][j]=T[i][k]+T[k][j];
					}
				}
			}
		}
//???????????????
		int k;
		cin>>k;
		for(int i=0;i<k;i++){
			int p,q,r;
			cin>>p>>q>>r;
			if(r==0)cout<<C[p-1][q-1]<<endl;
			if(r==1)cout<<T[p-1][q-1]<<endl;
		
		}
	//??????
	//	for(int i=0;i<k;i++){
	//		cout<<A[i]<<' ';
	//	}
//???????????????????????????
//	cout<<endl;
	}

	return 0;
}

Measured memory_bytes: 3072
import math
N, D = map(int, input().split())

mylist = []
for i in range(N):
  mylist += [input().split()]

cnt = 0
for i in range(0, N):
  for j in range(0, N):
    if i != j and i < j:
      mysum = 0
      for k in range(D):
        mysum += (int(mylist[i][k])-int(mylist[j][k]))**2
      #print(math.sqrt(mysum))
      if (math.sqrt(mysum)).is_integer():
      	cnt += 1
print(cnt)




Measured memory_bytes: 3064
from itertools import product

N=int(input())

P=[[] for i in range(N)]
for i in range(N):
    A=int(input())
    for j in range(A):
        x,y=map(int,input().split())
        P[i].append([x-1,y])

s=[0,1]
lis=list(product(s,repeat=N))

L=len(lis)
ans=0
for i in range(L): 
    f=True
    for j in range(N):
        if lis[i][j]==1:
            for k in range(len(P[j])):
                if P[j][k][1]==lis[i][P[j][k][0]]:
                    continue
                else:
                    f=False
                    break
            if f==False:
                break
    if f:
        cnt=lis[i].count(1)
        ans=max(ans,cnt)

print(ans)



Measured memory_bytes: 8820
#prag\
ma GCC optimize("O3")
#include<bits/stdc++.h>
using namespace std;

set<string> a;
int main()
{
	ios::sync_with_stdio(false);cin.tie(0);
	string s;
	int k;
	cin>>s>>k;
	int l=s.length();
	for(int i=0;i<l;++i){
		int x=min(l-1,i+k-1);
		string y="";
		for(int j=i;j<=x;++j)
			y+=s[j],a.insert(y);
	}
	for(int i=1;i<k;++i) a.erase(a.begin());
	cout<<*a.begin();
}

Measured memory_bytes: 1664
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; ++i)
using namespace std;
using ll = int64_t;
using vi = vector<int>;
using vvi = vector<vi>;



int main() {
    int N, W;
    cin >> N >> W;
    vi w(N);
    vector<ll> v(N);
    rep(i, N) {
        cin >> w[i] >> v[i];
    }
    vector<ll> dp(W+1);

    rep(i, N) {
        vector<ll> dp_(W+1);
        
        rep(j, W+1-w[i]) {
            dp_[j] = dp[j];
        }
        int j = 0;
        while(W-w[i] >= j){
            dp[j+w[i]] = max(dp[j+w[i]], dp_[j] + v[i]);
            ++j;
        }
        /*rep(i, W) {
            cout << dp[i] << '\n';
        }
        cout << '\n';*/
    }
    cout << dp[W] << '\n';
    
}

Measured memory_bytes: 1804
#include <iostream>
#include <algorithm>
#include <string>
#include  <queue>
#include <vector>
#include  <cstdio>
#include <cstring>
#include<map>
#include<cmath>
#include<set>
//#include<bits/stdc++.h>
#define ll long long int
#define ull unsigned long long int
#define I(a) scanf("%d",&a)
#define I2(a,b) scanf("%d%d",&a,&b)
#define I3(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define L(a) scanf("%lld",&a)
#define L2(a,b) scanf("%lld%lld",&a,&b)
#define L3(a,b,c) scanf("%lld%lld%lld",&a,&b,&c)
#define PI(a) printf("%d",a)
#define PL(a) printf("%lld",a)
#define PT(t) printf("Case %d: ",t)
#define PB push_back
#define x first
#define y second
#define xx first.first
#define xy first.second
#define yx second.first
#define yy second.second
#define SC scanf
#define PC printf
#define NL printf("\n")
#define SET(a) memset(a,0,sizeof a)
#define SETR(a) memset(a,-1,sizeof a)
#define SZ(a) ((int)a.size())-1
#define f(i,a,b) for(int i=a;i<=b; i++)
#define fr(i,a,b) for(int i=a;i<=b; i++)
#define frr(i,a,b) for(int i=a;i>=b; i--)
#define frv(i,a)  for(int i=0;i<a.size();i++)
#define pi 2.0*acos(0.0)
#define R(a) freopen(a, "r", stdin);
#define W(a) freopen(a, "w", stdout);
#define CB(x) __builtin_popcount(x)
#define STN(a) stringtonumber<ll>(a)
#define lol printf("BUG\n")
#define Endl "\n"
#define mk make_pair
using namespace std;
template <class T> inline T BM(T p, T e, T M)
{
    ll ret = 1;
    for(; e > 0; e >>= 1)
    {
        if(e & 1) ret = (ret * p) % M;
        p = (p * p) % M;
    }
    return (T)ret;
}
template <class T> inline T mul(T p, T e, T M)
{
    ll ret = 0;
    for(; e > 0; e >>= 1)
    {
        if(e & 1) ret = (ret + p) ;
        p = (p + p) ;
        if(ret>=M)ret-=M;
        if(p>=M)p-=M;
    }
    return (T)ret;
}
template <class T> inline T gcd(T a, T b)
{
    if(b == 0)return a;
    return gcd(b, a % b);
}
template <class T> inline T mdINV(T a, T M)
{
    return BM(a, M - 2, M);
}
template <class T> inline T PW(T p, T e)
{
    ll ret = 1;
    for(; e > 0; e >>= 1)
    {
        if(e & 1) ret = (ret * p);
        p = (p * p);
    }
    return (T)ret;
}
 
 
template <class T>bool ISLEFT(T a, T b, T c)
{
    if(((a.xx - b.xx) * (b.yy - c.yy) - (b.xx - c.xx) * (a.yy - b.yy)) < 0.0)return 1;  //Uporer dike //A,b,c, x okkher ordera sorted
    else return 0;
}
 

#define  mx 200004
#define base 193ll
 
typedef pair<int,int >P;
//////////////////////////
////////////////////////
#define F(i,a,b) for(int i=a;i<b; i++)
#define LL long long
#define MX  1000007
#define md 1000000007ll
///////////////////////////
///////////////////////////
int dp[MX+2];
int main(){
   int n;
   I(n);
   dp[0] = 0;

   for(int i= 1; i <= n;i++){
       dp[i] = i;
       dp[i] = min(dp[i-1] + 1, dp[i]);
       for(int j = 6; j<=i; j*= 6){
           dp[i] = min(dp[i-j] + 1, dp[i]);
       }
       for(int j = 9; j<=i; j*= 9){
           dp[i] = min(dp[i-j] + 1, dp[i]);
       }
   }
   PI(dp[n]), NL;

    return 0;
}

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

#define DEBUG(x) cerr << #x << ": " << x << endl;
#define ll long long

int main() {
    int a, b;
    cin >> a >> b;

    if (a == 1) a = 14;
    if (b == 1) b = 14;
    
    if (a > b) {
        puts("Alice");
    } else if (b > a) {
        puts("Bob");
    } else {
        puts("Draw");
    }

    return 0;
}

Measured memory_bytes: 256
import sys

sys.setrecursionlimit(10 ** 6)
INF = float("inf")
MOD = 10 ** 9 + 7


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


def main():
    N = int(input())
    A = list(map(lambda x: int(x) - 1, input().split()))
    S = [[] for _ in range(N)]
    for i in range(N - 1):
        S[A[i]].append(i + 2)

    for s in S:
        print(len(s))


if __name__ == "__main__":
    main()


Measured memory_bytes: 44064
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < (n); i++)
#define REPR(i, n) for(int i = (n); i >= 0; i--)
#define FOR(i, m, n) for(int i = (m); i < (n); i++)
#define INF 1e9
#define ALL(v) (v).begin(), (v).end()
#define debug(x) cerr << #x << ": " << x << endl;

using namespace std;
typedef long long ll;

signed main() {
  int k, ans;
  cin >> k;
  int a[32] = {1, 1, 1, 2, 1, 2, 1, 5,  2, 2, 1, 5, 1, 2, 1, 14,
               1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};

  cout << a[k - 1] << endl;
  return 0;
}


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

int main(void) {
    int N; cin >> N;
    int pull = N % 1000;
    int ans;
    if(pull == 0) ans = 0;
    else ans = 1000 - pull;
    cout << ans << endl;
}

Measured memory_bytes: 3604
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define pb push_back
const int maxn = 10000;
const int INF32 = 1'050'000'000;
const long long INF64 = 4'000'000'000'000'000'000;
const int MOD7 = 1'000'000'007;
const int MOD9 = 1'000'000'009;

ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
int dx[8]={-1,0,1,0,1,1,-1,-1};
int dy[8]={0,-1,0,1,1,-1,1,-1};

int k, s;

int main()
{
	cin >> k >> s;
	int z;
	int cnt = 0;
	for(int x = 0; x <= k; x++)
	for(int y = 0; y <= k; y++)
	{
		z = s - x - y;
		if(z>=0 && z <= k) cnt++;
	}
	cout << cnt << endl;    
}

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

int main(){
    int64_t N, p = 0, r = 0;
    string name = "";
    cin >> N;

    while (N > 0){
        N--;
        name = string(1, 'a'+N%26 ) + name;
        N = N/26;

    }
    cout << name << endl;
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long
#define pb push_back
#define fs first
#define se second
#define M 998244353
#define pii pair<long long,long long>
 
int dx[4]={0,1,0,-1};
int dy[4]={1,0,-1,0};
unordered_map<char,pii>dir;
ll D=1e9;
 
bool check(int x,int y,int n,int m)
{
	return x>0 && y>0 && x<=n && y<=m;
}
int fun()
{
	static int num = 16;
	return num--;
}
ll exp(ll a,ll p,ll m)
{
	if(p==0)
		return 1LL;
	if(p==1)
		return a;
	ll h=exp(a,p/2,m);
	h=(h*h)%m;
	if(p&1)
		h=(h*a)%m;
	return h;
}
int find_parent(ll a,vector<ll>&dsu)
{
	while(a!=dsu[a])
	{
		a=dsu[dsu[a]];
	}
	return a;
}
void join(ll a,ll b,vector<ll>&dsu,vector<ll>&si)
{
	ll pa=find_parent(a,dsu);
	ll pb=find_parent(b,dsu);
	if(pa!=pb)
	{
		if(si[pa]>si[pb])
		{
			dsu[pb]=pa;
			si[pa]+=si[pb];
		}
		else
		{
			dsu[pa]=pb;
			si[pb]+=si[pa];
		}
	}
}
ll cal(ll h)
{
	ll mn=LLONG_MAX,mx=LLONG_MIN;
	while(h)
		{
			ll r=h%10;
			mn=min(r,mn);
			mx=max(r,mx);
			h/=10;
		}
	return mn*mx;

}

void anon_sort(ll u,string &ans,vector<ll>&mark,int arr[][26])
{
	mark[u]=1;
	for(ll i=0;i<26;i++)
	{
		if(arr[u][i] && mark[i]==0)
			anon_sort(i,ans,mark,arr);
	}
	ans.pb(u+'A');
}



int main()
{
	ios_base::sync_with_stdio(false);
	
	ll n;
	cin>>n;
	ll d=n%10;
	if(d==3)
		cout<<"bon";
	else if(d==2 || d==4 || d==5 || d==7 || d==9)
		cout<<"hon";
	else
		cout<<"pon";
	cout<<endl;
}

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

typedef long long ll;

int n;
long long arr[600+5],prefix[900];

long long dp[500][500];

long long solve(int x,int y){
    if(dp[x][y]!=-1)return dp[x][y];
    if(y==x+1)return dp[x][y]=arr[x]+arr[y];
    if(x>=y)return dp[x][y]=0;
    ll ans=1e18;
    
    for(int i=x;i<y;i++){
        // ith ele remains till end
        ll a1=solve(x,i);
        ll a2=solve(i+1,y);
        ll c1;
        if(x>=1)
        c1=a1+a2+prefix[y]-prefix[x-1];
        else {c1=a1+a2+prefix[y];}
        ans=min(ans,c1);
        //cout<<ans<<"\n";
        
    }
    return dp[x][y]=ans;
}

int main(){
  cin>>n;
    for(int i=0;i<n;i++)cin>>arr[i];
    prefix[0]=arr[0];
    for(int i=1;i<n;i++){
        prefix[i]=prefix[i-1]+arr[i];
    }
    for(int i=0;i<=n;i++){
        for(int j=0;j<=n;j++){
            dp[i][j]=-1;
        }
    }
    cout<<solve(0,n-1);
}

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

typedef long long ll;
ll n, k, c1, c2;

int main() {
    cin >> n >> k;
    for (int i = 1; i <= n; i++) if (i % k == 0) c1++;
    if (!(k % 2)) {
        for (int i = 1; i <= n; i++) if (i % k == k / 2) c2++;
    }
    cout << c1 * c1 * c1 + c2 * c2 * c2 << endl;
    return 0;
}


Measured memory_bytes: 256
import sys
from collections import Counter

# sys.stdin = open('e1.in')


def read_int_list():
    return list(map(int, input().split()))


def read_int():
    return int(input())


def read_str_list():
    return input().split()


def read_str():
    return input()


total_in = 0
total_out = 0


def solve():
    n, h = read_int_list()
    a, b, c, d = zip(*[read_int_list() for _ in range(n)])
    n_nodes = 2 * h + 1
    n_edges = n
    adj = [[] for _ in range(n_nodes)]
    r_adj = [[] for _ in range(n_nodes)]
    for i in range(n_edges):
        if c[i] == 0:
            l = a[i]
        else:
            l = -c[i]
        if d[i] == 0:
            r = -b[i]
        else:
            r = d[i]
        adj[l + h].append(r + h)
        r_adj[r + h].append(l + h)
    in_degree = Counter()
    out_degree = Counter()
    for i in range(n_nodes):
        for j in adj[i]:
            out_degree[i] += 1
            in_degree[j] += 1

    for i in range(n_nodes):
        if i < h:
            if not out_degree[i] <= in_degree[i]:
                return 'NO'
        if h < i:
            if not in_degree[i] <= out_degree[i]:
                return 'NO'

    state = [0] * n_nodes

    def dfs(root):
        res = False
        state[root] = 1
        for i in adj[root]:
            if state[i] == 0:
                res |= dfs(i)
        for i in r_adj[root]:
            if state[i] == 0:
                res |= dfs(i)
        state[root] = 2
        if (in_degree[root], out_degree[root]) == (0,0):
            return True
        res |= in_degree[root] != out_degree[root]
        return res

    for i in range(n_nodes):
        if state[i] == 0:
            if not dfs(i):
                return 'NO'

    return 'YES'


def main():
    res = solve()
    print(res)


if __name__ == '__main__':
    main()


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

int main()
{
    int t,n,cnt=0;
    int d,m,a[105]={0};
    scanf("%d %d",&t,&n);
    for(int i=0;i<n;i++)
    {
        scanf("%d",&d);
        for(int j=0;j<d;j++)
        {
            scanf("%d",&m);
            a[m]++;
        }
    }
    for(int i=1;i<=t;i++)
    {
        if(a[i]==0)
        {
            cnt++;
            //printf("%d ",i);
        }
    }
    printf("%d\n",cnt);
    return 0;
}


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

// エイリアス
using  ll = long signed long;
using ull = long unsigned long;
using  ld = long double;
using   P = pair<int, int>;
using llP = pair<ll, ll>;
using DoP = pair<double, double>;

// 汎用マクロ
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define FOREACH(i,q) for (auto &i : q)
#define UNIQUE(v) do { sort((v).begin(), (v).end()); (v).erase(unique((v).begin(), (v).end()), (v).end()); } while (false)
#define SZ(x) ((int)(x).size())
template <class T>inline bool chmin(T &a, const T b) {if (a > b) { a = b; return true;} return false;}
template <class T>inline bool chmax(T &a, const T b) {if (a < b) { a = b; return true;} return false;}
template <class T>inline void line_out(const vector<T> vec) {int n = SZ(vec); rep(i, n) { cout << vec[i]; if(i < n-1) cout << " ";}cout << endl;}
const int di[] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dj[] = {1, 0, -1, 0, 1, -1, 1, -1};
const int INF = 1 << 28;
const ll INF64 = 1ll << 60;
const int mod = 1000000007;
//const int mod = 998244353;
//const ll mod = 1777777777ll;
struct mint
{
  ll x; // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint &operator+=(const mint a)
  {
    if ((x += a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator-=(const mint a)
  {
    if ((x += mod - a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator*=(const mint a)
  {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const
  {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const
  {
    mint res(*this);
    return res -= a;
  }
  mint &operator++()
  {
    if ((x += 1) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator--()
  {
    if ((x += mod - 1) >= mod)
      x -= mod;
    return *this;
  }
  mint operator*(const mint a) const
  {
    mint res(*this);
    return res *= a;
  }
  mint pow(ll t) const
  {
    if (!t)
      return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1)
      a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const
  {
    return pow(mod - 2);
  }
  mint &operator/=(const mint a)
  {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const
  {
    mint res(*this);
    return res /= a;
  }
};


int main()
{
  int n;
  ll T;
  cin >> n >> T;
  vector<ll> t(n);
  rep(i, n) cin >> t[i];
  t.push_back(INF64);
  ll ans = 0;
  rep(i, n) {
    ans += min(T, t[i+1]-t[i]);
  }
  cout << ans << endl;
}

Measured memory_bytes: 6376