akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
using namespace std;
#define Rep(i,n) for(int i=0;i<(int)(n);i++)
#define For(i,n1,n2) for(int i=(int)(n1);i<(int)(n2);i++)
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define RREP(i,n) for(ll i=((ll)(n)-1);i>=0;i--)
#define FOR(i,n1,n2) for(ll i=(ll)(n1);i<(ll)(n2);i++)
#define RFOR(i,n1,n2) for(ll i=((ll)(n1)-1);i>=(ll)(n2);i--)
#define all(a)  (a).begin(),(a).end()
#define SORT(a) sort((a).begin(),(a).end())
#define oorret 0
#define oor(x) [&](){try{x;} catch(const out_of_range& oor){return oorret;} return x;}()
#define IOS cin.tie(0),ios::sync_with_stdio(false)
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
template<typename T1, typename T2> inline bool chmin(T1& a, T2 b) { if (a > b) { a = b; return 1; }return 0; }
template<typename T1, typename T2> inline bool chmax(T1& a, T2 b) { if (a < b) { a = b; return 1; }return 0; }
template<class Type>struct is_vector : std::false_type {};
template<class ValueType, class Alloc>struct is_vector<std::vector<ValueType, Alloc>> : std::true_type {};
template <typename T> inline ostream& operator << (ostream& out, const vector<T>& v) {
	if (v.empty())return out;
	constexpr bool is_vector_v = is_vector<T>::value;
	if (is_vector_v)for (auto itr = v.begin(); itr != v.end();)out << (*itr), out << ((++itr != v.end()) ? "\n" : "");
	else for (auto itr = v.begin(); itr != v.end();)out << (*itr), out << ((++itr != v.end()) ? " " : "");
	return out;
}
inline void put() {}
template<class T> inline void put(const T& first) { std::cout << first << "\n"; }
template<class T, class... N> inline void put(const T& first, const N& ... rest) { std::cout << first << " "; put(rest...); }
inline void putn() {}
template<class T, class... N> inline void putn(const T& first, const N& ... rest) { std::cout << first << "\n"; putn(rest...); }


int main() {
	IOS;
	ll n, a, b, c, d;
	cin >> n >> a >> b >> c >> d;
	REP(i, n) {
		ll t1 = a + i * d - (n - 1 - i) * c;
		ll t2 = t1 - b;
		if (0 <= t2 && t2 <= (d - c) * (n - 1)) {
			put("YES");
			return 0;
		}
	}
	put("NO");
	return 0;
}


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

using namespace std;

