akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>

using namespace std;

bool a[500001];


int main(){
	vector<int> p;
	p.push_back(6);
	for(int i=1;i<=50000;i++){
		a[6*i]=1;
	}
	for(int i=1;7*i+1<=300000;i++){
		if(a[7*i+1]==0){
			p.push_back(7*i+1);
			for(int j=7*i+1;j<=300000;j+=7*i+1){
				a[j]=1;
			}
		}
		if(a[7*i+6]==0){
			p.push_back(7*i+6);
			for(int j=7*i+6;j<=300000;j+=7*i+6){
				a[j]=1;
			}
		}
	}
	int n;
	while(cin >> n &&n!=1){
		vector<int>v;
		for(int i=0;i<p.size();i++){
			if(n%p[i]==0){
				v.push_back(p[i]);
			}
		}
		cout << n << ":";
		for(int i=0;i<v.size();i++){
			cout << " " << v[i];
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 3460
#include <iostream>
#include <cstring>
#include <vector>
#include <cstdio>
#include <stack>
#include<queue>

using std::vector;

int main()
{
    int n,q,ope,t,x;
    std::cin>>n>>q;
    std::queue<int> S[n];

    for(int i = 0; i < q; i++)
    {
        std::cin>>ope>>t;
        if(ope==0){std::cin>>x;S[t].push(x);}
        else if(ope==1){if(!S[t].empty()){std::cout<<S[t].front()<<std::endl;}}
        else{if (!S[t].empty()) S[t].pop();}
    }

    return 0;
}



Measured memory_bytes: 4456
class Solver:

    def __init__(self):
        pass


    def solve(self, s):
        one = 0
        zero = 0
        for ch in s:
            if ch == '1':
                one += 1
            else:
                zero += 1
        return len(s) - abs(one-zero)


if __name__ == '__main__':

    solver = Solver()
    s = input()
    n = solver.solve(s)
    print(n)


Measured memory_bytes: 3188
N = int(input())
a = list(map(int, input().split()))
dp = [0] + [10**10]*N
for i,h in enumerate(a):
    for j in range(i+1,min(i+3,N)):
        dp[j] = min(dp[j],dp[i]+abs(h-a[j]))
    #print(dp)
print(dp[N-1])

Measured memory_bytes: 13924
import sys 
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

N,W = map(int, readline().split())
w=[];v=[]
for _ in range(N):
  a,b = map(int, readline().split())
  w.append(a)
  v.append(b)
dp = [[0 for _ in range(W+1)] for _ in range(N+1)]
for i in range(N):
  for j in range(W+1):
    if j >= w[i]:
      dp[i+1][j] = max(dp[i][j],dp[i][j-w[i]]+v[i])
    else:
      dp[i+1][j] = dp[i][j]
print(dp[N][W])

Measured memory_bytes: 171400
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
const long long MOD = 2;

void solve(long long N, std::vector<long long> a){
    vector<ll> ans;
    vector<int> hasBall(N,0);
    for(int i=N-1;i>=0;--i){
        ll num = i+1;
        ll t =2;
        ll sum =a[i];
        while(num*t<=N){
            sum += hasBall[num*t-1];
            ++t;
        }
        if(sum%2==1){
            hasBall[i] =1;
            ans.push_back(num);
        }
    }
    cout << ans.size() <<endl;
    sort(ans.begin(),ans.end());
    for(ll num:ans){
        cout << num << endl;
    }
}

// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<long long> a(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&a[i]);
    }
    solve(N, std::move(a));
    return 0;
}


Measured memory_bytes: 4340
#include<iostream>
#include<iomanip>
#include<cmath>

int main(){
  double a, b, C, S, L, h, CRadian;
  using namespace std;

  cin >> a >> b >> C;
  CRadian = C * acos(-1) / 180;
  S = 0.5 * a * b * sin(CRadian);
  L = sqrt(pow(a, 2) + pow(b, 2) - 2 * a * b * cos(CRadian)) + a + b;
  h = 2 * S / a;

  cout << fixed << setprecision(5) << S << endl << L << endl << h << endl;
}

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

int main() {
    ll n, m; cin >> n >> m;
    vector<ll> A(n); rep(i, n) cin >> A[i];
    sort(A.begin(), A.end());
    vector<P> CB(m); 
    rep(i, m) {
        ll b, c; cin >> b >> c;
        CB[i] = P(c, b);
    }
    sort(CB.begin(), CB.end());
    reverse(CB.begin(), CB.end());
    int changed = 0;
    rep(i, m) {
        while (CB[i].first>A[changed] && CB[i].second>0 && changed<n) {
            A[changed] = CB[i].first;
            changed++;
            CB[i].second--;
        }
        if (CB[i].second>0) {
            break;
        }
    }
    ll ans = 0;
    rep(i, n) ans += A[i];
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 2560
/*


               BASIC TEMPLATES


*/
//#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops")
//#pragma GCC target("avx,avx2")

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

//#
//#  #
//#   #
//#    #
//#   # #
//#  #   ###
//#
#define ll long long
#define pb push_back
#define emb emplace_back
#define ff first
#define ss second
#define FAST cin.tie(0); ios_base::sync_with_stdio (false)
#define pii pair<int,int>
#define TEN6 1000000
#define TEN5 100000
#define TEN4 10000
#define TEN9 1000000000
#define ipv pair<ll,vector<ll> >
#define pll pair<ll,ll>
#define CASE(x) "Case "<<x<<": "
#define _endl "\n"


#define for_r(i,st,lim) for(ll i=st-1;i>=lim;i--)
#define fRead(x) freopen(x,"r",stdin)
#define fWrite(x) freopen (x,"w",stdout)
#define all_set(arr,val) memset(arr,val,sizeof(arr))
#define all(x) x.begin(),x.end()
#define for_(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

//lower_bound returns an iterator pointing to the first element in the range [first,last) which has a value not less than ‘val’.

//upper_bound returns an iterator pointing to the first element in the range [first,last) which has a value greater than ‘val’.
using namespace __gnu_pbds;
#define ordered_set tree<ll , null_type,less<ll  >, rb_tree_tag,tree_order_statistics_node_update>

#define MOD 998244353 ///////<<<<<<<<<<<<<<<<<<=====MOD value change here!!!!!
#define INF 5e18
#define what_is(x) cerr << #x << " is " << x << endl;

ll BMod(ll B,ll P,ll M)
{
    ll R=1;
    B=B%M;
    while(P)
    {
        if(P&1)
            R=(R*B)%M;
        P >>= 1;
        B=(B*B)%M;
    }
    return R;
}

ll invMOD(ll num,ll M)
{
    return BMod(num,M-2,M);
}


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

}



ll lcm(ll a,ll b)
{
    return a*b / gcd(a,b);
}
ll my_abs(ll x)
{
    if(x<0)x*=-1;
    return x;
}
int main()
{
    //
    // FAST;
    ll n,k;
    cin>>n>>k;
    ll arr[n+10];
    for_(i,0,n)
    {
        cin>>arr[i];

    }
    ll dp[n+10];
    all_set(dp,0);
    dp[n-2]=my_abs(arr[n-1]-arr[n-2]);
    for_(i,n-2,0)
    {
        //dp[i]=min(dp[i+1]+my_abs(arr[i]-arr[i+1]),dp[i+2]+my_abs(arr[i]-arr[i+2]));
        ll mn=INF;
        for_(j,1,k+1)
        {
            if(i+j>=n)break;
            mn=min(mn,dp[i+j]+my_abs(arr[i]-arr[i+j]));
        }
        dp[i]=mn;
    }
    cout<<dp[0]<<_endl;


}

















Measured memory_bytes: 1792
n, x = [int(x) for x in input().split()]
a = list(map(int,input().split())) 
answer=0
if a[0]>x:
  answer+=(a[0]-x)
  a[0]=x
  #print(a[0])
for i in range(n-1):
  tmp=max(0,a[i]+a[i+1]-x)
  answer+=tmp
  a[i+1]-=tmp
print(answer)

Measured memory_bytes: 14132
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define int long long
using namespace std;
typedef pair<int, int> P;

string s1, s2;

string addString(string s, string t){
    if(s.size() < t.size()) swap(s, t);
    char tmp;
    for(int i = s.size() - 1, j = t.size() - 1; i >= 0; i--, j--){
        if(j >= 0) s[i] += t[j] - '0';
        if(s[i] > '9'){
            s[i] -= 10;
            if(i == 0) s = '1' + s;
            else s[i - 1]++;
        }
    }
    return s;
}

signed main(){
    int n;
    cin >> n;
    rep(i, 0, n){
        cin >> s1 >> s2;
        string ans = addString(s1, s2);
        if(ans.size() > 80) cout << "overflow" << endl;
        else cout << ans << endl;
    }
}

Measured memory_bytes: 3204
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using Pair = System.Collections.Generic.KeyValuePair<int, int>;

//Ford-Fulkerson O(F*|E|)
class Program
{
    static void Main()
    {
        var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
        Console.SetOut(sw);
        new Program().solve();
        Console.Out.Flush();
    }
    Scanner cin = new Scanner();

    class Edge
    {
        public int to, cap, rev;
        public Edge(int to, int cap, int rev)
        {
            this.to = to;
            this.cap = cap;
            this.rev = rev;
        }
    }

    bool[] used;
    List<Edge>[] G;
    int V, E;
    void solve()
    {
        V = cin.nextint;
        E = cin.nextint;

        G = Enumerable.Range(0, V).Select(i => new List<Edge>()).ToArray();
        

        for (int i = 0; i < E; i++)
        {
            var u = cin.scanint;
            G[u[0]].Add(new Edge(u[1], u[2], G[u[1]].Count));
            G[u[1]].Add(new Edge(u[0], 0, G[u[0]].Count - 1));
        }

        int flow = 0;
        while (true)
        {
            used = new bool[V];
            int f = dfs(0, V - 1, int.MaxValue);
            if (f == 0) break;
            flow += f;
        }
        Console.WriteLine(flow);
    }

    int dfs(int v, int t, int f)
    {
        if (v == t) return f;
        used[v] = true;
        for (int i = 0; i < G[v].Count; i++)
        {
            var e = G[v][i];
            if (used[e.to] || e.cap == 0) continue;
            int d = dfs(e.to, t, Math.Min(f, e.cap));
            if (d > 0)
            {
                e.cap -= d;
                G[e.to][e.rev].cap += d;
                return d;
            }         
        }
        return 0;
    }
}

class Scanner
{
    string[] s; int i;
    char[] cs = new char[] { ' ' };
    public Scanner() { s = new string[0]; i = 0; }
    public string[] scan { get { return Console.ReadLine().Split(); } }
    public int[] scanint { get { return Array.ConvertAll(scan, int.Parse); } }
    public long[] scanlong { get { return Array.ConvertAll(scan, long.Parse); } }
    public double[] scandouble { get { return Array.ConvertAll(scan, double.Parse); } }
    public string next
    {
        get
        {
            if (i < s.Length) return s[i++];
            string st = Console.ReadLine();
            while (st == "") st = Console.ReadLine();
            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            i = 0;
            return next;
        }
    }
    public int nextint { get { return int.Parse(next); } }
    public long nextlong { get { return long.Parse(next); } }
    public double nextdouble { get { return double.Parse(next); } }
}

Measured memory_bytes: 9844
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <numeric>
#include <utility>
#include <limits>
#include <ctime>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cassert>
#include <unordered_map>
#include <unordered_set>

using namespace std;

typedef long long lli;
typedef long double ld;
typedef pair<lli, lli > plli;
typedef vector<lli> vlli;
typedef vector<plli > vplli;

#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);
#define lcm(a, b) ((a * b) / gcd(a, b))
#define sqr(x) (x)*(x)
#define all(a) a.begin(),a.end()
#define UN(v) sort(all(v)), v.resize(unique(all(v))-v.begin())

#define endl '\n'

const long long INF = 100000000000000000;
const long long MOD = 1000000007;
const long long MAXN = 100005;

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

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

void solve() {
    lli n;
    cin >> n;
    lli ans = INF;
    for (lli i = 1; i * i <= n; ++i) {

        if (n % i == 0) {
            ans = min(ans, (i - 1) + (n / i - 1));
        }
        if (n % (n / i) == 0) {
            lli j = n / i;
            ans = min(ans, (j - 1) + (n / j - 1));
        }
    }
    cout << ans << endl;
}

int main()
{
    IOS;
    //comment it out
    //freopen("input.txt", "r", stdin);
    lli t = 1;
    //cin >> t;
    while (t--) {
        solve();
    }
    return 0;
}


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

#define ll long long int

#define pi 2*acos(0.0)
#define mod 1000000007

#define fast   ios_base::sync_with_stdio(false);cin.tie(NULL);

#define pii pair<ll,ll>

#define pb push_back

#define Bit_off(val,pos)       (val & (~(1<<pos)))
#define Bit_on(val,pos)        (val | (1<<pos))
#define Bit_toggle(val,pos)    (val ^ (1<<pos))
#define Bit_check(val,pos)     (bool)(val & (1<<pos))
#define odd_even(val)          (bool)(val & 1)
#define koita_1_ase(val)       (__builtin_popcount(val))

//ll Big_Mod(ll v1, ll p, ll md)  { ll res=1; v1=v1%md; while (p > 0){if (p & 1)res = (res * v1) % md; p =p>>1; v1 = (v1 * v1) % md;}return res;}
ll ar[500009],br[500009],cr[500009],tr[500009];
map<ll,ll>mp;
vector<ll>v;
string s;

struct evan
{
    ll l,r,pos;
}st[500009];
bool com(evan i1,evan i2)
{
    return (i1.r < i2.r);
}

int main()
{
    ll a,b,c,d,e,i,j,k,x,y,z,f,g,h,n,m;
    char ch;
    cin>>a>>b;
    for(i=0;i<a;i++)
    {
        cin>>ar[i];
    }
    sort(ar,ar+a);
    k=0;
    for(i=0;i<b;i++)
    {
        k+=ar[i];
    }
    cout<<k<<endl;
}






Measured memory_bytes: 3652
n = int(input())
li = []
for _ in range(n):
    a, b = list(map(int, input().split()))
    li.append([a, b])

li2 = sorted(li, key=lambda x: (x[0] + x[1]), reverse=True)
v = 0
for i, (a, b) in enumerate(li2):
    if i % 2 == 0:
        v += a
    else:
        v -= b

print(v)

Measured memory_bytes: 25640
import itertools


def triple(iterable):
    a, b, c = itertools.tee(iterable, 3)
    next(b, None), next(c, None), next(c, None)
    return zip(a, b, c)


n = int(input())
P = list(map(int, input().split()))

ans = 0
for x, y, z in triple(P):
    sorted_tuple = sorted([x, y, z])
    if sorted_tuple[1] == y:
        ans += 1
print(ans)


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

int main() {
    int N;
    cin >> N;
    vector<string>s(N);
    for (int i = 0; i < N; ++i) {
        cin >> s[i];
        s[i] = s[i] + s[i];
    }

    ll ans = 0;
    for (int i = 0; i < N; ++i) {
        int flag = 1;
        for (int j = 1; j < N; ++j) {
            for (int k = 0; k < j; ++k) {
                if(s[k][i+j] != s[j][i+k]) flag = 0;
            }
        }
        ans += flag;
    }
    ans *= N;
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 512
///A drunk man will find his way home, but a drunk bird may get lost forever...
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define f first
#define s second
#define int long long
#define sz(x) (int)x.size()
int a[1000 * 100 + 5];
int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
	int a, b, c;
	cin >> a >> b >> c;
	for(int i = 0; i < 1e6; i++){
		if(a % 2 || b % 2 || c % 2){
			cout << i << endl;
			return 0;
		}
		int ap = (b + c) / 2, bp = (a + c) / 2, cp = (b + a) / 2;
		a = ap, b = bp, c = cp;
	}
	cout << -1 << endl;
	return 0;
}


Measured memory_bytes: 256
import java.util.*

val sc = Scanner(System.`in`)
val N = sc.nextInt()
val L = arrayOf(2L, 1L)

fun main(args: Array<String>) {
    for (i in 2..N) {
        L[i % 2] = L.sum()
    }
    println(L[N % 2])
}


Measured memory_bytes: 35796
#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>;



int main() {
    int D, G, p, c;
    cin >> D >> G;
    vector<tuple<int,int,int>> point(D);
    rep(i,D) {
        cin >> p >> c;
        point.at(i) = make_tuple(p, c, (i+1)*100);
    }
    reverse(point.begin(), point.end());
    int ans = INFINITY;
    for (int bit = 0; bit < (1<<D); ++bit) {
        int cnt = 0;
        int sum = 0;
        for (int i = 0; i < D; ++i) {
            if (bit & (1<<i)) {
                sum += get<0>(point.at(i)) * get<2>(point.at(i)) + get<1>(point.at(i));
                cnt += get<0>(point.at(i));
            }
        }
        if (sum < G) {
            bool ok = false;
            for (int i = 0; i < D; ++i) {
                if ((bit & (1<<i)) == 0) {
                    if ((G - sum) / get<2>(point.at(i)) < get<0>(point.at(i))) {
                        cnt += (G - sum - 1) / get<2>(point.at(i)) + 1;
                        ok = true;
                        break;
                    }
                }
            }
            if (!ok) continue;
        }
        ans = min(ans, cnt);
    }
    cout << ans << endl;
}



Measured memory_bytes: 3528
#include<stdio.h>
int main(void)
{
	int i,n,x,array[100],need=0;
	scanf("%d",&n);
	scanf("%d",&x);
	for(i=0;i<n;i++)
	{
		scanf("%d",&array[i]);
		need=need+array[i];
	}
	x=x-need;
	for(i=0;i<n;i++)
	{
		if(array[0]>array[i]) array[0]=array[i];
	}
	int count=n,f=0;
	while(f==0)
	{if(x-array[0]>0) count++;
	if(x-array[0]>0) x=x-array[0];
        if(x-array[0]==0) count++;
	 if(x-array[0]==0) f=1;
	 if(x-array[0]<0) f=1;
	}
	printf("%d",count);
	return 0;
}


Measured memory_bytes: 128
#include <cstdio>
#include <iostream>

using namespace std;

template<class T> void ReadInteger(T & x) {
    x = 0;
    int f = 1, ch = getchar();
    while(ch < '0' || ch > '9') {
        if(ch == '-') f = -1;
        ch = getchar();
    }
    while(ch >= '0' && ch <= '9') {
        x = x * 10 - '0' + ch;
        ch = getchar();
    }
    x *= f;
}

int N, A[200050];

void Solve() {
    long long ans = 0;
    int now = N;
    while(now > 0) {
        if(A[now] >= now || (now != N && A[now] < A[now + 1] - 1)) {
            puts("-1");
            return;
        }
        ans += A[now];
        while(now > 0 && A[now - 1] == A[now] - 1) now--;
        now--;
    }
    cout << ans << endl;
}
int main() {
    ReadInteger(N);
    for(int i = 1; i <= N; i++) {
        ReadInteger(A[i]);
    }
    Solve();
    return 0;
}


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

using namespace std;

typedef long long ll;

ll extgcd(ll a, ll b, ll &x, ll &y) {
    ll d = a;
    if (b != 0) {
        d = extgcd(b, a%b, y, x);
        y -= (a/b) * x;
    } else {
        x = 1; y = 0;
    }
    return d;
}

ll modinv(ll a, ll m) {
    ll x, y;
    extgcd(a, m, x, y);
    return (m + x % m) % m;
}

ll mod_comb(ll n, ll r, ll mod) {
    ll ans_mul = 1, ans_div = 1;

    for (int i = 0; i < r; i++) {
        ans_mul *= (n-i);
        ans_div *= (i+1);
        ans_mul %= mod;
        ans_div %= mod;
    }
    return ans_mul * modinv(ans_div, mod) % mod;
}

int main() {
  const ll mod = 1000000007;
  int n, k;
  cin >> n >> k;

  for (int i = 1; i <= k; i++) {
    ll a = mod_comb(k-1, i-1, mod) % mod;
    ll b = mod_comb(n-k+1, i, mod) % mod;
    cout << a * b % mod << endl;
  }

  return 0;
}

Measured memory_bytes: 256
#include <iostream> 
#include <algorithm>
using namespace std;
int main(){
    bool check = true;
    int n;
    int arr[100005];
    long long color=1, yeah[100005];
    cin >>n;
    for(int i=1; i<=n; i++){
        cin >> arr[i];
    }
    yeah[0]=0;
    sort(arr+1, arr+1+n);
    for(int i=1; i<=n; i++){
       yeah[i]=arr[i]+yeah[i-1];
    }
    for(int i=n-1; i>=1; i--){
        if(yeah[i]*2>=arr[i+1] && check == true){
            color++;
        }
        else{
            check=false;
        }
    }
    cout << color << endl;
    return 0;
}

Measured memory_bytes: 4784
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cctype>
#include <iostream>
#include <algorithm>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <vector>
#include <utility>
#include <string>
using namespace std;

const int qq = 1e2 + 10;
int num[qq];
int gra[qq][qq];
int vis[qq];
int n, m, k, sum;

void dfs(int rt, int cnt){
	if(cnt == n){
		sum++;
		return;
	}
	for(int i = 1; i <= n; ++i)
		if(i != rt && gra[rt][i] && !vis[i]){
			vis[i] = 1;
			dfs(i, cnt + 1);
			vis[i] = 0;
		}
}

int main(){
	scanf("%d%d", &n, &m);
	memset(gra, 0, sizeof(gra));
	for(int i = 0; i < m; ++i){
		int a, b;scanf("%d%d", &a, &b);
		gra[a][b] = gra[b][a] = 1;
	}
	sum = 0;
	memset(vis, 0, sizeof(vis));
	vis[1] = 1;
	dfs(1, 1);
	printf("%d\n", sum);
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <array>
#include <vector>
#include <iomanip>
#include <string>
#include <cmath>
#include <algorithm>
#include <queue>
#include <map>
#include <set>
using namespace std;

typedef  pair<int,int> P;
typedef long long LL;

const LL  INF=1<<31;
const LL MOD=1000000007;



int main(){
     int n,m;
     cin>>n>>m;
     int sowa=n*(1+n)/2;
     int p[50][50]={0};
     for(int i=0;i<m;++i){
          int a,b;
          cin>>a>>b;
          p[a][b]=1;
          p[b][a]=1;
     }
     int ans=0;
     vector<int> v(n);
     for(int i=0;i<n;++i){
          v[i]=i+1;
     }
     do{
          int all=1;
          for(int i=0;i<n-1;++i){
               if(p[v[i]][v[i+1]])all+=v[i+1];
          }
          if(all==sowa)ans++;
     }while(next_permutation(v.begin()+1,v.end()));
     
     cout<<ans<<endl;
}

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

int main() {
  int N;
  cin >> N;
  int count = 0;
  int D;
  vector<int> diam(N);
  for (int i = 0; i < N; i++) {
    cin >> diam.at(i);
  }
  
  sort(diam.begin(),diam.end());
  
  for (int i = 0; i < N; i++) {
    if (i == 0) {
      count++;
      D = diam.at(i);
    }
    else {
      if (D < diam.at(i)) {
        count++;
        D = diam.at(i);
      }
    }
  }
  
  cout << count << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <utility>
#include <tuple>
#include <algorithm>
#include <cstdio>
#include <cmath>
using namespace std;

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

int N;
vector<vector<int>> to;

int dfs(int n, vector<bool> visited) {
  visited[n] = true;
  bool fin=true;
  for(int i=0; i<visited.size(); i++) {
    if(!visited[i]) {
      fin = false;
      break;
    }
  }
  if(fin)
    return 1;
  int ret=0;
  for(int i=0; i<to[n].size(); i++) {
    if(!visited[to[n][i]])
      ret += dfs(to[n][i], visited);
  }
  return ret;
}

int main() {
  int M;
  cin >> N >> M;
  vector<int> a(M), b(M);
  rep(i, M) {
    cin >> a[i] >> b[i];
    a[i]--;
    b[i]--;
  }
  to = vector<vector<int>>(N);
  rep(i, M) {
    to[a[i]].push_back(b[i]);
    to[b[i]].push_back(a[i]);
  }
  vector<bool> v(N, false);
  cout << dfs(0, v) << endl;
  return 0;
}

Measured memory_bytes: 256
use std::collections::VecDeque;
use std::io;
use std::io::prelude::*;

struct Window<'a, T: 'a> {
    d: VecDeque<T>,
    a: &'a [T],
    i: usize,
    j: usize,
}

impl<'a, T: Ord + Copy> Window<'a, T> {
    fn new(a: &[T]) -> Window<T> {
        Window {
            d: VecDeque::new(),
            a,
            i: 0,
            j: 0,
        }
    }

    fn advance_back(&mut self) {
        let x = self.a[self.j];
        while let Some(y) = self.d.pop_back() {
            if y <= x {
                self.d.push_back(y);
                break;
            }
        }
        self.d.push_back(x);
        self.j += 1;
    }

    fn advance_front(&mut self) {
        if self.d.front().map(|x| *x == self.a[self.i]) == Some(true) {
            self.d.pop_front();
        }
        self.i += 1;
    }

    fn get_min(&self) -> Option<T> {
        self.d.front().cloned()
    }
}

fn main() {
    let mut stdin = io::stdin();
    let mut buf = String::new();
    let _ = stdin.read_to_string(&mut buf);
    let mut iter = buf.split_whitespace();

    let n: usize = iter.next().unwrap().parse().unwrap();
    let l: usize = iter.next().unwrap().parse().unwrap();
    let a: Vec<u32> = iter.map(|nstr| nstr.parse().unwrap()).collect();

    let mut w = Window::new(&a[..]);

    for _ in 0..l {
        w.advance_back();
    }
    print!("{}", w.get_min().unwrap());
    while w.j < n {
        w.advance_back();
        w.advance_front();
        print!(" {}", w.get_min().unwrap());
    }
    println!("");
}



Measured memory_bytes: 20356
#include <bits/stdc++.h>
const double PI = acos(-1);
#define rep(i, n) for (int i = 0; i < (int)(n); i++ )
using namespace std;
int findSumOfDigits(int n) {
  int sum = 0;
  while (n > 0) { // n が 0 になるまで
    sum += n % 10;
    n /= 10;
  }
  return sum;
}
int main(){
  long long x;
  cin >> x;
  long long ans500;
  long long ans5;
  ans500 = x/500;
  x %= 500;
  ans5 = x/5;
  long long ans = 1000*ans500 + 5*ans5;
  cout << ans << endl;
}

Measured memory_bytes: 3636
#include <cstdio>
#include <iostream>
#include <vector>
#define debug(...) fprintf(stderr,__VA_ARGS__)
using namespace std;
inline char gc() {
//	return getchar();
	static char buf[100000],*l=buf,*r=buf;
	return l==r&&(r=(l=buf)+fread(buf,1,100000,stdin),l==r)?EOF:*l++;
}
template<class T> void rd(T &x) {
	scanf("%d",&x); return;
	x=0; int f=1,ch=gc();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=gc();}
	while(ch>='0'&&ch<='9'){x=x*10-'0'+ch;ch=gc();}
	x*=f;
}
template<class T> inline bool Cmax(T &x,T y) {return x<y?x=y,1:0;} 
typedef long long ll;
int T,A,X,B,Y,C,D;
vector<int> pos,cnt;
int gcd(int a,int b) {return b==0?a:gcd(b,a%b);}
int exgcd(int a,int b,int &x,int &y) {
	if(b==0) {x=1,y=0; return a;}
	int d=exgcd(b,a%b,y,x);
	y-=a/b*x;
	return d;
}
inline int inver(int a,int mod) {
	int x,y,d=exgcd(a,mod,x,y);
	if(x<0) x+=mod;
	return x;
}
inline ll lowdiv(ll a,ll b) {return a/b-(a%b&&(a^b)<0);}
void init() {
	int d=gcd(A,B);
	A/=d,B/=d,C/=gcd(d,C);
	for(int _=0;_<2;++_) {
		d=gcd(A,C);
		C/=d,A/=d;
		int t=gcd(B,d);
		B/=t,Y/=d/t;
		swap(A,B),swap(X,Y);
	}
}
void getpos() {
	pos.clear(),cnt.clear();
	int W=C,H=D,now=0,r=inver(D,C);
	while(W) {
		int d=W/H;
		pos.push_back((ll)now*r%C),cnt.push_back(d); 
		now+=d*H;
		W%=H; if(W==0) break;
		H%=W; if(H==0) H=W;
	}
	pos.push_back(C);
}
inline int gety(int x) {return x==0?C:(C-(ll)x*D%C)%C;}
int main() {
//	freopen("1.in","r",stdin);
//	freopen("1.out","w",stdout);
	rd(T);
	for(int kase=1;kase<=T;++kase) {
		rd(A),rd(X),rd(B),rd(Y),rd(C);
		init();
		if(C==1) {printf("%d\n",X+Y); continue;}
		D=(ll)A*inver(B,C)%C;
		getpos();
		int an=0;
		for(int i=0;i<cnt.size();++i) {
			int xl=pos[i],xr=pos[i+1],yl=gety(xl),yr=gety(xr);
			int dx=(xr-xl)/cnt[i],dy=(yl-yr)/cnt[i];
			int l=0,r=X+Y,re=-1;
			while(l<=r) {
				int mid=((ll)l+r)>>1;
				ll p=lowdiv(X-(ll)xl*mid,dx),q=lowdiv(Y-(ll)yr*mid,dy);
				if(p>=0&&q>=0&&p+q>=(ll)cnt[i]*mid) re=mid,l=mid+1;
				else r=mid-1;
			}
			Cmax(an,re);
		}
		printf("%d\n",an);
	}
	return 0;
} 


Measured memory_bytes: 3764
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;

typedef long long ll;

const ll M = 1e9+7;

ll n, m, k, ans;
ll fact[220000];

ll mpow(ll a, ll n) {
  if (n == 0) return 1;
  if (n % 2) return mpow(a, n-1) * a % M;
  return mpow(a * a % M, n/2);
}

ll cmb(ll n, ll r) {
  return fact[n] * mpow(fact[r], M-2) % M * mpow(fact[n-r], M-2) % M;
}

int main() {
  cin >> n >> m >> k;
  
  fact[0] = 1;
  for (ll i = 1; i <= 220000; ++i) {
    fact[i] = fact[i-1] * i % M;
  }
  
  ans = 0;
  for (ll i = 1; i <= n-1; i++) {
    ans += i * (n-i) * m % M * m % M * cmb(n*m-2, k-2) % M;
    ans %= M;
  }
  
  for (ll i = 1; i <= m-1; i++) {
    ans += i * (m-i) * n % M * n % M * cmb(n*m-2, k-2) % M;
    ans %= M;
  }
  
  ans %= M;
  
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1920
//????????¬??°???????????°??????1?????´???(??¨?????¨?????´???)
#include <bits/stdc++.h>
#define ll long long
#define INF 999999999
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<n;i++)

using namespace std;

typedef pair<int,int>P;

const int MAX_N = 100000;
vector<P> G[MAX_N];	//????????? ??????
int d[MAX_N]; //?????¢
bool visited[MAX_N];

void dfs(int v)
{
	visited[v] = true;
	rep(i,G[v].size()){
		if(!visited[G[v][i].first]){
			d[G[v][i].first] = d[v] + G[v][i].second;
			dfs(G[v][i].first);
		}
	}
}

int main()
{
	int n,max0=0,maxd,maxx=0;
	scanf("%d",&n);
	fill(d,d+n,INF);
	fill(visited,visited+n,false);
	rep(i,n){
		int x,y,z;
		scanf("%d %d %d",&x,&y,&z);
		G[x].push_back(make_pair(y,z));
		G[y].push_back(make_pair(x,z));
	}
	d[0] = 0;
	dfs(0);
	rep(i,n){
		if(max0 < d[i]){
			max0 = d[i];
			maxd = i;
		}
	}
	fill(d,d+n,INF);
	fill(visited,visited+n,false);
	d[maxd] = 0;
	dfs(maxd);
	rep(i,n){
		maxx = max(maxx,d[i]);
	}
	cout << maxx << "\n";
}

Measured memory_bytes: 12204
#include <stdio.h>
#include <cstdio>
#include <iostream>
#include <queue>
#include <set>
#include <vector>
#include <cstring>
#include <algorithm>

int main(){
  
  std::vector<long long int> prod_list(101);
  for(long long int i = 1; i <= 100; i++){
    prod_list[i] = 0;
  }
  
  for(long long int i = 1; i < 10; i++){
    for(long long int j = i; j < 10; j++){
      prod_list[i*j] = 1;
    }
  }
  
  long long int N;
  scanf("%lld", &N);
  if(prod_list[N] == 1){
    std::cout << "Yes" << std::endl;
  }
  else{
    std::cout << "No" << std::endl;
  }
  
  return 0;
  
}


Measured memory_bytes: 256
#include <iostream> // cin, cout, cerr, clog
#include <algorithm> // minmax, sort, swap
#include <numeric> // iota, accumulate, inner_product
#include <cstdio> // printf, scanf
#include <climits> // INT_MIN, LLONG_MIN
#include <cmath> // long, trig, pow
#include <string> // string, stoi, to_string
#include <vector> // vector
#include <queue> // queue, priority_queue
#include <deque> // deque
#include <stack> // stack
#include <map> // key-value pairs sorted by keys
#include <set> // set
#include <unordered_map> // hashed by keys
#include <unordered_set> // hashed by keys
#include <iomanip> // cout<<setprecision(n)
#include <functional> // std::function<void(int)>

#define rep(i,n) for(int i = 0; i < n; i++)
#define ENDL "\n"
#define print(i) std::cout << (i) << "\n"

#define int long long // at least int64 > 9*10^18
#define all(v) v.begin(), v.end()

signed main() {
	int n;
	std::cin >> n;
	std::vector<int> a(n+1);
	rep(i,n) std::cin >> a[i+1];
	int ballcount = 0;
	for(int i = n; i>=1; i--) {
		
		for(int j=2;i*j<=n;j++) {
			a[i] ^= a[i*j];
		}
		if(a[i]) ballcount++;
	}
	print(ballcount);
	for(int i=1;i<=n;i++) {
		if(a[i]) std::cout << i << ' ';
	}

	return 0;
}


Measured memory_bytes: 2432
using System;
using System.Linq;

class Bmondai
{
    static void Main()
    {
        Console.ReadLine();
        var line = Console.ReadLine().Split(' ').Select(x => Int32.Parse(x));
        var max = line.Max(x=>x);
        var sum = line.Sum()-max;
        Console.WriteLine(max<sum?"Yes":"No");
    }
}

Measured memory_bytes: 11348
#include<iostream>
#include<map>
#include<unordered_map>
#include<set>
#include<vector>
#include<algorithm>
#include<cmath>
#include<string>
#include<queue>
#include<stack>

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef long double ld;
#define mp make_pair
#define pb push_back

#define rep(i, N) for(ll i = 0; i < N; i++)
#define repa(i, a, N) for(ll i = a; i < N; i++)
#define repr(i, N) for(ll i = N-1; i >= 0; i--)

#define drep(i, N, j, M) rep(i, N) rep(j, M)
#define trep(i, N, j, M, k, L) rep(i, N) rep(j, M) rep(k, L)

#define all(A) A.begin(), A.end()

// const ll mod = 1e9 + 7;
const ll mod = 998244353;

const ll LLMAX = numeric_limits<long long>::max();

void No() {
	cout << "No" << endl;
}

void Yes() {
	cout << "Yes" << endl;
}

ll id(char c) {
	return c - 'a';
}

template<class t, class u>
ostream& operator<<(ostream& os, const pair<t, u>& p) {
	return os << "{" << p.first << "," << p.second << "}";
}

template<class t> ostream& operator<<(ostream& os, const vector<t>& v) {
	os << "{";
	for (auto e : v)os << e << ",";
	return os << "}";
}

int main() {
	ll N;

	cin >> N;
	ll ans = N;

	char c; cin >> c;
	rep(i, N-1) {
		char t;
		cin >> t;
		if (t == c) {
			ans--;
		}
		else {
			c = t;
		}
	}

	cout << ans<< endl;
	return 0;
}

Measured memory_bytes: 256
N, K = map(int, input().split())

if K % 2 == 0:
	cnt1 = 0
	cnt2 = 0
	for i in range(1, N+1):
		if i % K == 0: cnt1 += 1
		elif i % (K/2) == 0: cnt2 += 1
	print(cnt1**3 + cnt2**3)

else:
	cnt = 0
	for i in range(1, N+1):
		if i % K == 0: cnt += 1
	print(cnt**3)

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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef tuple<int, int> duo;
const int dx[] = {0, 0, 1, -1, 1, 1, -1, -1};
const int dy[] = {1, -1, 0, 0, 1, -1, 1, -1};
const int Mod = 1000000000 + 0;
//{{{ templates
#define TT_ template<typename T>inline
#define TTF_ template<typename T,typename F>inline
TT_ T sq(T x){return x*x;}
TT_ T In(){T x;cin>>x;return x;}
TT_ void Out(T&x){cout<<x;}
TT_ void sort(T&v){sort(begin(v),end(v));}
TT_ void revs(T&v){reverse(begin(v),end(v));}
TT_ void uniq(T&v){sort(v);v.erase(unique(begin(v),end(v)),end(v));}
TT_ int ubnd(T&v,typename T::value_type x){return upper_bound(begin(v),end(v),x)-begin(v);}
TT_ int lbnd(T&v,typename T::value_type x){return lower_bound(begin(v),end(v),x)-begin(v);}
TTF_ void inpt(T&v,int n,F f){for(v.reserve(n);n--;v.emplace_back(f()));}
TTF_ void show(T&v,F f,string d=" ",string e="\n"){int i=0;for(auto&x:v)i++&&(cout<<d),f(x);cout<<e;}
TT_ typename T::iterator minel(T&v){return min_element(begin(v),end(v));}
TT_ typename T::iterator maxel(T&v){return max_element(begin(v),end(v));}

inline void fast_io(){ios::sync_with_stdio(0);cin.tie(0);}
inline int in(){int x;scanf("%d",&x);return x;}
inline ll pow_mod(ll a,ll k,ll m){ll r=1;for(;k>0;a=a*a%m,k>>=1)if(k&1)r=r*a%m;return r;}
inline ll mod_inv(ll a,ll p){return pow_mod(a,p-2,p);}
//}}} priority_queue queue deque front stringstream max_element min_element insert count make_tuple

struct P {
  int x, y;
  void read(){ scanf("%d%d", &x, &y); }
  inline int dist(const P& a){ return sq(x - a.x) + sq(y - a.y); }
};
int closest_pair(P* a, int n){
  if (n <= 1) return 1 << 30;
  int m = n >> 1;
  int x = a[m].x;
  int d = min(closest_pair(a, m), closest_pair(a + m, n - m));
  inplace_merge(a, a + m, a + n, [](const P& a, const P& b){ return a.y < b.y; });
  deque<P> b;
  for (int i = 0; i < n; i++){
    if (sq(a[i].x - x) >= d) continue;
    for (const auto& bi : b){
      if (sq(a[i].y - bi.y) >= d) break;
      d = min(d, a[i].dist(bi));
    }
    b.push_front(a[i]);
  }
  return d; 
}
P A[500500];
int main()
{
  int n = in();
  for (int i = 0; i < n; i++) A[i].read();
  sort(A, A + n, [](const P& a, const P& b){ return a.x != b.x ? a.x < b.x : a.y < b.y; });
  cout << closest_pair(A, n) << endl;
  return 0;
}

Measured memory_bytes: 8384
#include <stdio.h>

int n;
int binarySearch(int A[],int);

int main(){

  int S[1000003],q,i,s=0;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&S[i]);
  }
  scanf("%d",&q);
  int T[q];
  for(i=0;i<q;i++){
    scanf("%d",&T[i]);
  }

  for(i=0;i<q;i++)
    {
      if(binarySearch(S,T[i])==1)
	s++;
    }

  printf("%d\n",s);

  return 0;
}

