akhauriyash/Code-Regression huggingface dataset:
#include <string>
#include <iostream>
#include <stack>
#include <queue> // priority_queue も入ってる
#include <set>   // 要素数は size() で取得 multisetもある
#include <map>
#include <array> // sizeはコンパイル時定数で固定
#include <vector>
#include <numeric>   // accumulate, gcd
#include <algorithm> // count_ifに必要
#include <iomanip>   // cout << setprecision(15) << x で小数の出力精度を指定
#include <tuple>
#include <utility> //pair
#include <cmath>
#include <random>

using namespace std;
// 問題が起こるまでintは使用禁止2020-04-13
using ll = long long;

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

template <class InputIterator, class T>
bool contains_itr(InputIterator iterator, const T &value)
{
    if (find(iterator.begin(), iterator.end(), value) == iterator.end())
        return false;
    else
        return true;
}

template <class T>
bool contains_set(set<T> st, const T &value)
{
    if (st.find(value) == st.end())
    {
        return false;
    }
    else
    {
        return true;
    }
}

template <class InputIterator>
auto sum(InputIterator iterator)
{
    return accumulate(iterator.begin(), iterator.end(), 0);
}

// endは排他的(exclusive)なので注意
vector<ll> range(ll begin, ll end)
{
    vector<ll> result;
    for (ll i = begin; i < end; ++i)
    {
        result.push_back(i);
    }
    return result;
}

random_device seed_gen;
mt19937 engine(seed_gen());
// 0, 1, 2 のどれかが得られる一様分布
// uniform_int_distribution<> dist(0, 2);
// cout << dist(engine) << endl;
// みたいに、先に確率分布を宣言して、そこにengineを与えて使う。

// =========ここまでテンプレ============

// 0からn-1までの中からm個選ぶnCmパターン全て列挙します。
// 返り値は昇順ソート済みになる
vector<vector<ll>> listAllCombinations(ll n, ll m)
{
    vector<vector<ll>> combis;
    queue<vector<ll>> que;
    rep(i, n - m + 1) que.push(vector<ll>{i});
    while (!que.empty())
    {
        vector<ll> tempSet = que.front();
        que.pop();
        if (tempSet.size() < m)
        {
            ll last = *(--tempSet.end());
            ll stillNeed = m - tempSet.size();
            ll possibleMax = n - stillNeed;
            for (ll i = last; i < possibleMax; ++i)
            {
                vector<ll> tempSet2 = tempSet;
                tempSet2.push_back(i + 1);
                que.push(tempSet2);
            }
        }
        else
        {
            combis.push_back(tempSet);
        }
    }
    return combis;
}

int main()
{
    ll n;
    cin >> n;
    vector<ll> l(n);
    rep(i, n) cin >> l[i];

    vector<vector<ll>> allCombis = listAllCombinations(n, 3);
    ll count = 0;
    for (auto itr = allCombis.begin(); itr != allCombis.end(); ++itr)
    {
        vector<ll> tri = (*itr);
        ll x = l[tri[0]];
        ll y = l[tri[1]];
        ll z = l[tri[2]];
        if (x != y && y != z && z != x && x + y > z && y + z > x && z + x > y)
        {
            ++count;
        }
    }
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 17920
#include <bits/stdc++.h>
using namespace std;
#define ll                      long long int
#define pb                      push_back
#define MOD                     1000000007
#define inf                     3e18
#define ld                      long double
//#define mp                      make_pair
#define vpll                    vector<pair<ll,ll>>
#define sll                     set<ll>
#define vll                     vector<ll>
#define vld                     vector<ld>
#define vvll                    vector<vector<ll>>
#define vvld                    vector<vector<ld>>
#define pll                     pair<ll,ll>
#define vvpll                   vector<vector<pair<ll,ll>>>
#define pqll                    priority_queue<ll>
#define mll                     map<ll,ll>
#define mlc                     map<ll,char>
#define um                      unordered_map
#define umll                    um<ll,ll>
#define umlc                    um<ll,char>
#define umcl                    um<char,ll>
#define all(x)                  x.begin(),x.end()
#define fi                      first
#define se                      second
#define test                    ll Testcases;cin>>Testcases;while(Testcases--)
#define fastIO                  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define db(...)                 __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) { cerr << " "<< name << " : " << arg1 <<'\n'; }
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
    const char* comma = strchr(names + 1, ',');
    cerr.write(names, comma - names) << " : " << arg1 << " | "; __f(comma + 1, args...);
}

void inp_out()
{
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    freopen("debug.txt", "w", stderr);
    #endif
}