int main(){
    int n; cin >> n;
    vector<int> a(n+1);
    vector<int> b(n+1);
    vector<int> c;

    for(int i = 0;i < n; i++){
        cin >> a[i+1];
    }

    int count = 0;
    for(int i = n;i >= 1; i--){
        int sum = 0;
        for(int j = i+i ; j <= n; j += i){
            sum ^= b[j];
        }
        b[i] = sum ^ a[i];
    }

    for(int i = 1;i <= n; i++){
        if(b[i]) c.push_back(i);
    }


    cout << c.size() << endl;
    for(int i = 0;i <c.size();i++){
        printf("%d%c",c[i],i+1==c.size()?'\n':' ');
    }
    cout << endl;

    return 0;
}

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define For(i , j , k) for (int i = (j) , _##end_ = (k) ; i <= _##end_ ; ++ i)
#define Fordown(i , j , k) for (int i = (j) , _##end_ = (k) ; i >= _##end_ ; -- i)
#define Set(a , b) memset(a , b , sizeof(a))
#define pb push_back
#define Mod 1000000007
typedef unsigned long long LL;
using namespace std;

const int maxn = 200010;

char s[maxn];

LL Ans , len , c[30];

int main()
{
#ifdef hany01
	freopen("test.in" , "r" , stdin);
	freopen("test.out" , "w" , stdout);
#endif
	scanf("%s" , s);
	len = strlen(s);
	For(i , 0 , len - 1)
		++ c[s[i] - 97];
	LL Ans = (len + 1) * len / 2;
	For(i , 0 , 25)
		if (c[i])
			Ans -= (c[i]) * (c[i] + 1) / 2;
	cout << Ans + 1 << endl;
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using VI = vector<int>;
using VL = vector<ll>;
#define FOR(i,a,n) for(int (i)=(a);(i)<(n);++(i))
#define eFOR(i,a,n) for(int (i)=(a);(i)<=(n);++(i))
#define rFOR(i,a,n) for(int (i)=(n)-1;(i)>=(a);--(i))
#define erFOR(i,a,n) for(int (i)=(n);(i)>=(a);--(i))
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
#define all(i) (i).begin(),(i).end()
#define out(y,x,h,w) (y) < 0 || (h) <= (y) || (x) < 0 || (w) <= (x)
#define line cout << "------------------------\n" 
#define ENDL(i,n) ((i) == (n) - 1 ? "\n" : " ")
#define stop system("pause")
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
const long double pi = acos(-1);
const long double eps = 1e-10;
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; }
inline void init() { cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }
template<class T>inline istream& operator>>(istream& is, vector<T>& v) { for (auto& elemnt : v)is >> elemnt; return is; }
//ate
template<class T, class U>inline istream& operator>>(istream& is, pair<T, U>& p) { is >> p.first >> p.second; return is; }
template<class T>inline vector<T> vec(size_t a) { return vector<T>(a); }
template<class T, class... Ts>inline auto vec(size_t a, Ts... ts) { return vector<decltype(vec<T>(ts...))>(a, vec<T>(ts...)); }
void yes() { cout << "Yay!\n"; }
void no() { cout << ":(\n"; }

int main() {
    init();

    int h, w, k; cin >> h >> w >> k;
    vector<string> s(h); cin >> s;

    VI g(h);
    FOR(y, 0, h) {
        bool c = false;
        FOR(x, 0, w) {
            if (s[y][x] == '#')c = true;
        }
        if (c)g[y] = y;
        else g[y] = -1;
    }
    vector<VI> ans(h, VI(w, -1));
    queue<pair<int, int>> bfs;
    int cnt = 1;
    FOR(y, 0, h){
        if (g[y] == -1)continue;
        bool f = true;
        FOR(x, 0, w) {
            if (s[y][x] == '#') {
                if (f)f = false;
                else ++cnt;
            }
            ans[y][x] = cnt;
        }
        ++cnt;
    }

    FOR(y, 0, h) {
        int p = g[y];
        if (g[y] == -1) {
            rFOR(i, 0, y)if (g[i] != -1) {
                p = g[i];
                break;
            }
            FOR(i, y + 1, h)if (g[i] != -1) {
                p = g[i];
                break;
            }
        }
        FOR(x, 0, w)cout << ans[p][x] << ENDL(x, w);
    }
}


Measured memory_bytes: 1280
package main

import "fmt"

func main() {
	var n, x, t int
	fmt.Scanf("%d %d %d", &n, &x, &t)
	if n%x > 0 {
		fmt.Println((n/x + 1) * t)
	} else {
		fmt.Println(n / x * t)
	}
}


Measured memory_bytes: 1832
#include <bits/stdc++.h>
using namespace std;;
#define ll long long
#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 FORR(i, m, n) for(int i = m;i >= n;i--)
#define INF 1<<30
#define LINF 1LL<<62
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;
int main(){
    int h,w; cin >> h >> w;
    int n; cin >> n;
    int a[n];
    vector<int> col[h];
    int now = 0;
    REP(i,n){
        int a; cin >> a;
        while(a!=0){
            if(col[now].size()==w) now++;
            col[now].push_back(i+1);
            a--;
        }
    }
    REP(i,h){
        if(i%2==0){
            auto it = col[i].begin();
            REP(i,w){
                cout << *it ;
                if(i!=w-1){
                    cout << " ";
                }else{
                    cout << endl;
                }
                it++;
            }
        }else{
            auto it = col[i].rbegin();
            REP(i,w){
                cout << *it ;
                if(i!=w-1){
                    cout << " ";
                }else{
                    cout << endl;
                }
                it++;
            }
        }

    }
    

}

Measured memory_bytes: 384
N = int(input())
L = input().split()
L = [int(s) for s in L]
i = 0
L_max = L[0]
for i in range(len(L)):
    if L_max < L[i]:
        L_max = L[i]
if L_max < sum(L) - L_max:
    print("Yes")
else:
    print("No")


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

using namespace std;


int n, k;
int have[10];

bool ok(int x) {
  if (x == 0) {
    return !have[x];
  }
  while (x) {
    int d = x % 10;
    if (have[d]) return false;
    x /= 10;
  }
  return true;
}

int main() {
  scanf("%d %d", &n, &k);
  for (int i = 0; i < k; i++) {
    int foo; scanf("%d", &foo);
    have[foo] = true;
  }
  for (int i = n; ; i++) {
    if (ok(i)) {
      printf("%d\n", i);
      return 0;
    }
  }
  return 0;
}

Measured memory_bytes: 256
import math
def Euclidean(x,y):
    if y == 0:
        return x
    else:
        return Euclidean(y,x%y)

A,B,C,D = [int(x) for x in input().split()]
count = B - A + 1
E = Euclidean(C,D)
F = int(C*D/E)

C_ = B//C - (A-1)//C
D_ = B//D - (A-1)//D
C_and_D = B//F - (A-1)//F
print(count - (C_ + D_ - C_and_D))


Measured memory_bytes: 3064
n, k = map(int, input().split())
dl = list(map(int, input().split()))

i = n
while True:
    money = list(map(int, str(i)))
    for m in money:
        if dl.count(m) != 0:
            break
    else:
        print(i)
        break
    i += 1
    


Measured memory_bytes: 9096
#include<bits/stdc++.h>
using namespace std;
int a[500002];
int main()
{
    int n,i,j,k,l,res=0;
    cin>>n>>k;
    for(i=0;i<n;i++)
    {
        cin>>a[i];
    }
    i=0;
    while(1)
    {
        i=i+k;
        res++;
        if(i>=n)break;
        else i--;
    }
    cout<<res<<'\n';
    return 0;
}


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

int main()
{
	int a, b, count = 1, sum;
	cin >> a >> b;
	if(b==1){
		cout << '0' << endl;
		return 0;
	}
	sum = a;
	while(sum<b){
		sum += a - 1;
		count++;
	}
	cout << count << endl;
}

Measured memory_bytes: 256
N, M = [int(v) for v in input().split()]

boat = [[] for _ in range(N)]
for _ in range(M):
    a, b = [int(v) for v in input().split()]
    boat[a-1].append(b-1)
    boat[b-1].append(a-1)
    
ans = False
for island in boat[N-1]:
    ans |= any(t == 0 for t in boat[island])
    
print ("POSSIBLE" if ans else "IMPOSSIBLE")

Measured memory_bytes: 38396
import std.algorithm, std.container, std.conv, std.math, std.range, std.typecons, std.stdio, std.string;

auto rdsp(){return readln.splitter;}
void pick(R,T)(ref R r,ref T t){t=r.front.to!T;r.popFront;}
void readV(T...)(ref T t){auto r=rdsp;foreach(ref v;t)pick(r,v);}
void readC(T...)(size_t n,ref T t){foreach(ref v;t)v=new typeof(v)(n);foreach(i;0..n){auto r=rdsp;foreach(ref v;t)pick(r,v[i]);}}

void main()
{
  int n, m; readV(n, m);
  long[] x, y, z; readC(n, x, y, z);

  auto r = -10L^^18;
  foreach (p; 0..1<<3) {
    auto sx = p.bitTest(0) ? 1 : -1;
    auto sy = p.bitTest(1) ? 1 : -1;
    auto sz = p.bitTest(2) ? 1 : -1;

    auto dp = new long[][](n+1, m+1);
    foreach (dpi; dp) dpi[] = -10L^^18;
    dp[0][0] = 0;

    foreach (i; 0..n)
      foreach (j; 0..m+1) {
        dp[i+1][j] = dp[i][j];
        if (j > 0)
          dp[i+1][j] = max(dp[i+1][j], dp[i][j-1]+x[i]*sx+y[i]*sy+z[i]*sz);
      }

    r = max(r, dp[n][m]);
  }

  writeln(r);
}

pragma(inline) {
  pure bool bitTest(T)(T n, size_t i) { return (n & (T(1) << i)) != 0; }
  pure T bitSet(T)(T n, size_t i) { return n | (T(1) << i); }
  pure T bitReset(T)(T n, size_t i) { return n & ~(T(1) << i); }
  pure T bitComp(T)(T n, size_t i) { return n ^ (T(1) << i); }

  pure T bitSet(T)(T n, size_t s, size_t e) { return n | ((T(1) << e) - 1) & ~((T(1) << s) - 1); }
  pure T bitReset(T)(T n, size_t s, size_t e) { return n & (~((T(1) << e) - 1) | ((T(1) << s) - 1)); }
  pure T bitComp(T)(T n, size_t s, size_t e) { return n ^ ((T(1) << e) - 1) & ~((T(1) << s) - 1); }

  import core.bitop;
  pure int bsf(T)(T n) { return core.bitop.bsf(ulong(n)); }
  pure int bsr(T)(T n) { return core.bitop.bsr(ulong(n)); }
  pure int popcnt(T)(T n) { return core.bitop.popcnt(ulong(n)); }
}


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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N, T;
  cin >> N >> T;
  vector<pair<int, int>> AB(N);
  for (int i = 0; i < N; i++) {
    cin >> AB[i].first >> AB[i].second;
  }
  sort(AB.begin(), AB.end());
  vector<int> dp(T + 1, 0);
  for (int i = 0; i < N; i++) {
    int a = AB[i].first, b = AB[i].second;
    for (int t = T - 1; t >= 0; t--) {
      dp[min(T, t + a)] = max(dp[min(T, t + a)], dp[t] + b);
    }
  }
  cout << dp[T] << '\n';
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define ull unsigned long long int
#define ld long double
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define intarr(arr, n)  ll arr[n];  for (ll i = 0; i < n; i++)  cin >> arr[i]
#define inpvec(vec,n) for(ll i=0;i<n;i++){ll var;cin>>var;vec.push_back(var);}
#define ff first
#define ss second
#define pb push_back
#define mkp make_pair
#define vec vector<ll>
#define pi pair<ll,ll>
#define changeline cout<<endl
#define loop(i,a,b) for(ll i=a;i<b;i++)
#define rev(i,a,b) for(ll i=a;i>=b;i--)
#define all(v) v.begin(),v.end()
#define mod2 998244353
#define NO cout << "NO" <<endl
#define YES cout << "YES" <<endl
#define mem(arr,val) memset(arr,val,sizeof(arr));
const ll mod=1e9+7;
#define piii 3.14159265358979323846264338327950
#define print(a, n, m)     for (ll i = n; i < m; i++) {  cout << a[i] << " "; }  //cout << endl
#define con continue

bool prime(ll n) 
{ 
    if (n <= 1)  return false; 
    if (n <= 3)  return true; 
    if (n%2 == 0 || n%3 == 0) return false; 
  
    for (ll i=5; i*i<=n; i=i+6) 
        if (n%i == 0 || n%(i+2) == 0) 
           return false; 
  
    return true; 
}
bool isPerfectSquare(ll x) {   
  long double sr = sqrt(x); 
  return ((sr - floor(sr)) == 0); 
} 
bool subsequence_checker(string str1, string str2, ll m, ll n) 
{ 
    if (m == 0) return true; 
    if (n == 0) return false; 
    if (str1[m-1] == str2[n-1]) 
        return subsequence_checker(str1, str2, m-1, n-1); 
    return subsequence_checker(str1, str2, m, n-1); 
}
bool cmp(const pair<int,int> &a,  const pair<int,int> &b) 
{ 
    if(a.ff == b.ff)
        return a.ss < b.ss;
    return (a.ff > b.ff); 
}
ll gcd(ll p, ll q){
if(p % q == 0)return q;
return gcd(q, p % q);
}
ll getSumofdigit(ll n) {

    ll sum = 0; 
    while (n != 0) 
    { 
     sum = sum + n % 10; 
     n = n/10; 
    }  
    return sum; 
} 
ll countDigit(ll n) 
{ 
    return floor(log10(n) + 1); 
}
//////////////////////////////////////////////////// Lets Do It ////////////////////////////////////////////////////////


ll printDivisors(ll n) 
{ 
    ll count =0 ;
    for (ll i = 1; i*i < n; i++) { 
        if (n % i == 0) 
            count++; 
    } 
    for (ll i = sqrt(n); i >= 1; i--) { 
        if (n % i == 0) 
            count++; 
    } 
    return count;
} 

void solve()
{

    ll n;

    cin>>n;

    ll ans = 0;

    loop(a,1,n)
    {
        for(ll b = 1; a*b<n ; b++)
        {
            if(n-a*b > 0) ans++;
        }
    }

    cout<<ans;
    return;
}
 
int main()
{
#ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
#endif
    IOS;
    ll t;
    //cin>>t;
    t=1;

    while(t--){
        solve();
        cout<<endl;
    }

    cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
    return 0;
} 



Measured memory_bytes: 3700
def f(n):
    memo = {}
    def compute(n):
        if n in memo:
            return memo[n]
        if n == 2:
            return 2
        if n <= 1:
            return 1
        ret = compute(n-1) + compute(n-2)
        memo[n] = ret
        return ret
    return compute(n)


memo = {}

def gen_patterns(c, h, w, k):
    if (c, h) in memo:
        return memo[(c,h)]
    elif h == 1:
        if c == k:
            return f(c-1) * f(w-c) % 1000000007
        elif c+1 == k:
            return f(c-1)* f(w-c-1) % 1000000007
        elif c-1 == k:
            return f(c-2)*f(w-c) % 1000000007
        else:
            return 0
    else:
        ret = 0
        ret += f(c-1) * f(w-c) * gen_patterns(c,h-1,w,k)
        ret = ret % 1000000007
        if c != 1:
            ret += f(c-2)*f(w-c)*gen_patterns(c-1,h-1,w,k)
            ret = ret % 1000000007
        if c != w:
            ret += f(c-1)*f(w-c-1)*gen_patterns(c+1,h-1,w,k)
            ret = ret % 1000000007
        memo[(c,h)] = ret
        return ret


def main():
    H, W, K = list(map(int, input().split(' ')))
    print(gen_patterns(1, H, W, K))



if __name__ == '__main__':
    main()

Measured memory_bytes: 3316
#encoding=utf-8

stac, car_in, ans = [], [], []
while True:
    try:
        stac.append(input())
    except:
        break

z = len(stac)
for i in xrange(z):
    if stac[i] != 0:
        car_in.insert(0,stac[i])
    elif stac[i] == 0:
        ans.append(car_in[0])
        del car_in[0]

for i in xrange(len(ans)):
    print ans[i]

Measured memory_bytes: 6336
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <vector>
#include <iostream>
#include <map>
#include <set>
#include <algorithm>
#include <unordered_map>
#include <queue>
#include <sstream>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define SZ(x) (int)(x.size())
#define F0(i,n) for(int i=0;i<n;i++)
#define F1(i,n) for(int i=1;i<=n;i++)
#define CL(a,x) memset(x, a, sizeof(x));
#define P(x) cerr << #x << "=" << x << endl

const int MOD = 998244353;
const double pi = atan(1.0)*4.0;
const double eps = 1e-8;
ll gcd(ll x, ll y) { return y ? gcd(y, x%y) : x; }
int bc(int n) { return n ? bc((n-1)&n)+1 : 0; }

const int N = 200001;
int i, j, k, m, n;
string s;
int a[N];

ll A, B;

void solve() {
   ll ans = k + 1;
   if (B > A + 2 && k >= A - 1) {
       ans += (B - A - 2) * ((k - (A - 1)) / 2);
   }
   cout << ans << endl;
}

int main() {
    //freopen("x.in", "r", stdin);
    while (cin >> k >> A >> B) {
        solve();
    }
    return 0;
}


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

using namespace std;

const int MaxN = 200005;

int n, k;
long long v[MaxN], BITree[MaxN];
pair <long long, int> x[MaxN];

void Update(int pos, int val = 1) {
  for (; pos < MaxN; pos += pos & (-pos)) {
    BITree[pos] += val;
  }
}

long long Query(int pos) {
  long long ans = 0;
  for (; pos; pos -= pos & (-pos)) {
    ans += BITree[pos];
  }

  return ans;
}

int main() {
  cin >> n >> k;
  for (int i = 0; i < n; ++i) {
    cin >> v[i];
  }

//  x[1].first = v[0];
//  x[1].second = 1;
  x[0].first = -(1LL << 62);
  x[0].second = 1;
  for (int i = 1; i <= n; ++i) {
    x[i].first = v[i - 1] + x[i - 1].first - k;
    x[i].second = i + 1;
  }

  sort(&x[0], &x[n + 1]);

  long long ans = 0;
  for (int i = 0; i <= n; ++i) {
    ans += Query(x[i].second);
    Update(x[i].second);
  }

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

Measured memory_bytes: 6528
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace B
{
    public class Program
    {
        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            Solve();
            Console.Out.Flush();
        }

        public static void Solve()
        {
            var nmvp = Console.ReadLine().Trim().Split(' ').Select(long.Parse).ToArray();
            var ai = Console.ReadLine().Trim().Split(' ').Select(long.Parse).ToArray();
            Array.Sort(ai);
            var n = nmvp[0];
            var m = nmvp[1];
            var v = nmvp[2];
            var p = nmvp[3];
            var l = -1;
            var r = ai.Length;
            var problem = ai.Length - p;
            while (r - l > 1)
            {
                var x = (l + r) / 2;
                if (x >= problem)
                {
                    r = x;
                    continue;
                }

                var tmp = (v - p) * m;
                var max = ai[x] + m;
                if (max < ai[problem])
                {
                    l = x;
                    continue;
                }

                var sum = 0L;
                for (var i = 0; i <= problem; i++)
                {
                    if (i != x) sum += Math.Min(m, max - ai[i]);
                }

                if (tmp <= sum) r = x;
                else l = x;
            }
            Console.WriteLine(ai.Length - r);
        }
    }
}


Measured memory_bytes: 23136
#include <iostream>
#include <utility>
#include <vector>
#include <tuple>
#include <cstdint>
#include <limits>

using namespace std;

// Type aliases
using i8  =  int8_t; using  u8 =  uint8_t;
using i16 = int16_t; using u16 = uint16_t;
using i32 = int32_t; using u32 = uint32_t;
using i64 = int64_t; using u64 = uint64_t;

template <class T> using V = vector<T>;

// Loops
#define REP(i, n) for (int i = 0; i < n; ++i)
#define REPR(i, n) for (int i = n - 1; i >= 0; --i)
#define FOR(i, n, m) for (int i = n; i < m; ++i)
#define FORR(i, n, m) for (int i = m - 1; i >= n; --i)

// Input
template <class T>
T read() {
    T t;
    cin >> t;
    return t;
}

template <class T>
vector<T> read(const int length) {
    vector<T> ts(length);
    for (auto& t: ts) {
        cin >> t;
    }
    return ts;
}

// Output
namespace debug {
    template <class F, class S>
    ostream &operator<<(ostream& stream, const pair<F, S> &pair) {
        stream << "{" << pair.first << ", " << pair.second << "}";
        return stream;
    }
    template <class Arg, class ...Args>
    void output(ostream& stream, tuple<Arg, Args...> tuple) {
        stream << get<1>(tuple) << ", ";
        // TODO
    }
    template <class Arg>
    void output(ostream& stream, tuple<Arg> tuple) {
        stream << get<1>(tuple);
    }
    template <class ...Args>
    ostream &operator<<(ostream& stream, const tuple<Args...> &tuple) {
        stream << "{";
        output(stream, tuple);
        stream << "}";
        return stream;
    }

    template <class T, class Alloc>
    ostream &operator<<(ostream& stream, const vector<T, Alloc> &vector) {
        stream << "[";

        for (auto i = 0; i < vector.size(); i++) {
            stream << vector[i];

            if (i != vector.size() - 1) {
                stream << "," << ((i % 10 == 9) ? "\n " : "\t");
            }
        }

        stream << "]";
        return stream;
    }
}

struct Edge {
    u16 source;
    u16 target;
    i64 weight;
};

// Body
void body() {
    auto N = read<u16>();
    auto M = read<u16>();
    auto edges = vector<Edge>(M);
    for (auto &edge: edges) {
        edge.source = read<u16>() - 1;
        edge.target = read<u16>() - 1;
        edge.weight = -read<i64>();
    }

    // Bellman-Ford
    auto vertices = vector<i64>(N, 999999999999999);
    vertices[0] = 0;

    REP(i, N - 1) {
        for (auto &edge: edges) {
            auto u = edge.source;
            auto v = edge.target;
            if (vertices[v] > vertices[u] + edge.weight) {
                vertices[v] = vertices[u] + edge.weight;
            }
        }
    }

    auto is_inf = vector<bool>(N, false);

    for (auto &edge: edges) {
        auto u = edge.source;
        auto v = edge.target;
        if (is_inf[u] || vertices[u] + edge.weight < vertices[v])  {
            is_inf[v] = true;
        }
    }

    using namespace debug;
    
    if (is_inf[N - 1]) {
        cout << "inf" << endl;
    } else {
        cout << -vertices[N-1] << endl;
    }
}

// main function (DO NOT EDIT)
int main () {
    ios_base::sync_with_stdio(false);
    body();
    return 0;
}

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

int main() {
    int A, B, C, D;
    cin >> A >> B >> C >> D;
    if (A + B > C + D){
        cout << "Left" << endl;
    }
    else if (A + B == C + D) {
        cout << "Balanced" << endl;
    }
    else {
        cout << "Right" << endl;
    }
}

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

int main()
{
  long long int n;
  scanf("%lld",&n);
  long long int m = 1;
  long long int ntemp = n;
  long long int sum = 0;
  long long int dig;
  //printf("ntemp = %lld\n",ntemp);
  while(ntemp > 0){
    dig = ntemp % 10;
    sum = sum + dig;
    ntemp = ntemp / 10;
  }
  //printf("sum = %lld\n",sum);
  long long int dsum = sum;
  ntemp = n;
  while(ntemp>0) {
    m = m * 10;
    //printf("m = %lld\n",m);
    ntemp = (n/m)*m-1;
    sum = 0;
    //printf("ntemp = %lld\n",ntemp);
    while(ntemp > 0){
      dig = ntemp % 10;
      sum = sum + dig;
      ntemp = ntemp / 10;
    }
    //printf("sum = %lld\n",sum);
    if (dsum < sum) {
      dsum = sum;
    }
    ntemp = (n/m)*m-1;
  }
  printf("%lld\n",dsum);
  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n, h[100001], k;
    scanf("%d%d", &n, &k);
    for (int i = 1; i <= n; i++)
        scanf("%d", &h[i]);
    long long dp[100001];
    dp[1] = 0;
    for (int i = 2; i <= n; i++)
        dp[i] = (long long) 1e18;
    for (int i = 1; i < n; i++)
        for (int j = 1; j <= k; j++)
        if (i + j <= n)
            dp[i + j] = min(dp[i + j], dp[i] + abs(h[i] - h[i + j]));
        else break;
    printf("%lld\n", dp[n]);
    return 0;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

int cs[505], ss[505], fs[505];

int main(int argc, char *argv[]) {
  ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);

  int n;cin>>n;
  for(int i=0;i<n-1;i++){
    cin>>cs[i]>>ss[i]>>fs[i];
  }

  for(int i=0;i<n-1;i++){
    ll t = ss[i]+cs[i];
    for(int j=i+1;j<n-1;j++){
      if(t<=ss[j]){
        t = ss[j] + cs[j];
      }else {
        ll mod = (t-ss[j]) % fs[j];
        if(mod==0){
          t += cs[j];
        } else {
          t += fs[j] + cs[j] - mod;
        }
      }
    }
    cout<<t<<endl;
  }
  cout<<0<<endl;

  return 0;
}


Measured memory_bytes: 256
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <climits>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <queue>
#include <random>
#include <complex>
#include <regex>

using namespace std;

#define C_MAX(a, b) ((a)>(b)?(a):(b))
#define SHOW_VECTOR(v) {std::cerr << #v << "\t:";for(const auto& xxx : v){std::cerr << xxx << " ";}std::cerr << "\n";}
#define SHOW_MAP(v){std::cerr << #v << endl; for(const auto& xxx: v){std::cerr << xxx.first << " " << xxx.second << "\n";}}


int main() {

    int N;
    cin >> N;

    vector<int> A(N);
    for (int i = 0; i < N; i++) cin >> A[i];

    bitset<24> B(0);
    long long sum = 0;
    long long ans = 0;

    int right = 0;
    for (int left = 0; left < N; left++) {
        if (right <= left) right = left;
        while (right < N && (sum + A[right]) == (B ^ (bitset<24>(A[right]))).to_ullong()) {
            sum += A[right];
            B ^= bitset<24>(A[right]);
            right++;
        }
        ans += (right - left);
        sum -= A[left];
        B ^= A[left];
    }

    cout << ans << endl;

    return 0;
}














































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

int main()
{
    int N;
    cin >> N;
    vector<vector<pair<int, int>>> testimonies;

    // init
    rep(i, N)
    {
        vector<pair<int, int>> vec;
        testimonies.push_back(vec);

        int A;
        cin >> A;
        rep(j, A)
        {
            int x, y;
            cin >> x >> y;
            testimonies[i].push_back(make_pair(x, y));
        }
    }

    // bitwise search
    int ans = 0;
    for (int bit = 0; bit < (1 << N); ++bit)
    {
        bool consistent = true;

        // determine who is honest for this combination
        set<int> honest;
        set<int> liers;

        for (int i = 0; i < N; i++)
        {
            if (bit & (1 << i))
            {
                honest.insert(i);
            }
            else
            {
                liers.insert(i);
            }
        }

        // Check if the testimonies are consistent
        for (int i : honest)
        {
            for (auto t : testimonies[i])
            {
                if (t.second == 0 && !liers.count(t.first - 1))
                {
                    consistent = false;
                }
                else if (t.second == 1 && !honest.count(t.first - 1))
                {
                    consistent = false;
                }
            }
        }

        // Update if larger than maximum
        if (consistent && honest.size() > ans)
        {
            ans = honest.size();
        }
    }

    cout << ans << endl;
}


Measured memory_bytes: 256
a,b,k = gets.split.map(&:to_i)

ans = []

k.times do |i|
  if a + i > b
    break
  end
  ans << a + i
end

k.times do |i|
  if b - k + i + 1 < a
    break
  end
  ans << b - k + i + 1
end

ans.uniq.each do |x|
  puts x
end

Measured memory_bytes: 14400
n = int(input())
a = list(map(int, input().split()))
r = {}
for i in range(n):
    try:
        r[i-a[i]] += 1
    except:
        r[i-a[i]] = 1
cnt = 0
for i in range(n):
    r[i-a[i]] -= 1
    try:
        cnt += r[i+a[i]]
    except:
        pass
print(cnt)

Measured memory_bytes: 40452
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iostream>
#include <iostream>
#include <fstream>
#include <numeric>
#include <cstring>
#include <cassert>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <cmath>
#include <set>
#include <map>
#include <functional>
#include <bitset>
#include <iomanip>
#include <stack>
#include <list>
#include <cstdint>
#include <chrono>

using namespace std;
#define     loop(n,i,a)     for(ll i=a;i<n;i++)
#define     loopR(n,i,a)    for(ll i=a-1;i>=n;i--)
#define     all(arr,n)      arr,arr+n
#define     allv(v)         (v).begin(),(v).end()
#define     rallv(v)        (v).rbegin(),(v).rend()
#define     m_p             make_pair
#define     ll              long long
#define     pii             pair<ll,ll>
#define     vi              vector<int>
#define     vll             vector<ll>
#define     vii             vector<pii>
#define     sz(x)           (int)x.size()
#define     pb              push_back
#define     endl            "\n"
#define     Endl            "\n"
#define     f               first
#define     s               second
#define     mem(dp,n)       memset(dp,n,sizeof dp)
template<typename T>void max_self(T &a,T b){a=max(a,b);}
template<typename T>void min_self(T &a,T b){a=min(a,b);}
int dx[] = { 1 , 0 ,-1 , 0 ,-1 ,-1 , 1 , 1 };
int dy[] = { 0 , 1 , 0 ,-1 ,-1 , 1 ,-1 , 1 };
int KnightI[] = { 2, 1, -1, -2, -2, -1, 1, 2 };
int KnightJ[] = { 1, 2, 2, 1, -1, -2, -2, -1 };
void fast(){
    std::ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);
}
vector<string> vec_splitter(string s) {
    s += ',';
    vector<string> res;
    while(!s.empty()) {
        res.push_back(s.substr(0, s.find(',')));
        s = s.substr(s.find(',') + 1);
    }
    return res;
}
void debug_out(
        vector<string> __attribute__ ((unused)) args,
        __attribute__ ((unused)) int idx,
        __attribute__ ((unused)) int LINE_NUM) { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(vector<string> args, int idx, int LINE_NUM, Head H, Tail... T) {
    if(idx > 0) cerr << ", "; else cerr << "Line(" << LINE_NUM << ") ";
    stringstream ss; ss << H;
    cerr << args[idx] << " = " << ss.str();
    debug_out(args, idx + 1, LINE_NUM, T...);
}
#define debug(...) debug_out(vec_splitter(#__VA_ARGS__), 0, __LINE__, __VA_ARGS__)
const ll mxN=4e5+10,oo=0x3f3f3f3f,MOD=1e9+7;
const long double PI = acos(-1),eps=1.0e-14;

void solve(){
    int a,b;
    cin>>a>>b;
    bool flag=a!=b;
    max_self(a,b);
    cout<<2*a-flag<<endl;
}
int main() {
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    fast();
    solve();

}


Measured memory_bytes: 3640
#include <bits/stdc++.h>
#define MOD 1000000007
using namespace std;

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

long long modinv(long long a, long long m=MOD) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m; 
    if (u < 0) u += m;
    return u;
    /*MODの割り算の際に
    a/＝b;
    を
    a *= modinv(b,MOD);
    とする。
        */
}
string S;
void solve(){
    rep(i,4){
        if(S[i]==S[i+1]){
            puts("Bad");
            return;
        }
    }
    puts("Good");
}
int main(){
    
    cin >> S;
    solve();
    

    return 0;
}

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

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