int binarySearch(int A[],int key)
{
  int right=n;
  int left=0;
  int m;
  while(left<right){
    m=(left+right)/2;
    if(A[m]==key){
      return 1;
    }
    else if(A[m]>key){
      right=m;
    }
    else if(A[m]<key){
      left=m+1;
    }
  }
  return 0;
}
    
  
  
  



Measured memory_bytes: 2300
n = input()
a = map(int, raw_input().split())
a.sort()
ok = 0
# print a

if n % 2 == 1:
	for i in range(len(a)):
		if (i % 2 == 0 and a[i] != i) or (i % 2 == 1 and a[i] != i + 1):
			print 0
			ok = 1
			break

if n % 2 == 0:
	for i in range(len(a)):
		if (i % 2 == 1 and a[i] != i) or (i % 2 == 0 and a[i] != i + 1):
			print 0
			ok = 1
			break

if ok == 0:
	# print pow(2, n / 2)
	print pow((2 % 1000000007), ((n / 2) % 1000000006)) % 1000000007

Measured memory_bytes: 11328
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main{

	public static void main(String[] args) throws Exception {
		// TODO ?????????????????????????????????????????????
		int game=0,i=0,person=0;
		int[] target=null;
		boolean first=true;
		int[] score = null;
		try (BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {
            String line;
            while ((line = br.readLine()) != null ) {
            	if(first){
            		person=Integer.parseInt(line);
            		game=Integer.parseInt(br.readLine());
                	String[] str=br.readLine().split(" ");
                	target=new int[str.length];
                	for(int k=0;k<str.length;k++){
                		target[k]=Integer.parseInt(str[k]);
                	}
                	score=new int[person+1];
                	first=false;
            	}else{
            		String[] str=line.split(" ");
            		int hazure=0;
            		for(int k=1;k<score.length;k++){
            			if(Integer.parseInt(str[k-1])==target[i]){
            				score[k]++;
            			}else{
            				hazure++;
            			}
            		}
            			score[target[i]]+=hazure;

            		i++;
            		if(i==game){
            			for(int k=1;k<score.length;k++){
            				System.out.println(score[k]);
            			}
            			break;
            		}
            	}
            }
		}
	}

}

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

#define int long long

const int N = 2e5 + 1;

int t[N * 4], n;
int h[N], a[N];

void upd(int v, int l, int r, int val, int ql, int qr)
{
	if(r < ql || qr < l) return;

	if(l == r) {
		t[v] = max(t[v], val);
		return;
	}
	
	int mid = l + r >> 1;
	
	upd(v + v, l, mid, val, ql, qr);
	upd(v + v + 1, mid + 1, r, val, ql, qr);
	
	t[v] = max(t[v + v], t[v + v + 1]);
}

int get(int v, int l, int r, int ql, int qr)
{
	if(r < ql || qr < l)
		return 0;

	if(ql <= l && r <= qr)
		return t[v];
	
	int mid = l + r >> 1;
	
	return max(get(v + v, l, mid, ql, qr), get(v + v + 1, mid + 1, r, ql, qr));
	
}

main()
{
	cin >> n;
	
	for(int i = 1; i <= n; i++)
		cin >> h[i];
	
	for(int i = 1; i <= n; i++)
		cin >> a[i];
	
	for(int i = 1; i <= n; i++)
	{
		int mx = 0;
		if(h[i] != 1)
			mx = get(1, 0, n, 1, h[i] - 1);
		
		upd(1, 0, n, a[i] + mx, h[i], h[i]);
	}
	
	int mx = 0;
	for(int i = 1; i <= n; i++)
		mx = max(mx, get(1, 0, n, h[i], h[i]));
	
	cout << mx << endl;/// try to edit t[1] to findmx
}


Measured memory_bytes: 8448
from operator import itemgetter
import bisect


def cross(a, b):
    l = max(a[0], b[0])
    r = min(a[1], b[1])
    if l <= r:
        return (l, r)
    else:
        return (-1, -2)
    
n = int(input())
info = [list(map(int, input().split())) for i in range(n)]
info = sorted(info, key = itemgetter(1))
max_ans = 0

l_ans = [(0, 10**9)]
for i in range(n):
    tmp = cross(l_ans[-1], info[i])
    l_ans.append(tmp)

r_ans = [(0, 10**9)]
for i in range(n)[::-1]:
    tmp = cross(r_ans[-1], info[i])
    r_ans.append(tmp)
r_ans = r_ans[::-1]

for i in range(1,n):
    ans = (l_ans[i][1] - l_ans[i][0]) + (r_ans[i][1] - r_ans[i][0]) + 2
    max_ans = max(ans, max_ans)
    
for i in range(n):
    ans = info[i][1] - info[i][0] + 1
    tmp = cross(l_ans[i], r_ans[i+1])
    ans += tmp[1] - tmp[0] + 1
    max_ans = max(ans, max_ans)

info = sorted(info)
l_ans = [(0, 10**9)]
for i in range(n):
    tmp = cross(l_ans[-1], info[i])
    l_ans.append(tmp)

r_ans = [(0, 10**9)]
for i in range(n)[::-1]:
    tmp = cross(r_ans[-1], info[i])
    r_ans.append(tmp)
r_ans = r_ans[::-1]

for i in range(1,n):
    ans = (l_ans[i][1] - l_ans[i][0]) + (r_ans[i][1] - r_ans[i][0]) + 2
    max_ans = max(ans, max_ans)
print(max_ans)

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



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

    if(n&1)
    {
        cout << 0 << endl;
        return 0;
    }

    long long d = 10 ;

    long long c = 0, rem;

    do{
        rem = n / d;
        c += rem;
        d = d * 5;

    }while(rem > 0);

    cout << c << endl;

    return 0;
}