int main()
{
	fastIO
//	inp_out();
	ll n;
	cin>>n;
	ll ans=0;
	ans=(n/500)*1000;
	n%=500;
	ans+=(n/5)*5;
	cout<<ans;

	return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
import sys, math, bisect, random, itertools
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt
bisect_left = bisect.bisect_left
bisect_right = bisect.bisect_right
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float, input().split()))
def LI_(): return list(map(lambda x: int(x)-1, input().split()))
def II(): return int(input())
def IF(): return float(input())
def LS(): return list(map(list, input().split()))
def S(): return list(input().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float('INF')

#A
def A():
    a, b, c = LI()
    print(c - min(b + c, a) + b)
    return

#B
def B():
    n = II()
    ans = 0
    for i in range(1, n + 1):
        if len(str(i)) % 2:
            ans += 1
    print(ans)
    return

#C
def C():
    n = II()
    h = LI()
    h = h[::-1]
    for i in range(1, n):
        if h[i] <= h[i-1]:
            continue
        if h[i] == h[i - 1] + 1:
            h[i] -= 1
            continue
        print("No")
        return
    print("Yes")
    return

#D
def D():
    s = S()
    lens = len(s)
    ans = [0] * len(s)
    i = 0
    while i != len(s):
        for j in range(i, lens):
            if s[j] == "R":
                continue
            break
        R = j - i
        for i in range(j, lens):
            if s[i] == "L":
                continue
            break
        else:
            i += 1
        L = i - j
        ans[j] = R // 2 + (L+1) // 2
        ans[j - 1] = L // 2 + (R+1) // 2

    print(*ans)
    return

#E
def E():
    def make_divisor(n):
        res = []
        for i in range(1, int(math.sqrt(n))+1):
            if n % i == 0:
                res.append(i)
                res.append(n // i)
        if n == math.sqrt(n)** 2:
            res.append(int(math.sqrt(n)))
        return res
    n, k = LI()
    a = LI()
    x = sum(a)
    maxa = max(a)
    lis = make_divisor(x)
    lis.sort(reverse=True)
    for li in lis:
        l1 = list(map(lambda x: x % li, a))
        l2 = list(map(lambda x: - x % li, a))
        l1.sort()
        l2.sort()
        c = 0
        while 0 in l1:
            l1.remove(0)
            c += 1
        while 0 in l2:
            l2.remove(0)
        l = 0
        r = 0
        b = 0
        rx = 0
        lx = 0
        while l + r < n - c:
            if b < 0:
                b += l2[r]
                rx += l2[r]
                r += 1
            else:
                b -= l1[l]
                lx += l1[l]
                l += 1
        if b == 0 and rx <= k:
            print(li)
            return
    return

#F
def F():
    return

#Solve
if __name__ == '__main__':
    E()


Measured memory_bytes: 44396
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define REP(i, m, n) for(int i = (m); i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007
#define INF (1e9)
#define PI (acos(-1))
#define print(x) cout << x << endl
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl

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

template<class T> inline auto __lcm(T& a, T& b) 
{ return a * b / __gcd(a, b); }

int main() {
    int N;  cin >> N;
    vector<ll> a(N);  rep(i, N) cin >> a[i];

    // 方針：a_iを2で割った商の合計が求める操作回数である．
    // a_iは高々2^30未満なので，全探索すれば10^7オーダーで求まる
    int cnt = 0;
    rep(i, N) {
        rep(j, 30) {
            if (a[i] % (ll)pow(2, j+1) == 0) {
                ++cnt;
            }
        }
    }

    print(cnt);
}


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

int main(){
    int a,b,c,x,count=0;
    cin>>a>>b>>c>>x;
    for(int i=0;i<=a;i++){
        for(int j=0;j<=b;j++){
            for(int k=0;k<=c;k++){
                if(x==500*i+100*j+50*k){count++;}
            }
        }
    }
    cout<<count<<endl;
    return 0;
}

Measured memory_bytes: 256
fun main(args: Array<String>) {
    var S = readLine()!! .toCharArray()
    var map = mutableMapOf<Char, Int>()
    S.forEach {
        val n = map.get(it) ?: 0
        map.put(it, n + 1)
    }
    var ans = (map.count() == 2) && (map.values.all { it == 2})
    println(if (ans) "Yes" else "No")
}


Measured memory_bytes: 31772
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define cu continue
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define inf LLONG_MAX
#define pll pair <ll,ll>
#define min_pq priority_queue <pll> ,vector <pll>, greater <pll> > > 
#define f first
#define s second
#define vll vector <ll>
#define dbg(n) cout<<n<<' ';

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


    ll n;
    cin>>n;
    ll m=log2(n);
    cout<<(1ll<<(m+1))-1<<'\n';
}       


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

using namespace std;
using ll = long long;
using vl = vector<ll>;
using vvl = vector<vl>;
using vb = vector<bool>;
using vs = vector<string>;
using pll = pair<ll, ll>;
const ll oo = 0x3f3f3f3f3f3f3f3fLL;
const double eps = 1e-9;
#define sz(c) ll((c).size())
#define all(c) begin(c),end(c)
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
#define xx first
#define yy second
#define FOR(i, a, b) for(ll i=(a); i<(b); i++)
#define FORD(i, a, b) for(ll i=ll(b)-1;i>=(a);i--)
#define TR(X) ({if(1) cerr << "TR: " << (#X) << " = " << (X) << endl; })
vl parent;
vl height;
vl s;

void init(ll n) {
    parent.resize(n);
    iota(all(parent), 0);
    height.assign(n, 0);
    s.assign(n, 1);
}

ll Find(ll x) {
    if (x != parent[x]) parent[x] = Find(parent[x]);
    return parent[x];
}

bool Union(ll x, ll y) {
    x = Find(x), y = Find(y);
    if (x == y) return false;
    if (height[x] > height[y]) { parent[y] = x;
    s[x] += s[y];}
    else {
        parent[x] = y;
        s[y] += s[x];
        if (height[x] == height[y]) height[y]++;
    }
    return true;
}

int main() {
    cin.sync_with_stdio(0);

    ll n, m;
    cin >> n >> m;
    init(n);
    ll a, b;
    FOR(i, 0, m){
        cin >> a >> b;
        a--;
        b--;
        Union(a, b);
    }
    cout << *max_element(all(s)) << endl;
}

Measured memory_bytes: 7924
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

S = input()
year = int(S[:4])
month = int(S[5:7])
day = int(S[8:])

heisei_flag = False
if year < 2019:
   heisei_flag = True
else:
    if month <= 4:
       heisei_flag = True
if heisei_flag:
   print('Heisei')
else:
   print('TBD')    


Measured memory_bytes: 3060
# -*- coding: utf-8 -*-

import sys

def main():
    input = sys.stdin.readline
    n = input()
    l = list(map(int, input().split()))
    max_l = max(l)
    l.remove(max_l)
    sum_l = sum(l)
    if max_l < sum_l:
        print("Yes")
    else:
        print("No")
    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 9152
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
using System.Numerics;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
            Solve();
            //Out.Flush();
            Read();
        }

        static void Solve()
        {
            var N = Sarray()[0];
            if (N % 2 == 0)
                WriteLine(N);
            else
                WriteLine(2 * N);
        }
 
        static long Mod = 998244353;
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }
        static public (T1 a, T2 b) Slice<T1, T2>()
        {
            var t = ReadLine().Split();
            return (
            (T1)Convert.ChangeType(t[0], typeof(T1)),
            (T2)Convert.ChangeType(t[1], typeof(T2)));
        }
        static public (T a, T b) Slice2<T>()
        {
            var t = ReadLine().Split();
            return (
            (T)Convert.ChangeType(t[0], typeof(T)),
            (T)Convert.ChangeType(t[1], typeof(T)));
        }
        static public (T a, T b, T c) Slice3<T>()
        {
            var t = ReadLine().Split();
            return (
            (T)Convert.ChangeType(t[0], typeof(T)),
            (T)Convert.ChangeType(t[1], typeof(T)),
            (T)Convert.ChangeType(t[2], typeof(T)));
        }
    }
}