using namespace std;
const int INF = 1 << 30;
const long long LINF = 1LL << 60;
const long long MOD = 1000000000 + 7;
const double PI = acos(-1);

int main() {
	int N; cin >> N;
	vector<int> a(N);
	map<int, int>mp;
	rep(i, N) {
		cin >> a[i];
		++mp[a[i]];
	}
	int ans = 0;
	for (auto itr = mp.begin(); itr != mp.end(); ++itr) {
		int key = itr->first;
		int num = itr->second;
		if (key <= num) {
			ans += (num - key);
		}
		else {
			ans += num;
		}
	}
	cout << ans;
}



Measured memory_bytes: 8136
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(int (i) = (s);(i) <= (e);(i)++)

int N;

int Ma,Mb;

vector<int> A,B,C;

int main(){
  cin >> N >> Ma >> Mb;
  A.resize(N);
  B.resize(N);
  C.resize(N);
  rep(i,0,N - 1){
    cin >> A[i] >> B[i] >> C[i];
  }

  vector<vector<int>> dp(505,vector<int>(505,1e9));
  dp[0][0] = 0;

  rep(i,0,N - 1){
    auto next = dp;
    rep(a,0,400)rep(b,0,400){
      if(a - A[i] >= 0 && b - B[i] >= 0){
        next[a][b] = min(next[a][b],dp[a - A[i]][b - B[i]] + C[i]);
      }
    }
    swap(next,dp);
  }
  int a = Ma;
  int b = Mb;
  int ans = 1e9;
  while(a <= 400 && b <= 400){
    ans = min(ans , dp[a][b]);
    a += Ma;
    b += Mb;
  }

  cout << (ans == 1e9 ? -1 : ans) << endl;
}