Measured memory_bytes: 256
import java.util.*;
import java.util.stream.*;

public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int[] a = new int[3];
		a[0] = in.nextInt();
		a[1] = in.nextInt();
		a[2] = in.nextInt();
		Arrays.sort(a);
		System.out.println(a[2] * 10 + a[1] + a[0]);
	}
}

Measured memory_bytes: 23764
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <stack>
#include <queue>
#include <utility>
#include <map>
#include <set>
#include <functional>
#include <deque>
typedef long long ll;
using namespace std;
const int MOD = 1000000007;
int n;
vector<string> ans;
void dfs(int cnt,int mx,string now){
    if(n == cnt){
        ans.push_back(now);
        return;
    }

    for(int i = 0;i <= mx+1;i++){
        dfs(cnt+1,max(mx,i),now+(char)('a'+i));
    }
}
int main(){
    cin >> n;
    dfs(1,0,"a");
    sort(ans.begin(),ans.end());
    for(string s:ans)cout << s << endl;
}


Measured memory_bytes: 7796
#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define fi first
#define se second
#define mp make_pair
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,K,Q,A,B,L,R;
string S,T;
const ll MOD = (1e+9) + 7;
const ll INF = 1LL << 60;
typedef pair<ll,ll> P;

typedef vector<P> vp;
typedef vector<vp> matP;