Measured memory_bytes: 28236
package main

import "fmt"

func main() {
	var a, b, k int
	fmt.Scan(&a, &b, &k)
	if k >= a {
		k -= a
		a = 0
	} else {
		a -= k
		k = 0
	}
	if k > 0 {
		if k >= b {
			k -= b
			b = 0
		} else {
			b -= k
		}
	}
	fmt.Println(a, b)
}


Measured memory_bytes: 512
N, Q = map(int, input().split())
S = input()
S_list = list(S)
count_list = [0]*N

for i in range(1, N):
    count_list[i] += count_list[i-1] 
    if S_list[i-1] == "A" and S_list[i] == "C":
        count_list[i] += 1

for i in range(Q):
    start, end = map(int, input().split())
    count = count_list[end-1] - count_list[start-1]
    print(count)

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

#define F first
#define S second
#define MP make_pair
#define pb push_back
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define LCM(a, b) (a) / __gcd((a), (b)) * (b)
#define CEIL(a, b) (a)/(b)+(((a)%(b))?1:0)
#define ln '\n'

using namespace std;

typedef long long LL;
typedef long double ldouble;
typedef pair<int, int> P;
typedef pair<LL, LL> LP;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1e9 + 7;
static const int SIZE = 200005;

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

vector<LL> Div(LL n) {
    vector<LL> ret;
    for(LL i = 1; i * i <= n; ++i) {
        if(n % i == 0) {
            ret.pb(i);
            if(i * i != n) ret.pb(n / i);
        }
    }
    sort(all(ret));
    return ret;
}

int graph[10][10];

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

    for(int i = 0; i < 10; ++i) {
        graph[i][i] = 1;

    }

    int n, m;
    cin >> n >> m;
    while(m--) {
        int a, b;
        cin >> a >> b;
        graph[a][b] = graph[b][a] = 1;

    }

    vector<int> v;
    for(int i = 1; i <= n; ++i) {
        v.pb(i);

    }

    int c = 0;
    do {
        if(v[0] != 1) continue;
        bool f = true;
        for(int i = 1; i < v.size(); ++i) {
            if(graph[v[i]][v[i - 1]] == 0) f = false;

        }
        if(f) ++c;

    } while(next_permutation(all(v)));
    cout << c << endl;
    return 0;
}



Measured memory_bytes: 256
import re
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
import functools
def v(): return input()
def k(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def X(): return list(input())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 9)
mod = 10**9+7
cnt = 0
ans = 0
inf = float("inf")

r,g,b,n = I()
a = []
a.append(r)
a.append(g)
a.append(b)
a.sort()
a[0],a[1],a[2] = r,g,b