Measured memory_bytes: 2328
#include <iostream>
#include <string>
#include <cstdio>
#include <cmath>

using namespace std;

int main(void)
{	
	int num;
	cin >> num;
	int p1 = 0, p2 = 0;

	for (int i = 0; i < num; i++)
	{
		string w1, w2;
		cin >> w1;
		cin >> w2;

		if (w1 < w2)
			p2 += 3;
		else if (w2 < w1)
			p1 += 3;
		else if (w1 == w2)
		{
			p1++;
			p2++;
		}
	}
	cout << p1 << " " << p2 << endl;


}

Measured memory_bytes: 1212
#include<bits/stdc++.h>
using namespace std;
int main(){
  int d;
  while(cin>>d){
    int men=0;
    for(int j=d;j<600;j+=d)
      men+=d*(600-j)*(600-j);
    cout<<men<<endl;
  }
  return 0;
}

Measured memory_bytes: 3092
Q=[]
A=->*x{Q<<[?+,*x]*" "}
C=->*x{Q<<[?<,*x]*" "}

C[2,0,403]
0.upto(30){|i|
 A[403+i,403+i,404+i]
}

def to_b(x,s)
 31.downto(0){|i|
  A[403+i,s+33,61]
  C[x,61,s+i]
  C[s+i,403,61]
  i.times{A[61,61,61]}
  A[61,s+33,s+33]
 }