int main(){
    cin>>S;
    ll ans = 7;
    rep(i,3) ans += S[i] == 'o';
    cout<<ans*100<<endl;
}

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


struct union_find2_2{
    vector<int> par;
    union_find2_2(int sz){
        par.resize(sz);
        for(int i=0;i<sz;++i) par[i]=i;
    }
    int find(int a){//根を探す
        if(par[a]==a) return a;
        else return par[a] = find(par[a]); 
    }
    void unite(int a,int b){
        int root_a = find(a),root_b = find(b); 
        par[root_a] = root_b;                   
    }
    bool same(int a,int b){
        return find(a)==find(b);
    }
};
int main(){
    int n , q ;
    cin >> n >> q;
    union_find2_2 uf(n);
    for(int i=0;i<q;i++){
        int c , x , y;
        cin >> c >> x >> y;
        if(c) cout << uf.same(x,y) << endl;
        else uf.unite(x,y);
    }
}


Measured memory_bytes: 3188
#include<stdio.h>

int main(void){
  int A,B,C,K;
  int max=0;
  int i;
  
  scanf("%d %d %d %d",&A,&B,&C,&K);
  i = A+B;
  
  if(K<=i){
    if(K<=A){
      max = K;
    }
    else{
      max = A;
    }
  }
  else{
    K = K-i;
    max = A-K;
  }
  
  printf("%d",max);
  
  return 0;
}

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