mx_b = n//b
amari = n%b
for i in range(n//r + 1):
    for j in range((n-r*i)//g + 1):
        if (n-r*i-g*j) % b == 0:
            cnt += 1

print(cnt)


Measured memory_bytes: 10452
#include <bits/stdc++.h>
#define FOR(i,a,b) for(ut i=(a);i<(ut)(b);i++)
#define REP(i,b) FOR(i,0,b)
#define ALL(c) c.begin(),c.end()
#define PB push_back
#define cat //cout << __LINE__ << endl;
using namespace std;
typedef long long LL;
typedef double ld;
typedef LL ut;
typedef vector<ut> VI;
typedef pair<ut,ut> pr;
typedef pair<ut,pr> ppr;
typedef vector<pr> Vpr;
typedef vector<ppr> Vppr;
typedef priority_queue<ut,VI> PQ;
const int SIZE=2*1e5;
const LL INF=1<<30;
const LL p=7+1e9;
int main(){
	LL N,M,K;
	cin >> N >> M >> K;
	REP(i,N+1)
		REP(j,M+1){
			if(((N-i)*j+(M-j)*i)==K){
				cout << "Yes" << endl;
				return 0;
			}
		}
	cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define ll long long
#define hell 1000000007
#define PI 3.14159265358979323846
using namespace std;
ll expo(ll base,ll p)
{
    if(p==0ll)
        return 1ll;
if(p%2==0)
    return expo((base*base)%hell,p/2);
else
    return (base*expo((base*base)%hell,p/2))%hell;
}
ll fac[1000005],inv[1000005];
void cal()
{
    fac[0]=1;
    for(ll i=1;i<=1000000;i++)
        fac[i]=(fac[i-1]*i)%hell;
    inv[1000000]=expo(fac[1000000],hell-2);
    for(ll i=99999;i>=0;i--)
        inv[i]=(inv[i+1]*(i+1))%hell;
}
ll ncr(ll n,ll r)
{
    return (((fac[n]*inv[r])%hell)*inv[n-r])%hell;
}
int main()
{
   ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t=1;
    //cin>>t;
    //int c=0;
    while(t--) {
     ll n,i,j,q,s=0,l,r;
     cin>>n;
     ll arr[n+1],brr[n+1];
     for(i=0;i<n;i++)
     {
         cin>>arr[i];
     }
     for(i=0;i<n;i++)
        cin>>brr[i];
     reverse(brr,brr+n);
     vector<ll> v1,v2;
     for(i=0;i<n;i++)
        if(arr[i]==brr[i])
     {
         v1.pb(i);
         j=arr[i];
     }
     for(i=0;i<n;i++)
     {
         if(arr[i]!=j && brr[i]!=j)
            v2.pb(i);
     }
     if(v1.size()>v2.size())
     {
         cout<<"No";
         return 0;
     }
     cout<<"Yes\n";
     for(i=0;i<v1.size();i++)
        swap(brr[v1[i]],brr[v2[i]]);
     for(i=0;i<n;i++)
        cout<<brr[i]<<" ";
    }

}


Measured memory_bytes: 8948
#include <iostream>
		       #include <map>
		     using					namespace
		  std;							  typedef
	    long		    long ll;  			    int main(){
	  int				n;ll a                     [212345];

	               a[0] = 0; cin >>
	                     n;     map
	                     <ll    ,ll
	                     >     mp;
	                     mp
	                    [0]
                     
	              =1;
	       for(int i
	             =1
	     ;i<=n;i++){cin
	    >>      a[i];       a[  i]+=a[i - 1];mp
	           [a [i]]      ++              ;}
	          ll  res =0     ;             for
	      (auto   i:         mp)          res
	    +=        i.         second       *(i.
	second        -1          )/2;       cout
	              <<           res<<endl;return
	             0;}


Measured memory_bytes: 14336
#include <bits/stdc++.h>
using namespace std;
 
typedef long long LL;
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<double> VD;
#define MP make_pair
#define PB push_back
#define X first
#define Y second
 
#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define RFOR(i, b, a) for(int i = (b) - 1; i >= (a); --i)
#define ITER(it, a) for(__typeof(a.begin()) it = a.begin(); it != a.end(); ++it)
#define ALL(a) a.begin(), a.end()
#define SZ(a) (int)((a).size())
#define FILL(a, value) memset(a, value, sizeof(a))
#define debug(a) cout << #a << " = " << a << endl;
 
const double PI = acos(-1.0);
const LL INF = 1e9 + 47;
const LL LINF = INF * INF;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
const int mod = 1000 * 1000 * 1000 + 7;
 
inline int add(int x, int y)
{
	if (x + y < mod)
		return x + y;
	return x + y - mod;
}
 
inline int mult(int x, int y)
{
	return x * (LL) y % mod;
}
 
const int N = 1 << 18;
int n;
string s;
int f[N];
string br;

int main()
{
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	//freopen("In.txt", "r", stdin);
	//freopen("In.txt", "w", stdout);
	
	cin >> n >> s;
	br = s;
	
	int xr = 0;
	FOR(i, 0, SZ(s))
	{
		if ((s[i] == 'B') == (xr == 0))
			br[i] = '(';
		else
			br[i] = ')';
		xr ^= 1;
	}
		
	f[0] = 1;
	FOR(i, 1, N)
		f[i] = mult(i, f[i - 1]);
	
	int ans = 1;
	int open = 0;
	FOR(i, 0, SZ(br))
		if (br[i] == '(')
			open++;
		else
		{
			if (open == 0)
			{
				ans = 0;
				continue;
			}
			
			ans = mult(ans, open);
			--open;
		}
	
	if (open)
		ans = 0;
	
	ans = mult(ans, f[n]);
	cout << ans << endl;
		
	cerr << "Time elapsed: " << clock() / (double)CLOCKS_PER_SEC << endl;
	return 0;
}


Measured memory_bytes: 1812
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <iomanip>
using namespace std;
#define INF 1e9
#define PI acos(-1)
typedef long long ll;


int main() {
	
	int n; cin >> n;
	vector<ll>a(n);
	for (int i = 0; i < n; i++)cin >> a[i];

	ll sum = 0, xr=0, ans = 0;
	int right = 0;

	for (int left = 0; left < n; left++) {
		while (right < n&&((sum + a[right]) == (xr^a[right]))) {
			sum += a[right];
			xr ^= a[right];
			right++;
		}

		ans += (right - left);

		if (right == left)right++;
		else {
			sum -= a[left];
			xr ^= a[left];
		}

	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 1792
program ABC175B
    implicit none
    integer(8)::N,ans=0,i,j,k
    integer(8),allocatable::L(:)
    read*,N
    allocate(L(N))
    read*,L
    call heapsort(N,L)

    do i=1,N-2
        do j=i+1,N-1
            do k=j+1,N
                if(L(i)+L(j)>L(k).and.L(i)/=L(j).and.L(j)/=L(k).and.L(k)/=L(i))ans=ans+1
            end do
        end do
    end do
    print'(i0)',ans
end program ABC175B

subroutine heapsort(n,array)
    implicit none
    integer(8),intent(in) :: n
    integer(8),intent(inout) :: array(1:n)
   
    integer(8) ::i,k,j,l
    integer(8) :: t
   
    if(n.eq.1)return
  
    l=n/2+1
    k=n
    do while(k.ne.1)
       if(l.gt.1)then
          l=l-1
          t=array(L)
       else
          t=array(k)
          array(k)=array(1)
          k=k-1
          if(k.eq.1) then
             array(1)=t
             exit
          endif
       endif
       i=l
       j=l+l
       do while(j.le.k)
          if(j.lt.k)then
             if(array(j).lt.array(j+1))j=j+1
          endif
          if (t.lt.array(j))then
             array(i)=array(j)
             i=j
             j=j+j
          else
             j=k+1
          endif
       enddo
       array(i)=t
    enddo
  
    return
end subroutine heapsort

Measured memory_bytes: 2932
#include<bits/stdc++.h>
using namespace std;
const int mod=1e9+7;
long long n,k,C[2005][2005];
int main(){
   C[0][0]=1;
   for(long long i=1;i<2005;i++){
      C[i][0]=1;
      for(int j=1;j<=i;j++) C[i][j]=(C[i-1][j]+C[i-1][j-1])%mod;
   }
   cin>>n>>k;
   for(int i=1;i<=k;i++){
      int ans=0;
      printf("%lld\n",C[k-1][i-1]*C[n-k+1][i]%mod);
   }
   return 0;
}

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

int main(){
	long long int T,A,K;
    cin >> T >> A >> K;
    if(T - K >= 0) cout << T - K << " " << A << endl; else if(A + (T - K) >= 0) cout << 0 << " " << A + (T - K) << endl; else cout << 0 << " " << 0 << endl;
}

Measured memory_bytes: 256
def main():
    N = int(input())
    H = list(map(int, input().split()))
    idx = 0
    mv = 0
    height = None
    vals = set([0])
    while True:
        height = H[idx]
        idx += 1
        if idx == N:
            if mv != 0:
                vals.add(mv)
            break
        if height >= H[idx]:
            mv += 1
        else:
            vals.add(mv)
            mv = 0
    print(max(list(vals)))


if __name__ == '__main__':
    main()


Measured memory_bytes: 85520
#include <stdio.h>
int main()
{
  int t[50],n,s,storn,i,j;
  while(1){
    scanf("%d %d",&n,&storn);
    //printf("%d %d",n,storn);///
    if(n==0&&storn==0)break;
    for(i=0;i<n;i++)t[i]=0;
    j=0;
    s=storn;
    while(1){
      //printf("%d %d %d %d\n",j,s,t[j],storn);///
      if(s!=0){
	t[j]++;
	s--;
      }else if(s==0){
	s=t[j];
	t[j]=0;
      }
      if(t[j]==storn)break;
      j++;
      if(j==n)j=0;
    }
    printf("%d\n",j);
  }
  return 0;
}

Measured memory_bytes: 1028
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>
#include <numeric>
#include <iomanip>

#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
/* const int MOD = 998244353; */
const int INF = 1e18;
const double PI = acos(-1);

using namespace std;
struct INIT { INIT(){
  cin.tie(0); ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
}}INIT;


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

  int keta = 0;
  int sum = 0;

  REP(i, N){
    int a, b;
    cin >> a >> b;

    keta += b;
    sum += a*b;
  }

  cout << (keta-1)+(sum-1)/9 << "\n";

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long int ll;
typedef long double ld;
using namespace std;
const long long int INF = 1e18;
const long long int mod = 1e9+7;
typedef pair<ll,ll> pairs;
typedef vector<pairs> p;


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

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

ll keta(ll N){
    int tmp{};
    while( N > 0 ){
        tmp += ( N % 10 );
        N /= 10;
    }
    N = tmp;
    return N;
}

vector<vector<ll>> combination(ll n, ll r){
    vector<vector<ll>> v(n + 1, vector<ll>(n + 1, 0));
    for(ll i=0;i<v.size();++i){
        v[i][0] = 1;
        v[i][i] = 1;
    }
    for(ll i=1;i<v.size();++i){
        for(ll j=0;j<i;++j){
            v[i][j] = (v[i - 1][j - 1] + v[i - 1][j]);
        }
    }
    return v;
}

// 回文
bool kai(string S){
    bool flag = true;
    for(ll i=0;i<S.size()/2;++i){
        if(S[i] != S[S.size()-i-1]){
            flag = false;
            break;
        }
    }
    return flag;
}
// ---------------------------------------------

int main(){
    ll n;
    cin>>n;
    ll c[n-1], s[n-1], f[n-1];
    for(ll i=0;i<n-1;++i){
        cin>>c[i]>>s[i]>>f[i];
    }

    for(ll i=0;i<n;++i){
        ll ans = 0;
        for(ll j=i;j<n-1;++j){
            if(ans < s[j]){
                ans = s[j];
            }else if(ans % f[j] != 0){
                ans += f[j] - ans % f[j];
            }
            ans += c[j];
        }
        cout<<ans<<endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
using namespace std;
using namespace __gnu_pbds;
 
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key
 
typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<int> vi;
typedef long double ld; 
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;

int main(){
    ios_base::sync_with_stdio(0); cin.tie(0);   
    char c;
    cin>>c;
    if(c=='a' || c=='e' || c=='i' || c=='o' || c=='u'){
        cout<<"vowel"<<endl;
    }
    else{
        cout<<"consonant"<<endl;
    }
    return 0;
}

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

int main(){
    int N, L;
    cin >> N >> L;
    vector<pair<int, int> > A(N);
    for (int i = 0; i < N; i++){
        A.at(i) = make_pair(abs(L + i), L + i);
    }
    sort(A.begin(), A.end());
    int sum = 0;
    for (int i = 1; i < N; i++){
        sum += A.at(i).second;
    }
    cout << sum << endl;
}

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

using namespace std;

vector<vector<int> > graph(200002, vector<int>());
vector<long long> counters(200002, 0);
int n, q;

void dfs(int node, long long toAdd, int nodeSource) {
	counters[node] += toAdd;
	for(int i = 0 ; i < graph[node].size() ; ++i) {
		if(graph[node][i] != nodeSource) {
			dfs(graph[node][i], counters[node], node);
		}
	}
}

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

	cin >> n >> q;
	for(int i = 0 ; i < n - 1 ; ++i) {
		int a, b;
		cin >> a >> b;
		graph[a].push_back(b);
		graph[b].push_back(a);
	}

	for(int i = 0 ; i < q ; ++i) {
		int a, b;
		cin >> a >> b;
		counters[a] += b;
	}

	dfs(1, 0, -1);

	for(int i = 1 ; i <= n ; ++i) {
		cout << counters[i] << ' ' ;
	}

	return 0;
}

Measured memory_bytes: 24320
#include <bits/stdc++.h>
using namespace std;
int main()
{
 string s[103];
 int n,m;
 cin>>n>>m;
  for(int i=1;i<=n;i++)
    cin>>s[i];
  sort(s+1,s+1+n);
  for(int i=1;i<=n;i++)
    cout<<s[i];
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using PII = pair<ll, ll>;
#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
template<typename T> void chmin(T &a, const T &b) { a = min(a, b); }
template<typename T> void chmax(T &a, const T &b) { a = max(a, b); }
struct FastIO {FastIO() { cin.tie(0); ios::sync_with_stdio(0); }}fastiofastio;
#ifdef DEBUG_ 
#include "../program_contest_library/memo/dump.hpp"
#else
#define dump(...)
#endif
const ll INF = 1LL<<60;

int main(void) {
    ll m, n;
    cin >> m >> n;
    vector<vector<ll>> lb(m, vector<ll>(n, -INF)), ub(m, vector<ll>(n, INF));
    REP(i, m) {
        ll k;
        cin >> k;
        REP(j, k) {
            ll s, t;
            string cond;
            cin >> s >> cond >> t;
            s--;

            if(cond == ">=") chmax(lb[i][s], t);
            else chmin(ub[i][s], t);
        }
    }

    REP(i, m) REP(j, n) {
        if(lb[i][j] > ub[i][j]) {
            cout << "No" << endl;
            return 0;
        }
    }

    vector<ll> deg(m);
    vector<vector<ll>> g(m);
    REP(i, m) REP(j, m) {
        if(i == j) continue;
        bool flag = true;
        REP(k, n) if(lb[i][k] > ub[j][k]) flag = false;
        if(flag) {
            dump(i, j);
            deg[i]++;
            g[j].push_back(i);
        }
    }

    ll need = m-1;
    stack<ll> st;
    vector<bool> del(m);
    REP(i, m) if(deg[i] >= need) st.push(i);
    while(st.size()) {
        ll t = st.top(); st.pop();
        if(del[t]) continue;
        need--;
        del[t] = true;
        for(auto to: g[t]) {
            deg[to]--;
        }
        REP(i, m) if(deg[i] >= need && !del[i]) st.push(i);
    }

    bool ret = true;
    REP(i, m) if(!del[i]) ret = false;
    if(ret) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}


Measured memory_bytes: 3372
#include <bits/stdc++.h>
 
using namespace std;
 
#define lli long long int
#define REP(i,s,l) for(lli i=s;i<l;i++)
#define DEBUG 0
#define INF (1LL<<50)

signed main(){

	lli n;
	cin>>n;

	vector<lli> w(n);
	lli sum=0;
	REP(i,0,n){
		cin>>w[i];
		sum+=w[i];
	}

	lli little=0;
	lli ans=1000000000;
	REP(i,0,n-1){
		little += w[i];
		ans = min(ans,abs(sum-2*little));
	}

	cout<<ans<<endl;


	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <vector>
#include <stack>

using namespace std;

int main()
{
	int N, M;
	scanf("%d%d", &N, &M);

	vector<vector<int> > adj(N + 1);
	for (int i = 0; i < M; i++) {
		int u, v; scanf("%d%d", &u, &v);
		adj[u].push_back(v);
	}
	stack<int> s;
	int dist[N + 1];
	fill(dist, dist + N + 1, -1);
	dist[1] = 0;
	s.push(1);
	while (!s.empty()) {
		int node = s.top();
		if (node == N)
			break;
		s.pop();
		for (int i = 0; i < adj[node].size(); i++) {
			if (dist[adj[node][i]] == -1) {
				dist[adj[node][i]] = dist[node] + 1;
				s.push(adj[node][i]);
			}
		}
	}
	if (dist[N] != -1 && dist[N] <= 2)
		printf("POSSIBLE\n");	
	else
		printf("IMPOSSIBLE\n");
}

		


Measured memory_bytes: 9592
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = a; i < n; i++)
#define repr(i, a, n) for (int i = n - 1; i >= a; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }

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

  int n;
  cin >> n;
  vector<int> v(n);
  rep(i, 0, n) cin >> v[i];

  int start = *min_element(v.begin(), v.end());
  int end = *max_element(v.begin(), v.end());

  int ans = 1e9 + 7;
  rep(i, start, end + 1) {
    int t = 0;
    rep(j, 0, n) t += (i - v[j]) * (i - v[j]);
    chmin(ans, t);
  }

  cout << ans << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <vector>
#include <queue>
using namespace std;
typedef long long ll;

int main(void) {
  ll i, n, q, a, b, now;
  scanf("%lld%lld", &n, &q);
  ll ans[n];
  vector<ll> vec[n];
  bool flg[n];
  ans[0] = 0, flg[0] = false;
  for(i = 1; i < n; ++i) {
    ans[i] = 0, flg[i] = true;
    scanf("%lld%lld", &a, &b);
    vec[--a].push_back(--b);
    vec[b].push_back(a);
  }
  for(i = 0; i < q; ++i) {
    scanf("%lld%lld", &a, &b);
    ans[--a] += b;
  }
  queue<ll> qu;
  qu.push(0);
  while(qu.size()) {
    now = qu.front(), qu.pop();
    for(i = 0; i < vec[now].size(); ++i) if(flg[vec[now][i]]) 
      flg[vec[now][i]] = false, ans[vec[now][i]] += ans[now], qu.push(vec[now][i]);
  }
  for(i = 0; i < n; ++i) printf("%lld ", ans[i]);
  return 0;
}

Measured memory_bytes: 18032
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef string str;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector <pii> vpii;
typedef vector <pll> vpll;
typedef map <str,int> mapsi;
typedef map <str,int> :: iterator mapsitr;
typedef map <int , int> mint;
typedef map <ll , ll> mll;
typedef set <int> si;
typedef set <ll> sll;
typedef si :: iterator sitr;
typedef si :: reverse_iterator rsitr;
typedef sll :: iterator sltr;
typedef sll :: reverse_iterator rsltr;
#define mset multiset
typedef mset <int> msi;
typedef mset <ll> msll;
typedef msi :: iterator msitr;
typedef msi :: reverse_iterator msritr;
typedef msll :: iterator msltr;
typedef msll :: reverse_iterator mslritr;
#define mp make_pair
#define pb push_back
#define pob pop_back
#define fi first
#define se second
#define fs first.second
#define ss second.second
#define ff first.first
#define sf second.first
#define newl '\n'
char to_upper (char x){
    if( 97 <= int(x) && int(x) <= 126)return char(x-32);
    else if( 65 <= int(x) && int(x) <= 90)return x;
}
char to_lower (char x){
    if( 97 <= int(x) && int(x) <= 126)return x;
    else if( 65 <= int(x) && int(x) <= 90)return char(x+32);
}
int numerize (char x){
    if(48 <= int(x) && int(x) <= 57)return int(x-'0');
    else if( 97 <= int(x) && int(x) <= 126)return int(x-96);
    else if( 65 <= int(x) && int(x) <= 90)return int(x-64);
}
//void IO(){
//	#ifndef ONLINE_JUDGE
//	    freopen("input.txt", "r", stdin);
//	    freopen("output.txt", "w", stdout);
//	#endif
//}
// end of Template

int n,mx;
str s;
void cut (int z){
    int f[30];
    for(int i=1;i<=26;i++)f[i]=0;
    set <char> a,b;
    for(int i=0;i<=z;i++){
        a.insert(s[i]);
    }
    for(int i=z+1;i<s.size();i++){
        b.insert(s[i]);
    }
    set<char> :: iterator itr;

    for(itr=a.begin();itr!=a.end();itr++){
        char temp = *itr;
        int num = numerize(temp);
        f[num]++;
    }
    for(itr=b.begin();itr!=b.end();itr++){
        char temp = *itr;
        int num = numerize(temp);
        f[num]++;
    }
    int res = 0;
    for(int i=1;i<=26;i++){
        if(f[i]>=2){res++;}
    }
    mx = max(mx,res);
}
int main(){
	//IO();
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin>>n;
    cin>>s;
    for(int i=0;i<s.size();i++){
        cut(i);
    }
    cout<<mx<<newl;
}


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

#define ll long long int
#define f(i,g,n) for(int i=g;i<=n;i++)

int main()
{
	ios::sync_with_stdio(false);

	ll n,res=0;
	cin>>n;
	ll A[n],B[n],C[n-1];
	f(i,0,n-1)
		cin>>A[i];
	f(i,0,n-1)
	{
		cin>>B[i];
		res += B[i];
	}
	f(i,0,n-2)
		cin>>C[i];
	f(i,1,n-1)
	{
		if(A[i]-A[i-1] == 1)
			res += C[A[i-1]-1];
	}
	cout<<res<<"\n";

	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
#include <cstring>
#include <deque>
#include <iomanip>
#include <limits>
#include <fstream>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define MOD1 1000000007

int main() {
  int N;
  cin >> N;
  int counter = 0;
  rep(i, N) {
    int p;
    cin >> p;
    if (p != i + 1) counter++;
  }

  cout << (counter <= 2 ? "YES" : "NO" ) << endl;


}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ll long long int
const int INF = 2147483647;

using namespace std;

ll dp[101][100001] = {};

int main()
{
  int w[100];
  ll v[100];
  int n, W;
  cin >> n >> W;
  REP(i, n)
  {
    cin >> w[i] >> v[i];
  }

  dp[1][w[0]] = v[0];
  FOR(i, 1, n + 1)
  {
    REP(j, W + 1)
    {
      dp[i][j] = dp[i - 1][j];
      if (j - w[i - 1] >= 0)
      {
        dp[i][j] = max(dp[i][j], dp[i - 1][j - w[i - 1]] + v[i - 1]);
      }
    }
  }
  ll ans = 0;
  REP(j, W + 1)
  {
    ans = max(ans, dp[n][j]);
  }
  cout << ans << endl;
}


Measured memory_bytes: 78336
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int num = sc.nextInt();
        String ans = "YES";
        Set<Integer> a = new HashSet<>();
        for(int i = 0; i < num; i++){
            a.add(sc.nextInt());
        }
        if(a.size() != num){
            ans = "NO";
        }
        
        System.out.println(ans);
    }
}

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

int main(){
  string s;
  cin>>s;
  int count = 0;
  int ans =0;
  for(int i=0;i<3;i++){
    if(s[i]=='R'){
      count++;
      ans = max(ans, count);
    }
    else count = 0;
  }
  cout<<ans<<endl;
  return 0;
}

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


void swap (int *x, int *y) {
  int temp;

  temp = *x;
  *x = *y;
  *y = temp;

  return;
}

int gcd(int a,int b){
  if(a<b){
    swap(&a,&b);
  }

  if(b==0){
    return a;
  }

  int r=a%b;
  while(r!=0){
    a = b;
    b = r;
    r = (a%b);
  }

  return b;
}

/* クイックソート */
int dn(const void*a,const void*b){return*(int*)b-*(int*)a;}


int modpow(int a,int n,int mod){
  int ans=1;
  while(n>0){
    if(n & 1){
      ans=ans*a%mod;
    }
    a=a*a%mod;
    n/=2;
  }
  return ans;
}

int max(int a,int b){
  if(a<b){
    return b;
  }
  else{
    return a;
  }
}

int min(int a,int b){
  if(a<b){
    return a;
  }
  else{
    return b;
  }
}

void chmax(int *a,int b){
  if(*a < b){
    *a = b;
  }

  return;
}

void chmin(int *a,int b){
  if(*a > b){
    *a =b;
  }

  return;
}

/****************************************\
| Thank you for viewing my code:)        |
| Written by RedSpica a.k.a. RanseMirage |
| Twitter:@asakaakasaka                  | 
\****************************************/

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

  int now=0;

  if(k%2==0 || k%5==0){
    printf("-1\n");
    return 0;
  }

  for(int i=1;i<=k;i++){
    now*=10;
    now+=7;

    if(now%k==0){
      printf("%d\n",i);
      return 0;
    }
    now%=k;
  }

  return 0;
}

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

//短縮
#define rep(i,n) for(int i=0;i<(n);++i)
//sort()用
#define all(v) v.begin(), v.end()

//using Graph = vector<vector<int>>;

using namespace std;

int main(){
  while(1){
    int n,x;
    cin >> n >> x;
    if(n==0&&x==0) break;
    vector<int> vec;
    int sum=0;
    rep(i,n){
      for(int j=i+1;j<n;j++){
        for(int k=j+1;k<n;k++){
          if((i+j+k+3) == x){
            sum++;
          }
        }
      }
    }
    cout << sum << endl;
  }
  return 0;
}



Measured memory_bytes: 3092
#include <stdio.h>

#define MAX_HILL 10
#define TOP 3

int hills[TOP+1];

void add(int height) {
    int i;
    for(i=TOP-1;i>=0;i--) {
        if(hills[i] < height) {
            hills[i+1] = hills[i];
            hills[i] = height;
        }
    }
}

void print(void) {
    int i;
    for(i=0;i<TOP;i++) {
        printf("%d\n", hills[i]);
    }
}

int main(void) {
    int i, h;
    for(i=0;i<MAX_HILL;i++) {
        scanf("%d\n", &h);
        add(h);
    }

    print();

    return 0;
}

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

void Main()
{
  ll A; cin >> A;
  string B; cin >> B;
  B = B.replace(B.end()-3, B.end()-2, "");
  //cout << B << endl;
  ll Bll = stoi(B);
  //cout << Bll << endl;
  cout << A*Bll/(ll)100 << endl;
}

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


Measured memory_bytes: 3596
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const int INF = (1<<30);
const ll INFLL = (1ll<<60);
const ll MOD = (ll)(1e9+7);

#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	a = (a<MOD)?a:(a-MOD);
	b = (b<MOD)?b:(b-MOD);
	a += b;
	a = (a<MOD)?a:(a-MOD);
}

int main(void){
	ll r;
	cin >> r;
	cout << (r*r*3) << endl;
	return 0;
}


Measured memory_bytes: 256
/*Hey, What's up?*/

#include<bits/stdc++.h>
using namespace std;
#define pi acos(-1.0)
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
vector<long long>v;
int main()
{
    fastio;
    long long a=0,b=0,c,d,e,f=0,l,g,m,n,k,i,j,t,p,q;
    cin>>n;
    n=3*n*n;
    cout<<n;
    return 0;
}


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

typedef long long lint;
#define REP(i, x, n) for(lint i = x ; i < n ; i++)
#define rep(i, n) REP(i, 0, n)
#define repr(i, n) for(lint i = n - 1 ; i >= 0 ; i--)
#define SORT(c) sort((c).begin(), (c).end())

const int IINF = 1e9 + 10;
const lint LLINF = (lint)1e18 + 10;
const lint MOD = (lint)1e9 + 7;
const lint inv = MOD - 2;
const int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};
const int dx8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dy8[] = {0, -1, -1, -1, 0, 1, 1, 1};

struct node{
    int y, x, cost;
};

char mp[55][55];

int bfs(int h, int w){
    queue<node> que;
    node now;
    now.y = 1;
    now.x = 1;
    now.cost = 1;
    que.push(now);
    mp[1][1] = '#';
    int res = IINF;
    while(!que.empty()){
        now = que.front();
        que.pop();
        if(now.y == h && now.x == w){
            res = now.cost;
            break;
        }
        rep(i, 4){
            node nex;
            nex.y = now.y + dy[i];
            nex.x = now.x + dx[i];
            nex.cost = now.cost + 1;
            if(mp[nex.y][nex.x] == '.'){
                que.push(nex);
                mp[nex.y][nex.x] = '#';
            }
        }
    }
    return res;
}

int main(){
    rep(i, 55){
        rep(j, 55){
            mp[i][j] = '#';
        }
    }
    int h, w;
    cin >> h >> w;
    int ans = 0;
    REP(i, 1, h+1){
        REP(j, 1, w+1){
            cin >> mp[i][j];
            if(mp[i][j] == '.'){
                ans++;
            }
        }
    }
    int tmp = bfs(h, w);
    if(tmp < IINF){
        ans -= tmp;
    }else{
        ans = -1;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fo(x,a,b) for(int x=a;x<=b;x++)
#define dfo(x,a,b) for( int x=a;a>=b;x--)
//using namespace std;
int n,m,x,y,s[400050],tt;
bool pd;
int min(int x,int y){return (x<y?x:y);}
void build(int k,int l,int r)
{
	if (l==r)
	{
		s[k]=2147483647;
	}
	else
	{
		int mid=(l+r)/2;
		build(k*2,l,mid);
		build(k*2+1,mid+1,r);	
		s[k]=min(s[k*2],s[k*2+1]);
	}
}
void modify(int o,int l,int r,int q,int vl)
{
	 if (l>q||r<q) return;
	 if (!pd) return;
	 if (l==r) {if (l==q){s[o]=vl;pd=false;return;}}
	 int mid=(l+r)/2;
	 modify(o*2,l,mid,q,vl);
	 modify(o*2+1,mid+1,r,q,vl);
	 s[o]=min(s[o*2],s[o*2+1]);
}
int query(int o,int l,int r,int ql,int qr)
{
	 if (ql>r||qr<l) return 2147483647;
	 if (ql<=l&&qr>=r) return s[o];
	 int mid=(l+r)/2;
	 int p1=query(o*2,l,mid,ql,qr),p2=query(o*2+1,mid+1,r,ql,qr);
	 return(min(p1,p2));
}
int main ()
{
	scanf("%d%d",&n,&m);
	build(1,1,(n+1));
	fo(i,1,m)
	{
		scanf("%d%d%d",&tt,&x,&y);
		pd=true;
		if (tt==1) printf("%d\n",query(1,1,n+1,x+1,y+1));
		else modify(1,1,n+1,x+1,y);
	}

	return 0;
}



Measured memory_bytes: 4216
n = int(input())
a = []
b = []
apb = []
for i in range(n):
    ai,bi = map(int, input().split())
    a.append(ai)
    b.append(bi)
    apb.append(ai + bi)

il = sorted(range(n), key=lambda k: apb[k], reverse=True)
at = 0
bt = 0
for i in range(len(il)):
    selected = il[i]
    if i % 2 == 0:
        at += a[selected]
    else:
        bt += b[selected]
print(at - bt)

Measured memory_bytes: 20540
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for(int i=0;i<(int)n;i++)
#define PI acos(-1)
#define fast_io ios_base::sync_with_stdio(false) ; cin.tie(0); cout.tie(0);
ll mod=1e9+7;

int dp[]={};
int main(){
    fast_io
    
    int L;
    cin>>L;
    double ans=L/3.0;

    cout<<fixed<<setprecision(10)<<ans*ans*ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
//#include<cmath>
int main(void)
{
	//入力用変数
	double nyuuryoku1 = 0, nyuuryoku2 = 0,nyuuryoku3 = 0,nyuuryoku4 = 0;
	//連立方程式の答えの変数(解ではない)
	double ans1 = 0,ans2 = 0;
	//ans1とans2を消さないために
	double ans1_hozon = 0,ans2_hozon;
	//解
	double x = 0,y = 0;
	//保存用変数
	double hozon1 = 0,hozon2 = 0;

	while (scanf("%lf %lf %lf %lf %lf %lf",&nyuuryoku1,&nyuuryoku2,&ans1,&nyuuryoku3,&nyuuryoku4,&ans2) != EOF)
	{
		//まず答えの値をＸのためにかけた値分ｎ倍する
		ans1_hozon = ans1 * nyuuryoku3;
		ans2_hozon = ans2 * nyuuryoku1;
		//yも同じ数分かける(紙に書けば理解できるはず・・・)
		hozon1 = nyuuryoku2 * nyuuryoku3;
		hozon2 = nyuuryoku4 * nyuuryoku1;
		//xは同じ数なので無視して、答えとｙを引き算し、最終的にはｙを求める
		y = (ans1_hozon - ans2_hozon) / (hozon1 - hozon2);

		//xを求めたyを悪用して簡単にやってしまう
		x = (ans1 - (nyuuryoku2 * y)) / nyuuryoku1;

		//表示
		printf("%.3lf %.3lf\n",x,y);
	}

	return 0;
}

Measured memory_bytes: 1080