end

to_b(0,67)
to_b(1,195)

30.times{|i|
 30.times{|j|
  A[67+i,195+j,61]
  C[61,403,61]
  A[2+i+j,61,2+i+j]
 }
}

57.downto(0){|i|
 2.times{A[2+i,3+i,2+i]}
}

puts Q.size,Q

Measured memory_bytes: 14772
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(ll i=0;i<(n);i++)
template<typename T =ll> using v = vector<T>;
template<typename T =ll> using vv = v<v<ll>>;
template<typename T> T chmin(T &a,T b) {return a=min(a,b);}
const ll INF = (ll)1e9;

void d(){
    ll h,n;
    cin >> h >> n;
    auto a = v<>(n,0);
    auto b = v<>(n,0);

    rep(i,n) cin >> a[i] >> b[i];
    auto dp = vv<>(n+2,v<>(h+1,INF));
    dp[0][0]=0;

    rep(i,n)
        rep(j,h+1){
            chmin(dp[i+1][j],dp[i][j]);
            chmin(dp[i+1][min(h,j+a[i])],dp[i+1][j]+b[i]);
        }

    cout << dp[n][h];
}
int main(){
    d();
    return 0;
}

Measured memory_bytes: 78720
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int mod=1e9+7;
const int N=1e5+5;
int n,u,v;
vector<int>g[N];
int dst_u[N];
int dst_v[N];
bool vstd[N];
int main(){
	ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
	cin>>n>>u>>v;
	for(int i=0;i<n-1;i++){
		int a,b;cin>>a>>b;
		g[a].push_back(b);
		g[b].push_back(a);
	}
	for(int i=0;i<N;i++){dst_u[i]=1e9;dst_v[i]=1e9;}
	queue<int>q;
	q.push(u);dst_u[u]=0;
	while(q.size()){
		int node=q.front();
		q.pop();
		if(vstd[node])continue;
		vstd[node]=true;
		for(int s:g[node]){
			if(dst_u[s]>dst_u[node]+1){
				dst_u[s]=dst_u[node]+1;
				q.push(s);
			}
		}
	}
	memset(vstd,false,sizeof vstd);
	q.push(v);
	dst_v[v]=0;
	while(q.size()){
		int node=q.front();
		q.pop();
		if(vstd[node])continue;
		vstd[node]=true;
		for(int s:g[node]){
			if(dst_v[s]>dst_v[node]+1){
				dst_v[s]=dst_v[node]+1;
				q.push(s);
			}
		}
	}
	// for(int i=1;i<=n;i++){
	// 	cout<<dst_u[i]<<' '<<dst_v[i]<<endl;
	// }
	//u is takashi 
	//v is aoki
	int mx=0;
	for(int i=1;i<=n;i++){
		if(dst_u[i]>dst_v[i]){
			continue;
		}else{
			mx=max(dst_v[i],mx);
		}
	}
	cout<<mx-1<<endl;
	return 0;
}