// Template START
#define endl "\n"
#define async ios_base::sync_with_stdio(false); cin.tie(NULL);
#define int long long int
#define all(y) y.begin(), y.end()
#define present( x, y ) (x.find( y ) != x.end())
const int mod = (int)1e9 + 7 ;
template<class T>
auto matrix( int r, int c, T v ){
    return vector<vector<T>>( r, vector<T>( c, v ) ) ;
}
template<class T>
auto matrix( int o1, int o2, int o3, T v ){ 
    return vector<vector<vector<T>>>( o1, vector<vector<T>>( o2, vector<T>( o3, v ) ) ) ;
}
#define v vector
int power( int x, int n ){
    if( n == 0 ) return 1 ;
    else if( n & 1 ) return ( x * power( (x*x) % mod, n / 2 ) ) % mod ;
    return power( (x*x) % mod, n / 2 ) % mod ;
}
// Template END

signed main(){
    int k ; cin >> k ;
    string add = "ACL" ;
    string res = "" ;
    for( int i = 0 ; i < k ; i++ ) res += add ;
    cout << res ;
    return 0 ;   
}          

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

int main() {
    int N, Q;
    string S;
    cin >> N >> Q >> S;
    vector<pair<int, int> > num(Q);
    for(int i = 0; i < Q; i++) {
        cin >> num[i].first;
        cin >> num[i].second;
    }
    char first, second;
    vector<int> start;
    for(int i = 0; i < N-1; i++) {
        first = S[i];
        second = S[i+1];
        if(S[i] == 'A' && S[i+1] == 'C') {
            start.push_back(i);
        }
    }
    
    for(int i = 0; i < Q; i++) {
        int count = 0;
        vector<int>::iterator first_itr = lower_bound(start.begin(), start.end(), num[i].first-1);
        vector<int>::iterator last_itr = lower_bound(start.begin(), start.end(), num[i].second-1);

        count = distance(first_itr, last_itr);
        cout << count << endl;
    }
    return 0;
}