Measured memory_bytes: 10108
#include <iostream>

using namespace std;

int main()
{
  int n; cin >> n;
  int sum;

  for (int i = 0; i < n; i++) {
    int l, r;
    cin >> l >> r;
    sum += (r - l) + 1;
  }

  cout << sum << endl;

  return 0;
}


Measured memory_bytes: 256
//#define NDEBUG
#include <algorithm>
#include <cstddef>
#include <cstdint>
#include <iostream>
#include <utility>
#include <vector>

namespace n91 {

using i8 = std::int_fast8_t;
using i32 = std::int_fast32_t;
using i64 = std::int_fast64_t;
using u8 = std::uint_fast8_t;
using u32 = std::uint_fast32_t;
using u64 = std::uint_fast64_t;
using isize = std::ptrdiff_t;
using usize = std::size_t;

struct rep {
  struct itr {
    usize i;
    constexpr itr(const usize i) noexcept : i(i) {}
    void operator++() noexcept { ++i; }
    constexpr usize operator*() const noexcept { return i; }
    constexpr bool operator!=(const itr x) const noexcept { return i != x.i; }
  };
  const itr f, l;
  constexpr rep(const usize f, const usize l) noexcept
      : f(std::min(f, l)), l(l) {}
  constexpr auto begin() const noexcept { return f; }
  constexpr auto end() const noexcept { return l; }
};
struct revrep {
  struct itr {
    usize i;
    constexpr itr(const usize i) noexcept : i(i) {}
    void operator++() noexcept { --i; }
    constexpr usize operator*() const noexcept { return i; }
    constexpr bool operator!=(const itr x) const noexcept { return i != x.i; }
  };
  const itr f, l;
  constexpr revrep(const usize f, const usize l) noexcept
      : f(l - 1), l(std::min(f, l) - 1) {}
  constexpr auto begin() const noexcept { return f; }
  constexpr auto end() const noexcept { return l; }
};
template <class T> auto md_vec(const usize n, const T &value) {
  return std::vector<T>(n, value);
}
template <class... Args> auto md_vec(const usize n, Args... args) {
  return std::vector<decltype(md_vec(args...))>(n, md_vec(args...));
}
template <class T> constexpr T difference(const T &a, const T &b) noexcept {
  if (a < b) {
    return b - a;
  } else {
    return a - b;
  }
}
template <class T> void chmin(T &a, const T &b) noexcept {
  if (b < a) {
    a = b;
  }
}
template <class T> void chmax(T &a, const T &b) noexcept {
  if (a < b) {
    a = b;
  }
}
template <class F> class fix_point : private F {
public:
  explicit constexpr fix_point(F &&f) : F(std::forward<F>(f)) {}

  template <class... Args>
  constexpr decltype(auto) operator()(Args &&... args) const {
    return F::operator()(*this, std::forward<Args>(args)...);
  }
};
template <class F> constexpr decltype(auto) make_fix(F &&f) {
  return fix_point<F>(std::forward<F>(f));
}
template <class T> T scan() {
  T ret;
  std::cin >> ret;
  return ret;
}

} // namespace n91

#include <algorithm>
#include <functional>
#include <iostream>
#include <queue>
#include <utility>
#include <vector>

namespace n91 {

void main_() {
  /*
  std::ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  //*/
  const u32 h = scan<u32>();
  const usize n = scan<usize>();
  u32 sum = 0;
  for (const usize i : rep(0, n)) {
    sum += scan<u32>();
  }
  std::cout << (sum >= h ? "Yes" : "No") << std::endl;
}

} // namespace n91

int main() {
  n91::main_();
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
using namespace std;
int main() {
	int n,k;
	string s;
	cin >> n >> k >> s;
	for (int i = 0; i < n; i++) {
		if (i + 1 == k) {
			s[i] += 32;
		}
	}
	cout << s << endl;
}

Measured memory_bytes: 256
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {

    static public final char[] n = new char[]{'M', 'A', 'R', 'C', 'H'};
    static public Map<Character, Integer> map = new HashMap<Character, Integer>();
    public static void main(String[] args) {
        for (int i = 0; i < 5; i++) map.put(n[i], 0);
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        for (int i = 0; i < N; i++) {
            char c = sc.next().toCharArray()[0];
            if(map.containsKey(c)) map.put(c, map.get(c) + 1);
        }
        long ans = 0;
        for (int i = 0; i < 3; i++) {
            if(map.get(n[i]) == 0) continue;
            for (int j = i + 1; j < 4; j++) {
                if(map.get(n[j]) == 0) continue;
                for (int k = j + 1; k < 5; k++) {
                    if(map.get(n[k]) == 0) continue;
                    ans += (long)map.get(n[i]) * map.get(n[j]) * map.get(n[k]);
                }
            }
        }

        System.out.println(ans);
        sc.close();
    }

}


Measured memory_bytes: 46188
#include<bits/stdc++.h>
#define rep(i, x) for(ll i = 0; i < x; i++)
#define all(a) (a).begin(),(a).end()
using ll = long long;
using ld = long double;
using namespace std;
const ll INF = 1000000000000000000;
const ll mod = 1000000007;
const ld pi = 3.141592653589793238;

ll x[1234567], y[1234567], m[12345][12345];
signed main() {
    while (true) {
	ll n, ans = 0; cin >> n;
	if(n==0){return 0;}
	rep(i, n) {
		cin >> x[i] >> y[i];
		x[i]++; y[i]++;
		m[x[i]][y[i]]++;
	}
	rep(h, n) {
		for (int i = h + 1; i < n; i++) {
			ll a = x[h] - x[i], b = y[h] - y[i];
			ll menseki = (abs(a) * abs(b) * 2) + pow(abs(abs(a) - abs(b)), 2);
			if (m[max((ll)0, x[h] - b)][max((ll)0, y[h] + a)] != 0 && m[max((ll)0, x[i] - b)][max((ll)0, y[i] + a)] != 0) {
				ans = max(ans, menseki);
			}
			if (m[max((ll)0, x[h] + b)][max((ll)0, y[h] - a)] != 0 && m[max((ll)0, x[i] + b)][max((ll)0, y[i] - a)] != 0) {
				ans = max(ans, menseki);
			}
		}
	}
	cout << ans << endl;
    }
	return 0;
}


Measured memory_bytes: 42360
#include<cstdio>
#include<iostream>
#include<string>
using namespace std;

struct Node{
    int key, pri;
    Node *left,*right;
} *root,*NIL;

Node* leftRotate(Node *t){
    Node *s = t->right;
    t->right = s->left;
    s->left = t;
    if( t == root ) root = s;
    return s;
}

Node* rightRotate(Node *t){
    Node *s = t->left;
    t->left = s->right;
    s->right = t;
    if( t == root ) root = s;
    return s;
}

void inorder(Node *t){
    if( t == NIL ) return;
    inorder(t->left);
    cout << " " << t->key;
    inorder(t->right);
}

void preorder(Node *t){
    if( t == NIL ) return;
    cout << " " << t->key;
    preorder(t->left);
    preorder(t->right);
}

Node* insert(Node* t, int key, int pri){
    if( t == NIL ){
        Node *u = new Node();
        u->key = key;
        u->pri = pri;
        u->left = u->right = NIL;
        return u;
    }
    if( key == t->key ) return t;
    else if( key < t->key ){
        t->left = insert(t->left,key,pri);
        if(t->pri < t->left->pri)
            t = rightRotate(t);
    }
    else if( key > t->key ){
        t->right = insert(t->right,key,pri);
        if(t->pri < t->right->pri)
            t = leftRotate(t);
    }
    return t;
}

Node* find(Node* t,int key){
    if( t == NIL ) return NIL;
    if( key == t->key ) return t;
    else if( key < t->key ) return find(t->left,key);
    else return find(t->right,key);
}

Node* _delete(Node *t,int key);

Node* nodeDelete( Node* t,int key){
    if( t == NIL ) return NIL;
    if( key < t->key ) t->left = nodeDelete(t->left,key);
    else if( key > t->key ) t->right = nodeDelete(t->right,key);
    else return _delete(t,key);
    return t;
}

Node* _delete(Node* t,int key){
    if( t->left == NIL && t->right ==NIL ) return NIL;
    else if( t->right == NIL ){
        t = rightRotate(t);
    }
    else if( t->left == NIL ){
        t = leftRotate(t);
    }
    else {
        if( t->left->pri > t->right->pri ){
            t = rightRotate(t);
        }
        else t = leftRotate(t);
    }
    return nodeDelete(t,key);
}

int main(){
    int i,n,j,k,p;
    string s;

    NIL = new Node();
    NIL->left = NIL->right =NIL;
    root = NIL;

    cin >> n;
    while(n--){
        cin >> s;
        if( s == "insert" ){
            cin >> k >> p;
            Node* t = insert(root,k,p);
            if( root == NIL ) root = t;
        }
        else if( s == "find" ){
            cin >> k;
            if( find(root,k) != NIL ) cout << "yes" << endl;
            else cout << "no" << endl;
        }
        else if( s == "delete" ){
            cin >> k;
            nodeDelete(root,k);
        }
        else if( s == "print" ){
            inorder(root);
            cout << endl;
            preorder(root);
            cout <<endl;
        }
    }
}



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

using ll=int64_t;

int main(){
  ll x; cin >>x;
  ll ans=0;
  ans=x/11*2;
  if (x%11<=6 && x%11!=0) ans+=1;
  else if (6<x%11) ans+=2;
  cout <<ans <<endl;
}


Measured memory_bytes: 256
A, B, C, D, E, F = map(int, input().split())
c = []
ans_list = []

for i in range(1, F // (100 * A) + 1):
    for j in range(F // (100 * B) + 1):
        a = 100 * A * i + 100 * B * j
        if a > F:
            break
        for k in range((F - a) // C + 1):
            for l in range((F - a) // D + 1):
                b = k * C + l * D
                if (A * i + B * j) * E >= b and a + b <= F:
                    c.append(100 * b / (a + b))
                    ans_list.append([a + b, b])
                else:
                    break

ans = ans_list[c.index(max(c))]

print(' '.join(map(str, ans)))


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

#define REP(i, x, n) for (int i = x; i < (int)(n); i++)
#define rep(i, n) REP(i, 0, x);
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

using namespace std;

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

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

int main(void)
{
    int r, g, b;
    cin >> r >> g >> b;
    (((r * 100 + g * 10 + b) % 4 == 0) ? (cout << "YES" << endl) : (cout << "NO" << endl));
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<array>
#include<string>
#include<numeric>
#include<set>
#include<unordered_map>
typedef long long ll;
using namespace std;
int main()
{
    int x;
    for(int i=1; i<=5; i++){
        cin>>x;
        if(x==0){
            cout<<i<<"\n";
            return 0;
        }
    }
    return 0;
}


Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,m;
  cin>>n>>m;
  for(int i=m/n;i>=1;i--){
    int temp=m-(n-1)*i;
    if(temp%i==0){
      cout<<i<<endl;
      return(0);
    }
  }
  return(0);
}


Measured memory_bytes: 256
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define SORT(a) sort(a.begin(), a.end())
#define SORTD(a) sort(a.rbegin(), a.rend());
#define UNIQUE(a) unique(a.begin(), a.end())
#define ll long long
#define INF 1000000000000000000
#define INT_MAX 2147483647

#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <cctype>
#include <numeric>
#include <algorithm>
#include <queue>
#include <set>
#include <utility>
#include <ios>
#include <iomanip>
#include <sstream>

using namespace std;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;

const ll mod = 1e9 + 7;

int main() {
	double a,p;
	cin >> a >> p;
	cout << floor((a * 3 + p) / 2) << endl;
}


Measured memory_bytes: 256