Measured memory_bytes: 2044
#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;

typedef long long ll;

#define sz size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(c) (c).begin(), (c).end()
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define per(i,a,b) for(ll i=b-1LL;i>=(a);--i)
#define clr(a, b) memset((a), (b) ,sizeof(a))
#define ctos(c) string(1,c)
#define print(x) cout<<#x<<" = "<<x<<endl;

#define MOD 1000000007

ll d[200100];

long long modpow(long long a, long long b) {
	long long r = 1LL;
	while (b) {
		if (b & 1LL)r *= a;
		if (r >= MOD)r %= MOD;
		a *= a;
		if (a >= MOD)a %= MOD;
		b >>= 1LL;
	}
	return r % MOD;
}

#define N_MAX 200100

long long fact[N_MAX];
long long rfact[N_MAX];

long long nCr(long long n, long long r) {
	long long ret = 1LL;
	ret *= fact[n];
	ret %= MOD;
	ret *= rfact[r];
	ret %= MOD;
	ret *= rfact[n - r];
	ret %= MOD;
	return ret;
}

int main() {
	clr(fact, 0);
	fact[0] = 1;
	rep(i, 1, N_MAX) {
		fact[i] = fact[i - 1] * i;
		fact[i] %= MOD;
	}
	clr(rfact, 0);
	rfact[0] = 1;
	rep(i, 1, N_MAX) {
		rfact[i] = rfact[i - 1] * modpow(i, MOD - 2);
		rfact[i] %= MOD;
	}
	ll half = 1LL * modpow(2, MOD - 2);
	clr(d, 0);
	ll b, w;
	cin >> b >> w;
	ll n = b + w;
	rep(i, 0, n - 1) {
		ll a = n - i - 1;
		// black
		if (b >= a) {
			ll b1 = b - a;
			ll b2 = a;
			ll w1 = w - 1;
			ll p1 = modpow(half, n - a);
			ll p3 = nCr(b1 + w1, b1);
			if (b1 > 0) {
				ll p2 = nCr(b1 + w1 - 1, b1 - 1);
				d[0] += p1 * p2 % MOD;
				d[0] %= MOD;
				d[i] += MOD - p1 * p2 % MOD;
				d[i] %= MOD;
			}
			d[i + 1] += p1 * p3;
			d[i + 1] %= MOD;
		}
		// white
		if (w >= a) {
			ll w1 = w - a;
			ll w2 = a;
			ll b1 = b - 1;
			ll p1 = modpow(half, n - a);
			ll p3 = nCr(b1 + w1, b1);
			if (b1 > 0) {
				ll p2 = nCr(b1 + w1 - 1, b1 - 1);
				d[0] += p1 * p2 % MOD;
				d[0] %= MOD;
				d[i] += MOD - p1 * p2 % MOD;
				d[i] %= MOD;
			}
			d[i] += p1 * p3 % MOD;
			d[i] %= MOD;
			d[i + 1] += MOD - p1 * p3 % MOD;
			d[i + 1] %= MOD;
		}
	}
	rep(i, 1, 200100) {
		d[i] += d[i - 1];
		d[i] %= MOD;
	}
	rep(i, 0, n) {
		cout << d[i] << endl;
	}
	return 0;
}

Measured memory_bytes: 6912
N, D  = map(int, input().split())

X = []
for _ in range(N):
    x = list(map(int, input().split()))
    X.append(x)
    

import math

ans = 0
for i, x_i in enumerate(X):
    for j, x_j in enumerate(X[i+1:]):
        l = sum([ (a-b)**2 for a, b in zip(x_i, x_j)])
        ans += math.sqrt(l).is_integer()
        
print(ans)

Measured memory_bytes: 38256
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;

int main() {
  int n, m, p;
  while (cin >> n >> m >> p && n) {
    int sum = 0;
    int dl[n];
    rep(i, n) {
      cin >> dl[i];
      sum += dl[i];
    }
    if (dl[m - 1] == 0) {
      cout << 0 << endl;
    } else {
      cout << sum * (100 - p) / dl[m - 1] << endl;
    }
  }
  return 0;
}



Measured memory_bytes: 3092